aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2006-01-07 03:50:18 -0500
committerLen Brown <len.brown@intel.com>2006-01-07 03:50:18 -0500
commited03f430cdc8c802652467e9097606fedc2c7abc (patch)
tree30941ec1e6f93e99358fefe18175e5dd800a4379 /drivers
parented349a8a0a780ed27e2a765f16cee54d9b63bfee (diff)
parent6f957eaf79356a32e838f5f262ee9a60544b1d5b (diff)
Pull pnpacpi into acpica branch
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acorn/char/pcf8583.c5
-rw-r--r--drivers/acpi/container.c8
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/processor_core.c8
-rw-r--r--drivers/acpi/processor_thermal.c4
-rw-r--r--drivers/acpi/scan.c14
-rw-r--r--drivers/atm/adummy.c2
-rw-r--r--drivers/base/Kconfig4
-rw-r--r--drivers/base/bus.c41
-rw-r--r--drivers/base/class.c66
-rw-r--r--drivers/base/core.c42
-rw-r--r--drivers/base/cpu.c4
-rw-r--r--drivers/base/dd.c15
-rw-r--r--drivers/base/firmware_class.c45
-rw-r--r--drivers/base/memory.c20
-rw-r--r--drivers/base/platform.c68
-rw-r--r--drivers/base/power/runtime.c3
-rw-r--r--drivers/block/DAC960.c2
-rw-r--r--drivers/block/Kconfig5
-rw-r--r--drivers/block/cciss.c9
-rw-r--r--drivers/block/cpqarray.c2
-rw-r--r--drivers/block/floppy.c2
-rw-r--r--drivers/block/loop.c23
-rw-r--r--drivers/block/nbd.c124
-rw-r--r--drivers/block/paride/Kconfig5
-rw-r--r--drivers/block/rd.c4
-rw-r--r--drivers/block/sx8.c2
-rw-r--r--drivers/block/ub.c439
-rw-r--r--drivers/block/viodasd.c2
-rw-r--r--drivers/bluetooth/bcm203x.c1
-rw-r--r--drivers/bluetooth/bfusb.c1
-rw-r--r--drivers/bluetooth/bluecard_cs.c109
-rw-r--r--drivers/bluetooth/bpa10x.c1
-rw-r--r--drivers/bluetooth/bt3c_cs.c110
-rw-r--r--drivers/bluetooth/btuart_cs.c110
-rw-r--r--drivers/bluetooth/dtl1_cs.c111
-rw-r--r--drivers/bluetooth/hci_usb.c1
-rw-r--r--drivers/cdrom/cdu31a.c2
-rw-r--r--drivers/char/.gitignore2
-rw-r--r--drivers/char/Kconfig24
-rw-r--r--drivers/char/drm/radeon_cp.c2
-rw-r--r--drivers/char/drm/radeon_drv.h1
-rw-r--r--drivers/char/hangcheck-timer.c2
-rw-r--r--drivers/char/hw_random.c70
-rw-r--r--drivers/char/ip2/i2pack.h2
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c6
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c6
-rw-r--r--drivers/char/keyboard.c10
-rw-r--r--drivers/char/mmtimer.c90
-rw-r--r--drivers/char/mwave/mwavepub.h2
-rw-r--r--drivers/char/n_hdlc.c2
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c175
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c151
-rw-r--r--drivers/char/pcmcia/synclink_cs.c132
-rw-r--r--drivers/char/random.c10
-rw-r--r--drivers/char/vc_screen.c2
-rw-r--r--drivers/char/watchdog/Kconfig2
-rw-r--r--drivers/char/watchdog/booke_wdt.c15
-rw-r--r--drivers/char/watchdog/ixp4xx_wdt.c4
-rw-r--r--drivers/char/watchdog/mpcore_wdt.c4
-rw-r--r--drivers/char/watchdog/pcwd_usb.c1
-rw-r--r--drivers/char/watchdog/wdrtas.c2
-rw-r--r--drivers/connector/cn_proc.c5
-rw-r--r--drivers/cpufreq/cpufreq.c24
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c10
-rw-r--r--drivers/cpufreq/cpufreq_ondemand.c10
-rw-r--r--drivers/fc4/Kconfig8
-rw-r--r--drivers/firmware/dell_rbu.c6
-rw-r--r--drivers/hwmon/Kconfig12
-rw-r--r--drivers/hwmon/Makefile1
-rw-r--r--drivers/hwmon/adm1021.c6
-rw-r--r--drivers/hwmon/adm1025.c10
-rw-r--r--drivers/hwmon/adm1026.c10
-rw-r--r--drivers/hwmon/adm1031.c6
-rw-r--r--drivers/hwmon/adm9240.c6
-rw-r--r--drivers/hwmon/asb100.c6
-rw-r--r--drivers/hwmon/atxp1.c6
-rw-r--r--drivers/hwmon/ds1621.c6
-rw-r--r--drivers/hwmon/fscher.c6
-rw-r--r--drivers/hwmon/fscpos.c6
-rw-r--r--drivers/hwmon/gl518sm.c6
-rw-r--r--drivers/hwmon/gl520sm.c6
-rw-r--r--drivers/hwmon/hwmon-vid.c69
-rw-r--r--drivers/hwmon/it87.c18
-rw-r--r--drivers/hwmon/lm63.c6
-rw-r--r--drivers/hwmon/lm75.c6
-rw-r--r--drivers/hwmon/lm77.c6
-rw-r--r--drivers/hwmon/lm78.c13
-rw-r--r--drivers/hwmon/lm80.c6
-rw-r--r--drivers/hwmon/lm83.c6
-rw-r--r--drivers/hwmon/lm85.c50
-rw-r--r--drivers/hwmon/lm87.c6
-rw-r--r--drivers/hwmon/lm90.c6
-rw-r--r--drivers/hwmon/lm92.c6
-rw-r--r--drivers/hwmon/max1619.c6
-rw-r--r--drivers/hwmon/pc87360.c7
-rw-r--r--drivers/hwmon/sis5595.c8
-rw-r--r--drivers/hwmon/smsc47b397.c8
-rw-r--r--drivers/hwmon/smsc47m1.c7
-rw-r--r--drivers/hwmon/via686a.c8
-rw-r--r--drivers/hwmon/vt8231.c862
-rw-r--r--drivers/hwmon/w83627ehf.c7
-rw-r--r--drivers/hwmon/w83627hf.c23
-rw-r--r--drivers/hwmon/w83781d.c13
-rw-r--r--drivers/hwmon/w83792d.c83
-rw-r--r--drivers/hwmon/w83l785ts.c6
-rw-r--r--drivers/i2c/busses/i2c-i801.c6
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c1
-rw-r--r--drivers/i2c/busses/i2c-isa.c10
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c44
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c2
-rw-r--r--drivers/i2c/busses/i2c-parport.h12
-rw-r--r--drivers/i2c/chips/ds1337.c43
-rw-r--r--drivers/i2c/chips/ds1374.c6
-rw-r--r--drivers/i2c/chips/eeprom.c6
-rw-r--r--drivers/i2c/chips/isp1301_omap.c6
-rw-r--r--drivers/i2c/chips/m41t00.c6
-rw-r--r--drivers/i2c/chips/max6875.c6
-rw-r--r--drivers/i2c/chips/pca9539.c6
-rw-r--r--drivers/i2c/chips/pcf8574.c6
-rw-r--r--drivers/i2c/chips/pcf8591.c6
-rw-r--r--drivers/i2c/chips/rtc8564.c43
-rw-r--r--drivers/i2c/chips/tps65010.c6
-rw-r--r--drivers/i2c/chips/x1205.c6
-rw-r--r--drivers/i2c/i2c-core.c70
-rw-r--r--drivers/i2c/i2c-dev.c63
-rw-r--r--drivers/ide/Kconfig10
-rw-r--r--drivers/ide/ide-cd.c12
-rw-r--r--drivers/ide/ide-cd.h1
-rw-r--r--drivers/ide/ide-disk.c142
-rw-r--r--drivers/ide/ide-dma.c15
-rw-r--r--drivers/ide/ide-floppy.c1
-rw-r--r--drivers/ide/ide-io.c11
-rw-r--r--drivers/ide/ide-tape.c1
-rw-r--r--drivers/ide/ide.c60
-rw-r--r--drivers/ide/legacy/ide-cs.c132
-rw-r--r--drivers/ide/mips/Makefile3
-rw-r--r--drivers/ide/mips/au1xxx-ide.c1498
-rw-r--r--drivers/ide/pci/sgiioc4.c8
-rw-r--r--drivers/ide/pci/via82cxxx.c1
-rw-r--r--drivers/ieee1394/.gitignore1
-rw-r--r--drivers/ieee1394/Kconfig23
-rw-r--r--drivers/ieee1394/Makefile2
-rw-r--r--drivers/ieee1394/csr1212.c21
-rw-r--r--drivers/ieee1394/csr1212.h2
-rw-r--r--drivers/ieee1394/dma.c73
-rw-r--r--drivers/ieee1394/dv1394.c13
-rw-r--r--drivers/ieee1394/eth1394.c20
-rw-r--r--drivers/ieee1394/highlevel.c18
-rw-r--r--drivers/ieee1394/hosts.c30
-rw-r--r--drivers/ieee1394/hosts.h163
-rw-r--r--drivers/ieee1394/ieee1394-ioctl.h8
-rw-r--r--drivers/ieee1394/ieee1394.h19
-rw-r--r--drivers/ieee1394/ieee1394_core.c827
-rw-r--r--drivers/ieee1394/ieee1394_core.h100
-rw-r--r--drivers/ieee1394/ieee1394_transactions.c389
-rw-r--r--drivers/ieee1394/iso.c102
-rw-r--r--drivers/ieee1394/nodemgr.c135
-rw-r--r--drivers/ieee1394/nodemgr.h18
-rw-r--r--drivers/ieee1394/ohci1394.c43
-rw-r--r--drivers/ieee1394/ohci1394.h4
-rw-r--r--drivers/ieee1394/pcilynx.c2
-rw-r--r--drivers/ieee1394/raw1394.c79
-rw-r--r--drivers/ieee1394/sbp2.c1040
-rw-r--r--drivers/ieee1394/sbp2.h70
-rw-r--r--drivers/ieee1394/video1394.c106
-rw-r--r--drivers/infiniband/core/sysfs.c16
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c2
-rw-r--r--drivers/input/evdev.c2
-rw-r--r--drivers/input/input.c54
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c1
-rw-r--r--drivers/input/joystick/warrior.c2
-rw-r--r--drivers/input/misc/Kconfig2
-rw-r--r--drivers/input/misc/wistron_btns.c2
-rw-r--r--drivers/input/mouse/alps.c2
-rw-r--r--drivers/input/mouse/sermouse.c2
-rw-r--r--drivers/input/serio/i8042.h2
-rw-r--r--drivers/input/serio/serio.c22
-rw-r--r--drivers/isdn/hardware/avm/avm_cs.c145
-rw-r--r--drivers/isdn/hisax/avma1_cs.c150
-rw-r--r--drivers/isdn/hisax/elsa_cs.c158
-rw-r--r--drivers/isdn/hisax/hfc_usb.c1
-rw-r--r--drivers/isdn/hisax/sedlbauer_cs.c169
-rw-r--r--drivers/isdn/hisax/st5481_init.c1
-rw-r--r--drivers/isdn/hisax/teles_cs.c149
-rw-r--r--drivers/macintosh/macio_asic.c4
-rw-r--r--drivers/macintosh/therm_adt746x.c45
-rw-r--r--drivers/macintosh/therm_pm72.c21
-rw-r--r--drivers/macintosh/therm_windtunnel.c6
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c13
-rw-r--r--drivers/macintosh/windfarm_pm81.c4
-rw-r--r--drivers/md/.gitignore4
-rw-r--r--drivers/md/bitmap.c114
-rw-r--r--drivers/md/dm-crypt.c5
-rw-r--r--drivers/md/dm-io.h3
-rw-r--r--drivers/md/dm-ioctl.c21
-rw-r--r--drivers/md/dm-log.c2
-rw-r--r--drivers/md/dm-raid1.c13
-rw-r--r--drivers/md/dm-snap.c25
-rw-r--r--drivers/md/dm-table.c2
-rw-r--r--drivers/md/dm.c95
-rw-r--r--drivers/md/dm.h5
-rw-r--r--drivers/md/faulty.c9
-rw-r--r--drivers/md/kcopyd.c3
-rw-r--r--drivers/md/linear.c14
-rw-r--r--drivers/md/md.c893
-rw-r--r--drivers/md/multipath.c22
-rw-r--r--drivers/md/raid0.c26
-rw-r--r--drivers/md/raid1.c731
-rw-r--r--drivers/md/raid10.c544
-rw-r--r--drivers/md/raid5.c181
-rw-r--r--drivers/md/raid6main.c348
-rw-r--r--drivers/media/common/Kconfig6
-rw-r--r--drivers/media/common/Makefile4
-rw-r--r--drivers/media/common/ir-common.c1
-rw-r--r--drivers/media/common/saa7146_core.c6
-rw-r--r--drivers/media/common/saa7146_fops.c32
-rw-r--r--drivers/media/common/saa7146_i2c.c16
-rw-r--r--drivers/media/common/saa7146_vbi.c4
-rw-r--r--drivers/media/common/saa7146_video.c46
-rw-r--r--drivers/media/dvb/b2c2/flexcop-common.h2
-rw-r--r--drivers/media/dvb/b2c2/flexcop-fe-tuner.c4
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c1
-rw-r--r--drivers/media/dvb/bt8xx/dst_ca.c6
-rw-r--r--drivers/media/dvb/bt8xx/dvb-bt8xx.c6
-rw-r--r--drivers/media/dvb/cinergyT2/cinergyT2.c3
-rw-r--r--drivers/media/dvb/dvb-core/demux.h92
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.c2
-rw-r--r--drivers/media/dvb/dvb-core/dmxdev.h64
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ca_en50221.c2
-rw-r--r--drivers/media/dvb/dvb-core/dvb_filter.c332
-rw-r--r--drivers/media/dvb/dvb-core/dvb_filter.h102
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c8
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.h8
-rw-r--r--drivers/media/dvb/dvb-core/dvb_net.c42
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ringbuffer.c262
-rw-r--r--drivers/media/dvb/dvb-core/dvb_ringbuffer.h20
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.c142
-rw-r--r--drivers/media/dvb/dvb-core/dvbdev.h6
-rw-r--r--drivers/media/dvb/dvb-usb/a800.c1
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c1
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mb.c1
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-mc.c1
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c1
-rw-r--r--drivers/media/dvb/dvb-usb/dtt200u.c1
-rw-r--r--drivers/media/dvb/dvb-usb/nova-t-usb2.c1
-rw-r--r--drivers/media/dvb/dvb-usb/umt-010.c1
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c2
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x.c1
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045-fe.c2
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045.c1
-rw-r--r--drivers/media/dvb/frontends/at76c651.c6
-rw-r--r--drivers/media/dvb/frontends/bcm3510.c4
-rw-r--r--drivers/media/dvb/frontends/cx22700.c10
-rw-r--r--drivers/media/dvb/frontends/cx22702.c2
-rw-r--r--drivers/media/dvb/frontends/cx22702.h2
-rw-r--r--drivers/media/dvb/frontends/cx24110.c312
-rw-r--r--drivers/media/dvb/frontends/l64781.c26
-rw-r--r--drivers/media/dvb/frontends/l64781.h2
-rw-r--r--drivers/media/dvb/frontends/lgdt330x.c8
-rw-r--r--drivers/media/dvb/frontends/mt312.c4
-rw-r--r--drivers/media/dvb/frontends/nxt2002.c6
-rw-r--r--drivers/media/dvb/frontends/nxt200x.c4
-rw-r--r--drivers/media/dvb/frontends/nxt6000.c10
-rw-r--r--drivers/media/dvb/frontends/or51132.c2
-rw-r--r--drivers/media/dvb/frontends/s5h1420.c6
-rw-r--r--drivers/media/dvb/frontends/s5h1420.h2
-rw-r--r--drivers/media/dvb/frontends/sp8870.c16
-rw-r--r--drivers/media/dvb/frontends/sp887x.c14
-rw-r--r--drivers/media/dvb/frontends/stv0299.c36
-rw-r--r--drivers/media/dvb/frontends/tda10021.c10
-rw-r--r--drivers/media/dvb/frontends/tda10021.h4
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c2
-rw-r--r--drivers/media/dvb/frontends/tda8083.c20
-rw-r--r--drivers/media/dvb/ttpci/av7110.c29
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.c20
-rw-r--r--drivers/media/dvb/ttpci/av7110_hw.h3
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c4
-rw-r--r--drivers/media/dvb/ttpci/budget-core.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-patch.c326
-rw-r--r--drivers/media/dvb/ttpci/budget.c6
-rw-r--r--drivers/media/dvb/ttpci/budget.h2
-rw-r--r--drivers/media/dvb/ttpci/fdump.c2
-rw-r--r--drivers/media/dvb/ttpci/ttpci-eeprom.c40
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c128
-rw-r--r--drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h3276
-rw-r--r--drivers/media/dvb/ttusb-dec/ttusb_dec.c4
-rw-r--r--drivers/media/video/Kconfig14
-rw-r--r--drivers/media/video/adv7170.c7
-rw-r--r--drivers/media/video/adv7175.c7
-rw-r--r--drivers/media/video/bt819.c7
-rw-r--r--drivers/media/video/bt832.c17
-rw-r--r--drivers/media/video/bt856.c7
-rw-r--r--drivers/media/video/bttv-driver.c82
-rw-r--r--drivers/media/video/bttv-i2c.c2
-rw-r--r--drivers/media/video/bttvp.h1
-rw-r--r--drivers/media/video/cpia_pp.c30
-rw-r--r--drivers/media/video/cpia_usb.c1
-rw-r--r--drivers/media/video/cs53l32a.c14
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c49
-rw-r--r--drivers/media/video/cx25840/cx25840.h7
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c2
-rw-r--r--drivers/media/video/cx88/cx88-i2c.c2
-rw-r--r--drivers/media/video/cx88/cx88-input.c2
-rw-r--r--drivers/media/video/cx88/cx88.h1
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c50
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c3
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c22
-rw-r--r--drivers/media/video/indycam.c6
-rw-r--r--drivers/media/video/ir-kbd-gpio.c8
-rw-r--r--drivers/media/video/ir-kbd-i2c.c16
-rw-r--r--drivers/media/video/msp3400.c36
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_core.c6
-rw-r--r--drivers/media/video/saa5246a.c13
-rw-r--r--drivers/media/video/saa5249.c13
-rw-r--r--drivers/media/video/saa6588.c8
-rw-r--r--drivers/media/video/saa7110.c7
-rw-r--r--drivers/media/video/saa7111.c7
-rw-r--r--drivers/media/video/saa7114.c7
-rw-r--r--drivers/media/video/saa7115.c14
-rw-r--r--drivers/media/video/saa711x.c9
-rw-r--r--drivers/media/video/saa7127.c23
-rw-r--r--drivers/media/video/saa7134/Kconfig26
-rw-r--r--drivers/media/video/saa7134/Makefile7
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c20
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c32
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c4
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c111
-rw-r--r--drivers/media/video/saa7185.c7
-rw-r--r--drivers/media/video/saa7191.c6
-rw-r--r--drivers/media/video/tda7432.c6
-rw-r--r--drivers/media/video/tda9840.c8
-rw-r--r--drivers/media/video/tda9875.c6
-rw-r--r--drivers/media/video/tda9887.c16
-rw-r--r--drivers/media/video/tea6415c.c8
-rw-r--r--drivers/media/video/tea6420.c8
-rw-r--r--drivers/media/video/tuner-3036.c6
-rw-r--r--drivers/media/video/tuner-core.c7
-rw-r--r--drivers/media/video/tvaudio.c37
-rw-r--r--drivers/media/video/tveeprom.c12
-rw-r--r--drivers/media/video/tvmixer.c12
-rw-r--r--drivers/media/video/tvp5150.c10
-rw-r--r--drivers/media/video/video-buf-dvb.c2
-rw-r--r--drivers/media/video/vpx3220.c7
-rw-r--r--drivers/media/video/wm8775.c11
-rw-r--r--drivers/media/video/zoran_driver.c14
-rw-r--r--drivers/message/fusion/mptbase.c14
-rw-r--r--drivers/message/fusion/mptbase.h34
-rw-r--r--drivers/message/fusion/mptctl.c4
-rw-r--r--drivers/message/fusion/mptfc.c24
-rw-r--r--drivers/message/fusion/mptsas.c55
-rw-r--r--drivers/message/fusion/mptscsih.c968
-rw-r--r--drivers/message/fusion/mptscsih.h2
-rw-r--r--drivers/message/fusion/mptspi.c24
-rw-r--r--drivers/message/i2o/Kconfig12
-rw-r--r--drivers/message/i2o/bus-osm.c23
-rw-r--r--drivers/message/i2o/config-osm.c2
-rw-r--r--drivers/message/i2o/core.h20
-rw-r--r--drivers/message/i2o/device.c339
-rw-r--r--drivers/message/i2o/driver.c12
-rw-r--r--drivers/message/i2o/exec-osm.c114
-rw-r--r--drivers/message/i2o/i2o_block.c190
-rw-r--r--drivers/message/i2o/i2o_config.c196
-rw-r--r--drivers/message/i2o/i2o_lan.h38
-rw-r--r--drivers/message/i2o/i2o_proc.c2
-rw-r--r--drivers/message/i2o/i2o_scsi.c89
-rw-r--r--drivers/message/i2o/iop.c356
-rw-r--r--drivers/message/i2o/pci.c13
-rw-r--r--drivers/mfd/ucb1x00-ts.c19
-rw-r--r--drivers/mmc/mmc.c15
-rw-r--r--drivers/mmc/mmc_block.c18
-rw-r--r--drivers/mmc/mmc_sysfs.c4
-rw-r--r--drivers/mtd/devices/blkmtd.c8
-rw-r--r--drivers/mtd/maps/Kconfig2
-rw-r--r--drivers/mtd/maps/pcmciamtd.c121
-rw-r--r--drivers/mtd/onenand/generic.c4
-rw-r--r--drivers/mtd/onenand/onenand_base.c53
-rw-r--r--drivers/mtd/onenand/onenand_bbt.c4
-rw-r--r--drivers/net/8139too.c86
-rw-r--r--drivers/net/Kconfig17
-rw-r--r--drivers/net/Makefile7
-rw-r--r--drivers/net/bonding/Makefile2
-rw-r--r--drivers/net/bonding/bond_3ad.c106
-rw-r--r--drivers/net/bonding/bond_3ad.h13
-rw-r--r--drivers/net/bonding/bond_alb.c75
-rw-r--r--drivers/net/bonding/bond_alb.h9
-rw-r--r--drivers/net/bonding/bond_main.c781
-rw-r--r--drivers/net/bonding/bond_sysfs.c1358
-rw-r--r--drivers/net/bonding/bonding.h52
-rw-r--r--drivers/net/chelsio/sge.c19
-rw-r--r--drivers/net/chelsio/sge.h2
-rw-r--r--drivers/net/e1000/e1000.h4
-rw-r--r--drivers/net/e1000/e1000_ethtool.c111
-rw-r--r--drivers/net/e1000/e1000_hw.c67
-rw-r--r--drivers/net/e1000/e1000_hw.h4
-rw-r--r--drivers/net/e1000/e1000_main.c64
-rw-r--r--drivers/net/forcedeth.c15
-rw-r--r--drivers/net/gianfar.c231
-rw-r--r--drivers/net/gianfar.h69
-rw-r--r--drivers/net/gianfar_ethtool.c2
-rw-r--r--drivers/net/gianfar_mii.h1
-rw-r--r--drivers/net/gianfar_sysfs.c311
-rw-r--r--drivers/net/irda/irda-usb.c1
-rw-r--r--drivers/net/irda/stir4200.c1
-rw-r--r--drivers/net/ixp2000/Kconfig6
-rw-r--r--drivers/net/ixp2000/Makefile3
-rw-r--r--drivers/net/ixp2000/caleb.c137
-rw-r--r--drivers/net/ixp2000/caleb.h22
-rw-r--r--drivers/net/ixp2000/enp2611.c245
-rw-r--r--drivers/net/ixp2000/ixp2400-msf.c213
-rw-r--r--drivers/net/ixp2000/ixp2400-msf.h115
-rw-r--r--drivers/net/ixp2000/ixp2400_rx.uc408
-rw-r--r--drivers/net/ixp2000/ixp2400_rx.ucode130
-rw-r--r--drivers/net/ixp2000/ixp2400_tx.uc272
-rw-r--r--drivers/net/ixp2000/ixp2400_tx.ucode98
-rw-r--r--drivers/net/ixp2000/ixpdev.c421
-rw-r--r--drivers/net/ixp2000/ixpdev.h27
-rw-r--r--drivers/net/ixp2000/ixpdev_priv.h57
-rw-r--r--drivers/net/ixp2000/pm3386.c334
-rw-r--r--drivers/net/ixp2000/pm3386.h28
-rw-r--r--drivers/net/ns83820.c1
-rw-r--r--drivers/net/pcmcia/3c574_cs.c124
-rw-r--r--drivers/net/pcmcia/3c589_cs.c136
-rw-r--r--drivers/net/pcmcia/axnet_cs.c128
-rw-r--r--drivers/net/pcmcia/com20020_cs.c142
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c128
-rw-r--r--drivers/net/pcmcia/ibmtr_cs.c152
-rw-r--r--drivers/net/pcmcia/nmclan_cs.c134
-rw-r--r--drivers/net/pcmcia/pcnet_cs.c129
-rw-r--r--drivers/net/pcmcia/smc91c92_cs.c195
-rw-r--r--drivers/net/pcmcia/xirc2ps_cs.c158
-rw-r--r--drivers/net/pcnet32.c5
-rw-r--r--drivers/net/phy/Kconfig2
-rw-r--r--drivers/net/phy/phy_device.c4
-rw-r--r--drivers/net/plip.c2
-rw-r--r--drivers/net/ppp_generic.c3
-rw-r--r--drivers/net/pppoe.c31
-rw-r--r--drivers/net/pppox.c10
-rw-r--r--drivers/net/s2io.c210
-rw-r--r--drivers/net/s2io.h3
-rw-r--r--drivers/net/sis900.c73
-rw-r--r--drivers/net/sis900.h45
-rw-r--r--drivers/net/sk98lin/Makefile3
-rw-r--r--drivers/net/sk98lin/h/skdrv2nd.h9
-rw-r--r--drivers/net/sk98lin/h/skvpd.h8
-rw-r--r--drivers/net/sk98lin/skethtool.c48
-rw-r--r--drivers/net/sk98lin/skge.c217
-rw-r--r--drivers/net/sk98lin/skproc.c265
-rw-r--r--drivers/net/skge.c91
-rw-r--r--drivers/net/skge.h73
-rw-r--r--drivers/net/sky2.c3262
-rw-r--r--drivers/net/sky2.h1922
-rw-r--r--drivers/net/sungem.c4
-rw-r--r--drivers/net/tg3.c269
-rw-r--r--drivers/net/tg3.h14
-rw-r--r--drivers/net/tlan.c4
-rw-r--r--drivers/net/wan/.gitignore1
-rw-r--r--drivers/net/wan/lmc/lmc_prot.h15
-rw-r--r--drivers/net/wireless/Kconfig6
-rw-r--r--drivers/net/wireless/airo.c15
-rw-r--r--drivers/net/wireless/airo_cs.c161
-rw-r--r--drivers/net/wireless/atmel.c1490
-rw-r--r--drivers/net/wireless/atmel_cs.c156
-rw-r--r--drivers/net/wireless/hostap/Makefile1
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c156
-rw-r--r--drivers/net/wireless/hostap/hostap_main.c (renamed from drivers/net/wireless/hostap/hostap.c)0
-rw-r--r--drivers/net/wireless/ipw2100.c40
-rw-r--r--drivers/net/wireless/ipw2100.h2
-rw-r--r--drivers/net/wireless/ipw2200.c36
-rw-r--r--drivers/net/wireless/ipw2200.h6
-rw-r--r--drivers/net/wireless/netwave_cs.c184
-rw-r--r--drivers/net/wireless/orinoco_cs.c208
-rw-r--r--drivers/net/wireless/orinoco_nortel.c6
-rw-r--r--drivers/net/wireless/ray_cs.c154
-rw-r--r--drivers/net/wireless/spectrum_cs.c175
-rw-r--r--drivers/net/wireless/wavelan_cs.c183
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h11
-rw-r--r--drivers/net/wireless/wl3501_cs.c133
-rw-r--r--drivers/parport/Kconfig2
-rw-r--r--drivers/parport/daisy.c51
-rw-r--r--drivers/parport/ieee1284_ops.c62
-rw-r--r--drivers/parport/parport_cs.c120
-rw-r--r--drivers/parport/parport_pc.c30
-rw-r--r--drivers/parport/probe.c199
-rw-r--r--drivers/parport/share.c1
-rw-r--r--drivers/pci/Makefile7
-rw-r--r--drivers/pci/hotplug.c44
-rw-r--r--drivers/pci/pci-driver.c6
-rw-r--r--drivers/pci/pci.h4
-rw-r--r--drivers/pci/quirks.c30
-rw-r--r--drivers/pcmcia/Kconfig32
-rw-r--r--drivers/pcmcia/au1000_generic.c21
-rw-r--r--drivers/pcmcia/cistpl.c36
-rw-r--r--drivers/pcmcia/cs.c112
-rw-r--r--drivers/pcmcia/cs_internal.h4
-rw-r--r--drivers/pcmcia/ds.c401
-rw-r--r--drivers/pcmcia/hd64465_ss.c13
-rw-r--r--drivers/pcmcia/i82092.c73
-rw-r--r--drivers/pcmcia/i82092aa.h1
-rw-r--r--drivers/pcmcia/i82365.c83
-rw-r--r--drivers/pcmcia/m32r_cfc.c32
-rw-r--r--drivers/pcmcia/m32r_pcc.c20
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c114
-rw-r--r--drivers/pcmcia/pd6729.c74
-rw-r--r--drivers/pcmcia/pxa2xx_mainstone.c3
-rw-r--r--drivers/pcmcia/pxa2xx_sharpsl.c3
-rw-r--r--drivers/pcmcia/rsrc_mgr.c108
-rw-r--r--drivers/pcmcia/rsrc_nonstatic.c140
-rw-r--r--drivers/pcmcia/soc_common.c23
-rw-r--r--drivers/pcmcia/socket_sysfs.c30
-rw-r--r--drivers/pcmcia/tcic.c61
-rw-r--r--drivers/pcmcia/ti113x.h4
-rw-r--r--drivers/pcmcia/vrc4171_card.c70
-rw-r--r--drivers/pcmcia/vrc4173_cardu.c43
-rw-r--r--drivers/pcmcia/yenta_socket.c140
-rw-r--r--drivers/pnp/card.c25
-rw-r--r--drivers/pnp/driver.c47
-rw-r--r--drivers/pnp/manager.c78
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c48
-rw-r--r--drivers/pnp/pnpbios/bioscalls.c45
-rw-r--r--drivers/pnp/pnpbios/core.c8
-rw-r--r--drivers/s390/Makefile2
-rw-r--r--drivers/s390/block/Kconfig8
-rw-r--r--drivers/s390/block/dasd.c34
-rw-r--r--drivers/s390/block/dasd_diag.c11
-rw-r--r--drivers/s390/block/dasd_diag.h31
-rw-r--r--drivers/s390/block/dasd_eckd.c9
-rw-r--r--drivers/s390/block/dasd_fba.c6
-rw-r--r--drivers/s390/block/dasd_int.h3
-rw-r--r--drivers/s390/block/dasd_ioctl.c5
-rw-r--r--drivers/s390/block/dcssblk.c2
-rw-r--r--drivers/s390/block/xpram.c4
-rw-r--r--drivers/s390/char/sclp_cpi.c2
-rw-r--r--drivers/s390/char/sclp_quiesce.c2
-rw-r--r--drivers/s390/char/tape_block.c4
-rw-r--r--drivers/s390/char/vmwatchdog.c2
-rw-r--r--drivers/s390/cio/blacklist.c234
-rw-r--r--drivers/s390/cio/blacklist.h2
-rw-r--r--drivers/s390/cio/ccwgroup.c10
-rw-r--r--drivers/s390/cio/chsc.c473
-rw-r--r--drivers/s390/cio/chsc.h13
-rw-r--r--drivers/s390/cio/cio.c168
-rw-r--r--drivers/s390/cio/cio.h11
-rw-r--r--drivers/s390/cio/cmf.c8
-rw-r--r--drivers/s390/cio/css.c297
-rw-r--r--drivers/s390/cio/css.h43
-rw-r--r--drivers/s390/cio/device.c51
-rw-r--r--drivers/s390/cio/device.h1
-rw-r--r--drivers/s390/cio/device_fsm.c29
-rw-r--r--drivers/s390/cio/device_id.c26
-rw-r--r--drivers/s390/cio/device_ops.c4
-rw-r--r--drivers/s390/cio/device_pgid.c56
-rw-r--r--drivers/s390/cio/device_status.c14
-rw-r--r--drivers/s390/cio/ioasm.h86
-rw-r--r--drivers/s390/cio/qdio.c713
-rw-r--r--drivers/s390/cio/qdio.h144
-rw-r--r--drivers/s390/cio/schid.h26
-rw-r--r--drivers/s390/crypto/z90common.h9
-rw-r--r--drivers/s390/crypto/z90crypt.h13
-rw-r--r--drivers/s390/crypto/z90hardware.c309
-rw-r--r--drivers/s390/crypto/z90main.c112
-rw-r--r--drivers/s390/net/Kconfig2
-rw-r--r--drivers/s390/net/claw.c6
-rw-r--r--drivers/s390/net/cu3088.c3
-rw-r--r--drivers/s390/net/iucv.c10
-rw-r--r--drivers/s390/net/qeth_eddp.c3
-rw-r--r--drivers/s390/net/qeth_main.c82
-rw-r--r--drivers/s390/net/qeth_mpc.c2
-rw-r--r--drivers/s390/net/qeth_mpc.h4
-rw-r--r--drivers/s390/net/qeth_proc.c250
-rw-r--r--drivers/s390/net/qeth_sys.c6
-rw-r--r--drivers/s390/net/qeth_tso.h4
-rw-r--r--drivers/s390/s390_rdev.c53
-rw-r--r--drivers/s390/s390mach.c66
-rw-r--r--drivers/s390/sysinfo.c2
-rw-r--r--drivers/sbus/char/jsflash.c19
-rw-r--r--drivers/sbus/char/uctrl.c10
-rw-r--r--drivers/sbus/char/vfc.h2
-rw-r--r--drivers/sbus/char/vfc_dev.c6
-rw-r--r--drivers/scsi/.gitignore3
-rw-r--r--drivers/scsi/53c700.c6
-rw-r--r--drivers/scsi/53c700.h22
-rw-r--r--drivers/scsi/53c7xx.c7
-rw-r--r--drivers/scsi/Kconfig23
-rw-r--r--drivers/scsi/NCR5380.c7
-rw-r--r--drivers/scsi/aha152x.c7
-rw-r--r--drivers/scsi/ahci.c15
-rw-r--r--drivers/scsi/aic7xxx/.gitignore6
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c11
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c18
-rw-r--r--drivers/scsi/arm/Kconfig1
-rw-r--r--drivers/scsi/arm/acornscsi.c7
-rw-r--r--drivers/scsi/ata_piix.c132
-rw-r--r--drivers/scsi/atari_NCR5380.c7
-rw-r--r--drivers/scsi/ch.c4
-rw-r--r--drivers/scsi/constants.c118
-rw-r--r--drivers/scsi/dpt_i2o.c25
-rw-r--r--drivers/scsi/hosts.c9
-rw-r--r--drivers/scsi/ibmvscsi/ibmvscsi.h2
-rw-r--r--drivers/scsi/ibmvscsi/iseries_vscsi.c3
-rw-r--r--drivers/scsi/ibmvscsi/rpa_vscsi.c8
-rw-r--r--drivers/scsi/ide-scsi.c4
-rw-r--r--drivers/scsi/ipr.c19
-rw-r--r--drivers/scsi/ipr.h5
-rw-r--r--drivers/scsi/iscsi_tcp.c123
-rw-r--r--drivers/scsi/iscsi_tcp.h3
-rw-r--r--drivers/scsi/libata-core.c511
-rw-r--r--drivers/scsi/libata-scsi.c84
-rw-r--r--drivers/scsi/libata.h5
-rw-r--r--drivers/scsi/lpfc/lpfc.h14
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c92
-rw-r--r--drivers/scsi/lpfc/lpfc_crtn.h3
-rw-r--r--drivers/scsi/lpfc/lpfc_disc.h2
-rw-r--r--drivers/scsi/lpfc/lpfc_els.c4
-rw-r--r--drivers/scsi/lpfc/lpfc_hbadisc.c18
-rw-r--r--drivers/scsi/lpfc/lpfc_hw.h40
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c183
-rw-r--r--drivers/scsi/lpfc/lpfc_nportdisc.c69
-rw-r--r--drivers/scsi/lpfc/lpfc_scsi.c295
-rw-r--r--drivers/scsi/lpfc/lpfc_sli.c217
-rw-r--r--drivers/scsi/lpfc/lpfc_version.h2
-rw-r--r--drivers/scsi/megaraid.c29
-rw-r--r--drivers/scsi/megaraid/Kconfig.megaraid2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c82
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.h4
-rw-r--r--drivers/scsi/ncr53c8xx.c749
-rw-r--r--drivers/scsi/ncr53c8xx.h1263
-rw-r--r--drivers/scsi/pcmcia/aha152x_stub.c99
-rw-r--r--drivers/scsi/pcmcia/fdomain_stub.c117
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c167
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h4
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c127
-rw-r--r--drivers/scsi/pcmcia/sym53c500_cs.c133
-rw-r--r--drivers/scsi/pdc_adma.c11
-rw-r--r--drivers/scsi/qla2xxx/Kconfig69
-rw-r--r--drivers/scsi/qla2xxx/Makefile5
-rw-r--r--drivers/scsi/qla2xxx/ql2400.c111
-rw-r--r--drivers/scsi/qla2xxx/ql2400_fw.c12376
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h34
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c254
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c15
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c196
-rw-r--r--drivers/scsi/raid_class.c2
-rw-r--r--drivers/scsi/sata_mv.c15
-rw-r--r--drivers/scsi/sata_nv.c1
-rw-r--r--drivers/scsi/sata_promise.c33
-rw-r--r--drivers/scsi/sata_qstor.c9
-rw-r--r--drivers/scsi/sata_sil.c3
-rw-r--r--drivers/scsi/sata_sil24.c16
-rw-r--r--drivers/scsi/sata_sis.c1
-rw-r--r--drivers/scsi/sata_svw.c1
-rw-r--r--drivers/scsi/sata_sx4.c21
-rw-r--r--drivers/scsi/sata_uli.c1
-rw-r--r--drivers/scsi/sata_via.c1
-rw-r--r--drivers/scsi/sata_vsc.c1
-rw-r--r--drivers/scsi/scsi_devinfo.c5
-rw-r--r--drivers/scsi/scsi_error.c54
-rw-r--r--drivers/scsi/scsi_lib.c346
-rw-r--r--drivers/scsi/scsi_priv.h4
-rw-r--r--drivers/scsi/scsi_scan.c54
-rw-r--r--drivers/scsi/scsi_sysfs.c35
-rw-r--r--drivers/scsi/scsi_transport_fc.c67
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c2
-rw-r--r--drivers/scsi/scsi_transport_spi.c136
-rw-r--r--drivers/scsi/sd.c105
-rw-r--r--drivers/scsi/sg.c686
-rw-r--r--drivers/scsi/sr.c22
-rw-r--r--drivers/scsi/sr_vendor.c4
-rw-r--r--drivers/scsi/st.c296
-rw-r--r--drivers/scsi/st.h14
-rw-r--r--drivers/scsi/sun3_NCR5380.c7
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_defs.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw.c18
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw.h6
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw1.h48
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_fw2.h52
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c117
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c168
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.h104
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_malloc.c4
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_nvram.c29
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_nvram.h4
-rw-r--r--drivers/scsi/sym53c8xx_comm.h792
-rw-r--r--drivers/scsi/sym53c8xx_defs.h1320
-rw-r--r--drivers/serial/8250_pci.c2
-rw-r--r--drivers/serial/Kconfig10
-rw-r--r--drivers/serial/amba-pl011.c2
-rw-r--r--drivers/serial/mpc52xx_uart.c28
-rw-r--r--drivers/serial/pxa.c4
-rw-r--r--drivers/serial/serial_cs.c119
-rw-r--r--drivers/telephony/ixj_pcmcia.c112
-rw-r--r--drivers/usb/Makefile1
-rw-r--r--drivers/usb/atm/Kconfig13
-rw-r--r--drivers/usb/atm/Makefile1
-rw-r--r--drivers/usb/atm/cxacru.c1
-rw-r--r--drivers/usb/atm/speedtch.c1
-rw-r--r--drivers/usb/atm/ueagle-atm.c1820
-rw-r--r--drivers/usb/atm/usbatm.c4
-rw-r--r--drivers/usb/atm/xusbatm.c1
-rw-r--r--drivers/usb/class/audio.c1
-rw-r--r--drivers/usb/class/cdc-acm.c232
-rw-r--r--drivers/usb/class/cdc-acm.h33
-rw-r--r--drivers/usb/class/usb-midi.c1
-rw-r--r--drivers/usb/class/usblp.c47
-rw-r--r--drivers/usb/core/Makefile2
-rw-r--r--drivers/usb/core/buffer.c3
-rw-r--r--drivers/usb/core/devices.c24
-rw-r--r--drivers/usb/core/devio.c3
-rw-r--r--drivers/usb/core/driver.c472
-rw-r--r--drivers/usb/core/hcd.c10
-rw-r--r--drivers/usb/core/hcd.h1
-rw-r--r--drivers/usb/core/hub.c486
-rw-r--r--drivers/usb/core/hub.h3
-rw-r--r--drivers/usb/core/message.c6
-rw-r--r--drivers/usb/core/usb.c553
-rw-r--r--drivers/usb/core/usb.h6
-rw-r--r--drivers/usb/gadget/dummy_hcd.c91
-rw-r--r--drivers/usb/gadget/file_storage.c93
-rw-r--r--drivers/usb/gadget/serial.c2
-rw-r--r--drivers/usb/host/Makefile4
-rw-r--r--drivers/usb/host/ehci-hcd.c9
-rw-r--r--drivers/usb/host/ehci-hub.c4
-rw-r--r--drivers/usb/host/ehci-pci.c20
-rw-r--r--drivers/usb/host/ehci-q.c14
-rw-r--r--drivers/usb/host/hc_crisv10.c2
-rw-r--r--drivers/usb/host/isp116x-hcd.c422
-rw-r--r--drivers/usb/host/isp116x.h83
-rw-r--r--drivers/usb/host/ohci-hcd.c14
-rw-r--r--drivers/usb/host/ohci-hub.c2
-rw-r--r--drivers/usb/host/ohci-pxa27x.c121
-rw-r--r--drivers/usb/host/pci-quirks.c6
-rw-r--r--drivers/usb/host/sl811-hcd.c14
-rw-r--r--drivers/usb/host/sl811_cs.c115
-rw-r--r--drivers/usb/host/uhci-debug.c14
-rw-r--r--drivers/usb/host/uhci-hcd.c34
-rw-r--r--drivers/usb/host/uhci-hcd.h32
-rw-r--r--drivers/usb/host/uhci-q.c30
-rw-r--r--drivers/usb/image/mdc800.c1
-rw-r--r--drivers/usb/image/microtek.c1
-rw-r--r--drivers/usb/input/Kconfig14
-rw-r--r--drivers/usb/input/Makefile1
-rw-r--r--drivers/usb/input/acecad.c1
-rw-r--r--drivers/usb/input/aiptek.c9
-rw-r--r--drivers/usb/input/appletouch.c1
-rw-r--r--drivers/usb/input/ati_remote.c22
-rw-r--r--drivers/usb/input/ati_remote2.c477
-rw-r--r--drivers/usb/input/fixp-arith.h2
-rw-r--r--drivers/usb/input/hid-core.c7
-rw-r--r--drivers/usb/input/hid-input.c5
-rw-r--r--drivers/usb/input/hiddev.c1
-rw-r--r--drivers/usb/input/itmtouch.c1
-rw-r--r--drivers/usb/input/kbtab.c3
-rw-r--r--drivers/usb/input/keyspan_remote.c3
-rw-r--r--drivers/usb/input/mtouchusb.c1
-rw-r--r--drivers/usb/input/powermate.c1
-rw-r--r--drivers/usb/input/touchkitusb.c149
-rw-r--r--drivers/usb/input/usbkbd.c1
-rw-r--r--drivers/usb/input/usbmouse.c1
-rw-r--r--drivers/usb/input/wacom.c3
-rw-r--r--drivers/usb/input/xpad.c7
-rw-r--r--drivers/usb/input/yealink.c1
-rw-r--r--drivers/usb/media/dabusb.c1
-rw-r--r--drivers/usb/media/dsbr100.c1
-rw-r--r--drivers/usb/media/ibmcam.c2
-rw-r--r--drivers/usb/media/konicawc.c6
-rw-r--r--drivers/usb/media/ov511.c3
-rw-r--r--drivers/usb/media/pwc/pwc-ctrl.c2
-rw-r--r--drivers/usb/media/pwc/pwc-if.c1
-rw-r--r--drivers/usb/media/se401.c1
-rw-r--r--drivers/usb/media/sn9c102_core.c24
-rw-r--r--drivers/usb/media/stv680.c1
-rw-r--r--drivers/usb/media/stv680.h6
-rw-r--r--drivers/usb/media/usbvideo.c4
-rw-r--r--drivers/usb/media/vicam.c1
-rw-r--r--drivers/usb/media/w9968cf.c11
-rw-r--r--drivers/usb/misc/auerswald.c7
-rw-r--r--drivers/usb/misc/cytherm.c1
-rw-r--r--drivers/usb/misc/emi26.c1
-rw-r--r--drivers/usb/misc/emi62.c1
-rw-r--r--drivers/usb/misc/idmouse.c1
-rw-r--r--drivers/usb/misc/ldusb.c1
-rw-r--r--drivers/usb/misc/legousbtower.c1
-rw-r--r--drivers/usb/misc/phidgetkit.c1
-rw-r--r--drivers/usb/misc/phidgetservo.c1
-rw-r--r--drivers/usb/misc/rio500.c5
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb.c11
-rw-r--r--drivers/usb/misc/usblcd.c1
-rw-r--r--drivers/usb/misc/usbled.c1
-rw-r--r--drivers/usb/misc/usbtest.c1
-rw-r--r--drivers/usb/misc/uss720.c1
-rw-r--r--drivers/usb/mon/mon_text.c19
-rw-r--r--drivers/usb/net/asix.c5
-rw-r--r--drivers/usb/net/catc.c1
-rw-r--r--drivers/usb/net/cdc_ether.c1
-rw-r--r--drivers/usb/net/cdc_subset.c1
-rw-r--r--drivers/usb/net/gl620a.c1
-rw-r--r--drivers/usb/net/kaweth.c1
-rw-r--r--drivers/usb/net/net1080.c1
-rw-r--r--drivers/usb/net/pegasus.c144
-rw-r--r--drivers/usb/net/plusb.c1
-rw-r--r--drivers/usb/net/rndis_host.c1
-rw-r--r--drivers/usb/net/rtl8150.c1
-rw-r--r--drivers/usb/net/zaurus.c1
-rw-r--r--drivers/usb/net/zd1201.c11
-rw-r--r--drivers/usb/serial/airprime.c2
-rw-r--r--drivers/usb/serial/anydata.c2
-rw-r--r--drivers/usb/serial/belkin_sa.c2
-rw-r--r--drivers/usb/serial/cp2101.c2
-rw-r--r--drivers/usb/serial/cyberjack.c2
-rw-r--r--drivers/usb/serial/cypress_m8.c1
-rw-r--r--drivers/usb/serial/digi_acceleport.c2
-rw-r--r--drivers/usb/serial/empeg.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.c6
-rw-r--r--drivers/usb/serial/ftdi_sio.h15
-rw-r--r--drivers/usb/serial/garmin_gps.c2
-rw-r--r--drivers/usb/serial/generic.c2
-rw-r--r--drivers/usb/serial/hp4x.c2
-rw-r--r--drivers/usb/serial/io_edgeport.c6
-rw-r--r--drivers/usb/serial/io_edgeport.h3
-rw-r--r--drivers/usb/serial/io_fw_boot2.h2
-rw-r--r--drivers/usb/serial/io_ti.c4
-rw-r--r--drivers/usb/serial/ipaq.c2
-rw-r--r--drivers/usb/serial/ipw.c2
-rw-r--r--drivers/usb/serial/ir-usb.c2
-rw-r--r--drivers/usb/serial/keyspan.h2
-rw-r--r--drivers/usb/serial/keyspan_pda.c2
-rw-r--r--drivers/usb/serial/kl5kusb105.c2
-rw-r--r--drivers/usb/serial/kobil_sct.c2
-rw-r--r--drivers/usb/serial/mct_u232.c2
-rw-r--r--drivers/usb/serial/omninet.c2
-rw-r--r--drivers/usb/serial/option.c2
-rw-r--r--drivers/usb/serial/pl2303.c4
-rw-r--r--drivers/usb/serial/safe_serial.c6
-rw-r--r--drivers/usb/serial/ti_usb_3410_5052.c9
-rw-r--r--drivers/usb/serial/usb-serial.c48
-rw-r--r--drivers/usb/serial/usb-serial.h4
-rw-r--r--drivers/usb/serial/visor.c2
-rw-r--r--drivers/usb/serial/whiteheat.c2
-rw-r--r--drivers/usb/storage/Kconfig23
-rw-r--r--drivers/usb/storage/Makefile5
-rw-r--r--drivers/usb/storage/alauda.c1119
-rw-r--r--drivers/usb/storage/alauda.h100
-rw-r--r--drivers/usb/storage/debug.c1
-rw-r--r--drivers/usb/storage/initializers.h4
-rw-r--r--drivers/usb/storage/libusual.c266
-rw-r--r--drivers/usb/storage/onetouch.c27
-rw-r--r--drivers/usb/storage/protocol.h14
-rw-r--r--drivers/usb/storage/scsiglue.c4
-rw-r--r--drivers/usb/storage/sddr09.c214
-rw-r--r--drivers/usb/storage/sddr09.h15
-rw-r--r--drivers/usb/storage/transport.h31
-rw-r--r--drivers/usb/storage/unusual_devs.h74
-rw-r--r--drivers/usb/storage/usb.c160
-rw-r--r--drivers/usb/storage/usb.h40
-rw-r--r--drivers/usb/usb-skeleton.c29
-rw-r--r--drivers/video/Kconfig10
-rw-r--r--drivers/video/arcfb.c2
-rw-r--r--drivers/video/aty/atyfb_base.c2
-rw-r--r--drivers/video/aty/radeon_base.c16
-rw-r--r--drivers/video/bw2.c1
-rw-r--r--drivers/video/cfbcopyarea.c8
-rw-r--r--drivers/video/cfbfillrect.c16
-rw-r--r--drivers/video/cfbimgblt.c35
-rw-r--r--drivers/video/cg14.c1
-rw-r--r--drivers/video/cg3.c1
-rw-r--r--drivers/video/cg6.c3
-rw-r--r--drivers/video/console/Kconfig20
-rw-r--r--drivers/video/console/fbcon.c42
-rw-r--r--drivers/video/console/fbcon_ud.c8
-rw-r--r--drivers/video/cyber2000fb.c4
-rw-r--r--drivers/video/fbmem.c26
-rw-r--r--drivers/video/ffb.c1
-rw-r--r--drivers/video/intelfb/intelfb.h5
-rw-r--r--drivers/video/intelfb/intelfbdrv.c51
-rw-r--r--drivers/video/leo.c1
-rw-r--r--drivers/video/logo/Kconfig2
-rw-r--r--drivers/video/matrox/matroxfb_maven.c11
-rw-r--r--drivers/video/p9100.c1
-rw-r--r--drivers/video/pxafb.c3
-rw-r--r--drivers/video/sbuslib.c3
-rw-r--r--drivers/video/tcx.c3
-rw-r--r--drivers/w1/dscore.c1
-rw-r--r--drivers/w1/w1.c14
890 files changed, 51650 insertions, 25033 deletions
diff --git a/drivers/acorn/char/pcf8583.c b/drivers/acorn/char/pcf8583.c
index e26f007a1417..9b49f316ae92 100644
--- a/drivers/acorn/char/pcf8583.c
+++ b/drivers/acorn/char/pcf8583.c
@@ -257,9 +257,10 @@ pcf8583_command(struct i2c_client *client, unsigned int cmd, void *arg)
257} 257}
258 258
259static struct i2c_driver pcf8583_driver = { 259static struct i2c_driver pcf8583_driver = {
260 .name = "PCF8583", 260 .driver = {
261 .name = "PCF8583",
262 },
261 .id = I2C_DRIVERID_PCF8583, 263 .id = I2C_DRIVERID_PCF8583,
262 .flags = I2C_DF_NOTIFY,
263 .attach_adapter = pcf8583_probe, 264 .attach_adapter = pcf8583_probe,
264 .detach_client = pcf8583_detach, 265 .detach_client = pcf8583_detach,
265 .command = pcf8583_command 266 .command = pcf8583_command
diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 27ec12c1fab0..b69a8cad82b7 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -172,21 +172,21 @@ static void container_notify_cb(acpi_handle handle, u32 type, void *context)
172 if (ACPI_FAILURE(status) || !device) { 172 if (ACPI_FAILURE(status) || !device) {
173 result = container_device_add(&device, handle); 173 result = container_device_add(&device, handle);
174 if (!result) 174 if (!result)
175 kobject_hotplug(&device->kobj, 175 kobject_uevent(&device->kobj,
176 KOBJ_ONLINE); 176 KOBJ_ONLINE);
177 else 177 else
178 printk("Failed to add container\n"); 178 printk("Failed to add container\n");
179 } 179 }
180 } else { 180 } else {
181 if (ACPI_SUCCESS(status)) { 181 if (ACPI_SUCCESS(status)) {
182 /* device exist and this is a remove request */ 182 /* device exist and this is a remove request */
183 kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 183 kobject_uevent(&device->kobj, KOBJ_OFFLINE);
184 } 184 }
185 } 185 }
186 break; 186 break;
187 case ACPI_NOTIFY_EJECT_REQUEST: 187 case ACPI_NOTIFY_EJECT_REQUEST:
188 if (!acpi_bus_get_device(handle, &device) && device) { 188 if (!acpi_bus_get_device(handle, &device) && device) {
189 kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 189 kobject_uevent(&device->kobj, KOBJ_OFFLINE);
190 } 190 }
191 break; 191 break;
192 default: 192 default:
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 492170373494..1ffc77115367 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -316,7 +316,7 @@ static int acpi_pci_link_set(struct acpi_pci_link *link, int irq)
316 if (!link || !irq) 316 if (!link || !irq)
317 return_VALUE(-EINVAL); 317 return_VALUE(-EINVAL);
318 318
319 resource = kmalloc(sizeof(*resource) + 1, GFP_KERNEL); 319 resource = kmalloc(sizeof(*resource) + 1, GFP_ATOMIC);
320 if (!resource) 320 if (!resource)
321 return_VALUE(-ENOMEM); 321 return_VALUE(-ENOMEM);
322 322
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 0c561c571f29..1278aca96fe3 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -748,7 +748,7 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
748 return_VALUE(-ENODEV); 748 return_VALUE(-ENODEV);
749 749
750 if ((pr->id >= 0) && (pr->id < NR_CPUS)) { 750 if ((pr->id >= 0) && (pr->id < NR_CPUS)) {
751 kobject_hotplug(&(*device)->kobj, KOBJ_ONLINE); 751 kobject_uevent(&(*device)->kobj, KOBJ_ONLINE);
752 } 752 }
753 return_VALUE(0); 753 return_VALUE(0);
754} 754}
@@ -788,13 +788,13 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
788 } 788 }
789 789
790 if (pr->id >= 0 && (pr->id < NR_CPUS)) { 790 if (pr->id >= 0 && (pr->id < NR_CPUS)) {
791 kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 791 kobject_uevent(&device->kobj, KOBJ_OFFLINE);
792 break; 792 break;
793 } 793 }
794 794
795 result = acpi_processor_start(device); 795 result = acpi_processor_start(device);
796 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { 796 if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) {
797 kobject_hotplug(&device->kobj, KOBJ_ONLINE); 797 kobject_uevent(&device->kobj, KOBJ_ONLINE);
798 } else { 798 } else {
799 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, 799 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
800 "Device [%s] failed to start\n", 800 "Device [%s] failed to start\n",
@@ -818,7 +818,7 @@ acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data)
818 } 818 }
819 819
820 if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) 820 if ((pr->id < NR_CPUS) && (cpu_present(pr->id)))
821 kobject_hotplug(&device->kobj, KOBJ_OFFLINE); 821 kobject_uevent(&device->kobj, KOBJ_OFFLINE);
822 break; 822 break;
823 default: 823 default:
824 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 824 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index f37584015324..dc9817cfb882 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -102,8 +102,8 @@ static int cpu_has_cpufreq(unsigned int cpu)
102{ 102{
103 struct cpufreq_policy policy; 103 struct cpufreq_policy policy;
104 if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu)) 104 if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu))
105 return -ENODEV; 105 return 0;
106 return 0; 106 return 1;
107} 107}
108 108
109static int acpi_thermal_cpufreq_increase(unsigned int cpu) 109static int acpi_thermal_cpufreq_increase(unsigned int cpu)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index e332306ae2b9..c60516d0f66b 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -78,7 +78,7 @@ static struct kobj_type ktype_acpi_ns = {
78 .release = acpi_device_release, 78 .release = acpi_device_release,
79}; 79};
80 80
81static int namespace_hotplug(struct kset *kset, struct kobject *kobj, 81static int namespace_uevent(struct kset *kset, struct kobject *kobj,
82 char **envp, int num_envp, char *buffer, 82 char **envp, int num_envp, char *buffer,
83 int buffer_size) 83 int buffer_size)
84{ 84{
@@ -89,8 +89,8 @@ static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
89 if (!dev->driver) 89 if (!dev->driver)
90 return 0; 90 return 0;
91 91
92 if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, 92 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
93 "PHYSDEVDRIVER=%s", dev->driver->name)) 93 "PHYSDEVDRIVER=%s", dev->driver->name))
94 return -ENOMEM; 94 return -ENOMEM;
95 95
96 envp[i] = NULL; 96 envp[i] = NULL;
@@ -98,8 +98,8 @@ static int namespace_hotplug(struct kset *kset, struct kobject *kobj,
98 return 0; 98 return 0;
99} 99}
100 100
101static struct kset_hotplug_ops namespace_hotplug_ops = { 101static struct kset_uevent_ops namespace_uevent_ops = {
102 .hotplug = &namespace_hotplug, 102 .uevent = &namespace_uevent,
103}; 103};
104 104
105static struct kset acpi_namespace_kset = { 105static struct kset acpi_namespace_kset = {
@@ -108,7 +108,7 @@ static struct kset acpi_namespace_kset = {
108 }, 108 },
109 .subsys = &acpi_subsys, 109 .subsys = &acpi_subsys,
110 .ktype = &ktype_acpi_ns, 110 .ktype = &ktype_acpi_ns,
111 .hotplug_ops = &namespace_hotplug_ops, 111 .uevent_ops = &namespace_uevent_ops,
112}; 112};
113 113
114static void acpi_device_register(struct acpi_device *device, 114static void acpi_device_register(struct acpi_device *device,
@@ -347,7 +347,7 @@ static int acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
347} 347}
348 348
349/* -------------------------------------------------------------------------- 349/* --------------------------------------------------------------------------
350 ACPI hotplug sysfs device file support 350 ACPI sysfs device file support
351 -------------------------------------------------------------------------- */ 351 -------------------------------------------------------------------------- */
352static ssize_t acpi_eject_store(struct acpi_device *device, 352static ssize_t acpi_eject_store(struct acpi_device *device,
353 const char *buf, size_t count); 353 const char *buf, size_t count);
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
index d15c194be44a..d1387cfe2d30 100644
--- a/drivers/atm/adummy.c
+++ b/drivers/atm/adummy.c
@@ -123,7 +123,7 @@ static int __init adummy_init(void)
123 } 123 }
124 memset(adummy_dev, 0, sizeof(struct adummy_dev)); 124 memset(adummy_dev, 0, sizeof(struct adummy_dev));
125 125
126 atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, 0); 126 atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
127 if (!atm_dev) { 127 if (!atm_dev) {
128 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n"); 128 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
129 err = -ENODEV; 129 err = -ENODEV;
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 934149c1512b..f0eff3dac58d 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -19,11 +19,11 @@ config PREVENT_FIRMWARE_BUILD
19 If unsure say Y here. 19 If unsure say Y here.
20 20
21config FW_LOADER 21config FW_LOADER
22 tristate "Hotplug firmware loading support" 22 tristate "Userspace firmware loading support"
23 select HOTPLUG 23 select HOTPLUG
24 ---help--- 24 ---help---
25 This option is provided for the case where no in-kernel-tree modules 25 This option is provided for the case where no in-kernel-tree modules
26 require hotplug firmware loading support, but a module built outside 26 require userspace firmware loading support, but a module built outside
27 the kernel tree does. 27 the kernel tree does.
28 28
29config DEBUG_DRIVER 29config DEBUG_DRIVER
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index fa601b085eba..29f6af554e71 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -152,7 +152,11 @@ static ssize_t driver_unbind(struct device_driver *drv,
152 152
153 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); 153 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
154 if (dev && dev->driver == drv) { 154 if (dev && dev->driver == drv) {
155 if (dev->parent) /* Needed for USB */
156 down(&dev->parent->sem);
155 device_release_driver(dev); 157 device_release_driver(dev);
158 if (dev->parent)
159 up(&dev->parent->sem);
156 err = count; 160 err = count;
157 } 161 }
158 put_device(dev); 162 put_device(dev);
@@ -175,9 +179,13 @@ static ssize_t driver_bind(struct device_driver *drv,
175 179
176 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); 180 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
177 if (dev && dev->driver == NULL) { 181 if (dev && dev->driver == NULL) {
182 if (dev->parent) /* Needed for USB */
183 down(&dev->parent->sem);
178 down(&dev->sem); 184 down(&dev->sem);
179 err = driver_probe_device(drv, dev); 185 err = driver_probe_device(drv, dev);
180 up(&dev->sem); 186 up(&dev->sem);
187 if (dev->parent)
188 up(&dev->parent->sem);
181 } 189 }
182 put_device(dev); 190 put_device(dev);
183 put_bus(bus); 191 put_bus(bus);
@@ -420,6 +428,26 @@ static void driver_remove_attrs(struct bus_type * bus, struct device_driver * dr
420 } 428 }
421} 429}
422 430
431#ifdef CONFIG_HOTPLUG
432/*
433 * Thanks to drivers making their tables __devinit, we can't allow manual
434 * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled.
435 */
436static void add_bind_files(struct device_driver *drv)
437{
438 driver_create_file(drv, &driver_attr_unbind);
439 driver_create_file(drv, &driver_attr_bind);
440}
441
442static void remove_bind_files(struct device_driver *drv)
443{
444 driver_remove_file(drv, &driver_attr_bind);
445 driver_remove_file(drv, &driver_attr_unbind);
446}
447#else
448static inline void add_bind_files(struct device_driver *drv) {}
449static inline void remove_bind_files(struct device_driver *drv) {}
450#endif
423 451
424/** 452/**
425 * bus_add_driver - Add a driver to the bus. 453 * bus_add_driver - Add a driver to the bus.
@@ -449,8 +477,7 @@ int bus_add_driver(struct device_driver * drv)
449 module_add_driver(drv->owner, drv); 477 module_add_driver(drv->owner, drv);
450 478
451 driver_add_attrs(bus, drv); 479 driver_add_attrs(bus, drv);
452 driver_create_file(drv, &driver_attr_unbind); 480 add_bind_files(drv);
453 driver_create_file(drv, &driver_attr_bind);
454 } 481 }
455 return error; 482 return error;
456} 483}
@@ -468,8 +495,7 @@ int bus_add_driver(struct device_driver * drv)
468void bus_remove_driver(struct device_driver * drv) 495void bus_remove_driver(struct device_driver * drv)
469{ 496{
470 if (drv->bus) { 497 if (drv->bus) {
471 driver_remove_file(drv, &driver_attr_bind); 498 remove_bind_files(drv);
472 driver_remove_file(drv, &driver_attr_unbind);
473 driver_remove_attrs(drv->bus, drv); 499 driver_remove_attrs(drv->bus, drv);
474 klist_remove(&drv->knode_bus); 500 klist_remove(&drv->knode_bus);
475 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name); 501 pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
@@ -484,8 +510,13 @@ void bus_remove_driver(struct device_driver * drv)
484/* Helper for bus_rescan_devices's iter */ 510/* Helper for bus_rescan_devices's iter */
485static int bus_rescan_devices_helper(struct device *dev, void *data) 511static int bus_rescan_devices_helper(struct device *dev, void *data)
486{ 512{
487 if (!dev->driver) 513 if (!dev->driver) {
514 if (dev->parent) /* Needed for USB */
515 down(&dev->parent->sem);
488 device_attach(dev); 516 device_attach(dev);
517 if (dev->parent)
518 up(&dev->parent->sem);
519 }
489 return 0; 520 return 0;
490} 521}
491 522
diff --git a/drivers/base/class.c b/drivers/base/class.c
index db65fd0babe9..df7fdabd0730 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -178,7 +178,7 @@ static void class_device_create_release(struct class_device *class_dev)
178} 178}
179 179
180/* needed to allow these devices to have parent class devices */ 180/* needed to allow these devices to have parent class devices */
181static int class_device_create_hotplug(struct class_device *class_dev, 181static int class_device_create_uevent(struct class_device *class_dev,
182 char **envp, int num_envp, 182 char **envp, int num_envp,
183 char *buffer, int buffer_size) 183 char *buffer, int buffer_size)
184{ 184{
@@ -331,7 +331,7 @@ static struct kobj_type ktype_class_device = {
331 .release = class_dev_release, 331 .release = class_dev_release,
332}; 332};
333 333
334static int class_hotplug_filter(struct kset *kset, struct kobject *kobj) 334static int class_uevent_filter(struct kset *kset, struct kobject *kobj)
335{ 335{
336 struct kobj_type *ktype = get_ktype(kobj); 336 struct kobj_type *ktype = get_ktype(kobj);
337 337
@@ -343,14 +343,14 @@ static int class_hotplug_filter(struct kset *kset, struct kobject *kobj)
343 return 0; 343 return 0;
344} 344}
345 345
346static const char *class_hotplug_name(struct kset *kset, struct kobject *kobj) 346static const char *class_uevent_name(struct kset *kset, struct kobject *kobj)
347{ 347{
348 struct class_device *class_dev = to_class_dev(kobj); 348 struct class_device *class_dev = to_class_dev(kobj);
349 349
350 return class_dev->class->name; 350 return class_dev->class->name;
351} 351}
352 352
353static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp, 353static int class_uevent(struct kset *kset, struct kobject *kobj, char **envp,
354 int num_envp, char *buffer, int buffer_size) 354 int num_envp, char *buffer, int buffer_size)
355{ 355{
356 struct class_device *class_dev = to_class_dev(kobj); 356 struct class_device *class_dev = to_class_dev(kobj);
@@ -365,29 +365,29 @@ static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
365 struct device *dev = class_dev->dev; 365 struct device *dev = class_dev->dev;
366 char *path = kobject_get_path(&dev->kobj, GFP_KERNEL); 366 char *path = kobject_get_path(&dev->kobj, GFP_KERNEL);
367 367
368 add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, 368 add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
369 &length, "PHYSDEVPATH=%s", path); 369 &length, "PHYSDEVPATH=%s", path);
370 kfree(path); 370 kfree(path);
371 371
372 if (dev->bus) 372 if (dev->bus)
373 add_hotplug_env_var(envp, num_envp, &i, 373 add_uevent_var(envp, num_envp, &i,
374 buffer, buffer_size, &length, 374 buffer, buffer_size, &length,
375 "PHYSDEVBUS=%s", dev->bus->name); 375 "PHYSDEVBUS=%s", dev->bus->name);
376 376
377 if (dev->driver) 377 if (dev->driver)
378 add_hotplug_env_var(envp, num_envp, &i, 378 add_uevent_var(envp, num_envp, &i,
379 buffer, buffer_size, &length, 379 buffer, buffer_size, &length,
380 "PHYSDEVDRIVER=%s", dev->driver->name); 380 "PHYSDEVDRIVER=%s", dev->driver->name);
381 } 381 }
382 382
383 if (MAJOR(class_dev->devt)) { 383 if (MAJOR(class_dev->devt)) {
384 add_hotplug_env_var(envp, num_envp, &i, 384 add_uevent_var(envp, num_envp, &i,
385 buffer, buffer_size, &length, 385 buffer, buffer_size, &length,
386 "MAJOR=%u", MAJOR(class_dev->devt)); 386 "MAJOR=%u", MAJOR(class_dev->devt));
387 387
388 add_hotplug_env_var(envp, num_envp, &i, 388 add_uevent_var(envp, num_envp, &i,
389 buffer, buffer_size, &length, 389 buffer, buffer_size, &length,
390 "MINOR=%u", MINOR(class_dev->devt)); 390 "MINOR=%u", MINOR(class_dev->devt));
391 } 391 }
392 392
393 /* terminate, set to next free slot, shrink available space */ 393 /* terminate, set to next free slot, shrink available space */
@@ -397,30 +397,30 @@ static int class_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
397 buffer = &buffer[length]; 397 buffer = &buffer[length];
398 buffer_size -= length; 398 buffer_size -= length;
399 399
400 if (class_dev->hotplug) { 400 if (class_dev->uevent) {
401 /* have the class device specific function add its stuff */ 401 /* have the class device specific function add its stuff */
402 retval = class_dev->hotplug(class_dev, envp, num_envp, 402 retval = class_dev->uevent(class_dev, envp, num_envp,
403 buffer, buffer_size); 403 buffer, buffer_size);
404 if (retval) 404 if (retval)
405 pr_debug("class_dev->hotplug() returned %d\n", retval); 405 pr_debug("class_dev->uevent() returned %d\n", retval);
406 } else if (class_dev->class->hotplug) { 406 } else if (class_dev->class->uevent) {
407 /* have the class specific function add its stuff */ 407 /* have the class specific function add its stuff */
408 retval = class_dev->class->hotplug(class_dev, envp, num_envp, 408 retval = class_dev->class->uevent(class_dev, envp, num_envp,
409 buffer, buffer_size); 409 buffer, buffer_size);
410 if (retval) 410 if (retval)
411 pr_debug("class->hotplug() returned %d\n", retval); 411 pr_debug("class->uevent() returned %d\n", retval);
412 } 412 }
413 413
414 return retval; 414 return retval;
415} 415}
416 416
417static struct kset_hotplug_ops class_hotplug_ops = { 417static struct kset_uevent_ops class_uevent_ops = {
418 .filter = class_hotplug_filter, 418 .filter = class_uevent_filter,
419 .name = class_hotplug_name, 419 .name = class_uevent_name,
420 .hotplug = class_hotplug, 420 .uevent = class_uevent,
421}; 421};
422 422
423static decl_subsys(class_obj, &ktype_class_device, &class_hotplug_ops); 423static decl_subsys(class_obj, &ktype_class_device, &class_uevent_ops);
424 424
425 425
426static int class_device_add_attrs(struct class_device * cd) 426static int class_device_add_attrs(struct class_device * cd)
@@ -464,7 +464,7 @@ static ssize_t show_dev(struct class_device *class_dev, char *buf)
464static ssize_t store_uevent(struct class_device *class_dev, 464static ssize_t store_uevent(struct class_device *class_dev,
465 const char *buf, size_t count) 465 const char *buf, size_t count)
466{ 466{
467 kobject_hotplug(&class_dev->kobj, KOBJ_ADD); 467 kobject_uevent(&class_dev->kobj, KOBJ_ADD);
468 return count; 468 return count;
469} 469}
470 470
@@ -559,7 +559,7 @@ int class_device_add(struct class_device *class_dev)
559 class_name); 559 class_name);
560 } 560 }
561 561
562 kobject_hotplug(&class_dev->kobj, KOBJ_ADD); 562 kobject_uevent(&class_dev->kobj, KOBJ_ADD);
563 563
564 /* notify any interfaces this device is now here */ 564 /* notify any interfaces this device is now here */
565 if (parent_class) { 565 if (parent_class) {
@@ -632,7 +632,7 @@ struct class_device *class_device_create(struct class *cls,
632 class_dev->class = cls; 632 class_dev->class = cls;
633 class_dev->parent = parent; 633 class_dev->parent = parent;
634 class_dev->release = class_device_create_release; 634 class_dev->release = class_device_create_release;
635 class_dev->hotplug = class_device_create_hotplug; 635 class_dev->uevent = class_device_create_uevent;
636 636
637 va_start(args, fmt); 637 va_start(args, fmt);
638 vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args); 638 vsnprintf(class_dev->class_id, BUS_ID_SIZE, fmt, args);
@@ -674,7 +674,7 @@ void class_device_del(struct class_device *class_dev)
674 class_device_remove_file(class_dev, class_dev->devt_attr); 674 class_device_remove_file(class_dev, class_dev->devt_attr);
675 class_device_remove_attrs(class_dev); 675 class_device_remove_attrs(class_dev);
676 676
677 kobject_hotplug(&class_dev->kobj, KOBJ_REMOVE); 677 kobject_uevent(&class_dev->kobj, KOBJ_REMOVE);
678 kobject_del(&class_dev->kobj); 678 kobject_del(&class_dev->kobj);
679 679
680 class_device_put(parent_device); 680 class_device_put(parent_device);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8615b42b517a..fd8059920dbf 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -90,7 +90,7 @@ static struct kobj_type ktype_device = {
90}; 90};
91 91
92 92
93static int dev_hotplug_filter(struct kset *kset, struct kobject *kobj) 93static int dev_uevent_filter(struct kset *kset, struct kobject *kobj)
94{ 94{
95 struct kobj_type *ktype = get_ktype(kobj); 95 struct kobj_type *ktype = get_ktype(kobj);
96 96
@@ -102,14 +102,14 @@ static int dev_hotplug_filter(struct kset *kset, struct kobject *kobj)
102 return 0; 102 return 0;
103} 103}
104 104
105static const char *dev_hotplug_name(struct kset *kset, struct kobject *kobj) 105static const char *dev_uevent_name(struct kset *kset, struct kobject *kobj)
106{ 106{
107 struct device *dev = to_dev(kobj); 107 struct device *dev = to_dev(kobj);
108 108
109 return dev->bus->name; 109 return dev->bus->name;
110} 110}
111 111
112static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp, 112static int dev_uevent(struct kset *kset, struct kobject *kobj, char **envp,
113 int num_envp, char *buffer, int buffer_size) 113 int num_envp, char *buffer, int buffer_size)
114{ 114{
115 struct device *dev = to_dev(kobj); 115 struct device *dev = to_dev(kobj);
@@ -119,15 +119,15 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
119 119
120 /* add bus name of physical device */ 120 /* add bus name of physical device */
121 if (dev->bus) 121 if (dev->bus)
122 add_hotplug_env_var(envp, num_envp, &i, 122 add_uevent_var(envp, num_envp, &i,
123 buffer, buffer_size, &length, 123 buffer, buffer_size, &length,
124 "PHYSDEVBUS=%s", dev->bus->name); 124 "PHYSDEVBUS=%s", dev->bus->name);
125 125
126 /* add driver name of physical device */ 126 /* add driver name of physical device */
127 if (dev->driver) 127 if (dev->driver)
128 add_hotplug_env_var(envp, num_envp, &i, 128 add_uevent_var(envp, num_envp, &i,
129 buffer, buffer_size, &length, 129 buffer, buffer_size, &length,
130 "PHYSDEVDRIVER=%s", dev->driver->name); 130 "PHYSDEVDRIVER=%s", dev->driver->name);
131 131
132 /* terminate, set to next free slot, shrink available space */ 132 /* terminate, set to next free slot, shrink available space */
133 envp[i] = NULL; 133 envp[i] = NULL;
@@ -136,11 +136,11 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
136 buffer = &buffer[length]; 136 buffer = &buffer[length];
137 buffer_size -= length; 137 buffer_size -= length;
138 138
139 if (dev->bus && dev->bus->hotplug) { 139 if (dev->bus && dev->bus->uevent) {
140 /* have the bus specific function add its stuff */ 140 /* have the bus specific function add its stuff */
141 retval = dev->bus->hotplug (dev, envp, num_envp, buffer, buffer_size); 141 retval = dev->bus->uevent(dev, envp, num_envp, buffer, buffer_size);
142 if (retval) { 142 if (retval) {
143 pr_debug ("%s - hotplug() returned %d\n", 143 pr_debug ("%s - uevent() returned %d\n",
144 __FUNCTION__, retval); 144 __FUNCTION__, retval);
145 } 145 }
146 } 146 }
@@ -148,16 +148,16 @@ static int dev_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
148 return retval; 148 return retval;
149} 149}
150 150
151static struct kset_hotplug_ops device_hotplug_ops = { 151static struct kset_uevent_ops device_uevent_ops = {
152 .filter = dev_hotplug_filter, 152 .filter = dev_uevent_filter,
153 .name = dev_hotplug_name, 153 .name = dev_uevent_name,
154 .hotplug = dev_hotplug, 154 .uevent = dev_uevent,
155}; 155};
156 156
157static ssize_t store_uevent(struct device *dev, struct device_attribute *attr, 157static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
158 const char *buf, size_t count) 158 const char *buf, size_t count)
159{ 159{
160 kobject_hotplug(&dev->kobj, KOBJ_ADD); 160 kobject_uevent(&dev->kobj, KOBJ_ADD);
161 return count; 161 return count;
162} 162}
163 163
@@ -165,7 +165,7 @@ static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
165 * device_subsys - structure to be registered with kobject core. 165 * device_subsys - structure to be registered with kobject core.
166 */ 166 */
167 167
168decl_subsys(devices, &ktype_device, &device_hotplug_ops); 168decl_subsys(devices, &ktype_device, &device_uevent_ops);
169 169
170 170
171/** 171/**
@@ -274,7 +274,7 @@ int device_add(struct device *dev)
274 dev->uevent_attr.store = store_uevent; 274 dev->uevent_attr.store = store_uevent;
275 device_create_file(dev, &dev->uevent_attr); 275 device_create_file(dev, &dev->uevent_attr);
276 276
277 kobject_hotplug(&dev->kobj, KOBJ_ADD); 277 kobject_uevent(&dev->kobj, KOBJ_ADD);
278 if ((error = device_pm_add(dev))) 278 if ((error = device_pm_add(dev)))
279 goto PMError; 279 goto PMError;
280 if ((error = bus_add_device(dev))) 280 if ((error = bus_add_device(dev)))
@@ -291,7 +291,7 @@ int device_add(struct device *dev)
291 BusError: 291 BusError:
292 device_pm_remove(dev); 292 device_pm_remove(dev);
293 PMError: 293 PMError:
294 kobject_hotplug(&dev->kobj, KOBJ_REMOVE); 294 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
295 kobject_del(&dev->kobj); 295 kobject_del(&dev->kobj);
296 Error: 296 Error:
297 if (parent) 297 if (parent)
@@ -374,7 +374,7 @@ void device_del(struct device * dev)
374 platform_notify_remove(dev); 374 platform_notify_remove(dev);
375 bus_remove_device(dev); 375 bus_remove_device(dev);
376 device_pm_remove(dev); 376 device_pm_remove(dev);
377 kobject_hotplug(&dev->kobj, KOBJ_REMOVE); 377 kobject_uevent(&dev->kobj, KOBJ_REMOVE);
378 kobject_del(&dev->kobj); 378 kobject_del(&dev->kobj);
379 if (parent) 379 if (parent)
380 put_device(parent); 380 put_device(parent);
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index a95844790f7b..281d26784d25 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -41,14 +41,14 @@ static ssize_t store_online(struct sys_device *dev, const char *buf,
41 case '0': 41 case '0':
42 ret = cpu_down(cpu->sysdev.id); 42 ret = cpu_down(cpu->sysdev.id);
43 if (!ret) 43 if (!ret)
44 kobject_hotplug(&dev->kobj, KOBJ_OFFLINE); 44 kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
45 break; 45 break;
46 case '1': 46 case '1':
47 ret = smp_prepare_cpu(cpu->sysdev.id); 47 ret = smp_prepare_cpu(cpu->sysdev.id);
48 if (!ret) 48 if (!ret)
49 ret = cpu_up(cpu->sysdev.id); 49 ret = cpu_up(cpu->sysdev.id);
50 if (!ret) 50 if (!ret)
51 kobject_hotplug(&dev->kobj, KOBJ_ONLINE); 51 kobject_uevent(&dev->kobj, KOBJ_ONLINE);
52 break; 52 break;
53 default: 53 default:
54 ret = -EINVAL; 54 ret = -EINVAL;
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 3b419c9a1e7e..2b905016664d 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -65,7 +65,8 @@ void device_bind_driver(struct device * dev)
65 * This function returns 1 if a match is found, an error if one 65 * This function returns 1 if a match is found, an error if one
66 * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise. 66 * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise.
67 * 67 *
68 * This function must be called with @dev->sem held. 68 * This function must be called with @dev->sem held. When called
69 * for a USB interface, @dev->parent->sem must be held as well.
69 */ 70 */
70int driver_probe_device(struct device_driver * drv, struct device * dev) 71int driver_probe_device(struct device_driver * drv, struct device * dev)
71{ 72{
@@ -123,6 +124,8 @@ static int __device_attach(struct device_driver * drv, void * data)
123 * 124 *
124 * Returns 1 if the device was bound to a driver; 125 * Returns 1 if the device was bound to a driver;
125 * 0 if no matching device was found; error code otherwise. 126 * 0 if no matching device was found; error code otherwise.
127 *
128 * When called for a USB interface, @dev->parent->sem must be held.
126 */ 129 */
127int device_attach(struct device * dev) 130int device_attach(struct device * dev)
128{ 131{
@@ -152,10 +155,14 @@ static int __driver_attach(struct device * dev, void * data)
152 * is an error. 155 * is an error.
153 */ 156 */
154 157
158 if (dev->parent) /* Needed for USB */
159 down(&dev->parent->sem);
155 down(&dev->sem); 160 down(&dev->sem);
156 if (!dev->driver) 161 if (!dev->driver)
157 driver_probe_device(drv, dev); 162 driver_probe_device(drv, dev);
158 up(&dev->sem); 163 up(&dev->sem);
164 if (dev->parent)
165 up(&dev->parent->sem);
159 166
160 return 0; 167 return 0;
161} 168}
@@ -181,6 +188,8 @@ void driver_attach(struct device_driver * drv)
181 * Manually detach device from driver. 188 * Manually detach device from driver.
182 * 189 *
183 * __device_release_driver() must be called with @dev->sem held. 190 * __device_release_driver() must be called with @dev->sem held.
191 * When called for a USB interface, @dev->parent->sem must be held
192 * as well.
184 */ 193 */
185 194
186static void __device_release_driver(struct device * dev) 195static void __device_release_driver(struct device * dev)
@@ -233,10 +242,14 @@ void driver_detach(struct device_driver * drv)
233 get_device(dev); 242 get_device(dev);
234 spin_unlock(&drv->klist_devices.k_lock); 243 spin_unlock(&drv->klist_devices.k_lock);
235 244
245 if (dev->parent) /* Needed for USB */
246 down(&dev->parent->sem);
236 down(&dev->sem); 247 down(&dev->sem);
237 if (dev->driver == drv) 248 if (dev->driver == drv)
238 __device_release_driver(dev); 249 __device_release_driver(dev);
239 up(&dev->sem); 250 up(&dev->sem);
251 if (dev->parent)
252 up(&dev->parent->sem);
240 put_device(dev); 253 put_device(dev);
241 } 254 }
242} 255}
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 59dacb6552c0..5b3d5e9ddcb6 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -85,17 +85,17 @@ firmware_timeout_store(struct class *class, const char *buf, size_t count)
85static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); 85static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store);
86 86
87static void fw_class_dev_release(struct class_device *class_dev); 87static void fw_class_dev_release(struct class_device *class_dev);
88int firmware_class_hotplug(struct class_device *dev, char **envp, 88int firmware_class_uevent(struct class_device *dev, char **envp,
89 int num_envp, char *buffer, int buffer_size); 89 int num_envp, char *buffer, int buffer_size);
90 90
91static struct class firmware_class = { 91static struct class firmware_class = {
92 .name = "firmware", 92 .name = "firmware",
93 .hotplug = firmware_class_hotplug, 93 .uevent = firmware_class_uevent,
94 .release = fw_class_dev_release, 94 .release = fw_class_dev_release,
95}; 95};
96 96
97int 97int
98firmware_class_hotplug(struct class_device *class_dev, char **envp, 98firmware_class_uevent(struct class_device *class_dev, char **envp,
99 int num_envp, char *buffer, int buffer_size) 99 int num_envp, char *buffer, int buffer_size)
100{ 100{
101 struct firmware_priv *fw_priv = class_get_devdata(class_dev); 101 struct firmware_priv *fw_priv = class_get_devdata(class_dev);
@@ -104,13 +104,12 @@ firmware_class_hotplug(struct class_device *class_dev, char **envp,
104 if (!test_bit(FW_STATUS_READY, &fw_priv->status)) 104 if (!test_bit(FW_STATUS_READY, &fw_priv->status))
105 return -ENODEV; 105 return -ENODEV;
106 106
107 if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, 107 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
108 "FIRMWARE=%s", fw_priv->fw_id)) 108 "FIRMWARE=%s", fw_priv->fw_id))
109 return -ENOMEM; 109 return -ENOMEM;
110 if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &len, 110 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &len,
111 "TIMEOUT=%i", loading_timeout)) 111 "TIMEOUT=%i", loading_timeout))
112 return -ENOMEM; 112 return -ENOMEM;
113
114 envp[i] = NULL; 113 envp[i] = NULL;
115 114
116 return 0; 115 return 0;
@@ -352,7 +351,7 @@ error_kfree:
352 351
353static int 352static int
354fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p, 353fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p,
355 const char *fw_name, struct device *device, int hotplug) 354 const char *fw_name, struct device *device, int uevent)
356{ 355{
357 struct class_device *class_dev; 356 struct class_device *class_dev;
358 struct firmware_priv *fw_priv; 357 struct firmware_priv *fw_priv;
@@ -384,7 +383,7 @@ fw_setup_class_device(struct firmware *fw, struct class_device **class_dev_p,
384 goto error_unreg; 383 goto error_unreg;
385 } 384 }
386 385
387 if (hotplug) 386 if (uevent)
388 set_bit(FW_STATUS_READY, &fw_priv->status); 387 set_bit(FW_STATUS_READY, &fw_priv->status);
389 else 388 else
390 set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status); 389 set_bit(FW_STATUS_READY_NOHOTPLUG, &fw_priv->status);
@@ -399,7 +398,7 @@ out:
399 398
400static int 399static int
401_request_firmware(const struct firmware **firmware_p, const char *name, 400_request_firmware(const struct firmware **firmware_p, const char *name,
402 struct device *device, int hotplug) 401 struct device *device, int uevent)
403{ 402{
404 struct class_device *class_dev; 403 struct class_device *class_dev;
405 struct firmware_priv *fw_priv; 404 struct firmware_priv *fw_priv;
@@ -418,19 +417,19 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
418 } 417 }
419 418
420 retval = fw_setup_class_device(firmware, &class_dev, name, device, 419 retval = fw_setup_class_device(firmware, &class_dev, name, device,
421 hotplug); 420 uevent);
422 if (retval) 421 if (retval)
423 goto error_kfree_fw; 422 goto error_kfree_fw;
424 423
425 fw_priv = class_get_devdata(class_dev); 424 fw_priv = class_get_devdata(class_dev);
426 425
427 if (hotplug) { 426 if (uevent) {
428 if (loading_timeout > 0) { 427 if (loading_timeout > 0) {
429 fw_priv->timeout.expires = jiffies + loading_timeout * HZ; 428 fw_priv->timeout.expires = jiffies + loading_timeout * HZ;
430 add_timer(&fw_priv->timeout); 429 add_timer(&fw_priv->timeout);
431 } 430 }
432 431
433 kobject_hotplug(&class_dev->kobj, KOBJ_ADD); 432 kobject_uevent(&class_dev->kobj, KOBJ_ADD);
434 wait_for_completion(&fw_priv->completion); 433 wait_for_completion(&fw_priv->completion);
435 set_bit(FW_STATUS_DONE, &fw_priv->status); 434 set_bit(FW_STATUS_DONE, &fw_priv->status);
436 del_timer_sync(&fw_priv->timeout); 435 del_timer_sync(&fw_priv->timeout);
@@ -456,7 +455,7 @@ out:
456} 455}
457 456
458/** 457/**
459 * request_firmware: - request firmware to hotplug and wait for it 458 * request_firmware: - send firmware request and wait for it
460 * @firmware_p: pointer to firmware image 459 * @firmware_p: pointer to firmware image
461 * @name: name of firmware file 460 * @name: name of firmware file
462 * @device: device for which firmware is being loaded 461 * @device: device for which firmware is being loaded
@@ -466,7 +465,7 @@ out:
466 * 465 *
467 * Should be called from user context where sleeping is allowed. 466 * Should be called from user context where sleeping is allowed.
468 * 467 *
469 * @name will be used as $FIRMWARE in the hotplug environment and 468 * @name will be used as $FIRMWARE in the uevent environment and
470 * should be distinctive enough not to be confused with any other 469 * should be distinctive enough not to be confused with any other
471 * firmware image for this or any other device. 470 * firmware image for this or any other device.
472 **/ 471 **/
@@ -474,8 +473,8 @@ int
474request_firmware(const struct firmware **firmware_p, const char *name, 473request_firmware(const struct firmware **firmware_p, const char *name,
475 struct device *device) 474 struct device *device)
476{ 475{
477 int hotplug = 1; 476 int uevent = 1;
478 return _request_firmware(firmware_p, name, device, hotplug); 477 return _request_firmware(firmware_p, name, device, uevent);
479} 478}
480 479
481/** 480/**
@@ -518,7 +517,7 @@ struct firmware_work {
518 struct device *device; 517 struct device *device;
519 void *context; 518 void *context;
520 void (*cont)(const struct firmware *fw, void *context); 519 void (*cont)(const struct firmware *fw, void *context);
521 int hotplug; 520 int uevent;
522}; 521};
523 522
524static int 523static int
@@ -533,7 +532,7 @@ request_firmware_work_func(void *arg)
533 } 532 }
534 daemonize("%s/%s", "firmware", fw_work->name); 533 daemonize("%s/%s", "firmware", fw_work->name);
535 ret = _request_firmware(&fw, fw_work->name, fw_work->device, 534 ret = _request_firmware(&fw, fw_work->name, fw_work->device,
536 fw_work->hotplug); 535 fw_work->uevent);
537 if (ret < 0) 536 if (ret < 0)
538 fw_work->cont(NULL, fw_work->context); 537 fw_work->cont(NULL, fw_work->context);
539 else { 538 else {
@@ -548,7 +547,7 @@ request_firmware_work_func(void *arg)
548/** 547/**
549 * request_firmware_nowait: asynchronous version of request_firmware 548 * request_firmware_nowait: asynchronous version of request_firmware
550 * @module: module requesting the firmware 549 * @module: module requesting the firmware
551 * @hotplug: invokes hotplug event to copy the firmware image if this flag 550 * @uevent: sends uevent to copy the firmware image if this flag
552 * is non-zero else the firmware copy must be done manually. 551 * is non-zero else the firmware copy must be done manually.
553 * @name: name of firmware file 552 * @name: name of firmware file
554 * @device: device for which firmware is being loaded 553 * @device: device for which firmware is being loaded
@@ -562,7 +561,7 @@ request_firmware_work_func(void *arg)
562 **/ 561 **/
563int 562int
564request_firmware_nowait( 563request_firmware_nowait(
565 struct module *module, int hotplug, 564 struct module *module, int uevent,
566 const char *name, struct device *device, void *context, 565 const char *name, struct device *device, void *context,
567 void (*cont)(const struct firmware *fw, void *context)) 566 void (*cont)(const struct firmware *fw, void *context))
568{ 567{
@@ -583,7 +582,7 @@ request_firmware_nowait(
583 .device = device, 582 .device = device,
584 .context = context, 583 .context = context,
585 .cont = cont, 584 .cont = cont,
586 .hotplug = hotplug, 585 .uevent = uevent,
587 }; 586 };
588 587
589 ret = kernel_thread(request_firmware_work_func, fw_work, 588 ret = kernel_thread(request_firmware_work_func, fw_work,
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index b7ddd651d664..58801d718cc2 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -28,14 +28,13 @@
28static struct sysdev_class memory_sysdev_class = { 28static struct sysdev_class memory_sysdev_class = {
29 set_kset_name(MEMORY_CLASS_NAME), 29 set_kset_name(MEMORY_CLASS_NAME),
30}; 30};
31EXPORT_SYMBOL(memory_sysdev_class);
32 31
33static char *memory_hotplug_name(struct kset *kset, struct kobject *kobj) 32static const char *memory_uevent_name(struct kset *kset, struct kobject *kobj)
34{ 33{
35 return MEMORY_CLASS_NAME; 34 return MEMORY_CLASS_NAME;
36} 35}
37 36
38static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp, 37static int memory_uevent(struct kset *kset, struct kobject *kobj, char **envp,
39 int num_envp, char *buffer, int buffer_size) 38 int num_envp, char *buffer, int buffer_size)
40{ 39{
41 int retval = 0; 40 int retval = 0;
@@ -43,19 +42,19 @@ static int memory_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
43 return retval; 42 return retval;
44} 43}
45 44
46static struct kset_hotplug_ops memory_hotplug_ops = { 45static struct kset_uevent_ops memory_uevent_ops = {
47 .name = memory_hotplug_name, 46 .name = memory_uevent_name,
48 .hotplug = memory_hotplug, 47 .uevent = memory_uevent,
49}; 48};
50 49
51static struct notifier_block *memory_chain; 50static struct notifier_block *memory_chain;
52 51
53static int register_memory_notifier(struct notifier_block *nb) 52int register_memory_notifier(struct notifier_block *nb)
54{ 53{
55 return notifier_chain_register(&memory_chain, nb); 54 return notifier_chain_register(&memory_chain, nb);
56} 55}
57 56
58static void unregister_memory_notifier(struct notifier_block *nb) 57void unregister_memory_notifier(struct notifier_block *nb)
59{ 58{
60 notifier_chain_unregister(&memory_chain, nb); 59 notifier_chain_unregister(&memory_chain, nb);
61} 60}
@@ -63,8 +62,7 @@ static void unregister_memory_notifier(struct notifier_block *nb)
63/* 62/*
64 * register_memory - Setup a sysfs device for a memory block 63 * register_memory - Setup a sysfs device for a memory block
65 */ 64 */
66static int 65int register_memory(struct memory_block *memory, struct mem_section *section,
67register_memory(struct memory_block *memory, struct mem_section *section,
68 struct node *root) 66 struct node *root)
69{ 67{
70 int error; 68 int error;
@@ -432,7 +430,7 @@ int __init memory_dev_init(void)
432 unsigned int i; 430 unsigned int i;
433 int ret; 431 int ret;
434 432
435 memory_sysdev_class.kset.hotplug_ops = &memory_hotplug_ops; 433 memory_sysdev_class.kset.uevent_ops = &memory_uevent_ops;
436 ret = sysdev_class_register(&memory_sysdev_class); 434 ret = sysdev_class_register(&memory_sysdev_class);
437 435
438 /* 436 /*
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 8827dafba945..0f81731bdfa8 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -25,6 +25,7 @@
25struct device platform_bus = { 25struct device platform_bus = {
26 .bus_id = "platform", 26 .bus_id = "platform",
27}; 27};
28EXPORT_SYMBOL_GPL(platform_bus);
28 29
29/** 30/**
30 * platform_get_resource - get a resource for a device 31 * platform_get_resource - get a resource for a device
@@ -49,6 +50,7 @@ platform_get_resource(struct platform_device *dev, unsigned int type,
49 } 50 }
50 return NULL; 51 return NULL;
51} 52}
53EXPORT_SYMBOL_GPL(platform_get_resource);
52 54
53/** 55/**
54 * platform_get_irq - get an IRQ for a device 56 * platform_get_irq - get an IRQ for a device
@@ -61,6 +63,7 @@ int platform_get_irq(struct platform_device *dev, unsigned int num)
61 63
62 return r ? r->start : 0; 64 return r ? r->start : 0;
63} 65}
66EXPORT_SYMBOL_GPL(platform_get_irq);
64 67
65/** 68/**
66 * platform_get_resource_byname - get a resource for a device by name 69 * platform_get_resource_byname - get a resource for a device by name
@@ -84,6 +87,7 @@ platform_get_resource_byname(struct platform_device *dev, unsigned int type,
84 } 87 }
85 return NULL; 88 return NULL;
86} 89}
90EXPORT_SYMBOL_GPL(platform_get_resource_byname);
87 91
88/** 92/**
89 * platform_get_irq - get an IRQ for a device 93 * platform_get_irq - get an IRQ for a device
@@ -96,6 +100,7 @@ int platform_get_irq_byname(struct platform_device *dev, char *name)
96 100
97 return r ? r->start : 0; 101 return r ? r->start : 0;
98} 102}
103EXPORT_SYMBOL_GPL(platform_get_irq_byname);
99 104
100/** 105/**
101 * platform_add_devices - add a numbers of platform devices 106 * platform_add_devices - add a numbers of platform devices
@@ -117,6 +122,7 @@ int platform_add_devices(struct platform_device **devs, int num)
117 122
118 return ret; 123 return ret;
119} 124}
125EXPORT_SYMBOL_GPL(platform_add_devices);
120 126
121struct platform_object { 127struct platform_object {
122 struct platform_device pdev; 128 struct platform_device pdev;
@@ -168,7 +174,7 @@ struct platform_device *platform_device_alloc(const char *name, unsigned int id)
168 pa->pdev.dev.release = platform_device_release; 174 pa->pdev.dev.release = platform_device_release;
169 } 175 }
170 176
171 return pa ? &pa->pdev : NULL; 177 return pa ? &pa->pdev : NULL;
172} 178}
173EXPORT_SYMBOL_GPL(platform_device_alloc); 179EXPORT_SYMBOL_GPL(platform_device_alloc);
174 180
@@ -257,7 +263,7 @@ int platform_device_add(struct platform_device *pdev)
257 p = &ioport_resource; 263 p = &ioport_resource;
258 } 264 }
259 265
260 if (p && request_resource(p, r)) { 266 if (p && insert_resource(p, r)) {
261 printk(KERN_ERR 267 printk(KERN_ERR
262 "%s: failed to claim resource %d\n", 268 "%s: failed to claim resource %d\n",
263 pdev->dev.bus_id, i); 269 pdev->dev.bus_id, i);
@@ -282,24 +288,13 @@ int platform_device_add(struct platform_device *pdev)
282EXPORT_SYMBOL_GPL(platform_device_add); 288EXPORT_SYMBOL_GPL(platform_device_add);
283 289
284/** 290/**
285 * platform_device_register - add a platform-level device 291 * platform_device_del - remove a platform-level device
286 * @pdev: platform device we're adding
287 *
288 */
289int platform_device_register(struct platform_device * pdev)
290{
291 device_initialize(&pdev->dev);
292 return platform_device_add(pdev);
293}
294
295/**
296 * platform_device_unregister - remove a platform-level device
297 * @pdev: platform device we're removing 292 * @pdev: platform device we're removing
298 * 293 *
299 * 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
300 * resources owned by the device (@dev->resource). 295 * resources owned by the device (@dev->resource).
301 */ 296 */
302void platform_device_unregister(struct platform_device * pdev) 297void platform_device_del(struct platform_device *pdev)
303{ 298{
304 int i; 299 int i;
305 300
@@ -310,9 +305,37 @@ void platform_device_unregister(struct platform_device * pdev)
310 release_resource(r); 305 release_resource(r);
311 } 306 }
312 307
313 device_unregister(&pdev->dev); 308 device_del(&pdev->dev);
314 } 309 }
315} 310}
311EXPORT_SYMBOL_GPL(platform_device_del);
312
313/**
314 * platform_device_register - add a platform-level device
315 * @pdev: platform device we're adding
316 *
317 */
318int platform_device_register(struct platform_device * pdev)
319{
320 device_initialize(&pdev->dev);
321 return platform_device_add(pdev);
322}
323EXPORT_SYMBOL_GPL(platform_device_register);
324
325/**
326 * platform_device_unregister - unregister a platform-level device
327 * @pdev: platform device we're unregistering
328 *
329 * Unregistration is done in 2 steps. Fisrt we release all resources
330 * and remove it from the sybsystem, then we drop reference count by
331 * calling platform_device_put().
332 */
333void platform_device_unregister(struct platform_device * pdev)
334{
335 platform_device_del(pdev);
336 platform_device_put(pdev);
337}
338EXPORT_SYMBOL_GPL(platform_device_unregister);
316 339
317/** 340/**
318 * platform_device_register_simple 341 * platform_device_register_simple
@@ -355,6 +378,7 @@ error:
355 platform_device_put(pdev); 378 platform_device_put(pdev);
356 return ERR_PTR(retval); 379 return ERR_PTR(retval);
357} 380}
381EXPORT_SYMBOL_GPL(platform_device_register_simple);
358 382
359static int platform_drv_probe(struct device *_dev) 383static int platform_drv_probe(struct device *_dev)
360{ 384{
@@ -476,6 +500,7 @@ struct bus_type platform_bus_type = {
476 .suspend = platform_suspend, 500 .suspend = platform_suspend,
477 .resume = platform_resume, 501 .resume = platform_resume,
478}; 502};
503EXPORT_SYMBOL_GPL(platform_bus_type);
479 504
480int __init platform_bus_init(void) 505int __init platform_bus_init(void)
481{ 506{
@@ -504,14 +529,3 @@ u64 dma_get_required_mask(struct device *dev)
504} 529}
505EXPORT_SYMBOL_GPL(dma_get_required_mask); 530EXPORT_SYMBOL_GPL(dma_get_required_mask);
506#endif 531#endif
507
508EXPORT_SYMBOL_GPL(platform_bus);
509EXPORT_SYMBOL_GPL(platform_bus_type);
510EXPORT_SYMBOL_GPL(platform_add_devices);
511EXPORT_SYMBOL_GPL(platform_device_register);
512EXPORT_SYMBOL_GPL(platform_device_register_simple);
513EXPORT_SYMBOL_GPL(platform_device_unregister);
514EXPORT_SYMBOL_GPL(platform_get_irq);
515EXPORT_SYMBOL_GPL(platform_get_resource);
516EXPORT_SYMBOL_GPL(platform_get_irq_byname);
517EXPORT_SYMBOL_GPL(platform_get_resource_byname);
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index adbc3148c039..96370ec1d673 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -62,8 +62,10 @@ int dpm_runtime_suspend(struct device * dev, pm_message_t state)
62 up(&dpm_sem); 62 up(&dpm_sem);
63 return error; 63 return error;
64} 64}
65EXPORT_SYMBOL(dpm_runtime_suspend);
65 66
66 67
68#if 0
67/** 69/**
68 * dpm_set_power_state - Update power_state field. 70 * dpm_set_power_state - Update power_state field.
69 * @dev: Device. 71 * @dev: Device.
@@ -80,3 +82,4 @@ void dpm_set_power_state(struct device * dev, pm_message_t state)
80 dev->power.power_state = state; 82 dev->power.power_state = state;
81 up(&dpm_sem); 83 up(&dpm_sem);
82} 84}
85#endif /* 0 */
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 70eaa5c7ac08..21097a39a057 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -3471,7 +3471,7 @@ static inline boolean DAC960_ProcessCompletedRequest(DAC960_Command_T *Command,
3471 3471
3472 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) { 3472 if (!end_that_request_first(Request, UpToDate, Command->BlockCount)) {
3473 3473
3474 end_that_request_last(Request); 3474 end_that_request_last(Request, UpToDate);
3475 3475
3476 if (Command->Completion) { 3476 if (Command->Completion) {
3477 complete(Command->Completion); 3477 complete(Command->Completion);
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 7b1cd93892be..139cbba76180 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -117,7 +117,7 @@ config BLK_DEV_XD
117 117
118config PARIDE 118config PARIDE
119 tristate "Parallel port IDE device support" 119 tristate "Parallel port IDE device support"
120 depends on PARPORT 120 depends on PARPORT_PC
121 ---help--- 121 ---help---
122 There are many external CD-ROM and disk devices that connect through 122 There are many external CD-ROM and disk devices that connect through
123 your computer's parallel port. Most of them are actually IDE devices 123 your computer's parallel port. Most of them are actually IDE devices
@@ -358,7 +358,8 @@ config BLK_DEV_UB
358 This driver supports certain USB attached storage devices 358 This driver supports certain USB attached storage devices
359 such as flash keys. 359 such as flash keys.
360 360
361 Warning: Enabling this cripples the usb-storage driver. 361 If you enable this driver, it is recommended to avoid conflicts
362 with usb-storage by enabling USB_LIBUSUAL.
362 363
363 If unsure, say N. 364 If unsure, say N.
364 365
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index a9e33db46e68..d2815b7a9150 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1146,7 +1146,6 @@ static int revalidate_allvol(ctlr_info_t *host)
1146 del_gendisk(disk); 1146 del_gendisk(disk);
1147 if (q) 1147 if (q)
1148 blk_cleanup_queue(q); 1148 blk_cleanup_queue(q);
1149 put_disk(disk);
1150 } 1149 }
1151 } 1150 }
1152 1151
@@ -1465,9 +1464,10 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1465 request_queue_t *q = disk->queue; 1464 request_queue_t *q = disk->queue;
1466 if (disk->flags & GENHD_FL_UP) 1465 if (disk->flags & GENHD_FL_UP)
1467 del_gendisk(disk); 1466 del_gendisk(disk);
1468 if (q) 1467 if (q) {
1469 blk_cleanup_queue(q); 1468 blk_cleanup_queue(q);
1470 put_disk(disk); 1469 drv->queue = NULL;
1470 }
1471 } 1471 }
1472 } 1472 }
1473 1473
@@ -2310,7 +2310,7 @@ static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd,
2310 printk("Done with %p\n", cmd->rq); 2310 printk("Done with %p\n", cmd->rq);
2311#endif /* CCISS_DEBUG */ 2311#endif /* CCISS_DEBUG */
2312 2312
2313 end_that_request_last(cmd->rq); 2313 end_that_request_last(cmd->rq, status ? 1 : -EIO);
2314 cmd_free(h,cmd,1); 2314 cmd_free(h,cmd,1);
2315} 2315}
2316 2316
@@ -3243,7 +3243,6 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev)
3243 del_gendisk(disk); 3243 del_gendisk(disk);
3244 if (q) 3244 if (q)
3245 blk_cleanup_queue(q); 3245 blk_cleanup_queue(q);
3246 put_disk(disk);
3247 } 3246 }
3248 } 3247 }
3249 3248
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index cf1822a6361c..9bddb6874873 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -1036,7 +1036,7 @@ static inline void complete_command(cmdlist_t *cmd, int timeout)
1036 complete_buffers(cmd->rq->bio, ok); 1036 complete_buffers(cmd->rq->bio, ok);
1037 1037
1038 DBGPX(printk("Done with %p\n", cmd->rq);); 1038 DBGPX(printk("Done with %p\n", cmd->rq););
1039 end_that_request_last(cmd->rq); 1039 end_that_request_last(cmd->rq, ok ? 1 : -EIO);
1040} 1040}
1041 1041
1042/* 1042/*
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index f7e765a1d313..a5b857c5c4b8 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -2301,7 +2301,7 @@ static void floppy_end_request(struct request *req, int uptodate)
2301 add_disk_randomness(req->rq_disk); 2301 add_disk_randomness(req->rq_disk);
2302 floppy_off((long)req->rq_disk->private_data); 2302 floppy_off((long)req->rq_disk->private_data);
2303 blkdev_dequeue_request(req); 2303 blkdev_dequeue_request(req);
2304 end_that_request_last(req); 2304 end_that_request_last(req, uptodate);
2305 2305
2306 /* We're done with the request */ 2306 /* We're done with the request */
2307 current_req = NULL; 2307 current_req = NULL;
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 96c664af8d06..a452b13620a2 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -213,7 +213,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
213 struct address_space_operations *aops = mapping->a_ops; 213 struct address_space_operations *aops = mapping->a_ops;
214 pgoff_t index; 214 pgoff_t index;
215 unsigned offset, bv_offs; 215 unsigned offset, bv_offs;
216 int len, ret = 0; 216 int len, ret;
217 217
218 down(&mapping->host->i_sem); 218 down(&mapping->host->i_sem);
219 index = pos >> PAGE_CACHE_SHIFT; 219 index = pos >> PAGE_CACHE_SHIFT;
@@ -232,9 +232,15 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
232 page = grab_cache_page(mapping, index); 232 page = grab_cache_page(mapping, index);
233 if (unlikely(!page)) 233 if (unlikely(!page))
234 goto fail; 234 goto fail;
235 if (unlikely(aops->prepare_write(file, page, offset, 235 ret = aops->prepare_write(file, page, offset,
236 offset + size))) 236 offset + size);
237 if (unlikely(ret)) {
238 if (ret == AOP_TRUNCATED_PAGE) {
239 page_cache_release(page);
240 continue;
241 }
237 goto unlock; 242 goto unlock;
243 }
238 transfer_result = lo_do_transfer(lo, WRITE, page, offset, 244 transfer_result = lo_do_transfer(lo, WRITE, page, offset,
239 bvec->bv_page, bv_offs, size, IV); 245 bvec->bv_page, bv_offs, size, IV);
240 if (unlikely(transfer_result)) { 246 if (unlikely(transfer_result)) {
@@ -251,9 +257,15 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
251 kunmap_atomic(kaddr, KM_USER0); 257 kunmap_atomic(kaddr, KM_USER0);
252 } 258 }
253 flush_dcache_page(page); 259 flush_dcache_page(page);
254 if (unlikely(aops->commit_write(file, page, offset, 260 ret = aops->commit_write(file, page, offset,
255 offset + size))) 261 offset + size);
262 if (unlikely(ret)) {
263 if (ret == AOP_TRUNCATED_PAGE) {
264 page_cache_release(page);
265 continue;
266 }
256 goto unlock; 267 goto unlock;
268 }
257 if (unlikely(transfer_result)) 269 if (unlikely(transfer_result))
258 goto unlock; 270 goto unlock;
259 bv_offs += size; 271 bv_offs += size;
@@ -264,6 +276,7 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
264 unlock_page(page); 276 unlock_page(page);
265 page_cache_release(page); 277 page_cache_release(page);
266 } 278 }
279 ret = 0;
267out: 280out:
268 up(&mapping->host->i_sem); 281 up(&mapping->host->i_sem);
269 return ret; 282 return ret;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9e268ddedfbd..33d6f237b2ed 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -54,11 +54,15 @@
54#include <linux/errno.h> 54#include <linux/errno.h>
55#include <linux/file.h> 55#include <linux/file.h>
56#include <linux/ioctl.h> 56#include <linux/ioctl.h>
57#include <linux/compiler.h>
58#include <linux/err.h>
59#include <linux/kernel.h>
57#include <net/sock.h> 60#include <net/sock.h>
58 61
59#include <linux/devfs_fs_kernel.h> 62#include <linux/devfs_fs_kernel.h>
60 63
61#include <asm/uaccess.h> 64#include <asm/uaccess.h>
65#include <asm/system.h>
62#include <asm/types.h> 66#include <asm/types.h>
63 67
64#include <linux/nbd.h> 68#include <linux/nbd.h>
@@ -136,7 +140,7 @@ static void nbd_end_request(struct request *req)
136 140
137 spin_lock_irqsave(q->queue_lock, flags); 141 spin_lock_irqsave(q->queue_lock, flags);
138 if (!end_that_request_first(req, uptodate, req->nr_sectors)) { 142 if (!end_that_request_first(req, uptodate, req->nr_sectors)) {
139 end_that_request_last(req); 143 end_that_request_last(req, uptodate);
140 } 144 }
141 spin_unlock_irqrestore(q->queue_lock, flags); 145 spin_unlock_irqrestore(q->queue_lock, flags);
142} 146}
@@ -230,14 +234,6 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
230 request.len = htonl(size); 234 request.len = htonl(size);
231 memcpy(request.handle, &req, sizeof(req)); 235 memcpy(request.handle, &req, sizeof(req));
232 236
233 down(&lo->tx_lock);
234
235 if (!sock || !lo->sock) {
236 printk(KERN_ERR "%s: Attempted send on closed socket\n",
237 lo->disk->disk_name);
238 goto error_out;
239 }
240
241 dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%luB)\n", 237 dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%luB)\n",
242 lo->disk->disk_name, req, 238 lo->disk->disk_name, req,
243 nbdcmd_to_ascii(nbd_cmd(req)), 239 nbdcmd_to_ascii(nbd_cmd(req)),
@@ -276,11 +272,9 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
276 } 272 }
277 } 273 }
278 } 274 }
279 up(&lo->tx_lock);
280 return 0; 275 return 0;
281 276
282error_out: 277error_out:
283 up(&lo->tx_lock);
284 return 1; 278 return 1;
285} 279}
286 280
@@ -289,9 +283,14 @@ static struct request *nbd_find_request(struct nbd_device *lo, char *handle)
289 struct request *req; 283 struct request *req;
290 struct list_head *tmp; 284 struct list_head *tmp;
291 struct request *xreq; 285 struct request *xreq;
286 int err;
292 287
293 memcpy(&xreq, handle, sizeof(xreq)); 288 memcpy(&xreq, handle, sizeof(xreq));
294 289
290 err = wait_event_interruptible(lo->active_wq, lo->active_req != xreq);
291 if (unlikely(err))
292 goto out;
293
295 spin_lock(&lo->queue_lock); 294 spin_lock(&lo->queue_lock);
296 list_for_each(tmp, &lo->queue_head) { 295 list_for_each(tmp, &lo->queue_head) {
297 req = list_entry(tmp, struct request, queuelist); 296 req = list_entry(tmp, struct request, queuelist);
@@ -302,7 +301,11 @@ static struct request *nbd_find_request(struct nbd_device *lo, char *handle)
302 return req; 301 return req;
303 } 302 }
304 spin_unlock(&lo->queue_lock); 303 spin_unlock(&lo->queue_lock);
305 return NULL; 304
305 err = -ENOENT;
306
307out:
308 return ERR_PTR(err);
306} 309}
307 310
308static inline int sock_recv_bvec(struct socket *sock, struct bio_vec *bvec) 311static inline int sock_recv_bvec(struct socket *sock, struct bio_vec *bvec)
@@ -331,7 +334,11 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
331 goto harderror; 334 goto harderror;
332 } 335 }
333 req = nbd_find_request(lo, reply.handle); 336 req = nbd_find_request(lo, reply.handle);
334 if (req == NULL) { 337 if (unlikely(IS_ERR(req))) {
338 result = PTR_ERR(req);
339 if (result != -ENOENT)
340 goto harderror;
341
335 printk(KERN_ERR "%s: Unexpected reply (%p)\n", 342 printk(KERN_ERR "%s: Unexpected reply (%p)\n",
336 lo->disk->disk_name, reply.handle); 343 lo->disk->disk_name, reply.handle);
337 result = -EBADR; 344 result = -EBADR;
@@ -395,19 +402,24 @@ static void nbd_clear_que(struct nbd_device *lo)
395 402
396 BUG_ON(lo->magic != LO_MAGIC); 403 BUG_ON(lo->magic != LO_MAGIC);
397 404
398 do { 405 /*
399 req = NULL; 406 * Because we have set lo->sock to NULL under the tx_lock, all
400 spin_lock(&lo->queue_lock); 407 * modifications to the list must have completed by now. For
401 if (!list_empty(&lo->queue_head)) { 408 * the same reason, the active_req must be NULL.
402 req = list_entry(lo->queue_head.next, struct request, queuelist); 409 *
403 list_del_init(&req->queuelist); 410 * As a consequence, we don't need to take the spin lock while
404 } 411 * purging the list here.
405 spin_unlock(&lo->queue_lock); 412 */
406 if (req) { 413 BUG_ON(lo->sock);
407 req->errors++; 414 BUG_ON(lo->active_req);
408 nbd_end_request(req); 415
409 } 416 while (!list_empty(&lo->queue_head)) {
410 } while (req); 417 req = list_entry(lo->queue_head.next, struct request,
418 queuelist);
419 list_del_init(&req->queuelist);
420 req->errors++;
421 nbd_end_request(req);
422 }
411} 423}
412 424
413/* 425/*
@@ -435,11 +447,6 @@ static void do_nbd_request(request_queue_t * q)
435 447
436 BUG_ON(lo->magic != LO_MAGIC); 448 BUG_ON(lo->magic != LO_MAGIC);
437 449
438 if (!lo->file) {
439 printk(KERN_ERR "%s: Request when not-ready\n",
440 lo->disk->disk_name);
441 goto error_out;
442 }
443 nbd_cmd(req) = NBD_CMD_READ; 450 nbd_cmd(req) = NBD_CMD_READ;
444 if (rq_data_dir(req) == WRITE) { 451 if (rq_data_dir(req) == WRITE) {
445 nbd_cmd(req) = NBD_CMD_WRITE; 452 nbd_cmd(req) = NBD_CMD_WRITE;
@@ -453,32 +460,34 @@ static void do_nbd_request(request_queue_t * q)
453 req->errors = 0; 460 req->errors = 0;
454 spin_unlock_irq(q->queue_lock); 461 spin_unlock_irq(q->queue_lock);
455 462
456 spin_lock(&lo->queue_lock); 463 down(&lo->tx_lock);
457 464 if (unlikely(!lo->sock)) {
458 if (!lo->file) { 465 up(&lo->tx_lock);
459 spin_unlock(&lo->queue_lock); 466 printk(KERN_ERR "%s: Attempted send on closed socket\n",
460 printk(KERN_ERR "%s: failed between accept and semaphore, file lost\n", 467 lo->disk->disk_name);
461 lo->disk->disk_name);
462 req->errors++; 468 req->errors++;
463 nbd_end_request(req); 469 nbd_end_request(req);
464 spin_lock_irq(q->queue_lock); 470 spin_lock_irq(q->queue_lock);
465 continue; 471 continue;
466 } 472 }
467 473
468 list_add(&req->queuelist, &lo->queue_head); 474 lo->active_req = req;
469 spin_unlock(&lo->queue_lock);
470 475
471 if (nbd_send_req(lo, req) != 0) { 476 if (nbd_send_req(lo, req) != 0) {
472 printk(KERN_ERR "%s: Request send failed\n", 477 printk(KERN_ERR "%s: Request send failed\n",
473 lo->disk->disk_name); 478 lo->disk->disk_name);
474 if (nbd_find_request(lo, (char *)&req) != NULL) { 479 req->errors++;
475 /* we still own req */ 480 nbd_end_request(req);
476 req->errors++; 481 } else {
477 nbd_end_request(req); 482 spin_lock(&lo->queue_lock);
478 } else /* we're racing with nbd_clear_que */ 483 list_add(&req->queuelist, &lo->queue_head);
479 printk(KERN_DEBUG "nbd: can't find req\n"); 484 spin_unlock(&lo->queue_lock);
480 } 485 }
481 486
487 lo->active_req = NULL;
488 up(&lo->tx_lock);
489 wake_up_all(&lo->active_wq);
490
482 spin_lock_irq(q->queue_lock); 491 spin_lock_irq(q->queue_lock);
483 continue; 492 continue;
484 493
@@ -529,17 +538,10 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
529 down(&lo->tx_lock); 538 down(&lo->tx_lock);
530 lo->sock = NULL; 539 lo->sock = NULL;
531 up(&lo->tx_lock); 540 up(&lo->tx_lock);
532 spin_lock(&lo->queue_lock);
533 file = lo->file; 541 file = lo->file;
534 lo->file = NULL; 542 lo->file = NULL;
535 spin_unlock(&lo->queue_lock);
536 nbd_clear_que(lo); 543 nbd_clear_que(lo);
537 spin_lock(&lo->queue_lock); 544 BUG_ON(!list_empty(&lo->queue_head));
538 if (!list_empty(&lo->queue_head)) {
539 printk(KERN_ERR "nbd: disconnect: some requests are in progress -> please try again.\n");
540 error = -EBUSY;
541 }
542 spin_unlock(&lo->queue_lock);
543 if (file) 545 if (file)
544 fput(file); 546 fput(file);
545 return error; 547 return error;
@@ -598,24 +600,19 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
598 lo->sock = NULL; 600 lo->sock = NULL;
599 } 601 }
600 up(&lo->tx_lock); 602 up(&lo->tx_lock);
601 spin_lock(&lo->queue_lock);
602 file = lo->file; 603 file = lo->file;
603 lo->file = NULL; 604 lo->file = NULL;
604 spin_unlock(&lo->queue_lock);
605 nbd_clear_que(lo); 605 nbd_clear_que(lo);
606 printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name); 606 printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name);
607 if (file) 607 if (file)
608 fput(file); 608 fput(file);
609 return lo->harderror; 609 return lo->harderror;
610 case NBD_CLEAR_QUE: 610 case NBD_CLEAR_QUE:
611 down(&lo->tx_lock); 611 /*
612 if (lo->sock) { 612 * This is for compatibility only. The queue is always cleared
613 up(&lo->tx_lock); 613 * by NBD_DO_IT or NBD_CLEAR_SOCK.
614 return 0; /* probably should be error, but that would 614 */
615 * break "nbd-client -d", so just return 0 */ 615 BUG_ON(!lo->sock && !list_empty(&lo->queue_head));
616 }
617 up(&lo->tx_lock);
618 nbd_clear_que(lo);
619 return 0; 616 return 0;
620 case NBD_PRINT_DEBUG: 617 case NBD_PRINT_DEBUG:
621 printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n", 618 printk(KERN_INFO "%s: next = %p, prev = %p, head = %p\n",
@@ -688,6 +685,7 @@ static int __init nbd_init(void)
688 spin_lock_init(&nbd_dev[i].queue_lock); 685 spin_lock_init(&nbd_dev[i].queue_lock);
689 INIT_LIST_HEAD(&nbd_dev[i].queue_head); 686 INIT_LIST_HEAD(&nbd_dev[i].queue_head);
690 init_MUTEX(&nbd_dev[i].tx_lock); 687 init_MUTEX(&nbd_dev[i].tx_lock);
688 init_waitqueue_head(&nbd_dev[i].active_wq);
691 nbd_dev[i].blksize = 1024; 689 nbd_dev[i].blksize = 1024;
692 nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */ 690 nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */
693 disk->major = NBD_MAJOR; 691 disk->major = NBD_MAJOR;
diff --git a/drivers/block/paride/Kconfig b/drivers/block/paride/Kconfig
index 17ff40561257..c0d2854dd097 100644
--- a/drivers/block/paride/Kconfig
+++ b/drivers/block/paride/Kconfig
@@ -4,11 +4,12 @@
4# PARIDE doesn't need PARPORT, but if PARPORT is configured as a module, 4# PARIDE doesn't need PARPORT, but if PARPORT is configured as a module,
5# PARIDE must also be a module. The bogus CONFIG_PARIDE_PARPORT option 5# PARIDE must also be a module. The bogus CONFIG_PARIDE_PARPORT option
6# controls the choices given to the user ... 6# controls the choices given to the user ...
7# PARIDE only supports PC style parports. Tough for USB or other parports...
7config PARIDE_PARPORT 8config PARIDE_PARPORT
8 tristate 9 tristate
9 depends on PARIDE!=n 10 depends on PARIDE!=n
10 default m if PARPORT=m 11 default m if PARPORT_PC=m
11 default y if PARPORT!=m 12 default y if PARPORT_PC!=m
12 13
13comment "Parallel IDE high-level drivers" 14comment "Parallel IDE high-level drivers"
14 depends on PARIDE 15 depends on PARIDE
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 68c60a5bcdab..ffd6abd6d5a0 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -154,7 +154,7 @@ static int ramdisk_commit_write(struct file *file, struct page *page,
154 154
155/* 155/*
156 * ->writepage to the the blockdev's mapping has to redirty the page so that the 156 * ->writepage to the the blockdev's mapping has to redirty the page so that the
157 * VM doesn't go and steal it. We return WRITEPAGE_ACTIVATE so that the VM 157 * VM doesn't go and steal it. We return AOP_WRITEPAGE_ACTIVATE so that the VM
158 * won't try to (pointlessly) write the page again for a while. 158 * won't try to (pointlessly) write the page again for a while.
159 * 159 *
160 * Really, these pages should not be on the LRU at all. 160 * Really, these pages should not be on the LRU at all.
@@ -165,7 +165,7 @@ static int ramdisk_writepage(struct page *page, struct writeback_control *wbc)
165 make_page_uptodate(page); 165 make_page_uptodate(page);
166 SetPageDirty(page); 166 SetPageDirty(page);
167 if (wbc->for_reclaim) 167 if (wbc->for_reclaim)
168 return WRITEPAGE_ACTIVATE; 168 return AOP_WRITEPAGE_ACTIVATE;
169 unlock_page(page); 169 unlock_page(page);
170 return 0; 170 return 0;
171} 171}
diff --git a/drivers/block/sx8.c b/drivers/block/sx8.c
index 1ded3b433459..9251f4131b53 100644
--- a/drivers/block/sx8.c
+++ b/drivers/block/sx8.c
@@ -770,7 +770,7 @@ static inline void carm_end_request_queued(struct carm_host *host,
770 rc = end_that_request_first(req, uptodate, req->hard_nr_sectors); 770 rc = end_that_request_first(req, uptodate, req->hard_nr_sectors);
771 assert(rc == 0); 771 assert(rc == 0);
772 772
773 end_that_request_last(req); 773 end_that_request_last(req, uptodate);
774 774
775 rc = carm_put_request(host, crq); 775 rc = carm_put_request(host, crq);
776 assert(rc == 0); 776 assert(rc == 0);
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index bfb23d543ff7..a05fe5843e6c 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -9,7 +9,6 @@
9 * 9 *
10 * TODO (sorted by decreasing priority) 10 * TODO (sorted by decreasing priority)
11 * -- Kill first_open (Al Viro fixed the block layer now) 11 * -- Kill first_open (Al Viro fixed the block layer now)
12 * -- Do resets with usb_device_reset (needs a thread context, use khubd)
13 * -- set readonly flag for CDs, set removable flag for CF readers 12 * -- set readonly flag for CDs, set removable flag for CF readers
14 * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch) 13 * -- do inquiry and verify we got a disk and not a tape (for LUN mismatch)
15 * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries 14 * -- special case some senses, e.g. 3a/0 -> no media present, reduce retries
@@ -29,6 +28,7 @@
29#include <linux/kernel.h> 28#include <linux/kernel.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/usb.h> 30#include <linux/usb.h>
31#include <linux/usb_usual.h>
32#include <linux/blkdev.h> 32#include <linux/blkdev.h>
33#include <linux/devfs_fs_kernel.h> 33#include <linux/devfs_fs_kernel.h>
34#include <linux/timer.h> 34#include <linux/timer.h>
@@ -107,16 +107,6 @@
107 */ 107 */
108 108
109/* 109/*
110 * Definitions which have to be scattered once we understand the layout better.
111 */
112
113/* Transport (despite PR in the name) */
114#define US_PR_BULK 0x50 /* bulk only */
115
116/* Protocol */
117#define US_SC_SCSI 0x06 /* Transparent */
118
119/*
120 * This many LUNs per USB device. 110 * This many LUNs per USB device.
121 * Every one of them takes a host, see UB_MAX_HOSTS. 111 * Every one of them takes a host, see UB_MAX_HOSTS.
122 */ 112 */
@@ -125,7 +115,7 @@
125/* 115/*
126 */ 116 */
127 117
128#define UB_MINORS_PER_MAJOR 8 118#define UB_PARTS_PER_LUN 8
129 119
130#define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */ 120#define UB_MAX_CDB_SIZE 16 /* Corresponds to Bulk */
131 121
@@ -245,6 +235,13 @@ struct ub_scsi_cmd {
245 void *back; 235 void *back;
246}; 236};
247 237
238struct ub_request {
239 struct request *rq;
240 unsigned int current_try;
241 unsigned int nsg; /* sgv[nsg] */
242 struct scatterlist sgv[UB_MAX_REQ_SG];
243};
244
248/* 245/*
249 */ 246 */
250struct ub_capacity { 247struct ub_capacity {
@@ -340,6 +337,8 @@ struct ub_lun {
340 int readonly; 337 int readonly;
341 int first_open; /* Kludge. See ub_bd_open. */ 338 int first_open; /* Kludge. See ub_bd_open. */
342 339
340 struct ub_request urq;
341
343 /* Use Ingo's mempool if or when we have more than one command. */ 342 /* Use Ingo's mempool if or when we have more than one command. */
344 /* 343 /*
345 * Currently we never need more than one command for the whole device. 344 * Currently we never need more than one command for the whole device.
@@ -360,6 +359,7 @@ struct ub_dev {
360 atomic_t poison; /* The USB device is disconnected */ 359 atomic_t poison; /* The USB device is disconnected */
361 int openc; /* protected by ub_lock! */ 360 int openc; /* protected by ub_lock! */
362 /* kref is too implicit for our taste */ 361 /* kref is too implicit for our taste */
362 int reset; /* Reset is running */
363 unsigned int tagcnt; 363 unsigned int tagcnt;
364 char name[12]; 364 char name[12];
365 struct usb_device *dev; 365 struct usb_device *dev;
@@ -387,6 +387,9 @@ struct ub_dev {
387 struct bulk_cs_wrap work_bcs; 387 struct bulk_cs_wrap work_bcs;
388 struct usb_ctrlrequest work_cr; 388 struct usb_ctrlrequest work_cr;
389 389
390 struct work_struct reset_work;
391 wait_queue_head_t reset_wait;
392
390 int sg_stat[6]; 393 int sg_stat[6];
391 struct ub_scsi_trace tr; 394 struct ub_scsi_trace tr;
392}; 395};
@@ -395,12 +398,14 @@ struct ub_dev {
395 */ 398 */
396static void ub_cleanup(struct ub_dev *sc); 399static void ub_cleanup(struct ub_dev *sc);
397static int ub_request_fn_1(struct ub_lun *lun, struct request *rq); 400static int ub_request_fn_1(struct ub_lun *lun, struct request *rq);
398static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, 401static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
399 struct ub_scsi_cmd *cmd, struct request *rq); 402 struct ub_scsi_cmd *cmd, struct ub_request *urq);
400static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, 403static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
401 struct ub_scsi_cmd *cmd, struct request *rq); 404 struct ub_scsi_cmd *cmd, struct ub_request *urq);
402static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd); 405static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
403static void ub_end_rq(struct request *rq, int uptodate); 406static void ub_end_rq(struct request *rq, int uptodate);
407static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
408 struct ub_request *urq, struct ub_scsi_cmd *cmd);
404static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd); 409static int ub_submit_scsi(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
405static void ub_urb_complete(struct urb *urb, struct pt_regs *pt); 410static void ub_urb_complete(struct urb *urb, struct pt_regs *pt);
406static void ub_scsi_action(unsigned long _dev); 411static void ub_scsi_action(unsigned long _dev);
@@ -415,6 +420,8 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd);
415static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd, 420static int ub_submit_clear_stall(struct ub_dev *sc, struct ub_scsi_cmd *cmd,
416 int stalled_pipe); 421 int stalled_pipe);
417static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd); 422static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd);
423static void ub_reset_enter(struct ub_dev *sc);
424static void ub_reset_task(void *arg);
418static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun); 425static int ub_sync_tur(struct ub_dev *sc, struct ub_lun *lun);
419static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun, 426static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
420 struct ub_capacity *ret); 427 struct ub_capacity *ret);
@@ -422,13 +429,18 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum);
422 429
423/* 430/*
424 */ 431 */
432#ifdef CONFIG_USB_LIBUSUAL
433
434#define ub_usb_ids storage_usb_ids
435#else
436
425static struct usb_device_id ub_usb_ids[] = { 437static struct usb_device_id ub_usb_ids[] = {
426 // { USB_DEVICE_VER(0x0781, 0x0002, 0x0009, 0x0009) }, /* SDDR-31 */
427 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) }, 438 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) },
428 { } 439 { }
429}; 440};
430 441
431MODULE_DEVICE_TABLE(usb, ub_usb_ids); 442MODULE_DEVICE_TABLE(usb, ub_usb_ids);
443#endif /* CONFIG_USB_LIBUSUAL */
432 444
433/* 445/*
434 * Find me a way to identify "next free minor" for add_disk(), 446 * Find me a way to identify "next free minor" for add_disk(),
@@ -522,6 +534,9 @@ static ssize_t ub_diag_show(struct device *dev, struct device_attribute *attr,
522 spin_lock_irqsave(&sc->lock, flags); 534 spin_lock_irqsave(&sc->lock, flags);
523 535
524 cnt += sprintf(page + cnt, 536 cnt += sprintf(page + cnt,
537 "poison %d reset %d\n",
538 atomic_read(&sc->poison), sc->reset);
539 cnt += sprintf(page + cnt,
525 "qlen %d qmax %d\n", 540 "qlen %d qmax %d\n",
526 sc->cmd_queue.qlen, sc->cmd_queue.qmax); 541 sc->cmd_queue.qlen, sc->cmd_queue.qmax);
527 cnt += sprintf(page + cnt, 542 cnt += sprintf(page + cnt,
@@ -770,7 +785,8 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
770{ 785{
771 struct ub_dev *sc = lun->udev; 786 struct ub_dev *sc = lun->udev;
772 struct ub_scsi_cmd *cmd; 787 struct ub_scsi_cmd *cmd;
773 int rc; 788 struct ub_request *urq;
789 int n_elem;
774 790
775 if (atomic_read(&sc->poison) || lun->changed) { 791 if (atomic_read(&sc->poison) || lun->changed) {
776 blkdev_dequeue_request(rq); 792 blkdev_dequeue_request(rq);
@@ -778,65 +794,70 @@ static int ub_request_fn_1(struct ub_lun *lun, struct request *rq)
778 return 0; 794 return 0;
779 } 795 }
780 796
797 if (lun->urq.rq != NULL)
798 return -1;
781 if ((cmd = ub_get_cmd(lun)) == NULL) 799 if ((cmd = ub_get_cmd(lun)) == NULL)
782 return -1; 800 return -1;
783 memset(cmd, 0, sizeof(struct ub_scsi_cmd)); 801 memset(cmd, 0, sizeof(struct ub_scsi_cmd));
784 802
785 blkdev_dequeue_request(rq); 803 blkdev_dequeue_request(rq);
804
805 urq = &lun->urq;
806 memset(urq, 0, sizeof(struct ub_request));
807 urq->rq = rq;
808
809 /*
810 * get scatterlist from block layer
811 */
812 n_elem = blk_rq_map_sg(lun->disk->queue, rq, &urq->sgv[0]);
813 if (n_elem < 0) {
814 printk(KERN_INFO "%s: failed request map (%d)\n",
815 lun->name, n_elem); /* P3 */
816 goto drop;
817 }
818 if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */
819 printk(KERN_WARNING "%s: request with %d segments\n",
820 lun->name, n_elem);
821 goto drop;
822 }
823 urq->nsg = n_elem;
824 sc->sg_stat[n_elem < 5 ? n_elem : 5]++;
825
786 if (blk_pc_request(rq)) { 826 if (blk_pc_request(rq)) {
787 rc = ub_cmd_build_packet(sc, lun, cmd, rq); 827 ub_cmd_build_packet(sc, lun, cmd, urq);
788 } else { 828 } else {
789 rc = ub_cmd_build_block(sc, lun, cmd, rq); 829 ub_cmd_build_block(sc, lun, cmd, urq);
790 }
791 if (rc != 0) {
792 ub_put_cmd(lun, cmd);
793 ub_end_rq(rq, 0);
794 return 0;
795 } 830 }
796 cmd->state = UB_CMDST_INIT; 831 cmd->state = UB_CMDST_INIT;
797 cmd->lun = lun; 832 cmd->lun = lun;
798 cmd->done = ub_rw_cmd_done; 833 cmd->done = ub_rw_cmd_done;
799 cmd->back = rq; 834 cmd->back = urq;
800 835
801 cmd->tag = sc->tagcnt++; 836 cmd->tag = sc->tagcnt++;
802 if (ub_submit_scsi(sc, cmd) != 0) { 837 if (ub_submit_scsi(sc, cmd) != 0)
803 ub_put_cmd(lun, cmd); 838 goto drop;
804 ub_end_rq(rq, 0);
805 return 0;
806 }
807 839
808 return 0; 840 return 0;
841
842drop:
843 ub_put_cmd(lun, cmd);
844 ub_end_rq(rq, 0);
845 return 0;
809} 846}
810 847
811static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun, 848static void ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
812 struct ub_scsi_cmd *cmd, struct request *rq) 849 struct ub_scsi_cmd *cmd, struct ub_request *urq)
813{ 850{
814 int ub_dir; 851 struct request *rq = urq->rq;
815 int n_elem;
816 unsigned int block, nblks; 852 unsigned int block, nblks;
817 853
818 if (rq_data_dir(rq) == WRITE) 854 if (rq_data_dir(rq) == WRITE)
819 ub_dir = UB_DIR_WRITE; 855 cmd->dir = UB_DIR_WRITE;
820 else 856 else
821 ub_dir = UB_DIR_READ; 857 cmd->dir = UB_DIR_READ;
822 cmd->dir = ub_dir;
823 858
824 /* 859 cmd->nsg = urq->nsg;
825 * get scatterlist from block layer 860 memcpy(cmd->sgv, urq->sgv, sizeof(struct scatterlist) * cmd->nsg);
826 */
827 n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]);
828 if (n_elem <= 0) {
829 printk(KERN_INFO "%s: failed request map (%d)\n",
830 sc->name, n_elem); /* P3 */
831 return -1; /* request with no s/g entries? */
832 }
833 if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */
834 printk(KERN_WARNING "%s: request with %d segments\n",
835 sc->name, n_elem);
836 return -1;
837 }
838 cmd->nsg = n_elem;
839 sc->sg_stat[n_elem < 5 ? n_elem : 5]++;
840 861
841 /* 862 /*
842 * build the command 863 * build the command
@@ -847,7 +868,7 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
847 block = rq->sector >> lun->capacity.bshift; 868 block = rq->sector >> lun->capacity.bshift;
848 nblks = rq->nr_sectors >> lun->capacity.bshift; 869 nblks = rq->nr_sectors >> lun->capacity.bshift;
849 870
850 cmd->cdb[0] = (ub_dir == UB_DIR_READ)? READ_10: WRITE_10; 871 cmd->cdb[0] = (cmd->dir == UB_DIR_READ)? READ_10: WRITE_10;
851 /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */ 872 /* 10-byte uses 4 bytes of LBA: 2147483648KB, 2097152MB, 2048GB */
852 cmd->cdb[2] = block >> 24; 873 cmd->cdb[2] = block >> 24;
853 cmd->cdb[3] = block >> 16; 874 cmd->cdb[3] = block >> 16;
@@ -858,14 +879,12 @@ static int ub_cmd_build_block(struct ub_dev *sc, struct ub_lun *lun,
858 cmd->cdb_len = 10; 879 cmd->cdb_len = 10;
859 880
860 cmd->len = rq->nr_sectors * 512; 881 cmd->len = rq->nr_sectors * 512;
861
862 return 0;
863} 882}
864 883
865static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun, 884static void ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
866 struct ub_scsi_cmd *cmd, struct request *rq) 885 struct ub_scsi_cmd *cmd, struct ub_request *urq)
867{ 886{
868 int n_elem; 887 struct request *rq = urq->rq;
869 888
870 if (rq->data_len == 0) { 889 if (rq->data_len == 0) {
871 cmd->dir = UB_DIR_NONE; 890 cmd->dir = UB_DIR_NONE;
@@ -874,40 +893,26 @@ static int ub_cmd_build_packet(struct ub_dev *sc, struct ub_lun *lun,
874 cmd->dir = UB_DIR_WRITE; 893 cmd->dir = UB_DIR_WRITE;
875 else 894 else
876 cmd->dir = UB_DIR_READ; 895 cmd->dir = UB_DIR_READ;
877
878 } 896 }
879 897
880 /* 898 cmd->nsg = urq->nsg;
881 * get scatterlist from block layer 899 memcpy(cmd->sgv, urq->sgv, sizeof(struct scatterlist) * cmd->nsg);
882 */
883 n_elem = blk_rq_map_sg(lun->disk->queue, rq, &cmd->sgv[0]);
884 if (n_elem < 0) {
885 printk(KERN_INFO "%s: failed request map (%d)\n",
886 sc->name, n_elem); /* P3 */
887 return -1;
888 }
889 if (n_elem > UB_MAX_REQ_SG) { /* Paranoia */
890 printk(KERN_WARNING "%s: request with %d segments\n",
891 sc->name, n_elem);
892 return -1;
893 }
894 cmd->nsg = n_elem;
895 sc->sg_stat[n_elem < 5 ? n_elem : 5]++;
896 900
897 memcpy(&cmd->cdb, rq->cmd, rq->cmd_len); 901 memcpy(&cmd->cdb, rq->cmd, rq->cmd_len);
898 cmd->cdb_len = rq->cmd_len; 902 cmd->cdb_len = rq->cmd_len;
899 903
900 cmd->len = rq->data_len; 904 cmd->len = rq->data_len;
901
902 return 0;
903} 905}
904 906
905static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd) 907static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
906{ 908{
907 struct request *rq = cmd->back;
908 struct ub_lun *lun = cmd->lun; 909 struct ub_lun *lun = cmd->lun;
910 struct ub_request *urq = cmd->back;
911 struct request *rq;
909 int uptodate; 912 int uptodate;
910 913
914 rq = urq->rq;
915
911 if (cmd->error == 0) { 916 if (cmd->error == 0) {
912 uptodate = 1; 917 uptodate = 1;
913 918
@@ -928,9 +933,16 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
928 rq->errors = SAM_STAT_CHECK_CONDITION; 933 rq->errors = SAM_STAT_CHECK_CONDITION;
929 else 934 else
930 rq->errors = DID_ERROR << 16; 935 rq->errors = DID_ERROR << 16;
936 } else {
937 if (cmd->error == -EIO) {
938 if (ub_rw_cmd_retry(sc, lun, urq, cmd) == 0)
939 return;
940 }
931 } 941 }
932 } 942 }
933 943
944 urq->rq = NULL;
945
934 ub_put_cmd(lun, cmd); 946 ub_put_cmd(lun, cmd);
935 ub_end_rq(rq, uptodate); 947 ub_end_rq(rq, uptodate);
936 blk_start_queue(lun->disk->queue); 948 blk_start_queue(lun->disk->queue);
@@ -938,11 +950,43 @@ static void ub_rw_cmd_done(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
938 950
939static void ub_end_rq(struct request *rq, int uptodate) 951static void ub_end_rq(struct request *rq, int uptodate)
940{ 952{
941 int rc; 953 end_that_request_first(rq, uptodate, rq->hard_nr_sectors);
954 end_that_request_last(rq, uptodate);
955}
956
957static int ub_rw_cmd_retry(struct ub_dev *sc, struct ub_lun *lun,
958 struct ub_request *urq, struct ub_scsi_cmd *cmd)
959{
960
961 if (atomic_read(&sc->poison))
962 return -ENXIO;
963
964 ub_reset_enter(sc);
942 965
943 rc = end_that_request_first(rq, uptodate, rq->hard_nr_sectors); 966 if (urq->current_try >= 3)
944 // assert(rc == 0); 967 return -EIO;
945 end_that_request_last(rq); 968 urq->current_try++;
969 /* P3 */ printk("%s: dir %c len/act %d/%d "
970 "[sense %x %02x %02x] retry %d\n",
971 sc->name, UB_DIR_CHAR(cmd->dir), cmd->len, cmd->act_len,
972 cmd->key, cmd->asc, cmd->ascq, urq->current_try);
973
974 memset(cmd, 0, sizeof(struct ub_scsi_cmd));
975 ub_cmd_build_block(sc, lun, cmd, urq);
976
977 cmd->state = UB_CMDST_INIT;
978 cmd->lun = lun;
979 cmd->done = ub_rw_cmd_done;
980 cmd->back = urq;
981
982 cmd->tag = sc->tagcnt++;
983
984#if 0 /* Wasteful */
985 return ub_submit_scsi(sc, cmd);
986#else
987 ub_cmdq_add(sc, cmd);
988 return 0;
989#endif
946} 990}
947 991
948/* 992/*
@@ -1075,7 +1119,7 @@ static void ub_scsi_dispatch(struct ub_dev *sc)
1075 struct ub_scsi_cmd *cmd; 1119 struct ub_scsi_cmd *cmd;
1076 int rc; 1120 int rc;
1077 1121
1078 while ((cmd = ub_cmdq_peek(sc)) != NULL) { 1122 while (!sc->reset && (cmd = ub_cmdq_peek(sc)) != NULL) {
1079 if (cmd->state == UB_CMDST_DONE) { 1123 if (cmd->state == UB_CMDST_DONE) {
1080 ub_cmdq_pop(sc); 1124 ub_cmdq_pop(sc);
1081 (*cmd->done)(sc, cmd); 1125 (*cmd->done)(sc, cmd);
@@ -1098,11 +1142,12 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1098{ 1142{
1099 struct urb *urb = &sc->work_urb; 1143 struct urb *urb = &sc->work_urb;
1100 struct bulk_cs_wrap *bcs; 1144 struct bulk_cs_wrap *bcs;
1145 int len;
1101 int rc; 1146 int rc;
1102 1147
1103 if (atomic_read(&sc->poison)) { 1148 if (atomic_read(&sc->poison)) {
1104 /* A little too simplistic, I feel... */ 1149 ub_state_done(sc, cmd, -ENODEV);
1105 goto Bad_End; 1150 return;
1106 } 1151 }
1107 1152
1108 if (cmd->state == UB_CMDST_CLEAR) { 1153 if (cmd->state == UB_CMDST_CLEAR) {
@@ -1110,7 +1155,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1110 /* 1155 /*
1111 * STALL while clearning STALL. 1156 * STALL while clearning STALL.
1112 * The control pipe clears itself - nothing to do. 1157 * The control pipe clears itself - nothing to do.
1113 * XXX Might try to reset the device here and retry.
1114 */ 1158 */
1115 printk(KERN_NOTICE "%s: stall on control pipe\n", 1159 printk(KERN_NOTICE "%s: stall on control pipe\n",
1116 sc->name); 1160 sc->name);
@@ -1129,11 +1173,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1129 1173
1130 } else if (cmd->state == UB_CMDST_CLR2STS) { 1174 } else if (cmd->state == UB_CMDST_CLR2STS) {
1131 if (urb->status == -EPIPE) { 1175 if (urb->status == -EPIPE) {
1132 /*
1133 * STALL while clearning STALL.
1134 * The control pipe clears itself - nothing to do.
1135 * XXX Might try to reset the device here and retry.
1136 */
1137 printk(KERN_NOTICE "%s: stall on control pipe\n", 1176 printk(KERN_NOTICE "%s: stall on control pipe\n",
1138 sc->name); 1177 sc->name);
1139 goto Bad_End; 1178 goto Bad_End;
@@ -1151,11 +1190,6 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1151 1190
1152 } else if (cmd->state == UB_CMDST_CLRRS) { 1191 } else if (cmd->state == UB_CMDST_CLRRS) {
1153 if (urb->status == -EPIPE) { 1192 if (urb->status == -EPIPE) {
1154 /*
1155 * STALL while clearning STALL.
1156 * The control pipe clears itself - nothing to do.
1157 * XXX Might try to reset the device here and retry.
1158 */
1159 printk(KERN_NOTICE "%s: stall on control pipe\n", 1193 printk(KERN_NOTICE "%s: stall on control pipe\n",
1160 sc->name); 1194 sc->name);
1161 goto Bad_End; 1195 goto Bad_End;
@@ -1172,7 +1206,12 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1172 ub_state_stat_counted(sc, cmd); 1206 ub_state_stat_counted(sc, cmd);
1173 1207
1174 } else if (cmd->state == UB_CMDST_CMD) { 1208 } else if (cmd->state == UB_CMDST_CMD) {
1175 if (urb->status == -EPIPE) { 1209 switch (urb->status) {
1210 case 0:
1211 break;
1212 case -EOVERFLOW:
1213 goto Bad_End;
1214 case -EPIPE:
1176 rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe); 1215 rc = ub_submit_clear_stall(sc, cmd, sc->last_pipe);
1177 if (rc != 0) { 1216 if (rc != 0) {
1178 printk(KERN_NOTICE "%s: " 1217 printk(KERN_NOTICE "%s: "
@@ -1182,17 +1221,20 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1182 * This is typically ENOMEM or some other such shit. 1221 * This is typically ENOMEM or some other such shit.
1183 * Retrying is pointless. Just do Bad End on it... 1222 * Retrying is pointless. Just do Bad End on it...
1184 */ 1223 */
1185 goto Bad_End; 1224 ub_state_done(sc, cmd, rc);
1225 return;
1186 } 1226 }
1187 cmd->state = UB_CMDST_CLEAR; 1227 cmd->state = UB_CMDST_CLEAR;
1188 ub_cmdtr_state(sc, cmd); 1228 ub_cmdtr_state(sc, cmd);
1189 return; 1229 return;
1190 } 1230 case -ESHUTDOWN: /* unplug */
1191 if (urb->status != 0) { 1231 case -EILSEQ: /* unplug timeout on uhci */
1232 ub_state_done(sc, cmd, -ENODEV);
1233 return;
1234 default:
1192 goto Bad_End; 1235 goto Bad_End;
1193 } 1236 }
1194 if (urb->actual_length != US_BULK_CB_WRAP_LEN) { 1237 if (urb->actual_length != US_BULK_CB_WRAP_LEN) {
1195 /* XXX Must do reset here to unconfuse the device */
1196 goto Bad_End; 1238 goto Bad_End;
1197 } 1239 }
1198 1240
@@ -1211,11 +1253,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1211 printk(KERN_NOTICE "%s: " 1253 printk(KERN_NOTICE "%s: "
1212 "unable to submit clear (%d)\n", 1254 "unable to submit clear (%d)\n",
1213 sc->name, rc); 1255 sc->name, rc);
1214 /* 1256 ub_state_done(sc, cmd, rc);
1215 * This is typically ENOMEM or some other such shit. 1257 return;
1216 * Retrying is pointless. Just do Bad End on it...
1217 */
1218 goto Bad_End;
1219 } 1258 }
1220 cmd->state = UB_CMDST_CLR2STS; 1259 cmd->state = UB_CMDST_CLR2STS;
1221 ub_cmdtr_state(sc, cmd); 1260 ub_cmdtr_state(sc, cmd);
@@ -1224,14 +1263,50 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1224 if (urb->status == -EOVERFLOW) { 1263 if (urb->status == -EOVERFLOW) {
1225 /* 1264 /*
1226 * A babble? Failure, but we must transfer CSW now. 1265 * A babble? Failure, but we must transfer CSW now.
1227 * XXX This is going to end in perpetual babble. Reset.
1228 */ 1266 */
1229 cmd->error = -EOVERFLOW; /* A cheap trick... */ 1267 cmd->error = -EOVERFLOW; /* A cheap trick... */
1230 ub_state_stat(sc, cmd); 1268 ub_state_stat(sc, cmd);
1231 return; 1269 return;
1232 } 1270 }
1233 if (urb->status != 0) 1271
1234 goto Bad_End; 1272 if (cmd->dir == UB_DIR_WRITE) {
1273 /*
1274 * Do not continue writes in case of a failure.
1275 * Doing so would cause sectors to be mixed up,
1276 * which is worse than sectors lost.
1277 *
1278 * We must try to read the CSW, or many devices
1279 * get confused.
1280 */
1281 len = urb->actual_length;
1282 if (urb->status != 0 ||
1283 len != cmd->sgv[cmd->current_sg].length) {
1284 cmd->act_len += len;
1285 ub_cmdtr_act_len(sc, cmd);
1286
1287 cmd->error = -EIO;
1288 ub_state_stat(sc, cmd);
1289 return;
1290 }
1291
1292 } else {
1293 /*
1294 * If an error occurs on read, we record it, and
1295 * continue to fetch data in order to avoid bubble.
1296 *
1297 * As a small shortcut, we stop if we detect that
1298 * a CSW mixed into data.
1299 */
1300 if (urb->status != 0)
1301 cmd->error = -EIO;
1302
1303 len = urb->actual_length;
1304 if (urb->status != 0 ||
1305 len != cmd->sgv[cmd->current_sg].length) {
1306 if ((len & 0x1FF) == US_BULK_CS_WRAP_LEN)
1307 goto Bad_End;
1308 }
1309 }
1235 1310
1236 cmd->act_len += urb->actual_length; 1311 cmd->act_len += urb->actual_length;
1237 ub_cmdtr_act_len(sc, cmd); 1312 ub_cmdtr_act_len(sc, cmd);
@@ -1249,11 +1324,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1249 printk(KERN_NOTICE "%s: " 1324 printk(KERN_NOTICE "%s: "
1250 "unable to submit clear (%d)\n", 1325 "unable to submit clear (%d)\n",
1251 sc->name, rc); 1326 sc->name, rc);
1252 /* 1327 ub_state_done(sc, cmd, rc);
1253 * This is typically ENOMEM or some other such shit. 1328 return;
1254 * Retrying is pointless. Just do Bad End on it...
1255 */
1256 goto Bad_End;
1257 } 1329 }
1258 1330
1259 /* 1331 /*
@@ -1266,14 +1338,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1266 ub_cmdtr_state(sc, cmd); 1338 ub_cmdtr_state(sc, cmd);
1267 return; 1339 return;
1268 } 1340 }
1269 if (urb->status == -EOVERFLOW) { 1341
1270 /* 1342 /* Catch everything, including -EOVERFLOW and other nasties. */
1271 * XXX We are screwed here. Retrying is pointless,
1272 * because the pipelined data will not get in until
1273 * we read with a big enough buffer. We must reset XXX.
1274 */
1275 goto Bad_End;
1276 }
1277 if (urb->status != 0) 1343 if (urb->status != 0)
1278 goto Bad_End; 1344 goto Bad_End;
1279 1345
@@ -1319,15 +1385,15 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1319 return; 1385 return;
1320 } 1386 }
1321 1387
1322 rc = le32_to_cpu(bcs->Residue); 1388 len = le32_to_cpu(bcs->Residue);
1323 if (rc != cmd->len - cmd->act_len) { 1389 if (len != cmd->len - cmd->act_len) {
1324 /* 1390 /*
1325 * It is all right to transfer less, the caller has 1391 * It is all right to transfer less, the caller has
1326 * to check. But it's not all right if the device 1392 * to check. But it's not all right if the device
1327 * counts disagree with our counts. 1393 * counts disagree with our counts.
1328 */ 1394 */
1329 /* P3 */ printk("%s: resid %d len %d act %d\n", 1395 /* P3 */ printk("%s: resid %d len %d act %d\n",
1330 sc->name, rc, cmd->len, cmd->act_len); 1396 sc->name, len, cmd->len, cmd->act_len);
1331 goto Bad_End; 1397 goto Bad_End;
1332 } 1398 }
1333 1399
@@ -1338,13 +1404,13 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1338 ub_state_sense(sc, cmd); 1404 ub_state_sense(sc, cmd);
1339 return; 1405 return;
1340 case US_BULK_STAT_PHASE: 1406 case US_BULK_STAT_PHASE:
1341 /* XXX We must reset the transport here */
1342 /* P3 */ printk("%s: status PHASE\n", sc->name); 1407 /* P3 */ printk("%s: status PHASE\n", sc->name);
1343 goto Bad_End; 1408 goto Bad_End;
1344 default: 1409 default:
1345 printk(KERN_INFO "%s: unknown CSW status 0x%x\n", 1410 printk(KERN_INFO "%s: unknown CSW status 0x%x\n",
1346 sc->name, bcs->Status); 1411 sc->name, bcs->Status);
1347 goto Bad_End; 1412 ub_state_done(sc, cmd, -EINVAL);
1413 return;
1348 } 1414 }
1349 1415
1350 /* Not zeroing error to preserve a babble indicator */ 1416 /* Not zeroing error to preserve a babble indicator */
@@ -1364,7 +1430,8 @@ static void ub_scsi_urb_compl(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1364 printk(KERN_WARNING "%s: " 1430 printk(KERN_WARNING "%s: "
1365 "wrong command state %d\n", 1431 "wrong command state %d\n",
1366 sc->name, cmd->state); 1432 sc->name, cmd->state);
1367 goto Bad_End; 1433 ub_state_done(sc, cmd, -EINVAL);
1434 return;
1368 } 1435 }
1369 return; 1436 return;
1370 1437
@@ -1612,6 +1679,93 @@ static void ub_top_sense_done(struct ub_dev *sc, struct ub_scsi_cmd *scmd)
1612} 1679}
1613 1680
1614/* 1681/*
1682 * Reset management
1683 */
1684
1685static void ub_reset_enter(struct ub_dev *sc)
1686{
1687
1688 if (sc->reset) {
1689 /* This happens often on multi-LUN devices. */
1690 return;
1691 }
1692 sc->reset = 1;
1693
1694#if 0 /* Not needed because the disconnect waits for us. */
1695 unsigned long flags;
1696 spin_lock_irqsave(&ub_lock, flags);
1697 sc->openc++;
1698 spin_unlock_irqrestore(&ub_lock, flags);
1699#endif
1700
1701#if 0 /* We let them stop themselves. */
1702 struct list_head *p;
1703 struct ub_lun *lun;
1704 list_for_each(p, &sc->luns) {
1705 lun = list_entry(p, struct ub_lun, link);
1706 blk_stop_queue(lun->disk->queue);
1707 }
1708#endif
1709
1710 schedule_work(&sc->reset_work);
1711}
1712
1713static void ub_reset_task(void *arg)
1714{
1715 struct ub_dev *sc = arg;
1716 unsigned long flags;
1717 struct list_head *p;
1718 struct ub_lun *lun;
1719 int lkr, rc;
1720
1721 if (!sc->reset) {
1722 printk(KERN_WARNING "%s: Running reset unrequested\n",
1723 sc->name);
1724 return;
1725 }
1726
1727 if (atomic_read(&sc->poison)) {
1728 printk(KERN_NOTICE "%s: Not resetting disconnected device\n",
1729 sc->name); /* P3 This floods. Remove soon. XXX */
1730 } else if (sc->dev->actconfig->desc.bNumInterfaces != 1) {
1731 printk(KERN_NOTICE "%s: Not resetting multi-interface device\n",
1732 sc->name); /* P3 This floods. Remove soon. XXX */
1733 } else {
1734 if ((lkr = usb_lock_device_for_reset(sc->dev, sc->intf)) < 0) {
1735 printk(KERN_NOTICE
1736 "%s: usb_lock_device_for_reset failed (%d)\n",
1737 sc->name, lkr);
1738 } else {
1739 rc = usb_reset_device(sc->dev);
1740 if (rc < 0) {
1741 printk(KERN_NOTICE "%s: "
1742 "usb_lock_device_for_reset failed (%d)\n",
1743 sc->name, rc);
1744 }
1745
1746 if (lkr)
1747 usb_unlock_device(sc->dev);
1748 }
1749 }
1750
1751 /*
1752 * In theory, no commands can be running while reset is active,
1753 * so nobody can ask for another reset, and so we do not need any
1754 * queues of resets or anything. We do need a spinlock though,
1755 * to interact with block layer.
1756 */
1757 spin_lock_irqsave(&sc->lock, flags);
1758 sc->reset = 0;
1759 tasklet_schedule(&sc->tasklet);
1760 list_for_each(p, &sc->luns) {
1761 lun = list_entry(p, struct ub_lun, link);
1762 blk_start_queue(lun->disk->queue);
1763 }
1764 wake_up(&sc->reset_wait);
1765 spin_unlock_irqrestore(&sc->lock, flags);
1766}
1767
1768/*
1615 * This is called from a process context. 1769 * This is called from a process context.
1616 */ 1770 */
1617static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun) 1771static void ub_revalidate(struct ub_dev *sc, struct ub_lun *lun)
@@ -2146,7 +2300,7 @@ static int ub_get_pipes(struct ub_dev *sc, struct usb_device *dev,
2146 if (ep_in == NULL || ep_out == NULL) { 2300 if (ep_in == NULL || ep_out == NULL) {
2147 printk(KERN_NOTICE "%s: failed endpoint check\n", 2301 printk(KERN_NOTICE "%s: failed endpoint check\n",
2148 sc->name); 2302 sc->name);
2149 return -EIO; 2303 return -ENODEV;
2150 } 2304 }
2151 2305
2152 /* Calculate and store the pipe values */ 2306 /* Calculate and store the pipe values */
@@ -2172,6 +2326,9 @@ static int ub_probe(struct usb_interface *intf,
2172 int rc; 2326 int rc;
2173 int i; 2327 int i;
2174 2328
2329 if (usb_usual_check_type(dev_id, USB_US_TYPE_UB))
2330 return -ENXIO;
2331
2175 rc = -ENOMEM; 2332 rc = -ENOMEM;
2176 if ((sc = kmalloc(sizeof(struct ub_dev), GFP_KERNEL)) == NULL) 2333 if ((sc = kmalloc(sizeof(struct ub_dev), GFP_KERNEL)) == NULL)
2177 goto err_core; 2334 goto err_core;
@@ -2181,6 +2338,8 @@ static int ub_probe(struct usb_interface *intf,
2181 usb_init_urb(&sc->work_urb); 2338 usb_init_urb(&sc->work_urb);
2182 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc); 2339 tasklet_init(&sc->tasklet, ub_scsi_action, (unsigned long)sc);
2183 atomic_set(&sc->poison, 0); 2340 atomic_set(&sc->poison, 0);
2341 INIT_WORK(&sc->reset_work, ub_reset_task, sc);
2342 init_waitqueue_head(&sc->reset_wait);
2184 2343
2185 init_timer(&sc->work_timer); 2344 init_timer(&sc->work_timer);
2186 sc->work_timer.data = (unsigned long) sc; 2345 sc->work_timer.data = (unsigned long) sc;
@@ -2201,7 +2360,8 @@ static int ub_probe(struct usb_interface *intf,
2201 2360
2202 /* XXX Verify that we can handle the device (from descriptors) */ 2361 /* XXX Verify that we can handle the device (from descriptors) */
2203 2362
2204 ub_get_pipes(sc, sc->dev, intf); 2363 if (ub_get_pipes(sc, sc->dev, intf) != 0)
2364 goto err_dev_desc;
2205 2365
2206 if (device_create_file(&sc->intf->dev, &dev_attr_diag) != 0) 2366 if (device_create_file(&sc->intf->dev, &dev_attr_diag) != 0)
2207 goto err_diag; 2367 goto err_diag;
@@ -2272,6 +2432,7 @@ static int ub_probe(struct usb_interface *intf,
2272 2432
2273 /* device_remove_file(&sc->intf->dev, &dev_attr_diag); */ 2433 /* device_remove_file(&sc->intf->dev, &dev_attr_diag); */
2274err_diag: 2434err_diag:
2435err_dev_desc:
2275 usb_set_intfdata(intf, NULL); 2436 usb_set_intfdata(intf, NULL);
2276 // usb_put_intf(sc->intf); 2437 // usb_put_intf(sc->intf);
2277 usb_put_dev(sc->dev); 2438 usb_put_dev(sc->dev);
@@ -2309,14 +2470,14 @@ static int ub_probe_lun(struct ub_dev *sc, int lnum)
2309 ub_revalidate(sc, lun); 2470 ub_revalidate(sc, lun);
2310 2471
2311 rc = -ENOMEM; 2472 rc = -ENOMEM;
2312 if ((disk = alloc_disk(UB_MINORS_PER_MAJOR)) == NULL) 2473 if ((disk = alloc_disk(UB_PARTS_PER_LUN)) == NULL)
2313 goto err_diskalloc; 2474 goto err_diskalloc;
2314 2475
2315 lun->disk = disk; 2476 lun->disk = disk;
2316 sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a'); 2477 sprintf(disk->disk_name, DRV_NAME "%c", lun->id + 'a');
2317 sprintf(disk->devfs_name, DEVFS_NAME "/%c", lun->id + 'a'); 2478 sprintf(disk->devfs_name, DEVFS_NAME "/%c", lun->id + 'a');
2318 disk->major = UB_MAJOR; 2479 disk->major = UB_MAJOR;
2319 disk->first_minor = lun->id * UB_MINORS_PER_MAJOR; 2480 disk->first_minor = lun->id * UB_PARTS_PER_LUN;
2320 disk->fops = &ub_bd_fops; 2481 disk->fops = &ub_bd_fops;
2321 disk->private_data = lun; 2482 disk->private_data = lun;
2322 disk->driverfs_dev = &sc->intf->dev; 2483 disk->driverfs_dev = &sc->intf->dev;
@@ -2380,6 +2541,11 @@ static void ub_disconnect(struct usb_interface *intf)
2380 atomic_set(&sc->poison, 1); 2541 atomic_set(&sc->poison, 1);
2381 2542
2382 /* 2543 /*
2544 * Wait for reset to end, if any.
2545 */
2546 wait_event(sc->reset_wait, !sc->reset);
2547
2548 /*
2383 * Blow away queued commands. 2549 * Blow away queued commands.
2384 * 2550 *
2385 * Actually, this never works, because before we get here 2551 * Actually, this never works, because before we get here
@@ -2392,7 +2558,7 @@ static void ub_disconnect(struct usb_interface *intf)
2392 { 2558 {
2393 struct ub_scsi_cmd *cmd; 2559 struct ub_scsi_cmd *cmd;
2394 int cnt = 0; 2560 int cnt = 0;
2395 while ((cmd = ub_cmdq_pop(sc)) != NULL) { 2561 while ((cmd = ub_cmdq_peek(sc)) != NULL) {
2396 cmd->error = -ENOTCONN; 2562 cmd->error = -ENOTCONN;
2397 cmd->state = UB_CMDST_DONE; 2563 cmd->state = UB_CMDST_DONE;
2398 ub_cmdtr_state(sc, cmd); 2564 ub_cmdtr_state(sc, cmd);
@@ -2461,7 +2627,6 @@ static void ub_disconnect(struct usb_interface *intf)
2461} 2627}
2462 2628
2463static struct usb_driver ub_driver = { 2629static struct usb_driver ub_driver = {
2464 .owner = THIS_MODULE,
2465 .name = "ub", 2630 .name = "ub",
2466 .probe = ub_probe, 2631 .probe = ub_probe,
2467 .disconnect = ub_disconnect, 2632 .disconnect = ub_disconnect,
@@ -2479,6 +2644,7 @@ static int __init ub_init(void)
2479 if ((rc = usb_register(&ub_driver)) != 0) 2644 if ((rc = usb_register(&ub_driver)) != 0)
2480 goto err_register; 2645 goto err_register;
2481 2646
2647 usb_usual_set_present(USB_US_TYPE_UB);
2482 return 0; 2648 return 0;
2483 2649
2484err_register: 2650err_register:
@@ -2494,6 +2660,7 @@ static void __exit ub_exit(void)
2494 2660
2495 devfs_remove(DEVFS_NAME); 2661 devfs_remove(DEVFS_NAME);
2496 unregister_blkdev(UB_MAJOR, DRV_NAME); 2662 unregister_blkdev(UB_MAJOR, DRV_NAME);
2663 usb_usual_clear_present(USB_US_TYPE_UB);
2497} 2664}
2498 2665
2499module_init(ub_init); 2666module_init(ub_init);
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index 2d518aa2720a..063f0304a163 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -305,7 +305,7 @@ static void viodasd_end_request(struct request *req, int uptodate,
305 if (end_that_request_first(req, uptodate, num_sectors)) 305 if (end_that_request_first(req, uptodate, num_sectors))
306 return; 306 return;
307 add_disk_randomness(req->rq_disk); 307 add_disk_randomness(req->rq_disk);
308 end_that_request_last(req); 308 end_that_request_last(req, uptodate);
309} 309}
310 310
311/* 311/*
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 8e7fb3551775..3e7a067cc087 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -275,7 +275,6 @@ static void bcm203x_disconnect(struct usb_interface *intf)
275} 275}
276 276
277static struct usb_driver bcm203x_driver = { 277static struct usb_driver bcm203x_driver = {
278 .owner = THIS_MODULE,
279 .name = "bcm203x", 278 .name = "bcm203x",
280 .probe = bcm203x_probe, 279 .probe = bcm203x_probe,
281 .disconnect = bcm203x_disconnect, 280 .disconnect = bcm203x_disconnect,
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index 067e27893e4a..8947c8837dac 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -768,7 +768,6 @@ static void bfusb_disconnect(struct usb_interface *intf)
768} 768}
769 769
770static struct usb_driver bfusb_driver = { 770static struct usb_driver bfusb_driver = {
771 .owner = THIS_MODULE,
772 .name = "bfusb", 771 .name = "bfusb",
773 .probe = bfusb_probe, 772 .probe = bfusb_probe,
774 .disconnect = bfusb_disconnect, 773 .disconnect = bfusb_disconnect,
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index f36c563d72c4..9888bc151755 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -87,14 +87,8 @@ typedef struct bluecard_info_t {
87 87
88static void bluecard_config(dev_link_t *link); 88static void bluecard_config(dev_link_t *link);
89static void bluecard_release(dev_link_t *link); 89static void bluecard_release(dev_link_t *link);
90static int bluecard_event(event_t event, int priority, event_callback_args_t *args);
91 90
92static dev_info_t dev_info = "bluecard_cs"; 91static void bluecard_detach(struct pcmcia_device *p_dev);
93
94static dev_link_t *bluecard_attach(void);
95static void bluecard_detach(dev_link_t *);
96
97static dev_link_t *dev_list = NULL;
98 92
99 93
100/* Default baud rate: 57600, 115200, 230400 or 460800 */ 94/* Default baud rate: 57600, 115200, 230400 or 460800 */
@@ -862,17 +856,15 @@ static int bluecard_close(bluecard_info_t *info)
862 return 0; 856 return 0;
863} 857}
864 858
865static dev_link_t *bluecard_attach(void) 859static int bluecard_attach(struct pcmcia_device *p_dev)
866{ 860{
867 bluecard_info_t *info; 861 bluecard_info_t *info;
868 client_reg_t client_reg;
869 dev_link_t *link; 862 dev_link_t *link;
870 int ret;
871 863
872 /* Create new info device */ 864 /* Create new info device */
873 info = kzalloc(sizeof(*info), GFP_KERNEL); 865 info = kzalloc(sizeof(*info), GFP_KERNEL);
874 if (!info) 866 if (!info)
875 return NULL; 867 return -ENOMEM;
876 868
877 link = &info->link; 869 link = &info->link;
878 link->priv = info; 870 link->priv = info;
@@ -889,50 +881,24 @@ static dev_link_t *bluecard_attach(void)
889 link->conf.Vcc = 50; 881 link->conf.Vcc = 50;
890 link->conf.IntType = INT_MEMORY_AND_IO; 882 link->conf.IntType = INT_MEMORY_AND_IO;
891 883
892 /* Register with Card Services */ 884 link->handle = p_dev;
893 link->next = dev_list; 885 p_dev->instance = link;
894 dev_list = link;
895 client_reg.dev_info = &dev_info;
896 client_reg.Version = 0x0210;
897 client_reg.event_callback_args.client_data = link;
898
899 ret = pcmcia_register_client(&link->handle, &client_reg);
900 if (ret != CS_SUCCESS) {
901 cs_error(link->handle, RegisterClient, ret);
902 bluecard_detach(link);
903 return NULL;
904 }
905 886
906 return link; 887 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
888 bluecard_config(link);
889
890 return 0;
907} 891}
908 892
909 893
910static void bluecard_detach(dev_link_t *link) 894static void bluecard_detach(struct pcmcia_device *p_dev)
911{ 895{
896 dev_link_t *link = dev_to_instance(p_dev);
912 bluecard_info_t *info = link->priv; 897 bluecard_info_t *info = link->priv;
913 dev_link_t **linkp;
914 int ret;
915
916 /* Locate device structure */
917 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
918 if (*linkp == link)
919 break;
920
921 if (*linkp == NULL)
922 return;
923 898
924 if (link->state & DEV_CONFIG) 899 if (link->state & DEV_CONFIG)
925 bluecard_release(link); 900 bluecard_release(link);
926 901
927 if (link->handle) {
928 ret = pcmcia_deregister_client(link->handle);
929 if (ret != CS_SUCCESS)
930 cs_error(link->handle, DeregisterClient, ret);
931 }
932
933 /* Unlink device structure, free bits */
934 *linkp = link->next;
935
936 kfree(info); 902 kfree(info);
937} 903}
938 904
@@ -1045,39 +1011,24 @@ static void bluecard_release(dev_link_t *link)
1045 link->state &= ~DEV_CONFIG; 1011 link->state &= ~DEV_CONFIG;
1046} 1012}
1047 1013
1014static int bluecard_suspend(struct pcmcia_device *dev)
1015{
1016 dev_link_t *link = dev_to_instance(dev);
1017
1018 link->state |= DEV_SUSPEND;
1019 if (link->state & DEV_CONFIG)
1020 pcmcia_release_configuration(link->handle);
1048 1021
1049static int bluecard_event(event_t event, int priority, event_callback_args_t *args) 1022 return 0;
1023}
1024
1025static int bluecard_resume(struct pcmcia_device *dev)
1050{ 1026{
1051 dev_link_t *link = args->client_data; 1027 dev_link_t *link = dev_to_instance(dev);
1052 bluecard_info_t *info = link->priv;
1053 1028
1054 switch (event) { 1029 link->state &= ~DEV_SUSPEND;
1055 case CS_EVENT_CARD_REMOVAL: 1030 if (DEV_OK(link))
1056 link->state &= ~DEV_PRESENT; 1031 pcmcia_request_configuration(link->handle, &link->conf);
1057 if (link->state & DEV_CONFIG) {
1058 bluecard_close(info);
1059 bluecard_release(link);
1060 }
1061 break;
1062 case CS_EVENT_CARD_INSERTION:
1063 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1064 bluecard_config(link);
1065 break;
1066 case CS_EVENT_PM_SUSPEND:
1067 link->state |= DEV_SUSPEND;
1068 /* Fall through... */
1069 case CS_EVENT_RESET_PHYSICAL:
1070 if (link->state & DEV_CONFIG)
1071 pcmcia_release_configuration(link->handle);
1072 break;
1073 case CS_EVENT_PM_RESUME:
1074 link->state &= ~DEV_SUSPEND;
1075 /* Fall through... */
1076 case CS_EVENT_CARD_RESET:
1077 if (DEV_OK(link))
1078 pcmcia_request_configuration(link->handle, &link->conf);
1079 break;
1080 }
1081 1032
1082 return 0; 1033 return 0;
1083} 1034}
@@ -1095,10 +1046,11 @@ static struct pcmcia_driver bluecard_driver = {
1095 .drv = { 1046 .drv = {
1096 .name = "bluecard_cs", 1047 .name = "bluecard_cs",
1097 }, 1048 },
1098 .attach = bluecard_attach, 1049 .probe = bluecard_attach,
1099 .event = bluecard_event, 1050 .remove = bluecard_detach,
1100 .detach = bluecard_detach,
1101 .id_table = bluecard_ids, 1051 .id_table = bluecard_ids,
1052 .suspend = bluecard_suspend,
1053 .resume = bluecard_resume,
1102}; 1054};
1103 1055
1104static int __init init_bluecard_cs(void) 1056static int __init init_bluecard_cs(void)
@@ -1110,7 +1062,6 @@ static int __init init_bluecard_cs(void)
1110static void __exit exit_bluecard_cs(void) 1062static void __exit exit_bluecard_cs(void)
1111{ 1063{
1112 pcmcia_unregister_driver(&bluecard_driver); 1064 pcmcia_unregister_driver(&bluecard_driver);
1113 BUG_ON(dev_list != NULL);
1114} 1065}
1115 1066
1116module_init(init_bluecard_cs); 1067module_init(init_bluecard_cs);
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 394796315adc..9446960ac742 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -619,7 +619,6 @@ static void bpa10x_disconnect(struct usb_interface *intf)
619} 619}
620 620
621static struct usb_driver bpa10x_driver = { 621static struct usb_driver bpa10x_driver = {
622 .owner = THIS_MODULE,
623 .name = "bpa10x", 622 .name = "bpa10x",
624 .probe = bpa10x_probe, 623 .probe = bpa10x_probe,
625 .disconnect = bpa10x_disconnect, 624 .disconnect = bpa10x_disconnect,
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index d2a0add19cc8..e522d19ad886 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -90,14 +90,8 @@ typedef struct bt3c_info_t {
90 90
91static void bt3c_config(dev_link_t *link); 91static void bt3c_config(dev_link_t *link);
92static void bt3c_release(dev_link_t *link); 92static void bt3c_release(dev_link_t *link);
93static int bt3c_event(event_t event, int priority, event_callback_args_t *args);
94 93
95static dev_info_t dev_info = "bt3c_cs"; 94static void bt3c_detach(struct pcmcia_device *p_dev);
96
97static dev_link_t *bt3c_attach(void);
98static void bt3c_detach(dev_link_t *);
99
100static dev_link_t *dev_list = NULL;
101 95
102 96
103/* Transmit states */ 97/* Transmit states */
@@ -663,17 +657,15 @@ static int bt3c_close(bt3c_info_t *info)
663 return 0; 657 return 0;
664} 658}
665 659
666static dev_link_t *bt3c_attach(void) 660static int bt3c_attach(struct pcmcia_device *p_dev)
667{ 661{
668 bt3c_info_t *info; 662 bt3c_info_t *info;
669 client_reg_t client_reg;
670 dev_link_t *link; 663 dev_link_t *link;
671 int ret;
672 664
673 /* Create new info device */ 665 /* Create new info device */
674 info = kzalloc(sizeof(*info), GFP_KERNEL); 666 info = kzalloc(sizeof(*info), GFP_KERNEL);
675 if (!info) 667 if (!info)
676 return NULL; 668 return -ENOMEM;
677 669
678 link = &info->link; 670 link = &info->link;
679 link->priv = info; 671 link->priv = info;
@@ -690,50 +682,24 @@ static dev_link_t *bt3c_attach(void)
690 link->conf.Vcc = 50; 682 link->conf.Vcc = 50;
691 link->conf.IntType = INT_MEMORY_AND_IO; 683 link->conf.IntType = INT_MEMORY_AND_IO;
692 684
693 /* Register with Card Services */ 685 link->handle = p_dev;
694 link->next = dev_list; 686 p_dev->instance = link;
695 dev_list = link;
696 client_reg.dev_info = &dev_info;
697 client_reg.Version = 0x0210;
698 client_reg.event_callback_args.client_data = link;
699
700 ret = pcmcia_register_client(&link->handle, &client_reg);
701 if (ret != CS_SUCCESS) {
702 cs_error(link->handle, RegisterClient, ret);
703 bt3c_detach(link);
704 return NULL;
705 }
706 687
707 return link; 688 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
689 bt3c_config(link);
690
691 return 0;
708} 692}
709 693
710 694
711static void bt3c_detach(dev_link_t *link) 695static void bt3c_detach(struct pcmcia_device *p_dev)
712{ 696{
697 dev_link_t *link = dev_to_instance(p_dev);
713 bt3c_info_t *info = link->priv; 698 bt3c_info_t *info = link->priv;
714 dev_link_t **linkp;
715 int ret;
716
717 /* Locate device structure */
718 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
719 if (*linkp == link)
720 break;
721
722 if (*linkp == NULL)
723 return;
724 699
725 if (link->state & DEV_CONFIG) 700 if (link->state & DEV_CONFIG)
726 bt3c_release(link); 701 bt3c_release(link);
727 702
728 if (link->handle) {
729 ret = pcmcia_deregister_client(link->handle);
730 if (ret != CS_SUCCESS)
731 cs_error(link->handle, DeregisterClient, ret);
732 }
733
734 /* Unlink device structure, free bits */
735 *linkp = link->next;
736
737 kfree(info); 703 kfree(info);
738} 704}
739 705
@@ -891,43 +857,29 @@ static void bt3c_release(dev_link_t *link)
891 link->state &= ~DEV_CONFIG; 857 link->state &= ~DEV_CONFIG;
892} 858}
893 859
860static int bt3c_suspend(struct pcmcia_device *dev)
861{
862 dev_link_t *link = dev_to_instance(dev);
894 863
895static int bt3c_event(event_t event, int priority, event_callback_args_t *args) 864 link->state |= DEV_SUSPEND;
865 if (link->state & DEV_CONFIG)
866 pcmcia_release_configuration(link->handle);
867
868 return 0;
869}
870
871static int bt3c_resume(struct pcmcia_device *dev)
896{ 872{
897 dev_link_t *link = args->client_data; 873 dev_link_t *link = dev_to_instance(dev);
898 bt3c_info_t *info = link->priv;
899 874
900 switch (event) { 875 link->state &= ~DEV_SUSPEND;
901 case CS_EVENT_CARD_REMOVAL: 876 if (DEV_OK(link))
902 link->state &= ~DEV_PRESENT; 877 pcmcia_request_configuration(link->handle, &link->conf);
903 if (link->state & DEV_CONFIG) {
904 bt3c_close(info);
905 bt3c_release(link);
906 }
907 break;
908 case CS_EVENT_CARD_INSERTION:
909 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
910 bt3c_config(link);
911 break;
912 case CS_EVENT_PM_SUSPEND:
913 link->state |= DEV_SUSPEND;
914 /* Fall through... */
915 case CS_EVENT_RESET_PHYSICAL:
916 if (link->state & DEV_CONFIG)
917 pcmcia_release_configuration(link->handle);
918 break;
919 case CS_EVENT_PM_RESUME:
920 link->state &= ~DEV_SUSPEND;
921 /* Fall through... */
922 case CS_EVENT_CARD_RESET:
923 if (DEV_OK(link))
924 pcmcia_request_configuration(link->handle, &link->conf);
925 break;
926 }
927 878
928 return 0; 879 return 0;
929} 880}
930 881
882
931static struct pcmcia_device_id bt3c_ids[] = { 883static struct pcmcia_device_id bt3c_ids[] = {
932 PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02), 884 PCMCIA_DEVICE_PROD_ID13("3COM", "Bluetooth PC Card", 0xefce0a31, 0xd4ce9b02),
933 PCMCIA_DEVICE_NULL 885 PCMCIA_DEVICE_NULL
@@ -939,10 +891,11 @@ static struct pcmcia_driver bt3c_driver = {
939 .drv = { 891 .drv = {
940 .name = "bt3c_cs", 892 .name = "bt3c_cs",
941 }, 893 },
942 .attach = bt3c_attach, 894 .probe = bt3c_attach,
943 .event = bt3c_event, 895 .remove = bt3c_detach,
944 .detach = bt3c_detach,
945 .id_table = bt3c_ids, 896 .id_table = bt3c_ids,
897 .suspend = bt3c_suspend,
898 .resume = bt3c_resume,
946}; 899};
947 900
948static int __init init_bt3c_cs(void) 901static int __init init_bt3c_cs(void)
@@ -954,7 +907,6 @@ static int __init init_bt3c_cs(void)
954static void __exit exit_bt3c_cs(void) 907static void __exit exit_bt3c_cs(void)
955{ 908{
956 pcmcia_unregister_driver(&bt3c_driver); 909 pcmcia_unregister_driver(&bt3c_driver);
957 BUG_ON(dev_list != NULL);
958} 910}
959 911
960module_init(init_bt3c_cs); 912module_init(init_bt3c_cs);
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 529a28a3209d..7b4bff4cfa2d 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -86,14 +86,8 @@ typedef struct btuart_info_t {
86 86
87static void btuart_config(dev_link_t *link); 87static void btuart_config(dev_link_t *link);
88static void btuart_release(dev_link_t *link); 88static void btuart_release(dev_link_t *link);
89static int btuart_event(event_t event, int priority, event_callback_args_t *args);
90 89
91static dev_info_t dev_info = "btuart_cs"; 90static void btuart_detach(struct pcmcia_device *p_dev);
92
93static dev_link_t *btuart_attach(void);
94static void btuart_detach(dev_link_t *);
95
96static dev_link_t *dev_list = NULL;
97 91
98 92
99/* Maximum baud rate */ 93/* Maximum baud rate */
@@ -582,17 +576,15 @@ static int btuart_close(btuart_info_t *info)
582 return 0; 576 return 0;
583} 577}
584 578
585static dev_link_t *btuart_attach(void) 579static int btuart_attach(struct pcmcia_device *p_dev)
586{ 580{
587 btuart_info_t *info; 581 btuart_info_t *info;
588 client_reg_t client_reg;
589 dev_link_t *link; 582 dev_link_t *link;
590 int ret;
591 583
592 /* Create new info device */ 584 /* Create new info device */
593 info = kzalloc(sizeof(*info), GFP_KERNEL); 585 info = kzalloc(sizeof(*info), GFP_KERNEL);
594 if (!info) 586 if (!info)
595 return NULL; 587 return -ENOMEM;
596 588
597 link = &info->link; 589 link = &info->link;
598 link->priv = info; 590 link->priv = info;
@@ -609,50 +601,24 @@ static dev_link_t *btuart_attach(void)
609 link->conf.Vcc = 50; 601 link->conf.Vcc = 50;
610 link->conf.IntType = INT_MEMORY_AND_IO; 602 link->conf.IntType = INT_MEMORY_AND_IO;
611 603
612 /* Register with Card Services */ 604 link->handle = p_dev;
613 link->next = dev_list; 605 p_dev->instance = link;
614 dev_list = link;
615 client_reg.dev_info = &dev_info;
616 client_reg.Version = 0x0210;
617 client_reg.event_callback_args.client_data = link;
618
619 ret = pcmcia_register_client(&link->handle, &client_reg);
620 if (ret != CS_SUCCESS) {
621 cs_error(link->handle, RegisterClient, ret);
622 btuart_detach(link);
623 return NULL;
624 }
625 606
626 return link; 607 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
608 btuart_config(link);
609
610 return 0;
627} 611}
628 612
629 613
630static void btuart_detach(dev_link_t *link) 614static void btuart_detach(struct pcmcia_device *p_dev)
631{ 615{
616 dev_link_t *link = dev_to_instance(p_dev);
632 btuart_info_t *info = link->priv; 617 btuart_info_t *info = link->priv;
633 dev_link_t **linkp;
634 int ret;
635
636 /* Locate device structure */
637 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
638 if (*linkp == link)
639 break;
640
641 if (*linkp == NULL)
642 return;
643 618
644 if (link->state & DEV_CONFIG) 619 if (link->state & DEV_CONFIG)
645 btuart_release(link); 620 btuart_release(link);
646 621
647 if (link->handle) {
648 ret = pcmcia_deregister_client(link->handle);
649 if (ret != CS_SUCCESS)
650 cs_error(link->handle, DeregisterClient, ret);
651 }
652
653 /* Unlink device structure, free bits */
654 *linkp = link->next;
655
656 kfree(info); 622 kfree(info);
657} 623}
658 624
@@ -811,43 +777,29 @@ static void btuart_release(dev_link_t *link)
811 link->state &= ~DEV_CONFIG; 777 link->state &= ~DEV_CONFIG;
812} 778}
813 779
780static int btuart_suspend(struct pcmcia_device *dev)
781{
782 dev_link_t *link = dev_to_instance(dev);
814 783
815static int btuart_event(event_t event, int priority, event_callback_args_t *args) 784 link->state |= DEV_SUSPEND;
785 if (link->state & DEV_CONFIG)
786 pcmcia_release_configuration(link->handle);
787
788 return 0;
789}
790
791static int btuart_resume(struct pcmcia_device *dev)
816{ 792{
817 dev_link_t *link = args->client_data; 793 dev_link_t *link = dev_to_instance(dev);
818 btuart_info_t *info = link->priv;
819 794
820 switch (event) { 795 link->state &= ~DEV_SUSPEND;
821 case CS_EVENT_CARD_REMOVAL: 796 if (DEV_OK(link))
822 link->state &= ~DEV_PRESENT; 797 pcmcia_request_configuration(link->handle, &link->conf);
823 if (link->state & DEV_CONFIG) {
824 btuart_close(info);
825 btuart_release(link);
826 }
827 break;
828 case CS_EVENT_CARD_INSERTION:
829 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
830 btuart_config(link);
831 break;
832 case CS_EVENT_PM_SUSPEND:
833 link->state |= DEV_SUSPEND;
834 /* Fall through... */
835 case CS_EVENT_RESET_PHYSICAL:
836 if (link->state & DEV_CONFIG)
837 pcmcia_release_configuration(link->handle);
838 break;
839 case CS_EVENT_PM_RESUME:
840 link->state &= ~DEV_SUSPEND;
841 /* Fall through... */
842 case CS_EVENT_CARD_RESET:
843 if (DEV_OK(link))
844 pcmcia_request_configuration(link->handle, &link->conf);
845 break;
846 }
847 798
848 return 0; 799 return 0;
849} 800}
850 801
802
851static struct pcmcia_device_id btuart_ids[] = { 803static struct pcmcia_device_id btuart_ids[] = {
852 /* don't use this driver. Use serial_cs + hci_uart instead */ 804 /* don't use this driver. Use serial_cs + hci_uart instead */
853 PCMCIA_DEVICE_NULL 805 PCMCIA_DEVICE_NULL
@@ -859,10 +811,11 @@ static struct pcmcia_driver btuart_driver = {
859 .drv = { 811 .drv = {
860 .name = "btuart_cs", 812 .name = "btuart_cs",
861 }, 813 },
862 .attach = btuart_attach, 814 .probe = btuart_attach,
863 .event = btuart_event, 815 .remove = btuart_detach,
864 .detach = btuart_detach,
865 .id_table = btuart_ids, 816 .id_table = btuart_ids,
817 .suspend = btuart_suspend,
818 .resume = btuart_resume,
866}; 819};
867 820
868static int __init init_btuart_cs(void) 821static int __init init_btuart_cs(void)
@@ -874,7 +827,6 @@ static int __init init_btuart_cs(void)
874static void __exit exit_btuart_cs(void) 827static void __exit exit_btuart_cs(void)
875{ 828{
876 pcmcia_unregister_driver(&btuart_driver); 829 pcmcia_unregister_driver(&btuart_driver);
877 BUG_ON(dev_list != NULL);
878} 830}
879 831
880module_init(init_btuart_cs); 832module_init(init_btuart_cs);
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index dec5980a1cd6..0449bc45ae5e 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -89,14 +89,8 @@ typedef struct dtl1_info_t {
89 89
90static void dtl1_config(dev_link_t *link); 90static void dtl1_config(dev_link_t *link);
91static void dtl1_release(dev_link_t *link); 91static void dtl1_release(dev_link_t *link);
92static int dtl1_event(event_t event, int priority, event_callback_args_t *args);
93 92
94static dev_info_t dev_info = "dtl1_cs"; 93static void dtl1_detach(struct pcmcia_device *p_dev);
95
96static dev_link_t *dtl1_attach(void);
97static void dtl1_detach(dev_link_t *);
98
99static dev_link_t *dev_list = NULL;
100 94
101 95
102/* Transmit states */ 96/* Transmit states */
@@ -561,17 +555,15 @@ static int dtl1_close(dtl1_info_t *info)
561 return 0; 555 return 0;
562} 556}
563 557
564static dev_link_t *dtl1_attach(void) 558static int dtl1_attach(struct pcmcia_device *p_dev)
565{ 559{
566 dtl1_info_t *info; 560 dtl1_info_t *info;
567 client_reg_t client_reg;
568 dev_link_t *link; 561 dev_link_t *link;
569 int ret;
570 562
571 /* Create new info device */ 563 /* Create new info device */
572 info = kzalloc(sizeof(*info), GFP_KERNEL); 564 info = kzalloc(sizeof(*info), GFP_KERNEL);
573 if (!info) 565 if (!info)
574 return NULL; 566 return -ENOMEM;
575 567
576 link = &info->link; 568 link = &info->link;
577 link->priv = info; 569 link->priv = info;
@@ -588,50 +580,24 @@ static dev_link_t *dtl1_attach(void)
588 link->conf.Vcc = 50; 580 link->conf.Vcc = 50;
589 link->conf.IntType = INT_MEMORY_AND_IO; 581 link->conf.IntType = INT_MEMORY_AND_IO;
590 582
591 /* Register with Card Services */ 583 link->handle = p_dev;
592 link->next = dev_list; 584 p_dev->instance = link;
593 dev_list = link;
594 client_reg.dev_info = &dev_info;
595 client_reg.Version = 0x0210;
596 client_reg.event_callback_args.client_data = link;
597
598 ret = pcmcia_register_client(&link->handle, &client_reg);
599 if (ret != CS_SUCCESS) {
600 cs_error(link->handle, RegisterClient, ret);
601 dtl1_detach(link);
602 return NULL;
603 }
604 585
605 return link; 586 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
587 dtl1_config(link);
588
589 return 0;
606} 590}
607 591
608 592
609static void dtl1_detach(dev_link_t *link) 593static void dtl1_detach(struct pcmcia_device *p_dev)
610{ 594{
595 dev_link_t *link = dev_to_instance(p_dev);
611 dtl1_info_t *info = link->priv; 596 dtl1_info_t *info = link->priv;
612 dev_link_t **linkp;
613 int ret;
614
615 /* Locate device structure */
616 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
617 if (*linkp == link)
618 break;
619
620 if (*linkp == NULL)
621 return;
622 597
623 if (link->state & DEV_CONFIG) 598 if (link->state & DEV_CONFIG)
624 dtl1_release(link); 599 dtl1_release(link);
625 600
626 if (link->handle) {
627 ret = pcmcia_deregister_client(link->handle);
628 if (ret != CS_SUCCESS)
629 cs_error(link->handle, DeregisterClient, ret);
630 }
631
632 /* Unlink device structure, free bits */
633 *linkp = link->next;
634
635 kfree(info); 601 kfree(info);
636} 602}
637 603
@@ -763,46 +729,33 @@ static void dtl1_release(dev_link_t *link)
763 link->state &= ~DEV_CONFIG; 729 link->state &= ~DEV_CONFIG;
764} 730}
765 731
732static int dtl1_suspend(struct pcmcia_device *dev)
733{
734 dev_link_t *link = dev_to_instance(dev);
766 735
767static int dtl1_event(event_t event, int priority, event_callback_args_t *args) 736 link->state |= DEV_SUSPEND;
737 if (link->state & DEV_CONFIG)
738 pcmcia_release_configuration(link->handle);
739
740 return 0;
741}
742
743static int dtl1_resume(struct pcmcia_device *dev)
768{ 744{
769 dev_link_t *link = args->client_data; 745 dev_link_t *link = dev_to_instance(dev);
770 dtl1_info_t *info = link->priv;
771 746
772 switch (event) { 747 link->state &= ~DEV_SUSPEND;
773 case CS_EVENT_CARD_REMOVAL: 748 if (DEV_OK(link))
774 link->state &= ~DEV_PRESENT; 749 pcmcia_request_configuration(link->handle, &link->conf);
775 if (link->state & DEV_CONFIG) {
776 dtl1_close(info);
777 dtl1_release(link);
778 }
779 break;
780 case CS_EVENT_CARD_INSERTION:
781 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
782 dtl1_config(link);
783 break;
784 case CS_EVENT_PM_SUSPEND:
785 link->state |= DEV_SUSPEND;
786 /* Fall through... */
787 case CS_EVENT_RESET_PHYSICAL:
788 if (link->state & DEV_CONFIG)
789 pcmcia_release_configuration(link->handle);
790 break;
791 case CS_EVENT_PM_RESUME:
792 link->state &= ~DEV_SUSPEND;
793 /* Fall through... */
794 case CS_EVENT_CARD_RESET:
795 if (DEV_OK(link))
796 pcmcia_request_configuration(link->handle, &link->conf);
797 break;
798 }
799 750
800 return 0; 751 return 0;
801} 752}
802 753
754
803static struct pcmcia_device_id dtl1_ids[] = { 755static struct pcmcia_device_id dtl1_ids[] = {
804 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d), 756 PCMCIA_DEVICE_PROD_ID12("Nokia Mobile Phones", "DTL-1", 0xe1bfdd64, 0xe168480d),
805 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863), 757 PCMCIA_DEVICE_PROD_ID12("Socket", "CF", 0xb38bcc2e, 0x44ebf863),
758 PCMCIA_DEVICE_PROD_ID12("Socket", "CF+ Personal Network Card", 0xb38bcc2e, 0xe732bae3),
806 PCMCIA_DEVICE_NULL 759 PCMCIA_DEVICE_NULL
807}; 760};
808MODULE_DEVICE_TABLE(pcmcia, dtl1_ids); 761MODULE_DEVICE_TABLE(pcmcia, dtl1_ids);
@@ -812,10 +765,11 @@ static struct pcmcia_driver dtl1_driver = {
812 .drv = { 765 .drv = {
813 .name = "dtl1_cs", 766 .name = "dtl1_cs",
814 }, 767 },
815 .attach = dtl1_attach, 768 .probe = dtl1_attach,
816 .event = dtl1_event, 769 .remove = dtl1_detach,
817 .detach = dtl1_detach,
818 .id_table = dtl1_ids, 770 .id_table = dtl1_ids,
771 .suspend = dtl1_suspend,
772 .resume = dtl1_resume,
819}; 773};
820 774
821static int __init init_dtl1_cs(void) 775static int __init init_dtl1_cs(void)
@@ -827,7 +781,6 @@ static int __init init_dtl1_cs(void)
827static void __exit exit_dtl1_cs(void) 781static void __exit exit_dtl1_cs(void)
828{ 782{
829 pcmcia_unregister_driver(&dtl1_driver); 783 pcmcia_unregister_driver(&dtl1_driver);
830 BUG_ON(dev_list != NULL);
831} 784}
832 785
833module_init(init_dtl1_cs); 786module_init(init_dtl1_cs);
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c
index 057cb2b6e6d1..92382e823285 100644
--- a/drivers/bluetooth/hci_usb.c
+++ b/drivers/bluetooth/hci_usb.c
@@ -1044,7 +1044,6 @@ static void hci_usb_disconnect(struct usb_interface *intf)
1044} 1044}
1045 1045
1046static struct usb_driver hci_usb_driver = { 1046static struct usb_driver hci_usb_driver = {
1047 .owner = THIS_MODULE,
1048 .name = "hci_usb", 1047 .name = "hci_usb",
1049 .probe = hci_usb_probe, 1048 .probe = hci_usb_probe,
1050 .disconnect = hci_usb_disconnect, 1049 .disconnect = hci_usb_disconnect,
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
index ac96de15d833..378e88d20757 100644
--- a/drivers/cdrom/cdu31a.c
+++ b/drivers/cdrom/cdu31a.c
@@ -1402,7 +1402,7 @@ static void do_cdu31a_request(request_queue_t * q)
1402 if (!end_that_request_first(req, 1, nblock)) { 1402 if (!end_that_request_first(req, 1, nblock)) {
1403 spin_lock_irq(q->queue_lock); 1403 spin_lock_irq(q->queue_lock);
1404 blkdev_dequeue_request(req); 1404 blkdev_dequeue_request(req);
1405 end_that_request_last(req); 1405 end_that_request_last(req, 1);
1406 spin_unlock_irq(q->queue_lock); 1406 spin_unlock_irq(q->queue_lock);
1407 } 1407 }
1408 continue; 1408 continue;
diff --git a/drivers/char/.gitignore b/drivers/char/.gitignore
index 2b6b1d772ed7..73dfdcebfbba 100644
--- a/drivers/char/.gitignore
+++ b/drivers/char/.gitignore
@@ -1,3 +1,3 @@
1consolemap_deftbl.c 1consolemap_deftbl.c
2defkeymap.c 2defkeymap.c
3 3qtronixmap.c
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 970f70d498f4..5ebd06b1b4ca 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -687,7 +687,7 @@ config NVRAM
687 687
688config RTC 688config RTC
689 tristate "Enhanced Real Time Clock Support" 689 tristate "Enhanced Real Time Clock Support"
690 depends on !PPC32 && !PARISC && !IA64 && !M68K 690 depends on !PPC32 && !PARISC && !IA64 && !M68K && (!SPARC || PCI)
691 ---help--- 691 ---help---
692 If you say Y here and create a character special file /dev/rtc with 692 If you say Y here and create a character special file /dev/rtc with
693 major number 10 and minor number 135 using mknod ("man mknod"), you 693 major number 10 and minor number 135 using mknod ("man mknod"), you
@@ -735,7 +735,7 @@ config SGI_IP27_RTC
735 735
736config GEN_RTC 736config GEN_RTC
737 tristate "Generic /dev/rtc emulation" 737 tristate "Generic /dev/rtc emulation"
738 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC32 && !SPARC64 738 depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC
739 ---help--- 739 ---help---
740 If you say Y here and create a character special file /dev/rtc with 740 If you say Y here and create a character special file /dev/rtc with
741 major number 10 and minor number 135 using mknod ("man mknod"), you 741 major number 10 and minor number 135 using mknod ("man mknod"), you
@@ -943,6 +943,15 @@ config RAW_DRIVER
943 Applications should simply open the device (eg /dev/hda1) 943 Applications should simply open the device (eg /dev/hda1)
944 with the O_DIRECT flag. 944 with the O_DIRECT flag.
945 945
946config MAX_RAW_DEVS
947 int "Maximum number of RAW devices to support (1-8192)"
948 depends on RAW_DRIVER
949 default "256"
950 help
951 The maximum number of RAW devices that are supported.
952 Default is 256. Increase this number in case you need lots of
953 raw devices.
954
946config HPET 955config HPET
947 bool "HPET - High Precision Event Timer" if (X86 || IA64) 956 bool "HPET - High Precision Event Timer" if (X86 || IA64)
948 default n 957 default n
@@ -974,18 +983,9 @@ config HPET_MMAP
974 exposed to the user. If this applies to your hardware, 983 exposed to the user. If this applies to your hardware,
975 say N here. 984 say N here.
976 985
977config MAX_RAW_DEVS
978 int "Maximum number of RAW devices to support (1-8192)"
979 depends on RAW_DRIVER
980 default "256"
981 help
982 The maximum number of RAW devices that are supported.
983 Default is 256. Increase this number in case you need lots of
984 raw devices.
985
986config HANGCHECK_TIMER 986config HANGCHECK_TIMER
987 tristate "Hangcheck timer" 987 tristate "Hangcheck timer"
988 depends on X86 || IA64 || PPC64 || ARCH_S390 988 depends on X86 || IA64 || PPC64 || S390
989 help 989 help
990 The hangcheck-timer module detects when the system has gone 990 The hangcheck-timer module detects when the system has gone
991 out to lunch past a certain margin. It can reboot the system 991 out to lunch past a certain margin. It can reboot the system
diff --git a/drivers/char/drm/radeon_cp.c b/drivers/char/drm/radeon_cp.c
index 03839ea31092..342302d46743 100644
--- a/drivers/char/drm/radeon_cp.c
+++ b/drivers/char/drm/radeon_cp.c
@@ -1311,7 +1311,7 @@ static void radeon_set_pcigart(drm_radeon_private_t * dev_priv, int on)
1311 1311
1312static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init) 1312static int radeon_do_init_cp(drm_device_t * dev, drm_radeon_init_t * init)
1313{ 1313{
1314 drm_radeon_private_t *dev_priv = dev->dev_private;; 1314 drm_radeon_private_t *dev_priv = dev->dev_private;
1315 DRM_DEBUG("\n"); 1315 DRM_DEBUG("\n");
1316 1316
1317 dev_priv->is_pci = init->is_pci; 1317 dev_priv->is_pci = init->is_pci;
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index 7bda7e33d2bd..d92ccee3e54c 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -379,6 +379,7 @@ extern int r300_do_cp_cmdbuf(drm_device_t * dev, DRMFILE filp,
379# define RADEON_PLL_WR_EN (1 << 7) 379# define RADEON_PLL_WR_EN (1 << 7)
380#define RADEON_CLOCK_CNTL_INDEX 0x0008 380#define RADEON_CLOCK_CNTL_INDEX 0x0008
381#define RADEON_CONFIG_APER_SIZE 0x0108 381#define RADEON_CONFIG_APER_SIZE 0x0108
382#define RADEON_CONFIG_MEMSIZE 0x00f8
382#define RADEON_CRTC_OFFSET 0x0224 383#define RADEON_CRTC_OFFSET 0x0224
383#define RADEON_CRTC_OFFSET_CNTL 0x0228 384#define RADEON_CRTC_OFFSET_CNTL 0x0228
384# define RADEON_CRTC_TILE_EN (1 << 15) 385# define RADEON_CRTC_TILE_EN (1 << 15)
diff --git a/drivers/char/hangcheck-timer.c b/drivers/char/hangcheck-timer.c
index 66e53dd450ff..40a67c86420c 100644
--- a/drivers/char/hangcheck-timer.c
+++ b/drivers/char/hangcheck-timer.c
@@ -120,7 +120,7 @@ __setup("hcheck_dump_tasks", hangcheck_parse_dump_tasks);
120#if defined(CONFIG_X86) 120#if defined(CONFIG_X86)
121# define HAVE_MONOTONIC 121# define HAVE_MONOTONIC
122# define TIMER_FREQ 1000000000ULL 122# define TIMER_FREQ 1000000000ULL
123#elif defined(CONFIG_ARCH_S390) 123#elif defined(CONFIG_S390)
124/* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */ 124/* FA240000 is 1 Second in the IBM time universe (Page 4-38 Principles of Op for zSeries */
125# define TIMER_FREQ 0xFA240000ULL 125# define TIMER_FREQ 0xFA240000ULL
126#elif defined(CONFIG_IA64) 126#elif defined(CONFIG_IA64)
diff --git a/drivers/char/hw_random.c b/drivers/char/hw_random.c
index 6f673d2de0b1..49769f59ea1b 100644
--- a/drivers/char/hw_random.c
+++ b/drivers/char/hw_random.c
@@ -1,4 +1,9 @@
1/* 1/*
2 Added support for the AMD Geode LX RNG
3 (c) Copyright 2004-2005 Advanced Micro Devices, Inc.
4
5 derived from
6
2 Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG) 7 Hardware driver for the Intel/AMD/VIA Random Number Generators (RNG)
3 (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com> 8 (c) Copyright 2003 Red Hat Inc <jgarzik@redhat.com>
4 9
@@ -95,6 +100,11 @@ static unsigned int via_data_present (void);
95static u32 via_data_read (void); 100static u32 via_data_read (void);
96#endif 101#endif
97 102
103static int __init geode_init(struct pci_dev *dev);
104static void geode_cleanup(void);
105static unsigned int geode_data_present (void);
106static u32 geode_data_read (void);
107
98struct rng_operations { 108struct rng_operations {
99 int (*init) (struct pci_dev *dev); 109 int (*init) (struct pci_dev *dev);
100 void (*cleanup) (void); 110 void (*cleanup) (void);
@@ -122,6 +132,7 @@ enum {
122 rng_hw_intel, 132 rng_hw_intel,
123 rng_hw_amd, 133 rng_hw_amd,
124 rng_hw_via, 134 rng_hw_via,
135 rng_hw_geode,
125}; 136};
126 137
127static struct rng_operations rng_vendor_ops[] = { 138static struct rng_operations rng_vendor_ops[] = {
@@ -139,6 +150,9 @@ static struct rng_operations rng_vendor_ops[] = {
139 /* rng_hw_via */ 150 /* rng_hw_via */
140 { via_init, via_cleanup, via_data_present, via_data_read, 1 }, 151 { via_init, via_cleanup, via_data_present, via_data_read, 1 },
141#endif 152#endif
153
154 /* rng_hw_geode */
155 { geode_init, geode_cleanup, geode_data_present, geode_data_read, 4 }
142}; 156};
143 157
144/* 158/*
@@ -159,6 +173,9 @@ static struct pci_device_id rng_pci_tbl[] = {
159 { 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, 173 { 0x8086, 0x244e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
160 { 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel }, 174 { 0x8086, 0x245e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_intel },
161 175
176 { PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LX_AES,
177 PCI_ANY_ID, PCI_ANY_ID, 0, 0, rng_hw_geode },
178
162 { 0, }, /* terminate list */ 179 { 0, }, /* terminate list */
163}; 180};
164MODULE_DEVICE_TABLE (pci, rng_pci_tbl); 181MODULE_DEVICE_TABLE (pci, rng_pci_tbl);
@@ -460,6 +477,57 @@ static void via_cleanup(void)
460} 477}
461#endif 478#endif
462 479
480/***********************************************************************
481 *
482 * AMD Geode RNG operations
483 *
484 */
485
486static void __iomem *geode_rng_base = NULL;
487
488#define GEODE_RNG_DATA_REG 0x50
489#define GEODE_RNG_STATUS_REG 0x54
490
491static u32 geode_data_read(void)
492{
493 u32 val;
494
495 assert(geode_rng_base != NULL);
496 val = readl(geode_rng_base + GEODE_RNG_DATA_REG);
497 return val;
498}
499
500static unsigned int geode_data_present(void)
501{
502 u32 val;
503
504 assert(geode_rng_base != NULL);
505 val = readl(geode_rng_base + GEODE_RNG_STATUS_REG);
506 return val;
507}
508
509static void geode_cleanup(void)
510{
511 iounmap(geode_rng_base);
512 geode_rng_base = NULL;
513}
514
515static int geode_init(struct pci_dev *dev)
516{
517 unsigned long rng_base = pci_resource_start(dev, 0);
518
519 if (rng_base == 0)
520 return 1;
521
522 geode_rng_base = ioremap(rng_base, 0x58);
523
524 if (geode_rng_base == NULL) {
525 printk(KERN_ERR PFX "Cannot ioremap RNG memory\n");
526 return -EBUSY;
527 }
528
529 return 0;
530}
463 531
464/*********************************************************************** 532/***********************************************************************
465 * 533 *
@@ -574,7 +642,7 @@ static int __init rng_init (void)
574 642
575 DPRINTK ("ENTER\n"); 643 DPRINTK ("ENTER\n");
576 644
577 /* Probe for Intel, AMD RNGs */ 645 /* Probe for Intel, AMD, Geode RNGs */
578 for_each_pci_dev(pdev) { 646 for_each_pci_dev(pdev) {
579 ent = pci_match_id(rng_pci_tbl, pdev); 647 ent = pci_match_id(rng_pci_tbl, pdev);
580 if (ent) { 648 if (ent) {
diff --git a/drivers/char/ip2/i2pack.h b/drivers/char/ip2/i2pack.h
index e9b87a78622c..00342a677c90 100644
--- a/drivers/char/ip2/i2pack.h
+++ b/drivers/char/ip2/i2pack.h
@@ -358,7 +358,7 @@ typedef struct _failStat
358#define MB_OUT_STRIPPED 0x40 // Board has read all output from fifo 358#define MB_OUT_STRIPPED 0x40 // Board has read all output from fifo
359#define MB_FATAL_ERROR 0x20 // Board has encountered a fatal error 359#define MB_FATAL_ERROR 0x20 // Board has encountered a fatal error
360 360
361#pragma pack(4) // Reset padding to command-line default 361#pragma pack() // Reset padding to command-line default
362 362
363#endif // I2PACK_H 363#endif // I2PACK_H
364 364
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 6b302a930e5f..561430ed94af 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -787,7 +787,6 @@ int ipmi_destroy_user(ipmi_user_t user)
787 int i; 787 int i;
788 unsigned long flags; 788 unsigned long flags;
789 struct cmd_rcvr *rcvr; 789 struct cmd_rcvr *rcvr;
790 struct list_head *entry1, *entry2;
791 struct cmd_rcvr *rcvrs = NULL; 790 struct cmd_rcvr *rcvrs = NULL;
792 791
793 user->valid = 1; 792 user->valid = 1;
@@ -812,8 +811,7 @@ int ipmi_destroy_user(ipmi_user_t user)
812 * synchronize_rcu()) then free everything in that list. 811 * synchronize_rcu()) then free everything in that list.
813 */ 812 */
814 down(&intf->cmd_rcvrs_lock); 813 down(&intf->cmd_rcvrs_lock);
815 list_for_each_safe_rcu(entry1, entry2, &intf->cmd_rcvrs) { 814 list_for_each_entry_rcu(rcvr, &intf->cmd_rcvrs, link) {
816 rcvr = list_entry(entry1, struct cmd_rcvr, link);
817 if (rcvr->user == user) { 815 if (rcvr->user == user) {
818 list_del_rcu(&rcvr->link); 816 list_del_rcu(&rcvr->link);
819 rcvr->next = rcvrs; 817 rcvr->next = rcvrs;
@@ -2986,7 +2984,7 @@ static void send_panic_events(char *str)
2986 msg.cmd = 2; /* Platform event command. */ 2984 msg.cmd = 2; /* Platform event command. */
2987 msg.data = data; 2985 msg.data = data;
2988 msg.data_len = 8; 2986 msg.data_len = 8;
2989 data[0] = 0x21; /* Kernel generator ID, IPMI table 5-4 */ 2987 data[0] = 0x41; /* Kernel generator ID, IPMI table 5-4 */
2990 data[1] = 0x03; /* This is for IPMI 1.0. */ 2988 data[1] = 0x03; /* This is for IPMI 1.0. */
2991 data[2] = 0x20; /* OS Critical Stop, IPMI table 36-3 */ 2989 data[2] = 0x20; /* OS Critical Stop, IPMI table 36-3 */
2992 data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */ 2990 data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
index 01a1f6badb53..beea450ee4b2 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2399,7 +2399,8 @@ static int init_one_smi(int intf_num, struct smi_info **smi)
2399 new_smi->handlers->cleanup(new_smi->si_sm); 2399 new_smi->handlers->cleanup(new_smi->si_sm);
2400 kfree(new_smi->si_sm); 2400 kfree(new_smi->si_sm);
2401 } 2401 }
2402 new_smi->io_cleanup(new_smi); 2402 if (new_smi->io_cleanup)
2403 new_smi->io_cleanup(new_smi);
2403 2404
2404 return rv; 2405 return rv;
2405} 2406}
@@ -2518,7 +2519,8 @@ static void __exit cleanup_one_si(struct smi_info *to_clean)
2518 2519
2519 kfree(to_clean->si_sm); 2520 kfree(to_clean->si_sm);
2520 2521
2521 to_clean->io_cleanup(to_clean); 2522 if (to_clean->io_cleanup)
2523 to_clean->io_cleanup(to_clean);
2522} 2524}
2523 2525
2524static __exit void cleanup_ipmi_si(void) 2526static __exit void cleanup_ipmi_si(void)
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c
index 449d029ad4f4..8b603b2d1c42 100644
--- a/drivers/char/keyboard.c
+++ b/drivers/char/keyboard.c
@@ -930,8 +930,8 @@ static void kbd_refresh_leds(struct input_handle *handle)
930} 930}
931 931
932#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\ 932#if defined(CONFIG_X86) || defined(CONFIG_IA64) || defined(CONFIG_ALPHA) ||\
933 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC32) ||\ 933 defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) ||\
934 defined(CONFIG_SPARC64) || defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\ 934 defined(CONFIG_PARISC) || defined(CONFIG_SUPERH) ||\
935 (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC)) 935 (defined(CONFIG_ARM) && defined(CONFIG_KEYBOARD_ATKBD) && !defined(CONFIG_ARCH_RPC))
936 936
937#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\ 937#define HW_RAW(dev) (test_bit(EV_MSC, dev->evbit) && test_bit(MSC_RAW, dev->mscbit) &&\
@@ -958,7 +958,7 @@ static unsigned short x86_keycodes[256] =
958extern int mac_hid_mouse_emulate_buttons(int, int, int); 958extern int mac_hid_mouse_emulate_buttons(int, int, int);
959#endif /* CONFIG_MAC_EMUMOUSEBTN */ 959#endif /* CONFIG_MAC_EMUMOUSEBTN */
960 960
961#if defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) 961#ifdef CONFIG_SPARC
962static int sparc_l1_a_state = 0; 962static int sparc_l1_a_state = 0;
963extern void sun_do_break(void); 963extern void sun_do_break(void);
964#endif 964#endif
@@ -1045,7 +1045,7 @@ static void kbd_keycode(unsigned int keycode, int down,
1045 1045
1046 if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT) 1046 if (keycode == KEY_LEFTALT || keycode == KEY_RIGHTALT)
1047 sysrq_alt = down; 1047 sysrq_alt = down;
1048#if defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) 1048#ifdef CONFIG_SPARC
1049 if (keycode == KEY_STOP) 1049 if (keycode == KEY_STOP)
1050 sparc_l1_a_state = down; 1050 sparc_l1_a_state = down;
1051#endif 1051#endif
@@ -1072,7 +1072,7 @@ static void kbd_keycode(unsigned int keycode, int down,
1072 return; 1072 return;
1073 } 1073 }
1074#endif 1074#endif
1075#if defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) 1075#ifdef CONFIG_SPARC
1076 if (keycode == KEY_A && sparc_l1_a_state) { 1076 if (keycode == KEY_A && sparc_l1_a_state) {
1077 sparc_l1_a_state = 0; 1077 sparc_l1_a_state = 0;
1078 sun_do_break(); 1078 sun_do_break();
diff --git a/drivers/char/mmtimer.c b/drivers/char/mmtimer.c
index 78c89a3e7825..c92378121b4c 100644
--- a/drivers/char/mmtimer.c
+++ b/drivers/char/mmtimer.c
@@ -1,11 +1,11 @@
1/* 1/*
2 * Intel Multimedia Timer device implementation for SGI SN platforms. 2 * Timer device implementation for SGI SN platforms.
3 * 3 *
4 * This file is subject to the terms and conditions of the GNU General Public 4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive 5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details. 6 * for more details.
7 * 7 *
8 * Copyright (c) 2001-2004 Silicon Graphics, Inc. All rights reserved. 8 * Copyright (c) 2001-2006 Silicon Graphics, Inc. All rights reserved.
9 * 9 *
10 * This driver exports an API that should be supportable by any HPET or IA-PC 10 * This driver exports an API that should be supportable by any HPET or IA-PC
11 * multimedia timer. The code below is currently specific to the SGI Altix 11 * multimedia timer. The code below is currently specific to the SGI Altix
@@ -45,7 +45,7 @@ MODULE_LICENSE("GPL");
45/* name of the device, usually in /dev */ 45/* name of the device, usually in /dev */
46#define MMTIMER_NAME "mmtimer" 46#define MMTIMER_NAME "mmtimer"
47#define MMTIMER_DESC "SGI Altix RTC Timer" 47#define MMTIMER_DESC "SGI Altix RTC Timer"
48#define MMTIMER_VERSION "2.0" 48#define MMTIMER_VERSION "2.1"
49 49
50#define RTC_BITS 55 /* 55 bits for this implementation */ 50#define RTC_BITS 55 /* 55 bits for this implementation */
51 51
@@ -227,10 +227,7 @@ typedef struct mmtimer {
227 struct tasklet_struct tasklet; 227 struct tasklet_struct tasklet;
228} mmtimer_t; 228} mmtimer_t;
229 229
230/* 230static mmtimer_t ** timers;
231 * Total number of comparators is comparators/node * MAX nodes/running kernel
232 */
233static mmtimer_t timers[NUM_COMPARATORS*MAX_COMPACT_NODES];
234 231
235/** 232/**
236 * mmtimer_ioctl - ioctl interface for /dev/mmtimer 233 * mmtimer_ioctl - ioctl interface for /dev/mmtimer
@@ -441,29 +438,29 @@ static irqreturn_t
441mmtimer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 438mmtimer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
442{ 439{
443 int i; 440 int i;
444 mmtimer_t *base = timers + cpu_to_node(smp_processor_id()) *
445 NUM_COMPARATORS;
446 unsigned long expires = 0; 441 unsigned long expires = 0;
447 int result = IRQ_NONE; 442 int result = IRQ_NONE;
443 unsigned indx = cpu_to_node(smp_processor_id());
448 444
449 /* 445 /*
450 * Do this once for each comparison register 446 * Do this once for each comparison register
451 */ 447 */
452 for (i = 0; i < NUM_COMPARATORS; i++) { 448 for (i = 0; i < NUM_COMPARATORS; i++) {
449 mmtimer_t *base = timers[indx] + i;
453 /* Make sure this doesn't get reused before tasklet_sched */ 450 /* Make sure this doesn't get reused before tasklet_sched */
454 spin_lock(&base[i].lock); 451 spin_lock(&base->lock);
455 if (base[i].cpu == smp_processor_id()) { 452 if (base->cpu == smp_processor_id()) {
456 if (base[i].timer) 453 if (base->timer)
457 expires = base[i].timer->it.mmtimer.expires; 454 expires = base->timer->it.mmtimer.expires;
458 /* expires test won't work with shared irqs */ 455 /* expires test won't work with shared irqs */
459 if ((mmtimer_int_pending(i) > 0) || 456 if ((mmtimer_int_pending(i) > 0) ||
460 (expires && (expires < rtc_time()))) { 457 (expires && (expires < rtc_time()))) {
461 mmtimer_clr_int_pending(i); 458 mmtimer_clr_int_pending(i);
462 tasklet_schedule(&base[i].tasklet); 459 tasklet_schedule(&base->tasklet);
463 result = IRQ_HANDLED; 460 result = IRQ_HANDLED;
464 } 461 }
465 } 462 }
466 spin_unlock(&base[i].lock); 463 spin_unlock(&base->lock);
467 expires = 0; 464 expires = 0;
468 } 465 }
469 return result; 466 return result;
@@ -523,7 +520,7 @@ static int sgi_timer_del(struct k_itimer *timr)
523{ 520{
524 int i = timr->it.mmtimer.clock; 521 int i = timr->it.mmtimer.clock;
525 cnodeid_t nodeid = timr->it.mmtimer.node; 522 cnodeid_t nodeid = timr->it.mmtimer.node;
526 mmtimer_t *t = timers + nodeid * NUM_COMPARATORS +i; 523 mmtimer_t *t = timers[nodeid] + i;
527 unsigned long irqflags; 524 unsigned long irqflags;
528 525
529 if (i != TIMER_OFF) { 526 if (i != TIMER_OFF) {
@@ -609,11 +606,11 @@ static int sgi_timer_set(struct k_itimer *timr, int flags,
609 preempt_disable(); 606 preempt_disable();
610 607
611 nodeid = cpu_to_node(smp_processor_id()); 608 nodeid = cpu_to_node(smp_processor_id());
612 base = timers + nodeid * NUM_COMPARATORS;
613retry: 609retry:
614 /* Don't use an allocated timer, or a deleted one that's pending */ 610 /* Don't use an allocated timer, or a deleted one that's pending */
615 for(i = 0; i< NUM_COMPARATORS; i++) { 611 for(i = 0; i< NUM_COMPARATORS; i++) {
616 if (!base[i].timer && !base[i].tasklet.state) { 612 base = timers[nodeid] + i;
613 if (!base->timer && !base->tasklet.state) {
617 break; 614 break;
618 } 615 }
619 } 616 }
@@ -623,14 +620,14 @@ retry:
623 return -EBUSY; 620 return -EBUSY;
624 } 621 }
625 622
626 spin_lock_irqsave(&base[i].lock, irqflags); 623 spin_lock_irqsave(&base->lock, irqflags);
627 624
628 if (base[i].timer || base[i].tasklet.state != 0) { 625 if (base->timer || base->tasklet.state != 0) {
629 spin_unlock_irqrestore(&base[i].lock, irqflags); 626 spin_unlock_irqrestore(&base->lock, irqflags);
630 goto retry; 627 goto retry;
631 } 628 }
632 base[i].timer = timr; 629 base->timer = timr;
633 base[i].cpu = smp_processor_id(); 630 base->cpu = smp_processor_id();
634 631
635 timr->it.mmtimer.clock = i; 632 timr->it.mmtimer.clock = i;
636 timr->it.mmtimer.node = nodeid; 633 timr->it.mmtimer.node = nodeid;
@@ -645,11 +642,11 @@ retry:
645 } 642 }
646 } else { 643 } else {
647 timr->it.mmtimer.expires -= period; 644 timr->it.mmtimer.expires -= period;
648 if (reschedule_periodic_timer(base+i)) 645 if (reschedule_periodic_timer(base))
649 err = -EINVAL; 646 err = -EINVAL;
650 } 647 }
651 648
652 spin_unlock_irqrestore(&base[i].lock, irqflags); 649 spin_unlock_irqrestore(&base->lock, irqflags);
653 650
654 preempt_enable(); 651 preempt_enable();
655 652
@@ -675,6 +672,7 @@ static struct k_clock sgi_clock = {
675static int __init mmtimer_init(void) 672static int __init mmtimer_init(void)
676{ 673{
677 unsigned i; 674 unsigned i;
675 cnodeid_t node, maxn = -1;
678 676
679 if (!ia64_platform_is("sn2")) 677 if (!ia64_platform_is("sn2"))
680 return -1; 678 return -1;
@@ -691,14 +689,6 @@ static int __init mmtimer_init(void)
691 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second / 689 mmtimer_femtoperiod = ((unsigned long)1E15 + sn_rtc_cycles_per_second /
692 2) / sn_rtc_cycles_per_second; 690 2) / sn_rtc_cycles_per_second;
693 691
694 for (i=0; i< NUM_COMPARATORS*MAX_COMPACT_NODES; i++) {
695 spin_lock_init(&timers[i].lock);
696 timers[i].timer = NULL;
697 timers[i].cpu = 0;
698 timers[i].i = i % NUM_COMPARATORS;
699 tasklet_init(&timers[i].tasklet, mmtimer_tasklet, (unsigned long) (timers+i));
700 }
701
702 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, SA_PERCPU_IRQ, MMTIMER_NAME, NULL)) { 692 if (request_irq(SGI_MMTIMER_VECTOR, mmtimer_interrupt, SA_PERCPU_IRQ, MMTIMER_NAME, NULL)) {
703 printk(KERN_WARNING "%s: unable to allocate interrupt.", 693 printk(KERN_WARNING "%s: unable to allocate interrupt.",
704 MMTIMER_NAME); 694 MMTIMER_NAME);
@@ -712,6 +702,40 @@ static int __init mmtimer_init(void)
712 return -1; 702 return -1;
713 } 703 }
714 704
705 /* Get max numbered node, calculate slots needed */
706 for_each_online_node(node) {
707 maxn = node;
708 }
709 maxn++;
710
711 /* Allocate list of node ptrs to mmtimer_t's */
712 timers = kmalloc(sizeof(mmtimer_t *)*maxn, GFP_KERNEL);
713 if (timers == NULL) {
714 printk(KERN_ERR "%s: failed to allocate memory for device\n",
715 MMTIMER_NAME);
716 return -1;
717 }
718
719 /* Allocate mmtimer_t's for each online node */
720 for_each_online_node(node) {
721 timers[node] = kmalloc_node(sizeof(mmtimer_t)*NUM_COMPARATORS, GFP_KERNEL, node);
722 if (timers[node] == NULL) {
723 printk(KERN_ERR "%s: failed to allocate memory for device\n",
724 MMTIMER_NAME);
725 return -1;
726 }
727 for (i=0; i< NUM_COMPARATORS; i++) {
728 mmtimer_t * base = timers[node] + i;
729
730 spin_lock_init(&base->lock);
731 base->timer = NULL;
732 base->cpu = 0;
733 base->i = i;
734 tasklet_init(&base->tasklet, mmtimer_tasklet,
735 (unsigned long) (base));
736 }
737 }
738
715 sgi_clock_period = sgi_clock.res = NSEC_PER_SEC / sn_rtc_cycles_per_second; 739 sgi_clock_period = sgi_clock.res = NSEC_PER_SEC / sn_rtc_cycles_per_second;
716 register_posix_clock(CLOCK_SGI_CYCLE, &sgi_clock); 740 register_posix_clock(CLOCK_SGI_CYCLE, &sgi_clock);
717 741
diff --git a/drivers/char/mwave/mwavepub.h b/drivers/char/mwave/mwavepub.h
index f1f9da7a65c1..60c961ae23b4 100644
--- a/drivers/char/mwave/mwavepub.h
+++ b/drivers/char/mwave/mwavepub.h
@@ -69,7 +69,7 @@ typedef struct _MW_ABILITIES {
69typedef struct _MW_READWRITE { 69typedef struct _MW_READWRITE {
70 unsigned short usDspAddress; /* The dsp address */ 70 unsigned short usDspAddress; /* The dsp address */
71 unsigned long ulDataLength; /* The size in bytes of the data or user buffer */ 71 unsigned long ulDataLength; /* The size in bytes of the data or user buffer */
72 void *pBuf; /* Input:variable sized buffer */ 72 void __user *pBuf; /* Input:variable sized buffer */
73} MW_READWRITE, *pMW_READWRITE; 73} MW_READWRITE, *pMW_READWRITE;
74 74
75#define IOCTL_MW_RESET _IO(MWAVE_MINOR,1) 75#define IOCTL_MW_RESET _IO(MWAVE_MINOR,1)
diff --git a/drivers/char/n_hdlc.c b/drivers/char/n_hdlc.c
index c3660d8781a4..a133a62f3d55 100644
--- a/drivers/char/n_hdlc.c
+++ b/drivers/char/n_hdlc.c
@@ -562,7 +562,7 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
562} /* end of n_hdlc_tty_receive() */ 562} /* end of n_hdlc_tty_receive() */
563 563
564/** 564/**
565 * n_hdlc_tty_read - Called to retreive one frame of data (if available) 565 * n_hdlc_tty_read - Called to retrieve one frame of data (if available)
566 * @tty - pointer to tty instance data 566 * @tty - pointer to tty instance data
567 * @file - pointer to open file object 567 * @file - pointer to open file object
568 * @buf - pointer to returned data buffer 568 * @buf - pointer to returned data buffer
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index ef011ef5dc46..649677b5dc36 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -66,7 +66,6 @@ static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte";
66#define T_100MSEC msecs_to_jiffies(100) 66#define T_100MSEC msecs_to_jiffies(100)
67#define T_500MSEC msecs_to_jiffies(500) 67#define T_500MSEC msecs_to_jiffies(500)
68 68
69static void cm4000_detach(dev_link_t *link);
70static void cm4000_release(dev_link_t *link); 69static void cm4000_release(dev_link_t *link);
71 70
72static int major; /* major number we get from the kernel */ 71static int major; /* major number we get from the kernel */
@@ -156,7 +155,6 @@ struct cm4000_dev {
156 /*sbuf*/ 512*sizeof(char) - \ 155 /*sbuf*/ 512*sizeof(char) - \
157 /*queue*/ 4*sizeof(wait_queue_head_t)) 156 /*queue*/ 4*sizeof(wait_queue_head_t))
158 157
159static dev_info_t dev_info = MODULE_NAME;
160static dev_link_t *dev_table[CM4000_MAX_DEV]; 158static dev_link_t *dev_table[CM4000_MAX_DEV];
161 159
162/* This table doesn't use spaces after the comma between fields and thus 160/* This table doesn't use spaces after the comma between fields and thus
@@ -1444,6 +1442,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1444 dev_link_t *link; 1442 dev_link_t *link;
1445 int size; 1443 int size;
1446 int rc; 1444 int rc;
1445 void __user *argp = (void __user *)arg;
1447#ifdef PCMCIA_DEBUG 1446#ifdef PCMCIA_DEBUG
1448 char *ioctl_names[CM_IOC_MAXNR + 1] = { 1447 char *ioctl_names[CM_IOC_MAXNR + 1] = {
1449 [_IOC_NR(CM_IOCGSTATUS)] "CM_IOCGSTATUS", 1448 [_IOC_NR(CM_IOCGSTATUS)] "CM_IOCGSTATUS",
@@ -1481,11 +1480,11 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1481 _IOC_DIR(cmd), _IOC_READ, _IOC_WRITE, size, cmd); 1480 _IOC_DIR(cmd), _IOC_READ, _IOC_WRITE, size, cmd);
1482 1481
1483 if (_IOC_DIR(cmd) & _IOC_READ) { 1482 if (_IOC_DIR(cmd) & _IOC_READ) {
1484 if (!access_ok(VERIFY_WRITE, (void *)arg, size)) 1483 if (!access_ok(VERIFY_WRITE, argp, size))
1485 return -EFAULT; 1484 return -EFAULT;
1486 } 1485 }
1487 if (_IOC_DIR(cmd) & _IOC_WRITE) { 1486 if (_IOC_DIR(cmd) & _IOC_WRITE) {
1488 if (!access_ok(VERIFY_READ, (void *)arg, size)) 1487 if (!access_ok(VERIFY_READ, argp, size))
1489 return -EFAULT; 1488 return -EFAULT;
1490 } 1489 }
1491 1490
@@ -1506,14 +1505,14 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1506 status |= CM_NO_READER; 1505 status |= CM_NO_READER;
1507 if (test_bit(IS_BAD_CARD, &dev->flags)) 1506 if (test_bit(IS_BAD_CARD, &dev->flags))
1508 status |= CM_BAD_CARD; 1507 status |= CM_BAD_CARD;
1509 if (copy_to_user((int *)arg, &status, sizeof(int))) 1508 if (copy_to_user(argp, &status, sizeof(int)))
1510 return -EFAULT; 1509 return -EFAULT;
1511 } 1510 }
1512 return 0; 1511 return 0;
1513 case CM_IOCGATR: 1512 case CM_IOCGATR:
1514 DEBUGP(4, dev, "... in CM_IOCGATR\n"); 1513 DEBUGP(4, dev, "... in CM_IOCGATR\n");
1515 { 1514 {
1516 struct atreq *atreq = (struct atreq *) arg; 1515 struct atreq __user *atreq = argp;
1517 int tmp; 1516 int tmp;
1518 /* allow nonblocking io and being interrupted */ 1517 /* allow nonblocking io and being interrupted */
1519 if (wait_event_interruptible 1518 if (wait_event_interruptible
@@ -1597,7 +1596,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1597 { 1596 {
1598 struct ptsreq krnptsreq; 1597 struct ptsreq krnptsreq;
1599 1598
1600 if (copy_from_user(&krnptsreq, (struct ptsreq *) arg, 1599 if (copy_from_user(&krnptsreq, argp,
1601 sizeof(struct ptsreq))) 1600 sizeof(struct ptsreq)))
1602 return -EFAULT; 1601 return -EFAULT;
1603 1602
@@ -1641,7 +1640,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1641 int old_pc_debug = 0; 1640 int old_pc_debug = 0;
1642 1641
1643 old_pc_debug = pc_debug; 1642 old_pc_debug = pc_debug;
1644 if (copy_from_user(&pc_debug, (int *)arg, sizeof(int))) 1643 if (copy_from_user(&pc_debug, argp, sizeof(int)))
1645 return -EFAULT; 1644 return -EFAULT;
1646 1645
1647 if (old_pc_debug != pc_debug) 1646 if (old_pc_debug != pc_debug)
@@ -1863,68 +1862,36 @@ cs_release:
1863 link->state &= ~DEV_CONFIG_PENDING; 1862 link->state &= ~DEV_CONFIG_PENDING;
1864} 1863}
1865 1864
1866static int cm4000_event(event_t event, int priority, 1865static int cm4000_suspend(struct pcmcia_device *p_dev)
1867 event_callback_args_t *args)
1868{ 1866{
1869 dev_link_t *link; 1867 dev_link_t *link = dev_to_instance(p_dev);
1870 struct cm4000_dev *dev; 1868 struct cm4000_dev *dev;
1871 int devno;
1872 1869
1873 link = args->client_data;
1874 dev = link->priv; 1870 dev = link->priv;
1875 1871
1876 DEBUGP(3, dev, "-> cm4000_event\n"); 1872 link->state |= DEV_SUSPEND;
1877 for (devno = 0; devno < CM4000_MAX_DEV; devno++) 1873 if (link->state & DEV_CONFIG)
1878 if (dev_table[devno] == link) 1874 pcmcia_release_configuration(link->handle);
1879 break; 1875 stop_monitor(dev);
1880 1876
1881 if (devno == CM4000_MAX_DEV) 1877 return 0;
1882 return CS_BAD_ADAPTER; 1878}
1883 1879
1884 switch (event) { 1880static int cm4000_resume(struct pcmcia_device *p_dev)
1885 case CS_EVENT_CARD_INSERTION: 1881{
1886 DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n"); 1882 dev_link_t *link = dev_to_instance(p_dev);
1887 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 1883 struct cm4000_dev *dev;
1888 cm4000_config(link, devno); 1884
1889 break; 1885 dev = link->priv;
1890 case CS_EVENT_CARD_REMOVAL: 1886
1891 DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n"); 1887 link->state &= ~DEV_SUSPEND;
1892 link->state &= ~DEV_PRESENT; 1888 if (link->state & DEV_CONFIG)
1893 stop_monitor(dev); 1889 pcmcia_request_configuration(link->handle, &link->conf);
1894 break; 1890
1895 case CS_EVENT_PM_SUSPEND: 1891 if (link->open)
1896 DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND " 1892 start_monitor(dev);
1897 "(fall-through to CS_EVENT_RESET_PHYSICAL)\n"); 1893
1898 link->state |= DEV_SUSPEND; 1894 return 0;
1899 /* fall-through */
1900 case CS_EVENT_RESET_PHYSICAL:
1901 DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
1902 if (link->state & DEV_CONFIG) {
1903 DEBUGP(5, dev, "ReleaseConfiguration\n");
1904 pcmcia_release_configuration(link->handle);
1905 }
1906 stop_monitor(dev);
1907 break;
1908 case CS_EVENT_PM_RESUME:
1909 DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
1910 "(fall-through to CS_EVENT_CARD_RESET)\n");
1911 link->state &= ~DEV_SUSPEND;
1912 /* fall-through */
1913 case CS_EVENT_CARD_RESET:
1914 DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
1915 if ((link->state & DEV_CONFIG)) {
1916 DEBUGP(5, dev, "RequestConfiguration\n");
1917 pcmcia_request_configuration(link->handle, &link->conf);
1918 }
1919 if (link->open)
1920 start_monitor(dev);
1921 break;
1922 default:
1923 DEBUGP(5, dev, "unknown event %.2x\n", event);
1924 break;
1925 }
1926 DEBUGP(3, dev, "<- cm4000_event\n");
1927 return CS_SUCCESS;
1928} 1895}
1929 1896
1930static void cm4000_release(dev_link_t *link) 1897static void cm4000_release(dev_link_t *link)
@@ -1934,11 +1901,10 @@ static void cm4000_release(dev_link_t *link)
1934 pcmcia_release_io(link->handle, &link->io); 1901 pcmcia_release_io(link->handle, &link->io);
1935} 1902}
1936 1903
1937static dev_link_t *cm4000_attach(void) 1904static int cm4000_attach(struct pcmcia_device *p_dev)
1938{ 1905{
1939 struct cm4000_dev *dev; 1906 struct cm4000_dev *dev;
1940 dev_link_t *link; 1907 dev_link_t *link;
1941 client_reg_t client_reg;
1942 int i; 1908 int i;
1943 1909
1944 for (i = 0; i < CM4000_MAX_DEV; i++) 1910 for (i = 0; i < CM4000_MAX_DEV; i++)
@@ -1947,76 +1913,55 @@ static dev_link_t *cm4000_attach(void)
1947 1913
1948 if (i == CM4000_MAX_DEV) { 1914 if (i == CM4000_MAX_DEV) {
1949 printk(KERN_NOTICE MODULE_NAME ": all devices in use\n"); 1915 printk(KERN_NOTICE MODULE_NAME ": all devices in use\n");
1950 return NULL; 1916 return -ENODEV;
1951 } 1917 }
1952 1918
1953 /* create a new cm4000_cs device */ 1919 /* create a new cm4000_cs device */
1954 dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL); 1920 dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL);
1955 if (dev == NULL) 1921 if (dev == NULL)
1956 return NULL; 1922 return -ENOMEM;
1957 1923
1958 link = &dev->link; 1924 link = &dev->link;
1959 link->priv = dev; 1925 link->priv = dev;
1960 link->conf.IntType = INT_MEMORY_AND_IO; 1926 link->conf.IntType = INT_MEMORY_AND_IO;
1961 dev_table[i] = link; 1927 dev_table[i] = link;
1962 1928
1963 /* register with card services */
1964 client_reg.dev_info = &dev_info;
1965 client_reg.EventMask =
1966 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
1967 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
1968 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
1969 client_reg.Version = 0x0210;
1970 client_reg.event_callback_args.client_data = link;
1971
1972 i = pcmcia_register_client(&link->handle, &client_reg);
1973 if (i) {
1974 cs_error(link->handle, RegisterClient, i);
1975 cm4000_detach(link);
1976 return NULL;
1977 }
1978
1979 init_waitqueue_head(&dev->devq); 1929 init_waitqueue_head(&dev->devq);
1980 init_waitqueue_head(&dev->ioq); 1930 init_waitqueue_head(&dev->ioq);
1981 init_waitqueue_head(&dev->atrq); 1931 init_waitqueue_head(&dev->atrq);
1982 init_waitqueue_head(&dev->readq); 1932 init_waitqueue_head(&dev->readq);
1983 1933
1984 return link; 1934 link->handle = p_dev;
1985} 1935 p_dev->instance = link;
1986
1987static void cm4000_detach_by_devno(int devno, dev_link_t * link)
1988{
1989 struct cm4000_dev *dev = link->priv;
1990
1991 DEBUGP(3, dev, "-> detach_by_devno(devno=%d)\n", devno);
1992
1993 if (link->state & DEV_CONFIG) {
1994 DEBUGP(5, dev, "device still configured (try to release it)\n");
1995 cm4000_release(link);
1996 }
1997 1936
1998 if (link->handle) { 1937 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1999 pcmcia_deregister_client(link->handle); 1938 cm4000_config(link, i);
2000 }
2001 1939
2002 dev_table[devno] = NULL; 1940 return 0;
2003 kfree(dev);
2004 return;
2005} 1941}
2006 1942
2007static void cm4000_detach(dev_link_t * link) 1943static void cm4000_detach(struct pcmcia_device *p_dev)
2008{ 1944{
2009 int i; 1945 dev_link_t *link = dev_to_instance(p_dev);
1946 struct cm4000_dev *dev = link->priv;
1947 int devno;
2010 1948
2011 /* find device */ 1949 /* find device */
2012 for (i = 0; i < CM4000_MAX_DEV; i++) 1950 for (devno = 0; devno < CM4000_MAX_DEV; devno++)
2013 if (dev_table[i] == link) 1951 if (dev_table[devno] == link)
2014 break; 1952 break;
2015 1953 if (devno == CM4000_MAX_DEV)
2016 if (i == CM4000_MAX_DEV)
2017 return; 1954 return;
2018 1955
2019 cm4000_detach_by_devno(i, link); 1956 link->state &= ~DEV_PRESENT;
1957 stop_monitor(dev);
1958
1959 if (link->state & DEV_CONFIG)
1960 cm4000_release(link);
1961
1962 dev_table[devno] = NULL;
1963 kfree(dev);
1964
2020 return; 1965 return;
2021} 1966}
2022 1967
@@ -2041,9 +1986,10 @@ static struct pcmcia_driver cm4000_driver = {
2041 .drv = { 1986 .drv = {
2042 .name = "cm4000_cs", 1987 .name = "cm4000_cs",
2043 }, 1988 },
2044 .attach = cm4000_attach, 1989 .probe = cm4000_attach,
2045 .detach = cm4000_detach, 1990 .remove = cm4000_detach,
2046 .event = cm4000_event, 1991 .suspend = cm4000_suspend,
1992 .resume = cm4000_resume,
2047 .id_table = cm4000_ids, 1993 .id_table = cm4000_ids,
2048}; 1994};
2049 1995
@@ -2063,13 +2009,8 @@ static int __init cmm_init(void)
2063 2009
2064static void __exit cmm_exit(void) 2010static void __exit cmm_exit(void)
2065{ 2011{
2066 int i;
2067
2068 printk(KERN_INFO MODULE_NAME ": unloading\n"); 2012 printk(KERN_INFO MODULE_NAME ": unloading\n");
2069 pcmcia_unregister_driver(&cm4000_driver); 2013 pcmcia_unregister_driver(&cm4000_driver);
2070 for (i = 0; i < CM4000_MAX_DEV; i++)
2071 if (dev_table[i])
2072 cm4000_detach_by_devno(i, dev_table[i]);
2073 unregister_chrdev(major, DEVICE_NAME); 2014 unregister_chrdev(major, DEVICE_NAME);
2074}; 2015};
2075 2016
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 4c698d908ffa..46eb371bf17e 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -65,7 +65,6 @@ static char *version =
65#define POLL_PERIOD msecs_to_jiffies(10) 65#define POLL_PERIOD msecs_to_jiffies(10)
66 66
67static void reader_release(dev_link_t *link); 67static void reader_release(dev_link_t *link);
68static void reader_detach(dev_link_t *link);
69 68
70static int major; 69static int major;
71 70
@@ -86,7 +85,6 @@ struct reader_dev {
86 struct timer_list poll_timer; 85 struct timer_list poll_timer;
87}; 86};
88 87
89static dev_info_t dev_info = MODULE_NAME;
90static dev_link_t *dev_table[CM_MAX_DEV]; 88static dev_link_t *dev_table[CM_MAX_DEV];
91 89
92#ifndef PCMCIA_DEBUG 90#ifndef PCMCIA_DEBUG
@@ -629,65 +627,26 @@ cs_release:
629 link->state &= ~DEV_CONFIG_PENDING; 627 link->state &= ~DEV_CONFIG_PENDING;
630} 628}
631 629
632static int reader_event(event_t event, int priority, 630static int reader_suspend(struct pcmcia_device *p_dev)
633 event_callback_args_t *args)
634{ 631{
635 dev_link_t *link; 632 dev_link_t *link = dev_to_instance(p_dev);
636 struct reader_dev *dev;
637 int devno;
638 633
639 link = args->client_data; 634 link->state |= DEV_SUSPEND;
640 dev = link->priv; 635 if (link->state & DEV_CONFIG)
641 DEBUGP(3, dev, "-> reader_event\n"); 636 pcmcia_release_configuration(link->handle);
642 for (devno = 0; devno < CM_MAX_DEV; devno++) {
643 if (dev_table[devno] == link)
644 break;
645 }
646 if (devno == CM_MAX_DEV)
647 return CS_BAD_ADAPTER;
648 637
649 switch (event) { 638 return 0;
650 case CS_EVENT_CARD_INSERTION: 639}
651 DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n"); 640
652 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 641static int reader_resume(struct pcmcia_device *p_dev)
653 reader_config(link, devno); 642{
654 break; 643 dev_link_t *link = dev_to_instance(p_dev);
655 case CS_EVENT_CARD_REMOVAL: 644
656 DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n"); 645 link->state &= ~DEV_SUSPEND;
657 link->state &= ~DEV_PRESENT; 646 if (link->state & DEV_CONFIG)
658 break; 647 pcmcia_request_configuration(link->handle, &link->conf);
659 case CS_EVENT_PM_SUSPEND: 648
660 DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND " 649 return 0;
661 "(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
662 link->state |= DEV_SUSPEND;
663
664 case CS_EVENT_RESET_PHYSICAL:
665 DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
666 if (link->state & DEV_CONFIG) {
667 DEBUGP(5, dev, "ReleaseConfiguration\n");
668 pcmcia_release_configuration(link->handle);
669 }
670 break;
671 case CS_EVENT_PM_RESUME:
672 DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
673 "(fall-through to CS_EVENT_CARD_RESET)\n");
674 link->state &= ~DEV_SUSPEND;
675
676 case CS_EVENT_CARD_RESET:
677 DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
678 if ((link->state & DEV_CONFIG)) {
679 DEBUGP(5, dev, "RequestConfiguration\n");
680 pcmcia_request_configuration(link->handle,
681 &link->conf);
682 }
683 break;
684 default:
685 DEBUGP(5, dev, "reader_event: unknown event %.2x\n",
686 event);
687 break;
688 }
689 DEBUGP(3, dev, "<- reader_event\n");
690 return CS_SUCCESS;
691} 650}
692 651
693static void reader_release(dev_link_t *link) 652static void reader_release(dev_link_t *link)
@@ -697,11 +656,10 @@ static void reader_release(dev_link_t *link)
697 pcmcia_release_io(link->handle, &link->io); 656 pcmcia_release_io(link->handle, &link->io);
698} 657}
699 658
700static dev_link_t *reader_attach(void) 659static int reader_attach(struct pcmcia_device *p_dev)
701{ 660{
702 struct reader_dev *dev; 661 struct reader_dev *dev;
703 dev_link_t *link; 662 dev_link_t *link;
704 client_reg_t client_reg;
705 int i; 663 int i;
706 664
707 for (i = 0; i < CM_MAX_DEV; i++) { 665 for (i = 0; i < CM_MAX_DEV; i++) {
@@ -710,11 +668,11 @@ static dev_link_t *reader_attach(void)
710 } 668 }
711 669
712 if (i == CM_MAX_DEV) 670 if (i == CM_MAX_DEV)
713 return NULL; 671 return -ENODEV;
714 672
715 dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL); 673 dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL);
716 if (dev == NULL) 674 if (dev == NULL)
717 return NULL; 675 return -ENOMEM;
718 676
719 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT; 677 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
720 dev->buffer_status = 0; 678 dev->buffer_status = 0;
@@ -725,20 +683,6 @@ static dev_link_t *reader_attach(void)
725 link->conf.IntType = INT_MEMORY_AND_IO; 683 link->conf.IntType = INT_MEMORY_AND_IO;
726 dev_table[i] = link; 684 dev_table[i] = link;
727 685
728 client_reg.dev_info = &dev_info;
729 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
730 client_reg.EventMask=
731 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
732 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
733 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
734 client_reg.Version = 0x0210;
735 client_reg.event_callback_args.client_data = link;
736 i = pcmcia_register_client(&link->handle, &client_reg);
737 if (i) {
738 cs_error(link->handle, RegisterClient, i);
739 reader_detach(link);
740 return NULL;
741 }
742 init_waitqueue_head(&dev->devq); 686 init_waitqueue_head(&dev->devq);
743 init_waitqueue_head(&dev->poll_wait); 687 init_waitqueue_head(&dev->poll_wait);
744 init_waitqueue_head(&dev->read_wait); 688 init_waitqueue_head(&dev->read_wait);
@@ -746,39 +690,37 @@ static dev_link_t *reader_attach(void)
746 init_timer(&dev->poll_timer); 690 init_timer(&dev->poll_timer);
747 dev->poll_timer.function = &cm4040_do_poll; 691 dev->poll_timer.function = &cm4040_do_poll;
748 692
749 return link; 693 link->handle = p_dev;
750} 694 p_dev->instance = link;
751
752static void reader_detach_by_devno(int devno, dev_link_t *link)
753{
754 struct reader_dev *dev = link->priv;
755 695
756 if (link->state & DEV_CONFIG) { 696 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
757 DEBUGP(5, dev, "device still configured (try to release it)\n"); 697 reader_config(link, i);
758 reader_release(link);
759 }
760 698
761 pcmcia_deregister_client(link->handle); 699 return 0;
762 dev_table[devno] = NULL;
763 DEBUGP(5, dev, "freeing dev=%p\n", dev);
764 cm4040_stop_poll(dev);
765 kfree(dev);
766 return;
767} 700}
768 701
769static void reader_detach(dev_link_t *link) 702static void reader_detach(struct pcmcia_device *p_dev)
770{ 703{
771 int i; 704 dev_link_t *link = dev_to_instance(p_dev);
705 struct reader_dev *dev = link->priv;
706 int devno;
772 707
773 /* find device */ 708 /* find device */
774 for (i = 0; i < CM_MAX_DEV; i++) { 709 for (devno = 0; devno < CM_MAX_DEV; devno++) {
775 if (dev_table[i] == link) 710 if (dev_table[devno] == link)
776 break; 711 break;
777 } 712 }
778 if (i == CM_MAX_DEV) 713 if (devno == CM_MAX_DEV)
779 return; 714 return;
780 715
781 reader_detach_by_devno(i, link); 716 link->state &= ~DEV_PRESENT;
717
718 if (link->state & DEV_CONFIG)
719 reader_release(link);
720
721 dev_table[devno] = NULL;
722 kfree(dev);
723
782 return; 724 return;
783} 725}
784 726
@@ -804,9 +746,10 @@ static struct pcmcia_driver reader_driver = {
804 .drv = { 746 .drv = {
805 .name = "cm4040_cs", 747 .name = "cm4040_cs",
806 }, 748 },
807 .attach = reader_attach, 749 .probe = reader_attach,
808 .detach = reader_detach, 750 .remove = reader_detach,
809 .event = reader_event, 751 .suspend = reader_suspend,
752 .resume = reader_resume,
810 .id_table = cm4040_ids, 753 .id_table = cm4040_ids,
811}; 754};
812 755
@@ -825,14 +768,8 @@ static int __init cm4040_init(void)
825 768
826static void __exit cm4040_exit(void) 769static void __exit cm4040_exit(void)
827{ 770{
828 int i;
829
830 printk(KERN_INFO MODULE_NAME ": unloading\n"); 771 printk(KERN_INFO MODULE_NAME ": unloading\n");
831 pcmcia_unregister_driver(&reader_driver); 772 pcmcia_unregister_driver(&reader_driver);
832 for (i = 0; i < CM_MAX_DEV; i++) {
833 if (dev_table[i])
834 reader_detach_by_devno(i, dev_table[i]);
835 }
836 unregister_chrdev(major, DEVICE_NAME); 773 unregister_chrdev(major, DEVICE_NAME);
837} 774}
838 775
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 2c326ea53421..cf45b100eff1 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -486,13 +486,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout);
486 486
487static void mgslpc_config(dev_link_t *link); 487static void mgslpc_config(dev_link_t *link);
488static void mgslpc_release(u_long arg); 488static void mgslpc_release(u_long arg);
489static int mgslpc_event(event_t event, int priority, 489static void mgslpc_detach(struct pcmcia_device *p_dev);
490 event_callback_args_t *args);
491static dev_link_t *mgslpc_attach(void);
492static void mgslpc_detach(dev_link_t *);
493
494static dev_info_t dev_info = "synclink_cs";
495static dev_link_t *dev_list = NULL;
496 490
497/* 491/*
498 * 1st function defined in .text section. Calling this function in 492 * 1st function defined in .text section. Calling this function in
@@ -539,12 +533,10 @@ static void ldisc_receive_buf(struct tty_struct *tty,
539 } 533 }
540} 534}
541 535
542static dev_link_t *mgslpc_attach(void) 536static int mgslpc_attach(struct pcmcia_device *p_dev)
543{ 537{
544 MGSLPC_INFO *info; 538 MGSLPC_INFO *info;
545 dev_link_t *link; 539 dev_link_t *link;
546 client_reg_t client_reg;
547 int ret;
548 540
549 if (debug_level >= DEBUG_LEVEL_INFO) 541 if (debug_level >= DEBUG_LEVEL_INFO)
550 printk("mgslpc_attach\n"); 542 printk("mgslpc_attach\n");
@@ -552,7 +544,7 @@ static dev_link_t *mgslpc_attach(void)
552 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL); 544 info = (MGSLPC_INFO *)kmalloc(sizeof(MGSLPC_INFO), GFP_KERNEL);
553 if (!info) { 545 if (!info) {
554 printk("Error can't allocate device instance data\n"); 546 printk("Error can't allocate device instance data\n");
555 return NULL; 547 return -ENOMEM;
556 } 548 }
557 549
558 memset(info, 0, sizeof(MGSLPC_INFO)); 550 memset(info, 0, sizeof(MGSLPC_INFO));
@@ -587,24 +579,15 @@ static dev_link_t *mgslpc_attach(void)
587 link->conf.Vcc = 50; 579 link->conf.Vcc = 50;
588 link->conf.IntType = INT_MEMORY_AND_IO; 580 link->conf.IntType = INT_MEMORY_AND_IO;
589 581
590 /* Register with Card Services */ 582 link->handle = p_dev;
591 link->next = dev_list; 583 p_dev->instance = link;
592 dev_list = link;
593
594 client_reg.dev_info = &dev_info;
595 client_reg.Version = 0x0210;
596 client_reg.event_callback_args.client_data = link;
597 584
598 ret = pcmcia_register_client(&link->handle, &client_reg); 585 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
599 if (ret != CS_SUCCESS) { 586 mgslpc_config(link);
600 cs_error(link->handle, RegisterClient, ret);
601 mgslpc_detach(link);
602 return NULL;
603 }
604 587
605 mgslpc_add_device(info); 588 mgslpc_add_device(info);
606 589
607 return link; 590 return 0;
608} 591}
609 592
610/* Card has been inserted. 593/* Card has been inserted.
@@ -736,85 +719,50 @@ static void mgslpc_release(u_long arg)
736 pcmcia_release_io(link->handle, &link->io); 719 pcmcia_release_io(link->handle, &link->io);
737 if (link->irq.AssignedIRQ) 720 if (link->irq.AssignedIRQ)
738 pcmcia_release_irq(link->handle, &link->irq); 721 pcmcia_release_irq(link->handle, &link->irq);
739 if (link->state & DEV_STALE_LINK)
740 mgslpc_detach(link);
741} 722}
742 723
743static void mgslpc_detach(dev_link_t *link) 724static void mgslpc_detach(struct pcmcia_device *p_dev)
744{ 725{
745 dev_link_t **linkp; 726 dev_link_t *link = dev_to_instance(p_dev);
746 727
747 if (debug_level >= DEBUG_LEVEL_INFO) 728 if (debug_level >= DEBUG_LEVEL_INFO)
748 printk("mgslpc_detach(0x%p)\n", link); 729 printk("mgslpc_detach(0x%p)\n", link);
749
750 /* find device */
751 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
752 if (*linkp == link) break;
753 if (*linkp == NULL)
754 return;
755 730
756 if (link->state & DEV_CONFIG) { 731 if (link->state & DEV_CONFIG) {
757 /* device is configured/active, mark it so when 732 ((MGSLPC_INFO *)link->priv)->stop = 1;
758 * release() is called a proper detach() occurs. 733 mgslpc_release((u_long)link);
759 */
760 if (debug_level >= DEBUG_LEVEL_INFO)
761 printk(KERN_DEBUG "synclinkpc: detach postponed, '%s' "
762 "still locked\n", link->dev->dev_name);
763 link->state |= DEV_STALE_LINK;
764 return;
765 } 734 }
766 735
767 /* Break the link with Card Services */
768 if (link->handle)
769 pcmcia_deregister_client(link->handle);
770
771 /* Unlink device structure, and free it */
772 *linkp = link->next;
773 mgslpc_remove_device((MGSLPC_INFO *)link->priv); 736 mgslpc_remove_device((MGSLPC_INFO *)link->priv);
774} 737}
775 738
776static int mgslpc_event(event_t event, int priority, 739static int mgslpc_suspend(struct pcmcia_device *dev)
777 event_callback_args_t *args)
778{ 740{
779 dev_link_t *link = args->client_data; 741 dev_link_t *link = dev_to_instance(dev);
780 MGSLPC_INFO *info = link->priv; 742 MGSLPC_INFO *info = link->priv;
781 743
782 if (debug_level >= DEBUG_LEVEL_INFO) 744 link->state |= DEV_SUSPEND;
783 printk("mgslpc_event(0x%06x)\n", event); 745 info->stop = 1;
784 746 if (link->state & DEV_CONFIG)
785 switch (event) { 747 pcmcia_release_configuration(link->handle);
786 case CS_EVENT_CARD_REMOVAL: 748
787 link->state &= ~DEV_PRESENT; 749 return 0;
788 if (link->state & DEV_CONFIG) {
789 ((MGSLPC_INFO *)link->priv)->stop = 1;
790 mgslpc_release((u_long)link);
791 }
792 break;
793 case CS_EVENT_CARD_INSERTION:
794 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
795 mgslpc_config(link);
796 break;
797 case CS_EVENT_PM_SUSPEND:
798 link->state |= DEV_SUSPEND;
799 /* Fall through... */
800 case CS_EVENT_RESET_PHYSICAL:
801 /* Mark the device as stopped, to block IO until later */
802 info->stop = 1;
803 if (link->state & DEV_CONFIG)
804 pcmcia_release_configuration(link->handle);
805 break;
806 case CS_EVENT_PM_RESUME:
807 link->state &= ~DEV_SUSPEND;
808 /* Fall through... */
809 case CS_EVENT_CARD_RESET:
810 if (link->state & DEV_CONFIG)
811 pcmcia_request_configuration(link->handle, &link->conf);
812 info->stop = 0;
813 break;
814 }
815 return 0;
816} 750}
817 751
752static int mgslpc_resume(struct pcmcia_device *dev)
753{
754 dev_link_t *link = dev_to_instance(dev);
755 MGSLPC_INFO *info = link->priv;
756
757 link->state &= ~DEV_SUSPEND;
758 if (link->state & DEV_CONFIG)
759 pcmcia_request_configuration(link->handle, &link->conf);
760 info->stop = 0;
761
762 return 0;
763}
764
765
818static inline int mgslpc_paranoia_check(MGSLPC_INFO *info, 766static inline int mgslpc_paranoia_check(MGSLPC_INFO *info,
819 char *name, const char *routine) 767 char *name, const char *routine)
820{ 768{
@@ -3091,10 +3039,11 @@ static struct pcmcia_driver mgslpc_driver = {
3091 .drv = { 3039 .drv = {
3092 .name = "synclink_cs", 3040 .name = "synclink_cs",
3093 }, 3041 },
3094 .attach = mgslpc_attach, 3042 .probe = mgslpc_attach,
3095 .event = mgslpc_event, 3043 .remove = mgslpc_detach,
3096 .detach = mgslpc_detach,
3097 .id_table = mgslpc_ids, 3044 .id_table = mgslpc_ids,
3045 .suspend = mgslpc_suspend,
3046 .resume = mgslpc_resume,
3098}; 3047};
3099 3048
3100static struct tty_operations mgslpc_ops = { 3049static struct tty_operations mgslpc_ops = {
@@ -3138,7 +3087,6 @@ static void synclink_cs_cleanup(void)
3138 } 3087 }
3139 3088
3140 pcmcia_unregister_driver(&mgslpc_driver); 3089 pcmcia_unregister_driver(&mgslpc_driver);
3141 BUG_ON(dev_list != NULL);
3142} 3090}
3143 3091
3144static int __init synclink_cs_init(void) 3092static int __init synclink_cs_init(void)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 7999da25fe40..bdfdfd28594d 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1554,10 +1554,8 @@ __u32 secure_tcp_sequence_number(__u32 saddr, __u32 daddr,
1554 1554
1555EXPORT_SYMBOL(secure_tcp_sequence_number); 1555EXPORT_SYMBOL(secure_tcp_sequence_number);
1556 1556
1557 1557/* Generate secure starting point for ephemeral IPV4 transport port search */
1558 1558u32 secure_ipv4_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport)
1559/* Generate secure starting point for ephemeral TCP port search */
1560u32 secure_tcp_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport)
1561{ 1559{
1562 struct keydata *keyptr = get_keyptr(); 1560 struct keydata *keyptr = get_keyptr();
1563 u32 hash[4]; 1561 u32 hash[4];
@@ -1575,7 +1573,7 @@ u32 secure_tcp_port_ephemeral(__u32 saddr, __u32 daddr, __u16 dport)
1575} 1573}
1576 1574
1577#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) 1575#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
1578u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dport) 1576u32 secure_ipv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dport)
1579{ 1577{
1580 struct keydata *keyptr = get_keyptr(); 1578 struct keydata *keyptr = get_keyptr();
1581 u32 hash[12]; 1579 u32 hash[12];
@@ -1586,7 +1584,7 @@ u32 secure_tcpv6_port_ephemeral(const __u32 *saddr, const __u32 *daddr, __u16 dp
1586 1584
1587 return twothirdsMD4Transform(daddr, hash); 1585 return twothirdsMD4Transform(daddr, hash);
1588} 1586}
1589EXPORT_SYMBOL(secure_tcpv6_port_ephemeral); 1587EXPORT_SYMBOL(secure_ipv6_port_ephemeral);
1590#endif 1588#endif
1591 1589
1592#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) 1590#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
index f66c7ad6fd38..3c1dafaa3441 100644
--- a/drivers/char/vc_screen.c
+++ b/drivers/char/vc_screen.c
@@ -419,7 +419,7 @@ vcs_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
419 while (this_round > 1) { 419 while (this_round > 1) {
420 unsigned short w; 420 unsigned short w;
421 421
422 w = get_unaligned(((const unsigned short *)con_buf0)); 422 w = get_unaligned(((unsigned short *)con_buf0));
423 vcs_scr_writew(vc, w, org++); 423 vcs_scr_writew(vc, w, org++);
424 con_buf0 += 2; 424 con_buf0 += 2;
425 this_round -= 2; 425 this_round -= 2;
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index 344001b45af9..a6544790af60 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -438,7 +438,7 @@ config INDYDOG
438 438
439config ZVM_WATCHDOG 439config ZVM_WATCHDOG
440 tristate "z/VM Watchdog Timer" 440 tristate "z/VM Watchdog Timer"
441 depends on WATCHDOG && ARCH_S390 441 depends on WATCHDOG && S390
442 help 442 help
443 IBM s/390 and zSeries machines running under z/VM 5.1 or later 443 IBM s/390 and zSeries machines running under z/VM 5.1 or later
444 provide a virtual watchdog timer to their guest that cause a 444 provide a virtual watchdog timer to their guest that cause a
diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c
index 65830ec71042..b6640606b44d 100644
--- a/drivers/char/watchdog/booke_wdt.c
+++ b/drivers/char/watchdog/booke_wdt.c
@@ -72,7 +72,7 @@ static __inline__ void booke_wdt_ping(void)
72/* 72/*
73 * booke_wdt_write: 73 * booke_wdt_write:
74 */ 74 */
75static ssize_t booke_wdt_write (struct file *file, const char *buf, 75static ssize_t booke_wdt_write (struct file *file, const char __user *buf,
76 size_t count, loff_t *ppos) 76 size_t count, loff_t *ppos)
77{ 77{
78 booke_wdt_ping(); 78 booke_wdt_ping();
@@ -92,14 +92,15 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file,
92 unsigned int cmd, unsigned long arg) 92 unsigned int cmd, unsigned long arg)
93{ 93{
94 u32 tmp = 0; 94 u32 tmp = 0;
95 u32 __user *p = (u32 __user *)arg;
95 96
96 switch (cmd) { 97 switch (cmd) {
97 case WDIOC_GETSUPPORT: 98 case WDIOC_GETSUPPORT:
98 if (copy_to_user ((struct watchdog_info *) arg, &ident, 99 if (copy_to_user ((struct watchdog_info __user *) arg, &ident,
99 sizeof(struct watchdog_info))) 100 sizeof(struct watchdog_info)))
100 return -EFAULT; 101 return -EFAULT;
101 case WDIOC_GETSTATUS: 102 case WDIOC_GETSTATUS:
102 return put_user(ident.options, (u32 *) arg); 103 return put_user(ident.options, p);
103 case WDIOC_GETBOOTSTATUS: 104 case WDIOC_GETBOOTSTATUS:
104 /* XXX: something is clearing TSR */ 105 /* XXX: something is clearing TSR */
105 tmp = mfspr(SPRN_TSR) & TSR_WRS(3); 106 tmp = mfspr(SPRN_TSR) & TSR_WRS(3);
@@ -109,14 +110,14 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file,
109 booke_wdt_ping(); 110 booke_wdt_ping();
110 return 0; 111 return 0;
111 case WDIOC_SETTIMEOUT: 112 case WDIOC_SETTIMEOUT:
112 if (get_user(booke_wdt_period, (u32 *) arg)) 113 if (get_user(booke_wdt_period, p))
113 return -EFAULT; 114 return -EFAULT;
114 mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period)); 115 mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period));
115 return 0; 116 return 0;
116 case WDIOC_GETTIMEOUT: 117 case WDIOC_GETTIMEOUT:
117 return put_user(booke_wdt_period, (u32 *) arg); 118 return put_user(booke_wdt_period, p);
118 case WDIOC_SETOPTIONS: 119 case WDIOC_SETOPTIONS:
119 if (get_user(tmp, (u32 *) arg)) 120 if (get_user(tmp, p))
120 return -EINVAL; 121 return -EINVAL;
121 if (tmp == WDIOS_ENABLECARD) { 122 if (tmp == WDIOS_ENABLECARD) {
122 booke_wdt_ping(); 123 booke_wdt_ping();
@@ -172,7 +173,7 @@ static int __init booke_wdt_init(void)
172 int ret = 0; 173 int ret = 0;
173 174
174 printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n"); 175 printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n");
175 ident.firmware_version = cpu_specs[0].pvr_value; 176 ident.firmware_version = cur_cpu_spec->pvr_value;
176 177
177 ret = misc_register(&booke_wdt_miscdev); 178 ret = misc_register(&booke_wdt_miscdev);
178 if (ret) { 179 if (ret) {
diff --git a/drivers/char/watchdog/ixp4xx_wdt.c b/drivers/char/watchdog/ixp4xx_wdt.c
index b5be8b11104a..3800835ca8f3 100644
--- a/drivers/char/watchdog/ixp4xx_wdt.c
+++ b/drivers/char/watchdog/ixp4xx_wdt.c
@@ -186,8 +186,8 @@ static int __init ixp4xx_wdt_init(void)
186 unsigned long processor_id; 186 unsigned long processor_id;
187 187
188 asm("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(processor_id) :); 188 asm("mrc p15, 0, %0, cr0, cr0, 0;" : "=r"(processor_id) :);
189 if (!(processor_id & 0xf)) { 189 if (!(processor_id & 0xf) && !cpu_is_ixp46x()) {
190 printk("IXP4XXX Watchdog: Rev. A0 CPU detected - " 190 printk("IXP4XXX Watchdog: Rev. A0 IXP42x CPU detected - "
191 "watchdog disabled\n"); 191 "watchdog disabled\n");
192 192
193 return -ENODEV; 193 return -ENODEV;
diff --git a/drivers/char/watchdog/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c
index 9defcf861b67..b4d843489881 100644
--- a/drivers/char/watchdog/mpcore_wdt.c
+++ b/drivers/char/watchdog/mpcore_wdt.c
@@ -180,10 +180,6 @@ static ssize_t mpcore_wdt_write(struct file *file, const char *data, size_t len,
180{ 180{
181 struct mpcore_wdt *wdt = file->private_data; 181 struct mpcore_wdt *wdt = file->private_data;
182 182
183 /* Can't seek (pwrite) on this device */
184 if (ppos != &file->f_pos)
185 return -ESPIPE;
186
187 /* 183 /*
188 * Refresh the timer. 184 * Refresh the timer.
189 */ 185 */
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 092e9b133750..1533f56baa42 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -151,7 +151,6 @@ static void usb_pcwd_disconnect (struct usb_interface *interface);
151 151
152/* usb specific object needed to register this driver with the usb subsystem */ 152/* usb specific object needed to register this driver with the usb subsystem */
153static struct usb_driver usb_pcwd_driver = { 153static struct usb_driver usb_pcwd_driver = {
154 .owner = THIS_MODULE,
155 .name = DRIVER_NAME, 154 .name = DRIVER_NAME,
156 .probe = usb_pcwd_probe, 155 .probe = usb_pcwd_probe,
157 .disconnect = usb_pcwd_disconnect, 156 .disconnect = usb_pcwd_disconnect,
diff --git a/drivers/char/watchdog/wdrtas.c b/drivers/char/watchdog/wdrtas.c
index 619e2ffca33f..dacfe31caccf 100644
--- a/drivers/char/watchdog/wdrtas.c
+++ b/drivers/char/watchdog/wdrtas.c
@@ -320,7 +320,7 @@ static int
320wdrtas_ioctl(struct inode *inode, struct file *file, 320wdrtas_ioctl(struct inode *inode, struct file *file,
321 unsigned int cmd, unsigned long arg) 321 unsigned int cmd, unsigned long arg)
322{ 322{
323 int __user *argp = (void *)arg; 323 int __user *argp = (void __user *)arg;
324 int i; 324 int i;
325 static struct watchdog_info wdinfo = { 325 static struct watchdog_info wdinfo = {
326 .options = WDRTAS_SUPPORTED_MASK, 326 .options = WDRTAS_SUPPORTED_MASK,
diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c
index fcdf0fff13a6..969d2b4aaec0 100644
--- a/drivers/connector/cn_proc.c
+++ b/drivers/connector/cn_proc.c
@@ -56,6 +56,7 @@ void proc_fork_connector(struct task_struct *task)
56 msg = (struct cn_msg*)buffer; 56 msg = (struct cn_msg*)buffer;
57 ev = (struct proc_event*)msg->data; 57 ev = (struct proc_event*)msg->data;
58 get_seq(&msg->seq, &ev->cpu); 58 get_seq(&msg->seq, &ev->cpu);
59 getnstimestamp(&ev->timestamp);
59 ev->what = PROC_EVENT_FORK; 60 ev->what = PROC_EVENT_FORK;
60 ev->event_data.fork.parent_pid = task->real_parent->pid; 61 ev->event_data.fork.parent_pid = task->real_parent->pid;
61 ev->event_data.fork.parent_tgid = task->real_parent->tgid; 62 ev->event_data.fork.parent_tgid = task->real_parent->tgid;
@@ -81,6 +82,7 @@ void proc_exec_connector(struct task_struct *task)
81 msg = (struct cn_msg*)buffer; 82 msg = (struct cn_msg*)buffer;
82 ev = (struct proc_event*)msg->data; 83 ev = (struct proc_event*)msg->data;
83 get_seq(&msg->seq, &ev->cpu); 84 get_seq(&msg->seq, &ev->cpu);
85 getnstimestamp(&ev->timestamp);
84 ev->what = PROC_EVENT_EXEC; 86 ev->what = PROC_EVENT_EXEC;
85 ev->event_data.exec.process_pid = task->pid; 87 ev->event_data.exec.process_pid = task->pid;
86 ev->event_data.exec.process_tgid = task->tgid; 88 ev->event_data.exec.process_tgid = task->tgid;
@@ -114,6 +116,7 @@ void proc_id_connector(struct task_struct *task, int which_id)
114 } else 116 } else
115 return; 117 return;
116 get_seq(&msg->seq, &ev->cpu); 118 get_seq(&msg->seq, &ev->cpu);
119 getnstimestamp(&ev->timestamp);
117 120
118 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); 121 memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id));
119 msg->ack = 0; /* not used */ 122 msg->ack = 0; /* not used */
@@ -133,6 +136,7 @@ void proc_exit_connector(struct task_struct *task)
133 msg = (struct cn_msg*)buffer; 136 msg = (struct cn_msg*)buffer;
134 ev = (struct proc_event*)msg->data; 137 ev = (struct proc_event*)msg->data;
135 get_seq(&msg->seq, &ev->cpu); 138 get_seq(&msg->seq, &ev->cpu);
139 getnstimestamp(&ev->timestamp);
136 ev->what = PROC_EVENT_EXIT; 140 ev->what = PROC_EVENT_EXIT;
137 ev->event_data.exit.process_pid = task->pid; 141 ev->event_data.exit.process_pid = task->pid;
138 ev->event_data.exit.process_tgid = task->tgid; 142 ev->event_data.exit.process_tgid = task->tgid;
@@ -165,6 +169,7 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
165 msg = (struct cn_msg*)buffer; 169 msg = (struct cn_msg*)buffer;
166 ev = (struct proc_event*)msg->data; 170 ev = (struct proc_event*)msg->data;
167 msg->seq = rcvd_seq; 171 msg->seq = rcvd_seq;
172 getnstimestamp(&ev->timestamp);
168 ev->cpu = -1; 173 ev->cpu = -1;
169 ev->what = PROC_EVENT_NONE; 174 ev->what = PROC_EVENT_NONE;
170 ev->event_data.ack.err = err; 175 ev->event_data.ack.err = err;
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 815902c2c856..a9163d02983a 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -823,6 +823,30 @@ static void cpufreq_out_of_sync(unsigned int cpu, unsigned int old_freq, unsigne
823 823
824 824
825/** 825/**
826 * cpufreq_quick_get - get the CPU frequency (in kHz) frpm policy->cur
827 * @cpu: CPU number
828 *
829 * This is the last known freq, without actually getting it from the driver.
830 * Return value will be same as what is shown in scaling_cur_freq in sysfs.
831 */
832unsigned int cpufreq_quick_get(unsigned int cpu)
833{
834 struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);
835 unsigned int ret = 0;
836
837 if (policy) {
838 down(&policy->lock);
839 ret = policy->cur;
840 up(&policy->lock);
841 cpufreq_cpu_put(policy);
842 }
843
844 return (ret);
845}
846EXPORT_SYMBOL(cpufreq_quick_get);
847
848
849/**
826 * cpufreq_get - get the current CPU frequency (in kHz) 850 * cpufreq_get - get the current CPU frequency (in kHz)
827 * @cpu: CPU number 851 * @cpu: CPU number
828 * 852 *
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 2ed5c4363b53..39543a2bed0f 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -93,7 +93,7 @@ static inline unsigned int get_cpu_idle_time(unsigned int cpu)
93{ 93{
94 return kstat_cpu(cpu).cpustat.idle + 94 return kstat_cpu(cpu).cpustat.idle +
95 kstat_cpu(cpu).cpustat.iowait + 95 kstat_cpu(cpu).cpustat.iowait +
96 ( !dbs_tuners_ins.ignore_nice ? 96 ( dbs_tuners_ins.ignore_nice ?
97 kstat_cpu(cpu).cpustat.nice : 97 kstat_cpu(cpu).cpustat.nice :
98 0); 98 0);
99} 99}
@@ -127,7 +127,7 @@ show_one(sampling_rate, sampling_rate);
127show_one(sampling_down_factor, sampling_down_factor); 127show_one(sampling_down_factor, sampling_down_factor);
128show_one(up_threshold, up_threshold); 128show_one(up_threshold, up_threshold);
129show_one(down_threshold, down_threshold); 129show_one(down_threshold, down_threshold);
130show_one(ignore_nice, ignore_nice); 130show_one(ignore_nice_load, ignore_nice);
131show_one(freq_step, freq_step); 131show_one(freq_step, freq_step);
132 132
133static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, 133static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
@@ -207,7 +207,7 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused,
207 return count; 207 return count;
208} 208}
209 209
210static ssize_t store_ignore_nice(struct cpufreq_policy *policy, 210static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
211 const char *buf, size_t count) 211 const char *buf, size_t count)
212{ 212{
213 unsigned int input; 213 unsigned int input;
@@ -272,7 +272,7 @@ define_one_rw(sampling_rate);
272define_one_rw(sampling_down_factor); 272define_one_rw(sampling_down_factor);
273define_one_rw(up_threshold); 273define_one_rw(up_threshold);
274define_one_rw(down_threshold); 274define_one_rw(down_threshold);
275define_one_rw(ignore_nice); 275define_one_rw(ignore_nice_load);
276define_one_rw(freq_step); 276define_one_rw(freq_step);
277 277
278static struct attribute * dbs_attributes[] = { 278static struct attribute * dbs_attributes[] = {
@@ -282,7 +282,7 @@ static struct attribute * dbs_attributes[] = {
282 &sampling_down_factor.attr, 282 &sampling_down_factor.attr,
283 &up_threshold.attr, 283 &up_threshold.attr,
284 &down_threshold.attr, 284 &down_threshold.attr,
285 &ignore_nice.attr, 285 &ignore_nice_load.attr,
286 &freq_step.attr, 286 &freq_step.attr,
287 NULL 287 NULL
288}; 288};
diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
index 17741111246b..e69fd8dd1f1c 100644
--- a/drivers/cpufreq/cpufreq_ondemand.c
+++ b/drivers/cpufreq/cpufreq_ondemand.c
@@ -89,7 +89,7 @@ static inline unsigned int get_cpu_idle_time(unsigned int cpu)
89{ 89{
90 return kstat_cpu(cpu).cpustat.idle + 90 return kstat_cpu(cpu).cpustat.idle +
91 kstat_cpu(cpu).cpustat.iowait + 91 kstat_cpu(cpu).cpustat.iowait +
92 ( !dbs_tuners_ins.ignore_nice ? 92 ( dbs_tuners_ins.ignore_nice ?
93 kstat_cpu(cpu).cpustat.nice : 93 kstat_cpu(cpu).cpustat.nice :
94 0); 94 0);
95} 95}
@@ -122,7 +122,7 @@ static ssize_t show_##file_name \
122show_one(sampling_rate, sampling_rate); 122show_one(sampling_rate, sampling_rate);
123show_one(sampling_down_factor, sampling_down_factor); 123show_one(sampling_down_factor, sampling_down_factor);
124show_one(up_threshold, up_threshold); 124show_one(up_threshold, up_threshold);
125show_one(ignore_nice, ignore_nice); 125show_one(ignore_nice_load, ignore_nice);
126 126
127static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused, 127static ssize_t store_sampling_down_factor(struct cpufreq_policy *unused,
128 const char *buf, size_t count) 128 const char *buf, size_t count)
@@ -182,7 +182,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused,
182 return count; 182 return count;
183} 183}
184 184
185static ssize_t store_ignore_nice(struct cpufreq_policy *policy, 185static ssize_t store_ignore_nice_load(struct cpufreq_policy *policy,
186 const char *buf, size_t count) 186 const char *buf, size_t count)
187{ 187{
188 unsigned int input; 188 unsigned int input;
@@ -223,7 +223,7 @@ __ATTR(_name, 0644, show_##_name, store_##_name)
223define_one_rw(sampling_rate); 223define_one_rw(sampling_rate);
224define_one_rw(sampling_down_factor); 224define_one_rw(sampling_down_factor);
225define_one_rw(up_threshold); 225define_one_rw(up_threshold);
226define_one_rw(ignore_nice); 226define_one_rw(ignore_nice_load);
227 227
228static struct attribute * dbs_attributes[] = { 228static struct attribute * dbs_attributes[] = {
229 &sampling_rate_max.attr, 229 &sampling_rate_max.attr,
@@ -231,7 +231,7 @@ static struct attribute * dbs_attributes[] = {
231 &sampling_rate.attr, 231 &sampling_rate.attr,
232 &sampling_down_factor.attr, 232 &sampling_down_factor.attr,
233 &up_threshold.attr, 233 &up_threshold.attr,
234 &ignore_nice.attr, 234 &ignore_nice_load.attr,
235 NULL 235 NULL
236}; 236};
237 237
diff --git a/drivers/fc4/Kconfig b/drivers/fc4/Kconfig
index f00c02a13ed6..345dbe6f10df 100644
--- a/drivers/fc4/Kconfig
+++ b/drivers/fc4/Kconfig
@@ -26,7 +26,7 @@ comment "FC4 drivers"
26 26
27config FC4_SOC 27config FC4_SOC
28 tristate "Sun SOC/Sbus" 28 tristate "Sun SOC/Sbus"
29 depends on FC4!=n && (SPARC32 || SPARC64) 29 depends on FC4!=n && SPARC
30 help 30 help
31 Serial Optical Channel is an interface card with one or two Fibre 31 Serial Optical Channel is an interface card with one or two Fibre
32 Optic ports, each of which can be connected to a disk array. Note 32 Optic ports, each of which can be connected to a disk array. Note
@@ -38,7 +38,7 @@ config FC4_SOC
38 38
39config FC4_SOCAL 39config FC4_SOCAL
40 tristate "Sun SOC+ (aka SOCAL)" 40 tristate "Sun SOC+ (aka SOCAL)"
41 depends on FC4!=n && (SPARC32 || SPARC64) 41 depends on FC4!=n && SPARC
42 ---help--- 42 ---help---
43 Serial Optical Channel Plus is an interface card with up to two 43 Serial Optical Channel Plus is an interface card with up to two
44 Fibre Optic ports. This card supports FC Arbitrated Loop (usually 44 Fibre Optic ports. This card supports FC Arbitrated Loop (usually
@@ -62,7 +62,7 @@ config SCSI_PLUTO
62 be called pluto. 62 be called pluto.
63 63
64config SCSI_FCAL 64config SCSI_FCAL
65 tristate "Sun Enterprise Network Array (A5000 and EX500)" if SPARC32 || SPARC64 65 tristate "Sun Enterprise Network Array (A5000 and EX500)" if SPARC
66 depends on FC4!=n && SCSI 66 depends on FC4!=n && SCSI
67 help 67 help
68 This driver drives FC-AL disks connected through a Fibre Channel 68 This driver drives FC-AL disks connected through a Fibre Channel
@@ -75,7 +75,7 @@ config SCSI_FCAL
75 75
76config SCSI_FCAL 76config SCSI_FCAL
77 prompt "Generic FC-AL disk driver" 77 prompt "Generic FC-AL disk driver"
78 depends on FC4!=n && SCSI && !SPARC32 && !SPARC64 78 depends on FC4!=n && SCSI && !SPARC
79 79
80endmenu 80endmenu
81 81
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c
index 6d83299e7c9b..dfedb777d8c9 100644
--- a/drivers/firmware/dell_rbu.c
+++ b/drivers/firmware/dell_rbu.c
@@ -105,8 +105,8 @@ static int create_packet(void *data, size_t length)
105 int ordernum = 0; 105 int ordernum = 0;
106 int retval = 0; 106 int retval = 0;
107 unsigned int packet_array_size = 0; 107 unsigned int packet_array_size = 0;
108 void **invalid_addr_packet_array = 0; 108 void **invalid_addr_packet_array = NULL;
109 void *packet_data_temp_buf = 0; 109 void *packet_data_temp_buf = NULL;
110 unsigned int idx = 0; 110 unsigned int idx = 0;
111 111
112 pr_debug("create_packet: entry \n"); 112 pr_debug("create_packet: entry \n");
@@ -178,7 +178,7 @@ static int create_packet(void *data, size_t length)
178 packet_data_temp_buf), 178 packet_data_temp_buf),
179 allocation_floor); 179 allocation_floor);
180 invalid_addr_packet_array[idx++] = packet_data_temp_buf; 180 invalid_addr_packet_array[idx++] = packet_data_temp_buf;
181 packet_data_temp_buf = 0; 181 packet_data_temp_buf = NULL;
182 } 182 }
183 } 183 }
184 spin_lock(&rbu_data.lock); 184 spin_lock(&rbu_data.lock);
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index db358cfa7cbf..c58295914365 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -350,6 +350,18 @@ config SENSORS_VIA686A
350 This driver can also be built as a module. If so, the module 350 This driver can also be built as a module. If so, the module
351 will be called via686a. 351 will be called via686a.
352 352
353config SENSORS_VT8231
354 tristate "VT8231"
355 depends on HWMON && I2C && PCI && EXPERIMENTAL
356 select HWMON_VID
357 select I2C_ISA
358 help
359 If you say yes here then you get support for the integrated sensors
360 in the VIA VT8231 device.
361
362 This driver can also be built as a module. If so, the module
363 will be called vt8231.
364
353config SENSORS_W83781D 365config SENSORS_W83781D
354 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F" 366 tristate "Winbond W83781D, W83782D, W83783S, W83627HF, Asus AS99127F"
355 depends on HWMON && I2C 367 depends on HWMON && I2C
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
index f7d6a2f61ee7..06d4a1d14105 100644
--- a/drivers/hwmon/Makefile
+++ b/drivers/hwmon/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o
40obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o 40obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o
41obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o 41obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
42obj-$(CONFIG_SENSORS_VIA686A) += via686a.o 42obj-$(CONFIG_SENSORS_VIA686A) += via686a.o
43obj-$(CONFIG_SENSORS_VT8231) += vt8231.o
43obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o 44obj-$(CONFIG_SENSORS_W83627EHF) += w83627ehf.o
44obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o 45obj-$(CONFIG_SENSORS_W83L785TS) += w83l785ts.o
45 46
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 8102876c7c3f..665612729cb9 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -126,10 +126,10 @@ static int read_only;
126 126
127/* This is the driver that will be inserted */ 127/* This is the driver that will be inserted */
128static struct i2c_driver adm1021_driver = { 128static struct i2c_driver adm1021_driver = {
129 .owner = THIS_MODULE, 129 .driver = {
130 .name = "adm1021", 130 .name = "adm1021",
131 },
131 .id = I2C_DRIVERID_ADM1021, 132 .id = I2C_DRIVERID_ADM1021,
132 .flags = I2C_DF_NOTIFY,
133 .attach_adapter = adm1021_attach_adapter, 133 .attach_adapter = adm1021_attach_adapter,
134 .detach_client = adm1021_detach_client, 134 .detach_client = adm1021_detach_client,
135}; 135};
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index 3ec12421694f..9331c56d2ba6 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -118,10 +118,10 @@ static struct adm1025_data *adm1025_update_device(struct device *dev);
118 */ 118 */
119 119
120static struct i2c_driver adm1025_driver = { 120static struct i2c_driver adm1025_driver = {
121 .owner = THIS_MODULE, 121 .driver = {
122 .name = "adm1025", 122 .name = "adm1025",
123 },
123 .id = I2C_DRIVERID_ADM1025, 124 .id = I2C_DRIVERID_ADM1025,
124 .flags = I2C_DF_NOTIFY,
125 .attach_adapter = adm1025_attach_adapter, 125 .attach_adapter = adm1025_attach_adapter,
126 .detach_client = adm1025_detach_client, 126 .detach_client = adm1025_detach_client,
127}; 127};
@@ -287,8 +287,6 @@ static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char
287 struct adm1025_data *data = adm1025_update_device(dev); 287 struct adm1025_data *data = adm1025_update_device(dev);
288 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); 288 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm));
289} 289}
290/* in1_ref is deprecated in favour of cpu0_vid, remove after 2005-11-11 */
291static DEVICE_ATTR(in1_ref, S_IRUGO, show_vid, NULL);
292static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 290static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
293 291
294static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf) 292static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, char *buf)
@@ -444,8 +442,6 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
444 device_create_file(&new_client->dev, &dev_attr_temp1_max); 442 device_create_file(&new_client->dev, &dev_attr_temp1_max);
445 device_create_file(&new_client->dev, &dev_attr_temp2_max); 443 device_create_file(&new_client->dev, &dev_attr_temp2_max);
446 device_create_file(&new_client->dev, &dev_attr_alarms); 444 device_create_file(&new_client->dev, &dev_attr_alarms);
447 /* in1_ref is deprecated, remove after 2005-11-11 */
448 device_create_file(&new_client->dev, &dev_attr_in1_ref);
449 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 445 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
450 device_create_file(&new_client->dev, &dev_attr_vrm); 446 device_create_file(&new_client->dev, &dev_attr_vrm);
451 447
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index e0f56549d1d8..fefe6e74fd02 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -308,9 +308,9 @@ static void adm1026_init_client(struct i2c_client *client);
308 308
309 309
310static struct i2c_driver adm1026_driver = { 310static struct i2c_driver adm1026_driver = {
311 .owner = THIS_MODULE, 311 .driver = {
312 .name = "adm1026", 312 .name = "adm1026",
313 .flags = I2C_DF_NOTIFY, 313 },
314 .attach_adapter = adm1026_attach_adapter, 314 .attach_adapter = adm1026_attach_adapter,
315 .detach_client = adm1026_detach_client, 315 .detach_client = adm1026_detach_client,
316}; 316};
@@ -1227,8 +1227,6 @@ static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, c
1227 struct adm1026_data *data = adm1026_update_device(dev); 1227 struct adm1026_data *data = adm1026_update_device(dev);
1228 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm)); 1228 return sprintf(buf,"%d\n", vid_from_reg(data->vid & 0x3f, data->vrm));
1229} 1229}
1230/* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */
1231static DEVICE_ATTR(vid, S_IRUGO, show_vid_reg, NULL);
1232static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 1230static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
1233 1231
1234static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 1232static ssize_t show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
@@ -1673,8 +1671,6 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
1673 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable); 1671 device_create_file(&new_client->dev, &dev_attr_temp1_crit_enable);
1674 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable); 1672 device_create_file(&new_client->dev, &dev_attr_temp2_crit_enable);
1675 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable); 1673 device_create_file(&new_client->dev, &dev_attr_temp3_crit_enable);
1676 /* vid deprecated in favour of cpu0_vid, remove after 2005-11-11 */
1677 device_create_file(&new_client->dev, &dev_attr_vid);
1678 device_create_file(&new_client->dev, &dev_attr_cpu0_vid); 1674 device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
1679 device_create_file(&new_client->dev, &dev_attr_vrm); 1675 device_create_file(&new_client->dev, &dev_attr_vrm);
1680 device_create_file(&new_client->dev, &dev_attr_alarms); 1676 device_create_file(&new_client->dev, &dev_attr_alarms);
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index 7c545d5eee45..d06397966081 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -105,9 +105,9 @@ static struct adm1031_data *adm1031_update_device(struct device *dev);
105 105
106/* This is the driver that will be inserted */ 106/* This is the driver that will be inserted */
107static struct i2c_driver adm1031_driver = { 107static struct i2c_driver adm1031_driver = {
108 .owner = THIS_MODULE, 108 .driver = {
109 .name = "adm1031", 109 .name = "adm1031",
110 .flags = I2C_DF_NOTIFY, 110 },
111 .attach_adapter = adm1031_attach_adapter, 111 .attach_adapter = adm1031_attach_adapter,
112 .detach_client = adm1031_detach_client, 112 .detach_client = adm1031_detach_client,
113}; 113};
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 11dc95f8a17e..5ddc22fea4a3 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -137,10 +137,10 @@ static struct adm9240_data *adm9240_update_device(struct device *dev);
137 137
138/* driver data */ 138/* driver data */
139static struct i2c_driver adm9240_driver = { 139static struct i2c_driver adm9240_driver = {
140 .owner = THIS_MODULE, 140 .driver = {
141 .name = "adm9240", 141 .name = "adm9240",
142 },
142 .id = I2C_DRIVERID_ADM9240, 143 .id = I2C_DRIVERID_ADM9240,
143 .flags = I2C_DF_NOTIFY,
144 .attach_adapter = adm9240_attach_adapter, 144 .attach_adapter = adm9240_attach_adapter,
145 .detach_client = adm9240_detach_client, 145 .detach_client = adm9240_detach_client,
146}; 146};
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index 52c469722a65..ae9de63cf2e0 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -217,10 +217,10 @@ static struct asb100_data *asb100_update_device(struct device *dev);
217static void asb100_init_client(struct i2c_client *client); 217static void asb100_init_client(struct i2c_client *client);
218 218
219static struct i2c_driver asb100_driver = { 219static struct i2c_driver asb100_driver = {
220 .owner = THIS_MODULE, 220 .driver = {
221 .name = "asb100", 221 .name = "asb100",
222 },
222 .id = I2C_DRIVERID_ASB100, 223 .id = I2C_DRIVERID_ASB100,
223 .flags = I2C_DF_NOTIFY,
224 .attach_adapter = asb100_attach_adapter, 224 .attach_adapter = asb100_attach_adapter,
225 .detach_client = asb100_detach_client, 225 .detach_client = asb100_detach_client,
226}; 226};
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index 53324f56404e..b0c490073c8e 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -50,9 +50,9 @@ static struct atxp1_data * atxp1_update_device(struct device *dev);
50static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind); 50static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind);
51 51
52static struct i2c_driver atxp1_driver = { 52static struct i2c_driver atxp1_driver = {
53 .owner = THIS_MODULE, 53 .driver = {
54 .name = "atxp1", 54 .name = "atxp1",
55 .flags = I2C_DF_NOTIFY, 55 },
56 .attach_adapter = atxp1_attach_adapter, 56 .attach_adapter = atxp1_attach_adapter,
57 .detach_client = atxp1_detach_client, 57 .detach_client = atxp1_detach_client,
58}; 58};
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 34f71b7c7f37..203f9c7abb20 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -89,10 +89,10 @@ static struct ds1621_data *ds1621_update_client(struct device *dev);
89 89
90/* This is the driver that will be inserted */ 90/* This is the driver that will be inserted */
91static struct i2c_driver ds1621_driver = { 91static struct i2c_driver ds1621_driver = {
92 .owner = THIS_MODULE, 92 .driver = {
93 .name = "ds1621", 93 .name = "ds1621",
94 },
94 .id = I2C_DRIVERID_DS1621, 95 .id = I2C_DRIVERID_DS1621,
95 .flags = I2C_DF_NOTIFY,
96 .attach_adapter = ds1621_attach_adapter, 96 .attach_adapter = ds1621_attach_adapter,
97 .detach_client = ds1621_detach_client, 97 .detach_client = ds1621_detach_client,
98}; 98};
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index a02e1c34c757..25409181d1eb 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -118,10 +118,10 @@ static int fscher_write_value(struct i2c_client *client, u8 reg, u8 value);
118 */ 118 */
119 119
120static struct i2c_driver fscher_driver = { 120static struct i2c_driver fscher_driver = {
121 .owner = THIS_MODULE, 121 .driver = {
122 .name = "fscher", 122 .name = "fscher",
123 },
123 .id = I2C_DRIVERID_FSCHER, 124 .id = I2C_DRIVERID_FSCHER,
124 .flags = I2C_DF_NOTIFY,
125 .attach_adapter = fscher_attach_adapter, 125 .attach_adapter = fscher_attach_adapter,
126 .detach_client = fscher_detach_client, 126 .detach_client = fscher_detach_client,
127}; 127};
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c
index 64e4edc64f8d..6d0146b57020 100644
--- a/drivers/hwmon/fscpos.c
+++ b/drivers/hwmon/fscpos.c
@@ -100,10 +100,10 @@ static void reset_fan_alarm(struct i2c_client *client, int nr);
100 * Driver data (common to all clients) 100 * Driver data (common to all clients)
101 */ 101 */
102static struct i2c_driver fscpos_driver = { 102static struct i2c_driver fscpos_driver = {
103 .owner = THIS_MODULE, 103 .driver = {
104 .name = "fscpos", 104 .name = "fscpos",
105 },
105 .id = I2C_DRIVERID_FSCPOS, 106 .id = I2C_DRIVERID_FSCPOS,
106 .flags = I2C_DF_NOTIFY,
107 .attach_adapter = fscpos_attach_adapter, 107 .attach_adapter = fscpos_attach_adapter,
108 .detach_client = fscpos_detach_client, 108 .detach_client = fscpos_detach_client,
109}; 109};
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 2f178dbe3d87..9e685e3a3bc9 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -151,10 +151,10 @@ static struct gl518_data *gl518_update_device(struct device *dev);
151 151
152/* This is the driver that will be inserted */ 152/* This is the driver that will be inserted */
153static struct i2c_driver gl518_driver = { 153static struct i2c_driver gl518_driver = {
154 .owner = THIS_MODULE, 154 .driver = {
155 .name = "gl518sm", 155 .name = "gl518sm",
156 },
156 .id = I2C_DRIVERID_GL518, 157 .id = I2C_DRIVERID_GL518,
157 .flags = I2C_DF_NOTIFY,
158 .attach_adapter = gl518_attach_adapter, 158 .attach_adapter = gl518_attach_adapter,
159 .detach_client = gl518_detach_client, 159 .detach_client = gl518_detach_client,
160}; 160};
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index c39ba1239426..baee60e44b52 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -109,10 +109,10 @@ static struct gl520_data *gl520_update_device(struct device *dev);
109 109
110/* Driver data */ 110/* Driver data */
111static struct i2c_driver gl520_driver = { 111static struct i2c_driver gl520_driver = {
112 .owner = THIS_MODULE, 112 .driver = {
113 .name = "gl520sm", 113 .name = "gl520sm",
114 },
114 .id = I2C_DRIVERID_GL520, 115 .id = I2C_DRIVERID_GL520,
115 .flags = I2C_DF_NOTIFY,
116 .attach_adapter = gl520_attach_adapter, 116 .attach_adapter = gl520_attach_adapter,
117 .detach_client = gl520_detach_client, 117 .detach_client = gl520_detach_client,
118}; 118};
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c
index 312769ad4dab..e497274916ce 100644
--- a/drivers/hwmon/hwmon-vid.c
+++ b/drivers/hwmon/hwmon-vid.c
@@ -49,20 +49,22 @@
49 . . . . 49 . . . .
50 11110 = 0.800 V 50 11110 = 0.800 V
51 11111 = 0.000 V (off) 51 11111 = 0.000 V (off)
52
53 The 17 specification is in fact Intel Mobile Voltage Positioning -
54 (IMVP-II). You can find more information in the datasheet of Max1718
55 http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452
56
52*/ 57*/
53 58
54/* vrm is the VRM/VRD document version multiplied by 10. 59/* vrm is the VRM/VRD document version multiplied by 10.
55 val is the 4-, 5- or 6-bit VID code. 60 val is the 4-, 5- or 6-bit VID code.
56 Returned value is in mV to avoid floating point in the kernel. */ 61 Returned value is in mV to avoid floating point in the kernel. */
57int vid_from_reg(int val, int vrm) 62int vid_from_reg(int val, u8 vrm)
58{ 63{
59 int vid; 64 int vid;
60 65
61 switch(vrm) { 66 switch(vrm) {
62 67
63 case 0:
64 return 0;
65
66 case 100: /* VRD 10.0 */ 68 case 100: /* VRD 10.0 */
67 if((val & 0x1f) == 0x1f) 69 if((val & 0x1f) == 0x1f)
68 return 0; 70 return 0;
@@ -91,10 +93,16 @@ int vid_from_reg(int val, int vrm)
91 case 84: /* VRM 8.4 */ 93 case 84: /* VRM 8.4 */
92 val &= 0x0f; 94 val &= 0x0f;
93 /* fall through */ 95 /* fall through */
94 default: /* VRM 8.2 */ 96 case 82: /* VRM 8.2 */
95 return(val == 0x1f ? 0 : 97 return(val == 0x1f ? 0 :
96 val & 0x10 ? 5100 - (val) * 100 : 98 val & 0x10 ? 5100 - (val) * 100 :
97 2050 - (val) * 50); 99 2050 - (val) * 50);
100 case 17: /* Intel IMVP-II */
101 return(val & 0x10 ? 975 - (val & 0xF) * 25 :
102 1750 - val * 50);
103 default: /* report 0 for unknown */
104 printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n");
105 return 0;
98 } 106 }
99} 107}
100 108
@@ -108,30 +116,36 @@ struct vrm_model {
108 u8 vendor; 116 u8 vendor;
109 u8 eff_family; 117 u8 eff_family;
110 u8 eff_model; 118 u8 eff_model;
111 int vrm_type; 119 u8 eff_stepping;
120 u8 vrm_type;
112}; 121};
113 122
114#define ANY 0xFF 123#define ANY 0xFF
115 124
116#ifdef CONFIG_X86 125#ifdef CONFIG_X86
117 126
127/* the stepping parameter is highest acceptable stepping for current line */
128
118static struct vrm_model vrm_models[] = { 129static struct vrm_model vrm_models[] = {
119 {X86_VENDOR_AMD, 0x6, ANY, 90}, /* Athlon Duron etc */ 130 {X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */
120 {X86_VENDOR_AMD, 0xF, ANY, 24}, /* Athlon 64, Opteron */ 131 {X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */
121 {X86_VENDOR_INTEL, 0x6, 0x9, 85}, /* 0.13um too */ 132 {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */
122 {X86_VENDOR_INTEL, 0x6, 0xB, 85}, /* Tualatin */ 133 {X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */
123 {X86_VENDOR_INTEL, 0x6, ANY, 82}, /* any P6 */ 134 {X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */
124 {X86_VENDOR_INTEL, 0x7, ANY, 0}, /* Itanium */ 135 {X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */
125 {X86_VENDOR_INTEL, 0xF, 0x0, 90}, /* P4 */ 136 {X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */
126 {X86_VENDOR_INTEL, 0xF, 0x1, 90}, /* P4 Willamette */ 137 {X86_VENDOR_INTEL, 0xF, 0x1, ANY, 90}, /* P4 Willamette */
127 {X86_VENDOR_INTEL, 0xF, 0x2, 90}, /* P4 Northwood */ 138 {X86_VENDOR_INTEL, 0xF, 0x2, ANY, 90}, /* P4 Northwood */
128 {X86_VENDOR_INTEL, 0xF, 0x3, 100}, /* P4 Prescott */ 139 {X86_VENDOR_INTEL, 0xF, ANY, ANY, 100}, /* Prescott and above assume VRD 10 */
129 {X86_VENDOR_INTEL, 0xF, 0x4, 100}, /* P4 Prescott */ 140 {X86_VENDOR_INTEL, 0x10, ANY, ANY, 0}, /* Itanium 2 */
130 {X86_VENDOR_INTEL, 0x10,ANY, 0}, /* Itanium 2 */ 141 {X86_VENDOR_CENTAUR, 0x6, 0x7, ANY, 85}, /* Eden ESP/Ezra */
131 {X86_VENDOR_UNKNOWN, ANY, ANY, 0} /* stop here */ 142 {X86_VENDOR_CENTAUR, 0x6, 0x8, 0x7, 85}, /* Ezra T */
143 {X86_VENDOR_CENTAUR, 0x6, 0x9, 0x7, 85}, /* Nemiah */
144 {X86_VENDOR_CENTAUR, 0x6, 0x9, ANY, 17}, /* C3-M */
145 {X86_VENDOR_UNKNOWN, ANY, ANY, ANY, 0} /* stop here */
132}; 146};
133 147
134static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor) 148static u8 find_vrm(u8 eff_family, u8 eff_model, u8 eff_stepping, u8 vendor)
135{ 149{
136 int i = 0; 150 int i = 0;
137 151
@@ -139,7 +153,8 @@ static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
139 if (vrm_models[i].vendor==vendor) 153 if (vrm_models[i].vendor==vendor)
140 if ((vrm_models[i].eff_family==eff_family) 154 if ((vrm_models[i].eff_family==eff_family)
141 && ((vrm_models[i].eff_model==eff_model) || 155 && ((vrm_models[i].eff_model==eff_model) ||
142 (vrm_models[i].eff_model==ANY))) 156 (vrm_models[i].eff_model==ANY)) &&
157 (eff_stepping <= vrm_models[i].eff_stepping))
143 return vrm_models[i].vrm_type; 158 return vrm_models[i].vrm_type;
144 i++; 159 i++;
145 } 160 }
@@ -147,12 +162,11 @@ static int find_vrm(u8 eff_family, u8 eff_model, u8 vendor)
147 return 0; 162 return 0;
148} 163}
149 164
150int vid_which_vrm(void) 165u8 vid_which_vrm(void)
151{ 166{
152 struct cpuinfo_x86 *c = cpu_data; 167 struct cpuinfo_x86 *c = cpu_data;
153 u32 eax; 168 u32 eax;
154 u8 eff_family, eff_model; 169 u8 eff_family, eff_model, eff_stepping, vrm_ret;
155 int vrm_ret;
156 170
157 if (c->x86 < 6) /* Any CPU with family lower than 6 */ 171 if (c->x86 < 6) /* Any CPU with family lower than 6 */
158 return 0; /* doesn't have VID and/or CPUID */ 172 return 0; /* doesn't have VID and/or CPUID */
@@ -160,20 +174,21 @@ int vid_which_vrm(void)
160 eax = cpuid_eax(1); 174 eax = cpuid_eax(1);
161 eff_family = ((eax & 0x00000F00)>>8); 175 eff_family = ((eax & 0x00000F00)>>8);
162 eff_model = ((eax & 0x000000F0)>>4); 176 eff_model = ((eax & 0x000000F0)>>4);
177 eff_stepping = eax & 0xF;
163 if (eff_family == 0xF) { /* use extended model & family */ 178 if (eff_family == 0xF) { /* use extended model & family */
164 eff_family += ((eax & 0x00F00000)>>20); 179 eff_family += ((eax & 0x00F00000)>>20);
165 eff_model += ((eax & 0x000F0000)>>16)<<4; 180 eff_model += ((eax & 0x000F0000)>>16)<<4;
166 } 181 }
167 vrm_ret = find_vrm(eff_family,eff_model,c->x86_vendor); 182 vrm_ret = find_vrm(eff_family, eff_model, eff_stepping, c->x86_vendor);
168 if (vrm_ret == 0) 183 if (vrm_ret == 0)
169 printk(KERN_INFO "hwmon-vid: Unknown VRM version of your " 184 printk(KERN_INFO "hwmon-vid: Unknown VRM version of your "
170 "x86 CPU\n"); 185 "x86 CPU\n");
171 return vrm_ret; 186 return vrm_ret;
172} 187}
173 188
174/* and now something completely different for the non-x86 world */ 189/* and now for something completely different for the non-x86 world */
175#else 190#else
176int vid_which_vrm(void) 191u8 vid_which_vrm(void)
177{ 192{
178 printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n"); 193 printk(KERN_INFO "hwmon-vid: Unknown VRM version of your CPU\n");
179 return 0; 194 return 0;
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index a61f5d00f10a..0da7c9c508c3 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -213,7 +213,7 @@ struct it87_data {
213 u8 sensor; /* Register value */ 213 u8 sensor; /* Register value */
214 u8 fan_div[3]; /* Register encoding, shifted right */ 214 u8 fan_div[3]; /* Register encoding, shifted right */
215 u8 vid; /* Register encoding, combined */ 215 u8 vid; /* Register encoding, combined */
216 int vrm; 216 u8 vrm;
217 u32 alarms; /* Register encoding, combined */ 217 u32 alarms; /* Register encoding, combined */
218 u8 fan_main_ctrl; /* Register value */ 218 u8 fan_main_ctrl; /* Register value */
219 u8 manual_pwm_ctl[3]; /* manual PWM value set by user */ 219 u8 manual_pwm_ctl[3]; /* manual PWM value set by user */
@@ -234,17 +234,18 @@ static void it87_init_client(struct i2c_client *client, struct it87_data *data);
234 234
235 235
236static struct i2c_driver it87_driver = { 236static struct i2c_driver it87_driver = {
237 .owner = THIS_MODULE, 237 .driver = {
238 .name = "it87", 238 .name = "it87",
239 },
239 .id = I2C_DRIVERID_IT87, 240 .id = I2C_DRIVERID_IT87,
240 .flags = I2C_DF_NOTIFY,
241 .attach_adapter = it87_attach_adapter, 241 .attach_adapter = it87_attach_adapter,
242 .detach_client = it87_detach_client, 242 .detach_client = it87_detach_client,
243}; 243};
244 244
245static struct i2c_driver it87_isa_driver = { 245static struct i2c_driver it87_isa_driver = {
246 .owner = THIS_MODULE, 246 .driver = {
247 .name = "it87-isa", 247 .name = "it87-isa",
248 },
248 .attach_adapter = it87_isa_attach_adapter, 249 .attach_adapter = it87_isa_attach_adapter,
249 .detach_client = it87_detach_client, 250 .detach_client = it87_detach_client,
250}; 251};
@@ -668,7 +669,7 @@ static ssize_t
668show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 669show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf)
669{ 670{
670 struct it87_data *data = it87_update_device(dev); 671 struct it87_data *data = it87_update_device(dev);
671 return sprintf(buf, "%ld\n", (long) data->vrm); 672 return sprintf(buf, "%u\n", data->vrm);
672} 673}
673static ssize_t 674static ssize_t
674store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 675store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
@@ -761,7 +762,8 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
761 762
762 /* Reserve the ISA region */ 763 /* Reserve the ISA region */
763 if (is_isa) 764 if (is_isa)
764 if (!request_region(address, IT87_EXTENT, it87_isa_driver.name)) 765 if (!request_region(address, IT87_EXTENT,
766 it87_isa_driver.driver.name))
765 goto ERROR0; 767 goto ERROR0;
766 768
767 /* For now, we presume we have a valid client. We create the 769 /* For now, we presume we have a valid client. We create the
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 954ec2497249..6b1aa7ef552e 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -139,9 +139,9 @@ static void lm63_init_client(struct i2c_client *client);
139 */ 139 */
140 140
141static struct i2c_driver lm63_driver = { 141static struct i2c_driver lm63_driver = {
142 .owner = THIS_MODULE, 142 .driver = {
143 .name = "lm63", 143 .name = "lm63",
144 .flags = I2C_DF_NOTIFY, 144 },
145 .attach_adapter = lm63_attach_adapter, 145 .attach_adapter = lm63_attach_adapter,
146 .detach_client = lm63_detach_client, 146 .detach_client = lm63_detach_client,
147}; 147};
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index d70f4c8fc1e6..74ca2c8c61c3 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -66,10 +66,10 @@ static struct lm75_data *lm75_update_device(struct device *dev);
66 66
67/* This is the driver that will be inserted */ 67/* This is the driver that will be inserted */
68static struct i2c_driver lm75_driver = { 68static struct i2c_driver lm75_driver = {
69 .owner = THIS_MODULE, 69 .driver = {
70 .name = "lm75", 70 .name = "lm75",
71 },
71 .id = I2C_DRIVERID_LM75, 72 .id = I2C_DRIVERID_LM75,
72 .flags = I2C_DF_NOTIFY,
73 .attach_adapter = lm75_attach_adapter, 73 .attach_adapter = lm75_attach_adapter,
74 .detach_client = lm75_detach_client, 74 .detach_client = lm75_detach_client,
75}; 75};
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index 9380fda7dcd1..a2f420d01fb7 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -74,9 +74,9 @@ static struct lm77_data *lm77_update_device(struct device *dev);
74 74
75/* This is the driver that will be inserted */ 75/* This is the driver that will be inserted */
76static struct i2c_driver lm77_driver = { 76static struct i2c_driver lm77_driver = {
77 .owner = THIS_MODULE, 77 .driver = {
78 .name = "lm77", 78 .name = "lm77",
79 .flags = I2C_DF_NOTIFY, 79 },
80 .attach_adapter = lm77_attach_adapter, 80 .attach_adapter = lm77_attach_adapter,
81 .detach_client = lm77_detach_client, 81 .detach_client = lm77_detach_client,
82}; 82};
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index 78cdd506439f..e404001e20da 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -164,17 +164,18 @@ static void lm78_init_client(struct i2c_client *client);
164 164
165 165
166static struct i2c_driver lm78_driver = { 166static struct i2c_driver lm78_driver = {
167 .owner = THIS_MODULE, 167 .driver = {
168 .name = "lm78", 168 .name = "lm78",
169 },
169 .id = I2C_DRIVERID_LM78, 170 .id = I2C_DRIVERID_LM78,
170 .flags = I2C_DF_NOTIFY,
171 .attach_adapter = lm78_attach_adapter, 171 .attach_adapter = lm78_attach_adapter,
172 .detach_client = lm78_detach_client, 172 .detach_client = lm78_detach_client,
173}; 173};
174 174
175static struct i2c_driver lm78_isa_driver = { 175static struct i2c_driver lm78_isa_driver = {
176 .owner = THIS_MODULE, 176 .driver = {
177 .name = "lm78-isa", 177 .name = "lm78-isa",
178 },
178 .attach_adapter = lm78_isa_attach_adapter, 179 .attach_adapter = lm78_isa_attach_adapter,
179 .detach_client = lm78_detach_client, 180 .detach_client = lm78_detach_client,
180}; 181};
@@ -497,7 +498,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
497 /* Reserve the ISA region */ 498 /* Reserve the ISA region */
498 if (is_isa) 499 if (is_isa)
499 if (!request_region(address, LM78_EXTENT, 500 if (!request_region(address, LM78_EXTENT,
500 lm78_isa_driver.name)) { 501 lm78_isa_driver.driver.name)) {
501 err = -EBUSY; 502 err = -EBUSY;
502 goto ERROR0; 503 goto ERROR0;
503 } 504 }
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index c359fdea211e..c9a7cdea7bd7 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -143,10 +143,10 @@ static int lm80_write_value(struct i2c_client *client, u8 reg, u8 value);
143 */ 143 */
144 144
145static struct i2c_driver lm80_driver = { 145static struct i2c_driver lm80_driver = {
146 .owner = THIS_MODULE, 146 .driver = {
147 .name = "lm80", 147 .name = "lm80",
148 },
148 .id = I2C_DRIVERID_LM80, 149 .id = I2C_DRIVERID_LM80,
149 .flags = I2C_DF_NOTIFY,
150 .attach_adapter = lm80_attach_adapter, 150 .attach_adapter = lm80_attach_adapter,
151 .detach_client = lm80_detach_client, 151 .detach_client = lm80_detach_client,
152}; 152};
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index 9a70611a9f69..26dfa9e216c2 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -124,10 +124,10 @@ static struct lm83_data *lm83_update_device(struct device *dev);
124 */ 124 */
125 125
126static struct i2c_driver lm83_driver = { 126static struct i2c_driver lm83_driver = {
127 .owner = THIS_MODULE, 127 .driver = {
128 .name = "lm83", 128 .name = "lm83",
129 },
129 .id = I2C_DRIVERID_LM83, 130 .id = I2C_DRIVERID_LM83,
130 .flags = I2C_DF_NOTIFY,
131 .attach_adapter = lm83_attach_adapter, 131 .attach_adapter = lm83_attach_adapter,
132 .detach_client = lm83_detach_client, 132 .detach_client = lm83_detach_client,
133}; 133};
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index d1070ed2bee6..7389a0127547 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -380,10 +380,10 @@ static void lm85_init_client(struct i2c_client *client);
380 380
381 381
382static struct i2c_driver lm85_driver = { 382static struct i2c_driver lm85_driver = {
383 .owner = THIS_MODULE, 383 .driver = {
384 .name = "lm85", 384 .name = "lm85",
385 },
385 .id = I2C_DRIVERID_LM85, 386 .id = I2C_DRIVERID_LM85,
386 .flags = I2C_DF_NOTIFY,
387 .attach_adapter = lm85_attach_adapter, 387 .attach_adapter = lm85_attach_adapter,
388 .detach_client = lm85_detach_client, 388 .detach_client = lm85_detach_client,
389}; 389};
@@ -443,7 +443,17 @@ show_fan_offset(4);
443static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) 443static ssize_t show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf)
444{ 444{
445 struct lm85_data *data = lm85_update_device(dev); 445 struct lm85_data *data = lm85_update_device(dev);
446 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 446 int vid;
447
448 if (data->type == adt7463 && (data->vid & 0x80)) {
449 /* 6-pin VID (VRM 10) */
450 vid = vid_from_reg(data->vid & 0x3f, data->vrm);
451 } else {
452 /* 5-pin VID (VRM 9) */
453 vid = vid_from_reg(data->vid & 0x1f, data->vrm);
454 }
455
456 return sprintf(buf, "%d\n", vid);
447} 457}
448 458
449static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 459static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL);
@@ -1176,17 +1186,14 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1176 device_create_file(&new_client->dev, &dev_attr_in1_input); 1186 device_create_file(&new_client->dev, &dev_attr_in1_input);
1177 device_create_file(&new_client->dev, &dev_attr_in2_input); 1187 device_create_file(&new_client->dev, &dev_attr_in2_input);
1178 device_create_file(&new_client->dev, &dev_attr_in3_input); 1188 device_create_file(&new_client->dev, &dev_attr_in3_input);
1179 device_create_file(&new_client->dev, &dev_attr_in4_input);
1180 device_create_file(&new_client->dev, &dev_attr_in0_min); 1189 device_create_file(&new_client->dev, &dev_attr_in0_min);
1181 device_create_file(&new_client->dev, &dev_attr_in1_min); 1190 device_create_file(&new_client->dev, &dev_attr_in1_min);
1182 device_create_file(&new_client->dev, &dev_attr_in2_min); 1191 device_create_file(&new_client->dev, &dev_attr_in2_min);
1183 device_create_file(&new_client->dev, &dev_attr_in3_min); 1192 device_create_file(&new_client->dev, &dev_attr_in3_min);
1184 device_create_file(&new_client->dev, &dev_attr_in4_min);
1185 device_create_file(&new_client->dev, &dev_attr_in0_max); 1193 device_create_file(&new_client->dev, &dev_attr_in0_max);
1186 device_create_file(&new_client->dev, &dev_attr_in1_max); 1194 device_create_file(&new_client->dev, &dev_attr_in1_max);
1187 device_create_file(&new_client->dev, &dev_attr_in2_max); 1195 device_create_file(&new_client->dev, &dev_attr_in2_max);
1188 device_create_file(&new_client->dev, &dev_attr_in3_max); 1196 device_create_file(&new_client->dev, &dev_attr_in3_max);
1189 device_create_file(&new_client->dev, &dev_attr_in4_max);
1190 device_create_file(&new_client->dev, &dev_attr_temp1_input); 1197 device_create_file(&new_client->dev, &dev_attr_temp1_input);
1191 device_create_file(&new_client->dev, &dev_attr_temp2_input); 1198 device_create_file(&new_client->dev, &dev_attr_temp2_input);
1192 device_create_file(&new_client->dev, &dev_attr_temp3_input); 1199 device_create_file(&new_client->dev, &dev_attr_temp3_input);
@@ -1224,6 +1231,15 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
1224 device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit); 1231 device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit);
1225 device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit); 1232 device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit);
1226 1233
1234 /* The ADT7463 has an optional VRM 10 mode where pin 21 is used
1235 as a sixth digital VID input rather than an analog input. */
1236 data->vid = lm85_read_value(new_client, LM85_REG_VID);
1237 if (!(kind == adt7463 && (data->vid & 0x80))) {
1238 device_create_file(&new_client->dev, &dev_attr_in4_input);
1239 device_create_file(&new_client->dev, &dev_attr_in4_min);
1240 device_create_file(&new_client->dev, &dev_attr_in4_max);
1241 }
1242
1227 return 0; 1243 return 0;
1228 1244
1229 /* Error out and cleanup code */ 1245 /* Error out and cleanup code */
@@ -1382,11 +1398,18 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1382 irrelevant. So it is left in 4*/ 1398 irrelevant. So it is left in 4*/
1383 data->adc_scale = (data->type == emc6d102 ) ? 16 : 4; 1399 data->adc_scale = (data->type == emc6d102 ) ? 16 : 4;
1384 1400
1385 for (i = 0; i <= 4; ++i) { 1401 data->vid = lm85_read_value(client, LM85_REG_VID);
1402
1403 for (i = 0; i <= 3; ++i) {
1386 data->in[i] = 1404 data->in[i] =
1387 lm85_read_value(client, LM85_REG_IN(i)); 1405 lm85_read_value(client, LM85_REG_IN(i));
1388 } 1406 }
1389 1407
1408 if (!(data->type == adt7463 && (data->vid & 0x80))) {
1409 data->in[4] = lm85_read_value(client,
1410 LM85_REG_IN(4));
1411 }
1412
1390 for (i = 0; i <= 3; ++i) { 1413 for (i = 0; i <= 3; ++i) {
1391 data->fan[i] = 1414 data->fan[i] =
1392 lm85_read_value(client, LM85_REG_FAN(i)); 1415 lm85_read_value(client, LM85_REG_FAN(i));
@@ -1450,13 +1473,20 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1450 /* Things that don't change often */ 1473 /* Things that don't change often */
1451 dev_dbg(&client->dev, "Reading config values\n"); 1474 dev_dbg(&client->dev, "Reading config values\n");
1452 1475
1453 for (i = 0; i <= 4; ++i) { 1476 for (i = 0; i <= 3; ++i) {
1454 data->in_min[i] = 1477 data->in_min[i] =
1455 lm85_read_value(client, LM85_REG_IN_MIN(i)); 1478 lm85_read_value(client, LM85_REG_IN_MIN(i));
1456 data->in_max[i] = 1479 data->in_max[i] =
1457 lm85_read_value(client, LM85_REG_IN_MAX(i)); 1480 lm85_read_value(client, LM85_REG_IN_MAX(i));
1458 } 1481 }
1459 1482
1483 if (!(data->type == adt7463 && (data->vid & 0x80))) {
1484 data->in_min[4] = lm85_read_value(client,
1485 LM85_REG_IN_MIN(4));
1486 data->in_max[4] = lm85_read_value(client,
1487 LM85_REG_IN_MAX(4));
1488 }
1489
1460 if ( data->type == emc6d100 ) { 1490 if ( data->type == emc6d100 ) {
1461 for (i = 5; i <= 7; ++i) { 1491 for (i = 5; i <= 7; ++i) {
1462 data->in_min[i] = 1492 data->in_min[i] =
@@ -1478,8 +1508,6 @@ static struct lm85_data *lm85_update_device(struct device *dev)
1478 lm85_read_value(client, LM85_REG_TEMP_MAX(i)); 1508 lm85_read_value(client, LM85_REG_TEMP_MAX(i));
1479 } 1509 }
1480 1510
1481 data->vid = lm85_read_value(client, LM85_REG_VID);
1482
1483 for (i = 0; i <= 2; ++i) { 1511 for (i = 0; i <= 2; ++i) {
1484 int val ; 1512 int val ;
1485 data->autofan[i].config = 1513 data->autofan[i].config =
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index eeec18177861..6ba34c302d8d 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -161,10 +161,10 @@ static struct lm87_data *lm87_update_device(struct device *dev);
161 */ 161 */
162 162
163static struct i2c_driver lm87_driver = { 163static struct i2c_driver lm87_driver = {
164 .owner = THIS_MODULE, 164 .driver = {
165 .name = "lm87", 165 .name = "lm87",
166 },
166 .id = I2C_DRIVERID_LM87, 167 .id = I2C_DRIVERID_LM87,
167 .flags = I2C_DF_NOTIFY,
168 .attach_adapter = lm87_attach_adapter, 168 .attach_adapter = lm87_attach_adapter,
169 .detach_client = lm87_detach_client, 169 .detach_client = lm87_detach_client,
170}; 170};
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 83cf2e1b09f5..5679464447cc 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -186,10 +186,10 @@ static struct lm90_data *lm90_update_device(struct device *dev);
186 */ 186 */
187 187
188static struct i2c_driver lm90_driver = { 188static struct i2c_driver lm90_driver = {
189 .owner = THIS_MODULE, 189 .driver = {
190 .name = "lm90", 190 .name = "lm90",
191 },
191 .id = I2C_DRIVERID_LM90, 192 .id = I2C_DRIVERID_LM90,
192 .flags = I2C_DF_NOTIFY,
193 .attach_adapter = lm90_attach_adapter, 193 .attach_adapter = lm90_attach_adapter,
194 .detach_client = lm90_detach_client, 194 .detach_client = lm90_detach_client,
195}; 195};
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index 7a4b3701ed1a..b0c4cb730a7e 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -410,10 +410,10 @@ static int lm92_detach_client(struct i2c_client *client)
410 */ 410 */
411 411
412static struct i2c_driver lm92_driver = { 412static struct i2c_driver lm92_driver = {
413 .owner = THIS_MODULE, 413 .driver = {
414 .name = "lm92", 414 .name = "lm92",
415 },
415 .id = I2C_DRIVERID_LM92, 416 .id = I2C_DRIVERID_LM92,
416 .flags = I2C_DF_NOTIFY,
417 .attach_adapter = lm92_attach_adapter, 417 .attach_adapter = lm92_attach_adapter,
418 .detach_client = lm92_detach_client, 418 .detach_client = lm92_detach_client,
419}; 419};
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 69e7e125683b..3abe330b22ce 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -90,9 +90,9 @@ static struct max1619_data *max1619_update_device(struct device *dev);
90 */ 90 */
91 91
92static struct i2c_driver max1619_driver = { 92static struct i2c_driver max1619_driver = {
93 .owner = THIS_MODULE, 93 .driver = {
94 .name = "max1619", 94 .name = "max1619",
95 .flags = I2C_DF_NOTIFY, 95 },
96 .attach_adapter = max1619_attach_adapter, 96 .attach_adapter = max1619_attach_adapter,
97 .detach_client = max1619_detach_client, 97 .detach_client = max1619_detach_client,
98}; 98};
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index 17f745a23d04..f161e88e3bb6 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -236,8 +236,9 @@ static struct pc87360_data *pc87360_update_device(struct device *dev);
236 */ 236 */
237 237
238static struct i2c_driver pc87360_driver = { 238static struct i2c_driver pc87360_driver = {
239 .owner = THIS_MODULE, 239 .driver = {
240 .name = "pc87360", 240 .name = "pc87360",
241 },
241 .attach_adapter = pc87360_detect, 242 .attach_adapter = pc87360_detect,
242 .detach_client = pc87360_detach_client, 243 .detach_client = pc87360_detach_client,
243}; 244};
@@ -798,7 +799,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
798 for (i = 0; i < 3; i++) { 799 for (i = 0; i < 3; i++) {
799 if (((data->address[i] = extra_isa[i])) 800 if (((data->address[i] = extra_isa[i]))
800 && !request_region(extra_isa[i], PC87360_EXTENT, 801 && !request_region(extra_isa[i], PC87360_EXTENT,
801 pc87360_driver.name)) { 802 pc87360_driver.driver.name)) {
802 dev_err(&new_client->dev, "Region 0x%x-0x%x already " 803 dev_err(&new_client->dev, "Region 0x%x-0x%x already "
803 "in use!\n", extra_isa[i], 804 "in use!\n", extra_isa[i],
804 extra_isa[i]+PC87360_EXTENT-1); 805 extra_isa[i]+PC87360_EXTENT-1);
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 9c6cadec1087..8be5189d9bd9 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -198,8 +198,9 @@ static struct sis5595_data *sis5595_update_device(struct device *dev);
198static void sis5595_init_client(struct i2c_client *client); 198static void sis5595_init_client(struct i2c_client *client);
199 199
200static struct i2c_driver sis5595_driver = { 200static struct i2c_driver sis5595_driver = {
201 .owner = THIS_MODULE, 201 .driver = {
202 .name = "sis5595", 202 .name = "sis5595",
203 },
203 .attach_adapter = sis5595_detect, 204 .attach_adapter = sis5595_detect,
204 .detach_client = sis5595_detach_client, 205 .detach_client = sis5595_detach_client,
205}; 206};
@@ -484,7 +485,8 @@ static int sis5595_detect(struct i2c_adapter *adapter)
484 if (force_addr) 485 if (force_addr)
485 address = force_addr & ~(SIS5595_EXTENT - 1); 486 address = force_addr & ~(SIS5595_EXTENT - 1);
486 /* Reserve the ISA region */ 487 /* Reserve the ISA region */
487 if (!request_region(address, SIS5595_EXTENT, sis5595_driver.name)) { 488 if (!request_region(address, SIS5595_EXTENT,
489 sis5595_driver.driver.name)) {
488 err = -EBUSY; 490 err = -EBUSY;
489 goto exit; 491 goto exit;
490 } 492 }
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 2a3e21b5b6b4..8663bbbe97f5 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -226,8 +226,9 @@ static int smsc47b397_detach_client(struct i2c_client *client)
226static int smsc47b397_detect(struct i2c_adapter *adapter); 226static int smsc47b397_detect(struct i2c_adapter *adapter);
227 227
228static struct i2c_driver smsc47b397_driver = { 228static struct i2c_driver smsc47b397_driver = {
229 .owner = THIS_MODULE, 229 .driver = {
230 .name = "smsc47b397", 230 .name = "smsc47b397",
231 },
231 .attach_adapter = smsc47b397_detect, 232 .attach_adapter = smsc47b397_detect,
232 .detach_client = smsc47b397_detach_client, 233 .detach_client = smsc47b397_detach_client,
233}; 234};
@@ -238,7 +239,8 @@ static int smsc47b397_detect(struct i2c_adapter *adapter)
238 struct smsc47b397_data *data; 239 struct smsc47b397_data *data;
239 int err = 0; 240 int err = 0;
240 241
241 if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) { 242 if (!request_region(address, SMSC_EXTENT,
243 smsc47b397_driver.driver.name)) {
242 dev_err(&adapter->dev, "Region 0x%x already in use!\n", 244 dev_err(&adapter->dev, "Region 0x%x already in use!\n",
243 address); 245 address);
244 return -EBUSY; 246 return -EBUSY;
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 5905c1af88f2..d1e3ec0fe4df 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -126,8 +126,9 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
126 126
127 127
128static struct i2c_driver smsc47m1_driver = { 128static struct i2c_driver smsc47m1_driver = {
129 .owner = THIS_MODULE, 129 .driver = {
130 .name = "smsc47m1", 130 .name = "smsc47m1",
131 },
131 .attach_adapter = smsc47m1_detect, 132 .attach_adapter = smsc47m1_detect,
132 .detach_client = smsc47m1_detach_client, 133 .detach_client = smsc47m1_detach_client,
133}; 134};
@@ -394,7 +395,7 @@ static int smsc47m1_detect(struct i2c_adapter *adapter)
394 int err = 0; 395 int err = 0;
395 int fan1, fan2, pwm1, pwm2; 396 int fan1, fan2, pwm1, pwm2;
396 397
397 if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) { 398 if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.driver.name)) {
398 dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); 399 dev_err(&adapter->dev, "Region 0x%x already in use!\n", address);
399 return -EBUSY; 400 return -EBUSY;
400 } 401 }
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 6f696f897176..cb01848729b5 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -572,8 +572,9 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
572/* The driver. I choose to use type i2c_driver, as at is identical to both 572/* The driver. I choose to use type i2c_driver, as at is identical to both
573 smbus_driver and isa_driver, and clients could be of either kind */ 573 smbus_driver and isa_driver, and clients could be of either kind */
574static struct i2c_driver via686a_driver = { 574static struct i2c_driver via686a_driver = {
575 .owner = THIS_MODULE, 575 .driver = {
576 .name = "via686a", 576 .name = "via686a",
577 },
577 .attach_adapter = via686a_detect, 578 .attach_adapter = via686a_detect,
578 .detach_client = via686a_detach_client, 579 .detach_client = via686a_detach_client,
579}; 580};
@@ -615,7 +616,8 @@ static int via686a_detect(struct i2c_adapter *adapter)
615 } 616 }
616 617
617 /* Reserve the ISA region */ 618 /* Reserve the ISA region */
618 if (!request_region(address, VIA686A_EXTENT, via686a_driver.name)) { 619 if (!request_region(address, VIA686A_EXTENT,
620 via686a_driver.driver.name)) {
619 dev_err(&adapter->dev, "region 0x%x already in use!\n", 621 dev_err(&adapter->dev, "region 0x%x already in use!\n",
620 address); 622 address);
621 return -ENODEV; 623 return -ENODEV;
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
new file mode 100644
index 000000000000..d00a726d0239
--- /dev/null
+++ b/drivers/hwmon/vt8231.c
@@ -0,0 +1,862 @@
1/*
2 vt8231.c - Part of lm_sensors, Linux kernel modules
3 for hardware monitoring
4
5 Copyright (c) 2005 Roger Lucas <roger@planbit.co.uk>
6 Copyright (c) 2002 Mark D. Studebaker <mdsxyz123@yahoo.com>
7 Aaron M. Marsh <amarsh@sdf.lonestar.org>
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22*/
23
24/* Supports VIA VT8231 South Bridge embedded sensors
25*/
26
27#include <linux/module.h>
28#include <linux/init.h>
29#include <linux/slab.h>
30#include <linux/pci.h>
31#include <linux/jiffies.h>
32#include <linux/i2c.h>
33#include <linux/i2c-isa.h>
34#include <linux/hwmon.h>
35#include <linux/hwmon-sysfs.h>
36#include <linux/hwmon-vid.h>
37#include <linux/err.h>
38#include <asm/io.h>
39
40static int force_addr;
41module_param(force_addr, int, 0);
42MODULE_PARM_DESC(force_addr, "Initialize the base address of the sensors");
43
44/* Device address
45 Note that we can't determine the ISA address until we have initialized
46 our module */
47static unsigned short isa_address;
48
49#define VT8231_EXTENT 0x80
50#define VT8231_BASE_REG 0x70
51#define VT8231_ENABLE_REG 0x74
52
53/* The VT8231 registers
54
55 The reset value for the input channel configuration is used (Reg 0x4A=0x07)
56 which sets the selected inputs marked with '*' below if multiple options are
57 possible:
58
59 Voltage Mode Temperature Mode
60 Sensor Linux Id Linux Id VIA Id
61 -------- -------- -------- ------
62 CPU Diode N/A temp1 0
63 UIC1 in0 temp2 * 1
64 UIC2 in1 * temp3 2
65 UIC3 in2 * temp4 3
66 UIC4 in3 * temp5 4
67 UIC5 in4 * temp6 5
68 3.3V in5 N/A
69
70 Note that the BIOS may set the configuration register to a different value
71 to match the motherboard configuration.
72*/
73
74/* fans numbered 0-1 */
75#define VT8231_REG_FAN_MIN(nr) (0x3b + (nr))
76#define VT8231_REG_FAN(nr) (0x29 + (nr))
77
78/* Voltage inputs numbered 0-5 */
79
80static const u8 regvolt[] = { 0x21, 0x22, 0x23, 0x24, 0x25, 0x26 };
81static const u8 regvoltmax[] = { 0x3d, 0x2b, 0x2d, 0x2f, 0x31, 0x33 };
82static const u8 regvoltmin[] = { 0x3e, 0x2c, 0x2e, 0x30, 0x32, 0x34 };
83
84/* Temperatures are numbered 1-6 according to the Linux kernel specification.
85**
86** In the VIA datasheet, however, the temperatures are numbered from zero.
87** Since it is important that this driver can easily be compared to the VIA
88** datasheet, we will use the VIA numbering within this driver and map the
89** kernel sysfs device name to the VIA number in the sysfs callback.
90*/
91
92#define VT8231_REG_TEMP_LOW01 0x49
93#define VT8231_REG_TEMP_LOW25 0x4d
94
95static const u8 regtemp[] = { 0x1f, 0x21, 0x22, 0x23, 0x24, 0x25 };
96static const u8 regtempmax[] = { 0x39, 0x3d, 0x2b, 0x2d, 0x2f, 0x31 };
97static const u8 regtempmin[] = { 0x3a, 0x3e, 0x2c, 0x2e, 0x30, 0x32 };
98
99#define TEMP_FROM_REG(reg) (((253 * 4 - (reg)) * 550 + 105) / 210)
100#define TEMP_MAXMIN_FROM_REG(reg) (((253 - (reg)) * 2200 + 105) / 210)
101#define TEMP_MAXMIN_TO_REG(val) (253 - ((val) * 210 + 1100) / 2200)
102
103#define VT8231_REG_CONFIG 0x40
104#define VT8231_REG_ALARM1 0x41
105#define VT8231_REG_ALARM2 0x42
106#define VT8231_REG_FANDIV 0x47
107#define VT8231_REG_UCH_CONFIG 0x4a
108#define VT8231_REG_TEMP1_CONFIG 0x4b
109#define VT8231_REG_TEMP2_CONFIG 0x4c
110
111/* temps 0-5 as numbered in VIA datasheet - see later for mapping to Linux
112** numbering
113*/
114#define ISTEMP(i, ch_config) ((i) == 0 ? 1 : \
115 ((ch_config) >> ((i)+1)) & 0x01)
116/* voltages 0-5 */
117#define ISVOLT(i, ch_config) ((i) == 5 ? 1 : \
118 !(((ch_config) >> ((i)+2)) & 0x01))
119
120#define DIV_FROM_REG(val) (1 << (val))
121
122/* NB The values returned here are NOT temperatures. The calibration curves
123** for the thermistor curves are board-specific and must go in the
124** sensors.conf file. Temperature sensors are actually ten bits, but the
125** VIA datasheet only considers the 8 MSBs obtained from the regtemp[]
126** register. The temperature value returned should have a magnitude of 3,
127** so we use the VIA scaling as the "true" scaling and use the remaining 2
128** LSBs as fractional precision.
129**
130** All the on-chip hardware temperature comparisons for the alarms are only
131** 8-bits wide, and compare against the 8 MSBs of the temperature. The bits
132** in the registers VT8231_REG_TEMP_LOW01 and VT8231_REG_TEMP_LOW25 are
133** ignored.
134*/
135
136/******** FAN RPM CONVERSIONS ********
137** This chip saturates back at 0, not at 255 like many the other chips.
138** So, 0 means 0 RPM
139*/
140static inline u8 FAN_TO_REG(long rpm, int div)
141{
142 if (rpm == 0)
143 return 0;
144 return SENSORS_LIMIT(1310720 / (rpm * div), 1, 255);
145}
146
147#define FAN_FROM_REG(val, div) ((val) == 0 ? 0 : 1310720 / ((val) * (div)))
148
149struct vt8231_data {
150 struct i2c_client client;
151 struct semaphore update_lock;
152 struct class_device *class_dev;
153 char valid; /* !=0 if following fields are valid */
154 unsigned long last_updated; /* In jiffies */
155
156 u8 in[6]; /* Register value */
157 u8 in_max[6]; /* Register value */
158 u8 in_min[6]; /* Register value */
159 u16 temp[6]; /* Register value 10 bit, right aligned */
160 u8 temp_max[6]; /* Register value */
161 u8 temp_min[6]; /* Register value */
162 u8 fan[2]; /* Register value */
163 u8 fan_min[2]; /* Register value */
164 u8 fan_div[2]; /* Register encoding, shifted right */
165 u16 alarms; /* Register encoding */
166 u8 uch_config;
167};
168
169static struct pci_dev *s_bridge;
170static int vt8231_detect(struct i2c_adapter *adapter);
171static int vt8231_detach_client(struct i2c_client *client);
172static struct vt8231_data *vt8231_update_device(struct device *dev);
173static void vt8231_init_client(struct i2c_client *client);
174
175static inline int vt8231_read_value(struct i2c_client *client, u8 reg)
176{
177 return inb_p(client->addr + reg);
178}
179
180static inline void vt8231_write_value(struct i2c_client *client, u8 reg,
181 u8 value)
182{
183 outb_p(value, client->addr + reg);
184}
185
186/* following are the sysfs callback functions */
187static ssize_t show_in(struct device *dev, struct device_attribute *attr,
188 char *buf)
189{
190 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
191 int nr = sensor_attr->index;
192 struct vt8231_data *data = vt8231_update_device(dev);
193
194 return sprintf(buf, "%d\n", ((data->in[nr] - 3) * 10000) / 958);
195}
196
197static ssize_t show_in_min(struct device *dev, struct device_attribute *attr,
198 char *buf)
199{
200 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
201 int nr = sensor_attr->index;
202 struct vt8231_data *data = vt8231_update_device(dev);
203
204 return sprintf(buf, "%d\n", ((data->in_min[nr] - 3) * 10000) / 958);
205}
206
207static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
208 char *buf)
209{
210 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
211 int nr = sensor_attr->index;
212 struct vt8231_data *data = vt8231_update_device(dev);
213
214 return sprintf(buf, "%d\n", (((data->in_max[nr] - 3) * 10000) / 958));
215}
216
217static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
218 const char *buf, size_t count)
219{
220 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
221 int nr = sensor_attr->index;
222 struct i2c_client *client = to_i2c_client(dev);
223 struct vt8231_data *data = i2c_get_clientdata(client);
224 unsigned long val = simple_strtoul(buf, NULL, 10);
225
226 down(&data->update_lock);
227 data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
228 vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]);
229 up(&data->update_lock);
230 return count;
231}
232
233static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
234 const char *buf, size_t count)
235{
236 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
237 int nr = sensor_attr->index;
238 struct i2c_client *client = to_i2c_client(dev);
239 struct vt8231_data *data = i2c_get_clientdata(client);
240 unsigned long val = simple_strtoul(buf, NULL, 10);
241
242 down(&data->update_lock);
243 data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
244 vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]);
245 up(&data->update_lock);
246 return count;
247}
248
249/* Special case for input 5 as this has 3.3V scaling built into the chip */
250static ssize_t show_in5(struct device *dev, struct device_attribute *attr,
251 char *buf)
252{
253 struct vt8231_data *data = vt8231_update_device(dev);
254
255 return sprintf(buf, "%d\n",
256 (((data->in[5] - 3) * 10000 * 54) / (958 * 34)));
257}
258
259static ssize_t show_in5_min(struct device *dev, struct device_attribute *attr,
260 char *buf)
261{
262 struct vt8231_data *data = vt8231_update_device(dev);
263
264 return sprintf(buf, "%d\n",
265 (((data->in_min[5] - 3) * 10000 * 54) / (958 * 34)));
266}
267
268static ssize_t show_in5_max(struct device *dev, struct device_attribute *attr,
269 char *buf)
270{
271 struct vt8231_data *data = vt8231_update_device(dev);
272
273 return sprintf(buf, "%d\n",
274 (((data->in_max[5] - 3) * 10000 * 54) / (958 * 34)));
275}
276
277static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr,
278 const char *buf, size_t count)
279{
280 struct i2c_client *client = to_i2c_client(dev);
281 struct vt8231_data *data = i2c_get_clientdata(client);
282 unsigned long val = simple_strtoul(buf, NULL, 10);
283
284 down(&data->update_lock);
285 data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
286 0, 255);
287 vt8231_write_value(client, regvoltmin[5], data->in_min[5]);
288 up(&data->update_lock);
289 return count;
290}
291
292static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr,
293 const char *buf, size_t count)
294{
295 struct i2c_client *client = to_i2c_client(dev);
296 struct vt8231_data *data = i2c_get_clientdata(client);
297 unsigned long val = simple_strtoul(buf, NULL, 10);
298
299 down(&data->update_lock);
300 data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
301 0, 255);
302 vt8231_write_value(client, regvoltmax[5], data->in_max[5]);
303 up(&data->update_lock);
304 return count;
305}
306
307#define define_voltage_sysfs(offset) \
308static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
309 show_in, NULL, offset); \
310static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
311 show_in_min, set_in_min, offset); \
312static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
313 show_in_max, set_in_max, offset)
314
315define_voltage_sysfs(0);
316define_voltage_sysfs(1);
317define_voltage_sysfs(2);
318define_voltage_sysfs(3);
319define_voltage_sysfs(4);
320
321static DEVICE_ATTR(in5_input, S_IRUGO, show_in5, NULL);
322static DEVICE_ATTR(in5_min, S_IRUGO | S_IWUSR, show_in5_min, set_in5_min);
323static DEVICE_ATTR(in5_max, S_IRUGO | S_IWUSR, show_in5_max, set_in5_max);
324
325/* Temperatures */
326static ssize_t show_temp0(struct device *dev, struct device_attribute *attr,
327 char *buf)
328{
329 struct vt8231_data *data = vt8231_update_device(dev);
330 return sprintf(buf, "%d\n", data->temp[0] * 250);
331}
332
333static ssize_t show_temp0_max(struct device *dev, struct device_attribute *attr,
334 char *buf)
335{
336 struct vt8231_data *data = vt8231_update_device(dev);
337 return sprintf(buf, "%d\n", data->temp_max[0] * 1000);
338}
339
340static ssize_t show_temp0_min(struct device *dev, struct device_attribute *attr,
341 char *buf)
342{
343 struct vt8231_data *data = vt8231_update_device(dev);
344 return sprintf(buf, "%d\n", data->temp_min[0] * 1000);
345}
346
347static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr,
348 const char *buf, size_t count)
349{
350 struct i2c_client *client = to_i2c_client(dev);
351 struct vt8231_data *data = i2c_get_clientdata(client);
352 int val = simple_strtol(buf, NULL, 10);
353
354 down(&data->update_lock);
355 data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
356 vt8231_write_value(client, regtempmax[0], data->temp_max[0]);
357 up(&data->update_lock);
358 return count;
359}
360static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr,
361 const char *buf, size_t count)
362{
363 struct i2c_client *client = to_i2c_client(dev);
364 struct vt8231_data *data = i2c_get_clientdata(client);
365 int val = simple_strtol(buf, NULL, 10);
366
367 down(&data->update_lock);
368 data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
369 vt8231_write_value(client, regtempmin[0], data->temp_min[0]);
370 up(&data->update_lock);
371 return count;
372}
373
374static ssize_t show_temp(struct device *dev, struct device_attribute *attr,
375 char *buf)
376{
377 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
378 int nr = sensor_attr->index;
379 struct vt8231_data *data = vt8231_update_device(dev);
380 return sprintf(buf, "%d\n", TEMP_FROM_REG(data->temp[nr]));
381}
382
383static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
384 char *buf)
385{
386 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
387 int nr = sensor_attr->index;
388 struct vt8231_data *data = vt8231_update_device(dev);
389 return sprintf(buf, "%d\n", TEMP_MAXMIN_FROM_REG(data->temp_max[nr]));
390}
391
392static ssize_t show_temp_min(struct device *dev, struct device_attribute *attr,
393 char *buf)
394{
395 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
396 int nr = sensor_attr->index;
397 struct vt8231_data *data = vt8231_update_device(dev);
398 return sprintf(buf, "%d\n", TEMP_MAXMIN_FROM_REG(data->temp_min[nr]));
399}
400
401static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
402 const char *buf, size_t count)
403{
404 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
405 int nr = sensor_attr->index;
406 struct i2c_client *client = to_i2c_client(dev);
407 struct vt8231_data *data = i2c_get_clientdata(client);
408 int val = simple_strtol(buf, NULL, 10);
409
410 down(&data->update_lock);
411 data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
412 vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]);
413 up(&data->update_lock);
414 return count;
415}
416static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
417 const char *buf, size_t count)
418{
419 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
420 int nr = sensor_attr->index;
421 struct i2c_client *client = to_i2c_client(dev);
422 struct vt8231_data *data = i2c_get_clientdata(client);
423 int val = simple_strtol(buf, NULL, 10);
424
425 down(&data->update_lock);
426 data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
427 vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]);
428 up(&data->update_lock);
429 return count;
430}
431
432/* Note that these map the Linux temperature sensor numbering (1-6) to the VIA
433** temperature sensor numbering (0-5)
434*/
435#define define_temperature_sysfs(offset) \
436static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
437 show_temp, NULL, offset - 1); \
438static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
439 show_temp_max, set_temp_max, offset - 1); \
440static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
441 show_temp_min, set_temp_min, offset - 1)
442
443static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp0, NULL);
444static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp0_max, set_temp0_max);
445static DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, show_temp0_min, set_temp0_min);
446
447define_temperature_sysfs(2);
448define_temperature_sysfs(3);
449define_temperature_sysfs(4);
450define_temperature_sysfs(5);
451define_temperature_sysfs(6);
452
453#define CFG_INFO_TEMP(id) { &sensor_dev_attr_temp##id##_input.dev_attr, \
454 &sensor_dev_attr_temp##id##_min.dev_attr, \
455 &sensor_dev_attr_temp##id##_max.dev_attr }
456#define CFG_INFO_VOLT(id) { &sensor_dev_attr_in##id##_input.dev_attr, \
457 &sensor_dev_attr_in##id##_min.dev_attr, \
458 &sensor_dev_attr_in##id##_max.dev_attr }
459
460struct str_device_attr_table {
461 struct device_attribute *input;
462 struct device_attribute *min;
463 struct device_attribute *max;
464};
465
466static struct str_device_attr_table cfg_info_temp[] = {
467 { &dev_attr_temp1_input, &dev_attr_temp1_min, &dev_attr_temp1_max },
468 CFG_INFO_TEMP(2),
469 CFG_INFO_TEMP(3),
470 CFG_INFO_TEMP(4),
471 CFG_INFO_TEMP(5),
472 CFG_INFO_TEMP(6)
473};
474
475static struct str_device_attr_table cfg_info_volt[] = {
476 CFG_INFO_VOLT(0),
477 CFG_INFO_VOLT(1),
478 CFG_INFO_VOLT(2),
479 CFG_INFO_VOLT(3),
480 CFG_INFO_VOLT(4),
481 { &dev_attr_in5_input, &dev_attr_in5_min, &dev_attr_in5_max }
482};
483
484/* Fans */
485static ssize_t show_fan(struct device *dev, struct device_attribute *attr,
486 char *buf)
487{
488 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
489 int nr = sensor_attr->index;
490 struct vt8231_data *data = vt8231_update_device(dev);
491 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan[nr],
492 DIV_FROM_REG(data->fan_div[nr])));
493}
494
495static ssize_t show_fan_min(struct device *dev, struct device_attribute *attr,
496 char *buf)
497{
498 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
499 int nr = sensor_attr->index;
500 struct vt8231_data *data = vt8231_update_device(dev);
501 return sprintf(buf, "%d\n", FAN_FROM_REG(data->fan_min[nr],
502 DIV_FROM_REG(data->fan_div[nr])));
503}
504
505static ssize_t show_fan_div(struct device *dev, struct device_attribute *attr,
506 char *buf)
507{
508 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
509 int nr = sensor_attr->index;
510 struct vt8231_data *data = vt8231_update_device(dev);
511 return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]));
512}
513
514static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
515 const char *buf, size_t count)
516{
517 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
518 int nr = sensor_attr->index;
519 struct i2c_client *client = to_i2c_client(dev);
520 struct vt8231_data *data = i2c_get_clientdata(client);
521 int val = simple_strtoul(buf, NULL, 10);
522
523 down(&data->update_lock);
524 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
525 vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]);
526 up(&data->update_lock);
527 return count;
528}
529
530static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
531 const char *buf, size_t count)
532{
533 struct i2c_client *client = to_i2c_client(dev);
534 struct vt8231_data *data = i2c_get_clientdata(client);
535 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
536 unsigned long val = simple_strtoul(buf, NULL, 10);
537 int nr = sensor_attr->index;
538 int old = vt8231_read_value(client, VT8231_REG_FANDIV);
539 long min = FAN_FROM_REG(data->fan_min[nr],
540 DIV_FROM_REG(data->fan_div[nr]));
541
542 down(&data->update_lock);
543 switch (val) {
544 case 1: data->fan_div[nr] = 0; break;
545 case 2: data->fan_div[nr] = 1; break;
546 case 4: data->fan_div[nr] = 2; break;
547 case 8: data->fan_div[nr] = 3; break;
548 default:
549 dev_err(&client->dev, "fan_div value %ld not supported."
550 "Choose one of 1, 2, 4 or 8!\n", val);
551 up(&data->update_lock);
552 return -EINVAL;
553 }
554
555 /* Correct the fan minimum speed */
556 data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
557 vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]);
558
559 old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
560 vt8231_write_value(client, VT8231_REG_FANDIV, old);
561 up(&data->update_lock);
562 return count;
563}
564
565
566#define define_fan_sysfs(offset) \
567static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
568 show_fan, NULL, offset - 1); \
569static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
570 show_fan_div, set_fan_div, offset - 1); \
571static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
572 show_fan_min, set_fan_min, offset - 1)
573
574define_fan_sysfs(1);
575define_fan_sysfs(2);
576
577/* Alarms */
578static ssize_t show_alarms(struct device *dev, struct device_attribute *attr,
579 char *buf)
580{
581 struct vt8231_data *data = vt8231_update_device(dev);
582 return sprintf(buf, "%d\n", data->alarms);
583}
584
585static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
586
587static struct i2c_driver vt8231_driver = {
588 .driver = {
589 .name = "vt8231",
590 },
591 .attach_adapter = vt8231_detect,
592 .detach_client = vt8231_detach_client,
593};
594
595static struct pci_device_id vt8231_pci_ids[] = {
596 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231_4) },
597 { 0, }
598};
599
600MODULE_DEVICE_TABLE(pci, vt8231_pci_ids);
601
602static int __devinit vt8231_pci_probe(struct pci_dev *dev,
603 const struct pci_device_id *id);
604
605static struct pci_driver vt8231_pci_driver = {
606 .name = "vt8231",
607 .id_table = vt8231_pci_ids,
608 .probe = vt8231_pci_probe,
609};
610
611int vt8231_detect(struct i2c_adapter *adapter)
612{
613 struct i2c_client *client;
614 struct vt8231_data *data;
615 int err = 0, i;
616 u16 val;
617
618 /* 8231 requires multiple of 256 */
619 if (force_addr) {
620 isa_address = force_addr & 0xFF00;
621 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
622 isa_address);
623 if (PCIBIOS_SUCCESSFUL != pci_write_config_word(s_bridge,
624 VT8231_BASE_REG, isa_address))
625 return -ENODEV;
626 }
627
628 if (PCIBIOS_SUCCESSFUL !=
629 pci_read_config_word(s_bridge, VT8231_ENABLE_REG, &val))
630 return -ENODEV;
631
632 if (!(val & 0x0001)) {
633 dev_warn(&adapter->dev, "enabling sensors\n");
634 if (PCIBIOS_SUCCESSFUL !=
635 pci_write_config_word(s_bridge, VT8231_ENABLE_REG,
636 val | 0x0001))
637 return -ENODEV;
638 }
639
640 /* Reserve the ISA region */
641 if (!request_region(isa_address, VT8231_EXTENT,
642 vt8231_pci_driver.name)) {
643 dev_err(&adapter->dev, "region 0x%x already in use!\n",
644 isa_address);
645 return -ENODEV;
646 }
647
648 if (!(data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL))) {
649 err = -ENOMEM;
650 goto exit_release;
651 }
652
653 client = &data->client;
654 i2c_set_clientdata(client, data);
655 client->addr = isa_address;
656 client->adapter = adapter;
657 client->driver = &vt8231_driver;
658 client->dev.parent = &adapter->dev;
659
660 /* Fill in the remaining client fields and put into the global list */
661 strlcpy(client->name, "vt8231", I2C_NAME_SIZE);
662
663 init_MUTEX(&data->update_lock);
664
665 /* Tell the I2C layer a new client has arrived */
666 if ((err = i2c_attach_client(client)))
667 goto exit_free;
668
669 vt8231_init_client(client);
670
671 /* Register sysfs hooks */
672 data->class_dev = hwmon_device_register(&client->dev);
673 if (IS_ERR(data->class_dev)) {
674 err = PTR_ERR(data->class_dev);
675 goto exit_detach;
676 }
677
678 /* Must update device information to find out the config field */
679 data->uch_config = vt8231_read_value(client, VT8231_REG_UCH_CONFIG);
680
681 for (i = 0; i < ARRAY_SIZE(cfg_info_temp); i++) {
682 if (ISTEMP(i, data->uch_config)) {
683 device_create_file(&client->dev,
684 cfg_info_temp[i].input);
685 device_create_file(&client->dev, cfg_info_temp[i].max);
686 device_create_file(&client->dev, cfg_info_temp[i].min);
687 }
688 }
689
690 for (i = 0; i < ARRAY_SIZE(cfg_info_volt); i++) {
691 if (ISVOLT(i, data->uch_config)) {
692 device_create_file(&client->dev,
693 cfg_info_volt[i].input);
694 device_create_file(&client->dev, cfg_info_volt[i].max);
695 device_create_file(&client->dev, cfg_info_volt[i].min);
696 }
697 }
698
699 device_create_file(&client->dev, &sensor_dev_attr_fan1_input.dev_attr);
700 device_create_file(&client->dev, &sensor_dev_attr_fan2_input.dev_attr);
701 device_create_file(&client->dev, &sensor_dev_attr_fan1_min.dev_attr);
702 device_create_file(&client->dev, &sensor_dev_attr_fan2_min.dev_attr);
703 device_create_file(&client->dev, &sensor_dev_attr_fan1_div.dev_attr);
704 device_create_file(&client->dev, &sensor_dev_attr_fan2_div.dev_attr);
705
706 device_create_file(&client->dev, &dev_attr_alarms);
707 return 0;
708
709exit_detach:
710 i2c_detach_client(client);
711exit_free:
712 kfree(data);
713exit_release:
714 release_region(isa_address, VT8231_EXTENT);
715 return err;
716}
717
718static int vt8231_detach_client(struct i2c_client *client)
719{
720 struct vt8231_data *data = i2c_get_clientdata(client);
721 int err;
722
723 hwmon_device_unregister(data->class_dev);
724
725 if ((err = i2c_detach_client(client))) {
726 return err;
727 }
728
729 release_region(client->addr, VT8231_EXTENT);
730 kfree(data);
731
732 return 0;
733}
734
735static void vt8231_init_client(struct i2c_client *client)
736{
737 vt8231_write_value(client, VT8231_REG_TEMP1_CONFIG, 0);
738 vt8231_write_value(client, VT8231_REG_TEMP2_CONFIG, 0);
739}
740
741static struct vt8231_data *vt8231_update_device(struct device *dev)
742{
743 struct i2c_client *client = to_i2c_client(dev);
744 struct vt8231_data *data = i2c_get_clientdata(client);
745 int i;
746 u16 low;
747
748 down(&data->update_lock);
749
750 if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
751 || !data->valid) {
752 for (i = 0; i < 6; i++) {
753 if (ISVOLT(i, data->uch_config)) {
754 data->in[i] = vt8231_read_value(client,
755 regvolt[i]);
756 data->in_min[i] = vt8231_read_value(client,
757 regvoltmin[i]);
758 data->in_max[i] = vt8231_read_value(client,
759 regvoltmax[i]);
760 }
761 }
762 for (i = 0; i < 2; i++) {
763 data->fan[i] = vt8231_read_value(client,
764 VT8231_REG_FAN(i));
765 data->fan_min[i] = vt8231_read_value(client,
766 VT8231_REG_FAN_MIN(i));
767 }
768
769 low = vt8231_read_value(client, VT8231_REG_TEMP_LOW01);
770 low = (low >> 6) | ((low & 0x30) >> 2)
771 | (vt8231_read_value(client, VT8231_REG_TEMP_LOW25) << 4);
772 for (i = 0; i < 6; i++) {
773 if (ISTEMP(i, data->uch_config)) {
774 data->temp[i] = (vt8231_read_value(client,
775 regtemp[i]) << 2)
776 | ((low >> (2 * i)) & 0x03);
777 data->temp_max[i] = vt8231_read_value(client,
778 regtempmax[i]);
779 data->temp_min[i] = vt8231_read_value(client,
780 regtempmin[i]);
781 }
782 }
783
784 i = vt8231_read_value(client, VT8231_REG_FANDIV);
785 data->fan_div[0] = (i >> 4) & 0x03;
786 data->fan_div[1] = i >> 6;
787 data->alarms = vt8231_read_value(client, VT8231_REG_ALARM1) |
788 (vt8231_read_value(client, VT8231_REG_ALARM2) << 8);
789
790 /* Set alarm flags correctly */
791 if (!data->fan[0] && data->fan_min[0]) {
792 data->alarms |= 0x40;
793 } else if (data->fan[0] && !data->fan_min[0]) {
794 data->alarms &= ~0x40;
795 }
796
797 if (!data->fan[1] && data->fan_min[1]) {
798 data->alarms |= 0x80;
799 } else if (data->fan[1] && !data->fan_min[1]) {
800 data->alarms &= ~0x80;
801 }
802
803 data->last_updated = jiffies;
804 data->valid = 1;
805 }
806
807 up(&data->update_lock);
808
809 return data;
810}
811
812static int __devinit vt8231_pci_probe(struct pci_dev *dev,
813 const struct pci_device_id *id)
814{
815 u16 val;
816
817 if (PCIBIOS_SUCCESSFUL != pci_read_config_word(dev, VT8231_BASE_REG,
818 &val))
819 return -ENODEV;
820
821 isa_address = val & ~(VT8231_EXTENT - 1);
822 if (isa_address == 0 && force_addr == 0) {
823 dev_err(&dev->dev, "base address not set -\
824 upgrade BIOS or use force_addr=0xaddr\n");
825 return -ENODEV;
826 }
827
828 s_bridge = pci_dev_get(dev);
829
830 if (i2c_isa_add_driver(&vt8231_driver)) {
831 pci_dev_put(s_bridge);
832 s_bridge = NULL;
833 }
834
835 /* Always return failure here. This is to allow other drivers to bind
836 * to this pci device. We don't really want to have control over the
837 * pci device, we only wanted to read as few register values from it.
838 */
839 return -ENODEV;
840}
841
842static int __init sm_vt8231_init(void)
843{
844 return pci_module_init(&vt8231_pci_driver);
845}
846
847static void __exit sm_vt8231_exit(void)
848{
849 pci_unregister_driver(&vt8231_pci_driver);
850 if (s_bridge != NULL) {
851 i2c_isa_del_driver(&vt8231_driver);
852 pci_dev_put(s_bridge);
853 s_bridge = NULL;
854 }
855}
856
857MODULE_AUTHOR("Roger Lucas <roger@planbit.co.uk>");
858MODULE_DESCRIPTION("VT8231 sensors");
859MODULE_LICENSE("GPL");
860
861module_init(sm_vt8231_init);
862module_exit(sm_vt8231_exit);
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index eee22a57e929..12d79f5e4900 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -676,7 +676,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
676 int i, err = 0; 676 int i, err = 0;
677 677
678 if (!request_region(address + REGION_OFFSET, REGION_LENGTH, 678 if (!request_region(address + REGION_OFFSET, REGION_LENGTH,
679 w83627ehf_driver.name)) { 679 w83627ehf_driver.driver.name)) {
680 err = -EBUSY; 680 err = -EBUSY;
681 goto exit; 681 goto exit;
682 } 682 }
@@ -785,8 +785,9 @@ static int w83627ehf_detach_client(struct i2c_client *client)
785} 785}
786 786
787static struct i2c_driver w83627ehf_driver = { 787static struct i2c_driver w83627ehf_driver = {
788 .owner = THIS_MODULE, 788 .driver = {
789 .name = "w83627ehf", 789 .name = "w83627ehf",
790 },
790 .attach_adapter = w83627ehf_detect, 791 .attach_adapter = w83627ehf_detect,
791 .detach_client = w83627ehf_detach_client, 792 .detach_client = w83627ehf_detach_client,
792}; 793};
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index bbb3dcde146b..7ea441d4da63 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -332,8 +332,9 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev);
332static void w83627hf_init_client(struct i2c_client *client); 332static void w83627hf_init_client(struct i2c_client *client);
333 333
334static struct i2c_driver w83627hf_driver = { 334static struct i2c_driver w83627hf_driver = {
335 .owner = THIS_MODULE, 335 .driver = {
336 .name = "w83627hf", 336 .name = "w83627hf",
337 },
337 .attach_adapter = w83627hf_detect, 338 .attach_adapter = w83627hf_detect,
338 .detach_client = w83627hf_detach_client, 339 .detach_client = w83627hf_detach_client,
339}; 340};
@@ -1009,7 +1010,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1009 address = force_addr & WINB_ALIGNMENT; 1010 address = force_addr & WINB_ALIGNMENT;
1010 1011
1011 if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE, 1012 if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE,
1012 w83627hf_driver.name)) { 1013 w83627hf_driver.driver.name)) {
1013 err = -EBUSY; 1014 err = -EBUSY;
1014 goto ERROR0; 1015 goto ERROR0;
1015 } 1016 }
@@ -1122,11 +1123,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1122 if (kind != w83697hf) 1123 if (kind != w83697hf)
1123 device_create_file_temp(new_client, 3); 1124 device_create_file_temp(new_client, 3);
1124 1125
1125 if (kind != w83697hf) 1126 if (kind != w83697hf && data->vid != 0xff) {
1126 device_create_file_vid(new_client); 1127 device_create_file_vid(new_client);
1127
1128 if (kind != w83697hf)
1129 device_create_file_vrm(new_client); 1128 device_create_file_vrm(new_client);
1129 }
1130 1130
1131 device_create_file_fan_div(new_client, 1); 1131 device_create_file_fan_div(new_client, 1);
1132 device_create_file_fan_div(new_client, 2); 1132 device_create_file_fan_div(new_client, 2);
@@ -1232,7 +1232,7 @@ static int w83627thf_read_gpio5(struct i2c_client *client)
1232 1232
1233 /* Make sure the pins are configured for input 1233 /* Make sure the pins are configured for input
1234 There must be at least five (VRM 9), and possibly 6 (VRM 10) */ 1234 There must be at least five (VRM 9), and possibly 6 (VRM 10) */
1235 sel = superio_inb(W83627THF_GPIO5_IOSR); 1235 sel = superio_inb(W83627THF_GPIO5_IOSR) & 0x3f;
1236 if ((sel & 0x1f) != 0x1f) { 1236 if ((sel & 0x1f) != 0x1f) {
1237 dev_dbg(&client->dev, "GPIO5 not configured for VID " 1237 dev_dbg(&client->dev, "GPIO5 not configured for VID "
1238 "function\n"); 1238 "function\n");
@@ -1323,19 +1323,18 @@ static void w83627hf_init_client(struct i2c_client *client)
1323 int hi = w83627hf_read_value(client, W83781D_REG_CHIPID); 1323 int hi = w83627hf_read_value(client, W83781D_REG_CHIPID);
1324 data->vid = (lo & 0x0f) | ((hi & 0x01) << 4); 1324 data->vid = (lo & 0x0f) | ((hi & 0x01) << 4);
1325 } else if (w83627thf == data->type) { 1325 } else if (w83627thf == data->type) {
1326 data->vid = w83627thf_read_gpio5(client) & 0x3f; 1326 data->vid = w83627thf_read_gpio5(client);
1327 } 1327 }
1328 1328
1329 /* Read VRM & OVT Config only once */ 1329 /* Read VRM & OVT Config only once */
1330 if (w83627thf == data->type || w83637hf == data->type) { 1330 if (w83627thf == data->type || w83637hf == data->type) {
1331 data->vrm_ovt = 1331 data->vrm_ovt =
1332 w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG); 1332 w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
1333 data->vrm = (data->vrm_ovt & 0x01) ? 90 : 82;
1334 } else {
1335 /* Convert VID to voltage based on default VRM */
1336 data->vrm = vid_which_vrm();
1337 } 1333 }
1338 1334
1335 /* Convert VID to voltage based on VRM */
1336 data->vrm = vid_which_vrm();
1337
1339 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1); 1338 tmp = w83627hf_read_value(client, W83781D_REG_SCFG1);
1340 for (i = 1; i <= 3; i++) { 1339 for (i = 1; i <= 3; i++) {
1341 if (!(tmp & BIT_SCFG1[i - 1])) { 1340 if (!(tmp & BIT_SCFG1[i - 1])) {
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index ffdb3a03e2b5..557114872f3c 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -269,17 +269,18 @@ static struct w83781d_data *w83781d_update_device(struct device *dev);
269static void w83781d_init_client(struct i2c_client *client); 269static void w83781d_init_client(struct i2c_client *client);
270 270
271static struct i2c_driver w83781d_driver = { 271static struct i2c_driver w83781d_driver = {
272 .owner = THIS_MODULE, 272 .driver = {
273 .name = "w83781d", 273 .name = "w83781d",
274 },
274 .id = I2C_DRIVERID_W83781D, 275 .id = I2C_DRIVERID_W83781D,
275 .flags = I2C_DF_NOTIFY,
276 .attach_adapter = w83781d_attach_adapter, 276 .attach_adapter = w83781d_attach_adapter,
277 .detach_client = w83781d_detach_client, 277 .detach_client = w83781d_detach_client,
278}; 278};
279 279
280static struct i2c_driver w83781d_isa_driver = { 280static struct i2c_driver w83781d_isa_driver = {
281 .owner = THIS_MODULE, 281 .driver = {
282 .name = "w83781d-isa", 282 .name = "w83781d-isa",
283 },
283 .attach_adapter = w83781d_isa_attach_adapter, 284 .attach_adapter = w83781d_isa_attach_adapter,
284 .detach_client = w83781d_detach_client, 285 .detach_client = w83781d_detach_client,
285}; 286};
@@ -1012,7 +1013,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
1012 1013
1013 if (is_isa) 1014 if (is_isa)
1014 if (!request_region(address, W83781D_EXTENT, 1015 if (!request_region(address, W83781D_EXTENT,
1015 w83781d_isa_driver.name)) { 1016 w83781d_isa_driver.driver.name)) {
1016 dev_dbg(&adapter->dev, "Request of region " 1017 dev_dbg(&adapter->dev, "Request of region "
1017 "0x%x-0x%x for w83781d failed\n", address, 1018 "0x%x-0x%x for w83781d failed\n", address,
1018 address + W83781D_EXTENT - 1); 1019 address + W83781D_EXTENT - 1);
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 1ba072630361..b176bf0c4c7b 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -269,7 +269,6 @@ DIV_TO_REG(long val)
269struct w83792d_data { 269struct w83792d_data {
270 struct i2c_client client; 270 struct i2c_client client;
271 struct class_device *class_dev; 271 struct class_device *class_dev;
272 struct semaphore lock;
273 enum chips type; 272 enum chips type;
274 273
275 struct semaphore update_lock; 274 struct semaphore update_lock;
@@ -282,7 +281,7 @@ struct w83792d_data {
282 u8 in[9]; /* Register value */ 281 u8 in[9]; /* Register value */
283 u8 in_max[9]; /* Register value */ 282 u8 in_max[9]; /* Register value */
284 u8 in_min[9]; /* Register value */ 283 u8 in_min[9]; /* Register value */
285 u8 low_bits[2]; /* Additional resolution to voltage in0-6 */ 284 u16 low_bits; /* Additional resolution to voltage in6-0 */
286 u8 fan[7]; /* Register value */ 285 u8 fan[7]; /* Register value */
287 u8 fan_min[7]; /* Register value */ 286 u8 fan_min[7]; /* Register value */
288 u8 temp1[3]; /* current, over, thyst */ 287 u8 temp1[3]; /* current, over, thyst */
@@ -317,45 +316,17 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev);
317static void w83792d_init_client(struct i2c_client *client); 316static void w83792d_init_client(struct i2c_client *client);
318 317
319static struct i2c_driver w83792d_driver = { 318static struct i2c_driver w83792d_driver = {
320 .owner = THIS_MODULE, 319 .driver = {
321 .name = "w83792d", 320 .name = "w83792d",
322 .flags = I2C_DF_NOTIFY, 321 },
323 .attach_adapter = w83792d_attach_adapter, 322 .attach_adapter = w83792d_attach_adapter,
324 .detach_client = w83792d_detach_client, 323 .detach_client = w83792d_detach_client,
325}; 324};
326 325
327static long in_count_from_reg(int nr, struct w83792d_data *data) 326static inline long in_count_from_reg(int nr, struct w83792d_data *data)
328{ 327{
329 u16 vol_count = data->in[nr]; 328 /* in7 and in8 do not have low bits, but the formula still works */
330 u16 low_bits = 0; 329 return ((data->in[nr] << 2) | ((data->low_bits >> (2 * nr)) & 0x03));
331 vol_count = (vol_count << 2);
332 switch (nr)
333 {
334 case 0: /* vin0 */
335 low_bits = (data->low_bits[0]) & 0x03;
336 break;
337 case 1: /* vin1 */
338 low_bits = ((data->low_bits[0]) & 0x0c) >> 2;
339 break;
340 case 2: /* vin2 */
341 low_bits = ((data->low_bits[0]) & 0x30) >> 4;
342 break;
343 case 3: /* vin3 */
344 low_bits = ((data->low_bits[0]) & 0xc0) >> 6;
345 break;
346 case 4: /* vin4 */
347 low_bits = (data->low_bits[1]) & 0x03;
348 break;
349 case 5: /* vin5 */
350 low_bits = ((data->low_bits[1]) & 0x0c) >> 2;
351 break;
352 case 6: /* vin6 */
353 low_bits = ((data->low_bits[1]) & 0x30) >> 4;
354 default:
355 break;
356 }
357 vol_count = vol_count | low_bits;
358 return vol_count;
359} 330}
360 331
361/* following are the sysfs callback functions */ 332/* following are the sysfs callback functions */
@@ -1192,7 +1163,6 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1192 new_client = &data->client; 1163 new_client = &data->client;
1193 i2c_set_clientdata(new_client, data); 1164 i2c_set_clientdata(new_client, data);
1194 new_client->addr = address; 1165 new_client->addr = address;
1195 init_MUTEX(&data->lock);
1196 new_client->adapter = adapter; 1166 new_client->adapter = adapter;
1197 new_client->driver = &w83792d_driver; 1167 new_client->driver = &w83792d_driver;
1198 new_client->flags = 0; 1168 new_client->flags = 0;
@@ -1243,7 +1213,7 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1243 goto ERROR1; 1213 goto ERROR1;
1244 } 1214 }
1245 val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID); 1215 val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID);
1246 if (val1 == 0x7a && address >= 0x2c) { 1216 if (val1 == 0x7a) {
1247 kind = w83792d; 1217 kind = w83792d;
1248 } else { 1218 } else {
1249 if (kind == 0) 1219 if (kind == 0)
@@ -1416,26 +1386,17 @@ w83792d_detach_client(struct i2c_client *client)
1416 return 0; 1386 return 0;
1417} 1387}
1418 1388
1419/* The SMBus locks itself, usually, but nothing may access the Winbond between 1389/* The SMBus locks itself. The Winbond W83792D chip has a bank register,
1420 bank switches. ISA access must always be locked explicitly! 1390 but the driver only accesses registers in bank 0, so we don't have
1421 We ignore the W83792D BUSY flag at this moment - it could lead to deadlocks, 1391 to switch banks and lock access between switches. */
1422 would slow down the W83792D access and should not be necessary. 1392static int w83792d_read_value(struct i2c_client *client, u8 reg)
1423 There are some ugly typecasts here, but the good news is - they should
1424 nowhere else be necessary! */
1425static int
1426w83792d_read_value(struct i2c_client *client, u8 reg)
1427{ 1393{
1428 int res=0; 1394 return i2c_smbus_read_byte_data(client, reg);
1429 res = i2c_smbus_read_byte_data(client, reg);
1430
1431 return res;
1432} 1395}
1433 1396
1434static int 1397static int w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
1435w83792d_write_value(struct i2c_client *client, u8 reg, u8 value)
1436{ 1398{
1437 i2c_smbus_write_byte_data(client, reg, value); 1399 return i2c_smbus_write_byte_data(client, reg, value);
1438 return 0;
1439} 1400}
1440 1401
1441static void 1402static void
@@ -1492,10 +1453,10 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
1492 data->in_min[i] = w83792d_read_value(client, 1453 data->in_min[i] = w83792d_read_value(client,
1493 W83792D_REG_IN_MIN[i]); 1454 W83792D_REG_IN_MIN[i]);
1494 } 1455 }
1495 data->low_bits[0] = w83792d_read_value(client, 1456 data->low_bits = w83792d_read_value(client,
1496 W83792D_REG_LOW_BITS1); 1457 W83792D_REG_LOW_BITS1) +
1497 data->low_bits[1] = w83792d_read_value(client, 1458 (w83792d_read_value(client,
1498 W83792D_REG_LOW_BITS2); 1459 W83792D_REG_LOW_BITS2) << 8);
1499 for (i = 0; i < 7; i++) { 1460 for (i = 0; i < 7; i++) {
1500 /* Update the Fan measured value and limits */ 1461 /* Update the Fan measured value and limits */
1501 data->fan[i] = w83792d_read_value(client, 1462 data->fan[i] = w83792d_read_value(client,
@@ -1506,7 +1467,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
1506 pwm_array_tmp[i] = w83792d_read_value(client, 1467 pwm_array_tmp[i] = w83792d_read_value(client,
1507 W83792D_REG_PWM[i]); 1468 W83792D_REG_PWM[i]);
1508 data->pwm[i] = pwm_array_tmp[i] & 0x0f; 1469 data->pwm[i] = pwm_array_tmp[i] & 0x0f;
1509 data->pwm_mode[i] = (pwm_array_tmp[i] >> 7) & 0x01; 1470 data->pwm_mode[i] = pwm_array_tmp[i] >> 7;
1510 } 1471 }
1511 1472
1512 reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG); 1473 reg_tmp = w83792d_read_value(client, W83792D_REG_FAN_CFG);
@@ -1607,8 +1568,8 @@ static void w83792d_print_debug(struct w83792d_data *data, struct device *dev)
1607 dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); 1568 dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]);
1608 dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); 1569 dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]);
1609 } 1570 }
1610 dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]); 1571 dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits & 0xff);
1611 dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]); 1572 dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits >> 8);
1612 dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); 1573 dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n");
1613 for (i=0; i<7; i++) { 1574 for (i=0; i<7; i++) {
1614 dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); 1575 dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]);
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index f495b6378668..f66c0cfdeda7 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -92,10 +92,10 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev);
92 */ 92 */
93 93
94static struct i2c_driver w83l785ts_driver = { 94static struct i2c_driver w83l785ts_driver = {
95 .owner = THIS_MODULE, 95 .driver = {
96 .name = "w83l785ts", 96 .name = "w83l785ts",
97 },
97 .id = I2C_DRIVERID_W83L785TS, 98 .id = I2C_DRIVERID_W83L785TS,
98 .flags = I2C_DF_NOTIFY,
99 .attach_adapter = w83l785ts_attach_adapter, 99 .attach_adapter = w83l785ts_attach_adapter,
100 .detach_client = w83l785ts_detach_client, 100 .detach_client = w83l785ts_detach_client,
101}; 101};
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index ac3eafa8aac0..1c752ddc10e2 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -468,8 +468,7 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
468 return -1; 468 return -1;
469 } 469 }
470 470
471 if (hwpec) 471 outb_p(hwpec, SMBAUXCTL); /* enable/disable hardware PEC */
472 outb_p(1, SMBAUXCTL); /* enable hardware PEC */
473 472
474 if(block) 473 if(block)
475 ret = i801_block_transaction(data, read_write, size, hwpec); 474 ret = i801_block_transaction(data, read_write, size, hwpec);
@@ -478,9 +477,6 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr,
478 ret = i801_transaction(); 477 ret = i801_transaction();
479 } 478 }
480 479
481 if (hwpec)
482 outb_p(0, SMBAUXCTL); /* disable hardware PEC */
483
484 if(block) 480 if(block)
485 return ret; 481 return ret;
486 if(ret) 482 if(ret)
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 1a587253d716..87fae937e666 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -725,6 +725,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
725 strcpy(adap->name, "IBM IIC"); 725 strcpy(adap->name, "IBM IIC");
726 i2c_set_adapdata(adap, dev); 726 i2c_set_adapdata(adap, dev);
727 adap->id = I2C_HW_OCP; 727 adap->id = I2C_HW_OCP;
728 adap->class = I2C_CLASS_HWMON;
728 adap->algo = &iic_algo; 729 adap->algo = &iic_algo;
729 adap->client_register = NULL; 730 adap->client_register = NULL;
730 adap->client_unregister = NULL; 731 adap->client_unregister = NULL;
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 03672c9ca409..9f2ffef4d812 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -92,15 +92,13 @@ int i2c_isa_add_driver(struct i2c_driver *driver)
92 int res; 92 int res;
93 93
94 /* Add the driver to the list of i2c drivers in the driver core */ 94 /* Add the driver to the list of i2c drivers in the driver core */
95 driver->driver.name = driver->name;
96 driver->driver.owner = driver->owner;
97 driver->driver.bus = &i2c_bus_type; 95 driver->driver.bus = &i2c_bus_type;
98 driver->driver.probe = i2c_isa_device_probe; 96 driver->driver.probe = i2c_isa_device_probe;
99 driver->driver.remove = i2c_isa_device_remove; 97 driver->driver.remove = i2c_isa_device_remove;
100 res = driver_register(&driver->driver); 98 res = driver_register(&driver->driver);
101 if (res) 99 if (res)
102 return res; 100 return res;
103 dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->name); 101 dev_dbg(&isa_adapter.dev, "Driver %s registered\n", driver->driver.name);
104 102
105 /* Now look for clients */ 103 /* Now look for clients */
106 driver->attach_adapter(&isa_adapter); 104 driver->attach_adapter(&isa_adapter);
@@ -124,14 +122,14 @@ int i2c_isa_del_driver(struct i2c_driver *driver)
124 if ((res = driver->detach_client(client))) { 122 if ((res = driver->detach_client(client))) {
125 dev_err(&isa_adapter.dev, "Failed, driver " 123 dev_err(&isa_adapter.dev, "Failed, driver "
126 "%s not unregistered!\n", 124 "%s not unregistered!\n",
127 driver->name); 125 driver->driver.name);
128 return res; 126 return res;
129 } 127 }
130 } 128 }
131 129
132 /* Get the driver off the core list */ 130 /* Get the driver off the core list */
133 driver_unregister(&driver->driver); 131 driver_unregister(&driver->driver);
134 dev_dbg(&isa_adapter.dev, "Driver %s unregistered\n", driver->name); 132 dev_dbg(&isa_adapter.dev, "Driver %s unregistered\n", driver->driver.name);
135 133
136 return 0; 134 return 0;
137} 135}
@@ -176,7 +174,7 @@ static void __exit i2c_isa_exit(void)
176 list_for_each_safe(item, _n, &isa_adapter.clients) { 174 list_for_each_safe(item, _n, &isa_adapter.clients) {
177 client = list_entry(item, struct i2c_client, list); 175 client = list_entry(item, struct i2c_client, list);
178 dev_err(&isa_adapter.dev, "Driver %s still has an active " 176 dev_err(&isa_adapter.dev, "Driver %s still has an active "
179 "ISA client at 0x%x\n", client->driver->name, 177 "ISA client at 0x%x\n", client->driver->driver.name,
180 client->addr); 178 client->addr);
181 } 179 }
182 if (client != NULL) 180 if (client != NULL)
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index afd7634e5cc9..22781d84f79f 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * drivers/i2c/busses/i2c-mv64xxx.c
3 *
4 * Driver for the i2c controller on the Marvell line of host bridges for MIPS 2 * Driver for the i2c controller on the Marvell line of host bridges for MIPS
5 * and PPC (e.g, gt642[46]0, mv643[46]0, mv644[46]0). 3 * and PPC (e.g, gt642[46]0, mv643[46]0, mv644[46]0).
6 * 4 *
@@ -65,7 +63,6 @@ enum {
65 MV64XXX_I2C_STATE_WAITING_FOR_ADDR_2_ACK, 63 MV64XXX_I2C_STATE_WAITING_FOR_ADDR_2_ACK,
66 MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK, 64 MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK,
67 MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA, 65 MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA,
68 MV64XXX_I2C_STATE_ABORTING,
69}; 66};
70 67
71/* Driver actions */ 68/* Driver actions */
@@ -85,6 +82,7 @@ struct mv64xxx_i2c_data {
85 int irq; 82 int irq;
86 u32 state; 83 u32 state;
87 u32 action; 84 u32 action;
85 u32 aborting;
88 u32 cntl_bits; 86 u32 cntl_bits;
89 void __iomem *reg_base; 87 void __iomem *reg_base;
90 u32 reg_base_p; 88 u32 reg_base_p;
@@ -122,12 +120,6 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status)
122 return; 120 return;
123 } 121 }
124 122
125 if (drv_data->state == MV64XXX_I2C_STATE_ABORTING) {
126 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
127 drv_data->state = MV64XXX_I2C_STATE_IDLE;
128 return;
129 }
130
131 /* The status from the ctlr [mostly] tells us what to do next */ 123 /* The status from the ctlr [mostly] tells us what to do next */
132 switch (status) { 124 switch (status) {
133 /* Start condition interrupt */ 125 /* Start condition interrupt */
@@ -148,14 +140,16 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status)
148 /* FALLTHRU */ 140 /* FALLTHRU */
149 case MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_ACK: /* 0xd0 */ 141 case MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_ACK: /* 0xd0 */
150 case MV64XXX_I2C_STATUS_MAST_WR_ACK: /* 0x28 */ 142 case MV64XXX_I2C_STATUS_MAST_WR_ACK: /* 0x28 */
151 if (drv_data->bytes_left > 0) { 143 if ((drv_data->bytes_left == 0)
144 || (drv_data->aborting
145 && (drv_data->byte_posn != 0))) {
146 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
147 drv_data->state = MV64XXX_I2C_STATE_IDLE;
148 } else {
152 drv_data->action = MV64XXX_I2C_ACTION_SEND_DATA; 149 drv_data->action = MV64XXX_I2C_ACTION_SEND_DATA;
153 drv_data->state = 150 drv_data->state =
154 MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK; 151 MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK;
155 drv_data->bytes_left--; 152 drv_data->bytes_left--;
156 } else {
157 drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
158 drv_data->state = MV64XXX_I2C_STATE_IDLE;
159 } 153 }
160 break; 154 break;
161 155
@@ -184,7 +178,7 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status)
184 } 178 }
185 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA; 179 drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA;
186 180
187 if (drv_data->bytes_left == 1) 181 if ((drv_data->bytes_left == 1) || drv_data->aborting)
188 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_ACK; 182 drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_ACK;
189 break; 183 break;
190 184
@@ -320,6 +314,7 @@ mv64xxx_i2c_prepare_for_io(struct mv64xxx_i2c_data *drv_data,
320 drv_data->msg = msg; 314 drv_data->msg = msg;
321 drv_data->byte_posn = 0; 315 drv_data->byte_posn = 0;
322 drv_data->bytes_left = msg->len; 316 drv_data->bytes_left = msg->len;
317 drv_data->aborting = 0;
323 drv_data->rc = 0; 318 drv_data->rc = 0;
324 drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK | 319 drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK |
325 MV64XXX_I2C_REG_CONTROL_INTEN | MV64XXX_I2C_REG_CONTROL_TWSIEN; 320 MV64XXX_I2C_REG_CONTROL_INTEN | MV64XXX_I2C_REG_CONTROL_TWSIEN;
@@ -359,17 +354,19 @@ mv64xxx_i2c_wait_for_completion(struct mv64xxx_i2c_data *drv_data)
359 } 354 }
360 355
361 if (abort && drv_data->block) { 356 if (abort && drv_data->block) {
362 drv_data->state = MV64XXX_I2C_STATE_ABORTING; 357 drv_data->aborting = 1;
363 spin_unlock_irqrestore(&drv_data->lock, flags); 358 spin_unlock_irqrestore(&drv_data->lock, flags);
364 359
365 time_left = wait_event_timeout(drv_data->waitq, 360 time_left = wait_event_timeout(drv_data->waitq,
366 !drv_data->block, 361 !drv_data->block,
367 msecs_to_jiffies(drv_data->adapter.timeout)); 362 msecs_to_jiffies(drv_data->adapter.timeout));
368 363
369 if (time_left <= 0) { 364 if ((time_left <= 0) && drv_data->block) {
370 drv_data->state = MV64XXX_I2C_STATE_IDLE; 365 drv_data->state = MV64XXX_I2C_STATE_IDLE;
371 dev_err(&drv_data->adapter.dev, 366 dev_err(&drv_data->adapter.dev,
372 "mv64xxx: I2C bus locked\n"); 367 "mv64xxx: I2C bus locked, block: %d, "
368 "time_left: %d\n", drv_data->block,
369 (int)time_left);
373 } 370 }
374 } else 371 } else
375 spin_unlock_irqrestore(&drv_data->lock, flags); 372 spin_unlock_irqrestore(&drv_data->lock, flags);
@@ -510,7 +507,7 @@ mv64xxx_i2c_probe(struct platform_device *pd)
510 goto exit_kfree; 507 goto exit_kfree;
511 } 508 }
512 509
513 strncpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter", 510 strlcpy(drv_data->adapter.name, MV64XXX_I2C_CTLR_NAME " adapter",
514 I2C_NAME_SIZE); 511 I2C_NAME_SIZE);
515 512
516 init_waitqueue_head(&drv_data->waitq); 513 init_waitqueue_head(&drv_data->waitq);
@@ -529,14 +526,15 @@ mv64xxx_i2c_probe(struct platform_device *pd)
529 i2c_set_adapdata(&drv_data->adapter, drv_data); 526 i2c_set_adapdata(&drv_data->adapter, drv_data);
530 527
531 if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0, 528 if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0,
532 MV64XXX_I2C_CTLR_NAME, drv_data)) { 529 MV64XXX_I2C_CTLR_NAME, drv_data)) {
533 530 dev_err(&drv_data->adapter.dev,
534 dev_err(dev, "mv64xxx: Can't register intr handler " 531 "mv64xxx: Can't register intr handler irq: %d\n",
535 "irq: %d\n", drv_data->irq); 532 drv_data->irq);
536 rc = -EINVAL; 533 rc = -EINVAL;
537 goto exit_unmap_regs; 534 goto exit_unmap_regs;
538 } else if ((rc = i2c_add_adapter(&drv_data->adapter)) != 0) { 535 } else if ((rc = i2c_add_adapter(&drv_data->adapter)) != 0) {
539 dev_err(dev, "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc); 536 dev_err(&drv_data->adapter.dev,
537 "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc);
540 goto exit_free_irq; 538 goto exit_free_irq;
541 } 539 }
542 540
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index 4d18e6e5f159..2d80eb26f688 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -30,6 +30,7 @@
30 nForce3 Pro150 MCP 00D4 30 nForce3 Pro150 MCP 00D4
31 nForce3 250Gb MCP 00E4 31 nForce3 250Gb MCP 00E4
32 nForce4 MCP 0052 32 nForce4 MCP 0052
33 nForce4 MCP-04 0034
33 34
34 This driver supports the 2 SMBuses that are included in the MCP of the 35 This driver supports the 2 SMBuses that are included in the MCP of the
35 nForce2/3/4 chipsets. 36 nForce2/3/4 chipsets.
@@ -257,6 +258,7 @@ static struct pci_device_id nforce2_ids[] = {
257 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS) }, 258 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_SMBUS) },
258 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS) }, 259 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SMBUS) },
259 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS) }, 260 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE4_SMBUS) },
261 { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_SMBUS) },
260 { 0 } 262 { 0 }
261}; 263};
262 264
diff --git a/drivers/i2c/busses/i2c-parport.h b/drivers/i2c/busses/i2c-parport.h
index f63a53779281..d702e5e0388d 100644
--- a/drivers/i2c/busses/i2c-parport.h
+++ b/drivers/i2c/busses/i2c-parport.h
@@ -80,6 +80,14 @@ static struct adapter_parm adapter_parm[] = {
80 .setscl = { 0x01, DATA, 1 }, 80 .setscl = { 0x01, DATA, 1 },
81 .getsda = { 0x10, STAT, 1 }, 81 .getsda = { 0x10, STAT, 1 },
82 }, 82 },
83 /* type 6: Barco LPT->DVI (K5800236) adapter */
84 {
85 .setsda = { 0x02, DATA, 1 },
86 .setscl = { 0x01, DATA, 1 },
87 .getsda = { 0x20, STAT, 0 },
88 .getscl = { 0x40, STAT, 0 },
89 .init = { 0xfc, DATA, 0 },
90 },
83}; 91};
84 92
85static int type; 93static int type;
@@ -91,4 +99,6 @@ MODULE_PARM_DESC(type,
91 " 2 = Velleman K8000 adapter\n" 99 " 2 = Velleman K8000 adapter\n"
92 " 3 = ELV adapter\n" 100 " 3 = ELV adapter\n"
93 " 4 = ADM1032 evaluation board\n" 101 " 4 = ADM1032 evaluation board\n"
94 " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n"); 102 " 5 = ADM1025, ADM1030 and ADM1031 evaluation boards\n"
103 " 6 = Barco LPT->DVI (K5800236) adapter\n"
104);
diff --git a/drivers/i2c/chips/ds1337.c b/drivers/i2c/chips/ds1337.c
index 02682fb794c8..93d483b8b770 100644
--- a/drivers/i2c/chips/ds1337.c
+++ b/drivers/i2c/chips/ds1337.c
@@ -52,9 +52,9 @@ static int ds1337_command(struct i2c_client *client, unsigned int cmd,
52 * Driver data (common to all clients) 52 * Driver data (common to all clients)
53 */ 53 */
54static struct i2c_driver ds1337_driver = { 54static struct i2c_driver ds1337_driver = {
55 .owner = THIS_MODULE, 55 .driver = {
56 .name = "ds1337", 56 .name = "ds1337",
57 .flags = I2C_DF_NOTIFY, 57 },
58 .attach_adapter = ds1337_attach_adapter, 58 .attach_adapter = ds1337_attach_adapter,
59 .detach_client = ds1337_detach_client, 59 .detach_client = ds1337_detach_client,
60 .command = ds1337_command, 60 .command = ds1337_command,
@@ -337,13 +337,38 @@ exit:
337 337
338static void ds1337_init_client(struct i2c_client *client) 338static void ds1337_init_client(struct i2c_client *client)
339{ 339{
340 s32 val; 340 u8 status, control;
341 341
342 /* Ensure that device is set in 24-hour mode */ 342 /* On some boards, the RTC isn't configured by boot firmware.
343 val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR); 343 * Handle that case by starting/configuring the RTC now.
344 if ((val >= 0) && (val & (1 << 6))) 344 */
345 i2c_smbus_write_byte_data(client, DS1337_REG_HOUR, 345 status = i2c_smbus_read_byte_data(client, DS1337_REG_STATUS);
346 val & 0x3f); 346 control = i2c_smbus_read_byte_data(client, DS1337_REG_CONTROL);
347
348 if ((status & 0x80) || (control & 0x80)) {
349 /* RTC not running */
350 u8 buf[16];
351 struct i2c_msg msg[1];
352
353 dev_dbg(&client->dev, "%s: RTC not running!\n", __FUNCTION__);
354
355 /* Initialize all, including STATUS and CONTROL to zero */
356 memset(buf, 0, sizeof(buf));
357 msg[0].addr = client->addr;
358 msg[0].flags = 0;
359 msg[0].len = sizeof(buf);
360 msg[0].buf = &buf[0];
361
362 i2c_transfer(client->adapter, msg, 1);
363 } else {
364 /* Running: ensure that device is set in 24-hour mode */
365 s32 val;
366
367 val = i2c_smbus_read_byte_data(client, DS1337_REG_HOUR);
368 if ((val >= 0) && (val & (1 << 6)))
369 i2c_smbus_write_byte_data(client, DS1337_REG_HOUR,
370 val & 0x3f);
371 }
347} 372}
348 373
349static int ds1337_detach_client(struct i2c_client *client) 374static int ds1337_detach_client(struct i2c_client *client)
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index da488b735abf..0710b9da9d54 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -232,10 +232,10 @@ static int ds1374_detach(struct i2c_client *client)
232} 232}
233 233
234static struct i2c_driver ds1374_driver = { 234static struct i2c_driver ds1374_driver = {
235 .owner = THIS_MODULE, 235 .driver = {
236 .name = DS1374_DRV_NAME, 236 .name = DS1374_DRV_NAME,
237 },
237 .id = I2C_DRIVERID_DS1374, 238 .id = I2C_DRIVERID_DS1374,
238 .flags = I2C_DF_NOTIFY,
239 .attach_adapter = ds1374_attach, 239 .attach_adapter = ds1374_attach,
240 .detach_client = ds1374_detach, 240 .detach_client = ds1374_detach,
241}; 241};
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index 4baf573fa04f..41116b7947f6 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -68,10 +68,10 @@ static int eeprom_detach_client(struct i2c_client *client);
68 68
69/* This is the driver that will be inserted */ 69/* This is the driver that will be inserted */
70static struct i2c_driver eeprom_driver = { 70static struct i2c_driver eeprom_driver = {
71 .owner = THIS_MODULE, 71 .driver = {
72 .name = "eeprom", 72 .name = "eeprom",
73 },
73 .id = I2C_DRIVERID_EEPROM, 74 .id = I2C_DRIVERID_EEPROM,
74 .flags = I2C_DF_NOTIFY,
75 .attach_adapter = eeprom_attach_adapter, 75 .attach_adapter = eeprom_attach_adapter,
76 .detach_client = eeprom_detach_client, 76 .detach_client = eeprom_detach_client,
77}; 77};
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index d2a100d77839..1251c7fc18d5 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -1632,11 +1632,11 @@ static int isp1301_scan_bus(struct i2c_adapter *bus)
1632} 1632}
1633 1633
1634static struct i2c_driver isp1301_driver = { 1634static struct i2c_driver isp1301_driver = {
1635 .owner = THIS_MODULE, 1635 .driver = {
1636 .name = "isp1301_omap", 1636 .name = "isp1301_omap",
1637 },
1637 .id = 1301, /* FIXME "official", i2c-ids.h */ 1638 .id = 1301, /* FIXME "official", i2c-ids.h */
1638 .class = I2C_CLASS_HWMON, 1639 .class = I2C_CLASS_HWMON,
1639 .flags = I2C_DF_NOTIFY,
1640 .attach_adapter = isp1301_scan_bus, 1640 .attach_adapter = isp1301_scan_bus,
1641 .detach_client = isp1301_detach_client, 1641 .detach_client = isp1301_detach_client,
1642}; 1642};
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 3df309ae44a6..2dc3d48375fc 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -211,10 +211,10 @@ m41t00_detach(struct i2c_client *client)
211} 211}
212 212
213static struct i2c_driver m41t00_driver = { 213static struct i2c_driver m41t00_driver = {
214 .owner = THIS_MODULE, 214 .driver = {
215 .name = M41T00_DRV_NAME, 215 .name = M41T00_DRV_NAME,
216 },
216 .id = I2C_DRIVERID_STM41T00, 217 .id = I2C_DRIVERID_STM41T00,
217 .flags = I2C_DF_NOTIFY,
218 .attach_adapter = m41t00_attach, 218 .attach_adapter = m41t00_attach,
219 .detach_client = m41t00_detach, 219 .detach_client = m41t00_detach,
220}; 220};
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index b376a006883c..6d3ff584155e 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -67,9 +67,9 @@ static int max6875_detach_client(struct i2c_client *client);
67 67
68/* This is the driver that will be inserted */ 68/* This is the driver that will be inserted */
69static struct i2c_driver max6875_driver = { 69static struct i2c_driver max6875_driver = {
70 .owner = THIS_MODULE, 70 .driver = {
71 .name = "max6875", 71 .name = "max6875",
72 .flags = I2C_DF_NOTIFY, 72 },
73 .attach_adapter = max6875_attach_adapter, 73 .attach_adapter = max6875_attach_adapter,
74 .detach_client = max6875_detach_client, 74 .detach_client = max6875_detach_client,
75}; 75};
diff --git a/drivers/i2c/chips/pca9539.c b/drivers/i2c/chips/pca9539.c
index 59a930346229..54b6e6a4beed 100644
--- a/drivers/i2c/chips/pca9539.c
+++ b/drivers/i2c/chips/pca9539.c
@@ -38,9 +38,9 @@ static int pca9539_detach_client(struct i2c_client *client);
38 38
39/* This is the driver that will be inserted */ 39/* This is the driver that will be inserted */
40static struct i2c_driver pca9539_driver = { 40static struct i2c_driver pca9539_driver = {
41 .owner = THIS_MODULE, 41 .driver = {
42 .name = "pca9539", 42 .name = "pca9539",
43 .flags = I2C_DF_NOTIFY, 43 },
44 .attach_adapter = pca9539_attach_adapter, 44 .attach_adapter = pca9539_attach_adapter,
45 .detach_client = pca9539_detach_client, 45 .detach_client = pca9539_detach_client,
46}; 46};
diff --git a/drivers/i2c/chips/pcf8574.c b/drivers/i2c/chips/pcf8574.c
index c323c2de236c..c3e6449c4481 100644
--- a/drivers/i2c/chips/pcf8574.c
+++ b/drivers/i2c/chips/pcf8574.c
@@ -65,10 +65,10 @@ static void pcf8574_init_client(struct i2c_client *client);
65 65
66/* This is the driver that will be inserted */ 66/* This is the driver that will be inserted */
67static struct i2c_driver pcf8574_driver = { 67static struct i2c_driver pcf8574_driver = {
68 .owner = THIS_MODULE, 68 .driver = {
69 .name = "pcf8574", 69 .name = "pcf8574",
70 },
70 .id = I2C_DRIVERID_PCF8574, 71 .id = I2C_DRIVERID_PCF8574,
71 .flags = I2C_DF_NOTIFY,
72 .attach_adapter = pcf8574_attach_adapter, 72 .attach_adapter = pcf8574_attach_adapter,
73 .detach_client = pcf8574_detach_client, 73 .detach_client = pcf8574_detach_client,
74}; 74};
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index ce420a67560b..36cff09c678d 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -88,10 +88,10 @@ static int pcf8591_read_channel(struct device *dev, int channel);
88 88
89/* This is the driver that will be inserted */ 89/* This is the driver that will be inserted */
90static struct i2c_driver pcf8591_driver = { 90static struct i2c_driver pcf8591_driver = {
91 .owner = THIS_MODULE, 91 .driver = {
92 .name = "pcf8591", 92 .name = "pcf8591",
93 },
93 .id = I2C_DRIVERID_PCF8591, 94 .id = I2C_DRIVERID_PCF8591,
94 .flags = I2C_DF_NOTIFY,
95 .attach_adapter = pcf8591_attach_adapter, 95 .attach_adapter = pcf8591_attach_adapter,
96 .detach_client = pcf8591_detach_client, 96 .detach_client = pcf8591_detach_client,
97}; 97};
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index 916cdc1af23c..ceaa6b0bdfd6 100644
--- a/drivers/i2c/chips/rtc8564.c
+++ b/drivers/i2c/chips/rtc8564.c
@@ -14,6 +14,7 @@
14 */ 14 */
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/bcd.h>
17#include <linux/i2c.h> 18#include <linux/i2c.h>
18#include <linux/slab.h> 19#include <linux/slab.h>
19#include <linux/string.h> 20#include <linux/string.h>
@@ -52,9 +53,6 @@ static inline u8 _rtc8564_ctrl2(struct i2c_client *client)
52#define CTRL1(c) _rtc8564_ctrl1(c) 53#define CTRL1(c) _rtc8564_ctrl1(c)
53#define CTRL2(c) _rtc8564_ctrl2(c) 54#define CTRL2(c) _rtc8564_ctrl2(c)
54 55
55#define BCD_TO_BIN(val) (((val)&15) + ((val)>>4)*10)
56#define BIN_TO_BCD(val) ((((val)/10)<<4) + (val)%10)
57
58static int debug;; 56static int debug;;
59module_param(debug, int, S_IRUGO | S_IWUSR); 57module_param(debug, int, S_IRUGO | S_IWUSR);
60 58
@@ -157,7 +155,6 @@ static int rtc8564_attach(struct i2c_adapter *adap, int addr, int kind)
157 155
158 strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE); 156 strlcpy(new_client->name, "RTC8564", I2C_NAME_SIZE);
159 i2c_set_clientdata(new_client, d); 157 i2c_set_clientdata(new_client, d);
160 new_client->flags = I2C_CLIENT_ALLOW_USE;
161 new_client->addr = addr; 158 new_client->addr = addr;
162 new_client->adapter = adap; 159 new_client->adapter = adap;
163 new_client->driver = &rtc8564_driver; 160 new_client->driver = &rtc8564_driver;
@@ -224,16 +221,16 @@ static int rtc8564_get_datetime(struct i2c_client *client, struct rtc_tm *dt)
224 return ret; 221 return ret;
225 222
226 /* century stored in minute alarm reg */ 223 /* century stored in minute alarm reg */
227 dt->year = BCD_TO_BIN(buf[RTC8564_REG_YEAR]); 224 dt->year = BCD2BIN(buf[RTC8564_REG_YEAR]);
228 dt->year += 100 * BCD_TO_BIN(buf[RTC8564_REG_AL_MIN] & 0x3f); 225 dt->year += 100 * BCD2BIN(buf[RTC8564_REG_AL_MIN] & 0x3f);
229 dt->mday = BCD_TO_BIN(buf[RTC8564_REG_DAY] & 0x3f); 226 dt->mday = BCD2BIN(buf[RTC8564_REG_DAY] & 0x3f);
230 dt->wday = BCD_TO_BIN(buf[RTC8564_REG_WDAY] & 7); 227 dt->wday = BCD2BIN(buf[RTC8564_REG_WDAY] & 7);
231 dt->mon = BCD_TO_BIN(buf[RTC8564_REG_MON_CENT] & 0x1f); 228 dt->mon = BCD2BIN(buf[RTC8564_REG_MON_CENT] & 0x1f);
232 229
233 dt->secs = BCD_TO_BIN(buf[RTC8564_REG_SEC] & 0x7f); 230 dt->secs = BCD2BIN(buf[RTC8564_REG_SEC] & 0x7f);
234 dt->vl = (buf[RTC8564_REG_SEC] & 0x80) == 0x80; 231 dt->vl = (buf[RTC8564_REG_SEC] & 0x80) == 0x80;
235 dt->mins = BCD_TO_BIN(buf[RTC8564_REG_MIN] & 0x7f); 232 dt->mins = BCD2BIN(buf[RTC8564_REG_MIN] & 0x7f);
236 dt->hours = BCD_TO_BIN(buf[RTC8564_REG_HR] & 0x3f); 233 dt->hours = BCD2BIN(buf[RTC8564_REG_HR] & 0x3f);
237 234
238 _DBGRTCTM(2, *dt); 235 _DBGRTCTM(2, *dt);
239 236
@@ -255,18 +252,18 @@ rtc8564_set_datetime(struct i2c_client *client, struct rtc_tm *dt, int datetoo)
255 252
256 buf[RTC8564_REG_CTRL1] = CTRL1(client) | RTC8564_CTRL1_STOP; 253 buf[RTC8564_REG_CTRL1] = CTRL1(client) | RTC8564_CTRL1_STOP;
257 buf[RTC8564_REG_CTRL2] = CTRL2(client); 254 buf[RTC8564_REG_CTRL2] = CTRL2(client);
258 buf[RTC8564_REG_SEC] = BIN_TO_BCD(dt->secs); 255 buf[RTC8564_REG_SEC] = BIN2BCD(dt->secs);
259 buf[RTC8564_REG_MIN] = BIN_TO_BCD(dt->mins); 256 buf[RTC8564_REG_MIN] = BIN2BCD(dt->mins);
260 buf[RTC8564_REG_HR] = BIN_TO_BCD(dt->hours); 257 buf[RTC8564_REG_HR] = BIN2BCD(dt->hours);
261 258
262 if (datetoo) { 259 if (datetoo) {
263 len += 5; 260 len += 5;
264 buf[RTC8564_REG_DAY] = BIN_TO_BCD(dt->mday); 261 buf[RTC8564_REG_DAY] = BIN2BCD(dt->mday);
265 buf[RTC8564_REG_WDAY] = BIN_TO_BCD(dt->wday); 262 buf[RTC8564_REG_WDAY] = BIN2BCD(dt->wday);
266 buf[RTC8564_REG_MON_CENT] = BIN_TO_BCD(dt->mon) & 0x1f; 263 buf[RTC8564_REG_MON_CENT] = BIN2BCD(dt->mon) & 0x1f;
267 /* century stored in minute alarm reg */ 264 /* century stored in minute alarm reg */
268 buf[RTC8564_REG_YEAR] = BIN_TO_BCD(dt->year % 100); 265 buf[RTC8564_REG_YEAR] = BIN2BCD(dt->year % 100);
269 buf[RTC8564_REG_AL_MIN] = BIN_TO_BCD(dt->year / 100); 266 buf[RTC8564_REG_AL_MIN] = BIN2BCD(dt->year / 100);
270 } 267 }
271 268
272 ret = rtc8564_write(client, 0, buf, len); 269 ret = rtc8564_write(client, 0, buf, len);
@@ -361,10 +358,10 @@ rtc8564_command(struct i2c_client *client, unsigned int cmd, void *arg)
361} 358}
362 359
363static struct i2c_driver rtc8564_driver = { 360static struct i2c_driver rtc8564_driver = {
364 .owner = THIS_MODULE, 361 .driver = {
365 .name = "RTC8564", 362 .name = "RTC8564",
363 },
366 .id = I2C_DRIVERID_RTC8564, 364 .id = I2C_DRIVERID_RTC8564,
367 .flags = I2C_DF_NOTIFY,
368 .attach_adapter = rtc8564_probe, 365 .attach_adapter = rtc8564_probe,
369 .detach_client = rtc8564_detach, 366 .detach_client = rtc8564_detach,
370 .command = rtc8564_command 367 .command = rtc8564_command
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 280dd7a45db6..e70b3db69edd 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -637,9 +637,9 @@ static int __init tps65010_scan_bus(struct i2c_adapter *bus)
637} 637}
638 638
639static struct i2c_driver tps65010_driver = { 639static struct i2c_driver tps65010_driver = {
640 .owner = THIS_MODULE, 640 .driver = {
641 .name = "tps65010", 641 .name = "tps65010",
642 .flags = I2C_DF_NOTIFY, 642 },
643 .attach_adapter = tps65010_scan_bus, 643 .attach_adapter = tps65010_scan_bus,
644 .detach_client = __exit_p(tps65010_detach_client), 644 .detach_client = __exit_p(tps65010_detach_client),
645}; 645};
diff --git a/drivers/i2c/chips/x1205.c b/drivers/i2c/chips/x1205.c
index 7da366cdc18c..245fffa92dbd 100644
--- a/drivers/i2c/chips/x1205.c
+++ b/drivers/i2c/chips/x1205.c
@@ -105,9 +105,9 @@ static int x1205_command(struct i2c_client *client, unsigned int cmd,
105 void *arg); 105 void *arg);
106 106
107static struct i2c_driver x1205_driver = { 107static struct i2c_driver x1205_driver = {
108 .owner = THIS_MODULE, 108 .driver = {
109 .name = "x1205", 109 .name = "x1205",
110 .flags = I2C_DF_NOTIFY, 110 },
111 .attach_adapter = &x1205_attach, 111 .attach_adapter = &x1205_attach,
112 .detach_client = &x1205_detach, 112 .detach_client = &x1205_detach,
113}; 113};
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 82ea1b7ec914..52b77477df57 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -197,7 +197,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
197 /* inform drivers of new adapters */ 197 /* inform drivers of new adapters */
198 list_for_each(item,&drivers) { 198 list_for_each(item,&drivers) {
199 driver = list_entry(item, struct i2c_driver, list); 199 driver = list_entry(item, struct i2c_driver, list);
200 if (driver->flags & I2C_DF_NOTIFY) 200 if (driver->attach_adapter)
201 /* We ignore the return code; if it fails, too bad */ 201 /* We ignore the return code; if it fails, too bad */
202 driver->attach_adapter(adap); 202 driver->attach_adapter(adap);
203 } 203 }
@@ -235,7 +235,8 @@ int i2c_del_adapter(struct i2c_adapter *adap)
235 if (driver->detach_adapter) 235 if (driver->detach_adapter)
236 if ((res = driver->detach_adapter(adap))) { 236 if ((res = driver->detach_adapter(adap))) {
237 dev_err(&adap->dev, "detach_adapter failed " 237 dev_err(&adap->dev, "detach_adapter failed "
238 "for driver [%s]\n", driver->name); 238 "for driver [%s]\n",
239 driver->driver.name);
239 goto out_unlock; 240 goto out_unlock;
240 } 241 }
241 } 242 }
@@ -245,10 +246,6 @@ int i2c_del_adapter(struct i2c_adapter *adap)
245 list_for_each_safe(item, _n, &adap->clients) { 246 list_for_each_safe(item, _n, &adap->clients) {
246 client = list_entry(item, struct i2c_client, list); 247 client = list_entry(item, struct i2c_client, list);
247 248
248 /* detaching devices is unconditional of the set notify
249 * flag, as _all_ clients that reside on the adapter
250 * must be deleted, as this would cause invalid states.
251 */
252 if ((res=client->driver->detach_client(client))) { 249 if ((res=client->driver->detach_client(client))) {
253 dev_err(&adap->dev, "detach_client failed for client " 250 dev_err(&adap->dev, "detach_client failed for client "
254 "[%s] at address 0x%02x\n", client->name, 251 "[%s] at address 0x%02x\n", client->name,
@@ -286,7 +283,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
286 * chips. 283 * chips.
287 */ 284 */
288 285
289int i2c_add_driver(struct i2c_driver *driver) 286int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
290{ 287{
291 struct list_head *item; 288 struct list_head *item;
292 struct i2c_adapter *adapter; 289 struct i2c_adapter *adapter;
@@ -295,8 +292,7 @@ int i2c_add_driver(struct i2c_driver *driver)
295 down(&core_lists); 292 down(&core_lists);
296 293
297 /* add the driver to the list of i2c drivers in the driver core */ 294 /* add the driver to the list of i2c drivers in the driver core */
298 driver->driver.owner = driver->owner; 295 driver->driver.owner = owner;
299 driver->driver.name = driver->name;
300 driver->driver.bus = &i2c_bus_type; 296 driver->driver.bus = &i2c_bus_type;
301 driver->driver.probe = i2c_device_probe; 297 driver->driver.probe = i2c_device_probe;
302 driver->driver.remove = i2c_device_remove; 298 driver->driver.remove = i2c_device_remove;
@@ -306,10 +302,10 @@ int i2c_add_driver(struct i2c_driver *driver)
306 goto out_unlock; 302 goto out_unlock;
307 303
308 list_add_tail(&driver->list,&drivers); 304 list_add_tail(&driver->list,&drivers);
309 pr_debug("i2c-core: driver [%s] registered\n", driver->name); 305 pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
310 306
311 /* now look for instances of driver on our adapters */ 307 /* now look for instances of driver on our adapters */
312 if (driver->flags & I2C_DF_NOTIFY) { 308 if (driver->attach_adapter) {
313 list_for_each(item,&adapters) { 309 list_for_each(item,&adapters) {
314 adapter = list_entry(item, struct i2c_adapter, list); 310 adapter = list_entry(item, struct i2c_adapter, list);
315 driver->attach_adapter(adapter); 311 driver->attach_adapter(adapter);
@@ -320,6 +316,7 @@ int i2c_add_driver(struct i2c_driver *driver)
320 up(&core_lists); 316 up(&core_lists);
321 return res; 317 return res;
322} 318}
319EXPORT_SYMBOL(i2c_register_driver);
323 320
324int i2c_del_driver(struct i2c_driver *driver) 321int i2c_del_driver(struct i2c_driver *driver)
325{ 322{
@@ -334,17 +331,14 @@ int i2c_del_driver(struct i2c_driver *driver)
334 /* Have a look at each adapter, if clients of this driver are still 331 /* Have a look at each adapter, if clients of this driver are still
335 * attached. If so, detach them to be able to kill the driver 332 * attached. If so, detach them to be able to kill the driver
336 * afterwards. 333 * afterwards.
337 *
338 * Removing clients does not depend on the notify flag, else
339 * invalid operation might (will!) result, when using stale client
340 * pointers.
341 */ 334 */
342 list_for_each(item1,&adapters) { 335 list_for_each(item1,&adapters) {
343 adap = list_entry(item1, struct i2c_adapter, list); 336 adap = list_entry(item1, struct i2c_adapter, list);
344 if (driver->detach_adapter) { 337 if (driver->detach_adapter) {
345 if ((res = driver->detach_adapter(adap))) { 338 if ((res = driver->detach_adapter(adap))) {
346 dev_err(&adap->dev, "detach_adapter failed " 339 dev_err(&adap->dev, "detach_adapter failed "
347 "for driver [%s]\n", driver->name); 340 "for driver [%s]\n",
341 driver->driver.name);
348 goto out_unlock; 342 goto out_unlock;
349 } 343 }
350 } else { 344 } else {
@@ -368,7 +362,7 @@ int i2c_del_driver(struct i2c_driver *driver)
368 362
369 driver_unregister(&driver->driver); 363 driver_unregister(&driver->driver);
370 list_del(&driver->list); 364 list_del(&driver->list);
371 pr_debug("i2c-core: driver [%s] unregistered\n", driver->name); 365 pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
372 366
373 out_unlock: 367 out_unlock:
374 up(&core_lists); 368 up(&core_lists);
@@ -419,8 +413,7 @@ int i2c_attach_client(struct i2c_client *client)
419 } 413 }
420 } 414 }
421 415
422 if (client->flags & I2C_CLIENT_ALLOW_USE) 416 client->usage_count = 0;
423 client->usage_count = 0;
424 417
425 client->dev.parent = &client->adapter->dev; 418 client->dev.parent = &client->adapter->dev;
426 client->dev.driver = &client->driver->driver; 419 client->dev.driver = &client->driver->driver;
@@ -443,8 +436,7 @@ int i2c_detach_client(struct i2c_client *client)
443 struct i2c_adapter *adapter = client->adapter; 436 struct i2c_adapter *adapter = client->adapter;
444 int res = 0; 437 int res = 0;
445 438
446 if ((client->flags & I2C_CLIENT_ALLOW_USE) 439 if (client->usage_count > 0) {
447 && (client->usage_count > 0)) {
448 dev_warn(&client->dev, "Client [%s] still busy, " 440 dev_warn(&client->dev, "Client [%s] still busy, "
449 "can't detach\n", client->name); 441 "can't detach\n", client->name);
450 return -EBUSY; 442 return -EBUSY;
@@ -475,10 +467,10 @@ int i2c_detach_client(struct i2c_client *client)
475static int i2c_inc_use_client(struct i2c_client *client) 467static int i2c_inc_use_client(struct i2c_client *client)
476{ 468{
477 469
478 if (!try_module_get(client->driver->owner)) 470 if (!try_module_get(client->driver->driver.owner))
479 return -ENODEV; 471 return -ENODEV;
480 if (!try_module_get(client->adapter->owner)) { 472 if (!try_module_get(client->adapter->owner)) {
481 module_put(client->driver->owner); 473 module_put(client->driver->driver.owner);
482 return -ENODEV; 474 return -ENODEV;
483 } 475 }
484 476
@@ -487,7 +479,7 @@ static int i2c_inc_use_client(struct i2c_client *client)
487 479
488static void i2c_dec_use_client(struct i2c_client *client) 480static void i2c_dec_use_client(struct i2c_client *client)
489{ 481{
490 module_put(client->driver->owner); 482 module_put(client->driver->driver.owner);
491 module_put(client->adapter->owner); 483 module_put(client->adapter->owner);
492} 484}
493 485
@@ -499,33 +491,20 @@ int i2c_use_client(struct i2c_client *client)
499 if (ret) 491 if (ret)
500 return ret; 492 return ret;
501 493
502 if (client->flags & I2C_CLIENT_ALLOW_USE) { 494 client->usage_count++;
503 if (client->flags & I2C_CLIENT_ALLOW_MULTIPLE_USE)
504 client->usage_count++;
505 else if (client->usage_count > 0)
506 goto busy;
507 else
508 client->usage_count++;
509 }
510 495
511 return 0; 496 return 0;
512 busy:
513 i2c_dec_use_client(client);
514 return -EBUSY;
515} 497}
516 498
517int i2c_release_client(struct i2c_client *client) 499int i2c_release_client(struct i2c_client *client)
518{ 500{
519 if(client->flags & I2C_CLIENT_ALLOW_USE) { 501 if (!client->usage_count) {
520 if(client->usage_count>0) 502 pr_debug("i2c-core: %s used one too many times\n",
521 client->usage_count--; 503 __FUNCTION__);
522 else { 504 return -EPERM;
523 pr_debug("i2c-core: %s used one too many times\n",
524 __FUNCTION__);
525 return -EPERM;
526 }
527 } 505 }
528 506
507 client->usage_count--;
529 i2c_dec_use_client(client); 508 i2c_dec_use_client(client);
530 509
531 return 0; 510 return 0;
@@ -539,14 +518,14 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg)
539 down(&adap->clist_lock); 518 down(&adap->clist_lock);
540 list_for_each(item,&adap->clients) { 519 list_for_each(item,&adap->clients) {
541 client = list_entry(item, struct i2c_client, list); 520 client = list_entry(item, struct i2c_client, list);
542 if (!try_module_get(client->driver->owner)) 521 if (!try_module_get(client->driver->driver.owner))
543 continue; 522 continue;
544 if (NULL != client->driver->command) { 523 if (NULL != client->driver->command) {
545 up(&adap->clist_lock); 524 up(&adap->clist_lock);
546 client->driver->command(client,cmd,arg); 525 client->driver->command(client,cmd,arg);
547 down(&adap->clist_lock); 526 down(&adap->clist_lock);
548 } 527 }
549 module_put(client->driver->owner); 528 module_put(client->driver->driver.owner);
550 } 529 }
551 up(&adap->clist_lock); 530 up(&adap->clist_lock);
552} 531}
@@ -1147,7 +1126,6 @@ EXPORT_SYMBOL_GPL(i2c_bus_type);
1147 1126
1148EXPORT_SYMBOL(i2c_add_adapter); 1127EXPORT_SYMBOL(i2c_add_adapter);
1149EXPORT_SYMBOL(i2c_del_adapter); 1128EXPORT_SYMBOL(i2c_del_adapter);
1150EXPORT_SYMBOL(i2c_add_driver);
1151EXPORT_SYMBOL(i2c_del_driver); 1129EXPORT_SYMBOL(i2c_del_driver);
1152EXPORT_SYMBOL(i2c_attach_client); 1130EXPORT_SYMBOL(i2c_attach_client);
1153EXPORT_SYMBOL(i2c_detach_client); 1131EXPORT_SYMBOL(i2c_detach_client);
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 8af0bd1424d2..ed7eed388bae 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -42,8 +42,7 @@ static struct i2c_client i2cdev_client_template;
42struct i2c_dev { 42struct i2c_dev {
43 int minor; 43 int minor;
44 struct i2c_adapter *adap; 44 struct i2c_adapter *adap;
45 struct class_device class_dev; 45 struct class_device *class_dev;
46 struct completion released; /* FIXME, we need a class_device_unregister() */
47}; 46};
48#define to_i2c_dev(d) container_of(d, struct i2c_dev, class_dev) 47#define to_i2c_dev(d) container_of(d, struct i2c_dev, class_dev)
49 48
@@ -105,7 +104,10 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev)
105 104
106static ssize_t show_adapter_name(struct class_device *class_dev, char *buf) 105static ssize_t show_adapter_name(struct class_device *class_dev, char *buf)
107{ 106{
108 struct i2c_dev *i2c_dev = to_i2c_dev(class_dev); 107 struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(class_dev->devt));
108
109 if (!i2c_dev)
110 return -ENODEV;
109 return sprintf(buf, "%s\n", i2c_dev->adap->name); 111 return sprintf(buf, "%s\n", i2c_dev->adap->name);
110} 112}
111static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); 113static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
@@ -408,21 +410,12 @@ static struct file_operations i2cdev_fops = {
408 .release = i2cdev_release, 410 .release = i2cdev_release,
409}; 411};
410 412
411static void release_i2c_dev(struct class_device *dev) 413static struct class *i2c_dev_class;
412{
413 struct i2c_dev *i2c_dev = to_i2c_dev(dev);
414 complete(&i2c_dev->released);
415}
416
417static struct class i2c_dev_class = {
418 .name = "i2c-dev",
419 .release = &release_i2c_dev,
420};
421 414
422static int i2cdev_attach_adapter(struct i2c_adapter *adap) 415static int i2cdev_attach_adapter(struct i2c_adapter *adap)
423{ 416{
424 struct i2c_dev *i2c_dev; 417 struct i2c_dev *i2c_dev;
425 int retval; 418 struct device *dev;
426 419
427 i2c_dev = get_free_i2c_dev(adap); 420 i2c_dev = get_free_i2c_dev(adap);
428 if (IS_ERR(i2c_dev)) 421 if (IS_ERR(i2c_dev))
@@ -434,21 +427,20 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
434 /* register this i2c device with the driver core */ 427 /* register this i2c device with the driver core */
435 i2c_dev->adap = adap; 428 i2c_dev->adap = adap;
436 if (adap->dev.parent == &platform_bus) 429 if (adap->dev.parent == &platform_bus)
437 i2c_dev->class_dev.dev = &adap->dev; 430 dev = &adap->dev;
438 else 431 else
439 i2c_dev->class_dev.dev = adap->dev.parent; 432 dev = adap->dev.parent;
440 i2c_dev->class_dev.class = &i2c_dev_class; 433 i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL,
441 i2c_dev->class_dev.devt = MKDEV(I2C_MAJOR, i2c_dev->minor); 434 MKDEV(I2C_MAJOR, i2c_dev->minor),
442 snprintf(i2c_dev->class_dev.class_id, BUS_ID_SIZE, "i2c-%d", i2c_dev->minor); 435 dev, "i2c-%d", i2c_dev->minor);
443 retval = class_device_register(&i2c_dev->class_dev); 436 if (!i2c_dev->class_dev)
444 if (retval)
445 goto error; 437 goto error;
446 class_device_create_file(&i2c_dev->class_dev, &class_device_attr_name); 438 class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
447 return 0; 439 return 0;
448error: 440error:
449 return_i2c_dev(i2c_dev); 441 return_i2c_dev(i2c_dev);
450 kfree(i2c_dev); 442 kfree(i2c_dev);
451 return retval; 443 return -ENODEV;
452} 444}
453 445
454static int i2cdev_detach_adapter(struct i2c_adapter *adap) 446static int i2cdev_detach_adapter(struct i2c_adapter *adap)
@@ -459,10 +451,8 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
459 if (!i2c_dev) 451 if (!i2c_dev)
460 return -ENODEV; 452 return -ENODEV;
461 453
462 init_completion(&i2c_dev->released);
463 return_i2c_dev(i2c_dev); 454 return_i2c_dev(i2c_dev);
464 class_device_unregister(&i2c_dev->class_dev); 455 class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, i2c_dev->minor));
465 wait_for_completion(&i2c_dev->released);
466 kfree(i2c_dev); 456 kfree(i2c_dev);
467 457
468 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name); 458 pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
@@ -474,21 +464,14 @@ static int i2cdev_detach_client(struct i2c_client *client)
474 return 0; 464 return 0;
475} 465}
476 466
477static int i2cdev_command(struct i2c_client *client, unsigned int cmd,
478 void *arg)
479{
480 return -1;
481}
482
483static struct i2c_driver i2cdev_driver = { 467static struct i2c_driver i2cdev_driver = {
484 .owner = THIS_MODULE, 468 .driver = {
485 .name = "dev_driver", 469 .name = "dev_driver",
470 },
486 .id = I2C_DRIVERID_I2CDEV, 471 .id = I2C_DRIVERID_I2CDEV,
487 .flags = I2C_DF_NOTIFY,
488 .attach_adapter = i2cdev_attach_adapter, 472 .attach_adapter = i2cdev_attach_adapter,
489 .detach_adapter = i2cdev_detach_adapter, 473 .detach_adapter = i2cdev_detach_adapter,
490 .detach_client = i2cdev_detach_client, 474 .detach_client = i2cdev_detach_client,
491 .command = i2cdev_command,
492}; 475};
493 476
494static struct i2c_client i2cdev_client_template = { 477static struct i2c_client i2cdev_client_template = {
@@ -507,8 +490,8 @@ static int __init i2c_dev_init(void)
507 if (res) 490 if (res)
508 goto out; 491 goto out;
509 492
510 res = class_register(&i2c_dev_class); 493 i2c_dev_class = class_create(THIS_MODULE, "i2c-dev");
511 if (res) 494 if (IS_ERR(i2c_dev_class))
512 goto out_unreg_chrdev; 495 goto out_unreg_chrdev;
513 496
514 res = i2c_add_driver(&i2cdev_driver); 497 res = i2c_add_driver(&i2cdev_driver);
@@ -518,7 +501,7 @@ static int __init i2c_dev_init(void)
518 return 0; 501 return 0;
519 502
520out_unreg_class: 503out_unreg_class:
521 class_unregister(&i2c_dev_class); 504 class_destroy(i2c_dev_class);
522out_unreg_chrdev: 505out_unreg_chrdev:
523 unregister_chrdev(I2C_MAJOR, "i2c"); 506 unregister_chrdev(I2C_MAJOR, "i2c");
524out: 507out:
@@ -529,7 +512,7 @@ out:
529static void __exit i2c_dev_exit(void) 512static void __exit i2c_dev_exit(void)
530{ 513{
531 i2c_del_driver(&i2cdev_driver); 514 i2c_del_driver(&i2cdev_driver);
532 class_unregister(&i2c_dev_class); 515 class_destroy(i2c_dev_class);
533 unregister_chrdev(I2C_MAJOR,"i2c"); 516 unregister_chrdev(I2C_MAJOR,"i2c");
534} 517}
535 518
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 31e649a9ff71..1c81174595b3 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -807,14 +807,6 @@ config BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
807 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX 807 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX
808endchoice 808endchoice
809 809
810config BLK_DEV_IDE_AU1XXX_BURSTABLE_ON
811 bool "Enable burstable Mode on DbDMA"
812 default false
813 depends BLK_DEV_IDE_AU1XXX
814 help
815 This option enable the burstable Flag on DbDMA controller
816 (cf. "AMD Alchemy 'Au1200' Processor Data Book - PRELIMINARY").
817
818config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ 810config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
819 int "Maximum transfer size (KB) per request (up to 128)" 811 int "Maximum transfer size (KB) per request (up to 128)"
820 default "128" 812 default "128"
@@ -940,7 +932,7 @@ config BLK_DEV_Q40IDE
940 932
941config BLK_DEV_MPC8xx_IDE 933config BLK_DEV_MPC8xx_IDE
942 bool "MPC8xx IDE support" 934 bool "MPC8xx IDE support"
943 depends on 8xx 935 depends on 8xx && IDE=y && BLK_DEV_IDE=y
944 help 936 help
945 This option provides support for IDE on Motorola MPC8xx Systems. 937 This option provides support for IDE on Motorola MPC8xx Systems.
946 Please see 'Type of MPC8xx IDE interface' for details. 938 Please see 'Type of MPC8xx IDE interface' for details.
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 9455e42abb23..d31117eb95aa 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -614,7 +614,7 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate)
614 */ 614 */
615 spin_lock_irqsave(&ide_lock, flags); 615 spin_lock_irqsave(&ide_lock, flags);
616 end_that_request_chunk(failed, 0, failed->data_len); 616 end_that_request_chunk(failed, 0, failed->data_len);
617 end_that_request_last(failed); 617 end_that_request_last(failed, 0);
618 spin_unlock_irqrestore(&ide_lock, flags); 618 spin_unlock_irqrestore(&ide_lock, flags);
619 } 619 }
620 620
@@ -1292,7 +1292,6 @@ static ide_startstop_t cdrom_start_seek (ide_drive_t *drive, unsigned int block)
1292 struct cdrom_info *info = drive->driver_data; 1292 struct cdrom_info *info = drive->driver_data;
1293 1293
1294 info->dma = 0; 1294 info->dma = 0;
1295 info->cmd = 0;
1296 info->start_seek = jiffies; 1295 info->start_seek = jiffies;
1297 return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); 1296 return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation);
1298} 1297}
@@ -1344,8 +1343,6 @@ static ide_startstop_t cdrom_start_read (ide_drive_t *drive, unsigned int block)
1344 (rq->nr_sectors & (sectors_per_frame - 1))) 1343 (rq->nr_sectors & (sectors_per_frame - 1)))
1345 info->dma = 0; 1344 info->dma = 0;
1346 1345
1347 info->cmd = READ;
1348
1349 /* Start sending the read request to the drive. */ 1346 /* Start sending the read request to the drive. */
1350 return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation); 1347 return cdrom_start_packet_command(drive, 32768, cdrom_start_read_continuation);
1351} 1348}
@@ -1484,7 +1481,6 @@ static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive)
1484 struct cdrom_info *info = drive->driver_data; 1481 struct cdrom_info *info = drive->driver_data;
1485 1482
1486 info->dma = 0; 1483 info->dma = 0;
1487 info->cmd = 0;
1488 rq->flags &= ~REQ_FAILED; 1484 rq->flags &= ~REQ_FAILED;
1489 len = rq->data_len; 1485 len = rq->data_len;
1490 1486
@@ -1739,7 +1735,7 @@ end_request:
1739 1735
1740 spin_lock_irqsave(&ide_lock, flags); 1736 spin_lock_irqsave(&ide_lock, flags);
1741 blkdev_dequeue_request(rq); 1737 blkdev_dequeue_request(rq);
1742 end_that_request_last(rq); 1738 end_that_request_last(rq, 1);
1743 HWGROUP(drive)->rq = NULL; 1739 HWGROUP(drive)->rq = NULL;
1744 spin_unlock_irqrestore(&ide_lock, flags); 1740 spin_unlock_irqrestore(&ide_lock, flags);
1745 return ide_stopped; 1741 return ide_stopped;
@@ -1891,7 +1887,6 @@ static ide_startstop_t cdrom_start_write(ide_drive_t *drive, struct request *rq)
1891 /* use dma, if possible. we don't need to check more, since we 1887 /* use dma, if possible. we don't need to check more, since we
1892 * know that the transfer is always (at least!) frame aligned */ 1888 * know that the transfer is always (at least!) frame aligned */
1893 info->dma = drive->using_dma ? 1 : 0; 1889 info->dma = drive->using_dma ? 1 : 0;
1894 info->cmd = WRITE;
1895 1890
1896 info->devinfo.media_written = 1; 1891 info->devinfo.media_written = 1;
1897 1892
@@ -1916,7 +1911,6 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1916 rq->flags |= REQ_QUIET; 1911 rq->flags |= REQ_QUIET;
1917 1912
1918 info->dma = 0; 1913 info->dma = 0;
1919 info->cmd = 0;
1920 1914
1921 /* 1915 /*
1922 * sg request 1916 * sg request
@@ -1925,7 +1919,6 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1925 int mask = drive->queue->dma_alignment; 1919 int mask = drive->queue->dma_alignment;
1926 unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); 1920 unsigned long addr = (unsigned long) page_address(bio_page(rq->bio));
1927 1921
1928 info->cmd = rq_data_dir(rq);
1929 info->dma = drive->using_dma; 1922 info->dma = drive->using_dma;
1930 1923
1931 /* 1924 /*
@@ -3516,6 +3509,7 @@ static int __init ide_cdrom_init(void)
3516 return driver_register(&ide_cdrom_driver.gen_driver); 3509 return driver_register(&ide_cdrom_driver.gen_driver);
3517} 3510}
3518 3511
3512MODULE_ALIAS("ide:*m-cdrom*");
3519module_init(ide_cdrom_init); 3513module_init(ide_cdrom_init);
3520module_exit(ide_cdrom_exit); 3514module_exit(ide_cdrom_exit);
3521MODULE_LICENSE("GPL"); 3515MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index 7ca3e5afc665..ad1f2ed14a37 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -480,7 +480,6 @@ struct cdrom_info {
480 480
481 struct request request_sense_request; 481 struct request request_sense_request;
482 int dma; 482 int dma;
483 int cmd;
484 unsigned long last_block; 483 unsigned long last_block;
485 unsigned long start_seek; 484 unsigned long start_seek;
486 /* Buffer to hold mechanism status and changer slot table. */ 485 /* Buffer to hold mechanism status and changer slot table. */
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index f4e3d3527b0e..4b441720b6ba 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -681,50 +681,9 @@ static ide_proc_entry_t idedisk_proc[] = {
681 681
682#endif /* CONFIG_PROC_FS */ 682#endif /* CONFIG_PROC_FS */
683 683
684static void idedisk_end_flush(request_queue_t *q, struct request *flush_rq) 684static void idedisk_prepare_flush(request_queue_t *q, struct request *rq)
685{ 685{
686 ide_drive_t *drive = q->queuedata; 686 ide_drive_t *drive = q->queuedata;
687 struct request *rq = flush_rq->end_io_data;
688 int good_sectors = rq->hard_nr_sectors;
689 int bad_sectors;
690 sector_t sector;
691
692 if (flush_rq->errors & ABRT_ERR) {
693 printk(KERN_ERR "%s: barrier support doesn't work\n", drive->name);
694 blk_queue_ordered(drive->queue, QUEUE_ORDERED_NONE);
695 blk_queue_issue_flush_fn(drive->queue, NULL);
696 good_sectors = 0;
697 } else if (flush_rq->errors) {
698 good_sectors = 0;
699 if (blk_barrier_preflush(rq)) {
700 sector = ide_get_error_location(drive,flush_rq->buffer);
701 if ((sector >= rq->hard_sector) &&
702 (sector < rq->hard_sector + rq->hard_nr_sectors))
703 good_sectors = sector - rq->hard_sector;
704 }
705 }
706
707 if (flush_rq->errors)
708 printk(KERN_ERR "%s: failed barrier write: "
709 "sector=%Lx(good=%d/bad=%d)\n",
710 drive->name, (unsigned long long)rq->sector,
711 good_sectors,
712 (int) (rq->hard_nr_sectors-good_sectors));
713
714 bad_sectors = rq->hard_nr_sectors - good_sectors;
715
716 if (good_sectors)
717 __ide_end_request(drive, rq, 1, good_sectors);
718 if (bad_sectors)
719 __ide_end_request(drive, rq, 0, bad_sectors);
720}
721
722static int idedisk_prepare_flush(request_queue_t *q, struct request *rq)
723{
724 ide_drive_t *drive = q->queuedata;
725
726 if (!drive->wcache)
727 return 0;
728 687
729 memset(rq->cmd, 0, sizeof(rq->cmd)); 688 memset(rq->cmd, 0, sizeof(rq->cmd));
730 689
@@ -735,9 +694,8 @@ static int idedisk_prepare_flush(request_queue_t *q, struct request *rq)
735 rq->cmd[0] = WIN_FLUSH_CACHE; 694 rq->cmd[0] = WIN_FLUSH_CACHE;
736 695
737 696
738 rq->flags |= REQ_DRIVE_TASK | REQ_SOFTBARRIER; 697 rq->flags |= REQ_DRIVE_TASK;
739 rq->buffer = rq->cmd; 698 rq->buffer = rq->cmd;
740 return 1;
741} 699}
742 700
743static int idedisk_issue_flush(request_queue_t *q, struct gendisk *disk, 701static int idedisk_issue_flush(request_queue_t *q, struct gendisk *disk,
@@ -794,27 +752,64 @@ static int set_nowerr(ide_drive_t *drive, int arg)
794 return 0; 752 return 0;
795} 753}
796 754
755static void update_ordered(ide_drive_t *drive)
756{
757 struct hd_driveid *id = drive->id;
758 unsigned ordered = QUEUE_ORDERED_NONE;
759 prepare_flush_fn *prep_fn = NULL;
760 issue_flush_fn *issue_fn = NULL;
761
762 if (drive->wcache) {
763 unsigned long long capacity;
764 int barrier;
765 /*
766 * We must avoid issuing commands a drive does not
767 * understand or we may crash it. We check flush cache
768 * is supported. We also check we have the LBA48 flush
769 * cache if the drive capacity is too large. By this
770 * time we have trimmed the drive capacity if LBA48 is
771 * not available so we don't need to recheck that.
772 */
773 capacity = idedisk_capacity(drive);
774 barrier = ide_id_has_flush_cache(id) &&
775 (drive->addressing == 0 || capacity <= (1ULL << 28) ||
776 ide_id_has_flush_cache_ext(id));
777
778 printk(KERN_INFO "%s: cache flushes %ssupported\n",
779 drive->name, barrier ? "" : "not");
780
781 if (barrier) {
782 ordered = QUEUE_ORDERED_DRAIN_FLUSH;
783 prep_fn = idedisk_prepare_flush;
784 issue_fn = idedisk_issue_flush;
785 }
786 } else
787 ordered = QUEUE_ORDERED_DRAIN;
788
789 blk_queue_ordered(drive->queue, ordered, prep_fn);
790 blk_queue_issue_flush_fn(drive->queue, issue_fn);
791}
792
797static int write_cache(ide_drive_t *drive, int arg) 793static int write_cache(ide_drive_t *drive, int arg)
798{ 794{
799 ide_task_t args; 795 ide_task_t args;
800 int err; 796 int err = 1;
801
802 if (!ide_id_has_flush_cache(drive->id))
803 return 1;
804 797
805 memset(&args, 0, sizeof(ide_task_t)); 798 if (ide_id_has_flush_cache(drive->id)) {
806 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ? 799 memset(&args, 0, sizeof(ide_task_t));
800 args.tfRegister[IDE_FEATURE_OFFSET] = (arg) ?
807 SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; 801 SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE;
808 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES; 802 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SETFEATURES;
809 args.command_type = IDE_DRIVE_TASK_NO_DATA; 803 args.command_type = IDE_DRIVE_TASK_NO_DATA;
810 args.handler = &task_no_data_intr; 804 args.handler = &task_no_data_intr;
805 err = ide_raw_taskfile(drive, &args, NULL);
806 if (err == 0)
807 drive->wcache = arg;
808 }
811 809
812 err = ide_raw_taskfile(drive, &args, NULL); 810 update_ordered(drive);
813 if (err)
814 return err;
815 811
816 drive->wcache = arg; 812 return err;
817 return 0;
818} 813}
819 814
820static int do_idedisk_flushcache (ide_drive_t *drive) 815static int do_idedisk_flushcache (ide_drive_t *drive)
@@ -888,7 +883,6 @@ static void idedisk_setup (ide_drive_t *drive)
888{ 883{
889 struct hd_driveid *id = drive->id; 884 struct hd_driveid *id = drive->id;
890 unsigned long long capacity; 885 unsigned long long capacity;
891 int barrier;
892 886
893 idedisk_add_settings(drive); 887 idedisk_add_settings(drive);
894 888
@@ -992,31 +986,6 @@ static void idedisk_setup (ide_drive_t *drive)
992 drive->wcache = 1; 986 drive->wcache = 1;
993 987
994 write_cache(drive, 1); 988 write_cache(drive, 1);
995
996 /*
997 * We must avoid issuing commands a drive does not understand
998 * or we may crash it. We check flush cache is supported. We also
999 * check we have the LBA48 flush cache if the drive capacity is
1000 * too large. By this time we have trimmed the drive capacity if
1001 * LBA48 is not available so we don't need to recheck that.
1002 */
1003 barrier = 0;
1004 if (ide_id_has_flush_cache(id))
1005 barrier = 1;
1006 if (drive->addressing == 1) {
1007 /* Can't issue the correct flush ? */
1008 if (capacity > (1ULL << 28) && !ide_id_has_flush_cache_ext(id))
1009 barrier = 0;
1010 }
1011
1012 printk(KERN_INFO "%s: cache flushes %ssupported\n",
1013 drive->name, barrier ? "" : "not ");
1014 if (barrier) {
1015 blk_queue_ordered(drive->queue, QUEUE_ORDERED_FLUSH);
1016 drive->queue->prepare_flush_fn = idedisk_prepare_flush;
1017 drive->queue->end_flush_fn = idedisk_end_flush;
1018 blk_queue_issue_flush_fn(drive->queue, idedisk_issue_flush);
1019 }
1020} 989}
1021 990
1022static void ide_cacheflush_p(ide_drive_t *drive) 991static void ide_cacheflush_p(ide_drive_t *drive)
@@ -1034,12 +1003,12 @@ static int ide_disk_remove(struct device *dev)
1034 struct ide_disk_obj *idkp = drive->driver_data; 1003 struct ide_disk_obj *idkp = drive->driver_data;
1035 struct gendisk *g = idkp->disk; 1004 struct gendisk *g = idkp->disk;
1036 1005
1037 ide_cacheflush_p(drive);
1038
1039 ide_unregister_subdriver(drive, idkp->driver); 1006 ide_unregister_subdriver(drive, idkp->driver);
1040 1007
1041 del_gendisk(g); 1008 del_gendisk(g);
1042 1009
1010 ide_cacheflush_p(drive);
1011
1043 ide_disk_put(idkp); 1012 ide_disk_put(idkp);
1044 1013
1045 return 0; 1014 return 0;
@@ -1271,6 +1240,7 @@ static int __init idedisk_init(void)
1271 return driver_register(&idedisk_driver.gen_driver); 1240 return driver_register(&idedisk_driver.gen_driver);
1272} 1241}
1273 1242
1243MODULE_ALIAS("ide:*m-disk*");
1274module_init(idedisk_init); 1244module_init(idedisk_init);
1275module_exit(idedisk_exit); 1245module_exit(idedisk_exit);
1276MODULE_LICENSE("GPL"); 1246MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 1e1531334c25..0523da77425a 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -90,11 +90,6 @@
90#include <asm/io.h> 90#include <asm/io.h>
91#include <asm/irq.h> 91#include <asm/irq.h>
92 92
93struct drive_list_entry {
94 const char *id_model;
95 const char *id_firmware;
96};
97
98static const struct drive_list_entry drive_whitelist [] = { 93static const struct drive_list_entry drive_whitelist [] = {
99 94
100 { "Micropolis 2112A" , "ALL" }, 95 { "Micropolis 2112A" , "ALL" },
@@ -139,7 +134,7 @@ static const struct drive_list_entry drive_blacklist [] = {
139}; 134};
140 135
141/** 136/**
142 * in_drive_list - look for drive in black/white list 137 * ide_in_drive_list - look for drive in black/white list
143 * @id: drive identifier 138 * @id: drive identifier
144 * @drive_table: list to inspect 139 * @drive_table: list to inspect
145 * 140 *
@@ -147,7 +142,7 @@ static const struct drive_list_entry drive_blacklist [] = {
147 * Returns 1 if the drive is found in the table. 142 * Returns 1 if the drive is found in the table.
148 */ 143 */
149 144
150static int in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table) 145int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table)
151{ 146{
152 for ( ; drive_table->id_model ; drive_table++) 147 for ( ; drive_table->id_model ; drive_table++)
153 if ((!strcmp(drive_table->id_model, id->model)) && 148 if ((!strcmp(drive_table->id_model, id->model)) &&
@@ -157,6 +152,8 @@ static int in_drive_list(struct hd_driveid *id, const struct drive_list_entry *d
157 return 0; 152 return 0;
158} 153}
159 154
155EXPORT_SYMBOL_GPL(ide_in_drive_list);
156
160/** 157/**
161 * ide_dma_intr - IDE DMA interrupt handler 158 * ide_dma_intr - IDE DMA interrupt handler
162 * @drive: the drive the interrupt is for 159 * @drive: the drive the interrupt is for
@@ -663,7 +660,7 @@ int __ide_dma_bad_drive (ide_drive_t *drive)
663{ 660{
664 struct hd_driveid *id = drive->id; 661 struct hd_driveid *id = drive->id;
665 662
666 int blacklist = in_drive_list(id, drive_blacklist); 663 int blacklist = ide_in_drive_list(id, drive_blacklist);
667 if (blacklist) { 664 if (blacklist) {
668 printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n", 665 printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n",
669 drive->name, id->model); 666 drive->name, id->model);
@@ -677,7 +674,7 @@ EXPORT_SYMBOL(__ide_dma_bad_drive);
677int __ide_dma_good_drive (ide_drive_t *drive) 674int __ide_dma_good_drive (ide_drive_t *drive)
678{ 675{
679 struct hd_driveid *id = drive->id; 676 struct hd_driveid *id = drive->id;
680 return in_drive_list(id, drive_whitelist); 677 return ide_in_drive_list(id, drive_whitelist);
681} 678}
682 679
683EXPORT_SYMBOL(__ide_dma_good_drive); 680EXPORT_SYMBOL(__ide_dma_good_drive);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 9e293c8063dc..fba3fffc2d66 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -2197,6 +2197,7 @@ static int __init idefloppy_init(void)
2197 return driver_register(&idefloppy_driver.gen_driver); 2197 return driver_register(&idefloppy_driver.gen_driver);
2198} 2198}
2199 2199
2200MODULE_ALIAS("ide:*m-floppy*");
2200module_init(idefloppy_init); 2201module_init(idefloppy_init);
2201module_exit(idefloppy_exit); 2202module_exit(idefloppy_exit);
2202MODULE_LICENSE("GPL"); 2203MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index ecfafcdafea4..b5dc6df8e67d 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -89,7 +89,7 @@ int __ide_end_request(ide_drive_t *drive, struct request *rq, int uptodate,
89 89
90 blkdev_dequeue_request(rq); 90 blkdev_dequeue_request(rq);
91 HWGROUP(drive)->rq = NULL; 91 HWGROUP(drive)->rq = NULL;
92 end_that_request_last(rq); 92 end_that_request_last(rq, uptodate);
93 ret = 0; 93 ret = 0;
94 } 94 }
95 return ret; 95 return ret;
@@ -119,10 +119,7 @@ int ide_end_request (ide_drive_t *drive, int uptodate, int nr_sectors)
119 if (!nr_sectors) 119 if (!nr_sectors)
120 nr_sectors = rq->hard_cur_sectors; 120 nr_sectors = rq->hard_cur_sectors;
121 121
122 if (blk_complete_barrier_rq_locked(drive->queue, rq, nr_sectors)) 122 ret = __ide_end_request(drive, rq, uptodate, nr_sectors);
123 ret = rq->nr_sectors != 0;
124 else
125 ret = __ide_end_request(drive, rq, uptodate, nr_sectors);
126 123
127 spin_unlock_irqrestore(&ide_lock, flags); 124 spin_unlock_irqrestore(&ide_lock, flags);
128 return ret; 125 return ret;
@@ -247,7 +244,7 @@ static void ide_complete_pm_request (ide_drive_t *drive, struct request *rq)
247 } 244 }
248 blkdev_dequeue_request(rq); 245 blkdev_dequeue_request(rq);
249 HWGROUP(drive)->rq = NULL; 246 HWGROUP(drive)->rq = NULL;
250 end_that_request_last(rq); 247 end_that_request_last(rq, 1);
251 spin_unlock_irqrestore(&ide_lock, flags); 248 spin_unlock_irqrestore(&ide_lock, flags);
252} 249}
253 250
@@ -379,7 +376,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err)
379 blkdev_dequeue_request(rq); 376 blkdev_dequeue_request(rq);
380 HWGROUP(drive)->rq = NULL; 377 HWGROUP(drive)->rq = NULL;
381 rq->errors = err; 378 rq->errors = err;
382 end_that_request_last(rq); 379 end_that_request_last(rq, !rq->errors);
383 spin_unlock_irqrestore(&ide_lock, flags); 380 spin_unlock_irqrestore(&ide_lock, flags);
384} 381}
385 382
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 7d7944ed4158..fab9b2b02504 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4947,6 +4947,7 @@ out:
4947 return error; 4947 return error;
4948} 4948}
4949 4949
4950MODULE_ALIAS("ide:*m-tape*");
4950module_init(idetape_init); 4951module_init(idetape_init);
4951module_exit(idetape_exit); 4952module_exit(idetape_exit);
4952MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR); 4953MODULE_ALIAS_CHARDEV_MAJOR(IDETAPE_MAJOR);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 8af179b531c3..4b524f6b3ecd 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -1904,9 +1904,69 @@ static int ide_bus_match(struct device *dev, struct device_driver *drv)
1904 return 1; 1904 return 1;
1905} 1905}
1906 1906
1907static char *media_string(ide_drive_t *drive)
1908{
1909 switch (drive->media) {
1910 case ide_disk:
1911 return "disk";
1912 case ide_cdrom:
1913 return "cdrom";
1914 case ide_tape:
1915 return "tape";
1916 case ide_floppy:
1917 return "floppy";
1918 default:
1919 return "UNKNOWN";
1920 }
1921}
1922
1923static ssize_t media_show(struct device *dev, struct device_attribute *attr, char *buf)
1924{
1925 ide_drive_t *drive = to_ide_device(dev);
1926 return sprintf(buf, "%s\n", media_string(drive));
1927}
1928
1929static ssize_t drivename_show(struct device *dev, struct device_attribute *attr, char *buf)
1930{
1931 ide_drive_t *drive = to_ide_device(dev);
1932 return sprintf(buf, "%s\n", drive->name);
1933}
1934
1935static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
1936{
1937 ide_drive_t *drive = to_ide_device(dev);
1938 return sprintf(buf, "ide:m-%s\n", media_string(drive));
1939}
1940
1941static struct device_attribute ide_dev_attrs[] = {
1942 __ATTR_RO(media),
1943 __ATTR_RO(drivename),
1944 __ATTR_RO(modalias),
1945 __ATTR_NULL
1946};
1947
1948static int ide_uevent(struct device *dev, char **envp, int num_envp,
1949 char *buffer, int buffer_size)
1950{
1951 ide_drive_t *drive = to_ide_device(dev);
1952 int i = 0;
1953 int length = 0;
1954
1955 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1956 "MEDIA=%s", media_string(drive));
1957 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1958 "DRIVENAME=%s", drive->name);
1959 add_uevent_var(envp, num_envp, &i, buffer, buffer_size, &length,
1960 "MODALIAS=ide:m-%s", media_string(drive));
1961 envp[i] = NULL;
1962 return 0;
1963}
1964
1907struct bus_type ide_bus_type = { 1965struct bus_type ide_bus_type = {
1908 .name = "ide", 1966 .name = "ide",
1909 .match = ide_bus_match, 1967 .match = ide_bus_match,
1968 .uevent = ide_uevent,
1969 .dev_attrs = ide_dev_attrs,
1910 .suspend = generic_ide_suspend, 1970 .suspend = generic_ide_suspend,
1911 .resume = generic_ide_resume, 1971 .resume = generic_ide_resume,
1912}; 1972};
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c
index ef79805218e4..4c2af9020905 100644
--- a/drivers/ide/legacy/ide-cs.c
+++ b/drivers/ide/legacy/ide-cs.c
@@ -88,15 +88,12 @@ typedef struct ide_info_t {
88} ide_info_t; 88} ide_info_t;
89 89
90static void ide_release(dev_link_t *); 90static void ide_release(dev_link_t *);
91static int ide_event(event_t event, int priority, 91static void ide_config(dev_link_t *);
92 event_callback_args_t *args); 92
93static void ide_detach(struct pcmcia_device *p_dev);
93 94
94static dev_info_t dev_info = "ide-cs";
95 95
96static dev_link_t *ide_attach(void);
97static void ide_detach(dev_link_t *);
98 96
99static dev_link_t *dev_list = NULL;
100 97
101/*====================================================================== 98/*======================================================================
102 99
@@ -106,18 +103,17 @@ static dev_link_t *dev_list = NULL;
106 103
107======================================================================*/ 104======================================================================*/
108 105
109static dev_link_t *ide_attach(void) 106static int ide_attach(struct pcmcia_device *p_dev)
110{ 107{
111 ide_info_t *info; 108 ide_info_t *info;
112 dev_link_t *link; 109 dev_link_t *link;
113 client_reg_t client_reg; 110
114 int ret;
115
116 DEBUG(0, "ide_attach()\n"); 111 DEBUG(0, "ide_attach()\n");
117 112
118 /* Create new ide device */ 113 /* Create new ide device */
119 info = kzalloc(sizeof(*info), GFP_KERNEL); 114 info = kzalloc(sizeof(*info), GFP_KERNEL);
120 if (!info) return NULL; 115 if (!info)
116 return -ENOMEM;
121 link = &info->link; link->priv = info; 117 link = &info->link; link->priv = info;
122 118
123 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; 119 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
@@ -128,21 +124,14 @@ static dev_link_t *ide_attach(void)
128 link->conf.Attributes = CONF_ENABLE_IRQ; 124 link->conf.Attributes = CONF_ENABLE_IRQ;
129 link->conf.Vcc = 50; 125 link->conf.Vcc = 50;
130 link->conf.IntType = INT_MEMORY_AND_IO; 126 link->conf.IntType = INT_MEMORY_AND_IO;
131 127
132 /* Register with Card Services */ 128 link->handle = p_dev;
133 link->next = dev_list; 129 p_dev->instance = link;
134 dev_list = link; 130
135 client_reg.dev_info = &dev_info; 131 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
136 client_reg.Version = 0x0210; 132 ide_config(link);
137 client_reg.event_callback_args.client_data = link; 133
138 ret = pcmcia_register_client(&link->handle, &client_reg); 134 return 0;
139 if (ret != CS_SUCCESS) {
140 cs_error(link->handle, RegisterClient, ret);
141 ide_detach(link);
142 return NULL;
143 }
144
145 return link;
146} /* ide_attach */ 135} /* ide_attach */
147 136
148/*====================================================================== 137/*======================================================================
@@ -154,32 +143,16 @@ static dev_link_t *ide_attach(void)
154 143
155======================================================================*/ 144======================================================================*/
156 145
157static void ide_detach(dev_link_t *link) 146static void ide_detach(struct pcmcia_device *p_dev)
158{ 147{
159 dev_link_t **linkp; 148 dev_link_t *link = dev_to_instance(p_dev);
160 int ret;
161 149
162 DEBUG(0, "ide_detach(0x%p)\n", link); 150 DEBUG(0, "ide_detach(0x%p)\n", link);
163
164 /* Locate device structure */
165 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
166 if (*linkp == link) break;
167 if (*linkp == NULL)
168 return;
169 151
170 if (link->state & DEV_CONFIG) 152 if (link->state & DEV_CONFIG)
171 ide_release(link); 153 ide_release(link);
172 154
173 if (link->handle) {
174 ret = pcmcia_deregister_client(link->handle);
175 if (ret != CS_SUCCESS)
176 cs_error(link->handle, DeregisterClient, ret);
177 }
178
179 /* Unlink, free device structure */
180 *linkp = link->next;
181 kfree(link->priv); 155 kfree(link->priv);
182
183} /* ide_detach */ 156} /* ide_detach */
184 157
185static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) 158static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle)
@@ -406,6 +379,28 @@ void ide_release(dev_link_t *link)
406 379
407} /* ide_release */ 380} /* ide_release */
408 381
382static int ide_suspend(struct pcmcia_device *dev)
383{
384 dev_link_t *link = dev_to_instance(dev);
385
386 link->state |= DEV_SUSPEND;
387 if (link->state & DEV_CONFIG)
388 pcmcia_release_configuration(link->handle);
389
390 return 0;
391}
392
393static int ide_resume(struct pcmcia_device *dev)
394{
395 dev_link_t *link = dev_to_instance(dev);
396
397 link->state &= ~DEV_SUSPEND;
398 if (DEV_OK(link))
399 pcmcia_request_configuration(link->handle, &link->conf);
400
401 return 0;
402}
403
409/*====================================================================== 404/*======================================================================
410 405
411 The card status event handler. Mostly, this schedules other 406 The card status event handler. Mostly, this schedules other
@@ -415,48 +410,15 @@ void ide_release(dev_link_t *link)
415 410
416======================================================================*/ 411======================================================================*/
417 412
418int ide_event(event_t event, int priority,
419 event_callback_args_t *args)
420{
421 dev_link_t *link = args->client_data;
422
423 DEBUG(1, "ide_event(0x%06x)\n", event);
424
425 switch (event) {
426 case CS_EVENT_CARD_REMOVAL:
427 link->state &= ~DEV_PRESENT;
428 if (link->state & DEV_CONFIG)
429 ide_release(link);
430 break;
431 case CS_EVENT_CARD_INSERTION:
432 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
433 ide_config(link);
434 break;
435 case CS_EVENT_PM_SUSPEND:
436 link->state |= DEV_SUSPEND;
437 /* Fall through... */
438 case CS_EVENT_RESET_PHYSICAL:
439 if (link->state & DEV_CONFIG)
440 pcmcia_release_configuration(link->handle);
441 break;
442 case CS_EVENT_PM_RESUME:
443 link->state &= ~DEV_SUSPEND;
444 /* Fall through... */
445 case CS_EVENT_CARD_RESET:
446 if (DEV_OK(link))
447 pcmcia_request_configuration(link->handle, &link->conf);
448 break;
449 }
450 return 0;
451} /* ide_event */
452
453static struct pcmcia_device_id ide_ids[] = { 413static struct pcmcia_device_id ide_ids[] = {
454 PCMCIA_DEVICE_FUNC_ID(4), 414 PCMCIA_DEVICE_FUNC_ID(4),
415 PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */
455 PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704), 416 PCMCIA_DEVICE_MANF_CARD(0x0032, 0x0704),
456 PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401), 417 PCMCIA_DEVICE_MANF_CARD(0x0045, 0x0401),
457 PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */ 418 PCMCIA_DEVICE_MANF_CARD(0x0098, 0x0000), /* Toshiba */
458 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d), 419 PCMCIA_DEVICE_MANF_CARD(0x00a4, 0x002d),
459 PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */ 420 PCMCIA_DEVICE_MANF_CARD(0x00ce, 0x0000), /* Samsung */
421 PCMCIA_DEVICE_MANF_CARD(0x0319, 0x0000), /* Hitachi */
460 PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001), 422 PCMCIA_DEVICE_MANF_CARD(0x2080, 0x0001),
461 PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar */ 423 PCMCIA_DEVICE_MANF_CARD(0x4e01, 0x0200), /* Lexar */
462 PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0), 424 PCMCIA_DEVICE_PROD_ID123("Caravelle", "PSC-IDE ", "PSC000", 0x8c36137c, 0xd0693ab8, 0x2768a9f0),
@@ -471,6 +433,8 @@ static struct pcmcia_device_id ide_ids[] = {
471 PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591), 433 PCMCIA_DEVICE_PROD_ID12("EXP ", "CD-ROM", 0x0a5c52fd, 0x66536591),
472 PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728), 434 PCMCIA_DEVICE_PROD_ID12("EXP ", "PnPIDE", 0x0a5c52fd, 0x0c694728),
473 PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e), 435 PCMCIA_DEVICE_PROD_ID12("FREECOM", "PCCARD-IDE", 0x5714cbf7, 0x48e0ab8e),
436 PCMCIA_DEVICE_PROD_ID12("HITACHI", "FLASH", 0xf4f43949, 0x9eb86aae),
437 PCMCIA_DEVICE_PROD_ID12("HITACHI", "microdrive", 0xf4f43949, 0xa6d76178),
474 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753), 438 PCMCIA_DEVICE_PROD_ID12("IBM", "IBM17JSSFP20", 0xb569a6e5, 0xf2508753),
475 PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b), 439 PCMCIA_DEVICE_PROD_ID12("IO DATA", "CBIDE2 ", 0x547e66dc, 0x8671043b),
476 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149), 440 PCMCIA_DEVICE_PROD_ID12("IO DATA", "PCIDE", 0x547e66dc, 0x5c5ab149),
@@ -494,10 +458,11 @@ static struct pcmcia_driver ide_cs_driver = {
494 .drv = { 458 .drv = {
495 .name = "ide-cs", 459 .name = "ide-cs",
496 }, 460 },
497 .attach = ide_attach, 461 .probe = ide_attach,
498 .event = ide_event, 462 .remove = ide_detach,
499 .detach = ide_detach,
500 .id_table = ide_ids, 463 .id_table = ide_ids,
464 .suspend = ide_suspend,
465 .resume = ide_resume,
501}; 466};
502 467
503static int __init init_ide_cs(void) 468static int __init init_ide_cs(void)
@@ -508,7 +473,6 @@ static int __init init_ide_cs(void)
508static void __exit exit_ide_cs(void) 473static void __exit exit_ide_cs(void)
509{ 474{
510 pcmcia_unregister_driver(&ide_cs_driver); 475 pcmcia_unregister_driver(&ide_cs_driver);
511 BUG_ON(dev_list != NULL);
512} 476}
513 477
514late_initcall(init_ide_cs); 478late_initcall(init_ide_cs);
diff --git a/drivers/ide/mips/Makefile b/drivers/ide/mips/Makefile
index 578e52a59588..677c7b2bac92 100644
--- a/drivers/ide/mips/Makefile
+++ b/drivers/ide/mips/Makefile
@@ -1 +1,4 @@
1obj-$(CONFIG_BLK_DEV_IDE_SWARM) += swarm.o 1obj-$(CONFIG_BLK_DEV_IDE_SWARM) += swarm.o
2obj-$(CONFIG_BLK_DEV_IDE_AU1XXX) += au1xxx-ide.o
3
4EXTRA_CFLAGS := -Idrivers/ide
diff --git a/drivers/ide/mips/au1xxx-ide.c b/drivers/ide/mips/au1xxx-ide.c
index 2b6327c576b9..32431dcf5d8e 100644
--- a/drivers/ide/mips/au1xxx-ide.c
+++ b/drivers/ide/mips/au1xxx-ide.c
@@ -31,865 +31,638 @@
31 */ 31 */
32#undef REALLY_SLOW_IO /* most systems can safely undef this */ 32#undef REALLY_SLOW_IO /* most systems can safely undef this */
33 33
34#include <linux/config.h> /* for CONFIG_BLK_DEV_IDEPCI */
35#include <linux/types.h> 34#include <linux/types.h>
36#include <linux/module.h> 35#include <linux/module.h>
37#include <linux/kernel.h> 36#include <linux/kernel.h>
38#include <linux/delay.h> 37#include <linux/delay.h>
39#include <linux/timer.h> 38#include <linux/platform_device.h>
40#include <linux/mm.h> 39
41#include <linux/ioport.h>
42#include <linux/hdreg.h>
43#include <linux/init.h> 40#include <linux/init.h>
44#include <linux/ide.h> 41#include <linux/ide.h>
45#include <linux/sysdev.h> 42#include <linux/sysdev.h>
46 43
47#include <linux/dma-mapping.h> 44#include <linux/dma-mapping.h>
48 45
46#include "ide-timing.h"
47
49#include <asm/io.h> 48#include <asm/io.h>
50#include <asm/mach-au1x00/au1xxx.h> 49#include <asm/mach-au1x00/au1xxx.h>
51#include <asm/mach-au1x00/au1xxx_dbdma.h> 50#include <asm/mach-au1x00/au1xxx_dbdma.h>
52 51
53#if CONFIG_PM
54#include <asm/mach-au1x00/au1xxx_pm.h>
55#endif
56
57#include <asm/mach-au1x00/au1xxx_ide.h> 52#include <asm/mach-au1x00/au1xxx_ide.h>
58 53
59#define DRV_NAME "au1200-ide" 54#define DRV_NAME "au1200-ide"
60#define DRV_VERSION "1.0" 55#define DRV_VERSION "1.0"
61#define DRV_AUTHOR "AMD PCS / Pete Popov <ppopov@embeddedalley.com>" 56#define DRV_AUTHOR "Enrico Walther <enrico.walther@amd.com> / Pete Popov <ppopov@embeddedalley.com>"
62#define DRV_DESC "Au1200 IDE"
63
64static _auide_hwif auide_hwif;
65static spinlock_t ide_tune_drive_spin_lock = SPIN_LOCK_UNLOCKED;
66static spinlock_t ide_tune_chipset_spin_lock = SPIN_LOCK_UNLOCKED;
67static int dbdma_init_done = 0;
68
69/*
70 * local I/O functions
71 */
72u8 auide_inb(unsigned long port)
73{
74 return (au_readb(port));
75}
76 57
77u16 auide_inw(unsigned long port) 58/* enable the burstmode in the dbdma */
78{ 59#define IDE_AU1XXX_BURSTMODE 1
79 return (au_readw(port));
80}
81 60
82u32 auide_inl(unsigned long port) 61static _auide_hwif auide_hwif;
83{ 62static int dbdma_init_done;
84 return (au_readl(port));
85}
86 63
87void auide_insw(unsigned long port, void *addr, u32 count)
88{
89#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA) 64#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
90 65
91 _auide_hwif *ahwif = &auide_hwif; 66void auide_insw(unsigned long port, void *addr, u32 count)
92 chan_tab_t *ctp;
93 au1x_ddma_desc_t *dp;
94
95 if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1,
96 DDMA_FLAGS_NOIE)) {
97 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
98 return;
99 }
100 ctp = *((chan_tab_t **)ahwif->rx_chan);
101 dp = ctp->cur_ptr;
102 while (dp->dscr_cmd0 & DSCR_CMD0_V)
103 ;
104 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
105#else
106 while (count--)
107 {
108 *(u16 *)addr = au_readw(port);
109 addr +=2 ;
110 }
111#endif
112}
113
114void auide_insl(unsigned long port, void *addr, u32 count)
115{
116 while (count--)
117 {
118 *(u32 *)addr = au_readl(port);
119 /* NOTE: For IDE interfaces over PCMCIA,
120 * 32-bit access does not work
121 */
122 addr += 4;
123 }
124}
125
126void auide_outb(u8 addr, unsigned long port)
127{ 67{
128 return (au_writeb(addr, port)); 68 _auide_hwif *ahwif = &auide_hwif;
129} 69 chan_tab_t *ctp;
70 au1x_ddma_desc_t *dp;
130 71
131void auide_outbsync(ide_drive_t *drive, u8 addr, unsigned long port) 72 if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1,
132{ 73 DDMA_FLAGS_NOIE)) {
133 return (au_writeb(addr, port)); 74 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
75 return;
76 }
77 ctp = *((chan_tab_t **)ahwif->rx_chan);
78 dp = ctp->cur_ptr;
79 while (dp->dscr_cmd0 & DSCR_CMD0_V)
80 ;
81 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
134} 82}
135 83
136void auide_outw(u16 addr, unsigned long port) 84void auide_outsw(unsigned long port, void *addr, u32 count)
137{ 85{
138 return (au_writew(addr, port)); 86 _auide_hwif *ahwif = &auide_hwif;
139} 87 chan_tab_t *ctp;
88 au1x_ddma_desc_t *dp;
140 89
141void auide_outl(u32 addr, unsigned long port) 90 if(!put_source_flags(ahwif->tx_chan, (void*)addr,
142{ 91 count << 1, DDMA_FLAGS_NOIE)) {
143 return (au_writel(addr, port)); 92 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
93 return;
94 }
95 ctp = *((chan_tab_t **)ahwif->tx_chan);
96 dp = ctp->cur_ptr;
97 while (dp->dscr_cmd0 & DSCR_CMD0_V)
98 ;
99 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
144} 100}
145 101
146void auide_outsw(unsigned long port, void *addr, u32 count)
147{
148#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
149 _auide_hwif *ahwif = &auide_hwif;
150 chan_tab_t *ctp;
151 au1x_ddma_desc_t *dp;
152
153 if(!put_source_flags(ahwif->tx_chan, (void*)addr,
154 count << 1, DDMA_FLAGS_NOIE)) {
155 printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__);
156 return;
157 }
158 ctp = *((chan_tab_t **)ahwif->tx_chan);
159 dp = ctp->cur_ptr;
160 while (dp->dscr_cmd0 & DSCR_CMD0_V)
161 ;
162 ctp->cur_ptr = au1xxx_ddma_get_nextptr_virt(dp);
163#else
164 while (count--)
165 {
166 au_writew(*(u16 *)addr, port);
167 addr += 2;
168 }
169#endif 102#endif
170}
171
172void auide_outsl(unsigned long port, void *addr, u32 count)
173{
174 while (count--)
175 {
176 au_writel(*(u32 *)addr, port);
177 /* NOTE: For IDE interfaces over PCMCIA,
178 * 32-bit access does not work
179 */
180 addr += 4;
181 }
182}
183 103
184static void auide_tune_drive(ide_drive_t *drive, byte pio) 104static void auide_tune_drive(ide_drive_t *drive, byte pio)
185{ 105{
186 int mem_sttime; 106 int mem_sttime;
187 int mem_stcfg; 107 int mem_stcfg;
188 unsigned long flags; 108 u8 speed;
189 u8 speed; 109
190 110 /* get the best pio mode for the drive */
191 /* get the best pio mode for the drive */ 111 pio = ide_get_best_pio_mode(drive, pio, 4, NULL);
192 pio = ide_get_best_pio_mode(drive, pio, 4, NULL); 112
193 113 printk(KERN_INFO "%s: setting Au1XXX IDE to PIO mode%d\n",
194 printk("%s: setting Au1XXX IDE to PIO mode%d\n", 114 drive->name, pio);
195 drive->name, pio); 115
196 116 mem_sttime = 0;
197 spin_lock_irqsave(&ide_tune_drive_spin_lock, flags); 117 mem_stcfg = au_readl(MEM_STCFG2);
198 118
199 mem_sttime = 0; 119 /* set pio mode! */
200 mem_stcfg = au_readl(MEM_STCFG2); 120 switch(pio) {
201 121 case 0:
202 /* set pio mode! */ 122 mem_sttime = SBC_IDE_TIMING(PIO0);
203 switch(pio) { 123
204 case 0: 124 /* set configuration for RCS2# */
205 /* set timing parameters for RCS2# */ 125 mem_stcfg |= TS_MASK;
206 mem_sttime = SBC_IDE_PIO0_TWCS 126 mem_stcfg &= ~TCSOE_MASK;
207 | SBC_IDE_PIO0_TCSH 127 mem_stcfg &= ~TOECS_MASK;
208 | SBC_IDE_PIO0_TCSOFF 128 mem_stcfg |= SBC_IDE_PIO0_TCSOE | SBC_IDE_PIO0_TOECS;
209 | SBC_IDE_PIO0_TWP 129 break;
210 | SBC_IDE_PIO0_TCSW 130
211 | SBC_IDE_PIO0_TPM 131 case 1:
212 | SBC_IDE_PIO0_TA; 132 mem_sttime = SBC_IDE_TIMING(PIO1);
213 /* set configuration for RCS2# */ 133
214 mem_stcfg |= TS_MASK; 134 /* set configuration for RCS2# */
215 mem_stcfg &= ~TCSOE_MASK; 135 mem_stcfg |= TS_MASK;
216 mem_stcfg &= ~TOECS_MASK; 136 mem_stcfg &= ~TCSOE_MASK;
217 mem_stcfg |= SBC_IDE_PIO0_TCSOE | SBC_IDE_PIO0_TOECS; 137 mem_stcfg &= ~TOECS_MASK;
218 138 mem_stcfg |= SBC_IDE_PIO1_TCSOE | SBC_IDE_PIO1_TOECS;
219 au_writel(mem_sttime,MEM_STTIME2); 139 break;
220 au_writel(mem_stcfg,MEM_STCFG2); 140
221 break; 141 case 2:
222 142 mem_sttime = SBC_IDE_TIMING(PIO2);
223 case 1: 143
224 /* set timing parameters for RCS2# */ 144 /* set configuration for RCS2# */
225 mem_sttime = SBC_IDE_PIO1_TWCS 145 mem_stcfg &= ~TS_MASK;
226 | SBC_IDE_PIO1_TCSH 146 mem_stcfg &= ~TCSOE_MASK;
227 | SBC_IDE_PIO1_TCSOFF 147 mem_stcfg &= ~TOECS_MASK;
228 | SBC_IDE_PIO1_TWP 148 mem_stcfg |= SBC_IDE_PIO2_TCSOE | SBC_IDE_PIO2_TOECS;
229 | SBC_IDE_PIO1_TCSW 149 break;
230 | SBC_IDE_PIO1_TPM 150
231 | SBC_IDE_PIO1_TA; 151 case 3:
232 /* set configuration for RCS2# */ 152 mem_sttime = SBC_IDE_TIMING(PIO3);
233 mem_stcfg |= TS_MASK; 153
234 mem_stcfg &= ~TCSOE_MASK; 154 /* set configuration for RCS2# */
235 mem_stcfg &= ~TOECS_MASK; 155 mem_stcfg &= ~TS_MASK;
236 mem_stcfg |= SBC_IDE_PIO1_TCSOE | SBC_IDE_PIO1_TOECS; 156 mem_stcfg &= ~TCSOE_MASK;
237 break; 157 mem_stcfg &= ~TOECS_MASK;
238 158 mem_stcfg |= SBC_IDE_PIO3_TCSOE | SBC_IDE_PIO3_TOECS;
239 case 2: 159
240 /* set timing parameters for RCS2# */ 160 break;
241 mem_sttime = SBC_IDE_PIO2_TWCS 161
242 | SBC_IDE_PIO2_TCSH 162 case 4:
243 | SBC_IDE_PIO2_TCSOFF 163 mem_sttime = SBC_IDE_TIMING(PIO4);
244 | SBC_IDE_PIO2_TWP 164
245 | SBC_IDE_PIO2_TCSW 165 /* set configuration for RCS2# */
246 | SBC_IDE_PIO2_TPM 166 mem_stcfg &= ~TS_MASK;
247 | SBC_IDE_PIO2_TA; 167 mem_stcfg &= ~TCSOE_MASK;
248 /* set configuration for RCS2# */ 168 mem_stcfg &= ~TOECS_MASK;
249 mem_stcfg &= ~TS_MASK; 169 mem_stcfg |= SBC_IDE_PIO4_TCSOE | SBC_IDE_PIO4_TOECS;
250 mem_stcfg &= ~TCSOE_MASK; 170 break;
251 mem_stcfg &= ~TOECS_MASK; 171 }
252 mem_stcfg |= SBC_IDE_PIO2_TCSOE | SBC_IDE_PIO2_TOECS; 172
253 break; 173 au_writel(mem_sttime,MEM_STTIME2);
254 174 au_writel(mem_stcfg,MEM_STCFG2);
255 case 3: 175
256 /* set timing parameters for RCS2# */ 176 speed = pio + XFER_PIO_0;
257 mem_sttime = SBC_IDE_PIO3_TWCS 177 ide_config_drive_speed(drive, speed);
258 | SBC_IDE_PIO3_TCSH
259 | SBC_IDE_PIO3_TCSOFF
260 | SBC_IDE_PIO3_TWP
261 | SBC_IDE_PIO3_TCSW
262 | SBC_IDE_PIO3_TPM
263 | SBC_IDE_PIO3_TA;
264 /* set configuration for RCS2# */
265 mem_stcfg |= TS_MASK;
266 mem_stcfg &= ~TS_MASK;
267 mem_stcfg &= ~TCSOE_MASK;
268 mem_stcfg &= ~TOECS_MASK;
269 mem_stcfg |= SBC_IDE_PIO3_TCSOE | SBC_IDE_PIO3_TOECS;
270
271 break;
272
273 case 4:
274 /* set timing parameters for RCS2# */
275 mem_sttime = SBC_IDE_PIO4_TWCS
276 | SBC_IDE_PIO4_TCSH
277 | SBC_IDE_PIO4_TCSOFF
278 | SBC_IDE_PIO4_TWP
279 | SBC_IDE_PIO4_TCSW
280 | SBC_IDE_PIO4_TPM
281 | SBC_IDE_PIO4_TA;
282 /* set configuration for RCS2# */
283 mem_stcfg &= ~TS_MASK;
284 mem_stcfg &= ~TCSOE_MASK;
285 mem_stcfg &= ~TOECS_MASK;
286 mem_stcfg |= SBC_IDE_PIO4_TCSOE | SBC_IDE_PIO4_TOECS;
287 break;
288 }
289
290 au_writel(mem_sttime,MEM_STTIME2);
291 au_writel(mem_stcfg,MEM_STCFG2);
292
293 spin_unlock_irqrestore(&ide_tune_drive_spin_lock, flags);
294
295 speed = pio + XFER_PIO_0;
296 ide_config_drive_speed(drive, speed);
297} 178}
298 179
299static int auide_tune_chipset (ide_drive_t *drive, u8 speed) 180static int auide_tune_chipset (ide_drive_t *drive, u8 speed)
300{ 181{
301 u8 mode = 0; 182 int mem_sttime;
302 int mem_sttime; 183 int mem_stcfg;
303 int mem_stcfg; 184 unsigned long mode;
304 unsigned long flags; 185
305#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 186#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
306 struct hd_driveid *id = drive->id; 187 if (ide_use_dma(drive))
307 188 mode = ide_dma_speed(drive, 0);
308 /*
309 * Now see what the current drive is capable of,
310 * selecting UDMA only if the mate said it was ok.
311 */
312 if (id && (id->capability & 1) && drive->autodma &&
313 !__ide_dma_bad_drive(drive)) {
314 if (!mode && (id->field_valid & 2) && (id->dma_mword & 7)) {
315 if (id->dma_mword & 4)
316 mode = XFER_MW_DMA_2;
317 else if (id->dma_mword & 2)
318 mode = XFER_MW_DMA_1;
319 else if (id->dma_mword & 1)
320 mode = XFER_MW_DMA_0;
321 }
322 }
323#endif 189#endif
324 190
325 spin_lock_irqsave(&ide_tune_chipset_spin_lock, flags); 191 mem_sttime = 0;
192 mem_stcfg = au_readl(MEM_STCFG2);
326 193
327 mem_sttime = 0; 194 if (speed >= XFER_PIO_0 && speed <= XFER_PIO_4) {
328 mem_stcfg = au_readl(MEM_STCFG2); 195 auide_tune_drive(drive, speed - XFER_PIO_0);
329 196 return 0;
330 switch(speed) { 197 }
331 case XFER_PIO_4: 198
332 case XFER_PIO_3: 199 switch(speed) {
333 case XFER_PIO_2:
334 case XFER_PIO_1:
335 case XFER_PIO_0:
336 auide_tune_drive(drive, (speed - XFER_PIO_0));
337 break;
338#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 200#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
339 case XFER_MW_DMA_2: 201 case XFER_MW_DMA_2:
340 /* set timing parameters for RCS2# */ 202 mem_sttime = SBC_IDE_TIMING(MDMA2);
341 mem_sttime = SBC_IDE_MDMA2_TWCS 203
342 | SBC_IDE_MDMA2_TCSH 204 /* set configuration for RCS2# */
343 | SBC_IDE_MDMA2_TCSOFF 205 mem_stcfg &= ~TS_MASK;
344 | SBC_IDE_MDMA2_TWP 206 mem_stcfg &= ~TCSOE_MASK;
345 | SBC_IDE_MDMA2_TCSW 207 mem_stcfg &= ~TOECS_MASK;
346 | SBC_IDE_MDMA2_TPM 208 mem_stcfg |= SBC_IDE_MDMA2_TCSOE | SBC_IDE_MDMA2_TOECS;
347 | SBC_IDE_MDMA2_TA; 209
348 /* set configuration for RCS2# */ 210 mode = XFER_MW_DMA_2;
349 mem_stcfg &= ~TS_MASK; 211 break;
350 mem_stcfg &= ~TCSOE_MASK; 212 case XFER_MW_DMA_1:
351 mem_stcfg &= ~TOECS_MASK; 213 mem_sttime = SBC_IDE_TIMING(MDMA1);
352 mem_stcfg |= SBC_IDE_MDMA2_TCSOE | SBC_IDE_MDMA2_TOECS; 214
353 215 /* set configuration for RCS2# */
354 mode = XFER_MW_DMA_2; 216 mem_stcfg &= ~TS_MASK;
355 break; 217 mem_stcfg &= ~TCSOE_MASK;
356 case XFER_MW_DMA_1: 218 mem_stcfg &= ~TOECS_MASK;
357 /* set timing parameters for RCS2# */ 219 mem_stcfg |= SBC_IDE_MDMA1_TCSOE | SBC_IDE_MDMA1_TOECS;
358 mem_sttime = SBC_IDE_MDMA1_TWCS 220
359 | SBC_IDE_MDMA1_TCSH 221 mode = XFER_MW_DMA_1;
360 | SBC_IDE_MDMA1_TCSOFF 222 break;
361 | SBC_IDE_MDMA1_TWP 223 case XFER_MW_DMA_0:
362 | SBC_IDE_MDMA1_TCSW 224 mem_sttime = SBC_IDE_TIMING(MDMA0);
363 | SBC_IDE_MDMA1_TPM 225
364 | SBC_IDE_MDMA1_TA; 226 /* set configuration for RCS2# */
365 /* set configuration for RCS2# */ 227 mem_stcfg |= TS_MASK;
366 mem_stcfg &= ~TS_MASK; 228 mem_stcfg &= ~TCSOE_MASK;
367 mem_stcfg &= ~TCSOE_MASK; 229 mem_stcfg &= ~TOECS_MASK;
368 mem_stcfg &= ~TOECS_MASK; 230 mem_stcfg |= SBC_IDE_MDMA0_TCSOE | SBC_IDE_MDMA0_TOECS;
369 mem_stcfg |= SBC_IDE_MDMA1_TCSOE | SBC_IDE_MDMA1_TOECS; 231
370 232 mode = XFER_MW_DMA_0;
371 mode = XFER_MW_DMA_1; 233 break;
372 break;
373 case XFER_MW_DMA_0:
374 /* set timing parameters for RCS2# */
375 mem_sttime = SBC_IDE_MDMA0_TWCS
376 | SBC_IDE_MDMA0_TCSH
377 | SBC_IDE_MDMA0_TCSOFF
378 | SBC_IDE_MDMA0_TWP
379 | SBC_IDE_MDMA0_TCSW
380 | SBC_IDE_MDMA0_TPM
381 | SBC_IDE_MDMA0_TA;
382 /* set configuration for RCS2# */
383 mem_stcfg |= TS_MASK;
384 mem_stcfg &= ~TCSOE_MASK;
385 mem_stcfg &= ~TOECS_MASK;
386 mem_stcfg |= SBC_IDE_MDMA0_TCSOE | SBC_IDE_MDMA0_TOECS;
387
388 mode = XFER_MW_DMA_0;
389 break;
390#endif 234#endif
391 default: 235 default:
392 return 1; 236 return 1;
393 } 237 }
394 238
395 /* 239 if (ide_config_drive_speed(drive, mode))
396 * Tell the drive to switch to the new mode; abort on failure. 240 return 1;
397 */
398 if (!mode || ide_config_drive_speed(drive, mode))
399 {
400 return 1; /* failure */
401 }
402
403
404 au_writel(mem_sttime,MEM_STTIME2);
405 au_writel(mem_stcfg,MEM_STCFG2);
406 241
407 spin_unlock_irqrestore(&ide_tune_chipset_spin_lock, flags); 242 au_writel(mem_sttime,MEM_STTIME2);
243 au_writel(mem_stcfg,MEM_STCFG2);
408 244
409 return 0; 245 return 0;
410} 246}
411 247
412/* 248/*
413 * Multi-Word DMA + DbDMA functions 249 * Multi-Word DMA + DbDMA functions
414 */ 250 */
415#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
416 251
417static int in_drive_list(struct hd_driveid *id, 252#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
418 const struct drive_list_entry *drive_table)
419{
420 for ( ; drive_table->id_model ; drive_table++){
421 if ((!strcmp(drive_table->id_model, id->model)) &&
422 ((strstr(drive_table->id_firmware, id->fw_rev)) ||
423 (!strcmp(drive_table->id_firmware, "ALL")))
424 )
425 return 1;
426 }
427 return 0;
428}
429 253
430static int auide_build_sglist(ide_drive_t *drive, struct request *rq) 254static int auide_build_sglist(ide_drive_t *drive, struct request *rq)
431{ 255{
432 ide_hwif_t *hwif = drive->hwif; 256 ide_hwif_t *hwif = drive->hwif;
433 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 257 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
434 struct scatterlist *sg = hwif->sg_table; 258 struct scatterlist *sg = hwif->sg_table;
435 259
436 ide_map_sg(drive, rq); 260 ide_map_sg(drive, rq);
437 261
438 if (rq_data_dir(rq) == READ) 262 if (rq_data_dir(rq) == READ)
439 hwif->sg_dma_direction = DMA_FROM_DEVICE; 263 hwif->sg_dma_direction = DMA_FROM_DEVICE;
440 else 264 else
441 hwif->sg_dma_direction = DMA_TO_DEVICE; 265 hwif->sg_dma_direction = DMA_TO_DEVICE;
442 266
443 return dma_map_sg(ahwif->dev, sg, hwif->sg_nents, 267 return dma_map_sg(ahwif->dev, sg, hwif->sg_nents,
444 hwif->sg_dma_direction); 268 hwif->sg_dma_direction);
445} 269}
446 270
447static int auide_build_dmatable(ide_drive_t *drive) 271static int auide_build_dmatable(ide_drive_t *drive)
448{ 272{
449 int i, iswrite, count = 0; 273 int i, iswrite, count = 0;
450 ide_hwif_t *hwif = HWIF(drive); 274 ide_hwif_t *hwif = HWIF(drive);
451 275
452 struct request *rq = HWGROUP(drive)->rq; 276 struct request *rq = HWGROUP(drive)->rq;
453 277
454 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 278 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
455 struct scatterlist *sg; 279 struct scatterlist *sg;
456 280
457 iswrite = (rq_data_dir(rq) == WRITE); 281 iswrite = (rq_data_dir(rq) == WRITE);
458 /* Save for interrupt context */ 282 /* Save for interrupt context */
459 ahwif->drive = drive; 283 ahwif->drive = drive;
460 284
461 /* Build sglist */ 285 /* Build sglist */
462 hwif->sg_nents = i = auide_build_sglist(drive, rq); 286 hwif->sg_nents = i = auide_build_sglist(drive, rq);
463 287
464 if (!i) 288 if (!i)
465 return 0; 289 return 0;
466 290
467 /* fill the descriptors */ 291 /* fill the descriptors */
468 sg = hwif->sg_table; 292 sg = hwif->sg_table;
469 while (i && sg_dma_len(sg)) { 293 while (i && sg_dma_len(sg)) {
470 u32 cur_addr; 294 u32 cur_addr;
471 u32 cur_len; 295 u32 cur_len;
472 296
473 cur_addr = sg_dma_address(sg); 297 cur_addr = sg_dma_address(sg);
474 cur_len = sg_dma_len(sg); 298 cur_len = sg_dma_len(sg);
475 299
476 while (cur_len) { 300 while (cur_len) {
477 u32 flags = DDMA_FLAGS_NOIE; 301 u32 flags = DDMA_FLAGS_NOIE;
478 unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00; 302 unsigned int tc = (cur_len < 0xfe00)? cur_len: 0xfe00;
479 303
480 if (++count >= PRD_ENTRIES) { 304 if (++count >= PRD_ENTRIES) {
481 printk(KERN_WARNING "%s: DMA table too small\n", 305 printk(KERN_WARNING "%s: DMA table too small\n",
482 drive->name); 306 drive->name);
483 goto use_pio_instead; 307 goto use_pio_instead;
484 } 308 }
485 309
486 /* Lets enable intr for the last descriptor only */ 310 /* Lets enable intr for the last descriptor only */
487 if (1==i) 311 if (1==i)
488 flags = DDMA_FLAGS_IE; 312 flags = DDMA_FLAGS_IE;
489 else 313 else
490 flags = DDMA_FLAGS_NOIE; 314 flags = DDMA_FLAGS_NOIE;
491 315
492 if (iswrite) { 316 if (iswrite) {
493 if(!put_source_flags(ahwif->tx_chan, 317 if(!put_source_flags(ahwif->tx_chan,
494 (void*)(page_address(sg->page) 318 (void*)(page_address(sg->page)
495 + sg->offset), 319 + sg->offset),
496 tc, flags)) { 320 tc, flags)) {
497 printk(KERN_ERR "%s failed %d\n", 321 printk(KERN_ERR "%s failed %d\n",
498 __FUNCTION__, __LINE__); 322 __FUNCTION__, __LINE__);
499 } 323 }
500 } else 324 } else
501 { 325 {
502 if(!put_dest_flags(ahwif->rx_chan, 326 if(!put_dest_flags(ahwif->rx_chan,
503 (void*)(page_address(sg->page) 327 (void*)(page_address(sg->page)
504 + sg->offset), 328 + sg->offset),
505 tc, flags)) { 329 tc, flags)) {
506 printk(KERN_ERR "%s failed %d\n", 330 printk(KERN_ERR "%s failed %d\n",
507 __FUNCTION__, __LINE__); 331 __FUNCTION__, __LINE__);
508 } 332 }
509 } 333 }
510 334
511 cur_addr += tc; 335 cur_addr += tc;
512 cur_len -= tc; 336 cur_len -= tc;
513 } 337 }
514 sg++; 338 sg++;
515 i--; 339 i--;
516 } 340 }
517 341
518 if (count) 342 if (count)
519 return 1; 343 return 1;
520 344
521use_pio_instead: 345 use_pio_instead:
522 dma_unmap_sg(ahwif->dev, 346 dma_unmap_sg(ahwif->dev,
523 hwif->sg_table, 347 hwif->sg_table,
524 hwif->sg_nents, 348 hwif->sg_nents,
525 hwif->sg_dma_direction); 349 hwif->sg_dma_direction);
526 350
527 return 0; /* revert to PIO for this request */ 351 return 0; /* revert to PIO for this request */
528} 352}
529 353
530static int auide_dma_end(ide_drive_t *drive) 354static int auide_dma_end(ide_drive_t *drive)
531{ 355{
532 ide_hwif_t *hwif = HWIF(drive); 356 ide_hwif_t *hwif = HWIF(drive);
533 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data; 357 _auide_hwif *ahwif = (_auide_hwif*)hwif->hwif_data;
534 358
535 if (hwif->sg_nents) { 359 if (hwif->sg_nents) {
536 dma_unmap_sg(ahwif->dev, hwif->sg_table, hwif->sg_nents, 360 dma_unmap_sg(ahwif->dev, hwif->sg_table, hwif->sg_nents,
537 hwif->sg_dma_direction); 361 hwif->sg_dma_direction);
538 hwif->sg_nents = 0; 362 hwif->sg_nents = 0;
539 } 363 }
540 364
541 return 0; 365 return 0;
542} 366}
543 367
544static void auide_dma_start(ide_drive_t *drive ) 368static void auide_dma_start(ide_drive_t *drive )
545{ 369{
546// printk("%s\n", __FUNCTION__);
547} 370}
548 371
549ide_startstop_t auide_dma_intr(ide_drive_t *drive)
550{
551 //printk("%s\n", __FUNCTION__);
552
553 u8 stat = 0, dma_stat = 0;
554
555 dma_stat = HWIF(drive)->ide_dma_end(drive);
556 stat = HWIF(drive)->INB(IDE_STATUS_REG); /* get drive status */
557 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) {
558 if (!dma_stat) {
559 struct request *rq = HWGROUP(drive)->rq;
560
561 ide_end_request(drive, 1, rq->nr_sectors);
562 return ide_stopped;
563 }
564 printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n",
565 drive->name, dma_stat);
566 }
567 return ide_error(drive, "dma_intr", stat);
568}
569 372
570static void auide_dma_exec_cmd(ide_drive_t *drive, u8 command) 373static void auide_dma_exec_cmd(ide_drive_t *drive, u8 command)
571{ 374{
572 //printk("%s\n", __FUNCTION__); 375 /* issue cmd to drive */
573 376 ide_execute_command(drive, command, &ide_dma_intr,
574 /* issue cmd to drive */ 377 (2*WAIT_CMD), NULL);
575 ide_execute_command(drive, command, &auide_dma_intr,
576 (2*WAIT_CMD), NULL);
577} 378}
578 379
579static int auide_dma_setup(ide_drive_t *drive) 380static int auide_dma_setup(ide_drive_t *drive)
580{ 381{
581// printk("%s\n", __FUNCTION__); 382 struct request *rq = HWGROUP(drive)->rq;
582
583 if (drive->media != ide_disk)
584 return 1;
585
586 if (!auide_build_dmatable(drive))
587 /* try PIO instead of DMA */
588 return 1;
589 383
590 drive->waiting_for_dma = 1; 384 if (!auide_build_dmatable(drive)) {
385 ide_map_sg(drive, rq);
386 return 1;
387 }
591 388
592 return 0; 389 drive->waiting_for_dma = 1;
390 return 0;
593} 391}
594 392
595static int auide_dma_check(ide_drive_t *drive) 393static int auide_dma_check(ide_drive_t *drive)
596{ 394{
597// printk("%s\n", __FUNCTION__); 395 u8 speed;
598 396
599#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 397#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
600 if( !dbdma_init_done ){ 398
601 auide_hwif.white_list = in_drive_list(drive->id, 399 if( dbdma_init_done == 0 ){
602 dma_white_list); 400 auide_hwif.white_list = ide_in_drive_list(drive->id,
603 auide_hwif.black_list = in_drive_list(drive->id, 401 dma_white_list);
604 dma_black_list); 402 auide_hwif.black_list = ide_in_drive_list(drive->id,
605 auide_hwif.drive = drive; 403 dma_black_list);
606 auide_ddma_init(&auide_hwif); 404 auide_hwif.drive = drive;
607 dbdma_init_done = 1; 405 auide_ddma_init(&auide_hwif);
608 } 406 dbdma_init_done = 1;
407 }
609#endif 408#endif
610 409
611 /* Is the drive in our DMA black list? */ 410 /* Is the drive in our DMA black list? */
612 if ( auide_hwif.black_list ) { 411
613 drive->using_dma = 0; 412 if ( auide_hwif.black_list ) {
614 printk("%s found in dma_blacklist[]! Disabling DMA.\n", 413 drive->using_dma = 0;
615 drive->id->model); 414
616 } 415 /* Borrowed the warning message from ide-dma.c */
617 else
618 drive->using_dma = 1;
619 416
620 return HWIF(drive)->ide_dma_host_on(drive); 417 printk(KERN_WARNING "%s: Disabling DMA for %s (blacklisted)\n",
418 drive->name, drive->id->model);
419 }
420 else
421 drive->using_dma = 1;
422
423 speed = ide_find_best_mode(drive, XFER_PIO | XFER_MWDMA);
424
425 if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
426 return HWIF(drive)->ide_dma_on(drive);
427
428 return HWIF(drive)->ide_dma_off_quietly(drive);
621} 429}
622 430
623static int auide_dma_test_irq(ide_drive_t *drive) 431static int auide_dma_test_irq(ide_drive_t *drive)
624{ 432{
625// printk("%s\n", __FUNCTION__); 433 if (drive->waiting_for_dma == 0)
626 434 printk(KERN_WARNING "%s: ide_dma_test_irq \
627 if (!drive->waiting_for_dma)
628 printk(KERN_WARNING "%s: ide_dma_test_irq \
629 called while not waiting\n", drive->name); 435 called while not waiting\n", drive->name);
630 436
631 /* If dbdma didn't execute the STOP command yet, the 437 /* If dbdma didn't execute the STOP command yet, the
632 * active bit is still set 438 * active bit is still set
633 */ 439 */
634 drive->waiting_for_dma++; 440 drive->waiting_for_dma++;
635 if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) { 441 if (drive->waiting_for_dma >= DMA_WAIT_TIMEOUT) {
636 printk(KERN_WARNING "%s: timeout waiting for ddma to \ 442 printk(KERN_WARNING "%s: timeout waiting for ddma to \
637 complete\n", drive->name); 443 complete\n", drive->name);
638 return 1; 444 return 1;
639 } 445 }
640 udelay(10); 446 udelay(10);
641 return 0; 447 return 0;
642} 448}
643 449
644static int auide_dma_host_on(ide_drive_t *drive) 450static int auide_dma_host_on(ide_drive_t *drive)
645{ 451{
646// printk("%s\n", __FUNCTION__); 452 return 0;
647 return 0;
648} 453}
649 454
650static int auide_dma_on(ide_drive_t *drive) 455static int auide_dma_on(ide_drive_t *drive)
651{ 456{
652// printk("%s\n", __FUNCTION__); 457 drive->using_dma = 1;
653 drive->using_dma = 1; 458 return auide_dma_host_on(drive);
654 return auide_dma_host_on(drive);
655} 459}
656 460
657 461
658static int auide_dma_host_off(ide_drive_t *drive) 462static int auide_dma_host_off(ide_drive_t *drive)
659{ 463{
660// printk("%s\n", __FUNCTION__); 464 return 0;
661 return 0;
662} 465}
663 466
664static int auide_dma_off_quietly(ide_drive_t *drive) 467static int auide_dma_off_quietly(ide_drive_t *drive)
665{ 468{
666// printk("%s\n", __FUNCTION__); 469 drive->using_dma = 0;
667 drive->using_dma = 0; 470 return auide_dma_host_off(drive);
668 return auide_dma_host_off(drive);
669} 471}
670 472
671static int auide_dma_lostirq(ide_drive_t *drive) 473static int auide_dma_lostirq(ide_drive_t *drive)
672{ 474{
673// printk("%s\n", __FUNCTION__); 475 printk(KERN_ERR "%s: IRQ lost\n", drive->name);
674 476 return 0;
675 printk(KERN_ERR "%s: IRQ lost\n", drive->name);
676 return 0;
677} 477}
678 478
679static void auide_ddma_tx_callback(int irq, void *param, struct pt_regs *regs) 479static void auide_ddma_tx_callback(int irq, void *param, struct pt_regs *regs)
680{ 480{
681// printk("%s\n", __FUNCTION__); 481 _auide_hwif *ahwif = (_auide_hwif*)param;
682 482 ahwif->drive->waiting_for_dma = 0;
683 _auide_hwif *ahwif = (_auide_hwif*)param;
684 ahwif->drive->waiting_for_dma = 0;
685 return;
686} 483}
687 484
688static void auide_ddma_rx_callback(int irq, void *param, struct pt_regs *regs) 485static void auide_ddma_rx_callback(int irq, void *param, struct pt_regs *regs)
689{ 486{
690// printk("%s\n", __FUNCTION__); 487 _auide_hwif *ahwif = (_auide_hwif*)param;
488 ahwif->drive->waiting_for_dma = 0;
489}
490
491#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
691 492
692 _auide_hwif *ahwif = (_auide_hwif*)param; 493static void auide_init_dbdma_dev(dbdev_tab_t *dev, u32 dev_id, u32 tsize, u32 devwidth, u32 flags)
693 ahwif->drive->waiting_for_dma = 0; 494{
694 return; 495 dev->dev_id = dev_id;
496 dev->dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
497 dev->dev_intlevel = 0;
498 dev->dev_intpolarity = 0;
499 dev->dev_tsize = tsize;
500 dev->dev_devwidth = devwidth;
501 dev->dev_flags = flags;
695} 502}
503
504#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
696 505
697static int auide_dma_timeout(ide_drive_t *drive) 506static int auide_dma_timeout(ide_drive_t *drive)
698{ 507{
699// printk("%s\n", __FUNCTION__); 508// printk("%s\n", __FUNCTION__);
700 509
701 printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); 510 printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name);
702 511
703 if (HWIF(drive)->ide_dma_test_irq(drive)) 512 if (HWIF(drive)->ide_dma_test_irq(drive))
704 return 0; 513 return 0;
705 514
706 return HWIF(drive)->ide_dma_end(drive); 515 return HWIF(drive)->ide_dma_end(drive);
707} 516}
708#endif /* end CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */ 517
709 518
519static int auide_ddma_init(_auide_hwif *auide) {
520
521 dbdev_tab_t source_dev_tab, target_dev_tab;
522 u32 dev_id, tsize, devwidth, flags;
523 ide_hwif_t *hwif = auide->hwif;
710 524
711static int auide_ddma_init( _auide_hwif *auide ) 525 dev_id = AU1XXX_ATA_DDMA_REQ;
712{
713// printk("%s\n", __FUNCTION__);
714 526
715 dbdev_tab_t source_dev_tab; 527 if (auide->white_list || auide->black_list) {
716#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 528 tsize = 8;
717 dbdev_tab_t target_dev_tab; 529 devwidth = 32;
718 ide_hwif_t *hwif = auide->hwif; 530 }
719 char warning_output [2][80]; 531 else {
720 int i; 532 tsize = 1;
721#endif 533 devwidth = 16;
534
535 printk(KERN_ERR "au1xxx-ide: %s is not on ide driver whitelist.\n",auide_hwif.drive->id->model);
536 printk(KERN_ERR " please read 'Documentation/mips/AU1xxx_IDE.README'");
537 }
722 538
723 /* Add our custom device to DDMA device table */ 539#ifdef IDE_AU1XXX_BURSTMODE
724 /* Create our new device entries in the table */ 540 flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
725#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
726 source_dev_tab.dev_id = AU1XXX_ATA_DDMA_REQ;
727
728 if( auide->white_list || auide->black_list ){
729 source_dev_tab.dev_tsize = 8;
730 source_dev_tab.dev_devwidth = 32;
731 source_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
732 source_dev_tab.dev_intlevel = 0;
733 source_dev_tab.dev_intpolarity = 0;
734
735 /* init device table for target - static bus controller - */
736 target_dev_tab.dev_id = DSCR_CMD0_ALWAYS;
737 target_dev_tab.dev_tsize = 8;
738 target_dev_tab.dev_devwidth = 32;
739 target_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
740 target_dev_tab.dev_intlevel = 0;
741 target_dev_tab.dev_intpolarity = 0;
742 target_dev_tab.dev_flags = DEV_FLAGS_ANYUSE;
743 }
744 else{
745 source_dev_tab.dev_tsize = 1;
746 source_dev_tab.dev_devwidth = 16;
747 source_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
748 source_dev_tab.dev_intlevel = 0;
749 source_dev_tab.dev_intpolarity = 0;
750
751 /* init device table for target - static bus controller - */
752 target_dev_tab.dev_id = DSCR_CMD0_ALWAYS;
753 target_dev_tab.dev_tsize = 1;
754 target_dev_tab.dev_devwidth = 16;
755 target_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
756 target_dev_tab.dev_intlevel = 0;
757 target_dev_tab.dev_intpolarity = 0;
758 target_dev_tab.dev_flags = DEV_FLAGS_ANYUSE;
759
760 sprintf(&warning_output[0][0],
761 "%s is not on ide driver white list.",
762 auide_hwif.drive->id->model);
763 for ( i=strlen(&warning_output[0][0]) ; i<76; i++ ){
764 sprintf(&warning_output[0][i]," ");
765 }
766
767 sprintf(&warning_output[1][0],
768 "To add %s please read 'Documentation/mips/AU1xxx_IDE.README'.",
769 auide_hwif.drive->id->model);
770 for ( i=strlen(&warning_output[1][0]) ; i<76; i++ ){
771 sprintf(&warning_output[1][i]," ");
772 }
773
774 printk("\n****************************************");
775 printk("****************************************\n");
776 printk("* %s *\n",&warning_output[0][0]);
777 printk("* Switch to safe MWDMA Mode! ");
778 printk(" *\n");
779 printk("* %s *\n",&warning_output[1][0]);
780 printk("****************************************");
781 printk("****************************************\n\n");
782 }
783#else 541#else
784 source_dev_tab.dev_id = DSCR_CMD0_ALWAYS; 542 flags = DEV_FLAGS_SYNC;
785 source_dev_tab.dev_tsize = 8;
786 source_dev_tab.dev_devwidth = 32;
787 source_dev_tab.dev_physaddr = (u32)AU1XXX_ATA_PHYS_ADDR;
788 source_dev_tab.dev_intlevel = 0;
789 source_dev_tab.dev_intpolarity = 0;
790#endif 543#endif
791 544
792#if CONFIG_BLK_DEV_IDE_AU1XXX_BURSTABLE_ON 545 /* setup dev_tab for tx channel */
793 /* set flags for tx channel */ 546 auide_init_dbdma_dev( &source_dev_tab,
794 source_dev_tab.dev_flags = DEV_FLAGS_OUT 547 dev_id,
795 | DEV_FLAGS_SYNC 548 tsize, devwidth, DEV_FLAGS_OUT | flags);
796 | DEV_FLAGS_BURSTABLE; 549 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
797 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab ); 550
798 /* set flags for rx channel */ 551 auide_init_dbdma_dev( &source_dev_tab,
799 source_dev_tab.dev_flags = DEV_FLAGS_IN 552 dev_id,
800 | DEV_FLAGS_SYNC 553 tsize, devwidth, DEV_FLAGS_IN | flags);
801 | DEV_FLAGS_BURSTABLE; 554 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
802 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab ); 555
556 /* We also need to add a target device for the DMA */
557 auide_init_dbdma_dev( &target_dev_tab,
558 (u32)DSCR_CMD0_ALWAYS,
559 tsize, devwidth, DEV_FLAGS_ANYUSE);
560 auide->target_dev_id = au1xxx_ddma_add_device(&target_dev_tab);
561
562 /* Get a channel for TX */
563 auide->tx_chan = au1xxx_dbdma_chan_alloc(auide->target_dev_id,
564 auide->tx_dev_id,
565 auide_ddma_tx_callback,
566 (void*)auide);
567
568 /* Get a channel for RX */
569 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
570 auide->target_dev_id,
571 auide_ddma_rx_callback,
572 (void*)auide);
573
574 auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
575 NUM_DESCRIPTORS);
576 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
577 NUM_DESCRIPTORS);
578
579 hwif->dmatable_cpu = dma_alloc_coherent(auide->dev,
580 PRD_ENTRIES * PRD_BYTES, /* 1 Page */
581 &hwif->dmatable_dma, GFP_KERNEL);
582
583 au1xxx_dbdma_start( auide->tx_chan );
584 au1xxx_dbdma_start( auide->rx_chan );
585
586 return 0;
587}
803#else 588#else
804 /* set flags for tx channel */ 589
805 source_dev_tab.dev_flags = DEV_FLAGS_OUT | DEV_FLAGS_SYNC; 590static int auide_ddma_init( _auide_hwif *auide )
806 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab ); 591{
807 /* set flags for rx channel */ 592 dbdev_tab_t source_dev_tab;
808 source_dev_tab.dev_flags = DEV_FLAGS_IN | DEV_FLAGS_SYNC; 593 int flags;
809 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
810#endif
811 594
812#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 595#ifdef IDE_AU1XXX_BURSTMODE
813 596 flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE;
814 auide->target_dev_id = au1xxx_ddma_add_device(&target_dev_tab); 597#else
815 598 flags = DEV_FLAGS_SYNC;
816 /* Get a channel for TX */
817 auide->tx_chan = au1xxx_dbdma_chan_alloc(auide->target_dev_id,
818 auide->tx_dev_id,
819 auide_ddma_tx_callback,
820 (void*)auide);
821 /* Get a channel for RX */
822 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
823 auide->target_dev_id,
824 auide_ddma_rx_callback,
825 (void*)auide);
826#else /* CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA */
827 /*
828 * Note: if call back is not enabled, update ctp->cur_ptr manually
829 */
830 auide->tx_chan = au1xxx_dbdma_chan_alloc(DSCR_CMD0_ALWAYS,
831 auide->tx_dev_id,
832 NULL,
833 (void*)auide);
834 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
835 DSCR_CMD0_ALWAYS,
836 NULL,
837 (void*)auide);
838#endif 599#endif
839 auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
840 NUM_DESCRIPTORS);
841 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
842 NUM_DESCRIPTORS);
843 600
844#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 601 /* setup dev_tab for tx channel */
845 hwif->dmatable_cpu = dma_alloc_coherent(auide->dev, 602 auide_init_dbdma_dev( &source_dev_tab,
846 PRD_ENTRIES * PRD_BYTES, /* 1 Page */ 603 (u32)DSCR_CMD0_ALWAYS,
847 &hwif->dmatable_dma, GFP_KERNEL); 604 8, 32, DEV_FLAGS_OUT | flags);
848 605 auide->tx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
849 auide->sg_table = kmalloc(sizeof(struct scatterlist) * PRD_ENTRIES, 606
850 GFP_KERNEL|GFP_DMA); 607 auide_init_dbdma_dev( &source_dev_tab,
851 if (auide->sg_table == NULL) { 608 (u32)DSCR_CMD0_ALWAYS,
852 return -ENOMEM; 609 8, 32, DEV_FLAGS_IN | flags);
853 } 610 auide->rx_dev_id = au1xxx_ddma_add_device( &source_dev_tab );
854#endif 611
855 au1xxx_dbdma_start( auide->tx_chan ); 612 /* Get a channel for TX */
856 au1xxx_dbdma_start( auide->rx_chan ); 613 auide->tx_chan = au1xxx_dbdma_chan_alloc(DSCR_CMD0_ALWAYS,
857 return 0; 614 auide->tx_dev_id,
615 NULL,
616 (void*)auide);
617
618 /* Get a channel for RX */
619 auide->rx_chan = au1xxx_dbdma_chan_alloc(auide->rx_dev_id,
620 DSCR_CMD0_ALWAYS,
621 NULL,
622 (void*)auide);
623
624 auide->tx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->tx_chan,
625 NUM_DESCRIPTORS);
626 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan,
627 NUM_DESCRIPTORS);
628
629 au1xxx_dbdma_start( auide->tx_chan );
630 au1xxx_dbdma_start( auide->rx_chan );
631
632 return 0;
858} 633}
634#endif
859 635
860static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif) 636static void auide_setup_ports(hw_regs_t *hw, _auide_hwif *ahwif)
861{ 637{
862 int i; 638 int i;
863#define ide_ioreg_t unsigned long 639 unsigned long *ata_regs = hw->io_ports;
864 ide_ioreg_t *ata_regs = hw->io_ports; 640
865 641 /* FIXME? */
866 /* fixme */ 642 for (i = 0; i < IDE_CONTROL_OFFSET; i++) {
867 for (i = 0; i < IDE_CONTROL_OFFSET; i++) { 643 *ata_regs++ = ahwif->regbase + (i << AU1XXX_ATA_REG_OFFSET);
868 *ata_regs++ = (ide_ioreg_t) ahwif->regbase 644 }
869 + (ide_ioreg_t)(i << AU1XXX_ATA_REG_OFFSET); 645
870 } 646 /* set the Alternative Status register */
871 647 *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET);
872 /* set the Alternative Status register */
873 *ata_regs = (ide_ioreg_t) ahwif->regbase
874 + (ide_ioreg_t)(14 << AU1XXX_ATA_REG_OFFSET);
875} 648}
876 649
877static int au_ide_probe(struct device *dev) 650static int au_ide_probe(struct device *dev)
878{ 651{
879 struct platform_device *pdev = to_platform_device(dev); 652 struct platform_device *pdev = to_platform_device(dev);
880 _auide_hwif *ahwif = &auide_hwif; 653 _auide_hwif *ahwif = &auide_hwif;
881 ide_hwif_t *hwif; 654 ide_hwif_t *hwif;
882 struct resource *res; 655 struct resource *res;
883 int ret = 0; 656 int ret = 0;
884 657
885#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 658#if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA)
886 char *mode = "MWDMA2"; 659 char *mode = "MWDMA2";
887#elif defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA) 660#elif defined(CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA)
888 char *mode = "PIO+DDMA(offload)"; 661 char *mode = "PIO+DDMA(offload)";
889#endif 662#endif
890 663
891 memset(&auide_hwif, 0, sizeof(_auide_hwif)); 664 memset(&auide_hwif, 0, sizeof(_auide_hwif));
892 auide_hwif.dev = 0; 665 auide_hwif.dev = 0;
893 666
894 ahwif->dev = dev; 667 ahwif->dev = dev;
895 ahwif->irq = platform_get_irq(pdev, 0); 668 ahwif->irq = platform_get_irq(pdev, 0);
@@ -902,11 +675,11 @@ static int au_ide_probe(struct device *dev)
902 goto out; 675 goto out;
903 } 676 }
904 677
905 if (!request_mem_region (res->start, res->end-res->start, pdev->name)) { 678 if (!request_mem_region (res->start, res->end-res->start, pdev->name)) {
906 pr_debug("%s: request_mem_region failed\n", DRV_NAME); 679 pr_debug("%s: request_mem_region failed\n", DRV_NAME);
907 ret = -EBUSY; 680 ret = -EBUSY;
908 goto out; 681 goto out;
909 } 682 }
910 683
911 ahwif->regbase = (u32)ioremap(res->start, res->end-res->start); 684 ahwif->regbase = (u32)ioremap(res->start, res->end-res->start);
912 if (ahwif->regbase == 0) { 685 if (ahwif->regbase == 0) {
@@ -914,130 +687,92 @@ static int au_ide_probe(struct device *dev)
914 goto out; 687 goto out;
915 } 688 }
916 689
917 hwif = &ide_hwifs[pdev->id]; 690 /* FIXME: This might possibly break PCMCIA IDE devices */
691
692 hwif = &ide_hwifs[pdev->id];
918 hw_regs_t *hw = &hwif->hw; 693 hw_regs_t *hw = &hwif->hw;
919 hwif->irq = hw->irq = ahwif->irq; 694 hwif->irq = hw->irq = ahwif->irq;
920 hwif->chipset = ide_au1xxx; 695 hwif->chipset = ide_au1xxx;
921 696
922 auide_setup_ports(hw, ahwif); 697 auide_setup_ports(hw, ahwif);
923 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); 698 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports));
924 699
925#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ 700 hwif->ultra_mask = 0x0; /* Disable Ultra DMA */
926 hwif->rqsize = CONFIG_BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ;
927 hwif->rqsize = ((hwif->rqsize > AU1XXX_ATA_RQSIZE)
928 || (hwif->rqsize < 32)) ? AU1XXX_ATA_RQSIZE : hwif->rqsize;
929#else /* if kernel config is not set */
930 hwif->rqsize = AU1XXX_ATA_RQSIZE;
931#endif
932
933 hwif->ultra_mask = 0x0; /* Disable Ultra DMA */
934#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 701#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
935 hwif->mwdma_mask = 0x07; /* Multimode-2 DMA */ 702 hwif->mwdma_mask = 0x07; /* Multimode-2 DMA */
936 hwif->swdma_mask = 0x07; 703 hwif->swdma_mask = 0x00;
937#else 704#else
938 hwif->mwdma_mask = 0x0; 705 hwif->mwdma_mask = 0x0;
939 hwif->swdma_mask = 0x0; 706 hwif->swdma_mask = 0x0;
707#endif
708
709 hwif->noprobe = 0;
710 hwif->drives[0].unmask = 1;
711 hwif->drives[1].unmask = 1;
712
713 /* hold should be on in all cases */
714 hwif->hold = 1;
715 hwif->mmio = 2;
716
717 /* If the user has selected DDMA assisted copies,
718 then set up a few local I/O function entry points
719 */
720
721#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
722 hwif->INSW = auide_insw;
723 hwif->OUTSW = auide_outsw;
940#endif 724#endif
941 //hwif->noprobe = !hwif->io_ports[IDE_DATA_OFFSET]; 725
942 hwif->noprobe = 0; 726 hwif->tuneproc = &auide_tune_drive;
943 hwif->drives[0].unmask = 1; 727 hwif->speedproc = &auide_tune_chipset;
944 hwif->drives[1].unmask = 1;
945
946 /* hold should be on in all cases */
947 hwif->hold = 1;
948 hwif->mmio = 2;
949
950 /* set up local I/O function entry points */
951 hwif->INB = auide_inb;
952 hwif->INW = auide_inw;
953 hwif->INL = auide_inl;
954 hwif->INSW = auide_insw;
955 hwif->INSL = auide_insl;
956 hwif->OUTB = auide_outb;
957 hwif->OUTBSYNC = auide_outbsync;
958 hwif->OUTW = auide_outw;
959 hwif->OUTL = auide_outl;
960 hwif->OUTSW = auide_outsw;
961 hwif->OUTSL = auide_outsl;
962
963 hwif->tuneproc = &auide_tune_drive;
964 hwif->speedproc = &auide_tune_chipset;
965 728
966#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 729#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
967 hwif->ide_dma_off_quietly = &auide_dma_off_quietly; 730 hwif->ide_dma_off_quietly = &auide_dma_off_quietly;
968 hwif->ide_dma_timeout = &auide_dma_timeout; 731 hwif->ide_dma_timeout = &auide_dma_timeout;
969 732
970 hwif->ide_dma_check = &auide_dma_check; 733 hwif->ide_dma_check = &auide_dma_check;
971 hwif->dma_exec_cmd = &auide_dma_exec_cmd; 734 hwif->dma_exec_cmd = &auide_dma_exec_cmd;
972 hwif->dma_start = &auide_dma_start; 735 hwif->dma_start = &auide_dma_start;
973 hwif->ide_dma_end = &auide_dma_end; 736 hwif->ide_dma_end = &auide_dma_end;
974 hwif->dma_setup = &auide_dma_setup; 737 hwif->dma_setup = &auide_dma_setup;
975 hwif->ide_dma_test_irq = &auide_dma_test_irq; 738 hwif->ide_dma_test_irq = &auide_dma_test_irq;
976 hwif->ide_dma_host_off = &auide_dma_host_off; 739 hwif->ide_dma_host_off = &auide_dma_host_off;
977 hwif->ide_dma_host_on = &auide_dma_host_on; 740 hwif->ide_dma_host_on = &auide_dma_host_on;
978 hwif->ide_dma_lostirq = &auide_dma_lostirq; 741 hwif->ide_dma_lostirq = &auide_dma_lostirq;
979 hwif->ide_dma_on = &auide_dma_on; 742 hwif->ide_dma_on = &auide_dma_on;
980 743
981 hwif->autodma = 1; 744 hwif->autodma = 1;
982 hwif->drives[0].autodma = hwif->autodma; 745 hwif->drives[0].autodma = hwif->autodma;
983 hwif->drives[1].autodma = hwif->autodma; 746 hwif->drives[1].autodma = hwif->autodma;
984 hwif->atapi_dma = 1; 747 hwif->atapi_dma = 1;
985 hwif->drives[0].using_dma = 1; 748
986 hwif->drives[1].using_dma = 1;
987#else /* !CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */ 749#else /* !CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA */
988 hwif->autodma = 0; 750 hwif->autodma = 0;
989 hwif->channel = 0; 751 hwif->channel = 0;
990 hwif->hold = 1; 752 hwif->hold = 1;
991 hwif->select_data = 0; /* no chipset-specific code */ 753 hwif->select_data = 0; /* no chipset-specific code */
992 hwif->config_data = 0; /* no chipset-specific code */ 754 hwif->config_data = 0; /* no chipset-specific code */
993 755
994 hwif->drives[0].autodma = 0; 756 hwif->drives[0].autodma = 0;
995 hwif->drives[0].drive_data = 0; /* no drive data */ 757 hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */
996 hwif->drives[0].using_dma = 0;
997 hwif->drives[0].waiting_for_dma = 0;
998 hwif->drives[0].autotune = 1; /* 1=autotune, 2=noautotune, 0=default */
999 /* secondary hdd not supported */
1000 hwif->drives[1].autodma = 0;
1001
1002 hwif->drives[1].drive_data = 0;
1003 hwif->drives[1].using_dma = 0;
1004 hwif->drives[1].waiting_for_dma = 0;
1005 hwif->drives[1].autotune = 2; /* 1=autotune, 2=noautotune, 0=default */
1006#endif
1007 hwif->drives[0].io_32bit = 0; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
1008 hwif->drives[1].io_32bit = 0; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
1009
1010 /*Register Driver with PM Framework*/
1011#ifdef CONFIG_PM
1012 auide_hwif.pm.lock = SPIN_LOCK_UNLOCKED;
1013 auide_hwif.pm.stopped = 0;
1014
1015 auide_hwif.pm.dev = new_au1xxx_power_device( "ide",
1016 &au1200ide_pm_callback,
1017 NULL);
1018 if ( auide_hwif.pm.dev == NULL )
1019 printk(KERN_INFO "Unable to create a power management \
1020 device entry for the au1200-IDE.\n");
1021 else
1022 printk(KERN_INFO "Power management device entry for the \
1023 au1200-IDE loaded.\n");
1024#endif 758#endif
759 hwif->drives[0].no_io_32bit = 1;
1025 760
1026 auide_hwif.hwif = hwif; 761 auide_hwif.hwif = hwif;
1027 hwif->hwif_data = &auide_hwif; 762 hwif->hwif_data = &auide_hwif;
1028 763
1029#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA 764#ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA
1030 auide_ddma_init(&auide_hwif); 765 auide_ddma_init(&auide_hwif);
1031 dbdma_init_done = 1; 766 dbdma_init_done = 1;
1032#endif 767#endif
1033 768
1034 probe_hwif_init(hwif); 769 probe_hwif_init(hwif);
1035 dev_set_drvdata(dev, hwif); 770 dev_set_drvdata(dev, hwif);
1036 771
1037 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode ); 772 printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
1038 773
1039out: 774 out:
1040 return ret; 775 return ret;
1041} 776}
1042 777
1043static int au_ide_remove(struct device *dev) 778static int au_ide_remove(struct device *dev)
@@ -1045,7 +780,7 @@ static int au_ide_remove(struct device *dev)
1045 struct platform_device *pdev = to_platform_device(dev); 780 struct platform_device *pdev = to_platform_device(dev);
1046 struct resource *res; 781 struct resource *res;
1047 ide_hwif_t *hwif = dev_get_drvdata(dev); 782 ide_hwif_t *hwif = dev_get_drvdata(dev);
1048 _auide_hwif *ahwif = &auide_hwif; 783 _auide_hwif *ahwif = &auide_hwif;
1049 784
1050 ide_unregister(hwif - ide_hwifs); 785 ide_unregister(hwif - ide_hwifs);
1051 786
@@ -1069,180 +804,11 @@ static int __init au_ide_init(void)
1069 return driver_register(&au1200_ide_driver); 804 return driver_register(&au1200_ide_driver);
1070} 805}
1071 806
1072static void __init au_ide_exit(void) 807static void __exit au_ide_exit(void)
1073{ 808{
1074 driver_unregister(&au1200_ide_driver); 809 driver_unregister(&au1200_ide_driver);
1075} 810}
1076 811
1077#ifdef CONFIG_PM
1078int au1200ide_pm_callback( au1xxx_power_dev_t *dev,\
1079 au1xxx_request_t request, void *data) {
1080
1081 unsigned int d, err = 0;
1082 unsigned long flags;
1083
1084 spin_lock_irqsave(auide_hwif.pm.lock, flags);
1085
1086 switch (request){
1087 case AU1XXX_PM_SLEEP:
1088 err = au1xxxide_pm_sleep(dev);
1089 break;
1090 case AU1XXX_PM_WAKEUP:
1091 d = *((unsigned int*)data);
1092 if ( d > 0 && d <= 99) {
1093 err = au1xxxide_pm_standby(dev);
1094 }
1095 else {
1096 err = au1xxxide_pm_resume(dev);
1097 }
1098 break;
1099 case AU1XXX_PM_GETSTATUS:
1100 err = au1xxxide_pm_getstatus(dev);
1101 break;
1102 case AU1XXX_PM_ACCESS:
1103 err = au1xxxide_pm_access(dev);
1104 break;
1105 case AU1XXX_PM_IDLE:
1106 err = au1xxxide_pm_idle(dev);
1107 break;
1108 case AU1XXX_PM_CLEANUP:
1109 err = au1xxxide_pm_cleanup(dev);
1110 break;
1111 default:
1112 err = -1;
1113 break;
1114 }
1115
1116 spin_unlock_irqrestore(auide_hwif.pm.lock, flags);
1117
1118 return err;
1119}
1120
1121static int au1xxxide_pm_standby( au1xxx_power_dev_t *dev ) {
1122 return 0;
1123}
1124
1125static int au1xxxide_pm_sleep( au1xxx_power_dev_t *dev ) {
1126
1127 int retval;
1128 ide_hwif_t *hwif = auide_hwif.hwif;
1129 struct request rq;
1130 struct request_pm_state rqpm;
1131 ide_task_t args;
1132
1133 if(auide_hwif.pm.stopped)
1134 return -1;
1135
1136 /*
1137 * wait until hard disc is ready
1138 */
1139 if ( wait_for_ready(&hwif->drives[0], 35000) ) {
1140 printk("Wait for drive sleep timeout!\n");
1141 retval = -1;
1142 }
1143
1144 /*
1145 * sequenz to tell the high level ide driver that pm is resuming
1146 */
1147 memset(&rq, 0, sizeof(rq));
1148 memset(&rqpm, 0, sizeof(rqpm));
1149 memset(&args, 0, sizeof(args));
1150 rq.flags = REQ_PM_SUSPEND;
1151 rq.special = &args;
1152 rq.pm = &rqpm;
1153 rqpm.pm_step = ide_pm_state_start_suspend;
1154 rqpm.pm_state = PMSG_SUSPEND;
1155
1156 retval = ide_do_drive_cmd(&hwif->drives[0], &rq, ide_wait);
1157
1158 if (wait_for_ready (&hwif->drives[0], 35000)) {
1159 printk("Wait for drive sleep timeout!\n");
1160 retval = -1;
1161 }
1162
1163 /*
1164 * stop dbdma channels
1165 */
1166 au1xxx_dbdma_reset(auide_hwif.tx_chan);
1167 au1xxx_dbdma_reset(auide_hwif.rx_chan);
1168
1169 auide_hwif.pm.stopped = 1;
1170
1171 return retval;
1172}
1173
1174static int au1xxxide_pm_resume( au1xxx_power_dev_t *dev ) {
1175
1176 int retval;
1177 ide_hwif_t *hwif = auide_hwif.hwif;
1178 struct request rq;
1179 struct request_pm_state rqpm;
1180 ide_task_t args;
1181
1182 if(!auide_hwif.pm.stopped)
1183 return -1;
1184
1185 /*
1186 * start dbdma channels
1187 */
1188 au1xxx_dbdma_start(auide_hwif.tx_chan);
1189 au1xxx_dbdma_start(auide_hwif.rx_chan);
1190
1191 /*
1192 * wait until hard disc is ready
1193 */
1194 if (wait_for_ready ( &hwif->drives[0], 35000)) {
1195 printk("Wait for drive wake up timeout!\n");
1196 retval = -1;
1197 }
1198
1199 /*
1200 * sequenz to tell the high level ide driver that pm is resuming
1201 */
1202 memset(&rq, 0, sizeof(rq));
1203 memset(&rqpm, 0, sizeof(rqpm));
1204 memset(&args, 0, sizeof(args));
1205 rq.flags = REQ_PM_RESUME;
1206 rq.special = &args;
1207 rq.pm = &rqpm;
1208 rqpm.pm_step = ide_pm_state_start_resume;
1209 rqpm.pm_state = PMSG_ON;
1210
1211 retval = ide_do_drive_cmd(&hwif->drives[0], &rq, ide_head_wait);
1212
1213 /*
1214 * wait for hard disc
1215 */
1216 if ( wait_for_ready(&hwif->drives[0], 35000) ) {
1217 printk("Wait for drive wake up timeout!\n");
1218 retval = -1;
1219 }
1220
1221 auide_hwif.pm.stopped = 0;
1222
1223 return retval;
1224}
1225
1226static int au1xxxide_pm_getstatus( au1xxx_power_dev_t *dev ) {
1227 return dev->cur_state;
1228}
1229
1230static int au1xxxide_pm_access( au1xxx_power_dev_t *dev ) {
1231 if (dev->cur_state != AWAKE_STATE)
1232 return 0;
1233 else
1234 return -1;
1235}
1236
1237static int au1xxxide_pm_idle( au1xxx_power_dev_t *dev ) {
1238 return 0;
1239}
1240
1241static int au1xxxide_pm_cleanup( au1xxx_power_dev_t *dev ) {
1242 return 0;
1243}
1244#endif /* CONFIG_PM */
1245
1246MODULE_LICENSE("GPL"); 812MODULE_LICENSE("GPL");
1247MODULE_DESCRIPTION("AU1200 IDE driver"); 813MODULE_DESCRIPTION("AU1200 IDE driver");
1248 814
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index af526b671c4e..4ee597d08797 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -622,12 +622,18 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
622 ide_hwif_t *hwif; 622 ide_hwif_t *hwif;
623 int h; 623 int h;
624 624
625 /*
626 * Find an empty HWIF; if none available, return -ENOMEM.
627 */
625 for (h = 0; h < MAX_HWIFS; ++h) { 628 for (h = 0; h < MAX_HWIFS; ++h) {
626 hwif = &ide_hwifs[h]; 629 hwif = &ide_hwifs[h];
627 /* Find an empty HWIF */
628 if (hwif->chipset == ide_unknown) 630 if (hwif->chipset == ide_unknown)
629 break; 631 break;
630 } 632 }
633 if (h == MAX_HWIFS) {
634 printk(KERN_ERR "%s: too many IDE interfaces, no room in table\n", d->name);
635 return -ENOMEM;
636 }
631 637
632 /* Get the CmdBlk and CtrlBlk Base Registers */ 638 /* Get the CmdBlk and CtrlBlk Base Registers */
633 base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET; 639 base = pci_resource_start(dev, 0) + IOC4_CMD_OFFSET;
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 7161ce0ef5aa..86fb1e0286d3 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -80,6 +80,7 @@ static struct via_isa_bridge {
80 u16 flags; 80 u16 flags;
81} via_isa_bridges[] = { 81} via_isa_bridges[] = {
82 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 82 { "vt6410", PCI_DEVICE_ID_VIA_6410, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
83 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
83 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 84 { "vt8237", PCI_DEVICE_ID_VIA_8237, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
84 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 85 { "vt8235", PCI_DEVICE_ID_VIA_8235, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
85 { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST }, 86 { "vt8233a", PCI_DEVICE_ID_VIA_8233A, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
diff --git a/drivers/ieee1394/.gitignore b/drivers/ieee1394/.gitignore
new file mode 100644
index 000000000000..33da10a25323
--- /dev/null
+++ b/drivers/ieee1394/.gitignore
@@ -0,0 +1 @@
oui.c
diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig
index 25103a0ef9b3..39142e2f804b 100644
--- a/drivers/ieee1394/Kconfig
+++ b/drivers/ieee1394/Kconfig
@@ -169,27 +169,4 @@ config IEEE1394_RAWIO
169 To compile this driver as a module, say M here: the 169 To compile this driver as a module, say M here: the
170 module will be called raw1394. 170 module will be called raw1394.
171 171
172config IEEE1394_CMP
173 tristate "IEC61883-1 Plug support"
174 depends on IEEE1394
175 help
176 This option enables the Connection Management Procedures
177 (IEC61883-1) driver, which implements input and output plugs.
178
179 To compile this driver as a module, say M here: the
180 module will be called cmp.
181
182config IEEE1394_AMDTP
183 tristate "IEC61883-6 (Audio transmission) support"
184 depends on IEEE1394 && IEEE1394_OHCI1394 && IEEE1394_CMP
185 help
186 This option enables the Audio & Music Data Transmission Protocol
187 (IEC61883-6) driver, which implements audio transmission over
188 IEEE1394.
189
190 The userspace interface is documented in amdtp.h.
191
192 To compile this driver as a module, say M here: the
193 module will be called amdtp.
194
195endmenu 172endmenu
diff --git a/drivers/ieee1394/Makefile b/drivers/ieee1394/Makefile
index e8b4d48d376e..6f53611fe255 100644
--- a/drivers/ieee1394/Makefile
+++ b/drivers/ieee1394/Makefile
@@ -14,8 +14,6 @@ obj-$(CONFIG_IEEE1394_RAWIO) += raw1394.o
14obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o 14obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o
15obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o 15obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o
16obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o 16obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o
17obj-$(CONFIG_IEEE1394_AMDTP) += amdtp.o
18obj-$(CONFIG_IEEE1394_CMP) += cmp.o
19 17
20quiet_cmd_oui2c = OUI2C $@ 18quiet_cmd_oui2c = OUI2C $@
21 cmd_oui2c = $(CONFIG_SHELL) $(srctree)/$(src)/oui2c.sh < $< > $@ 19 cmd_oui2c = $(CONFIG_SHELL) $(srctree)/$(src)/oui2c.sh < $< > $@
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c
index 61ddd5d37eff..15773544234b 100644
--- a/drivers/ieee1394/csr1212.c
+++ b/drivers/ieee1394/csr1212.c
@@ -1261,7 +1261,7 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr)
1261 return CSR1212_EINVAL; 1261 return CSR1212_EINVAL;
1262#endif 1262#endif
1263 1263
1264 cr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); 1264 cr = CSR1212_MALLOC(sizeof(*cr));
1265 if (!cr) 1265 if (!cr)
1266 return CSR1212_ENOMEM; 1266 return CSR1212_ENOMEM;
1267 1267
@@ -1393,8 +1393,7 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv,
1393 case CSR1212_KV_TYPE_LEAF: 1393 case CSR1212_KV_TYPE_LEAF:
1394 if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) { 1394 if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) {
1395 kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len)); 1395 kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len));
1396 if (!kv->value.leaf.data) 1396 if (!kv->value.leaf.data) {
1397 {
1398 ret = CSR1212_ENOMEM; 1397 ret = CSR1212_ENOMEM;
1399 goto fail; 1398 goto fail;
1400 } 1399 }
@@ -1462,7 +1461,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1462 cache->next = NULL; 1461 cache->next = NULL;
1463 csr->cache_tail = cache; 1462 csr->cache_tail = cache;
1464 cache->filled_head = 1463 cache->filled_head =
1465 CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); 1464 CSR1212_MALLOC(sizeof(*cache->filled_head));
1466 if (!cache->filled_head) { 1465 if (!cache->filled_head) {
1467 return CSR1212_ENOMEM; 1466 return CSR1212_ENOMEM;
1468 } 1467 }
@@ -1484,7 +1483,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1484 /* Now seach read portions of the cache to see if it is there. */ 1483 /* Now seach read portions of the cache to see if it is there. */
1485 for (cr = cache->filled_head; cr; cr = cr->next) { 1484 for (cr = cache->filled_head; cr; cr = cr->next) {
1486 if (cache_index < cr->offset_start) { 1485 if (cache_index < cr->offset_start) {
1487 newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); 1486 newcr = CSR1212_MALLOC(sizeof(*newcr));
1488 if (!newcr) 1487 if (!newcr)
1489 return CSR1212_ENOMEM; 1488 return CSR1212_ENOMEM;
1490 1489
@@ -1508,7 +1507,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv)
1508 1507
1509 if (!cr) { 1508 if (!cr) {
1510 cr = cache->filled_tail; 1509 cr = cache->filled_tail;
1511 newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); 1510 newcr = CSR1212_MALLOC(sizeof(*newcr));
1512 if (!newcr) 1511 if (!newcr)
1513 return CSR1212_ENOMEM; 1512 return CSR1212_ENOMEM;
1514 1513
@@ -1611,15 +1610,17 @@ int csr1212_parse_csr(struct csr1212_csr *csr)
1611 csr->root_kv->valid = 0; 1610 csr->root_kv->valid = 0;
1612 csr->root_kv->next = csr->root_kv; 1611 csr->root_kv->next = csr->root_kv;
1613 csr->root_kv->prev = csr->root_kv; 1612 csr->root_kv->prev = csr->root_kv;
1614 csr1212_get_keyval(csr, csr->root_kv); 1613 ret = _csr1212_read_keyval(csr, csr->root_kv);
1614 if (ret != CSR1212_SUCCESS)
1615 return ret;
1615 1616
1616 /* Scan through the Root directory finding all extended ROM regions 1617 /* Scan through the Root directory finding all extended ROM regions
1617 * and make cache regions for them */ 1618 * and make cache regions for them */
1618 for (dentry = csr->root_kv->value.directory.dentries_head; 1619 for (dentry = csr->root_kv->value.directory.dentries_head;
1619 dentry; dentry = dentry->next) { 1620 dentry; dentry = dentry->next) {
1620 if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM) { 1621 if (dentry->kv->key.id == CSR1212_KV_ID_EXTENDED_ROM &&
1621 csr1212_get_keyval(csr, dentry->kv); 1622 !dentry->kv->valid) {
1622 1623 ret = _csr1212_read_keyval(csr, dentry->kv);
1623 if (ret != CSR1212_SUCCESS) 1624 if (ret != CSR1212_SUCCESS)
1624 return ret; 1625 return ret;
1625 } 1626 }
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h
index 28c5f4b726e2..cecd5871f2de 100644
--- a/drivers/ieee1394/csr1212.h
+++ b/drivers/ieee1394/csr1212.h
@@ -646,7 +646,7 @@ static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u_int32_t o
646{ 646{
647 struct csr1212_csr_rom_cache *cache; 647 struct csr1212_csr_rom_cache *cache;
648 648
649 cache = CSR1212_MALLOC(sizeof(struct csr1212_csr_rom_cache) + size); 649 cache = CSR1212_MALLOC(sizeof(*cache) + size);
650 if (!cache) 650 if (!cache)
651 return NULL; 651 return NULL;
652 652
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c
index b79ddb43e746..9fb2769d9abc 100644
--- a/drivers/ieee1394/dma.c
+++ b/drivers/ieee1394/dma.c
@@ -23,7 +23,8 @@ void dma_prog_region_init(struct dma_prog_region *prog)
23 prog->bus_addr = 0; 23 prog->bus_addr = 0;
24} 24}
25 25
26int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes, struct pci_dev *dev) 26int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes,
27 struct pci_dev *dev)
27{ 28{
28 /* round up to page size */ 29 /* round up to page size */
29 n_bytes = PAGE_ALIGN(n_bytes); 30 n_bytes = PAGE_ALIGN(n_bytes);
@@ -32,7 +33,8 @@ int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes,
32 33
33 prog->kvirt = pci_alloc_consistent(dev, n_bytes, &prog->bus_addr); 34 prog->kvirt = pci_alloc_consistent(dev, n_bytes, &prog->bus_addr);
34 if (!prog->kvirt) { 35 if (!prog->kvirt) {
35 printk(KERN_ERR "dma_prog_region_alloc: pci_alloc_consistent() failed\n"); 36 printk(KERN_ERR
37 "dma_prog_region_alloc: pci_alloc_consistent() failed\n");
36 dma_prog_region_free(prog); 38 dma_prog_region_free(prog);
37 return -ENOMEM; 39 return -ENOMEM;
38 } 40 }
@@ -45,7 +47,8 @@ int dma_prog_region_alloc(struct dma_prog_region *prog, unsigned long n_bytes,
45void dma_prog_region_free(struct dma_prog_region *prog) 47void dma_prog_region_free(struct dma_prog_region *prog)
46{ 48{
47 if (prog->kvirt) { 49 if (prog->kvirt) {
48 pci_free_consistent(prog->dev, prog->n_pages << PAGE_SHIFT, prog->kvirt, prog->bus_addr); 50 pci_free_consistent(prog->dev, prog->n_pages << PAGE_SHIFT,
51 prog->kvirt, prog->bus_addr);
49 } 52 }
50 53
51 prog->kvirt = NULL; 54 prog->kvirt = NULL;
@@ -65,7 +68,8 @@ void dma_region_init(struct dma_region *dma)
65 dma->sglist = NULL; 68 dma->sglist = NULL;
66} 69}
67 70
68int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_dev *dev, int direction) 71int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes,
72 struct pci_dev *dev, int direction)
69{ 73{
70 unsigned int i; 74 unsigned int i;
71 75
@@ -95,14 +99,16 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d
95 99
96 /* fill scatter/gather list with pages */ 100 /* fill scatter/gather list with pages */
97 for (i = 0; i < dma->n_pages; i++) { 101 for (i = 0; i < dma->n_pages; i++) {
98 unsigned long va = (unsigned long) dma->kvirt + (i << PAGE_SHIFT); 102 unsigned long va =
103 (unsigned long)dma->kvirt + (i << PAGE_SHIFT);
99 104
100 dma->sglist[i].page = vmalloc_to_page((void *)va); 105 dma->sglist[i].page = vmalloc_to_page((void *)va);
101 dma->sglist[i].length = PAGE_SIZE; 106 dma->sglist[i].length = PAGE_SIZE;
102 } 107 }
103 108
104 /* map sglist to the IOMMU */ 109 /* map sglist to the IOMMU */
105 dma->n_dma_pages = pci_map_sg(dev, dma->sglist, dma->n_pages, direction); 110 dma->n_dma_pages =
111 pci_map_sg(dev, dma->sglist, dma->n_pages, direction);
106 112
107 if (dma->n_dma_pages == 0) { 113 if (dma->n_dma_pages == 0) {
108 printk(KERN_ERR "dma_region_alloc: pci_map_sg() failed\n"); 114 printk(KERN_ERR "dma_region_alloc: pci_map_sg() failed\n");
@@ -114,7 +120,7 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes, struct pci_d
114 120
115 return 0; 121 return 0;
116 122
117err: 123 err:
118 dma_region_free(dma); 124 dma_region_free(dma);
119 return -ENOMEM; 125 return -ENOMEM;
120} 126}
@@ -122,7 +128,8 @@ err:
122void dma_region_free(struct dma_region *dma) 128void dma_region_free(struct dma_region *dma)
123{ 129{
124 if (dma->n_dma_pages) { 130 if (dma->n_dma_pages) {
125 pci_unmap_sg(dma->dev, dma->sglist, dma->n_pages, dma->direction); 131 pci_unmap_sg(dma->dev, dma->sglist, dma->n_pages,
132 dma->direction);
126 dma->n_dma_pages = 0; 133 dma->n_dma_pages = 0;
127 dma->dev = NULL; 134 dma->dev = NULL;
128 } 135 }
@@ -137,7 +144,8 @@ void dma_region_free(struct dma_region *dma)
137 144
138/* find the scatterlist index and remaining offset corresponding to a 145/* find the scatterlist index and remaining offset corresponding to a
139 given offset from the beginning of the buffer */ 146 given offset from the beginning of the buffer */
140static inline int dma_region_find(struct dma_region *dma, unsigned long offset, unsigned long *rem) 147static inline int dma_region_find(struct dma_region *dma, unsigned long offset,
148 unsigned long *rem)
141{ 149{
142 int i; 150 int i;
143 unsigned long off = offset; 151 unsigned long off = offset;
@@ -156,15 +164,18 @@ static inline int dma_region_find(struct dma_region *dma, unsigned long offset,
156 return i; 164 return i;
157} 165}
158 166
159dma_addr_t dma_region_offset_to_bus(struct dma_region *dma, unsigned long offset) 167dma_addr_t dma_region_offset_to_bus(struct dma_region * dma,
168 unsigned long offset)
160{ 169{
161 unsigned long rem = 0; 170 unsigned long rem = 0;
162 171
163 struct scatterlist *sg = &dma->sglist[dma_region_find(dma, offset, &rem)]; 172 struct scatterlist *sg =
173 &dma->sglist[dma_region_find(dma, offset, &rem)];
164 return sg_dma_address(sg) + rem; 174 return sg_dma_address(sg) + rem;
165} 175}
166 176
167void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, unsigned long len) 177void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset,
178 unsigned long len)
168{ 179{
169 int first, last; 180 int first, last;
170 unsigned long rem; 181 unsigned long rem;
@@ -175,10 +186,12 @@ void dma_region_sync_for_cpu(struct dma_region *dma, unsigned long offset, unsig
175 first = dma_region_find(dma, offset, &rem); 186 first = dma_region_find(dma, offset, &rem);
176 last = dma_region_find(dma, offset + len - 1, &rem); 187 last = dma_region_find(dma, offset + len - 1, &rem);
177 188
178 pci_dma_sync_sg_for_cpu(dma->dev, &dma->sglist[first], last - first + 1, dma->direction); 189 pci_dma_sync_sg_for_cpu(dma->dev, &dma->sglist[first], last - first + 1,
190 dma->direction);
179} 191}
180 192
181void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, unsigned long len) 193void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset,
194 unsigned long len)
182{ 195{
183 int first, last; 196 int first, last;
184 unsigned long rem; 197 unsigned long rem;
@@ -189,44 +202,47 @@ void dma_region_sync_for_device(struct dma_region *dma, unsigned long offset, un
189 first = dma_region_find(dma, offset, &rem); 202 first = dma_region_find(dma, offset, &rem);
190 last = dma_region_find(dma, offset + len - 1, &rem); 203 last = dma_region_find(dma, offset + len - 1, &rem);
191 204
192 pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first], last - first + 1, dma->direction); 205 pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first],
206 last - first + 1, dma->direction);
193} 207}
194 208
195#ifdef CONFIG_MMU 209#ifdef CONFIG_MMU
196 210
197/* nopage() handler for mmap access */ 211/* nopage() handler for mmap access */
198 212
199static struct page* 213static struct page *dma_region_pagefault(struct vm_area_struct *area,
200dma_region_pagefault(struct vm_area_struct *area, unsigned long address, int *type) 214 unsigned long address, int *type)
201{ 215{
202 unsigned long offset; 216 unsigned long offset;
203 unsigned long kernel_virt_addr; 217 unsigned long kernel_virt_addr;
204 struct page *ret = NOPAGE_SIGBUS; 218 struct page *ret = NOPAGE_SIGBUS;
205 219
206 struct dma_region *dma = (struct dma_region*) area->vm_private_data; 220 struct dma_region *dma = (struct dma_region *)area->vm_private_data;
207 221
208 if (!dma->kvirt) 222 if (!dma->kvirt)
209 goto out; 223 goto out;
210 224
211 if ( (address < (unsigned long) area->vm_start) || 225 if ((address < (unsigned long)area->vm_start) ||
212 (address > (unsigned long) area->vm_start + (dma->n_pages << PAGE_SHIFT)) ) 226 (address >
227 (unsigned long)area->vm_start + (dma->n_pages << PAGE_SHIFT)))
213 goto out; 228 goto out;
214 229
215 if (type) 230 if (type)
216 *type = VM_FAULT_MINOR; 231 *type = VM_FAULT_MINOR;
217 offset = address - area->vm_start; 232 offset = address - area->vm_start;
218 kernel_virt_addr = (unsigned long) dma->kvirt + offset; 233 kernel_virt_addr = (unsigned long)dma->kvirt + offset;
219 ret = vmalloc_to_page((void*) kernel_virt_addr); 234 ret = vmalloc_to_page((void *)kernel_virt_addr);
220 get_page(ret); 235 get_page(ret);
221out: 236 out:
222 return ret; 237 return ret;
223} 238}
224 239
225static struct vm_operations_struct dma_region_vm_ops = { 240static struct vm_operations_struct dma_region_vm_ops = {
226 .nopage = dma_region_pagefault, 241 .nopage = dma_region_pagefault,
227}; 242};
228 243
229int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma) 244int dma_region_mmap(struct dma_region *dma, struct file *file,
245 struct vm_area_struct *vma)
230{ 246{
231 unsigned long size; 247 unsigned long size;
232 248
@@ -250,11 +266,12 @@ int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_st
250 return 0; 266 return 0;
251} 267}
252 268
253#else /* CONFIG_MMU */ 269#else /* CONFIG_MMU */
254 270
255int dma_region_mmap(struct dma_region *dma, struct file *file, struct vm_area_struct *vma) 271int dma_region_mmap(struct dma_region *dma, struct file *file,
272 struct vm_area_struct *vma)
256{ 273{
257 return -EINVAL; 274 return -EINVAL;
258} 275}
259 276
260#endif /* CONFIG_MMU */ 277#endif /* CONFIG_MMU */
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c
index cbbbe14b8849..196db7439272 100644
--- a/drivers/ieee1394/dv1394.c
+++ b/drivers/ieee1394/dv1394.c
@@ -123,15 +123,6 @@
123 123
124#include "ohci1394.h" 124#include "ohci1394.h"
125 125
126#ifndef virt_to_page
127#define virt_to_page(x) MAP_NR(x)
128#endif
129
130#ifndef vmalloc_32
131#define vmalloc_32(x) vmalloc(x)
132#endif
133
134
135/* DEBUG LEVELS: 126/* DEBUG LEVELS:
136 0 - no debugging messages 127 0 - no debugging messages
137 1 - some debugging messages, but none during DMA frame transmission 128 1 - some debugging messages, but none during DMA frame transmission
@@ -2218,14 +2209,12 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes
2218 unsigned long flags; 2209 unsigned long flags;
2219 int i; 2210 int i;
2220 2211
2221 video = kmalloc(sizeof(struct video_card), GFP_KERNEL); 2212 video = kzalloc(sizeof(*video), GFP_KERNEL);
2222 if (!video) { 2213 if (!video) {
2223 printk(KERN_ERR "dv1394: cannot allocate video_card\n"); 2214 printk(KERN_ERR "dv1394: cannot allocate video_card\n");
2224 goto err; 2215 goto err;
2225 } 2216 }
2226 2217
2227 memset(video, 0, sizeof(struct video_card));
2228
2229 video->ohci = ohci; 2218 video->ohci = ohci;
2230 /* lower 2 bits of id indicate which of four "plugs" 2219 /* lower 2 bits of id indicate which of four "plugs"
2231 per host */ 2220 per host */
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c
index c9e92d85c893..30fa0d43a43a 100644
--- a/drivers/ieee1394/eth1394.c
+++ b/drivers/ieee1394/eth1394.c
@@ -88,9 +88,6 @@
88 printk(KERN_ERR "%s:%s[%d]: " fmt "\n", driver_name, __FUNCTION__, __LINE__, ## args) 88 printk(KERN_ERR "%s:%s[%d]: " fmt "\n", driver_name, __FUNCTION__, __LINE__, ## args)
89#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__) 89#define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__)
90 90
91static char version[] __devinitdata =
92 "$Rev: 1312 $ Ben Collins <bcollins@debian.org>";
93
94struct fragment_info { 91struct fragment_info {
95 struct list_head list; 92 struct list_head list;
96 int offset; 93 int offset;
@@ -355,12 +352,12 @@ static int eth1394_probe(struct device *dev)
355 if (!hi) 352 if (!hi)
356 return -ENOENT; 353 return -ENOENT;
357 354
358 new_node = kmalloc(sizeof(struct eth1394_node_ref), 355 new_node = kmalloc(sizeof(*new_node),
359 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); 356 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
360 if (!new_node) 357 if (!new_node)
361 return -ENOMEM; 358 return -ENOMEM;
362 359
363 node_info = kmalloc(sizeof(struct eth1394_node_info), 360 node_info = kmalloc(sizeof(*node_info),
364 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); 361 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
365 if (!node_info) { 362 if (!node_info) {
366 kfree(new_node); 363 kfree(new_node);
@@ -436,12 +433,12 @@ static int eth1394_update(struct unit_directory *ud)
436 node = eth1394_find_node(&priv->ip_node_list, ud); 433 node = eth1394_find_node(&priv->ip_node_list, ud);
437 434
438 if (!node) { 435 if (!node) {
439 node = kmalloc(sizeof(struct eth1394_node_ref), 436 node = kmalloc(sizeof(*node),
440 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); 437 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
441 if (!node) 438 if (!node)
442 return -ENOMEM; 439 return -ENOMEM;
443 440
444 node_info = kmalloc(sizeof(struct eth1394_node_info), 441 node_info = kmalloc(sizeof(*node_info),
445 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); 442 in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
446 if (!node_info) { 443 if (!node_info) {
447 kfree(node); 444 kfree(node);
@@ -566,7 +563,6 @@ static void ether1394_add_host (struct hpsb_host *host)
566 struct eth1394_host_info *hi = NULL; 563 struct eth1394_host_info *hi = NULL;
567 struct net_device *dev = NULL; 564 struct net_device *dev = NULL;
568 struct eth1394_priv *priv; 565 struct eth1394_priv *priv;
569 static int version_printed = 0;
570 u64 fifo_addr; 566 u64 fifo_addr;
571 567
572 if (!(host->config_roms & HPSB_CONFIG_ROM_ENTRY_IP1394)) 568 if (!(host->config_roms & HPSB_CONFIG_ROM_ENTRY_IP1394))
@@ -581,9 +577,6 @@ static void ether1394_add_host (struct hpsb_host *host)
581 if (fifo_addr == ~0ULL) 577 if (fifo_addr == ~0ULL)
582 goto out; 578 goto out;
583 579
584 if (version_printed++ == 0)
585 ETH1394_PRINT_G (KERN_INFO, "%s\n", version);
586
587 /* We should really have our own alloc_hpsbdev() function in 580 /* We should really have our own alloc_hpsbdev() function in
588 * net_init.c instead of calling the one for ethernet then hijacking 581 * net_init.c instead of calling the one for ethernet then hijacking
589 * it for ourselves. That way we'd be a real networking device. */ 582 * it for ourselves. That way we'd be a real networking device. */
@@ -1021,7 +1014,7 @@ static inline int new_fragment(struct list_head *frag_info, int offset, int len)
1021 } 1014 }
1022 } 1015 }
1023 1016
1024 new = kmalloc(sizeof(struct fragment_info), GFP_ATOMIC); 1017 new = kmalloc(sizeof(*new), GFP_ATOMIC);
1025 if (!new) 1018 if (!new)
1026 return -ENOMEM; 1019 return -ENOMEM;
1027 1020
@@ -1040,7 +1033,7 @@ static inline int new_partial_datagram(struct net_device *dev,
1040{ 1033{
1041 struct partial_datagram *new; 1034 struct partial_datagram *new;
1042 1035
1043 new = kmalloc(sizeof(struct partial_datagram), GFP_ATOMIC); 1036 new = kmalloc(sizeof(*new), GFP_ATOMIC);
1044 if (!new) 1037 if (!new)
1045 return -ENOMEM; 1038 return -ENOMEM;
1046 1039
@@ -1768,7 +1761,6 @@ fail:
1768static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) 1761static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1769{ 1762{
1770 strcpy (info->driver, driver_name); 1763 strcpy (info->driver, driver_name);
1771 strcpy (info->version, "$Rev: 1312 $");
1772 /* FIXME XXX provide sane businfo */ 1764 /* FIXME XXX provide sane businfo */
1773 strcpy (info->bus_info, "ieee1394"); 1765 strcpy (info->bus_info, "ieee1394");
1774} 1766}
diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c
index 997e1bf6297f..734b121a0554 100644
--- a/drivers/ieee1394/highlevel.c
+++ b/drivers/ieee1394/highlevel.c
@@ -101,12 +101,10 @@ void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
101 return NULL; 101 return NULL;
102 } 102 }
103 103
104 hi = kmalloc(sizeof(*hi) + data_size, GFP_ATOMIC); 104 hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC);
105 if (!hi) 105 if (!hi)
106 return NULL; 106 return NULL;
107 107
108 memset(hi, 0, sizeof(*hi) + data_size);
109
110 if (data_size) { 108 if (data_size) {
111 data = hi->data = hi + 1; 109 data = hi->data = hi + 1;
112 hi->size = data_size; 110 hi->size = data_size;
@@ -326,11 +324,9 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
326 return retval; 324 return retval;
327 } 325 }
328 326
329 as = (struct hpsb_address_serve *) 327 as = kmalloc(sizeof(*as), GFP_KERNEL);
330 kmalloc(sizeof(struct hpsb_address_serve), GFP_KERNEL); 328 if (!as)
331 if (as == NULL) {
332 return retval; 329 return retval;
333 }
334 330
335 INIT_LIST_HEAD(&as->host_list); 331 INIT_LIST_HEAD(&as->host_list);
336 INIT_LIST_HEAD(&as->hl_list); 332 INIT_LIST_HEAD(&as->hl_list);
@@ -383,11 +379,9 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
383 return 0; 379 return 0;
384 } 380 }
385 381
386 as = (struct hpsb_address_serve *) 382 as = kmalloc(sizeof(*as), GFP_ATOMIC);
387 kmalloc(sizeof(struct hpsb_address_serve), GFP_ATOMIC); 383 if (!as)
388 if (as == NULL) { 384 return 0;
389 return 0;
390 }
391 385
392 INIT_LIST_HEAD(&as->host_list); 386 INIT_LIST_HEAD(&as->host_list);
393 INIT_LIST_HEAD(&as->hl_list); 387 INIT_LIST_HEAD(&as->hl_list);
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c
index aeeaeb670d03..ba09741fc826 100644
--- a/drivers/ieee1394/hosts.c
+++ b/drivers/ieee1394/hosts.c
@@ -61,12 +61,12 @@ static void delayed_reset_bus(void * __reset_info)
61 61
62static int dummy_transmit_packet(struct hpsb_host *h, struct hpsb_packet *p) 62static int dummy_transmit_packet(struct hpsb_host *h, struct hpsb_packet *p)
63{ 63{
64 return 0; 64 return 0;
65} 65}
66 66
67static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg) 67static int dummy_devctl(struct hpsb_host *h, enum devctl_cmd c, int arg)
68{ 68{
69 return -1; 69 return -1;
70} 70}
71 71
72static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg) 72static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg)
@@ -75,9 +75,9 @@ static int dummy_isoctl(struct hpsb_iso *iso, enum isoctl_cmd command, unsigned
75} 75}
76 76
77static struct hpsb_host_driver dummy_driver = { 77static struct hpsb_host_driver dummy_driver = {
78 .transmit_packet = dummy_transmit_packet, 78 .transmit_packet = dummy_transmit_packet,
79 .devctl = dummy_devctl, 79 .devctl = dummy_devctl,
80 .isoctl = dummy_isoctl 80 .isoctl = dummy_isoctl
81}; 81};
82 82
83static int alloc_hostnum_cb(struct hpsb_host *host, void *__data) 83static int alloc_hostnum_cb(struct hpsb_host *host, void *__data)
@@ -110,13 +110,13 @@ static DECLARE_MUTEX(host_num_alloc);
110struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, 110struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
111 struct device *dev) 111 struct device *dev)
112{ 112{
113 struct hpsb_host *h; 113 struct hpsb_host *h;
114 int i; 114 int i;
115 int hostnum = 0; 115 int hostnum = 0;
116 116
117 h = kmalloc(sizeof(struct hpsb_host) + extra, SLAB_KERNEL); 117 h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL);
118 if (!h) return NULL; 118 if (!h)
119 memset(h, 0, sizeof(struct hpsb_host) + extra); 119 return NULL;
120 120
121 h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); 121 h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h);
122 if (!h->csr.rom) { 122 if (!h->csr.rom) {
@@ -125,7 +125,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
125 } 125 }
126 126
127 h->hostdata = h + 1; 127 h->hostdata = h + 1;
128 h->driver = drv; 128 h->driver = drv;
129 129
130 skb_queue_head_init(&h->pending_packet_queue); 130 skb_queue_head_init(&h->pending_packet_queue);
131 INIT_LIST_HEAD(&h->addr_space); 131 INIT_LIST_HEAD(&h->addr_space);
@@ -145,8 +145,8 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
145 h->timeout.function = abort_timedouts; 145 h->timeout.function = abort_timedouts;
146 h->timeout_interval = HZ / 20; // 50ms by default 146 h->timeout_interval = HZ / 20; // 50ms by default
147 147
148 h->topology_map = h->csr.topology_map + 3; 148 h->topology_map = h->csr.topology_map + 3;
149 h->speed_map = (u8 *)(h->csr.speed_map + 2); 149 h->speed_map = (u8 *)(h->csr.speed_map + 2);
150 150
151 down(&host_num_alloc); 151 down(&host_num_alloc);
152 152
@@ -186,14 +186,14 @@ int hpsb_add_host(struct hpsb_host *host)
186 186
187void hpsb_remove_host(struct hpsb_host *host) 187void hpsb_remove_host(struct hpsb_host *host)
188{ 188{
189 host->is_shutdown = 1; 189 host->is_shutdown = 1;
190 190
191 cancel_delayed_work(&host->delayed_reset); 191 cancel_delayed_work(&host->delayed_reset);
192 flush_scheduled_work(); 192 flush_scheduled_work();
193 193
194 host->driver = &dummy_driver; 194 host->driver = &dummy_driver;
195 195
196 highlevel_remove_host(host); 196 highlevel_remove_host(host);
197 197
198 hpsb_remove_extra_config_roms(host); 198 hpsb_remove_extra_config_roms(host);
199 199
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index 38f42112dff0..07d188ca8495 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -17,46 +17,47 @@ struct hpsb_packet;
17struct hpsb_iso; 17struct hpsb_iso;
18 18
19struct hpsb_host { 19struct hpsb_host {
20 struct list_head host_list; 20 struct list_head host_list;
21 21
22 void *hostdata; 22 void *hostdata;
23 23
24 atomic_t generation; 24 atomic_t generation;
25 25
26 struct sk_buff_head pending_packet_queue; 26 struct sk_buff_head pending_packet_queue;
27 27
28 struct timer_list timeout; 28 struct timer_list timeout;
29 unsigned long timeout_interval; 29 unsigned long timeout_interval;
30 30
31 unsigned char iso_listen_count[64]; 31 unsigned char iso_listen_count[64];
32 32
33 int node_count; /* number of identified nodes on this bus */ 33 int node_count; /* number of identified nodes on this bus */
34 int selfid_count; /* total number of SelfIDs received */ 34 int selfid_count; /* total number of SelfIDs received */
35 int nodes_active; /* number of nodes that are actually active */ 35 int nodes_active; /* number of nodes that are actually active */
36 36
37 nodeid_t node_id; /* node ID of this host */ 37 nodeid_t node_id; /* node ID of this host */
38 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */ 38 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
39 nodeid_t busmgr_id; /* ID of this bus' bus manager */ 39 nodeid_t busmgr_id; /* ID of this bus' bus manager */
40 40
41 /* this nodes state */ 41 /* this nodes state */
42 unsigned in_bus_reset:1; 42 unsigned in_bus_reset:1;
43 unsigned is_shutdown:1; 43 unsigned is_shutdown:1;
44 unsigned resume_packet_sent:1;
44 45
45 /* this nodes' duties on the bus */ 46 /* this nodes' duties on the bus */
46 unsigned is_root:1; 47 unsigned is_root:1;
47 unsigned is_cycmst:1; 48 unsigned is_cycmst:1;
48 unsigned is_irm:1; 49 unsigned is_irm:1;
49 unsigned is_busmgr:1; 50 unsigned is_busmgr:1;
50 51
51 int reset_retries; 52 int reset_retries;
52 quadlet_t *topology_map; 53 quadlet_t *topology_map;
53 u8 *speed_map; 54 u8 *speed_map;
54 struct csr_control csr; 55 struct csr_control csr;
55 56
56 /* Per node tlabel pool allocation */ 57 /* Per node tlabel pool allocation */
57 struct hpsb_tlabel_pool tpool[64]; 58 struct hpsb_tlabel_pool tpool[64];
58 59
59 struct hpsb_host_driver *driver; 60 struct hpsb_host_driver *driver;
60 61
61 struct pci_dev *pdev; 62 struct pci_dev *pdev;
62 63
@@ -76,34 +77,34 @@ struct hpsb_host {
76 77
77 78
78enum devctl_cmd { 79enum devctl_cmd {
79 /* Host is requested to reset its bus and cancel all outstanding async 80 /* Host is requested to reset its bus and cancel all outstanding async
80 * requests. If arg == 1, it shall also attempt to become root on the 81 * requests. If arg == 1, it shall also attempt to become root on the
81 * bus. Return void. */ 82 * bus. Return void. */
82 RESET_BUS, 83 RESET_BUS,
83 84
84 /* Arg is void, return value is the hardware cycle counter value. */ 85 /* Arg is void, return value is the hardware cycle counter value. */
85 GET_CYCLE_COUNTER, 86 GET_CYCLE_COUNTER,
86 87
87 /* Set the hardware cycle counter to the value in arg, return void. 88 /* Set the hardware cycle counter to the value in arg, return void.
88 * FIXME - setting is probably not required. */ 89 * FIXME - setting is probably not required. */
89 SET_CYCLE_COUNTER, 90 SET_CYCLE_COUNTER,
90 91
91 /* Configure hardware for new bus ID in arg, return void. */ 92 /* Configure hardware for new bus ID in arg, return void. */
92 SET_BUS_ID, 93 SET_BUS_ID,
93 94
94 /* If arg true, start sending cycle start packets, stop if arg == 0. 95 /* If arg true, start sending cycle start packets, stop if arg == 0.
95 * Return void. */ 96 * Return void. */
96 ACT_CYCLE_MASTER, 97 ACT_CYCLE_MASTER,
97 98
98 /* Cancel all outstanding async requests without resetting the bus. 99 /* Cancel all outstanding async requests without resetting the bus.
99 * Return void. */ 100 * Return void. */
100 CANCEL_REQUESTS, 101 CANCEL_REQUESTS,
101 102
102 /* Start or stop receiving isochronous channel in arg. Return void. 103 /* Start or stop receiving isochronous channel in arg. Return void.
103 * This acts as an optimization hint, hosts are not required not to 104 * This acts as an optimization hint, hosts are not required not to
104 * listen on unrequested channels. */ 105 * listen on unrequested channels. */
105 ISO_LISTEN_CHANNEL, 106 ISO_LISTEN_CHANNEL,
106 ISO_UNLISTEN_CHANNEL 107 ISO_UNLISTEN_CHANNEL
107}; 108};
108 109
109enum isoctl_cmd { 110enum isoctl_cmd {
@@ -134,13 +135,13 @@ enum isoctl_cmd {
134}; 135};
135 136
136enum reset_types { 137enum reset_types {
137 /* 166 microsecond reset -- only type of reset available on 138 /* 166 microsecond reset -- only type of reset available on
138 non-1394a capable controllers */ 139 non-1394a capable controllers */
139 LONG_RESET, 140 LONG_RESET,
140 141
141 /* Short (arbitrated) reset -- only available on 1394a capable 142 /* Short (arbitrated) reset -- only available on 1394a capable
142 controllers */ 143 controllers */
143 SHORT_RESET, 144 SHORT_RESET,
144 145
145 /* Variants that set force_root before issueing the bus reset */ 146 /* Variants that set force_root before issueing the bus reset */
146 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT, 147 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
@@ -158,22 +159,22 @@ struct hpsb_host_driver {
158 * reads to the ConfigROM on its own. */ 159 * reads to the ConfigROM on its own. */
159 void (*set_hw_config_rom) (struct hpsb_host *host, quadlet_t *config_rom); 160 void (*set_hw_config_rom) (struct hpsb_host *host, quadlet_t *config_rom);
160 161
161 /* This function shall implement packet transmission based on 162 /* This function shall implement packet transmission based on
162 * packet->type. It shall CRC both parts of the packet (unless 163 * packet->type. It shall CRC both parts of the packet (unless
163 * packet->type == raw) and do byte-swapping as necessary or instruct 164 * packet->type == raw) and do byte-swapping as necessary or instruct
164 * the hardware to do so. It can return immediately after the packet 165 * the hardware to do so. It can return immediately after the packet
165 * was queued for sending. After sending, hpsb_sent_packet() has to be 166 * was queued for sending. After sending, hpsb_sent_packet() has to be
166 * called. Return 0 on success, negative errno on failure. 167 * called. Return 0 on success, negative errno on failure.
167 * NOTE: The function must be callable in interrupt context. 168 * NOTE: The function must be callable in interrupt context.
168 */ 169 */
169 int (*transmit_packet) (struct hpsb_host *host, 170 int (*transmit_packet) (struct hpsb_host *host,
170 struct hpsb_packet *packet); 171 struct hpsb_packet *packet);
171 172
172 /* This function requests miscellanous services from the driver, see 173 /* This function requests miscellanous services from the driver, see
173 * above for command codes and expected actions. Return -1 for unknown 174 * above for command codes and expected actions. Return -1 for unknown
174 * command, though that should never happen. 175 * command, though that should never happen.
175 */ 176 */
176 int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg); 177 int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg);
177 178
178 /* ISO transmission/reception functions. Return 0 on success, -1 179 /* ISO transmission/reception functions. Return 0 on success, -1
179 * (or -EXXX errno code) on failure. If the low-level driver does not 180 * (or -EXXX errno code) on failure. If the low-level driver does not
@@ -181,15 +182,15 @@ struct hpsb_host_driver {
181 */ 182 */
182 int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg); 183 int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg);
183 184
184 /* This function is mainly to redirect local CSR reads/locks to the iso 185 /* This function is mainly to redirect local CSR reads/locks to the iso
185 * management registers (bus manager id, bandwidth available, channels 186 * management registers (bus manager id, bandwidth available, channels
186 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus 187 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
187 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids 188 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
188 * as OHCI uses). data and compare are the new data and expected data 189 * as OHCI uses). data and compare are the new data and expected data
189 * respectively, return value is the old value. 190 * respectively, return value is the old value.
190 */ 191 */
191 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg, 192 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
192 quadlet_t data, quadlet_t compare); 193 quadlet_t data, quadlet_t compare);
193}; 194};
194 195
195 196
diff --git a/drivers/ieee1394/ieee1394-ioctl.h b/drivers/ieee1394/ieee1394-ioctl.h
index f92b566363d5..156703986348 100644
--- a/drivers/ieee1394/ieee1394-ioctl.h
+++ b/drivers/ieee1394/ieee1394-ioctl.h
@@ -7,14 +7,6 @@
7#include <linux/ioctl.h> 7#include <linux/ioctl.h>
8#include <linux/types.h> 8#include <linux/types.h>
9 9
10
11/* AMDTP Gets 6 */
12#define AMDTP_IOC_CHANNEL _IOW('#', 0x00, struct amdtp_ioctl)
13#define AMDTP_IOC_PLUG _IOW('#', 0x01, struct amdtp_ioctl)
14#define AMDTP_IOC_PING _IOW('#', 0x02, struct amdtp_ioctl)
15#define AMDTP_IOC_ZAP _IO ('#', 0x03)
16
17
18/* DV1394 Gets 10 */ 10/* DV1394 Gets 10 */
19 11
20/* Get the driver ready to transmit video. pass a struct dv1394_init* as 12/* Get the driver ready to transmit video. pass a struct dv1394_init* as
diff --git a/drivers/ieee1394/ieee1394.h b/drivers/ieee1394/ieee1394.h
index b634a9bb365c..936d776de00a 100644
--- a/drivers/ieee1394/ieee1394.h
+++ b/drivers/ieee1394/ieee1394.h
@@ -62,6 +62,7 @@
62extern const char *hpsb_speedto_str[]; 62extern const char *hpsb_speedto_str[];
63 63
64 64
65/* 1394a cable PHY packets */
65#define SELFID_PWRCL_NO_POWER 0x0 66#define SELFID_PWRCL_NO_POWER 0x0
66#define SELFID_PWRCL_PROVIDE_15W 0x1 67#define SELFID_PWRCL_PROVIDE_15W 0x1
67#define SELFID_PWRCL_PROVIDE_30W 0x2 68#define SELFID_PWRCL_PROVIDE_30W 0x2
@@ -76,8 +77,24 @@ extern const char *hpsb_speedto_str[];
76#define SELFID_PORT_NCONN 0x1 77#define SELFID_PORT_NCONN 0x1
77#define SELFID_PORT_NONE 0x0 78#define SELFID_PORT_NONE 0x0
78 79
80#define PHYPACKET_LINKON 0x40000000
81#define PHYPACKET_PHYCONFIG_R 0x00800000
82#define PHYPACKET_PHYCONFIG_T 0x00400000
83#define EXTPHYPACKET_TYPE_PING 0x00000000
84#define EXTPHYPACKET_TYPE_REMOTEACCESS_BASE 0x00040000
85#define EXTPHYPACKET_TYPE_REMOTEACCESS_PAGED 0x00140000
86#define EXTPHYPACKET_TYPE_REMOTEREPLY_BASE 0x000C0000
87#define EXTPHYPACKET_TYPE_REMOTEREPLY_PAGED 0x001C0000
88#define EXTPHYPACKET_TYPE_REMOTECOMMAND 0x00200000
89#define EXTPHYPACKET_TYPE_REMOTECONFIRMATION 0x00280000
90#define EXTPHYPACKET_TYPE_RESUME 0x003C0000
79 91
80/* 1394a PHY bitmasks */ 92#define EXTPHYPACKET_TYPEMASK 0xC0FC0000
93
94#define PHYPACKET_PORT_SHIFT 24
95#define PHYPACKET_GAPCOUNT_SHIFT 16
96
97/* 1394a PHY register map bitmasks */
81#define PHY_00_PHYSICAL_ID 0xFC 98#define PHY_00_PHYSICAL_ID 0xFC
82#define PHY_00_R 0x02 /* Root */ 99#define PHY_00_R 0x02 /* Root */
83#define PHY_00_PS 0x01 /* Power Status*/ 100#define PHY_00_PS 0x01 /* Power Status*/
diff --git a/drivers/ieee1394/ieee1394_core.c b/drivers/ieee1394/ieee1394_core.c
index 32a1e016c85e..25ef5a86f5f0 100644
--- a/drivers/ieee1394/ieee1394_core.c
+++ b/drivers/ieee1394/ieee1394_core.c
@@ -179,34 +179,34 @@ void hpsb_free_packet(struct hpsb_packet *packet)
179 179
180int hpsb_reset_bus(struct hpsb_host *host, int type) 180int hpsb_reset_bus(struct hpsb_host *host, int type)
181{ 181{
182 if (!host->in_bus_reset) { 182 if (!host->in_bus_reset) {
183 host->driver->devctl(host, RESET_BUS, type); 183 host->driver->devctl(host, RESET_BUS, type);
184 return 0; 184 return 0;
185 } else { 185 } else {
186 return 1; 186 return 1;
187 } 187 }
188} 188}
189 189
190 190
191int hpsb_bus_reset(struct hpsb_host *host) 191int hpsb_bus_reset(struct hpsb_host *host)
192{ 192{
193 if (host->in_bus_reset) { 193 if (host->in_bus_reset) {
194 HPSB_NOTICE("%s called while bus reset already in progress", 194 HPSB_NOTICE("%s called while bus reset already in progress",
195 __FUNCTION__); 195 __FUNCTION__);
196 return 1; 196 return 1;
197 } 197 }
198 198
199 abort_requests(host); 199 abort_requests(host);
200 host->in_bus_reset = 1; 200 host->in_bus_reset = 1;
201 host->irm_id = -1; 201 host->irm_id = -1;
202 host->is_irm = 0; 202 host->is_irm = 0;
203 host->busmgr_id = -1; 203 host->busmgr_id = -1;
204 host->is_busmgr = 0; 204 host->is_busmgr = 0;
205 host->is_cycmst = 0; 205 host->is_cycmst = 0;
206 host->node_count = 0; 206 host->node_count = 0;
207 host->selfid_count = 0; 207 host->selfid_count = 0;
208 208
209 return 0; 209 return 0;
210} 210}
211 211
212 212
@@ -216,150 +216,156 @@ int hpsb_bus_reset(struct hpsb_host *host)
216 */ 216 */
217static int check_selfids(struct hpsb_host *host) 217static int check_selfids(struct hpsb_host *host)
218{ 218{
219 int nodeid = -1; 219 int nodeid = -1;
220 int rest_of_selfids = host->selfid_count; 220 int rest_of_selfids = host->selfid_count;
221 struct selfid *sid = (struct selfid *)host->topology_map; 221 struct selfid *sid = (struct selfid *)host->topology_map;
222 struct ext_selfid *esid; 222 struct ext_selfid *esid;
223 int esid_seq = 23; 223 int esid_seq = 23;
224 224
225 host->nodes_active = 0; 225 host->nodes_active = 0;
226 226
227 while (rest_of_selfids--) { 227 while (rest_of_selfids--) {
228 if (!sid->extended) { 228 if (!sid->extended) {
229 nodeid++; 229 nodeid++;
230 esid_seq = 0; 230 esid_seq = 0;
231 231
232 if (sid->phy_id != nodeid) { 232 if (sid->phy_id != nodeid) {
233 HPSB_INFO("SelfIDs failed monotony check with " 233 HPSB_INFO("SelfIDs failed monotony check with "
234 "%d", sid->phy_id); 234 "%d", sid->phy_id);
235 return 0; 235 return 0;
236 } 236 }
237 237
238 if (sid->link_active) { 238 if (sid->link_active) {
239 host->nodes_active++; 239 host->nodes_active++;
240 if (sid->contender) 240 if (sid->contender)
241 host->irm_id = LOCAL_BUS | sid->phy_id; 241 host->irm_id = LOCAL_BUS | sid->phy_id;
242 } 242 }
243 } else { 243 } else {
244 esid = (struct ext_selfid *)sid; 244 esid = (struct ext_selfid *)sid;
245 245
246 if ((esid->phy_id != nodeid) 246 if ((esid->phy_id != nodeid)
247 || (esid->seq_nr != esid_seq)) { 247 || (esid->seq_nr != esid_seq)) {
248 HPSB_INFO("SelfIDs failed monotony check with " 248 HPSB_INFO("SelfIDs failed monotony check with "
249 "%d/%d", esid->phy_id, esid->seq_nr); 249 "%d/%d", esid->phy_id, esid->seq_nr);
250 return 0; 250 return 0;
251 } 251 }
252 esid_seq++; 252 esid_seq++;
253 } 253 }
254 sid++; 254 sid++;
255 } 255 }
256 256
257 esid = (struct ext_selfid *)(sid - 1); 257 esid = (struct ext_selfid *)(sid - 1);
258 while (esid->extended) { 258 while (esid->extended) {
259 if ((esid->porta == 0x2) || (esid->portb == 0x2) 259 if ((esid->porta == SELFID_PORT_PARENT) ||
260 || (esid->portc == 0x2) || (esid->portd == 0x2) 260 (esid->portb == SELFID_PORT_PARENT) ||
261 || (esid->porte == 0x2) || (esid->portf == 0x2) 261 (esid->portc == SELFID_PORT_PARENT) ||
262 || (esid->portg == 0x2) || (esid->porth == 0x2)) { 262 (esid->portd == SELFID_PORT_PARENT) ||
263 (esid->porte == SELFID_PORT_PARENT) ||
264 (esid->portf == SELFID_PORT_PARENT) ||
265 (esid->portg == SELFID_PORT_PARENT) ||
266 (esid->porth == SELFID_PORT_PARENT)) {
263 HPSB_INFO("SelfIDs failed root check on " 267 HPSB_INFO("SelfIDs failed root check on "
264 "extended SelfID"); 268 "extended SelfID");
265 return 0; 269 return 0;
266 } 270 }
267 esid--; 271 esid--;
268 } 272 }
269 273
270 sid = (struct selfid *)esid; 274 sid = (struct selfid *)esid;
271 if ((sid->port0 == 0x2) || (sid->port1 == 0x2) || (sid->port2 == 0x2)) { 275 if ((sid->port0 == SELFID_PORT_PARENT) ||
276 (sid->port1 == SELFID_PORT_PARENT) ||
277 (sid->port2 == SELFID_PORT_PARENT)) {
272 HPSB_INFO("SelfIDs failed root check"); 278 HPSB_INFO("SelfIDs failed root check");
273 return 0; 279 return 0;
274 } 280 }
275 281
276 host->node_count = nodeid + 1; 282 host->node_count = nodeid + 1;
277 return 1; 283 return 1;
278} 284}
279 285
280static void build_speed_map(struct hpsb_host *host, int nodecount) 286static void build_speed_map(struct hpsb_host *host, int nodecount)
281{ 287{
282 u8 speedcap[nodecount]; 288 u8 speedcap[nodecount];
283 u8 cldcnt[nodecount]; 289 u8 cldcnt[nodecount];
284 u8 *map = host->speed_map; 290 u8 *map = host->speed_map;
285 struct selfid *sid; 291 struct selfid *sid;
286 struct ext_selfid *esid; 292 struct ext_selfid *esid;
287 int i, j, n; 293 int i, j, n;
288 294
289 for (i = 0; i < (nodecount * 64); i += 64) { 295 for (i = 0; i < (nodecount * 64); i += 64) {
290 for (j = 0; j < nodecount; j++) { 296 for (j = 0; j < nodecount; j++) {
291 map[i+j] = IEEE1394_SPEED_MAX; 297 map[i+j] = IEEE1394_SPEED_MAX;
292 } 298 }
293 } 299 }
294 300
295 for (i = 0; i < nodecount; i++) { 301 for (i = 0; i < nodecount; i++) {
296 cldcnt[i] = 0; 302 cldcnt[i] = 0;
297 } 303 }
298 304
299 /* find direct children count and speed */ 305 /* find direct children count and speed */
300 for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1], 306 for (sid = (struct selfid *)&host->topology_map[host->selfid_count-1],
301 n = nodecount - 1; 307 n = nodecount - 1;
302 (void *)sid >= (void *)host->topology_map; sid--) { 308 (void *)sid >= (void *)host->topology_map; sid--) {
303 if (sid->extended) { 309 if (sid->extended) {
304 esid = (struct ext_selfid *)sid; 310 esid = (struct ext_selfid *)sid;
305 311
306 if (esid->porta == 0x3) cldcnt[n]++; 312 if (esid->porta == SELFID_PORT_CHILD) cldcnt[n]++;
307 if (esid->portb == 0x3) cldcnt[n]++; 313 if (esid->portb == SELFID_PORT_CHILD) cldcnt[n]++;
308 if (esid->portc == 0x3) cldcnt[n]++; 314 if (esid->portc == SELFID_PORT_CHILD) cldcnt[n]++;
309 if (esid->portd == 0x3) cldcnt[n]++; 315 if (esid->portd == SELFID_PORT_CHILD) cldcnt[n]++;
310 if (esid->porte == 0x3) cldcnt[n]++; 316 if (esid->porte == SELFID_PORT_CHILD) cldcnt[n]++;
311 if (esid->portf == 0x3) cldcnt[n]++; 317 if (esid->portf == SELFID_PORT_CHILD) cldcnt[n]++;
312 if (esid->portg == 0x3) cldcnt[n]++; 318 if (esid->portg == SELFID_PORT_CHILD) cldcnt[n]++;
313 if (esid->porth == 0x3) cldcnt[n]++; 319 if (esid->porth == SELFID_PORT_CHILD) cldcnt[n]++;
314 } else { 320 } else {
315 if (sid->port0 == 0x3) cldcnt[n]++; 321 if (sid->port0 == SELFID_PORT_CHILD) cldcnt[n]++;
316 if (sid->port1 == 0x3) cldcnt[n]++; 322 if (sid->port1 == SELFID_PORT_CHILD) cldcnt[n]++;
317 if (sid->port2 == 0x3) cldcnt[n]++; 323 if (sid->port2 == SELFID_PORT_CHILD) cldcnt[n]++;
318 324
319 speedcap[n] = sid->speed; 325 speedcap[n] = sid->speed;
320 n--; 326 n--;
321 } 327 }
322 } 328 }
323 329
324 /* set self mapping */ 330 /* set self mapping */
325 for (i = 0; i < nodecount; i++) { 331 for (i = 0; i < nodecount; i++) {
326 map[64*i + i] = speedcap[i]; 332 map[64*i + i] = speedcap[i];
327 } 333 }
328 334
329 /* fix up direct children count to total children count; 335 /* fix up direct children count to total children count;
330 * also fix up speedcaps for sibling and parent communication */ 336 * also fix up speedcaps for sibling and parent communication */
331 for (i = 1; i < nodecount; i++) { 337 for (i = 1; i < nodecount; i++) {
332 for (j = cldcnt[i], n = i - 1; j > 0; j--) { 338 for (j = cldcnt[i], n = i - 1; j > 0; j--) {
333 cldcnt[i] += cldcnt[n]; 339 cldcnt[i] += cldcnt[n];
334 speedcap[n] = min(speedcap[n], speedcap[i]); 340 speedcap[n] = min(speedcap[n], speedcap[i]);
335 n -= cldcnt[n] + 1; 341 n -= cldcnt[n] + 1;
336 } 342 }
337 } 343 }
338 344
339 for (n = 0; n < nodecount; n++) { 345 for (n = 0; n < nodecount; n++) {
340 for (i = n - cldcnt[n]; i <= n; i++) { 346 for (i = n - cldcnt[n]; i <= n; i++) {
341 for (j = 0; j < (n - cldcnt[n]); j++) { 347 for (j = 0; j < (n - cldcnt[n]); j++) {
342 map[j*64 + i] = map[i*64 + j] = 348 map[j*64 + i] = map[i*64 + j] =
343 min(map[i*64 + j], speedcap[n]); 349 min(map[i*64 + j], speedcap[n]);
344 } 350 }
345 for (j = n + 1; j < nodecount; j++) { 351 for (j = n + 1; j < nodecount; j++) {
346 map[j*64 + i] = map[i*64 + j] = 352 map[j*64 + i] = map[i*64 + j] =
347 min(map[i*64 + j], speedcap[n]); 353 min(map[i*64 + j], speedcap[n]);
348 } 354 }
349 } 355 }
350 } 356 }
351} 357}
352 358
353 359
354void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid) 360void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid)
355{ 361{
356 if (host->in_bus_reset) { 362 if (host->in_bus_reset) {
357 HPSB_VERBOSE("Including SelfID 0x%x", sid); 363 HPSB_VERBOSE("Including SelfID 0x%x", sid);
358 host->topology_map[host->selfid_count++] = sid; 364 host->topology_map[host->selfid_count++] = sid;
359 } else { 365 } else {
360 HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d", 366 HPSB_NOTICE("Spurious SelfID packet (0x%08x) received from bus %d",
361 sid, NODEID_TO_BUS(host->node_id)); 367 sid, NODEID_TO_BUS(host->node_id));
362 } 368 }
363} 369}
364 370
365void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot) 371void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
@@ -367,50 +373,50 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
367 if (!host->in_bus_reset) 373 if (!host->in_bus_reset)
368 HPSB_NOTICE("SelfID completion called outside of bus reset!"); 374 HPSB_NOTICE("SelfID completion called outside of bus reset!");
369 375
370 host->node_id = LOCAL_BUS | phyid; 376 host->node_id = LOCAL_BUS | phyid;
371 host->is_root = isroot; 377 host->is_root = isroot;
372 378
373 if (!check_selfids(host)) { 379 if (!check_selfids(host)) {
374 if (host->reset_retries++ < 20) { 380 if (host->reset_retries++ < 20) {
375 /* selfid stage did not complete without error */ 381 /* selfid stage did not complete without error */
376 HPSB_NOTICE("Error in SelfID stage, resetting"); 382 HPSB_NOTICE("Error in SelfID stage, resetting");
377 host->in_bus_reset = 0; 383 host->in_bus_reset = 0;
378 /* this should work from ohci1394 now... */ 384 /* this should work from ohci1394 now... */
379 hpsb_reset_bus(host, LONG_RESET); 385 hpsb_reset_bus(host, LONG_RESET);
380 return; 386 return;
381 } else { 387 } else {
382 HPSB_NOTICE("Stopping out-of-control reset loop"); 388 HPSB_NOTICE("Stopping out-of-control reset loop");
383 HPSB_NOTICE("Warning - topology map and speed map will not be valid"); 389 HPSB_NOTICE("Warning - topology map and speed map will not be valid");
384 host->reset_retries = 0; 390 host->reset_retries = 0;
385 } 391 }
386 } else { 392 } else {
387 host->reset_retries = 0; 393 host->reset_retries = 0;
388 build_speed_map(host, host->node_count); 394 build_speed_map(host, host->node_count);
389 } 395 }
390 396
391 HPSB_VERBOSE("selfid_complete called with successful SelfID stage " 397 HPSB_VERBOSE("selfid_complete called with successful SelfID stage "
392 "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id); 398 "... irm_id: 0x%X node_id: 0x%X",host->irm_id,host->node_id);
393 399
394 /* irm_id is kept up to date by check_selfids() */ 400 /* irm_id is kept up to date by check_selfids() */
395 if (host->irm_id == host->node_id) { 401 if (host->irm_id == host->node_id) {
396 host->is_irm = 1; 402 host->is_irm = 1;
397 } else { 403 } else {
398 host->is_busmgr = 0; 404 host->is_busmgr = 0;
399 host->is_irm = 0; 405 host->is_irm = 0;
400 } 406 }
401 407
402 if (isroot) { 408 if (isroot) {
403 host->driver->devctl(host, ACT_CYCLE_MASTER, 1); 409 host->driver->devctl(host, ACT_CYCLE_MASTER, 1);
404 host->is_cycmst = 1; 410 host->is_cycmst = 1;
405 } 411 }
406 atomic_inc(&host->generation); 412 atomic_inc(&host->generation);
407 host->in_bus_reset = 0; 413 host->in_bus_reset = 0;
408 highlevel_host_reset(host); 414 highlevel_host_reset(host);
409} 415}
410 416
411 417
412void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, 418void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
413 int ackcode) 419 int ackcode)
414{ 420{
415 unsigned long flags; 421 unsigned long flags;
416 422
@@ -457,6 +463,7 @@ void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
457int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt) 463int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
458{ 464{
459 struct hpsb_packet *packet; 465 struct hpsb_packet *packet;
466 quadlet_t d = 0;
460 int retval = 0; 467 int retval = 0;
461 468
462 if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 || 469 if (rootid >= ALL_NODES || rootid < -1 || gapcnt > 0x3f || gapcnt < -1 ||
@@ -466,26 +473,16 @@ int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt)
466 return -EINVAL; 473 return -EINVAL;
467 } 474 }
468 475
469 packet = hpsb_alloc_packet(0);
470 if (!packet)
471 return -ENOMEM;
472
473 packet->host = host;
474 packet->header_size = 8;
475 packet->data_size = 0;
476 packet->expect_response = 0;
477 packet->no_waiter = 0;
478 packet->type = hpsb_raw;
479 packet->header[0] = 0;
480 if (rootid != -1) 476 if (rootid != -1)
481 packet->header[0] |= rootid << 24 | 1 << 23; 477 d |= PHYPACKET_PHYCONFIG_R | rootid << PHYPACKET_PORT_SHIFT;
482 if (gapcnt != -1) 478 if (gapcnt != -1)
483 packet->header[0] |= gapcnt << 16 | 1 << 22; 479 d |= PHYPACKET_PHYCONFIG_T | gapcnt << PHYPACKET_GAPCOUNT_SHIFT;
484 480
485 packet->header[1] = ~packet->header[0]; 481 packet = hpsb_make_phypacket(host, d);
482 if (!packet)
483 return -ENOMEM;
486 484
487 packet->generation = get_hpsb_generation(host); 485 packet->generation = get_hpsb_generation(host);
488
489 retval = hpsb_send_packet_and_wait(packet); 486 retval = hpsb_send_packet_and_wait(packet);
490 hpsb_free_packet(packet); 487 hpsb_free_packet(packet);
491 488
@@ -510,13 +507,13 @@ int hpsb_send_packet(struct hpsb_packet *packet)
510{ 507{
511 struct hpsb_host *host = packet->host; 508 struct hpsb_host *host = packet->host;
512 509
513 if (host->is_shutdown) 510 if (host->is_shutdown)
514 return -EINVAL; 511 return -EINVAL;
515 if (host->in_bus_reset || 512 if (host->in_bus_reset ||
516 (packet->generation != get_hpsb_generation(host))) 513 (packet->generation != get_hpsb_generation(host)))
517 return -EAGAIN; 514 return -EAGAIN;
518 515
519 packet->state = hpsb_queued; 516 packet->state = hpsb_queued;
520 517
521 /* This just seems silly to me */ 518 /* This just seems silly to me */
522 WARN_ON(packet->no_waiter && packet->expect_response); 519 WARN_ON(packet->no_waiter && packet->expect_response);
@@ -530,42 +527,42 @@ int hpsb_send_packet(struct hpsb_packet *packet)
530 skb_queue_tail(&host->pending_packet_queue, packet->skb); 527 skb_queue_tail(&host->pending_packet_queue, packet->skb);
531 } 528 }
532 529
533 if (packet->node_id == host->node_id) { 530 if (packet->node_id == host->node_id) {
534 /* it is a local request, so handle it locally */ 531 /* it is a local request, so handle it locally */
535 532
536 quadlet_t *data; 533 quadlet_t *data;
537 size_t size = packet->data_size + packet->header_size; 534 size_t size = packet->data_size + packet->header_size;
538 535
539 data = kmalloc(size, GFP_ATOMIC); 536 data = kmalloc(size, GFP_ATOMIC);
540 if (!data) { 537 if (!data) {
541 HPSB_ERR("unable to allocate memory for concatenating header and data"); 538 HPSB_ERR("unable to allocate memory for concatenating header and data");
542 return -ENOMEM; 539 return -ENOMEM;
543 } 540 }
544 541
545 memcpy(data, packet->header, packet->header_size); 542 memcpy(data, packet->header, packet->header_size);
546 543
547 if (packet->data_size) 544 if (packet->data_size)
548 memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size); 545 memcpy(((u8*)data) + packet->header_size, packet->data, packet->data_size);
549 546
550 dump_packet("send packet local", packet->header, packet->header_size, -1); 547 dump_packet("send packet local", packet->header, packet->header_size, -1);
551 548
552 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE); 549 hpsb_packet_sent(host, packet, packet->expect_response ? ACK_PENDING : ACK_COMPLETE);
553 hpsb_packet_received(host, data, size, 0); 550 hpsb_packet_received(host, data, size, 0);
554 551
555 kfree(data); 552 kfree(data);
556 553
557 return 0; 554 return 0;
558 } 555 }
559 556
560 if (packet->type == hpsb_async && packet->node_id != ALL_NODES) { 557 if (packet->type == hpsb_async && packet->node_id != ALL_NODES) {
561 packet->speed_code = 558 packet->speed_code =
562 host->speed_map[NODEID_TO_NODE(host->node_id) * 64 559 host->speed_map[NODEID_TO_NODE(host->node_id) * 64
563 + NODEID_TO_NODE(packet->node_id)]; 560 + NODEID_TO_NODE(packet->node_id)];
564 } 561 }
565 562
566 dump_packet("send packet", packet->header, packet->header_size, packet->speed_code); 563 dump_packet("send packet", packet->header, packet->header_size, packet->speed_code);
567 564
568 return host->driver->transmit_packet(host, packet); 565 return host->driver->transmit_packet(host, packet);
569} 566}
570 567
571/* We could just use complete() directly as the packet complete 568/* We could just use complete() directly as the packet complete
@@ -593,81 +590,81 @@ int hpsb_send_packet_and_wait(struct hpsb_packet *packet)
593 590
594static void send_packet_nocare(struct hpsb_packet *packet) 591static void send_packet_nocare(struct hpsb_packet *packet)
595{ 592{
596 if (hpsb_send_packet(packet) < 0) { 593 if (hpsb_send_packet(packet) < 0) {
597 hpsb_free_packet(packet); 594 hpsb_free_packet(packet);
598 } 595 }
599} 596}
600 597
601 598
602static void handle_packet_response(struct hpsb_host *host, int tcode, 599static void handle_packet_response(struct hpsb_host *host, int tcode,
603 quadlet_t *data, size_t size) 600 quadlet_t *data, size_t size)
604{ 601{
605 struct hpsb_packet *packet = NULL; 602 struct hpsb_packet *packet = NULL;
606 struct sk_buff *skb; 603 struct sk_buff *skb;
607 int tcode_match = 0; 604 int tcode_match = 0;
608 int tlabel; 605 int tlabel;
609 unsigned long flags; 606 unsigned long flags;
610 607
611 tlabel = (data[0] >> 10) & 0x3f; 608 tlabel = (data[0] >> 10) & 0x3f;
612 609
613 spin_lock_irqsave(&host->pending_packet_queue.lock, flags); 610 spin_lock_irqsave(&host->pending_packet_queue.lock, flags);
614 611
615 skb_queue_walk(&host->pending_packet_queue, skb) { 612 skb_queue_walk(&host->pending_packet_queue, skb) {
616 packet = (struct hpsb_packet *)skb->data; 613 packet = (struct hpsb_packet *)skb->data;
617 if ((packet->tlabel == tlabel) 614 if ((packet->tlabel == tlabel)
618 && (packet->node_id == (data[1] >> 16))){ 615 && (packet->node_id == (data[1] >> 16))){
619 break; 616 break;
620 } 617 }
621 618
622 packet = NULL; 619 packet = NULL;
623 } 620 }
624 621
625 if (packet == NULL) { 622 if (packet == NULL) {
626 HPSB_DEBUG("unsolicited response packet received - no tlabel match"); 623 HPSB_DEBUG("unsolicited response packet received - no tlabel match");
627 dump_packet("contents", data, 16, -1); 624 dump_packet("contents", data, 16, -1);
628 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); 625 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
629 return; 626 return;
630 } 627 }
631 628
632 switch (packet->tcode) { 629 switch (packet->tcode) {
633 case TCODE_WRITEQ: 630 case TCODE_WRITEQ:
634 case TCODE_WRITEB: 631 case TCODE_WRITEB:
635 if (tcode != TCODE_WRITE_RESPONSE) 632 if (tcode != TCODE_WRITE_RESPONSE)
636 break; 633 break;
637 tcode_match = 1; 634 tcode_match = 1;
638 memcpy(packet->header, data, 12); 635 memcpy(packet->header, data, 12);
639 break; 636 break;
640 case TCODE_READQ: 637 case TCODE_READQ:
641 if (tcode != TCODE_READQ_RESPONSE) 638 if (tcode != TCODE_READQ_RESPONSE)
642 break; 639 break;
643 tcode_match = 1; 640 tcode_match = 1;
644 memcpy(packet->header, data, 16); 641 memcpy(packet->header, data, 16);
645 break; 642 break;
646 case TCODE_READB: 643 case TCODE_READB:
647 if (tcode != TCODE_READB_RESPONSE) 644 if (tcode != TCODE_READB_RESPONSE)
648 break; 645 break;
649 tcode_match = 1; 646 tcode_match = 1;
650 BUG_ON(packet->skb->len - sizeof(*packet) < size - 16); 647 BUG_ON(packet->skb->len - sizeof(*packet) < size - 16);
651 memcpy(packet->header, data, 16); 648 memcpy(packet->header, data, 16);
652 memcpy(packet->data, data + 4, size - 16); 649 memcpy(packet->data, data + 4, size - 16);
653 break; 650 break;
654 case TCODE_LOCK_REQUEST: 651 case TCODE_LOCK_REQUEST:
655 if (tcode != TCODE_LOCK_RESPONSE) 652 if (tcode != TCODE_LOCK_RESPONSE)
656 break; 653 break;
657 tcode_match = 1; 654 tcode_match = 1;
658 size = min((size - 16), (size_t)8); 655 size = min((size - 16), (size_t)8);
659 BUG_ON(packet->skb->len - sizeof(*packet) < size); 656 BUG_ON(packet->skb->len - sizeof(*packet) < size);
660 memcpy(packet->header, data, 16); 657 memcpy(packet->header, data, 16);
661 memcpy(packet->data, data + 4, size); 658 memcpy(packet->data, data + 4, size);
662 break; 659 break;
663 } 660 }
664 661
665 if (!tcode_match) { 662 if (!tcode_match) {
666 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags); 663 spin_unlock_irqrestore(&host->pending_packet_queue.lock, flags);
667 HPSB_INFO("unsolicited response packet received - tcode mismatch"); 664 HPSB_INFO("unsolicited response packet received - tcode mismatch");
668 dump_packet("contents", data, 16, -1); 665 dump_packet("contents", data, 16, -1);
669 return; 666 return;
670 } 667 }
671 668
672 __skb_unlink(skb, &host->pending_packet_queue); 669 __skb_unlink(skb, &host->pending_packet_queue);
673 670
@@ -686,27 +683,27 @@ static void handle_packet_response(struct hpsb_host *host, int tcode,
686static struct hpsb_packet *create_reply_packet(struct hpsb_host *host, 683static struct hpsb_packet *create_reply_packet(struct hpsb_host *host,
687 quadlet_t *data, size_t dsize) 684 quadlet_t *data, size_t dsize)
688{ 685{
689 struct hpsb_packet *p; 686 struct hpsb_packet *p;
690 687
691 p = hpsb_alloc_packet(dsize); 688 p = hpsb_alloc_packet(dsize);
692 if (unlikely(p == NULL)) { 689 if (unlikely(p == NULL)) {
693 /* FIXME - send data_error response */ 690 /* FIXME - send data_error response */
694 return NULL; 691 return NULL;
695 } 692 }
696 693
697 p->type = hpsb_async; 694 p->type = hpsb_async;
698 p->state = hpsb_unused; 695 p->state = hpsb_unused;
699 p->host = host; 696 p->host = host;
700 p->node_id = data[1] >> 16; 697 p->node_id = data[1] >> 16;
701 p->tlabel = (data[0] >> 10) & 0x3f; 698 p->tlabel = (data[0] >> 10) & 0x3f;
702 p->no_waiter = 1; 699 p->no_waiter = 1;
703 700
704 p->generation = get_hpsb_generation(host); 701 p->generation = get_hpsb_generation(host);
705 702
706 if (dsize % 4) 703 if (dsize % 4)
707 p->data[dsize / 4] = 0; 704 p->data[dsize / 4] = 0;
708 705
709 return p; 706 return p;
710} 707}
711 708
712#define PREP_ASYNC_HEAD_RCODE(tc) \ 709#define PREP_ASYNC_HEAD_RCODE(tc) \
@@ -717,7 +714,7 @@ static struct hpsb_packet *create_reply_packet(struct hpsb_host *host,
717 packet->header[2] = 0 714 packet->header[2] = 0
718 715
719static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode, 716static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode,
720 quadlet_t data) 717 quadlet_t data)
721{ 718{
722 PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE); 719 PREP_ASYNC_HEAD_RCODE(TCODE_READQ_RESPONSE);
723 packet->header[3] = data; 720 packet->header[3] = data;
@@ -726,7 +723,7 @@ static void fill_async_readquad_resp(struct hpsb_packet *packet, int rcode,
726} 723}
727 724
728static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode, 725static void fill_async_readblock_resp(struct hpsb_packet *packet, int rcode,
729 int length) 726 int length)
730{ 727{
731 if (rcode != RCODE_COMPLETE) 728 if (rcode != RCODE_COMPLETE)
732 length = 0; 729 length = 0;
@@ -746,7 +743,7 @@ static void fill_async_write_resp(struct hpsb_packet *packet, int rcode)
746} 743}
747 744
748static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode, 745static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extcode,
749 int length) 746 int length)
750{ 747{
751 if (rcode != RCODE_COMPLETE) 748 if (rcode != RCODE_COMPLETE)
752 length = 0; 749 length = 0;
@@ -758,184 +755,184 @@ static void fill_async_lock_resp(struct hpsb_packet *packet, int rcode, int extc
758} 755}
759 756
760#define PREP_REPLY_PACKET(length) \ 757#define PREP_REPLY_PACKET(length) \
761 packet = create_reply_packet(host, data, length); \ 758 packet = create_reply_packet(host, data, length); \
762 if (packet == NULL) break 759 if (packet == NULL) break
763 760
764static void handle_incoming_packet(struct hpsb_host *host, int tcode, 761static void handle_incoming_packet(struct hpsb_host *host, int tcode,
765 quadlet_t *data, size_t size, int write_acked) 762 quadlet_t *data, size_t size, int write_acked)
766{ 763{
767 struct hpsb_packet *packet; 764 struct hpsb_packet *packet;
768 int length, rcode, extcode; 765 int length, rcode, extcode;
769 quadlet_t buffer; 766 quadlet_t buffer;
770 nodeid_t source = data[1] >> 16; 767 nodeid_t source = data[1] >> 16;
771 nodeid_t dest = data[0] >> 16; 768 nodeid_t dest = data[0] >> 16;
772 u16 flags = (u16) data[0]; 769 u16 flags = (u16) data[0];
773 u64 addr; 770 u64 addr;
774 771
775 /* big FIXME - no error checking is done for an out of bounds length */ 772 /* big FIXME - no error checking is done for an out of bounds length */
776 773
777 switch (tcode) { 774 switch (tcode) {
778 case TCODE_WRITEQ: 775 case TCODE_WRITEQ:
779 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 776 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
780 rcode = highlevel_write(host, source, dest, data+3, 777 rcode = highlevel_write(host, source, dest, data+3,
781 addr, 4, flags); 778 addr, 4, flags);
782 779
783 if (!write_acked 780 if (!write_acked
784 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) 781 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK)
785 && (rcode >= 0)) { 782 && (rcode >= 0)) {
786 /* not a broadcast write, reply */ 783 /* not a broadcast write, reply */
787 PREP_REPLY_PACKET(0); 784 PREP_REPLY_PACKET(0);
788 fill_async_write_resp(packet, rcode); 785 fill_async_write_resp(packet, rcode);
789 send_packet_nocare(packet); 786 send_packet_nocare(packet);
790 } 787 }
791 break; 788 break;
792 789
793 case TCODE_WRITEB: 790 case TCODE_WRITEB:
794 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 791 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
795 rcode = highlevel_write(host, source, dest, data+4, 792 rcode = highlevel_write(host, source, dest, data+4,
796 addr, data[3]>>16, flags); 793 addr, data[3]>>16, flags);
797 794
798 if (!write_acked 795 if (!write_acked
799 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK) 796 && (NODEID_TO_NODE(data[0] >> 16) != NODE_MASK)
800 && (rcode >= 0)) { 797 && (rcode >= 0)) {
801 /* not a broadcast write, reply */ 798 /* not a broadcast write, reply */
802 PREP_REPLY_PACKET(0); 799 PREP_REPLY_PACKET(0);
803 fill_async_write_resp(packet, rcode); 800 fill_async_write_resp(packet, rcode);
804 send_packet_nocare(packet); 801 send_packet_nocare(packet);
805 } 802 }
806 break; 803 break;
807 804
808 case TCODE_READQ: 805 case TCODE_READQ:
809 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 806 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
810 rcode = highlevel_read(host, source, &buffer, addr, 4, flags); 807 rcode = highlevel_read(host, source, &buffer, addr, 4, flags);
811 808
812 if (rcode >= 0) { 809 if (rcode >= 0) {
813 PREP_REPLY_PACKET(0); 810 PREP_REPLY_PACKET(0);
814 fill_async_readquad_resp(packet, rcode, buffer); 811 fill_async_readquad_resp(packet, rcode, buffer);
815 send_packet_nocare(packet); 812 send_packet_nocare(packet);
816 } 813 }
817 break; 814 break;
818 815
819 case TCODE_READB: 816 case TCODE_READB:
820 length = data[3] >> 16; 817 length = data[3] >> 16;
821 PREP_REPLY_PACKET(length); 818 PREP_REPLY_PACKET(length);
822 819
823 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 820 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
824 rcode = highlevel_read(host, source, packet->data, addr, 821 rcode = highlevel_read(host, source, packet->data, addr,
825 length, flags); 822 length, flags);
826 823
827 if (rcode >= 0) { 824 if (rcode >= 0) {
828 fill_async_readblock_resp(packet, rcode, length); 825 fill_async_readblock_resp(packet, rcode, length);
829 send_packet_nocare(packet); 826 send_packet_nocare(packet);
830 } else { 827 } else {
831 hpsb_free_packet(packet); 828 hpsb_free_packet(packet);
832 } 829 }
833 break; 830 break;
834 831
835 case TCODE_LOCK_REQUEST: 832 case TCODE_LOCK_REQUEST:
836 length = data[3] >> 16; 833 length = data[3] >> 16;
837 extcode = data[3] & 0xffff; 834 extcode = data[3] & 0xffff;
838 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2]; 835 addr = (((u64)(data[1] & 0xffff)) << 32) | data[2];
839 836
840 PREP_REPLY_PACKET(8); 837 PREP_REPLY_PACKET(8);
841 838
842 if ((extcode == 0) || (extcode >= 7)) { 839 if ((extcode == 0) || (extcode >= 7)) {
843 /* let switch default handle error */ 840 /* let switch default handle error */
844 length = 0; 841 length = 0;
845 } 842 }
846 843
847 switch (length) { 844 switch (length) {
848 case 4: 845 case 4:
849 rcode = highlevel_lock(host, source, packet->data, addr, 846 rcode = highlevel_lock(host, source, packet->data, addr,
850 data[4], 0, extcode,flags); 847 data[4], 0, extcode,flags);
851 fill_async_lock_resp(packet, rcode, extcode, 4); 848 fill_async_lock_resp(packet, rcode, extcode, 4);
852 break; 849 break;
853 case 8: 850 case 8:
854 if ((extcode != EXTCODE_FETCH_ADD) 851 if ((extcode != EXTCODE_FETCH_ADD)
855 && (extcode != EXTCODE_LITTLE_ADD)) { 852 && (extcode != EXTCODE_LITTLE_ADD)) {
856 rcode = highlevel_lock(host, source, 853 rcode = highlevel_lock(host, source,
857 packet->data, addr, 854 packet->data, addr,
858 data[5], data[4], 855 data[5], data[4],
859 extcode, flags); 856 extcode, flags);
860 fill_async_lock_resp(packet, rcode, extcode, 4); 857 fill_async_lock_resp(packet, rcode, extcode, 4);
861 } else { 858 } else {
862 rcode = highlevel_lock64(host, source, 859 rcode = highlevel_lock64(host, source,
863 (octlet_t *)packet->data, addr, 860 (octlet_t *)packet->data, addr,
864 *(octlet_t *)(data + 4), 0ULL, 861 *(octlet_t *)(data + 4), 0ULL,
865 extcode, flags); 862 extcode, flags);
866 fill_async_lock_resp(packet, rcode, extcode, 8); 863 fill_async_lock_resp(packet, rcode, extcode, 8);
867 } 864 }
868 break; 865 break;
869 case 16: 866 case 16:
870 rcode = highlevel_lock64(host, source, 867 rcode = highlevel_lock64(host, source,
871 (octlet_t *)packet->data, addr, 868 (octlet_t *)packet->data, addr,
872 *(octlet_t *)(data + 6), 869 *(octlet_t *)(data + 6),
873 *(octlet_t *)(data + 4), 870 *(octlet_t *)(data + 4),
874 extcode, flags); 871 extcode, flags);
875 fill_async_lock_resp(packet, rcode, extcode, 8); 872 fill_async_lock_resp(packet, rcode, extcode, 8);
876 break; 873 break;
877 default: 874 default:
878 rcode = RCODE_TYPE_ERROR; 875 rcode = RCODE_TYPE_ERROR;
879 fill_async_lock_resp(packet, rcode, 876 fill_async_lock_resp(packet, rcode,
880 extcode, 0); 877 extcode, 0);
881 } 878 }
882 879
883 if (rcode >= 0) { 880 if (rcode >= 0) {
884 send_packet_nocare(packet); 881 send_packet_nocare(packet);
885 } else { 882 } else {
886 hpsb_free_packet(packet); 883 hpsb_free_packet(packet);
887 } 884 }
888 break; 885 break;
889 } 886 }
890 887
891} 888}
892#undef PREP_REPLY_PACKET 889#undef PREP_REPLY_PACKET
893 890
894 891
895void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, 892void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
896 int write_acked) 893 int write_acked)
897{ 894{
898 int tcode; 895 int tcode;
899 896
900 if (host->in_bus_reset) { 897 if (host->in_bus_reset) {
901 HPSB_INFO("received packet during reset; ignoring"); 898 HPSB_INFO("received packet during reset; ignoring");
902 return; 899 return;
903 } 900 }
904 901
905 dump_packet("received packet", data, size, -1); 902 dump_packet("received packet", data, size, -1);
906 903
907 tcode = (data[0] >> 4) & 0xf; 904 tcode = (data[0] >> 4) & 0xf;
908 905
909 switch (tcode) { 906 switch (tcode) {
910 case TCODE_WRITE_RESPONSE: 907 case TCODE_WRITE_RESPONSE:
911 case TCODE_READQ_RESPONSE: 908 case TCODE_READQ_RESPONSE:
912 case TCODE_READB_RESPONSE: 909 case TCODE_READB_RESPONSE:
913 case TCODE_LOCK_RESPONSE: 910 case TCODE_LOCK_RESPONSE:
914 handle_packet_response(host, tcode, data, size); 911 handle_packet_response(host, tcode, data, size);
915 break; 912 break;
916 913
917 case TCODE_WRITEQ: 914 case TCODE_WRITEQ:
918 case TCODE_WRITEB: 915 case TCODE_WRITEB:
919 case TCODE_READQ: 916 case TCODE_READQ:
920 case TCODE_READB: 917 case TCODE_READB:
921 case TCODE_LOCK_REQUEST: 918 case TCODE_LOCK_REQUEST:
922 handle_incoming_packet(host, tcode, data, size, write_acked); 919 handle_incoming_packet(host, tcode, data, size, write_acked);
923 break; 920 break;
924 921
925 922
926 case TCODE_ISO_DATA: 923 case TCODE_ISO_DATA:
927 highlevel_iso_receive(host, data, size); 924 highlevel_iso_receive(host, data, size);
928 break; 925 break;
929 926
930 case TCODE_CYCLE_START: 927 case TCODE_CYCLE_START:
931 /* simply ignore this packet if it is passed on */ 928 /* simply ignore this packet if it is passed on */
932 break; 929 break;
933 930
934 default: 931 default:
935 HPSB_NOTICE("received packet with bogus transaction code %d", 932 HPSB_NOTICE("received packet with bogus transaction code %d",
936 tcode); 933 tcode);
937 break; 934 break;
938 } 935 }
939} 936}
940 937
941 938
@@ -1030,10 +1027,10 @@ static int hpsbpkt_thread(void *__hi)
1030 1027
1031 daemonize("khpsbpkt"); 1028 daemonize("khpsbpkt");
1032 1029
1030 current->flags |= PF_NOFREEZE;
1031
1033 while (1) { 1032 while (1) {
1034 if (down_interruptible(&khpsbpkt_sig)) { 1033 if (down_interruptible(&khpsbpkt_sig)) {
1035 if (try_to_freeze())
1036 continue;
1037 printk("khpsbpkt: received unexpected signal?!\n" ); 1034 printk("khpsbpkt: received unexpected signal?!\n" );
1038 break; 1035 break;
1039 } 1036 }
@@ -1129,7 +1126,7 @@ static int __init ieee1394_init(void)
1129 nodemgr implements functionality required of ieee1394a-2000 1126 nodemgr implements functionality required of ieee1394a-2000
1130 IRMs */ 1127 IRMs */
1131 hpsb_disable_irm = 1; 1128 hpsb_disable_irm = 1;
1132 1129
1133 return 0; 1130 return 0;
1134 } 1131 }
1135 1132
diff --git a/drivers/ieee1394/ieee1394_core.h b/drivers/ieee1394/ieee1394_core.h
index 0b31429d0a68..b35466023f00 100644
--- a/drivers/ieee1394/ieee1394_core.h
+++ b/drivers/ieee1394/ieee1394_core.h
@@ -10,8 +10,8 @@
10 10
11 11
12struct hpsb_packet { 12struct hpsb_packet {
13 /* This struct is basically read-only for hosts with the exception of 13 /* This struct is basically read-only for hosts with the exception of
14 * the data buffer contents and xnext - see below. */ 14 * the data buffer contents and xnext - see below. */
15 15
16 /* This can be used for host driver internal linking. 16 /* This can be used for host driver internal linking.
17 * 17 *
@@ -21,47 +21,47 @@ struct hpsb_packet {
21 * driver_list when free'ing it. */ 21 * driver_list when free'ing it. */
22 struct list_head driver_list; 22 struct list_head driver_list;
23 23
24 nodeid_t node_id; 24 nodeid_t node_id;
25 25
26 /* Async and Iso types should be clear, raw means send-as-is, do not 26 /* Async and Iso types should be clear, raw means send-as-is, do not
27 * CRC! Byte swapping shall still be done in this case. */ 27 * CRC! Byte swapping shall still be done in this case. */
28 enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type; 28 enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type;
29 29
30 /* Okay, this is core internal and a no care for hosts. 30 /* Okay, this is core internal and a no care for hosts.
31 * queued = queued for sending 31 * queued = queued for sending
32 * pending = sent, waiting for response 32 * pending = sent, waiting for response
33 * complete = processing completed, successful or not 33 * complete = processing completed, successful or not
34 */ 34 */
35 enum { 35 enum {
36 hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete 36 hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete
37 } __attribute__((packed)) state; 37 } __attribute__((packed)) state;
38 38
39 /* These are core internal. */ 39 /* These are core internal. */
40 signed char tlabel; 40 signed char tlabel;
41 signed char ack_code; 41 signed char ack_code;
42 unsigned char tcode; 42 unsigned char tcode;
43 43
44 unsigned expect_response:1; 44 unsigned expect_response:1;
45 unsigned no_waiter:1; 45 unsigned no_waiter:1;
46 46
47 /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */ 47 /* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */
48 unsigned speed_code:2; 48 unsigned speed_code:2;
49 49
50 /* 50 /*
51 * *header and *data are guaranteed to be 32-bit DMAable and may be 51 * *header and *data are guaranteed to be 32-bit DMAable and may be
52 * overwritten to allow in-place byte swapping. Neither of these is 52 * overwritten to allow in-place byte swapping. Neither of these is
53 * CRCed (the sizes also don't include CRC), but contain space for at 53 * CRCed (the sizes also don't include CRC), but contain space for at
54 * least one additional quadlet to allow in-place CRCing. The memory is 54 * least one additional quadlet to allow in-place CRCing. The memory is
55 * also guaranteed to be DMA mappable. 55 * also guaranteed to be DMA mappable.
56 */ 56 */
57 quadlet_t *header; 57 quadlet_t *header;
58 quadlet_t *data; 58 quadlet_t *data;
59 size_t header_size; 59 size_t header_size;
60 size_t data_size; 60 size_t data_size;
61 61
62 62
63 struct hpsb_host *host; 63 struct hpsb_host *host;
64 unsigned int generation; 64 unsigned int generation;
65 65
66 atomic_t refcnt; 66 atomic_t refcnt;
67 67
@@ -73,10 +73,10 @@ struct hpsb_packet {
73 /* XXX This is just a hack at the moment */ 73 /* XXX This is just a hack at the moment */
74 struct sk_buff *skb; 74 struct sk_buff *skb;
75 75
76 /* Store jiffies for implementing bus timeouts. */ 76 /* Store jiffies for implementing bus timeouts. */
77 unsigned long sendtime; 77 unsigned long sendtime;
78 78
79 quadlet_t embedded_header[5]; 79 quadlet_t embedded_header[5];
80}; 80};
81 81
82/* Set a task for when a packet completes */ 82/* Set a task for when a packet completes */
@@ -102,7 +102,7 @@ void hpsb_free_packet(struct hpsb_packet *packet);
102 */ 102 */
103static inline unsigned int get_hpsb_generation(struct hpsb_host *host) 103static inline unsigned int get_hpsb_generation(struct hpsb_host *host)
104{ 104{
105 return atomic_read(&host->generation); 105 return atomic_read(&host->generation);
106} 106}
107 107
108/* 108/*
@@ -157,7 +157,7 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot);
157 * from within a transmit packet routine. 157 * from within a transmit packet routine.
158 */ 158 */
159void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet, 159void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
160 int ackcode); 160 int ackcode);
161 161
162/* 162/*
163 * Hand over received packet to the core. The contents of data are expected to 163 * Hand over received packet to the core. The contents of data are expected to
@@ -171,7 +171,7 @@ void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
171 * packet type. 171 * packet type.
172 */ 172 */
173void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size, 173void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
174 int write_acked); 174 int write_acked);
175 175
176 176
177/* 177/*
@@ -197,20 +197,20 @@ void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
197 * Block 15 (240-255) reserved for drivers under development, etc. 197 * Block 15 (240-255) reserved for drivers under development, etc.
198 */ 198 */
199 199
200#define IEEE1394_MAJOR 171 200#define IEEE1394_MAJOR 171
201 201
202#define IEEE1394_MINOR_BLOCK_RAW1394 0 202#define IEEE1394_MINOR_BLOCK_RAW1394 0
203#define IEEE1394_MINOR_BLOCK_VIDEO1394 1 203#define IEEE1394_MINOR_BLOCK_VIDEO1394 1
204#define IEEE1394_MINOR_BLOCK_DV1394 2 204#define IEEE1394_MINOR_BLOCK_DV1394 2
205#define IEEE1394_MINOR_BLOCK_AMDTP 3 205#define IEEE1394_MINOR_BLOCK_AMDTP 3
206#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15 206#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
207 207
208#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0) 208#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0)
209#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16) 209#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)
210#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16) 210#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_VIDEO1394 * 16)
211#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16) 211#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_DV1394 * 16)
212#define IEEE1394_AMDTP_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16) 212#define IEEE1394_AMDTP_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_AMDTP * 16)
213#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16) 213#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)
214 214
215/* return the index (within a minor number block) of a file */ 215/* return the index (within a minor number block) of a file */
216static inline unsigned char ieee1394_file_to_instance(struct file *file) 216static inline unsigned char ieee1394_file_to_instance(struct file *file)
diff --git a/drivers/ieee1394/ieee1394_transactions.c b/drivers/ieee1394/ieee1394_transactions.c
index 0aa876360f9b..3fe2f6c4a253 100644
--- a/drivers/ieee1394/ieee1394_transactions.c
+++ b/drivers/ieee1394/ieee1394_transactions.c
@@ -22,7 +22,7 @@
22#include "ieee1394_core.h" 22#include "ieee1394_core.h"
23#include "highlevel.h" 23#include "highlevel.h"
24#include "nodemgr.h" 24#include "nodemgr.h"
25 25#include "ieee1394_transactions.h"
26 26
27#define PREP_ASYNC_HEAD_ADDRESS(tc) \ 27#define PREP_ASYNC_HEAD_ADDRESS(tc) \
28 packet->tcode = tc; \ 28 packet->tcode = tc; \
@@ -31,80 +31,82 @@
31 packet->header[1] = (packet->host->node_id << 16) | (addr >> 32); \ 31 packet->header[1] = (packet->host->node_id << 16) | (addr >> 32); \
32 packet->header[2] = addr & 0xffffffff 32 packet->header[2] = addr & 0xffffffff
33 33
34
35static void fill_async_readquad(struct hpsb_packet *packet, u64 addr) 34static void fill_async_readquad(struct hpsb_packet *packet, u64 addr)
36{ 35{
37 PREP_ASYNC_HEAD_ADDRESS(TCODE_READQ); 36 PREP_ASYNC_HEAD_ADDRESS(TCODE_READQ);
38 packet->header_size = 12; 37 packet->header_size = 12;
39 packet->data_size = 0; 38 packet->data_size = 0;
40 packet->expect_response = 1; 39 packet->expect_response = 1;
41} 40}
42 41
43static void fill_async_readblock(struct hpsb_packet *packet, u64 addr, int length) 42static void fill_async_readblock(struct hpsb_packet *packet, u64 addr,
43 int length)
44{ 44{
45 PREP_ASYNC_HEAD_ADDRESS(TCODE_READB); 45 PREP_ASYNC_HEAD_ADDRESS(TCODE_READB);
46 packet->header[3] = length << 16; 46 packet->header[3] = length << 16;
47 packet->header_size = 16; 47 packet->header_size = 16;
48 packet->data_size = 0; 48 packet->data_size = 0;
49 packet->expect_response = 1; 49 packet->expect_response = 1;
50} 50}
51 51
52static void fill_async_writequad(struct hpsb_packet *packet, u64 addr, quadlet_t data) 52static void fill_async_writequad(struct hpsb_packet *packet, u64 addr,
53 quadlet_t data)
53{ 54{
54 PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEQ); 55 PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEQ);
55 packet->header[3] = data; 56 packet->header[3] = data;
56 packet->header_size = 16; 57 packet->header_size = 16;
57 packet->data_size = 0; 58 packet->data_size = 0;
58 packet->expect_response = 1; 59 packet->expect_response = 1;
59} 60}
60 61
61static void fill_async_writeblock(struct hpsb_packet *packet, u64 addr, int length) 62static void fill_async_writeblock(struct hpsb_packet *packet, u64 addr,
63 int length)
62{ 64{
63 PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEB); 65 PREP_ASYNC_HEAD_ADDRESS(TCODE_WRITEB);
64 packet->header[3] = length << 16; 66 packet->header[3] = length << 16;
65 packet->header_size = 16; 67 packet->header_size = 16;
66 packet->expect_response = 1; 68 packet->expect_response = 1;
67 packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0); 69 packet->data_size = length + (length % 4 ? 4 - (length % 4) : 0);
68} 70}
69 71
70static void fill_async_lock(struct hpsb_packet *packet, u64 addr, int extcode, 72static void fill_async_lock(struct hpsb_packet *packet, u64 addr, int extcode,
71 int length) 73 int length)
72{ 74{
73 PREP_ASYNC_HEAD_ADDRESS(TCODE_LOCK_REQUEST); 75 PREP_ASYNC_HEAD_ADDRESS(TCODE_LOCK_REQUEST);
74 packet->header[3] = (length << 16) | extcode; 76 packet->header[3] = (length << 16) | extcode;
75 packet->header_size = 16; 77 packet->header_size = 16;
76 packet->data_size = length; 78 packet->data_size = length;
77 packet->expect_response = 1; 79 packet->expect_response = 1;
78} 80}
79 81
80static void fill_iso_packet(struct hpsb_packet *packet, int length, int channel, 82static void fill_iso_packet(struct hpsb_packet *packet, int length, int channel,
81 int tag, int sync) 83 int tag, int sync)
82{ 84{
83 packet->header[0] = (length << 16) | (tag << 14) | (channel << 8) 85 packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
84 | (TCODE_ISO_DATA << 4) | sync; 86 | (TCODE_ISO_DATA << 4) | sync;
85 87
86 packet->header_size = 4; 88 packet->header_size = 4;
87 packet->data_size = length; 89 packet->data_size = length;
88 packet->type = hpsb_iso; 90 packet->type = hpsb_iso;
89 packet->tcode = TCODE_ISO_DATA; 91 packet->tcode = TCODE_ISO_DATA;
90} 92}
91 93
92static void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data) 94static void fill_phy_packet(struct hpsb_packet *packet, quadlet_t data)
93{ 95{
94 packet->header[0] = data; 96 packet->header[0] = data;
95 packet->header[1] = ~data; 97 packet->header[1] = ~data;
96 packet->header_size = 8; 98 packet->header_size = 8;
97 packet->data_size = 0; 99 packet->data_size = 0;
98 packet->expect_response = 0; 100 packet->expect_response = 0;
99 packet->type = hpsb_raw; /* No CRC added */ 101 packet->type = hpsb_raw; /* No CRC added */
100 packet->speed_code = IEEE1394_SPEED_100; /* Force speed to be 100Mbps */ 102 packet->speed_code = IEEE1394_SPEED_100; /* Force speed to be 100Mbps */
101} 103}
102 104
103static void fill_async_stream_packet(struct hpsb_packet *packet, int length, 105static void fill_async_stream_packet(struct hpsb_packet *packet, int length,
104 int channel, int tag, int sync) 106 int channel, int tag, int sync)
105{ 107{
106 packet->header[0] = (length << 16) | (tag << 14) | (channel << 8) 108 packet->header[0] = (length << 16) | (tag << 14) | (channel << 8)
107 | (TCODE_STREAM_DATA << 4) | sync; 109 | (TCODE_STREAM_DATA << 4) | sync;
108 110
109 packet->header_size = 4; 111 packet->header_size = 4;
110 packet->data_size = length; 112 packet->data_size = length;
@@ -171,99 +173,96 @@ int hpsb_get_tlabel(struct hpsb_packet *packet)
171 */ 173 */
172void hpsb_free_tlabel(struct hpsb_packet *packet) 174void hpsb_free_tlabel(struct hpsb_packet *packet)
173{ 175{
174 unsigned long flags; 176 unsigned long flags;
175 struct hpsb_tlabel_pool *tp; 177 struct hpsb_tlabel_pool *tp;
176 178
177 tp = &packet->host->tpool[packet->node_id & NODE_MASK]; 179 tp = &packet->host->tpool[packet->node_id & NODE_MASK];
178 180
179 BUG_ON(packet->tlabel > 63 || packet->tlabel < 0); 181 BUG_ON(packet->tlabel > 63 || packet->tlabel < 0);
180 182
181 spin_lock_irqsave(&tp->lock, flags); 183 spin_lock_irqsave(&tp->lock, flags);
182 BUG_ON(!test_and_clear_bit(packet->tlabel, tp->pool)); 184 BUG_ON(!test_and_clear_bit(packet->tlabel, tp->pool));
183 spin_unlock_irqrestore(&tp->lock, flags); 185 spin_unlock_irqrestore(&tp->lock, flags);
184 186
185 up(&tp->count); 187 up(&tp->count);
186} 188}
187 189
188
189
190int hpsb_packet_success(struct hpsb_packet *packet) 190int hpsb_packet_success(struct hpsb_packet *packet)
191{ 191{
192 switch (packet->ack_code) { 192 switch (packet->ack_code) {
193 case ACK_PENDING: 193 case ACK_PENDING:
194 switch ((packet->header[1] >> 12) & 0xf) { 194 switch ((packet->header[1] >> 12) & 0xf) {
195 case RCODE_COMPLETE: 195 case RCODE_COMPLETE:
196 return 0; 196 return 0;
197 case RCODE_CONFLICT_ERROR: 197 case RCODE_CONFLICT_ERROR:
198 return -EAGAIN; 198 return -EAGAIN;
199 case RCODE_DATA_ERROR: 199 case RCODE_DATA_ERROR:
200 return -EREMOTEIO; 200 return -EREMOTEIO;
201 case RCODE_TYPE_ERROR: 201 case RCODE_TYPE_ERROR:
202 return -EACCES; 202 return -EACCES;
203 case RCODE_ADDRESS_ERROR: 203 case RCODE_ADDRESS_ERROR:
204 return -EINVAL; 204 return -EINVAL;
205 default: 205 default:
206 HPSB_ERR("received reserved rcode %d from node %d", 206 HPSB_ERR("received reserved rcode %d from node %d",
207 (packet->header[1] >> 12) & 0xf, 207 (packet->header[1] >> 12) & 0xf,
208 packet->node_id); 208 packet->node_id);
209 return -EAGAIN; 209 return -EAGAIN;
210 } 210 }
211 HPSB_PANIC("reached unreachable code 1 in %s", __FUNCTION__); 211 HPSB_PANIC("reached unreachable code 1 in %s", __FUNCTION__);
212 212
213 case ACK_BUSY_X: 213 case ACK_BUSY_X:
214 case ACK_BUSY_A: 214 case ACK_BUSY_A:
215 case ACK_BUSY_B: 215 case ACK_BUSY_B:
216 return -EBUSY; 216 return -EBUSY;
217 217
218 case ACK_TYPE_ERROR: 218 case ACK_TYPE_ERROR:
219 return -EACCES; 219 return -EACCES;
220 220
221 case ACK_COMPLETE: 221 case ACK_COMPLETE:
222 if (packet->tcode == TCODE_WRITEQ 222 if (packet->tcode == TCODE_WRITEQ
223 || packet->tcode == TCODE_WRITEB) { 223 || packet->tcode == TCODE_WRITEB) {
224 return 0; 224 return 0;
225 } else { 225 } else {
226 HPSB_ERR("impossible ack_complete from node %d " 226 HPSB_ERR("impossible ack_complete from node %d "
227 "(tcode %d)", packet->node_id, packet->tcode); 227 "(tcode %d)", packet->node_id, packet->tcode);
228 return -EAGAIN; 228 return -EAGAIN;
229 } 229 }
230 230
231 231 case ACK_DATA_ERROR:
232 case ACK_DATA_ERROR: 232 if (packet->tcode == TCODE_WRITEB
233 if (packet->tcode == TCODE_WRITEB 233 || packet->tcode == TCODE_LOCK_REQUEST) {
234 || packet->tcode == TCODE_LOCK_REQUEST) { 234 return -EAGAIN;
235 return -EAGAIN; 235 } else {
236 } else { 236 HPSB_ERR("impossible ack_data_error from node %d "
237 HPSB_ERR("impossible ack_data_error from node %d " 237 "(tcode %d)", packet->node_id, packet->tcode);
238 "(tcode %d)", packet->node_id, packet->tcode); 238 return -EAGAIN;
239 return -EAGAIN; 239 }
240 } 240
241 241 case ACK_ADDRESS_ERROR:
242 case ACK_ADDRESS_ERROR: 242 return -EINVAL;
243 return -EINVAL; 243
244 244 case ACK_TARDY:
245 case ACK_TARDY: 245 case ACK_CONFLICT_ERROR:
246 case ACK_CONFLICT_ERROR: 246 case ACKX_NONE:
247 case ACKX_NONE: 247 case ACKX_SEND_ERROR:
248 case ACKX_SEND_ERROR: 248 case ACKX_ABORTED:
249 case ACKX_ABORTED: 249 case ACKX_TIMEOUT:
250 case ACKX_TIMEOUT: 250 /* error while sending */
251 /* error while sending */ 251 return -EAGAIN;
252 return -EAGAIN; 252
253 253 default:
254 default: 254 HPSB_ERR("got invalid ack %d from node %d (tcode %d)",
255 HPSB_ERR("got invalid ack %d from node %d (tcode %d)", 255 packet->ack_code, packet->node_id, packet->tcode);
256 packet->ack_code, packet->node_id, packet->tcode); 256 return -EAGAIN;
257 return -EAGAIN; 257 }
258 } 258
259 259 HPSB_PANIC("reached unreachable code 2 in %s", __FUNCTION__);
260 HPSB_PANIC("reached unreachable code 2 in %s", __FUNCTION__);
261} 260}
262 261
263struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node, 262struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
264 u64 addr, size_t length) 263 u64 addr, size_t length)
265{ 264{
266 struct hpsb_packet *packet; 265 struct hpsb_packet *packet;
267 266
268 if (length == 0) 267 if (length == 0)
269 return NULL; 268 return NULL;
@@ -288,8 +287,9 @@ struct hpsb_packet *hpsb_make_readpacket(struct hpsb_host *host, nodeid_t node,
288 return packet; 287 return packet;
289} 288}
290 289
291struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node, 290struct hpsb_packet *hpsb_make_writepacket(struct hpsb_host *host, nodeid_t node,
292 u64 addr, quadlet_t *buffer, size_t length) 291 u64 addr, quadlet_t * buffer,
292 size_t length)
293{ 293{
294 struct hpsb_packet *packet; 294 struct hpsb_packet *packet;
295 295
@@ -300,7 +300,7 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node
300 if (!packet) 300 if (!packet)
301 return NULL; 301 return NULL;
302 302
303 if (length % 4) { /* zero padding bytes */ 303 if (length % 4) { /* zero padding bytes */
304 packet->data[length >> 2] = 0; 304 packet->data[length >> 2] = 0;
305 } 305 }
306 packet->host = host; 306 packet->host = host;
@@ -322,8 +322,9 @@ struct hpsb_packet *hpsb_make_writepacket (struct hpsb_host *host, nodeid_t node
322 return packet; 322 return packet;
323} 323}
324 324
325struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, int length, 325struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 * buffer,
326 int channel, int tag, int sync) 326 int length, int channel, int tag,
327 int sync)
327{ 328{
328 struct hpsb_packet *packet; 329 struct hpsb_packet *packet;
329 330
@@ -334,7 +335,7 @@ struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, i
334 if (!packet) 335 if (!packet)
335 return NULL; 336 return NULL;
336 337
337 if (length % 4) { /* zero padding bytes */ 338 if (length % 4) { /* zero padding bytes */
338 packet->data[length >> 2] = 0; 339 packet->data[length >> 2] = 0;
339 } 340 }
340 packet->host = host; 341 packet->host = host;
@@ -352,14 +353,15 @@ struct hpsb_packet *hpsb_make_streampacket(struct hpsb_host *host, u8 *buffer, i
352} 353}
353 354
354struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node, 355struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
355 u64 addr, int extcode, quadlet_t *data, 356 u64 addr, int extcode,
356 quadlet_t arg) 357 quadlet_t * data, quadlet_t arg)
357{ 358{
358 struct hpsb_packet *p; 359 struct hpsb_packet *p;
359 u32 length; 360 u32 length;
360 361
361 p = hpsb_alloc_packet(8); 362 p = hpsb_alloc_packet(8);
362 if (!p) return NULL; 363 if (!p)
364 return NULL;
363 365
364 p->host = host; 366 p->host = host;
365 p->node_id = node; 367 p->node_id = node;
@@ -388,15 +390,16 @@ struct hpsb_packet *hpsb_make_lockpacket(struct hpsb_host *host, nodeid_t node,
388 return p; 390 return p;
389} 391}
390 392
391struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node, 393struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host,
392 u64 addr, int extcode, octlet_t *data, 394 nodeid_t node, u64 addr, int extcode,
393 octlet_t arg) 395 octlet_t * data, octlet_t arg)
394{ 396{
395 struct hpsb_packet *p; 397 struct hpsb_packet *p;
396 u32 length; 398 u32 length;
397 399
398 p = hpsb_alloc_packet(16); 400 p = hpsb_alloc_packet(16);
399 if (!p) return NULL; 401 if (!p)
402 return NULL;
400 403
401 p->host = host; 404 p->host = host;
402 p->node_id = node; 405 p->node_id = node;
@@ -429,18 +432,18 @@ struct hpsb_packet *hpsb_make_lock64packet(struct hpsb_host *host, nodeid_t node
429 return p; 432 return p;
430} 433}
431 434
432struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host, 435struct hpsb_packet *hpsb_make_phypacket(struct hpsb_host *host, quadlet_t data)
433 quadlet_t data)
434{ 436{
435 struct hpsb_packet *p; 437 struct hpsb_packet *p;
436 438
437 p = hpsb_alloc_packet(0); 439 p = hpsb_alloc_packet(0);
438 if (!p) return NULL; 440 if (!p)
441 return NULL;
439 442
440 p->host = host; 443 p->host = host;
441 fill_phy_packet(p, data); 444 fill_phy_packet(p, data);
442 445
443 return p; 446 return p;
444} 447}
445 448
446struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host, 449struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host,
@@ -450,7 +453,8 @@ struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host,
450 struct hpsb_packet *p; 453 struct hpsb_packet *p;
451 454
452 p = hpsb_alloc_packet(length); 455 p = hpsb_alloc_packet(length);
453 if (!p) return NULL; 456 if (!p)
457 return NULL;
454 458
455 p->host = host; 459 p->host = host;
456 fill_iso_packet(p, length, channel, tag, sync); 460 fill_iso_packet(p, length, channel, tag, sync);
@@ -466,47 +470,46 @@ struct hpsb_packet *hpsb_make_isopacket(struct hpsb_host *host,
466 */ 470 */
467 471
468int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation, 472int hpsb_read(struct hpsb_host *host, nodeid_t node, unsigned int generation,
469 u64 addr, quadlet_t *buffer, size_t length) 473 u64 addr, quadlet_t * buffer, size_t length)
470{ 474{
471 struct hpsb_packet *packet; 475 struct hpsb_packet *packet;
472 int retval = 0; 476 int retval = 0;
473 477
474 if (length == 0) 478 if (length == 0)
475 return -EINVAL; 479 return -EINVAL;
476 480
477 BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet 481 BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
478 482
479 packet = hpsb_make_readpacket(host, node, addr, length); 483 packet = hpsb_make_readpacket(host, node, addr, length);
480 484
481 if (!packet) { 485 if (!packet) {
482 return -ENOMEM; 486 return -ENOMEM;
483 } 487 }
484 488
485 packet->generation = generation; 489 packet->generation = generation;
486 retval = hpsb_send_packet_and_wait(packet); 490 retval = hpsb_send_packet_and_wait(packet);
487 if (retval < 0) 491 if (retval < 0)
488 goto hpsb_read_fail; 492 goto hpsb_read_fail;
489 493
490 retval = hpsb_packet_success(packet); 494 retval = hpsb_packet_success(packet);
491 495
492 if (retval == 0) { 496 if (retval == 0) {
493 if (length == 4) { 497 if (length == 4) {
494 *buffer = packet->header[3]; 498 *buffer = packet->header[3];
495 } else { 499 } else {
496 memcpy(buffer, packet->data, length); 500 memcpy(buffer, packet->data, length);
497 } 501 }
498 } 502 }
499 503
500hpsb_read_fail: 504 hpsb_read_fail:
501 hpsb_free_tlabel(packet); 505 hpsb_free_tlabel(packet);
502 hpsb_free_packet(packet); 506 hpsb_free_packet(packet);
503 507
504 return retval; 508 return retval;
505} 509}
506 510
507
508int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation, 511int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
509 u64 addr, quadlet_t *buffer, size_t length) 512 u64 addr, quadlet_t * buffer, size_t length)
510{ 513{
511 struct hpsb_packet *packet; 514 struct hpsb_packet *packet;
512 int retval; 515 int retval;
@@ -514,62 +517,61 @@ int hpsb_write(struct hpsb_host *host, nodeid_t node, unsigned int generation,
514 if (length == 0) 517 if (length == 0)
515 return -EINVAL; 518 return -EINVAL;
516 519
517 BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet 520 BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
518 521
519 packet = hpsb_make_writepacket (host, node, addr, buffer, length); 522 packet = hpsb_make_writepacket(host, node, addr, buffer, length);
520 523
521 if (!packet) 524 if (!packet)
522 return -ENOMEM; 525 return -ENOMEM;
523 526
524 packet->generation = generation; 527 packet->generation = generation;
525 retval = hpsb_send_packet_and_wait(packet); 528 retval = hpsb_send_packet_and_wait(packet);
526 if (retval < 0) 529 if (retval < 0)
527 goto hpsb_write_fail; 530 goto hpsb_write_fail;
528 531
529 retval = hpsb_packet_success(packet); 532 retval = hpsb_packet_success(packet);
530 533
531hpsb_write_fail: 534 hpsb_write_fail:
532 hpsb_free_tlabel(packet); 535 hpsb_free_tlabel(packet);
533 hpsb_free_packet(packet); 536 hpsb_free_packet(packet);
534 537
535 return retval; 538 return retval;
536} 539}
537 540
538#if 0 541#if 0
539 542
540int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation, 543int hpsb_lock(struct hpsb_host *host, nodeid_t node, unsigned int generation,
541 u64 addr, int extcode, quadlet_t *data, quadlet_t arg) 544 u64 addr, int extcode, quadlet_t * data, quadlet_t arg)
542{ 545{
543 struct hpsb_packet *packet; 546 struct hpsb_packet *packet;
544 int retval = 0; 547 int retval = 0;
545 548
546 BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet 549 BUG_ON(in_interrupt()); // We can't be called in an interrupt, yet
547 550
548 packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg); 551 packet = hpsb_make_lockpacket(host, node, addr, extcode, data, arg);
549 if (!packet) 552 if (!packet)
550 return -ENOMEM; 553 return -ENOMEM;
551 554
552 packet->generation = generation; 555 packet->generation = generation;
553 retval = hpsb_send_packet_and_wait(packet); 556 retval = hpsb_send_packet_and_wait(packet);
554 if (retval < 0) 557 if (retval < 0)
555 goto hpsb_lock_fail; 558 goto hpsb_lock_fail;
556 559
557 retval = hpsb_packet_success(packet); 560 retval = hpsb_packet_success(packet);
558 561
559 if (retval == 0) { 562 if (retval == 0) {
560 *data = packet->data[0]; 563 *data = packet->data[0];
561 } 564 }
562 565
563hpsb_lock_fail: 566 hpsb_lock_fail:
564 hpsb_free_tlabel(packet); 567 hpsb_free_tlabel(packet);
565 hpsb_free_packet(packet); 568 hpsb_free_packet(packet);
566 569
567 return retval; 570 return retval;
568} 571}
569 572
570
571int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation, 573int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
572 quadlet_t *buffer, size_t length, u32 specifier_id, 574 quadlet_t * buffer, size_t length, u32 specifier_id,
573 unsigned int version) 575 unsigned int version)
574{ 576{
575 struct hpsb_packet *packet; 577 struct hpsb_packet *packet;
@@ -586,7 +588,8 @@ int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
586 return -ENOMEM; 588 return -ENOMEM;
587 589
588 packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi); 590 packet->data[0] = cpu_to_be32((host->node_id << 16) | specifier_id_hi);
589 packet->data[1] = cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff)); 591 packet->data[1] =
592 cpu_to_be32((specifier_id_lo << 24) | (version & 0x00ffffff));
590 593
591 memcpy(&(packet->data[2]), buffer, length - 8); 594 memcpy(&(packet->data[2]), buffer, length - 8);
592 595
@@ -601,4 +604,4 @@ int hpsb_send_gasp(struct hpsb_host *host, int channel, unsigned int generation,
601 return retval; 604 return retval;
602} 605}
603 606
604#endif /* 0 */ 607#endif /* 0 */
diff --git a/drivers/ieee1394/iso.c b/drivers/ieee1394/iso.c
index 615541b8b90f..f26680ebef7c 100644
--- a/drivers/ieee1394/iso.c
+++ b/drivers/ieee1394/iso.c
@@ -36,20 +36,22 @@ void hpsb_iso_shutdown(struct hpsb_iso *iso)
36 kfree(iso); 36 kfree(iso);
37} 37}
38 38
39static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_iso_type type, 39static struct hpsb_iso *hpsb_iso_common_init(struct hpsb_host *host,
40 enum hpsb_iso_type type,
40 unsigned int data_buf_size, 41 unsigned int data_buf_size,
41 unsigned int buf_packets, 42 unsigned int buf_packets,
42 int channel, 43 int channel, int dma_mode,
43 int dma_mode,
44 int irq_interval, 44 int irq_interval,
45 void (*callback)(struct hpsb_iso*)) 45 void (*callback) (struct hpsb_iso
46 *))
46{ 47{
47 struct hpsb_iso *iso; 48 struct hpsb_iso *iso;
48 int dma_direction; 49 int dma_direction;
49 50
50 /* make sure driver supports the ISO API */ 51 /* make sure driver supports the ISO API */
51 if (!host->driver->isoctl) { 52 if (!host->driver->isoctl) {
52 printk(KERN_INFO "ieee1394: host driver '%s' does not support the rawiso API\n", 53 printk(KERN_INFO
54 "ieee1394: host driver '%s' does not support the rawiso API\n",
53 host->driver->name); 55 host->driver->name);
54 return NULL; 56 return NULL;
55 } 57 }
@@ -59,12 +61,13 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
59 if (buf_packets < 2) 61 if (buf_packets < 2)
60 buf_packets = 2; 62 buf_packets = 2;
61 63
62 if ((dma_mode < HPSB_ISO_DMA_DEFAULT) || (dma_mode > HPSB_ISO_DMA_PACKET_PER_BUFFER)) 64 if ((dma_mode < HPSB_ISO_DMA_DEFAULT)
63 dma_mode=HPSB_ISO_DMA_DEFAULT; 65 || (dma_mode > HPSB_ISO_DMA_PACKET_PER_BUFFER))
66 dma_mode = HPSB_ISO_DMA_DEFAULT;
64 67
65 if ((irq_interval < 0) || (irq_interval > buf_packets / 4)) 68 if ((irq_interval < 0) || (irq_interval > buf_packets / 4))
66 irq_interval = buf_packets / 4; 69 irq_interval = buf_packets / 4;
67 if (irq_interval == 0) /* really interrupt for each packet*/ 70 if (irq_interval == 0) /* really interrupt for each packet */
68 irq_interval = 1; 71 irq_interval = 1;
69 72
70 if (channel < -1 || channel >= 64) 73 if (channel < -1 || channel >= 64)
@@ -76,7 +79,10 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
76 79
77 /* allocate and write the struct hpsb_iso */ 80 /* allocate and write the struct hpsb_iso */
78 81
79 iso = kmalloc(sizeof(*iso) + buf_packets * sizeof(struct hpsb_iso_packet_info), GFP_KERNEL); 82 iso =
83 kmalloc(sizeof(*iso) +
84 buf_packets * sizeof(struct hpsb_iso_packet_info),
85 GFP_KERNEL);
80 if (!iso) 86 if (!iso)
81 return NULL; 87 return NULL;
82 88
@@ -111,17 +117,18 @@ static struct hpsb_iso* hpsb_iso_common_init(struct hpsb_host *host, enum hpsb_i
111 iso->prebuffer = 0; 117 iso->prebuffer = 0;
112 118
113 /* allocate the packet buffer */ 119 /* allocate the packet buffer */
114 if (dma_region_alloc(&iso->data_buf, iso->buf_size, host->pdev, dma_direction)) 120 if (dma_region_alloc
121 (&iso->data_buf, iso->buf_size, host->pdev, dma_direction))
115 goto err; 122 goto err;
116 123
117 return iso; 124 return iso;
118 125
119err: 126 err:
120 hpsb_iso_shutdown(iso); 127 hpsb_iso_shutdown(iso);
121 return NULL; 128 return NULL;
122} 129}
123 130
124int hpsb_iso_n_ready(struct hpsb_iso* iso) 131int hpsb_iso_n_ready(struct hpsb_iso *iso)
125{ 132{
126 unsigned long flags; 133 unsigned long flags;
127 int val; 134 int val;
@@ -133,18 +140,19 @@ int hpsb_iso_n_ready(struct hpsb_iso* iso)
133 return val; 140 return val;
134} 141}
135 142
136 143struct hpsb_iso *hpsb_iso_xmit_init(struct hpsb_host *host,
137struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host,
138 unsigned int data_buf_size, 144 unsigned int data_buf_size,
139 unsigned int buf_packets, 145 unsigned int buf_packets,
140 int channel, 146 int channel,
141 int speed, 147 int speed,
142 int irq_interval, 148 int irq_interval,
143 void (*callback)(struct hpsb_iso*)) 149 void (*callback) (struct hpsb_iso *))
144{ 150{
145 struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_XMIT, 151 struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_XMIT,
146 data_buf_size, buf_packets, 152 data_buf_size, buf_packets,
147 channel, HPSB_ISO_DMA_DEFAULT, irq_interval, callback); 153 channel,
154 HPSB_ISO_DMA_DEFAULT,
155 irq_interval, callback);
148 if (!iso) 156 if (!iso)
149 return NULL; 157 return NULL;
150 158
@@ -157,22 +165,23 @@ struct hpsb_iso* hpsb_iso_xmit_init(struct hpsb_host *host,
157 iso->flags |= HPSB_ISO_DRIVER_INIT; 165 iso->flags |= HPSB_ISO_DRIVER_INIT;
158 return iso; 166 return iso;
159 167
160err: 168 err:
161 hpsb_iso_shutdown(iso); 169 hpsb_iso_shutdown(iso);
162 return NULL; 170 return NULL;
163} 171}
164 172
165struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host, 173struct hpsb_iso *hpsb_iso_recv_init(struct hpsb_host *host,
166 unsigned int data_buf_size, 174 unsigned int data_buf_size,
167 unsigned int buf_packets, 175 unsigned int buf_packets,
168 int channel, 176 int channel,
169 int dma_mode, 177 int dma_mode,
170 int irq_interval, 178 int irq_interval,
171 void (*callback)(struct hpsb_iso*)) 179 void (*callback) (struct hpsb_iso *))
172{ 180{
173 struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_RECV, 181 struct hpsb_iso *iso = hpsb_iso_common_init(host, HPSB_ISO_RECV,
174 data_buf_size, buf_packets, 182 data_buf_size, buf_packets,
175 channel, dma_mode, irq_interval, callback); 183 channel, dma_mode,
184 irq_interval, callback);
176 if (!iso) 185 if (!iso)
177 return NULL; 186 return NULL;
178 187
@@ -183,7 +192,7 @@ struct hpsb_iso* hpsb_iso_recv_init(struct hpsb_host *host,
183 iso->flags |= HPSB_ISO_DRIVER_INIT; 192 iso->flags |= HPSB_ISO_DRIVER_INIT;
184 return iso; 193 return iso;
185 194
186err: 195 err:
187 hpsb_iso_shutdown(iso); 196 hpsb_iso_shutdown(iso);
188 return NULL; 197 return NULL;
189} 198}
@@ -197,16 +206,17 @@ int hpsb_iso_recv_listen_channel(struct hpsb_iso *iso, unsigned char channel)
197 206
198int hpsb_iso_recv_unlisten_channel(struct hpsb_iso *iso, unsigned char channel) 207int hpsb_iso_recv_unlisten_channel(struct hpsb_iso *iso, unsigned char channel)
199{ 208{
200 if (iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64) 209 if (iso->type != HPSB_ISO_RECV || iso->channel != -1 || channel >= 64)
201 return -EINVAL; 210 return -EINVAL;
202 return iso->host->driver->isoctl(iso, RECV_UNLISTEN_CHANNEL, channel); 211 return iso->host->driver->isoctl(iso, RECV_UNLISTEN_CHANNEL, channel);
203} 212}
204 213
205int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask) 214int hpsb_iso_recv_set_channel_mask(struct hpsb_iso *iso, u64 mask)
206{ 215{
207 if (iso->type != HPSB_ISO_RECV || iso->channel != -1) 216 if (iso->type != HPSB_ISO_RECV || iso->channel != -1)
208 return -EINVAL; 217 return -EINVAL;
209 return iso->host->driver->isoctl(iso, RECV_SET_CHANNEL_MASK, (unsigned long) &mask); 218 return iso->host->driver->isoctl(iso, RECV_SET_CHANNEL_MASK,
219 (unsigned long)&mask);
210} 220}
211 221
212int hpsb_iso_recv_flush(struct hpsb_iso *iso) 222int hpsb_iso_recv_flush(struct hpsb_iso *iso)
@@ -283,7 +293,9 @@ int hpsb_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, int sync)
283 293
284 isoctl_args[2] = sync; 294 isoctl_args[2] = sync;
285 295
286 retval = iso->host->driver->isoctl(iso, RECV_START, (unsigned long) &isoctl_args[0]); 296 retval =
297 iso->host->driver->isoctl(iso, RECV_START,
298 (unsigned long)&isoctl_args[0]);
287 if (retval) 299 if (retval)
288 return retval; 300 return retval;
289 301
@@ -296,7 +308,8 @@ int hpsb_iso_recv_start(struct hpsb_iso *iso, int cycle, int tag_mask, int sync)
296 308
297static int hpsb_iso_check_offset_len(struct hpsb_iso *iso, 309static int hpsb_iso_check_offset_len(struct hpsb_iso *iso,
298 unsigned int offset, unsigned short len, 310 unsigned int offset, unsigned short len,
299 unsigned int *out_offset, unsigned short *out_len) 311 unsigned int *out_offset,
312 unsigned short *out_len)
300{ 313{
301 if (offset >= iso->buf_size) 314 if (offset >= iso->buf_size)
302 return -EFAULT; 315 return -EFAULT;
@@ -316,8 +329,8 @@ static int hpsb_iso_check_offset_len(struct hpsb_iso *iso,
316 return 0; 329 return 0;
317} 330}
318 331
319 332int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len,
320int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag, u8 sy) 333 u8 tag, u8 sy)
321{ 334{
322 struct hpsb_iso_packet_info *info; 335 struct hpsb_iso_packet_info *info;
323 unsigned long flags; 336 unsigned long flags;
@@ -334,7 +347,8 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag
334 info = &iso->infos[iso->first_packet]; 347 info = &iso->infos[iso->first_packet];
335 348
336 /* check for bogus offset/length */ 349 /* check for bogus offset/length */
337 if (hpsb_iso_check_offset_len(iso, offset, len, &info->offset, &info->len)) 350 if (hpsb_iso_check_offset_len
351 (iso, offset, len, &info->offset, &info->len))
338 return -EFAULT; 352 return -EFAULT;
339 353
340 info->tag = tag; 354 info->tag = tag;
@@ -342,13 +356,13 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag
342 356
343 spin_lock_irqsave(&iso->lock, flags); 357 spin_lock_irqsave(&iso->lock, flags);
344 358
345 rv = iso->host->driver->isoctl(iso, XMIT_QUEUE, (unsigned long) info); 359 rv = iso->host->driver->isoctl(iso, XMIT_QUEUE, (unsigned long)info);
346 if (rv) 360 if (rv)
347 goto out; 361 goto out;
348 362
349 /* increment cursors */ 363 /* increment cursors */
350 iso->first_packet = (iso->first_packet+1) % iso->buf_packets; 364 iso->first_packet = (iso->first_packet + 1) % iso->buf_packets;
351 iso->xmit_cycle = (iso->xmit_cycle+1) % 8000; 365 iso->xmit_cycle = (iso->xmit_cycle + 1) % 8000;
352 iso->n_ready_packets--; 366 iso->n_ready_packets--;
353 367
354 if (iso->prebuffer != 0) { 368 if (iso->prebuffer != 0) {
@@ -359,7 +373,7 @@ int hpsb_iso_xmit_queue_packet(struct hpsb_iso *iso, u32 offset, u16 len, u8 tag
359 } 373 }
360 } 374 }
361 375
362out: 376 out:
363 spin_unlock_irqrestore(&iso->lock, flags); 377 spin_unlock_irqrestore(&iso->lock, flags);
364 return rv; 378 return rv;
365} 379}
@@ -369,7 +383,9 @@ int hpsb_iso_xmit_sync(struct hpsb_iso *iso)
369 if (iso->type != HPSB_ISO_XMIT) 383 if (iso->type != HPSB_ISO_XMIT)
370 return -EINVAL; 384 return -EINVAL;
371 385
372 return wait_event_interruptible(iso->waitq, hpsb_iso_n_ready(iso) == iso->buf_packets); 386 return wait_event_interruptible(iso->waitq,
387 hpsb_iso_n_ready(iso) ==
388 iso->buf_packets);
373} 389}
374 390
375void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error) 391void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error)
@@ -396,7 +412,8 @@ void hpsb_iso_packet_sent(struct hpsb_iso *iso, int cycle, int error)
396} 412}
397 413
398void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len, 414void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
399 u16 total_len, u16 cycle, u8 channel, u8 tag, u8 sy) 415 u16 total_len, u16 cycle, u8 channel, u8 tag,
416 u8 sy)
400{ 417{
401 unsigned long flags; 418 unsigned long flags;
402 spin_lock_irqsave(&iso->lock, flags); 419 spin_lock_irqsave(&iso->lock, flags);
@@ -416,7 +433,7 @@ void hpsb_iso_packet_received(struct hpsb_iso *iso, u32 offset, u16 len,
416 info->tag = tag; 433 info->tag = tag;
417 info->sy = sy; 434 info->sy = sy;
418 435
419 iso->pkt_dma = (iso->pkt_dma+1) % iso->buf_packets; 436 iso->pkt_dma = (iso->pkt_dma + 1) % iso->buf_packets;
420 iso->n_ready_packets++; 437 iso->n_ready_packets++;
421 } 438 }
422 439
@@ -435,20 +452,21 @@ int hpsb_iso_recv_release_packets(struct hpsb_iso *iso, unsigned int n_packets)
435 spin_lock_irqsave(&iso->lock, flags); 452 spin_lock_irqsave(&iso->lock, flags);
436 for (i = 0; i < n_packets; i++) { 453 for (i = 0; i < n_packets; i++) {
437 rv = iso->host->driver->isoctl(iso, RECV_RELEASE, 454 rv = iso->host->driver->isoctl(iso, RECV_RELEASE,
438 (unsigned long) &iso->infos[iso->first_packet]); 455 (unsigned long)&iso->infos[iso->
456 first_packet]);
439 if (rv) 457 if (rv)
440 break; 458 break;
441 459
442 iso->first_packet = (iso->first_packet+1) % iso->buf_packets; 460 iso->first_packet = (iso->first_packet + 1) % iso->buf_packets;
443 iso->n_ready_packets--; 461 iso->n_ready_packets--;
444 462
445 /* release memory from packets discarded when queue was full */ 463 /* release memory from packets discarded when queue was full */
446 if (iso->n_ready_packets == 0) { /* Release only after all prior packets handled */ 464 if (iso->n_ready_packets == 0) { /* Release only after all prior packets handled */
447 if (iso->bytes_discarded != 0) { 465 if (iso->bytes_discarded != 0) {
448 struct hpsb_iso_packet_info inf; 466 struct hpsb_iso_packet_info inf;
449 inf.total_len = iso->bytes_discarded; 467 inf.total_len = iso->bytes_discarded;
450 iso->host->driver->isoctl(iso, RECV_RELEASE, 468 iso->host->driver->isoctl(iso, RECV_RELEASE,
451 (unsigned long) &inf); 469 (unsigned long)&inf);
452 iso->bytes_discarded = 0; 470 iso->bytes_discarded = 0;
453 } 471 }
454 } 472 }
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 7fff5a1d2ea4..082c7fd239f5 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -121,8 +121,8 @@ struct host_info {
121}; 121};
122 122
123static int nodemgr_bus_match(struct device * dev, struct device_driver * drv); 123static int nodemgr_bus_match(struct device * dev, struct device_driver * drv);
124static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, 124static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
125 char *buffer, int buffer_size); 125 char *buffer, int buffer_size);
126static void nodemgr_resume_ne(struct node_entry *ne); 126static void nodemgr_resume_ne(struct node_entry *ne);
127static void nodemgr_remove_ne(struct node_entry *ne); 127static void nodemgr_remove_ne(struct node_entry *ne);
128static struct node_entry *find_entry_by_guid(u64 guid); 128static struct node_entry *find_entry_by_guid(u64 guid);
@@ -162,7 +162,7 @@ static void ud_cls_release(struct class_device *class_dev)
162static struct class nodemgr_ud_class = { 162static struct class nodemgr_ud_class = {
163 .name = "ieee1394", 163 .name = "ieee1394",
164 .release = ud_cls_release, 164 .release = ud_cls_release,
165 .hotplug = nodemgr_hotplug, 165 .uevent = nodemgr_uevent,
166}; 166};
167 167
168static struct hpsb_highlevel nodemgr_highlevel; 168static struct hpsb_highlevel nodemgr_highlevel;
@@ -743,21 +743,20 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
743 unsigned int generation) 743 unsigned int generation)
744{ 744{
745 struct hpsb_host *host = hi->host; 745 struct hpsb_host *host = hi->host;
746 struct node_entry *ne; 746 struct node_entry *ne;
747
748 ne = kmalloc(sizeof(struct node_entry), GFP_KERNEL);
749 if (!ne) return NULL;
750 747
751 memset(ne, 0, sizeof(struct node_entry)); 748 ne = kzalloc(sizeof(*ne), GFP_KERNEL);
749 if (!ne)
750 return NULL;
752 751
753 ne->tpool = &host->tpool[nodeid & NODE_MASK]; 752 ne->tpool = &host->tpool[nodeid & NODE_MASK];
754 753
755 ne->host = host; 754 ne->host = host;
756 ne->nodeid = nodeid; 755 ne->nodeid = nodeid;
757 ne->generation = generation; 756 ne->generation = generation;
758 ne->needs_probe = 1; 757 ne->needs_probe = 1;
759 758
760 ne->guid = guid; 759 ne->guid = guid;
761 ne->guid_vendor_id = (guid >> 40) & 0xffffff; 760 ne->guid_vendor_id = (guid >> 40) & 0xffffff;
762 ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id); 761 ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id);
763 ne->csr = csr; 762 ne->csr = csr;
@@ -787,7 +786,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr
787 (host->node_id == nodeid) ? "Host" : "Node", 786 (host->node_id == nodeid) ? "Host" : "Node",
788 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); 787 NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid);
789 788
790 return ne; 789 return ne;
791} 790}
792 791
793 792
@@ -872,12 +871,10 @@ static struct unit_directory *nodemgr_process_unit_directory
872 struct csr1212_keyval *kv; 871 struct csr1212_keyval *kv;
873 u8 last_key_id = 0; 872 u8 last_key_id = 0;
874 873
875 ud = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); 874 ud = kzalloc(sizeof(*ud), GFP_KERNEL);
876 if (!ud) 875 if (!ud)
877 goto unit_directory_error; 876 goto unit_directory_error;
878 877
879 memset (ud, 0, sizeof(struct unit_directory));
880
881 ud->ne = ne; 878 ud->ne = ne;
882 ud->ignore_driver = ignore_drivers; 879 ud->ignore_driver = ignore_drivers;
883 ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE; 880 ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE;
@@ -937,10 +934,10 @@ static struct unit_directory *nodemgr_process_unit_directory
937 /* Logical Unit Number */ 934 /* Logical Unit Number */
938 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { 935 if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
939 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { 936 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) {
940 ud_child = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); 937 ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL);
941 if (!ud_child) 938 if (!ud_child)
942 goto unit_directory_error; 939 goto unit_directory_error;
943 memcpy(ud_child, ud, sizeof(struct unit_directory)); 940 memcpy(ud_child, ud, sizeof(*ud_child));
944 nodemgr_register_device(ne, ud_child, &ne->device); 941 nodemgr_register_device(ne, ud_child, &ne->device);
945 ud_child = NULL; 942 ud_child = NULL;
946 943
@@ -966,7 +963,7 @@ static struct unit_directory *nodemgr_process_unit_directory
966 if (ud_child == NULL) 963 if (ud_child == NULL)
967 break; 964 break;
968 965
969 /* inherit unspecified values so hotplug picks it up */ 966 /* inherit unspecified values, the driver core picks it up */
970 if ((ud->flags & UNIT_DIRECTORY_MODEL_ID) && 967 if ((ud->flags & UNIT_DIRECTORY_MODEL_ID) &&
971 !(ud_child->flags & UNIT_DIRECTORY_MODEL_ID)) 968 !(ud_child->flags & UNIT_DIRECTORY_MODEL_ID))
972 { 969 {
@@ -1062,8 +1059,8 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
1062 1059
1063#ifdef CONFIG_HOTPLUG 1060#ifdef CONFIG_HOTPLUG
1064 1061
1065static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, 1062static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
1066 char *buffer, int buffer_size) 1063 char *buffer, int buffer_size)
1067{ 1064{
1068 struct unit_directory *ud; 1065 struct unit_directory *ud;
1069 int i = 0; 1066 int i = 0;
@@ -1112,8 +1109,8 @@ do { \
1112 1109
1113#else 1110#else
1114 1111
1115static int nodemgr_hotplug(struct class_device *cdev, char **envp, int num_envp, 1112static int nodemgr_uevent(struct class_device *cdev, char **envp, int num_envp,
1116 char *buffer, int buffer_size) 1113 char *buffer, int buffer_size)
1117{ 1114{
1118 return -ENODEV; 1115 return -ENODEV;
1119} 1116}
@@ -1200,7 +1197,7 @@ static void nodemgr_node_scan_one(struct host_info *hi,
1200 struct csr1212_csr *csr; 1197 struct csr1212_csr *csr;
1201 struct nodemgr_csr_info *ci; 1198 struct nodemgr_csr_info *ci;
1202 1199
1203 ci = kmalloc(sizeof(struct nodemgr_csr_info), GFP_KERNEL); 1200 ci = kmalloc(sizeof(*ci), GFP_KERNEL);
1204 if (!ci) 1201 if (!ci)
1205 return; 1202 return;
1206 1203
@@ -1349,6 +1346,33 @@ static void nodemgr_update_pdrv(struct node_entry *ne)
1349} 1346}
1350 1347
1351 1348
1349/* Write the BROADCAST_CHANNEL as per IEEE1394a 8.3.2.3.11 and 8.4.2.3. This
1350 * seems like an optional service but in the end it is practically mandatory
1351 * as a consequence of these clauses.
1352 *
1353 * Note that we cannot do a broadcast write to all nodes at once because some
1354 * pre-1394a devices would hang. */
1355static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
1356{
1357 const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL);
1358 quadlet_t bc_remote, bc_local;
1359 int ret;
1360
1361 if (!ne->host->is_irm || ne->generation != generation ||
1362 ne->nodeid == ne->host->node_id)
1363 return;
1364
1365 bc_local = cpu_to_be32(ne->host->csr.broadcast_channel);
1366
1367 /* Check if the register is implemented and 1394a compliant. */
1368 ret = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote,
1369 sizeof(bc_remote));
1370 if (!ret && bc_remote & cpu_to_be32(0x80000000) &&
1371 bc_remote != bc_local)
1372 hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local));
1373}
1374
1375
1352static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation) 1376static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation)
1353{ 1377{
1354 struct device *dev; 1378 struct device *dev;
@@ -1360,6 +1384,8 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
1360 if (!dev) 1384 if (!dev)
1361 return; 1385 return;
1362 1386
1387 nodemgr_irm_write_bc(ne, generation);
1388
1363 /* If "needs_probe", then this is either a new or changed node we 1389 /* If "needs_probe", then this is either a new or changed node we
1364 * rescan totally. If the generation matches for an existing node 1390 * rescan totally. If the generation matches for an existing node
1365 * (one that existed prior to the bus reset) we send update calls 1391 * (one that existed prior to the bus reset) we send update calls
@@ -1381,14 +1407,28 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1381 struct hpsb_host *host = hi->host; 1407 struct hpsb_host *host = hi->host;
1382 struct class *class = &nodemgr_ne_class; 1408 struct class *class = &nodemgr_ne_class;
1383 struct class_device *cdev; 1409 struct class_device *cdev;
1410 struct node_entry *ne;
1384 1411
1385 /* Do some processing of the nodes we've probed. This pulls them 1412 /* Do some processing of the nodes we've probed. This pulls them
1386 * into the sysfs layer if needed, and can result in processing of 1413 * into the sysfs layer if needed, and can result in processing of
1387 * unit-directories, or just updating the node and it's 1414 * unit-directories, or just updating the node and it's
1388 * unit-directories. */ 1415 * unit-directories.
1416 *
1417 * Run updates before probes. Usually, updates are time-critical
1418 * while probes are time-consuming. (Well, those probes need some
1419 * improvement...) */
1420
1389 down_read(&class->subsys.rwsem); 1421 down_read(&class->subsys.rwsem);
1390 list_for_each_entry(cdev, &class->children, node) 1422 list_for_each_entry(cdev, &class->children, node) {
1391 nodemgr_probe_ne(hi, container_of(cdev, struct node_entry, class_dev), generation); 1423 ne = container_of(cdev, struct node_entry, class_dev);
1424 if (!ne->needs_probe)
1425 nodemgr_probe_ne(hi, ne, generation);
1426 }
1427 list_for_each_entry(cdev, &class->children, node) {
1428 ne = container_of(cdev, struct node_entry, class_dev);
1429 if (ne->needs_probe)
1430 nodemgr_probe_ne(hi, ne, generation);
1431 }
1392 up_read(&class->subsys.rwsem); 1432 up_read(&class->subsys.rwsem);
1393 1433
1394 1434
@@ -1413,9 +1453,26 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1413 return; 1453 return;
1414} 1454}
1415 1455
1416/* Because we are a 1394a-2000 compliant IRM, we need to inform all the other 1456static int nodemgr_send_resume_packet(struct hpsb_host *host)
1417 * nodes of the broadcast channel. (Really we're only setting the validity 1457{
1418 * bit). Other IRM responsibilities go in here as well. */ 1458 struct hpsb_packet *packet;
1459 int ret = 1;
1460
1461 packet = hpsb_make_phypacket(host,
1462 EXTPHYPACKET_TYPE_RESUME |
1463 NODEID_TO_NODE(host->node_id) << PHYPACKET_PORT_SHIFT);
1464 if (packet) {
1465 packet->no_waiter = 1;
1466 packet->generation = get_hpsb_generation(host);
1467 ret = hpsb_send_packet(packet);
1468 }
1469 if (ret)
1470 HPSB_WARN("fw-host%d: Failed to broadcast resume packet",
1471 host->id);
1472 return ret;
1473}
1474
1475/* Perform a few high-level IRM responsibilities. */
1419static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles) 1476static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
1420{ 1477{
1421 quadlet_t bc; 1478 quadlet_t bc;
@@ -1424,13 +1481,8 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
1424 if (!host->is_irm || host->irm_id == (nodeid_t)-1) 1481 if (!host->is_irm || host->irm_id == (nodeid_t)-1)
1425 return 1; 1482 return 1;
1426 1483
1427 host->csr.broadcast_channel |= 0x40000000; /* set validity bit */ 1484 /* We are a 1394a-2000 compliant IRM. Set the validity bit. */
1428 1485 host->csr.broadcast_channel |= 0x40000000;
1429 bc = cpu_to_be32(host->csr.broadcast_channel);
1430
1431 hpsb_write(host, LOCAL_BUS | ALL_NODES, get_hpsb_generation(host),
1432 (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL),
1433 &bc, sizeof(quadlet_t));
1434 1486
1435 /* If there is no bus manager then we should set the root node's 1487 /* If there is no bus manager then we should set the root node's
1436 * force_root bit to promote bus stability per the 1394 1488 * force_root bit to promote bus stability per the 1394
@@ -1463,6 +1515,13 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
1463 } 1515 }
1464 } 1516 }
1465 1517
1518 /* Some devices suspend their ports while being connected to an inactive
1519 * host adapter, i.e. if connected before the low-level driver is
1520 * loaded. They become visible either when physically unplugged and
1521 * replugged, or when receiving a resume packet. Send one once. */
1522 if (!host->resume_packet_sent && !nodemgr_send_resume_packet(host))
1523 host->resume_packet_sent = 1;
1524
1466 return 1; 1525 return 1;
1467} 1526}
1468 1527
@@ -1571,8 +1630,8 @@ static int nodemgr_host_thread(void *__hi)
1571 1630
1572 /* Scan our nodes to get the bus options and create node 1631 /* Scan our nodes to get the bus options and create node
1573 * entries. This does not do the sysfs stuff, since that 1632 * entries. This does not do the sysfs stuff, since that
1574 * would trigger hotplug callbacks and such, which is a 1633 * would trigger uevents and such, which is a bad idea at
1575 * bad idea at this point. */ 1634 * this point. */
1576 nodemgr_node_scan(hi, generation); 1635 nodemgr_node_scan(hi, generation);
1577 1636
1578 /* This actually does the full probe, with sysfs 1637 /* This actually does the full probe, with sysfs
diff --git a/drivers/ieee1394/nodemgr.h b/drivers/ieee1394/nodemgr.h
index 3a2f0c02fd08..0b26616e16c3 100644
--- a/drivers/ieee1394/nodemgr.h
+++ b/drivers/ieee1394/nodemgr.h
@@ -151,24 +151,6 @@ static inline int hpsb_node_entry_valid(struct node_entry *ne)
151} 151}
152 152
153/* 153/*
154 * Returns a node entry (which has its reference count incremented) or NULL if
155 * the GUID in question is not known. Getting a valid entry does not mean that
156 * the node with this GUID is currently accessible (might be powered down).
157 */
158struct node_entry *hpsb_guid_get_entry(u64 guid);
159
160/* Same as above, but use the nodeid to get an node entry. This is not
161 * fool-proof by itself, since the nodeid can change. */
162struct node_entry *hpsb_nodeid_get_entry(struct hpsb_host *host, nodeid_t nodeid);
163
164/*
165 * If the entry refers to a local host, this function will return the pointer
166 * to the hpsb_host structure. It will return NULL otherwise. Once you have
167 * established it is a local host, you can use that knowledge from then on (the
168 * GUID won't wander to an external node). */
169struct hpsb_host *hpsb_get_host_by_ne(struct node_entry *ne);
170
171/*
172 * This will fill in the given, pre-initialised hpsb_packet with the current 154 * This will fill in the given, pre-initialised hpsb_packet with the current
173 * information from the node entry (host, node ID, generation number). It will 155 * information from the node entry (host, node ID, generation number). It will
174 * return false if the node owning the GUID is not accessible (and not modify the 156 * return false if the node owning the GUID is not accessible (and not modify the
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index 4cf9b8f3e336..b6b96fa04d62 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -161,9 +161,6 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args)
161#define PRINT(level, fmt, args...) \ 161#define PRINT(level, fmt, args...) \
162printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args) 162printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args)
163 163
164static char version[] __devinitdata =
165 "$Rev: 1313 $ Ben Collins <bcollins@debian.org>";
166
167/* Module Parameters */ 164/* Module Parameters */
168static int phys_dma = 1; 165static int phys_dma = 1;
169module_param(phys_dma, int, 0644); 166module_param(phys_dma, int, 0644);
@@ -587,12 +584,13 @@ static void ohci_initialize(struct ti_ohci *ohci)
587 sprintf (irq_buf, "%s", __irq_itoa(ohci->dev->irq)); 584 sprintf (irq_buf, "%s", __irq_itoa(ohci->dev->irq));
588#endif 585#endif
589 PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] " 586 PRINT(KERN_INFO, "OHCI-1394 %d.%d (PCI): IRQ=[%s] "
590 "MMIO=[%lx-%lx] Max Packet=[%d]", 587 "MMIO=[%lx-%lx] Max Packet=[%d] IR/IT contexts=[%d/%d]",
591 ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10), 588 ((((buf) >> 16) & 0xf) + (((buf) >> 20) & 0xf) * 10),
592 ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf, 589 ((((buf) >> 4) & 0xf) + ((buf) & 0xf) * 10), irq_buf,
593 pci_resource_start(ohci->dev, 0), 590 pci_resource_start(ohci->dev, 0),
594 pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1, 591 pci_resource_start(ohci->dev, 0) + OHCI1394_REGISTER_SIZE - 1,
595 ohci->max_packet_size); 592 ohci->max_packet_size,
593 ohci->nb_iso_rcv_ctx, ohci->nb_iso_xmit_ctx);
596 594
597 /* Check all of our ports to make sure that if anything is 595 /* Check all of our ports to make sure that if anything is
598 * connected, we enable that port. */ 596 * connected, we enable that port. */
@@ -2960,28 +2958,23 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d,
2960 d->ctrlClear = 0; 2958 d->ctrlClear = 0;
2961 d->cmdPtr = 0; 2959 d->cmdPtr = 0;
2962 2960
2963 d->buf_cpu = kmalloc(d->num_desc * sizeof(quadlet_t*), GFP_ATOMIC); 2961 d->buf_cpu = kzalloc(d->num_desc * sizeof(*d->buf_cpu), GFP_ATOMIC);
2964 d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC); 2962 d->buf_bus = kzalloc(d->num_desc * sizeof(*d->buf_bus), GFP_ATOMIC);
2965 2963
2966 if (d->buf_cpu == NULL || d->buf_bus == NULL) { 2964 if (d->buf_cpu == NULL || d->buf_bus == NULL) {
2967 PRINT(KERN_ERR, "Failed to allocate dma buffer"); 2965 PRINT(KERN_ERR, "Failed to allocate dma buffer");
2968 free_dma_rcv_ctx(d); 2966 free_dma_rcv_ctx(d);
2969 return -ENOMEM; 2967 return -ENOMEM;
2970 } 2968 }
2971 memset(d->buf_cpu, 0, d->num_desc * sizeof(quadlet_t*));
2972 memset(d->buf_bus, 0, d->num_desc * sizeof(dma_addr_t));
2973 2969
2974 d->prg_cpu = kmalloc(d->num_desc * sizeof(struct dma_cmd*), 2970 d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_ATOMIC);
2975 GFP_ATOMIC); 2971 d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_ATOMIC);
2976 d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC);
2977 2972
2978 if (d->prg_cpu == NULL || d->prg_bus == NULL) { 2973 if (d->prg_cpu == NULL || d->prg_bus == NULL) {
2979 PRINT(KERN_ERR, "Failed to allocate dma prg"); 2974 PRINT(KERN_ERR, "Failed to allocate dma prg");
2980 free_dma_rcv_ctx(d); 2975 free_dma_rcv_ctx(d);
2981 return -ENOMEM; 2976 return -ENOMEM;
2982 } 2977 }
2983 memset(d->prg_cpu, 0, d->num_desc * sizeof(struct dma_cmd*));
2984 memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t));
2985 2978
2986 d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC); 2979 d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC);
2987 2980
@@ -3093,17 +3086,14 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d,
3093 d->ctrlClear = 0; 3086 d->ctrlClear = 0;
3094 d->cmdPtr = 0; 3087 d->cmdPtr = 0;
3095 3088
3096 d->prg_cpu = kmalloc(d->num_desc * sizeof(struct at_dma_prg*), 3089 d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_KERNEL);
3097 GFP_KERNEL); 3090 d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_KERNEL);
3098 d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL);
3099 3091
3100 if (d->prg_cpu == NULL || d->prg_bus == NULL) { 3092 if (d->prg_cpu == NULL || d->prg_bus == NULL) {
3101 PRINT(KERN_ERR, "Failed to allocate at dma prg"); 3093 PRINT(KERN_ERR, "Failed to allocate at dma prg");
3102 free_dma_trm_ctx(d); 3094 free_dma_trm_ctx(d);
3103 return -ENOMEM; 3095 return -ENOMEM;
3104 } 3096 }
3105 memset(d->prg_cpu, 0, d->num_desc * sizeof(struct at_dma_prg*));
3106 memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t));
3107 3097
3108 len = sprintf(pool_name, "ohci1394_trm_prg"); 3098 len = sprintf(pool_name, "ohci1394_trm_prg");
3109 sprintf(pool_name+len, "%d", num_allocs); 3099 sprintf(pool_name+len, "%d", num_allocs);
@@ -3201,8 +3191,6 @@ static struct hpsb_host_driver ohci1394_driver = {
3201 .hw_csr_reg = ohci_hw_csr_reg, 3191 .hw_csr_reg = ohci_hw_csr_reg,
3202}; 3192};
3203 3193
3204
3205
3206/*********************************** 3194/***********************************
3207 * PCI Driver Interface functions * 3195 * PCI Driver Interface functions *
3208 ***********************************/ 3196 ***********************************/
@@ -3217,15 +3205,10 @@ do { \
3217static int __devinit ohci1394_pci_probe(struct pci_dev *dev, 3205static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3218 const struct pci_device_id *ent) 3206 const struct pci_device_id *ent)
3219{ 3207{
3220 static int version_printed = 0;
3221
3222 struct hpsb_host *host; 3208 struct hpsb_host *host;
3223 struct ti_ohci *ohci; /* shortcut to currently handled device */ 3209 struct ti_ohci *ohci; /* shortcut to currently handled device */
3224 unsigned long ohci_base; 3210 unsigned long ohci_base;
3225 3211
3226 if (version_printed++ == 0)
3227 PRINT_G(KERN_INFO, "%s", version);
3228
3229 if (pci_enable_device(dev)) 3212 if (pci_enable_device(dev))
3230 FAIL(-ENXIO, "Failed to enable OHCI hardware"); 3213 FAIL(-ENXIO, "Failed to enable OHCI hardware");
3231 pci_set_master(dev); 3214 pci_set_master(dev);
@@ -3369,13 +3352,8 @@ static int __devinit ohci1394_pci_probe(struct pci_dev *dev,
3369 /* Determine the number of available IR and IT contexts. */ 3352 /* Determine the number of available IR and IT contexts. */
3370 ohci->nb_iso_rcv_ctx = 3353 ohci->nb_iso_rcv_ctx =
3371 get_nb_iso_ctx(ohci, OHCI1394_IsoRecvIntMaskSet); 3354 get_nb_iso_ctx(ohci, OHCI1394_IsoRecvIntMaskSet);
3372 DBGMSG("%d iso receive contexts available",
3373 ohci->nb_iso_rcv_ctx);
3374
3375 ohci->nb_iso_xmit_ctx = 3355 ohci->nb_iso_xmit_ctx =
3376 get_nb_iso_ctx(ohci, OHCI1394_IsoXmitIntMaskSet); 3356 get_nb_iso_ctx(ohci, OHCI1394_IsoXmitIntMaskSet);
3377 DBGMSG("%d iso transmit contexts available",
3378 ohci->nb_iso_xmit_ctx);
3379 3357
3380 /* Set the usage bits for non-existent contexts so they can't 3358 /* Set the usage bits for non-existent contexts so they can't
3381 * be allocated */ 3359 * be allocated */
@@ -3606,8 +3584,6 @@ static struct pci_driver ohci1394_pci_driver = {
3606 .suspend = ohci1394_pci_suspend, 3584 .suspend = ohci1394_pci_suspend,
3607}; 3585};
3608 3586
3609
3610
3611/*********************************** 3587/***********************************
3612 * OHCI1394 Video Interface * 3588 * OHCI1394 Video Interface *
3613 ***********************************/ 3589 ***********************************/
@@ -3714,7 +3690,6 @@ EXPORT_SYMBOL(ohci1394_init_iso_tasklet);
3714EXPORT_SYMBOL(ohci1394_register_iso_tasklet); 3690EXPORT_SYMBOL(ohci1394_register_iso_tasklet);
3715EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet); 3691EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet);
3716 3692
3717
3718/*********************************** 3693/***********************************
3719 * General module initialization * 3694 * General module initialization *
3720 ***********************************/ 3695 ***********************************/
diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h
index cc66c1cae250..7df0962144e3 100644
--- a/drivers/ieee1394/ohci1394.h
+++ b/drivers/ieee1394/ohci1394.h
@@ -219,8 +219,8 @@ struct ti_ohci {
219 219
220 int self_id_errors; 220 int self_id_errors;
221 221
222 /* Tasklets for iso receive and transmit, used by video1394, 222 /* Tasklets for iso receive and transmit, used by video1394
223 * amdtp and dv1394 */ 223 * and dv1394 */
224 224
225 struct list_head iso_tasklet_list; 225 struct list_head iso_tasklet_list;
226 spinlock_t iso_tasklet_list_lock; 226 spinlock_t iso_tasklet_list_lock;
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c
index 6b1ab875333b..e2edc41e1b6f 100644
--- a/drivers/ieee1394/pcilynx.c
+++ b/drivers/ieee1394/pcilynx.c
@@ -1435,7 +1435,7 @@ static int __devinit add_card(struct pci_dev *dev,
1435 struct i2c_algo_bit_data i2c_adapter_data; 1435 struct i2c_algo_bit_data i2c_adapter_data;
1436 1436
1437 error = -ENOMEM; 1437 error = -ENOMEM;
1438 i2c_ad = kmalloc(sizeof(struct i2c_adapter), SLAB_KERNEL); 1438 i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL);
1439 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); 1439 if (!i2c_ad) FAIL("failed to allocate I2C adapter memory");
1440 1440
1441 memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); 1441 memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter));
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c
index 24411e666b21..b05235639918 100644
--- a/drivers/ieee1394/raw1394.c
+++ b/drivers/ieee1394/raw1394.c
@@ -102,12 +102,9 @@ static struct pending_request *__alloc_pending_request(gfp_t flags)
102{ 102{
103 struct pending_request *req; 103 struct pending_request *req;
104 104
105 req = (struct pending_request *)kmalloc(sizeof(struct pending_request), 105 req = kzalloc(sizeof(*req), flags);
106 flags); 106 if (req)
107 if (req != NULL) {
108 memset(req, 0, sizeof(struct pending_request));
109 INIT_LIST_HEAD(&req->list); 107 INIT_LIST_HEAD(&req->list);
110 }
111 108
112 return req; 109 return req;
113} 110}
@@ -192,9 +189,9 @@ static void add_host(struct hpsb_host *host)
192 struct host_info *hi; 189 struct host_info *hi;
193 unsigned long flags; 190 unsigned long flags;
194 191
195 hi = (struct host_info *)kmalloc(sizeof(struct host_info), GFP_KERNEL); 192 hi = kmalloc(sizeof(*hi), GFP_KERNEL);
196 193
197 if (hi != NULL) { 194 if (hi) {
198 INIT_LIST_HEAD(&hi->list); 195 INIT_LIST_HEAD(&hi->list);
199 hi->host = host; 196 hi->host = host;
200 INIT_LIST_HEAD(&hi->file_info_list); 197 INIT_LIST_HEAD(&hi->file_info_list);
@@ -315,8 +312,8 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data,
315 break; 312 break;
316 313
317 if (!ibs) { 314 if (!ibs) {
318 ibs = kmalloc(sizeof(struct iso_block_store) 315 ibs = kmalloc(sizeof(*ibs) + length,
319 + length, SLAB_ATOMIC); 316 SLAB_ATOMIC);
320 if (!ibs) { 317 if (!ibs) {
321 kfree(req); 318 kfree(req);
322 break; 319 break;
@@ -376,8 +373,8 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction,
376 break; 373 break;
377 374
378 if (!ibs) { 375 if (!ibs) {
379 ibs = kmalloc(sizeof(struct iso_block_store) 376 ibs = kmalloc(sizeof(*ibs) + length,
380 + length, SLAB_ATOMIC); 377 SLAB_ATOMIC);
381 if (!ibs) { 378 if (!ibs) {
382 kfree(req); 379 kfree(req);
383 break; 380 break;
@@ -502,10 +499,9 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
502 switch (req->req.type) { 499 switch (req->req.type) {
503 case RAW1394_REQ_LIST_CARDS: 500 case RAW1394_REQ_LIST_CARDS:
504 spin_lock_irqsave(&host_info_lock, flags); 501 spin_lock_irqsave(&host_info_lock, flags);
505 khl = kmalloc(sizeof(struct raw1394_khost_list) * host_count, 502 khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC);
506 SLAB_ATOMIC);
507 503
508 if (khl != NULL) { 504 if (khl) {
509 req->req.misc = host_count; 505 req->req.misc = host_count;
510 req->data = (quadlet_t *) khl; 506 req->data = (quadlet_t *) khl;
511 507
@@ -517,7 +513,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req)
517 } 513 }
518 spin_unlock_irqrestore(&host_info_lock, flags); 514 spin_unlock_irqrestore(&host_info_lock, flags);
519 515
520 if (khl != NULL) { 516 if (khl) {
521 req->req.error = RAW1394_ERROR_NONE; 517 req->req.error = RAW1394_ERROR_NONE;
522 req->req.length = min(req->req.length, 518 req->req.length = min(req->req.length,
523 (u32) (sizeof 519 (u32) (sizeof
@@ -1647,13 +1643,13 @@ static int arm_register(struct file_info *fi, struct pending_request *req)
1647 return (-EINVAL); 1643 return (-EINVAL);
1648 } 1644 }
1649 /* addr-list-entry for fileinfo */ 1645 /* addr-list-entry for fileinfo */
1650 addr = (struct arm_addr *)kmalloc(sizeof(struct arm_addr), SLAB_KERNEL); 1646 addr = kmalloc(sizeof(*addr), SLAB_KERNEL);
1651 if (!addr) { 1647 if (!addr) {
1652 req->req.length = 0; 1648 req->req.length = 0;
1653 return (-ENOMEM); 1649 return (-ENOMEM);
1654 } 1650 }
1655 /* allocation of addr_space_buffer */ 1651 /* allocation of addr_space_buffer */
1656 addr->addr_space_buffer = (u8 *) vmalloc(req->req.length); 1652 addr->addr_space_buffer = vmalloc(req->req.length);
1657 if (!(addr->addr_space_buffer)) { 1653 if (!(addr->addr_space_buffer)) {
1658 kfree(addr); 1654 kfree(addr);
1659 req->req.length = 0; 1655 req->req.length = 0;
@@ -2122,8 +2118,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req)
2122 return -ENOMEM; 2118 return -ENOMEM;
2123 } 2119 }
2124 2120
2125 cache->filled_head = 2121 cache->filled_head = kmalloc(sizeof(*cache->filled_head), GFP_KERNEL);
2126 kmalloc(sizeof(struct csr1212_cache_region), GFP_KERNEL);
2127 if (!cache->filled_head) { 2122 if (!cache->filled_head) {
2128 csr1212_release_keyval(fi->csr1212_dirs[dr]); 2123 csr1212_release_keyval(fi->csr1212_dirs[dr]);
2129 fi->csr1212_dirs[dr] = NULL; 2124 fi->csr1212_dirs[dr] = NULL;
@@ -2136,7 +2131,6 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req)
2136 req->req.length)) { 2131 req->req.length)) {
2137 csr1212_release_keyval(fi->csr1212_dirs[dr]); 2132 csr1212_release_keyval(fi->csr1212_dirs[dr]);
2138 fi->csr1212_dirs[dr] = NULL; 2133 fi->csr1212_dirs[dr] = NULL;
2139 CSR1212_FREE(cache);
2140 ret = -EFAULT; 2134 ret = -EFAULT;
2141 } else { 2135 } else {
2142 cache->len = req->req.length; 2136 cache->len = req->req.length;
@@ -2172,7 +2166,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req)
2172 } 2166 }
2173 } 2167 }
2174 kfree(cache->filled_head); 2168 kfree(cache->filled_head);
2175 kfree(cache); 2169 CSR1212_FREE(cache);
2176 2170
2177 if (ret >= 0) { 2171 if (ret >= 0) {
2178 /* we have to free the request, because we queue no response, 2172 /* we have to free the request, because we queue no response,
@@ -2488,8 +2482,8 @@ static int raw1394_iso_recv_packets(struct file_info *fi, void __user * uaddr)
2488 2482
2489 /* ensure user-supplied buffer is accessible and big enough */ 2483 /* ensure user-supplied buffer is accessible and big enough */
2490 if (!access_ok(VERIFY_WRITE, upackets.infos, 2484 if (!access_ok(VERIFY_WRITE, upackets.infos,
2491 upackets.n_packets * 2485 upackets.n_packets *
2492 sizeof(struct raw1394_iso_packet_info))) 2486 sizeof(struct raw1394_iso_packet_info)))
2493 return -EFAULT; 2487 return -EFAULT;
2494 2488
2495 /* copy the packet_infos out */ 2489 /* copy the packet_infos out */
@@ -2522,8 +2516,8 @@ static int raw1394_iso_send_packets(struct file_info *fi, void __user * uaddr)
2522 2516
2523 /* ensure user-supplied buffer is accessible and big enough */ 2517 /* ensure user-supplied buffer is accessible and big enough */
2524 if (!access_ok(VERIFY_READ, upackets.infos, 2518 if (!access_ok(VERIFY_READ, upackets.infos,
2525 upackets.n_packets * 2519 upackets.n_packets *
2526 sizeof(struct raw1394_iso_packet_info))) 2520 sizeof(struct raw1394_iso_packet_info)))
2527 return -EFAULT; 2521 return -EFAULT;
2528 2522
2529 /* copy the infos structs in and queue the packets */ 2523 /* copy the infos structs in and queue the packets */
@@ -2684,11 +2678,10 @@ static int raw1394_open(struct inode *inode, struct file *file)
2684{ 2678{
2685 struct file_info *fi; 2679 struct file_info *fi;
2686 2680
2687 fi = kmalloc(sizeof(struct file_info), SLAB_KERNEL); 2681 fi = kzalloc(sizeof(*fi), SLAB_KERNEL);
2688 if (fi == NULL) 2682 if (!fi)
2689 return -ENOMEM; 2683 return -ENOMEM;
2690 2684
2691 memset(fi, 0, sizeof(struct file_info));
2692 fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ 2685 fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */
2693 2686
2694 INIT_LIST_HEAD(&fi->list); 2687 INIT_LIST_HEAD(&fi->list);
@@ -2748,8 +2741,7 @@ static int raw1394_release(struct inode *inode, struct file *file)
2748 list) { 2741 list) {
2749 entry = fi_hlp->addr_list.next; 2742 entry = fi_hlp->addr_list.next;
2750 while (entry != &(fi_hlp->addr_list)) { 2743 while (entry != &(fi_hlp->addr_list)) {
2751 arm_addr = list_entry(entry, 2744 arm_addr = list_entry(entry, struct
2752 struct
2753 arm_addr, 2745 arm_addr,
2754 addr_list); 2746 addr_list);
2755 if (arm_addr->start == 2747 if (arm_addr->start ==
@@ -2912,16 +2904,17 @@ static int __init init_raw1394(void)
2912 2904
2913 hpsb_register_highlevel(&raw1394_highlevel); 2905 hpsb_register_highlevel(&raw1394_highlevel);
2914 2906
2915 if (IS_ERR(class_device_create(hpsb_protocol_class, NULL, MKDEV( 2907 if (IS_ERR
2916 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 2908 (class_device_create
2917 NULL, RAW1394_DEVICE_NAME))) { 2909 (hpsb_protocol_class, NULL,
2910 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), NULL,
2911 RAW1394_DEVICE_NAME))) {
2918 ret = -EFAULT; 2912 ret = -EFAULT;
2919 goto out_unreg; 2913 goto out_unreg;
2920 } 2914 }
2921 2915
2922 devfs_mk_cdev(MKDEV( 2916 devfs_mk_cdev(MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16),
2923 IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16), 2917 S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
2924 S_IFCHR | S_IRUSR | S_IWUSR, RAW1394_DEVICE_NAME);
2925 2918
2926 cdev_init(&raw1394_cdev, &raw1394_fops); 2919 cdev_init(&raw1394_cdev, &raw1394_fops);
2927 raw1394_cdev.owner = THIS_MODULE; 2920 raw1394_cdev.owner = THIS_MODULE;
@@ -2943,20 +2936,22 @@ static int __init init_raw1394(void)
2943 2936
2944 goto out; 2937 goto out;
2945 2938
2946out_dev: 2939 out_dev:
2947 devfs_remove(RAW1394_DEVICE_NAME); 2940 devfs_remove(RAW1394_DEVICE_NAME);
2948 class_device_destroy(hpsb_protocol_class, 2941 class_device_destroy(hpsb_protocol_class,
2949 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 2942 MKDEV(IEEE1394_MAJOR,
2950out_unreg: 2943 IEEE1394_MINOR_BLOCK_RAW1394 * 16));
2944 out_unreg:
2951 hpsb_unregister_highlevel(&raw1394_highlevel); 2945 hpsb_unregister_highlevel(&raw1394_highlevel);
2952out: 2946 out:
2953 return ret; 2947 return ret;
2954} 2948}
2955 2949
2956static void __exit cleanup_raw1394(void) 2950static void __exit cleanup_raw1394(void)
2957{ 2951{
2958 class_device_destroy(hpsb_protocol_class, 2952 class_device_destroy(hpsb_protocol_class,
2959 MKDEV(IEEE1394_MAJOR, IEEE1394_MINOR_BLOCK_RAW1394 * 16)); 2953 MKDEV(IEEE1394_MAJOR,
2954 IEEE1394_MINOR_BLOCK_RAW1394 * 16));
2960 cdev_del(&raw1394_cdev); 2955 cdev_del(&raw1394_cdev);
2961 devfs_remove(RAW1394_DEVICE_NAME); 2956 devfs_remove(RAW1394_DEVICE_NAME);
2962 hpsb_unregister_highlevel(&raw1394_highlevel); 2957 hpsb_unregister_highlevel(&raw1394_highlevel);
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index f7e18ccc5c0a..18d7eda38851 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -80,9 +80,6 @@
80#include "ieee1394_transactions.h" 80#include "ieee1394_transactions.h"
81#include "sbp2.h" 81#include "sbp2.h"
82 82
83static char version[] __devinitdata =
84 "$Rev: 1306 $ Ben Collins <bcollins@debian.org>";
85
86/* 83/*
87 * Module load parameter definitions 84 * Module load parameter definitions
88 */ 85 */
@@ -151,18 +148,15 @@ static int force_inquiry_hack;
151module_param(force_inquiry_hack, int, 0444); 148module_param(force_inquiry_hack, int, 0444);
152MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); 149MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)");
153 150
154
155/* 151/*
156 * Export information about protocols/devices supported by this driver. 152 * Export information about protocols/devices supported by this driver.
157 */ 153 */
158static struct ieee1394_device_id sbp2_id_table[] = { 154static struct ieee1394_device_id sbp2_id_table[] = {
159 { 155 {
160 .match_flags =IEEE1394_MATCH_SPECIFIER_ID | 156 .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION,
161 IEEE1394_MATCH_VERSION, 157 .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff,
162 .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, 158 .version = SBP2_SW_VERSION_ENTRY & 0xffffff},
163 .version = SBP2_SW_VERSION_ENTRY & 0xffffff 159 {}
164 },
165 { }
166}; 160};
167 161
168MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); 162MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table);
@@ -221,7 +215,6 @@ static u32 global_outstanding_dmas = 0;
221 215
222#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) 216#define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args)
223 217
224
225/* 218/*
226 * Globals 219 * Globals
227 */ 220 */
@@ -254,8 +247,8 @@ static struct hpsb_address_ops sbp2_ops = {
254 247
255#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA 248#ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA
256static struct hpsb_address_ops sbp2_physdma_ops = { 249static struct hpsb_address_ops sbp2_physdma_ops = {
257 .read = sbp2_handle_physdma_read, 250 .read = sbp2_handle_physdma_read,
258 .write = sbp2_handle_physdma_write, 251 .write = sbp2_handle_physdma_write,
259}; 252};
260#endif 253#endif
261 254
@@ -287,7 +280,6 @@ static u32 sbp2_broken_inquiry_list[] = {
287 * General utility functions 280 * General utility functions
288 **************************************/ 281 **************************************/
289 282
290
291#ifndef __BIG_ENDIAN 283#ifndef __BIG_ENDIAN
292/* 284/*
293 * Converts a buffer from be32 to cpu byte ordering. Length is in bytes. 285 * Converts a buffer from be32 to cpu byte ordering. Length is in bytes.
@@ -324,7 +316,8 @@ static __inline__ void sbp2util_cpu_to_be32_buffer(void *buffer, int length)
324/* 316/*
325 * Debug packet dump routine. Length is in bytes. 317 * Debug packet dump routine. Length is in bytes.
326 */ 318 */
327static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 dump_phys_addr) 319static void sbp2util_packet_dump(void *buffer, int length, char *dump_name,
320 u32 dump_phys_addr)
328{ 321{
329 int i; 322 int i;
330 unsigned char *dump = buffer; 323 unsigned char *dump = buffer;
@@ -345,7 +338,7 @@ static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32
345 printk(" "); 338 printk(" ");
346 if ((i & 0xf) == 0) 339 if ((i & 0xf) == 0)
347 printk("\n "); 340 printk("\n ");
348 printk("%02x ", (int) dump[i]); 341 printk("%02x ", (int)dump[i]);
349 } 342 }
350 printk("\n"); 343 printk("\n");
351 344
@@ -364,9 +357,9 @@ static int sbp2util_down_timeout(atomic_t *done, int timeout)
364 357
365 for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { 358 for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) {
366 if (msleep_interruptible(100)) /* 100ms */ 359 if (msleep_interruptible(100)) /* 100ms */
367 return(1); 360 return 1;
368 } 361 }
369 return ((i > 0) ? 0:1); 362 return (i > 0) ? 0 : 1;
370} 363}
371 364
372/* Free's an allocated packet */ 365/* Free's an allocated packet */
@@ -380,21 +373,22 @@ static void sbp2_free_packet(struct hpsb_packet *packet)
380 * subaction and returns immediately. Can be used from interrupts. 373 * subaction and returns immediately. Can be used from interrupts.
381 */ 374 */
382static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, 375static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr,
383 quadlet_t *buffer, size_t length) 376 quadlet_t *buffer, size_t length)
384{ 377{
385 struct hpsb_packet *packet; 378 struct hpsb_packet *packet;
386 379
387 packet = hpsb_make_writepacket(ne->host, ne->nodeid, 380 packet = hpsb_make_writepacket(ne->host, ne->nodeid,
388 addr, buffer, length); 381 addr, buffer, length);
389 if (!packet) 382 if (!packet)
390 return -ENOMEM; 383 return -ENOMEM;
391 384
392 hpsb_set_packet_complete_task(packet, (void (*)(void*))sbp2_free_packet, 385 hpsb_set_packet_complete_task(packet,
386 (void (*)(void *))sbp2_free_packet,
393 packet); 387 packet);
394 388
395 hpsb_node_fill_packet(ne, packet); 389 hpsb_node_fill_packet(ne, packet);
396 390
397 if (hpsb_send_packet(packet) < 0) { 391 if (hpsb_send_packet(packet) < 0) {
398 sbp2_free_packet(packet); 392 sbp2_free_packet(packet);
399 return -EIO; 393 return -EIO;
400 } 394 }
@@ -417,22 +411,22 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i
417 411
418 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); 412 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
419 for (i = 0; i < orbs; i++) { 413 for (i = 0; i < orbs; i++) {
420 command = (struct sbp2_command_info *) 414 command = kzalloc(sizeof(*command), GFP_ATOMIC);
421 kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC);
422 if (!command) { 415 if (!command) {
423 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 416 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock,
424 return(-ENOMEM); 417 flags);
418 return -ENOMEM;
425 } 419 }
426 memset(command, '\0', sizeof(struct sbp2_command_info));
427 command->command_orb_dma = 420 command->command_orb_dma =
428 pci_map_single (hi->host->pdev, &command->command_orb, 421 pci_map_single(hi->host->pdev, &command->command_orb,
429 sizeof(struct sbp2_command_orb), 422 sizeof(struct sbp2_command_orb),
430 PCI_DMA_BIDIRECTIONAL); 423 PCI_DMA_BIDIRECTIONAL);
431 SBP2_DMA_ALLOC("single command orb DMA"); 424 SBP2_DMA_ALLOC("single command orb DMA");
432 command->sge_dma = 425 command->sge_dma =
433 pci_map_single (hi->host->pdev, &command->scatter_gather_element, 426 pci_map_single(hi->host->pdev,
434 sizeof(command->scatter_gather_element), 427 &command->scatter_gather_element,
435 PCI_DMA_BIDIRECTIONAL); 428 sizeof(command->scatter_gather_element),
429 PCI_DMA_BIDIRECTIONAL);
436 SBP2_DMA_ALLOC("scatter_gather_element"); 430 SBP2_DMA_ALLOC("scatter_gather_element");
437 INIT_LIST_HEAD(&command->list); 431 INIT_LIST_HEAD(&command->list);
438 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); 432 list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed);
@@ -488,7 +482,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb(
488 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { 482 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) {
489 if (command->command_orb_dma == orb) { 483 if (command->command_orb_dma == orb) {
490 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 484 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
491 return (command); 485 return command;
492 } 486 }
493 } 487 }
494 } 488 }
@@ -496,7 +490,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb(
496 490
497 SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb); 491 SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb);
498 492
499 return(NULL); 493 return NULL;
500} 494}
501 495
502/* 496/*
@@ -513,12 +507,12 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_
513 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { 507 list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) {
514 if (command->Current_SCpnt == SCpnt) { 508 if (command->Current_SCpnt == SCpnt) {
515 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 509 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
516 return (command); 510 return command;
517 } 511 }
518 } 512 }
519 } 513 }
520 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 514 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
521 return(NULL); 515 return NULL;
522} 516}
523 517
524/* 518/*
@@ -545,7 +539,7 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb(
545 SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); 539 SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!");
546 } 540 }
547 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); 541 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
548 return (command); 542 return command;
549} 543}
550 544
551/* Free our DMA's */ 545/* Free our DMA's */
@@ -587,7 +581,8 @@ static void sbp2util_free_command_dma(struct sbp2_command_info *command)
587/* 581/*
588 * This function moves a command to the completed orb list. 582 * This function moves a command to the completed orb list.
589 */ 583 */
590static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, struct sbp2_command_info *command) 584static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id,
585 struct sbp2_command_info *command)
591{ 586{
592 unsigned long flags; 587 unsigned long flags;
593 588
@@ -606,8 +601,6 @@ static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_
606 return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo; 601 return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo;
607} 602}
608 603
609
610
611/********************************************* 604/*********************************************
612 * IEEE-1394 core driver stack related section 605 * IEEE-1394 core driver stack related section
613 *********************************************/ 606 *********************************************/
@@ -627,14 +620,14 @@ static int sbp2_probe(struct device *dev)
627 if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY) 620 if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY)
628 return -ENODEV; 621 return -ENODEV;
629 622
630 scsi_id = sbp2_alloc_device(ud); 623 scsi_id = sbp2_alloc_device(ud);
631 624
632 if (!scsi_id) 625 if (!scsi_id)
633 return -ENOMEM; 626 return -ENOMEM;
634 627
635 sbp2_parse_unit_directory(scsi_id, ud); 628 sbp2_parse_unit_directory(scsi_id, ud);
636 629
637 return sbp2_start_device(scsi_id); 630 return sbp2_start_device(scsi_id);
638} 631}
639 632
640static int sbp2_remove(struct device *dev) 633static int sbp2_remove(struct device *dev)
@@ -719,12 +712,11 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
719 712
720 SBP2_DEBUG("sbp2_alloc_device"); 713 SBP2_DEBUG("sbp2_alloc_device");
721 714
722 scsi_id = kmalloc(sizeof(*scsi_id), GFP_KERNEL); 715 scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL);
723 if (!scsi_id) { 716 if (!scsi_id) {
724 SBP2_ERR("failed to create scsi_id"); 717 SBP2_ERR("failed to create scsi_id");
725 goto failed_alloc; 718 goto failed_alloc;
726 } 719 }
727 memset(scsi_id, 0, sizeof(*scsi_id));
728 720
729 scsi_id->ne = ud->ne; 721 scsi_id->ne = ud->ne;
730 scsi_id->ud = ud; 722 scsi_id->ud = ud;
@@ -735,7 +727,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
735 INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed); 727 INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed);
736 INIT_LIST_HEAD(&scsi_id->scsi_list); 728 INIT_LIST_HEAD(&scsi_id->scsi_list);
737 spin_lock_init(&scsi_id->sbp2_command_orb_lock); 729 spin_lock_init(&scsi_id->sbp2_command_orb_lock);
738 scsi_id->sbp2_device_type_and_lun = SBP2_DEVICE_TYPE_LUN_UNINITIALIZED; 730 scsi_id->sbp2_lun = 0;
739 731
740 ud->device.driver_data = scsi_id; 732 ud->device.driver_data = scsi_id;
741 733
@@ -769,7 +761,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud
769 761
770 /* Register our host with the SCSI stack. */ 762 /* Register our host with the SCSI stack. */
771 scsi_host = scsi_host_alloc(&scsi_driver_template, 763 scsi_host = scsi_host_alloc(&scsi_driver_template,
772 sizeof (unsigned long)); 764 sizeof(unsigned long));
773 if (!scsi_host) { 765 if (!scsi_host) {
774 SBP2_ERR("failed to register scsi host"); 766 SBP2_ERR("failed to register scsi host");
775 goto failed_alloc; 767 goto failed_alloc;
@@ -790,7 +782,6 @@ failed_alloc:
790 return NULL; 782 return NULL;
791} 783}
792 784
793
794static void sbp2_host_reset(struct hpsb_host *host) 785static void sbp2_host_reset(struct hpsb_host *host)
795{ 786{
796 struct sbp2scsi_host_info *hi; 787 struct sbp2scsi_host_info *hi;
@@ -804,7 +795,6 @@ static void sbp2_host_reset(struct hpsb_host *host)
804 } 795 }
805} 796}
806 797
807
808/* 798/*
809 * This function is where we first pull the node unique ids, and then 799 * This function is where we first pull the node unique ids, and then
810 * allocate memory and register a SBP-2 device. 800 * allocate memory and register a SBP-2 device.
@@ -818,7 +808,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
818 808
819 /* Login FIFO DMA */ 809 /* Login FIFO DMA */
820 scsi_id->login_response = 810 scsi_id->login_response =
821 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_response), 811 pci_alloc_consistent(hi->host->pdev,
812 sizeof(struct sbp2_login_response),
822 &scsi_id->login_response_dma); 813 &scsi_id->login_response_dma);
823 if (!scsi_id->login_response) 814 if (!scsi_id->login_response)
824 goto alloc_fail; 815 goto alloc_fail;
@@ -826,7 +817,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
826 817
827 /* Query logins ORB DMA */ 818 /* Query logins ORB DMA */
828 scsi_id->query_logins_orb = 819 scsi_id->query_logins_orb =
829 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_orb), 820 pci_alloc_consistent(hi->host->pdev,
821 sizeof(struct sbp2_query_logins_orb),
830 &scsi_id->query_logins_orb_dma); 822 &scsi_id->query_logins_orb_dma);
831 if (!scsi_id->query_logins_orb) 823 if (!scsi_id->query_logins_orb)
832 goto alloc_fail; 824 goto alloc_fail;
@@ -834,7 +826,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
834 826
835 /* Query logins response DMA */ 827 /* Query logins response DMA */
836 scsi_id->query_logins_response = 828 scsi_id->query_logins_response =
837 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_response), 829 pci_alloc_consistent(hi->host->pdev,
830 sizeof(struct sbp2_query_logins_response),
838 &scsi_id->query_logins_response_dma); 831 &scsi_id->query_logins_response_dma);
839 if (!scsi_id->query_logins_response) 832 if (!scsi_id->query_logins_response)
840 goto alloc_fail; 833 goto alloc_fail;
@@ -842,7 +835,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
842 835
843 /* Reconnect ORB DMA */ 836 /* Reconnect ORB DMA */
844 scsi_id->reconnect_orb = 837 scsi_id->reconnect_orb =
845 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_reconnect_orb), 838 pci_alloc_consistent(hi->host->pdev,
839 sizeof(struct sbp2_reconnect_orb),
846 &scsi_id->reconnect_orb_dma); 840 &scsi_id->reconnect_orb_dma);
847 if (!scsi_id->reconnect_orb) 841 if (!scsi_id->reconnect_orb)
848 goto alloc_fail; 842 goto alloc_fail;
@@ -850,7 +844,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
850 844
851 /* Logout ORB DMA */ 845 /* Logout ORB DMA */
852 scsi_id->logout_orb = 846 scsi_id->logout_orb =
853 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_logout_orb), 847 pci_alloc_consistent(hi->host->pdev,
848 sizeof(struct sbp2_logout_orb),
854 &scsi_id->logout_orb_dma); 849 &scsi_id->logout_orb_dma);
855 if (!scsi_id->logout_orb) 850 if (!scsi_id->logout_orb)
856 goto alloc_fail; 851 goto alloc_fail;
@@ -858,58 +853,11 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id)
858 853
859 /* Login ORB DMA */ 854 /* Login ORB DMA */
860 scsi_id->login_orb = 855 scsi_id->login_orb =
861 pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_orb), 856 pci_alloc_consistent(hi->host->pdev,
857 sizeof(struct sbp2_login_orb),
862 &scsi_id->login_orb_dma); 858 &scsi_id->login_orb_dma);
863 if (!scsi_id->login_orb) { 859 if (!scsi_id->login_orb)
864alloc_fail: 860 goto alloc_fail;
865 if (scsi_id->query_logins_response) {
866 pci_free_consistent(hi->host->pdev,
867 sizeof(struct sbp2_query_logins_response),
868 scsi_id->query_logins_response,
869 scsi_id->query_logins_response_dma);
870 SBP2_DMA_FREE("query logins response DMA");
871 }
872
873 if (scsi_id->query_logins_orb) {
874 pci_free_consistent(hi->host->pdev,
875 sizeof(struct sbp2_query_logins_orb),
876 scsi_id->query_logins_orb,
877 scsi_id->query_logins_orb_dma);
878 SBP2_DMA_FREE("query logins ORB DMA");
879 }
880
881 if (scsi_id->logout_orb) {
882 pci_free_consistent(hi->host->pdev,
883 sizeof(struct sbp2_logout_orb),
884 scsi_id->logout_orb,
885 scsi_id->logout_orb_dma);
886 SBP2_DMA_FREE("logout ORB DMA");
887 }
888
889 if (scsi_id->reconnect_orb) {
890 pci_free_consistent(hi->host->pdev,
891 sizeof(struct sbp2_reconnect_orb),
892 scsi_id->reconnect_orb,
893 scsi_id->reconnect_orb_dma);
894 SBP2_DMA_FREE("reconnect ORB DMA");
895 }
896
897 if (scsi_id->login_response) {
898 pci_free_consistent(hi->host->pdev,
899 sizeof(struct sbp2_login_response),
900 scsi_id->login_response,
901 scsi_id->login_response_dma);
902 SBP2_DMA_FREE("login FIFO DMA");
903 }
904
905 list_del(&scsi_id->scsi_list);
906
907 kfree(scsi_id);
908
909 SBP2_ERR ("Could not allocate memory for scsi_id");
910
911 return -ENOMEM;
912 }
913 SBP2_DMA_ALLOC("consistent DMA region for login ORB"); 861 SBP2_DMA_ALLOC("consistent DMA region for login ORB");
914 862
915 SBP2_DEBUG("New SBP-2 device inserted, SCSI ID = %x", scsi_id->ud->id); 863 SBP2_DEBUG("New SBP-2 device inserted, SCSI ID = %x", scsi_id->ud->id);
@@ -935,7 +883,7 @@ alloc_fail:
935 sbp2_remove_device(scsi_id); 883 sbp2_remove_device(scsi_id);
936 return -EINTR; 884 return -EINTR;
937 } 885 }
938 886
939 /* 887 /*
940 * Login to the sbp-2 device 888 * Login to the sbp-2 device
941 */ 889 */
@@ -964,10 +912,17 @@ alloc_fail:
964 error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0); 912 error = scsi_add_device(scsi_id->scsi_host, 0, scsi_id->ud->id, 0);
965 if (error) { 913 if (error) {
966 SBP2_ERR("scsi_add_device failed"); 914 SBP2_ERR("scsi_add_device failed");
915 sbp2_logout_device(scsi_id);
916 sbp2_remove_device(scsi_id);
967 return error; 917 return error;
968 } 918 }
969 919
970 return 0; 920 return 0;
921
922alloc_fail:
923 SBP2_ERR("Could not allocate memory for scsi_id");
924 sbp2_remove_device(scsi_id);
925 return -ENOMEM;
971} 926}
972 927
973/* 928/*
@@ -1054,51 +1009,44 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id)
1054 * This function deals with physical dma write requests (for adapters that do not support 1009 * This function deals with physical dma write requests (for adapters that do not support
1055 * physical dma in hardware). Mostly just here for debugging... 1010 * physical dma in hardware). Mostly just here for debugging...
1056 */ 1011 */
1057static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data, 1012static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid,
1058 u64 addr, size_t length, u16 flags) 1013 int destid, quadlet_t *data, u64 addr,
1014 size_t length, u16 flags)
1059{ 1015{
1060 1016
1061 /* 1017 /*
1062 * Manually put the data in the right place. 1018 * Manually put the data in the right place.
1063 */ 1019 */
1064 memcpy(bus_to_virt((u32)addr), data, length); 1020 memcpy(bus_to_virt((u32) addr), data, length);
1065 sbp2util_packet_dump(data, length, "sbp2 phys dma write by device", (u32)addr); 1021 sbp2util_packet_dump(data, length, "sbp2 phys dma write by device",
1066 return(RCODE_COMPLETE); 1022 (u32) addr);
1023 return RCODE_COMPLETE;
1067} 1024}
1068 1025
1069/* 1026/*
1070 * This function deals with physical dma read requests (for adapters that do not support 1027 * This function deals with physical dma read requests (for adapters that do not support
1071 * physical dma in hardware). Mostly just here for debugging... 1028 * physical dma in hardware). Mostly just here for debugging...
1072 */ 1029 */
1073static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data, 1030static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid,
1074 u64 addr, size_t length, u16 flags) 1031 quadlet_t *data, u64 addr, size_t length,
1032 u16 flags)
1075{ 1033{
1076 1034
1077 /* 1035 /*
1078 * Grab data from memory and send a read response. 1036 * Grab data from memory and send a read response.
1079 */ 1037 */
1080 memcpy(data, bus_to_virt((u32)addr), length); 1038 memcpy(data, bus_to_virt((u32) addr), length);
1081 sbp2util_packet_dump(data, length, "sbp2 phys dma read by device", (u32)addr); 1039 sbp2util_packet_dump(data, length, "sbp2 phys dma read by device",
1082 return(RCODE_COMPLETE); 1040 (u32) addr);
1041 return RCODE_COMPLETE;
1083} 1042}
1084#endif 1043#endif
1085 1044
1086
1087/************************************** 1045/**************************************
1088 * SBP-2 protocol related section 1046 * SBP-2 protocol related section
1089 **************************************/ 1047 **************************************/
1090 1048
1091/* 1049/*
1092 * This function determines if we should convert scsi commands for a particular sbp2 device type
1093 */
1094static __inline__ int sbp2_command_conversion_device_type(u8 device_type)
1095{
1096 return (((device_type == TYPE_DISK) ||
1097 (device_type == TYPE_RBC) ||
1098 (device_type == TYPE_ROM)) ? 1:0);
1099}
1100
1101/*
1102 * This function queries the device for the maximum concurrent logins it 1050 * This function queries the device for the maximum concurrent logins it
1103 * supports. 1051 * supports.
1104 */ 1052 */
@@ -1120,11 +1068,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1120 1068
1121 scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST); 1069 scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST);
1122 scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1); 1070 scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1);
1123 if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { 1071 scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun);
1124 scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun);
1125 SBP2_DEBUG("sbp2_query_logins: set lun to %d",
1126 ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun));
1127 }
1128 SBP2_DEBUG("sbp2_query_logins: lun_misc initialized"); 1072 SBP2_DEBUG("sbp2_query_logins: lun_misc initialized");
1129 1073
1130 scsi_id->query_logins_orb->reserved_resp_length = 1074 scsi_id->query_logins_orb->reserved_resp_length =
@@ -1161,12 +1105,12 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1161 1105
1162 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { 1106 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) {
1163 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1107 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1164 return(-EIO); 1108 return -EIO;
1165 } 1109 }
1166 1110
1167 if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) { 1111 if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) {
1168 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1112 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1169 return(-EIO); 1113 return -EIO;
1170 } 1114 }
1171 1115
1172 if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) || 1116 if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) ||
@@ -1174,7 +1118,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1174 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { 1118 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
1175 1119
1176 SBP2_INFO("Error querying logins to SBP-2 device - timed out"); 1120 SBP2_INFO("Error querying logins to SBP-2 device - timed out");
1177 return(-EIO); 1121 return -EIO;
1178 } 1122 }
1179 1123
1180 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response)); 1124 sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response));
@@ -1191,7 +1135,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id)
1191 SBP2_DEBUG("Number of active logins: %d", active_logins); 1135 SBP2_DEBUG("Number of active logins: %d", active_logins);
1192 1136
1193 if (active_logins >= max_logins) { 1137 if (active_logins >= max_logins) {
1194 return(-EIO); 1138 return -EIO;
1195 } 1139 }
1196 1140
1197 return 0; 1141 return 0;
@@ -1210,13 +1154,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1210 1154
1211 if (!scsi_id->login_orb) { 1155 if (!scsi_id->login_orb) {
1212 SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!"); 1156 SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!");
1213 return(-EIO); 1157 return -EIO;
1214 } 1158 }
1215 1159
1216 if (!exclusive_login) { 1160 if (!exclusive_login) {
1217 if (sbp2_query_logins(scsi_id)) { 1161 if (sbp2_query_logins(scsi_id)) {
1218 SBP2_INFO("Device does not support any more concurrent logins"); 1162 SBP2_INFO("Device does not support any more concurrent logins");
1219 return(-EIO); 1163 return -EIO;
1220 } 1164 }
1221 } 1165 }
1222 1166
@@ -1233,12 +1177,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1233 scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */ 1177 scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */
1234 scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */ 1178 scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */
1235 scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */ 1179 scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */
1236 /* Set the lun if we were able to pull it from the device's unit directory */ 1180 scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun);
1237 if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) {
1238 scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun);
1239 SBP2_DEBUG("sbp2_query_logins: set lun to %d",
1240 ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun));
1241 }
1242 SBP2_DEBUG("sbp2_login_device: lun_misc initialized"); 1181 SBP2_DEBUG("sbp2_login_device: lun_misc initialized");
1243 1182
1244 scsi_id->login_orb->passwd_resp_lengths = 1183 scsi_id->login_orb->passwd_resp_lengths =
@@ -1288,7 +1227,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1288 */ 1227 */
1289 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) { 1228 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) {
1290 SBP2_ERR("Error logging into SBP-2 device - login timed-out"); 1229 SBP2_ERR("Error logging into SBP-2 device - login timed-out");
1291 return(-EIO); 1230 return -EIO;
1292 } 1231 }
1293 1232
1294 /* 1233 /*
@@ -1296,7 +1235,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1296 */ 1235 */
1297 if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) { 1236 if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) {
1298 SBP2_ERR("Error logging into SBP-2 device - login timed-out"); 1237 SBP2_ERR("Error logging into SBP-2 device - login timed-out");
1299 return(-EIO); 1238 return -EIO;
1300 } 1239 }
1301 1240
1302 /* 1241 /*
@@ -1307,7 +1246,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1307 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { 1246 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
1308 1247
1309 SBP2_ERR("Error logging into SBP-2 device - login failed"); 1248 SBP2_ERR("Error logging into SBP-2 device - login failed");
1310 return(-EIO); 1249 return -EIO;
1311 } 1250 }
1312 1251
1313 /* 1252 /*
@@ -1331,7 +1270,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id)
1331 1270
1332 SBP2_INFO("Logged into SBP-2 device"); 1271 SBP2_INFO("Logged into SBP-2 device");
1333 1272
1334 return(0); 1273 return 0;
1335 1274
1336} 1275}
1337 1276
@@ -1385,8 +1324,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
1385 atomic_set(&scsi_id->sbp2_login_complete, 0); 1324 atomic_set(&scsi_id->sbp2_login_complete, 0);
1386 1325
1387 error = hpsb_node_write(scsi_id->ne, 1326 error = hpsb_node_write(scsi_id->ne,
1388 scsi_id->sbp2_management_agent_addr, 1327 scsi_id->sbp2_management_agent_addr, data, 8);
1389 data, 8);
1390 if (error) 1328 if (error)
1391 return error; 1329 return error;
1392 1330
@@ -1396,7 +1334,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id)
1396 1334
1397 SBP2_INFO("Logged out of SBP-2 device"); 1335 SBP2_INFO("Logged out of SBP-2 device");
1398 1336
1399 return(0); 1337 return 0;
1400 1338
1401} 1339}
1402 1340
@@ -1456,8 +1394,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1456 atomic_set(&scsi_id->sbp2_login_complete, 0); 1394 atomic_set(&scsi_id->sbp2_login_complete, 0);
1457 1395
1458 error = hpsb_node_write(scsi_id->ne, 1396 error = hpsb_node_write(scsi_id->ne,
1459 scsi_id->sbp2_management_agent_addr, 1397 scsi_id->sbp2_management_agent_addr, data, 8);
1460 data, 8);
1461 if (error) 1398 if (error)
1462 return error; 1399 return error;
1463 1400
@@ -1466,7 +1403,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1466 */ 1403 */
1467 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) { 1404 if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) {
1468 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); 1405 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out");
1469 return(-EIO); 1406 return -EIO;
1470 } 1407 }
1471 1408
1472 /* 1409 /*
@@ -1474,7 +1411,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1474 */ 1411 */
1475 if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) { 1412 if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) {
1476 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); 1413 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out");
1477 return(-EIO); 1414 return -EIO;
1478 } 1415 }
1479 1416
1480 /* 1417 /*
@@ -1485,12 +1422,12 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id)
1485 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { 1422 STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) {
1486 1423
1487 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed"); 1424 SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed");
1488 return(-EIO); 1425 return -EIO;
1489 } 1426 }
1490 1427
1491 HPSB_DEBUG("Reconnected to SBP-2 device"); 1428 HPSB_DEBUG("Reconnected to SBP-2 device");
1492 1429
1493 return(0); 1430 return 0;
1494 1431
1495} 1432}
1496 1433
@@ -1513,10 +1450,9 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id)
1513 SBP2_ERR("sbp2_set_busy_timeout error"); 1450 SBP2_ERR("sbp2_set_busy_timeout error");
1514 } 1451 }
1515 1452
1516 return(0); 1453 return 0;
1517} 1454}
1518 1455
1519
1520/* 1456/*
1521 * This function is called to parse sbp2 device's config rom unit 1457 * This function is called to parse sbp2 device's config rom unit
1522 * directory. Used to determine things like sbp2 management agent offset, 1458 * directory. Used to determine things like sbp2 management agent offset,
@@ -1529,7 +1465,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1529 struct csr1212_dentry *dentry; 1465 struct csr1212_dentry *dentry;
1530 u64 management_agent_addr; 1466 u64 management_agent_addr;
1531 u32 command_set_spec_id, command_set, unit_characteristics, 1467 u32 command_set_spec_id, command_set, unit_characteristics,
1532 firmware_revision, workarounds; 1468 firmware_revision, workarounds;
1533 int i; 1469 int i;
1534 1470
1535 SBP2_DEBUG("sbp2_parse_unit_directory"); 1471 SBP2_DEBUG("sbp2_parse_unit_directory");
@@ -1547,13 +1483,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1547 if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) { 1483 if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) {
1548 /* Save off the management agent address */ 1484 /* Save off the management agent address */
1549 management_agent_addr = 1485 management_agent_addr =
1550 CSR1212_REGISTER_SPACE_BASE + 1486 CSR1212_REGISTER_SPACE_BASE +
1551 (kv->value.csr_offset << 2); 1487 (kv->value.csr_offset << 2);
1552 1488
1553 SBP2_DEBUG("sbp2_management_agent_addr = %x", 1489 SBP2_DEBUG("sbp2_management_agent_addr = %x",
1554 (unsigned int) management_agent_addr); 1490 (unsigned int)management_agent_addr);
1555 } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { 1491 } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) {
1556 scsi_id->sbp2_device_type_and_lun = kv->value.immediate; 1492 scsi_id->sbp2_lun =
1493 ORB_SET_LUN(kv->value.immediate);
1557 } 1494 }
1558 break; 1495 break;
1559 1496
@@ -1561,14 +1498,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1561 /* Command spec organization */ 1498 /* Command spec organization */
1562 command_set_spec_id = kv->value.immediate; 1499 command_set_spec_id = kv->value.immediate;
1563 SBP2_DEBUG("sbp2_command_set_spec_id = %x", 1500 SBP2_DEBUG("sbp2_command_set_spec_id = %x",
1564 (unsigned int) command_set_spec_id); 1501 (unsigned int)command_set_spec_id);
1565 break; 1502 break;
1566 1503
1567 case SBP2_COMMAND_SET_KEY: 1504 case SBP2_COMMAND_SET_KEY:
1568 /* Command set used by sbp2 device */ 1505 /* Command set used by sbp2 device */
1569 command_set = kv->value.immediate; 1506 command_set = kv->value.immediate;
1570 SBP2_DEBUG("sbp2_command_set = %x", 1507 SBP2_DEBUG("sbp2_command_set = %x",
1571 (unsigned int) command_set); 1508 (unsigned int)command_set);
1572 break; 1509 break;
1573 1510
1574 case SBP2_UNIT_CHARACTERISTICS_KEY: 1511 case SBP2_UNIT_CHARACTERISTICS_KEY:
@@ -1578,7 +1515,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1578 */ 1515 */
1579 unit_characteristics = kv->value.immediate; 1516 unit_characteristics = kv->value.immediate;
1580 SBP2_DEBUG("sbp2_unit_characteristics = %x", 1517 SBP2_DEBUG("sbp2_unit_characteristics = %x",
1581 (unsigned int) unit_characteristics); 1518 (unsigned int)unit_characteristics);
1582 break; 1519 break;
1583 1520
1584 case SBP2_FIRMWARE_REVISION_KEY: 1521 case SBP2_FIRMWARE_REVISION_KEY:
@@ -1586,9 +1523,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1586 firmware_revision = kv->value.immediate; 1523 firmware_revision = kv->value.immediate;
1587 if (force_inquiry_hack) 1524 if (force_inquiry_hack)
1588 SBP2_INFO("sbp2_firmware_revision = %x", 1525 SBP2_INFO("sbp2_firmware_revision = %x",
1589 (unsigned int) firmware_revision); 1526 (unsigned int)firmware_revision);
1590 else SBP2_DEBUG("sbp2_firmware_revision = %x", 1527 else
1591 (unsigned int) firmware_revision); 1528 SBP2_DEBUG("sbp2_firmware_revision = %x",
1529 (unsigned int)firmware_revision);
1592 break; 1530 break;
1593 1531
1594 default: 1532 default:
@@ -1646,7 +1584,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
1646 scsi_id->sbp2_firmware_revision = firmware_revision; 1584 scsi_id->sbp2_firmware_revision = firmware_revision;
1647 scsi_id->workarounds = workarounds; 1585 scsi_id->workarounds = workarounds;
1648 if (ud->flags & UNIT_DIRECTORY_HAS_LUN) 1586 if (ud->flags & UNIT_DIRECTORY_HAS_LUN)
1649 scsi_id->sbp2_device_type_and_lun = ud->lun; 1587 scsi_id->sbp2_lun = ORB_SET_LUN(ud->lun);
1650 } 1588 }
1651} 1589}
1652 1590
@@ -1666,8 +1604,9 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
1666 SBP2_DEBUG("sbp2_max_speed_and_size"); 1604 SBP2_DEBUG("sbp2_max_speed_and_size");
1667 1605
1668 /* Initial setting comes from the hosts speed map */ 1606 /* Initial setting comes from the hosts speed map */
1669 scsi_id->speed_code = hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 1607 scsi_id->speed_code =
1670 + NODEID_TO_NODE(scsi_id->ne->nodeid)]; 1608 hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 +
1609 NODEID_TO_NODE(scsi_id->ne->nodeid)];
1671 1610
1672 /* Bump down our speed if the user requested it */ 1611 /* Bump down our speed if the user requested it */
1673 if (scsi_id->speed_code > max_speed) { 1612 if (scsi_id->speed_code > max_speed) {
@@ -1678,15 +1617,16 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id)
1678 1617
1679 /* Payload size is the lesser of what our speed supports and what 1618 /* Payload size is the lesser of what our speed supports and what
1680 * our host supports. */ 1619 * our host supports. */
1681 scsi_id->max_payload_size = min(sbp2_speedto_max_payload[scsi_id->speed_code], 1620 scsi_id->max_payload_size =
1682 (u8)(hi->host->csr.max_rec - 1)); 1621 min(sbp2_speedto_max_payload[scsi_id->speed_code],
1622 (u8) (hi->host->csr.max_rec - 1));
1683 1623
1684 HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", 1624 HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]",
1685 NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid), 1625 NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid),
1686 hpsb_speedto_str[scsi_id->speed_code], 1626 hpsb_speedto_str[scsi_id->speed_code],
1687 1 << ((u32)scsi_id->max_payload_size + 2)); 1627 1 << ((u32) scsi_id->max_payload_size + 2));
1688 1628
1689 return(0); 1629 return 0;
1690} 1630}
1691 1631
1692/* 1632/*
@@ -1721,30 +1661,187 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait)
1721 */ 1661 */
1722 scsi_id->last_orb = NULL; 1662 scsi_id->last_orb = NULL;
1723 1663
1724 return(0); 1664 return 0;
1665}
1666
1667static void sbp2_prep_command_orb_sg(struct sbp2_command_orb *orb,
1668 struct sbp2scsi_host_info *hi,
1669 struct sbp2_command_info *command,
1670 unsigned int scsi_use_sg,
1671 struct scatterlist *sgpnt,
1672 u32 orb_direction,
1673 enum dma_data_direction dma_dir)
1674{
1675 command->dma_dir = dma_dir;
1676 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1677 orb->misc |= ORB_SET_DIRECTION(orb_direction);
1678
1679 /* Special case if only one element (and less than 64KB in size) */
1680 if ((scsi_use_sg == 1) &&
1681 (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) {
1682
1683 SBP2_DEBUG("Only one s/g element");
1684 command->dma_size = sgpnt[0].length;
1685 command->dma_type = CMD_DMA_PAGE;
1686 command->cmd_dma = pci_map_page(hi->host->pdev,
1687 sgpnt[0].page,
1688 sgpnt[0].offset,
1689 command->dma_size,
1690 command->dma_dir);
1691 SBP2_DMA_ALLOC("single page scatter element");
1692
1693 orb->data_descriptor_lo = command->cmd_dma;
1694 orb->misc |= ORB_SET_DATA_SIZE(command->dma_size);
1695
1696 } else {
1697 struct sbp2_unrestricted_page_table *sg_element =
1698 &command->scatter_gather_element[0];
1699 u32 sg_count, sg_len;
1700 dma_addr_t sg_addr;
1701 int i, count = pci_map_sg(hi->host->pdev, sgpnt, scsi_use_sg,
1702 dma_dir);
1703
1704 SBP2_DMA_ALLOC("scatter list");
1705
1706 command->dma_size = scsi_use_sg;
1707 command->sge_buffer = sgpnt;
1708
1709 /* use page tables (s/g) */
1710 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1711 orb->data_descriptor_lo = command->sge_dma;
1712
1713 /*
1714 * Loop through and fill out our sbp-2 page tables
1715 * (and split up anything too large)
1716 */
1717 for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) {
1718 sg_len = sg_dma_len(sgpnt);
1719 sg_addr = sg_dma_address(sgpnt);
1720 while (sg_len) {
1721 sg_element[sg_count].segment_base_lo = sg_addr;
1722 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
1723 sg_element[sg_count].length_segment_base_hi =
1724 PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH);
1725 sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH;
1726 sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH;
1727 } else {
1728 sg_element[sg_count].length_segment_base_hi =
1729 PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len);
1730 sg_len = 0;
1731 }
1732 sg_count++;
1733 }
1734 }
1735
1736 /* Number of page table (s/g) elements */
1737 orb->misc |= ORB_SET_DATA_SIZE(sg_count);
1738
1739 sbp2util_packet_dump(sg_element,
1740 (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
1741 "sbp2 s/g list", command->sge_dma);
1742
1743 /* Byte swap page tables if necessary */
1744 sbp2util_cpu_to_be32_buffer(sg_element,
1745 (sizeof(struct sbp2_unrestricted_page_table)) *
1746 sg_count);
1747 }
1748}
1749
1750static void sbp2_prep_command_orb_no_sg(struct sbp2_command_orb *orb,
1751 struct sbp2scsi_host_info *hi,
1752 struct sbp2_command_info *command,
1753 struct scatterlist *sgpnt,
1754 u32 orb_direction,
1755 unsigned int scsi_request_bufflen,
1756 void *scsi_request_buffer,
1757 enum dma_data_direction dma_dir)
1758{
1759 command->dma_dir = dma_dir;
1760 command->dma_size = scsi_request_bufflen;
1761 command->dma_type = CMD_DMA_SINGLE;
1762 command->cmd_dma = pci_map_single(hi->host->pdev, scsi_request_buffer,
1763 command->dma_size, command->dma_dir);
1764 orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1765 orb->misc |= ORB_SET_DIRECTION(orb_direction);
1766
1767 SBP2_DMA_ALLOC("single bulk");
1768
1769 /*
1770 * Handle case where we get a command w/o s/g enabled (but
1771 * check for transfers larger than 64K)
1772 */
1773 if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) {
1774
1775 orb->data_descriptor_lo = command->cmd_dma;
1776 orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen);
1777
1778 } else {
1779 struct sbp2_unrestricted_page_table *sg_element =
1780 &command->scatter_gather_element[0];
1781 u32 sg_count, sg_len;
1782 dma_addr_t sg_addr;
1783
1784 /*
1785 * Need to turn this into page tables, since the
1786 * buffer is too large.
1787 */
1788 orb->data_descriptor_lo = command->sge_dma;
1789
1790 /* Use page tables (s/g) */
1791 orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1792
1793 /*
1794 * fill out our sbp-2 page tables (and split up
1795 * the large buffer)
1796 */
1797 sg_count = 0;
1798 sg_len = scsi_request_bufflen;
1799 sg_addr = command->cmd_dma;
1800 while (sg_len) {
1801 sg_element[sg_count].segment_base_lo = sg_addr;
1802 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
1803 sg_element[sg_count].length_segment_base_hi =
1804 PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH);
1805 sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH;
1806 sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH;
1807 } else {
1808 sg_element[sg_count].length_segment_base_hi =
1809 PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len);
1810 sg_len = 0;
1811 }
1812 sg_count++;
1813 }
1814
1815 /* Number of page table (s/g) elements */
1816 orb->misc |= ORB_SET_DATA_SIZE(sg_count);
1817
1818 sbp2util_packet_dump(sg_element,
1819 (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
1820 "sbp2 s/g list", command->sge_dma);
1821
1822 /* Byte swap page tables if necessary */
1823 sbp2util_cpu_to_be32_buffer(sg_element,
1824 (sizeof(struct sbp2_unrestricted_page_table)) *
1825 sg_count);
1826 }
1725} 1827}
1726 1828
1727/* 1829/*
1728 * This function is called to create the actual command orb and s/g list 1830 * This function is called to create the actual command orb and s/g list
1729 * out of the scsi command itself. 1831 * out of the scsi command itself.
1730 */ 1832 */
1731static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, 1833static void sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1732 struct sbp2_command_info *command, 1834 struct sbp2_command_info *command,
1733 unchar *scsi_cmd, 1835 unchar *scsi_cmd,
1734 unsigned int scsi_use_sg, 1836 unsigned int scsi_use_sg,
1735 unsigned int scsi_request_bufflen, 1837 unsigned int scsi_request_bufflen,
1736 void *scsi_request_buffer, 1838 void *scsi_request_buffer,
1737 enum dma_data_direction dma_dir) 1839 enum dma_data_direction dma_dir)
1738
1739{ 1840{
1740 struct sbp2scsi_host_info *hi = scsi_id->hi; 1841 struct sbp2scsi_host_info *hi = scsi_id->hi;
1741 struct scatterlist *sgpnt = (struct scatterlist *) scsi_request_buffer; 1842 struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer;
1742 struct sbp2_command_orb *command_orb = &command->command_orb; 1843 struct sbp2_command_orb *command_orb = &command->command_orb;
1743 struct sbp2_unrestricted_page_table *scatter_gather_element = 1844 u32 orb_direction;
1744 &command->scatter_gather_element[0];
1745 u32 sg_count, sg_len, orb_direction;
1746 dma_addr_t sg_addr;
1747 int i;
1748 1845
1749 /* 1846 /*
1750 * Set-up our command ORB.. 1847 * Set-up our command ORB..
@@ -1758,222 +1855,42 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
1758 command_orb->next_ORB_lo = 0x0; 1855 command_orb->next_ORB_lo = 0x0;
1759 command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); 1856 command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size);
1760 command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); 1857 command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code);
1761 command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ 1858 command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */
1762 1859
1763 /* 1860 if (dma_dir == DMA_NONE)
1764 * Get the direction of the transfer. If the direction is unknown, then use our 1861 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
1765 * goofy table as a back-up. 1862 else if (dma_dir == DMA_TO_DEVICE && scsi_request_bufflen)
1766 */ 1863 orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA;
1767 switch (dma_dir) { 1864 else if (dma_dir == DMA_FROM_DEVICE && scsi_request_bufflen)
1768 case DMA_NONE: 1865 orb_direction = ORB_DIRECTION_READ_FROM_MEDIA;
1769 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; 1866 else {
1770 break; 1867 SBP2_WARN("Falling back to DMA_NONE");
1771 case DMA_TO_DEVICE: 1868 orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER;
1772 orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA;
1773 break;
1774 case DMA_FROM_DEVICE:
1775 orb_direction = ORB_DIRECTION_READ_FROM_MEDIA;
1776 break;
1777 case DMA_BIDIRECTIONAL:
1778 default:
1779 SBP2_ERR("SCSI data transfer direction not specified. "
1780 "Update the SBP2 direction table in sbp2.h if "
1781 "necessary for your application");
1782 __scsi_print_command(scsi_cmd);
1783 orb_direction = sbp2scsi_direction_table[*scsi_cmd];
1784 break;
1785 } 1869 }
1786 1870
1787 /* 1871 /* Set-up our pagetable stuff */
1788 * Set-up our pagetable stuff... unfortunately, this has become
1789 * messier than I'd like. Need to clean this up a bit. ;-)
1790 */
1791 if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) { 1872 if (orb_direction == ORB_DIRECTION_NO_DATA_TRANSFER) {
1792
1793 SBP2_DEBUG("No data transfer"); 1873 SBP2_DEBUG("No data transfer");
1794
1795 /*
1796 * Handle no data transfer
1797 */
1798 command_orb->data_descriptor_hi = 0x0; 1874 command_orb->data_descriptor_hi = 0x0;
1799 command_orb->data_descriptor_lo = 0x0; 1875 command_orb->data_descriptor_lo = 0x0;
1800 command_orb->misc |= ORB_SET_DIRECTION(1); 1876 command_orb->misc |= ORB_SET_DIRECTION(1);
1801
1802 } else if (scsi_use_sg) { 1877 } else if (scsi_use_sg) {
1803
1804 SBP2_DEBUG("Use scatter/gather"); 1878 SBP2_DEBUG("Use scatter/gather");
1805 1879 sbp2_prep_command_orb_sg(command_orb, hi, command, scsi_use_sg,
1806 /* 1880 sgpnt, orb_direction, dma_dir);
1807 * Special case if only one element (and less than 64KB in size)
1808 */
1809 if ((scsi_use_sg == 1) && (sgpnt[0].length <= SBP2_MAX_SG_ELEMENT_LENGTH)) {
1810
1811 SBP2_DEBUG("Only one s/g element");
1812 command->dma_dir = dma_dir;
1813 command->dma_size = sgpnt[0].length;
1814 command->dma_type = CMD_DMA_PAGE;
1815 command->cmd_dma = pci_map_page(hi->host->pdev,
1816 sgpnt[0].page,
1817 sgpnt[0].offset,
1818 command->dma_size,
1819 command->dma_dir);
1820 SBP2_DMA_ALLOC("single page scatter element");
1821
1822 command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1823 command_orb->data_descriptor_lo = command->cmd_dma;
1824 command_orb->misc |= ORB_SET_DATA_SIZE(command->dma_size);
1825 command_orb->misc |= ORB_SET_DIRECTION(orb_direction);
1826
1827 } else {
1828 int count = pci_map_sg(hi->host->pdev, sgpnt, scsi_use_sg, dma_dir);
1829 SBP2_DMA_ALLOC("scatter list");
1830
1831 command->dma_size = scsi_use_sg;
1832 command->dma_dir = dma_dir;
1833 command->sge_buffer = sgpnt;
1834
1835 /* use page tables (s/g) */
1836 command_orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1837 command_orb->misc |= ORB_SET_DIRECTION(orb_direction);
1838 command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1839 command_orb->data_descriptor_lo = command->sge_dma;
1840
1841 /*
1842 * Loop through and fill out our sbp-2 page tables
1843 * (and split up anything too large)
1844 */
1845 for (i = 0, sg_count = 0 ; i < count; i++, sgpnt++) {
1846 sg_len = sg_dma_len(sgpnt);
1847 sg_addr = sg_dma_address(sgpnt);
1848 while (sg_len) {
1849 scatter_gather_element[sg_count].segment_base_lo = sg_addr;
1850 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
1851 scatter_gather_element[sg_count].length_segment_base_hi =
1852 PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH);
1853 sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH;
1854 sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH;
1855 } else {
1856 scatter_gather_element[sg_count].length_segment_base_hi =
1857 PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len);
1858 sg_len = 0;
1859 }
1860 sg_count++;
1861 }
1862 }
1863
1864 /* Number of page table (s/g) elements */
1865 command_orb->misc |= ORB_SET_DATA_SIZE(sg_count);
1866
1867 sbp2util_packet_dump(scatter_gather_element,
1868 (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
1869 "sbp2 s/g list", command->sge_dma);
1870
1871 /*
1872 * Byte swap page tables if necessary
1873 */
1874 sbp2util_cpu_to_be32_buffer(scatter_gather_element,
1875 (sizeof(struct sbp2_unrestricted_page_table)) *
1876 sg_count);
1877
1878 }
1879
1880 } else { 1881 } else {
1881
1882 SBP2_DEBUG("No scatter/gather"); 1882 SBP2_DEBUG("No scatter/gather");
1883 1883 sbp2_prep_command_orb_no_sg(command_orb, hi, command, sgpnt,
1884 command->dma_dir = dma_dir; 1884 orb_direction, scsi_request_bufflen,
1885 command->dma_size = scsi_request_bufflen; 1885 scsi_request_buffer, dma_dir);
1886 command->dma_type = CMD_DMA_SINGLE;
1887 command->cmd_dma = pci_map_single (hi->host->pdev, scsi_request_buffer,
1888 command->dma_size,
1889 command->dma_dir);
1890 SBP2_DMA_ALLOC("single bulk");
1891
1892 /*
1893 * Handle case where we get a command w/o s/g enabled (but
1894 * check for transfers larger than 64K)
1895 */
1896 if (scsi_request_bufflen <= SBP2_MAX_SG_ELEMENT_LENGTH) {
1897
1898 command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1899 command_orb->data_descriptor_lo = command->cmd_dma;
1900 command_orb->misc |= ORB_SET_DATA_SIZE(scsi_request_bufflen);
1901 command_orb->misc |= ORB_SET_DIRECTION(orb_direction);
1902
1903 /*
1904 * Sanity, in case our direction table is not
1905 * up-to-date
1906 */
1907 if (!scsi_request_bufflen) {
1908 command_orb->data_descriptor_hi = 0x0;
1909 command_orb->data_descriptor_lo = 0x0;
1910 command_orb->misc |= ORB_SET_DIRECTION(1);
1911 }
1912
1913 } else {
1914 /*
1915 * Need to turn this into page tables, since the
1916 * buffer is too large.
1917 */
1918 command_orb->data_descriptor_hi = ORB_SET_NODE_ID(hi->host->node_id);
1919 command_orb->data_descriptor_lo = command->sge_dma;
1920
1921 /* Use page tables (s/g) */
1922 command_orb->misc |= ORB_SET_PAGE_TABLE_PRESENT(0x1);
1923 command_orb->misc |= ORB_SET_DIRECTION(orb_direction);
1924
1925 /*
1926 * fill out our sbp-2 page tables (and split up
1927 * the large buffer)
1928 */
1929 sg_count = 0;
1930 sg_len = scsi_request_bufflen;
1931 sg_addr = command->cmd_dma;
1932 while (sg_len) {
1933 scatter_gather_element[sg_count].segment_base_lo = sg_addr;
1934 if (sg_len > SBP2_MAX_SG_ELEMENT_LENGTH) {
1935 scatter_gather_element[sg_count].length_segment_base_hi =
1936 PAGE_TABLE_SET_SEGMENT_LENGTH(SBP2_MAX_SG_ELEMENT_LENGTH);
1937 sg_addr += SBP2_MAX_SG_ELEMENT_LENGTH;
1938 sg_len -= SBP2_MAX_SG_ELEMENT_LENGTH;
1939 } else {
1940 scatter_gather_element[sg_count].length_segment_base_hi =
1941 PAGE_TABLE_SET_SEGMENT_LENGTH(sg_len);
1942 sg_len = 0;
1943 }
1944 sg_count++;
1945 }
1946
1947 /* Number of page table (s/g) elements */
1948 command_orb->misc |= ORB_SET_DATA_SIZE(sg_count);
1949
1950 sbp2util_packet_dump(scatter_gather_element,
1951 (sizeof(struct sbp2_unrestricted_page_table)) * sg_count,
1952 "sbp2 s/g list", command->sge_dma);
1953
1954 /*
1955 * Byte swap page tables if necessary
1956 */
1957 sbp2util_cpu_to_be32_buffer(scatter_gather_element,
1958 (sizeof(struct sbp2_unrestricted_page_table)) *
1959 sg_count);
1960
1961 }
1962
1963 } 1886 }
1964 1887
1965 /* 1888 /* Byte swap command ORB if necessary */
1966 * Byte swap command ORB if necessary
1967 */
1968 sbp2util_cpu_to_be32_buffer(command_orb, sizeof(struct sbp2_command_orb)); 1889 sbp2util_cpu_to_be32_buffer(command_orb, sizeof(struct sbp2_command_orb));
1969 1890
1970 /* 1891 /* Put our scsi command in the command ORB */
1971 * Put our scsi command in the command ORB
1972 */
1973 memset(command_orb->cdb, 0, 12); 1892 memset(command_orb->cdb, 0, 12);
1974 memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); 1893 memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd));
1975
1976 return(0);
1977} 1894}
1978 1895
1979/* 1896/*
@@ -1989,7 +1906,7 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
1989 1906
1990 outstanding_orb_incr; 1907 outstanding_orb_incr;
1991 SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x", 1908 SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x",
1992 command_orb, global_outstanding_command_orbs); 1909 command_orb, global_outstanding_command_orbs);
1993 1910
1994 pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma, 1911 pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma,
1995 sizeof(struct sbp2_command_orb), 1912 sizeof(struct sbp2_command_orb),
@@ -2034,10 +1951,11 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2034 * both by the sbp2 device and us. 1951 * both by the sbp2 device and us.
2035 */ 1952 */
2036 scsi_id->last_orb->next_ORB_lo = 1953 scsi_id->last_orb->next_ORB_lo =
2037 cpu_to_be32(command->command_orb_dma); 1954 cpu_to_be32(command->command_orb_dma);
2038 /* Tells hardware that this pointer is valid */ 1955 /* Tells hardware that this pointer is valid */
2039 scsi_id->last_orb->next_ORB_hi = 0x0; 1956 scsi_id->last_orb->next_ORB_hi = 0x0;
2040 pci_dma_sync_single_for_device(hi->host->pdev, scsi_id->last_orb_dma, 1957 pci_dma_sync_single_for_device(hi->host->pdev,
1958 scsi_id->last_orb_dma,
2041 sizeof(struct sbp2_command_orb), 1959 sizeof(struct sbp2_command_orb),
2042 PCI_DMA_BIDIRECTIONAL); 1960 PCI_DMA_BIDIRECTIONAL);
2043 1961
@@ -2051,14 +1969,14 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
2051 1969
2052 if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) { 1970 if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) {
2053 SBP2_ERR("sbp2util_node_write_no_wait failed"); 1971 SBP2_ERR("sbp2util_node_write_no_wait failed");
2054 return(-EIO); 1972 return -EIO;
2055 } 1973 }
2056 1974
2057 scsi_id->last_orb = command_orb; 1975 scsi_id->last_orb = command_orb;
2058 scsi_id->last_orb_dma = command->command_orb_dma; 1976 scsi_id->last_orb_dma = command->command_orb_dma;
2059 1977
2060 } 1978 }
2061 return(0); 1979 return 0;
2062} 1980}
2063 1981
2064/* 1982/*
@@ -2085,7 +2003,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2085 */ 2003 */
2086 command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done); 2004 command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done);
2087 if (!command) { 2005 if (!command) {
2088 return(-EIO); 2006 return -EIO;
2089 } 2007 }
2090 2008
2091 /* 2009 /*
@@ -2106,11 +2024,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2106 sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, 2024 sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg,
2107 request_bufflen, SCpnt->request_buffer, 2025 request_bufflen, SCpnt->request_buffer,
2108 SCpnt->sc_data_direction); 2026 SCpnt->sc_data_direction);
2109 /*
2110 * Update our cdb if necessary (to handle sbp2 RBC command set
2111 * differences). This is where the command set hacks go! =)
2112 */
2113 sbp2_check_sbp2_command(scsi_id, command->command_orb.cdb);
2114 2027
2115 sbp2util_packet_dump(&command->command_orb, sizeof(struct sbp2_command_orb), 2028 sbp2util_packet_dump(&command->command_orb, sizeof(struct sbp2_command_orb),
2116 "sbp2 command orb", command->command_orb_dma); 2029 "sbp2 command orb", command->command_orb_dma);
@@ -2125,112 +2038,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
2125 */ 2038 */
2126 sbp2_link_orb_command(scsi_id, command); 2039 sbp2_link_orb_command(scsi_id, command);
2127 2040
2128 return(0); 2041 return 0;
2129}
2130
2131
2132/*
2133 * This function deals with command set differences between Linux scsi
2134 * command set and sbp2 RBC command set.
2135 */
2136static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd)
2137{
2138 unchar new_cmd[16];
2139 u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun);
2140
2141 SBP2_DEBUG("sbp2_check_sbp2_command");
2142
2143 switch (*cmd) {
2144
2145 case READ_6:
2146
2147 if (sbp2_command_conversion_device_type(device_type)) {
2148
2149 SBP2_DEBUG("Convert READ_6 to READ_10");
2150
2151 /*
2152 * Need to turn read_6 into read_10
2153 */
2154 new_cmd[0] = 0x28;
2155 new_cmd[1] = (cmd[1] & 0xe0);
2156 new_cmd[2] = 0x0;
2157 new_cmd[3] = (cmd[1] & 0x1f);
2158 new_cmd[4] = cmd[2];
2159 new_cmd[5] = cmd[3];
2160 new_cmd[6] = 0x0;
2161 new_cmd[7] = 0x0;
2162 new_cmd[8] = cmd[4];
2163 new_cmd[9] = cmd[5];
2164
2165 memcpy(cmd, new_cmd, 10);
2166
2167 }
2168
2169 break;
2170
2171 case WRITE_6:
2172
2173 if (sbp2_command_conversion_device_type(device_type)) {
2174
2175 SBP2_DEBUG("Convert WRITE_6 to WRITE_10");
2176
2177 /*
2178 * Need to turn write_6 into write_10
2179 */
2180 new_cmd[0] = 0x2a;
2181 new_cmd[1] = (cmd[1] & 0xe0);
2182 new_cmd[2] = 0x0;
2183 new_cmd[3] = (cmd[1] & 0x1f);
2184 new_cmd[4] = cmd[2];
2185 new_cmd[5] = cmd[3];
2186 new_cmd[6] = 0x0;
2187 new_cmd[7] = 0x0;
2188 new_cmd[8] = cmd[4];
2189 new_cmd[9] = cmd[5];
2190
2191 memcpy(cmd, new_cmd, 10);
2192
2193 }
2194
2195 break;
2196
2197 case MODE_SENSE:
2198
2199 if (sbp2_command_conversion_device_type(device_type)) {
2200
2201 SBP2_DEBUG("Convert MODE_SENSE_6 to MODE_SENSE_10");
2202
2203 /*
2204 * Need to turn mode_sense_6 into mode_sense_10
2205 */
2206 new_cmd[0] = 0x5a;
2207 new_cmd[1] = cmd[1];
2208 new_cmd[2] = cmd[2];
2209 new_cmd[3] = 0x0;
2210 new_cmd[4] = 0x0;
2211 new_cmd[5] = 0x0;
2212 new_cmd[6] = 0x0;
2213 new_cmd[7] = 0x0;
2214 new_cmd[8] = cmd[4];
2215 new_cmd[9] = cmd[5];
2216
2217 memcpy(cmd, new_cmd, 10);
2218
2219 }
2220
2221 break;
2222
2223 case MODE_SELECT:
2224
2225 /*
2226 * TODO. Probably need to change mode select to 10 byte version
2227 */
2228
2229 default:
2230 break;
2231 }
2232
2233 return;
2234} 2042}
2235 2043
2236/* 2044/*
@@ -2260,80 +2068,40 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense
2260 sense_data[14] = sbp2_status[20]; 2068 sense_data[14] = sbp2_status[20];
2261 sense_data[15] = sbp2_status[21]; 2069 sense_data[15] = sbp2_status[21];
2262 2070
2263 return(sbp2_status[8] & 0x3f); /* return scsi status */ 2071 return sbp2_status[8] & 0x3f; /* return scsi status */
2264} 2072}
2265 2073
2266/* 2074/*
2267 * This function is called after a command is completed, in order to do any necessary SBP-2 2075 * This function is called after a command is completed, in order to do any necessary SBP-2
2268 * response data translations for the SCSI stack 2076 * response data translations for the SCSI stack
2269 */ 2077 */
2270static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, 2078static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
2271 struct scsi_cmnd *SCpnt) 2079 struct scsi_cmnd *SCpnt)
2272{ 2080{
2273 u8 *scsi_buf = SCpnt->request_buffer; 2081 u8 *scsi_buf = SCpnt->request_buffer;
2274 u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun);
2275 2082
2276 SBP2_DEBUG("sbp2_check_sbp2_response"); 2083 SBP2_DEBUG("sbp2_check_sbp2_response");
2277 2084
2278 switch (SCpnt->cmnd[0]) { 2085 switch (SCpnt->cmnd[0]) {
2279 2086
2280 case INQUIRY: 2087 case INQUIRY:
2281 2088 /*
2282 /* 2089 * Make sure data length is ok. Minimum length is 36 bytes
2283 * If scsi_id->sbp2_device_type_and_lun is uninitialized, then fill 2090 */
2284 * this information in from the inquiry response data. Lun is set to zero. 2091 if (scsi_buf[4] == 0) {
2285 */ 2092 scsi_buf[4] = 36 - 5;
2286 if (scsi_id->sbp2_device_type_and_lun == SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { 2093 }
2287 SBP2_DEBUG("Creating sbp2_device_type_and_lun from scsi inquiry data");
2288 scsi_id->sbp2_device_type_and_lun = (scsi_buf[0] & 0x1f) << 16;
2289 }
2290
2291 /*
2292 * Make sure data length is ok. Minimum length is 36 bytes
2293 */
2294 if (scsi_buf[4] == 0) {
2295 scsi_buf[4] = 36 - 5;
2296 }
2297
2298 /*
2299 * Check for Simple Direct Access Device and change it to TYPE_DISK
2300 */
2301 if ((scsi_buf[0] & 0x1f) == TYPE_RBC) {
2302 SBP2_DEBUG("Changing TYPE_RBC to TYPE_DISK");
2303 scsi_buf[0] &= 0xe0;
2304 }
2305
2306 /*
2307 * Fix ansi revision and response data format
2308 */
2309 scsi_buf[2] |= 2;
2310 scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2;
2311
2312 break;
2313
2314 case MODE_SENSE:
2315
2316 if (sbp2_command_conversion_device_type(device_type)) {
2317
2318 SBP2_DEBUG("Modify mode sense response (10 byte version)");
2319
2320 scsi_buf[0] = scsi_buf[1]; /* Mode data length */
2321 scsi_buf[1] = scsi_buf[2]; /* Medium type */
2322 scsi_buf[2] = scsi_buf[3]; /* Device specific parameter */
2323 scsi_buf[3] = scsi_buf[7]; /* Block descriptor length */
2324 memcpy(scsi_buf + 4, scsi_buf + 8, scsi_buf[0]);
2325 }
2326
2327 break;
2328 2094
2329 case MODE_SELECT: 2095 /*
2096 * Fix ansi revision and response data format
2097 */
2098 scsi_buf[2] |= 2;
2099 scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2;
2330 2100
2331 /* 2101 break;
2332 * TODO. Probably need to change mode select to 10 byte version
2333 */
2334 2102
2335 default: 2103 default:
2336 break; 2104 break;
2337 } 2105 }
2338 return; 2106 return;
2339} 2107}
@@ -2358,14 +2126,14 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2358 2126
2359 if (!host) { 2127 if (!host) {
2360 SBP2_ERR("host is NULL - this is bad!"); 2128 SBP2_ERR("host is NULL - this is bad!");
2361 return(RCODE_ADDRESS_ERROR); 2129 return RCODE_ADDRESS_ERROR;
2362 } 2130 }
2363 2131
2364 hi = hpsb_get_hostinfo(&sbp2_highlevel, host); 2132 hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
2365 2133
2366 if (!hi) { 2134 if (!hi) {
2367 SBP2_ERR("host info is NULL - this is bad!"); 2135 SBP2_ERR("host info is NULL - this is bad!");
2368 return(RCODE_ADDRESS_ERROR); 2136 return RCODE_ADDRESS_ERROR;
2369 } 2137 }
2370 2138
2371 /* 2139 /*
@@ -2382,7 +2150,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2382 2150
2383 if (!scsi_id) { 2151 if (!scsi_id) {
2384 SBP2_ERR("scsi_id is NULL - device is gone?"); 2152 SBP2_ERR("scsi_id is NULL - device is gone?");
2385 return(RCODE_ADDRESS_ERROR); 2153 return RCODE_ADDRESS_ERROR;
2386 } 2154 }
2387 2155
2388 /* 2156 /*
@@ -2480,10 +2248,9 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2480 SBP2_ORB_DEBUG("command orb completed"); 2248 SBP2_ORB_DEBUG("command orb completed");
2481 } 2249 }
2482 2250
2483 return(RCODE_COMPLETE); 2251 return RCODE_COMPLETE;
2484} 2252}
2485 2253
2486
2487/************************************** 2254/**************************************
2488 * SCSI interface related section 2255 * SCSI interface related section
2489 **************************************/ 2256 **************************************/
@@ -2541,6 +2308,16 @@ static int sbp2scsi_queuecommand(struct scsi_cmnd *SCpnt,
2541 } 2308 }
2542 2309
2543 /* 2310 /*
2311 * Bidirectional commands are not yet implemented,
2312 * and unknown transfer direction not handled.
2313 */
2314 if (SCpnt->sc_data_direction == DMA_BIDIRECTIONAL) {
2315 SBP2_ERR("Cannot handle DMA_BIDIRECTIONAL - rejecting command");
2316 result = DID_ERROR << 16;
2317 goto done;
2318 }
2319
2320 /*
2544 * Try and send our SCSI command 2321 * Try and send our SCSI command
2545 */ 2322 */
2546 if (sbp2_send_command(scsi_id, SCpnt, done)) { 2323 if (sbp2_send_command(scsi_id, SCpnt, done)) {
@@ -2616,55 +2393,56 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2616 * complete the command, just let it get retried at the end of the 2393 * complete the command, just let it get retried at the end of the
2617 * bus reset. 2394 * bus reset.
2618 */ 2395 */
2619 if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { 2396 if (!hpsb_node_entry_valid(scsi_id->ne)
2397 && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
2620 SBP2_ERR("Bus reset in progress - retry command later"); 2398 SBP2_ERR("Bus reset in progress - retry command later");
2621 return; 2399 return;
2622 } 2400 }
2623 2401
2624 /* 2402 /*
2625 * Switch on scsi status 2403 * Switch on scsi status
2626 */ 2404 */
2627 switch (scsi_status) { 2405 switch (scsi_status) {
2628 case SBP2_SCSI_STATUS_GOOD: 2406 case SBP2_SCSI_STATUS_GOOD:
2629 SCpnt->result = DID_OK; 2407 SCpnt->result = DID_OK;
2630 break; 2408 break;
2631 2409
2632 case SBP2_SCSI_STATUS_BUSY: 2410 case SBP2_SCSI_STATUS_BUSY:
2633 SBP2_ERR("SBP2_SCSI_STATUS_BUSY"); 2411 SBP2_ERR("SBP2_SCSI_STATUS_BUSY");
2634 SCpnt->result = DID_BUS_BUSY << 16; 2412 SCpnt->result = DID_BUS_BUSY << 16;
2635 break; 2413 break;
2636 2414
2637 case SBP2_SCSI_STATUS_CHECK_CONDITION: 2415 case SBP2_SCSI_STATUS_CHECK_CONDITION:
2638 SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); 2416 SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION");
2639 SCpnt->result = CHECK_CONDITION << 1; 2417 SCpnt->result = CHECK_CONDITION << 1;
2640 2418
2641 /* 2419 /*
2642 * Debug stuff 2420 * Debug stuff
2643 */ 2421 */
2644#if CONFIG_IEEE1394_SBP2_DEBUG >= 1 2422#if CONFIG_IEEE1394_SBP2_DEBUG >= 1
2645 scsi_print_command(SCpnt); 2423 scsi_print_command(SCpnt);
2646 scsi_print_sense("bh", SCpnt); 2424 scsi_print_sense("bh", SCpnt);
2647#endif 2425#endif
2648 2426
2649 break; 2427 break;
2650 2428
2651 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: 2429 case SBP2_SCSI_STATUS_SELECTION_TIMEOUT:
2652 SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT"); 2430 SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT");
2653 SCpnt->result = DID_NO_CONNECT << 16; 2431 SCpnt->result = DID_NO_CONNECT << 16;
2654 scsi_print_command(SCpnt); 2432 scsi_print_command(SCpnt);
2655 break; 2433 break;
2656 2434
2657 case SBP2_SCSI_STATUS_CONDITION_MET: 2435 case SBP2_SCSI_STATUS_CONDITION_MET:
2658 case SBP2_SCSI_STATUS_RESERVATION_CONFLICT: 2436 case SBP2_SCSI_STATUS_RESERVATION_CONFLICT:
2659 case SBP2_SCSI_STATUS_COMMAND_TERMINATED: 2437 case SBP2_SCSI_STATUS_COMMAND_TERMINATED:
2660 SBP2_ERR("Bad SCSI status = %x", scsi_status); 2438 SBP2_ERR("Bad SCSI status = %x", scsi_status);
2661 SCpnt->result = DID_ERROR << 16; 2439 SCpnt->result = DID_ERROR << 16;
2662 scsi_print_command(SCpnt); 2440 scsi_print_command(SCpnt);
2663 break; 2441 break;
2664 2442
2665 default: 2443 default:
2666 SBP2_ERR("Unsupported SCSI status = %x", scsi_status); 2444 SBP2_ERR("Unsupported SCSI status = %x", scsi_status);
2667 SCpnt->result = DID_ERROR << 16; 2445 SCpnt->result = DID_ERROR << 16;
2668 } 2446 }
2669 2447
2670 /* 2448 /*
@@ -2678,7 +2456,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2678 * If a bus reset is in progress and there was an error, complete 2456 * If a bus reset is in progress and there was an error, complete
2679 * the command as busy so that it will get retried. 2457 * the command as busy so that it will get retried.
2680 */ 2458 */
2681 if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { 2459 if (!hpsb_node_entry_valid(scsi_id->ne)
2460 && (scsi_status != SBP2_SCSI_STATUS_GOOD)) {
2682 SBP2_ERR("Completing command with busy (bus reset)"); 2461 SBP2_ERR("Completing command with busy (bus reset)");
2683 SCpnt->result = DID_BUS_BUSY << 16; 2462 SCpnt->result = DID_BUS_BUSY << 16;
2684 } 2463 }
@@ -2699,31 +2478,29 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id,
2699 /* 2478 /*
2700 * Tell scsi stack that we're done with this command 2479 * Tell scsi stack that we're done with this command
2701 */ 2480 */
2702 done (SCpnt); 2481 done(SCpnt);
2703} 2482}
2704 2483
2705
2706static int sbp2scsi_slave_alloc(struct scsi_device *sdev) 2484static int sbp2scsi_slave_alloc(struct scsi_device *sdev)
2707{ 2485{
2708 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; 2486 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev;
2709 return 0; 2487 return 0;
2710} 2488}
2711 2489
2712
2713static int sbp2scsi_slave_configure(struct scsi_device *sdev) 2490static int sbp2scsi_slave_configure(struct scsi_device *sdev)
2714{ 2491{
2715 blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); 2492 blk_queue_dma_alignment(sdev->request_queue, (512 - 1));
2493 sdev->use_10_for_rw = 1;
2494 sdev->use_10_for_ms = 1;
2716 return 0; 2495 return 0;
2717} 2496}
2718 2497
2719
2720static void sbp2scsi_slave_destroy(struct scsi_device *sdev) 2498static void sbp2scsi_slave_destroy(struct scsi_device *sdev)
2721{ 2499{
2722 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL; 2500 ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL;
2723 return; 2501 return;
2724} 2502}
2725 2503
2726
2727/* 2504/*
2728 * Called by scsi stack when something has really gone wrong. Usually 2505 * Called by scsi stack when something has really gone wrong. Usually
2729 * called when a command has timed-out for some reason. 2506 * called when a command has timed-out for some reason.
@@ -2769,7 +2546,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt)
2769 sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY); 2546 sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY);
2770 } 2547 }
2771 2548
2772 return(SUCCESS); 2549 return SUCCESS;
2773} 2550}
2774 2551
2775/* 2552/*
@@ -2779,28 +2556,20 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt)
2779{ 2556{
2780 struct scsi_id_instance_data *scsi_id = 2557 struct scsi_id_instance_data *scsi_id =
2781 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0]; 2558 (struct scsi_id_instance_data *)SCpnt->device->host->hostdata[0];
2782 unsigned long flags;
2783 2559
2784 SBP2_ERR("reset requested"); 2560 SBP2_ERR("reset requested");
2785 2561
2786 spin_lock_irqsave(SCpnt->device->host->host_lock, flags);
2787
2788 if (sbp2util_node_is_available(scsi_id)) { 2562 if (sbp2util_node_is_available(scsi_id)) {
2789 SBP2_ERR("Generating sbp2 fetch agent reset"); 2563 SBP2_ERR("Generating sbp2 fetch agent reset");
2790 sbp2_agent_reset(scsi_id, 0); 2564 sbp2_agent_reset(scsi_id, 0);
2791 } 2565 }
2792 2566
2793 spin_unlock_irqrestore(SCpnt->device->host->host_lock, flags);
2794
2795 return SUCCESS; 2567 return SUCCESS;
2796} 2568}
2797 2569
2798static const char *sbp2scsi_info (struct Scsi_Host *host) 2570static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev,
2799{ 2571 struct device_attribute *attr,
2800 return "SCSI emulation for IEEE-1394 SBP-2 Devices"; 2572 char *buf)
2801}
2802
2803static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, char *buf)
2804{ 2573{
2805 struct scsi_device *sdev; 2574 struct scsi_device *sdev;
2806 struct scsi_id_instance_data *scsi_id; 2575 struct scsi_id_instance_data *scsi_id;
@@ -2812,10 +2581,7 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_att
2812 if (!(scsi_id = (struct scsi_id_instance_data *)sdev->host->hostdata[0])) 2581 if (!(scsi_id = (struct scsi_id_instance_data *)sdev->host->hostdata[0]))
2813 return 0; 2582 return 0;
2814 2583
2815 if (scsi_id->sbp2_device_type_and_lun == SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) 2584 lun = ORB_SET_LUN(scsi_id->sbp2_lun);
2816 lun = 0;
2817 else
2818 lun = ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun);
2819 2585
2820 return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid, 2586 return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid,
2821 scsi_id->ud->id, lun); 2587 scsi_id->ud->id, lun);
@@ -2837,12 +2603,9 @@ static struct scsi_host_template scsi_driver_template = {
2837 .module = THIS_MODULE, 2603 .module = THIS_MODULE,
2838 .name = "SBP-2 IEEE-1394", 2604 .name = "SBP-2 IEEE-1394",
2839 .proc_name = SBP2_DEVICE_NAME, 2605 .proc_name = SBP2_DEVICE_NAME,
2840 .info = sbp2scsi_info,
2841 .queuecommand = sbp2scsi_queuecommand, 2606 .queuecommand = sbp2scsi_queuecommand,
2842 .eh_abort_handler = sbp2scsi_abort, 2607 .eh_abort_handler = sbp2scsi_abort,
2843 .eh_device_reset_handler = sbp2scsi_reset, 2608 .eh_device_reset_handler = sbp2scsi_reset,
2844 .eh_bus_reset_handler = sbp2scsi_reset,
2845 .eh_host_reset_handler = sbp2scsi_reset,
2846 .slave_alloc = sbp2scsi_slave_alloc, 2609 .slave_alloc = sbp2scsi_slave_alloc,
2847 .slave_configure = sbp2scsi_slave_configure, 2610 .slave_configure = sbp2scsi_slave_configure,
2848 .slave_destroy = sbp2scsi_slave_destroy, 2611 .slave_destroy = sbp2scsi_slave_destroy,
@@ -2861,8 +2624,6 @@ static int sbp2_module_init(void)
2861 2624
2862 SBP2_DEBUG("sbp2_module_init"); 2625 SBP2_DEBUG("sbp2_module_init");
2863 2626
2864 printk(KERN_INFO "sbp2: %s\n", version);
2865
2866 /* Module load debug option to force one command at a time (serializing I/O) */ 2627 /* Module load debug option to force one command at a time (serializing I/O) */
2867 if (serialize_io) { 2628 if (serialize_io) {
2868 SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)"); 2629 SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)");
@@ -2874,7 +2635,6 @@ static int sbp2_module_init(void)
2874 /* Set max sectors (module load option). Default is 255 sectors. */ 2635 /* Set max sectors (module load option). Default is 255 sectors. */
2875 scsi_driver_template.max_sectors = max_sectors; 2636 scsi_driver_template.max_sectors = max_sectors;
2876 2637
2877
2878 /* Register our high level driver with 1394 stack */ 2638 /* Register our high level driver with 1394 stack */
2879 hpsb_register_highlevel(&sbp2_highlevel); 2639 hpsb_register_highlevel(&sbp2_highlevel);
2880 2640
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h
index cd425be74841..900ea1d25e71 100644
--- a/drivers/ieee1394/sbp2.h
+++ b/drivers/ieee1394/sbp2.h
@@ -119,8 +119,8 @@ struct sbp2_query_logins_response {
119struct sbp2_reconnect_orb { 119struct sbp2_reconnect_orb {
120 u32 reserved1; 120 u32 reserved1;
121 u32 reserved2; 121 u32 reserved2;
122 u32 reserved3; 122 u32 reserved3;
123 u32 reserved4; 123 u32 reserved4;
124 u32 login_ID_misc; 124 u32 login_ID_misc;
125 u32 reserved5; 125 u32 reserved5;
126 u32 status_FIFO_hi; 126 u32 status_FIFO_hi;
@@ -130,8 +130,8 @@ struct sbp2_reconnect_orb {
130struct sbp2_logout_orb { 130struct sbp2_logout_orb {
131 u32 reserved1; 131 u32 reserved1;
132 u32 reserved2; 132 u32 reserved2;
133 u32 reserved3; 133 u32 reserved3;
134 u32 reserved4; 134 u32 reserved4;
135 u32 login_ID_misc; 135 u32 login_ID_misc;
136 u32 reserved5; 136 u32 reserved5;
137 u32 status_FIFO_hi; 137 u32 status_FIFO_hi;
@@ -188,7 +188,7 @@ struct sbp2_unrestricted_page_table {
188struct sbp2_status_block { 188struct sbp2_status_block {
189 u32 ORB_offset_hi_misc; 189 u32 ORB_offset_hi_misc;
190 u32 ORB_offset_lo; 190 u32 ORB_offset_lo;
191 u8 command_set_dependent[24]; 191 u8 command_set_dependent[24];
192}; 192};
193 193
194/* 194/*
@@ -211,7 +211,7 @@ struct sbp2_status_block {
211 * specified for write posting, where the ohci controller will 211 * specified for write posting, where the ohci controller will
212 * automatically send an ack_complete when the status is written by the 212 * automatically send an ack_complete when the status is written by the
213 * sbp2 device... saving a split transaction. =) 213 * sbp2 device... saving a split transaction. =)
214 */ 214 */
215#define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL 215#define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL
216#define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe 216#define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe
217#define SBP2_STATUS_FIFO_ADDRESS_LO 0x0 217#define SBP2_STATUS_FIFO_ADDRESS_LO 0x0
@@ -229,9 +229,6 @@ struct sbp2_status_block {
229#define SBP2_DEVICE_TYPE_AND_LUN_KEY 0x14 229#define SBP2_DEVICE_TYPE_AND_LUN_KEY 0x14
230#define SBP2_FIRMWARE_REVISION_KEY 0x3c 230#define SBP2_FIRMWARE_REVISION_KEY 0x3c
231 231
232#define SBP2_DEVICE_TYPE(q) (((q) >> 16) & 0x1f)
233#define SBP2_DEVICE_LUN(q) ((q) & 0xffff)
234
235#define SBP2_AGENT_STATE_OFFSET 0x00ULL 232#define SBP2_AGENT_STATE_OFFSET 0x00ULL
236#define SBP2_AGENT_RESET_OFFSET 0x04ULL 233#define SBP2_AGENT_RESET_OFFSET 0x04ULL
237#define SBP2_ORB_POINTER_OFFSET 0x08ULL 234#define SBP2_ORB_POINTER_OFFSET 0x08ULL
@@ -256,8 +253,6 @@ struct sbp2_status_block {
256 */ 253 */
257#define SBP2_128KB_BROKEN_FIRMWARE 0xa0b800 254#define SBP2_128KB_BROKEN_FIRMWARE 0xa0b800
258 255
259#define SBP2_DEVICE_TYPE_LUN_UNINITIALIZED 0xffffffff
260
261/* 256/*
262 * SCSI specific stuff 257 * SCSI specific stuff
263 */ 258 */
@@ -265,45 +260,7 @@ struct sbp2_status_block {
265#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000 260#define SBP2_MAX_SG_ELEMENT_LENGTH 0xf000
266#define SBP2_MAX_UDS_PER_NODE 16 /* Maximum scsi devices per node */ 261#define SBP2_MAX_UDS_PER_NODE 16 /* Maximum scsi devices per node */
267#define SBP2_MAX_SECTORS 255 /* Max sectors supported */ 262#define SBP2_MAX_SECTORS 255 /* Max sectors supported */
268 263#define SBP2_MAX_CMDS 8 /* This should be safe */
269/*
270 * SCSI direction table...
271 * (now used as a back-up in case the direction passed down from above is "unknown")
272 *
273 * DIN = IN data direction
274 * DOU = OUT data direction
275 * DNO = No data transfer
276 * DUN = Unknown data direction
277 *
278 * Opcode 0xec (Teac specific "opc execute") possibly should be DNO,
279 * but we'll change it when somebody reports a problem with this.
280 */
281#define DIN ORB_DIRECTION_READ_FROM_MEDIA
282#define DOU ORB_DIRECTION_WRITE_TO_MEDIA
283#define DNO ORB_DIRECTION_NO_DATA_TRANSFER
284#define DUN DIN
285
286static unchar sbp2scsi_direction_table[0x100] = {
287 DNO,DNO,DIN,DIN,DOU,DIN,DIN,DOU,DIN,DUN,DOU,DOU,DUN,DUN,DUN,DIN,
288 DNO,DIN,DIN,DOU,DIN,DOU,DNO,DNO,DOU,DNO,DIN,DNO,DIN,DOU,DNO,DUN,
289 DIN,DUN,DIN,DIN,DOU,DIN,DUN,DUN,DIN,DIN,DOU,DNO,DUN,DIN,DOU,DOU,
290 DOU,DOU,DOU,DNO,DIN,DNO,DNO,DIN,DOU,DOU,DOU,DOU,DIN,DOU,DIN,DOU,
291 DOU,DOU,DIN,DIN,DIN,DNO,DIN,DNO,DNO,DNO,DUN,DNO,DOU,DIN,DNO,DUN,
292 DUN,DIN,DIN,DNO,DNO,DOU,DUN,DUN,DNO,DIN,DIN,DNO,DIN,DOU,DUN,DUN,
293 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
294 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
295 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
296 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
297 DUN,DNO,DOU,DOU,DIN,DNO,DNO,DNO,DIN,DNO,DOU,DUN,DNO,DIN,DOU,DOU,
298 DOU,DOU,DOU,DNO,DUN,DIN,DOU,DIN,DIN,DIN,DNO,DNO,DNO,DIN,DIN,DUN,
299 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
300 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,
301 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DOU,DUN,DUN,DUN,DUN,DUN,
302 DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN,DUN
303};
304
305/* This should be safe */
306#define SBP2_MAX_CMDS 8
307 264
308/* This is the two dma types we use for cmd_dma below */ 265/* This is the two dma types we use for cmd_dma below */
309enum cmd_dma_types { 266enum cmd_dma_types {
@@ -338,10 +295,8 @@ struct sbp2_command_info {
338#define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1 295#define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1
339#define SBP2_BREAKAGE_INQUIRY_HACK 0x2 296#define SBP2_BREAKAGE_INQUIRY_HACK 0x2
340 297
341
342struct sbp2scsi_host_info; 298struct sbp2scsi_host_info;
343 299
344
345/* 300/*
346 * Information needed on a per scsi id basis (one for each sbp2 device) 301 * Information needed on a per scsi id basis (one for each sbp2 device)
347 */ 302 */
@@ -379,7 +334,7 @@ struct scsi_id_instance_data {
379 u32 sbp2_command_set_spec_id; 334 u32 sbp2_command_set_spec_id;
380 u32 sbp2_command_set; 335 u32 sbp2_command_set;
381 u32 sbp2_unit_characteristics; 336 u32 sbp2_unit_characteristics;
382 u32 sbp2_device_type_and_lun; 337 u32 sbp2_lun;
383 u32 sbp2_firmware_revision; 338 u32 sbp2_firmware_revision;
384 339
385 /* 340 /*
@@ -411,7 +366,6 @@ struct scsi_id_instance_data {
411 u32 workarounds; 366 u32 workarounds;
412}; 367};
413 368
414
415/* Sbp2 host data structure (one per IEEE1394 host) */ 369/* Sbp2 host data structure (one per IEEE1394 host) */
416struct sbp2scsi_host_info { 370struct sbp2scsi_host_info {
417 struct hpsb_host *host; /* IEEE1394 host */ 371 struct hpsb_host *host; /* IEEE1394 host */
@@ -456,20 +410,12 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id);
456static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid, 410static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int destid,
457 quadlet_t *data, u64 addr, size_t length, u16 flags); 411 quadlet_t *data, u64 addr, size_t length, u16 flags);
458static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait); 412static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait);
459static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id,
460 struct sbp2_command_info *command,
461 unchar *scsi_cmd,
462 unsigned int scsi_use_sg,
463 unsigned int scsi_request_bufflen,
464 void *scsi_request_buffer,
465 enum dma_data_direction dma_dir);
466static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, 413static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id,
467 struct sbp2_command_info *command); 414 struct sbp2_command_info *command);
468static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, 415static int sbp2_send_command(struct scsi_id_instance_data *scsi_id,
469 struct scsi_cmnd *SCpnt, 416 struct scsi_cmnd *SCpnt,
470 void (*done)(struct scsi_cmnd *)); 417 void (*done)(struct scsi_cmnd *));
471static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data); 418static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data);
472static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd);
473static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, 419static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id,
474 struct scsi_cmnd *SCpnt); 420 struct scsi_cmnd *SCpnt);
475static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, 421static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id,
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c
index 23911da50154..608479b2df14 100644
--- a/drivers/ieee1394/video1394.c
+++ b/drivers/ieee1394/video1394.c
@@ -19,12 +19,6 @@
19 * 19 *
20 * NOTES: 20 * NOTES:
21 * 21 *
22 * jds -- add private data to file to keep track of iso contexts associated
23 * with each open -- so release won't kill all iso transfers.
24 *
25 * Damien Douxchamps: Fix failure when the number of DMA pages per frame is
26 * one.
27 *
28 * ioctl return codes: 22 * ioctl return codes:
29 * EFAULT is only for invalid address for the argp 23 * EFAULT is only for invalid address for the argp
30 * EINVAL for out of range values 24 * EINVAL for out of range values
@@ -34,12 +28,6 @@
34 * ENOTTY for unsupported ioctl request 28 * ENOTTY for unsupported ioctl request
35 * 29 *
36 */ 30 */
37
38/* Markus Tavenrath <speedygoo@speedygoo.de> :
39 - fixed checks for valid buffer-numbers in video1394_icotl
40 - changed the ways the dma prg's are used, now it's possible to use
41 even a single dma buffer
42*/
43#include <linux/config.h> 31#include <linux/config.h>
44#include <linux/kernel.h> 32#include <linux/kernel.h>
45#include <linux/list.h> 33#include <linux/list.h>
@@ -77,14 +65,6 @@
77 65
78#define ISO_CHANNELS 64 66#define ISO_CHANNELS 64
79 67
80#ifndef virt_to_page
81#define virt_to_page(x) MAP_NR(x)
82#endif
83
84#ifndef vmalloc_32
85#define vmalloc_32(x) vmalloc(x)
86#endif
87
88struct it_dma_prg { 68struct it_dma_prg {
89 struct dma_cmd begin; 69 struct dma_cmd begin;
90 quadlet_t data[4]; 70 quadlet_t data[4];
@@ -206,14 +186,12 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
206 struct dma_iso_ctx *d; 186 struct dma_iso_ctx *d;
207 int i; 187 int i;
208 188
209 d = kmalloc(sizeof(struct dma_iso_ctx), GFP_KERNEL); 189 d = kzalloc(sizeof(*d), GFP_KERNEL);
210 if (d == NULL) { 190 if (!d) {
211 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx"); 191 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx");
212 return NULL; 192 return NULL;
213 } 193 }
214 194
215 memset(d, 0, sizeof *d);
216
217 d->ohci = ohci; 195 d->ohci = ohci;
218 d->type = type; 196 d->type = type;
219 d->channel = channel; 197 d->channel = channel;
@@ -251,9 +229,8 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
251 } 229 }
252 d->ctx = d->iso_tasklet.context; 230 d->ctx = d->iso_tasklet.context;
253 231
254 d->prg_reg = kmalloc(d->num_desc * sizeof(struct dma_prog_region), 232 d->prg_reg = kmalloc(d->num_desc * sizeof(*d->prg_reg), GFP_KERNEL);
255 GFP_KERNEL); 233 if (!d->prg_reg) {
256 if (d->prg_reg == NULL) {
257 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs"); 234 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs");
258 free_dma_iso_ctx(d); 235 free_dma_iso_ctx(d);
259 return NULL; 236 return NULL;
@@ -268,15 +245,14 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
268 d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx; 245 d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx;
269 d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx; 246 d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx;
270 247
271 d->ir_prg = kmalloc(d->num_desc * sizeof(struct dma_cmd *), 248 d->ir_prg = kzalloc(d->num_desc * sizeof(*d->ir_prg),
272 GFP_KERNEL); 249 GFP_KERNEL);
273 250
274 if (d->ir_prg == NULL) { 251 if (!d->ir_prg) {
275 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg"); 252 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg");
276 free_dma_iso_ctx(d); 253 free_dma_iso_ctx(d);
277 return NULL; 254 return NULL;
278 } 255 }
279 memset(d->ir_prg, 0, d->num_desc * sizeof(struct dma_cmd *));
280 256
281 d->nb_cmd = d->buf_size / PAGE_SIZE + 1; 257 d->nb_cmd = d->buf_size / PAGE_SIZE + 1;
282 d->left_size = (d->frame_size % PAGE_SIZE) ? 258 d->left_size = (d->frame_size % PAGE_SIZE) ?
@@ -297,16 +273,15 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
297 d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx; 273 d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx;
298 d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx; 274 d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx;
299 275
300 d->it_prg = kmalloc(d->num_desc * sizeof(struct it_dma_prg *), 276 d->it_prg = kzalloc(d->num_desc * sizeof(*d->it_prg),
301 GFP_KERNEL); 277 GFP_KERNEL);
302 278
303 if (d->it_prg == NULL) { 279 if (!d->it_prg) {
304 PRINT(KERN_ERR, ohci->host->id, 280 PRINT(KERN_ERR, ohci->host->id,
305 "Failed to allocate dma it prg"); 281 "Failed to allocate dma it prg");
306 free_dma_iso_ctx(d); 282 free_dma_iso_ctx(d);
307 return NULL; 283 return NULL;
308 } 284 }
309 memset(d->it_prg, 0, d->num_desc*sizeof(struct it_dma_prg *));
310 285
311 d->packet_size = packet_size; 286 d->packet_size = packet_size;
312 287
@@ -337,47 +312,24 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc,
337 } 312 }
338 } 313 }
339 314
340 d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int), 315 d->buffer_status =
341 GFP_KERNEL); 316 kzalloc(d->num_desc * sizeof(*d->buffer_status), GFP_KERNEL);
342 d->buffer_prg_assignment = kmalloc(d->num_desc * sizeof(unsigned int), 317 d->buffer_prg_assignment =
343 GFP_KERNEL); 318 kzalloc(d->num_desc * sizeof(*d->buffer_prg_assignment), GFP_KERNEL);
344 d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval), 319 d->buffer_time =
345 GFP_KERNEL); 320 kzalloc(d->num_desc * sizeof(*d->buffer_time), GFP_KERNEL);
346 d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int), 321 d->last_used_cmd =
347 GFP_KERNEL); 322 kzalloc(d->num_desc * sizeof(*d->last_used_cmd), GFP_KERNEL);
348 d->next_buffer = kmalloc(d->num_desc * sizeof(int), 323 d->next_buffer =
349 GFP_KERNEL); 324 kzalloc(d->num_desc * sizeof(*d->next_buffer), GFP_KERNEL);
350 325
351 if (d->buffer_status == NULL) { 326 if (!d->buffer_status || !d->buffer_prg_assignment || !d->buffer_time ||
352 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_status"); 327 !d->last_used_cmd || !d->next_buffer) {
353 free_dma_iso_ctx(d); 328 PRINT(KERN_ERR, ohci->host->id,
354 return NULL; 329 "Failed to allocate dma_iso_ctx member");
355 }
356 if (d->buffer_prg_assignment == NULL) {
357 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_prg_assignment");
358 free_dma_iso_ctx(d);
359 return NULL;
360 }
361 if (d->buffer_time == NULL) {
362 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time");
363 free_dma_iso_ctx(d);
364 return NULL;
365 }
366 if (d->last_used_cmd == NULL) {
367 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate last_used_cmd");
368 free_dma_iso_ctx(d);
369 return NULL;
370 }
371 if (d->next_buffer == NULL) {
372 PRINT(KERN_ERR, ohci->host->id, "Failed to allocate next_buffer");
373 free_dma_iso_ctx(d); 330 free_dma_iso_ctx(d);
374 return NULL; 331 return NULL;
375 } 332 }
376 memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int));
377 memset(d->buffer_prg_assignment, 0, d->num_desc * sizeof(unsigned int));
378 memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval));
379 memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int));
380 memset(d->next_buffer, -1, d->num_desc * sizeof(int));
381 333
382 spin_lock_init(&d->lock); 334 spin_lock_init(&d->lock);
383 335
@@ -539,7 +491,7 @@ static void wakeup_dma_ir_ctx(unsigned long l)
539 if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) { 491 if (d->ir_prg[i][d->nb_cmd-1].status & cpu_to_le32(0xFFFF0000)) {
540 reset_ir_status(d, i); 492 reset_ir_status(d, i);
541 d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY; 493 d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
542 do_gettimeofday(&d->buffer_time[i]); 494 do_gettimeofday(&d->buffer_time[d->buffer_prg_assignment[i]]);
543 } 495 }
544 } 496 }
545 497
@@ -1046,7 +998,6 @@ static int __video1394_ioctl(struct file *file,
1046 998
1047 /* set time of buffer */ 999 /* set time of buffer */
1048 v.filltime = d->buffer_time[v.buffer]; 1000 v.filltime = d->buffer_time[v.buffer];
1049// printk("Buffer %d time %d\n", v.buffer, (d->buffer_time[v.buffer]).tv_usec);
1050 1001
1051 /* 1002 /*
1052 * Look ahead to see how many more buffers have been received 1003 * Look ahead to see how many more buffers have been received
@@ -1085,7 +1036,7 @@ static int __video1394_ioctl(struct file *file,
1085 } 1036 }
1086 1037
1087 if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { 1038 if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) {
1088 int buf_size = d->nb_cmd * sizeof(unsigned int); 1039 int buf_size = d->nb_cmd * sizeof(*psizes);
1089 struct video1394_queue_variable __user *p = argp; 1040 struct video1394_queue_variable __user *p = argp;
1090 unsigned int __user *qv; 1041 unsigned int __user *qv;
1091 1042
@@ -1104,7 +1055,7 @@ static int __video1394_ioctl(struct file *file,
1104 1055
1105 spin_lock_irqsave(&d->lock,flags); 1056 spin_lock_irqsave(&d->lock,flags);
1106 1057
1107 // last_buffer is last_prg 1058 /* last_buffer is last_prg */
1108 next_prg = (d->last_buffer + 1) % d->num_desc; 1059 next_prg = (d->last_buffer + 1) % d->num_desc;
1109 if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) { 1060 if (d->buffer_status[v.buffer]!=VIDEO1394_BUFFER_FREE) {
1110 PRINT(KERN_ERR, ohci->host->id, 1061 PRINT(KERN_ERR, ohci->host->id,
@@ -1251,13 +1202,12 @@ static int video1394_open(struct inode *inode, struct file *file)
1251 if (ohci == NULL) 1202 if (ohci == NULL)
1252 return -EIO; 1203 return -EIO;
1253 1204
1254 ctx = kmalloc(sizeof(struct file_ctx), GFP_KERNEL); 1205 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
1255 if (ctx == NULL) { 1206 if (!ctx) {
1256 PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx"); 1207 PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx");
1257 return -ENOMEM; 1208 return -ENOMEM;
1258 } 1209 }
1259 1210
1260 memset(ctx, 0, sizeof(struct file_ctx));
1261 ctx->ohci = ohci; 1211 ctx->ohci = ohci;
1262 INIT_LIST_HEAD(&ctx->context_list); 1212 INIT_LIST_HEAD(&ctx->context_list);
1263 ctx->current_ctx = NULL; 1213 ctx->current_ctx = NULL;
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 08648b1a387e..1f1743c5c9a3 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -434,24 +434,24 @@ static void ib_device_release(struct class_device *cdev)
434 kfree(dev); 434 kfree(dev);
435} 435}
436 436
437static int ib_device_hotplug(struct class_device *cdev, char **envp, 437static int ib_device_uevent(struct class_device *cdev, char **envp,
438 int num_envp, char *buf, int size) 438 int num_envp, char *buf, int size)
439{ 439{
440 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev); 440 struct ib_device *dev = container_of(cdev, struct ib_device, class_dev);
441 int i = 0, len = 0; 441 int i = 0, len = 0;
442 442
443 if (add_hotplug_env_var(envp, num_envp, &i, buf, size, &len, 443 if (add_uevent_var(envp, num_envp, &i, buf, size, &len,
444 "NAME=%s", dev->name)) 444 "NAME=%s", dev->name))
445 return -ENOMEM; 445 return -ENOMEM;
446 446
447 /* 447 /*
448 * It might be nice to pass the node GUID to hotplug, but 448 * It might be nice to pass the node GUID with the event, but
449 * right now the only way to get it is to query the device 449 * right now the only way to get it is to query the device
450 * provider, and this can crash during device removal because 450 * provider, and this can crash during device removal because
451 * we are will be running after driver removal has started. 451 * we are will be running after driver removal has started.
452 * We could add a node_guid field to struct ib_device, or we 452 * We could add a node_guid field to struct ib_device, or we
453 * could just let the hotplug script read the node GUID from 453 * could just let userspace read the node GUID from sysfs when
454 * sysfs when devices are added. 454 * devices are added.
455 */ 455 */
456 456
457 envp[i] = NULL; 457 envp[i] = NULL;
@@ -653,7 +653,7 @@ static struct class_device_attribute *ib_class_attributes[] = {
653static struct class ib_class = { 653static struct class ib_class = {
654 .name = "infiniband", 654 .name = "infiniband",
655 .release = ib_device_release, 655 .release = ib_device_release,
656 .hotplug = ib_device_hotplug, 656 .uevent = ib_device_uevent,
657}; 657};
658 658
659int ib_device_register_sysfs(struct ib_device *device) 659int ib_device_register_sysfs(struct ib_device *device)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 475d98fa9e26..780009c7eaa6 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -47,6 +47,8 @@
47#include <linux/ip.h> 47#include <linux/ip.h>
48#include <linux/in.h> 48#include <linux/in.h>
49 49
50#include <net/dst.h>
51
50MODULE_AUTHOR("Roland Dreier"); 52MODULE_AUTHOR("Roland Dreier");
51MODULE_DESCRIPTION("IP-over-InfiniBand net driver"); 53MODULE_DESCRIPTION("IP-over-InfiniBand net driver");
52MODULE_LICENSE("Dual BSD/GPL"); 54MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index ef3ee035bbc8..ed0c2ead8bc1 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -43,6 +43,8 @@
43#include <linux/delay.h> 43#include <linux/delay.h>
44#include <linux/completion.h> 44#include <linux/completion.h>
45 45
46#include <net/dst.h>
47
46#include "ipoib.h" 48#include "ipoib.h"
47 49
48#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 50#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 9f2352bd8348..a1e660e3531d 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -157,7 +157,7 @@ struct input_event_compat {
157# define COMPAT_TEST test_thread_flag(TIF_IA32) 157# define COMPAT_TEST test_thread_flag(TIF_IA32)
158#elif defined(CONFIG_IA64) 158#elif defined(CONFIG_IA64)
159# define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current)) 159# define COMPAT_TEST IS_IA32_PROCESS(ia64_task_regs(current))
160#elif defined(CONFIG_ARCH_S390) 160#elif defined(CONFIG_S390)
161# define COMPAT_TEST test_thread_flag(TIF_31BIT) 161# define COMPAT_TEST test_thread_flag(TIF_31BIT)
162#elif defined(CONFIG_MIPS) 162#elif defined(CONFIG_MIPS)
163# define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR) 163# define COMPAT_TEST (current->thread.mflags & MF_32BIT_ADDR)
diff --git a/drivers/input/input.c b/drivers/input/input.c
index bdd2a7fc268d..ef5824c8846b 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -18,7 +18,6 @@
18#include <linux/random.h> 18#include <linux/random.h>
19#include <linux/major.h> 19#include <linux/major.h>
20#include <linux/proc_fs.h> 20#include <linux/proc_fs.h>
21#include <linux/kobject_uevent.h>
22#include <linux/interrupt.h> 21#include <linux/interrupt.h>
23#include <linux/poll.h> 22#include <linux/poll.h>
24#include <linux/device.h> 23#include <linux/device.h>
@@ -529,10 +528,49 @@ INPUT_DEV_STRING_ATTR_SHOW(name);
529INPUT_DEV_STRING_ATTR_SHOW(phys); 528INPUT_DEV_STRING_ATTR_SHOW(phys);
530INPUT_DEV_STRING_ATTR_SHOW(uniq); 529INPUT_DEV_STRING_ATTR_SHOW(uniq);
531 530
531static int print_modalias_bits(char *buf, char prefix, unsigned long *arr,
532 unsigned int min, unsigned int max)
533{
534 int len, i;
535
536 len = sprintf(buf, "%c", prefix);
537 for (i = min; i < max; i++)
538 if (arr[LONG(i)] & BIT(i))
539 len += sprintf(buf+len, "%X,", i);
540 return len;
541}
542
543static ssize_t input_dev_show_modalias(struct class_device *dev, char *buf)
544{
545 struct input_dev *id = to_input_dev(dev);
546 ssize_t len = 0;
547
548 len += sprintf(buf+len, "input:b%04Xv%04Xp%04Xe%04X-",
549 id->id.bustype,
550 id->id.vendor,
551 id->id.product,
552 id->id.version);
553
554 len += print_modalias_bits(buf+len, 'e', id->evbit, 0, EV_MAX);
555 len += print_modalias_bits(buf+len, 'k', id->keybit,
556 KEY_MIN_INTERESTING, KEY_MAX);
557 len += print_modalias_bits(buf+len, 'r', id->relbit, 0, REL_MAX);
558 len += print_modalias_bits(buf+len, 'a', id->absbit, 0, ABS_MAX);
559 len += print_modalias_bits(buf+len, 'm', id->mscbit, 0, MSC_MAX);
560 len += print_modalias_bits(buf+len, 'l', id->ledbit, 0, LED_MAX);
561 len += print_modalias_bits(buf+len, 's', id->sndbit, 0, SND_MAX);
562 len += print_modalias_bits(buf+len, 'f', id->ffbit, 0, FF_MAX);
563 len += print_modalias_bits(buf+len, 'w', id->swbit, 0, SW_MAX);
564 len += sprintf(buf+len, "\n");
565 return len;
566}
567static CLASS_DEVICE_ATTR(modalias, S_IRUGO, input_dev_show_modalias, NULL);
568
532static struct attribute *input_dev_attrs[] = { 569static struct attribute *input_dev_attrs[] = {
533 &class_device_attr_name.attr, 570 &class_device_attr_name.attr,
534 &class_device_attr_phys.attr, 571 &class_device_attr_phys.attr,
535 &class_device_attr_uniq.attr, 572 &class_device_attr_uniq.attr,
573 &class_device_attr_modalias.attr,
536 NULL 574 NULL
537}; 575};
538 576
@@ -611,10 +649,10 @@ static void input_dev_release(struct class_device *class_dev)
611} 649}
612 650
613/* 651/*
614 * Input hotplugging interface - loading event handlers based on 652 * Input uevent interface - loading event handlers based on
615 * device bitfields. 653 * device bitfields.
616 */ 654 */
617static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index, 655static int input_add_uevent_bm_var(char **envp, int num_envp, int *cur_index,
618 char *buffer, int buffer_size, int *cur_len, 656 char *buffer, int buffer_size, int *cur_len,
619 const char *name, unsigned long *bitmap, int max) 657 const char *name, unsigned long *bitmap, int max)
620{ 658{
@@ -639,7 +677,7 @@ static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index,
639 677
640#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \ 678#define INPUT_ADD_HOTPLUG_VAR(fmt, val...) \
641 do { \ 679 do { \
642 int err = add_hotplug_env_var(envp, num_envp, &i, \ 680 int err = add_uevent_var(envp, num_envp, &i, \
643 buffer, buffer_size, &len, \ 681 buffer, buffer_size, &len, \
644 fmt, val); \ 682 fmt, val); \
645 if (err) \ 683 if (err) \
@@ -648,15 +686,15 @@ static int input_add_hotplug_bm_var(char **envp, int num_envp, int *cur_index,
648 686
649#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \ 687#define INPUT_ADD_HOTPLUG_BM_VAR(name, bm, max) \
650 do { \ 688 do { \
651 int err = input_add_hotplug_bm_var(envp, num_envp, &i, \ 689 int err = input_add_uevent_bm_var(envp, num_envp, &i, \
652 buffer, buffer_size, &len, \ 690 buffer, buffer_size, &len, \
653 name, bm, max); \ 691 name, bm, max); \
654 if (err) \ 692 if (err) \
655 return err; \ 693 return err; \
656 } while (0) 694 } while (0)
657 695
658static int input_dev_hotplug(struct class_device *cdev, char **envp, 696static int input_dev_uevent(struct class_device *cdev, char **envp,
659 int num_envp, char *buffer, int buffer_size) 697 int num_envp, char *buffer, int buffer_size)
660{ 698{
661 struct input_dev *dev = to_input_dev(cdev); 699 struct input_dev *dev = to_input_dev(cdev);
662 int i = 0; 700 int i = 0;
@@ -698,7 +736,7 @@ static int input_dev_hotplug(struct class_device *cdev, char **envp,
698struct class input_class = { 736struct class input_class = {
699 .name = "input", 737 .name = "input",
700 .release = input_dev_release, 738 .release = input_dev_release,
701 .hotplug = input_dev_hotplug, 739 .uevent = input_dev_uevent,
702}; 740};
703 741
704struct input_dev *input_allocate_device(void) 742struct input_dev *input_allocate_device(void)
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index 64b4a3080985..bc2fce60f9f8 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -235,7 +235,6 @@ static struct usb_device_id iforce_usb_ids [] = {
235MODULE_DEVICE_TABLE (usb, iforce_usb_ids); 235MODULE_DEVICE_TABLE (usb, iforce_usb_ids);
236 236
237struct usb_driver iforce_usb_driver = { 237struct usb_driver iforce_usb_driver = {
238 .owner = THIS_MODULE,
239 .name = "iforce", 238 .name = "iforce",
240 .probe = iforce_usb_probe, 239 .probe = iforce_usb_probe,
241 .disconnect = iforce_usb_disconnect, 240 .disconnect = iforce_usb_disconnect,
diff --git a/drivers/input/joystick/warrior.c b/drivers/input/joystick/warrior.c
index 99a642d2a1fe..1849b176cf18 100644
--- a/drivers/input/joystick/warrior.c
+++ b/drivers/input/joystick/warrior.c
@@ -172,7 +172,7 @@ static int warrior_connect(struct serio *serio, struct serio_driver *drv)
172 input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8); 172 input_set_abs_params(input_dev, ABS_Y, -64, 64, 0, 8);
173 input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0); 173 input_set_abs_params(input_dev, ABS_THROTTLE, -112, 112, 0, 0);
174 input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0); 174 input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0);
175 input_set_abs_params(input_dev, ABS_HAT0X, -1, 1, 0, 0); 175 input_set_abs_params(input_dev, ABS_HAT0Y, -1, 1, 0, 0);
176 176
177 serio_set_drvdata(serio, warrior); 177 serio_set_drvdata(serio, warrior);
178 178
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 07813fc0523f..e08dbe08f46d 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -26,7 +26,7 @@ config INPUT_PCSPKR
26 26
27config INPUT_SPARCSPKR 27config INPUT_SPARCSPKR
28 tristate "SPARC Speaker support" 28 tristate "SPARC Speaker support"
29 depends on PCI && (SPARC32 || SPARC64) 29 depends on PCI && SPARC
30 help 30 help
31 Say Y here if you want the standard Speaker on Sparc PCI systems 31 Say Y here if you want the standard Speaker on Sparc PCI systems
32 to be used for bells and whistles. 32 to be used for bells and whistles.
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 49d0416a2a9a..bac3085185fe 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -320,7 +320,7 @@ static struct dmi_system_id dmi_ids[] = {
320 }, 320 },
321 .driver_data = keymap_acer_aspire_1500 321 .driver_data = keymap_acer_aspire_1500
322 }, 322 },
323 { 0, } 323 { NULL, }
324}; 324};
325 325
326static int __init select_keymap(void) 326static int __init select_keymap(void)
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
index 4acc7fd4cd0f..4f41ec3e4332 100644
--- a/drivers/input/mouse/alps.c
+++ b/drivers/input/mouse/alps.c
@@ -42,7 +42,7 @@ static struct alps_model_info alps_model_data[] = {
42 { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, 42 { { 0x53, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
43 { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 }, 43 { { 0x63, 0x02, 0x0a }, 0xf8, 0xf8, 0 },
44 { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 }, 44 { { 0x63, 0x02, 0x14 }, 0xf8, 0xf8, 0 },
45 { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, 0 }, 45 { { 0x63, 0x02, 0x28 }, 0xf8, 0xf8, ALPS_FW_BK_2 }, /* Fujitsu Siemens S6010 */
46 { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */ 46 { { 0x63, 0x02, 0x3c }, 0x8f, 0x8f, ALPS_WHEEL }, /* Toshiba Satellite S2400-103 */
47 { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */ 47 { { 0x63, 0x02, 0x50 }, 0xef, 0xef, ALPS_FW_BK_1 }, /* NEC Versa L320 */
48 { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 }, 48 { { 0x63, 0x02, 0x64 }, 0xf8, 0xf8, 0 },
diff --git a/drivers/input/mouse/sermouse.c b/drivers/input/mouse/sermouse.c
index 4bf584364d28..2f9a04ae725f 100644
--- a/drivers/input/mouse/sermouse.c
+++ b/drivers/input/mouse/sermouse.c
@@ -95,7 +95,7 @@ static void sermouse_process_msc(struct sermouse *sermouse, signed char data, st
95 95
96 input_sync(dev); 96 input_sync(dev);
97 97
98 if (++sermouse->count == (5 - ((sermouse->type == SERIO_SUN) << 1))) 98 if (++sermouse->count == 5)
99 sermouse->count = 0; 99 sermouse->count = 0;
100} 100}
101 101
diff --git a/drivers/input/serio/i8042.h b/drivers/input/serio/i8042.h
index 13835039a2a7..cbbf3842da5b 100644
--- a/drivers/input/serio/i8042.h
+++ b/drivers/input/serio/i8042.h
@@ -21,7 +21,7 @@
21#include "i8042-ip22io.h" 21#include "i8042-ip22io.h"
22#elif defined(CONFIG_PPC) 22#elif defined(CONFIG_PPC)
23#include "i8042-ppcio.h" 23#include "i8042-ppcio.h"
24#elif defined(CONFIG_SPARC32) || defined(CONFIG_SPARC64) 24#elif defined(CONFIG_SPARC)
25#include "i8042-sparcio.h" 25#include "i8042-sparcio.h"
26#elif defined(CONFIG_X86) || defined(CONFIG_IA64) 26#elif defined(CONFIG_X86) || defined(CONFIG_IA64)
27#include "i8042-x86ia64io.h" 27#include "i8042-x86ia64io.h"
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index fbb69ef6a77b..8e530cc970e1 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -800,16 +800,16 @@ static int serio_bus_match(struct device *dev, struct device_driver *drv)
800 800
801#ifdef CONFIG_HOTPLUG 801#ifdef CONFIG_HOTPLUG
802 802
803#define SERIO_ADD_HOTPLUG_VAR(fmt, val...) \ 803#define SERIO_ADD_UEVENT_VAR(fmt, val...) \
804 do { \ 804 do { \
805 int err = add_hotplug_env_var(envp, num_envp, &i, \ 805 int err = add_uevent_var(envp, num_envp, &i, \
806 buffer, buffer_size, &len, \ 806 buffer, buffer_size, &len, \
807 fmt, val); \ 807 fmt, val); \
808 if (err) \ 808 if (err) \
809 return err; \ 809 return err; \
810 } while (0) 810 } while (0)
811 811
812static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 812static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
813{ 813{
814 struct serio *serio; 814 struct serio *serio;
815 int i = 0; 815 int i = 0;
@@ -820,21 +820,21 @@ static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *bu
820 820
821 serio = to_serio_port(dev); 821 serio = to_serio_port(dev);
822 822
823 SERIO_ADD_HOTPLUG_VAR("SERIO_TYPE=%02x", serio->id.type); 823 SERIO_ADD_UEVENT_VAR("SERIO_TYPE=%02x", serio->id.type);
824 SERIO_ADD_HOTPLUG_VAR("SERIO_PROTO=%02x", serio->id.proto); 824 SERIO_ADD_UEVENT_VAR("SERIO_PROTO=%02x", serio->id.proto);
825 SERIO_ADD_HOTPLUG_VAR("SERIO_ID=%02x", serio->id.id); 825 SERIO_ADD_UEVENT_VAR("SERIO_ID=%02x", serio->id.id);
826 SERIO_ADD_HOTPLUG_VAR("SERIO_EXTRA=%02x", serio->id.extra); 826 SERIO_ADD_UEVENT_VAR("SERIO_EXTRA=%02x", serio->id.extra);
827 SERIO_ADD_HOTPLUG_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X", 827 SERIO_ADD_UEVENT_VAR("MODALIAS=serio:ty%02Xpr%02Xid%02Xex%02X",
828 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra); 828 serio->id.type, serio->id.proto, serio->id.id, serio->id.extra);
829 envp[i] = NULL; 829 envp[i] = NULL;
830 830
831 return 0; 831 return 0;
832} 832}
833#undef SERIO_ADD_HOTPLUG_VAR 833#undef SERIO_ADD_UEVENT_VAR
834 834
835#else 835#else
836 836
837static int serio_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 837static int serio_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
838{ 838{
839 return -ENODEV; 839 return -ENODEV;
840} 840}
@@ -908,7 +908,7 @@ static int __init serio_init(void)
908 serio_bus.dev_attrs = serio_device_attrs; 908 serio_bus.dev_attrs = serio_device_attrs;
909 serio_bus.drv_attrs = serio_driver_attrs; 909 serio_bus.drv_attrs = serio_driver_attrs;
910 serio_bus.match = serio_bus_match; 910 serio_bus.match = serio_bus_match;
911 serio_bus.hotplug = serio_hotplug; 911 serio_bus.uevent = serio_uevent;
912 serio_bus.resume = serio_resume; 912 serio_bus.resume = serio_resume;
913 bus_register(&serio_bus); 913 bus_register(&serio_bus);
914 914
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 27391c32f3eb..2a2b03ff096b 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -53,8 +53,6 @@ MODULE_LICENSE("GPL");
53 53
54static void avmcs_config(dev_link_t *link); 54static void avmcs_config(dev_link_t *link);
55static void avmcs_release(dev_link_t *link); 55static void avmcs_release(dev_link_t *link);
56static int avmcs_event(event_t event, int priority,
57 event_callback_args_t *args);
58 56
59/* 57/*
60 The attach() and detach() entry points are used to create and destroy 58 The attach() and detach() entry points are used to create and destroy
@@ -62,16 +60,7 @@ static int avmcs_event(event_t event, int priority,
62 needed to manage one actual PCMCIA card. 60 needed to manage one actual PCMCIA card.
63*/ 61*/
64 62
65static dev_link_t *avmcs_attach(void); 63static void avmcs_detach(struct pcmcia_device *p_dev);
66static void avmcs_detach(dev_link_t *);
67
68/*
69 The dev_info variable is the "key" that is used to match up this
70 device driver with appropriate cards, through the card configuration
71 database.
72*/
73
74static dev_info_t dev_info = "avm_cs";
75 64
76/* 65/*
77 A linked list of "instances" of the skeleton device. Each actual 66 A linked list of "instances" of the skeleton device. Each actual
@@ -83,15 +72,7 @@ static dev_info_t dev_info = "avm_cs";
83 device numbers are used to derive the corresponding array index. 72 device numbers are used to derive the corresponding array index.
84*/ 73*/
85 74
86static dev_link_t *dev_list = NULL;
87
88/* 75/*
89 A dev_link_t structure has fields for most things that are needed
90 to keep track of a socket, but there will usually be some device
91 specific information that also needs to be kept track of. The
92 'priv' pointer in a dev_link_t structure can be used to point to
93 a device-specific private data structure, like this.
94
95 A driver needs to provide a dev_node_t structure for each device 76 A driver needs to provide a dev_node_t structure for each device
96 on a card. In some cases, there is only one device per card (for 77 on a card. In some cases, there is only one device per card (for
97 example, ethernet cards, modems). In other cases, there may be 78 example, ethernet cards, modems). In other cases, there may be
@@ -118,13 +99,11 @@ typedef struct local_info_t {
118 99
119======================================================================*/ 100======================================================================*/
120 101
121static dev_link_t *avmcs_attach(void) 102static int avmcs_attach(struct pcmcia_device *p_dev)
122{ 103{
123 client_reg_t client_reg;
124 dev_link_t *link; 104 dev_link_t *link;
125 local_info_t *local; 105 local_info_t *local;
126 int ret; 106
127
128 /* Initialize the dev_link_t structure */ 107 /* Initialize the dev_link_t structure */
129 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 108 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
130 if (!link) 109 if (!link)
@@ -155,25 +134,19 @@ static dev_link_t *avmcs_attach(void)
155 goto err_kfree; 134 goto err_kfree;
156 memset(local, 0, sizeof(local_info_t)); 135 memset(local, 0, sizeof(local_info_t));
157 link->priv = local; 136 link->priv = local;
158 137
159 /* Register with Card Services */ 138 link->handle = p_dev;
160 link->next = dev_list; 139 p_dev->instance = link;
161 dev_list = link; 140
162 client_reg.dev_info = &dev_info; 141 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
163 client_reg.Version = 0x0210; 142 avmcs_config(link);
164 client_reg.event_callback_args.client_data = link; 143
165 ret = pcmcia_register_client(&link->handle, &client_reg); 144 return 0;
166 if (ret != 0) {
167 cs_error(link->handle, RegisterClient, ret);
168 avmcs_detach(link);
169 goto err;
170 }
171 return link;
172 145
173 err_kfree: 146 err_kfree:
174 kfree(link); 147 kfree(link);
175 err: 148 err:
176 return NULL; 149 return -EINVAL;
177} /* avmcs_attach */ 150} /* avmcs_attach */
178 151
179/*====================================================================== 152/*======================================================================
@@ -185,33 +158,13 @@ static dev_link_t *avmcs_attach(void)
185 158
186======================================================================*/ 159======================================================================*/
187 160
188static void avmcs_detach(dev_link_t *link) 161static void avmcs_detach(struct pcmcia_device *p_dev)
189{ 162{
190 dev_link_t **linkp; 163 dev_link_t *link = dev_to_instance(p_dev);
191
192 /* Locate device structure */
193 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
194 if (*linkp == link) break;
195 if (*linkp == NULL)
196 return;
197 164
198 /* 165 if (link->state & DEV_CONFIG)
199 If the device is currently configured and active, we won't 166 avmcs_release(link);
200 actually delete it yet. Instead, it is marked so that when
201 the release() function is called, that will trigger a proper
202 detach().
203 */
204 if (link->state & DEV_CONFIG) {
205 link->state |= DEV_STALE_LINK;
206 return;
207 }
208 167
209 /* Break the link with Card Services */
210 if (link->handle)
211 pcmcia_deregister_client(link->handle);
212
213 /* Unlink device structure, free pieces */
214 *linkp = link->next;
215 kfree(link->priv); 168 kfree(link->priv);
216 kfree(link); 169 kfree(link);
217} /* avmcs_detach */ 170} /* avmcs_detach */
@@ -424,12 +377,30 @@ static void avmcs_release(dev_link_t *link)
424 pcmcia_release_io(link->handle, &link->io); 377 pcmcia_release_io(link->handle, &link->io);
425 pcmcia_release_irq(link->handle, &link->irq); 378 pcmcia_release_irq(link->handle, &link->irq);
426 link->state &= ~DEV_CONFIG; 379 link->state &= ~DEV_CONFIG;
427
428 if (link->state & DEV_STALE_LINK)
429 avmcs_detach(link);
430
431} /* avmcs_release */ 380} /* avmcs_release */
432 381
382static int avmcs_suspend(struct pcmcia_device *dev)
383{
384 dev_link_t *link = dev_to_instance(dev);
385
386 link->state |= DEV_SUSPEND;
387 if (link->state & DEV_CONFIG)
388 pcmcia_release_configuration(link->handle);
389
390 return 0;
391}
392
393static int avmcs_resume(struct pcmcia_device *dev)
394{
395 dev_link_t *link = dev_to_instance(dev);
396
397 link->state &= ~DEV_SUSPEND;
398 if (link->state & DEV_CONFIG)
399 pcmcia_request_configuration(link->handle, &link->conf);
400
401 return 0;
402}
403
433/*====================================================================== 404/*======================================================================
434 405
435 The card status event handler. Mostly, this schedules other 406 The card status event handler. Mostly, this schedules other
@@ -444,38 +415,6 @@ static void avmcs_release(dev_link_t *link)
444 415
445======================================================================*/ 416======================================================================*/
446 417
447static int avmcs_event(event_t event, int priority,
448 event_callback_args_t *args)
449{
450 dev_link_t *link = args->client_data;
451
452 switch (event) {
453 case CS_EVENT_CARD_REMOVAL:
454 link->state &= ~DEV_PRESENT;
455 if (link->state & DEV_CONFIG)
456 avmcs_release(link);
457 break;
458 case CS_EVENT_CARD_INSERTION:
459 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
460 avmcs_config(link);
461 break;
462 case CS_EVENT_PM_SUSPEND:
463 link->state |= DEV_SUSPEND;
464 /* Fall through... */
465 case CS_EVENT_RESET_PHYSICAL:
466 if (link->state & DEV_CONFIG)
467 pcmcia_release_configuration(link->handle);
468 break;
469 case CS_EVENT_PM_RESUME:
470 link->state &= ~DEV_SUSPEND;
471 /* Fall through... */
472 case CS_EVENT_CARD_RESET:
473 if (link->state & DEV_CONFIG)
474 pcmcia_request_configuration(link->handle, &link->conf);
475 break;
476 }
477 return 0;
478} /* avmcs_event */
479 418
480static struct pcmcia_device_id avmcs_ids[] = { 419static struct pcmcia_device_id avmcs_ids[] = {
481 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335), 420 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN-Controller B1", 0x95d42008, 0x845dc335),
@@ -490,10 +429,11 @@ static struct pcmcia_driver avmcs_driver = {
490 .drv = { 429 .drv = {
491 .name = "avm_cs", 430 .name = "avm_cs",
492 }, 431 },
493 .attach = avmcs_attach, 432 .probe = avmcs_attach,
494 .event = avmcs_event, 433 .remove = avmcs_detach,
495 .detach = avmcs_detach,
496 .id_table = avmcs_ids, 434 .id_table = avmcs_ids,
435 .suspend= avmcs_suspend,
436 .resume = avmcs_resume,
497}; 437};
498 438
499static int __init avmcs_init(void) 439static int __init avmcs_init(void)
@@ -504,7 +444,6 @@ static int __init avmcs_init(void)
504static void __exit avmcs_exit(void) 444static void __exit avmcs_exit(void)
505{ 445{
506 pcmcia_unregister_driver(&avmcs_driver); 446 pcmcia_unregister_driver(&avmcs_driver);
507 BUG_ON(dev_list != NULL);
508} 447}
509 448
510module_init(avmcs_init); 449module_init(avmcs_init);
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 5f5a5ae740d2..969da40c4248 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -69,8 +69,6 @@ module_param(isdnprot, int, 0);
69 69
70static void avma1cs_config(dev_link_t *link); 70static void avma1cs_config(dev_link_t *link);
71static void avma1cs_release(dev_link_t *link); 71static void avma1cs_release(dev_link_t *link);
72static int avma1cs_event(event_t event, int priority,
73 event_callback_args_t *args);
74 72
75/* 73/*
76 The attach() and detach() entry points are used to create and destroy 74 The attach() and detach() entry points are used to create and destroy
@@ -78,16 +76,8 @@ static int avma1cs_event(event_t event, int priority,
78 needed to manage one actual PCMCIA card. 76 needed to manage one actual PCMCIA card.
79*/ 77*/
80 78
81static dev_link_t *avma1cs_attach(void); 79static void avma1cs_detach(struct pcmcia_device *p_dev);
82static void avma1cs_detach(dev_link_t *);
83 80
84/*
85 The dev_info variable is the "key" that is used to match up this
86 device driver with appropriate cards, through the card configuration
87 database.
88*/
89
90static dev_info_t dev_info = "avma1_cs";
91 81
92/* 82/*
93 A linked list of "instances" of the skeleton device. Each actual 83 A linked list of "instances" of the skeleton device. Each actual
@@ -99,15 +89,7 @@ static dev_info_t dev_info = "avma1_cs";
99 device numbers are used to derive the corresponding array index. 89 device numbers are used to derive the corresponding array index.
100*/ 90*/
101 91
102static dev_link_t *dev_list = NULL;
103
104/* 92/*
105 A dev_link_t structure has fields for most things that are needed
106 to keep track of a socket, but there will usually be some device
107 specific information that also needs to be kept track of. The
108 'priv' pointer in a dev_link_t structure can be used to point to
109 a device-specific private data structure, like this.
110
111 A driver needs to provide a dev_node_t structure for each device 93 A driver needs to provide a dev_node_t structure for each device
112 on a card. In some cases, there is only one device per card (for 94 on a card. In some cases, there is only one device per card (for
113 example, ethernet cards, modems). In other cases, there may be 95 example, ethernet cards, modems). In other cases, there may be
@@ -134,26 +116,24 @@ typedef struct local_info_t {
134 116
135======================================================================*/ 117======================================================================*/
136 118
137static dev_link_t *avma1cs_attach(void) 119static int avma1cs_attach(struct pcmcia_device *p_dev)
138{ 120{
139 client_reg_t client_reg;
140 dev_link_t *link; 121 dev_link_t *link;
141 local_info_t *local; 122 local_info_t *local;
142 int ret; 123
143
144 DEBUG(0, "avma1cs_attach()\n"); 124 DEBUG(0, "avma1cs_attach()\n");
145 125
146 /* Initialize the dev_link_t structure */ 126 /* Initialize the dev_link_t structure */
147 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 127 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
148 if (!link) 128 if (!link)
149 return NULL; 129 return -ENOMEM;
150 memset(link, 0, sizeof(struct dev_link_t)); 130 memset(link, 0, sizeof(struct dev_link_t));
151 131
152 /* Allocate space for private device-specific data */ 132 /* Allocate space for private device-specific data */
153 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 133 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
154 if (!local) { 134 if (!local) {
155 kfree(link); 135 kfree(link);
156 return NULL; 136 return -ENOMEM;
157 } 137 }
158 memset(local, 0, sizeof(local_info_t)); 138 memset(local, 0, sizeof(local_info_t));
159 link->priv = local; 139 link->priv = local;
@@ -178,20 +158,13 @@ static dev_link_t *avma1cs_attach(void)
178 link->conf.ConfigIndex = 1; 158 link->conf.ConfigIndex = 1;
179 link->conf.Present = PRESENT_OPTION; 159 link->conf.Present = PRESENT_OPTION;
180 160
181 /* Register with Card Services */ 161 link->handle = p_dev;
182 link->next = dev_list; 162 p_dev->instance = link;
183 dev_list = link;
184 client_reg.dev_info = &dev_info;
185 client_reg.Version = 0x0210;
186 client_reg.event_callback_args.client_data = link;
187 ret = pcmcia_register_client(&link->handle, &client_reg);
188 if (ret != 0) {
189 cs_error(link->handle, RegisterClient, ret);
190 avma1cs_detach(link);
191 return NULL;
192 }
193 163
194 return link; 164 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
165 avma1cs_config(link);
166
167 return 0;
195} /* avma1cs_attach */ 168} /* avma1cs_attach */
196 169
197/*====================================================================== 170/*======================================================================
@@ -203,42 +176,17 @@ static dev_link_t *avma1cs_attach(void)
203 176
204======================================================================*/ 177======================================================================*/
205 178
206static void avma1cs_detach(dev_link_t *link) 179static void avma1cs_detach(struct pcmcia_device *p_dev)
207{ 180{
208 dev_link_t **linkp; 181 dev_link_t *link = dev_to_instance(p_dev);
209 182
210 DEBUG(0, "avma1cs_detach(0x%p)\n", link); 183 DEBUG(0, "avma1cs_detach(0x%p)\n", link);
211
212 /* Locate device structure */
213 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
214 if (*linkp == link) break;
215 if (*linkp == NULL)
216 return;
217 184
218 /* 185 if (link->state & DEV_CONFIG)
219 If the device is currently configured and active, we won't 186 avma1cs_release(link);
220 actually delete it yet. Instead, it is marked so that when
221 the release() function is called, that will trigger a proper
222 detach().
223 */
224 if (link->state & DEV_CONFIG) {
225#ifdef PCMCIA_DEBUG
226 printk(KERN_DEBUG "avma1_cs: detach postponed, '%s' "
227 "still locked\n", link->dev->dev_name);
228#endif
229 link->state |= DEV_STALE_LINK;
230 return;
231 }
232 187
233 /* Break the link with Card Services */
234 if (link->handle)
235 pcmcia_deregister_client(link->handle);
236
237 /* Unlink device structure, free pieces */
238 *linkp = link->next;
239 kfree(link->priv); 188 kfree(link->priv);
240 kfree(link); 189 kfree(link);
241
242} /* avma1cs_detach */ 190} /* avma1cs_detach */
243 191
244/*====================================================================== 192/*======================================================================
@@ -440,58 +388,30 @@ static void avma1cs_release(dev_link_t *link)
440 pcmcia_release_io(link->handle, &link->io); 388 pcmcia_release_io(link->handle, &link->io);
441 pcmcia_release_irq(link->handle, &link->irq); 389 pcmcia_release_irq(link->handle, &link->irq);
442 link->state &= ~DEV_CONFIG; 390 link->state &= ~DEV_CONFIG;
443
444 if (link->state & DEV_STALE_LINK)
445 avma1cs_detach(link);
446} /* avma1cs_release */ 391} /* avma1cs_release */
447 392
448/*====================================================================== 393static int avma1cs_suspend(struct pcmcia_device *dev)
394{
395 dev_link_t *link = dev_to_instance(dev);
449 396
450 The card status event handler. Mostly, this schedules other 397 link->state |= DEV_SUSPEND;
451 stuff to run after an event is received. A CARD_REMOVAL event 398 if (link->state & DEV_CONFIG)
452 also sets some flags to discourage the net drivers from trying 399 pcmcia_release_configuration(link->handle);
453 to talk to the card any more.
454 400
455 When a CARD_REMOVAL event is received, we immediately set a flag 401 return 0;
456 to block future accesses to this device. All the functions that 402}
457 actually access the device should check this flag to make sure
458 the card is still present.
459
460======================================================================*/
461 403
462static int avma1cs_event(event_t event, int priority, 404static int avma1cs_resume(struct pcmcia_device *dev)
463 event_callback_args_t *args)
464{ 405{
465 dev_link_t *link = args->client_data; 406 dev_link_t *link = dev_to_instance(dev);
466 407
467 DEBUG(1, "avma1cs_event(0x%06x)\n", event); 408 link->state &= ~DEV_SUSPEND;
468 409 if (link->state & DEV_CONFIG)
469 switch (event) {
470 case CS_EVENT_CARD_REMOVAL:
471 if (link->state & DEV_CONFIG)
472 avma1cs_release(link);
473 break;
474 case CS_EVENT_CARD_INSERTION:
475 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
476 avma1cs_config(link);
477 break;
478 case CS_EVENT_PM_SUSPEND:
479 link->state |= DEV_SUSPEND;
480 /* Fall through... */
481 case CS_EVENT_RESET_PHYSICAL:
482 if (link->state & DEV_CONFIG)
483 pcmcia_release_configuration(link->handle);
484 break;
485 case CS_EVENT_PM_RESUME:
486 link->state &= ~DEV_SUSPEND;
487 /* Fall through... */
488 case CS_EVENT_CARD_RESET:
489 if (link->state & DEV_CONFIG)
490 pcmcia_request_configuration(link->handle, &link->conf); 410 pcmcia_request_configuration(link->handle, &link->conf);
491 break; 411
492 } 412 return 0;
493 return 0; 413}
494} /* avma1cs_event */ 414
495 415
496static struct pcmcia_device_id avma1cs_ids[] = { 416static struct pcmcia_device_id avma1cs_ids[] = {
497 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb), 417 PCMCIA_DEVICE_PROD_ID12("AVM", "ISDN A", 0x95d42008, 0xadc9d4bb),
@@ -505,10 +425,11 @@ static struct pcmcia_driver avma1cs_driver = {
505 .drv = { 425 .drv = {
506 .name = "avma1_cs", 426 .name = "avma1_cs",
507 }, 427 },
508 .attach = avma1cs_attach, 428 .probe = avma1cs_attach,
509 .event = avma1cs_event, 429 .remove = avma1cs_detach,
510 .detach = avma1cs_detach,
511 .id_table = avma1cs_ids, 430 .id_table = avma1cs_ids,
431 .suspend = avma1cs_suspend,
432 .resume = avma1cs_resume,
512}; 433};
513 434
514/*====================================================================*/ 435/*====================================================================*/
@@ -521,7 +442,6 @@ static int __init init_avma1_cs(void)
521static void __exit exit_avma1_cs(void) 442static void __exit exit_avma1_cs(void)
522{ 443{
523 pcmcia_unregister_driver(&avma1cs_driver); 444 pcmcia_unregister_driver(&avma1cs_driver);
524 BUG_ON(dev_list != NULL);
525} 445}
526 446
527module_init(init_avma1_cs); 447module_init(init_avma1_cs);
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index 6fc6868de0b0..062fb8f0739f 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -96,8 +96,6 @@ module_param(protocol, int, 0);
96 96
97static void elsa_cs_config(dev_link_t *link); 97static void elsa_cs_config(dev_link_t *link);
98static void elsa_cs_release(dev_link_t *link); 98static void elsa_cs_release(dev_link_t *link);
99static int elsa_cs_event(event_t event, int priority,
100 event_callback_args_t *args);
101 99
102/* 100/*
103 The attach() and detach() entry points are used to create and destroy 101 The attach() and detach() entry points are used to create and destroy
@@ -105,39 +103,9 @@ static int elsa_cs_event(event_t event, int priority,
105 needed to manage one actual PCMCIA card. 103 needed to manage one actual PCMCIA card.
106*/ 104*/
107 105
108static dev_link_t *elsa_cs_attach(void); 106static void elsa_cs_detach(struct pcmcia_device *p_dev);
109static void elsa_cs_detach(dev_link_t *);
110 107
111/* 108/*
112 The dev_info variable is the "key" that is used to match up this
113 device driver with appropriate cards, through the card configuration
114 database.
115*/
116
117static dev_info_t dev_info = "elsa_cs";
118
119/*
120 A linked list of "instances" of the elsa_cs device. Each actual
121 PCMCIA card corresponds to one device instance, and is described
122 by one dev_link_t structure (defined in ds.h).
123
124 You may not want to use a linked list for this -- for example, the
125 memory card driver uses an array of dev_link_t pointers, where minor
126 device numbers are used to derive the corresponding array index.
127*/
128
129static dev_link_t *dev_list = NULL;
130
131/*
132 A dev_link_t structure has fields for most things that are needed
133 to keep track of a socket, but there will usually be some device
134 specific information that also needs to be kept track of. The
135 'priv' pointer in a dev_link_t structure can be used to point to
136 a device-specific private data structure, like this.
137
138 To simplify the data structure handling, we actually include the
139 dev_link_t structure in the device's private data structure.
140
141 A driver needs to provide a dev_node_t structure for each device 109 A driver needs to provide a dev_node_t structure for each device
142 on a card. In some cases, there is only one device per card (for 110 on a card. In some cases, there is only one device per card (for
143 example, ethernet cards, modems). In other cases, there may be 111 example, ethernet cards, modems). In other cases, there may be
@@ -171,18 +139,16 @@ typedef struct local_info_t {
171 139
172======================================================================*/ 140======================================================================*/
173 141
174static dev_link_t *elsa_cs_attach(void) 142static int elsa_cs_attach(struct pcmcia_device *p_dev)
175{ 143{
176 client_reg_t client_reg;
177 dev_link_t *link; 144 dev_link_t *link;
178 local_info_t *local; 145 local_info_t *local;
179 int ret;
180 146
181 DEBUG(0, "elsa_cs_attach()\n"); 147 DEBUG(0, "elsa_cs_attach()\n");
182 148
183 /* Allocate space for private device-specific data */ 149 /* Allocate space for private device-specific data */
184 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 150 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
185 if (!local) return NULL; 151 if (!local) return -ENOMEM;
186 memset(local, 0, sizeof(local_info_t)); 152 memset(local, 0, sizeof(local_info_t));
187 local->cardnr = -1; 153 local->cardnr = -1;
188 link = &local->link; link->priv = local; 154 link = &local->link; link->priv = local;
@@ -207,20 +173,13 @@ static dev_link_t *elsa_cs_attach(void)
207 link->conf.Vcc = 50; 173 link->conf.Vcc = 50;
208 link->conf.IntType = INT_MEMORY_AND_IO; 174 link->conf.IntType = INT_MEMORY_AND_IO;
209 175
210 /* Register with Card Services */ 176 link->handle = p_dev;
211 link->next = dev_list; 177 p_dev->instance = link;
212 dev_list = link;
213 client_reg.dev_info = &dev_info;
214 client_reg.Version = 0x0210;
215 client_reg.event_callback_args.client_data = link;
216 ret = pcmcia_register_client(&link->handle, &client_reg);
217 if (ret != CS_SUCCESS) {
218 cs_error(link->handle, RegisterClient, ret);
219 elsa_cs_detach(link);
220 return NULL;
221 }
222 178
223 return link; 179 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
180 elsa_cs_config(link);
181
182 return 0;
224} /* elsa_cs_attach */ 183} /* elsa_cs_attach */
225 184
226/*====================================================================== 185/*======================================================================
@@ -232,32 +191,18 @@ static dev_link_t *elsa_cs_attach(void)
232 191
233======================================================================*/ 192======================================================================*/
234 193
235static void elsa_cs_detach(dev_link_t *link) 194static void elsa_cs_detach(struct pcmcia_device *p_dev)
236{ 195{
237 dev_link_t **linkp; 196 dev_link_t *link = dev_to_instance(p_dev);
238 local_info_t *info = link->priv; 197 local_info_t *info = link->priv;
239 int ret;
240 198
241 DEBUG(0, "elsa_cs_detach(0x%p)\n", link); 199 DEBUG(0, "elsa_cs_detach(0x%p)\n", link);
242 200
243 /* Locate device structure */ 201 if (link->state & DEV_CONFIG) {
244 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 202 info->busy = 1;
245 if (*linkp == link) break; 203 elsa_cs_release(link);
246 if (*linkp == NULL)
247 return;
248
249 if (link->state & DEV_CONFIG)
250 elsa_cs_release(link);
251
252 /* Break the link with Card Services */
253 if (link->handle) {
254 ret = pcmcia_deregister_client(link->handle);
255 if (ret != CS_SUCCESS)
256 cs_error(link->handle, DeregisterClient, ret);
257 } 204 }
258 205
259 /* Unlink device structure and free it */
260 *linkp = link->next;
261 kfree(info); 206 kfree(info);
262 207
263} /* elsa_cs_detach */ 208} /* elsa_cs_detach */
@@ -447,60 +392,31 @@ static void elsa_cs_release(dev_link_t *link)
447 link->state &= ~DEV_CONFIG; 392 link->state &= ~DEV_CONFIG;
448} /* elsa_cs_release */ 393} /* elsa_cs_release */
449 394
450/*====================================================================== 395static int elsa_suspend(struct pcmcia_device *p_dev)
451 396{
452 The card status event handler. Mostly, this schedules other 397 dev_link_t *link = dev_to_instance(p_dev);
453 stuff to run after an event is received. A CARD_REMOVAL event 398 local_info_t *dev = link->priv;
454 also sets some flags to discourage the net drivers from trying
455 to talk to the card any more.
456 399
457 When a CARD_REMOVAL event is received, we immediately set a flag 400 link->state |= DEV_SUSPEND;
458 to block future accesses to this device. All the functions that 401 dev->busy = 1;
459 actually access the device should check this flag to make sure 402 if (link->state & DEV_CONFIG)
460 the card is still present. 403 pcmcia_release_configuration(link->handle);
461 404
462======================================================================*/ 405 return 0;
406}
463 407
464static int elsa_cs_event(event_t event, int priority, 408static int elsa_resume(struct pcmcia_device *p_dev)
465 event_callback_args_t *args)
466{ 409{
467 dev_link_t *link = args->client_data; 410 dev_link_t *link = dev_to_instance(p_dev);
468 local_info_t *dev = link->priv; 411 local_info_t *dev = link->priv;
469
470 DEBUG(1, "elsa_cs_event(%d)\n", event);
471 412
472 switch (event) { 413 link->state &= ~DEV_SUSPEND;
473 case CS_EVENT_CARD_REMOVAL: 414 if (link->state & DEV_CONFIG)
474 link->state &= ~DEV_PRESENT; 415 pcmcia_request_configuration(link->handle, &link->conf);
475 if (link->state & DEV_CONFIG) {
476 ((local_info_t*)link->priv)->busy = 1;
477 elsa_cs_release(link);
478 }
479 break;
480 case CS_EVENT_CARD_INSERTION:
481 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
482 elsa_cs_config(link);
483 break;
484 case CS_EVENT_PM_SUSPEND:
485 link->state |= DEV_SUSPEND;
486 /* Fall through... */
487 case CS_EVENT_RESET_PHYSICAL:
488 /* Mark the device as stopped, to block IO until later */
489 dev->busy = 1;
490 if (link->state & DEV_CONFIG)
491 pcmcia_release_configuration(link->handle);
492 break;
493 case CS_EVENT_PM_RESUME:
494 link->state &= ~DEV_SUSPEND;
495 /* Fall through... */
496 case CS_EVENT_CARD_RESET:
497 if (link->state & DEV_CONFIG)
498 pcmcia_request_configuration(link->handle, &link->conf);
499 dev->busy = 0; 416 dev->busy = 0;
500 break; 417
501 } 418 return 0;
502 return 0; 419}
503} /* elsa_cs_event */
504 420
505static struct pcmcia_device_id elsa_ids[] = { 421static struct pcmcia_device_id elsa_ids[] = {
506 PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257), 422 PCMCIA_DEVICE_PROD_ID12("ELSA AG (Aachen, Germany)", "MicroLink ISDN/MC ", 0x983de2c4, 0x333ba257),
@@ -514,10 +430,11 @@ static struct pcmcia_driver elsa_cs_driver = {
514 .drv = { 430 .drv = {
515 .name = "elsa_cs", 431 .name = "elsa_cs",
516 }, 432 },
517 .attach = elsa_cs_attach, 433 .probe = elsa_cs_attach,
518 .event = elsa_cs_event, 434 .remove = elsa_cs_detach,
519 .detach = elsa_cs_detach,
520 .id_table = elsa_ids, 435 .id_table = elsa_ids,
436 .suspend = elsa_suspend,
437 .resume = elsa_resume,
521}; 438};
522 439
523static int __init init_elsa_cs(void) 440static int __init init_elsa_cs(void)
@@ -528,7 +445,6 @@ static int __init init_elsa_cs(void)
528static void __exit exit_elsa_cs(void) 445static void __exit exit_elsa_cs(void)
529{ 446{
530 pcmcia_unregister_driver(&elsa_cs_driver); 447 pcmcia_unregister_driver(&elsa_cs_driver);
531 BUG_ON(dev_list != NULL);
532} 448}
533 449
534module_init(init_elsa_cs); 450module_init(init_elsa_cs);
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index f8457ef48826..ca5b4a3b683e 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -1715,7 +1715,6 @@ hfc_usb_disconnect(struct usb_interface
1715/* our driver information structure */ 1715/* our driver information structure */
1716/************************************/ 1716/************************************/
1717static struct usb_driver hfc_drv = { 1717static struct usb_driver hfc_drv = {
1718 .owner = THIS_MODULE,
1719 .name = "hfc_usb", 1718 .name = "hfc_usb",
1720 .id_table = hfcusb_idtab, 1719 .id_table = hfcusb_idtab,
1721 .probe = hfc_usb_probe, 1720 .probe = hfc_usb_probe,
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index dc334aab433e..6f5213a18a8d 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -97,8 +97,6 @@ module_param(protocol, int, 0);
97 97
98static void sedlbauer_config(dev_link_t *link); 98static void sedlbauer_config(dev_link_t *link);
99static void sedlbauer_release(dev_link_t *link); 99static void sedlbauer_release(dev_link_t *link);
100static int sedlbauer_event(event_t event, int priority,
101 event_callback_args_t *args);
102 100
103/* 101/*
104 The attach() and detach() entry points are used to create and destroy 102 The attach() and detach() entry points are used to create and destroy
@@ -106,8 +104,7 @@ static int sedlbauer_event(event_t event, int priority,
106 needed to manage one actual PCMCIA card. 104 needed to manage one actual PCMCIA card.
107*/ 105*/
108 106
109static dev_link_t *sedlbauer_attach(void); 107static void sedlbauer_detach(struct pcmcia_device *p_dev);
110static void sedlbauer_detach(dev_link_t *);
111 108
112/* 109/*
113 You'll also need to prototype all the functions that will actually 110 You'll also need to prototype all the functions that will actually
@@ -117,35 +114,6 @@ static void sedlbauer_detach(dev_link_t *);
117*/ 114*/
118 115
119/* 116/*
120 The dev_info variable is the "key" that is used to match up this
121 device driver with appropriate cards, through the card configuration
122 database.
123*/
124
125static dev_info_t dev_info = "sedlbauer_cs";
126
127/*
128 A linked list of "instances" of the sedlbauer device. Each actual
129 PCMCIA card corresponds to one device instance, and is described
130 by one dev_link_t structure (defined in ds.h).
131
132 You may not want to use a linked list for this -- for example, the
133 memory card driver uses an array of dev_link_t pointers, where minor
134 device numbers are used to derive the corresponding array index.
135*/
136
137static dev_link_t *dev_list = NULL;
138
139/*
140 A dev_link_t structure has fields for most things that are needed
141 to keep track of a socket, but there will usually be some device
142 specific information that also needs to be kept track of. The
143 'priv' pointer in a dev_link_t structure can be used to point to
144 a device-specific private data structure, like this.
145
146 To simplify the data structure handling, we actually include the
147 dev_link_t structure in the device's private data structure.
148
149 A driver needs to provide a dev_node_t structure for each device 117 A driver needs to provide a dev_node_t structure for each device
150 on a card. In some cases, there is only one device per card (for 118 on a card. In some cases, there is only one device per card (for
151 example, ethernet cards, modems). In other cases, there may be 119 example, ethernet cards, modems). In other cases, there may be
@@ -180,18 +148,16 @@ typedef struct local_info_t {
180 148
181======================================================================*/ 149======================================================================*/
182 150
183static dev_link_t *sedlbauer_attach(void) 151static int sedlbauer_attach(struct pcmcia_device *p_dev)
184{ 152{
185 local_info_t *local; 153 local_info_t *local;
186 dev_link_t *link; 154 dev_link_t *link;
187 client_reg_t client_reg;
188 int ret;
189 155
190 DEBUG(0, "sedlbauer_attach()\n"); 156 DEBUG(0, "sedlbauer_attach()\n");
191 157
192 /* Allocate space for private device-specific data */ 158 /* Allocate space for private device-specific data */
193 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 159 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
194 if (!local) return NULL; 160 if (!local) return -ENOMEM;
195 memset(local, 0, sizeof(local_info_t)); 161 memset(local, 0, sizeof(local_info_t));
196 local->cardnr = -1; 162 local->cardnr = -1;
197 link = &local->link; link->priv = local; 163 link = &local->link; link->priv = local;
@@ -221,20 +187,13 @@ static dev_link_t *sedlbauer_attach(void)
221 link->conf.Vcc = 50; 187 link->conf.Vcc = 50;
222 link->conf.IntType = INT_MEMORY_AND_IO; 188 link->conf.IntType = INT_MEMORY_AND_IO;
223 189
224 /* Register with Card Services */ 190 link->handle = p_dev;
225 link->next = dev_list; 191 p_dev->instance = link;
226 dev_list = link; 192
227 client_reg.dev_info = &dev_info; 193 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
228 client_reg.Version = 0x0210; 194 sedlbauer_config(link);
229 client_reg.event_callback_args.client_data = link;
230 ret = pcmcia_register_client(&link->handle, &client_reg);
231 if (ret != CS_SUCCESS) {
232 cs_error(link->handle, RegisterClient, ret);
233 sedlbauer_detach(link);
234 return NULL;
235 }
236 195
237 return link; 196 return 0;
238} /* sedlbauer_attach */ 197} /* sedlbauer_attach */
239 198
240/*====================================================================== 199/*======================================================================
@@ -246,39 +205,17 @@ static dev_link_t *sedlbauer_attach(void)
246 205
247======================================================================*/ 206======================================================================*/
248 207
249static void sedlbauer_detach(dev_link_t *link) 208static void sedlbauer_detach(struct pcmcia_device *p_dev)
250{ 209{
251 dev_link_t **linkp; 210 dev_link_t *link = dev_to_instance(p_dev);
252 211
253 DEBUG(0, "sedlbauer_detach(0x%p)\n", link); 212 DEBUG(0, "sedlbauer_detach(0x%p)\n", link);
254
255 /* Locate device structure */
256 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
257 if (*linkp == link) break;
258 if (*linkp == NULL)
259 return;
260 213
261 /*
262 If the device is currently configured and active, we won't
263 actually delete it yet. Instead, it is marked so that when
264 the release() function is called, that will trigger a proper
265 detach().
266 */
267 if (link->state & DEV_CONFIG) { 214 if (link->state & DEV_CONFIG) {
268#ifdef PCMCIA_DEBUG 215 ((local_info_t *)link->priv)->stop = 1;
269 printk(KERN_DEBUG "sedlbauer_cs: detach postponed, '%s' " 216 sedlbauer_release(link);
270 "still locked\n", link->dev->dev_name);
271#endif
272 link->state |= DEV_STALE_LINK;
273 return;
274 } 217 }
275 218
276 /* Break the link with Card Services */
277 if (link->handle)
278 pcmcia_deregister_client(link->handle);
279
280 /* Unlink device structure, and free it */
281 *linkp = link->next;
282 /* This points to the parent local_info_t struct */ 219 /* This points to the parent local_info_t struct */
283 kfree(link->priv); 220 kfree(link->priv);
284} /* sedlbauer_detach */ 221} /* sedlbauer_detach */
@@ -547,68 +484,34 @@ static void sedlbauer_release(dev_link_t *link)
547 if (link->irq.AssignedIRQ) 484 if (link->irq.AssignedIRQ)
548 pcmcia_release_irq(link->handle, &link->irq); 485 pcmcia_release_irq(link->handle, &link->irq);
549 link->state &= ~DEV_CONFIG; 486 link->state &= ~DEV_CONFIG;
550
551 if (link->state & DEV_STALE_LINK)
552 sedlbauer_detach(link);
553
554} /* sedlbauer_release */ 487} /* sedlbauer_release */
555 488
556/*====================================================================== 489static int sedlbauer_suspend(struct pcmcia_device *p_dev)
557
558 The card status event handler. Mostly, this schedules other
559 stuff to run after an event is received.
560
561 When a CARD_REMOVAL event is received, we immediately set a
562 private flag to block future accesses to this device. All the
563 functions that actually access the device should check this flag
564 to make sure the card is still present.
565
566======================================================================*/
567
568static int sedlbauer_event(event_t event, int priority,
569 event_callback_args_t *args)
570{ 490{
571 dev_link_t *link = args->client_data; 491 dev_link_t *link = dev_to_instance(p_dev);
572 local_info_t *dev = link->priv; 492 local_info_t *dev = link->priv;
573 493
574 DEBUG(1, "sedlbauer_event(0x%06x)\n", event);
575
576 switch (event) {
577 case CS_EVENT_CARD_REMOVAL:
578 link->state &= ~DEV_PRESENT;
579 if (link->state & DEV_CONFIG) {
580 ((local_info_t *)link->priv)->stop = 1;
581 sedlbauer_release(link);
582 }
583 break;
584 case CS_EVENT_CARD_INSERTION:
585 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
586 sedlbauer_config(link);
587 break;
588 case CS_EVENT_PM_SUSPEND:
589 link->state |= DEV_SUSPEND; 494 link->state |= DEV_SUSPEND;
590 /* Fall through... */
591 case CS_EVENT_RESET_PHYSICAL:
592 /* Mark the device as stopped, to block IO until later */
593 dev->stop = 1; 495 dev->stop = 1;
594 if (link->state & DEV_CONFIG) 496 if (link->state & DEV_CONFIG)
595 pcmcia_release_configuration(link->handle); 497 pcmcia_release_configuration(link->handle);
596 break; 498
597 case CS_EVENT_PM_RESUME: 499 return 0;
500}
501
502static int sedlbauer_resume(struct pcmcia_device *p_dev)
503{
504 dev_link_t *link = dev_to_instance(p_dev);
505 local_info_t *dev = link->priv;
506
598 link->state &= ~DEV_SUSPEND; 507 link->state &= ~DEV_SUSPEND;
599 /* Fall through... */
600 case CS_EVENT_CARD_RESET:
601 if (link->state & DEV_CONFIG) 508 if (link->state & DEV_CONFIG)
602 pcmcia_request_configuration(link->handle, &link->conf); 509 pcmcia_request_configuration(link->handle, &link->conf);
603 dev->stop = 0; 510 dev->stop = 0;
604 /* 511
605 In a normal driver, additional code may go here to restore 512 return 0;
606 the device state and restart IO. 513}
607 */ 514
608 break;
609 }
610 return 0;
611} /* sedlbauer_event */
612 515
613static struct pcmcia_device_id sedlbauer_ids[] = { 516static struct pcmcia_device_id sedlbauer_ids[] = {
614 PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a), 517 PCMCIA_DEVICE_PROD_ID123("SEDLBAUER", "speed star II", "V 3.1", 0x81fb79f5, 0xf3612e1d, 0x6b95c78a),
@@ -627,10 +530,11 @@ static struct pcmcia_driver sedlbauer_driver = {
627 .drv = { 530 .drv = {
628 .name = "sedlbauer_cs", 531 .name = "sedlbauer_cs",
629 }, 532 },
630 .attach = sedlbauer_attach, 533 .probe = sedlbauer_attach,
631 .event = sedlbauer_event, 534 .remove = sedlbauer_detach,
632 .detach = sedlbauer_detach,
633 .id_table = sedlbauer_ids, 535 .id_table = sedlbauer_ids,
536 .suspend = sedlbauer_suspend,
537 .resume = sedlbauer_resume,
634}; 538};
635 539
636static int __init init_sedlbauer_cs(void) 540static int __init init_sedlbauer_cs(void)
@@ -641,7 +545,6 @@ static int __init init_sedlbauer_cs(void)
641static void __exit exit_sedlbauer_cs(void) 545static void __exit exit_sedlbauer_cs(void)
642{ 546{
643 pcmcia_unregister_driver(&sedlbauer_driver); 547 pcmcia_unregister_driver(&sedlbauer_driver);
644 BUG_ON(dev_list != NULL);
645} 548}
646 549
647module_init(init_sedlbauer_cs); 550module_init(init_sedlbauer_cs);
diff --git a/drivers/isdn/hisax/st5481_init.c b/drivers/isdn/hisax/st5481_init.c
index 8e192a3a3490..99cb0f3d59a1 100644
--- a/drivers/isdn/hisax/st5481_init.c
+++ b/drivers/isdn/hisax/st5481_init.c
@@ -180,7 +180,6 @@ static struct usb_device_id st5481_ids[] = {
180MODULE_DEVICE_TABLE (usb, st5481_ids); 180MODULE_DEVICE_TABLE (usb, st5481_ids);
181 181
182static struct usb_driver st5481_usb_driver = { 182static struct usb_driver st5481_usb_driver = {
183 .owner = THIS_MODULE,
184 .name = "st5481_usb", 183 .name = "st5481_usb",
185 .probe = probe_st5481, 184 .probe = probe_st5481,
186 .disconnect = disconnect_st5481, 185 .disconnect = disconnect_st5481,
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index 0ddef1bf778b..4e5c14c7240e 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -77,8 +77,6 @@ module_param(protocol, int, 0);
77 77
78static void teles_cs_config(dev_link_t *link); 78static void teles_cs_config(dev_link_t *link);
79static void teles_cs_release(dev_link_t *link); 79static void teles_cs_release(dev_link_t *link);
80static int teles_cs_event(event_t event, int priority,
81 event_callback_args_t *args);
82 80
83/* 81/*
84 The attach() and detach() entry points are used to create and destroy 82 The attach() and detach() entry points are used to create and destroy
@@ -86,16 +84,7 @@ static int teles_cs_event(event_t event, int priority,
86 needed to manage one actual PCMCIA card. 84 needed to manage one actual PCMCIA card.
87*/ 85*/
88 86
89static dev_link_t *teles_attach(void); 87static void teles_detach(struct pcmcia_device *p_dev);
90static void teles_detach(dev_link_t *);
91
92/*
93 The dev_info variable is the "key" that is used to match up this
94 device driver with appropriate cards, through the card configuration
95 database.
96*/
97
98static dev_info_t dev_info = "teles_cs";
99 88
100/* 89/*
101 A linked list of "instances" of the teles_cs device. Each actual 90 A linked list of "instances" of the teles_cs device. Each actual
@@ -107,18 +96,7 @@ static dev_info_t dev_info = "teles_cs";
107 device numbers are used to derive the corresponding array index. 96 device numbers are used to derive the corresponding array index.
108*/ 97*/
109 98
110static dev_link_t *dev_list = NULL;
111
112/* 99/*
113 A dev_link_t structure has fields for most things that are needed
114 to keep track of a socket, but there will usually be some device
115 specific information that also needs to be kept track of. The
116 'priv' pointer in a dev_link_t structure can be used to point to
117 a device-specific private data structure, like this.
118
119 To simplify the data structure handling, we actually include the
120 dev_link_t structure in the device's private data structure.
121
122 A driver needs to provide a dev_node_t structure for each device 100 A driver needs to provide a dev_node_t structure for each device
123 on a card. In some cases, there is only one device per card (for 101 on a card. In some cases, there is only one device per card (for
124 example, ethernet cards, modems). In other cases, there may be 102 example, ethernet cards, modems). In other cases, there may be
@@ -152,18 +130,16 @@ typedef struct local_info_t {
152 130
153======================================================================*/ 131======================================================================*/
154 132
155static dev_link_t *teles_attach(void) 133static int teles_attach(struct pcmcia_device *p_dev)
156{ 134{
157 client_reg_t client_reg;
158 dev_link_t *link; 135 dev_link_t *link;
159 local_info_t *local; 136 local_info_t *local;
160 int ret;
161 137
162 DEBUG(0, "teles_attach()\n"); 138 DEBUG(0, "teles_attach()\n");
163 139
164 /* Allocate space for private device-specific data */ 140 /* Allocate space for private device-specific data */
165 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 141 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
166 if (!local) return NULL; 142 if (!local) return -ENOMEM;
167 memset(local, 0, sizeof(local_info_t)); 143 memset(local, 0, sizeof(local_info_t));
168 local->cardnr = -1; 144 local->cardnr = -1;
169 link = &local->link; link->priv = local; 145 link = &local->link; link->priv = local;
@@ -188,20 +164,13 @@ static dev_link_t *teles_attach(void)
188 link->conf.Vcc = 50; 164 link->conf.Vcc = 50;
189 link->conf.IntType = INT_MEMORY_AND_IO; 165 link->conf.IntType = INT_MEMORY_AND_IO;
190 166
191 /* Register with Card Services */ 167 link->handle = p_dev;
192 link->next = dev_list; 168 p_dev->instance = link;
193 dev_list = link; 169
194 client_reg.dev_info = &dev_info; 170 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
195 client_reg.Version = 0x0210; 171 teles_cs_config(link);
196 client_reg.event_callback_args.client_data = link;
197 ret = pcmcia_register_client(&link->handle, &client_reg);
198 if (ret != CS_SUCCESS) {
199 cs_error(link->handle, RegisterClient, ret);
200 teles_detach(link);
201 return NULL;
202 }
203 172
204 return link; 173 return 0;
205} /* teles_attach */ 174} /* teles_attach */
206 175
207/*====================================================================== 176/*======================================================================
@@ -213,32 +182,18 @@ static dev_link_t *teles_attach(void)
213 182
214======================================================================*/ 183======================================================================*/
215 184
216static void teles_detach(dev_link_t *link) 185static void teles_detach(struct pcmcia_device *p_dev)
217{ 186{
218 dev_link_t **linkp; 187 dev_link_t *link = dev_to_instance(p_dev);
219 local_info_t *info = link->priv; 188 local_info_t *info = link->priv;
220 int ret;
221 189
222 DEBUG(0, "teles_detach(0x%p)\n", link); 190 DEBUG(0, "teles_detach(0x%p)\n", link);
223 191
224 /* Locate device structure */ 192 if (link->state & DEV_CONFIG) {
225 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 193 info->busy = 1;
226 if (*linkp == link) break; 194 teles_cs_release(link);
227 if (*linkp == NULL)
228 return;
229
230 if (link->state & DEV_CONFIG)
231 teles_cs_release(link);
232
233 /* Break the link with Card Services */
234 if (link->handle) {
235 ret = pcmcia_deregister_client(link->handle);
236 if (ret != CS_SUCCESS)
237 cs_error(link->handle, DeregisterClient, ret);
238 } 195 }
239 196
240 /* Unlink device structure and free it */
241 *linkp = link->next;
242 kfree(info); 197 kfree(info);
243 198
244} /* teles_detach */ 199} /* teles_detach */
@@ -428,60 +383,32 @@ static void teles_cs_release(dev_link_t *link)
428 link->state &= ~DEV_CONFIG; 383 link->state &= ~DEV_CONFIG;
429} /* teles_cs_release */ 384} /* teles_cs_release */
430 385
431/*====================================================================== 386static int teles_suspend(struct pcmcia_device *p_dev)
432 387{
433 The card status event handler. Mostly, this schedules other 388 dev_link_t *link = dev_to_instance(p_dev);
434 stuff to run after an event is received. A CARD_REMOVAL event 389 local_info_t *dev = link->priv;
435 also sets some flags to discourage the net drivers from trying
436 to talk to the card any more.
437 390
438 When a CARD_REMOVAL event is received, we immediately set a flag 391 link->state |= DEV_SUSPEND;
439 to block future accesses to this device. All the functions that 392 dev->busy = 1;
440 actually access the device should check this flag to make sure 393 if (link->state & DEV_CONFIG)
441 the card is still present. 394 pcmcia_release_configuration(link->handle);
442 395
443======================================================================*/ 396 return 0;
397}
444 398
445static int teles_cs_event(event_t event, int priority, 399static int teles_resume(struct pcmcia_device *p_dev)
446 event_callback_args_t *args)
447{ 400{
448 dev_link_t *link = args->client_data; 401 dev_link_t *link = dev_to_instance(p_dev);
449 local_info_t *dev = link->priv; 402 local_info_t *dev = link->priv;
450
451 DEBUG(1, "teles_cs_event(%d)\n", event);
452 403
453 switch (event) { 404 link->state &= ~DEV_SUSPEND;
454 case CS_EVENT_CARD_REMOVAL: 405 if (link->state & DEV_CONFIG)
455 link->state &= ~DEV_PRESENT; 406 pcmcia_request_configuration(link->handle, &link->conf);
456 if (link->state & DEV_CONFIG) {
457 ((local_info_t*)link->priv)->busy = 1;
458 teles_cs_release(link);
459 }
460 break;
461 case CS_EVENT_CARD_INSERTION:
462 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
463 teles_cs_config(link);
464 break;
465 case CS_EVENT_PM_SUSPEND:
466 link->state |= DEV_SUSPEND;
467 /* Fall through... */
468 case CS_EVENT_RESET_PHYSICAL:
469 /* Mark the device as stopped, to block IO until later */
470 dev->busy = 1;
471 if (link->state & DEV_CONFIG)
472 pcmcia_release_configuration(link->handle);
473 break;
474 case CS_EVENT_PM_RESUME:
475 link->state &= ~DEV_SUSPEND;
476 /* Fall through... */
477 case CS_EVENT_CARD_RESET:
478 if (link->state & DEV_CONFIG)
479 pcmcia_request_configuration(link->handle, &link->conf);
480 dev->busy = 0; 407 dev->busy = 0;
481 break; 408
482 } 409 return 0;
483 return 0; 410}
484} /* teles_cs_event */ 411
485 412
486static struct pcmcia_device_id teles_ids[] = { 413static struct pcmcia_device_id teles_ids[] = {
487 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119), 414 PCMCIA_DEVICE_PROD_ID12("TELES", "S0/PC", 0x67b50eae, 0xe9e70119),
@@ -494,10 +421,11 @@ static struct pcmcia_driver teles_cs_driver = {
494 .drv = { 421 .drv = {
495 .name = "teles_cs", 422 .name = "teles_cs",
496 }, 423 },
497 .attach = teles_attach, 424 .probe = teles_attach,
498 .event = teles_cs_event, 425 .remove = teles_detach,
499 .detach = teles_detach,
500 .id_table = teles_ids, 426 .id_table = teles_ids,
427 .suspend = teles_suspend,
428 .resume = teles_resume,
501}; 429};
502 430
503static int __init init_teles_cs(void) 431static int __init init_teles_cs(void)
@@ -508,7 +436,6 @@ static int __init init_teles_cs(void)
508static void __exit exit_teles_cs(void) 436static void __exit exit_teles_cs(void)
509{ 437{
510 pcmcia_unregister_driver(&teles_cs_driver); 438 pcmcia_unregister_driver(&teles_cs_driver);
511 BUG_ON(dev_list != NULL);
512} 439}
513 440
514module_init(init_teles_cs); 441module_init(init_teles_cs);
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index c34c96d18907..228e1852a836 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -128,7 +128,7 @@ static int macio_device_resume(struct device * dev)
128 return 0; 128 return 0;
129} 129}
130 130
131static int macio_hotplug (struct device *dev, char **envp, int num_envp, 131static int macio_uevent(struct device *dev, char **envp, int num_envp,
132 char *buffer, int buffer_size) 132 char *buffer, int buffer_size)
133{ 133{
134 struct macio_dev * macio_dev; 134 struct macio_dev * macio_dev;
@@ -203,7 +203,7 @@ extern struct device_attribute macio_dev_attrs[];
203struct bus_type macio_bus_type = { 203struct bus_type macio_bus_type = {
204 .name = "macio", 204 .name = "macio",
205 .match = macio_bus_match, 205 .match = macio_bus_match,
206 .hotplug = macio_hotplug, 206 .uevent = macio_uevent,
207 .suspend = macio_device_suspend, 207 .suspend = macio_device_suspend,
208 .resume = macio_device_resume, 208 .resume = macio_device_resume,
209 .dev_attrs = macio_dev_attrs, 209 .dev_attrs = macio_dev_attrs,
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c
index f38696622eb4..5ebfd1d138da 100644
--- a/drivers/macintosh/therm_adt746x.c
+++ b/drivers/macintosh/therm_adt746x.c
@@ -52,6 +52,7 @@ static char *sensor_location[3] = {NULL, NULL, NULL};
52 52
53static int limit_adjust = 0; 53static int limit_adjust = 0;
54static int fan_speed = -1; 54static int fan_speed = -1;
55static int verbose = 0;
55 56
56MODULE_AUTHOR("Colin Leroy <colin@colino.net>"); 57MODULE_AUTHOR("Colin Leroy <colin@colino.net>");
57MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and " 58MODULE_DESCRIPTION("Driver for ADT746x thermostat in iBook G4 and "
@@ -66,6 +67,10 @@ module_param(fan_speed, int, 0644);
66MODULE_PARM_DESC(fan_speed,"Specify starting fan speed (0-255) " 67MODULE_PARM_DESC(fan_speed,"Specify starting fan speed (0-255) "
67 "(default 64)"); 68 "(default 64)");
68 69
70module_param(verbose, bool, 0);
71MODULE_PARM_DESC(verbose,"Verbose log operations "
72 "(default 0)");
73
69struct thermostat { 74struct thermostat {
70 struct i2c_client clt; 75 struct i2c_client clt;
71 u8 temps[3]; 76 u8 temps[3];
@@ -149,13 +154,13 @@ detach_thermostat(struct i2c_adapter *adapter)
149 if (thread_therm != NULL) { 154 if (thread_therm != NULL) {
150 kthread_stop(thread_therm); 155 kthread_stop(thread_therm);
151 } 156 }
152 157
153 printk(KERN_INFO "adt746x: Putting max temperatures back from " 158 printk(KERN_INFO "adt746x: Putting max temperatures back from "
154 "%d, %d, %d to %d, %d, %d\n", 159 "%d, %d, %d to %d, %d, %d\n",
155 th->limits[0], th->limits[1], th->limits[2], 160 th->limits[0], th->limits[1], th->limits[2],
156 th->initial_limits[0], th->initial_limits[1], 161 th->initial_limits[0], th->initial_limits[1],
157 th->initial_limits[2]); 162 th->initial_limits[2]);
158 163
159 for (i = 0; i < 3; i++) 164 for (i = 0; i < 3; i++)
160 write_reg(th, LIMIT_REG[i], th->initial_limits[i]); 165 write_reg(th, LIMIT_REG[i], th->initial_limits[i]);
161 166
@@ -171,9 +176,9 @@ detach_thermostat(struct i2c_adapter *adapter)
171} 176}
172 177
173static struct i2c_driver thermostat_driver = { 178static struct i2c_driver thermostat_driver = {
174 .owner = THIS_MODULE, 179 .driver = {
175 .name = "therm_adt746x", 180 .name = "therm_adt746x",
176 .flags = I2C_DF_NOTIFY, 181 },
177 .attach_adapter = attach_thermostat, 182 .attach_adapter = attach_thermostat,
178 .detach_adapter = detach_thermostat, 183 .detach_adapter = detach_thermostat,
179}; 184};
@@ -212,12 +217,14 @@ static void write_fan_speed(struct thermostat *th, int speed, int fan)
212 return; 217 return;
213 218
214 if (th->last_speed[fan] != speed) { 219 if (th->last_speed[fan] != speed) {
215 if (speed == -1) 220 if (verbose) {
216 printk(KERN_DEBUG "adt746x: Setting speed to automatic " 221 if (speed == -1)
217 "for %s fan.\n", sensor_location[fan+1]); 222 printk(KERN_DEBUG "adt746x: Setting speed to automatic "
218 else 223 "for %s fan.\n", sensor_location[fan+1]);
219 printk(KERN_DEBUG "adt746x: Setting speed to %d " 224 else
220 "for %s fan.\n", speed, sensor_location[fan+1]); 225 printk(KERN_DEBUG "adt746x: Setting speed to %d "
226 "for %s fan.\n", speed, sensor_location[fan+1]);
227 }
221 } else 228 } else
222 return; 229 return;
223 230
@@ -298,10 +305,11 @@ static void update_fans_speed (struct thermostat *th)
298 if (new_speed > 255) 305 if (new_speed > 255)
299 new_speed = 255; 306 new_speed = 255;
300 307
301 printk(KERN_DEBUG "adt746x: setting fans speed to %d " 308 if (verbose)
302 "(limit exceeded by %d on %s) \n", 309 printk(KERN_DEBUG "adt746x: Setting fans speed to %d "
303 new_speed, var, 310 "(limit exceeded by %d on %s) \n",
304 sensor_location[fan_number+1]); 311 new_speed, var,
312 sensor_location[fan_number+1]);
305 write_both_fan_speed(th, new_speed); 313 write_both_fan_speed(th, new_speed);
306 th->last_var[fan_number] = var; 314 th->last_var[fan_number] = var;
307 } else if (var < -2) { 315 } else if (var < -2) {
@@ -309,8 +317,9 @@ static void update_fans_speed (struct thermostat *th)
309 * so cold (lastvar >= -1) */ 317 * so cold (lastvar >= -1) */
310 if (i == 2 && lastvar < -1) { 318 if (i == 2 && lastvar < -1) {
311 if (th->last_speed[fan_number] != 0) 319 if (th->last_speed[fan_number] != 0)
312 printk(KERN_DEBUG "adt746x: Stopping " 320 if (verbose)
313 "fans.\n"); 321 printk(KERN_DEBUG "adt746x: Stopping "
322 "fans.\n");
314 write_both_fan_speed(th, 0); 323 write_both_fan_speed(th, 0);
315 } 324 }
316 } 325 }
@@ -406,7 +415,7 @@ static int attach_one_thermostat(struct i2c_adapter *adapter, int addr,
406 th->initial_limits[i] = read_reg(th, LIMIT_REG[i]); 415 th->initial_limits[i] = read_reg(th, LIMIT_REG[i]);
407 set_limit(th, i); 416 set_limit(th, i);
408 } 417 }
409 418
410 printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d" 419 printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d"
411 " to %d, %d, %d\n", 420 " to %d, %d, %d\n",
412 th->initial_limits[0], th->initial_limits[1], 421 th->initial_limits[0], th->initial_limits[1],
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 3fc8cdd94c3d..8d0958c38b6b 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -283,9 +283,9 @@ static int therm_pm72_detach(struct i2c_adapter *adapter);
283 283
284static struct i2c_driver therm_pm72_driver = 284static struct i2c_driver therm_pm72_driver =
285{ 285{
286 .owner = THIS_MODULE, 286 .driver = {
287 .name = "therm_pm72", 287 .name = "therm_pm72",
288 .flags = I2C_DF_NOTIFY, 288 },
289 .attach_adapter = therm_pm72_attach, 289 .attach_adapter = therm_pm72_attach,
290 .detach_adapter = therm_pm72_detach, 290 .detach_adapter = therm_pm72_detach,
291}; 291};
@@ -923,7 +923,7 @@ static void do_monitor_cpu_combined(void)
923 if (temp_combi >= ((state0->mpu.tmax + 8) << 16)) { 923 if (temp_combi >= ((state0->mpu.tmax + 8) << 16)) {
924 printk(KERN_WARNING "Warning ! Temperature way above maximum (%d) !\n", 924 printk(KERN_WARNING "Warning ! Temperature way above maximum (%d) !\n",
925 temp_combi >> 16); 925 temp_combi >> 16);
926 state0->overtemp = CPU_MAX_OVERTEMP; 926 state0->overtemp += CPU_MAX_OVERTEMP / 4;
927 } else if (temp_combi > (state0->mpu.tmax << 16)) 927 } else if (temp_combi > (state0->mpu.tmax << 16))
928 state0->overtemp++; 928 state0->overtemp++;
929 else 929 else
@@ -933,7 +933,7 @@ static void do_monitor_cpu_combined(void)
933 if (state0->overtemp > 0) { 933 if (state0->overtemp > 0) {
934 state0->rpm = state0->mpu.rmaxn_exhaust_fan; 934 state0->rpm = state0->mpu.rmaxn_exhaust_fan;
935 state0->intake_rpm = intake = state0->mpu.rmaxn_intake_fan; 935 state0->intake_rpm = intake = state0->mpu.rmaxn_intake_fan;
936 pump = state0->pump_min; 936 pump = state0->pump_max;
937 goto do_set_fans; 937 goto do_set_fans;
938 } 938 }
939 939
@@ -998,7 +998,7 @@ static void do_monitor_cpu_split(struct cpu_pid_state *state)
998 printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum" 998 printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum"
999 " (%d) !\n", 999 " (%d) !\n",
1000 state->index, temp >> 16); 1000 state->index, temp >> 16);
1001 state->overtemp = CPU_MAX_OVERTEMP; 1001 state->overtemp += CPU_MAX_OVERTEMP / 4;
1002 } else if (temp > (state->mpu.tmax << 16)) 1002 } else if (temp > (state->mpu.tmax << 16))
1003 state->overtemp++; 1003 state->overtemp++;
1004 else 1004 else
@@ -1060,7 +1060,7 @@ static void do_monitor_cpu_rack(struct cpu_pid_state *state)
1060 printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum" 1060 printk(KERN_WARNING "Warning ! CPU %d temperature way above maximum"
1061 " (%d) !\n", 1061 " (%d) !\n",
1062 state->index, temp >> 16); 1062 state->index, temp >> 16);
1063 state->overtemp = CPU_MAX_OVERTEMP; 1063 state->overtemp = CPU_MAX_OVERTEMP / 4;
1064 } else if (temp > (state->mpu.tmax << 16)) 1064 } else if (temp > (state->mpu.tmax << 16))
1065 state->overtemp++; 1065 state->overtemp++;
1066 else 1066 else
@@ -1988,18 +1988,13 @@ static void fcu_lookup_fans(struct device_node *fcu_node)
1988 1988
1989static int fcu_of_probe(struct of_device* dev, const struct of_device_id *match) 1989static int fcu_of_probe(struct of_device* dev, const struct of_device_id *match)
1990{ 1990{
1991 int rc;
1992
1993 state = state_detached; 1991 state = state_detached;
1994 1992
1995 /* Lookup the fans in the device tree */ 1993 /* Lookup the fans in the device tree */
1996 fcu_lookup_fans(dev->node); 1994 fcu_lookup_fans(dev->node);
1997 1995
1998 /* Add the driver */ 1996 /* Add the driver */
1999 rc = i2c_add_driver(&therm_pm72_driver); 1997 return i2c_add_driver(&therm_pm72_driver);
2000 if (rc < 0)
2001 return rc;
2002 return 0;
2003} 1998}
2004 1999
2005static int fcu_of_remove(struct of_device* dev) 2000static int fcu_of_remove(struct of_device* dev)
diff --git a/drivers/macintosh/therm_windtunnel.c b/drivers/macintosh/therm_windtunnel.c
index 6aaa1df1a64e..3d9dd2e166aa 100644
--- a/drivers/macintosh/therm_windtunnel.c
+++ b/drivers/macintosh/therm_windtunnel.c
@@ -354,10 +354,10 @@ do_detach( struct i2c_client *client )
354} 354}
355 355
356static struct i2c_driver g4fan_driver = { 356static struct i2c_driver g4fan_driver = {
357 .owner = THIS_MODULE, 357 .driver = {
358 .name = "therm_windtunnel", 358 .name = "therm_windtunnel",
359 },
359 .id = I2C_DRIVERID_G4FAN, 360 .id = I2C_DRIVERID_G4FAN,
360 .flags = I2C_DF_NOTIFY,
361 .attach_adapter = do_attach, 361 .attach_adapter = do_attach,
362 .detach_client = do_detach, 362 .detach_client = do_detach,
363}; 363};
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index a0a41ad0f2b5..57460e46c89f 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -47,9 +47,9 @@ static int wf_lm75_attach(struct i2c_adapter *adapter);
47static int wf_lm75_detach(struct i2c_client *client); 47static int wf_lm75_detach(struct i2c_client *client);
48 48
49static struct i2c_driver wf_lm75_driver = { 49static struct i2c_driver wf_lm75_driver = {
50 .owner = THIS_MODULE, 50 .driver = {
51 .name = "wf_lm75", 51 .name = "wf_lm75",
52 .flags = I2C_DF_NOTIFY, 52 },
53 .attach_adapter = wf_lm75_attach, 53 .attach_adapter = wf_lm75_attach,
54 .detach_client = wf_lm75_detach, 54 .detach_client = wf_lm75_detach,
55}; 55};
@@ -240,12 +240,7 @@ static int wf_lm75_detach(struct i2c_client *client)
240 240
241static int __init wf_lm75_sensor_init(void) 241static int __init wf_lm75_sensor_init(void)
242{ 242{
243 int rc; 243 return i2c_add_driver(&wf_lm75_driver);
244
245 rc = i2c_add_driver(&wf_lm75_driver);
246 if (rc < 0)
247 return rc;
248 return 0;
249} 244}
250 245
251static void __exit wf_lm75_sensor_exit(void) 246static void __exit wf_lm75_sensor_exit(void)
diff --git a/drivers/macintosh/windfarm_pm81.c b/drivers/macintosh/windfarm_pm81.c
index 322c74b2687f..80ddf9776bde 100644
--- a/drivers/macintosh/windfarm_pm81.c
+++ b/drivers/macintosh/windfarm_pm81.c
@@ -207,7 +207,7 @@ static struct wf_smu_sys_fans_param wf_smu_sys_all_params[] = {
207 }, 207 },
208 /* Model ID 3 */ 208 /* Model ID 3 */
209 { 209 {
210 .model_id = 2, 210 .model_id = 3,
211 .itarget = 0x350000, 211 .itarget = 0x350000,
212 .gd = 0x08e00000, 212 .gd = 0x08e00000,
213 .gp = 0x00566666, 213 .gp = 0x00566666,
@@ -219,7 +219,7 @@ static struct wf_smu_sys_fans_param wf_smu_sys_all_params[] = {
219 }, 219 },
220 /* Model ID 5 */ 220 /* Model ID 5 */
221 { 221 {
222 .model_id = 2, 222 .model_id = 5,
223 .itarget = 0x3a0000, 223 .itarget = 0x3a0000,
224 .gd = 0x15400000, 224 .gd = 0x15400000,
225 .gp = 0x00233333, 225 .gp = 0x00233333,
diff --git a/drivers/md/.gitignore b/drivers/md/.gitignore
new file mode 100644
index 000000000000..a7afec6b19c6
--- /dev/null
+++ b/drivers/md/.gitignore
@@ -0,0 +1,4 @@
1mktables
2raid6altivec*.c
3raid6int*.c
4raid6tables.c
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 252d55df9642..76a189ceb529 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -315,6 +315,8 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait)
315 if (bitmap->file == NULL) 315 if (bitmap->file == NULL)
316 return write_sb_page(bitmap->mddev, bitmap->offset, page, wait); 316 return write_sb_page(bitmap->mddev, bitmap->offset, page, wait);
317 317
318 flush_dcache_page(page); /* make sure visible to anyone reading the file */
319
318 if (wait) 320 if (wait)
319 lock_page(page); 321 lock_page(page);
320 else { 322 else {
@@ -341,7 +343,7 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait)
341 /* add to list to be waited for by daemon */ 343 /* add to list to be waited for by daemon */
342 struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO); 344 struct page_list *item = mempool_alloc(bitmap->write_pool, GFP_NOIO);
343 item->page = page; 345 item->page = page;
344 page_cache_get(page); 346 get_page(page);
345 spin_lock(&bitmap->write_lock); 347 spin_lock(&bitmap->write_lock);
346 list_add(&item->list, &bitmap->complete_pages); 348 list_add(&item->list, &bitmap->complete_pages);
347 spin_unlock(&bitmap->write_lock); 349 spin_unlock(&bitmap->write_lock);
@@ -357,10 +359,10 @@ static struct page *read_page(struct file *file, unsigned long index,
357 struct inode *inode = file->f_mapping->host; 359 struct inode *inode = file->f_mapping->host;
358 struct page *page = NULL; 360 struct page *page = NULL;
359 loff_t isize = i_size_read(inode); 361 loff_t isize = i_size_read(inode);
360 unsigned long end_index = isize >> PAGE_CACHE_SHIFT; 362 unsigned long end_index = isize >> PAGE_SHIFT;
361 363
362 PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_CACHE_SIZE, 364 PRINTK("read bitmap file (%dB @ %Lu)\n", (int)PAGE_SIZE,
363 (unsigned long long)index << PAGE_CACHE_SHIFT); 365 (unsigned long long)index << PAGE_SHIFT);
364 366
365 page = read_cache_page(inode->i_mapping, index, 367 page = read_cache_page(inode->i_mapping, index,
366 (filler_t *)inode->i_mapping->a_ops->readpage, file); 368 (filler_t *)inode->i_mapping->a_ops->readpage, file);
@@ -368,7 +370,7 @@ static struct page *read_page(struct file *file, unsigned long index,
368 goto out; 370 goto out;
369 wait_on_page_locked(page); 371 wait_on_page_locked(page);
370 if (!PageUptodate(page) || PageError(page)) { 372 if (!PageUptodate(page) || PageError(page)) {
371 page_cache_release(page); 373 put_page(page);
372 page = ERR_PTR(-EIO); 374 page = ERR_PTR(-EIO);
373 goto out; 375 goto out;
374 } 376 }
@@ -376,14 +378,14 @@ static struct page *read_page(struct file *file, unsigned long index,
376 if (index > end_index) /* we have read beyond EOF */ 378 if (index > end_index) /* we have read beyond EOF */
377 *bytes_read = 0; 379 *bytes_read = 0;
378 else if (index == end_index) /* possible short read */ 380 else if (index == end_index) /* possible short read */
379 *bytes_read = isize & ~PAGE_CACHE_MASK; 381 *bytes_read = isize & ~PAGE_MASK;
380 else 382 else
381 *bytes_read = PAGE_CACHE_SIZE; /* got a full page */ 383 *bytes_read = PAGE_SIZE; /* got a full page */
382out: 384out:
383 if (IS_ERR(page)) 385 if (IS_ERR(page))
384 printk(KERN_ALERT "md: bitmap read error: (%dB @ %Lu): %ld\n", 386 printk(KERN_ALERT "md: bitmap read error: (%dB @ %Lu): %ld\n",
385 (int)PAGE_CACHE_SIZE, 387 (int)PAGE_SIZE,
386 (unsigned long long)index << PAGE_CACHE_SHIFT, 388 (unsigned long long)index << PAGE_SHIFT,
387 PTR_ERR(page)); 389 PTR_ERR(page));
388 return page; 390 return page;
389} 391}
@@ -406,11 +408,11 @@ int bitmap_update_sb(struct bitmap *bitmap)
406 return 0; 408 return 0;
407 } 409 }
408 spin_unlock_irqrestore(&bitmap->lock, flags); 410 spin_unlock_irqrestore(&bitmap->lock, flags);
409 sb = (bitmap_super_t *)kmap(bitmap->sb_page); 411 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
410 sb->events = cpu_to_le64(bitmap->mddev->events); 412 sb->events = cpu_to_le64(bitmap->mddev->events);
411 if (!bitmap->mddev->degraded) 413 if (!bitmap->mddev->degraded)
412 sb->events_cleared = cpu_to_le64(bitmap->mddev->events); 414 sb->events_cleared = cpu_to_le64(bitmap->mddev->events);
413 kunmap(bitmap->sb_page); 415 kunmap_atomic(sb, KM_USER0);
414 return write_page(bitmap, bitmap->sb_page, 1); 416 return write_page(bitmap, bitmap->sb_page, 1);
415} 417}
416 418
@@ -421,7 +423,7 @@ void bitmap_print_sb(struct bitmap *bitmap)
421 423
422 if (!bitmap || !bitmap->sb_page) 424 if (!bitmap || !bitmap->sb_page)
423 return; 425 return;
424 sb = (bitmap_super_t *)kmap(bitmap->sb_page); 426 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
425 printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap)); 427 printk(KERN_DEBUG "%s: bitmap file superblock:\n", bmname(bitmap));
426 printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic)); 428 printk(KERN_DEBUG " magic: %08x\n", le32_to_cpu(sb->magic));
427 printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version)); 429 printk(KERN_DEBUG " version: %d\n", le32_to_cpu(sb->version));
@@ -440,7 +442,7 @@ void bitmap_print_sb(struct bitmap *bitmap)
440 printk(KERN_DEBUG " sync size: %llu KB\n", 442 printk(KERN_DEBUG " sync size: %llu KB\n",
441 (unsigned long long)le64_to_cpu(sb->sync_size)/2); 443 (unsigned long long)le64_to_cpu(sb->sync_size)/2);
442 printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind)); 444 printk(KERN_DEBUG "max write behind: %d\n", le32_to_cpu(sb->write_behind));
443 kunmap(bitmap->sb_page); 445 kunmap_atomic(sb, KM_USER0);
444} 446}
445 447
446/* read the superblock from the bitmap file and initialize some bitmap fields */ 448/* read the superblock from the bitmap file and initialize some bitmap fields */
@@ -466,7 +468,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
466 return err; 468 return err;
467 } 469 }
468 470
469 sb = (bitmap_super_t *)kmap(bitmap->sb_page); 471 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
470 472
471 if (bytes_read < sizeof(*sb)) { /* short read */ 473 if (bytes_read < sizeof(*sb)) { /* short read */
472 printk(KERN_INFO "%s: bitmap file superblock truncated\n", 474 printk(KERN_INFO "%s: bitmap file superblock truncated\n",
@@ -485,12 +487,12 @@ static int bitmap_read_sb(struct bitmap *bitmap)
485 else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO || 487 else if (le32_to_cpu(sb->version) < BITMAP_MAJOR_LO ||
486 le32_to_cpu(sb->version) > BITMAP_MAJOR_HI) 488 le32_to_cpu(sb->version) > BITMAP_MAJOR_HI)
487 reason = "unrecognized superblock version"; 489 reason = "unrecognized superblock version";
488 else if (chunksize < 512 || chunksize > (1024 * 1024 * 4)) 490 else if (chunksize < PAGE_SIZE)
489 reason = "bitmap chunksize out of range (512B - 4MB)"; 491 reason = "bitmap chunksize too small";
490 else if ((1 << ffz(~chunksize)) != chunksize) 492 else if ((1 << ffz(~chunksize)) != chunksize)
491 reason = "bitmap chunksize not a power of 2"; 493 reason = "bitmap chunksize not a power of 2";
492 else if (daemon_sleep < 1 || daemon_sleep > 15) 494 else if (daemon_sleep < 1 || daemon_sleep > MAX_SCHEDULE_TIMEOUT / HZ)
493 reason = "daemon sleep period out of range (1-15s)"; 495 reason = "daemon sleep period out of range";
494 else if (write_behind > COUNTER_MAX) 496 else if (write_behind > COUNTER_MAX)
495 reason = "write-behind limit out of range (0 - 16383)"; 497 reason = "write-behind limit out of range (0 - 16383)";
496 if (reason) { 498 if (reason) {
@@ -535,7 +537,7 @@ success:
535 bitmap->events_cleared = bitmap->mddev->events; 537 bitmap->events_cleared = bitmap->mddev->events;
536 err = 0; 538 err = 0;
537out: 539out:
538 kunmap(bitmap->sb_page); 540 kunmap_atomic(sb, KM_USER0);
539 if (err) 541 if (err)
540 bitmap_print_sb(bitmap); 542 bitmap_print_sb(bitmap);
541 return err; 543 return err;
@@ -558,9 +560,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
558 spin_unlock_irqrestore(&bitmap->lock, flags); 560 spin_unlock_irqrestore(&bitmap->lock, flags);
559 return; 561 return;
560 } 562 }
561 page_cache_get(bitmap->sb_page); 563 get_page(bitmap->sb_page);
562 spin_unlock_irqrestore(&bitmap->lock, flags); 564 spin_unlock_irqrestore(&bitmap->lock, flags);
563 sb = (bitmap_super_t *)kmap(bitmap->sb_page); 565 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
564 switch (op) { 566 switch (op) {
565 case MASK_SET: sb->state |= bits; 567 case MASK_SET: sb->state |= bits;
566 break; 568 break;
@@ -568,8 +570,8 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
568 break; 570 break;
569 default: BUG(); 571 default: BUG();
570 } 572 }
571 kunmap(bitmap->sb_page); 573 kunmap_atomic(sb, KM_USER0);
572 page_cache_release(bitmap->sb_page); 574 put_page(bitmap->sb_page);
573} 575}
574 576
575/* 577/*
@@ -622,12 +624,11 @@ static void bitmap_file_unmap(struct bitmap *bitmap)
622 624
623 while (pages--) 625 while (pages--)
624 if (map[pages]->index != 0) /* 0 is sb_page, release it below */ 626 if (map[pages]->index != 0) /* 0 is sb_page, release it below */
625 page_cache_release(map[pages]); 627 put_page(map[pages]);
626 kfree(map); 628 kfree(map);
627 kfree(attr); 629 kfree(attr);
628 630
629 if (sb_page) 631 safe_put_page(sb_page);
630 page_cache_release(sb_page);
631} 632}
632 633
633static void bitmap_stop_daemon(struct bitmap *bitmap); 634static void bitmap_stop_daemon(struct bitmap *bitmap);
@@ -654,7 +655,7 @@ static void drain_write_queues(struct bitmap *bitmap)
654 655
655 while ((item = dequeue_page(bitmap))) { 656 while ((item = dequeue_page(bitmap))) {
656 /* don't bother to wait */ 657 /* don't bother to wait */
657 page_cache_release(item->page); 658 put_page(item->page);
658 mempool_free(item, bitmap->write_pool); 659 mempool_free(item, bitmap->write_pool);
659 } 660 }
660 661
@@ -763,7 +764,7 @@ static void bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
763 764
764 /* make sure the page stays cached until it gets written out */ 765 /* make sure the page stays cached until it gets written out */
765 if (! (get_page_attr(bitmap, page) & BITMAP_PAGE_DIRTY)) 766 if (! (get_page_attr(bitmap, page) & BITMAP_PAGE_DIRTY))
766 page_cache_get(page); 767 get_page(page);
767 768
768 /* set the bit */ 769 /* set the bit */
769 kaddr = kmap_atomic(page, KM_USER0); 770 kaddr = kmap_atomic(page, KM_USER0);
@@ -854,6 +855,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
854 unsigned long bytes, offset, dummy; 855 unsigned long bytes, offset, dummy;
855 int outofdate; 856 int outofdate;
856 int ret = -ENOSPC; 857 int ret = -ENOSPC;
858 void *paddr;
857 859
858 chunks = bitmap->chunks; 860 chunks = bitmap->chunks;
859 file = bitmap->file; 861 file = bitmap->file;
@@ -887,12 +889,10 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
887 if (!bitmap->filemap) 889 if (!bitmap->filemap)
888 goto out; 890 goto out;
889 891
890 bitmap->filemap_attr = kmalloc(sizeof(long) * num_pages, GFP_KERNEL); 892 bitmap->filemap_attr = kzalloc(sizeof(long) * num_pages, GFP_KERNEL);
891 if (!bitmap->filemap_attr) 893 if (!bitmap->filemap_attr)
892 goto out; 894 goto out;
893 895
894 memset(bitmap->filemap_attr, 0, sizeof(long) * num_pages);
895
896 oldindex = ~0L; 896 oldindex = ~0L;
897 897
898 for (i = 0; i < chunks; i++) { 898 for (i = 0; i < chunks; i++) {
@@ -901,8 +901,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
901 bit = file_page_offset(i); 901 bit = file_page_offset(i);
902 if (index != oldindex) { /* this is a new page, read it in */ 902 if (index != oldindex) { /* this is a new page, read it in */
903 /* unmap the old page, we're done with it */ 903 /* unmap the old page, we're done with it */
904 if (oldpage != NULL)
905 kunmap(oldpage);
906 if (index == 0) { 904 if (index == 0) {
907 /* 905 /*
908 * if we're here then the superblock page 906 * if we're here then the superblock page
@@ -925,30 +923,32 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
925 923
926 oldindex = index; 924 oldindex = index;
927 oldpage = page; 925 oldpage = page;
928 kmap(page);
929 926
930 if (outofdate) { 927 if (outofdate) {
931 /* 928 /*
932 * if bitmap is out of date, dirty the 929 * if bitmap is out of date, dirty the
933 * whole page and write it out 930 * whole page and write it out
934 */ 931 */
935 memset(page_address(page) + offset, 0xff, 932 paddr = kmap_atomic(page, KM_USER0);
933 memset(paddr + offset, 0xff,
936 PAGE_SIZE - offset); 934 PAGE_SIZE - offset);
935 kunmap_atomic(paddr, KM_USER0);
937 ret = write_page(bitmap, page, 1); 936 ret = write_page(bitmap, page, 1);
938 if (ret) { 937 if (ret) {
939 kunmap(page);
940 /* release, page not in filemap yet */ 938 /* release, page not in filemap yet */
941 page_cache_release(page); 939 put_page(page);
942 goto out; 940 goto out;
943 } 941 }
944 } 942 }
945 943
946 bitmap->filemap[bitmap->file_pages++] = page; 944 bitmap->filemap[bitmap->file_pages++] = page;
947 } 945 }
946 paddr = kmap_atomic(page, KM_USER0);
948 if (bitmap->flags & BITMAP_HOSTENDIAN) 947 if (bitmap->flags & BITMAP_HOSTENDIAN)
949 b = test_bit(bit, page_address(page)); 948 b = test_bit(bit, paddr);
950 else 949 else
951 b = ext2_test_bit(bit, page_address(page)); 950 b = ext2_test_bit(bit, paddr);
951 kunmap_atomic(paddr, KM_USER0);
952 if (b) { 952 if (b) {
953 /* if the disk bit is set, set the memory bit */ 953 /* if the disk bit is set, set the memory bit */
954 bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap), 954 bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap),
@@ -963,9 +963,6 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
963 ret = 0; 963 ret = 0;
964 bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET); 964 bitmap_mask_state(bitmap, BITMAP_STALE, MASK_UNSET);
965 965
966 if (page) /* unmap the last page */
967 kunmap(page);
968
969 if (bit_cnt) { /* Kick recovery if any bits were set */ 966 if (bit_cnt) { /* Kick recovery if any bits were set */
970 set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery); 967 set_bit(MD_RECOVERY_NEEDED, &bitmap->mddev->recovery);
971 md_wakeup_thread(bitmap->mddev->thread); 968 md_wakeup_thread(bitmap->mddev->thread);
@@ -1021,6 +1018,7 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1021 int err = 0; 1018 int err = 0;
1022 int blocks; 1019 int blocks;
1023 int attr; 1020 int attr;
1021 void *paddr;
1024 1022
1025 if (bitmap == NULL) 1023 if (bitmap == NULL)
1026 return 0; 1024 return 0;
@@ -1043,7 +1041,7 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1043 /* skip this page unless it's marked as needing cleaning */ 1041 /* skip this page unless it's marked as needing cleaning */
1044 if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) { 1042 if (!((attr=get_page_attr(bitmap, page)) & BITMAP_PAGE_CLEAN)) {
1045 if (attr & BITMAP_PAGE_NEEDWRITE) { 1043 if (attr & BITMAP_PAGE_NEEDWRITE) {
1046 page_cache_get(page); 1044 get_page(page);
1047 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE); 1045 clear_page_attr(bitmap, page, BITMAP_PAGE_NEEDWRITE);
1048 } 1046 }
1049 spin_unlock_irqrestore(&bitmap->lock, flags); 1047 spin_unlock_irqrestore(&bitmap->lock, flags);
@@ -1057,13 +1055,13 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1057 default: 1055 default:
1058 bitmap_file_kick(bitmap); 1056 bitmap_file_kick(bitmap);
1059 } 1057 }
1060 page_cache_release(page); 1058 put_page(page);
1061 } 1059 }
1062 continue; 1060 continue;
1063 } 1061 }
1064 1062
1065 /* grab the new page, sync and release the old */ 1063 /* grab the new page, sync and release the old */
1066 page_cache_get(page); 1064 get_page(page);
1067 if (lastpage != NULL) { 1065 if (lastpage != NULL) {
1068 if (get_page_attr(bitmap, lastpage) & BITMAP_PAGE_NEEDWRITE) { 1066 if (get_page_attr(bitmap, lastpage) & BITMAP_PAGE_NEEDWRITE) {
1069 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); 1067 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
@@ -1077,14 +1075,12 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1077 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); 1075 set_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
1078 spin_unlock_irqrestore(&bitmap->lock, flags); 1076 spin_unlock_irqrestore(&bitmap->lock, flags);
1079 } 1077 }
1080 kunmap(lastpage); 1078 put_page(lastpage);
1081 page_cache_release(lastpage);
1082 if (err) 1079 if (err)
1083 bitmap_file_kick(bitmap); 1080 bitmap_file_kick(bitmap);
1084 } else 1081 } else
1085 spin_unlock_irqrestore(&bitmap->lock, flags); 1082 spin_unlock_irqrestore(&bitmap->lock, flags);
1086 lastpage = page; 1083 lastpage = page;
1087 kmap(page);
1088/* 1084/*
1089 printk("bitmap clean at page %lu\n", j); 1085 printk("bitmap clean at page %lu\n", j);
1090*/ 1086*/
@@ -1107,10 +1103,12 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1107 -1); 1103 -1);
1108 1104
1109 /* clear the bit */ 1105 /* clear the bit */
1106 paddr = kmap_atomic(page, KM_USER0);
1110 if (bitmap->flags & BITMAP_HOSTENDIAN) 1107 if (bitmap->flags & BITMAP_HOSTENDIAN)
1111 clear_bit(file_page_offset(j), page_address(page)); 1108 clear_bit(file_page_offset(j), paddr);
1112 else 1109 else
1113 ext2_clear_bit(file_page_offset(j), page_address(page)); 1110 ext2_clear_bit(file_page_offset(j), paddr);
1111 kunmap_atomic(paddr, KM_USER0);
1114 } 1112 }
1115 } 1113 }
1116 spin_unlock_irqrestore(&bitmap->lock, flags); 1114 spin_unlock_irqrestore(&bitmap->lock, flags);
@@ -1118,7 +1116,6 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1118 1116
1119 /* now sync the final page */ 1117 /* now sync the final page */
1120 if (lastpage != NULL) { 1118 if (lastpage != NULL) {
1121 kunmap(lastpage);
1122 spin_lock_irqsave(&bitmap->lock, flags); 1119 spin_lock_irqsave(&bitmap->lock, flags);
1123 if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) { 1120 if (get_page_attr(bitmap, lastpage) &BITMAP_PAGE_NEEDWRITE) {
1124 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE); 1121 clear_page_attr(bitmap, lastpage, BITMAP_PAGE_NEEDWRITE);
@@ -1133,7 +1130,7 @@ int bitmap_daemon_work(struct bitmap *bitmap)
1133 spin_unlock_irqrestore(&bitmap->lock, flags); 1130 spin_unlock_irqrestore(&bitmap->lock, flags);
1134 } 1131 }
1135 1132
1136 page_cache_release(lastpage); 1133 put_page(lastpage);
1137 } 1134 }
1138 1135
1139 return err; 1136 return err;
@@ -1184,7 +1181,7 @@ static void bitmap_writeback_daemon(mddev_t *mddev)
1184 PRINTK("finished page writeback: %p\n", page); 1181 PRINTK("finished page writeback: %p\n", page);
1185 1182
1186 err = PageError(page); 1183 err = PageError(page);
1187 page_cache_release(page); 1184 put_page(page);
1188 if (err) { 1185 if (err) {
1189 printk(KERN_WARNING "%s: bitmap file writeback " 1186 printk(KERN_WARNING "%s: bitmap file writeback "
1190 "failed (page %lu): %d\n", 1187 "failed (page %lu): %d\n",
@@ -1530,6 +1527,8 @@ void bitmap_destroy(mddev_t *mddev)
1530 return; 1527 return;
1531 1528
1532 mddev->bitmap = NULL; /* disconnect from the md device */ 1529 mddev->bitmap = NULL; /* disconnect from the md device */
1530 if (mddev->thread)
1531 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
1533 1532
1534 bitmap_free(bitmap); 1533 bitmap_free(bitmap);
1535} 1534}
@@ -1555,12 +1554,10 @@ int bitmap_create(mddev_t *mddev)
1555 1554
1556 BUG_ON(file && mddev->bitmap_offset); 1555 BUG_ON(file && mddev->bitmap_offset);
1557 1556
1558 bitmap = kmalloc(sizeof(*bitmap), GFP_KERNEL); 1557 bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL);
1559 if (!bitmap) 1558 if (!bitmap)
1560 return -ENOMEM; 1559 return -ENOMEM;
1561 1560
1562 memset(bitmap, 0, sizeof(*bitmap));
1563
1564 spin_lock_init(&bitmap->lock); 1561 spin_lock_init(&bitmap->lock);
1565 bitmap->mddev = mddev; 1562 bitmap->mddev = mddev;
1566 1563
@@ -1601,12 +1598,11 @@ int bitmap_create(mddev_t *mddev)
1601#ifdef INJECT_FATAL_FAULT_1 1598#ifdef INJECT_FATAL_FAULT_1
1602 bitmap->bp = NULL; 1599 bitmap->bp = NULL;
1603#else 1600#else
1604 bitmap->bp = kmalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL); 1601 bitmap->bp = kzalloc(pages * sizeof(*bitmap->bp), GFP_KERNEL);
1605#endif 1602#endif
1606 err = -ENOMEM; 1603 err = -ENOMEM;
1607 if (!bitmap->bp) 1604 if (!bitmap->bp)
1608 goto error; 1605 goto error;
1609 memset(bitmap->bp, 0, pages * sizeof(*bitmap->bp));
1610 1606
1611 bitmap->flags |= BITMAP_ACTIVE; 1607 bitmap->flags |= BITMAP_ACTIVE;
1612 1608
@@ -1636,6 +1632,8 @@ int bitmap_create(mddev_t *mddev)
1636 1632
1637 if (IS_ERR(bitmap->writeback_daemon)) 1633 if (IS_ERR(bitmap->writeback_daemon))
1638 return PTR_ERR(bitmap->writeback_daemon); 1634 return PTR_ERR(bitmap->writeback_daemon);
1635 mddev->thread->timeout = bitmap->daemon_sleep * HZ;
1636
1639 return bitmap_update_sb(bitmap); 1637 return bitmap_update_sb(bitmap);
1640 1638
1641 error: 1639 error:
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index cf6631056683..a601a427885c 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -690,6 +690,8 @@ bad3:
690bad2: 690bad2:
691 crypto_free_tfm(tfm); 691 crypto_free_tfm(tfm);
692bad1: 692bad1:
693 /* Must zero key material before freeing */
694 memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8));
693 kfree(cc); 695 kfree(cc);
694 return -EINVAL; 696 return -EINVAL;
695} 697}
@@ -706,6 +708,9 @@ static void crypt_dtr(struct dm_target *ti)
706 cc->iv_gen_ops->dtr(cc); 708 cc->iv_gen_ops->dtr(cc);
707 crypto_free_tfm(cc->tfm); 709 crypto_free_tfm(cc->tfm);
708 dm_put_device(ti, cc->dev); 710 dm_put_device(ti, cc->dev);
711
712 /* Must zero key material before freeing */
713 memset(cc, 0, sizeof(*cc) + cc->key_size * sizeof(u8));
709 kfree(cc); 714 kfree(cc);
710} 715}
711 716
diff --git a/drivers/md/dm-io.h b/drivers/md/dm-io.h
index 1a77f3265706..f9035bfd1a9f 100644
--- a/drivers/md/dm-io.h
+++ b/drivers/md/dm-io.h
@@ -9,9 +9,6 @@
9 9
10#include "dm.h" 10#include "dm.h"
11 11
12/* FIXME make this configurable */
13#define DM_MAX_IO_REGIONS 8
14
15struct io_region { 12struct io_region {
16 struct block_device *bdev; 13 struct block_device *bdev;
17 sector_t sector; 14 sector_t sector;
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 07d44e19536e..561bda5011e0 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -270,6 +270,7 @@ static int dm_hash_rename(const char *old, const char *new)
270{ 270{
271 char *new_name, *old_name; 271 char *new_name, *old_name;
272 struct hash_cell *hc; 272 struct hash_cell *hc;
273 struct dm_table *table;
273 274
274 /* 275 /*
275 * duplicate new. 276 * duplicate new.
@@ -317,6 +318,15 @@ static int dm_hash_rename(const char *old, const char *new)
317 /* rename the device node in devfs */ 318 /* rename the device node in devfs */
318 register_with_devfs(hc); 319 register_with_devfs(hc);
319 320
321 /*
322 * Wake up any dm event waiters.
323 */
324 table = dm_get_table(hc->md);
325 if (table) {
326 dm_table_event(table);
327 dm_table_put(table);
328 }
329
320 up_write(&_hash_lock); 330 up_write(&_hash_lock);
321 kfree(old_name); 331 kfree(old_name);
322 return 0; 332 return 0;
@@ -683,14 +693,18 @@ static int dev_rename(struct dm_ioctl *param, size_t param_size)
683static int do_suspend(struct dm_ioctl *param) 693static int do_suspend(struct dm_ioctl *param)
684{ 694{
685 int r = 0; 695 int r = 0;
696 int do_lockfs = 1;
686 struct mapped_device *md; 697 struct mapped_device *md;
687 698
688 md = find_device(param); 699 md = find_device(param);
689 if (!md) 700 if (!md)
690 return -ENXIO; 701 return -ENXIO;
691 702
703 if (param->flags & DM_SKIP_LOCKFS_FLAG)
704 do_lockfs = 0;
705
692 if (!dm_suspended(md)) 706 if (!dm_suspended(md))
693 r = dm_suspend(md); 707 r = dm_suspend(md, do_lockfs);
694 708
695 if (!r) 709 if (!r)
696 r = __dev_status(md, param); 710 r = __dev_status(md, param);
@@ -702,6 +716,7 @@ static int do_suspend(struct dm_ioctl *param)
702static int do_resume(struct dm_ioctl *param) 716static int do_resume(struct dm_ioctl *param)
703{ 717{
704 int r = 0; 718 int r = 0;
719 int do_lockfs = 1;
705 struct hash_cell *hc; 720 struct hash_cell *hc;
706 struct mapped_device *md; 721 struct mapped_device *md;
707 struct dm_table *new_map; 722 struct dm_table *new_map;
@@ -727,8 +742,10 @@ static int do_resume(struct dm_ioctl *param)
727 /* Do we need to load a new map ? */ 742 /* Do we need to load a new map ? */
728 if (new_map) { 743 if (new_map) {
729 /* Suspend if it isn't already suspended */ 744 /* Suspend if it isn't already suspended */
745 if (param->flags & DM_SKIP_LOCKFS_FLAG)
746 do_lockfs = 0;
730 if (!dm_suspended(md)) 747 if (!dm_suspended(md))
731 dm_suspend(md); 748 dm_suspend(md, do_lockfs);
732 749
733 r = dm_swap_table(md, new_map); 750 r = dm_swap_table(md, new_map);
734 if (r) { 751 if (r) {
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index a76349cb10a5..efe4adf78530 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -573,7 +573,7 @@ static int core_get_resync_work(struct dirty_log *log, region_t *region)
573 lc->sync_search); 573 lc->sync_search);
574 lc->sync_search = *region + 1; 574 lc->sync_search = *region + 1;
575 575
576 if (*region == lc->region_count) 576 if (*region >= lc->region_count)
577 return 0; 577 return 0;
578 578
579 } while (log_test_bit(lc->recovering_bits, *region)); 579 } while (log_test_bit(lc->recovering_bits, *region));
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 6b0fc1670929..6cfa8d435d55 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -562,6 +562,8 @@ struct mirror_set {
562 region_t nr_regions; 562 region_t nr_regions;
563 int in_sync; 563 int in_sync;
564 564
565 struct mirror *default_mirror; /* Default mirror */
566
565 unsigned int nr_mirrors; 567 unsigned int nr_mirrors;
566 struct mirror mirror[0]; 568 struct mirror mirror[0];
567}; 569};
@@ -611,7 +613,7 @@ static int recover(struct mirror_set *ms, struct region *reg)
611 unsigned long flags = 0; 613 unsigned long flags = 0;
612 614
613 /* fill in the source */ 615 /* fill in the source */
614 m = ms->mirror + DEFAULT_MIRROR; 616 m = ms->default_mirror;
615 from.bdev = m->dev->bdev; 617 from.bdev = m->dev->bdev;
616 from.sector = m->offset + region_to_sector(reg->rh, reg->key); 618 from.sector = m->offset + region_to_sector(reg->rh, reg->key);
617 if (reg->key == (ms->nr_regions - 1)) { 619 if (reg->key == (ms->nr_regions - 1)) {
@@ -627,7 +629,7 @@ static int recover(struct mirror_set *ms, struct region *reg)
627 629
628 /* fill in the destinations */ 630 /* fill in the destinations */
629 for (i = 0, dest = to; i < ms->nr_mirrors; i++) { 631 for (i = 0, dest = to; i < ms->nr_mirrors; i++) {
630 if (i == DEFAULT_MIRROR) 632 if (&ms->mirror[i] == ms->default_mirror)
631 continue; 633 continue;
632 634
633 m = ms->mirror + i; 635 m = ms->mirror + i;
@@ -682,7 +684,7 @@ static void do_recovery(struct mirror_set *ms)
682static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector) 684static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
683{ 685{
684 /* FIXME: add read balancing */ 686 /* FIXME: add read balancing */
685 return ms->mirror + DEFAULT_MIRROR; 687 return ms->default_mirror;
686} 688}
687 689
688/* 690/*
@@ -709,7 +711,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
709 if (rh_in_sync(&ms->rh, region, 0)) 711 if (rh_in_sync(&ms->rh, region, 0))
710 m = choose_mirror(ms, bio->bi_sector); 712 m = choose_mirror(ms, bio->bi_sector);
711 else 713 else
712 m = ms->mirror + DEFAULT_MIRROR; 714 m = ms->default_mirror;
713 715
714 map_bio(ms, m, bio); 716 map_bio(ms, m, bio);
715 generic_make_request(bio); 717 generic_make_request(bio);
@@ -833,7 +835,7 @@ static void do_writes(struct mirror_set *ms, struct bio_list *writes)
833 rh_delay(&ms->rh, bio); 835 rh_delay(&ms->rh, bio);
834 836
835 while ((bio = bio_list_pop(&nosync))) { 837 while ((bio = bio_list_pop(&nosync))) {
836 map_bio(ms, ms->mirror + DEFAULT_MIRROR, bio); 838 map_bio(ms, ms->default_mirror, bio);
837 generic_make_request(bio); 839 generic_make_request(bio);
838 } 840 }
839} 841}
@@ -900,6 +902,7 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
900 ms->nr_mirrors = nr_mirrors; 902 ms->nr_mirrors = nr_mirrors;
901 ms->nr_regions = dm_sector_div_up(ti->len, region_size); 903 ms->nr_regions = dm_sector_div_up(ti->len, region_size);
902 ms->in_sync = 0; 904 ms->in_sync = 0;
905 ms->default_mirror = &ms->mirror[DEFAULT_MIRROR];
903 906
904 if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) { 907 if (rh_init(&ms->rh, ms, dl, region_size, ms->nr_regions)) {
905 ti->error = "dm-mirror: Error creating dirty region hash"; 908 ti->error = "dm-mirror: Error creating dirty region hash";
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index ab54f99b7c3b..4b9dd8fb1e5c 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -371,6 +371,20 @@ static inline ulong round_up(ulong n, ulong size)
371 return (n + size) & ~size; 371 return (n + size) & ~size;
372} 372}
373 373
374static void read_snapshot_metadata(struct dm_snapshot *s)
375{
376 if (s->have_metadata)
377 return;
378
379 if (s->store.read_metadata(&s->store)) {
380 down_write(&s->lock);
381 s->valid = 0;
382 up_write(&s->lock);
383 }
384
385 s->have_metadata = 1;
386}
387
374/* 388/*
375 * Construct a snapshot mapping: <origin_dev> <COW-dev> <p/n> <chunk-size> 389 * Construct a snapshot mapping: <origin_dev> <COW-dev> <p/n> <chunk-size>
376 */ 390 */
@@ -848,16 +862,7 @@ static void snapshot_resume(struct dm_target *ti)
848{ 862{
849 struct dm_snapshot *s = (struct dm_snapshot *) ti->private; 863 struct dm_snapshot *s = (struct dm_snapshot *) ti->private;
850 864
851 if (s->have_metadata) 865 read_snapshot_metadata(s);
852 return;
853
854 if (s->store.read_metadata(&s->store)) {
855 down_write(&s->lock);
856 s->valid = 0;
857 up_write(&s->lock);
858 }
859
860 s->have_metadata = 1;
861} 866}
862 867
863static int snapshot_status(struct dm_target *ti, status_type_t type, 868static int snapshot_status(struct dm_target *ti, status_type_t type,
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a6d3baa46f61..a6f2dc66c3db 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -638,7 +638,7 @@ int dm_split_args(int *argc, char ***argvp, char *input)
638static void check_for_valid_limits(struct io_restrictions *rs) 638static void check_for_valid_limits(struct io_restrictions *rs)
639{ 639{
640 if (!rs->max_sectors) 640 if (!rs->max_sectors)
641 rs->max_sectors = MAX_SECTORS; 641 rs->max_sectors = SAFE_MAX_SECTORS;
642 if (!rs->max_phys_segments) 642 if (!rs->max_phys_segments)
643 rs->max_phys_segments = MAX_PHYS_SEGMENTS; 643 rs->max_phys_segments = MAX_PHYS_SEGMENTS;
644 if (!rs->max_hw_segments) 644 if (!rs->max_hw_segments)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 930b9fc27953..0e481512f918 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -55,6 +55,7 @@ union map_info *dm_get_mapinfo(struct bio *bio)
55 */ 55 */
56#define DMF_BLOCK_IO 0 56#define DMF_BLOCK_IO 0
57#define DMF_SUSPENDED 1 57#define DMF_SUSPENDED 1
58#define DMF_FROZEN 2
58 59
59struct mapped_device { 60struct mapped_device {
60 struct rw_semaphore io_lock; 61 struct rw_semaphore io_lock;
@@ -97,7 +98,7 @@ struct mapped_device {
97 * freeze/thaw support require holding onto a super block 98 * freeze/thaw support require holding onto a super block
98 */ 99 */
99 struct super_block *frozen_sb; 100 struct super_block *frozen_sb;
100 struct block_device *frozen_bdev; 101 struct block_device *suspended_bdev;
101}; 102};
102 103
103#define MIN_IOS 256 104#define MIN_IOS 256
@@ -836,9 +837,9 @@ static void __set_size(struct mapped_device *md, sector_t size)
836{ 837{
837 set_capacity(md->disk, size); 838 set_capacity(md->disk, size);
838 839
839 down(&md->frozen_bdev->bd_inode->i_sem); 840 down(&md->suspended_bdev->bd_inode->i_sem);
840 i_size_write(md->frozen_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT); 841 i_size_write(md->suspended_bdev->bd_inode, (loff_t)size << SECTOR_SHIFT);
841 up(&md->frozen_bdev->bd_inode->i_sem); 842 up(&md->suspended_bdev->bd_inode->i_sem);
842} 843}
843 844
844static int __bind(struct mapped_device *md, struct dm_table *t) 845static int __bind(struct mapped_device *md, struct dm_table *t)
@@ -902,10 +903,9 @@ int dm_create_with_minor(unsigned int minor, struct mapped_device **result)
902 return create_aux(minor, 1, result); 903 return create_aux(minor, 1, result);
903} 904}
904 905
905void *dm_get_mdptr(dev_t dev) 906static struct mapped_device *dm_find_md(dev_t dev)
906{ 907{
907 struct mapped_device *md; 908 struct mapped_device *md;
908 void *mdptr = NULL;
909 unsigned minor = MINOR(dev); 909 unsigned minor = MINOR(dev);
910 910
911 if (MAJOR(dev) != _major || minor >= (1 << MINORBITS)) 911 if (MAJOR(dev) != _major || minor >= (1 << MINORBITS))
@@ -914,12 +914,32 @@ void *dm_get_mdptr(dev_t dev)
914 down(&_minor_lock); 914 down(&_minor_lock);
915 915
916 md = idr_find(&_minor_idr, minor); 916 md = idr_find(&_minor_idr, minor);
917 917 if (!md || (dm_disk(md)->first_minor != minor))
918 if (md && (dm_disk(md)->first_minor == minor)) 918 md = NULL;
919 mdptr = md->interface_ptr;
920 919
921 up(&_minor_lock); 920 up(&_minor_lock);
922 921
922 return md;
923}
924
925struct mapped_device *dm_get_md(dev_t dev)
926{
927 struct mapped_device *md = dm_find_md(dev);
928
929 if (md)
930 dm_get(md);
931
932 return md;
933}
934
935void *dm_get_mdptr(dev_t dev)
936{
937 struct mapped_device *md;
938 void *mdptr = NULL;
939
940 md = dm_find_md(dev);
941 if (md)
942 mdptr = md->interface_ptr;
923 return mdptr; 943 return mdptr;
924} 944}
925 945
@@ -991,43 +1011,33 @@ out:
991 */ 1011 */
992static int lock_fs(struct mapped_device *md) 1012static int lock_fs(struct mapped_device *md)
993{ 1013{
994 int r = -ENOMEM; 1014 int r;
995
996 md->frozen_bdev = bdget_disk(md->disk, 0);
997 if (!md->frozen_bdev) {
998 DMWARN("bdget failed in lock_fs");
999 goto out;
1000 }
1001 1015
1002 WARN_ON(md->frozen_sb); 1016 WARN_ON(md->frozen_sb);
1003 1017
1004 md->frozen_sb = freeze_bdev(md->frozen_bdev); 1018 md->frozen_sb = freeze_bdev(md->suspended_bdev);
1005 if (IS_ERR(md->frozen_sb)) { 1019 if (IS_ERR(md->frozen_sb)) {
1006 r = PTR_ERR(md->frozen_sb); 1020 r = PTR_ERR(md->frozen_sb);
1007 goto out_bdput; 1021 md->frozen_sb = NULL;
1022 return r;
1008 } 1023 }
1009 1024
1025 set_bit(DMF_FROZEN, &md->flags);
1026
1010 /* don't bdput right now, we don't want the bdev 1027 /* don't bdput right now, we don't want the bdev
1011 * to go away while it is locked. We'll bdput 1028 * to go away while it is locked.
1012 * in unlock_fs
1013 */ 1029 */
1014 return 0; 1030 return 0;
1015
1016out_bdput:
1017 bdput(md->frozen_bdev);
1018 md->frozen_sb = NULL;
1019 md->frozen_bdev = NULL;
1020out:
1021 return r;
1022} 1031}
1023 1032
1024static void unlock_fs(struct mapped_device *md) 1033static void unlock_fs(struct mapped_device *md)
1025{ 1034{
1026 thaw_bdev(md->frozen_bdev, md->frozen_sb); 1035 if (!test_bit(DMF_FROZEN, &md->flags))
1027 bdput(md->frozen_bdev); 1036 return;
1028 1037
1038 thaw_bdev(md->suspended_bdev, md->frozen_sb);
1029 md->frozen_sb = NULL; 1039 md->frozen_sb = NULL;
1030 md->frozen_bdev = NULL; 1040 clear_bit(DMF_FROZEN, &md->flags);
1031} 1041}
1032 1042
1033/* 1043/*
@@ -1037,7 +1047,7 @@ static void unlock_fs(struct mapped_device *md)
1037 * dm_bind_table, dm_suspend must be called to flush any in 1047 * dm_bind_table, dm_suspend must be called to flush any in
1038 * flight bios and ensure that any further io gets deferred. 1048 * flight bios and ensure that any further io gets deferred.
1039 */ 1049 */
1040int dm_suspend(struct mapped_device *md) 1050int dm_suspend(struct mapped_device *md, int do_lockfs)
1041{ 1051{
1042 struct dm_table *map = NULL; 1052 struct dm_table *map = NULL;
1043 DECLARE_WAITQUEUE(wait, current); 1053 DECLARE_WAITQUEUE(wait, current);
@@ -1053,10 +1063,19 @@ int dm_suspend(struct mapped_device *md)
1053 /* This does not get reverted if there's an error later. */ 1063 /* This does not get reverted if there's an error later. */
1054 dm_table_presuspend_targets(map); 1064 dm_table_presuspend_targets(map);
1055 1065
1056 /* Flush I/O to the device. */ 1066 md->suspended_bdev = bdget_disk(md->disk, 0);
1057 r = lock_fs(md); 1067 if (!md->suspended_bdev) {
1058 if (r) 1068 DMWARN("bdget failed in dm_suspend");
1069 r = -ENOMEM;
1059 goto out; 1070 goto out;
1071 }
1072
1073 /* Flush I/O to the device. */
1074 if (do_lockfs) {
1075 r = lock_fs(md);
1076 if (r)
1077 goto out;
1078 }
1060 1079
1061 /* 1080 /*
1062 * First we set the BLOCK_IO flag so no more ios will be mapped. 1081 * First we set the BLOCK_IO flag so no more ios will be mapped.
@@ -1105,6 +1124,11 @@ int dm_suspend(struct mapped_device *md)
1105 r = 0; 1124 r = 0;
1106 1125
1107out: 1126out:
1127 if (r && md->suspended_bdev) {
1128 bdput(md->suspended_bdev);
1129 md->suspended_bdev = NULL;
1130 }
1131
1108 dm_table_put(map); 1132 dm_table_put(map);
1109 up(&md->suspend_lock); 1133 up(&md->suspend_lock);
1110 return r; 1134 return r;
@@ -1135,6 +1159,9 @@ int dm_resume(struct mapped_device *md)
1135 1159
1136 unlock_fs(md); 1160 unlock_fs(md);
1137 1161
1162 bdput(md->suspended_bdev);
1163 md->suspended_bdev = NULL;
1164
1138 clear_bit(DMF_SUSPENDED, &md->flags); 1165 clear_bit(DMF_SUSPENDED, &md->flags);
1139 1166
1140 dm_table_unplug_all(map); 1167 dm_table_unplug_all(map);
diff --git a/drivers/md/dm.h b/drivers/md/dm.h
index e38c3fc1a1db..4eaf075da217 100644
--- a/drivers/md/dm.h
+++ b/drivers/md/dm.h
@@ -28,7 +28,7 @@
28 * in types.h. 28 * in types.h.
29 */ 29 */
30#ifdef CONFIG_LBD 30#ifdef CONFIG_LBD
31#define SECTOR_FORMAT "%Lu" 31#define SECTOR_FORMAT "%llu"
32#else 32#else
33#define SECTOR_FORMAT "%lu" 33#define SECTOR_FORMAT "%lu"
34#endif 34#endif
@@ -58,6 +58,7 @@ int dm_create(struct mapped_device **md);
58int dm_create_with_minor(unsigned int minor, struct mapped_device **md); 58int dm_create_with_minor(unsigned int minor, struct mapped_device **md);
59void dm_set_mdptr(struct mapped_device *md, void *ptr); 59void dm_set_mdptr(struct mapped_device *md, void *ptr);
60void *dm_get_mdptr(dev_t dev); 60void *dm_get_mdptr(dev_t dev);
61struct mapped_device *dm_get_md(dev_t dev);
61 62
62/* 63/*
63 * Reference counting for md. 64 * Reference counting for md.
@@ -68,7 +69,7 @@ void dm_put(struct mapped_device *md);
68/* 69/*
69 * A device can still be used while suspended, but I/O is deferred. 70 * A device can still be used while suspended, but I/O is deferred.
70 */ 71 */
71int dm_suspend(struct mapped_device *md); 72int dm_suspend(struct mapped_device *md, int with_lockfs);
72int dm_resume(struct mapped_device *md); 73int dm_resume(struct mapped_device *md);
73 74
74/* 75/*
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 0248f8e7eac0..a7a5ab554338 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -316,9 +316,10 @@ static int stop(mddev_t *mddev)
316 return 0; 316 return 0;
317} 317}
318 318
319static mdk_personality_t faulty_personality = 319static struct mdk_personality faulty_personality =
320{ 320{
321 .name = "faulty", 321 .name = "faulty",
322 .level = LEVEL_FAULTY,
322 .owner = THIS_MODULE, 323 .owner = THIS_MODULE,
323 .make_request = make_request, 324 .make_request = make_request,
324 .run = run, 325 .run = run,
@@ -329,15 +330,17 @@ static mdk_personality_t faulty_personality =
329 330
330static int __init raid_init(void) 331static int __init raid_init(void)
331{ 332{
332 return register_md_personality(FAULTY, &faulty_personality); 333 return register_md_personality(&faulty_personality);
333} 334}
334 335
335static void raid_exit(void) 336static void raid_exit(void)
336{ 337{
337 unregister_md_personality(FAULTY); 338 unregister_md_personality(&faulty_personality);
338} 339}
339 340
340module_init(raid_init); 341module_init(raid_init);
341module_exit(raid_exit); 342module_exit(raid_exit);
342MODULE_LICENSE("GPL"); 343MODULE_LICENSE("GPL");
343MODULE_ALIAS("md-personality-10"); /* faulty */ 344MODULE_ALIAS("md-personality-10"); /* faulty */
345MODULE_ALIAS("md-faulty");
346MODULE_ALIAS("md-level--5");
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c
index eb7036485975..ca99979c868a 100644
--- a/drivers/md/kcopyd.c
+++ b/drivers/md/kcopyd.c
@@ -561,11 +561,13 @@ int kcopyd_copy(struct kcopyd_client *kc, struct io_region *from,
561 * Cancels a kcopyd job, eg. someone might be deactivating a 561 * Cancels a kcopyd job, eg. someone might be deactivating a
562 * mirror. 562 * mirror.
563 */ 563 */
564#if 0
564int kcopyd_cancel(struct kcopyd_job *job, int block) 565int kcopyd_cancel(struct kcopyd_job *job, int block)
565{ 566{
566 /* FIXME: finish */ 567 /* FIXME: finish */
567 return -1; 568 return -1;
568} 569}
570#endif /* 0 */
569 571
570/*----------------------------------------------------------------- 572/*-----------------------------------------------------------------
571 * Unit setup 573 * Unit setup
@@ -684,4 +686,3 @@ void kcopyd_client_destroy(struct kcopyd_client *kc)
684EXPORT_SYMBOL(kcopyd_client_create); 686EXPORT_SYMBOL(kcopyd_client_create);
685EXPORT_SYMBOL(kcopyd_client_destroy); 687EXPORT_SYMBOL(kcopyd_client_destroy);
686EXPORT_SYMBOL(kcopyd_copy); 688EXPORT_SYMBOL(kcopyd_copy);
687EXPORT_SYMBOL(kcopyd_cancel);
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 946efef3a8f5..777585458c85 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -121,11 +121,10 @@ static int linear_run (mddev_t *mddev)
121 sector_t curr_offset; 121 sector_t curr_offset;
122 struct list_head *tmp; 122 struct list_head *tmp;
123 123
124 conf = kmalloc (sizeof (*conf) + mddev->raid_disks*sizeof(dev_info_t), 124 conf = kzalloc (sizeof (*conf) + mddev->raid_disks*sizeof(dev_info_t),
125 GFP_KERNEL); 125 GFP_KERNEL);
126 if (!conf) 126 if (!conf)
127 goto out; 127 goto out;
128 memset(conf, 0, sizeof(*conf) + mddev->raid_disks*sizeof(dev_info_t));
129 mddev->private = conf; 128 mddev->private = conf;
130 129
131 cnt = 0; 130 cnt = 0;
@@ -352,9 +351,10 @@ static void linear_status (struct seq_file *seq, mddev_t *mddev)
352} 351}
353 352
354 353
355static mdk_personality_t linear_personality= 354static struct mdk_personality linear_personality =
356{ 355{
357 .name = "linear", 356 .name = "linear",
357 .level = LEVEL_LINEAR,
358 .owner = THIS_MODULE, 358 .owner = THIS_MODULE,
359 .make_request = linear_make_request, 359 .make_request = linear_make_request,
360 .run = linear_run, 360 .run = linear_run,
@@ -364,16 +364,18 @@ static mdk_personality_t linear_personality=
364 364
365static int __init linear_init (void) 365static int __init linear_init (void)
366{ 366{
367 return register_md_personality (LINEAR, &linear_personality); 367 return register_md_personality (&linear_personality);
368} 368}
369 369
370static void linear_exit (void) 370static void linear_exit (void)
371{ 371{
372 unregister_md_personality (LINEAR); 372 unregister_md_personality (&linear_personality);
373} 373}
374 374
375 375
376module_init(linear_init); 376module_init(linear_init);
377module_exit(linear_exit); 377module_exit(linear_exit);
378MODULE_LICENSE("GPL"); 378MODULE_LICENSE("GPL");
379MODULE_ALIAS("md-personality-1"); /* LINEAR */ 379MODULE_ALIAS("md-personality-1"); /* LINEAR - deprecated*/
380MODULE_ALIAS("md-linear");
381MODULE_ALIAS("md-level--1");
diff --git a/drivers/md/md.c b/drivers/md/md.c
index cd12fca73b0d..1b76fb29fb70 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -42,6 +42,7 @@
42#include <linux/devfs_fs_kernel.h> 42#include <linux/devfs_fs_kernel.h>
43#include <linux/buffer_head.h> /* for invalidate_bdev */ 43#include <linux/buffer_head.h> /* for invalidate_bdev */
44#include <linux/suspend.h> 44#include <linux/suspend.h>
45#include <linux/poll.h>
45 46
46#include <linux/init.h> 47#include <linux/init.h>
47 48
@@ -67,7 +68,7 @@
67static void autostart_arrays (int part); 68static void autostart_arrays (int part);
68#endif 69#endif
69 70
70static mdk_personality_t *pers[MAX_PERSONALITY]; 71static LIST_HEAD(pers_list);
71static DEFINE_SPINLOCK(pers_lock); 72static DEFINE_SPINLOCK(pers_lock);
72 73
73/* 74/*
@@ -80,10 +81,22 @@ static DEFINE_SPINLOCK(pers_lock);
80 * idle IO detection. 81 * idle IO detection.
81 * 82 *
82 * you can change it via /proc/sys/dev/raid/speed_limit_min and _max. 83 * you can change it via /proc/sys/dev/raid/speed_limit_min and _max.
84 * or /sys/block/mdX/md/sync_speed_{min,max}
83 */ 85 */
84 86
85static int sysctl_speed_limit_min = 1000; 87static int sysctl_speed_limit_min = 1000;
86static int sysctl_speed_limit_max = 200000; 88static int sysctl_speed_limit_max = 200000;
89static inline int speed_min(mddev_t *mddev)
90{
91 return mddev->sync_speed_min ?
92 mddev->sync_speed_min : sysctl_speed_limit_min;
93}
94
95static inline int speed_max(mddev_t *mddev)
96{
97 return mddev->sync_speed_max ?
98 mddev->sync_speed_max : sysctl_speed_limit_max;
99}
87 100
88static struct ctl_table_header *raid_table_header; 101static struct ctl_table_header *raid_table_header;
89 102
@@ -134,6 +147,24 @@ static struct block_device_operations md_fops;
134static int start_readonly; 147static int start_readonly;
135 148
136/* 149/*
150 * We have a system wide 'event count' that is incremented
151 * on any 'interesting' event, and readers of /proc/mdstat
152 * can use 'poll' or 'select' to find out when the event
153 * count increases.
154 *
155 * Events are:
156 * start array, stop array, error, add device, remove device,
157 * start build, activate spare
158 */
159static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
160static atomic_t md_event_count;
161static void md_new_event(mddev_t *mddev)
162{
163 atomic_inc(&md_event_count);
164 wake_up(&md_event_waiters);
165}
166
167/*
137 * Enables to iterate over all existing md arrays 168 * Enables to iterate over all existing md arrays
138 * all_mddevs_lock protects this list. 169 * all_mddevs_lock protects this list.
139 */ 170 */
@@ -209,12 +240,10 @@ static mddev_t * mddev_find(dev_t unit)
209 } 240 }
210 spin_unlock(&all_mddevs_lock); 241 spin_unlock(&all_mddevs_lock);
211 242
212 new = (mddev_t *) kmalloc(sizeof(*new), GFP_KERNEL); 243 new = kzalloc(sizeof(*new), GFP_KERNEL);
213 if (!new) 244 if (!new)
214 return NULL; 245 return NULL;
215 246
216 memset(new, 0, sizeof(*new));
217
218 new->unit = unit; 247 new->unit = unit;
219 if (MAJOR(unit) == MD_MAJOR) 248 if (MAJOR(unit) == MD_MAJOR)
220 new->md_minor = MINOR(unit); 249 new->md_minor = MINOR(unit);
@@ -262,7 +291,7 @@ static inline void mddev_unlock(mddev_t * mddev)
262 md_wakeup_thread(mddev->thread); 291 md_wakeup_thread(mddev->thread);
263} 292}
264 293
265mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr) 294static mdk_rdev_t * find_rdev_nr(mddev_t *mddev, int nr)
266{ 295{
267 mdk_rdev_t * rdev; 296 mdk_rdev_t * rdev;
268 struct list_head *tmp; 297 struct list_head *tmp;
@@ -286,6 +315,18 @@ static mdk_rdev_t * find_rdev(mddev_t * mddev, dev_t dev)
286 return NULL; 315 return NULL;
287} 316}
288 317
318static struct mdk_personality *find_pers(int level, char *clevel)
319{
320 struct mdk_personality *pers;
321 list_for_each_entry(pers, &pers_list, list) {
322 if (level != LEVEL_NONE && pers->level == level)
323 return pers;
324 if (strcmp(pers->name, clevel)==0)
325 return pers;
326 }
327 return NULL;
328}
329
289static inline sector_t calc_dev_sboffset(struct block_device *bdev) 330static inline sector_t calc_dev_sboffset(struct block_device *bdev)
290{ 331{
291 sector_t size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; 332 sector_t size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;
@@ -320,7 +361,7 @@ static int alloc_disk_sb(mdk_rdev_t * rdev)
320static void free_disk_sb(mdk_rdev_t * rdev) 361static void free_disk_sb(mdk_rdev_t * rdev)
321{ 362{
322 if (rdev->sb_page) { 363 if (rdev->sb_page) {
323 page_cache_release(rdev->sb_page); 364 put_page(rdev->sb_page);
324 rdev->sb_loaded = 0; 365 rdev->sb_loaded = 0;
325 rdev->sb_page = NULL; 366 rdev->sb_page = NULL;
326 rdev->sb_offset = 0; 367 rdev->sb_offset = 0;
@@ -461,6 +502,7 @@ int sync_page_io(struct block_device *bdev, sector_t sector, int size,
461 bio_put(bio); 502 bio_put(bio);
462 return ret; 503 return ret;
463} 504}
505EXPORT_SYMBOL_GPL(sync_page_io);
464 506
465static int read_disk_sb(mdk_rdev_t * rdev, int size) 507static int read_disk_sb(mdk_rdev_t * rdev, int size)
466{ 508{
@@ -665,6 +707,10 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version
665 } 707 }
666 rdev->size = calc_dev_size(rdev, sb->chunk_size); 708 rdev->size = calc_dev_size(rdev, sb->chunk_size);
667 709
710 if (rdev->size < sb->size && sb->level > 1)
711 /* "this cannot possibly happen" ... */
712 ret = -EINVAL;
713
668 abort: 714 abort:
669 return ret; 715 return ret;
670} 716}
@@ -688,6 +734,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
688 mddev->ctime = sb->ctime; 734 mddev->ctime = sb->ctime;
689 mddev->utime = sb->utime; 735 mddev->utime = sb->utime;
690 mddev->level = sb->level; 736 mddev->level = sb->level;
737 mddev->clevel[0] = 0;
691 mddev->layout = sb->layout; 738 mddev->layout = sb->layout;
692 mddev->raid_disks = sb->raid_disks; 739 mddev->raid_disks = sb->raid_disks;
693 mddev->size = sb->size; 740 mddev->size = sb->size;
@@ -714,9 +761,10 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
714 761
715 if (sb->state & (1<<MD_SB_BITMAP_PRESENT) && 762 if (sb->state & (1<<MD_SB_BITMAP_PRESENT) &&
716 mddev->bitmap_file == NULL) { 763 mddev->bitmap_file == NULL) {
717 if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6) { 764 if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6
765 && mddev->level != 10) {
718 /* FIXME use a better test */ 766 /* FIXME use a better test */
719 printk(KERN_WARNING "md: bitmaps only support for raid1\n"); 767 printk(KERN_WARNING "md: bitmaps not supported for this level.\n");
720 return -EINVAL; 768 return -EINVAL;
721 } 769 }
722 mddev->bitmap_offset = mddev->default_bitmap_offset; 770 mddev->bitmap_offset = mddev->default_bitmap_offset;
@@ -968,6 +1016,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
968 } 1016 }
969 rdev->preferred_minor = 0xffff; 1017 rdev->preferred_minor = 0xffff;
970 rdev->data_offset = le64_to_cpu(sb->data_offset); 1018 rdev->data_offset = le64_to_cpu(sb->data_offset);
1019 atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
971 1020
972 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256; 1021 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
973 bmask = queue_hardsect_size(rdev->bdev->bd_disk->queue)-1; 1022 bmask = queue_hardsect_size(rdev->bdev->bd_disk->queue)-1;
@@ -1006,6 +1055,9 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1006 rdev->size = le64_to_cpu(sb->data_size)/2; 1055 rdev->size = le64_to_cpu(sb->data_size)/2;
1007 if (le32_to_cpu(sb->chunksize)) 1056 if (le32_to_cpu(sb->chunksize))
1008 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1); 1057 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1);
1058
1059 if (le32_to_cpu(sb->size) > rdev->size*2)
1060 return -EINVAL;
1009 return 0; 1061 return 0;
1010} 1062}
1011 1063
@@ -1023,6 +1075,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1023 mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1); 1075 mddev->ctime = le64_to_cpu(sb->ctime) & ((1ULL << 32)-1);
1024 mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1); 1076 mddev->utime = le64_to_cpu(sb->utime) & ((1ULL << 32)-1);
1025 mddev->level = le32_to_cpu(sb->level); 1077 mddev->level = le32_to_cpu(sb->level);
1078 mddev->clevel[0] = 0;
1026 mddev->layout = le32_to_cpu(sb->layout); 1079 mddev->layout = le32_to_cpu(sb->layout);
1027 mddev->raid_disks = le32_to_cpu(sb->raid_disks); 1080 mddev->raid_disks = le32_to_cpu(sb->raid_disks);
1028 mddev->size = le64_to_cpu(sb->size)/2; 1081 mddev->size = le64_to_cpu(sb->size)/2;
@@ -1037,8 +1090,9 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1037 1090
1038 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) && 1091 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_BITMAP_OFFSET) &&
1039 mddev->bitmap_file == NULL ) { 1092 mddev->bitmap_file == NULL ) {
1040 if (mddev->level != 1) { 1093 if (mddev->level != 1 && mddev->level != 5 && mddev->level != 6
1041 printk(KERN_WARNING "md: bitmaps only supported for raid1\n"); 1094 && mddev->level != 10) {
1095 printk(KERN_WARNING "md: bitmaps not supported for this level.\n");
1042 return -EINVAL; 1096 return -EINVAL;
1043 } 1097 }
1044 mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset); 1098 mddev->bitmap_offset = (__s32)le32_to_cpu(sb->bitmap_offset);
@@ -1105,6 +1159,8 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1105 else 1159 else
1106 sb->resync_offset = cpu_to_le64(0); 1160 sb->resync_offset = cpu_to_le64(0);
1107 1161
1162 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors);
1163
1108 if (mddev->bitmap && mddev->bitmap_file == NULL) { 1164 if (mddev->bitmap && mddev->bitmap_file == NULL) {
1109 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset); 1165 sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);
1110 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET); 1166 sb->feature_map = cpu_to_le32(MD_FEATURE_BITMAP_OFFSET);
@@ -1187,6 +1243,14 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1187 MD_BUG(); 1243 MD_BUG();
1188 return -EINVAL; 1244 return -EINVAL;
1189 } 1245 }
1246 /* make sure rdev->size exceeds mddev->size */
1247 if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) {
1248 if (mddev->pers)
1249 /* Cannot change size, so fail */
1250 return -ENOSPC;
1251 else
1252 mddev->size = rdev->size;
1253 }
1190 same_pdev = match_dev_unit(mddev, rdev); 1254 same_pdev = match_dev_unit(mddev, rdev);
1191 if (same_pdev) 1255 if (same_pdev)
1192 printk(KERN_WARNING 1256 printk(KERN_WARNING
@@ -1496,6 +1560,26 @@ repeat:
1496 1560
1497} 1561}
1498 1562
1563/* words written to sysfs files may, or my not, be \n terminated.
1564 * We want to accept with case. For this we use cmd_match.
1565 */
1566static int cmd_match(const char *cmd, const char *str)
1567{
1568 /* See if cmd, written into a sysfs file, matches
1569 * str. They must either be the same, or cmd can
1570 * have a trailing newline
1571 */
1572 while (*cmd && *str && *cmd == *str) {
1573 cmd++;
1574 str++;
1575 }
1576 if (*cmd == '\n')
1577 cmd++;
1578 if (*str || *cmd)
1579 return 0;
1580 return 1;
1581}
1582
1499struct rdev_sysfs_entry { 1583struct rdev_sysfs_entry {
1500 struct attribute attr; 1584 struct attribute attr;
1501 ssize_t (*show)(mdk_rdev_t *, char *); 1585 ssize_t (*show)(mdk_rdev_t *, char *);
@@ -1538,9 +1622,113 @@ super_show(mdk_rdev_t *rdev, char *page)
1538} 1622}
1539static struct rdev_sysfs_entry rdev_super = __ATTR_RO(super); 1623static struct rdev_sysfs_entry rdev_super = __ATTR_RO(super);
1540 1624
1625static ssize_t
1626errors_show(mdk_rdev_t *rdev, char *page)
1627{
1628 return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
1629}
1630
1631static ssize_t
1632errors_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1633{
1634 char *e;
1635 unsigned long n = simple_strtoul(buf, &e, 10);
1636 if (*buf && (*e == 0 || *e == '\n')) {
1637 atomic_set(&rdev->corrected_errors, n);
1638 return len;
1639 }
1640 return -EINVAL;
1641}
1642static struct rdev_sysfs_entry rdev_errors =
1643__ATTR(errors, 0644, errors_show, errors_store);
1644
1645static ssize_t
1646slot_show(mdk_rdev_t *rdev, char *page)
1647{
1648 if (rdev->raid_disk < 0)
1649 return sprintf(page, "none\n");
1650 else
1651 return sprintf(page, "%d\n", rdev->raid_disk);
1652}
1653
1654static ssize_t
1655slot_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1656{
1657 char *e;
1658 int slot = simple_strtoul(buf, &e, 10);
1659 if (strncmp(buf, "none", 4)==0)
1660 slot = -1;
1661 else if (e==buf || (*e && *e!= '\n'))
1662 return -EINVAL;
1663 if (rdev->mddev->pers)
1664 /* Cannot set slot in active array (yet) */
1665 return -EBUSY;
1666 if (slot >= rdev->mddev->raid_disks)
1667 return -ENOSPC;
1668 rdev->raid_disk = slot;
1669 /* assume it is working */
1670 rdev->flags = 0;
1671 set_bit(In_sync, &rdev->flags);
1672 return len;
1673}
1674
1675
1676static struct rdev_sysfs_entry rdev_slot =
1677__ATTR(slot, 0644, slot_show, slot_store);
1678
1679static ssize_t
1680offset_show(mdk_rdev_t *rdev, char *page)
1681{
1682 return sprintf(page, "%llu\n", (unsigned long long)rdev->data_offset);
1683}
1684
1685static ssize_t
1686offset_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1687{
1688 char *e;
1689 unsigned long long offset = simple_strtoull(buf, &e, 10);
1690 if (e==buf || (*e && *e != '\n'))
1691 return -EINVAL;
1692 if (rdev->mddev->pers)
1693 return -EBUSY;
1694 rdev->data_offset = offset;
1695 return len;
1696}
1697
1698static struct rdev_sysfs_entry rdev_offset =
1699__ATTR(offset, 0644, offset_show, offset_store);
1700
1701static ssize_t
1702rdev_size_show(mdk_rdev_t *rdev, char *page)
1703{
1704 return sprintf(page, "%llu\n", (unsigned long long)rdev->size);
1705}
1706
1707static ssize_t
1708rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
1709{
1710 char *e;
1711 unsigned long long size = simple_strtoull(buf, &e, 10);
1712 if (e==buf || (*e && *e != '\n'))
1713 return -EINVAL;
1714 if (rdev->mddev->pers)
1715 return -EBUSY;
1716 rdev->size = size;
1717 if (size < rdev->mddev->size || rdev->mddev->size == 0)
1718 rdev->mddev->size = size;
1719 return len;
1720}
1721
1722static struct rdev_sysfs_entry rdev_size =
1723__ATTR(size, 0644, rdev_size_show, rdev_size_store);
1724
1541static struct attribute *rdev_default_attrs[] = { 1725static struct attribute *rdev_default_attrs[] = {
1542 &rdev_state.attr, 1726 &rdev_state.attr,
1543 &rdev_super.attr, 1727 &rdev_super.attr,
1728 &rdev_errors.attr,
1729 &rdev_slot.attr,
1730 &rdev_offset.attr,
1731 &rdev_size.attr,
1544 NULL, 1732 NULL,
1545}; 1733};
1546static ssize_t 1734static ssize_t
@@ -1598,12 +1786,11 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
1598 mdk_rdev_t *rdev; 1786 mdk_rdev_t *rdev;
1599 sector_t size; 1787 sector_t size;
1600 1788
1601 rdev = (mdk_rdev_t *) kmalloc(sizeof(*rdev), GFP_KERNEL); 1789 rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
1602 if (!rdev) { 1790 if (!rdev) {
1603 printk(KERN_ERR "md: could not alloc mem for new device!\n"); 1791 printk(KERN_ERR "md: could not alloc mem for new device!\n");
1604 return ERR_PTR(-ENOMEM); 1792 return ERR_PTR(-ENOMEM);
1605 } 1793 }
1606 memset(rdev, 0, sizeof(*rdev));
1607 1794
1608 if ((err = alloc_disk_sb(rdev))) 1795 if ((err = alloc_disk_sb(rdev)))
1609 goto abort_free; 1796 goto abort_free;
@@ -1621,6 +1808,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
1621 rdev->data_offset = 0; 1808 rdev->data_offset = 0;
1622 atomic_set(&rdev->nr_pending, 0); 1809 atomic_set(&rdev->nr_pending, 0);
1623 atomic_set(&rdev->read_errors, 0); 1810 atomic_set(&rdev->read_errors, 0);
1811 atomic_set(&rdev->corrected_errors, 0);
1624 1812
1625 size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; 1813 size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;
1626 if (!size) { 1814 if (!size) {
@@ -1725,16 +1913,37 @@ static void analyze_sbs(mddev_t * mddev)
1725static ssize_t 1913static ssize_t
1726level_show(mddev_t *mddev, char *page) 1914level_show(mddev_t *mddev, char *page)
1727{ 1915{
1728 mdk_personality_t *p = mddev->pers; 1916 struct mdk_personality *p = mddev->pers;
1729 if (p == NULL && mddev->raid_disks == 0) 1917 if (p)
1730 return 0;
1731 if (mddev->level >= 0)
1732 return sprintf(page, "RAID-%d\n", mddev->level);
1733 else
1734 return sprintf(page, "%s\n", p->name); 1918 return sprintf(page, "%s\n", p->name);
1919 else if (mddev->clevel[0])
1920 return sprintf(page, "%s\n", mddev->clevel);
1921 else if (mddev->level != LEVEL_NONE)
1922 return sprintf(page, "%d\n", mddev->level);
1923 else
1924 return 0;
1925}
1926
1927static ssize_t
1928level_store(mddev_t *mddev, const char *buf, size_t len)
1929{
1930 int rv = len;
1931 if (mddev->pers)
1932 return -EBUSY;
1933 if (len == 0)
1934 return 0;
1935 if (len >= sizeof(mddev->clevel))
1936 return -ENOSPC;
1937 strncpy(mddev->clevel, buf, len);
1938 if (mddev->clevel[len-1] == '\n')
1939 len--;
1940 mddev->clevel[len] = 0;
1941 mddev->level = LEVEL_NONE;
1942 return rv;
1735} 1943}
1736 1944
1737static struct md_sysfs_entry md_level = __ATTR_RO(level); 1945static struct md_sysfs_entry md_level =
1946__ATTR(level, 0644, level_show, level_store);
1738 1947
1739static ssize_t 1948static ssize_t
1740raid_disks_show(mddev_t *mddev, char *page) 1949raid_disks_show(mddev_t *mddev, char *page)
@@ -1744,7 +1953,197 @@ raid_disks_show(mddev_t *mddev, char *page)
1744 return sprintf(page, "%d\n", mddev->raid_disks); 1953 return sprintf(page, "%d\n", mddev->raid_disks);
1745} 1954}
1746 1955
1747static struct md_sysfs_entry md_raid_disks = __ATTR_RO(raid_disks); 1956static int update_raid_disks(mddev_t *mddev, int raid_disks);
1957
1958static ssize_t
1959raid_disks_store(mddev_t *mddev, const char *buf, size_t len)
1960{
1961 /* can only set raid_disks if array is not yet active */
1962 char *e;
1963 int rv = 0;
1964 unsigned long n = simple_strtoul(buf, &e, 10);
1965
1966 if (!*buf || (*e && *e != '\n'))
1967 return -EINVAL;
1968
1969 if (mddev->pers)
1970 rv = update_raid_disks(mddev, n);
1971 else
1972 mddev->raid_disks = n;
1973 return rv ? rv : len;
1974}
1975static struct md_sysfs_entry md_raid_disks =
1976__ATTR(raid_disks, 0644, raid_disks_show, raid_disks_store);
1977
1978static ssize_t
1979chunk_size_show(mddev_t *mddev, char *page)
1980{
1981 return sprintf(page, "%d\n", mddev->chunk_size);
1982}
1983
1984static ssize_t
1985chunk_size_store(mddev_t *mddev, const char *buf, size_t len)
1986{
1987 /* can only set chunk_size if array is not yet active */
1988 char *e;
1989 unsigned long n = simple_strtoul(buf, &e, 10);
1990
1991 if (mddev->pers)
1992 return -EBUSY;
1993 if (!*buf || (*e && *e != '\n'))
1994 return -EINVAL;
1995
1996 mddev->chunk_size = n;
1997 return len;
1998}
1999static struct md_sysfs_entry md_chunk_size =
2000__ATTR(chunk_size, 0644, chunk_size_show, chunk_size_store);
2001
2002static ssize_t
2003null_show(mddev_t *mddev, char *page)
2004{
2005 return -EINVAL;
2006}
2007
2008static ssize_t
2009new_dev_store(mddev_t *mddev, const char *buf, size_t len)
2010{
2011 /* buf must be %d:%d\n? giving major and minor numbers */
2012 /* The new device is added to the array.
2013 * If the array has a persistent superblock, we read the
2014 * superblock to initialise info and check validity.
2015 * Otherwise, only checking done is that in bind_rdev_to_array,
2016 * which mainly checks size.
2017 */
2018 char *e;
2019 int major = simple_strtoul(buf, &e, 10);
2020 int minor;
2021 dev_t dev;
2022 mdk_rdev_t *rdev;
2023 int err;
2024
2025 if (!*buf || *e != ':' || !e[1] || e[1] == '\n')
2026 return -EINVAL;
2027 minor = simple_strtoul(e+1, &e, 10);
2028 if (*e && *e != '\n')
2029 return -EINVAL;
2030 dev = MKDEV(major, minor);
2031 if (major != MAJOR(dev) ||
2032 minor != MINOR(dev))
2033 return -EOVERFLOW;
2034
2035
2036 if (mddev->persistent) {
2037 rdev = md_import_device(dev, mddev->major_version,
2038 mddev->minor_version);
2039 if (!IS_ERR(rdev) && !list_empty(&mddev->disks)) {
2040 mdk_rdev_t *rdev0 = list_entry(mddev->disks.next,
2041 mdk_rdev_t, same_set);
2042 err = super_types[mddev->major_version]
2043 .load_super(rdev, rdev0, mddev->minor_version);
2044 if (err < 0)
2045 goto out;
2046 }
2047 } else
2048 rdev = md_import_device(dev, -1, -1);
2049
2050 if (IS_ERR(rdev))
2051 return PTR_ERR(rdev);
2052 err = bind_rdev_to_array(rdev, mddev);
2053 out:
2054 if (err)
2055 export_rdev(rdev);
2056 return err ? err : len;
2057}
2058
2059static struct md_sysfs_entry md_new_device =
2060__ATTR(new_dev, 0200, null_show, new_dev_store);
2061
2062static ssize_t
2063size_show(mddev_t *mddev, char *page)
2064{
2065 return sprintf(page, "%llu\n", (unsigned long long)mddev->size);
2066}
2067
2068static int update_size(mddev_t *mddev, unsigned long size);
2069
2070static ssize_t
2071size_store(mddev_t *mddev, const char *buf, size_t len)
2072{
2073 /* If array is inactive, we can reduce the component size, but
2074 * not increase it (except from 0).
2075 * If array is active, we can try an on-line resize
2076 */
2077 char *e;
2078 int err = 0;
2079 unsigned long long size = simple_strtoull(buf, &e, 10);
2080 if (!*buf || *buf == '\n' ||
2081 (*e && *e != '\n'))
2082 return -EINVAL;
2083
2084 if (mddev->pers) {
2085 err = update_size(mddev, size);
2086 md_update_sb(mddev);
2087 } else {
2088 if (mddev->size == 0 ||
2089 mddev->size > size)
2090 mddev->size = size;
2091 else
2092 err = -ENOSPC;
2093 }
2094 return err ? err : len;
2095}
2096
2097static struct md_sysfs_entry md_size =
2098__ATTR(component_size, 0644, size_show, size_store);
2099
2100
2101/* Metdata version.
2102 * This is either 'none' for arrays with externally managed metadata,
2103 * or N.M for internally known formats
2104 */
2105static ssize_t
2106metadata_show(mddev_t *mddev, char *page)
2107{
2108 if (mddev->persistent)
2109 return sprintf(page, "%d.%d\n",
2110 mddev->major_version, mddev->minor_version);
2111 else
2112 return sprintf(page, "none\n");
2113}
2114
2115static ssize_t
2116metadata_store(mddev_t *mddev, const char *buf, size_t len)
2117{
2118 int major, minor;
2119 char *e;
2120 if (!list_empty(&mddev->disks))
2121 return -EBUSY;
2122
2123 if (cmd_match(buf, "none")) {
2124 mddev->persistent = 0;
2125 mddev->major_version = 0;
2126 mddev->minor_version = 90;
2127 return len;
2128 }
2129 major = simple_strtoul(buf, &e, 10);
2130 if (e==buf || *e != '.')
2131 return -EINVAL;
2132 buf = e+1;
2133 minor = simple_strtoul(buf, &e, 10);
2134 if (e==buf || *e != '\n')
2135 return -EINVAL;
2136 if (major >= sizeof(super_types)/sizeof(super_types[0]) ||
2137 super_types[major].name == NULL)
2138 return -ENOENT;
2139 mddev->major_version = major;
2140 mddev->minor_version = minor;
2141 mddev->persistent = 1;
2142 return len;
2143}
2144
2145static struct md_sysfs_entry md_metadata =
2146__ATTR(metadata_version, 0644, metadata_show, metadata_store);
1748 2147
1749static ssize_t 2148static ssize_t
1750action_show(mddev_t *mddev, char *page) 2149action_show(mddev_t *mddev, char *page)
@@ -1771,31 +2170,27 @@ action_store(mddev_t *mddev, const char *page, size_t len)
1771 if (!mddev->pers || !mddev->pers->sync_request) 2170 if (!mddev->pers || !mddev->pers->sync_request)
1772 return -EINVAL; 2171 return -EINVAL;
1773 2172
1774 if (strcmp(page, "idle")==0 || strcmp(page, "idle\n")==0) { 2173 if (cmd_match(page, "idle")) {
1775 if (mddev->sync_thread) { 2174 if (mddev->sync_thread) {
1776 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 2175 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
1777 md_unregister_thread(mddev->sync_thread); 2176 md_unregister_thread(mddev->sync_thread);
1778 mddev->sync_thread = NULL; 2177 mddev->sync_thread = NULL;
1779 mddev->recovery = 0; 2178 mddev->recovery = 0;
1780 } 2179 }
1781 return len; 2180 } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
1782 } 2181 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
1783
1784 if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) ||
1785 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
1786 return -EBUSY; 2182 return -EBUSY;
1787 if (strcmp(page, "resync")==0 || strcmp(page, "resync\n")==0 || 2183 else if (cmd_match(page, "resync") || cmd_match(page, "recover"))
1788 strcmp(page, "recover")==0 || strcmp(page, "recover\n")==0)
1789 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 2184 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1790 else { 2185 else {
1791 if (strcmp(page, "check")==0 || strcmp(page, "check\n")==0) 2186 if (cmd_match(page, "check"))
1792 set_bit(MD_RECOVERY_CHECK, &mddev->recovery); 2187 set_bit(MD_RECOVERY_CHECK, &mddev->recovery);
1793 else if (strcmp(page, "repair")!=0 && strcmp(page, "repair\n")!=0) 2188 else if (cmd_match(page, "repair"))
1794 return -EINVAL; 2189 return -EINVAL;
1795 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); 2190 set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery);
1796 set_bit(MD_RECOVERY_SYNC, &mddev->recovery); 2191 set_bit(MD_RECOVERY_SYNC, &mddev->recovery);
1797 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1798 } 2192 }
2193 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1799 md_wakeup_thread(mddev->thread); 2194 md_wakeup_thread(mddev->thread);
1800 return len; 2195 return len;
1801} 2196}
@@ -1814,15 +2209,107 @@ md_scan_mode = __ATTR(sync_action, S_IRUGO|S_IWUSR, action_show, action_store);
1814static struct md_sysfs_entry 2209static struct md_sysfs_entry
1815md_mismatches = __ATTR_RO(mismatch_cnt); 2210md_mismatches = __ATTR_RO(mismatch_cnt);
1816 2211
2212static ssize_t
2213sync_min_show(mddev_t *mddev, char *page)
2214{
2215 return sprintf(page, "%d (%s)\n", speed_min(mddev),
2216 mddev->sync_speed_min ? "local": "system");
2217}
2218
2219static ssize_t
2220sync_min_store(mddev_t *mddev, const char *buf, size_t len)
2221{
2222 int min;
2223 char *e;
2224 if (strncmp(buf, "system", 6)==0) {
2225 mddev->sync_speed_min = 0;
2226 return len;
2227 }
2228 min = simple_strtoul(buf, &e, 10);
2229 if (buf == e || (*e && *e != '\n') || min <= 0)
2230 return -EINVAL;
2231 mddev->sync_speed_min = min;
2232 return len;
2233}
2234
2235static struct md_sysfs_entry md_sync_min =
2236__ATTR(sync_speed_min, S_IRUGO|S_IWUSR, sync_min_show, sync_min_store);
2237
2238static ssize_t
2239sync_max_show(mddev_t *mddev, char *page)
2240{
2241 return sprintf(page, "%d (%s)\n", speed_max(mddev),
2242 mddev->sync_speed_max ? "local": "system");
2243}
2244
2245static ssize_t
2246sync_max_store(mddev_t *mddev, const char *buf, size_t len)
2247{
2248 int max;
2249 char *e;
2250 if (strncmp(buf, "system", 6)==0) {
2251 mddev->sync_speed_max = 0;
2252 return len;
2253 }
2254 max = simple_strtoul(buf, &e, 10);
2255 if (buf == e || (*e && *e != '\n') || max <= 0)
2256 return -EINVAL;
2257 mddev->sync_speed_max = max;
2258 return len;
2259}
2260
2261static struct md_sysfs_entry md_sync_max =
2262__ATTR(sync_speed_max, S_IRUGO|S_IWUSR, sync_max_show, sync_max_store);
2263
2264
2265static ssize_t
2266sync_speed_show(mddev_t *mddev, char *page)
2267{
2268 unsigned long resync, dt, db;
2269 resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active));
2270 dt = ((jiffies - mddev->resync_mark) / HZ);
2271 if (!dt) dt++;
2272 db = resync - (mddev->resync_mark_cnt);
2273 return sprintf(page, "%ld\n", db/dt/2); /* K/sec */
2274}
2275
2276static struct md_sysfs_entry
2277md_sync_speed = __ATTR_RO(sync_speed);
2278
2279static ssize_t
2280sync_completed_show(mddev_t *mddev, char *page)
2281{
2282 unsigned long max_blocks, resync;
2283
2284 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
2285 max_blocks = mddev->resync_max_sectors;
2286 else
2287 max_blocks = mddev->size << 1;
2288
2289 resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active));
2290 return sprintf(page, "%lu / %lu\n", resync, max_blocks);
2291}
2292
2293static struct md_sysfs_entry
2294md_sync_completed = __ATTR_RO(sync_completed);
2295
1817static struct attribute *md_default_attrs[] = { 2296static struct attribute *md_default_attrs[] = {
1818 &md_level.attr, 2297 &md_level.attr,
1819 &md_raid_disks.attr, 2298 &md_raid_disks.attr,
2299 &md_chunk_size.attr,
2300 &md_size.attr,
2301 &md_metadata.attr,
2302 &md_new_device.attr,
1820 NULL, 2303 NULL,
1821}; 2304};
1822 2305
1823static struct attribute *md_redundancy_attrs[] = { 2306static struct attribute *md_redundancy_attrs[] = {
1824 &md_scan_mode.attr, 2307 &md_scan_mode.attr,
1825 &md_mismatches.attr, 2308 &md_mismatches.attr,
2309 &md_sync_min.attr,
2310 &md_sync_max.attr,
2311 &md_sync_speed.attr,
2312 &md_sync_completed.attr,
1826 NULL, 2313 NULL,
1827}; 2314};
1828static struct attribute_group md_redundancy_group = { 2315static struct attribute_group md_redundancy_group = {
@@ -1937,14 +2424,16 @@ static void md_safemode_timeout(unsigned long data)
1937 md_wakeup_thread(mddev->thread); 2424 md_wakeup_thread(mddev->thread);
1938} 2425}
1939 2426
2427static int start_dirty_degraded;
1940 2428
1941static int do_md_run(mddev_t * mddev) 2429static int do_md_run(mddev_t * mddev)
1942{ 2430{
1943 int pnum, err; 2431 int err;
1944 int chunk_size; 2432 int chunk_size;
1945 struct list_head *tmp; 2433 struct list_head *tmp;
1946 mdk_rdev_t *rdev; 2434 mdk_rdev_t *rdev;
1947 struct gendisk *disk; 2435 struct gendisk *disk;
2436 struct mdk_personality *pers;
1948 char b[BDEVNAME_SIZE]; 2437 char b[BDEVNAME_SIZE];
1949 2438
1950 if (list_empty(&mddev->disks)) 2439 if (list_empty(&mddev->disks))
@@ -1961,20 +2450,8 @@ static int do_md_run(mddev_t * mddev)
1961 analyze_sbs(mddev); 2450 analyze_sbs(mddev);
1962 2451
1963 chunk_size = mddev->chunk_size; 2452 chunk_size = mddev->chunk_size;
1964 pnum = level_to_pers(mddev->level);
1965 2453
1966 if ((pnum != MULTIPATH) && (pnum != RAID1)) { 2454 if (chunk_size) {
1967 if (!chunk_size) {
1968 /*
1969 * 'default chunksize' in the old md code used to
1970 * be PAGE_SIZE, baaad.
1971 * we abort here to be on the safe side. We don't
1972 * want to continue the bad practice.
1973 */
1974 printk(KERN_ERR
1975 "no chunksize specified, see 'man raidtab'\n");
1976 return -EINVAL;
1977 }
1978 if (chunk_size > MAX_CHUNK_SIZE) { 2455 if (chunk_size > MAX_CHUNK_SIZE) {
1979 printk(KERN_ERR "too big chunk_size: %d > %d\n", 2456 printk(KERN_ERR "too big chunk_size: %d > %d\n",
1980 chunk_size, MAX_CHUNK_SIZE); 2457 chunk_size, MAX_CHUNK_SIZE);
@@ -2010,10 +2487,10 @@ static int do_md_run(mddev_t * mddev)
2010 } 2487 }
2011 2488
2012#ifdef CONFIG_KMOD 2489#ifdef CONFIG_KMOD
2013 if (!pers[pnum]) 2490 if (mddev->level != LEVEL_NONE)
2014 { 2491 request_module("md-level-%d", mddev->level);
2015 request_module("md-personality-%d", pnum); 2492 else if (mddev->clevel[0])
2016 } 2493 request_module("md-%s", mddev->clevel);
2017#endif 2494#endif
2018 2495
2019 /* 2496 /*
@@ -2035,30 +2512,39 @@ static int do_md_run(mddev_t * mddev)
2035 return -ENOMEM; 2512 return -ENOMEM;
2036 2513
2037 spin_lock(&pers_lock); 2514 spin_lock(&pers_lock);
2038 if (!pers[pnum] || !try_module_get(pers[pnum]->owner)) { 2515 pers = find_pers(mddev->level, mddev->clevel);
2516 if (!pers || !try_module_get(pers->owner)) {
2039 spin_unlock(&pers_lock); 2517 spin_unlock(&pers_lock);
2040 printk(KERN_WARNING "md: personality %d is not loaded!\n", 2518 if (mddev->level != LEVEL_NONE)
2041 pnum); 2519 printk(KERN_WARNING "md: personality for level %d is not loaded!\n",
2520 mddev->level);
2521 else
2522 printk(KERN_WARNING "md: personality for level %s is not loaded!\n",
2523 mddev->clevel);
2042 return -EINVAL; 2524 return -EINVAL;
2043 } 2525 }
2044 2526 mddev->pers = pers;
2045 mddev->pers = pers[pnum];
2046 spin_unlock(&pers_lock); 2527 spin_unlock(&pers_lock);
2528 mddev->level = pers->level;
2529 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
2047 2530
2048 mddev->recovery = 0; 2531 mddev->recovery = 0;
2049 mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */ 2532 mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */
2050 mddev->barriers_work = 1; 2533 mddev->barriers_work = 1;
2534 mddev->ok_start_degraded = start_dirty_degraded;
2051 2535
2052 if (start_readonly) 2536 if (start_readonly)
2053 mddev->ro = 2; /* read-only, but switch on first write */ 2537 mddev->ro = 2; /* read-only, but switch on first write */
2054 2538
2055 /* before we start the array running, initialise the bitmap */ 2539 err = mddev->pers->run(mddev);
2056 err = bitmap_create(mddev); 2540 if (!err && mddev->pers->sync_request) {
2057 if (err) 2541 err = bitmap_create(mddev);
2058 printk(KERN_ERR "%s: failed to create bitmap (%d)\n", 2542 if (err) {
2059 mdname(mddev), err); 2543 printk(KERN_ERR "%s: failed to create bitmap (%d)\n",
2060 else 2544 mdname(mddev), err);
2061 err = mddev->pers->run(mddev); 2545 mddev->pers->stop(mddev);
2546 }
2547 }
2062 if (err) { 2548 if (err) {
2063 printk(KERN_ERR "md: pers->run() failed ...\n"); 2549 printk(KERN_ERR "md: pers->run() failed ...\n");
2064 module_put(mddev->pers->owner); 2550 module_put(mddev->pers->owner);
@@ -2104,6 +2590,7 @@ static int do_md_run(mddev_t * mddev)
2104 mddev->queue->make_request_fn = mddev->pers->make_request; 2590 mddev->queue->make_request_fn = mddev->pers->make_request;
2105 2591
2106 mddev->changed = 1; 2592 mddev->changed = 1;
2593 md_new_event(mddev);
2107 return 0; 2594 return 0;
2108} 2595}
2109 2596
@@ -2231,6 +2718,7 @@ static int do_md_stop(mddev_t * mddev, int ro)
2231 printk(KERN_INFO "md: %s switched to read-only mode.\n", 2718 printk(KERN_INFO "md: %s switched to read-only mode.\n",
2232 mdname(mddev)); 2719 mdname(mddev));
2233 err = 0; 2720 err = 0;
2721 md_new_event(mddev);
2234out: 2722out:
2235 return err; 2723 return err;
2236} 2724}
@@ -2668,12 +3156,6 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
2668 if (info->state & (1<<MD_DISK_WRITEMOSTLY)) 3156 if (info->state & (1<<MD_DISK_WRITEMOSTLY))
2669 set_bit(WriteMostly, &rdev->flags); 3157 set_bit(WriteMostly, &rdev->flags);
2670 3158
2671 err = bind_rdev_to_array(rdev, mddev);
2672 if (err) {
2673 export_rdev(rdev);
2674 return err;
2675 }
2676
2677 if (!mddev->persistent) { 3159 if (!mddev->persistent) {
2678 printk(KERN_INFO "md: nonpersistent superblock ...\n"); 3160 printk(KERN_INFO "md: nonpersistent superblock ...\n");
2679 rdev->sb_offset = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; 3161 rdev->sb_offset = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;
@@ -2681,8 +3163,11 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
2681 rdev->sb_offset = calc_dev_sboffset(rdev->bdev); 3163 rdev->sb_offset = calc_dev_sboffset(rdev->bdev);
2682 rdev->size = calc_dev_size(rdev, mddev->chunk_size); 3164 rdev->size = calc_dev_size(rdev, mddev->chunk_size);
2683 3165
2684 if (!mddev->size || (mddev->size > rdev->size)) 3166 err = bind_rdev_to_array(rdev, mddev);
2685 mddev->size = rdev->size; 3167 if (err) {
3168 export_rdev(rdev);
3169 return err;
3170 }
2686 } 3171 }
2687 3172
2688 return 0; 3173 return 0;
@@ -2705,6 +3190,7 @@ static int hot_remove_disk(mddev_t * mddev, dev_t dev)
2705 3190
2706 kick_rdev_from_array(rdev); 3191 kick_rdev_from_array(rdev);
2707 md_update_sb(mddev); 3192 md_update_sb(mddev);
3193 md_new_event(mddev);
2708 3194
2709 return 0; 3195 return 0;
2710busy: 3196busy:
@@ -2753,15 +3239,6 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
2753 size = calc_dev_size(rdev, mddev->chunk_size); 3239 size = calc_dev_size(rdev, mddev->chunk_size);
2754 rdev->size = size; 3240 rdev->size = size;
2755 3241
2756 if (size < mddev->size) {
2757 printk(KERN_WARNING
2758 "%s: disk size %llu blocks < array size %llu\n",
2759 mdname(mddev), (unsigned long long)size,
2760 (unsigned long long)mddev->size);
2761 err = -ENOSPC;
2762 goto abort_export;
2763 }
2764
2765 if (test_bit(Faulty, &rdev->flags)) { 3242 if (test_bit(Faulty, &rdev->flags)) {
2766 printk(KERN_WARNING 3243 printk(KERN_WARNING
2767 "md: can not hot-add faulty %s disk to %s!\n", 3244 "md: can not hot-add faulty %s disk to %s!\n",
@@ -2771,7 +3248,9 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
2771 } 3248 }
2772 clear_bit(In_sync, &rdev->flags); 3249 clear_bit(In_sync, &rdev->flags);
2773 rdev->desc_nr = -1; 3250 rdev->desc_nr = -1;
2774 bind_rdev_to_array(rdev, mddev); 3251 err = bind_rdev_to_array(rdev, mddev);
3252 if (err)
3253 goto abort_export;
2775 3254
2776 /* 3255 /*
2777 * The rest should better be atomic, we can have disk failures 3256 * The rest should better be atomic, we can have disk failures
@@ -2795,7 +3274,7 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
2795 */ 3274 */
2796 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 3275 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
2797 md_wakeup_thread(mddev->thread); 3276 md_wakeup_thread(mddev->thread);
2798 3277 md_new_event(mddev);
2799 return 0; 3278 return 0;
2800 3279
2801abort_unbind_export: 3280abort_unbind_export:
@@ -2942,6 +3421,81 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
2942 return 0; 3421 return 0;
2943} 3422}
2944 3423
3424static int update_size(mddev_t *mddev, unsigned long size)
3425{
3426 mdk_rdev_t * rdev;
3427 int rv;
3428 struct list_head *tmp;
3429
3430 if (mddev->pers->resize == NULL)
3431 return -EINVAL;
3432 /* The "size" is the amount of each device that is used.
3433 * This can only make sense for arrays with redundancy.
3434 * linear and raid0 always use whatever space is available
3435 * We can only consider changing the size if no resync
3436 * or reconstruction is happening, and if the new size
3437 * is acceptable. It must fit before the sb_offset or,
3438 * if that is <data_offset, it must fit before the
3439 * size of each device.
3440 * If size is zero, we find the largest size that fits.
3441 */
3442 if (mddev->sync_thread)
3443 return -EBUSY;
3444 ITERATE_RDEV(mddev,rdev,tmp) {
3445 sector_t avail;
3446 int fit = (size == 0);
3447 if (rdev->sb_offset > rdev->data_offset)
3448 avail = (rdev->sb_offset*2) - rdev->data_offset;
3449 else
3450 avail = get_capacity(rdev->bdev->bd_disk)
3451 - rdev->data_offset;
3452 if (fit && (size == 0 || size > avail/2))
3453 size = avail/2;
3454 if (avail < ((sector_t)size << 1))
3455 return -ENOSPC;
3456 }
3457 rv = mddev->pers->resize(mddev, (sector_t)size *2);
3458 if (!rv) {
3459 struct block_device *bdev;
3460
3461 bdev = bdget_disk(mddev->gendisk, 0);
3462 if (bdev) {
3463 down(&bdev->bd_inode->i_sem);
3464 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3465 up(&bdev->bd_inode->i_sem);
3466 bdput(bdev);
3467 }
3468 }
3469 return rv;
3470}
3471
3472static int update_raid_disks(mddev_t *mddev, int raid_disks)
3473{
3474 int rv;
3475 /* change the number of raid disks */
3476 if (mddev->pers->reshape == NULL)
3477 return -EINVAL;
3478 if (raid_disks <= 0 ||
3479 raid_disks >= mddev->max_disks)
3480 return -EINVAL;
3481 if (mddev->sync_thread)
3482 return -EBUSY;
3483 rv = mddev->pers->reshape(mddev, raid_disks);
3484 if (!rv) {
3485 struct block_device *bdev;
3486
3487 bdev = bdget_disk(mddev->gendisk, 0);
3488 if (bdev) {
3489 down(&bdev->bd_inode->i_sem);
3490 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3491 up(&bdev->bd_inode->i_sem);
3492 bdput(bdev);
3493 }
3494 }
3495 return rv;
3496}
3497
3498
2945/* 3499/*
2946 * update_array_info is used to change the configuration of an 3500 * update_array_info is used to change the configuration of an
2947 * on-line array. 3501 * on-line array.
@@ -2990,71 +3544,12 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
2990 else 3544 else
2991 return mddev->pers->reconfig(mddev, info->layout, -1); 3545 return mddev->pers->reconfig(mddev, info->layout, -1);
2992 } 3546 }
2993 if (mddev->size != info->size) { 3547 if (mddev->size != info->size)
2994 mdk_rdev_t * rdev; 3548 rv = update_size(mddev, info->size);
2995 struct list_head *tmp; 3549
2996 if (mddev->pers->resize == NULL) 3550 if (mddev->raid_disks != info->raid_disks)
2997 return -EINVAL; 3551 rv = update_raid_disks(mddev, info->raid_disks);
2998 /* The "size" is the amount of each device that is used. 3552
2999 * This can only make sense for arrays with redundancy.
3000 * linear and raid0 always use whatever space is available
3001 * We can only consider changing the size if no resync
3002 * or reconstruction is happening, and if the new size
3003 * is acceptable. It must fit before the sb_offset or,
3004 * if that is <data_offset, it must fit before the
3005 * size of each device.
3006 * If size is zero, we find the largest size that fits.
3007 */
3008 if (mddev->sync_thread)
3009 return -EBUSY;
3010 ITERATE_RDEV(mddev,rdev,tmp) {
3011 sector_t avail;
3012 int fit = (info->size == 0);
3013 if (rdev->sb_offset > rdev->data_offset)
3014 avail = (rdev->sb_offset*2) - rdev->data_offset;
3015 else
3016 avail = get_capacity(rdev->bdev->bd_disk)
3017 - rdev->data_offset;
3018 if (fit && (info->size == 0 || info->size > avail/2))
3019 info->size = avail/2;
3020 if (avail < ((sector_t)info->size << 1))
3021 return -ENOSPC;
3022 }
3023 rv = mddev->pers->resize(mddev, (sector_t)info->size *2);
3024 if (!rv) {
3025 struct block_device *bdev;
3026
3027 bdev = bdget_disk(mddev->gendisk, 0);
3028 if (bdev) {
3029 down(&bdev->bd_inode->i_sem);
3030 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3031 up(&bdev->bd_inode->i_sem);
3032 bdput(bdev);
3033 }
3034 }
3035 }
3036 if (mddev->raid_disks != info->raid_disks) {
3037 /* change the number of raid disks */
3038 if (mddev->pers->reshape == NULL)
3039 return -EINVAL;
3040 if (info->raid_disks <= 0 ||
3041 info->raid_disks >= mddev->max_disks)
3042 return -EINVAL;
3043 if (mddev->sync_thread)
3044 return -EBUSY;
3045 rv = mddev->pers->reshape(mddev, info->raid_disks);
3046 if (!rv) {
3047 struct block_device *bdev;
3048
3049 bdev = bdget_disk(mddev->gendisk, 0);
3050 if (bdev) {
3051 down(&bdev->bd_inode->i_sem);
3052 i_size_write(bdev->bd_inode, mddev->array_size << 10);
3053 up(&bdev->bd_inode->i_sem);
3054 bdput(bdev);
3055 }
3056 }
3057 }
3058 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) { 3553 if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) {
3059 if (mddev->pers->quiesce == NULL) 3554 if (mddev->pers->quiesce == NULL)
3060 return -EINVAL; 3555 return -EINVAL;
@@ -3476,11 +3971,10 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,
3476{ 3971{
3477 mdk_thread_t *thread; 3972 mdk_thread_t *thread;
3478 3973
3479 thread = kmalloc(sizeof(mdk_thread_t), GFP_KERNEL); 3974 thread = kzalloc(sizeof(mdk_thread_t), GFP_KERNEL);
3480 if (!thread) 3975 if (!thread)
3481 return NULL; 3976 return NULL;
3482 3977
3483 memset(thread, 0, sizeof(mdk_thread_t));
3484 init_waitqueue_head(&thread->wqueue); 3978 init_waitqueue_head(&thread->wqueue);
3485 3979
3486 thread->run = run; 3980 thread->run = run;
@@ -3524,6 +4018,7 @@ void md_error(mddev_t *mddev, mdk_rdev_t *rdev)
3524 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 4018 set_bit(MD_RECOVERY_INTR, &mddev->recovery);
3525 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4019 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
3526 md_wakeup_thread(mddev->thread); 4020 md_wakeup_thread(mddev->thread);
4021 md_new_event(mddev);
3527} 4022}
3528 4023
3529/* seq_file implementation /proc/mdstat */ 4024/* seq_file implementation /proc/mdstat */
@@ -3664,24 +4159,29 @@ static void md_seq_stop(struct seq_file *seq, void *v)
3664 mddev_put(mddev); 4159 mddev_put(mddev);
3665} 4160}
3666 4161
4162struct mdstat_info {
4163 int event;
4164};
4165
3667static int md_seq_show(struct seq_file *seq, void *v) 4166static int md_seq_show(struct seq_file *seq, void *v)
3668{ 4167{
3669 mddev_t *mddev = v; 4168 mddev_t *mddev = v;
3670 sector_t size; 4169 sector_t size;
3671 struct list_head *tmp2; 4170 struct list_head *tmp2;
3672 mdk_rdev_t *rdev; 4171 mdk_rdev_t *rdev;
3673 int i; 4172 struct mdstat_info *mi = seq->private;
3674 struct bitmap *bitmap; 4173 struct bitmap *bitmap;
3675 4174
3676 if (v == (void*)1) { 4175 if (v == (void*)1) {
4176 struct mdk_personality *pers;
3677 seq_printf(seq, "Personalities : "); 4177 seq_printf(seq, "Personalities : ");
3678 spin_lock(&pers_lock); 4178 spin_lock(&pers_lock);
3679 for (i = 0; i < MAX_PERSONALITY; i++) 4179 list_for_each_entry(pers, &pers_list, list)
3680 if (pers[i]) 4180 seq_printf(seq, "[%s] ", pers->name);
3681 seq_printf(seq, "[%s] ", pers[i]->name);
3682 4181
3683 spin_unlock(&pers_lock); 4182 spin_unlock(&pers_lock);
3684 seq_printf(seq, "\n"); 4183 seq_printf(seq, "\n");
4184 mi->event = atomic_read(&md_event_count);
3685 return 0; 4185 return 0;
3686 } 4186 }
3687 if (v == (void*)2) { 4187 if (v == (void*)2) {
@@ -3790,47 +4290,68 @@ static struct seq_operations md_seq_ops = {
3790static int md_seq_open(struct inode *inode, struct file *file) 4290static int md_seq_open(struct inode *inode, struct file *file)
3791{ 4291{
3792 int error; 4292 int error;
4293 struct mdstat_info *mi = kmalloc(sizeof(*mi), GFP_KERNEL);
4294 if (mi == NULL)
4295 return -ENOMEM;
3793 4296
3794 error = seq_open(file, &md_seq_ops); 4297 error = seq_open(file, &md_seq_ops);
4298 if (error)
4299 kfree(mi);
4300 else {
4301 struct seq_file *p = file->private_data;
4302 p->private = mi;
4303 mi->event = atomic_read(&md_event_count);
4304 }
3795 return error; 4305 return error;
3796} 4306}
3797 4307
4308static int md_seq_release(struct inode *inode, struct file *file)
4309{
4310 struct seq_file *m = file->private_data;
4311 struct mdstat_info *mi = m->private;
4312 m->private = NULL;
4313 kfree(mi);
4314 return seq_release(inode, file);
4315}
4316
4317static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
4318{
4319 struct seq_file *m = filp->private_data;
4320 struct mdstat_info *mi = m->private;
4321 int mask;
4322
4323 poll_wait(filp, &md_event_waiters, wait);
4324
4325 /* always allow read */
4326 mask = POLLIN | POLLRDNORM;
4327
4328 if (mi->event != atomic_read(&md_event_count))
4329 mask |= POLLERR | POLLPRI;
4330 return mask;
4331}
4332
3798static struct file_operations md_seq_fops = { 4333static struct file_operations md_seq_fops = {
3799 .open = md_seq_open, 4334 .open = md_seq_open,
3800 .read = seq_read, 4335 .read = seq_read,
3801 .llseek = seq_lseek, 4336 .llseek = seq_lseek,
3802 .release = seq_release, 4337 .release = md_seq_release,
4338 .poll = mdstat_poll,
3803}; 4339};
3804 4340
3805int register_md_personality(int pnum, mdk_personality_t *p) 4341int register_md_personality(struct mdk_personality *p)
3806{ 4342{
3807 if (pnum >= MAX_PERSONALITY) {
3808 printk(KERN_ERR
3809 "md: tried to install personality %s as nr %d, but max is %lu\n",
3810 p->name, pnum, MAX_PERSONALITY-1);
3811 return -EINVAL;
3812 }
3813
3814 spin_lock(&pers_lock); 4343 spin_lock(&pers_lock);
3815 if (pers[pnum]) { 4344 list_add_tail(&p->list, &pers_list);
3816 spin_unlock(&pers_lock); 4345 printk(KERN_INFO "md: %s personality registered for level %d\n", p->name, p->level);
3817 return -EBUSY;
3818 }
3819
3820 pers[pnum] = p;
3821 printk(KERN_INFO "md: %s personality registered as nr %d\n", p->name, pnum);
3822 spin_unlock(&pers_lock); 4346 spin_unlock(&pers_lock);
3823 return 0; 4347 return 0;
3824} 4348}
3825 4349
3826int unregister_md_personality(int pnum) 4350int unregister_md_personality(struct mdk_personality *p)
3827{ 4351{
3828 if (pnum >= MAX_PERSONALITY) 4352 printk(KERN_INFO "md: %s personality unregistered\n", p->name);
3829 return -EINVAL;
3830
3831 printk(KERN_INFO "md: %s personality unregistered\n", pers[pnum]->name);
3832 spin_lock(&pers_lock); 4353 spin_lock(&pers_lock);
3833 pers[pnum] = NULL; 4354 list_del_init(&p->list);
3834 spin_unlock(&pers_lock); 4355 spin_unlock(&pers_lock);
3835 return 0; 4356 return 0;
3836} 4357}
@@ -4012,10 +4533,10 @@ static void md_do_sync(mddev_t *mddev)
4012 4533
4013 printk(KERN_INFO "md: syncing RAID array %s\n", mdname(mddev)); 4534 printk(KERN_INFO "md: syncing RAID array %s\n", mdname(mddev));
4014 printk(KERN_INFO "md: minimum _guaranteed_ reconstruction speed:" 4535 printk(KERN_INFO "md: minimum _guaranteed_ reconstruction speed:"
4015 " %d KB/sec/disc.\n", sysctl_speed_limit_min); 4536 " %d KB/sec/disc.\n", speed_min(mddev));
4016 printk(KERN_INFO "md: using maximum available idle IO bandwidth " 4537 printk(KERN_INFO "md: using maximum available idle IO bandwidth "
4017 "(but not more than %d KB/sec) for reconstruction.\n", 4538 "(but not more than %d KB/sec) for reconstruction.\n",
4018 sysctl_speed_limit_max); 4539 speed_max(mddev));
4019 4540
4020 is_mddev_idle(mddev); /* this also initializes IO event counters */ 4541 is_mddev_idle(mddev); /* this also initializes IO event counters */
4021 /* we don't use the checkpoint if there's a bitmap */ 4542 /* we don't use the checkpoint if there's a bitmap */
@@ -4056,7 +4577,7 @@ static void md_do_sync(mddev_t *mddev)
4056 4577
4057 skipped = 0; 4578 skipped = 0;
4058 sectors = mddev->pers->sync_request(mddev, j, &skipped, 4579 sectors = mddev->pers->sync_request(mddev, j, &skipped,
4059 currspeed < sysctl_speed_limit_min); 4580 currspeed < speed_min(mddev));
4060 if (sectors == 0) { 4581 if (sectors == 0) {
4061 set_bit(MD_RECOVERY_ERR, &mddev->recovery); 4582 set_bit(MD_RECOVERY_ERR, &mddev->recovery);
4062 goto out; 4583 goto out;
@@ -4069,7 +4590,11 @@ static void md_do_sync(mddev_t *mddev)
4069 4590
4070 j += sectors; 4591 j += sectors;
4071 if (j>1) mddev->curr_resync = j; 4592 if (j>1) mddev->curr_resync = j;
4072 4593 if (last_check == 0)
4594 /* this is the earliers that rebuilt will be
4595 * visible in /proc/mdstat
4596 */
4597 md_new_event(mddev);
4073 4598
4074 if (last_check + window > io_sectors || j == max_sectors) 4599 if (last_check + window > io_sectors || j == max_sectors)
4075 continue; 4600 continue;
@@ -4117,8 +4642,8 @@ static void md_do_sync(mddev_t *mddev)
4117 currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2 4642 currspeed = ((unsigned long)(io_sectors-mddev->resync_mark_cnt))/2
4118 /((jiffies-mddev->resync_mark)/HZ +1) +1; 4643 /((jiffies-mddev->resync_mark)/HZ +1) +1;
4119 4644
4120 if (currspeed > sysctl_speed_limit_min) { 4645 if (currspeed > speed_min(mddev)) {
4121 if ((currspeed > sysctl_speed_limit_max) || 4646 if ((currspeed > speed_max(mddev)) ||
4122 !is_mddev_idle(mddev)) { 4647 !is_mddev_idle(mddev)) {
4123 msleep(500); 4648 msleep(500);
4124 goto repeat; 4649 goto repeat;
@@ -4255,6 +4780,7 @@ void md_check_recovery(mddev_t *mddev)
4255 mddev->recovery = 0; 4780 mddev->recovery = 0;
4256 /* flag recovery needed just to double check */ 4781 /* flag recovery needed just to double check */
4257 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4782 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
4783 md_new_event(mddev);
4258 goto unlock; 4784 goto unlock;
4259 } 4785 }
4260 /* Clear some bits that don't mean anything, but 4786 /* Clear some bits that don't mean anything, but
@@ -4292,6 +4818,7 @@ void md_check_recovery(mddev_t *mddev)
4292 sprintf(nm, "rd%d", rdev->raid_disk); 4818 sprintf(nm, "rd%d", rdev->raid_disk);
4293 sysfs_create_link(&mddev->kobj, &rdev->kobj, nm); 4819 sysfs_create_link(&mddev->kobj, &rdev->kobj, nm);
4294 spares++; 4820 spares++;
4821 md_new_event(mddev);
4295 } else 4822 } else
4296 break; 4823 break;
4297 } 4824 }
@@ -4324,9 +4851,9 @@ void md_check_recovery(mddev_t *mddev)
4324 mdname(mddev)); 4851 mdname(mddev));
4325 /* leave the spares where they are, it shouldn't hurt */ 4852 /* leave the spares where they are, it shouldn't hurt */
4326 mddev->recovery = 0; 4853 mddev->recovery = 0;
4327 } else { 4854 } else
4328 md_wakeup_thread(mddev->sync_thread); 4855 md_wakeup_thread(mddev->sync_thread);
4329 } 4856 md_new_event(mddev);
4330 } 4857 }
4331 unlock: 4858 unlock:
4332 mddev_unlock(mddev); 4859 mddev_unlock(mddev);
@@ -4503,12 +5030,14 @@ static int set_ro(const char *val, struct kernel_param *kp)
4503 int num = simple_strtoul(val, &e, 10); 5030 int num = simple_strtoul(val, &e, 10);
4504 if (*val && (*e == '\0' || *e == '\n')) { 5031 if (*val && (*e == '\0' || *e == '\n')) {
4505 start_readonly = num; 5032 start_readonly = num;
4506 return 0;; 5033 return 0;
4507 } 5034 }
4508 return -EINVAL; 5035 return -EINVAL;
4509} 5036}
4510 5037
4511module_param_call(start_ro, set_ro, get_ro, NULL, 0600); 5038module_param_call(start_ro, set_ro, get_ro, NULL, 0600);
5039module_param(start_dirty_degraded, int, 0644);
5040
4512 5041
4513EXPORT_SYMBOL(register_md_personality); 5042EXPORT_SYMBOL(register_md_personality);
4514EXPORT_SYMBOL(unregister_md_personality); 5043EXPORT_SYMBOL(unregister_md_personality);
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 145cdc5ad008..e6aa309a66d7 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -35,15 +35,10 @@
35#define NR_RESERVED_BUFS 32 35#define NR_RESERVED_BUFS 32
36 36
37 37
38static mdk_personality_t multipath_personality;
39
40
41static void *mp_pool_alloc(gfp_t gfp_flags, void *data) 38static void *mp_pool_alloc(gfp_t gfp_flags, void *data)
42{ 39{
43 struct multipath_bh *mpb; 40 struct multipath_bh *mpb;
44 mpb = kmalloc(sizeof(*mpb), gfp_flags); 41 mpb = kzalloc(sizeof(*mpb), gfp_flags);
45 if (mpb)
46 memset(mpb, 0, sizeof(*mpb));
47 return mpb; 42 return mpb;
48} 43}
49 44
@@ -444,7 +439,7 @@ static int multipath_run (mddev_t *mddev)
444 * should be freed in multipath_stop()] 439 * should be freed in multipath_stop()]
445 */ 440 */
446 441
447 conf = kmalloc(sizeof(multipath_conf_t), GFP_KERNEL); 442 conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL);
448 mddev->private = conf; 443 mddev->private = conf;
449 if (!conf) { 444 if (!conf) {
450 printk(KERN_ERR 445 printk(KERN_ERR
@@ -452,9 +447,8 @@ static int multipath_run (mddev_t *mddev)
452 mdname(mddev)); 447 mdname(mddev));
453 goto out; 448 goto out;
454 } 449 }
455 memset(conf, 0, sizeof(*conf));
456 450
457 conf->multipaths = kmalloc(sizeof(struct multipath_info)*mddev->raid_disks, 451 conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks,
458 GFP_KERNEL); 452 GFP_KERNEL);
459 if (!conf->multipaths) { 453 if (!conf->multipaths) {
460 printk(KERN_ERR 454 printk(KERN_ERR
@@ -462,7 +456,6 @@ static int multipath_run (mddev_t *mddev)
462 mdname(mddev)); 456 mdname(mddev));
463 goto out_free_conf; 457 goto out_free_conf;
464 } 458 }
465 memset(conf->multipaths, 0, sizeof(struct multipath_info)*mddev->raid_disks);
466 459
467 conf->working_disks = 0; 460 conf->working_disks = 0;
468 ITERATE_RDEV(mddev,rdev,tmp) { 461 ITERATE_RDEV(mddev,rdev,tmp) {
@@ -557,9 +550,10 @@ static int multipath_stop (mddev_t *mddev)
557 return 0; 550 return 0;
558} 551}
559 552
560static mdk_personality_t multipath_personality= 553static struct mdk_personality multipath_personality =
561{ 554{
562 .name = "multipath", 555 .name = "multipath",
556 .level = LEVEL_MULTIPATH,
563 .owner = THIS_MODULE, 557 .owner = THIS_MODULE,
564 .make_request = multipath_make_request, 558 .make_request = multipath_make_request,
565 .run = multipath_run, 559 .run = multipath_run,
@@ -572,15 +566,17 @@ static mdk_personality_t multipath_personality=
572 566
573static int __init multipath_init (void) 567static int __init multipath_init (void)
574{ 568{
575 return register_md_personality (MULTIPATH, &multipath_personality); 569 return register_md_personality (&multipath_personality);
576} 570}
577 571
578static void __exit multipath_exit (void) 572static void __exit multipath_exit (void)
579{ 573{
580 unregister_md_personality (MULTIPATH); 574 unregister_md_personality (&multipath_personality);
581} 575}
582 576
583module_init(multipath_init); 577module_init(multipath_init);
584module_exit(multipath_exit); 578module_exit(multipath_exit);
585MODULE_LICENSE("GPL"); 579MODULE_LICENSE("GPL");
586MODULE_ALIAS("md-personality-7"); /* MULTIPATH */ 580MODULE_ALIAS("md-personality-7"); /* MULTIPATH */
581MODULE_ALIAS("md-multipath");
582MODULE_ALIAS("md-level--4");
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index fece3277c2a5..abbca150202b 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -113,21 +113,16 @@ static int create_strip_zones (mddev_t *mddev)
113 } 113 }
114 printk("raid0: FINAL %d zones\n", conf->nr_strip_zones); 114 printk("raid0: FINAL %d zones\n", conf->nr_strip_zones);
115 115
116 conf->strip_zone = kmalloc(sizeof(struct strip_zone)* 116 conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
117 conf->nr_strip_zones, GFP_KERNEL); 117 conf->nr_strip_zones, GFP_KERNEL);
118 if (!conf->strip_zone) 118 if (!conf->strip_zone)
119 return 1; 119 return 1;
120 conf->devlist = kmalloc(sizeof(mdk_rdev_t*)* 120 conf->devlist = kzalloc(sizeof(mdk_rdev_t*)*
121 conf->nr_strip_zones*mddev->raid_disks, 121 conf->nr_strip_zones*mddev->raid_disks,
122 GFP_KERNEL); 122 GFP_KERNEL);
123 if (!conf->devlist) 123 if (!conf->devlist)
124 return 1; 124 return 1;
125 125
126 memset(conf->strip_zone, 0,sizeof(struct strip_zone)*
127 conf->nr_strip_zones);
128 memset(conf->devlist, 0,
129 sizeof(mdk_rdev_t*) * conf->nr_strip_zones * mddev->raid_disks);
130
131 /* The first zone must contain all devices, so here we check that 126 /* The first zone must contain all devices, so here we check that
132 * there is a proper alignment of slots to devices and find them all 127 * there is a proper alignment of slots to devices and find them all
133 */ 128 */
@@ -280,7 +275,11 @@ static int raid0_run (mddev_t *mddev)
280 mdk_rdev_t *rdev; 275 mdk_rdev_t *rdev;
281 struct list_head *tmp; 276 struct list_head *tmp;
282 277
283 printk("%s: setting max_sectors to %d, segment boundary to %d\n", 278 if (mddev->chunk_size == 0) {
279 printk(KERN_ERR "md/raid0: non-zero chunk size required.\n");
280 return -EINVAL;
281 }
282 printk(KERN_INFO "%s: setting max_sectors to %d, segment boundary to %d\n",
284 mdname(mddev), 283 mdname(mddev),
285 mddev->chunk_size >> 9, 284 mddev->chunk_size >> 9,
286 (mddev->chunk_size>>1)-1); 285 (mddev->chunk_size>>1)-1);
@@ -361,7 +360,7 @@ static int raid0_run (mddev_t *mddev)
361 * chunksize should be used in that case. 360 * chunksize should be used in that case.
362 */ 361 */
363 { 362 {
364 int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE; 363 int stripe = mddev->raid_disks * mddev->chunk_size / PAGE_SIZE;
365 if (mddev->queue->backing_dev_info.ra_pages < 2* stripe) 364 if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)
366 mddev->queue->backing_dev_info.ra_pages = 2* stripe; 365 mddev->queue->backing_dev_info.ra_pages = 2* stripe;
367 } 366 }
@@ -512,9 +511,10 @@ static void raid0_status (struct seq_file *seq, mddev_t *mddev)
512 return; 511 return;
513} 512}
514 513
515static mdk_personality_t raid0_personality= 514static struct mdk_personality raid0_personality=
516{ 515{
517 .name = "raid0", 516 .name = "raid0",
517 .level = 0,
518 .owner = THIS_MODULE, 518 .owner = THIS_MODULE,
519 .make_request = raid0_make_request, 519 .make_request = raid0_make_request,
520 .run = raid0_run, 520 .run = raid0_run,
@@ -524,15 +524,17 @@ static mdk_personality_t raid0_personality=
524 524
525static int __init raid0_init (void) 525static int __init raid0_init (void)
526{ 526{
527 return register_md_personality (RAID0, &raid0_personality); 527 return register_md_personality (&raid0_personality);
528} 528}
529 529
530static void raid0_exit (void) 530static void raid0_exit (void)
531{ 531{
532 unregister_md_personality (RAID0); 532 unregister_md_personality (&raid0_personality);
533} 533}
534 534
535module_init(raid0_init); 535module_init(raid0_init);
536module_exit(raid0_exit); 536module_exit(raid0_exit);
537MODULE_LICENSE("GPL"); 537MODULE_LICENSE("GPL");
538MODULE_ALIAS("md-personality-2"); /* RAID0 */ 538MODULE_ALIAS("md-personality-2"); /* RAID0 */
539MODULE_ALIAS("md-raid0");
540MODULE_ALIAS("md-level-0");
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 3066c587b539..a06ff91f27e2 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -47,10 +47,11 @@
47 */ 47 */
48#define NR_RAID1_BIOS 256 48#define NR_RAID1_BIOS 256
49 49
50static mdk_personality_t raid1_personality;
51 50
52static void unplug_slaves(mddev_t *mddev); 51static void unplug_slaves(mddev_t *mddev);
53 52
53static void allow_barrier(conf_t *conf);
54static void lower_barrier(conf_t *conf);
54 55
55static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data) 56static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
56{ 57{
@@ -59,10 +60,8 @@ static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
59 int size = offsetof(r1bio_t, bios[pi->raid_disks]); 60 int size = offsetof(r1bio_t, bios[pi->raid_disks]);
60 61
61 /* allocate a r1bio with room for raid_disks entries in the bios array */ 62 /* allocate a r1bio with room for raid_disks entries in the bios array */
62 r1_bio = kmalloc(size, gfp_flags); 63 r1_bio = kzalloc(size, gfp_flags);
63 if (r1_bio) 64 if (!r1_bio)
64 memset(r1_bio, 0, size);
65 else
66 unplug_slaves(pi->mddev); 65 unplug_slaves(pi->mddev);
67 66
68 return r1_bio; 67 return r1_bio;
@@ -104,15 +103,30 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
104 } 103 }
105 /* 104 /*
106 * Allocate RESYNC_PAGES data pages and attach them to 105 * Allocate RESYNC_PAGES data pages and attach them to
107 * the first bio; 106 * the first bio.
107 * If this is a user-requested check/repair, allocate
108 * RESYNC_PAGES for each bio.
108 */ 109 */
109 bio = r1_bio->bios[0]; 110 if (test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery))
110 for (i = 0; i < RESYNC_PAGES; i++) { 111 j = pi->raid_disks;
111 page = alloc_page(gfp_flags); 112 else
112 if (unlikely(!page)) 113 j = 1;
113 goto out_free_pages; 114 while(j--) {
114 115 bio = r1_bio->bios[j];
115 bio->bi_io_vec[i].bv_page = page; 116 for (i = 0; i < RESYNC_PAGES; i++) {
117 page = alloc_page(gfp_flags);
118 if (unlikely(!page))
119 goto out_free_pages;
120
121 bio->bi_io_vec[i].bv_page = page;
122 }
123 }
124 /* If not user-requests, copy the page pointers to all bios */
125 if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) {
126 for (i=0; i<RESYNC_PAGES ; i++)
127 for (j=1; j<pi->raid_disks; j++)
128 r1_bio->bios[j]->bi_io_vec[i].bv_page =
129 r1_bio->bios[0]->bi_io_vec[i].bv_page;
116 } 130 }
117 131
118 r1_bio->master_bio = NULL; 132 r1_bio->master_bio = NULL;
@@ -120,8 +134,10 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
120 return r1_bio; 134 return r1_bio;
121 135
122out_free_pages: 136out_free_pages:
123 for ( ; i > 0 ; i--) 137 for (i=0; i < RESYNC_PAGES ; i++)
124 __free_page(bio->bi_io_vec[i-1].bv_page); 138 for (j=0 ; j < pi->raid_disks; j++)
139 safe_put_page(r1_bio->bios[j]->bi_io_vec[i].bv_page);
140 j = -1;
125out_free_bio: 141out_free_bio:
126 while ( ++j < pi->raid_disks ) 142 while ( ++j < pi->raid_disks )
127 bio_put(r1_bio->bios[j]); 143 bio_put(r1_bio->bios[j]);
@@ -132,14 +148,16 @@ out_free_bio:
132static void r1buf_pool_free(void *__r1_bio, void *data) 148static void r1buf_pool_free(void *__r1_bio, void *data)
133{ 149{
134 struct pool_info *pi = data; 150 struct pool_info *pi = data;
135 int i; 151 int i,j;
136 r1bio_t *r1bio = __r1_bio; 152 r1bio_t *r1bio = __r1_bio;
137 struct bio *bio = r1bio->bios[0];
138 153
139 for (i = 0; i < RESYNC_PAGES; i++) { 154 for (i = 0; i < RESYNC_PAGES; i++)
140 __free_page(bio->bi_io_vec[i].bv_page); 155 for (j = pi->raid_disks; j-- ;) {
141 bio->bi_io_vec[i].bv_page = NULL; 156 if (j == 0 ||
142 } 157 r1bio->bios[j]->bi_io_vec[i].bv_page !=
158 r1bio->bios[0]->bi_io_vec[i].bv_page)
159 safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page);
160 }
143 for (i=0 ; i < pi->raid_disks; i++) 161 for (i=0 ; i < pi->raid_disks; i++)
144 bio_put(r1bio->bios[i]); 162 bio_put(r1bio->bios[i]);
145 163
@@ -152,7 +170,7 @@ static void put_all_bios(conf_t *conf, r1bio_t *r1_bio)
152 170
153 for (i = 0; i < conf->raid_disks; i++) { 171 for (i = 0; i < conf->raid_disks; i++) {
154 struct bio **bio = r1_bio->bios + i; 172 struct bio **bio = r1_bio->bios + i;
155 if (*bio) 173 if (*bio && *bio != IO_BLOCKED)
156 bio_put(*bio); 174 bio_put(*bio);
157 *bio = NULL; 175 *bio = NULL;
158 } 176 }
@@ -160,20 +178,13 @@ static void put_all_bios(conf_t *conf, r1bio_t *r1_bio)
160 178
161static inline void free_r1bio(r1bio_t *r1_bio) 179static inline void free_r1bio(r1bio_t *r1_bio)
162{ 180{
163 unsigned long flags;
164
165 conf_t *conf = mddev_to_conf(r1_bio->mddev); 181 conf_t *conf = mddev_to_conf(r1_bio->mddev);
166 182
167 /* 183 /*
168 * Wake up any possible resync thread that waits for the device 184 * Wake up any possible resync thread that waits for the device
169 * to go idle. 185 * to go idle.
170 */ 186 */
171 spin_lock_irqsave(&conf->resync_lock, flags); 187 allow_barrier(conf);
172 if (!--conf->nr_pending) {
173 wake_up(&conf->wait_idle);
174 wake_up(&conf->wait_resume);
175 }
176 spin_unlock_irqrestore(&conf->resync_lock, flags);
177 188
178 put_all_bios(conf, r1_bio); 189 put_all_bios(conf, r1_bio);
179 mempool_free(r1_bio, conf->r1bio_pool); 190 mempool_free(r1_bio, conf->r1bio_pool);
@@ -182,22 +193,17 @@ static inline void free_r1bio(r1bio_t *r1_bio)
182static inline void put_buf(r1bio_t *r1_bio) 193static inline void put_buf(r1bio_t *r1_bio)
183{ 194{
184 conf_t *conf = mddev_to_conf(r1_bio->mddev); 195 conf_t *conf = mddev_to_conf(r1_bio->mddev);
185 unsigned long flags; 196 int i;
186 197
187 mempool_free(r1_bio, conf->r1buf_pool); 198 for (i=0; i<conf->raid_disks; i++) {
199 struct bio *bio = r1_bio->bios[i];
200 if (bio->bi_end_io)
201 rdev_dec_pending(conf->mirrors[i].rdev, r1_bio->mddev);
202 }
188 203
189 spin_lock_irqsave(&conf->resync_lock, flags); 204 mempool_free(r1_bio, conf->r1buf_pool);
190 if (!conf->barrier)
191 BUG();
192 --conf->barrier;
193 wake_up(&conf->wait_resume);
194 wake_up(&conf->wait_idle);
195 205
196 if (!--conf->nr_pending) { 206 lower_barrier(conf);
197 wake_up(&conf->wait_idle);
198 wake_up(&conf->wait_resume);
199 }
200 spin_unlock_irqrestore(&conf->resync_lock, flags);
201} 207}
202 208
203static void reschedule_retry(r1bio_t *r1_bio) 209static void reschedule_retry(r1bio_t *r1_bio)
@@ -208,8 +214,10 @@ static void reschedule_retry(r1bio_t *r1_bio)
208 214
209 spin_lock_irqsave(&conf->device_lock, flags); 215 spin_lock_irqsave(&conf->device_lock, flags);
210 list_add(&r1_bio->retry_list, &conf->retry_list); 216 list_add(&r1_bio->retry_list, &conf->retry_list);
217 conf->nr_queued ++;
211 spin_unlock_irqrestore(&conf->device_lock, flags); 218 spin_unlock_irqrestore(&conf->device_lock, flags);
212 219
220 wake_up(&conf->wait_barrier);
213 md_wakeup_thread(mddev->thread); 221 md_wakeup_thread(mddev->thread);
214} 222}
215 223
@@ -261,9 +269,9 @@ static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int
261 /* 269 /*
262 * this branch is our 'one mirror IO has finished' event handler: 270 * this branch is our 'one mirror IO has finished' event handler:
263 */ 271 */
264 if (!uptodate) 272 update_head_pos(mirror, r1_bio);
265 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev); 273
266 else 274 if (uptodate || conf->working_disks <= 1) {
267 /* 275 /*
268 * Set R1BIO_Uptodate in our master bio, so that 276 * Set R1BIO_Uptodate in our master bio, so that
269 * we will return a good error code for to the higher 277 * we will return a good error code for to the higher
@@ -273,16 +281,11 @@ static int raid1_end_read_request(struct bio *bio, unsigned int bytes_done, int
273 * user-side. So if something waits for IO, then it will 281 * user-side. So if something waits for IO, then it will
274 * wait for the 'master' bio. 282 * wait for the 'master' bio.
275 */ 283 */
276 set_bit(R1BIO_Uptodate, &r1_bio->state); 284 if (uptodate)
277 285 set_bit(R1BIO_Uptodate, &r1_bio->state);
278 update_head_pos(mirror, r1_bio);
279 286
280 /*
281 * we have only one bio on the read side
282 */
283 if (uptodate)
284 raid_end_bio_io(r1_bio); 287 raid_end_bio_io(r1_bio);
285 else { 288 } else {
286 /* 289 /*
287 * oops, read error: 290 * oops, read error:
288 */ 291 */
@@ -320,7 +323,6 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
320 * this branch is our 'one mirror IO has finished' event handler: 323 * this branch is our 'one mirror IO has finished' event handler:
321 */ 324 */
322 r1_bio->bios[mirror] = NULL; 325 r1_bio->bios[mirror] = NULL;
323 bio_put(bio);
324 if (!uptodate) { 326 if (!uptodate) {
325 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev); 327 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
326 /* an I/O failed, we can't clear the bitmap */ 328 /* an I/O failed, we can't clear the bitmap */
@@ -377,10 +379,9 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
377 } 379 }
378 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { 380 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
379 /* free extra copy of the data pages */ 381 /* free extra copy of the data pages */
380/* FIXME bio has been freed!!! */
381 int i = bio->bi_vcnt; 382 int i = bio->bi_vcnt;
382 while (i--) 383 while (i--)
383 __free_page(bio->bi_io_vec[i].bv_page); 384 safe_put_page(bio->bi_io_vec[i].bv_page);
384 } 385 }
385 /* clear the bitmap if all writes complete successfully */ 386 /* clear the bitmap if all writes complete successfully */
386 bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector, 387 bitmap_endwrite(r1_bio->mddev->bitmap, r1_bio->sector,
@@ -391,6 +392,9 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
391 raid_end_bio_io(r1_bio); 392 raid_end_bio_io(r1_bio);
392 } 393 }
393 394
395 if (r1_bio->bios[mirror]==NULL)
396 bio_put(bio);
397
394 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); 398 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
395 return 0; 399 return 0;
396} 400}
@@ -432,11 +436,13 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
432 new_disk = 0; 436 new_disk = 0;
433 437
434 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); 438 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);
439 r1_bio->bios[new_disk] == IO_BLOCKED ||
435 !rdev || !test_bit(In_sync, &rdev->flags) 440 !rdev || !test_bit(In_sync, &rdev->flags)
436 || test_bit(WriteMostly, &rdev->flags); 441 || test_bit(WriteMostly, &rdev->flags);
437 rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) { 442 rdev = rcu_dereference(conf->mirrors[++new_disk].rdev)) {
438 443
439 if (rdev && test_bit(In_sync, &rdev->flags)) 444 if (rdev && test_bit(In_sync, &rdev->flags) &&
445 r1_bio->bios[new_disk] != IO_BLOCKED)
440 wonly_disk = new_disk; 446 wonly_disk = new_disk;
441 447
442 if (new_disk == conf->raid_disks - 1) { 448 if (new_disk == conf->raid_disks - 1) {
@@ -450,11 +456,13 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
450 456
451 /* make sure the disk is operational */ 457 /* make sure the disk is operational */
452 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev); 458 for (rdev = rcu_dereference(conf->mirrors[new_disk].rdev);
459 r1_bio->bios[new_disk] == IO_BLOCKED ||
453 !rdev || !test_bit(In_sync, &rdev->flags) || 460 !rdev || !test_bit(In_sync, &rdev->flags) ||
454 test_bit(WriteMostly, &rdev->flags); 461 test_bit(WriteMostly, &rdev->flags);
455 rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) { 462 rdev = rcu_dereference(conf->mirrors[new_disk].rdev)) {
456 463
457 if (rdev && test_bit(In_sync, &rdev->flags)) 464 if (rdev && test_bit(In_sync, &rdev->flags) &&
465 r1_bio->bios[new_disk] != IO_BLOCKED)
458 wonly_disk = new_disk; 466 wonly_disk = new_disk;
459 467
460 if (new_disk <= 0) 468 if (new_disk <= 0)
@@ -491,7 +499,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
491 499
492 rdev = rcu_dereference(conf->mirrors[disk].rdev); 500 rdev = rcu_dereference(conf->mirrors[disk].rdev);
493 501
494 if (!rdev || 502 if (!rdev || r1_bio->bios[disk] == IO_BLOCKED ||
495 !test_bit(In_sync, &rdev->flags) || 503 !test_bit(In_sync, &rdev->flags) ||
496 test_bit(WriteMostly, &rdev->flags)) 504 test_bit(WriteMostly, &rdev->flags))
497 continue; 505 continue;
@@ -519,7 +527,7 @@ static int read_balance(conf_t *conf, r1bio_t *r1_bio)
519 /* cannot risk returning a device that failed 527 /* cannot risk returning a device that failed
520 * before we inc'ed nr_pending 528 * before we inc'ed nr_pending
521 */ 529 */
522 atomic_dec(&rdev->nr_pending); 530 rdev_dec_pending(rdev, conf->mddev);
523 goto retry; 531 goto retry;
524 } 532 }
525 conf->next_seq_sect = this_sector + sectors; 533 conf->next_seq_sect = this_sector + sectors;
@@ -592,42 +600,119 @@ static int raid1_issue_flush(request_queue_t *q, struct gendisk *disk,
592 return ret; 600 return ret;
593} 601}
594 602
595/* 603/* Barriers....
596 * Throttle resync depth, so that we can both get proper overlapping of 604 * Sometimes we need to suspend IO while we do something else,
597 * requests, but are still able to handle normal requests quickly. 605 * either some resync/recovery, or reconfigure the array.
606 * To do this we raise a 'barrier'.
607 * The 'barrier' is a counter that can be raised multiple times
608 * to count how many activities are happening which preclude
609 * normal IO.
610 * We can only raise the barrier if there is no pending IO.
611 * i.e. if nr_pending == 0.
612 * We choose only to raise the barrier if no-one is waiting for the
613 * barrier to go down. This means that as soon as an IO request
614 * is ready, no other operations which require a barrier will start
615 * until the IO request has had a chance.
616 *
617 * So: regular IO calls 'wait_barrier'. When that returns there
618 * is no backgroup IO happening, It must arrange to call
619 * allow_barrier when it has finished its IO.
620 * backgroup IO calls must call raise_barrier. Once that returns
621 * there is no normal IO happeing. It must arrange to call
622 * lower_barrier when the particular background IO completes.
598 */ 623 */
599#define RESYNC_DEPTH 32 624#define RESYNC_DEPTH 32
600 625
601static void device_barrier(conf_t *conf, sector_t sect) 626static void raise_barrier(conf_t *conf)
602{ 627{
603 spin_lock_irq(&conf->resync_lock); 628 spin_lock_irq(&conf->resync_lock);
604 wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume), 629
605 conf->resync_lock, raid1_unplug(conf->mddev->queue)); 630 /* Wait until no block IO is waiting */
606 631 wait_event_lock_irq(conf->wait_barrier, !conf->nr_waiting,
607 if (!conf->barrier++) { 632 conf->resync_lock,
608 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, 633 raid1_unplug(conf->mddev->queue));
609 conf->resync_lock, raid1_unplug(conf->mddev->queue)); 634
610 if (conf->nr_pending) 635 /* block any new IO from starting */
611 BUG(); 636 conf->barrier++;
637
638 /* No wait for all pending IO to complete */
639 wait_event_lock_irq(conf->wait_barrier,
640 !conf->nr_pending && conf->barrier < RESYNC_DEPTH,
641 conf->resync_lock,
642 raid1_unplug(conf->mddev->queue));
643
644 spin_unlock_irq(&conf->resync_lock);
645}
646
647static void lower_barrier(conf_t *conf)
648{
649 unsigned long flags;
650 spin_lock_irqsave(&conf->resync_lock, flags);
651 conf->barrier--;
652 spin_unlock_irqrestore(&conf->resync_lock, flags);
653 wake_up(&conf->wait_barrier);
654}
655
656static void wait_barrier(conf_t *conf)
657{
658 spin_lock_irq(&conf->resync_lock);
659 if (conf->barrier) {
660 conf->nr_waiting++;
661 wait_event_lock_irq(conf->wait_barrier, !conf->barrier,
662 conf->resync_lock,
663 raid1_unplug(conf->mddev->queue));
664 conf->nr_waiting--;
612 } 665 }
613 wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH, 666 conf->nr_pending++;
614 conf->resync_lock, raid1_unplug(conf->mddev->queue));
615 conf->next_resync = sect;
616 spin_unlock_irq(&conf->resync_lock); 667 spin_unlock_irq(&conf->resync_lock);
617} 668}
618 669
670static void allow_barrier(conf_t *conf)
671{
672 unsigned long flags;
673 spin_lock_irqsave(&conf->resync_lock, flags);
674 conf->nr_pending--;
675 spin_unlock_irqrestore(&conf->resync_lock, flags);
676 wake_up(&conf->wait_barrier);
677}
678
679static void freeze_array(conf_t *conf)
680{
681 /* stop syncio and normal IO and wait for everything to
682 * go quite.
683 * We increment barrier and nr_waiting, and then
684 * wait until barrier+nr_pending match nr_queued+2
685 */
686 spin_lock_irq(&conf->resync_lock);
687 conf->barrier++;
688 conf->nr_waiting++;
689 wait_event_lock_irq(conf->wait_barrier,
690 conf->barrier+conf->nr_pending == conf->nr_queued+2,
691 conf->resync_lock,
692 raid1_unplug(conf->mddev->queue));
693 spin_unlock_irq(&conf->resync_lock);
694}
695static void unfreeze_array(conf_t *conf)
696{
697 /* reverse the effect of the freeze */
698 spin_lock_irq(&conf->resync_lock);
699 conf->barrier--;
700 conf->nr_waiting--;
701 wake_up(&conf->wait_barrier);
702 spin_unlock_irq(&conf->resync_lock);
703}
704
705
619/* duplicate the data pages for behind I/O */ 706/* duplicate the data pages for behind I/O */
620static struct page **alloc_behind_pages(struct bio *bio) 707static struct page **alloc_behind_pages(struct bio *bio)
621{ 708{
622 int i; 709 int i;
623 struct bio_vec *bvec; 710 struct bio_vec *bvec;
624 struct page **pages = kmalloc(bio->bi_vcnt * sizeof(struct page *), 711 struct page **pages = kzalloc(bio->bi_vcnt * sizeof(struct page *),
625 GFP_NOIO); 712 GFP_NOIO);
626 if (unlikely(!pages)) 713 if (unlikely(!pages))
627 goto do_sync_io; 714 goto do_sync_io;
628 715
629 memset(pages, 0, bio->bi_vcnt * sizeof(struct page *));
630
631 bio_for_each_segment(bvec, bio, i) { 716 bio_for_each_segment(bvec, bio, i) {
632 pages[i] = alloc_page(GFP_NOIO); 717 pages[i] = alloc_page(GFP_NOIO);
633 if (unlikely(!pages[i])) 718 if (unlikely(!pages[i]))
@@ -643,7 +728,7 @@ static struct page **alloc_behind_pages(struct bio *bio)
643do_sync_io: 728do_sync_io:
644 if (pages) 729 if (pages)
645 for (i = 0; i < bio->bi_vcnt && pages[i]; i++) 730 for (i = 0; i < bio->bi_vcnt && pages[i]; i++)
646 __free_page(pages[i]); 731 put_page(pages[i]);
647 kfree(pages); 732 kfree(pages);
648 PRINTK("%dB behind alloc failed, doing sync I/O\n", bio->bi_size); 733 PRINTK("%dB behind alloc failed, doing sync I/O\n", bio->bi_size);
649 return NULL; 734 return NULL;
@@ -677,10 +762,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
677 */ 762 */
678 md_write_start(mddev, bio); /* wait on superblock update early */ 763 md_write_start(mddev, bio); /* wait on superblock update early */
679 764
680 spin_lock_irq(&conf->resync_lock); 765 wait_barrier(conf);
681 wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, );
682 conf->nr_pending++;
683 spin_unlock_irq(&conf->resync_lock);
684 766
685 disk_stat_inc(mddev->gendisk, ios[rw]); 767 disk_stat_inc(mddev->gendisk, ios[rw]);
686 disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); 768 disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio));
@@ -748,7 +830,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
748 !test_bit(Faulty, &rdev->flags)) { 830 !test_bit(Faulty, &rdev->flags)) {
749 atomic_inc(&rdev->nr_pending); 831 atomic_inc(&rdev->nr_pending);
750 if (test_bit(Faulty, &rdev->flags)) { 832 if (test_bit(Faulty, &rdev->flags)) {
751 atomic_dec(&rdev->nr_pending); 833 rdev_dec_pending(rdev, mddev);
752 r1_bio->bios[i] = NULL; 834 r1_bio->bios[i] = NULL;
753 } else 835 } else
754 r1_bio->bios[i] = bio; 836 r1_bio->bios[i] = bio;
@@ -908,13 +990,8 @@ static void print_conf(conf_t *conf)
908 990
909static void close_sync(conf_t *conf) 991static void close_sync(conf_t *conf)
910{ 992{
911 spin_lock_irq(&conf->resync_lock); 993 wait_barrier(conf);
912 wait_event_lock_irq(conf->wait_resume, !conf->barrier, 994 allow_barrier(conf);
913 conf->resync_lock, raid1_unplug(conf->mddev->queue));
914 spin_unlock_irq(&conf->resync_lock);
915
916 if (conf->barrier) BUG();
917 if (waitqueue_active(&conf->wait_idle)) BUG();
918 995
919 mempool_destroy(conf->r1buf_pool); 996 mempool_destroy(conf->r1buf_pool);
920 conf->r1buf_pool = NULL; 997 conf->r1buf_pool = NULL;
@@ -1014,28 +1091,27 @@ abort:
1014 1091
1015static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) 1092static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
1016{ 1093{
1017 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
1018 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private); 1094 r1bio_t * r1_bio = (r1bio_t *)(bio->bi_private);
1019 conf_t *conf = mddev_to_conf(r1_bio->mddev); 1095 int i;
1020 1096
1021 if (bio->bi_size) 1097 if (bio->bi_size)
1022 return 1; 1098 return 1;
1023 1099
1024 if (r1_bio->bios[r1_bio->read_disk] != bio) 1100 for (i=r1_bio->mddev->raid_disks; i--; )
1025 BUG(); 1101 if (r1_bio->bios[i] == bio)
1026 update_head_pos(r1_bio->read_disk, r1_bio); 1102 break;
1103 BUG_ON(i < 0);
1104 update_head_pos(i, r1_bio);
1027 /* 1105 /*
1028 * we have read a block, now it needs to be re-written, 1106 * we have read a block, now it needs to be re-written,
1029 * or re-read if the read failed. 1107 * or re-read if the read failed.
1030 * We don't do much here, just schedule handling by raid1d 1108 * We don't do much here, just schedule handling by raid1d
1031 */ 1109 */
1032 if (!uptodate) { 1110 if (test_bit(BIO_UPTODATE, &bio->bi_flags))
1033 md_error(r1_bio->mddev,
1034 conf->mirrors[r1_bio->read_disk].rdev);
1035 } else
1036 set_bit(R1BIO_Uptodate, &r1_bio->state); 1111 set_bit(R1BIO_Uptodate, &r1_bio->state);
1037 rdev_dec_pending(conf->mirrors[r1_bio->read_disk].rdev, conf->mddev); 1112
1038 reschedule_retry(r1_bio); 1113 if (atomic_dec_and_test(&r1_bio->remaining))
1114 reschedule_retry(r1_bio);
1039 return 0; 1115 return 0;
1040} 1116}
1041 1117
@@ -1065,7 +1141,6 @@ static int end_sync_write(struct bio *bio, unsigned int bytes_done, int error)
1065 md_done_sync(mddev, r1_bio->sectors, uptodate); 1141 md_done_sync(mddev, r1_bio->sectors, uptodate);
1066 put_buf(r1_bio); 1142 put_buf(r1_bio);
1067 } 1143 }
1068 rdev_dec_pending(conf->mirrors[mirror].rdev, mddev);
1069 return 0; 1144 return 0;
1070} 1145}
1071 1146
@@ -1078,34 +1153,173 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio)
1078 1153
1079 bio = r1_bio->bios[r1_bio->read_disk]; 1154 bio = r1_bio->bios[r1_bio->read_disk];
1080 1155
1081/* 1156
1082 if (r1_bio->sector == 0) printk("First sync write startss\n"); 1157 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
1083*/ 1158 /* We have read all readable devices. If we haven't
1084 /* 1159 * got the block, then there is no hope left.
1085 * schedule writes 1160 * If we have, then we want to do a comparison
1086 */ 1161 * and skip the write if everything is the same.
1162 * If any blocks failed to read, then we need to
1163 * attempt an over-write
1164 */
1165 int primary;
1166 if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) {
1167 for (i=0; i<mddev->raid_disks; i++)
1168 if (r1_bio->bios[i]->bi_end_io == end_sync_read)
1169 md_error(mddev, conf->mirrors[i].rdev);
1170
1171 md_done_sync(mddev, r1_bio->sectors, 1);
1172 put_buf(r1_bio);
1173 return;
1174 }
1175 for (primary=0; primary<mddev->raid_disks; primary++)
1176 if (r1_bio->bios[primary]->bi_end_io == end_sync_read &&
1177 test_bit(BIO_UPTODATE, &r1_bio->bios[primary]->bi_flags)) {
1178 r1_bio->bios[primary]->bi_end_io = NULL;
1179 rdev_dec_pending(conf->mirrors[primary].rdev, mddev);
1180 break;
1181 }
1182 r1_bio->read_disk = primary;
1183 for (i=0; i<mddev->raid_disks; i++)
1184 if (r1_bio->bios[i]->bi_end_io == end_sync_read &&
1185 test_bit(BIO_UPTODATE, &r1_bio->bios[i]->bi_flags)) {
1186 int j;
1187 int vcnt = r1_bio->sectors >> (PAGE_SHIFT- 9);
1188 struct bio *pbio = r1_bio->bios[primary];
1189 struct bio *sbio = r1_bio->bios[i];
1190 for (j = vcnt; j-- ; )
1191 if (memcmp(page_address(pbio->bi_io_vec[j].bv_page),
1192 page_address(sbio->bi_io_vec[j].bv_page),
1193 PAGE_SIZE))
1194 break;
1195 if (j >= 0)
1196 mddev->resync_mismatches += r1_bio->sectors;
1197 if (j < 0 || test_bit(MD_RECOVERY_CHECK, &mddev->recovery)) {
1198 sbio->bi_end_io = NULL;
1199 rdev_dec_pending(conf->mirrors[i].rdev, mddev);
1200 } else {
1201 /* fixup the bio for reuse */
1202 sbio->bi_vcnt = vcnt;
1203 sbio->bi_size = r1_bio->sectors << 9;
1204 sbio->bi_idx = 0;
1205 sbio->bi_phys_segments = 0;
1206 sbio->bi_hw_segments = 0;
1207 sbio->bi_hw_front_size = 0;
1208 sbio->bi_hw_back_size = 0;
1209 sbio->bi_flags &= ~(BIO_POOL_MASK - 1);
1210 sbio->bi_flags |= 1 << BIO_UPTODATE;
1211 sbio->bi_next = NULL;
1212 sbio->bi_sector = r1_bio->sector +
1213 conf->mirrors[i].rdev->data_offset;
1214 sbio->bi_bdev = conf->mirrors[i].rdev->bdev;
1215 }
1216 }
1217 }
1087 if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) { 1218 if (!test_bit(R1BIO_Uptodate, &r1_bio->state)) {
1088 /* 1219 /* ouch - failed to read all of that.
1089 * There is no point trying a read-for-reconstruct as 1220 * Try some synchronous reads of other devices to get
1090 * reconstruct is about to be aborted 1221 * good data, much like with normal read errors. Only
1222 * read into the pages we already have so they we don't
1223 * need to re-issue the read request.
1224 * We don't need to freeze the array, because being in an
1225 * active sync request, there is no normal IO, and
1226 * no overlapping syncs.
1091 */ 1227 */
1092 char b[BDEVNAME_SIZE]; 1228 sector_t sect = r1_bio->sector;
1093 printk(KERN_ALERT "raid1: %s: unrecoverable I/O read error" 1229 int sectors = r1_bio->sectors;
1094 " for block %llu\n", 1230 int idx = 0;
1095 bdevname(bio->bi_bdev,b), 1231
1096 (unsigned long long)r1_bio->sector); 1232 while(sectors) {
1097 md_done_sync(mddev, r1_bio->sectors, 0); 1233 int s = sectors;
1098 put_buf(r1_bio); 1234 int d = r1_bio->read_disk;
1099 return; 1235 int success = 0;
1236 mdk_rdev_t *rdev;
1237
1238 if (s > (PAGE_SIZE>>9))
1239 s = PAGE_SIZE >> 9;
1240 do {
1241 if (r1_bio->bios[d]->bi_end_io == end_sync_read) {
1242 rdev = conf->mirrors[d].rdev;
1243 if (sync_page_io(rdev->bdev,
1244 sect + rdev->data_offset,
1245 s<<9,
1246 bio->bi_io_vec[idx].bv_page,
1247 READ)) {
1248 success = 1;
1249 break;
1250 }
1251 }
1252 d++;
1253 if (d == conf->raid_disks)
1254 d = 0;
1255 } while (!success && d != r1_bio->read_disk);
1256
1257 if (success) {
1258 int start = d;
1259 /* write it back and re-read */
1260 set_bit(R1BIO_Uptodate, &r1_bio->state);
1261 while (d != r1_bio->read_disk) {
1262 if (d == 0)
1263 d = conf->raid_disks;
1264 d--;
1265 if (r1_bio->bios[d]->bi_end_io != end_sync_read)
1266 continue;
1267 rdev = conf->mirrors[d].rdev;
1268 atomic_add(s, &rdev->corrected_errors);
1269 if (sync_page_io(rdev->bdev,
1270 sect + rdev->data_offset,
1271 s<<9,
1272 bio->bi_io_vec[idx].bv_page,
1273 WRITE) == 0)
1274 md_error(mddev, rdev);
1275 }
1276 d = start;
1277 while (d != r1_bio->read_disk) {
1278 if (d == 0)
1279 d = conf->raid_disks;
1280 d--;
1281 if (r1_bio->bios[d]->bi_end_io != end_sync_read)
1282 continue;
1283 rdev = conf->mirrors[d].rdev;
1284 if (sync_page_io(rdev->bdev,
1285 sect + rdev->data_offset,
1286 s<<9,
1287 bio->bi_io_vec[idx].bv_page,
1288 READ) == 0)
1289 md_error(mddev, rdev);
1290 }
1291 } else {
1292 char b[BDEVNAME_SIZE];
1293 /* Cannot read from anywhere, array is toast */
1294 md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev);
1295 printk(KERN_ALERT "raid1: %s: unrecoverable I/O read error"
1296 " for block %llu\n",
1297 bdevname(bio->bi_bdev,b),
1298 (unsigned long long)r1_bio->sector);
1299 md_done_sync(mddev, r1_bio->sectors, 0);
1300 put_buf(r1_bio);
1301 return;
1302 }
1303 sectors -= s;
1304 sect += s;
1305 idx ++;
1306 }
1100 } 1307 }
1101 1308
1309 /*
1310 * schedule writes
1311 */
1102 atomic_set(&r1_bio->remaining, 1); 1312 atomic_set(&r1_bio->remaining, 1);
1103 for (i = 0; i < disks ; i++) { 1313 for (i = 0; i < disks ; i++) {
1104 wbio = r1_bio->bios[i]; 1314 wbio = r1_bio->bios[i];
1105 if (wbio->bi_end_io != end_sync_write) 1315 if (wbio->bi_end_io == NULL ||
1316 (wbio->bi_end_io == end_sync_read &&
1317 (i == r1_bio->read_disk ||
1318 !test_bit(MD_RECOVERY_SYNC, &mddev->recovery))))
1106 continue; 1319 continue;
1107 1320
1108 atomic_inc(&conf->mirrors[i].rdev->nr_pending); 1321 wbio->bi_rw = WRITE;
1322 wbio->bi_end_io = end_sync_write;
1109 atomic_inc(&r1_bio->remaining); 1323 atomic_inc(&r1_bio->remaining);
1110 md_sync_acct(conf->mirrors[i].rdev->bdev, wbio->bi_size >> 9); 1324 md_sync_acct(conf->mirrors[i].rdev->bdev, wbio->bi_size >> 9);
1111 1325
@@ -1166,6 +1380,7 @@ static void raid1d(mddev_t *mddev)
1166 break; 1380 break;
1167 r1_bio = list_entry(head->prev, r1bio_t, retry_list); 1381 r1_bio = list_entry(head->prev, r1bio_t, retry_list);
1168 list_del(head->prev); 1382 list_del(head->prev);
1383 conf->nr_queued--;
1169 spin_unlock_irqrestore(&conf->device_lock, flags); 1384 spin_unlock_irqrestore(&conf->device_lock, flags);
1170 1385
1171 mddev = r1_bio->mddev; 1386 mddev = r1_bio->mddev;
@@ -1205,6 +1420,86 @@ static void raid1d(mddev_t *mddev)
1205 } 1420 }
1206 } else { 1421 } else {
1207 int disk; 1422 int disk;
1423
1424 /* we got a read error. Maybe the drive is bad. Maybe just
1425 * the block and we can fix it.
1426 * We freeze all other IO, and try reading the block from
1427 * other devices. When we find one, we re-write
1428 * and check it that fixes the read error.
1429 * This is all done synchronously while the array is
1430 * frozen
1431 */
1432 sector_t sect = r1_bio->sector;
1433 int sectors = r1_bio->sectors;
1434 freeze_array(conf);
1435 if (mddev->ro == 0) while(sectors) {
1436 int s = sectors;
1437 int d = r1_bio->read_disk;
1438 int success = 0;
1439
1440 if (s > (PAGE_SIZE>>9))
1441 s = PAGE_SIZE >> 9;
1442
1443 do {
1444 rdev = conf->mirrors[d].rdev;
1445 if (rdev &&
1446 test_bit(In_sync, &rdev->flags) &&
1447 sync_page_io(rdev->bdev,
1448 sect + rdev->data_offset,
1449 s<<9,
1450 conf->tmppage, READ))
1451 success = 1;
1452 else {
1453 d++;
1454 if (d == conf->raid_disks)
1455 d = 0;
1456 }
1457 } while (!success && d != r1_bio->read_disk);
1458
1459 if (success) {
1460 /* write it back and re-read */
1461 int start = d;
1462 while (d != r1_bio->read_disk) {
1463 if (d==0)
1464 d = conf->raid_disks;
1465 d--;
1466 rdev = conf->mirrors[d].rdev;
1467 atomic_add(s, &rdev->corrected_errors);
1468 if (rdev &&
1469 test_bit(In_sync, &rdev->flags)) {
1470 if (sync_page_io(rdev->bdev,
1471 sect + rdev->data_offset,
1472 s<<9, conf->tmppage, WRITE) == 0)
1473 /* Well, this device is dead */
1474 md_error(mddev, rdev);
1475 }
1476 }
1477 d = start;
1478 while (d != r1_bio->read_disk) {
1479 if (d==0)
1480 d = conf->raid_disks;
1481 d--;
1482 rdev = conf->mirrors[d].rdev;
1483 if (rdev &&
1484 test_bit(In_sync, &rdev->flags)) {
1485 if (sync_page_io(rdev->bdev,
1486 sect + rdev->data_offset,
1487 s<<9, conf->tmppage, READ) == 0)
1488 /* Well, this device is dead */
1489 md_error(mddev, rdev);
1490 }
1491 }
1492 } else {
1493 /* Cannot read from anywhere -- bye bye array */
1494 md_error(mddev, conf->mirrors[r1_bio->read_disk].rdev);
1495 break;
1496 }
1497 sectors -= s;
1498 sect += s;
1499 }
1500
1501 unfreeze_array(conf);
1502
1208 bio = r1_bio->bios[r1_bio->read_disk]; 1503 bio = r1_bio->bios[r1_bio->read_disk];
1209 if ((disk=read_balance(conf, r1_bio)) == -1) { 1504 if ((disk=read_balance(conf, r1_bio)) == -1) {
1210 printk(KERN_ALERT "raid1: %s: unrecoverable I/O" 1505 printk(KERN_ALERT "raid1: %s: unrecoverable I/O"
@@ -1213,7 +1508,8 @@ static void raid1d(mddev_t *mddev)
1213 (unsigned long long)r1_bio->sector); 1508 (unsigned long long)r1_bio->sector);
1214 raid_end_bio_io(r1_bio); 1509 raid_end_bio_io(r1_bio);
1215 } else { 1510 } else {
1216 r1_bio->bios[r1_bio->read_disk] = NULL; 1511 r1_bio->bios[r1_bio->read_disk] =
1512 mddev->ro ? IO_BLOCKED : NULL;
1217 r1_bio->read_disk = disk; 1513 r1_bio->read_disk = disk;
1218 bio_put(bio); 1514 bio_put(bio);
1219 bio = bio_clone(r1_bio->master_bio, GFP_NOIO); 1515 bio = bio_clone(r1_bio->master_bio, GFP_NOIO);
@@ -1268,14 +1564,13 @@ static int init_resync(conf_t *conf)
1268static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster) 1564static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, int go_faster)
1269{ 1565{
1270 conf_t *conf = mddev_to_conf(mddev); 1566 conf_t *conf = mddev_to_conf(mddev);
1271 mirror_info_t *mirror;
1272 r1bio_t *r1_bio; 1567 r1bio_t *r1_bio;
1273 struct bio *bio; 1568 struct bio *bio;
1274 sector_t max_sector, nr_sectors; 1569 sector_t max_sector, nr_sectors;
1275 int disk; 1570 int disk = -1;
1276 int i; 1571 int i;
1277 int wonly; 1572 int wonly = -1;
1278 int write_targets = 0; 1573 int write_targets = 0, read_targets = 0;
1279 int sync_blocks; 1574 int sync_blocks;
1280 int still_degraded = 0; 1575 int still_degraded = 0;
1281 1576
@@ -1316,55 +1611,35 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1316 return sync_blocks; 1611 return sync_blocks;
1317 } 1612 }
1318 /* 1613 /*
1319 * If there is non-resync activity waiting for us then 1614 * If there is non-resync activity waiting for a turn,
1320 * put in a delay to throttle resync. 1615 * and resync is going fast enough,
1616 * then let it though before starting on this new sync request.
1321 */ 1617 */
1322 if (!go_faster && waitqueue_active(&conf->wait_resume)) 1618 if (!go_faster && conf->nr_waiting)
1323 msleep_interruptible(1000); 1619 msleep_interruptible(1000);
1324 device_barrier(conf, sector_nr + RESYNC_SECTORS);
1325
1326 /*
1327 * If reconstructing, and >1 working disc,
1328 * could dedicate one to rebuild and others to
1329 * service read requests ..
1330 */
1331 disk = conf->last_used;
1332 /* make sure disk is operational */
1333 wonly = disk;
1334 while (conf->mirrors[disk].rdev == NULL ||
1335 !test_bit(In_sync, &conf->mirrors[disk].rdev->flags) ||
1336 test_bit(WriteMostly, &conf->mirrors[disk].rdev->flags)
1337 ) {
1338 if (conf->mirrors[disk].rdev &&
1339 test_bit(In_sync, &conf->mirrors[disk].rdev->flags))
1340 wonly = disk;
1341 if (disk <= 0)
1342 disk = conf->raid_disks;
1343 disk--;
1344 if (disk == conf->last_used) {
1345 disk = wonly;
1346 break;
1347 }
1348 }
1349 conf->last_used = disk;
1350 atomic_inc(&conf->mirrors[disk].rdev->nr_pending);
1351 1620
1621 raise_barrier(conf);
1352 1622
1353 mirror = conf->mirrors + disk; 1623 conf->next_resync = sector_nr;
1354 1624
1355 r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO); 1625 r1_bio = mempool_alloc(conf->r1buf_pool, GFP_NOIO);
1356 1626 rcu_read_lock();
1357 spin_lock_irq(&conf->resync_lock); 1627 /*
1358 conf->nr_pending++; 1628 * If we get a correctably read error during resync or recovery,
1359 spin_unlock_irq(&conf->resync_lock); 1629 * we might want to read from a different device. So we
1630 * flag all drives that could conceivably be read from for READ,
1631 * and any others (which will be non-In_sync devices) for WRITE.
1632 * If a read fails, we try reading from something else for which READ
1633 * is OK.
1634 */
1360 1635
1361 r1_bio->mddev = mddev; 1636 r1_bio->mddev = mddev;
1362 r1_bio->sector = sector_nr; 1637 r1_bio->sector = sector_nr;
1363 r1_bio->state = 0; 1638 r1_bio->state = 0;
1364 set_bit(R1BIO_IsSync, &r1_bio->state); 1639 set_bit(R1BIO_IsSync, &r1_bio->state);
1365 r1_bio->read_disk = disk;
1366 1640
1367 for (i=0; i < conf->raid_disks; i++) { 1641 for (i=0; i < conf->raid_disks; i++) {
1642 mdk_rdev_t *rdev;
1368 bio = r1_bio->bios[i]; 1643 bio = r1_bio->bios[i];
1369 1644
1370 /* take from bio_init */ 1645 /* take from bio_init */
@@ -1379,35 +1654,49 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1379 bio->bi_end_io = NULL; 1654 bio->bi_end_io = NULL;
1380 bio->bi_private = NULL; 1655 bio->bi_private = NULL;
1381 1656
1382 if (i == disk) { 1657 rdev = rcu_dereference(conf->mirrors[i].rdev);
1383 bio->bi_rw = READ; 1658 if (rdev == NULL ||
1384 bio->bi_end_io = end_sync_read; 1659 test_bit(Faulty, &rdev->flags)) {
1385 } else if (conf->mirrors[i].rdev == NULL ||
1386 test_bit(Faulty, &conf->mirrors[i].rdev->flags)) {
1387 still_degraded = 1; 1660 still_degraded = 1;
1388 continue; 1661 continue;
1389 } else if (!test_bit(In_sync, &conf->mirrors[i].rdev->flags) || 1662 } else if (!test_bit(In_sync, &rdev->flags)) {
1390 sector_nr + RESYNC_SECTORS > mddev->recovery_cp ||
1391 test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
1392 bio->bi_rw = WRITE; 1663 bio->bi_rw = WRITE;
1393 bio->bi_end_io = end_sync_write; 1664 bio->bi_end_io = end_sync_write;
1394 write_targets ++; 1665 write_targets ++;
1395 } else 1666 } else {
1396 /* no need to read or write here */ 1667 /* may need to read from here */
1397 continue; 1668 bio->bi_rw = READ;
1398 bio->bi_sector = sector_nr + conf->mirrors[i].rdev->data_offset; 1669 bio->bi_end_io = end_sync_read;
1399 bio->bi_bdev = conf->mirrors[i].rdev->bdev; 1670 if (test_bit(WriteMostly, &rdev->flags)) {
1671 if (wonly < 0)
1672 wonly = i;
1673 } else {
1674 if (disk < 0)
1675 disk = i;
1676 }
1677 read_targets++;
1678 }
1679 atomic_inc(&rdev->nr_pending);
1680 bio->bi_sector = sector_nr + rdev->data_offset;
1681 bio->bi_bdev = rdev->bdev;
1400 bio->bi_private = r1_bio; 1682 bio->bi_private = r1_bio;
1401 } 1683 }
1684 rcu_read_unlock();
1685 if (disk < 0)
1686 disk = wonly;
1687 r1_bio->read_disk = disk;
1688
1689 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery) && read_targets > 0)
1690 /* extra read targets are also write targets */
1691 write_targets += read_targets-1;
1402 1692
1403 if (write_targets == 0) { 1693 if (write_targets == 0 || read_targets == 0) {
1404 /* There is nowhere to write, so all non-sync 1694 /* There is nowhere to write, so all non-sync
1405 * drives must be failed - so we are finished 1695 * drives must be failed - so we are finished
1406 */ 1696 */
1407 sector_t rv = max_sector - sector_nr; 1697 sector_t rv = max_sector - sector_nr;
1408 *skipped = 1; 1698 *skipped = 1;
1409 put_buf(r1_bio); 1699 put_buf(r1_bio);
1410 rdev_dec_pending(conf->mirrors[disk].rdev, mddev);
1411 return rv; 1700 return rv;
1412 } 1701 }
1413 1702
@@ -1435,10 +1724,10 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1435 for (i=0 ; i < conf->raid_disks; i++) { 1724 for (i=0 ; i < conf->raid_disks; i++) {
1436 bio = r1_bio->bios[i]; 1725 bio = r1_bio->bios[i];
1437 if (bio->bi_end_io) { 1726 if (bio->bi_end_io) {
1438 page = r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page; 1727 page = bio->bi_io_vec[bio->bi_vcnt].bv_page;
1439 if (bio_add_page(bio, page, len, 0) == 0) { 1728 if (bio_add_page(bio, page, len, 0) == 0) {
1440 /* stop here */ 1729 /* stop here */
1441 r1_bio->bios[0]->bi_io_vec[bio->bi_vcnt].bv_page = page; 1730 bio->bi_io_vec[bio->bi_vcnt].bv_page = page;
1442 while (i > 0) { 1731 while (i > 0) {
1443 i--; 1732 i--;
1444 bio = r1_bio->bios[i]; 1733 bio = r1_bio->bios[i];
@@ -1458,12 +1747,28 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1458 sync_blocks -= (len>>9); 1747 sync_blocks -= (len>>9);
1459 } while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES); 1748 } while (r1_bio->bios[disk]->bi_vcnt < RESYNC_PAGES);
1460 bio_full: 1749 bio_full:
1461 bio = r1_bio->bios[disk];
1462 r1_bio->sectors = nr_sectors; 1750 r1_bio->sectors = nr_sectors;
1463 1751
1464 md_sync_acct(mirror->rdev->bdev, nr_sectors); 1752 /* For a user-requested sync, we read all readable devices and do a
1753 * compare
1754 */
1755 if (test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
1756 atomic_set(&r1_bio->remaining, read_targets);
1757 for (i=0; i<conf->raid_disks; i++) {
1758 bio = r1_bio->bios[i];
1759 if (bio->bi_end_io == end_sync_read) {
1760 md_sync_acct(conf->mirrors[i].rdev->bdev, nr_sectors);
1761 generic_make_request(bio);
1762 }
1763 }
1764 } else {
1765 atomic_set(&r1_bio->remaining, 1);
1766 bio = r1_bio->bios[r1_bio->read_disk];
1767 md_sync_acct(conf->mirrors[r1_bio->read_disk].rdev->bdev,
1768 nr_sectors);
1769 generic_make_request(bio);
1465 1770
1466 generic_make_request(bio); 1771 }
1467 1772
1468 return nr_sectors; 1773 return nr_sectors;
1469} 1774}
@@ -1486,18 +1791,19 @@ static int run(mddev_t *mddev)
1486 * bookkeeping area. [whatever we allocate in run(), 1791 * bookkeeping area. [whatever we allocate in run(),
1487 * should be freed in stop()] 1792 * should be freed in stop()]
1488 */ 1793 */
1489 conf = kmalloc(sizeof(conf_t), GFP_KERNEL); 1794 conf = kzalloc(sizeof(conf_t), GFP_KERNEL);
1490 mddev->private = conf; 1795 mddev->private = conf;
1491 if (!conf) 1796 if (!conf)
1492 goto out_no_mem; 1797 goto out_no_mem;
1493 1798
1494 memset(conf, 0, sizeof(*conf)); 1799 conf->mirrors = kzalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1495 conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1496 GFP_KERNEL); 1800 GFP_KERNEL);
1497 if (!conf->mirrors) 1801 if (!conf->mirrors)
1498 goto out_no_mem; 1802 goto out_no_mem;
1499 1803
1500 memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks); 1804 conf->tmppage = alloc_page(GFP_KERNEL);
1805 if (!conf->tmppage)
1806 goto out_no_mem;
1501 1807
1502 conf->poolinfo = kmalloc(sizeof(*conf->poolinfo), GFP_KERNEL); 1808 conf->poolinfo = kmalloc(sizeof(*conf->poolinfo), GFP_KERNEL);
1503 if (!conf->poolinfo) 1809 if (!conf->poolinfo)
@@ -1541,8 +1847,7 @@ static int run(mddev_t *mddev)
1541 mddev->recovery_cp = MaxSector; 1847 mddev->recovery_cp = MaxSector;
1542 1848
1543 spin_lock_init(&conf->resync_lock); 1849 spin_lock_init(&conf->resync_lock);
1544 init_waitqueue_head(&conf->wait_idle); 1850 init_waitqueue_head(&conf->wait_barrier);
1545 init_waitqueue_head(&conf->wait_resume);
1546 1851
1547 bio_list_init(&conf->pending_bio_list); 1852 bio_list_init(&conf->pending_bio_list);
1548 bio_list_init(&conf->flushing_bio_list); 1853 bio_list_init(&conf->flushing_bio_list);
@@ -1582,7 +1887,6 @@ static int run(mddev_t *mddev)
1582 mdname(mddev)); 1887 mdname(mddev));
1583 goto out_free_conf; 1888 goto out_free_conf;
1584 } 1889 }
1585 if (mddev->bitmap) mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1586 1890
1587 printk(KERN_INFO 1891 printk(KERN_INFO
1588 "raid1: raid set %s active with %d out of %d mirrors\n", 1892 "raid1: raid set %s active with %d out of %d mirrors\n",
@@ -1607,6 +1911,7 @@ out_free_conf:
1607 if (conf->r1bio_pool) 1911 if (conf->r1bio_pool)
1608 mempool_destroy(conf->r1bio_pool); 1912 mempool_destroy(conf->r1bio_pool);
1609 kfree(conf->mirrors); 1913 kfree(conf->mirrors);
1914 safe_put_page(conf->tmppage);
1610 kfree(conf->poolinfo); 1915 kfree(conf->poolinfo);
1611 kfree(conf); 1916 kfree(conf);
1612 mddev->private = NULL; 1917 mddev->private = NULL;
@@ -1705,19 +2010,14 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks)
1705 kfree(newpoolinfo); 2010 kfree(newpoolinfo);
1706 return -ENOMEM; 2011 return -ENOMEM;
1707 } 2012 }
1708 newmirrors = kmalloc(sizeof(struct mirror_info) * raid_disks, GFP_KERNEL); 2013 newmirrors = kzalloc(sizeof(struct mirror_info) * raid_disks, GFP_KERNEL);
1709 if (!newmirrors) { 2014 if (!newmirrors) {
1710 kfree(newpoolinfo); 2015 kfree(newpoolinfo);
1711 mempool_destroy(newpool); 2016 mempool_destroy(newpool);
1712 return -ENOMEM; 2017 return -ENOMEM;
1713 } 2018 }
1714 memset(newmirrors, 0, sizeof(struct mirror_info)*raid_disks);
1715 2019
1716 spin_lock_irq(&conf->resync_lock); 2020 raise_barrier(conf);
1717 conf->barrier++;
1718 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending,
1719 conf->resync_lock, raid1_unplug(mddev->queue));
1720 spin_unlock_irq(&conf->resync_lock);
1721 2021
1722 /* ok, everything is stopped */ 2022 /* ok, everything is stopped */
1723 oldpool = conf->r1bio_pool; 2023 oldpool = conf->r1bio_pool;
@@ -1737,12 +2037,7 @@ static int raid1_reshape(mddev_t *mddev, int raid_disks)
1737 conf->raid_disks = mddev->raid_disks = raid_disks; 2037 conf->raid_disks = mddev->raid_disks = raid_disks;
1738 2038
1739 conf->last_used = 0; /* just make sure it is in-range */ 2039 conf->last_used = 0; /* just make sure it is in-range */
1740 spin_lock_irq(&conf->resync_lock); 2040 lower_barrier(conf);
1741 conf->barrier--;
1742 spin_unlock_irq(&conf->resync_lock);
1743 wake_up(&conf->wait_resume);
1744 wake_up(&conf->wait_idle);
1745
1746 2041
1747 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 2042 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
1748 md_wakeup_thread(mddev->thread); 2043 md_wakeup_thread(mddev->thread);
@@ -1757,33 +2052,19 @@ static void raid1_quiesce(mddev_t *mddev, int state)
1757 2052
1758 switch(state) { 2053 switch(state) {
1759 case 1: 2054 case 1:
1760 spin_lock_irq(&conf->resync_lock); 2055 raise_barrier(conf);
1761 conf->barrier++;
1762 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending,
1763 conf->resync_lock, raid1_unplug(mddev->queue));
1764 spin_unlock_irq(&conf->resync_lock);
1765 break; 2056 break;
1766 case 0: 2057 case 0:
1767 spin_lock_irq(&conf->resync_lock); 2058 lower_barrier(conf);
1768 conf->barrier--;
1769 spin_unlock_irq(&conf->resync_lock);
1770 wake_up(&conf->wait_resume);
1771 wake_up(&conf->wait_idle);
1772 break; 2059 break;
1773 } 2060 }
1774 if (mddev->thread) {
1775 if (mddev->bitmap)
1776 mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1777 else
1778 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
1779 md_wakeup_thread(mddev->thread);
1780 }
1781} 2061}
1782 2062
1783 2063
1784static mdk_personality_t raid1_personality = 2064static struct mdk_personality raid1_personality =
1785{ 2065{
1786 .name = "raid1", 2066 .name = "raid1",
2067 .level = 1,
1787 .owner = THIS_MODULE, 2068 .owner = THIS_MODULE,
1788 .make_request = make_request, 2069 .make_request = make_request,
1789 .run = run, 2070 .run = run,
@@ -1801,15 +2082,17 @@ static mdk_personality_t raid1_personality =
1801 2082
1802static int __init raid_init(void) 2083static int __init raid_init(void)
1803{ 2084{
1804 return register_md_personality(RAID1, &raid1_personality); 2085 return register_md_personality(&raid1_personality);
1805} 2086}
1806 2087
1807static void raid_exit(void) 2088static void raid_exit(void)
1808{ 2089{
1809 unregister_md_personality(RAID1); 2090 unregister_md_personality(&raid1_personality);
1810} 2091}
1811 2092
1812module_init(raid_init); 2093module_init(raid_init);
1813module_exit(raid_exit); 2094module_exit(raid_exit);
1814MODULE_LICENSE("GPL"); 2095MODULE_LICENSE("GPL");
1815MODULE_ALIAS("md-personality-3"); /* RAID1 */ 2096MODULE_ALIAS("md-personality-3"); /* RAID1 */
2097MODULE_ALIAS("md-raid1");
2098MODULE_ALIAS("md-level-1");
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 713dc9c2c730..9e658e519a27 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -18,7 +18,9 @@
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */ 19 */
20 20
21#include "dm-bio-list.h"
21#include <linux/raid/raid10.h> 22#include <linux/raid/raid10.h>
23#include <linux/raid/bitmap.h>
22 24
23/* 25/*
24 * RAID10 provides a combination of RAID0 and RAID1 functionality. 26 * RAID10 provides a combination of RAID0 and RAID1 functionality.
@@ -47,6 +49,9 @@
47 49
48static void unplug_slaves(mddev_t *mddev); 50static void unplug_slaves(mddev_t *mddev);
49 51
52static void allow_barrier(conf_t *conf);
53static void lower_barrier(conf_t *conf);
54
50static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data) 55static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
51{ 56{
52 conf_t *conf = data; 57 conf_t *conf = data;
@@ -54,10 +59,8 @@ static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
54 int size = offsetof(struct r10bio_s, devs[conf->copies]); 59 int size = offsetof(struct r10bio_s, devs[conf->copies]);
55 60
56 /* allocate a r10bio with room for raid_disks entries in the bios array */ 61 /* allocate a r10bio with room for raid_disks entries in the bios array */
57 r10_bio = kmalloc(size, gfp_flags); 62 r10_bio = kzalloc(size, gfp_flags);
58 if (r10_bio) 63 if (!r10_bio)
59 memset(r10_bio, 0, size);
60 else
61 unplug_slaves(conf->mddev); 64 unplug_slaves(conf->mddev);
62 65
63 return r10_bio; 66 return r10_bio;
@@ -129,10 +132,10 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
129 132
130out_free_pages: 133out_free_pages:
131 for ( ; i > 0 ; i--) 134 for ( ; i > 0 ; i--)
132 __free_page(bio->bi_io_vec[i-1].bv_page); 135 safe_put_page(bio->bi_io_vec[i-1].bv_page);
133 while (j--) 136 while (j--)
134 for (i = 0; i < RESYNC_PAGES ; i++) 137 for (i = 0; i < RESYNC_PAGES ; i++)
135 __free_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page); 138 safe_put_page(r10_bio->devs[j].bio->bi_io_vec[i].bv_page);
136 j = -1; 139 j = -1;
137out_free_bio: 140out_free_bio:
138 while ( ++j < nalloc ) 141 while ( ++j < nalloc )
@@ -152,7 +155,7 @@ static void r10buf_pool_free(void *__r10_bio, void *data)
152 struct bio *bio = r10bio->devs[j].bio; 155 struct bio *bio = r10bio->devs[j].bio;
153 if (bio) { 156 if (bio) {
154 for (i = 0; i < RESYNC_PAGES; i++) { 157 for (i = 0; i < RESYNC_PAGES; i++) {
155 __free_page(bio->bi_io_vec[i].bv_page); 158 safe_put_page(bio->bi_io_vec[i].bv_page);
156 bio->bi_io_vec[i].bv_page = NULL; 159 bio->bi_io_vec[i].bv_page = NULL;
157 } 160 }
158 bio_put(bio); 161 bio_put(bio);
@@ -167,7 +170,7 @@ static void put_all_bios(conf_t *conf, r10bio_t *r10_bio)
167 170
168 for (i = 0; i < conf->copies; i++) { 171 for (i = 0; i < conf->copies; i++) {
169 struct bio **bio = & r10_bio->devs[i].bio; 172 struct bio **bio = & r10_bio->devs[i].bio;
170 if (*bio) 173 if (*bio && *bio != IO_BLOCKED)
171 bio_put(*bio); 174 bio_put(*bio);
172 *bio = NULL; 175 *bio = NULL;
173 } 176 }
@@ -175,20 +178,13 @@ static void put_all_bios(conf_t *conf, r10bio_t *r10_bio)
175 178
176static inline void free_r10bio(r10bio_t *r10_bio) 179static inline void free_r10bio(r10bio_t *r10_bio)
177{ 180{
178 unsigned long flags;
179
180 conf_t *conf = mddev_to_conf(r10_bio->mddev); 181 conf_t *conf = mddev_to_conf(r10_bio->mddev);
181 182
182 /* 183 /*
183 * Wake up any possible resync thread that waits for the device 184 * Wake up any possible resync thread that waits for the device
184 * to go idle. 185 * to go idle.
185 */ 186 */
186 spin_lock_irqsave(&conf->resync_lock, flags); 187 allow_barrier(conf);
187 if (!--conf->nr_pending) {
188 wake_up(&conf->wait_idle);
189 wake_up(&conf->wait_resume);
190 }
191 spin_unlock_irqrestore(&conf->resync_lock, flags);
192 188
193 put_all_bios(conf, r10_bio); 189 put_all_bios(conf, r10_bio);
194 mempool_free(r10_bio, conf->r10bio_pool); 190 mempool_free(r10_bio, conf->r10bio_pool);
@@ -197,22 +193,10 @@ static inline void free_r10bio(r10bio_t *r10_bio)
197static inline void put_buf(r10bio_t *r10_bio) 193static inline void put_buf(r10bio_t *r10_bio)
198{ 194{
199 conf_t *conf = mddev_to_conf(r10_bio->mddev); 195 conf_t *conf = mddev_to_conf(r10_bio->mddev);
200 unsigned long flags;
201 196
202 mempool_free(r10_bio, conf->r10buf_pool); 197 mempool_free(r10_bio, conf->r10buf_pool);
203 198
204 spin_lock_irqsave(&conf->resync_lock, flags); 199 lower_barrier(conf);
205 if (!conf->barrier)
206 BUG();
207 --conf->barrier;
208 wake_up(&conf->wait_resume);
209 wake_up(&conf->wait_idle);
210
211 if (!--conf->nr_pending) {
212 wake_up(&conf->wait_idle);
213 wake_up(&conf->wait_resume);
214 }
215 spin_unlock_irqrestore(&conf->resync_lock, flags);
216} 200}
217 201
218static void reschedule_retry(r10bio_t *r10_bio) 202static void reschedule_retry(r10bio_t *r10_bio)
@@ -223,6 +207,7 @@ static void reschedule_retry(r10bio_t *r10_bio)
223 207
224 spin_lock_irqsave(&conf->device_lock, flags); 208 spin_lock_irqsave(&conf->device_lock, flags);
225 list_add(&r10_bio->retry_list, &conf->retry_list); 209 list_add(&r10_bio->retry_list, &conf->retry_list);
210 conf->nr_queued ++;
226 spin_unlock_irqrestore(&conf->device_lock, flags); 211 spin_unlock_irqrestore(&conf->device_lock, flags);
227 212
228 md_wakeup_thread(mddev->thread); 213 md_wakeup_thread(mddev->thread);
@@ -268,9 +253,9 @@ static int raid10_end_read_request(struct bio *bio, unsigned int bytes_done, int
268 /* 253 /*
269 * this branch is our 'one mirror IO has finished' event handler: 254 * this branch is our 'one mirror IO has finished' event handler:
270 */ 255 */
271 if (!uptodate) 256 update_head_pos(slot, r10_bio);
272 md_error(r10_bio->mddev, conf->mirrors[dev].rdev); 257
273 else 258 if (uptodate) {
274 /* 259 /*
275 * Set R10BIO_Uptodate in our master bio, so that 260 * Set R10BIO_Uptodate in our master bio, so that
276 * we will return a good error code to the higher 261 * we will return a good error code to the higher
@@ -281,15 +266,8 @@ static int raid10_end_read_request(struct bio *bio, unsigned int bytes_done, int
281 * wait for the 'master' bio. 266 * wait for the 'master' bio.
282 */ 267 */
283 set_bit(R10BIO_Uptodate, &r10_bio->state); 268 set_bit(R10BIO_Uptodate, &r10_bio->state);
284
285 update_head_pos(slot, r10_bio);
286
287 /*
288 * we have only one bio on the read side
289 */
290 if (uptodate)
291 raid_end_bio_io(r10_bio); 269 raid_end_bio_io(r10_bio);
292 else { 270 } else {
293 /* 271 /*
294 * oops, read error: 272 * oops, read error:
295 */ 273 */
@@ -322,9 +300,11 @@ static int raid10_end_write_request(struct bio *bio, unsigned int bytes_done, in
322 /* 300 /*
323 * this branch is our 'one mirror IO has finished' event handler: 301 * this branch is our 'one mirror IO has finished' event handler:
324 */ 302 */
325 if (!uptodate) 303 if (!uptodate) {
326 md_error(r10_bio->mddev, conf->mirrors[dev].rdev); 304 md_error(r10_bio->mddev, conf->mirrors[dev].rdev);
327 else 305 /* an I/O failed, we can't clear the bitmap */
306 set_bit(R10BIO_Degraded, &r10_bio->state);
307 } else
328 /* 308 /*
329 * Set R10BIO_Uptodate in our master bio, so that 309 * Set R10BIO_Uptodate in our master bio, so that
330 * we will return a good error code for to the higher 310 * we will return a good error code for to the higher
@@ -344,6 +324,11 @@ static int raid10_end_write_request(struct bio *bio, unsigned int bytes_done, in
344 * already. 324 * already.
345 */ 325 */
346 if (atomic_dec_and_test(&r10_bio->remaining)) { 326 if (atomic_dec_and_test(&r10_bio->remaining)) {
327 /* clear the bitmap if all writes complete successfully */
328 bitmap_endwrite(r10_bio->mddev->bitmap, r10_bio->sector,
329 r10_bio->sectors,
330 !test_bit(R10BIO_Degraded, &r10_bio->state),
331 0);
347 md_write_end(r10_bio->mddev); 332 md_write_end(r10_bio->mddev);
348 raid_end_bio_io(r10_bio); 333 raid_end_bio_io(r10_bio);
349 } 334 }
@@ -502,8 +487,9 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
502 rcu_read_lock(); 487 rcu_read_lock();
503 /* 488 /*
504 * Check if we can balance. We can balance on the whole 489 * Check if we can balance. We can balance on the whole
505 * device if no resync is going on, or below the resync window. 490 * device if no resync is going on (recovery is ok), or below
506 * We take the first readable disk when above the resync window. 491 * the resync window. We take the first readable disk when
492 * above the resync window.
507 */ 493 */
508 if (conf->mddev->recovery_cp < MaxSector 494 if (conf->mddev->recovery_cp < MaxSector
509 && (this_sector + sectors >= conf->next_resync)) { 495 && (this_sector + sectors >= conf->next_resync)) {
@@ -512,6 +498,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
512 disk = r10_bio->devs[slot].devnum; 498 disk = r10_bio->devs[slot].devnum;
513 499
514 while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL || 500 while ((rdev = rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
501 r10_bio->devs[slot].bio == IO_BLOCKED ||
515 !test_bit(In_sync, &rdev->flags)) { 502 !test_bit(In_sync, &rdev->flags)) {
516 slot++; 503 slot++;
517 if (slot == conf->copies) { 504 if (slot == conf->copies) {
@@ -529,6 +516,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
529 slot = 0; 516 slot = 0;
530 disk = r10_bio->devs[slot].devnum; 517 disk = r10_bio->devs[slot].devnum;
531 while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL || 518 while ((rdev=rcu_dereference(conf->mirrors[disk].rdev)) == NULL ||
519 r10_bio->devs[slot].bio == IO_BLOCKED ||
532 !test_bit(In_sync, &rdev->flags)) { 520 !test_bit(In_sync, &rdev->flags)) {
533 slot ++; 521 slot ++;
534 if (slot == conf->copies) { 522 if (slot == conf->copies) {
@@ -549,6 +537,7 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
549 537
550 538
551 if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL || 539 if ((rdev=rcu_dereference(conf->mirrors[ndisk].rdev)) == NULL ||
540 r10_bio->devs[nslot].bio == IO_BLOCKED ||
552 !test_bit(In_sync, &rdev->flags)) 541 !test_bit(In_sync, &rdev->flags))
553 continue; 542 continue;
554 543
@@ -607,7 +596,10 @@ static void unplug_slaves(mddev_t *mddev)
607 596
608static void raid10_unplug(request_queue_t *q) 597static void raid10_unplug(request_queue_t *q)
609{ 598{
599 mddev_t *mddev = q->queuedata;
600
610 unplug_slaves(q->queuedata); 601 unplug_slaves(q->queuedata);
602 md_wakeup_thread(mddev->thread);
611} 603}
612 604
613static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk, 605static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk,
@@ -640,27 +632,107 @@ static int raid10_issue_flush(request_queue_t *q, struct gendisk *disk,
640 return ret; 632 return ret;
641} 633}
642 634
643/* 635/* Barriers....
644 * Throttle resync depth, so that we can both get proper overlapping of 636 * Sometimes we need to suspend IO while we do something else,
645 * requests, but are still able to handle normal requests quickly. 637 * either some resync/recovery, or reconfigure the array.
638 * To do this we raise a 'barrier'.
639 * The 'barrier' is a counter that can be raised multiple times
640 * to count how many activities are happening which preclude
641 * normal IO.
642 * We can only raise the barrier if there is no pending IO.
643 * i.e. if nr_pending == 0.
644 * We choose only to raise the barrier if no-one is waiting for the
645 * barrier to go down. This means that as soon as an IO request
646 * is ready, no other operations which require a barrier will start
647 * until the IO request has had a chance.
648 *
649 * So: regular IO calls 'wait_barrier'. When that returns there
650 * is no backgroup IO happening, It must arrange to call
651 * allow_barrier when it has finished its IO.
652 * backgroup IO calls must call raise_barrier. Once that returns
653 * there is no normal IO happeing. It must arrange to call
654 * lower_barrier when the particular background IO completes.
646 */ 655 */
647#define RESYNC_DEPTH 32 656#define RESYNC_DEPTH 32
648 657
649static void device_barrier(conf_t *conf, sector_t sect) 658static void raise_barrier(conf_t *conf, int force)
659{
660 BUG_ON(force && !conf->barrier);
661 spin_lock_irq(&conf->resync_lock);
662
663 /* Wait until no block IO is waiting (unless 'force') */
664 wait_event_lock_irq(conf->wait_barrier, force || !conf->nr_waiting,
665 conf->resync_lock,
666 raid10_unplug(conf->mddev->queue));
667
668 /* block any new IO from starting */
669 conf->barrier++;
670
671 /* No wait for all pending IO to complete */
672 wait_event_lock_irq(conf->wait_barrier,
673 !conf->nr_pending && conf->barrier < RESYNC_DEPTH,
674 conf->resync_lock,
675 raid10_unplug(conf->mddev->queue));
676
677 spin_unlock_irq(&conf->resync_lock);
678}
679
680static void lower_barrier(conf_t *conf)
681{
682 unsigned long flags;
683 spin_lock_irqsave(&conf->resync_lock, flags);
684 conf->barrier--;
685 spin_unlock_irqrestore(&conf->resync_lock, flags);
686 wake_up(&conf->wait_barrier);
687}
688
689static void wait_barrier(conf_t *conf)
650{ 690{
651 spin_lock_irq(&conf->resync_lock); 691 spin_lock_irq(&conf->resync_lock);
652 wait_event_lock_irq(conf->wait_idle, !waitqueue_active(&conf->wait_resume), 692 if (conf->barrier) {
653 conf->resync_lock, unplug_slaves(conf->mddev)); 693 conf->nr_waiting++;
654 694 wait_event_lock_irq(conf->wait_barrier, !conf->barrier,
655 if (!conf->barrier++) { 695 conf->resync_lock,
656 wait_event_lock_irq(conf->wait_idle, !conf->nr_pending, 696 raid10_unplug(conf->mddev->queue));
657 conf->resync_lock, unplug_slaves(conf->mddev)); 697 conf->nr_waiting--;
658 if (conf->nr_pending)
659 BUG();
660 } 698 }
661 wait_event_lock_irq(conf->wait_resume, conf->barrier < RESYNC_DEPTH, 699 conf->nr_pending++;
662 conf->resync_lock, unplug_slaves(conf->mddev)); 700 spin_unlock_irq(&conf->resync_lock);
663 conf->next_resync = sect; 701}
702
703static void allow_barrier(conf_t *conf)
704{
705 unsigned long flags;
706 spin_lock_irqsave(&conf->resync_lock, flags);
707 conf->nr_pending--;
708 spin_unlock_irqrestore(&conf->resync_lock, flags);
709 wake_up(&conf->wait_barrier);
710}
711
712static void freeze_array(conf_t *conf)
713{
714 /* stop syncio and normal IO and wait for everything to
715 * go quiet.
716 * We increment barrier and nr_waiting, and then
717 * wait until barrier+nr_pending match nr_queued+2
718 */
719 spin_lock_irq(&conf->resync_lock);
720 conf->barrier++;
721 conf->nr_waiting++;
722 wait_event_lock_irq(conf->wait_barrier,
723 conf->barrier+conf->nr_pending == conf->nr_queued+2,
724 conf->resync_lock,
725 raid10_unplug(conf->mddev->queue));
726 spin_unlock_irq(&conf->resync_lock);
727}
728
729static void unfreeze_array(conf_t *conf)
730{
731 /* reverse the effect of the freeze */
732 spin_lock_irq(&conf->resync_lock);
733 conf->barrier--;
734 conf->nr_waiting--;
735 wake_up(&conf->wait_barrier);
664 spin_unlock_irq(&conf->resync_lock); 736 spin_unlock_irq(&conf->resync_lock);
665} 737}
666 738
@@ -674,6 +746,8 @@ static int make_request(request_queue_t *q, struct bio * bio)
674 int i; 746 int i;
675 int chunk_sects = conf->chunk_mask + 1; 747 int chunk_sects = conf->chunk_mask + 1;
676 const int rw = bio_data_dir(bio); 748 const int rw = bio_data_dir(bio);
749 struct bio_list bl;
750 unsigned long flags;
677 751
678 if (unlikely(bio_barrier(bio))) { 752 if (unlikely(bio_barrier(bio))) {
679 bio_endio(bio, bio->bi_size, -EOPNOTSUPP); 753 bio_endio(bio, bio->bi_size, -EOPNOTSUPP);
@@ -719,10 +793,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
719 * thread has put up a bar for new requests. 793 * thread has put up a bar for new requests.
720 * Continue immediately if no resync is active currently. 794 * Continue immediately if no resync is active currently.
721 */ 795 */
722 spin_lock_irq(&conf->resync_lock); 796 wait_barrier(conf);
723 wait_event_lock_irq(conf->wait_resume, !conf->barrier, conf->resync_lock, );
724 conf->nr_pending++;
725 spin_unlock_irq(&conf->resync_lock);
726 797
727 disk_stat_inc(mddev->gendisk, ios[rw]); 798 disk_stat_inc(mddev->gendisk, ios[rw]);
728 disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); 799 disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio));
@@ -734,6 +805,7 @@ static int make_request(request_queue_t *q, struct bio * bio)
734 805
735 r10_bio->mddev = mddev; 806 r10_bio->mddev = mddev;
736 r10_bio->sector = bio->bi_sector; 807 r10_bio->sector = bio->bi_sector;
808 r10_bio->state = 0;
737 809
738 if (rw == READ) { 810 if (rw == READ) {
739 /* 811 /*
@@ -778,13 +850,16 @@ static int make_request(request_queue_t *q, struct bio * bio)
778 !test_bit(Faulty, &rdev->flags)) { 850 !test_bit(Faulty, &rdev->flags)) {
779 atomic_inc(&rdev->nr_pending); 851 atomic_inc(&rdev->nr_pending);
780 r10_bio->devs[i].bio = bio; 852 r10_bio->devs[i].bio = bio;
781 } else 853 } else {
782 r10_bio->devs[i].bio = NULL; 854 r10_bio->devs[i].bio = NULL;
855 set_bit(R10BIO_Degraded, &r10_bio->state);
856 }
783 } 857 }
784 rcu_read_unlock(); 858 rcu_read_unlock();
785 859
786 atomic_set(&r10_bio->remaining, 1); 860 atomic_set(&r10_bio->remaining, 0);
787 861
862 bio_list_init(&bl);
788 for (i = 0; i < conf->copies; i++) { 863 for (i = 0; i < conf->copies; i++) {
789 struct bio *mbio; 864 struct bio *mbio;
790 int d = r10_bio->devs[i].devnum; 865 int d = r10_bio->devs[i].devnum;
@@ -802,13 +877,14 @@ static int make_request(request_queue_t *q, struct bio * bio)
802 mbio->bi_private = r10_bio; 877 mbio->bi_private = r10_bio;
803 878
804 atomic_inc(&r10_bio->remaining); 879 atomic_inc(&r10_bio->remaining);
805 generic_make_request(mbio); 880 bio_list_add(&bl, mbio);
806 } 881 }
807 882
808 if (atomic_dec_and_test(&r10_bio->remaining)) { 883 bitmap_startwrite(mddev->bitmap, bio->bi_sector, r10_bio->sectors, 0);
809 md_write_end(mddev); 884 spin_lock_irqsave(&conf->device_lock, flags);
810 raid_end_bio_io(r10_bio); 885 bio_list_merge(&conf->pending_bio_list, &bl);
811 } 886 blk_plug_device(mddev->queue);
887 spin_unlock_irqrestore(&conf->device_lock, flags);
812 888
813 return 0; 889 return 0;
814} 890}
@@ -897,13 +973,8 @@ static void print_conf(conf_t *conf)
897 973
898static void close_sync(conf_t *conf) 974static void close_sync(conf_t *conf)
899{ 975{
900 spin_lock_irq(&conf->resync_lock); 976 wait_barrier(conf);
901 wait_event_lock_irq(conf->wait_resume, !conf->barrier, 977 allow_barrier(conf);
902 conf->resync_lock, unplug_slaves(conf->mddev));
903 spin_unlock_irq(&conf->resync_lock);
904
905 if (conf->barrier) BUG();
906 if (waitqueue_active(&conf->wait_idle)) BUG();
907 978
908 mempool_destroy(conf->r10buf_pool); 979 mempool_destroy(conf->r10buf_pool);
909 conf->r10buf_pool = NULL; 980 conf->r10buf_pool = NULL;
@@ -971,7 +1042,12 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
971 if (!enough(conf)) 1042 if (!enough(conf))
972 return 0; 1043 return 0;
973 1044
974 for (mirror=0; mirror < mddev->raid_disks; mirror++) 1045 if (rdev->saved_raid_disk >= 0 &&
1046 conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
1047 mirror = rdev->saved_raid_disk;
1048 else
1049 mirror = 0;
1050 for ( ; mirror < mddev->raid_disks; mirror++)
975 if ( !(p=conf->mirrors+mirror)->rdev) { 1051 if ( !(p=conf->mirrors+mirror)->rdev) {
976 1052
977 blk_queue_stack_limits(mddev->queue, 1053 blk_queue_stack_limits(mddev->queue,
@@ -987,6 +1063,8 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
987 p->head_position = 0; 1063 p->head_position = 0;
988 rdev->raid_disk = mirror; 1064 rdev->raid_disk = mirror;
989 found = 1; 1065 found = 1;
1066 if (rdev->saved_raid_disk != mirror)
1067 conf->fullsync = 1;
990 rcu_assign_pointer(p->rdev, rdev); 1068 rcu_assign_pointer(p->rdev, rdev);
991 break; 1069 break;
992 } 1070 }
@@ -1027,7 +1105,6 @@ abort:
1027 1105
1028static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error) 1106static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
1029{ 1107{
1030 int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
1031 r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private); 1108 r10bio_t * r10_bio = (r10bio_t *)(bio->bi_private);
1032 conf_t *conf = mddev_to_conf(r10_bio->mddev); 1109 conf_t *conf = mddev_to_conf(r10_bio->mddev);
1033 int i,d; 1110 int i,d;
@@ -1042,9 +1119,16 @@ static int end_sync_read(struct bio *bio, unsigned int bytes_done, int error)
1042 BUG(); 1119 BUG();
1043 update_head_pos(i, r10_bio); 1120 update_head_pos(i, r10_bio);
1044 d = r10_bio->devs[i].devnum; 1121 d = r10_bio->devs[i].devnum;
1045 if (!uptodate) 1122
1046 md_error(r10_bio->mddev, 1123 if (test_bit(BIO_UPTODATE, &bio->bi_flags))
1047 conf->mirrors[d].rdev); 1124 set_bit(R10BIO_Uptodate, &r10_bio->state);
1125 else {
1126 atomic_add(r10_bio->sectors,
1127 &conf->mirrors[d].rdev->corrected_errors);
1128 if (!test_bit(MD_RECOVERY_SYNC, &conf->mddev->recovery))
1129 md_error(r10_bio->mddev,
1130 conf->mirrors[d].rdev);
1131 }
1048 1132
1049 /* for reconstruct, we always reschedule after a read. 1133 /* for reconstruct, we always reschedule after a read.
1050 * for resync, only after all reads 1134 * for resync, only after all reads
@@ -1132,23 +1216,32 @@ static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio)
1132 fbio = r10_bio->devs[i].bio; 1216 fbio = r10_bio->devs[i].bio;
1133 1217
1134 /* now find blocks with errors */ 1218 /* now find blocks with errors */
1135 for (i=first+1 ; i < conf->copies ; i++) { 1219 for (i=0 ; i < conf->copies ; i++) {
1136 int vcnt, j, d; 1220 int j, d;
1221 int vcnt = r10_bio->sectors >> (PAGE_SHIFT-9);
1137 1222
1138 if (!test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags))
1139 continue;
1140 /* We know that the bi_io_vec layout is the same for
1141 * both 'first' and 'i', so we just compare them.
1142 * All vec entries are PAGE_SIZE;
1143 */
1144 tbio = r10_bio->devs[i].bio; 1223 tbio = r10_bio->devs[i].bio;
1145 vcnt = r10_bio->sectors >> (PAGE_SHIFT-9); 1224
1146 for (j = 0; j < vcnt; j++) 1225 if (tbio->bi_end_io != end_sync_read)
1147 if (memcmp(page_address(fbio->bi_io_vec[j].bv_page), 1226 continue;
1148 page_address(tbio->bi_io_vec[j].bv_page), 1227 if (i == first)
1149 PAGE_SIZE)) 1228 continue;
1150 break; 1229 if (test_bit(BIO_UPTODATE, &r10_bio->devs[i].bio->bi_flags)) {
1151 if (j == vcnt) 1230 /* We know that the bi_io_vec layout is the same for
1231 * both 'first' and 'i', so we just compare them.
1232 * All vec entries are PAGE_SIZE;
1233 */
1234 for (j = 0; j < vcnt; j++)
1235 if (memcmp(page_address(fbio->bi_io_vec[j].bv_page),
1236 page_address(tbio->bi_io_vec[j].bv_page),
1237 PAGE_SIZE))
1238 break;
1239 if (j == vcnt)
1240 continue;
1241 mddev->resync_mismatches += r10_bio->sectors;
1242 }
1243 if (test_bit(MD_RECOVERY_CHECK, &mddev->recovery))
1244 /* Don't fix anything. */
1152 continue; 1245 continue;
1153 /* Ok, we need to write this bio 1246 /* Ok, we need to write this bio
1154 * First we need to fixup bv_offset, bv_len and 1247 * First we need to fixup bv_offset, bv_len and
@@ -1227,7 +1320,10 @@ static void recovery_request_write(mddev_t *mddev, r10bio_t *r10_bio)
1227 1320
1228 atomic_inc(&conf->mirrors[d].rdev->nr_pending); 1321 atomic_inc(&conf->mirrors[d].rdev->nr_pending);
1229 md_sync_acct(conf->mirrors[d].rdev->bdev, wbio->bi_size >> 9); 1322 md_sync_acct(conf->mirrors[d].rdev->bdev, wbio->bi_size >> 9);
1230 generic_make_request(wbio); 1323 if (test_bit(R10BIO_Uptodate, &r10_bio->state))
1324 generic_make_request(wbio);
1325 else
1326 bio_endio(wbio, wbio->bi_size, -EIO);
1231} 1327}
1232 1328
1233 1329
@@ -1254,10 +1350,31 @@ static void raid10d(mddev_t *mddev)
1254 for (;;) { 1350 for (;;) {
1255 char b[BDEVNAME_SIZE]; 1351 char b[BDEVNAME_SIZE];
1256 spin_lock_irqsave(&conf->device_lock, flags); 1352 spin_lock_irqsave(&conf->device_lock, flags);
1353
1354 if (conf->pending_bio_list.head) {
1355 bio = bio_list_get(&conf->pending_bio_list);
1356 blk_remove_plug(mddev->queue);
1357 spin_unlock_irqrestore(&conf->device_lock, flags);
1358 /* flush any pending bitmap writes to disk before proceeding w/ I/O */
1359 if (bitmap_unplug(mddev->bitmap) != 0)
1360 printk("%s: bitmap file write failed!\n", mdname(mddev));
1361
1362 while (bio) { /* submit pending writes */
1363 struct bio *next = bio->bi_next;
1364 bio->bi_next = NULL;
1365 generic_make_request(bio);
1366 bio = next;
1367 }
1368 unplug = 1;
1369
1370 continue;
1371 }
1372
1257 if (list_empty(head)) 1373 if (list_empty(head))
1258 break; 1374 break;
1259 r10_bio = list_entry(head->prev, r10bio_t, retry_list); 1375 r10_bio = list_entry(head->prev, r10bio_t, retry_list);
1260 list_del(head->prev); 1376 list_del(head->prev);
1377 conf->nr_queued--;
1261 spin_unlock_irqrestore(&conf->device_lock, flags); 1378 spin_unlock_irqrestore(&conf->device_lock, flags);
1262 1379
1263 mddev = r10_bio->mddev; 1380 mddev = r10_bio->mddev;
@@ -1270,8 +1387,96 @@ static void raid10d(mddev_t *mddev)
1270 unplug = 1; 1387 unplug = 1;
1271 } else { 1388 } else {
1272 int mirror; 1389 int mirror;
1390 /* we got a read error. Maybe the drive is bad. Maybe just
1391 * the block and we can fix it.
1392 * We freeze all other IO, and try reading the block from
1393 * other devices. When we find one, we re-write
1394 * and check it that fixes the read error.
1395 * This is all done synchronously while the array is
1396 * frozen.
1397 */
1398 int sect = 0; /* Offset from r10_bio->sector */
1399 int sectors = r10_bio->sectors;
1400 freeze_array(conf);
1401 if (mddev->ro == 0) while(sectors) {
1402 int s = sectors;
1403 int sl = r10_bio->read_slot;
1404 int success = 0;
1405
1406 if (s > (PAGE_SIZE>>9))
1407 s = PAGE_SIZE >> 9;
1408
1409 do {
1410 int d = r10_bio->devs[sl].devnum;
1411 rdev = conf->mirrors[d].rdev;
1412 if (rdev &&
1413 test_bit(In_sync, &rdev->flags) &&
1414 sync_page_io(rdev->bdev,
1415 r10_bio->devs[sl].addr +
1416 sect + rdev->data_offset,
1417 s<<9,
1418 conf->tmppage, READ))
1419 success = 1;
1420 else {
1421 sl++;
1422 if (sl == conf->copies)
1423 sl = 0;
1424 }
1425 } while (!success && sl != r10_bio->read_slot);
1426
1427 if (success) {
1428 int start = sl;
1429 /* write it back and re-read */
1430 while (sl != r10_bio->read_slot) {
1431 int d;
1432 if (sl==0)
1433 sl = conf->copies;
1434 sl--;
1435 d = r10_bio->devs[sl].devnum;
1436 rdev = conf->mirrors[d].rdev;
1437 atomic_add(s, &rdev->corrected_errors);
1438 if (rdev &&
1439 test_bit(In_sync, &rdev->flags)) {
1440 if (sync_page_io(rdev->bdev,
1441 r10_bio->devs[sl].addr +
1442 sect + rdev->data_offset,
1443 s<<9, conf->tmppage, WRITE) == 0)
1444 /* Well, this device is dead */
1445 md_error(mddev, rdev);
1446 }
1447 }
1448 sl = start;
1449 while (sl != r10_bio->read_slot) {
1450 int d;
1451 if (sl==0)
1452 sl = conf->copies;
1453 sl--;
1454 d = r10_bio->devs[sl].devnum;
1455 rdev = conf->mirrors[d].rdev;
1456 if (rdev &&
1457 test_bit(In_sync, &rdev->flags)) {
1458 if (sync_page_io(rdev->bdev,
1459 r10_bio->devs[sl].addr +
1460 sect + rdev->data_offset,
1461 s<<9, conf->tmppage, READ) == 0)
1462 /* Well, this device is dead */
1463 md_error(mddev, rdev);
1464 }
1465 }
1466 } else {
1467 /* Cannot read from anywhere -- bye bye array */
1468 md_error(mddev, conf->mirrors[r10_bio->devs[r10_bio->read_slot].devnum].rdev);
1469 break;
1470 }
1471 sectors -= s;
1472 sect += s;
1473 }
1474
1475 unfreeze_array(conf);
1476
1273 bio = r10_bio->devs[r10_bio->read_slot].bio; 1477 bio = r10_bio->devs[r10_bio->read_slot].bio;
1274 r10_bio->devs[r10_bio->read_slot].bio = NULL; 1478 r10_bio->devs[r10_bio->read_slot].bio =
1479 mddev->ro ? IO_BLOCKED : NULL;
1275 bio_put(bio); 1480 bio_put(bio);
1276 mirror = read_balance(conf, r10_bio); 1481 mirror = read_balance(conf, r10_bio);
1277 if (mirror == -1) { 1482 if (mirror == -1) {
@@ -1360,6 +1565,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1360 sector_t max_sector, nr_sectors; 1565 sector_t max_sector, nr_sectors;
1361 int disk; 1566 int disk;
1362 int i; 1567 int i;
1568 int max_sync;
1569 int sync_blocks;
1363 1570
1364 sector_t sectors_skipped = 0; 1571 sector_t sectors_skipped = 0;
1365 int chunks_skipped = 0; 1572 int chunks_skipped = 0;
@@ -1373,6 +1580,29 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1373 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) 1580 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
1374 max_sector = mddev->resync_max_sectors; 1581 max_sector = mddev->resync_max_sectors;
1375 if (sector_nr >= max_sector) { 1582 if (sector_nr >= max_sector) {
1583 /* If we aborted, we need to abort the
1584 * sync on the 'current' bitmap chucks (there can
1585 * be several when recovering multiple devices).
1586 * as we may have started syncing it but not finished.
1587 * We can find the current address in
1588 * mddev->curr_resync, but for recovery,
1589 * we need to convert that to several
1590 * virtual addresses.
1591 */
1592 if (mddev->curr_resync < max_sector) { /* aborted */
1593 if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
1594 bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
1595 &sync_blocks, 1);
1596 else for (i=0; i<conf->raid_disks; i++) {
1597 sector_t sect =
1598 raid10_find_virt(conf, mddev->curr_resync, i);
1599 bitmap_end_sync(mddev->bitmap, sect,
1600 &sync_blocks, 1);
1601 }
1602 } else /* completed sync */
1603 conf->fullsync = 0;
1604
1605 bitmap_close_sync(mddev->bitmap);
1376 close_sync(conf); 1606 close_sync(conf);
1377 *skipped = 1; 1607 *skipped = 1;
1378 return sectors_skipped; 1608 return sectors_skipped;
@@ -1395,9 +1625,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1395 * If there is non-resync activity waiting for us then 1625 * If there is non-resync activity waiting for us then
1396 * put in a delay to throttle resync. 1626 * put in a delay to throttle resync.
1397 */ 1627 */
1398 if (!go_faster && waitqueue_active(&conf->wait_resume)) 1628 if (!go_faster && conf->nr_waiting)
1399 msleep_interruptible(1000); 1629 msleep_interruptible(1000);
1400 device_barrier(conf, sector_nr + RESYNC_SECTORS);
1401 1630
1402 /* Again, very different code for resync and recovery. 1631 /* Again, very different code for resync and recovery.
1403 * Both must result in an r10bio with a list of bios that 1632 * Both must result in an r10bio with a list of bios that
@@ -1414,6 +1643,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1414 * end_sync_write if we will want to write. 1643 * end_sync_write if we will want to write.
1415 */ 1644 */
1416 1645
1646 max_sync = RESYNC_PAGES << (PAGE_SHIFT-9);
1417 if (!test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) { 1647 if (!test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
1418 /* recovery... the complicated one */ 1648 /* recovery... the complicated one */
1419 int i, j, k; 1649 int i, j, k;
@@ -1422,14 +1652,29 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1422 for (i=0 ; i<conf->raid_disks; i++) 1652 for (i=0 ; i<conf->raid_disks; i++)
1423 if (conf->mirrors[i].rdev && 1653 if (conf->mirrors[i].rdev &&
1424 !test_bit(In_sync, &conf->mirrors[i].rdev->flags)) { 1654 !test_bit(In_sync, &conf->mirrors[i].rdev->flags)) {
1655 int still_degraded = 0;
1425 /* want to reconstruct this device */ 1656 /* want to reconstruct this device */
1426 r10bio_t *rb2 = r10_bio; 1657 r10bio_t *rb2 = r10_bio;
1658 sector_t sect = raid10_find_virt(conf, sector_nr, i);
1659 int must_sync;
1660 /* Unless we are doing a full sync, we only need
1661 * to recover the block if it is set in the bitmap
1662 */
1663 must_sync = bitmap_start_sync(mddev->bitmap, sect,
1664 &sync_blocks, 1);
1665 if (sync_blocks < max_sync)
1666 max_sync = sync_blocks;
1667 if (!must_sync &&
1668 !conf->fullsync) {
1669 /* yep, skip the sync_blocks here, but don't assume
1670 * that there will never be anything to do here
1671 */
1672 chunks_skipped = -1;
1673 continue;
1674 }
1427 1675
1428 r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO); 1676 r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO);
1429 spin_lock_irq(&conf->resync_lock); 1677 raise_barrier(conf, rb2 != NULL);
1430 conf->nr_pending++;
1431 if (rb2) conf->barrier++;
1432 spin_unlock_irq(&conf->resync_lock);
1433 atomic_set(&r10_bio->remaining, 0); 1678 atomic_set(&r10_bio->remaining, 0);
1434 1679
1435 r10_bio->master_bio = (struct bio*)rb2; 1680 r10_bio->master_bio = (struct bio*)rb2;
@@ -1437,8 +1682,23 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1437 atomic_inc(&rb2->remaining); 1682 atomic_inc(&rb2->remaining);
1438 r10_bio->mddev = mddev; 1683 r10_bio->mddev = mddev;
1439 set_bit(R10BIO_IsRecover, &r10_bio->state); 1684 set_bit(R10BIO_IsRecover, &r10_bio->state);
1440 r10_bio->sector = raid10_find_virt(conf, sector_nr, i); 1685 r10_bio->sector = sect;
1686
1441 raid10_find_phys(conf, r10_bio); 1687 raid10_find_phys(conf, r10_bio);
1688 /* Need to check if this section will still be
1689 * degraded
1690 */
1691 for (j=0; j<conf->copies;j++) {
1692 int d = r10_bio->devs[j].devnum;
1693 if (conf->mirrors[d].rdev == NULL ||
1694 test_bit(Faulty, &conf->mirrors[d].rdev->flags)) {
1695 still_degraded = 1;
1696 break;
1697 }
1698 }
1699 must_sync = bitmap_start_sync(mddev->bitmap, sect,
1700 &sync_blocks, still_degraded);
1701
1442 for (j=0; j<conf->copies;j++) { 1702 for (j=0; j<conf->copies;j++) {
1443 int d = r10_bio->devs[j].devnum; 1703 int d = r10_bio->devs[j].devnum;
1444 if (conf->mirrors[d].rdev && 1704 if (conf->mirrors[d].rdev &&
@@ -1498,14 +1758,22 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1498 } else { 1758 } else {
1499 /* resync. Schedule a read for every block at this virt offset */ 1759 /* resync. Schedule a read for every block at this virt offset */
1500 int count = 0; 1760 int count = 0;
1501 r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO);
1502 1761
1503 spin_lock_irq(&conf->resync_lock); 1762 if (!bitmap_start_sync(mddev->bitmap, sector_nr,
1504 conf->nr_pending++; 1763 &sync_blocks, mddev->degraded) &&
1505 spin_unlock_irq(&conf->resync_lock); 1764 !conf->fullsync && !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) {
1765 /* We can skip this block */
1766 *skipped = 1;
1767 return sync_blocks + sectors_skipped;
1768 }
1769 if (sync_blocks < max_sync)
1770 max_sync = sync_blocks;
1771 r10_bio = mempool_alloc(conf->r10buf_pool, GFP_NOIO);
1506 1772
1507 r10_bio->mddev = mddev; 1773 r10_bio->mddev = mddev;
1508 atomic_set(&r10_bio->remaining, 0); 1774 atomic_set(&r10_bio->remaining, 0);
1775 raise_barrier(conf, 0);
1776 conf->next_resync = sector_nr;
1509 1777
1510 r10_bio->master_bio = NULL; 1778 r10_bio->master_bio = NULL;
1511 r10_bio->sector = sector_nr; 1779 r10_bio->sector = sector_nr;
@@ -1558,6 +1826,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1558 } 1826 }
1559 1827
1560 nr_sectors = 0; 1828 nr_sectors = 0;
1829 if (sector_nr + max_sync < max_sector)
1830 max_sector = sector_nr + max_sync;
1561 do { 1831 do {
1562 struct page *page; 1832 struct page *page;
1563 int len = PAGE_SIZE; 1833 int len = PAGE_SIZE;
@@ -1632,11 +1902,11 @@ static int run(mddev_t *mddev)
1632 int nc, fc; 1902 int nc, fc;
1633 sector_t stride, size; 1903 sector_t stride, size;
1634 1904
1635 if (mddev->level != 10) { 1905 if (mddev->chunk_size == 0) {
1636 printk(KERN_ERR "raid10: %s: raid level not set correctly... (%d)\n", 1906 printk(KERN_ERR "md/raid10: non-zero chunk size required.\n");
1637 mdname(mddev), mddev->level); 1907 return -EINVAL;
1638 goto out;
1639 } 1908 }
1909
1640 nc = mddev->layout & 255; 1910 nc = mddev->layout & 255;
1641 fc = (mddev->layout >> 8) & 255; 1911 fc = (mddev->layout >> 8) & 255;
1642 if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks || 1912 if ((nc*fc) <2 || (nc*fc) > mddev->raid_disks ||
@@ -1650,22 +1920,24 @@ static int run(mddev_t *mddev)
1650 * bookkeeping area. [whatever we allocate in run(), 1920 * bookkeeping area. [whatever we allocate in run(),
1651 * should be freed in stop()] 1921 * should be freed in stop()]
1652 */ 1922 */
1653 conf = kmalloc(sizeof(conf_t), GFP_KERNEL); 1923 conf = kzalloc(sizeof(conf_t), GFP_KERNEL);
1654 mddev->private = conf; 1924 mddev->private = conf;
1655 if (!conf) { 1925 if (!conf) {
1656 printk(KERN_ERR "raid10: couldn't allocate memory for %s\n", 1926 printk(KERN_ERR "raid10: couldn't allocate memory for %s\n",
1657 mdname(mddev)); 1927 mdname(mddev));
1658 goto out; 1928 goto out;
1659 } 1929 }
1660 memset(conf, 0, sizeof(*conf)); 1930 conf->mirrors = kzalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1661 conf->mirrors = kmalloc(sizeof(struct mirror_info)*mddev->raid_disks,
1662 GFP_KERNEL); 1931 GFP_KERNEL);
1663 if (!conf->mirrors) { 1932 if (!conf->mirrors) {
1664 printk(KERN_ERR "raid10: couldn't allocate memory for %s\n", 1933 printk(KERN_ERR "raid10: couldn't allocate memory for %s\n",
1665 mdname(mddev)); 1934 mdname(mddev));
1666 goto out_free_conf; 1935 goto out_free_conf;
1667 } 1936 }
1668 memset(conf->mirrors, 0, sizeof(struct mirror_info)*mddev->raid_disks); 1937
1938 conf->tmppage = alloc_page(GFP_KERNEL);
1939 if (!conf->tmppage)
1940 goto out_free_conf;
1669 1941
1670 conf->near_copies = nc; 1942 conf->near_copies = nc;
1671 conf->far_copies = fc; 1943 conf->far_copies = fc;
@@ -1713,8 +1985,7 @@ static int run(mddev_t *mddev)
1713 INIT_LIST_HEAD(&conf->retry_list); 1985 INIT_LIST_HEAD(&conf->retry_list);
1714 1986
1715 spin_lock_init(&conf->resync_lock); 1987 spin_lock_init(&conf->resync_lock);
1716 init_waitqueue_head(&conf->wait_idle); 1988 init_waitqueue_head(&conf->wait_barrier);
1717 init_waitqueue_head(&conf->wait_resume);
1718 1989
1719 /* need to check that every block has at least one working mirror */ 1990 /* need to check that every block has at least one working mirror */
1720 if (!enough(conf)) { 1991 if (!enough(conf)) {
@@ -1763,7 +2034,7 @@ static int run(mddev_t *mddev)
1763 * maybe... 2034 * maybe...
1764 */ 2035 */
1765 { 2036 {
1766 int stripe = conf->raid_disks * mddev->chunk_size / PAGE_CACHE_SIZE; 2037 int stripe = conf->raid_disks * mddev->chunk_size / PAGE_SIZE;
1767 stripe /= conf->near_copies; 2038 stripe /= conf->near_copies;
1768 if (mddev->queue->backing_dev_info.ra_pages < 2* stripe) 2039 if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)
1769 mddev->queue->backing_dev_info.ra_pages = 2* stripe; 2040 mddev->queue->backing_dev_info.ra_pages = 2* stripe;
@@ -1776,6 +2047,7 @@ static int run(mddev_t *mddev)
1776out_free_conf: 2047out_free_conf:
1777 if (conf->r10bio_pool) 2048 if (conf->r10bio_pool)
1778 mempool_destroy(conf->r10bio_pool); 2049 mempool_destroy(conf->r10bio_pool);
2050 safe_put_page(conf->tmppage);
1779 kfree(conf->mirrors); 2051 kfree(conf->mirrors);
1780 kfree(conf); 2052 kfree(conf);
1781 mddev->private = NULL; 2053 mddev->private = NULL;
@@ -1798,10 +2070,31 @@ static int stop(mddev_t *mddev)
1798 return 0; 2070 return 0;
1799} 2071}
1800 2072
2073static void raid10_quiesce(mddev_t *mddev, int state)
2074{
2075 conf_t *conf = mddev_to_conf(mddev);
2076
2077 switch(state) {
2078 case 1:
2079 raise_barrier(conf, 0);
2080 break;
2081 case 0:
2082 lower_barrier(conf);
2083 break;
2084 }
2085 if (mddev->thread) {
2086 if (mddev->bitmap)
2087 mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
2088 else
2089 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
2090 md_wakeup_thread(mddev->thread);
2091 }
2092}
1801 2093
1802static mdk_personality_t raid10_personality = 2094static struct mdk_personality raid10_personality =
1803{ 2095{
1804 .name = "raid10", 2096 .name = "raid10",
2097 .level = 10,
1805 .owner = THIS_MODULE, 2098 .owner = THIS_MODULE,
1806 .make_request = make_request, 2099 .make_request = make_request,
1807 .run = run, 2100 .run = run,
@@ -1812,19 +2105,22 @@ static mdk_personality_t raid10_personality =
1812 .hot_remove_disk= raid10_remove_disk, 2105 .hot_remove_disk= raid10_remove_disk,
1813 .spare_active = raid10_spare_active, 2106 .spare_active = raid10_spare_active,
1814 .sync_request = sync_request, 2107 .sync_request = sync_request,
2108 .quiesce = raid10_quiesce,
1815}; 2109};
1816 2110
1817static int __init raid_init(void) 2111static int __init raid_init(void)
1818{ 2112{
1819 return register_md_personality(RAID10, &raid10_personality); 2113 return register_md_personality(&raid10_personality);
1820} 2114}
1821 2115
1822static void raid_exit(void) 2116static void raid_exit(void)
1823{ 2117{
1824 unregister_md_personality(RAID10); 2118 unregister_md_personality(&raid10_personality);
1825} 2119}
1826 2120
1827module_init(raid_init); 2121module_init(raid_init);
1828module_exit(raid_exit); 2122module_exit(raid_exit);
1829MODULE_LICENSE("GPL"); 2123MODULE_LICENSE("GPL");
1830MODULE_ALIAS("md-personality-9"); /* RAID10 */ 2124MODULE_ALIAS("md-personality-9"); /* RAID10 */
2125MODULE_ALIAS("md-raid10");
2126MODULE_ALIAS("md-level-10");
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 36d5f8ac8265..54f4a9847e38 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -35,12 +35,10 @@
35#define STRIPE_SHIFT (PAGE_SHIFT - 9) 35#define STRIPE_SHIFT (PAGE_SHIFT - 9)
36#define STRIPE_SECTORS (STRIPE_SIZE>>9) 36#define STRIPE_SECTORS (STRIPE_SIZE>>9)
37#define IO_THRESHOLD 1 37#define IO_THRESHOLD 1
38#define HASH_PAGES 1 38#define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head))
39#define HASH_PAGES_ORDER 0
40#define NR_HASH (HASH_PAGES * PAGE_SIZE / sizeof(struct stripe_head *))
41#define HASH_MASK (NR_HASH - 1) 39#define HASH_MASK (NR_HASH - 1)
42 40
43#define stripe_hash(conf, sect) ((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK]) 41#define stripe_hash(conf, sect) (&((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK]))
44 42
45/* bio's attached to a stripe+device for I/O are linked together in bi_sector 43/* bio's attached to a stripe+device for I/O are linked together in bi_sector
46 * order without overlap. There may be several bio's per stripe+device, and 44 * order without overlap. There may be several bio's per stripe+device, and
@@ -98,7 +96,7 @@ static inline void __release_stripe(raid5_conf_t *conf, struct stripe_head *sh)
98 list_add_tail(&sh->lru, &conf->inactive_list); 96 list_add_tail(&sh->lru, &conf->inactive_list);
99 atomic_dec(&conf->active_stripes); 97 atomic_dec(&conf->active_stripes);
100 if (!conf->inactive_blocked || 98 if (!conf->inactive_blocked ||
101 atomic_read(&conf->active_stripes) < (NR_STRIPES*3/4)) 99 atomic_read(&conf->active_stripes) < (conf->max_nr_stripes*3/4))
102 wake_up(&conf->wait_for_stripe); 100 wake_up(&conf->wait_for_stripe);
103 } 101 }
104 } 102 }
@@ -113,29 +111,21 @@ static void release_stripe(struct stripe_head *sh)
113 spin_unlock_irqrestore(&conf->device_lock, flags); 111 spin_unlock_irqrestore(&conf->device_lock, flags);
114} 112}
115 113
116static void remove_hash(struct stripe_head *sh) 114static inline void remove_hash(struct stripe_head *sh)
117{ 115{
118 PRINTK("remove_hash(), stripe %llu\n", (unsigned long long)sh->sector); 116 PRINTK("remove_hash(), stripe %llu\n", (unsigned long long)sh->sector);
119 117
120 if (sh->hash_pprev) { 118 hlist_del_init(&sh->hash);
121 if (sh->hash_next)
122 sh->hash_next->hash_pprev = sh->hash_pprev;
123 *sh->hash_pprev = sh->hash_next;
124 sh->hash_pprev = NULL;
125 }
126} 119}
127 120
128static __inline__ void insert_hash(raid5_conf_t *conf, struct stripe_head *sh) 121static inline void insert_hash(raid5_conf_t *conf, struct stripe_head *sh)
129{ 122{
130 struct stripe_head **shp = &stripe_hash(conf, sh->sector); 123 struct hlist_head *hp = stripe_hash(conf, sh->sector);
131 124
132 PRINTK("insert_hash(), stripe %llu\n", (unsigned long long)sh->sector); 125 PRINTK("insert_hash(), stripe %llu\n", (unsigned long long)sh->sector);
133 126
134 CHECK_DEVLOCK(); 127 CHECK_DEVLOCK();
135 if ((sh->hash_next = *shp) != NULL) 128 hlist_add_head(&sh->hash, hp);
136 (*shp)->hash_pprev = &sh->hash_next;
137 *shp = sh;
138 sh->hash_pprev = shp;
139} 129}
140 130
141 131
@@ -167,7 +157,7 @@ static void shrink_buffers(struct stripe_head *sh, int num)
167 if (!p) 157 if (!p)
168 continue; 158 continue;
169 sh->dev[i].page = NULL; 159 sh->dev[i].page = NULL;
170 page_cache_release(p); 160 put_page(p);
171 } 161 }
172} 162}
173 163
@@ -228,10 +218,11 @@ static inline void init_stripe(struct stripe_head *sh, sector_t sector, int pd_i
228static struct stripe_head *__find_stripe(raid5_conf_t *conf, sector_t sector) 218static struct stripe_head *__find_stripe(raid5_conf_t *conf, sector_t sector)
229{ 219{
230 struct stripe_head *sh; 220 struct stripe_head *sh;
221 struct hlist_node *hn;
231 222
232 CHECK_DEVLOCK(); 223 CHECK_DEVLOCK();
233 PRINTK("__find_stripe, sector %llu\n", (unsigned long long)sector); 224 PRINTK("__find_stripe, sector %llu\n", (unsigned long long)sector);
234 for (sh = stripe_hash(conf, sector); sh; sh = sh->hash_next) 225 hlist_for_each_entry(sh, hn, stripe_hash(conf, sector), hash)
235 if (sh->sector == sector) 226 if (sh->sector == sector)
236 return sh; 227 return sh;
237 PRINTK("__stripe %llu not in cache\n", (unsigned long long)sector); 228 PRINTK("__stripe %llu not in cache\n", (unsigned long long)sector);
@@ -264,7 +255,8 @@ static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector
264 conf->inactive_blocked = 1; 255 conf->inactive_blocked = 1;
265 wait_event_lock_irq(conf->wait_for_stripe, 256 wait_event_lock_irq(conf->wait_for_stripe,
266 !list_empty(&conf->inactive_list) && 257 !list_empty(&conf->inactive_list) &&
267 (atomic_read(&conf->active_stripes) < (NR_STRIPES *3/4) 258 (atomic_read(&conf->active_stripes)
259 < (conf->max_nr_stripes *3/4)
268 || !conf->inactive_blocked), 260 || !conf->inactive_blocked),
269 conf->device_lock, 261 conf->device_lock,
270 unplug_slaves(conf->mddev); 262 unplug_slaves(conf->mddev);
@@ -416,7 +408,7 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done,
416 set_bit(R5_UPTODATE, &sh->dev[i].flags); 408 set_bit(R5_UPTODATE, &sh->dev[i].flags);
417#endif 409#endif
418 if (test_bit(R5_ReadError, &sh->dev[i].flags)) { 410 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
419 printk("R5: read error corrected!!\n"); 411 printk(KERN_INFO "raid5: read error corrected!!\n");
420 clear_bit(R5_ReadError, &sh->dev[i].flags); 412 clear_bit(R5_ReadError, &sh->dev[i].flags);
421 clear_bit(R5_ReWrite, &sh->dev[i].flags); 413 clear_bit(R5_ReWrite, &sh->dev[i].flags);
422 } 414 }
@@ -427,13 +419,14 @@ static int raid5_end_read_request(struct bio * bi, unsigned int bytes_done,
427 clear_bit(R5_UPTODATE, &sh->dev[i].flags); 419 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
428 atomic_inc(&conf->disks[i].rdev->read_errors); 420 atomic_inc(&conf->disks[i].rdev->read_errors);
429 if (conf->mddev->degraded) 421 if (conf->mddev->degraded)
430 printk("R5: read error not correctable.\n"); 422 printk(KERN_WARNING "raid5: read error not correctable.\n");
431 else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) 423 else if (test_bit(R5_ReWrite, &sh->dev[i].flags))
432 /* Oh, no!!! */ 424 /* Oh, no!!! */
433 printk("R5: read error NOT corrected!!\n"); 425 printk(KERN_WARNING "raid5: read error NOT corrected!!\n");
434 else if (atomic_read(&conf->disks[i].rdev->read_errors) 426 else if (atomic_read(&conf->disks[i].rdev->read_errors)
435 > conf->max_nr_stripes) 427 > conf->max_nr_stripes)
436 printk("raid5: Too many read errors, failing device.\n"); 428 printk(KERN_WARNING
429 "raid5: Too many read errors, failing device.\n");
437 else 430 else
438 retry = 1; 431 retry = 1;
439 if (retry) 432 if (retry)
@@ -603,7 +596,7 @@ static sector_t raid5_compute_sector(sector_t r_sector, unsigned int raid_disks,
603 *dd_idx = (*pd_idx + 1 + *dd_idx) % raid_disks; 596 *dd_idx = (*pd_idx + 1 + *dd_idx) % raid_disks;
604 break; 597 break;
605 default: 598 default:
606 printk("raid5: unsupported algorithm %d\n", 599 printk(KERN_ERR "raid5: unsupported algorithm %d\n",
607 conf->algorithm); 600 conf->algorithm);
608 } 601 }
609 602
@@ -644,7 +637,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i)
644 i -= (sh->pd_idx + 1); 637 i -= (sh->pd_idx + 1);
645 break; 638 break;
646 default: 639 default:
647 printk("raid5: unsupported algorithm %d\n", 640 printk(KERN_ERR "raid5: unsupported algorithm %d\n",
648 conf->algorithm); 641 conf->algorithm);
649 } 642 }
650 643
@@ -653,7 +646,7 @@ static sector_t compute_blocknr(struct stripe_head *sh, int i)
653 646
654 check = raid5_compute_sector (r_sector, raid_disks, data_disks, &dummy1, &dummy2, conf); 647 check = raid5_compute_sector (r_sector, raid_disks, data_disks, &dummy1, &dummy2, conf);
655 if (check != sh->sector || dummy1 != dd_idx || dummy2 != sh->pd_idx) { 648 if (check != sh->sector || dummy1 != dd_idx || dummy2 != sh->pd_idx) {
656 printk("compute_blocknr: map not correct\n"); 649 printk(KERN_ERR "compute_blocknr: map not correct\n");
657 return 0; 650 return 0;
658 } 651 }
659 return r_sector; 652 return r_sector;
@@ -736,7 +729,7 @@ static void compute_block(struct stripe_head *sh, int dd_idx)
736 if (test_bit(R5_UPTODATE, &sh->dev[i].flags)) 729 if (test_bit(R5_UPTODATE, &sh->dev[i].flags))
737 ptr[count++] = p; 730 ptr[count++] = p;
738 else 731 else
739 printk("compute_block() %d, stripe %llu, %d" 732 printk(KERN_ERR "compute_block() %d, stripe %llu, %d"
740 " not present\n", dd_idx, 733 " not present\n", dd_idx,
741 (unsigned long long)sh->sector, i); 734 (unsigned long long)sh->sector, i);
742 735
@@ -959,11 +952,11 @@ static void handle_stripe(struct stripe_head *sh)
959 syncing = test_bit(STRIPE_SYNCING, &sh->state); 952 syncing = test_bit(STRIPE_SYNCING, &sh->state);
960 /* Now to look around and see what can be done */ 953 /* Now to look around and see what can be done */
961 954
955 rcu_read_lock();
962 for (i=disks; i--; ) { 956 for (i=disks; i--; ) {
963 mdk_rdev_t *rdev; 957 mdk_rdev_t *rdev;
964 dev = &sh->dev[i]; 958 dev = &sh->dev[i];
965 clear_bit(R5_Insync, &dev->flags); 959 clear_bit(R5_Insync, &dev->flags);
966 clear_bit(R5_Syncio, &dev->flags);
967 960
968 PRINTK("check %d: state 0x%lx read %p write %p written %p\n", 961 PRINTK("check %d: state 0x%lx read %p write %p written %p\n",
969 i, dev->flags, dev->toread, dev->towrite, dev->written); 962 i, dev->flags, dev->toread, dev->towrite, dev->written);
@@ -1002,9 +995,9 @@ static void handle_stripe(struct stripe_head *sh)
1002 non_overwrite++; 995 non_overwrite++;
1003 } 996 }
1004 if (dev->written) written++; 997 if (dev->written) written++;
1005 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ 998 rdev = rcu_dereference(conf->disks[i].rdev);
1006 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 999 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
1007 /* The ReadError flag wil just be confusing now */ 1000 /* The ReadError flag will just be confusing now */
1008 clear_bit(R5_ReadError, &dev->flags); 1001 clear_bit(R5_ReadError, &dev->flags);
1009 clear_bit(R5_ReWrite, &dev->flags); 1002 clear_bit(R5_ReWrite, &dev->flags);
1010 } 1003 }
@@ -1015,6 +1008,7 @@ static void handle_stripe(struct stripe_head *sh)
1015 } else 1008 } else
1016 set_bit(R5_Insync, &dev->flags); 1009 set_bit(R5_Insync, &dev->flags);
1017 } 1010 }
1011 rcu_read_unlock();
1018 PRINTK("locked=%d uptodate=%d to_read=%d" 1012 PRINTK("locked=%d uptodate=%d to_read=%d"
1019 " to_write=%d failed=%d failed_num=%d\n", 1013 " to_write=%d failed=%d failed_num=%d\n",
1020 locked, uptodate, to_read, to_write, failed, failed_num); 1014 locked, uptodate, to_read, to_write, failed, failed_num);
@@ -1026,10 +1020,13 @@ static void handle_stripe(struct stripe_head *sh)
1026 int bitmap_end = 0; 1020 int bitmap_end = 0;
1027 1021
1028 if (test_bit(R5_ReadError, &sh->dev[i].flags)) { 1022 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
1029 mdk_rdev_t *rdev = conf->disks[i].rdev; 1023 mdk_rdev_t *rdev;
1024 rcu_read_lock();
1025 rdev = rcu_dereference(conf->disks[i].rdev);
1030 if (rdev && test_bit(In_sync, &rdev->flags)) 1026 if (rdev && test_bit(In_sync, &rdev->flags))
1031 /* multiple read failures in one stripe */ 1027 /* multiple read failures in one stripe */
1032 md_error(conf->mddev, rdev); 1028 md_error(conf->mddev, rdev);
1029 rcu_read_unlock();
1033 } 1030 }
1034 1031
1035 spin_lock_irq(&conf->device_lock); 1032 spin_lock_irq(&conf->device_lock);
@@ -1178,9 +1175,6 @@ static void handle_stripe(struct stripe_head *sh)
1178 locked++; 1175 locked++;
1179 PRINTK("Reading block %d (sync=%d)\n", 1176 PRINTK("Reading block %d (sync=%d)\n",
1180 i, syncing); 1177 i, syncing);
1181 if (syncing)
1182 md_sync_acct(conf->disks[i].rdev->bdev,
1183 STRIPE_SECTORS);
1184 } 1178 }
1185 } 1179 }
1186 } 1180 }
@@ -1287,7 +1281,7 @@ static void handle_stripe(struct stripe_head *sh)
1287 * is available 1281 * is available
1288 */ 1282 */
1289 if (syncing && locked == 0 && 1283 if (syncing && locked == 0 &&
1290 !test_bit(STRIPE_INSYNC, &sh->state) && failed <= 1) { 1284 !test_bit(STRIPE_INSYNC, &sh->state)) {
1291 set_bit(STRIPE_HANDLE, &sh->state); 1285 set_bit(STRIPE_HANDLE, &sh->state);
1292 if (failed == 0) { 1286 if (failed == 0) {
1293 char *pagea; 1287 char *pagea;
@@ -1305,27 +1299,25 @@ static void handle_stripe(struct stripe_head *sh)
1305 if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) 1299 if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery))
1306 /* don't try to repair!! */ 1300 /* don't try to repair!! */
1307 set_bit(STRIPE_INSYNC, &sh->state); 1301 set_bit(STRIPE_INSYNC, &sh->state);
1302 else {
1303 compute_block(sh, sh->pd_idx);
1304 uptodate++;
1305 }
1308 } 1306 }
1309 } 1307 }
1310 if (!test_bit(STRIPE_INSYNC, &sh->state)) { 1308 if (!test_bit(STRIPE_INSYNC, &sh->state)) {
1309 /* either failed parity check, or recovery is happening */
1311 if (failed==0) 1310 if (failed==0)
1312 failed_num = sh->pd_idx; 1311 failed_num = sh->pd_idx;
1313 /* should be able to compute the missing block and write it to spare */
1314 if (!test_bit(R5_UPTODATE, &sh->dev[failed_num].flags)) {
1315 if (uptodate+1 != disks)
1316 BUG();
1317 compute_block(sh, failed_num);
1318 uptodate++;
1319 }
1320 if (uptodate != disks)
1321 BUG();
1322 dev = &sh->dev[failed_num]; 1312 dev = &sh->dev[failed_num];
1313 BUG_ON(!test_bit(R5_UPTODATE, &dev->flags));
1314 BUG_ON(uptodate != disks);
1315
1323 set_bit(R5_LOCKED, &dev->flags); 1316 set_bit(R5_LOCKED, &dev->flags);
1324 set_bit(R5_Wantwrite, &dev->flags); 1317 set_bit(R5_Wantwrite, &dev->flags);
1325 clear_bit(STRIPE_DEGRADED, &sh->state); 1318 clear_bit(STRIPE_DEGRADED, &sh->state);
1326 locked++; 1319 locked++;
1327 set_bit(STRIPE_INSYNC, &sh->state); 1320 set_bit(STRIPE_INSYNC, &sh->state);
1328 set_bit(R5_Syncio, &dev->flags);
1329 } 1321 }
1330 } 1322 }
1331 if (syncing && locked == 0 && test_bit(STRIPE_INSYNC, &sh->state)) { 1323 if (syncing && locked == 0 && test_bit(STRIPE_INSYNC, &sh->state)) {
@@ -1391,7 +1383,7 @@ static void handle_stripe(struct stripe_head *sh)
1391 rcu_read_unlock(); 1383 rcu_read_unlock();
1392 1384
1393 if (rdev) { 1385 if (rdev) {
1394 if (test_bit(R5_Syncio, &sh->dev[i].flags)) 1386 if (syncing)
1395 md_sync_acct(rdev->bdev, STRIPE_SECTORS); 1387 md_sync_acct(rdev->bdev, STRIPE_SECTORS);
1396 1388
1397 bi->bi_bdev = rdev->bdev; 1389 bi->bi_bdev = rdev->bdev;
@@ -1408,6 +1400,9 @@ static void handle_stripe(struct stripe_head *sh)
1408 bi->bi_io_vec[0].bv_offset = 0; 1400 bi->bi_io_vec[0].bv_offset = 0;
1409 bi->bi_size = STRIPE_SIZE; 1401 bi->bi_size = STRIPE_SIZE;
1410 bi->bi_next = NULL; 1402 bi->bi_next = NULL;
1403 if (rw == WRITE &&
1404 test_bit(R5_ReWrite, &sh->dev[i].flags))
1405 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
1411 generic_make_request(bi); 1406 generic_make_request(bi);
1412 } else { 1407 } else {
1413 if (rw == 1) 1408 if (rw == 1)
@@ -1821,21 +1816,21 @@ static int run(mddev_t *mddev)
1821 struct list_head *tmp; 1816 struct list_head *tmp;
1822 1817
1823 if (mddev->level != 5 && mddev->level != 4) { 1818 if (mddev->level != 5 && mddev->level != 4) {
1824 printk("raid5: %s: raid level not set to 4/5 (%d)\n", mdname(mddev), mddev->level); 1819 printk(KERN_ERR "raid5: %s: raid level not set to 4/5 (%d)\n",
1820 mdname(mddev), mddev->level);
1825 return -EIO; 1821 return -EIO;
1826 } 1822 }
1827 1823
1828 mddev->private = kmalloc (sizeof (raid5_conf_t) 1824 mddev->private = kzalloc(sizeof (raid5_conf_t)
1829 + mddev->raid_disks * sizeof(struct disk_info), 1825 + mddev->raid_disks * sizeof(struct disk_info),
1830 GFP_KERNEL); 1826 GFP_KERNEL);
1831 if ((conf = mddev->private) == NULL) 1827 if ((conf = mddev->private) == NULL)
1832 goto abort; 1828 goto abort;
1833 memset (conf, 0, sizeof (*conf) + mddev->raid_disks * sizeof(struct disk_info) ); 1829
1834 conf->mddev = mddev; 1830 conf->mddev = mddev;
1835 1831
1836 if ((conf->stripe_hashtbl = (struct stripe_head **) __get_free_pages(GFP_ATOMIC, HASH_PAGES_ORDER)) == NULL) 1832 if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL)
1837 goto abort; 1833 goto abort;
1838 memset(conf->stripe_hashtbl, 0, HASH_PAGES * PAGE_SIZE);
1839 1834
1840 spin_lock_init(&conf->device_lock); 1835 spin_lock_init(&conf->device_lock);
1841 init_waitqueue_head(&conf->wait_for_stripe); 1836 init_waitqueue_head(&conf->wait_for_stripe);
@@ -1902,10 +1897,17 @@ static int run(mddev_t *mddev)
1902 1897
1903 if (mddev->degraded == 1 && 1898 if (mddev->degraded == 1 &&
1904 mddev->recovery_cp != MaxSector) { 1899 mddev->recovery_cp != MaxSector) {
1905 printk(KERN_ERR 1900 if (mddev->ok_start_degraded)
1906 "raid5: cannot start dirty degraded array for %s\n", 1901 printk(KERN_WARNING
1907 mdname(mddev)); 1902 "raid5: starting dirty degraded array: %s"
1908 goto abort; 1903 "- data corruption possible.\n",
1904 mdname(mddev));
1905 else {
1906 printk(KERN_ERR
1907 "raid5: cannot start dirty degraded array for %s\n",
1908 mdname(mddev));
1909 goto abort;
1910 }
1909 } 1911 }
1910 1912
1911 { 1913 {
@@ -1917,7 +1919,7 @@ static int run(mddev_t *mddev)
1917 goto abort; 1919 goto abort;
1918 } 1920 }
1919 } 1921 }
1920memory = conf->max_nr_stripes * (sizeof(struct stripe_head) + 1922 memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
1921 conf->raid_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024; 1923 conf->raid_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024;
1922 if (grow_stripes(conf, conf->max_nr_stripes)) { 1924 if (grow_stripes(conf, conf->max_nr_stripes)) {
1923 printk(KERN_ERR 1925 printk(KERN_ERR
@@ -1947,7 +1949,7 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
1947 */ 1949 */
1948 { 1950 {
1949 int stripe = (mddev->raid_disks-1) * mddev->chunk_size 1951 int stripe = (mddev->raid_disks-1) * mddev->chunk_size
1950 / PAGE_CACHE_SIZE; 1952 / PAGE_SIZE;
1951 if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe) 1953 if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
1952 mddev->queue->backing_dev_info.ra_pages = 2 * stripe; 1954 mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
1953 } 1955 }
@@ -1955,9 +1957,6 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
1955 /* Ok, everything is just fine now */ 1957 /* Ok, everything is just fine now */
1956 sysfs_create_group(&mddev->kobj, &raid5_attrs_group); 1958 sysfs_create_group(&mddev->kobj, &raid5_attrs_group);
1957 1959
1958 if (mddev->bitmap)
1959 mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1960
1961 mddev->queue->unplug_fn = raid5_unplug_device; 1960 mddev->queue->unplug_fn = raid5_unplug_device;
1962 mddev->queue->issue_flush_fn = raid5_issue_flush; 1961 mddev->queue->issue_flush_fn = raid5_issue_flush;
1963 1962
@@ -1966,9 +1965,7 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
1966abort: 1965abort:
1967 if (conf) { 1966 if (conf) {
1968 print_raid5_conf(conf); 1967 print_raid5_conf(conf);
1969 if (conf->stripe_hashtbl) 1968 kfree(conf->stripe_hashtbl);
1970 free_pages((unsigned long) conf->stripe_hashtbl,
1971 HASH_PAGES_ORDER);
1972 kfree(conf); 1969 kfree(conf);
1973 } 1970 }
1974 mddev->private = NULL; 1971 mddev->private = NULL;
@@ -1985,7 +1982,7 @@ static int stop(mddev_t *mddev)
1985 md_unregister_thread(mddev->thread); 1982 md_unregister_thread(mddev->thread);
1986 mddev->thread = NULL; 1983 mddev->thread = NULL;
1987 shrink_stripes(conf); 1984 shrink_stripes(conf);
1988 free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); 1985 kfree(conf->stripe_hashtbl);
1989 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 1986 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
1990 sysfs_remove_group(&mddev->kobj, &raid5_attrs_group); 1987 sysfs_remove_group(&mddev->kobj, &raid5_attrs_group);
1991 kfree(conf); 1988 kfree(conf);
@@ -2013,12 +2010,12 @@ static void print_sh (struct stripe_head *sh)
2013static void printall (raid5_conf_t *conf) 2010static void printall (raid5_conf_t *conf)
2014{ 2011{
2015 struct stripe_head *sh; 2012 struct stripe_head *sh;
2013 struct hlist_node *hn;
2016 int i; 2014 int i;
2017 2015
2018 spin_lock_irq(&conf->device_lock); 2016 spin_lock_irq(&conf->device_lock);
2019 for (i = 0; i < NR_HASH; i++) { 2017 for (i = 0; i < NR_HASH; i++) {
2020 sh = conf->stripe_hashtbl[i]; 2018 hlist_for_each_entry(sh, hn, &conf->stripe_hashtbl[i], hash) {
2021 for (; sh; sh = sh->hash_next) {
2022 if (sh->raid_conf != conf) 2019 if (sh->raid_conf != conf)
2023 continue; 2020 continue;
2024 print_sh(sh); 2021 print_sh(sh);
@@ -2191,17 +2188,12 @@ static void raid5_quiesce(mddev_t *mddev, int state)
2191 spin_unlock_irq(&conf->device_lock); 2188 spin_unlock_irq(&conf->device_lock);
2192 break; 2189 break;
2193 } 2190 }
2194 if (mddev->thread) {
2195 if (mddev->bitmap)
2196 mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
2197 else
2198 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
2199 md_wakeup_thread(mddev->thread);
2200 }
2201} 2191}
2202static mdk_personality_t raid5_personality= 2192
2193static struct mdk_personality raid5_personality =
2203{ 2194{
2204 .name = "raid5", 2195 .name = "raid5",
2196 .level = 5,
2205 .owner = THIS_MODULE, 2197 .owner = THIS_MODULE,
2206 .make_request = make_request, 2198 .make_request = make_request,
2207 .run = run, 2199 .run = run,
@@ -2216,17 +2208,42 @@ static mdk_personality_t raid5_personality=
2216 .quiesce = raid5_quiesce, 2208 .quiesce = raid5_quiesce,
2217}; 2209};
2218 2210
2219static int __init raid5_init (void) 2211static struct mdk_personality raid4_personality =
2220{ 2212{
2221 return register_md_personality (RAID5, &raid5_personality); 2213 .name = "raid4",
2214 .level = 4,
2215 .owner = THIS_MODULE,
2216 .make_request = make_request,
2217 .run = run,
2218 .stop = stop,
2219 .status = status,
2220 .error_handler = error,
2221 .hot_add_disk = raid5_add_disk,
2222 .hot_remove_disk= raid5_remove_disk,
2223 .spare_active = raid5_spare_active,
2224 .sync_request = sync_request,
2225 .resize = raid5_resize,
2226 .quiesce = raid5_quiesce,
2227};
2228
2229static int __init raid5_init(void)
2230{
2231 register_md_personality(&raid5_personality);
2232 register_md_personality(&raid4_personality);
2233 return 0;
2222} 2234}
2223 2235
2224static void raid5_exit (void) 2236static void raid5_exit(void)
2225{ 2237{
2226 unregister_md_personality (RAID5); 2238 unregister_md_personality(&raid5_personality);
2239 unregister_md_personality(&raid4_personality);
2227} 2240}
2228 2241
2229module_init(raid5_init); 2242module_init(raid5_init);
2230module_exit(raid5_exit); 2243module_exit(raid5_exit);
2231MODULE_LICENSE("GPL"); 2244MODULE_LICENSE("GPL");
2232MODULE_ALIAS("md-personality-4"); /* RAID5 */ 2245MODULE_ALIAS("md-personality-4"); /* RAID5 */
2246MODULE_ALIAS("md-raid5");
2247MODULE_ALIAS("md-raid4");
2248MODULE_ALIAS("md-level-5");
2249MODULE_ALIAS("md-level-4");
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index 0000d162d198..8c823d686a60 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -40,12 +40,10 @@
40#define STRIPE_SHIFT (PAGE_SHIFT - 9) 40#define STRIPE_SHIFT (PAGE_SHIFT - 9)
41#define STRIPE_SECTORS (STRIPE_SIZE>>9) 41#define STRIPE_SECTORS (STRIPE_SIZE>>9)
42#define IO_THRESHOLD 1 42#define IO_THRESHOLD 1
43#define HASH_PAGES 1 43#define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head))
44#define HASH_PAGES_ORDER 0
45#define NR_HASH (HASH_PAGES * PAGE_SIZE / sizeof(struct stripe_head *))
46#define HASH_MASK (NR_HASH - 1) 44#define HASH_MASK (NR_HASH - 1)
47 45
48#define stripe_hash(conf, sect) ((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK]) 46#define stripe_hash(conf, sect) (&((conf)->stripe_hashtbl[((sect) >> STRIPE_SHIFT) & HASH_MASK]))
49 47
50/* bio's attached to a stripe+device for I/O are linked together in bi_sector 48/* bio's attached to a stripe+device for I/O are linked together in bi_sector
51 * order without overlap. There may be several bio's per stripe+device, and 49 * order without overlap. There may be several bio's per stripe+device, and
@@ -132,29 +130,21 @@ static void release_stripe(struct stripe_head *sh)
132 spin_unlock_irqrestore(&conf->device_lock, flags); 130 spin_unlock_irqrestore(&conf->device_lock, flags);
133} 131}
134 132
135static void remove_hash(struct stripe_head *sh) 133static inline void remove_hash(struct stripe_head *sh)
136{ 134{
137 PRINTK("remove_hash(), stripe %llu\n", (unsigned long long)sh->sector); 135 PRINTK("remove_hash(), stripe %llu\n", (unsigned long long)sh->sector);
138 136
139 if (sh->hash_pprev) { 137 hlist_del_init(&sh->hash);
140 if (sh->hash_next)
141 sh->hash_next->hash_pprev = sh->hash_pprev;
142 *sh->hash_pprev = sh->hash_next;
143 sh->hash_pprev = NULL;
144 }
145} 138}
146 139
147static __inline__ void insert_hash(raid6_conf_t *conf, struct stripe_head *sh) 140static inline void insert_hash(raid6_conf_t *conf, struct stripe_head *sh)
148{ 141{
149 struct stripe_head **shp = &stripe_hash(conf, sh->sector); 142 struct hlist_head *hp = stripe_hash(conf, sh->sector);
150 143
151 PRINTK("insert_hash(), stripe %llu\n", (unsigned long long)sh->sector); 144 PRINTK("insert_hash(), stripe %llu\n", (unsigned long long)sh->sector);
152 145
153 CHECK_DEVLOCK(); 146 CHECK_DEVLOCK();
154 if ((sh->hash_next = *shp) != NULL) 147 hlist_add_head(&sh->hash, hp);
155 (*shp)->hash_pprev = &sh->hash_next;
156 *shp = sh;
157 sh->hash_pprev = shp;
158} 148}
159 149
160 150
@@ -186,7 +176,7 @@ static void shrink_buffers(struct stripe_head *sh, int num)
186 if (!p) 176 if (!p)
187 continue; 177 continue;
188 sh->dev[i].page = NULL; 178 sh->dev[i].page = NULL;
189 page_cache_release(p); 179 put_page(p);
190 } 180 }
191} 181}
192 182
@@ -247,10 +237,11 @@ static inline void init_stripe(struct stripe_head *sh, sector_t sector, int pd_i
247static struct stripe_head *__find_stripe(raid6_conf_t *conf, sector_t sector) 237static struct stripe_head *__find_stripe(raid6_conf_t *conf, sector_t sector)
248{ 238{
249 struct stripe_head *sh; 239 struct stripe_head *sh;
240 struct hlist_node *hn;
250 241
251 CHECK_DEVLOCK(); 242 CHECK_DEVLOCK();
252 PRINTK("__find_stripe, sector %llu\n", (unsigned long long)sector); 243 PRINTK("__find_stripe, sector %llu\n", (unsigned long long)sector);
253 for (sh = stripe_hash(conf, sector); sh; sh = sh->hash_next) 244 hlist_for_each_entry (sh, hn, stripe_hash(conf, sector), hash)
254 if (sh->sector == sector) 245 if (sh->sector == sector)
255 return sh; 246 return sh;
256 PRINTK("__stripe %llu not in cache\n", (unsigned long long)sector); 247 PRINTK("__stripe %llu not in cache\n", (unsigned long long)sector);
@@ -367,8 +358,8 @@ static void shrink_stripes(raid6_conf_t *conf)
367 conf->slab_cache = NULL; 358 conf->slab_cache = NULL;
368} 359}
369 360
370static int raid6_end_read_request (struct bio * bi, unsigned int bytes_done, 361static int raid6_end_read_request(struct bio * bi, unsigned int bytes_done,
371 int error) 362 int error)
372{ 363{
373 struct stripe_head *sh = bi->bi_private; 364 struct stripe_head *sh = bi->bi_private;
374 raid6_conf_t *conf = sh->raid_conf; 365 raid6_conf_t *conf = sh->raid_conf;
@@ -420,9 +411,35 @@ static int raid6_end_read_request (struct bio * bi, unsigned int bytes_done,
420#else 411#else
421 set_bit(R5_UPTODATE, &sh->dev[i].flags); 412 set_bit(R5_UPTODATE, &sh->dev[i].flags);
422#endif 413#endif
414 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
415 printk(KERN_INFO "raid6: read error corrected!!\n");
416 clear_bit(R5_ReadError, &sh->dev[i].flags);
417 clear_bit(R5_ReWrite, &sh->dev[i].flags);
418 }
419 if (atomic_read(&conf->disks[i].rdev->read_errors))
420 atomic_set(&conf->disks[i].rdev->read_errors, 0);
423 } else { 421 } else {
424 md_error(conf->mddev, conf->disks[i].rdev); 422 int retry = 0;
425 clear_bit(R5_UPTODATE, &sh->dev[i].flags); 423 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
424 atomic_inc(&conf->disks[i].rdev->read_errors);
425 if (conf->mddev->degraded)
426 printk(KERN_WARNING "raid6: read error not correctable.\n");
427 else if (test_bit(R5_ReWrite, &sh->dev[i].flags))
428 /* Oh, no!!! */
429 printk(KERN_WARNING "raid6: read error NOT corrected!!\n");
430 else if (atomic_read(&conf->disks[i].rdev->read_errors)
431 > conf->max_nr_stripes)
432 printk(KERN_WARNING
433 "raid6: Too many read errors, failing device.\n");
434 else
435 retry = 1;
436 if (retry)
437 set_bit(R5_ReadError, &sh->dev[i].flags);
438 else {
439 clear_bit(R5_ReadError, &sh->dev[i].flags);
440 clear_bit(R5_ReWrite, &sh->dev[i].flags);
441 md_error(conf->mddev, conf->disks[i].rdev);
442 }
426 } 443 }
427 rdev_dec_pending(conf->disks[i].rdev, conf->mddev); 444 rdev_dec_pending(conf->disks[i].rdev, conf->mddev);
428#if 0 445#if 0
@@ -805,7 +822,7 @@ static void compute_parity(struct stripe_head *sh, int method)
805} 822}
806 823
807/* Compute one missing block */ 824/* Compute one missing block */
808static void compute_block_1(struct stripe_head *sh, int dd_idx) 825static void compute_block_1(struct stripe_head *sh, int dd_idx, int nozero)
809{ 826{
810 raid6_conf_t *conf = sh->raid_conf; 827 raid6_conf_t *conf = sh->raid_conf;
811 int i, count, disks = conf->raid_disks; 828 int i, count, disks = conf->raid_disks;
@@ -821,7 +838,7 @@ static void compute_block_1(struct stripe_head *sh, int dd_idx)
821 compute_parity(sh, UPDATE_PARITY); 838 compute_parity(sh, UPDATE_PARITY);
822 } else { 839 } else {
823 ptr[0] = page_address(sh->dev[dd_idx].page); 840 ptr[0] = page_address(sh->dev[dd_idx].page);
824 memset(ptr[0], 0, STRIPE_SIZE); 841 if (!nozero) memset(ptr[0], 0, STRIPE_SIZE);
825 count = 1; 842 count = 1;
826 for (i = disks ; i--; ) { 843 for (i = disks ; i--; ) {
827 if (i == dd_idx || i == qd_idx) 844 if (i == dd_idx || i == qd_idx)
@@ -838,7 +855,8 @@ static void compute_block_1(struct stripe_head *sh, int dd_idx)
838 } 855 }
839 if (count != 1) 856 if (count != 1)
840 xor_block(count, STRIPE_SIZE, ptr); 857 xor_block(count, STRIPE_SIZE, ptr);
841 set_bit(R5_UPTODATE, &sh->dev[dd_idx].flags); 858 if (!nozero) set_bit(R5_UPTODATE, &sh->dev[dd_idx].flags);
859 else clear_bit(R5_UPTODATE, &sh->dev[dd_idx].flags);
842 } 860 }
843} 861}
844 862
@@ -871,7 +889,7 @@ static void compute_block_2(struct stripe_head *sh, int dd_idx1, int dd_idx2)
871 return; 889 return;
872 } else { 890 } else {
873 /* We're missing D+Q; recompute D from P */ 891 /* We're missing D+Q; recompute D from P */
874 compute_block_1(sh, (dd_idx1 == qd_idx) ? dd_idx2 : dd_idx1); 892 compute_block_1(sh, (dd_idx1 == qd_idx) ? dd_idx2 : dd_idx1, 0);
875 compute_parity(sh, UPDATE_PARITY); /* Is this necessary? */ 893 compute_parity(sh, UPDATE_PARITY); /* Is this necessary? */
876 return; 894 return;
877 } 895 }
@@ -982,6 +1000,12 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
982} 1000}
983 1001
984 1002
1003static int page_is_zero(struct page *p)
1004{
1005 char *a = page_address(p);
1006 return ((*(u32*)a) == 0 &&
1007 memcmp(a, a+4, STRIPE_SIZE-4)==0);
1008}
985/* 1009/*
986 * handle_stripe - do things to a stripe. 1010 * handle_stripe - do things to a stripe.
987 * 1011 *
@@ -1000,7 +1024,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in
1000 * 1024 *
1001 */ 1025 */
1002 1026
1003static void handle_stripe(struct stripe_head *sh) 1027static void handle_stripe(struct stripe_head *sh, struct page *tmp_page)
1004{ 1028{
1005 raid6_conf_t *conf = sh->raid_conf; 1029 raid6_conf_t *conf = sh->raid_conf;
1006 int disks = conf->raid_disks; 1030 int disks = conf->raid_disks;
@@ -1027,11 +1051,11 @@ static void handle_stripe(struct stripe_head *sh)
1027 syncing = test_bit(STRIPE_SYNCING, &sh->state); 1051 syncing = test_bit(STRIPE_SYNCING, &sh->state);
1028 /* Now to look around and see what can be done */ 1052 /* Now to look around and see what can be done */
1029 1053
1054 rcu_read_lock();
1030 for (i=disks; i--; ) { 1055 for (i=disks; i--; ) {
1031 mdk_rdev_t *rdev; 1056 mdk_rdev_t *rdev;
1032 dev = &sh->dev[i]; 1057 dev = &sh->dev[i];
1033 clear_bit(R5_Insync, &dev->flags); 1058 clear_bit(R5_Insync, &dev->flags);
1034 clear_bit(R5_Syncio, &dev->flags);
1035 1059
1036 PRINTK("check %d: state 0x%lx read %p write %p written %p\n", 1060 PRINTK("check %d: state 0x%lx read %p write %p written %p\n",
1037 i, dev->flags, dev->toread, dev->towrite, dev->written); 1061 i, dev->flags, dev->toread, dev->towrite, dev->written);
@@ -1070,14 +1094,21 @@ static void handle_stripe(struct stripe_head *sh)
1070 non_overwrite++; 1094 non_overwrite++;
1071 } 1095 }
1072 if (dev->written) written++; 1096 if (dev->written) written++;
1073 rdev = conf->disks[i].rdev; /* FIXME, should I be looking rdev */ 1097 rdev = rcu_dereference(conf->disks[i].rdev);
1074 if (!rdev || !test_bit(In_sync, &rdev->flags)) { 1098 if (!rdev || !test_bit(In_sync, &rdev->flags)) {
1099 /* The ReadError flag will just be confusing now */
1100 clear_bit(R5_ReadError, &dev->flags);
1101 clear_bit(R5_ReWrite, &dev->flags);
1102 }
1103 if (!rdev || !test_bit(In_sync, &rdev->flags)
1104 || test_bit(R5_ReadError, &dev->flags)) {
1075 if ( failed < 2 ) 1105 if ( failed < 2 )
1076 failed_num[failed] = i; 1106 failed_num[failed] = i;
1077 failed++; 1107 failed++;
1078 } else 1108 } else
1079 set_bit(R5_Insync, &dev->flags); 1109 set_bit(R5_Insync, &dev->flags);
1080 } 1110 }
1111 rcu_read_unlock();
1081 PRINTK("locked=%d uptodate=%d to_read=%d" 1112 PRINTK("locked=%d uptodate=%d to_read=%d"
1082 " to_write=%d failed=%d failed_num=%d,%d\n", 1113 " to_write=%d failed=%d failed_num=%d,%d\n",
1083 locked, uptodate, to_read, to_write, failed, 1114 locked, uptodate, to_read, to_write, failed,
@@ -1088,6 +1119,17 @@ static void handle_stripe(struct stripe_head *sh)
1088 if (failed > 2 && to_read+to_write+written) { 1119 if (failed > 2 && to_read+to_write+written) {
1089 for (i=disks; i--; ) { 1120 for (i=disks; i--; ) {
1090 int bitmap_end = 0; 1121 int bitmap_end = 0;
1122
1123 if (test_bit(R5_ReadError, &sh->dev[i].flags)) {
1124 mdk_rdev_t *rdev;
1125 rcu_read_lock();
1126 rdev = rcu_dereference(conf->disks[i].rdev);
1127 if (rdev && test_bit(In_sync, &rdev->flags))
1128 /* multiple read failures in one stripe */
1129 md_error(conf->mddev, rdev);
1130 rcu_read_unlock();
1131 }
1132
1091 spin_lock_irq(&conf->device_lock); 1133 spin_lock_irq(&conf->device_lock);
1092 /* fail all writes first */ 1134 /* fail all writes first */
1093 bi = sh->dev[i].towrite; 1135 bi = sh->dev[i].towrite;
@@ -1123,7 +1165,8 @@ static void handle_stripe(struct stripe_head *sh)
1123 } 1165 }
1124 1166
1125 /* fail any reads if this device is non-operational */ 1167 /* fail any reads if this device is non-operational */
1126 if (!test_bit(R5_Insync, &sh->dev[i].flags)) { 1168 if (!test_bit(R5_Insync, &sh->dev[i].flags) ||
1169 test_bit(R5_ReadError, &sh->dev[i].flags)) {
1127 bi = sh->dev[i].toread; 1170 bi = sh->dev[i].toread;
1128 sh->dev[i].toread = NULL; 1171 sh->dev[i].toread = NULL;
1129 if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) 1172 if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags))
@@ -1228,7 +1271,7 @@ static void handle_stripe(struct stripe_head *sh)
1228 if (uptodate == disks-1) { 1271 if (uptodate == disks-1) {
1229 PRINTK("Computing stripe %llu block %d\n", 1272 PRINTK("Computing stripe %llu block %d\n",
1230 (unsigned long long)sh->sector, i); 1273 (unsigned long long)sh->sector, i);
1231 compute_block_1(sh, i); 1274 compute_block_1(sh, i, 0);
1232 uptodate++; 1275 uptodate++;
1233 } else if ( uptodate == disks-2 && failed >= 2 ) { 1276 } else if ( uptodate == disks-2 && failed >= 2 ) {
1234 /* Computing 2-failure is *very* expensive; only do it if failed >= 2 */ 1277 /* Computing 2-failure is *very* expensive; only do it if failed >= 2 */
@@ -1259,9 +1302,6 @@ static void handle_stripe(struct stripe_head *sh)
1259 locked++; 1302 locked++;
1260 PRINTK("Reading block %d (sync=%d)\n", 1303 PRINTK("Reading block %d (sync=%d)\n",
1261 i, syncing); 1304 i, syncing);
1262 if (syncing)
1263 md_sync_acct(conf->disks[i].rdev->bdev,
1264 STRIPE_SECTORS);
1265 } 1305 }
1266 } 1306 }
1267 } 1307 }
@@ -1323,7 +1363,7 @@ static void handle_stripe(struct stripe_head *sh)
1323 /* We have failed blocks and need to compute them */ 1363 /* We have failed blocks and need to compute them */
1324 switch ( failed ) { 1364 switch ( failed ) {
1325 case 0: BUG(); 1365 case 0: BUG();
1326 case 1: compute_block_1(sh, failed_num[0]); break; 1366 case 1: compute_block_1(sh, failed_num[0], 0); break;
1327 case 2: compute_block_2(sh, failed_num[0], failed_num[1]); break; 1367 case 2: compute_block_2(sh, failed_num[0], failed_num[1]); break;
1328 default: BUG(); /* This request should have been failed? */ 1368 default: BUG(); /* This request should have been failed? */
1329 } 1369 }
@@ -1338,12 +1378,10 @@ static void handle_stripe(struct stripe_head *sh)
1338 (unsigned long long)sh->sector, i); 1378 (unsigned long long)sh->sector, i);
1339 locked++; 1379 locked++;
1340 set_bit(R5_Wantwrite, &sh->dev[i].flags); 1380 set_bit(R5_Wantwrite, &sh->dev[i].flags);
1341#if 0 /**** FIX: I don't understand the logic here... ****/
1342 if (!test_bit(R5_Insync, &sh->dev[i].flags)
1343 || ((i==pd_idx || i==qd_idx) && failed == 0)) /* FIX? */
1344 set_bit(STRIPE_INSYNC, &sh->state);
1345#endif
1346 } 1381 }
1382 /* after a RECONSTRUCT_WRITE, the stripe MUST be in-sync */
1383 set_bit(STRIPE_INSYNC, &sh->state);
1384
1347 if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) { 1385 if (test_and_clear_bit(STRIPE_PREREAD_ACTIVE, &sh->state)) {
1348 atomic_dec(&conf->preread_active_stripes); 1386 atomic_dec(&conf->preread_active_stripes);
1349 if (atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD) 1387 if (atomic_read(&conf->preread_active_stripes) < IO_THRESHOLD)
@@ -1356,84 +1394,119 @@ static void handle_stripe(struct stripe_head *sh)
1356 * Any reads will already have been scheduled, so we just see if enough data 1394 * Any reads will already have been scheduled, so we just see if enough data
1357 * is available 1395 * is available
1358 */ 1396 */
1359 if (syncing && locked == 0 && 1397 if (syncing && locked == 0 && !test_bit(STRIPE_INSYNC, &sh->state)) {
1360 !test_bit(STRIPE_INSYNC, &sh->state) && failed <= 2) { 1398 int update_p = 0, update_q = 0;
1361 set_bit(STRIPE_HANDLE, &sh->state); 1399 struct r5dev *dev;
1362#if 0 /* RAID-6: Don't support CHECK PARITY yet */
1363 if (failed == 0) {
1364 char *pagea;
1365 if (uptodate != disks)
1366 BUG();
1367 compute_parity(sh, CHECK_PARITY);
1368 uptodate--;
1369 pagea = page_address(sh->dev[pd_idx].page);
1370 if ((*(u32*)pagea) == 0 &&
1371 !memcmp(pagea, pagea+4, STRIPE_SIZE-4)) {
1372 /* parity is correct (on disc, not in buffer any more) */
1373 set_bit(STRIPE_INSYNC, &sh->state);
1374 }
1375 }
1376#endif
1377 if (!test_bit(STRIPE_INSYNC, &sh->state)) {
1378 int failed_needupdate[2];
1379 struct r5dev *adev, *bdev;
1380
1381 if ( failed < 1 )
1382 failed_num[0] = pd_idx;
1383 if ( failed < 2 )
1384 failed_num[1] = (failed_num[0] == qd_idx) ? pd_idx : qd_idx;
1385 1400
1386 failed_needupdate[0] = !test_bit(R5_UPTODATE, &sh->dev[failed_num[0]].flags); 1401 set_bit(STRIPE_HANDLE, &sh->state);
1387 failed_needupdate[1] = !test_bit(R5_UPTODATE, &sh->dev[failed_num[1]].flags);
1388 1402
1389 PRINTK("sync: failed=%d num=%d,%d fnu=%u%u\n", 1403 BUG_ON(failed>2);
1390 failed, failed_num[0], failed_num[1], failed_needupdate[0], failed_needupdate[1]); 1404 BUG_ON(uptodate < disks);
1405 /* Want to check and possibly repair P and Q.
1406 * However there could be one 'failed' device, in which
1407 * case we can only check one of them, possibly using the
1408 * other to generate missing data
1409 */
1391 1410
1392#if 0 /* RAID-6: This code seems to require that CHECK_PARITY destroys the uptodateness of the parity */ 1411 /* If !tmp_page, we cannot do the calculations,
1393 /* should be able to compute the missing block(s) and write to spare */ 1412 * but as we have set STRIPE_HANDLE, we will soon be called
1394 if ( failed_needupdate[0] ^ failed_needupdate[1] ) { 1413 * by stripe_handle with a tmp_page - just wait until then.
1395 if (uptodate+1 != disks) 1414 */
1396 BUG(); 1415 if (tmp_page) {
1397 compute_block_1(sh, failed_needupdate[0] ? failed_num[0] : failed_num[1]); 1416 if (failed == q_failed) {
1398 uptodate++; 1417 /* The only possible failed device holds 'Q', so it makes
1399 } else if ( failed_needupdate[0] & failed_needupdate[1] ) { 1418 * sense to check P (If anything else were failed, we would
1400 if (uptodate+2 != disks) 1419 * have used P to recreate it).
1401 BUG(); 1420 */
1402 compute_block_2(sh, failed_num[0], failed_num[1]); 1421 compute_block_1(sh, pd_idx, 1);
1403 uptodate += 2; 1422 if (!page_is_zero(sh->dev[pd_idx].page)) {
1423 compute_block_1(sh,pd_idx,0);
1424 update_p = 1;
1425 }
1426 }
1427 if (!q_failed && failed < 2) {
1428 /* q is not failed, and we didn't use it to generate
1429 * anything, so it makes sense to check it
1430 */
1431 memcpy(page_address(tmp_page),
1432 page_address(sh->dev[qd_idx].page),
1433 STRIPE_SIZE);
1434 compute_parity(sh, UPDATE_PARITY);
1435 if (memcmp(page_address(tmp_page),
1436 page_address(sh->dev[qd_idx].page),
1437 STRIPE_SIZE)!= 0) {
1438 clear_bit(STRIPE_INSYNC, &sh->state);
1439 update_q = 1;
1440 }
1441 }
1442 if (update_p || update_q) {
1443 conf->mddev->resync_mismatches += STRIPE_SECTORS;
1444 if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery))
1445 /* don't try to repair!! */
1446 update_p = update_q = 0;
1404 } 1447 }
1405#else
1406 compute_block_2(sh, failed_num[0], failed_num[1]);
1407 uptodate += failed_needupdate[0] + failed_needupdate[1];
1408#endif
1409 1448
1410 if (uptodate != disks) 1449 /* now write out any block on a failed drive,
1411 BUG(); 1450 * or P or Q if they need it
1451 */
1412 1452
1413 PRINTK("Marking for sync stripe %llu blocks %d,%d\n", 1453 if (failed == 2) {
1414 (unsigned long long)sh->sector, failed_num[0], failed_num[1]); 1454 dev = &sh->dev[failed_num[1]];
1455 locked++;
1456 set_bit(R5_LOCKED, &dev->flags);
1457 set_bit(R5_Wantwrite, &dev->flags);
1458 }
1459 if (failed >= 1) {
1460 dev = &sh->dev[failed_num[0]];
1461 locked++;
1462 set_bit(R5_LOCKED, &dev->flags);
1463 set_bit(R5_Wantwrite, &dev->flags);
1464 }
1415 1465
1416 /**** FIX: Should we really do both of these unconditionally? ****/ 1466 if (update_p) {
1417 adev = &sh->dev[failed_num[0]]; 1467 dev = &sh->dev[pd_idx];
1418 locked += !test_bit(R5_LOCKED, &adev->flags); 1468 locked ++;
1419 set_bit(R5_LOCKED, &adev->flags); 1469 set_bit(R5_LOCKED, &dev->flags);
1420 set_bit(R5_Wantwrite, &adev->flags); 1470 set_bit(R5_Wantwrite, &dev->flags);
1421 bdev = &sh->dev[failed_num[1]]; 1471 }
1422 locked += !test_bit(R5_LOCKED, &bdev->flags); 1472 if (update_q) {
1423 set_bit(R5_LOCKED, &bdev->flags); 1473 dev = &sh->dev[qd_idx];
1474 locked++;
1475 set_bit(R5_LOCKED, &dev->flags);
1476 set_bit(R5_Wantwrite, &dev->flags);
1477 }
1424 clear_bit(STRIPE_DEGRADED, &sh->state); 1478 clear_bit(STRIPE_DEGRADED, &sh->state);
1425 set_bit(R5_Wantwrite, &bdev->flags);
1426 1479
1427 set_bit(STRIPE_INSYNC, &sh->state); 1480 set_bit(STRIPE_INSYNC, &sh->state);
1428 set_bit(R5_Syncio, &adev->flags);
1429 set_bit(R5_Syncio, &bdev->flags);
1430 } 1481 }
1431 } 1482 }
1483
1432 if (syncing && locked == 0 && test_bit(STRIPE_INSYNC, &sh->state)) { 1484 if (syncing && locked == 0 && test_bit(STRIPE_INSYNC, &sh->state)) {
1433 md_done_sync(conf->mddev, STRIPE_SECTORS,1); 1485 md_done_sync(conf->mddev, STRIPE_SECTORS,1);
1434 clear_bit(STRIPE_SYNCING, &sh->state); 1486 clear_bit(STRIPE_SYNCING, &sh->state);
1435 } 1487 }
1436 1488
1489 /* If the failed drives are just a ReadError, then we might need
1490 * to progress the repair/check process
1491 */
1492 if (failed <= 2 && ! conf->mddev->ro)
1493 for (i=0; i<failed;i++) {
1494 dev = &sh->dev[failed_num[i]];
1495 if (test_bit(R5_ReadError, &dev->flags)
1496 && !test_bit(R5_LOCKED, &dev->flags)
1497 && test_bit(R5_UPTODATE, &dev->flags)
1498 ) {
1499 if (!test_bit(R5_ReWrite, &dev->flags)) {
1500 set_bit(R5_Wantwrite, &dev->flags);
1501 set_bit(R5_ReWrite, &dev->flags);
1502 set_bit(R5_LOCKED, &dev->flags);
1503 } else {
1504 /* let's read it back */
1505 set_bit(R5_Wantread, &dev->flags);
1506 set_bit(R5_LOCKED, &dev->flags);
1507 }
1508 }
1509 }
1437 spin_unlock(&sh->lock); 1510 spin_unlock(&sh->lock);
1438 1511
1439 while ((bi=return_bi)) { 1512 while ((bi=return_bi)) {
@@ -1472,7 +1545,7 @@ static void handle_stripe(struct stripe_head *sh)
1472 rcu_read_unlock(); 1545 rcu_read_unlock();
1473 1546
1474 if (rdev) { 1547 if (rdev) {
1475 if (test_bit(R5_Syncio, &sh->dev[i].flags)) 1548 if (syncing)
1476 md_sync_acct(rdev->bdev, STRIPE_SECTORS); 1549 md_sync_acct(rdev->bdev, STRIPE_SECTORS);
1477 1550
1478 bi->bi_bdev = rdev->bdev; 1551 bi->bi_bdev = rdev->bdev;
@@ -1489,6 +1562,9 @@ static void handle_stripe(struct stripe_head *sh)
1489 bi->bi_io_vec[0].bv_offset = 0; 1562 bi->bi_io_vec[0].bv_offset = 0;
1490 bi->bi_size = STRIPE_SIZE; 1563 bi->bi_size = STRIPE_SIZE;
1491 bi->bi_next = NULL; 1564 bi->bi_next = NULL;
1565 if (rw == WRITE &&
1566 test_bit(R5_ReWrite, &sh->dev[i].flags))
1567 atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
1492 generic_make_request(bi); 1568 generic_make_request(bi);
1493 } else { 1569 } else {
1494 if (rw == 1) 1570 if (rw == 1)
@@ -1664,7 +1740,7 @@ static int make_request (request_queue_t *q, struct bio * bi)
1664 } 1740 }
1665 finish_wait(&conf->wait_for_overlap, &w); 1741 finish_wait(&conf->wait_for_overlap, &w);
1666 raid6_plug_device(conf); 1742 raid6_plug_device(conf);
1667 handle_stripe(sh); 1743 handle_stripe(sh, NULL);
1668 release_stripe(sh); 1744 release_stripe(sh);
1669 } else { 1745 } else {
1670 /* cannot get stripe for read-ahead, just give-up */ 1746 /* cannot get stripe for read-ahead, just give-up */
@@ -1728,6 +1804,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1728 return rv; 1804 return rv;
1729 } 1805 }
1730 if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) && 1806 if (!bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) &&
1807 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) &&
1731 !conf->fullsync && sync_blocks >= STRIPE_SECTORS) { 1808 !conf->fullsync && sync_blocks >= STRIPE_SECTORS) {
1732 /* we can skip this block, and probably more */ 1809 /* we can skip this block, and probably more */
1733 sync_blocks /= STRIPE_SECTORS; 1810 sync_blocks /= STRIPE_SECTORS;
@@ -1765,7 +1842,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1765 clear_bit(STRIPE_INSYNC, &sh->state); 1842 clear_bit(STRIPE_INSYNC, &sh->state);
1766 spin_unlock(&sh->lock); 1843 spin_unlock(&sh->lock);
1767 1844
1768 handle_stripe(sh); 1845 handle_stripe(sh, NULL);
1769 release_stripe(sh); 1846 release_stripe(sh);
1770 1847
1771 return STRIPE_SECTORS; 1848 return STRIPE_SECTORS;
@@ -1821,7 +1898,7 @@ static void raid6d (mddev_t *mddev)
1821 spin_unlock_irq(&conf->device_lock); 1898 spin_unlock_irq(&conf->device_lock);
1822 1899
1823 handled++; 1900 handled++;
1824 handle_stripe(sh); 1901 handle_stripe(sh, conf->spare_page);
1825 release_stripe(sh); 1902 release_stripe(sh);
1826 1903
1827 spin_lock_irq(&conf->device_lock); 1904 spin_lock_irq(&conf->device_lock);
@@ -1848,17 +1925,19 @@ static int run(mddev_t *mddev)
1848 return -EIO; 1925 return -EIO;
1849 } 1926 }
1850 1927
1851 mddev->private = kmalloc (sizeof (raid6_conf_t) 1928 mddev->private = kzalloc(sizeof (raid6_conf_t)
1852 + mddev->raid_disks * sizeof(struct disk_info), 1929 + mddev->raid_disks * sizeof(struct disk_info),
1853 GFP_KERNEL); 1930 GFP_KERNEL);
1854 if ((conf = mddev->private) == NULL) 1931 if ((conf = mddev->private) == NULL)
1855 goto abort; 1932 goto abort;
1856 memset (conf, 0, sizeof (*conf) + mddev->raid_disks * sizeof(struct disk_info) );
1857 conf->mddev = mddev; 1933 conf->mddev = mddev;
1858 1934
1859 if ((conf->stripe_hashtbl = (struct stripe_head **) __get_free_pages(GFP_ATOMIC, HASH_PAGES_ORDER)) == NULL) 1935 if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL)
1936 goto abort;
1937
1938 conf->spare_page = alloc_page(GFP_KERNEL);
1939 if (!conf->spare_page)
1860 goto abort; 1940 goto abort;
1861 memset(conf->stripe_hashtbl, 0, HASH_PAGES * PAGE_SIZE);
1862 1941
1863 spin_lock_init(&conf->device_lock); 1942 spin_lock_init(&conf->device_lock);
1864 init_waitqueue_head(&conf->wait_for_stripe); 1943 init_waitqueue_head(&conf->wait_for_stripe);
@@ -1929,13 +2008,18 @@ static int run(mddev_t *mddev)
1929 goto abort; 2008 goto abort;
1930 } 2009 }
1931 2010
1932#if 0 /* FIX: For now */
1933 if (mddev->degraded > 0 && 2011 if (mddev->degraded > 0 &&
1934 mddev->recovery_cp != MaxSector) { 2012 mddev->recovery_cp != MaxSector) {
1935 printk(KERN_ERR "raid6: cannot start dirty degraded array for %s\n", mdname(mddev)); 2013 if (mddev->ok_start_degraded)
1936 goto abort; 2014 printk(KERN_WARNING "raid6: starting dirty degraded array:%s"
2015 "- data corruption possible.\n",
2016 mdname(mddev));
2017 else {
2018 printk(KERN_ERR "raid6: cannot start dirty degraded array"
2019 " for %s\n", mdname(mddev));
2020 goto abort;
2021 }
1937 } 2022 }
1938#endif
1939 2023
1940 { 2024 {
1941 mddev->thread = md_register_thread(raid6d, mddev, "%s_raid6"); 2025 mddev->thread = md_register_thread(raid6d, mddev, "%s_raid6");
@@ -1977,7 +2061,7 @@ static int run(mddev_t *mddev)
1977 */ 2061 */
1978 { 2062 {
1979 int stripe = (mddev->raid_disks-2) * mddev->chunk_size 2063 int stripe = (mddev->raid_disks-2) * mddev->chunk_size
1980 / PAGE_CACHE_SIZE; 2064 / PAGE_SIZE;
1981 if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe) 2065 if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
1982 mddev->queue->backing_dev_info.ra_pages = 2 * stripe; 2066 mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
1983 } 2067 }
@@ -1985,18 +2069,14 @@ static int run(mddev_t *mddev)
1985 /* Ok, everything is just fine now */ 2069 /* Ok, everything is just fine now */
1986 mddev->array_size = mddev->size * (mddev->raid_disks - 2); 2070 mddev->array_size = mddev->size * (mddev->raid_disks - 2);
1987 2071
1988 if (mddev->bitmap)
1989 mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
1990
1991 mddev->queue->unplug_fn = raid6_unplug_device; 2072 mddev->queue->unplug_fn = raid6_unplug_device;
1992 mddev->queue->issue_flush_fn = raid6_issue_flush; 2073 mddev->queue->issue_flush_fn = raid6_issue_flush;
1993 return 0; 2074 return 0;
1994abort: 2075abort:
1995 if (conf) { 2076 if (conf) {
1996 print_raid6_conf(conf); 2077 print_raid6_conf(conf);
1997 if (conf->stripe_hashtbl) 2078 safe_put_page(conf->spare_page);
1998 free_pages((unsigned long) conf->stripe_hashtbl, 2079 kfree(conf->stripe_hashtbl);
1999 HASH_PAGES_ORDER);
2000 kfree(conf); 2080 kfree(conf);
2001 } 2081 }
2002 mddev->private = NULL; 2082 mddev->private = NULL;
@@ -2013,7 +2093,7 @@ static int stop (mddev_t *mddev)
2013 md_unregister_thread(mddev->thread); 2093 md_unregister_thread(mddev->thread);
2014 mddev->thread = NULL; 2094 mddev->thread = NULL;
2015 shrink_stripes(conf); 2095 shrink_stripes(conf);
2016 free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER); 2096 kfree(conf->stripe_hashtbl);
2017 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 2097 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
2018 kfree(conf); 2098 kfree(conf);
2019 mddev->private = NULL; 2099 mddev->private = NULL;
@@ -2040,12 +2120,13 @@ static void print_sh (struct seq_file *seq, struct stripe_head *sh)
2040static void printall (struct seq_file *seq, raid6_conf_t *conf) 2120static void printall (struct seq_file *seq, raid6_conf_t *conf)
2041{ 2121{
2042 struct stripe_head *sh; 2122 struct stripe_head *sh;
2123 struct hlist_node *hn;
2043 int i; 2124 int i;
2044 2125
2045 spin_lock_irq(&conf->device_lock); 2126 spin_lock_irq(&conf->device_lock);
2046 for (i = 0; i < NR_HASH; i++) { 2127 for (i = 0; i < NR_HASH; i++) {
2047 sh = conf->stripe_hashtbl[i]; 2128 sh = conf->stripe_hashtbl[i];
2048 for (; sh; sh = sh->hash_next) { 2129 hlist_for_each_entry(sh, hn, &conf->stripe_hashtbl[i], hash) {
2049 if (sh->raid_conf != conf) 2130 if (sh->raid_conf != conf)
2050 continue; 2131 continue;
2051 print_sh(seq, sh); 2132 print_sh(seq, sh);
@@ -2223,17 +2304,12 @@ static void raid6_quiesce(mddev_t *mddev, int state)
2223 spin_unlock_irq(&conf->device_lock); 2304 spin_unlock_irq(&conf->device_lock);
2224 break; 2305 break;
2225 } 2306 }
2226 if (mddev->thread) {
2227 if (mddev->bitmap)
2228 mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
2229 else
2230 mddev->thread->timeout = MAX_SCHEDULE_TIMEOUT;
2231 md_wakeup_thread(mddev->thread);
2232 }
2233} 2307}
2234static mdk_personality_t raid6_personality= 2308
2309static struct mdk_personality raid6_personality =
2235{ 2310{
2236 .name = "raid6", 2311 .name = "raid6",
2312 .level = 6,
2237 .owner = THIS_MODULE, 2313 .owner = THIS_MODULE,
2238 .make_request = make_request, 2314 .make_request = make_request,
2239 .run = run, 2315 .run = run,
@@ -2248,7 +2324,7 @@ static mdk_personality_t raid6_personality=
2248 .quiesce = raid6_quiesce, 2324 .quiesce = raid6_quiesce,
2249}; 2325};
2250 2326
2251static int __init raid6_init (void) 2327static int __init raid6_init(void)
2252{ 2328{
2253 int e; 2329 int e;
2254 2330
@@ -2256,15 +2332,17 @@ static int __init raid6_init (void)
2256 if ( e ) 2332 if ( e )
2257 return e; 2333 return e;
2258 2334
2259 return register_md_personality (RAID6, &raid6_personality); 2335 return register_md_personality(&raid6_personality);
2260} 2336}
2261 2337
2262static void raid6_exit (void) 2338static void raid6_exit (void)
2263{ 2339{
2264 unregister_md_personality (RAID6); 2340 unregister_md_personality(&raid6_personality);
2265} 2341}
2266 2342
2267module_init(raid6_init); 2343module_init(raid6_init);
2268module_exit(raid6_exit); 2344module_exit(raid6_exit);
2269MODULE_LICENSE("GPL"); 2345MODULE_LICENSE("GPL");
2270MODULE_ALIAS("md-personality-8"); /* RAID6 */ 2346MODULE_ALIAS("md-personality-8"); /* RAID6 */
2347MODULE_ALIAS("md-raid6");
2348MODULE_ALIAS("md-level-6");
diff --git a/drivers/media/common/Kconfig b/drivers/media/common/Kconfig
index caebd0a1c021..6a901a0268e1 100644
--- a/drivers/media/common/Kconfig
+++ b/drivers/media/common/Kconfig
@@ -1,12 +1,12 @@
1config VIDEO_SAA7146 1config VIDEO_SAA7146
2 tristate 2 tristate
3 select I2C 3 select I2C
4 4
5config VIDEO_SAA7146_VV 5config VIDEO_SAA7146_VV
6 tristate 6 tristate
7 select VIDEO_BUF 7 select VIDEO_BUF
8 select VIDEO_VIDEOBUF 8 select VIDEO_VIDEOBUF
9 select VIDEO_SAA7146 9 select VIDEO_SAA7146
10 10
11config VIDEO_VIDEOBUF 11config VIDEO_VIDEOBUF
12 tristate 12 tristate
diff --git a/drivers/media/common/Makefile b/drivers/media/common/Makefile
index 97b4341255ea..bd458cb9b4ea 100644
--- a/drivers/media/common/Makefile
+++ b/drivers/media/common/Makefile
@@ -1,5 +1,5 @@
1saa7146-objs := saa7146_i2c.o saa7146_core.o 1saa7146-objs := saa7146_i2c.o saa7146_core.o
2saa7146_vv-objs := saa7146_vv_ksyms.o saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o 2saa7146_vv-objs := saa7146_vv_ksyms.o saa7146_fops.o saa7146_video.o saa7146_hlp.o saa7146_vbi.o
3 3
4obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o 4obj-$(CONFIG_VIDEO_SAA7146) += saa7146.o
5obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o 5obj-$(CONFIG_VIDEO_SAA7146_VV) += saa7146_vv.o
diff --git a/drivers/media/common/ir-common.c b/drivers/media/common/ir-common.c
index 7972c73bc14e..97fa3fc571c4 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -313,6 +313,7 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
313 if (ir_codes) 313 if (ir_codes)
314 memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes)); 314 memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
315 315
316
316 dev->keycode = ir->ir_codes; 317 dev->keycode = ir->ir_codes;
317 dev->keycodesize = sizeof(IR_KEYTAB_TYPE); 318 dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
318 dev->keycodemax = IR_KEYTAB_SIZE; 319 dev->keycodemax = IR_KEYTAB_SIZE;
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 206cc2f61f26..2899d34e5f7e 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -174,8 +174,8 @@ void saa7146_pgtable_free(struct pci_dev *pci, struct saa7146_pgtable *pt)
174 174
175int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt) 175int saa7146_pgtable_alloc(struct pci_dev *pci, struct saa7146_pgtable *pt)
176{ 176{
177 u32 *cpu; 177 u32 *cpu;
178 dma_addr_t dma_addr; 178 dma_addr_t dma_addr;
179 179
180 cpu = pci_alloc_consistent(pci, PAGE_SIZE, &dma_addr); 180 cpu = pci_alloc_consistent(pci, PAGE_SIZE, &dma_addr);
181 if (NULL == cpu) { 181 if (NULL == cpu) {
@@ -405,7 +405,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
405 405
406 pci_set_drvdata(pci, dev); 406 pci_set_drvdata(pci, dev);
407 407
408 init_MUTEX(&dev->lock); 408 init_MUTEX(&dev->lock);
409 spin_lock_init(&dev->int_slock); 409 spin_lock_init(&dev->int_slock);
410 spin_lock_init(&dev->slock); 410 spin_lock_init(&dev->slock);
411 411
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 37888989ea2e..09ec964dec5c 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -1,6 +1,6 @@
1#include <media/saa7146_vv.h> 1#include <media/saa7146_vv.h>
2 2
3#define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1) 3#define BOARD_CAN_DO_VBI(dev) (dev->revision != 0 && dev->vv_data->vbi_minor != -1)
4 4
5/****************************************************************************/ 5/****************************************************************************/
6/* resource management functions, shamelessly stolen from saa7134 driver */ 6/* resource management functions, shamelessly stolen from saa7134 driver */
@@ -102,9 +102,9 @@ void saa7146_buffer_finish(struct saa7146_dev *dev,
102 /* finish current buffer */ 102 /* finish current buffer */
103 if (NULL == q->curr) { 103 if (NULL == q->curr) {
104 DEB_D(("aiii. no current buffer\n")); 104 DEB_D(("aiii. no current buffer\n"));
105 return; 105 return;
106 } 106 }
107 107
108 q->curr->vb.state = state; 108 q->curr->vb.state = state;
109 do_gettimeofday(&q->curr->vb.ts); 109 do_gettimeofday(&q->curr->vb.ts);
110 wake_up(&q->curr->vb.done); 110 wake_up(&q->curr->vb.done);
@@ -143,13 +143,13 @@ void saa7146_buffer_next(struct saa7146_dev *dev,
143 // fixme: fix this for vflip != 0 143 // fixme: fix this for vflip != 0
144 144
145 saa7146_write(dev, PROT_ADDR1, 0); 145 saa7146_write(dev, PROT_ADDR1, 0);
146 saa7146_write(dev, MC2, (MASK_02|MASK_18)); 146 saa7146_write(dev, MC2, (MASK_02|MASK_18));
147 147
148 /* write the address of the rps-program */ 148 /* write the address of the rps-program */
149 saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle); 149 saa7146_write(dev, RPS_ADDR0, dev->d_rps0.dma_handle);
150 /* turn on rps */ 150 /* turn on rps */
151 saa7146_write(dev, MC1, (MASK_12 | MASK_28)); 151 saa7146_write(dev, MC1, (MASK_12 | MASK_28));
152 152
153/* 153/*
154 printk("vdma%d.base_even: 0x%08x\n", 1,saa7146_read(dev,BASE_EVEN1)); 154 printk("vdma%d.base_even: 0x%08x\n", 1,saa7146_read(dev,BASE_EVEN1));
155 printk("vdma%d.base_odd: 0x%08x\n", 1,saa7146_read(dev,BASE_ODD1)); 155 printk("vdma%d.base_odd: 0x%08x\n", 1,saa7146_read(dev,BASE_ODD1));
@@ -246,7 +246,7 @@ static int fops_open(struct inode *inode, struct file *file)
246 goto out; 246 goto out;
247 } 247 }
248 memset(fh,0,sizeof(*fh)); 248 memset(fh,0,sizeof(*fh));
249 249
250 file->private_data = fh; 250 file->private_data = fh;
251 fh->dev = dev; 251 fh->dev = dev;
252 fh->type = type; 252 fh->type = type;
@@ -275,7 +275,7 @@ out:
275 file->private_data = NULL; 275 file->private_data = NULL;
276 } 276 }
277 up(&saa7146_devices_lock); 277 up(&saa7146_devices_lock);
278 return result; 278 return result;
279} 279}
280 280
281static int fops_release(struct inode *inode, struct file *file) 281static int fops_release(struct inode *inode, struct file *file)
@@ -405,7 +405,7 @@ static struct file_operations video_fops =
405static void vv_callback(struct saa7146_dev *dev, unsigned long status) 405static void vv_callback(struct saa7146_dev *dev, unsigned long status)
406{ 406{
407 u32 isr = status; 407 u32 isr = status;
408 408
409 DEB_INT(("dev:%p, isr:0x%08x\n",dev,(u32)status)); 409 DEB_INT(("dev:%p, isr:0x%08x\n",dev,(u32)status));
410 410
411 if (0 != (isr & (MASK_27))) { 411 if (0 != (isr & (MASK_27))) {
@@ -454,11 +454,11 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
454 handle different devices that might need different 454 handle different devices that might need different
455 configuration data) */ 455 configuration data) */
456 dev->ext_vv_data = ext_vv; 456 dev->ext_vv_data = ext_vv;
457 457
458 vv->video_minor = -1; 458 vv->video_minor = -1;
459 vv->vbi_minor = -1; 459 vv->vbi_minor = -1;
460 460
461 vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle); 461 vv->d_clipping.cpu_addr = pci_alloc_consistent(dev->pci, SAA7146_CLIPPING_MEM, &vv->d_clipping.dma_handle);
462 if( NULL == vv->d_clipping.cpu_addr ) { 462 if( NULL == vv->d_clipping.cpu_addr ) {
463 ERR(("out of memory. aborting.\n")); 463 ERR(("out of memory. aborting.\n"));
464 kfree(vv); 464 kfree(vv);
@@ -468,7 +468,7 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
468 468
469 saa7146_video_uops.init(dev,vv); 469 saa7146_video_uops.init(dev,vv);
470 saa7146_vbi_uops.init(dev,vv); 470 saa7146_vbi_uops.init(dev,vv);
471 471
472 dev->vv_data = vv; 472 dev->vv_data = vv;
473 dev->vv_callback = &vv_callback; 473 dev->vv_callback = &vv_callback;
474 474
@@ -480,12 +480,12 @@ int saa7146_vv_release(struct saa7146_dev* dev)
480 struct saa7146_vv *vv = dev->vv_data; 480 struct saa7146_vv *vv = dev->vv_data;
481 481
482 DEB_EE(("dev:%p\n",dev)); 482 DEB_EE(("dev:%p\n",dev));
483 483
484 pci_free_consistent(dev->pci, SAA7146_RPS_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle); 484 pci_free_consistent(dev->pci, SAA7146_RPS_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle);
485 kfree(vv); 485 kfree(vv);
486 dev->vv_data = NULL; 486 dev->vv_data = NULL;
487 dev->vv_callback = NULL; 487 dev->vv_callback = NULL;
488 488
489 return 0; 489 return 0;
490} 490}
491 491
@@ -498,7 +498,7 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
498 DEB_EE(("dev:%p, name:'%s', type:%d\n",dev,name,type)); 498 DEB_EE(("dev:%p, name:'%s', type:%d\n",dev,name,type));
499 499
500 // released by vfd->release 500 // released by vfd->release
501 vfd = video_device_alloc(); 501 vfd = video_device_alloc();
502 if (vfd == NULL) 502 if (vfd == NULL)
503 return -ENOMEM; 503 return -ENOMEM;
504 504
@@ -530,7 +530,7 @@ int saa7146_register_device(struct video_device **vid, struct saa7146_dev* dev,
530int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev) 530int saa7146_unregister_device(struct video_device **vid, struct saa7146_dev* dev)
531{ 531{
532 struct saa7146_vv *vv = dev->vv_data; 532 struct saa7146_vv *vv = dev->vv_data;
533 533
534 DEB_EE(("dev:%p\n",dev)); 534 DEB_EE(("dev:%p\n",dev));
535 535
536 if( VFL_TYPE_GRABBER == (*vid)->type ) { 536 if( VFL_TYPE_GRABBER == (*vid)->type ) {
diff --git a/drivers/media/common/saa7146_i2c.c b/drivers/media/common/saa7146_i2c.c
index fec6beab8c28..8aabdd8fb3c5 100644
--- a/drivers/media/common/saa7146_i2c.c
+++ b/drivers/media/common/saa7146_i2c.c
@@ -276,8 +276,8 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, in
276 int i = 0, count = 0; 276 int i = 0, count = 0;
277 u32* buffer = dev->d_i2c.cpu_addr; 277 u32* buffer = dev->d_i2c.cpu_addr;
278 int err = 0; 278 int err = 0;
279 int address_err = 0; 279 int address_err = 0;
280 int short_delay = 0; 280 int short_delay = 0;
281 281
282 if (down_interruptible (&dev->i2c_lock)) 282 if (down_interruptible (&dev->i2c_lock))
283 return -ERESTARTSYS; 283 return -ERESTARTSYS;
@@ -325,7 +325,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, in
325 if( 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) { 325 if( 0 != (SAA7146_USE_I2C_IRQ & dev->ext->flags)) {
326 goto out; 326 goto out;
327 } 327 }
328 address_err++; 328 address_err++;
329 } 329 }
330 DEB_I2C(("error while sending message(s). starting again.\n")); 330 DEB_I2C(("error while sending message(s). starting again.\n"));
331 break; 331 break;
@@ -336,14 +336,14 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg *msgs, in
336 break; 336 break;
337 } 337 }
338 338
339 /* delay a bit before retrying */ 339 /* delay a bit before retrying */
340 msleep(10); 340 msleep(10);
341 341
342 } while (err != num && retries--); 342 } while (err != num && retries--);
343 343
344 /* if every retry had an address error, exit right away */ 344 /* if every retry had an address error, exit right away */
345 if (address_err == retries) { 345 if (address_err == retries) {
346 goto out; 346 goto out;
347 } 347 }
348 348
349 /* if any things had to be read, get the results */ 349 /* if any things had to be read, get the results */
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
index cb86a97fda1f..063986ec16b5 100644
--- a/drivers/media/common/saa7146_vbi.c
+++ b/drivers/media/common/saa7146_vbi.c
@@ -6,8 +6,8 @@ static int vbi_workaround(struct saa7146_dev *dev)
6{ 6{
7 struct saa7146_vv *vv = dev->vv_data; 7 struct saa7146_vv *vv = dev->vv_data;
8 8
9 u32 *cpu; 9 u32 *cpu;
10 dma_addr_t dma_addr; 10 dma_addr_t dma_addr;
11 11
12 int count = 0; 12 int count = 0;
13 int i; 13 int i;
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 8dd4d15ca36d..1d961023b837 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -150,23 +150,23 @@ static int try_win(struct saa7146_dev *dev, struct v4l2_window *win)
150 maxh = vv->standard->v_max_out; 150 maxh = vv->standard->v_max_out;
151 151
152 if (V4L2_FIELD_ANY == field) { 152 if (V4L2_FIELD_ANY == field) {
153 field = (win->w.height > maxh/2) 153 field = (win->w.height > maxh/2)
154 ? V4L2_FIELD_INTERLACED 154 ? V4L2_FIELD_INTERLACED
155 : V4L2_FIELD_TOP; 155 : V4L2_FIELD_TOP;
156 } 156 }
157 switch (field) { 157 switch (field) {
158 case V4L2_FIELD_TOP: 158 case V4L2_FIELD_TOP:
159 case V4L2_FIELD_BOTTOM: 159 case V4L2_FIELD_BOTTOM:
160 case V4L2_FIELD_ALTERNATE: 160 case V4L2_FIELD_ALTERNATE:
161 maxh = maxh / 2; 161 maxh = maxh / 2;
162 break; 162 break;
163 case V4L2_FIELD_INTERLACED: 163 case V4L2_FIELD_INTERLACED:
164 break; 164 break;
165 default: { 165 default: {
166 DEB_D(("no known field mode '%d'.\n",field)); 166 DEB_D(("no known field mode '%d'.\n",field));
167 return -EINVAL; 167 return -EINVAL;
168 }
168 } 169 }
169 }
170 170
171 win->field = field; 171 win->field = field;
172 if (win->w.width > maxw) 172 if (win->w.width > maxw)
@@ -887,7 +887,7 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
887 887
888 DEB_EE(("VIDIOC_QUERYCAP\n")); 888 DEB_EE(("VIDIOC_QUERYCAP\n"));
889 889
890 strcpy(cap->driver, "saa7146 v4l2"); 890 strcpy(cap->driver, "saa7146 v4l2");
891 strlcpy(cap->card, dev->ext->name, sizeof(cap->card)); 891 strlcpy(cap->card, dev->ext->name, sizeof(cap->card));
892 sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci)); 892 sprintf(cap->bus_info,"PCI:%s", pci_name(dev->pci));
893 cap->version = SAA7146_VERSION_CODE; 893 cap->version = SAA7146_VERSION_CODE;
@@ -1011,19 +1011,19 @@ int saa7146_video_do_ioctl(struct inode *inode, struct file *file, unsigned int
1011 err = set_control(fh,arg); 1011 err = set_control(fh,arg);
1012 return err; 1012 return err;
1013 } 1013 }
1014 case VIDIOC_G_PARM: 1014 case VIDIOC_G_PARM:
1015 { 1015 {
1016 struct v4l2_streamparm *parm = arg; 1016 struct v4l2_streamparm *parm = arg;
1017 if( parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ) { 1017 if( parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ) {
1018 return -EINVAL; 1018 return -EINVAL;
1019 } 1019 }
1020 memset(&parm->parm.capture,0,sizeof(struct v4l2_captureparm)); 1020 memset(&parm->parm.capture,0,sizeof(struct v4l2_captureparm));
1021 parm->parm.capture.readbuffers = 1; 1021 parm->parm.capture.readbuffers = 1;
1022 // fixme: only for PAL! 1022 // fixme: only for PAL!
1023 parm->parm.capture.timeperframe.numerator = 1; 1023 parm->parm.capture.timeperframe.numerator = 1;
1024 parm->parm.capture.timeperframe.denominator = 25; 1024 parm->parm.capture.timeperframe.denominator = 25;
1025 return 0; 1025 return 0;
1026 } 1026 }
1027 case VIDIOC_G_FMT: 1027 case VIDIOC_G_FMT:
1028 { 1028 {
1029 struct v4l2_format *f = arg; 1029 struct v4l2_format *f = arg;
@@ -1383,7 +1383,7 @@ static struct videobuf_queue_ops video_qops = {
1383 1383
1384static void video_init(struct saa7146_dev *dev, struct saa7146_vv *vv) 1384static void video_init(struct saa7146_dev *dev, struct saa7146_vv *vv)
1385{ 1385{
1386 INIT_LIST_HEAD(&vv->video_q.queue); 1386 INIT_LIST_HEAD(&vv->video_q.queue);
1387 1387
1388 init_timer(&vv->video_q.timeout); 1388 init_timer(&vv->video_q.timeout);
1389 vv->video_q.timeout.function = saa7146_buffer_timeout; 1389 vv->video_q.timeout.function = saa7146_buffer_timeout;
diff --git a/drivers/media/dvb/b2c2/flexcop-common.h b/drivers/media/dvb/b2c2/flexcop-common.h
index a94912ac1872..344a3c898460 100644
--- a/drivers/media/dvb/b2c2/flexcop-common.h
+++ b/drivers/media/dvb/b2c2/flexcop-common.h
@@ -132,7 +132,7 @@ int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended);
132 * I2C-channel of the flexcop. 132 * I2C-channel of the flexcop.
133 */ 133 */
134int flexcop_i2c_request(struct flexcop_device*, flexcop_access_op_t, 134int flexcop_i2c_request(struct flexcop_device*, flexcop_access_op_t,
135 flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len); 135 flexcop_i2c_port_t, u8 chipaddr, u8 addr, u8 *buf, u16 len);
136 136
137/* from flexcop-sram.c */ 137/* from flexcop-sram.c */
138int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target); 138int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, flexcop_sram_dest_target_t target);
diff --git a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
index a35330315f65..21a9045b3ef6 100644
--- a/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
+++ b/drivers/media/dvb/b2c2/flexcop-fe-tuner.c
@@ -298,7 +298,7 @@ static int flexcop_fe_request_firmware(struct dvb_frontend* fe, const struct fir
298} 298}
299 299
300static int lgdt3303_pll_set(struct dvb_frontend* fe, 300static int lgdt3303_pll_set(struct dvb_frontend* fe,
301 struct dvb_frontend_parameters* params) 301 struct dvb_frontend_parameters* params)
302{ 302{
303 struct flexcop_device *fc = fe->dvb->priv; 303 struct flexcop_device *fc = fe->dvb->priv;
304 u8 buf[4]; 304 u8 buf[4];
@@ -332,7 +332,7 @@ static int lgdt3303_pll_set(struct dvb_frontend* fe,
332 return -EREMOTEIO; 332 return -EREMOTEIO;
333 } 333 }
334 334
335 return 0; 335 return 0;
336} 336}
337 337
338static struct lgdt330x_config air2pc_atsc_hd5000_config = { 338static struct lgdt330x_config air2pc_atsc_hd5000_config = {
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
index 0a78ba3737a5..a6c91db40ad6 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -544,7 +544,6 @@ static struct usb_device_id flexcop_usb_table [] = {
544 544
545/* usb specific object needed to register this driver with the usb subsystem */ 545/* usb specific object needed to register this driver with the usb subsystem */
546static struct usb_driver flexcop_usb_driver = { 546static struct usb_driver flexcop_usb_driver = {
547 .owner = THIS_MODULE,
548 .name = "b2c2_flexcop_usb", 547 .name = "b2c2_flexcop_usb",
549 .probe = flexcop_usb_probe, 548 .probe = flexcop_usb_probe,
550 .disconnect = flexcop_usb_disconnect, 549 .disconnect = flexcop_usb_disconnect,
diff --git a/drivers/media/dvb/bt8xx/dst_ca.c b/drivers/media/dvb/bt8xx/dst_ca.c
index e6541aff3996..2239651969c8 100644
--- a/drivers/media/dvb/bt8xx/dst_ca.c
+++ b/drivers/media/dvb/bt8xx/dst_ca.c
@@ -406,7 +406,7 @@ static int ca_send_message(struct dst_state *state, struct ca_msg *p_ca_message,
406 } 406 }
407 dprintk(verbose, DST_CA_DEBUG, 1, " "); 407 dprintk(verbose, DST_CA_DEBUG, 1, " ");
408 408
409 if (copy_from_user(p_ca_message, (void *)arg, sizeof (struct ca_msg))) { 409 if (copy_from_user(p_ca_message, arg, sizeof (struct ca_msg))) {
410 result = -EFAULT; 410 result = -EFAULT;
411 goto free_mem_and_exit; 411 goto free_mem_and_exit;
412 } 412 }
@@ -579,7 +579,7 @@ static int dst_ca_release(struct inode *inode, struct file *file)
579 return 0; 579 return 0;
580} 580}
581 581
582static int dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset) 582static ssize_t dst_ca_read(struct file *file, char __user *buffer, size_t length, loff_t *offset)
583{ 583{
584 int bytes_read = 0; 584 int bytes_read = 0;
585 585
@@ -588,7 +588,7 @@ static int dst_ca_read(struct file *file, char __user *buffer, size_t length, lo
588 return bytes_read; 588 return bytes_read;
589} 589}
590 590
591static int dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset) 591static ssize_t dst_ca_write(struct file *file, const char __user *buffer, size_t length, loff_t *offset)
592{ 592{
593 dprintk(verbose, DST_CA_DEBUG, 1, " Device write."); 593 dprintk(verbose, DST_CA_DEBUG, 1, " Device write.");
594 594
diff --git a/drivers/media/dvb/bt8xx/dvb-bt8xx.c b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
index 2e398090cf63..77977e9c013e 100644
--- a/drivers/media/dvb/bt8xx/dvb-bt8xx.c
+++ b/drivers/media/dvb/bt8xx/dvb-bt8xx.c
@@ -556,9 +556,9 @@ static int tdvs_tua6034_pll_set(struct dvb_frontend* fe, struct dvb_frontend_par
556 dprintk("%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n", 556 dprintk("%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
557 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]); 557 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]);
558 if ((err = i2c_transfer(card->i2c_adapter, &msg, 1)) != 1) { 558 if ((err = i2c_transfer(card->i2c_adapter, &msg, 1)) != 1) {
559 printk(KERN_WARNING "dvb-bt8xx: %s error " 559 printk(KERN_WARNING "dvb-bt8xx: %s error "
560 "(addr %02x <- %02x, err = %i)\n", 560 "(addr %02x <- %02x, err = %i)\n",
561 __FUNCTION__, buf[0], buf[1], err); 561 __FUNCTION__, buf[0], buf[1], err);
562 if (err < 0) 562 if (err < 0)
563 return err; 563 return err;
564 else 564 else
diff --git a/drivers/media/dvb/cinergyT2/cinergyT2.c b/drivers/media/dvb/cinergyT2/cinergyT2.c
index 336fc284fa52..1d69bf031fb9 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -60,7 +60,7 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
60#define dprintk(level, args...) \ 60#define dprintk(level, args...) \
61do { \ 61do { \
62 if ((debug & level)) { \ 62 if ((debug & level)) { \
63 printk("%s: %s(): ", __stringify(KBUILD_MODNAME), \ 63 printk("%s: %s(): ", KBUILD_MODNAME, \
64 __FUNCTION__); \ 64 __FUNCTION__); \
65 printk(args); } \ 65 printk(args); } \
66} while (0) 66} while (0)
@@ -986,7 +986,6 @@ static const struct usb_device_id cinergyt2_table [] __devinitdata = {
986MODULE_DEVICE_TABLE(usb, cinergyt2_table); 986MODULE_DEVICE_TABLE(usb, cinergyt2_table);
987 987
988static struct usb_driver cinergyt2_driver = { 988static struct usb_driver cinergyt2_driver = {
989 .owner = THIS_MODULE,
990 .name = "cinergyT2", 989 .name = "cinergyT2",
991 .probe = cinergyt2_probe, 990 .probe = cinergyt2_probe,
992 .disconnect = cinergyt2_disconnect, 991 .disconnect = cinergyt2_disconnect,
diff --git a/drivers/media/dvb/dvb-core/demux.h b/drivers/media/dvb/dvb-core/demux.h
index 7d7b0067f228..9f025825b2d2 100644
--- a/drivers/media/dvb/dvb-core/demux.h
+++ b/drivers/media/dvb/dvb-core/demux.h
@@ -86,25 +86,25 @@ enum dmx_success {
86 86
87enum dmx_ts_pes 87enum dmx_ts_pes
88{ /* also send packets to decoder (if it exists) */ 88{ /* also send packets to decoder (if it exists) */
89 DMX_TS_PES_AUDIO0, 89 DMX_TS_PES_AUDIO0,
90 DMX_TS_PES_VIDEO0, 90 DMX_TS_PES_VIDEO0,
91 DMX_TS_PES_TELETEXT0, 91 DMX_TS_PES_TELETEXT0,
92 DMX_TS_PES_SUBTITLE0, 92 DMX_TS_PES_SUBTITLE0,
93 DMX_TS_PES_PCR0, 93 DMX_TS_PES_PCR0,
94 94
95 DMX_TS_PES_AUDIO1, 95 DMX_TS_PES_AUDIO1,
96 DMX_TS_PES_VIDEO1, 96 DMX_TS_PES_VIDEO1,
97 DMX_TS_PES_TELETEXT1, 97 DMX_TS_PES_TELETEXT1,
98 DMX_TS_PES_SUBTITLE1, 98 DMX_TS_PES_SUBTITLE1,
99 DMX_TS_PES_PCR1, 99 DMX_TS_PES_PCR1,
100 100
101 DMX_TS_PES_AUDIO2, 101 DMX_TS_PES_AUDIO2,
102 DMX_TS_PES_VIDEO2, 102 DMX_TS_PES_VIDEO2,
103 DMX_TS_PES_TELETEXT2, 103 DMX_TS_PES_TELETEXT2,
104 DMX_TS_PES_SUBTITLE2, 104 DMX_TS_PES_SUBTITLE2,
105 DMX_TS_PES_PCR2, 105 DMX_TS_PES_PCR2,
106 106
107 DMX_TS_PES_AUDIO3, 107 DMX_TS_PES_AUDIO3,
108 DMX_TS_PES_VIDEO3, 108 DMX_TS_PES_VIDEO3,
109 DMX_TS_PES_TELETEXT3, 109 DMX_TS_PES_TELETEXT3,
110 DMX_TS_PES_SUBTITLE3, 110 DMX_TS_PES_SUBTITLE3,
@@ -121,17 +121,17 @@ enum dmx_ts_pes
121 121
122 122
123struct dmx_ts_feed { 123struct dmx_ts_feed {
124 int is_filtering; /* Set to non-zero when filtering in progress */ 124 int is_filtering; /* Set to non-zero when filtering in progress */
125 struct dmx_demux *parent; /* Back-pointer */ 125 struct dmx_demux *parent; /* Back-pointer */
126 void *priv; /* Pointer to private data of the API client */ 126 void *priv; /* Pointer to private data of the API client */
127 int (*set) (struct dmx_ts_feed *feed, 127 int (*set) (struct dmx_ts_feed *feed,
128 u16 pid, 128 u16 pid,
129 int type, 129 int type,
130 enum dmx_ts_pes pes_type, 130 enum dmx_ts_pes pes_type,
131 size_t circular_buffer_size, 131 size_t circular_buffer_size,
132 struct timespec timeout); 132 struct timespec timeout);
133 int (*start_filtering) (struct dmx_ts_feed* feed); 133 int (*start_filtering) (struct dmx_ts_feed* feed);
134 int (*stop_filtering) (struct dmx_ts_feed* feed); 134 int (*stop_filtering) (struct dmx_ts_feed* feed);
135}; 135};
136 136
137/*--------------------------------------------------------------------------*/ 137/*--------------------------------------------------------------------------*/
@@ -139,35 +139,35 @@ struct dmx_ts_feed {
139/*--------------------------------------------------------------------------*/ 139/*--------------------------------------------------------------------------*/
140 140
141struct dmx_section_filter { 141struct dmx_section_filter {
142 u8 filter_value [DMX_MAX_FILTER_SIZE]; 142 u8 filter_value [DMX_MAX_FILTER_SIZE];
143 u8 filter_mask [DMX_MAX_FILTER_SIZE]; 143 u8 filter_mask [DMX_MAX_FILTER_SIZE];
144 u8 filter_mode [DMX_MAX_FILTER_SIZE]; 144 u8 filter_mode [DMX_MAX_FILTER_SIZE];
145 struct dmx_section_feed* parent; /* Back-pointer */ 145 struct dmx_section_feed* parent; /* Back-pointer */
146 void* priv; /* Pointer to private data of the API client */ 146 void* priv; /* Pointer to private data of the API client */
147}; 147};
148 148
149struct dmx_section_feed { 149struct dmx_section_feed {
150 int is_filtering; /* Set to non-zero when filtering in progress */ 150 int is_filtering; /* Set to non-zero when filtering in progress */
151 struct dmx_demux* parent; /* Back-pointer */ 151 struct dmx_demux* parent; /* Back-pointer */
152 void* priv; /* Pointer to private data of the API client */ 152 void* priv; /* Pointer to private data of the API client */
153 153
154 int check_crc; 154 int check_crc;
155 u32 crc_val; 155 u32 crc_val;
156 156
157 u8 *secbuf; 157 u8 *secbuf;
158 u8 secbuf_base[DMX_MAX_SECFEED_SIZE]; 158 u8 secbuf_base[DMX_MAX_SECFEED_SIZE];
159 u16 secbufp, seclen, tsfeedp; 159 u16 secbufp, seclen, tsfeedp;
160 160
161 int (*set) (struct dmx_section_feed* feed, 161 int (*set) (struct dmx_section_feed* feed,
162 u16 pid, 162 u16 pid,
163 size_t circular_buffer_size, 163 size_t circular_buffer_size,
164 int check_crc); 164 int check_crc);
165 int (*allocate_filter) (struct dmx_section_feed* feed, 165 int (*allocate_filter) (struct dmx_section_feed* feed,
166 struct dmx_section_filter** filter); 166 struct dmx_section_filter** filter);
167 int (*release_filter) (struct dmx_section_feed* feed, 167 int (*release_filter) (struct dmx_section_feed* feed,
168 struct dmx_section_filter* filter); 168 struct dmx_section_filter* filter);
169 int (*start_filtering) (struct dmx_section_feed* feed); 169 int (*start_filtering) (struct dmx_section_feed* feed);
170 int (*stop_filtering) (struct dmx_section_feed* feed); 170 int (*stop_filtering) (struct dmx_section_feed* feed);
171}; 171};
172 172
173/*--------------------------------------------------------------------------*/ 173/*--------------------------------------------------------------------------*/
@@ -205,10 +205,10 @@ enum dmx_frontend_source {
205}; 205};
206 206
207struct dmx_frontend { 207struct dmx_frontend {
208 struct list_head connectivity_list; /* List of front-ends that can 208 struct list_head connectivity_list; /* List of front-ends that can
209 be connected to a particular 209 be connected to a particular
210 demux */ 210 demux */
211 enum dmx_frontend_source source; 211 enum dmx_frontend_source source;
212}; 212};
213 213
214/*--------------------------------------------------------------------------*/ 214/*--------------------------------------------------------------------------*/
@@ -240,38 +240,38 @@ struct dmx_frontend {
240#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list) 240#define DMX_FE_ENTRY(list) list_entry(list, struct dmx_frontend, connectivity_list)
241 241
242struct dmx_demux { 242struct dmx_demux {
243 u32 capabilities; /* Bitfield of capability flags */ 243 u32 capabilities; /* Bitfield of capability flags */
244 struct dmx_frontend* frontend; /* Front-end connected to the demux */ 244 struct dmx_frontend* frontend; /* Front-end connected to the demux */
245 void* priv; /* Pointer to private data of the API client */ 245 void* priv; /* Pointer to private data of the API client */
246 int (*open) (struct dmx_demux* demux); 246 int (*open) (struct dmx_demux* demux);
247 int (*close) (struct dmx_demux* demux); 247 int (*close) (struct dmx_demux* demux);
248 int (*write) (struct dmx_demux* demux, const char* buf, size_t count); 248 int (*write) (struct dmx_demux* demux, const char* buf, size_t count);
249 int (*allocate_ts_feed) (struct dmx_demux* demux, 249 int (*allocate_ts_feed) (struct dmx_demux* demux,
250 struct dmx_ts_feed** feed, 250 struct dmx_ts_feed** feed,
251 dmx_ts_cb callback); 251 dmx_ts_cb callback);
252 int (*release_ts_feed) (struct dmx_demux* demux, 252 int (*release_ts_feed) (struct dmx_demux* demux,
253 struct dmx_ts_feed* feed); 253 struct dmx_ts_feed* feed);
254 int (*allocate_section_feed) (struct dmx_demux* demux, 254 int (*allocate_section_feed) (struct dmx_demux* demux,
255 struct dmx_section_feed** feed, 255 struct dmx_section_feed** feed,
256 dmx_section_cb callback); 256 dmx_section_cb callback);
257 int (*release_section_feed) (struct dmx_demux* demux, 257 int (*release_section_feed) (struct dmx_demux* demux,
258 struct dmx_section_feed* feed); 258 struct dmx_section_feed* feed);
259 int (*add_frontend) (struct dmx_demux* demux, 259 int (*add_frontend) (struct dmx_demux* demux,
260 struct dmx_frontend* frontend); 260 struct dmx_frontend* frontend);
261 int (*remove_frontend) (struct dmx_demux* demux, 261 int (*remove_frontend) (struct dmx_demux* demux,
262 struct dmx_frontend* frontend); 262 struct dmx_frontend* frontend);
263 struct list_head* (*get_frontends) (struct dmx_demux* demux); 263 struct list_head* (*get_frontends) (struct dmx_demux* demux);
264 int (*connect_frontend) (struct dmx_demux* demux, 264 int (*connect_frontend) (struct dmx_demux* demux,
265 struct dmx_frontend* frontend); 265 struct dmx_frontend* frontend);
266 int (*disconnect_frontend) (struct dmx_demux* demux); 266 int (*disconnect_frontend) (struct dmx_demux* demux);
267 267
268 int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids); 268 int (*get_pes_pids) (struct dmx_demux* demux, u16 *pids);
269 269
270 int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps); 270 int (*get_caps) (struct dmx_demux* demux, struct dmx_caps *caps);
271 271
272 int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src); 272 int (*set_source) (struct dmx_demux* demux, const dmx_source_t *src);
273 273
274 int (*get_stc) (struct dmx_demux* demux, unsigned int num, 274 int (*get_stc) (struct dmx_demux* demux, unsigned int num,
275 u64 *stc, unsigned int *base); 275 u64 *stc, unsigned int *base);
276}; 276};
277 277
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c
index 8028c3a5e287..7b8373ad121b 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/drivers/media/dvb/dvb-core/dmxdev.c
@@ -947,7 +947,7 @@ static int dvb_demux_do_ioctl(struct inode *inode, struct file *file,
947 947
948 case DMX_GET_STC: 948 case DMX_GET_STC:
949 if (!dmxdev->demux->get_stc) { 949 if (!dmxdev->demux->get_stc) {
950 ret=-EINVAL; 950 ret=-EINVAL;
951 break; 951 break;
952 } 952 }
953 ret = dmxdev->demux->get_stc(dmxdev->demux, 953 ret = dmxdev->demux->get_stc(dmxdev->demux,
diff --git a/drivers/media/dvb/dvb-core/dmxdev.h b/drivers/media/dvb/dvb-core/dmxdev.h
index 395a9cd75012..fd72920c2199 100644
--- a/drivers/media/dvb/dvb-core/dmxdev.h
+++ b/drivers/media/dvb/dvb-core/dmxdev.h
@@ -53,51 +53,51 @@ enum dmxdev_state {
53}; 53};
54 54
55struct dmxdev_buffer { 55struct dmxdev_buffer {
56 u8 *data; 56 u8 *data;
57 int size; 57 int size;
58 int pread; 58 int pread;
59 int pwrite; 59 int pwrite;
60 wait_queue_head_t queue; 60 wait_queue_head_t queue;
61 int error; 61 int error;
62}; 62};
63 63
64struct dmxdev_filter { 64struct dmxdev_filter {
65 struct dvb_device *dvbdev; 65 struct dvb_device *dvbdev;
66 66
67 union { 67 union {
68 struct dmx_section_filter *sec; 68 struct dmx_section_filter *sec;
69 } filter; 69 } filter;
70 70
71 union { 71 union {
72 struct dmx_ts_feed *ts; 72 struct dmx_ts_feed *ts;
73 struct dmx_section_feed *sec; 73 struct dmx_section_feed *sec;
74 } feed; 74 } feed;
75 75
76 union { 76 union {
77 struct dmx_sct_filter_params sec; 77 struct dmx_sct_filter_params sec;
78 struct dmx_pes_filter_params pes; 78 struct dmx_pes_filter_params pes;
79 } params; 79 } params;
80 80
81 int type; 81 int type;
82 enum dmxdev_state state; 82 enum dmxdev_state state;
83 struct dmxdev *dev; 83 struct dmxdev *dev;
84 struct dmxdev_buffer buffer; 84 struct dmxdev_buffer buffer;
85 85
86 struct semaphore mutex; 86 struct semaphore mutex;
87 87
88 /* only for sections */ 88 /* only for sections */
89 struct timer_list timer; 89 struct timer_list timer;
90 int todo; 90 int todo;
91 u8 secheader[3]; 91 u8 secheader[3];
92 92
93 u16 pid; 93 u16 pid;
94}; 94};
95 95
96 96
97struct dmxdev_dvr { 97struct dmxdev_dvr {
98 int state; 98 int state;
99 struct dmxdev *dev; 99 struct dmxdev *dev;
100 struct dmxdev_buffer buffer; 100 struct dmxdev_buffer buffer;
101}; 101};
102 102
103 103
@@ -105,16 +105,16 @@ struct dmxdev {
105 struct dvb_device *dvbdev; 105 struct dvb_device *dvbdev;
106 struct dvb_device *dvr_dvbdev; 106 struct dvb_device *dvr_dvbdev;
107 107
108 struct dmxdev_filter *filter; 108 struct dmxdev_filter *filter;
109 struct dmxdev_dvr *dvr; 109 struct dmxdev_dvr *dvr;
110 struct dmx_demux *demux; 110 struct dmx_demux *demux;
111 111
112 int filternum; 112 int filternum;
113 int capabilities; 113 int capabilities;
114#define DMXDEV_CAP_DUPLEX 1 114#define DMXDEV_CAP_DUPLEX 1
115 struct dmx_frontend *dvr_orig_fe; 115 struct dmx_frontend *dvr_orig_fe;
116 116
117 struct dmxdev_buffer dvr_buffer; 117 struct dmxdev_buffer dvr_buffer;
118#define DVR_BUFFER_SIZE (10*188*1024) 118#define DVR_BUFFER_SIZE (10*188*1024)
119 119
120 struct semaphore mutex; 120 struct semaphore mutex;
diff --git a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
index cb2e7d6ba283..5956c35d34ac 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -498,7 +498,7 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
498 /* process the CFTABLE_ENTRY tuples, and any after those */ 498 /* process the CFTABLE_ENTRY tuples, and any after those */
499 while ((!end_chain) && (address < 0x1000)) { 499 while ((!end_chain) && (address < 0x1000)) {
500 if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, 500 if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
501 &tupleLength, tuple)) < 0) 501 &tupleLength, tuple)) < 0)
502 return status; 502 return status;
503 switch (tupleType) { 503 switch (tupleType) {
504 case 0x1B: // CISTPL_CFTABLE_ENTRY 504 case 0x1B: // CISTPL_CFTABLE_ENTRY
diff --git a/drivers/media/dvb/dvb-core/dvb_filter.c b/drivers/media/dvb/dvb-core/dvb_filter.c
index bd5143906084..c49fd0bd7181 100644
--- a/drivers/media/dvb/dvb-core/dvb_filter.c
+++ b/drivers/media/dvb/dvb-core/dvb_filter.c
@@ -72,12 +72,12 @@ static int read_picture_header(u8 *headr, struct mpg_picture *pic, int field, in
72 u8 pct; 72 u8 pct;
73 73
74 if (pr) printk( "Pic header: "); 74 if (pr) printk( "Pic header: ");
75 pic->temporal_reference[field] = (( headr[0] << 2 ) | 75 pic->temporal_reference[field] = (( headr[0] << 2 ) |
76 (headr[1] & 0x03) )& 0x03ff; 76 (headr[1] & 0x03) )& 0x03ff;
77 if (pr) printk( " temp ref: 0x%04x", pic->temporal_reference[field]); 77 if (pr) printk( " temp ref: 0x%04x", pic->temporal_reference[field]);
78 78
79 pct = ( headr[1] >> 2 ) & 0x07; 79 pct = ( headr[1] >> 2 ) & 0x07;
80 pic->picture_coding_type[field] = pct; 80 pic->picture_coding_type[field] = pct;
81 if (pr) { 81 if (pr) {
82 switch(pct){ 82 switch(pct){
83 case I_FRAME: 83 case I_FRAME:
@@ -93,17 +93,17 @@ static int read_picture_header(u8 *headr, struct mpg_picture *pic, int field, in
93 } 93 }
94 94
95 95
96 pic->vinfo.vbv_delay = (( headr[1] >> 5 ) | ( headr[2] << 3) | 96 pic->vinfo.vbv_delay = (( headr[1] >> 5 ) | ( headr[2] << 3) |
97 ( (headr[3] & 0x1F) << 11) ) & 0xffff; 97 ( (headr[3] & 0x1F) << 11) ) & 0xffff;
98 98
99 if (pr) printk( " vbv delay: 0x%04x", pic->vinfo.vbv_delay); 99 if (pr) printk( " vbv delay: 0x%04x", pic->vinfo.vbv_delay);
100 100
101 pic->picture_header_parameter = ( headr[3] & 0xe0 ) | 101 pic->picture_header_parameter = ( headr[3] & 0xe0 ) |
102 ((headr[4] & 0x80) >> 3); 102 ((headr[4] & 0x80) >> 3);
103 103
104 if ( pct == B_FRAME ){ 104 if ( pct == B_FRAME ){
105 pic->picture_header_parameter |= ( headr[4] >> 3 ) & 0x0f; 105 pic->picture_header_parameter |= ( headr[4] >> 3 ) & 0x0f;
106 } 106 }
107 if (pr) printk( " pic head param: 0x%x", 107 if (pr) printk( " pic head param: 0x%x",
108 pic->picture_header_parameter); 108 pic->picture_header_parameter);
109 109
@@ -124,18 +124,18 @@ static int read_gop_header(u8 *headr, struct mpg_picture *pic, int pr)
124 ((headr[0]<<4)& 0x30)| ((headr[1]>>4)& 0x0F), 124 ((headr[0]<<4)& 0x30)| ((headr[1]>>4)& 0x0F),
125 ((headr[1]<<3)& 0x38)| ((headr[2]>>5)& 0x0F)); 125 ((headr[1]<<3)& 0x38)| ((headr[2]>>5)& 0x0F));
126 126
127 if ( ( headr[3] & 0x40 ) != 0 ){ 127 if ( ( headr[3] & 0x40 ) != 0 ){
128 pic->closed_gop = 1; 128 pic->closed_gop = 1;
129 } else { 129 } else {
130 pic->closed_gop = 0; 130 pic->closed_gop = 0;
131 } 131 }
132 if (pr) printk("closed: %d", pic->closed_gop); 132 if (pr) printk("closed: %d", pic->closed_gop);
133 133
134 if ( ( headr[3] & 0x20 ) != 0 ){ 134 if ( ( headr[3] & 0x20 ) != 0 ){
135 pic->broken_link = 1; 135 pic->broken_link = 1;
136 } else { 136 } else {
137 pic->broken_link = 0; 137 pic->broken_link = 0;
138 } 138 }
139 if (pr) printk(" broken: %d\n", pic->broken_link); 139 if (pr) printk(" broken: %d\n", pic->broken_link);
140 140
141 return 0; 141 return 0;
@@ -146,7 +146,7 @@ static int read_gop_header(u8 *headr, struct mpg_picture *pic, int pr)
146/* needs 8 byte input */ 146/* needs 8 byte input */
147static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr) 147static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr)
148{ 148{
149 int sw; 149 int sw;
150 int form = -1; 150 int form = -1;
151 151
152 if (pr) printk("Reading sequence header\n"); 152 if (pr) printk("Reading sequence header\n");
@@ -154,9 +154,9 @@ static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr)
154 vi->horizontal_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4); 154 vi->horizontal_size = ((headr[1] &0xF0) >> 4) | (headr[0] << 4);
155 vi->vertical_size = ((headr[1] &0x0F) << 8) | (headr[2]); 155 vi->vertical_size = ((headr[1] &0x0F) << 8) | (headr[2]);
156 156
157 sw = (int)((headr[3]&0xF0) >> 4) ; 157 sw = (int)((headr[3]&0xF0) >> 4) ;
158 158
159 switch( sw ){ 159 switch( sw ){
160 case 1: 160 case 1:
161 if (pr) 161 if (pr)
162 printk("Videostream: ASPECT: 1:1"); 162 printk("Videostream: ASPECT: 1:1");
@@ -165,84 +165,84 @@ static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr)
165 case 2: 165 case 2:
166 if (pr) 166 if (pr)
167 printk("Videostream: ASPECT: 4:3"); 167 printk("Videostream: ASPECT: 4:3");
168 vi->aspect_ratio = 133; 168 vi->aspect_ratio = 133;
169 break; 169 break;
170 case 3: 170 case 3:
171 if (pr) 171 if (pr)
172 printk("Videostream: ASPECT: 16:9"); 172 printk("Videostream: ASPECT: 16:9");
173 vi->aspect_ratio = 177; 173 vi->aspect_ratio = 177;
174 break; 174 break;
175 case 4: 175 case 4:
176 if (pr) 176 if (pr)
177 printk("Videostream: ASPECT: 2.21:1"); 177 printk("Videostream: ASPECT: 2.21:1");
178 vi->aspect_ratio = 221; 178 vi->aspect_ratio = 221;
179 break; 179 break;
180 180
181 case 5 ... 15: 181 case 5 ... 15:
182 if (pr) 182 if (pr)
183 printk("Videostream: ASPECT: reserved"); 183 printk("Videostream: ASPECT: reserved");
184 vi->aspect_ratio = 0; 184 vi->aspect_ratio = 0;
185 break; 185 break;
186 186
187 default: 187 default:
188 vi->aspect_ratio = 0; 188 vi->aspect_ratio = 0;
189 return -1; 189 return -1;
190 } 190 }
191 191
192 if (pr) 192 if (pr)
193 printk(" Size = %dx%d",vi->horizontal_size,vi->vertical_size); 193 printk(" Size = %dx%d",vi->horizontal_size,vi->vertical_size);
194 194
195 sw = (int)(headr[3]&0x0F); 195 sw = (int)(headr[3]&0x0F);
196 196
197 switch ( sw ) { 197 switch ( sw ) {
198 case 1: 198 case 1:
199 if (pr) 199 if (pr)
200 printk(" FRate: 23.976 fps"); 200 printk(" FRate: 23.976 fps");
201 vi->framerate = 23976; 201 vi->framerate = 23976;
202 form = -1; 202 form = -1;
203 break; 203 break;
204 case 2: 204 case 2:
205 if (pr) 205 if (pr)
206 printk(" FRate: 24 fps"); 206 printk(" FRate: 24 fps");
207 vi->framerate = 24000; 207 vi->framerate = 24000;
208 form = -1; 208 form = -1;
209 break; 209 break;
210 case 3: 210 case 3:
211 if (pr) 211 if (pr)
212 printk(" FRate: 25 fps"); 212 printk(" FRate: 25 fps");
213 vi->framerate = 25000; 213 vi->framerate = 25000;
214 form = VIDEO_MODE_PAL; 214 form = VIDEO_MODE_PAL;
215 break; 215 break;
216 case 4: 216 case 4:
217 if (pr) 217 if (pr)
218 printk(" FRate: 29.97 fps"); 218 printk(" FRate: 29.97 fps");
219 vi->framerate = 29970; 219 vi->framerate = 29970;
220 form = VIDEO_MODE_NTSC; 220 form = VIDEO_MODE_NTSC;
221 break; 221 break;
222 case 5: 222 case 5:
223 if (pr) 223 if (pr)
224 printk(" FRate: 30 fps"); 224 printk(" FRate: 30 fps");
225 vi->framerate = 30000; 225 vi->framerate = 30000;
226 form = VIDEO_MODE_NTSC; 226 form = VIDEO_MODE_NTSC;
227 break; 227 break;
228 case 6: 228 case 6:
229 if (pr) 229 if (pr)
230 printk(" FRate: 50 fps"); 230 printk(" FRate: 50 fps");
231 vi->framerate = 50000; 231 vi->framerate = 50000;
232 form = VIDEO_MODE_PAL; 232 form = VIDEO_MODE_PAL;
233 break; 233 break;
234 case 7: 234 case 7:
235 if (pr) 235 if (pr)
236 printk(" FRate: 60 fps"); 236 printk(" FRate: 60 fps");
237 vi->framerate = 60000; 237 vi->framerate = 60000;
238 form = VIDEO_MODE_NTSC; 238 form = VIDEO_MODE_NTSC;
239 break; 239 break;
240 } 240 }
241 241
242 vi->bit_rate = (headr[4] << 10) | (headr[5] << 2) | (headr[6] & 0x03); 242 vi->bit_rate = (headr[4] << 10) | (headr[5] << 2) | (headr[6] & 0x03);
243 243
244 vi->vbv_buffer_size 244 vi->vbv_buffer_size
245 = (( headr[6] & 0xF8) >> 3 ) | (( headr[7] & 0x1F )<< 5); 245 = (( headr[6] & 0xF8) >> 3 ) | (( headr[7] & 0x1F )<< 5);
246 246
247 if (pr){ 247 if (pr){
248 printk(" BRate: %d Mbit/s",4*(vi->bit_rate)/10000); 248 printk(" BRate: %d Mbit/s",4*(vi->bit_rate)/10000);
@@ -250,7 +250,7 @@ static int read_sequence_header(u8 *headr, struct dvb_video_info *vi, int pr)
250 printk("\n"); 250 printk("\n");
251 } 251 }
252 252
253 vi->video_format = form; 253 vi->video_format = form;
254 254
255 return 0; 255 return 0;
256} 256}
@@ -308,7 +308,7 @@ static int get_ainfo(u8 *mbuf, int count, struct dvb_audio_info *ai, int pr)
308 if (!found) return -1; 308 if (!found) return -1;
309 309
310 if (c+3 >= count) return -1; 310 if (c+3 >= count) return -1;
311 headr = mbuf+c; 311 headr = mbuf+c;
312 312
313 ai->layer = (headr[1] & 0x06) >> 1; 313 ai->layer = (headr[1] & 0x06) >> 1;
314 314
@@ -368,7 +368,7 @@ int dvb_filter_get_ac3info(u8 *mbuf, int count, struct dvb_audio_info *ai, int p
368 if (c+5 >= count) return -1; 368 if (c+5 >= count) return -1;
369 369
370 ai->layer = 0; // 0 for AC3 370 ai->layer = 0; // 0 for AC3
371 headr = mbuf+c+2; 371 headr = mbuf+c+2;
372 372
373 frame = (headr[2]&0x3f); 373 frame = (headr[2]&0x3f);
374 ai->bit_rate = ac3_bitrates[frame >> 1]*1000; 374 ai->bit_rate = ac3_bitrates[frame >> 1]*1000;
@@ -396,159 +396,159 @@ EXPORT_SYMBOL(dvb_filter_get_ac3info);
396#if 0 396#if 0
397static u8 *skip_pes_header(u8 **bufp) 397static u8 *skip_pes_header(u8 **bufp)
398{ 398{
399 u8 *inbuf = *bufp; 399 u8 *inbuf = *bufp;
400 u8 *buf = inbuf; 400 u8 *buf = inbuf;
401 u8 *pts = NULL; 401 u8 *pts = NULL;
402 int skip = 0; 402 int skip = 0;
403 403
404 static const int mpeg1_skip_table[16] = { 404 static const int mpeg1_skip_table[16] = {
405 1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff, 405 1, 0xffff, 5, 10, 0xffff, 0xffff, 0xffff, 0xffff,
406 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff 406 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff
407 }; 407 };
408 408
409 409
410 if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */ 410 if ((inbuf[6] & 0xc0) == 0x80){ /* mpeg2 */
411 if (buf[7] & PTS_ONLY) 411 if (buf[7] & PTS_ONLY)
412 pts = buf+9; 412 pts = buf+9;
413 else pts = NULL; 413 else pts = NULL;
414 buf = inbuf + 9 + inbuf[8]; 414 buf = inbuf + 9 + inbuf[8];
415 } else { /* mpeg1 */ 415 } else { /* mpeg1 */
416 for (buf = inbuf + 6; *buf == 0xff; buf++) 416 for (buf = inbuf + 6; *buf == 0xff; buf++)
417 if (buf == inbuf + 6 + 16) { 417 if (buf == inbuf + 6 + 16) {
418 break; 418 break;
419 } 419 }
420 if ((*buf & 0xc0) == 0x40) 420 if ((*buf & 0xc0) == 0x40)
421 buf += 2; 421 buf += 2;
422 skip = mpeg1_skip_table [*buf >> 4]; 422 skip = mpeg1_skip_table [*buf >> 4];
423 if (skip == 5 || skip == 10) pts = buf; 423 if (skip == 5 || skip == 10) pts = buf;
424 else pts = NULL; 424 else pts = NULL;
425 425
426 buf += mpeg1_skip_table [*buf >> 4]; 426 buf += mpeg1_skip_table [*buf >> 4];
427 } 427 }
428 428
429 *bufp = buf; 429 *bufp = buf;
430 return pts; 430 return pts;
431} 431}
432#endif 432#endif
433 433
434#if 0 434#if 0
435static void initialize_quant_matrix( u32 *matrix ) 435static void initialize_quant_matrix( u32 *matrix )
436{ 436{
437 int i; 437 int i;
438 438
439 matrix[0] = 0x08101013; 439 matrix[0] = 0x08101013;
440 matrix[1] = 0x10131616; 440 matrix[1] = 0x10131616;
441 matrix[2] = 0x16161616; 441 matrix[2] = 0x16161616;
442 matrix[3] = 0x1a181a1b; 442 matrix[3] = 0x1a181a1b;
443 matrix[4] = 0x1b1b1a1a; 443 matrix[4] = 0x1b1b1a1a;
444 matrix[5] = 0x1a1a1b1b; 444 matrix[5] = 0x1a1a1b1b;
445 matrix[6] = 0x1b1d1d1d; 445 matrix[6] = 0x1b1d1d1d;
446 matrix[7] = 0x2222221d; 446 matrix[7] = 0x2222221d;
447 matrix[8] = 0x1d1d1b1b; 447 matrix[8] = 0x1d1d1b1b;
448 matrix[9] = 0x1d1d2020; 448 matrix[9] = 0x1d1d2020;
449 matrix[10] = 0x22222526; 449 matrix[10] = 0x22222526;
450 matrix[11] = 0x25232322; 450 matrix[11] = 0x25232322;
451 matrix[12] = 0x23262628; 451 matrix[12] = 0x23262628;
452 matrix[13] = 0x28283030; 452 matrix[13] = 0x28283030;
453 matrix[14] = 0x2e2e3838; 453 matrix[14] = 0x2e2e3838;
454 matrix[15] = 0x3a454553; 454 matrix[15] = 0x3a454553;
455 455
456 for ( i = 16 ; i < 32 ; i++ ) 456 for ( i = 16 ; i < 32 ; i++ )
457 matrix[i] = 0x10101010; 457 matrix[i] = 0x10101010;
458} 458}
459#endif 459#endif
460 460
461#if 0 461#if 0
462static void initialize_mpg_picture(struct mpg_picture *pic) 462static void initialize_mpg_picture(struct mpg_picture *pic)
463{ 463{
464 int i; 464 int i;
465 465
466 /* set MPEG1 */ 466 /* set MPEG1 */
467 pic->mpeg1_flag = 1; 467 pic->mpeg1_flag = 1;
468 pic->profile_and_level = 0x4A ; /* MP@LL */ 468 pic->profile_and_level = 0x4A ; /* MP@LL */
469 pic->progressive_sequence = 1; 469 pic->progressive_sequence = 1;
470 pic->low_delay = 0; 470 pic->low_delay = 0;
471 471
472 pic->sequence_display_extension_flag = 0; 472 pic->sequence_display_extension_flag = 0;
473 for ( i = 0 ; i < 4 ; i++ ){ 473 for ( i = 0 ; i < 4 ; i++ ){
474 pic->frame_centre_horizontal_offset[i] = 0; 474 pic->frame_centre_horizontal_offset[i] = 0;
475 pic->frame_centre_vertical_offset[i] = 0; 475 pic->frame_centre_vertical_offset[i] = 0;
476 } 476 }
477 pic->last_frame_centre_horizontal_offset = 0; 477 pic->last_frame_centre_horizontal_offset = 0;
478 pic->last_frame_centre_vertical_offset = 0; 478 pic->last_frame_centre_vertical_offset = 0;
479 479
480 pic->picture_display_extension_flag[0] = 0; 480 pic->picture_display_extension_flag[0] = 0;
481 pic->picture_display_extension_flag[1] = 0; 481 pic->picture_display_extension_flag[1] = 0;
482 pic->sequence_header_flag = 0; 482 pic->sequence_header_flag = 0;
483 pic->gop_flag = 0; 483 pic->gop_flag = 0;
484 pic->sequence_end_flag = 0; 484 pic->sequence_end_flag = 0;
485} 485}
486#endif 486#endif
487 487
488#if 0 488#if 0
489static void mpg_set_picture_parameter( int32_t field_type, struct mpg_picture *pic ) 489static void mpg_set_picture_parameter( int32_t field_type, struct mpg_picture *pic )
490{ 490{
491 int16_t last_h_offset; 491 int16_t last_h_offset;
492 int16_t last_v_offset; 492 int16_t last_v_offset;
493 493
494 int16_t *p_h_offset; 494 int16_t *p_h_offset;
495 int16_t *p_v_offset; 495 int16_t *p_v_offset;
496 496
497 if ( pic->mpeg1_flag ){ 497 if ( pic->mpeg1_flag ){
498 pic->picture_structure[field_type] = VIDEO_FRAME_PICTURE; 498 pic->picture_structure[field_type] = VIDEO_FRAME_PICTURE;
499 pic->top_field_first = 0; 499 pic->top_field_first = 0;
500 pic->repeat_first_field = 0; 500 pic->repeat_first_field = 0;
501 pic->progressive_frame = 1; 501 pic->progressive_frame = 1;
502 pic->picture_coding_parameter = 0x000010; 502 pic->picture_coding_parameter = 0x000010;
503 } 503 }
504 504
505 /* Reset flag */ 505 /* Reset flag */
506 pic->picture_display_extension_flag[field_type] = 0; 506 pic->picture_display_extension_flag[field_type] = 0;
507 507
508 last_h_offset = pic->last_frame_centre_horizontal_offset; 508 last_h_offset = pic->last_frame_centre_horizontal_offset;
509 last_v_offset = pic->last_frame_centre_vertical_offset; 509 last_v_offset = pic->last_frame_centre_vertical_offset;
510 if ( field_type == FIRST_FIELD ){ 510 if ( field_type == FIRST_FIELD ){
511 p_h_offset = pic->frame_centre_horizontal_offset; 511 p_h_offset = pic->frame_centre_horizontal_offset;
512 p_v_offset = pic->frame_centre_vertical_offset; 512 p_v_offset = pic->frame_centre_vertical_offset;
513 *p_h_offset = last_h_offset; 513 *p_h_offset = last_h_offset;
514 *(p_h_offset + 1) = last_h_offset; 514 *(p_h_offset + 1) = last_h_offset;
515 *(p_h_offset + 2) = last_h_offset; 515 *(p_h_offset + 2) = last_h_offset;
516 *p_v_offset = last_v_offset; 516 *p_v_offset = last_v_offset;
517 *(p_v_offset + 1) = last_v_offset; 517 *(p_v_offset + 1) = last_v_offset;
518 *(p_v_offset + 2) = last_v_offset; 518 *(p_v_offset + 2) = last_v_offset;
519 } else { 519 } else {
520 pic->frame_centre_horizontal_offset[3] = last_h_offset; 520 pic->frame_centre_horizontal_offset[3] = last_h_offset;
521 pic->frame_centre_vertical_offset[3] = last_v_offset; 521 pic->frame_centre_vertical_offset[3] = last_v_offset;
522 } 522 }
523} 523}
524#endif 524#endif
525 525
526#if 0 526#if 0
527static void init_mpg_picture( struct mpg_picture *pic, int chan, int32_t field_type) 527static void init_mpg_picture( struct mpg_picture *pic, int chan, int32_t field_type)
528{ 528{
529 pic->picture_header = 0; 529 pic->picture_header = 0;
530 pic->sequence_header_data 530 pic->sequence_header_data
531 = ( INIT_HORIZONTAL_SIZE << 20 ) 531 = ( INIT_HORIZONTAL_SIZE << 20 )
532 | ( INIT_VERTICAL_SIZE << 8 ) 532 | ( INIT_VERTICAL_SIZE << 8 )
533 | ( INIT_ASPECT_RATIO << 4 ) 533 | ( INIT_ASPECT_RATIO << 4 )
534 | ( INIT_FRAME_RATE ); 534 | ( INIT_FRAME_RATE );
535 pic->mpeg1_flag = 0; 535 pic->mpeg1_flag = 0;
536 pic->vinfo.horizontal_size 536 pic->vinfo.horizontal_size
537 = INIT_DISP_HORIZONTAL_SIZE; 537 = INIT_DISP_HORIZONTAL_SIZE;
538 pic->vinfo.vertical_size 538 pic->vinfo.vertical_size
539 = INIT_DISP_VERTICAL_SIZE; 539 = INIT_DISP_VERTICAL_SIZE;
540 pic->picture_display_extension_flag[field_type] 540 pic->picture_display_extension_flag[field_type]
541 = 0; 541 = 0;
542 pic->pts_flag[field_type] = 0; 542 pic->pts_flag[field_type] = 0;
543 543
544 pic->sequence_gop_header = 0; 544 pic->sequence_gop_header = 0;
545 pic->picture_header = 0; 545 pic->picture_header = 0;
546 pic->sequence_header_flag = 0; 546 pic->sequence_header_flag = 0;
547 pic->gop_flag = 0; 547 pic->gop_flag = 0;
548 pic->sequence_end_flag = 0; 548 pic->sequence_end_flag = 0;
549 pic->sequence_display_extension_flag = 0; 549 pic->sequence_display_extension_flag = 0;
550 pic->last_frame_centre_horizontal_offset = 0; 550 pic->last_frame_centre_horizontal_offset = 0;
551 pic->last_frame_centre_vertical_offset = 0; 551 pic->last_frame_centre_vertical_offset = 0;
552 pic->channel = chan; 552 pic->channel = chan;
553} 553}
554#endif 554#endif
@@ -588,11 +588,11 @@ int dvb_filter_pes2ts(struct dvb_filter_pes2ts *p2ts, unsigned char *pes,
588 buf[1]&=~0x40; 588 buf[1]&=~0x40;
589 } 589 }
590 if (!len) 590 if (!len)
591 return 0; 591 return 0;
592 buf[3]=0x30|((p2ts->cc++)&0x0f); 592 buf[3]=0x30|((p2ts->cc++)&0x0f);
593 rest=183-len; 593 rest=183-len;
594 if (rest) { 594 if (rest) {
595 buf[5]=0x00; 595 buf[5]=0x00;
596 if (rest-1) 596 if (rest-1)
597 memset(buf+6, 0xff, rest-1); 597 memset(buf+6, 0xff, rest-1);
598 } 598 }
diff --git a/drivers/media/dvb/dvb-core/dvb_filter.h b/drivers/media/dvb/dvb-core/dvb_filter.h
index b0848f7836b7..375e3be184b1 100644
--- a/drivers/media/dvb/dvb-core/dvb_filter.h
+++ b/drivers/media/dvb/dvb-core/dvb_filter.h
@@ -29,8 +29,8 @@ typedef int (dvb_filter_pes2ts_cb_t) (void *, unsigned char *);
29 29
30struct dvb_filter_pes2ts { 30struct dvb_filter_pes2ts {
31 unsigned char buf[188]; 31 unsigned char buf[188];
32 unsigned char cc; 32 unsigned char cc;
33 dvb_filter_pes2ts_cb_t *cb; 33 dvb_filter_pes2ts_cb_t *cb;
34 void *priv; 34 void *priv;
35}; 35};
36 36
@@ -162,7 +162,7 @@ struct dvb_video_info {
162 u32 bit_rate; 162 u32 bit_rate;
163 u32 comp_bit_rate; 163 u32 comp_bit_rate;
164 u32 vbv_buffer_size; 164 u32 vbv_buffer_size;
165 s16 vbv_delay; 165 s16 vbv_delay;
166 u32 CSPF; 166 u32 CSPF;
167 u32 off; 167 u32 off;
168}; 168};
@@ -173,60 +173,60 @@ struct dvb_video_info {
173#define VIDEO_FRAME_PICTURE 0x03 173#define VIDEO_FRAME_PICTURE 0x03
174 174
175struct mpg_picture { 175struct mpg_picture {
176 int channel; 176 int channel;
177 struct dvb_video_info vinfo; 177 struct dvb_video_info vinfo;
178 u32 *sequence_gop_header; 178 u32 *sequence_gop_header;
179 u32 *picture_header; 179 u32 *picture_header;
180 s32 time_code; 180 s32 time_code;
181 int low_delay; 181 int low_delay;
182 int closed_gop; 182 int closed_gop;
183 int broken_link; 183 int broken_link;
184 int sequence_header_flag; 184 int sequence_header_flag;
185 int gop_flag; 185 int gop_flag;
186 int sequence_end_flag; 186 int sequence_end_flag;
187 187
188 u8 profile_and_level; 188 u8 profile_and_level;
189 s32 picture_coding_parameter; 189 s32 picture_coding_parameter;
190 u32 matrix[32]; 190 u32 matrix[32];
191 s8 matrix_change_flag; 191 s8 matrix_change_flag;
192 192
193 u8 picture_header_parameter; 193 u8 picture_header_parameter;
194 /* bit 0 - 2: bwd f code 194 /* bit 0 - 2: bwd f code
195 bit 3 : fpb vector 195 bit 3 : fpb vector
196 bit 4 - 6: fwd f code 196 bit 4 - 6: fwd f code
197 bit 7 : fpf vector */ 197 bit 7 : fpf vector */
198 198
199 int mpeg1_flag; 199 int mpeg1_flag;
200 int progressive_sequence; 200 int progressive_sequence;
201 int sequence_display_extension_flag; 201 int sequence_display_extension_flag;
202 u32 sequence_header_data; 202 u32 sequence_header_data;
203 s16 last_frame_centre_horizontal_offset; 203 s16 last_frame_centre_horizontal_offset;
204 s16 last_frame_centre_vertical_offset; 204 s16 last_frame_centre_vertical_offset;
205 205
206 u32 pts[2]; /* [0] 1st field, [1] 2nd field */ 206 u32 pts[2]; /* [0] 1st field, [1] 2nd field */
207 int top_field_first; 207 int top_field_first;
208 int repeat_first_field; 208 int repeat_first_field;
209 int progressive_frame; 209 int progressive_frame;
210 int bank; 210 int bank;
211 int forward_bank; 211 int forward_bank;
212 int backward_bank; 212 int backward_bank;
213 int compress; 213 int compress;
214 s16 frame_centre_horizontal_offset[OFF_SIZE]; 214 s16 frame_centre_horizontal_offset[OFF_SIZE];
215 /* [0-2] 1st field, [3] 2nd field */ 215 /* [0-2] 1st field, [3] 2nd field */
216 s16 frame_centre_vertical_offset[OFF_SIZE]; 216 s16 frame_centre_vertical_offset[OFF_SIZE];
217 /* [0-2] 1st field, [3] 2nd field */ 217 /* [0-2] 1st field, [3] 2nd field */
218 s16 temporal_reference[2]; 218 s16 temporal_reference[2];
219 /* [0] 1st field, [1] 2nd field */ 219 /* [0] 1st field, [1] 2nd field */
220 220
221 s8 picture_coding_type[2]; 221 s8 picture_coding_type[2];
222 /* [0] 1st field, [1] 2nd field */ 222 /* [0] 1st field, [1] 2nd field */
223 s8 picture_structure[2]; 223 s8 picture_structure[2];
224 /* [0] 1st field, [1] 2nd field */ 224 /* [0] 1st field, [1] 2nd field */
225 s8 picture_display_extension_flag[2]; 225 s8 picture_display_extension_flag[2];
226 /* [0] 1st field, [1] 2nd field */ 226 /* [0] 1st field, [1] 2nd field */
227 /* picture_display_extenion() 0:no 1:exit*/ 227 /* picture_display_extenion() 0:no 1:exit*/
228 s8 pts_flag[2]; 228 s8 pts_flag[2];
229 /* [0] 1st field, [1] 2nd field */ 229 /* [0] 1st field, [1] 2nd field */
230}; 230};
231 231
232struct dvb_audio_info { 232struct dvb_audio_info {
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 6ffa6b216363..95ea5095e07e 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -372,10 +372,10 @@ static int dvb_frontend_thread(void *data)
372 372
373 snprintf (name, sizeof(name), "kdvb-fe-%i", fe->dvb->num); 373 snprintf (name, sizeof(name), "kdvb-fe-%i", fe->dvb->num);
374 374
375 lock_kernel(); 375 lock_kernel();
376 daemonize(name); 376 daemonize(name);
377 sigfillset(&current->blocked); 377 sigfillset(&current->blocked);
378 unlock_kernel(); 378 unlock_kernel();
379 379
380 fepriv->status = 0; 380 fepriv->status = 0;
381 dvb_frontend_init(fe); 381 dvb_frontend_init(fe);
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h
index 348c9b0b988a..1e0840d02f1f 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.h
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.h
@@ -41,10 +41,10 @@
41#include "dvbdev.h" 41#include "dvbdev.h"
42 42
43struct dvb_frontend_tune_settings { 43struct dvb_frontend_tune_settings {
44 int min_delay_ms; 44 int min_delay_ms;
45 int step_size; 45 int step_size;
46 int max_drift; 46 int max_drift;
47 struct dvb_frontend_parameters parameters; 47 struct dvb_frontend_parameters parameters;
48}; 48};
49 49
50struct dvb_frontend; 50struct dvb_frontend;
diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
index df536bd2e103..86bba81e851e 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -713,7 +713,7 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
713 if (buffer1_len > 32768) 713 if (buffer1_len > 32768)
714 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len); 714 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len);
715 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n", 715 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n",
716 buffer1_len, buffer1_len / TS_SZ, buffer1); */ 716 buffer1_len, buffer1_len / TS_SZ, buffer1); */
717 dvb_net_ule(dev, buffer1, buffer1_len); 717 dvb_net_ule(dev, buffer1, buffer1_len);
718 return 0; 718 return 0;
719} 719}
@@ -721,8 +721,8 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
721 721
722static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len) 722static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
723{ 723{
724 u8 *eth; 724 u8 *eth;
725 struct sk_buff *skb; 725 struct sk_buff *skb;
726 struct net_device_stats *stats = &(((struct dvb_net_priv *) dev->priv)->stats); 726 struct net_device_stats *stats = &(((struct dvb_net_priv *) dev->priv)->stats);
727 int snap = 0; 727 int snap = 0;
728 728
@@ -754,7 +754,7 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
754 return; 754 return;
755 } 755 }
756 snap = 8; 756 snap = 8;
757 } 757 }
758 if (pkt[7]) { 758 if (pkt[7]) {
759 /* FIXME: assemble datagram from multiple sections */ 759 /* FIXME: assemble datagram from multiple sections */
760 stats->rx_errors++; 760 stats->rx_errors++;
@@ -778,14 +778,14 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
778 memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap); 778 memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap);
779 779
780 /* create ethernet header: */ 780 /* create ethernet header: */
781 eth[0]=pkt[0x0b]; 781 eth[0]=pkt[0x0b];
782 eth[1]=pkt[0x0a]; 782 eth[1]=pkt[0x0a];
783 eth[2]=pkt[0x09]; 783 eth[2]=pkt[0x09];
784 eth[3]=pkt[0x08]; 784 eth[3]=pkt[0x08];
785 eth[4]=pkt[0x04]; 785 eth[4]=pkt[0x04];
786 eth[5]=pkt[0x03]; 786 eth[5]=pkt[0x03];
787 787
788 eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0; 788 eth[6]=eth[7]=eth[8]=eth[9]=eth[10]=eth[11]=0;
789 789
790 if (snap) { 790 if (snap) {
791 eth[12] = pkt[18]; 791 eth[12] = pkt[18];
@@ -807,7 +807,7 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
807 807
808 stats->rx_packets++; 808 stats->rx_packets++;
809 stats->rx_bytes+=skb->len; 809 stats->rx_bytes+=skb->len;
810 netif_rx(skb); 810 netif_rx(skb);
811} 811}
812 812
813static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len, 813static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len,
@@ -815,7 +815,7 @@ static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len,
815 struct dmx_section_filter *filter, 815 struct dmx_section_filter *filter,
816 enum dmx_success success) 816 enum dmx_success success)
817{ 817{
818 struct net_device *dev = filter->priv; 818 struct net_device *dev = filter->priv;
819 819
820 /** 820 /**
821 * we rely on the DVB API definition where exactly one complete 821 * we rely on the DVB API definition where exactly one complete
@@ -885,8 +885,8 @@ static int dvb_net_feed_start(struct net_device *dev)
885{ 885{
886 int ret = 0, i; 886 int ret = 0, i;
887 struct dvb_net_priv *priv = dev->priv; 887 struct dvb_net_priv *priv = dev->priv;
888 struct dmx_demux *demux = priv->demux; 888 struct dmx_demux *demux = priv->demux;
889 unsigned char *mac = (unsigned char *) dev->dev_addr; 889 unsigned char *mac = (unsigned char *) dev->dev_addr;
890 890
891 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode); 891 dprintk("%s: rx_mode %i\n", __FUNCTION__, priv->rx_mode);
892 down(&priv->mutex); 892 down(&priv->mutex);
@@ -1129,12 +1129,12 @@ static int dvb_net_stop(struct net_device *dev)
1129 struct dvb_net_priv *priv = dev->priv; 1129 struct dvb_net_priv *priv = dev->priv;
1130 1130
1131 priv->in_use--; 1131 priv->in_use--;
1132 return dvb_net_feed_stop(dev); 1132 return dvb_net_feed_stop(dev);
1133} 1133}
1134 1134
1135static struct net_device_stats * dvb_net_get_stats(struct net_device *dev) 1135static struct net_device_stats * dvb_net_get_stats(struct net_device *dev)
1136{ 1136{
1137 return &((struct dvb_net_priv*) dev->priv)->stats; 1137 return &((struct dvb_net_priv*) dev->priv)->stats;
1138} 1138}
1139 1139
1140static void dvb_net_setup(struct net_device *dev) 1140static void dvb_net_setup(struct net_device *dev)
@@ -1360,10 +1360,10 @@ static struct file_operations dvb_net_fops = {
1360}; 1360};
1361 1361
1362static struct dvb_device dvbdev_net = { 1362static struct dvb_device dvbdev_net = {
1363 .priv = NULL, 1363 .priv = NULL,
1364 .users = 1, 1364 .users = 1,
1365 .writers = 1, 1365 .writers = 1,
1366 .fops = &dvb_net_fops, 1366 .fops = &dvb_net_fops,
1367}; 1367};
1368 1368
1369 1369
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
index fb6d94a69d71..283c6e9339a4 100644
--- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
+++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
@@ -42,216 +42,216 @@
42 42
43void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len) 43void dvb_ringbuffer_init(struct dvb_ringbuffer *rbuf, void *data, size_t len)
44{ 44{
45 rbuf->pread=rbuf->pwrite=0; 45 rbuf->pread=rbuf->pwrite=0;
46 rbuf->data=data; 46 rbuf->data=data;
47 rbuf->size=len; 47 rbuf->size=len;
48 48
49 init_waitqueue_head(&rbuf->queue); 49 init_waitqueue_head(&rbuf->queue);
50 50
51 spin_lock_init(&(rbuf->lock)); 51 spin_lock_init(&(rbuf->lock));
52} 52}
53 53
54 54
55 55
56int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf) 56int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf)
57{ 57{
58 return (rbuf->pread==rbuf->pwrite); 58 return (rbuf->pread==rbuf->pwrite);
59} 59}
60 60
61 61
62 62
63ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf) 63ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf)
64{ 64{
65 ssize_t free; 65 ssize_t free;
66 66
67 free = rbuf->pread - rbuf->pwrite; 67 free = rbuf->pread - rbuf->pwrite;
68 if (free <= 0) 68 if (free <= 0)
69 free += rbuf->size; 69 free += rbuf->size;
70 return free-1; 70 return free-1;
71} 71}
72 72
73 73
74 74
75ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf) 75ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf)
76{ 76{
77 ssize_t avail; 77 ssize_t avail;
78 78
79 avail = rbuf->pwrite - rbuf->pread; 79 avail = rbuf->pwrite - rbuf->pread;
80 if (avail < 0) 80 if (avail < 0)
81 avail += rbuf->size; 81 avail += rbuf->size;
82 return avail; 82 return avail;
83} 83}
84 84
85 85
86 86
87void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf) 87void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
88{ 88{
89 rbuf->pread = rbuf->pwrite; 89 rbuf->pread = rbuf->pwrite;
90} 90}
91 91
92 92
93 93
94void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf) 94void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf)
95{ 95{
96 unsigned long flags; 96 unsigned long flags;
97 97
98 spin_lock_irqsave(&rbuf->lock, flags); 98 spin_lock_irqsave(&rbuf->lock, flags);
99 dvb_ringbuffer_flush(rbuf); 99 dvb_ringbuffer_flush(rbuf);
100 spin_unlock_irqrestore(&rbuf->lock, flags); 100 spin_unlock_irqrestore(&rbuf->lock, flags);
101 101
102 wake_up(&rbuf->queue); 102 wake_up(&rbuf->queue);
103} 103}
104 104
105 105
106 106
107ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, size_t len, int usermem) 107ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, size_t len, int usermem)
108{ 108{
109 size_t todo = len; 109 size_t todo = len;
110 size_t split; 110 size_t split;
111 111
112 split = (rbuf->pread + len > rbuf->size) ? rbuf->size - rbuf->pread : 0; 112 split = (rbuf->pread + len > rbuf->size) ? rbuf->size - rbuf->pread : 0;
113 if (split > 0) { 113 if (split > 0) {
114 if (!usermem) 114 if (!usermem)
115 memcpy(buf, rbuf->data+rbuf->pread, split); 115 memcpy(buf, rbuf->data+rbuf->pread, split);
116 else 116 else
117 if (copy_to_user(buf, rbuf->data+rbuf->pread, split)) 117 if (copy_to_user(buf, rbuf->data+rbuf->pread, split))
118 return -EFAULT; 118 return -EFAULT;
119 buf += split; 119 buf += split;
120 todo -= split; 120 todo -= split;
121 rbuf->pread = 0; 121 rbuf->pread = 0;
122 } 122 }
123 if (!usermem) 123 if (!usermem)
124 memcpy(buf, rbuf->data+rbuf->pread, todo); 124 memcpy(buf, rbuf->data+rbuf->pread, todo);
125 else 125 else
126 if (copy_to_user(buf, rbuf->data+rbuf->pread, todo)) 126 if (copy_to_user(buf, rbuf->data+rbuf->pread, todo))
127 return -EFAULT; 127 return -EFAULT;
128 128
129 rbuf->pread = (rbuf->pread + todo) % rbuf->size; 129 rbuf->pread = (rbuf->pread + todo) % rbuf->size;
130 130
131 return len; 131 return len;
132} 132}
133 133
134 134
135 135
136ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, size_t len) 136ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, size_t len)
137{ 137{
138 size_t todo = len; 138 size_t todo = len;
139 size_t split; 139 size_t split;
140 140
141 split = (rbuf->pwrite + len > rbuf->size) ? rbuf->size - rbuf->pwrite : 0; 141 split = (rbuf->pwrite + len > rbuf->size) ? rbuf->size - rbuf->pwrite : 0;
142 142
143 if (split > 0) { 143 if (split > 0) {
144 memcpy(rbuf->data+rbuf->pwrite, buf, split); 144 memcpy(rbuf->data+rbuf->pwrite, buf, split);
145 buf += split; 145 buf += split;
146 todo -= split; 146 todo -= split;
147 rbuf->pwrite = 0; 147 rbuf->pwrite = 0;
148 } 148 }
149 memcpy(rbuf->data+rbuf->pwrite, buf, todo); 149 memcpy(rbuf->data+rbuf->pwrite, buf, todo);
150 rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size; 150 rbuf->pwrite = (rbuf->pwrite + todo) % rbuf->size;
151 151
152 return len; 152 return len;
153} 153}
154 154
155ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, size_t len) 155ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, size_t len)
156{ 156{
157 int status; 157 int status;
158 ssize_t oldpwrite = rbuf->pwrite; 158 ssize_t oldpwrite = rbuf->pwrite;
159 159
160 DVB_RINGBUFFER_WRITE_BYTE(rbuf, len >> 8); 160 DVB_RINGBUFFER_WRITE_BYTE(rbuf, len >> 8);
161 DVB_RINGBUFFER_WRITE_BYTE(rbuf, len & 0xff); 161 DVB_RINGBUFFER_WRITE_BYTE(rbuf, len & 0xff);
162 DVB_RINGBUFFER_WRITE_BYTE(rbuf, PKT_READY); 162 DVB_RINGBUFFER_WRITE_BYTE(rbuf, PKT_READY);
163 status = dvb_ringbuffer_write(rbuf, buf, len); 163 status = dvb_ringbuffer_write(rbuf, buf, len);
164 164
165 if (status < 0) rbuf->pwrite = oldpwrite; 165 if (status < 0) rbuf->pwrite = oldpwrite;
166 return status; 166 return status;
167} 167}
168 168
169ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx, 169ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,
170 int offset, u8* buf, size_t len, int usermem) 170 int offset, u8* buf, size_t len, int usermem)
171{ 171{
172 size_t todo; 172 size_t todo;
173 size_t split; 173 size_t split;
174 size_t pktlen; 174 size_t pktlen;
175 175
176 pktlen = rbuf->data[idx] << 8; 176 pktlen = rbuf->data[idx] << 8;
177 pktlen |= rbuf->data[(idx + 1) % rbuf->size]; 177 pktlen |= rbuf->data[(idx + 1) % rbuf->size];
178 if (offset > pktlen) return -EINVAL; 178 if (offset > pktlen) return -EINVAL;
179 if ((offset + len) > pktlen) len = pktlen - offset; 179 if ((offset + len) > pktlen) len = pktlen - offset;
180 180
181 idx = (idx + DVB_RINGBUFFER_PKTHDRSIZE + offset) % rbuf->size; 181 idx = (idx + DVB_RINGBUFFER_PKTHDRSIZE + offset) % rbuf->size;
182 todo = len; 182 todo = len;
183 split = ((idx + len) > rbuf->size) ? rbuf->size - idx : 0; 183 split = ((idx + len) > rbuf->size) ? rbuf->size - idx : 0;
184 if (split > 0) { 184 if (split > 0) {
185 if (!usermem) 185 if (!usermem)
186 memcpy(buf, rbuf->data+idx, split); 186 memcpy(buf, rbuf->data+idx, split);
187 else 187 else
188 if (copy_to_user(buf, rbuf->data+idx, split)) 188 if (copy_to_user(buf, rbuf->data+idx, split))
189 return -EFAULT; 189 return -EFAULT;
190 buf += split; 190 buf += split;
191 todo -= split; 191 todo -= split;
192 idx = 0; 192 idx = 0;
193 } 193 }
194 if (!usermem) 194 if (!usermem)
195 memcpy(buf, rbuf->data+idx, todo); 195 memcpy(buf, rbuf->data+idx, todo);
196 else 196 else
197 if (copy_to_user(buf, rbuf->data+idx, todo)) 197 if (copy_to_user(buf, rbuf->data+idx, todo))
198 return -EFAULT; 198 return -EFAULT;
199 199
200 return len; 200 return len;
201} 201}
202 202
203void dvb_ringbuffer_pkt_dispose(struct dvb_ringbuffer *rbuf, size_t idx) 203void dvb_ringbuffer_pkt_dispose(struct dvb_ringbuffer *rbuf, size_t idx)
204{ 204{
205 size_t pktlen; 205 size_t pktlen;
206 206
207 rbuf->data[(idx + 2) % rbuf->size] = PKT_DISPOSED; 207 rbuf->data[(idx + 2) % rbuf->size] = PKT_DISPOSED;
208 208
209 // clean up disposed packets 209 // clean up disposed packets
210 while(dvb_ringbuffer_avail(rbuf) > DVB_RINGBUFFER_PKTHDRSIZE) { 210 while(dvb_ringbuffer_avail(rbuf) > DVB_RINGBUFFER_PKTHDRSIZE) {
211 if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) { 211 if (DVB_RINGBUFFER_PEEK(rbuf, 2) == PKT_DISPOSED) {
212 pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8; 212 pktlen = DVB_RINGBUFFER_PEEK(rbuf, 0) << 8;
213 pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1); 213 pktlen |= DVB_RINGBUFFER_PEEK(rbuf, 1);
214 DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE); 214 DVB_RINGBUFFER_SKIP(rbuf, pktlen + DVB_RINGBUFFER_PKTHDRSIZE);
215 } else { 215 } else {
216 // first packet is not disposed, so we stop cleaning now 216 // first packet is not disposed, so we stop cleaning now
217 break; 217 break;
218 } 218 }
219 } 219 }
220} 220}
221 221
222ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t* pktlen) 222ssize_t dvb_ringbuffer_pkt_next(struct dvb_ringbuffer *rbuf, size_t idx, size_t* pktlen)
223{ 223{
224 int consumed; 224 int consumed;
225 int curpktlen; 225 int curpktlen;
226 int curpktstatus; 226 int curpktstatus;
227 227
228 if (idx == -1) { 228 if (idx == -1) {
229 idx = rbuf->pread; 229 idx = rbuf->pread;
230 } else { 230 } else {
231 curpktlen = rbuf->data[idx] << 8; 231 curpktlen = rbuf->data[idx] << 8;
232 curpktlen |= rbuf->data[(idx + 1) % rbuf->size]; 232 curpktlen |= rbuf->data[(idx + 1) % rbuf->size];
233 idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size; 233 idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
234 } 234 }
235 235
236 consumed = (idx - rbuf->pread) % rbuf->size; 236 consumed = (idx - rbuf->pread) % rbuf->size;
237 237
238 while((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) { 238 while((dvb_ringbuffer_avail(rbuf) - consumed) > DVB_RINGBUFFER_PKTHDRSIZE) {
239 239
240 curpktlen = rbuf->data[idx] << 8; 240 curpktlen = rbuf->data[idx] << 8;
241 curpktlen |= rbuf->data[(idx + 1) % rbuf->size]; 241 curpktlen |= rbuf->data[(idx + 1) % rbuf->size];
242 curpktstatus = rbuf->data[(idx + 2) % rbuf->size]; 242 curpktstatus = rbuf->data[(idx + 2) % rbuf->size];
243 243
244 if (curpktstatus == PKT_READY) { 244 if (curpktstatus == PKT_READY) {
245 *pktlen = curpktlen; 245 *pktlen = curpktlen;
246 return idx; 246 return idx;
247 } 247 }
248 248
249 consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE; 249 consumed += curpktlen + DVB_RINGBUFFER_PKTHDRSIZE;
250 idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size; 250 idx = (idx + curpktlen + DVB_RINGBUFFER_PKTHDRSIZE) % rbuf->size;
251 } 251 }
252 252
253 // no packets available 253 // no packets available
254 return -1; 254 return -1;
255} 255}
256 256
257 257
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
index d18e9c4ba9ea..fa476f662f82 100644
--- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
+++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
@@ -31,13 +31,13 @@
31#include <linux/wait.h> 31#include <linux/wait.h>
32 32
33struct dvb_ringbuffer { 33struct dvb_ringbuffer {
34 u8 *data; 34 u8 *data;
35 ssize_t size; 35 ssize_t size;
36 ssize_t pread; 36 ssize_t pread;
37 ssize_t pwrite; 37 ssize_t pwrite;
38 38
39 wait_queue_head_t queue; 39 wait_queue_head_t queue;
40 spinlock_t lock; 40 spinlock_t lock;
41}; 41};
42 42
43#define DVB_RINGBUFFER_PKTHDRSIZE 3 43#define DVB_RINGBUFFER_PKTHDRSIZE 3
@@ -106,7 +106,7 @@ extern void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf);
106** returns number of bytes transferred or -EFAULT 106** returns number of bytes transferred or -EFAULT
107*/ 107*/
108extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf, 108extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf,
109 size_t len, int usermem); 109 size_t len, int usermem);
110 110
111 111
112/* write routines & macros */ 112/* write routines & macros */
@@ -121,7 +121,7 @@ extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf,
121** returns number of bytes transferred or -EFAULT 121** returns number of bytes transferred or -EFAULT
122*/ 122*/
123extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf, 123extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf,
124 size_t len); 124 size_t len);
125 125
126 126
127/** 127/**
@@ -133,7 +133,7 @@ extern ssize_t dvb_ringbuffer_write(struct dvb_ringbuffer *rbuf, const u8 *buf,
133 * returns Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL. 133 * returns Number of bytes written, or -EFAULT, -ENOMEM, -EVINAL.
134 */ 134 */
135extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf, 135extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf,
136 size_t len); 136 size_t len);
137 137
138/** 138/**
139 * Read from a packet in the ringbuffer. Note: unlike dvb_ringbuffer_read(), this 139 * Read from a packet in the ringbuffer. Note: unlike dvb_ringbuffer_read(), this
@@ -149,7 +149,7 @@ extern ssize_t dvb_ringbuffer_pkt_write(struct dvb_ringbuffer *rbuf, u8* buf,
149 * returns Number of bytes read, or -EFAULT. 149 * returns Number of bytes read, or -EFAULT.
150 */ 150 */
151extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx, 151extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,
152 int offset, u8* buf, size_t len, int usermem); 152 int offset, u8* buf, size_t len, int usermem);
153 153
154/** 154/**
155 * Dispose of a packet in the ring buffer. 155 * Dispose of a packet in the ring buffer.
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c
index 477b4fa56430..a4aee8665854 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/drivers/media/dvb/dvb-core/dvbdev.c
@@ -47,7 +47,7 @@ static LIST_HEAD(dvb_adapter_list);
47static DECLARE_MUTEX(dvbdev_register_lock); 47static DECLARE_MUTEX(dvbdev_register_lock);
48 48
49static const char * const dnames[] = { 49static const char * const dnames[] = {
50 "video", "audio", "sec", "frontend", "demux", "dvr", "ca", 50 "video", "audio", "sec", "frontend", "demux", "dvr", "ca",
51 "net", "osd" 51 "net", "osd"
52}; 52};
53 53
@@ -90,15 +90,15 @@ static int dvb_device_open(struct inode *inode, struct file *file)
90 90
91 file->private_data = dvbdev; 91 file->private_data = dvbdev;
92 old_fops = file->f_op; 92 old_fops = file->f_op;
93 file->f_op = fops_get(dvbdev->fops); 93 file->f_op = fops_get(dvbdev->fops);
94 if(file->f_op->open) 94 if(file->f_op->open)
95 err = file->f_op->open(inode,file); 95 err = file->f_op->open(inode,file);
96 if (err) { 96 if (err) {
97 fops_put(file->f_op); 97 fops_put(file->f_op);
98 file->f_op = fops_get(old_fops); 98 file->f_op = fops_get(old_fops);
99 } 99 }
100 fops_put(old_fops); 100 fops_put(old_fops);
101 return err; 101 return err;
102 } 102 }
103 return -ENODEV; 103 return -ENODEV;
104} 104}
@@ -117,21 +117,21 @@ static struct cdev dvb_device_cdev = {
117 117
118int dvb_generic_open(struct inode *inode, struct file *file) 118int dvb_generic_open(struct inode *inode, struct file *file)
119{ 119{
120 struct dvb_device *dvbdev = file->private_data; 120 struct dvb_device *dvbdev = file->private_data;
121 121
122 if (!dvbdev) 122 if (!dvbdev)
123 return -ENODEV; 123 return -ENODEV;
124 124
125 if (!dvbdev->users) 125 if (!dvbdev->users)
126 return -EBUSY; 126 return -EBUSY;
127 127
128 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 128 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
129 if (!dvbdev->readers) 129 if (!dvbdev->readers)
130 return -EBUSY; 130 return -EBUSY;
131 dvbdev->readers--; 131 dvbdev->readers--;
132 } else { 132 } else {
133 if (!dvbdev->writers) 133 if (!dvbdev->writers)
134 return -EBUSY; 134 return -EBUSY;
135 dvbdev->writers--; 135 dvbdev->writers--;
136 } 136 }
137 137
@@ -143,10 +143,10 @@ EXPORT_SYMBOL(dvb_generic_open);
143 143
144int dvb_generic_release(struct inode *inode, struct file *file) 144int dvb_generic_release(struct inode *inode, struct file *file)
145{ 145{
146 struct dvb_device *dvbdev = file->private_data; 146 struct dvb_device *dvbdev = file->private_data;
147 147
148 if (!dvbdev) 148 if (!dvbdev)
149 return -ENODEV; 149 return -ENODEV;
150 150
151 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { 151 if ((file->f_flags & O_ACCMODE) == O_RDONLY) {
152 dvbdev->readers++; 152 dvbdev->readers++;
@@ -163,10 +163,10 @@ EXPORT_SYMBOL(dvb_generic_release);
163int dvb_generic_ioctl(struct inode *inode, struct file *file, 163int dvb_generic_ioctl(struct inode *inode, struct file *file,
164 unsigned int cmd, unsigned long arg) 164 unsigned int cmd, unsigned long arg)
165{ 165{
166 struct dvb_device *dvbdev = file->private_data; 166 struct dvb_device *dvbdev = file->private_data;
167 167
168 if (!dvbdev) 168 if (!dvbdev)
169 return -ENODEV; 169 return -ENODEV;
170 170
171 if (!dvbdev->kernel_ioctl) 171 if (!dvbdev->kernel_ioctl)
172 return -EINVAL; 172 return -EINVAL;
@@ -334,63 +334,63 @@ EXPORT_SYMBOL(dvb_unregister_adapter);
334 to the v4l "videodev.o" module, which is unnecessary for some 334 to the v4l "videodev.o" module, which is unnecessary for some
335 cards (ie. the budget dvb-cards don't need the v4l module...) */ 335 cards (ie. the budget dvb-cards don't need the v4l module...) */
336int dvb_usercopy(struct inode *inode, struct file *file, 336int dvb_usercopy(struct inode *inode, struct file *file,
337 unsigned int cmd, unsigned long arg, 337 unsigned int cmd, unsigned long arg,
338 int (*func)(struct inode *inode, struct file *file, 338 int (*func)(struct inode *inode, struct file *file,
339 unsigned int cmd, void *arg)) 339 unsigned int cmd, void *arg))
340{ 340{
341 char sbuf[128]; 341 char sbuf[128];
342 void *mbuf = NULL; 342 void *mbuf = NULL;
343 void *parg = NULL; 343 void *parg = NULL;
344 int err = -EINVAL; 344 int err = -EINVAL;
345 345
346 /* Copy arguments into temp kernel buffer */ 346 /* Copy arguments into temp kernel buffer */
347 switch (_IOC_DIR(cmd)) { 347 switch (_IOC_DIR(cmd)) {
348 case _IOC_NONE: 348 case _IOC_NONE:
349 /* 349 /*
350 * For this command, the pointer is actually an integer 350 * For this command, the pointer is actually an integer
351 * argument. 351 * argument.
352 */ 352 */
353 parg = (void *) arg; 353 parg = (void *) arg;
354 break; 354 break;
355 case _IOC_READ: /* some v4l ioctls are marked wrong ... */ 355 case _IOC_READ: /* some v4l ioctls are marked wrong ... */
356 case _IOC_WRITE: 356 case _IOC_WRITE:
357 case (_IOC_WRITE | _IOC_READ): 357 case (_IOC_WRITE | _IOC_READ):
358 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) { 358 if (_IOC_SIZE(cmd) <= sizeof(sbuf)) {
359 parg = sbuf; 359 parg = sbuf;
360 } else { 360 } else {
361 /* too big to allocate from stack */ 361 /* too big to allocate from stack */
362 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL); 362 mbuf = kmalloc(_IOC_SIZE(cmd),GFP_KERNEL);
363 if (NULL == mbuf) 363 if (NULL == mbuf)
364 return -ENOMEM; 364 return -ENOMEM;
365 parg = mbuf; 365 parg = mbuf;
366 } 366 }
367 367
368 err = -EFAULT; 368 err = -EFAULT;
369 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) 369 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
370 goto out; 370 goto out;
371 break; 371 break;
372 } 372 }
373 373
374 /* call driver */ 374 /* call driver */
375 if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD) 375 if ((err = func(inode, file, cmd, parg)) == -ENOIOCTLCMD)
376 err = -EINVAL; 376 err = -EINVAL;
377 377
378 if (err < 0) 378 if (err < 0)
379 goto out; 379 goto out;
380 380
381 /* Copy results into user buffer */ 381 /* Copy results into user buffer */
382 switch (_IOC_DIR(cmd)) 382 switch (_IOC_DIR(cmd))
383 { 383 {
384 case _IOC_READ: 384 case _IOC_READ:
385 case (_IOC_WRITE | _IOC_READ): 385 case (_IOC_WRITE | _IOC_READ):
386 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd))) 386 if (copy_to_user((void __user *)arg, parg, _IOC_SIZE(cmd)))
387 err = -EFAULT; 387 err = -EFAULT;
388 break; 388 break;
389 } 389 }
390 390
391out: 391out:
392 kfree(mbuf); 392 kfree(mbuf);
393 return err; 393 return err;
394} 394}
395 395
396static int __init init_dvbdev(void) 396static int __init init_dvbdev(void)
@@ -427,10 +427,10 @@ error:
427 427
428static void __exit exit_dvbdev(void) 428static void __exit exit_dvbdev(void)
429{ 429{
430 devfs_remove("dvb"); 430 devfs_remove("dvb");
431 class_destroy(dvb_class); 431 class_destroy(dvb_class);
432 cdev_del(&dvb_device_cdev); 432 cdev_del(&dvb_device_cdev);
433 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS); 433 unregister_chrdev_region(MKDEV(DVB_MAJOR, 0), MAX_DVB_MINORS);
434} 434}
435 435
436module_init(init_dvbdev); 436module_init(init_dvbdev);
diff --git a/drivers/media/dvb/dvb-core/dvbdev.h b/drivers/media/dvb/dvb-core/dvbdev.h
index a251867f30f1..0cc6e4a0e27c 100644
--- a/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/drivers/media/dvb/dvb-core/dvbdev.h
@@ -68,8 +68,8 @@ struct dvb_device {
68 int writers; 68 int writers;
69 int users; 69 int users;
70 70
71 /* don't really need those !? -- FIXME: use video_usercopy */ 71 /* don't really need those !? -- FIXME: use video_usercopy */
72 int (*kernel_ioctl)(struct inode *inode, struct file *file, 72 int (*kernel_ioctl)(struct inode *inode, struct file *file,
73 unsigned int cmd, void *arg); 73 unsigned int cmd, void *arg);
74 74
75 void *priv; 75 void *priv;
@@ -97,7 +97,7 @@ we simply define out own dvb_usercopy(), which will hopefully become
97generic_usercopy() someday... */ 97generic_usercopy() someday... */
98 98
99extern int dvb_usercopy(struct inode *inode, struct file *file, 99extern int dvb_usercopy(struct inode *inode, struct file *file,
100 unsigned int cmd, unsigned long arg, 100 unsigned int cmd, unsigned long arg,
101 int (*func)(struct inode *inode, struct file *file, 101 int (*func)(struct inode *inode, struct file *file,
102 unsigned int cmd, void *arg)); 102 unsigned int cmd, void *arg));
103 103
diff --git a/drivers/media/dvb/dvb-usb/a800.c b/drivers/media/dvb/dvb-usb/a800.c
index 8c7beffb045f..ce44aa6bbb83 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -144,7 +144,6 @@ static struct dvb_usb_properties a800_properties = {
144}; 144};
145 145
146static struct usb_driver a800_driver = { 146static struct usb_driver a800_driver = {
147 .owner = THIS_MODULE,
148 .name = "dvb_usb_a800", 147 .name = "dvb_usb_a800",
149 .probe = a800_probe, 148 .probe = a800_probe,
150 .disconnect = dvb_usb_device_exit, 149 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index 3fe383f4bb4c..d05fab01cccd 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -241,7 +241,6 @@ static struct dvb_usb_properties cxusb_properties = {
241}; 241};
242 242
243static struct usb_driver cxusb_driver = { 243static struct usb_driver cxusb_driver = {
244 .owner = THIS_MODULE,
245 .name = "dvb_usb_cxusb", 244 .name = "dvb_usb_cxusb",
246 .probe = cxusb_probe, 245 .probe = cxusb_probe,
247 .disconnect = dvb_usb_device_exit, 246 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mb.c b/drivers/media/dvb/dvb-usb/dibusb-mb.c
index aa271a2496d5..52ac3e5adf5d 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mb.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mb.c
@@ -373,7 +373,6 @@ static struct dvb_usb_properties artec_t1_usb2_properties = {
373}; 373};
374 374
375static struct usb_driver dibusb_driver = { 375static struct usb_driver dibusb_driver = {
376 .owner = THIS_MODULE,
377 .name = "dvb_usb_dibusb_mb", 376 .name = "dvb_usb_dibusb_mb",
378 .probe = dibusb_probe, 377 .probe = dibusb_probe,
379 .disconnect = dvb_usb_device_exit, 378 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/dibusb-mc.c b/drivers/media/dvb/dvb-usb/dibusb-mc.c
index 6a0912eab396..55802fba3c29 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-mc.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-mc.c
@@ -82,7 +82,6 @@ static struct dvb_usb_properties dibusb_mc_properties = {
82}; 82};
83 83
84static struct usb_driver dibusb_mc_driver = { 84static struct usb_driver dibusb_mc_driver = {
85 .owner = THIS_MODULE,
86 .name = "dvb_usb_dibusb_mc", 85 .name = "dvb_usb_dibusb_mc",
87 .probe = dibusb_mc_probe, 86 .probe = dibusb_mc_probe,
88 .disconnect = dvb_usb_device_exit, 87 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index f98e306a5759..450417a9e64b 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -233,7 +233,6 @@ static struct dvb_usb_properties digitv_properties = {
233}; 233};
234 234
235static struct usb_driver digitv_driver = { 235static struct usb_driver digitv_driver = {
236 .owner = THIS_MODULE,
237 .name = "dvb_usb_digitv", 236 .name = "dvb_usb_digitv",
238 .probe = digitv_probe, 237 .probe = digitv_probe,
239 .disconnect = dvb_usb_device_exit, 238 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/dtt200u.c b/drivers/media/dvb/dvb-usb/dtt200u.c
index b595476332cd..6e2bac873445 100644
--- a/drivers/media/dvb/dvb-usb/dtt200u.c
+++ b/drivers/media/dvb/dvb-usb/dtt200u.c
@@ -198,7 +198,6 @@ static struct dvb_usb_properties wt220u_properties = {
198 198
199/* usb specific object needed to register this driver with the usb subsystem */ 199/* usb specific object needed to register this driver with the usb subsystem */
200static struct usb_driver dtt200u_usb_driver = { 200static struct usb_driver dtt200u_usb_driver = {
201 .owner = THIS_MODULE,
202 .name = "dvb_usb_dtt200u", 201 .name = "dvb_usb_dtt200u",
203 .probe = dtt200u_usb_probe, 202 .probe = dtt200u_usb_probe,
204 .disconnect = dvb_usb_device_exit, 203 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/nova-t-usb2.c b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
index 1841a66427bf..fac48fc7a4ac 100644
--- a/drivers/media/dvb/dvb-usb/nova-t-usb2.c
+++ b/drivers/media/dvb/dvb-usb/nova-t-usb2.c
@@ -202,7 +202,6 @@ static struct dvb_usb_properties nova_t_properties = {
202}; 202};
203 203
204static struct usb_driver nova_t_driver = { 204static struct usb_driver nova_t_driver = {
205 .owner = THIS_MODULE,
206 .name = "dvb_usb_nova_t_usb2", 205 .name = "dvb_usb_nova_t_usb2",
207 .probe = nova_t_probe, 206 .probe = nova_t_probe,
208 .disconnect = dvb_usb_device_exit, 207 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/umt-010.c b/drivers/media/dvb/dvb-usb/umt-010.c
index 6fd67657c269..14f1911c79bb 100644
--- a/drivers/media/dvb/dvb-usb/umt-010.c
+++ b/drivers/media/dvb/dvb-usb/umt-010.c
@@ -128,7 +128,6 @@ static struct dvb_usb_properties umt_properties = {
128}; 128};
129 129
130static struct usb_driver umt_driver = { 130static struct usb_driver umt_driver = {
131 .owner = THIS_MODULE,
132 .name = "dvb_usb_umt_010", 131 .name = "dvb_usb_umt_010",
133 .probe = umt_probe, 132 .probe = umt_probe,
134 .disconnect = dvb_usb_device_exit, 133 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/vp702x-fe.c b/drivers/media/dvb/dvb-usb/vp702x-fe.c
index f20d8dbd0be8..104b5d016c7b 100644
--- a/drivers/media/dvb/dvb-usb/vp702x-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp702x-fe.c
@@ -190,7 +190,7 @@ static int vp702x_fe_get_frontend(struct dvb_frontend* fe,
190} 190}
191 191
192static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe, 192static int vp702x_fe_send_diseqc_msg (struct dvb_frontend* fe,
193 struct dvb_diseqc_master_cmd *m) 193 struct dvb_diseqc_master_cmd *m)
194{ 194{
195 struct vp702x_fe_state *st = fe->demodulator_priv; 195 struct vp702x_fe_state *st = fe->demodulator_priv;
196 u8 cmd[8],ibuf[10]; 196 u8 cmd[8],ibuf[10];
diff --git a/drivers/media/dvb/dvb-usb/vp702x.c b/drivers/media/dvb/dvb-usb/vp702x.c
index de13c04e8e64..afa00fdb5ec0 100644
--- a/drivers/media/dvb/dvb-usb/vp702x.c
+++ b/drivers/media/dvb/dvb-usb/vp702x.c
@@ -256,7 +256,6 @@ static struct dvb_usb_properties vp702x_properties = {
256 256
257/* usb specific object needed to register this driver with the usb subsystem */ 257/* usb specific object needed to register this driver with the usb subsystem */
258static struct usb_driver vp702x_usb_driver = { 258static struct usb_driver vp702x_usb_driver = {
259 .owner = THIS_MODULE,
260 .name = "dvb-usb-vp702x", 259 .name = "dvb-usb-vp702x",
261 .probe = vp702x_usb_probe, 260 .probe = vp702x_usb_probe,
262 .disconnect = dvb_usb_device_exit, 261 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/dvb-usb/vp7045-fe.c b/drivers/media/dvb/dvb-usb/vp7045-fe.c
index 2746edfeccba..83f1de1e7e57 100644
--- a/drivers/media/dvb/dvb-usb/vp7045-fe.c
+++ b/drivers/media/dvb/dvb-usb/vp7045-fe.c
@@ -58,7 +58,7 @@ static int vp7045_fe_read_ber(struct dvb_frontend* fe, u32 *ber)
58 struct vp7045_fe_state *state = fe->demodulator_priv; 58 struct vp7045_fe_state *state = fe->demodulator_priv;
59 *ber = (vp7045_read_reg(state->d, 0x0D) << 16) | 59 *ber = (vp7045_read_reg(state->d, 0x0D) << 16) |
60 (vp7045_read_reg(state->d, 0x0E) << 8) | 60 (vp7045_read_reg(state->d, 0x0E) << 8) |
61 vp7045_read_reg(state->d, 0x0F); 61 vp7045_read_reg(state->d, 0x0F);
62 return 0; 62 return 0;
63} 63}
64 64
diff --git a/drivers/media/dvb/dvb-usb/vp7045.c b/drivers/media/dvb/dvb-usb/vp7045.c
index 75765e3a569c..3835235b68df 100644
--- a/drivers/media/dvb/dvb-usb/vp7045.c
+++ b/drivers/media/dvb/dvb-usb/vp7045.c
@@ -253,7 +253,6 @@ static struct dvb_usb_properties vp7045_properties = {
253 253
254/* usb specific object needed to register this driver with the usb subsystem */ 254/* usb specific object needed to register this driver with the usb subsystem */
255static struct usb_driver vp7045_usb_driver = { 255static struct usb_driver vp7045_usb_driver = {
256 .owner = THIS_MODULE,
257 .name = "dvb_usb_vp7045", 256 .name = "dvb_usb_vp7045",
258 .probe = vp7045_usb_probe, 257 .probe = vp7045_usb_probe,
259 .disconnect = dvb_usb_device_exit, 258 .disconnect = dvb_usb_device_exit,
diff --git a/drivers/media/dvb/frontends/at76c651.c b/drivers/media/dvb/frontends/at76c651.c
index 72a2b5455b0b..8e0f4b3a1417 100644
--- a/drivers/media/dvb/frontends/at76c651.c
+++ b/drivers/media/dvb/frontends/at76c651.c
@@ -361,9 +361,9 @@ static int at76c651_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
361 361
362static int at76c651_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *fesettings) 362static int at76c651_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings *fesettings)
363{ 363{
364 fesettings->min_delay_ms = 50; 364 fesettings->min_delay_ms = 50;
365 fesettings->step_size = 0; 365 fesettings->step_size = 0;
366 fesettings->max_drift = 0; 366 fesettings->max_drift = 0;
367 return 0; 367 return 0;
368} 368}
369 369
diff --git a/drivers/media/dvb/frontends/bcm3510.c b/drivers/media/dvb/frontends/bcm3510.c
index f6d4ee78bdd4..8ceb9a33c7af 100644
--- a/drivers/media/dvb/frontends/bcm3510.c
+++ b/drivers/media/dvb/frontends/bcm3510.c
@@ -69,7 +69,7 @@ MODULE_PARM_DESC(debug, "set debugging level (1=info,2=i2c (|-able)).");
69#define dbufout(b,l,m) {\ 69#define dbufout(b,l,m) {\
70 int i; \ 70 int i; \
71 for (i = 0; i < l; i++) \ 71 for (i = 0; i < l; i++) \
72 m("%02x ",b[i]); \ 72 m("%02x ",b[i]); \
73} 73}
74#define deb_info(args...) dprintk(0x01,args) 74#define deb_info(args...) dprintk(0x01,args)
75#define deb_i2c(args...) dprintk(0x02,args) 75#define deb_i2c(args...) dprintk(0x02,args)
@@ -827,7 +827,7 @@ static struct dvb_frontend_ops bcm3510_ops = {
827 .type = FE_ATSC, 827 .type = FE_ATSC,
828 .frequency_min = 54000000, 828 .frequency_min = 54000000,
829 .frequency_max = 803000000, 829 .frequency_max = 803000000,
830 /* stepsize is just a guess */ 830 /* stepsize is just a guess */
831 .frequency_stepsize = 0, 831 .frequency_stepsize = 0,
832 .caps = 832 .caps =
833 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 833 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
diff --git a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c
index 0c2ed4438618..755f774f6b7d 100644
--- a/drivers/media/dvb/frontends/cx22700.c
+++ b/drivers/media/dvb/frontends/cx22700.c
@@ -355,10 +355,10 @@ static int cx22700_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
355 355
356static int cx22700_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 356static int cx22700_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
357{ 357{
358 fesettings->min_delay_ms = 150; 358 fesettings->min_delay_ms = 150;
359 fesettings->step_size = 166667; 359 fesettings->step_size = 166667;
360 fesettings->max_drift = 166667*2; 360 fesettings->max_drift = 166667*2;
361 return 0; 361 return 0;
362} 362}
363 363
364static void cx22700_release(struct dvb_frontend* fe) 364static void cx22700_release(struct dvb_frontend* fe)
@@ -407,7 +407,7 @@ static struct dvb_frontend_ops cx22700_ops = {
407 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 407 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
408 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 408 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
409 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | 409 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
410 FE_CAN_RECOVER 410 FE_CAN_RECOVER
411 }, 411 },
412 412
413 .release = cx22700_release, 413 .release = cx22700_release,
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index d9a8ede14b45..5de0e6d350b1 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -2,7 +2,7 @@
2 Conexant 22702 DVB OFDM demodulator driver 2 Conexant 22702 DVB OFDM demodulator driver
3 3
4 based on: 4 based on:
5 Alps TDMB7 DVB OFDM demodulator driver 5 Alps TDMB7 DVB OFDM demodulator driver
6 6
7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH 7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH
8 Holger Waechtler <holger@convergence.de> 8 Holger Waechtler <holger@convergence.de>
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 1f250885d2ce..5633976a58f1 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -2,7 +2,7 @@
2 Conexant 22702 DVB OFDM demodulator driver 2 Conexant 22702 DVB OFDM demodulator driver
3 3
4 based on: 4 based on:
5 Alps TDMB7 DVB OFDM demodulator driver 5 Alps TDMB7 DVB OFDM demodulator driver
6 6
7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH 7 Copyright (C) 2001-2002 Convergence Integrated Media GmbH
8 Holger Waechtler <holger@convergence.de> 8 Holger Waechtler <holger@convergence.de>
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
index 654d7dc879d9..0c4db80ec332 100644
--- a/drivers/media/dvb/frontends/cx24110.c
+++ b/drivers/media/dvb/frontends/cx24110.c
@@ -55,81 +55,81 @@ static int debug;
55 } while (0) 55 } while (0)
56 56
57static struct {u8 reg; u8 data;} cx24110_regdata[]= 57static struct {u8 reg; u8 data;} cx24110_regdata[]=
58 /* Comments beginning with @ denote this value should 58 /* Comments beginning with @ denote this value should
59 be the default */ 59 be the default */
60 {{0x09,0x01}, /* SoftResetAll */ 60 {{0x09,0x01}, /* SoftResetAll */
61 {0x09,0x00}, /* release reset */ 61 {0x09,0x00}, /* release reset */
62 {0x01,0xe8}, /* MSB of code rate 27.5MS/s */ 62 {0x01,0xe8}, /* MSB of code rate 27.5MS/s */
63 {0x02,0x17}, /* middle byte " */ 63 {0x02,0x17}, /* middle byte " */
64 {0x03,0x29}, /* LSB " */ 64 {0x03,0x29}, /* LSB " */
65 {0x05,0x03}, /* @ DVB mode, standard code rate 3/4 */ 65 {0x05,0x03}, /* @ DVB mode, standard code rate 3/4 */
66 {0x06,0xa5}, /* @ PLL 60MHz */ 66 {0x06,0xa5}, /* @ PLL 60MHz */
67 {0x07,0x01}, /* @ Fclk, i.e. sampling clock, 60MHz */ 67 {0x07,0x01}, /* @ Fclk, i.e. sampling clock, 60MHz */
68 {0x0a,0x00}, /* @ partial chip disables, do not set */ 68 {0x0a,0x00}, /* @ partial chip disables, do not set */
69 {0x0b,0x01}, /* set output clock in gapped mode, start signal low 69 {0x0b,0x01}, /* set output clock in gapped mode, start signal low
70 active for first byte */ 70 active for first byte */
71 {0x0c,0x11}, /* no parity bytes, large hold time, serial data out */ 71 {0x0c,0x11}, /* no parity bytes, large hold time, serial data out */
72 {0x0d,0x6f}, /* @ RS Sync/Unsync thresholds */ 72 {0x0d,0x6f}, /* @ RS Sync/Unsync thresholds */
73 {0x10,0x40}, /* chip doc is misleading here: write bit 6 as 1 73 {0x10,0x40}, /* chip doc is misleading here: write bit 6 as 1
74 to avoid starting the BER counter. Reset the 74 to avoid starting the BER counter. Reset the
75 CRC test bit. Finite counting selected */ 75 CRC test bit. Finite counting selected */
76 {0x15,0xff}, /* @ size of the limited time window for RS BER 76 {0x15,0xff}, /* @ size of the limited time window for RS BER
77 estimation. It is <value>*256 RS blocks, this 77 estimation. It is <value>*256 RS blocks, this
78 gives approx. 2.6 sec at 27.5MS/s, rate 3/4 */ 78 gives approx. 2.6 sec at 27.5MS/s, rate 3/4 */
79 {0x16,0x00}, /* @ enable all RS output ports */ 79 {0x16,0x00}, /* @ enable all RS output ports */
80 {0x17,0x04}, /* @ time window allowed for the RS to sync */ 80 {0x17,0x04}, /* @ time window allowed for the RS to sync */
81 {0x18,0xae}, /* @ allow all standard DVB code rates to be scanned 81 {0x18,0xae}, /* @ allow all standard DVB code rates to be scanned
82 for automatically */ 82 for automatically */
83 /* leave the current code rate and normalization 83 /* leave the current code rate and normalization
84 registers as they are after reset... */ 84 registers as they are after reset... */
85 {0x21,0x10}, /* @ during AutoAcq, search each viterbi setting 85 {0x21,0x10}, /* @ during AutoAcq, search each viterbi setting
86 only once */ 86 only once */
87 {0x23,0x18}, /* @ size of the limited time window for Viterbi BER 87 {0x23,0x18}, /* @ size of the limited time window for Viterbi BER
88 estimation. It is <value>*65536 channel bits, i.e. 88 estimation. It is <value>*65536 channel bits, i.e.
89 approx. 38ms at 27.5MS/s, rate 3/4 */ 89 approx. 38ms at 27.5MS/s, rate 3/4 */
90 {0x24,0x24}, /* do not trigger Viterbi CRC test. Finite count window */ 90 {0x24,0x24}, /* do not trigger Viterbi CRC test. Finite count window */
91 /* leave front-end AGC parameters at default values */ 91 /* leave front-end AGC parameters at default values */
92 /* leave decimation AGC parameters at default values */ 92 /* leave decimation AGC parameters at default values */
93 {0x35,0x40}, /* disable all interrupts. They are not connected anyway */ 93 {0x35,0x40}, /* disable all interrupts. They are not connected anyway */
94 {0x36,0xff}, /* clear all interrupt pending flags */ 94 {0x36,0xff}, /* clear all interrupt pending flags */
95 {0x37,0x00}, /* @ fully enable AutoAcqq state machine */ 95 {0x37,0x00}, /* @ fully enable AutoAcqq state machine */
96 {0x38,0x07}, /* @ enable fade recovery, but not autostart AutoAcq */ 96 {0x38,0x07}, /* @ enable fade recovery, but not autostart AutoAcq */
97 /* leave the equalizer parameters on their default values */ 97 /* leave the equalizer parameters on their default values */
98 /* leave the final AGC parameters on their default values */ 98 /* leave the final AGC parameters on their default values */
99 {0x41,0x00}, /* @ MSB of front-end derotator frequency */ 99 {0x41,0x00}, /* @ MSB of front-end derotator frequency */
100 {0x42,0x00}, /* @ middle bytes " */ 100 {0x42,0x00}, /* @ middle bytes " */
101 {0x43,0x00}, /* @ LSB " */ 101 {0x43,0x00}, /* @ LSB " */
102 /* leave the carrier tracking loop parameters on default */ 102 /* leave the carrier tracking loop parameters on default */
103 /* leave the bit timing loop parameters at gefault */ 103 /* leave the bit timing loop parameters at gefault */
104 {0x56,0x4d}, /* set the filtune voltage to 2.7V, as recommended by */ 104 {0x56,0x4d}, /* set the filtune voltage to 2.7V, as recommended by */
105 /* the cx24108 data sheet for symbol rates above 15MS/s */ 105 /* the cx24108 data sheet for symbol rates above 15MS/s */
106 {0x57,0x00}, /* @ Filter sigma delta enabled, positive */ 106 {0x57,0x00}, /* @ Filter sigma delta enabled, positive */
107 {0x61,0x95}, /* GPIO pins 1-4 have special function */ 107 {0x61,0x95}, /* GPIO pins 1-4 have special function */
108 {0x62,0x05}, /* GPIO pin 5 has special function, pin 6 is GPIO */ 108 {0x62,0x05}, /* GPIO pin 5 has special function, pin 6 is GPIO */
109 {0x63,0x00}, /* All GPIO pins use CMOS output characteristics */ 109 {0x63,0x00}, /* All GPIO pins use CMOS output characteristics */
110 {0x64,0x20}, /* GPIO 6 is input, all others are outputs */ 110 {0x64,0x20}, /* GPIO 6 is input, all others are outputs */
111 {0x6d,0x30}, /* tuner auto mode clock freq 62kHz */ 111 {0x6d,0x30}, /* tuner auto mode clock freq 62kHz */
112 {0x70,0x15}, /* use auto mode, tuner word is 21 bits long */ 112 {0x70,0x15}, /* use auto mode, tuner word is 21 bits long */
113 {0x73,0x00}, /* @ disable several demod bypasses */ 113 {0x73,0x00}, /* @ disable several demod bypasses */
114 {0x74,0x00}, /* @ " */ 114 {0x74,0x00}, /* @ " */
115 {0x75,0x00} /* @ " */ 115 {0x75,0x00} /* @ " */
116 /* the remaining registers are for SEC */ 116 /* the remaining registers are for SEC */
117 }; 117 };
118 118
119 119
120static int cx24110_writereg (struct cx24110_state* state, int reg, int data) 120static int cx24110_writereg (struct cx24110_state* state, int reg, int data)
121{ 121{
122 u8 buf [] = { reg, data }; 122 u8 buf [] = { reg, data };
123 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 123 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
124 int err; 124 int err;
125 125
126 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 126 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
127 dprintk ("%s: writereg error (err == %i, reg == 0x%02x," 127 dprintk ("%s: writereg error (err == %i, reg == 0x%02x,"
128 " data == 0x%02x)\n", __FUNCTION__, err, reg, data); 128 " data == 0x%02x)\n", __FUNCTION__, err, reg, data);
129 return -EREMOTEIO; 129 return -EREMOTEIO;
130 } 130 }
131 131
132 return 0; 132 return 0;
133} 133}
134 134
135static int cx24110_readreg (struct cx24110_state* state, u8 reg) 135static int cx24110_readreg (struct cx24110_state* state, u8 reg)
@@ -153,27 +153,27 @@ static int cx24110_set_inversion (struct cx24110_state* state, fe_spectral_inver
153 153
154 switch (inversion) { 154 switch (inversion) {
155 case INVERSION_OFF: 155 case INVERSION_OFF:
156 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1); 156 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1);
157 /* AcqSpectrInvDis on. No idea why someone should want this */ 157 /* AcqSpectrInvDis on. No idea why someone should want this */
158 cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)&0xf7); 158 cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)&0xf7);
159 /* Initial value 0 at start of acq */ 159 /* Initial value 0 at start of acq */
160 cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)&0xef); 160 cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)&0xef);
161 /* current value 0 */ 161 /* current value 0 */
162 /* The cx24110 manual tells us this reg is read-only. 162 /* The cx24110 manual tells us this reg is read-only.
163 But what the heck... set it ayways */ 163 But what the heck... set it ayways */
164 break; 164 break;
165 case INVERSION_ON: 165 case INVERSION_ON:
166 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1); 166 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x1);
167 /* AcqSpectrInvDis on. No idea why someone should want this */ 167 /* AcqSpectrInvDis on. No idea why someone should want this */
168 cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)|0x08); 168 cx24110_writereg(state,0x5,cx24110_readreg(state,0x5)|0x08);
169 /* Initial value 1 at start of acq */ 169 /* Initial value 1 at start of acq */
170 cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)|0x10); 170 cx24110_writereg(state,0x22,cx24110_readreg(state,0x22)|0x10);
171 /* current value 1 */ 171 /* current value 1 */
172 break; 172 break;
173 case INVERSION_AUTO: 173 case INVERSION_AUTO:
174 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xfe); 174 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xfe);
175 /* AcqSpectrInvDis off. Leave initial & current states as is */ 175 /* AcqSpectrInvDis off. Leave initial & current states as is */
176 break; 176 break;
177 default: 177 default:
178 return -EINVAL; 178 return -EINVAL;
179 } 179 }
@@ -185,18 +185,18 @@ static int cx24110_set_fec (struct cx24110_state* state, fe_code_rate_t fec)
185{ 185{
186/* fixme (low): error handling */ 186/* fixme (low): error handling */
187 187
188 static const int rate[]={-1,1,2,3,5,7,-1}; 188 static const int rate[]={-1,1,2,3,5,7,-1};
189 static const int g1[]={-1,0x01,0x02,0x05,0x15,0x45,-1}; 189 static const int g1[]={-1,0x01,0x02,0x05,0x15,0x45,-1};
190 static const int g2[]={-1,0x01,0x03,0x06,0x1a,0x7a,-1}; 190 static const int g2[]={-1,0x01,0x03,0x06,0x1a,0x7a,-1};
191 191
192 /* Well, the AutoAcq engine of the cx24106 and 24110 automatically 192 /* Well, the AutoAcq engine of the cx24106 and 24110 automatically
193 searches all enabled viterbi rates, and can handle non-standard 193 searches all enabled viterbi rates, and can handle non-standard
194 rates as well. */ 194 rates as well. */
195 195
196 if (fec>FEC_AUTO) 196 if (fec>FEC_AUTO)
197 fec=FEC_AUTO; 197 fec=FEC_AUTO;
198 198
199 if (fec==FEC_AUTO) { /* (re-)establish AutoAcq behaviour */ 199 if (fec==FEC_AUTO) { /* (re-)establish AutoAcq behaviour */
200 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xdf); 200 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)&0xdf);
201 /* clear AcqVitDis bit */ 201 /* clear AcqVitDis bit */
202 cx24110_writereg(state,0x18,0xae); 202 cx24110_writereg(state,0x18,0xae);
@@ -208,7 +208,7 @@ static int cx24110_set_fec (struct cx24110_state* state, fe_code_rate_t fec)
208 cx24110_writereg(state,0x1a,0x05); cx24110_writereg(state,0x1b,0x06); 208 cx24110_writereg(state,0x1a,0x05); cx24110_writereg(state,0x1b,0x06);
209 /* set the puncture registers for code rate 3/4 */ 209 /* set the puncture registers for code rate 3/4 */
210 return 0; 210 return 0;
211 } else { 211 } else {
212 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x20); 212 cx24110_writereg(state,0x37,cx24110_readreg(state,0x37)|0x20);
213 /* set AcqVitDis bit */ 213 /* set AcqVitDis bit */
214 if(rate[fec]>0) { 214 if(rate[fec]>0) {
@@ -219,10 +219,10 @@ static int cx24110_set_fec (struct cx24110_state* state, fe_code_rate_t fec)
219 cx24110_writereg(state,0x1a,g1[fec]); 219 cx24110_writereg(state,0x1a,g1[fec]);
220 cx24110_writereg(state,0x1b,g2[fec]); 220 cx24110_writereg(state,0x1b,g2[fec]);
221 /* not sure if this is the right way: I always used AutoAcq mode */ 221 /* not sure if this is the right way: I always used AutoAcq mode */
222 } else 222 } else
223 return -EOPNOTSUPP; 223 return -EOPNOTSUPP;
224/* fixme (low): which is the correct return code? */ 224/* fixme (low): which is the correct return code? */
225 }; 225 };
226 return 0; 226 return 0;
227} 227}
228 228
@@ -245,72 +245,72 @@ static fe_code_rate_t cx24110_get_fec (struct cx24110_state* state)
245static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate) 245static int cx24110_set_symbolrate (struct cx24110_state* state, u32 srate)
246{ 246{
247/* fixme (low): add error handling */ 247/* fixme (low): add error handling */
248 u32 ratio; 248 u32 ratio;
249 u32 tmp, fclk, BDRI; 249 u32 tmp, fclk, BDRI;
250 250
251 static const u32 bands[]={5000000UL,15000000UL,90999000UL/2}; 251 static const u32 bands[]={5000000UL,15000000UL,90999000UL/2};
252 int i; 252 int i;
253 253
254dprintk("cx24110 debug: entering %s(%d)\n",__FUNCTION__,srate); 254dprintk("cx24110 debug: entering %s(%d)\n",__FUNCTION__,srate);
255 if (srate>90999000UL/2) 255 if (srate>90999000UL/2)
256 srate=90999000UL/2; 256 srate=90999000UL/2;
257 if (srate<500000) 257 if (srate<500000)
258 srate=500000; 258 srate=500000;
259 259
260 for(i=0;(i<sizeof(bands)/sizeof(bands[0]))&&(srate>bands[i]);i++) 260 for(i=0;(i<sizeof(bands)/sizeof(bands[0]))&&(srate>bands[i]);i++)
261 ; 261 ;
262 /* first, check which sample rate is appropriate: 45, 60 80 or 90 MHz, 262 /* first, check which sample rate is appropriate: 45, 60 80 or 90 MHz,
263 and set the PLL accordingly (R07[1:0] Fclk, R06[7:4] PLLmult, 263 and set the PLL accordingly (R07[1:0] Fclk, R06[7:4] PLLmult,
264 R06[3:0] PLLphaseDetGain */ 264 R06[3:0] PLLphaseDetGain */
265 tmp=cx24110_readreg(state,0x07)&0xfc; 265 tmp=cx24110_readreg(state,0x07)&0xfc;
266 if(srate<90999000UL/4) { /* sample rate 45MHz*/ 266 if(srate<90999000UL/4) { /* sample rate 45MHz*/
267 cx24110_writereg(state,0x07,tmp); 267 cx24110_writereg(state,0x07,tmp);
268 cx24110_writereg(state,0x06,0x78); 268 cx24110_writereg(state,0x06,0x78);
269 fclk=90999000UL/2; 269 fclk=90999000UL/2;
270 } else if(srate<60666000UL/2) { /* sample rate 60MHz */ 270 } else if(srate<60666000UL/2) { /* sample rate 60MHz */
271 cx24110_writereg(state,0x07,tmp|0x1); 271 cx24110_writereg(state,0x07,tmp|0x1);
272 cx24110_writereg(state,0x06,0xa5); 272 cx24110_writereg(state,0x06,0xa5);
273 fclk=60666000UL; 273 fclk=60666000UL;
274 } else if(srate<80888000UL/2) { /* sample rate 80MHz */ 274 } else if(srate<80888000UL/2) { /* sample rate 80MHz */
275 cx24110_writereg(state,0x07,tmp|0x2); 275 cx24110_writereg(state,0x07,tmp|0x2);
276 cx24110_writereg(state,0x06,0x87); 276 cx24110_writereg(state,0x06,0x87);
277 fclk=80888000UL; 277 fclk=80888000UL;
278 } else { /* sample rate 90MHz */ 278 } else { /* sample rate 90MHz */
279 cx24110_writereg(state,0x07,tmp|0x3); 279 cx24110_writereg(state,0x07,tmp|0x3);
280 cx24110_writereg(state,0x06,0x78); 280 cx24110_writereg(state,0x06,0x78);
281 fclk=90999000UL; 281 fclk=90999000UL;
282 }; 282 };
283 dprintk("cx24110 debug: fclk %d Hz\n",fclk); 283 dprintk("cx24110 debug: fclk %d Hz\n",fclk);
284 /* we need to divide two integers with approx. 27 bits in 32 bit 284 /* we need to divide two integers with approx. 27 bits in 32 bit
285 arithmetic giving a 25 bit result */ 285 arithmetic giving a 25 bit result */
286 /* the maximum dividend is 90999000/2, 0x02b6446c, this number is 286 /* the maximum dividend is 90999000/2, 0x02b6446c, this number is
287 also the most complex divisor. Hence, the dividend has, 287 also the most complex divisor. Hence, the dividend has,
288 assuming 32bit unsigned arithmetic, 6 clear bits on top, the 288 assuming 32bit unsigned arithmetic, 6 clear bits on top, the
289 divisor 2 unused bits at the bottom. Also, the quotient is 289 divisor 2 unused bits at the bottom. Also, the quotient is
290 always less than 1/2. Borrowed from VES1893.c, of course */ 290 always less than 1/2. Borrowed from VES1893.c, of course */
291 291
292 tmp=srate<<6; 292 tmp=srate<<6;
293 BDRI=fclk>>2; 293 BDRI=fclk>>2;
294 ratio=(tmp/BDRI); 294 ratio=(tmp/BDRI);
295 295
296 tmp=(tmp%BDRI)<<8; 296 tmp=(tmp%BDRI)<<8;
297 ratio=(ratio<<8)+(tmp/BDRI); 297 ratio=(ratio<<8)+(tmp/BDRI);
298 298
299 tmp=(tmp%BDRI)<<8; 299 tmp=(tmp%BDRI)<<8;
300 ratio=(ratio<<8)+(tmp/BDRI); 300 ratio=(ratio<<8)+(tmp/BDRI);
301 301
302 tmp=(tmp%BDRI)<<1; 302 tmp=(tmp%BDRI)<<1;
303 ratio=(ratio<<1)+(tmp/BDRI); 303 ratio=(ratio<<1)+(tmp/BDRI);
304 304
305 dprintk("srate= %d (range %d, up to %d)\n", srate,i,bands[i]); 305 dprintk("srate= %d (range %d, up to %d)\n", srate,i,bands[i]);
306 dprintk("fclk = %d\n", fclk); 306 dprintk("fclk = %d\n", fclk);
307 dprintk("ratio= %08x\n", ratio); 307 dprintk("ratio= %08x\n", ratio);
308 308
309 cx24110_writereg(state, 0x1, (ratio>>16)&0xff); 309 cx24110_writereg(state, 0x1, (ratio>>16)&0xff);
310 cx24110_writereg(state, 0x2, (ratio>>8)&0xff); 310 cx24110_writereg(state, 0x2, (ratio>>8)&0xff);
311 cx24110_writereg(state, 0x3, (ratio)&0xff); 311 cx24110_writereg(state, 0x3, (ratio)&0xff);
312 312
313 return 0; 313 return 0;
314 314
315} 315}
316 316
@@ -324,48 +324,48 @@ int cx24110_pll_write (struct dvb_frontend* fe, u32 data)
324 324
325 dprintk("cx24110 debug: cx24108_write(%8.8x)\n",data); 325 dprintk("cx24110 debug: cx24108_write(%8.8x)\n",data);
326 326
327 cx24110_writereg(state,0x6d,0x30); /* auto mode at 62kHz */ 327 cx24110_writereg(state,0x6d,0x30); /* auto mode at 62kHz */
328 cx24110_writereg(state,0x70,0x15); /* auto mode 21 bits */ 328 cx24110_writereg(state,0x70,0x15); /* auto mode 21 bits */
329 329
330 /* if the auto tuner writer is still busy, clear it out */ 330 /* if the auto tuner writer is still busy, clear it out */
331 while (cx24110_readreg(state,0x6d)&0x80) 331 while (cx24110_readreg(state,0x6d)&0x80)
332 cx24110_writereg(state,0x72,0); 332 cx24110_writereg(state,0x72,0);
333 333
334 /* write the topmost 8 bits */ 334 /* write the topmost 8 bits */
335 cx24110_writereg(state,0x72,(data>>24)&0xff); 335 cx24110_writereg(state,0x72,(data>>24)&0xff);
336 336
337 /* wait for the send to be completed */ 337 /* wait for the send to be completed */
338 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) 338 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
339 ; 339 ;
340 340
341 /* send another 8 bytes */ 341 /* send another 8 bytes */
342 cx24110_writereg(state,0x72,(data>>16)&0xff); 342 cx24110_writereg(state,0x72,(data>>16)&0xff);
343 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) 343 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
344 ; 344 ;
345 345
346 /* and the topmost 5 bits of this byte */ 346 /* and the topmost 5 bits of this byte */
347 cx24110_writereg(state,0x72,(data>>8)&0xff); 347 cx24110_writereg(state,0x72,(data>>8)&0xff);
348 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80) 348 while ((cx24110_readreg(state,0x6d)&0xc0)==0x80)
349 ; 349 ;
350 350
351 /* now strobe the enable line once */ 351 /* now strobe the enable line once */
352 cx24110_writereg(state,0x6d,0x32); 352 cx24110_writereg(state,0x6d,0x32);
353 cx24110_writereg(state,0x6d,0x30); 353 cx24110_writereg(state,0x6d,0x30);
354 354
355 return 0; 355 return 0;
356} 356}
357 357
358static int cx24110_initfe(struct dvb_frontend* fe) 358static int cx24110_initfe(struct dvb_frontend* fe)
359{ 359{
360 struct cx24110_state *state = fe->demodulator_priv; 360 struct cx24110_state *state = fe->demodulator_priv;
361/* fixme (low): error handling */ 361/* fixme (low): error handling */
362 int i; 362 int i;
363 363
364 dprintk("%s: init chip\n", __FUNCTION__); 364 dprintk("%s: init chip\n", __FUNCTION__);
365 365
366 for(i=0;i<sizeof(cx24110_regdata)/sizeof(cx24110_regdata[0]);i++) { 366 for(i=0;i<sizeof(cx24110_regdata)/sizeof(cx24110_regdata[0]);i++) {
367 cx24110_writereg(state, cx24110_regdata[i].reg, cx24110_regdata[i].data); 367 cx24110_writereg(state, cx24110_regdata[i].reg, cx24110_regdata[i].data);
368 }; 368 };
369 369
370 if (state->config->pll_init) state->config->pll_init(fe); 370 if (state->config->pll_init) state->config->pll_init(fe);
371 371
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index 19b4bf7c21a7..1c7c91224472 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -2,7 +2,7 @@
2 driver for LSI L64781 COFDM demodulator 2 driver for LSI L64781 COFDM demodulator
3 3
4 Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH 4 Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH
5 Marko Kohtala <marko.kohtala@luukku.com> 5 Marko Kohtala <marko.kohtala@luukku.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -433,7 +433,7 @@ static int l64781_init(struct dvb_frontend* fe)
433{ 433{
434 struct l64781_state* state = fe->demodulator_priv; 434 struct l64781_state* state = fe->demodulator_priv;
435 435
436 reset_and_configure (state); 436 reset_and_configure (state);
437 437
438 /* Power up */ 438 /* Power up */
439 l64781_writereg (state, 0x3e, 0xa5); 439 l64781_writereg (state, 0x3e, 0xa5);
@@ -456,9 +456,9 @@ static int l64781_init(struct dvb_frontend* fe)
456 l64781_writereg (state, 0x0d, 0x8c); 456 l64781_writereg (state, 0x0d, 0x8c);
457 457
458 /* With ppm=8000, it seems the DTR_SENSITIVITY will result in 458 /* With ppm=8000, it seems the DTR_SENSITIVITY will result in
459 value of 2 with all possible bandwidths and guard 459 value of 2 with all possible bandwidths and guard
460 intervals, which is the initial value anyway. */ 460 intervals, which is the initial value anyway. */
461 /*l64781_writereg (state, 0x19, 0x92);*/ 461 /*l64781_writereg (state, 0x19, 0x92);*/
462 462
463 /* Everything is two's complement, soft bit and CSI_OUT too */ 463 /* Everything is two's complement, soft bit and CSI_OUT too */
464 l64781_writereg (state, 0x1e, 0x09); 464 l64781_writereg (state, 0x1e, 0x09);
@@ -477,10 +477,10 @@ static int l64781_init(struct dvb_frontend* fe)
477static int l64781_get_tune_settings(struct dvb_frontend* fe, 477static int l64781_get_tune_settings(struct dvb_frontend* fe,
478 struct dvb_frontend_tune_settings* fesettings) 478 struct dvb_frontend_tune_settings* fesettings)
479{ 479{
480 fesettings->min_delay_ms = 4000; 480 fesettings->min_delay_ms = 4000;
481 fesettings->step_size = 0; 481 fesettings->step_size = 0;
482 fesettings->max_drift = 0; 482 fesettings->max_drift = 0;
483 return 0; 483 return 0;
484} 484}
485 485
486static void l64781_release(struct dvb_frontend* fe) 486static void l64781_release(struct dvb_frontend* fe)
@@ -522,7 +522,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
522 522
523 /* The chip always responds to reads */ 523 /* The chip always responds to reads */
524 if (i2c_transfer(state->i2c, msg, 2) != 2) { 524 if (i2c_transfer(state->i2c, msg, 2) != 2) {
525 dprintk("No response to read on I2C bus\n"); 525 dprintk("No response to read on I2C bus\n");
526 goto error; 526 goto error;
527 } 527 }
528 528
@@ -531,7 +531,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
531 531
532 /* Reading the POWER_DOWN register always returns 0 */ 532 /* Reading the POWER_DOWN register always returns 0 */
533 if (reg0x3e != 0) { 533 if (reg0x3e != 0) {
534 dprintk("Device doesn't look like L64781\n"); 534 dprintk("Device doesn't look like L64781\n");
535 goto error; 535 goto error;
536 } 536 }
537 537
@@ -540,7 +540,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
540 540
541 /* Responds to all reads with 0 */ 541 /* Responds to all reads with 0 */
542 if (l64781_readreg(state, 0x1a) != 0) { 542 if (l64781_readreg(state, 0x1a) != 0) {
543 dprintk("Read 1 returned unexpcted value\n"); 543 dprintk("Read 1 returned unexpcted value\n");
544 goto error; 544 goto error;
545 } 545 }
546 546
@@ -549,7 +549,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
549 549
550 /* Responds with register default value */ 550 /* Responds with register default value */
551 if (l64781_readreg(state, 0x1a) != 0xa1) { 551 if (l64781_readreg(state, 0x1a) != 0xa1) {
552 dprintk("Read 2 returned unexpcted value\n"); 552 dprintk("Read 2 returned unexpcted value\n");
553 goto error; 553 goto error;
554 } 554 }
555 555
diff --git a/drivers/media/dvb/frontends/l64781.h b/drivers/media/dvb/frontends/l64781.h
index 7e30fb0fdfa7..947f65f87465 100644
--- a/drivers/media/dvb/frontends/l64781.h
+++ b/drivers/media/dvb/frontends/l64781.h
@@ -2,7 +2,7 @@
2 driver for LSI L64781 COFDM demodulator 2 driver for LSI L64781 COFDM demodulator
3 3
4 Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH 4 Copyright (C) 2001 Holger Waechtler for Convergence Integrated Media GmbH
5 Marko Kohtala <marko.kohtala@luukku.com> 5 Marko Kohtala <marko.kohtala@luukku.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb/frontends/lgdt330x.c b/drivers/media/dvb/frontends/lgdt330x.c
index 6a33f5a19a8d..cb5301865d07 100644
--- a/drivers/media/dvb/frontends/lgdt330x.c
+++ b/drivers/media/dvb/frontends/lgdt330x.c
@@ -301,10 +301,10 @@ static int lgdt330x_set_parameters(struct dvb_frontend* fe,
301 static u8 lgdt3303_8vsb_44_data[] = { 301 static u8 lgdt3303_8vsb_44_data[] = {
302 0x04, 0x00, 302 0x04, 0x00,
303 0x0d, 0x40, 303 0x0d, 0x40,
304 0x0e, 0x87, 304 0x0e, 0x87,
305 0x0f, 0x8e, 305 0x0f, 0x8e,
306 0x10, 0x01, 306 0x10, 0x01,
307 0x47, 0x8b }; 307 0x47, 0x8b };
308 308
309 /* 309 /*
310 * Array of byte pairs <address, value> 310 * Array of byte pairs <address, value>
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index 9c67f406d581..8d672283c93d 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -554,7 +554,7 @@ static int mt312_set_frontend(struct dvb_frontend* fe,
554 if ((ret = mt312_write(state, SYM_RATE_H, buf, sizeof(buf))) < 0) 554 if ((ret = mt312_write(state, SYM_RATE_H, buf, sizeof(buf))) < 0)
555 return ret; 555 return ret;
556 556
557 mt312_reset(state, 0); 557 mt312_reset(state, 0);
558 558
559 return 0; 559 return 0;
560} 560}
@@ -695,7 +695,7 @@ static struct dvb_frontend_ops vp310_mt312_ops = {
695 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | 695 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
696 FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | 696 FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
697 FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_MUTE_TS | 697 FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_MUTE_TS |
698 FE_CAN_RECOVER 698 FE_CAN_RECOVER
699 }, 699 },
700 700
701 .release = mt312_release, 701 .release = mt312_release,
diff --git a/drivers/media/dvb/frontends/nxt2002.c b/drivers/media/dvb/frontends/nxt2002.c
index 30786b1911bd..52c416043a62 100644
--- a/drivers/media/dvb/frontends/nxt2002.c
+++ b/drivers/media/dvb/frontends/nxt2002.c
@@ -527,7 +527,7 @@ static int nxt2002_read_snr(struct dvb_frontend* fe, u16* snr)
527 else 527 else
528 snrdb = 1000*0 + ( 1000*(12-0) * ( temp2 - 0 ) / ( 0x7C00 - 0 ) ); 528 snrdb = 1000*0 + ( 1000*(12-0) * ( temp2 - 0 ) / ( 0x7C00 - 0 ) );
529 529
530 /* the value reported back from the frontend will be FFFF=32db 0000=0db */ 530 /* the value reported back from the frontend will be FFFF=32db 0000=0db */
531 531
532 *snr = snrdb * (0xFFFF/32000); 532 *snr = snrdb * (0xFFFF/32000);
533 533
@@ -646,7 +646,7 @@ struct dvb_frontend* nxt2002_attach(const struct nxt2002_config* config,
646 memcpy(&state->ops, &nxt2002_ops, sizeof(struct dvb_frontend_ops)); 646 memcpy(&state->ops, &nxt2002_ops, sizeof(struct dvb_frontend_ops));
647 state->initialised = 0; 647 state->initialised = 0;
648 648
649 /* Check the first 5 registers to ensure this a revision we can handle */ 649 /* Check the first 5 registers to ensure this a revision we can handle */
650 650
651 i2c_readbytes(state, 0x00, buf, 5); 651 i2c_readbytes(state, 0x00, buf, 5);
652 if (buf[0] != 0x04) goto error; /* device id */ 652 if (buf[0] != 0x04) goto error; /* device id */
@@ -672,7 +672,7 @@ static struct dvb_frontend_ops nxt2002_ops = {
672 .type = FE_ATSC, 672 .type = FE_ATSC,
673 .frequency_min = 54000000, 673 .frequency_min = 54000000,
674 .frequency_max = 860000000, 674 .frequency_max = 860000000,
675 /* stepsize is just a guess */ 675 /* stepsize is just a guess */
676 .frequency_stepsize = 166666, 676 .frequency_stepsize = 166666,
677 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 677 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
678 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 678 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
diff --git a/drivers/media/dvb/frontends/nxt200x.c b/drivers/media/dvb/frontends/nxt200x.c
index 84b62881cea7..aeafef46e3eb 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -339,7 +339,7 @@ static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
339 switch (state->demod_chip) { 339 switch (state->demod_chip) {
340 case NXT2004: 340 case NXT2004:
341 if (i2c_writebytes(state, state->config->pll_address, data, 4)) 341 if (i2c_writebytes(state, state->config->pll_address, data, 4))
342 printk(KERN_WARNING "nxt200x: error writing to tuner\n"); 342 printk(KERN_WARNING "nxt200x: error writing to tuner\n");
343 /* wait until we have a lock */ 343 /* wait until we have a lock */
344 while (count < 20) { 344 while (count < 20) {
345 i2c_readbytes(state, state->config->pll_address, &buf, 1); 345 i2c_readbytes(state, state->config->pll_address, &buf, 1);
@@ -497,7 +497,7 @@ static int nxt2004_load_firmware (struct dvb_frontend* fe, const struct firmware
497 497
498 /* calculate firmware CRC */ 498 /* calculate firmware CRC */
499 for (position = 0; position < fw->size; position++) { 499 for (position = 0; position < fw->size; position++) {
500 crc = nxt200x_crc(crc, fw->data[position]); 500 crc = nxt200x_crc(crc, fw->data[position]);
501 } 501 }
502 502
503 buf[0] = rambase >> 8; 503 buf[0] = rambase >> 8;
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c
index 88a57b791112..a458a3bfff70 100644
--- a/drivers/media/dvb/frontends/nxt6000.c
+++ b/drivers/media/dvb/frontends/nxt6000.c
@@ -574,11 +574,11 @@ static struct dvb_frontend_ops nxt6000_ops = {
574 .symbol_rate_max = 9360000, /* FIXME */ 574 .symbol_rate_max = 9360000, /* FIXME */
575 .symbol_rate_tolerance = 4000, 575 .symbol_rate_tolerance = 4000,
576 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 576 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
577 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | 577 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
578 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | 578 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
579 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | 579 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
580 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | 580 FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
581 FE_CAN_HIERARCHY_AUTO, 581 FE_CAN_HIERARCHY_AUTO,
582 }, 582 },
583 583
584 .release = nxt6000_release, 584 .release = nxt6000_release,
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c
index 78bded861d02..80e0f28127b7 100644
--- a/drivers/media/dvb/frontends/or51132.c
+++ b/drivers/media/dvb/frontends/or51132.c
@@ -503,7 +503,7 @@ static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
503 rcvr_stat = rec_buf[1]; 503 rcvr_stat = rec_buf[1];
504 usK = (rcvr_stat & 0x10) ? 3 : 0; 504 usK = (rcvr_stat & 0x10) ? 3 : 0;
505 505
506 /* The value reported back from the frontend will be FFFF=100% 0000=0% */ 506 /* The value reported back from the frontend will be FFFF=100% 0000=0% */
507 signal_strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000; 507 signal_strength = (((8952 - i20Log10(snr_equ) - usK*100)/3+5)*65535)/1000;
508 if (signal_strength > 0xffff) 508 if (signal_strength > 0xffff)
509 *strength = 0xffff; 509 *strength = 0xffff;
diff --git a/drivers/media/dvb/frontends/s5h1420.c b/drivers/media/dvb/frontends/s5h1420.c
index f265418e3261..18715091aed8 100644
--- a/drivers/media/dvb/frontends/s5h1420.c
+++ b/drivers/media/dvb/frontends/s5h1420.c
@@ -494,7 +494,7 @@ static int s5h1420_getfreqoffset(struct s5h1420_state* state)
494} 494}
495 495
496static void s5h1420_setfec_inversion(struct s5h1420_state* state, 496static void s5h1420_setfec_inversion(struct s5h1420_state* state,
497 struct dvb_frontend_parameters *p) 497 struct dvb_frontend_parameters *p)
498{ 498{
499 u8 inversion = 0; 499 u8 inversion = 0;
500 500
@@ -521,8 +521,8 @@ static void s5h1420_setfec_inversion(struct s5h1420_state* state,
521 521
522 case FEC_3_4: 522 case FEC_3_4:
523 s5h1420_writereg(state, 0x30, 0x04); 523 s5h1420_writereg(state, 0x30, 0x04);
524 s5h1420_writereg(state, 0x31, 0x12 | inversion); 524 s5h1420_writereg(state, 0x31, 0x12 | inversion);
525 break; 525 break;
526 526
527 case FEC_5_6: 527 case FEC_5_6:
528 s5h1420_writereg(state, 0x30, 0x08); 528 s5h1420_writereg(state, 0x30, 0x08);
diff --git a/drivers/media/dvb/frontends/s5h1420.h b/drivers/media/dvb/frontends/s5h1420.h
index 872028ddf2a2..73296f13c324 100644
--- a/drivers/media/dvb/frontends/s5h1420.h
+++ b/drivers/media/dvb/frontends/s5h1420.h
@@ -39,6 +39,6 @@ struct s5h1420_config
39}; 39};
40 40
41extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config, 41extern struct dvb_frontend* s5h1420_attach(const struct s5h1420_config* config,
42 struct i2c_adapter* i2c); 42 struct i2c_adapter* i2c);
43 43
44#endif // S5H1420_H 44#endif // S5H1420_H
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c
index 1c6b2e9264bc..fc06cd6b46c3 100644
--- a/drivers/media/dvb/frontends/sp8870.c
+++ b/drivers/media/dvb/frontends/sp8870.c
@@ -67,16 +67,16 @@ static int debug;
67 67
68static int sp8870_writereg (struct sp8870_state* state, u16 reg, u16 data) 68static int sp8870_writereg (struct sp8870_state* state, u16 reg, u16 data)
69{ 69{
70 u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff }; 70 u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff };
71 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 4 }; 71 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 4 };
72 int err; 72 int err;
73 73
74 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) { 74 if ((err = i2c_transfer (state->i2c, &msg, 1)) != 1) {
75 dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data); 75 dprintk ("%s: writereg error (err == %i, reg == 0x%02x, data == 0x%02x)\n", __FUNCTION__, err, reg, data);
76 return -EREMOTEIO; 76 return -EREMOTEIO;
77 } 77 }
78 78
79 return 0; 79 return 0;
80} 80}
81 81
82static int sp8870_readreg (struct sp8870_state* state, u16 reg) 82static int sp8870_readreg (struct sp8870_state* state, u16 reg)
@@ -305,7 +305,7 @@ static int sp8870_set_frontend_parameters (struct dvb_frontend* fe,
305static int sp8870_init (struct dvb_frontend* fe) 305static int sp8870_init (struct dvb_frontend* fe)
306{ 306{
307 struct sp8870_state* state = fe->demodulator_priv; 307 struct sp8870_state* state = fe->demodulator_priv;
308 const struct firmware *fw = NULL; 308 const struct firmware *fw = NULL;
309 309
310 sp8870_wake_up(state); 310 sp8870_wake_up(state);
311 if (state->initialised) return 0; 311 if (state->initialised) return 0;
@@ -534,10 +534,10 @@ static int sp8870_sleep(struct dvb_frontend* fe)
534 534
535static int sp8870_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 535static int sp8870_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
536{ 536{
537 fesettings->min_delay_ms = 350; 537 fesettings->min_delay_ms = 350;
538 fesettings->step_size = 0; 538 fesettings->step_size = 0;
539 fesettings->max_drift = 0; 539 fesettings->max_drift = 0;
540 return 0; 540 return 0;
541} 541}
542 542
543static void sp8870_release(struct dvb_frontend* fe) 543static void sp8870_release(struct dvb_frontend* fe)
diff --git a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c
index 73384e75625e..e3b665782243 100644
--- a/drivers/media/dvb/frontends/sp887x.c
+++ b/drivers/media/dvb/frontends/sp887x.c
@@ -80,7 +80,7 @@ static int sp887x_readreg (struct sp887x_state* state, u16 reg)
80 u8 b1 [2]; 80 u8 b1 [2];
81 int ret; 81 int ret;
82 struct i2c_msg msg[] = {{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 }, 82 struct i2c_msg msg[] = {{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 2 },
83 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }}; 83 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 2 }};
84 84
85 if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) { 85 if ((ret = i2c_transfer(state->i2c, msg, 2)) != 2) {
86 printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret); 86 printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
@@ -498,7 +498,7 @@ static int sp887x_sleep(struct dvb_frontend* fe)
498static int sp887x_init(struct dvb_frontend* fe) 498static int sp887x_init(struct dvb_frontend* fe)
499{ 499{
500 struct sp887x_state* state = fe->demodulator_priv; 500 struct sp887x_state* state = fe->demodulator_priv;
501 const struct firmware *fw = NULL; 501 const struct firmware *fw = NULL;
502 int ret; 502 int ret;
503 503
504 if (!state->initialised) { 504 if (!state->initialised) {
@@ -528,10 +528,10 @@ static int sp887x_init(struct dvb_frontend* fe)
528 528
529static int sp887x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 529static int sp887x_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
530{ 530{
531 fesettings->min_delay_ms = 350; 531 fesettings->min_delay_ms = 350;
532 fesettings->step_size = 166666*2; 532 fesettings->step_size = 166666*2;
533 fesettings->max_drift = (166666*2)+1; 533 fesettings->max_drift = (166666*2)+1;
534 return 0; 534 return 0;
535} 535}
536 536
537static void sp887x_release(struct dvb_frontend* fe) 537static void sp887x_release(struct dvb_frontend* fe)
@@ -581,7 +581,7 @@ static struct dvb_frontend_ops sp887x_ops = {
581 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | 581 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
582 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO | 582 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
583 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | 583 FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
584 FE_CAN_RECOVER 584 FE_CAN_RECOVER
585 }, 585 },
586 586
587 .release = sp887x_release, 587 .release = sp887x_release,
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
index 29c48665e130..177d71d56b67 100644
--- a/drivers/media/dvb/frontends/stv0299.c
+++ b/drivers/media/dvb/frontends/stv0299.c
@@ -95,7 +95,7 @@ static int stv0299_writeregI (struct stv0299_state* state, u8 reg, u8 data)
95 95
96int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data) 96int stv0299_writereg (struct dvb_frontend* fe, u8 reg, u8 data)
97{ 97{
98 struct stv0299_state* state = fe->demodulator_priv; 98 struct stv0299_state* state = fe->demodulator_priv;
99 99
100 return stv0299_writeregI(state, reg, data); 100 return stv0299_writeregI(state, reg, data);
101} 101}
@@ -220,7 +220,7 @@ static int stv0299_wait_diseqc_idle (struct stv0299_state* state, int timeout)
220 220
221static int stv0299_set_symbolrate (struct dvb_frontend* fe, u32 srate) 221static int stv0299_set_symbolrate (struct dvb_frontend* fe, u32 srate)
222{ 222{
223 struct stv0299_state* state = fe->demodulator_priv; 223 struct stv0299_state* state = fe->demodulator_priv;
224 u64 big = srate; 224 u64 big = srate;
225 u32 ratio; 225 u32 ratio;
226 226
@@ -271,7 +271,7 @@ static int stv0299_get_symbolrate (struct stv0299_state* state)
271static int stv0299_send_diseqc_msg (struct dvb_frontend* fe, 271static int stv0299_send_diseqc_msg (struct dvb_frontend* fe,
272 struct dvb_diseqc_master_cmd *m) 272 struct dvb_diseqc_master_cmd *m)
273{ 273{
274 struct stv0299_state* state = fe->demodulator_priv; 274 struct stv0299_state* state = fe->demodulator_priv;
275 u8 val; 275 u8 val;
276 int i; 276 int i;
277 277
@@ -301,7 +301,7 @@ static int stv0299_send_diseqc_msg (struct dvb_frontend* fe,
301 301
302static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 302static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t burst)
303{ 303{
304 struct stv0299_state* state = fe->demodulator_priv; 304 struct stv0299_state* state = fe->demodulator_priv;
305 u8 val; 305 u8 val;
306 306
307 dprintk ("%s\n", __FUNCTION__); 307 dprintk ("%s\n", __FUNCTION__);
@@ -328,7 +328,7 @@ static int stv0299_send_diseqc_burst (struct dvb_frontend* fe, fe_sec_mini_cmd_t
328 328
329static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 329static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
330{ 330{
331 struct stv0299_state* state = fe->demodulator_priv; 331 struct stv0299_state* state = fe->demodulator_priv;
332 u8 val; 332 u8 val;
333 333
334 if (stv0299_wait_diseqc_idle (state, 100) < 0) 334 if (stv0299_wait_diseqc_idle (state, 100) < 0)
@@ -350,7 +350,7 @@ static int stv0299_set_tone (struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
350 350
351static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage) 351static int stv0299_set_voltage (struct dvb_frontend* fe, fe_sec_voltage_t voltage)
352{ 352{
353 struct stv0299_state* state = fe->demodulator_priv; 353 struct stv0299_state* state = fe->demodulator_priv;
354 u8 reg0x08; 354 u8 reg0x08;
355 u8 reg0x0c; 355 u8 reg0x0c;
356 356
@@ -442,7 +442,7 @@ static int stv0299_send_legacy_dish_cmd (struct dvb_frontend* fe, u32 cmd)
442 442
443static int stv0299_init (struct dvb_frontend* fe) 443static int stv0299_init (struct dvb_frontend* fe)
444{ 444{
445 struct stv0299_state* state = fe->demodulator_priv; 445 struct stv0299_state* state = fe->demodulator_priv;
446 int i; 446 int i;
447 447
448 dprintk("stv0299: init chip\n"); 448 dprintk("stv0299: init chip\n");
@@ -461,7 +461,7 @@ static int stv0299_init (struct dvb_frontend* fe)
461 461
462static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status) 462static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status)
463{ 463{
464 struct stv0299_state* state = fe->demodulator_priv; 464 struct stv0299_state* state = fe->demodulator_priv;
465 465
466 u8 signal = 0xff - stv0299_readreg (state, 0x18); 466 u8 signal = 0xff - stv0299_readreg (state, 0x18);
467 u8 sync = stv0299_readreg (state, 0x1b); 467 u8 sync = stv0299_readreg (state, 0x1b);
@@ -489,7 +489,7 @@ static int stv0299_read_status(struct dvb_frontend* fe, fe_status_t* status)
489 489
490static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber) 490static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber)
491{ 491{
492 struct stv0299_state* state = fe->demodulator_priv; 492 struct stv0299_state* state = fe->demodulator_priv;
493 493
494 if (state->errmode != STATUS_BER) return 0; 494 if (state->errmode != STATUS_BER) return 0;
495 *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); 495 *ber = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
@@ -499,7 +499,7 @@ static int stv0299_read_ber(struct dvb_frontend* fe, u32* ber)
499 499
500static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength) 500static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength)
501{ 501{
502 struct stv0299_state* state = fe->demodulator_priv; 502 struct stv0299_state* state = fe->demodulator_priv;
503 503
504 s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8) 504 s32 signal = 0xffff - ((stv0299_readreg (state, 0x18) << 8)
505 | stv0299_readreg (state, 0x19)); 505 | stv0299_readreg (state, 0x19));
@@ -516,7 +516,7 @@ static int stv0299_read_signal_strength(struct dvb_frontend* fe, u16* strength)
516 516
517static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr) 517static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr)
518{ 518{
519 struct stv0299_state* state = fe->demodulator_priv; 519 struct stv0299_state* state = fe->demodulator_priv;
520 520
521 s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8) 521 s32 xsnr = 0xffff - ((stv0299_readreg (state, 0x24) << 8)
522 | stv0299_readreg (state, 0x25)); 522 | stv0299_readreg (state, 0x25));
@@ -528,7 +528,7 @@ static int stv0299_read_snr(struct dvb_frontend* fe, u16* snr)
528 528
529static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 529static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
530{ 530{
531 struct stv0299_state* state = fe->demodulator_priv; 531 struct stv0299_state* state = fe->demodulator_priv;
532 532
533 if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0; 533 if (state->errmode != STATUS_UCBLOCKS) *ucblocks = 0;
534 else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e); 534 else *ucblocks = (stv0299_readreg (state, 0x1d) << 8) | stv0299_readreg (state, 0x1e);
@@ -538,7 +538,7 @@ static int stv0299_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
538 538
539static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p) 539static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
540{ 540{
541 struct stv0299_state* state = fe->demodulator_priv; 541 struct stv0299_state* state = fe->demodulator_priv;
542 int invval = 0; 542 int invval = 0;
543 543
544 dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__); 544 dprintk ("%s : FE_SET_FRONTEND\n", __FUNCTION__);
@@ -571,7 +571,7 @@ static int stv0299_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
571 571
572static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p) 572static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters * p)
573{ 573{
574 struct stv0299_state* state = fe->demodulator_priv; 574 struct stv0299_state* state = fe->demodulator_priv;
575 s32 derot_freq; 575 s32 derot_freq;
576 int invval; 576 int invval;
577 577
@@ -596,7 +596,7 @@ static int stv0299_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
596 596
597static int stv0299_sleep(struct dvb_frontend* fe) 597static int stv0299_sleep(struct dvb_frontend* fe)
598{ 598{
599 struct stv0299_state* state = fe->demodulator_priv; 599 struct stv0299_state* state = fe->demodulator_priv;
600 600
601 stv0299_writeregI(state, 0x02, 0x80); 601 stv0299_writeregI(state, 0x02, 0x80);
602 state->initialised = 0; 602 state->initialised = 0;
@@ -606,7 +606,7 @@ static int stv0299_sleep(struct dvb_frontend* fe)
606 606
607static int stv0299_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings) 607static int stv0299_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fesettings)
608{ 608{
609 struct stv0299_state* state = fe->demodulator_priv; 609 struct stv0299_state* state = fe->demodulator_priv;
610 610
611 fesettings->min_delay_ms = state->config->min_delay_ms; 611 fesettings->min_delay_ms = state->config->min_delay_ms;
612 if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) { 612 if (fesettings->parameters.u.qpsk.symbol_rate < 10000000) {
@@ -658,7 +658,7 @@ struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
658 658
659 /* create dvb_frontend */ 659 /* create dvb_frontend */
660 state->frontend.ops = &state->ops; 660 state->frontend.ops = &state->ops;
661 state->frontend.demodulator_priv = state; 661 state->frontend.demodulator_priv = state;
662 return &state->frontend; 662 return &state->frontend;
663 663
664error: 664error:
@@ -714,7 +714,7 @@ MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
714 714
715MODULE_DESCRIPTION("ST STV0299 DVB Demodulator driver"); 715MODULE_DESCRIPTION("ST STV0299 DVB Demodulator driver");
716MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, " 716MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann, Felix Domke, "
717 "Andreas Oberritter, Andrew de Quincey, Kenneth Aafløy"); 717 "Andreas Oberritter, Andrew de Quincey, Kenneth Aafløy");
718MODULE_LICENSE("GPL"); 718MODULE_LICENSE("GPL");
719 719
720EXPORT_SYMBOL(stv0299_writereg); 720EXPORT_SYMBOL(stv0299_writereg);
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index eaf130e666d8..425cd19136fe 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -1,10 +1,10 @@
1/* 1/*
2 TDA10021 - Single Chip Cable Channel Receiver driver module 2 TDA10021 - Single Chip Cable Channel Receiver driver module
3 used on the the Siemens DVB-C cards 3 used on the the Siemens DVB-C cards
4 4
5 Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> 5 Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
6 Copyright (C) 2004 Markus Schulz <msc@antzsystem.de> 6 Copyright (C) 2004 Markus Schulz <msc@antzsystem.de>
7 Support for TDA10021 7 Support for TDA10021
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
@@ -76,9 +76,9 @@ static u8 tda10021_inittab[0x40]=
76 76
77static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data) 77static int tda10021_writereg (struct tda10021_state* state, u8 reg, u8 data)
78{ 78{
79 u8 buf[] = { reg, data }; 79 u8 buf[] = { reg, data };
80 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 80 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
81 int ret; 81 int ret;
82 82
83 ret = i2c_transfer (state->i2c, &msg, 1); 83 ret = i2c_transfer (state->i2c, &msg, 1);
84 if (ret != 1) 84 if (ret != 1)
@@ -95,7 +95,7 @@ static u8 tda10021_readreg (struct tda10021_state* state, u8 reg)
95 u8 b0 [] = { reg }; 95 u8 b0 [] = { reg };
96 u8 b1 [] = { 0 }; 96 u8 b1 [] = { 0 };
97 struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, 97 struct i2c_msg msg [] = { { .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 },
98 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; 98 { .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
99 int ret; 99 int ret;
100 100
101 ret = i2c_transfer (state->i2c, msg, 2); 101 ret = i2c_transfer (state->i2c, msg, 2);
diff --git a/drivers/media/dvb/frontends/tda10021.h b/drivers/media/dvb/frontends/tda10021.h
index 7d6a51ce291e..53be939e8c55 100644
--- a/drivers/media/dvb/frontends/tda10021.h
+++ b/drivers/media/dvb/frontends/tda10021.h
@@ -1,10 +1,10 @@
1/* 1/*
2 TDA10021 - Single Chip Cable Channel Receiver driver module 2 TDA10021 - Single Chip Cable Channel Receiver driver module
3 used on the the Siemens DVB-C cards 3 used on the the Siemens DVB-C cards
4 4
5 Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de> 5 Copyright (C) 1999 Convergence Integrated Media GmbH <ralph@convergence.de>
6 Copyright (C) 2004 Markus Schulz <msc@antzsystem.de> 6 Copyright (C) 2004 Markus Schulz <msc@antzsystem.de>
7 Support for TDA10021 7 Support for TDA10021
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index 7968743826fc..dd02aff467fe 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -475,7 +475,7 @@ static int tda10046_fwupload(struct dvb_frontend* fe)
475 ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE); 475 ret = state->config->request_firmware(fe, &fw, TDA10046_DEFAULT_FIRMWARE);
476 if (ret) { 476 if (ret) {
477 printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n"); 477 printk(KERN_ERR "tda1004x: no firmware upload (timeout or file not found?)\n");
478 return ret; 478 return ret;
479 } 479 }
480 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST 480 tda1004x_write_mask(state, TDA1004X_CONFC4, 8, 8); // going to boot from HOST
481 ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN); 481 ret = tda1004x_do_upload(state, fw->data, fw->size, TDA10046H_CODE_CPT, TDA10046H_CODE_IN);
diff --git a/drivers/media/dvb/frontends/tda8083.c b/drivers/media/dvb/frontends/tda8083.c
index c05cf1861051..91baa9cedd79 100644
--- a/drivers/media/dvb/frontends/tda8083.c
+++ b/drivers/media/dvb/frontends/tda8083.c
@@ -66,13 +66,13 @@ static int tda8083_writereg (struct tda8083_state* state, u8 reg, u8 data)
66 u8 buf [] = { reg, data }; 66 u8 buf [] = { reg, data };
67 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 }; 67 struct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };
68 68
69 ret = i2c_transfer(state->i2c, &msg, 1); 69 ret = i2c_transfer(state->i2c, &msg, 1);
70 70
71 if (ret != 1) 71 if (ret != 1)
72 dprintk ("%s: writereg error (reg %02x, ret == %i)\n", 72 dprintk ("%s: writereg error (reg %02x, ret == %i)\n",
73 __FUNCTION__, reg, ret); 73 __FUNCTION__, reg, ret);
74 74
75 return (ret != 1) ? -1 : 0; 75 return (ret != 1) ? -1 : 0;
76} 76}
77 77
78static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len) 78static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len)
@@ -87,7 +87,7 @@ static int tda8083_readregs (struct tda8083_state* state, u8 reg1, u8 *b, u8 len
87 dprintk ("%s: readreg error (reg %02x, ret == %i)\n", 87 dprintk ("%s: readreg error (reg %02x, ret == %i)\n",
88 __FUNCTION__, reg1, ret); 88 __FUNCTION__, reg1, ret);
89 89
90 return ret == 2 ? 0 : -1; 90 return ret == 2 ? 0 : -1;
91} 91}
92 92
93static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg) 93static inline u8 tda8083_readreg (struct tda8083_state* state, u8 reg)
@@ -132,14 +132,14 @@ static fe_code_rate_t tda8083_get_fec (struct tda8083_state* state)
132 132
133static int tda8083_set_symbolrate (struct tda8083_state* state, u32 srate) 133static int tda8083_set_symbolrate (struct tda8083_state* state, u32 srate)
134{ 134{
135 u32 ratio; 135 u32 ratio;
136 u32 tmp; 136 u32 tmp;
137 u8 filter; 137 u8 filter;
138 138
139 if (srate > 32000000) 139 if (srate > 32000000)
140 srate = 32000000; 140 srate = 32000000;
141 if (srate < 500000) 141 if (srate < 500000)
142 srate = 500000; 142 srate = 500000;
143 143
144 filter = 0; 144 filter = 0;
145 if (srate < 24000000) 145 if (srate < 24000000)
@@ -174,7 +174,7 @@ static void tda8083_wait_diseqc_fifo (struct tda8083_state* state, int timeout)
174 unsigned long start = jiffies; 174 unsigned long start = jiffies;
175 175
176 while (jiffies - start < timeout && 176 while (jiffies - start < timeout &&
177 !(tda8083_readreg(state, 0x02) & 0x80)) 177 !(tda8083_readreg(state, 0x02) & 0x80))
178 { 178 {
179 msleep(50); 179 msleep(50);
180 }; 180 };
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 87ea52757a21..7dae91e5863c 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -176,6 +176,9 @@ static void init_av7110_av(struct av7110 *av7110)
176 } 176 }
177 } 177 }
178 178
179 if (dev->pci->subsystem_vendor == 0x13c2 && dev->pci->subsystem_device == 0x000e)
180 av7110_fw_cmd(av7110, COMTYPE_AUDIODAC, SpdifSwitch, 1, 0); // SPDIF on
181
179 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right); 182 ret = av7110_set_volume(av7110, av7110->mixer.volume_left, av7110->mixer.volume_right);
180 if (ret < 0) 183 if (ret < 0)
181 printk("dvb-ttpci:cannot set volume :%d\n",ret); 184 printk("dvb-ttpci:cannot set volume :%d\n",ret);
@@ -217,10 +220,10 @@ static int arm_thread(void *data)
217 220
218 dprintk(4, "%p\n",av7110); 221 dprintk(4, "%p\n",av7110);
219 222
220 lock_kernel(); 223 lock_kernel();
221 daemonize("arm_mon"); 224 daemonize("arm_mon");
222 sigfillset(&current->blocked); 225 sigfillset(&current->blocked);
223 unlock_kernel(); 226 unlock_kernel();
224 227
225 av7110->arm_thread = current; 228 av7110->arm_thread = current;
226 229
@@ -1535,7 +1538,7 @@ static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
1535 buf[2] = ((div & 0x18000) >> 10) | 0x95; 1538 buf[2] = ((div & 0x18000) >> 10) | 0x95;
1536 buf[3] = (pwr << 6) | 0x30; 1539 buf[3] = (pwr << 6) | 0x30;
1537 1540
1538 // NOTE: since we're using a prescaler of 2, we set the 1541 // NOTE: since we're using a prescaler of 2, we set the
1539 // divisor frequency to 62.5kHz and divide by 125 above 1542 // divisor frequency to 62.5kHz and divide by 125 above
1540 1543
1541 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1) 1544 if (i2c_transfer (&av7110->i2c_adap, &msg, 1) != 1)
@@ -1811,7 +1814,7 @@ static struct tda8083_config grundig_29504_451_config = {
1811static int philips_cd1516_pll_set(struct dvb_frontend* fe, 1814static int philips_cd1516_pll_set(struct dvb_frontend* fe,
1812 struct dvb_frontend_parameters* params) 1815 struct dvb_frontend_parameters* params)
1813{ 1816{
1814 struct av7110* av7110 = fe->dvb->priv; 1817 struct av7110* av7110 = fe->dvb->priv;
1815 u32 div; 1818 u32 div;
1816 u32 f = params->frequency; 1819 u32 f = params->frequency;
1817 u8 data[4]; 1820 u8 data[4];
@@ -2202,7 +2205,7 @@ static u8 read_pwm(struct av7110* av7110)
2202 struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 }, 2205 struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
2203 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} }; 2206 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
2204 2207
2205 if ((i2c_transfer(&av7110->i2c_adap, msg, 2) != 2) || (pwm == 0xff)) 2208 if ((i2c_transfer(&av7110->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
2206 pwm = 0x48; 2209 pwm = 0x48;
2207 2210
2208 return pwm; 2211 return pwm;
@@ -2245,7 +2248,7 @@ static int frontend_init(struct av7110 *av7110)
2245 } 2248 }
2246 2249
2247 // Try the grundig 29504-451 2250 // Try the grundig 29504-451
2248 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap); 2251 av7110->fe = tda8083_attach(&grundig_29504_451_config, &av7110->i2c_adap);
2249 if (av7110->fe) { 2252 if (av7110->fe) {
2250 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd; 2253 av7110->fe->ops->diseqc_send_master_cmd = av7110_diseqc_send_master_cmd;
2251 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst; 2254 av7110->fe->ops->diseqc_send_burst = av7110_diseqc_send_burst;
@@ -2271,12 +2274,12 @@ static int frontend_init(struct av7110 *av7110)
2271 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X 2274 case 0x0001: // Hauppauge/TT Nexus-T premium rev1.X
2272 2275
2273 // ALPS TDLB7 2276 // ALPS TDLB7
2274 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap); 2277 av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap);
2275 break; 2278 break;
2276 2279
2277 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X 2280 case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
2278 2281
2279 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110)); 2282 av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
2280 break; 2283 break;
2281 2284
2282 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */ 2285 case 0x0006: /* Fujitsu-Siemens DVB-S rev 1.6 */
@@ -2421,9 +2424,9 @@ static int av7110_attach(struct saa7146_dev* dev, struct saa7146_pci_extension_d
2421 2424
2422 dprintk(4, "dev: %p\n", dev); 2425 dprintk(4, "dev: %p\n", dev);
2423 2426
2424 /* Set RPS_IRQ to 1 to track rps1 activity. 2427 /* Set RPS_IRQ to 1 to track rps1 activity.
2425 * Enabling this won't send any interrupt to PC CPU. 2428 * Enabling this won't send any interrupt to PC CPU.
2426 */ 2429 */
2427#define RPS_IRQ 0 2430#define RPS_IRQ 0
2428 2431
2429 if (budgetpatch == 1) { 2432 if (budgetpatch == 1) {
diff --git a/drivers/media/dvb/ttpci/av7110_hw.c b/drivers/media/dvb/ttpci/av7110_hw.c
index 7442f56a72ec..87106e8bf35b 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.c
+++ b/drivers/media/dvb/ttpci/av7110_hw.c
@@ -1203,15 +1203,15 @@ int av7110_osd_cmd(struct av7110 *av7110, osd_cmd_t *dc)
1203 1203
1204int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap) 1204int av7110_osd_capability(struct av7110 *av7110, osd_cap_t *cap)
1205{ 1205{
1206 switch (cap->cmd) { 1206 switch (cap->cmd) {
1207 case OSD_CAP_MEMSIZE: 1207 case OSD_CAP_MEMSIZE:
1208 if (FW_4M_SDRAM(av7110->arm_app)) 1208 if (FW_4M_SDRAM(av7110->arm_app))
1209 cap->val = 1000000; 1209 cap->val = 1000000;
1210 else 1210 else
1211 cap->val = 92000; 1211 cap->val = 92000;
1212 return 0; 1212 return 0;
1213 default: 1213 default:
1214 return -EINVAL; 1214 return -EINVAL;
1215 } 1215 }
1216} 1216}
1217#endif /* CONFIG_DVB_AV7110_OSD */ 1217#endif /* CONFIG_DVB_AV7110_OSD */
diff --git a/drivers/media/dvb/ttpci/av7110_hw.h b/drivers/media/dvb/ttpci/av7110_hw.h
index fedd20f9815d..2a5e87ba1052 100644
--- a/drivers/media/dvb/ttpci/av7110_hw.h
+++ b/drivers/media/dvb/ttpci/av7110_hw.h
@@ -143,7 +143,8 @@ enum av7110_audio_command {
143 MainSwitch, 143 MainSwitch,
144 ADSwitch, 144 ADSwitch,
145 SendDiSEqC, 145 SendDiSEqC,
146 SetRegister 146 SetRegister,
147 SpdifSwitch
147}; 148};
148 149
149enum av7110_request_command { 150enum av7110_request_command {
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index 6af74f78b3e5..b5aea4129fa7 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -120,8 +120,8 @@ static int ves1820_writereg(struct saa7146_dev *dev, u8 addr, u8 reg, u8 data)
120 120
121static int stv0297_writereg(struct saa7146_dev *dev, u8 addr, u8 reg, u8 data) 121static int stv0297_writereg(struct saa7146_dev *dev, u8 addr, u8 reg, u8 data)
122{ 122{
123 u8 buf [] = { reg, data }; 123 u8 buf [] = { reg, data };
124 struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 2 }; 124 struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = 2 };
125 125
126 if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1)) 126 if (1 != saa7146_i2c_transfer(dev, &msg, 1, 1))
127 return -1; 127 return -1;
diff --git a/drivers/media/dvb/ttpci/budget-core.c b/drivers/media/dvb/ttpci/budget-core.c
index 0498a055a4cd..017fcbccb8cc 100644
--- a/drivers/media/dvb/ttpci/budget-core.c
+++ b/drivers/media/dvb/ttpci/budget-core.c
@@ -87,7 +87,7 @@ static int start_ts_capture(struct budget *budget)
87 * Pitch: 188, NumBytes3: 188, NumLines3: 1024 87 * Pitch: 188, NumBytes3: 188, NumLines3: 1024
88 */ 88 */
89 89
90 switch(budget->card->type) { 90 switch(budget->card->type) {
91 case BUDGET_FS_ACTIVY: 91 case BUDGET_FS_ACTIVY:
92 saa7146_write(dev, DD1_INIT, 0x04000000); 92 saa7146_write(dev, DD1_INIT, 0x04000000);
93 saa7146_write(dev, MC2, (MASK_09 | MASK_25)); 93 saa7146_write(dev, MC2, (MASK_09 | MASK_25));
diff --git a/drivers/media/dvb/ttpci/budget-patch.c b/drivers/media/dvb/ttpci/budget-patch.c
index 755df81cbc49..fc416cf5253c 100644
--- a/drivers/media/dvb/ttpci/budget-patch.c
+++ b/drivers/media/dvb/ttpci/budget-patch.c
@@ -45,11 +45,11 @@ MAKE_BUDGET_INFO(ttbp, "TT-Budget/Patch DVB-S 1.x PCI", BUDGET_PATCH);
45//MAKE_BUDGET_INFO(satel,"TT-Budget/Patch SATELCO PCI", BUDGET_TT_HW_DISEQC); 45//MAKE_BUDGET_INFO(satel,"TT-Budget/Patch SATELCO PCI", BUDGET_TT_HW_DISEQC);
46 46
47static struct pci_device_id pci_tbl[] = { 47static struct pci_device_id pci_tbl[] = {
48 MAKE_EXTENSION_PCI(ttbp,0x13c2, 0x0000), 48 MAKE_EXTENSION_PCI(ttbp,0x13c2, 0x0000),
49// MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013), 49// MAKE_EXTENSION_PCI(satel, 0x13c2, 0x1013),
50 { 50 {
51 .vendor = 0, 51 .vendor = 0,
52 } 52 }
53}; 53};
54 54
55/* those lines are for budget-patch to be tried 55/* those lines are for budget-patch to be tried
@@ -165,57 +165,57 @@ static int budget_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t m
165 165
166static int budget_av7110_send_fw_cmd(struct budget_patch *budget, u16* buf, int length) 166static int budget_av7110_send_fw_cmd(struct budget_patch *budget, u16* buf, int length)
167{ 167{
168 int i; 168 int i;
169 169
170 dprintk(2, "budget: %p\n", budget); 170 dprintk(2, "budget: %p\n", budget);
171 171
172 for (i = 2; i < length; i++) 172 for (i = 2; i < length; i++)
173 { 173 {
174 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2*i, 2, (u32) buf[i], 0,0); 174 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2*i, 2, (u32) buf[i], 0,0);
175 msleep(5); 175 msleep(5);
176 } 176 }
177 if (length) 177 if (length)
178 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2, 2, (u32) buf[1], 0,0); 178 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2, 2, (u32) buf[1], 0,0);
179 else 179 else
180 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2, 2, 0, 0,0); 180 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND + 2, 2, 0, 0,0);
181 msleep(5); 181 msleep(5);
182 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND, 2, (u32) buf[0], 0,0); 182 ttpci_budget_debiwrite(budget, DEBINOSWAP, COMMAND, 2, (u32) buf[0], 0,0);
183 msleep(5); 183 msleep(5);
184 return 0; 184 return 0;
185} 185}
186 186
187static void av7110_set22k(struct budget_patch *budget, int state) 187static void av7110_set22k(struct budget_patch *budget, int state)
188{ 188{
189 u16 buf[2] = {( COMTYPE_AUDIODAC << 8) | (state ? ON22K : OFF22K), 0}; 189 u16 buf[2] = {( COMTYPE_AUDIODAC << 8) | (state ? ON22K : OFF22K), 0};
190 190
191 dprintk(2, "budget: %p\n", budget); 191 dprintk(2, "budget: %p\n", budget);
192 budget_av7110_send_fw_cmd(budget, buf, 2); 192 budget_av7110_send_fw_cmd(budget, buf, 2);
193} 193}
194 194
195static int av7110_send_diseqc_msg(struct budget_patch *budget, int len, u8 *msg, int burst) 195static int av7110_send_diseqc_msg(struct budget_patch *budget, int len, u8 *msg, int burst)
196{ 196{
197 int i; 197 int i;
198 u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) | SendDiSEqC), 198 u16 buf[18] = { ((COMTYPE_AUDIODAC << 8) | SendDiSEqC),
199 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 199 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
200 200
201 dprintk(2, "budget: %p\n", budget); 201 dprintk(2, "budget: %p\n", budget);
202 202
203 if (len>10) 203 if (len>10)
204 len=10; 204 len=10;
205 205
206 buf[1] = len+2; 206 buf[1] = len+2;
207 buf[2] = len; 207 buf[2] = len;
208 208
209 if (burst != -1) 209 if (burst != -1)
210 buf[3]=burst ? 0x01 : 0x00; 210 buf[3]=burst ? 0x01 : 0x00;
211 else 211 else
212 buf[3]=0xffff; 212 buf[3]=0xffff;
213 213
214 for (i=0; i<len; i++) 214 for (i=0; i<len; i++)
215 buf[i+4]=msg[i]; 215 buf[i+4]=msg[i];
216 216
217 budget_av7110_send_fw_cmd(budget, buf, 18); 217 budget_av7110_send_fw_cmd(budget, buf, 18);
218 return 0; 218 return 0;
219} 219}
220 220
221static int budget_patch_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 221static int budget_patch_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
@@ -276,7 +276,7 @@ static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
276 buf[2] = ((div & 0x18000) >> 10) | 0x95; 276 buf[2] = ((div & 0x18000) >> 10) | 0x95;
277 buf[3] = (pwr << 6) | 0x30; 277 buf[3] = (pwr << 6) | 0x30;
278 278
279 // NOTE: since we're using a prescaler of 2, we set the 279 // NOTE: since we're using a prescaler of 2, we set the
280 // divisor frequency to 62.5kHz and divide by 125 above 280 // divisor frequency to 62.5kHz and divide by 125 above
281 281
282 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; 282 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
@@ -294,7 +294,7 @@ static u8 alps_bsru6_inittab[] = {
294 0x01, 0x15, 294 0x01, 0x15,
295 0x02, 0x00, 295 0x02, 0x00,
296 0x03, 0x00, 296 0x03, 0x00,
297 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ 297 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
298 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ 298 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
299 0x06, 0x40, /* DAC not used, set to high impendance mode */ 299 0x06, 0x40, /* DAC not used, set to high impendance mode */
300 0x07, 0x00, /* DAC LSB */ 300 0x07, 0x00, /* DAC LSB */
@@ -413,7 +413,7 @@ static void frontend_init(struct budget_patch* budget)
413{ 413{
414 switch(budget->dev->pci->subsystem_device) { 414 switch(budget->dev->pci->subsystem_device) {
415 case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X 415 case 0x0000: // Hauppauge/TT WinTV DVB-S rev1.X
416 case 0x1013: // SATELCO Multimedia PCI 416 case 0x1013: // SATELCO Multimedia PCI
417 417
418 // try the ALPS BSRV2 first of all 418 // try the ALPS BSRV2 first of all
419 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); 419 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap);
@@ -463,8 +463,8 @@ static void frontend_init(struct budget_patch* budget)
463/* written by Emard */ 463/* written by Emard */
464static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info) 464static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *info)
465{ 465{
466 struct budget_patch *budget; 466 struct budget_patch *budget;
467 int err; 467 int err;
468 int count = 0; 468 int count = 0;
469 int detected = 0; 469 int detected = 0;
470 470
@@ -472,12 +472,12 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
472#define RPS_IRQ 0 472#define RPS_IRQ 0
473#define HPS_SETUP 0 473#define HPS_SETUP 0
474#if PATCH_RESET 474#if PATCH_RESET
475 saa7146_write(dev, MC1, MASK_31); 475 saa7146_write(dev, MC1, MASK_31);
476 msleep(40); 476 msleep(40);
477#endif 477#endif
478#if HPS_SETUP 478#if HPS_SETUP
479 // initialize registers. Better to have it like this 479 // initialize registers. Better to have it like this
480 // than leaving something unconfigured 480 // than leaving something unconfigured
481 saa7146_write(dev, DD1_STREAM_B, 0); 481 saa7146_write(dev, DD1_STREAM_B, 0);
482 // port B VSYNC at rising edge 482 // port B VSYNC at rising edge
483 saa7146_write(dev, DD1_INIT, 0x00000200); // have this in budget-core too! 483 saa7146_write(dev, DD1_INIT, 0x00000200); // have this in budget-core too!
@@ -486,29 +486,29 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
486 // debi config 486 // debi config
487 // saa7146_write(dev, DEBI_CONFIG, MASK_30|MASK_28|MASK_18); 487 // saa7146_write(dev, DEBI_CONFIG, MASK_30|MASK_28|MASK_18);
488 488
489 // zero all HPS registers 489 // zero all HPS registers
490 saa7146_write(dev, HPS_H_PRESCALE, 0); // r68 490 saa7146_write(dev, HPS_H_PRESCALE, 0); // r68
491 saa7146_write(dev, HPS_H_SCALE, 0); // r6c 491 saa7146_write(dev, HPS_H_SCALE, 0); // r6c
492 saa7146_write(dev, BCS_CTRL, 0); // r70 492 saa7146_write(dev, BCS_CTRL, 0); // r70
493 saa7146_write(dev, HPS_V_SCALE, 0); // r60 493 saa7146_write(dev, HPS_V_SCALE, 0); // r60
494 saa7146_write(dev, HPS_V_GAIN, 0); // r64 494 saa7146_write(dev, HPS_V_GAIN, 0); // r64
495 saa7146_write(dev, CHROMA_KEY_RANGE, 0); // r74 495 saa7146_write(dev, CHROMA_KEY_RANGE, 0); // r74
496 saa7146_write(dev, CLIP_FORMAT_CTRL, 0); // r78 496 saa7146_write(dev, CLIP_FORMAT_CTRL, 0); // r78
497 // Set HPS prescaler for port B input 497 // Set HPS prescaler for port B input
498 saa7146_write(dev, HPS_CTRL, (1<<30) | (0<<29) | (1<<28) | (0<<12) ); 498 saa7146_write(dev, HPS_CTRL, (1<<30) | (0<<29) | (1<<28) | (0<<12) );
499 saa7146_write(dev, MC2, 499 saa7146_write(dev, MC2,
500 0 * (MASK_08 | MASK_24) | // BRS control 500 0 * (MASK_08 | MASK_24) | // BRS control
501 0 * (MASK_09 | MASK_25) | // a 501 0 * (MASK_09 | MASK_25) | // a
502 0 * (MASK_10 | MASK_26) | // b 502 0 * (MASK_10 | MASK_26) | // b
503 1 * (MASK_06 | MASK_22) | // HPS_CTRL1 503 1 * (MASK_06 | MASK_22) | // HPS_CTRL1
504 1 * (MASK_05 | MASK_21) | // HPS_CTRL2 504 1 * (MASK_05 | MASK_21) | // HPS_CTRL2
505 0 * (MASK_01 | MASK_15) // DEBI 505 0 * (MASK_01 | MASK_15) // DEBI
506 ); 506 );
507#endif 507#endif
508 // Disable RPS1 and RPS0 508 // Disable RPS1 and RPS0
509 saa7146_write(dev, MC1, ( MASK_29 | MASK_28)); 509 saa7146_write(dev, MC1, ( MASK_29 | MASK_28));
510 // RPS1 timeout disable 510 // RPS1 timeout disable
511 saa7146_write(dev, RPS_TOV1, 0); 511 saa7146_write(dev, RPS_TOV1, 0);
512 512
513 // code for autodetection 513 // code for autodetection
514 // will wait for VBI_B event (vertical blank at port B) 514 // will wait for VBI_B event (vertical blank at port B)
@@ -521,38 +521,38 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
521 WRITE_RPS1(cpu_to_le32(CMD_UPLOAD | 521 WRITE_RPS1(cpu_to_le32(CMD_UPLOAD |
522 MASK_10 | MASK_09 | MASK_08 | MASK_06 | MASK_05 | MASK_04 | MASK_03 | MASK_02 )); 522 MASK_10 | MASK_09 | MASK_08 | MASK_06 | MASK_05 | MASK_04 | MASK_03 | MASK_02 ));
523#endif 523#endif
524 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_VBI_B)); 524 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_VBI_B));
525 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2))); 525 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
526 WRITE_RPS1(cpu_to_le32(GPIO3_MSK)); 526 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
527 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24)); 527 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
528#if RPS_IRQ 528#if RPS_IRQ
529 // issue RPS1 interrupt to increment counter 529 // issue RPS1 interrupt to increment counter
530 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT)); 530 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
531 // at least a NOP is neede between two interrupts 531 // at least a NOP is neede between two interrupts
532 WRITE_RPS1(cpu_to_le32(CMD_NOP)); 532 WRITE_RPS1(cpu_to_le32(CMD_NOP));
533 // interrupt again 533 // interrupt again
534 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT)); 534 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
535#endif 535#endif
536 WRITE_RPS1(cpu_to_le32(CMD_STOP)); 536 WRITE_RPS1(cpu_to_le32(CMD_STOP));
537 537
538#if RPS_IRQ 538#if RPS_IRQ
539 // set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53) 539 // set event counter 1 source as RPS1 interrupt (0x03) (rE4 p53)
540 // use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled 540 // use 0x03 to track RPS1 interrupts - increase by 1 every gpio3 is toggled
541 // use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called 541 // use 0x15 to track VPE interrupts - increase by 1 every vpeirq() is called
542 saa7146_write(dev, EC1SSR, (0x03<<2) | 3 ); 542 saa7146_write(dev, EC1SSR, (0x03<<2) | 3 );
543 // set event counter 1 treshold to maximum allowed value (rEC p55) 543 // set event counter 1 treshold to maximum allowed value (rEC p55)
544 saa7146_write(dev, ECT1R, 0x3fff ); 544 saa7146_write(dev, ECT1R, 0x3fff );
545#endif 545#endif
546 // Fix VSYNC level 546 // Fix VSYNC level
547 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); 547 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
548 // Set RPS1 Address register to point to RPS code (r108 p42) 548 // Set RPS1 Address register to point to RPS code (r108 p42)
549 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle); 549 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
550 // Enable RPS1, (rFC p33) 550 // Enable RPS1, (rFC p33)
551 saa7146_write(dev, MC1, (MASK_13 | MASK_29 )); 551 saa7146_write(dev, MC1, (MASK_13 | MASK_29 ));
552 552
553 553
554 mdelay(50); 554 mdelay(50);
555 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI); 555 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTHI);
556 mdelay(150); 556 mdelay(150);
557 557
558 558
@@ -560,17 +560,17 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
560 detected = 1; 560 detected = 1;
561 561
562#if RPS_IRQ 562#if RPS_IRQ
563 printk("Event Counter 1 0x%04x\n", saa7146_read(dev, EC1R) & 0x3fff ); 563 printk("Event Counter 1 0x%04x\n", saa7146_read(dev, EC1R) & 0x3fff );
564#endif 564#endif
565 // Disable RPS1 565 // Disable RPS1
566 saa7146_write(dev, MC1, ( MASK_29 )); 566 saa7146_write(dev, MC1, ( MASK_29 ));
567 567
568 if(detected == 0) 568 if(detected == 0)
569 printk("budget-patch not detected or saa7146 in non-default state.\n" 569 printk("budget-patch not detected or saa7146 in non-default state.\n"
570 "try enabling ressetting of 7146 with MASK_31 in MC1 register\n"); 570 "try enabling ressetting of 7146 with MASK_31 in MC1 register\n");
571 571
572 else 572 else
573 printk("BUDGET-PATCH DETECTED.\n"); 573 printk("BUDGET-PATCH DETECTED.\n");
574 574
575 575
576/* OLD (Original design by Roberto Deza): 576/* OLD (Original design by Roberto Deza):
@@ -641,83 +641,83 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
641*/ 641*/
642 642
643 // Setup RPS1 "program" (p35) 643 // Setup RPS1 "program" (p35)
644 count = 0; 644 count = 0;
645 645
646 646
647 // Wait Source Line Counter Threshold (p36) 647 // Wait Source Line Counter Threshold (p36)
648 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS)); 648 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | EVT_HS));
649 // Set GPIO3=1 (p42) 649 // Set GPIO3=1 (p42)
650 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2))); 650 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
651 WRITE_RPS1(cpu_to_le32(GPIO3_MSK)); 651 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
652 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTHI<<24)); 652 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTHI<<24));
653#if RPS_IRQ 653#if RPS_IRQ
654 // issue RPS1 interrupt 654 // issue RPS1 interrupt
655 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT)); 655 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
656#endif 656#endif
657 // Wait reset Source Line Counter Threshold (p36) 657 // Wait reset Source Line Counter Threshold (p36)
658 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS)); 658 WRITE_RPS1(cpu_to_le32(CMD_PAUSE | RPS_INV | EVT_HS));
659 // Set GPIO3=0 (p42) 659 // Set GPIO3=0 (p42)
660 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2))); 660 WRITE_RPS1(cpu_to_le32(CMD_WR_REG_MASK | (GPIO_CTRL>>2)));
661 WRITE_RPS1(cpu_to_le32(GPIO3_MSK)); 661 WRITE_RPS1(cpu_to_le32(GPIO3_MSK));
662 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24)); 662 WRITE_RPS1(cpu_to_le32(SAA7146_GPIO_OUTLO<<24));
663#if RPS_IRQ 663#if RPS_IRQ
664 // issue RPS1 interrupt 664 // issue RPS1 interrupt
665 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT)); 665 WRITE_RPS1(cpu_to_le32(CMD_INTERRUPT));
666#endif 666#endif
667 // Jump to begin of RPS program (p37) 667 // Jump to begin of RPS program (p37)
668 WRITE_RPS1(cpu_to_le32(CMD_JUMP)); 668 WRITE_RPS1(cpu_to_le32(CMD_JUMP));
669 WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle)); 669 WRITE_RPS1(cpu_to_le32(dev->d_rps1.dma_handle));
670
671 // Fix VSYNC level
672 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
673 // Set RPS1 Address register to point to RPS code (r108 p42)
674 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
675 // Set Source Line Counter Threshold, using BRS (rCC p43)
676 // It generates HS event every TS_HEIGHT lines
677 // this is related to TS_WIDTH set in register
678 // NUM_LINE_BYTE3 in budget-core.c. If NUM_LINE_BYTE
679 // low 16 bits are set to TS_WIDTH bytes (TS_WIDTH=2*188
680 //,then RPS_THRESH1
681 // should be set to trigger every TS_HEIGHT (512) lines.
682 //
683 saa7146_write(dev, RPS_THRESH1, (TS_HEIGHT*1) | MASK_12 );
684 670
685 // saa7146_write(dev, RPS_THRESH0, ((TS_HEIGHT/2)<<16) |MASK_28| (TS_HEIGHT/2) |MASK_12 ); 671 // Fix VSYNC level
686 // Enable RPS1 (rFC p33) 672 saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO);
687 saa7146_write(dev, MC1, (MASK_13 | MASK_29)); 673 // Set RPS1 Address register to point to RPS code (r108 p42)
688 674 saa7146_write(dev, RPS_ADDR1, dev->d_rps1.dma_handle);
689 675 // Set Source Line Counter Threshold, using BRS (rCC p43)
690 if (!(budget = kmalloc (sizeof(struct budget_patch), GFP_KERNEL))) 676 // It generates HS event every TS_HEIGHT lines
691 return -ENOMEM; 677 // this is related to TS_WIDTH set in register
678 // NUM_LINE_BYTE3 in budget-core.c. If NUM_LINE_BYTE
679 // low 16 bits are set to TS_WIDTH bytes (TS_WIDTH=2*188
680 //,then RPS_THRESH1
681 // should be set to trigger every TS_HEIGHT (512) lines.
682 //
683 saa7146_write(dev, RPS_THRESH1, (TS_HEIGHT*1) | MASK_12 );
684
685 // saa7146_write(dev, RPS_THRESH0, ((TS_HEIGHT/2)<<16) |MASK_28| (TS_HEIGHT/2) |MASK_12 );
686 // Enable RPS1 (rFC p33)
687 saa7146_write(dev, MC1, (MASK_13 | MASK_29));
688
689
690 if (!(budget = kmalloc (sizeof(struct budget_patch), GFP_KERNEL)))
691 return -ENOMEM;
692 692
693 dprintk(2, "budget: %p\n", budget); 693 dprintk(2, "budget: %p\n", budget);
694 694
695 if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) { 695 if ((err = ttpci_budget_init (budget, dev, info, THIS_MODULE))) {
696 kfree (budget); 696 kfree (budget);
697 return err; 697 return err;
698 } 698 }
699 699
700 700
701 dev->ext_priv = budget; 701 dev->ext_priv = budget;
702 702
703 budget->dvb_adapter.priv = budget; 703 budget->dvb_adapter.priv = budget;
704 frontend_init(budget); 704 frontend_init(budget);
705 705
706 return 0; 706 return 0;
707} 707}
708 708
709static int budget_patch_detach (struct saa7146_dev* dev) 709static int budget_patch_detach (struct saa7146_dev* dev)
710{ 710{
711 struct budget_patch *budget = (struct budget_patch*) dev->ext_priv; 711 struct budget_patch *budget = (struct budget_patch*) dev->ext_priv;
712 int err; 712 int err;
713 713
714 if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend); 714 if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend);
715 715
716 err = ttpci_budget_deinit (budget); 716 err = ttpci_budget_deinit (budget);
717 717
718 kfree (budget); 718 kfree (budget);
719 719
720 return err; 720 return err;
721} 721}
722 722
723static int __init budget_patch_init(void) 723static int __init budget_patch_init(void)
@@ -727,20 +727,20 @@ static int __init budget_patch_init(void)
727 727
728static void __exit budget_patch_exit(void) 728static void __exit budget_patch_exit(void)
729{ 729{
730 saa7146_unregister_extension(&budget_extension); 730 saa7146_unregister_extension(&budget_extension);
731} 731}
732 732
733static struct saa7146_extension budget_extension = { 733static struct saa7146_extension budget_extension = {
734 .name = "budget_patch dvb\0", 734 .name = "budget_patch dvb\0",
735 .flags = 0, 735 .flags = 0,
736 736
737 .module = THIS_MODULE, 737 .module = THIS_MODULE,
738 .pci_tbl = pci_tbl, 738 .pci_tbl = pci_tbl,
739 .attach = budget_patch_attach, 739 .attach = budget_patch_attach,
740 .detach = budget_patch_detach, 740 .detach = budget_patch_detach,
741 741
742 .irq_mask = MASK_10, 742 .irq_mask = MASK_10,
743 .irq_func = ttpci_budget_irq10_handler, 743 .irq_func = ttpci_budget_irq10_handler,
744}; 744};
745 745
746module_init(budget_patch_init); 746module_init(budget_patch_init);
@@ -749,4 +749,4 @@ module_exit(budget_patch_exit);
749MODULE_LICENSE("GPL"); 749MODULE_LICENSE("GPL");
750MODULE_AUTHOR("Emard, Roberto Deza, Holger Waechtler, Michael Hunold, others"); 750MODULE_AUTHOR("Emard, Roberto Deza, Holger Waechtler, Michael Hunold, others");
751MODULE_DESCRIPTION("Driver for full TS modified DVB-S SAA7146+AV7110 " 751MODULE_DESCRIPTION("Driver for full TS modified DVB-S SAA7146+AV7110 "
752 "based so-called Budget Patch cards"); 752 "based so-called Budget Patch cards");
diff --git a/drivers/media/dvb/ttpci/budget.c b/drivers/media/dvb/ttpci/budget.c
index bc4ce7559cbe..fafe6407b3d0 100644
--- a/drivers/media/dvb/ttpci/budget.c
+++ b/drivers/media/dvb/ttpci/budget.c
@@ -256,7 +256,7 @@ static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
256 buf[2] = ((div & 0x18000) >> 10) | 0x95; 256 buf[2] = ((div & 0x18000) >> 10) | 0x95;
257 buf[3] = (pwr << 6) | 0x30; 257 buf[3] = (pwr << 6) | 0x30;
258 258
259 // NOTE: since we're using a prescaler of 2, we set the 259 // NOTE: since we're using a prescaler of 2, we set the
260 // divisor frequency to 62.5kHz and divide by 125 above 260 // divisor frequency to 62.5kHz and divide by 125 above
261 261
262 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO; 262 if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
@@ -565,7 +565,7 @@ static u8 read_pwm(struct budget* budget)
565 struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 }, 565 struct i2c_msg msg[] = { { .addr = 0x50,.flags = 0,.buf = &b,.len = 1 },
566 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} }; 566 { .addr = 0x50,.flags = I2C_M_RD,.buf = &pwm,.len = 1} };
567 567
568 if ((i2c_transfer(&budget->i2c_adap, msg, 2) != 2) || (pwm == 0xff)) 568 if ((i2c_transfer(&budget->i2c_adap, msg, 2) != 2) || (pwm == 0xff))
569 pwm = 0x48; 569 pwm = 0x48;
570 570
571 return pwm; 571 return pwm;
@@ -593,7 +593,7 @@ static void frontend_init(struct budget *budget)
593 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap); 593 budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap);
594 if (budget->dvb_frontend) { 594 if (budget->dvb_frontend) {
595 budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd; 595 budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
596 budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst; 596 budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst;
597 budget->dvb_frontend->ops->set_tone = budget_set_tone; 597 budget->dvb_frontend->ops->set_tone = budget_set_tone;
598 break; 598 break;
599 } 599 }
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
index c6ef496ba70a..c8d48cfba277 100644
--- a/drivers/media/dvb/ttpci/budget.h
+++ b/drivers/media/dvb/ttpci/budget.h
@@ -19,7 +19,7 @@ extern int budget_debug;
19#endif 19#endif
20 20
21#define dprintk(level,args...) \ 21#define dprintk(level,args...) \
22 do { if ((budget_debug & level)) { printk("%s: %s(): ",__stringify(KBUILD_MODNAME), __FUNCTION__); printk(args); } } while (0) 22 do { if ((budget_debug & level)) { printk("%s: %s(): ", KBUILD_MODNAME, __FUNCTION__); printk(args); } } while (0)
23 23
24struct budget_info { 24struct budget_info {
25 char *name; 25 char *name;
diff --git a/drivers/media/dvb/ttpci/fdump.c b/drivers/media/dvb/ttpci/fdump.c
index 0b478db3e744..c90001d35e7d 100644
--- a/drivers/media/dvb/ttpci/fdump.c
+++ b/drivers/media/dvb/ttpci/fdump.c
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
36 } 36 }
37 37
38 fprintf(fd_out, "\n};\n\n"); 38 fprintf(fd_out, "\n};\n\n");
39 39
40 fclose(fd_in); 40 fclose(fd_in);
41 fclose(fd_out); 41 fclose(fd_out);
42 42
diff --git a/drivers/media/dvb/ttpci/ttpci-eeprom.c b/drivers/media/dvb/ttpci/ttpci-eeprom.c
index ac79ef178c05..18aa22b5478d 100644
--- a/drivers/media/dvb/ttpci/ttpci-eeprom.c
+++ b/drivers/media/dvb/ttpci/ttpci-eeprom.c
@@ -13,7 +13,7 @@
13 Holger Waechtler Convergence 13 Holger Waechtler Convergence
14 14
15 Copyright (C) 2002-2003 Ralph Metzler <rjkm@metzlerbros.de> 15 Copyright (C) 2002-2003 Ralph Metzler <rjkm@metzlerbros.de>
16 Metzler Brothers Systementwicklung GbR 16 Metzler Brothers Systementwicklung GbR
17 17
18 This program is free software; you can redistribute it and/or modify 18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License as published by 19 it under the terms of the GNU General Public License as published by
@@ -48,41 +48,41 @@
48 48
49static int check_mac_tt(u8 *buf) 49static int check_mac_tt(u8 *buf)
50{ 50{
51 int i; 51 int i;
52 u16 tmp = 0xffff; 52 u16 tmp = 0xffff;
53 53
54 for (i = 0; i < 8; i++) { 54 for (i = 0; i < 8; i++) {
55 tmp = (tmp << 8) | ((tmp >> 8) ^ buf[i]); 55 tmp = (tmp << 8) | ((tmp >> 8) ^ buf[i]);
56 tmp ^= (tmp >> 4) & 0x0f; 56 tmp ^= (tmp >> 4) & 0x0f;
57 tmp ^= (tmp << 12) ^ ((tmp & 0xff) << 5); 57 tmp ^= (tmp << 12) ^ ((tmp & 0xff) << 5);
58 } 58 }
59 tmp ^= 0xffff; 59 tmp ^= 0xffff;
60 return (((tmp >> 8) ^ buf[8]) | ((tmp & 0xff) ^ buf[9])); 60 return (((tmp >> 8) ^ buf[8]) | ((tmp & 0xff) ^ buf[9]));
61} 61}
62 62
63static int getmac_tt(u8 * decodedMAC, u8 * encodedMAC) 63static int getmac_tt(u8 * decodedMAC, u8 * encodedMAC)
64{ 64{
65 u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c, 65 u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c,
66 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6, 66 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6,
67 0x1d, 0x36, 0x64, 0x78}; 67 0x1d, 0x36, 0x64, 0x78};
68 u8 data[20]; 68 u8 data[20];
69 int i; 69 int i;
70 70
71 /* In case there is a sig check failure have the orig contents available */ 71 /* In case there is a sig check failure have the orig contents available */
72 memcpy(data, encodedMAC, 20); 72 memcpy(data, encodedMAC, 20);
73 73
74 for (i = 0; i < 20; i++) 74 for (i = 0; i < 20; i++)
75 data[i] ^= xor[i]; 75 data[i] ^= xor[i];
76 for (i = 0; i < 10; i++) 76 for (i = 0; i < 10; i++)
77 data[i] = ((data[2 * i + 1] << 8) | data[2 * i]) 77 data[i] = ((data[2 * i + 1] << 8) | data[2 * i])
78 >> ((data[2 * i + 1] >> 6) & 3); 78 >> ((data[2 * i + 1] >> 6) & 3);
79 79
80 if (check_mac_tt(data)) 80 if (check_mac_tt(data))
81 return -ENODEV; 81 return -ENODEV;
82 82
83 decodedMAC[0] = data[2]; decodedMAC[1] = data[1]; decodedMAC[2] = data[0]; 83 decodedMAC[0] = data[2]; decodedMAC[1] = data[1]; decodedMAC[2] = data[0];
84 decodedMAC[3] = data[6]; decodedMAC[4] = data[5]; decodedMAC[5] = data[4]; 84 decodedMAC[3] = data[6]; decodedMAC[4] = data[5]; decodedMAC[5] = data[4];
85 return 0; 85 return 0;
86} 86}
87 87
88static int ttpci_eeprom_read_encodedMAC(struct i2c_adapter *adapter, u8 * encodedMAC) 88static int ttpci_eeprom_read_encodedMAC(struct i2c_adapter *adapter, u8 * encodedMAC)
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
index fd53d6010502..104df610dbe1 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-budget.c
@@ -225,8 +225,8 @@ static int ttusb_i2c_msg(struct ttusb *ttusb,
225 225
226 err = ttusb_result(ttusb, b, 0x20); 226 err = ttusb_result(ttusb, b, 0x20);
227 227
228 /* check if the i2c transaction was successful */ 228 /* check if the i2c transaction was successful */
229 if ((snd_len != b[5]) || (rcv_len != b[6])) return -EREMOTEIO; 229 if ((snd_len != b[5]) || (rcv_len != b[6])) return -EREMOTEIO;
230 230
231 if (rcv_len > 0) { 231 if (rcv_len > 0) {
232 232
@@ -489,27 +489,27 @@ static int ttusb_send_diseqc(struct dvb_frontend* fe,
489 489
490static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 490static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
491{ 491{
492 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv; 492 struct ttusb* ttusb = (struct ttusb*) fe->dvb->priv;
493 int ret; 493 int ret;
494 u8 data[1]; 494 u8 data[1];
495 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) }; 495 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) };
496 496
497 switch(voltage) { 497 switch(voltage) {
498 case SEC_VOLTAGE_OFF: 498 case SEC_VOLTAGE_OFF:
499 data[0] = 0x00; 499 data[0] = 0x00;
500 break; 500 break;
501 case SEC_VOLTAGE_13: 501 case SEC_VOLTAGE_13:
502 data[0] = 0x44; 502 data[0] = 0x44;
503 break; 503 break;
504 case SEC_VOLTAGE_18: 504 case SEC_VOLTAGE_18:
505 data[0] = 0x4c; 505 data[0] = 0x4c;
506 break; 506 break;
507 default: 507 default:
508 return -EINVAL; 508 return -EINVAL;
509 }; 509 };
510 510
511 ret = i2c_transfer(&ttusb->i2c_adap, &msg, 1); 511 ret = i2c_transfer(&ttusb->i2c_adap, &msg, 1);
512 return (ret != 1) ? -EIO : 0; 512 return (ret != 1) ? -EIO : 0;
513} 513}
514 514
515static int ttusb_update_lnb(struct ttusb *ttusb) 515static int ttusb_update_lnb(struct ttusb *ttusb)
@@ -1184,45 +1184,45 @@ static struct tda1004x_config philips_tdm1316l_config = {
1184}; 1184};
1185 1185
1186static u8 alps_bsbe1_inittab[] = { 1186static u8 alps_bsbe1_inittab[] = {
1187 0x01, 0x15, 1187 0x01, 0x15,
1188 0x02, 0x30, 1188 0x02, 0x30,
1189 0x03, 0x00, 1189 0x03, 0x00,
1190 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */ 1190 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
1191 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */ 1191 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
1192 0x06, 0x40, /* DAC not used, set to high impendance mode */ 1192 0x06, 0x40, /* DAC not used, set to high impendance mode */
1193 0x07, 0x00, /* DAC LSB */ 1193 0x07, 0x00, /* DAC LSB */
1194 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */ 1194 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
1195 0x09, 0x00, /* FIFO */ 1195 0x09, 0x00, /* FIFO */
1196 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */ 1196 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
1197 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */ 1197 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
1198 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */ 1198 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
1199 0x10, 0x3f, // AGC2 0x3d 1199 0x10, 0x3f, // AGC2 0x3d
1200 0x11, 0x84, 1200 0x11, 0x84,
1201 0x12, 0xb9, 1201 0x12, 0xb9,
1202 0x15, 0xc9, // lock detector threshold 1202 0x15, 0xc9, // lock detector threshold
1203 0x16, 0x00, 1203 0x16, 0x00,
1204 0x17, 0x00, 1204 0x17, 0x00,
1205 0x18, 0x00, 1205 0x18, 0x00,
1206 0x19, 0x00, 1206 0x19, 0x00,
1207 0x1a, 0x00, 1207 0x1a, 0x00,
1208 0x1f, 0x50, 1208 0x1f, 0x50,
1209 0x20, 0x00, 1209 0x20, 0x00,
1210 0x21, 0x00, 1210 0x21, 0x00,
1211 0x22, 0x00, 1211 0x22, 0x00,
1212 0x23, 0x00, 1212 0x23, 0x00,
1213 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0 1213 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
1214 0x29, 0x1e, // 1/2 threshold 1214 0x29, 0x1e, // 1/2 threshold
1215 0x2a, 0x14, // 2/3 threshold 1215 0x2a, 0x14, // 2/3 threshold
1216 0x2b, 0x0f, // 3/4 threshold 1216 0x2b, 0x0f, // 3/4 threshold
1217 0x2c, 0x09, // 5/6 threshold 1217 0x2c, 0x09, // 5/6 threshold
1218 0x2d, 0x05, // 7/8 threshold 1218 0x2d, 0x05, // 7/8 threshold
1219 0x2e, 0x01, 1219 0x2e, 0x01,
1220 0x31, 0x1f, // test all FECs 1220 0x31, 0x1f, // test all FECs
1221 0x32, 0x19, // viterbi and synchro search 1221 0x32, 0x19, // viterbi and synchro search
1222 0x33, 0xfc, // rs control 1222 0x33, 0xfc, // rs control
1223 0x34, 0x93, // error control 1223 0x34, 0x93, // error control
1224 0x0f, 0x92, 1224 0x0f, 0x92,
1225 0xff, 0xff 1225 0xff, 0xff
1226}; 1226};
1227 1227
1228static u8 alps_bsru6_inittab[] = { 1228static u8 alps_bsru6_inittab[] = {
@@ -1350,7 +1350,7 @@ static int ttusb_novas_grundig_29504_491_pll_set(struct dvb_frontend *fe, struct
1350 u32 div; 1350 u32 div;
1351 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) }; 1351 struct i2c_msg msg = {.addr = 0x61,.flags = 0,.buf = buf,.len = sizeof(buf) };
1352 1352
1353 div = params->frequency / 125; 1353 div = params->frequency / 125;
1354 1354
1355 buf[0] = (div >> 8) & 0x7f; 1355 buf[0] = (div >> 8) & 0x7f;
1356 buf[1] = div & 0xff; 1356 buf[1] = div & 0xff;
@@ -1487,7 +1487,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i
1487 1487
1488 udev = interface_to_usbdev(intf); 1488 udev = interface_to_usbdev(intf);
1489 1489
1490 if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV; 1490 if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV;
1491 1491
1492 if (!(ttusb = kmalloc(sizeof(struct ttusb), GFP_KERNEL))) 1492 if (!(ttusb = kmalloc(sizeof(struct ttusb), GFP_KERNEL)))
1493 return -ENOMEM; 1493 return -ENOMEM;
diff --git a/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h b/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h
index 95ee7995455e..8c3cd545e8f4 100644
--- a/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h
+++ b/drivers/media/dvb/ttusb-budget/dvb-ttusb-dspbootcode.h
@@ -2,1643 +2,1643 @@
2#include <asm/types.h> 2#include <asm/types.h>
3 3
4static u8 dsp_bootcode [] = { 4static u8 dsp_bootcode [] = {
5 0x08, 0xaa, 0x00, 0x18, 0x00, 0x03, 0x08, 0x00, 5 0x08, 0xaa, 0x00, 0x18, 0x00, 0x03, 0x08, 0x00,
6 0x00, 0x10, 0x00, 0x00, 0x01, 0x80, 0x18, 0x5f, 6 0x00, 0x10, 0x00, 0x00, 0x01, 0x80, 0x18, 0x5f,
7 0x00, 0x00, 0x01, 0x80, 0x77, 0x18, 0x2a, 0xeb, 7 0x00, 0x00, 0x01, 0x80, 0x77, 0x18, 0x2a, 0xeb,
8 0x6b, 0xf8, 0x00, 0x18, 0x03, 0xff, 0x68, 0xf8, 8 0x6b, 0xf8, 0x00, 0x18, 0x03, 0xff, 0x68, 0xf8,
9 0x00, 0x18, 0xff, 0xfe, 0xf7, 0xb8, 0xf7, 0xbe, 9 0x00, 0x18, 0xff, 0xfe, 0xf7, 0xb8, 0xf7, 0xbe,
10 0xf6, 0xb9, 0xf4, 0xa0, 0xf6, 0xb7, 0xf6, 0xb5, 10 0xf6, 0xb9, 0xf4, 0xa0, 0xf6, 0xb7, 0xf6, 0xb5,
11 0xf6, 0xb6, 0xf0, 0x20, 0x19, 0xdf, 0xf1, 0x00, 11 0xf6, 0xb6, 0xf0, 0x20, 0x19, 0xdf, 0xf1, 0x00,
12 0x00, 0x01, 0xf8, 0x4d, 0x01, 0xab, 0xf6, 0xb8, 12 0x00, 0x01, 0xf8, 0x4d, 0x01, 0xab, 0xf6, 0xb8,
13 0xf0, 0x20, 0x19, 0xdf, 0xf0, 0x73, 0x01, 0xa5, 13 0xf0, 0x20, 0x19, 0xdf, 0xf0, 0x73, 0x01, 0xa5,
14 0x7e, 0xf8, 0x00, 0x12, 0xf0, 0x00, 0x00, 0x01, 14 0x7e, 0xf8, 0x00, 0x12, 0xf0, 0x00, 0x00, 0x01,
15 0x47, 0xf8, 0x00, 0x11, 0x7e, 0x92, 0x00, 0xf8, 15 0x47, 0xf8, 0x00, 0x11, 0x7e, 0x92, 0x00, 0xf8,
16 0x00, 0x11, 0xf0, 0x00, 0x00, 0x01, 0x7e, 0xf8, 16 0x00, 0x11, 0xf0, 0x00, 0x00, 0x01, 0x7e, 0xf8,
17 0x00, 0x11, 0xf0, 0x00, 0x00, 0x01, 0x6c, 0x89, 17 0x00, 0x11, 0xf0, 0x00, 0x00, 0x01, 0x6c, 0x89,
18 0x01, 0x9a, 0xf7, 0xb8, 0xee, 0xfc, 0xf0, 0x20, 18 0x01, 0x9a, 0xf7, 0xb8, 0xee, 0xfc, 0xf0, 0x20,
19 0xff, 0xff, 0xf1, 0x00, 0x00, 0x01, 0xf8, 0x4d, 19 0xff, 0xff, 0xf1, 0x00, 0x00, 0x01, 0xf8, 0x4d,
20 0x01, 0xbf, 0xf2, 0x73, 0x01, 0xb9, 0x4e, 0x02, 20 0x01, 0xbf, 0xf2, 0x73, 0x01, 0xb9, 0x4e, 0x02,
21 0xf4, 0x95, 0xf5, 0xe3, 0x56, 0x02, 0x7e, 0x00, 21 0xf4, 0x95, 0xf5, 0xe3, 0x56, 0x02, 0x7e, 0x00,
22 0x11, 0x00, 0xfa, 0x4c, 0x01, 0xb7, 0x6b, 0x03, 22 0x11, 0x00, 0xfa, 0x4c, 0x01, 0xb7, 0x6b, 0x03,
23 0x00, 0x01, 0xf6, 0xb8, 0xee, 0x04, 0xf0, 0x74, 23 0x00, 0x01, 0xf6, 0xb8, 0xee, 0x04, 0xf0, 0x74,
24 0x0d, 0xa7, 0xf0, 0x74, 0x01, 0xc5, 0x4a, 0x11, 24 0x0d, 0xa7, 0xf0, 0x74, 0x01, 0xc5, 0x4a, 0x11,
25 0x4a, 0x16, 0x72, 0x11, 0x2a, 0xe6, 0x10, 0xf8, 25 0x4a, 0x16, 0x72, 0x11, 0x2a, 0xe6, 0x10, 0xf8,
26 0x00, 0x11, 0xfa, 0x45, 0x01, 0xdb, 0xf4, 0x95, 26 0x00, 0x11, 0xfa, 0x45, 0x01, 0xdb, 0xf4, 0x95,
27 0xee, 0xff, 0x48, 0x11, 0xf0, 0x00, 0x2a, 0xc6, 27 0xee, 0xff, 0x48, 0x11, 0xf0, 0x00, 0x2a, 0xc6,
28 0x88, 0x16, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0xee, 28 0x88, 0x16, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0xee,
29 0xff, 0xff, 0xf4, 0xe3, 0x6c, 0xe9, 0xff, 0xff, 29 0xff, 0xff, 0xf4, 0xe3, 0x6c, 0xe9, 0xff, 0xff,
30 0x01, 0xd5, 0x10, 0xf8, 0x2a, 0xe7, 0xf8, 0x45, 30 0x01, 0xd5, 0x10, 0xf8, 0x2a, 0xe7, 0xf8, 0x45,
31 0x01, 0xe2, 0x10, 0xf8, 0x2a, 0xe7, 0xf4, 0xe3, 31 0x01, 0xe2, 0x10, 0xf8, 0x2a, 0xe7, 0xf4, 0xe3,
32 0xf0, 0x74, 0x01, 0xff, 0xee, 0x01, 0x8a, 0x16, 32 0xf0, 0x74, 0x01, 0xff, 0xee, 0x01, 0x8a, 0x16,
33 0x8a, 0x11, 0xfc, 0x00, 0xf7, 0xb8, 0xe9, 0x20, 33 0x8a, 0x11, 0xfc, 0x00, 0xf7, 0xb8, 0xe9, 0x20,
34 0x4a, 0x11, 0x09, 0xf8, 0x2a, 0xe6, 0xf8, 0x4e, 34 0x4a, 0x11, 0x09, 0xf8, 0x2a, 0xe6, 0xf8, 0x4e,
35 0x01, 0xf3, 0xf2, 0x73, 0x01, 0xfd, 0xf4, 0x95, 35 0x01, 0xf3, 0xf2, 0x73, 0x01, 0xfd, 0xf4, 0x95,
36 0xe8, 0x01, 0x72, 0x11, 0x2a, 0xe6, 0x49, 0x11, 36 0xe8, 0x01, 0x72, 0x11, 0x2a, 0xe6, 0x49, 0x11,
37 0x80, 0xe1, 0x2a, 0xc6, 0xf3, 0x00, 0x00, 0x01, 37 0x80, 0xe1, 0x2a, 0xc6, 0xf3, 0x00, 0x00, 0x01,
38 0xe8, 0x00, 0x81, 0xf8, 0x2a, 0xe6, 0x8a, 0x11, 38 0xe8, 0x00, 0x81, 0xf8, 0x2a, 0xe6, 0x8a, 0x11,
39 0xfc, 0x00, 0xf4, 0x95, 0xf0, 0x73, 0x02, 0x00, 39 0xfc, 0x00, 0xf4, 0x95, 0xf0, 0x73, 0x02, 0x00,
40 0x10, 0xf8, 0x2a, 0x0f, 0xfc, 0x00, 0x4a, 0x11, 40 0x10, 0xf8, 0x2a, 0x0f, 0xfc, 0x00, 0x4a, 0x11,
41 0xf0, 0x74, 0x02, 0x02, 0x80, 0xf8, 0x2a, 0x10, 41 0xf0, 0x74, 0x02, 0x02, 0x80, 0xf8, 0x2a, 0x10,
42 0x73, 0x08, 0x00, 0x09, 0x40, 0xf8, 0x2a, 0x15, 42 0x73, 0x08, 0x00, 0x09, 0x40, 0xf8, 0x2a, 0x15,
43 0x82, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0x77, 0x10, 43 0x82, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0x77, 0x10,
44 0x03, 0xe8, 0xf5, 0xa9, 0xf8, 0x30, 0x02, 0x21, 44 0x03, 0xe8, 0xf5, 0xa9, 0xf8, 0x30, 0x02, 0x21,
45 0x71, 0xf8, 0x2a, 0x10, 0x2a, 0x15, 0x56, 0xf8, 45 0x71, 0xf8, 0x2a, 0x10, 0x2a, 0x15, 0x56, 0xf8,
46 0x2a, 0x0c, 0xf0, 0xe3, 0x4e, 0xf8, 0x2a, 0x16, 46 0x2a, 0x0c, 0xf0, 0xe3, 0x4e, 0xf8, 0x2a, 0x16,
47 0xe8, 0x00, 0x4e, 0xf8, 0x2a, 0x0c, 0x8a, 0x11, 47 0xe8, 0x00, 0x4e, 0xf8, 0x2a, 0x0c, 0x8a, 0x11,
48 0xfc, 0x00, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1d, 48 0xfc, 0x00, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1d,
49 0x68, 0xf8, 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 49 0x68, 0xf8, 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8,
50 0x00, 0x07, 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 50 0x00, 0x07, 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d,
51 0xff, 0xfc, 0x6b, 0xf8, 0x2a, 0x0f, 0x00, 0x01, 51 0xff, 0xfc, 0x6b, 0xf8, 0x2a, 0x0f, 0x00, 0x01,
52 0x8a, 0x1d, 0x8a, 0x07, 0x8a, 0x06, 0xf4, 0xeb, 52 0x8a, 0x1d, 0x8a, 0x07, 0x8a, 0x06, 0xf4, 0xeb,
53 0xee, 0xfd, 0x76, 0xf8, 0x2a, 0x0f, 0x00, 0x00, 53 0xee, 0xfd, 0x76, 0xf8, 0x2a, 0x0f, 0x00, 0x00,
54 0x76, 0x00, 0x00, 0x00, 0xfb, 0x80, 0x19, 0x4c, 54 0x76, 0x00, 0x00, 0x00, 0xfb, 0x80, 0x19, 0x4c,
55 0xf4, 0x95, 0xe8, 0x00, 0x80, 0xf8, 0x2a, 0x11, 55 0xf4, 0x95, 0xe8, 0x00, 0x80, 0xf8, 0x2a, 0x11,
56 0xf9, 0x80, 0x19, 0x07, 0x80, 0xf8, 0x2a, 0x0e, 56 0xf9, 0x80, 0x19, 0x07, 0x80, 0xf8, 0x2a, 0x0e,
57 0xf9, 0x80, 0x16, 0x66, 0x76, 0x00, 0x2a, 0x12, 57 0xf9, 0x80, 0x16, 0x66, 0x76, 0x00, 0x2a, 0x12,
58 0x10, 0xf8, 0x2a, 0x11, 0xf9, 0x80, 0x18, 0xe3, 58 0x10, 0xf8, 0x2a, 0x11, 0xf9, 0x80, 0x18, 0xe3,
59 0x10, 0xf8, 0x2a, 0x0e, 0xf9, 0x80, 0x16, 0x66, 59 0x10, 0xf8, 0x2a, 0x0e, 0xf9, 0x80, 0x16, 0x66,
60 0x10, 0xf8, 0x2a, 0x0e, 0xf9, 0x80, 0x16, 0x87, 60 0x10, 0xf8, 0x2a, 0x0e, 0xf9, 0x80, 0x16, 0x87,
61 0xee, 0x03, 0xfc, 0x00, 0x4a, 0x11, 0xf6, 0xb8, 61 0xee, 0x03, 0xfc, 0x00, 0x4a, 0x11, 0xf6, 0xb8,
62 0xf4, 0x95, 0xf0, 0x20, 0x80, 0x00, 0x11, 0xf8, 62 0xf4, 0x95, 0xf0, 0x20, 0x80, 0x00, 0x11, 0xf8,
63 0x2a, 0x5a, 0xf8, 0x4d, 0x02, 0x93, 0x11, 0xf8, 63 0x2a, 0x5a, 0xf8, 0x4d, 0x02, 0x93, 0x11, 0xf8,
64 0x2a, 0x9f, 0xf8, 0x4c, 0x02, 0x7c, 0x77, 0x12, 64 0x2a, 0x9f, 0xf8, 0x4c, 0x02, 0x7c, 0x77, 0x12,
65 0x2a, 0x39, 0x49, 0x12, 0x01, 0xf8, 0x2a, 0x9f, 65 0x2a, 0x39, 0x49, 0x12, 0x01, 0xf8, 0x2a, 0x9f,
66 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0x81, 66 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0x81,
67 0x00, 0x11, 0x6c, 0xe1, 0xff, 0xab, 0x02, 0x93, 67 0x00, 0x11, 0x6c, 0xe1, 0xff, 0xab, 0x02, 0x93,
68 0x6b, 0xf8, 0x2a, 0x9f, 0x00, 0x01, 0xe9, 0x05, 68 0x6b, 0xf8, 0x2a, 0x9f, 0x00, 0x01, 0xe9, 0x05,
69 0x01, 0xe2, 0x00, 0x03, 0x81, 0xf8, 0x2a, 0xa0, 69 0x01, 0xe2, 0x00, 0x03, 0x81, 0xf8, 0x2a, 0xa0,
70 0xf0, 0x73, 0x02, 0x95, 0x72, 0x11, 0x2a, 0x9f, 70 0xf0, 0x73, 0x02, 0x95, 0x72, 0x11, 0x2a, 0x9f,
71 0xf4, 0x95, 0x10, 0xe1, 0x2a, 0x39, 0x6b, 0xf8, 71 0xf4, 0x95, 0x10, 0xe1, 0x2a, 0x39, 0x6b, 0xf8,
72 0x2a, 0x9f, 0x00, 0x01, 0x11, 0xf8, 0x2a, 0x9f, 72 0x2a, 0x9f, 0x00, 0x01, 0x11, 0xf8, 0x2a, 0x9f,
73 0x09, 0xf8, 0x2a, 0xa0, 0xf8, 0x4c, 0x02, 0x93, 73 0x09, 0xf8, 0x2a, 0xa0, 0xf8, 0x4c, 0x02, 0x93,
74 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x00, 0x76, 0xf8, 74 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x00, 0x76, 0xf8,
75 0x2a, 0x9f, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa0, 75 0x2a, 0x9f, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa0,
76 0x00, 0x00, 0x88, 0x11, 0xf4, 0x95, 0x48, 0x11, 76 0x00, 0x00, 0x88, 0x11, 0xf4, 0x95, 0x48, 0x11,
77 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 77 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
78 0x10, 0xf8, 0x2a, 0x5a, 0xf8, 0x44, 0x02, 0xb2, 78 0x10, 0xf8, 0x2a, 0x5a, 0xf8, 0x44, 0x02, 0xb2,
79 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x01, 0xf0, 0x74, 79 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x01, 0xf0, 0x74,
80 0x02, 0x58, 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10, 80 0x02, 0x58, 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10,
81 0x80, 0x00, 0xf4, 0xa9, 0xf8, 0x30, 0x02, 0xb2, 81 0x80, 0x00, 0xf4, 0xa9, 0xf8, 0x30, 0x02, 0xb2,
82 0x48, 0x11, 0xf0, 0x30, 0x00, 0xff, 0x80, 0x00, 82 0x48, 0x11, 0xf0, 0x30, 0x00, 0xff, 0x80, 0x00,
83 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x18, 0xd6, 83 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x18, 0xd6,
84 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00, 0xf4, 0x95, 84 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00, 0xf4, 0x95,
85 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a, 0x4a, 0x0b, 85 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a, 0x4a, 0x0b,
86 0x4a, 0x0c, 0x4a, 0x0d, 0x4a, 0x10, 0x4a, 0x11, 86 0x4a, 0x0c, 0x4a, 0x0d, 0x4a, 0x10, 0x4a, 0x11,
87 0x4a, 0x12, 0x4a, 0x13, 0x4a, 0x14, 0x4a, 0x15, 87 0x4a, 0x12, 0x4a, 0x13, 0x4a, 0x14, 0x4a, 0x15,
88 0x4a, 0x16, 0x4a, 0x17, 0x4a, 0x17, 0x4a, 0x19, 88 0x4a, 0x16, 0x4a, 0x17, 0x4a, 0x17, 0x4a, 0x19,
89 0x4a, 0x0e, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1a, 89 0x4a, 0x0e, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1a,
90 0x4a, 0x1d, 0x4a, 0x1b, 0x4a, 0x1c, 0x68, 0xf8, 90 0x4a, 0x1d, 0x4a, 0x1b, 0x4a, 0x1c, 0x68, 0xf8,
91 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07, 91 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
92 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc, 92 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
93 0x48, 0x18, 0x68, 0xf8, 0x00, 0x18, 0xff, 0xfe, 93 0x48, 0x18, 0x68, 0xf8, 0x00, 0x18, 0xff, 0xfe,
94 0xf4, 0x95, 0xf4, 0x95, 0x4a, 0x08, 0xee, 0xfd, 94 0xf4, 0x95, 0xf4, 0x95, 0x4a, 0x08, 0xee, 0xfd,
95 0xf0, 0x74, 0x02, 0x58, 0x88, 0x11, 0xf4, 0x95, 95 0xf0, 0x74, 0x02, 0x58, 0x88, 0x11, 0xf4, 0x95,
96 0x77, 0x10, 0x80, 0x00, 0xf4, 0xa9, 0xf8, 0x30, 96 0x77, 0x10, 0x80, 0x00, 0xf4, 0xa9, 0xf8, 0x30,
97 0x02, 0xef, 0x48, 0x11, 0xf0, 0x30, 0x00, 0xff, 97 0x02, 0xef, 0x48, 0x11, 0xf0, 0x30, 0x00, 0xff,
98 0x80, 0x00, 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 98 0x80, 0x00, 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80,
99 0x18, 0xd6, 0xee, 0x03, 0x8a, 0x18, 0xf4, 0x95, 99 0x18, 0xd6, 0xee, 0x03, 0x8a, 0x18, 0xf4, 0x95,
100 0x8a, 0x1c, 0x8a, 0x1b, 0x8a, 0x1d, 0x8a, 0x1a, 100 0x8a, 0x1c, 0x8a, 0x1b, 0x8a, 0x1d, 0x8a, 0x1a,
101 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0e, 0x8a, 0x19, 101 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0e, 0x8a, 0x19,
102 0x8a, 0x17, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x15, 102 0x8a, 0x17, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x15,
103 0x8a, 0x14, 0x8a, 0x13, 0x8a, 0x12, 0x8a, 0x11, 103 0x8a, 0x14, 0x8a, 0x13, 0x8a, 0x12, 0x8a, 0x11,
104 0x8a, 0x10, 0x8a, 0x0d, 0x8a, 0x0c, 0x8a, 0x0b, 104 0x8a, 0x10, 0x8a, 0x0d, 0x8a, 0x0c, 0x8a, 0x0b,
105 0x8a, 0x0a, 0x8a, 0x09, 0x8a, 0x08, 0xf4, 0xeb, 105 0x8a, 0x0a, 0x8a, 0x09, 0x8a, 0x08, 0xf4, 0xeb,
106 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 106 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81,
107 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2, 107 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2,
108 0x00, 0x01, 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe2, 108 0x00, 0x01, 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe2,
109 0x00, 0x02, 0x80, 0xe1, 0x00, 0x02, 0x76, 0xe1, 109 0x00, 0x02, 0x80, 0xe1, 0x00, 0x02, 0x76, 0xe1,
110 0x00, 0x03, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04, 110 0x00, 0x03, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04,
111 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11, 111 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11,
112 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11, 0xf4, 0x95, 112 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11, 0xf4, 0x95,
113 0xf4, 0x95, 0x10, 0x81, 0x6f, 0xf8, 0x2a, 0x9e, 113 0xf4, 0x95, 0x10, 0x81, 0x6f, 0xf8, 0x2a, 0x9e,
114 0x0c, 0x88, 0xe8, 0xff, 0x18, 0xe1, 0x00, 0x01, 114 0x0c, 0x88, 0xe8, 0xff, 0x18, 0xe1, 0x00, 0x01,
115 0x1a, 0xf8, 0x2a, 0x9e, 0xf0, 0x30, 0x1f, 0xff, 115 0x1a, 0xf8, 0x2a, 0x9e, 0xf0, 0x30, 0x1f, 0xff,
116 0x80, 0xf8, 0x2a, 0x9e, 0x8a, 0x11, 0xfc, 0x00, 116 0x80, 0xf8, 0x2a, 0x9e, 0x8a, 0x11, 0xfc, 0x00,
117 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 117 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81,
118 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18, 0x11, 0xe2, 118 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18, 0x11, 0xe2,
119 0x00, 0x01, 0x81, 0xe1, 0x00, 0x01, 0x11, 0xe2, 119 0x00, 0x01, 0x81, 0xe1, 0x00, 0x01, 0x11, 0xe2,
120 0x00, 0x02, 0x81, 0xe1, 0x00, 0x02, 0x76, 0xe1, 120 0x00, 0x02, 0x81, 0xe1, 0x00, 0x02, 0x76, 0xe1,
121 0x00, 0x03, 0x00, 0x02, 0x48, 0x08, 0x6f, 0xe1, 121 0x00, 0x03, 0x00, 0x02, 0x48, 0x08, 0x6f, 0xe1,
122 0x00, 0x04, 0x0c, 0x98, 0xf0, 0x30, 0x00, 0xff, 122 0x00, 0x04, 0x0c, 0x98, 0xf0, 0x30, 0x00, 0xff,
123 0x80, 0xe1, 0x00, 0x05, 0x76, 0xe1, 0x00, 0x06, 123 0x80, 0xe1, 0x00, 0x05, 0x76, 0xe1, 0x00, 0x06,
124 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11, 124 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11,
125 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39, 125 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11, 0x2a, 0x39,
126 0x76, 0x81, 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18, 126 0x76, 0x81, 0x00, 0x55, 0x77, 0x12, 0x2a, 0x18,
127 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1, 0x00, 0x01, 127 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1, 0x00, 0x01,
128 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1, 0x00, 0x02, 128 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1, 0x00, 0x02,
129 0x76, 0xe1, 0x00, 0x03, 0x00, 0x04, 0x48, 0x11, 129 0x76, 0xe1, 0x00, 0x03, 0x00, 0x04, 0x48, 0x11,
130 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12, 0xf4, 0x95, 130 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12, 0xf4, 0x95,
131 0x77, 0x13, 0x2a, 0x76, 0xe9, 0x00, 0xe5, 0x98, 131 0x77, 0x13, 0x2a, 0x76, 0xe9, 0x00, 0xe5, 0x98,
132 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8, 0x48, 0x0b, 132 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8, 0x48, 0x0b,
133 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 0x03, 0x71, 133 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 0x03, 0x71,
134 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 134 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98,
135 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xf0, 135 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xf0,
136 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0x81, 136 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0x81,
137 0x00, 0x14, 0x71, 0xe1, 0x00, 0x01, 0x00, 0x15, 137 0x00, 0x14, 0x71, 0xe1, 0x00, 0x01, 0x00, 0x15,
138 0x49, 0x11, 0xf3, 0x00, 0x00, 0x02, 0x89, 0x11, 138 0x49, 0x11, 0xf3, 0x00, 0x00, 0x02, 0x89, 0x11,
139 0xe7, 0x82, 0x6d, 0xea, 0x00, 0x04, 0xe7, 0x83, 139 0xe7, 0x82, 0x6d, 0xea, 0x00, 0x04, 0xe7, 0x83,
140 0x6d, 0xeb, 0x00, 0x0a, 0x77, 0x1a, 0x00, 0x05, 140 0x6d, 0xeb, 0x00, 0x0a, 0x77, 0x1a, 0x00, 0x05,
141 0xf0, 0x72, 0x03, 0xaa, 0x11, 0x81, 0xf2, 0xe8, 141 0xf0, 0x72, 0x03, 0xaa, 0x11, 0x81, 0xf2, 0xe8,
142 0x80, 0x82, 0xe9, 0xff, 0x19, 0xe1, 0x00, 0x01, 142 0x80, 0x82, 0xe9, 0xff, 0x19, 0xe1, 0x00, 0x01,
143 0xf1, 0xa0, 0x81, 0x92, 0x11, 0xe1, 0x00, 0x0c, 143 0xf1, 0xa0, 0x81, 0x92, 0x11, 0xe1, 0x00, 0x0c,
144 0xf2, 0xe8, 0x80, 0x83, 0xe9, 0xff, 0x19, 0xe1, 144 0xf2, 0xe8, 0x80, 0x83, 0xe9, 0xff, 0x19, 0xe1,
145 0x00, 0x0d, 0xf1, 0xa0, 0x81, 0x93, 0x6d, 0xe9, 145 0x00, 0x0d, 0xf1, 0xa0, 0x81, 0x93, 0x6d, 0xe9,
146 0x00, 0x02, 0x48, 0x18, 0x49, 0x18, 0x70, 0x00, 146 0x00, 0x02, 0x48, 0x18, 0x49, 0x18, 0x70, 0x00,
147 0x00, 0x15, 0xf0, 0x00, 0x00, 0x04, 0xf3, 0x00, 147 0x00, 0x15, 0xf0, 0x00, 0x00, 0x04, 0xf3, 0x00,
148 0x00, 0x0a, 0x80, 0x01, 0x81, 0x02, 0xf2, 0x74, 148 0x00, 0x0a, 0x80, 0x01, 0x81, 0x02, 0xf2, 0x74,
149 0x0e, 0x54, 0xf4, 0x95, 0x48, 0x14, 0xee, 0x10, 149 0x0e, 0x54, 0xf4, 0x95, 0x48, 0x14, 0xee, 0x10,
150 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xf0, 0x74, 150 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xf0, 0x74,
151 0x0c, 0x5e, 0x80, 0xf8, 0x2a, 0x5c, 0x77, 0x12, 151 0x0c, 0x5e, 0x80, 0xf8, 0x2a, 0x5c, 0x77, 0x12,
152 0x2a, 0x39, 0x76, 0x82, 0x00, 0x55, 0x77, 0x11, 152 0x2a, 0x39, 0x76, 0x82, 0x00, 0x55, 0x77, 0x11,
153 0x2a, 0x18, 0x10, 0xe1, 0x00, 0x01, 0x80, 0xe2, 153 0x2a, 0x18, 0x10, 0xe1, 0x00, 0x01, 0x80, 0xe2,
154 0x00, 0x01, 0x10, 0xe1, 0x00, 0x02, 0x80, 0xe2, 154 0x00, 0x01, 0x10, 0xe1, 0x00, 0x02, 0x80, 0xe2,
155 0x00, 0x02, 0x76, 0xe2, 0x00, 0x03, 0x00, 0x1c, 155 0x00, 0x02, 0x76, 0xe2, 0x00, 0x03, 0x00, 0x1c,
156 0xf6, 0xb8, 0x56, 0xf8, 0x2a, 0x16, 0xf0, 0xf0, 156 0xf6, 0xb8, 0x56, 0xf8, 0x2a, 0x16, 0xf0, 0xf0,
157 0xf0, 0xf8, 0x80, 0xe2, 0x00, 0x07, 0x56, 0xf8, 157 0xf0, 0xf8, 0x80, 0xe2, 0x00, 0x07, 0x56, 0xf8,
158 0x2a, 0x16, 0xf1, 0xf0, 0xe8, 0xff, 0xf2, 0x80, 158 0x2a, 0x16, 0xf1, 0xf0, 0xe8, 0xff, 0xf2, 0x80,
159 0x80, 0xe2, 0x00, 0x06, 0x56, 0xf8, 0x2a, 0x16, 159 0x80, 0xe2, 0x00, 0x06, 0x56, 0xf8, 0x2a, 0x16,
160 0xf1, 0xf8, 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2, 160 0xf1, 0xf8, 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2,
161 0x00, 0x05, 0x57, 0xf8, 0x2a, 0x16, 0xe8, 0xff, 161 0x00, 0x05, 0x57, 0xf8, 0x2a, 0x16, 0xe8, 0xff,
162 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x04, 0x56, 0xf8, 162 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x04, 0x56, 0xf8,
163 0x27, 0x6c, 0xf0, 0xf0, 0xf0, 0xf8, 0x80, 0xe2, 163 0x27, 0x6c, 0xf0, 0xf0, 0xf0, 0xf8, 0x80, 0xe2,
164 0x00, 0x0b, 0x56, 0xf8, 0x27, 0x6c, 0xf1, 0xf0, 164 0x00, 0x0b, 0x56, 0xf8, 0x27, 0x6c, 0xf1, 0xf0,
165 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x0a, 165 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x0a,
166 0x56, 0xf8, 0x27, 0x6c, 0xf1, 0xf8, 0xe8, 0xff, 166 0x56, 0xf8, 0x27, 0x6c, 0xf1, 0xf8, 0xe8, 0xff,
167 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x09, 0xe8, 0xff, 167 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x09, 0xe8, 0xff,
168 0x57, 0xf8, 0x27, 0x6c, 0xf2, 0x80, 0x80, 0xe2, 168 0x57, 0xf8, 0x27, 0x6c, 0xf2, 0x80, 0x80, 0xe2,
169 0x00, 0x08, 0x56, 0xf8, 0x27, 0x6a, 0xf0, 0xf0, 169 0x00, 0x08, 0x56, 0xf8, 0x27, 0x6a, 0xf0, 0xf0,
170 0xf0, 0xf8, 0x80, 0xe2, 0x00, 0x0f, 0x56, 0xf8, 170 0xf0, 0xf8, 0x80, 0xe2, 0x00, 0x0f, 0x56, 0xf8,
171 0x27, 0x6a, 0xf1, 0xf0, 0xe8, 0xff, 0xf2, 0x80, 171 0x27, 0x6a, 0xf1, 0xf0, 0xe8, 0xff, 0xf2, 0x80,
172 0x80, 0xe2, 0x00, 0x0e, 0x56, 0xf8, 0x27, 0x6a, 172 0x80, 0xe2, 0x00, 0x0e, 0x56, 0xf8, 0x27, 0x6a,
173 0xf1, 0xf8, 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2, 173 0xf1, 0xf8, 0xe8, 0xff, 0xf2, 0x80, 0x80, 0xe2,
174 0x00, 0x0d, 0x57, 0xf8, 0x27, 0x6a, 0xe8, 0xff, 174 0x00, 0x0d, 0x57, 0xf8, 0x27, 0x6a, 0xe8, 0xff,
175 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x0c, 0x76, 0xe2, 175 0xf2, 0x80, 0x80, 0xe2, 0x00, 0x0c, 0x76, 0xe2,
176 0x00, 0x13, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x12, 176 0x00, 0x13, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x12,
177 0x00, 0x00, 0x6f, 0xf8, 0x2a, 0x5c, 0x0c, 0x58, 177 0x00, 0x00, 0x6f, 0xf8, 0x2a, 0x5c, 0x0c, 0x58,
178 0x80, 0xe2, 0x00, 0x11, 0xe8, 0xff, 0x18, 0xf8, 178 0x80, 0xe2, 0x00, 0x11, 0xe8, 0xff, 0x18, 0xf8,
179 0x2a, 0x5c, 0x80, 0xe2, 0x00, 0x10, 0x76, 0xe2, 179 0x2a, 0x5c, 0x80, 0xe2, 0x00, 0x10, 0x76, 0xe2,
180 0x00, 0x17, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x16, 180 0x00, 0x17, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x16,
181 0x00, 0x00, 0x6f, 0xf8, 0x2a, 0x9e, 0x0c, 0x58, 181 0x00, 0x00, 0x6f, 0xf8, 0x2a, 0x9e, 0x0c, 0x58,
182 0x80, 0xe2, 0x00, 0x15, 0xe8, 0xff, 0x18, 0xf8, 182 0x80, 0xe2, 0x00, 0x15, 0xe8, 0xff, 0x18, 0xf8,
183 0x2a, 0x9e, 0x80, 0xe2, 0x00, 0x14, 0x76, 0xe2, 183 0x2a, 0x9e, 0x80, 0xe2, 0x00, 0x14, 0x76, 0xe2,
184 0x00, 0x1b, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1a, 184 0x00, 0x1b, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1a,
185 0x00, 0x00, 0x76, 0xe2, 0x00, 0x19, 0x00, 0x00, 185 0x00, 0x00, 0x76, 0xe2, 0x00, 0x19, 0x00, 0x00,
186 0x70, 0xe2, 0x00, 0x18, 0x27, 0x6e, 0x76, 0xe2, 186 0x70, 0xe2, 0x00, 0x18, 0x27, 0x6e, 0x76, 0xe2,
187 0x00, 0x1f, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1e, 187 0x00, 0x1f, 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1e,
188 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1d, 0x00, 0x00, 188 0x00, 0x00, 0x76, 0xe2, 0x00, 0x1d, 0x00, 0x00,
189 0x76, 0xe2, 0x00, 0x1c, 0x00, 0x00, 0x76, 0xe2, 189 0x76, 0xe2, 0x00, 0x1c, 0x00, 0x00, 0x76, 0xe2,
190 0x00, 0x20, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 190 0x00, 0x20, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98,
191 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 191 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
192 0x10, 0xf8, 0x2a, 0x38, 0xf8, 0x45, 0x04, 0xed, 192 0x10, 0xf8, 0x2a, 0x38, 0xf8, 0x45, 0x04, 0xed,
193 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x02, 193 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x02,
194 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x08, 194 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x08,
195 0x6d, 0xe9, 0xff, 0xdf, 0xf6, 0xa9, 0xf8, 0x20, 195 0x6d, 0xe9, 0xff, 0xdf, 0xf6, 0xa9, 0xf8, 0x20,
196 0x04, 0x75, 0xf0, 0x73, 0x04, 0x7d, 0xf0, 0x10, 196 0x04, 0x75, 0xf0, 0x73, 0x04, 0x7d, 0xf0, 0x10,
197 0x00, 0x21, 0xf0, 0x00, 0x1a, 0x83, 0x48, 0x08, 197 0x00, 0x21, 0xf0, 0x00, 0x1a, 0x83, 0x48, 0x08,
198 0x7e, 0xf8, 0x00, 0x08, 0xf4, 0xe2, 0xf0, 0x74, 198 0x7e, 0xf8, 0x00, 0x08, 0xf4, 0xe2, 0xf0, 0x74,
199 0x03, 0x0a, 0xf0, 0x73, 0x04, 0xea, 0x48, 0x12, 199 0x03, 0x0a, 0xf0, 0x73, 0x04, 0xea, 0x48, 0x12,
200 0xf2, 0x74, 0x03, 0x23, 0xf0, 0x00, 0x00, 0x04, 200 0xf2, 0x74, 0x03, 0x23, 0xf0, 0x00, 0x00, 0x04,
201 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00, 201 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00,
202 0xf0, 0x73, 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18, 202 0xf0, 0x73, 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18,
203 0xe8, 0xff, 0x6f, 0xe1, 0x00, 0x04, 0x0d, 0x48, 203 0xe8, 0xff, 0x6f, 0xe1, 0x00, 0x04, 0x0d, 0x48,
204 0x18, 0xe1, 0x00, 0x05, 0xf2, 0x74, 0x09, 0x69, 204 0x18, 0xe1, 0x00, 0x05, 0xf2, 0x74, 0x09, 0x69,
205 0xf4, 0x95, 0xf2, 0xa0, 0xf0, 0x74, 0x03, 0x36, 205 0xf4, 0x95, 0xf2, 0xa0, 0xf0, 0x74, 0x03, 0x36,
206 0xf0, 0x73, 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18, 206 0xf0, 0x73, 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18,
207 0xe8, 0xff, 0x6f, 0xe1, 0x00, 0x04, 0x0d, 0x48, 207 0xe8, 0xff, 0x6f, 0xe1, 0x00, 0x04, 0x0d, 0x48,
208 0x18, 0xe1, 0x00, 0x05, 0xf2, 0x74, 0x09, 0x41, 208 0x18, 0xe1, 0x00, 0x05, 0xf2, 0x74, 0x09, 0x41,
209 0xf4, 0x95, 0xf2, 0xa0, 0xf0, 0x74, 0x03, 0x36, 209 0xf4, 0x95, 0xf2, 0xa0, 0xf0, 0x74, 0x03, 0x36,
210 0xf0, 0x73, 0x04, 0xea, 0xf0, 0x74, 0x03, 0x57, 210 0xf0, 0x73, 0x04, 0xea, 0xf0, 0x74, 0x03, 0x57,
211 0xf0, 0x73, 0x04, 0xea, 0x10, 0xf8, 0x2a, 0x1c, 211 0xf0, 0x73, 0x04, 0xea, 0x10, 0xf8, 0x2a, 0x1c,
212 0xf0, 0x74, 0x12, 0xa4, 0xf2, 0x74, 0x03, 0x36, 212 0xf0, 0x74, 0x12, 0xa4, 0xf2, 0x74, 0x03, 0x36,
213 0xf4, 0x95, 0xe8, 0x00, 0xf0, 0x73, 0x04, 0xea, 213 0xf4, 0x95, 0xe8, 0x00, 0xf0, 0x73, 0x04, 0xea,
214 0x48, 0x12, 0xf2, 0x74, 0x03, 0x80, 0xf0, 0x00, 214 0x48, 0x12, 0xf2, 0x74, 0x03, 0x80, 0xf0, 0x00,
215 0x00, 0x04, 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95, 215 0x00, 0x04, 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95,
216 0xe8, 0x00, 0xf0, 0x73, 0x04, 0xea, 0x10, 0xf8, 216 0xe8, 0x00, 0xf0, 0x73, 0x04, 0xea, 0x10, 0xf8,
217 0x2a, 0x1c, 0xf0, 0x74, 0x12, 0xc5, 0xf2, 0x74, 217 0x2a, 0x1c, 0xf0, 0x74, 0x12, 0xc5, 0xf2, 0x74,
218 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00, 0xf0, 0x73, 218 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00, 0xf0, 0x73,
219 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18, 0xe8, 0xff, 219 0x04, 0xea, 0x77, 0x11, 0x2a, 0x18, 0xe8, 0xff,
220 0x6f, 0xe1, 0x00, 0x06, 0x0d, 0x48, 0x18, 0xe1, 220 0x6f, 0xe1, 0x00, 0x06, 0x0d, 0x48, 0x18, 0xe1,
221 0x00, 0x07, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 221 0x00, 0x07, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
222 0xf2, 0xa0, 0x70, 0x00, 0x00, 0x12, 0x80, 0x01, 222 0xf2, 0xa0, 0x70, 0x00, 0x00, 0x12, 0x80, 0x01,
223 0x10, 0xe1, 0x00, 0x04, 0xf0, 0x74, 0x0e, 0x7a, 223 0x10, 0xe1, 0x00, 0x04, 0xf0, 0x74, 0x0e, 0x7a,
224 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00, 224 0xf2, 0x74, 0x03, 0x36, 0xf4, 0x95, 0xe8, 0x00,
225 0xf0, 0x73, 0x04, 0xea, 0xf0, 0x74, 0x03, 0xbc, 225 0xf0, 0x73, 0x04, 0xea, 0xf0, 0x74, 0x03, 0xbc,
226 0x76, 0xf8, 0x2a, 0x38, 0x00, 0x00, 0xee, 0x02, 226 0x76, 0xf8, 0x2a, 0x38, 0x00, 0x00, 0xee, 0x02,
227 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11, 227 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11,
228 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 0x77, 0x12, 228 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 0x77, 0x12,
229 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1, 229 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1,
230 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1, 230 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1,
231 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x09, 231 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x09,
232 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12, 232 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12,
233 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x86, 0xe9, 0x00, 233 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x86, 0xe9, 0x00,
234 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8, 234 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8,
235 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 235 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43,
236 0x05, 0x0a, 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74, 236 0x05, 0x0a, 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74,
237 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 237 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
238 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 238 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55,
239 0x77, 0x13, 0x2a, 0x18, 0x10, 0xe3, 0x00, 0x01, 239 0x77, 0x13, 0x2a, 0x18, 0x10, 0xe3, 0x00, 0x01,
240 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe3, 0x00, 0x02, 240 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe3, 0x00, 0x02,
241 0x80, 0xe1, 0x00, 0x02, 0x13, 0xe3, 0x00, 0x03, 241 0x80, 0xe1, 0x00, 0x02, 0x13, 0xe3, 0x00, 0x03,
242 0x81, 0xe1, 0x00, 0x03, 0x48, 0x11, 0x77, 0x11, 242 0x81, 0xe1, 0x00, 0x03, 0x48, 0x11, 0x77, 0x11,
243 0x00, 0x00, 0xf8, 0x4d, 0x05, 0x44, 0xf0, 0x00, 243 0x00, 0x00, 0xf8, 0x4d, 0x05, 0x44, 0xf0, 0x00,
244 0x00, 0x04, 0x88, 0x12, 0x48, 0x13, 0xf0, 0x00, 244 0x00, 0x04, 0x88, 0x12, 0x48, 0x13, 0xf0, 0x00,
245 0x00, 0x04, 0x88, 0x13, 0xf4, 0x95, 0xf4, 0x95, 245 0x00, 0x04, 0x88, 0x13, 0xf4, 0x95, 0xf4, 0x95,
246 0xe5, 0x98, 0x6d, 0x91, 0xf6, 0xb8, 0x48, 0x11, 246 0xe5, 0x98, 0x6d, 0x91, 0xf6, 0xb8, 0x48, 0x11,
247 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 0x05, 0x3a, 247 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 0x05, 0x3a,
248 0xf0, 0x20, 0x2a, 0x39, 0x49, 0x11, 0xf5, 0x00, 248 0xf0, 0x20, 0x2a, 0x39, 0x49, 0x11, 0xf5, 0x00,
249 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x76, 0xe1, 249 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x76, 0xe1,
250 0x00, 0x04, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98, 250 0x00, 0x04, 0x00, 0xaa, 0xf0, 0x74, 0x02, 0x98,
251 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11, 251 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x77, 0x11,
252 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 0x77, 0x12, 252 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 0x77, 0x12,
253 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1, 253 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01, 0x80, 0xe1,
254 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1, 254 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02, 0x80, 0xe1,
255 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x0c, 255 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x0c,
256 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12, 256 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x12,
257 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x7a, 0xe9, 0x00, 257 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x7a, 0xe9, 0x00,
258 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8, 258 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01, 0xf6, 0xb8,
259 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43, 259 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c, 0xf8, 0x43,
260 0x05, 0x6a, 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74, 260 0x05, 0x6a, 0x76, 0x82, 0x00, 0xaa, 0xf0, 0x74,
261 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 261 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
262 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55, 262 0x77, 0x11, 0x2a, 0x39, 0x76, 0x81, 0x00, 0x55,
263 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01, 263 0x77, 0x12, 0x2a, 0x18, 0x10, 0xe2, 0x00, 0x01,
264 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02, 264 0x80, 0xe1, 0x00, 0x01, 0x10, 0xe2, 0x00, 0x02,
265 0x80, 0xe1, 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 265 0x80, 0xe1, 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03,
266 0x00, 0x19, 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04, 266 0x00, 0x19, 0x48, 0x11, 0xf0, 0x00, 0x00, 0x04,
267 0x88, 0x12, 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x5d, 267 0x88, 0x12, 0xf4, 0x95, 0x77, 0x13, 0x2a, 0x5d,
268 0xe9, 0x00, 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01, 268 0xe9, 0x00, 0xe5, 0x98, 0xf3, 0x00, 0x00, 0x01,
269 0xf6, 0xb8, 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c, 269 0xf6, 0xb8, 0x48, 0x0b, 0x08, 0xf8, 0x2a, 0x3c,
270 0xf8, 0x43, 0x05, 0x93, 0x76, 0x82, 0x00, 0xaa, 270 0xf8, 0x43, 0x05, 0x93, 0x76, 0x82, 0x00, 0xaa,
271 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00, 271 0xf0, 0x74, 0x02, 0x98, 0x8a, 0x11, 0xfc, 0x00,
272 0x4a, 0x11, 0x88, 0x11, 0x10, 0xf8, 0x2a, 0x38, 272 0x4a, 0x11, 0x88, 0x11, 0x10, 0xf8, 0x2a, 0x38,
273 0xf8, 0x44, 0x05, 0xe3, 0x10, 0xf8, 0x2a, 0xa1, 273 0xf8, 0x44, 0x05, 0xe3, 0x10, 0xf8, 0x2a, 0xa1,
274 0xf8, 0x44, 0x05, 0xba, 0x6c, 0xe1, 0xff, 0x56, 274 0xf8, 0x44, 0x05, 0xba, 0x6c, 0xe1, 0xff, 0x56,
275 0x05, 0xe3, 0x72, 0x12, 0x2a, 0xa1, 0xf4, 0x95, 275 0x05, 0xe3, 0x72, 0x12, 0x2a, 0xa1, 0xf4, 0x95,
276 0x70, 0xe2, 0x2a, 0x18, 0x00, 0x11, 0x6b, 0xf8, 276 0x70, 0xe2, 0x2a, 0x18, 0x00, 0x11, 0x6b, 0xf8,
277 0x2a, 0xa1, 0x00, 0x01, 0xf0, 0x73, 0x05, 0xe3, 277 0x2a, 0xa1, 0x00, 0x01, 0xf0, 0x73, 0x05, 0xe3,
278 0x72, 0x12, 0x2a, 0xa1, 0xf4, 0x95, 0x70, 0xe2, 278 0x72, 0x12, 0x2a, 0xa1, 0xf4, 0x95, 0x70, 0xe2,
279 0x2a, 0x18, 0x00, 0x11, 0x10, 0xf8, 0x2a, 0xa1, 279 0x2a, 0x18, 0x00, 0x11, 0x10, 0xf8, 0x2a, 0xa1,
280 0xf0, 0x00, 0x00, 0x01, 0x88, 0x12, 0xf4, 0x95, 280 0xf0, 0x00, 0x00, 0x01, 0x88, 0x12, 0xf4, 0x95,
281 0xf4, 0x95, 0x6e, 0xe2, 0xff, 0xfc, 0x05, 0xd1, 281 0xf4, 0x95, 0x6e, 0xe2, 0xff, 0xfc, 0x05, 0xd1,
282 0x73, 0x12, 0x2a, 0xa1, 0x48, 0x11, 0xf0, 0x00, 282 0x73, 0x12, 0x2a, 0xa1, 0x48, 0x11, 0xf0, 0x00,
283 0x00, 0x05, 0x80, 0xf8, 0x2a, 0xa2, 0x10, 0xf8, 283 0x00, 0x05, 0x80, 0xf8, 0x2a, 0xa2, 0x10, 0xf8,
284 0x2a, 0xa1, 0x08, 0xf8, 0x2a, 0xa2, 0xf8, 0x44, 284 0x2a, 0xa1, 0x08, 0xf8, 0x2a, 0xa2, 0xf8, 0x44,
285 0x05, 0xe3, 0x6c, 0xe1, 0xff, 0xab, 0x05, 0xdd, 285 0x05, 0xe3, 0x6c, 0xe1, 0xff, 0xab, 0x05, 0xdd,
286 0x76, 0xf8, 0x2a, 0x38, 0x00, 0x01, 0x76, 0xf8, 286 0x76, 0xf8, 0x2a, 0x38, 0x00, 0x01, 0x76, 0xf8,
287 0x2a, 0xa1, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa2, 287 0x2a, 0xa1, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa2,
288 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0xf4, 0x95, 288 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0xf4, 0x95,
289 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a, 0x4a, 0x0b, 289 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a, 0x4a, 0x0b,
290 0x4a, 0x0c, 0x4a, 0x0d, 0x4a, 0x10, 0x4a, 0x11, 290 0x4a, 0x0c, 0x4a, 0x0d, 0x4a, 0x10, 0x4a, 0x11,
291 0x4a, 0x12, 0x4a, 0x13, 0x4a, 0x14, 0x4a, 0x15, 291 0x4a, 0x12, 0x4a, 0x13, 0x4a, 0x14, 0x4a, 0x15,
292 0x4a, 0x16, 0x4a, 0x17, 0x4a, 0x17, 0x4a, 0x19, 292 0x4a, 0x16, 0x4a, 0x17, 0x4a, 0x17, 0x4a, 0x19,
293 0x4a, 0x0e, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1a, 293 0x4a, 0x0e, 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1a,
294 0x4a, 0x1d, 0x4a, 0x1b, 0x4a, 0x1c, 0x68, 0xf8, 294 0x4a, 0x1d, 0x4a, 0x1b, 0x4a, 0x1c, 0x68, 0xf8,
295 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07, 295 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
296 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc, 296 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
297 0x48, 0x18, 0x68, 0xf8, 0x00, 0x18, 0xff, 0xfe, 297 0x48, 0x18, 0x68, 0xf8, 0x00, 0x18, 0xff, 0xfe,
298 0xf4, 0x95, 0xf4, 0x95, 0x4a, 0x08, 0xee, 0xff, 298 0xf4, 0x95, 0xf4, 0x95, 0x4a, 0x08, 0xee, 0xff,
299 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x18, 0x04, 299 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x18, 0x04,
300 0xf0, 0x74, 0x05, 0xa2, 0xee, 0x01, 0x8a, 0x18, 300 0xf0, 0x74, 0x05, 0xa2, 0xee, 0x01, 0x8a, 0x18,
301 0xf4, 0x95, 0x8a, 0x1c, 0x8a, 0x1b, 0x8a, 0x1d, 301 0xf4, 0x95, 0x8a, 0x1c, 0x8a, 0x1b, 0x8a, 0x1d,
302 0x8a, 0x1a, 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0e, 302 0x8a, 0x1a, 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0e,
303 0x8a, 0x19, 0x8a, 0x17, 0x8a, 0x17, 0x8a, 0x16, 303 0x8a, 0x19, 0x8a, 0x17, 0x8a, 0x17, 0x8a, 0x16,
304 0x8a, 0x15, 0x8a, 0x14, 0x8a, 0x13, 0x8a, 0x12, 304 0x8a, 0x15, 0x8a, 0x14, 0x8a, 0x13, 0x8a, 0x12,
305 0x8a, 0x11, 0x8a, 0x10, 0x8a, 0x0d, 0x8a, 0x0c, 305 0x8a, 0x11, 0x8a, 0x10, 0x8a, 0x0d, 0x8a, 0x0c,
306 0x8a, 0x0b, 0x8a, 0x0a, 0x8a, 0x09, 0x8a, 0x08, 306 0x8a, 0x0b, 0x8a, 0x0a, 0x8a, 0x09, 0x8a, 0x08,
307 0xf4, 0xeb, 0xee, 0xfd, 0x76, 0xf8, 0x2a, 0x38, 307 0xf4, 0xeb, 0xee, 0xfd, 0x76, 0xf8, 0x2a, 0x38,
308 0x00, 0x00, 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x00, 308 0x00, 0x00, 0x76, 0xf8, 0x2a, 0x5a, 0x00, 0x00,
309 0xe8, 0x01, 0x4e, 0x00, 0xfb, 0x80, 0x17, 0xd6, 309 0xe8, 0x01, 0x4e, 0x00, 0xfb, 0x80, 0x17, 0xd6,
310 0xf4, 0x95, 0xe8, 0x01, 0x80, 0xf8, 0x2a, 0x5b, 310 0xf4, 0x95, 0xe8, 0x01, 0x80, 0xf8, 0x2a, 0x5b,
311 0x76, 0x00, 0x2a, 0x8f, 0xf9, 0x80, 0x16, 0xaa, 311 0x76, 0x00, 0x2a, 0x8f, 0xf9, 0x80, 0x16, 0xaa,
312 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x17, 0x5c, 312 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x17, 0x5c,
313 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x17, 0x6f, 313 0x10, 0xf8, 0x2a, 0x5b, 0xf9, 0x80, 0x17, 0x6f,
314 0xfb, 0x80, 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x1a, 314 0xfb, 0x80, 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x1a,
315 0xfb, 0x80, 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x1a, 315 0xfb, 0x80, 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x1a,
316 0xfb, 0x80, 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x1b, 316 0xfb, 0x80, 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x1b,
317 0xfb, 0x80, 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x1b, 317 0xfb, 0x80, 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x1b,
318 0xee, 0x03, 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 318 0xee, 0x03, 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95,
319 0x13, 0x02, 0x88, 0x11, 0xe8, 0x00, 0xf8, 0x4d, 319 0x13, 0x02, 0x88, 0x11, 0xe8, 0x00, 0xf8, 0x4d,
320 0x06, 0x6a, 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a, 320 0x06, 0x6a, 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a,
321 0xf4, 0x95, 0xf0, 0x72, 0x06, 0x69, 0x1c, 0x91, 321 0xf4, 0x95, 0xf0, 0x72, 0x06, 0x69, 0x1c, 0x91,
322 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11, 322 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11,
323 0x12, 0x03, 0x11, 0x02, 0xf8, 0x45, 0x06, 0x79, 323 0x12, 0x03, 0x11, 0x02, 0xf8, 0x45, 0x06, 0x79,
324 0xf0, 0x10, 0x00, 0x01, 0x88, 0x1a, 0xf4, 0x95, 324 0xf0, 0x10, 0x00, 0x01, 0x88, 0x1a, 0xf4, 0x95,
325 0xf0, 0x72, 0x06, 0x78, 0x81, 0x91, 0x8a, 0x11, 325 0xf0, 0x72, 0x06, 0x78, 0x81, 0x91, 0x8a, 0x11,
326 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 326 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02,
327 0x00, 0x11, 0x11, 0x03, 0x61, 0xf8, 0x00, 0x11, 327 0x00, 0x11, 0x11, 0x03, 0x61, 0xf8, 0x00, 0x11,
328 0x00, 0x01, 0xf8, 0x30, 0x06, 0x91, 0xf6, 0xb8, 328 0x00, 0x01, 0xf8, 0x30, 0x06, 0x91, 0xf6, 0xb8,
329 0x6f, 0xf8, 0x00, 0x11, 0x0c, 0x1f, 0x88, 0x11, 329 0x6f, 0xf8, 0x00, 0x11, 0x0c, 0x1f, 0x88, 0x11,
330 0xf3, 0xe8, 0xe8, 0xff, 0x18, 0x81, 0xf1, 0xa0, 330 0xf3, 0xe8, 0xe8, 0xff, 0x18, 0x81, 0xf1, 0xa0,
331 0x81, 0x81, 0xf0, 0x73, 0x06, 0x9d, 0xf6, 0xb8, 331 0x81, 0x81, 0xf0, 0x73, 0x06, 0x9d, 0xf6, 0xb8,
332 0x6f, 0xf8, 0x00, 0x11, 0x0c, 0x1f, 0x88, 0x11, 332 0x6f, 0xf8, 0x00, 0x11, 0x0c, 0x1f, 0x88, 0x11,
333 0xf3, 0x30, 0x00, 0xff, 0xf0, 0x20, 0xff, 0x00, 333 0xf3, 0x30, 0x00, 0xff, 0xf0, 0x20, 0xff, 0x00,
334 0x18, 0x81, 0xf1, 0xa0, 0x81, 0x81, 0x8a, 0x11, 334 0x18, 0x81, 0xf1, 0xa0, 0x81, 0x81, 0x8a, 0x11,
335 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x11, 0x02, 335 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x11, 0x02,
336 0x61, 0xf8, 0x00, 0x0b, 0x00, 0x01, 0xf8, 0x20, 336 0x61, 0xf8, 0x00, 0x0b, 0x00, 0x01, 0xf8, 0x20,
337 0x06, 0xb1, 0x49, 0x0b, 0xf6, 0x1f, 0x88, 0x11, 337 0x06, 0xb1, 0x49, 0x0b, 0xf6, 0x1f, 0x88, 0x11,
338 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xf2, 0x73, 338 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xf2, 0x73,
339 0x06, 0xb8, 0xf0, 0x30, 0x00, 0xff, 0x49, 0x0b, 339 0x06, 0xb8, 0xf0, 0x30, 0x00, 0xff, 0x49, 0x0b,
340 0xf6, 0x1f, 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 340 0xf6, 0x1f, 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95,
341 0x12, 0x81, 0xf4, 0x78, 0x8a, 0x11, 0xfc, 0x00, 341 0x12, 0x81, 0xf4, 0x78, 0x8a, 0x11, 0xfc, 0x00,
342 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x12, 342 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x12,
343 0x13, 0x03, 0x88, 0x11, 0xe8, 0x00, 0xf8, 0x4d, 343 0x13, 0x03, 0x88, 0x11, 0xe8, 0x00, 0xf8, 0x4d,
344 0x06, 0xcc, 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a, 344 0x06, 0xcc, 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a,
345 0xf4, 0x95, 0xf0, 0x72, 0x06, 0xcb, 0x11, 0x92, 345 0xf4, 0x95, 0xf0, 0x72, 0x06, 0xcb, 0x11, 0x92,
346 0xf2, 0xc0, 0x81, 0x91, 0x8a, 0x11, 0xfc, 0x00, 346 0xf2, 0xc0, 0x81, 0x91, 0x8a, 0x11, 0xfc, 0x00,
347 0x88, 0x12, 0x12, 0x02, 0x71, 0x01, 0x00, 0x13, 347 0x88, 0x12, 0x12, 0x02, 0x71, 0x01, 0x00, 0x13,
348 0xf8, 0x45, 0x06, 0xdb, 0xf0, 0x10, 0x00, 0x01, 348 0xf8, 0x45, 0x06, 0xdb, 0xf0, 0x10, 0x00, 0x01,
349 0x88, 0x1a, 0xf4, 0x95, 0xf0, 0x72, 0x06, 0xda, 349 0x88, 0x1a, 0xf4, 0x95, 0xf0, 0x72, 0x06, 0xda,
350 0xe5, 0x98, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 350 0xe5, 0x98, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
351 0x88, 0x11, 0x11, 0x04, 0x10, 0x06, 0x71, 0x05, 351 0x88, 0x11, 0x11, 0x04, 0x10, 0x06, 0x71, 0x05,
352 0x00, 0x12, 0x61, 0xf8, 0x00, 0x12, 0x00, 0x01, 352 0x00, 0x12, 0x61, 0xf8, 0x00, 0x12, 0x00, 0x01,
353 0xf8, 0x20, 0x06, 0xea, 0xf0, 0x00, 0x00, 0x01, 353 0xf8, 0x20, 0x06, 0xea, 0xf0, 0x00, 0x00, 0x01,
354 0xf6, 0xb8, 0xf0, 0x00, 0x00, 0x01, 0x6f, 0xf8, 354 0xf6, 0xb8, 0xf0, 0x00, 0x00, 0x01, 0x6f, 0xf8,
355 0x00, 0x12, 0x0f, 0x1f, 0x48, 0x08, 0x81, 0x00, 355 0x00, 0x12, 0x0f, 0x1f, 0x48, 0x08, 0x81, 0x00,
356 0xf4, 0x7f, 0x80, 0x01, 0xf2, 0x74, 0x06, 0xba, 356 0xf4, 0x7f, 0x80, 0x01, 0xf2, 0x74, 0x06, 0xba,
357 0xf4, 0x95, 0x48, 0x11, 0xee, 0x02, 0x8a, 0x11, 357 0xf4, 0x95, 0x48, 0x11, 0xee, 0x02, 0x8a, 0x11,
358 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 0x88, 0x12, 358 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 0x88, 0x12,
359 0x11, 0x04, 0x10, 0x06, 0x71, 0x05, 0x00, 0x13, 359 0x11, 0x04, 0x10, 0x06, 0x71, 0x05, 0x00, 0x13,
360 0x61, 0xf8, 0x00, 0x13, 0x00, 0x01, 0xf8, 0x20, 360 0x61, 0xf8, 0x00, 0x13, 0x00, 0x01, 0xf8, 0x20,
361 0x07, 0x09, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00, 361 0x07, 0x09, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00,
362 0x00, 0x01, 0x88, 0x11, 0xf6, 0xb8, 0x6f, 0xf8, 362 0x00, 0x01, 0x88, 0x11, 0xf6, 0xb8, 0x6f, 0xf8,
363 0x00, 0x13, 0x0f, 0x1f, 0x81, 0x00, 0x48, 0x11, 363 0x00, 0x13, 0x0f, 0x1f, 0x81, 0x00, 0x48, 0x11,
364 0xf4, 0x7f, 0x80, 0x01, 0xf2, 0x74, 0x06, 0xce, 364 0xf4, 0x7f, 0x80, 0x01, 0xf2, 0x74, 0x06, 0xce,
365 0xf4, 0x95, 0x48, 0x12, 0x48, 0x11, 0xf0, 0x30, 365 0xf4, 0x95, 0x48, 0x12, 0x48, 0x11, 0xf0, 0x30,
366 0xff, 0xfe, 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00, 366 0xff, 0xfe, 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00,
367 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xfc, 367 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xfc,
368 0xf4, 0x95, 0x80, 0x02, 0x71, 0x08, 0x00, 0x16, 368 0xf4, 0x95, 0x80, 0x02, 0x71, 0x08, 0x00, 0x16,
369 0x10, 0x09, 0x71, 0x0b, 0x00, 0x17, 0x80, 0x03, 369 0x10, 0x09, 0x71, 0x0b, 0x00, 0x17, 0x80, 0x03,
370 0x71, 0x0a, 0x00, 0x11, 0x48, 0x17, 0xf8, 0x45, 370 0x71, 0x0a, 0x00, 0x11, 0x48, 0x17, 0xf8, 0x45,
371 0x07, 0x3f, 0x70, 0x00, 0x00, 0x11, 0x10, 0x03, 371 0x07, 0x3f, 0x70, 0x00, 0x00, 0x11, 0x10, 0x03,
372 0xf0, 0x74, 0x06, 0x9f, 0x80, 0x01, 0x70, 0x00, 372 0xf0, 0x74, 0x06, 0x9f, 0x80, 0x01, 0x70, 0x00,
373 0x00, 0x16, 0x10, 0x02, 0xf0, 0x74, 0x06, 0x7b, 373 0x00, 0x16, 0x10, 0x02, 0xf0, 0x74, 0x06, 0x7b,
374 0x6d, 0x91, 0x6d, 0x96, 0x6c, 0xef, 0xff, 0xff, 374 0x6d, 0x91, 0x6d, 0x96, 0x6c, 0xef, 0xff, 0xff,
375 0x07, 0x2f, 0xee, 0x04, 0x8a, 0x17, 0x8a, 0x16, 375 0x07, 0x2f, 0xee, 0x04, 0x8a, 0x17, 0x8a, 0x16,
376 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 376 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
377 0x10, 0xf8, 0x2a, 0xe8, 0x08, 0xf8, 0x2a, 0xe9, 377 0x10, 0xf8, 0x2a, 0xe8, 0x08, 0xf8, 0x2a, 0xe9,
378 0xf8, 0x45, 0x07, 0x64, 0x76, 0x00, 0x00, 0x01, 378 0xf8, 0x45, 0x07, 0x64, 0x76, 0x00, 0x00, 0x01,
379 0x62, 0xf8, 0x2a, 0xe9, 0x00, 0x5e, 0xf2, 0x74, 379 0x62, 0xf8, 0x2a, 0xe9, 0x00, 0x5e, 0xf2, 0x74,
380 0x12, 0x0b, 0xf0, 0x00, 0x30, 0x40, 0x72, 0x11, 380 0x12, 0x0b, 0xf0, 0x00, 0x30, 0x40, 0x72, 0x11,
381 0x2a, 0xe9, 0x77, 0x10, 0x00, 0x0f, 0xf5, 0xa9, 381 0x2a, 0xe9, 0x77, 0x10, 0x00, 0x0f, 0xf5, 0xa9,
382 0xf8, 0x20, 0x07, 0x61, 0x6b, 0xf8, 0x2a, 0xe9, 382 0xf8, 0x20, 0x07, 0x61, 0x6b, 0xf8, 0x2a, 0xe9,
383 0x00, 0x01, 0xf0, 0x73, 0x07, 0x64, 0x76, 0xf8, 383 0x00, 0x01, 0xf0, 0x73, 0x07, 0x64, 0x76, 0xf8,
384 0x2a, 0xe9, 0x00, 0x00, 0xee, 0x02, 0x8a, 0x11, 384 0x2a, 0xe9, 0x00, 0x00, 0xee, 0x02, 0x8a, 0x11,
385 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11, 0xe8, 0x00, 385 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x11, 0xe8, 0x00,
386 0x75, 0xf8, 0x00, 0x08, 0x00, 0x08, 0xe8, 0x00, 386 0x75, 0xf8, 0x00, 0x08, 0x00, 0x08, 0xe8, 0x00,
387 0x75, 0xf8, 0x00, 0x08, 0x00, 0x09, 0xf6, 0xb8, 387 0x75, 0xf8, 0x00, 0x08, 0x00, 0x09, 0xf6, 0xb8,
388 0xf4, 0x95, 0xf0, 0x20, 0xfc, 0x3f, 0x75, 0xf8, 388 0xf4, 0x95, 0xf0, 0x20, 0xfc, 0x3f, 0x75, 0xf8,
389 0x00, 0x08, 0x00, 0x0d, 0xf0, 0x20, 0x0c, 0x30, 389 0x00, 0x08, 0x00, 0x0d, 0xf0, 0x20, 0x0c, 0x30,
390 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0c, 0x76, 0xf8, 390 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0c, 0x76, 0xf8,
391 0x2a, 0xe8, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xe9, 391 0x2a, 0xe8, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xe9,
392 0x00, 0x00, 0x6c, 0x81, 0x07, 0x92, 0x76, 0xf8, 392 0x00, 0x00, 0x6c, 0x81, 0x07, 0x92, 0x76, 0xf8,
393 0x2a, 0xea, 0x00, 0x00, 0xfb, 0x80, 0x16, 0x76, 393 0x2a, 0xea, 0x00, 0x00, 0xfb, 0x80, 0x16, 0x76,
394 0xf4, 0x95, 0xe8, 0x10, 0xe8, 0x00, 0x75, 0xf8, 394 0xf4, 0x95, 0xe8, 0x10, 0xe8, 0x00, 0x75, 0xf8,
395 0x00, 0x08, 0x00, 0x00, 0xf0, 0x73, 0x07, 0xa8, 395 0x00, 0x08, 0x00, 0x00, 0xf0, 0x73, 0x07, 0xa8,
396 0x76, 0xf8, 0x2a, 0xea, 0x00, 0x01, 0xfb, 0x80, 396 0x76, 0xf8, 0x2a, 0xea, 0x00, 0x01, 0xfb, 0x80,
397 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x10, 0xfb, 0x80, 397 0x16, 0x66, 0xf4, 0x95, 0xe8, 0x10, 0xfb, 0x80,
398 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x10, 0xe8, 0x00, 398 0x16, 0x87, 0xf4, 0x95, 0xe8, 0x10, 0xe8, 0x00,
399 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00, 0xf6, 0xb8, 399 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00, 0xf6, 0xb8,
400 0xf4, 0x95, 0xf0, 0x20, 0xff, 0xff, 0x75, 0xf8, 400 0xf4, 0x95, 0xf0, 0x20, 0xff, 0xff, 0x75, 0xf8,
401 0x00, 0x08, 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00, 401 0x00, 0x08, 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00,
402 0xf4, 0x95, 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a, 402 0xf4, 0x95, 0x4a, 0x08, 0x4a, 0x09, 0x4a, 0x0a,
403 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8, 403 0x4a, 0x06, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8,
404 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07, 404 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
405 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc, 405 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
406 0x10, 0xf8, 0x2a, 0xea, 0xf8, 0x45, 0x07, 0xe1, 406 0x10, 0xf8, 0x2a, 0xea, 0xf8, 0x45, 0x07, 0xe1,
407 0x10, 0xf8, 0x2a, 0xe8, 0xf0, 0x00, 0x00, 0x01, 407 0x10, 0xf8, 0x2a, 0xe8, 0xf0, 0x00, 0x00, 0x01,
408 0xf0, 0x30, 0x00, 0x0f, 0x80, 0xf8, 0x2a, 0xe8, 408 0xf0, 0x30, 0x00, 0x0f, 0x80, 0xf8, 0x2a, 0xe8,
409 0x10, 0xf8, 0x2a, 0xe8, 0xf8, 0x44, 0x07, 0xd6, 409 0x10, 0xf8, 0x2a, 0xe8, 0xf8, 0x44, 0x07, 0xd6,
410 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xfc, 0x3f, 410 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xfc, 0x3f,
411 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0d, 0xf0, 0x20, 411 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0d, 0xf0, 0x20,
412 0x0c, 0x30, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0c, 412 0x0c, 0x30, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x0c,
413 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00, 413 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00,
414 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xff, 0xff, 414 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xff, 0xff,
415 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00, 0x8a, 0x1d, 415 0x75, 0xf8, 0x00, 0x08, 0x00, 0x00, 0x8a, 0x1d,
416 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0a, 0x8a, 0x09, 416 0x8a, 0x07, 0x8a, 0x06, 0x8a, 0x0a, 0x8a, 0x09,
417 0x8a, 0x08, 0xf4, 0xeb, 0xee, 0xff, 0xf2, 0x74, 417 0x8a, 0x08, 0xf4, 0xeb, 0xee, 0xff, 0xf2, 0x74,
418 0x07, 0x67, 0xf4, 0x95, 0xe8, 0x01, 0xee, 0x01, 418 0x07, 0x67, 0xf4, 0x95, 0xe8, 0x01, 0xee, 0x01,
419 0xfc, 0x00, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8, 419 0xfc, 0x00, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8,
420 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07, 420 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
421 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc, 421 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
422 0x8a, 0x1d, 0x8a, 0x07, 0xf4, 0xeb, 0x4a, 0x11, 422 0x8a, 0x1d, 0x8a, 0x07, 0xf4, 0xeb, 0x4a, 0x11,
423 0x77, 0x11, 0x00, 0x28, 0x76, 0x81, 0x24, 0x00, 423 0x77, 0x11, 0x00, 0x28, 0x76, 0x81, 0x24, 0x00,
424 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 424 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
425 0xf2, 0x74, 0x07, 0x67, 0xf4, 0x95, 0xe8, 0x00, 425 0xf2, 0x74, 0x07, 0x67, 0xf4, 0x95, 0xe8, 0x00,
426 0x77, 0x11, 0x00, 0x1d, 0x68, 0x81, 0x00, 0x7f, 426 0x77, 0x11, 0x00, 0x1d, 0x68, 0x81, 0x00, 0x7f,
427 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xff, 0x80, 427 0xf6, 0xb8, 0xf4, 0x95, 0xf0, 0x20, 0xff, 0x80,
428 0x77, 0x11, 0x00, 0x1d, 0xf0, 0x30, 0x01, 0x00, 428 0x77, 0x11, 0x00, 0x1d, 0xf0, 0x30, 0x01, 0x00,
429 0x1a, 0x81, 0x80, 0x81, 0xf0, 0x74, 0x0a, 0x33, 429 0x1a, 0x81, 0x80, 0x81, 0xf0, 0x74, 0x0a, 0x33,
430 0xf0, 0x74, 0x11, 0xac, 0xf9, 0x80, 0x13, 0x25, 430 0xf0, 0x74, 0x11, 0xac, 0xf9, 0x80, 0x13, 0x25,
431 0xf9, 0x80, 0x16, 0x53, 0xf9, 0x80, 0x17, 0x82, 431 0xf9, 0x80, 0x16, 0x53, 0xf9, 0x80, 0x17, 0x82,
432 0xf0, 0x74, 0x06, 0x2f, 0xf9, 0x80, 0x14, 0xb2, 432 0xf0, 0x74, 0x06, 0x2f, 0xf9, 0x80, 0x14, 0xb2,
433 0xf9, 0x80, 0x19, 0x10, 0xf0, 0x74, 0x0d, 0xe3, 433 0xf9, 0x80, 0x19, 0x10, 0xf0, 0x74, 0x0d, 0xe3,
434 0xf0, 0x74, 0x07, 0xe8, 0xf0, 0x74, 0x02, 0x36, 434 0xf0, 0x74, 0x07, 0xe8, 0xf0, 0x74, 0x02, 0x36,
435 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x60, 0xf8, 435 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x60, 0xf8,
436 0x27, 0x7b, 0xff, 0xff, 0xf8, 0x30, 0x08, 0x39, 436 0x27, 0x7b, 0xff, 0xff, 0xf8, 0x30, 0x08, 0x39,
437 0x71, 0xf8, 0x27, 0x7b, 0x27, 0x79, 0x60, 0xf8, 437 0x71, 0xf8, 0x27, 0x7b, 0x27, 0x79, 0x60, 0xf8,
438 0x27, 0x79, 0xff, 0xff, 0xf8, 0x30, 0x08, 0xb2, 438 0x27, 0x79, 0xff, 0xff, 0xf8, 0x30, 0x08, 0xb2,
439 0x10, 0xf8, 0x29, 0x86, 0x08, 0xf8, 0x27, 0x79, 439 0x10, 0xf8, 0x29, 0x86, 0x08, 0xf8, 0x27, 0x79,
440 0xf0, 0x30, 0x7f, 0xff, 0x88, 0x11, 0xf4, 0x95, 440 0xf0, 0x30, 0x7f, 0xff, 0x88, 0x11, 0xf4, 0x95,
441 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x30, 441 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x30,
442 0x08, 0x58, 0x10, 0xf8, 0x27, 0x79, 0x08, 0xf8, 442 0x08, 0x58, 0x10, 0xf8, 0x27, 0x79, 0x08, 0xf8,
443 0x27, 0x7a, 0xf0, 0x30, 0x7f, 0xff, 0x88, 0x11, 443 0x27, 0x7a, 0xf0, 0x30, 0x7f, 0xff, 0x88, 0x11,
444 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9, 444 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9,
445 0xf8, 0x20, 0x08, 0x63, 0x76, 0xf8, 0x27, 0x79, 445 0xf8, 0x20, 0x08, 0x63, 0x76, 0xf8, 0x27, 0x79,
446 0xff, 0xff, 0x76, 0xf8, 0x27, 0x7b, 0xff, 0xff, 446 0xff, 0xff, 0x76, 0xf8, 0x27, 0x7b, 0xff, 0xff,
447 0xf7, 0xb8, 0xf2, 0x73, 0x08, 0xd9, 0xf0, 0x20, 447 0xf7, 0xb8, 0xf2, 0x73, 0x08, 0xd9, 0xf0, 0x20,
448 0xff, 0xff, 0xf6, 0xb8, 0x56, 0xf8, 0x27, 0x74, 448 0xff, 0xff, 0xf6, 0xb8, 0x56, 0xf8, 0x27, 0x74,
449 0xf0, 0xf9, 0x88, 0x11, 0x56, 0xf8, 0x27, 0x72, 449 0xf0, 0xf9, 0x88, 0x11, 0x56, 0xf8, 0x27, 0x72,
450 0xf0, 0xf9, 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95, 450 0xf0, 0xf9, 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95,
451 0xe7, 0x20, 0xf4, 0xa9, 0xf8, 0x30, 0x08, 0x8f, 451 0xe7, 0x20, 0xf4, 0xa9, 0xf8, 0x30, 0x08, 0x8f,
452 0xf1, 0x20, 0x27, 0x7c, 0x48, 0x11, 0xf6, 0x00, 452 0xf1, 0x20, 0x27, 0x7c, 0x48, 0x11, 0xf6, 0x00,
453 0x88, 0x13, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x83, 453 0x88, 0x13, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x83,
454 0x08, 0xf8, 0x27, 0x79, 0xf0, 0x30, 0x7f, 0xff, 454 0x08, 0xf8, 0x27, 0x79, 0xf0, 0x30, 0x7f, 0xff,
455 0x88, 0x13, 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 455 0x88, 0x13, 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00,
456 0xf5, 0xab, 0xf8, 0x30, 0x08, 0x8f, 0x6d, 0x91, 456 0xf5, 0xab, 0xf8, 0x30, 0x08, 0x8f, 0x6d, 0x91,
457 0x48, 0x11, 0xf0, 0x30, 0x01, 0xff, 0x88, 0x11, 457 0x48, 0x11, 0xf0, 0x30, 0x01, 0xff, 0x88, 0x11,
458 0xf4, 0x95, 0xe7, 0x20, 0xf7, 0xa9, 0xf8, 0x30, 458 0xf4, 0x95, 0xe7, 0x20, 0xf7, 0xa9, 0xf8, 0x30,
459 0x08, 0x74, 0x6d, 0x89, 0x48, 0x11, 0xf0, 0x30, 459 0x08, 0x74, 0x6d, 0x89, 0x48, 0x11, 0xf0, 0x30,
460 0x01, 0xff, 0xf0, 0xe7, 0xf4, 0x95, 0x48, 0x08, 460 0x01, 0xff, 0xf0, 0xe7, 0xf4, 0x95, 0x48, 0x08,
461 0x4e, 0xf8, 0x27, 0x74, 0x48, 0x08, 0xf1, 0xf9, 461 0x4e, 0xf8, 0x27, 0x74, 0x48, 0x08, 0xf1, 0xf9,
462 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0xe1, 462 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x71, 0xe1,
463 0x27, 0x7c, 0x27, 0x7a, 0x60, 0xf8, 0x27, 0x7b, 463 0x27, 0x7c, 0x27, 0x7a, 0x60, 0xf8, 0x27, 0x7b,
464 0xff, 0xff, 0xf8, 0x30, 0x08, 0xab, 0x48, 0x08, 464 0xff, 0xff, 0xf8, 0x30, 0x08, 0xab, 0x48, 0x08,
465 0x4e, 0xf8, 0x27, 0x72, 0x76, 0xf8, 0x27, 0x7b, 465 0x4e, 0xf8, 0x27, 0x72, 0x76, 0xf8, 0x27, 0x7b,
466 0xff, 0xff, 0x76, 0xf8, 0x27, 0x79, 0xff, 0xff, 466 0xff, 0xff, 0x76, 0xf8, 0x27, 0x79, 0xff, 0xff,
467 0xf2, 0x73, 0x08, 0xd9, 0xf4, 0x95, 0xe8, 0x00, 467 0xf2, 0x73, 0x08, 0xd9, 0xf4, 0x95, 0xe8, 0x00,
468 0x44, 0xf8, 0x27, 0x73, 0x40, 0xf8, 0x27, 0x75, 468 0x44, 0xf8, 0x27, 0x73, 0x40, 0xf8, 0x27, 0x75,
469 0x82, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0x77, 0x10, 469 0x82, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0x77, 0x10,
470 0x80, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x08, 0xd8, 470 0x80, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x08, 0xd8,
471 0xf6, 0xb8, 0x10, 0xf8, 0x27, 0x73, 0xf0, 0x00, 471 0xf6, 0xb8, 0x10, 0xf8, 0x27, 0x73, 0xf0, 0x00,
472 0x80, 0x00, 0x48, 0x08, 0x4e, 0xf8, 0x27, 0x74, 472 0x80, 0x00, 0x48, 0x08, 0x4e, 0xf8, 0x27, 0x74,
473 0x48, 0x08, 0xf0, 0xf9, 0x88, 0x11, 0xf4, 0x95, 473 0x48, 0x08, 0xf0, 0xf9, 0x88, 0x11, 0xf4, 0x95,
474 0xf4, 0x95, 0x71, 0xe1, 0x27, 0x7c, 0x27, 0x7a, 474 0xf4, 0x95, 0x71, 0xe1, 0x27, 0x7c, 0x27, 0x7a,
475 0xf7, 0xb8, 0x57, 0xf8, 0x27, 0x74, 0xf0, 0x62, 475 0xf7, 0xb8, 0x57, 0xf8, 0x27, 0x74, 0xf0, 0x62,
476 0xff, 0xff, 0xf0, 0x40, 0xff, 0x80, 0xf2, 0x80, 476 0xff, 0xff, 0xf0, 0x40, 0xff, 0x80, 0xf2, 0x80,
477 0x4e, 0xf8, 0x27, 0x74, 0xe8, 0x00, 0x8a, 0x11, 477 0x4e, 0xf8, 0x27, 0x74, 0xe8, 0x00, 0x8a, 0x11,
478 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xfb, 478 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xfb,
479 0x11, 0xf8, 0x27, 0x71, 0x09, 0xf8, 0x27, 0x73, 479 0x11, 0xf8, 0x27, 0x71, 0x09, 0xf8, 0x27, 0x73,
480 0x89, 0x11, 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 480 0x89, 0x11, 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95,
481 0xf6, 0xa9, 0xf8, 0x20, 0x08, 0xed, 0xf2, 0x73, 481 0xf6, 0xa9, 0xf8, 0x20, 0x08, 0xed, 0xf2, 0x73,
482 0x09, 0x0e, 0xf4, 0x95, 0xe8, 0x00, 0xf6, 0x20, 482 0x09, 0x0e, 0xf4, 0x95, 0xe8, 0x00, 0xf6, 0x20,
483 0x76, 0x00, 0x00, 0x41, 0xf0, 0x74, 0x12, 0xee, 483 0x76, 0x00, 0x00, 0x41, 0xf0, 0x74, 0x12, 0xee,
484 0x88, 0x16, 0xf4, 0x95, 0xf7, 0xb8, 0x6d, 0x96, 484 0x88, 0x16, 0xf4, 0x95, 0xf7, 0xb8, 0x6d, 0x96,
485 0x10, 0xf8, 0x00, 0x16, 0xf8, 0x47, 0x09, 0x0a, 485 0x10, 0xf8, 0x00, 0x16, 0xf8, 0x47, 0x09, 0x0a,
486 0xe7, 0x61, 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 486 0xe7, 0x61, 0x76, 0x00, 0x00, 0x00, 0x76, 0x01,
487 0x00, 0x80, 0x76, 0x02, 0x00, 0xff, 0x76, 0x03, 487 0x00, 0x80, 0x76, 0x02, 0x00, 0xff, 0x76, 0x03,
488 0x00, 0x00, 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95, 488 0x00, 0x00, 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95,
489 0xe8, 0x00, 0x6c, 0xe9, 0xff, 0xff, 0x08, 0xfb, 489 0xe8, 0x00, 0x6c, 0xe9, 0xff, 0xff, 0x08, 0xfb,
490 0x73, 0x16, 0x00, 0x0e, 0xf0, 0x66, 0x00, 0x41, 490 0x73, 0x16, 0x00, 0x0e, 0xf0, 0x66, 0x00, 0x41,
491 0xee, 0x05, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00, 491 0xee, 0x05, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00,
492 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x13, 492 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x13,
493 0xf6, 0xb8, 0x77, 0x11, 0x7f, 0xff, 0x57, 0xf8, 493 0xf6, 0xb8, 0x77, 0x11, 0x7f, 0xff, 0x57, 0xf8,
494 0x27, 0x72, 0x48, 0x11, 0xf2, 0x80, 0xf0, 0x00, 494 0x27, 0x72, 0x48, 0x11, 0xf2, 0x80, 0xf0, 0x00,
495 0x80, 0x00, 0x88, 0x11, 0xf6, 0x40, 0xf0, 0xe0, 495 0x80, 0x00, 0x88, 0x11, 0xf6, 0x40, 0xf0, 0xe0,
496 0xf1, 0xf1, 0xe8, 0x01, 0xf2, 0x80, 0x80, 0xf8, 496 0xf1, 0xf1, 0xe8, 0x01, 0xf2, 0x80, 0x80, 0xf8,
497 0x27, 0x78, 0x77, 0x12, 0x80, 0x00, 0x57, 0xf8, 497 0x27, 0x78, 0x77, 0x12, 0x80, 0x00, 0x57, 0xf8,
498 0x27, 0x72, 0x48, 0x12, 0xf2, 0x80, 0x88, 0x12, 498 0x27, 0x72, 0x48, 0x12, 0xf2, 0x80, 0x88, 0x12,
499 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x82, 0x09, 0x38, 499 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x82, 0x09, 0x38,
500 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 500 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
501 0xf0, 0x73, 0x09, 0x3d, 0xf0, 0x20, 0x80, 0x01, 501 0xf0, 0x73, 0x09, 0x3d, 0xf0, 0x20, 0x80, 0x01,
502 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0x70, 0x81, 502 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0x70, 0x81,
503 0x00, 0x13, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 503 0x00, 0x13, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
504 0xf0, 0x30, 0x7f, 0xff, 0x11, 0xf8, 0x29, 0x86, 504 0xf0, 0x30, 0x7f, 0xff, 0x11, 0xf8, 0x29, 0x86,
505 0xf5, 0x20, 0xf3, 0x30, 0x7f, 0xff, 0x89, 0x11, 505 0xf5, 0x20, 0xf3, 0x30, 0x7f, 0xff, 0x89, 0x11,
506 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9, 506 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9,
507 0xf8, 0x20, 0x09, 0x54, 0xf2, 0x73, 0x09, 0x67, 507 0xf8, 0x20, 0x09, 0x54, 0xf2, 0x73, 0x09, 0x67,
508 0xf4, 0x95, 0xe8, 0x02, 0x6f, 0xf8, 0x27, 0x7a, 508 0xf4, 0x95, 0xe8, 0x02, 0x6f, 0xf8, 0x27, 0x7a,
509 0x0d, 0x20, 0xf3, 0x30, 0x7f, 0xff, 0x89, 0x11, 509 0x0d, 0x20, 0xf3, 0x30, 0x7f, 0xff, 0x89, 0x11,
510 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9, 510 0xf4, 0x95, 0x77, 0x10, 0x40, 0x00, 0xf6, 0xa9,
511 0xf8, 0x20, 0x09, 0x64, 0xf2, 0x73, 0x09, 0x67, 511 0xf8, 0x20, 0x09, 0x64, 0xf2, 0x73, 0x09, 0x67,
512 0xf4, 0x95, 0xe8, 0x01, 0x80, 0xf8, 0x27, 0x7b, 512 0xf4, 0x95, 0xe8, 0x01, 0x80, 0xf8, 0x27, 0x7b,
513 0xe8, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 513 0xe8, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
514 0x11, 0xf8, 0x29, 0x86, 0xf5, 0x20, 0xf3, 0x30, 514 0x11, 0xf8, 0x29, 0x86, 0xf5, 0x20, 0xf3, 0x30,
515 0x7f, 0xff, 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10, 515 0x7f, 0xff, 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10,
516 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x09, 0x7a, 516 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x09, 0x7a,
517 0xf2, 0x73, 0x09, 0x8d, 0xf4, 0x95, 0xe8, 0x02, 517 0xf2, 0x73, 0x09, 0x8d, 0xf4, 0x95, 0xe8, 0x02,
518 0x6f, 0xf8, 0x27, 0x7a, 0x0d, 0x20, 0xf3, 0x30, 518 0x6f, 0xf8, 0x27, 0x7a, 0x0d, 0x20, 0xf3, 0x30,
519 0x7f, 0xff, 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10, 519 0x7f, 0xff, 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10,
520 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x09, 0x8a, 520 0x40, 0x00, 0xf6, 0xa9, 0xf8, 0x20, 0x09, 0x8a,
521 0xf2, 0x73, 0x09, 0x8d, 0xf4, 0x95, 0xe8, 0x01, 521 0xf2, 0x73, 0x09, 0x8d, 0xf4, 0x95, 0xe8, 0x01,
522 0x80, 0xf8, 0x27, 0x79, 0xe8, 0x00, 0x8a, 0x11, 522 0x80, 0xf8, 0x27, 0x79, 0xe8, 0x00, 0x8a, 0x11,
523 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 523 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02,
524 0x00, 0x12, 0x88, 0x11, 0xf6, 0xb8, 0x57, 0xf8, 524 0x00, 0x12, 0x88, 0x11, 0xf6, 0xb8, 0x57, 0xf8,
525 0x27, 0x72, 0xf0, 0x20, 0x7f, 0xff, 0xf2, 0x80, 525 0x27, 0x72, 0xf0, 0x20, 0x7f, 0xff, 0xf2, 0x80,
526 0xf0, 0x00, 0x80, 0x00, 0x80, 0x81, 0x57, 0xf8, 526 0xf0, 0x00, 0x80, 0x00, 0x80, 0x81, 0x57, 0xf8,
527 0x27, 0x72, 0xe8, 0x01, 0xf3, 0xf1, 0xf2, 0x80, 527 0x27, 0x72, 0xe8, 0x01, 0xf3, 0xf1, 0xf2, 0x80,
528 0x80, 0xf8, 0x27, 0x78, 0x77, 0x11, 0x80, 0x00, 528 0x80, 0xf8, 0x27, 0x78, 0x77, 0x11, 0x80, 0x00,
529 0x48, 0x11, 0x57, 0xf8, 0x27, 0x72, 0xf2, 0x80, 529 0x48, 0x11, 0x57, 0xf8, 0x27, 0x72, 0xf2, 0x80,
530 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 530 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81,
531 0x09, 0xb5, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 531 0x09, 0xb5, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08,
532 0x00, 0x01, 0xf0, 0x73, 0x09, 0xba, 0xf0, 0x20, 532 0x00, 0x01, 0xf0, 0x73, 0x09, 0xba, 0xf0, 0x20,
533 0x80, 0x01, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 533 0x80, 0x01, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
534 0x45, 0xf8, 0x27, 0x71, 0x43, 0xf8, 0x27, 0x73, 534 0x45, 0xf8, 0x27, 0x71, 0x43, 0xf8, 0x27, 0x73,
535 0x83, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0xe7, 0x20, 535 0x83, 0xf8, 0x00, 0x11, 0xf4, 0x95, 0xe7, 0x20,
536 0xf6, 0xa9, 0xf8, 0x30, 0x09, 0xc9, 0xf2, 0x73, 536 0xf6, 0xa9, 0xf8, 0x30, 0x09, 0xc9, 0xf2, 0x73,
537 0x09, 0xe4, 0x77, 0x12, 0x00, 0x00, 0x57, 0xf8, 537 0x09, 0xe4, 0x77, 0x12, 0x00, 0x00, 0x57, 0xf8,
538 0x27, 0x72, 0xf0, 0x20, 0x7f, 0xff, 0xf2, 0x80, 538 0x27, 0x72, 0xf0, 0x20, 0x7f, 0xff, 0xf2, 0x80,
539 0x49, 0x12, 0xf5, 0x00, 0xf3, 0x00, 0x80, 0x00, 539 0x49, 0x12, 0xf5, 0x00, 0xf3, 0x00, 0x80, 0x00,
540 0x61, 0xf8, 0x00, 0x0b, 0x80, 0x00, 0xf8, 0x30, 540 0x61, 0xf8, 0x00, 0x0b, 0x80, 0x00, 0xf8, 0x30,
541 0x09, 0xdc, 0xf1, 0x20, 0x80, 0x00, 0xf5, 0x20, 541 0x09, 0xdc, 0xf1, 0x20, 0x80, 0x00, 0xf5, 0x20,
542 0x89, 0x12, 0xf4, 0x95, 0x48, 0x12, 0x6f, 0xf8, 542 0x89, 0x12, 0xf4, 0x95, 0x48, 0x12, 0x6f, 0xf8,
543 0x27, 0x73, 0x0d, 0x00, 0xf4, 0x95, 0x49, 0x0b, 543 0x27, 0x73, 0x0d, 0x00, 0xf4, 0x95, 0x49, 0x0b,
544 0x4f, 0xf8, 0x27, 0x72, 0x8a, 0x11, 0xfe, 0x00, 544 0x4f, 0xf8, 0x27, 0x72, 0x8a, 0x11, 0xfe, 0x00,
545 0x48, 0x12, 0xf4, 0x95, 0x4a, 0x11, 0x4a, 0x16, 545 0x48, 0x12, 0xf4, 0x95, 0x4a, 0x11, 0x4a, 0x16,
546 0x4a, 0x17, 0xee, 0xfc, 0xf4, 0x95, 0x71, 0x08, 546 0x4a, 0x17, 0xee, 0xfc, 0xf4, 0x95, 0x71, 0x08,
547 0x00, 0x16, 0x88, 0x17, 0xf0, 0x74, 0x08, 0x30, 547 0x00, 0x16, 0x88, 0x17, 0xf0, 0x74, 0x08, 0x30,
548 0x48, 0x18, 0x70, 0x00, 0x00, 0x16, 0xf2, 0x74, 548 0x48, 0x18, 0x70, 0x00, 0x00, 0x16, 0xf2, 0x74,
549 0x09, 0x8f, 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11, 549 0x09, 0x8f, 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11,
550 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 0x0a, 0x0a, 550 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 0x0a, 0x0a,
551 0xf2, 0x74, 0x08, 0xdb, 0xf4, 0x95, 0x48, 0x16, 551 0xf2, 0x74, 0x08, 0xdb, 0xf4, 0x95, 0x48, 0x16,
552 0x48, 0x18, 0x70, 0x00, 0x00, 0x16, 0xf2, 0x74, 552 0x48, 0x18, 0x70, 0x00, 0x00, 0x16, 0xf2, 0x74,
553 0x09, 0x8f, 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11, 553 0x09, 0x8f, 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11,
554 0x10, 0x02, 0x70, 0x01, 0x00, 0x11, 0x80, 0x00, 554 0x10, 0x02, 0x70, 0x01, 0x00, 0x11, 0x80, 0x00,
555 0xf2, 0x74, 0x06, 0xce, 0xf4, 0x95, 0x48, 0x17, 555 0xf2, 0x74, 0x06, 0xce, 0xf4, 0x95, 0x48, 0x17,
556 0x49, 0x11, 0x48, 0x17, 0xf6, 0x00, 0x88, 0x17, 556 0x49, 0x11, 0x48, 0x17, 0xf6, 0x00, 0x88, 0x17,
557 0xe7, 0x60, 0xf5, 0xa9, 0xf8, 0x20, 0x0a, 0x2d, 557 0xe7, 0x60, 0xf5, 0xa9, 0xf8, 0x20, 0x0a, 0x2d,
558 0x48, 0x16, 0xf6, 0x20, 0x88, 0x11, 0x48, 0x18, 558 0x48, 0x16, 0xf6, 0x20, 0x88, 0x11, 0x48, 0x18,
559 0x70, 0x00, 0x00, 0x11, 0xf2, 0x74, 0x09, 0x8f, 559 0x70, 0x00, 0x00, 0x11, 0xf2, 0x74, 0x09, 0x8f,
560 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11, 0x70, 0x01, 560 0xf0, 0x00, 0x00, 0x02, 0x88, 0x11, 0x70, 0x01,
561 0x00, 0x11, 0x10, 0x02, 0x80, 0x00, 0xf2, 0x74, 561 0x00, 0x11, 0x10, 0x02, 0x80, 0x00, 0xf2, 0x74,
562 0x06, 0xce, 0xf4, 0x95, 0x48, 0x17, 0xee, 0x04, 562 0x06, 0xce, 0xf4, 0x95, 0x48, 0x17, 0xee, 0x04,
563 0x48, 0x16, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 563 0x48, 0x16, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11,
564 0xfc, 0x00, 0xee, 0xfd, 0xe8, 0x00, 0x4e, 0xf8, 564 0xfc, 0x00, 0xee, 0xfd, 0xe8, 0x00, 0x4e, 0xf8,
565 0x27, 0x70, 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x72, 565 0x27, 0x70, 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x72,
566 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x74, 0xe8, 0x00, 566 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x74, 0xe8, 0x00,
567 0x4e, 0xf8, 0x27, 0x76, 0x76, 0xf8, 0x27, 0x79, 567 0x4e, 0xf8, 0x27, 0x76, 0x76, 0xf8, 0x27, 0x79,
568 0xff, 0xff, 0x76, 0xf8, 0x27, 0x7a, 0x00, 0x00, 568 0xff, 0xff, 0x76, 0xf8, 0x27, 0x7a, 0x00, 0x00,
569 0x76, 0xf8, 0x27, 0x7b, 0xff, 0xff, 0x76, 0xf8, 569 0x76, 0xf8, 0x27, 0x7b, 0xff, 0xff, 0x76, 0xf8,
570 0x27, 0x78, 0x00, 0x00, 0xe8, 0x00, 0x75, 0xf8, 570 0x27, 0x78, 0x00, 0x00, 0xe8, 0x00, 0x75, 0xf8,
571 0x00, 0x08, 0x00, 0x01, 0x76, 0x00, 0x00, 0x00, 571 0x00, 0x08, 0x00, 0x01, 0x76, 0x00, 0x00, 0x00,
572 0x76, 0x01, 0x02, 0x00, 0xf2, 0x74, 0x12, 0xdc, 572 0x76, 0x01, 0x02, 0x00, 0xf2, 0x74, 0x12, 0xdc,
573 0xf0, 0x20, 0x27, 0x7c, 0xee, 0x03, 0xfc, 0x00, 573 0xf0, 0x20, 0x27, 0x7c, 0xee, 0x03, 0xfc, 0x00,
574 0x4a, 0x11, 0xee, 0xfc, 0xf4, 0x95, 0x4e, 0x00, 574 0x4a, 0x11, 0xee, 0xfc, 0xf4, 0x95, 0x4e, 0x00,
575 0x77, 0x12, 0x7f, 0xff, 0xf6, 0xb8, 0x49, 0x12, 575 0x77, 0x12, 0x7f, 0xff, 0xf6, 0xb8, 0x49, 0x12,
576 0xf1, 0x80, 0xf3, 0x00, 0x80, 0x00, 0x89, 0x12, 576 0xf1, 0x80, 0xf3, 0x00, 0x80, 0x00, 0x89, 0x12,
577 0xf0, 0xe0, 0xf1, 0xf1, 0x4f, 0x02, 0xe9, 0x01, 577 0xf0, 0xe0, 0xf1, 0xf1, 0x4f, 0x02, 0xe9, 0x01,
578 0xf4, 0x95, 0x48, 0x0b, 0xf5, 0x40, 0x56, 0x02, 578 0xf4, 0x95, 0x48, 0x0b, 0xf5, 0x40, 0x56, 0x02,
579 0xf1, 0x80, 0x81, 0xf8, 0x27, 0x78, 0x77, 0x11, 579 0xf1, 0x80, 0x81, 0xf8, 0x27, 0x78, 0x77, 0x11,
580 0x80, 0x00, 0x56, 0x00, 0x49, 0x11, 0xf1, 0x80, 580 0x80, 0x00, 0x56, 0x00, 0x49, 0x11, 0xf1, 0x80,
581 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 581 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81,
582 0x0a, 0x81, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 582 0x0a, 0x81, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08,
583 0x00, 0x01, 0xf0, 0x73, 0x0a, 0x86, 0xf0, 0x20, 583 0x00, 0x01, 0xf0, 0x73, 0x0a, 0x86, 0xf0, 0x20,
584 0x80, 0x01, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 584 0x80, 0x01, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
585 0x10, 0x82, 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00, 585 0x10, 0x82, 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00,
586 0x4a, 0x11, 0xee, 0xfe, 0xf4, 0x95, 0x4e, 0x00, 586 0x4a, 0x11, 0xee, 0xfe, 0xf4, 0x95, 0x4e, 0x00,
587 0x77, 0x11, 0x7f, 0xff, 0xf6, 0xb8, 0x49, 0x11, 587 0x77, 0x11, 0x7f, 0xff, 0xf6, 0xb8, 0x49, 0x11,
588 0xf1, 0x80, 0xf3, 0x00, 0x80, 0x00, 0x89, 0x11, 588 0xf1, 0x80, 0xf3, 0x00, 0x80, 0x00, 0x89, 0x11,
589 0xf0, 0xe0, 0xf1, 0xf1, 0xe8, 0x01, 0xf2, 0x80, 589 0xf0, 0xe0, 0xf1, 0xf1, 0xe8, 0x01, 0xf2, 0x80,
590 0x80, 0xf8, 0x27, 0x78, 0x56, 0x00, 0xf1, 0x20, 590 0x80, 0xf8, 0x27, 0x78, 0x56, 0x00, 0xf1, 0x20,
591 0x80, 0x00, 0xf1, 0x80, 0xf4, 0x95, 0x49, 0x0b, 591 0x80, 0x00, 0xf1, 0x80, 0xf4, 0x95, 0x49, 0x0b,
592 0xf8, 0x4d, 0x0a, 0xab, 0xf0, 0x20, 0x80, 0x01, 592 0xf8, 0x4d, 0x0a, 0xab, 0xf0, 0x20, 0x80, 0x01,
593 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0xf0, 0x73, 593 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0xf0, 0x73,
594 0x0a, 0xaf, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 594 0x0a, 0xaf, 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08,
595 0x00, 0x01, 0xee, 0x02, 0x48, 0x11, 0x8a, 0x11, 595 0x00, 0x01, 0xee, 0x02, 0x48, 0x11, 0x8a, 0x11,
596 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x12, 0x13, 0x02, 596 0xfc, 0x00, 0x4a, 0x11, 0x88, 0x12, 0x13, 0x02,
597 0x77, 0x11, 0x00, 0x00, 0xf8, 0x4d, 0x0a, 0xcb, 597 0x77, 0x11, 0x00, 0x00, 0xf8, 0x4d, 0x0a, 0xcb,
598 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a, 0xf4, 0x95, 598 0xf3, 0x10, 0x00, 0x01, 0x89, 0x1a, 0xf4, 0x95,
599 0xf0, 0x72, 0x0a, 0xca, 0x48, 0x11, 0x1c, 0xf8, 599 0xf0, 0x72, 0x0a, 0xca, 0x48, 0x11, 0x1c, 0xf8,
600 0x29, 0x7e, 0x88, 0x11, 0x11, 0xf8, 0x29, 0x7e, 600 0x29, 0x7e, 0x88, 0x11, 0x11, 0xf8, 0x29, 0x7e,
601 0xf2, 0x00, 0x00, 0x01, 0x80, 0xf8, 0x29, 0x7e, 601 0xf2, 0x00, 0x00, 0x01, 0x80, 0xf8, 0x29, 0x7e,
602 0x81, 0x92, 0x48, 0x11, 0x8a, 0x11, 0xfc, 0x00, 602 0x81, 0x92, 0x48, 0x11, 0x8a, 0x11, 0xfc, 0x00,
603 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x11, 603 0x4a, 0x11, 0xf4, 0x95, 0x71, 0x02, 0x00, 0x11,
604 0x88, 0x12, 0xf6, 0xb8, 0xf0, 0x20, 0x7f, 0xff, 604 0x88, 0x12, 0xf6, 0xb8, 0xf0, 0x20, 0x7f, 0xff,
605 0x57, 0xf8, 0x27, 0x70, 0xf2, 0x80, 0xf0, 0x00, 605 0x57, 0xf8, 0x27, 0x70, 0xf2, 0x80, 0xf0, 0x00,
606 0x80, 0x00, 0x80, 0x82, 0x57, 0xf8, 0x27, 0x70, 606 0x80, 0x00, 0x80, 0x82, 0x57, 0xf8, 0x27, 0x70,
607 0xe8, 0x01, 0xf3, 0xf1, 0xf2, 0x80, 0x80, 0xf8, 607 0xe8, 0x01, 0xf3, 0xf1, 0xf2, 0x80, 0x80, 0xf8,
608 0x27, 0x78, 0x77, 0x12, 0x80, 0x00, 0x48, 0x12, 608 0x27, 0x78, 0x77, 0x12, 0x80, 0x00, 0x48, 0x12,
609 0x57, 0xf8, 0x27, 0x70, 0xf2, 0x80, 0x88, 0x12, 609 0x57, 0xf8, 0x27, 0x70, 0xf2, 0x80, 0x88, 0x12,
610 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x82, 0x0a, 0xf4, 610 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x82, 0x0a, 0xf4,
611 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 611 0xe8, 0x00, 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01,
612 0xf0, 0x73, 0x0a, 0xf9, 0xf0, 0x20, 0x80, 0x01, 612 0xf0, 0x73, 0x0a, 0xf9, 0xf0, 0x20, 0x80, 0x01,
613 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0x45, 0xf8, 613 0x75, 0xf8, 0x00, 0x08, 0x00, 0x01, 0x45, 0xf8,
614 0x27, 0x75, 0xe7, 0x10, 0x43, 0xf8, 0x27, 0x71, 614 0x27, 0x75, 0xe7, 0x10, 0x43, 0xf8, 0x27, 0x71,
615 0x83, 0xf8, 0x00, 0x12, 0x6d, 0xe8, 0x00, 0x04, 615 0x83, 0xf8, 0x00, 0x12, 0x6d, 0xe8, 0x00, 0x04,
616 0x6d, 0x8a, 0xf6, 0xaa, 0xf8, 0x30, 0x0b, 0x0a, 616 0x6d, 0x8a, 0xf6, 0xaa, 0xf8, 0x30, 0x0b, 0x0a,
617 0xf2, 0x73, 0x0b, 0x25, 0x77, 0x11, 0x00, 0x00, 617 0xf2, 0x73, 0x0b, 0x25, 0x77, 0x11, 0x00, 0x00,
618 0x57, 0xf8, 0x27, 0x70, 0xf0, 0x20, 0x7f, 0xff, 618 0x57, 0xf8, 0x27, 0x70, 0xf0, 0x20, 0x7f, 0xff,
619 0xf2, 0x80, 0x49, 0x11, 0xf5, 0x00, 0xf3, 0x00, 619 0xf2, 0x80, 0x49, 0x11, 0xf5, 0x00, 0xf3, 0x00,
620 0x80, 0x00, 0x61, 0xf8, 0x00, 0x0b, 0x80, 0x00, 620 0x80, 0x00, 0x61, 0xf8, 0x00, 0x0b, 0x80, 0x00,
621 0xf8, 0x30, 0x0b, 0x1d, 0xf1, 0x20, 0x80, 0x00, 621 0xf8, 0x30, 0x0b, 0x1d, 0xf1, 0x20, 0x80, 0x00,
622 0xf5, 0x20, 0x89, 0x11, 0xf4, 0x95, 0x48, 0x11, 622 0xf5, 0x20, 0x89, 0x11, 0xf4, 0x95, 0x48, 0x11,
623 0x6f, 0xf8, 0x27, 0x71, 0x0d, 0x00, 0xf4, 0x95, 623 0x6f, 0xf8, 0x27, 0x71, 0x0d, 0x00, 0xf4, 0x95,
624 0x49, 0x0b, 0x4f, 0xf8, 0x27, 0x70, 0x48, 0x11, 624 0x49, 0x0b, 0x4f, 0xf8, 0x27, 0x70, 0x48, 0x11,
625 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 625 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16,
626 0x4a, 0x17, 0xee, 0xf0, 0x88, 0x17, 0x10, 0x17, 626 0x4a, 0x17, 0xee, 0xf0, 0x88, 0x17, 0x10, 0x17,
627 0x80, 0x05, 0x10, 0x16, 0x80, 0x06, 0x10, 0x15, 627 0x80, 0x05, 0x10, 0x16, 0x80, 0x06, 0x10, 0x15,
628 0x80, 0x07, 0x71, 0x14, 0x00, 0x11, 0x10, 0x05, 628 0x80, 0x07, 0x71, 0x14, 0x00, 0x11, 0x10, 0x05,
629 0xf0, 0x30, 0x00, 0x01, 0x88, 0x10, 0x10, 0x06, 629 0xf0, 0x30, 0x00, 0x01, 0x88, 0x10, 0x10, 0x06,
630 0xf0, 0x30, 0x00, 0x01, 0x80, 0x08, 0x49, 0x11, 630 0xf0, 0x30, 0x00, 0x01, 0x80, 0x08, 0x49, 0x11,
631 0x10, 0x05, 0xf6, 0x01, 0x80, 0x09, 0x10, 0x06, 631 0x10, 0x05, 0xf6, 0x01, 0x80, 0x09, 0x10, 0x06,
632 0x61, 0xf8, 0x00, 0x08, 0x00, 0x01, 0xf8, 0x20, 632 0x61, 0xf8, 0x00, 0x08, 0x00, 0x01, 0xf8, 0x20,
633 0x0b, 0x4b, 0x10, 0x09, 0xf0, 0x00, 0x00, 0x01, 633 0x0b, 0x4b, 0x10, 0x09, 0xf0, 0x00, 0x00, 0x01,
634 0x80, 0x09, 0x71, 0x08, 0x00, 0x12, 0xf4, 0xaa, 634 0x80, 0x09, 0x71, 0x08, 0x00, 0x12, 0xf4, 0xaa,
635 0xf8, 0x30, 0x0b, 0x54, 0x10, 0x09, 0xf0, 0x00, 635 0xf8, 0x30, 0x0b, 0x54, 0x10, 0x09, 0xf0, 0x00,
636 0x00, 0x01, 0x80, 0x09, 0x12, 0x09, 0x49, 0x11, 636 0x00, 0x01, 0x80, 0x09, 0x12, 0x09, 0x49, 0x11,
637 0xf4, 0x7f, 0x80, 0x09, 0xf6, 0x20, 0x80, 0x0a, 637 0xf4, 0x7f, 0x80, 0x09, 0xf6, 0x20, 0x80, 0x0a,
638 0x56, 0xf8, 0x27, 0x70, 0x4e, 0x0c, 0x10, 0x09, 638 0x56, 0xf8, 0x27, 0x70, 0x4e, 0x0c, 0x10, 0x09,
639 0x80, 0x00, 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce, 639 0x80, 0x00, 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce,
640 0xf0, 0x00, 0x00, 0x04, 0x88, 0x16, 0xf4, 0x95, 640 0xf0, 0x00, 0x00, 0x04, 0x88, 0x16, 0xf4, 0x95,
641 0xf4, 0x95, 0x6c, 0x86, 0x0b, 0x6d, 0xf2, 0x73, 641 0xf4, 0x95, 0x6c, 0x86, 0x0b, 0x6d, 0xf2, 0x73,
642 0x0c, 0x59, 0xf4, 0x95, 0xe8, 0x00, 0xf6, 0xb8, 642 0x0c, 0x59, 0xf4, 0x95, 0xe8, 0x00, 0xf6, 0xb8,
643 0xf4, 0x95, 0x56, 0x0c, 0xf0, 0xf9, 0x88, 0x12, 643 0xf4, 0x95, 0x56, 0x0c, 0xf0, 0xf9, 0x88, 0x12,
644 0xf4, 0x95, 0xf4, 0x95, 0x70, 0xe2, 0x27, 0x7c, 644 0xf4, 0x95, 0xf4, 0x95, 0x70, 0xe2, 0x27, 0x7c,
645 0x29, 0x86, 0xe8, 0x00, 0x80, 0x0e, 0x48, 0x11, 645 0x29, 0x86, 0xe8, 0x00, 0x80, 0x0e, 0x48, 0x11,
646 0xf8, 0x45, 0x0b, 0xcc, 0x77, 0x10, 0x00, 0x01, 646 0xf8, 0x45, 0x0b, 0xcc, 0x77, 0x10, 0x00, 0x01,
647 0xf4, 0xa9, 0xf8, 0x30, 0x0b, 0x89, 0x6c, 0xe1, 647 0xf4, 0xa9, 0xf8, 0x30, 0x0b, 0x89, 0x6c, 0xe1,
648 0xff, 0xfd, 0x0b, 0x8b, 0x10, 0xe7, 0x00, 0x02, 648 0xff, 0xfd, 0x0b, 0x8b, 0x10, 0xe7, 0x00, 0x02,
649 0x80, 0x0e, 0xf0, 0x73, 0x0b, 0x8b, 0x10, 0x87, 649 0x80, 0x0e, 0xf0, 0x73, 0x0b, 0x8b, 0x10, 0x87,
650 0x80, 0x0e, 0xe7, 0x10, 0xf5, 0xae, 0xf8, 0x20, 650 0x80, 0x0e, 0xe7, 0x10, 0xf5, 0xae, 0xf8, 0x20,
651 0x0b, 0xb2, 0x70, 0x00, 0x00, 0x17, 0x70, 0x01, 651 0x0b, 0xb2, 0x70, 0x00, 0x00, 0x17, 0x70, 0x01,
652 0x00, 0x16, 0x10, 0x04, 0xf0, 0x74, 0x06, 0xce, 652 0x00, 0x16, 0x10, 0x04, 0xf0, 0x74, 0x06, 0xce,
653 0x48, 0x17, 0x49, 0x16, 0xf6, 0x00, 0x88, 0x17, 653 0x48, 0x17, 0x49, 0x16, 0xf6, 0x00, 0x88, 0x17,
654 0x48, 0x11, 0xf6, 0x20, 0x88, 0x11, 0x10, 0x09, 654 0x48, 0x11, 0xf6, 0x20, 0x88, 0x11, 0x10, 0x09,
655 0xf6, 0x20, 0x80, 0x00, 0x48, 0x18, 0xf2, 0x74, 655 0xf6, 0x20, 0x80, 0x00, 0x48, 0x18, 0xf2, 0x74,
656 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x16, 656 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x16,
657 0x10, 0x04, 0x70, 0x00, 0x00, 0x17, 0x70, 0x01, 657 0x10, 0x04, 0x70, 0x00, 0x00, 0x17, 0x70, 0x01,
658 0x00, 0x11, 0xf0, 0x74, 0x06, 0xce, 0x48, 0x11, 658 0x00, 0x11, 0xf0, 0x74, 0x06, 0xce, 0x48, 0x11,
659 0x00, 0x04, 0x80, 0x04, 0xf0, 0x73, 0x0b, 0xbc, 659 0x00, 0x04, 0x80, 0x04, 0xf0, 0x73, 0x0b, 0xbc,
660 0x70, 0x00, 0x00, 0x17, 0x70, 0x01, 0x00, 0x11, 660 0x70, 0x00, 0x00, 0x17, 0x70, 0x01, 0x00, 0x11,
661 0x10, 0x04, 0xf0, 0x74, 0x06, 0xce, 0x48, 0x11, 661 0x10, 0x04, 0xf0, 0x74, 0x06, 0xce, 0x48, 0x11,
662 0x00, 0x04, 0x80, 0x04, 0x49, 0x11, 0x48, 0x16, 662 0x00, 0x04, 0x80, 0x04, 0x49, 0x11, 0x48, 0x16,
663 0xf6, 0x20, 0x88, 0x16, 0xf4, 0x95, 0xf4, 0x95, 663 0xf6, 0x20, 0x88, 0x16, 0xf4, 0x95, 0xf4, 0x95,
664 0x6c, 0x86, 0x0b, 0xcc, 0x10, 0x0a, 0x80, 0x00, 664 0x6c, 0x86, 0x0b, 0xcc, 0x10, 0x0a, 0x80, 0x00,
665 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00, 665 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00,
666 0x00, 0x04, 0x88, 0x16, 0x12, 0x0a, 0xf8, 0x45, 666 0x00, 0x04, 0x88, 0x16, 0x12, 0x0a, 0xf8, 0x45,
667 0x0c, 0x33, 0x71, 0x0a, 0x00, 0x10, 0xf4, 0xae, 667 0x0c, 0x33, 0x71, 0x0a, 0x00, 0x10, 0xf4, 0xae,
668 0xf8, 0x30, 0x0c, 0x1c, 0x48, 0x16, 0xf0, 0xe1, 668 0xf8, 0x30, 0x0c, 0x1c, 0x48, 0x16, 0xf0, 0xe1,
669 0x88, 0x11, 0x12, 0x08, 0xf8, 0x45, 0x0b, 0xdb, 669 0x88, 0x11, 0x12, 0x08, 0xf8, 0x45, 0x0b, 0xdb,
670 0x6d, 0x89, 0x12, 0x07, 0xf8, 0x45, 0x0b, 0xe9, 670 0x6d, 0x89, 0x12, 0x07, 0xf8, 0x45, 0x0b, 0xe9,
671 0x10, 0x07, 0x80, 0x00, 0x70, 0x02, 0x00, 0x11, 671 0x10, 0x07, 0x80, 0x00, 0x70, 0x02, 0x00, 0x11,
672 0x10, 0x06, 0x80, 0x01, 0x10, 0x04, 0xf0, 0x74, 672 0x10, 0x06, 0x80, 0x01, 0x10, 0x04, 0xf0, 0x74,
673 0x06, 0xdc, 0xf0, 0x73, 0x0b, 0xef, 0x48, 0x11, 673 0x06, 0xdc, 0xf0, 0x73, 0x0b, 0xef, 0x48, 0x11,
674 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04, 0xf0, 0x74, 674 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04, 0xf0, 0x74,
675 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0, 0x81, 0x0e, 675 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0, 0x81, 0x0e,
676 0x10, 0x06, 0x49, 0x11, 0xf6, 0x00, 0x80, 0x06, 676 0x10, 0x06, 0x49, 0x11, 0xf6, 0x00, 0x80, 0x06,
677 0x10, 0x05, 0xf6, 0x20, 0x88, 0x11, 0xf0, 0x00, 677 0x10, 0x05, 0xf6, 0x20, 0x88, 0x11, 0xf0, 0x00,
678 0x00, 0x01, 0x48, 0x08, 0x6f, 0x00, 0x0c, 0x9f, 678 0x00, 0x01, 0x48, 0x08, 0x6f, 0x00, 0x0c, 0x9f,
679 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00, 679 0x48, 0x18, 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00,
680 0x00, 0x04, 0x12, 0x07, 0xf8, 0x45, 0x0c, 0x11, 680 0x00, 0x04, 0x12, 0x07, 0xf8, 0x45, 0x0c, 0x11,
681 0x10, 0x07, 0x80, 0x00, 0x70, 0x02, 0x00, 0x11, 681 0x10, 0x07, 0x80, 0x00, 0x70, 0x02, 0x00, 0x11,
682 0x10, 0x06, 0x80, 0x01, 0x10, 0x04, 0xf0, 0x74, 682 0x10, 0x06, 0x80, 0x01, 0x10, 0x04, 0xf0, 0x74,
683 0x06, 0xdc, 0xf0, 0x73, 0x0c, 0x17, 0x48, 0x11, 683 0x06, 0xdc, 0xf0, 0x73, 0x0c, 0x17, 0x48, 0x11,
684 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04, 0xf0, 0x74, 684 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04, 0xf0, 0x74,
685 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0, 0x81, 0x0e, 685 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0, 0x81, 0x0e,
686 0xf0, 0x73, 0x0c, 0x33, 0x12, 0x07, 0xf8, 0x45, 686 0xf0, 0x73, 0x0c, 0x33, 0x12, 0x07, 0xf8, 0x45,
687 0x0c, 0x2a, 0x10, 0x07, 0x80, 0x00, 0x10, 0x06, 687 0x0c, 0x2a, 0x10, 0x07, 0x80, 0x00, 0x10, 0x06,
688 0x80, 0x01, 0x10, 0x05, 0x80, 0x02, 0x10, 0x04, 688 0x80, 0x01, 0x10, 0x05, 0x80, 0x02, 0x10, 0x04,
689 0xf0, 0x74, 0x06, 0xdc, 0xf0, 0x73, 0x0c, 0x30, 689 0xf0, 0x74, 0x06, 0xdc, 0xf0, 0x73, 0x0c, 0x30,
690 0x12, 0x05, 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04, 690 0x12, 0x05, 0x6f, 0x00, 0x0c, 0x9f, 0x10, 0x04,
691 0xf0, 0x74, 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0, 691 0xf0, 0x74, 0x0a, 0xb3, 0x11, 0x0e, 0xf1, 0xc0,
692 0x81, 0x0e, 0x76, 0x00, 0x00, 0x01, 0x48, 0x18, 692 0x81, 0x0e, 0x76, 0x00, 0x00, 0x01, 0x48, 0x18,
693 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04, 693 0xf2, 0x74, 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04,
694 0x71, 0x04, 0x00, 0x11, 0x70, 0x81, 0x29, 0x86, 694 0x71, 0x04, 0x00, 0x11, 0x70, 0x81, 0x29, 0x86,
695 0x10, 0x0e, 0x1c, 0xf8, 0x29, 0x86, 0x80, 0x0e, 695 0x10, 0x0e, 0x1c, 0xf8, 0x29, 0x86, 0x80, 0x0e,
696 0x76, 0x00, 0x00, 0x01, 0x48, 0x18, 0xf2, 0x74, 696 0x76, 0x00, 0x00, 0x01, 0x48, 0x18, 0xf2, 0x74,
697 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04, 0x10, 0x0e, 697 0x0a, 0xce, 0xf0, 0x00, 0x00, 0x04, 0x10, 0x0e,
698 0x71, 0x04, 0x00, 0x11, 0x80, 0x81, 0x10, 0xf8, 698 0x71, 0x04, 0x00, 0x11, 0x80, 0x81, 0x10, 0xf8,
699 0x29, 0x86, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x30, 699 0x29, 0x86, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x30,
700 0x7f, 0xff, 0x80, 0xf8, 0x29, 0x86, 0x10, 0x09, 700 0x7f, 0xff, 0x80, 0xf8, 0x29, 0x86, 0x10, 0x09,
701 0xf0, 0x00, 0x00, 0x02, 0x80, 0x09, 0xee, 0x10, 701 0xf0, 0x00, 0x00, 0x02, 0x80, 0x09, 0xee, 0x10,
702 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00, 702 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00,
703 0x10, 0xf8, 0x27, 0x75, 0x08, 0xf8, 0x27, 0x71, 703 0x10, 0xf8, 0x27, 0x75, 0x08, 0xf8, 0x27, 0x71,
704 0xf0, 0x10, 0x00, 0x01, 0x48, 0x08, 0xfc, 0x00, 704 0xf0, 0x10, 0x00, 0x01, 0x48, 0x08, 0xfc, 0x00,
705 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xff, 0xf4, 0x95, 705 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xff, 0xf4, 0x95,
706 0x71, 0x04, 0x00, 0x16, 0xf0, 0x00, 0x00, 0x01, 706 0x71, 0x04, 0x00, 0x16, 0xf0, 0x00, 0x00, 0x01,
707 0x48, 0x08, 0x4e, 0xf8, 0x29, 0x7c, 0x6d, 0xee, 707 0x48, 0x08, 0x4e, 0xf8, 0x29, 0x7c, 0x6d, 0xee,
708 0xff, 0xfd, 0x48, 0x16, 0xf8, 0x45, 0x0c, 0x99, 708 0xff, 0xfd, 0x48, 0x16, 0xf8, 0x45, 0x0c, 0x99,
709 0x56, 0xf8, 0x29, 0x7c, 0xf0, 0x74, 0x0a, 0x5a, 709 0x56, 0xf8, 0x29, 0x7c, 0xf0, 0x74, 0x0a, 0x5a,
710 0x88, 0x11, 0x10, 0xf8, 0x29, 0x7d, 0xf0, 0x00, 710 0x88, 0x11, 0x10, 0xf8, 0x29, 0x7d, 0xf0, 0x00,
711 0x00, 0x01, 0x48, 0x08, 0x4e, 0xf8, 0x29, 0x7c, 711 0x00, 0x01, 0x48, 0x08, 0x4e, 0xf8, 0x29, 0x7c,
712 0x10, 0xf8, 0x29, 0x82, 0xf0, 0x00, 0x00, 0x01, 712 0x10, 0xf8, 0x29, 0x82, 0xf0, 0x00, 0x00, 0x01,
713 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xa9, 713 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xa9,
714 0xfa, 0x30, 0x0c, 0x96, 0x80, 0xf8, 0x29, 0x82, 714 0xfa, 0x30, 0x0c, 0x96, 0x80, 0xf8, 0x29, 0x82,
715 0x56, 0xf8, 0x29, 0x80, 0xf0, 0x00, 0x00, 0x01, 715 0x56, 0xf8, 0x29, 0x80, 0xf0, 0x00, 0x00, 0x01,
716 0x4e, 0xf8, 0x29, 0x80, 0x73, 0x11, 0x29, 0x82, 716 0x4e, 0xf8, 0x29, 0x80, 0x73, 0x11, 0x29, 0x82,
717 0x6c, 0xee, 0xff, 0xff, 0x0c, 0x76, 0xee, 0x01, 717 0x6c, 0xee, 0xff, 0xff, 0x0c, 0x76, 0xee, 0x01,
718 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 718 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
719 0x76, 0xf8, 0x29, 0x84, 0x00, 0x00, 0x76, 0xf8, 719 0x76, 0xf8, 0x29, 0x84, 0x00, 0x00, 0x76, 0xf8,
720 0x29, 0x85, 0x00, 0x01, 0xe8, 0x00, 0x4e, 0xf8, 720 0x29, 0x85, 0x00, 0x01, 0xe8, 0x00, 0x4e, 0xf8,
721 0x2a, 0x0c, 0x76, 0xf8, 0x29, 0x86, 0x00, 0x00, 721 0x2a, 0x0c, 0x76, 0xf8, 0x29, 0x86, 0x00, 0x00,
722 0x76, 0xf8, 0x29, 0x87, 0x00, 0x00, 0x77, 0x11, 722 0x76, 0xf8, 0x29, 0x87, 0x00, 0x00, 0x77, 0x11,
723 0x29, 0x88, 0x76, 0x81, 0xaa, 0xaa, 0x76, 0xe1, 723 0x29, 0x88, 0x76, 0x81, 0xaa, 0xaa, 0x76, 0xe1,
724 0x00, 0x01, 0xaa, 0xaa, 0x76, 0xe1, 0x00, 0x02, 724 0x00, 0x01, 0xaa, 0xaa, 0x76, 0xe1, 0x00, 0x02,
725 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 725 0x00, 0x00, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
726 0xee, 0xfc, 0xf4, 0x95, 0x71, 0x06, 0x00, 0x14, 726 0xee, 0xfc, 0xf4, 0x95, 0x71, 0x06, 0x00, 0x14,
727 0x71, 0x07, 0x00, 0x13, 0x71, 0x08, 0x00, 0x12, 727 0x71, 0x07, 0x00, 0x13, 0x71, 0x08, 0x00, 0x12,
728 0x71, 0x09, 0x00, 0x15, 0x77, 0x10, 0x00, 0xff, 728 0x71, 0x09, 0x00, 0x15, 0x77, 0x10, 0x00, 0xff,
729 0xf4, 0xaa, 0xf8, 0x30, 0x0d, 0x44, 0x49, 0x13, 729 0xf4, 0xaa, 0xf8, 0x30, 0x0d, 0x44, 0x49, 0x13,
730 0x53, 0xf8, 0x2a, 0x0c, 0x4f, 0xf8, 0x2a, 0x0c, 730 0x53, 0xf8, 0x2a, 0x0c, 0x4f, 0xf8, 0x2a, 0x0c,
731 0x73, 0x12, 0x00, 0x0e, 0xf1, 0x66, 0x00, 0x0d, 731 0x73, 0x12, 0x00, 0x0e, 0xf1, 0x66, 0x00, 0x0d,
732 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x01, 732 0x89, 0x11, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x01,
733 0x71, 0xe1, 0x24, 0x00, 0x00, 0x11, 0xf4, 0xa9, 733 0x71, 0xe1, 0x24, 0x00, 0x00, 0x11, 0xf4, 0xa9,
734 0xf8, 0x30, 0x0d, 0x17, 0x77, 0x10, 0x00, 0x02, 734 0xf8, 0x30, 0x0d, 0x17, 0x77, 0x10, 0x00, 0x02,
735 0xf4, 0xa9, 0xf8, 0x30, 0x0c, 0xec, 0x77, 0x11, 735 0xf4, 0xa9, 0xf8, 0x30, 0x0c, 0xec, 0x77, 0x11,
736 0x29, 0x8a, 0x76, 0x81, 0x00, 0x00, 0xe8, 0x00, 736 0x29, 0x8a, 0x76, 0x81, 0x00, 0x00, 0xe8, 0x00,
737 0x77, 0x14, 0x00, 0x00, 0x77, 0x13, 0x00, 0x00, 737 0x77, 0x14, 0x00, 0x00, 0x77, 0x13, 0x00, 0x00,
738 0xf0, 0x73, 0x0d, 0x48, 0x6c, 0x83, 0x0c, 0xfa, 738 0xf0, 0x73, 0x0d, 0x48, 0x6c, 0x83, 0x0c, 0xfa,
739 0x77, 0x11, 0x29, 0x8a, 0x48, 0x12, 0xf0, 0xe8, 739 0x77, 0x11, 0x29, 0x8a, 0x48, 0x12, 0xf0, 0xe8,
740 0xf0, 0x40, 0x80, 0x00, 0x80, 0x81, 0xe8, 0x00, 740 0xf0, 0x40, 0x80, 0x00, 0x80, 0x81, 0xe8, 0x00,
741 0x77, 0x14, 0x00, 0x00, 0xf0, 0x73, 0x0d, 0x48, 741 0x77, 0x14, 0x00, 0x00, 0xf0, 0x73, 0x0d, 0x48,
742 0x49, 0x13, 0xf3, 0x40, 0x80, 0x00, 0x81, 0xf8, 742 0x49, 0x13, 0xf3, 0x40, 0x80, 0x00, 0x81, 0xf8,
743 0x29, 0x8a, 0x61, 0xf8, 0x00, 0x15, 0x00, 0x01, 743 0x29, 0x8a, 0x61, 0xf8, 0x00, 0x15, 0x00, 0x01,
744 0xf8, 0x20, 0x0d, 0x07, 0x69, 0xf8, 0x29, 0x8a, 744 0xf8, 0x20, 0x0d, 0x07, 0x69, 0xf8, 0x29, 0x8a,
745 0x40, 0x00, 0x61, 0xf8, 0x00, 0x14, 0x00, 0x01, 745 0x40, 0x00, 0x61, 0xf8, 0x00, 0x14, 0x00, 0x01,
746 0xf8, 0x20, 0x0d, 0x0f, 0x69, 0xf8, 0x29, 0x8a, 746 0xf8, 0x20, 0x0d, 0x0f, 0x69, 0xf8, 0x29, 0x8a,
747 0x20, 0x00, 0x77, 0x11, 0x29, 0x8a, 0x49, 0x12, 747 0x20, 0x00, 0x77, 0x11, 0x29, 0x8a, 0x49, 0x12,
748 0xf3, 0xe8, 0x1b, 0x81, 0x81, 0x81, 0xf0, 0x73, 748 0xf3, 0xe8, 0x1b, 0x81, 0x81, 0x81, 0xf0, 0x73,
749 0x0d, 0x48, 0x11, 0xf8, 0x29, 0x84, 0xf8, 0x4c, 749 0x0d, 0x48, 0x11, 0xf8, 0x29, 0x84, 0xf8, 0x4c,
750 0x0d, 0x37, 0x77, 0x11, 0x29, 0x88, 0x76, 0x81, 750 0x0d, 0x37, 0x77, 0x11, 0x29, 0x88, 0x76, 0x81,
751 0xaa, 0xaa, 0x11, 0xf8, 0x29, 0x85, 0xf3, 0x10, 751 0xaa, 0xaa, 0x11, 0xf8, 0x29, 0x85, 0xf3, 0x10,
752 0x00, 0x01, 0xf3, 0x40, 0xaa, 0x00, 0x81, 0xe1, 752 0x00, 0x01, 0xf3, 0x40, 0xaa, 0x00, 0x81, 0xe1,
753 0x00, 0x01, 0x76, 0x00, 0x00, 0x02, 0x80, 0x01, 753 0x00, 0x01, 0x76, 0x00, 0x00, 0x02, 0x80, 0x01,
754 0x70, 0x02, 0x00, 0x14, 0x70, 0x03, 0x00, 0x13, 754 0x70, 0x02, 0x00, 0x14, 0x70, 0x03, 0x00, 0x13,
755 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 0x48, 0x11, 755 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 0x48, 0x11,
756 0x71, 0xf8, 0x29, 0x85, 0x29, 0x84, 0xf0, 0x73, 756 0x71, 0xf8, 0x29, 0x85, 0x29, 0x84, 0xf0, 0x73,
757 0x0d, 0x73, 0x76, 0x00, 0x00, 0x00, 0x80, 0x01, 757 0x0d, 0x73, 0x76, 0x00, 0x00, 0x00, 0x80, 0x01,
758 0x76, 0x02, 0x00, 0x00, 0x70, 0x03, 0x00, 0x13, 758 0x76, 0x02, 0x00, 0x00, 0x70, 0x03, 0x00, 0x13,
759 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 0xe8, 0x00, 759 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 0xe8, 0x00,
760 0xf0, 0x73, 0x0d, 0x73, 0x77, 0x11, 0x29, 0x8a, 760 0xf0, 0x73, 0x0d, 0x73, 0x77, 0x11, 0x29, 0x8a,
761 0x70, 0x81, 0x00, 0x13, 0x11, 0xf8, 0x29, 0x84, 761 0x70, 0x81, 0x00, 0x13, 0x11, 0xf8, 0x29, 0x84,
762 0xf8, 0x4c, 0x0d, 0x68, 0x77, 0x11, 0x29, 0x88, 762 0xf8, 0x4c, 0x0d, 0x68, 0x77, 0x11, 0x29, 0x88,
763 0x76, 0x81, 0xaa, 0xaa, 0x11, 0xf8, 0x29, 0x85, 763 0x76, 0x81, 0xaa, 0xaa, 0x11, 0xf8, 0x29, 0x85,
764 0xf3, 0x10, 0x00, 0x01, 0xf3, 0x40, 0xaa, 0x00, 764 0xf3, 0x10, 0x00, 0x01, 0xf3, 0x40, 0xaa, 0x00,
765 0x81, 0xe1, 0x00, 0x01, 0x76, 0x00, 0x00, 0x03, 765 0x81, 0xe1, 0x00, 0x01, 0x76, 0x00, 0x00, 0x03,
766 0x80, 0x01, 0x70, 0x02, 0x00, 0x14, 0x70, 0x03, 766 0x80, 0x01, 0x70, 0x02, 0x00, 0x14, 0x70, 0x03,
767 0x00, 0x13, 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 767 0x00, 0x13, 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95,
768 0x48, 0x11, 0x71, 0xf8, 0x29, 0x85, 0x29, 0x84, 768 0x48, 0x11, 0x71, 0xf8, 0x29, 0x85, 0x29, 0x84,
769 0xf0, 0x73, 0x0d, 0x73, 0x76, 0x00, 0x00, 0x01, 769 0xf0, 0x73, 0x0d, 0x73, 0x76, 0x00, 0x00, 0x01,
770 0x80, 0x01, 0x70, 0x02, 0x00, 0x14, 0x70, 0x03, 770 0x80, 0x01, 0x70, 0x02, 0x00, 0x14, 0x70, 0x03,
771 0x00, 0x13, 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95, 771 0x00, 0x13, 0xf2, 0x74, 0x0b, 0x28, 0xf4, 0x95,
772 0x48, 0x11, 0x6b, 0xf8, 0x29, 0x84, 0xff, 0xff, 772 0x48, 0x11, 0x6b, 0xf8, 0x29, 0x84, 0xff, 0xff,
773 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 773 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
774 0xf5, 0x40, 0xf4, 0x95, 0x48, 0x0b, 0xf4, 0x78, 774 0xf5, 0x40, 0xf4, 0x95, 0x48, 0x0b, 0xf4, 0x78,
775 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0xe1, 775 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0xe1,
776 0xff, 0xb9, 0x0d, 0x88, 0xf2, 0x73, 0x0d, 0xa5, 776 0xff, 0xb9, 0x0d, 0x88, 0xf2, 0x73, 0x0d, 0xa5,
777 0xf4, 0x95, 0xe8, 0x60, 0xf2, 0x00, 0x00, 0x06, 777 0xf4, 0x95, 0xe8, 0x60, 0xf2, 0x00, 0x00, 0x06,
778 0x61, 0xf8, 0x00, 0x11, 0x00, 0x20, 0xf8, 0x30, 778 0x61, 0xf8, 0x00, 0x11, 0x00, 0x20, 0xf8, 0x30,
779 0x0d, 0x98, 0x61, 0xf8, 0x00, 0x0b, 0x00, 0x01, 779 0x0d, 0x98, 0x61, 0xf8, 0x00, 0x0b, 0x00, 0x01,
780 0xf8, 0x20, 0x0d, 0xa3, 0xf2, 0x00, 0x00, 0x07, 780 0xf8, 0x20, 0x0d, 0xa3, 0xf2, 0x00, 0x00, 0x07,
781 0xf0, 0x73, 0x0d, 0xa3, 0x61, 0xf8, 0x00, 0x0b, 781 0xf0, 0x73, 0x0d, 0xa3, 0x61, 0xf8, 0x00, 0x0b,
782 0x00, 0x01, 0xf8, 0x20, 0x0d, 0xa1, 0xf2, 0x73, 782 0x00, 0x01, 0xf8, 0x20, 0x0d, 0xa1, 0xf2, 0x73,
783 0x0d, 0xa3, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00, 783 0x0d, 0xa3, 0xf0, 0x00, 0x00, 0x01, 0xf0, 0x00,
784 0x00, 0x02, 0x48, 0x08, 0xf4, 0x7f, 0x8a, 0x11, 784 0x00, 0x02, 0x48, 0x08, 0xf4, 0x7f, 0x8a, 0x11,
785 0xfc, 0x00, 0xee, 0xff, 0xf0, 0x74, 0x07, 0xfd, 785 0xfc, 0x00, 0xee, 0xff, 0xf0, 0x74, 0x07, 0xfd,
786 0xf0, 0x74, 0x07, 0x44, 0xf0, 0x74, 0x0d, 0xb4, 786 0xf0, 0x74, 0x07, 0x44, 0xf0, 0x74, 0x0d, 0xb4,
787 0xf0, 0x74, 0x02, 0x05, 0xf0, 0x74, 0x04, 0x60, 787 0xf0, 0x74, 0x02, 0x05, 0xf0, 0x74, 0x04, 0x60,
788 0xf0, 0x73, 0x0d, 0xaa, 0xee, 0xfd, 0x10, 0xf8, 788 0xf0, 0x73, 0x0d, 0xaa, 0xee, 0xfd, 0x10, 0xf8,
789 0x2a, 0xa3, 0xf8, 0x44, 0x0d, 0xcb, 0x10, 0xf8, 789 0x2a, 0xa3, 0xf8, 0x44, 0x0d, 0xcb, 0x10, 0xf8,
790 0x2a, 0xa4, 0xf8, 0x45, 0x0d, 0xd7, 0x76, 0x00, 790 0x2a, 0xa4, 0xf8, 0x45, 0x0d, 0xd7, 0x76, 0x00,
791 0x02, 0x00, 0xf2, 0x74, 0x09, 0xe8, 0xf0, 0x20, 791 0x02, 0x00, 0xf2, 0x74, 0x09, 0xe8, 0xf0, 0x20,
792 0x22, 0x00, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x00, 792 0x22, 0x00, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x00,
793 0x76, 0xf8, 0x2a, 0xa7, 0x00, 0x00, 0xf0, 0x73, 793 0x76, 0xf8, 0x2a, 0xa7, 0x00, 0x00, 0xf0, 0x73,
794 0x0d, 0xd7, 0x76, 0x00, 0x02, 0x00, 0xf2, 0x74, 794 0x0d, 0xd7, 0x76, 0x00, 0x02, 0x00, 0xf2, 0x74,
795 0x09, 0xe8, 0xf0, 0x20, 0x20, 0x00, 0x76, 0xf8, 795 0x09, 0xe8, 0xf0, 0x20, 0x20, 0x00, 0x76, 0xf8,
796 0x2a, 0xa3, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa7, 796 0x2a, 0xa3, 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa7,
797 0x00, 0x01, 0xf0, 0x74, 0x0c, 0x5e, 0xf0, 0xe0, 797 0x00, 0x01, 0xf0, 0x74, 0x0c, 0x5e, 0xf0, 0xe0,
798 0xf0, 0x10, 0x3a, 0x98, 0xf8, 0x47, 0x0d, 0xe1, 798 0xf0, 0x10, 0x3a, 0x98, 0xf8, 0x47, 0x0d, 0xe1,
799 0x76, 0xf8, 0x27, 0x6e, 0x00, 0x00, 0xee, 0x03, 799 0x76, 0xf8, 0x27, 0x6e, 0x00, 0x00, 0xee, 0x03,
800 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 0x77, 0x11, 800 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 0x77, 0x11,
801 0x20, 0x00, 0x76, 0x00, 0xaa, 0xaa, 0x76, 0x01, 801 0x20, 0x00, 0x76, 0x00, 0xaa, 0xaa, 0x76, 0x01,
802 0x02, 0x00, 0xf2, 0x74, 0x06, 0x6c, 0xf4, 0x95, 802 0x02, 0x00, 0xf2, 0x74, 0x06, 0x6c, 0xf4, 0x95,
803 0x48, 0x11, 0x76, 0x00, 0x55, 0x55, 0x76, 0x01, 803 0x48, 0x11, 0x76, 0x00, 0x55, 0x55, 0x76, 0x01,
804 0x02, 0x00, 0x48, 0x11, 0xf2, 0x74, 0x06, 0x6c, 804 0x02, 0x00, 0x48, 0x11, 0xf2, 0x74, 0x06, 0x6c,
805 0xf0, 0x00, 0x02, 0x00, 0x76, 0xf8, 0x2a, 0xa3, 805 0xf0, 0x00, 0x02, 0x00, 0x76, 0xf8, 0x2a, 0xa3,
806 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x00, 806 0x00, 0x00, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x00,
807 0xe8, 0x00, 0x4e, 0x00, 0xfb, 0x80, 0x15, 0x3e, 807 0xe8, 0x00, 0x4e, 0x00, 0xfb, 0x80, 0x15, 0x3e,
808 0xf4, 0x95, 0xe8, 0x04, 0x80, 0xf8, 0x2a, 0xa5, 808 0xf4, 0x95, 0xe8, 0x04, 0x80, 0xf8, 0x2a, 0xa5,
809 0x76, 0x00, 0x2a, 0xa8, 0xf9, 0x80, 0x14, 0x87, 809 0x76, 0x00, 0x2a, 0xa8, 0xf9, 0x80, 0x14, 0x87,
810 0x76, 0x00, 0x2a, 0xad, 0xfb, 0x80, 0x13, 0x62, 810 0x76, 0x00, 0x2a, 0xad, 0xfb, 0x80, 0x13, 0x62,
811 0xf4, 0x95, 0xe8, 0x02, 0x10, 0xf8, 0x2a, 0xa5, 811 0xf4, 0x95, 0xe8, 0x02, 0x10, 0xf8, 0x2a, 0xa5,
812 0xf9, 0x80, 0x14, 0x63, 0xfb, 0x80, 0x16, 0x66, 812 0xf9, 0x80, 0x14, 0x63, 0xfb, 0x80, 0x16, 0x66,
813 0xf4, 0x95, 0xe8, 0x1c, 0xfb, 0x80, 0x16, 0x87, 813 0xf4, 0x95, 0xe8, 0x1c, 0xfb, 0x80, 0x16, 0x87,
814 0xf4, 0x95, 0xe8, 0x1c, 0xe8, 0x01, 0x4e, 0x00, 814 0xf4, 0x95, 0xe8, 0x1c, 0xe8, 0x01, 0x4e, 0x00,
815 0xfb, 0x80, 0x17, 0xd6, 0xf4, 0x95, 0xe8, 0x00, 815 0xfb, 0x80, 0x17, 0xd6, 0xf4, 0x95, 0xe8, 0x00,
816 0x80, 0xf8, 0x2a, 0xa6, 0x76, 0x00, 0x2a, 0xb7, 816 0x80, 0xf8, 0x2a, 0xa6, 0x76, 0x00, 0x2a, 0xb7,
817 0xf9, 0x80, 0x16, 0xaa, 0x10, 0xf8, 0x2a, 0xa6, 817 0xf9, 0x80, 0x16, 0xaa, 0x10, 0xf8, 0x2a, 0xa6,
818 0xf9, 0x80, 0x17, 0x5c, 0x10, 0xf8, 0x2a, 0xa6, 818 0xf9, 0x80, 0x17, 0x5c, 0x10, 0xf8, 0x2a, 0xa6,
819 0xf9, 0x80, 0x17, 0x6f, 0xee, 0x02, 0x8a, 0x11, 819 0xf9, 0x80, 0x17, 0x6f, 0xee, 0x02, 0x8a, 0x11,
820 0xfc, 0x00, 0xf4, 0x95, 0x4a, 0x08, 0x4a, 0x09, 820 0xfc, 0x00, 0xf4, 0x95, 0x4a, 0x08, 0x4a, 0x09,
821 0x4a, 0x0a, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8, 821 0x4a, 0x0a, 0x4a, 0x07, 0x4a, 0x1d, 0x68, 0xf8,
822 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07, 822 0x00, 0x07, 0x7d, 0x3f, 0x69, 0xf8, 0x00, 0x07,
823 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc, 823 0x40, 0x00, 0x68, 0xf8, 0x00, 0x1d, 0xff, 0xfc,
824 0x10, 0xf8, 0x2a, 0xa7, 0xf8, 0x44, 0x0e, 0x4b, 824 0x10, 0xf8, 0x2a, 0xa7, 0xf8, 0x44, 0x0e, 0x4b,
825 0x76, 0xf8, 0x2a, 0xa3, 0x00, 0x01, 0xf0, 0x73, 825 0x76, 0xf8, 0x2a, 0xa3, 0x00, 0x01, 0xf0, 0x73,
826 0x0e, 0x4e, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x01, 826 0x0e, 0x4e, 0x76, 0xf8, 0x2a, 0xa4, 0x00, 0x01,
827 0x8a, 0x1d, 0x8a, 0x07, 0x8a, 0x0a, 0x8a, 0x09, 827 0x8a, 0x1d, 0x8a, 0x07, 0x8a, 0x0a, 0x8a, 0x09,
828 0x8a, 0x08, 0xf4, 0xeb, 0x4a, 0x11, 0x4a, 0x16, 828 0x8a, 0x08, 0xf4, 0xeb, 0x4a, 0x11, 0x4a, 0x16,
829 0x4a, 0x17, 0xee, 0xfe, 0x88, 0x0e, 0x71, 0x08, 829 0x4a, 0x17, 0xee, 0xfe, 0x88, 0x0e, 0x71, 0x08,
830 0x00, 0x16, 0x71, 0x06, 0x00, 0x17, 0x11, 0x07, 830 0x00, 0x16, 0x71, 0x06, 0x00, 0x17, 0x11, 0x07,
831 0xf0, 0x66, 0x00, 0x0d, 0xf0, 0x00, 0x25, 0xa0, 831 0xf0, 0x66, 0x00, 0x0d, 0xf0, 0x00, 0x25, 0xa0,
832 0x88, 0x11, 0x76, 0x01, 0x00, 0x06, 0x81, 0x00, 832 0x88, 0x11, 0x76, 0x01, 0x00, 0x06, 0x81, 0x00,
833 0xf2, 0x74, 0x06, 0xce, 0xf0, 0x00, 0x00, 0x01, 833 0xf2, 0x74, 0x06, 0xce, 0xf0, 0x00, 0x00, 0x01,
834 0x76, 0x01, 0x00, 0x06, 0x70, 0x00, 0x00, 0x16, 834 0x76, 0x01, 0x00, 0x06, 0x70, 0x00, 0x00, 0x16,
835 0x48, 0x11, 0xf2, 0x74, 0x06, 0xce, 0xf0, 0x00, 835 0x48, 0x11, 0xf2, 0x74, 0x06, 0xce, 0xf0, 0x00,
836 0x00, 0x07, 0x70, 0x81, 0x00, 0x17, 0xee, 0x02, 836 0x00, 0x07, 0x70, 0x81, 0x00, 0x17, 0xee, 0x02,
837 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00, 837 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xfc, 0x00,
838 0x4a, 0x11, 0x88, 0x0e, 0x71, 0x02, 0x00, 0x12, 838 0x4a, 0x11, 0x88, 0x0e, 0x71, 0x02, 0x00, 0x12,
839 0x11, 0x03, 0xf0, 0x66, 0x00, 0x0d, 0xf0, 0x00, 839 0x11, 0x03, 0xf0, 0x66, 0x00, 0x0d, 0xf0, 0x00,
840 0x24, 0x00, 0x88, 0x11, 0xf4, 0x95, 0x70, 0x81, 840 0x24, 0x00, 0x88, 0x11, 0xf4, 0x95, 0x70, 0x81,
841 0x00, 0x12, 0x6e, 0xe2, 0xff, 0xfe, 0x0e, 0x8d, 841 0x00, 0x12, 0x6e, 0xe2, 0xff, 0xfe, 0x0e, 0x8d,
842 0xf4, 0x95, 0xe8, 0x00, 0xe8, 0x01, 0x80, 0xe1, 842 0xf4, 0x95, 0xe8, 0x00, 0xe8, 0x01, 0x80, 0xe1,
843 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff, 843 0x00, 0x02, 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff,
844 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1, 844 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1,
845 0x00, 0x0b, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0c, 845 0x00, 0x0b, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0c,
846 0x00, 0x00, 0x81, 0xe1, 0x00, 0x01, 0x8a, 0x11, 846 0x00, 0x00, 0x81, 0xe1, 0x00, 0x01, 0x8a, 0x11,
847 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfc, 0x88, 0x0e, 847 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfc, 0x88, 0x0e,
848 0xf4, 0x95, 0xf1, 0x66, 0x00, 0x0d, 0xf3, 0x00, 848 0xf4, 0x95, 0xf1, 0x66, 0x00, 0x0d, 0xf3, 0x00,
849 0x24, 0x00, 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95, 849 0x24, 0x00, 0x89, 0x11, 0xf4, 0x95, 0xf4, 0x95,
850 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x00, 0x76, 0xe1, 850 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x00, 0x76, 0xe1,
851 0x00, 0x0b, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02, 851 0x00, 0x0b, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
852 0x00, 0x01, 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 852 0x00, 0x01, 0x76, 0x00, 0x00, 0x00, 0x76, 0x01,
853 0x00, 0x00, 0x80, 0x02, 0x76, 0x03, 0x00, 0x00, 853 0x00, 0x00, 0x80, 0x02, 0x76, 0x03, 0x00, 0x00,
854 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95, 0xe8, 0x00, 854 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95, 0xe8, 0x00,
855 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 855 0xee, 0x04, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
856 0x88, 0x19, 0xf4, 0x95, 0x73, 0x19, 0x00, 0x0e, 856 0x88, 0x19, 0xf4, 0x95, 0x73, 0x19, 0x00, 0x0e,
857 0xf1, 0x66, 0x00, 0x0d, 0xf2, 0x00, 0x24, 0x00, 857 0xf1, 0x66, 0x00, 0x0d, 0xf2, 0x00, 0x24, 0x00,
858 0x77, 0x15, 0x25, 0xa0, 0x77, 0x14, 0x00, 0x00, 858 0x77, 0x15, 0x25, 0xa0, 0x77, 0x14, 0x00, 0x00,
859 0x77, 0x1a, 0x00, 0x1f, 0xf0, 0x72, 0x0f, 0x14, 859 0x77, 0x1a, 0x00, 0x1f, 0xf0, 0x72, 0x0f, 0x14,
860 0xf6, 0xb8, 0x49, 0x19, 0x09, 0x85, 0xf8, 0x4c, 860 0xf6, 0xb8, 0x49, 0x19, 0x09, 0x85, 0xf8, 0x4c,
861 0x0f, 0x13, 0xf1, 0x00, 0x00, 0x05, 0x89, 0x11, 861 0x0f, 0x13, 0xf1, 0x00, 0x00, 0x05, 0x89, 0x11,
862 0x49, 0x15, 0xf3, 0x00, 0x00, 0x01, 0x89, 0x13, 862 0x49, 0x15, 0xf3, 0x00, 0x00, 0x01, 0x89, 0x13,
863 0x49, 0x15, 0xf3, 0x00, 0x00, 0x07, 0x89, 0x12, 863 0x49, 0x15, 0xf3, 0x00, 0x00, 0x07, 0x89, 0x12,
864 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10, 864 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
865 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13, 865 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
866 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10, 866 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
867 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13, 867 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
868 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10, 868 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
869 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13, 869 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
870 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10, 870 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
871 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13, 871 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
872 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10, 872 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x10,
873 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13, 873 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x80, 0x0f, 0x13,
874 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x11, 874 0x11, 0x93, 0x1d, 0x91, 0x19, 0x92, 0x89, 0x11,
875 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 0x0f, 0x13, 875 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0x81, 0x0f, 0x13,
876 0x6d, 0x94, 0x6d, 0xed, 0x00, 0x0d, 0x48, 0x14, 876 0x6d, 0x94, 0x6d, 0xed, 0x00, 0x0d, 0x48, 0x14,
877 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 877 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16,
878 0x4a, 0x17, 0xee, 0xf8, 0x88, 0x17, 0x10, 0x0d, 878 0x4a, 0x17, 0xee, 0xf8, 0x88, 0x17, 0x10, 0x0d,
879 0x80, 0x04, 0x10, 0x0c, 0x80, 0x05, 0x71, 0x0e, 879 0x80, 0x04, 0x10, 0x0c, 0x80, 0x05, 0x71, 0x0e,
880 0x00, 0x16, 0x73, 0x17, 0x00, 0x0e, 0xf0, 0x66, 880 0x00, 0x16, 0x73, 0x17, 0x00, 0x0e, 0xf0, 0x66,
881 0x00, 0x0d, 0xf0, 0x00, 0x24, 0x00, 0x88, 0x11, 881 0x00, 0x0d, 0xf0, 0x00, 0x24, 0x00, 0x88, 0x11,
882 0x10, 0xf8, 0x27, 0x63, 0xf8, 0x45, 0x0f, 0x32, 882 0x10, 0xf8, 0x27, 0x63, 0xf8, 0x45, 0x0f, 0x32,
883 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17, 883 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17,
884 0x10, 0xf8, 0x27, 0x60, 0xf8, 0x44, 0x0f, 0x3d, 884 0x10, 0xf8, 0x27, 0x60, 0xf8, 0x44, 0x0f, 0x3d,
885 0x60, 0xe1, 0x00, 0x02, 0x00, 0x01, 0xf8, 0x20, 885 0x60, 0xe1, 0x00, 0x02, 0x00, 0x01, 0xf8, 0x20,
886 0x0f, 0x6d, 0xf0, 0x73, 0x11, 0x33, 0x10, 0x04, 886 0x0f, 0x6d, 0xf0, 0x73, 0x11, 0x33, 0x10, 0x04,
887 0x80, 0x00, 0x10, 0x05, 0xf0, 0x74, 0x06, 0x9f, 887 0x80, 0x00, 0x10, 0x05, 0xf0, 0x74, 0x06, 0x9f,
888 0x11, 0x04, 0xf3, 0x00, 0x00, 0x01, 0x81, 0x04, 888 0x11, 0x04, 0xf3, 0x00, 0x00, 0x01, 0x81, 0x04,
889 0x6d, 0x8e, 0x77, 0x10, 0x00, 0x01, 0x71, 0xe1, 889 0x6d, 0x8e, 0x77, 0x10, 0x00, 0x01, 0x71, 0xe1,
890 0x00, 0x02, 0x00, 0x12, 0xf4, 0xaa, 0xf8, 0x30, 890 0x00, 0x02, 0x00, 0x12, 0xf4, 0xaa, 0xf8, 0x30,
891 0x0f, 0x62, 0x77, 0x10, 0x00, 0x02, 0xf4, 0xaa, 891 0x0f, 0x62, 0x77, 0x10, 0x00, 0x02, 0xf4, 0xaa,
892 0xf8, 0x30, 0x0f, 0x6d, 0x45, 0xe1, 0x00, 0x0b, 892 0xf8, 0x30, 0x0f, 0x6d, 0x45, 0xe1, 0x00, 0x0b,
893 0x88, 0x10, 0x43, 0xe1, 0x00, 0x0c, 0x83, 0xf8, 893 0x88, 0x10, 0x43, 0xe1, 0x00, 0x0c, 0x83, 0xf8,
894 0x00, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xaa, 894 0x00, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xaa,
895 0xf8, 0x30, 0x0f, 0x6d, 0xf0, 0x73, 0x0f, 0x96, 895 0xf8, 0x30, 0x0f, 0x6d, 0xf0, 0x73, 0x0f, 0x96,
896 0xf5, 0x00, 0x81, 0x04, 0x49, 0x16, 0xf5, 0x20, 896 0xf5, 0x00, 0x81, 0x04, 0x49, 0x16, 0xf5, 0x20,
897 0x89, 0x16, 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x00, 897 0x89, 0x16, 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x00,
898 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x48, 0x16, 898 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x48, 0x16,
899 0xf8, 0x45, 0x11, 0x33, 0xf7, 0xb8, 0x71, 0xe1, 899 0xf8, 0x45, 0x11, 0x33, 0xf7, 0xb8, 0x71, 0xe1,
900 0x00, 0x02, 0x00, 0x12, 0x10, 0xf8, 0x00, 0x12, 900 0x00, 0x02, 0x00, 0x12, 0x10, 0xf8, 0x00, 0x12,
901 0xf0, 0x10, 0x00, 0x03, 0xf8, 0x46, 0x0f, 0x8c, 901 0xf0, 0x10, 0x00, 0x03, 0xf8, 0x46, 0x0f, 0x8c,
902 0x10, 0xf8, 0x00, 0x12, 0xf0, 0x10, 0x00, 0x03, 902 0x10, 0xf8, 0x00, 0x12, 0xf0, 0x10, 0x00, 0x03,
903 0xf8, 0x45, 0x10, 0x16, 0x77, 0x10, 0x00, 0x01, 903 0xf8, 0x45, 0x10, 0x16, 0x77, 0x10, 0x00, 0x01,
904 0xf4, 0xaa, 0xf8, 0x30, 0x0f, 0x9c, 0x77, 0x10, 904 0xf4, 0xaa, 0xf8, 0x30, 0x0f, 0x9c, 0x77, 0x10,
905 0x00, 0x02, 0xf4, 0xaa, 0xf8, 0x30, 0x0f, 0xa8, 905 0x00, 0x02, 0xf4, 0xaa, 0xf8, 0x30, 0x0f, 0xa8,
906 0xf0, 0x73, 0x0f, 0x96, 0x77, 0x10, 0x00, 0x04, 906 0xf0, 0x73, 0x0f, 0x96, 0x77, 0x10, 0x00, 0x04,
907 0xf4, 0xaa, 0xf8, 0x30, 0x10, 0xb7, 0x77, 0x10, 907 0xf4, 0xaa, 0xf8, 0x30, 0x10, 0xb7, 0x77, 0x10,
908 0x00, 0x05, 0xf4, 0xaa, 0xf8, 0x30, 0x10, 0xbc, 908 0x00, 0x05, 0xf4, 0xaa, 0xf8, 0x30, 0x10, 0xbc,
909 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17, 909 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17,
910 0xf0, 0x73, 0x11, 0x31, 0x76, 0xe1, 0x00, 0x0c, 910 0xf0, 0x73, 0x11, 0x31, 0x76, 0xe1, 0x00, 0x0c,
911 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x00, 911 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x00,
912 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1, 912 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1,
913 0x00, 0x02, 0x00, 0x02, 0x11, 0xe1, 0x00, 0x0c, 913 0x00, 0x02, 0x00, 0x02, 0x11, 0xe1, 0x00, 0x0c,
914 0xe8, 0x03, 0xf6, 0x20, 0x89, 0x12, 0xf4, 0x95, 914 0xe8, 0x03, 0xf6, 0x20, 0x89, 0x12, 0xf4, 0x95,
915 0x77, 0x10, 0x00, 0x03, 0xf5, 0xaa, 0xf8, 0x30, 915 0x77, 0x10, 0x00, 0x03, 0xf5, 0xaa, 0xf8, 0x30,
916 0x0f, 0xb6, 0x6b, 0xf8, 0x27, 0x6f, 0x00, 0x01, 916 0x0f, 0xb6, 0x6b, 0xf8, 0x27, 0x6f, 0x00, 0x01,
917 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 0xf5, 0xae, 917 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 0xf5, 0xae,
918 0xf8, 0x20, 0x0f, 0xbd, 0x48, 0x16, 0x80, 0x06, 918 0xf8, 0x20, 0x0f, 0xbd, 0x48, 0x16, 0x80, 0x06,
919 0x88, 0x13, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x03, 919 0x88, 0x13, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x03,
920 0xf6, 0xab, 0xf8, 0x20, 0x0f, 0xc8, 0x6b, 0xf8, 920 0xf6, 0xab, 0xf8, 0x20, 0x0f, 0xc8, 0x6b, 0xf8,
921 0x27, 0x6f, 0x00, 0x01, 0x12, 0x06, 0xf8, 0x45, 921 0x27, 0x6f, 0x00, 0x01, 0x12, 0x06, 0xf8, 0x45,
922 0x10, 0x00, 0x10, 0xe1, 0x00, 0x04, 0x80, 0x00, 922 0x10, 0x00, 0x10, 0xe1, 0x00, 0x04, 0x80, 0x00,
923 0x10, 0x05, 0x80, 0x01, 0x10, 0x04, 0x80, 0x02, 923 0x10, 0x05, 0x80, 0x01, 0x10, 0x04, 0x80, 0x02,
924 0x10, 0x06, 0x80, 0x03, 0x48, 0x11, 0xf2, 0x74, 924 0x10, 0x06, 0x80, 0x03, 0x48, 0x11, 0xf2, 0x74,
925 0x07, 0x1e, 0xf0, 0x00, 0x00, 0x05, 0x10, 0x06, 925 0x07, 0x1e, 0xf0, 0x00, 0x00, 0x05, 0x10, 0x06,
926 0x00, 0xe1, 0x00, 0x04, 0x80, 0xe1, 0x00, 0x04, 926 0x00, 0xe1, 0x00, 0x04, 0x80, 0xe1, 0x00, 0x04,
927 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1, 927 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1,
928 0x00, 0x0c, 0x88, 0x12, 0x11, 0x06, 0x10, 0x04, 928 0x00, 0x0c, 0x88, 0x12, 0x11, 0x06, 0x10, 0x04,
929 0xf6, 0x00, 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20, 929 0xf6, 0x00, 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20,
930 0x88, 0x16, 0x89, 0x13, 0xf4, 0x95, 0x77, 0x10, 930 0x88, 0x16, 0x89, 0x13, 0xf4, 0x95, 0x77, 0x10,
931 0x00, 0x03, 0xf6, 0xab, 0xf8, 0x20, 0x0f, 0xf5, 931 0x00, 0x03, 0xf6, 0xab, 0xf8, 0x20, 0x0f, 0xf5,
932 0x6b, 0xf8, 0x27, 0x6f, 0x00, 0x01, 0x77, 0x10, 932 0x6b, 0xf8, 0x27, 0x6f, 0x00, 0x01, 0x77, 0x10,
933 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x13, 933 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x13,
934 0xf6, 0xab, 0xf8, 0x20, 0x10, 0x00, 0x6b, 0xf8, 934 0xf6, 0xab, 0xf8, 0x20, 0x10, 0x00, 0x6b, 0xf8,
935 0x27, 0x6f, 0x00, 0x01, 0x6c, 0xe2, 0xff, 0xfd, 935 0x27, 0x6f, 0x00, 0x01, 0x6c, 0xe2, 0xff, 0xfd,
936 0x11, 0x31, 0xf6, 0xb8, 0x6f, 0xe1, 0x00, 0x05, 936 0x11, 0x31, 0xf6, 0xb8, 0x6f, 0xe1, 0x00, 0x05,
937 0x0c, 0x48, 0x6f, 0xe1, 0x00, 0x06, 0x0c, 0x18, 937 0x0c, 0x48, 0x6f, 0xe1, 0x00, 0x06, 0x0c, 0x18,
938 0xf0, 0x30, 0x0f, 0xff, 0xf0, 0x00, 0x00, 0x03, 938 0xf0, 0x30, 0x0f, 0xff, 0xf0, 0x00, 0x00, 0x03,
939 0x80, 0xe1, 0x00, 0x0b, 0x76, 0xe1, 0x00, 0x02, 939 0x80, 0xe1, 0x00, 0x0b, 0x76, 0xe1, 0x00, 0x02,
940 0x00, 0x03, 0x48, 0x16, 0xf8, 0x45, 0x11, 0x33, 940 0x00, 0x03, 0x48, 0x16, 0xf8, 0x45, 0x11, 0x33,
941 0x71, 0xe1, 0x00, 0x0c, 0x00, 0x12, 0x10, 0xe1, 941 0x71, 0xe1, 0x00, 0x0c, 0x00, 0x12, 0x10, 0xe1,
942 0x00, 0x0b, 0x49, 0x12, 0xf6, 0x20, 0x88, 0x13, 942 0x00, 0x0b, 0x49, 0x12, 0xf6, 0x20, 0x88, 0x13,
943 0xe8, 0x0c, 0xf6, 0x20, 0x88, 0x10, 0xf4, 0x95, 943 0xe8, 0x0c, 0xf6, 0x20, 0x88, 0x10, 0xf4, 0x95,
944 0xf4, 0x95, 0xf5, 0xab, 0xf8, 0x20, 0x10, 0x27, 944 0xf4, 0x95, 0xf5, 0xab, 0xf8, 0x20, 0x10, 0x27,
945 0x48, 0x13, 0x80, 0x06, 0x88, 0x10, 0xf4, 0x95, 945 0x48, 0x13, 0x80, 0x06, 0x88, 0x10, 0xf4, 0x95,
946 0xf4, 0x95, 0xf5, 0xae, 0xf8, 0x20, 0x10, 0x30, 946 0xf4, 0x95, 0xf5, 0xae, 0xf8, 0x20, 0x10, 0x30,
947 0x70, 0x06, 0x00, 0x16, 0x12, 0x06, 0xf8, 0x45, 947 0x70, 0x06, 0x00, 0x16, 0x12, 0x06, 0xf8, 0x45,
948 0x10, 0x5f, 0x10, 0xe1, 0x00, 0x04, 0x80, 0x00, 948 0x10, 0x5f, 0x10, 0xe1, 0x00, 0x04, 0x80, 0x00,
949 0x10, 0x05, 0x80, 0x01, 0x10, 0x04, 0x80, 0x02, 949 0x10, 0x05, 0x80, 0x01, 0x10, 0x04, 0x80, 0x02,
950 0x10, 0x06, 0x80, 0x03, 0x48, 0x11, 0xf2, 0x74, 950 0x10, 0x06, 0x80, 0x03, 0x48, 0x11, 0xf2, 0x74,
951 0x07, 0x1e, 0xf0, 0x00, 0x00, 0x05, 0x10, 0x06, 951 0x07, 0x1e, 0xf0, 0x00, 0x00, 0x05, 0x10, 0x06,
952 0x00, 0xe1, 0x00, 0x04, 0x80, 0xe1, 0x00, 0x04, 952 0x00, 0xe1, 0x00, 0x04, 0x80, 0xe1, 0x00, 0x04,
953 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1, 953 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1,
954 0x00, 0x0c, 0x88, 0x12, 0x11, 0x06, 0x10, 0x04, 954 0x00, 0x0c, 0x88, 0x12, 0x11, 0x06, 0x10, 0x04,
955 0xf6, 0x00, 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20, 955 0xf6, 0x00, 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20,
956 0x88, 0x16, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x0c, 956 0x88, 0x16, 0xf4, 0x95, 0x77, 0x10, 0x00, 0x0c,
957 0x71, 0xe1, 0x00, 0x04, 0x00, 0x13, 0xf6, 0xab, 957 0x71, 0xe1, 0x00, 0x04, 0x00, 0x13, 0xf6, 0xab,
958 0xf8, 0x20, 0x10, 0x5f, 0x6b, 0xf8, 0x27, 0x6f, 958 0xf8, 0x20, 0x10, 0x5f, 0x6b, 0xf8, 0x27, 0x6f,
959 0x00, 0x01, 0x77, 0x10, 0x00, 0x0c, 0xf6, 0xaa, 959 0x00, 0x01, 0x77, 0x10, 0x00, 0x0c, 0xf6, 0xaa,
960 0xf8, 0x20, 0x10, 0x6b, 0xf2, 0x74, 0x0e, 0x9f, 960 0xf8, 0x20, 0x10, 0x6b, 0xf2, 0x74, 0x0e, 0x9f,
961 0xf4, 0x95, 0x48, 0x17, 0x71, 0xe1, 0x00, 0x0c, 961 0xf4, 0x95, 0x48, 0x17, 0x71, 0xe1, 0x00, 0x0c,
962 0x00, 0x12, 0x77, 0x10, 0x00, 0x0c, 0xf4, 0xaa, 962 0x00, 0x12, 0x77, 0x10, 0x00, 0x0c, 0xf4, 0xaa,
963 0xf8, 0x30, 0x10, 0x7c, 0x77, 0x10, 0x00, 0x0c, 963 0xf8, 0x30, 0x10, 0x7c, 0x77, 0x10, 0x00, 0x0c,
964 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x13, 0xf6, 0xab, 964 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x13, 0xf6, 0xab,
965 0xf8, 0x30, 0x10, 0xb4, 0xe7, 0x30, 0xf7, 0xaa, 965 0xf8, 0x30, 0x10, 0xb4, 0xe7, 0x30, 0xf7, 0xaa,
966 0xf8, 0x30, 0x10, 0xb4, 0xf2, 0x74, 0x0e, 0xc1, 966 0xf8, 0x30, 0x10, 0xb4, 0xf2, 0x74, 0x0e, 0xc1,
967 0xf4, 0x95, 0x48, 0x17, 0x88, 0x12, 0xf4, 0x95, 967 0xf4, 0x95, 0x48, 0x17, 0x88, 0x12, 0xf4, 0x95,
968 0xf4, 0x95, 0x6c, 0x82, 0x10, 0x8d, 0x76, 0xe1, 968 0xf4, 0x95, 0x6c, 0x82, 0x10, 0x8d, 0x76, 0xe1,
969 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02, 969 0x00, 0x04, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
970 0x00, 0x05, 0xf0, 0x73, 0x10, 0xb4, 0x76, 0xe1, 970 0x00, 0x05, 0xf0, 0x73, 0x10, 0xb4, 0x76, 0xe1,
971 0x00, 0x02, 0x00, 0x04, 0x77, 0x10, 0x00, 0x0c, 971 0x00, 0x02, 0x00, 0x04, 0x77, 0x10, 0x00, 0x0c,
972 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x12, 0xf5, 0xaa, 972 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x12, 0xf5, 0xaa,
973 0xf8, 0x20, 0x10, 0x9a, 0xf0, 0x73, 0x10, 0x9c, 973 0xf8, 0x20, 0x10, 0x9a, 0xf0, 0x73, 0x10, 0x9c,
974 0x77, 0x12, 0x00, 0x0c, 0x76, 0x00, 0x00, 0x00, 974 0x77, 0x12, 0x00, 0x0c, 0x76, 0x00, 0x00, 0x00,
975 0x70, 0x01, 0x00, 0x12, 0x70, 0x02, 0x00, 0x17, 975 0x70, 0x01, 0x00, 0x12, 0x70, 0x02, 0x00, 0x17,
976 0x76, 0x03, 0x00, 0x01, 0x48, 0x11, 0xf2, 0x74, 976 0x76, 0x03, 0x00, 0x01, 0x48, 0x11, 0xf2, 0x74,
977 0x0c, 0xb9, 0xf0, 0x00, 0x00, 0x05, 0x76, 0xe1, 977 0x0c, 0xb9, 0xf0, 0x00, 0x00, 0x05, 0x76, 0xe1,
978 0x00, 0x04, 0x00, 0x00, 0x77, 0x10, 0x00, 0x0c, 978 0x00, 0x04, 0x00, 0x00, 0x77, 0x10, 0x00, 0x0c,
979 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x12, 0xf6, 0xaa, 979 0x71, 0xe1, 0x00, 0x0b, 0x00, 0x12, 0xf6, 0xaa,
980 0xf8, 0x20, 0x11, 0x1c, 0x48, 0x16, 0xf8, 0x45, 980 0xf8, 0x20, 0x11, 0x1c, 0x48, 0x16, 0xf8, 0x45,
981 0x11, 0x33, 0x60, 0xe1, 0x00, 0x02, 0x00, 0x05, 981 0x11, 0x33, 0x60, 0xe1, 0x00, 0x02, 0x00, 0x05,
982 0xf8, 0x20, 0x10, 0xdf, 0x10, 0xe1, 0x00, 0x0b, 982 0xf8, 0x20, 0x10, 0xdf, 0x10, 0xe1, 0x00, 0x0b,
983 0x08, 0xe1, 0x00, 0x0c, 0x11, 0xe1, 0x00, 0x04, 983 0x08, 0xe1, 0x00, 0x0c, 0x11, 0xe1, 0x00, 0x04,
984 0xf8, 0x4d, 0x10, 0xc7, 0x6b, 0xf8, 0x27, 0x6f, 984 0xf8, 0x4d, 0x10, 0xc7, 0x6b, 0xf8, 0x27, 0x6f,
985 0x00, 0x01, 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95, 985 0x00, 0x01, 0x88, 0x10, 0xf4, 0x95, 0xf4, 0x95,
986 0xf5, 0xae, 0xf8, 0x20, 0x10, 0xcf, 0x48, 0x16, 986 0xf5, 0xae, 0xf8, 0x20, 0x10, 0xcf, 0x48, 0x16,
987 0xf4, 0x95, 0x48, 0x08, 0xf8, 0x45, 0x11, 0x16, 987 0xf4, 0x95, 0x48, 0x08, 0xf8, 0x45, 0x11, 0x16,
988 0x6f, 0xe1, 0x00, 0x0c, 0x0d, 0x00, 0x81, 0xe1, 988 0x6f, 0xe1, 0x00, 0x0c, 0x0d, 0x00, 0x81, 0xe1,
989 0x00, 0x0c, 0x11, 0x04, 0xf5, 0x00, 0x81, 0x04, 989 0x00, 0x0c, 0x11, 0x04, 0xf5, 0x00, 0x81, 0x04,
990 0x49, 0x16, 0xf5, 0x20, 0x89, 0x16, 0xf0, 0x73, 990 0x49, 0x16, 0xf5, 0x20, 0x89, 0x16, 0xf0, 0x73,
991 0x11, 0x0e, 0x10, 0xe1, 0x00, 0x0b, 0x71, 0xe1, 991 0x11, 0x0e, 0x10, 0xe1, 0x00, 0x0b, 0x71, 0xe1,
992 0x00, 0x0c, 0x00, 0x12, 0x88, 0x10, 0xf4, 0x95, 992 0x00, 0x0c, 0x00, 0x12, 0x88, 0x10, 0xf4, 0x95,
993 0xf4, 0x95, 0xf6, 0xaa, 0xf8, 0x30, 0x11, 0x16, 993 0xf4, 0x95, 0xf6, 0xaa, 0xf8, 0x30, 0x11, 0x16,
994 0x49, 0x12, 0xf6, 0x20, 0x88, 0x10, 0xf4, 0x95, 994 0x49, 0x12, 0xf6, 0x20, 0x88, 0x10, 0xf4, 0x95,
995 0xf4, 0x95, 0xf5, 0xae, 0xf8, 0x20, 0x10, 0xf3, 995 0xf4, 0x95, 0xf5, 0xae, 0xf8, 0x20, 0x10, 0xf3,
996 0x48, 0x16, 0x80, 0x06, 0x48, 0x08, 0xf8, 0x45, 996 0x48, 0x16, 0x80, 0x06, 0x48, 0x08, 0xf8, 0x45,
997 0x11, 0x16, 0x10, 0x04, 0x70, 0x02, 0x00, 0x17, 997 0x11, 0x16, 0x10, 0x04, 0x70, 0x02, 0x00, 0x17,
998 0x80, 0x00, 0x76, 0x03, 0x00, 0x00, 0x10, 0x06, 998 0x80, 0x00, 0x76, 0x03, 0x00, 0x00, 0x10, 0x06,
999 0x80, 0x01, 0x10, 0x05, 0xf0, 0x74, 0x0c, 0xb9, 999 0x80, 0x01, 0x10, 0x05, 0xf0, 0x74, 0x0c, 0xb9,
1000 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1, 1000 0x10, 0x06, 0x00, 0xe1, 0x00, 0x0c, 0x80, 0xe1,
1001 0x00, 0x0c, 0x11, 0x06, 0x10, 0x04, 0xf6, 0x00, 1001 0x00, 0x0c, 0x11, 0x06, 0x10, 0x04, 0xf6, 0x00,
1002 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20, 0x88, 0x16, 1002 0x80, 0x04, 0x48, 0x16, 0xf6, 0x20, 0x88, 0x16,
1003 0x10, 0xe1, 0x00, 0x0c, 0x08, 0xe1, 0x00, 0x0b, 1003 0x10, 0xe1, 0x00, 0x0c, 0x08, 0xe1, 0x00, 0x0b,
1004 0xf8, 0x45, 0x11, 0x1c, 0xf0, 0x73, 0x11, 0x31, 1004 0xf8, 0x45, 0x11, 0x1c, 0xf0, 0x73, 0x11, 0x31,
1005 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17, 1005 0xf2, 0x74, 0x0e, 0x9f, 0xf4, 0x95, 0x48, 0x17,
1006 0xf0, 0x73, 0x11, 0x33, 0x76, 0xe1, 0x00, 0x0c, 1006 0xf0, 0x73, 0x11, 0x33, 0x76, 0xe1, 0x00, 0x0c,
1007 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x00, 1007 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x00,
1008 0x76, 0xe1, 0x00, 0x02, 0x00, 0x01, 0x10, 0x04, 1008 0x76, 0xe1, 0x00, 0x02, 0x00, 0x01, 0x10, 0x04,
1009 0x80, 0x00, 0x10, 0x05, 0xf0, 0x74, 0x06, 0x9f, 1009 0x80, 0x00, 0x10, 0x05, 0xf0, 0x74, 0x06, 0x9f,
1010 0x88, 0x12, 0xf4, 0x95, 0x77, 0x10, 0x00, 0xff, 1010 0x88, 0x12, 0xf4, 0x95, 0x77, 0x10, 0x00, 0xff,
1011 0xf4, 0xaa, 0xf8, 0x30, 0x11, 0x33, 0x6c, 0x86, 1011 0xf4, 0xaa, 0xf8, 0x30, 0x11, 0x33, 0x6c, 0x86,
1012 0x0f, 0x70, 0xee, 0x08, 0x8a, 0x17, 0x8a, 0x16, 1012 0x0f, 0x70, 0xee, 0x08, 0x8a, 0x17, 0x8a, 0x16,
1013 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfc, 1013 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfc,
1014 0xf4, 0x95, 0x71, 0x06, 0x00, 0x12, 0x88, 0x11, 1014 0xf4, 0x95, 0x71, 0x06, 0x00, 0x12, 0x88, 0x11,
1015 0x73, 0x12, 0x00, 0x0e, 0xf1, 0x66, 0x00, 0x0d, 1015 0x73, 0x12, 0x00, 0x0e, 0xf1, 0x66, 0x00, 0x0d,
1016 0xf3, 0x00, 0x24, 0x00, 0x89, 0x14, 0x13, 0x81, 1016 0xf3, 0x00, 0x24, 0x00, 0x89, 0x14, 0x13, 0x81,
1017 0xf7, 0x7a, 0xf3, 0x30, 0x00, 0x01, 0x81, 0xf8, 1017 0xf7, 0x7a, 0xf3, 0x30, 0x00, 0x01, 0x81, 0xf8,
1018 0x27, 0x60, 0x13, 0xe1, 0x00, 0x01, 0xf7, 0x7c, 1018 0x27, 0x60, 0x13, 0xe1, 0x00, 0x01, 0xf7, 0x7c,
1019 0xf3, 0x30, 0x00, 0x03, 0x81, 0xf8, 0x27, 0x61, 1019 0xf3, 0x30, 0x00, 0x03, 0x81, 0xf8, 0x27, 0x61,
1020 0xe9, 0x0f, 0x19, 0xe1, 0x00, 0x01, 0x81, 0xf8, 1020 0xe9, 0x0f, 0x19, 0xe1, 0x00, 0x01, 0x81, 0xf8,
1021 0x27, 0x62, 0x71, 0xe4, 0x00, 0x03, 0x00, 0x13, 1021 0x27, 0x62, 0x71, 0xe4, 0x00, 0x03, 0x00, 0x13,
1022 0xf6, 0xb8, 0x49, 0x13, 0xf3, 0x00, 0x00, 0x01, 1022 0xf6, 0xb8, 0x49, 0x13, 0xf3, 0x00, 0x00, 0x01,
1023 0xf3, 0x30, 0x00, 0x0f, 0x49, 0x0b, 0x09, 0xf8, 1023 0xf3, 0x30, 0x00, 0x0f, 0x49, 0x0b, 0x09, 0xf8,
1024 0x27, 0x62, 0xf8, 0x4d, 0x11, 0x75, 0x77, 0x10, 1024 0x27, 0x62, 0xf8, 0x4d, 0x11, 0x75, 0x77, 0x10,
1025 0x00, 0xff, 0xf4, 0xab, 0xf8, 0x30, 0x11, 0x75, 1025 0x00, 0xff, 0xf4, 0xab, 0xf8, 0x30, 0x11, 0x75,
1026 0x57, 0xf8, 0x27, 0x6c, 0xf3, 0x00, 0x00, 0x01, 1026 0x57, 0xf8, 0x27, 0x6c, 0xf3, 0x00, 0x00, 0x01,
1027 0x4f, 0xf8, 0x27, 0x6c, 0x76, 0xf8, 0x27, 0x63, 1027 0x4f, 0xf8, 0x27, 0x6c, 0x76, 0xf8, 0x27, 0x63,
1028 0x00, 0x01, 0xf0, 0x73, 0x11, 0x78, 0x76, 0xf8, 1028 0x00, 0x01, 0xf0, 0x73, 0x11, 0x78, 0x76, 0xf8,
1029 0x27, 0x63, 0x00, 0x00, 0x70, 0xe4, 0x00, 0x03, 1029 0x27, 0x63, 0x00, 0x00, 0x70, 0xe4, 0x00, 0x03,
1030 0x27, 0x62, 0x76, 0xf8, 0x27, 0x64, 0x00, 0x00, 1030 0x27, 0x62, 0x76, 0xf8, 0x27, 0x64, 0x00, 0x00,
1031 0x11, 0xf8, 0x27, 0x61, 0x61, 0xf8, 0x00, 0x0b, 1031 0x11, 0xf8, 0x27, 0x61, 0x61, 0xf8, 0x00, 0x0b,
1032 0x00, 0x02, 0xf8, 0x20, 0x11, 0x8d, 0xe9, 0x01, 1032 0x00, 0x02, 0xf8, 0x20, 0x11, 0x8d, 0xe9, 0x01,
1033 0x6f, 0xe1, 0x00, 0x02, 0x0f, 0x18, 0x81, 0xf8, 1033 0x6f, 0xe1, 0x00, 0x02, 0x0f, 0x18, 0x81, 0xf8,
1034 0x27, 0x64, 0x11, 0xf8, 0x27, 0x61, 0x61, 0xf8, 1034 0x27, 0x64, 0x11, 0xf8, 0x27, 0x61, 0x61, 0xf8,
1035 0x00, 0x0b, 0x00, 0x01, 0xf8, 0x20, 0x11, 0xa9, 1035 0x00, 0x0b, 0x00, 0x01, 0xf8, 0x20, 0x11, 0xa9,
1036 0x10, 0xf8, 0x27, 0x64, 0xf1, 0x00, 0x00, 0x04, 1036 0x10, 0xf8, 0x27, 0x64, 0xf1, 0x00, 0x00, 0x04,
1037 0x89, 0x13, 0xe9, 0xb8, 0xf5, 0x20, 0x81, 0xf8, 1037 0x89, 0x13, 0xe9, 0xb8, 0xf5, 0x20, 0x81, 0xf8,
1038 0x27, 0x65, 0x60, 0x84, 0x00, 0x02, 0xf8, 0x20, 1038 0x27, 0x65, 0x60, 0x84, 0x00, 0x02, 0xf8, 0x20,
1039 0x11, 0xa9, 0x70, 0x00, 0x00, 0x11, 0x70, 0x01, 1039 0x11, 0xa9, 0x70, 0x00, 0x00, 0x11, 0x70, 0x01,
1040 0x00, 0x13, 0x70, 0x02, 0x27, 0x65, 0xf2, 0x74, 1040 0x00, 0x13, 0x70, 0x02, 0x27, 0x65, 0xf2, 0x74,
1041 0x0f, 0x18, 0xf4, 0x95, 0x48, 0x12, 0xee, 0x04, 1041 0x0f, 0x18, 0xf4, 0x95, 0x48, 0x12, 0xee, 0x04,
1042 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 1042 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16,
1043 0x4a, 0x17, 0xee, 0xfc, 0xe8, 0x00, 0x4e, 0xf8, 1043 0x4a, 0x17, 0xee, 0xfc, 0xe8, 0x00, 0x4e, 0xf8,
1044 0x27, 0x66, 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x68, 1044 0x27, 0x66, 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x68,
1045 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x6c, 0xe8, 0x00, 1045 0xe8, 0x00, 0x4e, 0xf8, 0x27, 0x6c, 0xe8, 0x00,
1046 0x4e, 0xf8, 0x27, 0x6a, 0x77, 0x12, 0x27, 0x40, 1046 0x4e, 0xf8, 0x27, 0x6a, 0x77, 0x12, 0x27, 0x40,
1047 0x77, 0x11, 0x24, 0x00, 0x77, 0x1a, 0x00, 0x1f, 1047 0x77, 0x11, 0x24, 0x00, 0x77, 0x1a, 0x00, 0x1f,
1048 0xf0, 0x72, 0x11, 0xdb, 0x70, 0x92, 0x00, 0x11, 1048 0xf0, 0x72, 0x11, 0xdb, 0x70, 0x92, 0x00, 0x11,
1049 0x76, 0xe1, 0x00, 0x01, 0xff, 0xff, 0x76, 0x81, 1049 0x76, 0xe1, 0x00, 0x01, 0xff, 0xff, 0x76, 0x81,
1050 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02, 0x00, 0x00, 1050 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02, 0x00, 0x00,
1051 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff, 0x76, 0xe1, 1051 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff, 0x76, 0xe1,
1052 0x00, 0x0c, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 1052 0x00, 0x0c, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b,
1053 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 1053 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00,
1054 0x6d, 0xe9, 0x00, 0x0d, 0xf0, 0x20, 0x25, 0xa0, 1054 0x6d, 0xe9, 0x00, 0x0d, 0xf0, 0x20, 0x25, 0xa0,
1055 0xf1, 0x00, 0x00, 0x07, 0x89, 0x11, 0xf1, 0x00, 1055 0xf1, 0x00, 0x00, 0x07, 0x89, 0x11, 0xf1, 0x00,
1056 0x00, 0x01, 0x81, 0x02, 0x88, 0x16, 0xf4, 0x95, 1056 0x00, 0x01, 0x81, 0x02, 0x88, 0x16, 0xf4, 0x95,
1057 0x77, 0x17, 0x00, 0x20, 0x76, 0x86, 0x00, 0xff, 1057 0x77, 0x17, 0x00, 0x20, 0x76, 0x86, 0x00, 0xff,
1058 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 1058 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0x06,
1059 0x10, 0x02, 0xf0, 0x74, 0x06, 0x6c, 0x76, 0x00, 1059 0x10, 0x02, 0xf0, 0x74, 0x06, 0x6c, 0x76, 0x00,
1060 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0xf2, 0x74, 1060 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0xf2, 0x74,
1061 0x06, 0x6c, 0xf4, 0x95, 0x48, 0x11, 0x10, 0x02, 1061 0x06, 0x6c, 0xf4, 0x95, 0x48, 0x11, 0x10, 0x02,
1062 0xf0, 0x00, 0x00, 0x0d, 0x80, 0x02, 0x6d, 0xe9, 1062 0xf0, 0x00, 0x00, 0x0d, 0x80, 0x02, 0x6d, 0xe9,
1063 0x00, 0x0d, 0x6d, 0xee, 0x00, 0x0d, 0x6c, 0xef, 1063 0x00, 0x0d, 0x6d, 0xee, 0x00, 0x0d, 0x6c, 0xef,
1064 0xff, 0xff, 0x11, 0xe8, 0xf0, 0x74, 0x0c, 0x9d, 1064 0xff, 0xff, 0x11, 0xe8, 0xf0, 0x74, 0x0c, 0x9d,
1065 0xee, 0x04, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 1065 0xee, 0x04, 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11,
1066 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 1066 0xfc, 0x00, 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17,
1067 0xee, 0xfa, 0x88, 0x11, 0x10, 0x0a, 0x49, 0x11, 1067 0xee, 0xfa, 0x88, 0x11, 0x10, 0x0a, 0x49, 0x11,
1068 0xf8, 0x4d, 0x12, 0x9f, 0x48, 0x08, 0xf8, 0x45, 1068 0xf8, 0x4d, 0x12, 0x9f, 0x48, 0x08, 0xf8, 0x45,
1069 0x12, 0x9f, 0x80, 0x04, 0x12, 0x81, 0xf5, 0x78, 1069 0x12, 0x9f, 0x80, 0x04, 0x12, 0x81, 0xf5, 0x78,
1070 0x89, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0xe2, 1070 0x89, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x6c, 0xe2,
1071 0xff, 0xb9, 0x12, 0x8a, 0x61, 0xf8, 0x00, 0x08, 1071 0xff, 0xb9, 0x12, 0x8a, 0x61, 0xf8, 0x00, 0x08,
1072 0x00, 0x80, 0xf8, 0x30, 0x12, 0x8a, 0x13, 0xe1, 1072 0x00, 0x80, 0xf8, 0x30, 0x12, 0x8a, 0x13, 0xe1,
1073 0x00, 0x01, 0xf0, 0xe8, 0xf7, 0x78, 0xf1, 0xa0, 1073 0x00, 0x01, 0xf0, 0xe8, 0xf7, 0x78, 0xf1, 0xa0,
1074 0xf2, 0x30, 0x1f, 0xff, 0x88, 0x17, 0xf4, 0x95, 1074 0xf2, 0x30, 0x1f, 0xff, 0x88, 0x17, 0xf4, 0x95,
1075 0x77, 0x12, 0x24, 0x00, 0x77, 0x16, 0x00, 0x00, 1075 0x77, 0x12, 0x24, 0x00, 0x77, 0x16, 0x00, 0x00,
1076 0x77, 0x13, 0x00, 0x20, 0xf6, 0xb8, 0x48, 0x17, 1076 0x77, 0x13, 0x00, 0x20, 0xf6, 0xb8, 0x48, 0x17,
1077 0x08, 0xe2, 0x00, 0x01, 0xf8, 0x45, 0x12, 0x42, 1077 0x08, 0xe2, 0x00, 0x01, 0xf8, 0x45, 0x12, 0x42,
1078 0x6d, 0xea, 0x00, 0x0d, 0x6d, 0x96, 0x6c, 0xeb, 1078 0x6d, 0xea, 0x00, 0x0d, 0x6d, 0x96, 0x6c, 0xeb,
1079 0xff, 0xff, 0x12, 0x34, 0xf0, 0x73, 0x12, 0x90, 1079 0xff, 0xff, 0x12, 0x34, 0xf0, 0x73, 0x12, 0x90,
1080 0x56, 0xf8, 0x27, 0x6a, 0xf0, 0x00, 0x00, 0x01, 1080 0x56, 0xf8, 0x27, 0x6a, 0xf0, 0x00, 0x00, 0x01,
1081 0x4e, 0xf8, 0x27, 0x6a, 0x60, 0x82, 0x00, 0x01, 1081 0x4e, 0xf8, 0x27, 0x6a, 0x60, 0x82, 0x00, 0x01,
1082 0xf8, 0x30, 0x12, 0x54, 0x70, 0x00, 0x00, 0x16, 1082 0xf8, 0x30, 0x12, 0x54, 0x70, 0x00, 0x00, 0x16,
1083 0xf2, 0x74, 0x11, 0x38, 0xf4, 0x95, 0x48, 0x11, 1083 0xf2, 0x74, 0x11, 0x38, 0xf4, 0x95, 0x48, 0x11,
1084 0xf0, 0x73, 0x12, 0x90, 0x70, 0x00, 0x00, 0x16, 1084 0xf0, 0x73, 0x12, 0x90, 0x70, 0x00, 0x00, 0x16,
1085 0xf2, 0x74, 0x11, 0x38, 0xf4, 0x95, 0x48, 0x11, 1085 0xf2, 0x74, 0x11, 0x38, 0xf4, 0x95, 0x48, 0x11,
1086 0x72, 0x10, 0x2a, 0x9e, 0xf4, 0x95, 0xf4, 0xaf, 1086 0x72, 0x10, 0x2a, 0x9e, 0xf4, 0x95, 0xf4, 0xaf,
1087 0xf8, 0x30, 0x12, 0x6e, 0x76, 0x00, 0x00, 0x00, 1087 0xf8, 0x30, 0x12, 0x6e, 0x76, 0x00, 0x00, 0x00,
1088 0x76, 0x01, 0x00, 0xbc, 0x70, 0x02, 0x00, 0x16, 1088 0x76, 0x01, 0x00, 0xbc, 0x70, 0x02, 0x00, 0x16,
1089 0x76, 0x03, 0x00, 0x00, 0xf2, 0x74, 0x0c, 0xb9, 1089 0x76, 0x03, 0x00, 0x00, 0xf2, 0x74, 0x0c, 0xb9,
1090 0xf4, 0x95, 0x48, 0x11, 0xf0, 0x73, 0x12, 0x90, 1090 0xf4, 0x95, 0x48, 0x11, 0xf0, 0x73, 0x12, 0x90,
1091 0x10, 0xf8, 0x27, 0x6e, 0xf8, 0x44, 0x12, 0x90, 1091 0x10, 0xf8, 0x27, 0x6e, 0xf8, 0x44, 0x12, 0x90,
1092 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0xbc, 1092 0x76, 0x00, 0x00, 0x00, 0x76, 0x01, 0x00, 0xbc,
1093 0x70, 0x02, 0x00, 0x16, 0x76, 0x03, 0x00, 0x00, 1093 0x70, 0x02, 0x00, 0x16, 0x76, 0x03, 0x00, 0x00,
1094 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95, 0x48, 0x11, 1094 0xf2, 0x74, 0x0c, 0xb9, 0xf4, 0x95, 0x48, 0x11,
1095 0xf0, 0x74, 0x0c, 0x5e, 0xf0, 0xe0, 0xf0, 0x10, 1095 0xf0, 0x74, 0x0c, 0x5e, 0xf0, 0xe0, 0xf0, 0x10,
1096 0x13, 0x88, 0xf8, 0x42, 0x12, 0x90, 0x76, 0xf8, 1096 0x13, 0x88, 0xf8, 0x42, 0x12, 0x90, 0x76, 0xf8,
1097 0x27, 0x6e, 0x00, 0x01, 0xf0, 0x73, 0x12, 0x90, 1097 0x27, 0x6e, 0x00, 0x01, 0xf0, 0x73, 0x12, 0x90,
1098 0x56, 0xf8, 0x27, 0x66, 0xf0, 0x00, 0x00, 0x01, 1098 0x56, 0xf8, 0x27, 0x66, 0xf0, 0x00, 0x00, 0x01,
1099 0x4e, 0xf8, 0x27, 0x66, 0x6d, 0xe9, 0x00, 0x5e, 1099 0x4e, 0xf8, 0x27, 0x66, 0x6d, 0xe9, 0x00, 0x5e,
1100 0x56, 0xf8, 0x27, 0x68, 0xf0, 0x00, 0x00, 0x01, 1100 0x56, 0xf8, 0x27, 0x68, 0xf0, 0x00, 0x00, 0x01,
1101 0x4e, 0xf8, 0x27, 0x68, 0x71, 0x04, 0x00, 0x12, 1101 0x4e, 0xf8, 0x27, 0x68, 0x71, 0x04, 0x00, 0x12,
1102 0x6e, 0xea, 0xff, 0xff, 0x12, 0x18, 0x70, 0x04, 1102 0x6e, 0xea, 0xff, 0xff, 0x12, 0x18, 0x70, 0x04,
1103 0x00, 0x12, 0xee, 0x06, 0x8a, 0x17, 0x8a, 0x16, 1103 0x00, 0x12, 0xee, 0x06, 0x8a, 0x17, 0x8a, 0x16,
1104 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe, 1104 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xee, 0xfe,
1105 0x88, 0x0e, 0xf4, 0x95, 0xf0, 0x66, 0x00, 0x0d, 1105 0x88, 0x0e, 0xf4, 0x95, 0xf0, 0x66, 0x00, 0x0d,
1106 0xf0, 0x00, 0x25, 0xa0, 0x88, 0x11, 0xf4, 0x95, 1106 0xf0, 0x00, 0x25, 0xa0, 0x88, 0x11, 0xf4, 0x95,
1107 0xf4, 0x95, 0x76, 0x81, 0x00, 0xff, 0x76, 0x00, 1107 0xf4, 0x95, 0x76, 0x81, 0x00, 0xff, 0x76, 0x00,
1108 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0xf2, 0x74, 1108 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0xf2, 0x74,
1109 0x06, 0x6c, 0xf0, 0x00, 0x00, 0x01, 0x76, 0x00, 1109 0x06, 0x6c, 0xf0, 0x00, 0x00, 0x01, 0x76, 0x00,
1110 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0x48, 0x11, 1110 0x00, 0x00, 0x76, 0x01, 0x00, 0x06, 0x48, 0x11,
1111 0xf2, 0x74, 0x06, 0x6c, 0xf0, 0x00, 0x00, 0x07, 1111 0xf2, 0x74, 0x06, 0x6c, 0xf0, 0x00, 0x00, 0x07,
1112 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 1112 0xee, 0x02, 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11,
1113 0x88, 0x0e, 0xf4, 0x95, 0xf0, 0x66, 0x00, 0x0d, 1113 0x88, 0x0e, 0xf4, 0x95, 0xf0, 0x66, 0x00, 0x0d,
1114 0xf0, 0x00, 0x24, 0x00, 0x88, 0x11, 0xf4, 0x95, 1114 0xf0, 0x00, 0x24, 0x00, 0x88, 0x11, 0xf4, 0x95,
1115 0xf4, 0x95, 0x76, 0xe1, 0x00, 0x01, 0xff, 0xff, 1115 0xf4, 0x95, 0x76, 0xe1, 0x00, 0x01, 0xff, 0xff,
1116 0x76, 0x81, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02, 1116 0x76, 0x81, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
1117 0x00, 0x00, 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff, 1117 0x00, 0x00, 0x76, 0xe1, 0x00, 0x03, 0x00, 0xff,
1118 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95, 1118 0x8a, 0x11, 0xfc, 0x00, 0x4a, 0x11, 0xf4, 0x95,
1119 0x13, 0x03, 0x88, 0x11, 0xfa, 0x4d, 0x12, 0xec, 1119 0x13, 0x03, 0x88, 0x11, 0xfa, 0x4d, 0x12, 0xec,
1120 0x71, 0x02, 0x00, 0x12, 0xf3, 0x10, 0x00, 0x01, 1120 0x71, 0x02, 0x00, 0x12, 0xf3, 0x10, 0x00, 0x01,
1121 0x89, 0x1a, 0xf4, 0x95, 0xf0, 0x72, 0x12, 0xeb, 1121 0x89, 0x1a, 0xf4, 0x95, 0xf0, 0x72, 0x12, 0xeb,
1122 0x70, 0x91, 0x00, 0x12, 0x8a, 0x11, 0xfc, 0x00, 1122 0x70, 0x91, 0x00, 0x12, 0x8a, 0x11, 0xfc, 0x00,
1123 0xf4, 0x95, 0x4a, 0x0b, 0x4a, 0x0c, 0x4a, 0x0d, 1123 0xf4, 0x95, 0x4a, 0x0b, 0x4a, 0x0c, 0x4a, 0x0d,
1124 0xf7, 0xb8, 0xee, 0xfe, 0x10, 0xf8, 0x00, 0x08, 1124 0xf7, 0xb8, 0xee, 0xfe, 0x10, 0xf8, 0x00, 0x08,
1125 0x11, 0x06, 0xf1, 0xc0, 0x83, 0x00, 0xf4, 0x85, 1125 0x11, 0x06, 0xf1, 0xc0, 0x83, 0x00, 0xf4, 0x85,
1126 0x11, 0x06, 0xf7, 0x85, 0x81, 0x06, 0xf6, 0xb8, 1126 0x11, 0x06, 0xf7, 0x85, 0x81, 0x06, 0xf6, 0xb8,
1127 0xec, 0x0f, 0x1e, 0x06, 0x61, 0x00, 0x80, 0x00, 1127 0xec, 0x0f, 0x1e, 0x06, 0x61, 0x00, 0x80, 0x00,
1128 0xf8, 0x20, 0x13, 0x05, 0xf4, 0x84, 0xee, 0x02, 1128 0xf8, 0x20, 0x13, 0x05, 0xf4, 0x84, 0xee, 0x02,
1129 0x8a, 0x0d, 0x8a, 0x0c, 0x8a, 0x0b, 0xfc, 0x00, 1129 0x8a, 0x0d, 0x8a, 0x0c, 0x8a, 0x0b, 0xfc, 0x00,
1130 0xf4, 0x95, 0x4a, 0x0b, 0x4a, 0x0c, 0x4a, 0x0d, 1130 0xf4, 0x95, 0x4a, 0x0b, 0x4a, 0x0c, 0x4a, 0x0d,
1131 0xee, 0xfe, 0xf7, 0xb8, 0x80, 0x00, 0x10, 0xf8, 1131 0xee, 0xfe, 0xf7, 0xb8, 0x80, 0x00, 0x10, 0xf8,
1132 0x00, 0x08, 0xf4, 0x85, 0x11, 0x06, 0xf7, 0x85, 1132 0x00, 0x08, 0xf4, 0x85, 0x11, 0x06, 0xf7, 0x85,
1133 0x81, 0x06, 0xf6, 0xb8, 0xec, 0x0f, 0x1e, 0x06, 1133 0x81, 0x06, 0xf6, 0xb8, 0xec, 0x0f, 0x1e, 0x06,
1134 0xf0, 0xf0, 0x61, 0x00, 0x80, 0x00, 0xf8, 0x20, 1134 0xf0, 0xf0, 0x61, 0x00, 0x80, 0x00, 0xf8, 0x20,
1135 0x13, 0x20, 0xf4, 0x84, 0xee, 0x02, 0x8a, 0x0d, 1135 0x13, 0x20, 0xf4, 0x84, 0xee, 0x02, 0x8a, 0x0d,
1136 0x8a, 0x0c, 0x8a, 0x0b, 0xfc, 0x00, 0x4a, 0x11, 1136 0x8a, 0x0c, 0x8a, 0x0b, 0xfc, 0x00, 0x4a, 0x11,
1137 0x77, 0x11, 0x00, 0x7b, 0x76, 0x81, 0x2e, 0xec, 1137 0x77, 0x11, 0x00, 0x7b, 0x76, 0x81, 0x2e, 0xec,
1138 0x77, 0x11, 0x00, 0x7b, 0xee, 0xff, 0x71, 0x81, 1138 0x77, 0x11, 0x00, 0x7b, 0xee, 0xff, 0x71, 0x81,
1139 0x00, 0x11, 0xee, 0x01, 0x76, 0xe1, 0x00, 0x01, 1139 0x00, 0x11, 0xee, 0x01, 0x76, 0xe1, 0x00, 0x01,
1140 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00, 1140 0x00, 0x00, 0x76, 0xe1, 0x00, 0x04, 0x00, 0x00,
1141 0x76, 0xe1, 0x00, 0x06, 0x00, 0x00, 0x76, 0xe1, 1141 0x76, 0xe1, 0x00, 0x06, 0x00, 0x00, 0x76, 0xe1,
1142 0x00, 0x62, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x76, 1142 0x00, 0x62, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x76,
1143 0x00, 0x00, 0x76, 0xe1, 0x00, 0x92, 0x00, 0x00, 1143 0x00, 0x00, 0x76, 0xe1, 0x00, 0x92, 0x00, 0x00,
1144 0x76, 0xe1, 0x00, 0x94, 0x00, 0x00, 0x76, 0xe1, 1144 0x76, 0xe1, 0x00, 0x94, 0x00, 0x00, 0x76, 0xe1,
1145 0x00, 0xb0, 0x00, 0x00, 0x76, 0xe1, 0x00, 0xb3, 1145 0x00, 0xb0, 0x00, 0x00, 0x76, 0xe1, 0x00, 0xb3,
1146 0x00, 0x00, 0x76, 0xe1, 0x00, 0xbe, 0x00, 0x00, 1146 0x00, 0x00, 0x76, 0xe1, 0x00, 0xbe, 0x00, 0x00,
1147 0x76, 0xe1, 0x00, 0xbf, 0x00, 0x00, 0x76, 0xe1, 1147 0x76, 0xe1, 0x00, 0xbf, 0x00, 0x00, 0x76, 0xe1,
1148 0x00, 0xc1, 0x00, 0x00, 0x76, 0xe1, 0x00, 0xc3, 1148 0x00, 0xc1, 0x00, 0x00, 0x76, 0xe1, 0x00, 0xc3,
1149 0x00, 0x00, 0x76, 0xe1, 0x00, 0xc5, 0x00, 0x00, 1149 0x00, 0x00, 0x76, 0xe1, 0x00, 0xc5, 0x00, 0x00,
1150 0x76, 0xe1, 0x00, 0xc7, 0x00, 0x00, 0x76, 0x81, 1150 0x76, 0xe1, 0x00, 0xc7, 0x00, 0x00, 0x76, 0x81,
1151 0x00, 0x00, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4, 1151 0x00, 0x00, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
1152 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xff, 1152 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xff,
1153 0xf4, 0x95, 0x71, 0x06, 0x00, 0x16, 0xfb, 0x80, 1153 0xf4, 0x95, 0x71, 0x06, 0x00, 0x16, 0xfb, 0x80,
1154 0x16, 0xa2, 0x88, 0x17, 0xf4, 0x95, 0xf7, 0xb8, 1154 0x16, 0xa2, 0x88, 0x17, 0xf4, 0x95, 0xf7, 0xb8,
1155 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x02, 1155 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x02,
1156 0xfa, 0x46, 0x13, 0x88, 0x77, 0x11, 0x00, 0x00, 1156 0xfa, 0x46, 0x13, 0x88, 0x77, 0x11, 0x00, 0x00,
1157 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x02, 1157 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x02,
1158 0xf8, 0x45, 0x13, 0xf9, 0x10, 0xf8, 0x00, 0x17, 1158 0xf8, 0x45, 0x13, 0xf9, 0x10, 0xf8, 0x00, 0x17,
1159 0xf8, 0x45, 0x14, 0x39, 0x10, 0xf8, 0x00, 0x17, 1159 0xf8, 0x45, 0x14, 0x39, 0x10, 0xf8, 0x00, 0x17,
1160 0xf0, 0x10, 0x00, 0x01, 0xf8, 0x45, 0x14, 0x1f, 1160 0xf0, 0x10, 0x00, 0x01, 0xf8, 0x45, 0x14, 0x1f,
1161 0xf0, 0x73, 0x14, 0x52, 0x10, 0xf8, 0x00, 0x17, 1161 0xf0, 0x73, 0x14, 0x52, 0x10, 0xf8, 0x00, 0x17,
1162 0xf0, 0x10, 0x00, 0x03, 0xf8, 0x45, 0x13, 0xd3, 1162 0xf0, 0x10, 0x00, 0x03, 0xf8, 0x45, 0x13, 0xd3,
1163 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x06, 1163 0x10, 0xf8, 0x00, 0x17, 0xf0, 0x10, 0x00, 0x06,
1164 0xf8, 0x44, 0x14, 0x52, 0x77, 0x12, 0x00, 0x7b, 1164 0xf8, 0x44, 0x14, 0x52, 0x77, 0x12, 0x00, 0x7b,
1165 0x71, 0x82, 0x00, 0x14, 0x61, 0xe4, 0x00, 0x07, 1165 0x71, 0x82, 0x00, 0x14, 0x61, 0xe4, 0x00, 0x07,
1166 0x00, 0x40, 0xf8, 0x30, 0x14, 0x52, 0x49, 0x14, 1166 0x00, 0x40, 0xf8, 0x30, 0x14, 0x52, 0x49, 0x14,
1167 0x48, 0x17, 0xf6, 0x00, 0x88, 0x12, 0xf4, 0x95, 1167 0x48, 0x17, 0xf6, 0x00, 0x88, 0x12, 0xf4, 0x95,
1168 0x77, 0x13, 0x00, 0x55, 0x77, 0x11, 0x00, 0x57, 1168 0x77, 0x13, 0x00, 0x55, 0x77, 0x11, 0x00, 0x57,
1169 0x6d, 0xea, 0x00, 0x3b, 0xe5, 0x01, 0x10, 0xe6, 1169 0x6d, 0xea, 0x00, 0x3b, 0xe5, 0x01, 0x10, 0xe6,
1170 0x00, 0x06, 0x80, 0x81, 0x48, 0x14, 0x00, 0xf8, 1170 0x00, 0x06, 0x80, 0x81, 0x48, 0x14, 0x00, 0xf8,
1171 0x00, 0x17, 0x88, 0x12, 0xf4, 0x95, 0x77, 0x11, 1171 0x00, 0x17, 0x88, 0x12, 0xf4, 0x95, 0x77, 0x11,
1172 0x00, 0x55, 0x10, 0xe2, 0x00, 0x40, 0x80, 0x81, 1172 0x00, 0x55, 0x10, 0xe2, 0x00, 0x40, 0x80, 0x81,
1173 0x77, 0x11, 0x00, 0x57, 0x10, 0xe6, 0x00, 0x07, 1173 0x77, 0x11, 0x00, 0x57, 0x10, 0xe6, 0x00, 0x07,
1174 0x80, 0x81, 0x77, 0x11, 0x00, 0x55, 0x10, 0xe2, 1174 0x80, 0x81, 0x77, 0x11, 0x00, 0x55, 0x10, 0xe2,
1175 0x00, 0x45, 0x80, 0x81, 0x10, 0xe6, 0x00, 0x08, 1175 0x00, 0x45, 0x80, 0x81, 0x10, 0xe6, 0x00, 0x08,
1176 0x77, 0x11, 0x00, 0x57, 0x80, 0x81, 0x77, 0x11, 1176 0x77, 0x11, 0x00, 0x57, 0x80, 0x81, 0x77, 0x11,
1177 0x00, 0x55, 0x10, 0xe2, 0x00, 0x4a, 0x80, 0x81, 1177 0x00, 0x55, 0x10, 0xe2, 0x00, 0x4a, 0x80, 0x81,
1178 0x77, 0x11, 0x00, 0x57, 0x10, 0xe6, 0x00, 0x09, 1178 0x77, 0x11, 0x00, 0x57, 0x10, 0xe6, 0x00, 0x09,
1179 0x80, 0x81, 0xf2, 0x73, 0x14, 0x52, 0x77, 0x11, 1179 0x80, 0x81, 0xf2, 0x73, 0x14, 0x52, 0x77, 0x11,
1180 0x03, 0xc0, 0x77, 0x12, 0x00, 0x7b, 0x10, 0x82, 1180 0x03, 0xc0, 0x77, 0x12, 0x00, 0x7b, 0x10, 0x82,
1181 0xf0, 0x00, 0x00, 0x07, 0x88, 0x13, 0xf4, 0x95, 1181 0xf0, 0x00, 0x00, 0x07, 0x88, 0x13, 0xf4, 0x95,
1182 0xf4, 0x95, 0x96, 0x1b, 0xf8, 0x30, 0x14, 0x52, 1182 0xf4, 0x95, 0x96, 0x1b, 0xf8, 0x30, 0x14, 0x52,
1183 0x10, 0xe3, 0x00, 0x35, 0x77, 0x12, 0x00, 0x55, 1183 0x10, 0xe3, 0x00, 0x35, 0x77, 0x12, 0x00, 0x55,
1184 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6, 1184 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6,
1185 0x00, 0x04, 0x80, 0x82, 0x77, 0x12, 0x00, 0x55, 1185 0x00, 0x04, 0x80, 0x82, 0x77, 0x12, 0x00, 0x55,
1186 0x10, 0xe3, 0x00, 0x37, 0x80, 0x82, 0x77, 0x12, 1186 0x10, 0xe3, 0x00, 0x37, 0x80, 0x82, 0x77, 0x12,
1187 0x00, 0x57, 0x10, 0xe6, 0x00, 0x05, 0x80, 0x82, 1187 0x00, 0x57, 0x10, 0xe6, 0x00, 0x05, 0x80, 0x82,
1188 0x48, 0x11, 0xf0, 0x40, 0x00, 0x10, 0xf2, 0x73, 1188 0x48, 0x11, 0xf0, 0x40, 0x00, 0x10, 0xf2, 0x73,
1189 0x14, 0x50, 0xf0, 0x40, 0x00, 0x20, 0x77, 0x12, 1189 0x14, 0x50, 0xf0, 0x40, 0x00, 0x20, 0x77, 0x12,
1190 0x00, 0x7b, 0x10, 0x82, 0xf0, 0x00, 0x00, 0x07, 1190 0x00, 0x7b, 0x10, 0x82, 0xf0, 0x00, 0x00, 0x07,
1191 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x96, 0x0d, 1191 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x96, 0x0d,
1192 0xf8, 0x30, 0x14, 0x52, 0x10, 0xe2, 0x00, 0x34, 1192 0xf8, 0x30, 0x14, 0x52, 0x10, 0xe2, 0x00, 0x34,
1193 0x77, 0x13, 0x00, 0x55, 0x80, 0x83, 0x77, 0x13, 1193 0x77, 0x13, 0x00, 0x55, 0x80, 0x83, 0x77, 0x13,
1194 0x00, 0x57, 0x10, 0xe6, 0x00, 0x02, 0x80, 0x83, 1194 0x00, 0x57, 0x10, 0xe6, 0x00, 0x02, 0x80, 0x83,
1195 0x10, 0xe2, 0x00, 0x36, 0x77, 0x12, 0x00, 0x55, 1195 0x10, 0xe2, 0x00, 0x36, 0x77, 0x12, 0x00, 0x55,
1196 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6, 1196 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6,
1197 0x00, 0x03, 0x80, 0x82, 0x48, 0x11, 0xf0, 0x40, 1197 0x00, 0x03, 0x80, 0x82, 0x48, 0x11, 0xf0, 0x40,
1198 0x00, 0x04, 0xf2, 0x73, 0x14, 0x50, 0xf0, 0x40, 1198 0x00, 0x04, 0xf2, 0x73, 0x14, 0x50, 0xf0, 0x40,
1199 0x00, 0x08, 0x77, 0x12, 0x00, 0x7b, 0x10, 0x82, 1199 0x00, 0x08, 0x77, 0x12, 0x00, 0x7b, 0x10, 0x82,
1200 0xf0, 0x00, 0x00, 0x07, 0x88, 0x12, 0xf4, 0x95, 1200 0xf0, 0x00, 0x00, 0x07, 0x88, 0x12, 0xf4, 0x95,
1201 0xf4, 0x95, 0x96, 0x0e, 0xf8, 0x30, 0x14, 0x52, 1201 0xf4, 0x95, 0x96, 0x0e, 0xf8, 0x30, 0x14, 0x52,
1202 0x10, 0xe2, 0x00, 0x33, 0x77, 0x12, 0x00, 0x55, 1202 0x10, 0xe2, 0x00, 0x33, 0x77, 0x12, 0x00, 0x55,
1203 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6, 1203 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0x10, 0xe6,
1204 0x00, 0x01, 0x80, 0x82, 0x48, 0x11, 0xf2, 0x73, 1204 0x00, 0x01, 0x80, 0x82, 0x48, 0x11, 0xf2, 0x73,
1205 0x14, 0x50, 0xf0, 0x40, 0x00, 0x02, 0x77, 0x12, 1205 0x14, 0x50, 0xf0, 0x40, 0x00, 0x02, 0x77, 0x12,
1206 0x00, 0x7b, 0x10, 0x82, 0xf0, 0x00, 0x00, 0x07, 1206 0x00, 0x7b, 0x10, 0x82, 0xf0, 0x00, 0x00, 0x07,
1207 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x96, 0x0f, 1207 0x88, 0x12, 0xf4, 0x95, 0xf4, 0x95, 0x96, 0x0f,
1208 0xf8, 0x30, 0x14, 0x52, 0x10, 0xe2, 0x00, 0x32, 1208 0xf8, 0x30, 0x14, 0x52, 0x10, 0xe2, 0x00, 0x32,
1209 0x77, 0x12, 0x00, 0x55, 0x77, 0x13, 0x00, 0x57, 1209 0x77, 0x12, 0x00, 0x55, 0x77, 0x13, 0x00, 0x57,
1210 0x80, 0x82, 0x48, 0x11, 0xe7, 0x62, 0xf0, 0x40, 1210 0x80, 0x82, 0x48, 0x11, 0xe7, 0x62, 0xf0, 0x40,
1211 0x00, 0x01, 0xe5, 0x01, 0x88, 0x11, 0xf4, 0x95, 1211 0x00, 0x01, 0xe5, 0x01, 0x88, 0x11, 0xf4, 0x95,
1212 0x77, 0x12, 0x00, 0x7b, 0x48, 0x11, 0x71, 0x82, 1212 0x77, 0x12, 0x00, 0x7b, 0x48, 0x11, 0x71, 0x82,
1213 0x00, 0x12, 0x1a, 0xe2, 0x00, 0x07, 0x80, 0xe2, 1213 0x00, 0x12, 0x1a, 0xe2, 0x00, 0x07, 0x80, 0xe2,
1214 0x00, 0x07, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 1214 0x00, 0x07, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01,
1215 0x8a, 0x17, 0x48, 0x11, 0x8a, 0x16, 0x8a, 0x11, 1215 0x8a, 0x17, 0x48, 0x11, 0x8a, 0x16, 0x8a, 0x11,
1216 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0x77, 0x0e, 1216 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0x77, 0x0e,
1217 0x00, 0x05, 0x77, 0x12, 0x00, 0x55, 0xe8, 0x04, 1217 0x00, 0x05, 0x77, 0x12, 0x00, 0x55, 0xe8, 0x04,
1218 0xf6, 0xb8, 0x28, 0xe1, 0x00, 0x02, 0xee, 0xff, 1218 0xf6, 0xb8, 0x28, 0xe1, 0x00, 0x02, 0xee, 0xff,
1219 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0xf0, 0x20, 1219 0x80, 0x82, 0x77, 0x12, 0x00, 0x57, 0xf0, 0x20,
1220 0x80, 0x00, 0xee, 0x01, 0x1a, 0x82, 0x77, 0x12, 1220 0x80, 0x00, 0xee, 0x01, 0x1a, 0x82, 0x77, 0x12,
1221 0x00, 0x57, 0x80, 0x82, 0xe8, 0x01, 0x32, 0xe1, 1221 0x00, 0x57, 0x80, 0x82, 0xe8, 0x01, 0x32, 0xe1,
1222 0x00, 0x02, 0xf5, 0x82, 0x77, 0x11, 0x00, 0x54, 1222 0x00, 0x02, 0xf5, 0x82, 0x77, 0x11, 0x00, 0x54,
1223 0xf6, 0x93, 0x18, 0x81, 0x77, 0x11, 0x00, 0x54, 1223 0xf6, 0x93, 0x18, 0x81, 0x77, 0x11, 0x00, 0x54,
1224 0xf2, 0xa0, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 1224 0xf2, 0xa0, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95,
1225 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95, 1225 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95,
1226 0x71, 0x04, 0x00, 0x11, 0xfb, 0x80, 0x16, 0xa2, 1226 0x71, 0x04, 0x00, 0x11, 0xfb, 0x80, 0x16, 0xa2,
1227 0x88, 0x16, 0xf4, 0x95, 0x77, 0x12, 0x00, 0x55, 1227 0x88, 0x16, 0xf4, 0x95, 0x77, 0x12, 0x00, 0x55,
1228 0x10, 0xe6, 0x00, 0x03, 0x80, 0x82, 0x77, 0x12, 1228 0x10, 0xe6, 0x00, 0x03, 0x80, 0x82, 0x77, 0x12,
1229 0x00, 0x56, 0x10, 0xe1, 0x00, 0x02, 0x77, 0x13, 1229 0x00, 0x56, 0x10, 0xe1, 0x00, 0x02, 0x77, 0x13,
1230 0x00, 0x56, 0x80, 0x82, 0x77, 0x12, 0x00, 0x56, 1230 0x00, 0x56, 0x80, 0x82, 0x77, 0x12, 0x00, 0x56,
1231 0x10, 0xe1, 0x00, 0x03, 0x80, 0x82, 0x10, 0xe1, 1231 0x10, 0xe1, 0x00, 0x03, 0x80, 0x82, 0x10, 0xe1,
1232 0x00, 0x04, 0x77, 0x12, 0x00, 0x56, 0x80, 0x82, 1232 0x00, 0x04, 0x77, 0x12, 0x00, 0x56, 0x80, 0x82,
1233 0x77, 0x12, 0x00, 0x56, 0x10, 0xe1, 0x00, 0x01, 1233 0x77, 0x12, 0x00, 0x56, 0x10, 0xe1, 0x00, 0x01,
1234 0x80, 0x82, 0xe7, 0x12, 0xe5, 0x01, 0xf9, 0x80, 1234 0x80, 0x82, 0xe7, 0x12, 0xe5, 0x01, 0xf9, 0x80,
1235 0x16, 0x9a, 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4, 1235 0x16, 0x9a, 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4,
1236 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xf9, 1236 0x4a, 0x11, 0x4a, 0x16, 0x4a, 0x17, 0xee, 0xf9,
1237 0x77, 0x11, 0x00, 0x7b, 0x76, 0x00, 0x00, 0x16, 1237 0x77, 0x11, 0x00, 0x7b, 0x76, 0x00, 0x00, 0x16,
1238 0x76, 0x01, 0x00, 0x17, 0x76, 0x02, 0x00, 0x1a, 1238 0x76, 0x01, 0x00, 0x17, 0x76, 0x02, 0x00, 0x1a,
1239 0x76, 0x03, 0x00, 0x1b, 0x76, 0x04, 0x00, 0x1c, 1239 0x76, 0x03, 0x00, 0x1b, 0x76, 0x04, 0x00, 0x1c,
1240 0x76, 0x05, 0x00, 0x1d, 0x71, 0x81, 0x00, 0x17, 1240 0x76, 0x05, 0x00, 0x1d, 0x71, 0x81, 0x00, 0x17,
1241 0x71, 0xe7, 0x00, 0x06, 0x00, 0x11, 0x10, 0x81, 1241 0x71, 0xe7, 0x00, 0x06, 0x00, 0x11, 0x10, 0x81,
1242 0xf8, 0x44, 0x14, 0xdf, 0xf9, 0x80, 0x16, 0x53, 1242 0xf8, 0x44, 0x14, 0xdf, 0xf9, 0x80, 0x16, 0x53,
1243 0xf6, 0xb8, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x20, 1243 0xf6, 0xb8, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x20,
1244 0xff, 0xff, 0xf6, 0xb8, 0xfb, 0x80, 0x16, 0x08, 1244 0xff, 0xff, 0xf6, 0xb8, 0xfb, 0x80, 0x16, 0x08,
1245 0xf0, 0x20, 0xff, 0xff, 0x77, 0x11, 0x00, 0x7b, 1245 0xf0, 0x20, 0xff, 0xff, 0x77, 0x11, 0x00, 0x7b,
1246 0x71, 0x81, 0x00, 0x17, 0x76, 0xe7, 0x00, 0x06, 1246 0x71, 0x81, 0x00, 0x17, 0x76, 0xe7, 0x00, 0x06,
1247 0x00, 0x01, 0x48, 0x17, 0x77, 0x16, 0x00, 0x00, 1247 0x00, 0x01, 0x48, 0x17, 0x77, 0x16, 0x00, 0x00,
1248 0x77, 0x10, 0x00, 0x04, 0x77, 0x15, 0x00, 0x03, 1248 0x77, 0x10, 0x00, 0x04, 0x77, 0x15, 0x00, 0x03,
1249 0x77, 0x14, 0x00, 0x02, 0x77, 0x13, 0x00, 0x01, 1249 0x77, 0x14, 0x00, 0x02, 0x77, 0x13, 0x00, 0x01,
1250 0xf0, 0x00, 0x00, 0x39, 0x76, 0xe7, 0x00, 0x08, 1250 0xf0, 0x00, 0x00, 0x39, 0x76, 0xe7, 0x00, 0x08,
1251 0x00, 0x1f, 0x76, 0xe7, 0x00, 0x07, 0x00, 0x00, 1251 0x00, 0x1f, 0x76, 0xe7, 0x00, 0x07, 0x00, 0x00,
1252 0x88, 0x0e, 0x77, 0x1a, 0x00, 0x05, 0x48, 0x17, 1252 0x88, 0x0e, 0x77, 0x1a, 0x00, 0x05, 0x48, 0x17,
1253 0xf0, 0x00, 0x00, 0x09, 0x88, 0x12, 0x48, 0x18, 1253 0xf0, 0x00, 0x00, 0x09, 0x88, 0x12, 0x48, 0x18,
1254 0x88, 0x19, 0xe8, 0x00, 0xf0, 0x72, 0x15, 0x2c, 1254 0x88, 0x19, 0xe8, 0x00, 0xf0, 0x72, 0x15, 0x2c,
1255 0x73, 0x19, 0x00, 0x11, 0x76, 0x82, 0x00, 0x00, 1255 0x73, 0x19, 0x00, 0x11, 0x76, 0x82, 0x00, 0x00,
1256 0x11, 0x91, 0x73, 0x11, 0x00, 0x19, 0x70, 0xe2, 1256 0x11, 0x91, 0x73, 0x11, 0x00, 0x19, 0x70, 0xe2,
1257 0x00, 0x03, 0x00, 0x16, 0x70, 0xe2, 0x00, 0x04, 1257 0x00, 0x03, 0x00, 0x16, 0x70, 0xe2, 0x00, 0x04,
1258 0x00, 0x13, 0x70, 0xe2, 0x00, 0x05, 0x00, 0x14, 1258 0x00, 0x13, 0x70, 0xe2, 0x00, 0x05, 0x00, 0x14,
1259 0x81, 0xe2, 0x00, 0x01, 0x70, 0xe2, 0x00, 0x06, 1259 0x81, 0xe2, 0x00, 0x01, 0x70, 0xe2, 0x00, 0x06,
1260 0x00, 0x15, 0x70, 0xe2, 0x00, 0x07, 0x00, 0x10, 1260 0x00, 0x15, 0x70, 0xe2, 0x00, 0x07, 0x00, 0x10,
1261 0x80, 0xe2, 0x00, 0x02, 0x73, 0x0e, 0x00, 0x11, 1261 0x80, 0xe2, 0x00, 0x02, 0x73, 0x0e, 0x00, 0x11,
1262 0xf1, 0x00, 0x00, 0x1e, 0x6d, 0xee, 0x00, 0x05, 1262 0xf1, 0x00, 0x00, 0x1e, 0x6d, 0xee, 0x00, 0x05,
1263 0x6d, 0xeb, 0x00, 0x05, 0x6d, 0xec, 0x00, 0x05, 1263 0x6d, 0xeb, 0x00, 0x05, 0x6d, 0xec, 0x00, 0x05,
1264 0x6d, 0xed, 0x00, 0x05, 0x6d, 0xe8, 0x00, 0x05, 1264 0x6d, 0xed, 0x00, 0x05, 0x6d, 0xe8, 0x00, 0x05,
1265 0xf0, 0x00, 0x00, 0x01, 0x81, 0x91, 0x6d, 0xea, 1265 0xf0, 0x00, 0x00, 0x01, 0x81, 0x91, 0x6d, 0xea,
1266 0x00, 0x08, 0x73, 0x11, 0x00, 0x0e, 0xee, 0x07, 1266 0x00, 0x08, 0x73, 0x11, 0x00, 0x0e, 0xee, 0x07,
1267 0x76, 0xe7, 0x00, 0x41, 0x00, 0x24, 0x76, 0xe7, 1267 0x76, 0xe7, 0x00, 0x41, 0x00, 0x24, 0x76, 0xe7,
1268 0x00, 0x46, 0x00, 0x25, 0x76, 0xe7, 0x00, 0x4b, 1268 0x00, 0x46, 0x00, 0x25, 0x76, 0xe7, 0x00, 0x4b,
1269 0x00, 0x26, 0x76, 0xe7, 0x00, 0x50, 0x00, 0x27, 1269 0x00, 0x26, 0x76, 0xe7, 0x00, 0x50, 0x00, 0x27,
1270 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4, 1270 0x8a, 0x17, 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4,
1271 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xfe, 0x88, 0x11, 1271 0x4a, 0x11, 0x4a, 0x16, 0xee, 0xfe, 0x88, 0x11,
1272 0x56, 0x06, 0x4e, 0x00, 0xf9, 0x80, 0x16, 0xa2, 1272 0x56, 0x06, 0x4e, 0x00, 0xf9, 0x80, 0x16, 0xa2,
1273 0xf7, 0xb8, 0x10, 0xf8, 0x00, 0x11, 0xf0, 0x10, 1273 0xf7, 0xb8, 0x10, 0xf8, 0x00, 0x11, 0xf0, 0x10,
1274 0xff, 0xff, 0xfa, 0x45, 0x15, 0x60, 0x77, 0x16, 1274 0xff, 0xff, 0xfa, 0x45, 0x15, 0x60, 0x77, 0x16,
1275 0xff, 0xff, 0x77, 0x12, 0x00, 0x7b, 0x49, 0x11, 1275 0xff, 0xff, 0x77, 0x12, 0x00, 0x7b, 0x49, 0x11,
1276 0x10, 0x82, 0xf6, 0x03, 0xf0, 0x00, 0x00, 0x09, 1276 0x10, 0x82, 0xf6, 0x03, 0xf0, 0x00, 0x00, 0x09,
1277 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 1277 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81,
1278 0xf8, 0x44, 0x15, 0x71, 0xf2, 0x73, 0x15, 0x71, 1278 0xf8, 0x44, 0x15, 0x71, 0xf2, 0x73, 0x15, 0x71,
1279 0xf4, 0x95, 0xe7, 0x16, 0x77, 0x11, 0x00, 0x7b, 1279 0xf4, 0x95, 0xe7, 0x16, 0x77, 0x11, 0x00, 0x7b,
1280 0x10, 0x81, 0xf0, 0x00, 0x00, 0x09, 0x88, 0x11, 1280 0x10, 0x81, 0xf0, 0x00, 0x00, 0x09, 0x88, 0x11,
1281 0xf4, 0x95, 0x77, 0x12, 0x00, 0x06, 0x10, 0x81, 1281 0xf4, 0x95, 0x77, 0x12, 0x00, 0x06, 0x10, 0x81,
1282 0xf8, 0x45, 0x15, 0x5c, 0x6e, 0xea, 0xff, 0xff, 1282 0xf8, 0x45, 0x15, 0x5c, 0x6e, 0xea, 0xff, 0xff,
1283 0x15, 0x69, 0x6d, 0xe9, 0x00, 0x08, 0x76, 0x86, 1283 0x15, 0x69, 0x6d, 0xe9, 0x00, 0x08, 0x76, 0x86,
1284 0x00, 0x01, 0xe9, 0x01, 0x56, 0x00, 0xf1, 0x80, 1284 0x00, 0x01, 0xe9, 0x01, 0x56, 0x00, 0xf1, 0x80,
1285 0x10, 0xf8, 0x00, 0x0b, 0xf8, 0x45, 0x15, 0x7e, 1285 0x10, 0xf8, 0x00, 0x0b, 0xf8, 0x45, 0x15, 0x7e,
1286 0xfb, 0x80, 0x15, 0x85, 0xf4, 0x95, 0x48, 0x16, 1286 0xfb, 0x80, 0x15, 0x85, 0xf4, 0x95, 0x48, 0x16,
1287 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x02, 0x48, 0x16, 1287 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x02, 0x48, 0x16,
1288 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11, 1288 0x8a, 0x16, 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11,
1289 0xee, 0xff, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 1289 0xee, 0xff, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11,
1290 0xf4, 0x95, 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9, 1290 0xf4, 0x95, 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9,
1291 0xf8, 0x30, 0x15, 0xc4, 0x10, 0xe1, 0x00, 0x03, 1291 0xf8, 0x30, 0x15, 0xc4, 0x10, 0xe1, 0x00, 0x03,
1292 0x77, 0x12, 0x00, 0x55, 0x80, 0x82, 0x77, 0x12, 1292 0x77, 0x12, 0x00, 0x55, 0x80, 0x82, 0x77, 0x12,
1293 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12, 1293 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
1294 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12, 1294 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
1295 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12, 1295 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
1296 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12, 1296 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x77, 0x12,
1297 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1, 1297 0x00, 0x56, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1,
1298 0x00, 0x02, 0xf0, 0x00, 0x00, 0x08, 0x32, 0xf8, 1298 0x00, 0x02, 0xf0, 0x00, 0x00, 0x08, 0x32, 0xf8,
1299 0x00, 0x08, 0x77, 0x12, 0x00, 0x54, 0xe8, 0x01, 1299 0x00, 0x08, 0x77, 0x12, 0x00, 0x54, 0xe8, 0x01,
1300 0xf4, 0x82, 0xf4, 0x93, 0x18, 0x82, 0x77, 0x12, 1300 0xf4, 0x82, 0xf4, 0x93, 0x18, 0x82, 0x77, 0x12,
1301 0x00, 0x54, 0xf0, 0x40, 0x00, 0x00, 0x80, 0x82, 1301 0x00, 0x54, 0xf0, 0x40, 0x00, 0x00, 0x80, 0x82,
1302 0x10, 0xe1, 0x00, 0x01, 0xf9, 0x80, 0x16, 0x76, 1302 0x10, 0xe1, 0x00, 0x01, 0xf9, 0x80, 0x16, 0x76,
1303 0x10, 0xe1, 0x00, 0x01, 0xf9, 0x80, 0x16, 0x66, 1303 0x10, 0xe1, 0x00, 0x01, 0xf9, 0x80, 0x16, 0x66,
1304 0xf0, 0x73, 0x16, 0x03, 0x77, 0x11, 0x00, 0x7b, 1304 0xf0, 0x73, 0x16, 0x03, 0x77, 0x11, 0x00, 0x7b,
1305 0x71, 0x81, 0x00, 0x11, 0x71, 0xe1, 0x00, 0x07, 1305 0x71, 0x81, 0x00, 0x11, 0x71, 0xe1, 0x00, 0x07,
1306 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1, 1306 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1,
1307 0x00, 0x09, 0xf9, 0x80, 0x15, 0x85, 0x77, 0x11, 1307 0x00, 0x09, 0xf9, 0x80, 0x15, 0x85, 0x77, 0x11,
1308 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1, 1308 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1,
1309 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00, 1309 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00,
1310 0x00, 0x08, 0x77, 0x11, 0x00, 0x7b, 0x71, 0x81, 1310 0x00, 0x08, 0x77, 0x11, 0x00, 0x7b, 0x71, 0x81,
1311 0x00, 0x11, 0x10, 0xe1, 0x00, 0x09, 0xfb, 0x80, 1311 0x00, 0x11, 0x10, 0xe1, 0x00, 0x09, 0xfb, 0x80,
1312 0x15, 0x85, 0xf0, 0x00, 0x00, 0x10, 0x77, 0x11, 1312 0x15, 0x85, 0xf0, 0x00, 0x00, 0x10, 0x77, 0x11,
1313 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1, 1313 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1,
1314 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00, 1314 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00,
1315 0x00, 0x18, 0x77, 0x11, 0x00, 0x7b, 0x71, 0x81, 1315 0x00, 0x18, 0x77, 0x11, 0x00, 0x7b, 0x71, 0x81,
1316 0x00, 0x11, 0x10, 0xe1, 0x00, 0x09, 0xfb, 0x80, 1316 0x00, 0x11, 0x10, 0xe1, 0x00, 0x09, 0xfb, 0x80,
1317 0x15, 0x85, 0xf0, 0x00, 0x00, 0x20, 0x77, 0x11, 1317 0x15, 0x85, 0xf0, 0x00, 0x00, 0x20, 0x77, 0x11,
1318 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1, 1318 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x10, 0xe1,
1319 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00, 1319 0x00, 0x09, 0xfb, 0x80, 0x15, 0x85, 0xf0, 0x00,
1320 0x00, 0x28, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 1320 0x00, 0x28, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01,
1321 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff, 1321 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff,
1322 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95, 1322 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95,
1323 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30, 1323 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30,
1324 0x16, 0x41, 0x77, 0x11, 0x00, 0x55, 0x76, 0x81, 1324 0x16, 0x41, 0x77, 0x11, 0x00, 0x55, 0x76, 0x81,
1325 0x00, 0x1e, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1325 0x00, 0x1e, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1326 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1326 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1327 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1327 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1328 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1328 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1329 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1329 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1330 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1330 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1331 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1331 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1332 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1332 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1333 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81, 1333 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0x76, 0x81,
1334 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0xf2, 0x73, 1334 0x00, 0x00, 0x77, 0x11, 0x00, 0x56, 0xf2, 0x73,
1335 0x16, 0x4e, 0x76, 0x81, 0x00, 0x00, 0x77, 0x11, 1335 0x16, 0x4e, 0x76, 0x81, 0x00, 0x00, 0x77, 0x11,
1336 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x71, 0xe1, 1336 0x00, 0x7b, 0x71, 0x81, 0x00, 0x11, 0x71, 0xe1,
1337 0x00, 0x07, 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 1337 0x00, 0x07, 0x00, 0x12, 0x76, 0x82, 0x00, 0x00,
1338 0x10, 0xe1, 0x00, 0x39, 0xf9, 0x80, 0x16, 0x08, 1338 0x10, 0xe1, 0x00, 0x39, 0xf9, 0x80, 0x16, 0x08,
1339 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11, 1339 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11,
1340 0xf4, 0xe4, 0x4a, 0x11, 0x77, 0x11, 0x00, 0x7b, 1340 0xf4, 0xe4, 0x4a, 0x11, 0x77, 0x11, 0x00, 0x7b,
1341 0x10, 0x81, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x11, 1341 0x10, 0x81, 0xf0, 0x00, 0x00, 0x04, 0x88, 0x11,
1342 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xfa, 0x44, 1342 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xfa, 0x44,
1343 0x16, 0x63, 0xf4, 0x95, 0xee, 0xff, 0x76, 0x81, 1343 0x16, 0x63, 0xf4, 0x95, 0xee, 0xff, 0x76, 0x81,
1344 0x00, 0x01, 0xee, 0x01, 0x8a, 0x11, 0xf4, 0xe4, 1344 0x00, 0x01, 0xee, 0x01, 0x8a, 0x11, 0xf4, 0xe4,
1345 0xf0, 0x10, 0x00, 0x10, 0x4a, 0x11, 0x32, 0xf8, 1345 0xf0, 0x10, 0x00, 0x10, 0x4a, 0x11, 0x32, 0xf8,
1346 0x00, 0x08, 0xee, 0xff, 0x77, 0x11, 0x00, 0x01, 1346 0x00, 0x08, 0xee, 0xff, 0x77, 0x11, 0x00, 0x01,
1347 0xe8, 0x01, 0xee, 0x01, 0xf4, 0x82, 0x1a, 0x81, 1347 0xe8, 0x01, 0xee, 0x01, 0xf4, 0x82, 0x1a, 0x81,
1348 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4, 1348 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
1349 0xf0, 0x10, 0x00, 0x10, 0x4a, 0x11, 0x32, 0xf8, 1349 0xf0, 0x10, 0x00, 0x10, 0x4a, 0x11, 0x32, 0xf8,
1350 0x00, 0x08, 0xee, 0xff, 0xe8, 0x01, 0x77, 0x11, 1350 0x00, 0x08, 0xee, 0xff, 0xe8, 0x01, 0x77, 0x11,
1351 0x00, 0x00, 0xf4, 0x82, 0xee, 0x01, 0xf4, 0x93, 1351 0x00, 0x00, 0xf4, 0x82, 0xee, 0x01, 0xf4, 0x93,
1352 0x18, 0x81, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 1352 0x18, 0x81, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95,
1353 0xf4, 0xe4, 0x4a, 0x11, 0xf0, 0x10, 0x00, 0x10, 1353 0xf4, 0xe4, 0x4a, 0x11, 0xf0, 0x10, 0x00, 0x10,
1354 0x77, 0x11, 0x00, 0x00, 0x32, 0xf8, 0x00, 0x08, 1354 0x77, 0x11, 0x00, 0x00, 0x32, 0xf8, 0x00, 0x08,
1355 0xee, 0xff, 0x11, 0x81, 0xe8, 0x01, 0xee, 0x01, 1355 0xee, 0xff, 0x11, 0x81, 0xe8, 0x01, 0xee, 0x01,
1356 0x77, 0x11, 0x00, 0x00, 0xf4, 0x82, 0xf2, 0xa0, 1356 0x77, 0x11, 0x00, 0x00, 0xf4, 0x82, 0xf2, 0xa0,
1357 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4, 1357 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
1358 0xf2, 0x73, 0x16, 0x9e, 0xf6, 0xbb, 0xf4, 0x95, 1358 0xf2, 0x73, 0x16, 0x9e, 0xf6, 0xbb, 0xf4, 0x95,
1359 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xe4, 1359 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xe4,
1360 0xf2, 0x73, 0x16, 0xa6, 0xf7, 0xbb, 0xf4, 0x95, 1360 0xf2, 0x73, 0x16, 0xa6, 0xf7, 0xbb, 0xf4, 0x95,
1361 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xe4, 1361 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0x95, 0xf4, 0xe4,
1362 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95, 0x71, 0x04, 1362 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95, 0x71, 0x04,
1363 0x00, 0x16, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 1363 0x00, 0x16, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11,
1364 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1364 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1365 0x76, 0x82, 0x00, 0x0e, 0x10, 0xe6, 0x00, 0x0e, 1365 0x76, 0x82, 0x00, 0x0e, 0x10, 0xe6, 0x00, 0x0e,
1366 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 1366 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x80, 0x82,
1367 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 1367 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
1368 0x00, 0x0d, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 1368 0x00, 0x0d, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
1369 0x10, 0xe6, 0x00, 0x0d, 0x80, 0x82, 0x71, 0xe1, 1369 0x10, 0xe6, 0x00, 0x0d, 0x80, 0x82, 0x71, 0xe1,
1370 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0c, 1370 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0c,
1371 0x10, 0xe6, 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x06, 1371 0x10, 0xe6, 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x06,
1372 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 1372 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05,
1373 0x00, 0x12, 0x76, 0x82, 0x00, 0x0b, 0x10, 0xe6, 1373 0x00, 0x12, 0x76, 0x82, 0x00, 0x0b, 0x10, 0xe6,
1374 0x00, 0x0b, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 1374 0x00, 0x0b, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
1375 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1375 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1376 0x76, 0x82, 0x00, 0x0a, 0x71, 0xe1, 0x00, 0x06, 1376 0x76, 0x82, 0x00, 0x0a, 0x71, 0xe1, 0x00, 0x06,
1377 0x00, 0x12, 0x10, 0xe6, 0x00, 0x0a, 0x80, 0x82, 1377 0x00, 0x12, 0x10, 0xe6, 0x00, 0x0a, 0x80, 0x82,
1378 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 1378 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
1379 0x00, 0x09, 0x10, 0xe6, 0x00, 0x09, 0x71, 0xe1, 1379 0x00, 0x09, 0x10, 0xe6, 0x00, 0x09, 0x71, 0xe1,
1380 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1, 1380 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1,
1381 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x08, 1381 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x08,
1382 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6, 1382 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6,
1383 0x00, 0x08, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 1383 0x00, 0x08, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05,
1384 0x00, 0x12, 0x76, 0x82, 0x00, 0x07, 0x10, 0xe6, 1384 0x00, 0x12, 0x76, 0x82, 0x00, 0x07, 0x10, 0xe6,
1385 0x00, 0x07, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 1385 0x00, 0x07, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
1386 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1386 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1387 0x76, 0x82, 0x00, 0x06, 0x71, 0xe1, 0x00, 0x06, 1387 0x76, 0x82, 0x00, 0x06, 0x71, 0xe1, 0x00, 0x06,
1388 0x00, 0x12, 0x10, 0xe6, 0x00, 0x06, 0x80, 0x82, 1388 0x00, 0x12, 0x10, 0xe6, 0x00, 0x06, 0x80, 0x82,
1389 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 1389 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
1390 0x00, 0x05, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 1390 0x00, 0x05, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12,
1391 0x10, 0xe6, 0x00, 0x05, 0x80, 0x82, 0x71, 0xe1, 1391 0x10, 0xe6, 0x00, 0x05, 0x80, 0x82, 0x71, 0xe1,
1392 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x04, 1392 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x04,
1393 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6, 1393 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6,
1394 0x00, 0x04, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 1394 0x00, 0x04, 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05,
1395 0x00, 0x12, 0x76, 0x82, 0x00, 0x03, 0x71, 0xe1, 1395 0x00, 0x12, 0x76, 0x82, 0x00, 0x03, 0x71, 0xe1,
1396 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6, 0x00, 0x03, 1396 0x00, 0x06, 0x00, 0x12, 0x10, 0xe6, 0x00, 0x03,
1397 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1397 0x80, 0x82, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1398 0x76, 0x82, 0x00, 0x02, 0x10, 0xe6, 0x00, 0x02, 1398 0x76, 0x82, 0x00, 0x02, 0x10, 0xe6, 0x00, 0x02,
1399 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 1399 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x80, 0x82,
1400 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 1400 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 0x76, 0x82,
1401 0x00, 0x01, 0x10, 0xe6, 0x00, 0x01, 0x71, 0xe1, 1401 0x00, 0x01, 0x10, 0xe6, 0x00, 0x01, 0x71, 0xe1,
1402 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1, 1402 0x00, 0x06, 0x00, 0x12, 0x80, 0x82, 0x71, 0xe1,
1403 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 1403 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x00,
1404 0x71, 0xe1, 0x00, 0x06, 0x00, 0x13, 0xe7, 0x62, 1404 0x71, 0xe1, 0x00, 0x06, 0x00, 0x13, 0xe7, 0x62,
1405 0xe5, 0x01, 0xf9, 0x80, 0x16, 0x9a, 0x8a, 0x16, 1405 0xe5, 0x01, 0xf9, 0x80, 0x16, 0x9a, 0x8a, 0x16,
1406 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 1406 0x8a, 0x11, 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11,
1407 0xf4, 0x95, 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05, 1407 0xf4, 0x95, 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05,
1408 0x00, 0x12, 0xee, 0xff, 0x76, 0x82, 0x00, 0x00, 1408 0x00, 0x12, 0xee, 0xff, 0x76, 0x82, 0x00, 0x00,
1409 0xee, 0x01, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x11, 1409 0xee, 0x01, 0x71, 0xe1, 0x00, 0x06, 0x00, 0x11,
1410 0x69, 0x81, 0x00, 0x01, 0x8a, 0x11, 0xf4, 0x95, 1410 0x69, 0x81, 0x00, 0x01, 0x8a, 0x11, 0xf4, 0x95,
1411 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0xf4, 0x95, 1411 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0xf4, 0x95,
1412 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1412 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1413 0xee, 0xff, 0x76, 0x82, 0x00, 0x01, 0xee, 0x01, 1413 0xee, 0xff, 0x76, 0x82, 0x00, 0x01, 0xee, 0x01,
1414 0x71, 0xe1, 0x00, 0x06, 0x00, 0x11, 0x69, 0x81, 1414 0x71, 0xe1, 0x00, 0x06, 0x00, 0x11, 0x69, 0x81,
1415 0x00, 0x01, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4, 1415 0x00, 0x01, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
1416 0x4a, 0x11, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 1416 0x4a, 0x11, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
1417 0xf0, 0x00, 0x00, 0x94, 0x88, 0x11, 0xf4, 0x95, 1417 0xf0, 0x00, 0x00, 0x94, 0x88, 0x11, 0xf4, 0x95,
1418 0xf4, 0x95, 0x10, 0x81, 0xfa, 0x44, 0x17, 0x9c, 1418 0xf4, 0x95, 0x10, 0x81, 0xfa, 0x44, 0x17, 0x9c,
1419 0xf4, 0x95, 0xee, 0xff, 0xf9, 0x80, 0x16, 0x53, 1419 0xf4, 0x95, 0xee, 0xff, 0xf9, 0x80, 0x16, 0x53,
1420 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 0xf0, 0x00, 1420 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 0xf0, 0x00,
1421 0x00, 0x94, 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 1421 0x00, 0x94, 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95,
1422 0x76, 0x81, 0x00, 0x01, 0xee, 0x01, 0x76, 0xe1, 1422 0x76, 0x81, 0x00, 0x01, 0xee, 0x01, 0x76, 0xe1,
1423 0x00, 0x01, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02, 1423 0x00, 0x01, 0x00, 0x00, 0x76, 0xe1, 0x00, 0x02,
1424 0x00, 0x21, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x20, 1424 0x00, 0x21, 0x76, 0xe1, 0x00, 0x03, 0x00, 0x20,
1425 0x76, 0xe1, 0x00, 0x04, 0x00, 0x23, 0x76, 0xe1, 1425 0x76, 0xe1, 0x00, 0x04, 0x00, 0x23, 0x76, 0xe1,
1426 0x00, 0x05, 0x00, 0x22, 0x76, 0xe1, 0x00, 0x06, 1426 0x00, 0x05, 0x00, 0x22, 0x76, 0xe1, 0x00, 0x06,
1427 0x00, 0x38, 0x76, 0xe1, 0x00, 0x07, 0x00, 0x39, 1427 0x00, 0x38, 0x76, 0xe1, 0x00, 0x07, 0x00, 0x39,
1428 0x76, 0xe1, 0x00, 0x08, 0x00, 0x15, 0x76, 0xe1, 1428 0x76, 0xe1, 0x00, 0x08, 0x00, 0x15, 0x76, 0xe1,
1429 0x00, 0x09, 0x00, 0x14, 0x76, 0xe1, 0x00, 0x0a, 1429 0x00, 0x09, 0x00, 0x14, 0x76, 0xe1, 0x00, 0x0a,
1430 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x41, 1430 0x00, 0x00, 0x76, 0xe1, 0x00, 0x0b, 0x00, 0x41,
1431 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x40, 0x76, 0xe1, 1431 0x76, 0xe1, 0x00, 0x0c, 0x00, 0x40, 0x76, 0xe1,
1432 0x00, 0x0d, 0x00, 0x43, 0x76, 0xe1, 0x00, 0x0e, 1432 0x00, 0x0d, 0x00, 0x43, 0x76, 0xe1, 0x00, 0x0e,
1433 0x00, 0x42, 0x76, 0xe1, 0x00, 0x0f, 0x00, 0x48, 1433 0x00, 0x42, 0x76, 0xe1, 0x00, 0x0f, 0x00, 0x48,
1434 0x76, 0xe1, 0x00, 0x10, 0x00, 0x49, 0x76, 0xe1, 1434 0x76, 0xe1, 0x00, 0x10, 0x00, 0x49, 0x76, 0xe1,
1435 0x00, 0x11, 0x00, 0x1b, 0x76, 0xe1, 0x00, 0x12, 1435 0x00, 0x11, 0x00, 0x1b, 0x76, 0xe1, 0x00, 0x12,
1436 0x00, 0x1a, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4, 1436 0x00, 0x1a, 0x8a, 0x11, 0xf4, 0x95, 0xf4, 0xe4,
1437 0x4a, 0x11, 0xee, 0xfd, 0x88, 0x11, 0x56, 0x06, 1437 0x4a, 0x11, 0xee, 0xfd, 0x88, 0x11, 0x56, 0x06,
1438 0x4e, 0x00, 0xf9, 0x80, 0x16, 0xa2, 0x77, 0x12, 1438 0x4e, 0x00, 0xf9, 0x80, 0x16, 0xa2, 0x77, 0x12,
1439 0x00, 0x7b, 0x77, 0x0e, 0x00, 0x09, 0x10, 0x82, 1439 0x00, 0x7b, 0x77, 0x0e, 0x00, 0x09, 0x10, 0x82,
1440 0x28, 0xf8, 0x00, 0x11, 0xf0, 0x00, 0x00, 0x95, 1440 0x28, 0xf8, 0x00, 0x11, 0xf0, 0x00, 0x00, 0x95,
1441 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 1441 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81,
1442 0xf8, 0x45, 0x17, 0xf0, 0xf2, 0x73, 0x17, 0xfd, 1442 0xf8, 0x45, 0x17, 0xf0, 0xf2, 0x73, 0x17, 0xfd,
1443 0x77, 0x11, 0xff, 0xff, 0x76, 0x81, 0x00, 0x01, 1443 0x77, 0x11, 0xff, 0xff, 0x76, 0x81, 0x00, 0x01,
1444 0xe9, 0x01, 0x56, 0x00, 0xf1, 0x80, 0x10, 0xf8, 1444 0xe9, 0x01, 0x56, 0x00, 0xf1, 0x80, 0x10, 0xf8,
1445 0x00, 0x0b, 0xf8, 0x45, 0x17, 0xfd, 0xfb, 0x80, 1445 0x00, 0x0b, 0xf8, 0x45, 0x17, 0xfd, 0xfb, 0x80,
1446 0x18, 0x10, 0xf4, 0x95, 0x48, 0x11, 0xf9, 0x80, 1446 0x18, 0x10, 0xf4, 0x95, 0x48, 0x11, 0xf9, 0x80,
1447 0x16, 0x9a, 0xee, 0x03, 0x48, 0x11, 0x8a, 0x11, 1447 0x16, 0x9a, 0xee, 0x03, 0x48, 0x11, 0x8a, 0x11,
1448 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 1448 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11,
1449 0xf4, 0x95, 0xee, 0xff, 0x71, 0xe1, 0x00, 0x01, 1449 0xf4, 0x95, 0xee, 0xff, 0x71, 0xe1, 0x00, 0x01,
1450 0x00, 0x11, 0xee, 0x01, 0x10, 0x81, 0x8a, 0x11, 1450 0x00, 0x11, 0xee, 0x01, 0x10, 0x81, 0x8a, 0x11,
1451 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff, 1451 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff,
1452 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95, 1452 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95,
1453 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30, 1453 0x77, 0x10, 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30,
1454 0x18, 0xc3, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1454 0x18, 0xc3, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1455 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 0x00, 0x06, 1455 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 0x00, 0x06,
1456 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 1456 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
1457 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x01, 1457 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x01,
1458 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82, 1458 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
1459 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1459 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1460 0x76, 0x82, 0x00, 0x02, 0x71, 0xe1, 0x00, 0x06, 1460 0x76, 0x82, 0x00, 0x02, 0x71, 0xe1, 0x00, 0x06,
1461 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 1461 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
1462 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x03, 1462 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x03,
1463 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82, 1463 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
1464 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1464 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1465 0x76, 0x82, 0x00, 0x04, 0x71, 0xe1, 0x00, 0x06, 1465 0x76, 0x82, 0x00, 0x04, 0x71, 0xe1, 0x00, 0x06,
1466 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 1466 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
1467 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x05, 1467 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x05,
1468 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82, 1468 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
1469 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1469 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1470 0x76, 0x82, 0x00, 0x06, 0x71, 0xe1, 0x00, 0x06, 1470 0x76, 0x82, 0x00, 0x06, 0x71, 0xe1, 0x00, 0x06,
1471 0x00, 0x12, 0x76, 0x82, 0x00, 0x01, 0x71, 0xe1, 1471 0x00, 0x12, 0x76, 0x82, 0x00, 0x01, 0x71, 0xe1,
1472 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x07, 1472 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x07,
1473 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82, 1473 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
1474 0x20, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1474 0x20, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1475 0x76, 0x82, 0x00, 0x08, 0x71, 0xe1, 0x00, 0x06, 1475 0x76, 0x82, 0x00, 0x08, 0x71, 0xe1, 0x00, 0x06,
1476 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 1476 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
1477 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x09, 1477 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x09,
1478 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82, 1478 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
1479 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1479 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1480 0x76, 0x82, 0x00, 0x0a, 0x71, 0xe1, 0x00, 0x06, 1480 0x76, 0x82, 0x00, 0x0a, 0x71, 0xe1, 0x00, 0x06,
1481 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 1481 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
1482 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0b, 1482 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0b,
1483 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82, 1483 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
1484 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1484 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1485 0x76, 0x82, 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x06, 1485 0x76, 0x82, 0x00, 0x0c, 0x71, 0xe1, 0x00, 0x06,
1486 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1, 1486 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x71, 0xe1,
1487 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0d, 1487 0x00, 0x05, 0x00, 0x12, 0x76, 0x82, 0x00, 0x0d,
1488 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82, 1488 0x71, 0xe1, 0x00, 0x06, 0x00, 0x12, 0x76, 0x82,
1489 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12, 1489 0x00, 0x00, 0x71, 0xe1, 0x00, 0x05, 0x00, 0x12,
1490 0x76, 0x82, 0x00, 0x0e, 0x71, 0xe1, 0x00, 0x06, 1490 0x76, 0x82, 0x00, 0x0e, 0x71, 0xe1, 0x00, 0x06,
1491 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1, 1491 0x00, 0x12, 0x76, 0x82, 0x00, 0x00, 0x10, 0xe1,
1492 0x00, 0x07, 0xf9, 0x80, 0x16, 0x76, 0x10, 0xe1, 1492 0x00, 0x07, 0xf9, 0x80, 0x16, 0x76, 0x10, 0xe1,
1493 0x00, 0x08, 0xf9, 0x80, 0x16, 0x76, 0x10, 0xe1, 1493 0x00, 0x08, 0xf9, 0x80, 0x16, 0x76, 0x10, 0xe1,
1494 0x00, 0x07, 0xf9, 0x80, 0x16, 0x66, 0x10, 0xe1, 1494 0x00, 0x07, 0xf9, 0x80, 0x16, 0x66, 0x10, 0xe1,
1495 0x00, 0x08, 0xf9, 0x80, 0x16, 0x66, 0xf0, 0x73, 1495 0x00, 0x08, 0xf9, 0x80, 0x16, 0x66, 0xf0, 0x73,
1496 0x18, 0xd1, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 1496 0x18, 0xd1, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
1497 0xfb, 0x80, 0x18, 0x10, 0xf0, 0x00, 0x00, 0x95, 1497 0xfb, 0x80, 0x18, 0x10, 0xf0, 0x00, 0x00, 0x95,
1498 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 0xfb, 0x80, 1498 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 0xfb, 0x80,
1499 0x18, 0x10, 0xf0, 0x00, 0x00, 0x9e, 0xf9, 0x80, 1499 0x18, 0x10, 0xf0, 0x00, 0x00, 0x9e, 0xf9, 0x80,
1500 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11, 0xf4, 0xe4, 1500 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11, 0xf4, 0xe4,
1501 0x4a, 0x11, 0x88, 0x11, 0xee, 0xff, 0xf4, 0x95, 1501 0x4a, 0x11, 0x88, 0x11, 0xee, 0xff, 0xf4, 0x95,
1502 0x10, 0x04, 0x71, 0xe1, 0x00, 0x03, 0x00, 0x11, 1502 0x10, 0x04, 0x71, 0xe1, 0x00, 0x03, 0x00, 0x11,
1503 0xee, 0x01, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95, 1503 0xee, 0x01, 0x80, 0x81, 0x8a, 0x11, 0xf4, 0x95,
1504 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95, 1504 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16, 0xf4, 0x95,
1505 0x71, 0x04, 0x00, 0x16, 0xfb, 0x80, 0x16, 0xa2, 1505 0x71, 0x04, 0x00, 0x16, 0xfb, 0x80, 0x16, 0xa2,
1506 0x88, 0x11, 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x02, 1506 0x88, 0x11, 0xf4, 0x95, 0x71, 0xe1, 0x00, 0x02,
1507 0x00, 0x12, 0x76, 0x82, 0x00, 0x10, 0x10, 0xe6, 1507 0x00, 0x12, 0x76, 0x82, 0x00, 0x10, 0x10, 0xe6,
1508 0x00, 0x01, 0x71, 0xe1, 0x00, 0x03, 0x00, 0x12, 1508 0x00, 0x01, 0x71, 0xe1, 0x00, 0x03, 0x00, 0x12,
1509 0x80, 0x82, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x12, 1509 0x80, 0x82, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x12,
1510 0x10, 0xe6, 0x00, 0x02, 0x80, 0x82, 0xe7, 0x62, 1510 0x10, 0xe6, 0x00, 0x02, 0x80, 0x82, 0xe7, 0x62,
1511 0x71, 0xe1, 0x00, 0x02, 0x00, 0x13, 0xe5, 0x01, 1511 0x71, 0xe1, 0x00, 0x02, 0x00, 0x13, 0xe5, 0x01,
1512 0xf9, 0x80, 0x16, 0x9a, 0x8a, 0x16, 0x8a, 0x11, 1512 0xf9, 0x80, 0x16, 0x9a, 0x8a, 0x16, 0x8a, 0x11,
1513 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0xee, 0xff, 1513 0xf4, 0xe4, 0x4a, 0x11, 0x88, 0x11, 0xee, 0xff,
1514 0xee, 0x01, 0x10, 0xe1, 0x00, 0x01, 0x8a, 0x11, 1514 0xee, 0x01, 0x10, 0xe1, 0x00, 0x01, 0x8a, 0x11,
1515 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x77, 0x11, 1515 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x77, 0x11,
1516 0x00, 0x7b, 0x10, 0x81, 0xf0, 0x00, 0x00, 0xb3, 1516 0x00, 0x7b, 0x10, 0x81, 0xf0, 0x00, 0x00, 0xb3,
1517 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 1517 0x88, 0x11, 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81,
1518 0xfa, 0x44, 0x19, 0x2a, 0xf4, 0x95, 0xee, 0xff, 1518 0xfa, 0x44, 0x19, 0x2a, 0xf4, 0x95, 0xee, 0xff,
1519 0xf9, 0x80, 0x16, 0x53, 0x77, 0x11, 0x00, 0x7b, 1519 0xf9, 0x80, 0x16, 0x53, 0x77, 0x11, 0x00, 0x7b,
1520 0x10, 0x81, 0xf0, 0x00, 0x00, 0xb3, 0x88, 0x11, 1520 0x10, 0x81, 0xf0, 0x00, 0x00, 0xb3, 0x88, 0x11,
1521 0xf4, 0x95, 0xf4, 0x95, 0x76, 0x81, 0x00, 0x01, 1521 0xf4, 0x95, 0xf4, 0x95, 0x76, 0x81, 0x00, 0x01,
1522 0xee, 0x01, 0x76, 0xe1, 0x00, 0x01, 0x00, 0x00, 1522 0xee, 0x01, 0x76, 0xe1, 0x00, 0x01, 0x00, 0x00,
1523 0x76, 0xe1, 0x00, 0x02, 0x00, 0x13, 0x76, 0xe1, 1523 0x76, 0xe1, 0x00, 0x02, 0x00, 0x13, 0x76, 0xe1,
1524 0x00, 0x03, 0x00, 0x26, 0x76, 0xe1, 0x00, 0x04, 1524 0x00, 0x03, 0x00, 0x26, 0x76, 0xe1, 0x00, 0x04,
1525 0x00, 0x25, 0x76, 0xe1, 0x00, 0x05, 0x00, 0x24, 1525 0x00, 0x25, 0x76, 0xe1, 0x00, 0x05, 0x00, 0x24,
1526 0x76, 0xe1, 0x00, 0x06, 0x00, 0x00, 0x76, 0xe1, 1526 0x76, 0xe1, 0x00, 0x06, 0x00, 0x00, 0x76, 0xe1,
1527 0x00, 0x07, 0x00, 0x17, 0x76, 0xe1, 0x00, 0x08, 1527 0x00, 0x07, 0x00, 0x17, 0x76, 0xe1, 0x00, 0x08,
1528 0x00, 0x32, 0x76, 0xe1, 0x00, 0x09, 0x00, 0x31, 1528 0x00, 0x32, 0x76, 0xe1, 0x00, 0x09, 0x00, 0x31,
1529 0x76, 0xe1, 0x00, 0x0a, 0x00, 0x30, 0x8a, 0x11, 1529 0x76, 0xe1, 0x00, 0x0a, 0x00, 0x30, 0x8a, 0x11,
1530 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16, 1530 0xf4, 0x95, 0xf4, 0xe4, 0x4a, 0x11, 0x4a, 0x16,
1531 0x4a, 0x17, 0xee, 0xff, 0xf4, 0x95, 0x71, 0x06, 1531 0x4a, 0x17, 0xee, 0xff, 0xf4, 0x95, 0x71, 0x06,
1532 0x00, 0x17, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11, 1532 0x00, 0x17, 0xfb, 0x80, 0x16, 0xa2, 0x88, 0x11,
1533 0xf4, 0x95, 0xf7, 0xb8, 0x10, 0xf8, 0x00, 0x11, 1533 0xf4, 0x95, 0xf7, 0xb8, 0x10, 0xf8, 0x00, 0x11,
1534 0xf0, 0x10, 0xff, 0xff, 0xfa, 0x45, 0x19, 0x73, 1534 0xf0, 0x10, 0xff, 0xff, 0xfa, 0x45, 0x19, 0x73,
1535 0x77, 0x16, 0xff, 0xff, 0x77, 0x12, 0x00, 0x7b, 1535 0x77, 0x16, 0xff, 0xff, 0x77, 0x12, 0x00, 0x7b,
1536 0x77, 0x0e, 0x00, 0x05, 0x10, 0x82, 0x28, 0xf8, 1536 0x77, 0x0e, 0x00, 0x05, 0x10, 0x82, 0x28, 0xf8,
1537 0x00, 0x11, 0xf0, 0x00, 0x00, 0xb4, 0x88, 0x11, 1537 0x00, 0x11, 0xf0, 0x00, 0x00, 0xb4, 0x88, 0x11,
1538 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xf8, 0x44, 1538 0xf4, 0x95, 0xf4, 0x95, 0x10, 0x81, 0xf8, 0x44,
1539 0x19, 0x84, 0xf2, 0x73, 0x19, 0x84, 0xf4, 0x95, 1539 0x19, 0x84, 0xf2, 0x73, 0x19, 0x84, 0xf4, 0x95,
1540 0xe7, 0x16, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 1540 0xe7, 0x16, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
1541 0xf0, 0x00, 0x00, 0xb4, 0x88, 0x11, 0xf4, 0x95, 1541 0xf0, 0x00, 0x00, 0xb4, 0x88, 0x11, 0xf4, 0x95,
1542 0x77, 0x12, 0x00, 0x02, 0x10, 0x81, 0xf8, 0x45, 1542 0x77, 0x12, 0x00, 0x02, 0x10, 0x81, 0xf8, 0x45,
1543 0x19, 0x6f, 0x6e, 0xea, 0xff, 0xff, 0x19, 0x7c, 1543 0x19, 0x6f, 0x6e, 0xea, 0xff, 0xff, 0x19, 0x7c,
1544 0x6d, 0xe9, 0x00, 0x05, 0x61, 0xf8, 0x00, 0x17, 1544 0x6d, 0xe9, 0x00, 0x05, 0x61, 0xf8, 0x00, 0x17,
1545 0x00, 0x01, 0xfa, 0x20, 0x19, 0x8f, 0x76, 0x86, 1545 0x00, 0x01, 0xfa, 0x20, 0x19, 0x8f, 0x76, 0x86,
1546 0x00, 0x01, 0xfb, 0x80, 0x19, 0x97, 0xf4, 0x95, 1546 0x00, 0x01, 0xfb, 0x80, 0x19, 0x97, 0xf4, 0x95,
1547 0x48, 0x16, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 1547 0x48, 0x16, 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01,
1548 0x8a, 0x17, 0x48, 0x16, 0x8a, 0x16, 0x8a, 0x11, 1548 0x8a, 0x17, 0x48, 0x16, 0x8a, 0x16, 0x8a, 0x11,
1549 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff, 0xfb, 0x80, 1549 0xf4, 0xe4, 0x4a, 0x11, 0xee, 0xff, 0xfb, 0x80,
1550 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10, 1550 0x16, 0xa2, 0x88, 0x11, 0xf4, 0x95, 0x77, 0x10,
1551 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30, 0x19, 0xcc, 1551 0xff, 0xff, 0xf4, 0xa9, 0xf8, 0x30, 0x19, 0xcc,
1552 0x71, 0xe1, 0x00, 0x02, 0x00, 0x12, 0x69, 0x82, 1552 0x71, 0xe1, 0x00, 0x02, 0x00, 0x12, 0x69, 0x82,
1553 0x00, 0x10, 0x71, 0xe1, 0x00, 0x02, 0x00, 0x12, 1553 0x00, 0x10, 0x71, 0xe1, 0x00, 0x02, 0x00, 0x12,
1554 0x68, 0x82, 0xf7, 0xff, 0x71, 0xe1, 0x00, 0x02, 1554 0x68, 0x82, 0xf7, 0xff, 0x71, 0xe1, 0x00, 0x02,
1555 0x00, 0x12, 0x68, 0x82, 0xfb, 0xff, 0x71, 0xe1, 1555 0x00, 0x12, 0x68, 0x82, 0xfb, 0xff, 0x71, 0xe1,
1556 0x00, 0x02, 0x00, 0x12, 0x68, 0x82, 0xff, 0xf0, 1556 0x00, 0x02, 0x00, 0x12, 0x68, 0x82, 0xff, 0xf0,
1557 0x71, 0xe1, 0x00, 0x03, 0x00, 0x12, 0x76, 0x82, 1557 0x71, 0xe1, 0x00, 0x03, 0x00, 0x12, 0x76, 0x82,
1558 0xff, 0xff, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x12, 1558 0xff, 0xff, 0x71, 0xe1, 0x00, 0x04, 0x00, 0x12,
1559 0x76, 0x82, 0xff, 0xff, 0x71, 0xe1, 0x00, 0x02, 1559 0x76, 0x82, 0xff, 0xff, 0x71, 0xe1, 0x00, 0x02,
1560 0x00, 0x12, 0x69, 0x82, 0x00, 0x20, 0x71, 0xe1, 1560 0x00, 0x12, 0x69, 0x82, 0x00, 0x20, 0x71, 0xe1,
1561 0x00, 0x02, 0x00, 0x11, 0xf2, 0x73, 0x19, 0xda, 1561 0x00, 0x02, 0x00, 0x11, 0xf2, 0x73, 0x19, 0xda,
1562 0x68, 0x81, 0xff, 0xef, 0x77, 0x11, 0x00, 0x7b, 1562 0x68, 0x81, 0xff, 0xef, 0x77, 0x11, 0x00, 0x7b,
1563 0x10, 0x81, 0xfb, 0x80, 0x19, 0x97, 0xf0, 0x00, 1563 0x10, 0x81, 0xfb, 0x80, 0x19, 0x97, 0xf0, 0x00,
1564 0x00, 0xb4, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81, 1564 0x00, 0xb4, 0x77, 0x11, 0x00, 0x7b, 0x10, 0x81,
1565 0xfb, 0x80, 0x19, 0x97, 0xf0, 0x00, 0x00, 0xb9, 1565 0xfb, 0x80, 0x19, 0x97, 0xf0, 0x00, 0x00, 0xb9,
1566 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11, 1566 0xf9, 0x80, 0x16, 0x9a, 0xee, 0x01, 0x8a, 0x11,
1567 0xf4, 0xe4, 0x00, 0xa4, 0x00, 0x00, 0x19, 0xdf, 1567 0xf4, 0xe4, 0x00, 0xa4, 0x00, 0x00, 0x19, 0xdf,
1568 0x00, 0x01, 0x2a, 0xe6, 0x00, 0x00, 0x00, 0x01, 1568 0x00, 0x01, 0x2a, 0xe6, 0x00, 0x00, 0x00, 0x01,
1569 0x2a, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x2a, 0x12, 1569 0x2a, 0xe7, 0x00, 0x00, 0x00, 0x03, 0x2a, 0x12,
1570 0x0c, 0x01, 0xc3, 0x4f, 0x00, 0x00, 0x00, 0x01, 1570 0x0c, 0x01, 0xc3, 0x4f, 0x00, 0x00, 0x00, 0x01,
1571 0x2a, 0x15, 0x00, 0x00, 0x00, 0x02, 0x2a, 0x16, 1571 0x2a, 0x15, 0x00, 0x00, 0x00, 0x02, 0x2a, 0x16,
1572 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x2a, 0x5d, 1572 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x2a, 0x5d,
1573 0x00, 0x43, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x79, 1573 0x00, 0x43, 0x00, 0x6f, 0x00, 0x70, 0x00, 0x79,
1574 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68, 1574 0x00, 0x72, 0x00, 0x69, 0x00, 0x67, 0x00, 0x68,
1575 0x00, 0x74, 0x00, 0x20, 0x00, 0x54, 0x00, 0x65, 1575 0x00, 0x74, 0x00, 0x20, 0x00, 0x54, 0x00, 0x65,
1576 0x00, 0x63, 0x00, 0x68, 0x00, 0x6e, 0x00, 0x6f, 1576 0x00, 0x63, 0x00, 0x68, 0x00, 0x6e, 0x00, 0x6f,
1577 0x00, 0x54, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6e, 1577 0x00, 0x54, 0x00, 0x72, 0x00, 0x65, 0x00, 0x6e,
1578 0x00, 0x64, 0x00, 0x20, 0x00, 0x41, 0x00, 0x47, 1578 0x00, 0x64, 0x00, 0x20, 0x00, 0x41, 0x00, 0x47,
1579 0x00, 0x00, 0x00, 0x04, 0x2a, 0x76, 0x00, 0x30, 1579 0x00, 0x00, 0x00, 0x04, 0x2a, 0x76, 0x00, 0x30,
1580 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0c, 1580 0x00, 0x2e, 0x00, 0x30, 0x00, 0x00, 0x00, 0x0c,
1581 0x2a, 0x7a, 0x00, 0x46, 0x00, 0x65, 0x00, 0x62, 1581 0x2a, 0x7a, 0x00, 0x46, 0x00, 0x65, 0x00, 0x62,
1582 0x00, 0x20, 0x00, 0x32, 0x00, 0x37, 0x00, 0x20, 1582 0x00, 0x20, 0x00, 0x32, 0x00, 0x37, 0x00, 0x20,
1583 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x31, 1583 0x00, 0x32, 0x00, 0x30, 0x00, 0x30, 0x00, 0x31,
1584 0x00, 0x00, 0x00, 0x09, 0x2a, 0x86, 0x00, 0x31, 1584 0x00, 0x00, 0x00, 0x09, 0x2a, 0x86, 0x00, 0x31,
1585 0x00, 0x34, 0x00, 0x3a, 0x00, 0x33, 0x00, 0x35, 1585 0x00, 0x34, 0x00, 0x3a, 0x00, 0x33, 0x00, 0x35,
1586 0x00, 0x3a, 0x00, 0x33, 0x00, 0x33, 0x00, 0x00, 1586 0x00, 0x3a, 0x00, 0x33, 0x00, 0x33, 0x00, 0x00,
1587 0x00, 0x0f, 0x2a, 0x8f, 0x00, 0x00, 0x00, 0x00, 1587 0x00, 0x0f, 0x2a, 0x8f, 0x00, 0x00, 0x00, 0x00,
1588 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 1588 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
1589 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1589 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1590 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1590 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1591 0x00, 0x00, 0x00, 0x01, 0x2a, 0x9e, 0x00, 0x00, 1591 0x00, 0x00, 0x00, 0x01, 0x2a, 0x9e, 0x00, 0x00,
1592 0x00, 0x01, 0x2a, 0x9f, 0x00, 0x00, 0x00, 0x01, 1592 0x00, 0x01, 0x2a, 0x9f, 0x00, 0x00, 0x00, 0x01,
1593 0x2a, 0xa0, 0x00, 0x00, 0x00, 0x01, 0x2a, 0xa1, 1593 0x2a, 0xa0, 0x00, 0x00, 0x00, 0x01, 0x2a, 0xa1,
1594 0x00, 0x00, 0x00, 0x01, 0x2a, 0xa2, 0x00, 0x00, 1594 0x00, 0x00, 0x00, 0x01, 0x2a, 0xa2, 0x00, 0x00,
1595 0x00, 0x01, 0x29, 0x7e, 0x00, 0x00, 0x00, 0x02, 1595 0x00, 0x01, 0x29, 0x7e, 0x00, 0x00, 0x00, 0x02,
1596 0x29, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 1596 0x29, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
1597 0x29, 0x82, 0xff, 0xff, 0x00, 0x01, 0x2a, 0xa7, 1597 0x29, 0x82, 0xff, 0xff, 0x00, 0x01, 0x2a, 0xa7,
1598 0x00, 0x00, 0x00, 0x05, 0x2a, 0xa8, 0x71, 0x41, 1598 0x00, 0x00, 0x00, 0x05, 0x2a, 0xa8, 0x71, 0x41,
1599 0x20, 0x00, 0x20, 0x00, 0x00, 0x23, 0x04, 0x00, 1599 0x20, 0x00, 0x20, 0x00, 0x00, 0x23, 0x04, 0x00,
1600 0x00, 0x0a, 0x2a, 0xad, 0x00, 0x00, 0x00, 0x00, 1600 0x00, 0x0a, 0x2a, 0xad, 0x00, 0x00, 0x00, 0x00,
1601 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1601 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1602 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1602 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1603 0x00, 0x0f, 0x2a, 0xb7, 0x00, 0x00, 0x00, 0x00, 1603 0x00, 0x0f, 0x2a, 0xb7, 0x00, 0x00, 0x00, 0x00,
1604 0x00, 0x00, 0x00, 0x40, 0x00, 0xa0, 0x82, 0x40, 1604 0x00, 0x00, 0x00, 0x40, 0x00, 0xa0, 0x82, 0x40,
1605 0x00, 0x08, 0x30, 0x7f, 0x00, 0x80, 0x01, 0x80, 1605 0x00, 0x08, 0x30, 0x7f, 0x00, 0x80, 0x01, 0x80,
1606 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 1606 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1607 0x00, 0x00, 0x00, 0x01, 0x27, 0x6e, 0x00, 0x00, 1607 0x00, 0x00, 0x00, 0x01, 0x27, 0x6e, 0x00, 0x00,
1608 0x00, 0x01, 0x27, 0x6f, 0x00, 0x00, 0x00, 0x00, 1608 0x00, 0x01, 0x27, 0x6f, 0x00, 0x00, 0x00, 0x00,
1609 0x00, 0x09, 0x00, 0x00, 0x1a, 0x83, 0x04, 0xe8, 1609 0x00, 0x09, 0x00, 0x00, 0x1a, 0x83, 0x04, 0xe8,
1610 0x04, 0xcf, 0x04, 0xc5, 0x04, 0xba, 0x04, 0xb0, 1610 0x04, 0xcf, 0x04, 0xc5, 0x04, 0xba, 0x04, 0xb0,
1611 0x04, 0xac, 0x04, 0x9c, 0x04, 0x8c, 0x04, 0x81, 1611 0x04, 0xac, 0x04, 0x9c, 0x04, 0x8c, 0x04, 0x81,
1612 0x00, 0x78, 0x00, 0x00, 0x01, 0x00, 0xf2, 0x73, 1612 0x00, 0x78, 0x00, 0x00, 0x01, 0x00, 0xf2, 0x73,
1613 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1613 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1614 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1614 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1615 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1615 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1616 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1616 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1617 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1617 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1618 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1618 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1619 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1619 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1620 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1620 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1621 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1621 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1622 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1622 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1623 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1623 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1624 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1624 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1625 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1625 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1626 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1626 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1627 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1627 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1628 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1628 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1629 0x07, 0xaa, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1629 0x07, 0xaa, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1630 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1630 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1631 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1631 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1632 0x02, 0x23, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1632 0x02, 0x23, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1633 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1633 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1634 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1634 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1635 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1635 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1636 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1636 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1637 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1637 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1638 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1638 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1639 0x05, 0xe5, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1639 0x05, 0xe5, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1640 0x02, 0xb5, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1640 0x02, 0xb5, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1641 0x0e, 0x33, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73, 1641 0x0e, 0x33, 0xf4, 0x95, 0xf4, 0x95, 0xf2, 0x73,
1642 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0x00, 0x00, 1642 0x07, 0xef, 0xf4, 0x95, 0xf4, 0x95, 0x00, 0x00,
1643}; 1643};
1644 1644
diff --git a/drivers/media/dvb/ttusb-dec/ttusb_dec.c b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
index 832d179f26fa..8abc21890129 100644
--- a/drivers/media/dvb/ttusb-dec/ttusb_dec.c
+++ b/drivers/media/dvb/ttusb-dec/ttusb_dec.c
@@ -1203,7 +1203,7 @@ static int ttusb_init_rc(struct ttusb_dec *dec)
1203 input_dev->keycode = rc_keys; 1203 input_dev->keycode = rc_keys;
1204 1204
1205 for (i = 0; i < ARRAY_SIZE(rc_keys); i++) 1205 for (i = 0; i < ARRAY_SIZE(rc_keys); i++)
1206 set_bit(rc_keys[i], input_dev->keybit); 1206 set_bit(rc_keys[i], input_dev->keybit);
1207 1207
1208 input_register_device(input_dev); 1208 input_register_device(input_dev);
1209 1209
@@ -1529,7 +1529,7 @@ static void ttusb_dec_exit_rc(struct ttusb_dec *dec)
1529 usb_free_urb(dec->irq_urb); 1529 usb_free_urb(dec->irq_urb);
1530 1530
1531 usb_buffer_free(dec->udev,IRQ_PACKET_SIZE, 1531 usb_buffer_free(dec->udev,IRQ_PACKET_SIZE,
1532 dec->irq_buffer, dec->irq_dma_handle); 1532 dec->irq_buffer, dec->irq_dma_handle);
1533 1533
1534 if (dec->rc_input_dev) { 1534 if (dec->rc_input_dev) {
1535 input_unregister_device(dec->rc_input_dev); 1535 input_unregister_device(dec->rc_input_dev);
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index cc4a723e24db..fc87efc5049c 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -188,7 +188,7 @@ config VIDEO_ZORAN
188 188
189 To compile this driver as a module, choose M here: the 189 To compile this driver as a module, choose M here: the
190 module will be called zr36067. 190 module will be called zr36067.
191 191
192config VIDEO_ZORAN_BUZ 192config VIDEO_ZORAN_BUZ
193 tristate "Iomega Buz support" 193 tristate "Iomega Buz support"
194 depends on VIDEO_ZORAN 194 depends on VIDEO_ZORAN
@@ -204,8 +204,8 @@ config VIDEO_ZORAN_DC10
204 204
205config VIDEO_ZORAN_DC30 205config VIDEO_ZORAN_DC30
206 tristate "Pinnacle/Miro DC30(+) support" 206 tristate "Pinnacle/Miro DC30(+) support"
207 depends on VIDEO_ZORAN 207 depends on VIDEO_ZORAN
208 help 208 help
209 Support for the Pinnacle/Miro DC30(+) MJPEG capture/playback 209 Support for the Pinnacle/Miro DC30(+) MJPEG capture/playback
210 card. This also supports really old DC10 cards based on the 210 card. This also supports really old DC10 cards based on the
211 zr36050 MJPEG codec and zr36016 VFE. 211 zr36050 MJPEG codec and zr36016 VFE.
@@ -260,7 +260,7 @@ config VIDEO_MXB
260 ---help--- 260 ---help---
261 This is a video4linux driver for the 'Multimedia eXtension Board' 261 This is a video4linux driver for the 'Multimedia eXtension Board'
262 TV card by Siemens-Nixdorf. 262 TV card by Siemens-Nixdorf.
263 263
264 To compile this driver as a module, choose M here: the 264 To compile this driver as a module, choose M here: the
265 module will be called mxb. 265 module will be called mxb.
266 266
@@ -274,7 +274,7 @@ config VIDEO_DPC
274 for SAA7146 bases boards, so if you have some unsupported 274 for SAA7146 bases boards, so if you have some unsupported
275 saa7146 based, analog video card, chances are good that it 275 saa7146 based, analog video card, chances are good that it
276 will work with this skeleton driver. 276 will work with this skeleton driver.
277 277
278 To compile this driver as a module, choose M here: the 278 To compile this driver as a module, choose M here: the
279 module will be called dpc7146. 279 module will be called dpc7146.
280 280
@@ -285,7 +285,7 @@ config VIDEO_HEXIUM_ORION
285 ---help--- 285 ---help---
286 This is a video4linux driver for the Hexium HV-PCI6 and 286 This is a video4linux driver for the Hexium HV-PCI6 and
287 Orion frame grabber cards by Hexium. 287 Orion frame grabber cards by Hexium.
288 288
289 To compile this driver as a module, choose M here: the 289 To compile this driver as a module, choose M here: the
290 module will be called hexium_orion. 290 module will be called hexium_orion.
291 291
@@ -297,7 +297,7 @@ config VIDEO_HEXIUM_GEMINI
297 This is a video4linux driver for the Hexium Gemini frame 297 This is a video4linux driver for the Hexium Gemini frame
298 grabber card by Hexium. Please note that the Gemini Dual 298 grabber card by Hexium. Please note that the Gemini Dual
299 card is *not* fully supported. 299 card is *not* fully supported.
300 300
301 To compile this driver as a module, choose M here: the 301 To compile this driver as a module, choose M here: the
302 module will be called hexium_gemini. 302 module will be called hexium_gemini.
303 303
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 1ca2b67aedfb..e61003de1d5f 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -420,7 +420,6 @@ adv7170_detect_client (struct i2c_adapter *adapter,
420 client->addr = address; 420 client->addr = address;
421 client->adapter = adapter; 421 client->adapter = adapter;
422 client->driver = &i2c_driver_adv7170; 422 client->driver = &i2c_driver_adv7170;
423 client->flags = I2C_CLIENT_ALLOW_USE;
424 if ((client->addr == I2C_ADV7170 >> 1) || 423 if ((client->addr == I2C_ADV7170 >> 1) ||
425 (client->addr == (I2C_ADV7170 >> 1) + 1)) { 424 (client->addr == (I2C_ADV7170 >> 1) + 1)) {
426 dname = adv7170_name; 425 dname = adv7170_name;
@@ -498,11 +497,11 @@ adv7170_detach_client (struct i2c_client *client)
498/* ----------------------------------------------------------------------- */ 497/* ----------------------------------------------------------------------- */
499 498
500static struct i2c_driver i2c_driver_adv7170 = { 499static struct i2c_driver i2c_driver_adv7170 = {
501 .owner = THIS_MODULE, 500 .driver = {
502 .name = "adv7170", /* name */ 501 .name = "adv7170", /* name */
502 },
503 503
504 .id = I2C_DRIVERID_ADV7170, 504 .id = I2C_DRIVERID_ADV7170,
505 .flags = I2C_DF_NOTIFY,
506 505
507 .attach_adapter = adv7170_attach_adapter, 506 .attach_adapter = adv7170_attach_adapter,
508 .detach_client = adv7170_detach_client, 507 .detach_client = adv7170_detach_client,
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 173bca1e0295..6d9536a71ee4 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -470,7 +470,6 @@ adv7175_detect_client (struct i2c_adapter *adapter,
470 client->addr = address; 470 client->addr = address;
471 client->adapter = adapter; 471 client->adapter = adapter;
472 client->driver = &i2c_driver_adv7175; 472 client->driver = &i2c_driver_adv7175;
473 client->flags = I2C_CLIENT_ALLOW_USE;
474 if ((client->addr == I2C_ADV7175 >> 1) || 473 if ((client->addr == I2C_ADV7175 >> 1) ||
475 (client->addr == (I2C_ADV7175 >> 1) + 1)) { 474 (client->addr == (I2C_ADV7175 >> 1) + 1)) {
476 dname = adv7175_name; 475 dname = adv7175_name;
@@ -548,11 +547,11 @@ adv7175_detach_client (struct i2c_client *client)
548/* ----------------------------------------------------------------------- */ 547/* ----------------------------------------------------------------------- */
549 548
550static struct i2c_driver i2c_driver_adv7175 = { 549static struct i2c_driver i2c_driver_adv7175 = {
551 .owner = THIS_MODULE, 550 .driver = {
552 .name = "adv7175", /* name */ 551 .name = "adv7175", /* name */
552 },
553 553
554 .id = I2C_DRIVERID_ADV7175, 554 .id = I2C_DRIVERID_ADV7175,
555 .flags = I2C_DF_NOTIFY,
556 555
557 .attach_adapter = adv7175_attach_adapter, 556 .attach_adapter = adv7175_attach_adapter,
558 .detach_client = adv7175_detach_client, 557 .detach_client = adv7175_detach_client,
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index 3ee0afca76a7..560b99891753 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -535,7 +535,6 @@ bt819_detect_client (struct i2c_adapter *adapter,
535 client->addr = address; 535 client->addr = address;
536 client->adapter = adapter; 536 client->adapter = adapter;
537 client->driver = &i2c_driver_bt819; 537 client->driver = &i2c_driver_bt819;
538 client->flags = I2C_CLIENT_ALLOW_USE;
539 538
540 decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL); 539 decoder = kmalloc(sizeof(struct bt819), GFP_KERNEL);
541 if (decoder == NULL) { 540 if (decoder == NULL) {
@@ -623,11 +622,11 @@ bt819_detach_client (struct i2c_client *client)
623/* ----------------------------------------------------------------------- */ 622/* ----------------------------------------------------------------------- */
624 623
625static struct i2c_driver i2c_driver_bt819 = { 624static struct i2c_driver i2c_driver_bt819 = {
626 .owner = THIS_MODULE, 625 .driver = {
627 .name = "bt819", 626 .name = "bt819",
627 },
628 628
629 .id = I2C_DRIVERID_BT819, 629 .id = I2C_DRIVERID_BT819,
630 .flags = I2C_DF_NOTIFY,
631 630
632 .attach_adapter = bt819_attach_adapter, 631 .attach_adapter = bt819_attach_adapter,
633 .detach_client = bt819_detach_client, 632 .detach_client = bt819_detach_client,
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index e4063950ae57..1c3ff5f38a6d 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -230,19 +230,18 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
230/* ----------------------------------------------------------------------- */ 230/* ----------------------------------------------------------------------- */
231 231
232static struct i2c_driver driver = { 232static struct i2c_driver driver = {
233 .owner = THIS_MODULE, 233 .driver = {
234 .name = "i2c bt832 driver", 234 .name = "i2c bt832 driver",
235 .id = -1, /* FIXME */ 235 },
236 .flags = I2C_DF_NOTIFY, 236 .id = -1, /* FIXME */
237 .attach_adapter = bt832_probe, 237 .attach_adapter = bt832_probe,
238 .detach_client = bt832_detach, 238 .detach_client = bt832_detach,
239 .command = bt832_command, 239 .command = bt832_command,
240}; 240};
241static struct i2c_client client_template = 241static struct i2c_client client_template =
242{ 242{
243 .name = "bt832", 243 .name = "bt832",
244 .flags = I2C_CLIENT_ALLOW_USE, 244 .driver = &driver,
245 .driver = &driver,
246}; 245};
247 246
248 247
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 8eb871d0e85b..60508069bbed 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -323,7 +323,6 @@ bt856_detect_client (struct i2c_adapter *adapter,
323 client->addr = address; 323 client->addr = address;
324 client->adapter = adapter; 324 client->adapter = adapter;
325 client->driver = &i2c_driver_bt856; 325 client->driver = &i2c_driver_bt856;
326 client->flags = I2C_CLIENT_ALLOW_USE;
327 strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client))); 326 strlcpy(I2C_NAME(client), "bt856", sizeof(I2C_NAME(client)));
328 327
329 encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL); 328 encoder = kmalloc(sizeof(struct bt856), GFP_KERNEL);
@@ -405,11 +404,11 @@ bt856_detach_client (struct i2c_client *client)
405/* ----------------------------------------------------------------------- */ 404/* ----------------------------------------------------------------------- */
406 405
407static struct i2c_driver i2c_driver_bt856 = { 406static struct i2c_driver i2c_driver_bt856 = {
408 .owner = THIS_MODULE, 407 .driver = {
409 .name = "bt856", 408 .name = "bt856",
409 },
410 410
411 .id = I2C_DRIVERID_BT856, 411 .id = I2C_DRIVERID_BT856,
412 .flags = I2C_DF_NOTIFY,
413 412
414 .attach_adapter = bt856_attach_adapter, 413 .attach_adapter = bt856_attach_adapter,
415 .detach_client = bt856_detach_client, 414 .detach_client = bt856_detach_client,
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 3c58a2a68906..1ddf9ba613ef 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bttv-driver.c
@@ -727,71 +727,71 @@ void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits)
727 727
728static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout) 728static void set_pll_freq(struct bttv *btv, unsigned int fin, unsigned int fout)
729{ 729{
730 unsigned char fl, fh, fi; 730 unsigned char fl, fh, fi;
731 731
732 /* prevent overflows */ 732 /* prevent overflows */
733 fin/=4; 733 fin/=4;
734 fout/=4; 734 fout/=4;
735 735
736 fout*=12; 736 fout*=12;
737 fi=fout/fin; 737 fi=fout/fin;
738 738
739 fout=(fout%fin)*256; 739 fout=(fout%fin)*256;
740 fh=fout/fin; 740 fh=fout/fin;
741 741
742 fout=(fout%fin)*256; 742 fout=(fout%fin)*256;
743 fl=fout/fin; 743 fl=fout/fin;
744 744
745 btwrite(fl, BT848_PLL_F_LO); 745 btwrite(fl, BT848_PLL_F_LO);
746 btwrite(fh, BT848_PLL_F_HI); 746 btwrite(fh, BT848_PLL_F_HI);
747 btwrite(fi|BT848_PLL_X, BT848_PLL_XCI); 747 btwrite(fi|BT848_PLL_X, BT848_PLL_XCI);
748} 748}
749 749
750static void set_pll(struct bttv *btv) 750static void set_pll(struct bttv *btv)
751{ 751{
752 int i; 752 int i;
753 753
754 if (!btv->pll.pll_crystal) 754 if (!btv->pll.pll_crystal)
755 return; 755 return;
756 756
757 if (btv->pll.pll_ofreq == btv->pll.pll_current) { 757 if (btv->pll.pll_ofreq == btv->pll.pll_current) {
758 dprintk("bttv%d: PLL: no change required\n",btv->c.nr); 758 dprintk("bttv%d: PLL: no change required\n",btv->c.nr);
759 return; 759 return;
760 } 760 }
761 761
762 if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) { 762 if (btv->pll.pll_ifreq == btv->pll.pll_ofreq) {
763 /* no PLL needed */ 763 /* no PLL needed */
764 if (btv->pll.pll_current == 0) 764 if (btv->pll.pll_current == 0)
765 return; 765 return;
766 bttv_printk(KERN_INFO "bttv%d: PLL can sleep, using XTAL (%d).\n", 766 bttv_printk(KERN_INFO "bttv%d: PLL can sleep, using XTAL (%d).\n",
767 btv->c.nr,btv->pll.pll_ifreq); 767 btv->c.nr,btv->pll.pll_ifreq);
768 btwrite(0x00,BT848_TGCTRL); 768 btwrite(0x00,BT848_TGCTRL);
769 btwrite(0x00,BT848_PLL_XCI); 769 btwrite(0x00,BT848_PLL_XCI);
770 btv->pll.pll_current = 0; 770 btv->pll.pll_current = 0;
771 return; 771 return;
772 } 772 }
773 773
774 bttv_printk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->c.nr, 774 bttv_printk(KERN_INFO "bttv%d: PLL: %d => %d ",btv->c.nr,
775 btv->pll.pll_ifreq, btv->pll.pll_ofreq); 775 btv->pll.pll_ifreq, btv->pll.pll_ofreq);
776 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq); 776 set_pll_freq(btv, btv->pll.pll_ifreq, btv->pll.pll_ofreq);
777 777
778 for (i=0; i<10; i++) { 778 for (i=0; i<10; i++) {
779 /* Let other people run while the PLL stabilizes */ 779 /* Let other people run while the PLL stabilizes */
780 bttv_printk("."); 780 bttv_printk(".");
781 msleep(10); 781 msleep(10);
782 782
783 if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) { 783 if (btread(BT848_DSTATUS) & BT848_DSTATUS_PLOCK) {
784 btwrite(0,BT848_DSTATUS); 784 btwrite(0,BT848_DSTATUS);
785 } else { 785 } else {
786 btwrite(0x08,BT848_TGCTRL); 786 btwrite(0x08,BT848_TGCTRL);
787 btv->pll.pll_current = btv->pll.pll_ofreq; 787 btv->pll.pll_current = btv->pll.pll_ofreq;
788 bttv_printk(" ok\n"); 788 bttv_printk(" ok\n");
789 return; 789 return;
790 } 790 }
791 } 791 }
792 btv->pll.pll_current = -1; 792 btv->pll.pll_current = -1;
793 bttv_printk("failed\n"); 793 bttv_printk("failed\n");
794 return; 794 return;
795} 795}
796 796
797/* used to switch between the bt848's analog/digital video capture modes */ 797/* used to switch between the bt848's analog/digital video capture modes */
@@ -1964,7 +1964,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
1964 } 1964 }
1965 1965
1966 down(&fh->cap.lock); 1966 down(&fh->cap.lock);
1967 kfree(fh->ov.clips); 1967 kfree(fh->ov.clips);
1968 fh->ov.clips = clips; 1968 fh->ov.clips = clips;
1969 fh->ov.nclips = n; 1969 fh->ov.nclips = n;
1970 1970
@@ -2758,7 +2758,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2758 fh->ov.w.height = fb->fmt.height; 2758 fh->ov.w.height = fb->fmt.height;
2759 btv->init.ov.w.width = fb->fmt.width; 2759 btv->init.ov.w.width = fb->fmt.width;
2760 btv->init.ov.w.height = fb->fmt.height; 2760 btv->init.ov.w.height = fb->fmt.height;
2761 kfree(fh->ov.clips); 2761 kfree(fh->ov.clips);
2762 fh->ov.clips = NULL; 2762 fh->ov.clips = NULL;
2763 fh->ov.nclips = 0; 2763 fh->ov.nclips = 0;
2764 2764
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bttv-i2c.c
index 77619eb131f6..d6418c023d39 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bttv-i2c.c
@@ -300,7 +300,7 @@ static int attach_inform(struct i2c_client *client)
300 300
301 if (bttv_debug) 301 if (bttv_debug)
302 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n", 302 printk(KERN_DEBUG "bttv%d: %s i2c attach [addr=0x%x,client=%s]\n",
303 btv->c.nr,client->driver->name,client->addr, 303 btv->c.nr, client->driver->driver.name, client->addr,
304 client->name); 304 client->name);
305 if (!client->driver->command) 305 if (!client->driver->command)
306 return 0; 306 return 0;
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h
index 3aa9c6e4fc33..1e6a5632c3c7 100644
--- a/drivers/media/video/bttvp.h
+++ b/drivers/media/video/bttvp.h
@@ -45,6 +45,7 @@
45#include <media/tveeprom.h> 45#include <media/tveeprom.h>
46#include <media/ir-common.h> 46#include <media/ir-common.h>
47 47
48
48#include "bt848.h" 49#include "bt848.h"
49#include "bttv.h" 50#include "bttv.h"
50#include "btcx-risc.h" 51#include "btcx-risc.h"
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index ddf184f95d80..6861d408f1b3 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -170,16 +170,9 @@ static size_t cpia_read_nibble (struct parport *port,
170 /* Does the error line indicate end of data? */ 170 /* Does the error line indicate end of data? */
171 if (((i /*& 1*/) == 0) && 171 if (((i /*& 1*/) == 0) &&
172 (parport_read_status(port) & PARPORT_STATUS_ERROR)) { 172 (parport_read_status(port) & PARPORT_STATUS_ERROR)) {
173 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; 173 DBG("%s: No more nibble data (%d bytes)\n",
174 DBG("%s: No more nibble data (%d bytes)\n", 174 port->name, i/2);
175 port->name, i/2); 175 goto end_of_data;
176
177 /* Go to reverse idle phase. */
178 parport_frob_control (port,
179 PARPORT_CONTROL_AUTOFD,
180 PARPORT_CONTROL_AUTOFD);
181 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
182 break;
183 } 176 }
184 177
185 /* Event 7: Set nAutoFd low. */ 178 /* Event 7: Set nAutoFd low. */
@@ -227,18 +220,21 @@ static size_t cpia_read_nibble (struct parport *port,
227 byte = nibble; 220 byte = nibble;
228 } 221 }
229 222
230 i /= 2; /* i is now in bytes */
231
232 if (i == len) { 223 if (i == len) {
233 /* Read the last nibble without checking data avail. */ 224 /* Read the last nibble without checking data avail. */
234 port = port->physport; 225 if (parport_read_status (port) & PARPORT_STATUS_ERROR) {
235 if (parport_read_status (port) & PARPORT_STATUS_ERROR) 226 end_of_data:
236 port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; 227 /* Go to reverse idle phase. */
228 parport_frob_control (port,
229 PARPORT_CONTROL_AUTOFD,
230 PARPORT_CONTROL_AUTOFD);
231 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
232 }
237 else 233 else
238 port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; 234 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL;
239 } 235 }
240 236
241 return i; 237 return i/2;
242} 238}
243 239
244/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1) 240/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1)
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
index 9774e94d1e7d..1439cb752874 100644
--- a/drivers/media/video/cpia_usb.c
+++ b/drivers/media/video/cpia_usb.c
@@ -582,7 +582,6 @@ MODULE_LICENSE("GPL");
582 582
583 583
584static struct usb_driver cpia_driver = { 584static struct usb_driver cpia_driver = {
585 .owner = THIS_MODULE,
586 .name = "cpia", 585 .name = "cpia",
587 .probe = cpia_probe, 586 .probe = cpia_probe,
588 .disconnect = cpia_disconnect, 587 .disconnect = cpia_disconnect,
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 780b352ec119..643ead1a87ee 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -42,15 +42,16 @@ MODULE_PARM_DESC(debug, "Debugging messages\n\t\t\t0=Off (default), 1=On");
42#define cs53l32a_dbg(fmt, arg...) \ 42#define cs53l32a_dbg(fmt, arg...) \
43 do { \ 43 do { \
44 if (debug) \ 44 if (debug) \
45 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 45 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
46 client->driver->driver.name, \
46 i2c_adapter_id(client->adapter), client->addr , ## arg); \ 47 i2c_adapter_id(client->adapter), client->addr , ## arg); \
47 } while (0) 48 } while (0)
48 49
49#define cs53l32a_err(fmt, arg...) do { \ 50#define cs53l32a_err(fmt, arg...) do { \
50 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ 51 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
51 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 52 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
52#define cs53l32a_info(fmt, arg...) do { \ 53#define cs53l32a_info(fmt, arg...) do { \
53 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ 54 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
54 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 55 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
55 56
56static unsigned short normal_i2c[] = { 0x22 >> 1, I2C_CLIENT_END }; 57static unsigned short normal_i2c[] = { 0x22 >> 1, I2C_CLIENT_END };
@@ -154,7 +155,6 @@ static int cs53l32a_attach(struct i2c_adapter *adapter, int address, int kind)
154 client->addr = address; 155 client->addr = address;
155 client->adapter = adapter; 156 client->adapter = adapter;
156 client->driver = &i2c_driver; 157 client->driver = &i2c_driver;
157 client->flags = I2C_CLIENT_ALLOW_USE;
158 snprintf(client->name, sizeof(client->name) - 1, "cs53l32a"); 158 snprintf(client->name, sizeof(client->name) - 1, "cs53l32a");
159 159
160 cs53l32a_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name); 160 cs53l32a_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name);
@@ -216,13 +216,13 @@ static int cs53l32a_detach(struct i2c_client *client)
216 216
217/* i2c implementation */ 217/* i2c implementation */
218static struct i2c_driver i2c_driver = { 218static struct i2c_driver i2c_driver = {
219 .name = "cs53l32a", 219 .driver = {
220 .name = "cs53l32a",
221 },
220 .id = I2C_DRIVERID_CS53L32A, 222 .id = I2C_DRIVERID_CS53L32A,
221 .flags = I2C_DF_NOTIFY,
222 .attach_adapter = cs53l32a_probe, 223 .attach_adapter = cs53l32a_probe,
223 .detach_client = cs53l32a_detach, 224 .detach_client = cs53l32a_detach,
224 .command = cs53l32a_command, 225 .command = cs53l32a_command,
225 .owner = THIS_MODULE,
226}; 226};
227 227
228 228
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index aea3f038cff6..3b09f46dddf6 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -333,24 +333,30 @@ static int set_input(struct i2c_client *client, enum cx25840_input input)
333 333
334static int set_v4lstd(struct i2c_client *client, v4l2_std_id std) 334static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
335{ 335{
336 u8 fmt; 336 u8 fmt=0; /* zero is autodetect */
337 337
338 switch (std) { 338 /* First tests should be against specific std */
339 /* zero is autodetect */ 339 if (std & V4L2_STD_NTSC_M_JP) {
340 case 0: fmt = 0x0; break; 340 fmt=0x2;
341 /* default ntsc to ntsc-m */ 341 } else if (std & V4L2_STD_NTSC_443) {
342 case V4L2_STD_NTSC: 342 fmt=0x3;
343 case V4L2_STD_NTSC_M: fmt = 0x1; break; 343 } else if (std & V4L2_STD_PAL_M) {
344 case V4L2_STD_NTSC_M_JP: fmt = 0x2; break; 344 fmt=0x5;
345 case V4L2_STD_NTSC_443: fmt = 0x3; break; 345 } else if (std & V4L2_STD_PAL_N) {
346 case V4L2_STD_PAL: fmt = 0x4; break; 346 fmt=0x6;
347 case V4L2_STD_PAL_M: fmt = 0x5; break; 347 } else if (std & V4L2_STD_PAL_Nc) {
348 case V4L2_STD_PAL_N: fmt = 0x6; break; 348 fmt=0x7;
349 case V4L2_STD_PAL_Nc: fmt = 0x7; break; 349 } else if (std & V4L2_STD_PAL_60) {
350 case V4L2_STD_PAL_60: fmt = 0x8; break; 350 fmt=0x8;
351 case V4L2_STD_SECAM: fmt = 0xc; break; 351 } else {
352 default: 352 /* Then, test against generic ones */
353 return -ERANGE; 353 if (std & V4L2_STD_NTSC) {
354 fmt=0x1;
355 } else if (std & V4L2_STD_PAL) {
356 fmt=0x4;
357 } else if (std & V4L2_STD_SECAM) {
358 fmt=0xc;
359 }
354 } 360 }
355 361
356 cx25840_and_or(client, 0x400, ~0xf, fmt); 362 cx25840_and_or(client, 0x400, ~0xf, fmt);
@@ -767,7 +773,6 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
767 client->addr = address; 773 client->addr = address;
768 client->adapter = adapter; 774 client->adapter = adapter;
769 client->driver = &i2c_driver_cx25840; 775 client->driver = &i2c_driver_cx25840;
770 client->flags = I2C_CLIENT_ALLOW_USE;
771 snprintf(client->name, sizeof(client->name) - 1, "cx25840"); 776 snprintf(client->name, sizeof(client->name) - 1, "cx25840");
772 777
773 cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1); 778 cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1);
@@ -838,15 +843,15 @@ static int cx25840_detach_client(struct i2c_client *client)
838/* ----------------------------------------------------------------------- */ 843/* ----------------------------------------------------------------------- */
839 844
840static struct i2c_driver i2c_driver_cx25840 = { 845static struct i2c_driver i2c_driver_cx25840 = {
841 .name = "cx25840", 846 .driver = {
847 .name = "cx25840",
848 },
842 849
843 .id = I2C_DRIVERID_CX25840, 850 .id = I2C_DRIVERID_CX25840,
844 .flags = I2C_DF_NOTIFY,
845 851
846 .attach_adapter = cx25840_attach_adapter, 852 .attach_adapter = cx25840_attach_adapter,
847 .detach_client = cx25840_detach_client, 853 .detach_client = cx25840_detach_client,
848 .command = cx25840_command, 854 .command = cx25840_command,
849 .owner = THIS_MODULE,
850}; 855};
851 856
852 857
diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840.h
index 4932ed1c9b19..40aa59f9c525 100644
--- a/drivers/media/video/cx25840/cx25840.h
+++ b/drivers/media/video/cx25840/cx25840.h
@@ -27,15 +27,16 @@
27extern int cx25840_debug; 27extern int cx25840_debug;
28 28
29#define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \ 29#define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \
30 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 30 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
31 client->driver->driver.name, \
31 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 32 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
32 33
33#define cx25840_err(fmt, arg...) do { \ 34#define cx25840_err(fmt, arg...) do { \
34 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ 35 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
35 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 36 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
36 37
37#define cx25840_info(fmt, arg...) do { \ 38#define cx25840_info(fmt, arg...) do { \
38 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ 39 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
39 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 40 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
40 41
41#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0) 42#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0)
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index 4ae3f78cccf2..74e57a53116f 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -616,6 +616,8 @@ static int blackbird_load_firmware(struct cx8802_dev *dev)
616 616
617 retval = request_firmware(&firmware, BLACKBIRD_FIRM_ENC_FILENAME, 617 retval = request_firmware(&firmware, BLACKBIRD_FIRM_ENC_FILENAME,
618 &dev->pci->dev); 618 &dev->pci->dev);
619
620
619 if (retval != 0) { 621 if (retval != 0) {
620 dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n", 622 dprintk(0, "ERROR: Hotplug firmware request failed (%s).\n",
621 BLACKBIRD_FIRM_ENC_FILENAME); 623 BLACKBIRD_FIRM_ENC_FILENAME);
diff --git a/drivers/media/video/cx88/cx88-i2c.c b/drivers/media/video/cx88/cx88-i2c.c
index 9790d412f192..4a8fb161b16a 100644
--- a/drivers/media/video/cx88/cx88-i2c.c
+++ b/drivers/media/video/cx88/cx88-i2c.c
@@ -94,7 +94,7 @@ static int attach_inform(struct i2c_client *client)
94 struct cx88_core *core = i2c_get_adapdata(client->adapter); 94 struct cx88_core *core = i2c_get_adapdata(client->adapter);
95 95
96 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n", 96 dprintk(1, "%s i2c attach [addr=0x%x,client=%s]\n",
97 client->driver->name, client->addr, client->name); 97 client->driver->driver.name, client->addr, client->name);
98 if (!client->driver->command) 98 if (!client->driver->command)
99 return 0; 99 return 0;
100 100
diff --git a/drivers/media/video/cx88/cx88-input.c b/drivers/media/video/cx88/cx88-input.c
index 38b12ebaa49e..461019dca901 100644
--- a/drivers/media/video/cx88/cx88-input.c
+++ b/drivers/media/video/cx88/cx88-input.c
@@ -453,7 +453,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)
453 input_dev->id.product = pci->device; 453 input_dev->id.product = pci->device;
454 } 454 }
455 input_dev->cdev.dev = &pci->dev; 455 input_dev->cdev.dev = &pci->dev;
456
457 /* record handles to ourself */ 456 /* record handles to ourself */
458 ir->core = core; 457 ir->core = core;
459 core->ir = ir; 458 core->ir = ir;
@@ -586,7 +585,6 @@ void cx88_ir_irq(struct cx88_core *core)
586MODULE_AUTHOR("Gerd Knorr, Pavel Machek, Chris Pascoe"); 585MODULE_AUTHOR("Gerd Knorr, Pavel Machek, Chris Pascoe");
587MODULE_DESCRIPTION("input driver for cx88 GPIO-based IR remote controls"); 586MODULE_DESCRIPTION("input driver for cx88 GPIO-based IR remote controls");
588MODULE_LICENSE("GPL"); 587MODULE_LICENSE("GPL");
589
590/* 588/*
591 * Local variables: 589 * Local variables:
592 * c-basic-offset: 8 590 * c-basic-offset: 8
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index 27fb080fd7aa..77beafc5c327 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -411,7 +411,6 @@ struct cx8802_dev {
411 struct videobuf_dvb dvb; 411 struct videobuf_dvb dvb;
412 void* fe_handle; 412 void* fe_handle;
413 int (*fe_release)(void *handle); 413 int (*fe_release)(void *handle);
414
415 /* for switching modulation types */ 414 /* for switching modulation types */
416 unsigned char ts_gen_cntrl; 415 unsigned char ts_gen_cntrl;
417 416
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 9f6e5e5355a1..0cfe75416ec6 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -116,47 +116,6 @@ void em28xx_print_ioctl(char *name, unsigned int cmd)
116 } 116 }
117} 117}
118 118
119static void *rvmalloc(size_t size)
120{
121 void *mem;
122 unsigned long adr;
123
124 size = PAGE_ALIGN(size);
125
126 mem = vmalloc_32((unsigned long)size);
127 if (!mem)
128 return NULL;
129
130 memset(mem, 0, size);
131
132 adr = (unsigned long)mem;
133 while (size > 0) {
134 SetPageReserved(vmalloc_to_page((void *)adr));
135 adr += PAGE_SIZE;
136 size -= PAGE_SIZE;
137 }
138
139 return mem;
140}
141
142static void rvfree(void *mem, size_t size)
143{
144 unsigned long adr;
145
146 if (!mem)
147 return;
148
149 size = PAGE_ALIGN(size);
150
151 adr = (unsigned long)mem;
152 while (size > 0) {
153 ClearPageReserved(vmalloc_to_page((void *)adr));
154 adr += PAGE_SIZE;
155 size -= PAGE_SIZE;
156 }
157
158 vfree(mem);
159}
160 119
161/* 120/*
162 * em28xx_request_buffers() 121 * em28xx_request_buffers()
@@ -167,14 +126,16 @@ u32 em28xx_request_buffers(struct em28xx *dev, u32 count)
167 const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */ 126 const size_t imagesize = PAGE_ALIGN(dev->frame_size); /*needs to be page aligned cause the buffers can be mapped individually! */
168 void *buff = NULL; 127 void *buff = NULL;
169 u32 i; 128 u32 i;
170 em28xx_coredbg("requested %i buffers with size %i", count, imagesize); 129 em28xx_coredbg("requested %i buffers with size %zd", count, imagesize);
171 if (count > EM28XX_NUM_FRAMES) 130 if (count > EM28XX_NUM_FRAMES)
172 count = EM28XX_NUM_FRAMES; 131 count = EM28XX_NUM_FRAMES;
173 132
174 dev->num_frames = count; 133 dev->num_frames = count;
175 while (dev->num_frames > 0) { 134 while (dev->num_frames > 0) {
176 if ((buff = rvmalloc(dev->num_frames * imagesize))) 135 if ((buff = vmalloc_32(dev->num_frames * imagesize))) {
136 memset(buff, 0, dev->num_frames * imagesize);
177 break; 137 break;
138 }
178 dev->num_frames--; 139 dev->num_frames--;
179 } 140 }
180 141
@@ -217,8 +178,7 @@ void em28xx_queue_unusedframes(struct em28xx *dev)
217void em28xx_release_buffers(struct em28xx *dev) 178void em28xx_release_buffers(struct em28xx *dev)
218{ 179{
219 if (dev->num_frames) { 180 if (dev->num_frames) {
220 rvfree(dev->frame[0].bufmem, 181 vfree(dev->frame[0].bufmem);
221 dev->num_frames * PAGE_ALIGN(dev->frame[0].buf.length));
222 dev->num_frames = 0; 182 dev->num_frames = 0;
223 } 183 }
224} 184}
diff --git a/drivers/media/video/em28xx/em28xx-i2c.c b/drivers/media/video/em28xx/em28xx-i2c.c
index b32d9852f34c..d14bcf4ceaea 100644
--- a/drivers/media/video/em28xx/em28xx-i2c.c
+++ b/drivers/media/video/em28xx/em28xx-i2c.c
@@ -41,7 +41,7 @@ module_param(i2c_debug, int, 0644);
41MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]"); 41MODULE_PARM_DESC(i2c_debug, "enable debug messages [i2c]");
42 42
43#define dprintk1(lvl,fmt, args...) if (i2c_debug>=lvl) do {\ 43#define dprintk1(lvl,fmt, args...) if (i2c_debug>=lvl) do {\
44 printk(fmt , ##args); } while (0) 44 printk(fmt, ##args); } while (0)
45#define dprintk2(lvl,fmt, args...) if (i2c_debug>=lvl) do{ \ 45#define dprintk2(lvl,fmt, args...) if (i2c_debug>=lvl) do{ \
46 printk(KERN_DEBUG "%s at %s: " fmt, \ 46 printk(KERN_DEBUG "%s at %s: " fmt, \
47 dev->name, __FUNCTION__ , ##args); } while (0) 47 dev->name, __FUNCTION__ , ##args); } while (0)
@@ -497,7 +497,6 @@ static struct i2c_adapter em28xx_adap_template = {
497 497
498static struct i2c_client em28xx_client_template = { 498static struct i2c_client em28xx_client_template = {
499 .name = "em28xx internal", 499 .name = "em28xx internal",
500 .flags = I2C_CLIENT_ALLOW_USE,
501}; 500};
502 501
503/* ----------------------------------------------------------- */ 502/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index abec32c175aa..3a56120397ae 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -189,16 +189,6 @@ static DECLARE_RWSEM(em28xx_disconnect);
189 189
190/********************* v4l2 interface ******************************************/ 190/********************* v4l2 interface ******************************************/
191 191
192static inline unsigned long kvirt_to_pa(unsigned long adr)
193{
194 unsigned long kva, ret;
195
196 kva = (unsigned long)page_address(vmalloc_to_page((void *)adr));
197 kva |= adr & (PAGE_SIZE - 1);
198 ret = __pa(kva);
199 return ret;
200}
201
202/* 192/*
203 * em28xx_config() 193 * em28xx_config()
204 * inits registers with sane defaults 194 * inits registers with sane defaults
@@ -616,7 +606,8 @@ static struct vm_operations_struct em28xx_vm_ops = {
616static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) 606static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
617{ 607{
618 unsigned long size = vma->vm_end - vma->vm_start, 608 unsigned long size = vma->vm_end - vma->vm_start,
619 start = vma->vm_start, pos, page; 609 start = vma->vm_start;
610 void *pos;
620 u32 i; 611 u32 i;
621 612
622 struct em28xx *dev = filp->private_data; 613 struct em28xx *dev = filp->private_data;
@@ -657,12 +648,10 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
657 vma->vm_flags |= VM_IO; 648 vma->vm_flags |= VM_IO;
658 vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */ 649 vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */
659 650
660 pos = (unsigned long)dev->frame[i].bufmem; 651 pos = dev->frame[i].bufmem;
661 while (size > 0) { /* size is page-aligned */ 652 while (size > 0) { /* size is page-aligned */
662 page = vmalloc_to_pfn((void *)pos); 653 if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
663 if (remap_pfn_range(vma, start, page, PAGE_SIZE, 654 em28xx_videodbg("mmap: vm_insert_page failed\n");
664 vma->vm_page_prot)) {
665 em28xx_videodbg("mmap: rename page map failed\n");
666 up(&dev->fileop_lock); 655 up(&dev->fileop_lock);
667 return -EAGAIN; 656 return -EAGAIN;
668 } 657 }
@@ -1895,7 +1884,6 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
1895} 1884}
1896 1885
1897static struct usb_driver em28xx_usb_driver = { 1886static struct usb_driver em28xx_usb_driver = {
1898 .owner = THIS_MODULE,
1899 .name = "em28xx", 1887 .name = "em28xx",
1900 .probe = em28xx_usb_probe, 1888 .probe = em28xx_usb_probe,
1901 .disconnect = em28xx_usb_disconnect, 1889 .disconnect = em28xx_usb_disconnect,
diff --git a/drivers/media/video/indycam.c b/drivers/media/video/indycam.c
index deeef125eb92..bb5cbecffcc3 100644
--- a/drivers/media/video/indycam.c
+++ b/drivers/media/video/indycam.c
@@ -451,10 +451,10 @@ static int indycam_command(struct i2c_client *client, unsigned int cmd,
451} 451}
452 452
453static struct i2c_driver i2c_driver_indycam = { 453static struct i2c_driver i2c_driver_indycam = {
454 .owner = THIS_MODULE, 454 .driver = {
455 .name = "indycam", 455 .name = "indycam",
456 },
456 .id = I2C_DRIVERID_INDYCAM, 457 .id = I2C_DRIVERID_INDYCAM,
457 .flags = I2C_DF_NOTIFY,
458 .attach_adapter = indycam_probe, 458 .attach_adapter = indycam_probe,
459 .detach_client = indycam_detach, 459 .detach_client = indycam_detach,
460 .command = indycam_command, 460 .command = indycam_command,
diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c
index 6345e29e4951..de1385e5d05e 100644
--- a/drivers/media/video/ir-kbd-gpio.c
+++ b/drivers/media/video/ir-kbd-gpio.c
@@ -291,13 +291,12 @@ struct IR {
291 u32 mask_keycode; 291 u32 mask_keycode;
292 u32 mask_keydown; 292 u32 mask_keydown;
293 u32 mask_keyup; 293 u32 mask_keyup;
294 u32 polling; 294 u32 polling;
295 u32 last_gpio; 295 u32 last_gpio;
296 struct work_struct work; 296 struct work_struct work;
297 struct timer_list timer; 297 struct timer_list timer;
298 298
299 /* RC5 gpio */ 299 /* RC5 gpio */
300
301 u32 rc5_gpio; 300 u32 rc5_gpio;
302 struct timer_list timer_end; /* timer_end for code completion */ 301 struct timer_list timer_end; /* timer_end for code completion */
303 struct timer_list timer_keyup; /* timer_end for key release */ 302 struct timer_list timer_keyup; /* timer_end for key release */
@@ -647,7 +646,7 @@ static int ir_probe(struct device *dev)
647 driver.any_irq = ir_rc5_irq; 646 driver.any_irq = ir_rc5_irq;
648 driver.gpio_irq = NULL; 647 driver.gpio_irq = NULL;
649 ir->rc5_gpio = 1; 648 ir->rc5_gpio = 1;
650 break; 649 break;
651 } 650 }
652 if (NULL == ir_codes) { 651 if (NULL == ir_codes) {
653 kfree(ir); 652 kfree(ir);
@@ -657,7 +656,7 @@ static int ir_probe(struct device *dev)
657 656
658 if (ir->rc5_gpio) { 657 if (ir->rc5_gpio) {
659 u32 gpio; 658 u32 gpio;
660 /* enable remote irq */ 659 /* enable remote irq */
661 bttv_gpio_inout(sub->core, (1 << 4), 1 << 4); 660 bttv_gpio_inout(sub->core, (1 << 4), 1 << 4);
662 gpio = bttv_gpio_read(sub->core); 661 gpio = bttv_gpio_read(sub->core);
663 bttv_gpio_write(sub->core, gpio & ~(1 << 4)); 662 bttv_gpio_write(sub->core, gpio & ~(1 << 4));
@@ -726,6 +725,7 @@ static int ir_remove(struct device *dev)
726 del_timer(&ir->timer); 725 del_timer(&ir->timer);
727 flush_scheduled_work(); 726 flush_scheduled_work();
728 } 727 }
728
729 if (ir->rc5_gpio) { 729 if (ir->rc5_gpio) {
730 u32 gpio; 730 u32 gpio;
731 731
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 124c502ea1f3..3cc1d6a6019b 100644
--- a/drivers/media/video/ir-kbd-i2c.c
+++ b/drivers/media/video/ir-kbd-i2c.c
@@ -40,6 +40,7 @@
40#include <linux/i2c.h> 40#include <linux/i2c.h>
41#include <linux/workqueue.h> 41#include <linux/workqueue.h>
42#include <asm/semaphore.h> 42#include <asm/semaphore.h>
43
43#include <media/ir-common.h> 44#include <media/ir-common.h>
44#include <media/ir-kbd-i2c.h> 45#include <media/ir-kbd-i2c.h>
45 46
@@ -277,9 +278,10 @@ static int ir_detach(struct i2c_client *client);
277static int ir_probe(struct i2c_adapter *adap); 278static int ir_probe(struct i2c_adapter *adap);
278 279
279static struct i2c_driver driver = { 280static struct i2c_driver driver = {
280 .name = "ir remote kbd driver", 281 .driver = {
281 .id = I2C_DRIVERID_I2C_IR, 282 .name = "ir remote kbd driver",
282 .flags = I2C_DF_NOTIFY, 283 },
284 .id = I2C_DRIVERID_INFRARED,
283 .attach_adapter = ir_probe, 285 .attach_adapter = ir_probe,
284 .detach_client = ir_detach, 286 .detach_client = ir_detach,
285}; 287};
@@ -296,15 +298,15 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
296 IR_KEYTAB_TYPE *ir_codes = NULL; 298 IR_KEYTAB_TYPE *ir_codes = NULL;
297 char *name; 299 char *name;
298 int ir_type; 300 int ir_type;
299 struct IR_i2c *ir; 301 struct IR_i2c *ir;
300 struct input_dev *input_dev; 302 struct input_dev *input_dev;
301 303
302 ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL); 304 ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL);
303 input_dev = input_allocate_device(); 305 input_dev = input_allocate_device();
304 if (!ir || !input_dev) { 306 if (!ir || !input_dev) {
305 kfree(ir); 307 kfree(ir);
306 input_free_device(input_dev); 308 input_free_device(input_dev);
307 return -ENOMEM; 309 return -ENOMEM;
308 } 310 }
309 311
310 ir->c = client_template; 312 ir->c = client_template;
@@ -360,7 +362,7 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
360 /* register i2c device 362 /* register i2c device
361 * At device register, IR codes may be changed to be 363 * At device register, IR codes may be changed to be
362 * board dependent. 364 * board dependent.
363 */ 365 */
364 i2c_attach_client(&ir->c); 366 i2c_attach_client(&ir->c);
365 367
366 /* If IR not supported or disabled, unregisters driver */ 368 /* If IR not supported or disabled, unregisters driver */
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index a23fb0338986..183253e2dd91 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -59,7 +59,8 @@
59#define msp3400_dbg(fmt, arg...) \ 59#define msp3400_dbg(fmt, arg...) \
60 do { \ 60 do { \
61 if (debug) \ 61 if (debug) \
62 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 62 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
63 client->driver->driver.name, \
63 i2c_adapter_id(client->adapter), client->addr , ## arg); \ 64 i2c_adapter_id(client->adapter), client->addr , ## arg); \
64 } while (0) 65 } while (0)
65 66
@@ -67,7 +68,8 @@
67#define msp3400_dbg_mediumvol(fmt, arg...) \ 68#define msp3400_dbg_mediumvol(fmt, arg...) \
68 do { \ 69 do { \
69 if (debug >= 2) \ 70 if (debug >= 2) \
70 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 71 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
72 client->driver->driver.name, \
71 i2c_adapter_id(client->adapter), client->addr , ## arg); \ 73 i2c_adapter_id(client->adapter), client->addr , ## arg); \
72 } while (0) 74 } while (0)
73 75
@@ -75,18 +77,19 @@
75#define msp3400_dbg_highvol(fmt, arg...) \ 77#define msp3400_dbg_highvol(fmt, arg...) \
76 do { \ 78 do { \
77 if (debug >= 16) \ 79 if (debug >= 16) \
78 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 80 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
81 client->driver->driver.name, \
79 i2c_adapter_id(client->adapter), client->addr , ## arg); \ 82 i2c_adapter_id(client->adapter), client->addr , ## arg); \
80 } while (0) 83 } while (0)
81 84
82#define msp3400_err(fmt, arg...) do { \ 85#define msp3400_err(fmt, arg...) do { \
83 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ 86 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
84 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 87 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
85#define msp3400_warn(fmt, arg...) do { \ 88#define msp3400_warn(fmt, arg...) do { \
86 printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->name, \ 89 printk(KERN_WARNING "%s %d-%04x: " fmt, client->driver->driver.name, \
87 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 90 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
88#define msp3400_info(fmt, arg...) do { \ 91#define msp3400_info(fmt, arg...) do { \
89 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ 92 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
90 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 93 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
91 94
92#define OPMODE_AUTO -1 95#define OPMODE_AUTO -1
@@ -134,7 +137,7 @@ struct msp3400c {
134 int rxsubchans; 137 int rxsubchans;
135 138
136 int muted; 139 int muted;
137 int left, right; /* volume */ 140 int left, right; /* volume */
138 int bass, treble; 141 int bass, treble;
139 142
140 /* shadow register set */ 143 /* shadow register set */
@@ -882,6 +885,7 @@ static void watch_stereo(struct i2c_client *client)
882 msp->watch_stereo = 0; 885 msp->watch_stereo = 0;
883} 886}
884 887
888
885static int msp3400c_thread(void *data) 889static int msp3400c_thread(void *data)
886{ 890{
887 struct i2c_client *client = data; 891 struct i2c_client *client = data;
@@ -889,6 +893,7 @@ static int msp3400c_thread(void *data)
889 struct CARRIER_DETECT *cd; 893 struct CARRIER_DETECT *cd;
890 int count, max1,max2,val1,val2, val,this; 894 int count, max1,max2,val1,val2, val,this;
891 895
896
892 msp3400_info("msp3400 daemon started\n"); 897 msp3400_info("msp3400 daemon started\n");
893 for (;;) { 898 for (;;) {
894 msp3400_dbg_mediumvol("msp3400 thread: sleep\n"); 899 msp3400_dbg_mediumvol("msp3400 thread: sleep\n");
@@ -1162,6 +1167,7 @@ static int msp3410d_thread(void *data)
1162 int mode,val,i,std; 1167 int mode,val,i,std;
1163 1168
1164 msp3400_info("msp3410 daemon started\n"); 1169 msp3400_info("msp3410 daemon started\n");
1170
1165 for (;;) { 1171 for (;;) {
1166 msp3400_dbg_mediumvol("msp3410 thread: sleep\n"); 1172 msp3400_dbg_mediumvol("msp3410 thread: sleep\n");
1167 msp34xx_sleep(msp,-1); 1173 msp34xx_sleep(msp,-1);
@@ -1384,6 +1390,7 @@ static int msp34xxg_thread(void *data)
1384 int val, std, i; 1390 int val, std, i;
1385 1391
1386 msp3400_info("msp34xxg daemon started\n"); 1392 msp3400_info("msp34xxg daemon started\n");
1393
1387 msp->source = 1; /* default */ 1394 msp->source = 1; /* default */
1388 for (;;) { 1395 for (;;) {
1389 msp3400_dbg_mediumvol("msp34xxg thread: sleep\n"); 1396 msp3400_dbg_mediumvol("msp34xxg thread: sleep\n");
@@ -1557,14 +1564,12 @@ static int msp_resume(struct device * dev);
1557static void msp_wake_thread(struct i2c_client *client); 1564static void msp_wake_thread(struct i2c_client *client);
1558 1565
1559static struct i2c_driver driver = { 1566static struct i2c_driver driver = {
1560 .owner = THIS_MODULE, 1567 .id = I2C_DRIVERID_MSP3400,
1561 .name = "msp3400", 1568 .attach_adapter = msp_probe,
1562 .id = I2C_DRIVERID_MSP3400, 1569 .detach_client = msp_detach,
1563 .flags = I2C_DF_NOTIFY, 1570 .command = msp_command,
1564 .attach_adapter = msp_probe,
1565 .detach_client = msp_detach,
1566 .command = msp_command,
1567 .driver = { 1571 .driver = {
1572 .name = "i2c msp3400 driver",
1568 .suspend = msp_suspend, 1573 .suspend = msp_suspend,
1569 .resume = msp_resume, 1574 .resume = msp_resume,
1570 }, 1575 },
@@ -1573,8 +1578,7 @@ static struct i2c_driver driver = {
1573static struct i2c_client client_template = 1578static struct i2c_client client_template =
1574{ 1579{
1575 .name = "(unset)", 1580 .name = "(unset)",
1576 .flags = I2C_CLIENT_ALLOW_USE, 1581 .driver = &driver,
1577 .driver = &driver,
1578}; 1582};
1579 1583
1580static int msp_attach(struct i2c_adapter *adap, int addr, int kind) 1584static int msp_attach(struct i2c_adapter *adap, int addr, int kind)
diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
index 2de34ebf0673..428f1bb75ec3 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_core.c
+++ b/drivers/media/video/ovcamchip/ovcamchip_core.c
@@ -410,11 +410,11 @@ static int ovcamchip_command(struct i2c_client *c, unsigned int cmd, void *arg)
410/* ----------------------------------------------------------------------- */ 410/* ----------------------------------------------------------------------- */
411 411
412static struct i2c_driver driver = { 412static struct i2c_driver driver = {
413 .owner = THIS_MODULE, 413 .driver = {
414 .name = "ovcamchip", 414 .name = "ovcamchip",
415 },
415 .id = I2C_DRIVERID_OVCAMCHIP, 416 .id = I2C_DRIVERID_OVCAMCHIP,
416 .class = I2C_CLASS_CAM_DIGITAL, 417 .class = I2C_CLASS_CAM_DIGITAL,
417 .flags = I2C_DF_NOTIFY,
418 .attach_adapter = ovcamchip_attach, 418 .attach_adapter = ovcamchip_attach,
419 .detach_client = ovcamchip_detach, 419 .detach_client = ovcamchip_detach,
420 .command = ovcamchip_command, 420 .command = ovcamchip_command,
diff --git a/drivers/media/video/saa5246a.c b/drivers/media/video/saa5246a.c
index b8054da31ffd..0aa9e72f632c 100644
--- a/drivers/media/video/saa5246a.c
+++ b/drivers/media/video/saa5246a.c
@@ -151,25 +151,18 @@ static int saa5246a_detach(struct i2c_client *client)
151 return 0; 151 return 0;
152} 152}
153 153
154static int saa5246a_command(struct i2c_client *device, unsigned int cmd,
155 void *arg)
156{
157 return -EINVAL;
158}
159
160/* 154/*
161 * I2C interfaces 155 * I2C interfaces
162 */ 156 */
163 157
164static struct i2c_driver i2c_driver_videotext = 158static struct i2c_driver i2c_driver_videotext =
165{ 159{
166 .owner = THIS_MODULE, 160 .driver = {
167 .name = IF_NAME, /* name */ 161 .name = IF_NAME, /* name */
162 },
168 .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ 163 .id = I2C_DRIVERID_SAA5249, /* in i2c.h */
169 .flags = I2C_DF_NOTIFY,
170 .attach_adapter = saa5246a_probe, 164 .attach_adapter = saa5246a_probe,
171 .detach_client = saa5246a_detach, 165 .detach_client = saa5246a_detach,
172 .command = saa5246a_command
173}; 166};
174 167
175static struct i2c_client client_template = { 168static struct i2c_client client_template = {
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index 7ffa2e9a9bf3..a51c7bd96618 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -226,23 +226,16 @@ static int saa5249_detach(struct i2c_client *client)
226 return 0; 226 return 0;
227} 227}
228 228
229static int saa5249_command(struct i2c_client *device,
230 unsigned int cmd, void *arg)
231{
232 return -EINVAL;
233}
234
235/* new I2C driver support */ 229/* new I2C driver support */
236 230
237static struct i2c_driver i2c_driver_videotext = 231static struct i2c_driver i2c_driver_videotext =
238{ 232{
239 .owner = THIS_MODULE, 233 .driver = {
240 .name = IF_NAME, /* name */ 234 .name = IF_NAME, /* name */
235 },
241 .id = I2C_DRIVERID_SAA5249, /* in i2c.h */ 236 .id = I2C_DRIVERID_SAA5249, /* in i2c.h */
242 .flags = I2C_DF_NOTIFY,
243 .attach_adapter = saa5249_probe, 237 .attach_adapter = saa5249_probe,
244 .detach_client = saa5249_detach, 238 .detach_client = saa5249_detach,
245 .command = saa5249_command
246}; 239};
247 240
248static struct i2c_client client_template = { 241static struct i2c_client client_template = {
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index dca3ddfd510f..d60a783e0473 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -422,7 +422,6 @@ static int saa6588_attach(struct i2c_adapter *adap, int addr, int kind)
422 s->timer.function = saa6588_timer; 422 s->timer.function = saa6588_timer;
423 s->timer.data = (unsigned long)s; 423 s->timer.data = (unsigned long)s;
424 schedule_work(&s->work); 424 schedule_work(&s->work);
425
426 return 0; 425 return 0;
427} 426}
428 427
@@ -496,10 +495,10 @@ static int saa6588_command(struct i2c_client *client, unsigned int cmd,
496/* ----------------------------------------------------------------------- */ 495/* ----------------------------------------------------------------------- */
497 496
498static struct i2c_driver driver = { 497static struct i2c_driver driver = {
499 .owner = THIS_MODULE, 498 .driver = {
500 .name = "i2c saa6588 driver", 499 .name = "i2c saa6588 driver",
500 },
501 .id = -1, /* FIXME */ 501 .id = -1, /* FIXME */
502 .flags = I2C_DF_NOTIFY,
503 .attach_adapter = saa6588_probe, 502 .attach_adapter = saa6588_probe,
504 .detach_client = saa6588_detach, 503 .detach_client = saa6588_detach,
505 .command = saa6588_command, 504 .command = saa6588_command,
@@ -507,7 +506,6 @@ static struct i2c_driver driver = {
507 506
508static struct i2c_client client_template = { 507static struct i2c_client client_template = {
509 .name = "saa6588", 508 .name = "saa6588",
510 .flags = I2C_CLIENT_ALLOW_USE,
511 .driver = &driver, 509 .driver = &driver,
512}; 510};
513 511
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index e116bdbed310..619ff0b7a1ff 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -501,7 +501,6 @@ saa7110_detect_client (struct i2c_adapter *adapter,
501 client->addr = address; 501 client->addr = address;
502 client->adapter = adapter; 502 client->adapter = adapter;
503 client->driver = &i2c_driver_saa7110; 503 client->driver = &i2c_driver_saa7110;
504 client->flags = I2C_CLIENT_ALLOW_USE;
505 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client))); 504 strlcpy(I2C_NAME(client), "saa7110", sizeof(I2C_NAME(client)));
506 505
507 decoder = kmalloc(sizeof(struct saa7110), GFP_KERNEL); 506 decoder = kmalloc(sizeof(struct saa7110), GFP_KERNEL);
@@ -587,11 +586,11 @@ saa7110_detach_client (struct i2c_client *client)
587/* ----------------------------------------------------------------------- */ 586/* ----------------------------------------------------------------------- */
588 587
589static struct i2c_driver i2c_driver_saa7110 = { 588static struct i2c_driver i2c_driver_saa7110 = {
590 .owner = THIS_MODULE, 589 .driver = {
591 .name = "saa7110", 590 .name = "saa7110",
591 },
592 592
593 .id = I2C_DRIVERID_SAA7110, 593 .id = I2C_DRIVERID_SAA7110,
594 .flags = I2C_DF_NOTIFY,
595 594
596 .attach_adapter = saa7110_attach_adapter, 595 .attach_adapter = saa7110_attach_adapter,
597 .detach_client = saa7110_detach_client, 596 .detach_client = saa7110_detach_client,
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index fe8a5e453969..acaeee592b54 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -518,7 +518,6 @@ saa7111_detect_client (struct i2c_adapter *adapter,
518 client->addr = address; 518 client->addr = address;
519 client->adapter = adapter; 519 client->adapter = adapter;
520 client->driver = &i2c_driver_saa7111; 520 client->driver = &i2c_driver_saa7111;
521 client->flags = I2C_CLIENT_ALLOW_USE;
522 strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client))); 521 strlcpy(I2C_NAME(client), "saa7111", sizeof(I2C_NAME(client)));
523 522
524 decoder = kmalloc(sizeof(struct saa7111), GFP_KERNEL); 523 decoder = kmalloc(sizeof(struct saa7111), GFP_KERNEL);
@@ -590,11 +589,11 @@ saa7111_detach_client (struct i2c_client *client)
590/* ----------------------------------------------------------------------- */ 589/* ----------------------------------------------------------------------- */
591 590
592static struct i2c_driver i2c_driver_saa7111 = { 591static struct i2c_driver i2c_driver_saa7111 = {
593 .owner = THIS_MODULE, 592 .driver = {
594 .name = "saa7111", 593 .name = "saa7111",
594 },
595 595
596 .id = I2C_DRIVERID_SAA7111A, 596 .id = I2C_DRIVERID_SAA7111A,
597 .flags = I2C_DF_NOTIFY,
598 597
599 .attach_adapter = saa7111_attach_adapter, 598 .attach_adapter = saa7111_attach_adapter,
600 .detach_client = saa7111_detach_client, 599 .detach_client = saa7111_detach_client,
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index d9f50e2f7b92..b7ac0122f729 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -859,7 +859,6 @@ saa7114_detect_client (struct i2c_adapter *adapter,
859 client->addr = address; 859 client->addr = address;
860 client->adapter = adapter; 860 client->adapter = adapter;
861 client->driver = &i2c_driver_saa7114; 861 client->driver = &i2c_driver_saa7114;
862 client->flags = I2C_CLIENT_ALLOW_USE;
863 strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client))); 862 strlcpy(I2C_NAME(client), "saa7114", sizeof(I2C_NAME(client)));
864 863
865 decoder = kmalloc(sizeof(struct saa7114), GFP_KERNEL); 864 decoder = kmalloc(sizeof(struct saa7114), GFP_KERNEL);
@@ -1204,11 +1203,11 @@ saa7114_detach_client (struct i2c_client *client)
1204/* ----------------------------------------------------------------------- */ 1203/* ----------------------------------------------------------------------- */
1205 1204
1206static struct i2c_driver i2c_driver_saa7114 = { 1205static struct i2c_driver i2c_driver_saa7114 = {
1207 .owner = THIS_MODULE, 1206 .driver = {
1208 .name = "saa7114", 1207 .name = "saa7114",
1208 },
1209 1209
1210 .id = I2C_DRIVERID_SAA7114, 1210 .id = I2C_DRIVERID_SAA7114,
1211 .flags = I2C_DF_NOTIFY,
1212 1211
1213 .attach_adapter = saa7114_attach_adapter, 1212 .attach_adapter = saa7114_attach_adapter,
1214 .detach_client = saa7114_detach_client, 1213 .detach_client = saa7114_detach_client,
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index e717e30d8187..29e28c742cd4 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -52,15 +52,16 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
52#define saa7115_dbg(fmt,arg...) \ 52#define saa7115_dbg(fmt,arg...) \
53 do { \ 53 do { \
54 if (debug) \ 54 if (debug) \
55 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 55 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
56 client->driver->driver.name, \
56 i2c_adapter_id(client->adapter), client->addr , ## arg); \ 57 i2c_adapter_id(client->adapter), client->addr , ## arg); \
57 } while (0) 58 } while (0)
58 59
59#define saa7115_err(fmt, arg...) do { \ 60#define saa7115_err(fmt, arg...) do { \
60 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ 61 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
61 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 62 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
62#define saa7115_info(fmt, arg...) do { \ 63#define saa7115_info(fmt, arg...) do { \
63 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ 64 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
64 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 65 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
65 66
66static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END }; 67static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END };
@@ -1270,7 +1271,6 @@ static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1270 client->addr = address; 1271 client->addr = address;
1271 client->adapter = adapter; 1272 client->adapter = adapter;
1272 client->driver = &i2c_driver_saa7115; 1273 client->driver = &i2c_driver_saa7115;
1273 client->flags = I2C_CLIENT_ALLOW_USE;
1274 snprintf(client->name, sizeof(client->name) - 1, "saa7115"); 1274 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1275 1275
1276 saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1); 1276 saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1);
@@ -1354,13 +1354,13 @@ static int saa7115_detach(struct i2c_client *client)
1354 1354
1355/* i2c implementation */ 1355/* i2c implementation */
1356static struct i2c_driver i2c_driver_saa7115 = { 1356static struct i2c_driver i2c_driver_saa7115 = {
1357 .name = "saa7115", 1357 .driver = {
1358 .name = "saa7115",
1359 },
1358 .id = I2C_DRIVERID_SAA711X, 1360 .id = I2C_DRIVERID_SAA711X,
1359 .flags = I2C_DF_NOTIFY,
1360 .attach_adapter = saa7115_probe, 1361 .attach_adapter = saa7115_probe,
1361 .detach_client = saa7115_detach, 1362 .detach_client = saa7115_detach,
1362 .command = saa7115_command, 1363 .command = saa7115_command,
1363 .owner = THIS_MODULE,
1364}; 1364};
1365 1365
1366 1366
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index 59e13fdea780..8008537391b5 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -59,7 +59,7 @@ MODULE_PARM_DESC(debug, " Set the default Debug level. Default: 0 (Off) - (0-1)
59#define dprintk(num, format, args...) \ 59#define dprintk(num, format, args...) \
60 do { \ 60 do { \
61 if (debug >= num) \ 61 if (debug >= num) \
62 printk(format , ##args); \ 62 printk(format, ##args); \
63 } while (0) 63 } while (0)
64 64
65/* ----------------------------------------------------------------------- */ 65/* ----------------------------------------------------------------------- */
@@ -494,7 +494,6 @@ saa711x_detect_client (struct i2c_adapter *adapter,
494 client->addr = address; 494 client->addr = address;
495 client->adapter = adapter; 495 client->adapter = adapter;
496 client->driver = &i2c_driver_saa711x; 496 client->driver = &i2c_driver_saa711x;
497 client->flags = I2C_CLIENT_ALLOW_USE;
498 strlcpy(I2C_NAME(client), "saa711x", sizeof(I2C_NAME(client))); 497 strlcpy(I2C_NAME(client), "saa711x", sizeof(I2C_NAME(client)));
499 decoder = kmalloc(sizeof(struct saa711x), GFP_KERNEL); 498 decoder = kmalloc(sizeof(struct saa711x), GFP_KERNEL);
500 if (decoder == NULL) { 499 if (decoder == NULL) {
@@ -565,11 +564,11 @@ saa711x_detach_client (struct i2c_client *client)
565/* ----------------------------------------------------------------------- */ 564/* ----------------------------------------------------------------------- */
566 565
567static struct i2c_driver i2c_driver_saa711x = { 566static struct i2c_driver i2c_driver_saa711x = {
568 .owner = THIS_MODULE, 567 .driver = {
569 .name = "saa711x", 568 .name = "saa711x",
569 },
570 570
571 .id = I2C_DRIVERID_SAA711X, 571 .id = I2C_DRIVERID_SAA711X,
572 .flags = I2C_DF_NOTIFY,
573 572
574 .attach_adapter = saa711x_attach_adapter, 573 .attach_adapter = saa711x_attach_adapter,
575 .detach_client = saa711x_detach_client, 574 .detach_client = saa711x_detach_client,
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index 3428e1ed0032..bca6ed0e2752 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -69,7 +69,8 @@ MODULE_PARM_DESC(test_image, "test_image (0-1)");
69#define saa7127_dbg(fmt, arg...) \ 69#define saa7127_dbg(fmt, arg...) \
70 do { \ 70 do { \
71 if (debug >= 1) \ 71 if (debug >= 1) \
72 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 72 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
73 client->driver->driver.name, \
73 i2c_adapter_id(client->adapter), client->addr , ## arg); \ 74 i2c_adapter_id(client->adapter), client->addr , ## arg); \
74 } while (0) 75 } while (0)
75 76
@@ -77,15 +78,16 @@ MODULE_PARM_DESC(test_image, "test_image (0-1)");
77#define saa7127_dbg_highvol(fmt, arg...) \ 78#define saa7127_dbg_highvol(fmt, arg...) \
78 do { \ 79 do { \
79 if (debug == 2) \ 80 if (debug == 2) \
80 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \ 81 printk(KERN_INFO "%s debug %d-%04x: " fmt, \
82 client->driver->driver.name, \
81 i2c_adapter_id(client->adapter), client->addr , ## arg); \ 83 i2c_adapter_id(client->adapter), client->addr , ## arg); \
82 } while (0) 84 } while (0)
83 85
84#define saa7127_err(fmt, arg...) do { \ 86#define saa7127_err(fmt, arg...) do { \
85 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ 87 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
86 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 88 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
87#define saa7127_info(fmt, arg...) do { \ 89#define saa7127_info(fmt, arg...) do { \
88 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ 90 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
89 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 91 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
90 92
91static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END }; 93static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
@@ -389,7 +391,7 @@ static int saa7127_set_vps(struct i2c_client *client, struct v4l2_sliced_vbi_dat
389static int saa7127_set_cc(struct i2c_client *client, struct v4l2_sliced_vbi_data *data) 391static int saa7127_set_cc(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
390{ 392{
391 struct saa7127_state *state = i2c_get_clientdata(client); 393 struct saa7127_state *state = i2c_get_clientdata(client);
392 u16 cc = data->data[0] << 8 | data->data[1]; 394 u16 cc = data->data[1] << 8 | data->data[0];
393 int enable = (data->line != 0); 395 int enable = (data->line != 0);
394 396
395 if (enable && (data->field != 0 || data->line != 21)) 397 if (enable && (data->field != 0 || data->line != 21))
@@ -397,7 +399,7 @@ static int saa7127_set_cc(struct i2c_client *client, struct v4l2_sliced_vbi_data
397 if (state->cc_enable != enable) { 399 if (state->cc_enable != enable) {
398 saa7127_dbg("Turn CC %s\n", enable ? "on" : "off"); 400 saa7127_dbg("Turn CC %s\n", enable ? "on" : "off");
399 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION, 401 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
400 (enable << 6) | 0x11); 402 (state->xds_enable << 7) | (enable << 6) | 0x11);
401 state->cc_enable = enable; 403 state->cc_enable = enable;
402 } 404 }
403 if (!enable) 405 if (!enable)
@@ -423,7 +425,7 @@ static int saa7127_set_xds(struct i2c_client *client, struct v4l2_sliced_vbi_dat
423 if (state->xds_enable != enable) { 425 if (state->xds_enable != enable) {
424 saa7127_dbg("Turn XDS %s\n", enable ? "on" : "off"); 426 saa7127_dbg("Turn XDS %s\n", enable ? "on" : "off");
425 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION, 427 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
426 (enable << 7) | 0x11); 428 (enable << 7) | (state->cc_enable << 6) | 0x11);
427 state->xds_enable = enable; 429 state->xds_enable = enable;
428 } 430 }
429 if (!enable) 431 if (!enable)
@@ -719,7 +721,6 @@ static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind)
719 client->addr = address; 721 client->addr = address;
720 client->adapter = adapter; 722 client->adapter = adapter;
721 client->driver = &i2c_driver_saa7127; 723 client->driver = &i2c_driver_saa7127;
722 client->flags = I2C_CLIENT_ALLOW_USE;
723 snprintf(client->name, sizeof(client->name) - 1, "saa7127"); 724 snprintf(client->name, sizeof(client->name) - 1, "saa7127");
724 725
725 saa7127_dbg("detecting saa7127 client on address 0x%x\n", address << 1); 726 saa7127_dbg("detecting saa7127 client on address 0x%x\n", address << 1);
@@ -819,13 +820,13 @@ static int saa7127_detach(struct i2c_client *client)
819/* ----------------------------------------------------------------------- */ 820/* ----------------------------------------------------------------------- */
820 821
821static struct i2c_driver i2c_driver_saa7127 = { 822static struct i2c_driver i2c_driver_saa7127 = {
822 .name = "saa7127", 823 .driver = {
824 .name = "saa7127",
825 },
823 .id = I2C_DRIVERID_SAA7127, 826 .id = I2C_DRIVERID_SAA7127,
824 .flags = I2C_DF_NOTIFY,
825 .attach_adapter = saa7127_probe, 827 .attach_adapter = saa7127_probe,
826 .detach_client = saa7127_detach, 828 .detach_client = saa7127_detach,
827 .command = saa7127_command, 829 .command = saa7127_command,
828 .owner = THIS_MODULE,
829}; 830};
830 831
831 832
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index c512c4411b38..8a5c3e71b37d 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -1,11 +1,10 @@
1config VIDEO_SAA7134 1config VIDEO_SAA7134
2 tristate "Philips SAA7134 support" 2 tristate "Philips SAA7134 support"
3 depends on VIDEO_DEV && PCI && I2C && SOUND && SND 3 depends on VIDEO_DEV && PCI && I2C
4 select VIDEO_BUF 4 select VIDEO_BUF
5 select VIDEO_IR 5 select VIDEO_IR
6 select VIDEO_TUNER 6 select VIDEO_TUNER
7 select CRC32 7 select CRC32
8 select SND_PCM_OSS
9 ---help--- 8 ---help---
10 This is a video4linux driver for Philips SAA713x based 9 This is a video4linux driver for Philips SAA713x based
11 TV cards. 10 TV cards.
@@ -13,6 +12,29 @@ config VIDEO_SAA7134
13 To compile this driver as a module, choose M here: the 12 To compile this driver as a module, choose M here: the
14 module will be called saa7134. 13 module will be called saa7134.
15 14
15config VIDEO_SAA7134_ALSA
16 tristate "Philips SAA7134 DMA audio support"
17 depends on VIDEO_SAA7134 && SND
18 select SND_PCM_OSS
19 ---help---
20 This is a video4linux driver for direct (DMA) audio in
21 Philips SAA713x based TV cards using ALSA
22
23 To compile this driver as a module, choose M here: the
24 module will be called saa7134-alsa.
25
26config VIDEO_SAA7134_OSS
27 tristate "Philips SAA7134 DMA audio support (OSS, DEPRECATED)"
28 depends on VIDEO_SAA7134 && SOUND_PRIME && !VIDEO_SAA7134_ALSA
29 ---help---
30 This is a video4linux driver for direct (DMA) audio in
31 Philips SAA713x based TV cards using OSS
32
33 This is deprecated in favor of the ALSA module
34
35 To compile this driver as a module, choose M here: the
36 module will be called saa7134-oss.
37
16config VIDEO_SAA7134_DVB 38config VIDEO_SAA7134_DVB
17 tristate "DVB/ATSC Support for saa7134 based TV cards" 39 tristate "DVB/ATSC Support for saa7134 based TV cards"
18 depends on VIDEO_SAA7134 && DVB_CORE 40 depends on VIDEO_SAA7134 && DVB_CORE
diff --git a/drivers/media/video/saa7134/Makefile b/drivers/media/video/saa7134/Makefile
index 134f83a96218..1ba998424bbd 100644
--- a/drivers/media/video/saa7134/Makefile
+++ b/drivers/media/video/saa7134/Makefile
@@ -4,8 +4,11 @@ saa7134-objs := saa7134-cards.o saa7134-core.o saa7134-i2c.o \
4 saa7134-video.o saa7134-input.o 4 saa7134-video.o saa7134-input.o
5 5
6obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o saa7134-empress.o \ 6obj-$(CONFIG_VIDEO_SAA7134) += saa7134.o saa7134-empress.o \
7 saa6752hs.o saa7134-alsa.o \ 7 saa6752hs.o
8 saa7134-oss.o 8
9obj-$(CONFIG_VIDEO_SAA7134_ALSA) += saa7134-alsa.o
10obj-$(CONFIG_VIDEO_SAA7134_OSS) += saa7134-oss.o
11
9obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o 12obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
10 13
11EXTRA_CFLAGS += -I$(src)/.. 14EXTRA_CFLAGS += -I$(src)/..
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index cdd1ed9c8065..4615a982ac64 100644
--- a/drivers/media/video/saa7134/saa6752hs.c
+++ b/drivers/media/video/saa7134/saa6752hs.c
@@ -523,7 +523,8 @@ static int saa6752hs_attach(struct i2c_adapter *adap, int addr, int kind)
523 h->standard = 0; 523 h->standard = 0;
524 524
525 i2c_set_clientdata(&h->client, h); 525 i2c_set_clientdata(&h->client, h);
526 i2c_attach_client(&h->client); 526 i2c_attach_client(&h->client);
527
527 return 0; 528 return 0;
528} 529}
529 530
@@ -596,20 +597,19 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
596/* ----------------------------------------------------------------------- */ 597/* ----------------------------------------------------------------------- */
597 598
598static struct i2c_driver driver = { 599static struct i2c_driver driver = {
599 .owner = THIS_MODULE, 600 .driver = {
600 .name = "i2c saa6752hs MPEG encoder", 601 .name = "i2c saa6752hs MPEG encoder",
601 .id = I2C_DRIVERID_SAA6752HS, 602 },
602 .flags = I2C_DF_NOTIFY, 603 .id = I2C_DRIVERID_SAA6752HS,
603 .attach_adapter = saa6752hs_probe, 604 .attach_adapter = saa6752hs_probe,
604 .detach_client = saa6752hs_detach, 605 .detach_client = saa6752hs_detach,
605 .command = saa6752hs_command, 606 .command = saa6752hs_command,
606}; 607};
607 608
608static struct i2c_client client_template = 609static struct i2c_client client_template =
609{ 610{
610 .name = "saa6752hs", 611 .name = "saa6752hs",
611 .flags = I2C_CLIENT_ALLOW_USE, 612 .driver = &driver,
612 .driver = &driver,
613}; 613};
614 614
615static int __init saa6752hs_init_module(void) 615static int __init saa6752hs_init_module(void)
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index 263c6e2e3e8e..ade05f75fdb0 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -51,6 +51,7 @@ MODULE_PARM_DESC(debug,"enable debug messages [alsa]");
51#define MIXER_ADDR_LINE2 2 51#define MIXER_ADDR_LINE2 2
52#define MIXER_ADDR_LAST 2 52#define MIXER_ADDR_LAST 2
53 53
54
54static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
55static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
56static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; 57static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
@@ -59,11 +60,14 @@ module_param_array(index, int, NULL, 0444);
59MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); 60MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
60 61
61#define dprintk(fmt, arg...) if (debug) \ 62#define dprintk(fmt, arg...) if (debug) \
62 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) 63 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ##arg)
64
65
63 66
64/* 67/*
65 * Main chip structure 68 * Main chip structure
66 */ 69 */
70
67typedef struct snd_card_saa7134 { 71typedef struct snd_card_saa7134 {
68 snd_card_t *card; 72 snd_card_t *card;
69 spinlock_t mixer_lock; 73 spinlock_t mixer_lock;
@@ -208,8 +212,8 @@ static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
208 212
209static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs) 213static irqreturn_t saa7134_alsa_irq(int irq, void *dev_id, struct pt_regs *regs)
210{ 214{
211 struct saa7134_dmasound *dmasound = dev_id; 215 struct saa7134_dmasound *dmasound = dev_id;
212 struct saa7134_dev *dev = dmasound->priv_data; 216 struct saa7134_dev *dev = dmasound->priv_data;
213 217
214 unsigned long report, status; 218 unsigned long report, status;
215 int loop, handled = 0; 219 int loop, handled = 0;
@@ -985,7 +989,15 @@ static int saa7134_alsa_init(void)
985 struct saa7134_dev *dev = NULL; 989 struct saa7134_dev *dev = NULL;
986 struct list_head *list; 990 struct list_head *list;
987 991
988 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); 992 if (!dmasound_init && !dmasound_exit) {
993 dmasound_init = alsa_device_init;
994 dmasound_exit = alsa_device_exit;
995 } else {
996 printk(KERN_WARNING "saa7134 ALSA: can't load, DMA sound handler already assigned (probably to OSS)\n");
997 return -EBUSY;
998 }
999
1000 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
989 1001
990 list_for_each(list,&saa7134_devlist) { 1002 list_for_each(list,&saa7134_devlist) {
991 dev = list_entry(list, struct saa7134_dev, devlist); 1003 dev = list_entry(list, struct saa7134_dev, devlist);
@@ -997,13 +1009,11 @@ static int saa7134_alsa_init(void)
997 } 1009 }
998 } 1010 }
999 1011
1000 dmasound_init = alsa_device_init;
1001 dmasound_exit = alsa_device_exit;
1002
1003 if (dev == NULL) 1012 if (dev == NULL)
1004 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); 1013 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
1005 1014
1006 return 0; 1015 return 0;
1016
1007} 1017}
1008 1018
1009/* 1019/*
@@ -1018,12 +1028,18 @@ static void saa7134_alsa_exit(void)
1018 snd_card_free(snd_saa7134_cards[idx]); 1028 snd_card_free(snd_saa7134_cards[idx]);
1019 } 1029 }
1020 1030
1031 dmasound_init = NULL;
1032 dmasound_exit = NULL;
1021 printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n"); 1033 printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n");
1022 1034
1023 return; 1035 return;
1024} 1036}
1025 1037
1026module_init(saa7134_alsa_init); 1038/* We initialize this late, to make sure the sound system is up and running */
1039late_initcall(saa7134_alsa_init);
1027module_exit(saa7134_alsa_exit); 1040module_exit(saa7134_alsa_exit);
1028MODULE_LICENSE("GPL"); 1041MODULE_LICENSE("GPL");
1029MODULE_AUTHOR("Ricardo Cerqueira"); 1042MODULE_AUTHOR("Ricardo Cerqueira");
1043
1044
1045
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 75abc20b0ccd..672fb205959f 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -976,7 +976,7 @@ struct saa7134_board saa7134_boards[] = {
976 .radio_type = UNSET, 976 .radio_type = UNSET,
977 .tuner_addr = ADDR_UNSET, 977 .tuner_addr = ADDR_UNSET,
978 .radio_addr = ADDR_UNSET, 978 .radio_addr = ADDR_UNSET,
979 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER, 979 .tda9887_conf = TDA9887_PRESENT | TDA9887_INTERCARRIER | TDA9887_PORT2_ACTIVE,
980 .inputs = {{ 980 .inputs = {{
981 .name = name_tv, 981 .name = name_tv,
982 .vmux = 3, 982 .vmux = 3,
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 1a093bf176f3..23d8747338ed 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -71,6 +71,7 @@ static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
71static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 71static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
72static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 72static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
73 73
74
74module_param_array(video_nr, int, NULL, 0444); 75module_param_array(video_nr, int, NULL, 0444);
75module_param_array(vbi_nr, int, NULL, 0444); 76module_param_array(vbi_nr, int, NULL, 0444);
76module_param_array(radio_nr, int, NULL, 0444); 77module_param_array(radio_nr, int, NULL, 0444);
diff --git a/drivers/media/video/saa7134/saa7134-empress.c b/drivers/media/video/saa7134/saa7134-empress.c
index e9ec69efb4c9..575f3e835f91 100644
--- a/drivers/media/video/saa7134/saa7134-empress.c
+++ b/drivers/media/video/saa7134/saa7134-empress.c
@@ -36,6 +36,7 @@ MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
36MODULE_LICENSE("GPL"); 36MODULE_LICENSE("GPL");
37 37
38static unsigned int empress_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 38static unsigned int empress_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
39
39module_param_array(empress_nr, int, NULL, 0444); 40module_param_array(empress_nr, int, NULL, 0444);
40MODULE_PARM_DESC(empress_nr,"ts device number"); 41MODULE_PARM_DESC(empress_nr,"ts device number");
41 42
diff --git a/drivers/media/video/saa7134/saa7134-i2c.c b/drivers/media/video/saa7134/saa7134-i2c.c
index 7575043f0874..1792d03d621d 100644
--- a/drivers/media/video/saa7134/saa7134-i2c.c
+++ b/drivers/media/video/saa7134/saa7134-i2c.c
@@ -333,7 +333,7 @@ static int attach_inform(struct i2c_client *client)
333 struct tuner_setup tun_setup; 333 struct tuner_setup tun_setup;
334 334
335 d1printk( "%s i2c attach [addr=0x%x,client=%s]\n", 335 d1printk( "%s i2c attach [addr=0x%x,client=%s]\n",
336 client->driver->name, client->addr, client->name); 336 client->driver->driver.name, client->addr, client->name);
337 337
338 /* Am I an i2c remote control? */ 338 /* Am I an i2c remote control? */
339 339
@@ -343,7 +343,7 @@ static int attach_inform(struct i2c_client *client)
343 { 343 {
344 struct IR_i2c *ir = i2c_get_clientdata(client); 344 struct IR_i2c *ir = i2c_get_clientdata(client);
345 d1printk("%s i2c IR detected (%s).\n", 345 d1printk("%s i2c IR detected (%s).\n",
346 client->driver->name,ir->phys); 346 client->driver->driver.name, ir->phys);
347 saa7134_set_i2c_ir(dev,ir); 347 saa7134_set_i2c_ir(dev,ir);
348 break; 348 break;
349 } 349 }
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index 5a579194e455..8badd2a9cb2f 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -782,36 +782,36 @@ struct file_operations saa7134_mixer_fops = {
782 782
783static irqreturn_t saa7134_oss_irq(int irq, void *dev_id, struct pt_regs *regs) 783static irqreturn_t saa7134_oss_irq(int irq, void *dev_id, struct pt_regs *regs)
784{ 784{
785 struct saa7134_dmasound *dmasound = dev_id; 785 struct saa7134_dmasound *dmasound = dev_id;
786 struct saa7134_dev *dev = dmasound->priv_data; 786 struct saa7134_dev *dev = dmasound->priv_data;
787 unsigned long report, status; 787 unsigned long report, status;
788 int loop, handled = 0; 788 int loop, handled = 0;
789 789
790 for (loop = 0; loop < 10; loop++) { 790 for (loop = 0; loop < 10; loop++) {
791 report = saa_readl(SAA7134_IRQ_REPORT); 791 report = saa_readl(SAA7134_IRQ_REPORT);
792 status = saa_readl(SAA7134_IRQ_STATUS); 792 status = saa_readl(SAA7134_IRQ_STATUS);
793 793
794 if (report & SAA7134_IRQ_REPORT_DONE_RA3) { 794 if (report & SAA7134_IRQ_REPORT_DONE_RA3) {
795 handled = 1; 795 handled = 1;
796 saa_writel(SAA7134_IRQ_REPORT,report); 796 saa_writel(SAA7134_IRQ_REPORT,report);
797 saa7134_irq_oss_done(dev, status); 797 saa7134_irq_oss_done(dev, status);
798 } else { 798 } else {
799 goto out; 799 goto out;
800 } 800 }
801 } 801 }
802 802
803 if (loop == 10) { 803 if (loop == 10) {
804 dprintk("error! looping IRQ!"); 804 dprintk("error! looping IRQ!");
805 } 805 }
806out: 806out:
807 return IRQ_RETVAL(handled); 807 return IRQ_RETVAL(handled);
808} 808}
809 809
810int saa7134_oss_init1(struct saa7134_dev *dev) 810int saa7134_oss_init1(struct saa7134_dev *dev)
811{ 811{
812 812
813 if ((request_irq(dev->pci->irq, saa7134_oss_irq, 813 if ((request_irq(dev->pci->irq, saa7134_oss_irq,
814 SA_SHIRQ | SA_INTERRUPT, dev->name, 814 SA_SHIRQ | SA_INTERRUPT, dev->name,
815 (void*) &dev->dmasound)) < 0) 815 (void*) &dev->dmasound)) < 0)
816 return -1; 816 return -1;
817 817
@@ -905,25 +905,25 @@ static int saa7134_dsp_create(struct saa7134_dev *dev)
905 905
906 err = dev->dmasound.minor_dsp = 906 err = dev->dmasound.minor_dsp =
907 register_sound_dsp(&saa7134_dsp_fops, 907 register_sound_dsp(&saa7134_dsp_fops,
908 dsp_nr[dev->nr]); 908 dsp_nr[dev->nr]);
909 if (err < 0) { 909 if (err < 0) {
910 goto fail; 910 goto fail;
911 } 911 }
912 printk(KERN_INFO "%s: registered device dsp%d\n", 912 printk(KERN_INFO "%s: registered device dsp%d\n",
913 dev->name,dev->dmasound.minor_dsp >> 4); 913 dev->name,dev->dmasound.minor_dsp >> 4);
914 914
915 err = dev->dmasound.minor_mixer = 915 err = dev->dmasound.minor_mixer =
916 register_sound_mixer(&saa7134_mixer_fops, 916 register_sound_mixer(&saa7134_mixer_fops,
917 mixer_nr[dev->nr]); 917 mixer_nr[dev->nr]);
918 if (err < 0) 918 if (err < 0)
919 goto fail; 919 goto fail;
920 printk(KERN_INFO "%s: registered device mixer%d\n", 920 printk(KERN_INFO "%s: registered device mixer%d\n",
921 dev->name,dev->dmasound.minor_mixer >> 4); 921 dev->name,dev->dmasound.minor_mixer >> 4);
922 922
923 return 0; 923 return 0;
924 924
925fail: 925fail:
926 unregister_sound_dsp(dev->dmasound.minor_dsp); 926 unregister_sound_dsp(dev->dmasound.minor_dsp);
927 return 0; 927 return 0;
928 928
929 929
@@ -956,52 +956,63 @@ static int oss_device_exit(struct saa7134_dev *dev)
956 956
957static int saa7134_oss_init(void) 957static int saa7134_oss_init(void)
958{ 958{
959 struct saa7134_dev *dev = NULL; 959 struct saa7134_dev *dev = NULL;
960 struct list_head *list; 960 struct list_head *list;
961
962 if (!dmasound_init && !dmasound_exit) {
963 dmasound_init = oss_device_init;
964 dmasound_exit = oss_device_exit;
965 } else {
966 printk(KERN_WARNING "saa7134 OSS: can't load, DMA sound handler already assigned (probably to ALSA)\n");
967 return -EBUSY;
968 }
961 969
962 printk(KERN_INFO "saa7134 OSS driver for DMA sound loaded\n"); 970 printk(KERN_INFO "saa7134 OSS driver for DMA sound loaded\n");
963 971
964 list_for_each(list,&saa7134_devlist) { 972
965 dev = list_entry(list, struct saa7134_dev, devlist); 973 list_for_each(list,&saa7134_devlist) {
974 dev = list_entry(list, struct saa7134_dev, devlist);
966 if (dev->dmasound.priv_data == NULL) { 975 if (dev->dmasound.priv_data == NULL) {
967 oss_device_init(dev); 976 oss_device_init(dev);
968 } else { 977 } else {
969 printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name); 978 printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name);
970 return -EBUSY; 979 return -EBUSY;
971 } 980 }
972 } 981 }
973
974 if (dev == NULL)
975 printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
976 982
977 dmasound_init = oss_device_init; 983 if (dev == NULL)
978 dmasound_exit = oss_device_exit; 984 printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
979 985
980 return 0; 986 return 0;
981 987
982} 988}
983 989
984static void saa7134_oss_exit(void) 990static void saa7134_oss_exit(void)
985{ 991{
986 struct saa7134_dev *dev = NULL; 992 struct saa7134_dev *dev = NULL;
987 struct list_head *list; 993 struct list_head *list;
988 994
989 list_for_each(list,&saa7134_devlist) { 995 list_for_each(list,&saa7134_devlist) {
990 dev = list_entry(list, struct saa7134_dev, devlist); 996 dev = list_entry(list, struct saa7134_dev, devlist);
991 997
992 /* Device isn't registered by OSS, probably ALSA's */ 998 /* Device isn't registered by OSS, probably ALSA's */
993 if (!dev->dmasound.minor_dsp) 999 if (!dev->dmasound.minor_dsp)
994 continue; 1000 continue;
995 1001
996 oss_device_exit(dev); 1002 oss_device_exit(dev);
997 }
998 1003
999 printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n"); 1004 }
1005
1006 dmasound_init = NULL;
1007 dmasound_exit = NULL;
1008
1009 printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n");
1000 1010
1001 return; 1011 return;
1002} 1012}
1003 1013
1004module_init(saa7134_oss_init); 1014/* We initialize this late, to make sure the sound system is up and running */
1015late_initcall(saa7134_oss_init);
1005module_exit(saa7134_oss_exit); 1016module_exit(saa7134_oss_exit);
1006MODULE_LICENSE("GPL"); 1017MODULE_LICENSE("GPL");
1007MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]"); 1018MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 132aa7943c16..f72a9f796209 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -415,7 +415,6 @@ saa7185_detect_client (struct i2c_adapter *adapter,
415 client->addr = address; 415 client->addr = address;
416 client->adapter = adapter; 416 client->adapter = adapter;
417 client->driver = &i2c_driver_saa7185; 417 client->driver = &i2c_driver_saa7185;
418 client->flags = I2C_CLIENT_ALLOW_USE;
419 strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client))); 418 strlcpy(I2C_NAME(client), "saa7185", sizeof(I2C_NAME(client)));
420 419
421 encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL); 420 encoder = kmalloc(sizeof(struct saa7185), GFP_KERNEL);
@@ -487,11 +486,11 @@ saa7185_detach_client (struct i2c_client *client)
487/* ----------------------------------------------------------------------- */ 486/* ----------------------------------------------------------------------- */
488 487
489static struct i2c_driver i2c_driver_saa7185 = { 488static struct i2c_driver i2c_driver_saa7185 = {
490 .owner = THIS_MODULE, 489 .driver = {
491 .name = "saa7185", /* name */ 490 .name = "saa7185", /* name */
491 },
492 492
493 .id = I2C_DRIVERID_SAA7185B, 493 .id = I2C_DRIVERID_SAA7185B,
494 .flags = I2C_DF_NOTIFY,
495 494
496 .attach_adapter = saa7185_attach_adapter, 495 .attach_adapter = saa7185_attach_adapter,
497 .detach_client = saa7185_detach_client, 496 .detach_client = saa7185_detach_client,
diff --git a/drivers/media/video/saa7191.c b/drivers/media/video/saa7191.c
index cbca896e8cfa..41f6f05a0436 100644
--- a/drivers/media/video/saa7191.c
+++ b/drivers/media/video/saa7191.c
@@ -788,10 +788,10 @@ static int saa7191_command(struct i2c_client *client, unsigned int cmd,
788} 788}
789 789
790static struct i2c_driver i2c_driver_saa7191 = { 790static struct i2c_driver i2c_driver_saa7191 = {
791 .owner = THIS_MODULE, 791 .driver = {
792 .name = "saa7191", 792 .name = "saa7191",
793 },
793 .id = I2C_DRIVERID_SAA7191, 794 .id = I2C_DRIVERID_SAA7191,
794 .flags = I2C_DF_NOTIFY,
795 .attach_adapter = saa7191_probe, 795 .attach_adapter = saa7191_probe,
796 .detach_client = saa7191_detach, 796 .detach_client = saa7191_detach,
797 .command = saa7191_command 797 .command = saa7191_command
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index d32737dd2142..549c9929f107 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -501,10 +501,10 @@ static int tda7432_command(struct i2c_client *client,
501} 501}
502 502
503static struct i2c_driver driver = { 503static struct i2c_driver driver = {
504 .owner = THIS_MODULE, 504 .driver = {
505 .name = "i2c tda7432 driver", 505 .name = "i2c tda7432 driver",
506 },
506 .id = I2C_DRIVERID_TDA7432, 507 .id = I2C_DRIVERID_TDA7432,
507 .flags = I2C_DF_NOTIFY,
508 .attach_adapter = tda7432_probe, 508 .attach_adapter = tda7432_probe,
509 .detach_client = tda7432_detach, 509 .detach_client = tda7432_detach,
510 .command = tda7432_command, 510 .command = tda7432_command,
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index 1794686612c6..ed4c04119ccc 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -34,7 +34,7 @@ static int debug = 0; /* insmod parameter */
34module_param(debug, int, 0644); 34module_param(debug, int, 0644);
35MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 35MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
36#define dprintk(args...) \ 36#define dprintk(args...) \
37 do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0) 37 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
38 38
39#define SWITCH 0x00 39#define SWITCH 0x00
40#define LEVEL_ADJUST 0x02 40#define LEVEL_ADJUST 0x02
@@ -221,10 +221,10 @@ static int detach(struct i2c_client *client)
221} 221}
222 222
223static struct i2c_driver driver = { 223static struct i2c_driver driver = {
224 .owner = THIS_MODULE, 224 .driver = {
225 .name = "tda9840", 225 .name = "tda9840",
226 },
226 .id = I2C_DRIVERID_TDA9840, 227 .id = I2C_DRIVERID_TDA9840,
227 .flags = I2C_DF_NOTIFY,
228 .attach_adapter = attach, 228 .attach_adapter = attach,
229 .detach_client = detach, 229 .detach_client = detach,
230 .command = command, 230 .command = command,
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index a5e37dc91f39..9c3ecf7a0fed 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -372,10 +372,10 @@ static int tda9875_command(struct i2c_client *client,
372 372
373 373
374static struct i2c_driver driver = { 374static struct i2c_driver driver = {
375 .owner = THIS_MODULE, 375 .driver = {
376 .name = "i2c tda9875 driver", 376 .name = "i2c tda9875 driver",
377 },
377 .id = I2C_DRIVERID_TDA9875, 378 .id = I2C_DRIVERID_TDA9875,
378 .flags = I2C_DF_NOTIFY,
379 .attach_adapter = tda9875_probe, 379 .attach_adapter = tda9875_probe,
380 .detach_client = tda9875_detach, 380 .detach_client = tda9875_detach,
381 .command = tda9875_command, 381 .command = tda9875_command,
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 4249127c0a1d..7165a1b9625a 100644
--- a/drivers/media/video/tda9887.c
+++ b/drivers/media/video/tda9887.c
@@ -12,6 +12,7 @@
12#include <media/audiochip.h> 12#include <media/audiochip.h>
13#include <media/tuner.h> 13#include <media/tuner.h>
14 14
15
15/* Chips: 16/* Chips:
16 TDA9885 (PAL, NTSC) 17 TDA9885 (PAL, NTSC)
17 TDA9886 (PAL, SECAM, NTSC) 18 TDA9886 (PAL, SECAM, NTSC)
@@ -818,14 +819,12 @@ static int tda9887_resume(struct device * dev)
818/* ----------------------------------------------------------------------- */ 819/* ----------------------------------------------------------------------- */
819 820
820static struct i2c_driver driver = { 821static struct i2c_driver driver = {
821 .owner = THIS_MODULE, 822 .id = -1, /* FIXME */
822 .name = "i2c tda9887 driver", 823 .attach_adapter = tda9887_probe,
823 .id = -1, /* FIXME */ 824 .detach_client = tda9887_detach,
824 .flags = I2C_DF_NOTIFY, 825 .command = tda9887_command,
825 .attach_adapter = tda9887_probe,
826 .detach_client = tda9887_detach,
827 .command = tda9887_command,
828 .driver = { 826 .driver = {
827 .name = "i2c tda9887 driver",
829 .suspend = tda9887_suspend, 828 .suspend = tda9887_suspend,
830 .resume = tda9887_resume, 829 .resume = tda9887_resume,
831 }, 830 },
@@ -833,8 +832,7 @@ static struct i2c_driver driver = {
833static struct i2c_client client_template = 832static struct i2c_client client_template =
834{ 833{
835 .name = "tda9887", 834 .name = "tda9887",
836 .flags = I2C_CLIENT_ALLOW_USE, 835 .driver = &driver,
837 .driver = &driver,
838}; 836};
839 837
840static int __init tda9887_init_module(void) 838static int __init tda9887_init_module(void)
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index ee3688348b66..bb35844e3842 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -36,7 +36,7 @@ static int debug = 0; /* insmod parameter */
36module_param(debug, int, 0644); 36module_param(debug, int, 0644);
37MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 37MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
38#define dprintk(args...) \ 38#define dprintk(args...) \
39 do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0) 39 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
40 40
41#define TEA6415C_NUM_INPUTS 8 41#define TEA6415C_NUM_INPUTS 8
42#define TEA6415C_NUM_OUTPUTS 6 42#define TEA6415C_NUM_OUTPUTS 6
@@ -190,10 +190,10 @@ static int command(struct i2c_client *client, unsigned int cmd, void *arg)
190} 190}
191 191
192static struct i2c_driver driver = { 192static struct i2c_driver driver = {
193 .owner = THIS_MODULE, 193 .driver = {
194 .name = "tea6415c", 194 .name = "tea6415c",
195 },
195 .id = I2C_DRIVERID_TEA6415C, 196 .id = I2C_DRIVERID_TEA6415C,
196 .flags = I2C_DF_NOTIFY,
197 .attach_adapter = attach, 197 .attach_adapter = attach,
198 .detach_client = detach, 198 .detach_client = detach,
199 .command = command, 199 .command = command,
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index 17975c19da5e..c4ba3742f5c7 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -36,7 +36,7 @@ static int debug = 0; /* insmod parameter */
36module_param(debug, int, 0644); 36module_param(debug, int, 0644);
37MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off)."); 37MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
38#define dprintk(args...) \ 38#define dprintk(args...) \
39 do { if (debug) { printk("%s: %s()[%d]: ",__stringify(KBUILD_MODNAME), __FUNCTION__, __LINE__); printk(args); } } while (0) 39 do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
40 40
41/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */ 41/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */
42static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END }; 42static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END };
@@ -167,10 +167,10 @@ static int command(struct i2c_client *client, unsigned int cmd, void *arg)
167} 167}
168 168
169static struct i2c_driver driver = { 169static struct i2c_driver driver = {
170 .owner = THIS_MODULE, 170 .driver = {
171 .name = "tea6420", 171 .name = "tea6420",
172 },
172 .id = I2C_DRIVERID_TEA6420, 173 .id = I2C_DRIVERID_TEA6420,
173 .flags = I2C_DF_NOTIFY,
174 .attach_adapter = attach, 174 .attach_adapter = attach,
175 .detach_client = detach, 175 .detach_client = detach,
176 .command = command, 176 .command = command,
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index 79203595b9c1..d97f66804c37 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -175,10 +175,10 @@ tuner_probe(struct i2c_adapter *adap)
175static struct i2c_driver 175static struct i2c_driver
176i2c_driver_tuner = 176i2c_driver_tuner =
177{ 177{
178 .owner = THIS_MODULE, 178 .driver = {
179 .name = "sab3036", 179 .name = "sab3036",
180 },
180 .id = I2C_DRIVERID_SAB3036, 181 .id = I2C_DRIVERID_SAB3036,
181 .flags = I2C_DF_NOTIFY,
182 .attach_adapter = tuner_probe, 182 .attach_adapter = tuner_probe,
183 .detach_client = tuner_detach, 183 .detach_client = tuner_detach,
184 .command = tuner_command 184 .command = tuner_command
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index e58abdfcaab8..c13c7b95ef35 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -206,7 +206,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
206 206
207 set_freq(c, t->freq); 207 set_freq(c, t->freq);
208 tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", 208 tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n",
209 c->adapter->name, c->driver->name, c->addr << 1, type, 209 c->adapter->name, c->driver->driver.name, c->addr << 1, type,
210 t->mode_mask); 210 t->mode_mask);
211} 211}
212 212
@@ -742,21 +742,18 @@ static int tuner_resume(struct device *dev)
742/* ----------------------------------------------------------------------- */ 742/* ----------------------------------------------------------------------- */
743 743
744static struct i2c_driver driver = { 744static struct i2c_driver driver = {
745 .owner = THIS_MODULE,
746 .name = "tuner",
747 .id = I2C_DRIVERID_TUNER, 745 .id = I2C_DRIVERID_TUNER,
748 .flags = I2C_DF_NOTIFY,
749 .attach_adapter = tuner_probe, 746 .attach_adapter = tuner_probe,
750 .detach_client = tuner_detach, 747 .detach_client = tuner_detach,
751 .command = tuner_command, 748 .command = tuner_command,
752 .driver = { 749 .driver = {
750 .name = "tuner",
753 .suspend = tuner_suspend, 751 .suspend = tuner_suspend,
754 .resume = tuner_resume, 752 .resume = tuner_resume,
755 }, 753 },
756}; 754};
757static struct i2c_client client_template = { 755static struct i2c_client client_template = {
758 .name = "(tuner unset)", 756 .name = "(tuner unset)",
759 .flags = I2C_CLIENT_ALLOW_USE,
760 .driver = &driver, 757 .driver = &driver,
761}; 758};
762 759
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index c31bf28b73fe..0292c5abf14a 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -188,7 +188,7 @@ static int chip_write(struct CHIPSTATE *chip, int subaddr, int val)
188 buffer[1] = val; 188 buffer[1] = val;
189 if (2 != i2c_master_send(&chip->c,buffer,2)) { 189 if (2 != i2c_master_send(&chip->c,buffer,2)) {
190 tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n", 190 tvaudio_warn("%s: I/O error (write reg%d=0x%x)\n",
191 chip->c.name, subaddr, val); 191 chip->c.name, subaddr, val);
192 return -1; 192 return -1;
193 } 193 }
194 } 194 }
@@ -216,7 +216,7 @@ static int chip_read(struct CHIPSTATE *chip)
216 chip->c.name); 216 chip->c.name);
217 return -1; 217 return -1;
218 } 218 }
219 tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name,buffer); 219 tvaudio_dbg("%s: chip_read: 0x%x\n",chip->c.name, buffer);
220 return buffer; 220 return buffer;
221} 221}
222 222
@@ -235,7 +235,7 @@ static int chip_read2(struct CHIPSTATE *chip, int subaddr)
235 return -1; 235 return -1;
236 } 236 }
237 tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n", 237 tvaudio_dbg("%s: chip_read2: reg%d=0x%x\n",
238 chip->c.name,subaddr,read[0]); 238 chip->c.name, subaddr,read[0]);
239 return read[0]; 239 return read[0];
240} 240}
241 241
@@ -248,7 +248,7 @@ static int chip_cmd(struct CHIPSTATE *chip, char *name, audiocmd *cmd)
248 248
249 /* update our shadow register set; print bytes if (debug > 0) */ 249 /* update our shadow register set; print bytes if (debug > 0) */
250 tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:", 250 tvaudio_dbg("%s: chip_cmd(%s): reg=%d, data:",
251 chip->c.name,name,cmd->bytes[0]); 251 chip->c.name, name,cmd->bytes[0]);
252 for (i = 1; i < cmd->count; i++) { 252 for (i = 1; i < cmd->count; i++) {
253 if (debug) 253 if (debug)
254 printk(" 0x%x",cmd->bytes[i]); 254 printk(" 0x%x",cmd->bytes[i]);
@@ -322,7 +322,7 @@ static void generic_checkmode(struct CHIPSTATE *chip)
322 int mode = desc->getmode(chip); 322 int mode = desc->getmode(chip);
323 323
324 if (mode == chip->prevmode) 324 if (mode == chip->prevmode)
325 return; 325 return;
326 326
327 tvaudio_dbg("%s: thread checkmode\n", chip->c.name); 327 tvaudio_dbg("%s: thread checkmode\n", chip->c.name);
328 chip->prevmode = mode; 328 chip->prevmode = mode;
@@ -1506,18 +1506,18 @@ static int chip_attach(struct i2c_adapter *adap, int addr, int kind)
1506 return -EIO; 1506 return -EIO;
1507 } 1507 }
1508 tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name); 1508 tvaudio_info("%s found @ 0x%x (%s)\n", desc->name, addr<<1, adap->name);
1509 if (desc->flags) { 1509 if (desc->flags) {
1510 tvaudio_dbg("matches:%s%s%s.\n", 1510 tvaudio_dbg("matches:%s%s%s.\n",
1511 (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "", 1511 (desc->flags & CHIP_HAS_VOLUME) ? " volume" : "",
1512 (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "", 1512 (desc->flags & CHIP_HAS_BASSTREBLE) ? " bass/treble" : "",
1513 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : ""); 1513 (desc->flags & CHIP_HAS_INPUTSEL) ? " audiomux" : "");
1514 } 1514 }
1515 1515
1516 /* fill required data structures */ 1516 /* fill required data structures */
1517 strcpy(chip->c.name,desc->name); 1517 strcpy(chip->c.name, desc->name);
1518 chip->type = desc-chiplist; 1518 chip->type = desc-chiplist;
1519 chip->shadow.count = desc->registers+1; 1519 chip->shadow.count = desc->registers+1;
1520 chip->prevmode = -1; 1520 chip->prevmode = -1;
1521 /* register */ 1521 /* register */
1522 i2c_attach_client(&chip->c); 1522 i2c_attach_client(&chip->c);
1523 1523
@@ -1604,7 +1604,7 @@ static int chip_command(struct i2c_client *client,
1604 struct CHIPSTATE *chip = i2c_get_clientdata(client); 1604 struct CHIPSTATE *chip = i2c_get_clientdata(client);
1605 struct CHIPDESC *desc = chiplist + chip->type; 1605 struct CHIPDESC *desc = chiplist + chip->type;
1606 1606
1607 tvaudio_dbg("%s: chip_command 0x%x\n",chip->c.name,cmd); 1607 tvaudio_dbg("%s: chip_command 0x%x\n", chip->c.name, cmd);
1608 1608
1609 switch (cmd) { 1609 switch (cmd) {
1610 case AUDC_SET_INPUT: 1610 case AUDC_SET_INPUT:
@@ -1624,7 +1624,7 @@ static int chip_command(struct i2c_client *client,
1624 1624
1625 /* --- v4l ioctls --- */ 1625 /* --- v4l ioctls --- */
1626 /* take care: bttv does userspace copying, we'll get a 1626 /* take care: bttv does userspace copying, we'll get a
1627 kernel pointer here... */ 1627 kernel pointer here... */
1628 case VIDIOCGAUDIO: 1628 case VIDIOCGAUDIO:
1629 { 1629 {
1630 struct video_audio *va = arg; 1630 struct video_audio *va = arg;
@@ -1702,10 +1702,10 @@ static int chip_command(struct i2c_client *client,
1702 1702
1703 1703
1704static struct i2c_driver driver = { 1704static struct i2c_driver driver = {
1705 .owner = THIS_MODULE, 1705 .driver = {
1706 .name = "generic i2c audio driver", 1706 .name = "generic i2c audio driver",
1707 },
1707 .id = I2C_DRIVERID_TVAUDIO, 1708 .id = I2C_DRIVERID_TVAUDIO,
1708 .flags = I2C_DF_NOTIFY,
1709 .attach_adapter = chip_probe, 1709 .attach_adapter = chip_probe,
1710 .detach_client = chip_detach, 1710 .detach_client = chip_detach,
1711 .command = chip_command, 1711 .command = chip_command,
@@ -1714,7 +1714,6 @@ static struct i2c_driver driver = {
1714static struct i2c_client client_template = 1714static struct i2c_client client_template =
1715{ 1715{
1716 .name = "(unset)", 1716 .name = "(unset)",
1717 .flags = I2C_CLIENT_ALLOW_USE,
1718 .driver = &driver, 1717 .driver = &driver,
1719}; 1718};
1720 1719
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index d95aecebbda3..8ac4cb82a459 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -206,7 +206,7 @@ hauppauge_tuner[] =
206 { TUNER_ABSENT, "TCL 2002MI_3H"}, 206 { TUNER_ABSENT, "TCL 2002MI_3H"},
207 { TUNER_TCL_2002N, "TCL 2002N 5H"}, 207 { TUNER_TCL_2002N, "TCL 2002N 5H"},
208 /* 100-109 */ 208 /* 100-109 */
209 { TUNER_ABSENT, "Philips FMD1216ME"}, 209 { TUNER_PHILIPS_FMD1216ME_MK3, "Philips FMD1216ME"},
210 { TUNER_TEA5767, "Philips TEA5768HL FM Radio"}, 210 { TUNER_TEA5767, "Philips TEA5768HL FM Radio"},
211 { TUNER_ABSENT, "Panasonic ENV57H12D5"}, 211 { TUNER_ABSENT, "Panasonic ENV57H12D5"},
212 { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05-4"}, 212 { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05-4"},
@@ -751,9 +751,9 @@ tveeprom_detect_client(struct i2c_adapter *adapter,
751 client->addr = address; 751 client->addr = address;
752 client->adapter = adapter; 752 client->adapter = adapter;
753 client->driver = &i2c_driver_tveeprom; 753 client->driver = &i2c_driver_tveeprom;
754 client->flags = I2C_CLIENT_ALLOW_USE;
755 snprintf(client->name, sizeof(client->name), "tveeprom"); 754 snprintf(client->name, sizeof(client->name), "tveeprom");
756 i2c_attach_client(client); 755 i2c_attach_client(client);
756
757 return 0; 757 return 0;
758} 758}
759 759
@@ -778,10 +778,10 @@ tveeprom_detach_client (struct i2c_client *client)
778} 778}
779 779
780static struct i2c_driver i2c_driver_tveeprom = { 780static struct i2c_driver i2c_driver_tveeprom = {
781 .owner = THIS_MODULE, 781 .driver = {
782 .name = "tveeprom", 782 .name = "tveeprom",
783 },
783 .id = I2C_DRIVERID_TVEEPROM, 784 .id = I2C_DRIVERID_TVEEPROM,
784 .flags = I2C_DF_NOTIFY,
785 .attach_adapter = tveeprom_attach_adapter, 785 .attach_adapter = tveeprom_attach_adapter,
786 .detach_client = tveeprom_detach_client, 786 .detach_client = tveeprom_detach_client,
787 .command = tveeprom_command, 787 .command = tveeprom_command,
diff --git a/drivers/media/video/tvmixer.c b/drivers/media/video/tvmixer.c
index 8318bd1aad00..e837f9f7fed6 100644
--- a/drivers/media/video/tvmixer.c
+++ b/drivers/media/video/tvmixer.c
@@ -228,16 +228,14 @@ static int tvmixer_release(struct inode *inode, struct file *file)
228 228
229static struct i2c_driver driver = { 229static struct i2c_driver driver = {
230#ifdef I2C_PEC 230#ifdef I2C_PEC
231 .owner = THIS_MODULE, 231 .driver = {
232#endif 232 .name = "tv card mixer driver",
233 },
234#else
233 .name = "tv card mixer driver", 235 .name = "tv card mixer driver",
236#endif
234 .id = I2C_DRIVERID_TVMIXER, 237 .id = I2C_DRIVERID_TVMIXER,
235#ifdef I2C_DF_DUMMY
236 .flags = I2C_DF_DUMMY,
237#else
238 .flags = I2C_DF_NOTIFY,
239 .detach_adapter = tvmixer_adapters, 238 .detach_adapter = tvmixer_adapters,
240#endif
241 .attach_adapter = tvmixer_adapters, 239 .attach_adapter = tvmixer_adapters,
242 .detach_client = tvmixer_clients, 240 .detach_client = tvmixer_clients,
243}; 241};
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 81e6d4494e7d..a60442ea4f94 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -31,7 +31,7 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
31#define dprintk(num, format, args...) \ 31#define dprintk(num, format, args...) \
32 do { \ 32 do { \
33 if (debug >= num) \ 33 if (debug >= num) \
34 printk(format , ##args); \ 34 printk(format, ##args); \
35 } while (0) 35 } while (0)
36 36
37/* supported controls */ 37/* supported controls */
@@ -714,7 +714,6 @@ static struct i2c_driver driver;
714 714
715static struct i2c_client client_template = { 715static struct i2c_client client_template = {
716 .name = "(unset)", 716 .name = "(unset)",
717 .flags = I2C_CLIENT_ALLOW_USE,
718 .driver = &driver, 717 .driver = &driver,
719}; 718};
720 719
@@ -770,7 +769,6 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
770 769
771 if (debug > 1) 770 if (debug > 1)
772 dump_reg(client); 771 dump_reg(client);
773
774 return 0; 772 return 0;
775} 773}
776 774
@@ -802,12 +800,12 @@ static int tvp5150_detach_client(struct i2c_client *client)
802/* ----------------------------------------------------------------------- */ 800/* ----------------------------------------------------------------------- */
803 801
804static struct i2c_driver driver = { 802static struct i2c_driver driver = {
805 .owner = THIS_MODULE, 803 .driver = {
806 .name = "tvp5150", 804 .name = "tvp5150",
805 },
807 806
808 /* FIXME */ 807 /* FIXME */
809 .id = I2C_DRIVERID_SAA7110, 808 .id = I2C_DRIVERID_SAA7110,
810 .flags = I2C_DF_NOTIFY,
811 809
812 .attach_adapter = tvp5150_attach_adapter, 810 .attach_adapter = tvp5150_attach_adapter,
813 .detach_client = tvp5150_detach_client, 811 .detach_client = tvp5150_detach_client,
diff --git a/drivers/media/video/video-buf-dvb.c b/drivers/media/video/video-buf-dvb.c
index 55f129e964eb..0a4004a4393c 100644
--- a/drivers/media/video/video-buf-dvb.c
+++ b/drivers/media/video/video-buf-dvb.c
@@ -13,6 +13,7 @@
13 * (at your option) any later version. 13 * (at your option) any later version.
14 */ 14 */
15 15
16
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/device.h> 19#include <linux/device.h>
@@ -247,3 +248,4 @@ EXPORT_SYMBOL(videobuf_dvb_unregister);
247 * compile-command: "make DVB=1" 248 * compile-command: "make DVB=1"
248 * End: 249 * End:
249 */ 250 */
251
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index 137b58f2c666..8dcee8b60e21 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -631,7 +631,6 @@ vpx3220_detect_client (struct i2c_adapter *adapter,
631 client->addr = address; 631 client->addr = address;
632 client->adapter = adapter; 632 client->adapter = adapter;
633 client->driver = &vpx3220_i2c_driver; 633 client->driver = &vpx3220_i2c_driver;
634 client->flags = I2C_CLIENT_ALLOW_USE;
635 634
636 /* Check for manufacture ID and part number */ 635 /* Check for manufacture ID and part number */
637 if (kind < 0) { 636 if (kind < 0) {
@@ -722,11 +721,11 @@ vpx3220_attach_adapter (struct i2c_adapter *adapter)
722 */ 721 */
723 722
724static struct i2c_driver vpx3220_i2c_driver = { 723static struct i2c_driver vpx3220_i2c_driver = {
725 .owner = THIS_MODULE, 724 .driver = {
726 .name = "vpx3220", 725 .name = "vpx3220",
726 },
727 727
728 .id = I2C_DRIVERID_VPX3220, 728 .id = I2C_DRIVERID_VPX3220,
729 .flags = I2C_DF_NOTIFY,
730 729
731 .attach_adapter = vpx3220_attach_adapter, 730 .attach_adapter = vpx3220_attach_adapter,
732 .detach_client = vpx3220_detach_client, 731 .detach_client = vpx3220_detach_client,
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index a6936ad74fcf..bbfd55cd9948 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -40,10 +40,10 @@ MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
40MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
41 41
42#define wm8775_err(fmt, arg...) do { \ 42#define wm8775_err(fmt, arg...) do { \
43 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \ 43 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
44 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 44 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
45#define wm8775_info(fmt, arg...) do { \ 45#define wm8775_info(fmt, arg...) do { \
46 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \ 46 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
47 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0) 47 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
48 48
49 49
@@ -168,7 +168,6 @@ static int wm8775_attach(struct i2c_adapter *adapter, int address, int kind)
168 client->addr = address; 168 client->addr = address;
169 client->adapter = adapter; 169 client->adapter = adapter;
170 client->driver = &i2c_driver; 170 client->driver = &i2c_driver;
171 client->flags = I2C_CLIENT_ALLOW_USE;
172 snprintf(client->name, sizeof(client->name) - 1, "wm8775"); 171 snprintf(client->name, sizeof(client->name) - 1, "wm8775");
173 172
174 wm8775_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name); 173 wm8775_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name);
@@ -233,15 +232,15 @@ static int wm8775_detach(struct i2c_client *client)
233 232
234/* i2c implementation */ 233/* i2c implementation */
235static struct i2c_driver i2c_driver = { 234static struct i2c_driver i2c_driver = {
236 .name = "wm8775", 235 .driver = {
236 .name = "wm8775",
237 },
237 238
238 .id = I2C_DRIVERID_WM8775, 239 .id = I2C_DRIVERID_WM8775,
239 .flags = I2C_DF_NOTIFY,
240 240
241 .attach_adapter = wm8775_probe, 241 .attach_adapter = wm8775_probe,
242 .detach_client = wm8775_detach, 242 .detach_client = wm8775_detach,
243 .command = wm8775_command, 243 .command = wm8775_command,
244 .owner = THIS_MODULE,
245}; 244};
246 245
247 246
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 07bde9acd672..4034f1b45366 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -1311,7 +1311,7 @@ zoran_open (struct inode *inode,
1311 res = -ENODEV; 1311 res = -ENODEV;
1312 goto open_unlock_and_return; 1312 goto open_unlock_and_return;
1313 } 1313 }
1314 if (!try_module_get(zr->decoder->driver->owner)) { 1314 if (!try_module_get(zr->decoder->driver->driver.owner)) {
1315 dprintk(1, 1315 dprintk(1,
1316 KERN_ERR 1316 KERN_ERR
1317 "%s: failed to grab ownership of i2c decoder\n", 1317 "%s: failed to grab ownership of i2c decoder\n",
@@ -1321,13 +1321,13 @@ zoran_open (struct inode *inode,
1321 goto open_unlock_and_return; 1321 goto open_unlock_and_return;
1322 } 1322 }
1323 if (zr->encoder && 1323 if (zr->encoder &&
1324 !try_module_get(zr->encoder->driver->owner)) { 1324 !try_module_get(zr->encoder->driver->driver.owner)) {
1325 dprintk(1, 1325 dprintk(1,
1326 KERN_ERR 1326 KERN_ERR
1327 "%s: failed to grab ownership of i2c encoder\n", 1327 "%s: failed to grab ownership of i2c encoder\n",
1328 ZR_DEVNAME(zr)); 1328 ZR_DEVNAME(zr));
1329 res = -EIO; 1329 res = -EIO;
1330 module_put(zr->decoder->driver->owner); 1330 module_put(zr->decoder->driver->driver.owner);
1331 module_put(THIS_MODULE); 1331 module_put(THIS_MODULE);
1332 goto open_unlock_and_return; 1332 goto open_unlock_and_return;
1333 } 1333 }
@@ -1393,9 +1393,9 @@ zoran_open (struct inode *inode,
1393open_unlock_and_return: 1393open_unlock_and_return:
1394 /* if we grabbed locks, release them accordingly */ 1394 /* if we grabbed locks, release them accordingly */
1395 if (have_module_locks) { 1395 if (have_module_locks) {
1396 module_put(zr->decoder->driver->owner); 1396 module_put(zr->decoder->driver->driver.owner);
1397 if (zr->encoder) { 1397 if (zr->encoder) {
1398 module_put(zr->encoder->driver->owner); 1398 module_put(zr->encoder->driver->driver.owner);
1399 } 1399 }
1400 module_put(THIS_MODULE); 1400 module_put(THIS_MODULE);
1401 } 1401 }
@@ -1461,9 +1461,9 @@ zoran_close (struct inode *inode,
1461 kfree(fh); 1461 kfree(fh);
1462 1462
1463 /* release locks on the i2c modules */ 1463 /* release locks on the i2c modules */
1464 module_put(zr->decoder->driver->owner); 1464 module_put(zr->decoder->driver->driver.owner);
1465 if (zr->encoder) { 1465 if (zr->encoder) {
1466 module_put(zr->encoder->driver->owner); 1466 module_put(zr->encoder->driver->driver.owner);
1467 } 1467 }
1468 module_put(THIS_MODULE); 1468 module_put(THIS_MODULE);
1469 1469
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 4262a22adc22..537836068c49 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -313,13 +313,13 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
313 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo); 313 u32 log_info = le32_to_cpu(mr->u.reply.IOCLogInfo);
314 if (ioc->bus_type == FC) 314 if (ioc->bus_type == FC)
315 mpt_fc_log_info(ioc, log_info); 315 mpt_fc_log_info(ioc, log_info);
316 else if (ioc->bus_type == SCSI) 316 else if (ioc->bus_type == SPI)
317 mpt_sp_log_info(ioc, log_info); 317 mpt_sp_log_info(ioc, log_info);
318 else if (ioc->bus_type == SAS) 318 else if (ioc->bus_type == SAS)
319 mpt_sas_log_info(ioc, log_info); 319 mpt_sas_log_info(ioc, log_info);
320 } 320 }
321 if (ioc_stat & MPI_IOCSTATUS_MASK) { 321 if (ioc_stat & MPI_IOCSTATUS_MASK) {
322 if (ioc->bus_type == SCSI && 322 if (ioc->bus_type == SPI &&
323 cb_idx != mpt_stm_index && 323 cb_idx != mpt_stm_index &&
324 cb_idx != mpt_lan_index) 324 cb_idx != mpt_lan_index)
325 mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf); 325 mpt_sp_ioc_info(ioc, (u32)ioc_stat, mf);
@@ -1376,7 +1376,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1376 } 1376 }
1377 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) { 1377 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) {
1378 ioc->prod_name = "LSI53C1030"; 1378 ioc->prod_name = "LSI53C1030";
1379 ioc->bus_type = SCSI; 1379 ioc->bus_type = SPI;
1380 /* 1030 Chip Fix. Disable Split transactions 1380 /* 1030 Chip Fix. Disable Split transactions
1381 * for PCIX. Set MOST bits to zero if Rev < C0( = 8). 1381 * for PCIX. Set MOST bits to zero if Rev < C0( = 8).
1382 */ 1382 */
@@ -1389,7 +1389,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1389 } 1389 }
1390 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_1030_53C1035) { 1390 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_1030_53C1035) {
1391 ioc->prod_name = "LSI53C1035"; 1391 ioc->prod_name = "LSI53C1035";
1392 ioc->bus_type = SCSI; 1392 ioc->bus_type = SPI;
1393 } 1393 }
1394 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) { 1394 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) {
1395 ioc->prod_name = "LSISAS1064"; 1395 ioc->prod_name = "LSISAS1064";
@@ -3042,7 +3042,7 @@ mpt_downloadboot(MPT_ADAPTER *ioc, MpiFwHeader_t *pFwHeader, int sleepFlag)
3042 /* Clear the internal flash bad bit - autoincrementing register, 3042 /* Clear the internal flash bad bit - autoincrementing register,
3043 * so must do two writes. 3043 * so must do two writes.
3044 */ 3044 */
3045 if (ioc->bus_type == SCSI) { 3045 if (ioc->bus_type == SPI) {
3046 /* 3046 /*
3047 * 1030 and 1035 H/W errata, workaround to access 3047 * 1030 and 1035 H/W errata, workaround to access
3048 * the ClearFlashBadSignatureBit 3048 * the ClearFlashBadSignatureBit
@@ -3152,7 +3152,7 @@ KickStart(MPT_ADAPTER *ioc, int force, int sleepFlag)
3152 int cnt,cntdn; 3152 int cnt,cntdn;
3153 3153
3154 dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name)); 3154 dinitprintk((KERN_WARNING MYNAM ": KickStarting %s!\n", ioc->name));
3155 if (ioc->bus_type == SCSI) { 3155 if (ioc->bus_type == SPI) {
3156 /* Always issue a Msg Unit Reset first. This will clear some 3156 /* Always issue a Msg Unit Reset first. This will clear some
3157 * SCSI bus hang conditions. 3157 * SCSI bus hang conditions.
3158 */ 3158 */
@@ -3580,7 +3580,7 @@ initChainBuffers(MPT_ADAPTER *ioc)
3580 dinitprintk((KERN_INFO MYNAM ": %s Now numSGE=%d num_sge=%d num_chain=%d\n", 3580 dinitprintk((KERN_INFO MYNAM ": %s Now numSGE=%d num_sge=%d num_chain=%d\n",
3581 ioc->name, numSGE, num_sge, num_chain)); 3581 ioc->name, numSGE, num_sge, num_chain));
3582 3582
3583 if (ioc->bus_type == SCSI) 3583 if (ioc->bus_type == SPI)
3584 num_chain *= MPT_SCSI_CAN_QUEUE; 3584 num_chain *= MPT_SCSI_CAN_QUEUE;
3585 else 3585 else
3586 num_chain *= MPT_FC_CAN_QUEUE; 3586 num_chain *= MPT_FC_CAN_QUEUE;
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index bac8eb4186d2..6c48d1f54ac9 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -76,8 +76,8 @@
76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR 76#define COPYRIGHT "Copyright (c) 1999-2005 " MODULEAUTHOR
77#endif 77#endif
78 78
79#define MPT_LINUX_VERSION_COMMON "3.03.04" 79#define MPT_LINUX_VERSION_COMMON "3.03.05"
80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.04" 80#define MPT_LINUX_PACKAGE_NAME "@(#)mptlinux-3.03.05"
81#define WHAT_MAGIC_STRING "@" "(" "#" ")" 81#define WHAT_MAGIC_STRING "@" "(" "#" ")"
82 82
83#define show_mptmod_ver(s,ver) \ 83#define show_mptmod_ver(s,ver) \
@@ -321,7 +321,7 @@ typedef struct _SYSIF_REGS
321 * Dynamic Multi-Pathing specific stuff... 321 * Dynamic Multi-Pathing specific stuff...
322 */ 322 */
323 323
324/* VirtDevice negoFlags field */ 324/* VirtTarget negoFlags field */
325#define MPT_TARGET_NO_NEGO_WIDE 0x01 325#define MPT_TARGET_NO_NEGO_WIDE 0x01
326#define MPT_TARGET_NO_NEGO_SYNC 0x02 326#define MPT_TARGET_NO_NEGO_SYNC 0x02
327#define MPT_TARGET_NO_NEGO_QAS 0x04 327#define MPT_TARGET_NO_NEGO_QAS 0x04
@@ -330,8 +330,7 @@ typedef struct _SYSIF_REGS
330/* 330/*
331 * VirtDevice - FC LUN device or SCSI target device 331 * VirtDevice - FC LUN device or SCSI target device
332 */ 332 */
333typedef struct _VirtDevice { 333typedef struct _VirtTarget {
334 struct scsi_device *device;
335 u8 tflags; 334 u8 tflags;
336 u8 ioc_id; 335 u8 ioc_id;
337 u8 target_id; 336 u8 target_id;
@@ -342,21 +341,18 @@ typedef struct _VirtDevice {
342 u8 negoFlags; /* bit field, see above */ 341 u8 negoFlags; /* bit field, see above */
343 u8 raidVolume; /* set, if RAID Volume */ 342 u8 raidVolume; /* set, if RAID Volume */
344 u8 type; /* byte 0 of Inquiry data */ 343 u8 type; /* byte 0 of Inquiry data */
345 u8 cflags; /* controller flags */
346 u8 rsvd1raid;
347 u16 fc_phys_lun;
348 u16 fc_xlat_lun;
349 u32 num_luns; 344 u32 num_luns;
350 u32 luns[8]; /* Max LUNs is 256 */ 345 u32 luns[8]; /* Max LUNs is 256 */
351 u8 pad[4];
352 u8 inq_data[8]; 346 u8 inq_data[8];
353 /* IEEE Registered Extended Identifier 347} VirtTarget;
354 obtained via INQUIRY VPD page 0x83 */ 348
355 /* NOTE: Do not separate uniq_prepad and uniq_data 349typedef struct _VirtDevice {
356 as they are treateed as a single entity in the code */ 350 VirtTarget *vtarget;
357 u8 uniq_prepad[8]; 351 u8 ioc_id;
358 u8 uniq_data[20]; 352 u8 bus_id;
359 u8 pad2[4]; 353 u8 target_id;
354 u8 configured_lun;
355 u32 lun;
360} VirtDevice; 356} VirtDevice;
361 357
362/* 358/*
@@ -903,7 +899,7 @@ typedef struct _MPT_LOCAL_REPLY {
903 899
904typedef enum { 900typedef enum {
905 FC, 901 FC,
906 SCSI, 902 SPI,
907 SAS 903 SAS
908} BUS_TYPE; 904} BUS_TYPE;
909 905
@@ -912,7 +908,7 @@ typedef struct _MPT_SCSI_HOST {
912 int port; 908 int port;
913 u32 pad0; 909 u32 pad0;
914 struct scsi_cmnd **ScsiLookup; 910 struct scsi_cmnd **ScsiLookup;
915 VirtDevice **Targets; 911 VirtTarget **Targets;
916 MPT_LOCAL_REPLY *pLocal; /* used for internal commands */ 912 MPT_LOCAL_REPLY *pLocal; /* used for internal commands */
917 struct timer_list timer; 913 struct timer_list timer;
918 /* Pool of memory for holding SCpnts before doing 914 /* Pool of memory for holding SCpnts before doing
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 602138f8544d..959d2c5951b8 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1245,7 +1245,7 @@ mptctl_gettargetinfo (unsigned long arg)
1245 MPT_ADAPTER *ioc; 1245 MPT_ADAPTER *ioc;
1246 struct Scsi_Host *sh; 1246 struct Scsi_Host *sh;
1247 MPT_SCSI_HOST *hd; 1247 MPT_SCSI_HOST *hd;
1248 VirtDevice *vdev; 1248 VirtTarget *vdev;
1249 char *pmem; 1249 char *pmem;
1250 int *pdata; 1250 int *pdata;
1251 IOCPage2_t *pIoc2; 1251 IOCPage2_t *pIoc2;
@@ -1822,7 +1822,7 @@ mptctl_do_mpt_command (struct mpt_ioctl_command karg, void __user *mfPtr)
1822 case MPI_FUNCTION_SCSI_IO_REQUEST: 1822 case MPI_FUNCTION_SCSI_IO_REQUEST:
1823 if (ioc->sh) { 1823 if (ioc->sh) {
1824 SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf; 1824 SCSIIORequest_t *pScsiReq = (SCSIIORequest_t *) mf;
1825 VirtDevice *pTarget = NULL; 1825 VirtTarget *pTarget = NULL;
1826 MPT_SCSI_HOST *hd = NULL; 1826 MPT_SCSI_HOST *hd = NULL;
1827 int qtag = MPI_SCSIIO_CONTROL_UNTAGGED; 1827 int qtag = MPI_SCSIIO_CONTROL_UNTAGGED;
1828 int scsidir = 0; 1828 int scsidir = 0;
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index a628be9bbbad..ba61e1828858 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -84,13 +84,16 @@ static int mptfcTaskCtx = -1;
84static int mptfcInternalCtx = -1; /* Used only for internal commands */ 84static int mptfcInternalCtx = -1; /* Used only for internal commands */
85 85
86static struct scsi_host_template mptfc_driver_template = { 86static struct scsi_host_template mptfc_driver_template = {
87 .module = THIS_MODULE,
87 .proc_name = "mptfc", 88 .proc_name = "mptfc",
88 .proc_info = mptscsih_proc_info, 89 .proc_info = mptscsih_proc_info,
89 .name = "MPT FC Host", 90 .name = "MPT FC Host",
90 .info = mptscsih_info, 91 .info = mptscsih_info,
91 .queuecommand = mptscsih_qcmd, 92 .queuecommand = mptscsih_qcmd,
93 .target_alloc = mptscsih_target_alloc,
92 .slave_alloc = mptscsih_slave_alloc, 94 .slave_alloc = mptscsih_slave_alloc,
93 .slave_configure = mptscsih_slave_configure, 95 .slave_configure = mptscsih_slave_configure,
96 .target_destroy = mptscsih_target_destroy,
94 .slave_destroy = mptscsih_slave_destroy, 97 .slave_destroy = mptscsih_slave_destroy,
95 .change_queue_depth = mptscsih_change_queue_depth, 98 .change_queue_depth = mptscsih_change_queue_depth,
96 .eh_abort_handler = mptscsih_abort, 99 .eh_abort_handler = mptscsih_abort,
@@ -167,13 +170,15 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
167 printk(MYIOC_s_WARN_FMT 170 printk(MYIOC_s_WARN_FMT
168 "Skipping because it's not operational!\n", 171 "Skipping because it's not operational!\n",
169 ioc->name); 172 ioc->name);
170 return -ENODEV; 173 error = -ENODEV;
174 goto out_mptfc_probe;
171 } 175 }
172 176
173 if (!ioc->active) { 177 if (!ioc->active) {
174 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 178 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
175 ioc->name); 179 ioc->name);
176 return -ENODEV; 180 error = -ENODEV;
181 goto out_mptfc_probe;
177 } 182 }
178 183
179 /* Sanity check - ensure at least 1 port is INITIATOR capable 184 /* Sanity check - ensure at least 1 port is INITIATOR capable
@@ -198,7 +203,8 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
198 printk(MYIOC_s_WARN_FMT 203 printk(MYIOC_s_WARN_FMT
199 "Unable to register controller with SCSI subsystem\n", 204 "Unable to register controller with SCSI subsystem\n",
200 ioc->name); 205 ioc->name);
201 return -1; 206 error = -1;
207 goto out_mptfc_probe;
202 } 208 }
203 209
204 spin_lock_irqsave(&ioc->FreeQlock, flags); 210 spin_lock_irqsave(&ioc->FreeQlock, flags);
@@ -266,7 +272,7 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
266 mem = kmalloc(sz, GFP_ATOMIC); 272 mem = kmalloc(sz, GFP_ATOMIC);
267 if (mem == NULL) { 273 if (mem == NULL) {
268 error = -ENOMEM; 274 error = -ENOMEM;
269 goto mptfc_probe_failed; 275 goto out_mptfc_probe;
270 } 276 }
271 277
272 memset(mem, 0, sz); 278 memset(mem, 0, sz);
@@ -284,14 +290,14 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
284 mem = kmalloc(sz, GFP_ATOMIC); 290 mem = kmalloc(sz, GFP_ATOMIC);
285 if (mem == NULL) { 291 if (mem == NULL) {
286 error = -ENOMEM; 292 error = -ENOMEM;
287 goto mptfc_probe_failed; 293 goto out_mptfc_probe;
288 } 294 }
289 295
290 memset(mem, 0, sz); 296 memset(mem, 0, sz);
291 hd->Targets = (VirtDevice **) mem; 297 hd->Targets = (VirtTarget **) mem;
292 298
293 dprintk((KERN_INFO 299 dprintk((KERN_INFO
294 " Targets @ %p, sz=%d\n", hd->Targets, sz)); 300 " vdev @ %p, sz=%d\n", hd->Targets, sz));
295 301
296 /* Clear the TM flags 302 /* Clear the TM flags
297 */ 303 */
@@ -330,13 +336,13 @@ mptfc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
330 if(error) { 336 if(error) {
331 dprintk((KERN_ERR MYNAM 337 dprintk((KERN_ERR MYNAM
332 "scsi_add_host failed\n")); 338 "scsi_add_host failed\n"));
333 goto mptfc_probe_failed; 339 goto out_mptfc_probe;
334 } 340 }
335 341
336 scsi_scan_host(sh); 342 scsi_scan_host(sh);
337 return 0; 343 return 0;
338 344
339mptfc_probe_failed: 345out_mptfc_probe:
340 346
341 mptscsih_remove(pdev); 347 mptscsih_remove(pdev);
342 return error; 348 return error;
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index e0a8bb8ba7d8..17e9757e728b 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -228,31 +228,35 @@ static void mptsas_print_expander_pg1(SasExpanderPage1_t *pg1)
228 * implement ->target_alloc. 228 * implement ->target_alloc.
229 */ 229 */
230static int 230static int
231mptsas_slave_alloc(struct scsi_device *device) 231mptsas_slave_alloc(struct scsi_device *sdev)
232{ 232{
233 struct Scsi_Host *host = device->host; 233 struct Scsi_Host *host = sdev->host;
234 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 234 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
235 struct sas_rphy *rphy; 235 struct sas_rphy *rphy;
236 struct mptsas_portinfo *p; 236 struct mptsas_portinfo *p;
237 VirtTarget *vtarget;
237 VirtDevice *vdev; 238 VirtDevice *vdev;
238 uint target = device->id; 239 struct scsi_target *starget;
239 int i; 240 int i;
240 241
241 if ((vdev = hd->Targets[target]) != NULL)
242 goto out;
243
244 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); 242 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
245 if (!vdev) { 243 if (!vdev) {
246 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n", 244 printk(MYIOC_s_ERR_FMT "slave_alloc kmalloc(%zd) FAILED!\n",
247 hd->ioc->name, sizeof(VirtDevice)); 245 hd->ioc->name, sizeof(VirtDevice));
248 return -ENOMEM; 246 return -ENOMEM;
249 } 247 }
250
251 memset(vdev, 0, sizeof(VirtDevice)); 248 memset(vdev, 0, sizeof(VirtDevice));
252 vdev->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY;
253 vdev->ioc_id = hd->ioc->id; 249 vdev->ioc_id = hd->ioc->id;
250 sdev->hostdata = vdev;
251 starget = scsi_target(sdev);
252 vtarget = starget->hostdata;
253 vdev->vtarget = vtarget;
254 if (vtarget->num_luns == 0) {
255 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES|MPT_TARGET_FLAGS_VALID_INQUIRY;
256 hd->Targets[sdev->id] = vtarget;
257 }
254 258
255 rphy = dev_to_rphy(device->sdev_target->dev.parent); 259 rphy = dev_to_rphy(sdev->sdev_target->dev.parent);
256 list_for_each_entry(p, &hd->ioc->sas_topology, list) { 260 list_for_each_entry(p, &hd->ioc->sas_topology, list) {
257 for (i = 0; i < p->num_phys; i++) { 261 for (i = 0; i < p->num_phys; i++) {
258 if (p->phy_info[i].attached.sas_address == 262 if (p->phy_info[i].attached.sas_address ==
@@ -260,7 +264,7 @@ mptsas_slave_alloc(struct scsi_device *device)
260 vdev->target_id = 264 vdev->target_id =
261 p->phy_info[i].attached.target; 265 p->phy_info[i].attached.target;
262 vdev->bus_id = p->phy_info[i].attached.bus; 266 vdev->bus_id = p->phy_info[i].attached.bus;
263 hd->Targets[device->id] = vdev; 267 vdev->lun = sdev->lun;
264 goto out; 268 goto out;
265 } 269 }
266 } 270 }
@@ -271,19 +275,24 @@ mptsas_slave_alloc(struct scsi_device *device)
271 return -ENODEV; 275 return -ENODEV;
272 276
273 out: 277 out:
274 vdev->num_luns++; 278 vtarget->ioc_id = vdev->ioc_id;
275 device->hostdata = vdev; 279 vtarget->target_id = vdev->target_id;
280 vtarget->bus_id = vdev->bus_id;
281 vtarget->num_luns++;
276 return 0; 282 return 0;
277} 283}
278 284
279static struct scsi_host_template mptsas_driver_template = { 285static struct scsi_host_template mptsas_driver_template = {
286 .module = THIS_MODULE,
280 .proc_name = "mptsas", 287 .proc_name = "mptsas",
281 .proc_info = mptscsih_proc_info, 288 .proc_info = mptscsih_proc_info,
282 .name = "MPT SPI Host", 289 .name = "MPT SPI Host",
283 .info = mptscsih_info, 290 .info = mptscsih_info,
284 .queuecommand = mptscsih_qcmd, 291 .queuecommand = mptscsih_qcmd,
292 .target_alloc = mptscsih_target_alloc,
285 .slave_alloc = mptsas_slave_alloc, 293 .slave_alloc = mptsas_slave_alloc,
286 .slave_configure = mptscsih_slave_configure, 294 .slave_configure = mptscsih_slave_configure,
295 .target_destroy = mptscsih_target_destroy,
287 .slave_destroy = mptscsih_slave_destroy, 296 .slave_destroy = mptscsih_slave_destroy,
288 .change_queue_depth = mptscsih_change_queue_depth, 297 .change_queue_depth = mptscsih_change_queue_depth,
289 .eh_abort_handler = mptscsih_abort, 298 .eh_abort_handler = mptscsih_abort,
@@ -986,7 +995,6 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc, int *index)
986 goto out_free_port_info; 995 goto out_free_port_info;
987 996
988 list_add_tail(&port_info->list, &ioc->sas_topology); 997 list_add_tail(&port_info->list, &ioc->sas_topology);
989
990 for (i = 0; i < port_info->num_phys; i++) { 998 for (i = 0; i < port_info->num_phys; i++) {
991 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i], 999 mptsas_sas_phy_pg0(ioc, &port_info->phy_info[i],
992 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER << 1000 (MPI_SAS_PHY_PGAD_FORM_PHY_NUMBER <<
@@ -1133,13 +1141,15 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1133 printk(MYIOC_s_WARN_FMT 1141 printk(MYIOC_s_WARN_FMT
1134 "Skipping because it's not operational!\n", 1142 "Skipping because it's not operational!\n",
1135 ioc->name); 1143 ioc->name);
1136 return -ENODEV; 1144 error = -ENODEV;
1145 goto out_mptsas_probe;
1137 } 1146 }
1138 1147
1139 if (!ioc->active) { 1148 if (!ioc->active) {
1140 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 1149 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
1141 ioc->name); 1150 ioc->name);
1142 return -ENODEV; 1151 error = -ENODEV;
1152 goto out_mptsas_probe;
1143 } 1153 }
1144 1154
1145 /* Sanity check - ensure at least 1 port is INITIATOR capable 1155 /* Sanity check - ensure at least 1 port is INITIATOR capable
@@ -1163,7 +1173,8 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1163 printk(MYIOC_s_WARN_FMT 1173 printk(MYIOC_s_WARN_FMT
1164 "Unable to register controller with SCSI subsystem\n", 1174 "Unable to register controller with SCSI subsystem\n",
1165 ioc->name); 1175 ioc->name);
1166 return -1; 1176 error = -1;
1177 goto out_mptsas_probe;
1167 } 1178 }
1168 1179
1169 spin_lock_irqsave(&ioc->FreeQlock, flags); 1180 spin_lock_irqsave(&ioc->FreeQlock, flags);
@@ -1237,7 +1248,7 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1237 mem = kmalloc(sz, GFP_ATOMIC); 1248 mem = kmalloc(sz, GFP_ATOMIC);
1238 if (mem == NULL) { 1249 if (mem == NULL) {
1239 error = -ENOMEM; 1250 error = -ENOMEM;
1240 goto mptsas_probe_failed; 1251 goto out_mptsas_probe;
1241 } 1252 }
1242 1253
1243 memset(mem, 0, sz); 1254 memset(mem, 0, sz);
@@ -1255,14 +1266,14 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1255 mem = kmalloc(sz, GFP_ATOMIC); 1266 mem = kmalloc(sz, GFP_ATOMIC);
1256 if (mem == NULL) { 1267 if (mem == NULL) {
1257 error = -ENOMEM; 1268 error = -ENOMEM;
1258 goto mptsas_probe_failed; 1269 goto out_mptsas_probe;
1259 } 1270 }
1260 1271
1261 memset(mem, 0, sz); 1272 memset(mem, 0, sz);
1262 hd->Targets = (VirtDevice **) mem; 1273 hd->Targets = (VirtTarget **) mem;
1263 1274
1264 dprintk((KERN_INFO 1275 dprintk((KERN_INFO
1265 " Targets @ %p, sz=%d\n", hd->Targets, sz)); 1276 " vtarget @ %p, sz=%d\n", hd->Targets, sz));
1266 1277
1267 /* Clear the TM flags 1278 /* Clear the TM flags
1268 */ 1279 */
@@ -1308,14 +1319,14 @@ mptsas_probe(struct pci_dev *pdev, const struct pci_device_id *id)
1308 if (error) { 1319 if (error) {
1309 dprintk((KERN_ERR MYNAM 1320 dprintk((KERN_ERR MYNAM
1310 "scsi_add_host failed\n")); 1321 "scsi_add_host failed\n"));
1311 goto mptsas_probe_failed; 1322 goto out_mptsas_probe;
1312 } 1323 }
1313 1324
1314 mptsas_scan_sas_topology(ioc); 1325 mptsas_scan_sas_topology(ioc);
1315 1326
1316 return 0; 1327 return 0;
1317 1328
1318mptsas_probe_failed: 1329out_mptsas_probe:
1319 1330
1320 mptscsih_remove(pdev); 1331 mptscsih_remove(pdev);
1321 return error; 1332 return error;
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index b7b9846ff3fd..93a16fa3c4ba 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -150,28 +150,29 @@ static int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 tar
150int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset); 150int mptscsih_ioc_reset(MPT_ADAPTER *ioc, int post_reset);
151int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply); 151int mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply);
152 152
153static void mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen); 153static void mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, u8 lun, char *data, int dlen);
154static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56); 154static void mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *vtarget, char byte56);
155static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq);
156static void mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *requestedPtr, int *configurationPtr, u8 flags); 155static void mptscsih_setDevicePage1Flags (u8 width, u8 factor, u8 offset, int *requestedPtr, int *configurationPtr, u8 flags);
157static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id); 156static void mptscsih_no_negotiate(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc);
158static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags); 157static int mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target, int flags);
159static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus); 158static int mptscsih_writeIOCPage4(MPT_SCSI_HOST *hd, int target_id, int bus);
160int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r); 159int mptscsih_scandv_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
161static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd); 160static int mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *iocmd);
162static int mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum); 161static void mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice);
162static void mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget);
163static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id);
163 164
164static struct work_struct mptscsih_persistTask; 165static struct work_struct mptscsih_persistTask;
165 166
166#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 167#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
167static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io); 168static int mptscsih_do_raid(MPT_SCSI_HOST *hd, u8 action, INTERNAL_CMD *io);
168static void mptscsih_domainValidation(void *hd); 169static void mptscsih_domainValidation(void *hd);
169static int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id);
170static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id); 170static void mptscsih_qas_check(MPT_SCSI_HOST *hd, int id);
171static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target); 171static int mptscsih_doDv(MPT_SCSI_HOST *hd, int channel, int target);
172static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage); 172static void mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage);
173static void mptscsih_fillbuf(char *buffer, int size, int index, int width); 173static void mptscsih_fillbuf(char *buffer, int size, int index, int width);
174static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id); 174static void mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id);
175static void mptscsih_set_dvflags(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc);
175#endif 176#endif
176 177
177void mptscsih_remove(struct pci_dev *); 178void mptscsih_remove(struct pci_dev *);
@@ -627,7 +628,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
627 dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n" 628 dreplyprintk((KERN_NOTICE "Reply ha=%d id=%d lun=%d:\n"
628 "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n" 629 "IOCStatus=%04xh SCSIState=%02xh SCSIStatus=%02xh\n"
629 "resid=%d bufflen=%d xfer_cnt=%d\n", 630 "resid=%d bufflen=%d xfer_cnt=%d\n",
630 ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], 631 ioc->id, sc->device->id, sc->device->lun,
631 status, scsi_state, scsi_status, sc->resid, 632 status, scsi_state, scsi_status, sc->resid,
632 sc->request_bufflen, xfer_cnt)); 633 sc->request_bufflen, xfer_cnt));
633 634
@@ -641,7 +642,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
641 pScsiReply->ResponseInfo) { 642 pScsiReply->ResponseInfo) {
642 printk(KERN_NOTICE "ha=%d id=%d lun=%d: " 643 printk(KERN_NOTICE "ha=%d id=%d lun=%d: "
643 "FCP_ResponseInfo=%08xh\n", 644 "FCP_ResponseInfo=%08xh\n",
644 ioc->id, pScsiReq->TargetID, pScsiReq->LUN[1], 645 ioc->id, sc->device->id, sc->device->lun,
645 le32_to_cpu(pScsiReply->ResponseInfo)); 646 le32_to_cpu(pScsiReply->ResponseInfo));
646 } 647 }
647 648
@@ -677,8 +678,8 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)
677 sc->result = DID_RESET << 16; 678 sc->result = DID_RESET << 16;
678 679
679 /* GEM Workaround. */ 680 /* GEM Workaround. */
680 if (ioc->bus_type == SCSI) 681 if (ioc->bus_type == SPI)
681 mptscsih_no_negotiate(hd, sc->device->id); 682 mptscsih_no_negotiate(hd, sc);
682 break; 683 break;
683 684
684 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */ 685 case MPI_IOCSTATUS_SCSI_RESIDUAL_MISMATCH: /* 0x0049 */
@@ -892,16 +893,15 @@ mptscsih_flush_running_cmds(MPT_SCSI_HOST *hd)
892 * when a lun is disable by mid-layer. 893 * when a lun is disable by mid-layer.
893 * Do NOT access the referenced scsi_cmnd structure or 894 * Do NOT access the referenced scsi_cmnd structure or
894 * members. Will cause either a paging or NULL ptr error. 895 * members. Will cause either a paging or NULL ptr error.
895 * @hd: Pointer to a SCSI HOST structure 896 * @hd: Pointer to a SCSI HOST structure
896 * @target: target id 897 * @vdevice: per device private data
897 * @lun: lun
898 * 898 *
899 * Returns: None. 899 * Returns: None.
900 * 900 *
901 * Called from slave_destroy. 901 * Called from slave_destroy.
902 */ 902 */
903static void 903static void
904mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun) 904mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
905{ 905{
906 SCSIIORequest_t *mf = NULL; 906 SCSIIORequest_t *mf = NULL;
907 int ii; 907 int ii;
@@ -909,7 +909,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun)
909 struct scsi_cmnd *sc; 909 struct scsi_cmnd *sc;
910 910
911 dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n", 911 dsprintk((KERN_INFO MYNAM ": search_running target %d lun %d max %d\n",
912 target, lun, max)); 912 vdevice->target_id, vdevice->lun, max));
913 913
914 for (ii=0; ii < max; ii++) { 914 for (ii=0; ii < max; ii++) {
915 if ((sc = hd->ScsiLookup[ii]) != NULL) { 915 if ((sc = hd->ScsiLookup[ii]) != NULL) {
@@ -919,7 +919,7 @@ mptscsih_search_running_cmds(MPT_SCSI_HOST *hd, uint target, uint lun)
919 dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n", 919 dsprintk(( "search_running: found (sc=%p, mf = %p) target %d, lun %d \n",
920 hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1])); 920 hd->ScsiLookup[ii], mf, mf->TargetID, mf->LUN[1]));
921 921
922 if ((mf->TargetID != ((u8)target)) || (mf->LUN[1] != ((u8) lun))) 922 if ((mf->TargetID != ((u8)vdevice->target_id)) || (mf->LUN[1] != ((u8) vdevice->lun)))
923 continue; 923 continue;
924 924
925 /* Cleanup 925 /* Cleanup
@@ -993,8 +993,10 @@ mptscsih_remove(struct pci_dev *pdev)
993 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 993 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
994 struct Scsi_Host *host = ioc->sh; 994 struct Scsi_Host *host = ioc->sh;
995 MPT_SCSI_HOST *hd; 995 MPT_SCSI_HOST *hd;
996#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
996 int count; 997 int count;
997 unsigned long flags; 998 unsigned long flags;
999#endif
998 int sz1; 1000 int sz1;
999 1001
1000 if(!host) { 1002 if(!host) {
@@ -1075,11 +1077,6 @@ mptscsih_shutdown(struct pci_dev *pdev)
1075 1077
1076 hd = (MPT_SCSI_HOST *)host->hostdata; 1078 hd = (MPT_SCSI_HOST *)host->hostdata;
1077 1079
1078 /* Flush the cache of this adapter
1079 */
1080 if(hd != NULL)
1081 mptscsih_synchronize_cache(hd, 0);
1082
1083} 1080}
1084 1081
1085#ifdef CONFIG_PM 1082#ifdef CONFIG_PM
@@ -1286,7 +1283,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1286 MPT_SCSI_HOST *hd; 1283 MPT_SCSI_HOST *hd;
1287 MPT_FRAME_HDR *mf; 1284 MPT_FRAME_HDR *mf;
1288 SCSIIORequest_t *pScsiReq; 1285 SCSIIORequest_t *pScsiReq;
1289 VirtDevice *pTarget = SCpnt->device->hostdata; 1286 VirtDevice *vdev = SCpnt->device->hostdata;
1290 int lun; 1287 int lun;
1291 u32 datalen; 1288 u32 datalen;
1292 u32 scsictl; 1289 u32 scsictl;
@@ -1341,8 +1338,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1341 /* Default to untagged. Once a target structure has been allocated, 1338 /* Default to untagged. Once a target structure has been allocated,
1342 * use the Inquiry data to determine if device supports tagged. 1339 * use the Inquiry data to determine if device supports tagged.
1343 */ 1340 */
1344 if (pTarget 1341 if (vdev
1345 && (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) 1342 && (vdev->vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)
1346 && (SCpnt->device->tagged_supported)) { 1343 && (SCpnt->device->tagged_supported)) {
1347 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ; 1344 scsictl = scsidir | MPI_SCSIIO_CONTROL_SIMPLEQ;
1348 } else { 1345 } else {
@@ -1351,8 +1348,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1351 1348
1352 /* Use the above information to set up the message frame 1349 /* Use the above information to set up the message frame
1353 */ 1350 */
1354 pScsiReq->TargetID = (u8) pTarget->target_id; 1351 pScsiReq->TargetID = (u8) vdev->target_id;
1355 pScsiReq->Bus = pTarget->bus_id; 1352 pScsiReq->Bus = vdev->bus_id;
1356 pScsiReq->ChainOffset = 0; 1353 pScsiReq->ChainOffset = 0;
1357 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST; 1354 pScsiReq->Function = MPI_FUNCTION_SCSI_IO_REQUEST;
1358 pScsiReq->CDBLength = SCpnt->cmd_len; 1355 pScsiReq->CDBLength = SCpnt->cmd_len;
@@ -1403,8 +1400,8 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1403 SCpnt->host_scribble = NULL; 1400 SCpnt->host_scribble = NULL;
1404 1401
1405#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 1402#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
1406 if (hd->ioc->bus_type == SCSI) { 1403 if (hd->ioc->bus_type == SPI) {
1407 int dvStatus = hd->ioc->spi_data.dvStatus[pTarget->target_id]; 1404 int dvStatus = hd->ioc->spi_data.dvStatus[vdev->target_id];
1408 int issueCmd = 1; 1405 int issueCmd = 1;
1409 1406
1410 if (dvStatus || hd->ioc->spi_data.forceDv) { 1407 if (dvStatus || hd->ioc->spi_data.forceDv) {
@@ -1437,7 +1434,7 @@ mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *))
1437 /* Set the DV flags. 1434 /* Set the DV flags.
1438 */ 1435 */
1439 if (dvStatus & MPT_SCSICFG_DV_NOT_DONE) 1436 if (dvStatus & MPT_SCSICFG_DV_NOT_DONE)
1440 mptscsih_set_dvflags(hd, pScsiReq); 1437 mptscsih_set_dvflags(hd, SCpnt);
1441 1438
1442 if (!issueCmd) 1439 if (!issueCmd)
1443 goto fail; 1440 goto fail;
@@ -1741,6 +1738,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1741 u32 ctx2abort; 1738 u32 ctx2abort;
1742 int scpnt_idx; 1739 int scpnt_idx;
1743 int retval; 1740 int retval;
1741 VirtDevice *vdev;
1744 1742
1745 /* If we can't locate our host adapter structure, return FAILED status. 1743 /* If we can't locate our host adapter structure, return FAILED status.
1746 */ 1744 */
@@ -1790,8 +1788,9 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
1790 1788
1791 hd->abortSCpnt = SCpnt; 1789 hd->abortSCpnt = SCpnt;
1792 1790
1791 vdev = SCpnt->device->hostdata;
1793 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK, 1792 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_ABORT_TASK,
1794 SCpnt->device->channel, SCpnt->device->id, SCpnt->device->lun, 1793 vdev->bus_id, vdev->target_id, vdev->lun,
1795 ctx2abort, 2 /* 2 second timeout */); 1794 ctx2abort, 2 /* 2 second timeout */);
1796 1795
1797 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n", 1796 printk (KERN_WARNING MYNAM ": %s: task abort: %s (sc=%p)\n",
@@ -1822,6 +1821,7 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1822{ 1821{
1823 MPT_SCSI_HOST *hd; 1822 MPT_SCSI_HOST *hd;
1824 int retval; 1823 int retval;
1824 VirtDevice *vdev;
1825 1825
1826 /* If we can't locate our host adapter structure, return FAILED status. 1826 /* If we can't locate our host adapter structure, return FAILED status.
1827 */ 1827 */
@@ -1839,8 +1839,9 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
1839 hd->ioc->name, SCpnt); 1839 hd->ioc->name, SCpnt);
1840 scsi_print_command(SCpnt); 1840 scsi_print_command(SCpnt);
1841 1841
1842 vdev = SCpnt->device->hostdata;
1842 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 1843 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
1843 SCpnt->device->channel, SCpnt->device->id, 1844 vdev->bus_id, vdev->target_id,
1844 0, 0, 5 /* 5 second timeout */); 1845 0, 0, 5 /* 5 second timeout */);
1845 1846
1846 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n", 1847 printk (KERN_WARNING MYNAM ": %s: target reset: %s (sc=%p)\n",
@@ -1871,6 +1872,7 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1871{ 1872{
1872 MPT_SCSI_HOST *hd; 1873 MPT_SCSI_HOST *hd;
1873 int retval; 1874 int retval;
1875 VirtDevice *vdev;
1874 1876
1875 /* If we can't locate our host adapter structure, return FAILED status. 1877 /* If we can't locate our host adapter structure, return FAILED status.
1876 */ 1878 */
@@ -1888,8 +1890,9 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
1888 if (hd->timeouts < -1) 1890 if (hd->timeouts < -1)
1889 hd->timeouts++; 1891 hd->timeouts++;
1890 1892
1893 vdev = SCpnt->device->hostdata;
1891 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS, 1894 retval = mptscsih_TMHandler(hd, MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
1892 SCpnt->device->channel, 0, 0, 0, 5 /* 5 second timeout */); 1895 vdev->bus_id, 0, 0, 0, 5 /* 5 second timeout */);
1893 1896
1894 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n", 1897 printk (KERN_WARNING MYNAM ": %s: bus reset: %s (sc=%p)\n",
1895 hd->ioc->name, 1898 hd->ioc->name,
@@ -2151,23 +2154,36 @@ mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev,
2151/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2154/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2152/* 2155/*
2153 * OS entry point to allow host driver to alloc memory 2156 * OS entry point to allow host driver to alloc memory
2157 * for each scsi target. Called once per device the bus scan.
2158 * Return non-zero if allocation fails.
2159 */
2160int
2161mptscsih_target_alloc(struct scsi_target *starget)
2162{
2163 VirtTarget *vtarget;
2164
2165 vtarget = kmalloc(sizeof(VirtTarget), GFP_KERNEL);
2166 if (!vtarget)
2167 return -ENOMEM;
2168 memset(vtarget, 0, sizeof(VirtTarget));
2169 starget->hostdata = vtarget;
2170 return 0;
2171}
2172
2173/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2174/*
2175 * OS entry point to allow host driver to alloc memory
2154 * for each scsi device. Called once per device the bus scan. 2176 * for each scsi device. Called once per device the bus scan.
2155 * Return non-zero if allocation fails. 2177 * Return non-zero if allocation fails.
2156 * Init memory once per id (not LUN).
2157 */ 2178 */
2158int 2179int
2159mptscsih_slave_alloc(struct scsi_device *device) 2180mptscsih_slave_alloc(struct scsi_device *sdev)
2160{ 2181{
2161 struct Scsi_Host *host = device->host; 2182 struct Scsi_Host *host = sdev->host;
2162 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 2183 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
2184 VirtTarget *vtarget;
2163 VirtDevice *vdev; 2185 VirtDevice *vdev;
2164 uint target = device->id; 2186 struct scsi_target *starget;
2165
2166 if (hd == NULL)
2167 return -ENODEV;
2168
2169 if ((vdev = hd->Targets[target]) != NULL)
2170 goto out;
2171 2187
2172 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL); 2188 vdev = kmalloc(sizeof(VirtDevice), GFP_KERNEL);
2173 if (!vdev) { 2189 if (!vdev) {
@@ -2177,25 +2193,33 @@ mptscsih_slave_alloc(struct scsi_device *device)
2177 } 2193 }
2178 2194
2179 memset(vdev, 0, sizeof(VirtDevice)); 2195 memset(vdev, 0, sizeof(VirtDevice));
2180 vdev->tflags = MPT_TARGET_FLAGS_Q_YES;
2181 vdev->ioc_id = hd->ioc->id; 2196 vdev->ioc_id = hd->ioc->id;
2182 vdev->target_id = device->id; 2197 vdev->target_id = sdev->id;
2183 vdev->bus_id = device->channel; 2198 vdev->bus_id = sdev->channel;
2184 vdev->raidVolume = 0; 2199 vdev->lun = sdev->lun;
2185 hd->Targets[device->id] = vdev; 2200 sdev->hostdata = vdev;
2186 if (hd->ioc->bus_type == SCSI) { 2201
2187 if (hd->ioc->raid_data.isRaid & (1 << device->id)) { 2202 starget = scsi_target(sdev);
2188 vdev->raidVolume = 1; 2203 vtarget = starget->hostdata;
2189 ddvtprintk((KERN_INFO 2204 vdev->vtarget = vtarget;
2190 "RAID Volume @ id %d\n", device->id)); 2205
2206 if (vtarget->num_luns == 0) {
2207 hd->Targets[sdev->id] = vtarget;
2208 vtarget->ioc_id = hd->ioc->id;
2209 vtarget->tflags = MPT_TARGET_FLAGS_Q_YES;
2210 vtarget->target_id = sdev->id;
2211 vtarget->bus_id = sdev->channel;
2212 if (hd->ioc->bus_type == SPI) {
2213 if (hd->ioc->raid_data.isRaid & (1 << sdev->id)) {
2214 vtarget->raidVolume = 1;
2215 ddvtprintk((KERN_INFO
2216 "RAID Volume @ id %d\n", sdev->id));
2217 }
2218 } else {
2219 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2191 } 2220 }
2192 } else {
2193 vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2194 } 2221 }
2195 2222 vtarget->num_luns++;
2196 out:
2197 vdev->num_luns++;
2198 device->hostdata = vdev;
2199 return 0; 2223 return 0;
2200} 2224}
2201 2225
@@ -2204,40 +2228,52 @@ mptscsih_slave_alloc(struct scsi_device *device)
2204 * Called if no device present or device being unloaded 2228 * Called if no device present or device being unloaded
2205 */ 2229 */
2206void 2230void
2207mptscsih_slave_destroy(struct scsi_device *device) 2231mptscsih_target_destroy(struct scsi_target *starget)
2208{ 2232{
2209 struct Scsi_Host *host = device->host; 2233 if (starget->hostdata)
2210 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata; 2234 kfree(starget->hostdata);
2211 VirtDevice *vdev; 2235 starget->hostdata = NULL;
2212 uint target = device->id; 2236}
2213 uint lun = device->lun;
2214
2215 if (hd == NULL)
2216 return;
2217
2218 mptscsih_search_running_cmds(hd, target, lun);
2219
2220 vdev = hd->Targets[target];
2221 vdev->luns[0] &= ~(1 << lun);
2222 if (--vdev->num_luns)
2223 return;
2224
2225 kfree(hd->Targets[target]);
2226 hd->Targets[target] = NULL;
2227
2228 if (hd->ioc->bus_type == SCSI) {
2229 if (mptscsih_is_phys_disk(hd->ioc, target)) {
2230 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
2231 } else {
2232 hd->ioc->spi_data.dvStatus[target] =
2233 MPT_SCSICFG_NEGOTIATE;
2234 2237
2235 if (!hd->negoNvram) { 2238/*
2236 hd->ioc->spi_data.dvStatus[target] |= 2239 * OS entry point to allow for host driver to free allocated memory
2237 MPT_SCSICFG_DV_NOT_DONE; 2240 * Called if no device present or device being unloaded
2241 */
2242void
2243mptscsih_slave_destroy(struct scsi_device *sdev)
2244{
2245 struct Scsi_Host *host = sdev->host;
2246 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
2247 VirtTarget *vtarget;
2248 VirtDevice *vdevice;
2249 struct scsi_target *starget;
2250
2251 starget = scsi_target(sdev);
2252 vtarget = starget->hostdata;
2253 vdevice = sdev->hostdata;
2254
2255 mptscsih_search_running_cmds(hd, vdevice);
2256 vtarget->luns[0] &= ~(1 << vdevice->lun);
2257 vtarget->num_luns--;
2258 if (vtarget->num_luns == 0) {
2259 mptscsih_negotiate_to_asyn_narrow(hd, vtarget);
2260 if (hd->ioc->bus_type == SPI) {
2261 if (mptscsih_is_phys_disk(hd->ioc, vtarget->target_id)) {
2262 hd->ioc->spi_data.forceDv |= MPT_SCSICFG_RELOAD_IOC_PG3;
2263 } else {
2264 hd->ioc->spi_data.dvStatus[vtarget->target_id] =
2265 MPT_SCSICFG_NEGOTIATE;
2266 if (!hd->negoNvram) {
2267 hd->ioc->spi_data.dvStatus[vtarget->target_id] |=
2268 MPT_SCSICFG_DV_NOT_DONE;
2269 }
2238 } 2270 }
2239 } 2271 }
2272 hd->Targets[sdev->id] = NULL;
2240 } 2273 }
2274 mptscsih_synchronize_cache(hd, vdevice);
2275 kfree(vdevice);
2276 sdev->hostdata = NULL;
2241} 2277}
2242 2278
2243/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2279/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
@@ -2251,22 +2287,21 @@ mptscsih_slave_destroy(struct scsi_device *device)
2251int 2287int
2252mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth) 2288mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
2253{ 2289{
2254 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata; 2290 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sdev->host->hostdata;
2255 VirtDevice *pTarget; 2291 VirtTarget *vtarget;
2256 int max_depth; 2292 struct scsi_target *starget;
2257 int tagged; 2293 int max_depth;
2258 2294 int tagged;
2259 if (hd == NULL) 2295
2260 return 0; 2296 starget = scsi_target(sdev);
2261 if (!(pTarget = hd->Targets[sdev->id])) 2297 vtarget = starget->hostdata;
2262 return 0; 2298
2263 2299 if (hd->ioc->bus_type == SPI) {
2264 if (hd->ioc->bus_type == SCSI) { 2300 if (vtarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) {
2265 if (pTarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY) { 2301 if (!(vtarget->tflags & MPT_TARGET_FLAGS_Q_YES))
2266 if (!(pTarget->tflags & MPT_TARGET_FLAGS_Q_YES))
2267 max_depth = 1; 2302 max_depth = 1;
2268 else if (((pTarget->inq_data[0] & 0x1f) == 0x00) && 2303 else if (((vtarget->inq_data[0] & 0x1f) == 0x00) &&
2269 (pTarget->minSyncFactor <= MPT_ULTRA160 )) 2304 (vtarget->minSyncFactor <= MPT_ULTRA160 ))
2270 max_depth = MPT_SCSI_CMD_PER_DEV_HIGH; 2305 max_depth = MPT_SCSI_CMD_PER_DEV_HIGH;
2271 else 2306 else
2272 max_depth = MPT_SCSI_CMD_PER_DEV_LOW; 2307 max_depth = MPT_SCSI_CMD_PER_DEV_LOW;
@@ -2295,64 +2330,58 @@ mptscsih_change_queue_depth(struct scsi_device *sdev, int qdepth)
2295 * Return non-zero if fails. 2330 * Return non-zero if fails.
2296 */ 2331 */
2297int 2332int
2298mptscsih_slave_configure(struct scsi_device *device) 2333mptscsih_slave_configure(struct scsi_device *sdev)
2299{ 2334{
2300 struct Scsi_Host *sh = device->host; 2335 struct Scsi_Host *sh = sdev->host;
2301 VirtDevice *pTarget; 2336 VirtTarget *vtarget;
2337 VirtDevice *vdevice;
2338 struct scsi_target *starget;
2302 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata; 2339 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)sh->hostdata;
2340 int indexed_lun, lun_index;
2303 2341
2304 if ((hd == NULL) || (hd->Targets == NULL)) { 2342 starget = scsi_target(sdev);
2305 return 0; 2343 vtarget = starget->hostdata;
2306 } 2344 vdevice = sdev->hostdata;
2307 2345
2308 dsprintk((MYIOC_s_INFO_FMT 2346 dsprintk((MYIOC_s_INFO_FMT
2309 "device @ %p, id=%d, LUN=%d, channel=%d\n", 2347 "device @ %p, id=%d, LUN=%d, channel=%d\n",
2310 hd->ioc->name, device, device->id, device->lun, device->channel)); 2348 hd->ioc->name, sdev, sdev->id, sdev->lun, sdev->channel));
2311 dsprintk((MYIOC_s_INFO_FMT 2349 if (hd->ioc->bus_type == SPI)
2312 "sdtr %d wdtr %d ppr %d inq length=%d\n", 2350 dsprintk((MYIOC_s_INFO_FMT
2313 hd->ioc->name, device->sdtr, device->wdtr, 2351 "sdtr %d wdtr %d ppr %d inq length=%d\n",
2314 device->ppr, device->inquiry_len)); 2352 hd->ioc->name, sdev->sdtr, sdev->wdtr,
2315 2353 sdev->ppr, sdev->inquiry_len));
2316 if (device->id > sh->max_id) { 2354
2355 if (sdev->id > sh->max_id) {
2317 /* error case, should never happen */ 2356 /* error case, should never happen */
2318 scsi_adjust_queue_depth(device, 0, 1); 2357 scsi_adjust_queue_depth(sdev, 0, 1);
2319 goto slave_configure_exit;
2320 }
2321
2322 pTarget = hd->Targets[device->id];
2323
2324 if (pTarget == NULL) {
2325 /* Driver doesn't know about this device.
2326 * Kernel may generate a "Dummy Lun 0" which
2327 * may become a real Lun if a
2328 * "scsi add-single-device" command is executed
2329 * while the driver is active (hot-plug a
2330 * device). LSI Raid controllers need
2331 * queue_depth set to DEV_HIGH for this reason.
2332 */
2333 scsi_adjust_queue_depth(device, MSG_SIMPLE_TAG,
2334 MPT_SCSI_CMD_PER_DEV_HIGH);
2335 goto slave_configure_exit; 2358 goto slave_configure_exit;
2336 } 2359 }
2337 2360
2338 mptscsih_initTarget(hd, device->channel, device->id, device->lun, 2361 vdevice->configured_lun=1;
2339 device->inquiry, device->inquiry_len ); 2362 lun_index = (vdevice->lun >> 5); /* 32 luns per lun_index */
2340 mptscsih_change_queue_depth(device, MPT_SCSI_CMD_PER_DEV_HIGH); 2363 indexed_lun = (vdevice->lun % 32);
2364 vtarget->luns[lun_index] |= (1 << indexed_lun);
2365 mptscsih_initTarget(hd, vtarget, sdev->lun, sdev->inquiry,
2366 sdev->inquiry_len );
2367 mptscsih_change_queue_depth(sdev, MPT_SCSI_CMD_PER_DEV_HIGH);
2341 2368
2342 dsprintk((MYIOC_s_INFO_FMT 2369 dsprintk((MYIOC_s_INFO_FMT
2343 "Queue depth=%d, tflags=%x\n", 2370 "Queue depth=%d, tflags=%x\n",
2344 hd->ioc->name, device->queue_depth, pTarget->tflags)); 2371 hd->ioc->name, sdev->queue_depth, vtarget->tflags));
2345 2372
2346 dsprintk((MYIOC_s_INFO_FMT 2373 if (hd->ioc->bus_type == SPI)
2347 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n", 2374 dsprintk((MYIOC_s_INFO_FMT
2348 hd->ioc->name, pTarget->negoFlags, pTarget->maxOffset, pTarget->minSyncFactor)); 2375 "negoFlags=%x, maxOffset=%x, SyncFactor=%x\n",
2376 hd->ioc->name, vtarget->negoFlags, vtarget->maxOffset,
2377 vtarget->minSyncFactor));
2349 2378
2350slave_configure_exit: 2379slave_configure_exit:
2351 2380
2352 dsprintk((MYIOC_s_INFO_FMT 2381 dsprintk((MYIOC_s_INFO_FMT
2353 "tagged %d, simple %d, ordered %d\n", 2382 "tagged %d, simple %d, ordered %d\n",
2354 hd->ioc->name,device->tagged_supported, device->simple_tags, 2383 hd->ioc->name,sdev->tagged_supported, sdev->simple_tags,
2355 device->ordered_tags)); 2384 sdev->ordered_tags));
2356 2385
2357 return 0; 2386 return 0;
2358} 2387}
@@ -2370,16 +2399,14 @@ slave_configure_exit:
2370static void 2399static void
2371mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply) 2400mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR *mf, SCSIIOReply_t *pScsiReply)
2372{ 2401{
2373 VirtDevice *target; 2402 VirtDevice *vdev;
2374 SCSIIORequest_t *pReq; 2403 SCSIIORequest_t *pReq;
2375 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount); 2404 u32 sense_count = le32_to_cpu(pScsiReply->SenseCount);
2376 int index;
2377 2405
2378 /* Get target structure 2406 /* Get target structure
2379 */ 2407 */
2380 pReq = (SCSIIORequest_t *) mf; 2408 pReq = (SCSIIORequest_t *) mf;
2381 index = (int) pReq->TargetID; 2409 vdev = sc->device->hostdata;
2382 target = hd->Targets[index];
2383 2410
2384 if (sense_count) { 2411 if (sense_count) {
2385 u8 *sense_data; 2412 u8 *sense_data;
@@ -2393,7 +2420,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2393 /* Log SMART data (asc = 0x5D, non-IM case only) if required. 2420 /* Log SMART data (asc = 0x5D, non-IM case only) if required.
2394 */ 2421 */
2395 if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) { 2422 if ((hd->ioc->events) && (hd->ioc->eventTypes & (1 << MPI_EVENT_SCSI_DEVICE_STATUS_CHANGE))) {
2396 if ((sense_data[12] == 0x5D) && (target->raidVolume == 0)) { 2423 if ((sense_data[12] == 0x5D) && (vdev->vtarget->raidVolume == 0)) {
2397 int idx; 2424 int idx;
2398 MPT_ADAPTER *ioc = hd->ioc; 2425 MPT_ADAPTER *ioc = hd->ioc;
2399 2426
@@ -2403,7 +2430,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR
2403 2430
2404 ioc->events[idx].data[0] = (pReq->LUN[1] << 24) || 2431 ioc->events[idx].data[0] = (pReq->LUN[1] << 24) ||
2405 (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) || 2432 (MPI_EVENT_SCSI_DEV_STAT_RC_SMART_DATA << 16) ||
2406 (pReq->Bus << 8) || pReq->TargetID; 2433 (sc->device->channel << 8) || sc->device->id;
2407 2434
2408 ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12]; 2435 ioc->events[idx].data[1] = (sense_data[13] << 8) || sense_data[12];
2409 2436
@@ -2503,9 +2530,9 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2503 /* 2. Chain Buffer initialization 2530 /* 2. Chain Buffer initialization
2504 */ 2531 */
2505 2532
2506 /* 4. Renegotiate to all devices, if SCSI 2533 /* 4. Renegotiate to all devices, if SPI
2507 */ 2534 */
2508 if (ioc->bus_type == SCSI) { 2535 if (ioc->bus_type == SPI) {
2509 dnegoprintk(("writeSDP1: ALL_IDS USE_NVRAM\n")); 2536 dnegoprintk(("writeSDP1: ALL_IDS USE_NVRAM\n"));
2510 mptscsih_writeSDP1(hd, 0, 0, MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM); 2537 mptscsih_writeSDP1(hd, 0, 0, MPT_SCSICFG_ALL_IDS | MPT_SCSICFG_USE_NVRAM);
2511 } 2538 }
@@ -2534,7 +2561,7 @@ mptscsih_ioc_reset(MPT_ADAPTER *ioc, int reset_phase)
2534 2561
2535 /* 7. Set flag to force DV and re-read IOC Page 3 2562 /* 7. Set flag to force DV and re-read IOC Page 3
2536 */ 2563 */
2537 if (ioc->bus_type == SCSI) { 2564 if (ioc->bus_type == SPI) {
2538 ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3; 2565 ioc->spi_data.forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
2539 ddvtprintk(("Set reload IOC Pg3 Flag\n")); 2566 ddvtprintk(("Set reload IOC Pg3 Flag\n"));
2540 } 2567 }
@@ -2576,7 +2603,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2576 break; 2603 break;
2577 case MPI_EVENT_IOC_BUS_RESET: /* 04 */ 2604 case MPI_EVENT_IOC_BUS_RESET: /* 04 */
2578 case MPI_EVENT_EXT_BUS_RESET: /* 05 */ 2605 case MPI_EVENT_EXT_BUS_RESET: /* 05 */
2579 if (hd && (ioc->bus_type == SCSI) && (hd->soft_resets < -1)) 2606 if (hd && (ioc->bus_type == SPI) && (hd->soft_resets < -1))
2580 hd->soft_resets++; 2607 hd->soft_resets++;
2581 break; 2608 break;
2582 case MPI_EVENT_LOGOUT: /* 09 */ 2609 case MPI_EVENT_LOGOUT: /* 09 */
@@ -2597,11 +2624,11 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2597 2624
2598 case MPI_EVENT_INTEGRATED_RAID: /* 0B */ 2625 case MPI_EVENT_INTEGRATED_RAID: /* 0B */
2599 { 2626 {
2627#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
2600 pMpiEventDataRaid_t pRaidEventData = 2628 pMpiEventDataRaid_t pRaidEventData =
2601 (pMpiEventDataRaid_t) pEvReply->Data; 2629 (pMpiEventDataRaid_t) pEvReply->Data;
2602#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
2603 /* Domain Validation Needed */ 2630 /* Domain Validation Needed */
2604 if (ioc->bus_type == SCSI && 2631 if (ioc->bus_type == SPI &&
2605 pRaidEventData->ReasonCode == 2632 pRaidEventData->ReasonCode ==
2606 MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED) 2633 MPI_EVENT_RAID_RC_DOMAIN_VAL_NEEDED)
2607 mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum); 2634 mptscsih_set_dvflags_raid(hd, pRaidEventData->PhysDiskNum);
@@ -2632,8 +2659,7 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2632/* 2659/*
2633 * mptscsih_initTarget - Target, LUN alloc/free functionality. 2660 * mptscsih_initTarget - Target, LUN alloc/free functionality.
2634 * @hd: Pointer to MPT_SCSI_HOST structure 2661 * @hd: Pointer to MPT_SCSI_HOST structure
2635 * @bus_id: Bus number (?) 2662 * @vtarget: per target private data
2636 * @target_id: SCSI target id
2637 * @lun: SCSI LUN id 2663 * @lun: SCSI LUN id
2638 * @data: Pointer to data 2664 * @data: Pointer to data
2639 * @dlen: Number of INQUIRY bytes 2665 * @dlen: Number of INQUIRY bytes
@@ -2646,15 +2672,14 @@ mptscsih_event_process(MPT_ADAPTER *ioc, EventNotificationReply_t *pEvReply)
2646 * 2672 *
2647 */ 2673 */
2648static void 2674static void
2649mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *data, int dlen) 2675mptscsih_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget, u8 lun, char *data, int dlen)
2650{ 2676{
2651 int indexed_lun, lun_index;
2652 VirtDevice *vdev;
2653 SpiCfgData *pSpi; 2677 SpiCfgData *pSpi;
2654 char data_56; 2678 char data_56;
2679 int inq_len;
2655 2680
2656 dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n", 2681 dinitprintk((MYIOC_s_INFO_FMT "initTarget bus=%d id=%d lun=%d hd=%p\n",
2657 hd->ioc->name, bus_id, target_id, lun, hd)); 2682 hd->ioc->name, vtarget->bus_id, vtarget->target_id, lun, hd));
2658 2683
2659 /* 2684 /*
2660 * If the peripheral qualifier filter is enabled then if the target reports a 0x1 2685 * If the peripheral qualifier filter is enabled then if the target reports a 0x1
@@ -2674,75 +2699,68 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
2674 if (data[0] & 0xe0) 2699 if (data[0] & 0xe0)
2675 return; 2700 return;
2676 2701
2677 if ((vdev = hd->Targets[target_id]) == NULL) { 2702 if (vtarget == NULL)
2678 return; 2703 return;
2679 }
2680 2704
2681 lun_index = (lun >> 5); /* 32 luns per lun_index */ 2705 if (data)
2682 indexed_lun = (lun % 32); 2706 vtarget->type = data[0];
2683 vdev->luns[lun_index] |= (1 << indexed_lun); 2707
2684 2708 if (hd->ioc->bus_type != SPI)
2685 if (hd->ioc->bus_type == SCSI) { 2709 return;
2686 if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) { 2710
2687 /* Treat all Processors as SAF-TE if 2711 if ((data[0] == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) {
2688 * command line option is set */ 2712 /* Treat all Processors as SAF-TE if
2689 vdev->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; 2713 * command line option is set */
2690 mptscsih_writeIOCPage4(hd, target_id, bus_id); 2714 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
2691 }else if ((data[0] == TYPE_PROCESSOR) && 2715 mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id);
2692 !(vdev->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) { 2716 }else if ((data[0] == TYPE_PROCESSOR) &&
2693 if ( dlen > 49 ) { 2717 !(vtarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) {
2694 vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY; 2718 if ( dlen > 49 ) {
2695 if ( data[44] == 'S' && 2719 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2696 data[45] == 'A' && 2720 if ( data[44] == 'S' &&
2697 data[46] == 'F' && 2721 data[45] == 'A' &&
2698 data[47] == '-' && 2722 data[46] == 'F' &&
2699 data[48] == 'T' && 2723 data[47] == '-' &&
2700 data[49] == 'E' ) { 2724 data[48] == 'T' &&
2701 vdev->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED; 2725 data[49] == 'E' ) {
2702 mptscsih_writeIOCPage4(hd, target_id, bus_id); 2726 vtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;
2703 } 2727 mptscsih_writeIOCPage4(hd, vtarget->target_id, vtarget->bus_id);
2704 } 2728 }
2705 } 2729 }
2706 if (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) { 2730 }
2707 if ( dlen > 8 ) { 2731 if (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_INQUIRY)) {
2708 memcpy (vdev->inq_data, data, 8); 2732 inq_len = dlen < 8 ? dlen : 8;
2709 } else { 2733 memcpy (vtarget->inq_data, data, inq_len);
2710 memcpy (vdev->inq_data, data, dlen); 2734 /* If have not done DV, set the DV flag.
2711 } 2735 */
2736 pSpi = &hd->ioc->spi_data;
2737 if ((data[0] == TYPE_TAPE) || (data[0] == TYPE_PROCESSOR)) {
2738 if (pSpi->dvStatus[vtarget->target_id] & MPT_SCSICFG_DV_NOT_DONE)
2739 pSpi->dvStatus[vtarget->target_id] |= MPT_SCSICFG_NEED_DV;
2740 }
2741 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2712 2742
2713 /* If have not done DV, set the DV flag. 2743 data_56 = 0x0F; /* Default to full capabilities if Inq data length is < 57 */
2744 if (dlen > 56) {
2745 if ( (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_56))) {
2746 /* Update the target capabilities
2714 */ 2747 */
2715 pSpi = &hd->ioc->spi_data; 2748 data_56 = data[56];
2716 if ((data[0] == TYPE_TAPE) || (data[0] == TYPE_PROCESSOR)) { 2749 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_56;
2717 if (pSpi->dvStatus[target_id] & MPT_SCSICFG_DV_NOT_DONE)
2718 pSpi->dvStatus[target_id] |= MPT_SCSICFG_NEED_DV;
2719 }
2720
2721 vdev->tflags |= MPT_TARGET_FLAGS_VALID_INQUIRY;
2722
2723
2724 data_56 = 0x0F; /* Default to full capabilities if Inq data length is < 57 */
2725 if (dlen > 56) {
2726 if ( (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_56))) {
2727 /* Update the target capabilities
2728 */
2729 data_56 = data[56];
2730 vdev->tflags |= MPT_TARGET_FLAGS_VALID_56;
2731 }
2732 } 2750 }
2733 mptscsih_setTargetNegoParms(hd, vdev, data_56); 2751 }
2734 } else { 2752 mptscsih_setTargetNegoParms(hd, vtarget, data_56);
2735 /* Initial Inquiry may not request enough data bytes to 2753 } else {
2736 * obtain byte 57. DV will; if target doesn't return 2754 /* Initial Inquiry may not request enough data bytes to
2737 * at least 57 bytes, data[56] will be zero. */ 2755 * obtain byte 57. DV will; if target doesn't return
2738 if (dlen > 56) { 2756 * at least 57 bytes, data[56] will be zero. */
2739 if ( (!(vdev->tflags & MPT_TARGET_FLAGS_VALID_56))) { 2757 if (dlen > 56) {
2740 /* Update the target capabilities 2758 if ( (!(vtarget->tflags & MPT_TARGET_FLAGS_VALID_56))) {
2741 */ 2759 /* Update the target capabilities
2742 data_56 = data[56]; 2760 */
2743 vdev->tflags |= MPT_TARGET_FLAGS_VALID_56; 2761 data_56 = data[56];
2744 mptscsih_setTargetNegoParms(hd, vdev, data_56); 2762 vtarget->tflags |= MPT_TARGET_FLAGS_VALID_56;
2745 } 2763 mptscsih_setTargetNegoParms(hd, vtarget, data_56);
2746 } 2764 }
2747 } 2765 }
2748 } 2766 }
@@ -2755,12 +2773,12 @@ mptscsih_initTarget(MPT_SCSI_HOST *hd, int bus_id, int target_id, u8 lun, char *
2755 * 2773 *
2756 */ 2774 */
2757static void 2775static void
2758mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56) 2776mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtTarget *target, char byte56)
2759{ 2777{
2760 SpiCfgData *pspi_data = &hd->ioc->spi_data; 2778 SpiCfgData *pspi_data = &hd->ioc->spi_data;
2761 int id = (int) target->target_id; 2779 int id = (int) target->target_id;
2762 int nvram; 2780 int nvram;
2763 VirtDevice *vdev; 2781 VirtTarget *vtarget;
2764 int ii; 2782 int ii;
2765 u8 width = MPT_NARROW; 2783 u8 width = MPT_NARROW;
2766 u8 factor = MPT_ASYNC; 2784 u8 factor = MPT_ASYNC;
@@ -2905,9 +2923,9 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
2905 2923
2906 ddvtprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id)); 2924 ddvtprintk((KERN_INFO "Disabling QAS due to noQas=%02x on id=%d!\n", noQas, id));
2907 for (ii = 0; ii < id; ii++) { 2925 for (ii = 0; ii < id; ii++) {
2908 if ( (vdev = hd->Targets[ii]) ) { 2926 if ( (vtarget = hd->Targets[ii]) ) {
2909 vdev->negoFlags |= MPT_TARGET_NO_NEGO_QAS; 2927 vtarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
2910 mptscsih_writeSDP1(hd, 0, ii, vdev->negoFlags); 2928 mptscsih_writeSDP1(hd, 0, ii, vtarget->negoFlags);
2911 } 2929 }
2912 } 2930 }
2913 } 2931 }
@@ -2926,105 +2944,17 @@ mptscsih_setTargetNegoParms(MPT_SCSI_HOST *hd, VirtDevice *target, char byte56)
2926} 2944}
2927 2945
2928/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 2946/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
2929/* If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return.
2930 * Else set the NEED_DV flag after Read Capacity Issued (disks)
2931 * or Mode Sense (cdroms).
2932 *
2933 * Tapes, initTarget will set this flag on completion of Inquiry command.
2934 * Called only if DV_NOT_DONE flag is set
2935 */
2936static void
2937mptscsih_set_dvflags(MPT_SCSI_HOST *hd, SCSIIORequest_t *pReq)
2938{
2939 MPT_ADAPTER *ioc = hd->ioc;
2940 u8 cmd;
2941 SpiCfgData *pSpi;
2942
2943 ddvtprintk((MYIOC_s_NOTE_FMT
2944 " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n",
2945 hd->ioc->name, pReq->TargetID, pReq->LUN[1], hd->negoNvram, pReq->CDB[0]));
2946
2947 if ((pReq->LUN[1] != 0) || (hd->negoNvram != 0))
2948 return;
2949
2950 cmd = pReq->CDB[0];
2951
2952 if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) {
2953 pSpi = &ioc->spi_data;
2954 if ((ioc->raid_data.isRaid & (1 << pReq->TargetID)) && ioc->raid_data.pIocPg3) {
2955 /* Set NEED_DV for all hidden disks
2956 */
2957 Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
2958 int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
2959
2960 while (numPDisk) {
2961 pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
2962 ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
2963 pPDisk++;
2964 numPDisk--;
2965 }
2966 }
2967 pSpi->dvStatus[pReq->TargetID] |= MPT_SCSICFG_NEED_DV;
2968 ddvtprintk(("NEED_DV set for visible disk id %d\n", pReq->TargetID));
2969 }
2970}
2971
2972/* mptscsih_raid_set_dv_flags()
2973 *
2974 * New or replaced disk. Set DV flag and schedule DV.
2975 */
2976static void
2977mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id)
2978{
2979 MPT_ADAPTER *ioc = hd->ioc;
2980 SpiCfgData *pSpi = &ioc->spi_data;
2981 Ioc3PhysDisk_t *pPDisk;
2982 int numPDisk;
2983
2984 if (hd->negoNvram != 0)
2985 return;
2986
2987 ddvtprintk(("DV requested for phys disk id %d\n", id));
2988 if (ioc->raid_data.pIocPg3) {
2989 pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
2990 numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
2991 while (numPDisk) {
2992 if (id == pPDisk->PhysDiskNum) {
2993 pSpi->dvStatus[pPDisk->PhysDiskID] =
2994 (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE);
2995 pSpi->forceDv = MPT_SCSICFG_NEED_DV;
2996 ddvtprintk(("NEED_DV set for phys disk id %d\n",
2997 pPDisk->PhysDiskID));
2998 break;
2999 }
3000 pPDisk++;
3001 numPDisk--;
3002 }
3003
3004 if (numPDisk == 0) {
3005 /* The physical disk that needs DV was not found
3006 * in the stored IOC Page 3. The driver must reload
3007 * this page. DV routine will set the NEED_DV flag for
3008 * all phys disks that have DV_NOT_DONE set.
3009 */
3010 pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
3011 ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id));
3012 }
3013 }
3014}
3015
3016/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3017/* 2947/*
3018 * If no Target, bus reset on 1st I/O. Set the flag to 2948 * If no Target, bus reset on 1st I/O. Set the flag to
3019 * prevent any future negotiations to this device. 2949 * prevent any future negotiations to this device.
3020 */ 2950 */
3021static void 2951static void
3022mptscsih_no_negotiate(MPT_SCSI_HOST *hd, int target_id) 2952mptscsih_no_negotiate(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc)
3023{ 2953{
2954 VirtDevice *vdev;
3024 2955
3025 if ((hd->Targets) && (hd->Targets[target_id] == NULL)) 2956 if ((vdev = sc->device->hostdata) != NULL)
3026 hd->ioc->spi_data.dvStatus[target_id] |= MPT_SCSICFG_BLK_NEGO; 2957 hd->ioc->spi_data.dvStatus[vdev->target_id] |= MPT_SCSICFG_BLK_NEGO;
3027
3028 return; 2958 return;
3029} 2959}
3030 2960
@@ -3100,7 +3030,7 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3100 MPT_ADAPTER *ioc = hd->ioc; 3030 MPT_ADAPTER *ioc = hd->ioc;
3101 Config_t *pReq; 3031 Config_t *pReq;
3102 SCSIDevicePage1_t *pData; 3032 SCSIDevicePage1_t *pData;
3103 VirtDevice *pTarget=NULL; 3033 VirtTarget *vtarget=NULL;
3104 MPT_FRAME_HDR *mf; 3034 MPT_FRAME_HDR *mf;
3105 dma_addr_t dataDma; 3035 dma_addr_t dataDma;
3106 u16 req_idx; 3036 u16 req_idx;
@@ -3180,11 +3110,11 @@ mptscsih_writeSDP1(MPT_SCSI_HOST *hd, int portnum, int target_id, int flags)
3180 /* If id is not a raid volume, get the updated 3110 /* If id is not a raid volume, get the updated
3181 * transmission settings from the target structure. 3111 * transmission settings from the target structure.
3182 */ 3112 */
3183 if (hd->Targets && (pTarget = hd->Targets[id]) && !pTarget->raidVolume) { 3113 if (hd->Targets && (vtarget = hd->Targets[id]) && !vtarget->raidVolume) {
3184 width = pTarget->maxWidth; 3114 width = vtarget->maxWidth;
3185 factor = pTarget->minSyncFactor; 3115 factor = vtarget->minSyncFactor;
3186 offset = pTarget->maxOffset; 3116 offset = vtarget->maxOffset;
3187 negoFlags = pTarget->negoFlags; 3117 negoFlags = vtarget->negoFlags;
3188 } 3118 }
3189 3119
3190#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION 3120#ifdef MPTSCSIH_ENABLE_DOMAIN_VALIDATION
@@ -3904,149 +3834,139 @@ mptscsih_do_cmd(MPT_SCSI_HOST *hd, INTERNAL_CMD *io)
3904 3834
3905/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 3835/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
3906/** 3836/**
3907 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks. 3837 * mptscsih_negotiate_to_asyn_narrow - Restore devices to default state
3908 * @hd: Pointer to MPT_SCSI_HOST structure 3838 * @hd: Pointer to a SCSI HOST structure
3909 * @portnum: IOC port number 3839 * @vtarget: per device private data
3910 * 3840 *
3911 * Uses the ISR, but with special processing. 3841 * Uses the ISR, but with special processing.
3912 * MUST be single-threaded. 3842 * MUST be single-threaded.
3913 * 3843 *
3914 * Return: 0 on completion
3915 */ 3844 */
3916static int 3845static void
3917mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, int portnum) 3846mptscsih_negotiate_to_asyn_narrow(MPT_SCSI_HOST *hd, VirtTarget *vtarget)
3918{ 3847{
3919 MPT_ADAPTER *ioc= hd->ioc; 3848 MPT_ADAPTER *ioc= hd->ioc;
3920 VirtDevice *pTarget; 3849 SCSIDevicePage1_t *pcfg1Data;
3921 SCSIDevicePage1_t *pcfg1Data = NULL;
3922 INTERNAL_CMD iocmd;
3923 CONFIGPARMS cfg; 3850 CONFIGPARMS cfg;
3924 dma_addr_t cfg1_dma_addr = -1; 3851 dma_addr_t cfg1_dma_addr;
3925 ConfigPageHeader_t header1; 3852 ConfigPageHeader_t header;
3926 int bus = 0; 3853 int id;
3927 int id = 0; 3854 int requested, configuration, data,i;
3928 int lun;
3929 int indexed_lun, lun_index;
3930 int hostId = ioc->pfacts[portnum].PortSCSIID;
3931 int max_id;
3932 int requested, configuration, data;
3933 int doConfig = 0;
3934 u8 flags, factor; 3855 u8 flags, factor;
3935 3856
3936 max_id = ioc->sh->max_id - 1; 3857 if (ioc->bus_type != SPI)
3937 3858 return;
3938 /* Following parameters will not change
3939 * in this routine.
3940 */
3941 iocmd.cmd = SYNCHRONIZE_CACHE;
3942 iocmd.flags = 0;
3943 iocmd.physDiskNum = -1;
3944 iocmd.data = NULL;
3945 iocmd.data_dma = -1;
3946 iocmd.size = 0;
3947 iocmd.rsvd = iocmd.rsvd2 = 0;
3948
3949 /* No SCSI hosts
3950 */
3951 if (hd->Targets == NULL)
3952 return 0;
3953
3954 /* Skip the host
3955 */
3956 if (id == hostId)
3957 id++;
3958
3959 /* Write SDP1 for all SCSI devices
3960 * Alloc memory and set up config buffer
3961 */
3962 if (ioc->bus_type == SCSI) {
3963 if (ioc->spi_data.sdp1length > 0) {
3964 pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev,
3965 ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);
3966
3967 if (pcfg1Data != NULL) {
3968 doConfig = 1;
3969 header1.PageVersion = ioc->spi_data.sdp1version;
3970 header1.PageLength = ioc->spi_data.sdp1length;
3971 header1.PageNumber = 1;
3972 header1.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
3973 cfg.cfghdr.hdr = &header1;
3974 cfg.physAddr = cfg1_dma_addr;
3975 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
3976 cfg.dir = 1;
3977 cfg.timeout = 0;
3978 }
3979 }
3980 }
3981 3859
3982 /* loop through all devices on this port 3860 if (!ioc->spi_data.sdp1length)
3983 */ 3861 return;
3984 while (bus < MPT_MAX_BUS) {
3985 iocmd.bus = bus;
3986 iocmd.id = id;
3987 pTarget = hd->Targets[(int)id];
3988 3862
3989 if (doConfig) { 3863 pcfg1Data = (SCSIDevicePage1_t *)pci_alloc_consistent(ioc->pcidev,
3864 ioc->spi_data.sdp1length * 4, &cfg1_dma_addr);
3990 3865
3991 /* Set the negotiation flags */ 3866 if (pcfg1Data == NULL)
3992 if (pTarget && (pTarget = hd->Targets[id]) && !pTarget->raidVolume) { 3867 return;
3993 flags = pTarget->negoFlags;
3994 } else {
3995 flags = hd->ioc->spi_data.noQas;
3996 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
3997 data = hd->ioc->spi_data.nvram[id];
3998 3868
3999 if (data & MPT_NVRAM_WIDE_DISABLE) 3869 header.PageVersion = ioc->spi_data.sdp1version;
4000 flags |= MPT_TARGET_NO_NEGO_WIDE; 3870 header.PageLength = ioc->spi_data.sdp1length;
3871 header.PageNumber = 1;
3872 header.PageType = MPI_CONFIG_PAGETYPE_SCSI_DEVICE;
3873 cfg.cfghdr.hdr = &header;
3874 cfg.physAddr = cfg1_dma_addr;
3875 cfg.action = MPI_CONFIG_ACTION_PAGE_WRITE_CURRENT;
3876 cfg.dir = 1;
3877 cfg.timeout = 0;
4001 3878
4002 factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT; 3879 if (vtarget->raidVolume && ioc->raid_data.pIocPg3) {
4003 if ((factor == 0) || (factor == MPT_ASYNC)) 3880 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
4004 flags |= MPT_TARGET_NO_NEGO_SYNC; 3881 id = ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID;
4005 } 3882 flags = hd->ioc->spi_data.noQas;
3883 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
3884 data = hd->ioc->spi_data.nvram[id];
3885 if (data & MPT_NVRAM_WIDE_DISABLE)
3886 flags |= MPT_TARGET_NO_NEGO_WIDE;
3887 factor = (data & MPT_NVRAM_SYNC_MASK) >> MPT_NVRAM_SYNC_SHIFT;
3888 if ((factor == 0) || (factor == MPT_ASYNC))
3889 flags |= MPT_TARGET_NO_NEGO_SYNC;
4006 } 3890 }
4007
4008 /* Force to async, narrow */
4009 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested, 3891 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,
4010 &configuration, flags); 3892 &configuration, flags);
4011 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC " 3893 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC "
4012 "offset=0 negoFlags=%x request=%x config=%x\n", 3894 "offset=0 negoFlags=%x request=%x config=%x\n",
4013 id, flags, requested, configuration)); 3895 id, flags, requested, configuration));
4014 pcfg1Data->RequestedParameters = cpu_to_le32(requested); 3896 pcfg1Data->RequestedParameters = cpu_to_le32(requested);
4015 pcfg1Data->Reserved = 0; 3897 pcfg1Data->Reserved = 0;
4016 pcfg1Data->Configuration = cpu_to_le32(configuration); 3898 pcfg1Data->Configuration = cpu_to_le32(configuration);
4017 cfg.pageAddr = (bus<<8) | id; 3899 cfg.pageAddr = (vtarget->bus_id<<8) | id;
4018 mpt_config(hd->ioc, &cfg); 3900 mpt_config(hd->ioc, &cfg);
4019 } 3901 }
3902 } else {
3903 flags = vtarget->negoFlags;
3904 mptscsih_setDevicePage1Flags(0, MPT_ASYNC, 0, &requested,
3905 &configuration, flags);
3906 dnegoprintk(("syncronize cache: id=%d width=0 factor=MPT_ASYNC "
3907 "offset=0 negoFlags=%x request=%x config=%x\n",
3908 vtarget->target_id, flags, requested, configuration));
3909 pcfg1Data->RequestedParameters = cpu_to_le32(requested);
3910 pcfg1Data->Reserved = 0;
3911 pcfg1Data->Configuration = cpu_to_le32(configuration);
3912 cfg.pageAddr = (vtarget->bus_id<<8) | vtarget->target_id;
3913 mpt_config(hd->ioc, &cfg);
3914 }
4020 3915
4021 /* If target Ptr NULL or if this target is NOT a disk, skip. 3916 if (pcfg1Data)
4022 */ 3917 pci_free_consistent(ioc->pcidev, header.PageLength * 4, pcfg1Data, cfg1_dma_addr);
4023 if ((pTarget) && (pTarget->inq_data[0] == TYPE_DISK)){ 3918}
4024 for (lun=0; lun <= MPT_LAST_LUN; lun++) {
4025 /* If LUN present, issue the command
4026 */
4027 lun_index = (lun >> 5); /* 32 luns per lun_index */
4028 indexed_lun = (lun % 32);
4029 if (pTarget->luns[lun_index] & (1<<indexed_lun)) {
4030 iocmd.lun = lun;
4031 (void) mptscsih_do_cmd(hd, &iocmd);
4032 }
4033 }
4034 }
4035 3919
4036 /* get next relevant device */ 3920/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
4037 id++; 3921/**
3922 * mptscsih_synchronize_cache - Send SYNCHRONIZE_CACHE to all disks.
3923 * @hd: Pointer to a SCSI HOST structure
3924 * @vtarget: per device private data
3925 * @lun: lun
3926 *
3927 * Uses the ISR, but with special processing.
3928 * MUST be single-threaded.
3929 *
3930 */
3931static void
3932mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
3933{
3934 INTERNAL_CMD iocmd;
4038 3935
4039 if (id == hostId) 3936 /* Following parameters will not change
4040 id++; 3937 * in this routine.
3938 */
3939 iocmd.cmd = SYNCHRONIZE_CACHE;
3940 iocmd.flags = 0;
3941 iocmd.physDiskNum = -1;
3942 iocmd.data = NULL;
3943 iocmd.data_dma = -1;
3944 iocmd.size = 0;
3945 iocmd.rsvd = iocmd.rsvd2 = 0;
3946 iocmd.bus = vdevice->bus_id;
3947 iocmd.id = vdevice->target_id;
3948 iocmd.lun = (u8)vdevice->lun;
4041 3949
4042 if (id > max_id) { 3950 if ((vdevice->vtarget->type & TYPE_DISK) &&
4043 id = 0; 3951 (vdevice->configured_lun))
4044 bus++; 3952 mptscsih_do_cmd(hd, &iocmd);
4045 } 3953}
4046 }
4047 3954
4048 if (pcfg1Data) { 3955/* Search IOC page 3 to determine if this is hidden physical disk
4049 pci_free_consistent(ioc->pcidev, header1.PageLength * 4, pcfg1Data, cfg1_dma_addr); 3956 */
3957/* Search IOC page 3 to determine if this is hidden physical disk
3958 */
3959static int
3960mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
3961{
3962 int i;
3963
3964 if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3)
3965 return 0;
3966
3967 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
3968 if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID)
3969 return 1;
4050 } 3970 }
4051 3971
4052 return 0; 3972 return 0;
@@ -4101,8 +4021,8 @@ mptscsih_domainValidation(void *arg)
4101 4021
4102 msleep(250); 4022 msleep(250);
4103 4023
4104 /* DV only to SCSI adapters */ 4024 /* DV only to SPI adapters */
4105 if (ioc->bus_type != SCSI) 4025 if (ioc->bus_type != SPI)
4106 continue; 4026 continue;
4107 4027
4108 /* Make sure everything looks ok */ 4028 /* Make sure everything looks ok */
@@ -4205,32 +4125,12 @@ mptscsih_domainValidation(void *arg)
4205 return; 4125 return;
4206} 4126}
4207 4127
4208/* Search IOC page 3 to determine if this is hidden physical disk
4209 */
4210/* Search IOC page 3 to determine if this is hidden physical disk
4211 */
4212static int
4213mptscsih_is_phys_disk(MPT_ADAPTER *ioc, int id)
4214{
4215 int i;
4216
4217 if (!ioc->raid_data.isRaid || !ioc->raid_data.pIocPg3)
4218 return 0;
4219
4220 for (i = 0; i < ioc->raid_data.pIocPg3->NumPhysDisks; i++) {
4221 if (id == ioc->raid_data.pIocPg3->PhysDisk[i].PhysDiskID)
4222 return 1;
4223 }
4224
4225 return 0;
4226}
4227
4228/* Write SDP1 if no QAS has been enabled 4128/* Write SDP1 if no QAS has been enabled
4229 */ 4129 */
4230static void 4130static void
4231mptscsih_qas_check(MPT_SCSI_HOST *hd, int id) 4131mptscsih_qas_check(MPT_SCSI_HOST *hd, int id)
4232{ 4132{
4233 VirtDevice *pTarget; 4133 VirtTarget *vtarget;
4234 int ii; 4134 int ii;
4235 4135
4236 if (hd->Targets == NULL) 4136 if (hd->Targets == NULL)
@@ -4243,11 +4143,11 @@ mptscsih_qas_check(MPT_SCSI_HOST *hd, int id)
4243 if ((hd->ioc->spi_data.dvStatus[ii] & MPT_SCSICFG_DV_NOT_DONE) != 0) 4143 if ((hd->ioc->spi_data.dvStatus[ii] & MPT_SCSICFG_DV_NOT_DONE) != 0)
4244 continue; 4144 continue;
4245 4145
4246 pTarget = hd->Targets[ii]; 4146 vtarget = hd->Targets[ii];
4247 4147
4248 if ((pTarget != NULL) && (!pTarget->raidVolume)) { 4148 if ((vtarget != NULL) && (!vtarget->raidVolume)) {
4249 if ((pTarget->negoFlags & hd->ioc->spi_data.noQas) == 0) { 4149 if ((vtarget->negoFlags & hd->ioc->spi_data.noQas) == 0) {
4250 pTarget->negoFlags |= hd->ioc->spi_data.noQas; 4150 vtarget->negoFlags |= hd->ioc->spi_data.noQas;
4251 dnegoprintk(("writeSDP1: id=%d flags=0\n", id)); 4151 dnegoprintk(("writeSDP1: id=%d flags=0\n", id));
4252 mptscsih_writeSDP1(hd, 0, ii, 0); 4152 mptscsih_writeSDP1(hd, 0, ii, 0);
4253 } 4153 }
@@ -4287,7 +4187,7 @@ static int
4287mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id) 4187mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4288{ 4188{
4289 MPT_ADAPTER *ioc = hd->ioc; 4189 MPT_ADAPTER *ioc = hd->ioc;
4290 VirtDevice *pTarget; 4190 VirtTarget *vtarget;
4291 SCSIDevicePage1_t *pcfg1Data; 4191 SCSIDevicePage1_t *pcfg1Data;
4292 SCSIDevicePage0_t *pcfg0Data; 4192 SCSIDevicePage0_t *pcfg0Data;
4293 u8 *pbuf1; 4193 u8 *pbuf1;
@@ -4358,12 +4258,12 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4358 iocmd.physDiskNum = -1; 4258 iocmd.physDiskNum = -1;
4359 iocmd.rsvd = iocmd.rsvd2 = 0; 4259 iocmd.rsvd = iocmd.rsvd2 = 0;
4360 4260
4361 pTarget = hd->Targets[id]; 4261 vtarget = hd->Targets[id];
4362 4262
4363 /* Use tagged commands if possible. 4263 /* Use tagged commands if possible.
4364 */ 4264 */
4365 if (pTarget) { 4265 if (vtarget) {
4366 if (pTarget->tflags & MPT_TARGET_FLAGS_Q_YES) 4266 if (vtarget->tflags & MPT_TARGET_FLAGS_Q_YES)
4367 iocmd.flags |= MPT_ICFLAG_TAGGED_CMD; 4267 iocmd.flags |= MPT_ICFLAG_TAGGED_CMD;
4368 else { 4268 else {
4369 if (hd->ioc->facts.FWVersion.Word < 0x01000600) 4269 if (hd->ioc->facts.FWVersion.Word < 0x01000600)
@@ -4579,7 +4479,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4579 /* Reset the size for disks 4479 /* Reset the size for disks
4580 */ 4480 */
4581 inq0 = (*pbuf1) & 0x1F; 4481 inq0 = (*pbuf1) & 0x1F;
4582 if ((inq0 == 0) && pTarget && !pTarget->raidVolume) { 4482 if ((inq0 == 0) && vtarget && !vtarget->raidVolume) {
4583 sz = 0x40; 4483 sz = 0x40;
4584 iocmd.size = sz; 4484 iocmd.size = sz;
4585 } 4485 }
@@ -4589,8 +4489,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4589 */ 4489 */
4590 if (inq0 == TYPE_PROCESSOR) { 4490 if (inq0 == TYPE_PROCESSOR) {
4591 mptscsih_initTarget(hd, 4491 mptscsih_initTarget(hd,
4592 bus, 4492 vtarget,
4593 id,
4594 lun, 4493 lun,
4595 pbuf1, 4494 pbuf1,
4596 sz); 4495 sz);
@@ -4604,22 +4503,22 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4604 goto target_done; 4503 goto target_done;
4605 4504
4606 if (sz == 0x40) { 4505 if (sz == 0x40) {
4607 if ((pTarget->maxWidth == 1) && (pTarget->maxOffset) && (nfactor < 0x0A) 4506 if ((vtarget->maxWidth == 1) && (vtarget->maxOffset) && (nfactor < 0x0A)
4608 && (pTarget->minSyncFactor > 0x09)) { 4507 && (vtarget->minSyncFactor > 0x09)) {
4609 if ((pbuf1[56] & 0x04) == 0) 4508 if ((pbuf1[56] & 0x04) == 0)
4610 ; 4509 ;
4611 else if ((pbuf1[56] & 0x01) == 1) { 4510 else if ((pbuf1[56] & 0x01) == 1) {
4612 pTarget->minSyncFactor = 4511 vtarget->minSyncFactor =
4613 nfactor > MPT_ULTRA320 ? nfactor : MPT_ULTRA320; 4512 nfactor > MPT_ULTRA320 ? nfactor : MPT_ULTRA320;
4614 } else { 4513 } else {
4615 pTarget->minSyncFactor = 4514 vtarget->minSyncFactor =
4616 nfactor > MPT_ULTRA160 ? nfactor : MPT_ULTRA160; 4515 nfactor > MPT_ULTRA160 ? nfactor : MPT_ULTRA160;
4617 } 4516 }
4618 4517
4619 dv.max.factor = pTarget->minSyncFactor; 4518 dv.max.factor = vtarget->minSyncFactor;
4620 4519
4621 if ((pbuf1[56] & 0x02) == 0) { 4520 if ((pbuf1[56] & 0x02) == 0) {
4622 pTarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS; 4521 vtarget->negoFlags |= MPT_TARGET_NO_NEGO_QAS;
4623 hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS; 4522 hd->ioc->spi_data.noQas = MPT_TARGET_NO_NEGO_QAS;
4624 ddvprintk((MYIOC_s_NOTE_FMT 4523 ddvprintk((MYIOC_s_NOTE_FMT
4625 "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n", 4524 "DV: Start Basic noQas on id=%d due to pbuf1[56]=%x\n",
@@ -4702,8 +4601,7 @@ mptscsih_doDv(MPT_SCSI_HOST *hd, int bus_number, int id)
4702 "DV:Inquiry compared id=%d, calling initTarget\n", ioc->name, id)); 4601 "DV:Inquiry compared id=%d, calling initTarget\n", ioc->name, id));
4703 hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE; 4602 hd->ioc->spi_data.dvStatus[id] &= ~MPT_SCSICFG_DV_NOT_DONE;
4704 mptscsih_initTarget(hd, 4603 mptscsih_initTarget(hd,
4705 bus, 4604 vtarget,
4706 id,
4707 lun, 4605 lun,
4708 pbuf1, 4606 pbuf1,
4709 sz); 4607 sz);
@@ -5204,7 +5102,7 @@ target_done:
5204static void 5102static void
5205mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage) 5103mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5206{ 5104{
5207 VirtDevice *pTarget; 5105 VirtTarget *vtarget;
5208 SCSIDevicePage0_t *pPage0; 5106 SCSIDevicePage0_t *pPage0;
5209 SCSIDevicePage1_t *pPage1; 5107 SCSIDevicePage1_t *pPage1;
5210 int val = 0, data, configuration; 5108 int val = 0, data, configuration;
@@ -5224,11 +5122,11 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5224 * already throttled back. 5122 * already throttled back.
5225 */ 5123 */
5226 negoFlags = hd->ioc->spi_data.noQas; 5124 negoFlags = hd->ioc->spi_data.noQas;
5227 if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume) { 5125 if ((hd->Targets)&&((vtarget = hd->Targets[(int)id]) != NULL) && !vtarget->raidVolume) {
5228 width = pTarget->maxWidth; 5126 width = vtarget->maxWidth;
5229 offset = pTarget->maxOffset; 5127 offset = vtarget->maxOffset;
5230 factor = pTarget->minSyncFactor; 5128 factor = vtarget->minSyncFactor;
5231 negoFlags |= pTarget->negoFlags; 5129 negoFlags |= vtarget->negoFlags;
5232 } else { 5130 } else {
5233 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) { 5131 if (hd->ioc->spi_data.nvram && (hd->ioc->spi_data.nvram[id] != MPT_HOST_NVRAM_INVALID)) {
5234 data = hd->ioc->spi_data.nvram[id]; 5132 data = hd->ioc->spi_data.nvram[id];
@@ -5430,11 +5328,11 @@ mptscsih_dv_parms(MPT_SCSI_HOST *hd, DVPARAMETERS *dv,void *pPage)
5430 * or overwrite nvram (phys disks only). 5328 * or overwrite nvram (phys disks only).
5431 */ 5329 */
5432 5330
5433 if ((hd->Targets)&&((pTarget = hd->Targets[(int)id]) != NULL) && !pTarget->raidVolume ) { 5331 if ((hd->Targets)&&((vtarget = hd->Targets[(int)id]) != NULL) && !vtarget->raidVolume ) {
5434 pTarget->maxWidth = dv->now.width; 5332 vtarget->maxWidth = dv->now.width;
5435 pTarget->maxOffset = dv->now.offset; 5333 vtarget->maxOffset = dv->now.offset;
5436 pTarget->minSyncFactor = dv->now.factor; 5334 vtarget->minSyncFactor = dv->now.factor;
5437 pTarget->negoFlags = dv->now.flags; 5335 vtarget->negoFlags = dv->now.flags;
5438 } else { 5336 } else {
5439 /* Preserv all flags, use 5337 /* Preserv all flags, use
5440 * read-modify-write algorithm 5338 * read-modify-write algorithm
@@ -5588,6 +5486,94 @@ mptscsih_fillbuf(char *buffer, int size, int index, int width)
5588 break; 5486 break;
5589 } 5487 }
5590} 5488}
5489
5490/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5491/* If DV disabled (negoNvram set to USE_NVARM) or if not LUN 0, return.
5492 * Else set the NEED_DV flag after Read Capacity Issued (disks)
5493 * or Mode Sense (cdroms).
5494 *
5495 * Tapes, initTarget will set this flag on completion of Inquiry command.
5496 * Called only if DV_NOT_DONE flag is set
5497 */
5498static void
5499mptscsih_set_dvflags(MPT_SCSI_HOST *hd, struct scsi_cmnd *sc)
5500{
5501 MPT_ADAPTER *ioc = hd->ioc;
5502 u8 cmd;
5503 SpiCfgData *pSpi;
5504
5505 ddvtprintk((MYIOC_s_NOTE_FMT
5506 " set_dvflags: id=%d lun=%d negoNvram=%x cmd=%x\n",
5507 hd->ioc->name, sc->device->id, sc->device->lun , hd->negoNvram, sc->cmnd[0]));
5508
5509 if ((sc->device->lun != 0) || (hd->negoNvram != 0))
5510 return;
5511
5512 cmd = sc->cmnd[0];
5513
5514 if ((cmd == READ_CAPACITY) || (cmd == MODE_SENSE)) {
5515 pSpi = &ioc->spi_data;
5516 if ((ioc->raid_data.isRaid & (1 << sc->device->id)) && ioc->raid_data.pIocPg3) {
5517 /* Set NEED_DV for all hidden disks
5518 */
5519 Ioc3PhysDisk_t *pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
5520 int numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
5521
5522 while (numPDisk) {
5523 pSpi->dvStatus[pPDisk->PhysDiskID] |= MPT_SCSICFG_NEED_DV;
5524 ddvtprintk(("NEED_DV set for phys disk id %d\n", pPDisk->PhysDiskID));
5525 pPDisk++;
5526 numPDisk--;
5527 }
5528 }
5529 pSpi->dvStatus[sc->device->id] |= MPT_SCSICFG_NEED_DV;
5530 ddvtprintk(("NEED_DV set for visible disk id %d\n", sc->device->id));
5531 }
5532}
5533
5534/* mptscsih_raid_set_dv_flags()
5535 *
5536 * New or replaced disk. Set DV flag and schedule DV.
5537 */
5538static void
5539mptscsih_set_dvflags_raid(MPT_SCSI_HOST *hd, int id)
5540{
5541 MPT_ADAPTER *ioc = hd->ioc;
5542 SpiCfgData *pSpi = &ioc->spi_data;
5543 Ioc3PhysDisk_t *pPDisk;
5544 int numPDisk;
5545
5546 if (hd->negoNvram != 0)
5547 return;
5548
5549 ddvtprintk(("DV requested for phys disk id %d\n", id));
5550 if (ioc->raid_data.pIocPg3) {
5551 pPDisk = ioc->raid_data.pIocPg3->PhysDisk;
5552 numPDisk = ioc->raid_data.pIocPg3->NumPhysDisks;
5553 while (numPDisk) {
5554 if (id == pPDisk->PhysDiskNum) {
5555 pSpi->dvStatus[pPDisk->PhysDiskID] =
5556 (MPT_SCSICFG_NEED_DV | MPT_SCSICFG_DV_NOT_DONE);
5557 pSpi->forceDv = MPT_SCSICFG_NEED_DV;
5558 ddvtprintk(("NEED_DV set for phys disk id %d\n",
5559 pPDisk->PhysDiskID));
5560 break;
5561 }
5562 pPDisk++;
5563 numPDisk--;
5564 }
5565
5566 if (numPDisk == 0) {
5567 /* The physical disk that needs DV was not found
5568 * in the stored IOC Page 3. The driver must reload
5569 * this page. DV routine will set the NEED_DV flag for
5570 * all phys disks that have DV_NOT_DONE set.
5571 */
5572 pSpi->forceDv = MPT_SCSICFG_NEED_DV | MPT_SCSICFG_RELOAD_IOC_PG3;
5573 ddvtprintk(("phys disk %d not found. Setting reload IOC Pg3 Flag\n",id));
5574 }
5575 }
5576}
5591#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */ 5577#endif /* ~MPTSCSIH_ENABLE_DOMAIN_VALIDATION */
5592 5578
5593EXPORT_SYMBOL(mptscsih_remove); 5579EXPORT_SYMBOL(mptscsih_remove);
@@ -5599,7 +5585,9 @@ EXPORT_SYMBOL(mptscsih_resume);
5599EXPORT_SYMBOL(mptscsih_proc_info); 5585EXPORT_SYMBOL(mptscsih_proc_info);
5600EXPORT_SYMBOL(mptscsih_info); 5586EXPORT_SYMBOL(mptscsih_info);
5601EXPORT_SYMBOL(mptscsih_qcmd); 5587EXPORT_SYMBOL(mptscsih_qcmd);
5588EXPORT_SYMBOL(mptscsih_target_alloc);
5602EXPORT_SYMBOL(mptscsih_slave_alloc); 5589EXPORT_SYMBOL(mptscsih_slave_alloc);
5590EXPORT_SYMBOL(mptscsih_target_destroy);
5603EXPORT_SYMBOL(mptscsih_slave_destroy); 5591EXPORT_SYMBOL(mptscsih_slave_destroy);
5604EXPORT_SYMBOL(mptscsih_slave_configure); 5592EXPORT_SYMBOL(mptscsih_slave_configure);
5605EXPORT_SYMBOL(mptscsih_abort); 5593EXPORT_SYMBOL(mptscsih_abort);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 971fda4b8b57..d3cba12f4bd9 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -91,7 +91,9 @@ extern int mptscsih_resume(struct pci_dev *pdev);
91extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func); 91extern int mptscsih_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t offset, int length, int func);
92extern const char * mptscsih_info(struct Scsi_Host *SChost); 92extern const char * mptscsih_info(struct Scsi_Host *SChost);
93extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *)); 93extern int mptscsih_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cmnd *));
94extern int mptscsih_target_alloc(struct scsi_target *starget);
94extern int mptscsih_slave_alloc(struct scsi_device *device); 95extern int mptscsih_slave_alloc(struct scsi_device *device);
96extern void mptscsih_target_destroy(struct scsi_target *starget);
95extern void mptscsih_slave_destroy(struct scsi_device *device); 97extern void mptscsih_slave_destroy(struct scsi_device *device);
96extern int mptscsih_slave_configure(struct scsi_device *device); 98extern int mptscsih_slave_configure(struct scsi_device *device);
97extern int mptscsih_abort(struct scsi_cmnd * SCpnt); 99extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 5c0e307d1d5d..ce332a6085e5 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -103,13 +103,16 @@ static int mptspiTaskCtx = -1;
103static int mptspiInternalCtx = -1; /* Used only for internal commands */ 103static int mptspiInternalCtx = -1; /* Used only for internal commands */
104 104
105static struct scsi_host_template mptspi_driver_template = { 105static struct scsi_host_template mptspi_driver_template = {
106 .module = THIS_MODULE,
106 .proc_name = "mptspi", 107 .proc_name = "mptspi",
107 .proc_info = mptscsih_proc_info, 108 .proc_info = mptscsih_proc_info,
108 .name = "MPT SPI Host", 109 .name = "MPT SPI Host",
109 .info = mptscsih_info, 110 .info = mptscsih_info,
110 .queuecommand = mptscsih_qcmd, 111 .queuecommand = mptscsih_qcmd,
112 .target_alloc = mptscsih_target_alloc,
111 .slave_alloc = mptscsih_slave_alloc, 113 .slave_alloc = mptscsih_slave_alloc,
112 .slave_configure = mptscsih_slave_configure, 114 .slave_configure = mptscsih_slave_configure,
115 .target_destroy = mptscsih_target_destroy,
113 .slave_destroy = mptscsih_slave_destroy, 116 .slave_destroy = mptscsih_slave_destroy,
114 .change_queue_depth = mptscsih_change_queue_depth, 117 .change_queue_depth = mptscsih_change_queue_depth,
115 .eh_abort_handler = mptscsih_abort, 118 .eh_abort_handler = mptscsih_abort,
@@ -177,13 +180,15 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
177 printk(MYIOC_s_WARN_FMT 180 printk(MYIOC_s_WARN_FMT
178 "Skipping because it's not operational!\n", 181 "Skipping because it's not operational!\n",
179 ioc->name); 182 ioc->name);
180 return -ENODEV; 183 error = -ENODEV;
184 goto out_mptspi_probe;
181 } 185 }
182 186
183 if (!ioc->active) { 187 if (!ioc->active) {
184 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n", 188 printk(MYIOC_s_WARN_FMT "Skipping because it's disabled!\n",
185 ioc->name); 189 ioc->name);
186 return -ENODEV; 190 error = -ENODEV;
191 goto out_mptspi_probe;
187 } 192 }
188 193
189 /* Sanity check - ensure at least 1 port is INITIATOR capable 194 /* Sanity check - ensure at least 1 port is INITIATOR capable
@@ -208,7 +213,8 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
208 printk(MYIOC_s_WARN_FMT 213 printk(MYIOC_s_WARN_FMT
209 "Unable to register controller with SCSI subsystem\n", 214 "Unable to register controller with SCSI subsystem\n",
210 ioc->name); 215 ioc->name);
211 return -1; 216 error = -1;
217 goto out_mptspi_probe;
212 } 218 }
213 219
214 spin_lock_irqsave(&ioc->FreeQlock, flags); 220 spin_lock_irqsave(&ioc->FreeQlock, flags);
@@ -286,7 +292,7 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
286 mem = kmalloc(sz, GFP_ATOMIC); 292 mem = kmalloc(sz, GFP_ATOMIC);
287 if (mem == NULL) { 293 if (mem == NULL) {
288 error = -ENOMEM; 294 error = -ENOMEM;
289 goto mptspi_probe_failed; 295 goto out_mptspi_probe;
290 } 296 }
291 297
292 memset(mem, 0, sz); 298 memset(mem, 0, sz);
@@ -304,14 +310,14 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
304 mem = kmalloc(sz, GFP_ATOMIC); 310 mem = kmalloc(sz, GFP_ATOMIC);
305 if (mem == NULL) { 311 if (mem == NULL) {
306 error = -ENOMEM; 312 error = -ENOMEM;
307 goto mptspi_probe_failed; 313 goto out_mptspi_probe;
308 } 314 }
309 315
310 memset(mem, 0, sz); 316 memset(mem, 0, sz);
311 hd->Targets = (VirtDevice **) mem; 317 hd->Targets = (VirtTarget **) mem;
312 318
313 dprintk((KERN_INFO 319 dprintk((KERN_INFO
314 " Targets @ %p, sz=%d\n", hd->Targets, sz)); 320 " vdev @ %p, sz=%d\n", hd->Targets, sz));
315 321
316 /* Clear the TM flags 322 /* Clear the TM flags
317 */ 323 */
@@ -385,13 +391,13 @@ mptspi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
385 if(error) { 391 if(error) {
386 dprintk((KERN_ERR MYNAM 392 dprintk((KERN_ERR MYNAM
387 "scsi_add_host failed\n")); 393 "scsi_add_host failed\n"));
388 goto mptspi_probe_failed; 394 goto out_mptspi_probe;
389 } 395 }
390 396
391 scsi_scan_host(sh); 397 scsi_scan_host(sh);
392 return 0; 398 return 0;
393 399
394mptspi_probe_failed: 400out_mptspi_probe:
395 401
396 mptscsih_remove(pdev); 402 mptscsih_remove(pdev);
397 return error; 403 return error;
diff --git a/drivers/message/i2o/Kconfig b/drivers/message/i2o/Kconfig
index 43a942a29c2e..fef677103880 100644
--- a/drivers/message/i2o/Kconfig
+++ b/drivers/message/i2o/Kconfig
@@ -24,6 +24,18 @@ config I2O
24 24
25 If unsure, say N. 25 If unsure, say N.
26 26
27config I2O_LCT_NOTIFY_ON_CHANGES
28 bool "Enable LCT notification"
29 depends on I2O
30 default y
31 ---help---
32 Only say N here if you have a I2O controller from SUN. The SUN
33 firmware doesn't support LCT notification on changes. If this option
34 is enabled on such a controller the driver will hang up in a endless
35 loop. On all other controllers say Y.
36
37 If unsure, say Y.
38
27config I2O_EXT_ADAPTEC 39config I2O_EXT_ADAPTEC
28 bool "Enable Adaptec extensions" 40 bool "Enable Adaptec extensions"
29 depends on I2O 41 depends on I2O
diff --git a/drivers/message/i2o/bus-osm.c b/drivers/message/i2o/bus-osm.c
index 151b228e1cb3..ac06f10c54ec 100644
--- a/drivers/message/i2o/bus-osm.c
+++ b/drivers/message/i2o/bus-osm.c
@@ -17,7 +17,7 @@
17#include <linux/i2o.h> 17#include <linux/i2o.h>
18 18
19#define OSM_NAME "bus-osm" 19#define OSM_NAME "bus-osm"
20#define OSM_VERSION "$Rev$" 20#define OSM_VERSION "1.317"
21#define OSM_DESCRIPTION "I2O Bus Adapter OSM" 21#define OSM_DESCRIPTION "I2O Bus Adapter OSM"
22 22
23static struct i2o_driver i2o_bus_driver; 23static struct i2o_driver i2o_bus_driver;
@@ -39,18 +39,18 @@ static struct i2o_class_id i2o_bus_class_id[] = {
39 */ 39 */
40static int i2o_bus_scan(struct i2o_device *dev) 40static int i2o_bus_scan(struct i2o_device *dev)
41{ 41{
42 struct i2o_message __iomem *msg; 42 struct i2o_message *msg;
43 u32 m;
44 43
45 m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); 44 msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
46 if (m == I2O_QUEUE_EMPTY) 45 if (IS_ERR(msg))
47 return -ETIMEDOUT; 46 return -ETIMEDOUT;
48 47
49 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 48 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
50 writel(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.tid, 49 msg->u.head[1] =
51 &msg->u.head[1]); 50 cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.
51 tid);
52 52
53 return i2o_msg_post_wait(dev->iop, m, 60); 53 return i2o_msg_post_wait(dev->iop, msg, 60);
54}; 54};
55 55
56/** 56/**
@@ -59,8 +59,9 @@ static int i2o_bus_scan(struct i2o_device *dev)
59 * 59 *
60 * Returns count. 60 * Returns count.
61 */ 61 */
62static ssize_t i2o_bus_store_scan(struct device *d, struct device_attribute *attr, const char *buf, 62static ssize_t i2o_bus_store_scan(struct device *d,
63 size_t count) 63 struct device_attribute *attr,
64 const char *buf, size_t count)
64{ 65{
65 struct i2o_device *i2o_dev = to_i2o_device(d); 66 struct i2o_device *i2o_dev = to_i2o_device(d);
66 int rc; 67 int rc;
diff --git a/drivers/message/i2o/config-osm.c b/drivers/message/i2o/config-osm.c
index 10432f665201..3bba7aa82e58 100644
--- a/drivers/message/i2o/config-osm.c
+++ b/drivers/message/i2o/config-osm.c
@@ -22,7 +22,7 @@
22#include <asm/uaccess.h> 22#include <asm/uaccess.h>
23 23
24#define OSM_NAME "config-osm" 24#define OSM_NAME "config-osm"
25#define OSM_VERSION "1.248" 25#define OSM_VERSION "1.323"
26#define OSM_DESCRIPTION "I2O Configuration OSM" 26#define OSM_DESCRIPTION "I2O Configuration OSM"
27 27
28/* access mode user rw */ 28/* access mode user rw */
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index 9eefedb16211..90628562851e 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -14,8 +14,6 @@
14 */ 14 */
15 15
16/* Exec-OSM */ 16/* Exec-OSM */
17extern struct bus_type i2o_bus_type;
18
19extern struct i2o_driver i2o_exec_driver; 17extern struct i2o_driver i2o_exec_driver;
20extern int i2o_exec_lct_get(struct i2o_controller *); 18extern int i2o_exec_lct_get(struct i2o_controller *);
21 19
@@ -23,6 +21,8 @@ extern int __init i2o_exec_init(void);
23extern void __exit i2o_exec_exit(void); 21extern void __exit i2o_exec_exit(void);
24 22
25/* driver */ 23/* driver */
24extern struct bus_type i2o_bus_type;
25
26extern int i2o_driver_dispatch(struct i2o_controller *, u32); 26extern int i2o_driver_dispatch(struct i2o_controller *, u32);
27 27
28extern int __init i2o_driver_init(void); 28extern int __init i2o_driver_init(void);
@@ -33,19 +33,27 @@ extern int __init i2o_pci_init(void);
33extern void __exit i2o_pci_exit(void); 33extern void __exit i2o_pci_exit(void);
34 34
35/* device */ 35/* device */
36extern struct device_attribute i2o_device_attrs[];
37
36extern void i2o_device_remove(struct i2o_device *); 38extern void i2o_device_remove(struct i2o_device *);
37extern int i2o_device_parse_lct(struct i2o_controller *); 39extern int i2o_device_parse_lct(struct i2o_controller *);
38 40
39/* IOP */ 41/* IOP */
40extern struct i2o_controller *i2o_iop_alloc(void); 42extern struct i2o_controller *i2o_iop_alloc(void);
41extern void i2o_iop_free(struct i2o_controller *); 43
44/**
45 * i2o_iop_free - Free the i2o_controller struct
46 * @c: I2O controller to free
47 */
48static inline void i2o_iop_free(struct i2o_controller *c)
49{
50 i2o_pool_free(&c->in_msg);
51 kfree(c);
52}
42 53
43extern int i2o_iop_add(struct i2o_controller *); 54extern int i2o_iop_add(struct i2o_controller *);
44extern void i2o_iop_remove(struct i2o_controller *); 55extern void i2o_iop_remove(struct i2o_controller *);
45 56
46/* config */
47extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int);
48
49/* control registers relative to c->base */ 57/* control registers relative to c->base */
50#define I2O_IRQ_STATUS 0x30 58#define I2O_IRQ_STATUS 0x30
51#define I2O_IRQ_MASK 0x34 59#define I2O_IRQ_MASK 0x34
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 8eb50cdb8ae1..ee183053fa23 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -35,18 +35,18 @@
35static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd, 35static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
36 u32 type) 36 u32 type)
37{ 37{
38 struct i2o_message __iomem *msg; 38 struct i2o_message *msg;
39 u32 m;
40 39
41 m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); 40 msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
42 if (m == I2O_QUEUE_EMPTY) 41 if (IS_ERR(msg))
43 return -ETIMEDOUT; 42 return PTR_ERR(msg);
44 43
45 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 44 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
46 writel(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid, &msg->u.head[1]); 45 msg->u.head[1] =
47 writel(type, &msg->body[0]); 46 cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid);
47 msg->body[0] = cpu_to_le32(type);
48 48
49 return i2o_msg_post_wait(dev->iop, m, 60); 49 return i2o_msg_post_wait(dev->iop, msg, 60);
50} 50}
51 51
52/** 52/**
@@ -123,7 +123,6 @@ int i2o_device_claim_release(struct i2o_device *dev)
123 return rc; 123 return rc;
124} 124}
125 125
126
127/** 126/**
128 * i2o_device_release - release the memory for a I2O device 127 * i2o_device_release - release the memory for a I2O device
129 * @dev: I2O device which should be released 128 * @dev: I2O device which should be released
@@ -140,10 +139,10 @@ static void i2o_device_release(struct device *dev)
140 kfree(i2o_dev); 139 kfree(i2o_dev);
141} 140}
142 141
143
144/** 142/**
145 * i2o_device_class_show_class_id - Displays class id of I2O device 143 * i2o_device_show_class_id - Displays class id of I2O device
146 * @cd: class device of which the class id should be displayed 144 * @dev: device of which the class id should be displayed
145 * @attr: pointer to device attribute
147 * @buf: buffer into which the class id should be printed 146 * @buf: buffer into which the class id should be printed
148 * 147 *
149 * Returns the number of bytes which are printed into the buffer. 148 * Returns the number of bytes which are printed into the buffer.
@@ -159,15 +158,15 @@ static ssize_t i2o_device_show_class_id(struct device *dev,
159} 158}
160 159
161/** 160/**
162 * i2o_device_class_show_tid - Displays TID of I2O device 161 * i2o_device_show_tid - Displays TID of I2O device
163 * @cd: class device of which the TID should be displayed 162 * @dev: device of which the TID should be displayed
164 * @buf: buffer into which the class id should be printed 163 * @attr: pointer to device attribute
164 * @buf: buffer into which the TID should be printed
165 * 165 *
166 * Returns the number of bytes which are printed into the buffer. 166 * Returns the number of bytes which are printed into the buffer.
167 */ 167 */
168static ssize_t i2o_device_show_tid(struct device *dev, 168static ssize_t i2o_device_show_tid(struct device *dev,
169 struct device_attribute *attr, 169 struct device_attribute *attr, char *buf)
170 char *buf)
171{ 170{
172 struct i2o_device *i2o_dev = to_i2o_device(dev); 171 struct i2o_device *i2o_dev = to_i2o_device(dev);
173 172
@@ -175,6 +174,7 @@ static ssize_t i2o_device_show_tid(struct device *dev,
175 return strlen(buf) + 1; 174 return strlen(buf) + 1;
176} 175}
177 176
177/* I2O device attributes */
178struct device_attribute i2o_device_attrs[] = { 178struct device_attribute i2o_device_attrs[] = {
179 __ATTR(class_id, S_IRUGO, i2o_device_show_class_id, NULL), 179 __ATTR(class_id, S_IRUGO, i2o_device_show_class_id, NULL),
180 __ATTR(tid, S_IRUGO, i2o_device_show_tid, NULL), 180 __ATTR(tid, S_IRUGO, i2o_device_show_tid, NULL),
@@ -193,12 +193,10 @@ static struct i2o_device *i2o_device_alloc(void)
193{ 193{
194 struct i2o_device *dev; 194 struct i2o_device *dev;
195 195
196 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 196 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
197 if (!dev) 197 if (!dev)
198 return ERR_PTR(-ENOMEM); 198 return ERR_PTR(-ENOMEM);
199 199
200 memset(dev, 0, sizeof(*dev));
201
202 INIT_LIST_HEAD(&dev->list); 200 INIT_LIST_HEAD(&dev->list);
203 init_MUTEX(&dev->lock); 201 init_MUTEX(&dev->lock);
204 202
@@ -209,66 +207,6 @@ static struct i2o_device *i2o_device_alloc(void)
209} 207}
210 208
211/** 209/**
212 * i2o_setup_sysfs_links - Adds attributes to the I2O device
213 * @cd: I2O class device which is added to the I2O device class
214 *
215 * This function get called when a I2O device is added to the class. It
216 * creates the attributes for each device and creates user/parent symlink
217 * if necessary.
218 *
219 * Returns 0 on success or negative error code on failure.
220 */
221static void i2o_setup_sysfs_links(struct i2o_device *i2o_dev)
222{
223 struct i2o_controller *c = i2o_dev->iop;
224 struct i2o_device *tmp;
225
226 /* create user entries for this device */
227 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
228 if (tmp && tmp != i2o_dev)
229 sysfs_create_link(&i2o_dev->device.kobj,
230 &tmp->device.kobj, "user");
231
232 /* create user entries refering to this device */
233 list_for_each_entry(tmp, &c->devices, list)
234 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid &&
235 tmp != i2o_dev)
236 sysfs_create_link(&tmp->device.kobj,
237 &i2o_dev->device.kobj, "user");
238
239 /* create parent entries for this device */
240 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
241 if (tmp && tmp != i2o_dev)
242 sysfs_create_link(&i2o_dev->device.kobj,
243 &tmp->device.kobj, "parent");
244
245 /* create parent entries refering to this device */
246 list_for_each_entry(tmp, &c->devices, list)
247 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid &&
248 tmp != i2o_dev)
249 sysfs_create_link(&tmp->device.kobj,
250 &i2o_dev->device.kobj, "parent");
251}
252
253static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
254{
255 struct i2o_controller *c = i2o_dev->iop;
256 struct i2o_device *tmp;
257
258 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
259 sysfs_remove_link(&i2o_dev->device.kobj, "user");
260
261 list_for_each_entry(tmp, &c->devices, list) {
262 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
263 sysfs_remove_link(&tmp->device.kobj, "parent");
264 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
265 sysfs_remove_link(&tmp->device.kobj, "user");
266 }
267}
268
269
270
271/**
272 * i2o_device_add - allocate a new I2O device and add it to the IOP 210 * i2o_device_add - allocate a new I2O device and add it to the IOP
273 * @iop: I2O controller where the device is on 211 * @iop: I2O controller where the device is on
274 * @entry: LCT entry of the I2O device 212 * @entry: LCT entry of the I2O device
@@ -282,33 +220,57 @@ static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
282static struct i2o_device *i2o_device_add(struct i2o_controller *c, 220static struct i2o_device *i2o_device_add(struct i2o_controller *c,
283 i2o_lct_entry * entry) 221 i2o_lct_entry * entry)
284{ 222{
285 struct i2o_device *dev; 223 struct i2o_device *i2o_dev, *tmp;
286 224
287 dev = i2o_device_alloc(); 225 i2o_dev = i2o_device_alloc();
288 if (IS_ERR(dev)) { 226 if (IS_ERR(i2o_dev)) {
289 printk(KERN_ERR "i2o: unable to allocate i2o device\n"); 227 printk(KERN_ERR "i2o: unable to allocate i2o device\n");
290 return dev; 228 return i2o_dev;
291 } 229 }
292 230
293 dev->lct_data = *entry; 231 i2o_dev->lct_data = *entry;
294 dev->iop = c;
295 232
296 snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, 233 snprintf(i2o_dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit,
297 dev->lct_data.tid); 234 i2o_dev->lct_data.tid);
298 235
299 dev->device.parent = &c->device; 236 i2o_dev->iop = c;
237 i2o_dev->device.parent = &c->device;
300 238
301 device_register(&dev->device); 239 device_register(&i2o_dev->device);
302 240
303 list_add_tail(&dev->list, &c->devices); 241 list_add_tail(&i2o_dev->list, &c->devices);
304 242
305 i2o_setup_sysfs_links(dev); 243 /* create user entries for this device */
244 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
245 if (tmp && (tmp != i2o_dev))
246 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
247 "user");
306 248
307 i2o_driver_notify_device_add_all(dev); 249 /* create user entries refering to this device */
250 list_for_each_entry(tmp, &c->devices, list)
251 if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
252 && (tmp != i2o_dev))
253 sysfs_create_link(&tmp->device.kobj,
254 &i2o_dev->device.kobj, "user");
308 255
309 pr_debug("i2o: device %s added\n", dev->device.bus_id); 256 /* create parent entries for this device */
257 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
258 if (tmp && (tmp != i2o_dev))
259 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
260 "parent");
310 261
311 return dev; 262 /* create parent entries refering to this device */
263 list_for_each_entry(tmp, &c->devices, list)
264 if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
265 && (tmp != i2o_dev))
266 sysfs_create_link(&tmp->device.kobj,
267 &i2o_dev->device.kobj, "parent");
268
269 i2o_driver_notify_device_add_all(i2o_dev);
270
271 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
272
273 return i2o_dev;
312} 274}
313 275
314/** 276/**
@@ -321,9 +283,22 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
321 */ 283 */
322void i2o_device_remove(struct i2o_device *i2o_dev) 284void i2o_device_remove(struct i2o_device *i2o_dev)
323{ 285{
286 struct i2o_device *tmp;
287 struct i2o_controller *c = i2o_dev->iop;
288
324 i2o_driver_notify_device_remove_all(i2o_dev); 289 i2o_driver_notify_device_remove_all(i2o_dev);
325 i2o_remove_sysfs_links(i2o_dev); 290
291 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
292 sysfs_remove_link(&i2o_dev->device.kobj, "user");
293
294 list_for_each_entry(tmp, &c->devices, list) {
295 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
296 sysfs_remove_link(&tmp->device.kobj, "parent");
297 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
298 sysfs_remove_link(&tmp->device.kobj, "user");
299 }
326 list_del(&i2o_dev->list); 300 list_del(&i2o_dev->list);
301
327 device_unregister(&i2o_dev->device); 302 device_unregister(&i2o_dev->device);
328} 303}
329 304
@@ -341,56 +316,83 @@ int i2o_device_parse_lct(struct i2o_controller *c)
341{ 316{
342 struct i2o_device *dev, *tmp; 317 struct i2o_device *dev, *tmp;
343 i2o_lct *lct; 318 i2o_lct *lct;
344 int i; 319 u32 *dlct = c->dlct.virt;
345 int max; 320 int max = 0, i = 0;
321 u16 table_size;
322 u32 buf;
346 323
347 down(&c->lct_lock); 324 down(&c->lct_lock);
348 325
349 kfree(c->lct); 326 kfree(c->lct);
350 327
351 lct = c->dlct.virt; 328 buf = le32_to_cpu(*dlct++);
329 table_size = buf & 0xffff;
352 330
353 c->lct = kmalloc(lct->table_size * 4, GFP_KERNEL); 331 lct = c->lct = kmalloc(table_size * 4, GFP_KERNEL);
354 if (!c->lct) { 332 if (!lct) {
355 up(&c->lct_lock); 333 up(&c->lct_lock);
356 return -ENOMEM; 334 return -ENOMEM;
357 } 335 }
358 336
359 if (lct->table_size * 4 > c->dlct.len) { 337 lct->lct_ver = buf >> 28;
360 memcpy(c->lct, c->dlct.virt, c->dlct.len); 338 lct->boot_tid = buf >> 16 & 0xfff;
361 up(&c->lct_lock); 339 lct->table_size = table_size;
362 return -EAGAIN; 340 lct->change_ind = le32_to_cpu(*dlct++);
363 } 341 lct->iop_flags = le32_to_cpu(*dlct++);
364 342
365 memcpy(c->lct, c->dlct.virt, lct->table_size * 4); 343 table_size -= 3;
366
367 lct = c->lct;
368
369 max = (lct->table_size - 3) / 9;
370 344
371 pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max, 345 pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max,
372 lct->table_size); 346 lct->table_size);
373 347
374 /* remove devices, which are not in the LCT anymore */ 348 while (table_size > 0) {
375 list_for_each_entry_safe(dev, tmp, &c->devices, list) { 349 i2o_lct_entry *entry = &lct->lct_entry[max];
376 int found = 0; 350 int found = 0;
377 351
378 for (i = 0; i < max; i++) { 352 buf = le32_to_cpu(*dlct++);
379 if (lct->lct_entry[i].tid == dev->lct_data.tid) { 353 entry->entry_size = buf & 0xffff;
354 entry->tid = buf >> 16 & 0xfff;
355
356 entry->change_ind = le32_to_cpu(*dlct++);
357 entry->device_flags = le32_to_cpu(*dlct++);
358
359 buf = le32_to_cpu(*dlct++);
360 entry->class_id = buf & 0xfff;
361 entry->version = buf >> 12 & 0xf;
362 entry->vendor_id = buf >> 16;
363
364 entry->sub_class = le32_to_cpu(*dlct++);
365
366 buf = le32_to_cpu(*dlct++);
367 entry->user_tid = buf & 0xfff;
368 entry->parent_tid = buf >> 12 & 0xfff;
369 entry->bios_info = buf >> 24;
370
371 memcpy(&entry->identity_tag, dlct, 8);
372 dlct += 2;
373
374 entry->event_capabilities = le32_to_cpu(*dlct++);
375
376 /* add new devices, which are new in the LCT */
377 list_for_each_entry_safe(dev, tmp, &c->devices, list) {
378 if (entry->tid == dev->lct_data.tid) {
380 found = 1; 379 found = 1;
381 break; 380 break;
382 } 381 }
383 } 382 }
384 383
385 if (!found) 384 if (!found)
386 i2o_device_remove(dev); 385 i2o_device_add(c, entry);
386
387 table_size -= 9;
388 max++;
387 } 389 }
388 390
389 /* add new devices, which are new in the LCT */ 391 /* remove devices, which are not in the LCT anymore */
390 for (i = 0; i < max; i++) { 392 list_for_each_entry_safe(dev, tmp, &c->devices, list) {
391 int found = 0; 393 int found = 0;
392 394
393 list_for_each_entry_safe(dev, tmp, &c->devices, list) { 395 for (i = 0; i < max; i++) {
394 if (lct->lct_entry[i].tid == dev->lct_data.tid) { 396 if (lct->lct_entry[i].tid == dev->lct_data.tid) {
395 found = 1; 397 found = 1;
396 break; 398 break;
@@ -398,14 +400,14 @@ int i2o_device_parse_lct(struct i2o_controller *c)
398 } 400 }
399 401
400 if (!found) 402 if (!found)
401 i2o_device_add(c, &lct->lct_entry[i]); 403 i2o_device_remove(dev);
402 } 404 }
405
403 up(&c->lct_lock); 406 up(&c->lct_lock);
404 407
405 return 0; 408 return 0;
406} 409}
407 410
408
409/* 411/*
410 * Run time support routines 412 * Run time support routines
411 */ 413 */
@@ -419,13 +421,9 @@ int i2o_device_parse_lct(struct i2o_controller *c)
419 * ResultCount, ErrorInfoSize, BlockStatus and BlockSize. 421 * ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
420 */ 422 */
421int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist, 423int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
422 int oplen, void *reslist, int reslen) 424 int oplen, void *reslist, int reslen)
423{ 425{
424 struct i2o_message __iomem *msg; 426 struct i2o_message *msg;
425 u32 m;
426 u32 *res32 = (u32 *) reslist;
427 u32 *restmp = (u32 *) reslist;
428 int len = 0;
429 int i = 0; 427 int i = 0;
430 int rc; 428 int rc;
431 struct i2o_dma res; 429 struct i2o_dma res;
@@ -437,26 +435,27 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
437 if (i2o_dma_alloc(dev, &res, reslen, GFP_KERNEL)) 435 if (i2o_dma_alloc(dev, &res, reslen, GFP_KERNEL))
438 return -ENOMEM; 436 return -ENOMEM;
439 437
440 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 438 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
441 if (m == I2O_QUEUE_EMPTY) { 439 if (IS_ERR(msg)) {
442 i2o_dma_free(dev, &res); 440 i2o_dma_free(dev, &res);
443 return -ETIMEDOUT; 441 return PTR_ERR(msg);
444 } 442 }
445 443
446 i = 0; 444 i = 0;
447 writel(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid, 445 msg->u.head[1] =
448 &msg->u.head[1]); 446 cpu_to_le32(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid);
449 writel(0, &msg->body[i++]); 447 msg->body[i++] = cpu_to_le32(0x00000000);
450 writel(0x4C000000 | oplen, &msg->body[i++]); /* OperationList */ 448 msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */
451 memcpy_toio(&msg->body[i], oplist, oplen); 449 memcpy(&msg->body[i], oplist, oplen);
452 i += (oplen / 4 + (oplen % 4 ? 1 : 0)); 450 i += (oplen / 4 + (oplen % 4 ? 1 : 0));
453 writel(0xD0000000 | res.len, &msg->body[i++]); /* ResultList */ 451 msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */
454 writel(res.phys, &msg->body[i++]); 452 msg->body[i++] = cpu_to_le32(res.phys);
455 453
456 writel(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) | 454 msg->u.head[0] =
457 SGL_OFFSET_5, &msg->u.head[0]); 455 cpu_to_le32(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) |
456 SGL_OFFSET_5);
458 457
459 rc = i2o_msg_post_wait_mem(c, m, 10, &res); 458 rc = i2o_msg_post_wait_mem(c, msg, 10, &res);
460 459
461 /* This only looks like a memory leak - don't "fix" it. */ 460 /* This only looks like a memory leak - don't "fix" it. */
462 if (rc == -ETIMEDOUT) 461 if (rc == -ETIMEDOUT)
@@ -465,36 +464,7 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
465 memcpy(reslist, res.virt, res.len); 464 memcpy(reslist, res.virt, res.len);
466 i2o_dma_free(dev, &res); 465 i2o_dma_free(dev, &res);
467 466
468 /* Query failed */ 467 return rc;
469 if (rc)
470 return rc;
471 /*
472 * Calculate number of bytes of Result LIST
473 * We need to loop through each Result BLOCK and grab the length
474 */
475 restmp = res32 + 1;
476 len = 1;
477 for (i = 0; i < (res32[0] & 0X0000FFFF); i++) {
478 if (restmp[0] & 0x00FF0000) { /* BlockStatus != SUCCESS */
479 printk(KERN_WARNING
480 "%s - Error:\n ErrorInfoSize = 0x%02x, "
481 "BlockStatus = 0x%02x, BlockSize = 0x%04x\n",
482 (cmd ==
483 I2O_CMD_UTIL_PARAMS_SET) ? "PARAMS_SET" :
484 "PARAMS_GET", res32[1] >> 24,
485 (res32[1] >> 16) & 0xFF, res32[1] & 0xFFFF);
486
487 /*
488 * If this is the only request,than we return an error
489 */
490 if ((res32[0] & 0x0000FFFF) == 1) {
491 return -((res32[1] >> 16) & 0xFF); /* -BlockStatus */
492 }
493 }
494 len += restmp[0] & 0x0000FFFF; /* Length of res BLOCK */
495 restmp += restmp[0] & 0x0000FFFF; /* Skip to next BLOCK */
496 }
497 return (len << 2); /* bytes used by result list */
498} 468}
499 469
500/* 470/*
@@ -503,28 +473,25 @@ int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
503int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field, 473int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
504 void *buf, int buflen) 474 void *buf, int buflen)
505{ 475{
506 u16 opblk[] = { 1, 0, I2O_PARAMS_FIELD_GET, group, 1, field }; 476 u32 opblk[] = { cpu_to_le32(0x00000001),
477 cpu_to_le32((u16) group << 16 | I2O_PARAMS_FIELD_GET),
478 cpu_to_le32((s16) field << 16 | 0x00000001)
479 };
507 u8 *resblk; /* 8 bytes for header */ 480 u8 *resblk; /* 8 bytes for header */
508 int size; 481 int rc;
509
510 if (field == -1) /* whole group */
511 opblk[4] = -1;
512 482
513 resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC); 483 resblk = kmalloc(buflen + 8, GFP_KERNEL | GFP_ATOMIC);
514 if (!resblk) 484 if (!resblk)
515 return -ENOMEM; 485 return -ENOMEM;
516 486
517 size = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk, 487 rc = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk,
518 sizeof(opblk), resblk, buflen + 8); 488 sizeof(opblk), resblk, buflen + 8);
519 489
520 memcpy(buf, resblk + 8, buflen); /* cut off header */ 490 memcpy(buf, resblk + 8, buflen); /* cut off header */
521 491
522 kfree(resblk); 492 kfree(resblk);
523 493
524 if (size > buflen) 494 return rc;
525 return buflen;
526
527 return size;
528} 495}
529 496
530/* 497/*
@@ -534,12 +501,12 @@ int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
534 * else return specific fields 501 * else return specific fields
535 * ibuf contains fieldindexes 502 * ibuf contains fieldindexes
536 * 503 *
537 * if oper == I2O_PARAMS_LIST_GET, get from specific rows 504 * if oper == I2O_PARAMS_LIST_GET, get from specific rows
538 * if fieldcount == -1 return all fields 505 * if fieldcount == -1 return all fields
539 * ibuf contains rowcount, keyvalues 506 * ibuf contains rowcount, keyvalues
540 * else return specific fields 507 * else return specific fields
541 * fieldcount is # of fieldindexes 508 * fieldcount is # of fieldindexes
542 * ibuf contains fieldindexes, rowcount, keyvalues 509 * ibuf contains fieldindexes, rowcount, keyvalues
543 * 510 *
544 * You could also use directly function i2o_issue_params(). 511 * You could also use directly function i2o_issue_params().
545 */ 512 */
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 0fb9c4e2ad4c..64130227574f 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -61,12 +61,10 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv)
61}; 61};
62 62
63/* I2O bus type */ 63/* I2O bus type */
64extern struct device_attribute i2o_device_attrs[];
65
66struct bus_type i2o_bus_type = { 64struct bus_type i2o_bus_type = {
67 .name = "i2o", 65 .name = "i2o",
68 .match = i2o_bus_match, 66 .match = i2o_bus_match,
69 .dev_attrs = i2o_device_attrs, 67 .dev_attrs = i2o_device_attrs
70}; 68};
71 69
72/** 70/**
@@ -219,14 +217,14 @@ int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
219 /* cut of header from message size (in 32-bit words) */ 217 /* cut of header from message size (in 32-bit words) */
220 size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5; 218 size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5;
221 219
222 evt = kmalloc(size * 4 + sizeof(*evt), GFP_ATOMIC | __GFP_ZERO); 220 evt = kzalloc(size * 4 + sizeof(*evt), GFP_ATOMIC);
223 if (!evt) 221 if (!evt)
224 return -ENOMEM; 222 return -ENOMEM;
225 223
226 evt->size = size; 224 evt->size = size;
227 evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt); 225 evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt);
228 evt->event_indicator = le32_to_cpu(msg->body[0]); 226 evt->event_indicator = le32_to_cpu(msg->body[0]);
229 memcpy(&evt->tcntxt, &msg->u.s.tcntxt, size * 4); 227 memcpy(&evt->data, &msg->body[1], size * 4);
230 228
231 list_for_each_entry_safe(dev, tmp, &c->devices, list) 229 list_for_each_entry_safe(dev, tmp, &c->devices, list)
232 if (dev->lct_data.tid == tid) { 230 if (dev->lct_data.tid == tid) {
@@ -349,12 +347,10 @@ int __init i2o_driver_init(void)
349 osm_info("max drivers = %d\n", i2o_max_drivers); 347 osm_info("max drivers = %d\n", i2o_max_drivers);
350 348
351 i2o_drivers = 349 i2o_drivers =
352 kmalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL); 350 kzalloc(i2o_max_drivers * sizeof(*i2o_drivers), GFP_KERNEL);
353 if (!i2o_drivers) 351 if (!i2o_drivers)
354 return -ENOMEM; 352 return -ENOMEM;
355 353
356 memset(i2o_drivers, 0, i2o_max_drivers * sizeof(*i2o_drivers));
357
358 rc = bus_register(&i2o_bus_type); 354 rc = bus_register(&i2o_bus_type);
359 355
360 if (rc < 0) 356 if (rc < 0)
diff --git a/drivers/message/i2o/exec-osm.c b/drivers/message/i2o/exec-osm.c
index 9c339a2505b0..9bb9859f6dfe 100644
--- a/drivers/message/i2o/exec-osm.c
+++ b/drivers/message/i2o/exec-osm.c
@@ -33,7 +33,7 @@
33#include <linux/workqueue.h> 33#include <linux/workqueue.h>
34#include <linux/string.h> 34#include <linux/string.h>
35#include <linux/slab.h> 35#include <linux/slab.h>
36#include <linux/sched.h> /* wait_event_interruptible_timeout() needs this */ 36#include <linux/sched.h> /* wait_event_interruptible_timeout() needs this */
37#include <asm/param.h> /* HZ */ 37#include <asm/param.h> /* HZ */
38#include "core.h" 38#include "core.h"
39 39
@@ -75,11 +75,9 @@ static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
75{ 75{
76 struct i2o_exec_wait *wait; 76 struct i2o_exec_wait *wait;
77 77
78 wait = kmalloc(sizeof(*wait), GFP_KERNEL); 78 wait = kzalloc(sizeof(*wait), GFP_KERNEL);
79 if (!wait) 79 if (!wait)
80 return ERR_PTR(-ENOMEM); 80 return NULL;
81
82 memset(wait, 0, sizeof(*wait));
83 81
84 INIT_LIST_HEAD(&wait->list); 82 INIT_LIST_HEAD(&wait->list);
85 83
@@ -114,13 +112,12 @@ static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
114 * Returns 0 on success, negative error code on timeout or positive error 112 * Returns 0 on success, negative error code on timeout or positive error
115 * code from reply. 113 * code from reply.
116 */ 114 */
117int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long 115int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
118 timeout, struct i2o_dma *dma) 116 unsigned long timeout, struct i2o_dma *dma)
119{ 117{
120 DECLARE_WAIT_QUEUE_HEAD(wq); 118 DECLARE_WAIT_QUEUE_HEAD(wq);
121 struct i2o_exec_wait *wait; 119 struct i2o_exec_wait *wait;
122 static u32 tcntxt = 0x80000000; 120 static u32 tcntxt = 0x80000000;
123 struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m);
124 int rc = 0; 121 int rc = 0;
125 122
126 wait = i2o_exec_wait_alloc(); 123 wait = i2o_exec_wait_alloc();
@@ -138,15 +135,15 @@ int i2o_msg_post_wait_mem(struct i2o_controller *c, u32 m, unsigned long
138 * We will only use transaction contexts >= 0x80000000 for POST WAIT, 135 * We will only use transaction contexts >= 0x80000000 for POST WAIT,
139 * so we could find a POST WAIT reply easier in the reply handler. 136 * so we could find a POST WAIT reply easier in the reply handler.
140 */ 137 */
141 writel(i2o_exec_driver.context, &msg->u.s.icntxt); 138 msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
142 wait->tcntxt = tcntxt++; 139 wait->tcntxt = tcntxt++;
143 writel(wait->tcntxt, &msg->u.s.tcntxt); 140 msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt);
144 141
145 /* 142 /*
146 * Post the message to the controller. At some point later it will 143 * Post the message to the controller. At some point later it will
147 * return. If we time out before it returns then complete will be zero. 144 * return. If we time out before it returns then complete will be zero.
148 */ 145 */
149 i2o_msg_post(c, m); 146 i2o_msg_post(c, msg);
150 147
151 if (!wait->complete) { 148 if (!wait->complete) {
152 wait->wq = &wq; 149 wait->wq = &wq;
@@ -266,13 +263,14 @@ static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
266 * 263 *
267 * Returns number of bytes printed into buffer. 264 * Returns number of bytes printed into buffer.
268 */ 265 */
269static ssize_t i2o_exec_show_vendor_id(struct device *d, struct device_attribute *attr, char *buf) 266static ssize_t i2o_exec_show_vendor_id(struct device *d,
267 struct device_attribute *attr, char *buf)
270{ 268{
271 struct i2o_device *dev = to_i2o_device(d); 269 struct i2o_device *dev = to_i2o_device(d);
272 u16 id; 270 u16 id;
273 271
274 if (i2o_parm_field_get(dev, 0x0000, 0, &id, 2)) { 272 if (!i2o_parm_field_get(dev, 0x0000, 0, &id, 2)) {
275 sprintf(buf, "0x%04x", id); 273 sprintf(buf, "0x%04x", le16_to_cpu(id));
276 return strlen(buf) + 1; 274 return strlen(buf) + 1;
277 } 275 }
278 276
@@ -286,13 +284,15 @@ static ssize_t i2o_exec_show_vendor_id(struct device *d, struct device_attribute
286 * 284 *
287 * Returns number of bytes printed into buffer. 285 * Returns number of bytes printed into buffer.
288 */ 286 */
289static ssize_t i2o_exec_show_product_id(struct device *d, struct device_attribute *attr, char *buf) 287static ssize_t i2o_exec_show_product_id(struct device *d,
288 struct device_attribute *attr,
289 char *buf)
290{ 290{
291 struct i2o_device *dev = to_i2o_device(d); 291 struct i2o_device *dev = to_i2o_device(d);
292 u16 id; 292 u16 id;
293 293
294 if (i2o_parm_field_get(dev, 0x0000, 1, &id, 2)) { 294 if (!i2o_parm_field_get(dev, 0x0000, 1, &id, 2)) {
295 sprintf(buf, "0x%04x", id); 295 sprintf(buf, "0x%04x", le16_to_cpu(id));
296 return strlen(buf) + 1; 296 return strlen(buf) + 1;
297 } 297 }
298 298
@@ -362,7 +362,9 @@ static void i2o_exec_lct_modified(struct i2o_controller *c)
362 if (i2o_device_parse_lct(c) != -EAGAIN) 362 if (i2o_device_parse_lct(c) != -EAGAIN)
363 change_ind = c->lct->change_ind + 1; 363 change_ind = c->lct->change_ind + 1;
364 364
365#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES
365 i2o_exec_lct_notify(c, change_ind); 366 i2o_exec_lct_notify(c, change_ind);
367#endif
366}; 368};
367 369
368/** 370/**
@@ -385,23 +387,22 @@ static int i2o_exec_reply(struct i2o_controller *c, u32 m,
385 u32 context; 387 u32 context;
386 388
387 if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) { 389 if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) {
390 struct i2o_message __iomem *pmsg;
391 u32 pm;
392
388 /* 393 /*
389 * If Fail bit is set we must take the transaction context of 394 * If Fail bit is set we must take the transaction context of
390 * the preserved message to find the right request again. 395 * the preserved message to find the right request again.
391 */ 396 */
392 struct i2o_message __iomem *pmsg;
393 u32 pm;
394 397
395 pm = le32_to_cpu(msg->body[3]); 398 pm = le32_to_cpu(msg->body[3]);
396
397 pmsg = i2o_msg_in_to_virt(c, pm); 399 pmsg = i2o_msg_in_to_virt(c, pm);
400 context = readl(&pmsg->u.s.tcntxt);
398 401
399 i2o_report_status(KERN_INFO, "i2o_core", msg); 402 i2o_report_status(KERN_INFO, "i2o_core", msg);
400 403
401 context = readl(&pmsg->u.s.tcntxt);
402
403 /* Release the preserved msg */ 404 /* Release the preserved msg */
404 i2o_msg_nop(c, pm); 405 i2o_msg_nop_mfa(c, pm);
405 } else 406 } else
406 context = le32_to_cpu(msg->u.s.tcntxt); 407 context = le32_to_cpu(msg->u.s.tcntxt);
407 408
@@ -462,25 +463,26 @@ static void i2o_exec_event(struct i2o_event *evt)
462 */ 463 */
463int i2o_exec_lct_get(struct i2o_controller *c) 464int i2o_exec_lct_get(struct i2o_controller *c)
464{ 465{
465 struct i2o_message __iomem *msg; 466 struct i2o_message *msg;
466 u32 m;
467 int i = 0; 467 int i = 0;
468 int rc = -EAGAIN; 468 int rc = -EAGAIN;
469 469
470 for (i = 1; i <= I2O_LCT_GET_TRIES; i++) { 470 for (i = 1; i <= I2O_LCT_GET_TRIES; i++) {
471 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 471 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
472 if (m == I2O_QUEUE_EMPTY) 472 if (IS_ERR(msg))
473 return -ETIMEDOUT; 473 return PTR_ERR(msg);
474 474
475 writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); 475 msg->u.head[0] =
476 writel(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | ADAPTER_TID, 476 cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
477 &msg->u.head[1]); 477 msg->u.head[1] =
478 writel(0xffffffff, &msg->body[0]); 478 cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
479 writel(0x00000000, &msg->body[1]); 479 ADAPTER_TID);
480 writel(0xd0000000 | c->dlct.len, &msg->body[2]); 480 msg->body[0] = cpu_to_le32(0xffffffff);
481 writel(c->dlct.phys, &msg->body[3]); 481 msg->body[1] = cpu_to_le32(0x00000000);
482 482 msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
483 rc = i2o_msg_post_wait(c, m, I2O_TIMEOUT_LCT_GET); 483 msg->body[3] = cpu_to_le32(c->dlct.phys);
484
485 rc = i2o_msg_post_wait(c, msg, I2O_TIMEOUT_LCT_GET);
484 if (rc < 0) 486 if (rc < 0)
485 break; 487 break;
486 488
@@ -506,29 +508,29 @@ static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
506{ 508{
507 i2o_status_block *sb = c->status_block.virt; 509 i2o_status_block *sb = c->status_block.virt;
508 struct device *dev; 510 struct device *dev;
509 struct i2o_message __iomem *msg; 511 struct i2o_message *msg;
510 u32 m;
511 512
512 dev = &c->pdev->dev; 513 dev = &c->pdev->dev;
513 514
514 if (i2o_dma_realloc(dev, &c->dlct, sb->expected_lct_size, GFP_KERNEL)) 515 if (i2o_dma_realloc
516 (dev, &c->dlct, le32_to_cpu(sb->expected_lct_size), GFP_KERNEL))
515 return -ENOMEM; 517 return -ENOMEM;
516 518
517 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 519 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
518 if (m == I2O_QUEUE_EMPTY) 520 if (IS_ERR(msg))
519 return -ETIMEDOUT; 521 return PTR_ERR(msg);
520 522
521 writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); 523 msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
522 writel(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 | ADAPTER_TID, 524 msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
523 &msg->u.head[1]); 525 ADAPTER_TID);
524 writel(i2o_exec_driver.context, &msg->u.s.icntxt); 526 msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
525 writel(0, &msg->u.s.tcntxt); /* FIXME */ 527 msg->u.s.tcntxt = cpu_to_le32(0x00000000);
526 writel(0xffffffff, &msg->body[0]); 528 msg->body[0] = cpu_to_le32(0xffffffff);
527 writel(change_ind, &msg->body[1]); 529 msg->body[1] = cpu_to_le32(change_ind);
528 writel(0xd0000000 | c->dlct.len, &msg->body[2]); 530 msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
529 writel(c->dlct.phys, &msg->body[3]); 531 msg->body[3] = cpu_to_le32(c->dlct.phys);
530 532
531 i2o_msg_post(c, m); 533 i2o_msg_post(c, msg);
532 534
533 return 0; 535 return 0;
534}; 536};
diff --git a/drivers/message/i2o/i2o_block.c b/drivers/message/i2o/i2o_block.c
index f283b5bafdd3..5b1febed3133 100644
--- a/drivers/message/i2o/i2o_block.c
+++ b/drivers/message/i2o/i2o_block.c
@@ -59,10 +59,12 @@
59#include <linux/blkdev.h> 59#include <linux/blkdev.h>
60#include <linux/hdreg.h> 60#include <linux/hdreg.h>
61 61
62#include <scsi/scsi.h>
63
62#include "i2o_block.h" 64#include "i2o_block.h"
63 65
64#define OSM_NAME "block-osm" 66#define OSM_NAME "block-osm"
65#define OSM_VERSION "1.287" 67#define OSM_VERSION "1.325"
66#define OSM_DESCRIPTION "I2O Block Device OSM" 68#define OSM_DESCRIPTION "I2O Block Device OSM"
67 69
68static struct i2o_driver i2o_block_driver; 70static struct i2o_driver i2o_block_driver;
@@ -130,20 +132,20 @@ static int i2o_block_remove(struct device *dev)
130 */ 132 */
131static int i2o_block_device_flush(struct i2o_device *dev) 133static int i2o_block_device_flush(struct i2o_device *dev)
132{ 134{
133 struct i2o_message __iomem *msg; 135 struct i2o_message *msg;
134 u32 m;
135 136
136 m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); 137 msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
137 if (m == I2O_QUEUE_EMPTY) 138 if (IS_ERR(msg))
138 return -ETIMEDOUT; 139 return PTR_ERR(msg);
139 140
140 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 141 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
141 writel(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev->lct_data.tid, 142 msg->u.head[1] =
142 &msg->u.head[1]); 143 cpu_to_le32(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev->
143 writel(60 << 16, &msg->body[0]); 144 lct_data.tid);
145 msg->body[0] = cpu_to_le32(60 << 16);
144 osm_debug("Flushing...\n"); 146 osm_debug("Flushing...\n");
145 147
146 return i2o_msg_post_wait(dev->iop, m, 60); 148 return i2o_msg_post_wait(dev->iop, msg, 60);
147}; 149};
148 150
149/** 151/**
@@ -181,21 +183,21 @@ static int i2o_block_issue_flush(request_queue_t * queue, struct gendisk *disk,
181 */ 183 */
182static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id) 184static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id)
183{ 185{
184 struct i2o_message __iomem *msg; 186 struct i2o_message *msg;
185 u32 m; 187
186 188 msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
187 m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); 189 if (IS_ERR(msg))
188 if (m == I2O_QUEUE_EMPTY) 190 return PTR_ERR(msg);
189 return -ETIMEDOUT; 191
190 192 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
191 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 193 msg->u.head[1] =
192 writel(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev->lct_data.tid, 194 cpu_to_le32(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev->
193 &msg->u.head[1]); 195 lct_data.tid);
194 writel(-1, &msg->body[0]); 196 msg->body[0] = cpu_to_le32(-1);
195 writel(0, &msg->body[1]); 197 msg->body[1] = cpu_to_le32(0x00000000);
196 osm_debug("Mounting...\n"); 198 osm_debug("Mounting...\n");
197 199
198 return i2o_msg_post_wait(dev->iop, m, 2); 200 return i2o_msg_post_wait(dev->iop, msg, 2);
199}; 201};
200 202
201/** 203/**
@@ -210,20 +212,20 @@ static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id)
210 */ 212 */
211static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id) 213static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id)
212{ 214{
213 struct i2o_message __iomem *msg; 215 struct i2o_message *msg;
214 u32 m;
215 216
216 m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); 217 msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
217 if (m == I2O_QUEUE_EMPTY) 218 if (IS_ERR(msg) == I2O_QUEUE_EMPTY)
218 return -ETIMEDOUT; 219 return PTR_ERR(msg);
219 220
220 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 221 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
221 writel(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, 222 msg->u.head[1] =
222 &msg->u.head[1]); 223 cpu_to_le32(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev->
223 writel(-1, &msg->body[0]); 224 lct_data.tid);
225 msg->body[0] = cpu_to_le32(-1);
224 osm_debug("Locking...\n"); 226 osm_debug("Locking...\n");
225 227
226 return i2o_msg_post_wait(dev->iop, m, 2); 228 return i2o_msg_post_wait(dev->iop, msg, 2);
227}; 229};
228 230
229/** 231/**
@@ -238,20 +240,20 @@ static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id)
238 */ 240 */
239static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id) 241static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
240{ 242{
241 struct i2o_message __iomem *msg; 243 struct i2o_message *msg;
242 u32 m;
243 244
244 m = i2o_msg_get_wait(dev->iop, &msg, I2O_TIMEOUT_MESSAGE_GET); 245 msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
245 if (m == I2O_QUEUE_EMPTY) 246 if (IS_ERR(msg))
246 return -ETIMEDOUT; 247 return PTR_ERR(msg);
247 248
248 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 249 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
249 writel(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev->lct_data.tid, 250 msg->u.head[1] =
250 &msg->u.head[1]); 251 cpu_to_le32(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev->
251 writel(media_id, &msg->body[0]); 252 lct_data.tid);
253 msg->body[0] = cpu_to_le32(media_id);
252 osm_debug("Unlocking...\n"); 254 osm_debug("Unlocking...\n");
253 255
254 return i2o_msg_post_wait(dev->iop, m, 2); 256 return i2o_msg_post_wait(dev->iop, msg, 2);
255}; 257};
256 258
257/** 259/**
@@ -267,21 +269,21 @@ static int i2o_block_device_power(struct i2o_block_device *dev, u8 op)
267{ 269{
268 struct i2o_device *i2o_dev = dev->i2o_dev; 270 struct i2o_device *i2o_dev = dev->i2o_dev;
269 struct i2o_controller *c = i2o_dev->iop; 271 struct i2o_controller *c = i2o_dev->iop;
270 struct i2o_message __iomem *msg; 272 struct i2o_message *msg;
271 u32 m;
272 int rc; 273 int rc;
273 274
274 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 275 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
275 if (m == I2O_QUEUE_EMPTY) 276 if (IS_ERR(msg))
276 return -ETIMEDOUT; 277 return PTR_ERR(msg);
277 278
278 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 279 msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
279 writel(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev->lct_data. 280 msg->u.head[1] =
280 tid, &msg->u.head[1]); 281 cpu_to_le32(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev->
281 writel(op << 24, &msg->body[0]); 282 lct_data.tid);
283 msg->body[0] = cpu_to_le32(op << 24);
282 osm_debug("Power...\n"); 284 osm_debug("Power...\n");
283 285
284 rc = i2o_msg_post_wait(c, m, 60); 286 rc = i2o_msg_post_wait(c, msg, 60);
285 if (!rc) 287 if (!rc)
286 dev->power = op; 288 dev->power = op;
287 289
@@ -331,7 +333,7 @@ static inline void i2o_block_request_free(struct i2o_block_request *ireq)
331 */ 333 */
332static inline int i2o_block_sglist_alloc(struct i2o_controller *c, 334static inline int i2o_block_sglist_alloc(struct i2o_controller *c,
333 struct i2o_block_request *ireq, 335 struct i2o_block_request *ireq,
334 u32 __iomem ** mptr) 336 u32 ** mptr)
335{ 337{
336 int nents; 338 int nents;
337 enum dma_data_direction direction; 339 enum dma_data_direction direction;
@@ -466,7 +468,7 @@ static void i2o_block_end_request(struct request *req, int uptodate,
466 468
467 spin_lock_irqsave(q->queue_lock, flags); 469 spin_lock_irqsave(q->queue_lock, flags);
468 470
469 end_that_request_last(req); 471 end_that_request_last(req, uptodate);
470 472
471 if (likely(dev)) { 473 if (likely(dev)) {
472 dev->open_queue_depth--; 474 dev->open_queue_depth--;
@@ -745,10 +747,9 @@ static int i2o_block_transfer(struct request *req)
745 struct i2o_block_device *dev = req->rq_disk->private_data; 747 struct i2o_block_device *dev = req->rq_disk->private_data;
746 struct i2o_controller *c; 748 struct i2o_controller *c;
747 int tid = dev->i2o_dev->lct_data.tid; 749 int tid = dev->i2o_dev->lct_data.tid;
748 struct i2o_message __iomem *msg; 750 struct i2o_message *msg;
749 u32 __iomem *mptr; 751 u32 *mptr;
750 struct i2o_block_request *ireq = req->special; 752 struct i2o_block_request *ireq = req->special;
751 u32 m;
752 u32 tcntxt; 753 u32 tcntxt;
753 u32 sgl_offset = SGL_OFFSET_8; 754 u32 sgl_offset = SGL_OFFSET_8;
754 u32 ctl_flags = 0x00000000; 755 u32 ctl_flags = 0x00000000;
@@ -763,9 +764,9 @@ static int i2o_block_transfer(struct request *req)
763 764
764 c = dev->i2o_dev->iop; 765 c = dev->i2o_dev->iop;
765 766
766 m = i2o_msg_get(c, &msg); 767 msg = i2o_msg_get(c);
767 if (m == I2O_QUEUE_EMPTY) { 768 if (IS_ERR(msg)) {
768 rc = -EBUSY; 769 rc = PTR_ERR(msg);
769 goto exit; 770 goto exit;
770 } 771 }
771 772
@@ -775,8 +776,8 @@ static int i2o_block_transfer(struct request *req)
775 goto nop_msg; 776 goto nop_msg;
776 } 777 }
777 778
778 writel(i2o_block_driver.context, &msg->u.s.icntxt); 779 msg->u.s.icntxt = cpu_to_le32(i2o_block_driver.context);
779 writel(tcntxt, &msg->u.s.tcntxt); 780 msg->u.s.tcntxt = cpu_to_le32(tcntxt);
780 781
781 mptr = &msg->body[0]; 782 mptr = &msg->body[0];
782 783
@@ -834,11 +835,11 @@ static int i2o_block_transfer(struct request *req)
834 835
835 sgl_offset = SGL_OFFSET_12; 836 sgl_offset = SGL_OFFSET_12;
836 837
837 writel(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid, 838 msg->u.head[1] =
838 &msg->u.head[1]); 839 cpu_to_le32(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid);
839 840
840 writel(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC, mptr++); 841 *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC);
841 writel(tid, mptr++); 842 *mptr++ = cpu_to_le32(tid);
842 843
843 /* 844 /*
844 * ENABLE_DISCONNECT 845 * ENABLE_DISCONNECT
@@ -846,29 +847,31 @@ static int i2o_block_transfer(struct request *req)
846 * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME 847 * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME
847 */ 848 */
848 if (rq_data_dir(req) == READ) { 849 if (rq_data_dir(req) == READ) {
849 cmd[0] = 0x28; 850 cmd[0] = READ_10;
850 scsi_flags = 0x60a0000a; 851 scsi_flags = 0x60a0000a;
851 } else { 852 } else {
852 cmd[0] = 0x2A; 853 cmd[0] = WRITE_10;
853 scsi_flags = 0xa0a0000a; 854 scsi_flags = 0xa0a0000a;
854 } 855 }
855 856
856 writel(scsi_flags, mptr++); 857 *mptr++ = cpu_to_le32(scsi_flags);
857 858
858 *((u32 *) & cmd[2]) = cpu_to_be32(req->sector * hwsec); 859 *((u32 *) & cmd[2]) = cpu_to_be32(req->sector * hwsec);
859 *((u16 *) & cmd[7]) = cpu_to_be16(req->nr_sectors * hwsec); 860 *((u16 *) & cmd[7]) = cpu_to_be16(req->nr_sectors * hwsec);
860 861
861 memcpy_toio(mptr, cmd, 10); 862 memcpy(mptr, cmd, 10);
862 mptr += 4; 863 mptr += 4;
863 writel(req->nr_sectors << KERNEL_SECTOR_SHIFT, mptr++); 864 *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT);
864 } else 865 } else
865#endif 866#endif
866 { 867 {
867 writel(cmd | HOST_TID << 12 | tid, &msg->u.head[1]); 868 msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
868 writel(ctl_flags, mptr++); 869 *mptr++ = cpu_to_le32(ctl_flags);
869 writel(req->nr_sectors << KERNEL_SECTOR_SHIFT, mptr++); 870 *mptr++ = cpu_to_le32(req->nr_sectors << KERNEL_SECTOR_SHIFT);
870 writel((u32) (req->sector << KERNEL_SECTOR_SHIFT), mptr++); 871 *mptr++ =
871 writel(req->sector >> (32 - KERNEL_SECTOR_SHIFT), mptr++); 872 cpu_to_le32((u32) (req->sector << KERNEL_SECTOR_SHIFT));
873 *mptr++ =
874 cpu_to_le32(req->sector >> (32 - KERNEL_SECTOR_SHIFT));
872 } 875 }
873 876
874 if (!i2o_block_sglist_alloc(c, ireq, &mptr)) { 877 if (!i2o_block_sglist_alloc(c, ireq, &mptr)) {
@@ -876,13 +879,13 @@ static int i2o_block_transfer(struct request *req)
876 goto context_remove; 879 goto context_remove;
877 } 880 }
878 881
879 writel(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | 882 msg->u.head[0] =
880 sgl_offset, &msg->u.head[0]); 883 cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset);
881 884
882 list_add_tail(&ireq->queue, &dev->open_queue); 885 list_add_tail(&ireq->queue, &dev->open_queue);
883 dev->open_queue_depth++; 886 dev->open_queue_depth++;
884 887
885 i2o_msg_post(c, m); 888 i2o_msg_post(c, msg);
886 889
887 return 0; 890 return 0;
888 891
@@ -890,7 +893,7 @@ static int i2o_block_transfer(struct request *req)
890 i2o_cntxt_list_remove(c, req); 893 i2o_cntxt_list_remove(c, req);
891 894
892 nop_msg: 895 nop_msg:
893 i2o_msg_nop(c, m); 896 i2o_msg_nop(c, msg);
894 897
895 exit: 898 exit:
896 return rc; 899 return rc;
@@ -978,13 +981,12 @@ static struct i2o_block_device *i2o_block_device_alloc(void)
978 struct request_queue *queue; 981 struct request_queue *queue;
979 int rc; 982 int rc;
980 983
981 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 984 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
982 if (!dev) { 985 if (!dev) {
983 osm_err("Insufficient memory to allocate I2O Block disk.\n"); 986 osm_err("Insufficient memory to allocate I2O Block disk.\n");
984 rc = -ENOMEM; 987 rc = -ENOMEM;
985 goto exit; 988 goto exit;
986 } 989 }
987 memset(dev, 0, sizeof(*dev));
988 990
989 INIT_LIST_HEAD(&dev->open_queue); 991 INIT_LIST_HEAD(&dev->open_queue);
990 spin_lock_init(&dev->lock); 992 spin_lock_init(&dev->lock);
@@ -1049,8 +1051,8 @@ static int i2o_block_probe(struct device *dev)
1049 int rc; 1051 int rc;
1050 u64 size; 1052 u64 size;
1051 u32 blocksize; 1053 u32 blocksize;
1052 u32 flags, status;
1053 u16 body_size = 4; 1054 u16 body_size = 4;
1055 u16 power;
1054 unsigned short max_sectors; 1056 unsigned short max_sectors;
1055 1057
1056#ifdef CONFIG_I2O_EXT_ADAPTEC 1058#ifdef CONFIG_I2O_EXT_ADAPTEC
@@ -1108,22 +1110,20 @@ static int i2o_block_probe(struct device *dev)
1108 * Ask for the current media data. If that isn't supported 1110 * Ask for the current media data. If that isn't supported
1109 * then we ask for the device capacity data 1111 * then we ask for the device capacity data
1110 */ 1112 */
1111 if (i2o_parm_field_get(i2o_dev, 0x0004, 1, &blocksize, 4) || 1113 if (!i2o_parm_field_get(i2o_dev, 0x0004, 1, &blocksize, 4) ||
1112 i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4)) { 1114 !i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4)) {
1113 blk_queue_hardsect_size(queue, blocksize); 1115 blk_queue_hardsect_size(queue, le32_to_cpu(blocksize));
1114 } else 1116 } else
1115 osm_warn("unable to get blocksize of %s\n", gd->disk_name); 1117 osm_warn("unable to get blocksize of %s\n", gd->disk_name);
1116 1118
1117 if (i2o_parm_field_get(i2o_dev, 0x0004, 0, &size, 8) || 1119 if (!i2o_parm_field_get(i2o_dev, 0x0004, 0, &size, 8) ||
1118 i2o_parm_field_get(i2o_dev, 0x0000, 4, &size, 8)) { 1120 !i2o_parm_field_get(i2o_dev, 0x0000, 4, &size, 8)) {
1119 set_capacity(gd, size >> KERNEL_SECTOR_SHIFT); 1121 set_capacity(gd, le64_to_cpu(size) >> KERNEL_SECTOR_SHIFT);
1120 } else 1122 } else
1121 osm_warn("could not get size of %s\n", gd->disk_name); 1123 osm_warn("could not get size of %s\n", gd->disk_name);
1122 1124
1123 if (!i2o_parm_field_get(i2o_dev, 0x0000, 2, &i2o_blk_dev->power, 2)) 1125 if (!i2o_parm_field_get(i2o_dev, 0x0000, 2, &power, 2))
1124 i2o_blk_dev->power = 0; 1126 i2o_blk_dev->power = power;
1125 i2o_parm_field_get(i2o_dev, 0x0000, 5, &flags, 4);
1126 i2o_parm_field_get(i2o_dev, 0x0000, 6, &status, 4);
1127 1127
1128 i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0xffffffff); 1128 i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0xffffffff);
1129 1129
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 3c3a7abebb1b..89daf67b764d 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -36,12 +36,12 @@
36 36
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38 38
39#include "core.h"
40
41#define SG_TABLESIZE 30 39#define SG_TABLESIZE 30
42 40
43static int i2o_cfg_ioctl(struct inode *inode, struct file *fp, unsigned int cmd, 41extern int i2o_parm_issue(struct i2o_device *, int, void *, int, void *, int);
44 unsigned long arg); 42
43static int i2o_cfg_ioctl(struct inode *, struct file *, unsigned int,
44 unsigned long);
45 45
46static spinlock_t i2o_config_lock; 46static spinlock_t i2o_config_lock;
47 47
@@ -230,8 +230,7 @@ static int i2o_cfg_swdl(unsigned long arg)
230 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; 230 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
231 unsigned char maxfrag = 0, curfrag = 1; 231 unsigned char maxfrag = 0, curfrag = 1;
232 struct i2o_dma buffer; 232 struct i2o_dma buffer;
233 struct i2o_message __iomem *msg; 233 struct i2o_message *msg;
234 u32 m;
235 unsigned int status = 0, swlen = 0, fragsize = 8192; 234 unsigned int status = 0, swlen = 0, fragsize = 8192;
236 struct i2o_controller *c; 235 struct i2o_controller *c;
237 236
@@ -257,31 +256,34 @@ static int i2o_cfg_swdl(unsigned long arg)
257 if (!c) 256 if (!c)
258 return -ENXIO; 257 return -ENXIO;
259 258
260 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 259 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
261 if (m == I2O_QUEUE_EMPTY) 260 if (IS_ERR(msg))
262 return -EBUSY; 261 return PTR_ERR(msg);
263 262
264 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) { 263 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) {
265 i2o_msg_nop(c, m); 264 i2o_msg_nop(c, msg);
266 return -ENOMEM; 265 return -ENOMEM;
267 } 266 }
268 267
269 __copy_from_user(buffer.virt, kxfer.buf, fragsize); 268 __copy_from_user(buffer.virt, kxfer.buf, fragsize);
270 269
271 writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_7, &msg->u.head[0]); 270 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
272 writel(I2O_CMD_SW_DOWNLOAD << 24 | HOST_TID << 12 | ADAPTER_TID, 271 msg->u.head[1] =
273 &msg->u.head[1]); 272 cpu_to_le32(I2O_CMD_SW_DOWNLOAD << 24 | HOST_TID << 12 |
274 writel(i2o_config_driver.context, &msg->u.head[2]); 273 ADAPTER_TID);
275 writel(0, &msg->u.head[3]); 274 msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
276 writel((((u32) kxfer.flags) << 24) | (((u32) kxfer.sw_type) << 16) | 275 msg->u.head[3] = cpu_to_le32(0);
277 (((u32) maxfrag) << 8) | (((u32) curfrag)), &msg->body[0]); 276 msg->body[0] =
278 writel(swlen, &msg->body[1]); 277 cpu_to_le32((((u32) kxfer.flags) << 24) | (((u32) kxfer.
279 writel(kxfer.sw_id, &msg->body[2]); 278 sw_type) << 16) |
280 writel(0xD0000000 | fragsize, &msg->body[3]); 279 (((u32) maxfrag) << 8) | (((u32) curfrag)));
281 writel(buffer.phys, &msg->body[4]); 280 msg->body[1] = cpu_to_le32(swlen);
281 msg->body[2] = cpu_to_le32(kxfer.sw_id);
282 msg->body[3] = cpu_to_le32(0xD0000000 | fragsize);
283 msg->body[4] = cpu_to_le32(buffer.phys);
282 284
283 osm_debug("swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize); 285 osm_debug("swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
284 status = i2o_msg_post_wait_mem(c, m, 60, &buffer); 286 status = i2o_msg_post_wait_mem(c, msg, 60, &buffer);
285 287
286 if (status != -ETIMEDOUT) 288 if (status != -ETIMEDOUT)
287 i2o_dma_free(&c->pdev->dev, &buffer); 289 i2o_dma_free(&c->pdev->dev, &buffer);
@@ -302,8 +304,7 @@ static int i2o_cfg_swul(unsigned long arg)
302 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; 304 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
303 unsigned char maxfrag = 0, curfrag = 1; 305 unsigned char maxfrag = 0, curfrag = 1;
304 struct i2o_dma buffer; 306 struct i2o_dma buffer;
305 struct i2o_message __iomem *msg; 307 struct i2o_message *msg;
306 u32 m;
307 unsigned int status = 0, swlen = 0, fragsize = 8192; 308 unsigned int status = 0, swlen = 0, fragsize = 8192;
308 struct i2o_controller *c; 309 struct i2o_controller *c;
309 int ret = 0; 310 int ret = 0;
@@ -330,30 +331,30 @@ static int i2o_cfg_swul(unsigned long arg)
330 if (!c) 331 if (!c)
331 return -ENXIO; 332 return -ENXIO;
332 333
333 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 334 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
334 if (m == I2O_QUEUE_EMPTY) 335 if (IS_ERR(msg))
335 return -EBUSY; 336 return PTR_ERR(msg);
336 337
337 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) { 338 if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize, GFP_KERNEL)) {
338 i2o_msg_nop(c, m); 339 i2o_msg_nop(c, msg);
339 return -ENOMEM; 340 return -ENOMEM;
340 } 341 }
341 342
342 writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_7, &msg->u.head[0]); 343 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
343 writel(I2O_CMD_SW_UPLOAD << 24 | HOST_TID << 12 | ADAPTER_TID, 344 msg->u.head[1] =
344 &msg->u.head[1]); 345 cpu_to_le32(I2O_CMD_SW_UPLOAD << 24 | HOST_TID << 12 | ADAPTER_TID);
345 writel(i2o_config_driver.context, &msg->u.head[2]); 346 msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
346 writel(0, &msg->u.head[3]); 347 msg->u.head[3] = cpu_to_le32(0);
347 writel((u32) kxfer.flags << 24 | (u32) kxfer. 348 msg->body[0] =
348 sw_type << 16 | (u32) maxfrag << 8 | (u32) curfrag, 349 cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer.
349 &msg->body[0]); 350 sw_type << 16 | (u32) maxfrag << 8 | (u32) curfrag);
350 writel(swlen, &msg->body[1]); 351 msg->body[1] = cpu_to_le32(swlen);
351 writel(kxfer.sw_id, &msg->body[2]); 352 msg->body[2] = cpu_to_le32(kxfer.sw_id);
352 writel(0xD0000000 | fragsize, &msg->body[3]); 353 msg->body[3] = cpu_to_le32(0xD0000000 | fragsize);
353 writel(buffer.phys, &msg->body[4]); 354 msg->body[4] = cpu_to_le32(buffer.phys);
354 355
355 osm_debug("swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize); 356 osm_debug("swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
356 status = i2o_msg_post_wait_mem(c, m, 60, &buffer); 357 status = i2o_msg_post_wait_mem(c, msg, 60, &buffer);
357 358
358 if (status != I2O_POST_WAIT_OK) { 359 if (status != I2O_POST_WAIT_OK) {
359 if (status != -ETIMEDOUT) 360 if (status != -ETIMEDOUT)
@@ -380,8 +381,7 @@ static int i2o_cfg_swdel(unsigned long arg)
380 struct i2o_controller *c; 381 struct i2o_controller *c;
381 struct i2o_sw_xfer kxfer; 382 struct i2o_sw_xfer kxfer;
382 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg; 383 struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
383 struct i2o_message __iomem *msg; 384 struct i2o_message *msg;
384 u32 m;
385 unsigned int swlen; 385 unsigned int swlen;
386 int token; 386 int token;
387 387
@@ -395,21 +395,21 @@ static int i2o_cfg_swdel(unsigned long arg)
395 if (!c) 395 if (!c)
396 return -ENXIO; 396 return -ENXIO;
397 397
398 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 398 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
399 if (m == I2O_QUEUE_EMPTY) 399 if (IS_ERR(msg))
400 return -EBUSY; 400 return PTR_ERR(msg);
401 401
402 writel(SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 402 msg->u.head[0] = cpu_to_le32(SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0);
403 writel(I2O_CMD_SW_REMOVE << 24 | HOST_TID << 12 | ADAPTER_TID, 403 msg->u.head[1] =
404 &msg->u.head[1]); 404 cpu_to_le32(I2O_CMD_SW_REMOVE << 24 | HOST_TID << 12 | ADAPTER_TID);
405 writel(i2o_config_driver.context, &msg->u.head[2]); 405 msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
406 writel(0, &msg->u.head[3]); 406 msg->u.head[3] = cpu_to_le32(0);
407 writel((u32) kxfer.flags << 24 | (u32) kxfer.sw_type << 16, 407 msg->body[0] =
408 &msg->body[0]); 408 cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer.sw_type << 16);
409 writel(swlen, &msg->body[1]); 409 msg->body[1] = cpu_to_le32(swlen);
410 writel(kxfer.sw_id, &msg->body[2]); 410 msg->body[2] = cpu_to_le32(kxfer.sw_id);
411 411
412 token = i2o_msg_post_wait(c, m, 10); 412 token = i2o_msg_post_wait(c, msg, 10);
413 413
414 if (token != I2O_POST_WAIT_OK) { 414 if (token != I2O_POST_WAIT_OK) {
415 osm_info("swdel failed, DetailedStatus = %d\n", token); 415 osm_info("swdel failed, DetailedStatus = %d\n", token);
@@ -423,25 +423,24 @@ static int i2o_cfg_validate(unsigned long arg)
423{ 423{
424 int token; 424 int token;
425 int iop = (int)arg; 425 int iop = (int)arg;
426 struct i2o_message __iomem *msg; 426 struct i2o_message *msg;
427 u32 m;
428 struct i2o_controller *c; 427 struct i2o_controller *c;
429 428
430 c = i2o_find_iop(iop); 429 c = i2o_find_iop(iop);
431 if (!c) 430 if (!c)
432 return -ENXIO; 431 return -ENXIO;
433 432
434 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 433 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
435 if (m == I2O_QUEUE_EMPTY) 434 if (IS_ERR(msg))
436 return -EBUSY; 435 return PTR_ERR(msg);
437 436
438 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 437 msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
439 writel(I2O_CMD_CONFIG_VALIDATE << 24 | HOST_TID << 12 | iop, 438 msg->u.head[1] =
440 &msg->u.head[1]); 439 cpu_to_le32(I2O_CMD_CONFIG_VALIDATE << 24 | HOST_TID << 12 | iop);
441 writel(i2o_config_driver.context, &msg->u.head[2]); 440 msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
442 writel(0, &msg->u.head[3]); 441 msg->u.head[3] = cpu_to_le32(0);
443 442
444 token = i2o_msg_post_wait(c, m, 10); 443 token = i2o_msg_post_wait(c, msg, 10);
445 444
446 if (token != I2O_POST_WAIT_OK) { 445 if (token != I2O_POST_WAIT_OK) {
447 osm_info("Can't validate configuration, ErrorStatus = %d\n", 446 osm_info("Can't validate configuration, ErrorStatus = %d\n",
@@ -454,8 +453,7 @@ static int i2o_cfg_validate(unsigned long arg)
454 453
455static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp) 454static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp)
456{ 455{
457 struct i2o_message __iomem *msg; 456 struct i2o_message *msg;
458 u32 m;
459 struct i2o_evt_id __user *pdesc = (struct i2o_evt_id __user *)arg; 457 struct i2o_evt_id __user *pdesc = (struct i2o_evt_id __user *)arg;
460 struct i2o_evt_id kdesc; 458 struct i2o_evt_id kdesc;
461 struct i2o_controller *c; 459 struct i2o_controller *c;
@@ -474,18 +472,19 @@ static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp)
474 if (!d) 472 if (!d)
475 return -ENODEV; 473 return -ENODEV;
476 474
477 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 475 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
478 if (m == I2O_QUEUE_EMPTY) 476 if (IS_ERR(msg))
479 return -EBUSY; 477 return PTR_ERR(msg);
480 478
481 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 479 msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
482 writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | kdesc.tid, 480 msg->u.head[1] =
483 &msg->u.head[1]); 481 cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 |
484 writel(i2o_config_driver.context, &msg->u.head[2]); 482 kdesc.tid);
485 writel(i2o_cntxt_list_add(c, fp->private_data), &msg->u.head[3]); 483 msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
486 writel(kdesc.evt_mask, &msg->body[0]); 484 msg->u.head[3] = cpu_to_le32(i2o_cntxt_list_add(c, fp->private_data));
485 msg->body[0] = cpu_to_le32(kdesc.evt_mask);
487 486
488 i2o_msg_post(c, m); 487 i2o_msg_post(c, msg);
489 488
490 return 0; 489 return 0;
491} 490}
@@ -537,7 +536,6 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
537 u32 sg_index = 0; 536 u32 sg_index = 0;
538 i2o_status_block *sb; 537 i2o_status_block *sb;
539 struct i2o_message *msg; 538 struct i2o_message *msg;
540 u32 m;
541 unsigned int iop; 539 unsigned int iop;
542 540
543 cmd = (struct i2o_cmd_passthru32 __user *)arg; 541 cmd = (struct i2o_cmd_passthru32 __user *)arg;
@@ -553,7 +551,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
553 return -ENXIO; 551 return -ENXIO;
554 } 552 }
555 553
556 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 554 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
557 555
558 sb = c->status_block.virt; 556 sb = c->status_block.virt;
559 557
@@ -585,19 +583,15 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
585 reply_size >>= 16; 583 reply_size >>= 16;
586 reply_size <<= 2; 584 reply_size <<= 2;
587 585
588 reply = kmalloc(reply_size, GFP_KERNEL); 586 reply = kzalloc(reply_size, GFP_KERNEL);
589 if (!reply) { 587 if (!reply) {
590 printk(KERN_WARNING "%s: Could not allocate reply buffer\n", 588 printk(KERN_WARNING "%s: Could not allocate reply buffer\n",
591 c->name); 589 c->name);
592 return -ENOMEM; 590 return -ENOMEM;
593 } 591 }
594 memset(reply, 0, reply_size);
595 592
596 sg_offset = (msg->u.head[0] >> 4) & 0x0f; 593 sg_offset = (msg->u.head[0] >> 4) & 0x0f;
597 594
598 writel(i2o_config_driver.context, &msg->u.s.icntxt);
599 writel(i2o_cntxt_list_add(c, reply), &msg->u.s.tcntxt);
600
601 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); 595 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE);
602 if (sg_offset) { 596 if (sg_offset) {
603 struct sg_simple_element *sg; 597 struct sg_simple_element *sg;
@@ -631,7 +625,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
631 goto cleanup; 625 goto cleanup;
632 } 626 }
633 sg_size = sg[i].flag_count & 0xffffff; 627 sg_size = sg[i].flag_count & 0xffffff;
634 p = &(sg_list[sg_index++]); 628 p = &(sg_list[sg_index]);
635 /* Allocate memory for the transfer */ 629 /* Allocate memory for the transfer */
636 if (i2o_dma_alloc 630 if (i2o_dma_alloc
637 (&c->pdev->dev, p, sg_size, 631 (&c->pdev->dev, p, sg_size,
@@ -642,6 +636,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
642 rcode = -ENOMEM; 636 rcode = -ENOMEM;
643 goto sg_list_cleanup; 637 goto sg_list_cleanup;
644 } 638 }
639 sg_index++;
645 /* Copy in the user's SG buffer if necessary */ 640 /* Copy in the user's SG buffer if necessary */
646 if (sg[i]. 641 if (sg[i].
647 flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) { 642 flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) {
@@ -662,9 +657,11 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
662 } 657 }
663 } 658 }
664 659
665 rcode = i2o_msg_post_wait(c, m, 60); 660 rcode = i2o_msg_post_wait(c, msg, 60);
666 if (rcode) 661 if (rcode) {
662 reply[4] = ((u32) rcode) << 24;
667 goto sg_list_cleanup; 663 goto sg_list_cleanup;
664 }
668 665
669 if (sg_offset) { 666 if (sg_offset) {
670 u32 msg[I2O_OUTBOUND_MSG_FRAME_SIZE]; 667 u32 msg[I2O_OUTBOUND_MSG_FRAME_SIZE];
@@ -714,6 +711,7 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
714 } 711 }
715 } 712 }
716 713
714 sg_list_cleanup:
717 /* Copy back the reply to user space */ 715 /* Copy back the reply to user space */
718 if (reply_size) { 716 if (reply_size) {
719 // we wrote our own values for context - now restore the user supplied ones 717 // we wrote our own values for context - now restore the user supplied ones
@@ -731,7 +729,6 @@ static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
731 } 729 }
732 } 730 }
733 731
734 sg_list_cleanup:
735 for (i = 0; i < sg_index; i++) 732 for (i = 0; i < sg_index; i++)
736 i2o_dma_free(&c->pdev->dev, &sg_list[i]); 733 i2o_dma_free(&c->pdev->dev, &sg_list[i]);
737 734
@@ -780,8 +777,7 @@ static int i2o_cfg_passthru(unsigned long arg)
780 u32 i = 0; 777 u32 i = 0;
781 void *p = NULL; 778 void *p = NULL;
782 i2o_status_block *sb; 779 i2o_status_block *sb;
783 struct i2o_message __iomem *msg; 780 struct i2o_message *msg;
784 u32 m;
785 unsigned int iop; 781 unsigned int iop;
786 782
787 if (get_user(iop, &cmd->iop) || get_user(user_msg, &cmd->msg)) 783 if (get_user(iop, &cmd->iop) || get_user(user_msg, &cmd->msg))
@@ -793,7 +789,7 @@ static int i2o_cfg_passthru(unsigned long arg)
793 return -ENXIO; 789 return -ENXIO;
794 } 790 }
795 791
796 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 792 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
797 793
798 sb = c->status_block.virt; 794 sb = c->status_block.virt;
799 795
@@ -820,19 +816,15 @@ static int i2o_cfg_passthru(unsigned long arg)
820 reply_size >>= 16; 816 reply_size >>= 16;
821 reply_size <<= 2; 817 reply_size <<= 2;
822 818
823 reply = kmalloc(reply_size, GFP_KERNEL); 819 reply = kzalloc(reply_size, GFP_KERNEL);
824 if (!reply) { 820 if (!reply) {
825 printk(KERN_WARNING "%s: Could not allocate reply buffer\n", 821 printk(KERN_WARNING "%s: Could not allocate reply buffer\n",
826 c->name); 822 c->name);
827 return -ENOMEM; 823 return -ENOMEM;
828 } 824 }
829 memset(reply, 0, reply_size);
830 825
831 sg_offset = (msg->u.head[0] >> 4) & 0x0f; 826 sg_offset = (msg->u.head[0] >> 4) & 0x0f;
832 827
833 writel(i2o_config_driver.context, &msg->u.s.icntxt);
834 writel(i2o_cntxt_list_add(c, reply), &msg->u.s.tcntxt);
835
836 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE); 828 memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE);
837 if (sg_offset) { 829 if (sg_offset) {
838 struct sg_simple_element *sg; 830 struct sg_simple_element *sg;
@@ -894,9 +886,11 @@ static int i2o_cfg_passthru(unsigned long arg)
894 } 886 }
895 } 887 }
896 888
897 rcode = i2o_msg_post_wait(c, m, 60); 889 rcode = i2o_msg_post_wait(c, msg, 60);
898 if (rcode) 890 if (rcode) {
891 reply[4] = ((u32) rcode) << 24;
899 goto sg_list_cleanup; 892 goto sg_list_cleanup;
893 }
900 894
901 if (sg_offset) { 895 if (sg_offset) {
902 u32 msg[128]; 896 u32 msg[128];
@@ -946,6 +940,7 @@ static int i2o_cfg_passthru(unsigned long arg)
946 } 940 }
947 } 941 }
948 942
943 sg_list_cleanup:
949 /* Copy back the reply to user space */ 944 /* Copy back the reply to user space */
950 if (reply_size) { 945 if (reply_size) {
951 // we wrote our own values for context - now restore the user supplied ones 946 // we wrote our own values for context - now restore the user supplied ones
@@ -962,7 +957,6 @@ static int i2o_cfg_passthru(unsigned long arg)
962 } 957 }
963 } 958 }
964 959
965 sg_list_cleanup:
966 for (i = 0; i < sg_index; i++) 960 for (i = 0; i < sg_index; i++)
967 kfree(sg_list[i]); 961 kfree(sg_list[i]);
968 962
diff --git a/drivers/message/i2o/i2o_lan.h b/drivers/message/i2o/i2o_lan.h
index 561d63304d7e..6502b817df58 100644
--- a/drivers/message/i2o/i2o_lan.h
+++ b/drivers/message/i2o/i2o_lan.h
@@ -103,14 +103,14 @@
103#define I2O_LAN_DSC_SUSPENDED 0x11 103#define I2O_LAN_DSC_SUSPENDED 0x11
104 104
105struct i2o_packet_info { 105struct i2o_packet_info {
106 u32 offset : 24; 106 u32 offset:24;
107 u32 flags : 8; 107 u32 flags:8;
108 u32 len : 24; 108 u32 len:24;
109 u32 status : 8; 109 u32 status:8;
110}; 110};
111 111
112struct i2o_bucket_descriptor { 112struct i2o_bucket_descriptor {
113 u32 context; /* FIXME: 64bit support */ 113 u32 context; /* FIXME: 64bit support */
114 struct i2o_packet_info packet_info[1]; 114 struct i2o_packet_info packet_info[1];
115}; 115};
116 116
@@ -127,14 +127,14 @@ struct i2o_lan_local {
127 u8 unit; 127 u8 unit;
128 struct i2o_device *i2o_dev; 128 struct i2o_device *i2o_dev;
129 129
130 struct fddi_statistics stats; /* see also struct net_device_stats */ 130 struct fddi_statistics stats; /* see also struct net_device_stats */
131 unsigned short (*type_trans)(struct sk_buff *, struct net_device *); 131 unsigned short (*type_trans) (struct sk_buff *, struct net_device *);
132 atomic_t buckets_out; /* nbr of unused buckets on DDM */ 132 atomic_t buckets_out; /* nbr of unused buckets on DDM */
133 atomic_t tx_out; /* outstanding TXes */ 133 atomic_t tx_out; /* outstanding TXes */
134 u8 tx_count; /* packets in one TX message frame */ 134 u8 tx_count; /* packets in one TX message frame */
135 u16 tx_max_out; /* DDM's Tx queue len */ 135 u16 tx_max_out; /* DDM's Tx queue len */
136 u8 sgl_max; /* max SGLs in one message frame */ 136 u8 sgl_max; /* max SGLs in one message frame */
137 u32 m; /* IOP address of the batch msg frame */ 137 u32 m; /* IOP address of the batch msg frame */
138 138
139 struct work_struct i2o_batch_send_task; 139 struct work_struct i2o_batch_send_task;
140 int send_active; 140 int send_active;
@@ -144,16 +144,16 @@ struct i2o_lan_local {
144 144
145 spinlock_t tx_lock; 145 spinlock_t tx_lock;
146 146
147 u32 max_size_mc_table; /* max number of multicast addresses */ 147 u32 max_size_mc_table; /* max number of multicast addresses */
148 148
149 /* LAN OSM configurable parameters are here: */ 149 /* LAN OSM configurable parameters are here: */
150 150
151 u16 max_buckets_out; /* max nbr of buckets to send to DDM */ 151 u16 max_buckets_out; /* max nbr of buckets to send to DDM */
152 u16 bucket_thresh; /* send more when this many used */ 152 u16 bucket_thresh; /* send more when this many used */
153 u16 rx_copybreak; 153 u16 rx_copybreak;
154 154
155 u8 tx_batch_mode; /* Set when using batch mode sends */ 155 u8 tx_batch_mode; /* Set when using batch mode sends */
156 u32 i2o_event_mask; /* To turn on interesting event flags */ 156 u32 i2o_event_mask; /* To turn on interesting event flags */
157}; 157};
158 158
159#endif /* _I2O_LAN_H */ 159#endif /* _I2O_LAN_H */
diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
index d559a1758363..2a0c42b8cda5 100644
--- a/drivers/message/i2o/i2o_proc.c
+++ b/drivers/message/i2o/i2o_proc.c
@@ -28,7 +28,7 @@
28 */ 28 */
29 29
30#define OSM_NAME "proc-osm" 30#define OSM_NAME "proc-osm"
31#define OSM_VERSION "1.145" 31#define OSM_VERSION "1.316"
32#define OSM_DESCRIPTION "I2O ProcFS OSM" 32#define OSM_DESCRIPTION "I2O ProcFS OSM"
33 33
34#define I2O_MAX_MODULES 4 34#define I2O_MAX_MODULES 4
diff --git a/drivers/message/i2o/i2o_scsi.c b/drivers/message/i2o/i2o_scsi.c
index 9f1744c3933b..f9e5a23697a1 100644
--- a/drivers/message/i2o/i2o_scsi.c
+++ b/drivers/message/i2o/i2o_scsi.c
@@ -70,7 +70,7 @@
70#include <scsi/sg_request.h> 70#include <scsi/sg_request.h>
71 71
72#define OSM_NAME "scsi-osm" 72#define OSM_NAME "scsi-osm"
73#define OSM_VERSION "1.282" 73#define OSM_VERSION "1.316"
74#define OSM_DESCRIPTION "I2O SCSI Peripheral OSM" 74#define OSM_DESCRIPTION "I2O SCSI Peripheral OSM"
75 75
76static struct i2o_driver i2o_scsi_driver; 76static struct i2o_driver i2o_scsi_driver;
@@ -113,7 +113,7 @@ static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c)
113 113
114 list_for_each_entry(i2o_dev, &c->devices, list) 114 list_for_each_entry(i2o_dev, &c->devices, list)
115 if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) { 115 if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
116 if (i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) 116 if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1)
117 && (type == 0x01)) /* SCSI bus */ 117 && (type == 0x01)) /* SCSI bus */
118 max_channel++; 118 max_channel++;
119 } 119 }
@@ -146,7 +146,7 @@ static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c)
146 i = 0; 146 i = 0;
147 list_for_each_entry(i2o_dev, &c->devices, list) 147 list_for_each_entry(i2o_dev, &c->devices, list)
148 if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) { 148 if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
149 if (i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1) 149 if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1)
150 && (type == 0x01)) /* only SCSI bus */ 150 && (type == 0x01)) /* only SCSI bus */
151 i2o_shost->channel[i++] = i2o_dev; 151 i2o_shost->channel[i++] = i2o_dev;
152 152
@@ -238,13 +238,15 @@ static int i2o_scsi_probe(struct device *dev)
238 u8 type; 238 u8 type;
239 struct i2o_device *d = i2o_shost->channel[0]; 239 struct i2o_device *d = i2o_shost->channel[0];
240 240
241 if (i2o_parm_field_get(d, 0x0000, 0, &type, 1) 241 if (!i2o_parm_field_get(d, 0x0000, 0, &type, 1)
242 && (type == 0x01)) /* SCSI bus */ 242 && (type == 0x01)) /* SCSI bus */
243 if (i2o_parm_field_get(d, 0x0200, 4, &id, 4)) { 243 if (!i2o_parm_field_get(d, 0x0200, 4, &id, 4)) {
244 channel = 0; 244 channel = 0;
245 if (i2o_dev->lct_data.class_id == 245 if (i2o_dev->lct_data.class_id ==
246 I2O_CLASS_RANDOM_BLOCK_STORAGE) 246 I2O_CLASS_RANDOM_BLOCK_STORAGE)
247 lun = i2o_shost->lun++; 247 lun =
248 cpu_to_le64(i2o_shost->
249 lun++);
248 else 250 else
249 lun = 0; 251 lun = 0;
250 } 252 }
@@ -253,10 +255,10 @@ static int i2o_scsi_probe(struct device *dev)
253 break; 255 break;
254 256
255 case I2O_CLASS_SCSI_PERIPHERAL: 257 case I2O_CLASS_SCSI_PERIPHERAL:
256 if (i2o_parm_field_get(i2o_dev, 0x0000, 3, &id, 4) < 0) 258 if (i2o_parm_field_get(i2o_dev, 0x0000, 3, &id, 4))
257 return -EFAULT; 259 return -EFAULT;
258 260
259 if (i2o_parm_field_get(i2o_dev, 0x0000, 4, &lun, 8) < 0) 261 if (i2o_parm_field_get(i2o_dev, 0x0000, 4, &lun, 8))
260 return -EFAULT; 262 return -EFAULT;
261 263
262 parent = i2o_iop_find_device(c, i2o_dev->lct_data.parent_tid); 264 parent = i2o_iop_find_device(c, i2o_dev->lct_data.parent_tid);
@@ -281,20 +283,22 @@ static int i2o_scsi_probe(struct device *dev)
281 return -EFAULT; 283 return -EFAULT;
282 } 284 }
283 285
284 if (id >= scsi_host->max_id) { 286 if (le32_to_cpu(id) >= scsi_host->max_id) {
285 osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)", id, 287 osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)",
286 scsi_host->max_id); 288 le32_to_cpu(id), scsi_host->max_id);
287 return -EFAULT; 289 return -EFAULT;
288 } 290 }
289 291
290 if (lun >= scsi_host->max_lun) { 292 if (le64_to_cpu(lun) >= scsi_host->max_lun) {
291 osm_warn("SCSI device id (%d) >= max_lun of I2O host (%d)", 293 osm_warn("SCSI device lun (%lu) >= max_lun of I2O host (%d)",
292 (unsigned int)lun, scsi_host->max_lun); 294 (long unsigned int)le64_to_cpu(lun),
295 scsi_host->max_lun);
293 return -EFAULT; 296 return -EFAULT;
294 } 297 }
295 298
296 scsi_dev = 299 scsi_dev =
297 __scsi_add_device(i2o_shost->scsi_host, channel, id, lun, i2o_dev); 300 __scsi_add_device(i2o_shost->scsi_host, channel, le32_to_cpu(id),
301 le64_to_cpu(lun), i2o_dev);
298 302
299 if (IS_ERR(scsi_dev)) { 303 if (IS_ERR(scsi_dev)) {
300 osm_warn("can not add SCSI device %03x\n", 304 osm_warn("can not add SCSI device %03x\n",
@@ -305,8 +309,9 @@ static int i2o_scsi_probe(struct device *dev)
305 sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj, 309 sysfs_create_link(&i2o_dev->device.kobj, &scsi_dev->sdev_gendev.kobj,
306 "scsi"); 310 "scsi");
307 311
308 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %d\n", 312 osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
309 i2o_dev->lct_data.tid, channel, id, (unsigned int)lun); 313 i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
314 (long unsigned int)le64_to_cpu(lun));
310 315
311 return 0; 316 return 0;
312}; 317};
@@ -510,8 +515,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
510 struct i2o_controller *c; 515 struct i2o_controller *c;
511 struct i2o_device *i2o_dev; 516 struct i2o_device *i2o_dev;
512 int tid; 517 int tid;
513 struct i2o_message __iomem *msg; 518 struct i2o_message *msg;
514 u32 m;
515 /* 519 /*
516 * ENABLE_DISCONNECT 520 * ENABLE_DISCONNECT
517 * SIMPLE_TAG 521 * SIMPLE_TAG
@@ -519,7 +523,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
519 */ 523 */
520 u32 scsi_flags = 0x20a00000; 524 u32 scsi_flags = 0x20a00000;
521 u32 sgl_offset; 525 u32 sgl_offset;
522 u32 __iomem *mptr; 526 u32 *mptr;
523 u32 cmd = I2O_CMD_SCSI_EXEC << 24; 527 u32 cmd = I2O_CMD_SCSI_EXEC << 24;
524 int rc = 0; 528 int rc = 0;
525 529
@@ -576,8 +580,8 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
576 * throw it back to the scsi layer 580 * throw it back to the scsi layer
577 */ 581 */
578 582
579 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 583 msg = i2o_msg_get(c);
580 if (m == I2O_QUEUE_EMPTY) { 584 if (IS_ERR(msg)) {
581 rc = SCSI_MLQUEUE_HOST_BUSY; 585 rc = SCSI_MLQUEUE_HOST_BUSY;
582 goto exit; 586 goto exit;
583 } 587 }
@@ -617,16 +621,16 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
617 if (sgl_offset == SGL_OFFSET_10) 621 if (sgl_offset == SGL_OFFSET_10)
618 sgl_offset = SGL_OFFSET_12; 622 sgl_offset = SGL_OFFSET_12;
619 cmd = I2O_CMD_PRIVATE << 24; 623 cmd = I2O_CMD_PRIVATE << 24;
620 writel(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC, mptr++); 624 *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC);
621 writel(adpt_flags | tid, mptr++); 625 *mptr++ = cpu_to_le32(adpt_flags | tid);
622 } 626 }
623#endif 627#endif
624 628
625 writel(cmd | HOST_TID << 12 | tid, &msg->u.head[1]); 629 msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
626 writel(i2o_scsi_driver.context, &msg->u.s.icntxt); 630 msg->u.s.icntxt = cpu_to_le32(i2o_scsi_driver.context);
627 631
628 /* We want the SCSI control block back */ 632 /* We want the SCSI control block back */
629 writel(i2o_cntxt_list_add(c, SCpnt), &msg->u.s.tcntxt); 633 msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, SCpnt));
630 634
631 /* LSI_920_PCI_QUIRK 635 /* LSI_920_PCI_QUIRK
632 * 636 *
@@ -649,15 +653,15 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
649 } 653 }
650 */ 654 */
651 655
652 writel(scsi_flags | SCpnt->cmd_len, mptr++); 656 *mptr++ = cpu_to_le32(scsi_flags | SCpnt->cmd_len);
653 657
654 /* Write SCSI command into the message - always 16 byte block */ 658 /* Write SCSI command into the message - always 16 byte block */
655 memcpy_toio(mptr, SCpnt->cmnd, 16); 659 memcpy(mptr, SCpnt->cmnd, 16);
656 mptr += 4; 660 mptr += 4;
657 661
658 if (sgl_offset != SGL_OFFSET_0) { 662 if (sgl_offset != SGL_OFFSET_0) {
659 /* write size of data addressed by SGL */ 663 /* write size of data addressed by SGL */
660 writel(SCpnt->request_bufflen, mptr++); 664 *mptr++ = cpu_to_le32(SCpnt->request_bufflen);
661 665
662 /* Now fill in the SGList and command */ 666 /* Now fill in the SGList and command */
663 if (SCpnt->use_sg) { 667 if (SCpnt->use_sg) {
@@ -676,11 +680,11 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
676 } 680 }
677 681
678 /* Stick the headers on */ 682 /* Stick the headers on */
679 writel(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset, 683 msg->u.head[0] =
680 &msg->u.head[0]); 684 cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset);
681 685
682 /* Queue the message */ 686 /* Queue the message */
683 i2o_msg_post(c, m); 687 i2o_msg_post(c, msg);
684 688
685 osm_debug("Issued %ld\n", SCpnt->serial_number); 689 osm_debug("Issued %ld\n", SCpnt->serial_number);
686 690
@@ -688,7 +692,7 @@ static int i2o_scsi_queuecommand(struct scsi_cmnd *SCpnt,
688 692
689 nomem: 693 nomem:
690 rc = -ENOMEM; 694 rc = -ENOMEM;
691 i2o_msg_nop(c, m); 695 i2o_msg_nop(c, msg);
692 696
693 exit: 697 exit:
694 return rc; 698 return rc;
@@ -709,8 +713,7 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
709{ 713{
710 struct i2o_device *i2o_dev; 714 struct i2o_device *i2o_dev;
711 struct i2o_controller *c; 715 struct i2o_controller *c;
712 struct i2o_message __iomem *msg; 716 struct i2o_message *msg;
713 u32 m;
714 int tid; 717 int tid;
715 int status = FAILED; 718 int status = FAILED;
716 719
@@ -720,16 +723,16 @@ static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
720 c = i2o_dev->iop; 723 c = i2o_dev->iop;
721 tid = i2o_dev->lct_data.tid; 724 tid = i2o_dev->lct_data.tid;
722 725
723 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 726 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
724 if (m == I2O_QUEUE_EMPTY) 727 if (IS_ERR(msg))
725 return SCSI_MLQUEUE_HOST_BUSY; 728 return SCSI_MLQUEUE_HOST_BUSY;
726 729
727 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 730 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
728 writel(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid, 731 msg->u.head[1] =
729 &msg->u.head[1]); 732 cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid);
730 writel(i2o_cntxt_list_get_ptr(c, SCpnt), &msg->body[0]); 733 msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt));
731 734
732 if (i2o_msg_post_wait(c, m, I2O_TIMEOUT_SCSI_SCB_ABORT)) 735 if (i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT))
733 status = SUCCESS; 736 status = SUCCESS;
734 737
735 return status; 738 return status;
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index 4eb53258842e..492167446936 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -32,7 +32,7 @@
32#include "core.h" 32#include "core.h"
33 33
34#define OSM_NAME "i2o" 34#define OSM_NAME "i2o"
35#define OSM_VERSION "1.288" 35#define OSM_VERSION "1.325"
36#define OSM_DESCRIPTION "I2O subsystem" 36#define OSM_DESCRIPTION "I2O subsystem"
37 37
38/* global I2O controller list */ 38/* global I2O controller list */
@@ -47,27 +47,6 @@ static struct i2o_dma i2o_systab;
47static int i2o_hrt_get(struct i2o_controller *c); 47static int i2o_hrt_get(struct i2o_controller *c);
48 48
49/** 49/**
50 * i2o_msg_nop - Returns a message which is not used
51 * @c: I2O controller from which the message was created
52 * @m: message which should be returned
53 *
54 * If you fetch a message via i2o_msg_get, and can't use it, you must
55 * return the message with this function. Otherwise the message frame
56 * is lost.
57 */
58void i2o_msg_nop(struct i2o_controller *c, u32 m)
59{
60 struct i2o_message __iomem *msg = i2o_msg_in_to_virt(c, m);
61
62 writel(THREE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]);
63 writel(I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID,
64 &msg->u.head[1]);
65 writel(0, &msg->u.head[2]);
66 writel(0, &msg->u.head[3]);
67 i2o_msg_post(c, m);
68};
69
70/**
71 * i2o_msg_get_wait - obtain an I2O message from the IOP 50 * i2o_msg_get_wait - obtain an I2O message from the IOP
72 * @c: I2O controller 51 * @c: I2O controller
73 * @msg: pointer to a I2O message pointer 52 * @msg: pointer to a I2O message pointer
@@ -81,22 +60,21 @@ void i2o_msg_nop(struct i2o_controller *c, u32 m)
81 * address from the read port (see the i2o spec). If no message is 60 * address from the read port (see the i2o spec). If no message is
82 * available returns I2O_QUEUE_EMPTY and msg is leaved untouched. 61 * available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
83 */ 62 */
84u32 i2o_msg_get_wait(struct i2o_controller *c, 63struct i2o_message *i2o_msg_get_wait(struct i2o_controller *c, int wait)
85 struct i2o_message __iomem ** msg, int wait)
86{ 64{
87 unsigned long timeout = jiffies + wait * HZ; 65 unsigned long timeout = jiffies + wait * HZ;
88 u32 m; 66 struct i2o_message *msg;
89 67
90 while ((m = i2o_msg_get(c, msg)) == I2O_QUEUE_EMPTY) { 68 while (IS_ERR(msg = i2o_msg_get(c))) {
91 if (time_after(jiffies, timeout)) { 69 if (time_after(jiffies, timeout)) {
92 osm_debug("%s: Timeout waiting for message frame.\n", 70 osm_debug("%s: Timeout waiting for message frame.\n",
93 c->name); 71 c->name);
94 return I2O_QUEUE_EMPTY; 72 return ERR_PTR(-ETIMEDOUT);
95 } 73 }
96 schedule_timeout_uninterruptible(1); 74 schedule_timeout_uninterruptible(1);
97 } 75 }
98 76
99 return m; 77 return msg;
100}; 78};
101 79
102#if BITS_PER_LONG == 64 80#if BITS_PER_LONG == 64
@@ -301,8 +279,7 @@ struct i2o_device *i2o_iop_find_device(struct i2o_controller *c, u16 tid)
301 */ 279 */
302static int i2o_iop_quiesce(struct i2o_controller *c) 280static int i2o_iop_quiesce(struct i2o_controller *c)
303{ 281{
304 struct i2o_message __iomem *msg; 282 struct i2o_message *msg;
305 u32 m;
306 i2o_status_block *sb = c->status_block.virt; 283 i2o_status_block *sb = c->status_block.virt;
307 int rc; 284 int rc;
308 285
@@ -313,16 +290,17 @@ static int i2o_iop_quiesce(struct i2o_controller *c)
313 (sb->iop_state != ADAPTER_STATE_OPERATIONAL)) 290 (sb->iop_state != ADAPTER_STATE_OPERATIONAL))
314 return 0; 291 return 0;
315 292
316 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 293 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
317 if (m == I2O_QUEUE_EMPTY) 294 if (IS_ERR(msg))
318 return -ETIMEDOUT; 295 return PTR_ERR(msg);
319 296
320 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 297 msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
321 writel(I2O_CMD_SYS_QUIESCE << 24 | HOST_TID << 12 | ADAPTER_TID, 298 msg->u.head[1] =
322 &msg->u.head[1]); 299 cpu_to_le32(I2O_CMD_SYS_QUIESCE << 24 | HOST_TID << 12 |
300 ADAPTER_TID);
323 301
324 /* Long timeout needed for quiesce if lots of devices */ 302 /* Long timeout needed for quiesce if lots of devices */
325 if ((rc = i2o_msg_post_wait(c, m, 240))) 303 if ((rc = i2o_msg_post_wait(c, msg, 240)))
326 osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc); 304 osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc);
327 else 305 else
328 osm_debug("%s: Quiesced.\n", c->name); 306 osm_debug("%s: Quiesced.\n", c->name);
@@ -342,8 +320,7 @@ static int i2o_iop_quiesce(struct i2o_controller *c)
342 */ 320 */
343static int i2o_iop_enable(struct i2o_controller *c) 321static int i2o_iop_enable(struct i2o_controller *c)
344{ 322{
345 struct i2o_message __iomem *msg; 323 struct i2o_message *msg;
346 u32 m;
347 i2o_status_block *sb = c->status_block.virt; 324 i2o_status_block *sb = c->status_block.virt;
348 int rc; 325 int rc;
349 326
@@ -353,16 +330,17 @@ static int i2o_iop_enable(struct i2o_controller *c)
353 if (sb->iop_state != ADAPTER_STATE_READY) 330 if (sb->iop_state != ADAPTER_STATE_READY)
354 return -EINVAL; 331 return -EINVAL;
355 332
356 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 333 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
357 if (m == I2O_QUEUE_EMPTY) 334 if (IS_ERR(msg))
358 return -ETIMEDOUT; 335 return PTR_ERR(msg);
359 336
360 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 337 msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
361 writel(I2O_CMD_SYS_ENABLE << 24 | HOST_TID << 12 | ADAPTER_TID, 338 msg->u.head[1] =
362 &msg->u.head[1]); 339 cpu_to_le32(I2O_CMD_SYS_ENABLE << 24 | HOST_TID << 12 |
340 ADAPTER_TID);
363 341
364 /* How long of a timeout do we need? */ 342 /* How long of a timeout do we need? */
365 if ((rc = i2o_msg_post_wait(c, m, 240))) 343 if ((rc = i2o_msg_post_wait(c, msg, 240)))
366 osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc); 344 osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc);
367 else 345 else
368 osm_debug("%s: Enabled.\n", c->name); 346 osm_debug("%s: Enabled.\n", c->name);
@@ -413,22 +391,22 @@ static inline void i2o_iop_enable_all(void)
413 */ 391 */
414static int i2o_iop_clear(struct i2o_controller *c) 392static int i2o_iop_clear(struct i2o_controller *c)
415{ 393{
416 struct i2o_message __iomem *msg; 394 struct i2o_message *msg;
417 u32 m;
418 int rc; 395 int rc;
419 396
420 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 397 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
421 if (m == I2O_QUEUE_EMPTY) 398 if (IS_ERR(msg))
422 return -ETIMEDOUT; 399 return PTR_ERR(msg);
423 400
424 /* Quiesce all IOPs first */ 401 /* Quiesce all IOPs first */
425 i2o_iop_quiesce_all(); 402 i2o_iop_quiesce_all();
426 403
427 writel(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 404 msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
428 writel(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 | ADAPTER_TID, 405 msg->u.head[1] =
429 &msg->u.head[1]); 406 cpu_to_le32(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 |
407 ADAPTER_TID);
430 408
431 if ((rc = i2o_msg_post_wait(c, m, 30))) 409 if ((rc = i2o_msg_post_wait(c, msg, 30)))
432 osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc); 410 osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc);
433 else 411 else
434 osm_debug("%s: Cleared.\n", c->name); 412 osm_debug("%s: Cleared.\n", c->name);
@@ -446,13 +424,13 @@ static int i2o_iop_clear(struct i2o_controller *c)
446 * Clear and (re)initialize IOP's outbound queue and post the message 424 * Clear and (re)initialize IOP's outbound queue and post the message
447 * frames to the IOP. 425 * frames to the IOP.
448 * 426 *
449 * Returns 0 on success or a negative errno code on failure. 427 * Returns 0 on success or negative error code on failure.
450 */ 428 */
451static int i2o_iop_init_outbound_queue(struct i2o_controller *c) 429static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
452{ 430{
453 volatile u8 *status = c->status.virt;
454 u32 m; 431 u32 m;
455 struct i2o_message __iomem *msg; 432 volatile u8 *status = c->status.virt;
433 struct i2o_message *msg;
456 ulong timeout; 434 ulong timeout;
457 int i; 435 int i;
458 436
@@ -460,23 +438,24 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
460 438
461 memset(c->status.virt, 0, 4); 439 memset(c->status.virt, 0, 4);
462 440
463 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 441 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
464 if (m == I2O_QUEUE_EMPTY) 442 if (IS_ERR(msg))
465 return -ETIMEDOUT; 443 return PTR_ERR(msg);
466 444
467 writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6, &msg->u.head[0]); 445 msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
468 writel(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 | ADAPTER_TID, 446 msg->u.head[1] =
469 &msg->u.head[1]); 447 cpu_to_le32(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 |
470 writel(i2o_exec_driver.context, &msg->u.s.icntxt); 448 ADAPTER_TID);
471 writel(0x00000000, &msg->u.s.tcntxt); 449 msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
472 writel(PAGE_SIZE, &msg->body[0]); 450 msg->u.s.tcntxt = cpu_to_le32(0x00000000);
451 msg->body[0] = cpu_to_le32(PAGE_SIZE);
473 /* Outbound msg frame size in words and Initcode */ 452 /* Outbound msg frame size in words and Initcode */
474 writel(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80, &msg->body[1]); 453 msg->body[1] = cpu_to_le32(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80);
475 writel(0xd0000004, &msg->body[2]); 454 msg->body[2] = cpu_to_le32(0xd0000004);
476 writel(i2o_dma_low(c->status.phys), &msg->body[3]); 455 msg->body[3] = cpu_to_le32(i2o_dma_low(c->status.phys));
477 writel(i2o_dma_high(c->status.phys), &msg->body[4]); 456 msg->body[4] = cpu_to_le32(i2o_dma_high(c->status.phys));
478 457
479 i2o_msg_post(c, m); 458 i2o_msg_post(c, msg);
480 459
481 timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ; 460 timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ;
482 while (*status <= I2O_CMD_IN_PROGRESS) { 461 while (*status <= I2O_CMD_IN_PROGRESS) {
@@ -511,34 +490,34 @@ static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
511static int i2o_iop_reset(struct i2o_controller *c) 490static int i2o_iop_reset(struct i2o_controller *c)
512{ 491{
513 volatile u8 *status = c->status.virt; 492 volatile u8 *status = c->status.virt;
514 struct i2o_message __iomem *msg; 493 struct i2o_message *msg;
515 u32 m;
516 unsigned long timeout; 494 unsigned long timeout;
517 i2o_status_block *sb = c->status_block.virt; 495 i2o_status_block *sb = c->status_block.virt;
518 int rc = 0; 496 int rc = 0;
519 497
520 osm_debug("%s: Resetting controller\n", c->name); 498 osm_debug("%s: Resetting controller\n", c->name);
521 499
522 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 500 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
523 if (m == I2O_QUEUE_EMPTY) 501 if (IS_ERR(msg))
524 return -ETIMEDOUT; 502 return PTR_ERR(msg);
525 503
526 memset(c->status_block.virt, 0, 8); 504 memset(c->status_block.virt, 0, 8);
527 505
528 /* Quiesce all IOPs first */ 506 /* Quiesce all IOPs first */
529 i2o_iop_quiesce_all(); 507 i2o_iop_quiesce_all();
530 508
531 writel(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 509 msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0);
532 writel(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 | ADAPTER_TID, 510 msg->u.head[1] =
533 &msg->u.head[1]); 511 cpu_to_le32(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 |
534 writel(i2o_exec_driver.context, &msg->u.s.icntxt); 512 ADAPTER_TID);
535 writel(0, &msg->u.s.tcntxt); //FIXME: use reasonable transaction context 513 msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
536 writel(0, &msg->body[0]); 514 msg->u.s.tcntxt = cpu_to_le32(0x00000000);
537 writel(0, &msg->body[1]); 515 msg->body[0] = cpu_to_le32(0x00000000);
538 writel(i2o_dma_low(c->status.phys), &msg->body[2]); 516 msg->body[1] = cpu_to_le32(0x00000000);
539 writel(i2o_dma_high(c->status.phys), &msg->body[3]); 517 msg->body[2] = cpu_to_le32(i2o_dma_low(c->status.phys));
518 msg->body[3] = cpu_to_le32(i2o_dma_high(c->status.phys));
540 519
541 i2o_msg_post(c, m); 520 i2o_msg_post(c, msg);
542 521
543 /* Wait for a reply */ 522 /* Wait for a reply */
544 timeout = jiffies + I2O_TIMEOUT_RESET * HZ; 523 timeout = jiffies + I2O_TIMEOUT_RESET * HZ;
@@ -567,18 +546,15 @@ static int i2o_iop_reset(struct i2o_controller *c)
567 osm_debug("%s: Reset in progress, waiting for reboot...\n", 546 osm_debug("%s: Reset in progress, waiting for reboot...\n",
568 c->name); 547 c->name);
569 548
570 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET); 549 while (IS_ERR(msg = i2o_msg_get_wait(c, I2O_TIMEOUT_RESET))) {
571 while (m == I2O_QUEUE_EMPTY) {
572 if (time_after(jiffies, timeout)) { 550 if (time_after(jiffies, timeout)) {
573 osm_err("%s: IOP reset timeout.\n", c->name); 551 osm_err("%s: IOP reset timeout.\n", c->name);
574 rc = -ETIMEDOUT; 552 rc = PTR_ERR(msg);
575 goto exit; 553 goto exit;
576 } 554 }
577 schedule_timeout_uninterruptible(1); 555 schedule_timeout_uninterruptible(1);
578
579 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_RESET);
580 } 556 }
581 i2o_msg_nop(c, m); 557 i2o_msg_nop(c, msg);
582 558
583 /* from here all quiesce commands are safe */ 559 /* from here all quiesce commands are safe */
584 c->no_quiesce = 0; 560 c->no_quiesce = 0;
@@ -686,8 +662,7 @@ static int i2o_iop_activate(struct i2o_controller *c)
686 */ 662 */
687static int i2o_iop_systab_set(struct i2o_controller *c) 663static int i2o_iop_systab_set(struct i2o_controller *c)
688{ 664{
689 struct i2o_message __iomem *msg; 665 struct i2o_message *msg;
690 u32 m;
691 i2o_status_block *sb = c->status_block.virt; 666 i2o_status_block *sb = c->status_block.virt;
692 struct device *dev = &c->pdev->dev; 667 struct device *dev = &c->pdev->dev;
693 struct resource *root; 668 struct resource *root;
@@ -735,41 +710,38 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
735 } 710 }
736 } 711 }
737 712
738 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 713 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
739 if (m == I2O_QUEUE_EMPTY) 714 if (IS_ERR(msg))
740 return -ETIMEDOUT; 715 return PTR_ERR(msg);
741 716
742 i2o_systab.phys = dma_map_single(dev, i2o_systab.virt, i2o_systab.len, 717 i2o_systab.phys = dma_map_single(dev, i2o_systab.virt, i2o_systab.len,
743 PCI_DMA_TODEVICE); 718 PCI_DMA_TODEVICE);
744 if (!i2o_systab.phys) { 719 if (!i2o_systab.phys) {
745 i2o_msg_nop(c, m); 720 i2o_msg_nop(c, msg);
746 return -ENOMEM; 721 return -ENOMEM;
747 } 722 }
748 723
749 writel(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6, &msg->u.head[0]); 724 msg->u.head[0] = cpu_to_le32(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6);
750 writel(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 | ADAPTER_TID, 725 msg->u.head[1] =
751 &msg->u.head[1]); 726 cpu_to_le32(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 |
727 ADAPTER_TID);
752 728
753 /* 729 /*
754 * Provide three SGL-elements: 730 * Provide three SGL-elements:
755 * System table (SysTab), Private memory space declaration and 731 * System table (SysTab), Private memory space declaration and
756 * Private i/o space declaration 732 * Private i/o space declaration
757 *
758 * FIXME: is this still true?
759 * Nasty one here. We can't use dma_alloc_coherent to send the
760 * same table to everyone. We have to go remap it for them all
761 */ 733 */
762 734
763 writel(c->unit + 2, &msg->body[0]); 735 msg->body[0] = cpu_to_le32(c->unit + 2);
764 writel(0, &msg->body[1]); 736 msg->body[1] = cpu_to_le32(0x00000000);
765 writel(0x54000000 | i2o_systab.len, &msg->body[2]); 737 msg->body[2] = cpu_to_le32(0x54000000 | i2o_systab.len);
766 writel(i2o_systab.phys, &msg->body[3]); 738 msg->body[3] = cpu_to_le32(i2o_systab.phys);
767 writel(0x54000000 | sb->current_mem_size, &msg->body[4]); 739 msg->body[4] = cpu_to_le32(0x54000000 | sb->current_mem_size);
768 writel(sb->current_mem_base, &msg->body[5]); 740 msg->body[5] = cpu_to_le32(sb->current_mem_base);
769 writel(0xd4000000 | sb->current_io_size, &msg->body[6]); 741 msg->body[6] = cpu_to_le32(0xd4000000 | sb->current_io_size);
770 writel(sb->current_io_base, &msg->body[6]); 742 msg->body[6] = cpu_to_le32(sb->current_io_base);
771 743
772 rc = i2o_msg_post_wait(c, m, 120); 744 rc = i2o_msg_post_wait(c, msg, 120);
773 745
774 dma_unmap_single(dev, i2o_systab.phys, i2o_systab.len, 746 dma_unmap_single(dev, i2o_systab.phys, i2o_systab.len,
775 PCI_DMA_TODEVICE); 747 PCI_DMA_TODEVICE);
@@ -780,8 +752,6 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
780 else 752 else
781 osm_debug("%s: SysTab set.\n", c->name); 753 osm_debug("%s: SysTab set.\n", c->name);
782 754
783 i2o_status_get(c); // Entered READY state
784
785 return rc; 755 return rc;
786} 756}
787 757
@@ -791,7 +761,7 @@ static int i2o_iop_systab_set(struct i2o_controller *c)
791 * 761 *
792 * Send the system table and enable the I2O controller. 762 * Send the system table and enable the I2O controller.
793 * 763 *
794 * Returns 0 on success or negativer error code on failure. 764 * Returns 0 on success or negative error code on failure.
795 */ 765 */
796static int i2o_iop_online(struct i2o_controller *c) 766static int i2o_iop_online(struct i2o_controller *c)
797{ 767{
@@ -830,7 +800,6 @@ void i2o_iop_remove(struct i2o_controller *c)
830 list_for_each_entry_safe(dev, tmp, &c->devices, list) 800 list_for_each_entry_safe(dev, tmp, &c->devices, list)
831 i2o_device_remove(dev); 801 i2o_device_remove(dev);
832 802
833 class_device_unregister(c->classdev);
834 device_del(&c->device); 803 device_del(&c->device);
835 804
836 /* Ask the IOP to switch to RESET state */ 805 /* Ask the IOP to switch to RESET state */
@@ -869,12 +838,11 @@ static int i2o_systab_build(void)
869 i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers * 838 i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers *
870 sizeof(struct i2o_sys_tbl_entry); 839 sizeof(struct i2o_sys_tbl_entry);
871 840
872 systab = i2o_systab.virt = kmalloc(i2o_systab.len, GFP_KERNEL); 841 systab = i2o_systab.virt = kzalloc(i2o_systab.len, GFP_KERNEL);
873 if (!systab) { 842 if (!systab) {
874 osm_err("unable to allocate memory for System Table\n"); 843 osm_err("unable to allocate memory for System Table\n");
875 return -ENOMEM; 844 return -ENOMEM;
876 } 845 }
877 memset(systab, 0, i2o_systab.len);
878 846
879 systab->version = I2OVERSION; 847 systab->version = I2OVERSION;
880 systab->change_ind = change_ind + 1; 848 systab->change_ind = change_ind + 1;
@@ -952,30 +920,30 @@ static int i2o_parse_hrt(struct i2o_controller *c)
952 */ 920 */
953int i2o_status_get(struct i2o_controller *c) 921int i2o_status_get(struct i2o_controller *c)
954{ 922{
955 struct i2o_message __iomem *msg; 923 struct i2o_message *msg;
956 u32 m;
957 volatile u8 *status_block; 924 volatile u8 *status_block;
958 unsigned long timeout; 925 unsigned long timeout;
959 926
960 status_block = (u8 *) c->status_block.virt; 927 status_block = (u8 *) c->status_block.virt;
961 memset(c->status_block.virt, 0, sizeof(i2o_status_block)); 928 memset(c->status_block.virt, 0, sizeof(i2o_status_block));
962 929
963 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 930 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
964 if (m == I2O_QUEUE_EMPTY) 931 if (IS_ERR(msg))
965 return -ETIMEDOUT; 932 return PTR_ERR(msg);
966 933
967 writel(NINE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 934 msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_0);
968 writel(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 | ADAPTER_TID, 935 msg->u.head[1] =
969 &msg->u.head[1]); 936 cpu_to_le32(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 |
970 writel(i2o_exec_driver.context, &msg->u.s.icntxt); 937 ADAPTER_TID);
971 writel(0, &msg->u.s.tcntxt); // FIXME: use resonable transaction context 938 msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
972 writel(0, &msg->body[0]); 939 msg->u.s.tcntxt = cpu_to_le32(0x00000000);
973 writel(0, &msg->body[1]); 940 msg->body[0] = cpu_to_le32(0x00000000);
974 writel(i2o_dma_low(c->status_block.phys), &msg->body[2]); 941 msg->body[1] = cpu_to_le32(0x00000000);
975 writel(i2o_dma_high(c->status_block.phys), &msg->body[3]); 942 msg->body[2] = cpu_to_le32(i2o_dma_low(c->status_block.phys));
976 writel(sizeof(i2o_status_block), &msg->body[4]); /* always 88 bytes */ 943 msg->body[3] = cpu_to_le32(i2o_dma_high(c->status_block.phys));
944 msg->body[4] = cpu_to_le32(sizeof(i2o_status_block)); /* always 88 bytes */
977 945
978 i2o_msg_post(c, m); 946 i2o_msg_post(c, msg);
979 947
980 /* Wait for a reply */ 948 /* Wait for a reply */
981 timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ; 949 timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ;
@@ -1002,7 +970,7 @@ int i2o_status_get(struct i2o_controller *c)
1002 * The HRT contains information about possible hidden devices but is 970 * The HRT contains information about possible hidden devices but is
1003 * mostly useless to us. 971 * mostly useless to us.
1004 * 972 *
1005 * Returns 0 on success or negativer error code on failure. 973 * Returns 0 on success or negative error code on failure.
1006 */ 974 */
1007static int i2o_hrt_get(struct i2o_controller *c) 975static int i2o_hrt_get(struct i2o_controller *c)
1008{ 976{
@@ -1013,20 +981,20 @@ static int i2o_hrt_get(struct i2o_controller *c)
1013 struct device *dev = &c->pdev->dev; 981 struct device *dev = &c->pdev->dev;
1014 982
1015 for (i = 0; i < I2O_HRT_GET_TRIES; i++) { 983 for (i = 0; i < I2O_HRT_GET_TRIES; i++) {
1016 struct i2o_message __iomem *msg; 984 struct i2o_message *msg;
1017 u32 m;
1018 985
1019 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 986 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
1020 if (m == I2O_QUEUE_EMPTY) 987 if (IS_ERR(msg))
1021 return -ETIMEDOUT; 988 return PTR_ERR(msg);
1022 989
1023 writel(SIX_WORD_MSG_SIZE | SGL_OFFSET_4, &msg->u.head[0]); 990 msg->u.head[0] = cpu_to_le32(SIX_WORD_MSG_SIZE | SGL_OFFSET_4);
1024 writel(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 | ADAPTER_TID, 991 msg->u.head[1] =
1025 &msg->u.head[1]); 992 cpu_to_le32(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 |
1026 writel(0xd0000000 | c->hrt.len, &msg->body[0]); 993 ADAPTER_TID);
1027 writel(c->hrt.phys, &msg->body[1]); 994 msg->body[0] = cpu_to_le32(0xd0000000 | c->hrt.len);
995 msg->body[1] = cpu_to_le32(c->hrt.phys);
1028 996
1029 rc = i2o_msg_post_wait_mem(c, m, 20, &c->hrt); 997 rc = i2o_msg_post_wait_mem(c, msg, 20, &c->hrt);
1030 998
1031 if (rc < 0) { 999 if (rc < 0) {
1032 osm_err("%s: Unable to get HRT (status=%#x)\n", c->name, 1000 osm_err("%s: Unable to get HRT (status=%#x)\n", c->name,
@@ -1051,15 +1019,6 @@ static int i2o_hrt_get(struct i2o_controller *c)
1051} 1019}
1052 1020
1053/** 1021/**
1054 * i2o_iop_free - Free the i2o_controller struct
1055 * @c: I2O controller to free
1056 */
1057void i2o_iop_free(struct i2o_controller *c)
1058{
1059 kfree(c);
1060};
1061
1062/**
1063 * i2o_iop_release - release the memory for a I2O controller 1022 * i2o_iop_release - release the memory for a I2O controller
1064 * @dev: I2O controller which should be released 1023 * @dev: I2O controller which should be released
1065 * 1024 *
@@ -1073,14 +1032,11 @@ static void i2o_iop_release(struct device *dev)
1073 i2o_iop_free(c); 1032 i2o_iop_free(c);
1074}; 1033};
1075 1034
1076/* I2O controller class */
1077static struct class *i2o_controller_class;
1078
1079/** 1035/**
1080 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct 1036 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
1081 * 1037 *
1082 * Allocate the necessary memory for a i2o_controller struct and 1038 * Allocate the necessary memory for a i2o_controller struct and
1083 * initialize the lists. 1039 * initialize the lists and message mempool.
1084 * 1040 *
1085 * Returns a pointer to the I2O controller or a negative error code on 1041 * Returns a pointer to the I2O controller or a negative error code on
1086 * failure. 1042 * failure.
@@ -1089,20 +1045,29 @@ struct i2o_controller *i2o_iop_alloc(void)
1089{ 1045{
1090 static int unit = 0; /* 0 and 1 are NULL IOP and Local Host */ 1046 static int unit = 0; /* 0 and 1 are NULL IOP and Local Host */
1091 struct i2o_controller *c; 1047 struct i2o_controller *c;
1048 char poolname[32];
1092 1049
1093 c = kmalloc(sizeof(*c), GFP_KERNEL); 1050 c = kzalloc(sizeof(*c), GFP_KERNEL);
1094 if (!c) { 1051 if (!c) {
1095 osm_err("i2o: Insufficient memory to allocate a I2O controller." 1052 osm_err("i2o: Insufficient memory to allocate a I2O controller."
1096 "\n"); 1053 "\n");
1097 return ERR_PTR(-ENOMEM); 1054 return ERR_PTR(-ENOMEM);
1098 } 1055 }
1099 memset(c, 0, sizeof(*c)); 1056
1057 c->unit = unit++;
1058 sprintf(c->name, "iop%d", c->unit);
1059
1060 snprintf(poolname, sizeof(poolname), "i2o_%s_msg_inpool", c->name);
1061 if (i2o_pool_alloc
1062 (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4,
1063 I2O_MSG_INPOOL_MIN)) {
1064 kfree(c);
1065 return ERR_PTR(-ENOMEM);
1066 };
1100 1067
1101 INIT_LIST_HEAD(&c->devices); 1068 INIT_LIST_HEAD(&c->devices);
1102 spin_lock_init(&c->lock); 1069 spin_lock_init(&c->lock);
1103 init_MUTEX(&c->lct_lock); 1070 init_MUTEX(&c->lct_lock);
1104 c->unit = unit++;
1105 sprintf(c->name, "iop%d", c->unit);
1106 1071
1107 device_initialize(&c->device); 1072 device_initialize(&c->device);
1108 1073
@@ -1137,36 +1102,29 @@ int i2o_iop_add(struct i2o_controller *c)
1137 goto iop_reset; 1102 goto iop_reset;
1138 } 1103 }
1139 1104
1140 c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0),
1141 &c->device, "iop%d", c->unit);
1142 if (IS_ERR(c->classdev)) {
1143 osm_err("%s: could not add controller class\n", c->name);
1144 goto device_del;
1145 }
1146
1147 osm_info("%s: Activating I2O controller...\n", c->name); 1105 osm_info("%s: Activating I2O controller...\n", c->name);
1148 osm_info("%s: This may take a few minutes if there are many devices\n", 1106 osm_info("%s: This may take a few minutes if there are many devices\n",
1149 c->name); 1107 c->name);
1150 1108
1151 if ((rc = i2o_iop_activate(c))) { 1109 if ((rc = i2o_iop_activate(c))) {
1152 osm_err("%s: could not activate controller\n", c->name); 1110 osm_err("%s: could not activate controller\n", c->name);
1153 goto class_del; 1111 goto device_del;
1154 } 1112 }
1155 1113
1156 osm_debug("%s: building sys table...\n", c->name); 1114 osm_debug("%s: building sys table...\n", c->name);
1157 1115
1158 if ((rc = i2o_systab_build())) 1116 if ((rc = i2o_systab_build()))
1159 goto class_del; 1117 goto device_del;
1160 1118
1161 osm_debug("%s: online controller...\n", c->name); 1119 osm_debug("%s: online controller...\n", c->name);
1162 1120
1163 if ((rc = i2o_iop_online(c))) 1121 if ((rc = i2o_iop_online(c)))
1164 goto class_del; 1122 goto device_del;
1165 1123
1166 osm_debug("%s: getting LCT...\n", c->name); 1124 osm_debug("%s: getting LCT...\n", c->name);
1167 1125
1168 if ((rc = i2o_exec_lct_get(c))) 1126 if ((rc = i2o_exec_lct_get(c)))
1169 goto class_del; 1127 goto device_del;
1170 1128
1171 list_add(&c->list, &i2o_controllers); 1129 list_add(&c->list, &i2o_controllers);
1172 1130
@@ -1176,9 +1134,6 @@ int i2o_iop_add(struct i2o_controller *c)
1176 1134
1177 return 0; 1135 return 0;
1178 1136
1179 class_del:
1180 class_device_unregister(c->classdev);
1181
1182 device_del: 1137 device_del:
1183 device_del(&c->device); 1138 device_del(&c->device);
1184 1139
@@ -1199,28 +1154,27 @@ int i2o_iop_add(struct i2o_controller *c)
1199 * is waited for, or expected. If you do not want further notifications, 1154 * is waited for, or expected. If you do not want further notifications,
1200 * call the i2o_event_register again with a evt_mask of 0. 1155 * call the i2o_event_register again with a evt_mask of 0.
1201 * 1156 *
1202 * Returns 0 on success or -ETIMEDOUT if no message could be fetched for 1157 * Returns 0 on success or negative error code on failure.
1203 * sending the request.
1204 */ 1158 */
1205int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv, 1159int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv,
1206 int tcntxt, u32 evt_mask) 1160 int tcntxt, u32 evt_mask)
1207{ 1161{
1208 struct i2o_controller *c = dev->iop; 1162 struct i2o_controller *c = dev->iop;
1209 struct i2o_message __iomem *msg; 1163 struct i2o_message *msg;
1210 u32 m;
1211 1164
1212 m = i2o_msg_get_wait(c, &msg, I2O_TIMEOUT_MESSAGE_GET); 1165 msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
1213 if (m == I2O_QUEUE_EMPTY) 1166 if (IS_ERR(msg))
1214 return -ETIMEDOUT; 1167 return PTR_ERR(msg);
1215 1168
1216 writel(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0, &msg->u.head[0]); 1169 msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
1217 writel(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->lct_data. 1170 msg->u.head[1] =
1218 tid, &msg->u.head[1]); 1171 cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->
1219 writel(drv->context, &msg->u.s.icntxt); 1172 lct_data.tid);
1220 writel(tcntxt, &msg->u.s.tcntxt); 1173 msg->u.s.icntxt = cpu_to_le32(drv->context);
1221 writel(evt_mask, &msg->body[0]); 1174 msg->u.s.tcntxt = cpu_to_le32(tcntxt);
1175 msg->body[0] = cpu_to_le32(evt_mask);
1222 1176
1223 i2o_msg_post(c, m); 1177 i2o_msg_post(c, msg);
1224 1178
1225 return 0; 1179 return 0;
1226}; 1180};
@@ -1239,14 +1193,8 @@ static int __init i2o_iop_init(void)
1239 1193
1240 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); 1194 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
1241 1195
1242 i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
1243 if (IS_ERR(i2o_controller_class)) {
1244 osm_err("can't register class i2o_controller\n");
1245 goto exit;
1246 }
1247
1248 if ((rc = i2o_driver_init())) 1196 if ((rc = i2o_driver_init()))
1249 goto class_exit; 1197 goto exit;
1250 1198
1251 if ((rc = i2o_exec_init())) 1199 if ((rc = i2o_exec_init()))
1252 goto driver_exit; 1200 goto driver_exit;
@@ -1262,9 +1210,6 @@ static int __init i2o_iop_init(void)
1262 driver_exit: 1210 driver_exit:
1263 i2o_driver_exit(); 1211 i2o_driver_exit();
1264 1212
1265 class_exit:
1266 class_destroy(i2o_controller_class);
1267
1268 exit: 1213 exit:
1269 return rc; 1214 return rc;
1270} 1215}
@@ -1279,7 +1224,6 @@ static void __exit i2o_iop_exit(void)
1279 i2o_pci_exit(); 1224 i2o_pci_exit();
1280 i2o_exec_exit(); 1225 i2o_exec_exit();
1281 i2o_driver_exit(); 1226 i2o_driver_exit();
1282 class_destroy(i2o_controller_class);
1283}; 1227};
1284 1228
1285module_init(i2o_iop_init); 1229module_init(i2o_iop_init);
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 81ef306cb124..c5b656cdea7c 100644
--- a/drivers/message/i2o/pci.c
+++ b/drivers/message/i2o/pci.c
@@ -303,6 +303,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
303 struct i2o_controller *c; 303 struct i2o_controller *c;
304 int rc; 304 int rc;
305 struct pci_dev *i960 = NULL; 305 struct pci_dev *i960 = NULL;
306 int pci_dev_busy = 0;
306 307
307 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n"); 308 printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
308 309
@@ -338,7 +339,7 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
338 pci_name(pdev)); 339 pci_name(pdev));
339 340
340 c->pdev = pdev; 341 c->pdev = pdev;
341 c->device.parent = get_device(&pdev->dev); 342 c->device.parent = &pdev->dev;
342 343
343 /* Cards that fall apart if you hit them with large I/O loads... */ 344 /* Cards that fall apart if you hit them with large I/O loads... */
344 if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) { 345 if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) {
@@ -395,6 +396,8 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
395 if ((rc = i2o_pci_alloc(c))) { 396 if ((rc = i2o_pci_alloc(c))) {
396 printk(KERN_ERR "%s: DMA / IO allocation for I2O controller " 397 printk(KERN_ERR "%s: DMA / IO allocation for I2O controller "
397 " failed\n", c->name); 398 " failed\n", c->name);
399 if (rc == -ENODEV)
400 pci_dev_busy = 1;
398 goto free_controller; 401 goto free_controller;
399 } 402 }
400 403
@@ -407,8 +410,6 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
407 if ((rc = i2o_iop_add(c))) 410 if ((rc = i2o_iop_add(c)))
408 goto uninstall; 411 goto uninstall;
409 412
410 get_device(&c->device);
411
412 if (i960) 413 if (i960)
413 pci_write_config_word(i960, 0x42, 0x03ff); 414 pci_write_config_word(i960, 0x42, 0x03ff);
414 415
@@ -421,11 +422,11 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
421 i2o_pci_free(c); 422 i2o_pci_free(c);
422 423
423 free_controller: 424 free_controller:
424 put_device(c->device.parent);
425 i2o_iop_free(c); 425 i2o_iop_free(c);
426 426
427 disable: 427 disable:
428 pci_disable_device(pdev); 428 if (!pci_dev_busy)
429 pci_disable_device(pdev);
429 430
430 return rc; 431 return rc;
431} 432}
@@ -450,7 +451,6 @@ static void __devexit i2o_pci_remove(struct pci_dev *pdev)
450 451
451 printk(KERN_INFO "%s: Controller removed.\n", c->name); 452 printk(KERN_INFO "%s: Controller removed.\n", c->name);
452 453
453 put_device(c->device.parent);
454 put_device(&c->device); 454 put_device(&c->device);
455}; 455};
456 456
@@ -479,4 +479,5 @@ void __exit i2o_pci_exit(void)
479{ 479{
480 pci_unregister_driver(&i2o_pci_driver); 480 pci_unregister_driver(&i2o_pci_driver);
481}; 481};
482
482MODULE_DEVICE_TABLE(pci, i2o_pci_ids); 483MODULE_DEVICE_TABLE(pci, i2o_pci_ids);
diff --git a/drivers/mfd/ucb1x00-ts.c b/drivers/mfd/ucb1x00-ts.c
index a984c0efabf0..551061c2eadf 100644
--- a/drivers/mfd/ucb1x00-ts.c
+++ b/drivers/mfd/ucb1x00-ts.c
@@ -59,16 +59,18 @@ static int adcsync;
59 59
60static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y) 60static inline void ucb1x00_ts_evt_add(struct ucb1x00_ts *ts, u16 pressure, u16 x, u16 y)
61{ 61{
62 input_report_abs(ts->idev, ABS_X, x); 62 struct input_dev *idev = ts->idev;
63 input_report_abs(ts->idev, ABS_Y, y); 63 input_report_abs(idev, ABS_X, x);
64 input_report_abs(ts->idev, ABS_PRESSURE, pressure); 64 input_report_abs(idev, ABS_Y, y);
65 input_sync(ts->idev); 65 input_report_abs(idev, ABS_PRESSURE, pressure);
66 input_sync(idev);
66} 67}
67 68
68static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts) 69static inline void ucb1x00_ts_event_release(struct ucb1x00_ts *ts)
69{ 70{
70 input_report_abs(ts->idev, ABS_PRESSURE, 0); 71 struct input_dev *idev = ts->idev;
71 input_sync(ts->idev); 72 input_report_abs(idev, ABS_PRESSURE, 0);
73 input_sync(idev);
72} 74}
73 75
74/* 76/*
@@ -297,7 +299,7 @@ static void ucb1x00_ts_irq(int idx, void *id)
297 299
298static int ucb1x00_ts_open(struct input_dev *idev) 300static int ucb1x00_ts_open(struct input_dev *idev)
299{ 301{
300 struct ucb1x00_ts *ts = (struct ucb1x00_ts *)idev; 302 struct ucb1x00_ts *ts = idev->private;
301 int ret = 0; 303 int ret = 0;
302 304
303 BUG_ON(ts->rtask); 305 BUG_ON(ts->rtask);
@@ -334,7 +336,7 @@ static int ucb1x00_ts_open(struct input_dev *idev)
334 */ 336 */
335static void ucb1x00_ts_close(struct input_dev *idev) 337static void ucb1x00_ts_close(struct input_dev *idev)
336{ 338{
337 struct ucb1x00_ts *ts = (struct ucb1x00_ts *)idev; 339 struct ucb1x00_ts *ts = idev->private;
338 340
339 if (ts->rtask) 341 if (ts->rtask)
340 kthread_stop(ts->rtask); 342 kthread_stop(ts->rtask);
@@ -386,6 +388,7 @@ static int ucb1x00_ts_add(struct ucb1x00_dev *dev)
386 ts->ucb = dev->ucb; 388 ts->ucb = dev->ucb;
387 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC; 389 ts->adcsync = adcsync ? UCB_SYNC : UCB_NOSYNC;
388 390
391 ts->idev->private = ts;
389 ts->idev->name = "Touchscreen panel"; 392 ts->idev->name = "Touchscreen panel";
390 ts->idev->id.product = ts->ucb->id; 393 ts->idev->id.product = ts->ucb->id;
391 ts->idev->open = ucb1x00_ts_open; 394 ts->idev->open = ucb1x00_ts_open;
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index d336a1d65dc7..eb41391e06e9 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -679,7 +679,15 @@ static void mmc_idle_cards(struct mmc_host *host)
679} 679}
680 680
681/* 681/*
682 * Apply power to the MMC stack. 682 * Apply power to the MMC stack. This is a two-stage process.
683 * First, we enable power to the card without the clock running.
684 * We then wait a bit for the power to stabilise. Finally,
685 * enable the bus drivers and clock to the card.
686 *
687 * We must _NOT_ enable the clock prior to power stablising.
688 *
689 * If a host does all the power sequencing itself, ignore the
690 * initial MMC_POWER_UP stage.
683 */ 691 */
684static void mmc_power_up(struct mmc_host *host) 692static void mmc_power_up(struct mmc_host *host)
685{ 693{
@@ -932,8 +940,9 @@ static void mmc_read_scrs(struct mmc_host *host)
932 940
933 sg_init_one(&sg, (u8*)card->raw_scr, 8); 941 sg_init_one(&sg, (u8*)card->raw_scr, 8);
934 942
935 err = mmc_wait_for_req(host, &mrq); 943 mmc_wait_for_req(host, &mrq);
936 if (err != MMC_ERR_NONE) { 944
945 if (cmd.error != MMC_ERR_NONE || data.error != MMC_ERR_NONE) {
937 mmc_card_set_dead(card); 946 mmc_card_set_dead(card);
938 continue; 947 continue;
939 } 948 }
diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
index d91fcf7c3178..8e380c14bf65 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -263,7 +263,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
263 */ 263 */
264 add_disk_randomness(req->rq_disk); 264 add_disk_randomness(req->rq_disk);
265 blkdev_dequeue_request(req); 265 blkdev_dequeue_request(req);
266 end_that_request_last(req); 266 end_that_request_last(req, 1);
267 } 267 }
268 spin_unlock_irq(&md->lock); 268 spin_unlock_irq(&md->lock);
269 } while (ret); 269 } while (ret);
@@ -289,7 +289,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
289 289
290 add_disk_randomness(req->rq_disk); 290 add_disk_randomness(req->rq_disk);
291 blkdev_dequeue_request(req); 291 blkdev_dequeue_request(req);
292 end_that_request_last(req); 292 end_that_request_last(req, 0);
293 spin_unlock_irq(&md->lock); 293 spin_unlock_irq(&md->lock);
294 294
295 return 0; 295 return 0;
@@ -359,7 +359,12 @@ static struct mmc_blk_data *mmc_blk_alloc(struct mmc_card *card)
359 md->block_bits = card->csd.read_blkbits; 359 md->block_bits = card->csd.read_blkbits;
360 360
361 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits); 361 blk_queue_hardsect_size(md->queue.queue, 1 << md->block_bits);
362 set_capacity(md->disk, card->csd.capacity); 362
363 /*
364 * The CSD capacity field is in units of read_blkbits.
365 * set_capacity takes units of 512 bytes.
366 */
367 set_capacity(md->disk, card->csd.capacity << (card->csd.read_blkbits - 9));
363 } 368 }
364 out: 369 out:
365 return md; 370 return md;
@@ -373,7 +378,7 @@ mmc_blk_set_blksize(struct mmc_blk_data *md, struct mmc_card *card)
373 378
374 mmc_card_claim_host(card); 379 mmc_card_claim_host(card);
375 cmd.opcode = MMC_SET_BLOCKLEN; 380 cmd.opcode = MMC_SET_BLOCKLEN;
376 cmd.arg = 1 << card->csd.read_blkbits; 381 cmd.arg = 1 << md->block_bits;
377 cmd.flags = MMC_RSP_R1; 382 cmd.flags = MMC_RSP_R1;
378 err = mmc_wait_for_cmd(card->host, &cmd, 5); 383 err = mmc_wait_for_cmd(card->host, &cmd, 5);
379 mmc_card_release_host(card); 384 mmc_card_release_host(card);
@@ -412,10 +417,9 @@ static int mmc_blk_probe(struct mmc_card *card)
412 if (err) 417 if (err)
413 goto out; 418 goto out;
414 419
415 printk(KERN_INFO "%s: %s %s %dKiB %s\n", 420 printk(KERN_INFO "%s: %s %s %luKiB %s\n",
416 md->disk->disk_name, mmc_card_id(card), mmc_card_name(card), 421 md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
417 (card->csd.capacity << card->csd.read_blkbits) / 1024, 422 get_capacity(md->disk) >> 1, mmc_blk_readonly(card)?"(ro)":"");
418 mmc_blk_readonly(card)?"(ro)":"");
419 423
420 mmc_set_drvdata(card, md); 424 mmc_set_drvdata(card, md);
421 add_disk(md->disk); 425 add_disk(md->disk);
diff --git a/drivers/mmc/mmc_sysfs.c b/drivers/mmc/mmc_sysfs.c
index 3f4a66ca9555..ec701667abfc 100644
--- a/drivers/mmc/mmc_sysfs.c
+++ b/drivers/mmc/mmc_sysfs.c
@@ -80,7 +80,7 @@ static int mmc_bus_match(struct device *dev, struct device_driver *drv)
80} 80}
81 81
82static int 82static int
83mmc_bus_hotplug(struct device *dev, char **envp, int num_envp, char *buf, 83mmc_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf,
84 int buf_size) 84 int buf_size)
85{ 85{
86 struct mmc_card *card = dev_to_mmc_card(dev); 86 struct mmc_card *card = dev_to_mmc_card(dev);
@@ -140,7 +140,7 @@ static struct bus_type mmc_bus_type = {
140 .name = "mmc", 140 .name = "mmc",
141 .dev_attrs = mmc_dev_attrs, 141 .dev_attrs = mmc_dev_attrs,
142 .match = mmc_bus_match, 142 .match = mmc_bus_match,
143 .hotplug = mmc_bus_hotplug, 143 .uevent = mmc_bus_uevent,
144 .suspend = mmc_bus_suspend, 144 .suspend = mmc_bus_suspend,
145 .resume = mmc_bus_resume, 145 .resume = mmc_bus_resume,
146}; 146};
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c
index f9db52f6bf00..04f864d238db 100644
--- a/drivers/mtd/devices/blkmtd.c
+++ b/drivers/mtd/devices/blkmtd.c
@@ -113,7 +113,7 @@ static int bi_write_complete(struct bio *bio, unsigned int bytes_done, int error
113 ClearPageUptodate(page); 113 ClearPageUptodate(page);
114 SetPageError(page); 114 SetPageError(page);
115 } 115 }
116 ClearPageDirty(page); 116 clear_page_dirty(page);
117 unlock_page(page); 117 unlock_page(page);
118 page_cache_release(page); 118 page_cache_release(page);
119 } while (bvec >= bio->bi_io_vec); 119 } while (bvec >= bio->bi_io_vec);
@@ -289,7 +289,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
289 BUG(); 289 BUG();
290 } 290 }
291 memcpy(page_address(page)+offset, buf, start_len); 291 memcpy(page_address(page)+offset, buf, start_len);
292 SetPageDirty(page); 292 set_page_dirty(page);
293 SetPageUptodate(page); 293 SetPageUptodate(page);
294 buf += start_len; 294 buf += start_len;
295 thislen = start_len; 295 thislen = start_len;
@@ -336,7 +336,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
336 } 336 }
337 pagenr++; 337 pagenr++;
338 pagecnt--; 338 pagecnt--;
339 SetPageDirty(page); 339 set_page_dirty(page);
340 SetPageUptodate(page); 340 SetPageUptodate(page);
341 pagesc--; 341 pagesc--;
342 thislen += PAGE_SIZE; 342 thislen += PAGE_SIZE;
@@ -357,7 +357,7 @@ static int write_pages(struct blkmtd_dev *dev, const u_char *buf, loff_t to,
357 BUG(); 357 BUG();
358 } 358 }
359 memcpy(page_address(page), buf, end_len); 359 memcpy(page_address(page), buf, end_len);
360 SetPageDirty(page); 360 set_page_dirty(page);
361 SetPageUptodate(page); 361 SetPageUptodate(page);
362 DEBUG(3, "blkmtd: write: writing out partial end\n"); 362 DEBUG(3, "blkmtd: write: writing out partial end\n");
363 thislen += end_len; 363 thislen += end_len;
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 452ccd5037c3..b9b77cf39a18 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -62,7 +62,7 @@ config MTD_PHYSMAP_BANKWIDTH
62 62
63config MTD_SUN_UFLASH 63config MTD_SUN_UFLASH
64 tristate "Sun Microsystems userflash support" 64 tristate "Sun Microsystems userflash support"
65 depends on (SPARC32 || SPARC64) && MTD_CFI 65 depends on SPARC && MTD_CFI
66 help 66 help
67 This provides a 'mapping' driver which supports the way in 67 This provides a 'mapping' driver which supports the way in
68 which user-programmable flash chips are connected on various 68 which user-programmable flash chips are connected on various
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index af24216a0626..f0f8916da7ad 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -66,9 +66,6 @@ struct pcmciamtd_dev {
66}; 66};
67 67
68 68
69static dev_info_t dev_info = "pcmciamtd";
70static dev_link_t *dev_list;
71
72/* Module parameters */ 69/* Module parameters */
73 70
74/* 2 = do 16-bit transfers, 1 = do 8-bit transfers */ 71/* 2 = do 16-bit transfers, 1 = do 8-bit transfers */
@@ -691,55 +688,21 @@ static void pcmciamtd_config(dev_link_t *link)
691} 688}
692 689
693 690
694/* The card status event handler. Mostly, this schedules other 691static int pcmciamtd_suspend(struct pcmcia_device *dev)
695 * stuff to run after an event is received. A CARD_REMOVAL event 692{
696 * also sets some flags to discourage the driver from trying 693 DEBUG(2, "EVENT_PM_RESUME");
697 * to talk to the card any more. 694
698 */ 695 /* get_lock(link); */
696
697 return 0;
698}
699 699
700static int pcmciamtd_event(event_t event, int priority, 700static int pcmciamtd_resume(struct pcmcia_device *dev)
701 event_callback_args_t *args)
702{ 701{
703 dev_link_t *link = args->client_data; 702 DEBUG(2, "EVENT_PM_SUSPEND");
704 703
705 DEBUG(1, "event=0x%06x", event); 704 /* free_lock(link); */
706 switch (event) { 705
707 case CS_EVENT_CARD_REMOVAL:
708 DEBUG(2, "EVENT_CARD_REMOVAL");
709 link->state &= ~DEV_PRESENT;
710 if (link->state & DEV_CONFIG) {
711 struct pcmciamtd_dev *dev = link->priv;
712 if(dev->mtd_info) {
713 del_mtd_device(dev->mtd_info);
714 info("mtd%d: Removed", dev->mtd_info->index);
715 }
716 pcmciamtd_release(link);
717 }
718 break;
719 case CS_EVENT_CARD_INSERTION:
720 DEBUG(2, "EVENT_CARD_INSERTION");
721 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
722 pcmciamtd_config(link);
723 break;
724 case CS_EVENT_PM_SUSPEND:
725 DEBUG(2, "EVENT_PM_SUSPEND");
726 link->state |= DEV_SUSPEND;
727 /* Fall through... */
728 case CS_EVENT_RESET_PHYSICAL:
729 DEBUG(2, "EVENT_RESET_PHYSICAL");
730 /* get_lock(link); */
731 break;
732 case CS_EVENT_PM_RESUME:
733 DEBUG(2, "EVENT_PM_RESUME");
734 link->state &= ~DEV_SUSPEND;
735 /* Fall through... */
736 case CS_EVENT_CARD_RESET:
737 DEBUG(2, "EVENT_CARD_RESET");
738 /* free_lock(link); */
739 break;
740 default:
741 DEBUG(2, "Unknown event %d", event);
742 }
743 return 0; 706 return 0;
744} 707}
745 708
@@ -750,23 +713,21 @@ static int pcmciamtd_event(event_t event, int priority,
750 * when the device is released. 713 * when the device is released.
751 */ 714 */
752 715
753static void pcmciamtd_detach(dev_link_t *link) 716static void pcmciamtd_detach(struct pcmcia_device *p_dev)
754{ 717{
718 dev_link_t *link = dev_to_instance(p_dev);
719
755 DEBUG(3, "link=0x%p", link); 720 DEBUG(3, "link=0x%p", link);
756 721
757 if(link->state & DEV_CONFIG) { 722 if(link->state & DEV_CONFIG) {
758 pcmciamtd_release(link); 723 struct pcmciamtd_dev *dev = link->priv;
759 } 724 if(dev->mtd_info) {
725 del_mtd_device(dev->mtd_info);
726 info("mtd%d: Removed", dev->mtd_info->index);
727 }
760 728
761 if (link->handle) { 729 pcmciamtd_release(link);
762 int ret;
763 DEBUG(2, "Deregistering with card services");
764 ret = pcmcia_deregister_client(link->handle);
765 if (ret != CS_SUCCESS)
766 cs_error(link->handle, DeregisterClient, ret);
767 } 730 }
768
769 link->state |= DEV_STALE_LINK;
770} 731}
771 732
772 733
@@ -775,16 +736,14 @@ static void pcmciamtd_detach(dev_link_t *link)
775 * with Card Services. 736 * with Card Services.
776 */ 737 */
777 738
778static dev_link_t *pcmciamtd_attach(void) 739static int pcmciamtd_attach(struct pcmcia_device *p_dev)
779{ 740{
780 struct pcmciamtd_dev *dev; 741 struct pcmciamtd_dev *dev;
781 dev_link_t *link; 742 dev_link_t *link;
782 client_reg_t client_reg;
783 int ret;
784 743
785 /* Create new memory card device */ 744 /* Create new memory card device */
786 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 745 dev = kmalloc(sizeof(*dev), GFP_KERNEL);
787 if (!dev) return NULL; 746 if (!dev) return -ENOMEM;
788 DEBUG(1, "dev=0x%p", dev); 747 DEBUG(1, "dev=0x%p", dev);
789 748
790 memset(dev, 0, sizeof(*dev)); 749 memset(dev, 0, sizeof(*dev));
@@ -794,22 +753,14 @@ static dev_link_t *pcmciamtd_attach(void)
794 link->conf.Attributes = 0; 753 link->conf.Attributes = 0;
795 link->conf.IntType = INT_MEMORY; 754 link->conf.IntType = INT_MEMORY;
796 755
797 link->next = dev_list; 756 link->next = NULL;
798 dev_list = link; 757 link->handle = p_dev;
799 758 p_dev->instance = link;
800 /* Register with Card Services */ 759
801 client_reg.dev_info = &dev_info; 760 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
802 client_reg.Version = 0x0210; 761 pcmciamtd_config(link);
803 client_reg.event_callback_args.client_data = link; 762
804 DEBUG(2, "Calling RegisterClient"); 763 return 0;
805 ret = pcmcia_register_client(&link->handle, &client_reg);
806 if (ret != 0) {
807 cs_error(link->handle, RegisterClient, ret);
808 pcmciamtd_detach(link);
809 return NULL;
810 }
811 DEBUG(2, "link = %p", link);
812 return link;
813} 764}
814 765
815static struct pcmcia_device_id pcmciamtd_ids[] = { 766static struct pcmcia_device_id pcmciamtd_ids[] = {
@@ -843,11 +794,12 @@ static struct pcmcia_driver pcmciamtd_driver = {
843 .drv = { 794 .drv = {
844 .name = "pcmciamtd" 795 .name = "pcmciamtd"
845 }, 796 },
846 .attach = pcmciamtd_attach, 797 .probe = pcmciamtd_attach,
847 .event = pcmciamtd_event, 798 .remove = pcmciamtd_detach,
848 .detach = pcmciamtd_detach,
849 .owner = THIS_MODULE, 799 .owner = THIS_MODULE,
850 .id_table = pcmciamtd_ids, 800 .id_table = pcmciamtd_ids,
801 .suspend = pcmciamtd_suspend,
802 .resume = pcmciamtd_resume,
851}; 803};
852 804
853 805
@@ -875,7 +827,6 @@ static void __exit exit_pcmciamtd(void)
875{ 827{
876 DEBUG(1, DRIVER_DESC " unloading"); 828 DEBUG(1, DRIVER_DESC " unloading");
877 pcmcia_unregister_driver(&pcmciamtd_driver); 829 pcmcia_unregister_driver(&pcmciamtd_driver);
878 BUG_ON(dev_list != NULL);
879} 830}
880 831
881module_init(init_pcmciamtd); 832module_init(init_pcmciamtd);
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c
index 48cce431f89f..45c077d0f063 100644
--- a/drivers/mtd/onenand/generic.c
+++ b/drivers/mtd/onenand/generic.c
@@ -12,9 +12,9 @@
12 * This is a device driver for the OneNAND flash for generic boards. 12 * This is a device driver for the OneNAND flash for generic boards.
13 */ 13 */
14 14
15#include <linux/device.h>
16#include <linux/module.h> 15#include <linux/module.h>
17#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/mtd/mtd.h> 18#include <linux/mtd/mtd.h>
19#include <linux/mtd/onenand.h> 19#include <linux/mtd/onenand.h>
20#include <linux/mtd/partitions.h> 20#include <linux/mtd/partitions.h>
@@ -39,7 +39,7 @@ static int __devinit generic_onenand_probe(struct device *dev)
39{ 39{
40 struct onenand_info *info; 40 struct onenand_info *info;
41 struct platform_device *pdev = to_platform_device(dev); 41 struct platform_device *pdev = to_platform_device(dev);
42 struct onenand_platform_data *pdata = pdev->dev.platform_data; 42 struct flash_platform_data *pdata = pdev->dev.platform_data;
43 struct resource *res = pdev->resource; 43 struct resource *res = pdev->resource;
44 unsigned long size = res->end - res->start + 1; 44 unsigned long size = res->end - res->start + 1;
45 int err; 45 int err;
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index f67d5d6eb9a6..a53a73fc2a5a 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -940,7 +940,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
940 u_char *eccbuf, struct nand_oobinfo *oobsel) 940 u_char *eccbuf, struct nand_oobinfo *oobsel)
941{ 941{
942 struct onenand_chip *this = mtd->priv; 942 struct onenand_chip *this = mtd->priv;
943 unsigned char buffer[MAX_ONENAND_PAGESIZE], *pbuf; 943 unsigned char *pbuf;
944 size_t total_len, len; 944 size_t total_len, len;
945 int i, written = 0; 945 int i, written = 0;
946 int ret = 0; 946 int ret = 0;
@@ -975,7 +975,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
975 /* Loop until all keve's data has been written */ 975 /* Loop until all keve's data has been written */
976 len = 0; 976 len = 0;
977 while (count) { 977 while (count) {
978 pbuf = buffer; 978 pbuf = this->page_buf;
979 /* 979 /*
980 * If the given tuple is >= pagesize then 980 * If the given tuple is >= pagesize then
981 * write it out from the iov 981 * write it out from the iov
@@ -995,7 +995,7 @@ static int onenand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs,
995 int cnt = 0, thislen; 995 int cnt = 0, thislen;
996 while (cnt < mtd->oobblock) { 996 while (cnt < mtd->oobblock) {
997 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len); 997 thislen = min_t(int, mtd->oobblock - cnt, vecs->iov_len - len);
998 memcpy(buffer + cnt, vecs->iov_base + len, thislen); 998 memcpy(this->page_buf + cnt, vecs->iov_base + len, thislen);
999 cnt += thislen; 999 cnt += thislen;
1000 len += thislen; 1000 len += thislen;
1001 1001
@@ -1296,6 +1296,12 @@ static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1296 1296
1297 /* Block lock scheme */ 1297 /* Block lock scheme */
1298 for (block = start; block < end; block++) { 1298 for (block = start; block < end; block++) {
1299 /* Set block address */
1300 value = onenand_block_address(this, block);
1301 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
1302 /* Select DataRAM for DDP */
1303 value = onenand_bufferram_address(this, block);
1304 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2);
1299 /* Set start block address */ 1305 /* Set start block address */
1300 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS); 1306 this->write_word(block, this->base + ONENAND_REG_START_BLOCK_ADDRESS);
1301 /* Write unlock command */ 1307 /* Write unlock command */
@@ -1309,10 +1315,6 @@ static int onenand_unlock(struct mtd_info *mtd, loff_t ofs, size_t len)
1309 & ONENAND_CTRL_ONGO) 1315 & ONENAND_CTRL_ONGO)
1310 continue; 1316 continue;
1311 1317
1312 /* Set block address for read block status */
1313 value = onenand_block_address(this, block);
1314 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS1);
1315
1316 /* Check lock status */ 1318 /* Check lock status */
1317 status = this->read_word(this->base + ONENAND_REG_WP_STATUS); 1319 status = this->read_word(this->base + ONENAND_REG_WP_STATUS);
1318 if (!(status & ONENAND_WP_US)) 1320 if (!(status & ONENAND_WP_US))
@@ -1346,7 +1348,6 @@ static void onenand_print_device_info(int device)
1346 1348
1347static const struct onenand_manufacturers onenand_manuf_ids[] = { 1349static const struct onenand_manufacturers onenand_manuf_ids[] = {
1348 {ONENAND_MFR_SAMSUNG, "Samsung"}, 1350 {ONENAND_MFR_SAMSUNG, "Samsung"},
1349 {ONENAND_MFR_UNKNOWN, "Unknown"}
1350}; 1351};
1351 1352
1352/** 1353/**
@@ -1357,17 +1358,22 @@ static const struct onenand_manufacturers onenand_manuf_ids[] = {
1357 */ 1358 */
1358static int onenand_check_maf(int manuf) 1359static int onenand_check_maf(int manuf)
1359{ 1360{
1361 int size = ARRAY_SIZE(onenand_manuf_ids);
1362 char *name;
1360 int i; 1363 int i;
1361 1364
1362 for (i = 0; onenand_manuf_ids[i].id; i++) { 1365 for (i = 0; i < size; i++)
1363 if (manuf == onenand_manuf_ids[i].id) 1366 if (manuf == onenand_manuf_ids[i].id)
1364 break; 1367 break;
1365 }
1366 1368
1367 printk(KERN_DEBUG "OneNAND Manufacturer: %s (0x%0x)\n", 1369 if (i < size)
1368 onenand_manuf_ids[i].name, manuf); 1370 name = onenand_manuf_ids[i].name;
1371 else
1372 name = "Unknown";
1373
1374 printk(KERN_DEBUG "OneNAND Manufacturer: %s (0x%0x)\n", name, manuf);
1369 1375
1370 return (i != ONENAND_MFR_UNKNOWN); 1376 return (i == size);
1371} 1377}
1372 1378
1373/** 1379/**
@@ -1513,6 +1519,18 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1513 this->read_bufferram = onenand_sync_read_bufferram; 1519 this->read_bufferram = onenand_sync_read_bufferram;
1514 } 1520 }
1515 1521
1522 /* Allocate buffers, if necessary */
1523 if (!this->page_buf) {
1524 size_t len;
1525 len = mtd->oobblock + mtd->oobsize;
1526 this->page_buf = kmalloc(len, GFP_KERNEL);
1527 if (!this->page_buf) {
1528 printk(KERN_ERR "onenand_scan(): Can't allocate page_buf\n");
1529 return -ENOMEM;
1530 }
1531 this->options |= ONENAND_PAGEBUF_ALLOC;
1532 }
1533
1516 this->state = FL_READY; 1534 this->state = FL_READY;
1517 init_waitqueue_head(&this->wq); 1535 init_waitqueue_head(&this->wq);
1518 spin_lock_init(&this->chip_lock); 1536 spin_lock_init(&this->chip_lock);
@@ -1574,12 +1592,21 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
1574 */ 1592 */
1575void onenand_release(struct mtd_info *mtd) 1593void onenand_release(struct mtd_info *mtd)
1576{ 1594{
1595 struct onenand_chip *this = mtd->priv;
1596
1577#ifdef CONFIG_MTD_PARTITIONS 1597#ifdef CONFIG_MTD_PARTITIONS
1578 /* Deregister partitions */ 1598 /* Deregister partitions */
1579 del_mtd_partitions (mtd); 1599 del_mtd_partitions (mtd);
1580#endif 1600#endif
1581 /* Deregister the device */ 1601 /* Deregister the device */
1582 del_mtd_device (mtd); 1602 del_mtd_device (mtd);
1603
1604 /* Free bad block table memory, if allocated */
1605 if (this->bbm)
1606 kfree(this->bbm);
1607 /* Buffer allocated by onenand_scan */
1608 if (this->options & ONENAND_PAGEBUF_ALLOC)
1609 kfree(this->page_buf);
1583} 1610}
1584 1611
1585EXPORT_SYMBOL_GPL(onenand_scan); 1612EXPORT_SYMBOL_GPL(onenand_scan);
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c
index f40190f499e1..4510d3361eaa 100644
--- a/drivers/mtd/onenand/onenand_bbt.c
+++ b/drivers/mtd/onenand/onenand_bbt.c
@@ -118,10 +118,10 @@ static int create_bbt(struct mtd_info *mtd, uint8_t *buf, struct nand_bbt_descr
118 */ 118 */
119static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd) 119static inline int onenand_memory_bbt (struct mtd_info *mtd, struct nand_bbt_descr *bd)
120{ 120{
121 unsigned char data_buf[MAX_ONENAND_PAGESIZE]; 121 struct onenand_chip *this = mtd->priv;
122 122
123 bd->options &= ~NAND_BBT_SCANEMPTY; 123 bd->options &= ~NAND_BBT_SCANEMPTY;
124 return create_bbt(mtd, data_buf, bd, -1); 124 return create_bbt(mtd, this->page_buf, bd, -1);
125} 125}
126 126
127/** 127/**
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index 30bee11c48bd..d2102a27d307 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -586,16 +586,16 @@ struct rtl8139_private {
586 dma_addr_t tx_bufs_dma; 586 dma_addr_t tx_bufs_dma;
587 signed char phys[4]; /* MII device addresses. */ 587 signed char phys[4]; /* MII device addresses. */
588 char twistie, twist_row, twist_col; /* Twister tune state. */ 588 char twistie, twist_row, twist_col; /* Twister tune state. */
589 unsigned int default_port:4; /* Last dev->if_port value. */ 589 unsigned int default_port : 4; /* Last dev->if_port value. */
590 unsigned int have_thread : 1;
590 spinlock_t lock; 591 spinlock_t lock;
591 spinlock_t rx_lock; 592 spinlock_t rx_lock;
592 chip_t chipset; 593 chip_t chipset;
593 pid_t thr_pid;
594 wait_queue_head_t thr_wait;
595 struct completion thr_exited;
596 u32 rx_config; 594 u32 rx_config;
597 struct rtl_extra_stats xstats; 595 struct rtl_extra_stats xstats;
598 int time_to_die; 596
597 struct work_struct thread;
598
599 struct mii_if_info mii; 599 struct mii_if_info mii;
600 unsigned int regs_len; 600 unsigned int regs_len;
601 unsigned long fifo_copy_timeout; 601 unsigned long fifo_copy_timeout;
@@ -620,7 +620,7 @@ static int rtl8139_open (struct net_device *dev);
620static int mdio_read (struct net_device *dev, int phy_id, int location); 620static int mdio_read (struct net_device *dev, int phy_id, int location);
621static void mdio_write (struct net_device *dev, int phy_id, int location, 621static void mdio_write (struct net_device *dev, int phy_id, int location,
622 int val); 622 int val);
623static void rtl8139_start_thread(struct net_device *dev); 623static void rtl8139_start_thread(struct rtl8139_private *tp);
624static void rtl8139_tx_timeout (struct net_device *dev); 624static void rtl8139_tx_timeout (struct net_device *dev);
625static void rtl8139_init_ring (struct net_device *dev); 625static void rtl8139_init_ring (struct net_device *dev);
626static int rtl8139_start_xmit (struct sk_buff *skb, 626static int rtl8139_start_xmit (struct sk_buff *skb,
@@ -637,6 +637,7 @@ static struct net_device_stats *rtl8139_get_stats (struct net_device *dev);
637static void rtl8139_set_rx_mode (struct net_device *dev); 637static void rtl8139_set_rx_mode (struct net_device *dev);
638static void __set_rx_mode (struct net_device *dev); 638static void __set_rx_mode (struct net_device *dev);
639static void rtl8139_hw_start (struct net_device *dev); 639static void rtl8139_hw_start (struct net_device *dev);
640static void rtl8139_thread (void *_data);
640static struct ethtool_ops rtl8139_ethtool_ops; 641static struct ethtool_ops rtl8139_ethtool_ops;
641 642
642/* write MMIO register, with flush */ 643/* write MMIO register, with flush */
@@ -1007,8 +1008,7 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
1007 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1)); 1008 (debug < 0 ? RTL8139_DEF_MSG_ENABLE : ((1 << debug) - 1));
1008 spin_lock_init (&tp->lock); 1009 spin_lock_init (&tp->lock);
1009 spin_lock_init (&tp->rx_lock); 1010 spin_lock_init (&tp->rx_lock);
1010 init_waitqueue_head (&tp->thr_wait); 1011 INIT_WORK(&tp->thread, rtl8139_thread, dev);
1011 init_completion (&tp->thr_exited);
1012 tp->mii.dev = dev; 1012 tp->mii.dev = dev;
1013 tp->mii.mdio_read = mdio_read; 1013 tp->mii.mdio_read = mdio_read;
1014 tp->mii.mdio_write = mdio_write; 1014 tp->mii.mdio_write = mdio_write;
@@ -1345,7 +1345,7 @@ static int rtl8139_open (struct net_device *dev)
1345 dev->irq, RTL_R8 (MediaStatus), 1345 dev->irq, RTL_R8 (MediaStatus),
1346 tp->mii.full_duplex ? "full" : "half"); 1346 tp->mii.full_duplex ? "full" : "half");
1347 1347
1348 rtl8139_start_thread(dev); 1348 rtl8139_start_thread(tp);
1349 1349
1350 return 0; 1350 return 0;
1351} 1351}
@@ -1594,55 +1594,43 @@ static inline void rtl8139_thread_iter (struct net_device *dev,
1594 RTL_R8 (Config1)); 1594 RTL_R8 (Config1));
1595} 1595}
1596 1596
1597static int rtl8139_thread (void *data) 1597static void rtl8139_thread (void *_data)
1598{ 1598{
1599 struct net_device *dev = data; 1599 struct net_device *dev = _data;
1600 struct rtl8139_private *tp = netdev_priv(dev); 1600 struct rtl8139_private *tp = netdev_priv(dev);
1601 unsigned long timeout; 1601 unsigned long thr_delay;
1602
1603 daemonize("%s", dev->name);
1604 allow_signal(SIGTERM);
1605
1606 while (1) {
1607 timeout = next_tick;
1608 do {
1609 timeout = interruptible_sleep_on_timeout (&tp->thr_wait, timeout);
1610 /* make swsusp happy with our thread */
1611 try_to_freeze();
1612 } while (!signal_pending (current) && (timeout > 0));
1613
1614 if (signal_pending (current)) {
1615 flush_signals(current);
1616 }
1617 1602
1618 if (tp->time_to_die) 1603 if (rtnl_shlock_nowait() == 0) {
1619 break;
1620
1621 if (rtnl_lock_interruptible ())
1622 break;
1623 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1604 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1624 rtnl_unlock (); 1605 rtnl_unlock ();
1606
1607 thr_delay = next_tick;
1608 } else {
1609 /* unlikely race. mitigate with fast poll. */
1610 thr_delay = HZ / 2;
1625 } 1611 }
1626 1612
1627 complete_and_exit (&tp->thr_exited, 0); 1613 schedule_delayed_work(&tp->thread, thr_delay);
1628} 1614}
1629 1615
1630static void rtl8139_start_thread(struct net_device *dev) 1616static void rtl8139_start_thread(struct rtl8139_private *tp)
1631{ 1617{
1632 struct rtl8139_private *tp = netdev_priv(dev);
1633
1634 tp->thr_pid = -1;
1635 tp->twistie = 0; 1618 tp->twistie = 0;
1636 tp->time_to_die = 0;
1637 if (tp->chipset == CH_8139_K) 1619 if (tp->chipset == CH_8139_K)
1638 tp->twistie = 1; 1620 tp->twistie = 1;
1639 else if (tp->drv_flags & HAS_LNK_CHNG) 1621 else if (tp->drv_flags & HAS_LNK_CHNG)
1640 return; 1622 return;
1641 1623
1642 tp->thr_pid = kernel_thread(rtl8139_thread, dev, CLONE_FS|CLONE_FILES); 1624 tp->have_thread = 1;
1643 if (tp->thr_pid < 0) { 1625
1644 printk (KERN_WARNING "%s: unable to start kernel thread\n", 1626 schedule_delayed_work(&tp->thread, next_tick);
1645 dev->name); 1627}
1628
1629static void rtl8139_stop_thread(struct rtl8139_private *tp)
1630{
1631 if (tp->have_thread) {
1632 cancel_rearming_delayed_work(&tp->thread);
1633 tp->have_thread = 0;
1646 } 1634 }
1647} 1635}
1648 1636
@@ -2224,22 +2212,12 @@ static int rtl8139_close (struct net_device *dev)
2224{ 2212{
2225 struct rtl8139_private *tp = netdev_priv(dev); 2213 struct rtl8139_private *tp = netdev_priv(dev);
2226 void __iomem *ioaddr = tp->mmio_addr; 2214 void __iomem *ioaddr = tp->mmio_addr;
2227 int ret = 0;
2228 unsigned long flags; 2215 unsigned long flags;
2229 2216
2230 netif_stop_queue (dev); 2217 netif_stop_queue (dev);
2231 2218
2232 if (tp->thr_pid >= 0) { 2219 rtl8139_stop_thread(tp);
2233 tp->time_to_die = 1; 2220
2234 wmb();
2235 ret = kill_proc (tp->thr_pid, SIGTERM, 1);
2236 if (ret) {
2237 printk (KERN_ERR "%s: unable to signal thread\n", dev->name);
2238 return ret;
2239 }
2240 wait_for_completion (&tp->thr_exited);
2241 }
2242
2243 if (netif_msg_ifdown(tp)) 2221 if (netif_msg_ifdown(tp))
2244 printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n", 2222 printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n",
2245 dev->name, RTL_R16 (IntrStatus)); 2223 dev->name, RTL_R16 (IntrStatus));
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ebd7313d7fc1..e2fa29b612cd 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1901,6 +1901,8 @@ config E1000_NAPI
1901 1901
1902 If in doubt, say N. 1902 If in doubt, say N.
1903 1903
1904source "drivers/net/ixp2000/Kconfig"
1905
1904config MYRI_SBUS 1906config MYRI_SBUS
1905 tristate "MyriCOM Gigabit Ethernet support" 1907 tristate "MyriCOM Gigabit Ethernet support"
1906 depends on SBUS 1908 depends on SBUS
@@ -2008,7 +2010,18 @@ config SKGE
2008 2010
2009 It does not support the link failover and network management 2011 It does not support the link failover and network management
2010 features that "portable" vendor supplied sk98lin driver does. 2012 features that "portable" vendor supplied sk98lin driver does.
2011 2013
2014
2015config SKY2
2016 tristate "SysKonnect Yukon2 support (EXPERIMENTAL)"
2017 depends on PCI && EXPERIMENTAL
2018 select CRC32
2019 ---help---
2020 This driver support the Marvell Yukon 2 Gigabit Ethernet adapter.
2021
2022 To compile this driver as a module, choose M here: the module
2023 will be called sky2. This is recommended.
2024
2012config SK98LIN 2025config SK98LIN
2013 tristate "Marvell Yukon Chipset / SysKonnect SK-98xx Support" 2026 tristate "Marvell Yukon Chipset / SysKonnect SK-98xx Support"
2014 depends on PCI 2027 depends on PCI
@@ -2120,7 +2133,7 @@ config BNX2
2120 2133
2121config SPIDER_NET 2134config SPIDER_NET
2122 tristate "Spider Gigabit Ethernet driver" 2135 tristate "Spider Gigabit Ethernet driver"
2123 depends on PCI && PPC_BPA 2136 depends on PCI && PPC_CELL
2124 help 2137 help
2125 This driver supports the Gigabit Ethernet chips present on the 2138 This driver supports the Gigabit Ethernet chips present on the
2126 Cell Processor-Based Blades from IBM. 2139 Cell Processor-Based Blades from IBM.
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 4cffd34442aa..b74a7cb5bae6 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -13,7 +13,10 @@ obj-$(CONFIG_CHELSIO_T1) += chelsio/
13obj-$(CONFIG_BONDING) += bonding/ 13obj-$(CONFIG_BONDING) += bonding/
14obj-$(CONFIG_GIANFAR) += gianfar_driver.o 14obj-$(CONFIG_GIANFAR) += gianfar_driver.o
15 15
16gianfar_driver-objs := gianfar.o gianfar_ethtool.o gianfar_mii.o 16gianfar_driver-objs := gianfar.o \
17 gianfar_ethtool.o \
18 gianfar_mii.o \
19 gianfar_sysfs.o
17 20
18# 21#
19# link order important here 22# link order important here
@@ -59,6 +62,7 @@ spidernet-y += spider_net.o spider_net_ethtool.o sungem_phy.o
59obj-$(CONFIG_SPIDER_NET) += spidernet.o 62obj-$(CONFIG_SPIDER_NET) += spidernet.o
60obj-$(CONFIG_TC35815) += tc35815.o 63obj-$(CONFIG_TC35815) += tc35815.o
61obj-$(CONFIG_SKGE) += skge.o 64obj-$(CONFIG_SKGE) += skge.o
65obj-$(CONFIG_SKY2) += sky2.o
62obj-$(CONFIG_SK98LIN) += sk98lin/ 66obj-$(CONFIG_SK98LIN) += sk98lin/
63obj-$(CONFIG_SKFP) += skfp/ 67obj-$(CONFIG_SKFP) += skfp/
64obj-$(CONFIG_VIA_RHINE) += via-rhine.o 68obj-$(CONFIG_VIA_RHINE) += via-rhine.o
@@ -202,6 +206,7 @@ obj-$(CONFIG_NET_TULIP) += tulip/
202obj-$(CONFIG_HAMRADIO) += hamradio/ 206obj-$(CONFIG_HAMRADIO) += hamradio/
203obj-$(CONFIG_IRDA) += irda/ 207obj-$(CONFIG_IRDA) += irda/
204obj-$(CONFIG_ETRAX_ETHERNET) += cris/ 208obj-$(CONFIG_ETRAX_ETHERNET) += cris/
209obj-$(CONFIG_ENP2611_MSF_NET) += ixp2000/
205 210
206obj-$(CONFIG_NETCONSOLE) += netconsole.o 211obj-$(CONFIG_NETCONSOLE) += netconsole.o
207 212
diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile
index cf50384b469e..5cdae2bc055a 100644
--- a/drivers/net/bonding/Makefile
+++ b/drivers/net/bonding/Makefile
@@ -4,5 +4,5 @@
4 4
5obj-$(CONFIG_BONDING) += bonding.o 5obj-$(CONFIG_BONDING) += bonding.o
6 6
7bonding-objs := bond_main.o bond_3ad.o bond_alb.o 7bonding-objs := bond_main.o bond_3ad.o bond_alb.o bond_sysfs.o
8 8
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c
index d2f34d5a8083..f3f5825469d6 100644
--- a/drivers/net/bonding/bond_3ad.c
+++ b/drivers/net/bonding/bond_3ad.c
@@ -18,38 +18,6 @@
18 * The full GNU General Public License is included in this distribution in the 18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE. 19 * file called LICENSE.
20 * 20 *
21 *
22 * Changes:
23 *
24 * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
25 * Amir Noam <amir.noam at intel dot com>
26 * - Added support for lacp_rate module param.
27 *
28 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
29 * - Based on discussion on mailing list, changed locking scheme
30 * to use lock/unlock or lock_bh/unlock_bh appropriately instead
31 * of lock_irqsave/unlock_irqrestore. The new scheme helps exposing
32 * hidden bugs and solves system hangs that occurred due to the fact
33 * that holding lock_irqsave doesn't prevent softirqs from running.
34 * This also increases total throughput since interrupts are not
35 * blocked on each transmitted packets or monitor timeout.
36 *
37 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
38 * - Renamed bond_3ad_link_status_changed() to
39 * bond_3ad_handle_link_change() for compatibility with TLB.
40 *
41 * 2003/05/20 - Amir Noam <amir.noam at intel dot com>
42 * - Fix long fail over time when releasing last slave of an active
43 * aggregator - send LACPDU on unbind of slave to tell partner this
44 * port is no longer aggregatable.
45 *
46 * 2003/06/25 - Tsippy Mendelson <tsippy.mendelson at intel dot com>
47 * - Send LACPDU as highest priority packet to further fix the above
48 * problem on very high Tx traffic load where packets may get dropped
49 * by the slave.
50 *
51 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
52 * - Code cleanup and style changes
53 */ 21 */
54 22
55//#define BONDING_DEBUG 1 23//#define BONDING_DEBUG 1
@@ -1198,10 +1166,10 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
1198 // detect loopback situation 1166 // detect loopback situation
1199 if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) { 1167 if (!MAC_ADDRESS_COMPARE(&(lacpdu->actor_system), &(port->actor_system))) {
1200 // INFO_RECEIVED_LOOPBACK_FRAMES 1168 // INFO_RECEIVED_LOOPBACK_FRAMES
1201 printk(KERN_ERR DRV_NAME ": An illegal loopback occurred on adapter (%s)\n", 1169 printk(KERN_ERR DRV_NAME ": %s: An illegal loopback occurred on "
1202 port->slave->dev->name); 1170 "adapter (%s). Check the configuration to verify that all "
1203 printk(KERN_ERR "Check the configuration to verify that all Adapters " 1171 "Adapters are connected to 802.3ad compliant switch ports\n",
1204 "are connected to 802.3ad compliant switch ports\n"); 1172 port->slave->dev->master->name, port->slave->dev->name);
1205 __release_rx_machine_lock(port); 1173 __release_rx_machine_lock(port);
1206 return; 1174 return;
1207 } 1175 }
@@ -1378,8 +1346,9 @@ static void ad_port_selection_logic(struct port *port)
1378 } 1346 }
1379 } 1347 }
1380 if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list 1348 if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
1381 printk(KERN_WARNING DRV_NAME ": Warning: Port %d (on %s) was " 1349 printk(KERN_WARNING DRV_NAME ": %s: Warning: Port %d (on %s) was "
1382 "related to aggregator %d but was not on its port list\n", 1350 "related to aggregator %d but was not on its port list\n",
1351 port->slave->dev->master->name,
1383 port->actor_port_number, port->slave->dev->name, 1352 port->actor_port_number, port->slave->dev->name,
1384 port->aggregator->aggregator_identifier); 1353 port->aggregator->aggregator_identifier);
1385 } 1354 }
@@ -1450,7 +1419,8 @@ static void ad_port_selection_logic(struct port *port)
1450 1419
1451 dprintk("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier); 1420 dprintk("Port %d joined LAG %d(new LAG)\n", port->actor_port_number, port->aggregator->aggregator_identifier);
1452 } else { 1421 } else {
1453 printk(KERN_ERR DRV_NAME ": Port %d (on %s) did not find a suitable aggregator\n", 1422 printk(KERN_ERR DRV_NAME ": %s: Port %d (on %s) did not find a suitable aggregator\n",
1423 port->slave->dev->master->name,
1454 port->actor_port_number, port->slave->dev->name); 1424 port->actor_port_number, port->slave->dev->name);
1455 } 1425 }
1456 } 1426 }
@@ -1582,8 +1552,9 @@ static void ad_agg_selection_logic(struct aggregator *aggregator)
1582 1552
1583 // check if any partner replys 1553 // check if any partner replys
1584 if (best_aggregator->is_individual) { 1554 if (best_aggregator->is_individual) {
1585 printk(KERN_WARNING DRV_NAME ": Warning: No 802.3ad response from the link partner " 1555 printk(KERN_WARNING DRV_NAME ": %s: Warning: No 802.3ad response from "
1586 "for any adapters in the bond\n"); 1556 "the link partner for any adapters in the bond\n",
1557 best_aggregator->slave->dev->master->name);
1587 } 1558 }
1588 1559
1589 // check if there are more than one aggregator 1560 // check if there are more than one aggregator
@@ -1915,7 +1886,8 @@ int bond_3ad_bind_slave(struct slave *slave)
1915 struct aggregator *aggregator; 1886 struct aggregator *aggregator;
1916 1887
1917 if (bond == NULL) { 1888 if (bond == NULL) {
1918 printk(KERN_ERR "The slave %s is not attached to its bond\n", slave->dev->name); 1889 printk(KERN_ERR DRV_NAME ": %s: The slave %s is not attached to its bond\n",
1890 slave->dev->master->name, slave->dev->name);
1919 return -1; 1891 return -1;
1920 } 1892 }
1921 1893
@@ -1990,7 +1962,9 @@ void bond_3ad_unbind_slave(struct slave *slave)
1990 1962
1991 // if slave is null, the whole port is not initialized 1963 // if slave is null, the whole port is not initialized
1992 if (!port->slave) { 1964 if (!port->slave) {
1993 printk(KERN_WARNING DRV_NAME ": Trying to unbind an uninitialized port on %s\n", slave->dev->name); 1965 printk(KERN_WARNING DRV_NAME ": Warning: %s: Trying to "
1966 "unbind an uninitialized port on %s\n",
1967 slave->dev->master->name, slave->dev->name);
1994 return; 1968 return;
1995 } 1969 }
1996 1970
@@ -2021,7 +1995,8 @@ void bond_3ad_unbind_slave(struct slave *slave)
2021 dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier); 1995 dprintk("Some port(s) related to LAG %d - replaceing with LAG %d\n", aggregator->aggregator_identifier, new_aggregator->aggregator_identifier);
2022 1996
2023 if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) { 1997 if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
2024 printk(KERN_INFO DRV_NAME ": Removing an active aggregator\n"); 1998 printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n",
1999 aggregator->slave->dev->master->name);
2025 // select new active aggregator 2000 // select new active aggregator
2026 select_new_active_agg = 1; 2001 select_new_active_agg = 1;
2027 } 2002 }
@@ -2051,15 +2026,17 @@ void bond_3ad_unbind_slave(struct slave *slave)
2051 ad_agg_selection_logic(__get_first_agg(port)); 2026 ad_agg_selection_logic(__get_first_agg(port));
2052 } 2027 }
2053 } else { 2028 } else {
2054 printk(KERN_WARNING DRV_NAME ": Warning: unbinding aggregator, " 2029 printk(KERN_WARNING DRV_NAME ": %s: Warning: unbinding aggregator, "
2055 "and could not find a new aggregator for its ports\n"); 2030 "and could not find a new aggregator for its ports\n",
2031 slave->dev->master->name);
2056 } 2032 }
2057 } else { // in case that the only port related to this aggregator is the one we want to remove 2033 } else { // in case that the only port related to this aggregator is the one we want to remove
2058 select_new_active_agg = aggregator->is_active; 2034 select_new_active_agg = aggregator->is_active;
2059 // clear the aggregator 2035 // clear the aggregator
2060 ad_clear_agg(aggregator); 2036 ad_clear_agg(aggregator);
2061 if (select_new_active_agg) { 2037 if (select_new_active_agg) {
2062 printk(KERN_INFO "Removing an active aggregator\n"); 2038 printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n",
2039 slave->dev->master->name);
2063 // select new active aggregator 2040 // select new active aggregator
2064 ad_agg_selection_logic(__get_first_agg(port)); 2041 ad_agg_selection_logic(__get_first_agg(port));
2065 } 2042 }
@@ -2085,7 +2062,8 @@ void bond_3ad_unbind_slave(struct slave *slave)
2085 // clear the aggregator 2062 // clear the aggregator
2086 ad_clear_agg(temp_aggregator); 2063 ad_clear_agg(temp_aggregator);
2087 if (select_new_active_agg) { 2064 if (select_new_active_agg) {
2088 printk(KERN_INFO "Removing an active aggregator\n"); 2065 printk(KERN_INFO DRV_NAME ": %s: Removing an active aggregator\n",
2066 slave->dev->master->name);
2089 // select new active aggregator 2067 // select new active aggregator
2090 ad_agg_selection_logic(__get_first_agg(port)); 2068 ad_agg_selection_logic(__get_first_agg(port));
2091 } 2069 }
@@ -2131,7 +2109,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond)
2131 // select the active aggregator for the bond 2109 // select the active aggregator for the bond
2132 if ((port = __get_first_port(bond))) { 2110 if ((port = __get_first_port(bond))) {
2133 if (!port->slave) { 2111 if (!port->slave) {
2134 printk(KERN_WARNING DRV_NAME ": Warning: bond's first port is uninitialized\n"); 2112 printk(KERN_WARNING DRV_NAME ": %s: Warning: bond's first port is "
2113 "uninitialized\n", bond->dev->name);
2135 goto re_arm; 2114 goto re_arm;
2136 } 2115 }
2137 2116
@@ -2143,7 +2122,8 @@ void bond_3ad_state_machine_handler(struct bonding *bond)
2143 // for each port run the state machines 2122 // for each port run the state machines
2144 for (port = __get_first_port(bond); port; port = __get_next_port(port)) { 2123 for (port = __get_first_port(bond); port; port = __get_next_port(port)) {
2145 if (!port->slave) { 2124 if (!port->slave) {
2146 printk(KERN_WARNING DRV_NAME ": Warning: Found an uninitialized port\n"); 2125 printk(KERN_WARNING DRV_NAME ": %s: Warning: Found an uninitialized "
2126 "port\n", bond->dev->name);
2147 goto re_arm; 2127 goto re_arm;
2148 } 2128 }
2149 2129
@@ -2184,7 +2164,8 @@ static void bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u
2184 port = &(SLAVE_AD_INFO(slave).port); 2164 port = &(SLAVE_AD_INFO(slave).port);
2185 2165
2186 if (!port->slave) { 2166 if (!port->slave) {
2187 printk(KERN_WARNING DRV_NAME ": Warning: port of slave %s is uninitialized\n", slave->dev->name); 2167 printk(KERN_WARNING DRV_NAME ": %s: Warning: port of slave %s is "
2168 "uninitialized\n", slave->dev->name, slave->dev->master->name);
2188 return; 2169 return;
2189 } 2170 }
2190 2171
@@ -2230,8 +2211,9 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
2230 2211
2231 // if slave is null, the whole port is not initialized 2212 // if slave is null, the whole port is not initialized
2232 if (!port->slave) { 2213 if (!port->slave) {
2233 printk(KERN_WARNING DRV_NAME ": Warning: speed changed for uninitialized port on %s\n", 2214 printk(KERN_WARNING DRV_NAME ": Warning: %s: speed "
2234 slave->dev->name); 2215 "changed for uninitialized port on %s\n",
2216 slave->dev->master->name, slave->dev->name);
2235 return; 2217 return;
2236 } 2218 }
2237 2219
@@ -2257,8 +2239,9 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
2257 2239
2258 // if slave is null, the whole port is not initialized 2240 // if slave is null, the whole port is not initialized
2259 if (!port->slave) { 2241 if (!port->slave) {
2260 printk(KERN_WARNING DRV_NAME ": Warning: duplex changed for uninitialized port on %s\n", 2242 printk(KERN_WARNING DRV_NAME ": %s: Warning: duplex changed "
2261 slave->dev->name); 2243 "for uninitialized port on %s\n",
2244 slave->dev->master->name, slave->dev->name);
2262 return; 2245 return;
2263 } 2246 }
2264 2247
@@ -2285,8 +2268,9 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
2285 2268
2286 // if slave is null, the whole port is not initialized 2269 // if slave is null, the whole port is not initialized
2287 if (!port->slave) { 2270 if (!port->slave) {
2288 printk(KERN_WARNING DRV_NAME ": Warning: link status changed for uninitialized port on %s\n", 2271 printk(KERN_WARNING DRV_NAME ": Warning: %s: link status changed for "
2289 slave->dev->name); 2272 "uninitialized port on %s\n",
2273 slave->dev->master->name, slave->dev->name);
2290 return; 2274 return;
2291 } 2275 }
2292 2276
@@ -2363,7 +2347,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2363 } 2347 }
2364 2348
2365 if (bond_3ad_get_active_agg_info(bond, &ad_info)) { 2349 if (bond_3ad_get_active_agg_info(bond, &ad_info)) {
2366 printk(KERN_DEBUG "ERROR: bond_3ad_get_active_agg_info failed\n"); 2350 printk(KERN_DEBUG DRV_NAME ": %s: Error: "
2351 "bond_3ad_get_active_agg_info failed\n", dev->name);
2367 goto out; 2352 goto out;
2368 } 2353 }
2369 2354
@@ -2372,7 +2357,9 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2372 2357
2373 if (slaves_in_agg == 0) { 2358 if (slaves_in_agg == 0) {
2374 /*the aggregator is empty*/ 2359 /*the aggregator is empty*/
2375 printk(KERN_DEBUG "ERROR: active aggregator is empty\n"); 2360 printk(KERN_DEBUG DRV_NAME ": %s: Error: active "
2361 "aggregator is empty\n",
2362 dev->name);
2376 goto out; 2363 goto out;
2377 } 2364 }
2378 2365
@@ -2390,7 +2377,8 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev)
2390 } 2377 }
2391 2378
2392 if (slave_agg_no >= 0) { 2379 if (slave_agg_no >= 0) {
2393 printk(KERN_ERR DRV_NAME ": Error: Couldn't find a slave to tx on for aggregator ID %d\n", agg_id); 2380 printk(KERN_ERR DRV_NAME ": %s: Error: Couldn't find a slave to tx on "
2381 "for aggregator ID %d\n", dev->name, agg_id);
2394 goto out; 2382 goto out;
2395 } 2383 }
2396 2384
diff --git a/drivers/net/bonding/bond_3ad.h b/drivers/net/bonding/bond_3ad.h
index 673a30af5660..5ee2cef5b037 100644
--- a/drivers/net/bonding/bond_3ad.h
+++ b/drivers/net/bonding/bond_3ad.h
@@ -18,19 +18,6 @@
18 * The full GNU General Public License is included in this distribution in the 18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE. 19 * file called LICENSE.
20 * 20 *
21 *
22 * Changes:
23 *
24 * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
25 * Amir Noam <amir.noam at intel dot com>
26 * - Added support for lacp_rate module param.
27 *
28 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
29 * - Renamed bond_3ad_link_status_changed() to
30 * bond_3ad_handle_link_change() for compatibility with TLB.
31 *
32 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
33 * - Code cleanup and style changes
34 */ 21 */
35 22
36#ifndef __BOND_3AD_H__ 23#ifndef __BOND_3AD_H__
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index f8fce3961197..854ddfb90da1 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -18,25 +18,6 @@
18 * The full GNU General Public License is included in this distribution in the 18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE. 19 * file called LICENSE.
20 * 20 *
21 *
22 * Changes:
23 *
24 * 2003/06/25 - Shmulik Hen <shmulik.hen at intel dot com>
25 * - Fixed signed/unsigned calculation errors that caused load sharing
26 * to collapse to one slave under very heavy UDP Tx stress.
27 *
28 * 2003/08/06 - Amir Noam <amir.noam at intel dot com>
29 * - Add support for setting bond's MAC address with special
30 * handling required for ALB/TLB.
31 *
32 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
33 * - Code cleanup and style changes
34 *
35 * 2003/12/30 - Amir Noam <amir.noam at intel dot com>
36 * - Fixed: Cannot remove and re-enslave the original active slave.
37 *
38 * 2004/01/14 - Shmulik Hen <shmulik.hen at intel dot com>
39 * - Add capability to tag self generated packets in ALB/TLB modes.
40 */ 21 */
41 22
42//#define BONDING_DEBUG 1 23//#define BONDING_DEBUG 1
@@ -198,20 +179,21 @@ static int tlb_initialize(struct bonding *bond)
198{ 179{
199 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 180 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
200 int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info); 181 int size = TLB_HASH_TABLE_SIZE * sizeof(struct tlb_client_info);
182 struct tlb_client_info *new_hashtbl;
201 int i; 183 int i;
202 184
203 spin_lock_init(&(bond_info->tx_hashtbl_lock)); 185 spin_lock_init(&(bond_info->tx_hashtbl_lock));
204 186
205 _lock_tx_hashtbl(bond); 187 new_hashtbl = kmalloc(size, GFP_KERNEL);
206 188 if (!new_hashtbl) {
207 bond_info->tx_hashtbl = kmalloc(size, GFP_KERNEL);
208 if (!bond_info->tx_hashtbl) {
209 printk(KERN_ERR DRV_NAME 189 printk(KERN_ERR DRV_NAME
210 ": Error: %s: Failed to allocate TLB hash table\n", 190 ": %s: Error: Failed to allocate TLB hash table\n",
211 bond->dev->name); 191 bond->dev->name);
212 _unlock_tx_hashtbl(bond);
213 return -1; 192 return -1;
214 } 193 }
194 _lock_tx_hashtbl(bond);
195
196 bond_info->tx_hashtbl = new_hashtbl;
215 197
216 memset(bond_info->tx_hashtbl, 0, size); 198 memset(bond_info->tx_hashtbl, 0, size);
217 199
@@ -513,7 +495,8 @@ static void rlb_update_client(struct rlb_client_info *client_info)
513 client_info->mac_dst); 495 client_info->mac_dst);
514 if (!skb) { 496 if (!skb) {
515 printk(KERN_ERR DRV_NAME 497 printk(KERN_ERR DRV_NAME
516 ": Error: failed to create an ARP packet\n"); 498 ": %s: Error: failed to create an ARP packet\n",
499 client_info->slave->dev->master->name);
517 continue; 500 continue;
518 } 501 }
519 502
@@ -523,7 +506,8 @@ static void rlb_update_client(struct rlb_client_info *client_info)
523 skb = vlan_put_tag(skb, client_info->vlan_id); 506 skb = vlan_put_tag(skb, client_info->vlan_id);
524 if (!skb) { 507 if (!skb) {
525 printk(KERN_ERR DRV_NAME 508 printk(KERN_ERR DRV_NAME
526 ": Error: failed to insert VLAN tag\n"); 509 ": %s: Error: failed to insert VLAN tag\n",
510 client_info->slave->dev->master->name);
527 continue; 511 continue;
528 } 512 }
529 } 513 }
@@ -606,8 +590,9 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, u32 src_ip)
606 590
607 if (!client_info->slave) { 591 if (!client_info->slave) {
608 printk(KERN_ERR DRV_NAME 592 printk(KERN_ERR DRV_NAME
609 ": Error: found a client with no channel in " 593 ": %s: Error: found a client with no channel in "
610 "the client's hash table\n"); 594 "the client's hash table\n",
595 bond->dev->name);
611 continue; 596 continue;
612 } 597 }
613 /*update all clients using this src_ip, that are not assigned 598 /*update all clients using this src_ip, that are not assigned
@@ -797,21 +782,22 @@ static int rlb_initialize(struct bonding *bond)
797{ 782{
798 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); 783 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
799 struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type); 784 struct packet_type *pk_type = &(BOND_ALB_INFO(bond).rlb_pkt_type);
785 struct rlb_client_info *new_hashtbl;
800 int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info); 786 int size = RLB_HASH_TABLE_SIZE * sizeof(struct rlb_client_info);
801 int i; 787 int i;
802 788
803 spin_lock_init(&(bond_info->rx_hashtbl_lock)); 789 spin_lock_init(&(bond_info->rx_hashtbl_lock));
804 790
805 _lock_rx_hashtbl(bond); 791 new_hashtbl = kmalloc(size, GFP_KERNEL);
806 792 if (!new_hashtbl) {
807 bond_info->rx_hashtbl = kmalloc(size, GFP_KERNEL);
808 if (!bond_info->rx_hashtbl) {
809 printk(KERN_ERR DRV_NAME 793 printk(KERN_ERR DRV_NAME
810 ": Error: %s: Failed to allocate RLB hash table\n", 794 ": %s: Error: Failed to allocate RLB hash table\n",
811 bond->dev->name); 795 bond->dev->name);
812 _unlock_rx_hashtbl(bond);
813 return -1; 796 return -1;
814 } 797 }
798 _lock_rx_hashtbl(bond);
799
800 bond_info->rx_hashtbl = new_hashtbl;
815 801
816 bond_info->rx_hashtbl_head = RLB_NULL_INDEX; 802 bond_info->rx_hashtbl_head = RLB_NULL_INDEX;
817 803
@@ -927,7 +913,8 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
927 skb = vlan_put_tag(skb, vlan->vlan_id); 913 skb = vlan_put_tag(skb, vlan->vlan_id);
928 if (!skb) { 914 if (!skb) {
929 printk(KERN_ERR DRV_NAME 915 printk(KERN_ERR DRV_NAME
930 ": Error: failed to insert VLAN tag\n"); 916 ": %s: Error: failed to insert VLAN tag\n",
917 bond->dev->name);
931 continue; 918 continue;
932 } 919 }
933 } 920 }
@@ -956,11 +943,11 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[], int hw)
956 s_addr.sa_family = dev->type; 943 s_addr.sa_family = dev->type;
957 if (dev_set_mac_address(dev, &s_addr)) { 944 if (dev_set_mac_address(dev, &s_addr)) {
958 printk(KERN_ERR DRV_NAME 945 printk(KERN_ERR DRV_NAME
959 ": Error: dev_set_mac_address of dev %s failed! ALB " 946 ": %s: Error: dev_set_mac_address of dev %s failed! ALB "
960 "mode requires that the base driver support setting " 947 "mode requires that the base driver support setting "
961 "the hw address also when the network device's " 948 "the hw address also when the network device's "
962 "interface is open\n", 949 "interface is open\n",
963 dev->name); 950 dev->master->name, dev->name);
964 return -EOPNOTSUPP; 951 return -EOPNOTSUPP;
965 } 952 }
966 return 0; 953 return 0;
@@ -1153,16 +1140,16 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav
1153 bond->alb_info.rlb_enabled); 1140 bond->alb_info.rlb_enabled);
1154 1141
1155 printk(KERN_WARNING DRV_NAME 1142 printk(KERN_WARNING DRV_NAME
1156 ": Warning: the hw address of slave %s is in use by " 1143 ": %s: Warning: the hw address of slave %s is in use by "
1157 "the bond; giving it the hw address of %s\n", 1144 "the bond; giving it the hw address of %s\n",
1158 slave->dev->name, free_mac_slave->dev->name); 1145 bond->dev->name, slave->dev->name, free_mac_slave->dev->name);
1159 1146
1160 } else if (has_bond_addr) { 1147 } else if (has_bond_addr) {
1161 printk(KERN_ERR DRV_NAME 1148 printk(KERN_ERR DRV_NAME
1162 ": Error: the hw address of slave %s is in use by the " 1149 ": %s: Error: the hw address of slave %s is in use by the "
1163 "bond; couldn't find a slave with a free hw address to " 1150 "bond; couldn't find a slave with a free hw address to "
1164 "give it (this should not have happened)\n", 1151 "give it (this should not have happened)\n",
1165 slave->dev->name); 1152 bond->dev->name, slave->dev->name);
1166 return -EFAULT; 1153 return -EFAULT;
1167 } 1154 }
1168 1155
@@ -1250,6 +1237,8 @@ int bond_alb_initialize(struct bonding *bond, int rlb_enabled)
1250 tlb_deinitialize(bond); 1237 tlb_deinitialize(bond);
1251 return res; 1238 return res;
1252 } 1239 }
1240 } else {
1241 bond->alb_info.rlb_enabled = 0;
1253 } 1242 }
1254 1243
1255 return 0; 1244 return 0;
@@ -1409,7 +1398,7 @@ void bond_alb_monitor(struct bonding *bond)
1409 read_lock(&bond->curr_slave_lock); 1398 read_lock(&bond->curr_slave_lock);
1410 1399
1411 bond_for_each_slave(bond, slave, i) { 1400 bond_for_each_slave(bond, slave, i) {
1412 alb_send_learning_packets(slave,slave->dev->dev_addr); 1401 alb_send_learning_packets(slave, slave->dev->dev_addr);
1413 } 1402 }
1414 1403
1415 read_unlock(&bond->curr_slave_lock); 1404 read_unlock(&bond->curr_slave_lock);
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index e4091cd8d654..28f2a2fd1b5a 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -18,15 +18,6 @@
18 * The full GNU General Public License is included in this distribution in the 18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE. 19 * file called LICENSE.
20 * 20 *
21 *
22 * Changes:
23 *
24 * 2003/08/06 - Amir Noam <amir.noam at intel dot com>
25 * - Add support for setting bond's MAC address with special
26 * handling required for ALB/TLB.
27 *
28 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
29 * - Code cleanup and style changes
30 */ 21 */
31 22
32#ifndef __BOND_ALB_H__ 23#ifndef __BOND_ALB_H__
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 94cec3cf2a13..2582d98ef5c3 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -29,466 +29,6 @@
29 * b: if a hw mac address already is there, eth0's hw mac address 29 * b: if a hw mac address already is there, eth0's hw mac address
30 * will then be set from bond0. 30 * will then be set from bond0.
31 * 31 *
32 * v0.1 - first working version.
33 * v0.2 - changed stats to be calculated by summing slaves stats.
34 *
35 * Changes:
36 * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
37 * - fix leaks on failure at bond_init
38 *
39 * 2000/09/30 - Willy Tarreau <willy at meta-x.org>
40 * - added trivial code to release a slave device.
41 * - fixed security bug (CAP_NET_ADMIN not checked)
42 * - implemented MII link monitoring to disable dead links :
43 * All MII capable slaves are checked every <miimon> milliseconds
44 * (100 ms seems good). This value can be changed by passing it to
45 * insmod. A value of zero disables the monitoring (default).
46 * - fixed an infinite loop in bond_xmit_roundrobin() when there's no
47 * good slave.
48 * - made the code hopefully SMP safe
49 *
50 * 2000/10/03 - Willy Tarreau <willy at meta-x.org>
51 * - optimized slave lists based on relevant suggestions from Thomas Davis
52 * - implemented active-backup method to obtain HA with two switches:
53 * stay as long as possible on the same active interface, while we
54 * also monitor the backup one (MII link status) because we want to know
55 * if we are able to switch at any time. ( pass "mode=1" to insmod )
56 * - lots of stress testings because we need it to be more robust than the
57 * wires ! :->
58 *
59 * 2000/10/09 - Willy Tarreau <willy at meta-x.org>
60 * - added up and down delays after link state change.
61 * - optimized the slaves chaining so that when we run forward, we never
62 * repass through the bond itself, but we can find it by searching
63 * backwards. Renders the deletion more difficult, but accelerates the
64 * scan.
65 * - smarter enslaving and releasing.
66 * - finer and more robust SMP locking
67 *
68 * 2000/10/17 - Willy Tarreau <willy at meta-x.org>
69 * - fixed two potential SMP race conditions
70 *
71 * 2000/10/18 - Willy Tarreau <willy at meta-x.org>
72 * - small fixes to the monitoring FSM in case of zero delays
73 * 2000/11/01 - Willy Tarreau <willy at meta-x.org>
74 * - fixed first slave not automatically used in trunk mode.
75 * 2000/11/10 : spelling of "EtherChannel" corrected.
76 * 2000/11/13 : fixed a race condition in case of concurrent accesses to ioctl().
77 * 2000/12/16 : fixed improper usage of rtnl_exlock_nowait().
78 *
79 * 2001/1/3 - Chad N. Tindel <ctindel at ieee dot org>
80 * - The bonding driver now simulates MII status monitoring, just like
81 * a normal network device. It will show that the link is down iff
82 * every slave in the bond shows that their links are down. If at least
83 * one slave is up, the bond's MII status will appear as up.
84 *
85 * 2001/2/7 - Chad N. Tindel <ctindel at ieee dot org>
86 * - Applications can now query the bond from user space to get
87 * information which may be useful. They do this by calling
88 * the BOND_INFO_QUERY ioctl. Once the app knows how many slaves
89 * are in the bond, it can call the BOND_SLAVE_INFO_QUERY ioctl to
90 * get slave specific information (# link failures, etc). See
91 * <linux/if_bonding.h> for more details. The structs of interest
92 * are ifbond and ifslave.
93 *
94 * 2001/4/5 - Chad N. Tindel <ctindel at ieee dot org>
95 * - Ported to 2.4 Kernel
96 *
97 * 2001/5/2 - Jeffrey E. Mast <jeff at mastfamily dot com>
98 * - When a device is detached from a bond, the slave device is no longer
99 * left thinking that is has a master.
100 *
101 * 2001/5/16 - Jeffrey E. Mast <jeff at mastfamily dot com>
102 * - memset did not appropriately initialized the bond rw_locks. Used
103 * rwlock_init to initialize to unlocked state to prevent deadlock when
104 * first attempting a lock
105 * - Called SET_MODULE_OWNER for bond device
106 *
107 * 2001/5/17 - Tim Anderson <tsa at mvista.com>
108 * - 2 paths for releasing for slave release; 1 through ioctl
109 * and 2) through close. Both paths need to release the same way.
110 * - the free slave in bond release is changing slave status before
111 * the free. The netdev_set_master() is intended to change slave state
112 * so it should not be done as part of the release process.
113 * - Simple rule for slave state at release: only the active in A/B and
114 * only one in the trunked case.
115 *
116 * 2001/6/01 - Tim Anderson <tsa at mvista.com>
117 * - Now call dev_close when releasing a slave so it doesn't screw up
118 * out routing table.
119 *
120 * 2001/6/01 - Chad N. Tindel <ctindel at ieee dot org>
121 * - Added /proc support for getting bond and slave information.
122 * Information is in /proc/net/<bond device>/info.
123 * - Changed the locking when calling bond_close to prevent deadlock.
124 *
125 * 2001/8/05 - Janice Girouard <girouard at us.ibm.com>
126 * - correct problem where refcnt of slave is not incremented in bond_ioctl
127 * so the system hangs when halting.
128 * - correct locking problem when unable to malloc in bond_enslave.
129 * - adding bond_xmit_xor logic.
130 * - adding multiple bond device support.
131 *
132 * 2001/8/13 - Erik Habbinga <erik_habbinga at hp dot com>
133 * - correct locking problem with rtnl_exlock_nowait
134 *
135 * 2001/8/23 - Janice Girouard <girouard at us.ibm.com>
136 * - bzero initial dev_bonds, to correct oops
137 * - convert SIOCDEVPRIVATE to new MII ioctl calls
138 *
139 * 2001/9/13 - Takao Indoh <indou dot takao at jp dot fujitsu dot com>
140 * - Add the BOND_CHANGE_ACTIVE ioctl implementation
141 *
142 * 2001/9/14 - Mark Huth <mhuth at mvista dot com>
143 * - Change MII_LINK_READY to not check for end of auto-negotiation,
144 * but only for an up link.
145 *
146 * 2001/9/20 - Chad N. Tindel <ctindel at ieee dot org>
147 * - Add the device field to bonding_t. Previously the net_device
148 * corresponding to a bond wasn't available from the bonding_t
149 * structure.
150 *
151 * 2001/9/25 - Janice Girouard <girouard at us.ibm.com>
152 * - add arp_monitor for active backup mode
153 *
154 * 2001/10/23 - Takao Indoh <indou dot takao at jp dot fujitsu dot com>
155 * - Various memory leak fixes
156 *
157 * 2001/11/5 - Mark Huth <mark dot huth at mvista dot com>
158 * - Don't take rtnl lock in bond_mii_monitor as it deadlocks under
159 * certain hotswap conditions.
160 * Note: this same change may be required in bond_arp_monitor ???
161 * - Remove possibility of calling bond_sethwaddr with NULL slave_dev ptr
162 * - Handle hot swap ethernet interface deregistration events to remove
163 * kernel oops following hot swap of enslaved interface
164 *
165 * 2002/1/2 - Chad N. Tindel <ctindel at ieee dot org>
166 * - Restore original slave flags at release time.
167 *
168 * 2002/02/18 - Erik Habbinga <erik_habbinga at hp dot com>
169 * - bond_release(): calling kfree on our_slave after call to
170 * bond_restore_slave_flags, not before
171 * - bond_enslave(): saving slave flags into original_flags before
172 * call to netdev_set_master, so the IFF_SLAVE flag doesn't end
173 * up in original_flags
174 *
175 * 2002/04/05 - Mark Smith <mark.smith at comdev dot cc> and
176 * Steve Mead <steve.mead at comdev dot cc>
177 * - Port Gleb Natapov's multicast support patchs from 2.4.12
178 * to 2.4.18 adding support for multicast.
179 *
180 * 2002/06/10 - Tony Cureington <tony.cureington * hp_com>
181 * - corrected uninitialized pointer (ifr.ifr_data) in bond_check_dev_link;
182 * actually changed function to use MIIPHY, then MIIREG, and finally
183 * ETHTOOL to determine the link status
184 * - fixed bad ifr_data pointer assignments in bond_ioctl
185 * - corrected mode 1 being reported as active-backup in bond_get_info;
186 * also added text to distinguish type of load balancing (rr or xor)
187 * - change arp_ip_target module param from "1-12s" (array of 12 ptrs)
188 * to "s" (a single ptr)
189 *
190 * 2002/08/30 - Jay Vosburgh <fubar at us dot ibm dot com>
191 * - Removed acquisition of xmit_lock in set_multicast_list; caused
192 * deadlock on SMP (lock is held by caller).
193 * - Revamped SIOCGMIIPHY, SIOCGMIIREG portion of bond_check_dev_link().
194 *
195 * 2002/09/18 - Jay Vosburgh <fubar at us dot ibm dot com>
196 * - Fixed up bond_check_dev_link() (and callers): removed some magic
197 * numbers, banished local MII_ defines, wrapped ioctl calls to
198 * prevent EFAULT errors
199 *
200 * 2002/9/30 - Jay Vosburgh <fubar at us dot ibm dot com>
201 * - make sure the ip target matches the arp_target before saving the
202 * hw address.
203 *
204 * 2002/9/30 - Dan Eisner <eisner at 2robots dot com>
205 * - make sure my_ip is set before taking down the link, since
206 * not all switches respond if the source ip is not set.
207 *
208 * 2002/10/8 - Janice Girouard <girouard at us dot ibm dot com>
209 * - read in the local ip address when enslaving a device
210 * - add primary support
211 * - make sure 2*arp_interval has passed when a new device
212 * is brought on-line before taking it down.
213 *
214 * 2002/09/11 - Philippe De Muyter <phdm at macqel dot be>
215 * - Added bond_xmit_broadcast logic.
216 * - Added bond_mode() support function.
217 *
218 * 2002/10/26 - Laurent Deniel <laurent.deniel at free.fr>
219 * - allow to register multicast addresses only on active slave
220 * (useful in active-backup mode)
221 * - add multicast module parameter
222 * - fix deletion of multicast groups after unloading module
223 *
224 * 2002/11/06 - Kameshwara Rayaprolu <kameshwara.rao * wipro_com>
225 * - Changes to prevent panic from closing the device twice; if we close
226 * the device in bond_release, we must set the original_flags to down
227 * so it won't be closed again by the network layer.
228 *
229 * 2002/11/07 - Tony Cureington <tony.cureington * hp_com>
230 * - Fix arp_target_hw_addr memory leak
231 * - Created activebackup_arp_monitor function to handle arp monitoring
232 * in active backup mode - the bond_arp_monitor had several problems...
233 * such as allowing slaves to tx arps sequentially without any delay
234 * for a response
235 * - Renamed bond_arp_monitor to loadbalance_arp_monitor and re-wrote
236 * this function to just handle arp monitoring in load-balancing mode;
237 * it is a lot more compact now
238 * - Changes to ensure one and only one slave transmits in active-backup
239 * mode
240 * - Robustesize parameters; warn users about bad combinations of
241 * parameters; also if miimon is specified and a network driver does
242 * not support MII or ETHTOOL, inform the user of this
243 * - Changes to support link_failure_count when in arp monitoring mode
244 * - Fix up/down delay reported in /proc
245 * - Added version; log version; make version available from "modinfo -d"
246 * - Fixed problem in bond_check_dev_link - if the first IOCTL (SIOCGMIIPH)
247 * failed, the ETHTOOL ioctl never got a chance
248 *
249 * 2002/11/16 - Laurent Deniel <laurent.deniel at free.fr>
250 * - fix multicast handling in activebackup_arp_monitor
251 * - remove one unnecessary and confusing curr_active_slave == slave test
252 * in activebackup_arp_monitor
253 *
254 * 2002/11/17 - Laurent Deniel <laurent.deniel at free.fr>
255 * - fix bond_slave_info_query when slave_id = num_slaves
256 *
257 * 2002/11/19 - Janice Girouard <girouard at us dot ibm dot com>
258 * - correct ifr_data reference. Update ifr_data reference
259 * to mii_ioctl_data struct values to avoid confusion.
260 *
261 * 2002/11/22 - Bert Barbe <bert.barbe at oracle dot com>
262 * - Add support for multiple arp_ip_target
263 *
264 * 2002/12/13 - Jay Vosburgh <fubar at us dot ibm dot com>
265 * - Changed to allow text strings for mode and multicast, e.g.,
266 * insmod bonding mode=active-backup. The numbers still work.
267 * One change: an invalid choice will cause module load failure,
268 * rather than the previous behavior of just picking one.
269 * - Minor cleanups; got rid of dup ctype stuff, atoi function
270 *
271 * 2003/02/07 - Jay Vosburgh <fubar at us dot ibm dot com>
272 * - Added use_carrier module parameter that causes miimon to
273 * use netif_carrier_ok() test instead of MII/ETHTOOL ioctls.
274 * - Minor cleanups; consolidated ioctl calls to one function.
275 *
276 * 2003/02/07 - Tony Cureington <tony.cureington * hp_com>
277 * - Fix bond_mii_monitor() logic error that could result in
278 * bonding round-robin mode ignoring links after failover/recovery
279 *
280 * 2003/03/17 - Jay Vosburgh <fubar at us dot ibm dot com>
281 * - kmalloc fix (GFP_KERNEL to GFP_ATOMIC) reported by
282 * Shmulik dot Hen at intel.com.
283 * - Based on discussion on mailing list, changed use of
284 * update_slave_cnt(), created wrapper functions for adding/removing
285 * slaves, changed bond_xmit_xor() to check slave_cnt instead of
286 * checking slave and slave->dev (which only worked by accident).
287 * - Misc code cleanup: get arp_send() prototype from header file,
288 * add max_bonds to bonding.txt.
289 *
290 * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
291 * Shmulik Hen <shmulik.hen at intel dot com>
292 * - Make sure only bond_attach_slave() and bond_detach_slave() can
293 * manipulate the slave list, including slave_cnt, even when in
294 * bond_release_all().
295 * - Fixed hang in bond_release() with traffic running:
296 * netdev_set_master() must not be called from within the bond lock.
297 *
298 * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
299 * Shmulik Hen <shmulik.hen at intel dot com>
300 * - Fixed hang in bond_enslave() with traffic running:
301 * netdev_set_master() must not be called from within the bond lock.
302 *
303 * 2003/03/18 - Amir Noam <amir.noam at intel dot com>
304 * - Added support for getting slave's speed and duplex via ethtool.
305 * Needed for 802.3ad and other future modes.
306 *
307 * 2003/03/18 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
308 * Shmulik Hen <shmulik.hen at intel dot com>
309 * - Enable support of modes that need to use the unique mac address of
310 * each slave.
311 * * bond_enslave(): Moved setting the slave's mac address, and
312 * openning it, from the application to the driver. This breaks
313 * backward comaptibility with old versions of ifenslave that open
314 * the slave before enalsving it !!!.
315 * * bond_release(): The driver also takes care of closing the slave
316 * and restoring its original mac address.
317 * - Removed the code that restores all base driver's flags.
318 * Flags are automatically restored once all undo stages are done
319 * properly.
320 * - Block possibility of enslaving before the master is up. This
321 * prevents putting the system in an unstable state.
322 *
323 * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
324 * Tsippy Mendelson <tsippy.mendelson at intel dot com> and
325 * Shmulik Hen <shmulik.hen at intel dot com>
326 * - Added support for IEEE 802.3ad Dynamic link aggregation mode.
327 *
328 * 2003/05/01 - Amir Noam <amir.noam at intel dot com>
329 * - Added ABI version control to restore compatibility between
330 * new/old ifenslave and new/old bonding.
331 *
332 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
333 * - Fixed bug in bond_release_all(): save old value of curr_active_slave
334 * before setting it to NULL.
335 * - Changed driver versioning scheme to include version number instead
336 * of release date (that is already in another field). There are 3
337 * fields X.Y.Z where:
338 * X - Major version - big behavior changes
339 * Y - Minor version - addition of features
340 * Z - Extra version - minor changes and bug fixes
341 * The current version is 1.0.0 as a base line.
342 *
343 * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
344 * Amir Noam <amir.noam at intel dot com>
345 * - Added support for lacp_rate module param.
346 * - Code beautification and style changes (mainly in comments).
347 * new version - 1.0.1
348 *
349 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
350 * - Based on discussion on mailing list, changed locking scheme
351 * to use lock/unlock or lock_bh/unlock_bh appropriately instead
352 * of lock_irqsave/unlock_irqrestore. The new scheme helps exposing
353 * hidden bugs and solves system hangs that occurred due to the fact
354 * that holding lock_irqsave doesn't prevent softirqs from running.
355 * This also increases total throughput since interrupts are not
356 * blocked on each transmitted packets or monitor timeout.
357 * new version - 2.0.0
358 *
359 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
360 * - Added support for Transmit load balancing mode.
361 * - Concentrate all assignments of curr_active_slave to a single point
362 * so specific modes can take actions when the primary adapter is
363 * changed.
364 * - Take the updelay parameter into consideration during bond_enslave
365 * since some adapters loose their link during setting the device.
366 * - Renamed bond_3ad_link_status_changed() to
367 * bond_3ad_handle_link_change() for compatibility with TLB.
368 * new version - 2.1.0
369 *
370 * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com>
371 * - Added support for Adaptive load balancing mode which is
372 * equivalent to Transmit load balancing + Receive load balancing.
373 * new version - 2.2.0
374 *
375 * 2003/05/15 - Jay Vosburgh <fubar at us dot ibm dot com>
376 * - Applied fix to activebackup_arp_monitor posted to bonding-devel
377 * by Tony Cureington <tony.cureington * hp_com>. Fixes ARP
378 * monitor endless failover bug. Version to 2.2.10
379 *
380 * 2003/05/20 - Amir Noam <amir.noam at intel dot com>
381 * - Fixed bug in ABI version control - Don't commit to a specific
382 * ABI version if receiving unsupported ioctl commands.
383 *
384 * 2003/05/22 - Jay Vosburgh <fubar at us dot ibm dot com>
385 * - Fix ifenslave -c causing bond to loose existing routes;
386 * added bond_set_mac_address() that doesn't require the
387 * bond to be down.
388 * - In conjunction with fix for ifenslave -c, in
389 * bond_change_active(), changing to the already active slave
390 * is no longer an error (it successfully does nothing).
391 *
392 * 2003/06/30 - Amir Noam <amir.noam at intel dot com>
393 * - Fixed bond_change_active() for ALB/TLB modes.
394 * Version to 2.2.14.
395 *
396 * 2003/07/29 - Amir Noam <amir.noam at intel dot com>
397 * - Fixed ARP monitoring bug.
398 * Version to 2.2.15.
399 *
400 * 2003/07/31 - Willy Tarreau <willy at ods dot org>
401 * - Fixed kernel panic when using ARP monitoring without
402 * setting bond's IP address.
403 * Version to 2.2.16.
404 *
405 * 2003/08/06 - Amir Noam <amir.noam at intel dot com>
406 * - Back port from 2.6: use alloc_netdev(); fix /proc handling;
407 * made stats a part of bond struct so no need to allocate
408 * and free it separately; use standard list operations instead
409 * of pre-allocated array of bonds.
410 * Version to 2.3.0.
411 *
412 * 2003/08/07 - Jay Vosburgh <fubar at us dot ibm dot com>,
413 * Amir Noam <amir.noam at intel dot com> and
414 * Shmulik Hen <shmulik.hen at intel dot com>
415 * - Propagating master's settings: Distinguish between modes that
416 * use a primary slave from those that don't, and propagate settings
417 * accordingly; Consolidate change_active opeartions and add
418 * reselect_active and find_best opeartions; Decouple promiscuous
419 * handling from the multicast mode setting; Add support for changing
420 * HW address and MTU with proper unwind; Consolidate procfs code,
421 * add CHANGENAME handler; Enhance netdev notification handling.
422 * Version to 2.4.0.
423 *
424 * 2003/09/15 - Stephen Hemminger <shemminger at osdl dot org>,
425 * Amir Noam <amir.noam at intel dot com>
426 * - Convert /proc to seq_file interface.
427 * Change /proc/net/bondX/info to /proc/net/bonding/bondX.
428 * Set version to 2.4.1.
429 *
430 * 2003/11/20 - Amir Noam <amir.noam at intel dot com>
431 * - Fix /proc creation/destruction.
432 *
433 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
434 * - Massive cleanup - Set version to 2.5.0
435 * Code changes:
436 * o Consolidate format of prints and debug prints.
437 * o Remove bonding_t/slave_t typedefs and consolidate all casts.
438 * o Remove dead code and unnecessary checks.
439 * o Consolidate starting/stopping timers.
440 * o Consolidate handling of primary module param throughout the code.
441 * o Removed multicast module param support - all settings are done
442 * according to mode.
443 * o Slave list iteration - bond is no longer part of the list,
444 * added cyclic list iteration macros.
445 * o Consolidate error handling in all xmit functions.
446 * Style changes:
447 * o Consolidate function naming and declarations.
448 * o Consolidate function params and local variables names.
449 * o Consolidate return values.
450 * o Consolidate curly braces.
451 * o Consolidate conditionals format.
452 * o Change struct member names and types.
453 * o Chomp trailing spaces, remove empty lines, fix indentations.
454 * o Re-organize code according to context.
455 *
456 * 2003/12/30 - Amir Noam <amir.noam at intel dot com>
457 * - Fixed: Cannot remove and re-enslave the original active slave.
458 * - Fixed: Releasing the original active slave causes mac address
459 * duplication.
460 * - Add support for slaves that use ethtool_ops.
461 * Set version to 2.5.3.
462 *
463 * 2004/01/05 - Amir Noam <amir.noam at intel dot com>
464 * - Save bonding parameters per bond instead of using the global values.
465 * Set version to 2.5.4.
466 *
467 * 2004/01/14 - Shmulik Hen <shmulik.hen at intel dot com>
468 * - Enhance VLAN support:
469 * * Add support for VLAN hardware acceleration capable slaves.
470 * * Add capability to tag self generated packets in ALB/TLB modes.
471 * Set version to 2.6.0.
472 * 2004/10/29 - Mitch Williams <mitch.a.williams at intel dot com>
473 * - Fixed bug when unloading module while using 802.3ad. If
474 * spinlock debugging is turned on, this causes a stack dump.
475 * Solution is to move call to dev_remove_pack outside of the
476 * spinlock.
477 * Set version to 2.6.1.
478 * 2005/06/05 - Jay Vosburgh <fubar@us.ibm.com>
479 * - Support for generating gratuitous ARPs in active-backup mode.
480 * Includes support for VLAN tagging all bonding-generated ARPs
481 * as needed. Set version to 2.6.2.
482 * 2005/06/08 - Jason Gabler <jygabler at lbl dot gov>
483 * - alternate hashing policy support for mode 2
484 * * Added kernel parameter "xmit_hash_policy" to allow the selection
485 * of different hashing policies for mode 2. The original mode 2
486 * policy is the default, now found in xmit_hash_policy_layer2().
487 * * Added xmit_hash_policy_layer34()
488 * - Modified by Jay Vosburgh <fubar@us.ibm.com> to also support mode 4.
489 * Set version to 2.6.3.
490 * 2005/09/26 - Jay Vosburgh <fubar@us.ibm.com>
491 * - Removed backwards compatibility for old ifenslaves. Version 2.6.4.
492 */ 32 */
493 33
494//#define BONDING_DEBUG 1 34//#define BONDING_DEBUG 1
@@ -557,6 +97,7 @@ static char *lacp_rate = NULL;
557static char *xmit_hash_policy = NULL; 97static char *xmit_hash_policy = NULL;
558static int arp_interval = BOND_LINK_ARP_INTERV; 98static int arp_interval = BOND_LINK_ARP_INTERV;
559static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; 99static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, };
100struct bond_params bonding_defaults;
560 101
561module_param(max_bonds, int, 0); 102module_param(max_bonds, int, 0);
562MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); 103MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
@@ -565,17 +106,24 @@ MODULE_PARM_DESC(miimon, "Link check interval in milliseconds");
565module_param(updelay, int, 0); 106module_param(updelay, int, 0);
566MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds"); 107MODULE_PARM_DESC(updelay, "Delay before considering link up, in milliseconds");
567module_param(downdelay, int, 0); 108module_param(downdelay, int, 0);
568MODULE_PARM_DESC(downdelay, "Delay before considering link down, in milliseconds"); 109MODULE_PARM_DESC(downdelay, "Delay before considering link down, "
110 "in milliseconds");
569module_param(use_carrier, int, 0); 111module_param(use_carrier, int, 0);
570MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; 0 for off, 1 for on (default)"); 112MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; "
113 "0 for off, 1 for on (default)");
571module_param(mode, charp, 0); 114module_param(mode, charp, 0);
572MODULE_PARM_DESC(mode, "Mode of operation : 0 for round robin, 1 for active-backup, 2 for xor"); 115MODULE_PARM_DESC(mode, "Mode of operation : 0 for balance-rr, "
116 "1 for active-backup, 2 for balance-xor, "
117 "3 for broadcast, 4 for 802.3ad, 5 for balance-tlb, "
118 "6 for balance-alb");
573module_param(primary, charp, 0); 119module_param(primary, charp, 0);
574MODULE_PARM_DESC(primary, "Primary network device to use"); 120MODULE_PARM_DESC(primary, "Primary network device to use");
575module_param(lacp_rate, charp, 0); 121module_param(lacp_rate, charp, 0);
576MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner (slow/fast)"); 122MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner "
123 "(slow/fast)");
577module_param(xmit_hash_policy, charp, 0); 124module_param(xmit_hash_policy, charp, 0);
578MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method : 0 for layer 2 (default), 1 for layer 3+4"); 125MODULE_PARM_DESC(xmit_hash_policy, "XOR hashing method: 0 for layer 2 (default)"
126 ", 1 for layer 3+4");
579module_param(arp_interval, int, 0); 127module_param(arp_interval, int, 0);
580MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds"); 128MODULE_PARM_DESC(arp_interval, "arp interval in milliseconds");
581module_param_array(arp_ip_target, charp, NULL, 0); 129module_param_array(arp_ip_target, charp, NULL, 0);
@@ -586,30 +134,27 @@ MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form");
586static const char *version = 134static const char *version =
587 DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n"; 135 DRV_DESCRIPTION ": v" DRV_VERSION " (" DRV_RELDATE ")\n";
588 136
589static LIST_HEAD(bond_dev_list); 137LIST_HEAD(bond_dev_list);
590 138
591#ifdef CONFIG_PROC_FS 139#ifdef CONFIG_PROC_FS
592static struct proc_dir_entry *bond_proc_dir = NULL; 140static struct proc_dir_entry *bond_proc_dir = NULL;
593#endif 141#endif
594 142
143extern struct rw_semaphore bonding_rwsem;
595static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ; 144static u32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ;
596static int arp_ip_count = 0; 145static int arp_ip_count = 0;
597static int bond_mode = BOND_MODE_ROUNDROBIN; 146static int bond_mode = BOND_MODE_ROUNDROBIN;
598static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2; 147static int xmit_hashtype= BOND_XMIT_POLICY_LAYER2;
599static int lacp_fast = 0; 148static int lacp_fast = 0;
600 149
601struct bond_parm_tbl {
602 char *modename;
603 int mode;
604};
605 150
606static struct bond_parm_tbl bond_lacp_tbl[] = { 151struct bond_parm_tbl bond_lacp_tbl[] = {
607{ "slow", AD_LACP_SLOW}, 152{ "slow", AD_LACP_SLOW},
608{ "fast", AD_LACP_FAST}, 153{ "fast", AD_LACP_FAST},
609{ NULL, -1}, 154{ NULL, -1},
610}; 155};
611 156
612static struct bond_parm_tbl bond_mode_tbl[] = { 157struct bond_parm_tbl bond_mode_tbl[] = {
613{ "balance-rr", BOND_MODE_ROUNDROBIN}, 158{ "balance-rr", BOND_MODE_ROUNDROBIN},
614{ "active-backup", BOND_MODE_ACTIVEBACKUP}, 159{ "active-backup", BOND_MODE_ACTIVEBACKUP},
615{ "balance-xor", BOND_MODE_XOR}, 160{ "balance-xor", BOND_MODE_XOR},
@@ -620,7 +165,7 @@ static struct bond_parm_tbl bond_mode_tbl[] = {
620{ NULL, -1}, 165{ NULL, -1},
621}; 166};
622 167
623static struct bond_parm_tbl xmit_hashtype_tbl[] = { 168struct bond_parm_tbl xmit_hashtype_tbl[] = {
624{ "layer2", BOND_XMIT_POLICY_LAYER2}, 169{ "layer2", BOND_XMIT_POLICY_LAYER2},
625{ "layer3+4", BOND_XMIT_POLICY_LAYER34}, 170{ "layer3+4", BOND_XMIT_POLICY_LAYER34},
626{ NULL, -1}, 171{ NULL, -1},
@@ -628,12 +173,11 @@ static struct bond_parm_tbl xmit_hashtype_tbl[] = {
628 173
629/*-------------------------- Forward declarations ---------------------------*/ 174/*-------------------------- Forward declarations ---------------------------*/
630 175
631static inline void bond_set_mode_ops(struct bonding *bond, int mode);
632static void bond_send_gratuitous_arp(struct bonding *bond); 176static void bond_send_gratuitous_arp(struct bonding *bond);
633 177
634/*---------------------------- General routines -----------------------------*/ 178/*---------------------------- General routines -----------------------------*/
635 179
636static const char *bond_mode_name(int mode) 180const char *bond_mode_name(int mode)
637{ 181{
638 switch (mode) { 182 switch (mode) {
639 case BOND_MODE_ROUNDROBIN : 183 case BOND_MODE_ROUNDROBIN :
@@ -910,7 +454,7 @@ static void bond_vlan_rx_add_vid(struct net_device *bond_dev, uint16_t vid)
910 res = bond_add_vlan(bond, vid); 454 res = bond_add_vlan(bond, vid);
911 if (res) { 455 if (res) {
912 printk(KERN_ERR DRV_NAME 456 printk(KERN_ERR DRV_NAME
913 ": %s: Failed to add vlan id %d\n", 457 ": %s: Error: Failed to add vlan id %d\n",
914 bond_dev->name, vid); 458 bond_dev->name, vid);
915 } 459 }
916} 460}
@@ -944,7 +488,7 @@ static void bond_vlan_rx_kill_vid(struct net_device *bond_dev, uint16_t vid)
944 res = bond_del_vlan(bond, vid); 488 res = bond_del_vlan(bond, vid);
945 if (res) { 489 if (res) {
946 printk(KERN_ERR DRV_NAME 490 printk(KERN_ERR DRV_NAME
947 ": %s: Failed to remove vlan id %d\n", 491 ": %s: Error: Failed to remove vlan id %d\n",
948 bond_dev->name, vid); 492 bond_dev->name, vid);
949 } 493 }
950} 494}
@@ -1449,7 +993,7 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
1449 * 993 *
1450 * Warning: Caller must hold curr_slave_lock for writing. 994 * Warning: Caller must hold curr_slave_lock for writing.
1451 */ 995 */
1452static void bond_change_active_slave(struct bonding *bond, struct slave *new_active) 996void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1453{ 997{
1454 struct slave *old_active = bond->curr_active_slave; 998 struct slave *old_active = bond->curr_active_slave;
1455 999
@@ -1523,7 +1067,7 @@ static void bond_change_active_slave(struct bonding *bond, struct slave *new_act
1523 * 1067 *
1524 * Warning: Caller must hold curr_slave_lock for writing. 1068 * Warning: Caller must hold curr_slave_lock for writing.
1525 */ 1069 */
1526static void bond_select_active_slave(struct bonding *bond) 1070void bond_select_active_slave(struct bonding *bond)
1527{ 1071{
1528 struct slave *best_slave; 1072 struct slave *best_slave;
1529 1073
@@ -1591,7 +1135,7 @@ static void bond_detach_slave(struct bonding *bond, struct slave *slave)
1591 1135
1592/*---------------------------------- IOCTL ----------------------------------*/ 1136/*---------------------------------- IOCTL ----------------------------------*/
1593 1137
1594static int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev) 1138int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev)
1595{ 1139{
1596 dprintk("bond_dev=%p\n", bond_dev); 1140 dprintk("bond_dev=%p\n", bond_dev);
1597 dprintk("slave_dev=%p\n", slave_dev); 1141 dprintk("slave_dev=%p\n", slave_dev);
@@ -1631,7 +1175,7 @@ static int bond_compute_features(struct bonding *bond)
1631} 1175}
1632 1176
1633/* enslave device <slave> to bond device <master> */ 1177/* enslave device <slave> to bond device <master> */
1634static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) 1178int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1635{ 1179{
1636 struct bonding *bond = bond_dev->priv; 1180 struct bonding *bond = bond_dev->priv;
1637 struct slave *new_slave = NULL; 1181 struct slave *new_slave = NULL;
@@ -1644,8 +1188,8 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1644 if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL && 1188 if (!bond->params.use_carrier && slave_dev->ethtool_ops == NULL &&
1645 slave_dev->do_ioctl == NULL) { 1189 slave_dev->do_ioctl == NULL) {
1646 printk(KERN_WARNING DRV_NAME 1190 printk(KERN_WARNING DRV_NAME
1647 ": Warning : no link monitoring support for %s\n", 1191 ": %s: Warning: no link monitoring support for %s\n",
1648 slave_dev->name); 1192 bond_dev->name, slave_dev->name);
1649 } 1193 }
1650 1194
1651 /* bond must be initialized by bond_open() before enslaving */ 1195 /* bond must be initialized by bond_open() before enslaving */
@@ -1666,17 +1210,17 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1666 dprintk("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name); 1210 dprintk("%s: NETIF_F_VLAN_CHALLENGED\n", slave_dev->name);
1667 if (!list_empty(&bond->vlan_list)) { 1211 if (!list_empty(&bond->vlan_list)) {
1668 printk(KERN_ERR DRV_NAME 1212 printk(KERN_ERR DRV_NAME
1669 ": Error: cannot enslave VLAN " 1213 ": %s: Error: cannot enslave VLAN "
1670 "challenged slave %s on VLAN enabled " 1214 "challenged slave %s on VLAN enabled "
1671 "bond %s\n", slave_dev->name, 1215 "bond %s\n", bond_dev->name, slave_dev->name,
1672 bond_dev->name); 1216 bond_dev->name);
1673 return -EPERM; 1217 return -EPERM;
1674 } else { 1218 } else {
1675 printk(KERN_WARNING DRV_NAME 1219 printk(KERN_WARNING DRV_NAME
1676 ": Warning: enslaved VLAN challenged " 1220 ": %s: Warning: enslaved VLAN challenged "
1677 "slave %s. Adding VLANs will be blocked as " 1221 "slave %s. Adding VLANs will be blocked as "
1678 "long as %s is part of bond %s\n", 1222 "long as %s is part of bond %s\n",
1679 slave_dev->name, slave_dev->name, 1223 bond_dev->name, slave_dev->name, slave_dev->name,
1680 bond_dev->name); 1224 bond_dev->name);
1681 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 1225 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
1682 } 1226 }
@@ -1706,12 +1250,11 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1706 1250
1707 if (slave_dev->set_mac_address == NULL) { 1251 if (slave_dev->set_mac_address == NULL) {
1708 printk(KERN_ERR DRV_NAME 1252 printk(KERN_ERR DRV_NAME
1709 ": Error: The slave device you specified does " 1253 ": %s: Error: The slave device you specified does "
1710 "not support setting the MAC address.\n"); 1254 "not support setting the MAC address. "
1711 printk(KERN_ERR 1255 "Your kernel likely does not support slave "
1712 "Your kernel likely does not support slave devices.\n"); 1256 "devices.\n", bond_dev->name);
1713 1257 res = -EOPNOTSUPP;
1714 res = -EOPNOTSUPP;
1715 goto err_undo_flags; 1258 goto err_undo_flags;
1716 } 1259 }
1717 1260
@@ -1827,21 +1370,21 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1827 * the messages for netif_carrier. 1370 * the messages for netif_carrier.
1828 */ 1371 */
1829 printk(KERN_WARNING DRV_NAME 1372 printk(KERN_WARNING DRV_NAME
1830 ": Warning: MII and ETHTOOL support not " 1373 ": %s: Warning: MII and ETHTOOL support not "
1831 "available for interface %s, and " 1374 "available for interface %s, and "
1832 "arp_interval/arp_ip_target module parameters " 1375 "arp_interval/arp_ip_target module parameters "
1833 "not specified, thus bonding will not detect " 1376 "not specified, thus bonding will not detect "
1834 "link failures! see bonding.txt for details.\n", 1377 "link failures! see bonding.txt for details.\n",
1835 slave_dev->name); 1378 bond_dev->name, slave_dev->name);
1836 } else if (link_reporting == -1) { 1379 } else if (link_reporting == -1) {
1837 /* unable get link status using mii/ethtool */ 1380 /* unable get link status using mii/ethtool */
1838 printk(KERN_WARNING DRV_NAME 1381 printk(KERN_WARNING DRV_NAME
1839 ": Warning: can't get link status from " 1382 ": %s: Warning: can't get link status from "
1840 "interface %s; the network driver associated " 1383 "interface %s; the network driver associated "
1841 "with this interface does not support MII or " 1384 "with this interface does not support MII or "
1842 "ETHTOOL link status reporting, thus miimon " 1385 "ETHTOOL link status reporting, thus miimon "
1843 "has no effect on this interface.\n", 1386 "has no effect on this interface.\n",
1844 slave_dev->name); 1387 bond_dev->name, slave_dev->name);
1845 } 1388 }
1846 } 1389 }
1847 1390
@@ -1868,15 +1411,15 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1868 if (bond_update_speed_duplex(new_slave) && 1411 if (bond_update_speed_duplex(new_slave) &&
1869 (new_slave->link != BOND_LINK_DOWN)) { 1412 (new_slave->link != BOND_LINK_DOWN)) {
1870 printk(KERN_WARNING DRV_NAME 1413 printk(KERN_WARNING DRV_NAME
1871 ": Warning: failed to get speed and duplex from %s, " 1414 ": %s: Warning: failed to get speed and duplex from %s, "
1872 "assumed to be 100Mb/sec and Full.\n", 1415 "assumed to be 100Mb/sec and Full.\n",
1873 new_slave->dev->name); 1416 bond_dev->name, new_slave->dev->name);
1874 1417
1875 if (bond->params.mode == BOND_MODE_8023AD) { 1418 if (bond->params.mode == BOND_MODE_8023AD) {
1876 printk(KERN_WARNING 1419 printk(KERN_WARNING DRV_NAME
1877 "Operation of 802.3ad mode requires ETHTOOL " 1420 ": %s: Warning: Operation of 802.3ad mode requires ETHTOOL "
1878 "support in base driver for proper aggregator " 1421 "support in base driver for proper aggregator "
1879 "selection.\n"); 1422 "selection.\n", bond_dev->name);
1880 } 1423 }
1881 } 1424 }
1882 1425
@@ -1958,6 +1501,10 @@ static int bond_enslave(struct net_device *bond_dev, struct net_device *slave_de
1958 1501
1959 write_unlock_bh(&bond->lock); 1502 write_unlock_bh(&bond->lock);
1960 1503
1504 res = bond_create_slave_symlinks(bond_dev, slave_dev);
1505 if (res)
1506 goto err_unset_master;
1507
1961 printk(KERN_INFO DRV_NAME 1508 printk(KERN_INFO DRV_NAME
1962 ": %s: enslaving %s as a%s interface with a%s link.\n", 1509 ": %s: enslaving %s as a%s interface with a%s link.\n",
1963 bond_dev->name, slave_dev->name, 1510 bond_dev->name, slave_dev->name,
@@ -1999,7 +1546,7 @@ err_undo_flags:
1999 * for Bonded connections: 1546 * for Bonded connections:
2000 * The first up interface should be left on and all others downed. 1547 * The first up interface should be left on and all others downed.
2001 */ 1548 */
2002static int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) 1549int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
2003{ 1550{
2004 struct bonding *bond = bond_dev->priv; 1551 struct bonding *bond = bond_dev->priv;
2005 struct slave *slave, *oldcurrent; 1552 struct slave *slave, *oldcurrent;
@@ -2010,7 +1557,7 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de
2010 if (!(slave_dev->flags & IFF_SLAVE) || 1557 if (!(slave_dev->flags & IFF_SLAVE) ||
2011 (slave_dev->master != bond_dev)) { 1558 (slave_dev->master != bond_dev)) {
2012 printk(KERN_ERR DRV_NAME 1559 printk(KERN_ERR DRV_NAME
2013 ": Error: %s: cannot release %s.\n", 1560 ": %s: Error: cannot release %s.\n",
2014 bond_dev->name, slave_dev->name); 1561 bond_dev->name, slave_dev->name);
2015 return -EINVAL; 1562 return -EINVAL;
2016 } 1563 }
@@ -2031,11 +1578,12 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de
2031 ETH_ALEN); 1578 ETH_ALEN);
2032 if (!mac_addr_differ && (bond->slave_cnt > 1)) { 1579 if (!mac_addr_differ && (bond->slave_cnt > 1)) {
2033 printk(KERN_WARNING DRV_NAME 1580 printk(KERN_WARNING DRV_NAME
2034 ": Warning: the permanent HWaddr of %s " 1581 ": %s: Warning: the permanent HWaddr of %s "
2035 "- %02X:%02X:%02X:%02X:%02X:%02X - is " 1582 "- %02X:%02X:%02X:%02X:%02X:%02X - is "
2036 "still in use by %s. Set the HWaddr of " 1583 "still in use by %s. Set the HWaddr of "
2037 "%s to a different address to avoid " 1584 "%s to a different address to avoid "
2038 "conflicts.\n", 1585 "conflicts.\n",
1586 bond_dev->name,
2039 slave_dev->name, 1587 slave_dev->name,
2040 slave->perm_hwaddr[0], 1588 slave->perm_hwaddr[0],
2041 slave->perm_hwaddr[1], 1589 slave->perm_hwaddr[1],
@@ -2111,24 +1659,28 @@ static int bond_release(struct net_device *bond_dev, struct net_device *slave_de
2111 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 1659 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
2112 } else { 1660 } else {
2113 printk(KERN_WARNING DRV_NAME 1661 printk(KERN_WARNING DRV_NAME
2114 ": Warning: clearing HW address of %s while it " 1662 ": %s: Warning: clearing HW address of %s while it "
2115 "still has VLANs.\n", 1663 "still has VLANs.\n",
2116 bond_dev->name); 1664 bond_dev->name, bond_dev->name);
2117 printk(KERN_WARNING DRV_NAME 1665 printk(KERN_WARNING DRV_NAME
2118 ": When re-adding slaves, make sure the bond's " 1666 ": %s: When re-adding slaves, make sure the bond's "
2119 "HW address matches its VLANs'.\n"); 1667 "HW address matches its VLANs'.\n",
1668 bond_dev->name);
2120 } 1669 }
2121 } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) && 1670 } else if ((bond_dev->features & NETIF_F_VLAN_CHALLENGED) &&
2122 !bond_has_challenged_slaves(bond)) { 1671 !bond_has_challenged_slaves(bond)) {
2123 printk(KERN_INFO DRV_NAME 1672 printk(KERN_INFO DRV_NAME
2124 ": last VLAN challenged slave %s " 1673 ": %s: last VLAN challenged slave %s "
2125 "left bond %s. VLAN blocking is removed\n", 1674 "left bond %s. VLAN blocking is removed\n",
2126 slave_dev->name, bond_dev->name); 1675 bond_dev->name, slave_dev->name, bond_dev->name);
2127 bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED; 1676 bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED;
2128 } 1677 }
2129 1678
2130 write_unlock_bh(&bond->lock); 1679 write_unlock_bh(&bond->lock);
2131 1680
1681 /* must do this from outside any spinlocks */
1682 bond_destroy_slave_symlinks(bond_dev, slave_dev);
1683
2132 bond_del_vlans_from_slave(bond, slave_dev); 1684 bond_del_vlans_from_slave(bond, slave_dev);
2133 1685
2134 /* If the mode USES_PRIMARY, then we should only remove its 1686 /* If the mode USES_PRIMARY, then we should only remove its
@@ -2220,6 +1772,7 @@ static int bond_release_all(struct net_device *bond_dev)
2220 */ 1772 */
2221 write_unlock_bh(&bond->lock); 1773 write_unlock_bh(&bond->lock);
2222 1774
1775 bond_destroy_slave_symlinks(bond_dev, slave_dev);
2223 bond_del_vlans_from_slave(bond, slave_dev); 1776 bond_del_vlans_from_slave(bond, slave_dev);
2224 1777
2225 /* If the mode USES_PRIMARY, then we should only remove its 1778 /* If the mode USES_PRIMARY, then we should only remove its
@@ -2274,12 +1827,13 @@ static int bond_release_all(struct net_device *bond_dev)
2274 bond_dev->features |= NETIF_F_VLAN_CHALLENGED; 1827 bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
2275 } else { 1828 } else {
2276 printk(KERN_WARNING DRV_NAME 1829 printk(KERN_WARNING DRV_NAME
2277 ": Warning: clearing HW address of %s while it " 1830 ": %s: Warning: clearing HW address of %s while it "
2278 "still has VLANs.\n", 1831 "still has VLANs.\n",
2279 bond_dev->name); 1832 bond_dev->name, bond_dev->name);
2280 printk(KERN_WARNING DRV_NAME 1833 printk(KERN_WARNING DRV_NAME
2281 ": When re-adding slaves, make sure the bond's " 1834 ": %s: When re-adding slaves, make sure the bond's "
2282 "HW address matches its VLANs'.\n"); 1835 "HW address matches its VLANs'.\n",
1836 bond_dev->name);
2283 } 1837 }
2284 1838
2285 printk(KERN_INFO DRV_NAME 1839 printk(KERN_INFO DRV_NAME
@@ -2397,7 +1951,7 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
2397/*-------------------------------- Monitoring -------------------------------*/ 1951/*-------------------------------- Monitoring -------------------------------*/
2398 1952
2399/* this function is called regularly to monitor each slave's link. */ 1953/* this function is called regularly to monitor each slave's link. */
2400static void bond_mii_monitor(struct net_device *bond_dev) 1954void bond_mii_monitor(struct net_device *bond_dev)
2401{ 1955{
2402 struct bonding *bond = bond_dev->priv; 1956 struct bonding *bond = bond_dev->priv;
2403 struct slave *slave, *oldcurrent; 1957 struct slave *slave, *oldcurrent;
@@ -2596,8 +2150,11 @@ static void bond_mii_monitor(struct net_device *bond_dev)
2596 break; 2150 break;
2597 default: 2151 default:
2598 /* Should not happen */ 2152 /* Should not happen */
2599 printk(KERN_ERR "bonding: Error: %s Illegal value (link=%d)\n", 2153 printk(KERN_ERR DRV_NAME
2600 slave->dev->name, slave->link); 2154 ": %s: Error: %s Illegal value (link=%d)\n",
2155 bond_dev->name,
2156 slave->dev->name,
2157 slave->link);
2601 goto out; 2158 goto out;
2602 } /* end of switch (slave->link) */ 2159 } /* end of switch (slave->link) */
2603 2160
@@ -2721,7 +2278,9 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2721 struct flowi fl; 2278 struct flowi fl;
2722 struct rtable *rt; 2279 struct rtable *rt;
2723 2280
2724 for (i = 0; (i < BOND_MAX_ARP_TARGETS) && targets[i]; i++) { 2281 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
2282 if (!targets[i])
2283 continue;
2725 dprintk("basa: target %x\n", targets[i]); 2284 dprintk("basa: target %x\n", targets[i]);
2726 if (list_empty(&bond->vlan_list)) { 2285 if (list_empty(&bond->vlan_list)) {
2727 dprintk("basa: empty vlan: arp_send\n"); 2286 dprintk("basa: empty vlan: arp_send\n");
@@ -2825,7 +2384,7 @@ static void bond_send_gratuitous_arp(struct bonding *bond)
2825 * arp is transmitted to generate traffic. see activebackup_arp_monitor for 2384 * arp is transmitted to generate traffic. see activebackup_arp_monitor for
2826 * arp monitoring in active backup mode. 2385 * arp monitoring in active backup mode.
2827 */ 2386 */
2828static void bond_loadbalance_arp_mon(struct net_device *bond_dev) 2387void bond_loadbalance_arp_mon(struct net_device *bond_dev)
2829{ 2388{
2830 struct bonding *bond = bond_dev->priv; 2389 struct bonding *bond = bond_dev->priv;
2831 struct slave *slave, *oldcurrent; 2390 struct slave *slave, *oldcurrent;
@@ -2963,7 +2522,7 @@ out:
2963 * may have received. 2522 * may have received.
2964 * see loadbalance_arp_monitor for arp monitoring in load balancing mode 2523 * see loadbalance_arp_monitor for arp monitoring in load balancing mode
2965 */ 2524 */
2966static void bond_activebackup_arp_mon(struct net_device *bond_dev) 2525void bond_activebackup_arp_mon(struct net_device *bond_dev)
2967{ 2526{
2968 struct bonding *bond = bond_dev->priv; 2527 struct bonding *bond = bond_dev->priv;
2969 struct slave *slave; 2528 struct slave *slave;
@@ -3249,6 +2808,8 @@ static void bond_info_show_master(struct seq_file *seq)
3249{ 2808{
3250 struct bonding *bond = seq->private; 2809 struct bonding *bond = seq->private;
3251 struct slave *curr; 2810 struct slave *curr;
2811 int i;
2812 u32 target;
3252 2813
3253 read_lock(&bond->curr_slave_lock); 2814 read_lock(&bond->curr_slave_lock);
3254 curr = bond->curr_active_slave; 2815 curr = bond->curr_active_slave;
@@ -3257,10 +2818,17 @@ static void bond_info_show_master(struct seq_file *seq)
3257 seq_printf(seq, "Bonding Mode: %s\n", 2818 seq_printf(seq, "Bonding Mode: %s\n",
3258 bond_mode_name(bond->params.mode)); 2819 bond_mode_name(bond->params.mode));
3259 2820
2821 if (bond->params.mode == BOND_MODE_XOR ||
2822 bond->params.mode == BOND_MODE_8023AD) {
2823 seq_printf(seq, "Transmit Hash Policy: %s (%d)\n",
2824 xmit_hashtype_tbl[bond->params.xmit_policy].modename,
2825 bond->params.xmit_policy);
2826 }
2827
3260 if (USES_PRIMARY(bond->params.mode)) { 2828 if (USES_PRIMARY(bond->params.mode)) {
3261 seq_printf(seq, "Primary Slave: %s\n", 2829 seq_printf(seq, "Primary Slave: %s\n",
3262 (bond->params.primary[0]) ? 2830 (bond->primary_slave) ?
3263 bond->params.primary : "None"); 2831 bond->primary_slave->dev->name : "None");
3264 2832
3265 seq_printf(seq, "Currently Active Slave: %s\n", 2833 seq_printf(seq, "Currently Active Slave: %s\n",
3266 (curr) ? curr->dev->name : "None"); 2834 (curr) ? curr->dev->name : "None");
@@ -3273,6 +2841,27 @@ static void bond_info_show_master(struct seq_file *seq)
3273 seq_printf(seq, "Down Delay (ms): %d\n", 2841 seq_printf(seq, "Down Delay (ms): %d\n",
3274 bond->params.downdelay * bond->params.miimon); 2842 bond->params.downdelay * bond->params.miimon);
3275 2843
2844
2845 /* ARP information */
2846 if(bond->params.arp_interval > 0) {
2847 int printed=0;
2848 seq_printf(seq, "ARP Polling Interval (ms): %d\n",
2849 bond->params.arp_interval);
2850
2851 seq_printf(seq, "ARP IP target/s (n.n.n.n form):");
2852
2853 for(i = 0; (i < BOND_MAX_ARP_TARGETS) ;i++) {
2854 if (!bond->params.arp_targets[i])
2855 continue;
2856 if (printed)
2857 seq_printf(seq, ",");
2858 target = ntohl(bond->params.arp_targets[i]);
2859 seq_printf(seq, " %d.%d.%d.%d", HIPQUAD(target));
2860 printed = 1;
2861 }
2862 seq_printf(seq, "\n");
2863 }
2864
3276 if (bond->params.mode == BOND_MODE_8023AD) { 2865 if (bond->params.mode == BOND_MODE_8023AD) {
3277 struct ad_info ad_info; 2866 struct ad_info ad_info;
3278 2867
@@ -3478,7 +3067,10 @@ static int bond_event_changename(struct bonding *bond)
3478 bond_remove_proc_entry(bond); 3067 bond_remove_proc_entry(bond);
3479 bond_create_proc_entry(bond); 3068 bond_create_proc_entry(bond);
3480#endif 3069#endif
3481 3070 down_write(&(bonding_rwsem));
3071 bond_destroy_sysfs_entry(bond);
3072 bond_create_sysfs_entry(bond);
3073 up_write(&(bonding_rwsem));
3482 return NOTIFY_DONE; 3074 return NOTIFY_DONE;
3483} 3075}
3484 3076
@@ -3955,6 +3547,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3955 return -EPERM; 3547 return -EPERM;
3956 } 3548 }
3957 3549
3550 down_write(&(bonding_rwsem));
3958 slave_dev = dev_get_by_name(ifr->ifr_slave); 3551 slave_dev = dev_get_by_name(ifr->ifr_slave);
3959 3552
3960 dprintk("slave_dev=%p: \n", slave_dev); 3553 dprintk("slave_dev=%p: \n", slave_dev);
@@ -3987,6 +3580,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd
3987 dev_put(slave_dev); 3580 dev_put(slave_dev);
3988 } 3581 }
3989 3582
3583 up_write(&(bonding_rwsem));
3990 return res; 3584 return res;
3991} 3585}
3992 3586
@@ -4071,6 +3665,7 @@ static int bond_change_mtu(struct net_device *bond_dev, int new_mtu)
4071 bond_for_each_slave(bond, slave, i) { 3665 bond_for_each_slave(bond, slave, i) {
4072 dprintk("s %p s->p %p c_m %p\n", slave, 3666 dprintk("s %p s->p %p c_m %p\n", slave,
4073 slave->prev, slave->dev->change_mtu); 3667 slave->prev, slave->dev->change_mtu);
3668
4074 res = dev_set_mtu(slave->dev, new_mtu); 3669 res = dev_set_mtu(slave->dev, new_mtu);
4075 3670
4076 if (res) { 3671 if (res) {
@@ -4397,8 +3992,9 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev)
4397 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); 3992 struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC);
4398 if (!skb2) { 3993 if (!skb2) {
4399 printk(KERN_ERR DRV_NAME 3994 printk(KERN_ERR DRV_NAME
4400 ": Error: bond_xmit_broadcast(): " 3995 ": %s: Error: bond_xmit_broadcast(): "
4401 "skb_clone() failed\n"); 3996 "skb_clone() failed\n",
3997 bond_dev->name);
4402 continue; 3998 continue;
4403 } 3999 }
4404 4000
@@ -4431,7 +4027,7 @@ out:
4431/* 4027/*
4432 * set bond mode specific net device operations 4028 * set bond mode specific net device operations
4433 */ 4029 */
4434static inline void bond_set_mode_ops(struct bonding *bond, int mode) 4030void bond_set_mode_ops(struct bonding *bond, int mode)
4435{ 4031{
4436 struct net_device *bond_dev = bond->dev; 4032 struct net_device *bond_dev = bond->dev;
4437 4033
@@ -4467,7 +4063,8 @@ static inline void bond_set_mode_ops(struct bonding *bond, int mode)
4467 default: 4063 default:
4468 /* Should never happen, mode already checked */ 4064 /* Should never happen, mode already checked */
4469 printk(KERN_ERR DRV_NAME 4065 printk(KERN_ERR DRV_NAME
4470 ": Error: Unknown bonding mode %d\n", 4066 ": %s: Error: Unknown bonding mode %d\n",
4067 bond_dev->name,
4471 mode); 4068 mode);
4472 break; 4069 break;
4473 } 4070 }
@@ -4491,7 +4088,7 @@ static struct ethtool_ops bond_ethtool_ops = {
4491 * Does not allocate but creates a /proc entry. 4088 * Does not allocate but creates a /proc entry.
4492 * Allowed to fail. 4089 * Allowed to fail.
4493 */ 4090 */
4494static int __init bond_init(struct net_device *bond_dev, struct bond_params *params) 4091static int bond_init(struct net_device *bond_dev, struct bond_params *params)
4495{ 4092{
4496 struct bonding *bond = bond_dev->priv; 4093 struct bonding *bond = bond_dev->priv;
4497 4094
@@ -4565,7 +4162,7 @@ static int __init bond_init(struct net_device *bond_dev, struct bond_params *par
4565/* De-initialize device specific data. 4162/* De-initialize device specific data.
4566 * Caller must hold rtnl_lock. 4163 * Caller must hold rtnl_lock.
4567 */ 4164 */
4568static inline void bond_deinit(struct net_device *bond_dev) 4165void bond_deinit(struct net_device *bond_dev)
4569{ 4166{
4570 struct bonding *bond = bond_dev->priv; 4167 struct bonding *bond = bond_dev->priv;
4571 4168
@@ -4601,7 +4198,7 @@ static void bond_free_all(void)
4601 * Convert string input module parms. Accept either the 4198 * Convert string input module parms. Accept either the
4602 * number of the mode or its string name. 4199 * number of the mode or its string name.
4603 */ 4200 */
4604static inline int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl) 4201int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl)
4605{ 4202{
4606 int i; 4203 int i;
4607 4204
@@ -4670,7 +4267,7 @@ static int bond_check_params(struct bond_params *params)
4670 if (max_bonds < 1 || max_bonds > INT_MAX) { 4267 if (max_bonds < 1 || max_bonds > INT_MAX) {
4671 printk(KERN_WARNING DRV_NAME 4268 printk(KERN_WARNING DRV_NAME
4672 ": Warning: max_bonds (%d) not in range %d-%d, so it " 4269 ": Warning: max_bonds (%d) not in range %d-%d, so it "
4673 "was reset to BOND_DEFAULT_MAX_BONDS (%d)", 4270 "was reset to BOND_DEFAULT_MAX_BONDS (%d)\n",
4674 max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS); 4271 max_bonds, 1, INT_MAX, BOND_DEFAULT_MAX_BONDS);
4675 max_bonds = BOND_DEFAULT_MAX_BONDS; 4272 max_bonds = BOND_DEFAULT_MAX_BONDS;
4676 } 4273 }
@@ -4881,81 +4478,96 @@ static int bond_check_params(struct bond_params *params)
4881 return 0; 4478 return 0;
4882} 4479}
4883 4480
4481/* Create a new bond based on the specified name and bonding parameters.
4482 * Caller must NOT hold rtnl_lock; we need to release it here before we
4483 * set up our sysfs entries.
4484 */
4485int bond_create(char *name, struct bond_params *params, struct bonding **newbond)
4486{
4487 struct net_device *bond_dev;
4488 int res;
4489
4490 rtnl_lock();
4491 bond_dev = alloc_netdev(sizeof(struct bonding), name, ether_setup);
4492 if (!bond_dev) {
4493 printk(KERN_ERR DRV_NAME
4494 ": %s: eek! can't alloc netdev!\n",
4495 name);
4496 res = -ENOMEM;
4497 goto out_rtnl;
4498 }
4499
4500 /* bond_init() must be called after dev_alloc_name() (for the
4501 * /proc files), but before register_netdevice(), because we
4502 * need to set function pointers.
4503 */
4504
4505 res = bond_init(bond_dev, params);
4506 if (res < 0) {
4507 goto out_netdev;
4508 }
4509
4510 SET_MODULE_OWNER(bond_dev);
4511
4512 res = register_netdevice(bond_dev);
4513 if (res < 0) {
4514 goto out_bond;
4515 }
4516 if (newbond)
4517 *newbond = bond_dev->priv;
4518
4519 rtnl_unlock(); /* allows sysfs registration of net device */
4520 res = bond_create_sysfs_entry(bond_dev->priv);
4521 goto done;
4522out_bond:
4523 bond_deinit(bond_dev);
4524out_netdev:
4525 free_netdev(bond_dev);
4526out_rtnl:
4527 rtnl_unlock();
4528done:
4529 return res;
4530}
4531
4884static int __init bonding_init(void) 4532static int __init bonding_init(void)
4885{ 4533{
4886 struct bond_params params;
4887 int i; 4534 int i;
4888 int res; 4535 int res;
4536 char new_bond_name[8]; /* Enough room for 999 bonds at init. */
4889 4537
4890 printk(KERN_INFO "%s", version); 4538 printk(KERN_INFO "%s", version);
4891 4539
4892 res = bond_check_params(&params); 4540 res = bond_check_params(&bonding_defaults);
4893 if (res) { 4541 if (res) {
4894 return res; 4542 goto out;
4895 } 4543 }
4896 4544
4897 rtnl_lock();
4898
4899#ifdef CONFIG_PROC_FS 4545#ifdef CONFIG_PROC_FS
4900 bond_create_proc_dir(); 4546 bond_create_proc_dir();
4901#endif 4547#endif
4902
4903 for (i = 0; i < max_bonds; i++) { 4548 for (i = 0; i < max_bonds; i++) {
4904 struct net_device *bond_dev; 4549 sprintf(new_bond_name, "bond%d",i);
4905 4550 res = bond_create(new_bond_name,&bonding_defaults, NULL);
4906 bond_dev = alloc_netdev(sizeof(struct bonding), "", ether_setup); 4551 if (res)
4907 if (!bond_dev) { 4552 goto err;
4908 res = -ENOMEM;
4909 goto out_err;
4910 }
4911
4912 res = dev_alloc_name(bond_dev, "bond%d");
4913 if (res < 0) {
4914 free_netdev(bond_dev);
4915 goto out_err;
4916 }
4917
4918 /* bond_init() must be called after dev_alloc_name() (for the
4919 * /proc files), but before register_netdevice(), because we
4920 * need to set function pointers.
4921 */
4922 res = bond_init(bond_dev, &params);
4923 if (res < 0) {
4924 free_netdev(bond_dev);
4925 goto out_err;
4926 }
4927
4928 SET_MODULE_OWNER(bond_dev);
4929
4930 res = register_netdevice(bond_dev);
4931 if (res < 0) {
4932 bond_deinit(bond_dev);
4933 free_netdev(bond_dev);
4934 goto out_err;
4935 }
4936 } 4553 }
4937 4554
4938 rtnl_unlock(); 4555 res = bond_create_sysfs();
4556 if (res)
4557 goto err;
4558
4939 register_netdevice_notifier(&bond_netdev_notifier); 4559 register_netdevice_notifier(&bond_netdev_notifier);
4940 register_inetaddr_notifier(&bond_inetaddr_notifier); 4560 register_inetaddr_notifier(&bond_inetaddr_notifier);
4941 4561
4942 return 0; 4562 goto out;
4943 4563err:
4944out_err:
4945 /*
4946 * rtnl_unlock() will run netdev_run_todo(), putting the
4947 * thus-far-registered bonding devices into a state which
4948 * unregigister_netdevice() will accept
4949 */
4950 rtnl_unlock();
4951 rtnl_lock(); 4564 rtnl_lock();
4952
4953 /* free and unregister all bonds that were successfully added */
4954 bond_free_all(); 4565 bond_free_all();
4955 4566 bond_destroy_sysfs();
4956 rtnl_unlock(); 4567 rtnl_unlock();
4957 4568out:
4958 return res; 4569 return res;
4570
4959} 4571}
4960 4572
4961static void __exit bonding_exit(void) 4573static void __exit bonding_exit(void)
@@ -4965,6 +4577,7 @@ static void __exit bonding_exit(void)
4965 4577
4966 rtnl_lock(); 4578 rtnl_lock();
4967 bond_free_all(); 4579 bond_free_all();
4580 bond_destroy_sysfs();
4968 rtnl_unlock(); 4581 rtnl_unlock();
4969} 4582}
4970 4583
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
new file mode 100644
index 000000000000..32d13da43a0b
--- /dev/null
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -0,0 +1,1358 @@
1
2/*
3 * Copyright(c) 2004-2005 Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 * The full GNU General Public License is included in this distribution in the
20 * file called LICENSE.
21 *
22 */
23#include <linux/config.h>
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/sched.h>
27#include <linux/device.h>
28#include <linux/sysdev.h>
29#include <linux/fs.h>
30#include <linux/types.h>
31#include <linux/string.h>
32#include <linux/netdevice.h>
33#include <linux/inetdevice.h>
34#include <linux/in.h>
35#include <linux/sysfs.h>
36#include <linux/string.h>
37#include <linux/ctype.h>
38#include <linux/inet.h>
39#include <linux/rtnetlink.h>
40
41/* #define BONDING_DEBUG 1 */
42#include "bonding.h"
43#define to_class_dev(obj) container_of(obj,struct class_device,kobj)
44#define to_net_dev(class) container_of(class, struct net_device, class_dev)
45#define to_bond(cd) ((struct bonding *)(to_net_dev(cd)->priv))
46
47/*---------------------------- Declarations -------------------------------*/
48
49
50extern struct list_head bond_dev_list;
51extern struct bond_params bonding_defaults;
52extern struct bond_parm_tbl bond_mode_tbl[];
53extern struct bond_parm_tbl bond_lacp_tbl[];
54extern struct bond_parm_tbl xmit_hashtype_tbl[];
55
56static int expected_refcount = -1;
57static struct class *netdev_class;
58/*--------------------------- Data Structures -----------------------------*/
59
60/* Bonding sysfs lock. Why can't we just use the subsytem lock?
61 * Because kobject_register tries to acquire the subsystem lock. If
62 * we already hold the lock (which we would if the user was creating
63 * a new bond through the sysfs interface), we deadlock.
64 * This lock is only needed when deleting a bond - we need to make sure
65 * that we don't collide with an ongoing ioctl.
66 */
67
68struct rw_semaphore bonding_rwsem;
69
70
71
72
73/*------------------------------ Functions --------------------------------*/
74
75/*
76 * "show" function for the bond_masters attribute.
77 * The class parameter is ignored.
78 */
79static ssize_t bonding_show_bonds(struct class *cls, char *buffer)
80{
81 int res = 0;
82 struct bonding *bond;
83
84 down_read(&(bonding_rwsem));
85
86 list_for_each_entry(bond, &bond_dev_list, bond_list) {
87 if (res > (PAGE_SIZE - IFNAMSIZ)) {
88 /* not enough space for another interface name */
89 if ((PAGE_SIZE - res) > 10)
90 res = PAGE_SIZE - 10;
91 res += sprintf(buffer + res, "++more++");
92 break;
93 }
94 res += sprintf(buffer + res, "%s ",
95 bond->dev->name);
96 }
97 res += sprintf(buffer + res, "\n");
98 res++;
99 up_read(&(bonding_rwsem));
100 return res;
101}
102
103/*
104 * "store" function for the bond_masters attribute. This is what
105 * creates and deletes entire bonds.
106 *
107 * The class parameter is ignored.
108 *
109 */
110
111static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t count)
112{
113 char command[IFNAMSIZ + 1] = {0, };
114 char *ifname;
115 int res = count;
116 struct bonding *bond;
117 struct bonding *nxt;
118
119 down_write(&(bonding_rwsem));
120 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
121 ifname = command + 1;
122 if ((strlen(command) <= 1) ||
123 !dev_valid_name(ifname))
124 goto err_no_cmd;
125
126 if (command[0] == '+') {
127
128 /* Check to see if the bond already exists. */
129 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list)
130 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) {
131 printk(KERN_ERR DRV_NAME
132 ": cannot add bond %s; it already exists\n",
133 ifname);
134 res = -EPERM;
135 goto out;
136 }
137
138 printk(KERN_INFO DRV_NAME
139 ": %s is being created...\n", ifname);
140 if (bond_create(ifname, &bonding_defaults, &bond)) {
141 printk(KERN_INFO DRV_NAME
142 ": %s interface already exists. Bond creation failed.\n",
143 ifname);
144 res = -EPERM;
145 }
146 goto out;
147 }
148
149 if (command[0] == '-') {
150 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list)
151 if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) {
152 rtnl_lock();
153 /* check the ref count on the bond's kobject.
154 * If it's > expected, then there's a file open,
155 * and we have to fail.
156 */
157 if (atomic_read(&bond->dev->class_dev.kobj.kref.refcount)
158 > expected_refcount){
159 rtnl_unlock();
160 printk(KERN_INFO DRV_NAME
161 ": Unable remove bond %s due to open references.\n",
162 ifname);
163 res = -EPERM;
164 goto out;
165 }
166 printk(KERN_INFO DRV_NAME
167 ": %s is being deleted...\n",
168 bond->dev->name);
169 unregister_netdevice(bond->dev);
170 bond_deinit(bond->dev);
171 bond_destroy_sysfs_entry(bond);
172 rtnl_unlock();
173 goto out;
174 }
175
176 printk(KERN_ERR DRV_NAME
177 ": unable to delete non-existent bond %s\n", ifname);
178 res = -ENODEV;
179 goto out;
180 }
181
182err_no_cmd:
183 printk(KERN_ERR DRV_NAME
184 ": no command found in bonding_masters. Use +ifname or -ifname.\n");
185 res = -EPERM;
186
187 /* Always return either count or an error. If you return 0, you'll
188 * get called forever, which is bad.
189 */
190out:
191 up_write(&(bonding_rwsem));
192 return res;
193}
194/* class attribute for bond_masters file. This ends up in /sys/class/net */
195static CLASS_ATTR(bonding_masters, S_IWUSR | S_IRUGO,
196 bonding_show_bonds, bonding_store_bonds);
197
198int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave)
199{
200 char linkname[IFNAMSIZ+7];
201 int ret = 0;
202
203 /* first, create a link from the slave back to the master */
204 ret = sysfs_create_link(&(slave->class_dev.kobj), &(master->class_dev.kobj),
205 "master");
206 if (ret)
207 return ret;
208 /* next, create a link from the master to the slave */
209 sprintf(linkname,"slave_%s",slave->name);
210 ret = sysfs_create_link(&(master->class_dev.kobj), &(slave->class_dev.kobj),
211 linkname);
212 return ret;
213
214}
215
216void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave)
217{
218 char linkname[IFNAMSIZ+7];
219
220 sysfs_remove_link(&(slave->class_dev.kobj), "master");
221 sprintf(linkname,"slave_%s",slave->name);
222 sysfs_remove_link(&(master->class_dev.kobj), linkname);
223}
224
225
226/*
227 * Show the slaves in the current bond.
228 */
229static ssize_t bonding_show_slaves(struct class_device *cd, char *buf)
230{
231 struct slave *slave;
232 int i, res = 0;
233 struct bonding *bond = to_bond(cd);
234
235 read_lock_bh(&bond->lock);
236 bond_for_each_slave(bond, slave, i) {
237 if (res > (PAGE_SIZE - IFNAMSIZ)) {
238 /* not enough space for another interface name */
239 if ((PAGE_SIZE - res) > 10)
240 res = PAGE_SIZE - 10;
241 res += sprintf(buf + res, "++more++");
242 break;
243 }
244 res += sprintf(buf + res, "%s ", slave->dev->name);
245 }
246 read_unlock_bh(&bond->lock);
247 res += sprintf(buf + res, "\n");
248 res++;
249 return res;
250}
251
252/*
253 * Set the slaves in the current bond. The bond interface must be
254 * up for this to succeed.
255 * This function is largely the same flow as bonding_update_bonds().
256 */
257static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer, size_t count)
258{
259 char command[IFNAMSIZ + 1] = { 0, };
260 char *ifname;
261 int i, res, found, ret = count;
262 struct slave *slave;
263 struct net_device *dev = 0;
264 struct bonding *bond = to_bond(cd);
265
266 /* Quick sanity check -- is the bond interface up? */
267 if (!(bond->dev->flags & IFF_UP)) {
268 printk(KERN_ERR DRV_NAME
269 ": %s: Unable to update slaves because interface is down.\n",
270 bond->dev->name);
271 ret = -EPERM;
272 goto out;
273 }
274
275 /* Note: We can't hold bond->lock here, as bond_create grabs it. */
276
277 sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
278 ifname = command + 1;
279 if ((strlen(command) <= 1) ||
280 !dev_valid_name(ifname))
281 goto err_no_cmd;
282
283 if (command[0] == '+') {
284
285 /* Got a slave name in ifname. Is it already in the list? */
286 found = 0;
287 read_lock_bh(&bond->lock);
288 bond_for_each_slave(bond, slave, i)
289 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
290 printk(KERN_ERR DRV_NAME
291 ": %s: Interface %s is already enslaved!\n",
292 bond->dev->name, ifname);
293 ret = -EPERM;
294 read_unlock_bh(&bond->lock);
295 goto out;
296 }
297
298 read_unlock_bh(&bond->lock);
299 printk(KERN_INFO DRV_NAME ": %s: Adding slave %s.\n",
300 bond->dev->name, ifname);
301 dev = dev_get_by_name(ifname);
302 if (!dev) {
303 printk(KERN_INFO DRV_NAME
304 ": %s: Interface %s does not exist!\n",
305 bond->dev->name, ifname);
306 ret = -EPERM;
307 goto out;
308 }
309 else
310 dev_put(dev);
311
312 if (dev->flags & IFF_UP) {
313 printk(KERN_ERR DRV_NAME
314 ": %s: Error: Unable to enslave %s "
315 "because it is already up.\n",
316 bond->dev->name, dev->name);
317 ret = -EPERM;
318 goto out;
319 }
320 /* If this is the first slave, then we need to set
321 the master's hardware address to be the same as the
322 slave's. */
323 if (!(*((u32 *) & (bond->dev->dev_addr[0])))) {
324 memcpy(bond->dev->dev_addr, dev->dev_addr,
325 dev->addr_len);
326 }
327
328 /* Set the slave's MTU to match the bond */
329 if (dev->mtu != bond->dev->mtu) {
330 if (dev->change_mtu) {
331 res = dev->change_mtu(dev,
332 bond->dev->mtu);
333 if (res) {
334 ret = res;
335 goto out;
336 }
337 } else {
338 dev->mtu = bond->dev->mtu;
339 }
340 }
341 rtnl_lock();
342 res = bond_enslave(bond->dev, dev);
343 rtnl_unlock();
344 if (res) {
345 ret = res;
346 }
347 goto out;
348 }
349
350 if (command[0] == '-') {
351 dev = NULL;
352 bond_for_each_slave(bond, slave, i)
353 if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
354 dev = slave->dev;
355 break;
356 }
357 if (dev) {
358 printk(KERN_INFO DRV_NAME ": %s: Removing slave %s\n",
359 bond->dev->name, dev->name);
360 rtnl_lock();
361 res = bond_release(bond->dev, dev);
362 rtnl_unlock();
363 if (res) {
364 ret = res;
365 goto out;
366 }
367 /* set the slave MTU to the default */
368 if (dev->change_mtu) {
369 dev->change_mtu(dev, 1500);
370 } else {
371 dev->mtu = 1500;
372 }
373 }
374 else {
375 printk(KERN_ERR DRV_NAME ": unable to remove non-existent slave %s for bond %s.\n",
376 ifname, bond->dev->name);
377 ret = -ENODEV;
378 }
379 goto out;
380 }
381
382err_no_cmd:
383 printk(KERN_ERR DRV_NAME ": no command found in slaves file for bond %s. Use +ifname or -ifname.\n", bond->dev->name);
384 ret = -EPERM;
385
386out:
387 return ret;
388}
389
390static CLASS_DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, bonding_store_slaves);
391
392/*
393 * Show and set the bonding mode. The bond interface must be down to
394 * change the mode.
395 */
396static ssize_t bonding_show_mode(struct class_device *cd, char *buf)
397{
398 struct bonding *bond = to_bond(cd);
399
400 return sprintf(buf, "%s %d\n",
401 bond_mode_tbl[bond->params.mode].modename,
402 bond->params.mode) + 1;
403}
404
405static ssize_t bonding_store_mode(struct class_device *cd, const char *buf, size_t count)
406{
407 int new_value, ret = count;
408 struct bonding *bond = to_bond(cd);
409
410 if (bond->dev->flags & IFF_UP) {
411 printk(KERN_ERR DRV_NAME
412 ": unable to update mode of %s because interface is up.\n",
413 bond->dev->name);
414 ret = -EPERM;
415 goto out;
416 }
417
418 new_value = bond_parse_parm((char *)buf, bond_mode_tbl);
419 if (new_value < 0) {
420 printk(KERN_ERR DRV_NAME
421 ": %s: Ignoring invalid mode value %.*s.\n",
422 bond->dev->name,
423 (int)strlen(buf) - 1, buf);
424 ret = -EINVAL;
425 goto out;
426 } else {
427 bond->params.mode = new_value;
428 bond_set_mode_ops(bond, bond->params.mode);
429 printk(KERN_INFO DRV_NAME ": %s: setting mode to %s (%d).\n",
430 bond->dev->name, bond_mode_tbl[new_value].modename, new_value);
431 }
432out:
433 return ret;
434}
435static CLASS_DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, bonding_show_mode, bonding_store_mode);
436
437/*
438 * Show and set the bonding transmit hash method. The bond interface must be down to
439 * change the xmit hash policy.
440 */
441static ssize_t bonding_show_xmit_hash(struct class_device *cd, char *buf)
442{
443 int count;
444 struct bonding *bond = to_bond(cd);
445
446 if ((bond->params.mode != BOND_MODE_XOR) &&
447 (bond->params.mode != BOND_MODE_8023AD)) {
448 // Not Applicable
449 count = sprintf(buf, "NA\n") + 1;
450 } else {
451 count = sprintf(buf, "%s %d\n",
452 xmit_hashtype_tbl[bond->params.xmit_policy].modename,
453 bond->params.xmit_policy) + 1;
454 }
455
456 return count;
457}
458
459static ssize_t bonding_store_xmit_hash(struct class_device *cd, const char *buf, size_t count)
460{
461 int new_value, ret = count;
462 struct bonding *bond = to_bond(cd);
463
464 if (bond->dev->flags & IFF_UP) {
465 printk(KERN_ERR DRV_NAME
466 "%s: Interface is up. Unable to update xmit policy.\n",
467 bond->dev->name);
468 ret = -EPERM;
469 goto out;
470 }
471
472 if ((bond->params.mode != BOND_MODE_XOR) &&
473 (bond->params.mode != BOND_MODE_8023AD)) {
474 printk(KERN_ERR DRV_NAME
475 "%s: Transmit hash policy is irrelevant in this mode.\n",
476 bond->dev->name);
477 ret = -EPERM;
478 goto out;
479 }
480
481 new_value = bond_parse_parm((char *)buf, xmit_hashtype_tbl);
482 if (new_value < 0) {
483 printk(KERN_ERR DRV_NAME
484 ": %s: Ignoring invalid xmit hash policy value %.*s.\n",
485 bond->dev->name,
486 (int)strlen(buf) - 1, buf);
487 ret = -EINVAL;
488 goto out;
489 } else {
490 bond->params.xmit_policy = new_value;
491 bond_set_mode_ops(bond, bond->params.mode);
492 printk(KERN_INFO DRV_NAME ": %s: setting xmit hash policy to %s (%d).\n",
493 bond->dev->name, xmit_hashtype_tbl[new_value].modename, new_value);
494 }
495out:
496 return ret;
497}
498static CLASS_DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, bonding_show_xmit_hash, bonding_store_xmit_hash);
499
500/*
501 * Show and set the arp timer interval. There are two tricky bits
502 * here. First, if ARP monitoring is activated, then we must disable
503 * MII monitoring. Second, if the ARP timer isn't running, we must
504 * start it.
505 */
506static ssize_t bonding_show_arp_interval(struct class_device *cd, char *buf)
507{
508 struct bonding *bond = to_bond(cd);
509
510 return sprintf(buf, "%d\n", bond->params.arp_interval) + 1;
511}
512
513static ssize_t bonding_store_arp_interval(struct class_device *cd, const char *buf, size_t count)
514{
515 int new_value, ret = count;
516 struct bonding *bond = to_bond(cd);
517
518 if (sscanf(buf, "%d", &new_value) != 1) {
519 printk(KERN_ERR DRV_NAME
520 ": %s: no arp_interval value specified.\n",
521 bond->dev->name);
522 ret = -EINVAL;
523 goto out;
524 }
525 if (new_value < 0) {
526 printk(KERN_ERR DRV_NAME
527 ": %s: Invalid arp_interval value %d not in range 1-%d; rejected.\n",
528 bond->dev->name, new_value, INT_MAX);
529 ret = -EINVAL;
530 goto out;
531 }
532
533 printk(KERN_INFO DRV_NAME
534 ": %s: Setting ARP monitoring interval to %d.\n",
535 bond->dev->name, new_value);
536 bond->params.arp_interval = new_value;
537 if (bond->params.miimon) {
538 printk(KERN_INFO DRV_NAME
539 ": %s: ARP monitoring cannot be used with MII monitoring. "
540 "%s Disabling MII monitoring.\n",
541 bond->dev->name, bond->dev->name);
542 bond->params.miimon = 0;
543 /* Kill MII timer, else it brings bond's link down */
544 if (bond->arp_timer.function) {
545 printk(KERN_INFO DRV_NAME
546 ": %s: Kill MII timer, else it brings bond's link down...\n",
547 bond->dev->name);
548 del_timer_sync(&bond->mii_timer);
549 }
550 }
551 if (!bond->params.arp_targets[0]) {
552 printk(KERN_INFO DRV_NAME
553 ": %s: ARP monitoring has been set up, "
554 "but no ARP targets have been specified.\n",
555 bond->dev->name);
556 }
557 if (bond->dev->flags & IFF_UP) {
558 /* If the interface is up, we may need to fire off
559 * the ARP timer. If the interface is down, the
560 * timer will get fired off when the open function
561 * is called.
562 */
563 if (bond->arp_timer.function) {
564 /* The timer's already set up, so fire it off */
565 mod_timer(&bond->arp_timer, jiffies + 1);
566 } else {
567 /* Set up the timer. */
568 init_timer(&bond->arp_timer);
569 bond->arp_timer.expires = jiffies + 1;
570 bond->arp_timer.data =
571 (unsigned long) bond->dev;
572 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
573 bond->arp_timer.function =
574 (void *)
575 &bond_activebackup_arp_mon;
576 } else {
577 bond->arp_timer.function =
578 (void *)
579 &bond_loadbalance_arp_mon;
580 }
581 add_timer(&bond->arp_timer);
582 }
583 }
584
585out:
586 return ret;
587}
588static CLASS_DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR , bonding_show_arp_interval, bonding_store_arp_interval);
589
590/*
591 * Show and set the arp targets.
592 */
593static ssize_t bonding_show_arp_targets(struct class_device *cd, char *buf)
594{
595 int i, res = 0;
596 struct bonding *bond = to_bond(cd);
597
598 for (i = 0; i < BOND_MAX_ARP_TARGETS; i++) {
599 if (bond->params.arp_targets[i])
600 res += sprintf(buf + res, "%u.%u.%u.%u ",
601 NIPQUAD(bond->params.arp_targets[i]));
602 }
603 if (res)
604 res--; /* eat the leftover space */
605 res += sprintf(buf + res, "\n");
606 res++;
607 return res;
608}
609
610static ssize_t bonding_store_arp_targets(struct class_device *cd, const char *buf, size_t count)
611{
612 u32 newtarget;
613 int i = 0, done = 0, ret = count;
614 struct bonding *bond = to_bond(cd);
615 u32 *targets;
616
617 targets = bond->params.arp_targets;
618 newtarget = in_aton(buf + 1);
619 /* look for adds */
620 if (buf[0] == '+') {
621 if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) {
622 printk(KERN_ERR DRV_NAME
623 ": %s: invalid ARP target %u.%u.%u.%u specified for addition\n",
624 bond->dev->name, NIPQUAD(newtarget));
625 ret = -EINVAL;
626 goto out;
627 }
628 /* look for an empty slot to put the target in, and check for dupes */
629 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
630 if (targets[i] == newtarget) { /* duplicate */
631 printk(KERN_ERR DRV_NAME
632 ": %s: ARP target %u.%u.%u.%u is already present\n",
633 bond->dev->name, NIPQUAD(newtarget));
634 if (done)
635 targets[i] = 0;
636 ret = -EINVAL;
637 goto out;
638 }
639 if (targets[i] == 0 && !done) {
640 printk(KERN_INFO DRV_NAME
641 ": %s: adding ARP target %d.%d.%d.%d.\n",
642 bond->dev->name, NIPQUAD(newtarget));
643 done = 1;
644 targets[i] = newtarget;
645 }
646 }
647 if (!done) {
648 printk(KERN_ERR DRV_NAME
649 ": %s: ARP target table is full!\n",
650 bond->dev->name);
651 ret = -EINVAL;
652 goto out;
653 }
654
655 }
656 else if (buf[0] == '-') {
657 if ((newtarget == 0) || (newtarget == INADDR_BROADCAST)) {
658 printk(KERN_ERR DRV_NAME
659 ": %s: invalid ARP target %d.%d.%d.%d specified for removal\n",
660 bond->dev->name, NIPQUAD(newtarget));
661 ret = -EINVAL;
662 goto out;
663 }
664
665 for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
666 if (targets[i] == newtarget) {
667 printk(KERN_INFO DRV_NAME
668 ": %s: removing ARP target %d.%d.%d.%d.\n",
669 bond->dev->name, NIPQUAD(newtarget));
670 targets[i] = 0;
671 done = 1;
672 }
673 }
674 if (!done) {
675 printk(KERN_INFO DRV_NAME
676 ": %s: unable to remove nonexistent ARP target %d.%d.%d.%d.\n",
677 bond->dev->name, NIPQUAD(newtarget));
678 ret = -EINVAL;
679 goto out;
680 }
681 }
682 else {
683 printk(KERN_ERR DRV_NAME ": no command found in arp_ip_targets file for bond %s. Use +<addr> or -<addr>.\n",
684 bond->dev->name);
685 ret = -EPERM;
686 goto out;
687 }
688
689out:
690 return ret;
691}
692static CLASS_DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets);
693
694/*
695 * Show and set the up and down delays. These must be multiples of the
696 * MII monitoring value, and are stored internally as the multiplier.
697 * Thus, we must translate to MS for the real world.
698 */
699static ssize_t bonding_show_downdelay(struct class_device *cd, char *buf)
700{
701 struct bonding *bond = to_bond(cd);
702
703 return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon) + 1;
704}
705
706static ssize_t bonding_store_downdelay(struct class_device *cd, const char *buf, size_t count)
707{
708 int new_value, ret = count;
709 struct bonding *bond = to_bond(cd);
710
711 if (!(bond->params.miimon)) {
712 printk(KERN_ERR DRV_NAME
713 ": %s: Unable to set down delay as MII monitoring is disabled\n",
714 bond->dev->name);
715 ret = -EPERM;
716 goto out;
717 }
718
719 if (sscanf(buf, "%d", &new_value) != 1) {
720 printk(KERN_ERR DRV_NAME
721 ": %s: no down delay value specified.\n",
722 bond->dev->name);
723 ret = -EINVAL;
724 goto out;
725 }
726 if (new_value < 0) {
727 printk(KERN_ERR DRV_NAME
728 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
729 bond->dev->name, new_value, 1, INT_MAX);
730 ret = -EINVAL;
731 goto out;
732 } else {
733 if ((new_value % bond->params.miimon) != 0) {
734 printk(KERN_WARNING DRV_NAME
735 ": %s: Warning: down delay (%d) is not a multiple "
736 "of miimon (%d), delay rounded to %d ms\n",
737 bond->dev->name, new_value, bond->params.miimon,
738 (new_value / bond->params.miimon) *
739 bond->params.miimon);
740 }
741 bond->params.downdelay = new_value / bond->params.miimon;
742 printk(KERN_INFO DRV_NAME ": %s: Setting down delay to %d.\n",
743 bond->dev->name, bond->params.downdelay * bond->params.miimon);
744
745 }
746
747out:
748 return ret;
749}
750static CLASS_DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR , bonding_show_downdelay, bonding_store_downdelay);
751
752static ssize_t bonding_show_updelay(struct class_device *cd, char *buf)
753{
754 struct bonding *bond = to_bond(cd);
755
756 return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon) + 1;
757
758}
759
760static ssize_t bonding_store_updelay(struct class_device *cd, const char *buf, size_t count)
761{
762 int new_value, ret = count;
763 struct bonding *bond = to_bond(cd);
764
765 if (!(bond->params.miimon)) {
766 printk(KERN_ERR DRV_NAME
767 ": %s: Unable to set up delay as MII monitoring is disabled\n",
768 bond->dev->name);
769 ret = -EPERM;
770 goto out;
771 }
772
773 if (sscanf(buf, "%d", &new_value) != 1) {
774 printk(KERN_ERR DRV_NAME
775 ": %s: no up delay value specified.\n",
776 bond->dev->name);
777 ret = -EINVAL;
778 goto out;
779 }
780 if (new_value < 0) {
781 printk(KERN_ERR DRV_NAME
782 ": %s: Invalid down delay value %d not in range %d-%d; rejected.\n",
783 bond->dev->name, new_value, 1, INT_MAX);
784 ret = -EINVAL;
785 goto out;
786 } else {
787 if ((new_value % bond->params.miimon) != 0) {
788 printk(KERN_WARNING DRV_NAME
789 ": %s: Warning: up delay (%d) is not a multiple "
790 "of miimon (%d), updelay rounded to %d ms\n",
791 bond->dev->name, new_value, bond->params.miimon,
792 (new_value / bond->params.miimon) *
793 bond->params.miimon);
794 }
795 bond->params.updelay = new_value / bond->params.miimon;
796 printk(KERN_INFO DRV_NAME ": %s: Setting up delay to %d.\n",
797 bond->dev->name, bond->params.updelay * bond->params.miimon);
798
799 }
800
801out:
802 return ret;
803}
804static CLASS_DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR , bonding_show_updelay, bonding_store_updelay);
805
806/*
807 * Show and set the LACP interval. Interface must be down, and the mode
808 * must be set to 802.3ad mode.
809 */
810static ssize_t bonding_show_lacp(struct class_device *cd, char *buf)
811{
812 struct bonding *bond = to_bond(cd);
813
814 return sprintf(buf, "%s %d\n",
815 bond_lacp_tbl[bond->params.lacp_fast].modename,
816 bond->params.lacp_fast) + 1;
817}
818
819static ssize_t bonding_store_lacp(struct class_device *cd, const char *buf, size_t count)
820{
821 int new_value, ret = count;
822 struct bonding *bond = to_bond(cd);
823
824 if (bond->dev->flags & IFF_UP) {
825 printk(KERN_ERR DRV_NAME
826 ": %s: Unable to update LACP rate because interface is up.\n",
827 bond->dev->name);
828 ret = -EPERM;
829 goto out;
830 }
831
832 if (bond->params.mode != BOND_MODE_8023AD) {
833 printk(KERN_ERR DRV_NAME
834 ": %s: Unable to update LACP rate because bond is not in 802.3ad mode.\n",
835 bond->dev->name);
836 ret = -EPERM;
837 goto out;
838 }
839
840 new_value = bond_parse_parm((char *)buf, bond_lacp_tbl);
841
842 if ((new_value == 1) || (new_value == 0)) {
843 bond->params.lacp_fast = new_value;
844 printk(KERN_INFO DRV_NAME
845 ": %s: Setting LACP rate to %s (%d).\n",
846 bond->dev->name, bond_lacp_tbl[new_value].modename, new_value);
847 } else {
848 printk(KERN_ERR DRV_NAME
849 ": %s: Ignoring invalid LACP rate value %.*s.\n",
850 bond->dev->name, (int)strlen(buf) - 1, buf);
851 ret = -EINVAL;
852 }
853out:
854 return ret;
855}
856static CLASS_DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, bonding_show_lacp, bonding_store_lacp);
857
858/*
859 * Show and set the MII monitor interval. There are two tricky bits
860 * here. First, if MII monitoring is activated, then we must disable
861 * ARP monitoring. Second, if the timer isn't running, we must
862 * start it.
863 */
864static ssize_t bonding_show_miimon(struct class_device *cd, char *buf)
865{
866 struct bonding *bond = to_bond(cd);
867
868 return sprintf(buf, "%d\n", bond->params.miimon) + 1;
869}
870
871static ssize_t bonding_store_miimon(struct class_device *cd, const char *buf, size_t count)
872{
873 int new_value, ret = count;
874 struct bonding *bond = to_bond(cd);
875
876 if (sscanf(buf, "%d", &new_value) != 1) {
877 printk(KERN_ERR DRV_NAME
878 ": %s: no miimon value specified.\n",
879 bond->dev->name);
880 ret = -EINVAL;
881 goto out;
882 }
883 if (new_value < 0) {
884 printk(KERN_ERR DRV_NAME
885 ": %s: Invalid miimon value %d not in range %d-%d; rejected.\n",
886 bond->dev->name, new_value, 1, INT_MAX);
887 ret = -EINVAL;
888 goto out;
889 } else {
890 printk(KERN_INFO DRV_NAME
891 ": %s: Setting MII monitoring interval to %d.\n",
892 bond->dev->name, new_value);
893 bond->params.miimon = new_value;
894 if(bond->params.updelay)
895 printk(KERN_INFO DRV_NAME
896 ": %s: Note: Updating updelay (to %d) "
897 "since it is a multiple of the miimon value.\n",
898 bond->dev->name,
899 bond->params.updelay * bond->params.miimon);
900 if(bond->params.downdelay)
901 printk(KERN_INFO DRV_NAME
902 ": %s: Note: Updating downdelay (to %d) "
903 "since it is a multiple of the miimon value.\n",
904 bond->dev->name,
905 bond->params.downdelay * bond->params.miimon);
906 if (bond->params.arp_interval) {
907 printk(KERN_INFO DRV_NAME
908 ": %s: MII monitoring cannot be used with "
909 "ARP monitoring. Disabling ARP monitoring...\n",
910 bond->dev->name);
911 bond->params.arp_interval = 0;
912 /* Kill ARP timer, else it brings bond's link down */
913 if (bond->mii_timer.function) {
914 printk(KERN_INFO DRV_NAME
915 ": %s: Kill ARP timer, else it brings bond's link down...\n",
916 bond->dev->name);
917 del_timer_sync(&bond->arp_timer);
918 }
919 }
920
921 if (bond->dev->flags & IFF_UP) {
922 /* If the interface is up, we may need to fire off
923 * the MII timer. If the interface is down, the
924 * timer will get fired off when the open function
925 * is called.
926 */
927 if (bond->mii_timer.function) {
928 /* The timer's already set up, so fire it off */
929 mod_timer(&bond->mii_timer, jiffies + 1);
930 } else {
931 /* Set up the timer. */
932 init_timer(&bond->mii_timer);
933 bond->mii_timer.expires = jiffies + 1;
934 bond->mii_timer.data =
935 (unsigned long) bond->dev;
936 bond->mii_timer.function =
937 (void *) &bond_mii_monitor;
938 add_timer(&bond->mii_timer);
939 }
940 }
941 }
942out:
943 return ret;
944}
945static CLASS_DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, bonding_show_miimon, bonding_store_miimon);
946
947/*
948 * Show and set the primary slave. The store function is much
949 * simpler than bonding_store_slaves function because it only needs to
950 * handle one interface name.
951 * The bond must be a mode that supports a primary for this be
952 * set.
953 */
954static ssize_t bonding_show_primary(struct class_device *cd, char *buf)
955{
956 int count = 0;
957 struct bonding *bond = to_bond(cd);
958
959 if (bond->primary_slave)
960 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name) + 1;
961 else
962 count = sprintf(buf, "\n") + 1;
963
964 return count;
965}
966
967static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, size_t count)
968{
969 int i;
970 struct slave *slave;
971 struct bonding *bond = to_bond(cd);
972
973 write_lock_bh(&bond->lock);
974 if (!USES_PRIMARY(bond->params.mode)) {
975 printk(KERN_INFO DRV_NAME
976 ": %s: Unable to set primary slave; %s is in mode %d\n",
977 bond->dev->name, bond->dev->name, bond->params.mode);
978 } else {
979 bond_for_each_slave(bond, slave, i) {
980 if (strnicmp
981 (slave->dev->name, buf,
982 strlen(slave->dev->name)) == 0) {
983 printk(KERN_INFO DRV_NAME
984 ": %s: Setting %s as primary slave.\n",
985 bond->dev->name, slave->dev->name);
986 bond->primary_slave = slave;
987 bond_select_active_slave(bond);
988 goto out;
989 }
990 }
991
992 /* if we got here, then we didn't match the name of any slave */
993
994 if (strlen(buf) == 0 || buf[0] == '\n') {
995 printk(KERN_INFO DRV_NAME
996 ": %s: Setting primary slave to None.\n",
997 bond->dev->name);
998 bond->primary_slave = 0;
999 bond_select_active_slave(bond);
1000 } else {
1001 printk(KERN_INFO DRV_NAME
1002 ": %s: Unable to set %.*s as primary slave as it is not a slave.\n",
1003 bond->dev->name, (int)strlen(buf) - 1, buf);
1004 }
1005 }
1006out:
1007 write_unlock_bh(&bond->lock);
1008 return count;
1009}
1010static CLASS_DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, bonding_show_primary, bonding_store_primary);
1011
1012/*
1013 * Show and set the use_carrier flag.
1014 */
1015static ssize_t bonding_show_carrier(struct class_device *cd, char *buf)
1016{
1017 struct bonding *bond = to_bond(cd);
1018
1019 return sprintf(buf, "%d\n", bond->params.use_carrier) + 1;
1020}
1021
1022static ssize_t bonding_store_carrier(struct class_device *cd, const char *buf, size_t count)
1023{
1024 int new_value, ret = count;
1025 struct bonding *bond = to_bond(cd);
1026
1027
1028 if (sscanf(buf, "%d", &new_value) != 1) {
1029 printk(KERN_ERR DRV_NAME
1030 ": %s: no use_carrier value specified.\n",
1031 bond->dev->name);
1032 ret = -EINVAL;
1033 goto out;
1034 }
1035 if ((new_value == 0) || (new_value == 1)) {
1036 bond->params.use_carrier = new_value;
1037 printk(KERN_INFO DRV_NAME ": %s: Setting use_carrier to %d.\n",
1038 bond->dev->name, new_value);
1039 } else {
1040 printk(KERN_INFO DRV_NAME
1041 ": %s: Ignoring invalid use_carrier value %d.\n",
1042 bond->dev->name, new_value);
1043 }
1044out:
1045 return count;
1046}
1047static CLASS_DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, bonding_show_carrier, bonding_store_carrier);
1048
1049
1050/*
1051 * Show and set currently active_slave.
1052 */
1053static ssize_t bonding_show_active_slave(struct class_device *cd, char *buf)
1054{
1055 struct slave *curr;
1056 struct bonding *bond = to_bond(cd);
1057 int count;
1058
1059
1060 read_lock(&bond->curr_slave_lock);
1061 curr = bond->curr_active_slave;
1062 read_unlock(&bond->curr_slave_lock);
1063
1064 if (USES_PRIMARY(bond->params.mode) && curr)
1065 count = sprintf(buf, "%s\n", curr->dev->name) + 1;
1066 else
1067 count = sprintf(buf, "\n") + 1;
1068 return count;
1069}
1070
1071static ssize_t bonding_store_active_slave(struct class_device *cd, const char *buf, size_t count)
1072{
1073 int i;
1074 struct slave *slave;
1075 struct slave *old_active = NULL;
1076 struct slave *new_active = NULL;
1077 struct bonding *bond = to_bond(cd);
1078
1079 write_lock_bh(&bond->lock);
1080 if (!USES_PRIMARY(bond->params.mode)) {
1081 printk(KERN_INFO DRV_NAME
1082 ": %s: Unable to change active slave; %s is in mode %d\n",
1083 bond->dev->name, bond->dev->name, bond->params.mode);
1084 } else {
1085 bond_for_each_slave(bond, slave, i) {
1086 if (strnicmp
1087 (slave->dev->name, buf,
1088 strlen(slave->dev->name)) == 0) {
1089 old_active = bond->curr_active_slave;
1090 new_active = slave;
1091 if (new_active && (new_active == old_active)) {
1092 /* do nothing */
1093 printk(KERN_INFO DRV_NAME
1094 ": %s: %s is already the current active slave.\n",
1095 bond->dev->name, slave->dev->name);
1096 goto out;
1097 }
1098 else {
1099 if ((new_active) &&
1100 (old_active) &&
1101 (new_active->link == BOND_LINK_UP) &&
1102 IS_UP(new_active->dev)) {
1103 printk(KERN_INFO DRV_NAME
1104 ": %s: Setting %s as active slave.\n",
1105 bond->dev->name, slave->dev->name);
1106 bond_change_active_slave(bond, new_active);
1107 }
1108 else {
1109 printk(KERN_INFO DRV_NAME
1110 ": %s: Could not set %s as active slave; "
1111 "either %s is down or the link is down.\n",
1112 bond->dev->name, slave->dev->name,
1113 slave->dev->name);
1114 }
1115 goto out;
1116 }
1117 }
1118 }
1119
1120 /* if we got here, then we didn't match the name of any slave */
1121
1122 if (strlen(buf) == 0 || buf[0] == '\n') {
1123 printk(KERN_INFO DRV_NAME
1124 ": %s: Setting active slave to None.\n",
1125 bond->dev->name);
1126 bond->primary_slave = 0;
1127 bond_select_active_slave(bond);
1128 } else {
1129 printk(KERN_INFO DRV_NAME
1130 ": %s: Unable to set %.*s as active slave as it is not a slave.\n",
1131 bond->dev->name, (int)strlen(buf) - 1, buf);
1132 }
1133 }
1134out:
1135 write_unlock_bh(&bond->lock);
1136 return count;
1137
1138}
1139static CLASS_DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, bonding_show_active_slave, bonding_store_active_slave);
1140
1141
1142/*
1143 * Show link status of the bond interface.
1144 */
1145static ssize_t bonding_show_mii_status(struct class_device *cd, char *buf)
1146{
1147 struct slave *curr;
1148 struct bonding *bond = to_bond(cd);
1149
1150 read_lock(&bond->curr_slave_lock);
1151 curr = bond->curr_active_slave;
1152 read_unlock(&bond->curr_slave_lock);
1153
1154 return sprintf(buf, "%s\n", (curr) ? "up" : "down") + 1;
1155}
1156static CLASS_DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL);
1157
1158
1159/*
1160 * Show current 802.3ad aggregator ID.
1161 */
1162static ssize_t bonding_show_ad_aggregator(struct class_device *cd, char *buf)
1163{
1164 int count = 0;
1165 struct bonding *bond = to_bond(cd);
1166
1167 if (bond->params.mode == BOND_MODE_8023AD) {
1168 struct ad_info ad_info;
1169 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id) + 1;
1170 }
1171 else
1172 count = sprintf(buf, "\n") + 1;
1173
1174 return count;
1175}
1176static CLASS_DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL);
1177
1178
1179/*
1180 * Show number of active 802.3ad ports.
1181 */
1182static ssize_t bonding_show_ad_num_ports(struct class_device *cd, char *buf)
1183{
1184 int count = 0;
1185 struct bonding *bond = to_bond(cd);
1186
1187 if (bond->params.mode == BOND_MODE_8023AD) {
1188 struct ad_info ad_info;
1189 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports) + 1;
1190 }
1191 else
1192 count = sprintf(buf, "\n") + 1;
1193
1194 return count;
1195}
1196static CLASS_DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL);
1197
1198
1199/*
1200 * Show current 802.3ad actor key.
1201 */
1202static ssize_t bonding_show_ad_actor_key(struct class_device *cd, char *buf)
1203{
1204 int count = 0;
1205 struct bonding *bond = to_bond(cd);
1206
1207 if (bond->params.mode == BOND_MODE_8023AD) {
1208 struct ad_info ad_info;
1209 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key) + 1;
1210 }
1211 else
1212 count = sprintf(buf, "\n") + 1;
1213
1214 return count;
1215}
1216static CLASS_DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL);
1217
1218
1219/*
1220 * Show current 802.3ad partner key.
1221 */
1222static ssize_t bonding_show_ad_partner_key(struct class_device *cd, char *buf)
1223{
1224 int count = 0;
1225 struct bonding *bond = to_bond(cd);
1226
1227 if (bond->params.mode == BOND_MODE_8023AD) {
1228 struct ad_info ad_info;
1229 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key) + 1;
1230 }
1231 else
1232 count = sprintf(buf, "\n") + 1;
1233
1234 return count;
1235}
1236static CLASS_DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL);
1237
1238
1239/*
1240 * Show current 802.3ad partner mac.
1241 */
1242static ssize_t bonding_show_ad_partner_mac(struct class_device *cd, char *buf)
1243{
1244 int count = 0;
1245 struct bonding *bond = to_bond(cd);
1246
1247 if (bond->params.mode == BOND_MODE_8023AD) {
1248 struct ad_info ad_info;
1249 if (!bond_3ad_get_active_agg_info(bond, &ad_info)) {
1250 count = sprintf(buf,"%02x:%02x:%02x:%02x:%02x:%02x\n",
1251 ad_info.partner_system[0],
1252 ad_info.partner_system[1],
1253 ad_info.partner_system[2],
1254 ad_info.partner_system[3],
1255 ad_info.partner_system[4],
1256 ad_info.partner_system[5]) + 1;
1257 }
1258 }
1259 else
1260 count = sprintf(buf, "\n") + 1;
1261
1262 return count;
1263}
1264static CLASS_DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
1265
1266
1267
1268static struct attribute *per_bond_attrs[] = {
1269 &class_device_attr_slaves.attr,
1270 &class_device_attr_mode.attr,
1271 &class_device_attr_arp_interval.attr,
1272 &class_device_attr_arp_ip_target.attr,
1273 &class_device_attr_downdelay.attr,
1274 &class_device_attr_updelay.attr,
1275 &class_device_attr_lacp_rate.attr,
1276 &class_device_attr_xmit_hash_policy.attr,
1277 &class_device_attr_miimon.attr,
1278 &class_device_attr_primary.attr,
1279 &class_device_attr_use_carrier.attr,
1280 &class_device_attr_active_slave.attr,
1281 &class_device_attr_mii_status.attr,
1282 &class_device_attr_ad_aggregator.attr,
1283 &class_device_attr_ad_num_ports.attr,
1284 &class_device_attr_ad_actor_key.attr,
1285 &class_device_attr_ad_partner_key.attr,
1286 &class_device_attr_ad_partner_mac.attr,
1287 NULL,
1288};
1289
1290static struct attribute_group bonding_group = {
1291 .name = "bonding",
1292 .attrs = per_bond_attrs,
1293};
1294
1295/*
1296 * Initialize sysfs. This sets up the bonding_masters file in
1297 * /sys/class/net.
1298 */
1299int bond_create_sysfs(void)
1300{
1301 int ret = 0;
1302 struct bonding *firstbond;
1303
1304 init_rwsem(&bonding_rwsem);
1305
1306 /* get the netdev class pointer */
1307 firstbond = container_of(bond_dev_list.next, struct bonding, bond_list);
1308 if (!firstbond)
1309 return -ENODEV;
1310
1311 netdev_class = firstbond->dev->class_dev.class;
1312 if (!netdev_class)
1313 return -ENODEV;
1314
1315 ret = class_create_file(netdev_class, &class_attr_bonding_masters);
1316
1317 return ret;
1318
1319}
1320
1321/*
1322 * Remove /sys/class/net/bonding_masters.
1323 */
1324void bond_destroy_sysfs(void)
1325{
1326 if (netdev_class)
1327 class_remove_file(netdev_class, &class_attr_bonding_masters);
1328}
1329
1330/*
1331 * Initialize sysfs for each bond. This sets up and registers
1332 * the 'bondctl' directory for each individual bond under /sys/class/net.
1333 */
1334int bond_create_sysfs_entry(struct bonding *bond)
1335{
1336 struct net_device *dev = bond->dev;
1337 int err;
1338
1339 err = sysfs_create_group(&(dev->class_dev.kobj), &bonding_group);
1340 if (err) {
1341 printk(KERN_EMERG "eek! didn't create group!\n");
1342 }
1343
1344 if (expected_refcount < 1)
1345 expected_refcount = atomic_read(&bond->dev->class_dev.kobj.kref.refcount);
1346
1347 return err;
1348}
1349/*
1350 * Remove sysfs entries for each bond.
1351 */
1352void bond_destroy_sysfs_entry(struct bonding *bond)
1353{
1354 struct net_device *dev = bond->dev;
1355
1356 sysfs_remove_group(&(dev->class_dev.kobj), &bonding_group);
1357}
1358
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 1433e91db0f7..015c7f1d1bc0 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -10,25 +10,6 @@
10 * This software may be used and distributed according to the terms 10 * This software may be used and distributed according to the terms
11 * of the GNU Public License, incorporated herein by reference. 11 * of the GNU Public License, incorporated herein by reference.
12 * 12 *
13 *
14 * 2003/03/18 - Amir Noam <amir.noam at intel dot com>,
15 * Tsippy Mendelson <tsippy.mendelson at intel dot com> and
16 * Shmulik Hen <shmulik.hen at intel dot com>
17 * - Added support for IEEE 802.3ad Dynamic link aggregation mode.
18 *
19 * 2003/05/01 - Tsippy Mendelson <tsippy.mendelson at intel dot com> and
20 * Amir Noam <amir.noam at intel dot com>
21 * - Code beautification and style changes (mainly in comments).
22 *
23 * 2003/05/01 - Shmulik Hen <shmulik.hen at intel dot com>
24 * - Added support for Transmit load balancing mode.
25 *
26 * 2003/12/01 - Shmulik Hen <shmulik.hen at intel dot com>
27 * - Code cleanup and style changes
28 *
29 * 2005/05/05 - Jason Gabler <jygabler at lbl dot gov>
30 * - added "xmit_policy" kernel parameter for alternate hashing policy
31 * support for mode 2
32 */ 13 */
33 14
34#ifndef _LINUX_BONDING_H 15#ifndef _LINUX_BONDING_H
@@ -37,11 +18,12 @@
37#include <linux/timer.h> 18#include <linux/timer.h>
38#include <linux/proc_fs.h> 19#include <linux/proc_fs.h>
39#include <linux/if_bonding.h> 20#include <linux/if_bonding.h>
21#include <linux/kobject.h>
40#include "bond_3ad.h" 22#include "bond_3ad.h"
41#include "bond_alb.h" 23#include "bond_alb.h"
42 24
43#define DRV_VERSION "2.6.5" 25#define DRV_VERSION "3.0.0"
44#define DRV_RELDATE "November 4, 2005" 26#define DRV_RELDATE "November 8, 2005"
45#define DRV_NAME "bonding" 27#define DRV_NAME "bonding"
46#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver" 28#define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
47 29
@@ -152,6 +134,11 @@ struct bond_params {
152 u32 arp_targets[BOND_MAX_ARP_TARGETS]; 134 u32 arp_targets[BOND_MAX_ARP_TARGETS];
153}; 135};
154 136
137struct bond_parm_tbl {
138 char *modename;
139 int mode;
140};
141
155struct vlan_entry { 142struct vlan_entry {
156 struct list_head vlan_list; 143 struct list_head vlan_list;
157 u32 vlan_ip; 144 u32 vlan_ip;
@@ -159,7 +146,7 @@ struct vlan_entry {
159}; 146};
160 147
161struct slave { 148struct slave {
162 struct net_device *dev; /* first - usefull for panic debug */ 149 struct net_device *dev; /* first - useful for panic debug */
163 struct slave *next; 150 struct slave *next;
164 struct slave *prev; 151 struct slave *prev;
165 s16 delay; 152 s16 delay;
@@ -185,7 +172,7 @@ struct slave {
185 * beforehand. 172 * beforehand.
186 */ 173 */
187struct bonding { 174struct bonding {
188 struct net_device *dev; /* first - usefull for panic debug */ 175 struct net_device *dev; /* first - useful for panic debug */
189 struct slave *first_slave; 176 struct slave *first_slave;
190 struct slave *curr_active_slave; 177 struct slave *curr_active_slave;
191 struct slave *current_arp_slave; 178 struct slave *current_arp_slave;
@@ -255,6 +242,25 @@ extern inline void bond_set_slave_active_flags(struct slave *slave)
255 242
256struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr); 243struct vlan_entry *bond_next_vlan(struct bonding *bond, struct vlan_entry *curr);
257int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); 244int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev);
245int bond_create(char *name, struct bond_params *params, struct bonding **newbond);
246void bond_deinit(struct net_device *bond_dev);
247int bond_create_sysfs(void);
248void bond_destroy_sysfs(void);
249void bond_destroy_sysfs_entry(struct bonding *bond);
250int bond_create_sysfs_entry(struct bonding *bond);
251int bond_create_slave_symlinks(struct net_device *master, struct net_device *slave);
252void bond_destroy_slave_symlinks(struct net_device *master, struct net_device *slave);
253int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev);
254int bond_release(struct net_device *bond_dev, struct net_device *slave_dev);
255int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev);
256void bond_mii_monitor(struct net_device *bond_dev);
257void bond_loadbalance_arp_mon(struct net_device *bond_dev);
258void bond_activebackup_arp_mon(struct net_device *bond_dev);
259void bond_set_mode_ops(struct bonding *bond, int mode);
260int bond_parse_parm(char *mode_arg, struct bond_parm_tbl *tbl);
261const char *bond_mode_name(int mode);
262void bond_select_active_slave(struct bonding *bond);
263void bond_change_active_slave(struct bonding *bond, struct slave *new_active);
258 264
259#endif /* _LINUX_BONDING_H */ 265#endif /* _LINUX_BONDING_H */
260 266
diff --git a/drivers/net/chelsio/sge.c b/drivers/net/chelsio/sge.c
index 53b41d99b00b..2c5b849b7ba4 100644
--- a/drivers/net/chelsio/sge.c
+++ b/drivers/net/chelsio/sge.c
@@ -1332,8 +1332,8 @@ intr_handler_t t1_select_intr_handler(adapter_t *adapter)
1332 * 1332 *
1333 * This runs with softirqs disabled. 1333 * This runs with softirqs disabled.
1334 */ 1334 */
1335unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter, 1335static int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
1336 unsigned int qid, struct net_device *dev) 1336 unsigned int qid, struct net_device *dev)
1337{ 1337{
1338 struct sge *sge = adapter->sge; 1338 struct sge *sge = adapter->sge;
1339 struct cmdQ *q = &sge->cmdQ[qid]; 1339 struct cmdQ *q = &sge->cmdQ[qid];
@@ -1352,9 +1352,10 @@ unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
1352 set_bit(dev->if_port, &sge->stopped_tx_queues); 1352 set_bit(dev->if_port, &sge->stopped_tx_queues);
1353 sge->stats.cmdQ_full[3]++; 1353 sge->stats.cmdQ_full[3]++;
1354 spin_unlock(&q->lock); 1354 spin_unlock(&q->lock);
1355 CH_ERR("%s: Tx ring full while queue awake!\n", 1355 if (!netif_queue_stopped(dev))
1356 adapter->name); 1356 CH_ERR("%s: Tx ring full while queue awake!\n",
1357 return 1; 1357 adapter->name);
1358 return NETDEV_TX_BUSY;
1358 } 1359 }
1359 if (unlikely(credits - count < q->stop_thres)) { 1360 if (unlikely(credits - count < q->stop_thres)) {
1360 sge->stats.cmdQ_full[3]++; 1361 sge->stats.cmdQ_full[3]++;
@@ -1389,7 +1390,7 @@ unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
1389 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL); 1390 writel(F_CMDQ0_ENABLE, adapter->regs + A_SG_DOORBELL);
1390 } 1391 }
1391 } 1392 }
1392 return 0; 1393 return NETDEV_TX_OK;
1393} 1394}
1394 1395
1395#define MK_ETH_TYPE_MSS(type, mss) (((mss) & 0x3FFF) | ((type) << 14)) 1396#define MK_ETH_TYPE_MSS(type, mss) (((mss) & 0x3FFF) | ((type) << 14))
@@ -1449,7 +1450,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1449 if (unlikely(skb->len < ETH_HLEN || 1450 if (unlikely(skb->len < ETH_HLEN ||
1450 skb->len > dev->mtu + eth_hdr_len(skb->data))) { 1451 skb->len > dev->mtu + eth_hdr_len(skb->data))) {
1451 dev_kfree_skb_any(skb); 1452 dev_kfree_skb_any(skb);
1452 return NET_XMIT_SUCCESS; 1453 return NETDEV_TX_OK;
1453 } 1454 }
1454 1455
1455 /* 1456 /*
@@ -1467,7 +1468,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1467 skb = skb_realloc_headroom(skb, sizeof(*cpl)); 1468 skb = skb_realloc_headroom(skb, sizeof(*cpl));
1468 dev_kfree_skb_any(orig_skb); 1469 dev_kfree_skb_any(orig_skb);
1469 if (!skb) 1470 if (!skb)
1470 return -ENOMEM; 1471 return NETDEV_TX_OK;
1471 } 1472 }
1472 1473
1473 if (!(adapter->flags & UDP_CSUM_CAPABLE) && 1474 if (!(adapter->flags & UDP_CSUM_CAPABLE) &&
@@ -1475,7 +1476,7 @@ int t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
1475 skb->nh.iph->protocol == IPPROTO_UDP) 1476 skb->nh.iph->protocol == IPPROTO_UDP)
1476 if (unlikely(skb_checksum_help(skb, 0))) { 1477 if (unlikely(skb_checksum_help(skb, 0))) {
1477 dev_kfree_skb_any(skb); 1478 dev_kfree_skb_any(skb);
1478 return -ENOMEM; 1479 return NETDEV_TX_OK;
1479 } 1480 }
1480 1481
1481 /* Hmmm, assuming to catch the gratious arp... and we'll use 1482 /* Hmmm, assuming to catch the gratious arp... and we'll use
diff --git a/drivers/net/chelsio/sge.h b/drivers/net/chelsio/sge.h
index 434b25586851..6d0d24a6364f 100644
--- a/drivers/net/chelsio/sge.h
+++ b/drivers/net/chelsio/sge.h
@@ -89,8 +89,6 @@ int t1_sge_configure(struct sge *, struct sge_params *);
89int t1_sge_set_coalesce_params(struct sge *, struct sge_params *); 89int t1_sge_set_coalesce_params(struct sge *, struct sge_params *);
90void t1_sge_destroy(struct sge *); 90void t1_sge_destroy(struct sge *);
91intr_handler_t t1_select_intr_handler(adapter_t *adapter); 91intr_handler_t t1_select_intr_handler(adapter_t *adapter);
92unsigned int t1_sge_tx(struct sk_buff *skb, struct adapter *adapter,
93 unsigned int qid, struct net_device *netdev);
94int t1_start_xmit(struct sk_buff *skb, struct net_device *dev); 92int t1_start_xmit(struct sk_buff *skb, struct net_device *dev);
95void t1_set_vlan_accel(struct adapter *adapter, int on_off); 93void t1_set_vlan_accel(struct adapter *adapter, int on_off);
96void t1_sge_start(struct sge *); 94void t1_sge_start(struct sge *);
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 3f653a93e1bc..e02e9ba2e18b 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -188,11 +188,13 @@ struct e1000_tx_ring {
188 /* array of buffer information structs */ 188 /* array of buffer information structs */
189 struct e1000_buffer *buffer_info; 189 struct e1000_buffer *buffer_info;
190 190
191 struct e1000_buffer previous_buffer_info;
192 spinlock_t tx_lock; 191 spinlock_t tx_lock;
193 uint16_t tdh; 192 uint16_t tdh;
194 uint16_t tdt; 193 uint16_t tdt;
195 uint64_t pkt; 194 uint64_t pkt;
195
196 boolean_t last_tx_tso;
197
196}; 198};
197 199
198struct e1000_rx_ring { 200struct e1000_rx_ring {
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c
index 8eae8ba27e84..c88f1a3c1b1d 100644
--- a/drivers/net/e1000/e1000_ethtool.c
+++ b/drivers/net/e1000/e1000_ethtool.c
@@ -562,10 +562,29 @@ e1000_get_drvinfo(struct net_device *netdev,
562 struct ethtool_drvinfo *drvinfo) 562 struct ethtool_drvinfo *drvinfo)
563{ 563{
564 struct e1000_adapter *adapter = netdev_priv(netdev); 564 struct e1000_adapter *adapter = netdev_priv(netdev);
565 char firmware_version[32];
566 uint16_t eeprom_data;
565 567
566 strncpy(drvinfo->driver, e1000_driver_name, 32); 568 strncpy(drvinfo->driver, e1000_driver_name, 32);
567 strncpy(drvinfo->version, e1000_driver_version, 32); 569 strncpy(drvinfo->version, e1000_driver_version, 32);
568 strncpy(drvinfo->fw_version, "N/A", 32); 570
571 /* EEPROM image version # is reported as firware version # for
572 * 8257{1|2|3} controllers */
573 e1000_read_eeprom(&adapter->hw, 5, 1, &eeprom_data);
574 switch (adapter->hw.mac_type) {
575 case e1000_82571:
576 case e1000_82572:
577 case e1000_82573:
578 sprintf(firmware_version, "%d.%d-%d",
579 (eeprom_data & 0xF000) >> 12,
580 (eeprom_data & 0x0FF0) >> 4,
581 eeprom_data & 0x000F);
582 break;
583 default:
584 sprintf(firmware_version, "n/a");
585 }
586
587 strncpy(drvinfo->fw_version, firmware_version, 32);
569 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32); 588 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
570 drvinfo->n_stats = E1000_STATS_LEN; 589 drvinfo->n_stats = E1000_STATS_LEN;
571 drvinfo->testinfo_len = E1000_TEST_LEN; 590 drvinfo->testinfo_len = E1000_TEST_LEN;
@@ -960,13 +979,21 @@ e1000_free_desc_rings(struct e1000_adapter *adapter)
960 } 979 }
961 } 980 }
962 981
963 if(txdr->desc) 982 if(txdr->desc) {
964 pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma); 983 pci_free_consistent(pdev, txdr->size, txdr->desc, txdr->dma);
965 if(rxdr->desc) 984 txdr->desc = NULL;
985 }
986 if(rxdr->desc) {
966 pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma); 987 pci_free_consistent(pdev, rxdr->size, rxdr->desc, rxdr->dma);
988 rxdr->desc = NULL;
989 }
967 990
968 kfree(txdr->buffer_info); 991 kfree(txdr->buffer_info);
992 txdr->buffer_info = NULL;
993
969 kfree(rxdr->buffer_info); 994 kfree(rxdr->buffer_info);
995 rxdr->buffer_info = NULL;
996
970 return; 997 return;
971} 998}
972 999
@@ -1301,21 +1328,32 @@ static int
1301e1000_setup_loopback_test(struct e1000_adapter *adapter) 1328e1000_setup_loopback_test(struct e1000_adapter *adapter)
1302{ 1329{
1303 uint32_t rctl; 1330 uint32_t rctl;
1331 struct e1000_hw *hw = &adapter->hw;
1304 1332
1305 if(adapter->hw.media_type == e1000_media_type_fiber || 1333 if (hw->media_type == e1000_media_type_fiber ||
1306 adapter->hw.media_type == e1000_media_type_internal_serdes) { 1334 hw->media_type == e1000_media_type_internal_serdes) {
1307 if(adapter->hw.mac_type == e1000_82545 || 1335 switch (hw->mac_type) {
1308 adapter->hw.mac_type == e1000_82546 || 1336 case e1000_82545:
1309 adapter->hw.mac_type == e1000_82545_rev_3 || 1337 case e1000_82546:
1310 adapter->hw.mac_type == e1000_82546_rev_3) 1338 case e1000_82545_rev_3:
1339 case e1000_82546_rev_3:
1311 return e1000_set_phy_loopback(adapter); 1340 return e1000_set_phy_loopback(adapter);
1312 else { 1341 break;
1313 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1342 case e1000_82571:
1343 case e1000_82572:
1344#define E1000_SERDES_LB_ON 0x410
1345 e1000_set_phy_loopback(adapter);
1346 E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_ON);
1347 msec_delay(10);
1348 return 0;
1349 break;
1350 default:
1351 rctl = E1000_READ_REG(hw, RCTL);
1314 rctl |= E1000_RCTL_LBM_TCVR; 1352 rctl |= E1000_RCTL_LBM_TCVR;
1315 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 1353 E1000_WRITE_REG(hw, RCTL, rctl);
1316 return 0; 1354 return 0;
1317 } 1355 }
1318 } else if(adapter->hw.media_type == e1000_media_type_copper) 1356 } else if (hw->media_type == e1000_media_type_copper)
1319 return e1000_set_phy_loopback(adapter); 1357 return e1000_set_phy_loopback(adapter);
1320 1358
1321 return 7; 1359 return 7;
@@ -1326,25 +1364,36 @@ e1000_loopback_cleanup(struct e1000_adapter *adapter)
1326{ 1364{
1327 uint32_t rctl; 1365 uint32_t rctl;
1328 uint16_t phy_reg; 1366 uint16_t phy_reg;
1367 struct e1000_hw *hw = &adapter->hw;
1329 1368
1330 rctl = E1000_READ_REG(&adapter->hw, RCTL); 1369 rctl = E1000_READ_REG(&adapter->hw, RCTL);
1331 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC); 1370 rctl &= ~(E1000_RCTL_LBM_TCVR | E1000_RCTL_LBM_MAC);
1332 E1000_WRITE_REG(&adapter->hw, RCTL, rctl); 1371 E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
1333 1372
1334 if(adapter->hw.media_type == e1000_media_type_copper || 1373 switch (hw->mac_type) {
1335 ((adapter->hw.media_type == e1000_media_type_fiber || 1374 case e1000_82571:
1336 adapter->hw.media_type == e1000_media_type_internal_serdes) && 1375 case e1000_82572:
1337 (adapter->hw.mac_type == e1000_82545 || 1376 if (hw->media_type == e1000_media_type_fiber ||
1338 adapter->hw.mac_type == e1000_82546 || 1377 hw->media_type == e1000_media_type_internal_serdes){
1339 adapter->hw.mac_type == e1000_82545_rev_3 || 1378#define E1000_SERDES_LB_OFF 0x400
1340 adapter->hw.mac_type == e1000_82546_rev_3))) { 1379 E1000_WRITE_REG(hw, SCTL, E1000_SERDES_LB_OFF);
1341 adapter->hw.autoneg = TRUE; 1380 msec_delay(10);
1342 e1000_read_phy_reg(&adapter->hw, PHY_CTRL, &phy_reg); 1381 break;
1343 if(phy_reg & MII_CR_LOOPBACK) { 1382 }
1383 /* fall thru for Cu adapters */
1384 case e1000_82545:
1385 case e1000_82546:
1386 case e1000_82545_rev_3:
1387 case e1000_82546_rev_3:
1388 default:
1389 hw->autoneg = TRUE;
1390 e1000_read_phy_reg(hw, PHY_CTRL, &phy_reg);
1391 if (phy_reg & MII_CR_LOOPBACK) {
1344 phy_reg &= ~MII_CR_LOOPBACK; 1392 phy_reg &= ~MII_CR_LOOPBACK;
1345 e1000_write_phy_reg(&adapter->hw, PHY_CTRL, phy_reg); 1393 e1000_write_phy_reg(hw, PHY_CTRL, phy_reg);
1346 e1000_phy_reset(&adapter->hw); 1394 e1000_phy_reset(hw);
1347 } 1395 }
1396 break;
1348 } 1397 }
1349} 1398}
1350 1399
@@ -1440,9 +1489,11 @@ static int
1440e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data) 1489e1000_loopback_test(struct e1000_adapter *adapter, uint64_t *data)
1441{ 1490{
1442 if((*data = e1000_setup_desc_rings(adapter))) goto err_loopback; 1491 if((*data = e1000_setup_desc_rings(adapter))) goto err_loopback;
1443 if((*data = e1000_setup_loopback_test(adapter))) goto err_loopback; 1492 if((*data = e1000_setup_loopback_test(adapter)))
1493 goto err_loopback_setup;
1444 *data = e1000_run_loopback_test(adapter); 1494 *data = e1000_run_loopback_test(adapter);
1445 e1000_loopback_cleanup(adapter); 1495 e1000_loopback_cleanup(adapter);
1496err_loopback_setup:
1446 e1000_free_desc_rings(adapter); 1497 e1000_free_desc_rings(adapter);
1447err_loopback: 1498err_loopback:
1448 return *data; 1499 return *data;
@@ -1671,6 +1722,14 @@ e1000_phys_id(struct net_device *netdev, uint32_t data)
1671 msleep_interruptible(data * 1000); 1722 msleep_interruptible(data * 1000);
1672 del_timer_sync(&adapter->blink_timer); 1723 del_timer_sync(&adapter->blink_timer);
1673 } 1724 }
1725 else if(adapter->hw.mac_type < e1000_82573) {
1726 E1000_WRITE_REG(&adapter->hw, LEDCTL, (E1000_LEDCTL_LED2_BLINK_RATE |
1727 E1000_LEDCTL_LED0_BLINK | E1000_LEDCTL_LED2_BLINK |
1728 (E1000_LEDCTL_MODE_LED_ON << E1000_LEDCTL_LED2_MODE_SHIFT) |
1729 (E1000_LEDCTL_MODE_LINK_ACTIVITY << E1000_LEDCTL_LED0_MODE_SHIFT) |
1730 (E1000_LEDCTL_MODE_LED_OFF << E1000_LEDCTL_LED1_MODE_SHIFT)));
1731 msleep_interruptible(data * 1000);
1732 }
1674 else { 1733 else {
1675 E1000_WRITE_REG(&adapter->hw, LEDCTL, (E1000_LEDCTL_LED2_BLINK_RATE | 1734 E1000_WRITE_REG(&adapter->hw, LEDCTL, (E1000_LEDCTL_LED2_BLINK_RATE |
1676 E1000_LEDCTL_LED1_BLINK | E1000_LEDCTL_LED2_BLINK | 1735 E1000_LEDCTL_LED1_BLINK | E1000_LEDCTL_LED2_BLINK |
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c
index a267c5235fc0..136fc031e4ad 100644
--- a/drivers/net/e1000/e1000_hw.c
+++ b/drivers/net/e1000/e1000_hw.c
@@ -563,11 +563,13 @@ e1000_reset_hw(struct e1000_hw *hw)
563 msec_delay(20); 563 msec_delay(20);
564 break; 564 break;
565 case e1000_82573: 565 case e1000_82573:
566 udelay(10); 566 if (e1000_is_onboard_nvm_eeprom(hw) == FALSE) {
567 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT); 567 udelay(10);
568 ctrl_ext |= E1000_CTRL_EXT_EE_RST; 568 ctrl_ext = E1000_READ_REG(hw, CTRL_EXT);
569 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext); 569 ctrl_ext |= E1000_CTRL_EXT_EE_RST;
570 E1000_WRITE_FLUSH(hw); 570 E1000_WRITE_REG(hw, CTRL_EXT, ctrl_ext);
571 E1000_WRITE_FLUSH(hw);
572 }
571 /* fall through */ 573 /* fall through */
572 case e1000_82571: 574 case e1000_82571:
573 case e1000_82572: 575 case e1000_82572:
@@ -844,19 +846,27 @@ e1000_setup_link(struct e1000_hw *hw)
844 * control setting, then the variable hw->fc will 846 * control setting, then the variable hw->fc will
845 * be initialized based on a value in the EEPROM. 847 * be initialized based on a value in the EEPROM.
846 */ 848 */
847 if(e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG, 1, &eeprom_data)) { 849 if (hw->fc == e1000_fc_default) {
848 DEBUGOUT("EEPROM Read Error\n"); 850 switch (hw->mac_type) {
849 return -E1000_ERR_EEPROM; 851 case e1000_82573:
850 }
851
852 if(hw->fc == e1000_fc_default) {
853 if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
854 hw->fc = e1000_fc_none;
855 else if((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
856 EEPROM_WORD0F_ASM_DIR)
857 hw->fc = e1000_fc_tx_pause;
858 else
859 hw->fc = e1000_fc_full; 852 hw->fc = e1000_fc_full;
853 break;
854 default:
855 ret_val = e1000_read_eeprom(hw, EEPROM_INIT_CONTROL2_REG,
856 1, &eeprom_data);
857 if (ret_val) {
858 DEBUGOUT("EEPROM Read Error\n");
859 return -E1000_ERR_EEPROM;
860 }
861 if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) == 0)
862 hw->fc = e1000_fc_none;
863 else if ((eeprom_data & EEPROM_WORD0F_PAUSE_MASK) ==
864 EEPROM_WORD0F_ASM_DIR)
865 hw->fc = e1000_fc_tx_pause;
866 else
867 hw->fc = e1000_fc_full;
868 break;
869 }
860 } 870 }
861 871
862 /* We want to save off the original Flow Control configuration just 872 /* We want to save off the original Flow Control configuration just
@@ -2962,13 +2972,22 @@ e1000_phy_hw_reset(struct e1000_hw *hw)
2962 if(hw->mac_type > e1000_82543) { 2972 if(hw->mac_type > e1000_82543) {
2963 /* Read the device control register and assert the E1000_CTRL_PHY_RST 2973 /* Read the device control register and assert the E1000_CTRL_PHY_RST
2964 * bit. Then, take it out of reset. 2974 * bit. Then, take it out of reset.
2975 * For pre-e1000_82571 hardware, we delay for 10ms between the assert
2976 * and deassert. For e1000_82571 hardware and later, we instead delay
2977 * for 10ms after the deassertion.
2965 */ 2978 */
2966 ctrl = E1000_READ_REG(hw, CTRL); 2979 ctrl = E1000_READ_REG(hw, CTRL);
2967 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST); 2980 E1000_WRITE_REG(hw, CTRL, ctrl | E1000_CTRL_PHY_RST);
2968 E1000_WRITE_FLUSH(hw); 2981 E1000_WRITE_FLUSH(hw);
2969 msec_delay(10); 2982
2983 if (hw->mac_type < e1000_82571)
2984 msec_delay(10);
2985
2970 E1000_WRITE_REG(hw, CTRL, ctrl); 2986 E1000_WRITE_REG(hw, CTRL, ctrl);
2971 E1000_WRITE_FLUSH(hw); 2987 E1000_WRITE_FLUSH(hw);
2988
2989 if (hw->mac_type >= e1000_82571)
2990 msec_delay(10);
2972 } else { 2991 } else {
2973 /* Read the Extended Device Control Register, assert the PHY_RESET_DIR 2992 /* Read the Extended Device Control Register, assert the PHY_RESET_DIR
2974 * bit to put the PHY into reset. Then, take it out of reset. 2993 * bit to put the PHY into reset. Then, take it out of reset.
@@ -5278,11 +5297,15 @@ e1000_get_bus_info(struct e1000_hw *hw)
5278 hw->bus_speed = e1000_bus_speed_unknown; 5297 hw->bus_speed = e1000_bus_speed_unknown;
5279 hw->bus_width = e1000_bus_width_unknown; 5298 hw->bus_width = e1000_bus_width_unknown;
5280 break; 5299 break;
5281 case e1000_82571:
5282 case e1000_82572: 5300 case e1000_82572:
5283 case e1000_82573: 5301 case e1000_82573:
5284 hw->bus_type = e1000_bus_type_pci_express; 5302 hw->bus_type = e1000_bus_type_pci_express;
5285 hw->bus_speed = e1000_bus_speed_2500; 5303 hw->bus_speed = e1000_bus_speed_2500;
5304 hw->bus_width = e1000_bus_width_pciex_1;
5305 break;
5306 case e1000_82571:
5307 hw->bus_type = e1000_bus_type_pci_express;
5308 hw->bus_speed = e1000_bus_speed_2500;
5286 hw->bus_width = e1000_bus_width_pciex_4; 5309 hw->bus_width = e1000_bus_width_pciex_4;
5287 break; 5310 break;
5288 default: 5311 default:
@@ -6650,6 +6673,12 @@ e1000_get_auto_rd_done(struct e1000_hw *hw)
6650 break; 6673 break;
6651 } 6674 }
6652 6675
6676 /* PHY configuration from NVM just starts after EECD_AUTO_RD sets to high.
6677 * Need to wait for PHY configuration completion before accessing NVM
6678 * and PHY. */
6679 if (hw->mac_type == e1000_82573)
6680 msec_delay(25);
6681
6653 return E1000_SUCCESS; 6682 return E1000_SUCCESS;
6654} 6683}
6655 6684
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h
index 76ce12809a11..7caa35748cea 100644
--- a/drivers/net/e1000/e1000_hw.h
+++ b/drivers/net/e1000/e1000_hw.h
@@ -123,6 +123,7 @@ typedef enum {
123 e1000_bus_width_32, 123 e1000_bus_width_32,
124 e1000_bus_width_64, 124 e1000_bus_width_64,
125 e1000_bus_width_pciex_1, 125 e1000_bus_width_pciex_1,
126 e1000_bus_width_pciex_2,
126 e1000_bus_width_pciex_4, 127 e1000_bus_width_pciex_4,
127 e1000_bus_width_reserved 128 e1000_bus_width_reserved
128} e1000_bus_width; 129} e1000_bus_width;
@@ -149,6 +150,7 @@ typedef enum {
149 e1000_igp_cable_length_90 = 90, 150 e1000_igp_cable_length_90 = 90,
150 e1000_igp_cable_length_100 = 100, 151 e1000_igp_cable_length_100 = 100,
151 e1000_igp_cable_length_110 = 110, 152 e1000_igp_cable_length_110 = 110,
153 e1000_igp_cable_length_115 = 115,
152 e1000_igp_cable_length_120 = 120, 154 e1000_igp_cable_length_120 = 120,
153 e1000_igp_cable_length_130 = 130, 155 e1000_igp_cable_length_130 = 130,
154 e1000_igp_cable_length_140 = 140, 156 e1000_igp_cable_length_140 = 140,
@@ -1457,6 +1459,7 @@ struct e1000_hw {
1457#define E1000_EECD_AUPDEN 0x00100000 /* Enable Autonomous FLASH update */ 1459#define E1000_EECD_AUPDEN 0x00100000 /* Enable Autonomous FLASH update */
1458#define E1000_EECD_SHADV 0x00200000 /* Shadow RAM Data Valid */ 1460#define E1000_EECD_SHADV 0x00200000 /* Shadow RAM Data Valid */
1459#define E1000_EECD_SEC1VAL 0x00400000 /* Sector One Valid */ 1461#define E1000_EECD_SEC1VAL 0x00400000 /* Sector One Valid */
1462#define E1000_EECD_SECVAL_SHIFT 22
1460#define E1000_STM_OPCODE 0xDB00 1463#define E1000_STM_OPCODE 0xDB00
1461#define E1000_HICR_FW_RESET 0xC0 1464#define E1000_HICR_FW_RESET 0xC0
1462 1465
@@ -1951,7 +1954,6 @@ struct e1000_host_command_info {
1951 1954
1952#define E1000_MDALIGN 4096 1955#define E1000_MDALIGN 4096
1953 1956
1954#define E1000_GCR_BEM32 0x00400000
1955#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 1957#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000
1956/* Function Active and Power State to MNG */ 1958/* Function Active and Power State to MNG */
1957#define E1000_FACTPS_FUNC0_POWER_STATE_MASK 0x00000003 1959#define E1000_FACTPS_FUNC0_POWER_STATE_MASK 0x00000003
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index e0ae248b4313..438a931fd55d 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -711,6 +711,7 @@ e1000_probe(struct pci_dev *pdev,
711 break; 711 break;
712 case e1000_82546: 712 case e1000_82546:
713 case e1000_82546_rev_3: 713 case e1000_82546_rev_3:
714 case e1000_82571:
714 if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1) 715 if((E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_FUNC_1)
715 && (adapter->hw.media_type == e1000_media_type_copper)) { 716 && (adapter->hw.media_type == e1000_media_type_copper)) {
716 e1000_read_eeprom(&adapter->hw, 717 e1000_read_eeprom(&adapter->hw,
@@ -1158,7 +1159,6 @@ e1000_setup_tx_resources(struct e1000_adapter *adapter,
1158 return -ENOMEM; 1159 return -ENOMEM;
1159 } 1160 }
1160 memset(txdr->buffer_info, 0, size); 1161 memset(txdr->buffer_info, 0, size);
1161 memset(&txdr->previous_buffer_info, 0, sizeof(struct e1000_buffer));
1162 1162
1163 /* round up to nearest 4K */ 1163 /* round up to nearest 4K */
1164 1164
@@ -1813,11 +1813,6 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter,
1813 1813
1814 /* Free all the Tx ring sk_buffs */ 1814 /* Free all the Tx ring sk_buffs */
1815 1815
1816 if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
1817 e1000_unmap_and_free_tx_resource(adapter,
1818 &tx_ring->previous_buffer_info);
1819 }
1820
1821 for(i = 0; i < tx_ring->count; i++) { 1816 for(i = 0; i < tx_ring->count; i++) {
1822 buffer_info = &tx_ring->buffer_info[i]; 1817 buffer_info = &tx_ring->buffer_info[i];
1823 e1000_unmap_and_free_tx_resource(adapter, buffer_info); 1818 e1000_unmap_and_free_tx_resource(adapter, buffer_info);
@@ -1832,6 +1827,7 @@ e1000_clean_tx_ring(struct e1000_adapter *adapter,
1832 1827
1833 tx_ring->next_to_use = 0; 1828 tx_ring->next_to_use = 0;
1834 tx_ring->next_to_clean = 0; 1829 tx_ring->next_to_clean = 0;
1830 tx_ring->last_tx_tso = 0;
1835 1831
1836 writel(0, adapter->hw.hw_addr + tx_ring->tdh); 1832 writel(0, adapter->hw.hw_addr + tx_ring->tdh);
1837 writel(0, adapter->hw.hw_addr + tx_ring->tdt); 1833 writel(0, adapter->hw.hw_addr + tx_ring->tdt);
@@ -2437,6 +2433,16 @@ e1000_tx_map(struct e1000_adapter *adapter, struct e1000_tx_ring *tx_ring,
2437 buffer_info = &tx_ring->buffer_info[i]; 2433 buffer_info = &tx_ring->buffer_info[i];
2438 size = min(len, max_per_txd); 2434 size = min(len, max_per_txd);
2439#ifdef NETIF_F_TSO 2435#ifdef NETIF_F_TSO
2436 /* Workaround for Controller erratum --
2437 * descriptor for non-tso packet in a linear SKB that follows a
2438 * tso gets written back prematurely before the data is fully
2439 * DMAd to the controller */
2440 if (!skb->data_len && tx_ring->last_tx_tso &&
2441 !skb_shinfo(skb)->tso_size) {
2442 tx_ring->last_tx_tso = 0;
2443 size -= 4;
2444 }
2445
2440 /* Workaround for premature desc write-backs 2446 /* Workaround for premature desc write-backs
2441 * in TSO mode. Append 4-byte sentinel desc */ 2447 * in TSO mode. Append 4-byte sentinel desc */
2442 if(unlikely(mss && !nr_frags && size == len && size > 8)) 2448 if(unlikely(mss && !nr_frags && size == len && size > 8))
@@ -2693,6 +2699,14 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2693 if(skb->ip_summed == CHECKSUM_HW) 2699 if(skb->ip_summed == CHECKSUM_HW)
2694 count++; 2700 count++;
2695#endif 2701#endif
2702
2703#ifdef NETIF_F_TSO
2704 /* Controller Erratum workaround */
2705 if (!skb->data_len && tx_ring->last_tx_tso &&
2706 !skb_shinfo(skb)->tso_size)
2707 count++;
2708#endif
2709
2696 count += TXD_USE_COUNT(len, max_txd_pwr); 2710 count += TXD_USE_COUNT(len, max_txd_pwr);
2697 2711
2698 if(adapter->pcix_82544) 2712 if(adapter->pcix_82544)
@@ -2774,9 +2788,10 @@ e1000_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
2774 return NETDEV_TX_OK; 2788 return NETDEV_TX_OK;
2775 } 2789 }
2776 2790
2777 if (likely(tso)) 2791 if (likely(tso)) {
2792 tx_ring->last_tx_tso = 1;
2778 tx_flags |= E1000_TX_FLAGS_TSO; 2793 tx_flags |= E1000_TX_FLAGS_TSO;
2779 else if (likely(e1000_tx_csum(adapter, tx_ring, skb))) 2794 } else if (likely(e1000_tx_csum(adapter, tx_ring, skb)))
2780 tx_flags |= E1000_TX_FLAGS_CSUM; 2795 tx_flags |= E1000_TX_FLAGS_CSUM;
2781 2796
2782 /* Old method was to assume IPv4 packet by default if TSO was enabled. 2797 /* Old method was to assume IPv4 packet by default if TSO was enabled.
@@ -3227,37 +3242,12 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3227 eop_desc = E1000_TX_DESC(*tx_ring, eop); 3242 eop_desc = E1000_TX_DESC(*tx_ring, eop);
3228 3243
3229 while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) { 3244 while (eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) {
3230 /* Premature writeback of Tx descriptors clear (free buffers
3231 * and unmap pci_mapping) previous_buffer_info */
3232 if (likely(tx_ring->previous_buffer_info.skb != NULL)) {
3233 e1000_unmap_and_free_tx_resource(adapter,
3234 &tx_ring->previous_buffer_info);
3235 }
3236
3237 for(cleaned = FALSE; !cleaned; ) { 3245 for(cleaned = FALSE; !cleaned; ) {
3238 tx_desc = E1000_TX_DESC(*tx_ring, i); 3246 tx_desc = E1000_TX_DESC(*tx_ring, i);
3239 buffer_info = &tx_ring->buffer_info[i]; 3247 buffer_info = &tx_ring->buffer_info[i];
3240 cleaned = (i == eop); 3248 cleaned = (i == eop);
3241 3249
3242#ifdef NETIF_F_TSO 3250 e1000_unmap_and_free_tx_resource(adapter, buffer_info);
3243 if (!(netdev->features & NETIF_F_TSO)) {
3244#endif
3245 e1000_unmap_and_free_tx_resource(adapter,
3246 buffer_info);
3247#ifdef NETIF_F_TSO
3248 } else {
3249 if (cleaned) {
3250 memcpy(&tx_ring->previous_buffer_info,
3251 buffer_info,
3252 sizeof(struct e1000_buffer));
3253 memset(buffer_info, 0,
3254 sizeof(struct e1000_buffer));
3255 } else {
3256 e1000_unmap_and_free_tx_resource(
3257 adapter, buffer_info);
3258 }
3259 }
3260#endif
3261 3251
3262 tx_desc->buffer_addr = 0; 3252 tx_desc->buffer_addr = 0;
3263 tx_desc->lower.data = 0; 3253 tx_desc->lower.data = 0;
@@ -3318,12 +3308,6 @@ e1000_clean_tx_irq(struct e1000_adapter *adapter,
3318 netif_stop_queue(netdev); 3308 netif_stop_queue(netdev);
3319 } 3309 }
3320 } 3310 }
3321#ifdef NETIF_F_TSO
3322 if (unlikely(!(eop_desc->upper.data & cpu_to_le32(E1000_TXD_STAT_DD)) &&
3323 time_after(jiffies, tx_ring->previous_buffer_info.time_stamp + HZ)))
3324 e1000_unmap_and_free_tx_resource(
3325 adapter, &tx_ring->previous_buffer_info);
3326#endif
3327 return cleaned; 3311 return cleaned;
3328} 3312}
3329 3313
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 525624fc03b4..c39344adecce 100644
--- a/drivers/net/forcedeth.c
+++ b/drivers/net/forcedeth.c
@@ -10,7 +10,7 @@
10 * trademarks of NVIDIA Corporation in the United States and other 10 * trademarks of NVIDIA Corporation in the United States and other
11 * countries. 11 * countries.
12 * 12 *
13 * Copyright (C) 2003,4 Manfred Spraul 13 * Copyright (C) 2003,4,5 Manfred Spraul
14 * Copyright (C) 2004 Andrew de Quincey (wol support) 14 * Copyright (C) 2004 Andrew de Quincey (wol support)
15 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane 15 * Copyright (C) 2004 Carl-Daniel Hailfinger (invalid MAC handling, insane
16 * IRQ rate fixes, bigendian fixes, cleanups, verification) 16 * IRQ rate fixes, bigendian fixes, cleanups, verification)
@@ -100,6 +100,7 @@
100 * 0.45: 18 Sep 2005: Remove nv_stop/start_rx from every link check 100 * 0.45: 18 Sep 2005: Remove nv_stop/start_rx from every link check
101 * 0.46: 20 Oct 2005: Add irq optimization modes. 101 * 0.46: 20 Oct 2005: Add irq optimization modes.
102 * 0.47: 26 Oct 2005: Add phyaddr 0 in phy scan. 102 * 0.47: 26 Oct 2005: Add phyaddr 0 in phy scan.
103 * 0.48: 24 Dec 2005: Disable TSO, bugfix for pci_map_single
103 * 104 *
104 * Known bugs: 105 * Known bugs:
105 * We suspect that on some hardware no TX done interrupts are generated. 106 * We suspect that on some hardware no TX done interrupts are generated.
@@ -111,7 +112,7 @@
111 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few 112 * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few
112 * superfluous timer interrupts from the nic. 113 * superfluous timer interrupts from the nic.
113 */ 114 */
114#define FORCEDETH_VERSION "0.47" 115#define FORCEDETH_VERSION "0.48"
115#define DRV_NAME "forcedeth" 116#define DRV_NAME "forcedeth"
116 117
117#include <linux/module.h> 118#include <linux/module.h>
@@ -871,8 +872,8 @@ static int nv_alloc_rx(struct net_device *dev)
871 } else { 872 } else {
872 skb = np->rx_skbuff[nr]; 873 skb = np->rx_skbuff[nr];
873 } 874 }
874 np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data, skb->len, 875 np->rx_dma[nr] = pci_map_single(np->pci_dev, skb->data,
875 PCI_DMA_FROMDEVICE); 876 skb->end-skb->data, PCI_DMA_FROMDEVICE);
876 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) { 877 if (np->desc_ver == DESC_VER_1 || np->desc_ver == DESC_VER_2) {
877 np->rx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]); 878 np->rx_ring.orig[nr].PacketBuffer = cpu_to_le32(np->rx_dma[nr]);
878 wmb(); 879 wmb();
@@ -999,7 +1000,7 @@ static void nv_drain_rx(struct net_device *dev)
999 wmb(); 1000 wmb();
1000 if (np->rx_skbuff[i]) { 1001 if (np->rx_skbuff[i]) {
1001 pci_unmap_single(np->pci_dev, np->rx_dma[i], 1002 pci_unmap_single(np->pci_dev, np->rx_dma[i],
1002 np->rx_skbuff[i]->len, 1003 np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
1003 PCI_DMA_FROMDEVICE); 1004 PCI_DMA_FROMDEVICE);
1004 dev_kfree_skb(np->rx_skbuff[i]); 1005 dev_kfree_skb(np->rx_skbuff[i]);
1005 np->rx_skbuff[i] = NULL; 1006 np->rx_skbuff[i] = NULL;
@@ -1334,7 +1335,7 @@ static void nv_rx_process(struct net_device *dev)
1334 * the performance. 1335 * the performance.
1335 */ 1336 */
1336 pci_unmap_single(np->pci_dev, np->rx_dma[i], 1337 pci_unmap_single(np->pci_dev, np->rx_dma[i],
1337 np->rx_skbuff[i]->len, 1338 np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
1338 PCI_DMA_FROMDEVICE); 1339 PCI_DMA_FROMDEVICE);
1339 1340
1340 { 1341 {
@@ -2455,7 +2456,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2455 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK; 2456 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
2456 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; 2457 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
2457#ifdef NETIF_F_TSO 2458#ifdef NETIF_F_TSO
2458 dev->features |= NETIF_F_TSO; 2459 /* disabled dev->features |= NETIF_F_TSO; */
2459#endif 2460#endif
2460 } 2461 }
2461 2462
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 0f030b73cbb3..146f9513aea5 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -2,7 +2,8 @@
2 * drivers/net/gianfar.c 2 * drivers/net/gianfar.c
3 * 3 *
4 * Gianfar Ethernet Driver 4 * Gianfar Ethernet Driver
5 * Driver for FEC on MPC8540 and TSEC on MPC8540/MPC8560 5 * This driver is designed for the non-CPM ethernet controllers
6 * on the 85xx and 83xx family of integrated processors
6 * Based on 8260_io/fcc_enet.c 7 * Based on 8260_io/fcc_enet.c
7 * 8 *
8 * Author: Andy Fleming 9 * Author: Andy Fleming
@@ -22,8 +23,6 @@
22 * B-V +1.62 23 * B-V +1.62
23 * 24 *
24 * Theory of operation 25 * Theory of operation
25 * This driver is designed for the non-CPM ethernet controllers
26 * on the 85xx and 83xx family of integrated processors
27 * 26 *
28 * The driver is initialized through platform_device. Structures which 27 * The driver is initialized through platform_device. Structures which
29 * define the configuration needed by the board are defined in a 28 * define the configuration needed by the board are defined in a
@@ -110,7 +109,7 @@
110#endif 109#endif
111 110
112const char gfar_driver_name[] = "Gianfar Ethernet"; 111const char gfar_driver_name[] = "Gianfar Ethernet";
113const char gfar_driver_version[] = "1.2"; 112const char gfar_driver_version[] = "1.3";
114 113
115static int gfar_enet_open(struct net_device *dev); 114static int gfar_enet_open(struct net_device *dev);
116static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev); 115static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev);
@@ -139,6 +138,10 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb, int l
139static void gfar_vlan_rx_register(struct net_device *netdev, 138static void gfar_vlan_rx_register(struct net_device *netdev,
140 struct vlan_group *grp); 139 struct vlan_group *grp);
141static void gfar_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid); 140static void gfar_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
141void gfar_halt(struct net_device *dev);
142void gfar_start(struct net_device *dev);
143static void gfar_clear_exact_match(struct net_device *dev);
144static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr);
142 145
143extern struct ethtool_ops gfar_ethtool_ops; 146extern struct ethtool_ops gfar_ethtool_ops;
144 147
@@ -146,12 +149,10 @@ MODULE_AUTHOR("Freescale Semiconductor, Inc");
146MODULE_DESCRIPTION("Gianfar Ethernet Driver"); 149MODULE_DESCRIPTION("Gianfar Ethernet Driver");
147MODULE_LICENSE("GPL"); 150MODULE_LICENSE("GPL");
148 151
149int gfar_uses_fcb(struct gfar_private *priv) 152/* Returns 1 if incoming frames use an FCB */
153static inline int gfar_uses_fcb(struct gfar_private *priv)
150{ 154{
151 if (priv->vlan_enable || priv->rx_csum_enable) 155 return (priv->vlan_enable || priv->rx_csum_enable);
152 return 1;
153 else
154 return 0;
155} 156}
156 157
157/* Set up the ethernet device structure, private data, 158/* Set up the ethernet device structure, private data,
@@ -320,15 +321,10 @@ static int gfar_probe(struct platform_device *pdev)
320 else 321 else
321 priv->padding = 0; 322 priv->padding = 0;
322 323
323 dev->hard_header_len += priv->padding;
324
325 if (dev->features & NETIF_F_IP_CSUM) 324 if (dev->features & NETIF_F_IP_CSUM)
326 dev->hard_header_len += GMAC_FCB_LEN; 325 dev->hard_header_len += GMAC_FCB_LEN;
327 326
328 priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE; 327 priv->rx_buffer_size = DEFAULT_RX_BUFFER_SIZE;
329#ifdef CONFIG_GFAR_BUFSTASH
330 priv->rx_stash_size = STASH_LENGTH;
331#endif
332 priv->tx_ring_size = DEFAULT_TX_RING_SIZE; 328 priv->tx_ring_size = DEFAULT_TX_RING_SIZE;
333 priv->rx_ring_size = DEFAULT_RX_RING_SIZE; 329 priv->rx_ring_size = DEFAULT_RX_RING_SIZE;
334 330
@@ -350,6 +346,9 @@ static int gfar_probe(struct platform_device *pdev)
350 goto register_fail; 346 goto register_fail;
351 } 347 }
352 348
349 /* Create all the sysfs files */
350 gfar_init_sysfs(dev);
351
353 /* Print out the device info */ 352 /* Print out the device info */
354 printk(KERN_INFO DEVICE_NAME, dev->name); 353 printk(KERN_INFO DEVICE_NAME, dev->name);
355 for (idx = 0; idx < 6; idx++) 354 for (idx = 0; idx < 6; idx++)
@@ -357,8 +356,7 @@ static int gfar_probe(struct platform_device *pdev)
357 printk("\n"); 356 printk("\n");
358 357
359 /* Even more device info helps when determining which kernel */ 358 /* Even more device info helps when determining which kernel */
360 /* provided which set of benchmarks. Since this is global for all */ 359 /* provided which set of benchmarks. */
361 /* devices, we only print it once */
362#ifdef CONFIG_GFAR_NAPI 360#ifdef CONFIG_GFAR_NAPI
363 printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name); 361 printk(KERN_INFO "%s: Running with NAPI enabled\n", dev->name);
364#else 362#else
@@ -463,19 +461,9 @@ static void init_registers(struct net_device *dev)
463 /* Initialize the max receive buffer length */ 461 /* Initialize the max receive buffer length */
464 gfar_write(&priv->regs->mrblr, priv->rx_buffer_size); 462 gfar_write(&priv->regs->mrblr, priv->rx_buffer_size);
465 463
466#ifdef CONFIG_GFAR_BUFSTASH
467 /* If we are stashing buffers, we need to set the
468 * extraction length to the size of the buffer */
469 gfar_write(&priv->regs->attreli, priv->rx_stash_size << 16);
470#endif
471
472 /* Initialize the Minimum Frame Length Register */ 464 /* Initialize the Minimum Frame Length Register */
473 gfar_write(&priv->regs->minflr, MINFLR_INIT_SETTINGS); 465 gfar_write(&priv->regs->minflr, MINFLR_INIT_SETTINGS);
474 466
475 /* Setup Attributes so that snooping is on for rx */
476 gfar_write(&priv->regs->attr, ATTR_INIT_SETTINGS);
477 gfar_write(&priv->regs->attreli, ATTRELI_INIT_SETTINGS);
478
479 /* Assign the TBI an address which won't conflict with the PHYs */ 467 /* Assign the TBI an address which won't conflict with the PHYs */
480 gfar_write(&priv->regs->tbipa, TBIPA_VALUE); 468 gfar_write(&priv->regs->tbipa, TBIPA_VALUE);
481} 469}
@@ -577,8 +565,7 @@ static void free_skb_resources(struct gfar_private *priv)
577 for (i = 0; i < priv->rx_ring_size; i++) { 565 for (i = 0; i < priv->rx_ring_size; i++) {
578 if (priv->rx_skbuff[i]) { 566 if (priv->rx_skbuff[i]) {
579 dma_unmap_single(NULL, rxbdp->bufPtr, 567 dma_unmap_single(NULL, rxbdp->bufPtr,
580 priv->rx_buffer_size 568 priv->rx_buffer_size,
581 + RXBUF_ALIGNMENT,
582 DMA_FROM_DEVICE); 569 DMA_FROM_DEVICE);
583 570
584 dev_kfree_skb_any(priv->rx_skbuff[i]); 571 dev_kfree_skb_any(priv->rx_skbuff[i]);
@@ -636,6 +623,7 @@ int startup_gfar(struct net_device *dev)
636 struct gfar *regs = priv->regs; 623 struct gfar *regs = priv->regs;
637 int err = 0; 624 int err = 0;
638 u32 rctrl = 0; 625 u32 rctrl = 0;
626 u32 attrs = 0;
639 627
640 gfar_write(&regs->imask, IMASK_INIT_CLEAR); 628 gfar_write(&regs->imask, IMASK_INIT_CLEAR);
641 629
@@ -795,18 +783,50 @@ int startup_gfar(struct net_device *dev)
795 if (priv->rx_csum_enable) 783 if (priv->rx_csum_enable)
796 rctrl |= RCTRL_CHECKSUMMING; 784 rctrl |= RCTRL_CHECKSUMMING;
797 785
798 if (priv->extended_hash) 786 if (priv->extended_hash) {
799 rctrl |= RCTRL_EXTHASH; 787 rctrl |= RCTRL_EXTHASH;
800 788
789 gfar_clear_exact_match(dev);
790 rctrl |= RCTRL_EMEN;
791 }
792
801 if (priv->vlan_enable) 793 if (priv->vlan_enable)
802 rctrl |= RCTRL_VLAN; 794 rctrl |= RCTRL_VLAN;
803 795
796 if (priv->padding) {
797 rctrl &= ~RCTRL_PAL_MASK;
798 rctrl |= RCTRL_PADDING(priv->padding);
799 }
800
804 /* Init rctrl based on our settings */ 801 /* Init rctrl based on our settings */
805 gfar_write(&priv->regs->rctrl, rctrl); 802 gfar_write(&priv->regs->rctrl, rctrl);
806 803
807 if (dev->features & NETIF_F_IP_CSUM) 804 if (dev->features & NETIF_F_IP_CSUM)
808 gfar_write(&priv->regs->tctrl, TCTRL_INIT_CSUM); 805 gfar_write(&priv->regs->tctrl, TCTRL_INIT_CSUM);
809 806
807 /* Set the extraction length and index */
808 attrs = ATTRELI_EL(priv->rx_stash_size) |
809 ATTRELI_EI(priv->rx_stash_index);
810
811 gfar_write(&priv->regs->attreli, attrs);
812
813 /* Start with defaults, and add stashing or locking
814 * depending on the approprate variables */
815 attrs = ATTR_INIT_SETTINGS;
816
817 if (priv->bd_stash_en)
818 attrs |= ATTR_BDSTASH;
819
820 if (priv->rx_stash_size != 0)
821 attrs |= ATTR_BUFSTASH;
822
823 gfar_write(&priv->regs->attr, attrs);
824
825 gfar_write(&priv->regs->fifo_tx_thr, priv->fifo_threshold);
826 gfar_write(&priv->regs->fifo_tx_starve, priv->fifo_starve);
827 gfar_write(&priv->regs->fifo_tx_starve_shutoff, priv->fifo_starve_off);
828
829 /* Start the controller */
810 gfar_start(dev); 830 gfar_start(dev);
811 831
812 return 0; 832 return 0;
@@ -851,34 +871,32 @@ static int gfar_enet_open(struct net_device *dev)
851 return err; 871 return err;
852} 872}
853 873
854static struct txfcb *gfar_add_fcb(struct sk_buff *skb, struct txbd8 *bdp) 874static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb, struct txbd8 *bdp)
855{ 875{
856 struct txfcb *fcb = (struct txfcb *)skb_push (skb, GMAC_FCB_LEN); 876 struct txfcb *fcb = (struct txfcb *)skb_push (skb, GMAC_FCB_LEN);
857 877
858 memset(fcb, 0, GMAC_FCB_LEN); 878 memset(fcb, 0, GMAC_FCB_LEN);
859 879
860 /* Flag the bd so the controller looks for the FCB */
861 bdp->status |= TXBD_TOE;
862
863 return fcb; 880 return fcb;
864} 881}
865 882
866static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb) 883static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
867{ 884{
868 int len; 885 u8 flags = 0;
869 886
870 /* If we're here, it's a IP packet with a TCP or UDP 887 /* If we're here, it's a IP packet with a TCP or UDP
871 * payload. We set it to checksum, using a pseudo-header 888 * payload. We set it to checksum, using a pseudo-header
872 * we provide 889 * we provide
873 */ 890 */
874 fcb->ip = 1; 891 flags = TXFCB_DEFAULT;
875 fcb->tup = 1;
876 fcb->ctu = 1;
877 fcb->nph = 1;
878 892
879 /* Notify the controller what the protocol is */ 893 /* Tell the controller what the protocol is */
880 if (skb->nh.iph->protocol == IPPROTO_UDP) 894 /* And provide the already calculated phcs */
881 fcb->udp = 1; 895 if (skb->nh.iph->protocol == IPPROTO_UDP) {
896 flags |= TXFCB_UDP;
897 fcb->phcs = skb->h.uh->check;
898 } else
899 fcb->phcs = skb->h.th->check;
882 900
883 /* l3os is the distance between the start of the 901 /* l3os is the distance between the start of the
884 * frame (skb->data) and the start of the IP hdr. 902 * frame (skb->data) and the start of the IP hdr.
@@ -887,17 +905,12 @@ static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb)
887 fcb->l3os = (u16)(skb->nh.raw - skb->data - GMAC_FCB_LEN); 905 fcb->l3os = (u16)(skb->nh.raw - skb->data - GMAC_FCB_LEN);
888 fcb->l4os = (u16)(skb->h.raw - skb->nh.raw); 906 fcb->l4os = (u16)(skb->h.raw - skb->nh.raw);
889 907
890 len = skb->nh.iph->tot_len - fcb->l4os; 908 fcb->flags = flags;
891
892 /* Provide the pseudoheader csum */
893 fcb->phcs = ~csum_tcpudp_magic(skb->nh.iph->saddr,
894 skb->nh.iph->daddr, len,
895 skb->nh.iph->protocol, 0);
896} 909}
897 910
898void gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb) 911void inline gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb)
899{ 912{
900 fcb->vln = 1; 913 fcb->flags |= TXFCB_VLN;
901 fcb->vlctl = vlan_tx_tag_get(skb); 914 fcb->vlctl = vlan_tx_tag_get(skb);
902} 915}
903 916
@@ -908,6 +921,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
908 struct gfar_private *priv = netdev_priv(dev); 921 struct gfar_private *priv = netdev_priv(dev);
909 struct txfcb *fcb = NULL; 922 struct txfcb *fcb = NULL;
910 struct txbd8 *txbdp; 923 struct txbd8 *txbdp;
924 u16 status;
911 925
912 /* Update transmit stats */ 926 /* Update transmit stats */
913 priv->stats.tx_bytes += skb->len; 927 priv->stats.tx_bytes += skb->len;
@@ -919,19 +933,22 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
919 txbdp = priv->cur_tx; 933 txbdp = priv->cur_tx;
920 934
921 /* Clear all but the WRAP status flags */ 935 /* Clear all but the WRAP status flags */
922 txbdp->status &= TXBD_WRAP; 936 status = txbdp->status & TXBD_WRAP;
923 937
924 /* Set up checksumming */ 938 /* Set up checksumming */
925 if ((dev->features & NETIF_F_IP_CSUM) 939 if (likely((dev->features & NETIF_F_IP_CSUM)
926 && (CHECKSUM_HW == skb->ip_summed)) { 940 && (CHECKSUM_HW == skb->ip_summed))) {
927 fcb = gfar_add_fcb(skb, txbdp); 941 fcb = gfar_add_fcb(skb, txbdp);
942 status |= TXBD_TOE;
928 gfar_tx_checksum(skb, fcb); 943 gfar_tx_checksum(skb, fcb);
929 } 944 }
930 945
931 if (priv->vlan_enable && 946 if (priv->vlan_enable &&
932 unlikely(priv->vlgrp && vlan_tx_tag_present(skb))) { 947 unlikely(priv->vlgrp && vlan_tx_tag_present(skb))) {
933 if (NULL == fcb) 948 if (unlikely(NULL == fcb)) {
934 fcb = gfar_add_fcb(skb, txbdp); 949 fcb = gfar_add_fcb(skb, txbdp);
950 status |= TXBD_TOE;
951 }
935 952
936 gfar_tx_vlan(skb, fcb); 953 gfar_tx_vlan(skb, fcb);
937 } 954 }
@@ -949,14 +966,16 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
949 (priv->skb_curtx + 1) & TX_RING_MOD_MASK(priv->tx_ring_size); 966 (priv->skb_curtx + 1) & TX_RING_MOD_MASK(priv->tx_ring_size);
950 967
951 /* Flag the BD as interrupt-causing */ 968 /* Flag the BD as interrupt-causing */
952 txbdp->status |= TXBD_INTERRUPT; 969 status |= TXBD_INTERRUPT;
953 970
954 /* Flag the BD as ready to go, last in frame, and */ 971 /* Flag the BD as ready to go, last in frame, and */
955 /* in need of CRC */ 972 /* in need of CRC */
956 txbdp->status |= (TXBD_READY | TXBD_LAST | TXBD_CRC); 973 status |= (TXBD_READY | TXBD_LAST | TXBD_CRC);
957 974
958 dev->trans_start = jiffies; 975 dev->trans_start = jiffies;
959 976
977 txbdp->status = status;
978
960 /* If this was the last BD in the ring, the next one */ 979 /* If this was the last BD in the ring, the next one */
961 /* is at the beginning of the ring */ 980 /* is at the beginning of the ring */
962 if (txbdp->status & TXBD_WRAP) 981 if (txbdp->status & TXBD_WRAP)
@@ -1010,21 +1029,7 @@ static struct net_device_stats * gfar_get_stats(struct net_device *dev)
1010/* Changes the mac address if the controller is not running. */ 1029/* Changes the mac address if the controller is not running. */
1011int gfar_set_mac_address(struct net_device *dev) 1030int gfar_set_mac_address(struct net_device *dev)
1012{ 1031{
1013 struct gfar_private *priv = netdev_priv(dev); 1032 gfar_set_mac_for_addr(dev, 0, dev->dev_addr);
1014 int i;
1015 char tmpbuf[MAC_ADDR_LEN];
1016 u32 tempval;
1017
1018 /* Now copy it into the mac registers backwards, cuz */
1019 /* little endian is silly */
1020 for (i = 0; i < MAC_ADDR_LEN; i++)
1021 tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->dev_addr[i];
1022
1023 gfar_write(&priv->regs->macstnaddr1, *((u32 *) (tmpbuf)));
1024
1025 tempval = *((u32 *) (tmpbuf + 4));
1026
1027 gfar_write(&priv->regs->macstnaddr2, tempval);
1028 1033
1029 return 0; 1034 return 0;
1030} 1035}
@@ -1110,7 +1115,7 @@ static int gfar_change_mtu(struct net_device *dev, int new_mtu)
1110 INCREMENTAL_BUFFER_SIZE; 1115 INCREMENTAL_BUFFER_SIZE;
1111 1116
1112 /* Only stop and start the controller if it isn't already 1117 /* Only stop and start the controller if it isn't already
1113 * stopped */ 1118 * stopped, and we changed something */
1114 if ((oldsize != tempsize) && (dev->flags & IFF_UP)) 1119 if ((oldsize != tempsize) && (dev->flags & IFF_UP))
1115 stop_gfar(dev); 1120 stop_gfar(dev);
1116 1121
@@ -1220,6 +1225,7 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs)
1220 1225
1221struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp) 1226struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
1222{ 1227{
1228 unsigned int alignamount;
1223 struct gfar_private *priv = netdev_priv(dev); 1229 struct gfar_private *priv = netdev_priv(dev);
1224 struct sk_buff *skb = NULL; 1230 struct sk_buff *skb = NULL;
1225 unsigned int timeout = SKB_ALLOC_TIMEOUT; 1231 unsigned int timeout = SKB_ALLOC_TIMEOUT;
@@ -1231,18 +1237,18 @@ struct sk_buff * gfar_new_skb(struct net_device *dev, struct rxbd8 *bdp)
1231 if (NULL == skb) 1237 if (NULL == skb)
1232 return NULL; 1238 return NULL;
1233 1239
1240 alignamount = RXBUF_ALIGNMENT -
1241 (((unsigned) skb->data) & (RXBUF_ALIGNMENT - 1));
1242
1234 /* We need the data buffer to be aligned properly. We will reserve 1243 /* We need the data buffer to be aligned properly. We will reserve
1235 * as many bytes as needed to align the data properly 1244 * as many bytes as needed to align the data properly
1236 */ 1245 */
1237 skb_reserve(skb, 1246 skb_reserve(skb, alignamount);
1238 RXBUF_ALIGNMENT -
1239 (((unsigned) skb->data) & (RXBUF_ALIGNMENT - 1)));
1240 1247
1241 skb->dev = dev; 1248 skb->dev = dev;
1242 1249
1243 bdp->bufPtr = dma_map_single(NULL, skb->data, 1250 bdp->bufPtr = dma_map_single(NULL, skb->data,
1244 priv->rx_buffer_size + RXBUF_ALIGNMENT, 1251 priv->rx_buffer_size, DMA_FROM_DEVICE);
1245 DMA_FROM_DEVICE);
1246 1252
1247 bdp->length = 0; 1253 bdp->length = 0;
1248 1254
@@ -1350,7 +1356,7 @@ static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb)
1350 /* If valid headers were found, and valid sums 1356 /* If valid headers were found, and valid sums
1351 * were verified, then we tell the kernel that no 1357 * were verified, then we tell the kernel that no
1352 * checksumming is necessary. Otherwise, it is */ 1358 * checksumming is necessary. Otherwise, it is */
1353 if (fcb->cip && !fcb->eip && fcb->ctu && !fcb->etu) 1359 if ((fcb->flags & RXFCB_CSUM_MASK) == (RXFCB_CIP | RXFCB_CTU))
1354 skb->ip_summed = CHECKSUM_UNNECESSARY; 1360 skb->ip_summed = CHECKSUM_UNNECESSARY;
1355 else 1361 else
1356 skb->ip_summed = CHECKSUM_NONE; 1362 skb->ip_summed = CHECKSUM_NONE;
@@ -1401,7 +1407,7 @@ static int gfar_process_frame(struct net_device *dev, struct sk_buff *skb,
1401 skb->protocol = eth_type_trans(skb, dev); 1407 skb->protocol = eth_type_trans(skb, dev);
1402 1408
1403 /* Send the packet up the stack */ 1409 /* Send the packet up the stack */
1404 if (unlikely(priv->vlgrp && fcb->vln)) 1410 if (unlikely(priv->vlgrp && (fcb->flags & RXFCB_VLN)))
1405 ret = gfar_rx_vlan(skb, priv->vlgrp, fcb->vlctl); 1411 ret = gfar_rx_vlan(skb, priv->vlgrp, fcb->vlctl);
1406 else 1412 else
1407 ret = RECEIVE(skb); 1413 ret = RECEIVE(skb);
@@ -1620,6 +1626,7 @@ static void adjust_link(struct net_device *dev)
1620 spin_lock_irqsave(&priv->lock, flags); 1626 spin_lock_irqsave(&priv->lock, flags);
1621 if (phydev->link) { 1627 if (phydev->link) {
1622 u32 tempval = gfar_read(&regs->maccfg2); 1628 u32 tempval = gfar_read(&regs->maccfg2);
1629 u32 ecntrl = gfar_read(&regs->ecntrl);
1623 1630
1624 /* Now we make sure that we can be in full duplex mode. 1631 /* Now we make sure that we can be in full duplex mode.
1625 * If not, we operate in half-duplex mode. */ 1632 * If not, we operate in half-duplex mode. */
@@ -1644,6 +1651,13 @@ static void adjust_link(struct net_device *dev)
1644 case 10: 1651 case 10:
1645 tempval = 1652 tempval =
1646 ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII); 1653 ((tempval & ~(MACCFG2_IF)) | MACCFG2_MII);
1654
1655 /* Reduced mode distinguishes
1656 * between 10 and 100 */
1657 if (phydev->speed == SPEED_100)
1658 ecntrl |= ECNTRL_R100;
1659 else
1660 ecntrl &= ~(ECNTRL_R100);
1647 break; 1661 break;
1648 default: 1662 default:
1649 if (netif_msg_link(priv)) 1663 if (netif_msg_link(priv))
@@ -1657,6 +1671,7 @@ static void adjust_link(struct net_device *dev)
1657 } 1671 }
1658 1672
1659 gfar_write(&regs->maccfg2, tempval); 1673 gfar_write(&regs->maccfg2, tempval);
1674 gfar_write(&regs->ecntrl, ecntrl);
1660 1675
1661 if (!priv->oldlink) { 1676 if (!priv->oldlink) {
1662 new_state = 1; 1677 new_state = 1;
@@ -1721,6 +1736,9 @@ static void gfar_set_multi(struct net_device *dev)
1721 gfar_write(&regs->gaddr6, 0xffffffff); 1736 gfar_write(&regs->gaddr6, 0xffffffff);
1722 gfar_write(&regs->gaddr7, 0xffffffff); 1737 gfar_write(&regs->gaddr7, 0xffffffff);
1723 } else { 1738 } else {
1739 int em_num;
1740 int idx;
1741
1724 /* zero out the hash */ 1742 /* zero out the hash */
1725 gfar_write(&regs->igaddr0, 0x0); 1743 gfar_write(&regs->igaddr0, 0x0);
1726 gfar_write(&regs->igaddr1, 0x0); 1744 gfar_write(&regs->igaddr1, 0x0);
@@ -1739,18 +1757,47 @@ static void gfar_set_multi(struct net_device *dev)
1739 gfar_write(&regs->gaddr6, 0x0); 1757 gfar_write(&regs->gaddr6, 0x0);
1740 gfar_write(&regs->gaddr7, 0x0); 1758 gfar_write(&regs->gaddr7, 0x0);
1741 1759
1760 /* If we have extended hash tables, we need to
1761 * clear the exact match registers to prepare for
1762 * setting them */
1763 if (priv->extended_hash) {
1764 em_num = GFAR_EM_NUM + 1;
1765 gfar_clear_exact_match(dev);
1766 idx = 1;
1767 } else {
1768 idx = 0;
1769 em_num = 0;
1770 }
1771
1742 if(dev->mc_count == 0) 1772 if(dev->mc_count == 0)
1743 return; 1773 return;
1744 1774
1745 /* Parse the list, and set the appropriate bits */ 1775 /* Parse the list, and set the appropriate bits */
1746 for(mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) { 1776 for(mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) {
1747 gfar_set_hash_for_addr(dev, mc_ptr->dmi_addr); 1777 if (idx < em_num) {
1778 gfar_set_mac_for_addr(dev, idx,
1779 mc_ptr->dmi_addr);
1780 idx++;
1781 } else
1782 gfar_set_hash_for_addr(dev, mc_ptr->dmi_addr);
1748 } 1783 }
1749 } 1784 }
1750 1785
1751 return; 1786 return;
1752} 1787}
1753 1788
1789
1790/* Clears each of the exact match registers to zero, so they
1791 * don't interfere with normal reception */
1792static void gfar_clear_exact_match(struct net_device *dev)
1793{
1794 int idx;
1795 u8 zero_arr[MAC_ADDR_LEN] = {0,0,0,0,0,0};
1796
1797 for(idx = 1;idx < GFAR_EM_NUM + 1;idx++)
1798 gfar_set_mac_for_addr(dev, idx, (u8 *)zero_arr);
1799}
1800
1754/* Set the appropriate hash bit for the given addr */ 1801/* Set the appropriate hash bit for the given addr */
1755/* The algorithm works like so: 1802/* The algorithm works like so:
1756 * 1) Take the Destination Address (ie the multicast address), and 1803 * 1) Take the Destination Address (ie the multicast address), and
@@ -1781,6 +1828,32 @@ static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr)
1781 return; 1828 return;
1782} 1829}
1783 1830
1831
1832/* There are multiple MAC Address register pairs on some controllers
1833 * This function sets the numth pair to a given address
1834 */
1835static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr)
1836{
1837 struct gfar_private *priv = netdev_priv(dev);
1838 int idx;
1839 char tmpbuf[MAC_ADDR_LEN];
1840 u32 tempval;
1841 u32 *macptr = &priv->regs->macstnaddr1;
1842
1843 macptr += num*2;
1844
1845 /* Now copy it into the mac registers backwards, cuz */
1846 /* little endian is silly */
1847 for (idx = 0; idx < MAC_ADDR_LEN; idx++)
1848 tmpbuf[MAC_ADDR_LEN - 1 - idx] = addr[idx];
1849
1850 gfar_write(macptr, *((u32 *) (tmpbuf)));
1851
1852 tempval = *((u32 *) (tmpbuf + 4));
1853
1854 gfar_write(macptr+1, tempval);
1855}
1856
1784/* GFAR error interrupt handler */ 1857/* GFAR error interrupt handler */
1785static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs) 1858static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs)
1786{ 1859{
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 5065ba82cb76..94a91da84fbb 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -90,12 +90,26 @@ extern const char gfar_driver_version[];
90#define GFAR_RX_MAX_RING_SIZE 256 90#define GFAR_RX_MAX_RING_SIZE 256
91#define GFAR_TX_MAX_RING_SIZE 256 91#define GFAR_TX_MAX_RING_SIZE 256
92 92
93#define GFAR_MAX_FIFO_THRESHOLD 511
94#define GFAR_MAX_FIFO_STARVE 511
95#define GFAR_MAX_FIFO_STARVE_OFF 511
96
93#define DEFAULT_RX_BUFFER_SIZE 1536 97#define DEFAULT_RX_BUFFER_SIZE 1536
94#define TX_RING_MOD_MASK(size) (size-1) 98#define TX_RING_MOD_MASK(size) (size-1)
95#define RX_RING_MOD_MASK(size) (size-1) 99#define RX_RING_MOD_MASK(size) (size-1)
96#define JUMBO_BUFFER_SIZE 9728 100#define JUMBO_BUFFER_SIZE 9728
97#define JUMBO_FRAME_SIZE 9600 101#define JUMBO_FRAME_SIZE 9600
98 102
103#define DEFAULT_FIFO_TX_THR 0x100
104#define DEFAULT_FIFO_TX_STARVE 0x40
105#define DEFAULT_FIFO_TX_STARVE_OFF 0x80
106#define DEFAULT_BD_STASH 1
107#define DEFAULT_STASH_LENGTH 64
108#define DEFAULT_STASH_INDEX 0
109
110/* The number of Exact Match registers */
111#define GFAR_EM_NUM 15
112
99/* Latency of interface clock in nanoseconds */ 113/* Latency of interface clock in nanoseconds */
100/* Interface clock latency , in this case, means the 114/* Interface clock latency , in this case, means the
101 * time described by a value of 1 in the interrupt 115 * time described by a value of 1 in the interrupt
@@ -112,11 +126,11 @@ extern const char gfar_driver_version[];
112 126
113#define DEFAULT_TX_COALESCE 1 127#define DEFAULT_TX_COALESCE 1
114#define DEFAULT_TXCOUNT 16 128#define DEFAULT_TXCOUNT 16
115#define DEFAULT_TXTIME 400 129#define DEFAULT_TXTIME 4
116 130
117#define DEFAULT_RX_COALESCE 1 131#define DEFAULT_RX_COALESCE 1
118#define DEFAULT_RXCOUNT 16 132#define DEFAULT_RXCOUNT 16
119#define DEFAULT_RXTIME 400 133#define DEFAULT_RXTIME 4
120 134
121#define TBIPA_VALUE 0x1f 135#define TBIPA_VALUE 0x1f
122#define MIIMCFG_INIT_VALUE 0x00000007 136#define MIIMCFG_INIT_VALUE 0x00000007
@@ -147,6 +161,7 @@ extern const char gfar_driver_version[];
147 161
148#define ECNTRL_INIT_SETTINGS 0x00001000 162#define ECNTRL_INIT_SETTINGS 0x00001000
149#define ECNTRL_TBI_MODE 0x00000020 163#define ECNTRL_TBI_MODE 0x00000020
164#define ECNTRL_R100 0x00000008
150 165
151#define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE 166#define MRBLR_INIT_SETTINGS DEFAULT_RX_BUFFER_SIZE
152 167
@@ -181,10 +196,12 @@ extern const char gfar_driver_version[];
181#define RCTRL_PRSDEP_MASK 0x000000c0 196#define RCTRL_PRSDEP_MASK 0x000000c0
182#define RCTRL_PRSDEP_INIT 0x000000c0 197#define RCTRL_PRSDEP_INIT 0x000000c0
183#define RCTRL_PROM 0x00000008 198#define RCTRL_PROM 0x00000008
199#define RCTRL_EMEN 0x00000002
184#define RCTRL_CHECKSUMMING (RCTRL_IPCSEN \ 200#define RCTRL_CHECKSUMMING (RCTRL_IPCSEN \
185 | RCTRL_TUCSEN | RCTRL_PRSDEP_INIT) 201 | RCTRL_TUCSEN | RCTRL_PRSDEP_INIT)
186#define RCTRL_EXTHASH (RCTRL_GHTX) 202#define RCTRL_EXTHASH (RCTRL_GHTX)
187#define RCTRL_VLAN (RCTRL_PRSDEP_INIT) 203#define RCTRL_VLAN (RCTRL_PRSDEP_INIT)
204#define RCTRL_PADDING(x) ((x << 16) & RCTRL_PAL_MASK)
188 205
189 206
190#define RSTAT_CLEAR_RHALT 0x00800000 207#define RSTAT_CLEAR_RHALT 0x00800000
@@ -251,28 +268,26 @@ extern const char gfar_driver_version[];
251 IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \ 268 IMASK_XFUN | IMASK_RXC | IMASK_BABT | IMASK_DPE \
252 | IMASK_PERR) 269 | IMASK_PERR)
253 270
271/* Fifo management */
272#define FIFO_TX_THR_MASK 0x01ff
273#define FIFO_TX_STARVE_MASK 0x01ff
274#define FIFO_TX_STARVE_OFF_MASK 0x01ff
254 275
255/* Attribute fields */ 276/* Attribute fields */
256 277
257/* This enables rx snooping for buffers and descriptors */ 278/* This enables rx snooping for buffers and descriptors */
258#ifdef CONFIG_GFAR_BDSTASH
259#define ATTR_BDSTASH 0x00000800 279#define ATTR_BDSTASH 0x00000800
260#else
261#define ATTR_BDSTASH 0x00000000
262#endif
263 280
264#ifdef CONFIG_GFAR_BUFSTASH
265#define ATTR_BUFSTASH 0x00004000 281#define ATTR_BUFSTASH 0x00004000
266#define STASH_LENGTH 64
267#else
268#define ATTR_BUFSTASH 0x00000000
269#endif
270 282
271#define ATTR_SNOOPING 0x000000c0 283#define ATTR_SNOOPING 0x000000c0
272#define ATTR_INIT_SETTINGS (ATTR_SNOOPING \ 284#define ATTR_INIT_SETTINGS ATTR_SNOOPING
273 | ATTR_BDSTASH | ATTR_BUFSTASH)
274 285
275#define ATTRELI_INIT_SETTINGS 0x0 286#define ATTRELI_INIT_SETTINGS 0x0
287#define ATTRELI_EL_MASK 0x3fff0000
288#define ATTRELI_EL(x) (x << 16)
289#define ATTRELI_EI_MASK 0x00003fff
290#define ATTRELI_EI(x) (x)
276 291
277 292
278/* TxBD status field bits */ 293/* TxBD status field bits */
@@ -328,6 +343,7 @@ extern const char gfar_driver_version[];
328#define RXFCB_CTU 0x0400 343#define RXFCB_CTU 0x0400
329#define RXFCB_EIP 0x0200 344#define RXFCB_EIP 0x0200
330#define RXFCB_ETU 0x0100 345#define RXFCB_ETU 0x0100
346#define RXFCB_CSUM_MASK 0x0f00
331#define RXFCB_PERR_MASK 0x000c 347#define RXFCB_PERR_MASK 0x000c
332#define RXFCB_PERR_BADL3 0x0008 348#define RXFCB_PERR_BADL3 0x0008
333 349
@@ -339,14 +355,7 @@ struct txbd8
339}; 355};
340 356
341struct txfcb { 357struct txfcb {
342 u8 vln:1, 358 u8 flags;
343 ip:1,
344 ip6:1,
345 tup:1,
346 udp:1,
347 cip:1,
348 ctu:1,
349 nph:1;
350 u8 reserved; 359 u8 reserved;
351 u8 l4os; /* Level 4 Header Offset */ 360 u8 l4os; /* Level 4 Header Offset */
352 u8 l3os; /* Level 3 Header Offset */ 361 u8 l3os; /* Level 3 Header Offset */
@@ -362,14 +371,7 @@ struct rxbd8
362}; 371};
363 372
364struct rxfcb { 373struct rxfcb {
365 u16 vln:1, 374 u16 flags;
366 ip:1,
367 ip6:1,
368 tup:1,
369 cip:1,
370 ctu:1,
371 eip:1,
372 etu:1;
373 u8 rq; /* Receive Queue index */ 375 u8 rq; /* Receive Queue index */
374 u8 pro; /* Layer 4 Protocol */ 376 u8 pro; /* Layer 4 Protocol */
375 u16 reserved; 377 u16 reserved;
@@ -688,12 +690,17 @@ struct gfar_private {
688 spinlock_t lock; 690 spinlock_t lock;
689 unsigned int rx_buffer_size; 691 unsigned int rx_buffer_size;
690 unsigned int rx_stash_size; 692 unsigned int rx_stash_size;
693 unsigned int rx_stash_index;
691 unsigned int tx_ring_size; 694 unsigned int tx_ring_size;
692 unsigned int rx_ring_size; 695 unsigned int rx_ring_size;
696 unsigned int fifo_threshold;
697 unsigned int fifo_starve;
698 unsigned int fifo_starve_off;
693 699
694 unsigned char vlan_enable:1, 700 unsigned char vlan_enable:1,
695 rx_csum_enable:1, 701 rx_csum_enable:1,
696 extended_hash:1; 702 extended_hash:1,
703 bd_stash_en:1;
697 unsigned short padding; 704 unsigned short padding;
698 struct vlan_group *vlgrp; 705 struct vlan_group *vlgrp;
699 /* Info structure initialized by board setup code */ 706 /* Info structure initialized by board setup code */
@@ -731,6 +738,6 @@ extern void stop_gfar(struct net_device *dev);
731extern void gfar_halt(struct net_device *dev); 738extern void gfar_halt(struct net_device *dev);
732extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev, 739extern void gfar_phy_test(struct mii_bus *bus, struct phy_device *phydev,
733 int enable, u32 regnum, u32 read); 740 int enable, u32 regnum, u32 read);
734void gfar_setup_stashing(struct net_device *dev); 741void gfar_init_sysfs(struct net_device *dev);
735 742
736#endif /* __GIANFAR_H */ 743#endif /* __GIANFAR_H */
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index cfa3cd7c91a0..765e810620fe 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -125,7 +125,7 @@ static char stat_gstrings[][ETH_GSTRING_LEN] = {
125static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf) 125static void gfar_gstrings(struct net_device *dev, u32 stringset, u8 * buf)
126{ 126{
127 struct gfar_private *priv = netdev_priv(dev); 127 struct gfar_private *priv = netdev_priv(dev);
128 128
129 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) 129 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON)
130 memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN); 130 memcpy(buf, stat_gstrings, GFAR_STATS_LEN * ETH_GSTRING_LEN);
131 else 131 else
diff --git a/drivers/net/gianfar_mii.h b/drivers/net/gianfar_mii.h
index e85eb216fb5b..d527cf2f9c1d 100644
--- a/drivers/net/gianfar_mii.h
+++ b/drivers/net/gianfar_mii.h
@@ -24,6 +24,7 @@
24#define MII_READ_COMMAND 0x00000001 24#define MII_READ_COMMAND 0x00000001
25 25
26#define GFAR_SUPPORTED (SUPPORTED_10baseT_Half \ 26#define GFAR_SUPPORTED (SUPPORTED_10baseT_Half \
27 | SUPPORTED_10baseT_Full \
27 | SUPPORTED_100baseT_Half \ 28 | SUPPORTED_100baseT_Half \
28 | SUPPORTED_100baseT_Full \ 29 | SUPPORTED_100baseT_Full \
29 | SUPPORTED_Autoneg \ 30 | SUPPORTED_Autoneg \
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c
new file mode 100644
index 000000000000..10d34cb19192
--- /dev/null
+++ b/drivers/net/gianfar_sysfs.c
@@ -0,0 +1,311 @@
1/*
2 * drivers/net/gianfar_sysfs.c
3 *
4 * Gianfar Ethernet Driver
5 * This driver is designed for the non-CPM ethernet controllers
6 * on the 85xx and 83xx family of integrated processors
7 * Based on 8260_io/fcc_enet.c
8 *
9 * Author: Andy Fleming
10 * Maintainer: Kumar Gala (kumar.gala@freescale.com)
11 *
12 * Copyright (c) 2002-2005 Freescale Semiconductor, Inc.
13 *
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version.
18 *
19 * Sysfs file creation and management
20 */
21
22#include <linux/config.h>
23#include <linux/kernel.h>
24#include <linux/sched.h>
25#include <linux/string.h>
26#include <linux/errno.h>
27#include <linux/unistd.h>
28#include <linux/slab.h>
29#include <linux/init.h>
30#include <linux/delay.h>
31#include <linux/etherdevice.h>
32#include <linux/spinlock.h>
33#include <linux/mm.h>
34#include <linux/device.h>
35
36#include <asm/uaccess.h>
37#include <linux/module.h>
38#include <linux/version.h>
39
40#include "gianfar.h"
41
42#define GFAR_ATTR(_name) \
43static ssize_t gfar_show_##_name(struct class_device *cdev, char *buf); \
44static ssize_t gfar_set_##_name(struct class_device *cdev, \
45 const char *buf, size_t count); \
46static CLASS_DEVICE_ATTR(_name, 0644, gfar_show_##_name, gfar_set_##_name)
47
48#define GFAR_CREATE_FILE(_dev, _name) \
49 class_device_create_file(&_dev->class_dev, &class_device_attr_##_name)
50
51GFAR_ATTR(bd_stash);
52GFAR_ATTR(rx_stash_size);
53GFAR_ATTR(rx_stash_index);
54GFAR_ATTR(fifo_threshold);
55GFAR_ATTR(fifo_starve);
56GFAR_ATTR(fifo_starve_off);
57
58#define to_net_dev(cd) container_of(cd, struct net_device, class_dev)
59
60static ssize_t gfar_show_bd_stash(struct class_device *cdev, char *buf)
61{
62 struct net_device *dev = to_net_dev(cdev);
63 struct gfar_private *priv = netdev_priv(dev);
64
65 return sprintf(buf, "%s\n", priv->bd_stash_en? "on" : "off");
66}
67
68static ssize_t gfar_set_bd_stash(struct class_device *cdev,
69 const char *buf, size_t count)
70{
71 struct net_device *dev = to_net_dev(cdev);
72 struct gfar_private *priv = netdev_priv(dev);
73 int new_setting = 0;
74 u32 temp;
75 unsigned long flags;
76
77 /* Find out the new setting */
78 if (!strncmp("on", buf, count-1) || !strncmp("1", buf, count-1))
79 new_setting = 1;
80 else if (!strncmp("off", buf, count-1) || !strncmp("0", buf, count-1))
81 new_setting = 0;
82 else
83 return count;
84
85 spin_lock_irqsave(&priv->lock, flags);
86
87 /* Set the new stashing value */
88 priv->bd_stash_en = new_setting;
89
90 temp = gfar_read(&priv->regs->attr);
91
92 if (new_setting)
93 temp |= ATTR_BDSTASH;
94 else
95 temp &= ~(ATTR_BDSTASH);
96
97 gfar_write(&priv->regs->attr, temp);
98
99 spin_unlock_irqrestore(&priv->lock, flags);
100
101 return count;
102}
103
104static ssize_t gfar_show_rx_stash_size(struct class_device *cdev, char *buf)
105{
106 struct net_device *dev = to_net_dev(cdev);
107 struct gfar_private *priv = netdev_priv(dev);
108
109 return sprintf(buf, "%d\n", priv->rx_stash_size);
110}
111
112static ssize_t gfar_set_rx_stash_size(struct class_device *cdev,
113 const char *buf, size_t count)
114{
115 struct net_device *dev = to_net_dev(cdev);
116 struct gfar_private *priv = netdev_priv(dev);
117 unsigned int length = simple_strtoul(buf, NULL, 0);
118 u32 temp;
119 unsigned long flags;
120
121 spin_lock_irqsave(&priv->lock, flags);
122 if (length > priv->rx_buffer_size)
123 return count;
124
125 if (length == priv->rx_stash_size)
126 return count;
127
128 priv->rx_stash_size = length;
129
130 temp = gfar_read(&priv->regs->attreli);
131 temp &= ~ATTRELI_EL_MASK;
132 temp |= ATTRELI_EL(length);
133 gfar_write(&priv->regs->attreli, temp);
134
135 /* Turn stashing on/off as appropriate */
136 temp = gfar_read(&priv->regs->attr);
137
138 if (length)
139 temp |= ATTR_BUFSTASH;
140 else
141 temp &= ~(ATTR_BUFSTASH);
142
143 gfar_write(&priv->regs->attr, temp);
144
145 spin_unlock_irqrestore(&priv->lock, flags);
146
147 return count;
148}
149
150
151/* Stashing will only be enabled when rx_stash_size != 0 */
152static ssize_t gfar_show_rx_stash_index(struct class_device *cdev, char *buf)
153{
154 struct net_device *dev = to_net_dev(cdev);
155 struct gfar_private *priv = netdev_priv(dev);
156
157 return sprintf(buf, "%d\n", priv->rx_stash_index);
158}
159
160static ssize_t gfar_set_rx_stash_index(struct class_device *cdev,
161 const char *buf, size_t count)
162{
163 struct net_device *dev = to_net_dev(cdev);
164 struct gfar_private *priv = netdev_priv(dev);
165 unsigned short index = simple_strtoul(buf, NULL, 0);
166 u32 temp;
167 unsigned long flags;
168
169 spin_lock_irqsave(&priv->lock, flags);
170 if (index > priv->rx_stash_size)
171 return count;
172
173 if (index == priv->rx_stash_index)
174 return count;
175
176 priv->rx_stash_index = index;
177
178 temp = gfar_read(&priv->regs->attreli);
179 temp &= ~ATTRELI_EI_MASK;
180 temp |= ATTRELI_EI(index);
181 gfar_write(&priv->regs->attreli, flags);
182
183 spin_unlock_irqrestore(&priv->lock, flags);
184
185 return count;
186}
187
188static ssize_t gfar_show_fifo_threshold(struct class_device *cdev, char *buf)
189{
190 struct net_device *dev = to_net_dev(cdev);
191 struct gfar_private *priv = netdev_priv(dev);
192
193 return sprintf(buf, "%d\n", priv->fifo_threshold);
194}
195
196static ssize_t gfar_set_fifo_threshold(struct class_device *cdev,
197 const char *buf, size_t count)
198{
199 struct net_device *dev = to_net_dev(cdev);
200 struct gfar_private *priv = netdev_priv(dev);
201 unsigned int length = simple_strtoul(buf, NULL, 0);
202 u32 temp;
203 unsigned long flags;
204
205 if (length > GFAR_MAX_FIFO_THRESHOLD)
206 return count;
207
208 spin_lock_irqsave(&priv->lock, flags);
209
210 priv->fifo_threshold = length;
211
212 temp = gfar_read(&priv->regs->fifo_tx_thr);
213 temp &= ~FIFO_TX_THR_MASK;
214 temp |= length;
215 gfar_write(&priv->regs->fifo_tx_thr, temp);
216
217 spin_unlock_irqrestore(&priv->lock, flags);
218
219 return count;
220}
221
222static ssize_t gfar_show_fifo_starve(struct class_device *cdev, char *buf)
223{
224 struct net_device *dev = to_net_dev(cdev);
225 struct gfar_private *priv = netdev_priv(dev);
226
227 return sprintf(buf, "%d\n", priv->fifo_starve);
228}
229
230
231static ssize_t gfar_set_fifo_starve(struct class_device *cdev,
232 const char *buf, size_t count)
233{
234 struct net_device *dev = to_net_dev(cdev);
235 struct gfar_private *priv = netdev_priv(dev);
236 unsigned int num = simple_strtoul(buf, NULL, 0);
237 u32 temp;
238 unsigned long flags;
239
240 if (num > GFAR_MAX_FIFO_STARVE)
241 return count;
242
243 spin_lock_irqsave(&priv->lock, flags);
244
245 priv->fifo_starve = num;
246
247 temp = gfar_read(&priv->regs->fifo_tx_starve);
248 temp &= ~FIFO_TX_STARVE_MASK;
249 temp |= num;
250 gfar_write(&priv->regs->fifo_tx_starve, temp);
251
252 spin_unlock_irqrestore(&priv->lock, flags);
253
254 return count;
255}
256
257static ssize_t gfar_show_fifo_starve_off(struct class_device *cdev, char *buf)
258{
259 struct net_device *dev = to_net_dev(cdev);
260 struct gfar_private *priv = netdev_priv(dev);
261
262 return sprintf(buf, "%d\n", priv->fifo_starve_off);
263}
264
265static ssize_t gfar_set_fifo_starve_off(struct class_device *cdev,
266 const char *buf, size_t count)
267{
268 struct net_device *dev = to_net_dev(cdev);
269 struct gfar_private *priv = netdev_priv(dev);
270 unsigned int num = simple_strtoul(buf, NULL, 0);
271 u32 temp;
272 unsigned long flags;
273
274 if (num > GFAR_MAX_FIFO_STARVE_OFF)
275 return count;
276
277 spin_lock_irqsave(&priv->lock, flags);
278
279 priv->fifo_starve_off = num;
280
281 temp = gfar_read(&priv->regs->fifo_tx_starve_shutoff);
282 temp &= ~FIFO_TX_STARVE_OFF_MASK;
283 temp |= num;
284 gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp);
285
286 spin_unlock_irqrestore(&priv->lock, flags);
287
288 return count;
289}
290
291void gfar_init_sysfs(struct net_device *dev)
292{
293 struct gfar_private *priv = netdev_priv(dev);
294
295 /* Initialize the default values */
296 priv->rx_stash_size = DEFAULT_STASH_LENGTH;
297 priv->rx_stash_index = DEFAULT_STASH_INDEX;
298 priv->fifo_threshold = DEFAULT_FIFO_TX_THR;
299 priv->fifo_starve = DEFAULT_FIFO_TX_STARVE;
300 priv->fifo_starve_off = DEFAULT_FIFO_TX_STARVE_OFF;
301 priv->bd_stash_en = DEFAULT_BD_STASH;
302
303 /* Create our sysfs files */
304 GFAR_CREATE_FILE(dev, bd_stash);
305 GFAR_CREATE_FILE(dev, rx_stash_size);
306 GFAR_CREATE_FILE(dev, rx_stash_index);
307 GFAR_CREATE_FILE(dev, fifo_threshold);
308 GFAR_CREATE_FILE(dev, fifo_starve);
309 GFAR_CREATE_FILE(dev, fifo_starve_off);
310
311}
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c
index c22c0517883c..fa176ffb4ad5 100644
--- a/drivers/net/irda/irda-usb.c
+++ b/drivers/net/irda/irda-usb.c
@@ -1539,7 +1539,6 @@ static void irda_usb_disconnect(struct usb_interface *intf)
1539 * USB device callbacks 1539 * USB device callbacks
1540 */ 1540 */
1541static struct usb_driver irda_driver = { 1541static struct usb_driver irda_driver = {
1542 .owner = THIS_MODULE,
1543 .name = "irda-usb", 1542 .name = "irda-usb",
1544 .probe = irda_usb_probe, 1543 .probe = irda_usb_probe,
1545 .disconnect = irda_usb_disconnect, 1544 .disconnect = irda_usb_disconnect,
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c
index 3961a754e920..31867e4b891b 100644
--- a/drivers/net/irda/stir4200.c
+++ b/drivers/net/irda/stir4200.c
@@ -1152,7 +1152,6 @@ static int stir_resume(struct usb_interface *intf)
1152 * USB device callbacks 1152 * USB device callbacks
1153 */ 1153 */
1154static struct usb_driver irda_driver = { 1154static struct usb_driver irda_driver = {
1155 .owner = THIS_MODULE,
1156 .name = "stir4200", 1155 .name = "stir4200",
1157 .probe = stir_probe, 1156 .probe = stir_probe,
1158 .disconnect = stir_disconnect, 1157 .disconnect = stir_disconnect,
diff --git a/drivers/net/ixp2000/Kconfig b/drivers/net/ixp2000/Kconfig
new file mode 100644
index 000000000000..2fec2415651f
--- /dev/null
+++ b/drivers/net/ixp2000/Kconfig
@@ -0,0 +1,6 @@
1config ENP2611_MSF_NET
2 tristate "Radisys ENP2611 MSF network interface support"
3 depends on ARCH_ENP2611
4 help
5 This is a driver for the MSF network interface unit in
6 the IXP2400 on the Radisys ENP2611 platform.
diff --git a/drivers/net/ixp2000/Makefile b/drivers/net/ixp2000/Makefile
new file mode 100644
index 000000000000..fd38351ceaa7
--- /dev/null
+++ b/drivers/net/ixp2000/Makefile
@@ -0,0 +1,3 @@
1obj-$(CONFIG_ENP2611_MSF_NET) += enp2611_mod.o
2
3enp2611_mod-objs := caleb.o enp2611.o ixp2400-msf.o ixpdev.o pm3386.o
diff --git a/drivers/net/ixp2000/caleb.c b/drivers/net/ixp2000/caleb.c
new file mode 100644
index 000000000000..3595e107df22
--- /dev/null
+++ b/drivers/net/ixp2000/caleb.c
@@ -0,0 +1,137 @@
1/*
2 * Helper functions for the SPI-3 bridge FPGA on the Radisys ENP2611
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/config.h>
13#include <linux/module.h>
14#include <linux/delay.h>
15#include <asm/io.h>
16#include "caleb.h"
17
18#define CALEB_IDLO 0x00
19#define CALEB_IDHI 0x01
20#define CALEB_RID 0x02
21#define CALEB_RESET 0x03
22#define CALEB_INTREN0 0x04
23#define CALEB_INTREN1 0x05
24#define CALEB_INTRSTAT0 0x06
25#define CALEB_INTRSTAT1 0x07
26#define CALEB_PORTEN 0x08
27#define CALEB_BURST 0x09
28#define CALEB_PORTPAUS 0x0A
29#define CALEB_PORTPAUSD 0x0B
30#define CALEB_PHY0RX 0x10
31#define CALEB_PHY1RX 0x11
32#define CALEB_PHY0TX 0x12
33#define CALEB_PHY1TX 0x13
34#define CALEB_IXPRX_HI_CNTR 0x15
35#define CALEB_PHY0RX_HI_CNTR 0x16
36#define CALEB_PHY1RX_HI_CNTR 0x17
37#define CALEB_IXPRX_CNTR 0x18
38#define CALEB_PHY0RX_CNTR 0x19
39#define CALEB_PHY1RX_CNTR 0x1A
40#define CALEB_IXPTX_CNTR 0x1B
41#define CALEB_PHY0TX_CNTR 0x1C
42#define CALEB_PHY1TX_CNTR 0x1D
43#define CALEB_DEBUG0 0x1E
44#define CALEB_DEBUG1 0x1F
45
46
47static u8 caleb_reg_read(int reg)
48{
49 u8 value;
50
51 value = *((volatile u8 *)(ENP2611_CALEB_VIRT_BASE + reg));
52
53// printk(KERN_INFO "caleb_reg_read(%d) = %.2x\n", reg, value);
54
55 return value;
56}
57
58static void caleb_reg_write(int reg, u8 value)
59{
60 u8 dummy;
61
62// printk(KERN_INFO "caleb_reg_write(%d, %.2x)\n", reg, value);
63
64 *((volatile u8 *)(ENP2611_CALEB_VIRT_BASE + reg)) = value;
65
66 dummy = *((volatile u8 *)ENP2611_CALEB_VIRT_BASE);
67 __asm__ __volatile__("mov %0, %0" : "+r" (dummy));
68}
69
70
71void caleb_reset(void)
72{
73 /*
74 * Perform a chip reset.
75 */
76 caleb_reg_write(CALEB_RESET, 0x02);
77 udelay(1);
78
79 /*
80 * Enable all interrupt sources. This is needed to get
81 * meaningful results out of the status bits (register 6
82 * and 7.)
83 */
84 caleb_reg_write(CALEB_INTREN0, 0xff);
85 caleb_reg_write(CALEB_INTREN1, 0x07);
86
87 /*
88 * Set RX and TX FIFO thresholds to 1.5kb.
89 */
90 caleb_reg_write(CALEB_PHY0RX, 0x11);
91 caleb_reg_write(CALEB_PHY1RX, 0x11);
92 caleb_reg_write(CALEB_PHY0TX, 0x11);
93 caleb_reg_write(CALEB_PHY1TX, 0x11);
94
95 /*
96 * Program SPI-3 burst size.
97 */
98 caleb_reg_write(CALEB_BURST, 0); // 64-byte RBUF mpackets
99// caleb_reg_write(CALEB_BURST, 1); // 128-byte RBUF mpackets
100// caleb_reg_write(CALEB_BURST, 2); // 256-byte RBUF mpackets
101}
102
103void caleb_enable_rx(int port)
104{
105 u8 temp;
106
107 temp = caleb_reg_read(CALEB_PORTEN);
108 temp |= 1 << port;
109 caleb_reg_write(CALEB_PORTEN, temp);
110}
111
112void caleb_disable_rx(int port)
113{
114 u8 temp;
115
116 temp = caleb_reg_read(CALEB_PORTEN);
117 temp &= ~(1 << port);
118 caleb_reg_write(CALEB_PORTEN, temp);
119}
120
121void caleb_enable_tx(int port)
122{
123 u8 temp;
124
125 temp = caleb_reg_read(CALEB_PORTEN);
126 temp |= 1 << (port + 4);
127 caleb_reg_write(CALEB_PORTEN, temp);
128}
129
130void caleb_disable_tx(int port)
131{
132 u8 temp;
133
134 temp = caleb_reg_read(CALEB_PORTEN);
135 temp &= ~(1 << (port + 4));
136 caleb_reg_write(CALEB_PORTEN, temp);
137}
diff --git a/drivers/net/ixp2000/caleb.h b/drivers/net/ixp2000/caleb.h
new file mode 100644
index 000000000000..e93a1ef5b8a3
--- /dev/null
+++ b/drivers/net/ixp2000/caleb.h
@@ -0,0 +1,22 @@
1/*
2 * Helper functions for the SPI-3 bridge FPGA on the Radisys ENP2611
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __CALEB_H
13#define __CALEB_H
14
15void caleb_reset(void);
16void caleb_enable_rx(int port);
17void caleb_disable_rx(int port);
18void caleb_enable_tx(int port);
19void caleb_disable_tx(int port);
20
21
22#endif
diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c
new file mode 100644
index 000000000000..d82651a97bae
--- /dev/null
+++ b/drivers/net/ixp2000/enp2611.c
@@ -0,0 +1,245 @@
1/*
2 * IXP2400 MSF network device driver for the Radisys ENP2611
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/config.h>
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/netdevice.h>
16#include <linux/etherdevice.h>
17#include <linux/init.h>
18#include <linux/moduleparam.h>
19#include <asm/arch/uengine.h>
20#include <asm/mach-types.h>
21#include <asm/io.h>
22#include "ixpdev.h"
23#include "caleb.h"
24#include "ixp2400-msf.h"
25#include "pm3386.h"
26
27/***********************************************************************
28 * The Radisys ENP2611 is a PCI form factor board with three SFP GBIC
29 * slots, connected via two PMC/Sierra 3386s and an SPI-3 bridge FPGA
30 * to the IXP2400.
31 *
32 * +-------------+
33 * SFP GBIC #0 ---+ | +---------+
34 * | PM3386 #0 +-------+ |
35 * SFP GBIC #1 ---+ | | "Caleb" | +---------+
36 * +-------------+ | | | |
37 * | SPI-3 +---------+ IXP2400 |
38 * +-------------+ | bridge | | |
39 * SFP GBIC #2 ---+ | | FPGA | +---------+
40 * | PM3386 #1 +-------+ |
41 * | | +---------+
42 * +-------------+
43 * ^ ^ ^
44 * | 1.25Gbaud | 104MHz | 104MHz
45 * | SERDES ea. | SPI-3 ea. | SPI-3
46 *
47 ***********************************************************************/
48static struct ixp2400_msf_parameters enp2611_msf_parameters =
49{
50 .rx_mode = IXP2400_RX_MODE_UTOPIA_POS |
51 IXP2400_RX_MODE_1x32 |
52 IXP2400_RX_MODE_MPHY |
53 IXP2400_RX_MODE_MPHY_32 |
54 IXP2400_RX_MODE_MPHY_POLLED_STATUS |
55 IXP2400_RX_MODE_MPHY_LEVEL3 |
56 IXP2400_RX_MODE_RBUF_SIZE_64,
57
58 .rxclk01_multiplier = IXP2400_PLL_MULTIPLIER_16,
59
60 .rx_poll_ports = 3,
61
62 .rx_channel_mode = {
63 IXP2400_PORT_RX_MODE_MASTER |
64 IXP2400_PORT_RX_MODE_POS_PHY |
65 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
66 IXP2400_PORT_RX_MODE_ODD_PARITY |
67 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE,
68
69 IXP2400_PORT_RX_MODE_MASTER |
70 IXP2400_PORT_RX_MODE_POS_PHY |
71 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
72 IXP2400_PORT_RX_MODE_ODD_PARITY |
73 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE,
74
75 IXP2400_PORT_RX_MODE_MASTER |
76 IXP2400_PORT_RX_MODE_POS_PHY |
77 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
78 IXP2400_PORT_RX_MODE_ODD_PARITY |
79 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE,
80
81 IXP2400_PORT_RX_MODE_MASTER |
82 IXP2400_PORT_RX_MODE_POS_PHY |
83 IXP2400_PORT_RX_MODE_POS_PHY_L3 |
84 IXP2400_PORT_RX_MODE_ODD_PARITY |
85 IXP2400_PORT_RX_MODE_2_CYCLE_DECODE
86 },
87
88 .tx_mode = IXP2400_TX_MODE_UTOPIA_POS |
89 IXP2400_TX_MODE_1x32 |
90 IXP2400_TX_MODE_MPHY |
91 IXP2400_TX_MODE_MPHY_32 |
92 IXP2400_TX_MODE_MPHY_POLLED_STATUS |
93 IXP2400_TX_MODE_MPHY_LEVEL3 |
94 IXP2400_TX_MODE_TBUF_SIZE_64,
95
96 .txclk01_multiplier = IXP2400_PLL_MULTIPLIER_16,
97
98 .tx_poll_ports = 3,
99
100 .tx_channel_mode = {
101 IXP2400_PORT_TX_MODE_MASTER |
102 IXP2400_PORT_TX_MODE_POS_PHY |
103 IXP2400_PORT_TX_MODE_ODD_PARITY |
104 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE,
105
106 IXP2400_PORT_TX_MODE_MASTER |
107 IXP2400_PORT_TX_MODE_POS_PHY |
108 IXP2400_PORT_TX_MODE_ODD_PARITY |
109 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE,
110
111 IXP2400_PORT_TX_MODE_MASTER |
112 IXP2400_PORT_TX_MODE_POS_PHY |
113 IXP2400_PORT_TX_MODE_ODD_PARITY |
114 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE,
115
116 IXP2400_PORT_TX_MODE_MASTER |
117 IXP2400_PORT_TX_MODE_POS_PHY |
118 IXP2400_PORT_TX_MODE_ODD_PARITY |
119 IXP2400_PORT_TX_MODE_2_CYCLE_DECODE
120 }
121};
122
123struct enp2611_ixpdev_priv
124{
125 struct ixpdev_priv ixpdev_priv;
126 struct net_device_stats stats;
127};
128
129static struct net_device *nds[3];
130static struct timer_list link_check_timer;
131
132static struct net_device_stats *enp2611_get_stats(struct net_device *dev)
133{
134 struct enp2611_ixpdev_priv *ip = netdev_priv(dev);
135
136 pm3386_get_stats(ip->ixpdev_priv.channel, &(ip->stats));
137
138 return &(ip->stats);
139}
140
141/* @@@ Poll the SFP moddef0 line too. */
142/* @@@ Try to use the pm3386 DOOL interrupt as well. */
143static void enp2611_check_link_status(unsigned long __dummy)
144{
145 int i;
146
147 for (i = 0; i < 3; i++) {
148 struct net_device *dev;
149 int status;
150
151 dev = nds[i];
152
153 status = pm3386_is_link_up(i);
154 if (status && !netif_carrier_ok(dev)) {
155 /* @@@ Should report autonegotiation status. */
156 printk(KERN_INFO "%s: NIC Link is Up\n", dev->name);
157
158 pm3386_enable_tx(i);
159 caleb_enable_tx(i);
160 netif_carrier_on(dev);
161 } else if (!status && netif_carrier_ok(dev)) {
162 printk(KERN_INFO "%s: NIC Link is Down\n", dev->name);
163
164 netif_carrier_off(dev);
165 caleb_disable_tx(i);
166 pm3386_disable_tx(i);
167 }
168 }
169
170 link_check_timer.expires = jiffies + HZ / 10;
171 add_timer(&link_check_timer);
172}
173
174static void enp2611_set_port_admin_status(int port, int up)
175{
176 if (up) {
177 caleb_enable_rx(port);
178
179 pm3386_set_carrier(port, 1);
180 pm3386_enable_rx(port);
181 } else {
182 caleb_disable_tx(port);
183 pm3386_disable_tx(port);
184 /* @@@ Flush out pending packets. */
185 pm3386_set_carrier(port, 0);
186
187 pm3386_disable_rx(port);
188 caleb_disable_rx(port);
189 }
190}
191
192static int __init enp2611_init_module(void)
193{
194 int i;
195
196 if (!machine_is_enp2611())
197 return -ENODEV;
198
199 caleb_reset();
200 pm3386_reset();
201
202 for (i = 0; i < 3; i++) {
203 nds[i] = ixpdev_alloc(i, sizeof(struct enp2611_ixpdev_priv));
204 if (nds[i] == NULL) {
205 while (--i >= 0)
206 free_netdev(nds[i]);
207 return -ENOMEM;
208 }
209
210 SET_MODULE_OWNER(nds[i]);
211 nds[i]->get_stats = enp2611_get_stats;
212 pm3386_init_port(i);
213 pm3386_get_mac(i, nds[i]->dev_addr);
214 }
215
216 ixp2400_msf_init(&enp2611_msf_parameters);
217
218 if (ixpdev_init(3, nds, enp2611_set_port_admin_status)) {
219 for (i = 0; i < 3; i++)
220 free_netdev(nds[i]);
221 return -EINVAL;
222 }
223
224 init_timer(&link_check_timer);
225 link_check_timer.function = enp2611_check_link_status;
226 link_check_timer.expires = jiffies;
227 add_timer(&link_check_timer);
228
229 return 0;
230}
231
232static void __exit enp2611_cleanup_module(void)
233{
234 int i;
235
236 del_timer_sync(&link_check_timer);
237
238 ixpdev_deinit();
239 for (i = 0; i < 3; i++)
240 free_netdev(nds[i]);
241}
242
243module_init(enp2611_init_module);
244module_exit(enp2611_cleanup_module);
245MODULE_LICENSE("GPL");
diff --git a/drivers/net/ixp2000/ixp2400-msf.c b/drivers/net/ixp2000/ixp2400-msf.c
new file mode 100644
index 000000000000..48a3a891d3a4
--- /dev/null
+++ b/drivers/net/ixp2000/ixp2400-msf.c
@@ -0,0 +1,213 @@
1/*
2 * Generic library functions for the MSF (Media and Switch Fabric) unit
3 * found on the Intel IXP2400 network processor.
4 *
5 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
6 * Dedicated to Marija Kulikova.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of the
11 * License, or (at your option) any later version.
12 */
13
14#include <linux/config.h>
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <asm/hardware.h>
18#include <asm/arch/ixp2000-regs.h>
19#include <asm/delay.h>
20#include <asm/io.h>
21#include "ixp2400-msf.h"
22
23/*
24 * This is the Intel recommended PLL init procedure as described on
25 * page 340 of the IXP2400/IXP2800 Programmer's Reference Manual.
26 */
27static void ixp2400_pll_init(struct ixp2400_msf_parameters *mp)
28{
29 int rx_dual_clock;
30 int tx_dual_clock;
31 u32 value;
32
33 /*
34 * If the RX mode is not 1x32, we have to enable both RX PLLs
35 * (#0 and #1.) The same thing for the TX direction.
36 */
37 rx_dual_clock = !!(mp->rx_mode & IXP2400_RX_MODE_WIDTH_MASK);
38 tx_dual_clock = !!(mp->tx_mode & IXP2400_TX_MODE_WIDTH_MASK);
39
40 /*
41 * Read initial value.
42 */
43 value = ixp2000_reg_read(IXP2000_MSF_CLK_CNTRL);
44
45 /*
46 * Put PLLs in powerdown and bypass mode.
47 */
48 value |= 0x0000f0f0;
49 ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value);
50
51 /*
52 * Set single or dual clock mode bits.
53 */
54 value &= ~0x03000000;
55 value |= (rx_dual_clock << 24) | (tx_dual_clock << 25);
56
57 /*
58 * Set multipliers.
59 */
60 value &= ~0x00ff0000;
61 value |= mp->rxclk01_multiplier << 16;
62 value |= mp->rxclk23_multiplier << 18;
63 value |= mp->txclk01_multiplier << 20;
64 value |= mp->txclk23_multiplier << 22;
65
66 /*
67 * And write value.
68 */
69 ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value);
70
71 /*
72 * Disable PLL bypass mode.
73 */
74 value &= ~(0x00005000 | rx_dual_clock << 13 | tx_dual_clock << 15);
75 ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value);
76
77 /*
78 * Turn on PLLs.
79 */
80 value &= ~(0x00000050 | rx_dual_clock << 5 | tx_dual_clock << 7);
81 ixp2000_reg_write(IXP2000_MSF_CLK_CNTRL, value);
82
83 /*
84 * Wait for PLLs to lock. There are lock status bits, but IXP2400
85 * erratum #65 says that these lock bits should not be relied upon
86 * as they might not accurately reflect the true state of the PLLs.
87 */
88 udelay(100);
89}
90
91/*
92 * Needed according to p480 of Programmer's Reference Manual.
93 */
94static void ixp2400_msf_free_rbuf_entries(struct ixp2400_msf_parameters *mp)
95{
96 int size_bits;
97 int i;
98
99 /*
100 * Work around IXP2400 erratum #69 (silent RBUF-to-DRAM transfer
101 * corruption) in the Intel-recommended way: do not add the RBUF
102 * elements susceptible to corruption to the freelist.
103 */
104 size_bits = mp->rx_mode & IXP2400_RX_MODE_RBUF_SIZE_MASK;
105 if (size_bits == IXP2400_RX_MODE_RBUF_SIZE_64) {
106 for (i = 1; i < 128; i++) {
107 if (i == 9 || i == 18 || i == 27)
108 continue;
109 ixp2000_reg_write(IXP2000_MSF_RBUF_ELEMENT_DONE, i);
110 }
111 } else if (size_bits == IXP2400_RX_MODE_RBUF_SIZE_128) {
112 for (i = 1; i < 64; i++) {
113 if (i == 4 || i == 9 || i == 13)
114 continue;
115 ixp2000_reg_write(IXP2000_MSF_RBUF_ELEMENT_DONE, i);
116 }
117 } else if (size_bits == IXP2400_RX_MODE_RBUF_SIZE_256) {
118 for (i = 1; i < 32; i++) {
119 if (i == 2 || i == 4 || i == 6)
120 continue;
121 ixp2000_reg_write(IXP2000_MSF_RBUF_ELEMENT_DONE, i);
122 }
123 }
124}
125
126static u32 ixp2400_msf_valid_channels(u32 reg)
127{
128 u32 channels;
129
130 channels = 0;
131 switch (reg & IXP2400_RX_MODE_WIDTH_MASK) {
132 case IXP2400_RX_MODE_1x32:
133 channels = 0x1;
134 if (reg & IXP2400_RX_MODE_MPHY &&
135 !(reg & IXP2400_RX_MODE_MPHY_32))
136 channels = 0xf;
137 break;
138
139 case IXP2400_RX_MODE_2x16:
140 channels = 0x5;
141 break;
142
143 case IXP2400_RX_MODE_4x8:
144 channels = 0xf;
145 break;
146
147 case IXP2400_RX_MODE_1x16_2x8:
148 channels = 0xd;
149 break;
150 }
151
152 return channels;
153}
154
155static void ixp2400_msf_enable_rx(struct ixp2400_msf_parameters *mp)
156{
157 u32 value;
158
159 value = ixp2000_reg_read(IXP2000_MSF_RX_CONTROL) & 0x0fffffff;
160 value |= ixp2400_msf_valid_channels(mp->rx_mode) << 28;
161 ixp2000_reg_write(IXP2000_MSF_RX_CONTROL, value);
162}
163
164static void ixp2400_msf_enable_tx(struct ixp2400_msf_parameters *mp)
165{
166 u32 value;
167
168 value = ixp2000_reg_read(IXP2000_MSF_TX_CONTROL) & 0x0fffffff;
169 value |= ixp2400_msf_valid_channels(mp->tx_mode) << 28;
170 ixp2000_reg_write(IXP2000_MSF_TX_CONTROL, value);
171}
172
173
174void ixp2400_msf_init(struct ixp2400_msf_parameters *mp)
175{
176 u32 value;
177 int i;
178
179 /*
180 * Init the RX/TX PLLs based on the passed parameter block.
181 */
182 ixp2400_pll_init(mp);
183
184 /*
185 * Reset MSF. Bit 7 in IXP_RESET_0 resets the MSF.
186 */
187 value = ixp2000_reg_read(IXP2000_RESET0);
188 ixp2000_reg_write(IXP2000_RESET0, value | 0x80);
189 ixp2000_reg_write(IXP2000_RESET0, value & ~0x80);
190
191 /*
192 * Initialise the RX section.
193 */
194 ixp2000_reg_write(IXP2000_MSF_RX_MPHY_POLL_LIMIT, mp->rx_poll_ports - 1);
195 ixp2000_reg_write(IXP2000_MSF_RX_CONTROL, mp->rx_mode);
196 for (i = 0; i < 4; i++) {
197 ixp2000_reg_write(IXP2000_MSF_RX_UP_CONTROL_0 + i,
198 mp->rx_channel_mode[i]);
199 }
200 ixp2400_msf_free_rbuf_entries(mp);
201 ixp2400_msf_enable_rx(mp);
202
203 /*
204 * Initialise the TX section.
205 */
206 ixp2000_reg_write(IXP2000_MSF_TX_MPHY_POLL_LIMIT, mp->tx_poll_ports - 1);
207 ixp2000_reg_write(IXP2000_MSF_TX_CONTROL, mp->tx_mode);
208 for (i = 0; i < 4; i++) {
209 ixp2000_reg_write(IXP2000_MSF_TX_UP_CONTROL_0 + i,
210 mp->tx_channel_mode[i]);
211 }
212 ixp2400_msf_enable_tx(mp);
213}
diff --git a/drivers/net/ixp2000/ixp2400-msf.h b/drivers/net/ixp2000/ixp2400-msf.h
new file mode 100644
index 000000000000..3ac1af2771da
--- /dev/null
+++ b/drivers/net/ixp2000/ixp2400-msf.h
@@ -0,0 +1,115 @@
1/*
2 * Generic library functions for the MSF (Media and Switch Fabric) unit
3 * found on the Intel IXP2400 network processor.
4 *
5 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
6 * Dedicated to Marija Kulikova.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of the
11 * License, or (at your option) any later version.
12 */
13
14#ifndef __IXP2400_MSF_H
15#define __IXP2400_MSF_H
16
17struct ixp2400_msf_parameters
18{
19 u32 rx_mode;
20 unsigned rxclk01_multiplier:2;
21 unsigned rxclk23_multiplier:2;
22 unsigned rx_poll_ports:6;
23 u32 rx_channel_mode[4];
24
25 u32 tx_mode;
26 unsigned txclk01_multiplier:2;
27 unsigned txclk23_multiplier:2;
28 unsigned tx_poll_ports:6;
29 u32 tx_channel_mode[4];
30};
31
32void ixp2400_msf_init(struct ixp2400_msf_parameters *mp);
33
34#define IXP2400_PLL_MULTIPLIER_48 0x00
35#define IXP2400_PLL_MULTIPLIER_24 0x01
36#define IXP2400_PLL_MULTIPLIER_16 0x02
37#define IXP2400_PLL_MULTIPLIER_12 0x03
38
39#define IXP2400_RX_MODE_CSIX 0x00400000
40#define IXP2400_RX_MODE_UTOPIA_POS 0x00000000
41#define IXP2400_RX_MODE_WIDTH_MASK 0x00300000
42#define IXP2400_RX_MODE_1x16_2x8 0x00300000
43#define IXP2400_RX_MODE_4x8 0x00200000
44#define IXP2400_RX_MODE_2x16 0x00100000
45#define IXP2400_RX_MODE_1x32 0x00000000
46#define IXP2400_RX_MODE_MPHY 0x00080000
47#define IXP2400_RX_MODE_SPHY 0x00000000
48#define IXP2400_RX_MODE_MPHY_32 0x00040000
49#define IXP2400_RX_MODE_MPHY_4 0x00000000
50#define IXP2400_RX_MODE_MPHY_POLLED_STATUS 0x00020000
51#define IXP2400_RX_MODE_MPHY_DIRECT_STATUS 0x00000000
52#define IXP2400_RX_MODE_CBUS_FULL_DUPLEX 0x00010000
53#define IXP2400_RX_MODE_CBUS_SIMPLEX 0x00000000
54#define IXP2400_RX_MODE_MPHY_LEVEL2 0x00004000
55#define IXP2400_RX_MODE_MPHY_LEVEL3 0x00000000
56#define IXP2400_RX_MODE_CBUS_8BIT 0x00002000
57#define IXP2400_RX_MODE_CBUS_4BIT 0x00000000
58#define IXP2400_RX_MODE_CSIX_SINGLE_FREELIST 0x00000200
59#define IXP2400_RX_MODE_CSIX_SPLIT_FREELISTS 0x00000000
60#define IXP2400_RX_MODE_RBUF_SIZE_MASK 0x0000000c
61#define IXP2400_RX_MODE_RBUF_SIZE_256 0x00000008
62#define IXP2400_RX_MODE_RBUF_SIZE_128 0x00000004
63#define IXP2400_RX_MODE_RBUF_SIZE_64 0x00000000
64
65#define IXP2400_PORT_RX_MODE_SLAVE 0x00000040
66#define IXP2400_PORT_RX_MODE_MASTER 0x00000000
67#define IXP2400_PORT_RX_MODE_POS_PHY_L3 0x00000020
68#define IXP2400_PORT_RX_MODE_POS_PHY_L2 0x00000000
69#define IXP2400_PORT_RX_MODE_POS_PHY 0x00000010
70#define IXP2400_PORT_RX_MODE_UTOPIA 0x00000000
71#define IXP2400_PORT_RX_MODE_EVEN_PARITY 0x0000000c
72#define IXP2400_PORT_RX_MODE_ODD_PARITY 0x00000008
73#define IXP2400_PORT_RX_MODE_NO_PARITY 0x00000000
74#define IXP2400_PORT_RX_MODE_UTOPIA_BIG_CELLS 0x00000002
75#define IXP2400_PORT_RX_MODE_UTOPIA_NORMAL_CELLS 0x00000000
76#define IXP2400_PORT_RX_MODE_2_CYCLE_DECODE 0x00000001
77#define IXP2400_PORT_RX_MODE_1_CYCLE_DECODE 0x00000000
78
79#define IXP2400_TX_MODE_CSIX 0x00400000
80#define IXP2400_TX_MODE_UTOPIA_POS 0x00000000
81#define IXP2400_TX_MODE_WIDTH_MASK 0x00300000
82#define IXP2400_TX_MODE_1x16_2x8 0x00300000
83#define IXP2400_TX_MODE_4x8 0x00200000
84#define IXP2400_TX_MODE_2x16 0x00100000
85#define IXP2400_TX_MODE_1x32 0x00000000
86#define IXP2400_TX_MODE_MPHY 0x00080000
87#define IXP2400_TX_MODE_SPHY 0x00000000
88#define IXP2400_TX_MODE_MPHY_32 0x00040000
89#define IXP2400_TX_MODE_MPHY_4 0x00000000
90#define IXP2400_TX_MODE_MPHY_POLLED_STATUS 0x00020000
91#define IXP2400_TX_MODE_MPHY_DIRECT_STATUS 0x00000000
92#define IXP2400_TX_MODE_CBUS_FULL_DUPLEX 0x00010000
93#define IXP2400_TX_MODE_CBUS_SIMPLEX 0x00000000
94#define IXP2400_TX_MODE_MPHY_LEVEL2 0x00004000
95#define IXP2400_TX_MODE_MPHY_LEVEL3 0x00000000
96#define IXP2400_TX_MODE_CBUS_8BIT 0x00002000
97#define IXP2400_TX_MODE_CBUS_4BIT 0x00000000
98#define IXP2400_TX_MODE_TBUF_SIZE_MASK 0x0000000c
99#define IXP2400_TX_MODE_TBUF_SIZE_256 0x00000008
100#define IXP2400_TX_MODE_TBUF_SIZE_128 0x00000004
101#define IXP2400_TX_MODE_TBUF_SIZE_64 0x00000000
102
103#define IXP2400_PORT_TX_MODE_SLAVE 0x00000040
104#define IXP2400_PORT_TX_MODE_MASTER 0x00000000
105#define IXP2400_PORT_TX_MODE_POS_PHY 0x00000010
106#define IXP2400_PORT_TX_MODE_UTOPIA 0x00000000
107#define IXP2400_PORT_TX_MODE_EVEN_PARITY 0x0000000c
108#define IXP2400_PORT_TX_MODE_ODD_PARITY 0x00000008
109#define IXP2400_PORT_TX_MODE_NO_PARITY 0x00000000
110#define IXP2400_PORT_TX_MODE_UTOPIA_BIG_CELLS 0x00000002
111#define IXP2400_PORT_TX_MODE_2_CYCLE_DECODE 0x00000001
112#define IXP2400_PORT_TX_MODE_1_CYCLE_DECODE 0x00000000
113
114
115#endif
diff --git a/drivers/net/ixp2000/ixp2400_rx.uc b/drivers/net/ixp2000/ixp2400_rx.uc
new file mode 100644
index 000000000000..42a73e357afa
--- /dev/null
+++ b/drivers/net/ixp2000/ixp2400_rx.uc
@@ -0,0 +1,408 @@
1/*
2 * RX ucode for the Intel IXP2400 in POS-PHY mode.
3 * Copyright (C) 2004, 2005 Lennert Buytenhek
4 * Dedicated to Marija Kulikova.
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 * Assumptions made in this code:
12 * - The IXP2400 MSF is configured for POS-PHY mode, in a mode where
13 * only one full element list is used. This includes, for example,
14 * 1x32 SPHY and 1x32 MPHY32, but not 4x8 SPHY or 1x32 MPHY4. (This
15 * is not an exhaustive list.)
16 * - The RBUF uses 64-byte mpackets.
17 * - RX descriptors reside in SRAM, and have the following format:
18 * struct rx_desc
19 * {
20 * // to uengine
21 * u32 buf_phys_addr;
22 * u32 buf_length;
23 *
24 * // from uengine
25 * u32 channel;
26 * u32 pkt_length;
27 * };
28 * - Packet data resides in DRAM.
29 * - Packet buffer addresses are 8-byte aligned.
30 * - Scratch ring 0 is rx_pending.
31 * - Scratch ring 1 is rx_done, and has status condition 'full'.
32 * - The host triggers rx_done flush and rx_pending refill on seeing INTA.
33 * - This code is run on all eight threads of the microengine it runs on.
34 *
35 * Local memory is used for per-channel RX state.
36 */
37
38#define RX_THREAD_FREELIST_0 0x0030
39#define RBUF_ELEMENT_DONE 0x0044
40
41#define CHANNEL_FLAGS *l$index0[0]
42#define CHANNEL_FLAG_RECEIVING 1
43#define PACKET_LENGTH *l$index0[1]
44#define PACKET_CHECKSUM *l$index0[2]
45#define BUFFER_HANDLE *l$index0[3]
46#define BUFFER_START *l$index0[4]
47#define BUFFER_LENGTH *l$index0[5]
48
49#define CHANNEL_STATE_SIZE 24 // in bytes
50#define CHANNEL_STATE_SHIFT 5 // ceil(log2(state size))
51
52
53 .sig volatile sig1
54 .sig volatile sig2
55 .sig volatile sig3
56
57 .sig mpacket_arrived
58 .reg add_to_rx_freelist
59 .reg read $rsw0, $rsw1
60 .xfer_order $rsw0 $rsw1
61
62 .reg zero
63
64 /*
65 * Initialise add_to_rx_freelist.
66 */
67 .begin
68 .reg temp
69 .reg temp2
70
71 immed[add_to_rx_freelist, RX_THREAD_FREELIST_0]
72 immed_w1[add_to_rx_freelist, (&$rsw0 | (&mpacket_arrived << 12))]
73
74 local_csr_rd[ACTIVE_CTX_STS]
75 immed[temp, 0]
76 alu[temp2, temp, and, 0x1f]
77 alu_shf[add_to_rx_freelist, add_to_rx_freelist, or, temp2, <<20]
78 alu[temp2, temp, and, 0x80]
79 alu_shf[add_to_rx_freelist, add_to_rx_freelist, or, temp2, <<18]
80 .end
81
82 immed[zero, 0]
83
84 /*
85 * Skip context 0 initialisation?
86 */
87 .begin
88 br!=ctx[0, mpacket_receive_loop#]
89 .end
90
91 /*
92 * Initialise local memory.
93 */
94 .begin
95 .reg addr
96 .reg temp
97
98 immed[temp, 0]
99 init_local_mem_loop#:
100 alu_shf[addr, --, b, temp, <<CHANNEL_STATE_SHIFT]
101 local_csr_wr[ACTIVE_LM_ADDR_0, addr]
102 nop
103 nop
104 nop
105
106 immed[CHANNEL_FLAGS, 0]
107
108 alu[temp, temp, +, 1]
109 alu[--, temp, and, 0x20]
110 beq[init_local_mem_loop#]
111 .end
112
113 /*
114 * Initialise signal pipeline.
115 */
116 .begin
117 local_csr_wr[SAME_ME_SIGNAL, (&sig1 << 3)]
118 .set_sig sig1
119
120 local_csr_wr[SAME_ME_SIGNAL, (&sig2 << 3)]
121 .set_sig sig2
122
123 local_csr_wr[SAME_ME_SIGNAL, (&sig3 << 3)]
124 .set_sig sig3
125 .end
126
127mpacket_receive_loop#:
128 /*
129 * Synchronise and wait for mpacket.
130 */
131 .begin
132 ctx_arb[sig1]
133 local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig1 << 3))]
134
135 msf[fast_wr, --, add_to_rx_freelist, 0]
136 .set_sig mpacket_arrived
137 ctx_arb[mpacket_arrived]
138 .set $rsw0 $rsw1
139 .end
140
141 /*
142 * We halt if we see {inbparerr,parerr,null,soperror}.
143 */
144 .begin
145 alu_shf[--, 0x1b, and, $rsw0, >>8]
146 bne[abort_rswerr#]
147 .end
148
149 /*
150 * Point local memory pointer to this channel's state area.
151 */
152 .begin
153 .reg chanaddr
154
155 alu[chanaddr, $rsw0, and, 0x1f]
156 alu_shf[chanaddr, --, b, chanaddr, <<CHANNEL_STATE_SHIFT]
157 local_csr_wr[ACTIVE_LM_ADDR_0, chanaddr]
158 nop
159 nop
160 nop
161 .end
162
163 /*
164 * Check whether we received a SOP mpacket while we were already
165 * working on a packet, or a non-SOP mpacket while there was no
166 * packet pending. (SOP == RECEIVING -> abort) If everything's
167 * okay, update the RECEIVING flag to reflect our new state.
168 */
169 .begin
170 .reg temp
171 .reg eop
172
173 #if CHANNEL_FLAG_RECEIVING != 1
174 #error CHANNEL_FLAG_RECEIVING is not 1
175 #endif
176
177 alu_shf[temp, 1, and, $rsw0, >>15]
178 alu[temp, temp, xor, CHANNEL_FLAGS]
179 alu[--, temp, and, CHANNEL_FLAG_RECEIVING]
180 beq[abort_proterr#]
181
182 alu_shf[eop, 1, and, $rsw0, >>14]
183 alu[CHANNEL_FLAGS, temp, xor, eop]
184 .end
185
186 /*
187 * Copy the mpacket into the right spot, and in case of EOP,
188 * write back the descriptor and pass the packet on.
189 */
190 .begin
191 .reg buffer_offset
192 .reg _packet_length
193 .reg _packet_checksum
194 .reg _buffer_handle
195 .reg _buffer_start
196 .reg _buffer_length
197
198 /*
199 * Determine buffer_offset, _packet_length and
200 * _packet_checksum.
201 */
202 .begin
203 .reg temp
204
205 alu[--, 1, and, $rsw0, >>15]
206 beq[not_sop#]
207
208 immed[PACKET_LENGTH, 0]
209 immed[PACKET_CHECKSUM, 0]
210
211 not_sop#:
212 alu[buffer_offset, --, b, PACKET_LENGTH]
213 alu_shf[temp, 0xff, and, $rsw0, >>16]
214 alu[_packet_length, buffer_offset, +, temp]
215 alu[PACKET_LENGTH, --, b, _packet_length]
216
217 immed[temp, 0xffff]
218 alu[temp, $rsw1, and, temp]
219 alu[_packet_checksum, PACKET_CHECKSUM, +, temp]
220 alu[PACKET_CHECKSUM, --, b, _packet_checksum]
221 .end
222
223 /*
224 * Allocate buffer in case of SOP.
225 */
226 .begin
227 .reg temp
228
229 alu[temp, 1, and, $rsw0, >>15]
230 beq[skip_buffer_alloc#]
231
232 .begin
233 .sig zzz
234 .reg read $stemp $stemp2
235 .xfer_order $stemp $stemp2
236
237 rx_nobufs#:
238 scratch[get, $stemp, zero, 0, 1], ctx_swap[zzz]
239 alu[_buffer_handle, --, b, $stemp]
240 beq[rx_nobufs#]
241
242 sram[read, $stemp, _buffer_handle, 0, 2],
243 ctx_swap[zzz]
244 alu[_buffer_start, --, b, $stemp]
245 alu[_buffer_length, --, b, $stemp2]
246 .end
247
248 skip_buffer_alloc#:
249 .end
250
251 /*
252 * Resynchronise.
253 */
254 .begin
255 ctx_arb[sig2]
256 local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig2 << 3))]
257 .end
258
259 /*
260 * Synchronise buffer state.
261 */
262 .begin
263 .reg temp
264
265 alu[temp, 1, and, $rsw0, >>15]
266 beq[copy_from_local_mem#]
267
268 alu[BUFFER_HANDLE, --, b, _buffer_handle]
269 alu[BUFFER_START, --, b, _buffer_start]
270 alu[BUFFER_LENGTH, --, b, _buffer_length]
271 br[sync_state_done#]
272
273 copy_from_local_mem#:
274 alu[_buffer_handle, --, b, BUFFER_HANDLE]
275 alu[_buffer_start, --, b, BUFFER_START]
276 alu[_buffer_length, --, b, BUFFER_LENGTH]
277
278 sync_state_done#:
279 .end
280
281#if 0
282 /*
283 * Debug buffer state management.
284 */
285 .begin
286 .reg temp
287
288 alu[temp, 1, and, $rsw0, >>14]
289 beq[no_poison#]
290 immed[BUFFER_HANDLE, 0xdead]
291 immed[BUFFER_START, 0xdead]
292 immed[BUFFER_LENGTH, 0xdead]
293 no_poison#:
294
295 immed[temp, 0xdead]
296 alu[--, _buffer_handle, -, temp]
297 beq[state_corrupted#]
298 alu[--, _buffer_start, -, temp]
299 beq[state_corrupted#]
300 alu[--, _buffer_length, -, temp]
301 beq[state_corrupted#]
302 .end
303#endif
304
305 /*
306 * Check buffer length.
307 */
308 .begin
309 alu[--, _buffer_length, -, _packet_length]
310 blo[buffer_overflow#]
311 .end
312
313 /*
314 * Copy the mpacket and give back the RBUF element.
315 */
316 .begin
317 .reg element
318 .reg xfer_size
319 .reg temp
320 .sig copy_sig
321
322 alu_shf[element, 0x7f, and, $rsw0, >>24]
323 alu_shf[xfer_size, 0xff, and, $rsw0, >>16]
324
325 alu[xfer_size, xfer_size, -, 1]
326 alu_shf[xfer_size, 0x10, or, xfer_size, >>3]
327 alu_shf[temp, 0x10, or, xfer_size, <<21]
328 alu_shf[temp, temp, or, element, <<11]
329 alu_shf[--, temp, or, 1, <<18]
330
331 dram[rbuf_rd, --, _buffer_start, buffer_offset, max_8],
332 indirect_ref, sig_done[copy_sig]
333 ctx_arb[copy_sig]
334
335 alu[temp, RBUF_ELEMENT_DONE, or, element, <<16]
336 msf[fast_wr, --, temp, 0]
337 .end
338
339 /*
340 * If EOP, write back the packet descriptor.
341 */
342 .begin
343 .reg write $stemp $stemp2
344 .xfer_order $stemp $stemp2
345 .sig zzz
346
347 alu_shf[--, 1, and, $rsw0, >>14]
348 beq[no_writeback#]
349
350 alu[$stemp, $rsw0, and, 0x1f]
351 alu[$stemp2, --, b, _packet_length]
352 sram[write, $stemp, _buffer_handle, 8, 2], ctx_swap[zzz]
353
354 no_writeback#:
355 .end
356
357 /*
358 * Resynchronise.
359 */
360 .begin
361 ctx_arb[sig3]
362 local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig3 << 3))]
363 .end
364
365 /*
366 * If EOP, put the buffer back onto the scratch ring.
367 */
368 .begin
369 .reg write $stemp
370 .sig zzz
371
372 br_inp_state[SCR_Ring1_Status, rx_done_ring_overflow#]
373
374 alu_shf[--, 1, and, $rsw0, >>14]
375 beq[mpacket_receive_loop#]
376
377 alu[--, 1, and, $rsw0, >>10]
378 bne[rxerr#]
379
380 alu[$stemp, --, b, _buffer_handle]
381 scratch[put, $stemp, zero, 4, 1], ctx_swap[zzz]
382 cap[fast_wr, 0, XSCALE_INT_A]
383 br[mpacket_receive_loop#]
384
385 rxerr#:
386 alu[$stemp, --, b, _buffer_handle]
387 scratch[put, $stemp, zero, 0, 1], ctx_swap[zzz]
388 br[mpacket_receive_loop#]
389 .end
390 .end
391
392
393abort_rswerr#:
394 halt
395
396abort_proterr#:
397 halt
398
399state_corrupted#:
400 halt
401
402buffer_overflow#:
403 halt
404
405rx_done_ring_overflow#:
406 halt
407
408
diff --git a/drivers/net/ixp2000/ixp2400_rx.ucode b/drivers/net/ixp2000/ixp2400_rx.ucode
new file mode 100644
index 000000000000..e8aee2f81aad
--- /dev/null
+++ b/drivers/net/ixp2000/ixp2400_rx.ucode
@@ -0,0 +1,130 @@
1static struct ixp2000_uengine_code ixp2400_rx =
2{
3 .cpu_model_bitmask = 0x000003fe,
4 .cpu_min_revision = 0,
5 .cpu_max_revision = 255,
6
7 .uengine_parameters = IXP2000_UENGINE_8_CONTEXTS |
8 IXP2000_UENGINE_PRN_UPDATE_EVERY |
9 IXP2000_UENGINE_NN_FROM_PREVIOUS |
10 IXP2000_UENGINE_ASSERT_EMPTY_AT_0 |
11 IXP2000_UENGINE_LM_ADDR1_PER_CONTEXT |
12 IXP2000_UENGINE_LM_ADDR0_PER_CONTEXT,
13
14 .initial_reg_values = (struct ixp2000_reg_value []) {
15 { -1, -1 }
16 },
17
18 .num_insns = 109,
19 .insns = (u8 []) {
20 0xf0, 0x00, 0x0c, 0xc0, 0x05,
21 0xf4, 0x44, 0x0c, 0x00, 0x05,
22 0xfc, 0x04, 0x4c, 0x00, 0x00,
23 0xf0, 0x00, 0x00, 0x3b, 0x00,
24 0xb4, 0x40, 0xf0, 0x3b, 0x1f,
25 0x8a, 0xc0, 0x50, 0x3e, 0x05,
26 0xb4, 0x40, 0xf0, 0x3b, 0x80,
27 0x9a, 0xe0, 0x00, 0x3e, 0x05,
28 0xf0, 0x00, 0x00, 0x07, 0x00,
29 0xd8, 0x05, 0xc0, 0x00, 0x11,
30 0xf0, 0x00, 0x00, 0x0f, 0x00,
31 0x91, 0xb0, 0x20, 0x0e, 0x00,
32 0xfc, 0x06, 0x60, 0x0b, 0x00,
33 0xf0, 0x00, 0x0c, 0x03, 0x00,
34 0xf0, 0x00, 0x0c, 0x03, 0x00,
35 0xf0, 0x00, 0x0c, 0x03, 0x00,
36 0xf0, 0x00, 0x0c, 0x02, 0x00,
37 0xb0, 0xc0, 0x30, 0x0f, 0x01,
38 0xa4, 0x70, 0x00, 0x0f, 0x20,
39 0xd8, 0x02, 0xc0, 0x01, 0x00,
40 0xfc, 0x10, 0xac, 0x23, 0x08,
41 0xfc, 0x10, 0xac, 0x43, 0x10,
42 0xfc, 0x10, 0xac, 0x63, 0x18,
43 0xe0, 0x00, 0x00, 0x00, 0x02,
44 0xfc, 0x10, 0xae, 0x23, 0x88,
45 0x3d, 0x00, 0x04, 0x03, 0x20,
46 0xe0, 0x00, 0x00, 0x00, 0x10,
47 0x84, 0x82, 0x02, 0x01, 0x3b,
48 0xd8, 0x1a, 0x00, 0x01, 0x01,
49 0xb4, 0x00, 0x8c, 0x7d, 0x80,
50 0x91, 0xb0, 0x80, 0x22, 0x00,
51 0xfc, 0x06, 0x60, 0x23, 0x00,
52 0xf0, 0x00, 0x0c, 0x03, 0x00,
53 0xf0, 0x00, 0x0c, 0x03, 0x00,
54 0xf0, 0x00, 0x0c, 0x03, 0x00,
55 0x94, 0xf0, 0x92, 0x01, 0x21,
56 0xac, 0x40, 0x60, 0x26, 0x00,
57 0xa4, 0x30, 0x0c, 0x04, 0x06,
58 0xd8, 0x1a, 0x40, 0x01, 0x00,
59 0x94, 0xe0, 0xa2, 0x01, 0x21,
60 0xac, 0x20, 0x00, 0x28, 0x06,
61 0x84, 0xf2, 0x02, 0x01, 0x21,
62 0xd8, 0x0b, 0x40, 0x01, 0x00,
63 0xf0, 0x00, 0x0c, 0x02, 0x01,
64 0xf0, 0x00, 0x0c, 0x02, 0x02,
65 0xa0, 0x00, 0x08, 0x04, 0x00,
66 0x95, 0x00, 0xc6, 0x01, 0xff,
67 0xa0, 0x80, 0x10, 0x30, 0x00,
68 0xa0, 0x60, 0x1c, 0x00, 0x01,
69 0xf0, 0x0f, 0xf0, 0x33, 0xff,
70 0xb4, 0x00, 0xc0, 0x31, 0x81,
71 0xb0, 0x80, 0xb0, 0x32, 0x02,
72 0xa0, 0x20, 0x20, 0x2c, 0x00,
73 0x94, 0xf0, 0xd2, 0x01, 0x21,
74 0xd8, 0x0f, 0x40, 0x01, 0x00,
75 0x19, 0x40, 0x10, 0x04, 0x20,
76 0xa0, 0x00, 0x26, 0x04, 0x00,
77 0xd8, 0x0d, 0xc0, 0x01, 0x00,
78 0x00, 0x42, 0x10, 0x80, 0x02,
79 0xb0, 0x00, 0x46, 0x04, 0x00,
80 0xb0, 0x00, 0x56, 0x08, 0x00,
81 0xe0, 0x00, 0x00, 0x00, 0x04,
82 0xfc, 0x10, 0xae, 0x43, 0x90,
83 0x84, 0xf0, 0x32, 0x01, 0x21,
84 0xd8, 0x11, 0x40, 0x01, 0x00,
85 0xa0, 0x60, 0x3c, 0x00, 0x02,
86 0xa0, 0x20, 0x40, 0x10, 0x00,
87 0xa0, 0x20, 0x50, 0x14, 0x00,
88 0xd8, 0x12, 0x00, 0x00, 0x18,
89 0xa0, 0x00, 0x28, 0x0c, 0x00,
90 0xb0, 0x00, 0x48, 0x10, 0x00,
91 0xb0, 0x00, 0x58, 0x14, 0x00,
92 0xaa, 0xf0, 0x00, 0x14, 0x01,
93 0xd8, 0x1a, 0xc0, 0x01, 0x05,
94 0x85, 0x80, 0x42, 0x01, 0xff,
95 0x95, 0x00, 0x66, 0x01, 0xff,
96 0xba, 0xc0, 0x60, 0x1b, 0x01,
97 0x9a, 0x30, 0x60, 0x19, 0x30,
98 0x9a, 0xb0, 0x70, 0x1a, 0x30,
99 0x9b, 0x50, 0x78, 0x1e, 0x04,
100 0x8a, 0xe2, 0x08, 0x1e, 0x21,
101 0x6a, 0x4e, 0x00, 0x13, 0x00,
102 0xe0, 0x00, 0x00, 0x00, 0x30,
103 0x9b, 0x00, 0x7a, 0x92, 0x04,
104 0x3d, 0x00, 0x04, 0x1f, 0x20,
105 0x84, 0xe2, 0x02, 0x01, 0x21,
106 0xd8, 0x16, 0x80, 0x01, 0x00,
107 0xa4, 0x18, 0x0c, 0x7d, 0x80,
108 0xa0, 0x58, 0x1c, 0x00, 0x01,
109 0x01, 0x42, 0x00, 0xa0, 0x02,
110 0xe0, 0x00, 0x00, 0x00, 0x08,
111 0xfc, 0x10, 0xae, 0x63, 0x98,
112 0xd8, 0x1b, 0x00, 0xc2, 0x14,
113 0x84, 0xe2, 0x02, 0x01, 0x21,
114 0xd8, 0x05, 0xc0, 0x01, 0x00,
115 0x84, 0xa2, 0x02, 0x01, 0x21,
116 0xd8, 0x19, 0x40, 0x01, 0x01,
117 0xa0, 0x58, 0x0c, 0x00, 0x02,
118 0x1a, 0x40, 0x00, 0x04, 0x24,
119 0x33, 0x00, 0x01, 0x2f, 0x20,
120 0xd8, 0x05, 0xc0, 0x00, 0x18,
121 0xa0, 0x58, 0x0c, 0x00, 0x02,
122 0x1a, 0x40, 0x00, 0x04, 0x20,
123 0xd8, 0x05, 0xc0, 0x00, 0x18,
124 0xe0, 0x00, 0x02, 0x00, 0x00,
125 0xe0, 0x00, 0x02, 0x00, 0x00,
126 0xe0, 0x00, 0x02, 0x00, 0x00,
127 0xe0, 0x00, 0x02, 0x00, 0x00,
128 0xe0, 0x00, 0x02, 0x00, 0x00,
129 }
130};
diff --git a/drivers/net/ixp2000/ixp2400_tx.uc b/drivers/net/ixp2000/ixp2400_tx.uc
new file mode 100644
index 000000000000..d090d1884fb7
--- /dev/null
+++ b/drivers/net/ixp2000/ixp2400_tx.uc
@@ -0,0 +1,272 @@
1/*
2 * TX ucode for the Intel IXP2400 in POS-PHY mode.
3 * Copyright (C) 2004, 2005 Lennert Buytenhek
4 * Dedicated to Marija Kulikova.
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 * Assumptions made in this code:
12 * - The IXP2400 MSF is configured for POS-PHY mode, in a mode where
13 * only one TBUF partition is used. This includes, for example,
14 * 1x32 SPHY and 1x32 MPHY32, but not 4x8 SPHY or 1x32 MPHY4. (This
15 * is not an exhaustive list.)
16 * - The TBUF uses 64-byte mpackets.
17 * - TX descriptors reside in SRAM, and have the following format:
18 * struct tx_desc
19 * {
20 * // to uengine
21 * u32 buf_phys_addr;
22 * u32 pkt_length;
23 * u32 channel;
24 * };
25 * - Packet data resides in DRAM.
26 * - Packet buffer addresses are 8-byte aligned.
27 * - Scratch ring 2 is tx_pending.
28 * - Scratch ring 3 is tx_done, and has status condition 'full'.
29 * - This code is run on all eight threads of the microengine it runs on.
30 */
31
32#define TX_SEQUENCE_0 0x0060
33#define TBUF_CTRL 0x1800
34
35#define PARTITION_SIZE 128
36#define PARTITION_THRESH 96
37
38
39 .sig volatile sig1
40 .sig volatile sig2
41 .sig volatile sig3
42
43 .reg @old_tx_seq_0
44 .reg @mpkts_in_flight
45 .reg @next_tbuf_mpacket
46
47 .reg @buffer_handle
48 .reg @buffer_start
49 .reg @packet_length
50 .reg @channel
51 .reg @packet_offset
52
53 .reg zero
54
55 immed[zero, 0]
56
57 /*
58 * Skip context 0 initialisation?
59 */
60 .begin
61 br!=ctx[0, mpacket_tx_loop#]
62 .end
63
64 /*
65 * Wait until all pending TBUF elements have been transmitted.
66 */
67 .begin
68 .reg read $tx
69 .sig zzz
70
71 loop_empty#:
72 msf[read, $tx, zero, TX_SEQUENCE_0, 1], ctx_swap[zzz]
73 alu_shf[--, --, b, $tx, >>31]
74 beq[loop_empty#]
75
76 alu[@old_tx_seq_0, --, b, $tx]
77 .end
78
79 immed[@mpkts_in_flight, 0]
80 alu[@next_tbuf_mpacket, @old_tx_seq_0, and, (PARTITION_SIZE - 1)]
81
82 immed[@buffer_handle, 0]
83
84 /*
85 * Initialise signal pipeline.
86 */
87 .begin
88 local_csr_wr[SAME_ME_SIGNAL, (&sig1 << 3)]
89 .set_sig sig1
90
91 local_csr_wr[SAME_ME_SIGNAL, (&sig2 << 3)]
92 .set_sig sig2
93
94 local_csr_wr[SAME_ME_SIGNAL, (&sig3 << 3)]
95 .set_sig sig3
96 .end
97
98mpacket_tx_loop#:
99 .begin
100 .reg tbuf_element_index
101 .reg buffer_handle
102 .reg sop_eop
103 .reg packet_data
104 .reg channel
105 .reg mpacket_size
106
107 /*
108 * If there is no packet currently being transmitted,
109 * dequeue the next TX descriptor, and fetch the buffer
110 * address, packet length and destination channel number.
111 */
112 .begin
113 .reg read $stemp $stemp2 $stemp3
114 .xfer_order $stemp $stemp2 $stemp3
115 .sig zzz
116
117 ctx_arb[sig1]
118
119 alu[--, --, b, @buffer_handle]
120 bne[already_got_packet#]
121
122 tx_nobufs#:
123 scratch[get, $stemp, zero, 8, 1], ctx_swap[zzz]
124 alu[@buffer_handle, --, b, $stemp]
125 beq[tx_nobufs#]
126
127 sram[read, $stemp, $stemp, 0, 3], ctx_swap[zzz]
128 alu[@buffer_start, --, b, $stemp]
129 alu[@packet_length, --, b, $stemp2]
130 beq[zero_byte_packet#]
131 alu[@channel, --, b, $stemp3]
132 immed[@packet_offset, 0]
133
134 already_got_packet#:
135 local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig1 << 3))]
136 .end
137
138 /*
139 * Determine tbuf element index, SOP/EOP flags, mpacket
140 * offset and mpacket size and cache buffer_handle and
141 * channel number.
142 */
143 .begin
144 alu[tbuf_element_index, --, b, @next_tbuf_mpacket]
145 alu[@next_tbuf_mpacket, @next_tbuf_mpacket, +, 1]
146 alu[@next_tbuf_mpacket, @next_tbuf_mpacket, and,
147 (PARTITION_SIZE - 1)]
148
149 alu[buffer_handle, --, b, @buffer_handle]
150 immed[@buffer_handle, 0]
151
152 immed[sop_eop, 1]
153
154 alu[packet_data, --, b, @packet_offset]
155 bne[no_sop#]
156 alu[sop_eop, sop_eop, or, 2]
157 no_sop#:
158 alu[packet_data, packet_data, +, @buffer_start]
159
160 alu[channel, --, b, @channel]
161
162 alu[mpacket_size, @packet_length, -, @packet_offset]
163 alu[--, 64, -, mpacket_size]
164 bhs[eop#]
165 alu[@buffer_handle, --, b, buffer_handle]
166 immed[mpacket_size, 64]
167 alu[sop_eop, sop_eop, and, 2]
168 eop#:
169
170 alu[@packet_offset, @packet_offset, +, mpacket_size]
171 .end
172
173 /*
174 * Wait until there's enough space in the TBUF.
175 */
176 .begin
177 .reg read $tx
178 .reg temp
179 .sig zzz
180
181 ctx_arb[sig2]
182
183 br[test_space#]
184
185 loop_space#:
186 msf[read, $tx, zero, TX_SEQUENCE_0, 1], ctx_swap[zzz]
187
188 alu[temp, $tx, -, @old_tx_seq_0]
189 alu[temp, temp, and, 0xff]
190 alu[@mpkts_in_flight, @mpkts_in_flight, -, temp]
191
192 alu[@old_tx_seq_0, --, b, $tx]
193
194 test_space#:
195 alu[--, PARTITION_THRESH, -, @mpkts_in_flight]
196 blo[loop_space#]
197
198 alu[@mpkts_in_flight, @mpkts_in_flight, +, 1]
199
200 local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig2 << 3))]
201 .end
202
203 /*
204 * Copy the packet data to the TBUF.
205 */
206 .begin
207 .reg temp
208 .sig copy_sig
209
210 alu[temp, mpacket_size, -, 1]
211 alu_shf[temp, 0x10, or, temp, >>3]
212 alu_shf[temp, 0x10, or, temp, <<21]
213 alu_shf[temp, temp, or, tbuf_element_index, <<11]
214 alu_shf[--, temp, or, 1, <<18]
215
216 dram[tbuf_wr, --, packet_data, 0, max_8],
217 indirect_ref, sig_done[copy_sig]
218 ctx_arb[copy_sig]
219 .end
220
221 /*
222 * Mark TBUF element as ready-to-be-transmitted.
223 */
224 .begin
225 .reg write $tsw $tsw2
226 .xfer_order $tsw $tsw2
227 .reg temp
228 .sig zzz
229
230 alu_shf[temp, channel, or, mpacket_size, <<24]
231 alu_shf[$tsw, temp, or, sop_eop, <<8]
232 immed[$tsw2, 0]
233
234 immed[temp, TBUF_CTRL]
235 alu_shf[temp, temp, or, tbuf_element_index, <<3]
236 msf[write, $tsw, temp, 0, 2], ctx_swap[zzz]
237 .end
238
239 /*
240 * Resynchronise.
241 */
242 .begin
243 ctx_arb[sig3]
244 local_csr_wr[SAME_ME_SIGNAL, (0x80 | (&sig3 << 3))]
245 .end
246
247 /*
248 * If this was an EOP mpacket, recycle the TX buffer
249 * and signal the host.
250 */
251 .begin
252 .reg write $stemp
253 .sig zzz
254
255 alu[--, sop_eop, and, 1]
256 beq[mpacket_tx_loop#]
257
258 tx_done_ring_full#:
259 br_inp_state[SCR_Ring3_Status, tx_done_ring_full#]
260
261 alu[$stemp, --, b, buffer_handle]
262 scratch[put, $stemp, zero, 12, 1], ctx_swap[zzz]
263 cap[fast_wr, 0, XSCALE_INT_A]
264 br[mpacket_tx_loop#]
265 .end
266 .end
267
268
269zero_byte_packet#:
270 halt
271
272
diff --git a/drivers/net/ixp2000/ixp2400_tx.ucode b/drivers/net/ixp2000/ixp2400_tx.ucode
new file mode 100644
index 000000000000..a433e24b0a51
--- /dev/null
+++ b/drivers/net/ixp2000/ixp2400_tx.ucode
@@ -0,0 +1,98 @@
1static struct ixp2000_uengine_code ixp2400_tx =
2{
3 .cpu_model_bitmask = 0x000003fe,
4 .cpu_min_revision = 0,
5 .cpu_max_revision = 255,
6
7 .uengine_parameters = IXP2000_UENGINE_8_CONTEXTS |
8 IXP2000_UENGINE_PRN_UPDATE_EVERY |
9 IXP2000_UENGINE_NN_FROM_PREVIOUS |
10 IXP2000_UENGINE_ASSERT_EMPTY_AT_0 |
11 IXP2000_UENGINE_LM_ADDR1_PER_CONTEXT |
12 IXP2000_UENGINE_LM_ADDR0_PER_CONTEXT,
13
14 .initial_reg_values = (struct ixp2000_reg_value []) {
15 { -1, -1 }
16 },
17
18 .num_insns = 77,
19 .insns = (u8 []) {
20 0xf0, 0x00, 0x00, 0x07, 0x00,
21 0xd8, 0x03, 0x00, 0x00, 0x11,
22 0x3c, 0x40, 0x00, 0x04, 0xe0,
23 0x81, 0xf2, 0x02, 0x01, 0x00,
24 0xd8, 0x00, 0x80, 0x01, 0x00,
25 0xb0, 0x08, 0x06, 0x00, 0x00,
26 0xf0, 0x00, 0x0c, 0x00, 0x80,
27 0xb4, 0x49, 0x02, 0x03, 0x7f,
28 0xf0, 0x00, 0x02, 0x83, 0x00,
29 0xfc, 0x10, 0xac, 0x23, 0x08,
30 0xfc, 0x10, 0xac, 0x43, 0x10,
31 0xfc, 0x10, 0xac, 0x63, 0x18,
32 0xe0, 0x00, 0x00, 0x00, 0x02,
33 0xa0, 0x30, 0x02, 0x80, 0x00,
34 0xd8, 0x06, 0x00, 0x01, 0x01,
35 0x19, 0x40, 0x00, 0x04, 0x28,
36 0xb0, 0x0a, 0x06, 0x00, 0x00,
37 0xd8, 0x03, 0xc0, 0x01, 0x00,
38 0x00, 0x44, 0x00, 0x80, 0x80,
39 0xa0, 0x09, 0x06, 0x00, 0x00,
40 0xb0, 0x0b, 0x06, 0x04, 0x00,
41 0xd8, 0x13, 0x00, 0x01, 0x00,
42 0xb0, 0x0c, 0x06, 0x08, 0x00,
43 0xf0, 0x00, 0x0c, 0x00, 0xa0,
44 0xfc, 0x10, 0xae, 0x23, 0x88,
45 0xa0, 0x00, 0x12, 0x40, 0x00,
46 0xb0, 0xc9, 0x02, 0x43, 0x01,
47 0xb4, 0x49, 0x02, 0x43, 0x7f,
48 0xb0, 0x00, 0x22, 0x80, 0x00,
49 0xf0, 0x00, 0x02, 0x83, 0x00,
50 0xf0, 0x00, 0x0c, 0x04, 0x02,
51 0xb0, 0x40, 0x6c, 0x00, 0xa0,
52 0xd8, 0x08, 0x80, 0x01, 0x01,
53 0xaa, 0x00, 0x2c, 0x08, 0x02,
54 0xa0, 0xc0, 0x30, 0x18, 0x90,
55 0xa0, 0x00, 0x43, 0x00, 0x00,
56 0xba, 0xc0, 0x32, 0xc0, 0xa0,
57 0xaa, 0xb0, 0x00, 0x0f, 0x40,
58 0xd8, 0x0a, 0x80, 0x01, 0x04,
59 0xb0, 0x0a, 0x00, 0x08, 0x00,
60 0xf0, 0x00, 0x00, 0x0f, 0x40,
61 0xa4, 0x00, 0x2c, 0x08, 0x02,
62 0xa0, 0x8a, 0x00, 0x0c, 0xa0,
63 0xe0, 0x00, 0x00, 0x00, 0x04,
64 0xd8, 0x0c, 0x80, 0x00, 0x18,
65 0x3c, 0x40, 0x00, 0x04, 0xe0,
66 0xba, 0x80, 0x42, 0x01, 0x80,
67 0xb4, 0x40, 0x40, 0x13, 0xff,
68 0xaa, 0x88, 0x00, 0x10, 0x80,
69 0xb0, 0x08, 0x06, 0x00, 0x00,
70 0xaa, 0xf0, 0x0d, 0x80, 0x80,
71 0xd8, 0x0b, 0x40, 0x01, 0x05,
72 0xa0, 0x88, 0x0c, 0x04, 0x80,
73 0xfc, 0x10, 0xae, 0x43, 0x90,
74 0xba, 0xc0, 0x50, 0x0f, 0x01,
75 0x9a, 0x30, 0x50, 0x15, 0x30,
76 0x9a, 0xb0, 0x50, 0x16, 0x30,
77 0x9b, 0x50, 0x58, 0x16, 0x01,
78 0x8a, 0xe2, 0x08, 0x16, 0x21,
79 0x6b, 0x4e, 0x00, 0x83, 0x03,
80 0xe0, 0x00, 0x00, 0x00, 0x30,
81 0x9a, 0x80, 0x70, 0x0e, 0x04,
82 0x8b, 0x88, 0x08, 0x1e, 0x02,
83 0xf0, 0x00, 0x0c, 0x01, 0x81,
84 0xf0, 0x01, 0x80, 0x1f, 0x00,
85 0x9b, 0xd0, 0x78, 0x1e, 0x01,
86 0x3d, 0x42, 0x00, 0x1c, 0x20,
87 0xe0, 0x00, 0x00, 0x00, 0x08,
88 0xfc, 0x10, 0xae, 0x63, 0x98,
89 0xa4, 0x30, 0x0c, 0x04, 0x02,
90 0xd8, 0x03, 0x00, 0x01, 0x00,
91 0xd8, 0x11, 0xc1, 0x42, 0x14,
92 0xa0, 0x18, 0x00, 0x08, 0x00,
93 0x1a, 0x40, 0x00, 0x04, 0x2c,
94 0x33, 0x00, 0x01, 0x2f, 0x20,
95 0xd8, 0x03, 0x00, 0x00, 0x18,
96 0xe0, 0x00, 0x02, 0x00, 0x00,
97 }
98};
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
new file mode 100644
index 000000000000..09f03f493bea
--- /dev/null
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -0,0 +1,421 @@
1/*
2 * IXP2000 MSF network device driver
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/config.h>
13#include <linux/module.h>
14#include <linux/kernel.h>
15#include <linux/netdevice.h>
16#include <linux/etherdevice.h>
17#include <linux/init.h>
18#include <linux/moduleparam.h>
19#include <asm/arch/uengine.h>
20#include <asm/mach-types.h>
21#include <asm/io.h>
22#include "ixp2400_rx.ucode"
23#include "ixp2400_tx.ucode"
24#include "ixpdev_priv.h"
25#include "ixpdev.h"
26
27#define DRV_MODULE_VERSION "0.2"
28
29static int nds_count;
30static struct net_device **nds;
31static int nds_open;
32static void (*set_port_admin_status)(int port, int up);
33
34static struct ixpdev_rx_desc * const rx_desc =
35 (struct ixpdev_rx_desc *)(IXP2000_SRAM0_VIRT_BASE + RX_BUF_DESC_BASE);
36static struct ixpdev_tx_desc * const tx_desc =
37 (struct ixpdev_tx_desc *)(IXP2000_SRAM0_VIRT_BASE + TX_BUF_DESC_BASE);
38static int tx_pointer;
39
40
41static int ixpdev_xmit(struct sk_buff *skb, struct net_device *dev)
42{
43 struct ixpdev_priv *ip = netdev_priv(dev);
44 struct ixpdev_tx_desc *desc;
45 int entry;
46
47 if (unlikely(skb->len > PAGE_SIZE)) {
48 /* @@@ Count drops. */
49 dev_kfree_skb(skb);
50 return 0;
51 }
52
53 entry = tx_pointer;
54 tx_pointer = (tx_pointer + 1) % TX_BUF_COUNT;
55
56 desc = tx_desc + entry;
57 desc->pkt_length = skb->len;
58 desc->channel = ip->channel;
59
60 skb_copy_and_csum_dev(skb, phys_to_virt(desc->buf_addr));
61 dev_kfree_skb(skb);
62
63 ixp2000_reg_write(RING_TX_PENDING,
64 TX_BUF_DESC_BASE + (entry * sizeof(struct ixpdev_tx_desc)));
65
66 dev->trans_start = jiffies;
67
68 local_irq_disable();
69 ip->tx_queue_entries++;
70 if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN)
71 netif_stop_queue(dev);
72 local_irq_enable();
73
74 return 0;
75}
76
77
78static int ixpdev_rx(struct net_device *dev, int *budget)
79{
80 while (*budget > 0) {
81 struct ixpdev_rx_desc *desc;
82 struct sk_buff *skb;
83 void *buf;
84 u32 _desc;
85
86 _desc = ixp2000_reg_read(RING_RX_DONE);
87 if (_desc == 0)
88 return 0;
89
90 desc = rx_desc +
91 ((_desc - RX_BUF_DESC_BASE) / sizeof(struct ixpdev_rx_desc));
92 buf = phys_to_virt(desc->buf_addr);
93
94 if (desc->pkt_length < 4 || desc->pkt_length > PAGE_SIZE) {
95 printk(KERN_ERR "ixp2000: rx err, length %d\n",
96 desc->pkt_length);
97 goto err;
98 }
99
100 if (desc->channel < 0 || desc->channel >= nds_count) {
101 printk(KERN_ERR "ixp2000: rx err, channel %d\n",
102 desc->channel);
103 goto err;
104 }
105
106 /* @@@ Make FCS stripping configurable. */
107 desc->pkt_length -= 4;
108
109 if (unlikely(!netif_running(nds[desc->channel])))
110 goto err;
111
112 skb = dev_alloc_skb(desc->pkt_length + 2);
113 if (likely(skb != NULL)) {
114 skb->dev = nds[desc->channel];
115 skb_reserve(skb, 2);
116 eth_copy_and_sum(skb, buf, desc->pkt_length, 0);
117 skb_put(skb, desc->pkt_length);
118 skb->protocol = eth_type_trans(skb, skb->dev);
119
120 skb->dev->last_rx = jiffies;
121
122 netif_receive_skb(skb);
123 }
124
125err:
126 ixp2000_reg_write(RING_RX_PENDING, _desc);
127 dev->quota--;
128 (*budget)--;
129 }
130
131 return 1;
132}
133
134/* dev always points to nds[0]. */
135static int ixpdev_poll(struct net_device *dev, int *budget)
136{
137 /* @@@ Have to stop polling when nds[0] is administratively
138 * downed while we are polling. */
139 do {
140 ixp2000_reg_write(IXP2000_IRQ_THD_RAW_STATUS_A_0, 0x00ff);
141
142 if (ixpdev_rx(dev, budget))
143 return 1;
144 } while (ixp2000_reg_read(IXP2000_IRQ_THD_RAW_STATUS_A_0) & 0x00ff);
145
146 netif_rx_complete(dev);
147 ixp2000_reg_write(IXP2000_IRQ_THD_ENABLE_SET_A_0, 0x00ff);
148
149 return 0;
150}
151
152static void ixpdev_tx_complete(void)
153{
154 int channel;
155 u32 wake;
156
157 wake = 0;
158 while (1) {
159 struct ixpdev_priv *ip;
160 u32 desc;
161 int entry;
162
163 desc = ixp2000_reg_read(RING_TX_DONE);
164 if (desc == 0)
165 break;
166
167 /* @@@ Check whether entries come back in order. */
168 entry = (desc - TX_BUF_DESC_BASE) / sizeof(struct ixpdev_tx_desc);
169 channel = tx_desc[entry].channel;
170
171 if (channel < 0 || channel >= nds_count) {
172 printk(KERN_ERR "ixp2000: txcomp channel index "
173 "out of bounds (%d, %.8i, %d)\n",
174 channel, (unsigned int)desc, entry);
175 continue;
176 }
177
178 ip = netdev_priv(nds[channel]);
179 if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN)
180 wake |= 1 << channel;
181 ip->tx_queue_entries--;
182 }
183
184 for (channel = 0; wake != 0; channel++) {
185 if (wake & (1 << channel)) {
186 netif_wake_queue(nds[channel]);
187 wake &= ~(1 << channel);
188 }
189 }
190}
191
192static irqreturn_t ixpdev_interrupt(int irq, void *dev_id, struct pt_regs *regs)
193{
194 u32 status;
195
196 status = ixp2000_reg_read(IXP2000_IRQ_THD_STATUS_A_0);
197 if (status == 0)
198 return IRQ_NONE;
199
200 /*
201 * Any of the eight receive units signaled RX?
202 */
203 if (status & 0x00ff) {
204 ixp2000_reg_wrb(IXP2000_IRQ_THD_ENABLE_CLEAR_A_0, 0x00ff);
205 if (likely(__netif_rx_schedule_prep(nds[0]))) {
206 __netif_rx_schedule(nds[0]);
207 } else {
208 printk(KERN_CRIT "ixp2000: irq while polling!!\n");
209 }
210 }
211
212 /*
213 * Any of the eight transmit units signaled TXdone?
214 */
215 if (status & 0xff00) {
216 ixp2000_reg_wrb(IXP2000_IRQ_THD_RAW_STATUS_A_0, 0xff00);
217 ixpdev_tx_complete();
218 }
219
220 return IRQ_HANDLED;
221}
222
223#ifdef CONFIG_NET_POLL_CONTROLLER
224static void ixpdev_poll_controller(struct net_device *dev)
225{
226 disable_irq(IRQ_IXP2000_THDA0);
227 ixpdev_interrupt(IRQ_IXP2000_THDA0, dev, NULL);
228 enable_irq(IRQ_IXP2000_THDA0);
229}
230#endif
231
232static int ixpdev_open(struct net_device *dev)
233{
234 struct ixpdev_priv *ip = netdev_priv(dev);
235 int err;
236
237 if (!nds_open++) {
238 err = request_irq(IRQ_IXP2000_THDA0, ixpdev_interrupt,
239 SA_SHIRQ, "ixp2000_eth", nds);
240 if (err) {
241 nds_open--;
242 return err;
243 }
244
245 ixp2000_reg_write(IXP2000_IRQ_THD_ENABLE_SET_A_0, 0xffff);
246 }
247
248 set_port_admin_status(ip->channel, 1);
249 netif_start_queue(dev);
250
251 return 0;
252}
253
254static int ixpdev_close(struct net_device *dev)
255{
256 struct ixpdev_priv *ip = netdev_priv(dev);
257
258 netif_stop_queue(dev);
259 set_port_admin_status(ip->channel, 0);
260
261 if (!--nds_open) {
262 ixp2000_reg_write(IXP2000_IRQ_THD_ENABLE_CLEAR_A_0, 0xffff);
263 free_irq(IRQ_IXP2000_THDA0, nds);
264 }
265
266 return 0;
267}
268
269struct net_device *ixpdev_alloc(int channel, int sizeof_priv)
270{
271 struct net_device *dev;
272 struct ixpdev_priv *ip;
273
274 dev = alloc_etherdev(sizeof_priv);
275 if (dev == NULL)
276 return NULL;
277
278 dev->hard_start_xmit = ixpdev_xmit;
279 dev->poll = ixpdev_poll;
280 dev->open = ixpdev_open;
281 dev->stop = ixpdev_close;
282#ifdef CONFIG_NET_POLL_CONTROLLER
283 dev->poll_controller = ixpdev_poll_controller;
284#endif
285
286 dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM;
287 dev->weight = 64;
288
289 ip = netdev_priv(dev);
290 ip->channel = channel;
291 ip->tx_queue_entries = 0;
292
293 return dev;
294}
295
296int ixpdev_init(int __nds_count, struct net_device **__nds,
297 void (*__set_port_admin_status)(int port, int up))
298{
299 int i;
300 int err;
301
302 if (RX_BUF_COUNT > 192 || TX_BUF_COUNT > 192) {
303 static void __too_many_rx_or_tx_buffers(void);
304 __too_many_rx_or_tx_buffers();
305 }
306
307 printk(KERN_INFO "IXP2000 MSF ethernet driver %s\n", DRV_MODULE_VERSION);
308
309 nds_count = __nds_count;
310 nds = __nds;
311 set_port_admin_status = __set_port_admin_status;
312
313 for (i = 0; i < RX_BUF_COUNT; i++) {
314 void *buf;
315
316 buf = (void *)get_zeroed_page(GFP_KERNEL);
317 if (buf == NULL) {
318 err = -ENOMEM;
319 while (--i >= 0)
320 free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr));
321 goto err_out;
322 }
323 rx_desc[i].buf_addr = virt_to_phys(buf);
324 rx_desc[i].buf_length = PAGE_SIZE;
325 }
326
327 /* @@@ Maybe we shouldn't be preallocating TX buffers. */
328 for (i = 0; i < TX_BUF_COUNT; i++) {
329 void *buf;
330
331 buf = (void *)get_zeroed_page(GFP_KERNEL);
332 if (buf == NULL) {
333 err = -ENOMEM;
334 while (--i >= 0)
335 free_page((unsigned long)phys_to_virt(tx_desc[i].buf_addr));
336 goto err_free_rx;
337 }
338 tx_desc[i].buf_addr = virt_to_phys(buf);
339 }
340
341 /* 256 entries, ring status set means 'empty', base address 0x0000. */
342 ixp2000_reg_write(RING_RX_PENDING_BASE, 0x44000000);
343 ixp2000_reg_write(RING_RX_PENDING_HEAD, 0x00000000);
344 ixp2000_reg_write(RING_RX_PENDING_TAIL, 0x00000000);
345
346 /* 256 entries, ring status set means 'full', base address 0x0400. */
347 ixp2000_reg_write(RING_RX_DONE_BASE, 0x40000400);
348 ixp2000_reg_write(RING_RX_DONE_HEAD, 0x00000000);
349 ixp2000_reg_write(RING_RX_DONE_TAIL, 0x00000000);
350
351 for (i = 0; i < RX_BUF_COUNT; i++) {
352 ixp2000_reg_write(RING_RX_PENDING,
353 RX_BUF_DESC_BASE + (i * sizeof(struct ixpdev_rx_desc)));
354 }
355
356 ixp2000_uengine_load(0, &ixp2400_rx);
357 ixp2000_uengine_start_contexts(0, 0xff);
358
359 /* 256 entries, ring status set means 'empty', base address 0x0800. */
360 ixp2000_reg_write(RING_TX_PENDING_BASE, 0x44000800);
361 ixp2000_reg_write(RING_TX_PENDING_HEAD, 0x00000000);
362 ixp2000_reg_write(RING_TX_PENDING_TAIL, 0x00000000);
363
364 /* 256 entries, ring status set means 'full', base address 0x0c00. */
365 ixp2000_reg_write(RING_TX_DONE_BASE, 0x40000c00);
366 ixp2000_reg_write(RING_TX_DONE_HEAD, 0x00000000);
367 ixp2000_reg_write(RING_TX_DONE_TAIL, 0x00000000);
368
369 ixp2000_uengine_load(1, &ixp2400_tx);
370 ixp2000_uengine_start_contexts(1, 0xff);
371
372 for (i = 0; i < nds_count; i++) {
373 err = register_netdev(nds[i]);
374 if (err) {
375 while (--i >= 0)
376 unregister_netdev(nds[i]);
377 goto err_free_tx;
378 }
379 }
380
381 for (i = 0; i < nds_count; i++) {
382 printk(KERN_INFO "%s: IXP2000 MSF ethernet (port %d), "
383 "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x.\n", nds[i]->name, i,
384 nds[i]->dev_addr[0], nds[i]->dev_addr[1],
385 nds[i]->dev_addr[2], nds[i]->dev_addr[3],
386 nds[i]->dev_addr[4], nds[i]->dev_addr[5]);
387 }
388
389 return 0;
390
391err_free_tx:
392 for (i = 0; i < TX_BUF_COUNT; i++)
393 free_page((unsigned long)phys_to_virt(tx_desc[i].buf_addr));
394
395err_free_rx:
396 for (i = 0; i < RX_BUF_COUNT; i++)
397 free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr));
398
399err_out:
400 return err;
401}
402
403void ixpdev_deinit(void)
404{
405 int i;
406
407 /* @@@ Flush out pending packets. */
408
409 for (i = 0; i < nds_count; i++)
410 unregister_netdev(nds[i]);
411
412 ixp2000_uengine_stop_contexts(1, 0xff);
413 ixp2000_uengine_stop_contexts(0, 0xff);
414 ixp2000_uengine_reset(0x3);
415
416 for (i = 0; i < TX_BUF_COUNT; i++)
417 free_page((unsigned long)phys_to_virt(tx_desc[i].buf_addr));
418
419 for (i = 0; i < RX_BUF_COUNT; i++)
420 free_page((unsigned long)phys_to_virt(rx_desc[i].buf_addr));
421}
diff --git a/drivers/net/ixp2000/ixpdev.h b/drivers/net/ixp2000/ixpdev.h
new file mode 100644
index 000000000000..bd686cb63058
--- /dev/null
+++ b/drivers/net/ixp2000/ixpdev.h
@@ -0,0 +1,27 @@
1/*
2 * IXP2000 MSF network device driver
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __IXPDEV_H
13#define __IXPDEV_H
14
15struct ixpdev_priv
16{
17 int channel;
18 int tx_queue_entries;
19};
20
21struct net_device *ixpdev_alloc(int channel, int sizeof_priv);
22int ixpdev_init(int num_ports, struct net_device **nds,
23 void (*set_port_admin_status)(int port, int up));
24void ixpdev_deinit(void);
25
26
27#endif
diff --git a/drivers/net/ixp2000/ixpdev_priv.h b/drivers/net/ixp2000/ixpdev_priv.h
new file mode 100644
index 000000000000..86aa08ea0c33
--- /dev/null
+++ b/drivers/net/ixp2000/ixpdev_priv.h
@@ -0,0 +1,57 @@
1/*
2 * IXP2000 MSF network device driver
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __IXPDEV_PRIV_H
13#define __IXPDEV_PRIV_H
14
15#define RX_BUF_DESC_BASE 0x00001000
16#define RX_BUF_COUNT ((3 * PAGE_SIZE) / (4 * sizeof(struct ixpdev_rx_desc)))
17#define TX_BUF_DESC_BASE 0x00002000
18#define TX_BUF_COUNT ((3 * PAGE_SIZE) / (4 * sizeof(struct ixpdev_tx_desc)))
19#define TX_BUF_COUNT_PER_CHAN (TX_BUF_COUNT / 4)
20
21#define RING_RX_PENDING ((u32 *)IXP2000_SCRATCH_RING_VIRT_BASE)
22#define RING_RX_DONE ((u32 *)(IXP2000_SCRATCH_RING_VIRT_BASE + 4))
23#define RING_TX_PENDING ((u32 *)(IXP2000_SCRATCH_RING_VIRT_BASE + 8))
24#define RING_TX_DONE ((u32 *)(IXP2000_SCRATCH_RING_VIRT_BASE + 12))
25
26#define SCRATCH_REG(x) ((u32 *)(IXP2000_GLOBAL_REG_VIRT_BASE | 0x0800 | (x)))
27#define RING_RX_PENDING_BASE SCRATCH_REG(0x00)
28#define RING_RX_PENDING_HEAD SCRATCH_REG(0x04)
29#define RING_RX_PENDING_TAIL SCRATCH_REG(0x08)
30#define RING_RX_DONE_BASE SCRATCH_REG(0x10)
31#define RING_RX_DONE_HEAD SCRATCH_REG(0x14)
32#define RING_RX_DONE_TAIL SCRATCH_REG(0x18)
33#define RING_TX_PENDING_BASE SCRATCH_REG(0x20)
34#define RING_TX_PENDING_HEAD SCRATCH_REG(0x24)
35#define RING_TX_PENDING_TAIL SCRATCH_REG(0x28)
36#define RING_TX_DONE_BASE SCRATCH_REG(0x30)
37#define RING_TX_DONE_HEAD SCRATCH_REG(0x34)
38#define RING_TX_DONE_TAIL SCRATCH_REG(0x38)
39
40struct ixpdev_rx_desc
41{
42 u32 buf_addr;
43 u32 buf_length;
44 u32 channel;
45 u32 pkt_length;
46};
47
48struct ixpdev_tx_desc
49{
50 u32 buf_addr;
51 u32 pkt_length;
52 u32 channel;
53 u32 unused;
54};
55
56
57#endif
diff --git a/drivers/net/ixp2000/pm3386.c b/drivers/net/ixp2000/pm3386.c
new file mode 100644
index 000000000000..5c7ab7564053
--- /dev/null
+++ b/drivers/net/ixp2000/pm3386.c
@@ -0,0 +1,334 @@
1/*
2 * Helper functions for the PM3386s on the Radisys ENP2611
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#include <linux/config.h>
13#include <linux/module.h>
14#include <linux/delay.h>
15#include <linux/netdevice.h>
16#include <asm/io.h>
17#include "pm3386.h"
18
19/*
20 * Read from register 'reg' of PM3386 device 'pm'.
21 */
22static u16 pm3386_reg_read(int pm, int reg)
23{
24 void *_reg;
25 u16 value;
26
27 _reg = (void *)ENP2611_PM3386_0_VIRT_BASE;
28 if (pm == 1)
29 _reg = (void *)ENP2611_PM3386_1_VIRT_BASE;
30
31 value = *((volatile u16 *)(_reg + (reg << 1)));
32
33// printk(KERN_INFO "pm3386_reg_read(%d, %.3x) = %.8x\n", pm, reg, value);
34
35 return value;
36}
37
38/*
39 * Write to register 'reg' of PM3386 device 'pm', and perform
40 * a readback from the identification register.
41 */
42static void pm3386_reg_write(int pm, int reg, u16 value)
43{
44 void *_reg;
45 u16 dummy;
46
47// printk(KERN_INFO "pm3386_reg_write(%d, %.3x, %.8x)\n", pm, reg, value);
48
49 _reg = (void *)ENP2611_PM3386_0_VIRT_BASE;
50 if (pm == 1)
51 _reg = (void *)ENP2611_PM3386_1_VIRT_BASE;
52
53 *((volatile u16 *)(_reg + (reg << 1))) = value;
54
55 dummy = *((volatile u16 *)_reg);
56 __asm__ __volatile__("mov %0, %0" : "+r" (dummy));
57}
58
59/*
60 * Read from port 'port' register 'reg', where the registers
61 * for the different ports are 'spacing' registers apart.
62 */
63static u16 pm3386_port_reg_read(int port, int _reg, int spacing)
64{
65 int reg;
66
67 reg = _reg;
68 if (port & 1)
69 reg += spacing;
70
71 return pm3386_reg_read(port >> 1, reg);
72}
73
74/*
75 * Write to port 'port' register 'reg', where the registers
76 * for the different ports are 'spacing' registers apart.
77 */
78static void pm3386_port_reg_write(int port, int _reg, int spacing, u16 value)
79{
80 int reg;
81
82 reg = _reg;
83 if (port & 1)
84 reg += spacing;
85
86 pm3386_reg_write(port >> 1, reg, value);
87}
88
89
90void pm3386_reset(void)
91{
92 u8 mac[3][6];
93
94 /* Save programmed MAC addresses. */
95 pm3386_get_mac(0, mac[0]);
96 pm3386_get_mac(1, mac[1]);
97 pm3386_get_mac(2, mac[2]);
98
99 /* Assert analog and digital reset. */
100 pm3386_reg_write(0, 0x002, 0x0060);
101 pm3386_reg_write(1, 0x002, 0x0060);
102 mdelay(1);
103
104 /* Deassert analog reset. */
105 pm3386_reg_write(0, 0x002, 0x0062);
106 pm3386_reg_write(1, 0x002, 0x0062);
107 mdelay(10);
108
109 /* Deassert digital reset. */
110 pm3386_reg_write(0, 0x002, 0x0063);
111 pm3386_reg_write(1, 0x002, 0x0063);
112 mdelay(10);
113
114 /* Restore programmed MAC addresses. */
115 pm3386_set_mac(0, mac[0]);
116 pm3386_set_mac(1, mac[1]);
117 pm3386_set_mac(2, mac[2]);
118
119 /* Disable carrier on all ports. */
120 pm3386_set_carrier(0, 0);
121 pm3386_set_carrier(1, 0);
122 pm3386_set_carrier(2, 0);
123}
124
125static u16 swaph(u16 x)
126{
127 return ((x << 8) | (x >> 8)) & 0xffff;
128}
129
130void pm3386_init_port(int port)
131{
132 int pm = port >> 1;
133
134 /*
135 * Work around ENP2611 bootloader programming MAC address
136 * in reverse.
137 */
138 if (pm3386_port_reg_read(port, 0x30a, 0x100) == 0x0000 &&
139 (pm3386_port_reg_read(port, 0x309, 0x100) & 0xff00) == 0x5000) {
140 u16 temp[3];
141
142 temp[0] = pm3386_port_reg_read(port, 0x308, 0x100);
143 temp[1] = pm3386_port_reg_read(port, 0x309, 0x100);
144 temp[2] = pm3386_port_reg_read(port, 0x30a, 0x100);
145 pm3386_port_reg_write(port, 0x308, 0x100, swaph(temp[2]));
146 pm3386_port_reg_write(port, 0x309, 0x100, swaph(temp[1]));
147 pm3386_port_reg_write(port, 0x30a, 0x100, swaph(temp[0]));
148 }
149
150 /*
151 * Initialise narrowbanding mode. See application note 2010486
152 * for more information. (@@@ We also need to issue a reset
153 * when ROOL or DOOL are detected.)
154 */
155 pm3386_port_reg_write(port, 0x708, 0x10, 0xd055);
156 udelay(500);
157 pm3386_port_reg_write(port, 0x708, 0x10, 0x5055);
158
159 /*
160 * SPI-3 ingress block. Set 64 bytes SPI-3 burst size
161 * towards SPI-3 bridge.
162 */
163 pm3386_port_reg_write(port, 0x122, 0x20, 0x0002);
164
165 /*
166 * Enable ingress protocol checking, and soft reset the
167 * SPI-3 ingress block.
168 */
169 pm3386_reg_write(pm, 0x103, 0x0003);
170 while (!(pm3386_reg_read(pm, 0x103) & 0x80))
171 ;
172
173 /*
174 * SPI-3 egress block. Gather 12288 bytes of the current
175 * packet in the TX fifo before initiating transmit on the
176 * SERDES interface. (Prevents TX underflows.)
177 */
178 pm3386_port_reg_write(port, 0x221, 0x20, 0x0007);
179
180 /*
181 * Enforce odd parity from the SPI-3 bridge, and soft reset
182 * the SPI-3 egress block.
183 */
184 pm3386_reg_write(pm, 0x203, 0x000d & ~(4 << (port & 1)));
185 while ((pm3386_reg_read(pm, 0x203) & 0x000c) != 0x000c)
186 ;
187
188 /*
189 * EGMAC block. Set this channels to reject long preambles,
190 * not send or transmit PAUSE frames, enable preamble checking,
191 * disable frame length checking, enable FCS appending, enable
192 * TX frame padding.
193 */
194 pm3386_port_reg_write(port, 0x302, 0x100, 0x0113);
195
196 /*
197 * Soft reset the EGMAC block.
198 */
199 pm3386_port_reg_write(port, 0x301, 0x100, 0x8000);
200 pm3386_port_reg_write(port, 0x301, 0x100, 0x0000);
201
202 /*
203 * Auto-sense autonegotiation status.
204 */
205 pm3386_port_reg_write(port, 0x306, 0x100, 0x0100);
206
207 /*
208 * Allow reception of jumbo frames.
209 */
210 pm3386_port_reg_write(port, 0x310, 0x100, 9018);
211
212 /*
213 * Allow transmission of jumbo frames.
214 */
215 pm3386_port_reg_write(port, 0x336, 0x100, 9018);
216
217 /* @@@ Should set 0x337/0x437 (RX forwarding threshold.) */
218
219 /*
220 * Set autonegotiation parameters to 'no PAUSE, full duplex.'
221 */
222 pm3386_port_reg_write(port, 0x31c, 0x100, 0x0020);
223
224 /*
225 * Enable and restart autonegotiation.
226 */
227 pm3386_port_reg_write(port, 0x318, 0x100, 0x0003);
228 pm3386_port_reg_write(port, 0x318, 0x100, 0x0002);
229}
230
231void pm3386_get_mac(int port, u8 *mac)
232{
233 u16 temp;
234
235 temp = pm3386_port_reg_read(port, 0x308, 0x100);
236 mac[0] = temp & 0xff;
237 mac[1] = (temp >> 8) & 0xff;
238
239 temp = pm3386_port_reg_read(port, 0x309, 0x100);
240 mac[2] = temp & 0xff;
241 mac[3] = (temp >> 8) & 0xff;
242
243 temp = pm3386_port_reg_read(port, 0x30a, 0x100);
244 mac[4] = temp & 0xff;
245 mac[5] = (temp >> 8) & 0xff;
246}
247
248void pm3386_set_mac(int port, u8 *mac)
249{
250 pm3386_port_reg_write(port, 0x308, 0x100, (mac[1] << 8) | mac[0]);
251 pm3386_port_reg_write(port, 0x309, 0x100, (mac[3] << 8) | mac[2]);
252 pm3386_port_reg_write(port, 0x30a, 0x100, (mac[5] << 8) | mac[4]);
253}
254
255static u32 pm3386_get_stat(int port, u16 base)
256{
257 u32 value;
258
259 value = pm3386_port_reg_read(port, base, 0x100);
260 value |= pm3386_port_reg_read(port, base + 1, 0x100) << 16;
261
262 return value;
263}
264
265void pm3386_get_stats(int port, struct net_device_stats *stats)
266{
267 /*
268 * Snapshot statistics counters.
269 */
270 pm3386_port_reg_write(port, 0x500, 0x100, 0x0001);
271 while (pm3386_port_reg_read(port, 0x500, 0x100) & 0x0001)
272 ;
273
274 memset(stats, 0, sizeof(*stats));
275
276 stats->rx_packets = pm3386_get_stat(port, 0x510);
277 stats->tx_packets = pm3386_get_stat(port, 0x590);
278 stats->rx_bytes = pm3386_get_stat(port, 0x514);
279 stats->tx_bytes = pm3386_get_stat(port, 0x594);
280 /* @@@ Add other stats. */
281}
282
283void pm3386_set_carrier(int port, int state)
284{
285 pm3386_port_reg_write(port, 0x703, 0x10, state ? 0x1001 : 0x0000);
286}
287
288int pm3386_is_link_up(int port)
289{
290 u16 temp;
291
292 temp = pm3386_port_reg_read(port, 0x31a, 0x100);
293 temp = pm3386_port_reg_read(port, 0x31a, 0x100);
294
295 return !!(temp & 0x0002);
296}
297
298void pm3386_enable_rx(int port)
299{
300 u16 temp;
301
302 temp = pm3386_port_reg_read(port, 0x303, 0x100);
303 temp |= 0x1000;
304 pm3386_port_reg_write(port, 0x303, 0x100, temp);
305}
306
307void pm3386_disable_rx(int port)
308{
309 u16 temp;
310
311 temp = pm3386_port_reg_read(port, 0x303, 0x100);
312 temp &= 0xefff;
313 pm3386_port_reg_write(port, 0x303, 0x100, temp);
314}
315
316void pm3386_enable_tx(int port)
317{
318 u16 temp;
319
320 temp = pm3386_port_reg_read(port, 0x303, 0x100);
321 temp |= 0x4000;
322 pm3386_port_reg_write(port, 0x303, 0x100, temp);
323}
324
325void pm3386_disable_tx(int port)
326{
327 u16 temp;
328
329 temp = pm3386_port_reg_read(port, 0x303, 0x100);
330 temp &= 0xbfff;
331 pm3386_port_reg_write(port, 0x303, 0x100, temp);
332}
333
334MODULE_LICENSE("GPL");
diff --git a/drivers/net/ixp2000/pm3386.h b/drivers/net/ixp2000/pm3386.h
new file mode 100644
index 000000000000..fe92bb056ac4
--- /dev/null
+++ b/drivers/net/ixp2000/pm3386.h
@@ -0,0 +1,28 @@
1/*
2 * Helper functions for the PM3386s on the Radisys ENP2611
3 * Copyright (C) 2004, 2005 Lennert Buytenhek <buytenh@wantstofly.org>
4 * Dedicated to Marija Kulikova.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __PM3386_H
13#define __PM3386_H
14
15void pm3386_reset(void);
16void pm3386_init_port(int port);
17void pm3386_get_mac(int port, u8 *mac);
18void pm3386_set_mac(int port, u8 *mac);
19void pm3386_get_stats(int port, struct net_device_stats *stats);
20void pm3386_set_carrier(int port, int state);
21int pm3386_is_link_up(int port);
22void pm3386_enable_rx(int port);
23void pm3386_disable_rx(int port);
24void pm3386_enable_tx(int port);
25void pm3386_disable_tx(int port);
26
27
28#endif
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c
index f857ae94d261..b0c3b6ab6263 100644
--- a/drivers/net/ns83820.c
+++ b/drivers/net/ns83820.c
@@ -115,6 +115,7 @@
115#include <linux/ethtool.h> 115#include <linux/ethtool.h>
116#include <linux/timer.h> 116#include <linux/timer.h>
117#include <linux/if_vlan.h> 117#include <linux/if_vlan.h>
118#include <linux/rtnetlink.h>
118 119
119#include <asm/io.h> 120#include <asm/io.h>
120#include <asm/uaccess.h> 121#include <asm/uaccess.h>
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 71fd41122c91..48774efeec71 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -227,8 +227,6 @@ static char mii_preamble_required = 0;
227 227
228static void tc574_config(dev_link_t *link); 228static void tc574_config(dev_link_t *link);
229static void tc574_release(dev_link_t *link); 229static void tc574_release(dev_link_t *link);
230static int tc574_event(event_t event, int priority,
231 event_callback_args_t *args);
232 230
233static void mdio_sync(kio_addr_t ioaddr, int bits); 231static void mdio_sync(kio_addr_t ioaddr, int bits);
234static int mdio_read(kio_addr_t ioaddr, int phy_id, int location); 232static int mdio_read(kio_addr_t ioaddr, int phy_id, int location);
@@ -250,12 +248,7 @@ static int el3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
250static struct ethtool_ops netdev_ethtool_ops; 248static struct ethtool_ops netdev_ethtool_ops;
251static void set_rx_mode(struct net_device *dev); 249static void set_rx_mode(struct net_device *dev);
252 250
253static dev_info_t dev_info = "3c574_cs"; 251static void tc574_detach(struct pcmcia_device *p_dev);
254
255static dev_link_t *tc574_attach(void);
256static void tc574_detach(dev_link_t *);
257
258static dev_link_t *dev_list;
259 252
260/* 253/*
261 tc574_attach() creates an "instance" of the driver, allocating 254 tc574_attach() creates an "instance" of the driver, allocating
@@ -263,20 +256,18 @@ static dev_link_t *dev_list;
263 with Card Services. 256 with Card Services.
264*/ 257*/
265 258
266static dev_link_t *tc574_attach(void) 259static int tc574_attach(struct pcmcia_device *p_dev)
267{ 260{
268 struct el3_private *lp; 261 struct el3_private *lp;
269 client_reg_t client_reg;
270 dev_link_t *link; 262 dev_link_t *link;
271 struct net_device *dev; 263 struct net_device *dev;
272 int ret;
273 264
274 DEBUG(0, "3c574_attach()\n"); 265 DEBUG(0, "3c574_attach()\n");
275 266
276 /* Create the PC card device object. */ 267 /* Create the PC card device object. */
277 dev = alloc_etherdev(sizeof(struct el3_private)); 268 dev = alloc_etherdev(sizeof(struct el3_private));
278 if (!dev) 269 if (!dev)
279 return NULL; 270 return -ENOMEM;
280 lp = netdev_priv(dev); 271 lp = netdev_priv(dev);
281 link = &lp->link; 272 link = &lp->link;
282 link->priv = dev; 273 link->priv = dev;
@@ -307,20 +298,13 @@ static dev_link_t *tc574_attach(void)
307 dev->watchdog_timeo = TX_TIMEOUT; 298 dev->watchdog_timeo = TX_TIMEOUT;
308#endif 299#endif
309 300
310 /* Register with Card Services */ 301 link->handle = p_dev;
311 link->next = dev_list; 302 p_dev->instance = link;
312 dev_list = link;
313 client_reg.dev_info = &dev_info;
314 client_reg.Version = 0x0210;
315 client_reg.event_callback_args.client_data = link;
316 ret = pcmcia_register_client(&link->handle, &client_reg);
317 if (ret != 0) {
318 cs_error(link->handle, RegisterClient, ret);
319 tc574_detach(link);
320 return NULL;
321 }
322 303
323 return link; 304 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
305 tc574_config(link);
306
307 return 0;
324} /* tc574_attach */ 308} /* tc574_attach */
325 309
326/* 310/*
@@ -332,30 +316,19 @@ static dev_link_t *tc574_attach(void)
332 316
333*/ 317*/
334 318
335static void tc574_detach(dev_link_t *link) 319static void tc574_detach(struct pcmcia_device *p_dev)
336{ 320{
321 dev_link_t *link = dev_to_instance(p_dev);
337 struct net_device *dev = link->priv; 322 struct net_device *dev = link->priv;
338 dev_link_t **linkp;
339 323
340 DEBUG(0, "3c574_detach(0x%p)\n", link); 324 DEBUG(0, "3c574_detach(0x%p)\n", link);
341 325
342 /* Locate device structure */
343 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
344 if (*linkp == link) break;
345 if (*linkp == NULL)
346 return;
347
348 if (link->dev) 326 if (link->dev)
349 unregister_netdev(dev); 327 unregister_netdev(dev);
350 328
351 if (link->state & DEV_CONFIG) 329 if (link->state & DEV_CONFIG)
352 tc574_release(link); 330 tc574_release(link);
353 331
354 if (link->handle)
355 pcmcia_deregister_client(link->handle);
356
357 /* Unlink device structure, free bits */
358 *linkp = link->next;
359 free_netdev(dev); 332 free_netdev(dev);
360} /* tc574_detach */ 333} /* tc574_detach */
361 334
@@ -547,56 +520,37 @@ static void tc574_release(dev_link_t *link)
547 link->state &= ~DEV_CONFIG; 520 link->state &= ~DEV_CONFIG;
548} 521}
549 522
550/* 523static int tc574_suspend(struct pcmcia_device *p_dev)
551 The card status event handler. Mostly, this schedules other
552 stuff to run after an event is received. A CARD_REMOVAL event
553 also sets some flags to discourage the net drivers from trying
554 to talk to the card any more.
555*/
556
557static int tc574_event(event_t event, int priority,
558 event_callback_args_t *args)
559{ 524{
560 dev_link_t *link = args->client_data; 525 dev_link_t *link = dev_to_instance(p_dev);
561 struct net_device *dev = link->priv; 526 struct net_device *dev = link->priv;
562 527
563 DEBUG(1, "3c574_event(0x%06x)\n", event); 528 link->state |= DEV_SUSPEND;
564 529 if (link->state & DEV_CONFIG) {
565 switch (event) { 530 if (link->open)
566 case CS_EVENT_CARD_REMOVAL:
567 link->state &= ~DEV_PRESENT;
568 if (link->state & DEV_CONFIG)
569 netif_device_detach(dev); 531 netif_device_detach(dev);
570 break; 532 pcmcia_release_configuration(link->handle);
571 case CS_EVENT_CARD_INSERTION: 533 }
572 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 534
573 tc574_config(link); 535 return 0;
574 break; 536}
575 case CS_EVENT_PM_SUSPEND: 537
576 link->state |= DEV_SUSPEND; 538static int tc574_resume(struct pcmcia_device *p_dev)
577 /* Fall through... */ 539{
578 case CS_EVENT_RESET_PHYSICAL: 540 dev_link_t *link = dev_to_instance(p_dev);
579 if (link->state & DEV_CONFIG) { 541 struct net_device *dev = link->priv;
580 if (link->open) 542
581 netif_device_detach(dev); 543 link->state &= ~DEV_SUSPEND;
582 pcmcia_release_configuration(link->handle); 544 if (link->state & DEV_CONFIG) {
583 } 545 pcmcia_request_configuration(link->handle, &link->conf);
584 break; 546 if (link->open) {
585 case CS_EVENT_PM_RESUME: 547 tc574_reset(dev);
586 link->state &= ~DEV_SUSPEND; 548 netif_device_attach(dev);
587 /* Fall through... */
588 case CS_EVENT_CARD_RESET:
589 if (link->state & DEV_CONFIG) {
590 pcmcia_request_configuration(link->handle, &link->conf);
591 if (link->open) {
592 tc574_reset(dev);
593 netif_device_attach(dev);
594 }
595 } 549 }
596 break;
597 } 550 }
551
598 return 0; 552 return 0;
599} /* tc574_event */ 553}
600 554
601static void dump_status(struct net_device *dev) 555static void dump_status(struct net_device *dev)
602{ 556{
@@ -1292,10 +1246,11 @@ static struct pcmcia_driver tc574_driver = {
1292 .drv = { 1246 .drv = {
1293 .name = "3c574_cs", 1247 .name = "3c574_cs",
1294 }, 1248 },
1295 .attach = tc574_attach, 1249 .probe = tc574_attach,
1296 .event = tc574_event, 1250 .remove = tc574_detach,
1297 .detach = tc574_detach,
1298 .id_table = tc574_ids, 1251 .id_table = tc574_ids,
1252 .suspend = tc574_suspend,
1253 .resume = tc574_resume,
1299}; 1254};
1300 1255
1301static int __init init_tc574(void) 1256static int __init init_tc574(void)
@@ -1306,7 +1261,6 @@ static int __init init_tc574(void)
1306static void __exit exit_tc574(void) 1261static void __exit exit_tc574(void)
1307{ 1262{
1308 pcmcia_unregister_driver(&tc574_driver); 1263 pcmcia_unregister_driver(&tc574_driver);
1309 BUG_ON(dev_list != NULL);
1310} 1264}
1311 1265
1312module_init(init_tc574); 1266module_init(init_tc574);
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index d83fdd8c1943..1c3c9c666f74 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -143,8 +143,6 @@ DRV_NAME ".c " DRV_VERSION " 2001/10/13 00:08:50 (David Hinds)";
143 143
144static void tc589_config(dev_link_t *link); 144static void tc589_config(dev_link_t *link);
145static void tc589_release(dev_link_t *link); 145static void tc589_release(dev_link_t *link);
146static int tc589_event(event_t event, int priority,
147 event_callback_args_t *args);
148 146
149static u16 read_eeprom(kio_addr_t ioaddr, int index); 147static u16 read_eeprom(kio_addr_t ioaddr, int index);
150static void tc589_reset(struct net_device *dev); 148static void tc589_reset(struct net_device *dev);
@@ -161,12 +159,7 @@ static void el3_tx_timeout(struct net_device *dev);
161static void set_multicast_list(struct net_device *dev); 159static void set_multicast_list(struct net_device *dev);
162static struct ethtool_ops netdev_ethtool_ops; 160static struct ethtool_ops netdev_ethtool_ops;
163 161
164static dev_info_t dev_info = "3c589_cs"; 162static void tc589_detach(struct pcmcia_device *p_dev);
165
166static dev_link_t *tc589_attach(void);
167static void tc589_detach(dev_link_t *);
168
169static dev_link_t *dev_list;
170 163
171/*====================================================================== 164/*======================================================================
172 165
@@ -176,20 +169,18 @@ static dev_link_t *dev_list;
176 169
177======================================================================*/ 170======================================================================*/
178 171
179static dev_link_t *tc589_attach(void) 172static int tc589_attach(struct pcmcia_device *p_dev)
180{ 173{
181 struct el3_private *lp; 174 struct el3_private *lp;
182 client_reg_t client_reg;
183 dev_link_t *link; 175 dev_link_t *link;
184 struct net_device *dev; 176 struct net_device *dev;
185 int ret;
186 177
187 DEBUG(0, "3c589_attach()\n"); 178 DEBUG(0, "3c589_attach()\n");
188 179
189 /* Create new ethernet device */ 180 /* Create new ethernet device */
190 dev = alloc_etherdev(sizeof(struct el3_private)); 181 dev = alloc_etherdev(sizeof(struct el3_private));
191 if (!dev) 182 if (!dev)
192 return NULL; 183 return -ENOMEM;
193 lp = netdev_priv(dev); 184 lp = netdev_priv(dev);
194 link = &lp->link; 185 link = &lp->link;
195 link->priv = dev; 186 link->priv = dev;
@@ -206,7 +197,7 @@ static dev_link_t *tc589_attach(void)
206 link->conf.IntType = INT_MEMORY_AND_IO; 197 link->conf.IntType = INT_MEMORY_AND_IO;
207 link->conf.ConfigIndex = 1; 198 link->conf.ConfigIndex = 1;
208 link->conf.Present = PRESENT_OPTION; 199 link->conf.Present = PRESENT_OPTION;
209 200
210 /* The EL3-specific entries in the device structure. */ 201 /* The EL3-specific entries in the device structure. */
211 SET_MODULE_OWNER(dev); 202 SET_MODULE_OWNER(dev);
212 dev->hard_start_xmit = &el3_start_xmit; 203 dev->hard_start_xmit = &el3_start_xmit;
@@ -221,20 +212,13 @@ static dev_link_t *tc589_attach(void)
221#endif 212#endif
222 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 213 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
223 214
224 /* Register with Card Services */ 215 link->handle = p_dev;
225 link->next = dev_list; 216 p_dev->instance = link;
226 dev_list = link; 217
227 client_reg.dev_info = &dev_info; 218 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
228 client_reg.Version = 0x0210; 219 tc589_config(link);
229 client_reg.event_callback_args.client_data = link; 220
230 ret = pcmcia_register_client(&link->handle, &client_reg); 221 return 0;
231 if (ret != 0) {
232 cs_error(link->handle, RegisterClient, ret);
233 tc589_detach(link);
234 return NULL;
235 }
236
237 return link;
238} /* tc589_attach */ 222} /* tc589_attach */
239 223
240/*====================================================================== 224/*======================================================================
@@ -246,30 +230,19 @@ static dev_link_t *tc589_attach(void)
246 230
247======================================================================*/ 231======================================================================*/
248 232
249static void tc589_detach(dev_link_t *link) 233static void tc589_detach(struct pcmcia_device *p_dev)
250{ 234{
235 dev_link_t *link = dev_to_instance(p_dev);
251 struct net_device *dev = link->priv; 236 struct net_device *dev = link->priv;
252 dev_link_t **linkp; 237
253
254 DEBUG(0, "3c589_detach(0x%p)\n", link); 238 DEBUG(0, "3c589_detach(0x%p)\n", link);
255
256 /* Locate device structure */
257 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
258 if (*linkp == link) break;
259 if (*linkp == NULL)
260 return;
261 239
262 if (link->dev) 240 if (link->dev)
263 unregister_netdev(dev); 241 unregister_netdev(dev);
264 242
265 if (link->state & DEV_CONFIG) 243 if (link->state & DEV_CONFIG)
266 tc589_release(link); 244 tc589_release(link);
267 245
268 if (link->handle)
269 pcmcia_deregister_client(link->handle);
270
271 /* Unlink device structure, free bits */
272 *linkp = link->next;
273 free_netdev(dev); 246 free_netdev(dev);
274} /* tc589_detach */ 247} /* tc589_detach */
275 248
@@ -421,58 +394,37 @@ static void tc589_release(dev_link_t *link)
421 link->state &= ~DEV_CONFIG; 394 link->state &= ~DEV_CONFIG;
422} 395}
423 396
424/*====================================================================== 397static int tc589_suspend(struct pcmcia_device *p_dev)
425
426 The card status event handler. Mostly, this schedules other
427 stuff to run after an event is received. A CARD_REMOVAL event
428 also sets some flags to discourage the net drivers from trying
429 to talk to the card any more.
430
431======================================================================*/
432
433static int tc589_event(event_t event, int priority,
434 event_callback_args_t *args)
435{ 398{
436 dev_link_t *link = args->client_data; 399 dev_link_t *link = dev_to_instance(p_dev);
437 struct net_device *dev = link->priv; 400 struct net_device *dev = link->priv;
438 401
439 DEBUG(1, "3c589_event(0x%06x)\n", event);
440
441 switch (event) {
442 case CS_EVENT_CARD_REMOVAL:
443 link->state &= ~DEV_PRESENT;
444 if (link->state & DEV_CONFIG)
445 netif_device_detach(dev);
446 break;
447 case CS_EVENT_CARD_INSERTION:
448 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
449 tc589_config(link);
450 break;
451 case CS_EVENT_PM_SUSPEND:
452 link->state |= DEV_SUSPEND; 402 link->state |= DEV_SUSPEND;
453 /* Fall through... */
454 case CS_EVENT_RESET_PHYSICAL:
455 if (link->state & DEV_CONFIG) { 403 if (link->state & DEV_CONFIG) {
456 if (link->open) 404 if (link->open)
457 netif_device_detach(dev); 405 netif_device_detach(dev);
458 pcmcia_release_configuration(link->handle); 406 pcmcia_release_configuration(link->handle);
459 } 407 }
460 break; 408
461 case CS_EVENT_PM_RESUME: 409 return 0;
410}
411
412static int tc589_resume(struct pcmcia_device *p_dev)
413{
414 dev_link_t *link = dev_to_instance(p_dev);
415 struct net_device *dev = link->priv;
416
462 link->state &= ~DEV_SUSPEND; 417 link->state &= ~DEV_SUSPEND;
463 /* Fall through... */
464 case CS_EVENT_CARD_RESET:
465 if (link->state & DEV_CONFIG) { 418 if (link->state & DEV_CONFIG) {
466 pcmcia_request_configuration(link->handle, &link->conf); 419 pcmcia_request_configuration(link->handle, &link->conf);
467 if (link->open) { 420 if (link->open) {
468 tc589_reset(dev); 421 tc589_reset(dev);
469 netif_device_attach(dev); 422 netif_device_attach(dev);
470 } 423 }
471 } 424 }
472 break; 425
473 } 426 return 0;
474 return 0; 427}
475} /* tc589_event */
476 428
477/*====================================================================*/ 429/*====================================================================*/
478 430
@@ -1067,10 +1019,11 @@ static struct pcmcia_driver tc589_driver = {
1067 .drv = { 1019 .drv = {
1068 .name = "3c589_cs", 1020 .name = "3c589_cs",
1069 }, 1021 },
1070 .attach = tc589_attach, 1022 .probe = tc589_attach,
1071 .event = tc589_event, 1023 .remove = tc589_detach,
1072 .detach = tc589_detach,
1073 .id_table = tc589_ids, 1024 .id_table = tc589_ids,
1025 .suspend = tc589_suspend,
1026 .resume = tc589_resume,
1074}; 1027};
1075 1028
1076static int __init init_tc589(void) 1029static int __init init_tc589(void)
@@ -1081,7 +1034,6 @@ static int __init init_tc589(void)
1081static void __exit exit_tc589(void) 1034static void __exit exit_tc589(void)
1082{ 1035{
1083 pcmcia_unregister_driver(&tc589_driver); 1036 pcmcia_unregister_driver(&tc589_driver);
1084 BUG_ON(dev_list != NULL);
1085} 1037}
1086 1038
1087module_init(init_tc589); 1039module_init(init_tc589);
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 8bb4e85689ea..01ddfc8cce3f 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -87,8 +87,6 @@ static char *version =
87 87
88static void axnet_config(dev_link_t *link); 88static void axnet_config(dev_link_t *link);
89static void axnet_release(dev_link_t *link); 89static void axnet_release(dev_link_t *link);
90static int axnet_event(event_t event, int priority,
91 event_callback_args_t *args);
92static int axnet_open(struct net_device *dev); 90static int axnet_open(struct net_device *dev);
93static int axnet_close(struct net_device *dev); 91static int axnet_close(struct net_device *dev);
94static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 92static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -107,11 +105,7 @@ static void block_input(struct net_device *dev, int count,
107static void block_output(struct net_device *dev, int count, 105static void block_output(struct net_device *dev, int count,
108 const u_char *buf, const int start_page); 106 const u_char *buf, const int start_page);
109 107
110static dev_link_t *axnet_attach(void); 108static void axnet_detach(struct pcmcia_device *p_dev);
111static void axnet_detach(dev_link_t *);
112
113static dev_info_t dev_info = "axnet_cs";
114static dev_link_t *dev_list;
115 109
116static void axdev_setup(struct net_device *dev); 110static void axdev_setup(struct net_device *dev);
117static void AX88190_init(struct net_device *dev, int startp); 111static void AX88190_init(struct net_device *dev, int startp);
@@ -147,13 +141,11 @@ static inline axnet_dev_t *PRIV(struct net_device *dev)
147 141
148======================================================================*/ 142======================================================================*/
149 143
150static dev_link_t *axnet_attach(void) 144static int axnet_attach(struct pcmcia_device *p_dev)
151{ 145{
152 axnet_dev_t *info; 146 axnet_dev_t *info;
153 dev_link_t *link; 147 dev_link_t *link;
154 struct net_device *dev; 148 struct net_device *dev;
155 client_reg_t client_reg;
156 int ret;
157 149
158 DEBUG(0, "axnet_attach()\n"); 150 DEBUG(0, "axnet_attach()\n");
159 151
@@ -161,7 +153,7 @@ static dev_link_t *axnet_attach(void)
161 "eth%d", axdev_setup); 153 "eth%d", axdev_setup);
162 154
163 if (!dev) 155 if (!dev)
164 return NULL; 156 return -ENOMEM;
165 157
166 info = PRIV(dev); 158 info = PRIV(dev);
167 link = &info->link; 159 link = &info->link;
@@ -176,20 +168,13 @@ static dev_link_t *axnet_attach(void)
176 dev->do_ioctl = &axnet_ioctl; 168 dev->do_ioctl = &axnet_ioctl;
177 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 169 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
178 170
179 /* Register with Card Services */ 171 link->handle = p_dev;
180 link->next = dev_list; 172 p_dev->instance = link;
181 dev_list = link;
182 client_reg.dev_info = &dev_info;
183 client_reg.Version = 0x0210;
184 client_reg.event_callback_args.client_data = link;
185 ret = pcmcia_register_client(&link->handle, &client_reg);
186 if (ret != CS_SUCCESS) {
187 cs_error(link->handle, RegisterClient, ret);
188 axnet_detach(link);
189 return NULL;
190 }
191 173
192 return link; 174 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
175 axnet_config(link);
176
177 return 0;
193} /* axnet_attach */ 178} /* axnet_attach */
194 179
195/*====================================================================== 180/*======================================================================
@@ -201,30 +186,19 @@ static dev_link_t *axnet_attach(void)
201 186
202======================================================================*/ 187======================================================================*/
203 188
204static void axnet_detach(dev_link_t *link) 189static void axnet_detach(struct pcmcia_device *p_dev)
205{ 190{
191 dev_link_t *link = dev_to_instance(p_dev);
206 struct net_device *dev = link->priv; 192 struct net_device *dev = link->priv;
207 dev_link_t **linkp;
208 193
209 DEBUG(0, "axnet_detach(0x%p)\n", link); 194 DEBUG(0, "axnet_detach(0x%p)\n", link);
210 195
211 /* Locate device structure */
212 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
213 if (*linkp == link) break;
214 if (*linkp == NULL)
215 return;
216
217 if (link->dev) 196 if (link->dev)
218 unregister_netdev(dev); 197 unregister_netdev(dev);
219 198
220 if (link->state & DEV_CONFIG) 199 if (link->state & DEV_CONFIG)
221 axnet_release(link); 200 axnet_release(link);
222 201
223 if (link->handle)
224 pcmcia_deregister_client(link->handle);
225
226 /* Unlink device structure, free bits */
227 *linkp = link->next;
228 free_netdev(dev); 202 free_netdev(dev);
229} /* axnet_detach */ 203} /* axnet_detach */
230 204
@@ -490,59 +464,39 @@ static void axnet_release(dev_link_t *link)
490 link->state &= ~DEV_CONFIG; 464 link->state &= ~DEV_CONFIG;
491} 465}
492 466
493/*====================================================================== 467static int axnet_suspend(struct pcmcia_device *p_dev)
494
495 The card status event handler. Mostly, this schedules other
496 stuff to run after an event is received. A CARD_REMOVAL event
497 also sets some flags to discourage the net drivers from trying
498 to talk to the card any more.
499
500======================================================================*/
501
502static int axnet_event(event_t event, int priority,
503 event_callback_args_t *args)
504{ 468{
505 dev_link_t *link = args->client_data; 469 dev_link_t *link = dev_to_instance(p_dev);
506 struct net_device *dev = link->priv; 470 struct net_device *dev = link->priv;
507 471
508 DEBUG(2, "axnet_event(0x%06x)\n", event);
509
510 switch (event) {
511 case CS_EVENT_CARD_REMOVAL:
512 link->state &= ~DEV_PRESENT;
513 if (link->state & DEV_CONFIG)
514 netif_device_detach(dev);
515 break;
516 case CS_EVENT_CARD_INSERTION:
517 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
518 axnet_config(link);
519 break;
520 case CS_EVENT_PM_SUSPEND:
521 link->state |= DEV_SUSPEND; 472 link->state |= DEV_SUSPEND;
522 /* Fall through... */
523 case CS_EVENT_RESET_PHYSICAL:
524 if (link->state & DEV_CONFIG) { 473 if (link->state & DEV_CONFIG) {
525 if (link->open) 474 if (link->open)
526 netif_device_detach(dev); 475 netif_device_detach(dev);
527 pcmcia_release_configuration(link->handle); 476 pcmcia_release_configuration(link->handle);
528 } 477 }
529 break; 478
530 case CS_EVENT_PM_RESUME: 479 return 0;
480}
481
482static int axnet_resume(struct pcmcia_device *p_dev)
483{
484 dev_link_t *link = dev_to_instance(p_dev);
485 struct net_device *dev = link->priv;
486
531 link->state &= ~DEV_SUSPEND; 487 link->state &= ~DEV_SUSPEND;
532 /* Fall through... */
533 case CS_EVENT_CARD_RESET:
534 if (link->state & DEV_CONFIG) { 488 if (link->state & DEV_CONFIG) {
535 pcmcia_request_configuration(link->handle, &link->conf); 489 pcmcia_request_configuration(link->handle, &link->conf);
536 if (link->open) { 490 if (link->open) {
537 axnet_reset_8390(dev); 491 axnet_reset_8390(dev);
538 AX88190_init(dev, 1); 492 AX88190_init(dev, 1);
539 netif_device_attach(dev); 493 netif_device_attach(dev);
540 } 494 }
541 } 495 }
542 break; 496
543 } 497 return 0;
544 return 0; 498}
545} /* axnet_event */ 499
546 500
547/*====================================================================== 501/*======================================================================
548 502
@@ -616,7 +570,7 @@ static int axnet_open(struct net_device *dev)
616 570
617 link->open++; 571 link->open++;
618 572
619 request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, dev_info, dev); 573 request_irq(dev->irq, ei_irq_wrapper, SA_SHIRQ, "axnet_cs", dev);
620 574
621 info->link_status = 0x00; 575 info->link_status = 0x00;
622 init_timer(&info->watchdog); 576 init_timer(&info->watchdog);
@@ -877,10 +831,11 @@ static struct pcmcia_driver axnet_cs_driver = {
877 .drv = { 831 .drv = {
878 .name = "axnet_cs", 832 .name = "axnet_cs",
879 }, 833 },
880 .attach = axnet_attach, 834 .probe = axnet_attach,
881 .event = axnet_event, 835 .remove = axnet_detach,
882 .detach = axnet_detach,
883 .id_table = axnet_ids, 836 .id_table = axnet_ids,
837 .suspend = axnet_suspend,
838 .resume = axnet_resume,
884}; 839};
885 840
886static int __init init_axnet_cs(void) 841static int __init init_axnet_cs(void)
@@ -891,7 +846,6 @@ static int __init init_axnet_cs(void)
891static void __exit exit_axnet_cs(void) 846static void __exit exit_axnet_cs(void)
892{ 847{
893 pcmcia_unregister_driver(&axnet_cs_driver); 848 pcmcia_unregister_driver(&axnet_cs_driver);
894 BUG_ON(dev_list != NULL);
895} 849}
896 850
897module_init(init_axnet_cs); 851module_init(init_axnet_cs);
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index b9355d9498a3..2827a48ea37c 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -120,15 +120,8 @@ MODULE_LICENSE("GPL");
120 120
121static void com20020_config(dev_link_t *link); 121static void com20020_config(dev_link_t *link);
122static void com20020_release(dev_link_t *link); 122static void com20020_release(dev_link_t *link);
123static int com20020_event(event_t event, int priority,
124 event_callback_args_t *args);
125 123
126static dev_info_t dev_info = "com20020_cs"; 124static void com20020_detach(struct pcmcia_device *p_dev);
127
128static dev_link_t *com20020_attach(void);
129static void com20020_detach(dev_link_t *);
130
131static dev_link_t *dev_list;
132 125
133/*====================================================================*/ 126/*====================================================================*/
134 127
@@ -145,21 +138,19 @@ typedef struct com20020_dev_t {
145 138
146======================================================================*/ 139======================================================================*/
147 140
148static dev_link_t *com20020_attach(void) 141static int com20020_attach(struct pcmcia_device *p_dev)
149{ 142{
150 client_reg_t client_reg;
151 dev_link_t *link; 143 dev_link_t *link;
152 com20020_dev_t *info; 144 com20020_dev_t *info;
153 struct net_device *dev; 145 struct net_device *dev;
154 int ret;
155 struct arcnet_local *lp; 146 struct arcnet_local *lp;
156 147
157 DEBUG(0, "com20020_attach()\n"); 148 DEBUG(0, "com20020_attach()\n");
158 149
159 /* Create new network device */ 150 /* Create new network device */
160 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 151 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
161 if (!link) 152 if (!link)
162 return NULL; 153 return -ENOMEM;
163 154
164 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); 155 info = kmalloc(sizeof(struct com20020_dev_t), GFP_KERNEL);
165 if (!info) 156 if (!info)
@@ -191,30 +182,19 @@ static dev_link_t *com20020_attach(void)
191 link->conf.IntType = INT_MEMORY_AND_IO; 182 link->conf.IntType = INT_MEMORY_AND_IO;
192 link->conf.Present = PRESENT_OPTION; 183 link->conf.Present = PRESENT_OPTION;
193 184
194
195 link->irq.Instance = info->dev = dev; 185 link->irq.Instance = info->dev = dev;
196 link->priv = info; 186 link->priv = info;
197 187
198 /* Register with Card Services */ 188 link->state |= DEV_PRESENT;
199 link->next = dev_list; 189 com20020_config(link);
200 dev_list = link;
201 client_reg.dev_info = &dev_info;
202 client_reg.Version = 0x0210;
203 client_reg.event_callback_args.client_data = link;
204 ret = pcmcia_register_client(&link->handle, &client_reg);
205 if (ret != 0) {
206 cs_error(link->handle, RegisterClient, ret);
207 com20020_detach(link);
208 return NULL;
209 }
210 190
211 return link; 191 return 0;
212 192
213fail_alloc_dev: 193fail_alloc_dev:
214 kfree(info); 194 kfree(info);
215fail_alloc_info: 195fail_alloc_info:
216 kfree(link); 196 kfree(link);
217 return NULL; 197 return -ENOMEM;
218} /* com20020_attach */ 198} /* com20020_attach */
219 199
220/*====================================================================== 200/*======================================================================
@@ -226,29 +206,21 @@ fail_alloc_info:
226 206
227======================================================================*/ 207======================================================================*/
228 208
229static void com20020_detach(dev_link_t *link) 209static void com20020_detach(struct pcmcia_device *p_dev)
230{ 210{
211 dev_link_t *link = dev_to_instance(p_dev);
231 struct com20020_dev_t *info = link->priv; 212 struct com20020_dev_t *info = link->priv;
232 dev_link_t **linkp; 213 struct net_device *dev = info->dev;
233 struct net_device *dev; 214
234
235 DEBUG(1,"detach...\n"); 215 DEBUG(1,"detach...\n");
236 216
237 DEBUG(0, "com20020_detach(0x%p)\n", link); 217 DEBUG(0, "com20020_detach(0x%p)\n", link);
238 218
239 /* Locate device structure */
240 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
241 if (*linkp == link) break;
242 if (*linkp == NULL)
243 return;
244
245 dev = info->dev;
246
247 if (link->dev) { 219 if (link->dev) {
248 DEBUG(1,"unregister...\n"); 220 DEBUG(1,"unregister...\n");
249 221
250 unregister_netdev(dev); 222 unregister_netdev(dev);
251 223
252 /* 224 /*
253 * this is necessary because we register our IRQ separately 225 * this is necessary because we register our IRQ separately
254 * from card services. 226 * from card services.
@@ -260,12 +232,8 @@ static void com20020_detach(dev_link_t *link)
260 if (link->state & DEV_CONFIG) 232 if (link->state & DEV_CONFIG)
261 com20020_release(link); 233 com20020_release(link);
262 234
263 if (link->handle)
264 pcmcia_deregister_client(link->handle);
265
266 /* Unlink device structure, free bits */ 235 /* Unlink device structure, free bits */
267 DEBUG(1,"unlinking...\n"); 236 DEBUG(1,"unlinking...\n");
268 *linkp = link->next;
269 if (link->priv) 237 if (link->priv)
270 { 238 {
271 dev = info->dev; 239 dev = info->dev;
@@ -421,61 +389,41 @@ static void com20020_release(dev_link_t *link)
421 link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING); 389 link->state &= ~(DEV_CONFIG | DEV_RELEASE_PENDING);
422} 390}
423 391
424/*====================================================================== 392static int com20020_suspend(struct pcmcia_device *p_dev)
393{
394 dev_link_t *link = dev_to_instance(p_dev);
395 com20020_dev_t *info = link->priv;
396 struct net_device *dev = info->dev;
425 397
426 The card status event handler. Mostly, this schedules other 398 link->state |= DEV_SUSPEND;
427 stuff to run after an event is received. A CARD_REMOVAL event 399 if (link->state & DEV_CONFIG) {
428 also sets some flags to discourage the net drivers from trying 400 if (link->open) {
429 to talk to the card any more. 401 netif_device_detach(dev);
402 }
403 pcmcia_release_configuration(link->handle);
404 }
430 405
431======================================================================*/ 406 return 0;
407}
432 408
433static int com20020_event(event_t event, int priority, 409static int com20020_resume(struct pcmcia_device *p_dev)
434 event_callback_args_t *args)
435{ 410{
436 dev_link_t *link = args->client_data; 411 dev_link_t *link = dev_to_instance(p_dev);
437 com20020_dev_t *info = link->priv; 412 com20020_dev_t *info = link->priv;
438 struct net_device *dev = info->dev; 413 struct net_device *dev = info->dev;
439 414
440 DEBUG(1, "com20020_event(0x%06x)\n", event); 415 link->state &= ~DEV_SUSPEND;
441
442 switch (event) {
443 case CS_EVENT_CARD_REMOVAL:
444 link->state &= ~DEV_PRESENT;
445 if (link->state & DEV_CONFIG)
446 netif_device_detach(dev);
447 break;
448 case CS_EVENT_CARD_INSERTION:
449 link->state |= DEV_PRESENT;
450 com20020_config(link);
451 break;
452 case CS_EVENT_PM_SUSPEND:
453 link->state |= DEV_SUSPEND;
454 /* Fall through... */
455 case CS_EVENT_RESET_PHYSICAL:
456 if (link->state & DEV_CONFIG) {
457 if (link->open) {
458 netif_device_detach(dev);
459 }
460 pcmcia_release_configuration(link->handle);
461 }
462 break;
463 case CS_EVENT_PM_RESUME:
464 link->state &= ~DEV_SUSPEND;
465 /* Fall through... */
466 case CS_EVENT_CARD_RESET:
467 if (link->state & DEV_CONFIG) { 416 if (link->state & DEV_CONFIG) {
468 pcmcia_request_configuration(link->handle, &link->conf); 417 pcmcia_request_configuration(link->handle, &link->conf);
469 if (link->open) { 418 if (link->open) {
470 int ioaddr = dev->base_addr; 419 int ioaddr = dev->base_addr;
471 struct arcnet_local *lp = dev->priv; 420 struct arcnet_local *lp = dev->priv;
472 ARCRESET; 421 ARCRESET;
473 } 422 }
474 } 423 }
475 break; 424
476 } 425 return 0;
477 return 0; 426}
478} /* com20020_event */
479 427
480static struct pcmcia_device_id com20020_ids[] = { 428static struct pcmcia_device_id com20020_ids[] = {
481 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf), 429 PCMCIA_DEVICE_PROD_ID12("Contemporary Control Systems, Inc.", "PCM20 Arcnet Adapter", 0x59991666, 0x95dfffaf),
@@ -488,10 +436,11 @@ static struct pcmcia_driver com20020_cs_driver = {
488 .drv = { 436 .drv = {
489 .name = "com20020_cs", 437 .name = "com20020_cs",
490 }, 438 },
491 .attach = com20020_attach, 439 .probe = com20020_attach,
492 .event = com20020_event, 440 .remove = com20020_detach,
493 .detach = com20020_detach,
494 .id_table = com20020_ids, 441 .id_table = com20020_ids,
442 .suspend = com20020_suspend,
443 .resume = com20020_resume,
495}; 444};
496 445
497static int __init init_com20020_cs(void) 446static int __init init_com20020_cs(void)
@@ -502,7 +451,6 @@ static int __init init_com20020_cs(void)
502static void __exit exit_com20020_cs(void) 451static void __exit exit_com20020_cs(void)
503{ 452{
504 pcmcia_unregister_driver(&com20020_cs_driver); 453 pcmcia_unregister_driver(&com20020_cs_driver);
505 BUG_ON(dev_list != NULL);
506} 454}
507 455
508module_init(init_com20020_cs); 456module_init(init_com20020_cs);
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 356f50909222..28fe2fb4d6c0 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -88,10 +88,7 @@ static void fmvj18x_config(dev_link_t *link);
88static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id); 88static int fmvj18x_get_hwinfo(dev_link_t *link, u_char *node_id);
89static int fmvj18x_setup_mfc(dev_link_t *link); 89static int fmvj18x_setup_mfc(dev_link_t *link);
90static void fmvj18x_release(dev_link_t *link); 90static void fmvj18x_release(dev_link_t *link);
91static int fmvj18x_event(event_t event, int priority, 91static void fmvj18x_detach(struct pcmcia_device *p_dev);
92 event_callback_args_t *args);
93static dev_link_t *fmvj18x_attach(void);
94static void fmvj18x_detach(dev_link_t *);
95 92
96/* 93/*
97 LAN controller(MBH86960A) specific routines 94 LAN controller(MBH86960A) specific routines
@@ -108,9 +105,6 @@ static void set_rx_mode(struct net_device *dev);
108static void fjn_tx_timeout(struct net_device *dev); 105static void fjn_tx_timeout(struct net_device *dev);
109static struct ethtool_ops netdev_ethtool_ops; 106static struct ethtool_ops netdev_ethtool_ops;
110 107
111static dev_info_t dev_info = "fmvj18x_cs";
112static dev_link_t *dev_list;
113
114/* 108/*
115 card type 109 card type
116 */ 110 */
@@ -234,20 +228,18 @@ typedef struct local_info_t {
234#define BANK_1U 0x24 /* bank 1 (CONFIG_1) */ 228#define BANK_1U 0x24 /* bank 1 (CONFIG_1) */
235#define BANK_2U 0x28 /* bank 2 (CONFIG_1) */ 229#define BANK_2U 0x28 /* bank 2 (CONFIG_1) */
236 230
237static dev_link_t *fmvj18x_attach(void) 231static int fmvj18x_attach(struct pcmcia_device *p_dev)
238{ 232{
239 local_info_t *lp; 233 local_info_t *lp;
240 dev_link_t *link; 234 dev_link_t *link;
241 struct net_device *dev; 235 struct net_device *dev;
242 client_reg_t client_reg; 236
243 int ret;
244
245 DEBUG(0, "fmvj18x_attach()\n"); 237 DEBUG(0, "fmvj18x_attach()\n");
246 238
247 /* Make up a FMVJ18x specific data structure */ 239 /* Make up a FMVJ18x specific data structure */
248 dev = alloc_etherdev(sizeof(local_info_t)); 240 dev = alloc_etherdev(sizeof(local_info_t));
249 if (!dev) 241 if (!dev)
250 return NULL; 242 return -ENOMEM;
251 lp = netdev_priv(dev); 243 lp = netdev_priv(dev);
252 link = &lp->link; 244 link = &lp->link;
253 link->priv = dev; 245 link->priv = dev;
@@ -262,7 +254,7 @@ static dev_link_t *fmvj18x_attach(void)
262 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 254 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
263 link->irq.Handler = &fjn_interrupt; 255 link->irq.Handler = &fjn_interrupt;
264 link->irq.Instance = dev; 256 link->irq.Instance = dev;
265 257
266 /* General socket configuration */ 258 /* General socket configuration */
267 link->conf.Attributes = CONF_ENABLE_IRQ; 259 link->conf.Attributes = CONF_ENABLE_IRQ;
268 link->conf.Vcc = 50; 260 link->conf.Vcc = 50;
@@ -281,37 +273,24 @@ static dev_link_t *fmvj18x_attach(void)
281 dev->watchdog_timeo = TX_TIMEOUT; 273 dev->watchdog_timeo = TX_TIMEOUT;
282#endif 274#endif
283 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 275 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
284
285 /* Register with Card Services */
286 link->next = dev_list;
287 dev_list = link;
288 client_reg.dev_info = &dev_info;
289 client_reg.Version = 0x0210;
290 client_reg.event_callback_args.client_data = link;
291 ret = pcmcia_register_client(&link->handle, &client_reg);
292 if (ret != 0) {
293 cs_error(link->handle, RegisterClient, ret);
294 fmvj18x_detach(link);
295 return NULL;
296 }
297 276
298 return link; 277 link->handle = p_dev;
278 p_dev->instance = link;
279
280 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
281 fmvj18x_config(link);
282
283 return 0;
299} /* fmvj18x_attach */ 284} /* fmvj18x_attach */
300 285
301/*====================================================================*/ 286/*====================================================================*/
302 287
303static void fmvj18x_detach(dev_link_t *link) 288static void fmvj18x_detach(struct pcmcia_device *p_dev)
304{ 289{
290 dev_link_t *link = dev_to_instance(p_dev);
305 struct net_device *dev = link->priv; 291 struct net_device *dev = link->priv;
306 dev_link_t **linkp; 292
307
308 DEBUG(0, "fmvj18x_detach(0x%p)\n", link); 293 DEBUG(0, "fmvj18x_detach(0x%p)\n", link);
309
310 /* Locate device structure */
311 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
312 if (*linkp == link) break;
313 if (*linkp == NULL)
314 return;
315 294
316 if (link->dev) 295 if (link->dev)
317 unregister_netdev(dev); 296 unregister_netdev(dev);
@@ -319,12 +298,6 @@ static void fmvj18x_detach(dev_link_t *link)
319 if (link->state & DEV_CONFIG) 298 if (link->state & DEV_CONFIG)
320 fmvj18x_release(link); 299 fmvj18x_release(link);
321 300
322 /* Break the link with Card Services */
323 if (link->handle)
324 pcmcia_deregister_client(link->handle);
325
326 /* Unlink device structure, free pieces */
327 *linkp = link->next;
328 free_netdev(dev); 301 free_netdev(dev);
329} /* fmvj18x_detach */ 302} /* fmvj18x_detach */
330 303
@@ -713,51 +686,40 @@ static void fmvj18x_release(dev_link_t *link)
713 link->state &= ~DEV_CONFIG; 686 link->state &= ~DEV_CONFIG;
714} 687}
715 688
716/*====================================================================*/ 689static int fmvj18x_suspend(struct pcmcia_device *p_dev)
717
718static int fmvj18x_event(event_t event, int priority,
719 event_callback_args_t *args)
720{ 690{
721 dev_link_t *link = args->client_data; 691 dev_link_t *link = dev_to_instance(p_dev);
722 struct net_device *dev = link->priv; 692 struct net_device *dev = link->priv;
723 693
724 DEBUG(1, "fmvj18x_event(0x%06x)\n", event);
725
726 switch (event) {
727 case CS_EVENT_CARD_REMOVAL:
728 link->state &= ~DEV_PRESENT;
729 if (link->state & DEV_CONFIG)
730 netif_device_detach(dev);
731 break;
732 case CS_EVENT_CARD_INSERTION:
733 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
734 fmvj18x_config(link);
735 break;
736 case CS_EVENT_PM_SUSPEND:
737 link->state |= DEV_SUSPEND; 694 link->state |= DEV_SUSPEND;
738 /* Fall through... */
739 case CS_EVENT_RESET_PHYSICAL:
740 if (link->state & DEV_CONFIG) { 695 if (link->state & DEV_CONFIG) {
741 if (link->open) 696 if (link->open)
742 netif_device_detach(dev); 697 netif_device_detach(dev);
743 pcmcia_release_configuration(link->handle); 698 pcmcia_release_configuration(link->handle);
744 } 699 }
745 break; 700
746 case CS_EVENT_PM_RESUME: 701
702 return 0;
703}
704
705static int fmvj18x_resume(struct pcmcia_device *p_dev)
706{
707 dev_link_t *link = dev_to_instance(p_dev);
708 struct net_device *dev = link->priv;
709
747 link->state &= ~DEV_SUSPEND; 710 link->state &= ~DEV_SUSPEND;
748 /* Fall through... */
749 case CS_EVENT_CARD_RESET:
750 if (link->state & DEV_CONFIG) { 711 if (link->state & DEV_CONFIG) {
751 pcmcia_request_configuration(link->handle, &link->conf); 712 pcmcia_request_configuration(link->handle, &link->conf);
752 if (link->open) { 713 if (link->open) {
753 fjn_reset(dev); 714 fjn_reset(dev);
754 netif_device_attach(dev); 715 netif_device_attach(dev);
755 } 716 }
756 } 717 }
757 break; 718
758 } 719 return 0;
759 return 0; 720}
760} /* fmvj18x_event */ 721
722/*====================================================================*/
761 723
762static struct pcmcia_device_id fmvj18x_ids[] = { 724static struct pcmcia_device_id fmvj18x_ids[] = {
763 PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004), 725 PCMCIA_DEVICE_MANF_CARD(0x0004, 0x0004),
@@ -789,10 +751,11 @@ static struct pcmcia_driver fmvj18x_cs_driver = {
789 .drv = { 751 .drv = {
790 .name = "fmvj18x_cs", 752 .name = "fmvj18x_cs",
791 }, 753 },
792 .attach = fmvj18x_attach, 754 .probe = fmvj18x_attach,
793 .event = fmvj18x_event, 755 .remove = fmvj18x_detach,
794 .detach = fmvj18x_detach,
795 .id_table = fmvj18x_ids, 756 .id_table = fmvj18x_ids,
757 .suspend = fmvj18x_suspend,
758 .resume = fmvj18x_resume,
796}; 759};
797 760
798static int __init init_fmvj18x_cs(void) 761static int __init init_fmvj18x_cs(void)
@@ -803,7 +766,6 @@ static int __init init_fmvj18x_cs(void)
803static void __exit exit_fmvj18x_cs(void) 766static void __exit exit_fmvj18x_cs(void)
804{ 767{
805 pcmcia_unregister_driver(&fmvj18x_cs_driver); 768 pcmcia_unregister_driver(&fmvj18x_cs_driver);
806 BUG_ON(dev_list != NULL);
807} 769}
808 770
809module_init(init_fmvj18x_cs); 771module_init(init_fmvj18x_cs);
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index b6c140eb9799..b9c7e39576f5 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -108,15 +108,7 @@ MODULE_LICENSE("GPL");
108static void ibmtr_config(dev_link_t *link); 108static void ibmtr_config(dev_link_t *link);
109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase); 109static void ibmtr_hw_setup(struct net_device *dev, u_int mmiobase);
110static void ibmtr_release(dev_link_t *link); 110static void ibmtr_release(dev_link_t *link);
111static int ibmtr_event(event_t event, int priority, 111static void ibmtr_detach(struct pcmcia_device *p_dev);
112 event_callback_args_t *args);
113
114static dev_info_t dev_info = "ibmtr_cs";
115
116static dev_link_t *ibmtr_attach(void);
117static void ibmtr_detach(dev_link_t *);
118
119static dev_link_t *dev_list;
120 112
121/*====================================================================*/ 113/*====================================================================*/
122 114
@@ -146,25 +138,23 @@ static struct ethtool_ops netdev_ethtool_ops = {
146 138
147======================================================================*/ 139======================================================================*/
148 140
149static dev_link_t *ibmtr_attach(void) 141static int ibmtr_attach(struct pcmcia_device *p_dev)
150{ 142{
151 ibmtr_dev_t *info; 143 ibmtr_dev_t *info;
152 dev_link_t *link; 144 dev_link_t *link;
153 struct net_device *dev; 145 struct net_device *dev;
154 client_reg_t client_reg;
155 int ret;
156 146
157 DEBUG(0, "ibmtr_attach()\n"); 147 DEBUG(0, "ibmtr_attach()\n");
158 148
159 /* Create new token-ring device */ 149 /* Create new token-ring device */
160 info = kmalloc(sizeof(*info), GFP_KERNEL); 150 info = kmalloc(sizeof(*info), GFP_KERNEL);
161 if (!info) return NULL; 151 if (!info) return -ENOMEM;
162 memset(info,0,sizeof(*info)); 152 memset(info,0,sizeof(*info));
163 dev = alloc_trdev(sizeof(struct tok_info)); 153 dev = alloc_trdev(sizeof(struct tok_info));
164 if (!dev) { 154 if (!dev) {
165 kfree(info); 155 kfree(info);
166 return NULL; 156 return -ENOMEM;
167 } 157 }
168 158
169 link = &info->link; 159 link = &info->link;
170 link->priv = info; 160 link->priv = info;
@@ -185,25 +175,13 @@ static dev_link_t *ibmtr_attach(void)
185 175
186 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 176 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
187 177
188 /* Register with Card Services */ 178 link->handle = p_dev;
189 link->next = dev_list; 179 p_dev->instance = link;
190 dev_list = link;
191 client_reg.dev_info = &dev_info;
192 client_reg.Version = 0x0210;
193 client_reg.event_callback_args.client_data = link;
194 ret = pcmcia_register_client(&link->handle, &client_reg);
195 if (ret != 0) {
196 cs_error(link->handle, RegisterClient, ret);
197 goto out_detach;
198 }
199 180
200out: 181 link->state |= DEV_PRESENT;
201 return link; 182 ibmtr_config(link);
202 183
203out_detach: 184 return 0;
204 ibmtr_detach(link);
205 link = NULL;
206 goto out;
207} /* ibmtr_attach */ 185} /* ibmtr_attach */
208 186
209/*====================================================================== 187/*======================================================================
@@ -215,22 +193,14 @@ out_detach:
215 193
216======================================================================*/ 194======================================================================*/
217 195
218static void ibmtr_detach(dev_link_t *link) 196static void ibmtr_detach(struct pcmcia_device *p_dev)
219{ 197{
198 dev_link_t *link = dev_to_instance(p_dev);
220 struct ibmtr_dev_t *info = link->priv; 199 struct ibmtr_dev_t *info = link->priv;
221 dev_link_t **linkp; 200 struct net_device *dev = info->dev;
222 struct net_device *dev;
223 201
224 DEBUG(0, "ibmtr_detach(0x%p)\n", link); 202 DEBUG(0, "ibmtr_detach(0x%p)\n", link);
225 203
226 /* Locate device structure */
227 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
228 if (*linkp == link) break;
229 if (*linkp == NULL)
230 return;
231
232 dev = info->dev;
233
234 if (link->dev) 204 if (link->dev)
235 unregister_netdev(dev); 205 unregister_netdev(dev);
236 206
@@ -241,13 +211,8 @@ static void ibmtr_detach(dev_link_t *link)
241 if (link->state & DEV_CONFIG) 211 if (link->state & DEV_CONFIG)
242 ibmtr_release(link); 212 ibmtr_release(link);
243 213
244 if (link->handle)
245 pcmcia_deregister_client(link->handle);
246
247 /* Unlink device structure, free bits */
248 *linkp = link->next;
249 free_netdev(dev); 214 free_netdev(dev);
250 kfree(info); 215 kfree(info);
251} /* ibmtr_detach */ 216} /* ibmtr_detach */
252 217
253/*====================================================================== 218/*======================================================================
@@ -401,63 +366,40 @@ static void ibmtr_release(dev_link_t *link)
401 link->state &= ~DEV_CONFIG; 366 link->state &= ~DEV_CONFIG;
402} 367}
403 368
404/*====================================================================== 369static int ibmtr_suspend(struct pcmcia_device *p_dev)
370{
371 dev_link_t *link = dev_to_instance(p_dev);
372 ibmtr_dev_t *info = link->priv;
373 struct net_device *dev = info->dev;
405 374
406 The card status event handler. Mostly, this schedules other 375 link->state |= DEV_SUSPEND;
407 stuff to run after an event is received. A CARD_REMOVAL event 376 if (link->state & DEV_CONFIG) {
408 also sets some flags to discourage the net drivers from trying 377 if (link->open)
409 to talk to the card any more. 378 netif_device_detach(dev);
379 pcmcia_release_configuration(link->handle);
380 }
410 381
411======================================================================*/ 382 return 0;
383}
412 384
413static int ibmtr_event(event_t event, int priority, 385static int ibmtr_resume(struct pcmcia_device *p_dev)
414 event_callback_args_t *args)
415{ 386{
416 dev_link_t *link = args->client_data; 387 dev_link_t *link = dev_to_instance(p_dev);
417 ibmtr_dev_t *info = link->priv; 388 ibmtr_dev_t *info = link->priv;
418 struct net_device *dev = info->dev; 389 struct net_device *dev = info->dev;
419 390
420 DEBUG(1, "ibmtr_event(0x%06x)\n", event); 391 link->state &= ~DEV_SUSPEND;
421
422 switch (event) {
423 case CS_EVENT_CARD_REMOVAL:
424 link->state &= ~DEV_PRESENT;
425 if (link->state & DEV_CONFIG) {
426 /* set flag to bypass normal interrupt code */
427 struct tok_info *priv = netdev_priv(dev);
428 priv->sram_phys |= 1;
429 netif_device_detach(dev);
430 }
431 break;
432 case CS_EVENT_CARD_INSERTION:
433 link->state |= DEV_PRESENT;
434 ibmtr_config(link);
435 break;
436 case CS_EVENT_PM_SUSPEND:
437 link->state |= DEV_SUSPEND;
438 /* Fall through... */
439 case CS_EVENT_RESET_PHYSICAL:
440 if (link->state & DEV_CONFIG) { 392 if (link->state & DEV_CONFIG) {
441 if (link->open) 393 pcmcia_request_configuration(link->handle, &link->conf);
442 netif_device_detach(dev); 394 if (link->open) {
443 pcmcia_release_configuration(link->handle); 395 ibmtr_probe(dev); /* really? */
396 netif_device_attach(dev);
397 }
444 } 398 }
445 break; 399
446 case CS_EVENT_PM_RESUME: 400 return 0;
447 link->state &= ~DEV_SUSPEND; 401}
448 /* Fall through... */ 402
449 case CS_EVENT_CARD_RESET:
450 if (link->state & DEV_CONFIG) {
451 pcmcia_request_configuration(link->handle, &link->conf);
452 if (link->open) {
453 ibmtr_probe(dev); /* really? */
454 netif_device_attach(dev);
455 }
456 }
457 break;
458 }
459 return 0;
460} /* ibmtr_event */
461 403
462/*====================================================================*/ 404/*====================================================================*/
463 405
@@ -514,10 +456,11 @@ static struct pcmcia_driver ibmtr_cs_driver = {
514 .drv = { 456 .drv = {
515 .name = "ibmtr_cs", 457 .name = "ibmtr_cs",
516 }, 458 },
517 .attach = ibmtr_attach, 459 .probe = ibmtr_attach,
518 .event = ibmtr_event, 460 .remove = ibmtr_detach,
519 .detach = ibmtr_detach,
520 .id_table = ibmtr_ids, 461 .id_table = ibmtr_ids,
462 .suspend = ibmtr_suspend,
463 .resume = ibmtr_resume,
521}; 464};
522 465
523static int __init init_ibmtr_cs(void) 466static int __init init_ibmtr_cs(void)
@@ -528,7 +471,6 @@ static int __init init_ibmtr_cs(void)
528static void __exit exit_ibmtr_cs(void) 471static void __exit exit_ibmtr_cs(void)
529{ 472{
530 pcmcia_unregister_driver(&ibmtr_cs_driver); 473 pcmcia_unregister_driver(&ibmtr_cs_driver);
531 BUG_ON(dev_list != NULL);
532} 474}
533 475
534module_init(init_ibmtr_cs); 476module_init(init_ibmtr_cs);
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index 980d7e5d66cb..4a232254a497 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -388,9 +388,6 @@ static char *version =
388DRV_NAME " " DRV_VERSION " (Roger C. Pao)"; 388DRV_NAME " " DRV_VERSION " (Roger C. Pao)";
389#endif 389#endif
390 390
391static dev_info_t dev_info="nmclan_cs";
392static dev_link_t *dev_list;
393
394static char *if_names[]={ 391static char *if_names[]={
395 "Auto", "10baseT", "BNC", 392 "Auto", "10baseT", "BNC",
396}; 393};
@@ -422,8 +419,6 @@ Function Prototypes
422 419
423static void nmclan_config(dev_link_t *link); 420static void nmclan_config(dev_link_t *link);
424static void nmclan_release(dev_link_t *link); 421static void nmclan_release(dev_link_t *link);
425static int nmclan_event(event_t event, int priority,
426 event_callback_args_t *args);
427 422
428static void nmclan_reset(struct net_device *dev); 423static void nmclan_reset(struct net_device *dev);
429static int mace_config(struct net_device *dev, struct ifmap *map); 424static int mace_config(struct net_device *dev, struct ifmap *map);
@@ -439,8 +434,7 @@ static void set_multicast_list(struct net_device *dev);
439static struct ethtool_ops netdev_ethtool_ops; 434static struct ethtool_ops netdev_ethtool_ops;
440 435
441 436
442static dev_link_t *nmclan_attach(void); 437static void nmclan_detach(struct pcmcia_device *p_dev);
443static void nmclan_detach(dev_link_t *);
444 438
445/* ---------------------------------------------------------------------------- 439/* ----------------------------------------------------------------------------
446nmclan_attach 440nmclan_attach
@@ -449,13 +443,11 @@ nmclan_attach
449 Services. 443 Services.
450---------------------------------------------------------------------------- */ 444---------------------------------------------------------------------------- */
451 445
452static dev_link_t *nmclan_attach(void) 446static int nmclan_attach(struct pcmcia_device *p_dev)
453{ 447{
454 mace_private *lp; 448 mace_private *lp;
455 dev_link_t *link; 449 dev_link_t *link;
456 struct net_device *dev; 450 struct net_device *dev;
457 client_reg_t client_reg;
458 int ret;
459 451
460 DEBUG(0, "nmclan_attach()\n"); 452 DEBUG(0, "nmclan_attach()\n");
461 DEBUG(1, "%s\n", rcsid); 453 DEBUG(1, "%s\n", rcsid);
@@ -463,7 +455,7 @@ static dev_link_t *nmclan_attach(void)
463 /* Create new ethernet device */ 455 /* Create new ethernet device */
464 dev = alloc_etherdev(sizeof(mace_private)); 456 dev = alloc_etherdev(sizeof(mace_private));
465 if (!dev) 457 if (!dev)
466 return NULL; 458 return -ENOMEM;
467 lp = netdev_priv(dev); 459 lp = netdev_priv(dev);
468 link = &lp->link; 460 link = &lp->link;
469 link->priv = dev; 461 link->priv = dev;
@@ -497,20 +489,13 @@ static dev_link_t *nmclan_attach(void)
497 dev->watchdog_timeo = TX_TIMEOUT; 489 dev->watchdog_timeo = TX_TIMEOUT;
498#endif 490#endif
499 491
500 /* Register with Card Services */ 492 link->handle = p_dev;
501 link->next = dev_list; 493 p_dev->instance = link;
502 dev_list = link; 494
503 client_reg.dev_info = &dev_info; 495 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
504 client_reg.Version = 0x0210; 496 nmclan_config(link);
505 client_reg.event_callback_args.client_data = link;
506 ret = pcmcia_register_client(&link->handle, &client_reg);
507 if (ret != 0) {
508 cs_error(link->handle, RegisterClient, ret);
509 nmclan_detach(link);
510 return NULL;
511 }
512 497
513 return link; 498 return 0;
514} /* nmclan_attach */ 499} /* nmclan_attach */
515 500
516/* ---------------------------------------------------------------------------- 501/* ----------------------------------------------------------------------------
@@ -521,30 +506,19 @@ nmclan_detach
521 when the device is released. 506 when the device is released.
522---------------------------------------------------------------------------- */ 507---------------------------------------------------------------------------- */
523 508
524static void nmclan_detach(dev_link_t *link) 509static void nmclan_detach(struct pcmcia_device *p_dev)
525{ 510{
511 dev_link_t *link = dev_to_instance(p_dev);
526 struct net_device *dev = link->priv; 512 struct net_device *dev = link->priv;
527 dev_link_t **linkp;
528 513
529 DEBUG(0, "nmclan_detach(0x%p)\n", link); 514 DEBUG(0, "nmclan_detach(0x%p)\n", link);
530 515
531 /* Locate device structure */
532 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
533 if (*linkp == link) break;
534 if (*linkp == NULL)
535 return;
536
537 if (link->dev) 516 if (link->dev)
538 unregister_netdev(dev); 517 unregister_netdev(dev);
539 518
540 if (link->state & DEV_CONFIG) 519 if (link->state & DEV_CONFIG)
541 nmclan_release(link); 520 nmclan_release(link);
542 521
543 if (link->handle)
544 pcmcia_deregister_client(link->handle);
545
546 /* Unlink device structure, free bits */
547 *linkp = link->next;
548 free_netdev(dev); 522 free_netdev(dev);
549} /* nmclan_detach */ 523} /* nmclan_detach */
550 524
@@ -801,59 +775,39 @@ static void nmclan_release(dev_link_t *link)
801 link->state &= ~DEV_CONFIG; 775 link->state &= ~DEV_CONFIG;
802} 776}
803 777
804/* ---------------------------------------------------------------------------- 778static int nmclan_suspend(struct pcmcia_device *p_dev)
805nmclan_event
806 The card status event handler. Mostly, this schedules other
807 stuff to run after an event is received. A CARD_REMOVAL event
808 also sets some flags to discourage the net drivers from trying
809 to talk to the card any more.
810---------------------------------------------------------------------------- */
811static int nmclan_event(event_t event, int priority,
812 event_callback_args_t *args)
813{ 779{
814 dev_link_t *link = args->client_data; 780 dev_link_t *link = dev_to_instance(p_dev);
815 struct net_device *dev = link->priv; 781 struct net_device *dev = link->priv;
782
783 link->state |= DEV_SUSPEND;
784 if (link->state & DEV_CONFIG) {
785 if (link->open)
786 netif_device_detach(dev);
787 pcmcia_release_configuration(link->handle);
788 }
816 789
817 DEBUG(1, "nmclan_event(0x%06x)\n", event);
818 790
819 switch (event) { 791 return 0;
820 case CS_EVENT_CARD_REMOVAL: 792}
821 link->state &= ~DEV_PRESENT; 793
822 if (link->state & DEV_CONFIG) 794static int nmclan_resume(struct pcmcia_device *p_dev)
823 netif_device_detach(dev); 795{
824 break; 796 dev_link_t *link = dev_to_instance(p_dev);
825 case CS_EVENT_CARD_INSERTION: 797 struct net_device *dev = link->priv;
826 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 798
827 nmclan_config(link); 799 link->state &= ~DEV_SUSPEND;
828 break; 800 if (link->state & DEV_CONFIG) {
829 case CS_EVENT_PM_SUSPEND: 801 pcmcia_request_configuration(link->handle, &link->conf);
830 link->state |= DEV_SUSPEND; 802 if (link->open) {
831 /* Fall through... */ 803 nmclan_reset(dev);
832 case CS_EVENT_RESET_PHYSICAL: 804 netif_device_attach(dev);
833 if (link->state & DEV_CONFIG) { 805 }
834 if (link->open)
835 netif_device_detach(dev);
836 pcmcia_release_configuration(link->handle);
837 }
838 break;
839 case CS_EVENT_PM_RESUME:
840 link->state &= ~DEV_SUSPEND;
841 /* Fall through... */
842 case CS_EVENT_CARD_RESET:
843 if (link->state & DEV_CONFIG) {
844 pcmcia_request_configuration(link->handle, &link->conf);
845 if (link->open) {
846 nmclan_reset(dev);
847 netif_device_attach(dev);
848 } 806 }
849 } 807
850 break; 808 return 0;
851 case CS_EVENT_RESET_REQUEST: 809}
852 return 1; 810
853 break;
854 }
855 return 0;
856} /* nmclan_event */
857 811
858/* ---------------------------------------------------------------------------- 812/* ----------------------------------------------------------------------------
859nmclan_reset 813nmclan_reset
@@ -1681,10 +1635,11 @@ static struct pcmcia_driver nmclan_cs_driver = {
1681 .drv = { 1635 .drv = {
1682 .name = "nmclan_cs", 1636 .name = "nmclan_cs",
1683 }, 1637 },
1684 .attach = nmclan_attach, 1638 .probe = nmclan_attach,
1685 .event = nmclan_event, 1639 .remove = nmclan_detach,
1686 .detach = nmclan_detach,
1687 .id_table = nmclan_ids, 1640 .id_table = nmclan_ids,
1641 .suspend = nmclan_suspend,
1642 .resume = nmclan_resume,
1688}; 1643};
1689 1644
1690static int __init init_nmclan_cs(void) 1645static int __init init_nmclan_cs(void)
@@ -1695,7 +1650,6 @@ static int __init init_nmclan_cs(void)
1695static void __exit exit_nmclan_cs(void) 1650static void __exit exit_nmclan_cs(void)
1696{ 1651{
1697 pcmcia_unregister_driver(&nmclan_cs_driver); 1652 pcmcia_unregister_driver(&nmclan_cs_driver);
1698 BUG_ON(dev_list != NULL);
1699} 1653}
1700 1654
1701module_init(init_nmclan_cs); 1655module_init(init_nmclan_cs);
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 818c185d6438..d85b758f3efa 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -105,8 +105,6 @@ module_param_array(hw_addr, int, NULL, 0);
105static void mii_phy_probe(struct net_device *dev); 105static void mii_phy_probe(struct net_device *dev);
106static void pcnet_config(dev_link_t *link); 106static void pcnet_config(dev_link_t *link);
107static void pcnet_release(dev_link_t *link); 107static void pcnet_release(dev_link_t *link);
108static int pcnet_event(event_t event, int priority,
109 event_callback_args_t *args);
110static int pcnet_open(struct net_device *dev); 108static int pcnet_open(struct net_device *dev);
111static int pcnet_close(struct net_device *dev); 109static int pcnet_close(struct net_device *dev);
112static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 110static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -120,11 +118,9 @@ static int setup_shmem_window(dev_link_t *link, int start_pg,
120static int setup_dma_config(dev_link_t *link, int start_pg, 118static int setup_dma_config(dev_link_t *link, int start_pg,
121 int stop_pg); 119 int stop_pg);
122 120
123static dev_link_t *pcnet_attach(void); 121static void pcnet_detach(struct pcmcia_device *p_dev);
124static void pcnet_detach(dev_link_t *);
125 122
126static dev_info_t dev_info = "pcnet_cs"; 123static dev_info_t dev_info = "pcnet_cs";
127static dev_link_t *dev_list;
128 124
129/*====================================================================*/ 125/*====================================================================*/
130 126
@@ -244,19 +240,17 @@ static inline pcnet_dev_t *PRIV(struct net_device *dev)
244 240
245======================================================================*/ 241======================================================================*/
246 242
247static dev_link_t *pcnet_attach(void) 243static int pcnet_probe(struct pcmcia_device *p_dev)
248{ 244{
249 pcnet_dev_t *info; 245 pcnet_dev_t *info;
250 dev_link_t *link; 246 dev_link_t *link;
251 struct net_device *dev; 247 struct net_device *dev;
252 client_reg_t client_reg;
253 int ret;
254 248
255 DEBUG(0, "pcnet_attach()\n"); 249 DEBUG(0, "pcnet_attach()\n");
256 250
257 /* Create new ethernet device */ 251 /* Create new ethernet device */
258 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 252 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t));
259 if (!dev) return NULL; 253 if (!dev) return -ENOMEM;
260 info = PRIV(dev); 254 info = PRIV(dev);
261 link = &info->link; 255 link = &info->link;
262 link->priv = dev; 256 link->priv = dev;
@@ -271,20 +265,13 @@ static dev_link_t *pcnet_attach(void)
271 dev->stop = &pcnet_close; 265 dev->stop = &pcnet_close;
272 dev->set_config = &set_config; 266 dev->set_config = &set_config;
273 267
274 /* Register with Card Services */ 268 link->handle = p_dev;
275 link->next = dev_list; 269 p_dev->instance = link;
276 dev_list = link;
277 client_reg.dev_info = &dev_info;
278 client_reg.Version = 0x0210;
279 client_reg.event_callback_args.client_data = link;
280 ret = pcmcia_register_client(&link->handle, &client_reg);
281 if (ret != CS_SUCCESS) {
282 cs_error(link->handle, RegisterClient, ret);
283 pcnet_detach(link);
284 return NULL;
285 }
286 270
287 return link; 271 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
272 pcnet_config(link);
273
274 return 0;
288} /* pcnet_attach */ 275} /* pcnet_attach */
289 276
290/*====================================================================== 277/*======================================================================
@@ -296,31 +283,20 @@ static dev_link_t *pcnet_attach(void)
296 283
297======================================================================*/ 284======================================================================*/
298 285
299static void pcnet_detach(dev_link_t *link) 286static void pcnet_detach(struct pcmcia_device *p_dev)
300{ 287{
301 struct net_device *dev = link->priv; 288 dev_link_t *link = dev_to_instance(p_dev);
302 dev_link_t **linkp; 289 struct net_device *dev = link->priv;
303
304 DEBUG(0, "pcnet_detach(0x%p)\n", link);
305 290
306 /* Locate device structure */ 291 DEBUG(0, "pcnet_detach(0x%p)\n", link);
307 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
308 if (*linkp == link) break;
309 if (*linkp == NULL)
310 return;
311 292
312 if (link->dev) 293 if (link->dev)
313 unregister_netdev(dev); 294 unregister_netdev(dev);
314 295
315 if (link->state & DEV_CONFIG) 296 if (link->state & DEV_CONFIG)
316 pcnet_release(link); 297 pcnet_release(link);
317
318 if (link->handle)
319 pcmcia_deregister_client(link->handle);
320 298
321 /* Unlink device structure, free bits */ 299 free_netdev(dev);
322 *linkp = link->next;
323 free_netdev(dev);
324} /* pcnet_detach */ 300} /* pcnet_detach */
325 301
326/*====================================================================== 302/*======================================================================
@@ -780,50 +756,39 @@ static void pcnet_release(dev_link_t *link)
780 756
781======================================================================*/ 757======================================================================*/
782 758
783static int pcnet_event(event_t event, int priority, 759static int pcnet_suspend(struct pcmcia_device *p_dev)
784 event_callback_args_t *args)
785{ 760{
786 dev_link_t *link = args->client_data; 761 dev_link_t *link = dev_to_instance(p_dev);
787 struct net_device *dev = link->priv; 762 struct net_device *dev = link->priv;
788 763
789 DEBUG(2, "pcnet_event(0x%06x)\n", event);
790
791 switch (event) {
792 case CS_EVENT_CARD_REMOVAL:
793 link->state &= ~DEV_PRESENT;
794 if (link->state & DEV_CONFIG)
795 netif_device_detach(dev);
796 break;
797 case CS_EVENT_CARD_INSERTION:
798 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
799 pcnet_config(link);
800 break;
801 case CS_EVENT_PM_SUSPEND:
802 link->state |= DEV_SUSPEND; 764 link->state |= DEV_SUSPEND;
803 /* Fall through... */
804 case CS_EVENT_RESET_PHYSICAL:
805 if (link->state & DEV_CONFIG) { 765 if (link->state & DEV_CONFIG) {
806 if (link->open) 766 if (link->open)
807 netif_device_detach(dev); 767 netif_device_detach(dev);
808 pcmcia_release_configuration(link->handle); 768 pcmcia_release_configuration(link->handle);
809 } 769 }
810 break; 770
811 case CS_EVENT_PM_RESUME: 771 return 0;
772}
773
774static int pcnet_resume(struct pcmcia_device *p_dev)
775{
776 dev_link_t *link = dev_to_instance(p_dev);
777 struct net_device *dev = link->priv;
778
812 link->state &= ~DEV_SUSPEND; 779 link->state &= ~DEV_SUSPEND;
813 /* Fall through... */
814 case CS_EVENT_CARD_RESET:
815 if (link->state & DEV_CONFIG) { 780 if (link->state & DEV_CONFIG) {
816 pcmcia_request_configuration(link->handle, &link->conf); 781 pcmcia_request_configuration(link->handle, &link->conf);
817 if (link->open) { 782 if (link->open) {
818 pcnet_reset_8390(dev); 783 pcnet_reset_8390(dev);
819 NS8390_init(dev, 1); 784 NS8390_init(dev, 1);
820 netif_device_attach(dev); 785 netif_device_attach(dev);
821 } 786 }
822 } 787 }
823 break; 788
824 } 789 return 0;
825 return 0; 790}
826} /* pcnet_event */ 791
827 792
828/*====================================================================== 793/*======================================================================
829 794
@@ -1844,11 +1809,12 @@ static struct pcmcia_driver pcnet_driver = {
1844 .drv = { 1809 .drv = {
1845 .name = "pcnet_cs", 1810 .name = "pcnet_cs",
1846 }, 1811 },
1847 .attach = pcnet_attach, 1812 .probe = pcnet_probe,
1848 .event = pcnet_event, 1813 .remove = pcnet_detach,
1849 .detach = pcnet_detach,
1850 .owner = THIS_MODULE, 1814 .owner = THIS_MODULE,
1851 .id_table = pcnet_ids, 1815 .id_table = pcnet_ids,
1816 .suspend = pcnet_suspend,
1817 .resume = pcnet_resume,
1852}; 1818};
1853 1819
1854static int __init init_pcnet_cs(void) 1820static int __init init_pcnet_cs(void)
@@ -1860,7 +1826,6 @@ static void __exit exit_pcnet_cs(void)
1860{ 1826{
1861 DEBUG(0, "pcnet_cs: unloading\n"); 1827 DEBUG(0, "pcnet_cs: unloading\n");
1862 pcmcia_unregister_driver(&pcnet_driver); 1828 pcmcia_unregister_driver(&pcnet_driver);
1863 BUG_ON(dev_list != NULL);
1864} 1829}
1865 1830
1866module_init(init_pcnet_cs); 1831module_init(init_pcnet_cs);
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index c7cca842e5ee..0122415dfeef 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -102,10 +102,6 @@ static const char *version =
102 currently have room for another Tx packet. */ 102 currently have room for another Tx packet. */
103#define MEMORY_WAIT_TIME 8 103#define MEMORY_WAIT_TIME 8
104 104
105static dev_info_t dev_info = "smc91c92_cs";
106
107static dev_link_t *dev_list;
108
109struct smc_private { 105struct smc_private {
110 dev_link_t link; 106 dev_link_t link;
111 spinlock_t lock; 107 spinlock_t lock;
@@ -281,12 +277,9 @@ enum RxCfg { RxAllMulti = 0x0004, RxPromisc = 0x0002,
281 277
282/*====================================================================*/ 278/*====================================================================*/
283 279
284static dev_link_t *smc91c92_attach(void); 280static void smc91c92_detach(struct pcmcia_device *p_dev);
285static void smc91c92_detach(dev_link_t *);
286static void smc91c92_config(dev_link_t *link); 281static void smc91c92_config(dev_link_t *link);
287static void smc91c92_release(dev_link_t *link); 282static void smc91c92_release(dev_link_t *link);
288static int smc91c92_event(event_t event, int priority,
289 event_callback_args_t *args);
290 283
291static int smc_open(struct net_device *dev); 284static int smc_open(struct net_device *dev);
292static int smc_close(struct net_device *dev); 285static int smc_close(struct net_device *dev);
@@ -315,20 +308,18 @@ static struct ethtool_ops ethtool_ops;
315 308
316======================================================================*/ 309======================================================================*/
317 310
318static dev_link_t *smc91c92_attach(void) 311static int smc91c92_attach(struct pcmcia_device *p_dev)
319{ 312{
320 client_reg_t client_reg;
321 struct smc_private *smc; 313 struct smc_private *smc;
322 dev_link_t *link; 314 dev_link_t *link;
323 struct net_device *dev; 315 struct net_device *dev;
324 int ret;
325 316
326 DEBUG(0, "smc91c92_attach()\n"); 317 DEBUG(0, "smc91c92_attach()\n");
327 318
328 /* Create new ethernet device */ 319 /* Create new ethernet device */
329 dev = alloc_etherdev(sizeof(struct smc_private)); 320 dev = alloc_etherdev(sizeof(struct smc_private));
330 if (!dev) 321 if (!dev)
331 return NULL; 322 return -ENOMEM;
332 smc = netdev_priv(dev); 323 smc = netdev_priv(dev);
333 link = &smc->link; 324 link = &smc->link;
334 link->priv = dev; 325 link->priv = dev;
@@ -366,20 +357,13 @@ static dev_link_t *smc91c92_attach(void)
366 smc->mii_if.phy_id_mask = 0x1f; 357 smc->mii_if.phy_id_mask = 0x1f;
367 smc->mii_if.reg_num_mask = 0x1f; 358 smc->mii_if.reg_num_mask = 0x1f;
368 359
369 /* Register with Card Services */ 360 link->handle = p_dev;
370 link->next = dev_list; 361 p_dev->instance = link;
371 dev_list = link; 362
372 client_reg.dev_info = &dev_info; 363 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
373 client_reg.Version = 0x0210; 364 smc91c92_config(link);
374 client_reg.event_callback_args.client_data = link;
375 ret = pcmcia_register_client(&link->handle, &client_reg);
376 if (ret != 0) {
377 cs_error(link->handle, RegisterClient, ret);
378 smc91c92_detach(link);
379 return NULL;
380 }
381 365
382 return link; 366 return 0;
383} /* smc91c92_attach */ 367} /* smc91c92_attach */
384 368
385/*====================================================================== 369/*======================================================================
@@ -391,30 +375,19 @@ static dev_link_t *smc91c92_attach(void)
391 375
392======================================================================*/ 376======================================================================*/
393 377
394static void smc91c92_detach(dev_link_t *link) 378static void smc91c92_detach(struct pcmcia_device *p_dev)
395{ 379{
380 dev_link_t *link = dev_to_instance(p_dev);
396 struct net_device *dev = link->priv; 381 struct net_device *dev = link->priv;
397 dev_link_t **linkp;
398 382
399 DEBUG(0, "smc91c92_detach(0x%p)\n", link); 383 DEBUG(0, "smc91c92_detach(0x%p)\n", link);
400 384
401 /* Locate device structure */
402 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
403 if (*linkp == link) break;
404 if (*linkp == NULL)
405 return;
406
407 if (link->dev) 385 if (link->dev)
408 unregister_netdev(dev); 386 unregister_netdev(dev);
409 387
410 if (link->state & DEV_CONFIG) 388 if (link->state & DEV_CONFIG)
411 smc91c92_release(link); 389 smc91c92_release(link);
412 390
413 if (link->handle)
414 pcmcia_deregister_client(link->handle);
415
416 /* Unlink device structure, free bits */
417 *linkp = link->next;
418 free_netdev(dev); 391 free_netdev(dev);
419} /* smc91c92_detach */ 392} /* smc91c92_detach */
420 393
@@ -895,6 +868,62 @@ free_cfg_mem:
895 return rc; 868 return rc;
896} 869}
897 870
871static int smc91c92_suspend(struct pcmcia_device *p_dev)
872{
873 dev_link_t *link = dev_to_instance(p_dev);
874 struct net_device *dev = link->priv;
875
876 link->state |= DEV_SUSPEND;
877 if (link->state & DEV_CONFIG) {
878 if (link->open)
879 netif_device_detach(dev);
880 pcmcia_release_configuration(link->handle);
881 }
882
883 return 0;
884}
885
886static int smc91c92_resume(struct pcmcia_device *p_dev)
887{
888 dev_link_t *link = dev_to_instance(p_dev);
889 struct net_device *dev = link->priv;
890 struct smc_private *smc = netdev_priv(dev);
891 int i;
892
893 link->state &= ~DEV_SUSPEND;
894 if (link->state & DEV_CONFIG) {
895 if ((smc->manfid == MANFID_MEGAHERTZ) &&
896 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
897 mhz_3288_power(link);
898 pcmcia_request_configuration(link->handle, &link->conf);
899 if (smc->manfid == MANFID_MOTOROLA)
900 mot_config(link);
901 if ((smc->manfid == MANFID_OSITECH) &&
902 (smc->cardid != PRODID_OSITECH_SEVEN)) {
903 /* Power up the card and enable interrupts */
904 set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR);
905 set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR);
906 }
907 if (((smc->manfid == MANFID_OSITECH) &&
908 (smc->cardid == PRODID_OSITECH_SEVEN)) ||
909 ((smc->manfid == MANFID_PSION) &&
910 (smc->cardid == PRODID_PSION_NET100))) {
911 /* Download the Seven of Diamonds firmware */
912 for (i = 0; i < sizeof(__Xilinx7OD); i++) {
913 outb(__Xilinx7OD[i], link->io.BasePort1+2);
914 udelay(50);
915 }
916 }
917 if (link->open) {
918 smc_reset(dev);
919 netif_device_attach(dev);
920 }
921 }
922
923 return 0;
924}
925
926
898/*====================================================================== 927/*======================================================================
899 928
900 This verifies that the chip is some SMC91cXX variant, and returns 929 This verifies that the chip is some SMC91cXX variant, and returns
@@ -935,14 +964,12 @@ static int check_sig(dev_link_t *link)
935 } 964 }
936 965
937 if (width) { 966 if (width) {
938 event_callback_args_t args;
939 printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n"); 967 printk(KERN_INFO "smc91c92_cs: using 8-bit IO window.\n");
940 args.client_data = link; 968 smc91c92_suspend(link->handle);
941 smc91c92_event(CS_EVENT_RESET_PHYSICAL, 0, &args);
942 pcmcia_release_io(link->handle, &link->io); 969 pcmcia_release_io(link->handle, &link->io);
943 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 970 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
944 pcmcia_request_io(link->handle, &link->io); 971 pcmcia_request_io(link->handle, &link->io);
945 smc91c92_event(CS_EVENT_CARD_RESET, 0, &args); 972 smc91c92_resume(link->handle);
946 return check_sig(link); 973 return check_sig(link);
947 } 974 }
948 return -ENODEV; 975 return -ENODEV;
@@ -1172,82 +1199,6 @@ static void smc91c92_release(dev_link_t *link)
1172 1199
1173/*====================================================================== 1200/*======================================================================
1174 1201
1175 The card status event handler. Mostly, this schedules other
1176 stuff to run after an event is received. A CARD_REMOVAL event
1177 also sets some flags to discourage the net drivers from trying
1178 to talk to the card any more.
1179
1180======================================================================*/
1181
1182static int smc91c92_event(event_t event, int priority,
1183 event_callback_args_t *args)
1184{
1185 dev_link_t *link = args->client_data;
1186 struct net_device *dev = link->priv;
1187 struct smc_private *smc = netdev_priv(dev);
1188 int i;
1189
1190 DEBUG(1, "smc91c92_event(0x%06x)\n", event);
1191
1192 switch (event) {
1193 case CS_EVENT_CARD_REMOVAL:
1194 link->state &= ~DEV_PRESENT;
1195 if (link->state & DEV_CONFIG)
1196 netif_device_detach(dev);
1197 break;
1198 case CS_EVENT_CARD_INSERTION:
1199 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1200 smc91c92_config(link);
1201 break;
1202 case CS_EVENT_PM_SUSPEND:
1203 link->state |= DEV_SUSPEND;
1204 /* Fall through... */
1205 case CS_EVENT_RESET_PHYSICAL:
1206 if (link->state & DEV_CONFIG) {
1207 if (link->open)
1208 netif_device_detach(dev);
1209 pcmcia_release_configuration(link->handle);
1210 }
1211 break;
1212 case CS_EVENT_PM_RESUME:
1213 link->state &= ~DEV_SUSPEND;
1214 /* Fall through... */
1215 case CS_EVENT_CARD_RESET:
1216 if (link->state & DEV_CONFIG) {
1217 if ((smc->manfid == MANFID_MEGAHERTZ) &&
1218 (smc->cardid == PRODID_MEGAHERTZ_EM3288))
1219 mhz_3288_power(link);
1220 pcmcia_request_configuration(link->handle, &link->conf);
1221 if (smc->manfid == MANFID_MOTOROLA)
1222 mot_config(link);
1223 if ((smc->manfid == MANFID_OSITECH) &&
1224 (smc->cardid != PRODID_OSITECH_SEVEN)) {
1225 /* Power up the card and enable interrupts */
1226 set_bits(0x0300, dev->base_addr-0x10+OSITECH_AUI_PWR);
1227 set_bits(0x0300, dev->base_addr-0x10+OSITECH_RESET_ISR);
1228 }
1229 if (((smc->manfid == MANFID_OSITECH) &&
1230 (smc->cardid == PRODID_OSITECH_SEVEN)) ||
1231 ((smc->manfid == MANFID_PSION) &&
1232 (smc->cardid == PRODID_PSION_NET100))) {
1233 /* Download the Seven of Diamonds firmware */
1234 for (i = 0; i < sizeof(__Xilinx7OD); i++) {
1235 outb(__Xilinx7OD[i], link->io.BasePort1+2);
1236 udelay(50);
1237 }
1238 }
1239 if (link->open) {
1240 smc_reset(dev);
1241 netif_device_attach(dev);
1242 }
1243 }
1244 break;
1245 }
1246 return 0;
1247} /* smc91c92_event */
1248
1249/*======================================================================
1250
1251 MII interface support for SMC91cXX based cards 1202 MII interface support for SMC91cXX based cards
1252======================================================================*/ 1203======================================================================*/
1253 1204
@@ -2360,10 +2311,11 @@ static struct pcmcia_driver smc91c92_cs_driver = {
2360 .drv = { 2311 .drv = {
2361 .name = "smc91c92_cs", 2312 .name = "smc91c92_cs",
2362 }, 2313 },
2363 .attach = smc91c92_attach, 2314 .probe = smc91c92_attach,
2364 .event = smc91c92_event, 2315 .remove = smc91c92_detach,
2365 .detach = smc91c92_detach,
2366 .id_table = smc91c92_ids, 2316 .id_table = smc91c92_ids,
2317 .suspend = smc91c92_suspend,
2318 .resume = smc91c92_resume,
2367}; 2319};
2368 2320
2369static int __init init_smc91c92_cs(void) 2321static int __init init_smc91c92_cs(void)
@@ -2374,7 +2326,6 @@ static int __init init_smc91c92_cs(void)
2374static void __exit exit_smc91c92_cs(void) 2326static void __exit exit_smc91c92_cs(void)
2375{ 2327{
2376 pcmcia_unregister_driver(&smc91c92_cs_driver); 2328 pcmcia_unregister_driver(&smc91c92_cs_driver);
2377 BUG_ON(dev_list != NULL);
2378} 2329}
2379 2330
2380module_init(init_smc91c92_cs); 2331module_init(init_smc91c92_cs);
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index ce143f08638a..049c34b37067 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -292,8 +292,6 @@ static void mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg,
292static int has_ce2_string(dev_link_t * link); 292static int has_ce2_string(dev_link_t * link);
293static void xirc2ps_config(dev_link_t * link); 293static void xirc2ps_config(dev_link_t * link);
294static void xirc2ps_release(dev_link_t * link); 294static void xirc2ps_release(dev_link_t * link);
295static int xirc2ps_event(event_t event, int priority,
296 event_callback_args_t * args);
297 295
298/**************** 296/****************
299 * The attach() and detach() entry points are used to create and destroy 297 * The attach() and detach() entry points are used to create and destroy
@@ -301,8 +299,7 @@ static int xirc2ps_event(event_t event, int priority,
301 * needed to manage one actual PCMCIA card. 299 * needed to manage one actual PCMCIA card.
302 */ 300 */
303 301
304static dev_link_t *xirc2ps_attach(void); 302static void xirc2ps_detach(struct pcmcia_device *p_dev);
305static void xirc2ps_detach(dev_link_t *);
306 303
307/**************** 304/****************
308 * You'll also need to prototype all the functions that will actually 305 * You'll also need to prototype all the functions that will actually
@@ -313,14 +310,6 @@ static void xirc2ps_detach(dev_link_t *);
313 310
314static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs); 311static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id, struct pt_regs *regs);
315 312
316/*
317 * The dev_info variable is the "key" that is used to match up this
318 * device driver with appropriate cards, through the card configuration
319 * database.
320 */
321
322static dev_info_t dev_info = "xirc2ps_cs";
323
324/**************** 313/****************
325 * A linked list of "instances" of the device. Each actual 314 * A linked list of "instances" of the device. Each actual
326 * PCMCIA card corresponds to one device instance, and is described 315 * PCMCIA card corresponds to one device instance, and is described
@@ -331,15 +320,7 @@ static dev_info_t dev_info = "xirc2ps_cs";
331 * device numbers are used to derive the corresponding array index. 320 * device numbers are used to derive the corresponding array index.
332 */ 321 */
333 322
334static dev_link_t *dev_list;
335
336/**************** 323/****************
337 * A dev_link_t structure has fields for most things that are needed
338 * to keep track of a socket, but there will usually be some device
339 * specific information that also needs to be kept track of. The
340 * 'priv' pointer in a dev_link_t structure can be used to point to
341 * a device-specific private data structure, like this.
342 *
343 * A driver needs to provide a dev_node_t structure for each device 324 * A driver needs to provide a dev_node_t structure for each device
344 * on a card. In some cases, there is only one device per card (for 325 * on a card. In some cases, there is only one device per card (for
345 * example, ethernet cards, modems). In other cases, there may be 326 * example, ethernet cards, modems). In other cases, there may be
@@ -571,21 +552,19 @@ mii_wr(kio_addr_t ioaddr, u_char phyaddr, u_char phyreg, unsigned data, int len)
571 * card insertion event. 552 * card insertion event.
572 */ 553 */
573 554
574static dev_link_t * 555static int
575xirc2ps_attach(void) 556xirc2ps_attach(struct pcmcia_device *p_dev)
576{ 557{
577 client_reg_t client_reg;
578 dev_link_t *link; 558 dev_link_t *link;
579 struct net_device *dev; 559 struct net_device *dev;
580 local_info_t *local; 560 local_info_t *local;
581 int err;
582 561
583 DEBUG(0, "attach()\n"); 562 DEBUG(0, "attach()\n");
584 563
585 /* Allocate the device structure */ 564 /* Allocate the device structure */
586 dev = alloc_etherdev(sizeof(local_info_t)); 565 dev = alloc_etherdev(sizeof(local_info_t));
587 if (!dev) 566 if (!dev)
588 return NULL; 567 return -ENOMEM;
589 local = netdev_priv(dev); 568 local = netdev_priv(dev);
590 link = &local->link; 569 link = &local->link;
591 link->priv = dev; 570 link->priv = dev;
@@ -614,19 +593,13 @@ xirc2ps_attach(void)
614 dev->watchdog_timeo = TX_TIMEOUT; 593 dev->watchdog_timeo = TX_TIMEOUT;
615#endif 594#endif
616 595
617 /* Register with Card Services */ 596 link->handle = p_dev;
618 link->next = dev_list; 597 p_dev->instance = link;
619 dev_list = link; 598
620 client_reg.dev_info = &dev_info; 599 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
621 client_reg.Version = 0x0210; 600 xirc2ps_config(link);
622 client_reg.event_callback_args.client_data = link;
623 if ((err = pcmcia_register_client(&link->handle, &client_reg))) {
624 cs_error(link->handle, RegisterClient, err);
625 xirc2ps_detach(link);
626 return NULL;
627 }
628 601
629 return link; 602 return 0;
630} /* xirc2ps_attach */ 603} /* xirc2ps_attach */
631 604
632/**************** 605/****************
@@ -637,40 +610,19 @@ xirc2ps_attach(void)
637 */ 610 */
638 611
639static void 612static void
640xirc2ps_detach(dev_link_t * link) 613xirc2ps_detach(struct pcmcia_device *p_dev)
641{ 614{
615 dev_link_t *link = dev_to_instance(p_dev);
642 struct net_device *dev = link->priv; 616 struct net_device *dev = link->priv;
643 dev_link_t **linkp;
644 617
645 DEBUG(0, "detach(0x%p)\n", link); 618 DEBUG(0, "detach(0x%p)\n", link);
646 619
647 /* Locate device structure */
648 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
649 if (*linkp == link)
650 break;
651 if (!*linkp) {
652 DEBUG(0, "detach(0x%p): dev_link lost\n", link);
653 return;
654 }
655
656 if (link->dev) 620 if (link->dev)
657 unregister_netdev(dev); 621 unregister_netdev(dev);
658 622
659 /*
660 * If the device is currently configured and active, we won't
661 * actually delete it yet. Instead, it is marked so that when
662 * the release() function is called, that will trigger a proper
663 * detach().
664 */
665 if (link->state & DEV_CONFIG) 623 if (link->state & DEV_CONFIG)
666 xirc2ps_release(link); 624 xirc2ps_release(link);
667 625
668 /* Break the link with Card Services */
669 if (link->handle)
670 pcmcia_deregister_client(link->handle);
671
672 /* Unlink device structure, free it */
673 *linkp = link->next;
674 free_netdev(dev); 626 free_netdev(dev);
675} /* xirc2ps_detach */ 627} /* xirc2ps_detach */
676 628
@@ -1157,67 +1109,41 @@ xirc2ps_release(dev_link_t *link)
1157 1109
1158/*====================================================================*/ 1110/*====================================================================*/
1159 1111
1160/****************
1161 * The card status event handler. Mostly, this schedules other
1162 * stuff to run after an event is received. A CARD_REMOVAL event
1163 * also sets some flags to discourage the net drivers from trying
1164 * to talk to the card any more.
1165 *
1166 * When a CARD_REMOVAL event is received, we immediately set a flag
1167 * to block future accesses to this device. All the functions that
1168 * actually access the device should check this flag to make sure
1169 * the card is still present.
1170 */
1171 1112
1172static int 1113static int xirc2ps_suspend(struct pcmcia_device *p_dev)
1173xirc2ps_event(event_t event, int priority,
1174 event_callback_args_t * args)
1175{ 1114{
1176 dev_link_t *link = args->client_data; 1115 dev_link_t *link = dev_to_instance(p_dev);
1177 struct net_device *dev = link->priv; 1116 struct net_device *dev = link->priv;
1178
1179 DEBUG(0, "event(%d)\n", (int)event);
1180 1117
1181 switch (event) {
1182 case CS_EVENT_REGISTRATION_COMPLETE:
1183 DEBUG(0, "registration complete\n");
1184 break;
1185 case CS_EVENT_CARD_REMOVAL:
1186 link->state &= ~DEV_PRESENT;
1187 if (link->state & DEV_CONFIG)
1188 netif_device_detach(dev);
1189 break;
1190 case CS_EVENT_CARD_INSERTION:
1191 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1192 xirc2ps_config(link);
1193 break;
1194 case CS_EVENT_PM_SUSPEND:
1195 link->state |= DEV_SUSPEND; 1118 link->state |= DEV_SUSPEND;
1196 /* Fall through... */
1197 case CS_EVENT_RESET_PHYSICAL:
1198 if (link->state & DEV_CONFIG) { 1119 if (link->state & DEV_CONFIG) {
1199 if (link->open) { 1120 if (link->open) {
1200 netif_device_detach(dev); 1121 netif_device_detach(dev);
1201 do_powerdown(dev); 1122 do_powerdown(dev);
1202 } 1123 }
1203 pcmcia_release_configuration(link->handle); 1124 pcmcia_release_configuration(link->handle);
1204 } 1125 }
1205 break; 1126
1206 case CS_EVENT_PM_RESUME: 1127 return 0;
1128}
1129
1130static int xirc2ps_resume(struct pcmcia_device *p_dev)
1131{
1132 dev_link_t *link = dev_to_instance(p_dev);
1133 struct net_device *dev = link->priv;
1134
1207 link->state &= ~DEV_SUSPEND; 1135 link->state &= ~DEV_SUSPEND;
1208 /* Fall through... */
1209 case CS_EVENT_CARD_RESET:
1210 if (link->state & DEV_CONFIG) { 1136 if (link->state & DEV_CONFIG) {
1211 pcmcia_request_configuration(link->handle, &link->conf); 1137 pcmcia_request_configuration(link->handle, &link->conf);
1212 if (link->open) { 1138 if (link->open) {
1213 do_reset(dev,1); 1139 do_reset(dev,1);
1214 netif_device_attach(dev); 1140 netif_device_attach(dev);
1215 } 1141 }
1216 } 1142 }
1217 break; 1143
1218 } 1144 return 0;
1219 return 0; 1145}
1220} /* xirc2ps_event */ 1146
1221 1147
1222/*====================================================================*/ 1148/*====================================================================*/
1223 1149
@@ -2009,10 +1935,11 @@ static struct pcmcia_driver xirc2ps_cs_driver = {
2009 .drv = { 1935 .drv = {
2010 .name = "xirc2ps_cs", 1936 .name = "xirc2ps_cs",
2011 }, 1937 },
2012 .attach = xirc2ps_attach, 1938 .probe = xirc2ps_attach,
2013 .event = xirc2ps_event, 1939 .remove = xirc2ps_detach,
2014 .detach = xirc2ps_detach,
2015 .id_table = xirc2ps_ids, 1940 .id_table = xirc2ps_ids,
1941 .suspend = xirc2ps_suspend,
1942 .resume = xirc2ps_resume,
2016}; 1943};
2017 1944
2018static int __init 1945static int __init
@@ -2025,7 +1952,6 @@ static void __exit
2025exit_xirc2ps_cs(void) 1952exit_xirc2ps_cs(void)
2026{ 1953{
2027 pcmcia_unregister_driver(&xirc2ps_cs_driver); 1954 pcmcia_unregister_driver(&xirc2ps_cs_driver);
2028 BUG_ON(dev_list != NULL);
2029} 1955}
2030 1956
2031module_init(init_xirc2ps_cs); 1957module_init(init_xirc2ps_cs);
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index be319229f543..8f6cf8c896a4 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1251,12 +1251,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1251 1251
1252 if (memcmp(promaddr, dev->dev_addr, 6) 1252 if (memcmp(promaddr, dev->dev_addr, 6)
1253 || !is_valid_ether_addr(dev->dev_addr)) { 1253 || !is_valid_ether_addr(dev->dev_addr)) {
1254#ifndef __powerpc__
1255 if (is_valid_ether_addr(promaddr)) { 1254 if (is_valid_ether_addr(promaddr)) {
1256#else
1257 if (!is_valid_ether_addr(dev->dev_addr)
1258 && is_valid_ether_addr(promaddr)) {
1259#endif
1260 if (pcnet32_debug & NETIF_MSG_PROBE) { 1255 if (pcnet32_debug & NETIF_MSG_PROBE) {
1261 printk(" warning: CSR address invalid,\n"); 1256 printk(" warning: CSR address invalid,\n");
1262 printk(KERN_INFO " using instead PROM address of"); 1257 printk(KERN_INFO " using instead PROM address of");
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index c782a6329805..fa39b944bc46 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -6,7 +6,7 @@ menu "PHY device support"
6 6
7config PHYLIB 7config PHYLIB
8 tristate "PHY Device support and infrastructure" 8 tristate "PHY Device support and infrastructure"
9 depends on NET_ETHERNET && (BROKEN || !ARCH_S390) 9 depends on NET_ETHERNET && (BROKEN || !S390)
10 help 10 help
11 Ethernet controllers are usually attached to PHY 11 Ethernet controllers are usually attached to PHY
12 devices. This option provides infrastructure for 12 devices. This option provides infrastructure for
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 16bebe7a7ce1..7da0e3dd5fe3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -38,6 +38,10 @@
38#include <asm/irq.h> 38#include <asm/irq.h>
39#include <asm/uaccess.h> 39#include <asm/uaccess.h>
40 40
41MODULE_DESCRIPTION("PHY library");
42MODULE_AUTHOR("Andy Fleming");
43MODULE_LICENSE("GPL");
44
41static struct phy_driver genphy_driver; 45static struct phy_driver genphy_driver;
42extern int mdio_bus_init(void); 46extern int mdio_bus_init(void);
43extern void mdio_bus_exit(void); 47extern void mdio_bus_exit(void);
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 1bd22cd40c75..87ee3271b17d 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -98,7 +98,6 @@ static const char version[] = "NET3 PLIP version 2.4-parport gniibe@mri.co.jp\n"
98#include <linux/in.h> 98#include <linux/in.h>
99#include <linux/errno.h> 99#include <linux/errno.h>
100#include <linux/delay.h> 100#include <linux/delay.h>
101#include <linux/lp.h>
102#include <linux/init.h> 101#include <linux/init.h>
103#include <linux/netdevice.h> 102#include <linux/netdevice.h>
104#include <linux/etherdevice.h> 103#include <linux/etherdevice.h>
@@ -106,7 +105,6 @@ static const char version[] = "NET3 PLIP version 2.4-parport gniibe@mri.co.jp\n"
106#include <linux/skbuff.h> 105#include <linux/skbuff.h>
107#include <linux/if_plip.h> 106#include <linux/if_plip.h>
108#include <linux/workqueue.h> 107#include <linux/workqueue.h>
109#include <linux/ioport.h>
110#include <linux/spinlock.h> 108#include <linux/spinlock.h>
111#include <linux/parport.h> 109#include <linux/parport.h>
112#include <linux/bitops.h> 110#include <linux/bitops.h>
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 50430f79f8cf..1c6d328165bb 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -524,9 +524,6 @@ static int get_filter(void __user *arg, struct sock_filter **p)
524 if (copy_from_user(&uprog, arg, sizeof(uprog))) 524 if (copy_from_user(&uprog, arg, sizeof(uprog)))
525 return -EFAULT; 525 return -EFAULT;
526 526
527 if (uprog.len > BPF_MAXINSNS)
528 return -EINVAL;
529
530 if (!uprog.len) { 527 if (!uprog.len) {
531 *p = NULL; 528 *p = NULL;
532 return 0; 529 return 0;
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index a842ecc60a34..9369f811075d 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -85,7 +85,7 @@ static int pppoe_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
85static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb); 85static int pppoe_xmit(struct ppp_channel *chan, struct sk_buff *skb);
86static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb); 86static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb);
87 87
88static struct proto_ops pppoe_ops; 88static const struct proto_ops pppoe_ops;
89static DEFINE_RWLOCK(pppoe_hash_lock); 89static DEFINE_RWLOCK(pppoe_hash_lock);
90 90
91static struct ppp_channel_ops pppoe_chan_ops; 91static struct ppp_channel_ops pppoe_chan_ops;
@@ -383,8 +383,6 @@ static int pppoe_rcv(struct sk_buff *skb,
383{ 383{
384 struct pppoe_hdr *ph; 384 struct pppoe_hdr *ph;
385 struct pppox_sock *po; 385 struct pppox_sock *po;
386 struct sock *sk;
387 int ret;
388 386
389 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr))) 387 if (!pskb_may_pull(skb, sizeof(struct pppoe_hdr)))
390 goto drop; 388 goto drop;
@@ -395,24 +393,8 @@ static int pppoe_rcv(struct sk_buff *skb,
395 ph = (struct pppoe_hdr *) skb->nh.raw; 393 ph = (struct pppoe_hdr *) skb->nh.raw;
396 394
397 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source); 395 po = get_item((unsigned long) ph->sid, eth_hdr(skb)->h_source);
398 if (!po) 396 if (po != NULL)
399 goto drop; 397 return sk_receive_skb(sk_pppox(po), skb);
400
401 sk = sk_pppox(po);
402 bh_lock_sock(sk);
403
404 /* Socket state is unknown, must put skb into backlog. */
405 if (sock_owned_by_user(sk) != 0) {
406 sk_add_backlog(sk, skb);
407 ret = NET_RX_SUCCESS;
408 } else {
409 ret = pppoe_rcv_core(sk, skb);
410 }
411
412 bh_unlock_sock(sk);
413 sock_put(sk);
414
415 return ret;
416drop: 398drop:
417 kfree_skb(skb); 399 kfree_skb(skb);
418out: 400out:
@@ -1081,9 +1063,7 @@ static int __init pppoe_proc_init(void)
1081static inline int pppoe_proc_init(void) { return 0; } 1063static inline int pppoe_proc_init(void) { return 0; }
1082#endif /* CONFIG_PROC_FS */ 1064#endif /* CONFIG_PROC_FS */
1083 1065
1084/* ->ioctl are set at pppox_create */ 1066static const struct proto_ops pppoe_ops = {
1085
1086static struct proto_ops pppoe_ops = {
1087 .family = AF_PPPOX, 1067 .family = AF_PPPOX,
1088 .owner = THIS_MODULE, 1068 .owner = THIS_MODULE,
1089 .release = pppoe_release, 1069 .release = pppoe_release,
@@ -1099,7 +1079,8 @@ static struct proto_ops pppoe_ops = {
1099 .getsockopt = sock_no_getsockopt, 1079 .getsockopt = sock_no_getsockopt,
1100 .sendmsg = pppoe_sendmsg, 1080 .sendmsg = pppoe_sendmsg,
1101 .recvmsg = pppoe_recvmsg, 1081 .recvmsg = pppoe_recvmsg,
1102 .mmap = sock_no_mmap 1082 .mmap = sock_no_mmap,
1083 .ioctl = pppox_ioctl,
1103}; 1084};
1104 1085
1105static struct pppox_proto pppoe_proto = { 1086static struct pppox_proto pppoe_proto = {
diff --git a/drivers/net/pppox.c b/drivers/net/pppox.c
index 0c1e114527fb..9315046b3f55 100644
--- a/drivers/net/pppox.c
+++ b/drivers/net/pppox.c
@@ -68,8 +68,7 @@ EXPORT_SYMBOL(register_pppox_proto);
68EXPORT_SYMBOL(unregister_pppox_proto); 68EXPORT_SYMBOL(unregister_pppox_proto);
69EXPORT_SYMBOL(pppox_unbind_sock); 69EXPORT_SYMBOL(pppox_unbind_sock);
70 70
71static int pppox_ioctl(struct socket* sock, unsigned int cmd, 71int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
72 unsigned long arg)
73{ 72{
74 struct sock *sk = sock->sk; 73 struct sock *sk = sock->sk;
75 struct pppox_sock *po = pppox_sk(sk); 74 struct pppox_sock *po = pppox_sk(sk);
@@ -105,6 +104,7 @@ static int pppox_ioctl(struct socket* sock, unsigned int cmd,
105 return rc; 104 return rc;
106} 105}
107 106
107EXPORT_SYMBOL(pppox_ioctl);
108 108
109static int pppox_create(struct socket *sock, int protocol) 109static int pppox_create(struct socket *sock, int protocol)
110{ 110{
@@ -119,11 +119,7 @@ static int pppox_create(struct socket *sock, int protocol)
119 goto out; 119 goto out;
120 120
121 rc = pppox_protos[protocol]->create(sock); 121 rc = pppox_protos[protocol]->create(sock);
122 if (!rc) { 122
123 /* We get to set the ioctl handler. */
124 /* For everything else, pppox is just a shell. */
125 sock->ops->ioctl = pppox_ioctl;
126 }
127 module_put(pppox_protos[protocol]->owner); 123 module_put(pppox_protos[protocol]->owner);
128out: 124out:
129 return rc; 125 return rc;
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index e57df8dfe6b4..89c46787676c 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -66,7 +66,7 @@
66#include "s2io.h" 66#include "s2io.h"
67#include "s2io-regs.h" 67#include "s2io-regs.h"
68 68
69#define DRV_VERSION "Version 2.0.9.3" 69#define DRV_VERSION "Version 2.0.9.4"
70 70
71/* S2io Driver name & version. */ 71/* S2io Driver name & version. */
72static char s2io_driver_name[] = "Neterion"; 72static char s2io_driver_name[] = "Neterion";
@@ -412,7 +412,7 @@ static int init_shared_mem(struct s2io_nic *nic)
412 config->tx_cfg[i].fifo_len - 1; 412 config->tx_cfg[i].fifo_len - 1;
413 mac_control->fifos[i].fifo_no = i; 413 mac_control->fifos[i].fifo_no = i;
414 mac_control->fifos[i].nic = nic; 414 mac_control->fifos[i].nic = nic;
415 mac_control->fifos[i].max_txds = MAX_SKB_FRAGS + 1; 415 mac_control->fifos[i].max_txds = MAX_SKB_FRAGS + 2;
416 416
417 for (j = 0; j < page_num; j++) { 417 for (j = 0; j < page_num; j++) {
418 int k = 0; 418 int k = 0;
@@ -459,6 +459,10 @@ static int init_shared_mem(struct s2io_nic *nic)
459 } 459 }
460 } 460 }
461 461
462 nic->ufo_in_band_v = kmalloc((sizeof(u64) * size), GFP_KERNEL);
463 if (!nic->ufo_in_band_v)
464 return -ENOMEM;
465
462 /* Allocation and initialization of RXDs in Rings */ 466 /* Allocation and initialization of RXDs in Rings */
463 size = 0; 467 size = 0;
464 for (i = 0; i < config->rx_ring_num; i++) { 468 for (i = 0; i < config->rx_ring_num; i++) {
@@ -731,6 +735,8 @@ static void free_shared_mem(struct s2io_nic *nic)
731 mac_control->stats_mem, 735 mac_control->stats_mem,
732 mac_control->stats_mem_phy); 736 mac_control->stats_mem_phy);
733 } 737 }
738 if (nic->ufo_in_band_v)
739 kfree(nic->ufo_in_band_v);
734} 740}
735 741
736/** 742/**
@@ -2003,6 +2009,49 @@ static int start_nic(struct s2io_nic *nic)
2003 2009
2004 return SUCCESS; 2010 return SUCCESS;
2005} 2011}
2012/**
2013 * s2io_txdl_getskb - Get the skb from txdl, unmap and return skb
2014 */
2015static struct sk_buff *s2io_txdl_getskb(fifo_info_t *fifo_data, TxD_t *txdlp, int get_off)
2016{
2017 nic_t *nic = fifo_data->nic;
2018 struct sk_buff *skb;
2019 TxD_t *txds;
2020 u16 j, frg_cnt;
2021
2022 txds = txdlp;
2023 if (txds->Host_Control == (u64)(long)nic->ufo_in_band_v) {
2024 pci_unmap_single(nic->pdev, (dma_addr_t)
2025 txds->Buffer_Pointer, sizeof(u64),
2026 PCI_DMA_TODEVICE);
2027 txds++;
2028 }
2029
2030 skb = (struct sk_buff *) ((unsigned long)
2031 txds->Host_Control);
2032 if (!skb) {
2033 memset(txdlp, 0, (sizeof(TxD_t) * fifo_data->max_txds));
2034 return NULL;
2035 }
2036 pci_unmap_single(nic->pdev, (dma_addr_t)
2037 txds->Buffer_Pointer,
2038 skb->len - skb->data_len,
2039 PCI_DMA_TODEVICE);
2040 frg_cnt = skb_shinfo(skb)->nr_frags;
2041 if (frg_cnt) {
2042 txds++;
2043 for (j = 0; j < frg_cnt; j++, txds++) {
2044 skb_frag_t *frag = &skb_shinfo(skb)->frags[j];
2045 if (!txds->Buffer_Pointer)
2046 break;
2047 pci_unmap_page(nic->pdev, (dma_addr_t)
2048 txds->Buffer_Pointer,
2049 frag->size, PCI_DMA_TODEVICE);
2050 }
2051 }
2052 txdlp->Host_Control = 0;
2053 return(skb);
2054}
2006 2055
2007/** 2056/**
2008 * free_tx_buffers - Free all queued Tx buffers 2057 * free_tx_buffers - Free all queued Tx buffers
@@ -2020,7 +2069,7 @@ static void free_tx_buffers(struct s2io_nic *nic)
2020 int i, j; 2069 int i, j;
2021 mac_info_t *mac_control; 2070 mac_info_t *mac_control;
2022 struct config_param *config; 2071 struct config_param *config;
2023 int cnt = 0, frg_cnt; 2072 int cnt = 0;
2024 2073
2025 mac_control = &nic->mac_control; 2074 mac_control = &nic->mac_control;
2026 config = &nic->config; 2075 config = &nic->config;
@@ -2029,38 +2078,11 @@ static void free_tx_buffers(struct s2io_nic *nic)
2029 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) { 2078 for (j = 0; j < config->tx_cfg[i].fifo_len - 1; j++) {
2030 txdp = (TxD_t *) mac_control->fifos[i].list_info[j]. 2079 txdp = (TxD_t *) mac_control->fifos[i].list_info[j].
2031 list_virt_addr; 2080 list_virt_addr;
2032 skb = 2081 skb = s2io_txdl_getskb(&mac_control->fifos[i], txdp, j);
2033 (struct sk_buff *) ((unsigned long) txdp-> 2082 if (skb) {
2034 Host_Control); 2083 dev_kfree_skb(skb);
2035 if (skb == NULL) { 2084 cnt++;
2036 memset(txdp, 0, sizeof(TxD_t) *
2037 config->max_txds);
2038 continue;
2039 } 2085 }
2040 frg_cnt = skb_shinfo(skb)->nr_frags;
2041 pci_unmap_single(nic->pdev, (dma_addr_t)
2042 txdp->Buffer_Pointer,
2043 skb->len - skb->data_len,
2044 PCI_DMA_TODEVICE);
2045 if (frg_cnt) {
2046 TxD_t *temp;
2047 temp = txdp;
2048 txdp++;
2049 for (j = 0; j < frg_cnt; j++, txdp++) {
2050 skb_frag_t *frag =
2051 &skb_shinfo(skb)->frags[j];
2052 pci_unmap_page(nic->pdev,
2053 (dma_addr_t)
2054 txdp->
2055 Buffer_Pointer,
2056 frag->size,
2057 PCI_DMA_TODEVICE);
2058 }
2059 txdp = temp;
2060 }
2061 dev_kfree_skb(skb);
2062 memset(txdp, 0, sizeof(TxD_t) * config->max_txds);
2063 cnt++;
2064 } 2086 }
2065 DBG_PRINT(INTR_DBG, 2087 DBG_PRINT(INTR_DBG,
2066 "%s:forcibly freeing %d skbs on FIFO%d\n", 2088 "%s:forcibly freeing %d skbs on FIFO%d\n",
@@ -2661,7 +2683,6 @@ static void tx_intr_handler(fifo_info_t *fifo_data)
2661 tx_curr_get_info_t get_info, put_info; 2683 tx_curr_get_info_t get_info, put_info;
2662 struct sk_buff *skb; 2684 struct sk_buff *skb;
2663 TxD_t *txdlp; 2685 TxD_t *txdlp;
2664 u16 j, frg_cnt;
2665 2686
2666 get_info = fifo_data->tx_curr_get_info; 2687 get_info = fifo_data->tx_curr_get_info;
2667 put_info = fifo_data->tx_curr_put_info; 2688 put_info = fifo_data->tx_curr_put_info;
@@ -2684,8 +2705,7 @@ to loss of link\n");
2684 } 2705 }
2685 } 2706 }
2686 2707
2687 skb = (struct sk_buff *) ((unsigned long) 2708 skb = s2io_txdl_getskb(fifo_data, txdlp, get_info.offset);
2688 txdlp->Host_Control);
2689 if (skb == NULL) { 2709 if (skb == NULL) {
2690 DBG_PRINT(ERR_DBG, "%s: Null skb ", 2710 DBG_PRINT(ERR_DBG, "%s: Null skb ",
2691 __FUNCTION__); 2711 __FUNCTION__);
@@ -2693,34 +2713,6 @@ to loss of link\n");
2693 return; 2713 return;
2694 } 2714 }
2695 2715
2696 frg_cnt = skb_shinfo(skb)->nr_frags;
2697 nic->tx_pkt_count++;
2698
2699 pci_unmap_single(nic->pdev, (dma_addr_t)
2700 txdlp->Buffer_Pointer,
2701 skb->len - skb->data_len,
2702 PCI_DMA_TODEVICE);
2703 if (frg_cnt) {
2704 TxD_t *temp;
2705 temp = txdlp;
2706 txdlp++;
2707 for (j = 0; j < frg_cnt; j++, txdlp++) {
2708 skb_frag_t *frag =
2709 &skb_shinfo(skb)->frags[j];
2710 if (!txdlp->Buffer_Pointer)
2711 break;
2712 pci_unmap_page(nic->pdev,
2713 (dma_addr_t)
2714 txdlp->
2715 Buffer_Pointer,
2716 frag->size,
2717 PCI_DMA_TODEVICE);
2718 }
2719 txdlp = temp;
2720 }
2721 memset(txdlp, 0,
2722 (sizeof(TxD_t) * fifo_data->max_txds));
2723
2724 /* Updating the statistics block */ 2716 /* Updating the statistics block */
2725 nic->stats.tx_bytes += skb->len; 2717 nic->stats.tx_bytes += skb->len;
2726 dev_kfree_skb_irq(skb); 2718 dev_kfree_skb_irq(skb);
@@ -3078,7 +3070,7 @@ int s2io_set_swapper(nic_t * sp)
3078 3070
3079static int wait_for_msix_trans(nic_t *nic, int i) 3071static int wait_for_msix_trans(nic_t *nic, int i)
3080{ 3072{
3081 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3073 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3082 u64 val64; 3074 u64 val64;
3083 int ret = 0, cnt = 0; 3075 int ret = 0, cnt = 0;
3084 3076
@@ -3099,7 +3091,7 @@ static int wait_for_msix_trans(nic_t *nic, int i)
3099 3091
3100void restore_xmsi_data(nic_t *nic) 3092void restore_xmsi_data(nic_t *nic)
3101{ 3093{
3102 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3094 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3103 u64 val64; 3095 u64 val64;
3104 int i; 3096 int i;
3105 3097
@@ -3117,7 +3109,7 @@ void restore_xmsi_data(nic_t *nic)
3117 3109
3118static void store_xmsi_data(nic_t *nic) 3110static void store_xmsi_data(nic_t *nic)
3119{ 3111{
3120 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3112 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3121 u64 val64, addr, data; 3113 u64 val64, addr, data;
3122 int i; 3114 int i;
3123 3115
@@ -3140,7 +3132,7 @@ static void store_xmsi_data(nic_t *nic)
3140 3132
3141int s2io_enable_msi(nic_t *nic) 3133int s2io_enable_msi(nic_t *nic)
3142{ 3134{
3143 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3135 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3144 u16 msi_ctrl, msg_val; 3136 u16 msi_ctrl, msg_val;
3145 struct config_param *config = &nic->config; 3137 struct config_param *config = &nic->config;
3146 struct net_device *dev = nic->dev; 3138 struct net_device *dev = nic->dev;
@@ -3190,7 +3182,7 @@ int s2io_enable_msi(nic_t *nic)
3190 3182
3191int s2io_enable_msi_x(nic_t *nic) 3183int s2io_enable_msi_x(nic_t *nic)
3192{ 3184{
3193 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3185 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3194 u64 tx_mat, rx_mat; 3186 u64 tx_mat, rx_mat;
3195 u16 msi_control; /* Temp variable */ 3187 u16 msi_control; /* Temp variable */
3196 int ret, i, j, msix_indx = 1; 3188 int ret, i, j, msix_indx = 1;
@@ -3331,7 +3323,7 @@ failed\n", dev->name);
3331 s2io_msix_fifo_handle, 0, sp->desc1, 3323 s2io_msix_fifo_handle, 0, sp->desc1,
3332 sp->s2io_entries[i].arg); 3324 sp->s2io_entries[i].arg);
3333 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc1, 3325 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc1,
3334 sp->msix_info[i].addr); 3326 (unsigned long long)sp->msix_info[i].addr);
3335 } else { 3327 } else {
3336 sprintf(sp->desc2, "%s:MSI-X-%d-RX", 3328 sprintf(sp->desc2, "%s:MSI-X-%d-RX",
3337 dev->name, i); 3329 dev->name, i);
@@ -3339,7 +3331,7 @@ failed\n", dev->name);
3339 s2io_msix_ring_handle, 0, sp->desc2, 3331 s2io_msix_ring_handle, 0, sp->desc2,
3340 sp->s2io_entries[i].arg); 3332 sp->s2io_entries[i].arg);
3341 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc2, 3333 DBG_PRINT(ERR_DBG, "%s @ 0x%llx\n", sp->desc2,
3342 sp->msix_info[i].addr); 3334 (unsigned long long)sp->msix_info[i].addr);
3343 } 3335 }
3344 if (err) { 3336 if (err) {
3345 DBG_PRINT(ERR_DBG, "%s: MSI-X-%d registration \ 3337 DBG_PRINT(ERR_DBG, "%s: MSI-X-%d registration \
@@ -3527,6 +3519,8 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3527 return 0; 3519 return 0;
3528 } 3520 }
3529 3521
3522 txdp->Control_1 = 0;
3523 txdp->Control_2 = 0;
3530#ifdef NETIF_F_TSO 3524#ifdef NETIF_F_TSO
3531 mss = skb_shinfo(skb)->tso_size; 3525 mss = skb_shinfo(skb)->tso_size;
3532 if (mss) { 3526 if (mss) {
@@ -3534,19 +3528,13 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3534 txdp->Control_1 |= TXD_TCP_LSO_MSS(mss); 3528 txdp->Control_1 |= TXD_TCP_LSO_MSS(mss);
3535 } 3529 }
3536#endif 3530#endif
3537
3538 frg_cnt = skb_shinfo(skb)->nr_frags;
3539 frg_len = skb->len - skb->data_len;
3540
3541 txdp->Buffer_Pointer = pci_map_single
3542 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
3543 txdp->Host_Control = (unsigned long) skb;
3544 if (skb->ip_summed == CHECKSUM_HW) { 3531 if (skb->ip_summed == CHECKSUM_HW) {
3545 txdp->Control_2 |= 3532 txdp->Control_2 |=
3546 (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN | 3533 (TXD_TX_CKO_IPV4_EN | TXD_TX_CKO_TCP_EN |
3547 TXD_TX_CKO_UDP_EN); 3534 TXD_TX_CKO_UDP_EN);
3548 } 3535 }
3549 3536 txdp->Control_1 |= TXD_GATHER_CODE_FIRST;
3537 txdp->Control_1 |= TXD_LIST_OWN_XENA;
3550 txdp->Control_2 |= config->tx_intr_type; 3538 txdp->Control_2 |= config->tx_intr_type;
3551 3539
3552 if (sp->vlgrp && vlan_tx_tag_present(skb)) { 3540 if (sp->vlgrp && vlan_tx_tag_present(skb)) {
@@ -3554,10 +3542,40 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3554 txdp->Control_2 |= TXD_VLAN_TAG(vlan_tag); 3542 txdp->Control_2 |= TXD_VLAN_TAG(vlan_tag);
3555 } 3543 }
3556 3544
3557 txdp->Control_1 |= (TXD_BUFFER0_SIZE(frg_len) | 3545 frg_len = skb->len - skb->data_len;
3558 TXD_GATHER_CODE_FIRST); 3546 if (skb_shinfo(skb)->ufo_size) {
3559 txdp->Control_1 |= TXD_LIST_OWN_XENA; 3547 int ufo_size;
3548
3549 ufo_size = skb_shinfo(skb)->ufo_size;
3550 ufo_size &= ~7;
3551 txdp->Control_1 |= TXD_UFO_EN;
3552 txdp->Control_1 |= TXD_UFO_MSS(ufo_size);
3553 txdp->Control_1 |= TXD_BUFFER0_SIZE(8);
3554#ifdef __BIG_ENDIAN
3555 sp->ufo_in_band_v[put_off] =
3556 (u64)skb_shinfo(skb)->ip6_frag_id;
3557#else
3558 sp->ufo_in_band_v[put_off] =
3559 (u64)skb_shinfo(skb)->ip6_frag_id << 32;
3560#endif
3561 txdp->Host_Control = (unsigned long)sp->ufo_in_band_v;
3562 txdp->Buffer_Pointer = pci_map_single(sp->pdev,
3563 sp->ufo_in_band_v,
3564 sizeof(u64), PCI_DMA_TODEVICE);
3565 txdp++;
3566 txdp->Control_1 = 0;
3567 txdp->Control_2 = 0;
3568 }
3560 3569
3570 txdp->Buffer_Pointer = pci_map_single
3571 (sp->pdev, skb->data, frg_len, PCI_DMA_TODEVICE);
3572 txdp->Host_Control = (unsigned long) skb;
3573 txdp->Control_1 |= TXD_BUFFER0_SIZE(frg_len);
3574
3575 if (skb_shinfo(skb)->ufo_size)
3576 txdp->Control_1 |= TXD_UFO_EN;
3577
3578 frg_cnt = skb_shinfo(skb)->nr_frags;
3561 /* For fragmented SKB. */ 3579 /* For fragmented SKB. */
3562 for (i = 0; i < frg_cnt; i++) { 3580 for (i = 0; i < frg_cnt; i++) {
3563 skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; 3581 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
@@ -3569,9 +3587,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3569 (sp->pdev, frag->page, frag->page_offset, 3587 (sp->pdev, frag->page, frag->page_offset,
3570 frag->size, PCI_DMA_TODEVICE); 3588 frag->size, PCI_DMA_TODEVICE);
3571 txdp->Control_1 |= TXD_BUFFER0_SIZE(frag->size); 3589 txdp->Control_1 |= TXD_BUFFER0_SIZE(frag->size);
3590 if (skb_shinfo(skb)->ufo_size)
3591 txdp->Control_1 |= TXD_UFO_EN;
3572 } 3592 }
3573 txdp->Control_1 |= TXD_GATHER_CODE_LAST; 3593 txdp->Control_1 |= TXD_GATHER_CODE_LAST;
3574 3594
3595 if (skb_shinfo(skb)->ufo_size)
3596 frg_cnt++; /* as Txd0 was used for inband header */
3597
3575 tx_fifo = mac_control->tx_FIFO_start[queue]; 3598 tx_fifo = mac_control->tx_FIFO_start[queue];
3576 val64 = mac_control->fifos[queue].list_info[put_off].list_phy_addr; 3599 val64 = mac_control->fifos[queue].list_info[put_off].list_phy_addr;
3577 writeq(val64, &tx_fifo->TxDL_Pointer); 3600 writeq(val64, &tx_fifo->TxDL_Pointer);
@@ -3583,6 +3606,8 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev)
3583 if (mss) 3606 if (mss)
3584 val64 |= TX_FIFO_SPECIAL_FUNC; 3607 val64 |= TX_FIFO_SPECIAL_FUNC;
3585#endif 3608#endif
3609 if (skb_shinfo(skb)->ufo_size)
3610 val64 |= TX_FIFO_SPECIAL_FUNC;
3586 writeq(val64, &tx_fifo->List_Control); 3611 writeq(val64, &tx_fifo->List_Control);
3587 3612
3588 mmiowb(); 3613 mmiowb();
@@ -4721,7 +4746,10 @@ static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
4721 fail = 1; 4746 fail = 1;
4722 4747
4723 if (ret_data != 0x012345) { 4748 if (ret_data != 0x012345) {
4724 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x4F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data); 4749 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x4F0. "
4750 "Data written %llx Data read %llx\n",
4751 dev->name, (unsigned long long)0x12345,
4752 (unsigned long long)ret_data);
4725 fail = 1; 4753 fail = 1;
4726 } 4754 }
4727 4755
@@ -4740,7 +4768,10 @@ static int s2io_eeprom_test(nic_t * sp, uint64_t * data)
4740 fail = 1; 4768 fail = 1;
4741 4769
4742 if (ret_data != 0x012345) { 4770 if (ret_data != 0x012345) {
4743 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x7F0. Data written %llx Data read %llx\n", dev->name, (u64)0x12345, ret_data); 4771 DBG_PRINT(ERR_DBG, "%s: eeprom test error at offset 0x7F0. "
4772 "Data written %llx Data read %llx\n",
4773 dev->name, (unsigned long long)0x12345,
4774 (unsigned long long)ret_data);
4744 fail = 1; 4775 fail = 1;
4745 } 4776 }
4746 4777
@@ -5190,6 +5221,8 @@ static struct ethtool_ops netdev_ethtool_ops = {
5190 .get_tso = ethtool_op_get_tso, 5221 .get_tso = ethtool_op_get_tso,
5191 .set_tso = ethtool_op_set_tso, 5222 .set_tso = ethtool_op_set_tso,
5192#endif 5223#endif
5224 .get_ufo = ethtool_op_get_ufo,
5225 .set_ufo = ethtool_op_set_ufo,
5193 .self_test_count = s2io_ethtool_self_test_count, 5226 .self_test_count = s2io_ethtool_self_test_count,
5194 .self_test = s2io_ethtool_test, 5227 .self_test = s2io_ethtool_test,
5195 .get_strings = s2io_ethtool_get_strings, 5228 .get_strings = s2io_ethtool_get_strings,
@@ -5941,7 +5974,8 @@ Defaulting to INTA\n");
5941 break; 5974 break;
5942 } 5975 }
5943 } 5976 }
5944 config->max_txds = MAX_SKB_FRAGS + 1; 5977 /* + 2 because one Txd for skb->data and one Txd for UFO */
5978 config->max_txds = MAX_SKB_FRAGS + 2;
5945 5979
5946 /* Rx side parameters. */ 5980 /* Rx side parameters. */
5947 if (rx_ring_sz[0] == 0) 5981 if (rx_ring_sz[0] == 0)
@@ -6035,6 +6069,10 @@ Defaulting to INTA\n");
6035#ifdef NETIF_F_TSO 6069#ifdef NETIF_F_TSO
6036 dev->features |= NETIF_F_TSO; 6070 dev->features |= NETIF_F_TSO;
6037#endif 6071#endif
6072 if (sp->device_type & XFRAME_II_DEVICE) {
6073 dev->features |= NETIF_F_UFO;
6074 dev->features |= NETIF_F_HW_CSUM;
6075 }
6038 6076
6039 dev->tx_timeout = &s2io_tx_watchdog; 6077 dev->tx_timeout = &s2io_tx_watchdog;
6040 dev->watchdog_timeo = WATCH_DOG_TIMEOUT; 6078 dev->watchdog_timeo = WATCH_DOG_TIMEOUT;
diff --git a/drivers/net/s2io.h b/drivers/net/s2io.h
index 419aad7f10e7..852a6a899d07 100644
--- a/drivers/net/s2io.h
+++ b/drivers/net/s2io.h
@@ -393,7 +393,9 @@ typedef struct _TxD {
393#define TXD_GATHER_CODE_LAST BIT(23) 393#define TXD_GATHER_CODE_LAST BIT(23)
394#define TXD_TCP_LSO_EN BIT(30) 394#define TXD_TCP_LSO_EN BIT(30)
395#define TXD_UDP_COF_EN BIT(31) 395#define TXD_UDP_COF_EN BIT(31)
396#define TXD_UFO_EN BIT(31) | BIT(30)
396#define TXD_TCP_LSO_MSS(val) vBIT(val,34,14) 397#define TXD_TCP_LSO_MSS(val) vBIT(val,34,14)
398#define TXD_UFO_MSS(val) vBIT(val,34,14)
397#define TXD_BUFFER0_SIZE(val) vBIT(val,48,16) 399#define TXD_BUFFER0_SIZE(val) vBIT(val,48,16)
398 400
399 u64 Control_2; 401 u64 Control_2;
@@ -789,6 +791,7 @@ struct s2io_nic {
789 791
790 spinlock_t rx_lock; 792 spinlock_t rx_lock;
791 atomic_t isr_cnt; 793 atomic_t isr_cnt;
794 u64 *ufo_in_band_v;
792}; 795};
793 796
794#define RESET_ERROR 1; 797#define RESET_ERROR 1;
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index 1d4d88680db1..3d95fa20cd88 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -1,6 +1,6 @@
1/* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux. 1/* sis900.c: A SiS 900/7016 PCI Fast Ethernet driver for Linux.
2 Copyright 1999 Silicon Integrated System Corporation 2 Copyright 1999 Silicon Integrated System Corporation
3 Revision: 1.08.08 Jan. 22 2005 3 Revision: 1.08.09 Sep. 19 2005
4 4
5 Modified from the driver which is originally written by Donald Becker. 5 Modified from the driver which is originally written by Donald Becker.
6 6
@@ -17,6 +17,7 @@
17 SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution, 17 SiS 7014 Single Chip 100BASE-TX/10BASE-T Physical Layer Solution,
18 preliminary Rev. 1.0 Jan. 18, 1998 18 preliminary Rev. 1.0 Jan. 18, 1998
19 19
20 Rev 1.08.09 Sep. 19 2005 Daniele Venzano add Wake on LAN support
20 Rev 1.08.08 Jan. 22 2005 Daniele Venzano use netif_msg for debugging messages 21 Rev 1.08.08 Jan. 22 2005 Daniele Venzano use netif_msg for debugging messages
21 Rev 1.08.07 Nov. 2 2003 Daniele Venzano <webvenza@libero.it> add suspend/resume support 22 Rev 1.08.07 Nov. 2 2003 Daniele Venzano <webvenza@libero.it> add suspend/resume support
22 Rev 1.08.06 Sep. 24 2002 Mufasa Yang bug fix for Tx timeout & add SiS963 support 23 Rev 1.08.06 Sep. 24 2002 Mufasa Yang bug fix for Tx timeout & add SiS963 support
@@ -76,7 +77,7 @@
76#include "sis900.h" 77#include "sis900.h"
77 78
78#define SIS900_MODULE_NAME "sis900" 79#define SIS900_MODULE_NAME "sis900"
79#define SIS900_DRV_VERSION "v1.08.08 Jan. 22 2005" 80#define SIS900_DRV_VERSION "v1.08.09 Sep. 19 2005"
80 81
81static char version[] __devinitdata = 82static char version[] __devinitdata =
82KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n"; 83KERN_INFO "sis900.c: " SIS900_DRV_VERSION "\n";
@@ -538,6 +539,11 @@ static int __devinit sis900_probe(struct pci_dev *pci_dev,
538 printk("%2.2x:", (u8)net_dev->dev_addr[i]); 539 printk("%2.2x:", (u8)net_dev->dev_addr[i]);
539 printk("%2.2x.\n", net_dev->dev_addr[i]); 540 printk("%2.2x.\n", net_dev->dev_addr[i]);
540 541
542 /* Detect Wake on Lan support */
543 ret = inl(CFGPMC & PMESP);
544 if (netif_msg_probe(sis_priv) && (ret & PME_D3C) == 0)
545 printk(KERN_INFO "%s: Wake on LAN only available from suspend to RAM.", net_dev->name);
546
541 return 0; 547 return 0;
542 548
543 err_unmap_rx: 549 err_unmap_rx:
@@ -2015,6 +2021,67 @@ static int sis900_nway_reset(struct net_device *net_dev)
2015 return mii_nway_restart(&sis_priv->mii_info); 2021 return mii_nway_restart(&sis_priv->mii_info);
2016} 2022}
2017 2023
2024/**
2025 * sis900_set_wol - Set up Wake on Lan registers
2026 * @net_dev: the net device to probe
2027 * @wol: container for info passed to the driver
2028 *
2029 * Process ethtool command "wol" to setup wake on lan features.
2030 * SiS900 supports sending WoL events if a correct packet is received,
2031 * but there is no simple way to filter them to only a subset (broadcast,
2032 * multicast, unicast or arp).
2033 */
2034
2035static int sis900_set_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
2036{
2037 struct sis900_private *sis_priv = net_dev->priv;
2038 long pmctrl_addr = net_dev->base_addr + pmctrl;
2039 u32 cfgpmcsr = 0, pmctrl_bits = 0;
2040
2041 if (wol->wolopts == 0) {
2042 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
2043 cfgpmcsr |= ~PME_EN;
2044 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
2045 outl(pmctrl_bits, pmctrl_addr);
2046 if (netif_msg_wol(sis_priv))
2047 printk(KERN_DEBUG "%s: Wake on LAN disabled\n", net_dev->name);
2048 return 0;
2049 }
2050
2051 if (wol->wolopts & (WAKE_MAGICSECURE | WAKE_UCAST | WAKE_MCAST
2052 | WAKE_BCAST | WAKE_ARP))
2053 return -EINVAL;
2054
2055 if (wol->wolopts & WAKE_MAGIC)
2056 pmctrl_bits |= MAGICPKT;
2057 if (wol->wolopts & WAKE_PHY)
2058 pmctrl_bits |= LINKON;
2059
2060 outl(pmctrl_bits, pmctrl_addr);
2061
2062 pci_read_config_dword(sis_priv->pci_dev, CFGPMCSR, &cfgpmcsr);
2063 cfgpmcsr |= PME_EN;
2064 pci_write_config_dword(sis_priv->pci_dev, CFGPMCSR, cfgpmcsr);
2065 if (netif_msg_wol(sis_priv))
2066 printk(KERN_DEBUG "%s: Wake on LAN enabled\n", net_dev->name);
2067
2068 return 0;
2069}
2070
2071static void sis900_get_wol(struct net_device *net_dev, struct ethtool_wolinfo *wol)
2072{
2073 long pmctrl_addr = net_dev->base_addr + pmctrl;
2074 u32 pmctrl_bits;
2075
2076 pmctrl_bits = inl(pmctrl_addr);
2077 if (pmctrl_bits & MAGICPKT)
2078 wol->wolopts |= WAKE_MAGIC;
2079 if (pmctrl_bits & LINKON)
2080 wol->wolopts |= WAKE_PHY;
2081
2082 wol->supported = (WAKE_PHY | WAKE_MAGIC);
2083}
2084
2018static struct ethtool_ops sis900_ethtool_ops = { 2085static struct ethtool_ops sis900_ethtool_ops = {
2019 .get_drvinfo = sis900_get_drvinfo, 2086 .get_drvinfo = sis900_get_drvinfo,
2020 .get_msglevel = sis900_get_msglevel, 2087 .get_msglevel = sis900_get_msglevel,
@@ -2023,6 +2090,8 @@ static struct ethtool_ops sis900_ethtool_ops = {
2023 .get_settings = sis900_get_settings, 2090 .get_settings = sis900_get_settings,
2024 .set_settings = sis900_set_settings, 2091 .set_settings = sis900_set_settings,
2025 .nway_reset = sis900_nway_reset, 2092 .nway_reset = sis900_nway_reset,
2093 .get_wol = sis900_get_wol,
2094 .set_wol = sis900_set_wol
2026}; 2095};
2027 2096
2028/** 2097/**
diff --git a/drivers/net/sis900.h b/drivers/net/sis900.h
index de3c06735d15..4233ea55670f 100644
--- a/drivers/net/sis900.h
+++ b/drivers/net/sis900.h
@@ -33,6 +33,7 @@ enum sis900_registers {
33 rxcfg=0x34, //Receive Configuration Register 33 rxcfg=0x34, //Receive Configuration Register
34 flctrl=0x38, //Flow Control Register 34 flctrl=0x38, //Flow Control Register
35 rxlen=0x3c, //Receive Packet Length Register 35 rxlen=0x3c, //Receive Packet Length Register
36 cfgpmcsr=0x44, //Configuration Power Management Control/Status Register
36 rfcr=0x48, //Receive Filter Control Register 37 rfcr=0x48, //Receive Filter Control Register
37 rfdr=0x4C, //Receive Filter Data Register 38 rfdr=0x4C, //Receive Filter Data Register
38 pmctrl=0xB0, //Power Management Control Register 39 pmctrl=0xB0, //Power Management Control Register
@@ -140,6 +141,50 @@ enum sis96x_eeprom_command {
140 EEREQ = 0x00000400, EEDONE = 0x00000200, EEGNT = 0x00000100 141 EEREQ = 0x00000400, EEDONE = 0x00000200, EEGNT = 0x00000100
141}; 142};
142 143
144/* PCI Registers */
145enum sis900_pci_registers {
146 CFGPMC = 0x40,
147 CFGPMCSR = 0x44
148};
149
150/* Power management capabilities bits */
151enum sis900_cfgpmc_register_bits {
152 PMVER = 0x00070000,
153 DSI = 0x00100000,
154 PMESP = 0xf8000000
155};
156
157enum sis900_pmesp_bits {
158 PME_D0 = 0x1,
159 PME_D1 = 0x2,
160 PME_D2 = 0x4,
161 PME_D3H = 0x8,
162 PME_D3C = 0x10
163};
164
165/* Power management control/status bits */
166enum sis900_cfgpmcsr_register_bits {
167 PMESTS = 0x00004000,
168 PME_EN = 0x00000100, // Power management enable
169 PWR_STA = 0x00000003 // Current power state
170};
171
172/* Wake-on-LAN support. */
173enum sis900_power_management_control_register_bits {
174 LINKLOSS = 0x00000001,
175 LINKON = 0x00000002,
176 MAGICPKT = 0x00000400,
177 ALGORITHM = 0x00000800,
178 FRM1EN = 0x00100000,
179 FRM2EN = 0x00200000,
180 FRM3EN = 0x00400000,
181 FRM1ACS = 0x01000000,
182 FRM2ACS = 0x02000000,
183 FRM3ACS = 0x04000000,
184 WAKEALL = 0x40000000,
185 GATECLK = 0x80000000
186};
187
143/* Management Data I/O (mdio) frame */ 188/* Management Data I/O (mdio) frame */
144#define MIIread 0x6000 189#define MIIread 0x6000
145#define MIIwrite 0x5002 190#define MIIwrite 0x5002
diff --git a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
index 7653d6e33aa2..afd900d5d730 100644
--- a/drivers/net/sk98lin/Makefile
+++ b/drivers/net/sk98lin/Makefile
@@ -26,8 +26,7 @@ sk98lin-objs := \
26 skrlmt.o \ 26 skrlmt.o \
27 sktimer.o \ 27 sktimer.o \
28 skvpd.o \ 28 skvpd.o \
29 skxmac2.o \ 29 skxmac2.o
30 skproc.o
31 30
32# DBGDEF = \ 31# DBGDEF = \
33# -DDEBUG 32# -DDEBUG
diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
index 2dc5728e3ef6..778d9e618ebd 100644
--- a/drivers/net/sk98lin/h/skdrv2nd.h
+++ b/drivers/net/sk98lin/h/skdrv2nd.h
@@ -60,7 +60,6 @@ extern SK_U64 SkOsGetTime(SK_AC*);
60extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*); 60extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
61extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*); 61extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*);
62extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*); 62extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*);
63extern int SkPciWriteCfgDWord(SK_AC*, int, SK_U32);
64extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16); 63extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16);
65extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8); 64extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8);
66extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA); 65extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
@@ -268,8 +267,6 @@ typedef struct s_DevNet DEV_NET;
268struct s_DevNet { 267struct s_DevNet {
269 int PortNr; 268 int PortNr;
270 int NetNr; 269 int NetNr;
271 int Mtu;
272 int Up;
273 SK_AC *pAC; 270 SK_AC *pAC;
274}; 271};
275 272
@@ -298,6 +295,7 @@ struct s_RxPort {
298 RXD *pRxdRingTail; /* Tail of Rx rings */ 295 RXD *pRxdRingTail; /* Tail of Rx rings */
299 RXD *pRxdRingPrev; /* descriptor given to BMU previously */ 296 RXD *pRxdRingPrev; /* descriptor given to BMU previously */
300 int RxdRingFree; /* # of free entrys */ 297 int RxdRingFree; /* # of free entrys */
298 int RxCsum; /* use receive checksum hardware */
301 spinlock_t RxDesRingLock; /* serialize descriptor accesses */ 299 spinlock_t RxDesRingLock; /* serialize descriptor accesses */
302 int RxFillLimit; /* limit for buffers in ring */ 300 int RxFillLimit; /* limit for buffers in ring */
303 SK_IOC HwAddr; /* bmu registers address */ 301 SK_IOC HwAddr; /* bmu registers address */
@@ -390,12 +388,10 @@ struct s_AC {
390 388
391 SK_IOC IoBase; /* register set of adapter */ 389 SK_IOC IoBase; /* register set of adapter */
392 int BoardLevel; /* level of active hw init (0-2) */ 390 int BoardLevel; /* level of active hw init (0-2) */
393 char DeviceStr[80]; /* adapter string from vpd */ 391
394 SK_U32 AllocFlag; /* flag allocation of resources */ 392 SK_U32 AllocFlag; /* flag allocation of resources */
395 struct pci_dev *PciDev; /* for access to pci config space */ 393 struct pci_dev *PciDev; /* for access to pci config space */
396 SK_U32 PciDevId; /* pci device id */
397 struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */ 394 struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */
398 char Name[30]; /* driver name */
399 395
400 int RxBufSize; /* length of receive buffers */ 396 int RxBufSize; /* length of receive buffers */
401 struct net_device_stats stats; /* linux 'netstat -i' statistics */ 397 struct net_device_stats stats; /* linux 'netstat -i' statistics */
@@ -430,7 +426,6 @@ struct s_AC {
430 DIM_INFO DynIrqModInfo; /* all data related to DIM */ 426 DIM_INFO DynIrqModInfo; /* all data related to DIM */
431 427
432 /* Only for tests */ 428 /* Only for tests */
433 int PortUp;
434 int PortDown; 429 int PortDown;
435 int ChipsetType; /* Chipset family type 430 int ChipsetType; /* Chipset family type
436 * 0 == Genesis family support 431 * 0 == Genesis family support
diff --git a/drivers/net/sk98lin/h/skvpd.h b/drivers/net/sk98lin/h/skvpd.h
index bdc1a5eaaae9..daa9a8d154fc 100644
--- a/drivers/net/sk98lin/h/skvpd.h
+++ b/drivers/net/sk98lin/h/skvpd.h
@@ -130,14 +130,12 @@ typedef struct s_vpd_key {
130#ifndef VPD_DO_IO 130#ifndef VPD_DO_IO
131#define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val) 131#define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val)
132#define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val) 132#define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val)
133#define VPD_OUT32(pAC,IoC,Addr,Val) (void)SkPciWriteCfgDWord(pAC,Addr,Val)
134#define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal) 133#define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal)
135#define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal) 134#define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal)
136#define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal) 135#define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal)
137#else /* VPD_DO_IO */ 136#else /* VPD_DO_IO */
138#define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val) 137#define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val)
139#define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val) 138#define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val)
140#define VPD_OUT32(pAC,IoC,Addr,Val) SK_OUT32(IoC,PCI_C(Addr),Val)
141#define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal) 139#define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal)
142#define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal) 140#define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal)
143#define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal) 141#define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal)
@@ -155,12 +153,6 @@ typedef struct s_vpd_key {
155 else \ 153 else \
156 SK_OUT16(pAC,PCI_C(Addr),Val); \ 154 SK_OUT16(pAC,PCI_C(Addr),Val); \
157 } 155 }
158#define VPD_OUT32(pAC,Ioc,Addr,Val) { \
159 if ((pAC)->DgT.DgUseCfgCycle) \
160 SkPciWriteCfgDWord(pAC,Addr,Val); \
161 else \
162 SK_OUT32(pAC,PCI_C(Addr),Val); \
163 }
164#define VPD_IN8(pAC,Ioc,Addr,pVal) { \ 156#define VPD_IN8(pAC,Ioc,Addr,pVal) { \
165 if ((pAC)->DgT.DgUseCfgCycle) \ 157 if ((pAC)->DgT.DgUseCfgCycle) \
166 SkPciReadCfgByte(pAC,Addr,pVal); \ 158 SkPciReadCfgByte(pAC,Addr,pVal); \
diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
index b71769ae4603..4265ed91a9c4 100644
--- a/drivers/net/sk98lin/skethtool.c
+++ b/drivers/net/sk98lin/skethtool.c
@@ -539,6 +539,48 @@ static int setPauseParams(struct net_device *dev , struct ethtool_pauseparam *ep
539 return ret ? -EIO : 0; 539 return ret ? -EIO : 0;
540} 540}
541 541
542/* Only Yukon supports checksum offload. */
543static int setScatterGather(struct net_device *dev, u32 data)
544{
545 DEV_NET *pNet = netdev_priv(dev);
546 SK_AC *pAC = pNet->pAC;
547
548 if (pAC->GIni.GIChipId == CHIP_ID_GENESIS)
549 return -EOPNOTSUPP;
550 return ethtool_op_set_sg(dev, data);
551}
552
553static int setTxCsum(struct net_device *dev, u32 data)
554{
555 DEV_NET *pNet = netdev_priv(dev);
556 SK_AC *pAC = pNet->pAC;
557
558 if (pAC->GIni.GIChipId == CHIP_ID_GENESIS)
559 return -EOPNOTSUPP;
560
561 return ethtool_op_set_tx_csum(dev, data);
562}
563
564static u32 getRxCsum(struct net_device *dev)
565{
566 DEV_NET *pNet = netdev_priv(dev);
567 SK_AC *pAC = pNet->pAC;
568
569 return pAC->RxPort[pNet->PortNr].RxCsum;
570}
571
572static int setRxCsum(struct net_device *dev, u32 data)
573{
574 DEV_NET *pNet = netdev_priv(dev);
575 SK_AC *pAC = pNet->pAC;
576
577 if (pAC->GIni.GIChipId == CHIP_ID_GENESIS)
578 return -EOPNOTSUPP;
579
580 pAC->RxPort[pNet->PortNr].RxCsum = data != 0;
581 return 0;
582}
583
542struct ethtool_ops SkGeEthtoolOps = { 584struct ethtool_ops SkGeEthtoolOps = {
543 .get_settings = getSettings, 585 .get_settings = getSettings,
544 .set_settings = setSettings, 586 .set_settings = setSettings,
@@ -551,4 +593,10 @@ struct ethtool_ops SkGeEthtoolOps = {
551 .set_pauseparam = setPauseParams, 593 .set_pauseparam = setPauseParams,
552 .get_link = ethtool_op_get_link, 594 .get_link = ethtool_op_get_link,
553 .get_perm_addr = ethtool_op_get_perm_addr, 595 .get_perm_addr = ethtool_op_get_perm_addr,
596 .get_sg = ethtool_op_get_sg,
597 .set_sg = setScatterGather,
598 .get_tx_csum = ethtool_op_get_tx_csum,
599 .set_tx_csum = setTxCsum,
600 .get_rx_csum = getRxCsum,
601 .set_rx_csum = setRxCsum,
554}; 602};
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index 00c5d7f04c68..9a76ac180b11 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -107,10 +107,10 @@
107 107
108#include "h/skversion.h" 108#include "h/skversion.h"
109 109
110#include <linux/in.h>
110#include <linux/module.h> 111#include <linux/module.h>
111#include <linux/moduleparam.h> 112#include <linux/moduleparam.h>
112#include <linux/init.h> 113#include <linux/init.h>
113#include <linux/proc_fs.h>
114#include <linux/dma-mapping.h> 114#include <linux/dma-mapping.h>
115#include <linux/ip.h> 115#include <linux/ip.h>
116 116
@@ -206,7 +206,6 @@ static void SkGeSetRxMode(struct SK_NET_DEVICE *dev);
206static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev); 206static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev);
207static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd); 207static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd);
208static void GetConfiguration(SK_AC*); 208static void GetConfiguration(SK_AC*);
209static void ProductStr(SK_AC*);
210static int XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*); 209static int XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*);
211static void FreeTxDescriptors(SK_AC*pAC, TX_PORT*); 210static void FreeTxDescriptors(SK_AC*pAC, TX_PORT*);
212static void FillRxRing(SK_AC*, RX_PORT*); 211static void FillRxRing(SK_AC*, RX_PORT*);
@@ -235,28 +234,6 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr);
235 * Extern Function Prototypes 234 * Extern Function Prototypes
236 * 235 *
237 ******************************************************************************/ 236 ******************************************************************************/
238static const char SKRootName[] = "net/sk98lin";
239static struct proc_dir_entry *pSkRootDir;
240extern struct file_operations sk_proc_fops;
241
242static inline void SkGeProcCreate(struct net_device *dev)
243{
244 struct proc_dir_entry *pe;
245
246 if (pSkRootDir &&
247 (pe = create_proc_entry(dev->name, S_IRUGO, pSkRootDir))) {
248 pe->proc_fops = &sk_proc_fops;
249 pe->data = dev;
250 pe->owner = THIS_MODULE;
251 }
252}
253
254static inline void SkGeProcRemove(struct net_device *dev)
255{
256 if (pSkRootDir)
257 remove_proc_entry(dev->name, pSkRootDir);
258}
259
260extern void SkDimEnableModerationIfNeeded(SK_AC *pAC); 237extern void SkDimEnableModerationIfNeeded(SK_AC *pAC);
261extern void SkDimDisplayModerationSettings(SK_AC *pAC); 238extern void SkDimDisplayModerationSettings(SK_AC *pAC);
262extern void SkDimStartModerationTimer(SK_AC *pAC); 239extern void SkDimStartModerationTimer(SK_AC *pAC);
@@ -279,6 +256,27 @@ static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
279 256
280/***************************************************************************** 257/*****************************************************************************
281 * 258 *
259 * SkPciWriteCfgDWord - write a 32 bit value to pci config space
260 *
261 * Description:
262 * This routine writes a 32 bit value to the pci configuration
263 * space.
264 *
265 * Returns:
266 * 0 - indicate everything worked ok.
267 * != 0 - error indication
268 */
269static inline int SkPciWriteCfgDWord(
270SK_AC *pAC, /* Adapter Control structure pointer */
271int PciAddr, /* PCI register address */
272SK_U32 Val) /* pointer to store the read value */
273{
274 pci_write_config_dword(pAC->PciDev, PciAddr, Val);
275 return(0);
276} /* SkPciWriteCfgDWord */
277
278/*****************************************************************************
279 *
282 * SkGeInitPCI - Init the PCI resources 280 * SkGeInitPCI - Init the PCI resources
283 * 281 *
284 * Description: 282 * Description:
@@ -300,7 +298,7 @@ int SkGeInitPCI(SK_AC *pAC)
300 dev->mem_start = pci_resource_start (pdev, 0); 298 dev->mem_start = pci_resource_start (pdev, 0);
301 pci_set_master(pdev); 299 pci_set_master(pdev);
302 300
303 if (pci_request_regions(pdev, pAC->Name) != 0) { 301 if (pci_request_regions(pdev, "sk98lin") != 0) {
304 retval = 2; 302 retval = 2;
305 goto out_disable; 303 goto out_disable;
306 } 304 }
@@ -578,10 +576,10 @@ SK_BOOL DualNet;
578 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); 576 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
579 577
580 if (pAC->GIni.GIMacsFound == 2) { 578 if (pAC->GIni.GIMacsFound == 2) {
581 Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev); 579 Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev);
582 } else if (pAC->GIni.GIMacsFound == 1) { 580 } else if (pAC->GIni.GIMacsFound == 1) {
583 Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, 581 Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ,
584 pAC->Name, dev); 582 "sk98lin", dev);
585 } else { 583 } else {
586 printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n", 584 printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n",
587 pAC->GIni.GIMacsFound); 585 pAC->GIni.GIMacsFound);
@@ -818,7 +816,7 @@ uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */
818 /* set the pointers right */ 816 /* set the pointers right */
819 pDescr->VNextRxd = VNextDescr & 0xffffffffULL; 817 pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
820 pDescr->pNextRxd = pNextDescr; 818 pDescr->pNextRxd = pNextDescr;
821 pDescr->TcpSumStarts = 0; 819 if (!IsTx) pDescr->TcpSumStarts = ETH_HLEN << 16 | ETH_HLEN;
822 820
823 /* advance one step */ 821 /* advance one step */
824 pPrevDescr = pDescr; 822 pPrevDescr = pDescr;
@@ -1265,7 +1263,6 @@ struct SK_NET_DEVICE *dev)
1265 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); 1263 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1266 1264
1267 pAC->MaxPorts++; 1265 pAC->MaxPorts++;
1268 pNet->Up = 1;
1269 1266
1270 1267
1271 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, 1268 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
@@ -1395,7 +1392,6 @@ struct SK_NET_DEVICE *dev)
1395 sizeof(SK_PNMI_STRUCT_DATA)); 1392 sizeof(SK_PNMI_STRUCT_DATA));
1396 1393
1397 pAC->MaxPorts--; 1394 pAC->MaxPorts--;
1398 pNet->Up = 0;
1399 1395
1400 return (0); 1396 return (0);
1401} /* SkGeClose */ 1397} /* SkGeClose */
@@ -2169,13 +2165,12 @@ rx_start:
2169 } /* frame > SK_COPY_TRESHOLD */ 2165 } /* frame > SK_COPY_TRESHOLD */
2170 2166
2171#ifdef USE_SK_RX_CHECKSUM 2167#ifdef USE_SK_RX_CHECKSUM
2172 pMsg->csum = pRxd->TcpSums; 2168 pMsg->csum = pRxd->TcpSums & 0xffff;
2173 pMsg->ip_summed = CHECKSUM_HW; 2169 pMsg->ip_summed = CHECKSUM_HW;
2174#else 2170#else
2175 pMsg->ip_summed = CHECKSUM_NONE; 2171 pMsg->ip_summed = CHECKSUM_NONE;
2176#endif 2172#endif
2177 2173
2178
2179 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V")); 2174 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V"));
2180 ForRlmt = SK_RLMT_RX_PROTOCOL; 2175 ForRlmt = SK_RLMT_RX_PROTOCOL;
2181#if 0 2176#if 0
@@ -2550,7 +2545,7 @@ unsigned long Flags;
2550static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu) 2545static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu)
2551{ 2546{
2552DEV_NET *pNet; 2547DEV_NET *pNet;
2553DEV_NET *pOtherNet; 2548struct net_device *pOtherDev;
2554SK_AC *pAC; 2549SK_AC *pAC;
2555unsigned long Flags; 2550unsigned long Flags;
2556int i; 2551int i;
@@ -2580,11 +2575,11 @@ SK_EVPARA EvPara;
2580 } 2575 }
2581#endif 2576#endif
2582 2577
2583 pNet->Mtu = NewMtu; 2578 pOtherDev = pAC->dev[1 - pNet->NetNr];
2584 pOtherNet = netdev_priv(pAC->dev[1 - pNet->NetNr]); 2579
2585 if ((pOtherNet->Mtu>1500) && (NewMtu<=1500) && (pOtherNet->Up==1)) { 2580 if ( netif_running(pOtherDev) && (pOtherDev->mtu > 1500)
2586 return(0); 2581 && (NewMtu <= 1500))
2587 } 2582 return 0;
2588 2583
2589 pAC->RxBufSize = NewMtu + 32; 2584 pAC->RxBufSize = NewMtu + 32;
2590 dev->mtu = NewMtu; 2585 dev->mtu = NewMtu;
@@ -2746,7 +2741,8 @@ SK_EVPARA EvPara;
2746 EvPara.Para32[1] = -1; 2741 EvPara.Para32[1] = -1;
2747 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); 2742 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
2748 2743
2749 if (pOtherNet->Up) { 2744 if (netif_running(pOtherDev)) {
2745 DEV_NET *pOtherNet = netdev_priv(pOtherDev);
2750 EvPara.Para32[0] = pOtherNet->PortNr; 2746 EvPara.Para32[0] = pOtherNet->PortNr;
2751 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); 2747 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
2752 } 2748 }
@@ -2820,7 +2816,7 @@ unsigned long Flags; /* for spin lock */
2820 pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts; 2816 pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts;
2821 pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts; 2817 pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts;
2822 2818
2823 if (pNet->Mtu <= 1500) { 2819 if (dev->mtu <= 1500) {
2824 pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF; 2820 pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF;
2825 } else { 2821 } else {
2826 pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts - 2822 pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts -
@@ -3771,25 +3767,21 @@ int Capabilities[3][3] =
3771 * 3767 *
3772 * Returns: N/A 3768 * Returns: N/A
3773 */ 3769 */
3774static void ProductStr( 3770static inline int ProductStr(
3775SK_AC *pAC /* pointer to adapter context */ 3771 SK_AC *pAC, /* pointer to adapter context */
3772 char *DeviceStr, /* result string */
3773 int StrLen /* length of the string */
3776) 3774)
3777{ 3775{
3778int StrLen = 80; /* length of the string, defined in SK_AC */
3779char Keyword[] = VPD_NAME; /* vpd productname identifier */ 3776char Keyword[] = VPD_NAME; /* vpd productname identifier */
3780int ReturnCode; /* return code from vpd_read */ 3777int ReturnCode; /* return code from vpd_read */
3781unsigned long Flags; 3778unsigned long Flags;
3782 3779
3783 spin_lock_irqsave(&pAC->SlowPathLock, Flags); 3780 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3784 ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, pAC->DeviceStr, 3781 ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, DeviceStr, &StrLen);
3785 &StrLen);
3786 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); 3782 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3787 if (ReturnCode != 0) { 3783
3788 /* there was an error reading the vpd data */ 3784 return ReturnCode;
3789 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ERROR,
3790 ("Error reading VPD data: %d\n", ReturnCode));
3791 pAC->DeviceStr[0] = '\0';
3792 }
3793} /* ProductStr */ 3785} /* ProductStr */
3794 3786
3795/***************************************************************************** 3787/*****************************************************************************
@@ -3992,28 +3984,6 @@ SK_U8 *pVal) /* pointer to store the read value */
3992 3984
3993/***************************************************************************** 3985/*****************************************************************************
3994 * 3986 *
3995 * SkPciWriteCfgDWord - write a 32 bit value to pci config space
3996 *
3997 * Description:
3998 * This routine writes a 32 bit value to the pci configuration
3999 * space.
4000 *
4001 * Returns:
4002 * 0 - indicate everything worked ok.
4003 * != 0 - error indication
4004 */
4005int SkPciWriteCfgDWord(
4006SK_AC *pAC, /* Adapter Control structure pointer */
4007int PciAddr, /* PCI register address */
4008SK_U32 Val) /* pointer to store the read value */
4009{
4010 pci_write_config_dword(pAC->PciDev, PciAddr, Val);
4011 return(0);
4012} /* SkPciWriteCfgDWord */
4013
4014
4015/*****************************************************************************
4016 *
4017 * SkPciWriteCfgWord - write a 16 bit value to pci config space 3987 * SkPciWriteCfgWord - write a 16 bit value to pci config space
4018 * 3988 *
4019 * Description: 3989 * Description:
@@ -4150,6 +4120,7 @@ SK_BOOL DualNet;
4150 Flags); 4120 Flags);
4151 break; 4121 break;
4152 case SK_DRV_NET_UP: /* SK_U32 PortIdx */ 4122 case SK_DRV_NET_UP: /* SK_U32 PortIdx */
4123 { struct net_device *dev = pAC->dev[Param.Para32[0]];
4153 /* action list 5 */ 4124 /* action list 5 */
4154 FromPort = Param.Para32[0]; 4125 FromPort = Param.Para32[0];
4155 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, 4126 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
@@ -4233,22 +4204,12 @@ SK_BOOL DualNet;
4233 printk(" irq moderation: disabled\n"); 4204 printk(" irq moderation: disabled\n");
4234 4205
4235 4206
4236#ifdef SK_ZEROCOPY 4207 printk(" scatter-gather: %s\n",
4237 if (pAC->ChipsetType) 4208 (dev->features & NETIF_F_SG) ? "enabled" : "disabled");
4238#ifdef USE_SK_TX_CHECKSUM 4209 printk(" tx-checksum: %s\n",
4239 printk(" scatter-gather: enabled\n"); 4210 (dev->features & NETIF_F_IP_CSUM) ? "enabled" : "disabled");
4240#else 4211 printk(" rx-checksum: %s\n",
4241 printk(" tx-checksum: disabled\n"); 4212 pAC->RxPort[Param.Para32[0]].RxCsum ? "enabled" : "disabled");
4242#endif
4243 else
4244 printk(" scatter-gather: disabled\n");
4245#else
4246 printk(" scatter-gather: disabled\n");
4247#endif
4248
4249#ifndef USE_SK_RX_CHECKSUM
4250 printk(" rx-checksum: disabled\n");
4251#endif
4252 4213
4253 } else { 4214 } else {
4254 DoPrintInterfaceChange = SK_TRUE; 4215 DoPrintInterfaceChange = SK_TRUE;
@@ -4263,9 +4224,9 @@ SK_BOOL DualNet;
4263 } 4224 }
4264 4225
4265 /* Inform the world that link protocol is up. */ 4226 /* Inform the world that link protocol is up. */
4266 netif_carrier_on(pAC->dev[Param.Para32[0]]); 4227 netif_carrier_on(dev);
4267
4268 break; 4228 break;
4229 }
4269 case SK_DRV_NET_DOWN: /* SK_U32 Reason */ 4230 case SK_DRV_NET_DOWN: /* SK_U32 Reason */
4270 /* action list 7 */ 4231 /* action list 7 */
4271 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, 4232 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
@@ -4479,7 +4440,7 @@ SK_AC *pAc) /* pointer to adapter context */
4479 4440
4480 pAC->DiagModeActive = DIAG_ACTIVE; 4441 pAC->DiagModeActive = DIAG_ACTIVE;
4481 if (pAC->BoardLevel > SK_INIT_DATA) { 4442 if (pAC->BoardLevel > SK_INIT_DATA) {
4482 if (pNet->Up) { 4443 if (netif_running(pAC->dev[0])) {
4483 pAC->WasIfUp[0] = SK_TRUE; 4444 pAC->WasIfUp[0] = SK_TRUE;
4484 pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ 4445 pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
4485 DoPrintInterfaceChange = SK_FALSE; 4446 DoPrintInterfaceChange = SK_FALSE;
@@ -4489,7 +4450,7 @@ SK_AC *pAc) /* pointer to adapter context */
4489 } 4450 }
4490 if (pNet != netdev_priv(pAC->dev[1])) { 4451 if (pNet != netdev_priv(pAC->dev[1])) {
4491 pNet = netdev_priv(pAC->dev[1]); 4452 pNet = netdev_priv(pAC->dev[1]);
4492 if (pNet->Up) { 4453 if (netif_running(pAC->dev[1])) {
4493 pAC->WasIfUp[1] = SK_TRUE; 4454 pAC->WasIfUp[1] = SK_TRUE;
4494 pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ 4455 pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */
4495 DoPrintInterfaceChange = SK_FALSE; 4456 DoPrintInterfaceChange = SK_FALSE;
@@ -4815,6 +4776,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4815 struct net_device *dev = NULL; 4776 struct net_device *dev = NULL;
4816 static int boards_found = 0; 4777 static int boards_found = 0;
4817 int error = -ENODEV; 4778 int error = -ENODEV;
4779 char DeviceStr[80];
4818 4780
4819 if (pci_enable_device(pdev)) 4781 if (pci_enable_device(pdev))
4820 goto out; 4782 goto out;
@@ -4842,14 +4804,11 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4842 memset(pNet->pAC, 0, sizeof(SK_AC)); 4804 memset(pNet->pAC, 0, sizeof(SK_AC));
4843 pAC = pNet->pAC; 4805 pAC = pNet->pAC;
4844 pAC->PciDev = pdev; 4806 pAC->PciDev = pdev;
4845 pAC->PciDevId = pdev->device; 4807
4846 pAC->dev[0] = dev; 4808 pAC->dev[0] = dev;
4847 pAC->dev[1] = dev; 4809 pAC->dev[1] = dev;
4848 sprintf(pAC->Name, "SysKonnect SK-98xx");
4849 pAC->CheckQueue = SK_FALSE; 4810 pAC->CheckQueue = SK_FALSE;
4850 4811
4851 pNet->Mtu = 1500;
4852 pNet->Up = 0;
4853 dev->irq = pdev->irq; 4812 dev->irq = pdev->irq;
4854 error = SkGeInitPCI(pAC); 4813 error = SkGeInitPCI(pAC);
4855 if (error) { 4814 if (error) {
@@ -4872,21 +4831,30 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4872 SET_NETDEV_DEV(dev, &pdev->dev); 4831 SET_NETDEV_DEV(dev, &pdev->dev);
4873 SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps); 4832 SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
4874 4833
4875#ifdef SK_ZEROCOPY 4834 /* Use only if yukon hardware */
4876#ifdef USE_SK_TX_CHECKSUM
4877 if (pAC->ChipsetType) { 4835 if (pAC->ChipsetType) {
4878 /* Use only if yukon hardware */ 4836#ifdef USE_SK_TX_CHECKSUM
4879 /* SK and ZEROCOPY - fly baby... */ 4837 dev->features |= NETIF_F_IP_CSUM;
4880 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; 4838#endif
4881 } 4839#ifdef SK_ZEROCOPY
4840 dev->features |= NETIF_F_SG;
4882#endif 4841#endif
4842#ifdef USE_SK_RX_CHECKSUM
4843 pAC->RxPort[0].RxCsum = 1;
4883#endif 4844#endif
4845 }
4884 4846
4885 pAC->Index = boards_found++; 4847 pAC->Index = boards_found++;
4886 4848
4887 if (SkGeBoardInit(dev, pAC)) 4849 if (SkGeBoardInit(dev, pAC))
4888 goto out_free_netdev; 4850 goto out_free_netdev;
4889 4851
4852 /* Read Adapter name from VPD */
4853 if (ProductStr(pAC, DeviceStr, sizeof(DeviceStr)) != 0) {
4854 printk(KERN_ERR "sk98lin: Could not read VPD data.\n");
4855 goto out_free_resources;
4856 }
4857
4890 /* Register net device */ 4858 /* Register net device */
4891 if (register_netdev(dev)) { 4859 if (register_netdev(dev)) {
4892 printk(KERN_ERR "sk98lin: Could not register device.\n"); 4860 printk(KERN_ERR "sk98lin: Could not register device.\n");
@@ -4894,8 +4862,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4894 } 4862 }
4895 4863
4896 /* Print adapter specific string from vpd */ 4864 /* Print adapter specific string from vpd */
4897 ProductStr(pAC); 4865 printk("%s: %s\n", dev->name, DeviceStr);
4898 printk("%s: %s\n", dev->name, pAC->DeviceStr);
4899 4866
4900 /* Print configuration settings */ 4867 /* Print configuration settings */
4901 printk(" PrefPort:%c RlmtMode:%s\n", 4868 printk(" PrefPort:%c RlmtMode:%s\n",
@@ -4911,8 +4878,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4911 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); 4878 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
4912 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 4879 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
4913 4880
4914 SkGeProcCreate(dev);
4915
4916 pNet->PortNr = 0; 4881 pNet->PortNr = 0;
4917 pNet->NetNr = 0; 4882 pNet->NetNr = 0;
4918 4883
@@ -4931,8 +4896,6 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4931 pNet->PortNr = 1; 4896 pNet->PortNr = 1;
4932 pNet->NetNr = 1; 4897 pNet->NetNr = 1;
4933 pNet->pAC = pAC; 4898 pNet->pAC = pAC;
4934 pNet->Mtu = 1500;
4935 pNet->Up = 0;
4936 4899
4937 dev->open = &SkGeOpen; 4900 dev->open = &SkGeOpen;
4938 dev->stop = &SkGeClose; 4901 dev->stop = &SkGeClose;
@@ -4945,26 +4908,28 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4945 SET_NETDEV_DEV(dev, &pdev->dev); 4908 SET_NETDEV_DEV(dev, &pdev->dev);
4946 SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps); 4909 SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps);
4947 4910
4948#ifdef SK_ZEROCOPY
4949#ifdef USE_SK_TX_CHECKSUM
4950 if (pAC->ChipsetType) { 4911 if (pAC->ChipsetType) {
4951 /* SG and ZEROCOPY - fly baby... */ 4912#ifdef USE_SK_TX_CHECKSUM
4952 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; 4913 dev->features |= NETIF_F_IP_CSUM;
4953 } 4914#endif
4915#ifdef SK_ZEROCOPY
4916 dev->features |= NETIF_F_SG;
4954#endif 4917#endif
4918#ifdef USE_SK_RX_CHECKSUM
4919 pAC->RxPort[1].RxCsum = 1;
4955#endif 4920#endif
4921 }
4956 4922
4957 if (register_netdev(dev)) { 4923 if (register_netdev(dev)) {
4958 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n"); 4924 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n");
4959 free_netdev(dev); 4925 free_netdev(dev);
4960 pAC->dev[1] = pAC->dev[0]; 4926 pAC->dev[1] = pAC->dev[0];
4961 } else { 4927 } else {
4962 SkGeProcCreate(dev);
4963 memcpy(&dev->dev_addr, 4928 memcpy(&dev->dev_addr,
4964 &pAC->Addr.Net[1].CurrentMacAddress, 6); 4929 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4965 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); 4930 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
4966 4931
4967 printk("%s: %s\n", dev->name, pAC->DeviceStr); 4932 printk("%s: %s\n", dev->name, DeviceStr);
4968 printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); 4933 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4969 } 4934 }
4970 } 4935 }
@@ -5000,10 +4965,7 @@ static void __devexit skge_remove_one(struct pci_dev *pdev)
5000 SK_AC *pAC = pNet->pAC; 4965 SK_AC *pAC = pNet->pAC;
5001 struct net_device *otherdev = pAC->dev[1]; 4966 struct net_device *otherdev = pAC->dev[1];
5002 4967
5003 SkGeProcRemove(dev);
5004 unregister_netdev(dev); 4968 unregister_netdev(dev);
5005 if (otherdev != dev)
5006 SkGeProcRemove(otherdev);
5007 4969
5008 SkGeYellowLED(pAC, pAC->IoBase, 0); 4970 SkGeYellowLED(pAC, pAC->IoBase, 0);
5009 4971
@@ -5088,9 +5050,9 @@ static int skge_resume(struct pci_dev *pdev)
5088 pci_enable_device(pdev); 5050 pci_enable_device(pdev);
5089 pci_set_master(pdev); 5051 pci_set_master(pdev);
5090 if (pAC->GIni.GIMacsFound == 2) 5052 if (pAC->GIni.GIMacsFound == 2)
5091 ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev); 5053 ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev);
5092 else 5054 else
5093 ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, pAC->Name, dev); 5055 ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, "sk98lin", dev);
5094 if (ret) { 5056 if (ret) {
5095 printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq); 5057 printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq);
5096 pAC->AllocFlag &= ~SK_ALLOC_IRQ; 5058 pAC->AllocFlag &= ~SK_ALLOC_IRQ;
@@ -5148,23 +5110,12 @@ static struct pci_driver skge_driver = {
5148 5110
5149static int __init skge_init(void) 5111static int __init skge_init(void)
5150{ 5112{
5151 int error; 5113 return pci_module_init(&skge_driver);
5152
5153 pSkRootDir = proc_mkdir(SKRootName, NULL);
5154 if (pSkRootDir)
5155 pSkRootDir->owner = THIS_MODULE;
5156
5157 error = pci_register_driver(&skge_driver);
5158 if (error)
5159 remove_proc_entry(SKRootName, NULL);
5160 return error;
5161} 5114}
5162 5115
5163static void __exit skge_exit(void) 5116static void __exit skge_exit(void)
5164{ 5117{
5165 pci_unregister_driver(&skge_driver); 5118 pci_unregister_driver(&skge_driver);
5166 remove_proc_entry(SKRootName, NULL);
5167
5168} 5119}
5169 5120
5170module_init(skge_init); 5121module_init(skge_init);
diff --git a/drivers/net/sk98lin/skproc.c b/drivers/net/sk98lin/skproc.c
deleted file mode 100644
index 5cece25c034e..000000000000
--- a/drivers/net/sk98lin/skproc.c
+++ /dev/null
@@ -1,265 +0,0 @@
1/******************************************************************************
2 *
3 * Name: skproc.c
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.11 $
6 * Date: $Date: 2003/12/11 16:03:57 $
7 * Purpose: Funktions to display statictic data
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
20 *
21 * Created 22-Nov-2000
22 * Author: Mirko Lindner (mlindner@syskonnect.de)
23 *
24 * The information in this file is provided "AS IS" without warranty.
25 *
26 ******************************************************************************/
27#include <linux/proc_fs.h>
28#include <linux/seq_file.h>
29
30#include "h/skdrv1st.h"
31#include "h/skdrv2nd.h"
32#include "h/skversion.h"
33
34static int sk_seq_show(struct seq_file *seq, void *v);
35static int sk_proc_open(struct inode *inode, struct file *file);
36
37struct file_operations sk_proc_fops = {
38 .owner = THIS_MODULE,
39 .open = sk_proc_open,
40 .read = seq_read,
41 .llseek = seq_lseek,
42 .release = single_release,
43};
44
45
46/*****************************************************************************
47 *
48 * sk_seq_show - show proc information of a particular adapter
49 *
50 * Description:
51 * This function fills the proc entry with statistic data about
52 * the ethernet device. It invokes the generic sk_gen_browse() to
53 * print out all items one per one.
54 *
55 * Returns: 0
56 *
57 */
58static int sk_seq_show(struct seq_file *seq, void *v)
59{
60 struct net_device *dev = seq->private;
61 DEV_NET *pNet = netdev_priv(dev);
62 SK_AC *pAC = pNet->pAC;
63 SK_PNMI_STRUCT_DATA *pPnmiStruct = &pAC->PnmiStruct;
64 unsigned long Flags;
65 unsigned int Size;
66 char sens_msg[50];
67 int t;
68 int i;
69
70 /* NetIndex in GetStruct is now required, zero is only dummy */
71 for (t=pAC->GIni.GIMacsFound; t > 0; t--) {
72 if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 1)
73 t--;
74
75 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
76 Size = SK_PNMI_STRUCT_SIZE;
77#ifdef SK_DIAG_SUPPORT
78 if (pAC->BoardLevel == SK_INIT_DATA) {
79 SK_MEMCPY(&(pAC->PnmiStruct), &(pAC->PnmiBackup), sizeof(SK_PNMI_STRUCT_DATA));
80 if (pAC->DiagModeActive == DIAG_NOTACTIVE) {
81 pAC->Pnmi.DiagAttached = SK_DIAG_IDLE;
82 }
83 } else {
84 SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, t-1);
85 }
86#else
87 SkPnmiGetStruct(pAC, pAC->IoBase,
88 pPnmiStruct, &Size, t-1);
89#endif
90 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
91
92 if (pAC->dev[t-1] == dev) {
93 SK_PNMI_STAT *pPnmiStat = &pPnmiStruct->Stat[0];
94
95 seq_printf(seq, "\nDetailed statistic for device %s\n",
96 pAC->dev[t-1]->name);
97 seq_printf(seq, "=======================================\n");
98
99 /* Board statistics */
100 seq_printf(seq, "\nBoard statistics\n\n");
101 seq_printf(seq, "Active Port %c\n",
102 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
103 Net[t-1].PrefPort]->PortNumber);
104 seq_printf(seq, "Preferred Port %c\n",
105 'A' + pAC->Rlmt.Net[t-1].Port[pAC->Rlmt.
106 Net[t-1].PrefPort]->PortNumber);
107
108 seq_printf(seq, "Bus speed (MHz) %d\n",
109 pPnmiStruct->BusSpeed);
110
111 seq_printf(seq, "Bus width (Bit) %d\n",
112 pPnmiStruct->BusWidth);
113 seq_printf(seq, "Driver version %s\n",
114 VER_STRING);
115 seq_printf(seq, "Hardware revision v%d.%d\n",
116 (pAC->GIni.GIPciHwRev >> 4) & 0x0F,
117 pAC->GIni.GIPciHwRev & 0x0F);
118
119 /* Print sensor informations */
120 for (i=0; i < pAC->I2c.MaxSens; i ++) {
121 /* Check type */
122 switch (pAC->I2c.SenTable[i].SenType) {
123 case 1:
124 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
125 strcat(sens_msg, " (C)");
126 seq_printf(seq, "%-25s %d.%02d\n",
127 sens_msg,
128 pAC->I2c.SenTable[i].SenValue / 10,
129 pAC->I2c.SenTable[i].SenValue % 10);
130
131 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
132 strcat(sens_msg, " (F)");
133 seq_printf(seq, "%-25s %d.%02d\n",
134 sens_msg,
135 ((((pAC->I2c.SenTable[i].SenValue)
136 *10)*9)/5 + 3200)/100,
137 ((((pAC->I2c.SenTable[i].SenValue)
138 *10)*9)/5 + 3200) % 10);
139 break;
140 case 2:
141 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
142 strcat(sens_msg, " (V)");
143 seq_printf(seq, "%-25s %d.%03d\n",
144 sens_msg,
145 pAC->I2c.SenTable[i].SenValue / 1000,
146 pAC->I2c.SenTable[i].SenValue % 1000);
147 break;
148 case 3:
149 strcpy(sens_msg, pAC->I2c.SenTable[i].SenDesc);
150 strcat(sens_msg, " (rpm)");
151 seq_printf(seq, "%-25s %d\n",
152 sens_msg,
153 pAC->I2c.SenTable[i].SenValue);
154 break;
155 default:
156 break;
157 }
158 }
159
160 /*Receive statistics */
161 seq_printf(seq, "\nReceive statistics\n\n");
162
163 seq_printf(seq, "Received bytes %Lu\n",
164 (unsigned long long) pPnmiStat->StatRxOctetsOkCts);
165 seq_printf(seq, "Received packets %Lu\n",
166 (unsigned long long) pPnmiStat->StatRxOkCts);
167#if 0
168 if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC &&
169 pAC->HWRevision < 12) {
170 pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
171 pPnmiStat->StatRxShortsCts;
172 pPnmiStat->StatRxShortsCts = 0;
173 }
174#endif
175 if (dev->mtu > 1500)
176 pPnmiStruct->InErrorsCts = pPnmiStruct->InErrorsCts -
177 pPnmiStat->StatRxTooLongCts;
178
179 seq_printf(seq, "Receive errors %Lu\n",
180 (unsigned long long) pPnmiStruct->InErrorsCts);
181 seq_printf(seq, "Receive dropped %Lu\n",
182 (unsigned long long) pPnmiStruct->RxNoBufCts);
183 seq_printf(seq, "Received multicast %Lu\n",
184 (unsigned long long) pPnmiStat->StatRxMulticastOkCts);
185 seq_printf(seq, "Receive error types\n");
186 seq_printf(seq, " length %Lu\n",
187 (unsigned long long) pPnmiStat->StatRxRuntCts);
188 seq_printf(seq, " buffer overflow %Lu\n",
189 (unsigned long long) pPnmiStat->StatRxFifoOverflowCts);
190 seq_printf(seq, " bad crc %Lu\n",
191 (unsigned long long) pPnmiStat->StatRxFcsCts);
192 seq_printf(seq, " framing %Lu\n",
193 (unsigned long long) pPnmiStat->StatRxFramingCts);
194 seq_printf(seq, " missed frames %Lu\n",
195 (unsigned long long) pPnmiStat->StatRxMissedCts);
196
197 if (dev->mtu > 1500)
198 pPnmiStat->StatRxTooLongCts = 0;
199
200 seq_printf(seq, " too long %Lu\n",
201 (unsigned long long) pPnmiStat->StatRxTooLongCts);
202 seq_printf(seq, " carrier extension %Lu\n",
203 (unsigned long long) pPnmiStat->StatRxCextCts);
204 seq_printf(seq, " too short %Lu\n",
205 (unsigned long long) pPnmiStat->StatRxShortsCts);
206 seq_printf(seq, " symbol %Lu\n",
207 (unsigned long long) pPnmiStat->StatRxSymbolCts);
208 seq_printf(seq, " LLC MAC size %Lu\n",
209 (unsigned long long) pPnmiStat->StatRxIRLengthCts);
210 seq_printf(seq, " carrier event %Lu\n",
211 (unsigned long long) pPnmiStat->StatRxCarrierCts);
212 seq_printf(seq, " jabber %Lu\n",
213 (unsigned long long) pPnmiStat->StatRxJabberCts);
214
215
216 /*Transmit statistics */
217 seq_printf(seq, "\nTransmit statistics\n\n");
218
219 seq_printf(seq, "Transmited bytes %Lu\n",
220 (unsigned long long) pPnmiStat->StatTxOctetsOkCts);
221 seq_printf(seq, "Transmited packets %Lu\n",
222 (unsigned long long) pPnmiStat->StatTxOkCts);
223 seq_printf(seq, "Transmit errors %Lu\n",
224 (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
225 seq_printf(seq, "Transmit dropped %Lu\n",
226 (unsigned long long) pPnmiStruct->TxNoBufCts);
227 seq_printf(seq, "Transmit collisions %Lu\n",
228 (unsigned long long) pPnmiStat->StatTxSingleCollisionCts);
229 seq_printf(seq, "Transmit error types\n");
230 seq_printf(seq, " excessive collision %ld\n",
231 pAC->stats.tx_aborted_errors);
232 seq_printf(seq, " carrier %Lu\n",
233 (unsigned long long) pPnmiStat->StatTxCarrierCts);
234 seq_printf(seq, " fifo underrun %Lu\n",
235 (unsigned long long) pPnmiStat->StatTxFifoUnderrunCts);
236 seq_printf(seq, " heartbeat %Lu\n",
237 (unsigned long long) pPnmiStat->StatTxCarrierCts);
238 seq_printf(seq, " window %ld\n",
239 pAC->stats.tx_window_errors);
240
241 }
242 }
243 return 0;
244}
245
246/*****************************************************************************
247 *
248 * sk_proc_open - register the show function when proc is open'ed
249 *
250 * Description:
251 * This function is called whenever a sk98lin proc file is queried.
252 *
253 * Returns: the return value of single_open()
254 *
255 */
256static int sk_proc_open(struct inode *inode, struct file *file)
257{
258 return single_open(file, sk_seq_show, PDE(inode)->data);
259}
260
261/*******************************************************************************
262 *
263 * End of file
264 *
265 ******************************************************************************/
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 716467879b9c..b538e3038058 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -25,6 +25,7 @@
25 */ 25 */
26 26
27#include <linux/config.h> 27#include <linux/config.h>
28#include <linux/in.h>
28#include <linux/kernel.h> 29#include <linux/kernel.h>
29#include <linux/module.h> 30#include <linux/module.h>
30#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
@@ -43,7 +44,7 @@
43#include "skge.h" 44#include "skge.h"
44 45
45#define DRV_NAME "skge" 46#define DRV_NAME "skge"
46#define DRV_VERSION "1.2" 47#define DRV_VERSION "1.3"
47#define PFX DRV_NAME " " 48#define PFX DRV_NAME " "
48 49
49#define DEFAULT_TX_RING_SIZE 128 50#define DEFAULT_TX_RING_SIZE 128
@@ -88,15 +89,14 @@ MODULE_DEVICE_TABLE(pci, skge_id_table);
88 89
89static int skge_up(struct net_device *dev); 90static int skge_up(struct net_device *dev);
90static int skge_down(struct net_device *dev); 91static int skge_down(struct net_device *dev);
92static void skge_phy_reset(struct skge_port *skge);
91static void skge_tx_clean(struct skge_port *skge); 93static void skge_tx_clean(struct skge_port *skge);
92static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val); 94static int xm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
93static int gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val); 95static int gm_phy_write(struct skge_hw *hw, int port, u16 reg, u16 val);
94static void genesis_get_stats(struct skge_port *skge, u64 *data); 96static void genesis_get_stats(struct skge_port *skge, u64 *data);
95static void yukon_get_stats(struct skge_port *skge, u64 *data); 97static void yukon_get_stats(struct skge_port *skge, u64 *data);
96static void yukon_init(struct skge_hw *hw, int port); 98static void yukon_init(struct skge_hw *hw, int port);
97static void yukon_reset(struct skge_hw *hw, int port);
98static void genesis_mac_init(struct skge_hw *hw, int port); 99static void genesis_mac_init(struct skge_hw *hw, int port);
99static void genesis_reset(struct skge_hw *hw, int port);
100static void genesis_link_up(struct skge_port *skge); 100static void genesis_link_up(struct skge_port *skge);
101 101
102/* Avoid conditionals by using array */ 102/* Avoid conditionals by using array */
@@ -276,10 +276,9 @@ static int skge_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
276 skge->autoneg = ecmd->autoneg; 276 skge->autoneg = ecmd->autoneg;
277 skge->advertising = ecmd->advertising; 277 skge->advertising = ecmd->advertising;
278 278
279 if (netif_running(dev)) { 279 if (netif_running(dev))
280 skge_down(dev); 280 skge_phy_reset(skge);
281 skge_up(dev); 281
282 }
283 return (0); 282 return (0);
284} 283}
285 284
@@ -399,6 +398,7 @@ static int skge_set_ring_param(struct net_device *dev,
399 struct ethtool_ringparam *p) 398 struct ethtool_ringparam *p)
400{ 399{
401 struct skge_port *skge = netdev_priv(dev); 400 struct skge_port *skge = netdev_priv(dev);
401 int err;
402 402
403 if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE || 403 if (p->rx_pending == 0 || p->rx_pending > MAX_RX_RING_SIZE ||
404 p->tx_pending == 0 || p->tx_pending > MAX_TX_RING_SIZE) 404 p->tx_pending == 0 || p->tx_pending > MAX_TX_RING_SIZE)
@@ -409,7 +409,9 @@ static int skge_set_ring_param(struct net_device *dev,
409 409
410 if (netif_running(dev)) { 410 if (netif_running(dev)) {
411 skge_down(dev); 411 skge_down(dev);
412 skge_up(dev); 412 err = skge_up(dev);
413 if (err)
414 dev_close(dev);
413 } 415 }
414 416
415 return 0; 417 return 0;
@@ -430,21 +432,11 @@ static void skge_set_msglevel(struct net_device *netdev, u32 value)
430static int skge_nway_reset(struct net_device *dev) 432static int skge_nway_reset(struct net_device *dev)
431{ 433{
432 struct skge_port *skge = netdev_priv(dev); 434 struct skge_port *skge = netdev_priv(dev);
433 struct skge_hw *hw = skge->hw;
434 int port = skge->port;
435 435
436 if (skge->autoneg != AUTONEG_ENABLE || !netif_running(dev)) 436 if (skge->autoneg != AUTONEG_ENABLE || !netif_running(dev))
437 return -EINVAL; 437 return -EINVAL;
438 438
439 spin_lock_bh(&hw->phy_lock); 439 skge_phy_reset(skge);
440 if (hw->chip_id == CHIP_ID_GENESIS) {
441 genesis_reset(hw, port);
442 genesis_mac_init(hw, port);
443 } else {
444 yukon_reset(hw, port);
445 yukon_init(hw, port);
446 }
447 spin_unlock_bh(&hw->phy_lock);
448 return 0; 440 return 0;
449} 441}
450 442
@@ -516,10 +508,8 @@ static int skge_set_pauseparam(struct net_device *dev,
516 else 508 else
517 skge->flow_control = FLOW_MODE_NONE; 509 skge->flow_control = FLOW_MODE_NONE;
518 510
519 if (netif_running(dev)) { 511 if (netif_running(dev))
520 skge_down(dev); 512 skge_phy_reset(skge);
521 skge_up(dev);
522 }
523 return 0; 513 return 0;
524} 514}
525 515
@@ -2019,6 +2009,25 @@ static void yukon_phy_intr(struct skge_port *skge)
2019 /* XXX restart autonegotiation? */ 2009 /* XXX restart autonegotiation? */
2020} 2010}
2021 2011
2012static void skge_phy_reset(struct skge_port *skge)
2013{
2014 struct skge_hw *hw = skge->hw;
2015 int port = skge->port;
2016
2017 netif_stop_queue(skge->netdev);
2018 netif_carrier_off(skge->netdev);
2019
2020 spin_lock_bh(&hw->phy_lock);
2021 if (hw->chip_id == CHIP_ID_GENESIS) {
2022 genesis_reset(hw, port);
2023 genesis_mac_init(hw, port);
2024 } else {
2025 yukon_reset(hw, port);
2026 yukon_init(hw, port);
2027 }
2028 spin_unlock_bh(&hw->phy_lock);
2029}
2030
2022/* Basic MII support */ 2031/* Basic MII support */
2023static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 2032static int skge_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2024{ 2033{
@@ -2187,6 +2196,7 @@ static int skge_up(struct net_device *dev)
2187 kfree(skge->rx_ring.start); 2196 kfree(skge->rx_ring.start);
2188 free_pci_mem: 2197 free_pci_mem:
2189 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma); 2198 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
2199 skge->mem = NULL;
2190 2200
2191 return err; 2201 return err;
2192} 2202}
@@ -2197,6 +2207,9 @@ static int skge_down(struct net_device *dev)
2197 struct skge_hw *hw = skge->hw; 2207 struct skge_hw *hw = skge->hw;
2198 int port = skge->port; 2208 int port = skge->port;
2199 2209
2210 if (skge->mem == NULL)
2211 return 0;
2212
2200 if (netif_msg_ifdown(skge)) 2213 if (netif_msg_ifdown(skge))
2201 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); 2214 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
2202 2215
@@ -2253,6 +2266,7 @@ static int skge_down(struct net_device *dev)
2253 kfree(skge->rx_ring.start); 2266 kfree(skge->rx_ring.start);
2254 kfree(skge->tx_ring.start); 2267 kfree(skge->tx_ring.start);
2255 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma); 2268 pci_free_consistent(hw->pdev, skge->mem_size, skge->mem, skge->dma);
2269 skge->mem = NULL;
2256 return 0; 2270 return 0;
2257} 2271}
2258 2272
@@ -2280,11 +2294,13 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2280 } 2294 }
2281 2295
2282 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) { 2296 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) {
2283 netif_stop_queue(dev); 2297 if (!netif_queue_stopped(dev)) {
2284 spin_unlock_irqrestore(&skge->tx_lock, flags); 2298 netif_stop_queue(dev);
2285 2299
2286 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", 2300 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n",
2287 dev->name); 2301 dev->name);
2302 }
2303 spin_unlock_irqrestore(&skge->tx_lock, flags);
2288 return NETDEV_TX_BUSY; 2304 return NETDEV_TX_BUSY;
2289 } 2305 }
2290 2306
@@ -2411,18 +2427,23 @@ static void skge_tx_timeout(struct net_device *dev)
2411 2427
2412static int skge_change_mtu(struct net_device *dev, int new_mtu) 2428static int skge_change_mtu(struct net_device *dev, int new_mtu)
2413{ 2429{
2414 int err = 0; 2430 int err;
2415 int running = netif_running(dev);
2416 2431
2417 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU) 2432 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
2418 return -EINVAL; 2433 return -EINVAL;
2419 2434
2435 if (!netif_running(dev)) {
2436 dev->mtu = new_mtu;
2437 return 0;
2438 }
2439
2440 skge_down(dev);
2420 2441
2421 if (running)
2422 skge_down(dev);
2423 dev->mtu = new_mtu; 2442 dev->mtu = new_mtu;
2424 if (running) 2443
2425 skge_up(dev); 2444 err = skge_up(dev);
2445 if (err)
2446 dev_close(dev);
2426 2447
2427 return err; 2448 return err;
2428} 2449}
@@ -3396,8 +3417,8 @@ static int skge_resume(struct pci_dev *pdev)
3396 struct net_device *dev = hw->dev[i]; 3417 struct net_device *dev = hw->dev[i];
3397 if (dev) { 3418 if (dev) {
3398 netif_device_attach(dev); 3419 netif_device_attach(dev);
3399 if (netif_running(dev)) 3420 if (netif_running(dev) && skge_up(dev))
3400 skge_up(dev); 3421 dev_close(dev);
3401 } 3422 }
3402 } 3423 }
3403 return 0; 3424 return 0;
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index ee123c15f545..2efdacc290e5 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -475,18 +475,6 @@ enum {
475 Q_T2 = 0x40, /* 32 bit Test Register 2 */ 475 Q_T2 = 0x40, /* 32 bit Test Register 2 */
476 Q_T3 = 0x44, /* 32 bit Test Register 3 */ 476 Q_T3 = 0x44, /* 32 bit Test Register 3 */
477 477
478/* Yukon-2 */
479 Q_DONE = 0x24, /* 16 bit Done Index (Yukon-2 only) */
480 Q_WM = 0x40, /* 16 bit FIFO Watermark */
481 Q_AL = 0x42, /* 8 bit FIFO Alignment */
482 Q_RSP = 0x44, /* 16 bit FIFO Read Shadow Pointer */
483 Q_RSL = 0x46, /* 8 bit FIFO Read Shadow Level */
484 Q_RP = 0x48, /* 8 bit FIFO Read Pointer */
485 Q_RL = 0x4a, /* 8 bit FIFO Read Level */
486 Q_WP = 0x4c, /* 8 bit FIFO Write Pointer */
487 Q_WSP = 0x4d, /* 8 bit FIFO Write Shadow Pointer */
488 Q_WL = 0x4e, /* 8 bit FIFO Write Level */
489 Q_WSL = 0x4f, /* 8 bit FIFO Write Shadow Level */
490}; 478};
491#define Q_ADDR(reg, offs) (B8_Q_REGS + (reg) + (offs)) 479#define Q_ADDR(reg, offs) (B8_Q_REGS + (reg) + (offs))
492 480
@@ -675,22 +663,16 @@ enum {
675 LED_OFF = 1<<0, /* switch LED off */ 663 LED_OFF = 1<<0, /* switch LED off */
676}; 664};
677 665
678/* Receive GMAC FIFO (YUKON and Yukon-2) */ 666/* Receive GMAC FIFO (YUKON) */
679enum { 667enum {
680 RX_GMF_EA = 0x0c40,/* 32 bit Rx GMAC FIFO End Address */ 668 RX_GMF_EA = 0x0c40,/* 32 bit Rx GMAC FIFO End Address */
681 RX_GMF_AF_THR = 0x0c44,/* 32 bit Rx GMAC FIFO Almost Full Thresh. */ 669 RX_GMF_AF_THR = 0x0c44,/* 32 bit Rx GMAC FIFO Almost Full Thresh. */
682 RX_GMF_CTRL_T = 0x0c48,/* 32 bit Rx GMAC FIFO Control/Test */ 670 RX_GMF_CTRL_T = 0x0c48,/* 32 bit Rx GMAC FIFO Control/Test */
683 RX_GMF_FL_MSK = 0x0c4c,/* 32 bit Rx GMAC FIFO Flush Mask */ 671 RX_GMF_FL_MSK = 0x0c4c,/* 32 bit Rx GMAC FIFO Flush Mask */
684 RX_GMF_FL_THR = 0x0c50,/* 32 bit Rx GMAC FIFO Flush Threshold */ 672 RX_GMF_FL_THR = 0x0c50,/* 32 bit Rx GMAC FIFO Flush Threshold */
685 RX_GMF_TR_THR = 0x0c54,/* 32 bit Rx Truncation Threshold (Yukon-2) */
686
687 RX_GMF_VLAN = 0x0c5c,/* 32 bit Rx VLAN Type Register (Yukon-2) */
688 RX_GMF_WP = 0x0c60,/* 32 bit Rx GMAC FIFO Write Pointer */ 673 RX_GMF_WP = 0x0c60,/* 32 bit Rx GMAC FIFO Write Pointer */
689
690 RX_GMF_WLEV = 0x0c68,/* 32 bit Rx GMAC FIFO Write Level */ 674 RX_GMF_WLEV = 0x0c68,/* 32 bit Rx GMAC FIFO Write Level */
691
692 RX_GMF_RP = 0x0c70,/* 32 bit Rx GMAC FIFO Read Pointer */ 675 RX_GMF_RP = 0x0c70,/* 32 bit Rx GMAC FIFO Read Pointer */
693
694 RX_GMF_RLEV = 0x0c78,/* 32 bit Rx GMAC FIFO Read Level */ 676 RX_GMF_RLEV = 0x0c78,/* 32 bit Rx GMAC FIFO Read Level */
695}; 677};
696 678
@@ -855,48 +837,6 @@ enum {
855 GMAC_TI_ST_TST = 0x0e1a,/* 8 bit Time Stamp Timer Test Reg */ 837 GMAC_TI_ST_TST = 0x0e1a,/* 8 bit Time Stamp Timer Test Reg */
856}; 838};
857 839
858/* Status BMU Registers (Yukon-2 only)*/
859enum {
860 STAT_CTRL = 0x0e80,/* 32 bit Status BMU Control Reg */
861 STAT_LAST_IDX = 0x0e84,/* 16 bit Status BMU Last Index */
862 /* 0x0e85 - 0x0e86: reserved */
863 STAT_LIST_ADDR_LO = 0x0e88,/* 32 bit Status List Start Addr (low) */
864 STAT_LIST_ADDR_HI = 0x0e8c,/* 32 bit Status List Start Addr (high) */
865 STAT_TXA1_RIDX = 0x0e90,/* 16 bit Status TxA1 Report Index Reg */
866 STAT_TXS1_RIDX = 0x0e92,/* 16 bit Status TxS1 Report Index Reg */
867 STAT_TXA2_RIDX = 0x0e94,/* 16 bit Status TxA2 Report Index Reg */
868 STAT_TXS2_RIDX = 0x0e96,/* 16 bit Status TxS2 Report Index Reg */
869 STAT_TX_IDX_TH = 0x0e98,/* 16 bit Status Tx Index Threshold Reg */
870 STAT_PUT_IDX = 0x0e9c,/* 16 bit Status Put Index Reg */
871
872/* FIFO Control/Status Registers (Yukon-2 only)*/
873 STAT_FIFO_WP = 0x0ea0,/* 8 bit Status FIFO Write Pointer Reg */
874 STAT_FIFO_RP = 0x0ea4,/* 8 bit Status FIFO Read Pointer Reg */
875 STAT_FIFO_RSP = 0x0ea6,/* 8 bit Status FIFO Read Shadow Ptr */
876 STAT_FIFO_LEVEL = 0x0ea8,/* 8 bit Status FIFO Level Reg */
877 STAT_FIFO_SHLVL = 0x0eaa,/* 8 bit Status FIFO Shadow Level Reg */
878 STAT_FIFO_WM = 0x0eac,/* 8 bit Status FIFO Watermark Reg */
879 STAT_FIFO_ISR_WM = 0x0ead,/* 8 bit Status FIFO ISR Watermark Reg */
880
881/* Level and ISR Timer Registers (Yukon-2 only)*/
882 STAT_LEV_TIMER_INI = 0x0eb0,/* 32 bit Level Timer Init. Value Reg */
883 STAT_LEV_TIMER_CNT = 0x0eb4,/* 32 bit Level Timer Counter Reg */
884 STAT_LEV_TIMER_CTRL = 0x0eb8,/* 8 bit Level Timer Control Reg */
885 STAT_LEV_TIMER_TEST = 0x0eb9,/* 8 bit Level Timer Test Reg */
886 STAT_TX_TIMER_INI = 0x0ec0,/* 32 bit Tx Timer Init. Value Reg */
887 STAT_TX_TIMER_CNT = 0x0ec4,/* 32 bit Tx Timer Counter Reg */
888 STAT_TX_TIMER_CTRL = 0x0ec8,/* 8 bit Tx Timer Control Reg */
889 STAT_TX_TIMER_TEST = 0x0ec9,/* 8 bit Tx Timer Test Reg */
890 STAT_ISR_TIMER_INI = 0x0ed0,/* 32 bit ISR Timer Init. Value Reg */
891 STAT_ISR_TIMER_CNT = 0x0ed4,/* 32 bit ISR Timer Counter Reg */
892 STAT_ISR_TIMER_CTRL = 0x0ed8,/* 8 bit ISR Timer Control Reg */
893 STAT_ISR_TIMER_TEST = 0x0ed9,/* 8 bit ISR Timer Test Reg */
894
895 ST_LAST_IDX_MASK = 0x007f,/* Last Index Mask */
896 ST_TXRP_IDX_MASK = 0x0fff,/* Tx Report Index Mask */
897 ST_TXTH_IDX_MASK = 0x0fff,/* Tx Threshold Index Mask */
898 ST_WM_IDX_MASK = 0x3f,/* FIFO Watermark Index Mask */
899};
900 840
901enum { 841enum {
902 LINKLED_OFF = 0x01, 842 LINKLED_OFF = 0x01,
@@ -923,8 +863,6 @@ enum {
923 WOL_MATCH_CTL = 0x0f22,/* 8 bit WOL Match Control Reg */ 863 WOL_MATCH_CTL = 0x0f22,/* 8 bit WOL Match Control Reg */
924 WOL_MATCH_RES = 0x0f23,/* 8 bit WOL Match Result Reg */ 864 WOL_MATCH_RES = 0x0f23,/* 8 bit WOL Match Result Reg */
925 WOL_MAC_ADDR = 0x0f24,/* 32 bit WOL MAC Address */ 865 WOL_MAC_ADDR = 0x0f24,/* 32 bit WOL MAC Address */
926 WOL_PATT_PME = 0x0f2a,/* 8 bit WOL PME Match Enable (Yukon-2) */
927 WOL_PATT_ASFM = 0x0f2b,/* 8 bit WOL ASF Match Enable (Yukon-2) */
928 WOL_PATT_RPTR = 0x0f2c,/* 8 bit WOL Pattern Read Pointer */ 866 WOL_PATT_RPTR = 0x0f2c,/* 8 bit WOL Pattern Read Pointer */
929 867
930/* WOL Pattern Length Registers (YUKON only) */ 868/* WOL Pattern Length Registers (YUKON only) */
@@ -1641,15 +1579,6 @@ enum {
1641 PHY_M_FESC_SEL_CL_A = 1<<0, /* Select Class A driver (100B-TX) */ 1579 PHY_M_FESC_SEL_CL_A = 1<<0, /* Select Class A driver (100B-TX) */
1642}; 1580};
1643 1581
1644/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
1645/***** PHY_MARV_PHY_CTRL (page 2) 16 bit r/w MAC Specific Ctrl *****/
1646enum {
1647 PHY_M_MAC_MD_MSK = 7<<7, /* Bit 9.. 7: Mode Select Mask */
1648 PHY_M_MAC_MD_AUTO = 3,/* Auto Copper/1000Base-X */
1649 PHY_M_MAC_MD_COPPER = 5,/* Copper only */
1650 PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */
1651};
1652#define PHY_M_MAC_MODE_SEL(x) (((x)<<7) & PHY_M_MAC_MD_MSK)
1653 1582
1654/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ 1583/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/
1655enum { 1584enum {
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
new file mode 100644
index 000000000000..f5d697c0c031
--- /dev/null
+++ b/drivers/net/sky2.c
@@ -0,0 +1,3262 @@
1/*
2 * New driver for Marvell Yukon 2 chipset.
3 * Based on earlier sk98lin, and skge driver.
4 *
5 * This driver intentionally does not support all the features
6 * of the original driver such as link fail-over and link management because
7 * those should be done at higher levels.
8 *
9 * Copyright (C) 2005 Stephen Hemminger <shemminger@osdl.org>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26/*
27 * TOTEST
28 * - speed setting
29 * - suspend/resume
30 */
31
32#include <linux/config.h>
33#include <linux/crc32.h>
34#include <linux/kernel.h>
35#include <linux/version.h>
36#include <linux/module.h>
37#include <linux/netdevice.h>
38#include <linux/dma-mapping.h>
39#include <linux/etherdevice.h>
40#include <linux/ethtool.h>
41#include <linux/pci.h>
42#include <linux/ip.h>
43#include <linux/tcp.h>
44#include <linux/in.h>
45#include <linux/delay.h>
46#include <linux/workqueue.h>
47#include <linux/if_vlan.h>
48#include <linux/prefetch.h>
49#include <linux/mii.h>
50
51#include <asm/irq.h>
52
53#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
54#define SKY2_VLAN_TAG_USED 1
55#endif
56
57#include "sky2.h"
58
59#define DRV_NAME "sky2"
60#define DRV_VERSION "0.11"
61#define PFX DRV_NAME " "
62
63/*
64 * The Yukon II chipset takes 64 bit command blocks (called list elements)
65 * that are organized into three (receive, transmit, status) different rings
66 * similar to Tigon3. A transmit can require several elements;
67 * a receive requires one (or two if using 64 bit dma).
68 */
69
70#define is_ec_a1(hw) \
71 unlikely((hw)->chip_id == CHIP_ID_YUKON_EC && \
72 (hw)->chip_rev == CHIP_REV_YU_EC_A1)
73
74#define RX_LE_SIZE 512
75#define RX_LE_BYTES (RX_LE_SIZE*sizeof(struct sky2_rx_le))
76#define RX_MAX_PENDING (RX_LE_SIZE/2 - 2)
77#define RX_DEF_PENDING RX_MAX_PENDING
78
79#define TX_RING_SIZE 512
80#define TX_DEF_PENDING (TX_RING_SIZE - 1)
81#define TX_MIN_PENDING 64
82#define MAX_SKB_TX_LE (4 + 2*MAX_SKB_FRAGS)
83
84#define STATUS_RING_SIZE 2048 /* 2 ports * (TX + 2*RX) */
85#define STATUS_LE_BYTES (STATUS_RING_SIZE*sizeof(struct sky2_status_le))
86#define ETH_JUMBO_MTU 9000
87#define TX_WATCHDOG (5 * HZ)
88#define NAPI_WEIGHT 64
89#define PHY_RETRIES 1000
90
91static const u32 default_msg =
92 NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK
93 | NETIF_MSG_TIMER | NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR
94 | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN | NETIF_MSG_INTR;
95
96static int debug = -1; /* defaults above */
97module_param(debug, int, 0);
98MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
99
100static int copybreak __read_mostly = 256;
101module_param(copybreak, int, 0);
102MODULE_PARM_DESC(copybreak, "Receive copy threshold");
103
104static const struct pci_device_id sky2_id_table[] = {
105 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
106 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
107 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) },
108 { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) },
109 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) },
110 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) },
111 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) },
112 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) },
113 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) },
114 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) },
115 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) },
116 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) },
117 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) },
118 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) },
119 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) },
120 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) },
121 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) },
122 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) },
123 { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) },
124 { 0 }
125};
126
127MODULE_DEVICE_TABLE(pci, sky2_id_table);
128
129/* Avoid conditionals by using array */
130static const unsigned txqaddr[] = { Q_XA1, Q_XA2 };
131static const unsigned rxqaddr[] = { Q_R1, Q_R2 };
132
133/* This driver supports yukon2 chipset only */
134static const char *yukon2_name[] = {
135 "XL", /* 0xb3 */
136 "EC Ultra", /* 0xb4 */
137 "UNKNOWN", /* 0xb5 */
138 "EC", /* 0xb6 */
139 "FE", /* 0xb7 */
140};
141
142/* Access to external PHY */
143static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
144{
145 int i;
146
147 gma_write16(hw, port, GM_SMI_DATA, val);
148 gma_write16(hw, port, GM_SMI_CTRL,
149 GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg));
150
151 for (i = 0; i < PHY_RETRIES; i++) {
152 if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY))
153 return 0;
154 udelay(1);
155 }
156
157 printk(KERN_WARNING PFX "%s: phy write timeout\n", hw->dev[port]->name);
158 return -ETIMEDOUT;
159}
160
161static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
162{
163 int i;
164
165 gma_write16(hw, port, GM_SMI_CTRL, GM_SMI_CT_PHY_AD(PHY_ADDR_MARV)
166 | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD);
167
168 for (i = 0; i < PHY_RETRIES; i++) {
169 if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) {
170 *val = gma_read16(hw, port, GM_SMI_DATA);
171 return 0;
172 }
173
174 udelay(1);
175 }
176
177 return -ETIMEDOUT;
178}
179
180static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
181{
182 u16 v;
183
184 if (__gm_phy_read(hw, port, reg, &v) != 0)
185 printk(KERN_WARNING PFX "%s: phy read timeout\n", hw->dev[port]->name);
186 return v;
187}
188
189static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
190{
191 u16 power_control;
192 u32 reg1;
193 int vaux;
194 int ret = 0;
195
196 pr_debug("sky2_set_power_state %d\n", state);
197 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
198
199 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control);
200 vaux = (sky2_read8(hw, B0_CTST) & Y2_VAUX_AVAIL) &&
201 (power_control & PCI_PM_CAP_PME_D3cold);
202
203 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control);
204
205 power_control |= PCI_PM_CTRL_PME_STATUS;
206 power_control &= ~(PCI_PM_CTRL_STATE_MASK);
207
208 switch (state) {
209 case PCI_D0:
210 /* switch power to VCC (WA for VAUX problem) */
211 sky2_write8(hw, B0_POWER_CTRL,
212 PC_VAUX_ENA | PC_VCC_ENA | PC_VAUX_OFF | PC_VCC_ON);
213
214 /* disable Core Clock Division, */
215 sky2_write32(hw, B2_Y2_CLK_CTRL, Y2_CLK_DIV_DIS);
216
217 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
218 /* enable bits are inverted */
219 sky2_write8(hw, B2_Y2_CLK_GATE,
220 Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS |
221 Y2_CLK_GAT_LNK1_DIS | Y2_PCI_CLK_LNK2_DIS |
222 Y2_COR_CLK_LNK2_DIS | Y2_CLK_GAT_LNK2_DIS);
223 else
224 sky2_write8(hw, B2_Y2_CLK_GATE, 0);
225
226 /* Turn off phy power saving */
227 pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1);
228 reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
229
230 /* looks like this XL is back asswards .. */
231 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1) {
232 reg1 |= PCI_Y2_PHY1_COMA;
233 if (hw->ports > 1)
234 reg1 |= PCI_Y2_PHY2_COMA;
235 }
236 pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1);
237 break;
238
239 case PCI_D3hot:
240 case PCI_D3cold:
241 /* Turn on phy power saving */
242 pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1);
243 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
244 reg1 &= ~(PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
245 else
246 reg1 |= (PCI_Y2_PHY1_POWD | PCI_Y2_PHY2_POWD);
247 pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1);
248
249 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
250 sky2_write8(hw, B2_Y2_CLK_GATE, 0);
251 else
252 /* enable bits are inverted */
253 sky2_write8(hw, B2_Y2_CLK_GATE,
254 Y2_PCI_CLK_LNK1_DIS | Y2_COR_CLK_LNK1_DIS |
255 Y2_CLK_GAT_LNK1_DIS | Y2_PCI_CLK_LNK2_DIS |
256 Y2_COR_CLK_LNK2_DIS | Y2_CLK_GAT_LNK2_DIS);
257
258 /* switch power to VAUX */
259 if (vaux && state != PCI_D3cold)
260 sky2_write8(hw, B0_POWER_CTRL,
261 (PC_VAUX_ENA | PC_VCC_ENA |
262 PC_VAUX_ON | PC_VCC_OFF));
263 break;
264 default:
265 printk(KERN_ERR PFX "Unknown power state %d\n", state);
266 ret = -1;
267 }
268
269 pci_write_config_byte(hw->pdev, hw->pm_cap + PCI_PM_CTRL, power_control);
270 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
271 return ret;
272}
273
274static void sky2_phy_reset(struct sky2_hw *hw, unsigned port)
275{
276 u16 reg;
277
278 /* disable all GMAC IRQ's */
279 sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0);
280 /* disable PHY IRQs */
281 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
282
283 gma_write16(hw, port, GM_MC_ADDR_H1, 0); /* clear MC hash */
284 gma_write16(hw, port, GM_MC_ADDR_H2, 0);
285 gma_write16(hw, port, GM_MC_ADDR_H3, 0);
286 gma_write16(hw, port, GM_MC_ADDR_H4, 0);
287
288 reg = gma_read16(hw, port, GM_RX_CTRL);
289 reg |= GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA;
290 gma_write16(hw, port, GM_RX_CTRL, reg);
291}
292
293static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
294{
295 struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
296 u16 ctrl, ct1000, adv, pg, ledctrl, ledover;
297
298 if (sky2->autoneg == AUTONEG_ENABLE && hw->chip_id != CHIP_ID_YUKON_XL) {
299 u16 ectrl = gm_phy_read(hw, port, PHY_MARV_EXT_CTRL);
300
301 ectrl &= ~(PHY_M_EC_M_DSC_MSK | PHY_M_EC_S_DSC_MSK |
302 PHY_M_EC_MAC_S_MSK);
303 ectrl |= PHY_M_EC_MAC_S(MAC_TX_CLK_25_MHZ);
304
305 if (hw->chip_id == CHIP_ID_YUKON_EC)
306 ectrl |= PHY_M_EC_DSC_2(2) | PHY_M_EC_DOWN_S_ENA;
307 else
308 ectrl |= PHY_M_EC_M_DSC(2) | PHY_M_EC_S_DSC(3);
309
310 gm_phy_write(hw, port, PHY_MARV_EXT_CTRL, ectrl);
311 }
312
313 ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL);
314 if (hw->copper) {
315 if (hw->chip_id == CHIP_ID_YUKON_FE) {
316 /* enable automatic crossover */
317 ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO) >> 1;
318 } else {
319 /* disable energy detect */
320 ctrl &= ~PHY_M_PC_EN_DET_MSK;
321
322 /* enable automatic crossover */
323 ctrl |= PHY_M_PC_MDI_XMODE(PHY_M_PC_ENA_AUTO);
324
325 if (sky2->autoneg == AUTONEG_ENABLE &&
326 hw->chip_id == CHIP_ID_YUKON_XL) {
327 ctrl &= ~PHY_M_PC_DSC_MSK;
328 ctrl |= PHY_M_PC_DSC(2) | PHY_M_PC_DOWN_S_ENA;
329 }
330 }
331 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl);
332 } else {
333 /* workaround for deviation #4.88 (CRC errors) */
334 /* disable Automatic Crossover */
335
336 ctrl &= ~PHY_M_PC_MDIX_MSK;
337 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl);
338
339 if (hw->chip_id == CHIP_ID_YUKON_XL) {
340 /* Fiber: select 1000BASE-X only mode MAC Specific Ctrl Reg. */
341 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 2);
342 ctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL);
343 ctrl &= ~PHY_M_MAC_MD_MSK;
344 ctrl |= PHY_M_MAC_MODE_SEL(PHY_M_MAC_MD_1000BX);
345 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ctrl);
346
347 /* select page 1 to access Fiber registers */
348 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 1);
349 }
350 }
351
352 ctrl = gm_phy_read(hw, port, PHY_MARV_CTRL);
353 if (sky2->autoneg == AUTONEG_DISABLE)
354 ctrl &= ~PHY_CT_ANE;
355 else
356 ctrl |= PHY_CT_ANE;
357
358 ctrl |= PHY_CT_RESET;
359 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
360
361 ctrl = 0;
362 ct1000 = 0;
363 adv = PHY_AN_CSMA;
364
365 if (sky2->autoneg == AUTONEG_ENABLE) {
366 if (hw->copper) {
367 if (sky2->advertising & ADVERTISED_1000baseT_Full)
368 ct1000 |= PHY_M_1000C_AFD;
369 if (sky2->advertising & ADVERTISED_1000baseT_Half)
370 ct1000 |= PHY_M_1000C_AHD;
371 if (sky2->advertising & ADVERTISED_100baseT_Full)
372 adv |= PHY_M_AN_100_FD;
373 if (sky2->advertising & ADVERTISED_100baseT_Half)
374 adv |= PHY_M_AN_100_HD;
375 if (sky2->advertising & ADVERTISED_10baseT_Full)
376 adv |= PHY_M_AN_10_FD;
377 if (sky2->advertising & ADVERTISED_10baseT_Half)
378 adv |= PHY_M_AN_10_HD;
379 } else /* special defines for FIBER (88E1011S only) */
380 adv |= PHY_M_AN_1000X_AHD | PHY_M_AN_1000X_AFD;
381
382 /* Set Flow-control capabilities */
383 if (sky2->tx_pause && sky2->rx_pause)
384 adv |= PHY_AN_PAUSE_CAP; /* symmetric */
385 else if (sky2->rx_pause && !sky2->tx_pause)
386 adv |= PHY_AN_PAUSE_ASYM | PHY_AN_PAUSE_CAP;
387 else if (!sky2->rx_pause && sky2->tx_pause)
388 adv |= PHY_AN_PAUSE_ASYM; /* local */
389
390 /* Restart Auto-negotiation */
391 ctrl |= PHY_CT_ANE | PHY_CT_RE_CFG;
392 } else {
393 /* forced speed/duplex settings */
394 ct1000 = PHY_M_1000C_MSE;
395
396 if (sky2->duplex == DUPLEX_FULL)
397 ctrl |= PHY_CT_DUP_MD;
398
399 switch (sky2->speed) {
400 case SPEED_1000:
401 ctrl |= PHY_CT_SP1000;
402 break;
403 case SPEED_100:
404 ctrl |= PHY_CT_SP100;
405 break;
406 }
407
408 ctrl |= PHY_CT_RESET;
409 }
410
411 if (hw->chip_id != CHIP_ID_YUKON_FE)
412 gm_phy_write(hw, port, PHY_MARV_1000T_CTRL, ct1000);
413
414 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV, adv);
415 gm_phy_write(hw, port, PHY_MARV_CTRL, ctrl);
416
417 /* Setup Phy LED's */
418 ledctrl = PHY_M_LED_PULS_DUR(PULS_170MS);
419 ledover = 0;
420
421 switch (hw->chip_id) {
422 case CHIP_ID_YUKON_FE:
423 /* on 88E3082 these bits are at 11..9 (shifted left) */
424 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) << 1;
425
426 ctrl = gm_phy_read(hw, port, PHY_MARV_FE_LED_PAR);
427
428 /* delete ACT LED control bits */
429 ctrl &= ~PHY_M_FELP_LED1_MSK;
430 /* change ACT LED control to blink mode */
431 ctrl |= PHY_M_FELP_LED1_CTRL(LED_PAR_CTRL_ACT_BL);
432 gm_phy_write(hw, port, PHY_MARV_FE_LED_PAR, ctrl);
433 break;
434
435 case CHIP_ID_YUKON_XL:
436 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
437
438 /* select page 3 to access LED control register */
439 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
440
441 /* set LED Function Control register */
442 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, (PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
443 PHY_M_LEDC_INIT_CTRL(7) | /* 10 Mbps */
444 PHY_M_LEDC_STA1_CTRL(7) | /* 100 Mbps */
445 PHY_M_LEDC_STA0_CTRL(7))); /* 1000 Mbps */
446
447 /* set Polarity Control register */
448 gm_phy_write(hw, port, PHY_MARV_PHY_STAT,
449 (PHY_M_POLC_LS1_P_MIX(4) |
450 PHY_M_POLC_IS0_P_MIX(4) |
451 PHY_M_POLC_LOS_CTRL(2) |
452 PHY_M_POLC_INIT_CTRL(2) |
453 PHY_M_POLC_STA1_CTRL(2) |
454 PHY_M_POLC_STA0_CTRL(2)));
455
456 /* restore page register */
457 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
458 break;
459
460 default:
461 /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */
462 ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL;
463 /* turn off the Rx LED (LED_RX) */
464 ledover |= PHY_M_LED_MO_RX(MO_LED_OFF);
465 }
466
467 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
468
469 if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) {
470 /* turn on 100 Mbps LED (LED_LINK100) */
471 ledover |= PHY_M_LED_MO_100(MO_LED_ON);
472 }
473
474 if (ledover)
475 gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover);
476
477 /* Enable phy interrupt on auto-negotiation complete (or link up) */
478 if (sky2->autoneg == AUTONEG_ENABLE)
479 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_IS_AN_COMPL);
480 else
481 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK);
482}
483
484/* Force a renegotiation */
485static void sky2_phy_reinit(struct sky2_port *sky2)
486{
487 down(&sky2->phy_sema);
488 sky2_phy_init(sky2->hw, sky2->port);
489 up(&sky2->phy_sema);
490}
491
492static void sky2_mac_init(struct sky2_hw *hw, unsigned port)
493{
494 struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
495 u16 reg;
496 int i;
497 const u8 *addr = hw->dev[port]->dev_addr;
498
499 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
500 sky2_write32(hw, SK_REG(port, GPHY_CTRL), GPC_RST_CLR|GPC_ENA_PAUSE);
501
502 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_CLR);
503
504 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0 && port == 1) {
505 /* WA DEV_472 -- looks like crossed wires on port 2 */
506 /* clear GMAC 1 Control reset */
507 sky2_write8(hw, SK_REG(0, GMAC_CTRL), GMC_RST_CLR);
508 do {
509 sky2_write8(hw, SK_REG(1, GMAC_CTRL), GMC_RST_SET);
510 sky2_write8(hw, SK_REG(1, GMAC_CTRL), GMC_RST_CLR);
511 } while (gm_phy_read(hw, 1, PHY_MARV_ID0) != PHY_MARV_ID0_VAL ||
512 gm_phy_read(hw, 1, PHY_MARV_ID1) != PHY_MARV_ID1_Y2 ||
513 gm_phy_read(hw, 1, PHY_MARV_INT_MASK) != 0);
514 }
515
516 if (sky2->autoneg == AUTONEG_DISABLE) {
517 reg = gma_read16(hw, port, GM_GP_CTRL);
518 reg |= GM_GPCR_AU_ALL_DIS;
519 gma_write16(hw, port, GM_GP_CTRL, reg);
520 gma_read16(hw, port, GM_GP_CTRL);
521
522 switch (sky2->speed) {
523 case SPEED_1000:
524 reg |= GM_GPCR_SPEED_1000;
525 /* fallthru */
526 case SPEED_100:
527 reg |= GM_GPCR_SPEED_100;
528 }
529
530 if (sky2->duplex == DUPLEX_FULL)
531 reg |= GM_GPCR_DUP_FULL;
532 } else
533 reg = GM_GPCR_SPEED_1000 | GM_GPCR_SPEED_100 | GM_GPCR_DUP_FULL;
534
535 if (!sky2->tx_pause && !sky2->rx_pause) {
536 sky2_write32(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
537 reg |=
538 GM_GPCR_FC_TX_DIS | GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
539 } else if (sky2->tx_pause && !sky2->rx_pause) {
540 /* disable Rx flow-control */
541 reg |= GM_GPCR_FC_RX_DIS | GM_GPCR_AU_FCT_DIS;
542 }
543
544 gma_write16(hw, port, GM_GP_CTRL, reg);
545
546 sky2_read16(hw, SK_REG(port, GMAC_IRQ_SRC));
547
548 down(&sky2->phy_sema);
549 sky2_phy_init(hw, port);
550 up(&sky2->phy_sema);
551
552 /* MIB clear */
553 reg = gma_read16(hw, port, GM_PHY_ADDR);
554 gma_write16(hw, port, GM_PHY_ADDR, reg | GM_PAR_MIB_CLR);
555
556 for (i = 0; i < GM_MIB_CNT_SIZE; i++)
557 gma_read16(hw, port, GM_MIB_CNT_BASE + 8 * i);
558 gma_write16(hw, port, GM_PHY_ADDR, reg);
559
560 /* transmit control */
561 gma_write16(hw, port, GM_TX_CTRL, TX_COL_THR(TX_COL_DEF));
562
563 /* receive control reg: unicast + multicast + no FCS */
564 gma_write16(hw, port, GM_RX_CTRL,
565 GM_RXCR_UCF_ENA | GM_RXCR_CRC_DIS | GM_RXCR_MCF_ENA);
566
567 /* transmit flow control */
568 gma_write16(hw, port, GM_TX_FLOW_CTRL, 0xffff);
569
570 /* transmit parameter */
571 gma_write16(hw, port, GM_TX_PARAM,
572 TX_JAM_LEN_VAL(TX_JAM_LEN_DEF) |
573 TX_JAM_IPG_VAL(TX_JAM_IPG_DEF) |
574 TX_IPG_JAM_DATA(TX_IPG_JAM_DEF) |
575 TX_BACK_OFF_LIM(TX_BOF_LIM_DEF));
576
577 /* serial mode register */
578 reg = DATA_BLIND_VAL(DATA_BLIND_DEF) |
579 GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF);
580
581 if (hw->dev[port]->mtu > ETH_DATA_LEN)
582 reg |= GM_SMOD_JUMBO_ENA;
583
584 gma_write16(hw, port, GM_SERIAL_MODE, reg);
585
586 /* virtual address for data */
587 gma_set_addr(hw, port, GM_SRC_ADDR_2L, addr);
588
589 /* physical address: used for pause frames */
590 gma_set_addr(hw, port, GM_SRC_ADDR_1L, addr);
591
592 /* ignore counter overflows */
593 gma_write16(hw, port, GM_TX_IRQ_MSK, 0);
594 gma_write16(hw, port, GM_RX_IRQ_MSK, 0);
595 gma_write16(hw, port, GM_TR_IRQ_MSK, 0);
596
597 /* Configure Rx MAC FIFO */
598 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_CLR);
599 sky2_write16(hw, SK_REG(port, RX_GMF_CTRL_T),
600 GMF_RX_CTRL_DEF);
601
602 /* Flush Rx MAC FIFO on any flow control or error */
603 sky2_write16(hw, SK_REG(port, RX_GMF_FL_MSK), GMR_FS_ANY_ERR);
604
605 /* Set threshold to 0xa (64 bytes)
606 * ASF disabled so no need to do WA dev #4.30
607 */
608 sky2_write16(hw, SK_REG(port, RX_GMF_FL_THR), RX_GMF_FL_THR_DEF);
609
610 /* Configure Tx MAC FIFO */
611 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_CLR);
612 sky2_write16(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_OPER_ON);
613
614 if (hw->chip_id == CHIP_ID_YUKON_EC_U) {
615 sky2_write8(hw, SK_REG(port, RX_GMF_LP_THR), 768/8);
616 sky2_write8(hw, SK_REG(port, RX_GMF_UP_THR), 1024/8);
617 if (hw->dev[port]->mtu > ETH_DATA_LEN) {
618 /* set Tx GMAC FIFO Almost Empty Threshold */
619 sky2_write32(hw, SK_REG(port, TX_GMF_AE_THR), 0x180);
620 /* Disable Store & Forward mode for TX */
621 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_STFW_DIS);
622 }
623 }
624
625}
626
627static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, size_t len)
628{
629 u32 end;
630
631 start /= 8;
632 len /= 8;
633 end = start + len - 1;
634
635 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR);
636 sky2_write32(hw, RB_ADDR(q, RB_START), start);
637 sky2_write32(hw, RB_ADDR(q, RB_END), end);
638 sky2_write32(hw, RB_ADDR(q, RB_WP), start);
639 sky2_write32(hw, RB_ADDR(q, RB_RP), start);
640
641 if (q == Q_R1 || q == Q_R2) {
642 u32 rxup, rxlo;
643
644 rxlo = len/2;
645 rxup = rxlo + len/4;
646
647 /* Set thresholds on receive queue's */
648 sky2_write32(hw, RB_ADDR(q, RB_RX_UTPP), rxup);
649 sky2_write32(hw, RB_ADDR(q, RB_RX_LTPP), rxlo);
650 } else {
651 /* Enable store & forward on Tx queue's because
652 * Tx FIFO is only 1K on Yukon
653 */
654 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_ENA_STFWD);
655 }
656
657 sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_ENA_OP_MD);
658 sky2_read8(hw, RB_ADDR(q, RB_CTRL));
659}
660
661/* Setup Bus Memory Interface */
662static void sky2_qset(struct sky2_hw *hw, u16 q)
663{
664 sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_CLR_RESET);
665 sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_OPER_INIT);
666 sky2_write32(hw, Q_ADDR(q, Q_CSR), BMU_FIFO_OP_ON);
667 sky2_write32(hw, Q_ADDR(q, Q_WM), BMU_WM_DEFAULT);
668}
669
670/* Setup prefetch unit registers. This is the interface between
671 * hardware and driver list elements
672 */
673static void sky2_prefetch_init(struct sky2_hw *hw, u32 qaddr,
674 u64 addr, u32 last)
675{
676 sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
677 sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_RST_CLR);
678 sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_HI), addr >> 32);
679 sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_ADDR_LO), (u32) addr);
680 sky2_write16(hw, Y2_QADDR(qaddr, PREF_UNIT_LAST_IDX), last);
681 sky2_write32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL), PREF_UNIT_OP_ON);
682
683 sky2_read32(hw, Y2_QADDR(qaddr, PREF_UNIT_CTRL));
684}
685
686static inline struct sky2_tx_le *get_tx_le(struct sky2_port *sky2)
687{
688 struct sky2_tx_le *le = sky2->tx_le + sky2->tx_prod;
689
690 sky2->tx_prod = (sky2->tx_prod + 1) % TX_RING_SIZE;
691 return le;
692}
693
694/*
695 * This is a workaround code taken from SysKonnect sk98lin driver
696 * to deal with chip bug on Yukon EC rev 0 in the wraparound case.
697 */
698static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q,
699 u16 idx, u16 *last, u16 size)
700{
701 if (is_ec_a1(hw) && idx < *last) {
702 u16 hwget = sky2_read16(hw, Y2_QADDR(q, PREF_UNIT_GET_IDX));
703
704 if (hwget == 0) {
705 /* Start prefetching again */
706 sky2_write8(hw, Y2_QADDR(q, PREF_UNIT_FIFO_WM), 0xe0);
707 goto setnew;
708 }
709
710 if (hwget == size - 1) {
711 /* set watermark to one list element */
712 sky2_write8(hw, Y2_QADDR(q, PREF_UNIT_FIFO_WM), 8);
713
714 /* set put index to first list element */
715 sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), 0);
716 } else /* have hardware go to end of list */
717 sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX),
718 size - 1);
719 } else {
720setnew:
721 sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx);
722 }
723 *last = idx;
724}
725
726
727static inline struct sky2_rx_le *sky2_next_rx(struct sky2_port *sky2)
728{
729 struct sky2_rx_le *le = sky2->rx_le + sky2->rx_put;
730 sky2->rx_put = (sky2->rx_put + 1) % RX_LE_SIZE;
731 return le;
732}
733
734/* Return high part of DMA address (could be 32 or 64 bit) */
735static inline u32 high32(dma_addr_t a)
736{
737 return (a >> 16) >> 16;
738}
739
740/* Build description to hardware about buffer */
741static inline void sky2_rx_add(struct sky2_port *sky2, dma_addr_t map)
742{
743 struct sky2_rx_le *le;
744 u32 hi = high32(map);
745 u16 len = sky2->rx_bufsize;
746
747 if (sky2->rx_addr64 != hi) {
748 le = sky2_next_rx(sky2);
749 le->addr = cpu_to_le32(hi);
750 le->ctrl = 0;
751 le->opcode = OP_ADDR64 | HW_OWNER;
752 sky2->rx_addr64 = high32(map + len);
753 }
754
755 le = sky2_next_rx(sky2);
756 le->addr = cpu_to_le32((u32) map);
757 le->length = cpu_to_le16(len);
758 le->ctrl = 0;
759 le->opcode = OP_PACKET | HW_OWNER;
760}
761
762
763/* Tell chip where to start receive checksum.
764 * Actually has two checksums, but set both same to avoid possible byte
765 * order problems.
766 */
767static void rx_set_checksum(struct sky2_port *sky2)
768{
769 struct sky2_rx_le *le;
770
771 le = sky2_next_rx(sky2);
772 le->addr = (ETH_HLEN << 16) | ETH_HLEN;
773 le->ctrl = 0;
774 le->opcode = OP_TCPSTART | HW_OWNER;
775
776 sky2_write32(sky2->hw,
777 Q_ADDR(rxqaddr[sky2->port], Q_CSR),
778 sky2->rx_csum ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
779
780}
781
782/*
783 * The RX Stop command will not work for Yukon-2 if the BMU does not
784 * reach the end of packet and since we can't make sure that we have
785 * incoming data, we must reset the BMU while it is not doing a DMA
786 * transfer. Since it is possible that the RX path is still active,
787 * the RX RAM buffer will be stopped first, so any possible incoming
788 * data will not trigger a DMA. After the RAM buffer is stopped, the
789 * BMU is polled until any DMA in progress is ended and only then it
790 * will be reset.
791 */
792static void sky2_rx_stop(struct sky2_port *sky2)
793{
794 struct sky2_hw *hw = sky2->hw;
795 unsigned rxq = rxqaddr[sky2->port];
796 int i;
797
798 /* disable the RAM Buffer receive queue */
799 sky2_write8(hw, RB_ADDR(rxq, RB_CTRL), RB_DIS_OP_MD);
800
801 for (i = 0; i < 0xffff; i++)
802 if (sky2_read8(hw, RB_ADDR(rxq, Q_RSL))
803 == sky2_read8(hw, RB_ADDR(rxq, Q_RL)))
804 goto stopped;
805
806 printk(KERN_WARNING PFX "%s: receiver stop failed\n",
807 sky2->netdev->name);
808stopped:
809 sky2_write32(hw, Q_ADDR(rxq, Q_CSR), BMU_RST_SET | BMU_FIFO_RST);
810
811 /* reset the Rx prefetch unit */
812 sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
813}
814
815/* Clean out receive buffer area, assumes receiver hardware stopped */
816static void sky2_rx_clean(struct sky2_port *sky2)
817{
818 unsigned i;
819
820 memset(sky2->rx_le, 0, RX_LE_BYTES);
821 for (i = 0; i < sky2->rx_pending; i++) {
822 struct ring_info *re = sky2->rx_ring + i;
823
824 if (re->skb) {
825 pci_unmap_single(sky2->hw->pdev,
826 re->mapaddr, sky2->rx_bufsize,
827 PCI_DMA_FROMDEVICE);
828 kfree_skb(re->skb);
829 re->skb = NULL;
830 }
831 }
832}
833
834/* Basic MII support */
835static int sky2_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
836{
837 struct mii_ioctl_data *data = if_mii(ifr);
838 struct sky2_port *sky2 = netdev_priv(dev);
839 struct sky2_hw *hw = sky2->hw;
840 int err = -EOPNOTSUPP;
841
842 if (!netif_running(dev))
843 return -ENODEV; /* Phy still in reset */
844
845 switch(cmd) {
846 case SIOCGMIIPHY:
847 data->phy_id = PHY_ADDR_MARV;
848
849 /* fallthru */
850 case SIOCGMIIREG: {
851 u16 val = 0;
852
853 down(&sky2->phy_sema);
854 err = __gm_phy_read(hw, sky2->port, data->reg_num & 0x1f, &val);
855 up(&sky2->phy_sema);
856
857 data->val_out = val;
858 break;
859 }
860
861 case SIOCSMIIREG:
862 if (!capable(CAP_NET_ADMIN))
863 return -EPERM;
864
865 down(&sky2->phy_sema);
866 err = gm_phy_write(hw, sky2->port, data->reg_num & 0x1f,
867 data->val_in);
868 up(&sky2->phy_sema);
869 break;
870 }
871 return err;
872}
873
874#ifdef SKY2_VLAN_TAG_USED
875static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
876{
877 struct sky2_port *sky2 = netdev_priv(dev);
878 struct sky2_hw *hw = sky2->hw;
879 u16 port = sky2->port;
880
881 spin_lock(&sky2->tx_lock);
882
883 sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_ON);
884 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_ON);
885 sky2->vlgrp = grp;
886
887 spin_unlock(&sky2->tx_lock);
888}
889
890static void sky2_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
891{
892 struct sky2_port *sky2 = netdev_priv(dev);
893 struct sky2_hw *hw = sky2->hw;
894 u16 port = sky2->port;
895
896 spin_lock(&sky2->tx_lock);
897
898 sky2_write32(hw, SK_REG(port, RX_GMF_CTRL_T), RX_VLAN_STRIP_OFF);
899 sky2_write32(hw, SK_REG(port, TX_GMF_CTRL_T), TX_VLAN_TAG_OFF);
900 if (sky2->vlgrp)
901 sky2->vlgrp->vlan_devices[vid] = NULL;
902
903 spin_unlock(&sky2->tx_lock);
904}
905#endif
906
907/*
908 * Allocate and setup receiver buffer pool.
909 * In case of 64 bit dma, there are 2X as many list elements
910 * available as ring entries
911 * and need to reserve one list element so we don't wrap around.
912 *
913 * It appears the hardware has a bug in the FIFO logic that
914 * cause it to hang if the FIFO gets overrun and the receive buffer
915 * is not aligned. This means we can't use skb_reserve to align
916 * the IP header.
917 */
918static int sky2_rx_start(struct sky2_port *sky2)
919{
920 struct sky2_hw *hw = sky2->hw;
921 unsigned rxq = rxqaddr[sky2->port];
922 int i;
923
924 sky2->rx_put = sky2->rx_next = 0;
925 sky2_qset(hw, rxq);
926 sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1);
927
928 rx_set_checksum(sky2);
929 for (i = 0; i < sky2->rx_pending; i++) {
930 struct ring_info *re = sky2->rx_ring + i;
931
932 re->skb = dev_alloc_skb(sky2->rx_bufsize);
933 if (!re->skb)
934 goto nomem;
935
936 re->mapaddr = pci_map_single(hw->pdev, re->skb->data,
937 sky2->rx_bufsize, PCI_DMA_FROMDEVICE);
938 sky2_rx_add(sky2, re->mapaddr);
939 }
940
941 /* Tell chip about available buffers */
942 sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put);
943 sky2->rx_last_put = sky2_read16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX));
944 return 0;
945nomem:
946 sky2_rx_clean(sky2);
947 return -ENOMEM;
948}
949
950/* Bring up network interface. */
951static int sky2_up(struct net_device *dev)
952{
953 struct sky2_port *sky2 = netdev_priv(dev);
954 struct sky2_hw *hw = sky2->hw;
955 unsigned port = sky2->port;
956 u32 ramsize, rxspace;
957 int err = -ENOMEM;
958
959 if (netif_msg_ifup(sky2))
960 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
961
962 /* must be power of 2 */
963 sky2->tx_le = pci_alloc_consistent(hw->pdev,
964 TX_RING_SIZE *
965 sizeof(struct sky2_tx_le),
966 &sky2->tx_le_map);
967 if (!sky2->tx_le)
968 goto err_out;
969
970 sky2->tx_ring = kcalloc(TX_RING_SIZE, sizeof(struct tx_ring_info),
971 GFP_KERNEL);
972 if (!sky2->tx_ring)
973 goto err_out;
974 sky2->tx_prod = sky2->tx_cons = 0;
975
976 sky2->rx_le = pci_alloc_consistent(hw->pdev, RX_LE_BYTES,
977 &sky2->rx_le_map);
978 if (!sky2->rx_le)
979 goto err_out;
980 memset(sky2->rx_le, 0, RX_LE_BYTES);
981
982 sky2->rx_ring = kcalloc(sky2->rx_pending, sizeof(struct ring_info),
983 GFP_KERNEL);
984 if (!sky2->rx_ring)
985 goto err_out;
986
987 sky2_mac_init(hw, port);
988
989 /* Configure RAM buffers */
990 if (hw->chip_id == CHIP_ID_YUKON_FE ||
991 (hw->chip_id == CHIP_ID_YUKON_EC && hw->chip_rev == 2))
992 ramsize = 4096;
993 else {
994 u8 e0 = sky2_read8(hw, B2_E_0);
995 ramsize = (e0 == 0) ? (128 * 1024) : (e0 * 4096);
996 }
997
998 /* 2/3 for Rx */
999 rxspace = (2 * ramsize) / 3;
1000 sky2_ramset(hw, rxqaddr[port], 0, rxspace);
1001 sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace);
1002
1003 /* Make sure SyncQ is disabled */
1004 sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL),
1005 RB_RST_SET);
1006
1007 sky2_qset(hw, txqaddr[port]);
1008 if (hw->chip_id == CHIP_ID_YUKON_EC_U)
1009 sky2_write16(hw, Q_ADDR(txqaddr[port], Q_AL), 0x1a0);
1010
1011
1012 sky2_prefetch_init(hw, txqaddr[port], sky2->tx_le_map,
1013 TX_RING_SIZE - 1);
1014
1015 err = sky2_rx_start(sky2);
1016 if (err)
1017 goto err_out;
1018
1019 /* Enable interrupts from phy/mac for port */
1020 hw->intr_mask |= (port == 0) ? Y2_IS_PORT_1 : Y2_IS_PORT_2;
1021 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1022 return 0;
1023
1024err_out:
1025 if (sky2->rx_le) {
1026 pci_free_consistent(hw->pdev, RX_LE_BYTES,
1027 sky2->rx_le, sky2->rx_le_map);
1028 sky2->rx_le = NULL;
1029 }
1030 if (sky2->tx_le) {
1031 pci_free_consistent(hw->pdev,
1032 TX_RING_SIZE * sizeof(struct sky2_tx_le),
1033 sky2->tx_le, sky2->tx_le_map);
1034 sky2->tx_le = NULL;
1035 }
1036 kfree(sky2->tx_ring);
1037 kfree(sky2->rx_ring);
1038
1039 sky2->tx_ring = NULL;
1040 sky2->rx_ring = NULL;
1041 return err;
1042}
1043
1044/* Modular subtraction in ring */
1045static inline int tx_dist(unsigned tail, unsigned head)
1046{
1047 return (head - tail) % TX_RING_SIZE;
1048}
1049
1050/* Number of list elements available for next tx */
1051static inline int tx_avail(const struct sky2_port *sky2)
1052{
1053 return sky2->tx_pending - tx_dist(sky2->tx_cons, sky2->tx_prod);
1054}
1055
1056/* Estimate of number of transmit list elements required */
1057static inline unsigned tx_le_req(const struct sk_buff *skb)
1058{
1059 unsigned count;
1060
1061 count = sizeof(dma_addr_t) / sizeof(u32);
1062 count += skb_shinfo(skb)->nr_frags * count;
1063
1064 if (skb_shinfo(skb)->tso_size)
1065 ++count;
1066
1067 if (skb->ip_summed == CHECKSUM_HW)
1068 ++count;
1069
1070 return count;
1071}
1072
1073/*
1074 * Put one packet in ring for transmit.
1075 * A single packet can generate multiple list elements, and
1076 * the number of ring elements will probably be less than the number
1077 * of list elements used.
1078 *
1079 * No BH disabling for tx_lock here (like tg3)
1080 */
1081static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
1082{
1083 struct sky2_port *sky2 = netdev_priv(dev);
1084 struct sky2_hw *hw = sky2->hw;
1085 struct sky2_tx_le *le = NULL;
1086 struct tx_ring_info *re;
1087 unsigned i, len;
1088 dma_addr_t mapping;
1089 u32 addr64;
1090 u16 mss;
1091 u8 ctrl;
1092
1093 if (!spin_trylock(&sky2->tx_lock))
1094 return NETDEV_TX_LOCKED;
1095
1096 if (unlikely(tx_avail(sky2) < tx_le_req(skb))) {
1097 /* There is a known but harmless race with lockless tx
1098 * and netif_stop_queue.
1099 */
1100 if (!netif_queue_stopped(dev)) {
1101 netif_stop_queue(dev);
1102 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n",
1103 dev->name);
1104 }
1105 spin_unlock(&sky2->tx_lock);
1106
1107 return NETDEV_TX_BUSY;
1108 }
1109
1110 if (unlikely(netif_msg_tx_queued(sky2)))
1111 printk(KERN_DEBUG "%s: tx queued, slot %u, len %d\n",
1112 dev->name, sky2->tx_prod, skb->len);
1113
1114 len = skb_headlen(skb);
1115 mapping = pci_map_single(hw->pdev, skb->data, len, PCI_DMA_TODEVICE);
1116 addr64 = high32(mapping);
1117
1118 re = sky2->tx_ring + sky2->tx_prod;
1119
1120 /* Send high bits if changed or crosses boundary */
1121 if (addr64 != sky2->tx_addr64 || high32(mapping + len) != sky2->tx_addr64) {
1122 le = get_tx_le(sky2);
1123 le->tx.addr = cpu_to_le32(addr64);
1124 le->ctrl = 0;
1125 le->opcode = OP_ADDR64 | HW_OWNER;
1126 sky2->tx_addr64 = high32(mapping + len);
1127 }
1128
1129 /* Check for TCP Segmentation Offload */
1130 mss = skb_shinfo(skb)->tso_size;
1131 if (mss != 0) {
1132 /* just drop the packet if non-linear expansion fails */
1133 if (skb_header_cloned(skb) &&
1134 pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
1135 dev_kfree_skb_any(skb);
1136 goto out_unlock;
1137 }
1138
1139 mss += ((skb->h.th->doff - 5) * 4); /* TCP options */
1140 mss += (skb->nh.iph->ihl * 4) + sizeof(struct tcphdr);
1141 mss += ETH_HLEN;
1142 }
1143
1144 if (mss != sky2->tx_last_mss) {
1145 le = get_tx_le(sky2);
1146 le->tx.tso.size = cpu_to_le16(mss);
1147 le->tx.tso.rsvd = 0;
1148 le->opcode = OP_LRGLEN | HW_OWNER;
1149 le->ctrl = 0;
1150 sky2->tx_last_mss = mss;
1151 }
1152
1153 ctrl = 0;
1154#ifdef SKY2_VLAN_TAG_USED
1155 /* Add VLAN tag, can piggyback on LRGLEN or ADDR64 */
1156 if (sky2->vlgrp && vlan_tx_tag_present(skb)) {
1157 if (!le) {
1158 le = get_tx_le(sky2);
1159 le->tx.addr = 0;
1160 le->opcode = OP_VLAN|HW_OWNER;
1161 le->ctrl = 0;
1162 } else
1163 le->opcode |= OP_VLAN;
1164 le->length = cpu_to_be16(vlan_tx_tag_get(skb));
1165 ctrl |= INS_VLAN;
1166 }
1167#endif
1168
1169 /* Handle TCP checksum offload */
1170 if (skb->ip_summed == CHECKSUM_HW) {
1171 u16 hdr = skb->h.raw - skb->data;
1172 u16 offset = hdr + skb->csum;
1173
1174 ctrl = CALSUM | WR_SUM | INIT_SUM | LOCK_SUM;
1175 if (skb->nh.iph->protocol == IPPROTO_UDP)
1176 ctrl |= UDPTCP;
1177
1178 le = get_tx_le(sky2);
1179 le->tx.csum.start = cpu_to_le16(hdr);
1180 le->tx.csum.offset = cpu_to_le16(offset);
1181 le->length = 0; /* initial checksum value */
1182 le->ctrl = 1; /* one packet */
1183 le->opcode = OP_TCPLISW | HW_OWNER;
1184 }
1185
1186 le = get_tx_le(sky2);
1187 le->tx.addr = cpu_to_le32((u32) mapping);
1188 le->length = cpu_to_le16(len);
1189 le->ctrl = ctrl;
1190 le->opcode = mss ? (OP_LARGESEND | HW_OWNER) : (OP_PACKET | HW_OWNER);
1191
1192 /* Record the transmit mapping info */
1193 re->skb = skb;
1194 pci_unmap_addr_set(re, mapaddr, mapping);
1195
1196 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1197 skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
1198 struct tx_ring_info *fre;
1199
1200 mapping = pci_map_page(hw->pdev, frag->page, frag->page_offset,
1201 frag->size, PCI_DMA_TODEVICE);
1202 addr64 = (mapping >> 16) >> 16;
1203 if (addr64 != sky2->tx_addr64) {
1204 le = get_tx_le(sky2);
1205 le->tx.addr = cpu_to_le32(addr64);
1206 le->ctrl = 0;
1207 le->opcode = OP_ADDR64 | HW_OWNER;
1208 sky2->tx_addr64 = addr64;
1209 }
1210
1211 le = get_tx_le(sky2);
1212 le->tx.addr = cpu_to_le32((u32) mapping);
1213 le->length = cpu_to_le16(frag->size);
1214 le->ctrl = ctrl;
1215 le->opcode = OP_BUFFER | HW_OWNER;
1216
1217 fre = sky2->tx_ring
1218 + ((re - sky2->tx_ring) + i + 1) % TX_RING_SIZE;
1219 pci_unmap_addr_set(fre, mapaddr, mapping);
1220 }
1221
1222 re->idx = sky2->tx_prod;
1223 le->ctrl |= EOP;
1224
1225 sky2_put_idx(hw, txqaddr[sky2->port], sky2->tx_prod,
1226 &sky2->tx_last_put, TX_RING_SIZE);
1227
1228 if (tx_avail(sky2) <= MAX_SKB_TX_LE)
1229 netif_stop_queue(dev);
1230
1231out_unlock:
1232 mmiowb();
1233 spin_unlock(&sky2->tx_lock);
1234
1235 dev->trans_start = jiffies;
1236 return NETDEV_TX_OK;
1237}
1238
1239/*
1240 * Free ring elements from starting at tx_cons until "done"
1241 *
1242 * NB: the hardware will tell us about partial completion of multi-part
1243 * buffers; these are deferred until completion.
1244 */
1245static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
1246{
1247 struct net_device *dev = sky2->netdev;
1248 struct pci_dev *pdev = sky2->hw->pdev;
1249 u16 nxt, put;
1250 unsigned i;
1251
1252 BUG_ON(done >= TX_RING_SIZE);
1253
1254 if (unlikely(netif_msg_tx_done(sky2)))
1255 printk(KERN_DEBUG "%s: tx done, up to %u\n",
1256 dev->name, done);
1257
1258 for (put = sky2->tx_cons; put != done; put = nxt) {
1259 struct tx_ring_info *re = sky2->tx_ring + put;
1260 struct sk_buff *skb = re->skb;
1261
1262 nxt = re->idx;
1263 BUG_ON(nxt >= TX_RING_SIZE);
1264 prefetch(sky2->tx_ring + nxt);
1265
1266 /* Check for partial status */
1267 if (tx_dist(put, done) < tx_dist(put, nxt))
1268 break;
1269
1270 skb = re->skb;
1271 pci_unmap_single(pdev, pci_unmap_addr(re, mapaddr),
1272 skb_headlen(skb), PCI_DMA_TODEVICE);
1273
1274 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
1275 struct tx_ring_info *fre;
1276 fre = sky2->tx_ring + (put + i + 1) % TX_RING_SIZE;
1277 pci_unmap_page(pdev, pci_unmap_addr(fre, mapaddr),
1278 skb_shinfo(skb)->frags[i].size,
1279 PCI_DMA_TODEVICE);
1280 }
1281
1282 dev_kfree_skb_any(skb);
1283 }
1284
1285 spin_lock(&sky2->tx_lock);
1286 sky2->tx_cons = put;
1287 if (netif_queue_stopped(dev) && tx_avail(sky2) > MAX_SKB_TX_LE)
1288 netif_wake_queue(dev);
1289 spin_unlock(&sky2->tx_lock);
1290}
1291
1292/* Cleanup all untransmitted buffers, assume transmitter not running */
1293static void sky2_tx_clean(struct sky2_port *sky2)
1294{
1295 sky2_tx_complete(sky2, sky2->tx_prod);
1296}
1297
1298/* Network shutdown */
1299static int sky2_down(struct net_device *dev)
1300{
1301 struct sky2_port *sky2 = netdev_priv(dev);
1302 struct sky2_hw *hw = sky2->hw;
1303 unsigned port = sky2->port;
1304 u16 ctrl;
1305
1306 /* Never really got started! */
1307 if (!sky2->tx_le)
1308 return 0;
1309
1310 if (netif_msg_ifdown(sky2))
1311 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
1312
1313 /* Stop more packets from being queued */
1314 netif_stop_queue(dev);
1315
1316 /* Disable port IRQ */
1317 local_irq_disable();
1318 hw->intr_mask &= ~((sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
1319 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1320 local_irq_enable();
1321
1322 flush_scheduled_work();
1323
1324 sky2_phy_reset(hw, port);
1325
1326 /* Stop transmitter */
1327 sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_STOP);
1328 sky2_read32(hw, Q_ADDR(txqaddr[port], Q_CSR));
1329
1330 sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL),
1331 RB_RST_SET | RB_DIS_OP_MD);
1332
1333 ctrl = gma_read16(hw, port, GM_GP_CTRL);
1334 ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA);
1335 gma_write16(hw, port, GM_GP_CTRL, ctrl);
1336
1337 sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
1338
1339 /* Workaround shared GMAC reset */
1340 if (!(hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0
1341 && port == 0 && hw->dev[1] && netif_running(hw->dev[1])))
1342 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_RST_SET);
1343
1344 /* Disable Force Sync bit and Enable Alloc bit */
1345 sky2_write8(hw, SK_REG(port, TXA_CTRL),
1346 TXA_DIS_FSYNC | TXA_DIS_ALLOC | TXA_STOP_RC);
1347
1348 /* Stop Interval Timer and Limit Counter of Tx Arbiter */
1349 sky2_write32(hw, SK_REG(port, TXA_ITI_INI), 0L);
1350 sky2_write32(hw, SK_REG(port, TXA_LIM_INI), 0L);
1351
1352 /* Reset the PCI FIFO of the async Tx queue */
1353 sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR),
1354 BMU_RST_SET | BMU_FIFO_RST);
1355
1356 /* Reset the Tx prefetch units */
1357 sky2_write32(hw, Y2_QADDR(txqaddr[port], PREF_UNIT_CTRL),
1358 PREF_UNIT_RST_SET);
1359
1360 sky2_write32(hw, RB_ADDR(txqaddr[port], RB_CTRL), RB_RST_SET);
1361
1362 sky2_rx_stop(sky2);
1363
1364 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
1365 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_RST_SET);
1366
1367 /* turn off LED's */
1368 sky2_write16(hw, B0_Y2LED, LED_STAT_OFF);
1369
1370 synchronize_irq(hw->pdev->irq);
1371
1372 sky2_tx_clean(sky2);
1373 sky2_rx_clean(sky2);
1374
1375 pci_free_consistent(hw->pdev, RX_LE_BYTES,
1376 sky2->rx_le, sky2->rx_le_map);
1377 kfree(sky2->rx_ring);
1378
1379 pci_free_consistent(hw->pdev,
1380 TX_RING_SIZE * sizeof(struct sky2_tx_le),
1381 sky2->tx_le, sky2->tx_le_map);
1382 kfree(sky2->tx_ring);
1383
1384 sky2->tx_le = NULL;
1385 sky2->rx_le = NULL;
1386
1387 sky2->rx_ring = NULL;
1388 sky2->tx_ring = NULL;
1389
1390 return 0;
1391}
1392
1393static u16 sky2_phy_speed(const struct sky2_hw *hw, u16 aux)
1394{
1395 if (!hw->copper)
1396 return SPEED_1000;
1397
1398 if (hw->chip_id == CHIP_ID_YUKON_FE)
1399 return (aux & PHY_M_PS_SPEED_100) ? SPEED_100 : SPEED_10;
1400
1401 switch (aux & PHY_M_PS_SPEED_MSK) {
1402 case PHY_M_PS_SPEED_1000:
1403 return SPEED_1000;
1404 case PHY_M_PS_SPEED_100:
1405 return SPEED_100;
1406 default:
1407 return SPEED_10;
1408 }
1409}
1410
1411static void sky2_link_up(struct sky2_port *sky2)
1412{
1413 struct sky2_hw *hw = sky2->hw;
1414 unsigned port = sky2->port;
1415 u16 reg;
1416
1417 /* Enable Transmit FIFO Underrun */
1418 sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), GMAC_DEF_MSK);
1419
1420 reg = gma_read16(hw, port, GM_GP_CTRL);
1421 if (sky2->duplex == DUPLEX_FULL || sky2->autoneg == AUTONEG_ENABLE)
1422 reg |= GM_GPCR_DUP_FULL;
1423
1424 /* enable Rx/Tx */
1425 reg |= GM_GPCR_RX_ENA | GM_GPCR_TX_ENA;
1426 gma_write16(hw, port, GM_GP_CTRL, reg);
1427 gma_read16(hw, port, GM_GP_CTRL);
1428
1429 gm_phy_write(hw, port, PHY_MARV_INT_MASK, PHY_M_DEF_MSK);
1430
1431 netif_carrier_on(sky2->netdev);
1432 netif_wake_queue(sky2->netdev);
1433
1434 /* Turn on link LED */
1435 sky2_write8(hw, SK_REG(port, LNK_LED_REG),
1436 LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF);
1437
1438 if (hw->chip_id == CHIP_ID_YUKON_XL) {
1439 u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
1440
1441 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
1442 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, PHY_M_LEDC_LOS_CTRL(1) | /* LINK/ACT */
1443 PHY_M_LEDC_INIT_CTRL(sky2->speed ==
1444 SPEED_10 ? 7 : 0) |
1445 PHY_M_LEDC_STA1_CTRL(sky2->speed ==
1446 SPEED_100 ? 7 : 0) |
1447 PHY_M_LEDC_STA0_CTRL(sky2->speed ==
1448 SPEED_1000 ? 7 : 0));
1449 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
1450 }
1451
1452 if (netif_msg_link(sky2))
1453 printk(KERN_INFO PFX
1454 "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
1455 sky2->netdev->name, sky2->speed,
1456 sky2->duplex == DUPLEX_FULL ? "full" : "half",
1457 (sky2->tx_pause && sky2->rx_pause) ? "both" :
1458 sky2->tx_pause ? "tx" : sky2->rx_pause ? "rx" : "none");
1459}
1460
1461static void sky2_link_down(struct sky2_port *sky2)
1462{
1463 struct sky2_hw *hw = sky2->hw;
1464 unsigned port = sky2->port;
1465 u16 reg;
1466
1467 gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
1468
1469 reg = gma_read16(hw, port, GM_GP_CTRL);
1470 reg &= ~(GM_GPCR_RX_ENA | GM_GPCR_TX_ENA);
1471 gma_write16(hw, port, GM_GP_CTRL, reg);
1472 gma_read16(hw, port, GM_GP_CTRL); /* PCI post */
1473
1474 if (sky2->rx_pause && !sky2->tx_pause) {
1475 /* restore Asymmetric Pause bit */
1476 gm_phy_write(hw, port, PHY_MARV_AUNE_ADV,
1477 gm_phy_read(hw, port, PHY_MARV_AUNE_ADV)
1478 | PHY_M_AN_ASP);
1479 }
1480
1481 netif_carrier_off(sky2->netdev);
1482 netif_stop_queue(sky2->netdev);
1483
1484 /* Turn on link LED */
1485 sky2_write8(hw, SK_REG(port, LNK_LED_REG), LINKLED_OFF);
1486
1487 if (netif_msg_link(sky2))
1488 printk(KERN_INFO PFX "%s: Link is down.\n", sky2->netdev->name);
1489 sky2_phy_init(hw, port);
1490}
1491
1492static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
1493{
1494 struct sky2_hw *hw = sky2->hw;
1495 unsigned port = sky2->port;
1496 u16 lpa;
1497
1498 lpa = gm_phy_read(hw, port, PHY_MARV_AUNE_LP);
1499
1500 if (lpa & PHY_M_AN_RF) {
1501 printk(KERN_ERR PFX "%s: remote fault", sky2->netdev->name);
1502 return -1;
1503 }
1504
1505 if (hw->chip_id != CHIP_ID_YUKON_FE &&
1506 gm_phy_read(hw, port, PHY_MARV_1000T_STAT) & PHY_B_1000S_MSF) {
1507 printk(KERN_ERR PFX "%s: master/slave fault",
1508 sky2->netdev->name);
1509 return -1;
1510 }
1511
1512 if (!(aux & PHY_M_PS_SPDUP_RES)) {
1513 printk(KERN_ERR PFX "%s: speed/duplex mismatch",
1514 sky2->netdev->name);
1515 return -1;
1516 }
1517
1518 sky2->duplex = (aux & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1519
1520 sky2->speed = sky2_phy_speed(hw, aux);
1521
1522 /* Pause bits are offset (9..8) */
1523 if (hw->chip_id == CHIP_ID_YUKON_XL)
1524 aux >>= 6;
1525
1526 sky2->rx_pause = (aux & PHY_M_PS_RX_P_EN) != 0;
1527 sky2->tx_pause = (aux & PHY_M_PS_TX_P_EN) != 0;
1528
1529 if ((sky2->tx_pause || sky2->rx_pause)
1530 && !(sky2->speed < SPEED_1000 && sky2->duplex == DUPLEX_HALF))
1531 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_ON);
1532 else
1533 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
1534
1535 return 0;
1536}
1537
1538/*
1539 * Interrupt from PHY are handled outside of interrupt context
1540 * because accessing phy registers requires spin wait which might
1541 * cause excess interrupt latency.
1542 */
1543static void sky2_phy_task(void *arg)
1544{
1545 struct sky2_port *sky2 = arg;
1546 struct sky2_hw *hw = sky2->hw;
1547 u16 istatus, phystat;
1548
1549 down(&sky2->phy_sema);
1550 istatus = gm_phy_read(hw, sky2->port, PHY_MARV_INT_STAT);
1551 phystat = gm_phy_read(hw, sky2->port, PHY_MARV_PHY_STAT);
1552
1553 if (netif_msg_intr(sky2))
1554 printk(KERN_INFO PFX "%s: phy interrupt status 0x%x 0x%x\n",
1555 sky2->netdev->name, istatus, phystat);
1556
1557 if (istatus & PHY_M_IS_AN_COMPL) {
1558 if (sky2_autoneg_done(sky2, phystat) == 0)
1559 sky2_link_up(sky2);
1560 goto out;
1561 }
1562
1563 if (istatus & PHY_M_IS_LSP_CHANGE)
1564 sky2->speed = sky2_phy_speed(hw, phystat);
1565
1566 if (istatus & PHY_M_IS_DUP_CHANGE)
1567 sky2->duplex =
1568 (phystat & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1569
1570 if (istatus & PHY_M_IS_LST_CHANGE) {
1571 if (phystat & PHY_M_PS_LINK_UP)
1572 sky2_link_up(sky2);
1573 else
1574 sky2_link_down(sky2);
1575 }
1576out:
1577 up(&sky2->phy_sema);
1578
1579 local_irq_disable();
1580 hw->intr_mask |= (sky2->port == 0) ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2;
1581 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1582 local_irq_enable();
1583}
1584
1585static void sky2_tx_timeout(struct net_device *dev)
1586{
1587 struct sky2_port *sky2 = netdev_priv(dev);
1588 struct sky2_hw *hw = sky2->hw;
1589 unsigned txq = txqaddr[sky2->port];
1590
1591 if (netif_msg_timer(sky2))
1592 printk(KERN_ERR PFX "%s: tx timeout\n", dev->name);
1593
1594 netif_stop_queue(dev);
1595
1596 sky2_write32(hw, Q_ADDR(txq, Q_CSR), BMU_STOP);
1597 sky2_read32(hw, Q_ADDR(txq, Q_CSR));
1598
1599 sky2_write32(hw, Y2_QADDR(txq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
1600
1601 sky2_tx_clean(sky2);
1602
1603 sky2_qset(hw, txq);
1604 sky2_prefetch_init(hw, txq, sky2->tx_le_map, TX_RING_SIZE - 1);
1605
1606 netif_wake_queue(dev);
1607}
1608
1609
1610#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
1611/* Want receive buffer size to be multiple of 64 bits, and incl room for vlan */
1612static inline unsigned sky2_buf_size(int mtu)
1613{
1614 return roundup(mtu + ETH_HLEN + 4, 8);
1615}
1616
1617static int sky2_change_mtu(struct net_device *dev, int new_mtu)
1618{
1619 struct sky2_port *sky2 = netdev_priv(dev);
1620 struct sky2_hw *hw = sky2->hw;
1621 int err;
1622 u16 ctl, mode;
1623
1624 if (new_mtu < ETH_ZLEN || new_mtu > ETH_JUMBO_MTU)
1625 return -EINVAL;
1626
1627 if (hw->chip_id == CHIP_ID_YUKON_EC_U && new_mtu > ETH_DATA_LEN)
1628 return -EINVAL;
1629
1630 if (!netif_running(dev)) {
1631 dev->mtu = new_mtu;
1632 return 0;
1633 }
1634
1635 sky2_write32(hw, B0_IMSK, 0);
1636
1637 dev->trans_start = jiffies; /* prevent tx timeout */
1638 netif_stop_queue(dev);
1639 netif_poll_disable(hw->dev[0]);
1640
1641 ctl = gma_read16(hw, sky2->port, GM_GP_CTRL);
1642 gma_write16(hw, sky2->port, GM_GP_CTRL, ctl & ~GM_GPCR_RX_ENA);
1643 sky2_rx_stop(sky2);
1644 sky2_rx_clean(sky2);
1645
1646 dev->mtu = new_mtu;
1647 sky2->rx_bufsize = sky2_buf_size(new_mtu);
1648 mode = DATA_BLIND_VAL(DATA_BLIND_DEF) |
1649 GM_SMOD_VLAN_ENA | IPG_DATA_VAL(IPG_DATA_DEF);
1650
1651 if (dev->mtu > ETH_DATA_LEN)
1652 mode |= GM_SMOD_JUMBO_ENA;
1653
1654 gma_write16(hw, sky2->port, GM_SERIAL_MODE, mode);
1655
1656 sky2_write8(hw, RB_ADDR(rxqaddr[sky2->port], RB_CTRL), RB_ENA_OP_MD);
1657
1658 err = sky2_rx_start(sky2);
1659 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1660
1661 if (err)
1662 dev_close(dev);
1663 else {
1664 gma_write16(hw, sky2->port, GM_GP_CTRL, ctl);
1665
1666 netif_poll_enable(hw->dev[0]);
1667 netif_wake_queue(dev);
1668 }
1669
1670 return err;
1671}
1672
1673/*
1674 * Receive one packet.
1675 * For small packets or errors, just reuse existing skb.
1676 * For larger packets, get new buffer.
1677 */
1678static struct sk_buff *sky2_receive(struct sky2_port *sky2,
1679 u16 length, u32 status)
1680{
1681 struct ring_info *re = sky2->rx_ring + sky2->rx_next;
1682 struct sk_buff *skb = NULL;
1683
1684 if (unlikely(netif_msg_rx_status(sky2)))
1685 printk(KERN_DEBUG PFX "%s: rx slot %u status 0x%x len %d\n",
1686 sky2->netdev->name, sky2->rx_next, status, length);
1687
1688 sky2->rx_next = (sky2->rx_next + 1) % sky2->rx_pending;
1689 prefetch(sky2->rx_ring + sky2->rx_next);
1690
1691 if (status & GMR_FS_ANY_ERR)
1692 goto error;
1693
1694 if (!(status & GMR_FS_RX_OK))
1695 goto resubmit;
1696
1697 if ((status >> 16) != length || length > sky2->rx_bufsize)
1698 goto oversize;
1699
1700 if (length < copybreak) {
1701 skb = alloc_skb(length + 2, GFP_ATOMIC);
1702 if (!skb)
1703 goto resubmit;
1704
1705 skb_reserve(skb, 2);
1706 pci_dma_sync_single_for_cpu(sky2->hw->pdev, re->mapaddr,
1707 length, PCI_DMA_FROMDEVICE);
1708 memcpy(skb->data, re->skb->data, length);
1709 skb->ip_summed = re->skb->ip_summed;
1710 skb->csum = re->skb->csum;
1711 pci_dma_sync_single_for_device(sky2->hw->pdev, re->mapaddr,
1712 length, PCI_DMA_FROMDEVICE);
1713 } else {
1714 struct sk_buff *nskb;
1715
1716 nskb = dev_alloc_skb(sky2->rx_bufsize);
1717 if (!nskb)
1718 goto resubmit;
1719
1720 skb = re->skb;
1721 re->skb = nskb;
1722 pci_unmap_single(sky2->hw->pdev, re->mapaddr,
1723 sky2->rx_bufsize, PCI_DMA_FROMDEVICE);
1724 prefetch(skb->data);
1725
1726 re->mapaddr = pci_map_single(sky2->hw->pdev, nskb->data,
1727 sky2->rx_bufsize, PCI_DMA_FROMDEVICE);
1728 }
1729
1730 skb_put(skb, length);
1731resubmit:
1732 re->skb->ip_summed = CHECKSUM_NONE;
1733 sky2_rx_add(sky2, re->mapaddr);
1734
1735 /* Tell receiver about new buffers. */
1736 sky2_put_idx(sky2->hw, rxqaddr[sky2->port], sky2->rx_put,
1737 &sky2->rx_last_put, RX_LE_SIZE);
1738
1739 return skb;
1740
1741oversize:
1742 ++sky2->net_stats.rx_over_errors;
1743 goto resubmit;
1744
1745error:
1746 ++sky2->net_stats.rx_errors;
1747
1748 if (netif_msg_rx_err(sky2))
1749 printk(KERN_INFO PFX "%s: rx error, status 0x%x length %d\n",
1750 sky2->netdev->name, status, length);
1751
1752 if (status & (GMR_FS_LONG_ERR | GMR_FS_UN_SIZE))
1753 sky2->net_stats.rx_length_errors++;
1754 if (status & GMR_FS_FRAGMENT)
1755 sky2->net_stats.rx_frame_errors++;
1756 if (status & GMR_FS_CRC_ERR)
1757 sky2->net_stats.rx_crc_errors++;
1758 if (status & GMR_FS_RX_FF_OV)
1759 sky2->net_stats.rx_fifo_errors++;
1760
1761 goto resubmit;
1762}
1763
1764/*
1765 * Check for transmit complete
1766 */
1767#define TX_NO_STATUS 0xffff
1768
1769static inline void sky2_tx_check(struct sky2_hw *hw, int port, u16 last)
1770{
1771 if (last != TX_NO_STATUS) {
1772 struct net_device *dev = hw->dev[port];
1773 if (dev && netif_running(dev)) {
1774 struct sky2_port *sky2 = netdev_priv(dev);
1775 sky2_tx_complete(sky2, last);
1776 }
1777 }
1778}
1779
1780/*
1781 * Both ports share the same status interrupt, therefore there is only
1782 * one poll routine.
1783 */
1784static int sky2_poll(struct net_device *dev0, int *budget)
1785{
1786 struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
1787 unsigned int to_do = min(dev0->quota, *budget);
1788 unsigned int work_done = 0;
1789 u16 hwidx;
1790 u16 tx_done[2] = { TX_NO_STATUS, TX_NO_STATUS };
1791
1792 hwidx = sky2_read16(hw, STAT_PUT_IDX);
1793 BUG_ON(hwidx >= STATUS_RING_SIZE);
1794 rmb();
1795
1796 while (hwidx != hw->st_idx) {
1797 struct sky2_status_le *le = hw->st_le + hw->st_idx;
1798 struct net_device *dev;
1799 struct sky2_port *sky2;
1800 struct sk_buff *skb;
1801 u32 status;
1802 u16 length;
1803 u8 op;
1804
1805 le = hw->st_le + hw->st_idx;
1806 hw->st_idx = (hw->st_idx + 1) % STATUS_RING_SIZE;
1807 prefetch(hw->st_le + hw->st_idx);
1808
1809 BUG_ON(le->link >= 2);
1810 dev = hw->dev[le->link];
1811 if (dev == NULL || !netif_running(dev))
1812 continue;
1813
1814 sky2 = netdev_priv(dev);
1815 status = le32_to_cpu(le->status);
1816 length = le16_to_cpu(le->length);
1817 op = le->opcode & ~HW_OWNER;
1818 le->opcode = 0;
1819
1820 switch (op) {
1821 case OP_RXSTAT:
1822 skb = sky2_receive(sky2, length, status);
1823 if (!skb)
1824 break;
1825
1826 skb->dev = dev;
1827 skb->protocol = eth_type_trans(skb, dev);
1828 dev->last_rx = jiffies;
1829
1830#ifdef SKY2_VLAN_TAG_USED
1831 if (sky2->vlgrp && (status & GMR_FS_VLAN)) {
1832 vlan_hwaccel_receive_skb(skb,
1833 sky2->vlgrp,
1834 be16_to_cpu(sky2->rx_tag));
1835 } else
1836#endif
1837 netif_receive_skb(skb);
1838
1839 if (++work_done >= to_do)
1840 goto exit_loop;
1841 break;
1842
1843#ifdef SKY2_VLAN_TAG_USED
1844 case OP_RXVLAN:
1845 sky2->rx_tag = length;
1846 break;
1847
1848 case OP_RXCHKSVLAN:
1849 sky2->rx_tag = length;
1850 /* fall through */
1851#endif
1852 case OP_RXCHKS:
1853 skb = sky2->rx_ring[sky2->rx_next].skb;
1854 skb->ip_summed = CHECKSUM_HW;
1855 skb->csum = le16_to_cpu(status);
1856 break;
1857
1858 case OP_TXINDEXLE:
1859 /* TX index reports status for both ports */
1860 tx_done[0] = status & 0xffff;
1861 tx_done[1] = ((status >> 24) & 0xff)
1862 | (u16)(length & 0xf) << 8;
1863 break;
1864
1865 default:
1866 if (net_ratelimit())
1867 printk(KERN_WARNING PFX
1868 "unknown status opcode 0x%x\n", op);
1869 break;
1870 }
1871 }
1872
1873exit_loop:
1874 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
1875 mmiowb();
1876
1877 sky2_tx_check(hw, 0, tx_done[0]);
1878 sky2_tx_check(hw, 1, tx_done[1]);
1879
1880 if (sky2_read16(hw, STAT_PUT_IDX) == hw->st_idx) {
1881 /* need to restart TX timer */
1882 if (is_ec_a1(hw)) {
1883 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
1884 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
1885 }
1886
1887 netif_rx_complete(dev0);
1888 hw->intr_mask |= Y2_IS_STAT_BMU;
1889 sky2_write32(hw, B0_IMSK, hw->intr_mask);
1890 mmiowb();
1891 return 0;
1892 } else {
1893 *budget -= work_done;
1894 dev0->quota -= work_done;
1895 return 1;
1896 }
1897}
1898
1899static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
1900{
1901 struct net_device *dev = hw->dev[port];
1902
1903 printk(KERN_INFO PFX "%s: hw error interrupt status 0x%x\n",
1904 dev->name, status);
1905
1906 if (status & Y2_IS_PAR_RD1) {
1907 printk(KERN_ERR PFX "%s: ram data read parity error\n",
1908 dev->name);
1909 /* Clear IRQ */
1910 sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_RD_PERR);
1911 }
1912
1913 if (status & Y2_IS_PAR_WR1) {
1914 printk(KERN_ERR PFX "%s: ram data write parity error\n",
1915 dev->name);
1916
1917 sky2_write16(hw, RAM_BUFFER(port, B3_RI_CTRL), RI_CLR_WR_PERR);
1918 }
1919
1920 if (status & Y2_IS_PAR_MAC1) {
1921 printk(KERN_ERR PFX "%s: MAC parity error\n", dev->name);
1922 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_PE);
1923 }
1924
1925 if (status & Y2_IS_PAR_RX1) {
1926 printk(KERN_ERR PFX "%s: RX parity error\n", dev->name);
1927 sky2_write32(hw, Q_ADDR(rxqaddr[port], Q_CSR), BMU_CLR_IRQ_PAR);
1928 }
1929
1930 if (status & Y2_IS_TCP_TXA1) {
1931 printk(KERN_ERR PFX "%s: TCP segmentation error\n", dev->name);
1932 sky2_write32(hw, Q_ADDR(txqaddr[port], Q_CSR), BMU_CLR_IRQ_TCP);
1933 }
1934}
1935
1936static void sky2_hw_intr(struct sky2_hw *hw)
1937{
1938 u32 status = sky2_read32(hw, B0_HWE_ISRC);
1939
1940 if (status & Y2_IS_TIST_OV)
1941 sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ);
1942
1943 if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
1944 u16 pci_err;
1945
1946 pci_read_config_word(hw->pdev, PCI_STATUS, &pci_err);
1947 printk(KERN_ERR PFX "%s: pci hw error (0x%x)\n",
1948 pci_name(hw->pdev), pci_err);
1949
1950 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
1951 pci_write_config_word(hw->pdev, PCI_STATUS,
1952 pci_err | PCI_STATUS_ERROR_BITS);
1953 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
1954 }
1955
1956 if (status & Y2_IS_PCI_EXP) {
1957 /* PCI-Express uncorrectable Error occurred */
1958 u32 pex_err;
1959
1960 pci_read_config_dword(hw->pdev, PEX_UNC_ERR_STAT, &pex_err);
1961
1962 printk(KERN_ERR PFX "%s: pci express error (0x%x)\n",
1963 pci_name(hw->pdev), pex_err);
1964
1965 /* clear the interrupt */
1966 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
1967 pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT,
1968 0xffffffffUL);
1969 sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
1970
1971 if (pex_err & PEX_FATAL_ERRORS) {
1972 u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
1973 hwmsk &= ~Y2_IS_PCI_EXP;
1974 sky2_write32(hw, B0_HWE_IMSK, hwmsk);
1975 }
1976 }
1977
1978 if (status & Y2_HWE_L1_MASK)
1979 sky2_hw_error(hw, 0, status);
1980 status >>= 8;
1981 if (status & Y2_HWE_L1_MASK)
1982 sky2_hw_error(hw, 1, status);
1983}
1984
1985static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
1986{
1987 struct net_device *dev = hw->dev[port];
1988 struct sky2_port *sky2 = netdev_priv(dev);
1989 u8 status = sky2_read8(hw, SK_REG(port, GMAC_IRQ_SRC));
1990
1991 if (netif_msg_intr(sky2))
1992 printk(KERN_INFO PFX "%s: mac interrupt status 0x%x\n",
1993 dev->name, status);
1994
1995 if (status & GM_IS_RX_FF_OR) {
1996 ++sky2->net_stats.rx_fifo_errors;
1997 sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO);
1998 }
1999
2000 if (status & GM_IS_TX_FF_UR) {
2001 ++sky2->net_stats.tx_fifo_errors;
2002 sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU);
2003 }
2004}
2005
2006static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
2007{
2008 struct net_device *dev = hw->dev[port];
2009 struct sky2_port *sky2 = netdev_priv(dev);
2010
2011 hw->intr_mask &= ~(port == 0 ? Y2_IS_IRQ_PHY1 : Y2_IS_IRQ_PHY2);
2012 sky2_write32(hw, B0_IMSK, hw->intr_mask);
2013 schedule_work(&sky2->phy_task);
2014}
2015
2016static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs)
2017{
2018 struct sky2_hw *hw = dev_id;
2019 struct net_device *dev0 = hw->dev[0];
2020 u32 status;
2021
2022 status = sky2_read32(hw, B0_Y2_SP_ISRC2);
2023 if (status == 0 || status == ~0)
2024 return IRQ_NONE;
2025
2026 if (status & Y2_IS_HW_ERR)
2027 sky2_hw_intr(hw);
2028
2029 /* Do NAPI for Rx and Tx status */
2030 if (status & Y2_IS_STAT_BMU) {
2031 hw->intr_mask &= ~Y2_IS_STAT_BMU;
2032 sky2_write32(hw, B0_IMSK, hw->intr_mask);
2033
2034 if (likely(__netif_rx_schedule_prep(dev0))) {
2035 prefetch(&hw->st_le[hw->st_idx]);
2036 __netif_rx_schedule(dev0);
2037 }
2038 }
2039
2040 if (status & Y2_IS_IRQ_PHY1)
2041 sky2_phy_intr(hw, 0);
2042
2043 if (status & Y2_IS_IRQ_PHY2)
2044 sky2_phy_intr(hw, 1);
2045
2046 if (status & Y2_IS_IRQ_MAC1)
2047 sky2_mac_intr(hw, 0);
2048
2049 if (status & Y2_IS_IRQ_MAC2)
2050 sky2_mac_intr(hw, 1);
2051
2052 sky2_write32(hw, B0_Y2_SP_ICR, 2);
2053
2054 sky2_read32(hw, B0_IMSK);
2055
2056 return IRQ_HANDLED;
2057}
2058
2059#ifdef CONFIG_NET_POLL_CONTROLLER
2060static void sky2_netpoll(struct net_device *dev)
2061{
2062 struct sky2_port *sky2 = netdev_priv(dev);
2063
2064 sky2_intr(sky2->hw->pdev->irq, sky2->hw, NULL);
2065}
2066#endif
2067
2068/* Chip internal frequency for clock calculations */
2069static inline u32 sky2_mhz(const struct sky2_hw *hw)
2070{
2071 switch (hw->chip_id) {
2072 case CHIP_ID_YUKON_EC:
2073 case CHIP_ID_YUKON_EC_U:
2074 return 125; /* 125 Mhz */
2075 case CHIP_ID_YUKON_FE:
2076 return 100; /* 100 Mhz */
2077 default: /* YUKON_XL */
2078 return 156; /* 156 Mhz */
2079 }
2080}
2081
2082static inline u32 sky2_us2clk(const struct sky2_hw *hw, u32 us)
2083{
2084 return sky2_mhz(hw) * us;
2085}
2086
2087static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
2088{
2089 return clk / sky2_mhz(hw);
2090}
2091
2092
2093static int sky2_reset(struct sky2_hw *hw)
2094{
2095 u32 ctst;
2096 u16 status;
2097 u8 t8, pmd_type;
2098 int i;
2099
2100 ctst = sky2_read32(hw, B0_CTST);
2101
2102 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2103 hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
2104 if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) {
2105 printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n",
2106 pci_name(hw->pdev), hw->chip_id);
2107 return -EOPNOTSUPP;
2108 }
2109
2110 /* ring for status responses */
2111 hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
2112 &hw->st_dma);
2113 if (!hw->st_le)
2114 return -ENOMEM;
2115
2116 /* disable ASF */
2117 if (hw->chip_id <= CHIP_ID_YUKON_EC) {
2118 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
2119 sky2_write16(hw, B0_CTST, Y2_ASF_DISABLE);
2120 }
2121
2122 /* do a SW reset */
2123 sky2_write8(hw, B0_CTST, CS_RST_SET);
2124 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2125
2126 /* clear PCI errors, if any */
2127 pci_read_config_word(hw->pdev, PCI_STATUS, &status);
2128 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2129 pci_write_config_word(hw->pdev, PCI_STATUS,
2130 status | PCI_STATUS_ERROR_BITS);
2131
2132 sky2_write8(hw, B0_CTST, CS_MRST_CLR);
2133
2134 /* clear any PEX errors */
2135 if (is_pciex(hw)) {
2136 u16 lstat;
2137 pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT,
2138 0xffffffffUL);
2139 pci_read_config_word(hw->pdev, PEX_LNK_STAT, &lstat);
2140 }
2141
2142 pmd_type = sky2_read8(hw, B2_PMD_TYP);
2143 hw->copper = !(pmd_type == 'L' || pmd_type == 'S');
2144
2145 hw->ports = 1;
2146 t8 = sky2_read8(hw, B2_Y2_HW_RES);
2147 if ((t8 & CFG_DUAL_MAC_MSK) == CFG_DUAL_MAC_MSK) {
2148 if (!(sky2_read8(hw, B2_Y2_CLK_GATE) & Y2_STATUS_LNK2_INAC))
2149 ++hw->ports;
2150 }
2151 hw->chip_rev = (sky2_read8(hw, B2_MAC_CFG) & CFG_CHIP_R_MSK) >> 4;
2152
2153 sky2_set_power_state(hw, PCI_D0);
2154
2155 for (i = 0; i < hw->ports; i++) {
2156 sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_SET);
2157 sky2_write8(hw, SK_REG(i, GMAC_LINK_CTRL), GMLC_RST_CLR);
2158 }
2159
2160 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
2161
2162 /* Clear I2C IRQ noise */
2163 sky2_write32(hw, B2_I2C_IRQ, 1);
2164
2165 /* turn off hardware timer (unused) */
2166 sky2_write8(hw, B2_TI_CTRL, TIM_STOP);
2167 sky2_write8(hw, B2_TI_CTRL, TIM_CLR_IRQ);
2168
2169 sky2_write8(hw, B0_Y2LED, LED_STAT_ON);
2170
2171 /* Turn off descriptor polling */
2172 sky2_write32(hw, B28_DPT_CTRL, DPT_STOP);
2173
2174 /* Turn off receive timestamp */
2175 sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_STOP);
2176 sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ);
2177
2178 /* enable the Tx Arbiters */
2179 for (i = 0; i < hw->ports; i++)
2180 sky2_write8(hw, SK_REG(i, TXA_CTRL), TXA_ENA_ARB);
2181
2182 /* Initialize ram interface */
2183 for (i = 0; i < hw->ports; i++) {
2184 sky2_write8(hw, RAM_BUFFER(i, B3_RI_CTRL), RI_RST_CLR);
2185
2186 sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_R1), SK_RI_TO_53);
2187 sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XA1), SK_RI_TO_53);
2188 sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XS1), SK_RI_TO_53);
2189 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_R1), SK_RI_TO_53);
2190 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XA1), SK_RI_TO_53);
2191 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS1), SK_RI_TO_53);
2192 sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_R2), SK_RI_TO_53);
2193 sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XA2), SK_RI_TO_53);
2194 sky2_write8(hw, RAM_BUFFER(i, B3_RI_WTO_XS2), SK_RI_TO_53);
2195 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_R2), SK_RI_TO_53);
2196 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XA2), SK_RI_TO_53);
2197 sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53);
2198 }
2199
2200 sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK);
2201
2202 for (i = 0; i < hw->ports; i++)
2203 sky2_phy_reset(hw, i);
2204
2205 memset(hw->st_le, 0, STATUS_LE_BYTES);
2206 hw->st_idx = 0;
2207
2208 sky2_write32(hw, STAT_CTRL, SC_STAT_RST_SET);
2209 sky2_write32(hw, STAT_CTRL, SC_STAT_RST_CLR);
2210
2211 sky2_write32(hw, STAT_LIST_ADDR_LO, hw->st_dma);
2212 sky2_write32(hw, STAT_LIST_ADDR_HI, (u64) hw->st_dma >> 32);
2213
2214 /* Set the list last index */
2215 sky2_write16(hw, STAT_LAST_IDX, STATUS_RING_SIZE - 1);
2216
2217 /* These status setup values are copied from SysKonnect's driver */
2218 if (is_ec_a1(hw)) {
2219 /* WA for dev. #4.3 */
2220 sky2_write16(hw, STAT_TX_IDX_TH, 0xfff); /* Tx Threshold */
2221
2222 /* set Status-FIFO watermark */
2223 sky2_write8(hw, STAT_FIFO_WM, 0x21); /* WA for dev. #4.18 */
2224
2225 /* set Status-FIFO ISR watermark */
2226 sky2_write8(hw, STAT_FIFO_ISR_WM, 0x07); /* WA for dev. #4.18 */
2227 sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 10000));
2228 } else {
2229 sky2_write16(hw, STAT_TX_IDX_TH, 10);
2230 sky2_write8(hw, STAT_FIFO_WM, 16);
2231
2232 /* set Status-FIFO ISR watermark */
2233 if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev == 0)
2234 sky2_write8(hw, STAT_FIFO_ISR_WM, 4);
2235 else
2236 sky2_write8(hw, STAT_FIFO_ISR_WM, 16);
2237
2238 sky2_write32(hw, STAT_TX_TIMER_INI, sky2_us2clk(hw, 1000));
2239 sky2_write32(hw, STAT_LEV_TIMER_INI, sky2_us2clk(hw, 100));
2240 sky2_write32(hw, STAT_ISR_TIMER_INI, sky2_us2clk(hw, 20));
2241 }
2242
2243 /* enable status unit */
2244 sky2_write32(hw, STAT_CTRL, SC_STAT_OP_ON);
2245
2246 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
2247 sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_START);
2248 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
2249
2250 return 0;
2251}
2252
2253static inline u32 sky2_supported_modes(const struct sky2_hw *hw)
2254{
2255 u32 modes;
2256 if (hw->copper) {
2257 modes = SUPPORTED_10baseT_Half
2258 | SUPPORTED_10baseT_Full
2259 | SUPPORTED_100baseT_Half
2260 | SUPPORTED_100baseT_Full
2261 | SUPPORTED_Autoneg | SUPPORTED_TP;
2262
2263 if (hw->chip_id != CHIP_ID_YUKON_FE)
2264 modes |= SUPPORTED_1000baseT_Half
2265 | SUPPORTED_1000baseT_Full;
2266 } else
2267 modes = SUPPORTED_1000baseT_Full | SUPPORTED_FIBRE
2268 | SUPPORTED_Autoneg;
2269 return modes;
2270}
2271
2272static int sky2_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2273{
2274 struct sky2_port *sky2 = netdev_priv(dev);
2275 struct sky2_hw *hw = sky2->hw;
2276
2277 ecmd->transceiver = XCVR_INTERNAL;
2278 ecmd->supported = sky2_supported_modes(hw);
2279 ecmd->phy_address = PHY_ADDR_MARV;
2280 if (hw->copper) {
2281 ecmd->supported = SUPPORTED_10baseT_Half
2282 | SUPPORTED_10baseT_Full
2283 | SUPPORTED_100baseT_Half
2284 | SUPPORTED_100baseT_Full
2285 | SUPPORTED_1000baseT_Half
2286 | SUPPORTED_1000baseT_Full
2287 | SUPPORTED_Autoneg | SUPPORTED_TP;
2288 ecmd->port = PORT_TP;
2289 } else
2290 ecmd->port = PORT_FIBRE;
2291
2292 ecmd->advertising = sky2->advertising;
2293 ecmd->autoneg = sky2->autoneg;
2294 ecmd->speed = sky2->speed;
2295 ecmd->duplex = sky2->duplex;
2296 return 0;
2297}
2298
2299static int sky2_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
2300{
2301 struct sky2_port *sky2 = netdev_priv(dev);
2302 const struct sky2_hw *hw = sky2->hw;
2303 u32 supported = sky2_supported_modes(hw);
2304
2305 if (ecmd->autoneg == AUTONEG_ENABLE) {
2306 ecmd->advertising = supported;
2307 sky2->duplex = -1;
2308 sky2->speed = -1;
2309 } else {
2310 u32 setting;
2311
2312 switch (ecmd->speed) {
2313 case SPEED_1000:
2314 if (ecmd->duplex == DUPLEX_FULL)
2315 setting = SUPPORTED_1000baseT_Full;
2316 else if (ecmd->duplex == DUPLEX_HALF)
2317 setting = SUPPORTED_1000baseT_Half;
2318 else
2319 return -EINVAL;
2320 break;
2321 case SPEED_100:
2322 if (ecmd->duplex == DUPLEX_FULL)
2323 setting = SUPPORTED_100baseT_Full;
2324 else if (ecmd->duplex == DUPLEX_HALF)
2325 setting = SUPPORTED_100baseT_Half;
2326 else
2327 return -EINVAL;
2328 break;
2329
2330 case SPEED_10:
2331 if (ecmd->duplex == DUPLEX_FULL)
2332 setting = SUPPORTED_10baseT_Full;
2333 else if (ecmd->duplex == DUPLEX_HALF)
2334 setting = SUPPORTED_10baseT_Half;
2335 else
2336 return -EINVAL;
2337 break;
2338 default:
2339 return -EINVAL;
2340 }
2341
2342 if ((setting & supported) == 0)
2343 return -EINVAL;
2344
2345 sky2->speed = ecmd->speed;
2346 sky2->duplex = ecmd->duplex;
2347 }
2348
2349 sky2->autoneg = ecmd->autoneg;
2350 sky2->advertising = ecmd->advertising;
2351
2352 if (netif_running(dev))
2353 sky2_phy_reinit(sky2);
2354
2355 return 0;
2356}
2357
2358static void sky2_get_drvinfo(struct net_device *dev,
2359 struct ethtool_drvinfo *info)
2360{
2361 struct sky2_port *sky2 = netdev_priv(dev);
2362
2363 strcpy(info->driver, DRV_NAME);
2364 strcpy(info->version, DRV_VERSION);
2365 strcpy(info->fw_version, "N/A");
2366 strcpy(info->bus_info, pci_name(sky2->hw->pdev));
2367}
2368
2369static const struct sky2_stat {
2370 char name[ETH_GSTRING_LEN];
2371 u16 offset;
2372} sky2_stats[] = {
2373 { "tx_bytes", GM_TXO_OK_HI },
2374 { "rx_bytes", GM_RXO_OK_HI },
2375 { "tx_broadcast", GM_TXF_BC_OK },
2376 { "rx_broadcast", GM_RXF_BC_OK },
2377 { "tx_multicast", GM_TXF_MC_OK },
2378 { "rx_multicast", GM_RXF_MC_OK },
2379 { "tx_unicast", GM_TXF_UC_OK },
2380 { "rx_unicast", GM_RXF_UC_OK },
2381 { "tx_mac_pause", GM_TXF_MPAUSE },
2382 { "rx_mac_pause", GM_RXF_MPAUSE },
2383 { "collisions", GM_TXF_SNG_COL },
2384 { "late_collision",GM_TXF_LAT_COL },
2385 { "aborted", GM_TXF_ABO_COL },
2386 { "multi_collisions", GM_TXF_MUL_COL },
2387 { "fifo_underrun", GM_TXE_FIFO_UR },
2388 { "fifo_overflow", GM_RXE_FIFO_OV },
2389 { "rx_toolong", GM_RXF_LNG_ERR },
2390 { "rx_jabber", GM_RXF_JAB_PKT },
2391 { "rx_runt", GM_RXE_FRAG },
2392 { "rx_too_long", GM_RXF_LNG_ERR },
2393 { "rx_fcs_error", GM_RXF_FCS_ERR },
2394};
2395
2396static u32 sky2_get_rx_csum(struct net_device *dev)
2397{
2398 struct sky2_port *sky2 = netdev_priv(dev);
2399
2400 return sky2->rx_csum;
2401}
2402
2403static int sky2_set_rx_csum(struct net_device *dev, u32 data)
2404{
2405 struct sky2_port *sky2 = netdev_priv(dev);
2406
2407 sky2->rx_csum = data;
2408
2409 sky2_write32(sky2->hw, Q_ADDR(rxqaddr[sky2->port], Q_CSR),
2410 data ? BMU_ENA_RX_CHKSUM : BMU_DIS_RX_CHKSUM);
2411
2412 return 0;
2413}
2414
2415static u32 sky2_get_msglevel(struct net_device *netdev)
2416{
2417 struct sky2_port *sky2 = netdev_priv(netdev);
2418 return sky2->msg_enable;
2419}
2420
2421static int sky2_nway_reset(struct net_device *dev)
2422{
2423 struct sky2_port *sky2 = netdev_priv(dev);
2424
2425 if (sky2->autoneg != AUTONEG_ENABLE)
2426 return -EINVAL;
2427
2428 sky2_phy_reinit(sky2);
2429
2430 return 0;
2431}
2432
2433static void sky2_phy_stats(struct sky2_port *sky2, u64 * data, unsigned count)
2434{
2435 struct sky2_hw *hw = sky2->hw;
2436 unsigned port = sky2->port;
2437 int i;
2438
2439 data[0] = (u64) gma_read32(hw, port, GM_TXO_OK_HI) << 32
2440 | (u64) gma_read32(hw, port, GM_TXO_OK_LO);
2441 data[1] = (u64) gma_read32(hw, port, GM_RXO_OK_HI) << 32
2442 | (u64) gma_read32(hw, port, GM_RXO_OK_LO);
2443
2444 for (i = 2; i < count; i++)
2445 data[i] = (u64) gma_read32(hw, port, sky2_stats[i].offset);
2446}
2447
2448static void sky2_set_msglevel(struct net_device *netdev, u32 value)
2449{
2450 struct sky2_port *sky2 = netdev_priv(netdev);
2451 sky2->msg_enable = value;
2452}
2453
2454static int sky2_get_stats_count(struct net_device *dev)
2455{
2456 return ARRAY_SIZE(sky2_stats);
2457}
2458
2459static void sky2_get_ethtool_stats(struct net_device *dev,
2460 struct ethtool_stats *stats, u64 * data)
2461{
2462 struct sky2_port *sky2 = netdev_priv(dev);
2463
2464 sky2_phy_stats(sky2, data, ARRAY_SIZE(sky2_stats));
2465}
2466
2467static void sky2_get_strings(struct net_device *dev, u32 stringset, u8 * data)
2468{
2469 int i;
2470
2471 switch (stringset) {
2472 case ETH_SS_STATS:
2473 for (i = 0; i < ARRAY_SIZE(sky2_stats); i++)
2474 memcpy(data + i * ETH_GSTRING_LEN,
2475 sky2_stats[i].name, ETH_GSTRING_LEN);
2476 break;
2477 }
2478}
2479
2480/* Use hardware MIB variables for critical path statistics and
2481 * transmit feedback not reported at interrupt.
2482 * Other errors are accounted for in interrupt handler.
2483 */
2484static struct net_device_stats *sky2_get_stats(struct net_device *dev)
2485{
2486 struct sky2_port *sky2 = netdev_priv(dev);
2487 u64 data[13];
2488
2489 sky2_phy_stats(sky2, data, ARRAY_SIZE(data));
2490
2491 sky2->net_stats.tx_bytes = data[0];
2492 sky2->net_stats.rx_bytes = data[1];
2493 sky2->net_stats.tx_packets = data[2] + data[4] + data[6];
2494 sky2->net_stats.rx_packets = data[3] + data[5] + data[7];
2495 sky2->net_stats.multicast = data[5] + data[7];
2496 sky2->net_stats.collisions = data[10];
2497 sky2->net_stats.tx_aborted_errors = data[12];
2498
2499 return &sky2->net_stats;
2500}
2501
2502static int sky2_set_mac_address(struct net_device *dev, void *p)
2503{
2504 struct sky2_port *sky2 = netdev_priv(dev);
2505 struct sockaddr *addr = p;
2506
2507 if (!is_valid_ether_addr(addr->sa_data))
2508 return -EADDRNOTAVAIL;
2509
2510 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
2511 memcpy_toio(sky2->hw->regs + B2_MAC_1 + sky2->port * 8,
2512 dev->dev_addr, ETH_ALEN);
2513 memcpy_toio(sky2->hw->regs + B2_MAC_2 + sky2->port * 8,
2514 dev->dev_addr, ETH_ALEN);
2515
2516 if (netif_running(dev))
2517 sky2_phy_reinit(sky2);
2518
2519 return 0;
2520}
2521
2522static void sky2_set_multicast(struct net_device *dev)
2523{
2524 struct sky2_port *sky2 = netdev_priv(dev);
2525 struct sky2_hw *hw = sky2->hw;
2526 unsigned port = sky2->port;
2527 struct dev_mc_list *list = dev->mc_list;
2528 u16 reg;
2529 u8 filter[8];
2530
2531 memset(filter, 0, sizeof(filter));
2532
2533 reg = gma_read16(hw, port, GM_RX_CTRL);
2534 reg |= GM_RXCR_UCF_ENA;
2535
2536 if (dev->flags & IFF_PROMISC) /* promiscuous */
2537 reg &= ~(GM_RXCR_UCF_ENA | GM_RXCR_MCF_ENA);
2538 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > 16) /* all multicast */
2539 memset(filter, 0xff, sizeof(filter));
2540 else if (dev->mc_count == 0) /* no multicast */
2541 reg &= ~GM_RXCR_MCF_ENA;
2542 else {
2543 int i;
2544 reg |= GM_RXCR_MCF_ENA;
2545
2546 for (i = 0; list && i < dev->mc_count; i++, list = list->next) {
2547 u32 bit = ether_crc(ETH_ALEN, list->dmi_addr) & 0x3f;
2548 filter[bit / 8] |= 1 << (bit % 8);
2549 }
2550 }
2551
2552 gma_write16(hw, port, GM_MC_ADDR_H1,
2553 (u16) filter[0] | ((u16) filter[1] << 8));
2554 gma_write16(hw, port, GM_MC_ADDR_H2,
2555 (u16) filter[2] | ((u16) filter[3] << 8));
2556 gma_write16(hw, port, GM_MC_ADDR_H3,
2557 (u16) filter[4] | ((u16) filter[5] << 8));
2558 gma_write16(hw, port, GM_MC_ADDR_H4,
2559 (u16) filter[6] | ((u16) filter[7] << 8));
2560
2561 gma_write16(hw, port, GM_RX_CTRL, reg);
2562}
2563
2564/* Can have one global because blinking is controlled by
2565 * ethtool and that is always under RTNL mutex
2566 */
2567static void sky2_led(struct sky2_hw *hw, unsigned port, int on)
2568{
2569 u16 pg;
2570
2571 switch (hw->chip_id) {
2572 case CHIP_ID_YUKON_XL:
2573 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
2574 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
2575 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL,
2576 on ? (PHY_M_LEDC_LOS_CTRL(1) |
2577 PHY_M_LEDC_INIT_CTRL(7) |
2578 PHY_M_LEDC_STA1_CTRL(7) |
2579 PHY_M_LEDC_STA0_CTRL(7))
2580 : 0);
2581
2582 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
2583 break;
2584
2585 default:
2586 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0);
2587 gm_phy_write(hw, port, PHY_MARV_LED_OVER,
2588 on ? PHY_M_LED_MO_DUP(MO_LED_ON) |
2589 PHY_M_LED_MO_10(MO_LED_ON) |
2590 PHY_M_LED_MO_100(MO_LED_ON) |
2591 PHY_M_LED_MO_1000(MO_LED_ON) |
2592 PHY_M_LED_MO_RX(MO_LED_ON)
2593 : PHY_M_LED_MO_DUP(MO_LED_OFF) |
2594 PHY_M_LED_MO_10(MO_LED_OFF) |
2595 PHY_M_LED_MO_100(MO_LED_OFF) |
2596 PHY_M_LED_MO_1000(MO_LED_OFF) |
2597 PHY_M_LED_MO_RX(MO_LED_OFF));
2598
2599 }
2600}
2601
2602/* blink LED's for finding board */
2603static int sky2_phys_id(struct net_device *dev, u32 data)
2604{
2605 struct sky2_port *sky2 = netdev_priv(dev);
2606 struct sky2_hw *hw = sky2->hw;
2607 unsigned port = sky2->port;
2608 u16 ledctrl, ledover = 0;
2609 long ms;
2610 int interrupted;
2611 int onoff = 1;
2612
2613 if (!data || data > (u32) (MAX_SCHEDULE_TIMEOUT / HZ))
2614 ms = jiffies_to_msecs(MAX_SCHEDULE_TIMEOUT);
2615 else
2616 ms = data * 1000;
2617
2618 /* save initial values */
2619 down(&sky2->phy_sema);
2620 if (hw->chip_id == CHIP_ID_YUKON_XL) {
2621 u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
2622 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
2623 ledctrl = gm_phy_read(hw, port, PHY_MARV_PHY_CTRL);
2624 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
2625 } else {
2626 ledctrl = gm_phy_read(hw, port, PHY_MARV_LED_CTRL);
2627 ledover = gm_phy_read(hw, port, PHY_MARV_LED_OVER);
2628 }
2629
2630 interrupted = 0;
2631 while (!interrupted && ms > 0) {
2632 sky2_led(hw, port, onoff);
2633 onoff = !onoff;
2634
2635 up(&sky2->phy_sema);
2636 interrupted = msleep_interruptible(250);
2637 down(&sky2->phy_sema);
2638
2639 ms -= 250;
2640 }
2641
2642 /* resume regularly scheduled programming */
2643 if (hw->chip_id == CHIP_ID_YUKON_XL) {
2644 u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
2645 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
2646 gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, ledctrl);
2647 gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
2648 } else {
2649 gm_phy_write(hw, port, PHY_MARV_LED_CTRL, ledctrl);
2650 gm_phy_write(hw, port, PHY_MARV_LED_OVER, ledover);
2651 }
2652 up(&sky2->phy_sema);
2653
2654 return 0;
2655}
2656
2657static void sky2_get_pauseparam(struct net_device *dev,
2658 struct ethtool_pauseparam *ecmd)
2659{
2660 struct sky2_port *sky2 = netdev_priv(dev);
2661
2662 ecmd->tx_pause = sky2->tx_pause;
2663 ecmd->rx_pause = sky2->rx_pause;
2664 ecmd->autoneg = sky2->autoneg;
2665}
2666
2667static int sky2_set_pauseparam(struct net_device *dev,
2668 struct ethtool_pauseparam *ecmd)
2669{
2670 struct sky2_port *sky2 = netdev_priv(dev);
2671 int err = 0;
2672
2673 sky2->autoneg = ecmd->autoneg;
2674 sky2->tx_pause = ecmd->tx_pause != 0;
2675 sky2->rx_pause = ecmd->rx_pause != 0;
2676
2677 sky2_phy_reinit(sky2);
2678
2679 return err;
2680}
2681
2682#ifdef CONFIG_PM
2683static void sky2_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2684{
2685 struct sky2_port *sky2 = netdev_priv(dev);
2686
2687 wol->supported = WAKE_MAGIC;
2688 wol->wolopts = sky2->wol ? WAKE_MAGIC : 0;
2689}
2690
2691static int sky2_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
2692{
2693 struct sky2_port *sky2 = netdev_priv(dev);
2694 struct sky2_hw *hw = sky2->hw;
2695
2696 if (wol->wolopts != WAKE_MAGIC && wol->wolopts != 0)
2697 return -EOPNOTSUPP;
2698
2699 sky2->wol = wol->wolopts == WAKE_MAGIC;
2700
2701 if (sky2->wol) {
2702 memcpy_toio(hw->regs + WOL_MAC_ADDR, dev->dev_addr, ETH_ALEN);
2703
2704 sky2_write16(hw, WOL_CTRL_STAT,
2705 WOL_CTL_ENA_PME_ON_MAGIC_PKT |
2706 WOL_CTL_ENA_MAGIC_PKT_UNIT);
2707 } else
2708 sky2_write16(hw, WOL_CTRL_STAT, WOL_CTL_DEFAULT);
2709
2710 return 0;
2711}
2712#endif
2713
2714static int sky2_get_coalesce(struct net_device *dev,
2715 struct ethtool_coalesce *ecmd)
2716{
2717 struct sky2_port *sky2 = netdev_priv(dev);
2718 struct sky2_hw *hw = sky2->hw;
2719
2720 if (sky2_read8(hw, STAT_TX_TIMER_CTRL) == TIM_STOP)
2721 ecmd->tx_coalesce_usecs = 0;
2722 else {
2723 u32 clks = sky2_read32(hw, STAT_TX_TIMER_INI);
2724 ecmd->tx_coalesce_usecs = sky2_clk2us(hw, clks);
2725 }
2726 ecmd->tx_max_coalesced_frames = sky2_read16(hw, STAT_TX_IDX_TH);
2727
2728 if (sky2_read8(hw, STAT_LEV_TIMER_CTRL) == TIM_STOP)
2729 ecmd->rx_coalesce_usecs = 0;
2730 else {
2731 u32 clks = sky2_read32(hw, STAT_LEV_TIMER_INI);
2732 ecmd->rx_coalesce_usecs = sky2_clk2us(hw, clks);
2733 }
2734 ecmd->rx_max_coalesced_frames = sky2_read8(hw, STAT_FIFO_WM);
2735
2736 if (sky2_read8(hw, STAT_ISR_TIMER_CTRL) == TIM_STOP)
2737 ecmd->rx_coalesce_usecs_irq = 0;
2738 else {
2739 u32 clks = sky2_read32(hw, STAT_ISR_TIMER_INI);
2740 ecmd->rx_coalesce_usecs_irq = sky2_clk2us(hw, clks);
2741 }
2742
2743 ecmd->rx_max_coalesced_frames_irq = sky2_read8(hw, STAT_FIFO_ISR_WM);
2744
2745 return 0;
2746}
2747
2748/* Note: this affect both ports */
2749static int sky2_set_coalesce(struct net_device *dev,
2750 struct ethtool_coalesce *ecmd)
2751{
2752 struct sky2_port *sky2 = netdev_priv(dev);
2753 struct sky2_hw *hw = sky2->hw;
2754 const u32 tmin = sky2_clk2us(hw, 1);
2755 const u32 tmax = 5000;
2756
2757 if (ecmd->tx_coalesce_usecs != 0 &&
2758 (ecmd->tx_coalesce_usecs < tmin || ecmd->tx_coalesce_usecs > tmax))
2759 return -EINVAL;
2760
2761 if (ecmd->rx_coalesce_usecs != 0 &&
2762 (ecmd->rx_coalesce_usecs < tmin || ecmd->rx_coalesce_usecs > tmax))
2763 return -EINVAL;
2764
2765 if (ecmd->rx_coalesce_usecs_irq != 0 &&
2766 (ecmd->rx_coalesce_usecs_irq < tmin || ecmd->rx_coalesce_usecs_irq > tmax))
2767 return -EINVAL;
2768
2769 if (ecmd->tx_max_coalesced_frames > 0xffff)
2770 return -EINVAL;
2771 if (ecmd->rx_max_coalesced_frames > 0xff)
2772 return -EINVAL;
2773 if (ecmd->rx_max_coalesced_frames_irq > 0xff)
2774 return -EINVAL;
2775
2776 if (ecmd->tx_coalesce_usecs == 0)
2777 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
2778 else {
2779 sky2_write32(hw, STAT_TX_TIMER_INI,
2780 sky2_us2clk(hw, ecmd->tx_coalesce_usecs));
2781 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
2782 }
2783 sky2_write16(hw, STAT_TX_IDX_TH, ecmd->tx_max_coalesced_frames);
2784
2785 if (ecmd->rx_coalesce_usecs == 0)
2786 sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_STOP);
2787 else {
2788 sky2_write32(hw, STAT_LEV_TIMER_INI,
2789 sky2_us2clk(hw, ecmd->rx_coalesce_usecs));
2790 sky2_write8(hw, STAT_LEV_TIMER_CTRL, TIM_START);
2791 }
2792 sky2_write8(hw, STAT_FIFO_WM, ecmd->rx_max_coalesced_frames);
2793
2794 if (ecmd->rx_coalesce_usecs_irq == 0)
2795 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_STOP);
2796 else {
2797 sky2_write32(hw, STAT_TX_TIMER_INI,
2798 sky2_us2clk(hw, ecmd->rx_coalesce_usecs_irq));
2799 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
2800 }
2801 sky2_write8(hw, STAT_FIFO_ISR_WM, ecmd->rx_max_coalesced_frames_irq);
2802 return 0;
2803}
2804
2805static void sky2_get_ringparam(struct net_device *dev,
2806 struct ethtool_ringparam *ering)
2807{
2808 struct sky2_port *sky2 = netdev_priv(dev);
2809
2810 ering->rx_max_pending = RX_MAX_PENDING;
2811 ering->rx_mini_max_pending = 0;
2812 ering->rx_jumbo_max_pending = 0;
2813 ering->tx_max_pending = TX_RING_SIZE - 1;
2814
2815 ering->rx_pending = sky2->rx_pending;
2816 ering->rx_mini_pending = 0;
2817 ering->rx_jumbo_pending = 0;
2818 ering->tx_pending = sky2->tx_pending;
2819}
2820
2821static int sky2_set_ringparam(struct net_device *dev,
2822 struct ethtool_ringparam *ering)
2823{
2824 struct sky2_port *sky2 = netdev_priv(dev);
2825 int err = 0;
2826
2827 if (ering->rx_pending > RX_MAX_PENDING ||
2828 ering->rx_pending < 8 ||
2829 ering->tx_pending < MAX_SKB_TX_LE ||
2830 ering->tx_pending > TX_RING_SIZE - 1)
2831 return -EINVAL;
2832
2833 if (netif_running(dev))
2834 sky2_down(dev);
2835
2836 sky2->rx_pending = ering->rx_pending;
2837 sky2->tx_pending = ering->tx_pending;
2838
2839 if (netif_running(dev)) {
2840 err = sky2_up(dev);
2841 if (err)
2842 dev_close(dev);
2843 else
2844 sky2_set_multicast(dev);
2845 }
2846
2847 return err;
2848}
2849
2850static int sky2_get_regs_len(struct net_device *dev)
2851{
2852 return 0x4000;
2853}
2854
2855/*
2856 * Returns copy of control register region
2857 * Note: access to the RAM address register set will cause timeouts.
2858 */
2859static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
2860 void *p)
2861{
2862 const struct sky2_port *sky2 = netdev_priv(dev);
2863 const void __iomem *io = sky2->hw->regs;
2864
2865 BUG_ON(regs->len < B3_RI_WTO_R1);
2866 regs->version = 1;
2867 memset(p, 0, regs->len);
2868
2869 memcpy_fromio(p, io, B3_RAM_ADDR);
2870
2871 memcpy_fromio(p + B3_RI_WTO_R1,
2872 io + B3_RI_WTO_R1,
2873 regs->len - B3_RI_WTO_R1);
2874}
2875
2876static struct ethtool_ops sky2_ethtool_ops = {
2877 .get_settings = sky2_get_settings,
2878 .set_settings = sky2_set_settings,
2879 .get_drvinfo = sky2_get_drvinfo,
2880 .get_msglevel = sky2_get_msglevel,
2881 .set_msglevel = sky2_set_msglevel,
2882 .nway_reset = sky2_nway_reset,
2883 .get_regs_len = sky2_get_regs_len,
2884 .get_regs = sky2_get_regs,
2885 .get_link = ethtool_op_get_link,
2886 .get_sg = ethtool_op_get_sg,
2887 .set_sg = ethtool_op_set_sg,
2888 .get_tx_csum = ethtool_op_get_tx_csum,
2889 .set_tx_csum = ethtool_op_set_tx_csum,
2890 .get_tso = ethtool_op_get_tso,
2891 .set_tso = ethtool_op_set_tso,
2892 .get_rx_csum = sky2_get_rx_csum,
2893 .set_rx_csum = sky2_set_rx_csum,
2894 .get_strings = sky2_get_strings,
2895 .get_coalesce = sky2_get_coalesce,
2896 .set_coalesce = sky2_set_coalesce,
2897 .get_ringparam = sky2_get_ringparam,
2898 .set_ringparam = sky2_set_ringparam,
2899 .get_pauseparam = sky2_get_pauseparam,
2900 .set_pauseparam = sky2_set_pauseparam,
2901#ifdef CONFIG_PM
2902 .get_wol = sky2_get_wol,
2903 .set_wol = sky2_set_wol,
2904#endif
2905 .phys_id = sky2_phys_id,
2906 .get_stats_count = sky2_get_stats_count,
2907 .get_ethtool_stats = sky2_get_ethtool_stats,
2908 .get_perm_addr = ethtool_op_get_perm_addr,
2909};
2910
2911/* Initialize network device */
2912static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
2913 unsigned port, int highmem)
2914{
2915 struct sky2_port *sky2;
2916 struct net_device *dev = alloc_etherdev(sizeof(*sky2));
2917
2918 if (!dev) {
2919 printk(KERN_ERR "sky2 etherdev alloc failed");
2920 return NULL;
2921 }
2922
2923 SET_MODULE_OWNER(dev);
2924 SET_NETDEV_DEV(dev, &hw->pdev->dev);
2925 dev->irq = hw->pdev->irq;
2926 dev->open = sky2_up;
2927 dev->stop = sky2_down;
2928 dev->do_ioctl = sky2_ioctl;
2929 dev->hard_start_xmit = sky2_xmit_frame;
2930 dev->get_stats = sky2_get_stats;
2931 dev->set_multicast_list = sky2_set_multicast;
2932 dev->set_mac_address = sky2_set_mac_address;
2933 dev->change_mtu = sky2_change_mtu;
2934 SET_ETHTOOL_OPS(dev, &sky2_ethtool_ops);
2935 dev->tx_timeout = sky2_tx_timeout;
2936 dev->watchdog_timeo = TX_WATCHDOG;
2937 if (port == 0)
2938 dev->poll = sky2_poll;
2939 dev->weight = NAPI_WEIGHT;
2940#ifdef CONFIG_NET_POLL_CONTROLLER
2941 dev->poll_controller = sky2_netpoll;
2942#endif
2943
2944 sky2 = netdev_priv(dev);
2945 sky2->netdev = dev;
2946 sky2->hw = hw;
2947 sky2->msg_enable = netif_msg_init(debug, default_msg);
2948
2949 spin_lock_init(&sky2->tx_lock);
2950 /* Auto speed and flow control */
2951 sky2->autoneg = AUTONEG_ENABLE;
2952 sky2->tx_pause = 1;
2953 sky2->rx_pause = 1;
2954 sky2->duplex = -1;
2955 sky2->speed = -1;
2956 sky2->advertising = sky2_supported_modes(hw);
2957
2958 /* Receive checksum disabled for Yukon XL
2959 * because of observed problems with incorrect
2960 * values when multiple packets are received in one interrupt
2961 */
2962 sky2->rx_csum = (hw->chip_id != CHIP_ID_YUKON_XL);
2963
2964 INIT_WORK(&sky2->phy_task, sky2_phy_task, sky2);
2965 init_MUTEX(&sky2->phy_sema);
2966 sky2->tx_pending = TX_DEF_PENDING;
2967 sky2->rx_pending = is_ec_a1(hw) ? 8 : RX_DEF_PENDING;
2968 sky2->rx_bufsize = sky2_buf_size(ETH_DATA_LEN);
2969
2970 hw->dev[port] = dev;
2971
2972 sky2->port = port;
2973
2974 dev->features |= NETIF_F_LLTX;
2975 if (hw->chip_id != CHIP_ID_YUKON_EC_U)
2976 dev->features |= NETIF_F_TSO;
2977 if (highmem)
2978 dev->features |= NETIF_F_HIGHDMA;
2979 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
2980
2981#ifdef SKY2_VLAN_TAG_USED
2982 dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
2983 dev->vlan_rx_register = sky2_vlan_rx_register;
2984 dev->vlan_rx_kill_vid = sky2_vlan_rx_kill_vid;
2985#endif
2986
2987 /* read the mac address */
2988 memcpy_fromio(dev->dev_addr, hw->regs + B2_MAC_1 + port * 8, ETH_ALEN);
2989 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
2990
2991 /* device is off until link detection */
2992 netif_carrier_off(dev);
2993 netif_stop_queue(dev);
2994
2995 return dev;
2996}
2997
2998static inline void sky2_show_addr(struct net_device *dev)
2999{
3000 const struct sky2_port *sky2 = netdev_priv(dev);
3001
3002 if (netif_msg_probe(sky2))
3003 printk(KERN_INFO PFX "%s: addr %02x:%02x:%02x:%02x:%02x:%02x\n",
3004 dev->name,
3005 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
3006 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
3007}
3008
3009static int __devinit sky2_probe(struct pci_dev *pdev,
3010 const struct pci_device_id *ent)
3011{
3012 struct net_device *dev, *dev1 = NULL;
3013 struct sky2_hw *hw;
3014 int err, pm_cap, using_dac = 0;
3015
3016 err = pci_enable_device(pdev);
3017 if (err) {
3018 printk(KERN_ERR PFX "%s cannot enable PCI device\n",
3019 pci_name(pdev));
3020 goto err_out;
3021 }
3022
3023 err = pci_request_regions(pdev, DRV_NAME);
3024 if (err) {
3025 printk(KERN_ERR PFX "%s cannot obtain PCI resources\n",
3026 pci_name(pdev));
3027 goto err_out;
3028 }
3029
3030 pci_set_master(pdev);
3031
3032 /* Find power-management capability. */
3033 pm_cap = pci_find_capability(pdev, PCI_CAP_ID_PM);
3034 if (pm_cap == 0) {
3035 printk(KERN_ERR PFX "Cannot find PowerManagement capability, "
3036 "aborting.\n");
3037 err = -EIO;
3038 goto err_out_free_regions;
3039 }
3040
3041 if (sizeof(dma_addr_t) > sizeof(u32)) {
3042 err = pci_set_dma_mask(pdev, DMA_64BIT_MASK);
3043 if (!err)
3044 using_dac = 1;
3045 }
3046
3047 if (!using_dac) {
3048 err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
3049 if (err) {
3050 printk(KERN_ERR PFX "%s no usable DMA configuration\n",
3051 pci_name(pdev));
3052 goto err_out_free_regions;
3053 }
3054 }
3055#ifdef __BIG_ENDIAN
3056 /* byte swap descriptors in hardware */
3057 {
3058 u32 reg;
3059
3060 pci_read_config_dword(pdev, PCI_DEV_REG2, &reg);
3061 reg |= PCI_REV_DESC;
3062 pci_write_config_dword(pdev, PCI_DEV_REG2, reg);
3063 }
3064#endif
3065
3066 err = -ENOMEM;
3067 hw = kmalloc(sizeof(*hw), GFP_KERNEL);
3068 if (!hw) {
3069 printk(KERN_ERR PFX "%s: cannot allocate hardware struct\n",
3070 pci_name(pdev));
3071 goto err_out_free_regions;
3072 }
3073
3074 memset(hw, 0, sizeof(*hw));
3075 hw->pdev = pdev;
3076
3077 hw->regs = ioremap_nocache(pci_resource_start(pdev, 0), 0x4000);
3078 if (!hw->regs) {
3079 printk(KERN_ERR PFX "%s: cannot map device registers\n",
3080 pci_name(pdev));
3081 goto err_out_free_hw;
3082 }
3083 hw->pm_cap = pm_cap;
3084
3085 err = sky2_reset(hw);
3086 if (err)
3087 goto err_out_iounmap;
3088
3089 printk(KERN_INFO PFX "v%s addr 0x%lx irq %d Yukon-%s (0x%x) rev %d\n",
3090 DRV_VERSION, pci_resource_start(pdev, 0), pdev->irq,
3091 yukon2_name[hw->chip_id - CHIP_ID_YUKON_XL],
3092 hw->chip_id, hw->chip_rev);
3093
3094 dev = sky2_init_netdev(hw, 0, using_dac);
3095 if (!dev)
3096 goto err_out_free_pci;
3097
3098 err = register_netdev(dev);
3099 if (err) {
3100 printk(KERN_ERR PFX "%s: cannot register net device\n",
3101 pci_name(pdev));
3102 goto err_out_free_netdev;
3103 }
3104
3105 sky2_show_addr(dev);
3106
3107 if (hw->ports > 1 && (dev1 = sky2_init_netdev(hw, 1, using_dac))) {
3108 if (register_netdev(dev1) == 0)
3109 sky2_show_addr(dev1);
3110 else {
3111 /* Failure to register second port need not be fatal */
3112 printk(KERN_WARNING PFX
3113 "register of second port failed\n");
3114 hw->dev[1] = NULL;
3115 free_netdev(dev1);
3116 }
3117 }
3118
3119 err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw);
3120 if (err) {
3121 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3122 pci_name(pdev), pdev->irq);
3123 goto err_out_unregister;
3124 }
3125
3126 hw->intr_mask = Y2_IS_BASE;
3127 sky2_write32(hw, B0_IMSK, hw->intr_mask);
3128
3129 pci_set_drvdata(pdev, hw);
3130
3131 return 0;
3132
3133err_out_unregister:
3134 if (dev1) {
3135 unregister_netdev(dev1);
3136 free_netdev(dev1);
3137 }
3138 unregister_netdev(dev);
3139err_out_free_netdev:
3140 free_netdev(dev);
3141err_out_free_pci:
3142 sky2_write8(hw, B0_CTST, CS_RST_SET);
3143 pci_free_consistent(hw->pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
3144err_out_iounmap:
3145 iounmap(hw->regs);
3146err_out_free_hw:
3147 kfree(hw);
3148err_out_free_regions:
3149 pci_release_regions(pdev);
3150 pci_disable_device(pdev);
3151err_out:
3152 return err;
3153}
3154
3155static void __devexit sky2_remove(struct pci_dev *pdev)
3156{
3157 struct sky2_hw *hw = pci_get_drvdata(pdev);
3158 struct net_device *dev0, *dev1;
3159
3160 if (!hw)
3161 return;
3162
3163 dev0 = hw->dev[0];
3164 dev1 = hw->dev[1];
3165 if (dev1)
3166 unregister_netdev(dev1);
3167 unregister_netdev(dev0);
3168
3169 sky2_write32(hw, B0_IMSK, 0);
3170 sky2_set_power_state(hw, PCI_D3hot);
3171 sky2_write16(hw, B0_Y2LED, LED_STAT_OFF);
3172 sky2_write8(hw, B0_CTST, CS_RST_SET);
3173 sky2_read8(hw, B0_CTST);
3174
3175 free_irq(pdev->irq, hw);
3176 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
3177 pci_release_regions(pdev);
3178 pci_disable_device(pdev);
3179
3180 if (dev1)
3181 free_netdev(dev1);
3182 free_netdev(dev0);
3183 iounmap(hw->regs);
3184 kfree(hw);
3185
3186 pci_set_drvdata(pdev, NULL);
3187}
3188
3189#ifdef CONFIG_PM
3190static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
3191{
3192 struct sky2_hw *hw = pci_get_drvdata(pdev);
3193 int i;
3194
3195 for (i = 0; i < 2; i++) {
3196 struct net_device *dev = hw->dev[i];
3197
3198 if (dev) {
3199 if (!netif_running(dev))
3200 continue;
3201
3202 sky2_down(dev);
3203 netif_device_detach(dev);
3204 }
3205 }
3206
3207 return sky2_set_power_state(hw, pci_choose_state(pdev, state));
3208}
3209
3210static int sky2_resume(struct pci_dev *pdev)
3211{
3212 struct sky2_hw *hw = pci_get_drvdata(pdev);
3213 int i;
3214
3215 pci_restore_state(pdev);
3216 pci_enable_wake(pdev, PCI_D0, 0);
3217 sky2_set_power_state(hw, PCI_D0);
3218
3219 sky2_reset(hw);
3220
3221 for (i = 0; i < 2; i++) {
3222 struct net_device *dev = hw->dev[i];
3223 if (dev) {
3224 if (netif_running(dev)) {
3225 netif_device_attach(dev);
3226 if (sky2_up(dev))
3227 dev_close(dev);
3228 }
3229 }
3230 }
3231 return 0;
3232}
3233#endif
3234
3235static struct pci_driver sky2_driver = {
3236 .name = DRV_NAME,
3237 .id_table = sky2_id_table,
3238 .probe = sky2_probe,
3239 .remove = __devexit_p(sky2_remove),
3240#ifdef CONFIG_PM
3241 .suspend = sky2_suspend,
3242 .resume = sky2_resume,
3243#endif
3244};
3245
3246static int __init sky2_init_module(void)
3247{
3248 return pci_register_driver(&sky2_driver);
3249}
3250
3251static void __exit sky2_cleanup_module(void)
3252{
3253 pci_unregister_driver(&sky2_driver);
3254}
3255
3256module_init(sky2_init_module);
3257module_exit(sky2_cleanup_module);
3258
3259MODULE_DESCRIPTION("Marvell Yukon 2 Gigabit Ethernet driver");
3260MODULE_AUTHOR("Stephen Hemminger <shemminger@osdl.org>");
3261MODULE_LICENSE("GPL");
3262MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
new file mode 100644
index 000000000000..95518921001c
--- /dev/null
+++ b/drivers/net/sky2.h
@@ -0,0 +1,1922 @@
1/*
2 * Definitions for the new Marvell Yukon 2 driver.
3 */
4#ifndef _SKY2_H
5#define _SKY2_H
6
7/* PCI config registers */
8#define PCI_DEV_REG1 0x40
9#define PCI_DEV_REG2 0x44
10#define PCI_DEV_STATUS 0x7c
11#define PCI_OS_PCI_X (1<<26)
12
13#define PEX_LNK_STAT 0xf2
14#define PEX_UNC_ERR_STAT 0x104
15#define PEX_DEV_CTRL 0xe8
16
17/* Yukon-2 */
18enum pci_dev_reg_1 {
19 PCI_Y2_PIG_ENA = 1<<31, /* Enable Plug-in-Go (YUKON-2) */
20 PCI_Y2_DLL_DIS = 1<<30, /* Disable PCI DLL (YUKON-2) */
21 PCI_Y2_PHY2_COMA = 1<<29, /* Set PHY 2 to Coma Mode (YUKON-2) */
22 PCI_Y2_PHY1_COMA = 1<<28, /* Set PHY 1 to Coma Mode (YUKON-2) */
23 PCI_Y2_PHY2_POWD = 1<<27, /* Set PHY 2 to Power Down (YUKON-2) */
24 PCI_Y2_PHY1_POWD = 1<<26, /* Set PHY 1 to Power Down (YUKON-2) */
25};
26
27enum pci_dev_reg_2 {
28 PCI_VPD_WR_THR = 0xffL<<24, /* Bit 31..24: VPD Write Threshold */
29 PCI_DEV_SEL = 0x7fL<<17, /* Bit 23..17: EEPROM Device Select */
30 PCI_VPD_ROM_SZ = 7L<<14, /* Bit 16..14: VPD ROM Size */
31
32 PCI_PATCH_DIR = 0xfL<<8, /* Bit 11.. 8: Ext Patches dir 3..0 */
33 PCI_EXT_PATCHS = 0xfL<<4, /* Bit 7.. 4: Extended Patches 3..0 */
34 PCI_EN_DUMMY_RD = 1<<3, /* Enable Dummy Read */
35 PCI_REV_DESC = 1<<2, /* Reverse Desc. Bytes */
36
37 PCI_USEDATA64 = 1<<0, /* Use 64Bit Data bus ext */
38};
39
40
41#define PCI_STATUS_ERROR_BITS (PCI_STATUS_DETECTED_PARITY | \
42 PCI_STATUS_SIG_SYSTEM_ERROR | \
43 PCI_STATUS_REC_MASTER_ABORT | \
44 PCI_STATUS_REC_TARGET_ABORT | \
45 PCI_STATUS_PARITY)
46
47enum pex_dev_ctrl {
48 PEX_DC_MAX_RRS_MSK = 7<<12, /* Bit 14..12: Max. Read Request Size */
49 PEX_DC_EN_NO_SNOOP = 1<<11,/* Enable No Snoop */
50 PEX_DC_EN_AUX_POW = 1<<10,/* Enable AUX Power */
51 PEX_DC_EN_PHANTOM = 1<<9, /* Enable Phantom Functions */
52 PEX_DC_EN_EXT_TAG = 1<<8, /* Enable Extended Tag Field */
53 PEX_DC_MAX_PLS_MSK = 7<<5, /* Bit 7.. 5: Max. Payload Size Mask */
54 PEX_DC_EN_REL_ORD = 1<<4, /* Enable Relaxed Ordering */
55 PEX_DC_EN_UNS_RQ_RP = 1<<3, /* Enable Unsupported Request Reporting */
56 PEX_DC_EN_FAT_ER_RP = 1<<2, /* Enable Fatal Error Reporting */
57 PEX_DC_EN_NFA_ER_RP = 1<<1, /* Enable Non-Fatal Error Reporting */
58 PEX_DC_EN_COR_ER_RP = 1<<0, /* Enable Correctable Error Reporting */
59};
60#define PEX_DC_MAX_RD_RQ_SIZE(x) (((x)<<12) & PEX_DC_MAX_RRS_MSK)
61
62/* PEX_UNC_ERR_STAT PEX Uncorrectable Errors Status Register (Yukon-2) */
63enum pex_err {
64 PEX_UNSUP_REQ = 1<<20, /* Unsupported Request Error */
65
66 PEX_MALFOR_TLP = 1<<18, /* Malformed TLP */
67
68 PEX_UNEXP_COMP = 1<<16, /* Unexpected Completion */
69
70 PEX_COMP_TO = 1<<14, /* Completion Timeout */
71 PEX_FLOW_CTRL_P = 1<<13, /* Flow Control Protocol Error */
72 PEX_POIS_TLP = 1<<12, /* Poisoned TLP */
73
74 PEX_DATA_LINK_P = 1<<4, /* Data Link Protocol Error */
75 PEX_FATAL_ERRORS= (PEX_MALFOR_TLP | PEX_FLOW_CTRL_P | PEX_DATA_LINK_P),
76};
77
78
79enum csr_regs {
80 B0_RAP = 0x0000,
81 B0_CTST = 0x0004,
82 B0_Y2LED = 0x0005,
83 B0_POWER_CTRL = 0x0007,
84 B0_ISRC = 0x0008,
85 B0_IMSK = 0x000c,
86 B0_HWE_ISRC = 0x0010,
87 B0_HWE_IMSK = 0x0014,
88
89 /* Special ISR registers (Yukon-2 only) */
90 B0_Y2_SP_ISRC2 = 0x001c,
91 B0_Y2_SP_ISRC3 = 0x0020,
92 B0_Y2_SP_EISR = 0x0024,
93 B0_Y2_SP_LISR = 0x0028,
94 B0_Y2_SP_ICR = 0x002c,
95
96 B2_MAC_1 = 0x0100,
97 B2_MAC_2 = 0x0108,
98 B2_MAC_3 = 0x0110,
99 B2_CONN_TYP = 0x0118,
100 B2_PMD_TYP = 0x0119,
101 B2_MAC_CFG = 0x011a,
102 B2_CHIP_ID = 0x011b,
103 B2_E_0 = 0x011c,
104
105 B2_Y2_CLK_GATE = 0x011d,
106 B2_Y2_HW_RES = 0x011e,
107 B2_E_3 = 0x011f,
108 B2_Y2_CLK_CTRL = 0x0120,
109
110 B2_TI_INI = 0x0130,
111 B2_TI_VAL = 0x0134,
112 B2_TI_CTRL = 0x0138,
113 B2_TI_TEST = 0x0139,
114
115 B2_TST_CTRL1 = 0x0158,
116 B2_TST_CTRL2 = 0x0159,
117 B2_GP_IO = 0x015c,
118
119 B2_I2C_CTRL = 0x0160,
120 B2_I2C_DATA = 0x0164,
121 B2_I2C_IRQ = 0x0168,
122 B2_I2C_SW = 0x016c,
123
124 B3_RAM_ADDR = 0x0180,
125 B3_RAM_DATA_LO = 0x0184,
126 B3_RAM_DATA_HI = 0x0188,
127
128/* RAM Interface Registers */
129/* Yukon-2: use RAM_BUFFER() to access the RAM buffer */
130/*
131 * The HW-Spec. calls this registers Timeout Value 0..11. But this names are
132 * not usable in SW. Please notice these are NOT real timeouts, these are
133 * the number of qWords transferred continuously.
134 */
135#define RAM_BUFFER(port, reg) (reg | (port <<6))
136
137 B3_RI_WTO_R1 = 0x0190,
138 B3_RI_WTO_XA1 = 0x0191,
139 B3_RI_WTO_XS1 = 0x0192,
140 B3_RI_RTO_R1 = 0x0193,
141 B3_RI_RTO_XA1 = 0x0194,
142 B3_RI_RTO_XS1 = 0x0195,
143 B3_RI_WTO_R2 = 0x0196,
144 B3_RI_WTO_XA2 = 0x0197,
145 B3_RI_WTO_XS2 = 0x0198,
146 B3_RI_RTO_R2 = 0x0199,
147 B3_RI_RTO_XA2 = 0x019a,
148 B3_RI_RTO_XS2 = 0x019b,
149 B3_RI_TO_VAL = 0x019c,
150 B3_RI_CTRL = 0x01a0,
151 B3_RI_TEST = 0x01a2,
152 B3_MA_TOINI_RX1 = 0x01b0,
153 B3_MA_TOINI_RX2 = 0x01b1,
154 B3_MA_TOINI_TX1 = 0x01b2,
155 B3_MA_TOINI_TX2 = 0x01b3,
156 B3_MA_TOVAL_RX1 = 0x01b4,
157 B3_MA_TOVAL_RX2 = 0x01b5,
158 B3_MA_TOVAL_TX1 = 0x01b6,
159 B3_MA_TOVAL_TX2 = 0x01b7,
160 B3_MA_TO_CTRL = 0x01b8,
161 B3_MA_TO_TEST = 0x01ba,
162 B3_MA_RCINI_RX1 = 0x01c0,
163 B3_MA_RCINI_RX2 = 0x01c1,
164 B3_MA_RCINI_TX1 = 0x01c2,
165 B3_MA_RCINI_TX2 = 0x01c3,
166 B3_MA_RCVAL_RX1 = 0x01c4,
167 B3_MA_RCVAL_RX2 = 0x01c5,
168 B3_MA_RCVAL_TX1 = 0x01c6,
169 B3_MA_RCVAL_TX2 = 0x01c7,
170 B3_MA_RC_CTRL = 0x01c8,
171 B3_MA_RC_TEST = 0x01ca,
172 B3_PA_TOINI_RX1 = 0x01d0,
173 B3_PA_TOINI_RX2 = 0x01d4,
174 B3_PA_TOINI_TX1 = 0x01d8,
175 B3_PA_TOINI_TX2 = 0x01dc,
176 B3_PA_TOVAL_RX1 = 0x01e0,
177 B3_PA_TOVAL_RX2 = 0x01e4,
178 B3_PA_TOVAL_TX1 = 0x01e8,
179 B3_PA_TOVAL_TX2 = 0x01ec,
180 B3_PA_CTRL = 0x01f0,
181 B3_PA_TEST = 0x01f2,
182
183 Y2_CFG_SPC = 0x1c00,
184};
185
186/* B0_CTST 16 bit Control/Status register */
187enum {
188 Y2_VMAIN_AVAIL = 1<<17,/* VMAIN available (YUKON-2 only) */
189 Y2_VAUX_AVAIL = 1<<16,/* VAUX available (YUKON-2 only) */
190 Y2_ASF_ENABLE = 1<<13,/* ASF Unit Enable (YUKON-2 only) */
191 Y2_ASF_DISABLE = 1<<12,/* ASF Unit Disable (YUKON-2 only) */
192 Y2_CLK_RUN_ENA = 1<<11,/* CLK_RUN Enable (YUKON-2 only) */
193 Y2_CLK_RUN_DIS = 1<<10,/* CLK_RUN Disable (YUKON-2 only) */
194 Y2_LED_STAT_ON = 1<<9, /* Status LED On (YUKON-2 only) */
195 Y2_LED_STAT_OFF = 1<<8, /* Status LED Off (YUKON-2 only) */
196
197 CS_ST_SW_IRQ = 1<<7, /* Set IRQ SW Request */
198 CS_CL_SW_IRQ = 1<<6, /* Clear IRQ SW Request */
199 CS_STOP_DONE = 1<<5, /* Stop Master is finished */
200 CS_STOP_MAST = 1<<4, /* Command Bit to stop the master */
201 CS_MRST_CLR = 1<<3, /* Clear Master reset */
202 CS_MRST_SET = 1<<2, /* Set Master reset */
203 CS_RST_CLR = 1<<1, /* Clear Software reset */
204 CS_RST_SET = 1, /* Set Software reset */
205};
206
207/* B0_LED 8 Bit LED register */
208enum {
209/* Bit 7.. 2: reserved */
210 LED_STAT_ON = 1<<1, /* Status LED on */
211 LED_STAT_OFF = 1, /* Status LED off */
212};
213
214/* B0_POWER_CTRL 8 Bit Power Control reg (YUKON only) */
215enum {
216 PC_VAUX_ENA = 1<<7, /* Switch VAUX Enable */
217 PC_VAUX_DIS = 1<<6, /* Switch VAUX Disable */
218 PC_VCC_ENA = 1<<5, /* Switch VCC Enable */
219 PC_VCC_DIS = 1<<4, /* Switch VCC Disable */
220 PC_VAUX_ON = 1<<3, /* Switch VAUX On */
221 PC_VAUX_OFF = 1<<2, /* Switch VAUX Off */
222 PC_VCC_ON = 1<<1, /* Switch VCC On */
223 PC_VCC_OFF = 1<<0, /* Switch VCC Off */
224};
225
226/* B2_IRQM_MSK 32 bit IRQ Moderation Mask */
227
228/* B0_Y2_SP_ISRC2 32 bit Special Interrupt Source Reg 2 */
229/* B0_Y2_SP_ISRC3 32 bit Special Interrupt Source Reg 3 */
230/* B0_Y2_SP_EISR 32 bit Enter ISR Reg */
231/* B0_Y2_SP_LISR 32 bit Leave ISR Reg */
232enum {
233 Y2_IS_HW_ERR = 1<<31, /* Interrupt HW Error */
234 Y2_IS_STAT_BMU = 1<<30, /* Status BMU Interrupt */
235 Y2_IS_ASF = 1<<29, /* ASF subsystem Interrupt */
236
237 Y2_IS_POLL_CHK = 1<<27, /* Check IRQ from polling unit */
238 Y2_IS_TWSI_RDY = 1<<26, /* IRQ on end of TWSI Tx */
239 Y2_IS_IRQ_SW = 1<<25, /* SW forced IRQ */
240 Y2_IS_TIMINT = 1<<24, /* IRQ from Timer */
241
242 Y2_IS_IRQ_PHY2 = 1<<12, /* Interrupt from PHY 2 */
243 Y2_IS_IRQ_MAC2 = 1<<11, /* Interrupt from MAC 2 */
244 Y2_IS_CHK_RX2 = 1<<10, /* Descriptor error Rx 2 */
245 Y2_IS_CHK_TXS2 = 1<<9, /* Descriptor error TXS 2 */
246 Y2_IS_CHK_TXA2 = 1<<8, /* Descriptor error TXA 2 */
247
248 Y2_IS_IRQ_PHY1 = 1<<4, /* Interrupt from PHY 1 */
249 Y2_IS_IRQ_MAC1 = 1<<3, /* Interrupt from MAC 1 */
250 Y2_IS_CHK_RX1 = 1<<2, /* Descriptor error Rx 1 */
251 Y2_IS_CHK_TXS1 = 1<<1, /* Descriptor error TXS 1 */
252 Y2_IS_CHK_TXA1 = 1<<0, /* Descriptor error TXA 1 */
253
254 Y2_IS_BASE = Y2_IS_HW_ERR | Y2_IS_STAT_BMU |
255 Y2_IS_POLL_CHK | Y2_IS_TWSI_RDY |
256 Y2_IS_IRQ_SW | Y2_IS_TIMINT,
257 Y2_IS_PORT_1 = Y2_IS_IRQ_PHY1 | Y2_IS_IRQ_MAC1 |
258 Y2_IS_CHK_RX1 | Y2_IS_CHK_TXA1 | Y2_IS_CHK_TXS1,
259 Y2_IS_PORT_2 = Y2_IS_IRQ_PHY2 | Y2_IS_IRQ_MAC2 |
260 Y2_IS_CHK_RX2 | Y2_IS_CHK_TXA2 | Y2_IS_CHK_TXS2,
261};
262
263/* B2_IRQM_HWE_MSK 32 bit IRQ Moderation HW Error Mask */
264enum {
265 IS_ERR_MSK = 0x00003fff,/* All Error bits */
266
267 IS_IRQ_TIST_OV = 1<<13, /* Time Stamp Timer Overflow (YUKON only) */
268 IS_IRQ_SENSOR = 1<<12, /* IRQ from Sensor (YUKON only) */
269 IS_IRQ_MST_ERR = 1<<11, /* IRQ master error detected */
270 IS_IRQ_STAT = 1<<10, /* IRQ status exception */
271 IS_NO_STAT_M1 = 1<<9, /* No Rx Status from MAC 1 */
272 IS_NO_STAT_M2 = 1<<8, /* No Rx Status from MAC 2 */
273 IS_NO_TIST_M1 = 1<<7, /* No Time Stamp from MAC 1 */
274 IS_NO_TIST_M2 = 1<<6, /* No Time Stamp from MAC 2 */
275 IS_RAM_RD_PAR = 1<<5, /* RAM Read Parity Error */
276 IS_RAM_WR_PAR = 1<<4, /* RAM Write Parity Error */
277 IS_M1_PAR_ERR = 1<<3, /* MAC 1 Parity Error */
278 IS_M2_PAR_ERR = 1<<2, /* MAC 2 Parity Error */
279 IS_R1_PAR_ERR = 1<<1, /* Queue R1 Parity Error */
280 IS_R2_PAR_ERR = 1<<0, /* Queue R2 Parity Error */
281};
282
283/* Hardware error interrupt mask for Yukon 2 */
284enum {
285 Y2_IS_TIST_OV = 1<<29,/* Time Stamp Timer overflow interrupt */
286 Y2_IS_SENSOR = 1<<28, /* Sensor interrupt */
287 Y2_IS_MST_ERR = 1<<27, /* Master error interrupt */
288 Y2_IS_IRQ_STAT = 1<<26, /* Status exception interrupt */
289 Y2_IS_PCI_EXP = 1<<25, /* PCI-Express interrupt */
290 Y2_IS_PCI_NEXP = 1<<24, /* PCI-Express error similar to PCI error */
291 /* Link 2 */
292 Y2_IS_PAR_RD2 = 1<<13, /* Read RAM parity error interrupt */
293 Y2_IS_PAR_WR2 = 1<<12, /* Write RAM parity error interrupt */
294 Y2_IS_PAR_MAC2 = 1<<11, /* MAC hardware fault interrupt */
295 Y2_IS_PAR_RX2 = 1<<10, /* Parity Error Rx Queue 2 */
296 Y2_IS_TCP_TXS2 = 1<<9, /* TCP length mismatch sync Tx queue IRQ */
297 Y2_IS_TCP_TXA2 = 1<<8, /* TCP length mismatch async Tx queue IRQ */
298 /* Link 1 */
299 Y2_IS_PAR_RD1 = 1<<5, /* Read RAM parity error interrupt */
300 Y2_IS_PAR_WR1 = 1<<4, /* Write RAM parity error interrupt */
301 Y2_IS_PAR_MAC1 = 1<<3, /* MAC hardware fault interrupt */
302 Y2_IS_PAR_RX1 = 1<<2, /* Parity Error Rx Queue 1 */
303 Y2_IS_TCP_TXS1 = 1<<1, /* TCP length mismatch sync Tx queue IRQ */
304 Y2_IS_TCP_TXA1 = 1<<0, /* TCP length mismatch async Tx queue IRQ */
305
306 Y2_HWE_L1_MASK = Y2_IS_PAR_RD1 | Y2_IS_PAR_WR1 | Y2_IS_PAR_MAC1 |
307 Y2_IS_PAR_RX1 | Y2_IS_TCP_TXS1| Y2_IS_TCP_TXA1,
308 Y2_HWE_L2_MASK = Y2_IS_PAR_RD2 | Y2_IS_PAR_WR2 | Y2_IS_PAR_MAC2 |
309 Y2_IS_PAR_RX2 | Y2_IS_TCP_TXS2| Y2_IS_TCP_TXA2,
310
311 Y2_HWE_ALL_MASK = Y2_IS_TIST_OV | Y2_IS_MST_ERR | Y2_IS_IRQ_STAT |
312 Y2_IS_PCI_EXP |
313 Y2_HWE_L1_MASK | Y2_HWE_L2_MASK,
314};
315
316/* B28_DPT_CTRL 8 bit Descriptor Poll Timer Ctrl Reg */
317enum {
318 DPT_START = 1<<1,
319 DPT_STOP = 1<<0,
320};
321
322/* B2_TST_CTRL1 8 bit Test Control Register 1 */
323enum {
324 TST_FRC_DPERR_MR = 1<<7, /* force DATAPERR on MST RD */
325 TST_FRC_DPERR_MW = 1<<6, /* force DATAPERR on MST WR */
326 TST_FRC_DPERR_TR = 1<<5, /* force DATAPERR on TRG RD */
327 TST_FRC_DPERR_TW = 1<<4, /* force DATAPERR on TRG WR */
328 TST_FRC_APERR_M = 1<<3, /* force ADDRPERR on MST */
329 TST_FRC_APERR_T = 1<<2, /* force ADDRPERR on TRG */
330 TST_CFG_WRITE_ON = 1<<1, /* Enable Config Reg WR */
331 TST_CFG_WRITE_OFF= 1<<0, /* Disable Config Reg WR */
332};
333
334/* B2_MAC_CFG 8 bit MAC Configuration / Chip Revision */
335enum {
336 CFG_CHIP_R_MSK = 0xf<<4, /* Bit 7.. 4: Chip Revision */
337 /* Bit 3.. 2: reserved */
338 CFG_DIS_M2_CLK = 1<<1, /* Disable Clock for 2nd MAC */
339 CFG_SNG_MAC = 1<<0, /* MAC Config: 0=2 MACs / 1=1 MAC*/
340};
341
342/* B2_CHIP_ID 8 bit Chip Identification Number */
343enum {
344 CHIP_ID_GENESIS = 0x0a, /* Chip ID for GENESIS */
345 CHIP_ID_YUKON = 0xb0, /* Chip ID for YUKON */
346 CHIP_ID_YUKON_LITE = 0xb1, /* Chip ID for YUKON-Lite (Rev. A1-A3) */
347 CHIP_ID_YUKON_LP = 0xb2, /* Chip ID for YUKON-LP */
348 CHIP_ID_YUKON_XL = 0xb3, /* Chip ID for YUKON-2 XL */
349 CHIP_ID_YUKON_EC_U = 0xb4, /* Chip ID for YUKON-2 EC Ultra */
350 CHIP_ID_YUKON_EC = 0xb6, /* Chip ID for YUKON-2 EC */
351 CHIP_ID_YUKON_FE = 0xb7, /* Chip ID for YUKON-2 FE */
352
353 CHIP_REV_YU_EC_A1 = 0, /* Chip Rev. for Yukon-EC A1/A0 */
354 CHIP_REV_YU_EC_A2 = 1, /* Chip Rev. for Yukon-EC A2 */
355 CHIP_REV_YU_EC_A3 = 2, /* Chip Rev. for Yukon-EC A3 */
356};
357
358/* B2_Y2_CLK_GATE 8 bit Clock Gating (Yukon-2 only) */
359enum {
360 Y2_STATUS_LNK2_INAC = 1<<7, /* Status Link 2 inactive (0 = active) */
361 Y2_CLK_GAT_LNK2_DIS = 1<<6, /* Disable clock gating Link 2 */
362 Y2_COR_CLK_LNK2_DIS = 1<<5, /* Disable Core clock Link 2 */
363 Y2_PCI_CLK_LNK2_DIS = 1<<4, /* Disable PCI clock Link 2 */
364 Y2_STATUS_LNK1_INAC = 1<<3, /* Status Link 1 inactive (0 = active) */
365 Y2_CLK_GAT_LNK1_DIS = 1<<2, /* Disable clock gating Link 1 */
366 Y2_COR_CLK_LNK1_DIS = 1<<1, /* Disable Core clock Link 1 */
367 Y2_PCI_CLK_LNK1_DIS = 1<<0, /* Disable PCI clock Link 1 */
368};
369
370/* B2_Y2_HW_RES 8 bit HW Resources (Yukon-2 only) */
371enum {
372 CFG_LED_MODE_MSK = 7<<2, /* Bit 4.. 2: LED Mode Mask */
373 CFG_LINK_2_AVAIL = 1<<1, /* Link 2 available */
374 CFG_LINK_1_AVAIL = 1<<0, /* Link 1 available */
375};
376#define CFG_LED_MODE(x) (((x) & CFG_LED_MODE_MSK) >> 2)
377#define CFG_DUAL_MAC_MSK (CFG_LINK_2_AVAIL | CFG_LINK_1_AVAIL)
378
379
380/* B2_Y2_CLK_CTRL 32 bit Clock Frequency Control Register (Yukon-2/EC) */
381enum {
382 Y2_CLK_DIV_VAL_MSK = 0xff<<16,/* Bit 23..16: Clock Divisor Value */
383#define Y2_CLK_DIV_VAL(x) (((x)<<16) & Y2_CLK_DIV_VAL_MSK)
384 Y2_CLK_DIV_VAL2_MSK = 7<<21, /* Bit 23..21: Clock Divisor Value */
385 Y2_CLK_SELECT2_MSK = 0x1f<<16,/* Bit 20..16: Clock Select */
386#define Y2_CLK_DIV_VAL_2(x) (((x)<<21) & Y2_CLK_DIV_VAL2_MSK)
387#define Y2_CLK_SEL_VAL_2(x) (((x)<<16) & Y2_CLK_SELECT2_MSK)
388 Y2_CLK_DIV_ENA = 1<<1, /* Enable Core Clock Division */
389 Y2_CLK_DIV_DIS = 1<<0, /* Disable Core Clock Division */
390};
391
392/* B2_TI_CTRL 8 bit Timer control */
393/* B2_IRQM_CTRL 8 bit IRQ Moderation Timer Control */
394enum {
395 TIM_START = 1<<2, /* Start Timer */
396 TIM_STOP = 1<<1, /* Stop Timer */
397 TIM_CLR_IRQ = 1<<0, /* Clear Timer IRQ (!IRQM) */
398};
399
400/* B2_TI_TEST 8 Bit Timer Test */
401/* B2_IRQM_TEST 8 bit IRQ Moderation Timer Test */
402/* B28_DPT_TST 8 bit Descriptor Poll Timer Test Reg */
403enum {
404 TIM_T_ON = 1<<2, /* Test mode on */
405 TIM_T_OFF = 1<<1, /* Test mode off */
406 TIM_T_STEP = 1<<0, /* Test step */
407};
408
409/* B3_RAM_ADDR 32 bit RAM Address, to read or write */
410 /* Bit 31..19: reserved */
411#define RAM_ADR_RAN 0x0007ffffL /* Bit 18.. 0: RAM Address Range */
412/* RAM Interface Registers */
413
414/* B3_RI_CTRL 16 bit RAM Interface Control Register */
415enum {
416 RI_CLR_RD_PERR = 1<<9, /* Clear IRQ RAM Read Parity Err */
417 RI_CLR_WR_PERR = 1<<8, /* Clear IRQ RAM Write Parity Err*/
418
419 RI_RST_CLR = 1<<1, /* Clear RAM Interface Reset */
420 RI_RST_SET = 1<<0, /* Set RAM Interface Reset */
421};
422
423#define SK_RI_TO_53 36 /* RAM interface timeout */
424
425
426/* Port related registers FIFO, and Arbiter */
427#define SK_REG(port,reg) (((port)<<7)+(reg))
428
429/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */
430/* TXA_ITI_INI 32 bit Tx Arb Interval Timer Init Val */
431/* TXA_ITI_VAL 32 bit Tx Arb Interval Timer Value */
432/* TXA_LIM_INI 32 bit Tx Arb Limit Counter Init Val */
433/* TXA_LIM_VAL 32 bit Tx Arb Limit Counter Value */
434
435#define TXA_MAX_VAL 0x00ffffffUL /* Bit 23.. 0: Max TXA Timer/Cnt Val */
436
437/* TXA_CTRL 8 bit Tx Arbiter Control Register */
438enum {
439 TXA_ENA_FSYNC = 1<<7, /* Enable force of sync Tx queue */
440 TXA_DIS_FSYNC = 1<<6, /* Disable force of sync Tx queue */
441 TXA_ENA_ALLOC = 1<<5, /* Enable alloc of free bandwidth */
442 TXA_DIS_ALLOC = 1<<4, /* Disable alloc of free bandwidth */
443 TXA_START_RC = 1<<3, /* Start sync Rate Control */
444 TXA_STOP_RC = 1<<2, /* Stop sync Rate Control */
445 TXA_ENA_ARB = 1<<1, /* Enable Tx Arbiter */
446 TXA_DIS_ARB = 1<<0, /* Disable Tx Arbiter */
447};
448
449/*
450 * Bank 4 - 5
451 */
452/* Transmit Arbiter Registers MAC 1 and 2, use SK_REG() to access */
453enum {
454 TXA_ITI_INI = 0x0200,/* 32 bit Tx Arb Interval Timer Init Val*/
455 TXA_ITI_VAL = 0x0204,/* 32 bit Tx Arb Interval Timer Value */
456 TXA_LIM_INI = 0x0208,/* 32 bit Tx Arb Limit Counter Init Val */
457 TXA_LIM_VAL = 0x020c,/* 32 bit Tx Arb Limit Counter Value */
458 TXA_CTRL = 0x0210,/* 8 bit Tx Arbiter Control Register */
459 TXA_TEST = 0x0211,/* 8 bit Tx Arbiter Test Register */
460 TXA_STAT = 0x0212,/* 8 bit Tx Arbiter Status Register */
461};
462
463
464enum {
465 B6_EXT_REG = 0x0300,/* External registers (GENESIS only) */
466 B7_CFG_SPC = 0x0380,/* copy of the Configuration register */
467 B8_RQ1_REGS = 0x0400,/* Receive Queue 1 */
468 B8_RQ2_REGS = 0x0480,/* Receive Queue 2 */
469 B8_TS1_REGS = 0x0600,/* Transmit sync queue 1 */
470 B8_TA1_REGS = 0x0680,/* Transmit async queue 1 */
471 B8_TS2_REGS = 0x0700,/* Transmit sync queue 2 */
472 B8_TA2_REGS = 0x0780,/* Transmit sync queue 2 */
473 B16_RAM_REGS = 0x0800,/* RAM Buffer Registers */
474};
475
476/* Queue Register Offsets, use Q_ADDR() to access */
477enum {
478 B8_Q_REGS = 0x0400, /* base of Queue registers */
479 Q_D = 0x00, /* 8*32 bit Current Descriptor */
480 Q_DA_L = 0x20, /* 32 bit Current Descriptor Address Low dWord */
481 Q_DA_H = 0x24, /* 32 bit Current Descriptor Address High dWord */
482 Q_AC_L = 0x28, /* 32 bit Current Address Counter Low dWord */
483 Q_AC_H = 0x2c, /* 32 bit Current Address Counter High dWord */
484 Q_BC = 0x30, /* 32 bit Current Byte Counter */
485 Q_CSR = 0x34, /* 32 bit BMU Control/Status Register */
486 Q_F = 0x38, /* 32 bit Flag Register */
487 Q_T1 = 0x3c, /* 32 bit Test Register 1 */
488 Q_T1_TR = 0x3c, /* 8 bit Test Register 1 Transfer SM */
489 Q_T1_WR = 0x3d, /* 8 bit Test Register 1 Write Descriptor SM */
490 Q_T1_RD = 0x3e, /* 8 bit Test Register 1 Read Descriptor SM */
491 Q_T1_SV = 0x3f, /* 8 bit Test Register 1 Supervisor SM */
492 Q_T2 = 0x40, /* 32 bit Test Register 2 */
493 Q_T3 = 0x44, /* 32 bit Test Register 3 */
494
495/* Yukon-2 */
496 Q_DONE = 0x24, /* 16 bit Done Index (Yukon-2 only) */
497 Q_WM = 0x40, /* 16 bit FIFO Watermark */
498 Q_AL = 0x42, /* 8 bit FIFO Alignment */
499 Q_RSP = 0x44, /* 16 bit FIFO Read Shadow Pointer */
500 Q_RSL = 0x46, /* 8 bit FIFO Read Shadow Level */
501 Q_RP = 0x48, /* 8 bit FIFO Read Pointer */
502 Q_RL = 0x4a, /* 8 bit FIFO Read Level */
503 Q_WP = 0x4c, /* 8 bit FIFO Write Pointer */
504 Q_WSP = 0x4d, /* 8 bit FIFO Write Shadow Pointer */
505 Q_WL = 0x4e, /* 8 bit FIFO Write Level */
506 Q_WSL = 0x4f, /* 8 bit FIFO Write Shadow Level */
507};
508#define Q_ADDR(reg, offs) (B8_Q_REGS + (reg) + (offs))
509
510
511/* Queue Prefetch Unit Offsets, use Y2_QADDR() to address (Yukon-2 only)*/
512enum {
513 Y2_B8_PREF_REGS = 0x0450,
514
515 PREF_UNIT_CTRL = 0x00, /* 32 bit Control register */
516 PREF_UNIT_LAST_IDX = 0x04, /* 16 bit Last Index */
517 PREF_UNIT_ADDR_LO = 0x08, /* 32 bit List start addr, low part */
518 PREF_UNIT_ADDR_HI = 0x0c, /* 32 bit List start addr, high part*/
519 PREF_UNIT_GET_IDX = 0x10, /* 16 bit Get Index */
520 PREF_UNIT_PUT_IDX = 0x14, /* 16 bit Put Index */
521 PREF_UNIT_FIFO_WP = 0x20, /* 8 bit FIFO write pointer */
522 PREF_UNIT_FIFO_RP = 0x24, /* 8 bit FIFO read pointer */
523 PREF_UNIT_FIFO_WM = 0x28, /* 8 bit FIFO watermark */
524 PREF_UNIT_FIFO_LEV = 0x2c, /* 8 bit FIFO level */
525
526 PREF_UNIT_MASK_IDX = 0x0fff,
527};
528#define Y2_QADDR(q,reg) (Y2_B8_PREF_REGS + (q) + (reg))
529
530/* RAM Buffer Register Offsets */
531enum {
532
533 RB_START = 0x00,/* 32 bit RAM Buffer Start Address */
534 RB_END = 0x04,/* 32 bit RAM Buffer End Address */
535 RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */
536 RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */
537 RB_RX_UTPP = 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */
538 RB_RX_LTPP = 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */
539 RB_RX_UTHP = 0x18,/* 32 bit Rx Upper Threshold, High Prio */
540 RB_RX_LTHP = 0x1c,/* 32 bit Rx Lower Threshold, High Prio */
541 /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */
542 RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */
543 RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */
544 RB_CTRL = 0x28,/* 32 bit RAM Buffer Control Register */
545 RB_TST1 = 0x29,/* 8 bit RAM Buffer Test Register 1 */
546 RB_TST2 = 0x2a,/* 8 bit RAM Buffer Test Register 2 */
547};
548
549/* Receive and Transmit Queues */
550enum {
551 Q_R1 = 0x0000, /* Receive Queue 1 */
552 Q_R2 = 0x0080, /* Receive Queue 2 */
553 Q_XS1 = 0x0200, /* Synchronous Transmit Queue 1 */
554 Q_XA1 = 0x0280, /* Asynchronous Transmit Queue 1 */
555 Q_XS2 = 0x0300, /* Synchronous Transmit Queue 2 */
556 Q_XA2 = 0x0380, /* Asynchronous Transmit Queue 2 */
557};
558
559/* Different PHY Types */
560enum {
561 PHY_ADDR_MARV = 0,
562};
563
564#define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs))
565
566
567enum {
568 LNK_SYNC_INI = 0x0c30,/* 32 bit Link Sync Cnt Init Value */
569 LNK_SYNC_VAL = 0x0c34,/* 32 bit Link Sync Cnt Current Value */
570 LNK_SYNC_CTRL = 0x0c38,/* 8 bit Link Sync Cnt Control Register */
571 LNK_SYNC_TST = 0x0c39,/* 8 bit Link Sync Cnt Test Register */
572
573 LNK_LED_REG = 0x0c3c,/* 8 bit Link LED Register */
574
575/* Receive GMAC FIFO (YUKON and Yukon-2) */
576
577 RX_GMF_EA = 0x0c40,/* 32 bit Rx GMAC FIFO End Address */
578 RX_GMF_AF_THR = 0x0c44,/* 32 bit Rx GMAC FIFO Almost Full Thresh. */
579 RX_GMF_CTRL_T = 0x0c48,/* 32 bit Rx GMAC FIFO Control/Test */
580 RX_GMF_FL_MSK = 0x0c4c,/* 32 bit Rx GMAC FIFO Flush Mask */
581 RX_GMF_FL_THR = 0x0c50,/* 32 bit Rx GMAC FIFO Flush Threshold */
582 RX_GMF_TR_THR = 0x0c54,/* 32 bit Rx Truncation Threshold (Yukon-2) */
583 RX_GMF_UP_THR = 0x0c58,/* 8 bit Rx Upper Pause Thr (Yukon-EC_U) */
584 RX_GMF_LP_THR = 0x0c5a,/* 8 bit Rx Lower Pause Thr (Yukon-EC_U) */
585 RX_GMF_VLAN = 0x0c5c,/* 32 bit Rx VLAN Type Register (Yukon-2) */
586 RX_GMF_WP = 0x0c60,/* 32 bit Rx GMAC FIFO Write Pointer */
587
588 RX_GMF_WLEV = 0x0c68,/* 32 bit Rx GMAC FIFO Write Level */
589
590 RX_GMF_RP = 0x0c70,/* 32 bit Rx GMAC FIFO Read Pointer */
591
592 RX_GMF_RLEV = 0x0c78,/* 32 bit Rx GMAC FIFO Read Level */
593};
594
595
596/* Q_BC 32 bit Current Byte Counter */
597
598/* BMU Control Status Registers */
599/* B0_R1_CSR 32 bit BMU Ctrl/Stat Rx Queue 1 */
600/* B0_R2_CSR 32 bit BMU Ctrl/Stat Rx Queue 2 */
601/* B0_XA1_CSR 32 bit BMU Ctrl/Stat Sync Tx Queue 1 */
602/* B0_XS1_CSR 32 bit BMU Ctrl/Stat Async Tx Queue 1 */
603/* B0_XA2_CSR 32 bit BMU Ctrl/Stat Sync Tx Queue 2 */
604/* B0_XS2_CSR 32 bit BMU Ctrl/Stat Async Tx Queue 2 */
605/* Q_CSR 32 bit BMU Control/Status Register */
606
607/* Rx BMU Control / Status Registers (Yukon-2) */
608enum {
609 BMU_IDLE = 1<<31, /* BMU Idle State */
610 BMU_RX_TCP_PKT = 1<<30, /* Rx TCP Packet (when RSS Hash enabled) */
611 BMU_RX_IP_PKT = 1<<29, /* Rx IP Packet (when RSS Hash enabled) */
612
613 BMU_ENA_RX_RSS_HASH = 1<<15, /* Enable Rx RSS Hash */
614 BMU_DIS_RX_RSS_HASH = 1<<14, /* Disable Rx RSS Hash */
615 BMU_ENA_RX_CHKSUM = 1<<13, /* Enable Rx TCP/IP Checksum Check */
616 BMU_DIS_RX_CHKSUM = 1<<12, /* Disable Rx TCP/IP Checksum Check */
617 BMU_CLR_IRQ_PAR = 1<<11, /* Clear IRQ on Parity errors (Rx) */
618 BMU_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segment. error (Tx) */
619 BMU_CLR_IRQ_CHK = 1<<10, /* Clear IRQ Check */
620 BMU_STOP = 1<<9, /* Stop Rx/Tx Queue */
621 BMU_START = 1<<8, /* Start Rx/Tx Queue */
622 BMU_FIFO_OP_ON = 1<<7, /* FIFO Operational On */
623 BMU_FIFO_OP_OFF = 1<<6, /* FIFO Operational Off */
624 BMU_FIFO_ENA = 1<<5, /* Enable FIFO */
625 BMU_FIFO_RST = 1<<4, /* Reset FIFO */
626 BMU_OP_ON = 1<<3, /* BMU Operational On */
627 BMU_OP_OFF = 1<<2, /* BMU Operational Off */
628 BMU_RST_CLR = 1<<1, /* Clear BMU Reset (Enable) */
629 BMU_RST_SET = 1<<0, /* Set BMU Reset */
630
631 BMU_CLR_RESET = BMU_FIFO_RST | BMU_OP_OFF | BMU_RST_CLR,
632 BMU_OPER_INIT = BMU_CLR_IRQ_PAR | BMU_CLR_IRQ_CHK | BMU_START |
633 BMU_FIFO_ENA | BMU_OP_ON,
634
635 BMU_WM_DEFAULT = 0x600,
636};
637
638/* Tx BMU Control / Status Registers (Yukon-2) */
639 /* Bit 31: same as for Rx */
640enum {
641 BMU_TX_IPIDINCR_ON = 1<<13, /* Enable IP ID Increment */
642 BMU_TX_IPIDINCR_OFF = 1<<12, /* Disable IP ID Increment */
643 BMU_TX_CLR_IRQ_TCP = 1<<11, /* Clear IRQ on TCP segment length mismatch */
644};
645
646/* Queue Prefetch Unit Offsets, use Y2_QADDR() to address (Yukon-2 only)*/
647/* PREF_UNIT_CTRL 32 bit Prefetch Control register */
648enum {
649 PREF_UNIT_OP_ON = 1<<3, /* prefetch unit operational */
650 PREF_UNIT_OP_OFF = 1<<2, /* prefetch unit not operational */
651 PREF_UNIT_RST_CLR = 1<<1, /* Clear Prefetch Unit Reset */
652 PREF_UNIT_RST_SET = 1<<0, /* Set Prefetch Unit Reset */
653};
654
655/* RAM Buffer Register Offsets, use RB_ADDR(Queue, Offs) to access */
656/* RB_START 32 bit RAM Buffer Start Address */
657/* RB_END 32 bit RAM Buffer End Address */
658/* RB_WP 32 bit RAM Buffer Write Pointer */
659/* RB_RP 32 bit RAM Buffer Read Pointer */
660/* RB_RX_UTPP 32 bit Rx Upper Threshold, Pause Pack */
661/* RB_RX_LTPP 32 bit Rx Lower Threshold, Pause Pack */
662/* RB_RX_UTHP 32 bit Rx Upper Threshold, High Prio */
663/* RB_RX_LTHP 32 bit Rx Lower Threshold, High Prio */
664/* RB_PC 32 bit RAM Buffer Packet Counter */
665/* RB_LEV 32 bit RAM Buffer Level Register */
666
667#define RB_MSK 0x0007ffff /* Bit 18.. 0: RAM Buffer Pointer Bits */
668/* RB_TST2 8 bit RAM Buffer Test Register 2 */
669/* RB_TST1 8 bit RAM Buffer Test Register 1 */
670
671/* RB_CTRL 8 bit RAM Buffer Control Register */
672enum {
673 RB_ENA_STFWD = 1<<5, /* Enable Store & Forward */
674 RB_DIS_STFWD = 1<<4, /* Disable Store & Forward */
675 RB_ENA_OP_MD = 1<<3, /* Enable Operation Mode */
676 RB_DIS_OP_MD = 1<<2, /* Disable Operation Mode */
677 RB_RST_CLR = 1<<1, /* Clear RAM Buf STM Reset */
678 RB_RST_SET = 1<<0, /* Set RAM Buf STM Reset */
679};
680
681
682/* Transmit GMAC FIFO (YUKON only) */
683enum {
684 TX_GMF_EA = 0x0d40,/* 32 bit Tx GMAC FIFO End Address */
685 TX_GMF_AE_THR = 0x0d44,/* 32 bit Tx GMAC FIFO Almost Empty Thresh.*/
686 TX_GMF_CTRL_T = 0x0d48,/* 32 bit Tx GMAC FIFO Control/Test */
687
688 TX_GMF_WP = 0x0d60,/* 32 bit Tx GMAC FIFO Write Pointer */
689 TX_GMF_WSP = 0x0d64,/* 32 bit Tx GMAC FIFO Write Shadow Ptr. */
690 TX_GMF_WLEV = 0x0d68,/* 32 bit Tx GMAC FIFO Write Level */
691
692 TX_GMF_RP = 0x0d70,/* 32 bit Tx GMAC FIFO Read Pointer */
693 TX_GMF_RSTP = 0x0d74,/* 32 bit Tx GMAC FIFO Restart Pointer */
694 TX_GMF_RLEV = 0x0d78,/* 32 bit Tx GMAC FIFO Read Level */
695};
696
697/* Descriptor Poll Timer Registers */
698enum {
699 B28_DPT_INI = 0x0e00,/* 24 bit Descriptor Poll Timer Init Val */
700 B28_DPT_VAL = 0x0e04,/* 24 bit Descriptor Poll Timer Curr Val */
701 B28_DPT_CTRL = 0x0e08,/* 8 bit Descriptor Poll Timer Ctrl Reg */
702
703 B28_DPT_TST = 0x0e0a,/* 8 bit Descriptor Poll Timer Test Reg */
704};
705
706/* Time Stamp Timer Registers (YUKON only) */
707enum {
708 GMAC_TI_ST_VAL = 0x0e14,/* 32 bit Time Stamp Timer Curr Val */
709 GMAC_TI_ST_CTRL = 0x0e18,/* 8 bit Time Stamp Timer Ctrl Reg */
710 GMAC_TI_ST_TST = 0x0e1a,/* 8 bit Time Stamp Timer Test Reg */
711};
712
713/* Polling Unit Registers (Yukon-2 only) */
714enum {
715 POLL_CTRL = 0x0e20, /* 32 bit Polling Unit Control Reg */
716 POLL_LAST_IDX = 0x0e24,/* 16 bit Polling Unit List Last Index */
717
718 POLL_LIST_ADDR_LO= 0x0e28,/* 32 bit Poll. List Start Addr (low) */
719 POLL_LIST_ADDR_HI= 0x0e2c,/* 32 bit Poll. List Start Addr (high) */
720};
721
722/* ASF Subsystem Registers (Yukon-2 only) */
723enum {
724 B28_Y2_SMB_CONFIG = 0x0e40,/* 32 bit ASF SMBus Config Register */
725 B28_Y2_SMB_CSD_REG = 0x0e44,/* 32 bit ASF SMB Control/Status/Data */
726 B28_Y2_ASF_IRQ_V_BASE=0x0e60,/* 32 bit ASF IRQ Vector Base */
727
728 B28_Y2_ASF_STAT_CMD= 0x0e68,/* 32 bit ASF Status and Command Reg */
729 B28_Y2_ASF_HOST_COM= 0x0e6c,/* 32 bit ASF Host Communication Reg */
730 B28_Y2_DATA_REG_1 = 0x0e70,/* 32 bit ASF/Host Data Register 1 */
731 B28_Y2_DATA_REG_2 = 0x0e74,/* 32 bit ASF/Host Data Register 2 */
732 B28_Y2_DATA_REG_3 = 0x0e78,/* 32 bit ASF/Host Data Register 3 */
733 B28_Y2_DATA_REG_4 = 0x0e7c,/* 32 bit ASF/Host Data Register 4 */
734};
735
736/* Status BMU Registers (Yukon-2 only)*/
737enum {
738 STAT_CTRL = 0x0e80,/* 32 bit Status BMU Control Reg */
739 STAT_LAST_IDX = 0x0e84,/* 16 bit Status BMU Last Index */
740
741 STAT_LIST_ADDR_LO= 0x0e88,/* 32 bit Status List Start Addr (low) */
742 STAT_LIST_ADDR_HI= 0x0e8c,/* 32 bit Status List Start Addr (high) */
743 STAT_TXA1_RIDX = 0x0e90,/* 16 bit Status TxA1 Report Index Reg */
744 STAT_TXS1_RIDX = 0x0e92,/* 16 bit Status TxS1 Report Index Reg */
745 STAT_TXA2_RIDX = 0x0e94,/* 16 bit Status TxA2 Report Index Reg */
746 STAT_TXS2_RIDX = 0x0e96,/* 16 bit Status TxS2 Report Index Reg */
747 STAT_TX_IDX_TH = 0x0e98,/* 16 bit Status Tx Index Threshold Reg */
748 STAT_PUT_IDX = 0x0e9c,/* 16 bit Status Put Index Reg */
749
750/* FIFO Control/Status Registers (Yukon-2 only)*/
751 STAT_FIFO_WP = 0x0ea0,/* 8 bit Status FIFO Write Pointer Reg */
752 STAT_FIFO_RP = 0x0ea4,/* 8 bit Status FIFO Read Pointer Reg */
753 STAT_FIFO_RSP = 0x0ea6,/* 8 bit Status FIFO Read Shadow Ptr */
754 STAT_FIFO_LEVEL = 0x0ea8,/* 8 bit Status FIFO Level Reg */
755 STAT_FIFO_SHLVL = 0x0eaa,/* 8 bit Status FIFO Shadow Level Reg */
756 STAT_FIFO_WM = 0x0eac,/* 8 bit Status FIFO Watermark Reg */
757 STAT_FIFO_ISR_WM= 0x0ead,/* 8 bit Status FIFO ISR Watermark Reg */
758
759/* Level and ISR Timer Registers (Yukon-2 only)*/
760 STAT_LEV_TIMER_INI= 0x0eb0,/* 32 bit Level Timer Init. Value Reg */
761 STAT_LEV_TIMER_CNT= 0x0eb4,/* 32 bit Level Timer Counter Reg */
762 STAT_LEV_TIMER_CTRL= 0x0eb8,/* 8 bit Level Timer Control Reg */
763 STAT_LEV_TIMER_TEST= 0x0eb9,/* 8 bit Level Timer Test Reg */
764 STAT_TX_TIMER_INI = 0x0ec0,/* 32 bit Tx Timer Init. Value Reg */
765 STAT_TX_TIMER_CNT = 0x0ec4,/* 32 bit Tx Timer Counter Reg */
766 STAT_TX_TIMER_CTRL = 0x0ec8,/* 8 bit Tx Timer Control Reg */
767 STAT_TX_TIMER_TEST = 0x0ec9,/* 8 bit Tx Timer Test Reg */
768 STAT_ISR_TIMER_INI = 0x0ed0,/* 32 bit ISR Timer Init. Value Reg */
769 STAT_ISR_TIMER_CNT = 0x0ed4,/* 32 bit ISR Timer Counter Reg */
770 STAT_ISR_TIMER_CTRL= 0x0ed8,/* 8 bit ISR Timer Control Reg */
771 STAT_ISR_TIMER_TEST= 0x0ed9,/* 8 bit ISR Timer Test Reg */
772};
773
774enum {
775 LINKLED_OFF = 0x01,
776 LINKLED_ON = 0x02,
777 LINKLED_LINKSYNC_OFF = 0x04,
778 LINKLED_LINKSYNC_ON = 0x08,
779 LINKLED_BLINK_OFF = 0x10,
780 LINKLED_BLINK_ON = 0x20,
781};
782
783/* GMAC and GPHY Control Registers (YUKON only) */
784enum {
785 GMAC_CTRL = 0x0f00,/* 32 bit GMAC Control Reg */
786 GPHY_CTRL = 0x0f04,/* 32 bit GPHY Control Reg */
787 GMAC_IRQ_SRC = 0x0f08,/* 8 bit GMAC Interrupt Source Reg */
788 GMAC_IRQ_MSK = 0x0f0c,/* 8 bit GMAC Interrupt Mask Reg */
789 GMAC_LINK_CTRL = 0x0f10,/* 16 bit Link Control Reg */
790
791/* Wake-up Frame Pattern Match Control Registers (YUKON only) */
792
793 WOL_REG_OFFS = 0x20,/* HW-Bug: Address is + 0x20 against spec. */
794
795 WOL_CTRL_STAT = 0x0f20,/* 16 bit WOL Control/Status Reg */
796 WOL_MATCH_CTL = 0x0f22,/* 8 bit WOL Match Control Reg */
797 WOL_MATCH_RES = 0x0f23,/* 8 bit WOL Match Result Reg */
798 WOL_MAC_ADDR = 0x0f24,/* 32 bit WOL MAC Address */
799 WOL_PATT_PME = 0x0f2a,/* 8 bit WOL PME Match Enable (Yukon-2) */
800 WOL_PATT_ASFM = 0x0f2b,/* 8 bit WOL ASF Match Enable (Yukon-2) */
801 WOL_PATT_RPTR = 0x0f2c,/* 8 bit WOL Pattern Read Pointer */
802
803/* WOL Pattern Length Registers (YUKON only) */
804
805 WOL_PATT_LEN_LO = 0x0f30,/* 32 bit WOL Pattern Length 3..0 */
806 WOL_PATT_LEN_HI = 0x0f34,/* 24 bit WOL Pattern Length 6..4 */
807
808/* WOL Pattern Counter Registers (YUKON only) */
809
810
811 WOL_PATT_CNT_0 = 0x0f38,/* 32 bit WOL Pattern Counter 3..0 */
812 WOL_PATT_CNT_4 = 0x0f3c,/* 24 bit WOL Pattern Counter 6..4 */
813};
814
815enum {
816 WOL_PATT_RAM_1 = 0x1000,/* WOL Pattern RAM Link 1 */
817 WOL_PATT_RAM_2 = 0x1400,/* WOL Pattern RAM Link 2 */
818};
819
820enum {
821 BASE_GMAC_1 = 0x2800,/* GMAC 1 registers */
822 BASE_GMAC_2 = 0x3800,/* GMAC 2 registers */
823};
824
825/*
826 * Marvel-PHY Registers, indirect addressed over GMAC
827 */
828enum {
829 PHY_MARV_CTRL = 0x00,/* 16 bit r/w PHY Control Register */
830 PHY_MARV_STAT = 0x01,/* 16 bit r/o PHY Status Register */
831 PHY_MARV_ID0 = 0x02,/* 16 bit r/o PHY ID0 Register */
832 PHY_MARV_ID1 = 0x03,/* 16 bit r/o PHY ID1 Register */
833 PHY_MARV_AUNE_ADV = 0x04,/* 16 bit r/w Auto-Neg. Advertisement */
834 PHY_MARV_AUNE_LP = 0x05,/* 16 bit r/o Link Part Ability Reg */
835 PHY_MARV_AUNE_EXP = 0x06,/* 16 bit r/o Auto-Neg. Expansion Reg */
836 PHY_MARV_NEPG = 0x07,/* 16 bit r/w Next Page Register */
837 PHY_MARV_NEPG_LP = 0x08,/* 16 bit r/o Next Page Link Partner */
838 /* Marvel-specific registers */
839 PHY_MARV_1000T_CTRL = 0x09,/* 16 bit r/w 1000Base-T Control Reg */
840 PHY_MARV_1000T_STAT = 0x0a,/* 16 bit r/o 1000Base-T Status Reg */
841 PHY_MARV_EXT_STAT = 0x0f,/* 16 bit r/o Extended Status Reg */
842 PHY_MARV_PHY_CTRL = 0x10,/* 16 bit r/w PHY Specific Ctrl Reg */
843 PHY_MARV_PHY_STAT = 0x11,/* 16 bit r/o PHY Specific Stat Reg */
844 PHY_MARV_INT_MASK = 0x12,/* 16 bit r/w Interrupt Mask Reg */
845 PHY_MARV_INT_STAT = 0x13,/* 16 bit r/o Interrupt Status Reg */
846 PHY_MARV_EXT_CTRL = 0x14,/* 16 bit r/w Ext. PHY Specific Ctrl */
847 PHY_MARV_RXE_CNT = 0x15,/* 16 bit r/w Receive Error Counter */
848 PHY_MARV_EXT_ADR = 0x16,/* 16 bit r/w Ext. Ad. for Cable Diag. */
849 PHY_MARV_PORT_IRQ = 0x17,/* 16 bit r/o Port 0 IRQ (88E1111 only) */
850 PHY_MARV_LED_CTRL = 0x18,/* 16 bit r/w LED Control Reg */
851 PHY_MARV_LED_OVER = 0x19,/* 16 bit r/w Manual LED Override Reg */
852 PHY_MARV_EXT_CTRL_2 = 0x1a,/* 16 bit r/w Ext. PHY Specific Ctrl 2 */
853 PHY_MARV_EXT_P_STAT = 0x1b,/* 16 bit r/w Ext. PHY Spec. Stat Reg */
854 PHY_MARV_CABLE_DIAG = 0x1c,/* 16 bit r/o Cable Diagnostic Reg */
855 PHY_MARV_PAGE_ADDR = 0x1d,/* 16 bit r/w Extended Page Address Reg */
856 PHY_MARV_PAGE_DATA = 0x1e,/* 16 bit r/w Extended Page Data Reg */
857
858/* for 10/100 Fast Ethernet PHY (88E3082 only) */
859 PHY_MARV_FE_LED_PAR = 0x16,/* 16 bit r/w LED Parallel Select Reg. */
860 PHY_MARV_FE_LED_SER = 0x17,/* 16 bit r/w LED Stream Select S. LED */
861 PHY_MARV_FE_VCT_TX = 0x1a,/* 16 bit r/w VCT Reg. for TXP/N Pins */
862 PHY_MARV_FE_VCT_RX = 0x1b,/* 16 bit r/o VCT Reg. for RXP/N Pins */
863 PHY_MARV_FE_SPEC_2 = 0x1c,/* 16 bit r/w Specific Control Reg. 2 */
864};
865
866enum {
867 PHY_CT_RESET = 1<<15, /* Bit 15: (sc) clear all PHY related regs */
868 PHY_CT_LOOP = 1<<14, /* Bit 14: enable Loopback over PHY */
869 PHY_CT_SPS_LSB = 1<<13, /* Bit 13: Speed select, lower bit */
870 PHY_CT_ANE = 1<<12, /* Bit 12: Auto-Negotiation Enabled */
871 PHY_CT_PDOWN = 1<<11, /* Bit 11: Power Down Mode */
872 PHY_CT_ISOL = 1<<10, /* Bit 10: Isolate Mode */
873 PHY_CT_RE_CFG = 1<<9, /* Bit 9: (sc) Restart Auto-Negotiation */
874 PHY_CT_DUP_MD = 1<<8, /* Bit 8: Duplex Mode */
875 PHY_CT_COL_TST = 1<<7, /* Bit 7: Collision Test enabled */
876 PHY_CT_SPS_MSB = 1<<6, /* Bit 6: Speed select, upper bit */
877};
878
879enum {
880 PHY_CT_SP1000 = PHY_CT_SPS_MSB, /* enable speed of 1000 Mbps */
881 PHY_CT_SP100 = PHY_CT_SPS_LSB, /* enable speed of 100 Mbps */
882 PHY_CT_SP10 = 0, /* enable speed of 10 Mbps */
883};
884
885enum {
886 PHY_ST_EXT_ST = 1<<8, /* Bit 8: Extended Status Present */
887
888 PHY_ST_PRE_SUP = 1<<6, /* Bit 6: Preamble Suppression */
889 PHY_ST_AN_OVER = 1<<5, /* Bit 5: Auto-Negotiation Over */
890 PHY_ST_REM_FLT = 1<<4, /* Bit 4: Remote Fault Condition Occured */
891 PHY_ST_AN_CAP = 1<<3, /* Bit 3: Auto-Negotiation Capability */
892 PHY_ST_LSYNC = 1<<2, /* Bit 2: Link Synchronized */
893 PHY_ST_JAB_DET = 1<<1, /* Bit 1: Jabber Detected */
894 PHY_ST_EXT_REG = 1<<0, /* Bit 0: Extended Register available */
895};
896
897enum {
898 PHY_I1_OUI_MSK = 0x3f<<10, /* Bit 15..10: Organization Unique ID */
899 PHY_I1_MOD_NUM = 0x3f<<4, /* Bit 9.. 4: Model Number */
900 PHY_I1_REV_MSK = 0xf, /* Bit 3.. 0: Revision Number */
901};
902
903/* different Marvell PHY Ids */
904enum {
905 PHY_MARV_ID0_VAL= 0x0141, /* Marvell Unique Identifier */
906
907 PHY_BCOM_ID1_A1 = 0x6041,
908 PHY_BCOM_ID1_B2 = 0x6043,
909 PHY_BCOM_ID1_C0 = 0x6044,
910 PHY_BCOM_ID1_C5 = 0x6047,
911
912 PHY_MARV_ID1_B0 = 0x0C23, /* Yukon (PHY 88E1011) */
913 PHY_MARV_ID1_B2 = 0x0C25, /* Yukon-Plus (PHY 88E1011) */
914 PHY_MARV_ID1_C2 = 0x0CC2, /* Yukon-EC (PHY 88E1111) */
915 PHY_MARV_ID1_Y2 = 0x0C91, /* Yukon-2 (PHY 88E1112) */
916};
917
918/* Advertisement register bits */
919enum {
920 PHY_AN_NXT_PG = 1<<15, /* Bit 15: Request Next Page */
921 PHY_AN_ACK = 1<<14, /* Bit 14: (ro) Acknowledge Received */
922 PHY_AN_RF = 1<<13, /* Bit 13: Remote Fault Bits */
923
924 PHY_AN_PAUSE_ASYM = 1<<11,/* Bit 11: Try for asymmetric */
925 PHY_AN_PAUSE_CAP = 1<<10, /* Bit 10: Try for pause */
926 PHY_AN_100BASE4 = 1<<9, /* Bit 9: Try for 100mbps 4k packets */
927 PHY_AN_100FULL = 1<<8, /* Bit 8: Try for 100mbps full-duplex */
928 PHY_AN_100HALF = 1<<7, /* Bit 7: Try for 100mbps half-duplex */
929 PHY_AN_10FULL = 1<<6, /* Bit 6: Try for 10mbps full-duplex */
930 PHY_AN_10HALF = 1<<5, /* Bit 5: Try for 10mbps half-duplex */
931 PHY_AN_CSMA = 1<<0, /* Bit 0: Only selector supported */
932 PHY_AN_SEL = 0x1f, /* Bit 4..0: Selector Field, 00001=Ethernet*/
933 PHY_AN_FULL = PHY_AN_100FULL | PHY_AN_10FULL | PHY_AN_CSMA,
934 PHY_AN_ALL = PHY_AN_10HALF | PHY_AN_10FULL |
935 PHY_AN_100HALF | PHY_AN_100FULL,
936};
937
938/***** PHY_BCOM_1000T_STAT 16 bit r/o 1000Base-T Status Reg *****/
939/***** PHY_MARV_1000T_STAT 16 bit r/o 1000Base-T Status Reg *****/
940enum {
941 PHY_B_1000S_MSF = 1<<15, /* Bit 15: Master/Slave Fault */
942 PHY_B_1000S_MSR = 1<<14, /* Bit 14: Master/Slave Result */
943 PHY_B_1000S_LRS = 1<<13, /* Bit 13: Local Receiver Status */
944 PHY_B_1000S_RRS = 1<<12, /* Bit 12: Remote Receiver Status */
945 PHY_B_1000S_LP_FD = 1<<11, /* Bit 11: Link Partner can FD */
946 PHY_B_1000S_LP_HD = 1<<10, /* Bit 10: Link Partner can HD */
947 /* Bit 9..8: reserved */
948 PHY_B_1000S_IEC = 0xff, /* Bit 7..0: Idle Error Count */
949};
950
951/** Marvell-Specific */
952enum {
953 PHY_M_AN_NXT_PG = 1<<15, /* Request Next Page */
954 PHY_M_AN_ACK = 1<<14, /* (ro) Acknowledge Received */
955 PHY_M_AN_RF = 1<<13, /* Remote Fault */
956
957 PHY_M_AN_ASP = 1<<11, /* Asymmetric Pause */
958 PHY_M_AN_PC = 1<<10, /* MAC Pause implemented */
959 PHY_M_AN_100_T4 = 1<<9, /* Not cap. 100Base-T4 (always 0) */
960 PHY_M_AN_100_FD = 1<<8, /* Advertise 100Base-TX Full Duplex */
961 PHY_M_AN_100_HD = 1<<7, /* Advertise 100Base-TX Half Duplex */
962 PHY_M_AN_10_FD = 1<<6, /* Advertise 10Base-TX Full Duplex */
963 PHY_M_AN_10_HD = 1<<5, /* Advertise 10Base-TX Half Duplex */
964 PHY_M_AN_SEL_MSK =0x1f<<4, /* Bit 4.. 0: Selector Field Mask */
965};
966
967/* special defines for FIBER (88E1011S only) */
968enum {
969 PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */
970 PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */
971 PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */
972 PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */
973};
974
975/* Pause Bits (PHY_M_AN_ASP_X and PHY_M_AN_PC_X) encoding */
976enum {
977 PHY_M_P_NO_PAUSE_X = 0<<7,/* Bit 8.. 7: no Pause Mode */
978 PHY_M_P_SYM_MD_X = 1<<7, /* Bit 8.. 7: symmetric Pause Mode */
979 PHY_M_P_ASYM_MD_X = 2<<7,/* Bit 8.. 7: asymmetric Pause Mode */
980 PHY_M_P_BOTH_MD_X = 3<<7,/* Bit 8.. 7: both Pause Mode */
981};
982
983/***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/
984enum {
985 PHY_M_1000C_TEST = 7<<13,/* Bit 15..13: Test Modes */
986 PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */
987 PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */
988 PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */
989 PHY_M_1000C_AFD = 1<<9, /* Advertise Full Duplex */
990 PHY_M_1000C_AHD = 1<<8, /* Advertise Half Duplex */
991};
992
993/***** PHY_MARV_PHY_CTRL 16 bit r/w PHY Specific Ctrl Reg *****/
994enum {
995 PHY_M_PC_TX_FFD_MSK = 3<<14,/* Bit 15..14: Tx FIFO Depth Mask */
996 PHY_M_PC_RX_FFD_MSK = 3<<12,/* Bit 13..12: Rx FIFO Depth Mask */
997 PHY_M_PC_ASS_CRS_TX = 1<<11, /* Assert CRS on Transmit */
998 PHY_M_PC_FL_GOOD = 1<<10, /* Force Link Good */
999 PHY_M_PC_EN_DET_MSK = 3<<8,/* Bit 9.. 8: Energy Detect Mask */
1000 PHY_M_PC_ENA_EXT_D = 1<<7, /* Enable Ext. Distance (10BT) */
1001 PHY_M_PC_MDIX_MSK = 3<<5,/* Bit 6.. 5: MDI/MDIX Config. Mask */
1002 PHY_M_PC_DIS_125CLK = 1<<4, /* Disable 125 CLK */
1003 PHY_M_PC_MAC_POW_UP = 1<<3, /* MAC Power up */
1004 PHY_M_PC_SQE_T_ENA = 1<<2, /* SQE Test Enabled */
1005 PHY_M_PC_POL_R_DIS = 1<<1, /* Polarity Reversal Disabled */
1006 PHY_M_PC_DIS_JABBER = 1<<0, /* Disable Jabber */
1007};
1008
1009enum {
1010 PHY_M_PC_EN_DET = 2<<8, /* Energy Detect (Mode 1) */
1011 PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */
1012};
1013
1014#define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK)
1015
1016enum {
1017 PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */
1018 PHY_M_PC_MAN_MDIX = 1, /* 01 = Manual MDIX configuration */
1019 PHY_M_PC_ENA_AUTO = 3, /* 11 = Enable Automatic Crossover */
1020};
1021
1022/* for 10/100 Fast Ethernet PHY (88E3082 only) */
1023enum {
1024 PHY_M_PC_ENA_DTE_DT = 1<<15, /* Enable Data Terminal Equ. (DTE) Detect */
1025 PHY_M_PC_ENA_ENE_DT = 1<<14, /* Enable Energy Detect (sense & pulse) */
1026 PHY_M_PC_DIS_NLP_CK = 1<<13, /* Disable Normal Link Puls (NLP) Check */
1027 PHY_M_PC_ENA_LIP_NP = 1<<12, /* Enable Link Partner Next Page Reg. */
1028 PHY_M_PC_DIS_NLP_GN = 1<<11, /* Disable Normal Link Puls Generation */
1029
1030 PHY_M_PC_DIS_SCRAMB = 1<<9, /* Disable Scrambler */
1031 PHY_M_PC_DIS_FEFI = 1<<8, /* Disable Far End Fault Indic. (FEFI) */
1032
1033 PHY_M_PC_SH_TP_SEL = 1<<6, /* Shielded Twisted Pair Select */
1034 PHY_M_PC_RX_FD_MSK = 3<<2,/* Bit 3.. 2: Rx FIFO Depth Mask */
1035};
1036
1037/***** PHY_MARV_PHY_STAT 16 bit r/o PHY Specific Status Reg *****/
1038enum {
1039 PHY_M_PS_SPEED_MSK = 3<<14, /* Bit 15..14: Speed Mask */
1040 PHY_M_PS_SPEED_1000 = 1<<15, /* 10 = 1000 Mbps */
1041 PHY_M_PS_SPEED_100 = 1<<14, /* 01 = 100 Mbps */
1042 PHY_M_PS_SPEED_10 = 0, /* 00 = 10 Mbps */
1043 PHY_M_PS_FULL_DUP = 1<<13, /* Full Duplex */
1044 PHY_M_PS_PAGE_REC = 1<<12, /* Page Received */
1045 PHY_M_PS_SPDUP_RES = 1<<11, /* Speed & Duplex Resolved */
1046 PHY_M_PS_LINK_UP = 1<<10, /* Link Up */
1047 PHY_M_PS_CABLE_MSK = 7<<7, /* Bit 9.. 7: Cable Length Mask */
1048 PHY_M_PS_MDI_X_STAT = 1<<6, /* MDI Crossover Stat (1=MDIX) */
1049 PHY_M_PS_DOWNS_STAT = 1<<5, /* Downshift Status (1=downsh.) */
1050 PHY_M_PS_ENDET_STAT = 1<<4, /* Energy Detect Status (1=act) */
1051 PHY_M_PS_TX_P_EN = 1<<3, /* Tx Pause Enabled */
1052 PHY_M_PS_RX_P_EN = 1<<2, /* Rx Pause Enabled */
1053 PHY_M_PS_POL_REV = 1<<1, /* Polarity Reversed */
1054 PHY_M_PS_JABBER = 1<<0, /* Jabber */
1055};
1056
1057#define PHY_M_PS_PAUSE_MSK (PHY_M_PS_TX_P_EN | PHY_M_PS_RX_P_EN)
1058
1059/* for 10/100 Fast Ethernet PHY (88E3082 only) */
1060enum {
1061 PHY_M_PS_DTE_DETECT = 1<<15, /* Data Terminal Equipment (DTE) Detected */
1062 PHY_M_PS_RES_SPEED = 1<<14, /* Resolved Speed (1=100 Mbps, 0=10 Mbps */
1063};
1064
1065enum {
1066 PHY_M_IS_AN_ERROR = 1<<15, /* Auto-Negotiation Error */
1067 PHY_M_IS_LSP_CHANGE = 1<<14, /* Link Speed Changed */
1068 PHY_M_IS_DUP_CHANGE = 1<<13, /* Duplex Mode Changed */
1069 PHY_M_IS_AN_PR = 1<<12, /* Page Received */
1070 PHY_M_IS_AN_COMPL = 1<<11, /* Auto-Negotiation Completed */
1071 PHY_M_IS_LST_CHANGE = 1<<10, /* Link Status Changed */
1072 PHY_M_IS_SYMB_ERROR = 1<<9, /* Symbol Error */
1073 PHY_M_IS_FALSE_CARR = 1<<8, /* False Carrier */
1074 PHY_M_IS_FIFO_ERROR = 1<<7, /* FIFO Overflow/Underrun Error */
1075 PHY_M_IS_MDI_CHANGE = 1<<6, /* MDI Crossover Changed */
1076 PHY_M_IS_DOWNSH_DET = 1<<5, /* Downshift Detected */
1077 PHY_M_IS_END_CHANGE = 1<<4, /* Energy Detect Changed */
1078
1079 PHY_M_IS_DTE_CHANGE = 1<<2, /* DTE Power Det. Status Changed */
1080 PHY_M_IS_POL_CHANGE = 1<<1, /* Polarity Changed */
1081 PHY_M_IS_JABBER = 1<<0, /* Jabber */
1082
1083 PHY_M_DEF_MSK = PHY_M_IS_LSP_CHANGE | PHY_M_IS_LST_CHANGE
1084 | PHY_M_IS_FIFO_ERROR,
1085 PHY_M_AN_MSK = PHY_M_IS_AN_ERROR | PHY_M_IS_AN_COMPL,
1086};
1087
1088
1089/***** PHY_MARV_EXT_CTRL 16 bit r/w Ext. PHY Specific Ctrl *****/
1090enum {
1091 PHY_M_EC_ENA_BC_EXT = 1<<15, /* Enable Block Carr. Ext. (88E1111 only) */
1092 PHY_M_EC_ENA_LIN_LB = 1<<14, /* Enable Line Loopback (88E1111 only) */
1093
1094 PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */
1095 PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */
1096 /* (88E1011 only) */
1097 PHY_M_EC_S_DSC_MSK = 3<<8,/* Bit 9.. 8: Slave Downshift Counter */
1098 /* (88E1011 only) */
1099 PHY_M_EC_M_DSC_MSK2 = 7<<9,/* Bit 11.. 9: Master Downshift Counter */
1100 /* (88E1111 only) */
1101 PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */
1102 /* !!! Errata in spec. (1 = disable) */
1103 PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/
1104 PHY_M_EC_MAC_S_MSK = 7<<4,/* Bit 6.. 4: Def. MAC interface speed */
1105 PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */
1106 PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */
1107 PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */
1108 PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */};
1109
1110#define PHY_M_EC_M_DSC(x) ((x)<<10 & PHY_M_EC_M_DSC_MSK)
1111 /* 00=1x; 01=2x; 10=3x; 11=4x */
1112#define PHY_M_EC_S_DSC(x) ((x)<<8 & PHY_M_EC_S_DSC_MSK)
1113 /* 00=dis; 01=1x; 10=2x; 11=3x */
1114#define PHY_M_EC_DSC_2(x) ((x)<<9 & PHY_M_EC_M_DSC_MSK2)
1115 /* 000=1x; 001=2x; 010=3x; 011=4x */
1116#define PHY_M_EC_MAC_S(x) ((x)<<4 & PHY_M_EC_MAC_S_MSK)
1117 /* 01X=0; 110=2.5; 111=25 (MHz) */
1118
1119/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
1120enum {
1121 PHY_M_PC_DIS_LINK_Pa = 1<<15,/* Disable Link Pulses */
1122 PHY_M_PC_DSC_MSK = 7<<12,/* Bit 14..12: Downshift Counter */
1123 PHY_M_PC_DOWN_S_ENA = 1<<11,/* Downshift Enable */
1124};
1125/* !!! Errata in spec. (1 = disable) */
1126
1127#define PHY_M_PC_DSC(x) (((x)<<12) & PHY_M_PC_DSC_MSK)
1128 /* 100=5x; 101=6x; 110=7x; 111=8x */
1129enum {
1130 MAC_TX_CLK_0_MHZ = 2,
1131 MAC_TX_CLK_2_5_MHZ = 6,
1132 MAC_TX_CLK_25_MHZ = 7,
1133};
1134
1135/***** PHY_MARV_LED_CTRL 16 bit r/w LED Control Reg *****/
1136enum {
1137 PHY_M_LEDC_DIS_LED = 1<<15, /* Disable LED */
1138 PHY_M_LEDC_PULS_MSK = 7<<12,/* Bit 14..12: Pulse Stretch Mask */
1139 PHY_M_LEDC_F_INT = 1<<11, /* Force Interrupt */
1140 PHY_M_LEDC_BL_R_MSK = 7<<8,/* Bit 10.. 8: Blink Rate Mask */
1141 PHY_M_LEDC_DP_C_LSB = 1<<7, /* Duplex Control (LSB, 88E1111 only) */
1142 PHY_M_LEDC_TX_C_LSB = 1<<6, /* Tx Control (LSB, 88E1111 only) */
1143 PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */
1144 /* (88E1111 only) */
1145};
1146
1147enum {
1148 PHY_M_LEDC_LINK_MSK = 3<<3,/* Bit 4.. 3: Link Control Mask */
1149 /* (88E1011 only) */
1150 PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */
1151 PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */
1152 PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */
1153 PHY_M_LEDC_TX_CTRL = 1<<0, /* Tx Activity / Link */
1154 PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */
1155};
1156
1157#define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK)
1158
1159/***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/
1160enum {
1161 PHY_M_POLC_LS1M_MSK = 0xf<<12, /* Bit 15..12: LOS,STAT1 Mix % Mask */
1162 PHY_M_POLC_IS0M_MSK = 0xf<<8, /* Bit 11.. 8: INIT,STAT0 Mix % Mask */
1163 PHY_M_POLC_LOS_MSK = 0x3<<6, /* Bit 7.. 6: LOS Pol. Ctrl. Mask */
1164 PHY_M_POLC_INIT_MSK = 0x3<<4, /* Bit 5.. 4: INIT Pol. Ctrl. Mask */
1165 PHY_M_POLC_STA1_MSK = 0x3<<2, /* Bit 3.. 2: STAT1 Pol. Ctrl. Mask */
1166 PHY_M_POLC_STA0_MSK = 0x3, /* Bit 1.. 0: STAT0 Pol. Ctrl. Mask */
1167};
1168
1169#define PHY_M_POLC_LS1_P_MIX(x) (((x)<<12) & PHY_M_POLC_LS1M_MSK)
1170#define PHY_M_POLC_IS0_P_MIX(x) (((x)<<8) & PHY_M_POLC_IS0M_MSK)
1171#define PHY_M_POLC_LOS_CTRL(x) (((x)<<6) & PHY_M_POLC_LOS_MSK)
1172#define PHY_M_POLC_INIT_CTRL(x) (((x)<<4) & PHY_M_POLC_INIT_MSK)
1173#define PHY_M_POLC_STA1_CTRL(x) (((x)<<2) & PHY_M_POLC_STA1_MSK)
1174#define PHY_M_POLC_STA0_CTRL(x) (((x)<<0) & PHY_M_POLC_STA0_MSK)
1175
1176enum {
1177 PULS_NO_STR = 0,/* no pulse stretching */
1178 PULS_21MS = 1,/* 21 ms to 42 ms */
1179 PULS_42MS = 2,/* 42 ms to 84 ms */
1180 PULS_84MS = 3,/* 84 ms to 170 ms */
1181 PULS_170MS = 4,/* 170 ms to 340 ms */
1182 PULS_340MS = 5,/* 340 ms to 670 ms */
1183 PULS_670MS = 6,/* 670 ms to 1.3 s */
1184 PULS_1300MS = 7,/* 1.3 s to 2.7 s */
1185};
1186
1187#define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK)
1188
1189enum {
1190 BLINK_42MS = 0,/* 42 ms */
1191 BLINK_84MS = 1,/* 84 ms */
1192 BLINK_170MS = 2,/* 170 ms */
1193 BLINK_340MS = 3,/* 340 ms */
1194 BLINK_670MS = 4,/* 670 ms */
1195};
1196
1197/***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/
1198#define PHY_M_LED_MO_SGMII(x) ((x)<<14) /* Bit 15..14: SGMII AN Timer */
1199 /* Bit 13..12: reserved */
1200#define PHY_M_LED_MO_DUP(x) ((x)<<10) /* Bit 11..10: Duplex */
1201#define PHY_M_LED_MO_10(x) ((x)<<8) /* Bit 9.. 8: Link 10 */
1202#define PHY_M_LED_MO_100(x) ((x)<<6) /* Bit 7.. 6: Link 100 */
1203#define PHY_M_LED_MO_1000(x) ((x)<<4) /* Bit 5.. 4: Link 1000 */
1204#define PHY_M_LED_MO_RX(x) ((x)<<2) /* Bit 3.. 2: Rx */
1205#define PHY_M_LED_MO_TX(x) ((x)<<0) /* Bit 1.. 0: Tx */
1206
1207enum {
1208 MO_LED_NORM = 0,
1209 MO_LED_BLINK = 1,
1210 MO_LED_OFF = 2,
1211 MO_LED_ON = 3,
1212};
1213
1214/***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/
1215enum {
1216 PHY_M_EC2_FI_IMPED = 1<<6, /* Fiber Input Impedance */
1217 PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */
1218 PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */
1219 PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */
1220 PHY_M_EC2_FO_AM_MSK = 7,/* Bit 2.. 0: Fiber Output Amplitude */
1221};
1222
1223/***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/
1224enum {
1225 PHY_M_FC_AUTO_SEL = 1<<15, /* Fiber/Copper Auto Sel. Dis. */
1226 PHY_M_FC_AN_REG_ACC = 1<<14, /* Fiber/Copper AN Reg. Access */
1227 PHY_M_FC_RESOLUTION = 1<<13, /* Fiber/Copper Resolution */
1228 PHY_M_SER_IF_AN_BP = 1<<12, /* Ser. IF AN Bypass Enable */
1229 PHY_M_SER_IF_BP_ST = 1<<11, /* Ser. IF AN Bypass Status */
1230 PHY_M_IRQ_POLARITY = 1<<10, /* IRQ polarity */
1231 PHY_M_DIS_AUT_MED = 1<<9, /* Disable Aut. Medium Reg. Selection */
1232 /* (88E1111 only) */
1233
1234 PHY_M_UNDOC1 = 1<<7, /* undocumented bit !! */
1235 PHY_M_DTE_POW_STAT = 1<<4, /* DTE Power Status (88E1111 only) */
1236 PHY_M_MODE_MASK = 0xf, /* Bit 3.. 0: copy of HWCFG MODE[3:0] */
1237};
1238
1239/* for 10/100 Fast Ethernet PHY (88E3082 only) */
1240/***** PHY_MARV_FE_LED_PAR 16 bit r/w LED Parallel Select Reg. *****/
1241 /* Bit 15..12: reserved (used internally) */
1242enum {
1243 PHY_M_FELP_LED2_MSK = 0xf<<8, /* Bit 11.. 8: LED2 Mask (LINK) */
1244 PHY_M_FELP_LED1_MSK = 0xf<<4, /* Bit 7.. 4: LED1 Mask (ACT) */
1245 PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */
1246};
1247
1248#define PHY_M_FELP_LED2_CTRL(x) (((x)<<8) & PHY_M_FELP_LED2_MSK)
1249#define PHY_M_FELP_LED1_CTRL(x) (((x)<<4) & PHY_M_FELP_LED1_MSK)
1250#define PHY_M_FELP_LED0_CTRL(x) (((x)<<0) & PHY_M_FELP_LED0_MSK)
1251
1252enum {
1253 LED_PAR_CTRL_COLX = 0x00,
1254 LED_PAR_CTRL_ERROR = 0x01,
1255 LED_PAR_CTRL_DUPLEX = 0x02,
1256 LED_PAR_CTRL_DP_COL = 0x03,
1257 LED_PAR_CTRL_SPEED = 0x04,
1258 LED_PAR_CTRL_LINK = 0x05,
1259 LED_PAR_CTRL_TX = 0x06,
1260 LED_PAR_CTRL_RX = 0x07,
1261 LED_PAR_CTRL_ACT = 0x08,
1262 LED_PAR_CTRL_LNK_RX = 0x09,
1263 LED_PAR_CTRL_LNK_AC = 0x0a,
1264 LED_PAR_CTRL_ACT_BL = 0x0b,
1265 LED_PAR_CTRL_TX_BL = 0x0c,
1266 LED_PAR_CTRL_RX_BL = 0x0d,
1267 LED_PAR_CTRL_COL_BL = 0x0e,
1268 LED_PAR_CTRL_INACT = 0x0f
1269};
1270
1271/*****,PHY_MARV_FE_SPEC_2 16 bit r/w Specific Control Reg. 2 *****/
1272enum {
1273 PHY_M_FESC_DIS_WAIT = 1<<2, /* Disable TDR Waiting Period */
1274 PHY_M_FESC_ENA_MCLK = 1<<1, /* Enable MAC Rx Clock in sleep mode */
1275 PHY_M_FESC_SEL_CL_A = 1<<0, /* Select Class A driver (100B-TX) */
1276};
1277
1278/* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */
1279/***** PHY_MARV_PHY_CTRL (page 2) 16 bit r/w MAC Specific Ctrl *****/
1280enum {
1281 PHY_M_MAC_MD_MSK = 7<<7, /* Bit 9.. 7: Mode Select Mask */
1282 PHY_M_MAC_MD_AUTO = 3,/* Auto Copper/1000Base-X */
1283 PHY_M_MAC_MD_COPPER = 5,/* Copper only */
1284 PHY_M_MAC_MD_1000BX = 7,/* 1000Base-X only */
1285};
1286#define PHY_M_MAC_MODE_SEL(x) (((x)<<7) & PHY_M_MAC_MD_MSK)
1287
1288/***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/
1289enum {
1290 PHY_M_LEDC_LOS_MSK = 0xf<<12,/* Bit 15..12: LOS LED Ctrl. Mask */
1291 PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */
1292 PHY_M_LEDC_STA1_MSK = 0xf<<4,/* Bit 7.. 4: STAT1 LED Ctrl. Mask */
1293 PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */
1294};
1295
1296#define PHY_M_LEDC_LOS_CTRL(x) (((x)<<12) & PHY_M_LEDC_LOS_MSK)
1297#define PHY_M_LEDC_INIT_CTRL(x) (((x)<<8) & PHY_M_LEDC_INIT_MSK)
1298#define PHY_M_LEDC_STA1_CTRL(x) (((x)<<4) & PHY_M_LEDC_STA1_MSK)
1299#define PHY_M_LEDC_STA0_CTRL(x) (((x)<<0) & PHY_M_LEDC_STA0_MSK)
1300
1301/* GMAC registers */
1302/* Port Registers */
1303enum {
1304 GM_GP_STAT = 0x0000, /* 16 bit r/o General Purpose Status */
1305 GM_GP_CTRL = 0x0004, /* 16 bit r/w General Purpose Control */
1306 GM_TX_CTRL = 0x0008, /* 16 bit r/w Transmit Control Reg. */
1307 GM_RX_CTRL = 0x000c, /* 16 bit r/w Receive Control Reg. */
1308 GM_TX_FLOW_CTRL = 0x0010, /* 16 bit r/w Transmit Flow-Control */
1309 GM_TX_PARAM = 0x0014, /* 16 bit r/w Transmit Parameter Reg. */
1310 GM_SERIAL_MODE = 0x0018, /* 16 bit r/w Serial Mode Register */
1311/* Source Address Registers */
1312 GM_SRC_ADDR_1L = 0x001c, /* 16 bit r/w Source Address 1 (low) */
1313 GM_SRC_ADDR_1M = 0x0020, /* 16 bit r/w Source Address 1 (middle) */
1314 GM_SRC_ADDR_1H = 0x0024, /* 16 bit r/w Source Address 1 (high) */
1315 GM_SRC_ADDR_2L = 0x0028, /* 16 bit r/w Source Address 2 (low) */
1316 GM_SRC_ADDR_2M = 0x002c, /* 16 bit r/w Source Address 2 (middle) */
1317 GM_SRC_ADDR_2H = 0x0030, /* 16 bit r/w Source Address 2 (high) */
1318
1319/* Multicast Address Hash Registers */
1320 GM_MC_ADDR_H1 = 0x0034, /* 16 bit r/w Multicast Address Hash 1 */
1321 GM_MC_ADDR_H2 = 0x0038, /* 16 bit r/w Multicast Address Hash 2 */
1322 GM_MC_ADDR_H3 = 0x003c, /* 16 bit r/w Multicast Address Hash 3 */
1323 GM_MC_ADDR_H4 = 0x0040, /* 16 bit r/w Multicast Address Hash 4 */
1324
1325/* Interrupt Source Registers */
1326 GM_TX_IRQ_SRC = 0x0044, /* 16 bit r/o Tx Overflow IRQ Source */
1327 GM_RX_IRQ_SRC = 0x0048, /* 16 bit r/o Rx Overflow IRQ Source */
1328 GM_TR_IRQ_SRC = 0x004c, /* 16 bit r/o Tx/Rx Over. IRQ Source */
1329
1330/* Interrupt Mask Registers */
1331 GM_TX_IRQ_MSK = 0x0050, /* 16 bit r/w Tx Overflow IRQ Mask */
1332 GM_RX_IRQ_MSK = 0x0054, /* 16 bit r/w Rx Overflow IRQ Mask */
1333 GM_TR_IRQ_MSK = 0x0058, /* 16 bit r/w Tx/Rx Over. IRQ Mask */
1334
1335/* Serial Management Interface (SMI) Registers */
1336 GM_SMI_CTRL = 0x0080, /* 16 bit r/w SMI Control Register */
1337 GM_SMI_DATA = 0x0084, /* 16 bit r/w SMI Data Register */
1338 GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */
1339};
1340
1341/* MIB Counters */
1342#define GM_MIB_CNT_BASE 0x0100 /* Base Address of MIB Counters */
1343#define GM_MIB_CNT_SIZE 44 /* Number of MIB Counters */
1344
1345/*
1346 * MIB Counters base address definitions (low word) -
1347 * use offset 4 for access to high word (32 bit r/o)
1348 */
1349enum {
1350 GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */
1351 GM_RXF_BC_OK = GM_MIB_CNT_BASE + 8, /* Broadcast Frames Received OK */
1352 GM_RXF_MPAUSE = GM_MIB_CNT_BASE + 16, /* Pause MAC Ctrl Frames Received */
1353 GM_RXF_MC_OK = GM_MIB_CNT_BASE + 24, /* Multicast Frames Received OK */
1354 GM_RXF_FCS_ERR = GM_MIB_CNT_BASE + 32, /* Rx Frame Check Seq. Error */
1355 /* GM_MIB_CNT_BASE + 40: reserved */
1356 GM_RXO_OK_LO = GM_MIB_CNT_BASE + 48, /* Octets Received OK Low */
1357 GM_RXO_OK_HI = GM_MIB_CNT_BASE + 56, /* Octets Received OK High */
1358 GM_RXO_ERR_LO = GM_MIB_CNT_BASE + 64, /* Octets Received Invalid Low */
1359 GM_RXO_ERR_HI = GM_MIB_CNT_BASE + 72, /* Octets Received Invalid High */
1360 GM_RXF_SHT = GM_MIB_CNT_BASE + 80, /* Frames <64 Byte Received OK */
1361 GM_RXE_FRAG = GM_MIB_CNT_BASE + 88, /* Frames <64 Byte Received with FCS Err */
1362 GM_RXF_64B = GM_MIB_CNT_BASE + 96, /* 64 Byte Rx Frame */
1363 GM_RXF_127B = GM_MIB_CNT_BASE + 104, /* 65-127 Byte Rx Frame */
1364 GM_RXF_255B = GM_MIB_CNT_BASE + 112, /* 128-255 Byte Rx Frame */
1365 GM_RXF_511B = GM_MIB_CNT_BASE + 120, /* 256-511 Byte Rx Frame */
1366 GM_RXF_1023B = GM_MIB_CNT_BASE + 128, /* 512-1023 Byte Rx Frame */
1367 GM_RXF_1518B = GM_MIB_CNT_BASE + 136, /* 1024-1518 Byte Rx Frame */
1368 GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144, /* 1519-MaxSize Byte Rx Frame */
1369 GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152, /* Rx Frame too Long Error */
1370 GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160, /* Rx Jabber Packet Frame */
1371 /* GM_MIB_CNT_BASE + 168: reserved */
1372 GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176, /* Rx FIFO overflow Event */
1373 /* GM_MIB_CNT_BASE + 184: reserved */
1374 GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192, /* Unicast Frames Xmitted OK */
1375 GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200, /* Broadcast Frames Xmitted OK */
1376 GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208, /* Pause MAC Ctrl Frames Xmitted */
1377 GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216, /* Multicast Frames Xmitted OK */
1378 GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224, /* Octets Transmitted OK Low */
1379 GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232, /* Octets Transmitted OK High */
1380 GM_TXF_64B = GM_MIB_CNT_BASE + 240, /* 64 Byte Tx Frame */
1381 GM_TXF_127B = GM_MIB_CNT_BASE + 248, /* 65-127 Byte Tx Frame */
1382 GM_TXF_255B = GM_MIB_CNT_BASE + 256, /* 128-255 Byte Tx Frame */
1383 GM_TXF_511B = GM_MIB_CNT_BASE + 264, /* 256-511 Byte Tx Frame */
1384 GM_TXF_1023B = GM_MIB_CNT_BASE + 272, /* 512-1023 Byte Tx Frame */
1385 GM_TXF_1518B = GM_MIB_CNT_BASE + 280, /* 1024-1518 Byte Tx Frame */
1386 GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288, /* 1519-MaxSize Byte Tx Frame */
1387
1388 GM_TXF_COL = GM_MIB_CNT_BASE + 304, /* Tx Collision */
1389 GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312, /* Tx Late Collision */
1390 GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320, /* Tx aborted due to Exces. Col. */
1391 GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328, /* Tx Multiple Collision */
1392 GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336, /* Tx Single Collision */
1393 GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344, /* Tx FIFO Underrun Event */
1394};
1395
1396/* GMAC Bit Definitions */
1397/* GM_GP_STAT 16 bit r/o General Purpose Status Register */
1398enum {
1399 GM_GPSR_SPEED = 1<<15, /* Bit 15: Port Speed (1 = 100 Mbps) */
1400 GM_GPSR_DUPLEX = 1<<14, /* Bit 14: Duplex Mode (1 = Full) */
1401 GM_GPSR_FC_TX_DIS = 1<<13, /* Bit 13: Tx Flow-Control Mode Disabled */
1402 GM_GPSR_LINK_UP = 1<<12, /* Bit 12: Link Up Status */
1403 GM_GPSR_PAUSE = 1<<11, /* Bit 11: Pause State */
1404 GM_GPSR_TX_ACTIVE = 1<<10, /* Bit 10: Tx in Progress */
1405 GM_GPSR_EXC_COL = 1<<9, /* Bit 9: Excessive Collisions Occured */
1406 GM_GPSR_LAT_COL = 1<<8, /* Bit 8: Late Collisions Occured */
1407
1408 GM_GPSR_PHY_ST_CH = 1<<5, /* Bit 5: PHY Status Change */
1409 GM_GPSR_GIG_SPEED = 1<<4, /* Bit 4: Gigabit Speed (1 = 1000 Mbps) */
1410 GM_GPSR_PART_MODE = 1<<3, /* Bit 3: Partition mode */
1411 GM_GPSR_FC_RX_DIS = 1<<2, /* Bit 2: Rx Flow-Control Mode Disabled */
1412 GM_GPSR_PROM_EN = 1<<1, /* Bit 1: Promiscuous Mode Enabled */
1413};
1414
1415/* GM_GP_CTRL 16 bit r/w General Purpose Control Register */
1416enum {
1417 GM_GPCR_PROM_ENA = 1<<14, /* Bit 14: Enable Promiscuous Mode */
1418 GM_GPCR_FC_TX_DIS = 1<<13, /* Bit 13: Disable Tx Flow-Control Mode */
1419 GM_GPCR_TX_ENA = 1<<12, /* Bit 12: Enable Transmit */
1420 GM_GPCR_RX_ENA = 1<<11, /* Bit 11: Enable Receive */
1421 GM_GPCR_BURST_ENA = 1<<10, /* Bit 10: Enable Burst Mode */
1422 GM_GPCR_LOOP_ENA = 1<<9, /* Bit 9: Enable MAC Loopback Mode */
1423 GM_GPCR_PART_ENA = 1<<8, /* Bit 8: Enable Partition Mode */
1424 GM_GPCR_GIGS_ENA = 1<<7, /* Bit 7: Gigabit Speed (1000 Mbps) */
1425 GM_GPCR_FL_PASS = 1<<6, /* Bit 6: Force Link Pass */
1426 GM_GPCR_DUP_FULL = 1<<5, /* Bit 5: Full Duplex Mode */
1427 GM_GPCR_FC_RX_DIS = 1<<4, /* Bit 4: Disable Rx Flow-Control Mode */
1428 GM_GPCR_SPEED_100 = 1<<3, /* Bit 3: Port Speed 100 Mbps */
1429 GM_GPCR_AU_DUP_DIS = 1<<2, /* Bit 2: Disable Auto-Update Duplex */
1430 GM_GPCR_AU_FCT_DIS = 1<<1, /* Bit 1: Disable Auto-Update Flow-C. */
1431 GM_GPCR_AU_SPD_DIS = 1<<0, /* Bit 0: Disable Auto-Update Speed */
1432};
1433
1434#define GM_GPCR_SPEED_1000 (GM_GPCR_GIGS_ENA | GM_GPCR_SPEED_100)
1435#define GM_GPCR_AU_ALL_DIS (GM_GPCR_AU_DUP_DIS | GM_GPCR_AU_FCT_DIS|GM_GPCR_AU_SPD_DIS)
1436
1437/* GM_TX_CTRL 16 bit r/w Transmit Control Register */
1438enum {
1439 GM_TXCR_FORCE_JAM = 1<<15, /* Bit 15: Force Jam / Flow-Control */
1440 GM_TXCR_CRC_DIS = 1<<14, /* Bit 14: Disable insertion of CRC */
1441 GM_TXCR_PAD_DIS = 1<<13, /* Bit 13: Disable padding of packets */
1442 GM_TXCR_COL_THR_MSK = 1<<10, /* Bit 12..10: Collision Threshold */
1443};
1444
1445#define TX_COL_THR(x) (((x)<<10) & GM_TXCR_COL_THR_MSK)
1446#define TX_COL_DEF 0x04
1447
1448/* GM_RX_CTRL 16 bit r/w Receive Control Register */
1449enum {
1450 GM_RXCR_UCF_ENA = 1<<15, /* Bit 15: Enable Unicast filtering */
1451 GM_RXCR_MCF_ENA = 1<<14, /* Bit 14: Enable Multicast filtering */
1452 GM_RXCR_CRC_DIS = 1<<13, /* Bit 13: Remove 4-byte CRC */
1453 GM_RXCR_PASS_FC = 1<<12, /* Bit 12: Pass FC packets to FIFO */
1454};
1455
1456/* GM_TX_PARAM 16 bit r/w Transmit Parameter Register */
1457enum {
1458 GM_TXPA_JAMLEN_MSK = 0x03<<14, /* Bit 15..14: Jam Length */
1459 GM_TXPA_JAMIPG_MSK = 0x1f<<9, /* Bit 13..9: Jam IPG */
1460 GM_TXPA_JAMDAT_MSK = 0x1f<<4, /* Bit 8..4: IPG Jam to Data */
1461 GM_TXPA_BO_LIM_MSK = 0x0f, /* Bit 3.. 0: Backoff Limit Mask */
1462
1463 TX_JAM_LEN_DEF = 0x03,
1464 TX_JAM_IPG_DEF = 0x0b,
1465 TX_IPG_JAM_DEF = 0x1c,
1466 TX_BOF_LIM_DEF = 0x04,
1467};
1468
1469#define TX_JAM_LEN_VAL(x) (((x)<<14) & GM_TXPA_JAMLEN_MSK)
1470#define TX_JAM_IPG_VAL(x) (((x)<<9) & GM_TXPA_JAMIPG_MSK)
1471#define TX_IPG_JAM_DATA(x) (((x)<<4) & GM_TXPA_JAMDAT_MSK)
1472#define TX_BACK_OFF_LIM(x) ((x) & GM_TXPA_BO_LIM_MSK)
1473
1474
1475/* GM_SERIAL_MODE 16 bit r/w Serial Mode Register */
1476enum {
1477 GM_SMOD_DATABL_MSK = 0x1f<<11, /* Bit 15..11: Data Blinder (r/o) */
1478 GM_SMOD_LIMIT_4 = 1<<10, /* Bit 10: 4 consecutive Tx trials */
1479 GM_SMOD_VLAN_ENA = 1<<9, /* Bit 9: Enable VLAN (Max. Frame Len) */
1480 GM_SMOD_JUMBO_ENA = 1<<8, /* Bit 8: Enable Jumbo (Max. Frame Len) */
1481 GM_SMOD_IPG_MSK = 0x1f /* Bit 4..0: Inter-Packet Gap (IPG) */
1482};
1483
1484#define DATA_BLIND_VAL(x) (((x)<<11) & GM_SMOD_DATABL_MSK)
1485#define DATA_BLIND_DEF 0x04
1486
1487#define IPG_DATA_VAL(x) (x & GM_SMOD_IPG_MSK)
1488#define IPG_DATA_DEF 0x1e
1489
1490/* GM_SMI_CTRL 16 bit r/w SMI Control Register */
1491enum {
1492 GM_SMI_CT_PHY_A_MSK = 0x1f<<11,/* Bit 15..11: PHY Device Address */
1493 GM_SMI_CT_REG_A_MSK = 0x1f<<6,/* Bit 10.. 6: PHY Register Address */
1494 GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/
1495 GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */
1496 GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */
1497};
1498
1499#define GM_SMI_CT_PHY_AD(x) (((x)<<11) & GM_SMI_CT_PHY_A_MSK)
1500#define GM_SMI_CT_REG_AD(x) (((x)<<6) & GM_SMI_CT_REG_A_MSK)
1501
1502/* GM_PHY_ADDR 16 bit r/w GPHY Address Register */
1503enum {
1504 GM_PAR_MIB_CLR = 1<<5, /* Bit 5: Set MIB Clear Counter Mode */
1505 GM_PAR_MIB_TST = 1<<4, /* Bit 4: MIB Load Counter (Test Mode) */
1506};
1507
1508/* Receive Frame Status Encoding */
1509enum {
1510 GMR_FS_LEN = 0xffff<<16, /* Bit 31..16: Rx Frame Length */
1511 GMR_FS_VLAN = 1<<13, /* VLAN Packet */
1512 GMR_FS_JABBER = 1<<12, /* Jabber Packet */
1513 GMR_FS_UN_SIZE = 1<<11, /* Undersize Packet */
1514 GMR_FS_MC = 1<<10, /* Multicast Packet */
1515 GMR_FS_BC = 1<<9, /* Broadcast Packet */
1516 GMR_FS_RX_OK = 1<<8, /* Receive OK (Good Packet) */
1517 GMR_FS_GOOD_FC = 1<<7, /* Good Flow-Control Packet */
1518 GMR_FS_BAD_FC = 1<<6, /* Bad Flow-Control Packet */
1519 GMR_FS_MII_ERR = 1<<5, /* MII Error */
1520 GMR_FS_LONG_ERR = 1<<4, /* Too Long Packet */
1521 GMR_FS_FRAGMENT = 1<<3, /* Fragment */
1522
1523 GMR_FS_CRC_ERR = 1<<1, /* CRC Error */
1524 GMR_FS_RX_FF_OV = 1<<0, /* Rx FIFO Overflow */
1525
1526 GMR_FS_ANY_ERR = GMR_FS_RX_FF_OV | GMR_FS_CRC_ERR |
1527 GMR_FS_FRAGMENT | GMR_FS_LONG_ERR |
1528 GMR_FS_MII_ERR | GMR_FS_BAD_FC | GMR_FS_GOOD_FC |
1529 GMR_FS_UN_SIZE | GMR_FS_JABBER,
1530};
1531
1532/* RX_GMF_CTRL_T 32 bit Rx GMAC FIFO Control/Test */
1533enum {
1534 RX_TRUNC_ON = 1<<27, /* enable packet truncation */
1535 RX_TRUNC_OFF = 1<<26, /* disable packet truncation */
1536 RX_VLAN_STRIP_ON = 1<<25, /* enable VLAN stripping */
1537 RX_VLAN_STRIP_OFF = 1<<24, /* disable VLAN stripping */
1538
1539 GMF_WP_TST_ON = 1<<14, /* Write Pointer Test On */
1540 GMF_WP_TST_OFF = 1<<13, /* Write Pointer Test Off */
1541 GMF_WP_STEP = 1<<12, /* Write Pointer Step/Increment */
1542
1543 GMF_RP_TST_ON = 1<<10, /* Read Pointer Test On */
1544 GMF_RP_TST_OFF = 1<<9, /* Read Pointer Test Off */
1545 GMF_RP_STEP = 1<<8, /* Read Pointer Step/Increment */
1546 GMF_RX_F_FL_ON = 1<<7, /* Rx FIFO Flush Mode On */
1547 GMF_RX_F_FL_OFF = 1<<6, /* Rx FIFO Flush Mode Off */
1548 GMF_CLI_RX_FO = 1<<5, /* Clear IRQ Rx FIFO Overrun */
1549 GMF_CLI_RX_C = 1<<4, /* Clear IRQ Rx Frame Complete */
1550
1551 GMF_OPER_ON = 1<<3, /* Operational Mode On */
1552 GMF_OPER_OFF = 1<<2, /* Operational Mode Off */
1553 GMF_RST_CLR = 1<<1, /* Clear GMAC FIFO Reset */
1554 GMF_RST_SET = 1<<0, /* Set GMAC FIFO Reset */
1555
1556 RX_GMF_FL_THR_DEF = 0xa, /* flush threshold (default) */
1557
1558 GMF_RX_CTRL_DEF = GMF_OPER_ON | GMF_RX_F_FL_ON,
1559};
1560
1561
1562/* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */
1563enum {
1564 TX_STFW_DIS = 1<<31,/* Disable Store & Forward (Yukon-EC Ultra) */
1565 TX_STFW_ENA = 1<<30,/* Enable Store & Forward (Yukon-EC Ultra) */
1566
1567 TX_VLAN_TAG_ON = 1<<25,/* enable VLAN tagging */
1568 TX_VLAN_TAG_OFF = 1<<24,/* disable VLAN tagging */
1569
1570 GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */
1571 GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */
1572 GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */
1573
1574 GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */
1575 GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */
1576 GMF_CLI_TX_PE = 1<<4, /* Clear IRQ Tx Parity Error */
1577};
1578
1579/* GMAC_TI_ST_CTRL 8 bit Time Stamp Timer Ctrl Reg (YUKON only) */
1580enum {
1581 GMT_ST_START = 1<<2, /* Start Time Stamp Timer */
1582 GMT_ST_STOP = 1<<1, /* Stop Time Stamp Timer */
1583 GMT_ST_CLR_IRQ = 1<<0, /* Clear Time Stamp Timer IRQ */
1584};
1585
1586/* B28_Y2_ASF_STAT_CMD 32 bit ASF Status and Command Reg */
1587enum {
1588 Y2_ASF_OS_PRES = 1<<4, /* ASF operation system present */
1589 Y2_ASF_RESET = 1<<3, /* ASF system in reset state */
1590 Y2_ASF_RUNNING = 1<<2, /* ASF system operational */
1591 Y2_ASF_CLR_HSTI = 1<<1, /* Clear ASF IRQ */
1592 Y2_ASF_IRQ = 1<<0, /* Issue an IRQ to ASF system */
1593
1594 Y2_ASF_UC_STATE = 3<<2, /* ASF uC State */
1595 Y2_ASF_CLK_HALT = 0, /* ASF system clock stopped */
1596};
1597
1598/* B28_Y2_ASF_HOST_COM 32 bit ASF Host Communication Reg */
1599enum {
1600 Y2_ASF_CLR_ASFI = 1<<1, /* Clear host IRQ */
1601 Y2_ASF_HOST_IRQ = 1<<0, /* Issue an IRQ to HOST system */
1602};
1603
1604/* STAT_CTRL 32 bit Status BMU control register (Yukon-2 only) */
1605enum {
1606 SC_STAT_CLR_IRQ = 1<<4, /* Status Burst IRQ clear */
1607 SC_STAT_OP_ON = 1<<3, /* Operational Mode On */
1608 SC_STAT_OP_OFF = 1<<2, /* Operational Mode Off */
1609 SC_STAT_RST_CLR = 1<<1, /* Clear Status Unit Reset (Enable) */
1610 SC_STAT_RST_SET = 1<<0, /* Set Status Unit Reset */
1611};
1612
1613/* GMAC_CTRL 32 bit GMAC Control Reg (YUKON only) */
1614enum {
1615 GMC_H_BURST_ON = 1<<7, /* Half Duplex Burst Mode On */
1616 GMC_H_BURST_OFF = 1<<6, /* Half Duplex Burst Mode Off */
1617 GMC_F_LOOPB_ON = 1<<5, /* FIFO Loopback On */
1618 GMC_F_LOOPB_OFF = 1<<4, /* FIFO Loopback Off */
1619 GMC_PAUSE_ON = 1<<3, /* Pause On */
1620 GMC_PAUSE_OFF = 1<<2, /* Pause Off */
1621 GMC_RST_CLR = 1<<1, /* Clear GMAC Reset */
1622 GMC_RST_SET = 1<<0, /* Set GMAC Reset */
1623};
1624
1625/* GPHY_CTRL 32 bit GPHY Control Reg (YUKON only) */
1626enum {
1627 GPC_SEL_BDT = 1<<28, /* Select Bi-Dir. Transfer for MDC/MDIO */
1628 GPC_INT_POL_HI = 1<<27, /* IRQ Polarity is Active HIGH */
1629 GPC_75_OHM = 1<<26, /* Use 75 Ohm Termination instead of 50 */
1630 GPC_DIS_FC = 1<<25, /* Disable Automatic Fiber/Copper Detection */
1631 GPC_DIS_SLEEP = 1<<24, /* Disable Energy Detect */
1632 GPC_HWCFG_M_3 = 1<<23, /* HWCFG_MODE[3] */
1633 GPC_HWCFG_M_2 = 1<<22, /* HWCFG_MODE[2] */
1634 GPC_HWCFG_M_1 = 1<<21, /* HWCFG_MODE[1] */
1635 GPC_HWCFG_M_0 = 1<<20, /* HWCFG_MODE[0] */
1636 GPC_ANEG_0 = 1<<19, /* ANEG[0] */
1637 GPC_ENA_XC = 1<<18, /* Enable MDI crossover */
1638 GPC_DIS_125 = 1<<17, /* Disable 125 MHz clock */
1639 GPC_ANEG_3 = 1<<16, /* ANEG[3] */
1640 GPC_ANEG_2 = 1<<15, /* ANEG[2] */
1641 GPC_ANEG_1 = 1<<14, /* ANEG[1] */
1642 GPC_ENA_PAUSE = 1<<13, /* Enable Pause (SYM_OR_REM) */
1643 GPC_PHYADDR_4 = 1<<12, /* Bit 4 of Phy Addr */
1644 GPC_PHYADDR_3 = 1<<11, /* Bit 3 of Phy Addr */
1645 GPC_PHYADDR_2 = 1<<10, /* Bit 2 of Phy Addr */
1646 GPC_PHYADDR_1 = 1<<9, /* Bit 1 of Phy Addr */
1647 GPC_PHYADDR_0 = 1<<8, /* Bit 0 of Phy Addr */
1648 /* Bits 7..2: reserved */
1649 GPC_RST_CLR = 1<<1, /* Clear GPHY Reset */
1650 GPC_RST_SET = 1<<0, /* Set GPHY Reset */
1651};
1652
1653/* GMAC_IRQ_SRC 8 bit GMAC Interrupt Source Reg (YUKON only) */
1654/* GMAC_IRQ_MSK 8 bit GMAC Interrupt Mask Reg (YUKON only) */
1655enum {
1656 GM_IS_TX_CO_OV = 1<<5, /* Transmit Counter Overflow IRQ */
1657 GM_IS_RX_CO_OV = 1<<4, /* Receive Counter Overflow IRQ */
1658 GM_IS_TX_FF_UR = 1<<3, /* Transmit FIFO Underrun */
1659 GM_IS_TX_COMPL = 1<<2, /* Frame Transmission Complete */
1660 GM_IS_RX_FF_OR = 1<<1, /* Receive FIFO Overrun */
1661 GM_IS_RX_COMPL = 1<<0, /* Frame Reception Complete */
1662
1663#define GMAC_DEF_MSK GM_IS_TX_FF_UR
1664
1665/* GMAC_LINK_CTRL 16 bit GMAC Link Control Reg (YUKON only) */
1666 /* Bits 15.. 2: reserved */
1667 GMLC_RST_CLR = 1<<1, /* Clear GMAC Link Reset */
1668 GMLC_RST_SET = 1<<0, /* Set GMAC Link Reset */
1669
1670
1671/* WOL_CTRL_STAT 16 bit WOL Control/Status Reg */
1672 WOL_CTL_LINK_CHG_OCC = 1<<15,
1673 WOL_CTL_MAGIC_PKT_OCC = 1<<14,
1674 WOL_CTL_PATTERN_OCC = 1<<13,
1675 WOL_CTL_CLEAR_RESULT = 1<<12,
1676 WOL_CTL_ENA_PME_ON_LINK_CHG = 1<<11,
1677 WOL_CTL_DIS_PME_ON_LINK_CHG = 1<<10,
1678 WOL_CTL_ENA_PME_ON_MAGIC_PKT = 1<<9,
1679 WOL_CTL_DIS_PME_ON_MAGIC_PKT = 1<<8,
1680 WOL_CTL_ENA_PME_ON_PATTERN = 1<<7,
1681 WOL_CTL_DIS_PME_ON_PATTERN = 1<<6,
1682 WOL_CTL_ENA_LINK_CHG_UNIT = 1<<5,
1683 WOL_CTL_DIS_LINK_CHG_UNIT = 1<<4,
1684 WOL_CTL_ENA_MAGIC_PKT_UNIT = 1<<3,
1685 WOL_CTL_DIS_MAGIC_PKT_UNIT = 1<<2,
1686 WOL_CTL_ENA_PATTERN_UNIT = 1<<1,
1687 WOL_CTL_DIS_PATTERN_UNIT = 1<<0,
1688};
1689
1690#define WOL_CTL_DEFAULT \
1691 (WOL_CTL_DIS_PME_ON_LINK_CHG | \
1692 WOL_CTL_DIS_PME_ON_PATTERN | \
1693 WOL_CTL_DIS_PME_ON_MAGIC_PKT | \
1694 WOL_CTL_DIS_LINK_CHG_UNIT | \
1695 WOL_CTL_DIS_PATTERN_UNIT | \
1696 WOL_CTL_DIS_MAGIC_PKT_UNIT)
1697
1698/* WOL_MATCH_CTL 8 bit WOL Match Control Reg */
1699#define WOL_CTL_PATT_ENA(x) (1 << (x))
1700
1701
1702/* Control flags */
1703enum {
1704 UDPTCP = 1<<0,
1705 CALSUM = 1<<1,
1706 WR_SUM = 1<<2,
1707 INIT_SUM= 1<<3,
1708 LOCK_SUM= 1<<4,
1709 INS_VLAN= 1<<5,
1710 FRC_STAT= 1<<6,
1711 EOP = 1<<7,
1712};
1713
1714enum {
1715 HW_OWNER = 1<<7,
1716 OP_TCPWRITE = 0x11,
1717 OP_TCPSTART = 0x12,
1718 OP_TCPINIT = 0x14,
1719 OP_TCPLCK = 0x18,
1720 OP_TCPCHKSUM = OP_TCPSTART,
1721 OP_TCPIS = OP_TCPINIT | OP_TCPSTART,
1722 OP_TCPLW = OP_TCPLCK | OP_TCPWRITE,
1723 OP_TCPLSW = OP_TCPLCK | OP_TCPSTART | OP_TCPWRITE,
1724 OP_TCPLISW = OP_TCPLCK | OP_TCPINIT | OP_TCPSTART | OP_TCPWRITE,
1725
1726 OP_ADDR64 = 0x21,
1727 OP_VLAN = 0x22,
1728 OP_ADDR64VLAN = OP_ADDR64 | OP_VLAN,
1729 OP_LRGLEN = 0x24,
1730 OP_LRGLENVLAN = OP_LRGLEN | OP_VLAN,
1731 OP_BUFFER = 0x40,
1732 OP_PACKET = 0x41,
1733 OP_LARGESEND = 0x43,
1734
1735/* YUKON-2 STATUS opcodes defines */
1736 OP_RXSTAT = 0x60,
1737 OP_RXTIMESTAMP = 0x61,
1738 OP_RXVLAN = 0x62,
1739 OP_RXCHKS = 0x64,
1740 OP_RXCHKSVLAN = OP_RXCHKS | OP_RXVLAN,
1741 OP_RXTIMEVLAN = OP_RXTIMESTAMP | OP_RXVLAN,
1742 OP_RSS_HASH = 0x65,
1743 OP_TXINDEXLE = 0x68,
1744};
1745
1746/* Yukon 2 hardware interface
1747 * Not tested on big endian
1748 */
1749struct sky2_tx_le {
1750 union {
1751 __le32 addr;
1752 struct {
1753 __le16 offset;
1754 __le16 start;
1755 } csum __attribute((packed));
1756 struct {
1757 __le16 size;
1758 __le16 rsvd;
1759 } tso __attribute((packed));
1760 } tx;
1761 __le16 length; /* also vlan tag or checksum start */
1762 u8 ctrl;
1763 u8 opcode;
1764} __attribute((packed));
1765
1766struct sky2_rx_le {
1767 __le32 addr;
1768 __le16 length;
1769 u8 ctrl;
1770 u8 opcode;
1771} __attribute((packed));;
1772
1773struct sky2_status_le {
1774 __le32 status; /* also checksum */
1775 __le16 length; /* also vlan tag */
1776 u8 link;
1777 u8 opcode;
1778} __attribute((packed));
1779
1780struct tx_ring_info {
1781 struct sk_buff *skb;
1782 DECLARE_PCI_UNMAP_ADDR(mapaddr);
1783 u16 idx;
1784};
1785
1786struct ring_info {
1787 struct sk_buff *skb;
1788 dma_addr_t mapaddr;
1789};
1790
1791struct sky2_port {
1792 struct sky2_hw *hw;
1793 struct net_device *netdev;
1794 unsigned port;
1795 u32 msg_enable;
1796
1797 spinlock_t tx_lock ____cacheline_aligned_in_smp;
1798 struct tx_ring_info *tx_ring;
1799 struct sky2_tx_le *tx_le;
1800 u16 tx_cons; /* next le to check */
1801 u16 tx_prod; /* next le to use */
1802 u32 tx_addr64;
1803 u16 tx_pending;
1804 u16 tx_last_put;
1805 u16 tx_last_mss;
1806
1807 struct ring_info *rx_ring ____cacheline_aligned_in_smp;
1808 struct sky2_rx_le *rx_le;
1809 u32 rx_addr64;
1810 u16 rx_next; /* next re to check */
1811 u16 rx_put; /* next le index to use */
1812 u16 rx_pending;
1813 u16 rx_last_put;
1814 u16 rx_bufsize;
1815#ifdef SKY2_VLAN_TAG_USED
1816 u16 rx_tag;
1817 struct vlan_group *vlgrp;
1818#endif
1819
1820 dma_addr_t rx_le_map;
1821 dma_addr_t tx_le_map;
1822 u32 advertising; /* ADVERTISED_ bits */
1823 u16 speed; /* SPEED_1000, SPEED_100, ... */
1824 u8 autoneg; /* AUTONEG_ENABLE, AUTONEG_DISABLE */
1825 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */
1826 u8 rx_pause;
1827 u8 tx_pause;
1828 u8 rx_csum;
1829 u8 wol;
1830
1831 struct net_device_stats net_stats;
1832
1833 struct work_struct phy_task;
1834 struct semaphore phy_sema;
1835};
1836
1837struct sky2_hw {
1838 void __iomem *regs;
1839 struct pci_dev *pdev;
1840 u32 intr_mask;
1841 struct net_device *dev[2];
1842
1843 int pm_cap;
1844 u8 chip_id;
1845 u8 chip_rev;
1846 u8 copper;
1847 u8 ports;
1848
1849 struct sky2_status_le *st_le;
1850 u32 st_idx;
1851 dma_addr_t st_dma;
1852};
1853
1854/* Register accessor for memory mapped device */
1855static inline u32 sky2_read32(const struct sky2_hw *hw, unsigned reg)
1856{
1857 return readl(hw->regs + reg);
1858}
1859
1860static inline u16 sky2_read16(const struct sky2_hw *hw, unsigned reg)
1861{
1862 return readw(hw->regs + reg);
1863}
1864
1865static inline u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
1866{
1867 return readb(hw->regs + reg);
1868}
1869
1870/* This should probably go away, bus based tweeks suck */
1871static inline int is_pciex(const struct sky2_hw *hw)
1872{
1873 u32 status;
1874 pci_read_config_dword(hw->pdev, PCI_DEV_STATUS, &status);
1875 return (status & PCI_OS_PCI_X) == 0;
1876}
1877
1878static inline void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
1879{
1880 writel(val, hw->regs + reg);
1881}
1882
1883static inline void sky2_write16(const struct sky2_hw *hw, unsigned reg, u16 val)
1884{
1885 writew(val, hw->regs + reg);
1886}
1887
1888static inline void sky2_write8(const struct sky2_hw *hw, unsigned reg, u8 val)
1889{
1890 writeb(val, hw->regs + reg);
1891}
1892
1893/* Yukon PHY related registers */
1894#define SK_GMAC_REG(port,reg) \
1895 (BASE_GMAC_1 + (port) * (BASE_GMAC_2-BASE_GMAC_1) + (reg))
1896#define GM_PHY_RETRIES 100
1897
1898static inline u16 gma_read16(const struct sky2_hw *hw, unsigned port, unsigned reg)
1899{
1900 return sky2_read16(hw, SK_GMAC_REG(port,reg));
1901}
1902
1903static inline u32 gma_read32(struct sky2_hw *hw, unsigned port, unsigned reg)
1904{
1905 unsigned base = SK_GMAC_REG(port, reg);
1906 return (u32) sky2_read16(hw, base)
1907 | (u32) sky2_read16(hw, base+4) << 16;
1908}
1909
1910static inline void gma_write16(const struct sky2_hw *hw, unsigned port, int r, u16 v)
1911{
1912 sky2_write16(hw, SK_GMAC_REG(port,r), v);
1913}
1914
1915static inline void gma_set_addr(struct sky2_hw *hw, unsigned port, unsigned reg,
1916 const u8 *addr)
1917{
1918 gma_write16(hw, port, reg, (u16) addr[0] | ((u16) addr[1] << 8));
1919 gma_write16(hw, port, reg+4,(u16) addr[2] | ((u16) addr[3] << 8));
1920 gma_write16(hw, port, reg+8,(u16) addr[4] | ((u16) addr[5] << 8));
1921}
1922#endif
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index 081717d01374..28ce47a02408 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -2907,7 +2907,7 @@ static int __devinit gem_get_device_address(struct gem *gp)
2907 return 0; 2907 return 0;
2908} 2908}
2909 2909
2910static void __devexit gem_remove_one(struct pci_dev *pdev) 2910static void gem_remove_one(struct pci_dev *pdev)
2911{ 2911{
2912 struct net_device *dev = pci_get_drvdata(pdev); 2912 struct net_device *dev = pci_get_drvdata(pdev);
2913 2913
@@ -3181,7 +3181,7 @@ static struct pci_driver gem_driver = {
3181 .name = GEM_MODULE_NAME, 3181 .name = GEM_MODULE_NAME,
3182 .id_table = gem_pci_tbl, 3182 .id_table = gem_pci_tbl,
3183 .probe = gem_init_one, 3183 .probe = gem_init_one,
3184 .remove = __devexit_p(gem_remove_one), 3184 .remove = gem_remove_one,
3185#ifdef CONFIG_PM 3185#ifdef CONFIG_PM
3186 .suspend = gem_suspend, 3186 .suspend = gem_suspend,
3187 .resume = gem_resume, 3187 .resume = gem_resume,
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 1828a6bf8458..eb86b059809b 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -24,6 +24,7 @@
24#include <linux/compiler.h> 24#include <linux/compiler.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/in.h>
27#include <linux/init.h> 28#include <linux/init.h>
28#include <linux/ioport.h> 29#include <linux/ioport.h>
29#include <linux/pci.h> 30#include <linux/pci.h>
@@ -68,8 +69,8 @@
68 69
69#define DRV_MODULE_NAME "tg3" 70#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 71#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.43" 72#define DRV_MODULE_VERSION "3.47"
72#define DRV_MODULE_RELDATE "Oct 24, 2005" 73#define DRV_MODULE_RELDATE "Dec 28, 2005"
73 74
74#define TG3_DEF_MAC_MODE 0 75#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 76#define TG3_DEF_RX_MODE 0
@@ -341,6 +342,16 @@ static struct {
341 { "interrupt test (offline)" }, 342 { "interrupt test (offline)" },
342}; 343};
343 344
345static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
346{
347 writel(val, tp->regs + off);
348}
349
350static u32 tg3_read32(struct tg3 *tp, u32 off)
351{
352 return (readl(tp->regs + off));
353}
354
344static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val) 355static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val)
345{ 356{
346 unsigned long flags; 357 unsigned long flags;
@@ -411,13 +422,29 @@ static u32 tg3_read_indirect_mbox(struct tg3 *tp, u32 off)
411 return val; 422 return val;
412} 423}
413 424
414static void _tw32_flush(struct tg3 *tp, u32 off, u32 val) 425/* usec_wait specifies the wait time in usec when writing to certain registers
426 * where it is unsafe to read back the register without some delay.
427 * GRC_LOCAL_CTRL is one example if the GPIOs are toggled to switch power.
428 * TG3PCI_CLOCK_CTRL is another example if the clock frequencies are changed.
429 */
430static void _tw32_flush(struct tg3 *tp, u32 off, u32 val, u32 usec_wait)
415{ 431{
416 tp->write32(tp, off, val); 432 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) ||
417 if (!(tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) && 433 (tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
418 !(tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) && 434 /* Non-posted methods */
419 !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)) 435 tp->write32(tp, off, val);
420 tp->read32(tp, off); /* flush */ 436 else {
437 /* Posted method */
438 tg3_write32(tp, off, val);
439 if (usec_wait)
440 udelay(usec_wait);
441 tp->read32(tp, off);
442 }
443 /* Wait again after the read for the posted method to guarantee that
444 * the wait time is met.
445 */
446 if (usec_wait)
447 udelay(usec_wait);
421} 448}
422 449
423static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val) 450static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
@@ -438,16 +465,6 @@ static void tg3_write32_tx_mbox(struct tg3 *tp, u32 off, u32 val)
438 readl(mbox); 465 readl(mbox);
439} 466}
440 467
441static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
442{
443 writel(val, tp->regs + off);
444}
445
446static u32 tg3_read32(struct tg3 *tp, u32 off)
447{
448 return (readl(tp->regs + off));
449}
450
451#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val) 468#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val)
452#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val)) 469#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val))
453#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val) 470#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val)
@@ -455,7 +472,8 @@ static u32 tg3_read32(struct tg3 *tp, u32 off)
455#define tr32_mailbox(reg) tp->read32_mbox(tp, reg) 472#define tr32_mailbox(reg) tp->read32_mbox(tp, reg)
456 473
457#define tw32(reg,val) tp->write32(tp, reg, val) 474#define tw32(reg,val) tp->write32(tp, reg, val)
458#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val)) 475#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val), 0)
476#define tw32_wait_f(reg,val,us) _tw32_flush(tp,(reg),(val), (us))
459#define tr32(reg) tp->read32(tp, reg) 477#define tr32(reg) tp->read32(tp, reg)
460 478
461static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val) 479static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
@@ -595,21 +613,19 @@ static void tg3_switch_clocks(struct tg3 *tp)
595 613
596 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { 614 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
597 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) { 615 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) {
598 tw32_f(TG3PCI_CLOCK_CTRL, 616 tw32_wait_f(TG3PCI_CLOCK_CTRL,
599 clock_ctrl | CLOCK_CTRL_625_CORE); 617 clock_ctrl | CLOCK_CTRL_625_CORE, 40);
600 udelay(40);
601 } 618 }
602 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) { 619 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
603 tw32_f(TG3PCI_CLOCK_CTRL, 620 tw32_wait_f(TG3PCI_CLOCK_CTRL,
604 clock_ctrl | 621 clock_ctrl |
605 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK)); 622 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK),
606 udelay(40); 623 40);
607 tw32_f(TG3PCI_CLOCK_CTRL, 624 tw32_wait_f(TG3PCI_CLOCK_CTRL,
608 clock_ctrl | (CLOCK_CTRL_ALTCLK)); 625 clock_ctrl | (CLOCK_CTRL_ALTCLK),
609 udelay(40); 626 40);
610 } 627 }
611 tw32_f(TG3PCI_CLOCK_CTRL, clock_ctrl); 628 tw32_wait_f(TG3PCI_CLOCK_CTRL, clock_ctrl, 40);
612 udelay(40);
613} 629}
614 630
615#define PHY_BUSY_LOOPS 5000 631#define PHY_BUSY_LOOPS 5000
@@ -1017,37 +1033,50 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1017 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0) 1033 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
1018 return; 1034 return;
1019 1035
1020 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 1036 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
1021 tp_peer = pci_get_drvdata(tp->pdev_peer); 1037 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714)) {
1022 if (!tp_peer) 1038 struct net_device *dev_peer;
1039
1040 dev_peer = pci_get_drvdata(tp->pdev_peer);
1041 if (!dev_peer)
1023 BUG(); 1042 BUG();
1043 tp_peer = netdev_priv(dev_peer);
1024 } 1044 }
1025 1045
1026
1027 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || 1046 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1028 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0) { 1047 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 ||
1048 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1049 (tp_peer->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) {
1029 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 1050 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
1030 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) { 1051 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
1031 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1052 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1032 (GRC_LCLCTRL_GPIO_OE0 | 1053 (GRC_LCLCTRL_GPIO_OE0 |
1033 GRC_LCLCTRL_GPIO_OE1 | 1054 GRC_LCLCTRL_GPIO_OE1 |
1034 GRC_LCLCTRL_GPIO_OE2 | 1055 GRC_LCLCTRL_GPIO_OE2 |
1035 GRC_LCLCTRL_GPIO_OUTPUT0 | 1056 GRC_LCLCTRL_GPIO_OUTPUT0 |
1036 GRC_LCLCTRL_GPIO_OUTPUT1)); 1057 GRC_LCLCTRL_GPIO_OUTPUT1),
1037 udelay(100); 1058 100);
1038 } else { 1059 } else {
1039 u32 no_gpio2; 1060 u32 no_gpio2;
1040 u32 grc_local_ctrl; 1061 u32 grc_local_ctrl = 0;
1041 1062
1042 if (tp_peer != tp && 1063 if (tp_peer != tp &&
1043 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1064 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1044 return; 1065 return;
1045 1066
1067 /* Workaround to prevent overdrawing Amps. */
1068 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
1069 ASIC_REV_5714) {
1070 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
1071 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1072 grc_local_ctrl, 100);
1073 }
1074
1046 /* On 5753 and variants, GPIO2 cannot be used. */ 1075 /* On 5753 and variants, GPIO2 cannot be used. */
1047 no_gpio2 = tp->nic_sram_data_cfg & 1076 no_gpio2 = tp->nic_sram_data_cfg &
1048 NIC_SRAM_DATA_CFG_NO_GPIO2; 1077 NIC_SRAM_DATA_CFG_NO_GPIO2;
1049 1078
1050 grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 | 1079 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE0 |
1051 GRC_LCLCTRL_GPIO_OE1 | 1080 GRC_LCLCTRL_GPIO_OE1 |
1052 GRC_LCLCTRL_GPIO_OE2 | 1081 GRC_LCLCTRL_GPIO_OE2 |
1053 GRC_LCLCTRL_GPIO_OUTPUT1 | 1082 GRC_LCLCTRL_GPIO_OUTPUT1 |
@@ -1056,21 +1085,18 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1056 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 | 1085 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 |
1057 GRC_LCLCTRL_GPIO_OUTPUT2); 1086 GRC_LCLCTRL_GPIO_OUTPUT2);
1058 } 1087 }
1059 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1088 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1060 grc_local_ctrl); 1089 grc_local_ctrl, 100);
1061 udelay(100);
1062 1090
1063 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0; 1091 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0;
1064 1092
1065 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1093 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1066 grc_local_ctrl); 1094 grc_local_ctrl, 100);
1067 udelay(100);
1068 1095
1069 if (!no_gpio2) { 1096 if (!no_gpio2) {
1070 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2; 1097 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2;
1071 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1098 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1072 grc_local_ctrl); 1099 grc_local_ctrl, 100);
1073 udelay(100);
1074 } 1100 }
1075 } 1101 }
1076 } else { 1102 } else {
@@ -1080,19 +1106,16 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1080 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1106 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1081 return; 1107 return;
1082 1108
1083 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1109 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1084 (GRC_LCLCTRL_GPIO_OE1 | 1110 (GRC_LCLCTRL_GPIO_OE1 |
1085 GRC_LCLCTRL_GPIO_OUTPUT1)); 1111 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1086 udelay(100);
1087 1112
1088 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1113 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1089 (GRC_LCLCTRL_GPIO_OE1)); 1114 GRC_LCLCTRL_GPIO_OE1, 100);
1090 udelay(100);
1091 1115
1092 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1116 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1093 (GRC_LCLCTRL_GPIO_OE1 | 1117 (GRC_LCLCTRL_GPIO_OE1 |
1094 GRC_LCLCTRL_GPIO_OUTPUT1)); 1118 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1095 udelay(100);
1096 } 1119 }
1097 } 1120 }
1098} 1121}
@@ -1105,6 +1128,8 @@ static int tg3_setup_phy(struct tg3 *, int);
1105 1128
1106static void tg3_write_sig_post_reset(struct tg3 *, int); 1129static void tg3_write_sig_post_reset(struct tg3 *, int);
1107static int tg3_halt_cpu(struct tg3 *, u32); 1130static int tg3_halt_cpu(struct tg3 *, u32);
1131static int tg3_nvram_lock(struct tg3 *);
1132static void tg3_nvram_unlock(struct tg3 *);
1108 1133
1109static int tg3_set_power_state(struct tg3 *tp, int state) 1134static int tg3_set_power_state(struct tg3 *tp, int state)
1110{ 1135{
@@ -1133,10 +1158,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1133 udelay(100); /* Delay after power state change */ 1158 udelay(100); /* Delay after power state change */
1134 1159
1135 /* Switch out of Vaux if it is not a LOM */ 1160 /* Switch out of Vaux if it is not a LOM */
1136 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) { 1161 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
1137 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 1162 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
1138 udelay(100);
1139 }
1140 1163
1141 return 0; 1164 return 0;
1142 1165
@@ -1179,6 +1202,21 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1179 tg3_setup_phy(tp, 0); 1202 tg3_setup_phy(tp, 0);
1180 } 1203 }
1181 1204
1205 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1206 int i;
1207 u32 val;
1208
1209 for (i = 0; i < 200; i++) {
1210 tg3_read_mem(tp, NIC_SRAM_FW_ASF_STATUS_MBOX, &val);
1211 if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
1212 break;
1213 msleep(1);
1214 }
1215 }
1216 tg3_write_mem(tp, NIC_SRAM_WOL_MBOX, WOL_SIGNATURE |
1217 WOL_DRV_STATE_SHUTDOWN |
1218 WOL_DRV_WOL | WOL_SET_MAGIC_PKT);
1219
1182 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps); 1220 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps);
1183 1221
1184 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) { 1222 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) {
@@ -1220,10 +1258,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1220 base_val |= (CLOCK_CTRL_RXCLK_DISABLE | 1258 base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
1221 CLOCK_CTRL_TXCLK_DISABLE); 1259 CLOCK_CTRL_TXCLK_DISABLE);
1222 1260
1223 tw32_f(TG3PCI_CLOCK_CTRL, base_val | 1261 tw32_wait_f(TG3PCI_CLOCK_CTRL, base_val | CLOCK_CTRL_ALTCLK |
1224 CLOCK_CTRL_ALTCLK | 1262 CLOCK_CTRL_PWRDOWN_PLL133, 40);
1225 CLOCK_CTRL_PWRDOWN_PLL133);
1226 udelay(40);
1227 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) { 1263 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) {
1228 /* do nothing */ 1264 /* do nothing */
1229 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 1265 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
@@ -1244,11 +1280,11 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1244 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE; 1280 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
1245 } 1281 }
1246 1282
1247 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1); 1283 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1,
1248 udelay(40); 1284 40);
1249 1285
1250 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2); 1286 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2,
1251 udelay(40); 1287 40);
1252 1288
1253 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 1289 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
1254 u32 newbits3; 1290 u32 newbits3;
@@ -1262,9 +1298,20 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1262 newbits3 = CLOCK_CTRL_44MHZ_CORE; 1298 newbits3 = CLOCK_CTRL_44MHZ_CORE;
1263 } 1299 }
1264 1300
1265 tw32_f(TG3PCI_CLOCK_CTRL, 1301 tw32_wait_f(TG3PCI_CLOCK_CTRL,
1266 tp->pci_clock_ctrl | newbits3); 1302 tp->pci_clock_ctrl | newbits3, 40);
1267 udelay(40); 1303 }
1304 }
1305
1306 if (!(tp->tg3_flags & TG3_FLAG_WOL_ENABLE) &&
1307 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1308 /* Turn off the PHY */
1309 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) {
1310 tg3_writephy(tp, MII_TG3_EXT_CTRL,
1311 MII_TG3_EXT_CTRL_FORCE_LED_OFF);
1312 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2);
1313 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700)
1314 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN);
1268 } 1315 }
1269 } 1316 }
1270 1317
@@ -1277,8 +1324,12 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1277 1324
1278 val &= ~((1 << 16) | (1 << 4) | (1 << 2) | (1 << 1) | 1); 1325 val &= ~((1 << 16) | (1 << 4) | (1 << 2) | (1 << 1) | 1);
1279 tw32(0x7d00, val); 1326 tw32(0x7d00, val);
1280 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) 1327 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1328 tg3_nvram_lock(tp);
1281 tg3_halt_cpu(tp, RX_CPU_BASE); 1329 tg3_halt_cpu(tp, RX_CPU_BASE);
1330 tw32_f(NVRAM_SWARB, SWARB_REQ_CLR0);
1331 tg3_nvram_unlock(tp);
1332 }
1282 } 1333 }
1283 1334
1284 /* Finally, set the new power state. */ 1335 /* Finally, set the new power state. */
@@ -1812,7 +1863,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
1812 } 1863 }
1813 } 1864 }
1814relink: 1865relink:
1815 if (current_link_up == 0) { 1866 if (current_link_up == 0 || tp->link_config.phy_is_low_power) {
1816 u32 tmp; 1867 u32 tmp;
1817 1868
1818 tg3_phy_copper_begin(tp); 1869 tg3_phy_copper_begin(tp);
@@ -3565,12 +3616,15 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3565 if (!spin_trylock(&tp->tx_lock)) 3616 if (!spin_trylock(&tp->tx_lock))
3566 return NETDEV_TX_LOCKED; 3617 return NETDEV_TX_LOCKED;
3567 3618
3568 /* This is a hard error, log it. */
3569 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { 3619 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) {
3570 netif_stop_queue(dev); 3620 if (!netif_queue_stopped(dev)) {
3621 netif_stop_queue(dev);
3622
3623 /* This is a hard error, log it. */
3624 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
3625 "queue awake!\n", dev->name);
3626 }
3571 spin_unlock(&tp->tx_lock); 3627 spin_unlock(&tp->tx_lock);
3572 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n",
3573 dev->name);
3574 return NETDEV_TX_BUSY; 3628 return NETDEV_TX_BUSY;
3575 } 3629 }
3576 3630
@@ -3597,7 +3651,7 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3597 TXD_FLAG_CPU_POST_DMA); 3651 TXD_FLAG_CPU_POST_DMA);
3598 3652
3599 skb->nh.iph->check = 0; 3653 skb->nh.iph->check = 0;
3600 skb->nh.iph->tot_len = ntohs(mss + ip_tcp_len + tcp_opt_len); 3654 skb->nh.iph->tot_len = htons(mss + ip_tcp_len + tcp_opt_len);
3601 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) { 3655 if (tp->tg3_flags2 & TG3_FLG2_HW_TSO) {
3602 skb->h.th->check = 0; 3656 skb->h.th->check = 0;
3603 base_flags &= ~TXD_FLAG_TCPUDP_CSUM; 3657 base_flags &= ~TXD_FLAG_TCPUDP_CSUM;
@@ -7098,8 +7152,13 @@ do { p = (u32 *)(orig_p + (reg)); \
7098 GET_REG32_LOOP(BUFMGR_MODE, 0x58); 7152 GET_REG32_LOOP(BUFMGR_MODE, 0x58);
7099 GET_REG32_LOOP(RDMAC_MODE, 0x08); 7153 GET_REG32_LOOP(RDMAC_MODE, 0x08);
7100 GET_REG32_LOOP(WDMAC_MODE, 0x08); 7154 GET_REG32_LOOP(WDMAC_MODE, 0x08);
7101 GET_REG32_LOOP(RX_CPU_BASE, 0x280); 7155 GET_REG32_1(RX_CPU_MODE);
7102 GET_REG32_LOOP(TX_CPU_BASE, 0x280); 7156 GET_REG32_1(RX_CPU_STATE);
7157 GET_REG32_1(RX_CPU_PGMCTR);
7158 GET_REG32_1(RX_CPU_HWBKPT);
7159 GET_REG32_1(TX_CPU_MODE);
7160 GET_REG32_1(TX_CPU_STATE);
7161 GET_REG32_1(TX_CPU_PGMCTR);
7103 GET_REG32_LOOP(GRCMBOX_INTERRUPT_0, 0x110); 7162 GET_REG32_LOOP(GRCMBOX_INTERRUPT_0, 0x110);
7104 GET_REG32_LOOP(FTQ_RESET, 0x120); 7163 GET_REG32_LOOP(FTQ_RESET, 0x120);
7105 GET_REG32_LOOP(MSGINT_MODE, 0x0c); 7164 GET_REG32_LOOP(MSGINT_MODE, 0x0c);
@@ -7922,13 +7981,12 @@ static int tg3_test_memory(struct tg3 *tp)
7922 u32 offset; 7981 u32 offset;
7923 u32 len; 7982 u32 len;
7924 } mem_tbl_570x[] = { 7983 } mem_tbl_570x[] = {
7925 { 0x00000000, 0x01000}, 7984 { 0x00000000, 0x00b50},
7926 { 0x00002000, 0x1c000}, 7985 { 0x00002000, 0x1c000},
7927 { 0xffffffff, 0x00000} 7986 { 0xffffffff, 0x00000}
7928 }, mem_tbl_5705[] = { 7987 }, mem_tbl_5705[] = {
7929 { 0x00000100, 0x0000c}, 7988 { 0x00000100, 0x0000c},
7930 { 0x00000200, 0x00008}, 7989 { 0x00000200, 0x00008},
7931 { 0x00000b50, 0x00400},
7932 { 0x00004000, 0x00800}, 7990 { 0x00004000, 0x00800},
7933 { 0x00006000, 0x01000}, 7991 { 0x00006000, 0x01000},
7934 { 0x00008000, 0x02000}, 7992 { 0x00008000, 0x02000},
@@ -8530,6 +8588,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
8530 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) { 8588 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
8531 tp->tg3_flags |= TG3_FLAG_NVRAM; 8589 tp->tg3_flags |= TG3_FLAG_NVRAM;
8532 8590
8591 tg3_nvram_lock(tp);
8533 tg3_enable_nvram_access(tp); 8592 tg3_enable_nvram_access(tp);
8534 8593
8535 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 8594 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
@@ -8540,6 +8599,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
8540 tg3_get_nvram_size(tp); 8599 tg3_get_nvram_size(tp);
8541 8600
8542 tg3_disable_nvram_access(tp); 8601 tg3_disable_nvram_access(tp);
8602 tg3_nvram_unlock(tp);
8543 8603
8544 } else { 8604 } else {
8545 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED); 8605 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
@@ -8637,10 +8697,10 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
8637 if (ret == 0) 8697 if (ret == 0)
8638 *val = swab32(tr32(NVRAM_RDDATA)); 8698 *val = swab32(tr32(NVRAM_RDDATA));
8639 8699
8640 tg3_nvram_unlock(tp);
8641
8642 tg3_disable_nvram_access(tp); 8700 tg3_disable_nvram_access(tp);
8643 8701
8702 tg3_nvram_unlock(tp);
8703
8644 return ret; 8704 return ret;
8645} 8705}
8646 8706
@@ -8725,6 +8785,10 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
8725 8785
8726 offset = offset + (pagesize - page_off); 8786 offset = offset + (pagesize - page_off);
8727 8787
8788 /* Nvram lock released by tg3_nvram_read() above,
8789 * so need to get it again.
8790 */
8791 tg3_nvram_lock(tp);
8728 tg3_enable_nvram_access(tp); 8792 tg3_enable_nvram_access(tp);
8729 8793
8730 /* 8794 /*
@@ -10423,7 +10487,7 @@ static char * __devinit tg3_bus_string(struct tg3 *tp, char *str)
10423 return str; 10487 return str;
10424} 10488}
10425 10489
10426static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp) 10490static struct pci_dev * __devinit tg3_find_peer(struct tg3 *tp)
10427{ 10491{
10428 struct pci_dev *peer; 10492 struct pci_dev *peer;
10429 unsigned int func, devnr = tp->pdev->devfn & ~7; 10493 unsigned int func, devnr = tp->pdev->devfn & ~7;
@@ -10434,8 +10498,13 @@ static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
10434 break; 10498 break;
10435 pci_dev_put(peer); 10499 pci_dev_put(peer);
10436 } 10500 }
10437 if (!peer || peer == tp->pdev) 10501 /* 5704 can be configured in single-port mode, set peer to
10438 BUG(); 10502 * tp->pdev in that case.
10503 */
10504 if (!peer) {
10505 peer = tp->pdev;
10506 return peer;
10507 }
10439 10508
10440 /* 10509 /*
10441 * We don't need to keep the refcount elevated; there's no way 10510 * We don't need to keep the refcount elevated; there's no way
@@ -10671,8 +10740,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10671 tp->rx_pending = 63; 10740 tp->rx_pending = 63;
10672 } 10741 }
10673 10742
10674 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) 10743 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10675 tp->pdev_peer = tg3_find_5704_peer(tp); 10744 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
10745 tp->pdev_peer = tg3_find_peer(tp);
10676 10746
10677 err = tg3_get_device_address(tp); 10747 err = tg3_get_device_address(tp);
10678 if (err) { 10748 if (err) {
@@ -10817,12 +10887,14 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
10817 10887
10818 tg3_full_lock(tp, 0); 10888 tg3_full_lock(tp, 0);
10819 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 10889 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
10890 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
10820 tg3_full_unlock(tp); 10891 tg3_full_unlock(tp);
10821 10892
10822 err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); 10893 err = tg3_set_power_state(tp, pci_choose_state(pdev, state));
10823 if (err) { 10894 if (err) {
10824 tg3_full_lock(tp, 0); 10895 tg3_full_lock(tp, 0);
10825 10896
10897 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
10826 tg3_init_hw(tp); 10898 tg3_init_hw(tp);
10827 10899
10828 tp->timer.expires = jiffies + tp->timer_offset; 10900 tp->timer.expires = jiffies + tp->timer_offset;
@@ -10856,6 +10928,7 @@ static int tg3_resume(struct pci_dev *pdev)
10856 10928
10857 tg3_full_lock(tp, 0); 10929 tg3_full_lock(tp, 0);
10858 10930
10931 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
10859 tg3_init_hw(tp); 10932 tg3_init_hw(tp);
10860 10933
10861 tp->timer.expires = jiffies + tp->timer_offset; 10934 tp->timer.expires = jiffies + tp->timer_offset;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index fb7e2a5f4a08..890e1635996b 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -1124,7 +1124,14 @@
1124/* 0x280 --> 0x400 unused */ 1124/* 0x280 --> 0x400 unused */
1125 1125
1126#define RX_CPU_BASE 0x00005000 1126#define RX_CPU_BASE 0x00005000
1127#define RX_CPU_MODE 0x00005000
1128#define RX_CPU_STATE 0x00005004
1129#define RX_CPU_PGMCTR 0x0000501c
1130#define RX_CPU_HWBKPT 0x00005034
1127#define TX_CPU_BASE 0x00005400 1131#define TX_CPU_BASE 0x00005400
1132#define TX_CPU_MODE 0x00005400
1133#define TX_CPU_STATE 0x00005404
1134#define TX_CPU_PGMCTR 0x0000541c
1128 1135
1129/* Mailboxes */ 1136/* Mailboxes */
1130#define GRCMBOX_INTERRUPT_0 0x00005800 /* 64-bit */ 1137#define GRCMBOX_INTERRUPT_0 0x00005800 /* 64-bit */
@@ -1529,6 +1536,12 @@
1529#define NIC_SRAM_MAC_ADDR_HIGH_MBOX 0x00000c14 1536#define NIC_SRAM_MAC_ADDR_HIGH_MBOX 0x00000c14
1530#define NIC_SRAM_MAC_ADDR_LOW_MBOX 0x00000c18 1537#define NIC_SRAM_MAC_ADDR_LOW_MBOX 0x00000c18
1531 1538
1539#define NIC_SRAM_WOL_MBOX 0x00000d30
1540#define WOL_SIGNATURE 0x474c0000
1541#define WOL_DRV_STATE_SHUTDOWN 0x00000001
1542#define WOL_DRV_WOL 0x00000002
1543#define WOL_SET_MAGIC_PKT 0x00000004
1544
1532#define NIC_SRAM_DATA_CFG_2 0x00000d38 1545#define NIC_SRAM_DATA_CFG_2 0x00000d38
1533 1546
1534#define SHASTA_EXT_LED_MODE_MASK 0x00018000 1547#define SHASTA_EXT_LED_MODE_MASK 0x00018000
@@ -1565,6 +1578,7 @@
1565#define MII_TG3_EXT_CTRL 0x10 /* Extended control register */ 1578#define MII_TG3_EXT_CTRL 0x10 /* Extended control register */
1566#define MII_TG3_EXT_CTRL_FIFO_ELASTIC 0x0001 1579#define MII_TG3_EXT_CTRL_FIFO_ELASTIC 0x0001
1567#define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002 1580#define MII_TG3_EXT_CTRL_LNK3_LED_MODE 0x0002
1581#define MII_TG3_EXT_CTRL_FORCE_LED_OFF 0x0008
1568#define MII_TG3_EXT_CTRL_TBI 0x8000 1582#define MII_TG3_EXT_CTRL_TBI 0x8000
1569 1583
1570#define MII_TG3_EXT_STAT 0x11 /* Extended status register */ 1584#define MII_TG3_EXT_STAT 0x11 /* Extended status register */
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index 942fae0f2130..c2506b56a186 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -2865,11 +2865,11 @@ void TLan_PhyMonitor( struct net_device *dev )
2865 * for this device. 2865 * for this device.
2866 * phy The address of the PHY to be queried. 2866 * phy The address of the PHY to be queried.
2867 * reg The register whose contents are to be 2867 * reg The register whose contents are to be
2868 * retreived. 2868 * retrieved.
2869 * val A pointer to a variable to store the 2869 * val A pointer to a variable to store the
2870 * retrieved value. 2870 * retrieved value.
2871 * 2871 *
2872 * This function uses the TLAN's MII bus to retreive the contents 2872 * This function uses the TLAN's MII bus to retrieve the contents
2873 * of a given register on a PHY. It sends the appropriate info 2873 * of a given register on a PHY. It sends the appropriate info
2874 * and then reads the 16-bit register value from the MII bus via 2874 * and then reads the 16-bit register value from the MII bus via
2875 * the TLAN SIO register. 2875 * the TLAN SIO register.
diff --git a/drivers/net/wan/.gitignore b/drivers/net/wan/.gitignore
new file mode 100644
index 000000000000..dae3ea6bb18c
--- /dev/null
+++ b/drivers/net/wan/.gitignore
@@ -0,0 +1 @@
wanxlfw.inc
diff --git a/drivers/net/wan/lmc/lmc_prot.h b/drivers/net/wan/lmc/lmc_prot.h
deleted file mode 100644
index f3b1df9e2cdb..000000000000
--- a/drivers/net/wan/lmc/lmc_prot.h
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifndef _LMC_PROTO_H_
2#define _LMC_PROTO_H_
3
4void lmc_proto_init(lmc_softc_t * const)
5void lmc_proto_attach(lmc_softc_t *sc const)
6void lmc_proto_detach(lmc_softc *sc const)
7void lmc_proto_reopen(lmc_softc_t *sc const)
8int lmc_proto_ioctl(lmc_softc_t *sc const, struct ifreq *ifr, int cmd)
9void lmc_proto_open(lmc_softc_t *sc const)
10void lmc_proto_close(lmc_softc_t *sc const)
11unsigned short lmc_proto_type(lmc_softc_t *sc const, struct skbuff *skb)
12
13
14#endif
15
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 00e55165b760..24f7967aab67 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -173,7 +173,7 @@ config IPW2100_MONITOR
173 promiscuous mode via the Wireless Tool's Monitor mode. While in this 173 promiscuous mode via the Wireless Tool's Monitor mode. While in this
174 mode, no packets can be sent. 174 mode, no packets can be sent.
175 175
176config IPW_DEBUG 176config IPW2100_DEBUG
177 bool "Enable full debugging output in IPW2100 module." 177 bool "Enable full debugging output in IPW2100 module."
178 depends on IPW2100 178 depends on IPW2100
179 ---help--- 179 ---help---
@@ -192,7 +192,7 @@ config IPW_DEBUG
192 192
193config IPW2200 193config IPW2200
194 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection" 194 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection"
195 depends on IEEE80211 && PCI 195 depends on NET_RADIO && IEEE80211 && PCI
196 select FW_LOADER 196 select FW_LOADER
197 ---help--- 197 ---help---
198 A driver for the Intel PRO/Wireless 2200BG and 2915ABG Network 198 A driver for the Intel PRO/Wireless 2200BG and 2915ABG Network
@@ -217,7 +217,7 @@ config IPW2200
217 say M here and read <file:Documentation/modules.txt>. The module 217 say M here and read <file:Documentation/modules.txt>. The module
218 will be called ipw2200.ko. 218 will be called ipw2200.ko.
219 219
220config IPW_DEBUG 220config IPW2200_DEBUG
221 bool "Enable full debugging output in IPW2200 module." 221 bool "Enable full debugging output in IPW2200 module."
222 depends on IPW2200 222 depends on IPW2200
223 ---help--- 223 ---help---
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 7a92b1cbd6aa..ee866fd6957d 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -4037,7 +4037,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid,
4037 Cmd cmd; 4037 Cmd cmd;
4038 Resp rsp; 4038 Resp rsp;
4039 4039
4040 if (test_bit(FLAG_ENABLED, &ai->flags)) 4040 if (test_bit(FLAG_ENABLED, &ai->flags) && (RID_WEP_TEMP != rid))
4041 printk(KERN_ERR 4041 printk(KERN_ERR
4042 "%s: MAC should be disabled (rid=%04x)\n", 4042 "%s: MAC should be disabled (rid=%04x)\n",
4043 __FUNCTION__, rid); 4043 __FUNCTION__, rid);
@@ -5093,9 +5093,9 @@ static int set_wep_key(struct airo_info *ai, u16 index,
5093 printk(KERN_INFO "Setting key %d\n", index); 5093 printk(KERN_INFO "Setting key %d\n", index);
5094 } 5094 }
5095 5095
5096 disable_MAC(ai, lock); 5096 if (perm) disable_MAC(ai, lock);
5097 writeWepKeyRid(ai, &wkr, perm, lock); 5097 writeWepKeyRid(ai, &wkr, perm, lock);
5098 enable_MAC(ai, &rsp, lock); 5098 if (perm) enable_MAC(ai, &rsp, lock);
5099 return 0; 5099 return 0;
5100} 5100}
5101 5101
@@ -6170,6 +6170,8 @@ static int airo_set_encode(struct net_device *dev,
6170{ 6170{
6171 struct airo_info *local = dev->priv; 6171 struct airo_info *local = dev->priv;
6172 CapabilityRid cap_rid; /* Card capability info */ 6172 CapabilityRid cap_rid; /* Card capability info */
6173 int perm = ( dwrq->flags & IW_ENCODE_TEMP ? 0 : 1 );
6174 u16 currentAuthType = local->config.authType;
6173 6175
6174 /* Is WEP supported ? */ 6176 /* Is WEP supported ? */
6175 readCapabilityRid(local, &cap_rid, 1); 6177 readCapabilityRid(local, &cap_rid, 1);
@@ -6212,7 +6214,7 @@ static int airo_set_encode(struct net_device *dev,
6212 /* Copy the key in the driver */ 6214 /* Copy the key in the driver */
6213 memcpy(key.key, extra, dwrq->length); 6215 memcpy(key.key, extra, dwrq->length);
6214 /* Send the key to the card */ 6216 /* Send the key to the card */
6215 set_wep_key(local, index, key.key, key.len, 1, 1); 6217 set_wep_key(local, index, key.key, key.len, perm, 1);
6216 } 6218 }
6217 /* WE specify that if a valid key is set, encryption 6219 /* WE specify that if a valid key is set, encryption
6218 * should be enabled (user may turn it off later) 6220 * should be enabled (user may turn it off later)
@@ -6220,13 +6222,12 @@ static int airo_set_encode(struct net_device *dev,
6220 if((index == current_index) && (key.len > 0) && 6222 if((index == current_index) && (key.len > 0) &&
6221 (local->config.authType == AUTH_OPEN)) { 6223 (local->config.authType == AUTH_OPEN)) {
6222 local->config.authType = AUTH_ENCRYPT; 6224 local->config.authType = AUTH_ENCRYPT;
6223 set_bit (FLAG_COMMIT, &local->flags);
6224 } 6225 }
6225 } else { 6226 } else {
6226 /* Do we want to just set the transmit key index ? */ 6227 /* Do we want to just set the transmit key index ? */
6227 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 6228 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
6228 if ((index >= 0) && (index < ((cap_rid.softCap & 0x80)?4:1))) { 6229 if ((index >= 0) && (index < ((cap_rid.softCap & 0x80)?4:1))) {
6229 set_wep_key(local, index, NULL, 0, 1, 1); 6230 set_wep_key(local, index, NULL, 0, perm, 1);
6230 } else 6231 } else
6231 /* Don't complain if only change the mode */ 6232 /* Don't complain if only change the mode */
6232 if(!dwrq->flags & IW_ENCODE_MODE) { 6233 if(!dwrq->flags & IW_ENCODE_MODE) {
@@ -6241,7 +6242,7 @@ static int airo_set_encode(struct net_device *dev,
6241 if(dwrq->flags & IW_ENCODE_OPEN) 6242 if(dwrq->flags & IW_ENCODE_OPEN)
6242 local->config.authType = AUTH_ENCRYPT; // Only Wep 6243 local->config.authType = AUTH_ENCRYPT; // Only Wep
6243 /* Commit the changes to flags if needed */ 6244 /* Commit the changes to flags if needed */
6244 if(dwrq->flags & IW_ENCODE_MODE) 6245 if (local->config.authType != currentAuthType)
6245 set_bit (FLAG_COMMIT, &local->flags); 6246 set_bit (FLAG_COMMIT, &local->flags);
6246 return -EINPROGRESS; /* Call commit handler */ 6247 return -EINPROGRESS; /* Call commit handler */
6247} 6248}
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index e328547599dc..a496460ce224 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -82,8 +82,6 @@ MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340 PCMCIA cards");
82 82
83static void airo_config(dev_link_t *link); 83static void airo_config(dev_link_t *link);
84static void airo_release(dev_link_t *link); 84static void airo_release(dev_link_t *link);
85static int airo_event(event_t event, int priority,
86 event_callback_args_t *args);
87 85
88/* 86/*
89 The attach() and detach() entry points are used to create and destroy 87 The attach() and detach() entry points are used to create and destroy
@@ -91,8 +89,7 @@ static int airo_event(event_t event, int priority,
91 needed to manage one actual PCMCIA card. 89 needed to manage one actual PCMCIA card.
92*/ 90*/
93 91
94static dev_link_t *airo_attach(void); 92static void airo_detach(struct pcmcia_device *p_dev);
95static void airo_detach(dev_link_t *);
96 93
97/* 94/*
98 You'll also need to prototype all the functions that will actually 95 You'll also need to prototype all the functions that will actually
@@ -102,14 +99,6 @@ static void airo_detach(dev_link_t *);
102*/ 99*/
103 100
104/* 101/*
105 The dev_info variable is the "key" that is used to match up this
106 device driver with appropriate cards, through the card configuration
107 database.
108*/
109
110static dev_info_t dev_info = "airo_cs";
111
112/*
113 A linked list of "instances" of the aironet device. Each actual 102 A linked list of "instances" of the aironet device. Each actual
114 PCMCIA card corresponds to one device instance, and is described 103 PCMCIA card corresponds to one device instance, and is described
115 by one dev_link_t structure (defined in ds.h). 104 by one dev_link_t structure (defined in ds.h).
@@ -119,15 +108,7 @@ static dev_info_t dev_info = "airo_cs";
119 device numbers are used to derive the corresponding array index. 108 device numbers are used to derive the corresponding array index.
120*/ 109*/
121 110
122static dev_link_t *dev_list = NULL;
123
124/* 111/*
125 A dev_link_t structure has fields for most things that are needed
126 to keep track of a socket, but there will usually be some device
127 specific information that also needs to be kept track of. The
128 'priv' pointer in a dev_link_t structure can be used to point to
129 a device-specific private data structure, like this.
130
131 A driver needs to provide a dev_node_t structure for each device 112 A driver needs to provide a dev_node_t structure for each device
132 on a card. In some cases, there is only one device per card (for 113 on a card. In some cases, there is only one device per card (for
133 example, ethernet cards, modems). In other cases, there may be 114 example, ethernet cards, modems). In other cases, there may be
@@ -160,20 +141,18 @@ typedef struct local_info_t {
160 141
161 ======================================================================*/ 142 ======================================================================*/
162 143
163static dev_link_t *airo_attach(void) 144static int airo_attach(struct pcmcia_device *p_dev)
164{ 145{
165 client_reg_t client_reg;
166 dev_link_t *link; 146 dev_link_t *link;
167 local_info_t *local; 147 local_info_t *local;
168 int ret; 148
169
170 DEBUG(0, "airo_attach()\n"); 149 DEBUG(0, "airo_attach()\n");
171 150
172 /* Initialize the dev_link_t structure */ 151 /* Initialize the dev_link_t structure */
173 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 152 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
174 if (!link) { 153 if (!link) {
175 printk(KERN_ERR "airo_cs: no memory for new device\n"); 154 printk(KERN_ERR "airo_cs: no memory for new device\n");
176 return NULL; 155 return -ENOMEM;
177 } 156 }
178 157
179 /* Interrupt setup */ 158 /* Interrupt setup */
@@ -197,24 +176,17 @@ static dev_link_t *airo_attach(void)
197 if (!local) { 176 if (!local) {
198 printk(KERN_ERR "airo_cs: no memory for new device\n"); 177 printk(KERN_ERR "airo_cs: no memory for new device\n");
199 kfree (link); 178 kfree (link);
200 return NULL; 179 return -ENOMEM;
201 } 180 }
202 link->priv = local; 181 link->priv = local;
203 182
204 /* Register with Card Services */ 183 link->handle = p_dev;
205 link->next = dev_list; 184 p_dev->instance = link;
206 dev_list = link; 185
207 client_reg.dev_info = &dev_info; 186 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
208 client_reg.Version = 0x0210; 187 airo_config(link);
209 client_reg.event_callback_args.client_data = link; 188
210 ret = pcmcia_register_client(&link->handle, &client_reg); 189 return 0;
211 if (ret != 0) {
212 cs_error(link->handle, RegisterClient, ret);
213 airo_detach(link);
214 return NULL;
215 }
216
217 return link;
218} /* airo_attach */ 190} /* airo_attach */
219 191
220/*====================================================================== 192/*======================================================================
@@ -226,37 +198,22 @@ static dev_link_t *airo_attach(void)
226 198
227 ======================================================================*/ 199 ======================================================================*/
228 200
229static void airo_detach(dev_link_t *link) 201static void airo_detach(struct pcmcia_device *p_dev)
230{ 202{
231 dev_link_t **linkp; 203 dev_link_t *link = dev_to_instance(p_dev);
232 204
233 DEBUG(0, "airo_detach(0x%p)\n", link); 205 DEBUG(0, "airo_detach(0x%p)\n", link);
234 206
235 /* Locate device structure */
236 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
237 if (*linkp == link) break;
238 if (*linkp == NULL)
239 return;
240
241 if (link->state & DEV_CONFIG) 207 if (link->state & DEV_CONFIG)
242 airo_release(link); 208 airo_release(link);
243 209
244 if ( ((local_info_t*)link->priv)->eth_dev ) { 210 if ( ((local_info_t*)link->priv)->eth_dev ) {
245 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 ); 211 stop_airo_card( ((local_info_t*)link->priv)->eth_dev, 0 );
246 } 212 }
247 ((local_info_t*)link->priv)->eth_dev = NULL; 213 ((local_info_t*)link->priv)->eth_dev = NULL;
248 214
249 /* Break the link with Card Services */
250 if (link->handle)
251 pcmcia_deregister_client(link->handle);
252
253
254
255 /* Unlink device structure, free pieces */
256 *linkp = link->next;
257 kfree(link->priv); 215 kfree(link->priv);
258 kfree(link); 216 kfree(link);
259
260} /* airo_detach */ 217} /* airo_detach */
261 218
262/*====================================================================== 219/*======================================================================
@@ -492,60 +449,34 @@ static void airo_release(dev_link_t *link)
492 link->state &= ~DEV_CONFIG; 449 link->state &= ~DEV_CONFIG;
493} 450}
494 451
495/*====================================================================== 452static int airo_suspend(struct pcmcia_device *p_dev)
496 453{
497 The card status event handler. Mostly, this schedules other 454 dev_link_t *link = dev_to_instance(p_dev);
498 stuff to run after an event is received. 455 local_info_t *local = link->priv;
499 456
500 When a CARD_REMOVAL event is received, we immediately set a 457 link->state |= DEV_SUSPEND;
501 private flag to block future accesses to this device. All the 458 if (link->state & DEV_CONFIG) {
502 functions that actually access the device should check this flag 459 netif_device_detach(local->eth_dev);
503 to make sure the card is still present. 460 pcmcia_release_configuration(link->handle);
504 461 }
505 ======================================================================*/ 462
463 return 0;
464}
506 465
507static int airo_event(event_t event, int priority, 466static int airo_resume(struct pcmcia_device *p_dev)
508 event_callback_args_t *args)
509{ 467{
510 dev_link_t *link = args->client_data; 468 dev_link_t *link = dev_to_instance(p_dev);
511 local_info_t *local = link->priv; 469 local_info_t *local = link->priv;
512 470
513 DEBUG(1, "airo_event(0x%06x)\n", event); 471 link->state &= ~DEV_SUSPEND;
514 472 if (link->state & DEV_CONFIG) {
515 switch (event) { 473 pcmcia_request_configuration(link->handle, &link->conf);
516 case CS_EVENT_CARD_REMOVAL: 474 reset_airo_card(local->eth_dev);
517 link->state &= ~DEV_PRESENT; 475 netif_device_attach(local->eth_dev);
518 if (link->state & DEV_CONFIG) {
519 netif_device_detach(local->eth_dev);
520 airo_release(link);
521 }
522 break;
523 case CS_EVENT_CARD_INSERTION:
524 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
525 airo_config(link);
526 break;
527 case CS_EVENT_PM_SUSPEND:
528 link->state |= DEV_SUSPEND;
529 /* Fall through... */
530 case CS_EVENT_RESET_PHYSICAL:
531 if (link->state & DEV_CONFIG) {
532 netif_device_detach(local->eth_dev);
533 pcmcia_release_configuration(link->handle);
534 }
535 break;
536 case CS_EVENT_PM_RESUME:
537 link->state &= ~DEV_SUSPEND;
538 /* Fall through... */
539 case CS_EVENT_CARD_RESET:
540 if (link->state & DEV_CONFIG) {
541 pcmcia_request_configuration(link->handle, &link->conf);
542 reset_airo_card(local->eth_dev);
543 netif_device_attach(local->eth_dev);
544 }
545 break;
546 } 476 }
477
547 return 0; 478 return 0;
548} /* airo_event */ 479}
549 480
550static struct pcmcia_device_id airo_ids[] = { 481static struct pcmcia_device_id airo_ids[] = {
551 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a), 482 PCMCIA_DEVICE_MANF_CARD(0x015f, 0x000a),
@@ -561,10 +492,11 @@ static struct pcmcia_driver airo_driver = {
561 .drv = { 492 .drv = {
562 .name = "airo_cs", 493 .name = "airo_cs",
563 }, 494 },
564 .attach = airo_attach, 495 .probe = airo_attach,
565 .event = airo_event, 496 .remove = airo_detach,
566 .detach = airo_detach,
567 .id_table = airo_ids, 497 .id_table = airo_ids,
498 .suspend = airo_suspend,
499 .resume = airo_resume,
568}; 500};
569 501
570static int airo_cs_init(void) 502static int airo_cs_init(void)
@@ -575,7 +507,6 @@ static int airo_cs_init(void)
575static void airo_cs_cleanup(void) 507static void airo_cs_cleanup(void)
576{ 508{
577 pcmcia_unregister_driver(&airo_driver); 509 pcmcia_unregister_driver(&airo_driver);
578 BUG_ON(dev_list != NULL);
579} 510}
580 511
581/* 512/*
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 5e53c5258a33..e4729ddf29fd 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -5,9 +5,9 @@
5 Copyright 2000-2001 ATMEL Corporation. 5 Copyright 2000-2001 ATMEL Corporation.
6 Copyright 2003-2004 Simon Kelley. 6 Copyright 2003-2004 Simon Kelley.
7 7
8 This code was developed from version 2.1.1 of the Atmel drivers, 8 This code was developed from version 2.1.1 of the Atmel drivers,
9 released by Atmel corp. under the GPL in December 2002. It also 9 released by Atmel corp. under the GPL in December 2002. It also
10 includes code from the Linux aironet drivers (C) Benjamin Reed, 10 includes code from the Linux aironet drivers (C) Benjamin Reed,
11 and the Linux PCMCIA package, (C) David Hinds and the Linux wireless 11 and the Linux PCMCIA package, (C) David Hinds and the Linux wireless
12 extensions, (C) Jean Tourrilhes. 12 extensions, (C) Jean Tourrilhes.
13 13
@@ -31,7 +31,7 @@
31 along with Atmel wireless lan drivers; if not, write to the Free Software 31 along with Atmel wireless lan drivers; if not, write to the Free Software
32 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 32 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 33
34 For all queries about this code, please contact the current author, 34 For all queries about this code, please contact the current author,
35 Simon Kelley <simon@thekelleys.org.uk> and not Atmel Corporation. 35 Simon Kelley <simon@thekelleys.org.uk> and not Atmel Corporation.
36 36
37 Credit is due to HP UK and Cambridge Online Systems Ltd for supplying 37 Credit is due to HP UK and Cambridge Online Systems Ltd for supplying
@@ -79,13 +79,13 @@ MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.")
79MODULE_LICENSE("GPL"); 79MODULE_LICENSE("GPL");
80MODULE_SUPPORTED_DEVICE("Atmel at76c50x wireless cards"); 80MODULE_SUPPORTED_DEVICE("Atmel at76c50x wireless cards");
81 81
82/* The name of the firmware file to be loaded 82/* The name of the firmware file to be loaded
83 over-rides any automatic selection */ 83 over-rides any automatic selection */
84static char *firmware = NULL; 84static char *firmware = NULL;
85module_param(firmware, charp, 0); 85module_param(firmware, charp, 0);
86 86
87/* table of firmware file names */ 87/* table of firmware file names */
88static struct { 88static struct {
89 AtmelFWType fw_type; 89 AtmelFWType fw_type;
90 const char *fw_file; 90 const char *fw_file;
91 const char *fw_file_ext; 91 const char *fw_file_ext;
@@ -104,17 +104,17 @@ static struct {
104#define MAX_SSID_LENGTH 32 104#define MAX_SSID_LENGTH 32
105#define MGMT_JIFFIES (256 * HZ / 100) 105#define MGMT_JIFFIES (256 * HZ / 100)
106 106
107#define MAX_BSS_ENTRIES 64 107#define MAX_BSS_ENTRIES 64
108 108
109/* registers */ 109/* registers */
110#define GCR 0x00 // (SIR0) General Configuration Register 110#define GCR 0x00 // (SIR0) General Configuration Register
111#define BSR 0x02 // (SIR1) Bank Switching Select Register 111#define BSR 0x02 // (SIR1) Bank Switching Select Register
112#define AR 0x04 112#define AR 0x04
113#define DR 0x08 113#define DR 0x08
114#define MR1 0x12 // Mirror Register 1 114#define MR1 0x12 // Mirror Register 1
115#define MR2 0x14 // Mirror Register 2 115#define MR2 0x14 // Mirror Register 2
116#define MR3 0x16 // Mirror Register 3 116#define MR3 0x16 // Mirror Register 3
117#define MR4 0x18 // Mirror Register 4 117#define MR4 0x18 // Mirror Register 4
118 118
119#define GPR1 0x0c 119#define GPR1 0x0c
120#define GPR2 0x0e 120#define GPR2 0x0e
@@ -123,9 +123,9 @@ static struct {
123// Constants for the GCR register. 123// Constants for the GCR register.
124// 124//
125#define GCR_REMAP 0x0400 // Remap internal SRAM to 0 125#define GCR_REMAP 0x0400 // Remap internal SRAM to 0
126#define GCR_SWRES 0x0080 // BIU reset (ARM and PAI are NOT reset) 126#define GCR_SWRES 0x0080 // BIU reset (ARM and PAI are NOT reset)
127#define GCR_CORES 0x0060 // Core Reset (ARM and PAI are reset) 127#define GCR_CORES 0x0060 // Core Reset (ARM and PAI are reset)
128#define GCR_ENINT 0x0002 // Enable Interrupts 128#define GCR_ENINT 0x0002 // Enable Interrupts
129#define GCR_ACKINT 0x0008 // Acknowledge Interrupts 129#define GCR_ACKINT 0x0008 // Acknowledge Interrupts
130 130
131#define BSS_SRAM 0x0200 // AMBA module selection --> SRAM 131#define BSS_SRAM 0x0200 // AMBA module selection --> SRAM
@@ -190,7 +190,7 @@ struct rx_desc {
190 u32 Next; 190 u32 Next;
191 u16 MsduPos; 191 u16 MsduPos;
192 u16 MsduSize; 192 u16 MsduSize;
193 193
194 u8 State; 194 u8 State;
195 u8 Status; 195 u8 Status;
196 u8 Rate; 196 u8 Rate;
@@ -199,7 +199,6 @@ struct rx_desc {
199 u8 PreambleType; 199 u8 PreambleType;
200 u16 Duration; 200 u16 Duration;
201 u32 RxTime; 201 u32 RxTime;
202
203}; 202};
204 203
205#define RX_DESC_FLAG_VALID 0x80 204#define RX_DESC_FLAG_VALID 0x80
@@ -218,16 +217,15 @@ struct rx_desc {
218#define RX_DESC_DURATION_OFFSET 14 217#define RX_DESC_DURATION_OFFSET 14
219#define RX_DESC_RX_TIME_OFFSET 16 218#define RX_DESC_RX_TIME_OFFSET 16
220 219
221
222struct tx_desc { 220struct tx_desc {
223 u32 NextDescriptor; 221 u32 NextDescriptor;
224 u16 TxStartOfFrame; 222 u16 TxStartOfFrame;
225 u16 TxLength; 223 u16 TxLength;
226 224
227 u8 TxState; 225 u8 TxState;
228 u8 TxStatus; 226 u8 TxStatus;
229 u8 RetryCount; 227 u8 RetryCount;
230 228
231 u8 TxRate; 229 u8 TxRate;
232 230
233 u8 KeyIndex; 231 u8 KeyIndex;
@@ -238,10 +236,8 @@ struct tx_desc {
238 u8 Reserved; 236 u8 Reserved;
239 u8 PacketType; 237 u8 PacketType;
240 u16 HostTxLength; 238 u16 HostTxLength;
241
242}; 239};
243 240
244
245#define TX_DESC_NEXT_OFFSET 0 241#define TX_DESC_NEXT_OFFSET 0
246#define TX_DESC_POS_OFFSET 4 242#define TX_DESC_POS_OFFSET 4
247#define TX_DESC_SIZE_OFFSET 6 243#define TX_DESC_SIZE_OFFSET 6
@@ -255,8 +251,6 @@ struct tx_desc {
255#define TX_DESC_PACKET_TYPE_OFFSET 17 251#define TX_DESC_PACKET_TYPE_OFFSET 17
256#define TX_DESC_HOST_LENGTH_OFFSET 18 252#define TX_DESC_HOST_LENGTH_OFFSET 18
257 253
258
259
260/////////////////////////////////////////////////////// 254///////////////////////////////////////////////////////
261// Host-MAC interface 255// Host-MAC interface
262/////////////////////////////////////////////////////// 256///////////////////////////////////////////////////////
@@ -266,7 +260,6 @@ struct tx_desc {
266#define TX_FIRM_OWN 0x80 260#define TX_FIRM_OWN 0x80
267#define TX_DONE 0x40 261#define TX_DONE 0x40
268 262
269
270#define TX_ERROR 0x01 263#define TX_ERROR 0x01
271 264
272#define TX_PACKET_TYPE_DATA 0x01 265#define TX_PACKET_TYPE_DATA 0x01
@@ -280,8 +273,7 @@ struct tx_desc {
280#define ISR_COMMAND_COMPLETE 0x10 // command completed 273#define ISR_COMMAND_COMPLETE 0x10 // command completed
281#define ISR_OUT_OF_RANGE 0x20 // command completed 274#define ISR_OUT_OF_RANGE 0x20 // command completed
282#define ISR_IBSS_MERGE 0x40 // (4.1.2.30): IBSS merge 275#define ISR_IBSS_MERGE 0x40 // (4.1.2.30): IBSS merge
283#define ISR_GENERIC_IRQ 0x80 276#define ISR_GENERIC_IRQ 0x80
284
285 277
286#define Local_Mib_Type 0x01 278#define Local_Mib_Type 0x01
287#define Mac_Address_Mib_Type 0x02 279#define Mac_Address_Mib_Type 0x02
@@ -317,7 +309,6 @@ struct tx_desc {
317#define LOCAL_MIB_PREAMBLE_TYPE 9 309#define LOCAL_MIB_PREAMBLE_TYPE 9
318#define MAC_ADDR_MIB_MAC_ADDR_POS 0 310#define MAC_ADDR_MIB_MAC_ADDR_POS 0
319 311
320
321#define CMD_Set_MIB_Vars 0x01 312#define CMD_Set_MIB_Vars 0x01
322#define CMD_Get_MIB_Vars 0x02 313#define CMD_Get_MIB_Vars 0x02
323#define CMD_Scan 0x03 314#define CMD_Scan 0x03
@@ -338,7 +329,6 @@ struct tx_desc {
338#define CMD_STATUS_HOST_ERROR 0xFF 329#define CMD_STATUS_HOST_ERROR 0xFF
339#define CMD_STATUS_BUSY 0xFE 330#define CMD_STATUS_BUSY 0xFE
340 331
341
342#define CMD_BLOCK_COMMAND_OFFSET 0 332#define CMD_BLOCK_COMMAND_OFFSET 0
343#define CMD_BLOCK_STATUS_OFFSET 1 333#define CMD_BLOCK_STATUS_OFFSET 1
344#define CMD_BLOCK_PARAMETERS_OFFSET 4 334#define CMD_BLOCK_PARAMETERS_OFFSET 4
@@ -347,15 +337,15 @@ struct tx_desc {
347 337
348#define MGMT_FRAME_BODY_OFFSET 24 338#define MGMT_FRAME_BODY_OFFSET 24
349#define MAX_AUTHENTICATION_RETRIES 3 339#define MAX_AUTHENTICATION_RETRIES 3
350#define MAX_ASSOCIATION_RETRIES 3 340#define MAX_ASSOCIATION_RETRIES 3
351 341
352#define AUTHENTICATION_RESPONSE_TIME_OUT 1000 342#define AUTHENTICATION_RESPONSE_TIME_OUT 1000
353 343
354#define MAX_WIRELESS_BODY 2316 /* mtu is 2312, CRC is 4 */ 344#define MAX_WIRELESS_BODY 2316 /* mtu is 2312, CRC is 4 */
355#define LOOP_RETRY_LIMIT 500000 345#define LOOP_RETRY_LIMIT 500000
356 346
357#define ACTIVE_MODE 1 347#define ACTIVE_MODE 1
358#define PS_MODE 2 348#define PS_MODE 2
359 349
360#define MAX_ENCRYPTION_KEYS 4 350#define MAX_ENCRYPTION_KEYS 4
361#define MAX_ENCRYPTION_KEY_SIZE 40 351#define MAX_ENCRYPTION_KEY_SIZE 40
@@ -377,7 +367,7 @@ struct tx_desc {
377#define REG_DOMAIN_MKK1 0x41 //Channel 1-14 Japan(MKK1) 367#define REG_DOMAIN_MKK1 0x41 //Channel 1-14 Japan(MKK1)
378#define REG_DOMAIN_ISRAEL 0x50 //Channel 3-9 ISRAEL 368#define REG_DOMAIN_ISRAEL 0x50 //Channel 3-9 ISRAEL
379 369
380#define BSS_TYPE_AD_HOC 1 370#define BSS_TYPE_AD_HOC 1
381#define BSS_TYPE_INFRASTRUCTURE 2 371#define BSS_TYPE_INFRASTRUCTURE 2
382 372
383#define SCAN_TYPE_ACTIVE 0 373#define SCAN_TYPE_ACTIVE 0
@@ -389,7 +379,7 @@ struct tx_desc {
389 379
390#define DATA_FRAME_WS_HEADER_SIZE 30 380#define DATA_FRAME_WS_HEADER_SIZE 30
391 381
392/* promiscuous mode control */ 382/* promiscuous mode control */
393#define PROM_MODE_OFF 0x0 383#define PROM_MODE_OFF 0x0
394#define PROM_MODE_UNKNOWN 0x1 384#define PROM_MODE_UNKNOWN 0x1
395#define PROM_MODE_CRC_FAILED 0x2 385#define PROM_MODE_CRC_FAILED 0x2
@@ -398,8 +388,7 @@ struct tx_desc {
398#define PROM_MODE_CTRL 0x10 388#define PROM_MODE_CTRL 0x10
399#define PROM_MODE_BAD_PROTOCOL 0x20 389#define PROM_MODE_BAD_PROTOCOL 0x20
400 390
401 391#define IFACE_INT_STATUS_OFFSET 0
402#define IFACE_INT_STATUS_OFFSET 0
403#define IFACE_INT_MASK_OFFSET 1 392#define IFACE_INT_MASK_OFFSET 1
404#define IFACE_LOCKOUT_HOST_OFFSET 2 393#define IFACE_LOCKOUT_HOST_OFFSET 2
405#define IFACE_LOCKOUT_MAC_OFFSET 3 394#define IFACE_LOCKOUT_MAC_OFFSET 3
@@ -407,7 +396,7 @@ struct tx_desc {
407#define IFACE_MAC_STAT_OFFSET 30 396#define IFACE_MAC_STAT_OFFSET 30
408#define IFACE_GENERIC_INT_TYPE_OFFSET 32 397#define IFACE_GENERIC_INT_TYPE_OFFSET 32
409 398
410#define CIPHER_SUITE_NONE 0 399#define CIPHER_SUITE_NONE 0
411#define CIPHER_SUITE_WEP_64 1 400#define CIPHER_SUITE_WEP_64 1
412#define CIPHER_SUITE_TKIP 2 401#define CIPHER_SUITE_TKIP 2
413#define CIPHER_SUITE_AES 3 402#define CIPHER_SUITE_AES 3
@@ -419,11 +408,11 @@ struct tx_desc {
419// 408//
420// 409//
421 410
422// FuncCtrl field: 411// FuncCtrl field:
423// 412//
424#define FUNC_CTRL_TxENABLE 0x10 413#define FUNC_CTRL_TxENABLE 0x10
425#define FUNC_CTRL_RxENABLE 0x20 414#define FUNC_CTRL_RxENABLE 0x20
426#define FUNC_CTRL_INIT_COMPLETE 0x01 415#define FUNC_CTRL_INIT_COMPLETE 0x01
427 416
428/* A stub firmware image which reads the MAC address from NVRAM on the card. 417/* A stub firmware image which reads the MAC address from NVRAM on the card.
429 For copyright information and source see the end of this file. */ 418 For copyright information and source see the end of this file. */
@@ -486,10 +475,10 @@ struct atmel_private {
486 struct net_device_stats stats; // device stats 475 struct net_device_stats stats; // device stats
487 spinlock_t irqlock, timerlock; // spinlocks 476 spinlock_t irqlock, timerlock; // spinlocks
488 enum { BUS_TYPE_PCCARD, BUS_TYPE_PCI } bus_type; 477 enum { BUS_TYPE_PCCARD, BUS_TYPE_PCI } bus_type;
489 enum { 478 enum {
490 CARD_TYPE_PARALLEL_FLASH, 479 CARD_TYPE_PARALLEL_FLASH,
491 CARD_TYPE_SPI_FLASH, 480 CARD_TYPE_SPI_FLASH,
492 CARD_TYPE_EEPROM 481 CARD_TYPE_EEPROM
493 } card_type; 482 } card_type;
494 int do_rx_crc; /* If we need to CRC incoming packets */ 483 int do_rx_crc; /* If we need to CRC incoming packets */
495 int probe_crc; /* set if we don't yet know */ 484 int probe_crc; /* set if we don't yet know */
@@ -497,18 +486,18 @@ struct atmel_private {
497 u16 rx_desc_head; 486 u16 rx_desc_head;
498 u16 tx_desc_free, tx_desc_head, tx_desc_tail, tx_desc_previous; 487 u16 tx_desc_free, tx_desc_head, tx_desc_tail, tx_desc_previous;
499 u16 tx_free_mem, tx_buff_head, tx_buff_tail; 488 u16 tx_free_mem, tx_buff_head, tx_buff_tail;
500 489
501 u16 frag_seq, frag_len, frag_no; 490 u16 frag_seq, frag_len, frag_no;
502 u8 frag_source[6]; 491 u8 frag_source[6];
503 492
504 u8 wep_is_on, default_key, exclude_unencrypted, encryption_level; 493 u8 wep_is_on, default_key, exclude_unencrypted, encryption_level;
505 u8 group_cipher_suite, pairwise_cipher_suite; 494 u8 group_cipher_suite, pairwise_cipher_suite;
506 u8 wep_keys[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE]; 495 u8 wep_keys[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE];
507 int wep_key_len[MAX_ENCRYPTION_KEYS]; 496 int wep_key_len[MAX_ENCRYPTION_KEYS];
508 int use_wpa, radio_on_broken; /* firmware dependent stuff. */ 497 int use_wpa, radio_on_broken; /* firmware dependent stuff. */
509 498
510 u16 host_info_base; 499 u16 host_info_base;
511 struct host_info_struct { 500 struct host_info_struct {
512 /* NB this is matched to the hardware, don't change. */ 501 /* NB this is matched to the hardware, don't change. */
513 u8 volatile int_status; 502 u8 volatile int_status;
514 u8 volatile int_mask; 503 u8 volatile int_mask;
@@ -524,20 +513,20 @@ struct atmel_private {
524 u16 rx_buff_size; 513 u16 rx_buff_size;
525 u16 rx_desc_pos; 514 u16 rx_desc_pos;
526 u16 rx_desc_count; 515 u16 rx_desc_count;
527 516
528 u16 build_version; 517 u16 build_version;
529 u16 command_pos; 518 u16 command_pos;
530 519
531 u16 major_version; 520 u16 major_version;
532 u16 minor_version; 521 u16 minor_version;
533 522
534 u16 func_ctrl; 523 u16 func_ctrl;
535 u16 mac_status; 524 u16 mac_status;
536 u16 generic_IRQ_type; 525 u16 generic_IRQ_type;
537 u8 reserved[2]; 526 u8 reserved[2];
538 } host_info; 527 } host_info;
539 528
540 enum { 529 enum {
541 STATION_STATE_SCANNING, 530 STATION_STATE_SCANNING,
542 STATION_STATE_JOINNING, 531 STATION_STATE_JOINNING,
543 STATION_STATE_AUTHENTICATING, 532 STATION_STATE_AUTHENTICATING,
@@ -547,7 +536,7 @@ struct atmel_private {
547 STATION_STATE_DOWN, 536 STATION_STATE_DOWN,
548 STATION_STATE_MGMT_ERROR 537 STATION_STATE_MGMT_ERROR
549 } station_state; 538 } station_state;
550 539
551 int operating_mode, power_mode; 540 int operating_mode, power_mode;
552 time_t last_qual; 541 time_t last_qual;
553 int beacons_this_sec; 542 int beacons_this_sec;
@@ -560,18 +549,18 @@ struct atmel_private {
560 int long_retry, short_retry; 549 int long_retry, short_retry;
561 int preamble; 550 int preamble;
562 int default_beacon_period, beacon_period, listen_interval; 551 int default_beacon_period, beacon_period, listen_interval;
563 int CurrentAuthentTransactionSeqNum, ExpectedAuthentTransactionSeqNum; 552 int CurrentAuthentTransactionSeqNum, ExpectedAuthentTransactionSeqNum;
564 int AuthenticationRequestRetryCnt, AssociationRequestRetryCnt, ReAssociationRequestRetryCnt; 553 int AuthenticationRequestRetryCnt, AssociationRequestRetryCnt, ReAssociationRequestRetryCnt;
565 enum { 554 enum {
566 SITE_SURVEY_IDLE, 555 SITE_SURVEY_IDLE,
567 SITE_SURVEY_IN_PROGRESS, 556 SITE_SURVEY_IN_PROGRESS,
568 SITE_SURVEY_COMPLETED 557 SITE_SURVEY_COMPLETED
569 } site_survey_state; 558 } site_survey_state;
570 time_t last_survey; 559 time_t last_survey;
571 560
572 int station_was_associated, station_is_associated; 561 int station_was_associated, station_is_associated;
573 int fast_scan; 562 int fast_scan;
574 563
575 struct bss_info { 564 struct bss_info {
576 int channel; 565 int channel;
577 int SSIDsize; 566 int SSIDsize;
@@ -584,13 +573,12 @@ struct atmel_private {
584 u8 SSID[MAX_SSID_LENGTH]; 573 u8 SSID[MAX_SSID_LENGTH];
585 } BSSinfo[MAX_BSS_ENTRIES]; 574 } BSSinfo[MAX_BSS_ENTRIES];
586 int BSS_list_entries, current_BSS; 575 int BSS_list_entries, current_BSS;
587 int connect_to_any_BSS; 576 int connect_to_any_BSS;
588 int SSID_size, new_SSID_size; 577 int SSID_size, new_SSID_size;
589 u8 CurrentBSSID[6], BSSID[6]; 578 u8 CurrentBSSID[6], BSSID[6];
590 u8 SSID[MAX_SSID_LENGTH], new_SSID[MAX_SSID_LENGTH]; 579 u8 SSID[MAX_SSID_LENGTH], new_SSID[MAX_SSID_LENGTH];
591 u64 last_beacon_timestamp; 580 u64 last_beacon_timestamp;
592 u8 rx_buf[MAX_WIRELESS_BODY]; 581 u8 rx_buf[MAX_WIRELESS_BODY];
593
594}; 582};
595 583
596static u8 atmel_basic_rates[4] = {0x82,0x84,0x0b,0x16}; 584static u8 atmel_basic_rates[4] = {0x82,0x84,0x0b,0x16};
@@ -598,39 +586,49 @@ static u8 atmel_basic_rates[4] = {0x82,0x84,0x0b,0x16};
598static const struct { 586static const struct {
599 int reg_domain; 587 int reg_domain;
600 int min, max; 588 int min, max;
601 char *name; 589 char *name;
602} channel_table[] = { { REG_DOMAIN_FCC, 1, 11, "USA" }, 590} channel_table[] = { { REG_DOMAIN_FCC, 1, 11, "USA" },
603 { REG_DOMAIN_DOC, 1, 11, "Canada" }, 591 { REG_DOMAIN_DOC, 1, 11, "Canada" },
604 { REG_DOMAIN_ETSI, 1, 13, "Europe" }, 592 { REG_DOMAIN_ETSI, 1, 13, "Europe" },
605 { REG_DOMAIN_SPAIN, 10, 11, "Spain" }, 593 { REG_DOMAIN_SPAIN, 10, 11, "Spain" },
606 { REG_DOMAIN_FRANCE, 10, 13, "France" }, 594 { REG_DOMAIN_FRANCE, 10, 13, "France" },
607 { REG_DOMAIN_MKK, 14, 14, "MKK" }, 595 { REG_DOMAIN_MKK, 14, 14, "MKK" },
608 { REG_DOMAIN_MKK1, 1, 14, "MKK1" }, 596 { REG_DOMAIN_MKK1, 1, 14, "MKK1" },
609 { REG_DOMAIN_ISRAEL, 3, 9, "Israel"} }; 597 { REG_DOMAIN_ISRAEL, 3, 9, "Israel"} };
610 598
611static void build_wpa_mib(struct atmel_private *priv); 599static void build_wpa_mib(struct atmel_private *priv);
612static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); 600static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
613static void atmel_copy_to_card(struct net_device *dev, u16 dest, unsigned char *src, u16 len); 601static void atmel_copy_to_card(struct net_device *dev, u16 dest,
614static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest, u16 src, u16 len); 602 unsigned char *src, u16 len);
603static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest,
604 u16 src, u16 len);
615static void atmel_set_gcr(struct net_device *dev, u16 mask); 605static void atmel_set_gcr(struct net_device *dev, u16 mask);
616static void atmel_clear_gcr(struct net_device *dev, u16 mask); 606static void atmel_clear_gcr(struct net_device *dev, u16 mask);
617static int atmel_lock_mac(struct atmel_private *priv); 607static int atmel_lock_mac(struct atmel_private *priv);
618static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data); 608static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data);
619static void atmel_command_irq(struct atmel_private *priv); 609static void atmel_command_irq(struct atmel_private *priv);
620static int atmel_validate_channel(struct atmel_private *priv, int channel); 610static int atmel_validate_channel(struct atmel_private *priv, int channel);
621static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, 611static void atmel_management_frame(struct atmel_private *priv,
612 struct ieee80211_hdr_4addr *header,
622 u16 frame_len, u8 rssi); 613 u16 frame_len, u8 rssi);
623static void atmel_management_timer(u_long a); 614static void atmel_management_timer(u_long a);
624static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size); 615static void atmel_send_command(struct atmel_private *priv, int command,
625static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size); 616 void *cmd, int cmd_size);
626static void atmel_transmit_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, 617static int atmel_send_command_wait(struct atmel_private *priv, int command,
618 void *cmd, int cmd_size);
619static void atmel_transmit_management_frame(struct atmel_private *priv,
620 struct ieee80211_hdr_4addr *header,
627 u8 *body, int body_len); 621 u8 *body, int body_len);
628 622
629static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index); 623static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
630static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, u8 data); 624static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index,
631static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, u16 data); 625 u8 data);
632static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len); 626static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index,
633static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len); 627 u16 data);
628static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index,
629 u8 *data, int data_len);
630static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index,
631 u8 *data, int data_len);
634static void atmel_scan(struct atmel_private *priv, int specific_ssid); 632static void atmel_scan(struct atmel_private *priv, int specific_ssid);
635static void atmel_join_bss(struct atmel_private *priv, int bss_index); 633static void atmel_join_bss(struct atmel_private *priv, int bss_index);
636static void atmel_smooth_qual(struct atmel_private *priv); 634static void atmel_smooth_qual(struct atmel_private *priv);
@@ -650,12 +648,12 @@ static inline u16 atmel_co(struct atmel_private *priv, u16 offset)
650 return priv->host_info.command_pos + offset; 648 return priv->host_info.command_pos + offset;
651} 649}
652 650
653static inline u16 atmel_rx(struct atmel_private *priv, u16 offset, u16 desc) 651static inline u16 atmel_rx(struct atmel_private *priv, u16 offset, u16 desc)
654{ 652{
655 return priv->host_info.rx_desc_pos + (sizeof(struct rx_desc) * desc) + offset; 653 return priv->host_info.rx_desc_pos + (sizeof(struct rx_desc) * desc) + offset;
656} 654}
657 655
658static inline u16 atmel_tx(struct atmel_private *priv, u16 offset, u16 desc) 656static inline u16 atmel_tx(struct atmel_private *priv, u16 offset, u16 desc)
659{ 657{
660 return priv->host_info.tx_desc_pos + (sizeof(struct tx_desc) * desc) + offset; 658 return priv->host_info.tx_desc_pos + (sizeof(struct tx_desc) * desc) + offset;
661} 659}
@@ -682,25 +680,25 @@ static inline void atmel_write16(struct net_device *dev, u16 offset, u16 data)
682 680
683static inline u8 atmel_rmem8(struct atmel_private *priv, u16 pos) 681static inline u8 atmel_rmem8(struct atmel_private *priv, u16 pos)
684{ 682{
685 atmel_writeAR(priv->dev, pos); 683 atmel_writeAR(priv->dev, pos);
686 return atmel_read8(priv->dev, DR); 684 return atmel_read8(priv->dev, DR);
687} 685}
688 686
689static inline void atmel_wmem8(struct atmel_private *priv, u16 pos, u16 data) 687static inline void atmel_wmem8(struct atmel_private *priv, u16 pos, u16 data)
690{ 688{
691 atmel_writeAR(priv->dev, pos); 689 atmel_writeAR(priv->dev, pos);
692 atmel_write8(priv->dev, DR, data); 690 atmel_write8(priv->dev, DR, data);
693} 691}
694 692
695static inline u16 atmel_rmem16(struct atmel_private *priv, u16 pos) 693static inline u16 atmel_rmem16(struct atmel_private *priv, u16 pos)
696{ 694{
697 atmel_writeAR(priv->dev, pos); 695 atmel_writeAR(priv->dev, pos);
698 return atmel_read16(priv->dev, DR); 696 return atmel_read16(priv->dev, DR);
699} 697}
700 698
701static inline void atmel_wmem16(struct atmel_private *priv, u16 pos, u16 data) 699static inline void atmel_wmem16(struct atmel_private *priv, u16 pos, u16 data)
702{ 700{
703 atmel_writeAR(priv->dev, pos); 701 atmel_writeAR(priv->dev, pos);
704 atmel_write16(priv->dev, DR, data); 702 atmel_write16(priv->dev, DR, data);
705} 703}
706 704
@@ -710,11 +708,10 @@ static void tx_done_irq(struct atmel_private *priv)
710{ 708{
711 int i; 709 int i;
712 710
713 for (i = 0; 711 for (i = 0;
714 atmel_rmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, priv->tx_desc_head)) == TX_DONE && 712 atmel_rmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, priv->tx_desc_head)) == TX_DONE &&
715 i < priv->host_info.tx_desc_count; 713 i < priv->host_info.tx_desc_count;
716 i++) { 714 i++) {
717
718 u8 status = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_STATUS_OFFSET, priv->tx_desc_head)); 715 u8 status = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_STATUS_OFFSET, priv->tx_desc_head));
719 u16 msdu_size = atmel_rmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_head)); 716 u16 msdu_size = atmel_rmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_head));
720 u8 type = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_PACKET_TYPE_OFFSET, priv->tx_desc_head)); 717 u8 type = atmel_rmem8(priv, atmel_tx(priv, TX_DESC_PACKET_TYPE_OFFSET, priv->tx_desc_head));
@@ -728,16 +725,16 @@ static void tx_done_irq(struct atmel_private *priv)
728 priv->tx_buff_head = 0; 725 priv->tx_buff_head = 0;
729 else 726 else
730 priv->tx_buff_head += msdu_size; 727 priv->tx_buff_head += msdu_size;
731 728
732 if (priv->tx_desc_head < (priv->host_info.tx_desc_count - 1)) 729 if (priv->tx_desc_head < (priv->host_info.tx_desc_count - 1))
733 priv->tx_desc_head++ ; 730 priv->tx_desc_head++ ;
734 else 731 else
735 priv->tx_desc_head = 0; 732 priv->tx_desc_head = 0;
736 733
737 if (type == TX_PACKET_TYPE_DATA) { 734 if (type == TX_PACKET_TYPE_DATA) {
738 if (status == TX_STATUS_SUCCESS) 735 if (status == TX_STATUS_SUCCESS)
739 priv->stats.tx_packets++; 736 priv->stats.tx_packets++;
740 else 737 else
741 priv->stats.tx_errors++; 738 priv->stats.tx_errors++;
742 netif_wake_queue(priv->dev); 739 netif_wake_queue(priv->dev);
743 } 740 }
@@ -748,21 +745,22 @@ static u16 find_tx_buff(struct atmel_private *priv, u16 len)
748{ 745{
749 u16 bottom_free = priv->host_info.tx_buff_size - priv->tx_buff_tail; 746 u16 bottom_free = priv->host_info.tx_buff_size - priv->tx_buff_tail;
750 747
751 if (priv->tx_desc_free == 3 || priv->tx_free_mem < len) 748 if (priv->tx_desc_free == 3 || priv->tx_free_mem < len)
752 return 0; 749 return 0;
753 750
754 if (bottom_free >= len) 751 if (bottom_free >= len)
755 return priv->host_info.tx_buff_pos + priv->tx_buff_tail; 752 return priv->host_info.tx_buff_pos + priv->tx_buff_tail;
756 753
757 if (priv->tx_free_mem - bottom_free >= len) { 754 if (priv->tx_free_mem - bottom_free >= len) {
758 priv->tx_buff_tail = 0; 755 priv->tx_buff_tail = 0;
759 return priv->host_info.tx_buff_pos; 756 return priv->host_info.tx_buff_pos;
760 } 757 }
761 758
762 return 0; 759 return 0;
763} 760}
764 761
765static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 len, u16 buff, u8 type) 762static void tx_update_descriptor(struct atmel_private *priv, int is_bcast,
763 u16 len, u16 buff, u8 type)
766{ 764{
767 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, priv->tx_desc_tail), buff); 765 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, priv->tx_desc_tail), buff);
768 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_tail), len); 766 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, priv->tx_desc_tail), len);
@@ -775,8 +773,8 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l
775 int cipher_type, cipher_length; 773 int cipher_type, cipher_length;
776 if (is_bcast) { 774 if (is_bcast) {
777 cipher_type = priv->group_cipher_suite; 775 cipher_type = priv->group_cipher_suite;
778 if (cipher_type == CIPHER_SUITE_WEP_64 || 776 if (cipher_type == CIPHER_SUITE_WEP_64 ||
779 cipher_type == CIPHER_SUITE_WEP_128 ) 777 cipher_type == CIPHER_SUITE_WEP_128)
780 cipher_length = 8; 778 cipher_length = 8;
781 else if (cipher_type == CIPHER_SUITE_TKIP) 779 else if (cipher_type == CIPHER_SUITE_TKIP)
782 cipher_length = 12; 780 cipher_length = 12;
@@ -790,8 +788,8 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l
790 } 788 }
791 } else { 789 } else {
792 cipher_type = priv->pairwise_cipher_suite; 790 cipher_type = priv->pairwise_cipher_suite;
793 if (cipher_type == CIPHER_SUITE_WEP_64 || 791 if (cipher_type == CIPHER_SUITE_WEP_64 ||
794 cipher_type == CIPHER_SUITE_WEP_128 ) 792 cipher_type == CIPHER_SUITE_WEP_128)
795 cipher_length = 8; 793 cipher_length = 8;
796 else if (cipher_type == CIPHER_SUITE_TKIP) 794 else if (cipher_type == CIPHER_SUITE_TKIP)
797 cipher_length = 12; 795 cipher_length = 12;
@@ -804,9 +802,9 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l
804 cipher_length = 0; 802 cipher_length = 0;
805 } 803 }
806 } 804 }
807 805
808 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_TYPE_OFFSET, priv->tx_desc_tail), 806 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_TYPE_OFFSET, priv->tx_desc_tail),
809 cipher_type); 807 cipher_type);
810 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_LENGTH_OFFSET, priv->tx_desc_tail), 808 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_CIPHER_LENGTH_OFFSET, priv->tx_desc_tail),
811 cipher_length); 809 cipher_length);
812 } 810 }
@@ -815,46 +813,46 @@ static void tx_update_descriptor(struct atmel_private *priv, int is_bcast, u16 l
815 if (priv->tx_desc_previous != priv->tx_desc_tail) 813 if (priv->tx_desc_previous != priv->tx_desc_tail)
816 atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, priv->tx_desc_previous), 0); 814 atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, priv->tx_desc_previous), 0);
817 priv->tx_desc_previous = priv->tx_desc_tail; 815 priv->tx_desc_previous = priv->tx_desc_tail;
818 if (priv->tx_desc_tail < (priv->host_info.tx_desc_count -1 )) 816 if (priv->tx_desc_tail < (priv->host_info.tx_desc_count - 1))
819 priv->tx_desc_tail++; 817 priv->tx_desc_tail++;
820 else 818 else
821 priv->tx_desc_tail = 0; 819 priv->tx_desc_tail = 0;
822 priv->tx_desc_free--; 820 priv->tx_desc_free--;
823 priv->tx_free_mem -= len; 821 priv->tx_free_mem -= len;
824
825} 822}
826 823
827static int start_tx (struct sk_buff *skb, struct net_device *dev) 824static int start_tx(struct sk_buff *skb, struct net_device *dev)
828{ 825{
829 struct atmel_private *priv = netdev_priv(dev); 826 struct atmel_private *priv = netdev_priv(dev);
830 struct ieee80211_hdr_4addr header; 827 struct ieee80211_hdr_4addr header;
831 unsigned long flags; 828 unsigned long flags;
832 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN; 829 u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;
833 u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; 830 u8 SNAP_RFC1024[6] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00};
834 831
835 if (priv->card && priv->present_callback && 832 if (priv->card && priv->present_callback &&
836 !(*priv->present_callback)(priv->card)) { 833 !(*priv->present_callback)(priv->card)) {
837 priv->stats.tx_errors++; 834 priv->stats.tx_errors++;
838 dev_kfree_skb(skb); 835 dev_kfree_skb(skb);
839 return 0; 836 return 0;
840 } 837 }
841 838
842 if (priv->station_state != STATION_STATE_READY) { 839 if (priv->station_state != STATION_STATE_READY) {
843 priv->stats.tx_errors++; 840 priv->stats.tx_errors++;
844 dev_kfree_skb(skb); 841 dev_kfree_skb(skb);
845 return 0; 842 return 0;
846 } 843 }
847 844
848 /* first ensure the timer func cannot run */ 845 /* first ensure the timer func cannot run */
849 spin_lock_bh(&priv->timerlock); 846 spin_lock_bh(&priv->timerlock);
850 /* then stop the hardware ISR */ 847 /* then stop the hardware ISR */
851 spin_lock_irqsave(&priv->irqlock, flags); 848 spin_lock_irqsave(&priv->irqlock, flags);
852 /* nb doing the above in the opposite order will deadlock */ 849 /* nb doing the above in the opposite order will deadlock */
853 850
854 /* The Wireless Header is 30 bytes. In the Ethernet packet we "cut" the 851 /* The Wireless Header is 30 bytes. In the Ethernet packet we "cut" the
855 12 first bytes (containing DA/SA) and put them in the appropriate fields of 852 12 first bytes (containing DA/SA) and put them in the appropriate
856 the Wireless Header. Thus the packet length is then the initial + 18 (+30-12) */ 853 fields of the Wireless Header. Thus the packet length is then the
857 854 initial + 18 (+30-12) */
855
858 if (!(buff = find_tx_buff(priv, len + 18))) { 856 if (!(buff = find_tx_buff(priv, len + 18))) {
859 priv->stats.tx_dropped++; 857 priv->stats.tx_dropped++;
860 spin_unlock_irqrestore(&priv->irqlock, flags); 858 spin_unlock_irqrestore(&priv->irqlock, flags);
@@ -862,7 +860,7 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
862 netif_stop_queue(dev); 860 netif_stop_queue(dev);
863 return 1; 861 return 1;
864 } 862 }
865 863
866 frame_ctl = IEEE80211_FTYPE_DATA; 864 frame_ctl = IEEE80211_FTYPE_DATA;
867 header.duration_id = 0; 865 header.duration_id = 0;
868 header.seq_ctl = 0; 866 header.seq_ctl = 0;
@@ -878,7 +876,7 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
878 memcpy(&header.addr2, dev->dev_addr, 6); 876 memcpy(&header.addr2, dev->dev_addr, 6);
879 memcpy(&header.addr3, skb->data, 6); 877 memcpy(&header.addr3, skb->data, 6);
880 } 878 }
881 879
882 if (priv->use_wpa) 880 if (priv->use_wpa)
883 memcpy(&header.addr4, SNAP_RFC1024, 6); 881 memcpy(&header.addr4, SNAP_RFC1024, 6);
884 882
@@ -888,27 +886,27 @@ static int start_tx (struct sk_buff *skb, struct net_device *dev)
888 /* Copy the packet sans its 802.3 header addresses which have been replaced */ 886 /* Copy the packet sans its 802.3 header addresses which have been replaced */
889 atmel_copy_to_card(dev, buff + DATA_FRAME_WS_HEADER_SIZE, skb->data + 12, len - 12); 887 atmel_copy_to_card(dev, buff + DATA_FRAME_WS_HEADER_SIZE, skb->data + 12, len - 12);
890 priv->tx_buff_tail += len - 12 + DATA_FRAME_WS_HEADER_SIZE; 888 priv->tx_buff_tail += len - 12 + DATA_FRAME_WS_HEADER_SIZE;
891 889
892 /* low bit of first byte of destination tells us if broadcast */ 890 /* low bit of first byte of destination tells us if broadcast */
893 tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA); 891 tx_update_descriptor(priv, *(skb->data) & 0x01, len + 18, buff, TX_PACKET_TYPE_DATA);
894 dev->trans_start = jiffies; 892 dev->trans_start = jiffies;
895 priv->stats.tx_bytes += len; 893 priv->stats.tx_bytes += len;
896 894
897 spin_unlock_irqrestore(&priv->irqlock, flags); 895 spin_unlock_irqrestore(&priv->irqlock, flags);
898 spin_unlock_bh(&priv->timerlock); 896 spin_unlock_bh(&priv->timerlock);
899 dev_kfree_skb(skb); 897 dev_kfree_skb(skb);
900 898
901 return 0; 899 return 0;
902} 900}
903 901
904static void atmel_transmit_management_frame(struct atmel_private *priv, 902static void atmel_transmit_management_frame(struct atmel_private *priv,
905 struct ieee80211_hdr_4addr *header, 903 struct ieee80211_hdr_4addr *header,
906 u8 *body, int body_len) 904 u8 *body, int body_len)
907{ 905{
908 u16 buff; 906 u16 buff;
909 int len = MGMT_FRAME_BODY_OFFSET + body_len; 907 int len = MGMT_FRAME_BODY_OFFSET + body_len;
910 908
911 if (!(buff = find_tx_buff(priv, len))) 909 if (!(buff = find_tx_buff(priv, len)))
912 return; 910 return;
913 911
914 atmel_copy_to_card(priv->dev, buff, (u8 *)header, MGMT_FRAME_BODY_OFFSET); 912 atmel_copy_to_card(priv->dev, buff, (u8 *)header, MGMT_FRAME_BODY_OFFSET);
@@ -916,24 +914,25 @@ static void atmel_transmit_management_frame(struct atmel_private *priv,
916 priv->tx_buff_tail += len; 914 priv->tx_buff_tail += len;
917 tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT); 915 tx_update_descriptor(priv, header->addr1[0] & 0x01, len, buff, TX_PACKET_TYPE_MGMT);
918} 916}
919 917
920static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, 918static void fast_rx_path(struct atmel_private *priv,
919 struct ieee80211_hdr_4addr *header,
921 u16 msdu_size, u16 rx_packet_loc, u32 crc) 920 u16 msdu_size, u16 rx_packet_loc, u32 crc)
922{ 921{
923 /* fast path: unfragmented packet copy directly into skbuf */ 922 /* fast path: unfragmented packet copy directly into skbuf */
924 u8 mac4[6]; 923 u8 mac4[6];
925 struct sk_buff *skb; 924 struct sk_buff *skb;
926 unsigned char *skbp; 925 unsigned char *skbp;
927 926
928 /* get the final, mac 4 header field, this tells us encapsulation */ 927 /* get the final, mac 4 header field, this tells us encapsulation */
929 atmel_copy_to_host(priv->dev, mac4, rx_packet_loc + 24, 6); 928 atmel_copy_to_host(priv->dev, mac4, rx_packet_loc + 24, 6);
930 msdu_size -= 6; 929 msdu_size -= 6;
931 930
932 if (priv->do_rx_crc) { 931 if (priv->do_rx_crc) {
933 crc = crc32_le(crc, mac4, 6); 932 crc = crc32_le(crc, mac4, 6);
934 msdu_size -= 4; 933 msdu_size -= 4;
935 } 934 }
936 935
937 if (!(skb = dev_alloc_skb(msdu_size + 14))) { 936 if (!(skb = dev_alloc_skb(msdu_size + 14))) {
938 priv->stats.rx_dropped++; 937 priv->stats.rx_dropped++;
939 return; 938 return;
@@ -942,7 +941,7 @@ static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr
942 skb_reserve(skb, 2); 941 skb_reserve(skb, 2);
943 skbp = skb_put(skb, msdu_size + 12); 942 skbp = skb_put(skb, msdu_size + 12);
944 atmel_copy_to_host(priv->dev, skbp + 12, rx_packet_loc + 30, msdu_size); 943 atmel_copy_to_host(priv->dev, skbp + 12, rx_packet_loc + 30, msdu_size);
945 944
946 if (priv->do_rx_crc) { 945 if (priv->do_rx_crc) {
947 u32 netcrc; 946 u32 netcrc;
948 crc = crc32_le(crc, skbp + 12, msdu_size); 947 crc = crc32_le(crc, skbp + 12, msdu_size);
@@ -953,24 +952,25 @@ static void fast_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr
953 return; 952 return;
954 } 953 }
955 } 954 }
956 955
957 memcpy(skbp, header->addr1, 6); /* destination address */ 956 memcpy(skbp, header->addr1, 6); /* destination address */
958 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 957 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
959 memcpy(&skbp[6], header->addr3, 6); 958 memcpy(&skbp[6], header->addr3, 6);
960 else 959 else
961 memcpy(&skbp[6], header->addr2, 6); /* source address */ 960 memcpy(&skbp[6], header->addr2, 6); /* source address */
962 961
963 priv->dev->last_rx=jiffies; 962 priv->dev->last_rx = jiffies;
964 skb->dev = priv->dev; 963 skb->dev = priv->dev;
965 skb->protocol = eth_type_trans(skb, priv->dev); 964 skb->protocol = eth_type_trans(skb, priv->dev);
966 skb->ip_summed = CHECKSUM_NONE; 965 skb->ip_summed = CHECKSUM_NONE;
967 netif_rx(skb); 966 netif_rx(skb);
968 priv->stats.rx_bytes += 12 + msdu_size; 967 priv->stats.rx_bytes += 12 + msdu_size;
969 priv->stats.rx_packets++; 968 priv->stats.rx_packets++;
970} 969}
971 970
972/* Test to see if the packet in card memory at packet_loc has a valid CRC 971/* Test to see if the packet in card memory at packet_loc has a valid CRC
973 It doesn't matter that this is slow: it is only used to proble the first few packets. */ 972 It doesn't matter that this is slow: it is only used to proble the first few
973 packets. */
974static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size) 974static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
975{ 975{
976 int i = msdu_size - 4; 976 int i = msdu_size - 4;
@@ -980,7 +980,7 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
980 return 0; 980 return 0;
981 981
982 atmel_copy_to_host(priv->dev, (void *)&netcrc, packet_loc + i, 4); 982 atmel_copy_to_host(priv->dev, (void *)&netcrc, packet_loc + i, 4);
983 983
984 atmel_writeAR(priv->dev, packet_loc); 984 atmel_writeAR(priv->dev, packet_loc);
985 while (i--) { 985 while (i--) {
986 u8 octet = atmel_read8(priv->dev, DR); 986 u8 octet = atmel_read8(priv->dev, DR);
@@ -990,20 +990,22 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
990 return (crc ^ 0xffffffff) == netcrc; 990 return (crc ^ 0xffffffff) == netcrc;
991} 991}
992 992
993static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, 993static void frag_rx_path(struct atmel_private *priv,
994 u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no, u8 frag_no, int more_frags) 994 struct ieee80211_hdr_4addr *header,
995 u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no,
996 u8 frag_no, int more_frags)
995{ 997{
996 u8 mac4[6]; 998 u8 mac4[6];
997 u8 source[6]; 999 u8 source[6];
998 struct sk_buff *skb; 1000 struct sk_buff *skb;
999 1001
1000 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 1002 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
1001 memcpy(source, header->addr3, 6); 1003 memcpy(source, header->addr3, 6);
1002 else 1004 else
1003 memcpy(source, header->addr2, 6); 1005 memcpy(source, header->addr2, 6);
1004 1006
1005 rx_packet_loc += 24; /* skip header */ 1007 rx_packet_loc += 24; /* skip header */
1006 1008
1007 if (priv->do_rx_crc) 1009 if (priv->do_rx_crc)
1008 msdu_size -= 4; 1010 msdu_size -= 4;
1009 1011
@@ -1012,16 +1014,16 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr
1012 msdu_size -= 6; 1014 msdu_size -= 6;
1013 rx_packet_loc += 6; 1015 rx_packet_loc += 6;
1014 1016
1015 if (priv->do_rx_crc) 1017 if (priv->do_rx_crc)
1016 crc = crc32_le(crc, mac4, 6); 1018 crc = crc32_le(crc, mac4, 6);
1017 1019
1018 priv->frag_seq = seq_no; 1020 priv->frag_seq = seq_no;
1019 priv->frag_no = 1; 1021 priv->frag_no = 1;
1020 priv->frag_len = msdu_size; 1022 priv->frag_len = msdu_size;
1021 memcpy(priv->frag_source, source, 6); 1023 memcpy(priv->frag_source, source, 6);
1022 memcpy(&priv->rx_buf[6], source, 6); 1024 memcpy(&priv->rx_buf[6], source, 6);
1023 memcpy(priv->rx_buf, header->addr1, 6); 1025 memcpy(priv->rx_buf, header->addr1, 6);
1024 1026
1025 atmel_copy_to_host(priv->dev, &priv->rx_buf[12], rx_packet_loc, msdu_size); 1027 atmel_copy_to_host(priv->dev, &priv->rx_buf[12], rx_packet_loc, msdu_size);
1026 1028
1027 if (priv->do_rx_crc) { 1029 if (priv->do_rx_crc) {
@@ -1033,17 +1035,17 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr
1033 memset(priv->frag_source, 0xff, 6); 1035 memset(priv->frag_source, 0xff, 6);
1034 } 1036 }
1035 } 1037 }
1036 1038
1037 } else if (priv->frag_no == frag_no && 1039 } else if (priv->frag_no == frag_no &&
1038 priv->frag_seq == seq_no && 1040 priv->frag_seq == seq_no &&
1039 memcmp(priv->frag_source, source, 6) == 0) { 1041 memcmp(priv->frag_source, source, 6) == 0) {
1040 1042
1041 atmel_copy_to_host(priv->dev, &priv->rx_buf[12 + priv->frag_len], 1043 atmel_copy_to_host(priv->dev, &priv->rx_buf[12 + priv->frag_len],
1042 rx_packet_loc, msdu_size); 1044 rx_packet_loc, msdu_size);
1043 if (priv->do_rx_crc) { 1045 if (priv->do_rx_crc) {
1044 u32 netcrc; 1046 u32 netcrc;
1045 crc = crc32_le(crc, 1047 crc = crc32_le(crc,
1046 &priv->rx_buf[12 + priv->frag_len], 1048 &priv->rx_buf[12 + priv->frag_len],
1047 msdu_size); 1049 msdu_size);
1048 atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4); 1050 atmel_copy_to_host(priv->dev, (void *)&netcrc, rx_packet_loc + msdu_size, 4);
1049 if ((crc ^ 0xffffffff) != netcrc) { 1051 if ((crc ^ 0xffffffff) != netcrc) {
@@ -1052,7 +1054,7 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr
1052 more_frags = 1; /* don't send broken assembly */ 1054 more_frags = 1; /* don't send broken assembly */
1053 } 1055 }
1054 } 1056 }
1055 1057
1056 priv->frag_len += msdu_size; 1058 priv->frag_len += msdu_size;
1057 priv->frag_no++; 1059 priv->frag_no++;
1058 1060
@@ -1062,60 +1064,60 @@ static void frag_rx_path(struct atmel_private *priv, struct ieee80211_hdr_4addr
1062 priv->stats.rx_dropped++; 1064 priv->stats.rx_dropped++;
1063 } else { 1065 } else {
1064 skb_reserve(skb, 2); 1066 skb_reserve(skb, 2);
1065 memcpy(skb_put(skb, priv->frag_len + 12), 1067 memcpy(skb_put(skb, priv->frag_len + 12),
1066 priv->rx_buf, 1068 priv->rx_buf,
1067 priv->frag_len + 12); 1069 priv->frag_len + 12);
1068 priv->dev->last_rx = jiffies; 1070 priv->dev->last_rx = jiffies;
1069 skb->dev = priv->dev; 1071 skb->dev = priv->dev;
1070 skb->protocol = eth_type_trans(skb, priv->dev); 1072 skb->protocol = eth_type_trans(skb, priv->dev);
1071 skb->ip_summed = CHECKSUM_NONE; 1073 skb->ip_summed = CHECKSUM_NONE;
1072 netif_rx(skb); 1074 netif_rx(skb);
1073 priv->stats.rx_bytes += priv->frag_len + 12; 1075 priv->stats.rx_bytes += priv->frag_len + 12;
1074 priv->stats.rx_packets++; 1076 priv->stats.rx_packets++;
1075 } 1077 }
1076 } 1078 }
1077
1078 } else 1079 } else
1079 priv->wstats.discard.fragment++; 1080 priv->wstats.discard.fragment++;
1080} 1081}
1081 1082
1082static void rx_done_irq(struct atmel_private *priv) 1083static void rx_done_irq(struct atmel_private *priv)
1083{ 1084{
1084 int i; 1085 int i;
1085 struct ieee80211_hdr_4addr header; 1086 struct ieee80211_hdr_4addr header;
1086 1087
1087 for (i = 0; 1088 for (i = 0;
1088 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID && 1089 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID &&
1089 i < priv->host_info.rx_desc_count; 1090 i < priv->host_info.rx_desc_count;
1090 i++) { 1091 i++) {
1091 1092
1092 u16 msdu_size, rx_packet_loc, frame_ctl, seq_control; 1093 u16 msdu_size, rx_packet_loc, frame_ctl, seq_control;
1093 u8 status = atmel_rmem8(priv, atmel_rx(priv, RX_DESC_STATUS_OFFSET, priv->rx_desc_head)); 1094 u8 status = atmel_rmem8(priv, atmel_rx(priv, RX_DESC_STATUS_OFFSET, priv->rx_desc_head));
1094 u32 crc = 0xffffffff; 1095 u32 crc = 0xffffffff;
1095 1096
1096 if (status != RX_STATUS_SUCCESS) { 1097 if (status != RX_STATUS_SUCCESS) {
1097 if (status == 0xc1) /* determined by experiment */ 1098 if (status == 0xc1) /* determined by experiment */
1098 priv->wstats.discard.nwid++; 1099 priv->wstats.discard.nwid++;
1099 else 1100 else
1100 priv->stats.rx_errors++; 1101 priv->stats.rx_errors++;
1101 goto next; 1102 goto next;
1102 } 1103 }
1103 1104
1104 msdu_size = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_SIZE_OFFSET, priv->rx_desc_head)); 1105 msdu_size = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_SIZE_OFFSET, priv->rx_desc_head));
1105 rx_packet_loc = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_POS_OFFSET, priv->rx_desc_head)); 1106 rx_packet_loc = atmel_rmem16(priv, atmel_rx(priv, RX_DESC_MSDU_POS_OFFSET, priv->rx_desc_head));
1106 1107
1107 if (msdu_size < 30) { 1108 if (msdu_size < 30) {
1108 priv->stats.rx_errors++; 1109 priv->stats.rx_errors++;
1109 goto next; 1110 goto next;
1110 } 1111 }
1111 1112
1112 /* Get header as far as end of seq_ctl */ 1113 /* Get header as far as end of seq_ctl */
1113 atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24); 1114 atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24);
1114 frame_ctl = le16_to_cpu(header.frame_ctl); 1115 frame_ctl = le16_to_cpu(header.frame_ctl);
1115 seq_control = le16_to_cpu(header.seq_ctl); 1116 seq_control = le16_to_cpu(header.seq_ctl);
1116 1117
1117 /* probe for CRC use here if needed once five packets have arrived with 1118 /* probe for CRC use here if needed once five packets have
1118 the same crc status, we assume we know what's happening and stop probing */ 1119 arrived with the same crc status, we assume we know what's
1120 happening and stop probing */
1119 if (priv->probe_crc) { 1121 if (priv->probe_crc) {
1120 if (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED)) { 1122 if (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED)) {
1121 priv->do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size); 1123 priv->do_rx_crc = probe_crc(priv, rx_packet_loc, msdu_size);
@@ -1130,34 +1132,33 @@ static void rx_done_irq(struct atmel_private *priv)
1130 priv->probe_crc = 0; 1132 priv->probe_crc = 0;
1131 } 1133 }
1132 } 1134 }
1133 1135
1134 /* don't CRC header when WEP in use */ 1136 /* don't CRC header when WEP in use */
1135 if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED))) { 1137 if (priv->do_rx_crc && (!priv->wep_is_on || !(frame_ctl & IEEE80211_FCTL_PROTECTED))) {
1136 crc = crc32_le(0xffffffff, (unsigned char *)&header, 24); 1138 crc = crc32_le(0xffffffff, (unsigned char *)&header, 24);
1137 } 1139 }
1138 msdu_size -= 24; /* header */ 1140 msdu_size -= 24; /* header */
1139 1141
1140 if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) { 1142 if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) {
1141
1142 int more_fragments = frame_ctl & IEEE80211_FCTL_MOREFRAGS; 1143 int more_fragments = frame_ctl & IEEE80211_FCTL_MOREFRAGS;
1143 u8 packet_fragment_no = seq_control & IEEE80211_SCTL_FRAG; 1144 u8 packet_fragment_no = seq_control & IEEE80211_SCTL_FRAG;
1144 u16 packet_sequence_no = (seq_control & IEEE80211_SCTL_SEQ) >> 4; 1145 u16 packet_sequence_no = (seq_control & IEEE80211_SCTL_SEQ) >> 4;
1145 1146
1146 if (!more_fragments && packet_fragment_no == 0 ) { 1147 if (!more_fragments && packet_fragment_no == 0) {
1147 fast_rx_path(priv, &header, msdu_size, rx_packet_loc, crc); 1148 fast_rx_path(priv, &header, msdu_size, rx_packet_loc, crc);
1148 } else { 1149 } else {
1149 frag_rx_path(priv, &header, msdu_size, rx_packet_loc, crc, 1150 frag_rx_path(priv, &header, msdu_size, rx_packet_loc, crc,
1150 packet_sequence_no, packet_fragment_no, more_fragments); 1151 packet_sequence_no, packet_fragment_no, more_fragments);
1151 } 1152 }
1152 } 1153 }
1153 1154
1154 if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) { 1155 if ((frame_ctl & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) {
1155 /* copy rest of packet into buffer */ 1156 /* copy rest of packet into buffer */
1156 atmel_copy_to_host(priv->dev, (unsigned char *)&priv->rx_buf, rx_packet_loc + 24, msdu_size); 1157 atmel_copy_to_host(priv->dev, (unsigned char *)&priv->rx_buf, rx_packet_loc + 24, msdu_size);
1157 1158
1158 /* we use the same buffer for frag reassembly and control packets */ 1159 /* we use the same buffer for frag reassembly and control packets */
1159 memset(priv->frag_source, 0xff, 6); 1160 memset(priv->frag_source, 0xff, 6);
1160 1161
1161 if (priv->do_rx_crc) { 1162 if (priv->do_rx_crc) {
1162 /* last 4 octets is crc */ 1163 /* last 4 octets is crc */
1163 msdu_size -= 4; 1164 msdu_size -= 4;
@@ -1170,18 +1171,18 @@ static void rx_done_irq(struct atmel_private *priv)
1170 1171
1171 atmel_management_frame(priv, &header, msdu_size, 1172 atmel_management_frame(priv, &header, msdu_size,
1172 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_RSSI_OFFSET, priv->rx_desc_head))); 1173 atmel_rmem8(priv, atmel_rx(priv, RX_DESC_RSSI_OFFSET, priv->rx_desc_head)));
1173 } 1174 }
1174 1175
1175 next: 1176next:
1176 /* release descriptor */ 1177 /* release descriptor */
1177 atmel_wmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head), RX_DESC_FLAG_CONSUMED); 1178 atmel_wmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head), RX_DESC_FLAG_CONSUMED);
1178 1179
1179 if (priv->rx_desc_head < (priv->host_info.rx_desc_count - 1)) 1180 if (priv->rx_desc_head < (priv->host_info.rx_desc_count - 1))
1180 priv->rx_desc_head++; 1181 priv->rx_desc_head++;
1181 else 1182 else
1182 priv->rx_desc_head = 0; 1183 priv->rx_desc_head = 0;
1183 } 1184 }
1184} 1185}
1185 1186
1186static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs) 1187static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1187{ 1188{
@@ -1189,7 +1190,7 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs
1189 struct atmel_private *priv = netdev_priv(dev); 1190 struct atmel_private *priv = netdev_priv(dev);
1190 u8 isr; 1191 u8 isr;
1191 int i = -1; 1192 int i = -1;
1192 static u8 irq_order[] = { 1193 static u8 irq_order[] = {
1193 ISR_OUT_OF_RANGE, 1194 ISR_OUT_OF_RANGE,
1194 ISR_RxCOMPLETE, 1195 ISR_RxCOMPLETE,
1195 ISR_TxCOMPLETE, 1196 ISR_TxCOMPLETE,
@@ -1199,20 +1200,19 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs
1199 ISR_IBSS_MERGE, 1200 ISR_IBSS_MERGE,
1200 ISR_GENERIC_IRQ 1201 ISR_GENERIC_IRQ
1201 }; 1202 };
1202
1203 1203
1204 if (priv->card && priv->present_callback && 1204 if (priv->card && priv->present_callback &&
1205 !(*priv->present_callback)(priv->card)) 1205 !(*priv->present_callback)(priv->card))
1206 return IRQ_HANDLED; 1206 return IRQ_HANDLED;
1207 1207
1208 /* In this state upper-level code assumes it can mess with 1208 /* In this state upper-level code assumes it can mess with
1209 the card unhampered by interrupts which may change register state. 1209 the card unhampered by interrupts which may change register state.
1210 Note that even though the card shouldn't generate interrupts 1210 Note that even though the card shouldn't generate interrupts
1211 the inturrupt line may be shared. This allows card setup 1211 the inturrupt line may be shared. This allows card setup
1212 to go on without disabling interrupts for a long time. */ 1212 to go on without disabling interrupts for a long time. */
1213 if (priv->station_state == STATION_STATE_DOWN) 1213 if (priv->station_state == STATION_STATE_DOWN)
1214 return IRQ_NONE; 1214 return IRQ_NONE;
1215 1215
1216 atmel_clear_gcr(dev, GCR_ENINT); /* disable interrupts */ 1216 atmel_clear_gcr(dev, GCR_ENINT); /* disable interrupts */
1217 1217
1218 while (1) { 1218 while (1) {
@@ -1221,36 +1221,36 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs
1221 printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name); 1221 printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name);
1222 return IRQ_HANDLED; 1222 return IRQ_HANDLED;
1223 } 1223 }
1224 1224
1225 isr = atmel_rmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET)); 1225 isr = atmel_rmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET));
1226 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0); 1226 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0);
1227 1227
1228 if (!isr) { 1228 if (!isr) {
1229 atmel_set_gcr(dev, GCR_ENINT); /* enable interrupts */ 1229 atmel_set_gcr(dev, GCR_ENINT); /* enable interrupts */
1230 return i == -1 ? IRQ_NONE : IRQ_HANDLED; 1230 return i == -1 ? IRQ_NONE : IRQ_HANDLED;
1231 } 1231 }
1232 1232
1233 atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */ 1233 atmel_set_gcr(dev, GCR_ACKINT); /* acknowledge interrupt */
1234 1234
1235 for (i = 0; i < sizeof(irq_order)/sizeof(u8); i++) 1235 for (i = 0; i < sizeof(irq_order)/sizeof(u8); i++)
1236 if (isr & irq_order[i]) 1236 if (isr & irq_order[i])
1237 break; 1237 break;
1238 1238
1239 if (!atmel_lock_mac(priv)) { 1239 if (!atmel_lock_mac(priv)) {
1240 /* failed to contact card */ 1240 /* failed to contact card */
1241 printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name); 1241 printk(KERN_ALERT "%s: failed to contact MAC.\n", dev->name);
1242 return IRQ_HANDLED; 1242 return IRQ_HANDLED;
1243 } 1243 }
1244 1244
1245 isr = atmel_rmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET)); 1245 isr = atmel_rmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET));
1246 isr ^= irq_order[i]; 1246 isr ^= irq_order[i];
1247 atmel_wmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET), isr); 1247 atmel_wmem8(priv, atmel_hi(priv, IFACE_INT_STATUS_OFFSET), isr);
1248 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0); 1248 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0);
1249 1249
1250 switch (irq_order[i]) { 1250 switch (irq_order[i]) {
1251 1251
1252 case ISR_OUT_OF_RANGE: 1252 case ISR_OUT_OF_RANGE:
1253 if (priv->operating_mode == IW_MODE_INFRA && 1253 if (priv->operating_mode == IW_MODE_INFRA &&
1254 priv->station_state == STATION_STATE_READY) { 1254 priv->station_state == STATION_STATE_READY) {
1255 priv->station_is_associated = 0; 1255 priv->station_is_associated = 0;
1256 atmel_scan(priv, 1); 1256 atmel_scan(priv, 1);
@@ -1261,24 +1261,24 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs
1261 priv->wstats.discard.misc++; 1261 priv->wstats.discard.misc++;
1262 /* fall through */ 1262 /* fall through */
1263 case ISR_RxCOMPLETE: 1263 case ISR_RxCOMPLETE:
1264 rx_done_irq(priv); 1264 rx_done_irq(priv);
1265 break; 1265 break;
1266 1266
1267 case ISR_TxCOMPLETE: 1267 case ISR_TxCOMPLETE:
1268 tx_done_irq(priv); 1268 tx_done_irq(priv);
1269 break; 1269 break;
1270 1270
1271 case ISR_FATAL_ERROR: 1271 case ISR_FATAL_ERROR:
1272 printk(KERN_ALERT "%s: *** FATAL error interrupt ***\n", dev->name); 1272 printk(KERN_ALERT "%s: *** FATAL error interrupt ***\n", dev->name);
1273 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); 1273 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
1274 break; 1274 break;
1275 1275
1276 case ISR_COMMAND_COMPLETE: 1276 case ISR_COMMAND_COMPLETE:
1277 atmel_command_irq(priv); 1277 atmel_command_irq(priv);
1278 break; 1278 break;
1279 1279
1280 case ISR_IBSS_MERGE: 1280 case ISR_IBSS_MERGE:
1281 atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS, 1281 atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS,
1282 priv->CurrentBSSID, 6); 1282 priv->CurrentBSSID, 6);
1283 /* The WPA stuff cares about the current AP address */ 1283 /* The WPA stuff cares about the current AP address */
1284 if (priv->use_wpa) 1284 if (priv->use_wpa)
@@ -1288,24 +1288,23 @@ static irqreturn_t service_interrupt(int irq, void *dev_id, struct pt_regs *regs
1288 printk(KERN_INFO "%s: Generic_irq received.\n", dev->name); 1288 printk(KERN_INFO "%s: Generic_irq received.\n", dev->name);
1289 break; 1289 break;
1290 } 1290 }
1291 } 1291 }
1292} 1292}
1293 1293
1294 1294static struct net_device_stats *atmel_get_stats(struct net_device *dev)
1295static struct net_device_stats *atmel_get_stats (struct net_device *dev)
1296{ 1295{
1297 struct atmel_private *priv = netdev_priv(dev); 1296 struct atmel_private *priv = netdev_priv(dev);
1298 return &priv->stats; 1297 return &priv->stats;
1299} 1298}
1300 1299
1301static struct iw_statistics *atmel_get_wireless_stats (struct net_device *dev) 1300static struct iw_statistics *atmel_get_wireless_stats(struct net_device *dev)
1302{ 1301{
1303 struct atmel_private *priv = netdev_priv(dev); 1302 struct atmel_private *priv = netdev_priv(dev);
1304 1303
1305 /* update the link quality here in case we are seeing no beacons 1304 /* update the link quality here in case we are seeing no beacons
1306 at all to drive the process */ 1305 at all to drive the process */
1307 atmel_smooth_qual(priv); 1306 atmel_smooth_qual(priv);
1308 1307
1309 priv->wstats.status = priv->station_state; 1308 priv->wstats.status = priv->station_state;
1310 1309
1311 if (priv->operating_mode == IW_MODE_INFRA) { 1310 if (priv->operating_mode == IW_MODE_INFRA) {
@@ -1328,8 +1327,8 @@ static struct iw_statistics *atmel_get_wireless_stats (struct net_device *dev)
1328 | IW_QUAL_NOISE_INVALID; 1327 | IW_QUAL_NOISE_INVALID;
1329 priv->wstats.miss.beacon = 0; 1328 priv->wstats.miss.beacon = 0;
1330 } 1329 }
1331 1330
1332 return (&priv->wstats); 1331 return &priv->wstats;
1333} 1332}
1334 1333
1335static int atmel_change_mtu(struct net_device *dev, int new_mtu) 1334static int atmel_change_mtu(struct net_device *dev, int new_mtu)
@@ -1343,21 +1342,21 @@ static int atmel_change_mtu(struct net_device *dev, int new_mtu)
1343static int atmel_set_mac_address(struct net_device *dev, void *p) 1342static int atmel_set_mac_address(struct net_device *dev, void *p)
1344{ 1343{
1345 struct sockaddr *addr = p; 1344 struct sockaddr *addr = p;
1346 1345
1347 memcpy (dev->dev_addr, addr->sa_data, dev->addr_len); 1346 memcpy (dev->dev_addr, addr->sa_data, dev->addr_len);
1348 return atmel_open(dev); 1347 return atmel_open(dev);
1349} 1348}
1350 1349
1351EXPORT_SYMBOL(atmel_open); 1350EXPORT_SYMBOL(atmel_open);
1352 1351
1353int atmel_open (struct net_device *dev) 1352int atmel_open(struct net_device *dev)
1354{ 1353{
1355 struct atmel_private *priv = netdev_priv(dev); 1354 struct atmel_private *priv = netdev_priv(dev);
1356 int i, channel; 1355 int i, channel;
1357 1356
1358 /* any scheduled timer is no longer needed and might screw things up.. */ 1357 /* any scheduled timer is no longer needed and might screw things up.. */
1359 del_timer_sync(&priv->management_timer); 1358 del_timer_sync(&priv->management_timer);
1360 1359
1361 /* Interrupts will not touch the card once in this state... */ 1360 /* Interrupts will not touch the card once in this state... */
1362 priv->station_state = STATION_STATE_DOWN; 1361 priv->station_state = STATION_STATE_DOWN;
1363 1362
@@ -1377,7 +1376,7 @@ int atmel_open (struct net_device *dev)
1377 priv->site_survey_state = SITE_SURVEY_IDLE; 1376 priv->site_survey_state = SITE_SURVEY_IDLE;
1378 priv->station_is_associated = 0; 1377 priv->station_is_associated = 0;
1379 1378
1380 if (!reset_atmel_card(dev)) 1379 if (!reset_atmel_card(dev))
1381 return -EAGAIN; 1380 return -EAGAIN;
1382 1381
1383 if (priv->config_reg_domain) { 1382 if (priv->config_reg_domain) {
@@ -1391,26 +1390,26 @@ int atmel_open (struct net_device *dev)
1391 if (i == sizeof(channel_table)/sizeof(channel_table[0])) { 1390 if (i == sizeof(channel_table)/sizeof(channel_table[0])) {
1392 priv->reg_domain = REG_DOMAIN_MKK1; 1391 priv->reg_domain = REG_DOMAIN_MKK1;
1393 printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name); 1392 printk(KERN_ALERT "%s: failed to get regulatory domain: assuming MKK1.\n", dev->name);
1394 } 1393 }
1395 } 1394 }
1396 1395
1397 if ((channel = atmel_validate_channel(priv, priv->channel))) 1396 if ((channel = atmel_validate_channel(priv, priv->channel)))
1398 priv->channel = channel; 1397 priv->channel = channel;
1399 1398
1400 /* this moves station_state on.... */ 1399 /* this moves station_state on.... */
1401 atmel_scan(priv, 1); 1400 atmel_scan(priv, 1);
1402 1401
1403 atmel_set_gcr(priv->dev, GCR_ENINT); /* enable interrupts */ 1402 atmel_set_gcr(priv->dev, GCR_ENINT); /* enable interrupts */
1404 return 0; 1403 return 0;
1405} 1404}
1406 1405
1407static int atmel_close (struct net_device *dev) 1406static int atmel_close(struct net_device *dev)
1408{ 1407{
1409 struct atmel_private *priv = netdev_priv(dev); 1408 struct atmel_private *priv = netdev_priv(dev);
1410 1409
1411 atmel_enter_state(priv, STATION_STATE_DOWN); 1410 atmel_enter_state(priv, STATION_STATE_DOWN);
1412 1411
1413 if (priv->bus_type == BUS_TYPE_PCCARD) 1412 if (priv->bus_type == BUS_TYPE_PCCARD)
1414 atmel_write16(dev, GCR, 0x0060); 1413 atmel_write16(dev, GCR, 0x0060);
1415 atmel_write16(dev, GCR, 0x0040); 1414 atmel_write16(dev, GCR, 0x0040);
1416 return 0; 1415 return 0;
@@ -1438,43 +1437,46 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv)
1438 int i; 1437 int i;
1439 char *p = buf; 1438 char *p = buf;
1440 char *s, *r, *c; 1439 char *s, *r, *c;
1441 1440
1442 p += sprintf(p, "Driver version:\t\t%d.%d\n", DRIVER_MAJOR, DRIVER_MINOR); 1441 p += sprintf(p, "Driver version:\t\t%d.%d\n",
1443 1442 DRIVER_MAJOR, DRIVER_MINOR);
1443
1444 if (priv->station_state != STATION_STATE_DOWN) { 1444 if (priv->station_state != STATION_STATE_DOWN) {
1445 p += sprintf(p, "Firmware version:\t%d.%d build %d\nFirmware location:\t", 1445 p += sprintf(p, "Firmware version:\t%d.%d build %d\n"
1446 "Firmware location:\t",
1446 priv->host_info.major_version, 1447 priv->host_info.major_version,
1447 priv->host_info.minor_version, 1448 priv->host_info.minor_version,
1448 priv->host_info.build_version); 1449 priv->host_info.build_version);
1449 1450
1450 if (priv->card_type != CARD_TYPE_EEPROM) 1451 if (priv->card_type != CARD_TYPE_EEPROM)
1451 p += sprintf(p, "on card\n"); 1452 p += sprintf(p, "on card\n");
1452 else if (priv->firmware) 1453 else if (priv->firmware)
1453 p += sprintf(p, "%s loaded by host\n", priv->firmware_id); 1454 p += sprintf(p, "%s loaded by host\n",
1455 priv->firmware_id);
1454 else 1456 else
1455 p += sprintf(p, "%s loaded by hotplug\n", priv->firmware_id); 1457 p += sprintf(p, "%s loaded by hotplug\n",
1456 1458 priv->firmware_id);
1457 switch(priv->card_type) { 1459
1460 switch (priv->card_type) {
1458 case CARD_TYPE_PARALLEL_FLASH: c = "Parallel flash"; break; 1461 case CARD_TYPE_PARALLEL_FLASH: c = "Parallel flash"; break;
1459 case CARD_TYPE_SPI_FLASH: c = "SPI flash\n"; break; 1462 case CARD_TYPE_SPI_FLASH: c = "SPI flash\n"; break;
1460 case CARD_TYPE_EEPROM: c = "EEPROM"; break; 1463 case CARD_TYPE_EEPROM: c = "EEPROM"; break;
1461 default: c = "<unknown>"; 1464 default: c = "<unknown>";
1462 } 1465 }
1463 1466
1464
1465 r = "<unknown>"; 1467 r = "<unknown>";
1466 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++) 1468 for (i = 0; i < sizeof(channel_table)/sizeof(channel_table[0]); i++)
1467 if (priv->reg_domain == channel_table[i].reg_domain) 1469 if (priv->reg_domain == channel_table[i].reg_domain)
1468 r = channel_table[i].name; 1470 r = channel_table[i].name;
1469 1471
1470 p += sprintf(p, "MAC memory type:\t%s\n", c); 1472 p += sprintf(p, "MAC memory type:\t%s\n", c);
1471 p += sprintf(p, "Regulatory domain:\t%s\n", r); 1473 p += sprintf(p, "Regulatory domain:\t%s\n", r);
1472 p += sprintf(p, "Host CRC checking:\t%s\n", 1474 p += sprintf(p, "Host CRC checking:\t%s\n",
1473 priv->do_rx_crc ? "On" : "Off"); 1475 priv->do_rx_crc ? "On" : "Off");
1474 p += sprintf(p, "WPA-capable firmware:\t%s\n", 1476 p += sprintf(p, "WPA-capable firmware:\t%s\n",
1475 priv->use_wpa ? "Yes" : "No"); 1477 priv->use_wpa ? "Yes" : "No");
1476 } 1478 }
1477 1479
1478 switch(priv->station_state) { 1480 switch(priv->station_state) {
1479 case STATION_STATE_SCANNING: s = "Scanning"; break; 1481 case STATION_STATE_SCANNING: s = "Scanning"; break;
1480 case STATION_STATE_JOINNING: s = "Joining"; break; 1482 case STATION_STATE_JOINNING: s = "Joining"; break;
@@ -1486,9 +1488,9 @@ static int atmel_proc_output (char *buf, struct atmel_private *priv)
1486 case STATION_STATE_DOWN: s = "Down"; break; 1488 case STATION_STATE_DOWN: s = "Down"; break;
1487 default: s = "<unknown>"; 1489 default: s = "<unknown>";
1488 } 1490 }
1489 1491
1490 p += sprintf(p, "Current state:\t\t%s\n", s); 1492 p += sprintf(p, "Current state:\t\t%s\n", s);
1491 return p - buf; 1493 return p - buf;
1492} 1494}
1493 1495
1494static int atmel_read_proc(char *page, char **start, off_t off, 1496static int atmel_read_proc(char *page, char **start, off_t off,
@@ -1504,9 +1506,12 @@ static int atmel_read_proc(char *page, char **start, off_t off,
1504 return len; 1506 return len;
1505} 1507}
1506 1508
1507struct net_device *init_atmel_card( unsigned short irq, unsigned long port, const AtmelFWType fw_type, 1509struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
1508 struct device *sys_dev, int (*card_present)(void *), void *card) 1510 const AtmelFWType fw_type,
1511 struct device *sys_dev,
1512 int (*card_present)(void *), void *card)
1509{ 1513{
1514 struct proc_dir_entry *ent;
1510 struct net_device *dev; 1515 struct net_device *dev;
1511 struct atmel_private *priv; 1516 struct atmel_private *priv;
1512 int rc; 1517 int rc;
@@ -1514,11 +1519,11 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons
1514 /* Create the network device object. */ 1519 /* Create the network device object. */
1515 dev = alloc_etherdev(sizeof(*priv)); 1520 dev = alloc_etherdev(sizeof(*priv));
1516 if (!dev) { 1521 if (!dev) {
1517 printk(KERN_ERR "atmel: Couldn't alloc_etherdev\n"); 1522 printk(KERN_ERR "atmel: Couldn't alloc_etherdev\n");
1518 return NULL; 1523 return NULL;
1519 } 1524 }
1520 if (dev_alloc_name(dev, dev->name) < 0) { 1525 if (dev_alloc_name(dev, dev->name) < 0) {
1521 printk(KERN_ERR "atmel: Couldn't get name!\n"); 1526 printk(KERN_ERR "atmel: Couldn't get name!\n");
1522 goto err_out_free; 1527 goto err_out_free;
1523 } 1528 }
1524 1529
@@ -1550,7 +1555,7 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons
1550 memset(priv->BSSID, 0, 6); 1555 memset(priv->BSSID, 0, 6);
1551 priv->CurrentBSSID[0] = 0xFF; /* Initialize to something invalid.... */ 1556 priv->CurrentBSSID[0] = 0xFF; /* Initialize to something invalid.... */
1552 priv->station_was_associated = 0; 1557 priv->station_was_associated = 0;
1553 1558
1554 priv->last_survey = jiffies; 1559 priv->last_survey = jiffies;
1555 priv->preamble = LONG_PREAMBLE; 1560 priv->preamble = LONG_PREAMBLE;
1556 priv->operating_mode = IW_MODE_INFRA; 1561 priv->operating_mode = IW_MODE_INFRA;
@@ -1586,7 +1591,7 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons
1586 spin_lock_init(&priv->timerlock); 1591 spin_lock_init(&priv->timerlock);
1587 priv->management_timer.function = atmel_management_timer; 1592 priv->management_timer.function = atmel_management_timer;
1588 priv->management_timer.data = (unsigned long) dev; 1593 priv->management_timer.data = (unsigned long) dev;
1589 1594
1590 dev->open = atmel_open; 1595 dev->open = atmel_open;
1591 dev->stop = atmel_close; 1596 dev->stop = atmel_close;
1592 dev->change_mtu = atmel_change_mtu; 1597 dev->change_mtu = atmel_change_mtu;
@@ -1597,44 +1602,46 @@ struct net_device *init_atmel_card( unsigned short irq, unsigned long port, cons
1597 dev->do_ioctl = atmel_ioctl; 1602 dev->do_ioctl = atmel_ioctl;
1598 dev->irq = irq; 1603 dev->irq = irq;
1599 dev->base_addr = port; 1604 dev->base_addr = port;
1600 1605
1601 SET_NETDEV_DEV(dev, sys_dev); 1606 SET_NETDEV_DEV(dev, sys_dev);
1602 1607
1603 if ((rc = request_irq(dev->irq, service_interrupt, SA_SHIRQ, dev->name, dev))) { 1608 if ((rc = request_irq(dev->irq, service_interrupt, SA_SHIRQ, dev->name, dev))) {
1604 printk(KERN_ERR "%s: register interrupt %d failed, rc %d\n", dev->name, irq, rc ); 1609 printk(KERN_ERR "%s: register interrupt %d failed, rc %d\n", dev->name, irq, rc);
1605 goto err_out_free; 1610 goto err_out_free;
1606 } 1611 }
1607 1612
1608 if (!request_region(dev->base_addr, 32, 1613 if (!request_region(dev->base_addr, 32,
1609 priv->bus_type == BUS_TYPE_PCCARD ? "atmel_cs" : "atmel_pci")) { 1614 priv->bus_type == BUS_TYPE_PCCARD ? "atmel_cs" : "atmel_pci")) {
1610 goto err_out_irq; 1615 goto err_out_irq;
1611 } 1616 }
1612 1617
1613 if (register_netdev(dev)) 1618 if (register_netdev(dev))
1614 goto err_out_res; 1619 goto err_out_res;
1615 1620
1616 if (!probe_atmel_card(dev)){ 1621 if (!probe_atmel_card(dev)){
1617 unregister_netdev(dev); 1622 unregister_netdev(dev);
1618 goto err_out_res; 1623 goto err_out_res;
1619 } 1624 }
1620 1625
1621 netif_carrier_off(dev); 1626 netif_carrier_off(dev);
1622 1627
1623 create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); 1628 ent = create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv);
1624 1629 if (!ent)
1630 printk(KERN_WARNING "atmel: unable to create /proc entry.\n");
1631
1625 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", 1632 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
1626 dev->name, DRIVER_MAJOR, DRIVER_MINOR, 1633 dev->name, DRIVER_MAJOR, DRIVER_MINOR,
1627 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], 1634 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
1628 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] ); 1635 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] );
1629 1636
1630 SET_MODULE_OWNER(dev); 1637 SET_MODULE_OWNER(dev);
1631 return dev; 1638 return dev;
1632 1639
1633 err_out_res: 1640err_out_res:
1634 release_region( dev->base_addr, 32); 1641 release_region( dev->base_addr, 32);
1635 err_out_irq: 1642err_out_irq:
1636 free_irq(dev->irq, dev); 1643 free_irq(dev->irq, dev);
1637 err_out_free: 1644err_out_free:
1638 free_netdev(dev); 1645 free_netdev(dev);
1639 return NULL; 1646 return NULL;
1640} 1647}
@@ -1644,12 +1651,12 @@ EXPORT_SYMBOL(init_atmel_card);
1644void stop_atmel_card(struct net_device *dev) 1651void stop_atmel_card(struct net_device *dev)
1645{ 1652{
1646 struct atmel_private *priv = netdev_priv(dev); 1653 struct atmel_private *priv = netdev_priv(dev);
1647 1654
1648 /* put a brick on it... */ 1655 /* put a brick on it... */
1649 if (priv->bus_type == BUS_TYPE_PCCARD) 1656 if (priv->bus_type == BUS_TYPE_PCCARD)
1650 atmel_write16(dev, GCR, 0x0060); 1657 atmel_write16(dev, GCR, 0x0060);
1651 atmel_write16(dev, GCR, 0x0040); 1658 atmel_write16(dev, GCR, 0x0040);
1652 1659
1653 del_timer_sync(&priv->management_timer); 1660 del_timer_sync(&priv->management_timer);
1654 unregister_netdev(dev); 1661 unregister_netdev(dev);
1655 remove_proc_entry("driver/atmel", NULL); 1662 remove_proc_entry("driver/atmel", NULL);
@@ -1675,13 +1682,13 @@ static int atmel_set_essid(struct net_device *dev,
1675 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 1682 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1676 1683
1677 priv->connect_to_any_BSS = 0; 1684 priv->connect_to_any_BSS = 0;
1678 1685
1679 /* Check the size of the string */ 1686 /* Check the size of the string */
1680 if (dwrq->length > MAX_SSID_LENGTH + 1) 1687 if (dwrq->length > MAX_SSID_LENGTH + 1)
1681 return -E2BIG ; 1688 return -E2BIG;
1682 if (index != 0) 1689 if (index != 0)
1683 return -EINVAL; 1690 return -EINVAL;
1684 1691
1685 memcpy(priv->new_SSID, extra, dwrq->length - 1); 1692 memcpy(priv->new_SSID, extra, dwrq->length - 1);
1686 priv->new_SSID_size = dwrq->length - 1; 1693 priv->new_SSID_size = dwrq->length - 1;
1687 } 1694 }
@@ -1706,7 +1713,7 @@ static int atmel_get_essid(struct net_device *dev,
1706 extra[priv->SSID_size] = '\0'; 1713 extra[priv->SSID_size] = '\0';
1707 dwrq->length = priv->SSID_size + 1; 1714 dwrq->length = priv->SSID_size + 1;
1708 } 1715 }
1709 1716
1710 dwrq->flags = !priv->connect_to_any_BSS; /* active */ 1717 dwrq->flags = !priv->connect_to_any_BSS; /* active */
1711 1718
1712 return 0; 1719 return 0;
@@ -1768,7 +1775,7 @@ static int atmel_set_encode(struct net_device *dev,
1768 /* WE specify that if a valid key is set, encryption 1775 /* WE specify that if a valid key is set, encryption
1769 * should be enabled (user may turn it off later) 1776 * should be enabled (user may turn it off later)
1770 * This is also how "iwconfig ethX key on" works */ 1777 * This is also how "iwconfig ethX key on" works */
1771 if (index == current_index && 1778 if (index == current_index &&
1772 priv->wep_key_len[index] > 0) { 1779 priv->wep_key_len[index] > 0) {
1773 priv->wep_is_on = 1; 1780 priv->wep_is_on = 1;
1774 priv->exclude_unencrypted = 1; 1781 priv->exclude_unencrypted = 1;
@@ -1783,18 +1790,18 @@ static int atmel_set_encode(struct net_device *dev,
1783 } else { 1790 } else {
1784 /* Do we want to just set the transmit key index ? */ 1791 /* Do we want to just set the transmit key index ? */
1785 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 1792 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1786 if ( index>=0 && index < 4 ) { 1793 if (index >= 0 && index < 4) {
1787 priv->default_key = index; 1794 priv->default_key = index;
1788 } else 1795 } else
1789 /* Don't complain if only change the mode */ 1796 /* Don't complain if only change the mode */
1790 if(!dwrq->flags & IW_ENCODE_MODE) { 1797 if (!dwrq->flags & IW_ENCODE_MODE) {
1791 return -EINVAL; 1798 return -EINVAL;
1792 } 1799 }
1793 } 1800 }
1794 /* Read the flags */ 1801 /* Read the flags */
1795 if(dwrq->flags & IW_ENCODE_DISABLED) { 1802 if (dwrq->flags & IW_ENCODE_DISABLED) {
1796 priv->wep_is_on = 0; 1803 priv->wep_is_on = 0;
1797 priv->encryption_level = 0; 1804 priv->encryption_level = 0;
1798 priv->pairwise_cipher_suite = CIPHER_SUITE_NONE; 1805 priv->pairwise_cipher_suite = CIPHER_SUITE_NONE;
1799 } else { 1806 } else {
1800 priv->wep_is_on = 1; 1807 priv->wep_is_on = 1;
@@ -1806,15 +1813,14 @@ static int atmel_set_encode(struct net_device *dev,
1806 priv->encryption_level = 1; 1813 priv->encryption_level = 1;
1807 } 1814 }
1808 } 1815 }
1809 if(dwrq->flags & IW_ENCODE_RESTRICTED) 1816 if (dwrq->flags & IW_ENCODE_RESTRICTED)
1810 priv->exclude_unencrypted = 1; 1817 priv->exclude_unencrypted = 1;
1811 if(dwrq->flags & IW_ENCODE_OPEN) 1818 if(dwrq->flags & IW_ENCODE_OPEN)
1812 priv->exclude_unencrypted = 0; 1819 priv->exclude_unencrypted = 0;
1813 1820
1814 return -EINPROGRESS; /* Call commit handler */ 1821 return -EINPROGRESS; /* Call commit handler */
1815} 1822}
1816 1823
1817
1818static int atmel_get_encode(struct net_device *dev, 1824static int atmel_get_encode(struct net_device *dev,
1819 struct iw_request_info *info, 1825 struct iw_request_info *info,
1820 struct iw_point *dwrq, 1826 struct iw_point *dwrq,
@@ -1822,7 +1828,7 @@ static int atmel_get_encode(struct net_device *dev,
1822{ 1828{
1823 struct atmel_private *priv = netdev_priv(dev); 1829 struct atmel_private *priv = netdev_priv(dev);
1824 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 1830 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1825 1831
1826 if (!priv->wep_is_on) 1832 if (!priv->wep_is_on)
1827 dwrq->flags = IW_ENCODE_DISABLED; 1833 dwrq->flags = IW_ENCODE_DISABLED;
1828 else { 1834 else {
@@ -1843,7 +1849,7 @@ static int atmel_get_encode(struct net_device *dev,
1843 memset(extra, 0, 16); 1849 memset(extra, 0, 16);
1844 memcpy(extra, priv->wep_keys[index], dwrq->length); 1850 memcpy(extra, priv->wep_keys[index], dwrq->length);
1845 } 1851 }
1846 1852
1847 return 0; 1853 return 0;
1848} 1854}
1849 1855
@@ -1862,17 +1868,17 @@ static int atmel_set_rate(struct net_device *dev,
1862 char *extra) 1868 char *extra)
1863{ 1869{
1864 struct atmel_private *priv = netdev_priv(dev); 1870 struct atmel_private *priv = netdev_priv(dev);
1865 1871
1866 if (vwrq->fixed == 0) { 1872 if (vwrq->fixed == 0) {
1867 priv->tx_rate = 3; 1873 priv->tx_rate = 3;
1868 priv->auto_tx_rate = 1; 1874 priv->auto_tx_rate = 1;
1869 } else { 1875 } else {
1870 priv->auto_tx_rate = 0; 1876 priv->auto_tx_rate = 0;
1871 1877
1872 /* Which type of value ? */ 1878 /* Which type of value ? */
1873 if((vwrq->value < 4) && (vwrq->value >= 0)) { 1879 if ((vwrq->value < 4) && (vwrq->value >= 0)) {
1874 /* Setting by rate index */ 1880 /* Setting by rate index */
1875 priv->tx_rate = vwrq->value; 1881 priv->tx_rate = vwrq->value;
1876 } else { 1882 } else {
1877 /* Setting by frequency value */ 1883 /* Setting by frequency value */
1878 switch (vwrq->value) { 1884 switch (vwrq->value) {
@@ -1899,7 +1905,7 @@ static int atmel_set_mode(struct net_device *dev,
1899 return -EINVAL; 1905 return -EINVAL;
1900 1906
1901 priv->operating_mode = *uwrq; 1907 priv->operating_mode = *uwrq;
1902 return -EINPROGRESS; 1908 return -EINPROGRESS;
1903} 1909}
1904 1910
1905static int atmel_get_mode(struct net_device *dev, 1911static int atmel_get_mode(struct net_device *dev,
@@ -1908,7 +1914,7 @@ static int atmel_get_mode(struct net_device *dev,
1908 char *extra) 1914 char *extra)
1909{ 1915{
1910 struct atmel_private *priv = netdev_priv(dev); 1916 struct atmel_private *priv = netdev_priv(dev);
1911 1917
1912 *uwrq = priv->operating_mode; 1918 *uwrq = priv->operating_mode;
1913 return 0; 1919 return 0;
1914} 1920}
@@ -1962,9 +1968,9 @@ static int atmel_set_retry(struct net_device *dev,
1962 char *extra) 1968 char *extra)
1963{ 1969{
1964 struct atmel_private *priv = netdev_priv(dev); 1970 struct atmel_private *priv = netdev_priv(dev);
1965 1971
1966 if(!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) { 1972 if (!vwrq->disabled && (vwrq->flags & IW_RETRY_LIMIT)) {
1967 if(vwrq->flags & IW_RETRY_MAX) 1973 if (vwrq->flags & IW_RETRY_MAX)
1968 priv->long_retry = vwrq->value; 1974 priv->long_retry = vwrq->value;
1969 else if (vwrq->flags & IW_RETRY_MIN) 1975 else if (vwrq->flags & IW_RETRY_MIN)
1970 priv->short_retry = vwrq->value; 1976 priv->short_retry = vwrq->value;
@@ -1973,9 +1979,9 @@ static int atmel_set_retry(struct net_device *dev,
1973 priv->long_retry = vwrq->value; 1979 priv->long_retry = vwrq->value;
1974 priv->short_retry = vwrq->value; 1980 priv->short_retry = vwrq->value;
1975 } 1981 }
1976 return -EINPROGRESS; 1982 return -EINPROGRESS;
1977 } 1983 }
1978 1984
1979 return -EINVAL; 1985 return -EINVAL;
1980} 1986}
1981 1987
@@ -1989,13 +1995,13 @@ static int atmel_get_retry(struct net_device *dev,
1989 vwrq->disabled = 0; /* Can't be disabled */ 1995 vwrq->disabled = 0; /* Can't be disabled */
1990 1996
1991 /* Note : by default, display the min retry number */ 1997 /* Note : by default, display the min retry number */
1992 if((vwrq->flags & IW_RETRY_MAX)) { 1998 if (vwrq->flags & IW_RETRY_MAX) {
1993 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX; 1999 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1994 vwrq->value = priv->long_retry; 2000 vwrq->value = priv->long_retry;
1995 } else { 2001 } else {
1996 vwrq->flags = IW_RETRY_LIMIT; 2002 vwrq->flags = IW_RETRY_LIMIT;
1997 vwrq->value = priv->short_retry; 2003 vwrq->value = priv->short_retry;
1998 if(priv->long_retry != priv->short_retry) 2004 if (priv->long_retry != priv->short_retry)
1999 vwrq->flags |= IW_RETRY_MIN; 2005 vwrq->flags |= IW_RETRY_MIN;
2000 } 2006 }
2001 2007
@@ -2010,13 +2016,13 @@ static int atmel_set_rts(struct net_device *dev,
2010 struct atmel_private *priv = netdev_priv(dev); 2016 struct atmel_private *priv = netdev_priv(dev);
2011 int rthr = vwrq->value; 2017 int rthr = vwrq->value;
2012 2018
2013 if(vwrq->disabled) 2019 if (vwrq->disabled)
2014 rthr = 2347; 2020 rthr = 2347;
2015 if((rthr < 0) || (rthr > 2347)) { 2021 if ((rthr < 0) || (rthr > 2347)) {
2016 return -EINVAL; 2022 return -EINVAL;
2017 } 2023 }
2018 priv->rts_threshold = rthr; 2024 priv->rts_threshold = rthr;
2019 2025
2020 return -EINPROGRESS; /* Call commit handler */ 2026 return -EINPROGRESS; /* Call commit handler */
2021} 2027}
2022 2028
@@ -2026,7 +2032,7 @@ static int atmel_get_rts(struct net_device *dev,
2026 char *extra) 2032 char *extra)
2027{ 2033{
2028 struct atmel_private *priv = netdev_priv(dev); 2034 struct atmel_private *priv = netdev_priv(dev);
2029 2035
2030 vwrq->value = priv->rts_threshold; 2036 vwrq->value = priv->rts_threshold;
2031 vwrq->disabled = (vwrq->value >= 2347); 2037 vwrq->disabled = (vwrq->value >= 2347);
2032 vwrq->fixed = 1; 2038 vwrq->fixed = 1;
@@ -2042,14 +2048,14 @@ static int atmel_set_frag(struct net_device *dev,
2042 struct atmel_private *priv = netdev_priv(dev); 2048 struct atmel_private *priv = netdev_priv(dev);
2043 int fthr = vwrq->value; 2049 int fthr = vwrq->value;
2044 2050
2045 if(vwrq->disabled) 2051 if (vwrq->disabled)
2046 fthr = 2346; 2052 fthr = 2346;
2047 if((fthr < 256) || (fthr > 2346)) { 2053 if ((fthr < 256) || (fthr > 2346)) {
2048 return -EINVAL; 2054 return -EINVAL;
2049 } 2055 }
2050 fthr &= ~0x1; /* Get an even value - is it really needed ??? */ 2056 fthr &= ~0x1; /* Get an even value - is it really needed ??? */
2051 priv->frag_threshold = fthr; 2057 priv->frag_threshold = fthr;
2052 2058
2053 return -EINPROGRESS; /* Call commit handler */ 2059 return -EINPROGRESS; /* Call commit handler */
2054} 2060}
2055 2061
@@ -2077,21 +2083,21 @@ static int atmel_set_freq(struct net_device *dev,
2077{ 2083{
2078 struct atmel_private *priv = netdev_priv(dev); 2084 struct atmel_private *priv = netdev_priv(dev);
2079 int rc = -EINPROGRESS; /* Call commit handler */ 2085 int rc = -EINPROGRESS; /* Call commit handler */
2080 2086
2081 /* If setting by frequency, convert to a channel */ 2087 /* If setting by frequency, convert to a channel */
2082 if((fwrq->e == 1) && 2088 if ((fwrq->e == 1) &&
2083 (fwrq->m >= (int) 241200000) && 2089 (fwrq->m >= (int) 241200000) &&
2084 (fwrq->m <= (int) 248700000)) { 2090 (fwrq->m <= (int) 248700000)) {
2085 int f = fwrq->m / 100000; 2091 int f = fwrq->m / 100000;
2086 int c = 0; 2092 int c = 0;
2087 while((c < 14) && (f != frequency_list[c])) 2093 while ((c < 14) && (f != frequency_list[c]))
2088 c++; 2094 c++;
2089 /* Hack to fall through... */ 2095 /* Hack to fall through... */
2090 fwrq->e = 0; 2096 fwrq->e = 0;
2091 fwrq->m = c + 1; 2097 fwrq->m = c + 1;
2092 } 2098 }
2093 /* Setting by channel number */ 2099 /* Setting by channel number */
2094 if((fwrq->m > 1000) || (fwrq->e > 0)) 2100 if ((fwrq->m > 1000) || (fwrq->e > 0))
2095 rc = -EOPNOTSUPP; 2101 rc = -EOPNOTSUPP;
2096 else { 2102 else {
2097 int channel = fwrq->m; 2103 int channel = fwrq->m;
@@ -2099,7 +2105,7 @@ static int atmel_set_freq(struct net_device *dev,
2099 priv->channel = channel; 2105 priv->channel = channel;
2100 } else { 2106 } else {
2101 rc = -EINVAL; 2107 rc = -EINVAL;
2102 } 2108 }
2103 } 2109 }
2104 return rc; 2110 return rc;
2105} 2111}
@@ -2130,7 +2136,7 @@ static int atmel_set_scan(struct net_device *dev,
2130 * This is not an error, while the device perform scanning, 2136 * This is not an error, while the device perform scanning,
2131 * traffic doesn't flow, so it's a perfect DoS... 2137 * traffic doesn't flow, so it's a perfect DoS...
2132 * Jean II */ 2138 * Jean II */
2133 2139
2134 if (priv->station_state == STATION_STATE_DOWN) 2140 if (priv->station_state == STATION_STATE_DOWN)
2135 return -EAGAIN; 2141 return -EAGAIN;
2136 2142
@@ -2142,15 +2148,15 @@ static int atmel_set_scan(struct net_device *dev,
2142 /* Initiate a scan command */ 2148 /* Initiate a scan command */
2143 if (priv->site_survey_state == SITE_SURVEY_IN_PROGRESS) 2149 if (priv->site_survey_state == SITE_SURVEY_IN_PROGRESS)
2144 return -EBUSY; 2150 return -EBUSY;
2145 2151
2146 del_timer_sync(&priv->management_timer); 2152 del_timer_sync(&priv->management_timer);
2147 spin_lock_irqsave(&priv->irqlock, flags); 2153 spin_lock_irqsave(&priv->irqlock, flags);
2148 2154
2149 priv->site_survey_state = SITE_SURVEY_IN_PROGRESS; 2155 priv->site_survey_state = SITE_SURVEY_IN_PROGRESS;
2150 priv->fast_scan = 0; 2156 priv->fast_scan = 0;
2151 atmel_scan(priv, 0); 2157 atmel_scan(priv, 0);
2152 spin_unlock_irqrestore(&priv->irqlock, flags); 2158 spin_unlock_irqrestore(&priv->irqlock, flags);
2153 2159
2154 return 0; 2160 return 0;
2155} 2161}
2156 2162
@@ -2163,11 +2169,11 @@ static int atmel_get_scan(struct net_device *dev,
2163 int i; 2169 int i;
2164 char *current_ev = extra; 2170 char *current_ev = extra;
2165 struct iw_event iwe; 2171 struct iw_event iwe;
2166 2172
2167 if (priv->site_survey_state != SITE_SURVEY_COMPLETED) 2173 if (priv->site_survey_state != SITE_SURVEY_COMPLETED)
2168 return -EAGAIN; 2174 return -EAGAIN;
2169 2175
2170 for(i=0; i<priv->BSS_list_entries; i++) { 2176 for (i = 0; i < priv->BSS_list_entries; i++) {
2171 iwe.cmd = SIOCGIWAP; 2177 iwe.cmd = SIOCGIWAP;
2172 iwe.u.ap_addr.sa_family = ARPHRD_ETHER; 2178 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
2173 memcpy(iwe.u.ap_addr.sa_data, priv->BSSinfo[i].BSSID, 6); 2179 memcpy(iwe.u.ap_addr.sa_data, priv->BSSinfo[i].BSSID, 6);
@@ -2179,16 +2185,16 @@ static int atmel_get_scan(struct net_device *dev,
2179 iwe.cmd = SIOCGIWESSID; 2185 iwe.cmd = SIOCGIWESSID;
2180 iwe.u.data.flags = 1; 2186 iwe.u.data.flags = 1;
2181 current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, priv->BSSinfo[i].SSID); 2187 current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, priv->BSSinfo[i].SSID);
2182 2188
2183 iwe.cmd = SIOCGIWMODE; 2189 iwe.cmd = SIOCGIWMODE;
2184 iwe.u.mode = priv->BSSinfo[i].BSStype; 2190 iwe.u.mode = priv->BSSinfo[i].BSStype;
2185 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_UINT_LEN); 2191 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_UINT_LEN);
2186 2192
2187 iwe.cmd = SIOCGIWFREQ; 2193 iwe.cmd = SIOCGIWFREQ;
2188 iwe.u.freq.m = priv->BSSinfo[i].channel; 2194 iwe.u.freq.m = priv->BSSinfo[i].channel;
2189 iwe.u.freq.e = 0; 2195 iwe.u.freq.e = 0;
2190 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN); 2196 current_ev = iwe_stream_add_event(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, IW_EV_FREQ_LEN);
2191 2197
2192 iwe.cmd = SIOCGIWENCODE; 2198 iwe.cmd = SIOCGIWENCODE;
2193 if (priv->BSSinfo[i].UsingWEP) 2199 if (priv->BSSinfo[i].UsingWEP)
2194 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; 2200 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
@@ -2196,13 +2202,12 @@ static int atmel_get_scan(struct net_device *dev,
2196 iwe.u.data.flags = IW_ENCODE_DISABLED; 2202 iwe.u.data.flags = IW_ENCODE_DISABLED;
2197 iwe.u.data.length = 0; 2203 iwe.u.data.length = 0;
2198 current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, NULL); 2204 current_ev = iwe_stream_add_point(current_ev, extra + IW_SCAN_MAX_DATA, &iwe, NULL);
2199
2200 } 2205 }
2201 2206
2202 /* Length of data */ 2207 /* Length of data */
2203 dwrq->length = (current_ev - extra); 2208 dwrq->length = (current_ev - extra);
2204 dwrq->flags = 0; 2209 dwrq->flags = 0;
2205 2210
2206 return 0; 2211 return 0;
2207} 2212}
2208 2213
@@ -2213,7 +2218,7 @@ static int atmel_get_range(struct net_device *dev,
2213{ 2218{
2214 struct atmel_private *priv = netdev_priv(dev); 2219 struct atmel_private *priv = netdev_priv(dev);
2215 struct iw_range *range = (struct iw_range *) extra; 2220 struct iw_range *range = (struct iw_range *) extra;
2216 int k,i,j; 2221 int k, i, j;
2217 2222
2218 dwrq->length = sizeof(struct iw_range); 2223 dwrq->length = sizeof(struct iw_range);
2219 memset(range, 0, sizeof(struct iw_range)); 2224 memset(range, 0, sizeof(struct iw_range));
@@ -2226,14 +2231,14 @@ static int atmel_get_range(struct net_device *dev,
2226 break; 2231 break;
2227 } 2232 }
2228 if (range->num_channels != 0) { 2233 if (range->num_channels != 0) {
2229 for(k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) { 2234 for (k = 0, i = channel_table[j].min; i <= channel_table[j].max; i++) {
2230 range->freq[k].i = i; /* List index */ 2235 range->freq[k].i = i; /* List index */
2231 range->freq[k].m = frequency_list[i-1] * 100000; 2236 range->freq[k].m = frequency_list[i - 1] * 100000;
2232 range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */ 2237 range->freq[k++].e = 1; /* Values in table in MHz -> * 10^5 * 10 */
2233 } 2238 }
2234 range->num_frequency = k; 2239 range->num_frequency = k;
2235 } 2240 }
2236 2241
2237 range->max_qual.qual = 100; 2242 range->max_qual.qual = 100;
2238 range->max_qual.level = 100; 2243 range->max_qual.level = 100;
2239 range->max_qual.noise = 0; 2244 range->max_qual.noise = 0;
@@ -2261,11 +2266,11 @@ static int atmel_get_range(struct net_device *dev,
2261 range->encoding_size[1] = 13; 2266 range->encoding_size[1] = 13;
2262 range->num_encoding_sizes = 2; 2267 range->num_encoding_sizes = 2;
2263 range->max_encoding_tokens = 4; 2268 range->max_encoding_tokens = 4;
2264 2269
2265 range->pmp_flags = IW_POWER_ON; 2270 range->pmp_flags = IW_POWER_ON;
2266 range->pmt_flags = IW_POWER_ON; 2271 range->pmt_flags = IW_POWER_ON;
2267 range->pm_capa = 0; 2272 range->pm_capa = 0;
2268 2273
2269 range->we_version_source = WIRELESS_EXT; 2274 range->we_version_source = WIRELESS_EXT;
2270 range->we_version_compiled = WIRELESS_EXT; 2275 range->we_version_compiled = WIRELESS_EXT;
2271 range->retry_capa = IW_RETRY_LIMIT ; 2276 range->retry_capa = IW_RETRY_LIMIT ;
@@ -2289,7 +2294,7 @@ static int atmel_set_wap(struct net_device *dev,
2289 2294
2290 if (awrq->sa_family != ARPHRD_ETHER) 2295 if (awrq->sa_family != ARPHRD_ETHER)
2291 return -EINVAL; 2296 return -EINVAL;
2292 2297
2293 if (memcmp(bcast, awrq->sa_data, 6) == 0) { 2298 if (memcmp(bcast, awrq->sa_data, 6) == 0) {
2294 del_timer_sync(&priv->management_timer); 2299 del_timer_sync(&priv->management_timer);
2295 spin_lock_irqsave(&priv->irqlock, flags); 2300 spin_lock_irqsave(&priv->irqlock, flags);
@@ -2297,8 +2302,8 @@ static int atmel_set_wap(struct net_device *dev,
2297 spin_unlock_irqrestore(&priv->irqlock, flags); 2302 spin_unlock_irqrestore(&priv->irqlock, flags);
2298 return 0; 2303 return 0;
2299 } 2304 }
2300 2305
2301 for(i=0; i<priv->BSS_list_entries; i++) { 2306 for (i = 0; i < priv->BSS_list_entries; i++) {
2302 if (memcmp(priv->BSSinfo[i].BSSID, awrq->sa_data, 6) == 0) { 2307 if (memcmp(priv->BSSinfo[i].BSSID, awrq->sa_data, 6) == 0) {
2303 if (!priv->wep_is_on && priv->BSSinfo[i].UsingWEP) { 2308 if (!priv->wep_is_on && priv->BSSinfo[i].UsingWEP) {
2304 return -EINVAL; 2309 return -EINVAL;
@@ -2313,10 +2318,10 @@ static int atmel_set_wap(struct net_device *dev,
2313 } 2318 }
2314 } 2319 }
2315 } 2320 }
2316 2321
2317 return -EINVAL; 2322 return -EINVAL;
2318} 2323}
2319 2324
2320static int atmel_config_commit(struct net_device *dev, 2325static int atmel_config_commit(struct net_device *dev,
2321 struct iw_request_info *info, /* NULL */ 2326 struct iw_request_info *info, /* NULL */
2322 void *zwrq, /* NULL */ 2327 void *zwrq, /* NULL */
@@ -2325,18 +2330,18 @@ static int atmel_config_commit(struct net_device *dev,
2325 return atmel_open(dev); 2330 return atmel_open(dev);
2326} 2331}
2327 2332
2328static const iw_handler atmel_handler[] = 2333static const iw_handler atmel_handler[] =
2329{ 2334{
2330 (iw_handler) atmel_config_commit, /* SIOCSIWCOMMIT */ 2335 (iw_handler) atmel_config_commit, /* SIOCSIWCOMMIT */
2331 (iw_handler) atmel_get_name, /* SIOCGIWNAME */ 2336 (iw_handler) atmel_get_name, /* SIOCGIWNAME */
2332 (iw_handler) NULL, /* SIOCSIWNWID */ 2337 (iw_handler) NULL, /* SIOCSIWNWID */
2333 (iw_handler) NULL, /* SIOCGIWNWID */ 2338 (iw_handler) NULL, /* SIOCGIWNWID */
2334 (iw_handler) atmel_set_freq, /* SIOCSIWFREQ */ 2339 (iw_handler) atmel_set_freq, /* SIOCSIWFREQ */
2335 (iw_handler) atmel_get_freq, /* SIOCGIWFREQ */ 2340 (iw_handler) atmel_get_freq, /* SIOCGIWFREQ */
2336 (iw_handler) atmel_set_mode, /* SIOCSIWMODE */ 2341 (iw_handler) atmel_set_mode, /* SIOCSIWMODE */
2337 (iw_handler) atmel_get_mode, /* SIOCGIWMODE */ 2342 (iw_handler) atmel_get_mode, /* SIOCGIWMODE */
2338 (iw_handler) NULL, /* SIOCSIWSENS */ 2343 (iw_handler) NULL, /* SIOCSIWSENS */
2339 (iw_handler) NULL, /* SIOCGIWSENS */ 2344 (iw_handler) NULL, /* SIOCGIWSENS */
2340 (iw_handler) NULL, /* SIOCSIWRANGE */ 2345 (iw_handler) NULL, /* SIOCSIWRANGE */
2341 (iw_handler) atmel_get_range, /* SIOCGIWRANGE */ 2346 (iw_handler) atmel_get_range, /* SIOCGIWRANGE */
2342 (iw_handler) NULL, /* SIOCSIWPRIV */ 2347 (iw_handler) NULL, /* SIOCSIWPRIV */
@@ -2350,13 +2355,13 @@ static const iw_handler atmel_handler[] =
2350 (iw_handler) atmel_set_wap, /* SIOCSIWAP */ 2355 (iw_handler) atmel_set_wap, /* SIOCSIWAP */
2351 (iw_handler) atmel_get_wap, /* SIOCGIWAP */ 2356 (iw_handler) atmel_get_wap, /* SIOCGIWAP */
2352 (iw_handler) NULL, /* -- hole -- */ 2357 (iw_handler) NULL, /* -- hole -- */
2353 (iw_handler) NULL, /* SIOCGIWAPLIST */ 2358 (iw_handler) NULL, /* SIOCGIWAPLIST */
2354 (iw_handler) atmel_set_scan, /* SIOCSIWSCAN */ 2359 (iw_handler) atmel_set_scan, /* SIOCSIWSCAN */
2355 (iw_handler) atmel_get_scan, /* SIOCGIWSCAN */ 2360 (iw_handler) atmel_get_scan, /* SIOCGIWSCAN */
2356 (iw_handler) atmel_set_essid, /* SIOCSIWESSID */ 2361 (iw_handler) atmel_set_essid, /* SIOCSIWESSID */
2357 (iw_handler) atmel_get_essid, /* SIOCGIWESSID */ 2362 (iw_handler) atmel_get_essid, /* SIOCGIWESSID */
2358 (iw_handler) NULL, /* SIOCSIWNICKN */ 2363 (iw_handler) NULL, /* SIOCSIWNICKN */
2359 (iw_handler) NULL, /* SIOCGIWNICKN */ 2364 (iw_handler) NULL, /* SIOCGIWNICKN */
2360 (iw_handler) NULL, /* -- hole -- */ 2365 (iw_handler) NULL, /* -- hole -- */
2361 (iw_handler) NULL, /* -- hole -- */ 2366 (iw_handler) NULL, /* -- hole -- */
2362 (iw_handler) atmel_set_rate, /* SIOCSIWRATE */ 2367 (iw_handler) atmel_set_rate, /* SIOCSIWRATE */
@@ -2365,8 +2370,8 @@ static const iw_handler atmel_handler[] =
2365 (iw_handler) atmel_get_rts, /* SIOCGIWRTS */ 2370 (iw_handler) atmel_get_rts, /* SIOCGIWRTS */
2366 (iw_handler) atmel_set_frag, /* SIOCSIWFRAG */ 2371 (iw_handler) atmel_set_frag, /* SIOCSIWFRAG */
2367 (iw_handler) atmel_get_frag, /* SIOCGIWFRAG */ 2372 (iw_handler) atmel_get_frag, /* SIOCGIWFRAG */
2368 (iw_handler) NULL, /* SIOCSIWTXPOW */ 2373 (iw_handler) NULL, /* SIOCSIWTXPOW */
2369 (iw_handler) NULL, /* SIOCGIWTXPOW */ 2374 (iw_handler) NULL, /* SIOCGIWTXPOW */
2370 (iw_handler) atmel_set_retry, /* SIOCSIWRETRY */ 2375 (iw_handler) atmel_set_retry, /* SIOCSIWRETRY */
2371 (iw_handler) atmel_get_retry, /* SIOCGIWRETRY */ 2376 (iw_handler) atmel_get_retry, /* SIOCGIWRETRY */
2372 (iw_handler) atmel_set_encode, /* SIOCSIWENCODE */ 2377 (iw_handler) atmel_set_encode, /* SIOCSIWENCODE */
@@ -2375,39 +2380,51 @@ static const iw_handler atmel_handler[] =
2375 (iw_handler) atmel_get_power, /* SIOCGIWPOWER */ 2380 (iw_handler) atmel_get_power, /* SIOCGIWPOWER */
2376}; 2381};
2377 2382
2378 2383static const iw_handler atmel_private_handler[] =
2379static const iw_handler atmel_private_handler[] =
2380{ 2384{
2381 NULL, /* SIOCIWFIRSTPRIV */ 2385 NULL, /* SIOCIWFIRSTPRIV */
2382}; 2386};
2383 2387
2384typedef struct atmel_priv_ioctl { 2388typedef struct atmel_priv_ioctl {
2385 char id[32]; 2389 char id[32];
2386 unsigned char __user *data; 2390 unsigned char __user *data;
2387 unsigned short len; 2391 unsigned short len;
2388} atmel_priv_ioctl; 2392} atmel_priv_ioctl;
2389 2393
2390 2394#define ATMELFWL SIOCIWFIRSTPRIV
2391#define ATMELFWL SIOCIWFIRSTPRIV 2395#define ATMELIDIFC ATMELFWL + 1
2392#define ATMELIDIFC ATMELFWL + 1 2396#define ATMELRD ATMELFWL + 2
2393#define ATMELRD ATMELFWL + 2 2397#define ATMELMAGIC 0x51807
2394#define ATMELMAGIC 0x51807
2395#define REGDOMAINSZ 20 2398#define REGDOMAINSZ 20
2396 2399
2397static const struct iw_priv_args atmel_private_args[] = { 2400static const struct iw_priv_args atmel_private_args[] = {
2398/*{ cmd, set_args, get_args, name } */ 2401 {
2399 { ATMELFWL, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | sizeof (atmel_priv_ioctl), IW_PRIV_TYPE_NONE, "atmelfwl" }, 2402 .cmd = ATMELFWL,
2400 { ATMELIDIFC, IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "atmelidifc" }, 2403 .set_args = IW_PRIV_TYPE_BYTE
2401 { ATMELRD, IW_PRIV_TYPE_CHAR | REGDOMAINSZ, IW_PRIV_TYPE_NONE, "regdomain" }, 2404 | IW_PRIV_SIZE_FIXED
2405 | sizeof (atmel_priv_ioctl),
2406 .get_args = IW_PRIV_TYPE_NONE,
2407 .name = "atmelfwl"
2408 }, {
2409 .cmd = ATMELIDIFC,
2410 .set_args = IW_PRIV_TYPE_NONE,
2411 .get_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2412 .name = "atmelidifc"
2413 }, {
2414 .cmd = ATMELRD,
2415 .set_args = IW_PRIV_TYPE_CHAR | REGDOMAINSZ,
2416 .get_args = IW_PRIV_TYPE_NONE,
2417 .name = "regdomain"
2418 },
2402}; 2419};
2403 2420
2404static const struct iw_handler_def atmel_handler_def = 2421static const struct iw_handler_def atmel_handler_def =
2405{ 2422{
2406 .num_standard = sizeof(atmel_handler)/sizeof(iw_handler), 2423 .num_standard = sizeof(atmel_handler)/sizeof(iw_handler),
2407 .num_private = sizeof(atmel_private_handler)/sizeof(iw_handler), 2424 .num_private = sizeof(atmel_private_handler)/sizeof(iw_handler),
2408 .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args), 2425 .num_private_args = sizeof(atmel_private_args)/sizeof(struct iw_priv_args),
2409 .standard = (iw_handler *) atmel_handler, 2426 .standard = (iw_handler *) atmel_handler,
2410 .private = (iw_handler *) atmel_private_handler, 2427 .private = (iw_handler *) atmel_private_handler,
2411 .private_args = (struct iw_priv_args *) atmel_private_args, 2428 .private_args = (struct iw_priv_args *) atmel_private_args,
2412 .get_wireless_stats = atmel_get_wireless_stats 2429 .get_wireless_stats = atmel_get_wireless_stats
2413}; 2430};
@@ -2419,13 +2436,13 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2419 atmel_priv_ioctl com; 2436 atmel_priv_ioctl com;
2420 struct iwreq *wrq = (struct iwreq *) rq; 2437 struct iwreq *wrq = (struct iwreq *) rq;
2421 unsigned char *new_firmware; 2438 unsigned char *new_firmware;
2422 char domain[REGDOMAINSZ+1]; 2439 char domain[REGDOMAINSZ + 1];
2423 2440
2424 switch (cmd) { 2441 switch (cmd) {
2425 case ATMELIDIFC: 2442 case ATMELIDIFC:
2426 wrq->u.param.value = ATMELMAGIC; 2443 wrq->u.param.value = ATMELMAGIC;
2427 break; 2444 break;
2428 2445
2429 case ATMELFWL: 2446 case ATMELFWL:
2430 if (copy_from_user(&com, rq->ifr_data, sizeof(com))) { 2447 if (copy_from_user(&com, rq->ifr_data, sizeof(com))) {
2431 rc = -EFAULT; 2448 rc = -EFAULT;
@@ -2449,7 +2466,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2449 } 2466 }
2450 2467
2451 kfree(priv->firmware); 2468 kfree(priv->firmware);
2452 2469
2453 priv->firmware = new_firmware; 2470 priv->firmware = new_firmware;
2454 priv->firmware_length = com.len; 2471 priv->firmware_length = com.len;
2455 strncpy(priv->firmware_id, com.id, 31); 2472 strncpy(priv->firmware_id, com.id, 31);
@@ -2461,7 +2478,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2461 rc = -EFAULT; 2478 rc = -EFAULT;
2462 break; 2479 break;
2463 } 2480 }
2464 2481
2465 if (!capable(CAP_NET_ADMIN)) { 2482 if (!capable(CAP_NET_ADMIN)) {
2466 rc = -EPERM; 2483 rc = -EPERM;
2467 break; 2484 break;
@@ -2484,15 +2501,15 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2484 rc = 0; 2501 rc = 0;
2485 } 2502 }
2486 } 2503 }
2487 2504
2488 if (rc == 0 && priv->station_state != STATION_STATE_DOWN) 2505 if (rc == 0 && priv->station_state != STATION_STATE_DOWN)
2489 rc = atmel_open(dev); 2506 rc = atmel_open(dev);
2490 break; 2507 break;
2491 2508
2492 default: 2509 default:
2493 rc = -EOPNOTSUPP; 2510 rc = -EOPNOTSUPP;
2494 } 2511 }
2495 2512
2496 return rc; 2513 return rc;
2497} 2514}
2498 2515
@@ -2503,17 +2520,17 @@ struct auth_body {
2503 u8 el_id; 2520 u8 el_id;
2504 u8 chall_text_len; 2521 u8 chall_text_len;
2505 u8 chall_text[253]; 2522 u8 chall_text[253];
2506}; 2523};
2507 2524
2508static void atmel_enter_state(struct atmel_private *priv, int new_state) 2525static void atmel_enter_state(struct atmel_private *priv, int new_state)
2509{ 2526{
2510 int old_state = priv->station_state; 2527 int old_state = priv->station_state;
2511 2528
2512 if (new_state == old_state) 2529 if (new_state == old_state)
2513 return; 2530 return;
2514 2531
2515 priv->station_state = new_state; 2532 priv->station_state = new_state;
2516 2533
2517 if (new_state == STATION_STATE_READY) { 2534 if (new_state == STATION_STATE_READY) {
2518 netif_start_queue(priv->dev); 2535 netif_start_queue(priv->dev);
2519 netif_carrier_on(priv->dev); 2536 netif_carrier_on(priv->dev);
@@ -2540,7 +2557,7 @@ static void atmel_scan(struct atmel_private *priv, int specific_ssid)
2540 u8 options; 2557 u8 options;
2541 u8 SSID_size; 2558 u8 SSID_size;
2542 } cmd; 2559 } cmd;
2543 2560
2544 memset(cmd.BSSID, 0xff, 6); 2561 memset(cmd.BSSID, 0xff, 6);
2545 2562
2546 if (priv->fast_scan) { 2563 if (priv->fast_scan) {
@@ -2554,17 +2571,17 @@ static void atmel_scan(struct atmel_private *priv, int specific_ssid)
2554 cmd.min_channel_time = cpu_to_le16(10); 2571 cmd.min_channel_time = cpu_to_le16(10);
2555 cmd.max_channel_time = cpu_to_le16(120); 2572 cmd.max_channel_time = cpu_to_le16(120);
2556 } 2573 }
2557 2574
2558 cmd.options = 0; 2575 cmd.options = 0;
2559 2576
2560 if (!specific_ssid) 2577 if (!specific_ssid)
2561 cmd.options |= SCAN_OPTIONS_SITE_SURVEY; 2578 cmd.options |= SCAN_OPTIONS_SITE_SURVEY;
2562 2579
2563 cmd.channel = (priv->channel & 0x7f); 2580 cmd.channel = (priv->channel & 0x7f);
2564 cmd.scan_type = SCAN_TYPE_ACTIVE; 2581 cmd.scan_type = SCAN_TYPE_ACTIVE;
2565 cmd.BSS_type = cpu_to_le16(priv->operating_mode == IW_MODE_ADHOC ? 2582 cmd.BSS_type = cpu_to_le16(priv->operating_mode == IW_MODE_ADHOC ?
2566 BSS_TYPE_AD_HOC : BSS_TYPE_INFRASTRUCTURE); 2583 BSS_TYPE_AD_HOC : BSS_TYPE_INFRASTRUCTURE);
2567 2584
2568 atmel_send_command(priv, CMD_Scan, &cmd, sizeof(cmd)); 2585 atmel_send_command(priv, CMD_Scan, &cmd, sizeof(cmd));
2569 2586
2570 /* This must come after all hardware access to avoid being messed up 2587 /* This must come after all hardware access to avoid being messed up
@@ -2591,16 +2608,15 @@ static void join(struct atmel_private *priv, int type)
2591 cmd.BSS_type = type; 2608 cmd.BSS_type = type;
2592 cmd.timeout = cpu_to_le16(2000); 2609 cmd.timeout = cpu_to_le16(2000);
2593 2610
2594 atmel_send_command(priv, CMD_Join, &cmd, sizeof(cmd)); 2611 atmel_send_command(priv, CMD_Join, &cmd, sizeof(cmd));
2595} 2612}
2596 2613
2597
2598static void start(struct atmel_private *priv, int type) 2614static void start(struct atmel_private *priv, int type)
2599{ 2615{
2600 struct { 2616 struct {
2601 u8 BSSID[6]; 2617 u8 BSSID[6];
2602 u8 SSID[MAX_SSID_LENGTH]; 2618 u8 SSID[MAX_SSID_LENGTH];
2603 u8 BSS_type; 2619 u8 BSS_type;
2604 u8 channel; 2620 u8 channel;
2605 u8 SSID_size; 2621 u8 SSID_size;
2606 u8 reserved[3]; 2622 u8 reserved[3];
@@ -2612,13 +2628,14 @@ static void start(struct atmel_private *priv, int type)
2612 cmd.BSS_type = type; 2628 cmd.BSS_type = type;
2613 cmd.channel = (priv->channel & 0x7f); 2629 cmd.channel = (priv->channel & 0x7f);
2614 2630
2615 atmel_send_command(priv, CMD_Start, &cmd, sizeof(cmd)); 2631 atmel_send_command(priv, CMD_Start, &cmd, sizeof(cmd));
2616} 2632}
2617 2633
2618static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 channel) 2634static void handle_beacon_probe(struct atmel_private *priv, u16 capability,
2635 u8 channel)
2619{ 2636{
2620 int rejoin = 0; 2637 int rejoin = 0;
2621 int new = capability & C80211_MGMT_CAPABILITY_ShortPreamble ? 2638 int new = capability & C80211_MGMT_CAPABILITY_ShortPreamble ?
2622 SHORT_PREAMBLE : LONG_PREAMBLE; 2639 SHORT_PREAMBLE : LONG_PREAMBLE;
2623 2640
2624 if (priv->preamble != new) { 2641 if (priv->preamble != new) {
@@ -2626,48 +2643,48 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 c
2626 rejoin = 1; 2643 rejoin = 1;
2627 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, new); 2644 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, new);
2628 } 2645 }
2629 2646
2630 if (priv->channel != channel) { 2647 if (priv->channel != channel) {
2631 priv->channel = channel; 2648 priv->channel = channel;
2632 rejoin = 1; 2649 rejoin = 1;
2633 atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_CHANNEL_POS, channel); 2650 atmel_set_mib8(priv, Phy_Mib_Type, PHY_MIB_CHANNEL_POS, channel);
2634 } 2651 }
2635 2652
2636 if (rejoin) { 2653 if (rejoin) {
2637 priv->station_is_associated = 0; 2654 priv->station_is_associated = 0;
2638 atmel_enter_state(priv, STATION_STATE_JOINNING); 2655 atmel_enter_state(priv, STATION_STATE_JOINNING);
2639 2656
2640 if (priv->operating_mode == IW_MODE_INFRA) 2657 if (priv->operating_mode == IW_MODE_INFRA)
2641 join(priv, BSS_TYPE_INFRASTRUCTURE); 2658 join(priv, BSS_TYPE_INFRASTRUCTURE);
2642 else 2659 else
2643 join(priv, BSS_TYPE_AD_HOC); 2660 join(priv, BSS_TYPE_AD_HOC);
2644 } 2661 }
2645} 2662}
2646 2663
2647 2664static void send_authentication_request(struct atmel_private *priv, u16 system,
2648static void send_authentication_request(struct atmel_private *priv, u16 system, u8 *challenge, int challenge_len) 2665 u8 *challenge, int challenge_len)
2649{ 2666{
2650 struct ieee80211_hdr_4addr header; 2667 struct ieee80211_hdr_4addr header;
2651 struct auth_body auth; 2668 struct auth_body auth;
2652 2669
2653 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH); 2670 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
2654 header.duration_id = cpu_to_le16(0x8000); 2671 header.duration_id = cpu_to_le16(0x8000);
2655 header.seq_ctl = 0; 2672 header.seq_ctl = 0;
2656 memcpy(header.addr1, priv->CurrentBSSID, 6); 2673 memcpy(header.addr1, priv->CurrentBSSID, 6);
2657 memcpy(header.addr2, priv->dev->dev_addr, 6); 2674 memcpy(header.addr2, priv->dev->dev_addr, 6);
2658 memcpy(header.addr3, priv->CurrentBSSID, 6); 2675 memcpy(header.addr3, priv->CurrentBSSID, 6);
2659 2676
2660 if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1) 2677 if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1)
2661 /* no WEP for authentication frames with TrSeqNo 1 */ 2678 /* no WEP for authentication frames with TrSeqNo 1 */
2662 header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); 2679 header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
2663 2680
2664 auth.alg = cpu_to_le16(system); 2681 auth.alg = cpu_to_le16(system);
2665 2682
2666 auth.status = 0; 2683 auth.status = 0;
2667 auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum); 2684 auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum);
2668 priv->ExpectedAuthentTransactionSeqNum = priv->CurrentAuthentTransactionSeqNum+1; 2685 priv->ExpectedAuthentTransactionSeqNum = priv->CurrentAuthentTransactionSeqNum+1;
2669 priv->CurrentAuthentTransactionSeqNum += 2; 2686 priv->CurrentAuthentTransactionSeqNum += 2;
2670 2687
2671 if (challenge_len != 0) { 2688 if (challenge_len != 0) {
2672 auth.el_id = 16; /* challenge_text */ 2689 auth.el_id = 16; /* challenge_text */
2673 auth.chall_text_len = challenge_len; 2690 auth.chall_text_len = challenge_len;
@@ -2685,7 +2702,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2685 struct ieee80211_hdr_4addr header; 2702 struct ieee80211_hdr_4addr header;
2686 struct ass_req_format { 2703 struct ass_req_format {
2687 u16 capability; 2704 u16 capability;
2688 u16 listen_interval; 2705 u16 listen_interval;
2689 u8 ap[6]; /* nothing after here directly accessible */ 2706 u8 ap[6]; /* nothing after here directly accessible */
2690 u8 ssid_el_id; 2707 u8 ssid_el_id;
2691 u8 ssid_len; 2708 u8 ssid_len;
@@ -2694,15 +2711,15 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2694 u8 sup_rates_len; 2711 u8 sup_rates_len;
2695 u8 rates[4]; 2712 u8 rates[4];
2696 } body; 2713 } body;
2697 2714
2698 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | 2715 header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
2699 (is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ)); 2716 (is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ));
2700 header.duration_id = cpu_to_le16(0x8000); 2717 header.duration_id = cpu_to_le16(0x8000);
2701 header.seq_ctl = 0; 2718 header.seq_ctl = 0;
2702 2719
2703 memcpy(header.addr1, priv->CurrentBSSID, 6); 2720 memcpy(header.addr1, priv->CurrentBSSID, 6);
2704 memcpy(header.addr2, priv->dev->dev_addr, 6); 2721 memcpy(header.addr2, priv->dev->dev_addr, 6);
2705 memcpy(header.addr3, priv->CurrentBSSID, 6); 2722 memcpy(header.addr3, priv->CurrentBSSID, 6);
2706 2723
2707 body.capability = cpu_to_le16(C80211_MGMT_CAPABILITY_ESS); 2724 body.capability = cpu_to_le16(C80211_MGMT_CAPABILITY_ESS);
2708 if (priv->wep_is_on) 2725 if (priv->wep_is_on)
@@ -2711,18 +2728,18 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2711 body.capability |= cpu_to_le16(C80211_MGMT_CAPABILITY_ShortPreamble); 2728 body.capability |= cpu_to_le16(C80211_MGMT_CAPABILITY_ShortPreamble);
2712 2729
2713 body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period); 2730 body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period);
2714 2731
2715 /* current AP address - only in reassoc frame */ 2732 /* current AP address - only in reassoc frame */
2716 if (is_reassoc) { 2733 if (is_reassoc) {
2717 memcpy(body.ap, priv->CurrentBSSID, 6); 2734 memcpy(body.ap, priv->CurrentBSSID, 6);
2718 ssid_el_p = (u8 *)&body.ssid_el_id; 2735 ssid_el_p = (u8 *)&body.ssid_el_id;
2719 bodysize = 18 + priv->SSID_size; 2736 bodysize = 18 + priv->SSID_size;
2720 } else { 2737 } else {
2721 ssid_el_p = (u8 *)&body.ap[0]; 2738 ssid_el_p = (u8 *)&body.ap[0];
2722 bodysize = 12 + priv->SSID_size; 2739 bodysize = 12 + priv->SSID_size;
2723 } 2740 }
2724 2741
2725 ssid_el_p[0]= C80211_MGMT_ElementID_SSID; 2742 ssid_el_p[0] = C80211_MGMT_ElementID_SSID;
2726 ssid_el_p[1] = priv->SSID_size; 2743 ssid_el_p[1] = priv->SSID_size;
2727 memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size); 2744 memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size);
2728 ssid_el_p[2 + priv->SSID_size] = C80211_MGMT_ElementID_SupportedRates; 2745 ssid_el_p[2 + priv->SSID_size] = C80211_MGMT_ElementID_SupportedRates;
@@ -2732,7 +2749,8 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
2732 atmel_transmit_management_frame(priv, &header, (void *)&body, bodysize); 2749 atmel_transmit_management_frame(priv, &header, (void *)&body, bodysize);
2733} 2750}
2734 2751
2735static int is_frame_from_current_bss(struct atmel_private *priv, struct ieee80211_hdr_4addr *header) 2752static int is_frame_from_current_bss(struct atmel_private *priv,
2753 struct ieee80211_hdr_4addr *header)
2736{ 2754{
2737 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS) 2755 if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
2738 return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0; 2756 return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0;
@@ -2745,29 +2763,29 @@ static int retrieve_bss(struct atmel_private *priv)
2745 int i; 2763 int i;
2746 int max_rssi = -128; 2764 int max_rssi = -128;
2747 int max_index = -1; 2765 int max_index = -1;
2748 2766
2749 if (priv->BSS_list_entries == 0) 2767 if (priv->BSS_list_entries == 0)
2750 return -1; 2768 return -1;
2751 2769
2752 if (priv->connect_to_any_BSS) { 2770 if (priv->connect_to_any_BSS) {
2753 /* Select a BSS with the max-RSSI but of the same type and of the same WEP mode 2771 /* Select a BSS with the max-RSSI but of the same type and of
2754 and that it is not marked as 'bad' (i.e. we had previously failed to connect to 2772 the same WEP mode and that it is not marked as 'bad' (i.e.
2755 this BSS with the settings that we currently use) */ 2773 we had previously failed to connect to this BSS with the
2774 settings that we currently use) */
2756 priv->current_BSS = 0; 2775 priv->current_BSS = 0;
2757 for(i=0; i<priv->BSS_list_entries; i++) { 2776 for (i = 0; i < priv->BSS_list_entries; i++) {
2758 if (priv->operating_mode == priv->BSSinfo[i].BSStype && 2777 if (priv->operating_mode == priv->BSSinfo[i].BSStype &&
2759 ((!priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) || 2778 ((!priv->wep_is_on && !priv->BSSinfo[i].UsingWEP) ||
2760 (priv->wep_is_on && priv->BSSinfo[i].UsingWEP)) && 2779 (priv->wep_is_on && priv->BSSinfo[i].UsingWEP)) &&
2761 !(priv->BSSinfo[i].channel & 0x80)) { 2780 !(priv->BSSinfo[i].channel & 0x80)) {
2762 max_rssi = priv->BSSinfo[i].RSSI; 2781 max_rssi = priv->BSSinfo[i].RSSI;
2763 priv->current_BSS = max_index = i; 2782 priv->current_BSS = max_index = i;
2764 } 2783 }
2765
2766 } 2784 }
2767 return max_index; 2785 return max_index;
2768 } 2786 }
2769 2787
2770 for(i=0; i<priv->BSS_list_entries; i++) { 2788 for (i = 0; i < priv->BSS_list_entries; i++) {
2771 if (priv->SSID_size == priv->BSSinfo[i].SSIDsize && 2789 if (priv->SSID_size == priv->BSSinfo[i].SSIDsize &&
2772 memcmp(priv->SSID, priv->BSSinfo[i].SSID, priv->SSID_size) == 0 && 2790 memcmp(priv->SSID, priv->BSSinfo[i].SSID, priv->SSID_size) == 0 &&
2773 priv->operating_mode == priv->BSSinfo[i].BSStype && 2791 priv->operating_mode == priv->BSSinfo[i].BSStype &&
@@ -2781,19 +2799,19 @@ static int retrieve_bss(struct atmel_private *priv)
2781 return max_index; 2799 return max_index;
2782} 2800}
2783 2801
2784 2802static void store_bss_info(struct atmel_private *priv,
2785static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, 2803 struct ieee80211_hdr_4addr *header, u16 capability,
2786 u16 capability, u16 beacon_period, u8 channel, u8 rssi, 2804 u16 beacon_period, u8 channel, u8 rssi, u8 ssid_len,
2787 u8 ssid_len, u8 *ssid, int is_beacon) 2805 u8 *ssid, int is_beacon)
2788{ 2806{
2789 u8 *bss = capability & C80211_MGMT_CAPABILITY_ESS ? header->addr2 : header->addr3; 2807 u8 *bss = capability & C80211_MGMT_CAPABILITY_ESS ? header->addr2 : header->addr3;
2790 int i, index; 2808 int i, index;
2791 2809
2792 for (index = -1, i = 0; i < priv->BSS_list_entries; i++) 2810 for (index = -1, i = 0; i < priv->BSS_list_entries; i++)
2793 if (memcmp(bss, priv->BSSinfo[i].BSSID, 6) == 0) 2811 if (memcmp(bss, priv->BSSinfo[i].BSSID, 6) == 0)
2794 index = i; 2812 index = i;
2795 2813
2796 /* If we process a probe and an entry from this BSS exists 2814 /* If we process a probe and an entry from this BSS exists
2797 we will update the BSS entry with the info from this BSS. 2815 we will update the BSS entry with the info from this BSS.
2798 If we process a beacon we will only update RSSI */ 2816 If we process a beacon we will only update RSSI */
2799 2817
@@ -2820,8 +2838,8 @@ static void store_bss_info(struct atmel_private *priv, struct ieee80211_hdr_4add
2820 priv->BSSinfo[index].BSStype = IW_MODE_ADHOC; 2838 priv->BSSinfo[index].BSStype = IW_MODE_ADHOC;
2821 else if (capability & C80211_MGMT_CAPABILITY_ESS) 2839 else if (capability & C80211_MGMT_CAPABILITY_ESS)
2822 priv->BSSinfo[index].BSStype =IW_MODE_INFRA; 2840 priv->BSSinfo[index].BSStype =IW_MODE_INFRA;
2823 2841
2824 priv->BSSinfo[index].preamble = capability & C80211_MGMT_CAPABILITY_ShortPreamble ? 2842 priv->BSSinfo[index].preamble = capability & C80211_MGMT_CAPABILITY_ShortPreamble ?
2825 SHORT_PREAMBLE : LONG_PREAMBLE; 2843 SHORT_PREAMBLE : LONG_PREAMBLE;
2826} 2844}
2827 2845
@@ -2831,8 +2849,8 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2831 u16 status = le16_to_cpu(auth->status); 2849 u16 status = le16_to_cpu(auth->status);
2832 u16 trans_seq_no = le16_to_cpu(auth->trans_seq); 2850 u16 trans_seq_no = le16_to_cpu(auth->trans_seq);
2833 u16 system = le16_to_cpu(auth->alg); 2851 u16 system = le16_to_cpu(auth->alg);
2834 2852
2835 if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) { 2853 if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) {
2836 /* no WEP */ 2854 /* no WEP */
2837 if (priv->station_was_associated) { 2855 if (priv->station_was_associated) {
2838 atmel_enter_state(priv, STATION_STATE_REASSOCIATING); 2856 atmel_enter_state(priv, STATION_STATE_REASSOCIATING);
@@ -2842,20 +2860,20 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2842 atmel_enter_state(priv, STATION_STATE_ASSOCIATING); 2860 atmel_enter_state(priv, STATION_STATE_ASSOCIATING);
2843 send_association_request(priv, 0); 2861 send_association_request(priv, 0);
2844 return; 2862 return;
2845 } 2863 }
2846 } 2864 }
2847 2865
2848 if (status == C80211_MGMT_SC_Success && priv->wep_is_on) { 2866 if (status == C80211_MGMT_SC_Success && priv->wep_is_on) {
2849 /* WEP */ 2867 /* WEP */
2850 if (trans_seq_no != priv->ExpectedAuthentTransactionSeqNum) 2868 if (trans_seq_no != priv->ExpectedAuthentTransactionSeqNum)
2851 return; 2869 return;
2852 2870
2853 if (trans_seq_no == 0x0002 && 2871 if (trans_seq_no == 0x0002 &&
2854 auth->el_id == C80211_MGMT_ElementID_ChallengeText) { 2872 auth->el_id == C80211_MGMT_ElementID_ChallengeText) {
2855 send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len); 2873 send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len);
2856 return; 2874 return;
2857 } 2875 }
2858 2876
2859 if (trans_seq_no == 0x0004) { 2877 if (trans_seq_no == 0x0004) {
2860 if(priv->station_was_associated) { 2878 if(priv->station_was_associated) {
2861 atmel_enter_state(priv, STATION_STATE_REASSOCIATING); 2879 atmel_enter_state(priv, STATION_STATE_REASSOCIATING);
@@ -2865,10 +2883,10 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2865 atmel_enter_state(priv, STATION_STATE_ASSOCIATING); 2883 atmel_enter_state(priv, STATION_STATE_ASSOCIATING);
2866 send_association_request(priv, 0); 2884 send_association_request(priv, 0);
2867 return; 2885 return;
2868 } 2886 }
2869 } 2887 }
2870 } 2888 }
2871 2889
2872 if (status == C80211_MGMT_SC_AuthAlgNotSupported) { 2890 if (status == C80211_MGMT_SC_AuthAlgNotSupported) {
2873 /* Do opensystem first, then try sharedkey */ 2891 /* Do opensystem first, then try sharedkey */
2874 if (system == C80211_MGMT_AAN_OPENSYSTEM) { 2892 if (system == C80211_MGMT_AAN_OPENSYSTEM) {
@@ -2876,17 +2894,16 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2876 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0); 2894 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0);
2877 } else if (priv->connect_to_any_BSS) { 2895 } else if (priv->connect_to_any_BSS) {
2878 int bss_index; 2896 int bss_index;
2879 2897
2880 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; 2898 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80;
2881 2899
2882 if ((bss_index = retrieve_bss(priv)) != -1) { 2900 if ((bss_index = retrieve_bss(priv)) != -1) {
2883 atmel_join_bss(priv, bss_index); 2901 atmel_join_bss(priv, bss_index);
2884 return; 2902 return;
2885 } 2903 }
2886 } 2904 }
2887 } 2905 }
2888 2906
2889
2890 priv->AuthenticationRequestRetryCnt = 0; 2907 priv->AuthenticationRequestRetryCnt = 0;
2891 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); 2908 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
2892 priv->station_is_associated = 0; 2909 priv->station_is_associated = 0;
@@ -2902,38 +2919,44 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype)
2902 u8 length; 2919 u8 length;
2903 u8 rates[4]; 2920 u8 rates[4];
2904 } *ass_resp = (struct ass_resp_format *)priv->rx_buf; 2921 } *ass_resp = (struct ass_resp_format *)priv->rx_buf;
2905 2922
2906 u16 status = le16_to_cpu(ass_resp->status); 2923 u16 status = le16_to_cpu(ass_resp->status);
2907 u16 ass_id = le16_to_cpu(ass_resp->ass_id); 2924 u16 ass_id = le16_to_cpu(ass_resp->ass_id);
2908 u16 rates_len = ass_resp->length > 4 ? 4 : ass_resp->length; 2925 u16 rates_len = ass_resp->length > 4 ? 4 : ass_resp->length;
2909 2926
2910 if (frame_len < 8 + rates_len) 2927 if (frame_len < 8 + rates_len)
2911 return; 2928 return;
2912 2929
2913 if (status == C80211_MGMT_SC_Success) { 2930 if (status == C80211_MGMT_SC_Success) {
2914 if (subtype == C80211_SUBTYPE_MGMT_ASS_RESPONSE) 2931 if (subtype == C80211_SUBTYPE_MGMT_ASS_RESPONSE)
2915 priv->AssociationRequestRetryCnt = 0; 2932 priv->AssociationRequestRetryCnt = 0;
2916 else 2933 else
2917 priv->ReAssociationRequestRetryCnt = 0; 2934 priv->ReAssociationRequestRetryCnt = 0;
2918 2935
2919 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_STATION_ID_POS, ass_id & 0x3fff); 2936 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type,
2920 atmel_set_mib(priv, Phy_Mib_Type, PHY_MIB_RATE_SET_POS, ass_resp->rates, rates_len); 2937 MAC_MGMT_MIB_STATION_ID_POS, ass_id & 0x3fff);
2938 atmel_set_mib(priv, Phy_Mib_Type,
2939 PHY_MIB_RATE_SET_POS, ass_resp->rates, rates_len);
2921 if (priv->power_mode == 0) { 2940 if (priv->power_mode == 0) {
2922 priv->listen_interval = 1; 2941 priv->listen_interval = 1;
2923 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); 2942 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type,
2924 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); 2943 MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE);
2944 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type,
2945 MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1);
2925 } else { 2946 } else {
2926 priv->listen_interval = 2; 2947 priv->listen_interval = 2;
2927 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, PS_MODE); 2948 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type,
2928 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 2); 2949 MAC_MGMT_MIB_PS_MODE_POS, PS_MODE);
2950 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type,
2951 MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 2);
2929 } 2952 }
2930 2953
2931 priv->station_is_associated = 1; 2954 priv->station_is_associated = 1;
2932 priv->station_was_associated = 1; 2955 priv->station_was_associated = 1;
2933 atmel_enter_state(priv, STATION_STATE_READY); 2956 atmel_enter_state(priv, STATION_STATE_READY);
2934 return; 2957 return;
2935 } 2958 }
2936 2959
2937 if (subtype == C80211_SUBTYPE_MGMT_ASS_RESPONSE && 2960 if (subtype == C80211_SUBTYPE_MGMT_ASS_RESPONSE &&
2938 status != C80211_MGMT_SC_AssDeniedBSSRate && 2961 status != C80211_MGMT_SC_AssDeniedBSSRate &&
2939 status != C80211_MGMT_SC_SupportCapabilities && 2962 status != C80211_MGMT_SC_SupportCapabilities &&
@@ -2943,7 +2966,7 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype)
2943 send_association_request(priv, 0); 2966 send_association_request(priv, 0);
2944 return; 2967 return;
2945 } 2968 }
2946 2969
2947 if (subtype == C80211_SUBTYPE_MGMT_REASS_RESPONSE && 2970 if (subtype == C80211_SUBTYPE_MGMT_REASS_RESPONSE &&
2948 status != C80211_MGMT_SC_AssDeniedBSSRate && 2971 status != C80211_MGMT_SC_AssDeniedBSSRate &&
2949 status != C80211_MGMT_SC_SupportCapabilities && 2972 status != C80211_MGMT_SC_SupportCapabilities &&
@@ -2953,17 +2976,16 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype)
2953 send_association_request(priv, 1); 2976 send_association_request(priv, 1);
2954 return; 2977 return;
2955 } 2978 }
2956 2979
2957 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); 2980 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
2958 priv->station_is_associated = 0; 2981 priv->station_is_associated = 0;
2959 2982
2960 if(priv->connect_to_any_BSS) { 2983 if (priv->connect_to_any_BSS) {
2961 int bss_index; 2984 int bss_index;
2962 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; 2985 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80;
2963 2986
2964 if ((bss_index = retrieve_bss(priv)) != -1) 2987 if ((bss_index = retrieve_bss(priv)) != -1)
2965 atmel_join_bss(priv, bss_index); 2988 atmel_join_bss(priv, bss_index);
2966
2967 } 2989 }
2968} 2990}
2969 2991
@@ -2977,7 +2999,7 @@ void atmel_join_bss(struct atmel_private *priv, int bss_index)
2977 /* The WPA stuff cares about the current AP address */ 2999 /* The WPA stuff cares about the current AP address */
2978 if (priv->use_wpa) 3000 if (priv->use_wpa)
2979 build_wpa_mib(priv); 3001 build_wpa_mib(priv);
2980 3002
2981 /* When switching to AdHoc turn OFF Power Save if needed */ 3003 /* When switching to AdHoc turn OFF Power Save if needed */
2982 3004
2983 if (bss->BSStype == IW_MODE_ADHOC && 3005 if (bss->BSStype == IW_MODE_ADHOC &&
@@ -2985,25 +3007,28 @@ void atmel_join_bss(struct atmel_private *priv, int bss_index)
2985 priv->power_mode) { 3007 priv->power_mode) {
2986 priv->power_mode = 0; 3008 priv->power_mode = 0;
2987 priv->listen_interval = 1; 3009 priv->listen_interval = 1;
2988 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); 3010 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type,
2989 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); 3011 MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE);
3012 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type,
3013 MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1);
2990 } 3014 }
2991 3015
2992 priv->operating_mode = bss->BSStype; 3016 priv->operating_mode = bss->BSStype;
2993 priv->channel = bss->channel & 0x7f; 3017 priv->channel = bss->channel & 0x7f;
2994 priv->beacon_period = bss->beacon_period; 3018 priv->beacon_period = bss->beacon_period;
2995 3019
2996 if (priv->preamble != bss->preamble) { 3020 if (priv->preamble != bss->preamble) {
2997 priv->preamble = bss->preamble; 3021 priv->preamble = bss->preamble;
2998 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, bss->preamble); 3022 atmel_set_mib8(priv, Local_Mib_Type,
3023 LOCAL_MIB_PREAMBLE_TYPE, bss->preamble);
2999 } 3024 }
3000 3025
3001 if (!priv->wep_is_on && bss->UsingWEP) { 3026 if (!priv->wep_is_on && bss->UsingWEP) {
3002 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); 3027 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3003 priv->station_is_associated = 0; 3028 priv->station_is_associated = 0;
3004 return; 3029 return;
3005 } 3030 }
3006 3031
3007 if (priv->wep_is_on && !bss->UsingWEP) { 3032 if (priv->wep_is_on && !bss->UsingWEP) {
3008 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); 3033 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3009 priv->station_is_associated = 0; 3034 priv->station_is_associated = 0;
@@ -3011,30 +3036,28 @@ void atmel_join_bss(struct atmel_private *priv, int bss_index)
3011 } 3036 }
3012 3037
3013 atmel_enter_state(priv, STATION_STATE_JOINNING); 3038 atmel_enter_state(priv, STATION_STATE_JOINNING);
3014 3039
3015 if (priv->operating_mode == IW_MODE_INFRA) 3040 if (priv->operating_mode == IW_MODE_INFRA)
3016 join(priv, BSS_TYPE_INFRASTRUCTURE); 3041 join(priv, BSS_TYPE_INFRASTRUCTURE);
3017 else 3042 else
3018 join(priv, BSS_TYPE_AD_HOC); 3043 join(priv, BSS_TYPE_AD_HOC);
3019} 3044}
3020 3045
3021
3022static void restart_search(struct atmel_private *priv) 3046static void restart_search(struct atmel_private *priv)
3023{ 3047{
3024 int bss_index; 3048 int bss_index;
3025 3049
3026 if (!priv->connect_to_any_BSS) { 3050 if (!priv->connect_to_any_BSS) {
3027 atmel_scan(priv, 1); 3051 atmel_scan(priv, 1);
3028 } else { 3052 } else {
3029 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; 3053 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80;
3030 3054
3031 if ((bss_index = retrieve_bss(priv)) != -1) 3055 if ((bss_index = retrieve_bss(priv)) != -1)
3032 atmel_join_bss(priv, bss_index); 3056 atmel_join_bss(priv, bss_index);
3033 else 3057 else
3034 atmel_scan(priv, 0); 3058 atmel_scan(priv, 0);
3035 3059 }
3036 } 3060}
3037}
3038 3061
3039static void smooth_rssi(struct atmel_private *priv, u8 rssi) 3062static void smooth_rssi(struct atmel_private *priv, u8 rssi)
3040{ 3063{
@@ -3050,21 +3073,21 @@ static void smooth_rssi(struct atmel_private *priv, u8 rssi)
3050 } 3073 }
3051 3074
3052 rssi = rssi * 100 / max_rssi; 3075 rssi = rssi * 100 / max_rssi;
3053 if((rssi + old) % 2) 3076 if ((rssi + old) % 2)
3054 priv->wstats.qual.level = ((rssi + old)/2) + 1; 3077 priv->wstats.qual.level = (rssi + old) / 2 + 1;
3055 else 3078 else
3056 priv->wstats.qual.level = ((rssi + old)/2); 3079 priv->wstats.qual.level = (rssi + old) / 2;
3057 priv->wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED; 3080 priv->wstats.qual.updated |= IW_QUAL_LEVEL_UPDATED;
3058 priv->wstats.qual.updated &= ~IW_QUAL_LEVEL_INVALID; 3081 priv->wstats.qual.updated &= ~IW_QUAL_LEVEL_INVALID;
3059} 3082}
3060 3083
3061static void atmel_smooth_qual(struct atmel_private *priv) 3084static void atmel_smooth_qual(struct atmel_private *priv)
3062{ 3085{
3063 unsigned long time_diff = (jiffies - priv->last_qual)/HZ; 3086 unsigned long time_diff = (jiffies - priv->last_qual) / HZ;
3064 while (time_diff--) { 3087 while (time_diff--) {
3065 priv->last_qual += HZ; 3088 priv->last_qual += HZ;
3066 priv->wstats.qual.qual = priv->wstats.qual.qual/2; 3089 priv->wstats.qual.qual = priv->wstats.qual.qual / 2;
3067 priv->wstats.qual.qual += 3090 priv->wstats.qual.qual +=
3068 priv->beacons_this_sec * priv->beacon_period * (priv->wstats.qual.level + 100) / 4000; 3091 priv->beacons_this_sec * priv->beacon_period * (priv->wstats.qual.level + 100) / 4000;
3069 priv->beacons_this_sec = 0; 3092 priv->beacons_this_sec = 0;
3070 } 3093 }
@@ -3073,15 +3096,17 @@ static void atmel_smooth_qual(struct atmel_private *priv)
3073} 3096}
3074 3097
3075/* deals with incoming managment frames. */ 3098/* deals with incoming managment frames. */
3076static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_hdr_4addr *header, 3099static void atmel_management_frame(struct atmel_private *priv,
3077 u16 frame_len, u8 rssi) 3100 struct ieee80211_hdr_4addr *header,
3101 u16 frame_len, u8 rssi)
3078{ 3102{
3079 u16 subtype; 3103 u16 subtype;
3080 3104
3081 switch (subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE) { 3105 subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE;
3082 case C80211_SUBTYPE_MGMT_BEACON : 3106 switch (subtype) {
3107 case C80211_SUBTYPE_MGMT_BEACON:
3083 case C80211_SUBTYPE_MGMT_ProbeResponse: 3108 case C80211_SUBTYPE_MGMT_ProbeResponse:
3084 3109
3085 /* beacon frame has multiple variable-length fields - 3110 /* beacon frame has multiple variable-length fields -
3086 never let an engineer loose with a data structure design. */ 3111 never let an engineer loose with a data structure design. */
3087 { 3112 {
@@ -3099,7 +3124,7 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_
3099 u8 ds_length; 3124 u8 ds_length;
3100 /* ds here */ 3125 /* ds here */
3101 } *beacon = (struct beacon_format *)priv->rx_buf; 3126 } *beacon = (struct beacon_format *)priv->rx_buf;
3102 3127
3103 u8 channel, rates_length, ssid_length; 3128 u8 channel, rates_length, ssid_length;
3104 u64 timestamp = le64_to_cpu(beacon->timestamp); 3129 u64 timestamp = le64_to_cpu(beacon->timestamp);
3105 u16 beacon_interval = le16_to_cpu(beacon->interval); 3130 u16 beacon_interval = le16_to_cpu(beacon->interval);
@@ -3107,7 +3132,7 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_
3107 u8 *beaconp = priv->rx_buf; 3132 u8 *beaconp = priv->rx_buf;
3108 ssid_length = beacon->ssid_length; 3133 ssid_length = beacon->ssid_length;
3109 /* this blows chunks. */ 3134 /* this blows chunks. */
3110 if (frame_len < 14 || frame_len < ssid_length + 15) 3135 if (frame_len < 14 || frame_len < ssid_length + 15)
3111 return; 3136 return;
3112 rates_length = beaconp[beacon->ssid_length + 15]; 3137 rates_length = beaconp[beacon->ssid_length + 15];
3113 if (frame_len < ssid_length + rates_length + 18) 3138 if (frame_len < ssid_length + rates_length + 18)
@@ -3115,10 +3140,10 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_
3115 if (ssid_length > MAX_SSID_LENGTH) 3140 if (ssid_length > MAX_SSID_LENGTH)
3116 return; 3141 return;
3117 channel = beaconp[ssid_length + rates_length + 18]; 3142 channel = beaconp[ssid_length + rates_length + 18];
3118 3143
3119 if (priv->station_state == STATION_STATE_READY) { 3144 if (priv->station_state == STATION_STATE_READY) {
3120 smooth_rssi(priv, rssi); 3145 smooth_rssi(priv, rssi);
3121 if (is_frame_from_current_bss(priv, header)) { 3146 if (is_frame_from_current_bss(priv, header)) {
3122 priv->beacons_this_sec++; 3147 priv->beacons_this_sec++;
3123 atmel_smooth_qual(priv); 3148 atmel_smooth_qual(priv);
3124 if (priv->last_beacon_timestamp) { 3149 if (priv->last_beacon_timestamp) {
@@ -3132,41 +3157,43 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_
3132 handle_beacon_probe(priv, capability, channel); 3157 handle_beacon_probe(priv, capability, channel);
3133 } 3158 }
3134 } 3159 }
3135 3160
3136 if (priv->station_state == STATION_STATE_SCANNING ) 3161 if (priv->station_state == STATION_STATE_SCANNING)
3137 store_bss_info(priv, header, capability, beacon_interval, channel, 3162 store_bss_info(priv, header, capability,
3138 rssi, ssid_length, &beacon->rates_el_id, 3163 beacon_interval, channel, rssi,
3139 subtype == C80211_SUBTYPE_MGMT_BEACON) ; 3164 ssid_length,
3165 &beacon->rates_el_id,
3166 subtype == C80211_SUBTYPE_MGMT_BEACON);
3140 } 3167 }
3141 break; 3168 break;
3142 3169
3143 case C80211_SUBTYPE_MGMT_Authentication: 3170 case C80211_SUBTYPE_MGMT_Authentication:
3144 3171
3145 if (priv->station_state == STATION_STATE_AUTHENTICATING) 3172 if (priv->station_state == STATION_STATE_AUTHENTICATING)
3146 authenticate(priv, frame_len); 3173 authenticate(priv, frame_len);
3147 3174
3148 break; 3175 break;
3149 3176
3150 case C80211_SUBTYPE_MGMT_ASS_RESPONSE: 3177 case C80211_SUBTYPE_MGMT_ASS_RESPONSE:
3151 case C80211_SUBTYPE_MGMT_REASS_RESPONSE: 3178 case C80211_SUBTYPE_MGMT_REASS_RESPONSE:
3152 3179
3153 if (priv->station_state == STATION_STATE_ASSOCIATING || 3180 if (priv->station_state == STATION_STATE_ASSOCIATING ||
3154 priv->station_state == STATION_STATE_REASSOCIATING) 3181 priv->station_state == STATION_STATE_REASSOCIATING)
3155 associate(priv, frame_len, subtype); 3182 associate(priv, frame_len, subtype);
3156 3183
3157 break; 3184 break;
3158 3185
3159 case C80211_SUBTYPE_MGMT_DISASSOSIATION: 3186 case C80211_SUBTYPE_MGMT_DISASSOSIATION:
3160 if (priv->station_is_associated && 3187 if (priv->station_is_associated &&
3161 priv->operating_mode == IW_MODE_INFRA && 3188 priv->operating_mode == IW_MODE_INFRA &&
3162 is_frame_from_current_bss(priv, header)) { 3189 is_frame_from_current_bss(priv, header)) {
3163 priv->station_was_associated = 0; 3190 priv->station_was_associated = 0;
3164 priv->station_is_associated = 0; 3191 priv->station_is_associated = 0;
3165 3192
3166 atmel_enter_state(priv, STATION_STATE_JOINNING); 3193 atmel_enter_state(priv, STATION_STATE_JOINNING);
3167 join(priv, BSS_TYPE_INFRASTRUCTURE); 3194 join(priv, BSS_TYPE_INFRASTRUCTURE);
3168 } 3195 }
3169 3196
3170 break; 3197 break;
3171 3198
3172 case C80211_SUBTYPE_MGMT_Deauthentication: 3199 case C80211_SUBTYPE_MGMT_Deauthentication:
@@ -3177,7 +3204,7 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_
3177 atmel_enter_state(priv, STATION_STATE_JOINNING); 3204 atmel_enter_state(priv, STATION_STATE_JOINNING);
3178 join(priv, BSS_TYPE_INFRASTRUCTURE); 3205 join(priv, BSS_TYPE_INFRASTRUCTURE);
3179 } 3206 }
3180 3207
3181 break; 3208 break;
3182 } 3209 }
3183} 3210}
@@ -3185,76 +3212,73 @@ static void atmel_management_frame(struct atmel_private *priv, struct ieee80211_
3185/* run when timer expires */ 3212/* run when timer expires */
3186static void atmel_management_timer(u_long a) 3213static void atmel_management_timer(u_long a)
3187{ 3214{
3188 struct net_device *dev = (struct net_device *) a; 3215 struct net_device *dev = (struct net_device *) a;
3189 struct atmel_private *priv = netdev_priv(dev); 3216 struct atmel_private *priv = netdev_priv(dev);
3190 unsigned long flags; 3217 unsigned long flags;
3191
3192 /* Check if the card has been yanked. */
3193 if (priv->card && priv->present_callback &&
3194 !(*priv->present_callback)(priv->card))
3195 return;
3196
3197 spin_lock_irqsave(&priv->irqlock, flags);
3198
3199 switch (priv->station_state) {
3200
3201 case STATION_STATE_AUTHENTICATING:
3202 if (priv->AuthenticationRequestRetryCnt >= MAX_AUTHENTICATION_RETRIES) {
3203 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3204 priv->station_is_associated = 0;
3205 priv->AuthenticationRequestRetryCnt = 0;
3206 restart_search(priv);
3207 } else {
3208 priv->AuthenticationRequestRetryCnt++;
3209 priv->CurrentAuthentTransactionSeqNum = 0x0001;
3210 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3211 send_authentication_request(priv, C80211_MGMT_AAN_OPENSYSTEM, NULL, 0);
3212 }
3213
3214 break;
3215 3218
3216 case STATION_STATE_ASSOCIATING: 3219 /* Check if the card has been yanked. */
3217 if (priv->AssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) { 3220 if (priv->card && priv->present_callback &&
3218 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR); 3221 !(*priv->present_callback)(priv->card))
3219 priv->station_is_associated = 0; 3222 return;
3220 priv->AssociationRequestRetryCnt = 0;
3221 restart_search(priv);
3222 } else {
3223 priv->AssociationRequestRetryCnt++;
3224 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3225 send_association_request(priv, 0);
3226 }
3227 3223
3228 break; 3224 spin_lock_irqsave(&priv->irqlock, flags);
3229 3225
3230 case STATION_STATE_REASSOCIATING: 3226 switch (priv->station_state) {
3231 if (priv->ReAssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) {
3232 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3233 priv->station_is_associated = 0;
3234 priv->ReAssociationRequestRetryCnt = 0;
3235 restart_search(priv);
3236 } else {
3237 priv->ReAssociationRequestRetryCnt++;
3238 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3239 send_association_request(priv, 1);
3240 }
3241 3227
3228 case STATION_STATE_AUTHENTICATING:
3229 if (priv->AuthenticationRequestRetryCnt >= MAX_AUTHENTICATION_RETRIES) {
3230 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3231 priv->station_is_associated = 0;
3232 priv->AuthenticationRequestRetryCnt = 0;
3233 restart_search(priv);
3234 } else {
3235 priv->AuthenticationRequestRetryCnt++;
3236 priv->CurrentAuthentTransactionSeqNum = 0x0001;
3237 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3238 send_authentication_request(priv, C80211_MGMT_AAN_OPENSYSTEM, NULL, 0);
3239 }
3242 break; 3240 break;
3243 3241
3244 default: 3242 case STATION_STATE_ASSOCIATING:
3243 if (priv->AssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) {
3244 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3245 priv->station_is_associated = 0;
3246 priv->AssociationRequestRetryCnt = 0;
3247 restart_search(priv);
3248 } else {
3249 priv->AssociationRequestRetryCnt++;
3250 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3251 send_association_request(priv, 0);
3252 }
3245 break; 3253 break;
3246 } 3254
3247 3255 case STATION_STATE_REASSOCIATING:
3248 spin_unlock_irqrestore(&priv->irqlock, flags); 3256 if (priv->ReAssociationRequestRetryCnt == MAX_ASSOCIATION_RETRIES) {
3257 atmel_enter_state(priv, STATION_STATE_MGMT_ERROR);
3258 priv->station_is_associated = 0;
3259 priv->ReAssociationRequestRetryCnt = 0;
3260 restart_search(priv);
3261 } else {
3262 priv->ReAssociationRequestRetryCnt++;
3263 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3264 send_association_request(priv, 1);
3265 }
3266 break;
3267
3268 default:
3269 break;
3270 }
3271
3272 spin_unlock_irqrestore(&priv->irqlock, flags);
3249} 3273}
3250 3274
3251static void atmel_command_irq(struct atmel_private *priv) 3275static void atmel_command_irq(struct atmel_private *priv)
3252{ 3276{
3253 u8 status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET)); 3277 u8 status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET));
3254 u8 command = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET)); 3278 u8 command = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET));
3255 int fast_scan; 3279 int fast_scan;
3256 3280
3257 if (status == CMD_STATUS_IDLE || 3281 if (status == CMD_STATUS_IDLE ||
3258 status == CMD_STATUS_IN_PROGRESS) 3282 status == CMD_STATUS_IN_PROGRESS)
3259 return; 3283 return;
3260 3284
@@ -3266,20 +3290,20 @@ static void atmel_command_irq(struct atmel_private *priv)
3266 atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS, 3290 atmel_get_mib(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_CUR_BSSID_POS,
3267 (u8 *)priv->CurrentBSSID, 6); 3291 (u8 *)priv->CurrentBSSID, 6);
3268 atmel_enter_state(priv, STATION_STATE_READY); 3292 atmel_enter_state(priv, STATION_STATE_READY);
3269 } 3293 }
3270 break; 3294 break;
3271 3295
3272 case CMD_Scan: 3296 case CMD_Scan:
3273 fast_scan = priv->fast_scan; 3297 fast_scan = priv->fast_scan;
3274 priv->fast_scan = 0; 3298 priv->fast_scan = 0;
3275 3299
3276 if (status != CMD_STATUS_COMPLETE) { 3300 if (status != CMD_STATUS_COMPLETE) {
3277 atmel_scan(priv, 1); 3301 atmel_scan(priv, 1);
3278 } else { 3302 } else {
3279 int bss_index = retrieve_bss(priv); 3303 int bss_index = retrieve_bss(priv);
3280 if (bss_index != -1) { 3304 if (bss_index != -1) {
3281 atmel_join_bss(priv, bss_index); 3305 atmel_join_bss(priv, bss_index);
3282 } else if (priv->operating_mode == IW_MODE_ADHOC && 3306 } else if (priv->operating_mode == IW_MODE_ADHOC &&
3283 priv->SSID_size != 0) { 3307 priv->SSID_size != 0) {
3284 start(priv, BSS_TYPE_AD_HOC); 3308 start(priv, BSS_TYPE_AD_HOC);
3285 } else { 3309 } else {
@@ -3289,16 +3313,16 @@ static void atmel_command_irq(struct atmel_private *priv)
3289 priv->site_survey_state = SITE_SURVEY_COMPLETED; 3313 priv->site_survey_state = SITE_SURVEY_COMPLETED;
3290 } 3314 }
3291 break; 3315 break;
3292 3316
3293 case CMD_SiteSurvey: 3317 case CMD_SiteSurvey:
3294 priv->fast_scan = 0; 3318 priv->fast_scan = 0;
3295 3319
3296 if (status != CMD_STATUS_COMPLETE) 3320 if (status != CMD_STATUS_COMPLETE)
3297 return; 3321 return;
3298 3322
3299 priv->site_survey_state = SITE_SURVEY_COMPLETED; 3323 priv->site_survey_state = SITE_SURVEY_COMPLETED;
3300 if (priv->station_is_associated) { 3324 if (priv->station_is_associated) {
3301 atmel_enter_state(priv, STATION_STATE_READY); 3325 atmel_enter_state(priv, STATION_STATE_READY);
3302 } else { 3326 } else {
3303 atmel_scan(priv, 1); 3327 atmel_scan(priv, 1);
3304 } 3328 }
@@ -3312,16 +3336,15 @@ static void atmel_command_irq(struct atmel_private *priv)
3312 } else { 3336 } else {
3313 priv->AuthenticationRequestRetryCnt = 0; 3337 priv->AuthenticationRequestRetryCnt = 0;
3314 atmel_enter_state(priv, STATION_STATE_AUTHENTICATING); 3338 atmel_enter_state(priv, STATION_STATE_AUTHENTICATING);
3315 3339
3316 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); 3340 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3317 priv->CurrentAuthentTransactionSeqNum = 0x0001; 3341 priv->CurrentAuthentTransactionSeqNum = 0x0001;
3318 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0); 3342 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0);
3319 } 3343 }
3320 return; 3344 return;
3321 } 3345 }
3322 3346
3323 atmel_scan(priv, 1); 3347 atmel_scan(priv, 1);
3324
3325 } 3348 }
3326} 3349}
3327 3350
@@ -3333,20 +3356,20 @@ static int atmel_wakeup_firmware(struct atmel_private *priv)
3333 3356
3334 if (priv->card_type == CARD_TYPE_SPI_FLASH) 3357 if (priv->card_type == CARD_TYPE_SPI_FLASH)
3335 atmel_set_gcr(priv->dev, GCR_REMAP); 3358 atmel_set_gcr(priv->dev, GCR_REMAP);
3336 3359
3337 /* wake up on-board processor */ 3360 /* wake up on-board processor */
3338 atmel_clear_gcr(priv->dev, 0x0040); 3361 atmel_clear_gcr(priv->dev, 0x0040);
3339 atmel_write16(priv->dev, BSR, BSS_SRAM); 3362 atmel_write16(priv->dev, BSR, BSS_SRAM);
3340 3363
3341 if (priv->card_type == CARD_TYPE_SPI_FLASH) 3364 if (priv->card_type == CARD_TYPE_SPI_FLASH)
3342 mdelay(100); 3365 mdelay(100);
3343 3366
3344 /* and wait for it */ 3367 /* and wait for it */
3345 for (i = LOOP_RETRY_LIMIT; i; i--) { 3368 for (i = LOOP_RETRY_LIMIT; i; i--) {
3346 mr1 = atmel_read16(priv->dev, MR1); 3369 mr1 = atmel_read16(priv->dev, MR1);
3347 mr3 = atmel_read16(priv->dev, MR3); 3370 mr3 = atmel_read16(priv->dev, MR3);
3348 3371
3349 if (mr3 & MAC_BOOT_COMPLETE) 3372 if (mr3 & MAC_BOOT_COMPLETE)
3350 break; 3373 break;
3351 if (mr1 & MAC_BOOT_COMPLETE && 3374 if (mr1 & MAC_BOOT_COMPLETE &&
3352 priv->bus_type == BUS_TYPE_PCCARD) 3375 priv->bus_type == BUS_TYPE_PCCARD)
@@ -3357,35 +3380,36 @@ static int atmel_wakeup_firmware(struct atmel_private *priv)
3357 printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name); 3380 printk(KERN_ALERT "%s: MAC failed to boot.\n", priv->dev->name);
3358 return 0; 3381 return 0;
3359 } 3382 }
3360 3383
3361 if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) { 3384 if ((priv->host_info_base = atmel_read16(priv->dev, MR2)) == 0xffff) {
3362 printk(KERN_ALERT "%s: card missing.\n", priv->dev->name); 3385 printk(KERN_ALERT "%s: card missing.\n", priv->dev->name);
3363 return 0; 3386 return 0;
3364 } 3387 }
3365 3388
3366 /* now check for completion of MAC initialization through 3389 /* now check for completion of MAC initialization through
3367 the FunCtrl field of the IFACE, poll MR1 to detect completion of 3390 the FunCtrl field of the IFACE, poll MR1 to detect completion of
3368 MAC initialization, check completion status, set interrupt mask, 3391 MAC initialization, check completion status, set interrupt mask,
3369 enables interrupts and calls Tx and Rx initialization functions */ 3392 enables interrupts and calls Tx and Rx initialization functions */
3370 3393
3371 atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), FUNC_CTRL_INIT_COMPLETE); 3394 atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), FUNC_CTRL_INIT_COMPLETE);
3372 3395
3373 for (i = LOOP_RETRY_LIMIT; i; i--) { 3396 for (i = LOOP_RETRY_LIMIT; i; i--) {
3374 mr1 = atmel_read16(priv->dev, MR1); 3397 mr1 = atmel_read16(priv->dev, MR1);
3375 mr3 = atmel_read16(priv->dev, MR3); 3398 mr3 = atmel_read16(priv->dev, MR3);
3376 3399
3377 if (mr3 & MAC_INIT_COMPLETE) 3400 if (mr3 & MAC_INIT_COMPLETE)
3378 break; 3401 break;
3379 if (mr1 & MAC_INIT_COMPLETE && 3402 if (mr1 & MAC_INIT_COMPLETE &&
3380 priv->bus_type == BUS_TYPE_PCCARD) 3403 priv->bus_type == BUS_TYPE_PCCARD)
3381 break; 3404 break;
3382 } 3405 }
3383 3406
3384 if (i == 0) { 3407 if (i == 0) {
3385 printk(KERN_ALERT "%s: MAC failed to initialise.\n", priv->dev->name); 3408 printk(KERN_ALERT "%s: MAC failed to initialise.\n",
3409 priv->dev->name);
3386 return 0; 3410 return 0;
3387 } 3411 }
3388 3412
3389 /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */ 3413 /* Check for MAC_INIT_OK only on the register that the MAC_INIT_OK was set */
3390 if ((mr3 & MAC_INIT_COMPLETE) && 3414 if ((mr3 & MAC_INIT_COMPLETE) &&
3391 !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) { 3415 !(atmel_read16(priv->dev, MR3) & MAC_INIT_OK)) {
@@ -3398,9 +3422,9 @@ static int atmel_wakeup_firmware(struct atmel_private *priv)
3398 return 0; 3422 return 0;
3399 } 3423 }
3400 3424
3401 atmel_copy_to_host(priv->dev, (unsigned char *)iface, 3425 atmel_copy_to_host(priv->dev, (unsigned char *)iface,
3402 priv->host_info_base, sizeof(*iface)); 3426 priv->host_info_base, sizeof(*iface));
3403 3427
3404 iface->tx_buff_pos = le16_to_cpu(iface->tx_buff_pos); 3428 iface->tx_buff_pos = le16_to_cpu(iface->tx_buff_pos);
3405 iface->tx_buff_size = le16_to_cpu(iface->tx_buff_size); 3429 iface->tx_buff_size = le16_to_cpu(iface->tx_buff_size);
3406 iface->tx_desc_pos = le16_to_cpu(iface->tx_desc_pos); 3430 iface->tx_desc_pos = le16_to_cpu(iface->tx_desc_pos);
@@ -3424,16 +3448,16 @@ static int probe_atmel_card(struct net_device *dev)
3424{ 3448{
3425 int rc = 0; 3449 int rc = 0;
3426 struct atmel_private *priv = netdev_priv(dev); 3450 struct atmel_private *priv = netdev_priv(dev);
3427 3451
3428 /* reset pccard */ 3452 /* reset pccard */
3429 if (priv->bus_type == BUS_TYPE_PCCARD) 3453 if (priv->bus_type == BUS_TYPE_PCCARD)
3430 atmel_write16(dev, GCR, 0x0060); 3454 atmel_write16(dev, GCR, 0x0060);
3431 3455
3432 atmel_write16(dev, GCR, 0x0040); 3456 atmel_write16(dev, GCR, 0x0040);
3433 mdelay(500); 3457 mdelay(500);
3434 3458
3435 if (atmel_read16(dev, MR2) == 0) { 3459 if (atmel_read16(dev, MR2) == 0) {
3436 /* No stored firmware so load a small stub which just 3460 /* No stored firmware so load a small stub which just
3437 tells us the MAC address */ 3461 tells us the MAC address */
3438 int i; 3462 int i;
3439 priv->card_type = CARD_TYPE_EEPROM; 3463 priv->card_type = CARD_TYPE_EEPROM;
@@ -3442,7 +3466,7 @@ static int probe_atmel_card(struct net_device *dev)
3442 atmel_set_gcr(dev, GCR_REMAP); 3466 atmel_set_gcr(dev, GCR_REMAP);
3443 atmel_clear_gcr(priv->dev, 0x0040); 3467 atmel_clear_gcr(priv->dev, 0x0040);
3444 atmel_write16(dev, BSR, BSS_SRAM); 3468 atmel_write16(dev, BSR, BSS_SRAM);
3445 for (i = LOOP_RETRY_LIMIT; i; i--) 3469 for (i = LOOP_RETRY_LIMIT; i; i--)
3446 if (atmel_read16(dev, MR3) & MAC_BOOT_COMPLETE) 3470 if (atmel_read16(dev, MR3) & MAC_BOOT_COMPLETE)
3447 break; 3471 break;
3448 if (i == 0) { 3472 if (i == 0) {
@@ -3451,7 +3475,7 @@ static int probe_atmel_card(struct net_device *dev)
3451 atmel_copy_to_host(dev, dev->dev_addr, atmel_read16(dev, MR2), 6); 3475 atmel_copy_to_host(dev, dev->dev_addr, atmel_read16(dev, MR2), 6);
3452 /* got address, now squash it again until the network 3476 /* got address, now squash it again until the network
3453 interface is opened */ 3477 interface is opened */
3454 if (priv->bus_type == BUS_TYPE_PCCARD) 3478 if (priv->bus_type == BUS_TYPE_PCCARD)
3455 atmel_write16(dev, GCR, 0x0060); 3479 atmel_write16(dev, GCR, 0x0060);
3456 atmel_write16(dev, GCR, 0x0040); 3480 atmel_write16(dev, GCR, 0x0040);
3457 rc = 1; 3481 rc = 1;
@@ -3459,7 +3483,7 @@ static int probe_atmel_card(struct net_device *dev)
3459 } else if (atmel_read16(dev, MR4) == 0) { 3483 } else if (atmel_read16(dev, MR4) == 0) {
3460 /* Mac address easy in this case. */ 3484 /* Mac address easy in this case. */
3461 priv->card_type = CARD_TYPE_PARALLEL_FLASH; 3485 priv->card_type = CARD_TYPE_PARALLEL_FLASH;
3462 atmel_write16(dev, BSR, 1); 3486 atmel_write16(dev, BSR, 1);
3463 atmel_copy_to_host(dev, dev->dev_addr, 0xc000, 6); 3487 atmel_copy_to_host(dev, dev->dev_addr, 0xc000, 6);
3464 atmel_write16(dev, BSR, 0x200); 3488 atmel_write16(dev, BSR, 0x200);
3465 rc = 1; 3489 rc = 1;
@@ -3469,16 +3493,16 @@ static int probe_atmel_card(struct net_device *dev)
3469 priv->card_type = CARD_TYPE_SPI_FLASH; 3493 priv->card_type = CARD_TYPE_SPI_FLASH;
3470 if (atmel_wakeup_firmware(priv)) { 3494 if (atmel_wakeup_firmware(priv)) {
3471 atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6); 3495 atmel_get_mib(priv, Mac_Address_Mib_Type, 0, dev->dev_addr, 6);
3472 3496
3473 /* got address, now squash it again until the network 3497 /* got address, now squash it again until the network
3474 interface is opened */ 3498 interface is opened */
3475 if (priv->bus_type == BUS_TYPE_PCCARD) 3499 if (priv->bus_type == BUS_TYPE_PCCARD)
3476 atmel_write16(dev, GCR, 0x0060); 3500 atmel_write16(dev, GCR, 0x0060);
3477 atmel_write16(dev, GCR, 0x0040); 3501 atmel_write16(dev, GCR, 0x0040);
3478 rc = 1; 3502 rc = 1;
3479 } 3503 }
3480 } 3504 }
3481 3505
3482 if (rc) { 3506 if (rc) {
3483 if (dev->dev_addr[0] == 0xFF) { 3507 if (dev->dev_addr[0] == 0xFF) {
3484 u8 default_mac[] = {0x00,0x04, 0x25, 0x00, 0x00, 0x00}; 3508 u8 default_mac[] = {0x00,0x04, 0x25, 0x00, 0x00, 0x00};
@@ -3486,27 +3510,27 @@ static int probe_atmel_card(struct net_device *dev)
3486 memcpy(dev->dev_addr, default_mac, 6); 3510 memcpy(dev->dev_addr, default_mac, 6);
3487 } 3511 }
3488 } 3512 }
3489 3513
3490 return rc; 3514 return rc;
3491} 3515}
3492 3516
3493static void build_wep_mib(struct atmel_private *priv)
3494/* Move the encyption information on the MIB structure. 3517/* Move the encyption information on the MIB structure.
3495 This routine is for the pre-WPA firmware: later firmware has 3518 This routine is for the pre-WPA firmware: later firmware has
3496 a different format MIB and a different routine. */ 3519 a different format MIB and a different routine. */
3520static void build_wep_mib(struct atmel_private *priv)
3497{ 3521{
3498 struct { /* NB this is matched to the hardware, don't change. */ 3522 struct { /* NB this is matched to the hardware, don't change. */
3499 u8 wep_is_on; 3523 u8 wep_is_on;
3500 u8 default_key; /* 0..3 */ 3524 u8 default_key; /* 0..3 */
3501 u8 reserved; 3525 u8 reserved;
3502 u8 exclude_unencrypted; 3526 u8 exclude_unencrypted;
3503 3527
3504 u32 WEPICV_error_count; 3528 u32 WEPICV_error_count;
3505 u32 WEP_excluded_count; 3529 u32 WEP_excluded_count;
3506 3530
3507 u8 wep_keys[MAX_ENCRYPTION_KEYS][13]; 3531 u8 wep_keys[MAX_ENCRYPTION_KEYS][13];
3508 u8 encryption_level; /* 0, 1, 2 */ 3532 u8 encryption_level; /* 0, 1, 2 */
3509 u8 reserved2[3]; 3533 u8 reserved2[3];
3510 } mib; 3534 } mib;
3511 int i; 3535 int i;
3512 3536
@@ -3515,54 +3539,55 @@ static void build_wep_mib(struct atmel_private *priv)
3515 if (priv->wep_key_len[priv->default_key] > 5) 3539 if (priv->wep_key_len[priv->default_key] > 5)
3516 mib.encryption_level = 2; 3540 mib.encryption_level = 2;
3517 else 3541 else
3518 mib.encryption_level = 1; 3542 mib.encryption_level = 1;
3519 } else { 3543 } else {
3520 mib.encryption_level = 0; 3544 mib.encryption_level = 0;
3521 } 3545 }
3522 3546
3523 mib.default_key = priv->default_key; 3547 mib.default_key = priv->default_key;
3524 mib.exclude_unencrypted = priv->exclude_unencrypted; 3548 mib.exclude_unencrypted = priv->exclude_unencrypted;
3525 3549
3526 for(i = 0; i < MAX_ENCRYPTION_KEYS; i++) 3550 for (i = 0; i < MAX_ENCRYPTION_KEYS; i++)
3527 memcpy(mib.wep_keys[i], priv->wep_keys[i], 13); 3551 memcpy(mib.wep_keys[i], priv->wep_keys[i], 13);
3528 3552
3529 atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib)); 3553 atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib));
3530} 3554}
3531 3555
3532static void build_wpa_mib(struct atmel_private *priv) 3556static void build_wpa_mib(struct atmel_private *priv)
3533{ 3557{
3534 /* This is for the later (WPA enabled) firmware. */ 3558 /* This is for the later (WPA enabled) firmware. */
3535 3559
3536 struct { /* NB this is matched to the hardware, don't change. */ 3560 struct { /* NB this is matched to the hardware, don't change. */
3537 u8 cipher_default_key_value[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE]; 3561 u8 cipher_default_key_value[MAX_ENCRYPTION_KEYS][MAX_ENCRYPTION_KEY_SIZE];
3538 u8 receiver_address[6]; 3562 u8 receiver_address[6];
3539 u8 wep_is_on; 3563 u8 wep_is_on;
3540 u8 default_key; /* 0..3 */ 3564 u8 default_key; /* 0..3 */
3541 u8 group_key; 3565 u8 group_key;
3542 u8 exclude_unencrypted; 3566 u8 exclude_unencrypted;
3543 u8 encryption_type; 3567 u8 encryption_type;
3544 u8 reserved; 3568 u8 reserved;
3545 3569
3546 u32 WEPICV_error_count; 3570 u32 WEPICV_error_count;
3547 u32 WEP_excluded_count; 3571 u32 WEP_excluded_count;
3548 3572
3549 u8 key_RSC[4][8]; 3573 u8 key_RSC[4][8];
3550 } mib; 3574 } mib;
3551 3575
3552 int i; 3576 int i;
3553 3577
3554 mib.wep_is_on = priv->wep_is_on; 3578 mib.wep_is_on = priv->wep_is_on;
3555 mib.exclude_unencrypted = priv->exclude_unencrypted; 3579 mib.exclude_unencrypted = priv->exclude_unencrypted;
3556 memcpy(mib.receiver_address, priv->CurrentBSSID, 6); 3580 memcpy(mib.receiver_address, priv->CurrentBSSID, 6);
3557 3581
3558 /* zero all the keys before adding in valid ones. */ 3582 /* zero all the keys before adding in valid ones. */
3559 memset(mib.cipher_default_key_value, 0, sizeof(mib.cipher_default_key_value)); 3583 memset(mib.cipher_default_key_value, 0, sizeof(mib.cipher_default_key_value));
3560 3584
3561 if (priv->wep_is_on) { 3585 if (priv->wep_is_on) {
3562 /* There's a comment in the Atmel code to the effect that this is only valid 3586 /* There's a comment in the Atmel code to the effect that this
3563 when still using WEP, it may need to be set to something to use WPA */ 3587 is only valid when still using WEP, it may need to be set to
3588 something to use WPA */
3564 memset(mib.key_RSC, 0, sizeof(mib.key_RSC)); 3589 memset(mib.key_RSC, 0, sizeof(mib.key_RSC));
3565 3590
3566 mib.default_key = mib.group_key = 255; 3591 mib.default_key = mib.group_key = 255;
3567 for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) { 3592 for (i = 0; i < MAX_ENCRYPTION_KEYS; i++) {
3568 if (priv->wep_key_len[i] > 0) { 3593 if (priv->wep_key_len[i] > 0) {
@@ -3570,12 +3595,12 @@ static void build_wpa_mib(struct atmel_private *priv)
3570 if (i == priv->default_key) { 3595 if (i == priv->default_key) {
3571 mib.default_key = i; 3596 mib.default_key = i;
3572 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 7; 3597 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 7;
3573 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->pairwise_cipher_suite; 3598 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->pairwise_cipher_suite;
3574 } else { 3599 } else {
3575 mib.group_key = i; 3600 mib.group_key = i;
3576 priv->group_cipher_suite = priv->pairwise_cipher_suite; 3601 priv->group_cipher_suite = priv->pairwise_cipher_suite;
3577 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 1; 3602 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-1] = 1;
3578 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->group_cipher_suite; 3603 mib.cipher_default_key_value[i][MAX_ENCRYPTION_KEY_SIZE-2] = priv->group_cipher_suite;
3579 } 3604 }
3580 } 3605 }
3581 } 3606 }
@@ -3583,47 +3608,47 @@ static void build_wpa_mib(struct atmel_private *priv)
3583 mib.default_key = mib.group_key != 255 ? mib.group_key : 0; 3608 mib.default_key = mib.group_key != 255 ? mib.group_key : 0;
3584 if (mib.group_key == 255) 3609 if (mib.group_key == 255)
3585 mib.group_key = mib.default_key; 3610 mib.group_key = mib.default_key;
3586 3611
3587 } 3612 }
3588 3613
3589 atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib)); 3614 atmel_set_mib(priv, Mac_Wep_Mib_Type, 0, (u8 *)&mib, sizeof(mib));
3590} 3615}
3591 3616
3592static int reset_atmel_card(struct net_device *dev) 3617static int reset_atmel_card(struct net_device *dev)
3593{ 3618{
3594 /* do everything necessary to wake up the hardware, including 3619 /* do everything necessary to wake up the hardware, including
3595 waiting for the lightning strike and throwing the knife switch.... 3620 waiting for the lightning strike and throwing the knife switch....
3596 3621
3597 set all the Mib values which matter in the card to match 3622 set all the Mib values which matter in the card to match
3598 their settings in the atmel_private structure. Some of these 3623 their settings in the atmel_private structure. Some of these
3599 can be altered on the fly, but many (WEP, infrastucture or ad-hoc) 3624 can be altered on the fly, but many (WEP, infrastucture or ad-hoc)
3600 can only be changed by tearing down the world and coming back through 3625 can only be changed by tearing down the world and coming back through
3601 here. 3626 here.
3602 3627
3603 This routine is also responsible for initialising some 3628 This routine is also responsible for initialising some
3604 hardware-specific fields in the atmel_private structure, 3629 hardware-specific fields in the atmel_private structure,
3605 including a copy of the firmware's hostinfo stucture 3630 including a copy of the firmware's hostinfo stucture
3606 which is the route into the rest of the firmare datastructures. */ 3631 which is the route into the rest of the firmare datastructures. */
3607 3632
3608 struct atmel_private *priv = netdev_priv(dev); 3633 struct atmel_private *priv = netdev_priv(dev);
3609 u8 configuration; 3634 u8 configuration;
3610 3635
3611 /* data to add to the firmware names, in priority order 3636 /* data to add to the firmware names, in priority order
3612 this implemenents firmware versioning */ 3637 this implemenents firmware versioning */
3613 3638
3614 static char *firmware_modifier[] = { 3639 static char *firmware_modifier[] = {
3615 "-wpa", 3640 "-wpa",
3616 "", 3641 "",
3617 NULL 3642 NULL
3618 }; 3643 };
3619 3644
3620 /* reset pccard */ 3645 /* reset pccard */
3621 if (priv->bus_type == BUS_TYPE_PCCARD) 3646 if (priv->bus_type == BUS_TYPE_PCCARD)
3622 atmel_write16(priv->dev, GCR, 0x0060); 3647 atmel_write16(priv->dev, GCR, 0x0060);
3623 3648
3624 /* stop card , disable interrupts */ 3649 /* stop card , disable interrupts */
3625 atmel_write16(priv->dev, GCR, 0x0040); 3650 atmel_write16(priv->dev, GCR, 0x0040);
3626 3651
3627 if (priv->card_type == CARD_TYPE_EEPROM) { 3652 if (priv->card_type == CARD_TYPE_EEPROM) {
3628 /* copy in firmware if needed */ 3653 /* copy in firmware if needed */
3629 const struct firmware *fw_entry = NULL; 3654 const struct firmware *fw_entry = NULL;
@@ -3636,13 +3661,13 @@ static int reset_atmel_card(struct net_device *dev)
3636 "%s: card type is unknown: assuming at76c502 firmware is OK.\n", 3661 "%s: card type is unknown: assuming at76c502 firmware is OK.\n",
3637 dev->name); 3662 dev->name);
3638 printk(KERN_INFO 3663 printk(KERN_INFO
3639 "%s: if not, use the firmware= module parameter.\n", 3664 "%s: if not, use the firmware= module parameter.\n",
3640 dev->name); 3665 dev->name);
3641 strcpy(priv->firmware_id, "atmel_at76c502.bin"); 3666 strcpy(priv->firmware_id, "atmel_at76c502.bin");
3642 } 3667 }
3643 if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) { 3668 if (request_firmware(&fw_entry, priv->firmware_id, priv->sys_dev) != 0) {
3644 printk(KERN_ALERT 3669 printk(KERN_ALERT
3645 "%s: firmware %s is missing, cannot continue.\n", 3670 "%s: firmware %s is missing, cannot continue.\n",
3646 dev->name, priv->firmware_id); 3671 dev->name, priv->firmware_id);
3647 return 0; 3672 return 0;
3648 } 3673 }
@@ -3654,7 +3679,7 @@ static int reset_atmel_card(struct net_device *dev)
3654 while (fw_table[fw_index].fw_type != priv->firmware_type 3679 while (fw_table[fw_index].fw_type != priv->firmware_type
3655 && fw_table[fw_index].fw_type != ATMEL_FW_TYPE_NONE) 3680 && fw_table[fw_index].fw_type != ATMEL_FW_TYPE_NONE)
3656 fw_index++; 3681 fw_index++;
3657 3682
3658 /* construct the actual firmware file name */ 3683 /* construct the actual firmware file name */
3659 if (fw_table[fw_index].fw_type != ATMEL_FW_TYPE_NONE) { 3684 if (fw_table[fw_index].fw_type != ATMEL_FW_TYPE_NONE) {
3660 int i; 3685 int i;
@@ -3669,24 +3694,24 @@ static int reset_atmel_card(struct net_device *dev)
3669 } 3694 }
3670 } 3695 }
3671 if (!success) { 3696 if (!success) {
3672 printk(KERN_ALERT 3697 printk(KERN_ALERT
3673 "%s: firmware %s is missing, cannot start.\n", 3698 "%s: firmware %s is missing, cannot start.\n",
3674 dev->name, priv->firmware_id); 3699 dev->name, priv->firmware_id);
3675 priv->firmware_id[0] = '\0'; 3700 priv->firmware_id[0] = '\0';
3676 return 0; 3701 return 0;
3677 } 3702 }
3678 } 3703 }
3679 3704
3680 fw = fw_entry->data; 3705 fw = fw_entry->data;
3681 len = fw_entry->size; 3706 len = fw_entry->size;
3682 } 3707 }
3683 3708
3684 if (len <= 0x6000) { 3709 if (len <= 0x6000) {
3685 atmel_write16(priv->dev, BSR, BSS_IRAM); 3710 atmel_write16(priv->dev, BSR, BSS_IRAM);
3686 atmel_copy_to_card(priv->dev, 0, fw, len); 3711 atmel_copy_to_card(priv->dev, 0, fw, len);
3687 atmel_set_gcr(priv->dev, GCR_REMAP); 3712 atmel_set_gcr(priv->dev, GCR_REMAP);
3688 } else { 3713 } else {
3689 /* Remap */ 3714 /* Remap */
3690 atmel_set_gcr(priv->dev, GCR_REMAP); 3715 atmel_set_gcr(priv->dev, GCR_REMAP);
3691 atmel_write16(priv->dev, BSR, BSS_IRAM); 3716 atmel_write16(priv->dev, BSR, BSS_IRAM);
3692 atmel_copy_to_card(priv->dev, 0, fw, 0x6000); 3717 atmel_copy_to_card(priv->dev, 0, fw, 0x6000);
@@ -3708,45 +3733,45 @@ static int reset_atmel_card(struct net_device *dev)
3708 the 3com broken-ness filter. */ 3733 the 3com broken-ness filter. */
3709 priv->use_wpa = (priv->host_info.major_version == 4); 3734 priv->use_wpa = (priv->host_info.major_version == 4);
3710 priv->radio_on_broken = (priv->host_info.major_version == 5); 3735 priv->radio_on_broken = (priv->host_info.major_version == 5);
3711 3736
3712 /* unmask all irq sources */ 3737 /* unmask all irq sources */
3713 atmel_wmem8(priv, atmel_hi(priv, IFACE_INT_MASK_OFFSET), 0xff); 3738 atmel_wmem8(priv, atmel_hi(priv, IFACE_INT_MASK_OFFSET), 0xff);
3714 3739
3715 /* int Tx system and enable Tx */ 3740 /* int Tx system and enable Tx */
3716 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, 0), 0); 3741 atmel_wmem8(priv, atmel_tx(priv, TX_DESC_FLAGS_OFFSET, 0), 0);
3717 atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, 0), 0x80000000L); 3742 atmel_wmem32(priv, atmel_tx(priv, TX_DESC_NEXT_OFFSET, 0), 0x80000000L);
3718 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, 0), 0); 3743 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_POS_OFFSET, 0), 0);
3719 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, 0), 0); 3744 atmel_wmem16(priv, atmel_tx(priv, TX_DESC_SIZE_OFFSET, 0), 0);
3720 3745
3721 priv->tx_desc_free = priv->host_info.tx_desc_count; 3746 priv->tx_desc_free = priv->host_info.tx_desc_count;
3722 priv->tx_desc_head = 0; 3747 priv->tx_desc_head = 0;
3723 priv->tx_desc_tail = 0; 3748 priv->tx_desc_tail = 0;
3724 priv->tx_desc_previous = 0; 3749 priv->tx_desc_previous = 0;
3725 priv->tx_free_mem = priv->host_info.tx_buff_size; 3750 priv->tx_free_mem = priv->host_info.tx_buff_size;
3726 priv->tx_buff_head = 0; 3751 priv->tx_buff_head = 0;
3727 priv->tx_buff_tail = 0; 3752 priv->tx_buff_tail = 0;
3728 3753
3729 configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET)); 3754 configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET));
3730 atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), 3755 atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET),
3731 configuration | FUNC_CTRL_TxENABLE); 3756 configuration | FUNC_CTRL_TxENABLE);
3732 3757
3733 /* init Rx system and enable */ 3758 /* init Rx system and enable */
3734 priv->rx_desc_head = 0; 3759 priv->rx_desc_head = 0;
3735 3760
3736 configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET)); 3761 configuration = atmel_rmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET));
3737 atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET), 3762 atmel_wmem8(priv, atmel_hi(priv, IFACE_FUNC_CTRL_OFFSET),
3738 configuration | FUNC_CTRL_RxENABLE); 3763 configuration | FUNC_CTRL_RxENABLE);
3739 3764
3740 if (!priv->radio_on_broken) { 3765 if (!priv->radio_on_broken) {
3741 if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) == 3766 if (atmel_send_command_wait(priv, CMD_EnableRadio, NULL, 0) ==
3742 CMD_STATUS_REJECTED_RADIO_OFF) { 3767 CMD_STATUS_REJECTED_RADIO_OFF) {
3743 printk(KERN_INFO 3768 printk(KERN_INFO
3744 "%s: cannot turn the radio on. (Hey radio, you're beautiful!)\n", 3769 "%s: cannot turn the radio on. (Hey radio, you're beautiful!)\n",
3745 dev->name); 3770 dev->name);
3746 return 0; 3771 return 0;
3747 } 3772 }
3748 } 3773 }
3749 3774
3750 /* set up enough MIB values to run. */ 3775 /* set up enough MIB values to run. */
3751 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_AUTO_TX_RATE_POS, priv->auto_tx_rate); 3776 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_AUTO_TX_RATE_POS, priv->auto_tx_rate);
3752 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_TX_PROMISCUOUS_POS, PROM_MODE_OFF); 3777 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_TX_PROMISCUOUS_POS, PROM_MODE_OFF);
@@ -3755,7 +3780,7 @@ static int reset_atmel_card(struct net_device *dev)
3755 atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_SHORT_RETRY_POS, priv->short_retry); 3780 atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_SHORT_RETRY_POS, priv->short_retry);
3756 atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_LONG_RETRY_POS, priv->long_retry); 3781 atmel_set_mib8(priv, Mac_Mib_Type, MAC_MIB_LONG_RETRY_POS, priv->long_retry);
3757 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, priv->preamble); 3782 atmel_set_mib8(priv, Local_Mib_Type, LOCAL_MIB_PREAMBLE_TYPE, priv->preamble);
3758 atmel_set_mib(priv, Mac_Address_Mib_Type, MAC_ADDR_MIB_MAC_ADDR_POS, 3783 atmel_set_mib(priv, Mac_Address_Mib_Type, MAC_ADDR_MIB_MAC_ADDR_POS,
3759 priv->dev->dev_addr, 6); 3784 priv->dev->dev_addr, 6);
3760 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE); 3785 atmel_set_mib8(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_PS_MODE_POS, ACTIVE_MODE);
3761 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1); 3786 atmel_set_mib16(priv, Mac_Mgmt_Mib_Type, MAC_MGMT_MIB_LISTEN_INTERVAL_POS, 1);
@@ -3766,42 +3791,44 @@ static int reset_atmel_card(struct net_device *dev)
3766 build_wpa_mib(priv); 3791 build_wpa_mib(priv);
3767 else 3792 else
3768 build_wep_mib(priv); 3793 build_wep_mib(priv);
3769 3794
3770 return 1; 3795 return 1;
3771} 3796}
3772 3797
3773static void atmel_send_command(struct atmel_private *priv, int command, void *cmd, int cmd_size) 3798static void atmel_send_command(struct atmel_private *priv, int command,
3799 void *cmd, int cmd_size)
3774{ 3800{
3775 if (cmd) 3801 if (cmd)
3776 atmel_copy_to_card(priv->dev, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET), 3802 atmel_copy_to_card(priv->dev, atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET),
3777 cmd, cmd_size); 3803 cmd, cmd_size);
3778 3804
3779 atmel_wmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET), command); 3805 atmel_wmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET), command);
3780 atmel_wmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET), 0); 3806 atmel_wmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET), 0);
3781} 3807}
3782 3808
3783static int atmel_send_command_wait(struct atmel_private *priv, int command, void *cmd, int cmd_size) 3809static int atmel_send_command_wait(struct atmel_private *priv, int command,
3810 void *cmd, int cmd_size)
3784{ 3811{
3785 int i, status; 3812 int i, status;
3786 3813
3787 atmel_send_command(priv, command, cmd, cmd_size); 3814 atmel_send_command(priv, command, cmd, cmd_size);
3788 3815
3789 for (i = 5000; i; i--) { 3816 for (i = 5000; i; i--) {
3790 status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET)); 3817 status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET));
3791 if (status != CMD_STATUS_IDLE && 3818 if (status != CMD_STATUS_IDLE &&
3792 status != CMD_STATUS_IN_PROGRESS) 3819 status != CMD_STATUS_IN_PROGRESS)
3793 break; 3820 break;
3794 udelay(20); 3821 udelay(20);
3795 } 3822 }
3796 3823
3797 if (i == 0) { 3824 if (i == 0) {
3798 printk(KERN_ALERT "%s: failed to contact MAC.\n", priv->dev->name); 3825 printk(KERN_ALERT "%s: failed to contact MAC.\n", priv->dev->name);
3799 status = CMD_STATUS_HOST_ERROR; 3826 status = CMD_STATUS_HOST_ERROR;
3800 } else { 3827 } else {
3801 if (command != CMD_EnableRadio) 3828 if (command != CMD_EnableRadio)
3802 status = CMD_STATUS_COMPLETE; 3829 status = CMD_STATUS_COMPLETE;
3803 } 3830 }
3804 3831
3805 return status; 3832 return status;
3806} 3833}
3807 3834
@@ -3827,7 +3854,8 @@ static void atmel_set_mib8(struct atmel_private *priv, u8 type, u8 index, u8 dat
3827 atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 1); 3854 atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 1);
3828} 3855}
3829 3856
3830static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, u16 data) 3857static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index,
3858 u16 data)
3831{ 3859{
3832 struct get_set_mib m; 3860 struct get_set_mib m;
3833 m.type = type; 3861 m.type = type;
@@ -3839,7 +3867,8 @@ static void atmel_set_mib16(struct atmel_private *priv, u8 type, u8 index, u16 d
3839 atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 2); 3867 atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + 2);
3840} 3868}
3841 3869
3842static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len) 3870static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index,
3871 u8 *data, int data_len)
3843{ 3872{
3844 struct get_set_mib m; 3873 struct get_set_mib m;
3845 m.type = type; 3874 m.type = type;
@@ -3848,23 +3877,24 @@ static void atmel_set_mib(struct atmel_private *priv, u8 type, u8 index, u8 *dat
3848 3877
3849 if (data_len > MIB_MAX_DATA_BYTES) 3878 if (data_len > MIB_MAX_DATA_BYTES)
3850 printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name); 3879 printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name);
3851 3880
3852 memcpy(m.data, data, data_len); 3881 memcpy(m.data, data, data_len);
3853 atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + data_len); 3882 atmel_send_command_wait(priv, CMD_Set_MIB_Vars, &m, MIB_HEADER_SIZE + data_len);
3854} 3883}
3855 3884
3856static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index, u8 *data, int data_len) 3885static void atmel_get_mib(struct atmel_private *priv, u8 type, u8 index,
3886 u8 *data, int data_len)
3857{ 3887{
3858 struct get_set_mib m; 3888 struct get_set_mib m;
3859 m.type = type; 3889 m.type = type;
3860 m.size = data_len; 3890 m.size = data_len;
3861 m.index = index; 3891 m.index = index;
3862 3892
3863 if (data_len > MIB_MAX_DATA_BYTES) 3893 if (data_len > MIB_MAX_DATA_BYTES)
3864 printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name); 3894 printk(KERN_ALERT "%s: MIB buffer too small.\n", priv->dev->name);
3865 3895
3866 atmel_send_command_wait(priv, CMD_Get_MIB_Vars, &m, MIB_HEADER_SIZE + data_len); 3896 atmel_send_command_wait(priv, CMD_Get_MIB_Vars, &m, MIB_HEADER_SIZE + data_len);
3867 atmel_copy_to_host(priv->dev, data, 3897 atmel_copy_to_host(priv->dev, data,
3868 atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET + MIB_HEADER_SIZE), data_len); 3898 atmel_co(priv, CMD_BLOCK_PARAMETERS_OFFSET + MIB_HEADER_SIZE), data_len);
3869} 3899}
3870 3900
@@ -3873,11 +3903,12 @@ static void atmel_writeAR(struct net_device *dev, u16 data)
3873 int i; 3903 int i;
3874 outw(data, dev->base_addr + AR); 3904 outw(data, dev->base_addr + AR);
3875 /* Address register appears to need some convincing..... */ 3905 /* Address register appears to need some convincing..... */
3876 for (i = 0; data != inw(dev->base_addr + AR) && i<10; i++) 3906 for (i = 0; data != inw(dev->base_addr + AR) && i < 10; i++)
3877 outw(data, dev->base_addr + AR); 3907 outw(data, dev->base_addr + AR);
3878} 3908}
3879 3909
3880static void atmel_copy_to_card(struct net_device *dev, u16 dest, unsigned char *src, u16 len) 3910static void atmel_copy_to_card(struct net_device *dev, u16 dest,
3911 unsigned char *src, u16 len)
3881{ 3912{
3882 int i; 3913 int i;
3883 atmel_writeAR(dev, dest); 3914 atmel_writeAR(dev, dest);
@@ -3894,7 +3925,8 @@ static void atmel_copy_to_card(struct net_device *dev, u16 dest, unsigned char *
3894 atmel_write8(dev, DR, *src); 3925 atmel_write8(dev, DR, *src);
3895} 3926}
3896 3927
3897static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest, u16 src, u16 len) 3928static void atmel_copy_to_host(struct net_device *dev, unsigned char *dest,
3929 u16 src, u16 len)
3898{ 3930{
3899 int i; 3931 int i;
3900 atmel_writeAR(dev, src); 3932 atmel_writeAR(dev, src);
@@ -3930,22 +3962,24 @@ static int atmel_lock_mac(struct atmel_private *priv)
3930 break; 3962 break;
3931 udelay(20); 3963 udelay(20);
3932 } 3964 }
3933 3965
3934 if (!i) return 0; /* timed out */ 3966 if (!i)
3935 3967 return 0; /* timed out */
3968
3936 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 1); 3969 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 1);
3937 if (atmel_rmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_HOST_OFFSET))) { 3970 if (atmel_rmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_HOST_OFFSET))) {
3938 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0); 3971 atmel_wmem8(priv, atmel_hi(priv, IFACE_LOCKOUT_MAC_OFFSET), 0);
3939 if (!j--) return 0; /* timed out */ 3972 if (!j--)
3973 return 0; /* timed out */
3940 goto retry; 3974 goto retry;
3941 } 3975 }
3942 3976
3943 return 1; 3977 return 1;
3944} 3978}
3945 3979
3946static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data) 3980static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data)
3947{ 3981{
3948 atmel_writeAR(priv->dev, pos); 3982 atmel_writeAR(priv->dev, pos);
3949 atmel_write16(priv->dev, DR, data); /* card is little-endian */ 3983 atmel_write16(priv->dev, DR, data); /* card is little-endian */
3950 atmel_write16(priv->dev, DR, data >> 16); 3984 atmel_write16(priv->dev, DR, data >> 16);
3951} 3985}
@@ -4017,9 +4051,9 @@ static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data)
4017 serial output, since SO is normally high. But it 4051 serial output, since SO is normally high. But it
4018 does cause 8 clock cycles and thus 8 bits to be 4052 does cause 8 clock cycles and thus 8 bits to be
4019 clocked in to the chip. See Atmel's SPI 4053 clocked in to the chip. See Atmel's SPI
4020 controller (e.g. AT91M55800) timing and 4K 4054 controller (e.g. AT91M55800) timing and 4K
4021 SPI EEPROM manuals */ 4055 SPI EEPROM manuals */
4022 4056
4023 .set NVRAM_SCRATCH, 0x02000100 /* arbitrary area for scratchpad memory */ 4057 .set NVRAM_SCRATCH, 0x02000100 /* arbitrary area for scratchpad memory */
4024 .set NVRAM_IMAGE, 0x02000200 4058 .set NVRAM_IMAGE, 0x02000200
4025 .set NVRAM_LENGTH, 0x0200 4059 .set NVRAM_LENGTH, 0x0200
@@ -4032,24 +4066,24 @@ static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data)
4032 .set MR4, 0xC 4066 .set MR4, 0xC
4033RESET_VECTOR: 4067RESET_VECTOR:
4034 b RESET_HANDLER 4068 b RESET_HANDLER
4035UNDEF_VECTOR: 4069UNDEF_VECTOR:
4036 b HALT1 4070 b HALT1
4037SWI_VECTOR: 4071SWI_VECTOR:
4038 b HALT1 4072 b HALT1
4039IABORT_VECTOR: 4073IABORT_VECTOR:
4040 b HALT1 4074 b HALT1
4041DABORT_VECTOR: 4075DABORT_VECTOR:
4042RESERVED_VECTOR: 4076RESERVED_VECTOR:
4043 b HALT1 4077 b HALT1
4044IRQ_VECTOR: 4078IRQ_VECTOR:
4045 b HALT1 4079 b HALT1
4046FIQ_VECTOR: 4080FIQ_VECTOR:
4047 b HALT1 4081 b HALT1
4048HALT1: b HALT1 4082HALT1: b HALT1
4049RESET_HANDLER: 4083RESET_HANDLER:
4050 mov r0, #CPSR_INITIAL 4084 mov r0, #CPSR_INITIAL
4051 msr CPSR_c, r0 /* This is probably unnecessary */ 4085 msr CPSR_c, r0 /* This is probably unnecessary */
4052 4086
4053/* I'm guessing this is initializing clock generator electronics for SPI */ 4087/* I'm guessing this is initializing clock generator electronics for SPI */
4054 ldr r0, =SPI_CGEN_BASE 4088 ldr r0, =SPI_CGEN_BASE
4055 mov r1, #0 4089 mov r1, #0
@@ -4061,7 +4095,7 @@ RESET_HANDLER:
4061 str r1, [r0, #28] 4095 str r1, [r0, #28]
4062 mov r1, #1 4096 mov r1, #1
4063 str r1, [r0, #8] 4097 str r1, [r0, #8]
4064 4098
4065 ldr r0, =MRBASE 4099 ldr r0, =MRBASE
4066 mov r1, #0 4100 mov r1, #0
4067 strh r1, [r0, #MR1] 4101 strh r1, [r0, #MR1]
@@ -4094,7 +4128,7 @@ GET_WHOLE_NVRAM:
4094 ldmia sp!, {lr} 4128 ldmia sp!, {lr}
4095 bx lr 4129 bx lr
4096.endfunc 4130.endfunc
4097 4131
4098.func Get_MAC_Addr, GET_MAC_ADDR 4132.func Get_MAC_Addr, GET_MAC_ADDR
4099GET_MAC_ADDR: 4133GET_MAC_ADDR:
4100 stmdb sp!, {lr} 4134 stmdb sp!, {lr}
@@ -4110,13 +4144,13 @@ GET_MAC_ADDR:
4110.func Delay9, DELAY9 4144.func Delay9, DELAY9
4111DELAY9: 4145DELAY9:
4112 adds r0, r0, r0, LSL #3 /* r0 = r0 * 9 */ 4146 adds r0, r0, r0, LSL #3 /* r0 = r0 * 9 */
4113DELAYLOOP: 4147DELAYLOOP:
4114 beq DELAY9_done 4148 beq DELAY9_done
4115 subs r0, r0, #1 4149 subs r0, r0, #1
4116 b DELAYLOOP 4150 b DELAYLOOP
4117DELAY9_done: 4151DELAY9_done:
4118 bx lr 4152 bx lr
4119.endfunc 4153.endfunc
4120 4154
4121.func SP_Init, SP_INIT 4155.func SP_Init, SP_INIT
4122SP_INIT: 4156SP_INIT:
@@ -4145,26 +4179,26 @@ SP_INIT:
4145 ldr r0, [r0, #SP_RDR] 4179 ldr r0, [r0, #SP_RDR]
4146 bx lr 4180 bx lr
4147.endfunc 4181.endfunc
4148.func NVRAM_Init, NVRAM_INIT 4182.func NVRAM_Init, NVRAM_INIT
4149NVRAM_INIT: 4183NVRAM_INIT:
4150 ldr r1, =SP_BASE 4184 ldr r1, =SP_BASE
4151 ldr r0, [r1, #SP_RDR] 4185 ldr r0, [r1, #SP_RDR]
4152 mov r0, #NVRAM_CMD_RDSR 4186 mov r0, #NVRAM_CMD_RDSR
4153 str r0, [r1, #SP_TDR] 4187 str r0, [r1, #SP_TDR]
4154SP_loop1: 4188SP_loop1:
4155 ldr r0, [r1, #SP_SR] 4189 ldr r0, [r1, #SP_SR]
4156 tst r0, #SP_TDRE 4190 tst r0, #SP_TDRE
4157 beq SP_loop1 4191 beq SP_loop1
4158 4192
4159 mov r0, #SPI_8CLOCKS 4193 mov r0, #SPI_8CLOCKS
4160 str r0, [r1, #SP_TDR] 4194 str r0, [r1, #SP_TDR]
4161SP_loop2: 4195SP_loop2:
4162 ldr r0, [r1, #SP_SR] 4196 ldr r0, [r1, #SP_SR]
4163 tst r0, #SP_TDRE 4197 tst r0, #SP_TDRE
4164 beq SP_loop2 4198 beq SP_loop2
4165 4199
4166 ldr r0, [r1, #SP_RDR] 4200 ldr r0, [r1, #SP_RDR]
4167SP_loop3: 4201SP_loop3:
4168 ldr r0, [r1, #SP_SR] 4202 ldr r0, [r1, #SP_SR]
4169 tst r0, #SP_RDRF 4203 tst r0, #SP_RDRF
4170 beq SP_loop3 4204 beq SP_loop3
@@ -4173,7 +4207,7 @@ SP_loop3:
4173 and r0, r0, #255 4207 and r0, r0, #255
4174 bx lr 4208 bx lr
4175.endfunc 4209.endfunc
4176 4210
4177.func NVRAM_Xfer, NVRAM_XFER 4211.func NVRAM_Xfer, NVRAM_XFER
4178 /* r0 = dest address */ 4212 /* r0 = dest address */
4179 /* r1 = not used */ 4213 /* r1 = not used */
@@ -4185,11 +4219,11 @@ NVRAM_XFER:
4185 mov r4, r3 /* save r3 (length) */ 4219 mov r4, r3 /* save r3 (length) */
4186 mov r0, r2, LSR #5 /* SPI memories put A8 in the command field */ 4220 mov r0, r2, LSR #5 /* SPI memories put A8 in the command field */
4187 and r0, r0, #8 4221 and r0, r0, #8
4188 add r0, r0, #NVRAM_CMD_READ 4222 add r0, r0, #NVRAM_CMD_READ
4189 ldr r1, =NVRAM_SCRATCH 4223 ldr r1, =NVRAM_SCRATCH
4190 strb r0, [r1, #0] /* save command in NVRAM_SCRATCH[0] */ 4224 strb r0, [r1, #0] /* save command in NVRAM_SCRATCH[0] */
4191 strb r2, [r1, #1] /* save low byte of source address in NVRAM_SCRATCH[1] */ 4225 strb r2, [r1, #1] /* save low byte of source address in NVRAM_SCRATCH[1] */
4192_local1: 4226_local1:
4193 bl NVRAM_INIT 4227 bl NVRAM_INIT
4194 tst r0, #NVRAM_SR_RDY 4228 tst r0, #NVRAM_SR_RDY
4195 bne _local1 4229 bne _local1
@@ -4211,7 +4245,7 @@ NVRAM_XFER2:
4211 cmp r0, #0 4245 cmp r0, #0
4212 bls _local2 4246 bls _local2
4213 ldr r5, =NVRAM_SCRATCH 4247 ldr r5, =NVRAM_SCRATCH
4214_local4: 4248_local4:
4215 ldrb r6, [r5, r3] 4249 ldrb r6, [r5, r3]
4216 str r6, [r4, #SP_TDR] 4250 str r6, [r4, #SP_TDR]
4217_local3: 4251_local3:
@@ -4225,7 +4259,7 @@ _local2:
4225 mov r3, #SPI_8CLOCKS 4259 mov r3, #SPI_8CLOCKS
4226 str r3, [r4, #SP_TDR] 4260 str r3, [r4, #SP_TDR]
4227 ldr r0, [r4, #SP_RDR] 4261 ldr r0, [r4, #SP_RDR]
4228_local5: 4262_local5:
4229 ldr r0, [r4, #SP_SR] 4263 ldr r0, [r4, #SP_SR]
4230 tst r0, #SP_RDRF 4264 tst r0, #SP_RDRF
4231 beq _local5 4265 beq _local5
@@ -4233,12 +4267,12 @@ _local5:
4233 mov r0, #0 4267 mov r0, #0
4234 cmp r2, #0 /* r2 is # of bytes to copy in */ 4268 cmp r2, #0 /* r2 is # of bytes to copy in */
4235 bls _local6 4269 bls _local6
4236_local7: 4270_local7:
4237 ldr r5, [r4, #SP_SR] 4271 ldr r5, [r4, #SP_SR]
4238 tst r5, #SP_TDRE 4272 tst r5, #SP_TDRE
4239 beq _local7 4273 beq _local7
4240 str r3, [r4, #SP_TDR] /* r3 has SPI_8CLOCKS */ 4274 str r3, [r4, #SP_TDR] /* r3 has SPI_8CLOCKS */
4241_local8: 4275_local8:
4242 ldr r5, [r4, #SP_SR] 4276 ldr r5, [r4, #SP_SR]
4243 tst r5, #SP_RDRF 4277 tst r5, #SP_RDRF
4244 beq _local8 4278 beq _local8
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 17d1fd90f832..d6f4a5a3e55a 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -93,8 +93,6 @@ MODULE_SUPPORTED_DEVICE("Atmel at76c50x PCMCIA cards");
93 93
94static void atmel_config(dev_link_t *link); 94static void atmel_config(dev_link_t *link);
95static void atmel_release(dev_link_t *link); 95static void atmel_release(dev_link_t *link);
96static int atmel_event(event_t event, int priority,
97 event_callback_args_t *args);
98 96
99/* 97/*
100 The attach() and detach() entry points are used to create and destroy 98 The attach() and detach() entry points are used to create and destroy
@@ -102,8 +100,7 @@ static int atmel_event(event_t event, int priority,
102 needed to manage one actual PCMCIA card. 100 needed to manage one actual PCMCIA card.
103*/ 101*/
104 102
105static dev_link_t *atmel_attach(void); 103static void atmel_detach(struct pcmcia_device *p_dev);
106static void atmel_detach(dev_link_t *);
107 104
108/* 105/*
109 You'll also need to prototype all the functions that will actually 106 You'll also need to prototype all the functions that will actually
@@ -113,14 +110,6 @@ static void atmel_detach(dev_link_t *);
113*/ 110*/
114 111
115/* 112/*
116 The dev_info variable is the "key" that is used to match up this
117 device driver with appropriate cards, through the card configuration
118 database.
119*/
120
121static dev_info_t dev_info = "atmel_cs";
122
123/*
124 A linked list of "instances" of the atmelnet device. Each actual 113 A linked list of "instances" of the atmelnet device. Each actual
125 PCMCIA card corresponds to one device instance, and is described 114 PCMCIA card corresponds to one device instance, and is described
126 by one dev_link_t structure (defined in ds.h). 115 by one dev_link_t structure (defined in ds.h).
@@ -130,15 +119,7 @@ static dev_info_t dev_info = "atmel_cs";
130 device numbers are used to derive the corresponding array index. 119 device numbers are used to derive the corresponding array index.
131*/ 120*/
132 121
133static dev_link_t *dev_list = NULL;
134
135/* 122/*
136 A dev_link_t structure has fields for most things that are needed
137 to keep track of a socket, but there will usually be some device
138 specific information that also needs to be kept track of. The
139 'priv' pointer in a dev_link_t structure can be used to point to
140 a device-specific private data structure, like this.
141
142 A driver needs to provide a dev_node_t structure for each device 123 A driver needs to provide a dev_node_t structure for each device
143 on a card. In some cases, there is only one device per card (for 124 on a card. In some cases, there is only one device per card (for
144 example, ethernet cards, modems). In other cases, there may be 125 example, ethernet cards, modems). In other cases, there may be
@@ -171,27 +152,25 @@ typedef struct local_info_t {
171 152
172 ======================================================================*/ 153 ======================================================================*/
173 154
174static dev_link_t *atmel_attach(void) 155static int atmel_attach(struct pcmcia_device *p_dev)
175{ 156{
176 client_reg_t client_reg;
177 dev_link_t *link; 157 dev_link_t *link;
178 local_info_t *local; 158 local_info_t *local;
179 int ret; 159
180
181 DEBUG(0, "atmel_attach()\n"); 160 DEBUG(0, "atmel_attach()\n");
182 161
183 /* Initialize the dev_link_t structure */ 162 /* Initialize the dev_link_t structure */
184 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 163 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
185 if (!link) { 164 if (!link) {
186 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 165 printk(KERN_ERR "atmel_cs: no memory for new device\n");
187 return NULL; 166 return -ENOMEM;
188 } 167 }
189 168
190 /* Interrupt setup */ 169 /* Interrupt setup */
191 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE; 170 link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
192 link->irq.IRQInfo1 = IRQ_LEVEL_ID; 171 link->irq.IRQInfo1 = IRQ_LEVEL_ID;
193 link->irq.Handler = NULL; 172 link->irq.Handler = NULL;
194 173
195 /* 174 /*
196 General socket configuration defaults can go here. In this 175 General socket configuration defaults can go here. In this
197 client, we assume very little, and rely on the CIS for almost 176 client, we assume very little, and rely on the CIS for almost
@@ -202,30 +181,23 @@ static dev_link_t *atmel_attach(void)
202 link->conf.Attributes = 0; 181 link->conf.Attributes = 0;
203 link->conf.Vcc = 50; 182 link->conf.Vcc = 50;
204 link->conf.IntType = INT_MEMORY_AND_IO; 183 link->conf.IntType = INT_MEMORY_AND_IO;
205 184
206 /* Allocate space for private device-specific data */ 185 /* Allocate space for private device-specific data */
207 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 186 local = kzalloc(sizeof(local_info_t), GFP_KERNEL);
208 if (!local) { 187 if (!local) {
209 printk(KERN_ERR "atmel_cs: no memory for new device\n"); 188 printk(KERN_ERR "atmel_cs: no memory for new device\n");
210 kfree (link); 189 kfree (link);
211 return NULL; 190 return -ENOMEM;
212 } 191 }
213 link->priv = local; 192 link->priv = local;
214 193
215 /* Register with Card Services */ 194 link->handle = p_dev;
216 link->next = dev_list; 195 p_dev->instance = link;
217 dev_list = link; 196
218 client_reg.dev_info = &dev_info; 197 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
219 client_reg.Version = 0x0210; 198 atmel_config(link);
220 client_reg.event_callback_args.client_data = link; 199
221 ret = pcmcia_register_client(&link->handle, &client_reg); 200 return 0;
222 if (ret != 0) {
223 cs_error(link->handle, RegisterClient, ret);
224 atmel_detach(link);
225 return NULL;
226 }
227
228 return link;
229} /* atmel_attach */ 201} /* atmel_attach */
230 202
231/*====================================================================== 203/*======================================================================
@@ -237,27 +209,15 @@ static dev_link_t *atmel_attach(void)
237 209
238 ======================================================================*/ 210 ======================================================================*/
239 211
240static void atmel_detach(dev_link_t *link) 212static void atmel_detach(struct pcmcia_device *p_dev)
241{ 213{
242 dev_link_t **linkp; 214 dev_link_t *link = dev_to_instance(p_dev);
243 215
244 DEBUG(0, "atmel_detach(0x%p)\n", link); 216 DEBUG(0, "atmel_detach(0x%p)\n", link);
245
246 /* Locate device structure */
247 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
248 if (*linkp == link) break;
249 if (*linkp == NULL)
250 return;
251 217
252 if (link->state & DEV_CONFIG) 218 if (link->state & DEV_CONFIG)
253 atmel_release(link); 219 atmel_release(link);
254
255 /* Break the link with Card Services */
256 if (link->handle)
257 pcmcia_deregister_client(link->handle);
258 220
259 /* Unlink device structure, free pieces */
260 *linkp = link->next;
261 kfree(link->priv); 221 kfree(link->priv);
262 kfree(link); 222 kfree(link);
263} 223}
@@ -477,60 +437,34 @@ static void atmel_release(dev_link_t *link)
477 link->state &= ~DEV_CONFIG; 437 link->state &= ~DEV_CONFIG;
478} 438}
479 439
480/*====================================================================== 440static int atmel_suspend(struct pcmcia_device *dev)
481 441{
482 The card status event handler. Mostly, this schedules other 442 dev_link_t *link = dev_to_instance(dev);
483 stuff to run after an event is received. 443 local_info_t *local = link->priv;
484 444
485 When a CARD_REMOVAL event is received, we immediately set a 445 link->state |= DEV_SUSPEND;
486 private flag to block future accesses to this device. All the 446 if (link->state & DEV_CONFIG) {
487 functions that actually access the device should check this flag 447 netif_device_detach(local->eth_dev);
488 to make sure the card is still present. 448 pcmcia_release_configuration(link->handle);
489 449 }
490 ======================================================================*/ 450
451 return 0;
452}
491 453
492static int atmel_event(event_t event, int priority, 454static int atmel_resume(struct pcmcia_device *dev)
493 event_callback_args_t *args)
494{ 455{
495 dev_link_t *link = args->client_data; 456 dev_link_t *link = dev_to_instance(dev);
496 local_info_t *local = link->priv; 457 local_info_t *local = link->priv;
497 458
498 DEBUG(1, "atmel_event(0x%06x)\n", event); 459 link->state &= ~DEV_SUSPEND;
499 460 if (link->state & DEV_CONFIG) {
500 switch (event) { 461 pcmcia_request_configuration(link->handle, &link->conf);
501 case CS_EVENT_CARD_REMOVAL: 462 atmel_open(local->eth_dev);
502 link->state &= ~DEV_PRESENT; 463 netif_device_attach(local->eth_dev);
503 if (link->state & DEV_CONFIG) {
504 netif_device_detach(local->eth_dev);
505 atmel_release(link);
506 }
507 break;
508 case CS_EVENT_CARD_INSERTION:
509 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
510 atmel_config(link);
511 break;
512 case CS_EVENT_PM_SUSPEND:
513 link->state |= DEV_SUSPEND;
514 /* Fall through... */
515 case CS_EVENT_RESET_PHYSICAL:
516 if (link->state & DEV_CONFIG) {
517 netif_device_detach(local->eth_dev);
518 pcmcia_release_configuration(link->handle);
519 }
520 break;
521 case CS_EVENT_PM_RESUME:
522 link->state &= ~DEV_SUSPEND;
523 /* Fall through... */
524 case CS_EVENT_CARD_RESET:
525 if (link->state & DEV_CONFIG) {
526 pcmcia_request_configuration(link->handle, &link->conf);
527 atmel_open(local->eth_dev);
528 netif_device_attach(local->eth_dev);
529 }
530 break;
531 } 464 }
465
532 return 0; 466 return 0;
533} /* atmel_event */ 467}
534 468
535/*====================================================================*/ 469/*====================================================================*/
536/* We use the driver_info field to store the correct firmware type for a card. */ 470/* We use the driver_info field to store the correct firmware type for a card. */
@@ -581,10 +515,11 @@ static struct pcmcia_driver atmel_driver = {
581 .drv = { 515 .drv = {
582 .name = "atmel_cs", 516 .name = "atmel_cs",
583 }, 517 },
584 .attach = atmel_attach, 518 .probe = atmel_attach,
585 .event = atmel_event, 519 .remove = atmel_detach,
586 .detach = atmel_detach,
587 .id_table = atmel_ids, 520 .id_table = atmel_ids,
521 .suspend = atmel_suspend,
522 .resume = atmel_resume,
588}; 523};
589 524
590static int atmel_cs_init(void) 525static int atmel_cs_init(void)
@@ -595,7 +530,6 @@ static int atmel_cs_init(void)
595static void atmel_cs_cleanup(void) 530static void atmel_cs_cleanup(void)
596{ 531{
597 pcmcia_unregister_driver(&atmel_driver); 532 pcmcia_unregister_driver(&atmel_driver);
598 BUG_ON(dev_list != NULL);
599} 533}
600 534
601/* 535/*
diff --git a/drivers/net/wireless/hostap/Makefile b/drivers/net/wireless/hostap/Makefile
index fc62235bfc24..353ccb93134b 100644
--- a/drivers/net/wireless/hostap/Makefile
+++ b/drivers/net/wireless/hostap/Makefile
@@ -1,3 +1,4 @@
1hostap-y := hostap_main.o
1obj-$(CONFIG_HOSTAP) += hostap.o 2obj-$(CONFIG_HOSTAP) += hostap.o
2 3
3obj-$(CONFIG_HOSTAP_CS) += hostap_cs.o 4obj-$(CONFIG_HOSTAP_CS) += hostap_cs.o
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 2643976a6677..8bc0b528548f 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -25,7 +25,6 @@
25 25
26static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)"; 26static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)";
27static dev_info_t dev_info = "hostap_cs"; 27static dev_info_t dev_info = "hostap_cs";
28static dev_link_t *dev_list = NULL;
29 28
30MODULE_AUTHOR("Jouni Malinen"); 29MODULE_AUTHOR("Jouni Malinen");
31MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN " 30MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
@@ -203,10 +202,9 @@ static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
203 202
204 203
205 204
206static void prism2_detach(dev_link_t *link); 205static void prism2_detach(struct pcmcia_device *p_dev);
207static void prism2_release(u_long arg); 206static void prism2_release(u_long arg);
208static int prism2_event(event_t event, int priority, 207static int prism2_config(dev_link_t *link);
209 event_callback_args_t *args);
210 208
211 209
212static int prism2_pccard_card_present(local_info_t *local) 210static int prism2_pccard_card_present(local_info_t *local)
@@ -503,15 +501,13 @@ static struct prism2_helper_functions prism2_pccard_funcs =
503 501
504/* allocate local data and register with CardServices 502/* allocate local data and register with CardServices
505 * initialize dev_link structure, but do not configure the card yet */ 503 * initialize dev_link structure, but do not configure the card yet */
506static dev_link_t *prism2_attach(void) 504static int prism2_attach(struct pcmcia_device *p_dev)
507{ 505{
508 dev_link_t *link; 506 dev_link_t *link;
509 client_reg_t client_reg;
510 int ret;
511 507
512 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL); 508 link = kmalloc(sizeof(dev_link_t), GFP_KERNEL);
513 if (link == NULL) 509 if (link == NULL)
514 return NULL; 510 return -ENOMEM;
515 511
516 memset(link, 0, sizeof(dev_link_t)); 512 memset(link, 0, sizeof(dev_link_t));
517 513
@@ -519,50 +515,27 @@ static dev_link_t *prism2_attach(void)
519 link->conf.Vcc = 33; 515 link->conf.Vcc = 33;
520 link->conf.IntType = INT_MEMORY_AND_IO; 516 link->conf.IntType = INT_MEMORY_AND_IO;
521 517
522 /* register with CardServices */ 518 link->handle = p_dev;
523 link->next = dev_list; 519 p_dev->instance = link;
524 dev_list = link; 520
525 client_reg.dev_info = &dev_info; 521 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
526 client_reg.Version = 0x0210; 522 if (prism2_config(link))
527 client_reg.event_callback_args.client_data = link; 523 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
528 ret = pcmcia_register_client(&link->handle, &client_reg); 524
529 if (ret != CS_SUCCESS) { 525 return 0;
530 cs_error(link->handle, RegisterClient, ret);
531 prism2_detach(link);
532 return NULL;
533 }
534 return link;
535} 526}
536 527
537 528
538static void prism2_detach(dev_link_t *link) 529static void prism2_detach(struct pcmcia_device *p_dev)
539{ 530{
540 dev_link_t **linkp; 531 dev_link_t *link = dev_to_instance(p_dev);
541 532
542 PDEBUG(DEBUG_FLOW, "prism2_detach\n"); 533 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
543 534
544 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
545 if (*linkp == link)
546 break;
547 if (*linkp == NULL) {
548 printk(KERN_WARNING "%s: Attempt to detach non-existing "
549 "PCMCIA client\n", dev_info);
550 return;
551 }
552
553 if (link->state & DEV_CONFIG) { 535 if (link->state & DEV_CONFIG) {
554 prism2_release((u_long)link); 536 prism2_release((u_long)link);
555 } 537 }
556 538
557 if (link->handle) {
558 int res = pcmcia_deregister_client(link->handle);
559 if (res) {
560 printk("CardService(DeregisterClient) => %d\n", res);
561 cs_error(link->handle, DeregisterClient, res);
562 }
563 }
564
565 *linkp = link->next;
566 /* release net devices */ 539 /* release net devices */
567 if (link->priv) { 540 if (link->priv) {
568 struct hostap_cs_priv *hw_priv; 541 struct hostap_cs_priv *hw_priv;
@@ -846,84 +819,58 @@ static void prism2_release(u_long arg)
846 PDEBUG(DEBUG_FLOW, "release - done\n"); 819 PDEBUG(DEBUG_FLOW, "release - done\n");
847} 820}
848 821
849 822static int hostap_cs_suspend(struct pcmcia_device *p_dev)
850static int prism2_event(event_t event, int priority,
851 event_callback_args_t *args)
852{ 823{
853 dev_link_t *link = args->client_data; 824 dev_link_t *link = dev_to_instance(p_dev);
854 struct net_device *dev = (struct net_device *) link->priv; 825 struct net_device *dev = (struct net_device *) link->priv;
855 int dev_open = 0; 826 int dev_open = 0;
856 827
828 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
829
830 link->state |= DEV_SUSPEND;
831
857 if (link->state & DEV_CONFIG) { 832 if (link->state & DEV_CONFIG) {
858 struct hostap_interface *iface = netdev_priv(dev); 833 struct hostap_interface *iface = netdev_priv(dev);
859 if (iface && iface->local) 834 if (iface && iface->local)
860 dev_open = iface->local->num_dev_open > 0; 835 dev_open = iface->local->num_dev_open > 0;
861 } 836 if (dev_open) {
862
863 switch (event) {
864 case CS_EVENT_CARD_INSERTION:
865 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_INSERTION\n", dev_info);
866 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
867 if (prism2_config(link)) {
868 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
869 }
870 break;
871
872 case CS_EVENT_CARD_REMOVAL:
873 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_REMOVAL\n", dev_info);
874 link->state &= ~DEV_PRESENT;
875 if (link->state & DEV_CONFIG) {
876 netif_stop_queue(dev); 837 netif_stop_queue(dev);
877 netif_device_detach(dev); 838 netif_device_detach(dev);
878 prism2_release((u_long) link);
879 } 839 }
880 break; 840 prism2_suspend(dev);
841 pcmcia_release_configuration(link->handle);
842 }
881 843
882 case CS_EVENT_PM_SUSPEND: 844 return 0;
883 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); 845}
884 link->state |= DEV_SUSPEND;
885 /* fall through */
886
887 case CS_EVENT_RESET_PHYSICAL:
888 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_RESET_PHYSICAL\n", dev_info);
889 if (link->state & DEV_CONFIG) {
890 if (dev_open) {
891 netif_stop_queue(dev);
892 netif_device_detach(dev);
893 }
894 prism2_suspend(dev);
895 pcmcia_release_configuration(link->handle);
896 }
897 break;
898 846
899 case CS_EVENT_PM_RESUME: 847static int hostap_cs_resume(struct pcmcia_device *p_dev)
900 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); 848{
901 link->state &= ~DEV_SUSPEND; 849 dev_link_t *link = dev_to_instance(p_dev);
902 /* fall through */ 850 struct net_device *dev = (struct net_device *) link->priv;
903 851 int dev_open = 0;
904 case CS_EVENT_CARD_RESET:
905 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_CARD_RESET\n", dev_info);
906 if (link->state & DEV_CONFIG) {
907 pcmcia_request_configuration(link->handle,
908 &link->conf);
909 prism2_hw_shutdown(dev, 1);
910 prism2_hw_config(dev, dev_open ? 0 : 1);
911 if (dev_open) {
912 netif_device_attach(dev);
913 netif_start_queue(dev);
914 }
915 }
916 break;
917 852
918 default: 853 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
919 PDEBUG(DEBUG_EXTRA, "%s: prism2_event() - unknown event %d\n", 854
920 dev_info, event); 855 link->state &= ~DEV_SUSPEND;
921 break; 856 if (link->state & DEV_CONFIG) {
857 struct hostap_interface *iface = netdev_priv(dev);
858 if (iface && iface->local)
859 dev_open = iface->local->num_dev_open > 0;
860
861 pcmcia_request_configuration(link->handle, &link->conf);
862
863 prism2_hw_shutdown(dev, 1);
864 prism2_hw_config(dev, dev_open ? 0 : 1);
865 if (dev_open) {
866 netif_device_attach(dev);
867 netif_start_queue(dev);
868 }
922 } 869 }
870
923 return 0; 871 return 0;
924} 872}
925 873
926
927static struct pcmcia_device_id hostap_cs_ids[] = { 874static struct pcmcia_device_id hostap_cs_ids[] = {
928 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100), 875 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),
929 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300), 876 PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
@@ -982,11 +929,12 @@ static struct pcmcia_driver hostap_driver = {
982 .drv = { 929 .drv = {
983 .name = "hostap_cs", 930 .name = "hostap_cs",
984 }, 931 },
985 .attach = prism2_attach, 932 .probe = prism2_attach,
986 .detach = prism2_detach, 933 .remove = prism2_detach,
987 .owner = THIS_MODULE, 934 .owner = THIS_MODULE,
988 .event = prism2_event,
989 .id_table = hostap_cs_ids, 935 .id_table = hostap_cs_ids,
936 .suspend = hostap_cs_suspend,
937 .resume = hostap_cs_resume,
990}; 938};
991 939
992static int __init init_prism2_pccard(void) 940static int __init init_prism2_pccard(void)
diff --git a/drivers/net/wireless/hostap/hostap.c b/drivers/net/wireless/hostap/hostap_main.c
index 3d2ea61033be..3d2ea61033be 100644
--- a/drivers/net/wireless/hostap/hostap.c
+++ b/drivers/net/wireless/hostap/hostap_main.c
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index 77d2a21d4cd0..44cd3fcd1572 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -175,7 +175,7 @@ that only one external action is invoked at a time.
175#define DRV_COPYRIGHT "Copyright(c) 2003-2005 Intel Corporation" 175#define DRV_COPYRIGHT "Copyright(c) 2003-2005 Intel Corporation"
176 176
177/* Debugging stuff */ 177/* Debugging stuff */
178#ifdef CONFIG_IPW_DEBUG 178#ifdef CONFIG_IPW2100_DEBUG
179#define CONFIG_IPW2100_RX_DEBUG /* Reception debugging */ 179#define CONFIG_IPW2100_RX_DEBUG /* Reception debugging */
180#endif 180#endif
181 181
@@ -208,7 +208,7 @@ MODULE_PARM_DESC(disable, "manually disable the radio (default 0 [radio on])");
208 208
209static u32 ipw2100_debug_level = IPW_DL_NONE; 209static u32 ipw2100_debug_level = IPW_DL_NONE;
210 210
211#ifdef CONFIG_IPW_DEBUG 211#ifdef CONFIG_IPW2100_DEBUG
212#define IPW_DEBUG(level, message...) \ 212#define IPW_DEBUG(level, message...) \
213do { \ 213do { \
214 if (ipw2100_debug_level & (level)) { \ 214 if (ipw2100_debug_level & (level)) { \
@@ -219,9 +219,9 @@ do { \
219} while (0) 219} while (0)
220#else 220#else
221#define IPW_DEBUG(level, message...) do {} while (0) 221#define IPW_DEBUG(level, message...) do {} while (0)
222#endif /* CONFIG_IPW_DEBUG */ 222#endif /* CONFIG_IPW2100_DEBUG */
223 223
224#ifdef CONFIG_IPW_DEBUG 224#ifdef CONFIG_IPW2100_DEBUG
225static const char *command_types[] = { 225static const char *command_types[] = {
226 "undefined", 226 "undefined",
227 "unused", /* HOST_ATTENTION */ 227 "unused", /* HOST_ATTENTION */
@@ -2081,7 +2081,7 @@ static void isr_scan_complete(struct ipw2100_priv *priv, u32 status)
2081 priv->status &= ~STATUS_SCANNING; 2081 priv->status &= ~STATUS_SCANNING;
2082} 2082}
2083 2083
2084#ifdef CONFIG_IPW_DEBUG 2084#ifdef CONFIG_IPW2100_DEBUG
2085#define IPW2100_HANDLER(v, f) { v, f, # v } 2085#define IPW2100_HANDLER(v, f) { v, f, # v }
2086struct ipw2100_status_indicator { 2086struct ipw2100_status_indicator {
2087 int status; 2087 int status;
@@ -2094,7 +2094,7 @@ struct ipw2100_status_indicator {
2094 int status; 2094 int status;
2095 void (*cb) (struct ipw2100_priv * priv, u32 status); 2095 void (*cb) (struct ipw2100_priv * priv, u32 status);
2096}; 2096};
2097#endif /* CONFIG_IPW_DEBUG */ 2097#endif /* CONFIG_IPW2100_DEBUG */
2098 2098
2099static void isr_indicate_scanning(struct ipw2100_priv *priv, u32 status) 2099static void isr_indicate_scanning(struct ipw2100_priv *priv, u32 status)
2100{ 2100{
@@ -2149,7 +2149,7 @@ static void isr_status_change(struct ipw2100_priv *priv, int status)
2149static void isr_rx_complete_command(struct ipw2100_priv *priv, 2149static void isr_rx_complete_command(struct ipw2100_priv *priv,
2150 struct ipw2100_cmd_header *cmd) 2150 struct ipw2100_cmd_header *cmd)
2151{ 2151{
2152#ifdef CONFIG_IPW_DEBUG 2152#ifdef CONFIG_IPW2100_DEBUG
2153 if (cmd->host_command_reg < ARRAY_SIZE(command_types)) { 2153 if (cmd->host_command_reg < ARRAY_SIZE(command_types)) {
2154 IPW_DEBUG_HC("Command completed '%s (%d)'\n", 2154 IPW_DEBUG_HC("Command completed '%s (%d)'\n",
2155 command_types[cmd->host_command_reg], 2155 command_types[cmd->host_command_reg],
@@ -2167,7 +2167,7 @@ static void isr_rx_complete_command(struct ipw2100_priv *priv,
2167 wake_up_interruptible(&priv->wait_command_queue); 2167 wake_up_interruptible(&priv->wait_command_queue);
2168} 2168}
2169 2169
2170#ifdef CONFIG_IPW_DEBUG 2170#ifdef CONFIG_IPW2100_DEBUG
2171static const char *frame_types[] = { 2171static const char *frame_types[] = {
2172 "COMMAND_STATUS_VAL", 2172 "COMMAND_STATUS_VAL",
2173 "STATUS_CHANGE_VAL", 2173 "STATUS_CHANGE_VAL",
@@ -2290,7 +2290,7 @@ static u8 packet_data[IPW_RX_NIC_BUFFER_LENGTH];
2290 2290
2291static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i) 2291static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i)
2292{ 2292{
2293#ifdef CONFIG_IPW_DEBUG_C3 2293#ifdef CONFIG_IPW2100_DEBUG_C3
2294 struct ipw2100_status *status = &priv->status_queue.drv[i]; 2294 struct ipw2100_status *status = &priv->status_queue.drv[i];
2295 u32 match, reg; 2295 u32 match, reg;
2296 int j; 2296 int j;
@@ -2312,7 +2312,7 @@ static inline void ipw2100_corruption_detected(struct ipw2100_priv *priv, int i)
2312 } 2312 }
2313#endif 2313#endif
2314 2314
2315#ifdef CONFIG_IPW_DEBUG_C3 2315#ifdef CONFIG_IPW2100_DEBUG_C3
2316 /* Halt the fimrware so we can get a good image */ 2316 /* Halt the fimrware so we can get a good image */
2317 write_register(priv->net_dev, IPW_REG_RESET_REG, 2317 write_register(priv->net_dev, IPW_REG_RESET_REG,
2318 IPW_AUX_HOST_RESET_REG_STOP_MASTER); 2318 IPW_AUX_HOST_RESET_REG_STOP_MASTER);
@@ -2716,7 +2716,7 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2716 list_del(element); 2716 list_del(element);
2717 DEC_STAT(&priv->fw_pend_stat); 2717 DEC_STAT(&priv->fw_pend_stat);
2718 2718
2719#ifdef CONFIG_IPW_DEBUG 2719#ifdef CONFIG_IPW2100_DEBUG
2720 { 2720 {
2721 int i = txq->oldest; 2721 int i = txq->oldest;
2722 IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i, 2722 IPW_DEBUG_TX("TX%d V=%p P=%04X T=%04X L=%d\n", i,
@@ -2782,7 +2782,7 @@ static inline int __ipw2100_tx_process(struct ipw2100_priv *priv)
2782 "something else: ids %d=%d.\n", 2782 "something else: ids %d=%d.\n",
2783 priv->net_dev->name, txq->oldest, packet->index); 2783 priv->net_dev->name, txq->oldest, packet->index);
2784 2784
2785#ifdef CONFIG_IPW_DEBUG 2785#ifdef CONFIG_IPW2100_DEBUG
2786 if (packet->info.c_struct.cmd->host_command_reg < 2786 if (packet->info.c_struct.cmd->host_command_reg <
2787 sizeof(command_types) / sizeof(*command_types)) 2787 sizeof(command_types) / sizeof(*command_types))
2788 IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n", 2788 IPW_DEBUG_TX("Command '%s (%d)' processed: %d.\n",
@@ -2975,7 +2975,7 @@ static void ipw2100_tx_send_data(struct ipw2100_priv *priv)
2975 2975
2976 IPW_DEBUG_TX("data header tbd TX%d P=%08x L=%d\n", 2976 IPW_DEBUG_TX("data header tbd TX%d P=%08x L=%d\n",
2977 packet->index, tbd->host_addr, tbd->buf_length); 2977 packet->index, tbd->host_addr, tbd->buf_length);
2978#ifdef CONFIG_IPW_DEBUG 2978#ifdef CONFIG_IPW2100_DEBUG
2979 if (packet->info.d_struct.txb->nr_frags > 1) 2979 if (packet->info.d_struct.txb->nr_frags > 1)
2980 IPW_DEBUG_FRAG("fragment Tx: %d frames\n", 2980 IPW_DEBUG_FRAG("fragment Tx: %d frames\n",
2981 packet->info.d_struct.txb->nr_frags); 2981 packet->info.d_struct.txb->nr_frags);
@@ -3827,7 +3827,7 @@ static ssize_t show_stats(struct device *d, struct device_attribute *attr,
3827 priv->rx_interrupts, priv->inta_other); 3827 priv->rx_interrupts, priv->inta_other);
3828 out += sprintf(out, "firmware resets: %d\n", priv->resets); 3828 out += sprintf(out, "firmware resets: %d\n", priv->resets);
3829 out += sprintf(out, "firmware hangs: %d\n", priv->hangs); 3829 out += sprintf(out, "firmware hangs: %d\n", priv->hangs);
3830#ifdef CONFIG_IPW_DEBUG 3830#ifdef CONFIG_IPW2100_DEBUG
3831 out += sprintf(out, "packet mismatch image: %s\n", 3831 out += sprintf(out, "packet mismatch image: %s\n",
3832 priv->snapshot[0] ? "YES" : "NO"); 3832 priv->snapshot[0] ? "YES" : "NO");
3833#endif 3833#endif
@@ -3982,7 +3982,7 @@ static ssize_t show_bssinfo(struct device *d, struct device_attribute *attr,
3982 3982
3983static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL); 3983static DEVICE_ATTR(bssinfo, S_IRUGO, show_bssinfo, NULL);
3984 3984
3985#ifdef CONFIG_IPW_DEBUG 3985#ifdef CONFIG_IPW2100_DEBUG
3986static ssize_t show_debug_level(struct device_driver *d, char *buf) 3986static ssize_t show_debug_level(struct device_driver *d, char *buf)
3987{ 3987{
3988 return sprintf(buf, "0x%08X\n", ipw2100_debug_level); 3988 return sprintf(buf, "0x%08X\n", ipw2100_debug_level);
@@ -4011,7 +4011,7 @@ static ssize_t store_debug_level(struct device_driver *d,
4011 4011
4012static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level, 4012static DRIVER_ATTR(debug_level, S_IWUSR | S_IRUGO, show_debug_level,
4013 store_debug_level); 4013 store_debug_level);
4014#endif /* CONFIG_IPW_DEBUG */ 4014#endif /* CONFIG_IPW2100_DEBUG */
4015 4015
4016static ssize_t show_fatal_error(struct device *d, 4016static ssize_t show_fatal_error(struct device *d,
4017 struct device_attribute *attr, char *buf) 4017 struct device_attribute *attr, char *buf)
@@ -4937,7 +4937,7 @@ static int ipw2100_set_mandatory_bssid(struct ipw2100_priv *priv, u8 * bssid,
4937 }; 4937 };
4938 int err; 4938 int err;
4939 4939
4940#ifdef CONFIG_IPW_DEBUG 4940#ifdef CONFIG_IPW2100_DEBUG
4941 if (bssid != NULL) 4941 if (bssid != NULL)
4942 IPW_DEBUG_HC("MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n", 4942 IPW_DEBUG_HC("MANDATORY_BSSID: %02X:%02X:%02X:%02X:%02X:%02X\n",
4943 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], 4943 bssid[0], bssid[1], bssid[2], bssid[3], bssid[4],
@@ -6858,7 +6858,7 @@ static int __init ipw2100_init(void)
6858 6858
6859 ret = pci_module_init(&ipw2100_pci_driver); 6859 ret = pci_module_init(&ipw2100_pci_driver);
6860 6860
6861#ifdef CONFIG_IPW_DEBUG 6861#ifdef CONFIG_IPW2100_DEBUG
6862 ipw2100_debug_level = debug; 6862 ipw2100_debug_level = debug;
6863 driver_create_file(&ipw2100_pci_driver.driver, 6863 driver_create_file(&ipw2100_pci_driver.driver,
6864 &driver_attr_debug_level); 6864 &driver_attr_debug_level);
@@ -6873,7 +6873,7 @@ static int __init ipw2100_init(void)
6873static void __exit ipw2100_exit(void) 6873static void __exit ipw2100_exit(void)
6874{ 6874{
6875 /* FIXME: IPG: check that we have no instances of the devices open */ 6875 /* FIXME: IPG: check that we have no instances of the devices open */
6876#ifdef CONFIG_IPW_DEBUG 6876#ifdef CONFIG_IPW2100_DEBUG
6877 driver_remove_file(&ipw2100_pci_driver.driver, 6877 driver_remove_file(&ipw2100_pci_driver.driver,
6878 &driver_attr_debug_level); 6878 &driver_attr_debug_level);
6879#endif 6879#endif
@@ -8558,7 +8558,7 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev)
8558 8558
8559 quality = min(beacon_qual, min(tx_qual, rssi_qual)); 8559 quality = min(beacon_qual, min(tx_qual, rssi_qual));
8560 8560
8561#ifdef CONFIG_IPW_DEBUG 8561#ifdef CONFIG_IPW2100_DEBUG
8562 if (beacon_qual == quality) 8562 if (beacon_qual == quality)
8563 IPW_DEBUG_WX("Quality clamped by Missed Beacons\n"); 8563 IPW_DEBUG_WX("Quality clamped by Missed Beacons\n");
8564 else if (tx_qual == quality) 8564 else if (tx_qual == quality)
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index 7c65b10bb164..f6c51441fa87 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -73,7 +73,7 @@ struct ipw2100_rx_packet;
73 * you simply need to add your entry to the ipw2100_debug_levels array. 73 * you simply need to add your entry to the ipw2100_debug_levels array.
74 * 74 *
75 * If you do not see debug_level in /proc/net/ipw2100 then you do not have 75 * If you do not see debug_level in /proc/net/ipw2100 then you do not have
76 * CONFIG_IPW_DEBUG defined in your kernel configuration 76 * CONFIG_IPW2100_DEBUG defined in your kernel configuration
77 * 77 *
78 */ 78 */
79 79
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index 5e7c7e944c9d..cdfe50207757 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -462,7 +462,7 @@ static inline void ipw_disable_interrupts(struct ipw_priv *priv)
462 ipw_write32(priv, IPW_INTA_MASK_R, ~IPW_INTA_MASK_ALL); 462 ipw_write32(priv, IPW_INTA_MASK_R, ~IPW_INTA_MASK_ALL);
463} 463}
464 464
465#ifdef CONFIG_IPW_DEBUG 465#ifdef CONFIG_IPW2200_DEBUG
466static char *ipw_error_desc(u32 val) 466static char *ipw_error_desc(u32 val)
467{ 467{
468 switch (val) { 468 switch (val) {
@@ -1235,7 +1235,7 @@ static ssize_t store_scan_age(struct device *d, struct device_attribute *attr,
1235 const char *buf, size_t count) 1235 const char *buf, size_t count)
1236{ 1236{
1237 struct ipw_priv *priv = dev_get_drvdata(d); 1237 struct ipw_priv *priv = dev_get_drvdata(d);
1238#ifdef CONFIG_IPW_DEBUG 1238#ifdef CONFIG_IPW2200_DEBUG
1239 struct net_device *dev = priv->net_dev; 1239 struct net_device *dev = priv->net_dev;
1240#endif 1240#endif
1241 char buffer[] = "00000000"; 1241 char buffer[] = "00000000";
@@ -1754,7 +1754,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
1754 IPW_ERROR("Firmware error detected. Restarting.\n"); 1754 IPW_ERROR("Firmware error detected. Restarting.\n");
1755 if (priv->error) { 1755 if (priv->error) {
1756 IPW_ERROR("Sysfs 'error' log already exists.\n"); 1756 IPW_ERROR("Sysfs 'error' log already exists.\n");
1757#ifdef CONFIG_IPW_DEBUG 1757#ifdef CONFIG_IPW2200_DEBUG
1758 if (ipw_debug_level & IPW_DL_FW_ERRORS) { 1758 if (ipw_debug_level & IPW_DL_FW_ERRORS) {
1759 struct ipw_fw_error *error = 1759 struct ipw_fw_error *error =
1760 ipw_alloc_error_log(priv); 1760 ipw_alloc_error_log(priv);
@@ -1770,7 +1770,7 @@ static void ipw_irq_tasklet(struct ipw_priv *priv)
1770 else 1770 else
1771 IPW_ERROR("Error allocating sysfs 'error' " 1771 IPW_ERROR("Error allocating sysfs 'error' "
1772 "log.\n"); 1772 "log.\n");
1773#ifdef CONFIG_IPW_DEBUG 1773#ifdef CONFIG_IPW2200_DEBUG
1774 if (ipw_debug_level & IPW_DL_FW_ERRORS) 1774 if (ipw_debug_level & IPW_DL_FW_ERRORS)
1775 ipw_dump_error_log(priv, priv->error); 1775 ipw_dump_error_log(priv, priv->error);
1776#endif 1776#endif
@@ -3778,7 +3778,7 @@ static const struct ipw_status_code ipw_status_codes[] = {
3778 {0x2E, "Cipher suite is rejected per security policy"}, 3778 {0x2E, "Cipher suite is rejected per security policy"},
3779}; 3779};
3780 3780
3781#ifdef CONFIG_IPW_DEBUG 3781#ifdef CONFIG_IPW2200_DEBUG
3782static const char *ipw_get_status_code(u16 status) 3782static const char *ipw_get_status_code(u16 status)
3783{ 3783{
3784 int i; 3784 int i;
@@ -4250,7 +4250,7 @@ static inline void ipw_rx_notification(struct ipw_priv *priv,
4250 if (priv-> 4250 if (priv->
4251 status & (STATUS_ASSOCIATED | 4251 status & (STATUS_ASSOCIATED |
4252 STATUS_AUTH)) { 4252 STATUS_AUTH)) {
4253#ifdef CONFIG_IPW_DEBUG 4253#ifdef CONFIG_IPW2200_DEBUG
4254 struct notif_authenticate *auth 4254 struct notif_authenticate *auth
4255 = &notif->u.auth; 4255 = &notif->u.auth;
4256 IPW_DEBUG(IPW_DL_NOTIF | 4256 IPW_DEBUG(IPW_DL_NOTIF |
@@ -4944,12 +4944,11 @@ static struct ipw_rx_queue *ipw_rx_queue_alloc(struct ipw_priv *priv)
4944 struct ipw_rx_queue *rxq; 4944 struct ipw_rx_queue *rxq;
4945 int i; 4945 int i;
4946 4946
4947 rxq = (struct ipw_rx_queue *)kmalloc(sizeof(*rxq), GFP_KERNEL); 4947 rxq = kzalloc(sizeof(*rxq), GFP_KERNEL);
4948 if (unlikely(!rxq)) { 4948 if (unlikely(!rxq)) {
4949 IPW_ERROR("memory allocation failed\n"); 4949 IPW_ERROR("memory allocation failed\n");
4950 return NULL; 4950 return NULL;
4951 } 4951 }
4952 memset(rxq, 0, sizeof(*rxq));
4953 spin_lock_init(&rxq->lock); 4952 spin_lock_init(&rxq->lock);
4954 INIT_LIST_HEAD(&rxq->rx_free); 4953 INIT_LIST_HEAD(&rxq->rx_free);
4955 INIT_LIST_HEAD(&rxq->rx_used); 4954 INIT_LIST_HEAD(&rxq->rx_used);
@@ -5828,7 +5827,7 @@ static void ipw_bg_adhoc_check(void *data)
5828 up(&priv->sem); 5827 up(&priv->sem);
5829} 5828}
5830 5829
5831#ifdef CONFIG_IPW_DEBUG 5830#ifdef CONFIG_IPW2200_DEBUG
5832static void ipw_debug_config(struct ipw_priv *priv) 5831static void ipw_debug_config(struct ipw_priv *priv)
5833{ 5832{
5834 IPW_DEBUG_INFO("Scan completed, no valid APs matched " 5833 IPW_DEBUG_INFO("Scan completed, no valid APs matched "
@@ -7456,8 +7455,7 @@ static void ipw_handle_data_packet(struct ipw_priv *priv,
7456 /* HW decrypt will not clear the WEP bit, MIC, PN, etc. */ 7455 /* HW decrypt will not clear the WEP bit, MIC, PN, etc. */
7457 hdr = (struct ieee80211_hdr_4addr *)rxb->skb->data; 7456 hdr = (struct ieee80211_hdr_4addr *)rxb->skb->data;
7458 if (priv->ieee->iw_mode != IW_MODE_MONITOR && 7457 if (priv->ieee->iw_mode != IW_MODE_MONITOR &&
7459 ((is_multicast_ether_addr(hdr->addr1) || 7458 (is_multicast_ether_addr(hdr->addr1) ?
7460 is_broadcast_ether_addr(hdr->addr1)) ?
7461 !priv->ieee->host_mc_decrypt : !priv->ieee->host_decrypt)) 7459 !priv->ieee->host_mc_decrypt : !priv->ieee->host_decrypt))
7462 ipw_rebuild_decrypted_skb(priv, rxb->skb); 7460 ipw_rebuild_decrypted_skb(priv, rxb->skb);
7463 7461
@@ -7648,8 +7646,7 @@ static inline int is_network_packet(struct ipw_priv *priv,
7648 return 0; 7646 return 0;
7649 7647
7650 /* {broad,multi}cast packets to our BSSID go through */ 7648 /* {broad,multi}cast packets to our BSSID go through */
7651 if (is_multicast_ether_addr(header->addr1) || 7649 if (is_multicast_ether_addr(header->addr1))
7652 is_broadcast_ether_addr(header->addr1))
7653 return !memcmp(header->addr3, priv->bssid, ETH_ALEN); 7650 return !memcmp(header->addr3, priv->bssid, ETH_ALEN);
7654 7651
7655 /* packets to our adapter go through */ 7652 /* packets to our adapter go through */
@@ -7662,8 +7659,7 @@ static inline int is_network_packet(struct ipw_priv *priv,
7662 return 0; 7659 return 0;
7663 7660
7664 /* {broad,multi}cast packets to our BSS go through */ 7661 /* {broad,multi}cast packets to our BSS go through */
7665 if (is_multicast_ether_addr(header->addr1) || 7662 if (is_multicast_ether_addr(header->addr1))
7666 is_broadcast_ether_addr(header->addr1))
7667 return !memcmp(header->addr2, priv->bssid, ETH_ALEN); 7663 return !memcmp(header->addr2, priv->bssid, ETH_ALEN);
7668 7664
7669 /* packets to our adapter go through */ 7665 /* packets to our adapter go through */
@@ -7815,7 +7811,7 @@ static void ipw_rx(struct ipw_priv *priv)
7815 7811
7816 while (i != r) { 7812 while (i != r) {
7817 rxb = priv->rxq->queue[i]; 7813 rxb = priv->rxq->queue[i];
7818#ifdef CONFIG_IPW_DEBUG 7814#ifdef CONFIG_IPW2200_DEBUG
7819 if (unlikely(rxb == NULL)) { 7815 if (unlikely(rxb == NULL)) {
7820 printk(KERN_CRIT "Queue not allocated!\n"); 7816 printk(KERN_CRIT "Queue not allocated!\n");
7821 break; 7817 break;
@@ -9657,8 +9653,7 @@ static inline int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
9657 switch (priv->ieee->iw_mode) { 9653 switch (priv->ieee->iw_mode) {
9658 case IW_MODE_ADHOC: 9654 case IW_MODE_ADHOC:
9659 hdr_len = IEEE80211_3ADDR_LEN; 9655 hdr_len = IEEE80211_3ADDR_LEN;
9660 unicast = !(is_multicast_ether_addr(hdr->addr1) || 9656 unicast = !is_multicast_ether_addr(hdr->addr1);
9661 is_broadcast_ether_addr(hdr->addr1));
9662 id = ipw_find_station(priv, hdr->addr1); 9657 id = ipw_find_station(priv, hdr->addr1);
9663 if (id == IPW_INVALID_STATION) { 9658 if (id == IPW_INVALID_STATION) {
9664 id = ipw_add_station(priv, hdr->addr1); 9659 id = ipw_add_station(priv, hdr->addr1);
@@ -9673,8 +9668,7 @@ static inline int ipw_tx_skb(struct ipw_priv *priv, struct ieee80211_txb *txb,
9673 9668
9674 case IW_MODE_INFRA: 9669 case IW_MODE_INFRA:
9675 default: 9670 default:
9676 unicast = !(is_multicast_ether_addr(hdr->addr3) || 9671 unicast = !is_multicast_ether_addr(hdr->addr3);
9677 is_broadcast_ether_addr(hdr->addr3));
9678 hdr_len = IEEE80211_3ADDR_LEN; 9672 hdr_len = IEEE80211_3ADDR_LEN;
9679 id = 0; 9673 id = 0;
9680 break; 9674 break;
@@ -10956,7 +10950,7 @@ static int ipw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
10956 10950
10957 priv->net_dev = net_dev; 10951 priv->net_dev = net_dev;
10958 priv->pci_dev = pdev; 10952 priv->pci_dev = pdev;
10959#ifdef CONFIG_IPW_DEBUG 10953#ifdef CONFIG_IPW2200_DEBUG
10960 ipw_debug_level = debug; 10954 ipw_debug_level = debug;
10961#endif 10955#endif
10962 spin_lock_init(&priv->lock); 10956 spin_lock_init(&priv->lock);
diff --git a/drivers/net/wireless/ipw2200.h b/drivers/net/wireless/ipw2200.h
index 1c98db0652c9..e65620a4d79e 100644
--- a/drivers/net/wireless/ipw2200.h
+++ b/drivers/net/wireless/ipw2200.h
@@ -1301,14 +1301,14 @@ struct ipw_priv {
1301 1301
1302/* debug macros */ 1302/* debug macros */
1303 1303
1304#ifdef CONFIG_IPW_DEBUG 1304#ifdef CONFIG_IPW2200_DEBUG
1305#define IPW_DEBUG(level, fmt, args...) \ 1305#define IPW_DEBUG(level, fmt, args...) \
1306do { if (ipw_debug_level & (level)) \ 1306do { if (ipw_debug_level & (level)) \
1307 printk(KERN_DEBUG DRV_NAME": %c %s " fmt, \ 1307 printk(KERN_DEBUG DRV_NAME": %c %s " fmt, \
1308 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) 1308 in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0)
1309#else 1309#else
1310#define IPW_DEBUG(level, fmt, args...) do {} while (0) 1310#define IPW_DEBUG(level, fmt, args...) do {} while (0)
1311#endif /* CONFIG_IPW_DEBUG */ 1311#endif /* CONFIG_IPW2200_DEBUG */
1312 1312
1313/* 1313/*
1314 * To use the debug system; 1314 * To use the debug system;
@@ -1332,7 +1332,7 @@ do { if (ipw_debug_level & (level)) \
1332 * you simply need to add your entry to the ipw_debug_levels array. 1332 * you simply need to add your entry to the ipw_debug_levels array.
1333 * 1333 *
1334 * If you do not see debug_level in /proc/net/ipw then you do not have 1334 * If you do not see debug_level in /proc/net/ipw then you do not have
1335 * CONFIG_IPW_DEBUG defined in your kernel configuration 1335 * CONFIG_IPW2200_DEBUG defined in your kernel configuration
1336 * 1336 *
1337 */ 1337 */
1338 1338
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c
index 92793b958e32..bf6271ee387a 100644
--- a/drivers/net/wireless/netwave_cs.c
+++ b/drivers/net/wireless/netwave_cs.c
@@ -166,8 +166,6 @@ static char *version =
166#define DEBUG(n, args...) 166#define DEBUG(n, args...)
167#endif 167#endif
168 168
169static dev_info_t dev_info = "netwave_cs";
170
171/*====================================================================*/ 169/*====================================================================*/
172 170
173/* Parameters that can be set with 'insmod' */ 171/* Parameters that can be set with 'insmod' */
@@ -195,12 +193,9 @@ module_param(mem_speed, int, 0);
195 193
196/* PCMCIA (Card Services) related functions */ 194/* PCMCIA (Card Services) related functions */
197static void netwave_release(dev_link_t *link); /* Card removal */ 195static void netwave_release(dev_link_t *link); /* Card removal */
198static int netwave_event(event_t event, int priority,
199 event_callback_args_t *args);
200static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card 196static void netwave_pcmcia_config(dev_link_t *arg); /* Runs after card
201 insertion */ 197 insertion */
202static dev_link_t *netwave_attach(void); /* Create instance */ 198static void netwave_detach(struct pcmcia_device *p_dev); /* Destroy instance */
203static void netwave_detach(dev_link_t *); /* Destroy instance */
204 199
205/* Hardware configuration */ 200/* Hardware configuration */
206static void netwave_doreset(kio_addr_t iobase, u_char __iomem *ramBase); 201static void netwave_doreset(kio_addr_t iobase, u_char __iomem *ramBase);
@@ -228,17 +223,6 @@ static struct iw_statistics* netwave_get_wireless_stats(struct net_device *dev);
228static void set_multicast_list(struct net_device *dev); 223static void set_multicast_list(struct net_device *dev);
229 224
230/* 225/*
231 A linked list of "instances" of the skeleton device. Each actual
232 PCMCIA card corresponds to one device instance, and is described
233 by one dev_link_t structure (defined in ds.h).
234
235 You may not want to use a linked list for this -- for example, the
236 memory card driver uses an array of dev_link_t pointers, where minor
237 device numbers are used to derive the corresponding array index.
238*/
239static dev_link_t *dev_list;
240
241/*
242 A dev_link_t structure has fields for most things that are needed 226 A dev_link_t structure has fields for most things that are needed
243 to keep track of a socket, but there will usually be some device 227 to keep track of a socket, but there will usually be some device
244 specific information that also needs to be kept track of. The 228 specific information that also needs to be kept track of. The
@@ -394,20 +378,18 @@ static struct iw_statistics *netwave_get_wireless_stats(struct net_device *dev)
394 * configure the card at this point -- we wait until we receive a 378 * configure the card at this point -- we wait until we receive a
395 * card insertion event. 379 * card insertion event.
396 */ 380 */
397static dev_link_t *netwave_attach(void) 381static int netwave_attach(struct pcmcia_device *p_dev)
398{ 382{
399 client_reg_t client_reg;
400 dev_link_t *link; 383 dev_link_t *link;
401 struct net_device *dev; 384 struct net_device *dev;
402 netwave_private *priv; 385 netwave_private *priv;
403 int ret; 386
404
405 DEBUG(0, "netwave_attach()\n"); 387 DEBUG(0, "netwave_attach()\n");
406 388
407 /* Initialize the dev_link_t structure */ 389 /* Initialize the dev_link_t structure */
408 dev = alloc_etherdev(sizeof(netwave_private)); 390 dev = alloc_etherdev(sizeof(netwave_private));
409 if (!dev) 391 if (!dev)
410 return NULL; 392 return -ENOMEM;
411 priv = netdev_priv(dev); 393 priv = netdev_priv(dev);
412 link = &priv->link; 394 link = &priv->link;
413 link->priv = dev; 395 link->priv = dev;
@@ -449,21 +431,14 @@ static dev_link_t *netwave_attach(void)
449 dev->open = &netwave_open; 431 dev->open = &netwave_open;
450 dev->stop = &netwave_close; 432 dev->stop = &netwave_close;
451 link->irq.Instance = dev; 433 link->irq.Instance = dev;
452
453 /* Register with Card Services */
454 link->next = dev_list;
455 dev_list = link;
456 client_reg.dev_info = &dev_info;
457 client_reg.Version = 0x0210;
458 client_reg.event_callback_args.client_data = link;
459 ret = pcmcia_register_client(&link->handle, &client_reg);
460 if (ret != 0) {
461 cs_error(link->handle, RegisterClient, ret);
462 netwave_detach(link);
463 return NULL;
464 }
465 434
466 return link; 435 link->handle = p_dev;
436 p_dev->instance = link;
437
438 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
439 netwave_pcmcia_config( link);
440
441 return 0;
467} /* netwave_attach */ 442} /* netwave_attach */
468 443
469/* 444/*
@@ -474,42 +449,20 @@ static dev_link_t *netwave_attach(void)
474 * structures are freed. Otherwise, the structures will be freed 449 * structures are freed. Otherwise, the structures will be freed
475 * when the device is released. 450 * when the device is released.
476 */ 451 */
477static void netwave_detach(dev_link_t *link) 452static void netwave_detach(struct pcmcia_device *p_dev)
478{ 453{
479 struct net_device *dev = link->priv; 454 dev_link_t *link = dev_to_instance(p_dev);
480 dev_link_t **linkp; 455 struct net_device *dev = link->priv;
481 456
482 DEBUG(0, "netwave_detach(0x%p)\n", link); 457 DEBUG(0, "netwave_detach(0x%p)\n", link);
483 458
484 /* 459 if (link->state & DEV_CONFIG)
485 If the device is currently configured and active, we won't 460 netwave_release(link);
486 actually delete it yet. Instead, it is marked so that when 461
487 the release() function is called, that will trigger a proper 462 if (link->dev)
488 detach(). 463 unregister_netdev(dev);
489 */ 464
490 if (link->state & DEV_CONFIG) 465 free_netdev(dev);
491 netwave_release(link);
492
493 /* Break the link with Card Services */
494 if (link->handle)
495 pcmcia_deregister_client(link->handle);
496
497 /* Locate device structure */
498 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
499 if (*linkp == link) break;
500 if (*linkp == NULL)
501 {
502 DEBUG(1, "netwave_cs: detach fail, '%s' not in list\n",
503 link->dev->dev_name);
504 return;
505 }
506
507 /* Unlink device structure, free pieces */
508 *linkp = link->next;
509 if (link->dev)
510 unregister_netdev(dev);
511 free_netdev(dev);
512
513} /* netwave_detach */ 466} /* netwave_detach */
514 467
515/* 468/*
@@ -935,69 +888,38 @@ static void netwave_release(dev_link_t *link)
935 link->state &= ~DEV_CONFIG; 888 link->state &= ~DEV_CONFIG;
936} 889}
937 890
938/* 891static int netwave_suspend(struct pcmcia_device *p_dev)
939 * Function netwave_event (event, priority, args)
940 *
941 * The card status event handler. Mostly, this schedules other
942 * stuff to run after an event is received. A CARD_REMOVAL event
943 * also sets some flags to discourage the net drivers from trying
944 * to talk to the card any more.
945 *
946 * When a CARD_REMOVAL event is received, we immediately set a flag
947 * to block future accesses to this device. All the functions that
948 * actually access the device should check this flag to make sure
949 * the card is still present.
950 *
951 */
952static int netwave_event(event_t event, int priority,
953 event_callback_args_t *args)
954{ 892{
955 dev_link_t *link = args->client_data; 893 dev_link_t *link = dev_to_instance(p_dev);
956 struct net_device *dev = link->priv; 894 struct net_device *dev = link->priv;
957 895
958 DEBUG(1, "netwave_event(0x%06x)\n", event);
959
960 switch (event) {
961 case CS_EVENT_REGISTRATION_COMPLETE:
962 DEBUG(0, "netwave_cs: registration complete\n");
963 break;
964
965 case CS_EVENT_CARD_REMOVAL:
966 link->state &= ~DEV_PRESENT;
967 if (link->state & DEV_CONFIG) {
968 netif_device_detach(dev);
969 netwave_release(link);
970 }
971 break;
972 case CS_EVENT_CARD_INSERTION:
973 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
974 netwave_pcmcia_config( link);
975 break;
976 case CS_EVENT_PM_SUSPEND:
977 link->state |= DEV_SUSPEND; 896 link->state |= DEV_SUSPEND;
978 /* Fall through... */
979 case CS_EVENT_RESET_PHYSICAL:
980 if (link->state & DEV_CONFIG) { 897 if (link->state & DEV_CONFIG) {
981 if (link->open) 898 if (link->open)
982 netif_device_detach(dev); 899 netif_device_detach(dev);
983 pcmcia_release_configuration(link->handle); 900 pcmcia_release_configuration(link->handle);
984 } 901 }
985 break; 902
986 case CS_EVENT_PM_RESUME: 903 return 0;
904}
905
906static int netwave_resume(struct pcmcia_device *p_dev)
907{
908 dev_link_t *link = dev_to_instance(p_dev);
909 struct net_device *dev = link->priv;
910
987 link->state &= ~DEV_SUSPEND; 911 link->state &= ~DEV_SUSPEND;
988 /* Fall through... */
989 case CS_EVENT_CARD_RESET:
990 if (link->state & DEV_CONFIG) { 912 if (link->state & DEV_CONFIG) {
991 pcmcia_request_configuration(link->handle, &link->conf); 913 pcmcia_request_configuration(link->handle, &link->conf);
992 if (link->open) { 914 if (link->open) {
993 netwave_reset(dev); 915 netwave_reset(dev);
994 netif_device_attach(dev); 916 netif_device_attach(dev);
995 } 917 }
996 } 918 }
997 break; 919
998 } 920 return 0;
999 return 0; 921}
1000} /* netwave_event */ 922
1001 923
1002/* 924/*
1003 * Function netwave_doreset (ioBase, ramBase) 925 * Function netwave_doreset (ioBase, ramBase)
@@ -1491,10 +1413,11 @@ static struct pcmcia_driver netwave_driver = {
1491 .drv = { 1413 .drv = {
1492 .name = "netwave_cs", 1414 .name = "netwave_cs",
1493 }, 1415 },
1494 .attach = netwave_attach, 1416 .probe = netwave_attach,
1495 .event = netwave_event, 1417 .remove = netwave_detach,
1496 .detach = netwave_detach,
1497 .id_table = netwave_ids, 1418 .id_table = netwave_ids,
1419 .suspend = netwave_suspend,
1420 .resume = netwave_resume,
1498}; 1421};
1499 1422
1500static int __init init_netwave_cs(void) 1423static int __init init_netwave_cs(void)
@@ -1505,7 +1428,6 @@ static int __init init_netwave_cs(void)
1505static void __exit exit_netwave_cs(void) 1428static void __exit exit_netwave_cs(void)
1506{ 1429{
1507 pcmcia_unregister_driver(&netwave_driver); 1430 pcmcia_unregister_driver(&netwave_driver);
1508 BUG_ON(dev_list != NULL);
1509} 1431}
1510 1432
1511module_init(init_netwave_cs); 1433module_init(init_netwave_cs);
diff --git a/drivers/net/wireless/orinoco_cs.c b/drivers/net/wireless/orinoco_cs.c
index dc1128a00971..b664708481cc 100644
--- a/drivers/net/wireless/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco_cs.c
@@ -43,17 +43,6 @@ module_param(ignore_cis_vcc, int, 0);
43MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); 43MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
44 44
45/********************************************************************/ 45/********************************************************************/
46/* Magic constants */
47/********************************************************************/
48
49/*
50 * The dev_info variable is the "key" that is used to match up this
51 * device driver with appropriate cards, through the card
52 * configuration database.
53 */
54static dev_info_t dev_info = DRIVER_NAME;
55
56/********************************************************************/
57/* Data structures */ 46/* Data structures */
58/********************************************************************/ 47/********************************************************************/
59 48
@@ -69,19 +58,14 @@ struct orinoco_pccard {
69 unsigned long hard_reset_in_progress; 58 unsigned long hard_reset_in_progress;
70}; 59};
71 60
72/*
73 * A linked list of "instances" of the device. Each actual PCMCIA
74 * card corresponds to one device instance, and is described by one
75 * dev_link_t structure (defined in ds.h).
76 */
77static dev_link_t *dev_list; /* = NULL */
78 61
79/********************************************************************/ 62/********************************************************************/
80/* Function prototypes */ 63/* Function prototypes */
81/********************************************************************/ 64/********************************************************************/
82 65
66static void orinoco_cs_config(dev_link_t *link);
83static void orinoco_cs_release(dev_link_t *link); 67static void orinoco_cs_release(dev_link_t *link);
84static void orinoco_cs_detach(dev_link_t *link); 68static void orinoco_cs_detach(struct pcmcia_device *p_dev);
85 69
86/********************************************************************/ 70/********************************************************************/
87/* Device methods */ 71/* Device methods */
@@ -119,19 +103,17 @@ orinoco_cs_hard_reset(struct orinoco_private *priv)
119 * The dev_link structure is initialized, but we don't actually 103 * The dev_link structure is initialized, but we don't actually
120 * configure the card at this point -- we wait until we receive a card 104 * configure the card at this point -- we wait until we receive a card
121 * insertion event. */ 105 * insertion event. */
122static dev_link_t * 106static int
123orinoco_cs_attach(void) 107orinoco_cs_attach(struct pcmcia_device *p_dev)
124{ 108{
125 struct net_device *dev; 109 struct net_device *dev;
126 struct orinoco_private *priv; 110 struct orinoco_private *priv;
127 struct orinoco_pccard *card; 111 struct orinoco_pccard *card;
128 dev_link_t *link; 112 dev_link_t *link;
129 client_reg_t client_reg;
130 int ret;
131 113
132 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset); 114 dev = alloc_orinocodev(sizeof(*card), orinoco_cs_hard_reset);
133 if (! dev) 115 if (! dev)
134 return NULL; 116 return -ENOMEM;
135 priv = netdev_priv(dev); 117 priv = netdev_priv(dev);
136 card = priv->card; 118 card = priv->card;
137 119
@@ -154,22 +136,15 @@ orinoco_cs_attach(void)
154 link->conf.IntType = INT_MEMORY_AND_IO; 136 link->conf.IntType = INT_MEMORY_AND_IO;
155 137
156 /* Register with Card Services */ 138 /* Register with Card Services */
157 /* FIXME: need a lock? */ 139 link->next = NULL;
158 link->next = dev_list; 140
159 dev_list = link; 141 link->handle = p_dev;
160 142 p_dev->instance = link;
161 client_reg.dev_info = &dev_info; 143
162 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 144 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
163 client_reg.event_callback_args.client_data = link; 145 orinoco_cs_config(link);
164
165 ret = pcmcia_register_client(&link->handle, &client_reg);
166 if (ret != CS_SUCCESS) {
167 cs_error(link->handle, RegisterClient, ret);
168 orinoco_cs_detach(link);
169 return NULL;
170 }
171 146
172 return link; 147 return 0;
173} /* orinoco_cs_attach */ 148} /* orinoco_cs_attach */
174 149
175/* 150/*
@@ -178,27 +153,14 @@ orinoco_cs_attach(void)
178 * are freed. Otherwise, the structures will be freed when the device 153 * are freed. Otherwise, the structures will be freed when the device
179 * is released. 154 * is released.
180 */ 155 */
181static void orinoco_cs_detach(dev_link_t *link) 156static void orinoco_cs_detach(struct pcmcia_device *p_dev)
182{ 157{
183 dev_link_t **linkp; 158 dev_link_t *link = dev_to_instance(p_dev);
184 struct net_device *dev = link->priv; 159 struct net_device *dev = link->priv;
185 160
186 /* Locate device structure */
187 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
188 if (*linkp == link)
189 break;
190
191 BUG_ON(*linkp == NULL);
192
193 if (link->state & DEV_CONFIG) 161 if (link->state & DEV_CONFIG)
194 orinoco_cs_release(link); 162 orinoco_cs_release(link);
195 163
196 /* Break the link with Card Services */
197 if (link->handle)
198 pcmcia_deregister_client(link->handle);
199
200 /* Unlink device structure, and free it */
201 *linkp = link->next;
202 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 164 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
203 if (link->dev) { 165 if (link->dev) {
204 DEBUG(0, PFX "About to unregister net device %p\n", 166 DEBUG(0, PFX "About to unregister net device %p\n",
@@ -465,106 +427,82 @@ orinoco_cs_release(dev_link_t *link)
465 ioport_unmap(priv->hw.iobase); 427 ioport_unmap(priv->hw.iobase);
466} /* orinoco_cs_release */ 428} /* orinoco_cs_release */
467 429
468/* 430static int orinoco_cs_suspend(struct pcmcia_device *p_dev)
469 * The card status event handler. Mostly, this schedules other stuff
470 * to run after an event is received.
471 */
472static int
473orinoco_cs_event(event_t event, int priority,
474 event_callback_args_t * args)
475{ 431{
476 dev_link_t *link = args->client_data; 432 dev_link_t *link = dev_to_instance(p_dev);
477 struct net_device *dev = link->priv; 433 struct net_device *dev = link->priv;
478 struct orinoco_private *priv = netdev_priv(dev); 434 struct orinoco_private *priv = netdev_priv(dev);
479 struct orinoco_pccard *card = priv->card; 435 struct orinoco_pccard *card = priv->card;
480 int err = 0; 436 int err = 0;
481 unsigned long flags; 437 unsigned long flags;
482 438
483 switch (event) { 439 link->state |= DEV_SUSPEND;
484 case CS_EVENT_CARD_REMOVAL: 440 if (link->state & DEV_CONFIG) {
485 link->state &= ~DEV_PRESENT; 441 /* This is probably racy, but I can't think of
486 if (link->state & DEV_CONFIG) { 442 a better way, short of rewriting the PCMCIA
487 unsigned long flags; 443 layer to not suck :-( */
488 444 if (! test_bit(0, &card->hard_reset_in_progress)) {
489 spin_lock_irqsave(&priv->lock, flags); 445 spin_lock_irqsave(&priv->lock, flags);
446
447 err = __orinoco_down(dev);
448 if (err)
449 printk(KERN_WARNING "%s: Error %d downing interface\n",
450 dev->name, err);
451
490 netif_device_detach(dev); 452 netif_device_detach(dev);
491 priv->hw_unavailable++; 453 priv->hw_unavailable++;
454
492 spin_unlock_irqrestore(&priv->lock, flags); 455 spin_unlock_irqrestore(&priv->lock, flags);
493 } 456 }
494 break;
495 457
496 case CS_EVENT_CARD_INSERTION: 458 pcmcia_release_configuration(link->handle);
497 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 459 }
498 orinoco_cs_config(link);
499 break;
500 460
501 case CS_EVENT_PM_SUSPEND: 461 return 0;
502 link->state |= DEV_SUSPEND; 462}
503 /* Fall through... */ 463
504 case CS_EVENT_RESET_PHYSICAL: 464static int orinoco_cs_resume(struct pcmcia_device *p_dev)
505 /* Mark the device as stopped, to block IO until later */ 465{
506 if (link->state & DEV_CONFIG) { 466 dev_link_t *link = dev_to_instance(p_dev);
507 /* This is probably racy, but I can't think of 467 struct net_device *dev = link->priv;
508 a better way, short of rewriting the PCMCIA 468 struct orinoco_private *priv = netdev_priv(dev);
509 layer to not suck :-( */ 469 struct orinoco_pccard *card = priv->card;
510 if (! test_bit(0, &card->hard_reset_in_progress)) { 470 int err = 0;
511 spin_lock_irqsave(&priv->lock, flags); 471 unsigned long flags;
512 472
513 err = __orinoco_down(dev); 473 link->state &= ~DEV_SUSPEND;
514 if (err) 474 if (link->state & DEV_CONFIG) {
515 printk(KERN_WARNING "%s: %s: Error %d downing interface\n", 475 /* FIXME: should we double check that this is
516 dev->name, 476 * the same card as we had before */
517 event == CS_EVENT_PM_SUSPEND ? "SUSPEND" : "RESET_PHYSICAL", 477 pcmcia_request_configuration(link->handle, &link->conf);
518 err); 478
519 479 if (! test_bit(0, &card->hard_reset_in_progress)) {
520 netif_device_detach(dev); 480 err = orinoco_reinit_firmware(dev);
521 priv->hw_unavailable++; 481 if (err) {
522 482 printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
523 spin_unlock_irqrestore(&priv->lock, flags); 483 dev->name, err);
484 return -EIO;
524 } 485 }
525 486
526 pcmcia_release_configuration(link->handle); 487 spin_lock_irqsave(&priv->lock, flags);
527 } 488
528 break; 489 netif_device_attach(dev);
490 priv->hw_unavailable--;
529 491
530 case CS_EVENT_PM_RESUME: 492 if (priv->open && ! priv->hw_unavailable) {
531 link->state &= ~DEV_SUSPEND; 493 err = __orinoco_up(dev);
532 /* Fall through... */ 494 if (err)
533 case CS_EVENT_CARD_RESET: 495 printk(KERN_ERR "%s: Error %d restarting card\n",
534 if (link->state & DEV_CONFIG) {
535 /* FIXME: should we double check that this is
536 * the same card as we had before */
537 pcmcia_request_configuration(link->handle, &link->conf);
538
539 if (! test_bit(0, &card->hard_reset_in_progress)) {
540 err = orinoco_reinit_firmware(dev);
541 if (err) {
542 printk(KERN_ERR "%s: Error %d re-initializing firmware\n",
543 dev->name, err); 496 dev->name, err);
544 break;
545 }
546
547 spin_lock_irqsave(&priv->lock, flags);
548
549 netif_device_attach(dev);
550 priv->hw_unavailable--;
551
552 if (priv->open && ! priv->hw_unavailable) {
553 err = __orinoco_up(dev);
554 if (err)
555 printk(KERN_ERR "%s: Error %d restarting card\n",
556 dev->name, err);
557
558 }
559
560 spin_unlock_irqrestore(&priv->lock, flags);
561 } 497 }
498
499 spin_unlock_irqrestore(&priv->lock, flags);
562 } 500 }
563 break;
564 } 501 }
565 502
566 return err; 503 return 0;
567} /* orinoco_cs_event */ 504}
505
568 506
569/********************************************************************/ 507/********************************************************************/
570/* Module initialization */ 508/* Module initialization */
@@ -665,10 +603,11 @@ static struct pcmcia_driver orinoco_driver = {
665 .drv = { 603 .drv = {
666 .name = DRIVER_NAME, 604 .name = DRIVER_NAME,
667 }, 605 },
668 .attach = orinoco_cs_attach, 606 .probe = orinoco_cs_attach,
669 .detach = orinoco_cs_detach, 607 .remove = orinoco_cs_detach,
670 .event = orinoco_cs_event,
671 .id_table = orinoco_cs_ids, 608 .id_table = orinoco_cs_ids,
609 .suspend = orinoco_cs_suspend,
610 .resume = orinoco_cs_resume,
672}; 611};
673 612
674static int __init 613static int __init
@@ -683,7 +622,6 @@ static void __exit
683exit_orinoco_cs(void) 622exit_orinoco_cs(void)
684{ 623{
685 pcmcia_unregister_driver(&orinoco_driver); 624 pcmcia_unregister_driver(&orinoco_driver);
686 BUG_ON(dev_list != NULL);
687} 625}
688 626
689module_init(init_orinoco_cs); 627module_init(init_orinoco_cs);
diff --git a/drivers/net/wireless/orinoco_nortel.c b/drivers/net/wireless/orinoco_nortel.c
index d8afd51ff8a5..d1a670b35338 100644
--- a/drivers/net/wireless/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco_nortel.c
@@ -1,6 +1,8 @@
1/* orinoco_nortel.c 1/* orinoco_nortel.c
2 * 2 *
3 * Driver for Prism II devices which would usually be driven by orinoco_cs, 3 * Driver for Prism II devices which would usually be driven by orinoco_cs,
4 * but are connected to the PCI bus by a PCI-to-PCMCIA adapter used in
5 * Nortel emobility, Symbol LA-4113 and Symbol LA-4123.
4 * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter. 6 * but are connected to the PCI bus by a Nortel PCI-PCMCIA-Adapter.
5 * 7 *
6 * Copyright (C) 2002 Tobias Hoffmann 8 * Copyright (C) 2002 Tobias Hoffmann
@@ -165,7 +167,7 @@ static int nortel_pci_init_one(struct pci_dev *pdev,
165 goto fail_resources; 167 goto fail_resources;
166 } 168 }
167 169
168 iomem = pci_iomap(pdev, 3, 0); 170 iomem = pci_iomap(pdev, 2, 0);
169 if (!iomem) { 171 if (!iomem) {
170 err = -ENOMEM; 172 err = -ENOMEM;
171 goto fail_map_io; 173 goto fail_map_io;
@@ -265,6 +267,8 @@ static void __devexit nortel_pci_remove_one(struct pci_dev *pdev)
265static struct pci_device_id nortel_pci_id_table[] = { 267static struct pci_device_id nortel_pci_id_table[] = {
266 /* Nortel emobility PCI */ 268 /* Nortel emobility PCI */
267 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,}, 269 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,},
270 /* Symbol LA-4123 PCI */
271 {0x1562, 0x0001, PCI_ANY_ID, PCI_ANY_ID,},
268 {0,}, 272 {0,},
269}; 273};
270 274
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 70fd6fd8feb9..319180ca7e71 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -92,9 +92,7 @@ module_param(pc_debug, int, 0);
92/** Prototypes based on PCMCIA skeleton driver *******************************/ 92/** Prototypes based on PCMCIA skeleton driver *******************************/
93static void ray_config(dev_link_t *link); 93static void ray_config(dev_link_t *link);
94static void ray_release(dev_link_t *link); 94static void ray_release(dev_link_t *link);
95static int ray_event(event_t event, int priority, event_callback_args_t *args); 95static void ray_detach(struct pcmcia_device *p_dev);
96static dev_link_t *ray_attach(void);
97static void ray_detach(dev_link_t *);
98 96
99/***** Prototypes indicated by device structure ******************************/ 97/***** Prototypes indicated by device structure ******************************/
100static int ray_dev_close(struct net_device *dev); 98static int ray_dev_close(struct net_device *dev);
@@ -192,12 +190,6 @@ static int bc;
192static char *phy_addr = NULL; 190static char *phy_addr = NULL;
193 191
194 192
195/* The dev_info variable is the "key" that is used to match up this
196 device driver with appropriate cards, through the card configuration
197 database.
198*/
199static dev_info_t dev_info = "ray_cs";
200
201/* A linked list of "instances" of the ray device. Each actual 193/* A linked list of "instances" of the ray device. Each actual
202 PCMCIA card corresponds to one device instance, and is described 194 PCMCIA card corresponds to one device instance, and is described
203 by one dev_link_t structure (defined in ds.h). 195 by one dev_link_t structure (defined in ds.h).
@@ -314,12 +306,10 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.
314 configure the card at this point -- we wait until we receive a 306 configure the card at this point -- we wait until we receive a
315 card insertion event. 307 card insertion event.
316=============================================================================*/ 308=============================================================================*/
317static dev_link_t *ray_attach(void) 309static int ray_attach(struct pcmcia_device *p_dev)
318{ 310{
319 client_reg_t client_reg;
320 dev_link_t *link; 311 dev_link_t *link;
321 ray_dev_t *local; 312 ray_dev_t *local;
322 int ret;
323 struct net_device *dev; 313 struct net_device *dev;
324 314
325 DEBUG(1, "ray_attach()\n"); 315 DEBUG(1, "ray_attach()\n");
@@ -328,7 +318,7 @@ static dev_link_t *ray_attach(void)
328 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 318 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
329 319
330 if (!link) 320 if (!link)
331 return NULL; 321 return -ENOMEM;
332 322
333 /* Allocate space for private device-specific data */ 323 /* Allocate space for private device-specific data */
334 dev = alloc_etherdev(sizeof(ray_dev_t)); 324 dev = alloc_etherdev(sizeof(ray_dev_t));
@@ -387,30 +377,19 @@ static dev_link_t *ray_attach(void)
387 dev->stop = &ray_dev_close; 377 dev->stop = &ray_dev_close;
388 netif_stop_queue(dev); 378 netif_stop_queue(dev);
389 379
390 /* Register with Card Services */ 380 init_timer(&local->timer);
391 link->next = dev_list;
392 dev_list = link;
393 client_reg.dev_info = &dev_info;
394 client_reg.Version = 0x0210;
395 client_reg.event_callback_args.client_data = link;
396 381
397 DEBUG(2,"ray_cs ray_attach calling pcmcia_register_client(...)\n"); 382 link->handle = p_dev;
383 p_dev->instance = link;
398 384
399 init_timer(&local->timer); 385 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
386 ray_config(link);
400 387
401 ret = pcmcia_register_client(&link->handle, &client_reg); 388 return 0;
402 if (ret != 0) {
403 printk("ray_cs ray_attach RegisterClient unhappy - detaching\n");
404 cs_error(link->handle, RegisterClient, ret);
405 ray_detach(link);
406 return NULL;
407 }
408 DEBUG(2,"ray_cs ray_attach ending\n");
409 return link;
410 389
411fail_alloc_dev: 390fail_alloc_dev:
412 kfree(link); 391 kfree(link);
413 return NULL; 392 return -ENOMEM;
414} /* ray_attach */ 393} /* ray_attach */
415/*============================================================================= 394/*=============================================================================
416 This deletes a driver "instance". The device is de-registered 395 This deletes a driver "instance". The device is de-registered
@@ -418,9 +397,12 @@ fail_alloc_dev:
418 structures are freed. Otherwise, the structures will be freed 397 structures are freed. Otherwise, the structures will be freed
419 when the device is released. 398 when the device is released.
420=============================================================================*/ 399=============================================================================*/
421static void ray_detach(dev_link_t *link) 400static void ray_detach(struct pcmcia_device *p_dev)
422{ 401{
402 dev_link_t *link = dev_to_instance(p_dev);
423 dev_link_t **linkp; 403 dev_link_t **linkp;
404 struct net_device *dev;
405 ray_dev_t *local;
424 406
425 DEBUG(1, "ray_detach(0x%p)\n", link); 407 DEBUG(1, "ray_detach(0x%p)\n", link);
426 408
@@ -430,22 +412,18 @@ static void ray_detach(dev_link_t *link)
430 if (*linkp == NULL) 412 if (*linkp == NULL)
431 return; 413 return;
432 414
433 /* If the device is currently configured and active, we won't 415 dev = link->priv;
434 actually delete it yet. Instead, it is marked so that when 416
435 the release() function is called, that will trigger a proper 417 if (link->state & DEV_CONFIG) {
436 detach(). 418 ray_release(link);
437 */ 419
438 if (link->state & DEV_CONFIG) 420 local = (ray_dev_t *)dev->priv;
439 ray_release(link); 421 del_timer(&local->timer);
422 }
440 423
441 /* Break the link with Card Services */
442 if (link->handle)
443 pcmcia_deregister_client(link->handle);
444
445 /* Unlink device structure, free pieces */ 424 /* Unlink device structure, free pieces */
446 *linkp = link->next; 425 *linkp = link->next;
447 if (link->priv) { 426 if (link->priv) {
448 struct net_device *dev = link->priv;
449 if (link->dev) unregister_netdev(dev); 427 if (link->dev) unregister_netdev(dev);
450 free_netdev(dev); 428 free_netdev(dev);
451 } 429 }
@@ -891,65 +869,40 @@ static void ray_release(dev_link_t *link)
891 DEBUG(2,"ray_release ending\n"); 869 DEBUG(2,"ray_release ending\n");
892} 870}
893 871
894/*============================================================================= 872static int ray_suspend(struct pcmcia_device *p_dev)
895 The card status event handler. Mostly, this schedules other
896 stuff to run after an event is received. A CARD_REMOVAL event
897 also sets some flags to discourage the net drivers from trying
898 to talk to the card any more.
899
900 When a CARD_REMOVAL event is received, we immediately set a flag
901 to block future accesses to this device. All the functions that
902 actually access the device should check this flag to make sure
903 the card is still present.
904=============================================================================*/
905static int ray_event(event_t event, int priority,
906 event_callback_args_t *args)
907{ 873{
908 dev_link_t *link = args->client_data; 874 dev_link_t *link = dev_to_instance(p_dev);
909 struct net_device *dev = link->priv; 875 struct net_device *dev = link->priv;
910 ray_dev_t *local = (ray_dev_t *)dev->priv; 876
911 DEBUG(1, "ray_event(0x%06x)\n", event); 877 link->state |= DEV_SUSPEND;
912
913 switch (event) {
914 case CS_EVENT_CARD_REMOVAL:
915 link->state &= ~DEV_PRESENT;
916 netif_device_detach(dev);
917 if (link->state & DEV_CONFIG) {
918 ray_release(link);
919 del_timer(&local->timer);
920 }
921 break;
922 case CS_EVENT_CARD_INSERTION:
923 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
924 ray_config(link);
925 break;
926 case CS_EVENT_PM_SUSPEND:
927 link->state |= DEV_SUSPEND;
928 /* Fall through... */
929 case CS_EVENT_RESET_PHYSICAL:
930 if (link->state & DEV_CONFIG) { 878 if (link->state & DEV_CONFIG) {
931 if (link->open) 879 if (link->open)
932 netif_device_detach(dev); 880 netif_device_detach(dev);
933 881
934 pcmcia_release_configuration(link->handle); 882 pcmcia_release_configuration(link->handle);
935 } 883 }
936 break; 884
937 case CS_EVENT_PM_RESUME: 885
938 link->state &= ~DEV_SUSPEND; 886 return 0;
939 /* Fall through... */ 887}
940 case CS_EVENT_CARD_RESET: 888
889static int ray_resume(struct pcmcia_device *p_dev)
890{
891 dev_link_t *link = dev_to_instance(p_dev);
892 struct net_device *dev = link->priv;
893
894 link->state &= ~DEV_SUSPEND;
941 if (link->state & DEV_CONFIG) { 895 if (link->state & DEV_CONFIG) {
942 pcmcia_request_configuration(link->handle, &link->conf); 896 pcmcia_request_configuration(link->handle, &link->conf);
943 if (link->open) { 897 if (link->open) {
944 ray_reset(dev); 898 ray_reset(dev);
945 netif_device_attach(dev); 899 netif_device_attach(dev);
946 } 900 }
947 } 901 }
948 break; 902
949 } 903 return 0;
950 return 0; 904}
951 DEBUG(2,"ray_event ending\n"); 905
952} /* ray_event */
953/*===========================================================================*/ 906/*===========================================================================*/
954int ray_dev_init(struct net_device *dev) 907int ray_dev_init(struct net_device *dev)
955{ 908{
@@ -2945,10 +2898,11 @@ static struct pcmcia_driver ray_driver = {
2945 .drv = { 2898 .drv = {
2946 .name = "ray_cs", 2899 .name = "ray_cs",
2947 }, 2900 },
2948 .attach = ray_attach, 2901 .probe = ray_attach,
2949 .event = ray_event, 2902 .remove = ray_detach,
2950 .detach = ray_detach,
2951 .id_table = ray_ids, 2903 .id_table = ray_ids,
2904 .suspend = ray_suspend,
2905 .resume = ray_resume,
2952}; 2906};
2953 2907
2954static int __init init_ray_cs(void) 2908static int __init init_ray_cs(void)
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index b1bbc8e8e91f..fee4be1ce810 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -57,17 +57,6 @@ module_param(ignore_cis_vcc, int, 0);
57MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket"); 57MODULE_PARM_DESC(ignore_cis_vcc, "Allow voltage mismatch between card and socket");
58 58
59/********************************************************************/ 59/********************************************************************/
60/* Magic constants */
61/********************************************************************/
62
63/*
64 * The dev_info variable is the "key" that is used to match up this
65 * device driver with appropriate cards, through the card
66 * configuration database.
67 */
68static dev_info_t dev_info = DRIVER_NAME;
69
70/********************************************************************/
71/* Data structures */ 60/* Data structures */
72/********************************************************************/ 61/********************************************************************/
73 62
@@ -78,19 +67,12 @@ struct orinoco_pccard {
78 dev_node_t node; 67 dev_node_t node;
79}; 68};
80 69
81/*
82 * A linked list of "instances" of the device. Each actual PCMCIA
83 * card corresponds to one device instance, and is described by one
84 * dev_link_t structure (defined in ds.h).
85 */
86static dev_link_t *dev_list; /* = NULL */
87
88/********************************************************************/ 70/********************************************************************/
89/* Function prototypes */ 71/* Function prototypes */
90/********************************************************************/ 72/********************************************************************/
91 73
74static void spectrum_cs_config(dev_link_t *link);
92static void spectrum_cs_release(dev_link_t *link); 75static void spectrum_cs_release(dev_link_t *link);
93static void spectrum_cs_detach(dev_link_t *link);
94 76
95/********************************************************************/ 77/********************************************************************/
96/* Firmware downloader */ 78/* Firmware downloader */
@@ -601,19 +583,17 @@ spectrum_cs_hard_reset(struct orinoco_private *priv)
601 * The dev_link structure is initialized, but we don't actually 583 * The dev_link structure is initialized, but we don't actually
602 * configure the card at this point -- we wait until we receive a card 584 * configure the card at this point -- we wait until we receive a card
603 * insertion event. */ 585 * insertion event. */
604static dev_link_t * 586static int
605spectrum_cs_attach(void) 587spectrum_cs_attach(struct pcmcia_device *p_dev)
606{ 588{
607 struct net_device *dev; 589 struct net_device *dev;
608 struct orinoco_private *priv; 590 struct orinoco_private *priv;
609 struct orinoco_pccard *card; 591 struct orinoco_pccard *card;
610 dev_link_t *link; 592 dev_link_t *link;
611 client_reg_t client_reg;
612 int ret;
613 593
614 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset); 594 dev = alloc_orinocodev(sizeof(*card), spectrum_cs_hard_reset);
615 if (! dev) 595 if (! dev)
616 return NULL; 596 return -ENOMEM;
617 priv = netdev_priv(dev); 597 priv = netdev_priv(dev);
618 card = priv->card; 598 card = priv->card;
619 599
@@ -635,23 +615,13 @@ spectrum_cs_attach(void)
635 link->conf.Attributes = 0; 615 link->conf.Attributes = 0;
636 link->conf.IntType = INT_MEMORY_AND_IO; 616 link->conf.IntType = INT_MEMORY_AND_IO;
637 617
638 /* Register with Card Services */ 618 link->handle = p_dev;
639 /* FIXME: need a lock? */ 619 p_dev->instance = link;
640 link->next = dev_list;
641 dev_list = link;
642 620
643 client_reg.dev_info = &dev_info; 621 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
644 client_reg.Version = 0x0210; /* FIXME: what does this mean? */ 622 spectrum_cs_config(link);
645 client_reg.event_callback_args.client_data = link;
646 623
647 ret = pcmcia_register_client(&link->handle, &client_reg); 624 return 0;
648 if (ret != CS_SUCCESS) {
649 cs_error(link->handle, RegisterClient, ret);
650 spectrum_cs_detach(link);
651 return NULL;
652 }
653
654 return link;
655} /* spectrum_cs_attach */ 625} /* spectrum_cs_attach */
656 626
657/* 627/*
@@ -660,27 +630,14 @@ spectrum_cs_attach(void)
660 * are freed. Otherwise, the structures will be freed when the device 630 * are freed. Otherwise, the structures will be freed when the device
661 * is released. 631 * is released.
662 */ 632 */
663static void spectrum_cs_detach(dev_link_t *link) 633static void spectrum_cs_detach(struct pcmcia_device *p_dev)
664{ 634{
665 dev_link_t **linkp; 635 dev_link_t *link = dev_to_instance(p_dev);
666 struct net_device *dev = link->priv; 636 struct net_device *dev = link->priv;
667 637
668 /* Locate device structure */
669 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
670 if (*linkp == link)
671 break;
672
673 BUG_ON(*linkp == NULL);
674
675 if (link->state & DEV_CONFIG) 638 if (link->state & DEV_CONFIG)
676 spectrum_cs_release(link); 639 spectrum_cs_release(link);
677 640
678 /* Break the link with Card Services */
679 if (link->handle)
680 pcmcia_deregister_client(link->handle);
681
682 /* Unlink device structure, and free it */
683 *linkp = link->next;
684 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev); 641 DEBUG(0, PFX "detach: link=%p link->dev=%p\n", link, link->dev);
685 if (link->dev) { 642 if (link->dev) {
686 DEBUG(0, PFX "About to unregister net device %p\n", 643 DEBUG(0, PFX "About to unregister net device %p\n",
@@ -948,82 +905,56 @@ spectrum_cs_release(dev_link_t *link)
948 ioport_unmap(priv->hw.iobase); 905 ioport_unmap(priv->hw.iobase);
949} /* spectrum_cs_release */ 906} /* spectrum_cs_release */
950 907
951/* 908
952 * The card status event handler. Mostly, this schedules other stuff
953 * to run after an event is received.
954 */
955static int 909static int
956spectrum_cs_event(event_t event, int priority, 910spectrum_cs_suspend(struct pcmcia_device *p_dev)
957 event_callback_args_t * args)
958{ 911{
959 dev_link_t *link = args->client_data; 912 dev_link_t *link = dev_to_instance(p_dev);
960 struct net_device *dev = link->priv; 913 struct net_device *dev = link->priv;
961 struct orinoco_private *priv = netdev_priv(dev); 914 struct orinoco_private *priv = netdev_priv(dev);
962 int err = 0;
963 unsigned long flags; 915 unsigned long flags;
916 int err = 0;
964 917
965 switch (event) { 918 link->state |= DEV_SUSPEND;
966 case CS_EVENT_CARD_REMOVAL: 919 /* Mark the device as stopped, to block IO until later */
967 link->state &= ~DEV_PRESENT; 920 if (link->state & DEV_CONFIG) {
968 if (link->state & DEV_CONFIG) { 921 spin_lock_irqsave(&priv->lock, flags);
969 unsigned long flags;
970 922
971 spin_lock_irqsave(&priv->lock, flags); 923 err = __orinoco_down(dev);
972 netif_device_detach(dev); 924 if (err)
973 priv->hw_unavailable++; 925 printk(KERN_WARNING "%s: Error %d downing interface\n",
974 spin_unlock_irqrestore(&priv->lock, flags); 926 dev->name, err);
975 }
976 break;
977 927
978 case CS_EVENT_CARD_INSERTION: 928 netif_device_detach(dev);
979 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 929 priv->hw_unavailable++;
980 spectrum_cs_config(link);
981 break;
982 930
983 case CS_EVENT_PM_SUSPEND: 931 spin_unlock_irqrestore(&priv->lock, flags);
984 link->state |= DEV_SUSPEND;
985 /* Fall through... */
986 case CS_EVENT_RESET_PHYSICAL:
987 /* Mark the device as stopped, to block IO until later */
988 if (link->state & DEV_CONFIG) {
989 /* This is probably racy, but I can't think of
990 a better way, short of rewriting the PCMCIA
991 layer to not suck :-( */
992 spin_lock_irqsave(&priv->lock, flags);
993
994 err = __orinoco_down(dev);
995 if (err)
996 printk(KERN_WARNING "%s: %s: Error %d downing interface\n",
997 dev->name,
998 event == CS_EVENT_PM_SUSPEND ? "SUSPEND" : "RESET_PHYSICAL",
999 err);
1000
1001 netif_device_detach(dev);
1002 priv->hw_unavailable++;
1003
1004 spin_unlock_irqrestore(&priv->lock, flags);
1005
1006 pcmcia_release_configuration(link->handle);
1007 }
1008 break;
1009 932
1010 case CS_EVENT_PM_RESUME: 933 pcmcia_release_configuration(link->handle);
1011 link->state &= ~DEV_SUSPEND; 934 }
1012 /* Fall through... */ 935
1013 case CS_EVENT_CARD_RESET: 936 return 0;
1014 if (link->state & DEV_CONFIG) { 937}
1015 /* FIXME: should we double check that this is 938
1016 * the same card as we had before */ 939static int
1017 pcmcia_request_configuration(link->handle, &link->conf); 940spectrum_cs_resume(struct pcmcia_device *p_dev)
1018 netif_device_attach(dev); 941{
1019 priv->hw_unavailable--; 942 dev_link_t *link = dev_to_instance(p_dev);
1020 schedule_work(&priv->reset_work); 943 struct net_device *dev = link->priv;
1021 } 944 struct orinoco_private *priv = netdev_priv(dev);
1022 break; 945
946 link->state &= ~DEV_SUSPEND;
947 if (link->state & DEV_CONFIG) {
948 /* FIXME: should we double check that this is
949 * the same card as we had before */
950 pcmcia_request_configuration(link->handle, &link->conf);
951 netif_device_attach(dev);
952 priv->hw_unavailable--;
953 schedule_work(&priv->reset_work);
1023 } 954 }
955 return 0;
956}
1024 957
1025 return err;
1026} /* spectrum_cs_event */
1027 958
1028/********************************************************************/ 959/********************************************************************/
1029/* Module initialization */ 960/* Module initialization */
@@ -1048,9 +979,10 @@ static struct pcmcia_driver orinoco_driver = {
1048 .drv = { 979 .drv = {
1049 .name = DRIVER_NAME, 980 .name = DRIVER_NAME,
1050 }, 981 },
1051 .attach = spectrum_cs_attach, 982 .probe = spectrum_cs_attach,
1052 .detach = spectrum_cs_detach, 983 .remove = spectrum_cs_detach,
1053 .event = spectrum_cs_event, 984 .suspend = spectrum_cs_suspend,
985 .resume = spectrum_cs_resume,
1054 .id_table = spectrum_cs_ids, 986 .id_table = spectrum_cs_ids,
1055}; 987};
1056 988
@@ -1066,7 +998,6 @@ static void __exit
1066exit_spectrum_cs(void) 998exit_spectrum_cs(void)
1067{ 999{
1068 pcmcia_unregister_driver(&orinoco_driver); 1000 pcmcia_unregister_driver(&orinoco_driver);
1069 BUG_ON(dev_list != NULL);
1070} 1001}
1071 1002
1072module_init(init_spectrum_cs); 1003module_init(init_spectrum_cs);
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index c822cad3333f..7e2039f52c49 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -4594,14 +4594,12 @@ wavelan_close(struct net_device * dev)
4594 * configure the card at this point -- we wait until we receive a 4594 * configure the card at this point -- we wait until we receive a
4595 * card insertion event. 4595 * card insertion event.
4596 */ 4596 */
4597static dev_link_t * 4597static int
4598wavelan_attach(void) 4598wavelan_attach(struct pcmcia_device *p_dev)
4599{ 4599{
4600 client_reg_t client_reg; /* Register with cardmgr */
4601 dev_link_t * link; /* Info for cardmgr */ 4600 dev_link_t * link; /* Info for cardmgr */
4602 struct net_device * dev; /* Interface generic data */ 4601 struct net_device * dev; /* Interface generic data */
4603 net_local * lp; /* Interface specific data */ 4602 net_local * lp; /* Interface specific data */
4604 int ret;
4605 4603
4606#ifdef DEBUG_CALLBACK_TRACE 4604#ifdef DEBUG_CALLBACK_TRACE
4607 printk(KERN_DEBUG "-> wavelan_attach()\n"); 4605 printk(KERN_DEBUG "-> wavelan_attach()\n");
@@ -4609,7 +4607,7 @@ wavelan_attach(void)
4609 4607
4610 /* Initialize the dev_link_t structure */ 4608 /* Initialize the dev_link_t structure */
4611 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL); 4609 link = kzalloc(sizeof(struct dev_link_t), GFP_KERNEL);
4612 if (!link) return NULL; 4610 if (!link) return -ENOMEM;
4613 4611
4614 /* The io structure describes IO port mapping */ 4612 /* The io structure describes IO port mapping */
4615 link->io.NumPorts1 = 8; 4613 link->io.NumPorts1 = 8;
@@ -4627,14 +4625,13 @@ wavelan_attach(void)
4627 link->conf.IntType = INT_MEMORY_AND_IO; 4625 link->conf.IntType = INT_MEMORY_AND_IO;
4628 4626
4629 /* Chain drivers */ 4627 /* Chain drivers */
4630 link->next = dev_list; 4628 link->next = NULL;
4631 dev_list = link;
4632 4629
4633 /* Allocate the generic data structure */ 4630 /* Allocate the generic data structure */
4634 dev = alloc_etherdev(sizeof(net_local)); 4631 dev = alloc_etherdev(sizeof(net_local));
4635 if (!dev) { 4632 if (!dev) {
4636 kfree(link); 4633 kfree(link);
4637 return NULL; 4634 return -ENOMEM;
4638 } 4635 }
4639 link->priv = link->irq.Instance = dev; 4636 link->priv = link->irq.Instance = dev;
4640 4637
@@ -4679,28 +4676,21 @@ wavelan_attach(void)
4679 /* Other specific data */ 4676 /* Other specific data */
4680 dev->mtu = WAVELAN_MTU; 4677 dev->mtu = WAVELAN_MTU;
4681 4678
4682 /* Register with Card Services */ 4679 link->handle = p_dev;
4683 client_reg.dev_info = &dev_info; 4680 p_dev->instance = link;
4684 client_reg.Version = 0x0210;
4685 client_reg.event_callback_args.client_data = link;
4686 4681
4687#ifdef DEBUG_CONFIG_INFO 4682 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4688 printk(KERN_DEBUG "wavelan_attach(): almost done, calling pcmcia_register_client\n"); 4683 if(wv_pcmcia_config(link) &&
4689#endif 4684 wv_hw_config(dev))
4690 4685 wv_init_info(dev);
4691 ret = pcmcia_register_client(&link->handle, &client_reg); 4686 else
4692 if(ret != 0) 4687 dev->irq = 0;
4693 {
4694 cs_error(link->handle, RegisterClient, ret);
4695 wavelan_detach(link);
4696 return NULL;
4697 }
4698 4688
4699#ifdef DEBUG_CALLBACK_TRACE 4689#ifdef DEBUG_CALLBACK_TRACE
4700 printk(KERN_DEBUG "<- wavelan_attach()\n"); 4690 printk(KERN_DEBUG "<- wavelan_attach()\n");
4701#endif 4691#endif
4702 4692
4703 return link; 4693 return 0;
4704} 4694}
4705 4695
4706/*------------------------------------------------------------------*/ 4696/*------------------------------------------------------------------*/
@@ -4711,8 +4701,10 @@ wavelan_attach(void)
4711 * is released. 4701 * is released.
4712 */ 4702 */
4713static void 4703static void
4714wavelan_detach(dev_link_t * link) 4704wavelan_detach(struct pcmcia_device *p_dev)
4715{ 4705{
4706 dev_link_t *link = dev_to_instance(p_dev);
4707
4716#ifdef DEBUG_CALLBACK_TRACE 4708#ifdef DEBUG_CALLBACK_TRACE
4717 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link); 4709 printk(KERN_DEBUG "-> wavelan_detach(0x%p)\n", link);
4718#endif 4710#endif
@@ -4729,31 +4721,6 @@ wavelan_detach(dev_link_t * link)
4729 wv_pcmcia_release(link); 4721 wv_pcmcia_release(link);
4730 } 4722 }
4731 4723
4732 /* Break the link with Card Services */
4733 if(link->handle)
4734 pcmcia_deregister_client(link->handle);
4735
4736 /* Remove the interface data from the linked list */
4737 if(dev_list == link)
4738 dev_list = link->next;
4739 else
4740 {
4741 dev_link_t * prev = dev_list;
4742
4743 while((prev != (dev_link_t *) NULL) && (prev->next != link))
4744 prev = prev->next;
4745
4746 if(prev == (dev_link_t *) NULL)
4747 {
4748#ifdef DEBUG_CONFIG_ERRORS
4749 printk(KERN_WARNING "wavelan_detach : Attempting to remove a nonexistent device.\n");
4750#endif
4751 return;
4752 }
4753
4754 prev->next = link->next;
4755 }
4756
4757 /* Free pieces */ 4724 /* Free pieces */
4758 if(link->priv) 4725 if(link->priv)
4759 { 4726 {
@@ -4775,65 +4742,11 @@ wavelan_detach(dev_link_t * link)
4775#endif 4742#endif
4776} 4743}
4777 4744
4778/*------------------------------------------------------------------*/ 4745static int wavelan_suspend(struct pcmcia_device *p_dev)
4779/*
4780 * The card status event handler. Mostly, this schedules other stuff
4781 * to run after an event is received. A CARD_REMOVAL event also sets
4782 * some flags to discourage the net drivers from trying to talk to the
4783 * card any more.
4784 */
4785static int
4786wavelan_event(event_t event, /* The event received */
4787 int priority,
4788 event_callback_args_t * args)
4789{ 4746{
4790 dev_link_t * link = (dev_link_t *) args->client_data; 4747 dev_link_t *link = dev_to_instance(p_dev);
4791 struct net_device * dev = (struct net_device *) link->priv; 4748 struct net_device * dev = (struct net_device *) link->priv;
4792
4793#ifdef DEBUG_CALLBACK_TRACE
4794 printk(KERN_DEBUG "->wavelan_event(): %s\n",
4795 ((event == CS_EVENT_REGISTRATION_COMPLETE)?"registration complete" :
4796 ((event == CS_EVENT_CARD_REMOVAL) ? "card removal" :
4797 ((event == CS_EVENT_CARD_INSERTION) ? "card insertion" :
4798 ((event == CS_EVENT_PM_SUSPEND) ? "pm suspend" :
4799 ((event == CS_EVENT_RESET_PHYSICAL) ? "physical reset" :
4800 ((event == CS_EVENT_PM_RESUME) ? "pm resume" :
4801 ((event == CS_EVENT_CARD_RESET) ? "card reset" :
4802 "unknown"))))))));
4803#endif
4804
4805 switch(event)
4806 {
4807 case CS_EVENT_REGISTRATION_COMPLETE:
4808#ifdef DEBUG_CONFIG_INFO
4809 printk(KERN_DEBUG "wavelan_cs: registration complete\n");
4810#endif
4811 break;
4812 4749
4813 case CS_EVENT_CARD_REMOVAL:
4814 /* Oups ! The card is no more there */
4815 link->state &= ~DEV_PRESENT;
4816 if(link->state & DEV_CONFIG)
4817 {
4818 /* Accept no more transmissions */
4819 netif_device_detach(dev);
4820
4821 /* Release the card */
4822 wv_pcmcia_release(link);
4823 }
4824 break;
4825
4826 case CS_EVENT_CARD_INSERTION:
4827 /* Reset and configure the card */
4828 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
4829 if(wv_pcmcia_config(link) &&
4830 wv_hw_config(dev))
4831 wv_init_info(dev);
4832 else
4833 dev->irq = 0;
4834 break;
4835
4836 case CS_EVENT_PM_SUSPEND:
4837 /* NB: wavelan_close will be called, but too late, so we are 4750 /* NB: wavelan_close will be called, but too late, so we are
4838 * obliged to close nicely the wavelan here. David, could you 4751 * obliged to close nicely the wavelan here. David, could you
4839 * close the device before suspending them ? And, by the way, 4752 * close the device before suspending them ? And, by the way,
@@ -4848,38 +4761,37 @@ wavelan_event(event_t event, /* The event received */
4848 4761
4849 /* The card is now suspended */ 4762 /* The card is now suspended */
4850 link->state |= DEV_SUSPEND; 4763 link->state |= DEV_SUSPEND;
4851 /* Fall through... */ 4764
4852 case CS_EVENT_RESET_PHYSICAL:
4853 if(link->state & DEV_CONFIG) 4765 if(link->state & DEV_CONFIG)
4854 { 4766 {
4855 if(link->open) 4767 if(link->open)
4856 netif_device_detach(dev); 4768 netif_device_detach(dev);
4857 pcmcia_release_configuration(link->handle); 4769 pcmcia_release_configuration(link->handle);
4858 } 4770 }
4859 break; 4771
4772 return 0;
4773}
4774
4775static int wavelan_resume(struct pcmcia_device *p_dev)
4776{
4777 dev_link_t *link = dev_to_instance(p_dev);
4778 struct net_device * dev = (struct net_device *) link->priv;
4860 4779
4861 case CS_EVENT_PM_RESUME:
4862 link->state &= ~DEV_SUSPEND; 4780 link->state &= ~DEV_SUSPEND;
4863 /* Fall through... */
4864 case CS_EVENT_CARD_RESET:
4865 if(link->state & DEV_CONFIG) 4781 if(link->state & DEV_CONFIG)
4866 { 4782 {
4867 pcmcia_request_configuration(link->handle, &link->conf); 4783 pcmcia_request_configuration(link->handle, &link->conf);
4868 if(link->open) /* If RESET -> True, If RESUME -> False ? */ 4784 if(link->open) /* If RESET -> True, If RESUME -> False ? */
4869 { 4785 {
4870 wv_hw_reset(dev); 4786 wv_hw_reset(dev);
4871 netif_device_attach(dev); 4787 netif_device_attach(dev);
4872 } 4788 }
4873 } 4789 }
4874 break;
4875 }
4876 4790
4877#ifdef DEBUG_CALLBACK_TRACE 4791 return 0;
4878 printk(KERN_DEBUG "<-wavelan_event()\n");
4879#endif
4880 return 0;
4881} 4792}
4882 4793
4794
4883static struct pcmcia_device_id wavelan_ids[] = { 4795static struct pcmcia_device_id wavelan_ids[] = {
4884 PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975), 4796 PCMCIA_DEVICE_PROD_ID12("AT&T","WaveLAN/PCMCIA", 0xe7c5affd, 0x1bc50975),
4885 PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06), 4797 PCMCIA_DEVICE_PROD_ID12("Digital", "RoamAbout/DS", 0x9999ab35, 0x00d05e06),
@@ -4894,10 +4806,11 @@ static struct pcmcia_driver wavelan_driver = {
4894 .drv = { 4806 .drv = {
4895 .name = "wavelan_cs", 4807 .name = "wavelan_cs",
4896 }, 4808 },
4897 .attach = wavelan_attach, 4809 .probe = wavelan_attach,
4898 .event = wavelan_event, 4810 .remove = wavelan_detach,
4899 .detach = wavelan_detach,
4900 .id_table = wavelan_ids, 4811 .id_table = wavelan_ids,
4812 .suspend = wavelan_suspend,
4813 .resume = wavelan_resume,
4901}; 4814};
4902 4815
4903static int __init 4816static int __init
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index 724a715089c9..f2d597568151 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -754,20 +754,11 @@ static void
754static int 754static int
755 wavelan_open(struct net_device *), /* Open the device */ 755 wavelan_open(struct net_device *), /* Open the device */
756 wavelan_close(struct net_device *); /* Close the device */ 756 wavelan_close(struct net_device *); /* Close the device */
757static dev_link_t *
758 wavelan_attach(void); /* Create a new device */
759static void 757static void
760 wavelan_detach(dev_link_t *); /* Destroy a removed device */ 758 wavelan_detach(struct pcmcia_device *p_dev); /* Destroy a removed device */
761static int
762 wavelan_event(event_t, /* Manage pcmcia events */
763 int,
764 event_callback_args_t *);
765 759
766/**************************** VARIABLES ****************************/ 760/**************************** VARIABLES ****************************/
767 761
768static dev_info_t dev_info = "wavelan_cs";
769static dev_link_t *dev_list = NULL; /* Linked list of devices */
770
771/* 762/*
772 * Parameters that can be set with 'insmod' 763 * Parameters that can be set with 'insmod'
773 * The exact syntax is 'insmod wavelan_cs.o <var>=<value>' 764 * The exact syntax is 'insmod wavelan_cs.o <var>=<value>'
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 978fdc606781..48e10b0c7e74 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -105,7 +105,6 @@ module_param(pc_debug, int, 0);
105 */ 105 */
106static void wl3501_config(dev_link_t *link); 106static void wl3501_config(dev_link_t *link);
107static void wl3501_release(dev_link_t *link); 107static void wl3501_release(dev_link_t *link);
108static int wl3501_event(event_t event, int pri, event_callback_args_t *args);
109 108
110/* 109/*
111 * The dev_info variable is the "key" that is used to match up this 110 * The dev_info variable is the "key" that is used to match up this
@@ -1498,9 +1497,11 @@ static struct ethtool_ops ops = {
1498 * Services. If it has been released, all local data structures are freed. 1497 * Services. If it has been released, all local data structures are freed.
1499 * Otherwise, the structures will be freed when the device is released. 1498 * Otherwise, the structures will be freed when the device is released.
1500 */ 1499 */
1501static void wl3501_detach(dev_link_t *link) 1500static void wl3501_detach(struct pcmcia_device *p_dev)
1502{ 1501{
1502 dev_link_t *link = dev_to_instance(p_dev);
1503 dev_link_t **linkp; 1503 dev_link_t **linkp;
1504 struct net_device *dev = link->priv;
1504 1505
1505 /* Locate device structure */ 1506 /* Locate device structure */
1506 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next) 1507 for (linkp = &wl3501_dev_list; *linkp; linkp = &(*linkp)->next)
@@ -1514,16 +1515,12 @@ static void wl3501_detach(dev_link_t *link)
1514 * function is called, that will trigger a proper detach(). */ 1515 * function is called, that will trigger a proper detach(). */
1515 1516
1516 if (link->state & DEV_CONFIG) { 1517 if (link->state & DEV_CONFIG) {
1517#ifdef PCMCIA_DEBUG 1518 while (link->open > 0)
1518 printk(KERN_DEBUG "wl3501_cs: detach postponed, '%s' " 1519 wl3501_close(dev);
1519 "still locked\n", link->dev->dev_name);
1520#endif
1521 goto out;
1522 }
1523 1520
1524 /* Break the link with Card Services */ 1521 netif_device_detach(dev);
1525 if (link->handle) 1522 wl3501_release(link);
1526 pcmcia_deregister_client(link->handle); 1523 }
1527 1524
1528 /* Unlink device structure, free pieces */ 1525 /* Unlink device structure, free pieces */
1529 *linkp = link->next; 1526 *linkp = link->next;
@@ -1956,18 +1953,16 @@ static const struct iw_handler_def wl3501_handler_def = {
1956 * The dev_link structure is initialized, but we don't actually configure the 1953 * The dev_link structure is initialized, but we don't actually configure the
1957 * card at this point -- we wait until we receive a card insertion event. 1954 * card at this point -- we wait until we receive a card insertion event.
1958 */ 1955 */
1959static dev_link_t *wl3501_attach(void) 1956static int wl3501_attach(struct pcmcia_device *p_dev)
1960{ 1957{
1961 client_reg_t client_reg;
1962 dev_link_t *link; 1958 dev_link_t *link;
1963 struct net_device *dev; 1959 struct net_device *dev;
1964 struct wl3501_card *this; 1960 struct wl3501_card *this;
1965 int ret;
1966 1961
1967 /* Initialize the dev_link_t structure */ 1962 /* Initialize the dev_link_t structure */
1968 link = kzalloc(sizeof(*link), GFP_KERNEL); 1963 link = kzalloc(sizeof(*link), GFP_KERNEL);
1969 if (!link) 1964 if (!link)
1970 goto out; 1965 return -ENOMEM;
1971 1966
1972 /* The io structure describes IO port mapping */ 1967 /* The io structure describes IO port mapping */
1973 link->io.NumPorts1 = 16; 1968 link->io.NumPorts1 = 16;
@@ -2003,24 +1998,17 @@ static dev_link_t *wl3501_attach(void)
2003 netif_stop_queue(dev); 1998 netif_stop_queue(dev);
2004 link->priv = link->irq.Instance = dev; 1999 link->priv = link->irq.Instance = dev;
2005 2000
2006 /* Register with Card Services */ 2001 link->handle = p_dev;
2007 link->next = wl3501_dev_list; 2002 p_dev->instance = link;
2008 wl3501_dev_list = link; 2003
2009 client_reg.dev_info = &wl3501_dev_info; 2004 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2010 client_reg.Version = 0x0210; 2005 wl3501_config(link);
2011 client_reg.event_callback_args.client_data = link; 2006
2012 ret = pcmcia_register_client(&link->handle, &client_reg); 2007 return 0;
2013 if (ret) {
2014 cs_error(link->handle, RegisterClient, ret);
2015 wl3501_detach(link);
2016 link = NULL;
2017 }
2018out:
2019 return link;
2020out_link: 2008out_link:
2021 kfree(link); 2009 kfree(link);
2022 link = NULL; 2010 link = NULL;
2023 goto out; 2011 return -ENOMEM;
2024} 2012}
2025 2013
2026#define CS_CHECK(fn, ret) \ 2014#define CS_CHECK(fn, ret) \
@@ -2173,67 +2161,41 @@ static void wl3501_release(dev_link_t *link)
2173 link->state &= ~DEV_CONFIG; 2161 link->state &= ~DEV_CONFIG;
2174} 2162}
2175 2163
2176/** 2164static int wl3501_suspend(struct pcmcia_device *p_dev)
2177 * wl3501_event - The card status event handler
2178 * @event - event
2179 * @pri - priority
2180 * @args - arguments for this event
2181 *
2182 * The card status event handler. Mostly, this schedules other stuff to run
2183 * after an event is received. A CARD_REMOVAL event also sets some flags to
2184 * discourage the net drivers from trying to talk to the card any more.
2185 *
2186 * When a CARD_REMOVAL event is received, we immediately set a flag to block
2187 * future accesses to this device. All the functions that actually access the
2188 * device should check this flag to make sure the card is still present.
2189 */
2190static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
2191{ 2165{
2192 dev_link_t *link = args->client_data; 2166 dev_link_t *link = dev_to_instance(p_dev);
2193 struct net_device *dev = link->priv; 2167 struct net_device *dev = link->priv;
2194 2168
2195 switch (event) { 2169 link->state |= DEV_SUSPEND;
2196 case CS_EVENT_CARD_REMOVAL: 2170
2197 link->state &= ~DEV_PRESENT; 2171 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND);
2198 if (link->state & DEV_CONFIG) { 2172 if (link->state & DEV_CONFIG) {
2199 while (link->open > 0) 2173 if (link->open)
2200 wl3501_close(dev);
2201 netif_device_detach(dev); 2174 netif_device_detach(dev);
2202 wl3501_release(link); 2175 pcmcia_release_configuration(link->handle);
2203 } 2176 }
2204 break; 2177
2205 case CS_EVENT_CARD_INSERTION: 2178 return 0;
2206 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 2179}
2207 wl3501_config(link); 2180
2208 break; 2181static int wl3501_resume(struct pcmcia_device *p_dev)
2209 case CS_EVENT_PM_SUSPEND: 2182{
2210 link->state |= DEV_SUSPEND; 2183 dev_link_t *link = dev_to_instance(p_dev);
2211 wl3501_pwr_mgmt(dev->priv, WL3501_SUSPEND); 2184 struct net_device *dev = link->priv;
2212 /* Fall through... */ 2185
2213 case CS_EVENT_RESET_PHYSICAL: 2186 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
2214 if (link->state & DEV_CONFIG) { 2187 if (link->state & DEV_CONFIG) {
2215 if (link->open) 2188 pcmcia_request_configuration(link->handle, &link->conf);
2216 netif_device_detach(dev); 2189 if (link->open) {
2217 pcmcia_release_configuration(link->handle); 2190 wl3501_reset(dev);
2218 } 2191 netif_device_attach(dev);
2219 break;
2220 case CS_EVENT_PM_RESUME:
2221 link->state &= ~DEV_SUSPEND;
2222 wl3501_pwr_mgmt(dev->priv, WL3501_RESUME);
2223 /* Fall through... */
2224 case CS_EVENT_CARD_RESET:
2225 if (link->state & DEV_CONFIG) {
2226 pcmcia_request_configuration(link->handle, &link->conf);
2227 if (link->open) {
2228 wl3501_reset(dev);
2229 netif_device_attach(dev);
2230 }
2231 } 2192 }
2232 break;
2233 } 2193 }
2194
2234 return 0; 2195 return 0;
2235} 2196}
2236 2197
2198
2237static struct pcmcia_device_id wl3501_ids[] = { 2199static struct pcmcia_device_id wl3501_ids[] = {
2238 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001), 2200 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
2239 PCMCIA_DEVICE_NULL 2201 PCMCIA_DEVICE_NULL
@@ -2245,10 +2207,11 @@ static struct pcmcia_driver wl3501_driver = {
2245 .drv = { 2207 .drv = {
2246 .name = "wl3501_cs", 2208 .name = "wl3501_cs",
2247 }, 2209 },
2248 .attach = wl3501_attach, 2210 .probe = wl3501_attach,
2249 .event = wl3501_event, 2211 .remove = wl3501_detach,
2250 .detach = wl3501_detach,
2251 .id_table = wl3501_ids, 2212 .id_table = wl3501_ids,
2213 .suspend = wl3501_suspend,
2214 .resume = wl3501_resume,
2252}; 2215};
2253 2216
2254static int __init wl3501_init_module(void) 2217static int __init wl3501_init_module(void)
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig
index 725a14119f2a..b8241561da45 100644
--- a/drivers/parport/Kconfig
+++ b/drivers/parport/Kconfig
@@ -77,7 +77,7 @@ config PARPORT_PC_SUPERIO
77 77
78config PARPORT_PC_PCMCIA 78config PARPORT_PC_PCMCIA
79 tristate "Support for PCMCIA management for PC-style ports" 79 tristate "Support for PCMCIA management for PC-style ports"
80 depends on PARPORT!=n && (PCMCIA!=n && PARPORT_PC=m && PARPORT_PC || PARPORT_PC=y && PCMCIA) 80 depends on PCMCIA && PARPORT_PC
81 help 81 help
82 Say Y here if you need PCMCIA support for your PC-style parallel 82 Say Y here if you need PCMCIA support for your PC-style parallel
83 ports. If unsure, say N. 83 ports. If unsure, say N.
diff --git a/drivers/parport/daisy.c b/drivers/parport/daisy.c
index 075c7eb5c85d..9ee67321b630 100644
--- a/drivers/parport/daisy.c
+++ b/drivers/parport/daisy.c
@@ -144,9 +144,9 @@ again:
144 add_dev (numdevs++, port, -1); 144 add_dev (numdevs++, port, -1);
145 145
146 /* Find out the legacy device's IEEE 1284 device ID. */ 146 /* Find out the legacy device's IEEE 1284 device ID. */
147 deviceid = kmalloc (1000, GFP_KERNEL); 147 deviceid = kmalloc (1024, GFP_KERNEL);
148 if (deviceid) { 148 if (deviceid) {
149 if (parport_device_id (numdevs - 1, deviceid, 1000) > 2) 149 if (parport_device_id (numdevs - 1, deviceid, 1024) > 2)
150 detected++; 150 detected++;
151 151
152 kfree (deviceid); 152 kfree (deviceid);
@@ -252,7 +252,7 @@ struct pardevice *parport_open (int devnum, const char *name,
252 selected = port->daisy; 252 selected = port->daisy;
253 parport_release (dev); 253 parport_release (dev);
254 254
255 if (selected != port->daisy) { 255 if (selected != daisy) {
256 /* No corresponding device. */ 256 /* No corresponding device. */
257 parport_unregister_device (dev); 257 parport_unregister_device (dev);
258 return NULL; 258 return NULL;
@@ -344,9 +344,9 @@ static int cpp_daisy (struct parport *port, int cmd)
344 PARPORT_CONTROL_STROBE, 344 PARPORT_CONTROL_STROBE,
345 PARPORT_CONTROL_STROBE); 345 PARPORT_CONTROL_STROBE);
346 udelay (1); 346 udelay (1);
347 s = parport_read_status (port);
347 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0); 348 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0);
348 udelay (1); 349 udelay (1);
349 s = parport_read_status (port);
350 parport_write_data (port, 0xff); udelay (2); 350 parport_write_data (port, 0xff); udelay (2);
351 351
352 return s; 352 return s;
@@ -395,15 +395,15 @@ int parport_daisy_select (struct parport *port, int daisy, int mode)
395 case IEEE1284_MODE_EPP: 395 case IEEE1284_MODE_EPP:
396 case IEEE1284_MODE_EPPSL: 396 case IEEE1284_MODE_EPPSL:
397 case IEEE1284_MODE_EPPSWE: 397 case IEEE1284_MODE_EPPSWE:
398 return (cpp_daisy (port, 0x20 + daisy) & 398 return !(cpp_daisy (port, 0x20 + daisy) &
399 PARPORT_STATUS_ERROR); 399 PARPORT_STATUS_ERROR);
400 400
401 // For these modes we should switch to ECP mode: 401 // For these modes we should switch to ECP mode:
402 case IEEE1284_MODE_ECP: 402 case IEEE1284_MODE_ECP:
403 case IEEE1284_MODE_ECPRLE: 403 case IEEE1284_MODE_ECPRLE:
404 case IEEE1284_MODE_ECPSWE: 404 case IEEE1284_MODE_ECPSWE:
405 return (cpp_daisy (port, 0xd0 + daisy) & 405 return !(cpp_daisy (port, 0xd0 + daisy) &
406 PARPORT_STATUS_ERROR); 406 PARPORT_STATUS_ERROR);
407 407
408 // Nothing was told for BECP in Daisy chain specification. 408 // Nothing was told for BECP in Daisy chain specification.
409 // May be it's wise to use ECP? 409 // May be it's wise to use ECP?
@@ -413,8 +413,8 @@ int parport_daisy_select (struct parport *port, int daisy, int mode)
413 case IEEE1284_MODE_BYTE: 413 case IEEE1284_MODE_BYTE:
414 case IEEE1284_MODE_COMPAT: 414 case IEEE1284_MODE_COMPAT:
415 default: 415 default:
416 return (cpp_daisy (port, 0xe0 + daisy) & 416 return !(cpp_daisy (port, 0xe0 + daisy) &
417 PARPORT_STATUS_ERROR); 417 PARPORT_STATUS_ERROR);
418 } 418 }
419} 419}
420 420
@@ -436,7 +436,7 @@ static int select_port (struct parport *port)
436 436
437static int assign_addrs (struct parport *port) 437static int assign_addrs (struct parport *port)
438{ 438{
439 unsigned char s, last_dev; 439 unsigned char s;
440 unsigned char daisy; 440 unsigned char daisy;
441 int thisdev = numdevs; 441 int thisdev = numdevs;
442 int detected; 442 int detected;
@@ -472,10 +472,13 @@ static int assign_addrs (struct parport *port)
472 } 472 }
473 473
474 parport_write_data (port, 0x78); udelay (2); 474 parport_write_data (port, 0x78); udelay (2);
475 last_dev = 0; /* We've just been speaking to a device, so we 475 s = parport_read_status (port);
476 know there must be at least _one_ out there. */
477 476
478 for (daisy = 0; daisy < 4; daisy++) { 477 for (daisy = 0;
478 (s & (PARPORT_STATUS_PAPEROUT|PARPORT_STATUS_SELECT))
479 == (PARPORT_STATUS_PAPEROUT|PARPORT_STATUS_SELECT)
480 && daisy < 4;
481 ++daisy) {
479 parport_write_data (port, daisy); 482 parport_write_data (port, daisy);
480 udelay (2); 483 udelay (2);
481 parport_frob_control (port, 484 parport_frob_control (port,
@@ -485,14 +488,18 @@ static int assign_addrs (struct parport *port)
485 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0); 488 parport_frob_control (port, PARPORT_CONTROL_STROBE, 0);
486 udelay (1); 489 udelay (1);
487 490
488 if (last_dev) 491 add_dev (numdevs++, port, daisy);
489 /* No more devices. */
490 break;
491 492
492 last_dev = !(parport_read_status (port) 493 /* See if this device thought it was the last in the
493 & PARPORT_STATUS_BUSY); 494 * chain. */
495 if (!(s & PARPORT_STATUS_BUSY))
496 break;
494 497
495 add_dev (numdevs++, port, daisy); 498 /* We are seeing pass through status now. We see
499 last_dev from next device or if last_dev does not
500 work status lines from some non-daisy chain
501 device. */
502 s = parport_read_status (port);
496 } 503 }
497 504
498 parport_write_data (port, 0xff); udelay (2); 505 parport_write_data (port, 0xff); udelay (2);
@@ -501,11 +508,11 @@ static int assign_addrs (struct parport *port)
501 detected); 508 detected);
502 509
503 /* Ask the new devices to introduce themselves. */ 510 /* Ask the new devices to introduce themselves. */
504 deviceid = kmalloc (1000, GFP_KERNEL); 511 deviceid = kmalloc (1024, GFP_KERNEL);
505 if (!deviceid) return 0; 512 if (!deviceid) return 0;
506 513
507 for (daisy = 0; thisdev < numdevs; thisdev++, daisy++) 514 for (daisy = 0; thisdev < numdevs; thisdev++, daisy++)
508 parport_device_id (thisdev, deviceid, 1000); 515 parport_device_id (thisdev, deviceid, 1024);
509 516
510 kfree (deviceid); 517 kfree (deviceid);
511 return detected; 518 return detected;
diff --git a/drivers/parport/ieee1284_ops.c b/drivers/parport/ieee1284_ops.c
index ce1e2aad8b10..d6c77658231e 100644
--- a/drivers/parport/ieee1284_ops.c
+++ b/drivers/parport/ieee1284_ops.c
@@ -165,17 +165,7 @@ size_t parport_ieee1284_read_nibble (struct parport *port,
165 /* Does the error line indicate end of data? */ 165 /* Does the error line indicate end of data? */
166 if (((i & 1) == 0) && 166 if (((i & 1) == 0) &&
167 (parport_read_status(port) & PARPORT_STATUS_ERROR)) { 167 (parport_read_status(port) & PARPORT_STATUS_ERROR)) {
168 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; 168 goto end_of_data;
169 DPRINTK (KERN_DEBUG
170 "%s: No more nibble data (%d bytes)\n",
171 port->name, i/2);
172
173 /* Go to reverse idle phase. */
174 parport_frob_control (port,
175 PARPORT_CONTROL_AUTOFD,
176 PARPORT_CONTROL_AUTOFD);
177 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
178 break;
179 } 169 }
180 170
181 /* Event 7: Set nAutoFd low. */ 171 /* Event 7: Set nAutoFd low. */
@@ -225,18 +215,25 @@ size_t parport_ieee1284_read_nibble (struct parport *port,
225 byte = nibble; 215 byte = nibble;
226 } 216 }
227 217
228 i /= 2; /* i is now in bytes */
229
230 if (i == len) { 218 if (i == len) {
231 /* Read the last nibble without checking data avail. */ 219 /* Read the last nibble without checking data avail. */
232 port = port->physport; 220 if (parport_read_status (port) & PARPORT_STATUS_ERROR) {
233 if (parport_read_status (port) & PARPORT_STATUS_ERROR) 221 end_of_data:
234 port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; 222 DPRINTK (KERN_DEBUG
223 "%s: No more nibble data (%d bytes)\n",
224 port->name, i/2);
225
226 /* Go to reverse idle phase. */
227 parport_frob_control (port,
228 PARPORT_CONTROL_AUTOFD,
229 PARPORT_CONTROL_AUTOFD);
230 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
231 }
235 else 232 else
236 port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; 233 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL;
237 } 234 }
238 235
239 return i; 236 return i/2;
240#endif /* IEEE1284 support */ 237#endif /* IEEE1284 support */
241} 238}
242 239
@@ -256,17 +253,7 @@ size_t parport_ieee1284_read_byte (struct parport *port,
256 253
257 /* Data available? */ 254 /* Data available? */
258 if (parport_read_status (port) & PARPORT_STATUS_ERROR) { 255 if (parport_read_status (port) & PARPORT_STATUS_ERROR) {
259 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; 256 goto end_of_data;
260 DPRINTK (KERN_DEBUG
261 "%s: No more byte data (%Zd bytes)\n",
262 port->name, count);
263
264 /* Go to reverse idle phase. */
265 parport_frob_control (port,
266 PARPORT_CONTROL_AUTOFD,
267 PARPORT_CONTROL_AUTOFD);
268 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
269 break;
270 } 257 }
271 258
272 /* Event 14: Place data bus in high impedance state. */ 259 /* Event 14: Place data bus in high impedance state. */
@@ -318,11 +305,20 @@ size_t parport_ieee1284_read_byte (struct parport *port,
318 305
319 if (count == len) { 306 if (count == len) {
320 /* Read the last byte without checking data avail. */ 307 /* Read the last byte without checking data avail. */
321 port = port->physport; 308 if (parport_read_status (port) & PARPORT_STATUS_ERROR) {
322 if (parport_read_status (port) & PARPORT_STATUS_ERROR) 309 end_of_data:
323 port->ieee1284.phase = IEEE1284_PH_HBUSY_DNA; 310 DPRINTK (KERN_DEBUG
311 "%s: No more byte data (%Zd bytes)\n",
312 port->name, count);
313
314 /* Go to reverse idle phase. */
315 parport_frob_control (port,
316 PARPORT_CONTROL_AUTOFD,
317 PARPORT_CONTROL_AUTOFD);
318 port->physport->ieee1284.phase = IEEE1284_PH_REV_IDLE;
319 }
324 else 320 else
325 port->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL; 321 port->physport->ieee1284.phase = IEEE1284_PH_HBUSY_DAVAIL;
326 } 322 }
327 323
328 return count; 324 return count;
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 24e6aacddb74..158d92563259 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -87,15 +87,9 @@ typedef struct parport_info_t {
87 struct parport *port; 87 struct parport *port;
88} parport_info_t; 88} parport_info_t;
89 89
90static dev_link_t *parport_attach(void); 90static void parport_detach(struct pcmcia_device *p_dev);
91static void parport_detach(dev_link_t *);
92static void parport_config(dev_link_t *link); 91static void parport_config(dev_link_t *link);
93static void parport_cs_release(dev_link_t *); 92static void parport_cs_release(dev_link_t *);
94static int parport_event(event_t event, int priority,
95 event_callback_args_t *args);
96
97static dev_info_t dev_info = "parport_cs";
98static dev_link_t *dev_list = NULL;
99 93
100/*====================================================================== 94/*======================================================================
101 95
@@ -105,18 +99,16 @@ static dev_link_t *dev_list = NULL;
105 99
106======================================================================*/ 100======================================================================*/
107 101
108static dev_link_t *parport_attach(void) 102static int parport_attach(struct pcmcia_device *p_dev)
109{ 103{
110 parport_info_t *info; 104 parport_info_t *info;
111 dev_link_t *link; 105 dev_link_t *link;
112 client_reg_t client_reg; 106
113 int ret;
114
115 DEBUG(0, "parport_attach()\n"); 107 DEBUG(0, "parport_attach()\n");
116 108
117 /* Create new parport device */ 109 /* Create new parport device */
118 info = kmalloc(sizeof(*info), GFP_KERNEL); 110 info = kmalloc(sizeof(*info), GFP_KERNEL);
119 if (!info) return NULL; 111 if (!info) return -ENOMEM;
120 memset(info, 0, sizeof(*info)); 112 memset(info, 0, sizeof(*info));
121 link = &info->link; link->priv = info; 113 link = &info->link; link->priv = info;
122 114
@@ -127,21 +119,14 @@ static dev_link_t *parport_attach(void)
127 link->conf.Attributes = CONF_ENABLE_IRQ; 119 link->conf.Attributes = CONF_ENABLE_IRQ;
128 link->conf.Vcc = 50; 120 link->conf.Vcc = 50;
129 link->conf.IntType = INT_MEMORY_AND_IO; 121 link->conf.IntType = INT_MEMORY_AND_IO;
130 122
131 /* Register with Card Services */ 123 link->handle = p_dev;
132 link->next = dev_list; 124 p_dev->instance = link;
133 dev_list = link; 125
134 client_reg.dev_info = &dev_info; 126 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
135 client_reg.Version = 0x0210; 127 parport_config(link);
136 client_reg.event_callback_args.client_data = link; 128
137 ret = pcmcia_register_client(&link->handle, &client_reg); 129 return 0;
138 if (ret != CS_SUCCESS) {
139 cs_error(link->handle, RegisterClient, ret);
140 parport_detach(link);
141 return NULL;
142 }
143
144 return link;
145} /* parport_attach */ 130} /* parport_attach */
146 131
147/*====================================================================== 132/*======================================================================
@@ -153,32 +138,16 @@ static dev_link_t *parport_attach(void)
153 138
154======================================================================*/ 139======================================================================*/
155 140
156static void parport_detach(dev_link_t *link) 141static void parport_detach(struct pcmcia_device *p_dev)
157{ 142{
158 dev_link_t **linkp; 143 dev_link_t *link = dev_to_instance(p_dev);
159 int ret;
160 144
161 DEBUG(0, "parport_detach(0x%p)\n", link); 145 DEBUG(0, "parport_detach(0x%p)\n", link);
162
163 /* Locate device structure */
164 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
165 if (*linkp == link) break;
166 if (*linkp == NULL)
167 return;
168 146
169 if (link->state & DEV_CONFIG) 147 if (link->state & DEV_CONFIG)
170 parport_cs_release(link); 148 parport_cs_release(link);
171 149
172 if (link->handle) {
173 ret = pcmcia_deregister_client(link->handle);
174 if (ret != CS_SUCCESS)
175 cs_error(link->handle, DeregisterClient, ret);
176 }
177
178 /* Unlink, free device structure */
179 *linkp = link->next;
180 kfree(link->priv); 150 kfree(link->priv);
181
182} /* parport_detach */ 151} /* parport_detach */
183 152
184/*====================================================================== 153/*======================================================================
@@ -325,47 +294,27 @@ void parport_cs_release(dev_link_t *link)
325 294
326} /* parport_cs_release */ 295} /* parport_cs_release */
327 296
328/*====================================================================== 297static int parport_suspend(struct pcmcia_device *dev)
329
330 The card status event handler. Mostly, this schedules other
331 stuff to run after an event is received.
332
333======================================================================*/
334
335int parport_event(event_t event, int priority,
336 event_callback_args_t *args)
337{ 298{
338 dev_link_t *link = args->client_data; 299 dev_link_t *link = dev_to_instance(dev);
339 300
340 DEBUG(1, "parport_event(0x%06x)\n", event);
341
342 switch (event) {
343 case CS_EVENT_CARD_REMOVAL:
344 link->state &= ~DEV_PRESENT;
345 if (link->state & DEV_CONFIG)
346 parport_cs_release(link);
347 break;
348 case CS_EVENT_CARD_INSERTION:
349 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
350 parport_config(link);
351 break;
352 case CS_EVENT_PM_SUSPEND:
353 link->state |= DEV_SUSPEND; 301 link->state |= DEV_SUSPEND;
354 /* Fall through... */
355 case CS_EVENT_RESET_PHYSICAL:
356 if (link->state & DEV_CONFIG) 302 if (link->state & DEV_CONFIG)
357 pcmcia_release_configuration(link->handle); 303 pcmcia_release_configuration(link->handle);
358 break; 304
359 case CS_EVENT_PM_RESUME: 305 return 0;
306}
307
308static int parport_resume(struct pcmcia_device *dev)
309{
310 dev_link_t *link = dev_to_instance(dev);
311
360 link->state &= ~DEV_SUSPEND; 312 link->state &= ~DEV_SUSPEND;
361 /* Fall through... */
362 case CS_EVENT_CARD_RESET:
363 if (DEV_OK(link)) 313 if (DEV_OK(link))
364 pcmcia_request_configuration(link->handle, &link->conf); 314 pcmcia_request_configuration(link->handle, &link->conf);
365 break; 315
366 } 316 return 0;
367 return 0; 317}
368} /* parport_event */
369 318
370static struct pcmcia_device_id parport_ids[] = { 319static struct pcmcia_device_id parport_ids[] = {
371 PCMCIA_DEVICE_FUNC_ID(3), 320 PCMCIA_DEVICE_FUNC_ID(3),
@@ -379,11 +328,11 @@ static struct pcmcia_driver parport_cs_driver = {
379 .drv = { 328 .drv = {
380 .name = "parport_cs", 329 .name = "parport_cs",
381 }, 330 },
382 .attach = parport_attach, 331 .probe = parport_attach,
383 .event = parport_event, 332 .remove = parport_detach,
384 .detach = parport_detach,
385 .id_table = parport_ids, 333 .id_table = parport_ids,
386 334 .suspend = parport_suspend,
335 .resume = parport_resume,
387}; 336};
388 337
389static int __init init_parport_cs(void) 338static int __init init_parport_cs(void)
@@ -394,7 +343,6 @@ static int __init init_parport_cs(void)
394static void __exit exit_parport_cs(void) 343static void __exit exit_parport_cs(void)
395{ 344{
396 pcmcia_unregister_driver(&parport_cs_driver); 345 pcmcia_unregister_driver(&parport_cs_driver);
397 BUG_ON(dev_list != NULL);
398} 346}
399 347
400module_init(init_parport_cs); 348module_init(init_parport_cs);
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c
index c6493ad7c0c8..18e85ccdae67 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -1169,7 +1169,7 @@ dump_parport_state ("fwd idle", port);
1169 1169
1170/* GCC is not inlining extern inline function later overwriten to non-inline, 1170/* GCC is not inlining extern inline function later overwriten to non-inline,
1171 so we use outlined_ variants here. */ 1171 so we use outlined_ variants here. */
1172static struct parport_operations parport_pc_ops = 1172static const struct parport_operations parport_pc_ops =
1173{ 1173{
1174 .write_data = parport_pc_write_data, 1174 .write_data = parport_pc_write_data,
1175 .read_data = parport_pc_read_data, 1175 .read_data = parport_pc_read_data,
@@ -1211,10 +1211,11 @@ static struct parport_operations parport_pc_ops =
1211static void __devinit show_parconfig_smsc37c669(int io, int key) 1211static void __devinit show_parconfig_smsc37c669(int io, int key)
1212{ 1212{
1213 int cr1,cr4,cra,cr23,cr26,cr27,i=0; 1213 int cr1,cr4,cra,cr23,cr26,cr27,i=0;
1214 static const char *modes[]={ "SPP and Bidirectional (PS/2)", 1214 static const char *const modes[]={
1215 "EPP and SPP", 1215 "SPP and Bidirectional (PS/2)",
1216 "ECP", 1216 "EPP and SPP",
1217 "ECP and EPP" }; 1217 "ECP",
1218 "ECP and EPP" };
1218 1219
1219 outb(key,io); 1220 outb(key,io);
1220 outb(key,io); 1221 outb(key,io);
@@ -1288,7 +1289,7 @@ static void __devinit show_parconfig_smsc37c669(int io, int key)
1288static void __devinit show_parconfig_winbond(int io, int key) 1289static void __devinit show_parconfig_winbond(int io, int key)
1289{ 1290{
1290 int cr30,cr60,cr61,cr70,cr74,crf0,i=0; 1291 int cr30,cr60,cr61,cr70,cr74,crf0,i=0;
1291 static const char *modes[] = { 1292 static const char *const modes[] = {
1292 "Standard (SPP) and Bidirectional(PS/2)", /* 0 */ 1293 "Standard (SPP) and Bidirectional(PS/2)", /* 0 */
1293 "EPP-1.9 and SPP", 1294 "EPP-1.9 and SPP",
1294 "ECP", 1295 "ECP",
@@ -1297,7 +1298,9 @@ static void __devinit show_parconfig_winbond(int io, int key)
1297 "EPP-1.7 and SPP", /* 5 */ 1298 "EPP-1.7 and SPP", /* 5 */
1298 "undefined!", 1299 "undefined!",
1299 "ECP and EPP-1.7" }; 1300 "ECP and EPP-1.7" };
1300 static char *irqtypes[] = { "pulsed low, high-Z", "follows nACK" }; 1301 static char *const irqtypes[] = {
1302 "pulsed low, high-Z",
1303 "follows nACK" };
1301 1304
1302 /* The registers are called compatible-PnP because the 1305 /* The registers are called compatible-PnP because the
1303 register layout is modelled after ISA-PnP, the access 1306 register layout is modelled after ISA-PnP, the access
@@ -2396,7 +2399,8 @@ EXPORT_SYMBOL (parport_pc_unregister_port);
2396 2399
2397/* ITE support maintained by Rich Liu <richliu@poorman.org> */ 2400/* ITE support maintained by Rich Liu <richliu@poorman.org> */
2398static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq, 2401static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
2399 int autodma, struct parport_pc_via_data *via) 2402 int autodma,
2403 const struct parport_pc_via_data *via)
2400{ 2404{
2401 short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 }; 2405 short inta_addr[6] = { 0x2A0, 0x2C0, 0x220, 0x240, 0x1E0 };
2402 struct resource *base_res; 2406 struct resource *base_res;
@@ -2524,7 +2528,8 @@ static struct parport_pc_via_data via_8231_data __devinitdata = {
2524}; 2528};
2525 2529
2526static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, 2530static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
2527 int autodma, struct parport_pc_via_data *via) 2531 int autodma,
2532 const struct parport_pc_via_data *via)
2528{ 2533{
2529 u8 tmp, tmp2, siofunc; 2534 u8 tmp, tmp2, siofunc;
2530 u8 ppcontrol = 0; 2535 u8 ppcontrol = 0;
@@ -2694,8 +2699,9 @@ enum parport_pc_sio_types {
2694 2699
2695/* each element directly indexed from enum list, above */ 2700/* each element directly indexed from enum list, above */
2696static struct parport_pc_superio { 2701static struct parport_pc_superio {
2697 int (*probe) (struct pci_dev *pdev, int autoirq, int autodma, struct parport_pc_via_data *via); 2702 int (*probe) (struct pci_dev *pdev, int autoirq, int autodma,
2698 struct parport_pc_via_data *via; 2703 const struct parport_pc_via_data *via);
2704 const struct parport_pc_via_data *via;
2699} parport_pc_superio_info[] __devinitdata = { 2705} parport_pc_superio_info[] __devinitdata = {
2700 { sio_via_probe, &via_686a_data, }, 2706 { sio_via_probe, &via_686a_data, },
2701 { sio_via_probe, &via_8231_data, }, 2707 { sio_via_probe, &via_8231_data, },
@@ -2828,7 +2834,7 @@ static struct parport_pc_pci {
2828 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */ 2834 /* netmos_9815 */ { 2, { { 0, -1 }, { 2, -1 }, } }, /* untested */
2829}; 2835};
2830 2836
2831static struct pci_device_id parport_pc_pci_tbl[] = { 2837static const struct pci_device_id parport_pc_pci_tbl[] = {
2832 /* Super-IO onboard chips */ 2838 /* Super-IO onboard chips */
2833 { 0x1106, 0x0686, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_686a }, 2839 { 0x1106, 0x0686, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_686a },
2834 { 0x1106, 0x8231, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_8231 }, 2840 { 0x1106, 0x8231, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sio_via_8231 },
diff --git a/drivers/parport/probe.c b/drivers/parport/probe.c
index 4b48b31ec235..b62aee8de3cb 100644
--- a/drivers/parport/probe.c
+++ b/drivers/parport/probe.c
@@ -11,9 +11,9 @@
11#include <linux/string.h> 11#include <linux/string.h>
12#include <asm/uaccess.h> 12#include <asm/uaccess.h>
13 13
14static struct { 14static const struct {
15 char *token; 15 const char *token;
16 char *descr; 16 const char *descr;
17} classes[] = { 17} classes[] = {
18 { "", "Legacy device" }, 18 { "", "Legacy device" },
19 { "PRINTER", "Printer" }, 19 { "PRINTER", "Printer" },
@@ -128,8 +128,131 @@ static void parse_data(struct parport *port, int device, char *str)
128 kfree(txt); 128 kfree(txt);
129} 129}
130 130
131/* Read up to count-1 bytes of device id. Terminate buffer with
132 * '\0'. Buffer begins with two Device ID length bytes as given by
133 * device. */
134static ssize_t parport_read_device_id (struct parport *port, char *buffer,
135 size_t count)
136{
137 unsigned char length[2];
138 unsigned lelen, belen;
139 size_t idlens[4];
140 unsigned numidlens;
141 unsigned current_idlen;
142 ssize_t retval;
143 size_t len;
144
145 /* First two bytes are MSB,LSB of inclusive length. */
146 retval = parport_read (port, length, 2);
147
148 if (retval < 0)
149 return retval;
150 if (retval != 2)
151 return -EIO;
152
153 if (count < 2)
154 return 0;
155 memcpy(buffer, length, 2);
156 len = 2;
157
158 /* Some devices wrongly send LE length, and some send it two
159 * bytes short. Construct a sorted array of lengths to try. */
160 belen = (length[0] << 8) + length[1];
161 lelen = (length[1] << 8) + length[0];
162 idlens[0] = min(belen, lelen);
163 idlens[1] = idlens[0]+2;
164 if (belen != lelen) {
165 int off = 2;
166 /* Don't try lenghts of 0x100 and 0x200 as 1 and 2 */
167 if (idlens[0] <= 2)
168 off = 0;
169 idlens[off] = max(belen, lelen);
170 idlens[off+1] = idlens[off]+2;
171 numidlens = off+2;
172 }
173 else {
174 /* Some devices don't truly implement Device ID, but
175 * just return constant nibble forever. This catches
176 * also those cases. */
177 if (idlens[0] == 0 || idlens[0] > 0xFFF) {
178 printk (KERN_DEBUG "%s: reported broken Device ID"
179 " length of %#zX bytes\n",
180 port->name, idlens[0]);
181 return -EIO;
182 }
183 numidlens = 2;
184 }
185
186 /* Try to respect the given ID length despite all the bugs in
187 * the ID length. Read according to shortest possible ID
188 * first. */
189 for (current_idlen = 0; current_idlen < numidlens; ++current_idlen) {
190 size_t idlen = idlens[current_idlen];
191 if (idlen+1 >= count)
192 break;
193
194 retval = parport_read (port, buffer+len, idlen-len);
195
196 if (retval < 0)
197 return retval;
198 len += retval;
199
200 if (port->physport->ieee1284.phase != IEEE1284_PH_HBUSY_DAVAIL) {
201 if (belen != len) {
202 printk (KERN_DEBUG "%s: Device ID was %d bytes"
203 " while device told it would be %d"
204 " bytes\n",
205 port->name, len, belen);
206 }
207 goto done;
208 }
209
210 /* This might end reading the Device ID too
211 * soon. Hopefully the needed fields were already in
212 * the first 256 bytes or so that we must have read so
213 * far. */
214 if (buffer[len-1] == ';') {
215 printk (KERN_DEBUG "%s: Device ID reading stopped"
216 " before device told data not available. "
217 "Current idlen %d of %d, len bytes %02X %02X\n",
218 port->name, current_idlen, numidlens,
219 length[0], length[1]);
220 goto done;
221 }
222 }
223 if (current_idlen < numidlens) {
224 /* Buffer not large enough, read to end of buffer. */
225 size_t idlen, len2;
226 if (len+1 < count) {
227 retval = parport_read (port, buffer+len, count-len-1);
228 if (retval < 0)
229 return retval;
230 len += retval;
231 }
232 /* Read the whole ID since some devices would not
233 * otherwise give back the Device ID from beginning
234 * next time when asked. */
235 idlen = idlens[current_idlen];
236 len2 = len;
237 while(len2 < idlen && retval > 0) {
238 char tmp[4];
239 retval = parport_read (port, tmp,
240 min(sizeof tmp, idlen-len2));
241 if (retval < 0)
242 return retval;
243 len2 += retval;
244 }
245 }
246 /* In addition, there are broken devices out there that don't
247 even finish off with a semi-colon. We do not need to care
248 about those at this time. */
249 done:
250 buffer[len] = '\0';
251 return len;
252}
253
131/* Get Std 1284 Device ID. */ 254/* Get Std 1284 Device ID. */
132ssize_t parport_device_id (int devnum, char *buffer, size_t len) 255ssize_t parport_device_id (int devnum, char *buffer, size_t count)
133{ 256{
134 ssize_t retval = -ENXIO; 257 ssize_t retval = -ENXIO;
135 struct pardevice *dev = parport_open (devnum, "Device ID probe", 258 struct pardevice *dev = parport_open (devnum, "Device ID probe",
@@ -139,76 +262,20 @@ ssize_t parport_device_id (int devnum, char *buffer, size_t len)
139 262
140 parport_claim_or_block (dev); 263 parport_claim_or_block (dev);
141 264
142 /* Negotiate to compatibility mode, and then to device ID mode. 265 /* Negotiate to compatibility mode, and then to device ID
143 * (This is in case we are already in device ID mode.) */ 266 * mode. (This so that we start form beginning of device ID if
267 * already in device ID mode.) */
144 parport_negotiate (dev->port, IEEE1284_MODE_COMPAT); 268 parport_negotiate (dev->port, IEEE1284_MODE_COMPAT);
145 retval = parport_negotiate (dev->port, 269 retval = parport_negotiate (dev->port,
146 IEEE1284_MODE_NIBBLE | IEEE1284_DEVICEID); 270 IEEE1284_MODE_NIBBLE | IEEE1284_DEVICEID);
147 271
148 if (!retval) { 272 if (!retval) {
149 int idlen; 273 retval = parport_read_device_id (dev->port, buffer, count);
150 unsigned char length[2];
151
152 /* First two bytes are MSB,LSB of inclusive length. */
153 retval = parport_read (dev->port, length, 2);
154
155 if (retval != 2) goto end_id;
156
157 idlen = (length[0] << 8) + length[1] - 2;
158 /*
159 * Check if the caller-allocated buffer is large enough
160 * otherwise bail out or there will be an at least off by one.
161 */
162 if (idlen + 1 < len)
163 len = idlen;
164 else {
165 retval = -EINVAL;
166 goto out;
167 }
168 retval = parport_read (dev->port, buffer, len);
169
170 if (retval != len)
171 printk (KERN_DEBUG "%s: only read %Zd of %Zd ID bytes\n",
172 dev->port->name, retval,
173 len);
174
175 /* Some printer manufacturers mistakenly believe that
176 the length field is supposed to be _exclusive_.
177 In addition, there are broken devices out there
178 that don't even finish off with a semi-colon. */
179 if (buffer[len - 1] != ';') {
180 ssize_t diff;
181 diff = parport_read (dev->port, buffer + len, 2);
182 retval += diff;
183
184 if (diff)
185 printk (KERN_DEBUG
186 "%s: device reported incorrect "
187 "length field (%d, should be %Zd)\n",
188 dev->port->name, idlen, retval);
189 else {
190 /* One semi-colon short of a device ID. */
191 buffer[len++] = ';';
192 printk (KERN_DEBUG "%s: faking semi-colon\n",
193 dev->port->name);
194
195 /* If we get here, I don't think we
196 need to worry about the possible
197 standard violation of having read
198 more than we were told to. The
199 device is non-compliant anyhow. */
200 }
201 }
202
203 end_id:
204 buffer[len] = '\0';
205 parport_negotiate (dev->port, IEEE1284_MODE_COMPAT); 274 parport_negotiate (dev->port, IEEE1284_MODE_COMPAT);
275 if (retval > 2)
276 parse_data (dev->port, dev->daisy, buffer+2);
206 } 277 }
207 278
208 if (retval > 2)
209 parse_data (dev->port, dev->daisy, buffer);
210
211out:
212 parport_release (dev); 279 parport_release (dev);
213 parport_close (dev); 280 parport_close (dev);
214 return retval; 281 return retval;
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 9cb3ab156b09..ea62bed6bc83 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -1002,6 +1002,7 @@ EXPORT_SYMBOL(parport_register_driver);
1002EXPORT_SYMBOL(parport_unregister_driver); 1002EXPORT_SYMBOL(parport_unregister_driver);
1003EXPORT_SYMBOL(parport_register_device); 1003EXPORT_SYMBOL(parport_register_device);
1004EXPORT_SYMBOL(parport_unregister_device); 1004EXPORT_SYMBOL(parport_unregister_device);
1005EXPORT_SYMBOL(parport_get_port);
1005EXPORT_SYMBOL(parport_put_port); 1006EXPORT_SYMBOL(parport_put_port);
1006EXPORT_SYMBOL(parport_find_number); 1007EXPORT_SYMBOL(parport_find_number);
1007EXPORT_SYMBOL(parport_find_base); 1008EXPORT_SYMBOL(parport_find_base);
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 716df015f8d0..6707df968934 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -6,6 +6,9 @@ obj-y += access.o bus.o probe.o remove.o pci.o quirks.o \
6 pci-driver.o search.o pci-sysfs.o rom.o setup-res.o 6 pci-driver.o search.o pci-sysfs.o rom.o setup-res.o
7obj-$(CONFIG_PROC_FS) += proc.o 7obj-$(CONFIG_PROC_FS) += proc.o
8 8
9# Build PCI Express stuff if needed
10obj-$(CONFIG_PCIEPORTBUS) += pcie/
11
9obj-$(CONFIG_HOTPLUG) += hotplug.o 12obj-$(CONFIG_HOTPLUG) += hotplug.o
10 13
11# Build the PCI Hotplug drivers if we were asked to 14# Build the PCI Hotplug drivers if we were asked to
@@ -40,7 +43,3 @@ endif
40ifeq ($(CONFIG_PCI_DEBUG),y) 43ifeq ($(CONFIG_PCI_DEBUG),y)
41EXTRA_CFLAGS += -DDEBUG 44EXTRA_CFLAGS += -DDEBUG
42endif 45endif
43
44# Build PCI Express stuff if needed
45obj-$(CONFIG_PCIEPORTBUS) += pcie/
46
diff --git a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
index e1743be31909..1c97e7dd130b 100644
--- a/drivers/pci/hotplug.c
+++ b/drivers/pci/hotplug.c
@@ -3,8 +3,8 @@
3#include <linux/module.h> 3#include <linux/module.h>
4#include "pci.h" 4#include "pci.h"
5 5
6int pci_hotplug (struct device *dev, char **envp, int num_envp, 6int pci_uevent(struct device *dev, char **envp, int num_envp,
7 char *buffer, int buffer_size) 7 char *buffer, int buffer_size)
8{ 8{
9 struct pci_dev *pdev; 9 struct pci_dev *pdev;
10 int i = 0; 10 int i = 0;
@@ -17,34 +17,34 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
17 if (!pdev) 17 if (!pdev)
18 return -ENODEV; 18 return -ENODEV;
19 19
20 if (add_hotplug_env_var(envp, num_envp, &i, 20 if (add_uevent_var(envp, num_envp, &i,
21 buffer, buffer_size, &length, 21 buffer, buffer_size, &length,
22 "PCI_CLASS=%04X", pdev->class)) 22 "PCI_CLASS=%04X", pdev->class))
23 return -ENOMEM; 23 return -ENOMEM;
24 24
25 if (add_hotplug_env_var(envp, num_envp, &i, 25 if (add_uevent_var(envp, num_envp, &i,
26 buffer, buffer_size, &length, 26 buffer, buffer_size, &length,
27 "PCI_ID=%04X:%04X", pdev->vendor, pdev->device)) 27 "PCI_ID=%04X:%04X", pdev->vendor, pdev->device))
28 return -ENOMEM; 28 return -ENOMEM;
29 29
30 if (add_hotplug_env_var(envp, num_envp, &i, 30 if (add_uevent_var(envp, num_envp, &i,
31 buffer, buffer_size, &length, 31 buffer, buffer_size, &length,
32 "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor, 32 "PCI_SUBSYS_ID=%04X:%04X", pdev->subsystem_vendor,
33 pdev->subsystem_device)) 33 pdev->subsystem_device))
34 return -ENOMEM; 34 return -ENOMEM;
35 35
36 if (add_hotplug_env_var(envp, num_envp, &i, 36 if (add_uevent_var(envp, num_envp, &i,
37 buffer, buffer_size, &length, 37 buffer, buffer_size, &length,
38 "PCI_SLOT_NAME=%s", pci_name(pdev))) 38 "PCI_SLOT_NAME=%s", pci_name(pdev)))
39 return -ENOMEM; 39 return -ENOMEM;
40 40
41 if (add_hotplug_env_var(envp, num_envp, &i, 41 if (add_uevent_var(envp, num_envp, &i,
42 buffer, buffer_size, &length, 42 buffer, buffer_size, &length,
43 "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x", 43 "MODALIAS=pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x",
44 pdev->vendor, pdev->device, 44 pdev->vendor, pdev->device,
45 pdev->subsystem_vendor, pdev->subsystem_device, 45 pdev->subsystem_vendor, pdev->subsystem_device,
46 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8), 46 (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
47 (u8)(pdev->class))) 47 (u8)(pdev->class)))
48 return -ENOMEM; 48 return -ENOMEM;
49 49
50 envp[i] = NULL; 50 envp[i] = NULL;
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index a9046d4b8af3..7146b69b812c 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -502,8 +502,8 @@ void pci_dev_put(struct pci_dev *dev)
502} 502}
503 503
504#ifndef CONFIG_HOTPLUG 504#ifndef CONFIG_HOTPLUG
505int pci_hotplug (struct device *dev, char **envp, int num_envp, 505int pci_uevent(struct device *dev, char **envp, int num_envp,
506 char *buffer, int buffer_size) 506 char *buffer, int buffer_size)
507{ 507{
508 return -ENODEV; 508 return -ENODEV;
509} 509}
@@ -512,7 +512,7 @@ int pci_hotplug (struct device *dev, char **envp, int num_envp,
512struct bus_type pci_bus_type = { 512struct bus_type pci_bus_type = {
513 .name = "pci", 513 .name = "pci",
514 .match = pci_bus_match, 514 .match = pci_bus_match,
515 .hotplug = pci_hotplug, 515 .uevent = pci_uevent,
516 .suspend = pci_device_suspend, 516 .suspend = pci_device_suspend,
517 .resume = pci_device_resume, 517 .resume = pci_device_resume,
518 .dev_attrs = pci_dev_attrs, 518 .dev_attrs = pci_dev_attrs,
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 6527b36c9a61..294849d24590 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -1,7 +1,7 @@
1/* Functions internal to the PCI core code */ 1/* Functions internal to the PCI core code */
2 2
3extern int pci_hotplug (struct device *dev, char **envp, int num_envp, 3extern int pci_uevent(struct device *dev, char **envp, int num_envp,
4 char *buffer, int buffer_size); 4 char *buffer, int buffer_size);
5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev); 5extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
6extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev); 6extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
7extern void pci_cleanup_rom(struct pci_dev *dev); 7extern void pci_cleanup_rom(struct pci_dev *dev);
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 3a4f49f4effb..f28ebdd3958a 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -1098,6 +1098,23 @@ static void __init quirk_alder_ioapic(struct pci_dev *pdev)
1098DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic ); 1098DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_EESSC, quirk_alder_ioapic );
1099#endif 1099#endif
1100 1100
1101enum ide_combined_type { COMBINED = 0, IDE = 1, LIBATA = 2 };
1102/* Defaults to combined */
1103static enum ide_combined_type combined_mode;
1104
1105static int __init combined_setup(char *str)
1106{
1107 if (!strncmp(str, "ide", 3))
1108 combined_mode = IDE;
1109 else if (!strncmp(str, "libata", 6))
1110 combined_mode = LIBATA;
1111 else /* "combined" or anything else defaults to old behavior */
1112 combined_mode = COMBINED;
1113
1114 return 1;
1115}
1116__setup("combined_mode=", combined_setup);
1117
1101#ifdef CONFIG_SCSI_SATA_INTEL_COMBINED 1118#ifdef CONFIG_SCSI_SATA_INTEL_COMBINED
1102static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev) 1119static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
1103{ 1120{
@@ -1164,6 +1181,19 @@ static void __devinit quirk_intel_ide_combined(struct pci_dev *pdev)
1164 if (prog & comb) 1181 if (prog & comb)
1165 return; 1182 return;
1166 1183
1184 /* Don't reserve any so the IDE driver can get them (but only if
1185 * combined_mode=ide).
1186 */
1187 if (combined_mode == IDE)
1188 return;
1189
1190 /* Grab them both for libata if combined_mode=libata. */
1191 if (combined_mode == LIBATA) {
1192 request_region(0x1f0, 8, "libata"); /* port 0 */
1193 request_region(0x170, 8, "libata"); /* port 1 */
1194 return;
1195 }
1196
1167 /* SATA port is in legacy mode. Reserve port so that 1197 /* SATA port is in legacy mode. Reserve port so that
1168 * IDE driver does not attempt to use it. If request_region 1198 * IDE driver does not attempt to use it. If request_region
1169 * fails, it will be obvious at boot time, so we don't bother 1199 * fails, it will be obvious at boot time, so we don't bother
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index 309eb557f9a3..1f4ad0e7836e 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -116,6 +116,31 @@ config YENTA
116 116
117 If unsure, say Y. 117 If unsure, say Y.
118 118
119config YENTA_O2
120 default y
121 bool "Special initialization for O2Micro bridges" if EMBEDDED
122 depends on YENTA
123
124config YENTA_RICOH
125 default y
126 bool "Special initialization for Ricoh bridges" if EMBEDDED
127 depends on YENTA
128
129config YENTA_TI
130 default y
131 bool "Special initialization for TI and EnE bridges" if EMBEDDED
132 depends on YENTA
133
134config YENTA_ENE_TUNE
135 default y
136 bool "Auto-tune EnE bridges for CB cards" if EMBEDDED
137 depends on YENTA_TI && CARDBUS
138
139config YENTA_TOSHIBA
140 default y
141 bool "Special initialization for Toshiba ToPIC bridges" if EMBEDDED
142 depends on YENTA
143
119config PD6729 144config PD6729
120 tristate "Cirrus PD6729 compatible bridge support" 145 tristate "Cirrus PD6729 compatible bridge support"
121 depends on PCMCIA && PCI 146 depends on PCMCIA && PCI
@@ -157,7 +182,7 @@ config TCIC
157config PCMCIA_M8XX 182config PCMCIA_M8XX
158 tristate "MPC8xx PCMCIA support" 183 tristate "MPC8xx PCMCIA support"
159 depends on PCMCIA && PPC && 8xx 184 depends on PCMCIA && PPC && 8xx
160 select PCCARD_NONSTATIC 185 select PCCARD_IODYN
161 help 186 help
162 Say Y here to include support for PowerPC 8xx series PCMCIA 187 Say Y here to include support for PowerPC 8xx series PCMCIA
163 controller. 188 controller.
@@ -200,7 +225,7 @@ config PCMCIA_PXA2XX
200 225
201config PCMCIA_PROBE 226config PCMCIA_PROBE
202 bool 227 bool
203 default y if ISA && !ARCH_SA1100 && !ARCH_CLPS711X 228 default y if ISA && !ARCH_SA1100 && !ARCH_CLPS711X && !PARISC
204 229
205config M32R_PCC 230config M32R_PCC
206 bool "M32R PCMCIA I/F" 231 bool "M32R PCMCIA I/F"
@@ -241,6 +266,9 @@ config OMAP_CF
241config PCCARD_NONSTATIC 266config PCCARD_NONSTATIC
242 tristate 267 tristate
243 268
269config PCCARD_IODYN
270 bool
271
244endif # PCCARD 272endif # PCCARD
245 273
246endmenu 274endmenu
diff --git a/drivers/pcmcia/au1000_generic.c b/drivers/pcmcia/au1000_generic.c
index 87302c548c24..971a35281649 100644
--- a/drivers/pcmcia/au1000_generic.c
+++ b/drivers/pcmcia/au1000_generic.c
@@ -241,23 +241,6 @@ au1x00_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status)
241 return 0; 241 return 0;
242} 242}
243 243
244/* au1x00_pcmcia_get_socket()
245 * Implements the get_socket() operation for the in-kernel PCMCIA
246 * service (formerly SS_GetSocket in Card Services). Not a very
247 * exciting routine.
248 *
249 * Returns: 0
250 */
251static int
252au1x00_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
253{
254 struct au1000_pcmcia_socket *skt = to_au1000_socket(sock);
255
256 debug("for sock %u\n", skt->nr);
257 *state = skt->cs_state;
258 return 0;
259}
260
261/* au1x00_pcmcia_set_socket() 244/* au1x00_pcmcia_set_socket()
262 * Implements the set_socket() operation for the in-kernel PCMCIA 245 * Implements the set_socket() operation for the in-kernel PCMCIA
263 * service (formerly SS_SetSocket in Card Services). We more or 246 * service (formerly SS_SetSocket in Card Services). We more or
@@ -352,7 +335,6 @@ static struct pccard_operations au1x00_pcmcia_operations = {
352 .init = au1x00_pcmcia_sock_init, 335 .init = au1x00_pcmcia_sock_init,
353 .suspend = au1x00_pcmcia_suspend, 336 .suspend = au1x00_pcmcia_suspend,
354 .get_status = au1x00_pcmcia_get_status, 337 .get_status = au1x00_pcmcia_get_status,
355 .get_socket = au1x00_pcmcia_get_socket,
356 .set_socket = au1x00_pcmcia_set_socket, 338 .set_socket = au1x00_pcmcia_set_socket,
357 .set_io_map = au1x00_pcmcia_set_io_map, 339 .set_io_map = au1x00_pcmcia_set_io_map,
358 .set_mem_map = au1x00_pcmcia_set_mem_map, 340 .set_mem_map = au1x00_pcmcia_set_mem_map,
@@ -372,13 +354,12 @@ int au1x00_pcmcia_socket_probe(struct device *dev, struct pcmcia_low_level *ops,
372 struct skt_dev_info *sinfo; 354 struct skt_dev_info *sinfo;
373 int ret, i; 355 int ret, i;
374 356
375 sinfo = kmalloc(sizeof(struct skt_dev_info), GFP_KERNEL); 357 sinfo = kzalloc(sizeof(struct skt_dev_info), GFP_KERNEL);
376 if (!sinfo) { 358 if (!sinfo) {
377 ret = -ENOMEM; 359 ret = -ENOMEM;
378 goto out; 360 goto out;
379 } 361 }
380 362
381 memset(sinfo, 0, sizeof(struct skt_dev_info));
382 sinfo->nskt = nr; 363 sinfo->nskt = nr;
383 364
384 /* 365 /*
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c
index 2dc3e611a9a3..120fa8da6392 100644
--- a/drivers/pcmcia/cistpl.c
+++ b/drivers/pcmcia/cistpl.c
@@ -60,9 +60,9 @@ static const u_int exponent[] = {
60 60
61/* Parameters that can be set with 'insmod' */ 61/* Parameters that can be set with 'insmod' */
62 62
63#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0444) 63/* 16-bit CIS? */
64 64static int cis_width;
65INT_MODULE_PARM(cis_width, 0); /* 16-bit CIS? */ 65module_param(cis_width, int, 0444);
66 66
67void release_cis_mem(struct pcmcia_socket *s) 67void release_cis_mem(struct pcmcia_socket *s)
68{ 68{
@@ -463,7 +463,7 @@ static int follow_link(struct pcmcia_socket *s, tuple_t *tuple)
463 /* Get indirect link from the MFC tuple */ 463 /* Get indirect link from the MFC tuple */
464 read_cis_cache(s, LINK_SPACE(tuple->Flags), 464 read_cis_cache(s, LINK_SPACE(tuple->Flags),
465 tuple->LinkOffset, 5, link); 465 tuple->LinkOffset, 5, link);
466 ofs = le32_to_cpu(*(u_int *)(link+1)); 466 ofs = le32_to_cpu(*(__le32 *)(link+1));
467 SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR); 467 SPACE(tuple->Flags) = (link[0] == CISTPL_MFC_ATTR);
468 /* Move to the next indirect link */ 468 /* Move to the next indirect link */
469 tuple->LinkOffset += 5; 469 tuple->LinkOffset += 5;
@@ -671,8 +671,8 @@ static int parse_checksum(tuple_t *tuple, cistpl_checksum_t *csum)
671 if (tuple->TupleDataLen < 5) 671 if (tuple->TupleDataLen < 5)
672 return CS_BAD_TUPLE; 672 return CS_BAD_TUPLE;
673 p = (u_char *)tuple->TupleData; 673 p = (u_char *)tuple->TupleData;
674 csum->addr = tuple->CISOffset+(short)le16_to_cpu(*(u_short *)p)-2; 674 csum->addr = tuple->CISOffset+(short)le16_to_cpu(*(__le16 *)p)-2;
675 csum->len = le16_to_cpu(*(u_short *)(p + 2)); 675 csum->len = le16_to_cpu(*(__le16 *)(p + 2));
676 csum->sum = *(p+4); 676 csum->sum = *(p+4);
677 return CS_SUCCESS; 677 return CS_SUCCESS;
678} 678}
@@ -683,7 +683,7 @@ static int parse_longlink(tuple_t *tuple, cistpl_longlink_t *link)
683{ 683{
684 if (tuple->TupleDataLen < 4) 684 if (tuple->TupleDataLen < 4)
685 return CS_BAD_TUPLE; 685 return CS_BAD_TUPLE;
686 link->addr = le32_to_cpu(*(u_int *)tuple->TupleData); 686 link->addr = le32_to_cpu(*(__le32 *)tuple->TupleData);
687 return CS_SUCCESS; 687 return CS_SUCCESS;
688} 688}
689 689
@@ -702,7 +702,7 @@ static int parse_longlink_mfc(tuple_t *tuple,
702 return CS_BAD_TUPLE; 702 return CS_BAD_TUPLE;
703 for (i = 0; i < link->nfn; i++) { 703 for (i = 0; i < link->nfn; i++) {
704 link->fn[i].space = *p; p++; 704 link->fn[i].space = *p; p++;
705 link->fn[i].addr = le32_to_cpu(*(u_int *)p); p += 4; 705 link->fn[i].addr = le32_to_cpu(*(__le32 *)p); p += 4;
706 } 706 }
707 return CS_SUCCESS; 707 return CS_SUCCESS;
708} 708}
@@ -789,10 +789,10 @@ static int parse_jedec(tuple_t *tuple, cistpl_jedec_t *jedec)
789 789
790static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m) 790static int parse_manfid(tuple_t *tuple, cistpl_manfid_t *m)
791{ 791{
792 u_short *p; 792 __le16 *p;
793 if (tuple->TupleDataLen < 4) 793 if (tuple->TupleDataLen < 4)
794 return CS_BAD_TUPLE; 794 return CS_BAD_TUPLE;
795 p = (u_short *)tuple->TupleData; 795 p = (__le16 *)tuple->TupleData;
796 m->manf = le16_to_cpu(p[0]); 796 m->manf = le16_to_cpu(p[0]);
797 m->card = le16_to_cpu(p[1]); 797 m->card = le16_to_cpu(p[1]);
798 return CS_SUCCESS; 798 return CS_SUCCESS;
@@ -1093,7 +1093,7 @@ static int parse_cftable_entry(tuple_t *tuple,
1093 break; 1093 break;
1094 case 0x20: 1094 case 0x20:
1095 entry->mem.nwin = 1; 1095 entry->mem.nwin = 1;
1096 entry->mem.win[0].len = le16_to_cpu(*(u_short *)p) << 8; 1096 entry->mem.win[0].len = le16_to_cpu(*(__le16 *)p) << 8;
1097 entry->mem.win[0].card_addr = 0; 1097 entry->mem.win[0].card_addr = 0;
1098 entry->mem.win[0].host_addr = 0; 1098 entry->mem.win[0].host_addr = 0;
1099 p += 2; 1099 p += 2;
@@ -1101,9 +1101,9 @@ static int parse_cftable_entry(tuple_t *tuple,
1101 break; 1101 break;
1102 case 0x40: 1102 case 0x40:
1103 entry->mem.nwin = 1; 1103 entry->mem.nwin = 1;
1104 entry->mem.win[0].len = le16_to_cpu(*(u_short *)p) << 8; 1104 entry->mem.win[0].len = le16_to_cpu(*(__le16 *)p) << 8;
1105 entry->mem.win[0].card_addr = 1105 entry->mem.win[0].card_addr =
1106 le16_to_cpu(*(u_short *)(p+2)) << 8; 1106 le16_to_cpu(*(__le16 *)(p+2)) << 8;
1107 entry->mem.win[0].host_addr = 0; 1107 entry->mem.win[0].host_addr = 0;
1108 p += 4; 1108 p += 4;
1109 if (p > q) return CS_BAD_TUPLE; 1109 if (p > q) return CS_BAD_TUPLE;
@@ -1140,7 +1140,7 @@ static int parse_bar(tuple_t *tuple, cistpl_bar_t *bar)
1140 p = (u_char *)tuple->TupleData; 1140 p = (u_char *)tuple->TupleData;
1141 bar->attr = *p; 1141 bar->attr = *p;
1142 p += 2; 1142 p += 2;
1143 bar->size = le32_to_cpu(*(u_int *)p); 1143 bar->size = le32_to_cpu(*(__le32 *)p);
1144 return CS_SUCCESS; 1144 return CS_SUCCESS;
1145} 1145}
1146 1146
@@ -1153,7 +1153,7 @@ static int parse_config_cb(tuple_t *tuple, cistpl_config_t *config)
1153 return CS_BAD_TUPLE; 1153 return CS_BAD_TUPLE;
1154 config->last_idx = *(++p); 1154 config->last_idx = *(++p);
1155 p++; 1155 p++;
1156 config->base = le32_to_cpu(*(u_int *)p); 1156 config->base = le32_to_cpu(*(__le32 *)p);
1157 config->subtuples = tuple->TupleDataLen - 6; 1157 config->subtuples = tuple->TupleDataLen - 6;
1158 return CS_SUCCESS; 1158 return CS_SUCCESS;
1159} 1159}
@@ -1269,7 +1269,7 @@ static int parse_vers_2(tuple_t *tuple, cistpl_vers_2_t *v2)
1269 1269
1270 v2->vers = p[0]; 1270 v2->vers = p[0];
1271 v2->comply = p[1]; 1271 v2->comply = p[1];
1272 v2->dindex = le16_to_cpu(*(u_short *)(p+2)); 1272 v2->dindex = le16_to_cpu(*(__le16 *)(p+2));
1273 v2->vspec8 = p[6]; 1273 v2->vspec8 = p[6];
1274 v2->vspec9 = p[7]; 1274 v2->vspec9 = p[7];
1275 v2->nhdr = p[8]; 1275 v2->nhdr = p[8];
@@ -1310,8 +1310,8 @@ static int parse_format(tuple_t *tuple, cistpl_format_t *fmt)
1310 1310
1311 fmt->type = p[0]; 1311 fmt->type = p[0];
1312 fmt->edc = p[1]; 1312 fmt->edc = p[1];
1313 fmt->offset = le32_to_cpu(*(u_int *)(p+2)); 1313 fmt->offset = le32_to_cpu(*(__le32 *)(p+2));
1314 fmt->length = le32_to_cpu(*(u_int *)(p+6)); 1314 fmt->length = le32_to_cpu(*(__le32 *)(p+6));
1315 1315
1316 return CS_SUCCESS; 1316 return CS_SUCCESS;
1317} 1317}
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index a30aa74304a2..613f2f1fbfdd 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -309,41 +309,6 @@ struct pcmcia_socket * pcmcia_get_socket_by_nr(unsigned int nr)
309} 309}
310EXPORT_SYMBOL(pcmcia_get_socket_by_nr); 310EXPORT_SYMBOL(pcmcia_get_socket_by_nr);
311 311
312
313/**
314 * socket_setup() and shutdown_socket() are called by the main event
315 * handler when card insertion and removal events are received.
316 * socket_setup() turns on socket power and resets the socket, in two stages.
317 * shutdown_socket() unconfigures a socket and turns off socket power.
318 */
319static void shutdown_socket(struct pcmcia_socket *s)
320{
321 cs_dbg(s, 1, "shutdown_socket\n");
322
323 /* Blank out the socket state */
324 s->socket = dead_socket;
325 s->ops->init(s);
326 s->ops->set_socket(s, &s->socket);
327 s->irq.AssignedIRQ = s->irq.Config = 0;
328 s->lock_count = 0;
329 destroy_cis_cache(s);
330#ifdef CONFIG_CARDBUS
331 cb_free(s);
332#endif
333 s->functions = 0;
334 kfree(s->config);
335 s->config = NULL;
336
337 {
338 int status;
339 s->ops->get_status(s, &status);
340 if (status & SS_POWERON) {
341 printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s);
342 }
343 }
344} /* shutdown_socket */
345
346
347/** 312/**
348 * The central event handler. Send_event() sends an event to the 313 * The central event handler. Send_event() sends an event to the
349 * 16-bit subsystem, which then calls the relevant device drivers. 314 * 16-bit subsystem, which then calls the relevant device drivers.
@@ -383,17 +348,6 @@ static void socket_remove_drivers(struct pcmcia_socket *skt)
383 send_event(skt, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH); 348 send_event(skt, CS_EVENT_CARD_REMOVAL, CS_EVENT_PRI_HIGH);
384} 349}
385 350
386static void socket_shutdown(struct pcmcia_socket *skt)
387{
388 cs_dbg(skt, 4, "shutdown\n");
389
390 socket_remove_drivers(skt);
391 skt->state &= SOCKET_INUSE|SOCKET_PRESENT;
392 msleep(shutdown_delay * 10);
393 skt->state &= SOCKET_INUSE;
394 shutdown_socket(skt);
395}
396
397static int socket_reset(struct pcmcia_socket *skt) 351static int socket_reset(struct pcmcia_socket *skt)
398{ 352{
399 int status, i; 353 int status, i;
@@ -424,6 +378,45 @@ static int socket_reset(struct pcmcia_socket *skt)
424 return CS_GENERAL_FAILURE; 378 return CS_GENERAL_FAILURE;
425} 379}
426 380
381/**
382 * socket_setup() and socket_shutdown() are called by the main event handler
383 * when card insertion and removal events are received.
384 * socket_setup() turns on socket power and resets the socket, in two stages.
385 * socket_shutdown() unconfigures a socket and turns off socket power.
386 */
387static void socket_shutdown(struct pcmcia_socket *s)
388{
389 int status;
390
391 cs_dbg(s, 4, "shutdown\n");
392
393 socket_remove_drivers(s);
394 s->state &= SOCKET_INUSE | SOCKET_PRESENT;
395 msleep(shutdown_delay * 10);
396 s->state &= SOCKET_INUSE;
397
398 /* Blank out the socket state */
399 s->socket = dead_socket;
400 s->ops->init(s);
401 s->ops->set_socket(s, &s->socket);
402 s->irq.AssignedIRQ = s->irq.Config = 0;
403 s->lock_count = 0;
404 destroy_cis_cache(s);
405#ifdef CONFIG_CARDBUS
406 cb_free(s);
407#endif
408 s->functions = 0;
409 kfree(s->config);
410 s->config = NULL;
411
412 s->ops->get_status(s, &status);
413 if (status & SS_POWERON) {
414 printk(KERN_ERR "PCMCIA: socket %p: *** DANGER *** unable to remove socket power\n", s);
415 }
416
417 cs_socket_put(s);
418}
419
427static int socket_setup(struct pcmcia_socket *skt, int initial_delay) 420static int socket_setup(struct pcmcia_socket *skt, int initial_delay)
428{ 421{
429 int status, i; 422 int status, i;
@@ -529,7 +522,6 @@ static int socket_insert(struct pcmcia_socket *skt)
529 send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW); 522 send_event(skt, CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW);
530 } else { 523 } else {
531 socket_shutdown(skt); 524 socket_shutdown(skt);
532 cs_socket_put(skt);
533 } 525 }
534 526
535 return ret; 527 return ret;
@@ -593,7 +585,6 @@ static int socket_resume(struct pcmcia_socket *skt)
593 } 585 }
594 } else { 586 } else {
595 socket_shutdown(skt); 587 socket_shutdown(skt);
596 cs_socket_put(skt);
597 } 588 }
598 589
599 skt->state &= ~SOCKET_SUSPEND; 590 skt->state &= ~SOCKET_SUSPEND;
@@ -605,7 +596,6 @@ static void socket_remove(struct pcmcia_socket *skt)
605{ 596{
606 printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock); 597 printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock);
607 socket_shutdown(skt); 598 socket_shutdown(skt);
608 cs_socket_put(skt);
609} 599}
610 600
611/* 601/*
@@ -780,8 +770,13 @@ int pccard_reset_card(struct pcmcia_socket *skt)
780 ret = send_event(skt, CS_EVENT_RESET_REQUEST, CS_EVENT_PRI_LOW); 770 ret = send_event(skt, CS_EVENT_RESET_REQUEST, CS_EVENT_PRI_LOW);
781 if (ret == 0) { 771 if (ret == 0) {
782 send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW); 772 send_event(skt, CS_EVENT_RESET_PHYSICAL, CS_EVENT_PRI_LOW);
783 if (socket_reset(skt) == CS_SUCCESS) 773 if (skt->callback)
774 skt->callback->suspend(skt);
775 if (socket_reset(skt) == CS_SUCCESS) {
784 send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW); 776 send_event(skt, CS_EVENT_CARD_RESET, CS_EVENT_PRI_LOW);
777 if (skt->callback)
778 skt->callback->resume(skt);
779 }
785 } 780 }
786 781
787 ret = CS_SUCCESS; 782 ret = CS_SUCCESS;
@@ -812,6 +807,11 @@ int pcmcia_suspend_card(struct pcmcia_socket *skt)
812 ret = CS_UNSUPPORTED_FUNCTION; 807 ret = CS_UNSUPPORTED_FUNCTION;
813 break; 808 break;
814 } 809 }
810 if (skt->callback) {
811 ret = skt->callback->suspend(skt);
812 if (ret)
813 break;
814 }
815 ret = socket_suspend(skt); 815 ret = socket_suspend(skt);
816 } while (0); 816 } while (0);
817 up(&skt->skt_sem); 817 up(&skt->skt_sem);
@@ -838,6 +838,8 @@ int pcmcia_resume_card(struct pcmcia_socket *skt)
838 break; 838 break;
839 } 839 }
840 ret = socket_resume(skt); 840 ret = socket_resume(skt);
841 if (!ret && skt->callback)
842 skt->callback->resume(skt);
841 } while (0); 843 } while (0);
842 up(&skt->skt_sem); 844 up(&skt->skt_sem);
843 845
@@ -901,14 +903,14 @@ int pcmcia_insert_card(struct pcmcia_socket *skt)
901EXPORT_SYMBOL(pcmcia_insert_card); 903EXPORT_SYMBOL(pcmcia_insert_card);
902 904
903 905
904static int pcmcia_socket_hotplug(struct class_device *dev, char **envp, 906static int pcmcia_socket_uevent(struct class_device *dev, char **envp,
905 int num_envp, char *buffer, int buffer_size) 907 int num_envp, char *buffer, int buffer_size)
906{ 908{
907 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev); 909 struct pcmcia_socket *s = container_of(dev, struct pcmcia_socket, dev);
908 int i = 0, length = 0; 910 int i = 0, length = 0;
909 911
910 if (add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, 912 if (add_uevent_var(envp, num_envp, &i, buffer, buffer_size,
911 &length, "SOCKET_NO=%u", s->sock)) 913 &length, "SOCKET_NO=%u", s->sock))
912 return -ENOMEM; 914 return -ENOMEM;
913 915
914 envp[i] = NULL; 916 envp[i] = NULL;
@@ -927,7 +929,7 @@ static void pcmcia_release_socket_class(struct class *data)
927 929
928struct class pcmcia_socket_class = { 930struct class pcmcia_socket_class = {
929 .name = "pcmcia_socket", 931 .name = "pcmcia_socket",
930 .hotplug = pcmcia_socket_hotplug, 932 .uevent = pcmcia_socket_uevent,
931 .release = pcmcia_release_socket, 933 .release = pcmcia_release_socket,
932 .class_release = pcmcia_release_socket_class, 934 .class_release = pcmcia_release_socket_class,
933}; 935};
diff --git a/drivers/pcmcia/cs_internal.h b/drivers/pcmcia/cs_internal.h
index 55867bc7f199..7b37eba35bf1 100644
--- a/drivers/pcmcia/cs_internal.h
+++ b/drivers/pcmcia/cs_internal.h
@@ -117,7 +117,7 @@ int verify_cis_cache(struct pcmcia_socket *s);
117int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse); 117int pccard_read_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, void *parse);
118 118
119/* In rsrc_mgr */ 119/* In rsrc_mgr */
120void pcmcia_validate_mem(struct pcmcia_socket *s); 120int pcmcia_validate_mem(struct pcmcia_socket *s);
121struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align, 121struct resource *pcmcia_find_io_region(unsigned long base, int num, unsigned long align,
122 struct pcmcia_socket *s); 122 struct pcmcia_socket *s);
123int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start, 123int pcmcia_adjust_io_region(struct resource *res, unsigned long r_start,
@@ -143,6 +143,8 @@ struct pcmcia_callback{
143 struct module *owner; 143 struct module *owner;
144 int (*event) (struct pcmcia_socket *s, event_t event, int priority); 144 int (*event) (struct pcmcia_socket *s, event_t event, int priority);
145 void (*requery) (struct pcmcia_socket *s); 145 void (*requery) (struct pcmcia_socket *s);
146 int (*suspend) (struct pcmcia_socket *s);
147 int (*resume) (struct pcmcia_socket *s);
146}; 148};
147 149
148int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c); 150int pccard_register_pcmcia(struct pcmcia_socket *s, struct pcmcia_callback *c);
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 7f8219f3fd9e..0252582b91cd 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -57,8 +57,6 @@ module_param_named(pc_debug, ds_pc_debug, int, 0644);
57 57
58spinlock_t pcmcia_dev_list_lock; 58spinlock_t pcmcia_dev_list_lock;
59 59
60static int unbind_request(struct pcmcia_socket *s);
61
62/*====================================================================*/ 60/*====================================================================*/
63 61
64/* code which was in cs.c before */ 62/* code which was in cs.c before */
@@ -205,7 +203,7 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv)
205 unsigned int i; 203 unsigned int i;
206 u32 hash; 204 u32 hash;
207 205
208 if (!p_drv->attach || !p_drv->event || !p_drv->detach) 206 if (!p_drv->probe || !p_drv->remove)
209 printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback " 207 printk(KERN_DEBUG "pcmcia: %s lacks a requisite callback "
210 "function\n", p_drv->drv.name); 208 "function\n", p_drv->drv.name);
211 209
@@ -266,12 +264,10 @@ static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename)
266 if (fw->size >= CISTPL_MAX_CIS_SIZE) 264 if (fw->size >= CISTPL_MAX_CIS_SIZE)
267 goto release; 265 goto release;
268 266
269 cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); 267 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
270 if (!cis) 268 if (!cis)
271 goto release; 269 goto release;
272 270
273 memset(cis, 0, sizeof(cisdump_t));
274
275 cis->Length = fw->size + 1; 271 cis->Length = fw->size + 1;
276 memcpy(cis->Data, fw->data, fw->size); 272 memcpy(cis->Data, fw->data, fw->size);
277 273
@@ -363,6 +359,7 @@ static int pcmcia_device_probe(struct device * dev)
363{ 359{
364 struct pcmcia_device *p_dev; 360 struct pcmcia_device *p_dev;
365 struct pcmcia_driver *p_drv; 361 struct pcmcia_driver *p_drv;
362 struct pcmcia_socket *s;
366 int ret = 0; 363 int ret = 0;
367 364
368 dev = get_device(dev); 365 dev = get_device(dev);
@@ -371,25 +368,38 @@ static int pcmcia_device_probe(struct device * dev)
371 368
372 p_dev = to_pcmcia_dev(dev); 369 p_dev = to_pcmcia_dev(dev);
373 p_drv = to_pcmcia_drv(dev->driver); 370 p_drv = to_pcmcia_drv(dev->driver);
371 s = p_dev->socket;
374 372
375 if (!try_module_get(p_drv->owner)) { 373 if ((!p_drv->probe) || (!try_module_get(p_drv->owner))) {
376 ret = -EINVAL; 374 ret = -EINVAL;
377 goto put_dev; 375 goto put_dev;
378 } 376 }
379 377
380 if (p_drv->attach) { 378 p_dev->state &= ~CLIENT_UNBOUND;
381 p_dev->instance = p_drv->attach(); 379
382 if ((!p_dev->instance) || (p_dev->state & CLIENT_UNBOUND)) { 380 /* set up the device configuration, if it hasn't been done before */
383 printk(KERN_NOTICE "ds: unable to create instance " 381 if (!s->functions) {
384 "of '%s'!\n", p_drv->drv.name); 382 cistpl_longlink_mfc_t mfc;
385 ret = -EINVAL; 383 if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC,
384 &mfc) == CS_SUCCESS)
385 s->functions = mfc.nfn;
386 else
387 s->functions = 1;
388 s->config = kzalloc(sizeof(config_t) * s->functions,
389 GFP_KERNEL);
390 if (!s->config) {
391 ret = -ENOMEM;
392 goto put_module;
386 } 393 }
387 } 394 }
388 395
396 ret = p_drv->probe(p_dev);
397
398 put_module:
389 if (ret) 399 if (ret)
390 module_put(p_drv->owner); 400 module_put(p_drv->owner);
391 put_dev: 401 put_dev:
392 if ((ret) || !(p_drv->attach)) 402 if (ret)
393 put_device(dev); 403 put_device(dev);
394 return (ret); 404 return (ret);
395} 405}
@@ -399,24 +409,66 @@ static int pcmcia_device_remove(struct device * dev)
399{ 409{
400 struct pcmcia_device *p_dev; 410 struct pcmcia_device *p_dev;
401 struct pcmcia_driver *p_drv; 411 struct pcmcia_driver *p_drv;
412 int i;
402 413
403 /* detach the "instance" */ 414 /* detach the "instance" */
404 p_dev = to_pcmcia_dev(dev); 415 p_dev = to_pcmcia_dev(dev);
405 p_drv = to_pcmcia_drv(dev->driver); 416 p_drv = to_pcmcia_drv(dev->driver);
417 if (!p_drv)
418 return 0;
406 419
407 if (p_drv) { 420 if (p_drv->remove)
408 if ((p_drv->detach) && (p_dev->instance)) { 421 p_drv->remove(p_dev);
409 p_drv->detach(p_dev->instance); 422
410 /* from pcmcia_probe_device */ 423 /* check for proper unloading */
411 put_device(&p_dev->dev); 424 if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED))
412 } 425 printk(KERN_INFO "pcmcia: driver %s did not release config properly\n",
413 module_put(p_drv->owner); 426 p_drv->drv.name);
414 } 427
428 for (i = 0; i < MAX_WIN; i++)
429 if (p_dev->state & CLIENT_WIN_REQ(i))
430 printk(KERN_INFO "pcmcia: driver %s did not release windows properly\n",
431 p_drv->drv.name);
432
433 /* references from pcmcia_probe_device */
434 p_dev->state = CLIENT_UNBOUND;
435 pcmcia_put_dev(p_dev);
436 module_put(p_drv->owner);
415 437
416 return 0; 438 return 0;
417} 439}
418 440
419 441
442/*
443 * Removes a PCMCIA card from the device tree and socket list.
444 */
445static void pcmcia_card_remove(struct pcmcia_socket *s)
446{
447 struct pcmcia_device *p_dev;
448 unsigned long flags;
449
450 ds_dbg(2, "unbind_request(%d)\n", s->sock);
451
452 s->device_count = 0;
453
454 for (;;) {
455 /* unregister all pcmcia_devices registered with this socket*/
456 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
457 if (list_empty(&s->devices_list)) {
458 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
459 return;
460 }
461 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list);
462 list_del(&p_dev->socket_device_list);
463 p_dev->state |= CLIENT_STALE;
464 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
465
466 device_unregister(&p_dev->dev);
467 }
468
469 return;
470} /* unbind_request */
471
420 472
421/* 473/*
422 * pcmcia_device_query -- determine information about a pcmcia device 474 * pcmcia_device_query -- determine information about a pcmcia device
@@ -517,10 +569,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
517 if (s->device_count == 2) 569 if (s->device_count == 2)
518 goto err_put; 570 goto err_put;
519 571
520 p_dev = kmalloc(sizeof(struct pcmcia_device), GFP_KERNEL); 572 p_dev = kzalloc(sizeof(struct pcmcia_device), GFP_KERNEL);
521 if (!p_dev) 573 if (!p_dev)
522 goto err_put; 574 goto err_put;
523 memset(p_dev, 0, sizeof(struct pcmcia_device));
524 575
525 p_dev->socket = s; 576 p_dev->socket = s;
526 p_dev->device_no = (s->device_count++); 577 p_dev->device_no = (s->device_count++);
@@ -583,7 +634,9 @@ static int pcmcia_card_add(struct pcmcia_socket *s)
583 if (!(s->resource_setup_done)) 634 if (!(s->resource_setup_done))
584 return -EAGAIN; /* try again, but later... */ 635 return -EAGAIN; /* try again, but later... */
585 636
586 pcmcia_validate_mem(s); 637 if (pcmcia_validate_mem(s))
638 return -EAGAIN; /* try again, but later... */
639
587 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo); 640 ret = pccard_validate_cis(s, BIND_FN_ALL, &cisinfo);
588 if (ret || !cisinfo.Chains) { 641 if (ret || !cisinfo.Chains) {
589 ds_dbg(0, "invalid CIS or invalid resources\n"); 642 ds_dbg(0, "invalid CIS or invalid resources\n");
@@ -779,8 +832,8 @@ static int pcmcia_bus_match(struct device * dev, struct device_driver * drv) {
779 832
780#ifdef CONFIG_HOTPLUG 833#ifdef CONFIG_HOTPLUG
781 834
782static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, 835static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp,
783 char *buffer, int buffer_size) 836 char *buffer, int buffer_size)
784{ 837{
785 struct pcmcia_device *p_dev; 838 struct pcmcia_device *p_dev;
786 int i, length = 0; 839 int i, length = 0;
@@ -800,31 +853,31 @@ static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp,
800 853
801 i = 0; 854 i = 0;
802 855
803 if (add_hotplug_env_var(envp, num_envp, &i, 856 if (add_uevent_var(envp, num_envp, &i,
804 buffer, buffer_size, &length, 857 buffer, buffer_size, &length,
805 "SOCKET_NO=%u", 858 "SOCKET_NO=%u",
806 p_dev->socket->sock)) 859 p_dev->socket->sock))
807 return -ENOMEM; 860 return -ENOMEM;
808 861
809 if (add_hotplug_env_var(envp, num_envp, &i, 862 if (add_uevent_var(envp, num_envp, &i,
810 buffer, buffer_size, &length, 863 buffer, buffer_size, &length,
811 "DEVICE_NO=%02X", 864 "DEVICE_NO=%02X",
812 p_dev->device_no)) 865 p_dev->device_no))
813 return -ENOMEM; 866 return -ENOMEM;
814 867
815 if (add_hotplug_env_var(envp, num_envp, &i, 868 if (add_uevent_var(envp, num_envp, &i,
816 buffer, buffer_size, &length, 869 buffer, buffer_size, &length,
817 "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X" 870 "MODALIAS=pcmcia:m%04Xc%04Xf%02Xfn%02Xpfn%02X"
818 "pa%08Xpb%08Xpc%08Xpd%08X", 871 "pa%08Xpb%08Xpc%08Xpd%08X",
819 p_dev->has_manf_id ? p_dev->manf_id : 0, 872 p_dev->has_manf_id ? p_dev->manf_id : 0,
820 p_dev->has_card_id ? p_dev->card_id : 0, 873 p_dev->has_card_id ? p_dev->card_id : 0,
821 p_dev->has_func_id ? p_dev->func_id : 0, 874 p_dev->has_func_id ? p_dev->func_id : 0,
822 p_dev->func, 875 p_dev->func,
823 p_dev->device_no, 876 p_dev->device_no,
824 hash[0], 877 hash[0],
825 hash[1], 878 hash[1],
826 hash[2], 879 hash[2],
827 hash[3])) 880 hash[3]))
828 return -ENOMEM; 881 return -ENOMEM;
829 882
830 envp[i] = NULL; 883 envp[i] = NULL;
@@ -834,7 +887,7 @@ static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp,
834 887
835#else 888#else
836 889
837static int pcmcia_bus_hotplug(struct device *dev, char **envp, int num_envp, 890static int pcmcia_bus_uevent(struct device *dev, char **envp, int num_envp,
838 char *buffer, int buffer_size) 891 char *buffer, int buffer_size)
839{ 892{
840 return -ENODEV; 893 return -ENODEV;
@@ -918,55 +971,84 @@ static struct device_attribute pcmcia_dev_attrs[] = {
918 __ATTR_NULL, 971 __ATTR_NULL,
919}; 972};
920 973
974/* PM support, also needed for reset */
921 975
922/*====================================================================== 976static int pcmcia_dev_suspend(struct device * dev, pm_message_t state)
977{
978 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
979 struct pcmcia_driver *p_drv = NULL;
923 980
924 The card status event handler. 981 if (dev->driver)
925 982 p_drv = to_pcmcia_drv(dev->driver);
926======================================================================*/
927 983
928struct send_event_data { 984 if (p_drv && p_drv->suspend)
929 struct pcmcia_socket *skt; 985 return p_drv->suspend(p_dev);
930 event_t event;
931 int priority;
932};
933 986
934static int send_event_callback(struct device *dev, void * _data) 987 return 0;
988}
989
990
991static int pcmcia_dev_resume(struct device * dev)
935{ 992{
936 struct pcmcia_device *p_dev = to_pcmcia_dev(dev); 993 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
937 struct pcmcia_driver *p_drv; 994 struct pcmcia_driver *p_drv = NULL;
938 struct send_event_data *data = _data;
939 995
940 /* we get called for all sockets, but may only pass the event 996 if (dev->driver)
941 * for drivers _on the affected socket_ */ 997 p_drv = to_pcmcia_drv(dev->driver);
942 if (p_dev->socket != data->skt)
943 return 0;
944 998
945 p_drv = to_pcmcia_drv(p_dev->dev.driver); 999 if (p_drv && p_drv->resume)
946 if (!p_drv) 1000 return p_drv->resume(p_dev);
1001
1002 return 0;
1003}
1004
1005
1006static int pcmcia_bus_suspend_callback(struct device *dev, void * _data)
1007{
1008 struct pcmcia_socket *skt = _data;
1009 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1010
1011 if (p_dev->socket != skt)
947 return 0; 1012 return 0;
948 1013
949 if (p_dev->state & (CLIENT_UNBOUND|CLIENT_STALE)) 1014 return dpm_runtime_suspend(dev, PMSG_SUSPEND);
1015}
1016
1017static int pcmcia_bus_resume_callback(struct device *dev, void * _data)
1018{
1019 struct pcmcia_socket *skt = _data;
1020 struct pcmcia_device *p_dev = to_pcmcia_dev(dev);
1021
1022 if (p_dev->socket != skt)
950 return 0; 1023 return 0;
951 1024
952 if (p_drv->event) 1025 dpm_runtime_resume(dev);
953 return p_drv->event(data->event, data->priority, 1026
954 &p_dev->event_callback_args); 1027 return 0;
1028}
955 1029
1030static int pcmcia_bus_resume(struct pcmcia_socket *skt)
1031{
1032 bus_for_each_dev(&pcmcia_bus_type, NULL, skt, pcmcia_bus_resume_callback);
956 return 0; 1033 return 0;
957} 1034}
958 1035
959static int send_event(struct pcmcia_socket *s, event_t event, int priority) 1036static int pcmcia_bus_suspend(struct pcmcia_socket *skt)
960{ 1037{
961 struct send_event_data private; 1038 if (bus_for_each_dev(&pcmcia_bus_type, NULL, skt,
1039 pcmcia_bus_suspend_callback)) {
1040 pcmcia_bus_resume(skt);
1041 return -EIO;
1042 }
1043 return 0;
1044}
962 1045
963 private.skt = s;
964 private.event = event;
965 private.priority = priority;
966 1046
967 return bus_for_each_dev(&pcmcia_bus_type, NULL, &private, send_event_callback); 1047/*======================================================================
968} /* send_event */
969 1048
1049 The card status event handler.
1050
1051======================================================================*/
970 1052
971/* Normally, the event is passed to individual drivers after 1053/* Normally, the event is passed to individual drivers after
972 * informing userspace. Only for CS_EVENT_CARD_REMOVAL this 1054 * informing userspace. Only for CS_EVENT_CARD_REMOVAL this
@@ -976,20 +1058,17 @@ static int send_event(struct pcmcia_socket *s, event_t event, int priority)
976static int ds_event(struct pcmcia_socket *skt, event_t event, int priority) 1058static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
977{ 1059{
978 struct pcmcia_socket *s = pcmcia_get_socket(skt); 1060 struct pcmcia_socket *s = pcmcia_get_socket(skt);
979 int ret = 0;
980 1061
981 ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n", 1062 ds_dbg(1, "ds_event(0x%06x, %d, 0x%p)\n",
982 event, priority, skt); 1063 event, priority, skt);
983
984 switch (event) {
985 1064
1065 switch (event) {
986 case CS_EVENT_CARD_REMOVAL: 1066 case CS_EVENT_CARD_REMOVAL:
987 s->pcmcia_state.present = 0; 1067 s->pcmcia_state.present = 0;
988 send_event(skt, event, priority); 1068 pcmcia_card_remove(skt);
989 unbind_request(skt);
990 handle_event(skt, event); 1069 handle_event(skt, event);
991 break; 1070 break;
992 1071
993 case CS_EVENT_CARD_INSERTION: 1072 case CS_EVENT_CARD_INSERTION:
994 s->pcmcia_state.present = 1; 1073 s->pcmcia_state.present = 1;
995 pcmcia_card_add(skt); 1074 pcmcia_card_add(skt);
@@ -997,12 +1076,14 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
997 break; 1076 break;
998 1077
999 case CS_EVENT_EJECTION_REQUEST: 1078 case CS_EVENT_EJECTION_REQUEST:
1000 ret = send_event(skt, event, priority);
1001 break; 1079 break;
1002 1080
1081 case CS_EVENT_PM_SUSPEND:
1082 case CS_EVENT_PM_RESUME:
1083 case CS_EVENT_RESET_PHYSICAL:
1084 case CS_EVENT_CARD_RESET:
1003 default: 1085 default:
1004 handle_event(skt, event); 1086 handle_event(skt, event);
1005 send_event(skt, event, priority);
1006 break; 1087 break;
1007 } 1088 }
1008 1089
@@ -1012,152 +1093,12 @@ static int ds_event(struct pcmcia_socket *skt, event_t event, int priority)
1012} /* ds_event */ 1093} /* ds_event */
1013 1094
1014 1095
1015
1016int pcmcia_register_client(struct pcmcia_device **handle, client_reg_t *req)
1017{
1018 struct pcmcia_socket *s = NULL;
1019 struct pcmcia_device *p_dev = NULL;
1020 struct pcmcia_driver *p_drv = NULL;
1021
1022 /* Look for unbound client with matching dev_info */
1023 down_read(&pcmcia_socket_list_rwsem);
1024 list_for_each_entry(s, &pcmcia_socket_list, socket_list) {
1025 unsigned long flags;
1026
1027 if (s->state & SOCKET_CARDBUS)
1028 continue;
1029
1030 s = pcmcia_get_socket(s);
1031 if (!s)
1032 continue;
1033 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
1034 list_for_each_entry(p_dev, &s->devices_list, socket_device_list) {
1035 p_dev = pcmcia_get_dev(p_dev);
1036 if (!p_dev)
1037 continue;
1038 if (!(p_dev->state & CLIENT_UNBOUND) ||
1039 (!p_dev->dev.driver)) {
1040 pcmcia_put_dev(p_dev);
1041 continue;
1042 }
1043 p_drv = to_pcmcia_drv(p_dev->dev.driver);
1044 if (!strncmp(p_drv->drv.name, (char *)req->dev_info, DEV_NAME_LEN)) {
1045 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1046 goto found;
1047 }
1048 pcmcia_put_dev(p_dev);
1049 }
1050 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1051 pcmcia_put_socket(s);
1052 }
1053 found:
1054 up_read(&pcmcia_socket_list_rwsem);
1055 if (!p_dev)
1056 return -ENODEV;
1057
1058 pcmcia_put_socket(s); /* safe, as we already hold a reference from bind_device */
1059
1060 *handle = p_dev;
1061 p_dev->state &= ~CLIENT_UNBOUND;
1062 p_dev->event_callback_args = req->event_callback_args;
1063 p_dev->event_callback_args.client_handle = p_dev;
1064
1065
1066 if (!s->functions) {
1067 cistpl_longlink_mfc_t mfc;
1068 if (pccard_read_tuple(s, p_dev->func, CISTPL_LONGLINK_MFC, &mfc)
1069 == CS_SUCCESS)
1070 s->functions = mfc.nfn;
1071 else
1072 s->functions = 1;
1073 s->config = kmalloc(sizeof(config_t) * s->functions,
1074 GFP_KERNEL);
1075 if (!s->config)
1076 goto out_no_resource;
1077 memset(s->config, 0, sizeof(config_t) * s->functions);
1078 }
1079
1080 ds_dbg(1, "register_client(): client 0x%p, dev %s\n",
1081 p_dev, p_dev->dev.bus_id);
1082
1083 if ((s->state & (SOCKET_PRESENT|SOCKET_CARDBUS)) == SOCKET_PRESENT) {
1084 if (p_drv->event)
1085 p_drv->event(CS_EVENT_CARD_INSERTION, CS_EVENT_PRI_LOW,
1086 &p_dev->event_callback_args);
1087
1088 }
1089
1090 return CS_SUCCESS;
1091
1092 out_no_resource:
1093 pcmcia_put_dev(p_dev);
1094 return CS_OUT_OF_RESOURCE;
1095} /* register_client */
1096EXPORT_SYMBOL(pcmcia_register_client);
1097
1098
1099/* unbind _all_ devices attached to a given pcmcia_bus_socket. The
1100 * drivers have been called with EVENT_CARD_REMOVAL before.
1101 */
1102static int unbind_request(struct pcmcia_socket *s)
1103{
1104 struct pcmcia_device *p_dev;
1105 unsigned long flags;
1106
1107 ds_dbg(2, "unbind_request(%d)\n", s->sock);
1108
1109 s->device_count = 0;
1110
1111 for (;;) {
1112 /* unregister all pcmcia_devices registered with this socket*/
1113 spin_lock_irqsave(&pcmcia_dev_list_lock, flags);
1114 if (list_empty(&s->devices_list)) {
1115 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1116 return 0;
1117 }
1118 p_dev = list_entry((&s->devices_list)->next, struct pcmcia_device, socket_device_list);
1119 list_del(&p_dev->socket_device_list);
1120 p_dev->state |= CLIENT_STALE;
1121 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
1122
1123 device_unregister(&p_dev->dev);
1124 }
1125
1126 return 0;
1127} /* unbind_request */
1128
1129int pcmcia_deregister_client(struct pcmcia_device *p_dev)
1130{
1131 struct pcmcia_socket *s;
1132 int i;
1133
1134 s = p_dev->socket;
1135 ds_dbg(1, "deregister_client(%p)\n", p_dev);
1136
1137 if (p_dev->state & (CLIENT_IRQ_REQ|CLIENT_IO_REQ|CLIENT_CONFIG_LOCKED))
1138 goto warn_out;
1139 for (i = 0; i < MAX_WIN; i++)
1140 if (p_dev->state & CLIENT_WIN_REQ(i))
1141 goto warn_out;
1142
1143 if (p_dev->state & CLIENT_STALE) {
1144 p_dev->state &= ~CLIENT_STALE;
1145 pcmcia_put_dev(p_dev);
1146 } else {
1147 p_dev->state = CLIENT_UNBOUND;
1148 }
1149
1150 return CS_SUCCESS;
1151 warn_out:
1152 printk(KERN_WARNING "ds: deregister_client was called too early.\n");
1153 return CS_IN_USE;
1154} /* deregister_client */
1155EXPORT_SYMBOL(pcmcia_deregister_client);
1156
1157static struct pcmcia_callback pcmcia_bus_callback = { 1096static struct pcmcia_callback pcmcia_bus_callback = {
1158 .owner = THIS_MODULE, 1097 .owner = THIS_MODULE,
1159 .event = ds_event, 1098 .event = ds_event,
1160 .requery = pcmcia_bus_rescan, 1099 .requery = pcmcia_bus_rescan,
1100 .suspend = pcmcia_bus_suspend,
1101 .resume = pcmcia_bus_resume,
1161}; 1102};
1162 1103
1163static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev, 1104static int __devinit pcmcia_bus_add_socket(struct class_device *class_dev,
@@ -1223,9 +1164,11 @@ static struct class_interface pcmcia_bus_interface = {
1223 1164
1224struct bus_type pcmcia_bus_type = { 1165struct bus_type pcmcia_bus_type = {
1225 .name = "pcmcia", 1166 .name = "pcmcia",
1226 .hotplug = pcmcia_bus_hotplug, 1167 .uevent = pcmcia_bus_uevent,
1227 .match = pcmcia_bus_match, 1168 .match = pcmcia_bus_match,
1228 .dev_attrs = pcmcia_dev_attrs, 1169 .dev_attrs = pcmcia_dev_attrs,
1170 .suspend = pcmcia_dev_suspend,
1171 .resume = pcmcia_dev_resume,
1229}; 1172};
1230 1173
1231 1174
diff --git a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
index 561706ba4499..b39435bbfaeb 100644
--- a/drivers/pcmcia/hd64465_ss.c
+++ b/drivers/pcmcia/hd64465_ss.c
@@ -417,18 +417,6 @@ static int hs_get_status(struct pcmcia_socket *s, u_int *value)
417 417
418/*============================================================*/ 418/*============================================================*/
419 419
420static int hs_get_socket(struct pcmcia_socket *s, socket_state_t *state)
421{
422 hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
423
424 DPRINTK("hs_get_socket(%d)\n", sock);
425
426 *state = sp->state;
427 return 0;
428}
429
430/*============================================================*/
431
432static int hs_set_socket(struct pcmcia_socket *s, socket_state_t *state) 420static int hs_set_socket(struct pcmcia_socket *s, socket_state_t *state)
433{ 421{
434 hs_socket_t *sp = container_of(s, struct hs_socket_t, socket); 422 hs_socket_t *sp = container_of(s, struct hs_socket_t, socket);
@@ -749,7 +737,6 @@ static irqreturn_t hs_interrupt(int irq, void *dev, struct pt_regs *regs)
749static struct pccard_operations hs_operations = { 737static struct pccard_operations hs_operations = {
750 .init = hs_init, 738 .init = hs_init,
751 .get_status = hs_get_status, 739 .get_status = hs_get_status,
752 .get_socket = hs_get_socket,
753 .set_socket = hs_set_socket, 740 .set_socket = hs_set_socket,
754 .set_io_map = hs_set_io_map, 741 .set_io_map = hs_set_io_map,
755 .set_mem_map = hs_set_mem_map, 742 .set_mem_map = hs_set_mem_map,
diff --git a/drivers/pcmcia/i82092.c b/drivers/pcmcia/i82092.c
index f3fdc748659d..7979c85df3dc 100644
--- a/drivers/pcmcia/i82092.c
+++ b/drivers/pcmcia/i82092.c
@@ -66,7 +66,6 @@ static struct pci_driver i82092aa_pci_drv = {
66static struct pccard_operations i82092aa_operations = { 66static struct pccard_operations i82092aa_operations = {
67 .init = i82092aa_init, 67 .init = i82092aa_init,
68 .get_status = i82092aa_get_status, 68 .get_status = i82092aa_get_status,
69 .get_socket = i82092aa_get_socket,
70 .set_socket = i82092aa_set_socket, 69 .set_socket = i82092aa_set_socket,
71 .set_io_map = i82092aa_set_io_map, 70 .set_io_map = i82092aa_set_io_map,
72 .set_mem_map = i82092aa_set_mem_map, 71 .set_mem_map = i82092aa_set_mem_map,
@@ -482,78 +481,6 @@ static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value)
482} 481}
483 482
484 483
485static int i82092aa_get_socket(struct pcmcia_socket *socket, socket_state_t *state)
486{
487 unsigned int sock = container_of(socket, struct socket_info, socket)->number;
488 unsigned char reg,vcc,vpp;
489
490 enter("i82092aa_get_socket");
491 state->flags = 0;
492 state->Vcc = 0;
493 state->Vpp = 0;
494 state->io_irq = 0;
495 state->csc_mask = 0;
496
497 /* First the power status of the socket */
498 reg = indirect_read(sock,I365_POWER); /* PCTRL - Power Control Register */
499
500 if (reg & I365_PWR_AUTO)
501 state->flags |= SS_PWR_AUTO; /* Automatic Power Switch */
502
503 if (reg & I365_PWR_OUT)
504 state->flags |= SS_OUTPUT_ENA; /* Output signals are enabled */
505
506 vcc = reg & I365_VCC_MASK; vpp = reg & I365_VPP1_MASK;
507
508 if (reg & I365_VCC_5V) { /* Can still be 3.3V, in this case the Vcc value will be overwritten later */
509 state->Vcc = 50;
510
511 if (vpp == I365_VPP1_5V)
512 state->Vpp = 50;
513 if (vpp == I365_VPP1_12V)
514 state->Vpp = 120;
515
516 }
517
518 if ((reg & I365_VCC_3V)==I365_VCC_3V)
519 state->Vcc = 33;
520
521
522 /* Now the IO card, RESET flags and IO interrupt */
523
524 reg = indirect_read(sock, I365_INTCTL); /* IGENC, Interrupt and General Control */
525
526 if ((reg & I365_PC_RESET)==0)
527 state->flags |= SS_RESET;
528 if (reg & I365_PC_IOCARD)
529 state->flags |= SS_IOCARD; /* This is an IO card */
530
531 /* Set the IRQ number */
532 if (sockets[sock].dev!=NULL)
533 state->io_irq = sockets[sock].dev->irq;
534
535 /* Card status change */
536 reg = indirect_read(sock, I365_CSCINT); /* CSCICR, Card Status Change Interrupt Configuration */
537
538 if (reg & I365_CSC_DETECT)
539 state->csc_mask |= SS_DETECT; /* Card detect is enabled */
540
541 if (state->flags & SS_IOCARD) {/* IO Cards behave different */
542 if (reg & I365_CSC_STSCHG)
543 state->csc_mask |= SS_STSCHG;
544 } else {
545 if (reg & I365_CSC_BVD1)
546 state->csc_mask |= SS_BATDEAD;
547 if (reg & I365_CSC_BVD2)
548 state->csc_mask |= SS_BATWARN;
549 if (reg & I365_CSC_READY)
550 state->csc_mask |= SS_READY;
551 }
552
553 leave("i82092aa_get_socket");
554 return 0;
555}
556
557static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *state) 484static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *state)
558{ 485{
559 unsigned int sock = container_of(socket, struct socket_info, socket)->number; 486 unsigned int sock = container_of(socket, struct socket_info, socket)->number;
diff --git a/drivers/pcmcia/i82092aa.h b/drivers/pcmcia/i82092aa.h
index b98cac7bda9f..9c14599d0673 100644
--- a/drivers/pcmcia/i82092aa.h
+++ b/drivers/pcmcia/i82092aa.h
@@ -29,7 +29,6 @@ static irqreturn_t i82092aa_interrupt(int irq, void *dev, struct pt_regs *regs);
29 29
30 30
31static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value); 31static int i82092aa_get_status(struct pcmcia_socket *socket, u_int *value);
32static int i82092aa_get_socket(struct pcmcia_socket *socket, socket_state_t *state);
33static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *state); 32static int i82092aa_set_socket(struct pcmcia_socket *socket, socket_state_t *state);
34static int i82092aa_set_io_map(struct pcmcia_socket *socket, struct pccard_io_map *io); 33static int i82092aa_set_io_map(struct pcmcia_socket *socket, struct pccard_io_map *io);
35static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_map *mem); 34static int i82092aa_set_mem_map(struct pcmcia_socket *socket, struct pccard_mem_map *mem);
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index 4d56bc9926d6..35a92d1e4945 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -940,78 +940,6 @@ static int i365_get_status(u_short sock, u_int *value)
940 940
941/*====================================================================*/ 941/*====================================================================*/
942 942
943static int i365_get_socket(u_short sock, socket_state_t *state)
944{
945 struct i82365_socket *t = &socket[sock];
946 u_char reg, vcc, vpp;
947
948 reg = i365_get(sock, I365_POWER);
949 state->flags = (reg & I365_PWR_AUTO) ? SS_PWR_AUTO : 0;
950 state->flags |= (reg & I365_PWR_OUT) ? SS_OUTPUT_ENA : 0;
951 vcc = reg & I365_VCC_MASK; vpp = reg & I365_VPP1_MASK;
952 state->Vcc = state->Vpp = 0;
953 if (t->flags & IS_CIRRUS) {
954 if (i365_get(sock, PD67_MISC_CTL_1) & PD67_MC1_VCC_3V) {
955 if (reg & I365_VCC_5V) state->Vcc = 33;
956 if (vpp == I365_VPP1_5V) state->Vpp = 33;
957 } else {
958 if (reg & I365_VCC_5V) state->Vcc = 50;
959 if (vpp == I365_VPP1_5V) state->Vpp = 50;
960 }
961 if (vpp == I365_VPP1_12V) state->Vpp = 120;
962 } else if (t->flags & IS_VG_PWR) {
963 if (i365_get(sock, VG469_VSELECT) & VG469_VSEL_VCC) {
964 if (reg & I365_VCC_5V) state->Vcc = 33;
965 if (vpp == I365_VPP1_5V) state->Vpp = 33;
966 } else {
967 if (reg & I365_VCC_5V) state->Vcc = 50;
968 if (vpp == I365_VPP1_5V) state->Vpp = 50;
969 }
970 if (vpp == I365_VPP1_12V) state->Vpp = 120;
971 } else if (t->flags & IS_DF_PWR) {
972 if (vcc == I365_VCC_3V) state->Vcc = 33;
973 if (vcc == I365_VCC_5V) state->Vcc = 50;
974 if (vpp == I365_VPP1_5V) state->Vpp = 50;
975 if (vpp == I365_VPP1_12V) state->Vpp = 120;
976 } else {
977 if (reg & I365_VCC_5V) {
978 state->Vcc = 50;
979 if (vpp == I365_VPP1_5V) state->Vpp = 50;
980 if (vpp == I365_VPP1_12V) state->Vpp = 120;
981 }
982 }
983
984 /* IO card, RESET flags, IO interrupt */
985 reg = i365_get(sock, I365_INTCTL);
986 state->flags |= (reg & I365_PC_RESET) ? 0 : SS_RESET;
987 if (reg & I365_PC_IOCARD) state->flags |= SS_IOCARD;
988 state->io_irq = reg & I365_IRQ_MASK;
989
990 /* speaker control */
991 if (t->flags & IS_CIRRUS) {
992 if (i365_get(sock, PD67_MISC_CTL_1) & PD67_MC1_SPKR_ENA)
993 state->flags |= SS_SPKR_ENA;
994 }
995
996 /* Card status change mask */
997 reg = i365_get(sock, I365_CSCINT);
998 state->csc_mask = (reg & I365_CSC_DETECT) ? SS_DETECT : 0;
999 if (state->flags & SS_IOCARD)
1000 state->csc_mask |= (reg & I365_CSC_STSCHG) ? SS_STSCHG : 0;
1001 else {
1002 state->csc_mask |= (reg & I365_CSC_BVD1) ? SS_BATDEAD : 0;
1003 state->csc_mask |= (reg & I365_CSC_BVD2) ? SS_BATWARN : 0;
1004 state->csc_mask |= (reg & I365_CSC_READY) ? SS_READY : 0;
1005 }
1006
1007 debug(1, "GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
1008 "io_irq %d, csc_mask %#2.2x\n", sock, state->flags,
1009 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
1010 return 0;
1011} /* i365_get_socket */
1012
1013/*====================================================================*/
1014
1015static int i365_set_socket(u_short sock, socket_state_t *state) 943static int i365_set_socket(u_short sock, socket_state_t *state)
1016{ 944{
1017 struct i82365_socket *t = &socket[sock]; 945 struct i82365_socket *t = &socket[sock];
@@ -1265,16 +1193,6 @@ static int pcic_get_status(struct pcmcia_socket *s, u_int *value)
1265 LOCKED(i365_get_status(sock, value)); 1193 LOCKED(i365_get_status(sock, value));
1266} 1194}
1267 1195
1268static int pcic_get_socket(struct pcmcia_socket *s, socket_state_t *state)
1269{
1270 unsigned int sock = container_of(s, struct i82365_socket, socket)->number;
1271
1272 if (socket[sock].flags & IS_ALIVE)
1273 return -EINVAL;
1274
1275 LOCKED(i365_get_socket(sock, state));
1276}
1277
1278static int pcic_set_socket(struct pcmcia_socket *s, socket_state_t *state) 1196static int pcic_set_socket(struct pcmcia_socket *s, socket_state_t *state)
1279{ 1197{
1280 unsigned int sock = container_of(s, struct i82365_socket, socket)->number; 1198 unsigned int sock = container_of(s, struct i82365_socket, socket)->number;
@@ -1324,7 +1242,6 @@ static int pcic_init(struct pcmcia_socket *s)
1324static struct pccard_operations pcic_operations = { 1242static struct pccard_operations pcic_operations = {
1325 .init = pcic_init, 1243 .init = pcic_init,
1326 .get_status = pcic_get_status, 1244 .get_status = pcic_get_status,
1327 .get_socket = pcic_get_socket,
1328 .set_socket = pcic_set_socket, 1245 .set_socket = pcic_set_socket,
1329 .set_io_map = pcic_set_io_map, 1246 .set_io_map = pcic_set_io_map,
1330 .set_mem_map = pcic_set_mem_map, 1247 .set_mem_map = pcic_set_mem_map,
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 078579ae6359..071cf485e1a3 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -480,25 +480,6 @@ static int _pcc_get_status(u_short sock, u_int *value)
480 480
481/*====================================================================*/ 481/*====================================================================*/
482 482
483static int _pcc_get_socket(u_short sock, socket_state_t *state)
484{
485// pcc_socket_t *t = &socket[sock];
486
487 state->flags = 0;
488 state->csc_mask = SS_DETECT;
489 state->csc_mask |= SS_READY;
490 state->io_irq = 0;
491 state->Vcc = 33; /* 3.3V fixed */
492 state->Vpp = 33;
493
494 debug(3, "m32r_cfc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
495 "io_irq %d, csc_mask %#2.2x\n", sock, state->flags,
496 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
497 return 0;
498} /* _get_socket */
499
500/*====================================================================*/
501
502static int _pcc_set_socket(u_short sock, socket_state_t *state) 483static int _pcc_set_socket(u_short sock, socket_state_t *state)
503{ 484{
504 debug(3, "m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, " 485 debug(3, "m32r_cfc: SetSocket(%d, flags %#3.3x, Vcc %d, Vpp %d, "
@@ -667,18 +648,6 @@ static int pcc_get_status(struct pcmcia_socket *s, u_int *value)
667 LOCKED(_pcc_get_status(sock, value)); 648 LOCKED(_pcc_get_status(sock, value));
668} 649}
669 650
670static int pcc_get_socket(struct pcmcia_socket *s, socket_state_t *state)
671{
672 unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
673
674 if (socket[sock].flags & IS_ALIVE) {
675 debug(3, "m32r_cfc: pcc_get_socket: sock(%d) -EINVAL\n", sock);
676 return -EINVAL;
677 }
678 debug(3, "m32r_cfc: pcc_get_socket: sock(%d)\n", sock);
679 LOCKED(_pcc_get_socket(sock, state));
680}
681
682static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state) 651static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state)
683{ 652{
684 unsigned int sock = container_of(s, struct pcc_socket, socket)->number; 653 unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
@@ -724,7 +693,6 @@ static int pcc_init(struct pcmcia_socket *s)
724static struct pccard_operations pcc_operations = { 693static struct pccard_operations pcc_operations = {
725 .init = pcc_init, 694 .init = pcc_init,
726 .get_status = pcc_get_status, 695 .get_status = pcc_get_status,
727 .get_socket = pcc_get_socket,
728 .set_socket = pcc_set_socket, 696 .set_socket = pcc_set_socket,
729 .set_io_map = pcc_set_io_map, 697 .set_io_map = pcc_set_io_map,
730 .set_mem_map = pcc_set_mem_map, 698 .set_mem_map = pcc_set_mem_map,
diff --git a/drivers/pcmcia/m32r_pcc.c b/drivers/pcmcia/m32r_pcc.c
index 356a6fb416a1..70d5f0748d55 100644
--- a/drivers/pcmcia/m32r_pcc.c
+++ b/drivers/pcmcia/m32r_pcc.c
@@ -429,16 +429,6 @@ static int _pcc_get_status(u_short sock, u_int *value)
429 429
430/*====================================================================*/ 430/*====================================================================*/
431 431
432static int _pcc_get_socket(u_short sock, socket_state_t *state)
433{
434 debug(3, "m32r-pcc: GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
435 "io_irq %d, csc_mask %#2.2x\n", sock, state->flags,
436 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
437 return 0;
438} /* _get_socket */
439
440/*====================================================================*/
441
442static int _pcc_set_socket(u_short sock, socket_state_t *state) 432static int _pcc_set_socket(u_short sock, socket_state_t *state)
443{ 433{
444 u_long reg = 0; 434 u_long reg = 0;
@@ -641,15 +631,6 @@ static int pcc_get_status(struct pcmcia_socket *s, u_int *value)
641 LOCKED(_pcc_get_status(sock, value)); 631 LOCKED(_pcc_get_status(sock, value));
642} 632}
643 633
644static int pcc_get_socket(struct pcmcia_socket *s, socket_state_t *state)
645{
646 unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
647
648 if (socket[sock].flags & IS_ALIVE)
649 return -EINVAL;
650 LOCKED(_pcc_get_socket(sock, state));
651}
652
653static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state) 634static int pcc_set_socket(struct pcmcia_socket *s, socket_state_t *state)
654{ 635{
655 unsigned int sock = container_of(s, struct pcc_socket, socket)->number; 636 unsigned int sock = container_of(s, struct pcc_socket, socket)->number;
@@ -687,7 +668,6 @@ static int pcc_init(struct pcmcia_socket *s)
687static struct pccard_operations pcc_operations = { 668static struct pccard_operations pcc_operations = {
688 .init = pcc_init, 669 .init = pcc_init,
689 .get_status = pcc_get_status, 670 .get_status = pcc_get_status,
690 .get_socket = pcc_get_socket,
691 .set_socket = pcc_set_socket, 671 .set_socket = pcc_set_socket,
692 .set_io_map = pcc_set_io_map, 672 .set_io_map = pcc_set_io_map,
693 .set_mem_map = pcc_set_mem_map, 673 .set_mem_map = pcc_set_mem_map,
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index 6d9f71cfcb34..0e07d9535116 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -9,6 +9,9 @@
9 * <oliver.kurth@cyclades.de> 9 * <oliver.kurth@cyclades.de>
10 * Further fixes, v2.6 kernel port 10 * Further fixes, v2.6 kernel port
11 * <marcelo.tosatti@cyclades.com> 11 * <marcelo.tosatti@cyclades.com>
12 *
13 * Some fixes, additions (C) 2005 Montavista Software, Inc.
14 * <vbordug@ru.mvista.com>
12 * 15 *
13 * "The ExCA standard specifies that socket controllers should provide 16 * "The ExCA standard specifies that socket controllers should provide
14 * two IO and five memory windows per socket, which can be independently 17 * two IO and five memory windows per socket, which can be independently
@@ -97,6 +100,11 @@ MODULE_LICENSE("Dual MPL/GPL");
97#endif 100#endif
98#endif 101#endif
99 102
103#if defined(CONFIG_MPC885ADS)
104#define CONFIG_PCMCIA_SLOT_A
105#define PCMCIA_GLITCHY_CD
106#endif
107
100/* Cyclades ACS uses both slots */ 108/* Cyclades ACS uses both slots */
101#ifdef CONFIG_PRxK 109#ifdef CONFIG_PRxK
102#define CONFIG_PCMCIA_SLOT_A 110#define CONFIG_PCMCIA_SLOT_A
@@ -374,10 +382,10 @@ static int voltage_set(int slot, int vcc, int vpp)
374 } 382 }
375 383
376 /* first, turn off all power */ 384 /* first, turn off all power */
377 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) & ~(BCSR1_PCCVCC_MASK | BCSR1_PCCVPP_MASK)); 385 out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) & ~(BCSR1_PCCVCC_MASK | BCSR1_PCCVPP_MASK));
378 386
379 /* enable new powersettings */ 387 /* enable new powersettings */
380 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) | reg); 388 out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) | reg);
381 389
382 return 0; 390 return 0;
383} 391}
@@ -386,12 +394,89 @@ static int voltage_set(int slot, int vcc, int vpp)
386 394
387static void hardware_enable(int slot) 395static void hardware_enable(int slot)
388{ 396{
389 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) & ~BCSR1_PCCEN); 397 out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) & ~BCSR1_PCCEN);
390} 398}
391 399
392static void hardware_disable(int slot) 400static void hardware_disable(int slot)
393{ 401{
394 out_be32(&((u32 *)BCSR1), in_be32(&((u32 *)BCSR1)) | BCSR1_PCCEN); 402 out_be32((u32 *)BCSR1, in_be32((u32 *)BCSR1) | BCSR1_PCCEN);
403}
404
405#endif
406
407/* MPC885ADS Boards */
408
409#if defined(CONFIG_MPC885ADS)
410
411#define PCMCIA_BOARD_MSG "MPC885ADS"
412
413static int voltage_set(int slot, int vcc, int vpp)
414{
415 u32 reg = 0;
416 unsigned *bcsr_io;
417
418 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
419
420 switch(vcc) {
421 case 0:
422 break;
423 case 33:
424 reg |= BCSR1_PCCVCC0;
425 break;
426 case 50:
427 reg |= BCSR1_PCCVCC1;
428 break;
429 default:
430 return 1;
431 }
432
433 switch(vpp) {
434 case 0:
435 break;
436 case 33:
437 case 50:
438 if(vcc == vpp)
439 reg |= BCSR1_PCCVPP1;
440 else
441 return 1;
442 break;
443 case 120:
444 if ((vcc == 33) || (vcc == 50))
445 reg |= BCSR1_PCCVPP0;
446 else
447 return 1;
448 default:
449 return 1;
450 }
451
452 /* first, turn off all power */
453 out_be32(bcsr_io, in_be32(bcsr_io) & ~(BCSR1_PCCVCC_MASK | BCSR1_PCCVPP_MASK));
454
455 /* enable new powersettings */
456 out_be32(bcsr_io, in_be32(bcsr_io) | reg);
457
458 iounmap(bcsr_io);
459 return 0;
460}
461
462#define socket_get(_slot_) PCMCIA_SOCKET_KEY_5V
463
464static void hardware_enable(int slot)
465{
466 unsigned *bcsr_io;
467
468 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
469 out_be32(bcsr_io, in_be32(bcsr_io) & ~BCSR1_PCCEN);
470 iounmap(bcsr_io);
471}
472
473static void hardware_disable(int slot)
474{
475 unsigned *bcsr_io;
476
477 bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
478 out_be32(bcsr_io, in_be32(bcsr_io) | BCSR1_PCCEN);
479 iounmap(bcsr_io);
395} 480}
396 481
397#endif 482#endif
@@ -440,10 +525,10 @@ static int voltage_set(int slot, int vcc, int vpp)
440 } 525 }
441 526
442 /* first, turn off all power */ 527 /* first, turn off all power */
443 out_8(&((u8 *)MBX_CSR2_ADDR), in_8(&((u8 *)MBX_CSR2_ADDR)) & ~(CSR2_VCC_MASK | CSR2_VPP_MASK)); 528 out_8((u8 *)MBX_CSR2_ADDR, in_8((u8 *)MBX_CSR2_ADDR) & ~(CSR2_VCC_MASK | CSR2_VPP_MASK));
444 529
445 /* enable new powersettings */ 530 /* enable new powersettings */
446 out_8(&((u8 *)MBX_CSR2_ADDR), in_8(&((u8 *)MBX_CSR2_ADDR)) | reg); 531 out_8((u8 *)MBX_CSR2_ADDR, in_8((u8 *)MBX_CSR2_ADDR) | reg);
447 532
448 return 0; 533 return 0;
449} 534}
@@ -823,17 +908,6 @@ static int m8xx_get_status(struct pcmcia_socket *sock, unsigned int *value)
823 return 0; 908 return 0;
824} 909}
825 910
826static int m8xx_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
827{
828 int lsock = container_of(sock, struct socket_info, socket)->slot;
829 *state = socket[lsock].state; /* copy the whole structure */
830
831 dprintk("GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
832 "io_irq %d, csc_mask %#2.2x\n", lsock, state->flags,
833 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
834 return 0;
835}
836
837static int m8xx_set_socket(struct pcmcia_socket *sock, socket_state_t *state) 911static int m8xx_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
838{ 912{
839 int lsock = container_of(sock, struct socket_info, socket)->slot; 913 int lsock = container_of(sock, struct socket_info, socket)->slot;
@@ -1023,8 +1097,7 @@ static int m8xx_set_io_map(struct pcmcia_socket *sock, struct pccard_io_map *io)
1023 if(io->flags & MAP_WRPROT) 1097 if(io->flags & MAP_WRPROT)
1024 reg |= M8XX_PCMCIA_POR_WRPROT; 1098 reg |= M8XX_PCMCIA_POR_WRPROT;
1025 1099
1026 /*if(io->flags & (MAP_16BIT | MAP_AUTOSZ))*/ 1100 if(io->flags & (MAP_16BIT | MAP_AUTOSZ))
1027 if(io->flags & MAP_16BIT)
1028 reg |= M8XX_PCMCIA_POR_16BIT; 1101 reg |= M8XX_PCMCIA_POR_16BIT;
1029 1102
1030 if(io->flags & MAP_ACTIVE) 1103 if(io->flags & MAP_ACTIVE)
@@ -1169,7 +1242,6 @@ static struct pccard_operations m8xx_services = {
1169 .init = m8xx_sock_init, 1242 .init = m8xx_sock_init,
1170 .suspend = m8xx_suspend, 1243 .suspend = m8xx_suspend,
1171 .get_status = m8xx_get_status, 1244 .get_status = m8xx_get_status,
1172 .get_socket = m8xx_get_socket,
1173 .set_socket = m8xx_set_socket, 1245 .set_socket = m8xx_set_socket,
1174 .set_io_map = m8xx_set_io_map, 1246 .set_io_map = m8xx_set_io_map,
1175 .set_mem_map = m8xx_set_mem_map, 1247 .set_mem_map = m8xx_set_mem_map,
@@ -1244,7 +1316,7 @@ static int __init m8xx_init(void)
1244 socket[i].socket.io_offset = 0; 1316 socket[i].socket.io_offset = 0;
1245 socket[i].socket.pci_irq = i ? 7 : 9; 1317 socket[i].socket.pci_irq = i ? 7 : 9;
1246 socket[i].socket.ops = &m8xx_services; 1318 socket[i].socket.ops = &m8xx_services;
1247 socket[i].socket.resource_ops = &pccard_nonstatic_ops; 1319 socket[i].socket.resource_ops = &pccard_iodyn_ops;
1248 socket[i].socket.cb_dev = NULL; 1320 socket[i].socket.cb_dev = NULL;
1249 socket[i].socket.dev.dev = &m8xx_device.dev; 1321 socket[i].socket.dev.dev = &m8xx_device.dev;
1250 } 1322 }
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c
index 20642f0e7bfe..f2789afb22b2 100644
--- a/drivers/pcmcia/pd6729.c
+++ b/drivers/pcmcia/pd6729.c
@@ -304,75 +304,6 @@ static int pd6729_get_status(struct pcmcia_socket *sock, u_int *value)
304} 304}
305 305
306 306
307static int pd6729_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
308{
309 struct pd6729_socket *socket
310 = container_of(sock, struct pd6729_socket, socket);
311 unsigned char reg, vcc, vpp;
312
313 state->flags = 0;
314 state->Vcc = 0;
315 state->Vpp = 0;
316 state->io_irq = 0;
317 state->csc_mask = 0;
318
319 /* First the power status of the socket */
320 reg = indirect_read(socket, I365_POWER);
321
322 if (reg & I365_PWR_AUTO)
323 state->flags |= SS_PWR_AUTO; /* Automatic Power Switch */
324
325 if (reg & I365_PWR_OUT)
326 state->flags |= SS_OUTPUT_ENA; /* Output signals are enabled */
327
328 vcc = reg & I365_VCC_MASK; vpp = reg & I365_VPP1_MASK;
329
330 if (reg & I365_VCC_5V) {
331 state->Vcc = (indirect_read(socket, PD67_MISC_CTL_1) &
332 PD67_MC1_VCC_3V) ? 33 : 50;
333
334 if (vpp == I365_VPP1_5V) {
335 if (state->Vcc == 50)
336 state->Vpp = 50;
337 else
338 state->Vpp = 33;
339 }
340 if (vpp == I365_VPP1_12V)
341 state->Vpp = 120;
342 }
343
344 /* Now the IO card, RESET flags and IO interrupt */
345 reg = indirect_read(socket, I365_INTCTL);
346
347 if ((reg & I365_PC_RESET) == 0)
348 state->flags |= SS_RESET;
349 if (reg & I365_PC_IOCARD)
350 state->flags |= SS_IOCARD; /* This is an IO card */
351
352 /* Set the IRQ number */
353 state->io_irq = socket->card_irq;
354
355 /* Card status change */
356 reg = indirect_read(socket, I365_CSCINT);
357
358 if (reg & I365_CSC_DETECT)
359 state->csc_mask |= SS_DETECT; /* Card detect is enabled */
360
361 if (state->flags & SS_IOCARD) {/* IO Cards behave different */
362 if (reg & I365_CSC_STSCHG)
363 state->csc_mask |= SS_STSCHG;
364 } else {
365 if (reg & I365_CSC_BVD1)
366 state->csc_mask |= SS_BATDEAD;
367 if (reg & I365_CSC_BVD2)
368 state->csc_mask |= SS_BATWARN;
369 if (reg & I365_CSC_READY)
370 state->csc_mask |= SS_READY;
371 }
372
373 return 0;
374}
375
376static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state) 307static int pd6729_set_socket(struct pcmcia_socket *sock, socket_state_t *state)
377{ 308{
378 struct pd6729_socket *socket 309 struct pd6729_socket *socket
@@ -640,7 +571,6 @@ static int pd6729_init(struct pcmcia_socket *sock)
640static struct pccard_operations pd6729_operations = { 571static struct pccard_operations pd6729_operations = {
641 .init = pd6729_init, 572 .init = pd6729_init,
642 .get_status = pd6729_get_status, 573 .get_status = pd6729_get_status,
643 .get_socket = pd6729_get_socket,
644 .set_socket = pd6729_set_socket, 574 .set_socket = pd6729_set_socket,
645 .set_io_map = pd6729_set_io_map, 575 .set_io_map = pd6729_set_io_map,
646 .set_mem_map = pd6729_set_mem_map, 576 .set_mem_map = pd6729_set_mem_map,
@@ -704,13 +634,11 @@ static int __devinit pd6729_pci_probe(struct pci_dev *dev,
704 char configbyte; 634 char configbyte;
705 struct pd6729_socket *socket; 635 struct pd6729_socket *socket;
706 636
707 socket = kmalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, 637 socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
708 GFP_KERNEL); 638 GFP_KERNEL);
709 if (!socket) 639 if (!socket)
710 return -ENOMEM; 640 return -ENOMEM;
711 641
712 memset(socket, 0, sizeof(struct pd6729_socket) * MAX_SOCKETS);
713
714 if ((ret = pci_enable_device(dev))) 642 if ((ret = pci_enable_device(dev)))
715 goto err_out_free_mem; 643 goto err_out_free_mem;
716 644
diff --git a/drivers/pcmcia/pxa2xx_mainstone.c b/drivers/pcmcia/pxa2xx_mainstone.c
index 5209d8c7764f..5d957dfe23d9 100644
--- a/drivers/pcmcia/pxa2xx_mainstone.c
+++ b/drivers/pcmcia/pxa2xx_mainstone.c
@@ -171,10 +171,9 @@ static int __init mst_pcmcia_init(void)
171{ 171{
172 int ret; 172 int ret;
173 173
174 mst_pcmcia_device = kmalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL); 174 mst_pcmcia_device = kzalloc(sizeof(*mst_pcmcia_device), GFP_KERNEL);
175 if (!mst_pcmcia_device) 175 if (!mst_pcmcia_device)
176 return -ENOMEM; 176 return -ENOMEM;
177 memset(mst_pcmcia_device, 0, sizeof(*mst_pcmcia_device));
178 mst_pcmcia_device->name = "pxa2xx-pcmcia"; 177 mst_pcmcia_device->name = "pxa2xx-pcmcia";
179 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops; 178 mst_pcmcia_device->dev.platform_data = &mst_pcmcia_ops;
180 179
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c
index 56c58831e80e..b5fdeec20b15 100644
--- a/drivers/pcmcia/pxa2xx_sharpsl.c
+++ b/drivers/pcmcia/pxa2xx_sharpsl.c
@@ -264,11 +264,10 @@ static int __init sharpsl_pcmcia_init(void)
264 int ret; 264 int ret;
265 265
266 sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs; 266 sharpsl_pcmcia_ops.nr=platform_scoop_config->num_devs;
267 sharpsl_pcmcia_device = kmalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL); 267 sharpsl_pcmcia_device = kzalloc(sizeof(*sharpsl_pcmcia_device), GFP_KERNEL);
268 if (!sharpsl_pcmcia_device) 268 if (!sharpsl_pcmcia_device)
269 return -ENOMEM; 269 return -ENOMEM;
270 270
271 memset(sharpsl_pcmcia_device, 0, sizeof(*sharpsl_pcmcia_device));
272 sharpsl_pcmcia_device->name = "pxa2xx-pcmcia"; 271 sharpsl_pcmcia_device->name = "pxa2xx-pcmcia";
273 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops; 272 sharpsl_pcmcia_device->dev.platform_data = &sharpsl_pcmcia_ops;
274 sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev; 273 sharpsl_pcmcia_device->dev.parent=platform_scoop_config->devs[0].dev;
diff --git a/drivers/pcmcia/rsrc_mgr.c b/drivers/pcmcia/rsrc_mgr.c
index 0668384ebc8b..514609369836 100644
--- a/drivers/pcmcia/rsrc_mgr.c
+++ b/drivers/pcmcia/rsrc_mgr.c
@@ -98,10 +98,12 @@ int pcmcia_adjust_resource_info(adjust_t *adj)
98} 98}
99EXPORT_SYMBOL(pcmcia_adjust_resource_info); 99EXPORT_SYMBOL(pcmcia_adjust_resource_info);
100 100
101void pcmcia_validate_mem(struct pcmcia_socket *s) 101int pcmcia_validate_mem(struct pcmcia_socket *s)
102{ 102{
103 if (s->resource_ops->validate_mem) 103 if (s->resource_ops->validate_mem)
104 s->resource_ops->validate_mem(s); 104 return s->resource_ops->validate_mem(s);
105 /* if there is no callback, we can assume that everything is OK */
106 return 0;
105} 107}
106EXPORT_SYMBOL(pcmcia_validate_mem); 108EXPORT_SYMBOL(pcmcia_validate_mem);
107 109
@@ -164,3 +166,105 @@ struct pccard_resource_ops pccard_static_ops = {
164 .exit = NULL, 166 .exit = NULL,
165}; 167};
166EXPORT_SYMBOL(pccard_static_ops); 168EXPORT_SYMBOL(pccard_static_ops);
169
170
171#ifdef CONFIG_PCCARD_IODYN
172
173static struct resource *
174make_resource(unsigned long b, unsigned long n, int flags, char *name)
175{
176 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
177
178 if (res) {
179 res->name = name;
180 res->start = b;
181 res->end = b + n - 1;
182 res->flags = flags;
183 }
184 return res;
185}
186
187struct pcmcia_align_data {
188 unsigned long mask;
189 unsigned long offset;
190};
191
192static void pcmcia_align(void *align_data, struct resource *res,
193 unsigned long size, unsigned long align)
194{
195 struct pcmcia_align_data *data = align_data;
196 unsigned long start;
197
198 start = (res->start & ~data->mask) + data->offset;
199 if (start < res->start)
200 start += data->mask + 1;
201 res->start = start;
202
203#ifdef CONFIG_X86
204 if (res->flags & IORESOURCE_IO) {
205 if (start & 0x300) {
206 start = (start + 0x3ff) & ~0x3ff;
207 res->start = start;
208 }
209 }
210#endif
211
212#ifdef CONFIG_M68K
213 if (res->flags & IORESOURCE_IO) {
214 if ((res->start + size - 1) >= 1024)
215 res->start = res->end;
216 }
217#endif
218}
219
220
221static int iodyn_adjust_io_region(struct resource *res, unsigned long r_start,
222 unsigned long r_end, struct pcmcia_socket *s)
223{
224 return adjust_resource(res, r_start, r_end - r_start + 1);
225}
226
227
228static struct resource *iodyn_find_io_region(unsigned long base, int num,
229 unsigned long align, struct pcmcia_socket *s)
230{
231 struct resource *res = make_resource(0, num, IORESOURCE_IO,
232 s->dev.class_id);
233 struct pcmcia_align_data data;
234 unsigned long min = base;
235 int ret;
236
237 if (align == 0)
238 align = 0x10000;
239
240 data.mask = align - 1;
241 data.offset = base & data.mask;
242
243#ifdef CONFIG_PCI
244 if (s->cb_dev) {
245 ret = pci_bus_alloc_resource(s->cb_dev->bus, res, num, 1,
246 min, 0, pcmcia_align, &data);
247 } else
248#endif
249 ret = allocate_resource(&ioport_resource, res, num, min, ~0UL,
250 1, pcmcia_align, &data);
251
252 if (ret != 0) {
253 kfree(res);
254 res = NULL;
255 }
256 return res;
257}
258
259struct pccard_resource_ops pccard_iodyn_ops = {
260 .validate_mem = NULL,
261 .adjust_io_region = iodyn_adjust_io_region,
262 .find_io = iodyn_find_io_region,
263 .find_mem = NULL,
264 .adjust_resource = NULL,
265 .init = static_init,
266 .exit = NULL,
267};
268EXPORT_SYMBOL(pccard_iodyn_ops);
269
270#endif /* CONFIG_PCCARD_IODYN */
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
index 00960a379b9c..5301ac60358f 100644
--- a/drivers/pcmcia/rsrc_nonstatic.c
+++ b/drivers/pcmcia/rsrc_nonstatic.c
@@ -75,10 +75,9 @@ static DECLARE_MUTEX(rsrc_sem);
75static struct resource * 75static struct resource *
76make_resource(unsigned long b, unsigned long n, int flags, char *name) 76make_resource(unsigned long b, unsigned long n, int flags, char *name)
77{ 77{
78 struct resource *res = kmalloc(sizeof(*res), GFP_KERNEL); 78 struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL);
79 79
80 if (res) { 80 if (res) {
81 memset(res, 0, sizeof(*res));
82 res->name = name; 81 res->name = name;
83 res->start = b; 82 res->start = b;
84 res->end = b + n - 1; 83 res->end = b + n - 1;
@@ -200,12 +199,11 @@ static void do_io_probe(struct pcmcia_socket *s, kio_addr_t base, kio_addr_t num
200 base, base+num-1); 199 base, base+num-1);
201 200
202 /* First, what does a floating port look like? */ 201 /* First, what does a floating port look like? */
203 b = kmalloc(256, GFP_KERNEL); 202 b = kzalloc(256, GFP_KERNEL);
204 if (!b) { 203 if (!b) {
205 printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes"); 204 printk(KERN_ERR "do_io_probe: unable to kmalloc 256 bytes");
206 return; 205 return;
207 } 206 }
208 memset(b, 0, 256);
209 for (i = base, most = 0; i < base+num; i += 8) { 207 for (i = base, most = 0; i < base+num; i += 8) {
210 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe"); 208 res = claim_region(NULL, i, 8, IORESOURCE_IO, "PCMCIA IO probe");
211 if (!res) 209 if (!res)
@@ -407,69 +405,79 @@ static int do_mem_probe(u_long base, u_long num, struct pcmcia_socket *s)
407 405
408static u_long inv_probe(struct resource_map *m, struct pcmcia_socket *s) 406static u_long inv_probe(struct resource_map *m, struct pcmcia_socket *s)
409{ 407{
410 struct socket_data *s_data = s->resource_data; 408 struct socket_data *s_data = s->resource_data;
411 u_long ok; 409 u_long ok;
412 if (m == &s_data->mem_db) 410 if (m == &s_data->mem_db)
413 return 0; 411 return 0;
414 ok = inv_probe(m->next, s); 412 ok = inv_probe(m->next, s);
415 if (ok) { 413 if (ok) {
416 if (m->base >= 0x100000) 414 if (m->base >= 0x100000)
417 sub_interval(&s_data->mem_db, m->base, m->num); 415 sub_interval(&s_data->mem_db, m->base, m->num);
418 return ok; 416 return ok;
419 } 417 }
420 if (m->base < 0x100000) 418 if (m->base < 0x100000)
421 return 0; 419 return 0;
422 return do_mem_probe(m->base, m->num, s); 420 return do_mem_probe(m->base, m->num, s);
423} 421}
424 422
425static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) 423static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
426{ 424{
427 struct resource_map *m, mm; 425 struct resource_map *m, mm;
428 static u_char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 }; 426 static unsigned char order[] = { 0xd0, 0xe0, 0xc0, 0xf0 };
429 u_long b, i, ok = 0; 427 unsigned long b, i, ok = 0;
430 struct socket_data *s_data = s->resource_data; 428 struct socket_data *s_data = s->resource_data;
431 429
432 /* We do up to four passes through the list */ 430 /* We do up to four passes through the list */
433 if (probe_mask & MEM_PROBE_HIGH) { 431 if (probe_mask & MEM_PROBE_HIGH) {
434 if (inv_probe(s_data->mem_db.next, s) > 0) 432 if (inv_probe(s_data->mem_db.next, s) > 0)
435 return; 433 return 0;
436 printk(KERN_NOTICE "cs: warning: no high memory space " 434 printk(KERN_NOTICE "cs: warning: no high memory space "
437 "available!\n"); 435 "available!\n");
438 } 436 return -ENODEV;
439 if ((probe_mask & MEM_PROBE_LOW) == 0)
440 return;
441 for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) {
442 mm = *m;
443 /* Only probe < 1 MB */
444 if (mm.base >= 0x100000) continue;
445 if ((mm.base | mm.num) & 0xffff) {
446 ok += do_mem_probe(mm.base, mm.num, s);
447 continue;
448 } 437 }
449 /* Special probe for 64K-aligned block */ 438
450 for (i = 0; i < 4; i++) { 439 for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) {
451 b = order[i] << 12; 440 mm = *m;
452 if ((b >= mm.base) && (b+0x10000 <= mm.base+mm.num)) { 441 /* Only probe < 1 MB */
453 if (ok >= mem_limit) 442 if (mm.base >= 0x100000)
454 sub_interval(&s_data->mem_db, b, 0x10000); 443 continue;
455 else 444 if ((mm.base | mm.num) & 0xffff) {
456 ok += do_mem_probe(b, 0x10000, s); 445 ok += do_mem_probe(mm.base, mm.num, s);
457 } 446 continue;
447 }
448 /* Special probe for 64K-aligned block */
449 for (i = 0; i < 4; i++) {
450 b = order[i] << 12;
451 if ((b >= mm.base) && (b+0x10000 <= mm.base+mm.num)) {
452 if (ok >= mem_limit)
453 sub_interval(&s_data->mem_db, b, 0x10000);
454 else
455 ok += do_mem_probe(b, 0x10000, s);
456 }
457 }
458 } 458 }
459 } 459
460 if (ok > 0)
461 return 0;
462
463 return -ENODEV;
460} 464}
461 465
462#else /* CONFIG_PCMCIA_PROBE */ 466#else /* CONFIG_PCMCIA_PROBE */
463 467
464static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask) 468static int validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
465{ 469{
466 struct resource_map *m, mm; 470 struct resource_map *m, mm;
467 struct socket_data *s_data = s->resource_data; 471 struct socket_data *s_data = s->resource_data;
472 unsigned long ok = 0;
468 473
469 for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) { 474 for (m = s_data->mem_db.next; m != &s_data->mem_db; m = mm.next) {
470 mm = *m; 475 mm = *m;
471 do_mem_probe(mm.base, mm.num, s); 476 ok += do_mem_probe(mm.base, mm.num, s);
472 } 477 }
478 if (ok > 0)
479 return 0;
480 return -ENODEV;
473} 481}
474 482
475#endif /* CONFIG_PCMCIA_PROBE */ 483#endif /* CONFIG_PCMCIA_PROBE */
@@ -478,27 +486,30 @@ static void validate_mem(struct pcmcia_socket *s, unsigned int probe_mask)
478/* 486/*
479 * Locking note: Must be called with skt_sem held! 487 * Locking note: Must be called with skt_sem held!
480 */ 488 */
481static void pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s) 489static int pcmcia_nonstatic_validate_mem(struct pcmcia_socket *s)
482{ 490{
483 struct socket_data *s_data = s->resource_data; 491 struct socket_data *s_data = s->resource_data;
484 if (probe_mem) { 492 unsigned int probe_mask = MEM_PROBE_LOW;
485 unsigned int probe_mask; 493 int ret = 0;
486 494
487 down(&rsrc_sem); 495 if (!probe_mem)
496 return 0;
488 497
489 probe_mask = MEM_PROBE_LOW; 498 down(&rsrc_sem);
490 if (s->features & SS_CAP_PAGE_REGS)
491 probe_mask = MEM_PROBE_HIGH;
492 499
493 if (probe_mask & ~s_data->rsrc_mem_probe) { 500 if (s->features & SS_CAP_PAGE_REGS)
501 probe_mask = MEM_PROBE_HIGH;
502
503 if (probe_mask & ~s_data->rsrc_mem_probe) {
504 if (s->state & SOCKET_PRESENT)
505 ret = validate_mem(s, probe_mask);
506 if (!ret)
494 s_data->rsrc_mem_probe |= probe_mask; 507 s_data->rsrc_mem_probe |= probe_mask;
508 }
495 509
496 if (s->state & SOCKET_PRESENT) 510 up(&rsrc_sem);
497 validate_mem(s, probe_mask);
498 }
499 511
500 up(&rsrc_sem); 512 return ret;
501 }
502} 513}
503 514
504struct pcmcia_align_data { 515struct pcmcia_align_data {
@@ -837,10 +848,9 @@ static int nonstatic_init(struct pcmcia_socket *s)
837{ 848{
838 struct socket_data *data; 849 struct socket_data *data;
839 850
840 data = kmalloc(sizeof(struct socket_data), GFP_KERNEL); 851 data = kzalloc(sizeof(struct socket_data), GFP_KERNEL);
841 if (!data) 852 if (!data)
842 return -ENOMEM; 853 return -ENOMEM;
843 memset(data, 0, sizeof(struct socket_data));
844 854
845 data->mem_db.next = &data->mem_db; 855 data->mem_db.next = &data->mem_db;
846 data->io_db.next = &data->io_db; 856 data->io_db.next = &data->io_db;
diff --git a/drivers/pcmcia/soc_common.c b/drivers/pcmcia/soc_common.c
index 9e7ccd8a4321..ea7d9ca160b2 100644
--- a/drivers/pcmcia/soc_common.c
+++ b/drivers/pcmcia/soc_common.c
@@ -297,25 +297,6 @@ soc_common_pcmcia_get_status(struct pcmcia_socket *sock, unsigned int *status)
297 297
298 298
299/* 299/*
300 * Implements the get_socket() operation for the in-kernel PCMCIA
301 * service (formerly SS_GetSocket in Card Services). Not a very
302 * exciting routine.
303 *
304 * Returns: 0
305 */
306static int
307soc_common_pcmcia_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
308{
309 struct soc_pcmcia_socket *skt = to_soc_pcmcia_socket(sock);
310
311 debug(skt, 2, "\n");
312
313 *state = skt->cs_state;
314
315 return 0;
316}
317
318/*
319 * Implements the set_socket() operation for the in-kernel PCMCIA 300 * Implements the set_socket() operation for the in-kernel PCMCIA
320 * service (formerly SS_SetSocket in Card Services). We more or 301 * service (formerly SS_SetSocket in Card Services). We more or
321 * less punt all of this work and let the kernel handle the details 302 * less punt all of this work and let the kernel handle the details
@@ -528,7 +509,6 @@ static struct pccard_operations soc_common_pcmcia_operations = {
528 .init = soc_common_pcmcia_sock_init, 509 .init = soc_common_pcmcia_sock_init,
529 .suspend = soc_common_pcmcia_suspend, 510 .suspend = soc_common_pcmcia_suspend,
530 .get_status = soc_common_pcmcia_get_status, 511 .get_status = soc_common_pcmcia_get_status,
531 .get_socket = soc_common_pcmcia_get_socket,
532 .set_socket = soc_common_pcmcia_set_socket, 512 .set_socket = soc_common_pcmcia_set_socket,
533 .set_io_map = soc_common_pcmcia_set_io_map, 513 .set_io_map = soc_common_pcmcia_set_io_map,
534 .set_mem_map = soc_common_pcmcia_set_mem_map, 514 .set_mem_map = soc_common_pcmcia_set_mem_map,
@@ -665,13 +645,12 @@ int soc_common_drv_pcmcia_probe(struct device *dev, struct pcmcia_low_level *ops
665 645
666 down(&soc_pcmcia_sockets_lock); 646 down(&soc_pcmcia_sockets_lock);
667 647
668 sinfo = kmalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL); 648 sinfo = kzalloc(SKT_DEV_INFO_SIZE(nr), GFP_KERNEL);
669 if (!sinfo) { 649 if (!sinfo) {
670 ret = -ENOMEM; 650 ret = -ENOMEM;
671 goto out; 651 goto out;
672 } 652 }
673 653
674 memset(sinfo, 0, SKT_DEV_INFO_SIZE(nr));
675 sinfo->nskt = nr; 654 sinfo->nskt = nr;
676 655
677 /* 656 /*
diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index 4a3150a7854c..7a7744662d54 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -42,35 +42,28 @@
42 42
43static ssize_t pccard_show_type(struct class_device *dev, char *buf) 43static ssize_t pccard_show_type(struct class_device *dev, char *buf)
44{ 44{
45 int val;
46 struct pcmcia_socket *s = to_socket(dev); 45 struct pcmcia_socket *s = to_socket(dev);
47 46
48 if (!(s->state & SOCKET_PRESENT)) 47 if (!(s->state & SOCKET_PRESENT))
49 return -ENODEV; 48 return -ENODEV;
50 s->ops->get_status(s, &val); 49 if (s->state & SOCKET_CARDBUS)
51 if (val & SS_CARDBUS)
52 return sprintf(buf, "32-bit\n"); 50 return sprintf(buf, "32-bit\n");
53 if (val & SS_DETECT) 51 return sprintf(buf, "16-bit\n");
54 return sprintf(buf, "16-bit\n");
55 return sprintf(buf, "invalid\n");
56} 52}
57static CLASS_DEVICE_ATTR(card_type, 0400, pccard_show_type, NULL); 53static CLASS_DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL);
58 54
59static ssize_t pccard_show_voltage(struct class_device *dev, char *buf) 55static ssize_t pccard_show_voltage(struct class_device *dev, char *buf)
60{ 56{
61 int val;
62 struct pcmcia_socket *s = to_socket(dev); 57 struct pcmcia_socket *s = to_socket(dev);
63 58
64 if (!(s->state & SOCKET_PRESENT)) 59 if (!(s->state & SOCKET_PRESENT))
65 return -ENODEV; 60 return -ENODEV;
66 s->ops->get_status(s, &val); 61 if (s->socket.Vcc)
67 if (val & SS_3VCARD) 62 return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10,
68 return sprintf(buf, "3.3V\n"); 63 s->socket.Vcc % 10);
69 if (val & SS_XVCARD) 64 return sprintf(buf, "X.XV\n");
70 return sprintf(buf, "X.XV\n");
71 return sprintf(buf, "5.0V\n");
72} 65}
73static CLASS_DEVICE_ATTR(card_voltage, 0400, pccard_show_voltage, NULL); 66static CLASS_DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL);
74 67
75static ssize_t pccard_show_vpp(struct class_device *dev, char *buf) 68static ssize_t pccard_show_vpp(struct class_device *dev, char *buf)
76{ 69{
@@ -79,7 +72,7 @@ static ssize_t pccard_show_vpp(struct class_device *dev, char *buf)
79 return -ENODEV; 72 return -ENODEV;
80 return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10); 73 return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
81} 74}
82static CLASS_DEVICE_ATTR(card_vpp, 0400, pccard_show_vpp, NULL); 75static CLASS_DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL);
83 76
84static ssize_t pccard_show_vcc(struct class_device *dev, char *buf) 77static ssize_t pccard_show_vcc(struct class_device *dev, char *buf)
85{ 78{
@@ -88,7 +81,7 @@ static ssize_t pccard_show_vcc(struct class_device *dev, char *buf)
88 return -ENODEV; 81 return -ENODEV;
89 return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10); 82 return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
90} 83}
91static CLASS_DEVICE_ATTR(card_vcc, 0400, pccard_show_vcc, NULL); 84static CLASS_DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL);
92 85
93 86
94static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count) 87static ssize_t pccard_store_insert(struct class_device *dev, const char *buf, size_t count)
@@ -292,10 +285,9 @@ static ssize_t pccard_store_cis(struct kobject *kobj, char *buf, loff_t off, siz
292 if (!(s->state & SOCKET_PRESENT)) 285 if (!(s->state & SOCKET_PRESENT))
293 return -ENODEV; 286 return -ENODEV;
294 287
295 cis = kmalloc(sizeof(cisdump_t), GFP_KERNEL); 288 cis = kzalloc(sizeof(cisdump_t), GFP_KERNEL);
296 if (!cis) 289 if (!cis)
297 return -ENOMEM; 290 return -ENOMEM;
298 memset(cis, 0, sizeof(cisdump_t));
299 291
300 cis->Length = count + 1; 292 cis->Length = count + 1;
301 memcpy(cis->Data, buf, count); 293 memcpy(cis->Data, buf, count);
diff --git a/drivers/pcmcia/tcic.c b/drivers/pcmcia/tcic.c
index e31263864377..73bad1d5cb23 100644
--- a/drivers/pcmcia/tcic.c
+++ b/drivers/pcmcia/tcic.c
@@ -181,13 +181,6 @@ static void tcic_setl(u_char reg, u_int data)
181 outw(data >> 16, tcic_base+reg+2); 181 outw(data >> 16, tcic_base+reg+2);
182} 182}
183 183
184static u_char tcic_aux_getb(u_short reg)
185{
186 u_char mode = (tcic_getb(TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;
187 tcic_setb(TCIC_MODE, mode);
188 return tcic_getb(TCIC_AUX);
189}
190
191static void tcic_aux_setb(u_short reg, u_char data) 184static void tcic_aux_setb(u_short reg, u_char data)
192{ 185{
193 u_char mode = (tcic_getb(TCIC_MODE) & TCIC_MODE_PGMMASK) | reg; 186 u_char mode = (tcic_getb(TCIC_MODE) & TCIC_MODE_PGMMASK) | reg;
@@ -641,59 +634,6 @@ static int tcic_get_status(struct pcmcia_socket *sock, u_int *value)
641 debug(1, "GetStatus(%d) = %#2.2x\n", psock, *value); 634 debug(1, "GetStatus(%d) = %#2.2x\n", psock, *value);
642 return 0; 635 return 0;
643} /* tcic_get_status */ 636} /* tcic_get_status */
644
645/*====================================================================*/
646
647static int tcic_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
648{
649 u_short psock = container_of(sock, struct tcic_socket, socket)->psock;
650 u_char reg;
651 u_short scf1, scf2;
652
653 tcic_setl(TCIC_ADDR, (psock << TCIC_ADDR_SS_SHFT)
654 | TCIC_ADDR_INDREG | TCIC_SCF1(psock));
655 scf1 = tcic_getw(TCIC_DATA);
656 state->flags = (scf1 & TCIC_SCF1_IOSTS) ? SS_IOCARD : 0;
657 state->flags |= (scf1 & TCIC_SCF1_DMA_MASK) ? SS_DMA_MODE : 0;
658 state->flags |= (scf1 & TCIC_SCF1_SPKR) ? SS_SPKR_ENA : 0;
659 if (tcic_getb(TCIC_SCTRL) & TCIC_SCTRL_ENA)
660 state->flags |= SS_OUTPUT_ENA;
661 state->io_irq = scf1 & TCIC_SCF1_IRQ_MASK;
662 if (state->io_irq == 1) state->io_irq = 11;
663
664 reg = tcic_getb(TCIC_PWR);
665 state->Vcc = state->Vpp = 0;
666 if (reg & TCIC_PWR_VCC(psock)) {
667 if (reg & TCIC_PWR_VPP(psock))
668 state->Vcc = 50;
669 else
670 state->Vcc = state->Vpp = 50;
671 } else {
672 if (reg & TCIC_PWR_VPP(psock)) {
673 state->Vcc = 50;
674 state->Vpp = 120;
675 }
676 }
677 reg = tcic_aux_getb(TCIC_AUX_ILOCK);
678 state->flags |= (reg & TCIC_ILOCK_CRESET) ? SS_RESET : 0;
679
680 /* Card status change interrupt mask */
681 tcic_setw(TCIC_ADDR, TCIC_SCF2(psock));
682 scf2 = tcic_getw(TCIC_DATA);
683 state->csc_mask = (scf2 & TCIC_SCF2_MCD) ? 0 : SS_DETECT;
684 if (state->flags & SS_IOCARD) {
685 state->csc_mask |= (scf2 & TCIC_SCF2_MLBAT1) ? 0 : SS_STSCHG;
686 } else {
687 state->csc_mask |= (scf2 & TCIC_SCF2_MLBAT1) ? 0 : SS_BATDEAD;
688 state->csc_mask |= (scf2 & TCIC_SCF2_MLBAT2) ? 0 : SS_BATWARN;
689 state->csc_mask |= (scf2 & TCIC_SCF2_MRDY) ? 0 : SS_READY;
690 }
691
692 debug(1, "GetSocket(%d) = flags %#3.3x, Vcc %d, Vpp %d, "
693 "io_irq %d, csc_mask %#2.2x\n", psock, state->flags,
694 state->Vcc, state->Vpp, state->io_irq, state->csc_mask);
695 return 0;
696} /* tcic_get_socket */
697 637
698/*====================================================================*/ 638/*====================================================================*/
699 639
@@ -874,7 +814,6 @@ static int tcic_init(struct pcmcia_socket *s)
874static struct pccard_operations tcic_operations = { 814static struct pccard_operations tcic_operations = {
875 .init = tcic_init, 815 .init = tcic_init,
876 .get_status = tcic_get_status, 816 .get_status = tcic_get_status,
877 .get_socket = tcic_get_socket,
878 .set_socket = tcic_set_socket, 817 .set_socket = tcic_set_socket,
879 .set_io_map = tcic_set_io_map, 818 .set_io_map = tcic_set_io_map,
880 .set_mem_map = tcic_set_mem_map, 819 .set_mem_map = tcic_set_mem_map,
diff --git a/drivers/pcmcia/ti113x.h b/drivers/pcmcia/ti113x.h
index 539b5cd1a598..d5b4ff74462e 100644
--- a/drivers/pcmcia/ti113x.h
+++ b/drivers/pcmcia/ti113x.h
@@ -873,7 +873,7 @@ static int ti1250_override(struct yenta_socket *socket)
873 * Some fixup code to make everybody happy (TM). 873 * Some fixup code to make everybody happy (TM).
874 */ 874 */
875 875
876#ifdef CONFIG_CARDBUS 876#ifdef CONFIG_YENTA_ENE_TUNE
877/** 877/**
878 * set/clear various test bits: 878 * set/clear various test bits:
879 * Defaults to clear the bit. 879 * Defaults to clear the bit.
@@ -937,7 +937,7 @@ static int ene_override(struct yenta_socket *socket)
937} 937}
938#else 938#else
939# define ene_override ti1250_override 939# define ene_override ti1250_override
940#endif 940#endif /* !CONFIG_YENTA_ENE_TUNE */
941 941
942#endif /* _LINUX_TI113X_H */ 942#endif /* _LINUX_TI113X_H */
943 943
diff --git a/drivers/pcmcia/vrc4171_card.c b/drivers/pcmcia/vrc4171_card.c
index 38a028c725d4..24c547ef512b 100644
--- a/drivers/pcmcia/vrc4171_card.c
+++ b/drivers/pcmcia/vrc4171_card.c
@@ -301,75 +301,6 @@ static int pccard_get_status(struct pcmcia_socket *sock, u_int *value)
301 return 0; 301 return 0;
302} 302}
303 303
304static inline u_char get_Vcc_value(uint8_t voltage)
305{
306 switch (voltage) {
307 case VCC_STATUS_3V:
308 return 33;
309 case VCC_STATUS_5V:
310 return 50;
311 default:
312 break;
313 }
314
315 return 0;
316}
317
318static inline u_char get_Vpp_value(uint8_t power, u_char Vcc)
319{
320 if ((power & 0x03) == 0x01 || (power & 0x03) == 0x02)
321 return Vcc;
322
323 return 0;
324}
325
326static int pccard_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
327{
328 unsigned int slot;
329 uint8_t power, voltage, control, cscint;
330
331 if (sock == NULL || sock->sock >= CARD_MAX_SLOTS || state == NULL)
332 return -EINVAL;
333
334 slot = sock->sock;
335
336 power = exca_read_byte(slot, I365_POWER);
337 voltage = exca_read_byte(slot, CARD_VOLTAGE_SELECT);
338
339 state->Vcc = get_Vcc_value(voltage);
340 state->Vpp = get_Vpp_value(power, state->Vcc);
341
342 state->flags = 0;
343 if (power & POWER_ENABLE)
344 state->flags |= SS_PWR_AUTO;
345 if (power & I365_PWR_OUT)
346 state->flags |= SS_OUTPUT_ENA;
347
348 control = exca_read_byte(slot, I365_INTCTL);
349 if (control & I365_PC_IOCARD)
350 state->flags |= SS_IOCARD;
351 if (!(control & I365_PC_RESET))
352 state->flags |= SS_RESET;
353
354 cscint = exca_read_byte(slot, I365_CSCINT);
355 state->csc_mask = 0;
356 if (state->flags & SS_IOCARD) {
357 if (cscint & I365_CSC_STSCHG)
358 state->flags |= SS_STSCHG;
359 } else {
360 if (cscint & I365_CSC_BVD1)
361 state->csc_mask |= SS_BATDEAD;
362 if (cscint & I365_CSC_BVD2)
363 state->csc_mask |= SS_BATWARN;
364 }
365 if (cscint & I365_CSC_READY)
366 state->csc_mask |= SS_READY;
367 if (cscint & I365_CSC_DETECT)
368 state->csc_mask |= SS_DETECT;
369
370 return 0;
371}
372
373static inline uint8_t set_Vcc_value(u_char Vcc) 304static inline uint8_t set_Vcc_value(u_char Vcc)
374{ 305{
375 switch (Vcc) { 306 switch (Vcc) {
@@ -551,7 +482,6 @@ static int pccard_set_mem_map(struct pcmcia_socket *sock, struct pccard_mem_map
551static struct pccard_operations vrc4171_pccard_operations = { 482static struct pccard_operations vrc4171_pccard_operations = {
552 .init = pccard_init, 483 .init = pccard_init,
553 .get_status = pccard_get_status, 484 .get_status = pccard_get_status,
554 .get_socket = pccard_get_socket,
555 .set_socket = pccard_set_socket, 485 .set_socket = pccard_set_socket,
556 .set_io_map = pccard_set_io_map, 486 .set_io_map = pccard_set_io_map,
557 .set_mem_map = pccard_set_mem_map, 487 .set_mem_map = pccard_set_mem_map,
diff --git a/drivers/pcmcia/vrc4173_cardu.c b/drivers/pcmcia/vrc4173_cardu.c
index db91259dc50e..1b277d2c1c96 100644
--- a/drivers/pcmcia/vrc4173_cardu.c
+++ b/drivers/pcmcia/vrc4173_cardu.c
@@ -198,48 +198,6 @@ static int cardu_get_status(unsigned int sock, u_int *value)
198 return 0; 198 return 0;
199} 199}
200 200
201static inline u_char get_Vcc_value(uint8_t val)
202{
203 switch (val & VCC_MASK) {
204 case VCC_3V:
205 return 33;
206 case VCC_5V:
207 return 50;
208 }
209
210 return 0;
211}
212
213static inline u_char get_Vpp_value(uint8_t val)
214{
215 switch (val & VPP_MASK) {
216 case VPP_12V:
217 return 120;
218 case VPP_VCC:
219 return get_Vcc_value(val);
220 }
221
222 return 0;
223}
224
225static int cardu_get_socket(unsigned int sock, socket_state_t *state)
226{
227 vrc4173_socket_t *socket = &cardu_sockets[sock];
228 uint8_t val;
229
230 val = exca_readb(socket, PWR_CNT);
231 state->Vcc = get_Vcc_value(val);
232 state->Vpp = get_Vpp_value(val);
233 state->flags = 0;
234 if (val & CARD_OUT_EN) state->flags |= SS_OUTPUT_ENA;
235
236 val = exca_readb(socket, INT_GEN_CNT);
237 if (!(val & CARD_REST0)) state->flags |= SS_RESET;
238 if (val & CARD_TYPE_IO) state->flags |= SS_IOCARD;
239
240 return 0;
241}
242
243static inline uint8_t set_Vcc_value(u_char Vcc) 201static inline uint8_t set_Vcc_value(u_char Vcc)
244{ 202{
245 switch (Vcc) { 203 switch (Vcc) {
@@ -431,7 +389,6 @@ static struct pccard_operations cardu_operations = {
431 .register_callback = cardu_register_callback, 389 .register_callback = cardu_register_callback,
432 .inquire_socket = cardu_inquire_socket, 390 .inquire_socket = cardu_inquire_socket,
433 .get_status = cardu_get_status, 391 .get_status = cardu_get_status,
434 .get_socket = cardu_get_socket,
435 .set_socket = cardu_set_socket, 392 .set_socket = cardu_set_socket,
436 .get_io_map = cardu_get_io_map, 393 .get_io_map = cardu_get_io_map,
437 .set_io_map = cardu_set_io_map, 394 .set_io_map = cardu_set_io_map,
diff --git a/drivers/pcmcia/yenta_socket.c b/drivers/pcmcia/yenta_socket.c
index ec6ab65f0872..4145eb83b9b6 100644
--- a/drivers/pcmcia/yenta_socket.c
+++ b/drivers/pcmcia/yenta_socket.c
@@ -49,7 +49,13 @@ MODULE_PARM_DESC(pwr_irqs_off, "Force IRQs off during power-on of slot. Use only
49#define to_cycles(ns) ((ns)/120) 49#define to_cycles(ns) ((ns)/120)
50#define to_ns(cycles) ((cycles)*120) 50#define to_ns(cycles) ((cycles)*120)
51 51
52/**
53 * yenta PCI irq probing.
54 * currently only used in the TI/EnE initialization code
55 */
56#ifdef CONFIG_YENTA_TI
52static int yenta_probe_cb_irq(struct yenta_socket *socket); 57static int yenta_probe_cb_irq(struct yenta_socket *socket);
58#endif
53 59
54 60
55static unsigned int override_bios; 61static unsigned int override_bios;
@@ -224,95 +230,6 @@ static int yenta_get_status(struct pcmcia_socket *sock, unsigned int *value)
224 return 0; 230 return 0;
225} 231}
226 232
227static void yenta_get_power(struct yenta_socket *socket, socket_state_t *state)
228{
229 if (!(cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) &&
230 (socket->flags & YENTA_16BIT_POWER_EXCA)) {
231 u8 reg, vcc, vpp;
232
233 reg = exca_readb(socket, I365_POWER);
234 vcc = reg & I365_VCC_MASK;
235 vpp = reg & I365_VPP1_MASK;
236 state->Vcc = state->Vpp = 0;
237
238 if (socket->flags & YENTA_16BIT_POWER_DF) {
239 if (vcc == I365_VCC_3V)
240 state->Vcc = 33;
241 if (vcc == I365_VCC_5V)
242 state->Vcc = 50;
243 if (vpp == I365_VPP1_5V)
244 state->Vpp = state->Vcc;
245 if (vpp == I365_VPP1_12V)
246 state->Vpp = 120;
247 } else {
248 if (reg & I365_VCC_5V) {
249 state->Vcc = 50;
250 if (vpp == I365_VPP1_5V)
251 state->Vpp = 50;
252 if (vpp == I365_VPP1_12V)
253 state->Vpp = 120;
254 }
255 }
256 } else {
257 u32 control;
258
259 control = cb_readl(socket, CB_SOCKET_CONTROL);
260
261 switch (control & CB_SC_VCC_MASK) {
262 case CB_SC_VCC_5V: state->Vcc = 50; break;
263 case CB_SC_VCC_3V: state->Vcc = 33; break;
264 default: state->Vcc = 0;
265 }
266
267 switch (control & CB_SC_VPP_MASK) {
268 case CB_SC_VPP_12V: state->Vpp = 120; break;
269 case CB_SC_VPP_5V: state->Vpp = 50; break;
270 case CB_SC_VPP_3V: state->Vpp = 33; break;
271 default: state->Vpp = 0;
272 }
273 }
274}
275
276static int yenta_get_socket(struct pcmcia_socket *sock, socket_state_t *state)
277{
278 struct yenta_socket *socket = container_of(sock, struct yenta_socket, socket);
279 u8 reg;
280 u32 control;
281
282 control = cb_readl(socket, CB_SOCKET_CONTROL);
283
284 yenta_get_power(socket, state);
285 state->io_irq = socket->io_irq;
286
287 if (cb_readl(socket, CB_SOCKET_STATE) & CB_CBCARD) {
288 u16 bridge = config_readw(socket, CB_BRIDGE_CONTROL);
289 if (bridge & CB_BRIDGE_CRST)
290 state->flags |= SS_RESET;
291 return 0;
292 }
293
294 /* 16-bit card state.. */
295 reg = exca_readb(socket, I365_POWER);
296 state->flags = (reg & I365_PWR_AUTO) ? SS_PWR_AUTO : 0;
297 state->flags |= (reg & I365_PWR_OUT) ? SS_OUTPUT_ENA : 0;
298
299 reg = exca_readb(socket, I365_INTCTL);
300 state->flags |= (reg & I365_PC_RESET) ? 0 : SS_RESET;
301 state->flags |= (reg & I365_PC_IOCARD) ? SS_IOCARD : 0;
302
303 reg = exca_readb(socket, I365_CSCINT);
304 state->csc_mask = (reg & I365_CSC_DETECT) ? SS_DETECT : 0;
305 if (state->flags & SS_IOCARD) {
306 state->csc_mask |= (reg & I365_CSC_STSCHG) ? SS_STSCHG : 0;
307 } else {
308 state->csc_mask |= (reg & I365_CSC_BVD1) ? SS_BATDEAD : 0;
309 state->csc_mask |= (reg & I365_CSC_BVD2) ? SS_BATWARN : 0;
310 state->csc_mask |= (reg & I365_CSC_READY) ? SS_READY : 0;
311 }
312
313 return 0;
314}
315
316static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state) 233static void yenta_set_power(struct yenta_socket *socket, socket_state_t *state)
317{ 234{
318 /* some birdges require to use the ExCA registers to power 16bit cards */ 235 /* some birdges require to use the ExCA registers to power 16bit cards */
@@ -531,6 +448,9 @@ static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
531 448
532 csc = exca_readb(socket, I365_CSC); 449 csc = exca_readb(socket, I365_CSC);
533 450
451 if (!(cb_event || csc))
452 return IRQ_NONE;
453
534 events = (cb_event & (CB_CD1EVENT | CB_CD2EVENT)) ? SS_DETECT : 0 ; 454 events = (cb_event & (CB_CD1EVENT | CB_CD2EVENT)) ? SS_DETECT : 0 ;
535 events |= (csc & I365_CSC_DETECT) ? SS_DETECT : 0; 455 events |= (csc & I365_CSC_DETECT) ? SS_DETECT : 0;
536 if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) { 456 if (exca_readb(socket, I365_INTCTL) & I365_PC_IOCARD) {
@@ -544,10 +464,7 @@ static irqreturn_t yenta_interrupt(int irq, void *dev_id, struct pt_regs *regs)
544 if (events) 464 if (events)
545 pcmcia_parse_events(&socket->socket, events); 465 pcmcia_parse_events(&socket->socket, events);
546 466
547 if (cb_event || csc) 467 return IRQ_HANDLED;
548 return IRQ_HANDLED;
549
550 return IRQ_NONE;
551} 468}
552 469
553static void yenta_interrupt_wrapper(unsigned long data) 470static void yenta_interrupt_wrapper(unsigned long data)
@@ -828,17 +745,24 @@ static struct pccard_operations yenta_socket_operations = {
828 .init = yenta_sock_init, 745 .init = yenta_sock_init,
829 .suspend = yenta_sock_suspend, 746 .suspend = yenta_sock_suspend,
830 .get_status = yenta_get_status, 747 .get_status = yenta_get_status,
831 .get_socket = yenta_get_socket,
832 .set_socket = yenta_set_socket, 748 .set_socket = yenta_set_socket,
833 .set_io_map = yenta_set_io_map, 749 .set_io_map = yenta_set_io_map,
834 .set_mem_map = yenta_set_mem_map, 750 .set_mem_map = yenta_set_mem_map,
835}; 751};
836 752
837 753
754#ifdef CONFIG_YENTA_TI
838#include "ti113x.h" 755#include "ti113x.h"
756#endif
757#ifdef CONFIG_YENTA_RICOH
839#include "ricoh.h" 758#include "ricoh.h"
759#endif
760#ifdef CONFIG_YENTA_TOSHIBA
840#include "topic.h" 761#include "topic.h"
762#endif
763#ifdef CONFIG_YENTA_O2
841#include "o2micro.h" 764#include "o2micro.h"
765#endif
842 766
843enum { 767enum {
844 CARDBUS_TYPE_DEFAULT = -1, 768 CARDBUS_TYPE_DEFAULT = -1,
@@ -858,6 +782,7 @@ enum {
858 * initialization sequences etc details. List them here.. 782 * initialization sequences etc details. List them here..
859 */ 783 */
860static struct cardbus_type cardbus_type[] = { 784static struct cardbus_type cardbus_type[] = {
785#ifdef CONFIG_YENTA_TI
861 [CARDBUS_TYPE_TI] = { 786 [CARDBUS_TYPE_TI] = {
862 .override = ti_override, 787 .override = ti_override,
863 .save_state = ti_save_state, 788 .save_state = ti_save_state,
@@ -882,27 +807,36 @@ static struct cardbus_type cardbus_type[] = {
882 .restore_state = ti_restore_state, 807 .restore_state = ti_restore_state,
883 .sock_init = ti_init, 808 .sock_init = ti_init,
884 }, 809 },
810#endif
811#ifdef CONFIG_YENTA_RICOH
885 [CARDBUS_TYPE_RICOH] = { 812 [CARDBUS_TYPE_RICOH] = {
886 .override = ricoh_override, 813 .override = ricoh_override,
887 .save_state = ricoh_save_state, 814 .save_state = ricoh_save_state,
888 .restore_state = ricoh_restore_state, 815 .restore_state = ricoh_restore_state,
889 }, 816 },
817#endif
818#ifdef CONFIG_YENTA_TOSHIBA
890 [CARDBUS_TYPE_TOPIC95] = { 819 [CARDBUS_TYPE_TOPIC95] = {
891 .override = topic95_override, 820 .override = topic95_override,
892 }, 821 },
893 [CARDBUS_TYPE_TOPIC97] = { 822 [CARDBUS_TYPE_TOPIC97] = {
894 .override = topic97_override, 823 .override = topic97_override,
895 }, 824 },
825#endif
826#ifdef CONFIG_YENTA_O2
896 [CARDBUS_TYPE_O2MICRO] = { 827 [CARDBUS_TYPE_O2MICRO] = {
897 .override = o2micro_override, 828 .override = o2micro_override,
898 .restore_state = o2micro_restore_state, 829 .restore_state = o2micro_restore_state,
899 }, 830 },
831#endif
832#ifdef CONFIG_YENTA_TI
900 [CARDBUS_TYPE_ENE] = { 833 [CARDBUS_TYPE_ENE] = {
901 .override = ene_override, 834 .override = ene_override,
902 .save_state = ti_save_state, 835 .save_state = ti_save_state,
903 .restore_state = ti_restore_state, 836 .restore_state = ti_restore_state,
904 .sock_init = ti_init, 837 .sock_init = ti_init,
905 }, 838 },
839#endif
906}; 840};
907 841
908 842
@@ -948,6 +882,12 @@ static unsigned int yenta_probe_irq(struct yenta_socket *socket, u32 isa_irq_mas
948} 882}
949 883
950 884
885/**
886 * yenta PCI irq probing.
887 * currently only used in the TI/EnE initialization code
888 */
889#ifdef CONFIG_YENTA_TI
890
951/* interrupt handler, only used during probing */ 891/* interrupt handler, only used during probing */
952static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *regs) 892static irqreturn_t yenta_probe_handler(int irq, void *dev_id, struct pt_regs *regs)
953{ 893{
@@ -1000,6 +940,7 @@ static int yenta_probe_cb_irq(struct yenta_socket *socket)
1000 return (int) socket->probe_status; 940 return (int) socket->probe_status;
1001} 941}
1002 942
943#endif /* CONFIG_YENTA_TI */
1003 944
1004 945
1005/* 946/*
@@ -1078,10 +1019,9 @@ static int __devinit yenta_probe (struct pci_dev *dev, const struct pci_device_i
1078 return -ENODEV; 1019 return -ENODEV;
1079 } 1020 }
1080 1021
1081 socket = kmalloc(sizeof(struct yenta_socket), GFP_KERNEL); 1022 socket = kzalloc(sizeof(struct yenta_socket), GFP_KERNEL);
1082 if (!socket) 1023 if (!socket)
1083 return -ENOMEM; 1024 return -ENOMEM;
1084 memset(socket, 0, sizeof(*socket));
1085 1025
1086 /* prepare pcmcia_socket */ 1026 /* prepare pcmcia_socket */
1087 socket->socket.ops = &yenta_socket_operations; 1027 socket->socket.ops = &yenta_socket_operations;
@@ -1263,6 +1203,7 @@ static struct pci_device_id yenta_table [] = {
1263 * advanced overrides instead. (I can't get the 1203 * advanced overrides instead. (I can't get the
1264 * data sheets for these devices. --rmk) 1204 * data sheets for these devices. --rmk)
1265 */ 1205 */
1206#ifdef CONFIG_YENTA_TI
1266 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI), 1207 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1210, TI),
1267 1208
1268 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X), 1209 CB_ID(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1130, TI113X),
@@ -1305,18 +1246,25 @@ static struct pci_device_id yenta_table [] = {
1305 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE), 1246 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1225, ENE),
1306 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE), 1247 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1410, ENE),
1307 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE), 1248 CB_ID(PCI_VENDOR_ID_ENE, PCI_DEVICE_ID_ENE_1420, ENE),
1249#endif /* CONFIG_YENTA_TI */
1308 1250
1251#ifdef CONFIG_YENTA_RICOH
1309 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH), 1252 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C465, RICOH),
1310 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH), 1253 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C466, RICOH),
1311 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH), 1254 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C475, RICOH),
1312 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH), 1255 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C476, RICOH),
1313 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH), 1256 CB_ID(PCI_VENDOR_ID_RICOH, PCI_DEVICE_ID_RICOH_RL5C478, RICOH),
1257#endif
1314 1258
1259#ifdef CONFIG_YENTA_TOSHIBA
1315 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC95, TOPIC95), 1260 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC95, TOPIC95),
1316 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97), 1261 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC97, TOPIC97),
1317 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97), 1262 CB_ID(PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_TOSHIBA_TOPIC100, TOPIC97),
1263#endif
1318 1264
1265#ifdef CONFIG_YENTA_O2
1319 CB_ID(PCI_VENDOR_ID_O2, PCI_ANY_ID, O2MICRO), 1266 CB_ID(PCI_VENDOR_ID_O2, PCI_ANY_ID, O2MICRO),
1267#endif
1320 1268
1321 /* match any cardbus bridge */ 1269 /* match any cardbus bridge */
1322 CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT), 1270 CB_ID(PCI_ANY_ID, PCI_ANY_ID, DEFAULT),
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index bd7c966ea2d7..0ecbe4edbec1 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -69,6 +69,7 @@ static int card_probe(struct pnp_card * card, struct pnp_card_driver * drv)
69 return 0; 69 return 0;
70 clink->card = card; 70 clink->card = card;
71 clink->driver = drv; 71 clink->driver = drv;
72 clink->pm_state = PMSG_ON;
72 if (drv->probe) { 73 if (drv->probe) {
73 if (drv->probe(clink, id)>=0) 74 if (drv->probe(clink, id)>=0)
74 return 1; 75 return 1;
@@ -333,6 +334,28 @@ void pnp_release_card_device(struct pnp_dev * dev)
333 up_write(&dev->dev.bus->subsys.rwsem); 334 up_write(&dev->dev.bus->subsys.rwsem);
334} 335}
335 336
337/*
338 * suspend/resume callbacks
339 */
340static int card_suspend(struct pnp_dev *dev, pm_message_t state)
341{
342 struct pnp_card_link *link = dev->card_link;
343 if (link->pm_state.event == state.event)
344 return 0;
345 link->pm_state = state;
346 return link->driver->suspend(link, state);
347}
348
349static int card_resume(struct pnp_dev *dev)
350{
351 struct pnp_card_link *link = dev->card_link;
352 if (link->pm_state.event == PM_EVENT_ON)
353 return 0;
354 link->pm_state = PMSG_ON;
355 link->driver->resume(link);
356 return 0;
357}
358
336/** 359/**
337 * pnp_register_card_driver - registers a PnP card driver with the PnP Layer 360 * pnp_register_card_driver - registers a PnP card driver with the PnP Layer
338 * @drv: pointer to the driver to register 361 * @drv: pointer to the driver to register
@@ -348,6 +371,8 @@ int pnp_register_card_driver(struct pnp_card_driver * drv)
348 drv->link.flags = drv->flags; 371 drv->link.flags = drv->flags;
349 drv->link.probe = NULL; 372 drv->link.probe = NULL;
350 drv->link.remove = &card_remove_first; 373 drv->link.remove = &card_remove_first;
374 drv->link.suspend = drv->suspend ? card_suspend : NULL;
375 drv->link.resume = drv->resume ? card_resume : NULL;
351 376
352 spin_lock(&pnp_lock); 377 spin_lock(&pnp_lock);
353 list_add_tail(&drv->global_list, &pnp_card_drivers); 378 list_add_tail(&drv->global_list, &pnp_card_drivers);
diff --git a/drivers/pnp/driver.c b/drivers/pnp/driver.c
index d3ccce706ab4..15fb758a9e52 100644
--- a/drivers/pnp/driver.c
+++ b/drivers/pnp/driver.c
@@ -146,10 +146,57 @@ static int pnp_bus_match(struct device *dev, struct device_driver *drv)
146 return 1; 146 return 1;
147} 147}
148 148
149static int pnp_bus_suspend(struct device *dev, pm_message_t state)
150{
151 struct pnp_dev * pnp_dev = to_pnp_dev(dev);
152 struct pnp_driver * pnp_drv = pnp_dev->driver;
153 int error;
154
155 if (!pnp_drv)
156 return 0;
157
158 if (pnp_drv->suspend) {
159 error = pnp_drv->suspend(pnp_dev, state);
160 if (error)
161 return error;
162 }
163
164 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE) &&
165 pnp_can_disable(pnp_dev)) {
166 error = pnp_stop_dev(pnp_dev);
167 if (error)
168 return error;
169 }
170
171 return 0;
172}
173
174static int pnp_bus_resume(struct device *dev)
175{
176 struct pnp_dev * pnp_dev = to_pnp_dev(dev);
177 struct pnp_driver * pnp_drv = pnp_dev->driver;
178 int error;
179
180 if (!pnp_drv)
181 return 0;
182
183 if (!(pnp_drv->flags & PNP_DRIVER_RES_DO_NOT_CHANGE)) {
184 error = pnp_start_dev(pnp_dev);
185 if (error)
186 return error;
187 }
188
189 if (pnp_drv->resume)
190 return pnp_drv->resume(pnp_dev);
191
192 return 0;
193}
149 194
150struct bus_type pnp_bus_type = { 195struct bus_type pnp_bus_type = {
151 .name = "pnp", 196 .name = "pnp",
152 .match = pnp_bus_match, 197 .match = pnp_bus_match,
198 .suspend = pnp_bus_suspend,
199 .resume = pnp_bus_resume,
153}; 200};
154 201
155 202
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 261668618b2d..c4256aa32bcb 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -470,6 +470,53 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
470} 470}
471 471
472/** 472/**
473 * pnp_start_dev - low-level start of the PnP device
474 * @dev: pointer to the desired device
475 *
476 * assumes that resources have alread been allocated
477 */
478
479int pnp_start_dev(struct pnp_dev *dev)
480{
481 if (!pnp_can_write(dev)) {
482 pnp_info("Device %s does not supported activation.", dev->dev.bus_id);
483 return -EINVAL;
484 }
485
486 if (dev->protocol->set(dev, &dev->res)<0) {
487 pnp_err("Failed to activate device %s.", dev->dev.bus_id);
488 return -EIO;
489 }
490
491 pnp_info("Device %s activated.", dev->dev.bus_id);
492
493 return 0;
494}
495
496/**
497 * pnp_stop_dev - low-level disable of the PnP device
498 * @dev: pointer to the desired device
499 *
500 * does not free resources
501 */
502
503int pnp_stop_dev(struct pnp_dev *dev)
504{
505 if (!pnp_can_disable(dev)) {
506 pnp_info("Device %s does not supported disabling.", dev->dev.bus_id);
507 return -EINVAL;
508 }
509 if (dev->protocol->disable(dev)<0) {
510 pnp_err("Failed to disable device %s.", dev->dev.bus_id);
511 return -EIO;
512 }
513
514 pnp_info("Device %s disabled.", dev->dev.bus_id);
515
516 return 0;
517}
518
519/**
473 * pnp_activate_dev - activates a PnP device for use 520 * pnp_activate_dev - activates a PnP device for use
474 * @dev: pointer to the desired device 521 * @dev: pointer to the desired device
475 * 522 *
@@ -477,6 +524,8 @@ int pnp_auto_config_dev(struct pnp_dev *dev)
477 */ 524 */
478int pnp_activate_dev(struct pnp_dev *dev) 525int pnp_activate_dev(struct pnp_dev *dev)
479{ 526{
527 int error;
528
480 if (!dev) 529 if (!dev)
481 return -EINVAL; 530 return -EINVAL;
482 if (dev->active) { 531 if (dev->active) {
@@ -487,18 +536,11 @@ int pnp_activate_dev(struct pnp_dev *dev)
487 if (pnp_auto_config_dev(dev)) 536 if (pnp_auto_config_dev(dev))
488 return -EBUSY; 537 return -EBUSY;
489 538
490 if (!pnp_can_write(dev)) { 539 error = pnp_start_dev(dev);
491 pnp_info("Device %s does not supported activation.", dev->dev.bus_id); 540 if (error)
492 return -EINVAL; 541 return error;
493 }
494
495 if (dev->protocol->set(dev, &dev->res)<0) {
496 pnp_err("Failed to activate device %s.", dev->dev.bus_id);
497 return -EIO;
498 }
499 542
500 dev->active = 1; 543 dev->active = 1;
501 pnp_info("Device %s activated.", dev->dev.bus_id);
502 544
503 return 1; 545 return 1;
504} 546}
@@ -511,23 +553,19 @@ int pnp_activate_dev(struct pnp_dev *dev)
511 */ 553 */
512int pnp_disable_dev(struct pnp_dev *dev) 554int pnp_disable_dev(struct pnp_dev *dev)
513{ 555{
556 int error;
557
514 if (!dev) 558 if (!dev)
515 return -EINVAL; 559 return -EINVAL;
516 if (!dev->active) { 560 if (!dev->active) {
517 return 0; /* the device is already disabled */ 561 return 0; /* the device is already disabled */
518 } 562 }
519 563
520 if (!pnp_can_disable(dev)) { 564 error = pnp_stop_dev(dev);
521 pnp_info("Device %s does not supported disabling.", dev->dev.bus_id); 565 if (error)
522 return -EINVAL; 566 return error;
523 }
524 if (dev->protocol->disable(dev)<0) {
525 pnp_err("Failed to disable device %s.", dev->dev.bus_id);
526 return -EIO;
527 }
528 567
529 dev->active = 0; 568 dev->active = 0;
530 pnp_info("Device %s disabled.", dev->dev.bus_id);
531 569
532 /* release the resources so that other devices can use them */ 570 /* release the resources so that other devices can use them */
533 down(&pnp_res_mutex); 571 down(&pnp_res_mutex);
@@ -558,6 +596,8 @@ EXPORT_SYMBOL(pnp_manual_config_dev);
558#if 0 596#if 0
559EXPORT_SYMBOL(pnp_auto_config_dev); 597EXPORT_SYMBOL(pnp_auto_config_dev);
560#endif 598#endif
599EXPORT_SYMBOL(pnp_start_dev);
600EXPORT_SYMBOL(pnp_stop_dev);
561EXPORT_SYMBOL(pnp_activate_dev); 601EXPORT_SYMBOL(pnp_activate_dev);
562EXPORT_SYMBOL(pnp_disable_dev); 602EXPORT_SYMBOL(pnp_disable_dev);
563EXPORT_SYMBOL(pnp_resource_change); 603EXPORT_SYMBOL(pnp_resource_change);
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index b8b46ab54f4e..c6db14d30ed6 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -453,6 +453,45 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
453 return; 453 return;
454} 454}
455 455
456static void
457pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
458{
459 struct acpi_resource_address64 addr, *p = &addr;
460 acpi_status status;
461 struct pnp_mem * mem;
462 struct pnp_port * port;
463
464 status = acpi_resource_to_address64(r, p);
465 if (!ACPI_SUCCESS(status)) {
466 pnp_warn("PnPACPI: failed to convert resource type %d", r->type);
467 return;
468 }
469
470 if (p->address_length == 0)
471 return;
472
473 if (p->resource_type == ACPI_MEMORY_RANGE) {
474 mem = kcalloc(1, sizeof(struct pnp_mem), GFP_KERNEL);
475 if (!mem)
476 return;
477 mem->min = mem->max = p->minimum;
478 mem->size = p->address_length;
479 mem->align = 0;
480 mem->flags = (p->info.mem.write_protect ==
481 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0;
482 pnp_register_mem_resource(option,mem);
483 } else if (p->resource_type == ACPI_IO_RANGE) {
484 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
485 if (!port)
486 return;
487 port->min = port->max = p->minimum;
488 port->size = p->address_length;
489 port->align = 0;
490 port->flags = PNP_PORT_FLAG_FIXED;
491 pnp_register_port_resource(option,port);
492 }
493}
494
456struct acpipnp_parse_option_s { 495struct acpipnp_parse_option_s {
457 struct pnp_option *option; 496 struct pnp_option *option;
458 struct pnp_option *option_independent; 497 struct pnp_option *option_independent;
@@ -495,6 +534,11 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
495 pnpacpi_parse_fixed_mem32_option(option, 534 pnpacpi_parse_fixed_mem32_option(option,
496 &res->data.fixed_memory32); 535 &res->data.fixed_memory32);
497 break; 536 break;
537 case ACPI_RESOURCE_TYPE_ADDRESS16:
538 case ACPI_RESOURCE_TYPE_ADDRESS32:
539 case ACPI_RESOURCE_TYPE_ADDRESS64:
540 pnpacpi_parse_address_option(option, res);
541 break;
498 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 542 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
499 switch (res->data.start_dpf.compatibility_priority) { 543 switch (res->data.start_dpf.compatibility_priority) {
500 case ACPI_GOOD_CONFIGURATION: 544 case ACPI_GOOD_CONFIGURATION:
@@ -568,11 +612,9 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
568 case ACPI_RESOURCE_TYPE_MEMORY24: 612 case ACPI_RESOURCE_TYPE_MEMORY24:
569 case ACPI_RESOURCE_TYPE_MEMORY32: 613 case ACPI_RESOURCE_TYPE_MEMORY32:
570 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 614 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
571#if 0
572 case ACPI_RESOURCE_TYPE_ADDRESS16: 615 case ACPI_RESOURCE_TYPE_ADDRESS16:
573 case ACPI_RESOURCE_TYPE_ADDRESS32: 616 case ACPI_RESOURCE_TYPE_ADDRESS32:
574 case ACPI_RESOURCE_TYPE_ADDRESS64: 617 case ACPI_RESOURCE_TYPE_ADDRESS64:
575#endif
576 (*res_cnt) ++; 618 (*res_cnt) ++;
577 default: 619 default:
578 return AE_OK; 620 return AE_OK;
@@ -593,11 +635,9 @@ static acpi_status pnpacpi_type_resources(struct acpi_resource *res,
593 case ACPI_RESOURCE_TYPE_MEMORY24: 635 case ACPI_RESOURCE_TYPE_MEMORY24:
594 case ACPI_RESOURCE_TYPE_MEMORY32: 636 case ACPI_RESOURCE_TYPE_MEMORY32:
595 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 637 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
596#if 0
597 case ACPI_RESOURCE_TYPE_ADDRESS16: 638 case ACPI_RESOURCE_TYPE_ADDRESS16:
598 case ACPI_RESOURCE_TYPE_ADDRESS32: 639 case ACPI_RESOURCE_TYPE_ADDRESS32:
599 case ACPI_RESOURCE_TYPE_ADDRESS64: 640 case ACPI_RESOURCE_TYPE_ADDRESS64:
600#endif
601 (*resource)->type = res->type; 641 (*resource)->type = res->type;
602 (*resource)++; 642 (*resource)++;
603 default: 643 default:
diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
index 6b7583f497d0..a1f0b0ba2bfe 100644
--- a/drivers/pnp/pnpbios/bioscalls.c
+++ b/drivers/pnp/pnpbios/bioscalls.c
@@ -31,15 +31,6 @@ static struct {
31} pnp_bios_callpoint; 31} pnp_bios_callpoint;
32 32
33 33
34/* The PnP BIOS entries in the GDT */
35#define PNP_GDT (GDT_ENTRY_PNPBIOS_BASE * 8)
36
37#define PNP_CS32 (PNP_GDT+0x00) /* segment for calling fn */
38#define PNP_CS16 (PNP_GDT+0x08) /* code segment for BIOS */
39#define PNP_DS (PNP_GDT+0x10) /* data segment for BIOS */
40#define PNP_TS1 (PNP_GDT+0x18) /* transfer data segment */
41#define PNP_TS2 (PNP_GDT+0x20) /* another data segment */
42
43/* 34/*
44 * These are some opcodes for a "static asmlinkage" 35 * These are some opcodes for a "static asmlinkage"
45 * As this code is *not* executed inside the linux kernel segment, but in a 36 * As this code is *not* executed inside the linux kernel segment, but in a
@@ -67,16 +58,11 @@ __asm__(
67 ".previous \n" 58 ".previous \n"
68); 59);
69 60
70#define Q_SET_SEL(cpu, selname, address, size) \
71do { \
72set_base(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], __va((u32)(address))); \
73set_limit(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], size); \
74} while(0)
75
76#define Q2_SET_SEL(cpu, selname, address, size) \ 61#define Q2_SET_SEL(cpu, selname, address, size) \
77do { \ 62do { \
78set_base(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], (u32)(address)); \ 63struct desc_struct *gdt = get_cpu_gdt_table((cpu)); \
79set_limit(per_cpu(cpu_gdt_table,cpu)[(selname) >> 3], size); \ 64set_base(gdt[(selname) >> 3], (u32)(address)); \
65set_limit(gdt[(selname) >> 3], size); \
80} while(0) 66} while(0)
81 67
82static struct desc_struct bad_bios_desc = { 0, 0x00409200 }; 68static struct desc_struct bad_bios_desc = { 0, 0x00409200 };
@@ -115,8 +101,8 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
115 return PNP_FUNCTION_NOT_SUPPORTED; 101 return PNP_FUNCTION_NOT_SUPPORTED;
116 102
117 cpu = get_cpu(); 103 cpu = get_cpu();
118 save_desc_40 = per_cpu(cpu_gdt_table,cpu)[0x40 / 8]; 104 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
119 per_cpu(cpu_gdt_table,cpu)[0x40 / 8] = bad_bios_desc; 105 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
120 106
121 /* On some boxes IRQ's during PnP BIOS calls are deadly. */ 107 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
122 spin_lock_irqsave(&pnp_bios_lock, flags); 108 spin_lock_irqsave(&pnp_bios_lock, flags);
@@ -158,7 +144,7 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
158 ); 144 );
159 spin_unlock_irqrestore(&pnp_bios_lock, flags); 145 spin_unlock_irqrestore(&pnp_bios_lock, flags);
160 146
161 per_cpu(cpu_gdt_table,cpu)[0x40 / 8] = save_desc_40; 147 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
162 put_cpu(); 148 put_cpu();
163 149
164 /* If we get here and this is set then the PnP BIOS faulted on us. */ 150 /* If we get here and this is set then the PnP BIOS faulted on us. */
@@ -290,12 +276,15 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
290static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data) 276static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data)
291{ 277{
292 u16 status; 278 u16 status;
279 u16 tmp_nodenum;
293 if (!pnp_bios_present()) 280 if (!pnp_bios_present())
294 return PNP_FUNCTION_NOT_SUPPORTED; 281 return PNP_FUNCTION_NOT_SUPPORTED;
295 if ( !boot && pnpbios_dont_use_current_config ) 282 if ( !boot && pnpbios_dont_use_current_config )
296 return PNP_FUNCTION_NOT_SUPPORTED; 283 return PNP_FUNCTION_NOT_SUPPORTED;
284 tmp_nodenum = *nodenum;
297 status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0, 285 status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0,
298 nodenum, sizeof(char), data, 65536); 286 &tmp_nodenum, sizeof(tmp_nodenum), data, 65536);
287 *nodenum = tmp_nodenum;
299 return status; 288 return status;
300} 289}
301 290
@@ -535,10 +524,12 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
535 524
536 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4)); 525 set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
537 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4)); 526 _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
538 for(i=0; i < NR_CPUS; i++) 527 for (i = 0; i < NR_CPUS; i++) {
539 { 528 struct desc_struct *gdt = get_cpu_gdt_table(i);
540 Q2_SET_SEL(i, PNP_CS32, &pnp_bios_callfunc, 64 * 1024); 529 if (!gdt)
541 Q_SET_SEL(i, PNP_CS16, header->fields.pm16cseg, 64 * 1024); 530 continue;
542 Q_SET_SEL(i, PNP_DS, header->fields.pm16dseg, 64 * 1024); 531 set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc);
543 } 532 set_base(gdt[GDT_ENTRY_PNPBIOS_CS16], __va(header->fields.pm16cseg));
533 set_base(gdt[GDT_ENTRY_PNPBIOS_DS], __va(header->fields.pm16dseg));
534 }
544} 535}
diff --git a/drivers/pnp/pnpbios/core.c b/drivers/pnp/pnpbios/core.c
index f49674f07949..b154b3f52cbe 100644
--- a/drivers/pnp/pnpbios/core.c
+++ b/drivers/pnp/pnpbios/core.c
@@ -56,7 +56,6 @@
56#include <linux/mm.h> 56#include <linux/mm.h>
57#include <linux/smp.h> 57#include <linux/smp.h>
58#include <linux/slab.h> 58#include <linux/slab.h>
59#include <linux/kobject_uevent.h>
60#include <linux/completion.h> 59#include <linux/completion.h>
61#include <linux/spinlock.h> 60#include <linux/spinlock.h>
62#include <linux/dmi.h> 61#include <linux/dmi.h>
@@ -106,8 +105,6 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
106 char *argv [3], **envp, *buf, *scratch; 105 char *argv [3], **envp, *buf, *scratch;
107 int i = 0, value; 106 int i = 0, value;
108 107
109 if (!hotplug_path [0])
110 return -ENOENT;
111 if (!current->fs->root) { 108 if (!current->fs->root) {
112 return -EAGAIN; 109 return -EAGAIN;
113 } 110 }
@@ -119,8 +116,9 @@ static int pnp_dock_event(int dock, struct pnp_docking_station_info *info)
119 return -ENOMEM; 116 return -ENOMEM;
120 } 117 }
121 118
122 /* only one standardized param to hotplug command: type */ 119 /* FIXME: if there are actual users of this, it should be integrated into
123 argv [0] = hotplug_path; 120 * the driver core and use the usual infrastructure like sysfs and uevents */
121 argv [0] = "/sbin/pnpbios";
124 argv [1] = "dock"; 122 argv [1] = "dock";
125 argv [2] = NULL; 123 argv [2] = NULL;
126 124
diff --git a/drivers/s390/Makefile b/drivers/s390/Makefile
index c99a2fe92fb0..9803c9352d78 100644
--- a/drivers/s390/Makefile
+++ b/drivers/s390/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the S/390 specific device drivers 2# Makefile for the S/390 specific device drivers
3# 3#
4 4
5obj-y += s390mach.o sysinfo.o 5obj-y += s390mach.o sysinfo.o s390_rdev.o
6obj-y += cio/ block/ char/ crypto/ net/ scsi/ 6obj-y += cio/ block/ char/ crypto/ net/ scsi/
7 7
8drivers-y += drivers/s390/built-in.o 8drivers-y += drivers/s390/built-in.o
diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig
index 6e7d7b06421d..6f50cc9323d9 100644
--- a/drivers/s390/block/Kconfig
+++ b/drivers/s390/block/Kconfig
@@ -1,11 +1,11 @@
1if ARCH_S390 1if S390
2 2
3comment "S/390 block device drivers" 3comment "S/390 block device drivers"
4 depends on ARCH_S390 4 depends on S390
5 5
6config BLK_DEV_XPRAM 6config BLK_DEV_XPRAM
7 tristate "XPRAM disk support" 7 tristate "XPRAM disk support"
8 depends on ARCH_S390 8 depends on S390
9 help 9 help
10 Select this option if you want to use your expanded storage on S/390 10 Select this option if you want to use your expanded storage on S/390
11 or zSeries as a disk. This is useful as a _fast_ swap device if you 11 or zSeries as a disk. This is useful as a _fast_ swap device if you
@@ -49,7 +49,7 @@ config DASD_FBA
49 49
50config DASD_DIAG 50config DASD_DIAG
51 tristate "Support for DIAG access to Disks" 51 tristate "Support for DIAG access to Disks"
52 depends on DASD && ( ARCH_S390X = 'n' || EXPERIMENTAL) 52 depends on DASD && ( 64BIT = 'n' || EXPERIMENTAL)
53 help 53 help
54 Select this option if you want to use Diagnose250 command to access 54 Select this option if you want to use Diagnose250 command to access
55 Disks under VM. If you are not running under VM or unsure what it is, 55 Disks under VM. If you are not running under VM or unsure what it is,
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 7008d32433bf..f779f674dfa0 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.167 $ 10 * $Revision: 1.172 $
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -604,7 +604,7 @@ dasd_smalloc_request(char *magic, int cplength, int datasize,
604void 604void
605dasd_kfree_request(struct dasd_ccw_req * cqr, struct dasd_device * device) 605dasd_kfree_request(struct dasd_ccw_req * cqr, struct dasd_device * device)
606{ 606{
607#ifdef CONFIG_ARCH_S390X 607#ifdef CONFIG_64BIT
608 struct ccw1 *ccw; 608 struct ccw1 *ccw;
609 609
610 /* Clear any idals used for the request. */ 610 /* Clear any idals used for the request. */
@@ -1035,7 +1035,7 @@ dasd_end_request(struct request *req, int uptodate)
1035 if (end_that_request_first(req, uptodate, req->hard_nr_sectors)) 1035 if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
1036 BUG(); 1036 BUG();
1037 add_disk_randomness(req->rq_disk); 1037 add_disk_randomness(req->rq_disk);
1038 end_that_request_last(req); 1038 end_that_request_last(req, uptodate);
1039} 1039}
1040 1040
1041/* 1041/*
@@ -1224,6 +1224,12 @@ __dasd_start_head(struct dasd_device * device)
1224 if (list_empty(&device->ccw_queue)) 1224 if (list_empty(&device->ccw_queue))
1225 return; 1225 return;
1226 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list); 1226 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1227 /* check FAILFAST */
1228 if (device->stopped & ~DASD_STOPPED_PENDING &&
1229 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) {
1230 cqr->status = DASD_CQR_FAILED;
1231 dasd_schedule_bh(device);
1232 }
1227 if ((cqr->status == DASD_CQR_QUEUED) && 1233 if ((cqr->status == DASD_CQR_QUEUED) &&
1228 (!device->stopped)) { 1234 (!device->stopped)) {
1229 /* try to start the first I/O that can be started */ 1235 /* try to start the first I/O that can be started */
@@ -1323,7 +1329,7 @@ void
1323dasd_schedule_bh(struct dasd_device * device) 1329dasd_schedule_bh(struct dasd_device * device)
1324{ 1330{
1325 /* Protect against rescheduling. */ 1331 /* Protect against rescheduling. */
1326 if (atomic_compare_and_swap (0, 1, &device->tasklet_scheduled)) 1332 if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0)
1327 return; 1333 return;
1328 dasd_get_device(device); 1334 dasd_get_device(device);
1329 tasklet_hi_schedule(&device->tasklet); 1335 tasklet_hi_schedule(&device->tasklet);
@@ -1750,8 +1756,10 @@ dasd_exit(void)
1750 * SECTION: common functions for ccw_driver use 1756 * SECTION: common functions for ccw_driver use
1751 */ 1757 */
1752 1758
1753/* initial attempt at a probe function. this can be simplified once 1759/*
1754 * the other detection code is gone */ 1760 * Initial attempt at a probe function. this can be simplified once
1761 * the other detection code is gone.
1762 */
1755int 1763int
1756dasd_generic_probe (struct ccw_device *cdev, 1764dasd_generic_probe (struct ccw_device *cdev,
1757 struct dasd_discipline *discipline) 1765 struct dasd_discipline *discipline)
@@ -1770,8 +1778,10 @@ dasd_generic_probe (struct ccw_device *cdev,
1770 return ret; 1778 return ret;
1771} 1779}
1772 1780
1773/* this will one day be called from a global not_oper handler. 1781/*
1774 * It is also used by driver_unregister during module unload */ 1782 * This will one day be called from a global not_oper handler.
1783 * It is also used by driver_unregister during module unload.
1784 */
1775void 1785void
1776dasd_generic_remove (struct ccw_device *cdev) 1786dasd_generic_remove (struct ccw_device *cdev)
1777{ 1787{
@@ -1798,9 +1808,11 @@ dasd_generic_remove (struct ccw_device *cdev)
1798 dasd_delete_device(device); 1808 dasd_delete_device(device);
1799} 1809}
1800 1810
1801/* activate a device. This is called from dasd_{eckd,fba}_probe() when either 1811/*
1812 * Activate a device. This is called from dasd_{eckd,fba}_probe() when either
1802 * the device is detected for the first time and is supposed to be used 1813 * the device is detected for the first time and is supposed to be used
1803 * or the user has started activation through sysfs */ 1814 * or the user has started activation through sysfs.
1815 */
1804int 1816int
1805dasd_generic_set_online (struct ccw_device *cdev, 1817dasd_generic_set_online (struct ccw_device *cdev,
1806 struct dasd_discipline *discipline) 1818 struct dasd_discipline *discipline)
@@ -1917,7 +1929,6 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
1917 if (cqr->status == DASD_CQR_IN_IO) 1929 if (cqr->status == DASD_CQR_IN_IO)
1918 cqr->status = DASD_CQR_FAILED; 1930 cqr->status = DASD_CQR_FAILED;
1919 device->stopped |= DASD_STOPPED_DC_EIO; 1931 device->stopped |= DASD_STOPPED_DC_EIO;
1920 dasd_schedule_bh(device);
1921 } else { 1932 } else {
1922 list_for_each_entry(cqr, &device->ccw_queue, list) 1933 list_for_each_entry(cqr, &device->ccw_queue, list)
1923 if (cqr->status == DASD_CQR_IN_IO) { 1934 if (cqr->status == DASD_CQR_IN_IO) {
@@ -1927,6 +1938,7 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
1927 device->stopped |= DASD_STOPPED_DC_WAIT; 1938 device->stopped |= DASD_STOPPED_DC_WAIT;
1928 dasd_set_timer(device, 0); 1939 dasd_set_timer(device, 0);
1929 } 1940 }
1941 dasd_schedule_bh(device);
1930 ret = 1; 1942 ret = 1;
1931 break; 1943 break;
1932 case CIO_OPER: 1944 case CIO_OPER:
diff --git a/drivers/s390/block/dasd_diag.c b/drivers/s390/block/dasd_diag.c
index ab8754e566bc..ba80fdea7ebf 100644
--- a/drivers/s390/block/dasd_diag.c
+++ b/drivers/s390/block/dasd_diag.c
@@ -6,7 +6,7 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.51 $ 9 * $Revision: 1.53 $
10 */ 10 */
11 11
12#include <linux/config.h> 12#include <linux/config.h>
@@ -25,6 +25,7 @@
25#include <asm/io.h> 25#include <asm/io.h>
26#include <asm/s390_ext.h> 26#include <asm/s390_ext.h>
27#include <asm/todclk.h> 27#include <asm/todclk.h>
28#include <asm/vtoc.h>
28 29
29#include "dasd_int.h" 30#include "dasd_int.h"
30#include "dasd_diag.h" 31#include "dasd_diag.h"
@@ -74,7 +75,7 @@ dia250(void *iob, int cmd)
74 int rc; 75 int rc;
75 76
76 __asm__ __volatile__( 77 __asm__ __volatile__(
77#ifdef CONFIG_ARCH_S390X 78#ifdef CONFIG_64BIT
78 " lghi %0,3\n" 79 " lghi %0,3\n"
79 " lgr 0,%3\n" 80 " lgr 0,%3\n"
80 " diag 0,%2,0x250\n" 81 " diag 0,%2,0x250\n"
@@ -329,7 +330,7 @@ dasd_diag_check_device(struct dasd_device *device)
329 struct dasd_diag_private *private; 330 struct dasd_diag_private *private;
330 struct dasd_diag_characteristics *rdc_data; 331 struct dasd_diag_characteristics *rdc_data;
331 struct dasd_diag_bio bio; 332 struct dasd_diag_bio bio;
332 struct dasd_diag_cms_label *label; 333 struct vtoc_cms_label *label;
333 blocknum_t end_block; 334 blocknum_t end_block;
334 unsigned int sb, bsize; 335 unsigned int sb, bsize;
335 int rc; 336 int rc;
@@ -380,7 +381,7 @@ dasd_diag_check_device(struct dasd_device *device)
380 mdsk_term_io(device); 381 mdsk_term_io(device);
381 382
382 /* figure out blocksize of device */ 383 /* figure out blocksize of device */
383 label = (struct dasd_diag_cms_label *) get_zeroed_page(GFP_KERNEL); 384 label = (struct vtoc_cms_label *) get_zeroed_page(GFP_KERNEL);
384 if (label == NULL) { 385 if (label == NULL) {
385 DEV_MESSAGE(KERN_WARNING, device, "%s", 386 DEV_MESSAGE(KERN_WARNING, device, "%s",
386 "No memory to allocate initialization request"); 387 "No memory to allocate initialization request");
@@ -548,6 +549,8 @@ dasd_diag_build_cp(struct dasd_device * device, struct request *req)
548 } 549 }
549 cqr->retries = DIAG_MAX_RETRIES; 550 cqr->retries = DIAG_MAX_RETRIES;
550 cqr->buildclk = get_clock(); 551 cqr->buildclk = get_clock();
552 if (req->flags & REQ_FAILFAST)
553 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
551 cqr->device = device; 554 cqr->device = device;
552 cqr->expires = DIAG_TIMEOUT; 555 cqr->expires = DIAG_TIMEOUT;
553 cqr->status = DASD_CQR_FILLED; 556 cqr->status = DASD_CQR_FILLED;
diff --git a/drivers/s390/block/dasd_diag.h b/drivers/s390/block/dasd_diag.h
index df31484d73a7..a4f80bd735f1 100644
--- a/drivers/s390/block/dasd_diag.h
+++ b/drivers/s390/block/dasd_diag.h
@@ -6,7 +6,7 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.8 $ 9 * $Revision: 1.9 $
10 */ 10 */
11 11
12#define MDSK_WRITE_REQ 0x01 12#define MDSK_WRITE_REQ 0x01
@@ -44,29 +44,8 @@ struct dasd_diag_characteristics {
44 u8 rdev_features; 44 u8 rdev_features;
45} __attribute__ ((packed, aligned(4))); 45} __attribute__ ((packed, aligned(4)));
46 46
47struct dasd_diag_cms_label { 47
48 u8 label_id[4]; 48#ifdef CONFIG_64BIT
49 u8 vol_id[6];
50 u16 version_id;
51 u32 block_size;
52 u32 origin_ptr;
53 u32 usable_count;
54 u32 formatted_count;
55 u32 block_count;
56 u32 used_count;
57 u32 fst_size;
58 u32 fst_count;
59 u8 format_date[6];
60 u8 reserved1[2];
61 u32 disk_offset;
62 u32 map_block;
63 u32 hblk_disp;
64 u32 user_disp;
65 u8 reserved2[4];
66 u8 segment_name[8];
67} __attribute__ ((packed));
68
69#ifdef CONFIG_ARCH_S390X
70#define DASD_DIAG_FLAGA_DEFAULT DASD_DIAG_FLAGA_FORMAT_64BIT 49#define DASD_DIAG_FLAGA_DEFAULT DASD_DIAG_FLAGA_FORMAT_64BIT
71 50
72typedef u64 blocknum_t; 51typedef u64 blocknum_t;
@@ -107,7 +86,7 @@ struct dasd_diag_rw_io {
107 struct dasd_diag_bio *bio_list; 86 struct dasd_diag_bio *bio_list;
108 u8 spare4[8]; 87 u8 spare4[8];
109} __attribute__ ((packed, aligned(8))); 88} __attribute__ ((packed, aligned(8)));
110#else /* CONFIG_ARCH_S390X */ 89#else /* CONFIG_64BIT */
111#define DASD_DIAG_FLAGA_DEFAULT 0x0 90#define DASD_DIAG_FLAGA_DEFAULT 0x0
112 91
113typedef u32 blocknum_t; 92typedef u32 blocknum_t;
@@ -146,4 +125,4 @@ struct dasd_diag_rw_io {
146 u32 interrupt_params; 125 u32 interrupt_params;
147 u8 spare3[20]; 126 u8 spare3[20];
148} __attribute__ ((packed, aligned(8))); 127} __attribute__ ((packed, aligned(8)));
149#endif /* CONFIG_ARCH_S390X */ 128#endif /* CONFIG_64BIT */
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 811060e10c00..96eb48258580 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
9 * 9 *
10 * $Revision: 1.71 $ 10 * $Revision: 1.74 $
11 */ 11 */
12 12
13#include <linux/config.h> 13#include <linux/config.h>
@@ -1041,7 +1041,7 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1041 /* Eckd can only do full blocks. */ 1041 /* Eckd can only do full blocks. */
1042 return ERR_PTR(-EINVAL); 1042 return ERR_PTR(-EINVAL);
1043 count += bv->bv_len >> (device->s2b_shift + 9); 1043 count += bv->bv_len >> (device->s2b_shift + 9);
1044#if defined(CONFIG_ARCH_S390X) 1044#if defined(CONFIG_64BIT)
1045 if (idal_is_needed (page_address(bv->bv_page), 1045 if (idal_is_needed (page_address(bv->bv_page),
1046 bv->bv_len)) 1046 bv->bv_len))
1047 cidaw += bv->bv_len >> (device->s2b_shift + 9); 1047 cidaw += bv->bv_len >> (device->s2b_shift + 9);
@@ -1136,6 +1136,8 @@ dasd_eckd_build_cp(struct dasd_device * device, struct request *req)
1136 recid++; 1136 recid++;
1137 } 1137 }
1138 } 1138 }
1139 if (req->flags & REQ_FAILFAST)
1140 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1139 cqr->device = device; 1141 cqr->device = device;
1140 cqr->expires = 5 * 60 * HZ; /* 5 minutes */ 1142 cqr->expires = 5 * 60 * HZ; /* 5 minutes */
1141 cqr->lpm = private->path_data.ppm; 1143 cqr->lpm = private->path_data.ppm;
@@ -1252,6 +1254,7 @@ dasd_eckd_release(struct block_device *bdev, int no, long args)
1252 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data; 1254 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
1253 cqr->device = device; 1255 cqr->device = device;
1254 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); 1256 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1257 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1255 cqr->retries = 0; 1258 cqr->retries = 0;
1256 cqr->expires = 2 * HZ; 1259 cqr->expires = 2 * HZ;
1257 cqr->buildclk = get_clock(); 1260 cqr->buildclk = get_clock();
@@ -1296,6 +1299,7 @@ dasd_eckd_reserve(struct block_device *bdev, int no, long args)
1296 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data; 1299 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
1297 cqr->device = device; 1300 cqr->device = device;
1298 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); 1301 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1302 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1299 cqr->retries = 0; 1303 cqr->retries = 0;
1300 cqr->expires = 2 * HZ; 1304 cqr->expires = 2 * HZ;
1301 cqr->buildclk = get_clock(); 1305 cqr->buildclk = get_clock();
@@ -1339,6 +1343,7 @@ dasd_eckd_steal_lock(struct block_device *bdev, int no, long args)
1339 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data; 1343 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
1340 cqr->device = device; 1344 cqr->device = device;
1341 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags); 1345 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1346 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1342 cqr->retries = 0; 1347 cqr->retries = 0;
1343 cqr->expires = 2 * HZ; 1348 cqr->expires = 2 * HZ;
1344 cqr->buildclk = get_clock(); 1349 cqr->buildclk = get_clock();
diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
index 28cb4613b7f5..8ec75dc08e2c 100644
--- a/drivers/s390/block/dasd_fba.c
+++ b/drivers/s390/block/dasd_fba.c
@@ -4,7 +4,7 @@
4 * Bugreports.to..: <Linux390@de.ibm.com> 4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 5 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
6 * 6 *
7 * $Revision: 1.40 $ 7 * $Revision: 1.41 $
8 */ 8 */
9 9
10#include <linux/config.h> 10#include <linux/config.h>
@@ -271,7 +271,7 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
271 /* Fba can only do full blocks. */ 271 /* Fba can only do full blocks. */
272 return ERR_PTR(-EINVAL); 272 return ERR_PTR(-EINVAL);
273 count += bv->bv_len >> (device->s2b_shift + 9); 273 count += bv->bv_len >> (device->s2b_shift + 9);
274#if defined(CONFIG_ARCH_S390X) 274#if defined(CONFIG_64BIT)
275 if (idal_is_needed (page_address(bv->bv_page), 275 if (idal_is_needed (page_address(bv->bv_page),
276 bv->bv_len)) 276 bv->bv_len))
277 cidaw += bv->bv_len / blksize; 277 cidaw += bv->bv_len / blksize;
@@ -352,6 +352,8 @@ dasd_fba_build_cp(struct dasd_device * device, struct request *req)
352 recid++; 352 recid++;
353 } 353 }
354 } 354 }
355 if (req->flags & REQ_FAILFAST)
356 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
355 cqr->device = device; 357 cqr->device = device;
356 cqr->expires = 5 * 60 * HZ; /* 5 minutes */ 358 cqr->expires = 5 * 60 * HZ; /* 5 minutes */
357 cqr->retries = 32; 359 cqr->retries = 32;
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 9fab04f3056d..2fb05c4a528c 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -6,7 +6,7 @@
6 * Bugreports.to..: <Linux390@de.ibm.com> 6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 7 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
8 * 8 *
9 * $Revision: 1.65 $ 9 * $Revision: 1.68 $
10 */ 10 */
11 11
12#ifndef DASD_INT_H 12#ifndef DASD_INT_H
@@ -208,6 +208,7 @@ struct dasd_ccw_req {
208 208
209/* per dasd_ccw_req flags */ 209/* per dasd_ccw_req flags */
210#define DASD_CQR_FLAGS_USE_ERP 0 /* use ERP for this request */ 210#define DASD_CQR_FLAGS_USE_ERP 0 /* use ERP for this request */
211#define DASD_CQR_FLAGS_FAILFAST 1 /* FAILFAST */
211 212
212/* Signature for error recovery functions. */ 213/* Signature for error recovery functions. */
213typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *); 214typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *);
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index 789595b3fa09..044b75371990 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -7,7 +7,7 @@
7 * Bugreports.to..: <Linux390@de.ibm.com> 7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
9 * 9 *
10 * $Revision: 1.47 $ 10 * $Revision: 1.50 $
11 * 11 *
12 * i/o controls for the dasd driver. 12 * i/o controls for the dasd driver.
13 */ 13 */
@@ -352,6 +352,9 @@ dasd_ioctl_read_profile(struct block_device *bdev, int no, long args)
352 if (device == NULL) 352 if (device == NULL)
353 return -ENODEV; 353 return -ENODEV;
354 354
355 if (dasd_profile_level == DASD_PROFILE_OFF)
356 return -EIO;
357
355 if (copy_to_user((long __user *) args, (long *) &device->profile, 358 if (copy_to_user((long __user *) args, (long *) &device->profile,
356 sizeof (struct dasd_profile_info_t))) 359 sizeof (struct dasd_profile_info_t)))
357 return -EFAULT; 360 return -EFAULT;
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index 4fde41188996..2e727f49ad19 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -15,7 +15,7 @@
15#include <asm/io.h> 15#include <asm/io.h>
16#include <linux/completion.h> 16#include <linux/completion.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <asm/ccwdev.h> // for s390_root_dev_(un)register() 18#include <asm/s390_rdev.h>
19 19
20//#define DCSSBLK_DEBUG /* Debug messages on/off */ 20//#define DCSSBLK_DEBUG /* Debug messages on/off */
21#define DCSSBLK_NAME "dcssblk" 21#define DCSSBLK_NAME "dcssblk"
diff --git a/drivers/s390/block/xpram.c b/drivers/s390/block/xpram.c
index d428c909b8a0..bf3a67c3cc5e 100644
--- a/drivers/s390/block/xpram.c
+++ b/drivers/s390/block/xpram.c
@@ -160,7 +160,7 @@ static int xpram_page_in (unsigned long page_addr, unsigned int xpage_index)
160 "0: ipm %0\n" 160 "0: ipm %0\n"
161 " srl %0,28\n" 161 " srl %0,28\n"
162 "1:\n" 162 "1:\n"
163#ifndef CONFIG_ARCH_S390X 163#ifndef CONFIG_64BIT
164 ".section __ex_table,\"a\"\n" 164 ".section __ex_table,\"a\"\n"
165 " .align 4\n" 165 " .align 4\n"
166 " .long 0b,1b\n" 166 " .long 0b,1b\n"
@@ -208,7 +208,7 @@ static long xpram_page_out (unsigned long page_addr, unsigned int xpage_index)
208 "0: ipm %0\n" 208 "0: ipm %0\n"
209 " srl %0,28\n" 209 " srl %0,28\n"
210 "1:\n" 210 "1:\n"
211#ifndef CONFIG_ARCH_S390X 211#ifndef CONFIG_64BIT
212 ".section __ex_table,\"a\"\n" 212 ".section __ex_table,\"a\"\n"
213 " .align 4\n" 213 " .align 4\n"
214 " .long 0b,1b\n" 214 " .long 0b,1b\n"
diff --git a/drivers/s390/char/sclp_cpi.c b/drivers/s390/char/sclp_cpi.c
index 5a6cef2dfa13..80f7f31310e6 100644
--- a/drivers/s390/char/sclp_cpi.c
+++ b/drivers/s390/char/sclp_cpi.c
@@ -204,7 +204,7 @@ cpi_module_init(void)
204 printk(KERN_WARNING "cpi: no control program identification " 204 printk(KERN_WARNING "cpi: no control program identification "
205 "support\n"); 205 "support\n");
206 sclp_unregister(&sclp_cpi_event); 206 sclp_unregister(&sclp_cpi_event);
207 return -ENOTSUPP; 207 return -EOPNOTSUPP;
208 } 208 }
209 209
210 req = cpi_prepare_req(); 210 req = cpi_prepare_req();
diff --git a/drivers/s390/char/sclp_quiesce.c b/drivers/s390/char/sclp_quiesce.c
index 83f75774df60..56fa69168898 100644
--- a/drivers/s390/char/sclp_quiesce.c
+++ b/drivers/s390/char/sclp_quiesce.c
@@ -32,7 +32,7 @@ do_load_quiesce_psw(void * __unused)
32 psw_t quiesce_psw; 32 psw_t quiesce_psw;
33 int cpu; 33 int cpu;
34 34
35 if (atomic_compare_and_swap(-1, smp_processor_id(), &cpuid)) 35 if (atomic_cmpxchg(&cpuid, -1, smp_processor_id()) != -1)
36 signal_processor(smp_processor_id(), sigp_stop); 36 signal_processor(smp_processor_id(), sigp_stop);
37 /* Wait for all other cpus to enter stopped state */ 37 /* Wait for all other cpus to enter stopped state */
38 for_each_online_cpu(cpu) { 38 for_each_online_cpu(cpu) {
diff --git a/drivers/s390/char/tape_block.c b/drivers/s390/char/tape_block.c
index 1efc9f21229e..5ced2725d6c7 100644
--- a/drivers/s390/char/tape_block.c
+++ b/drivers/s390/char/tape_block.c
@@ -65,7 +65,7 @@ static void
65tapeblock_trigger_requeue(struct tape_device *device) 65tapeblock_trigger_requeue(struct tape_device *device)
66{ 66{
67 /* Protect against rescheduling. */ 67 /* Protect against rescheduling. */
68 if (atomic_compare_and_swap(0, 1, &device->blk_data.requeue_scheduled)) 68 if (atomic_cmpxchg(&device->blk_data.requeue_scheduled, 0, 1) != 0)
69 return; 69 return;
70 schedule_work(&device->blk_data.requeue_task); 70 schedule_work(&device->blk_data.requeue_task);
71} 71}
@@ -78,7 +78,7 @@ tapeblock_end_request(struct request *req, int uptodate)
78{ 78{
79 if (end_that_request_first(req, uptodate, req->hard_nr_sectors)) 79 if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
80 BUG(); 80 BUG();
81 end_that_request_last(req); 81 end_that_request_last(req, uptodate);
82} 82}
83 83
84static void 84static void
diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c
index 5473c23fcb52..5acc0ace3d7d 100644
--- a/drivers/s390/char/vmwatchdog.c
+++ b/drivers/s390/char/vmwatchdog.c
@@ -66,7 +66,7 @@ static int __diag288(enum vmwdt_func func, unsigned int timeout,
66 __cmdl = len; 66 __cmdl = len;
67 err = 0; 67 err = 0;
68 asm volatile ( 68 asm volatile (
69#ifdef __s390x__ 69#ifdef CONFIG_64BIT
70 "diag %2,%4,0x288\n" 70 "diag %2,%4,0x288\n"
71 "1: \n" 71 "1: \n"
72 ".section .fixup,\"ax\"\n" 72 ".section .fixup,\"ax\"\n"
diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c
index a1c52a682191..daf21e03b21d 100644
--- a/drivers/s390/cio/blacklist.c
+++ b/drivers/s390/cio/blacklist.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/blacklist.c 2 * drivers/s390/cio/blacklist.c
3 * S/390 common I/O routines -- blacklisting of specific devices 3 * S/390 common I/O routines -- blacklisting of specific devices
4 * $Revision: 1.35 $ 4 * $Revision: 1.39 $
5 * 5 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -15,6 +15,7 @@
15#include <linux/vmalloc.h> 15#include <linux/vmalloc.h>
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/proc_fs.h> 17#include <linux/proc_fs.h>
18#include <linux/seq_file.h>
18#include <linux/ctype.h> 19#include <linux/ctype.h>
19#include <linux/device.h> 20#include <linux/device.h>
20 21
@@ -34,10 +35,10 @@
34 * These can be single devices or ranges of devices 35 * These can be single devices or ranges of devices
35 */ 36 */
36 37
37/* 65536 bits to indicate if a devno is blacklisted or not */ 38/* 65536 bits for each set to indicate if a devno is blacklisted or not */
38#define __BL_DEV_WORDS ((__MAX_SUBCHANNELS + (8*sizeof(long) - 1)) / \ 39#define __BL_DEV_WORDS ((__MAX_SUBCHANNEL + (8*sizeof(long) - 1)) / \
39 (8*sizeof(long))) 40 (8*sizeof(long)))
40static unsigned long bl_dev[__BL_DEV_WORDS]; 41static unsigned long bl_dev[__MAX_SSID + 1][__BL_DEV_WORDS];
41typedef enum {add, free} range_action; 42typedef enum {add, free} range_action;
42 43
43/* 44/*
@@ -45,21 +46,23 @@ typedef enum {add, free} range_action;
45 * (Un-)blacklist the devices from-to 46 * (Un-)blacklist the devices from-to
46 */ 47 */
47static inline void 48static inline void
48blacklist_range (range_action action, unsigned int from, unsigned int to) 49blacklist_range (range_action action, unsigned int from, unsigned int to,
50 unsigned int ssid)
49{ 51{
50 if (!to) 52 if (!to)
51 to = from; 53 to = from;
52 54
53 if (from > to || to > __MAX_SUBCHANNELS) { 55 if (from > to || to > __MAX_SUBCHANNEL || ssid > __MAX_SSID) {
54 printk (KERN_WARNING "Invalid blacklist range " 56 printk (KERN_WARNING "Invalid blacklist range "
55 "0x%04x to 0x%04x, skipping\n", from, to); 57 "0.%x.%04x to 0.%x.%04x, skipping\n",
58 ssid, from, ssid, to);
56 return; 59 return;
57 } 60 }
58 for (; from <= to; from++) { 61 for (; from <= to; from++) {
59 if (action == add) 62 if (action == add)
60 set_bit (from, bl_dev); 63 set_bit (from, bl_dev[ssid]);
61 else 64 else
62 clear_bit (from, bl_dev); 65 clear_bit (from, bl_dev[ssid]);
63 } 66 }
64} 67}
65 68
@@ -69,7 +72,7 @@ blacklist_range (range_action action, unsigned int from, unsigned int to)
69 * Shamelessly grabbed from dasd_devmap.c. 72 * Shamelessly grabbed from dasd_devmap.c.
70 */ 73 */
71static inline int 74static inline int
72blacklist_busid(char **str, int *id0, int *id1, int *devno) 75blacklist_busid(char **str, int *id0, int *ssid, int *devno)
73{ 76{
74 int val, old_style; 77 int val, old_style;
75 char *sav; 78 char *sav;
@@ -86,7 +89,7 @@ blacklist_busid(char **str, int *id0, int *id1, int *devno)
86 goto confused; 89 goto confused;
87 val = simple_strtoul(*str, str, 16); 90 val = simple_strtoul(*str, str, 16);
88 if (old_style || (*str)[0] != '.') { 91 if (old_style || (*str)[0] != '.') {
89 *id0 = *id1 = 0; 92 *id0 = *ssid = 0;
90 if (val < 0 || val > 0xffff) 93 if (val < 0 || val > 0xffff)
91 goto confused; 94 goto confused;
92 *devno = val; 95 *devno = val;
@@ -105,7 +108,7 @@ blacklist_busid(char **str, int *id0, int *id1, int *devno)
105 val = simple_strtoul(*str, str, 16); 108 val = simple_strtoul(*str, str, 16);
106 if (val < 0 || val > 0xff || (*str)++[0] != '.') 109 if (val < 0 || val > 0xff || (*str)++[0] != '.')
107 goto confused; 110 goto confused;
108 *id1 = val; 111 *ssid = val;
109 if (!isxdigit((*str)[0])) /* We require at least one hex digit */ 112 if (!isxdigit((*str)[0])) /* We require at least one hex digit */
110 goto confused; 113 goto confused;
111 val = simple_strtoul(*str, str, 16); 114 val = simple_strtoul(*str, str, 16);
@@ -125,7 +128,7 @@ confused:
125static inline int 128static inline int
126blacklist_parse_parameters (char *str, range_action action) 129blacklist_parse_parameters (char *str, range_action action)
127{ 130{
128 unsigned int from, to, from_id0, to_id0, from_id1, to_id1; 131 unsigned int from, to, from_id0, to_id0, from_ssid, to_ssid;
129 132
130 while (*str != 0 && *str != '\n') { 133 while (*str != 0 && *str != '\n') {
131 range_action ra = action; 134 range_action ra = action;
@@ -142,23 +145,25 @@ blacklist_parse_parameters (char *str, range_action action)
142 */ 145 */
143 if (strncmp(str,"all,",4) == 0 || strcmp(str,"all") == 0 || 146 if (strncmp(str,"all,",4) == 0 || strcmp(str,"all") == 0 ||
144 strncmp(str,"all\n",4) == 0 || strncmp(str,"all ",4) == 0) { 147 strncmp(str,"all\n",4) == 0 || strncmp(str,"all ",4) == 0) {
145 from = 0; 148 int j;
146 to = __MAX_SUBCHANNELS; 149
147 str += 3; 150 str += 3;
151 for (j=0; j <= __MAX_SSID; j++)
152 blacklist_range(ra, 0, __MAX_SUBCHANNEL, j);
148 } else { 153 } else {
149 int rc; 154 int rc;
150 155
151 rc = blacklist_busid(&str, &from_id0, 156 rc = blacklist_busid(&str, &from_id0,
152 &from_id1, &from); 157 &from_ssid, &from);
153 if (rc) 158 if (rc)
154 continue; 159 continue;
155 to = from; 160 to = from;
156 to_id0 = from_id0; 161 to_id0 = from_id0;
157 to_id1 = from_id1; 162 to_ssid = from_ssid;
158 if (*str == '-') { 163 if (*str == '-') {
159 str++; 164 str++;
160 rc = blacklist_busid(&str, &to_id0, 165 rc = blacklist_busid(&str, &to_id0,
161 &to_id1, &to); 166 &to_ssid, &to);
162 if (rc) 167 if (rc)
163 continue; 168 continue;
164 } 169 }
@@ -168,18 +173,19 @@ blacklist_parse_parameters (char *str, range_action action)
168 strsep(&str, ",\n")); 173 strsep(&str, ",\n"));
169 continue; 174 continue;
170 } 175 }
171 if ((from_id0 != to_id0) || (from_id1 != to_id1)) { 176 if ((from_id0 != to_id0) ||
177 (from_ssid != to_ssid)) {
172 printk(KERN_WARNING "invalid cio_ignore range " 178 printk(KERN_WARNING "invalid cio_ignore range "
173 "%x.%x.%04x-%x.%x.%04x\n", 179 "%x.%x.%04x-%x.%x.%04x\n",
174 from_id0, from_id1, from, 180 from_id0, from_ssid, from,
175 to_id0, to_id1, to); 181 to_id0, to_ssid, to);
176 continue; 182 continue;
177 } 183 }
184 pr_debug("blacklist_setup: adding range "
185 "from %x.%x.%04x to %x.%x.%04x\n",
186 from_id0, from_ssid, from, to_id0, to_ssid, to);
187 blacklist_range (ra, from, to, to_ssid);
178 } 188 }
179 /* FIXME: ignoring id0 and id1 here. */
180 pr_debug("blacklist_setup: adding range "
181 "from 0.0.%04x to 0.0.%04x\n", from, to);
182 blacklist_range (ra, from, to);
183 } 189 }
184 return 1; 190 return 1;
185} 191}
@@ -213,12 +219,33 @@ __setup ("cio_ignore=", blacklist_setup);
213 * Used by validate_subchannel() 219 * Used by validate_subchannel()
214 */ 220 */
215int 221int
216is_blacklisted (int devno) 222is_blacklisted (int ssid, int devno)
217{ 223{
218 return test_bit (devno, bl_dev); 224 return test_bit (devno, bl_dev[ssid]);
219} 225}
220 226
221#ifdef CONFIG_PROC_FS 227#ifdef CONFIG_PROC_FS
228static int
229__s390_redo_validation(struct subchannel_id schid, void *data)
230{
231 int ret;
232 struct subchannel *sch;
233
234 sch = get_subchannel_by_schid(schid);
235 if (sch) {
236 /* Already known. */
237 put_device(&sch->dev);
238 return 0;
239 }
240 ret = css_probe_device(schid);
241 if (ret == -ENXIO)
242 return ret; /* We're through. */
243 if (ret == -ENOMEM)
244 /* Stop validation for now. Bad, but no need for a panic. */
245 return ret;
246 return 0;
247}
248
222/* 249/*
223 * Function: s390_redo_validation 250 * Function: s390_redo_validation
224 * Look for no longer blacklisted devices 251 * Look for no longer blacklisted devices
@@ -226,29 +253,9 @@ is_blacklisted (int devno)
226static inline void 253static inline void
227s390_redo_validation (void) 254s390_redo_validation (void)
228{ 255{
229 unsigned int irq;
230
231 CIO_TRACE_EVENT (0, "redoval"); 256 CIO_TRACE_EVENT (0, "redoval");
232 for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { 257
233 int ret; 258 for_each_subchannel(__s390_redo_validation, NULL);
234 struct subchannel *sch;
235
236 sch = get_subchannel_by_schid(irq);
237 if (sch) {
238 /* Already known. */
239 put_device(&sch->dev);
240 continue;
241 }
242 ret = css_probe_device(irq);
243 if (ret == -ENXIO)
244 break; /* We're through. */
245 if (ret == -ENOMEM)
246 /*
247 * Stop validation for now. Bad, but no need for a
248 * panic.
249 */
250 break;
251 }
252} 259}
253 260
254/* 261/*
@@ -278,41 +285,90 @@ blacklist_parse_proc_parameters (char *buf)
278 s390_redo_validation (); 285 s390_redo_validation ();
279} 286}
280 287
281/* FIXME: These should be real bus ids and not home-grown ones! */ 288/* Iterator struct for all devices. */
282static int cio_ignore_read (char *page, char **start, off_t off, 289struct ccwdev_iter {
283 int count, int *eof, void *data) 290 int devno;
291 int ssid;
292 int in_range;
293};
294
295static void *
296cio_ignore_proc_seq_start(struct seq_file *s, loff_t *offset)
284{ 297{
285 const unsigned int entry_size = 18; /* "0.0.ABCD-0.0.EFGH\n" */ 298 struct ccwdev_iter *iter;
286 long devno; 299
287 int len; 300 if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
288 301 return NULL;
289 len = 0; 302 iter = kzalloc(sizeof(struct ccwdev_iter), GFP_KERNEL);
290 for (devno = off; /* abuse the page variable 303 if (!iter)
291 * as counter, see fs/proc/generic.c */ 304 return ERR_PTR(-ENOMEM);
292 devno < __MAX_SUBCHANNELS && len + entry_size < count; devno++) { 305 iter->ssid = *offset / (__MAX_SUBCHANNEL + 1);
293 if (!test_bit(devno, bl_dev)) 306 iter->devno = *offset % (__MAX_SUBCHANNEL + 1);
294 continue; 307 return iter;
295 len += sprintf(page + len, "0.0.%04lx", devno); 308}
296 if (test_bit(devno + 1, bl_dev)) { /* print range */ 309
297 while (++devno < __MAX_SUBCHANNELS) 310static void
298 if (!test_bit(devno, bl_dev)) 311cio_ignore_proc_seq_stop(struct seq_file *s, void *it)
299 break; 312{
300 len += sprintf(page + len, "-0.0.%04lx", --devno); 313 if (!IS_ERR(it))
301 } 314 kfree(it);
302 len += sprintf(page + len, "\n"); 315}
303 } 316
317static void *
318cio_ignore_proc_seq_next(struct seq_file *s, void *it, loff_t *offset)
319{
320 struct ccwdev_iter *iter;
321
322 if (*offset >= (__MAX_SUBCHANNEL + 1) * (__MAX_SSID + 1))
323 return NULL;
324 iter = it;
325 if (iter->devno == __MAX_SUBCHANNEL) {
326 iter->devno = 0;
327 iter->ssid++;
328 if (iter->ssid > __MAX_SSID)
329 return NULL;
330 } else
331 iter->devno++;
332 (*offset)++;
333 return iter;
334}
304 335
305 if (devno < __MAX_SUBCHANNELS) 336static int
306 *eof = 1; 337cio_ignore_proc_seq_show(struct seq_file *s, void *it)
307 *start = (char *) (devno - off); /* number of checked entries */ 338{
308 return len; 339 struct ccwdev_iter *iter;
340
341 iter = it;
342 if (!is_blacklisted(iter->ssid, iter->devno))
343 /* Not blacklisted, nothing to output. */
344 return 0;
345 if (!iter->in_range) {
346 /* First device in range. */
347 if ((iter->devno == __MAX_SUBCHANNEL) ||
348 !is_blacklisted(iter->ssid, iter->devno + 1))
349 /* Singular device. */
350 return seq_printf(s, "0.%x.%04x\n",
351 iter->ssid, iter->devno);
352 iter->in_range = 1;
353 return seq_printf(s, "0.%x.%04x-", iter->ssid, iter->devno);
354 }
355 if ((iter->devno == __MAX_SUBCHANNEL) ||
356 !is_blacklisted(iter->ssid, iter->devno + 1)) {
357 /* Last device in range. */
358 iter->in_range = 0;
359 return seq_printf(s, "0.%x.%04x\n", iter->ssid, iter->devno);
360 }
361 return 0;
309} 362}
310 363
311static int cio_ignore_write(struct file *file, const char __user *user_buf, 364static ssize_t
312 unsigned long user_len, void *data) 365cio_ignore_write(struct file *file, const char __user *user_buf,
366 size_t user_len, loff_t *offset)
313{ 367{
314 char *buf; 368 char *buf;
315 369
370 if (*offset)
371 return -EINVAL;
316 if (user_len > 65536) 372 if (user_len > 65536)
317 user_len = 65536; 373 user_len = 65536;
318 buf = vmalloc (user_len + 1); /* maybe better use the stack? */ 374 buf = vmalloc (user_len + 1); /* maybe better use the stack? */
@@ -330,6 +386,27 @@ static int cio_ignore_write(struct file *file, const char __user *user_buf,
330 return user_len; 386 return user_len;
331} 387}
332 388
389static struct seq_operations cio_ignore_proc_seq_ops = {
390 .start = cio_ignore_proc_seq_start,
391 .stop = cio_ignore_proc_seq_stop,
392 .next = cio_ignore_proc_seq_next,
393 .show = cio_ignore_proc_seq_show,
394};
395
396static int
397cio_ignore_proc_open(struct inode *inode, struct file *file)
398{
399 return seq_open(file, &cio_ignore_proc_seq_ops);
400}
401
402static struct file_operations cio_ignore_proc_fops = {
403 .open = cio_ignore_proc_open,
404 .read = seq_read,
405 .llseek = seq_lseek,
406 .release = seq_release,
407 .write = cio_ignore_write,
408};
409
333static int 410static int
334cio_ignore_proc_init (void) 411cio_ignore_proc_init (void)
335{ 412{
@@ -340,8 +417,7 @@ cio_ignore_proc_init (void)
340 if (!entry) 417 if (!entry)
341 return 0; 418 return 0;
342 419
343 entry->read_proc = cio_ignore_read; 420 entry->proc_fops = &cio_ignore_proc_fops;
344 entry->write_proc = cio_ignore_write;
345 421
346 return 1; 422 return 1;
347} 423}
diff --git a/drivers/s390/cio/blacklist.h b/drivers/s390/cio/blacklist.h
index fb42cafbe57c..95e25c1df922 100644
--- a/drivers/s390/cio/blacklist.h
+++ b/drivers/s390/cio/blacklist.h
@@ -1,6 +1,6 @@
1#ifndef S390_BLACKLIST_H 1#ifndef S390_BLACKLIST_H
2#define S390_BLACKLIST_H 2#define S390_BLACKLIST_H
3 3
4extern int is_blacklisted (int devno); 4extern int is_blacklisted (int ssid, int devno);
5 5
6#endif 6#endif
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index e7bd7f37f080..e849289d4f3c 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/ccwgroup.c 2 * drivers/s390/cio/ccwgroup.c
3 * bus driver for ccwgroup 3 * bus driver for ccwgroup
4 * $Revision: 1.32 $ 4 * $Revision: 1.33 $
5 * 5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -45,7 +45,7 @@ ccwgroup_bus_match (struct device * dev, struct device_driver * drv)
45 return 0; 45 return 0;
46} 46}
47static int 47static int
48ccwgroup_hotplug (struct device *dev, char **envp, int num_envp, char *buffer, 48ccwgroup_uevent (struct device *dev, char **envp, int num_envp, char *buffer,
49 int buffer_size) 49 int buffer_size)
50{ 50{
51 /* TODO */ 51 /* TODO */
@@ -55,7 +55,7 @@ ccwgroup_hotplug (struct device *dev, char **envp, int num_envp, char *buffer,
55static struct bus_type ccwgroup_bus_type = { 55static struct bus_type ccwgroup_bus_type = {
56 .name = "ccwgroup", 56 .name = "ccwgroup",
57 .match = ccwgroup_bus_match, 57 .match = ccwgroup_bus_match,
58 .hotplug = ccwgroup_hotplug, 58 .uevent = ccwgroup_uevent,
59}; 59};
60 60
61static inline void 61static inline void
@@ -263,7 +263,7 @@ ccwgroup_set_online(struct ccwgroup_device *gdev)
263 struct ccwgroup_driver *gdrv; 263 struct ccwgroup_driver *gdrv;
264 int ret; 264 int ret;
265 265
266 if (atomic_compare_and_swap(0, 1, &gdev->onoff)) 266 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0)
267 return -EAGAIN; 267 return -EAGAIN;
268 if (gdev->state == CCWGROUP_ONLINE) { 268 if (gdev->state == CCWGROUP_ONLINE) {
269 ret = 0; 269 ret = 0;
@@ -289,7 +289,7 @@ ccwgroup_set_offline(struct ccwgroup_device *gdev)
289 struct ccwgroup_driver *gdrv; 289 struct ccwgroup_driver *gdrv;
290 int ret; 290 int ret;
291 291
292 if (atomic_compare_and_swap(0, 1, &gdev->onoff)) 292 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0)
293 return -EAGAIN; 293 return -EAGAIN;
294 if (gdev->state == CCWGROUP_OFFLINE) { 294 if (gdev->state == CCWGROUP_OFFLINE) {
295 ret = 0; 295 ret = 0;
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index fa3c23b80e3a..7270808c02d1 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/chsc.c 2 * drivers/s390/cio/chsc.c
3 * S/390 common I/O routines -- channel subsystem call 3 * S/390 common I/O routines -- channel subsystem call
4 * $Revision: 1.120 $ 4 * $Revision: 1.126 $
5 * 5 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -24,8 +24,6 @@
24#include "ioasm.h" 24#include "ioasm.h"
25#include "chsc.h" 25#include "chsc.h"
26 26
27static struct channel_path *chps[NR_CHPIDS];
28
29static void *sei_page; 27static void *sei_page;
30 28
31static int new_channel_path(int chpid); 29static int new_channel_path(int chpid);
@@ -33,13 +31,13 @@ static int new_channel_path(int chpid);
33static inline void 31static inline void
34set_chp_logically_online(int chp, int onoff) 32set_chp_logically_online(int chp, int onoff)
35{ 33{
36 chps[chp]->state = onoff; 34 css[0]->chps[chp]->state = onoff;
37} 35}
38 36
39static int 37static int
40get_chp_status(int chp) 38get_chp_status(int chp)
41{ 39{
42 return (chps[chp] ? chps[chp]->state : -ENODEV); 40 return (css[0]->chps[chp] ? css[0]->chps[chp]->state : -ENODEV);
43} 41}
44 42
45void 43void
@@ -77,7 +75,9 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page)
77 75
78 struct { 76 struct {
79 struct chsc_header request; 77 struct chsc_header request;
80 u16 reserved1; 78 u16 reserved1a:10;
79 u16 ssid:2;
80 u16 reserved1b:4;
81 u16 f_sch; /* first subchannel */ 81 u16 f_sch; /* first subchannel */
82 u16 reserved2; 82 u16 reserved2;
83 u16 l_sch; /* last subchannel */ 83 u16 l_sch; /* last subchannel */
@@ -104,8 +104,9 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page)
104 .code = 0x0004, 104 .code = 0x0004,
105 }; 105 };
106 106
107 ssd_area->f_sch = sch->irq; 107 ssd_area->ssid = sch->schid.ssid;
108 ssd_area->l_sch = sch->irq; 108 ssd_area->f_sch = sch->schid.sch_no;
109 ssd_area->l_sch = sch->schid.sch_no;
109 110
110 ccode = chsc(ssd_area); 111 ccode = chsc(ssd_area);
111 if (ccode > 0) { 112 if (ccode > 0) {
@@ -147,7 +148,8 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page)
147 */ 148 */
148 if (ssd_area->st > 3) { /* uhm, that looks strange... */ 149 if (ssd_area->st > 3) { /* uhm, that looks strange... */
149 CIO_CRW_EVENT(0, "Strange subchannel type %d" 150 CIO_CRW_EVENT(0, "Strange subchannel type %d"
150 " for sch %04x\n", ssd_area->st, sch->irq); 151 " for sch 0.%x.%04x\n", ssd_area->st,
152 sch->schid.ssid, sch->schid.sch_no);
151 /* 153 /*
152 * There may have been a new subchannel type defined in the 154 * There may have been a new subchannel type defined in the
153 * time since this code was written; since we don't know which 155 * time since this code was written; since we don't know which
@@ -156,8 +158,9 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page)
156 return 0; 158 return 0;
157 } else { 159 } else {
158 const char *type[4] = {"I/O", "chsc", "message", "ADM"}; 160 const char *type[4] = {"I/O", "chsc", "message", "ADM"};
159 CIO_CRW_EVENT(6, "ssd: sch %04x is %s subchannel\n", 161 CIO_CRW_EVENT(6, "ssd: sch 0.%x.%04x is %s subchannel\n",
160 sch->irq, type[ssd_area->st]); 162 sch->schid.ssid, sch->schid.sch_no,
163 type[ssd_area->st]);
161 164
162 sch->ssd_info.valid = 1; 165 sch->ssd_info.valid = 1;
163 sch->ssd_info.type = ssd_area->st; 166 sch->ssd_info.type = ssd_area->st;
@@ -218,13 +221,13 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
218 int j; 221 int j;
219 int mask; 222 int mask;
220 struct subchannel *sch; 223 struct subchannel *sch;
221 __u8 *chpid; 224 struct channel_path *chpid;
222 struct schib schib; 225 struct schib schib;
223 226
224 sch = to_subchannel(dev); 227 sch = to_subchannel(dev);
225 chpid = data; 228 chpid = data;
226 for (j = 0; j < 8; j++) 229 for (j = 0; j < 8; j++)
227 if (sch->schib.pmcw.chpid[j] == *chpid) 230 if (sch->schib.pmcw.chpid[j] == chpid->id)
228 break; 231 break;
229 if (j >= 8) 232 if (j >= 8)
230 return 0; 233 return 0;
@@ -232,7 +235,7 @@ s390_subchannel_remove_chpid(struct device *dev, void *data)
232 mask = 0x80 >> j; 235 mask = 0x80 >> j;
233 spin_lock(&sch->lock); 236 spin_lock(&sch->lock);
234 237
235 stsch(sch->irq, &schib); 238 stsch(sch->schid, &schib);
236 if (!schib.pmcw.dnv) 239 if (!schib.pmcw.dnv)
237 goto out_unreg; 240 goto out_unreg;
238 memcpy(&sch->schib, &schib, sizeof(struct schib)); 241 memcpy(&sch->schib, &schib, sizeof(struct schib));
@@ -284,7 +287,7 @@ out_unlock:
284out_unreg: 287out_unreg:
285 spin_unlock(&sch->lock); 288 spin_unlock(&sch->lock);
286 sch->lpm = 0; 289 sch->lpm = 0;
287 if (css_enqueue_subchannel_slow(sch->irq)) { 290 if (css_enqueue_subchannel_slow(sch->schid)) {
288 css_clear_subchannel_slow_list(); 291 css_clear_subchannel_slow_list();
289 need_rescan = 1; 292 need_rescan = 1;
290 } 293 }
@@ -295,23 +298,30 @@ static inline void
295s390_set_chpid_offline( __u8 chpid) 298s390_set_chpid_offline( __u8 chpid)
296{ 299{
297 char dbf_txt[15]; 300 char dbf_txt[15];
301 struct device *dev;
298 302
299 sprintf(dbf_txt, "chpr%x", chpid); 303 sprintf(dbf_txt, "chpr%x", chpid);
300 CIO_TRACE_EVENT(2, dbf_txt); 304 CIO_TRACE_EVENT(2, dbf_txt);
301 305
302 if (get_chp_status(chpid) <= 0) 306 if (get_chp_status(chpid) <= 0)
303 return; 307 return;
304 308 dev = get_device(&css[0]->chps[chpid]->dev);
305 bus_for_each_dev(&css_bus_type, NULL, &chpid, 309 bus_for_each_dev(&css_bus_type, NULL, to_channelpath(dev),
306 s390_subchannel_remove_chpid); 310 s390_subchannel_remove_chpid);
307 311
308 if (need_rescan || css_slow_subchannels_exist()) 312 if (need_rescan || css_slow_subchannels_exist())
309 queue_work(slow_path_wq, &slow_path_work); 313 queue_work(slow_path_wq, &slow_path_work);
314 put_device(dev);
310} 315}
311 316
317struct res_acc_data {
318 struct channel_path *chp;
319 u32 fla_mask;
320 u16 fla;
321};
322
312static int 323static int
313s390_process_res_acc_sch(u8 chpid, __u16 fla, u32 fla_mask, 324s390_process_res_acc_sch(struct res_acc_data *res_data, struct subchannel *sch)
314 struct subchannel *sch)
315{ 325{
316 int found; 326 int found;
317 int chp; 327 int chp;
@@ -323,8 +333,9 @@ s390_process_res_acc_sch(u8 chpid, __u16 fla, u32 fla_mask,
323 * check if chpid is in information updated by ssd 333 * check if chpid is in information updated by ssd
324 */ 334 */
325 if (sch->ssd_info.valid && 335 if (sch->ssd_info.valid &&
326 sch->ssd_info.chpid[chp] == chpid && 336 sch->ssd_info.chpid[chp] == res_data->chp->id &&
327 (sch->ssd_info.fla[chp] & fla_mask) == fla) { 337 (sch->ssd_info.fla[chp] & res_data->fla_mask)
338 == res_data->fla) {
328 found = 1; 339 found = 1;
329 break; 340 break;
330 } 341 }
@@ -337,24 +348,87 @@ s390_process_res_acc_sch(u8 chpid, __u16 fla, u32 fla_mask,
337 * new path information and eventually check for logically 348 * new path information and eventually check for logically
338 * offline chpids. 349 * offline chpids.
339 */ 350 */
340 ccode = stsch(sch->irq, &sch->schib); 351 ccode = stsch(sch->schid, &sch->schib);
341 if (ccode > 0) 352 if (ccode > 0)
342 return 0; 353 return 0;
343 354
344 return 0x80 >> chp; 355 return 0x80 >> chp;
345} 356}
346 357
358static inline int
359s390_process_res_acc_new_sch(struct subchannel_id schid)
360{
361 struct schib schib;
362 int ret;
363 /*
364 * We don't know the device yet, but since a path
365 * may be available now to the device we'll have
366 * to do recognition again.
367 * Since we don't have any idea about which chpid
368 * that beast may be on we'll have to do a stsch
369 * on all devices, grr...
370 */
371 if (stsch_err(schid, &schib))
372 /* We're through */
373 return need_rescan ? -EAGAIN : -ENXIO;
374
375 /* Put it on the slow path. */
376 ret = css_enqueue_subchannel_slow(schid);
377 if (ret) {
378 css_clear_subchannel_slow_list();
379 need_rescan = 1;
380 return -EAGAIN;
381 }
382 return 0;
383}
384
347static int 385static int
348s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask) 386__s390_process_res_acc(struct subchannel_id schid, void *data)
349{ 387{
388 int chp_mask, old_lpm;
389 struct res_acc_data *res_data;
350 struct subchannel *sch; 390 struct subchannel *sch;
351 int irq, rc; 391
392 res_data = (struct res_acc_data *)data;
393 sch = get_subchannel_by_schid(schid);
394 if (!sch)
395 /* Check if a subchannel is newly available. */
396 return s390_process_res_acc_new_sch(schid);
397
398 spin_lock_irq(&sch->lock);
399
400 chp_mask = s390_process_res_acc_sch(res_data, sch);
401
402 if (chp_mask == 0) {
403 spin_unlock_irq(&sch->lock);
404 return 0;
405 }
406 old_lpm = sch->lpm;
407 sch->lpm = ((sch->schib.pmcw.pim &
408 sch->schib.pmcw.pam &
409 sch->schib.pmcw.pom)
410 | chp_mask) & sch->opm;
411 if (!old_lpm && sch->lpm)
412 device_trigger_reprobe(sch);
413 else if (sch->driver && sch->driver->verify)
414 sch->driver->verify(&sch->dev);
415
416 spin_unlock_irq(&sch->lock);
417 put_device(&sch->dev);
418 return (res_data->fla_mask == 0xffff) ? -ENODEV : 0;
419}
420
421
422static int
423s390_process_res_acc (struct res_acc_data *res_data)
424{
425 int rc;
352 char dbf_txt[15]; 426 char dbf_txt[15];
353 427
354 sprintf(dbf_txt, "accpr%x", chpid); 428 sprintf(dbf_txt, "accpr%x", res_data->chp->id);
355 CIO_TRACE_EVENT( 2, dbf_txt); 429 CIO_TRACE_EVENT( 2, dbf_txt);
356 if (fla != 0) { 430 if (res_data->fla != 0) {
357 sprintf(dbf_txt, "fla%x", fla); 431 sprintf(dbf_txt, "fla%x", res_data->fla);
358 CIO_TRACE_EVENT( 2, dbf_txt); 432 CIO_TRACE_EVENT( 2, dbf_txt);
359 } 433 }
360 434
@@ -365,70 +439,11 @@ s390_process_res_acc (u8 chpid, __u16 fla, u32 fla_mask)
365 * The more information we have (info), the less scanning 439 * The more information we have (info), the less scanning
366 * will we have to do. 440 * will we have to do.
367 */ 441 */
368 442 rc = for_each_subchannel(__s390_process_res_acc, res_data);
369 if (!get_chp_status(chpid)) 443 if (css_slow_subchannels_exist())
370 return 0; /* no need to do the rest */ 444 rc = -EAGAIN;
371 445 else if (rc != -EAGAIN)
372 rc = 0; 446 rc = 0;
373 for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) {
374 int chp_mask, old_lpm;
375
376 sch = get_subchannel_by_schid(irq);
377 if (!sch) {
378 struct schib schib;
379 int ret;
380 /*
381 * We don't know the device yet, but since a path
382 * may be available now to the device we'll have
383 * to do recognition again.
384 * Since we don't have any idea about which chpid
385 * that beast may be on we'll have to do a stsch
386 * on all devices, grr...
387 */
388 if (stsch(irq, &schib)) {
389 /* We're through */
390 if (need_rescan)
391 rc = -EAGAIN;
392 break;
393 }
394 if (need_rescan) {
395 rc = -EAGAIN;
396 continue;
397 }
398 /* Put it on the slow path. */
399 ret = css_enqueue_subchannel_slow(irq);
400 if (ret) {
401 css_clear_subchannel_slow_list();
402 need_rescan = 1;
403 }
404 rc = -EAGAIN;
405 continue;
406 }
407
408 spin_lock_irq(&sch->lock);
409
410 chp_mask = s390_process_res_acc_sch(chpid, fla, fla_mask, sch);
411
412 if (chp_mask == 0) {
413
414 spin_unlock_irq(&sch->lock);
415 continue;
416 }
417 old_lpm = sch->lpm;
418 sch->lpm = ((sch->schib.pmcw.pim &
419 sch->schib.pmcw.pam &
420 sch->schib.pmcw.pom)
421 | chp_mask) & sch->opm;
422 if (!old_lpm && sch->lpm)
423 device_trigger_reprobe(sch);
424 else if (sch->driver && sch->driver->verify)
425 sch->driver->verify(&sch->dev);
426
427 spin_unlock_irq(&sch->lock);
428 put_device(&sch->dev);
429 if (fla_mask == 0xffff)
430 break;
431 }
432 return rc; 447 return rc;
433} 448}
434 449
@@ -466,6 +481,7 @@ int
466chsc_process_crw(void) 481chsc_process_crw(void)
467{ 482{
468 int chpid, ret; 483 int chpid, ret;
484 struct res_acc_data res_data;
469 struct { 485 struct {
470 struct chsc_header request; 486 struct chsc_header request;
471 u32 reserved1; 487 u32 reserved1;
@@ -499,8 +515,9 @@ chsc_process_crw(void)
499 ret = 0; 515 ret = 0;
500 do { 516 do {
501 int ccode, status; 517 int ccode, status;
518 struct device *dev;
502 memset(sei_area, 0, sizeof(*sei_area)); 519 memset(sei_area, 0, sizeof(*sei_area));
503 520 memset(&res_data, 0, sizeof(struct res_acc_data));
504 sei_area->request = (struct chsc_header) { 521 sei_area->request = (struct chsc_header) {
505 .length = 0x0010, 522 .length = 0x0010,
506 .code = 0x000e, 523 .code = 0x000e,
@@ -573,26 +590,25 @@ chsc_process_crw(void)
573 if (status < 0) 590 if (status < 0)
574 new_channel_path(sei_area->rsid); 591 new_channel_path(sei_area->rsid);
575 else if (!status) 592 else if (!status)
576 return 0; 593 break;
577 if ((sei_area->vf & 0x80) == 0) { 594 dev = get_device(&css[0]->chps[sei_area->rsid]->dev);
578 pr_debug("chpid: %x\n", sei_area->rsid); 595 res_data.chp = to_channelpath(dev);
579 ret = s390_process_res_acc(sei_area->rsid, 596 pr_debug("chpid: %x", sei_area->rsid);
580 0, 0); 597 if ((sei_area->vf & 0xc0) != 0) {
581 } else if ((sei_area->vf & 0xc0) == 0x80) { 598 res_data.fla = sei_area->fla;
582 pr_debug("chpid: %x link addr: %x\n", 599 if ((sei_area->vf & 0xc0) == 0xc0) {
583 sei_area->rsid, sei_area->fla); 600 pr_debug(" full link addr: %x",
584 ret = s390_process_res_acc(sei_area->rsid, 601 sei_area->fla);
585 sei_area->fla, 602 res_data.fla_mask = 0xffff;
586 0xff00); 603 } else {
587 } else if ((sei_area->vf & 0xc0) == 0xc0) { 604 pr_debug(" link addr: %x",
588 pr_debug("chpid: %x full link addr: %x\n", 605 sei_area->fla);
589 sei_area->rsid, sei_area->fla); 606 res_data.fla_mask = 0xff00;
590 ret = s390_process_res_acc(sei_area->rsid, 607 }
591 sei_area->fla,
592 0xffff);
593 } 608 }
594 pr_debug("\n"); 609 ret = s390_process_res_acc(&res_data);
595 610 pr_debug("\n\n");
611 put_device(dev);
596 break; 612 break;
597 613
598 default: /* other stuff */ 614 default: /* other stuff */
@@ -604,12 +620,72 @@ chsc_process_crw(void)
604 return ret; 620 return ret;
605} 621}
606 622
623static inline int
624__chp_add_new_sch(struct subchannel_id schid)
625{
626 struct schib schib;
627 int ret;
628
629 if (stsch(schid, &schib))
630 /* We're through */
631 return need_rescan ? -EAGAIN : -ENXIO;
632
633 /* Put it on the slow path. */
634 ret = css_enqueue_subchannel_slow(schid);
635 if (ret) {
636 css_clear_subchannel_slow_list();
637 need_rescan = 1;
638 return -EAGAIN;
639 }
640 return 0;
641}
642
643
607static int 644static int
608chp_add(int chpid) 645__chp_add(struct subchannel_id schid, void *data)
609{ 646{
647 int i;
648 struct channel_path *chp;
610 struct subchannel *sch; 649 struct subchannel *sch;
611 int irq, ret, rc; 650
651 chp = (struct channel_path *)data;
652 sch = get_subchannel_by_schid(schid);
653 if (!sch)
654 /* Check if the subchannel is now available. */
655 return __chp_add_new_sch(schid);
656 spin_lock(&sch->lock);
657 for (i=0; i<8; i++)
658 if (sch->schib.pmcw.chpid[i] == chp->id) {
659 if (stsch(sch->schid, &sch->schib) != 0) {
660 /* Endgame. */
661 spin_unlock(&sch->lock);
662 return -ENXIO;
663 }
664 break;
665 }
666 if (i==8) {
667 spin_unlock(&sch->lock);
668 return 0;
669 }
670 sch->lpm = ((sch->schib.pmcw.pim &
671 sch->schib.pmcw.pam &
672 sch->schib.pmcw.pom)
673 | 0x80 >> i) & sch->opm;
674
675 if (sch->driver && sch->driver->verify)
676 sch->driver->verify(&sch->dev);
677
678 spin_unlock(&sch->lock);
679 put_device(&sch->dev);
680 return 0;
681}
682
683static int
684chp_add(int chpid)
685{
686 int rc;
612 char dbf_txt[15]; 687 char dbf_txt[15];
688 struct device *dev;
613 689
614 if (!get_chp_status(chpid)) 690 if (!get_chp_status(chpid))
615 return 0; /* no need to do the rest */ 691 return 0; /* no need to do the rest */
@@ -617,59 +693,13 @@ chp_add(int chpid)
617 sprintf(dbf_txt, "cadd%x", chpid); 693 sprintf(dbf_txt, "cadd%x", chpid);
618 CIO_TRACE_EVENT(2, dbf_txt); 694 CIO_TRACE_EVENT(2, dbf_txt);
619 695
620 rc = 0; 696 dev = get_device(&css[0]->chps[chpid]->dev);
621 for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { 697 rc = for_each_subchannel(__chp_add, to_channelpath(dev));
622 int i; 698 if (css_slow_subchannels_exist())
623 699 rc = -EAGAIN;
624 sch = get_subchannel_by_schid(irq); 700 if (rc != -EAGAIN)
625 if (!sch) { 701 rc = 0;
626 struct schib schib; 702 put_device(dev);
627
628 if (stsch(irq, &schib)) {
629 /* We're through */
630 if (need_rescan)
631 rc = -EAGAIN;
632 break;
633 }
634 if (need_rescan) {
635 rc = -EAGAIN;
636 continue;
637 }
638 /* Put it on the slow path. */
639 ret = css_enqueue_subchannel_slow(irq);
640 if (ret) {
641 css_clear_subchannel_slow_list();
642 need_rescan = 1;
643 }
644 rc = -EAGAIN;
645 continue;
646 }
647
648 spin_lock(&sch->lock);
649 for (i=0; i<8; i++)
650 if (sch->schib.pmcw.chpid[i] == chpid) {
651 if (stsch(sch->irq, &sch->schib) != 0) {
652 /* Endgame. */
653 spin_unlock(&sch->lock);
654 return rc;
655 }
656 break;
657 }
658 if (i==8) {
659 spin_unlock(&sch->lock);
660 return rc;
661 }
662 sch->lpm = ((sch->schib.pmcw.pim &
663 sch->schib.pmcw.pam &
664 sch->schib.pmcw.pom)
665 | 0x80 >> i) & sch->opm;
666
667 if (sch->driver && sch->driver->verify)
668 sch->driver->verify(&sch->dev);
669
670 spin_unlock(&sch->lock);
671 put_device(&sch->dev);
672 }
673 return rc; 703 return rc;
674} 704}
675 705
@@ -702,7 +732,7 @@ __check_for_io_and_kill(struct subchannel *sch, int index)
702 if (!device_is_online(sch)) 732 if (!device_is_online(sch))
703 /* cio could be doing I/O. */ 733 /* cio could be doing I/O. */
704 return 0; 734 return 0;
705 cc = stsch(sch->irq, &sch->schib); 735 cc = stsch(sch->schid, &sch->schib);
706 if (cc) 736 if (cc)
707 return 0; 737 return 0;
708 if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index)) { 738 if (sch->schib.scsw.actl && sch->schib.pmcw.lpum == (0x80 >> index)) {
@@ -743,7 +773,7 @@ __s390_subchannel_vary_chpid(struct subchannel *sch, __u8 chpid, int on)
743 * just varied off path. Then kill it. 773 * just varied off path. Then kill it.
744 */ 774 */
745 if (!__check_for_io_and_kill(sch, chp) && !sch->lpm) { 775 if (!__check_for_io_and_kill(sch, chp) && !sch->lpm) {
746 if (css_enqueue_subchannel_slow(sch->irq)) { 776 if (css_enqueue_subchannel_slow(sch->schid)) {
747 css_clear_subchannel_slow_list(); 777 css_clear_subchannel_slow_list();
748 need_rescan = 1; 778 need_rescan = 1;
749 } 779 }
@@ -781,6 +811,29 @@ s390_subchannel_vary_chpid_on(struct device *dev, void *data)
781 return 0; 811 return 0;
782} 812}
783 813
814static int
815__s390_vary_chpid_on(struct subchannel_id schid, void *data)
816{
817 struct schib schib;
818 struct subchannel *sch;
819
820 sch = get_subchannel_by_schid(schid);
821 if (sch) {
822 put_device(&sch->dev);
823 return 0;
824 }
825 if (stsch_err(schid, &schib))
826 /* We're through */
827 return -ENXIO;
828 /* Put it on the slow path. */
829 if (css_enqueue_subchannel_slow(schid)) {
830 css_clear_subchannel_slow_list();
831 need_rescan = 1;
832 return -EAGAIN;
833 }
834 return 0;
835}
836
784/* 837/*
785 * Function: s390_vary_chpid 838 * Function: s390_vary_chpid
786 * Varies the specified chpid online or offline 839 * Varies the specified chpid online or offline
@@ -789,8 +842,7 @@ static int
789s390_vary_chpid( __u8 chpid, int on) 842s390_vary_chpid( __u8 chpid, int on)
790{ 843{
791 char dbf_text[15]; 844 char dbf_text[15];
792 int status, irq, ret; 845 int status;
793 struct subchannel *sch;
794 846
795 sprintf(dbf_text, on?"varyon%x":"varyoff%x", chpid); 847 sprintf(dbf_text, on?"varyon%x":"varyoff%x", chpid);
796 CIO_TRACE_EVENT( 2, dbf_text); 848 CIO_TRACE_EVENT( 2, dbf_text);
@@ -815,30 +867,9 @@ s390_vary_chpid( __u8 chpid, int on)
815 bus_for_each_dev(&css_bus_type, NULL, &chpid, on ? 867 bus_for_each_dev(&css_bus_type, NULL, &chpid, on ?
816 s390_subchannel_vary_chpid_on : 868 s390_subchannel_vary_chpid_on :
817 s390_subchannel_vary_chpid_off); 869 s390_subchannel_vary_chpid_off);
818 if (!on) 870 if (on)
819 goto out; 871 /* Scan for new devices on varied on path. */
820 /* Scan for new devices on varied on path. */ 872 for_each_subchannel(__s390_vary_chpid_on, NULL);
821 for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) {
822 struct schib schib;
823
824 if (need_rescan)
825 break;
826 sch = get_subchannel_by_schid(irq);
827 if (sch) {
828 put_device(&sch->dev);
829 continue;
830 }
831 if (stsch(irq, &schib))
832 /* We're through */
833 break;
834 /* Put it on the slow path. */
835 ret = css_enqueue_subchannel_slow(irq);
836 if (ret) {
837 css_clear_subchannel_slow_list();
838 need_rescan = 1;
839 }
840 }
841out:
842 if (need_rescan || css_slow_subchannels_exist()) 873 if (need_rescan || css_slow_subchannels_exist())
843 queue_work(slow_path_wq, &slow_path_work); 874 queue_work(slow_path_wq, &slow_path_work);
844 return 0; 875 return 0;
@@ -995,7 +1026,7 @@ new_channel_path(int chpid)
995 chp->id = chpid; 1026 chp->id = chpid;
996 chp->state = 1; 1027 chp->state = 1;
997 chp->dev = (struct device) { 1028 chp->dev = (struct device) {
998 .parent = &css_bus_device, 1029 .parent = &css[0]->device,
999 .release = chp_release, 1030 .release = chp_release,
1000 }; 1031 };
1001 snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp0.%x", chpid); 1032 snprintf(chp->dev.bus_id, BUS_ID_SIZE, "chp0.%x", chpid);
@@ -1017,7 +1048,7 @@ new_channel_path(int chpid)
1017 device_unregister(&chp->dev); 1048 device_unregister(&chp->dev);
1018 goto out_free; 1049 goto out_free;
1019 } else 1050 } else
1020 chps[chpid] = chp; 1051 css[0]->chps[chpid] = chp;
1021 return ret; 1052 return ret;
1022out_free: 1053out_free:
1023 kfree(chp); 1054 kfree(chp);
@@ -1030,7 +1061,7 @@ chsc_get_chp_desc(struct subchannel *sch, int chp_no)
1030 struct channel_path *chp; 1061 struct channel_path *chp;
1031 struct channel_path_desc *desc; 1062 struct channel_path_desc *desc;
1032 1063
1033 chp = chps[sch->schib.pmcw.chpid[chp_no]]; 1064 chp = css[0]->chps[sch->schib.pmcw.chpid[chp_no]];
1034 if (!chp) 1065 if (!chp)
1035 return NULL; 1066 return NULL;
1036 desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL); 1067 desc = kmalloc(sizeof(struct channel_path_desc), GFP_KERNEL);
@@ -1051,6 +1082,54 @@ chsc_alloc_sei_area(void)
1051 return (sei_page ? 0 : -ENOMEM); 1082 return (sei_page ? 0 : -ENOMEM);
1052} 1083}
1053 1084
1085int __init
1086chsc_enable_facility(int operation_code)
1087{
1088 int ret;
1089 struct {
1090 struct chsc_header request;
1091 u8 reserved1:4;
1092 u8 format:4;
1093 u8 reserved2;
1094 u16 operation_code;
1095 u32 reserved3;
1096 u32 reserved4;
1097 u32 operation_data_area[252];
1098 struct chsc_header response;
1099 u32 reserved5:4;
1100 u32 format2:4;
1101 u32 reserved6:24;
1102 } *sda_area;
1103
1104 sda_area = (void *)get_zeroed_page(GFP_KERNEL|GFP_DMA);
1105 if (!sda_area)
1106 return -ENOMEM;
1107 sda_area->request = (struct chsc_header) {
1108 .length = 0x0400,
1109 .code = 0x0031,
1110 };
1111 sda_area->operation_code = operation_code;
1112
1113 ret = chsc(sda_area);
1114 if (ret > 0) {
1115 ret = (ret == 3) ? -ENODEV : -EBUSY;
1116 goto out;
1117 }
1118 switch (sda_area->response.code) {
1119 case 0x0003: /* invalid request block */
1120 case 0x0007:
1121 ret = -EINVAL;
1122 break;
1123 case 0x0004: /* command not provided */
1124 case 0x0101: /* facility not provided */
1125 ret = -EOPNOTSUPP;
1126 break;
1127 }
1128 out:
1129 free_page((unsigned long)sda_area);
1130 return ret;
1131}
1132
1054subsys_initcall(chsc_alloc_sei_area); 1133subsys_initcall(chsc_alloc_sei_area);
1055 1134
1056struct css_general_char css_general_characteristics; 1135struct css_general_char css_general_characteristics;
diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h
index be20da49d147..44e4b4bb1c5a 100644
--- a/drivers/s390/cio/chsc.h
+++ b/drivers/s390/cio/chsc.h
@@ -1,12 +1,12 @@
1#ifndef S390_CHSC_H 1#ifndef S390_CHSC_H
2#define S390_CHSC_H 2#define S390_CHSC_H
3 3
4#define NR_CHPIDS 256
5
6#define CHSC_SEI_ACC_CHPID 1 4#define CHSC_SEI_ACC_CHPID 1
7#define CHSC_SEI_ACC_LINKADDR 2 5#define CHSC_SEI_ACC_LINKADDR 2
8#define CHSC_SEI_ACC_FULLLINKADDR 3 6#define CHSC_SEI_ACC_FULLLINKADDR 3
9 7
8#define CHSC_SDA_OC_MSS 0x2
9
10struct chsc_header { 10struct chsc_header {
11 u16 length; 11 u16 length;
12 u16 code; 12 u16 code;
@@ -43,7 +43,9 @@ struct css_general_char {
43 u32 ext_mb : 1; /* bit 48 */ 43 u32 ext_mb : 1; /* bit 48 */
44 u32 : 7; 44 u32 : 7;
45 u32 aif_tdd : 1; /* bit 56 */ 45 u32 aif_tdd : 1; /* bit 56 */
46 u32 : 10; 46 u32 : 1;
47 u32 qebsm : 1; /* bit 58 */
48 u32 : 8;
47 u32 aif_osa : 1; /* bit 67 */ 49 u32 aif_osa : 1; /* bit 67 */
48 u32 : 28; 50 u32 : 28;
49}__attribute__((packed)); 51}__attribute__((packed));
@@ -63,4 +65,9 @@ extern int chsc_determine_css_characteristics(void);
63extern int css_characteristics_avail; 65extern int css_characteristics_avail;
64 66
65extern void *chsc_get_chp_desc(struct subchannel*, int); 67extern void *chsc_get_chp_desc(struct subchannel*, int);
68
69extern int chsc_enable_facility(int);
70
71#define to_channelpath(dev) container_of(dev, struct channel_path, dev)
72
66#endif 73#endif
diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 185bc73c3ecd..7376bc87206d 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/cio.c 2 * drivers/s390/cio/cio.c
3 * S/390 common I/O routines -- low level i/o calls 3 * S/390 common I/O routines -- low level i/o calls
4 * $Revision: 1.135 $ 4 * $Revision: 1.138 $
5 * 5 *
6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 1999-2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -135,7 +135,7 @@ cio_tpi(void)
135 return 0; 135 return 0;
136 irb = (struct irb *) __LC_IRB; 136 irb = (struct irb *) __LC_IRB;
137 /* Store interrupt response block to lowcore. */ 137 /* Store interrupt response block to lowcore. */
138 if (tsch (tpi_info->irq, irb) != 0) 138 if (tsch (tpi_info->schid, irb) != 0)
139 /* Not status pending or not operational. */ 139 /* Not status pending or not operational. */
140 return 1; 140 return 1;
141 sch = (struct subchannel *)(unsigned long)tpi_info->intparm; 141 sch = (struct subchannel *)(unsigned long)tpi_info->intparm;
@@ -163,10 +163,11 @@ cio_start_handle_notoper(struct subchannel *sch, __u8 lpm)
163 else 163 else
164 sch->lpm = 0; 164 sch->lpm = 0;
165 165
166 stsch (sch->irq, &sch->schib); 166 stsch (sch->schid, &sch->schib);
167 167
168 CIO_MSG_EVENT(0, "cio_start: 'not oper' status for " 168 CIO_MSG_EVENT(0, "cio_start: 'not oper' status for "
169 "subchannel %04x!\n", sch->irq); 169 "subchannel 0.%x.%04x!\n", sch->schid.ssid,
170 sch->schid.sch_no);
170 sprintf(dbf_text, "no%s", sch->dev.bus_id); 171 sprintf(dbf_text, "no%s", sch->dev.bus_id);
171 CIO_TRACE_EVENT(0, dbf_text); 172 CIO_TRACE_EVENT(0, dbf_text);
172 CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib)); 173 CIO_HEX_EVENT(0, &sch->schib, sizeof (struct schib));
@@ -194,7 +195,7 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */
194 sch->orb.spnd = sch->options.suspend; 195 sch->orb.spnd = sch->options.suspend;
195 sch->orb.ssic = sch->options.suspend && sch->options.inter; 196 sch->orb.ssic = sch->options.suspend && sch->options.inter;
196 sch->orb.lpm = (lpm != 0) ? (lpm & sch->opm) : sch->lpm; 197 sch->orb.lpm = (lpm != 0) ? (lpm & sch->opm) : sch->lpm;
197#ifdef CONFIG_ARCH_S390X 198#ifdef CONFIG_64BIT
198 /* 199 /*
199 * for 64 bit we always support 64 bit IDAWs with 4k page size only 200 * for 64 bit we always support 64 bit IDAWs with 4k page size only
200 */ 201 */
@@ -204,7 +205,7 @@ cio_start_key (struct subchannel *sch, /* subchannel structure */
204 sch->orb.key = key >> 4; 205 sch->orb.key = key >> 4;
205 /* issue "Start Subchannel" */ 206 /* issue "Start Subchannel" */
206 sch->orb.cpa = (__u32) __pa (cpa); 207 sch->orb.cpa = (__u32) __pa (cpa);
207 ccode = ssch (sch->irq, &sch->orb); 208 ccode = ssch (sch->schid, &sch->orb);
208 209
209 /* process condition code */ 210 /* process condition code */
210 sprintf (dbf_txt, "ccode:%d", ccode); 211 sprintf (dbf_txt, "ccode:%d", ccode);
@@ -243,7 +244,7 @@ cio_resume (struct subchannel *sch)
243 CIO_TRACE_EVENT (4, "resIO"); 244 CIO_TRACE_EVENT (4, "resIO");
244 CIO_TRACE_EVENT (4, sch->dev.bus_id); 245 CIO_TRACE_EVENT (4, sch->dev.bus_id);
245 246
246 ccode = rsch (sch->irq); 247 ccode = rsch (sch->schid);
247 248
248 sprintf (dbf_txt, "ccode:%d", ccode); 249 sprintf (dbf_txt, "ccode:%d", ccode);
249 CIO_TRACE_EVENT (4, dbf_txt); 250 CIO_TRACE_EVENT (4, dbf_txt);
@@ -283,7 +284,7 @@ cio_halt(struct subchannel *sch)
283 /* 284 /*
284 * Issue "Halt subchannel" and process condition code 285 * Issue "Halt subchannel" and process condition code
285 */ 286 */
286 ccode = hsch (sch->irq); 287 ccode = hsch (sch->schid);
287 288
288 sprintf (dbf_txt, "ccode:%d", ccode); 289 sprintf (dbf_txt, "ccode:%d", ccode);
289 CIO_TRACE_EVENT (2, dbf_txt); 290 CIO_TRACE_EVENT (2, dbf_txt);
@@ -318,7 +319,7 @@ cio_clear(struct subchannel *sch)
318 /* 319 /*
319 * Issue "Clear subchannel" and process condition code 320 * Issue "Clear subchannel" and process condition code
320 */ 321 */
321 ccode = csch (sch->irq); 322 ccode = csch (sch->schid);
322 323
323 sprintf (dbf_txt, "ccode:%d", ccode); 324 sprintf (dbf_txt, "ccode:%d", ccode);
324 CIO_TRACE_EVENT (2, dbf_txt); 325 CIO_TRACE_EVENT (2, dbf_txt);
@@ -351,7 +352,7 @@ cio_cancel (struct subchannel *sch)
351 CIO_TRACE_EVENT (2, "cancelIO"); 352 CIO_TRACE_EVENT (2, "cancelIO");
352 CIO_TRACE_EVENT (2, sch->dev.bus_id); 353 CIO_TRACE_EVENT (2, sch->dev.bus_id);
353 354
354 ccode = xsch (sch->irq); 355 ccode = xsch (sch->schid);
355 356
356 sprintf (dbf_txt, "ccode:%d", ccode); 357 sprintf (dbf_txt, "ccode:%d", ccode);
357 CIO_TRACE_EVENT (2, dbf_txt); 358 CIO_TRACE_EVENT (2, dbf_txt);
@@ -359,7 +360,7 @@ cio_cancel (struct subchannel *sch)
359 switch (ccode) { 360 switch (ccode) {
360 case 0: /* success */ 361 case 0: /* success */
361 /* Update information in scsw. */ 362 /* Update information in scsw. */
362 stsch (sch->irq, &sch->schib); 363 stsch (sch->schid, &sch->schib);
363 return 0; 364 return 0;
364 case 1: /* status pending */ 365 case 1: /* status pending */
365 return -EBUSY; 366 return -EBUSY;
@@ -381,7 +382,7 @@ cio_modify (struct subchannel *sch)
381 382
382 ret = 0; 383 ret = 0;
383 for (retry = 0; retry < 5; retry++) { 384 for (retry = 0; retry < 5; retry++) {
384 ccode = msch_err (sch->irq, &sch->schib); 385 ccode = msch_err (sch->schid, &sch->schib);
385 if (ccode < 0) /* -EIO if msch gets a program check. */ 386 if (ccode < 0) /* -EIO if msch gets a program check. */
386 return ccode; 387 return ccode;
387 switch (ccode) { 388 switch (ccode) {
@@ -414,7 +415,7 @@ cio_enable_subchannel (struct subchannel *sch, unsigned int isc)
414 CIO_TRACE_EVENT (2, "ensch"); 415 CIO_TRACE_EVENT (2, "ensch");
415 CIO_TRACE_EVENT (2, sch->dev.bus_id); 416 CIO_TRACE_EVENT (2, sch->dev.bus_id);
416 417
417 ccode = stsch (sch->irq, &sch->schib); 418 ccode = stsch (sch->schid, &sch->schib);
418 if (ccode) 419 if (ccode)
419 return -ENODEV; 420 return -ENODEV;
420 421
@@ -432,13 +433,13 @@ cio_enable_subchannel (struct subchannel *sch, unsigned int isc)
432 */ 433 */
433 sch->schib.pmcw.csense = 0; 434 sch->schib.pmcw.csense = 0;
434 if (ret == 0) { 435 if (ret == 0) {
435 stsch (sch->irq, &sch->schib); 436 stsch (sch->schid, &sch->schib);
436 if (sch->schib.pmcw.ena) 437 if (sch->schib.pmcw.ena)
437 break; 438 break;
438 } 439 }
439 if (ret == -EBUSY) { 440 if (ret == -EBUSY) {
440 struct irb irb; 441 struct irb irb;
441 if (tsch(sch->irq, &irb) != 0) 442 if (tsch(sch->schid, &irb) != 0)
442 break; 443 break;
443 } 444 }
444 } 445 }
@@ -461,7 +462,7 @@ cio_disable_subchannel (struct subchannel *sch)
461 CIO_TRACE_EVENT (2, "dissch"); 462 CIO_TRACE_EVENT (2, "dissch");
462 CIO_TRACE_EVENT (2, sch->dev.bus_id); 463 CIO_TRACE_EVENT (2, sch->dev.bus_id);
463 464
464 ccode = stsch (sch->irq, &sch->schib); 465 ccode = stsch (sch->schid, &sch->schib);
465 if (ccode == 3) /* Not operational. */ 466 if (ccode == 3) /* Not operational. */
466 return -ENODEV; 467 return -ENODEV;
467 468
@@ -485,7 +486,7 @@ cio_disable_subchannel (struct subchannel *sch)
485 */ 486 */
486 break; 487 break;
487 if (ret == 0) { 488 if (ret == 0) {
488 stsch (sch->irq, &sch->schib); 489 stsch (sch->schid, &sch->schib);
489 if (!sch->schib.pmcw.ena) 490 if (!sch->schib.pmcw.ena)
490 break; 491 break;
491 } 492 }
@@ -508,12 +509,12 @@ cio_disable_subchannel (struct subchannel *sch)
508 * -ENODEV for subchannels with invalid device number or blacklisted devices 509 * -ENODEV for subchannels with invalid device number or blacklisted devices
509 */ 510 */
510int 511int
511cio_validate_subchannel (struct subchannel *sch, unsigned int irq) 512cio_validate_subchannel (struct subchannel *sch, struct subchannel_id schid)
512{ 513{
513 char dbf_txt[15]; 514 char dbf_txt[15];
514 int ccode; 515 int ccode;
515 516
516 sprintf (dbf_txt, "valsch%x", irq); 517 sprintf (dbf_txt, "valsch%x", schid.sch_no);
517 CIO_TRACE_EVENT (4, dbf_txt); 518 CIO_TRACE_EVENT (4, dbf_txt);
518 519
519 /* Nuke all fields. */ 520 /* Nuke all fields. */
@@ -522,17 +523,20 @@ cio_validate_subchannel (struct subchannel *sch, unsigned int irq)
522 spin_lock_init(&sch->lock); 523 spin_lock_init(&sch->lock);
523 524
524 /* Set a name for the subchannel */ 525 /* Set a name for the subchannel */
525 snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", irq); 526 snprintf (sch->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x", schid.ssid,
527 schid.sch_no);
526 528
527 /* 529 /*
528 * The first subchannel that is not-operational (ccode==3) 530 * The first subchannel that is not-operational (ccode==3)
529 * indicates that there aren't any more devices available. 531 * indicates that there aren't any more devices available.
532 * If stsch gets an exception, it means the current subchannel set
533 * is not valid.
530 */ 534 */
531 sch->irq = irq; 535 ccode = stsch_err (schid, &sch->schib);
532 ccode = stsch (irq, &sch->schib);
533 if (ccode) 536 if (ccode)
534 return -ENXIO; 537 return (ccode == 3) ? -ENXIO : ccode;
535 538
539 sch->schid = schid;
536 /* Copy subchannel type from path management control word. */ 540 /* Copy subchannel type from path management control word. */
537 sch->st = sch->schib.pmcw.st; 541 sch->st = sch->schib.pmcw.st;
538 542
@@ -541,9 +545,9 @@ cio_validate_subchannel (struct subchannel *sch, unsigned int irq)
541 */ 545 */
542 if (sch->st != 0) { 546 if (sch->st != 0) {
543 CIO_DEBUG(KERN_INFO, 0, 547 CIO_DEBUG(KERN_INFO, 0,
544 "Subchannel %04X reports " 548 "Subchannel 0.%x.%04x reports "
545 "non-I/O subchannel type %04X\n", 549 "non-I/O subchannel type %04X\n",
546 sch->irq, sch->st); 550 sch->schid.ssid, sch->schid.sch_no, sch->st);
547 /* We stop here for non-io subchannels. */ 551 /* We stop here for non-io subchannels. */
548 return sch->st; 552 return sch->st;
549 } 553 }
@@ -554,26 +558,29 @@ cio_validate_subchannel (struct subchannel *sch, unsigned int irq)
554 return -ENODEV; 558 return -ENODEV;
555 559
556 /* Devno is valid. */ 560 /* Devno is valid. */
557 if (is_blacklisted (sch->schib.pmcw.dev)) { 561 if (is_blacklisted (sch->schid.ssid, sch->schib.pmcw.dev)) {
558 /* 562 /*
559 * This device must not be known to Linux. So we simply 563 * This device must not be known to Linux. So we simply
560 * say that there is no device and return ENODEV. 564 * say that there is no device and return ENODEV.
561 */ 565 */
562 CIO_MSG_EVENT(0, "Blacklisted device detected " 566 CIO_MSG_EVENT(0, "Blacklisted device detected "
563 "at devno %04X\n", sch->schib.pmcw.dev); 567 "at devno %04X, subchannel set %x\n",
568 sch->schib.pmcw.dev, sch->schid.ssid);
564 return -ENODEV; 569 return -ENODEV;
565 } 570 }
566 sch->opm = 0xff; 571 sch->opm = 0xff;
567 chsc_validate_chpids(sch); 572 if (!cio_is_console(sch->schid))
573 chsc_validate_chpids(sch);
568 sch->lpm = sch->schib.pmcw.pim & 574 sch->lpm = sch->schib.pmcw.pim &
569 sch->schib.pmcw.pam & 575 sch->schib.pmcw.pam &
570 sch->schib.pmcw.pom & 576 sch->schib.pmcw.pom &
571 sch->opm; 577 sch->opm;
572 578
573 CIO_DEBUG(KERN_INFO, 0, 579 CIO_DEBUG(KERN_INFO, 0,
574 "Detected device %04X on subchannel %04X" 580 "Detected device %04x on subchannel 0.%x.%04X"
575 " - PIM = %02X, PAM = %02X, POM = %02X\n", 581 " - PIM = %02X, PAM = %02X, POM = %02X\n",
576 sch->schib.pmcw.dev, sch->irq, sch->schib.pmcw.pim, 582 sch->schib.pmcw.dev, sch->schid.ssid,
583 sch->schid.sch_no, sch->schib.pmcw.pim,
577 sch->schib.pmcw.pam, sch->schib.pmcw.pom); 584 sch->schib.pmcw.pam, sch->schib.pmcw.pom);
578 585
579 /* 586 /*
@@ -632,7 +639,7 @@ do_IRQ (struct pt_regs *regs)
632 if (sch) 639 if (sch)
633 spin_lock(&sch->lock); 640 spin_lock(&sch->lock);
634 /* Store interrupt response block to lowcore. */ 641 /* Store interrupt response block to lowcore. */
635 if (tsch (tpi_info->irq, irb) == 0 && sch) { 642 if (tsch (tpi_info->schid, irb) == 0 && sch) {
636 /* Keep subchannel information word up to date. */ 643 /* Keep subchannel information word up to date. */
637 memcpy (&sch->schib.scsw, &irb->scsw, 644 memcpy (&sch->schib.scsw, &irb->scsw,
638 sizeof (irb->scsw)); 645 sizeof (irb->scsw));
@@ -691,28 +698,36 @@ wait_cons_dev (void)
691} 698}
692 699
693static int 700static int
694cio_console_irq(void) 701cio_test_for_console(struct subchannel_id schid, void *data)
695{ 702{
696 int irq; 703 if (stsch_err(schid, &console_subchannel.schib) != 0)
704 return -ENXIO;
705 if (console_subchannel.schib.pmcw.dnv &&
706 console_subchannel.schib.pmcw.dev ==
707 console_devno) {
708 console_irq = schid.sch_no;
709 return 1; /* found */
710 }
711 return 0;
712}
713
714
715static int
716cio_get_console_sch_no(void)
717{
718 struct subchannel_id schid;
697 719
720 init_subchannel_id(&schid);
698 if (console_irq != -1) { 721 if (console_irq != -1) {
699 /* VM provided us with the irq number of the console. */ 722 /* VM provided us with the irq number of the console. */
700 if (stsch(console_irq, &console_subchannel.schib) != 0 || 723 schid.sch_no = console_irq;
724 if (stsch(schid, &console_subchannel.schib) != 0 ||
701 !console_subchannel.schib.pmcw.dnv) 725 !console_subchannel.schib.pmcw.dnv)
702 return -1; 726 return -1;
703 console_devno = console_subchannel.schib.pmcw.dev; 727 console_devno = console_subchannel.schib.pmcw.dev;
704 } else if (console_devno != -1) { 728 } else if (console_devno != -1) {
705 /* At least the console device number is known. */ 729 /* At least the console device number is known. */
706 for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { 730 for_each_subchannel(cio_test_for_console, NULL);
707 if (stsch(irq, &console_subchannel.schib) != 0)
708 break;
709 if (console_subchannel.schib.pmcw.dnv &&
710 console_subchannel.schib.pmcw.dev ==
711 console_devno) {
712 console_irq = irq;
713 break;
714 }
715 }
716 if (console_irq == -1) 731 if (console_irq == -1)
717 return -1; 732 return -1;
718 } else { 733 } else {
@@ -728,17 +743,20 @@ cio_console_irq(void)
728struct subchannel * 743struct subchannel *
729cio_probe_console(void) 744cio_probe_console(void)
730{ 745{
731 int irq, ret; 746 int sch_no, ret;
747 struct subchannel_id schid;
732 748
733 if (xchg(&console_subchannel_in_use, 1) != 0) 749 if (xchg(&console_subchannel_in_use, 1) != 0)
734 return ERR_PTR(-EBUSY); 750 return ERR_PTR(-EBUSY);
735 irq = cio_console_irq(); 751 sch_no = cio_get_console_sch_no();
736 if (irq == -1) { 752 if (sch_no == -1) {
737 console_subchannel_in_use = 0; 753 console_subchannel_in_use = 0;
738 return ERR_PTR(-ENODEV); 754 return ERR_PTR(-ENODEV);
739 } 755 }
740 memset(&console_subchannel, 0, sizeof(struct subchannel)); 756 memset(&console_subchannel, 0, sizeof(struct subchannel));
741 ret = cio_validate_subchannel(&console_subchannel, irq); 757 init_subchannel_id(&schid);
758 schid.sch_no = sch_no;
759 ret = cio_validate_subchannel(&console_subchannel, schid);
742 if (ret) { 760 if (ret) {
743 console_subchannel_in_use = 0; 761 console_subchannel_in_use = 0;
744 return ERR_PTR(-ENODEV); 762 return ERR_PTR(-ENODEV);
@@ -770,11 +788,11 @@ cio_release_console(void)
770 788
771/* Bah... hack to catch console special sausages. */ 789/* Bah... hack to catch console special sausages. */
772int 790int
773cio_is_console(int irq) 791cio_is_console(struct subchannel_id schid)
774{ 792{
775 if (!console_subchannel_in_use) 793 if (!console_subchannel_in_use)
776 return 0; 794 return 0;
777 return (irq == console_subchannel.irq); 795 return schid_equal(&schid, &console_subchannel.schid);
778} 796}
779 797
780struct subchannel * 798struct subchannel *
@@ -787,7 +805,7 @@ cio_get_console_subchannel(void)
787 805
788#endif 806#endif
789static inline int 807static inline int
790__disable_subchannel_easy(unsigned int schid, struct schib *schib) 808__disable_subchannel_easy(struct subchannel_id schid, struct schib *schib)
791{ 809{
792 int retry, cc; 810 int retry, cc;
793 811
@@ -805,7 +823,7 @@ __disable_subchannel_easy(unsigned int schid, struct schib *schib)
805} 823}
806 824
807static inline int 825static inline int
808__clear_subchannel_easy(unsigned int schid) 826__clear_subchannel_easy(struct subchannel_id schid)
809{ 827{
810 int retry; 828 int retry;
811 829
@@ -815,8 +833,8 @@ __clear_subchannel_easy(unsigned int schid)
815 struct tpi_info ti; 833 struct tpi_info ti;
816 834
817 if (tpi(&ti)) { 835 if (tpi(&ti)) {
818 tsch(ti.irq, (struct irb *)__LC_IRB); 836 tsch(ti.schid, (struct irb *)__LC_IRB);
819 if (ti.irq == schid) 837 if (schid_equal(&ti.schid, &schid))
820 return 0; 838 return 0;
821 } 839 }
822 udelay(100); 840 udelay(100);
@@ -825,31 +843,33 @@ __clear_subchannel_easy(unsigned int schid)
825} 843}
826 844
827extern void do_reipl(unsigned long devno); 845extern void do_reipl(unsigned long devno);
846static int
847__shutdown_subchannel_easy(struct subchannel_id schid, void *data)
848{
849 struct schib schib;
850
851 if (stsch_err(schid, &schib))
852 return -ENXIO;
853 if (!schib.pmcw.ena)
854 return 0;
855 switch(__disable_subchannel_easy(schid, &schib)) {
856 case 0:
857 case -ENODEV:
858 break;
859 default: /* -EBUSY */
860 if (__clear_subchannel_easy(schid))
861 break; /* give up... */
862 stsch(schid, &schib);
863 __disable_subchannel_easy(schid, &schib);
864 }
865 return 0;
866}
828 867
829/* Clear all subchannels. */
830void 868void
831clear_all_subchannels(void) 869clear_all_subchannels(void)
832{ 870{
833 unsigned int schid;
834
835 local_irq_disable(); 871 local_irq_disable();
836 for (schid=0;schid<=highest_subchannel;schid++) { 872 for_each_subchannel(__shutdown_subchannel_easy, NULL);
837 struct schib schib;
838 if (stsch(schid, &schib))
839 break; /* break out of the loop */
840 if (!schib.pmcw.ena)
841 continue;
842 switch(__disable_subchannel_easy(schid, &schib)) {
843 case 0:
844 case -ENODEV:
845 break;
846 default: /* -EBUSY */
847 if (__clear_subchannel_easy(schid))
848 break; /* give up... jump out of switch */
849 stsch(schid, &schib);
850 __disable_subchannel_easy(schid, &schib);
851 }
852 }
853} 873}
854 874
855/* Make sure all subchannels are quiet before we re-ipl an lpar. */ 875/* Make sure all subchannels are quiet before we re-ipl an lpar. */
diff --git a/drivers/s390/cio/cio.h b/drivers/s390/cio/cio.h
index c50a9da420a9..0ca987344e07 100644
--- a/drivers/s390/cio/cio.h
+++ b/drivers/s390/cio/cio.h
@@ -1,6 +1,8 @@
1#ifndef S390_CIO_H 1#ifndef S390_CIO_H
2#define S390_CIO_H 2#define S390_CIO_H
3 3
4#include "schid.h"
5
4/* 6/*
5 * where we put the ssd info 7 * where we put the ssd info
6 */ 8 */
@@ -83,7 +85,7 @@ struct orb {
83 85
84/* subchannel data structure used by I/O subroutines */ 86/* subchannel data structure used by I/O subroutines */
85struct subchannel { 87struct subchannel {
86 unsigned int irq; /* aka. subchannel number */ 88 struct subchannel_id schid;
87 spinlock_t lock; /* subchannel lock */ 89 spinlock_t lock; /* subchannel lock */
88 90
89 enum { 91 enum {
@@ -114,7 +116,7 @@ struct subchannel {
114 116
115#define to_subchannel(n) container_of(n, struct subchannel, dev) 117#define to_subchannel(n) container_of(n, struct subchannel, dev)
116 118
117extern int cio_validate_subchannel (struct subchannel *, unsigned int); 119extern int cio_validate_subchannel (struct subchannel *, struct subchannel_id);
118extern int cio_enable_subchannel (struct subchannel *, unsigned int); 120extern int cio_enable_subchannel (struct subchannel *, unsigned int);
119extern int cio_disable_subchannel (struct subchannel *); 121extern int cio_disable_subchannel (struct subchannel *);
120extern int cio_cancel (struct subchannel *); 122extern int cio_cancel (struct subchannel *);
@@ -127,14 +129,15 @@ extern int cio_cancel (struct subchannel *);
127extern int cio_set_options (struct subchannel *, int); 129extern int cio_set_options (struct subchannel *, int);
128extern int cio_get_options (struct subchannel *); 130extern int cio_get_options (struct subchannel *);
129extern int cio_modify (struct subchannel *); 131extern int cio_modify (struct subchannel *);
132
130/* Use with care. */ 133/* Use with care. */
131#ifdef CONFIG_CCW_CONSOLE 134#ifdef CONFIG_CCW_CONSOLE
132extern struct subchannel *cio_probe_console(void); 135extern struct subchannel *cio_probe_console(void);
133extern void cio_release_console(void); 136extern void cio_release_console(void);
134extern int cio_is_console(int irq); 137extern int cio_is_console(struct subchannel_id);
135extern struct subchannel *cio_get_console_subchannel(void); 138extern struct subchannel *cio_get_console_subchannel(void);
136#else 139#else
137#define cio_is_console(irq) 0 140#define cio_is_console(schid) 0
138#define cio_get_console_subchannel() NULL 141#define cio_get_console_subchannel() NULL
139#endif 142#endif
140 143
diff --git a/drivers/s390/cio/cmf.c b/drivers/s390/cio/cmf.c
index b978f7fe8327..0b03714e696a 100644
--- a/drivers/s390/cio/cmf.c
+++ b/drivers/s390/cio/cmf.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.16 $) 2 * linux/drivers/s390/cio/cmf.c ($Revision: 1.19 $)
3 * 3 *
4 * Linux on zSeries Channel Measurement Facility support 4 * Linux on zSeries Channel Measurement Facility support
5 * 5 *
@@ -178,7 +178,7 @@ set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address)
178 /* msch can silently fail, so do it again if necessary */ 178 /* msch can silently fail, so do it again if necessary */
179 for (retry = 0; retry < 3; retry++) { 179 for (retry = 0; retry < 3; retry++) {
180 /* prepare schib */ 180 /* prepare schib */
181 stsch(sch->irq, schib); 181 stsch(sch->schid, schib);
182 schib->pmcw.mme = mme; 182 schib->pmcw.mme = mme;
183 schib->pmcw.mbfc = mbfc; 183 schib->pmcw.mbfc = mbfc;
184 /* address can be either a block address or a block index */ 184 /* address can be either a block address or a block index */
@@ -188,7 +188,7 @@ set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address)
188 schib->pmcw.mbi = address; 188 schib->pmcw.mbi = address;
189 189
190 /* try to submit it */ 190 /* try to submit it */
191 switch(ret = msch_err(sch->irq, schib)) { 191 switch(ret = msch_err(sch->schid, schib)) {
192 case 0: 192 case 0:
193 break; 193 break;
194 case 1: 194 case 1:
@@ -202,7 +202,7 @@ set_schib(struct ccw_device *cdev, u32 mme, int mbfc, unsigned long address)
202 ret = -EINVAL; 202 ret = -EINVAL;
203 break; 203 break;
204 } 204 }
205 stsch(sch->irq, schib); /* restore the schib */ 205 stsch(sch->schid, schib); /* restore the schib */
206 206
207 if (ret) 207 if (ret)
208 break; 208 break;
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 555119cacc27..e565193650c7 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/css.c 2 * drivers/s390/cio/css.c
3 * driver for channel subsystem 3 * driver for channel subsystem
4 * $Revision: 1.85 $ 4 * $Revision: 1.93 $
5 * 5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -21,19 +21,35 @@
21#include "ioasm.h" 21#include "ioasm.h"
22#include "chsc.h" 22#include "chsc.h"
23 23
24unsigned int highest_subchannel;
25int need_rescan = 0; 24int need_rescan = 0;
26int css_init_done = 0; 25int css_init_done = 0;
26static int max_ssid = 0;
27
28struct channel_subsystem *css[__MAX_CSSID + 1];
27 29
28struct pgid global_pgid;
29int css_characteristics_avail = 0; 30int css_characteristics_avail = 0;
30 31
31struct device css_bus_device = { 32inline int
32 .bus_id = "css0", 33for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *data)
33}; 34{
35 struct subchannel_id schid;
36 int ret;
37
38 init_subchannel_id(&schid);
39 ret = -ENODEV;
40 do {
41 do {
42 ret = fn(schid, data);
43 if (ret)
44 break;
45 } while (schid.sch_no++ < __MAX_SUBCHANNEL);
46 schid.sch_no = 0;
47 } while (schid.ssid++ < max_ssid);
48 return ret;
49}
34 50
35static struct subchannel * 51static struct subchannel *
36css_alloc_subchannel(int irq) 52css_alloc_subchannel(struct subchannel_id schid)
37{ 53{
38 struct subchannel *sch; 54 struct subchannel *sch;
39 int ret; 55 int ret;
@@ -41,13 +57,11 @@ css_alloc_subchannel(int irq)
41 sch = kmalloc (sizeof (*sch), GFP_KERNEL | GFP_DMA); 57 sch = kmalloc (sizeof (*sch), GFP_KERNEL | GFP_DMA);
42 if (sch == NULL) 58 if (sch == NULL)
43 return ERR_PTR(-ENOMEM); 59 return ERR_PTR(-ENOMEM);
44 ret = cio_validate_subchannel (sch, irq); 60 ret = cio_validate_subchannel (sch, schid);
45 if (ret < 0) { 61 if (ret < 0) {
46 kfree(sch); 62 kfree(sch);
47 return ERR_PTR(ret); 63 return ERR_PTR(ret);
48 } 64 }
49 if (irq > highest_subchannel)
50 highest_subchannel = irq;
51 65
52 if (sch->st != SUBCHANNEL_TYPE_IO) { 66 if (sch->st != SUBCHANNEL_TYPE_IO) {
53 /* For now we ignore all non-io subchannels. */ 67 /* For now we ignore all non-io subchannels. */
@@ -87,7 +101,7 @@ css_subchannel_release(struct device *dev)
87 struct subchannel *sch; 101 struct subchannel *sch;
88 102
89 sch = to_subchannel(dev); 103 sch = to_subchannel(dev);
90 if (!cio_is_console(sch->irq)) 104 if (!cio_is_console(sch->schid))
91 kfree(sch); 105 kfree(sch);
92} 106}
93 107
@@ -99,7 +113,7 @@ css_register_subchannel(struct subchannel *sch)
99 int ret; 113 int ret;
100 114
101 /* Initialize the subchannel structure */ 115 /* Initialize the subchannel structure */
102 sch->dev.parent = &css_bus_device; 116 sch->dev.parent = &css[0]->device;
103 sch->dev.bus = &css_bus_type; 117 sch->dev.bus = &css_bus_type;
104 sch->dev.release = &css_subchannel_release; 118 sch->dev.release = &css_subchannel_release;
105 119
@@ -114,12 +128,12 @@ css_register_subchannel(struct subchannel *sch)
114} 128}
115 129
116int 130int
117css_probe_device(int irq) 131css_probe_device(struct subchannel_id schid)
118{ 132{
119 int ret; 133 int ret;
120 struct subchannel *sch; 134 struct subchannel *sch;
121 135
122 sch = css_alloc_subchannel(irq); 136 sch = css_alloc_subchannel(schid);
123 if (IS_ERR(sch)) 137 if (IS_ERR(sch))
124 return PTR_ERR(sch); 138 return PTR_ERR(sch);
125 ret = css_register_subchannel(sch); 139 ret = css_register_subchannel(sch);
@@ -132,26 +146,26 @@ static int
132check_subchannel(struct device * dev, void * data) 146check_subchannel(struct device * dev, void * data)
133{ 147{
134 struct subchannel *sch; 148 struct subchannel *sch;
135 int irq = (unsigned long)data; 149 struct subchannel_id *schid = data;
136 150
137 sch = to_subchannel(dev); 151 sch = to_subchannel(dev);
138 return (sch->irq == irq); 152 return schid_equal(&sch->schid, schid);
139} 153}
140 154
141struct subchannel * 155struct subchannel *
142get_subchannel_by_schid(int irq) 156get_subchannel_by_schid(struct subchannel_id schid)
143{ 157{
144 struct device *dev; 158 struct device *dev;
145 159
146 dev = bus_find_device(&css_bus_type, NULL, 160 dev = bus_find_device(&css_bus_type, NULL,
147 (void *)(unsigned long)irq, check_subchannel); 161 (void *)&schid, check_subchannel);
148 162
149 return dev ? to_subchannel(dev) : NULL; 163 return dev ? to_subchannel(dev) : NULL;
150} 164}
151 165
152 166
153static inline int 167static inline int
154css_get_subchannel_status(struct subchannel *sch, int schid) 168css_get_subchannel_status(struct subchannel *sch, struct subchannel_id schid)
155{ 169{
156 struct schib schib; 170 struct schib schib;
157 int cc; 171 int cc;
@@ -170,13 +184,13 @@ css_get_subchannel_status(struct subchannel *sch, int schid)
170} 184}
171 185
172static int 186static int
173css_evaluate_subchannel(int irq, int slow) 187css_evaluate_subchannel(struct subchannel_id schid, int slow)
174{ 188{
175 int event, ret, disc; 189 int event, ret, disc;
176 struct subchannel *sch; 190 struct subchannel *sch;
177 unsigned long flags; 191 unsigned long flags;
178 192
179 sch = get_subchannel_by_schid(irq); 193 sch = get_subchannel_by_schid(schid);
180 disc = sch ? device_is_disconnected(sch) : 0; 194 disc = sch ? device_is_disconnected(sch) : 0;
181 if (disc && slow) { 195 if (disc && slow) {
182 if (sch) 196 if (sch)
@@ -194,9 +208,10 @@ css_evaluate_subchannel(int irq, int slow)
194 put_device(&sch->dev); 208 put_device(&sch->dev);
195 return -EAGAIN; /* Will be done on the slow path. */ 209 return -EAGAIN; /* Will be done on the slow path. */
196 } 210 }
197 event = css_get_subchannel_status(sch, irq); 211 event = css_get_subchannel_status(sch, schid);
198 CIO_MSG_EVENT(4, "Evaluating schid %04x, event %d, %s, %s path.\n", 212 CIO_MSG_EVENT(4, "Evaluating schid 0.%x.%04x, event %d, %s, %s path.\n",
199 irq, event, sch?(disc?"disconnected":"normal"):"unknown", 213 schid.ssid, schid.sch_no, event,
214 sch?(disc?"disconnected":"normal"):"unknown",
200 slow?"slow":"fast"); 215 slow?"slow":"fast");
201 switch (event) { 216 switch (event) {
202 case CIO_NO_PATH: 217 case CIO_NO_PATH:
@@ -253,7 +268,7 @@ css_evaluate_subchannel(int irq, int slow)
253 sch->schib.pmcw.intparm = 0; 268 sch->schib.pmcw.intparm = 0;
254 cio_modify(sch); 269 cio_modify(sch);
255 put_device(&sch->dev); 270 put_device(&sch->dev);
256 ret = css_probe_device(irq); 271 ret = css_probe_device(schid);
257 } else { 272 } else {
258 /* 273 /*
259 * We can't immediately deregister the disconnected 274 * We can't immediately deregister the disconnected
@@ -272,7 +287,7 @@ css_evaluate_subchannel(int irq, int slow)
272 device_trigger_reprobe(sch); 287 device_trigger_reprobe(sch);
273 spin_unlock_irqrestore(&sch->lock, flags); 288 spin_unlock_irqrestore(&sch->lock, flags);
274 } 289 }
275 ret = sch ? 0 : css_probe_device(irq); 290 ret = sch ? 0 : css_probe_device(schid);
276 break; 291 break;
277 default: 292 default:
278 BUG(); 293 BUG();
@@ -281,28 +296,15 @@ css_evaluate_subchannel(int irq, int slow)
281 return ret; 296 return ret;
282} 297}
283 298
284static void 299static int
285css_rescan_devices(void) 300css_rescan_devices(struct subchannel_id schid, void *data)
286{ 301{
287 int irq, ret; 302 return css_evaluate_subchannel(schid, 1);
288
289 for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) {
290 ret = css_evaluate_subchannel(irq, 1);
291 /* No more memory. It doesn't make sense to continue. No
292 * panic because this can happen in midflight and just
293 * because we can't use a new device is no reason to crash
294 * the system. */
295 if (ret == -ENOMEM)
296 break;
297 /* -ENXIO indicates that there are no more subchannels. */
298 if (ret == -ENXIO)
299 break;
300 }
301} 303}
302 304
303struct slow_subchannel { 305struct slow_subchannel {
304 struct list_head slow_list; 306 struct list_head slow_list;
305 unsigned long schid; 307 struct subchannel_id schid;
306}; 308};
307 309
308static LIST_HEAD(slow_subchannels_head); 310static LIST_HEAD(slow_subchannels_head);
@@ -315,7 +317,7 @@ css_trigger_slow_path(void)
315 317
316 if (need_rescan) { 318 if (need_rescan) {
317 need_rescan = 0; 319 need_rescan = 0;
318 css_rescan_devices(); 320 for_each_subchannel(css_rescan_devices, NULL);
319 return; 321 return;
320 } 322 }
321 323
@@ -354,23 +356,31 @@ css_reiterate_subchannels(void)
354 * Called from the machine check handler for subchannel report words. 356 * Called from the machine check handler for subchannel report words.
355 */ 357 */
356int 358int
357css_process_crw(int irq) 359css_process_crw(int rsid1, int rsid2)
358{ 360{
359 int ret; 361 int ret;
362 struct subchannel_id mchk_schid;
360 363
361 CIO_CRW_EVENT(2, "source is subchannel %04X\n", irq); 364 CIO_CRW_EVENT(2, "source is subchannel %04X, subsystem id %x\n",
365 rsid1, rsid2);
362 366
363 if (need_rescan) 367 if (need_rescan)
364 /* We need to iterate all subchannels anyway. */ 368 /* We need to iterate all subchannels anyway. */
365 return -EAGAIN; 369 return -EAGAIN;
370
371 init_subchannel_id(&mchk_schid);
372 mchk_schid.sch_no = rsid1;
373 if (rsid2 != 0)
374 mchk_schid.ssid = (rsid2 >> 8) & 3;
375
366 /* 376 /*
367 * Since we are always presented with IPI in the CRW, we have to 377 * Since we are always presented with IPI in the CRW, we have to
368 * use stsch() to find out if the subchannel in question has come 378 * use stsch() to find out if the subchannel in question has come
369 * or gone. 379 * or gone.
370 */ 380 */
371 ret = css_evaluate_subchannel(irq, 0); 381 ret = css_evaluate_subchannel(mchk_schid, 0);
372 if (ret == -EAGAIN) { 382 if (ret == -EAGAIN) {
373 if (css_enqueue_subchannel_slow(irq)) { 383 if (css_enqueue_subchannel_slow(mchk_schid)) {
374 css_clear_subchannel_slow_list(); 384 css_clear_subchannel_slow_list();
375 need_rescan = 1; 385 need_rescan = 1;
376 } 386 }
@@ -378,22 +388,83 @@ css_process_crw(int irq)
378 return ret; 388 return ret;
379} 389}
380 390
381static void __init 391static int __init
382css_generate_pgid(void) 392__init_channel_subsystem(struct subchannel_id schid, void *data)
383{ 393{
384 /* Let's build our path group ID here. */ 394 struct subchannel *sch;
385 if (css_characteristics_avail && css_general_characteristics.mcss) 395 int ret;
386 global_pgid.cpu_addr = 0x8000; 396
397 if (cio_is_console(schid))
398 sch = cio_get_console_subchannel();
387 else { 399 else {
400 sch = css_alloc_subchannel(schid);
401 if (IS_ERR(sch))
402 ret = PTR_ERR(sch);
403 else
404 ret = 0;
405 switch (ret) {
406 case 0:
407 break;
408 case -ENOMEM:
409 panic("Out of memory in init_channel_subsystem\n");
410 /* -ENXIO: no more subchannels. */
411 case -ENXIO:
412 return ret;
413 default:
414 return 0;
415 }
416 }
417 /*
418 * We register ALL valid subchannels in ioinfo, even those
419 * that have been present before init_channel_subsystem.
420 * These subchannels can't have been registered yet (kmalloc
421 * not working) so we do it now. This is true e.g. for the
422 * console subchannel.
423 */
424 css_register_subchannel(sch);
425 return 0;
426}
427
428static void __init
429css_generate_pgid(struct channel_subsystem *css, u32 tod_high)
430{
431 if (css_characteristics_avail && css_general_characteristics.mcss) {
432 css->global_pgid.pgid_high.ext_cssid.version = 0x80;
433 css->global_pgid.pgid_high.ext_cssid.cssid = css->cssid;
434 } else {
388#ifdef CONFIG_SMP 435#ifdef CONFIG_SMP
389 global_pgid.cpu_addr = hard_smp_processor_id(); 436 css->global_pgid.pgid_high.cpu_addr = hard_smp_processor_id();
390#else 437#else
391 global_pgid.cpu_addr = 0; 438 css->global_pgid.pgid_high.cpu_addr = 0;
392#endif 439#endif
393 } 440 }
394 global_pgid.cpu_id = ((cpuid_t *) __LC_CPUID)->ident; 441 css->global_pgid.cpu_id = ((cpuid_t *) __LC_CPUID)->ident;
395 global_pgid.cpu_model = ((cpuid_t *) __LC_CPUID)->machine; 442 css->global_pgid.cpu_model = ((cpuid_t *) __LC_CPUID)->machine;
396 global_pgid.tod_high = (__u32) (get_clock() >> 32); 443 css->global_pgid.tod_high = tod_high;
444
445}
446
447static void
448channel_subsystem_release(struct device *dev)
449{
450 struct channel_subsystem *css;
451
452 css = to_css(dev);
453 kfree(css);
454}
455
456static inline void __init
457setup_css(int nr)
458{
459 u32 tod_high;
460
461 memset(css[nr], 0, sizeof(struct channel_subsystem));
462 css[nr]->valid = 1;
463 css[nr]->cssid = nr;
464 sprintf(css[nr]->device.bus_id, "css%x", nr);
465 css[nr]->device.release = channel_subsystem_release;
466 tod_high = (u32) (get_clock() >> 32);
467 css_generate_pgid(css[nr], tod_high);
397} 468}
398 469
399/* 470/*
@@ -404,53 +475,50 @@ css_generate_pgid(void)
404static int __init 475static int __init
405init_channel_subsystem (void) 476init_channel_subsystem (void)
406{ 477{
407 int ret, irq; 478 int ret, i;
408 479
409 if (chsc_determine_css_characteristics() == 0) 480 if (chsc_determine_css_characteristics() == 0)
410 css_characteristics_avail = 1; 481 css_characteristics_avail = 1;
411 482
412 css_generate_pgid();
413
414 if ((ret = bus_register(&css_bus_type))) 483 if ((ret = bus_register(&css_bus_type)))
415 goto out; 484 goto out;
416 if ((ret = device_register (&css_bus_device)))
417 goto out_bus;
418 485
486 /* Try to enable MSS. */
487 ret = chsc_enable_facility(CHSC_SDA_OC_MSS);
488 switch (ret) {
489 case 0: /* Success. */
490 max_ssid = __MAX_SSID;
491 break;
492 case -ENOMEM:
493 goto out_bus;
494 default:
495 max_ssid = 0;
496 }
497 /* Setup css structure. */
498 for (i = 0; i <= __MAX_CSSID; i++) {
499 css[i] = kmalloc(sizeof(struct channel_subsystem), GFP_KERNEL);
500 if (!css[i]) {
501 ret = -ENOMEM;
502 goto out_unregister;
503 }
504 setup_css(i);
505 ret = device_register(&css[i]->device);
506 if (ret)
507 goto out_free;
508 }
419 css_init_done = 1; 509 css_init_done = 1;
420 510
421 ctl_set_bit(6, 28); 511 ctl_set_bit(6, 28);
422 512
423 for (irq = 0; irq < __MAX_SUBCHANNELS; irq++) { 513 for_each_subchannel(__init_channel_subsystem, NULL);
424 struct subchannel *sch;
425
426 if (cio_is_console(irq))
427 sch = cio_get_console_subchannel();
428 else {
429 sch = css_alloc_subchannel(irq);
430 if (IS_ERR(sch))
431 ret = PTR_ERR(sch);
432 else
433 ret = 0;
434 if (ret == -ENOMEM)
435 panic("Out of memory in "
436 "init_channel_subsystem\n");
437 /* -ENXIO: no more subchannels. */
438 if (ret == -ENXIO)
439 break;
440 if (ret)
441 continue;
442 }
443 /*
444 * We register ALL valid subchannels in ioinfo, even those
445 * that have been present before init_channel_subsystem.
446 * These subchannels can't have been registered yet (kmalloc
447 * not working) so we do it now. This is true e.g. for the
448 * console subchannel.
449 */
450 css_register_subchannel(sch);
451 }
452 return 0; 514 return 0;
453 515out_free:
516 kfree(css[i]);
517out_unregister:
518 while (i > 0) {
519 i--;
520 device_unregister(&css[i]->device);
521 }
454out_bus: 522out_bus:
455 bus_unregister(&css_bus_type); 523 bus_unregister(&css_bus_type);
456out: 524out:
@@ -481,47 +549,8 @@ struct bus_type css_bus_type = {
481 549
482subsys_initcall(init_channel_subsystem); 550subsys_initcall(init_channel_subsystem);
483 551
484/*
485 * Register root devices for some drivers. The release function must not be
486 * in the device drivers, so we do it here.
487 */
488static void
489s390_root_dev_release(struct device *dev)
490{
491 kfree(dev);
492}
493
494struct device *
495s390_root_dev_register(const char *name)
496{
497 struct device *dev;
498 int ret;
499
500 if (!strlen(name))
501 return ERR_PTR(-EINVAL);
502 dev = kmalloc(sizeof(struct device), GFP_KERNEL);
503 if (!dev)
504 return ERR_PTR(-ENOMEM);
505 memset(dev, 0, sizeof(struct device));
506 strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
507 dev->release = s390_root_dev_release;
508 ret = device_register(dev);
509 if (ret) {
510 kfree(dev);
511 return ERR_PTR(ret);
512 }
513 return dev;
514}
515
516void
517s390_root_dev_unregister(struct device *dev)
518{
519 if (dev)
520 device_unregister(dev);
521}
522
523int 552int
524css_enqueue_subchannel_slow(unsigned long schid) 553css_enqueue_subchannel_slow(struct subchannel_id schid)
525{ 554{
526 struct slow_subchannel *new_slow_sch; 555 struct slow_subchannel *new_slow_sch;
527 unsigned long flags; 556 unsigned long flags;
@@ -564,6 +593,4 @@ css_slow_subchannels_exist(void)
564 593
565MODULE_LICENSE("GPL"); 594MODULE_LICENSE("GPL");
566EXPORT_SYMBOL(css_bus_type); 595EXPORT_SYMBOL(css_bus_type);
567EXPORT_SYMBOL(s390_root_dev_register);
568EXPORT_SYMBOL(s390_root_dev_unregister);
569EXPORT_SYMBOL_GPL(css_characteristics_avail); 596EXPORT_SYMBOL_GPL(css_characteristics_avail);
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index 2004a6c49388..251ebd7a7d3a 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -6,6 +6,8 @@
6 6
7#include <asm/cio.h> 7#include <asm/cio.h>
8 8
9#include "schid.h"
10
9/* 11/*
10 * path grouping stuff 12 * path grouping stuff
11 */ 13 */
@@ -33,19 +35,25 @@ struct path_state {
33 __u8 resvd : 3; /* reserved */ 35 __u8 resvd : 3; /* reserved */
34} __attribute__ ((packed)); 36} __attribute__ ((packed));
35 37
38struct extended_cssid {
39 u8 version;
40 u8 cssid;
41} __attribute__ ((packed));
42
36struct pgid { 43struct pgid {
37 union { 44 union {
38 __u8 fc; /* SPID function code */ 45 __u8 fc; /* SPID function code */
39 struct path_state ps; /* SNID path state */ 46 struct path_state ps; /* SNID path state */
40 } inf; 47 } inf;
41 __u32 cpu_addr : 16; /* CPU address */ 48 union {
49 __u32 cpu_addr : 16; /* CPU address */
50 struct extended_cssid ext_cssid;
51 } pgid_high;
42 __u32 cpu_id : 24; /* CPU identification */ 52 __u32 cpu_id : 24; /* CPU identification */
43 __u32 cpu_model : 16; /* CPU model */ 53 __u32 cpu_model : 16; /* CPU model */
44 __u32 tod_high; /* high word TOD clock */ 54 __u32 tod_high; /* high word TOD clock */
45} __attribute__ ((packed)); 55} __attribute__ ((packed));
46 56
47extern struct pgid global_pgid;
48
49#define MAX_CIWS 8 57#define MAX_CIWS 8
50 58
51/* 59/*
@@ -68,7 +76,8 @@ struct ccw_device_private {
68 atomic_t onoff; 76 atomic_t onoff;
69 unsigned long registered; 77 unsigned long registered;
70 __u16 devno; /* device number */ 78 __u16 devno; /* device number */
71 __u16 irq; /* subchannel number */ 79 __u16 sch_no; /* subchannel number */
80 __u8 ssid; /* subchannel set id */
72 __u8 imask; /* lpm mask for SNID/SID/SPGID */ 81 __u8 imask; /* lpm mask for SNID/SID/SPGID */
73 int iretry; /* retry counter SNID/SID/SPGID */ 82 int iretry; /* retry counter SNID/SID/SPGID */
74 struct { 83 struct {
@@ -121,15 +130,27 @@ struct css_driver {
121extern struct bus_type css_bus_type; 130extern struct bus_type css_bus_type;
122extern struct css_driver io_subchannel_driver; 131extern struct css_driver io_subchannel_driver;
123 132
124int css_probe_device(int irq); 133extern int css_probe_device(struct subchannel_id);
125extern struct subchannel * get_subchannel_by_schid(int irq); 134extern struct subchannel * get_subchannel_by_schid(struct subchannel_id);
126extern unsigned int highest_subchannel;
127extern int css_init_done; 135extern int css_init_done;
128 136extern int for_each_subchannel(int(*fn)(struct subchannel_id, void *), void *);
129#define __MAX_SUBCHANNELS 65536 137
138#define __MAX_SUBCHANNEL 65535
139#define __MAX_SSID 3
140#define __MAX_CHPID 255
141#define __MAX_CSSID 0
142
143struct channel_subsystem {
144 u8 cssid;
145 int valid;
146 struct channel_path *chps[__MAX_CHPID];
147 struct device device;
148 struct pgid global_pgid;
149};
150#define to_css(dev) container_of(dev, struct channel_subsystem, device)
130 151
131extern struct bus_type css_bus_type; 152extern struct bus_type css_bus_type;
132extern struct device css_bus_device; 153extern struct channel_subsystem *css[];
133 154
134/* Some helper functions for disconnected state. */ 155/* Some helper functions for disconnected state. */
135int device_is_disconnected(struct subchannel *); 156int device_is_disconnected(struct subchannel *);
@@ -144,7 +165,7 @@ void device_set_waiting(struct subchannel *);
144void device_kill_pending_timer(struct subchannel *); 165void device_kill_pending_timer(struct subchannel *);
145 166
146/* Helper functions to build lists for the slow path. */ 167/* Helper functions to build lists for the slow path. */
147int css_enqueue_subchannel_slow(unsigned long schid); 168extern int css_enqueue_subchannel_slow(struct subchannel_id schid);
148void css_walk_subchannel_slow_list(void (*fn)(unsigned long)); 169void css_walk_subchannel_slow_list(void (*fn)(unsigned long));
149void css_clear_subchannel_slow_list(void); 170void css_clear_subchannel_slow_list(void);
150int css_slow_subchannels_exist(void); 171int css_slow_subchannels_exist(void);
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 811c9d150637..fa3e4c0a2536 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/device.c 2 * drivers/s390/cio/device.c
3 * bus driver for ccw devices 3 * bus driver for ccw devices
4 * $Revision: 1.131 $ 4 * $Revision: 1.137 $
5 * 5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -59,7 +59,7 @@ ccw_bus_match (struct device * dev, struct device_driver * drv)
59 * Heavily modeled on pci and usb hotplug. 59 * Heavily modeled on pci and usb hotplug.
60 */ 60 */
61static int 61static int
62ccw_hotplug (struct device *dev, char **envp, int num_envp, 62ccw_uevent (struct device *dev, char **envp, int num_envp,
63 char *buffer, int buffer_size) 63 char *buffer, int buffer_size)
64{ 64{
65 struct ccw_device *cdev = to_ccwdev(dev); 65 struct ccw_device *cdev = to_ccwdev(dev);
@@ -110,7 +110,7 @@ ccw_hotplug (struct device *dev, char **envp, int num_envp,
110struct bus_type ccw_bus_type = { 110struct bus_type ccw_bus_type = {
111 .name = "ccw", 111 .name = "ccw",
112 .match = &ccw_bus_match, 112 .match = &ccw_bus_match,
113 .hotplug = &ccw_hotplug, 113 .uevent = &ccw_uevent,
114}; 114};
115 115
116static int io_subchannel_probe (struct device *); 116static int io_subchannel_probe (struct device *);
@@ -374,7 +374,7 @@ online_store (struct device *dev, struct device_attribute *attr, const char *buf
374 int i, force, ret; 374 int i, force, ret;
375 char *tmp; 375 char *tmp;
376 376
377 if (atomic_compare_and_swap(0, 1, &cdev->private->onoff)) 377 if (atomic_cmpxchg(&cdev->private->onoff, 0, 1) != 0)
378 return -EAGAIN; 378 return -EAGAIN;
379 379
380 if (cdev->drv && !try_module_get(cdev->drv->owner)) { 380 if (cdev->drv && !try_module_get(cdev->drv->owner)) {
@@ -535,7 +535,8 @@ ccw_device_register(struct ccw_device *cdev)
535} 535}
536 536
537struct match_data { 537struct match_data {
538 unsigned int devno; 538 unsigned int devno;
539 unsigned int ssid;
539 struct ccw_device * sibling; 540 struct ccw_device * sibling;
540}; 541};
541 542
@@ -548,6 +549,7 @@ match_devno(struct device * dev, void * data)
548 cdev = to_ccwdev(dev); 549 cdev = to_ccwdev(dev);
549 if ((cdev->private->state == DEV_STATE_DISCONNECTED) && 550 if ((cdev->private->state == DEV_STATE_DISCONNECTED) &&
550 (cdev->private->devno == d->devno) && 551 (cdev->private->devno == d->devno) &&
552 (cdev->private->ssid == d->ssid) &&
551 (cdev != d->sibling)) { 553 (cdev != d->sibling)) {
552 cdev->private->state = DEV_STATE_NOT_OPER; 554 cdev->private->state = DEV_STATE_NOT_OPER;
553 return 1; 555 return 1;
@@ -556,11 +558,13 @@ match_devno(struct device * dev, void * data)
556} 558}
557 559
558static struct ccw_device * 560static struct ccw_device *
559get_disc_ccwdev_by_devno(unsigned int devno, struct ccw_device *sibling) 561get_disc_ccwdev_by_devno(unsigned int devno, unsigned int ssid,
562 struct ccw_device *sibling)
560{ 563{
561 struct device *dev; 564 struct device *dev;
562 struct match_data data = { 565 struct match_data data = {
563 .devno = devno, 566 .devno = devno,
567 .ssid = ssid,
564 .sibling = sibling, 568 .sibling = sibling,
565 }; 569 };
566 570
@@ -616,13 +620,13 @@ ccw_device_do_unreg_rereg(void *data)
616 620
617 need_rename = 1; 621 need_rename = 1;
618 other_cdev = get_disc_ccwdev_by_devno(sch->schib.pmcw.dev, 622 other_cdev = get_disc_ccwdev_by_devno(sch->schib.pmcw.dev,
619 cdev); 623 sch->schid.ssid, cdev);
620 if (other_cdev) { 624 if (other_cdev) {
621 struct subchannel *other_sch; 625 struct subchannel *other_sch;
622 626
623 other_sch = to_subchannel(other_cdev->dev.parent); 627 other_sch = to_subchannel(other_cdev->dev.parent);
624 if (get_device(&other_sch->dev)) { 628 if (get_device(&other_sch->dev)) {
625 stsch(other_sch->irq, &other_sch->schib); 629 stsch(other_sch->schid, &other_sch->schib);
626 if (other_sch->schib.pmcw.dnv) { 630 if (other_sch->schib.pmcw.dnv) {
627 other_sch->schib.pmcw.intparm = 0; 631 other_sch->schib.pmcw.intparm = 0;
628 cio_modify(other_sch); 632 cio_modify(other_sch);
@@ -639,8 +643,8 @@ ccw_device_do_unreg_rereg(void *data)
639 if (test_and_clear_bit(1, &cdev->private->registered)) 643 if (test_and_clear_bit(1, &cdev->private->registered))
640 device_del(&cdev->dev); 644 device_del(&cdev->dev);
641 if (need_rename) 645 if (need_rename)
642 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", 646 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x",
643 sch->schib.pmcw.dev); 647 sch->schid.ssid, sch->schib.pmcw.dev);
644 PREPARE_WORK(&cdev->private->kick_work, 648 PREPARE_WORK(&cdev->private->kick_work,
645 ccw_device_add_changed, (void *)cdev); 649 ccw_device_add_changed, (void *)cdev);
646 queue_work(ccw_device_work, &cdev->private->kick_work); 650 queue_work(ccw_device_work, &cdev->private->kick_work);
@@ -769,18 +773,20 @@ io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch)
769 sch->dev.driver_data = cdev; 773 sch->dev.driver_data = cdev;
770 sch->driver = &io_subchannel_driver; 774 sch->driver = &io_subchannel_driver;
771 cdev->ccwlock = &sch->lock; 775 cdev->ccwlock = &sch->lock;
776
772 /* Init private data. */ 777 /* Init private data. */
773 priv = cdev->private; 778 priv = cdev->private;
774 priv->devno = sch->schib.pmcw.dev; 779 priv->devno = sch->schib.pmcw.dev;
775 priv->irq = sch->irq; 780 priv->ssid = sch->schid.ssid;
781 priv->sch_no = sch->schid.sch_no;
776 priv->state = DEV_STATE_NOT_OPER; 782 priv->state = DEV_STATE_NOT_OPER;
777 INIT_LIST_HEAD(&priv->cmb_list); 783 INIT_LIST_HEAD(&priv->cmb_list);
778 init_waitqueue_head(&priv->wait_q); 784 init_waitqueue_head(&priv->wait_q);
779 init_timer(&priv->timer); 785 init_timer(&priv->timer);
780 786
781 /* Set an initial name for the device. */ 787 /* Set an initial name for the device. */
782 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.0.%04x", 788 snprintf (cdev->dev.bus_id, BUS_ID_SIZE, "0.%x.%04x",
783 sch->schib.pmcw.dev); 789 sch->schid.ssid, sch->schib.pmcw.dev);
784 790
785 /* Increase counter of devices currently in recognition. */ 791 /* Increase counter of devices currently in recognition. */
786 atomic_inc(&ccw_device_init_count); 792 atomic_inc(&ccw_device_init_count);
@@ -951,7 +957,7 @@ io_subchannel_shutdown(struct device *dev)
951 sch = to_subchannel(dev); 957 sch = to_subchannel(dev);
952 cdev = dev->driver_data; 958 cdev = dev->driver_data;
953 959
954 if (cio_is_console(sch->irq)) 960 if (cio_is_console(sch->schid))
955 return; 961 return;
956 if (!sch->schib.pmcw.ena) 962 if (!sch->schib.pmcw.ena)
957 /* Nothing to do. */ 963 /* Nothing to do. */
@@ -986,10 +992,6 @@ ccw_device_console_enable (struct ccw_device *cdev, struct subchannel *sch)
986 cdev->dev = (struct device) { 992 cdev->dev = (struct device) {
987 .parent = &sch->dev, 993 .parent = &sch->dev,
988 }; 994 };
989 /* Initialize the subchannel structure */
990 sch->dev.parent = &css_bus_device;
991 sch->dev.bus = &css_bus_type;
992
993 rc = io_subchannel_recog(cdev, sch); 995 rc = io_subchannel_recog(cdev, sch);
994 if (rc) 996 if (rc)
995 return rc; 997 return rc;
@@ -1146,6 +1148,16 @@ ccw_driver_unregister (struct ccw_driver *cdriver)
1146 driver_unregister(&cdriver->driver); 1148 driver_unregister(&cdriver->driver);
1147} 1149}
1148 1150
1151/* Helper func for qdio. */
1152struct subchannel_id
1153ccw_device_get_subchannel_id(struct ccw_device *cdev)
1154{
1155 struct subchannel *sch;
1156
1157 sch = to_subchannel(cdev->dev.parent);
1158 return sch->schid;
1159}
1160
1149MODULE_LICENSE("GPL"); 1161MODULE_LICENSE("GPL");
1150EXPORT_SYMBOL(ccw_device_set_online); 1162EXPORT_SYMBOL(ccw_device_set_online);
1151EXPORT_SYMBOL(ccw_device_set_offline); 1163EXPORT_SYMBOL(ccw_device_set_offline);
@@ -1155,3 +1167,4 @@ EXPORT_SYMBOL(get_ccwdev_by_busid);
1155EXPORT_SYMBOL(ccw_bus_type); 1167EXPORT_SYMBOL(ccw_bus_type);
1156EXPORT_SYMBOL(ccw_device_work); 1168EXPORT_SYMBOL(ccw_device_work);
1157EXPORT_SYMBOL(ccw_device_notify_work); 1169EXPORT_SYMBOL(ccw_device_notify_work);
1170EXPORT_SYMBOL_GPL(ccw_device_get_subchannel_id);
diff --git a/drivers/s390/cio/device.h b/drivers/s390/cio/device.h
index a3aa056d7245..11587ebb7289 100644
--- a/drivers/s390/cio/device.h
+++ b/drivers/s390/cio/device.h
@@ -110,6 +110,7 @@ int ccw_device_stlck(struct ccw_device *);
110 110
111/* qdio needs this. */ 111/* qdio needs this. */
112void ccw_device_set_timeout(struct ccw_device *, int); 112void ccw_device_set_timeout(struct ccw_device *, int);
113extern struct subchannel_id ccw_device_get_subchannel_id(struct ccw_device *);
113 114
114void retry_set_schib(struct ccw_device *cdev); 115void retry_set_schib(struct ccw_device *cdev);
115#endif 116#endif
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index c1c89f4fd4e3..23d12b65e5fa 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -133,7 +133,7 @@ ccw_device_cancel_halt_clear(struct ccw_device *cdev)
133 int ret; 133 int ret;
134 134
135 sch = to_subchannel(cdev->dev.parent); 135 sch = to_subchannel(cdev->dev.parent);
136 ret = stsch(sch->irq, &sch->schib); 136 ret = stsch(sch->schid, &sch->schib);
137 if (ret || !sch->schib.pmcw.dnv) 137 if (ret || !sch->schib.pmcw.dnv)
138 return -ENODEV; 138 return -ENODEV;
139 if (!sch->schib.pmcw.ena || sch->schib.scsw.actl == 0) 139 if (!sch->schib.pmcw.ena || sch->schib.scsw.actl == 0)
@@ -231,7 +231,7 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
231 * through ssch() and the path information is up to date. 231 * through ssch() and the path information is up to date.
232 */ 232 */
233 old_lpm = sch->lpm; 233 old_lpm = sch->lpm;
234 stsch(sch->irq, &sch->schib); 234 stsch(sch->schid, &sch->schib);
235 sch->lpm = sch->schib.pmcw.pim & 235 sch->lpm = sch->schib.pmcw.pim &
236 sch->schib.pmcw.pam & 236 sch->schib.pmcw.pam &
237 sch->schib.pmcw.pom & 237 sch->schib.pmcw.pom &
@@ -257,8 +257,9 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
257 switch (state) { 257 switch (state) {
258 case DEV_STATE_NOT_OPER: 258 case DEV_STATE_NOT_OPER:
259 CIO_DEBUG(KERN_WARNING, 2, 259 CIO_DEBUG(KERN_WARNING, 2,
260 "SenseID : unknown device %04x on subchannel %04x\n", 260 "SenseID : unknown device %04x on subchannel "
261 cdev->private->devno, sch->irq); 261 "0.%x.%04x\n", cdev->private->devno,
262 sch->schid.ssid, sch->schid.sch_no);
262 break; 263 break;
263 case DEV_STATE_OFFLINE: 264 case DEV_STATE_OFFLINE:
264 if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) { 265 if (cdev->private->state == DEV_STATE_DISCONNECTED_SENSE_ID) {
@@ -282,16 +283,18 @@ ccw_device_recog_done(struct ccw_device *cdev, int state)
282 return; 283 return;
283 } 284 }
284 /* Issue device info message. */ 285 /* Issue device info message. */
285 CIO_DEBUG(KERN_INFO, 2, "SenseID : device %04x reports: " 286 CIO_DEBUG(KERN_INFO, 2, "SenseID : device 0.%x.%04x reports: "
286 "CU Type/Mod = %04X/%02X, Dev Type/Mod = " 287 "CU Type/Mod = %04X/%02X, Dev Type/Mod = "
287 "%04X/%02X\n", cdev->private->devno, 288 "%04X/%02X\n",
289 cdev->private->ssid, cdev->private->devno,
288 cdev->id.cu_type, cdev->id.cu_model, 290 cdev->id.cu_type, cdev->id.cu_model,
289 cdev->id.dev_type, cdev->id.dev_model); 291 cdev->id.dev_type, cdev->id.dev_model);
290 break; 292 break;
291 case DEV_STATE_BOXED: 293 case DEV_STATE_BOXED:
292 CIO_DEBUG(KERN_WARNING, 2, 294 CIO_DEBUG(KERN_WARNING, 2,
293 "SenseID : boxed device %04x on subchannel %04x\n", 295 "SenseID : boxed device %04x on subchannel "
294 cdev->private->devno, sch->irq); 296 "0.%x.%04x\n", cdev->private->devno,
297 sch->schid.ssid, sch->schid.sch_no);
295 break; 298 break;
296 } 299 }
297 cdev->private->state = state; 300 cdev->private->state = state;
@@ -359,7 +362,7 @@ ccw_device_done(struct ccw_device *cdev, int state)
359 if (state == DEV_STATE_BOXED) 362 if (state == DEV_STATE_BOXED)
360 CIO_DEBUG(KERN_WARNING, 2, 363 CIO_DEBUG(KERN_WARNING, 2,
361 "Boxed device %04x on subchannel %04x\n", 364 "Boxed device %04x on subchannel %04x\n",
362 cdev->private->devno, sch->irq); 365 cdev->private->devno, sch->schid.sch_no);
363 366
364 if (cdev->private->flags.donotify) { 367 if (cdev->private->flags.donotify) {
365 cdev->private->flags.donotify = 0; 368 cdev->private->flags.donotify = 0;
@@ -592,7 +595,7 @@ ccw_device_offline(struct ccw_device *cdev)
592 struct subchannel *sch; 595 struct subchannel *sch;
593 596
594 sch = to_subchannel(cdev->dev.parent); 597 sch = to_subchannel(cdev->dev.parent);
595 if (stsch(sch->irq, &sch->schib) || !sch->schib.pmcw.dnv) 598 if (stsch(sch->schid, &sch->schib) || !sch->schib.pmcw.dnv)
596 return -ENODEV; 599 return -ENODEV;
597 if (cdev->private->state != DEV_STATE_ONLINE) { 600 if (cdev->private->state != DEV_STATE_ONLINE) {
598 if (sch->schib.scsw.actl != 0) 601 if (sch->schib.scsw.actl != 0)
@@ -711,7 +714,7 @@ ccw_device_online_verify(struct ccw_device *cdev, enum dev_event dev_event)
711 * Since we might not just be coming from an interrupt from the 714 * Since we might not just be coming from an interrupt from the
712 * subchannel we have to update the schib. 715 * subchannel we have to update the schib.
713 */ 716 */
714 stsch(sch->irq, &sch->schib); 717 stsch(sch->schid, &sch->schib);
715 718
716 if (sch->schib.scsw.actl != 0 || 719 if (sch->schib.scsw.actl != 0 ||
717 (cdev->private->irb.scsw.stctl & SCSW_STCTL_STATUS_PEND)) { 720 (cdev->private->irb.scsw.stctl & SCSW_STCTL_STATUS_PEND)) {
@@ -923,7 +926,7 @@ ccw_device_wait4io_irq(struct ccw_device *cdev, enum dev_event dev_event)
923 926
924 /* Iff device is idle, reset timeout. */ 927 /* Iff device is idle, reset timeout. */
925 sch = to_subchannel(cdev->dev.parent); 928 sch = to_subchannel(cdev->dev.parent);
926 if (!stsch(sch->irq, &sch->schib)) 929 if (!stsch(sch->schid, &sch->schib))
927 if (sch->schib.scsw.actl == 0) 930 if (sch->schib.scsw.actl == 0)
928 ccw_device_set_timeout(cdev, 0); 931 ccw_device_set_timeout(cdev, 0);
929 /* Call the handler. */ 932 /* Call the handler. */
@@ -1035,7 +1038,7 @@ device_trigger_reprobe(struct subchannel *sch)
1035 return; 1038 return;
1036 1039
1037 /* Update some values. */ 1040 /* Update some values. */
1038 if (stsch(sch->irq, &sch->schib)) 1041 if (stsch(sch->schid, &sch->schib))
1039 return; 1042 return;
1040 1043
1041 /* 1044 /*
diff --git a/drivers/s390/cio/device_id.c b/drivers/s390/cio/device_id.c
index 0e68fb511dc9..04ceba343db8 100644
--- a/drivers/s390/cio/device_id.c
+++ b/drivers/s390/cio/device_id.c
@@ -27,7 +27,7 @@
27/* 27/*
28 * diag210 is used under VM to get information about a virtual device 28 * diag210 is used under VM to get information about a virtual device
29 */ 29 */
30#ifdef CONFIG_ARCH_S390X 30#ifdef CONFIG_64BIT
31int 31int
32diag210(struct diag210 * addr) 32diag210(struct diag210 * addr)
33{ 33{
@@ -256,16 +256,17 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
256 * sense id information. So, for intervention required, 256 * sense id information. So, for intervention required,
257 * we use the "whack it until it talks" strategy... 257 * we use the "whack it until it talks" strategy...
258 */ 258 */
259 CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel %04x " 259 CIO_MSG_EVENT(2, "SenseID : device %04x on Subchannel "
260 "reports cmd reject\n", 260 "0.%x.%04x reports cmd reject\n",
261 cdev->private->devno, sch->irq); 261 cdev->private->devno, sch->schid.ssid,
262 sch->schid.sch_no);
262 return -EOPNOTSUPP; 263 return -EOPNOTSUPP;
263 } 264 }
264 if (irb->esw.esw0.erw.cons) { 265 if (irb->esw.esw0.erw.cons) {
265 CIO_MSG_EVENT(2, "SenseID : UC on dev %04x, " 266 CIO_MSG_EVENT(2, "SenseID : UC on dev 0.%x.%04x, "
266 "lpum %02X, cnt %02d, sns :" 267 "lpum %02X, cnt %02d, sns :"
267 " %02X%02X%02X%02X %02X%02X%02X%02X ...\n", 268 " %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
268 cdev->private->devno, 269 cdev->private->ssid, cdev->private->devno,
269 irb->esw.esw0.sublog.lpum, 270 irb->esw.esw0.sublog.lpum,
270 irb->esw.esw0.erw.scnt, 271 irb->esw.esw0.erw.scnt,
271 irb->ecw[0], irb->ecw[1], 272 irb->ecw[0], irb->ecw[1],
@@ -277,16 +278,17 @@ ccw_device_check_sense_id(struct ccw_device *cdev)
277 if (irb->scsw.cc == 3) { 278 if (irb->scsw.cc == 3) {
278 if ((sch->orb.lpm & 279 if ((sch->orb.lpm &
279 sch->schib.pmcw.pim & sch->schib.pmcw.pam) != 0) 280 sch->schib.pmcw.pim & sch->schib.pmcw.pam) != 0)
280 CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x on" 281 CIO_MSG_EVENT(2, "SenseID : path %02X for device %04x "
281 " subchannel %04x is 'not operational'\n", 282 "on subchannel 0.%x.%04x is "
282 sch->orb.lpm, cdev->private->devno, 283 "'not operational'\n", sch->orb.lpm,
283 sch->irq); 284 cdev->private->devno, sch->schid.ssid,
285 sch->schid.sch_no);
284 return -EACCES; 286 return -EACCES;
285 } 287 }
286 /* Hmm, whatever happened, try again. */ 288 /* Hmm, whatever happened, try again. */
287 CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on " 289 CIO_MSG_EVENT(2, "SenseID : start_IO() for device %04x on "
288 "subchannel %04x returns status %02X%02X\n", 290 "subchannel 0.%x.%04x returns status %02X%02X\n",
289 cdev->private->devno, sch->irq, 291 cdev->private->devno, sch->schid.ssid, sch->schid.sch_no,
290 irb->scsw.dstat, irb->scsw.cstat); 292 irb->scsw.dstat, irb->scsw.cstat);
291 return -EAGAIN; 293 return -EAGAIN;
292} 294}
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 85a3026e6900..143b6c25a4e6 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * drivers/s390/cio/device_ops.c 2 * drivers/s390/cio/device_ops.c
3 * 3 *
4 * $Revision: 1.57 $ 4 * $Revision: 1.58 $
5 * 5 *
6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH, 6 * Copyright (C) 2002 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation 7 * IBM Corporation
@@ -570,7 +570,7 @@ ccw_device_get_chp_desc(struct ccw_device *cdev, int chp_no)
570int 570int
571_ccw_device_get_subchannel_number(struct ccw_device *cdev) 571_ccw_device_get_subchannel_number(struct ccw_device *cdev)
572{ 572{
573 return cdev->private->irq; 573 return cdev->private->sch_no;
574} 574}
575 575
576int 576int
diff --git a/drivers/s390/cio/device_pgid.c b/drivers/s390/cio/device_pgid.c
index 0adac8a67331..052832d03d38 100644
--- a/drivers/s390/cio/device_pgid.c
+++ b/drivers/s390/cio/device_pgid.c
@@ -22,6 +22,7 @@
22#include "cio_debug.h" 22#include "cio_debug.h"
23#include "css.h" 23#include "css.h"
24#include "device.h" 24#include "device.h"
25#include "ioasm.h"
25 26
26/* 27/*
27 * Start Sense Path Group ID helper function. Used in ccw_device_recog 28 * Start Sense Path Group ID helper function. Used in ccw_device_recog
@@ -56,10 +57,10 @@ __ccw_device_sense_pgid_start(struct ccw_device *cdev)
56 if (ret != -EACCES) 57 if (ret != -EACCES)
57 return ret; 58 return ret;
58 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " 59 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel "
59 "%04x, lpm %02X, became 'not " 60 "0.%x.%04x, lpm %02X, became 'not "
60 "operational'\n", 61 "operational'\n",
61 cdev->private->devno, sch->irq, 62 cdev->private->devno, sch->schid.ssid,
62 cdev->private->imask); 63 sch->schid.sch_no, cdev->private->imask);
63 64
64 } 65 }
65 cdev->private->imask >>= 1; 66 cdev->private->imask >>= 1;
@@ -105,10 +106,10 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
105 return -EOPNOTSUPP; 106 return -EOPNOTSUPP;
106 } 107 }
107 if (irb->esw.esw0.erw.cons) { 108 if (irb->esw.esw0.erw.cons) {
108 CIO_MSG_EVENT(2, "SNID - device %04x, unit check, " 109 CIO_MSG_EVENT(2, "SNID - device 0.%x.%04x, unit check, "
109 "lpum %02X, cnt %02d, sns : " 110 "lpum %02X, cnt %02d, sns : "
110 "%02X%02X%02X%02X %02X%02X%02X%02X ...\n", 111 "%02X%02X%02X%02X %02X%02X%02X%02X ...\n",
111 cdev->private->devno, 112 cdev->private->ssid, cdev->private->devno,
112 irb->esw.esw0.sublog.lpum, 113 irb->esw.esw0.sublog.lpum,
113 irb->esw.esw0.erw.scnt, 114 irb->esw.esw0.erw.scnt,
114 irb->ecw[0], irb->ecw[1], 115 irb->ecw[0], irb->ecw[1],
@@ -118,15 +119,17 @@ __ccw_device_check_sense_pgid(struct ccw_device *cdev)
118 return -EAGAIN; 119 return -EAGAIN;
119 } 120 }
120 if (irb->scsw.cc == 3) { 121 if (irb->scsw.cc == 3) {
121 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel " 122 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x,"
122 "%04x, lpm %02X, became 'not operational'\n", 123 " lpm %02X, became 'not operational'\n",
123 cdev->private->devno, sch->irq, sch->orb.lpm); 124 cdev->private->devno, sch->schid.ssid,
125 sch->schid.sch_no, sch->orb.lpm);
124 return -EACCES; 126 return -EACCES;
125 } 127 }
126 if (cdev->private->pgid.inf.ps.state2 == SNID_STATE2_RESVD_ELSE) { 128 if (cdev->private->pgid.inf.ps.state2 == SNID_STATE2_RESVD_ELSE) {
127 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel %04x " 129 CIO_MSG_EVENT(2, "SNID - Device %04x on Subchannel 0.%x.%04x "
128 "is reserved by someone else\n", 130 "is reserved by someone else\n",
129 cdev->private->devno, sch->irq); 131 cdev->private->devno, sch->schid.ssid,
132 sch->schid.sch_no);
130 return -EUSERS; 133 return -EUSERS;
131 } 134 }
132 return 0; 135 return 0;
@@ -162,7 +165,7 @@ ccw_device_sense_pgid_irq(struct ccw_device *cdev, enum dev_event dev_event)
162 /* 0, -ETIME, -EOPNOTSUPP, -EAGAIN, -EACCES or -EUSERS */ 165 /* 0, -ETIME, -EOPNOTSUPP, -EAGAIN, -EACCES or -EUSERS */
163 case 0: /* Sense Path Group ID successful. */ 166 case 0: /* Sense Path Group ID successful. */
164 if (cdev->private->pgid.inf.ps.state1 == SNID_STATE1_RESET) 167 if (cdev->private->pgid.inf.ps.state1 == SNID_STATE1_RESET)
165 memcpy(&cdev->private->pgid, &global_pgid, 168 memcpy(&cdev->private->pgid, &css[0]->global_pgid,
166 sizeof(struct pgid)); 169 sizeof(struct pgid));
167 ccw_device_sense_pgid_done(cdev, 0); 170 ccw_device_sense_pgid_done(cdev, 0);
168 break; 171 break;
@@ -235,8 +238,9 @@ __ccw_device_do_pgid(struct ccw_device *cdev, __u8 func)
235 sch->lpm &= ~cdev->private->imask; 238 sch->lpm &= ~cdev->private->imask;
236 sch->vpm &= ~cdev->private->imask; 239 sch->vpm &= ~cdev->private->imask;
237 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " 240 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel "
238 "%04x, lpm %02X, became 'not operational'\n", 241 "0.%x.%04x, lpm %02X, became 'not operational'\n",
239 cdev->private->devno, sch->irq, cdev->private->imask); 242 cdev->private->devno, sch->schid.ssid,
243 sch->schid.sch_no, cdev->private->imask);
240 return ret; 244 return ret;
241} 245}
242 246
@@ -258,8 +262,10 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
258 if (irb->ecw[0] & SNS0_CMD_REJECT) 262 if (irb->ecw[0] & SNS0_CMD_REJECT)
259 return -EOPNOTSUPP; 263 return -EOPNOTSUPP;
260 /* Hmm, whatever happened, try again. */ 264 /* Hmm, whatever happened, try again. */
261 CIO_MSG_EVENT(2, "SPID - device %04x, unit check, cnt %02d, " 265 CIO_MSG_EVENT(2, "SPID - device 0.%x.%04x, unit check, "
266 "cnt %02d, "
262 "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n", 267 "sns : %02X%02X%02X%02X %02X%02X%02X%02X ...\n",
268 cdev->private->ssid,
263 cdev->private->devno, irb->esw.esw0.erw.scnt, 269 cdev->private->devno, irb->esw.esw0.erw.scnt,
264 irb->ecw[0], irb->ecw[1], 270 irb->ecw[0], irb->ecw[1],
265 irb->ecw[2], irb->ecw[3], 271 irb->ecw[2], irb->ecw[3],
@@ -268,10 +274,10 @@ __ccw_device_check_pgid(struct ccw_device *cdev)
268 return -EAGAIN; 274 return -EAGAIN;
269 } 275 }
270 if (irb->scsw.cc == 3) { 276 if (irb->scsw.cc == 3) {
271 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel " 277 CIO_MSG_EVENT(2, "SPID - Device %04x on Subchannel 0.%x.%04x,"
272 "%04x, lpm %02X, became 'not operational'\n", 278 " lpm %02X, became 'not operational'\n",
273 cdev->private->devno, sch->irq, 279 cdev->private->devno, sch->schid.ssid,
274 cdev->private->imask); 280 sch->schid.sch_no, cdev->private->imask);
275 return -EACCES; 281 return -EACCES;
276 } 282 }
277 return 0; 283 return 0;
@@ -364,8 +370,22 @@ ccw_device_verify_irq(struct ccw_device *cdev, enum dev_event dev_event)
364void 370void
365ccw_device_verify_start(struct ccw_device *cdev) 371ccw_device_verify_start(struct ccw_device *cdev)
366{ 372{
373 struct subchannel *sch = to_subchannel(cdev->dev.parent);
374
367 cdev->private->flags.pgid_single = 0; 375 cdev->private->flags.pgid_single = 0;
368 cdev->private->iretry = 5; 376 cdev->private->iretry = 5;
377 /*
378 * Update sch->lpm with current values to catch paths becoming
379 * available again.
380 */
381 if (stsch(sch->schid, &sch->schib)) {
382 ccw_device_verify_done(cdev, -ENODEV);
383 return;
384 }
385 sch->lpm = sch->schib.pmcw.pim &
386 sch->schib.pmcw.pam &
387 sch->schib.pmcw.pom &
388 sch->opm;
369 __ccw_device_verify_start(cdev); 389 __ccw_device_verify_start(cdev);
370} 390}
371 391
diff --git a/drivers/s390/cio/device_status.c b/drivers/s390/cio/device_status.c
index 12a24d4331a2..db09c209098b 100644
--- a/drivers/s390/cio/device_status.c
+++ b/drivers/s390/cio/device_status.c
@@ -36,15 +36,16 @@ ccw_device_msg_control_check(struct ccw_device *cdev, struct irb *irb)
36 36
37 CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check " 37 CIO_MSG_EVENT(0, "Channel-Check or Interface-Control-Check "
38 "received" 38 "received"
39 " ... device %04X on subchannel %04X, dev_stat " 39 " ... device %04x on subchannel 0.%x.%04x, dev_stat "
40 ": %02X sch_stat : %02X\n", 40 ": %02X sch_stat : %02X\n",
41 cdev->private->devno, cdev->private->irq, 41 cdev->private->devno, cdev->private->ssid,
42 cdev->private->sch_no,
42 irb->scsw.dstat, irb->scsw.cstat); 43 irb->scsw.dstat, irb->scsw.cstat);
43 44
44 if (irb->scsw.cc != 3) { 45 if (irb->scsw.cc != 3) {
45 char dbf_text[15]; 46 char dbf_text[15];
46 47
47 sprintf(dbf_text, "chk%x", cdev->private->irq); 48 sprintf(dbf_text, "chk%x", cdev->private->sch_no);
48 CIO_TRACE_EVENT(0, dbf_text); 49 CIO_TRACE_EVENT(0, dbf_text);
49 CIO_HEX_EVENT(0, irb, sizeof (struct irb)); 50 CIO_HEX_EVENT(0, irb, sizeof (struct irb));
50 } 51 }
@@ -59,10 +60,11 @@ ccw_device_path_notoper(struct ccw_device *cdev)
59 struct subchannel *sch; 60 struct subchannel *sch;
60 61
61 sch = to_subchannel(cdev->dev.parent); 62 sch = to_subchannel(cdev->dev.parent);
62 stsch (sch->irq, &sch->schib); 63 stsch (sch->schid, &sch->schib);
63 64
64 CIO_MSG_EVENT(0, "%s(%04x) - path(s) %02x are " 65 CIO_MSG_EVENT(0, "%s(0.%x.%04x) - path(s) %02x are "
65 "not operational \n", __FUNCTION__, sch->irq, 66 "not operational \n", __FUNCTION__,
67 sch->schid.ssid, sch->schid.sch_no,
66 sch->schib.pmcw.pnom); 68 sch->schib.pmcw.pnom);
67 69
68 sch->lpm &= ~sch->schib.pmcw.pnom; 70 sch->lpm &= ~sch->schib.pmcw.pnom;
diff --git a/drivers/s390/cio/ioasm.h b/drivers/s390/cio/ioasm.h
index 45480a2bc4c0..95a9462f9a91 100644
--- a/drivers/s390/cio/ioasm.h
+++ b/drivers/s390/cio/ioasm.h
@@ -1,12 +1,13 @@
1#ifndef S390_CIO_IOASM_H 1#ifndef S390_CIO_IOASM_H
2#define S390_CIO_IOASM_H 2#define S390_CIO_IOASM_H
3 3
4#include "schid.h"
5
4/* 6/*
5 * TPI info structure 7 * TPI info structure
6 */ 8 */
7struct tpi_info { 9struct tpi_info {
8 __u32 reserved1 : 16; /* reserved 0x00000001 */ 10 struct subchannel_id schid;
9 __u32 irq : 16; /* aka. subchannel number */
10 __u32 intparm; /* interruption parameter */ 11 __u32 intparm; /* interruption parameter */
11 __u32 adapter_IO : 1; 12 __u32 adapter_IO : 1;
12 __u32 reserved2 : 1; 13 __u32 reserved2 : 1;
@@ -21,7 +22,8 @@ struct tpi_info {
21 * Some S390 specific IO instructions as inline 22 * Some S390 specific IO instructions as inline
22 */ 23 */
23 24
24static inline int stsch(int irq, volatile struct schib *addr) 25static inline int stsch(struct subchannel_id schid,
26 volatile struct schib *addr)
25{ 27{
26 int ccode; 28 int ccode;
27 29
@@ -31,12 +33,42 @@ static inline int stsch(int irq, volatile struct schib *addr)
31 " ipm %0\n" 33 " ipm %0\n"
32 " srl %0,28" 34 " srl %0,28"
33 : "=d" (ccode) 35 : "=d" (ccode)
34 : "d" (irq | 0x10000), "a" (addr) 36 : "d" (schid), "a" (addr), "m" (*addr)
37 : "cc", "1" );
38 return ccode;
39}
40
41static inline int stsch_err(struct subchannel_id schid,
42 volatile struct schib *addr)
43{
44 int ccode;
45
46 __asm__ __volatile__(
47 " lhi %0,%3\n"
48 " lr 1,%1\n"
49 " stsch 0(%2)\n"
50 "0: ipm %0\n"
51 " srl %0,28\n"
52 "1:\n"
53#ifdef CONFIG_64BIT
54 ".section __ex_table,\"a\"\n"
55 " .align 8\n"
56 " .quad 0b,1b\n"
57 ".previous"
58#else
59 ".section __ex_table,\"a\"\n"
60 " .align 4\n"
61 " .long 0b,1b\n"
62 ".previous"
63#endif
64 : "=&d" (ccode)
65 : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr)
35 : "cc", "1" ); 66 : "cc", "1" );
36 return ccode; 67 return ccode;
37} 68}
38 69
39static inline int msch(int irq, volatile struct schib *addr) 70static inline int msch(struct subchannel_id schid,
71 volatile struct schib *addr)
40{ 72{
41 int ccode; 73 int ccode;
42 74
@@ -46,12 +78,13 @@ static inline int msch(int irq, volatile struct schib *addr)
46 " ipm %0\n" 78 " ipm %0\n"
47 " srl %0,28" 79 " srl %0,28"
48 : "=d" (ccode) 80 : "=d" (ccode)
49 : "d" (irq | 0x10000L), "a" (addr) 81 : "d" (schid), "a" (addr), "m" (*addr)
50 : "cc", "1" ); 82 : "cc", "1" );
51 return ccode; 83 return ccode;
52} 84}
53 85
54static inline int msch_err(int irq, volatile struct schib *addr) 86static inline int msch_err(struct subchannel_id schid,
87 volatile struct schib *addr)
55{ 88{
56 int ccode; 89 int ccode;
57 90
@@ -62,7 +95,7 @@ static inline int msch_err(int irq, volatile struct schib *addr)
62 "0: ipm %0\n" 95 "0: ipm %0\n"
63 " srl %0,28\n" 96 " srl %0,28\n"
64 "1:\n" 97 "1:\n"
65#ifdef CONFIG_ARCH_S390X 98#ifdef CONFIG_64BIT
66 ".section __ex_table,\"a\"\n" 99 ".section __ex_table,\"a\"\n"
67 " .align 8\n" 100 " .align 8\n"
68 " .quad 0b,1b\n" 101 " .quad 0b,1b\n"
@@ -74,12 +107,13 @@ static inline int msch_err(int irq, volatile struct schib *addr)
74 ".previous" 107 ".previous"
75#endif 108#endif
76 : "=&d" (ccode) 109 : "=&d" (ccode)
77 : "d" (irq | 0x10000L), "a" (addr), "K" (-EIO) 110 : "d" (schid), "a" (addr), "K" (-EIO), "m" (*addr)
78 : "cc", "1" ); 111 : "cc", "1" );
79 return ccode; 112 return ccode;
80} 113}
81 114
82static inline int tsch(int irq, volatile struct irb *addr) 115static inline int tsch(struct subchannel_id schid,
116 volatile struct irb *addr)
83{ 117{
84 int ccode; 118 int ccode;
85 119
@@ -89,7 +123,7 @@ static inline int tsch(int irq, volatile struct irb *addr)
89 " ipm %0\n" 123 " ipm %0\n"
90 " srl %0,28" 124 " srl %0,28"
91 : "=d" (ccode) 125 : "=d" (ccode)
92 : "d" (irq | 0x10000L), "a" (addr) 126 : "d" (schid), "a" (addr), "m" (*addr)
93 : "cc", "1" ); 127 : "cc", "1" );
94 return ccode; 128 return ccode;
95} 129}
@@ -103,12 +137,13 @@ static inline int tpi( volatile struct tpi_info *addr)
103 " ipm %0\n" 137 " ipm %0\n"
104 " srl %0,28" 138 " srl %0,28"
105 : "=d" (ccode) 139 : "=d" (ccode)
106 : "a" (addr) 140 : "a" (addr), "m" (*addr)
107 : "cc", "1" ); 141 : "cc", "1" );
108 return ccode; 142 return ccode;
109} 143}
110 144
111static inline int ssch(int irq, volatile struct orb *addr) 145static inline int ssch(struct subchannel_id schid,
146 volatile struct orb *addr)
112{ 147{
113 int ccode; 148 int ccode;
114 149
@@ -118,12 +153,12 @@ static inline int ssch(int irq, volatile struct orb *addr)
118 " ipm %0\n" 153 " ipm %0\n"
119 " srl %0,28" 154 " srl %0,28"
120 : "=d" (ccode) 155 : "=d" (ccode)
121 : "d" (irq | 0x10000L), "a" (addr) 156 : "d" (schid), "a" (addr), "m" (*addr)
122 : "cc", "1" ); 157 : "cc", "1" );
123 return ccode; 158 return ccode;
124} 159}
125 160
126static inline int rsch(int irq) 161static inline int rsch(struct subchannel_id schid)
127{ 162{
128 int ccode; 163 int ccode;
129 164
@@ -133,12 +168,12 @@ static inline int rsch(int irq)
133 " ipm %0\n" 168 " ipm %0\n"
134 " srl %0,28" 169 " srl %0,28"
135 : "=d" (ccode) 170 : "=d" (ccode)
136 : "d" (irq | 0x10000L) 171 : "d" (schid)
137 : "cc", "1" ); 172 : "cc", "1" );
138 return ccode; 173 return ccode;
139} 174}
140 175
141static inline int csch(int irq) 176static inline int csch(struct subchannel_id schid)
142{ 177{
143 int ccode; 178 int ccode;
144 179
@@ -148,12 +183,12 @@ static inline int csch(int irq)
148 " ipm %0\n" 183 " ipm %0\n"
149 " srl %0,28" 184 " srl %0,28"
150 : "=d" (ccode) 185 : "=d" (ccode)
151 : "d" (irq | 0x10000L) 186 : "d" (schid)
152 : "cc", "1" ); 187 : "cc", "1" );
153 return ccode; 188 return ccode;
154} 189}
155 190
156static inline int hsch(int irq) 191static inline int hsch(struct subchannel_id schid)
157{ 192{
158 int ccode; 193 int ccode;
159 194
@@ -163,12 +198,12 @@ static inline int hsch(int irq)
163 " ipm %0\n" 198 " ipm %0\n"
164 " srl %0,28" 199 " srl %0,28"
165 : "=d" (ccode) 200 : "=d" (ccode)
166 : "d" (irq | 0x10000L) 201 : "d" (schid)
167 : "cc", "1" ); 202 : "cc", "1" );
168 return ccode; 203 return ccode;
169} 204}
170 205
171static inline int xsch(int irq) 206static inline int xsch(struct subchannel_id schid)
172{ 207{
173 int ccode; 208 int ccode;
174 209
@@ -178,21 +213,22 @@ static inline int xsch(int irq)
178 " ipm %0\n" 213 " ipm %0\n"
179 " srl %0,28" 214 " srl %0,28"
180 : "=d" (ccode) 215 : "=d" (ccode)
181 : "d" (irq | 0x10000L) 216 : "d" (schid)
182 : "cc", "1" ); 217 : "cc", "1" );
183 return ccode; 218 return ccode;
184} 219}
185 220
186static inline int chsc(void *chsc_area) 221static inline int chsc(void *chsc_area)
187{ 222{
223 typedef struct { char _[4096]; } addr_type;
188 int cc; 224 int cc;
189 225
190 __asm__ __volatile__ ( 226 __asm__ __volatile__ (
191 ".insn rre,0xb25f0000,%1,0 \n\t" 227 ".insn rre,0xb25f0000,%2,0 \n\t"
192 "ipm %0 \n\t" 228 "ipm %0 \n\t"
193 "srl %0,28 \n\t" 229 "srl %0,28 \n\t"
194 : "=d" (cc) 230 : "=d" (cc), "=m" (*(addr_type *) chsc_area)
195 : "d" (chsc_area) 231 : "d" (chsc_area), "m" (*(addr_type *) chsc_area)
196 : "cc" ); 232 : "cc" );
197 233
198 return cc; 234 return cc;
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index eb39218b925e..30a836ffc31f 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -56,7 +56,7 @@
56#include "ioasm.h" 56#include "ioasm.h"
57#include "chsc.h" 57#include "chsc.h"
58 58
59#define VERSION_QDIO_C "$Revision: 1.108 $" 59#define VERSION_QDIO_C "$Revision: 1.114 $"
60 60
61/****************** MODULE PARAMETER VARIABLES ********************/ 61/****************** MODULE PARAMETER VARIABLES ********************/
62MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>"); 62MODULE_AUTHOR("Utz Bacher <utz.bacher@de.ibm.com>");
@@ -76,6 +76,7 @@ static struct qdio_perf_stats perf_stats;
76#endif /* QDIO_PERFORMANCE_STATS */ 76#endif /* QDIO_PERFORMANCE_STATS */
77 77
78static int hydra_thinints; 78static int hydra_thinints;
79static int is_passthrough = 0;
79static int omit_svs; 80static int omit_svs;
80 81
81static int indicator_used[INDICATORS_PER_CACHELINE]; 82static int indicator_used[INDICATORS_PER_CACHELINE];
@@ -136,12 +137,126 @@ qdio_release_q(struct qdio_q *q)
136 atomic_dec(&q->use_count); 137 atomic_dec(&q->use_count);
137} 138}
138 139
139static volatile inline void 140/*check ccq */
140qdio_set_slsb(volatile char *slsb, unsigned char value) 141static inline int
142qdio_check_ccq(struct qdio_q *q, unsigned int ccq)
143{
144 char dbf_text[15];
145
146 if (ccq == 0 || ccq == 32 || ccq == 96)
147 return 0;
148 if (ccq == 97)
149 return 1;
150 /*notify devices immediately*/
151 sprintf(dbf_text,"%d", ccq);
152 QDIO_DBF_TEXT2(1,trace,dbf_text);
153 return -EIO;
154}
155/* EQBS: extract buffer states */
156static inline int
157qdio_do_eqbs(struct qdio_q *q, unsigned char *state,
158 unsigned int *start, unsigned int *cnt)
159{
160 struct qdio_irq *irq;
161 unsigned int tmp_cnt, q_no, ccq;
162 int rc ;
163 char dbf_text[15];
164
165 ccq = 0;
166 tmp_cnt = *cnt;
167 irq = (struct qdio_irq*)q->irq_ptr;
168 q_no = q->q_no;
169 if(!q->is_input_q)
170 q_no += irq->no_input_qs;
171 ccq = do_eqbs(irq->sch_token, state, q_no, start, cnt);
172 rc = qdio_check_ccq(q, ccq);
173 if (rc < 0) {
174 QDIO_DBF_TEXT2(1,trace,"eqberr");
175 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt, *cnt, ccq, q_no);
176 QDIO_DBF_TEXT2(1,trace,dbf_text);
177 q->handler(q->cdev,QDIO_STATUS_ACTIVATE_CHECK_CONDITION|
178 QDIO_STATUS_LOOK_FOR_ERROR,
179 0, 0, 0, -1, -1, q->int_parm);
180 return 0;
181 }
182 return (tmp_cnt - *cnt);
183}
184
185/* SQBS: set buffer states */
186static inline int
187qdio_do_sqbs(struct qdio_q *q, unsigned char state,
188 unsigned int *start, unsigned int *cnt)
141{ 189{
142 xchg((char*)slsb,value); 190 struct qdio_irq *irq;
191 unsigned int tmp_cnt, q_no, ccq;
192 int rc;
193 char dbf_text[15];
194
195 ccq = 0;
196 tmp_cnt = *cnt;
197 irq = (struct qdio_irq*)q->irq_ptr;
198 q_no = q->q_no;
199 if(!q->is_input_q)
200 q_no += irq->no_input_qs;
201 ccq = do_sqbs(irq->sch_token, state, q_no, start, cnt);
202 rc = qdio_check_ccq(q, ccq);
203 if (rc < 0) {
204 QDIO_DBF_TEXT3(1,trace,"sqberr");
205 sprintf(dbf_text,"%2x,%2x,%d,%d",tmp_cnt,*cnt,ccq,q_no);
206 QDIO_DBF_TEXT3(1,trace,dbf_text);
207 q->handler(q->cdev,QDIO_STATUS_ACTIVATE_CHECK_CONDITION|
208 QDIO_STATUS_LOOK_FOR_ERROR,
209 0, 0, 0, -1, -1, q->int_parm);
210 return 0;
211 }
212 return (tmp_cnt - *cnt);
143} 213}
144 214
215static inline int
216qdio_set_slsb(struct qdio_q *q, unsigned int *bufno,
217 unsigned char state, unsigned int *count)
218{
219 volatile char *slsb;
220 struct qdio_irq *irq;
221
222 irq = (struct qdio_irq*)q->irq_ptr;
223 if (!irq->is_qebsm) {
224 slsb = (char *)&q->slsb.acc.val[(*bufno)];
225 xchg(slsb, state);
226 return 1;
227 }
228 return qdio_do_sqbs(q, state, bufno, count);
229}
230
231#ifdef CONFIG_QDIO_DEBUG
232static inline void
233qdio_trace_slsb(struct qdio_q *q)
234{
235 if (q->queue_type==QDIO_TRACE_QTYPE) {
236 if (q->is_input_q)
237 QDIO_DBF_HEX2(0,slsb_in,&q->slsb,
238 QDIO_MAX_BUFFERS_PER_Q);
239 else
240 QDIO_DBF_HEX2(0,slsb_out,&q->slsb,
241 QDIO_MAX_BUFFERS_PER_Q);
242 }
243}
244#endif
245
246static inline int
247set_slsb(struct qdio_q *q, unsigned int *bufno,
248 unsigned char state, unsigned int *count)
249{
250 int rc;
251#ifdef CONFIG_QDIO_DEBUG
252 qdio_trace_slsb(q);
253#endif
254 rc = qdio_set_slsb(q, bufno, state, count);
255#ifdef CONFIG_QDIO_DEBUG
256 qdio_trace_slsb(q);
257#endif
258 return rc;
259}
145static inline int 260static inline int
146qdio_siga_sync(struct qdio_q *q, unsigned int gpr2, 261qdio_siga_sync(struct qdio_q *q, unsigned int gpr2,
147 unsigned int gpr3) 262 unsigned int gpr3)
@@ -155,7 +270,7 @@ qdio_siga_sync(struct qdio_q *q, unsigned int gpr2,
155 perf_stats.siga_syncs++; 270 perf_stats.siga_syncs++;
156#endif /* QDIO_PERFORMANCE_STATS */ 271#endif /* QDIO_PERFORMANCE_STATS */
157 272
158 cc = do_siga_sync(q->irq, gpr2, gpr3); 273 cc = do_siga_sync(q->schid, gpr2, gpr3);
159 if (cc) 274 if (cc)
160 QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*)); 275 QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*));
161 276
@@ -170,6 +285,23 @@ qdio_siga_sync_q(struct qdio_q *q)
170 return qdio_siga_sync(q, q->mask, 0); 285 return qdio_siga_sync(q, q->mask, 0);
171} 286}
172 287
288static int
289__do_siga_output(struct qdio_q *q, unsigned int *busy_bit)
290{
291 struct qdio_irq *irq;
292 unsigned int fc = 0;
293 unsigned long schid;
294
295 irq = (struct qdio_irq *) q->irq_ptr;
296 if (!irq->is_qebsm)
297 schid = *((u32 *)&q->schid);
298 else {
299 schid = irq->sch_token;
300 fc |= 0x80;
301 }
302 return do_siga_output(schid, q->mask, busy_bit, fc);
303}
304
173/* 305/*
174 * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns 306 * returns QDIO_SIGA_ERROR_ACCESS_EXCEPTION as cc, when SIGA returns
175 * an access exception 307 * an access exception
@@ -189,7 +321,7 @@ qdio_siga_output(struct qdio_q *q)
189 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); 321 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
190 322
191 for (;;) { 323 for (;;) {
192 cc = do_siga_output(q->irq, q->mask, &busy_bit); 324 cc = __do_siga_output(q, &busy_bit);
193//QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit); 325//QDIO_PRINT_ERR("cc=%x, busy=%x\n",cc,busy_bit);
194 if ((cc==2) && (busy_bit) && (q->is_iqdio_q)) { 326 if ((cc==2) && (busy_bit) && (q->is_iqdio_q)) {
195 if (!start_time) 327 if (!start_time)
@@ -221,7 +353,7 @@ qdio_siga_input(struct qdio_q *q)
221 perf_stats.siga_ins++; 353 perf_stats.siga_ins++;
222#endif /* QDIO_PERFORMANCE_STATS */ 354#endif /* QDIO_PERFORMANCE_STATS */
223 355
224 cc = do_siga_input(q->irq, q->mask); 356 cc = do_siga_input(q->schid, q->mask);
225 357
226 if (cc) 358 if (cc)
227 QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*)); 359 QDIO_DBF_HEX3(0,trace,&cc,sizeof(int*));
@@ -230,7 +362,7 @@ qdio_siga_input(struct qdio_q *q)
230} 362}
231 363
232/* locked by the locks in qdio_activate and qdio_cleanup */ 364/* locked by the locks in qdio_activate and qdio_cleanup */
233static __u32 volatile * 365static __u32 *
234qdio_get_indicator(void) 366qdio_get_indicator(void)
235{ 367{
236 int i; 368 int i;
@@ -258,7 +390,7 @@ qdio_put_indicator(__u32 *addr)
258 atomic_dec(&spare_indicator_usecount); 390 atomic_dec(&spare_indicator_usecount);
259} 391}
260 392
261static inline volatile void 393static inline void
262tiqdio_clear_summary_bit(__u32 *location) 394tiqdio_clear_summary_bit(__u32 *location)
263{ 395{
264 QDIO_DBF_TEXT5(0,trace,"clrsummb"); 396 QDIO_DBF_TEXT5(0,trace,"clrsummb");
@@ -267,7 +399,7 @@ tiqdio_clear_summary_bit(__u32 *location)
267 xchg(location,0); 399 xchg(location,0);
268} 400}
269 401
270static inline volatile void 402static inline void
271tiqdio_set_summary_bit(__u32 *location) 403tiqdio_set_summary_bit(__u32 *location)
272{ 404{
273 QDIO_DBF_TEXT5(0,trace,"setsummb"); 405 QDIO_DBF_TEXT5(0,trace,"setsummb");
@@ -336,7 +468,9 @@ static inline int
336qdio_stop_polling(struct qdio_q *q) 468qdio_stop_polling(struct qdio_q *q)
337{ 469{
338#ifdef QDIO_USE_PROCESSING_STATE 470#ifdef QDIO_USE_PROCESSING_STATE
339 int gsf; 471 unsigned int tmp, gsf, count = 1;
472 unsigned char state = 0;
473 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
340 474
341 if (!atomic_swap(&q->polling,0)) 475 if (!atomic_swap(&q->polling,0))
342 return 1; 476 return 1;
@@ -348,17 +482,22 @@ qdio_stop_polling(struct qdio_q *q)
348 if (!q->is_input_q) 482 if (!q->is_input_q)
349 return 1; 483 return 1;
350 484
351 gsf=GET_SAVED_FRONTIER(q); 485 tmp = gsf = GET_SAVED_FRONTIER(q);
352 set_slsb(&q->slsb.acc.val[(gsf+QDIO_MAX_BUFFERS_PER_Q-1)& 486 tmp = ((tmp + QDIO_MAX_BUFFERS_PER_Q-1) & (QDIO_MAX_BUFFERS_PER_Q-1) );
353 (QDIO_MAX_BUFFERS_PER_Q-1)], 487 set_slsb(q, &tmp, SLSB_P_INPUT_NOT_INIT, &count);
354 SLSB_P_INPUT_NOT_INIT); 488
355 /* 489 /*
356 * we don't issue this SYNC_MEMORY, as we trust Rick T and 490 * we don't issue this SYNC_MEMORY, as we trust Rick T and
357 * moreover will not use the PROCESSING state under VM, so 491 * moreover will not use the PROCESSING state under VM, so
358 * q->polling was 0 anyway 492 * q->polling was 0 anyway
359 */ 493 */
360 /*SYNC_MEMORY;*/ 494 /*SYNC_MEMORY;*/
361 if (q->slsb.acc.val[gsf]!=SLSB_P_INPUT_PRIMED) 495 if (irq->is_qebsm) {
496 count = 1;
497 qdio_do_eqbs(q, &state, &gsf, &count);
498 } else
499 state = q->slsb.acc.val[gsf];
500 if (state != SLSB_P_INPUT_PRIMED)
362 return 1; 501 return 1;
363 /* 502 /*
364 * set our summary bit again, as otherwise there is a 503 * set our summary bit again, as otherwise there is a
@@ -431,18 +570,136 @@ tiqdio_clear_global_summary(void)
431 570
432 571
433/************************* OUTBOUND ROUTINES *******************************/ 572/************************* OUTBOUND ROUTINES *******************************/
573static int
574qdio_qebsm_get_outbound_buffer_frontier(struct qdio_q *q)
575{
576 struct qdio_irq *irq;
577 unsigned char state;
578 unsigned int cnt, count, ftc;
579
580 irq = (struct qdio_irq *) q->irq_ptr;
581 if ((!q->is_iqdio_q) && (!q->hydra_gives_outbound_pcis))
582 SYNC_MEMORY;
583
584 ftc = q->first_to_check;
585 count = qdio_min(atomic_read(&q->number_of_buffers_used),
586 (QDIO_MAX_BUFFERS_PER_Q-1));
587 if (count == 0)
588 return q->first_to_check;
589 cnt = qdio_do_eqbs(q, &state, &ftc, &count);
590 if (cnt == 0)
591 return q->first_to_check;
592 switch (state) {
593 case SLSB_P_OUTPUT_ERROR:
594 QDIO_DBF_TEXT3(0,trace,"outperr");
595 atomic_sub(cnt , &q->number_of_buffers_used);
596 if (q->qdio_error)
597 q->error_status_flags |=
598 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR;
599 q->qdio_error = SLSB_P_OUTPUT_ERROR;
600 q->error_status_flags |= QDIO_STATUS_LOOK_FOR_ERROR;
601 q->first_to_check = ftc;
602 break;
603 case SLSB_P_OUTPUT_EMPTY:
604 QDIO_DBF_TEXT5(0,trace,"outpempt");
605 atomic_sub(cnt, &q->number_of_buffers_used);
606 q->first_to_check = ftc;
607 break;
608 case SLSB_CU_OUTPUT_PRIMED:
609 /* all buffers primed */
610 QDIO_DBF_TEXT5(0,trace,"outpprim");
611 break;
612 default:
613 break;
614 }
615 QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int));
616 return q->first_to_check;
617}
618
619static int
620qdio_qebsm_get_inbound_buffer_frontier(struct qdio_q *q)
621{
622 struct qdio_irq *irq;
623 unsigned char state;
624 int tmp, ftc, count, cnt;
625 char dbf_text[15];
626
627
628 irq = (struct qdio_irq *) q->irq_ptr;
629 ftc = q->first_to_check;
630 count = qdio_min(atomic_read(&q->number_of_buffers_used),
631 (QDIO_MAX_BUFFERS_PER_Q-1));
632 if (count == 0)
633 return q->first_to_check;
634 cnt = qdio_do_eqbs(q, &state, &ftc, &count);
635 if (cnt == 0)
636 return q->first_to_check;
637 switch (state) {
638 case SLSB_P_INPUT_ERROR :
639#ifdef CONFIG_QDIO_DEBUG
640 QDIO_DBF_TEXT3(1,trace,"inperr");
641 sprintf(dbf_text,"%2x,%2x",ftc,count);
642 QDIO_DBF_TEXT3(1,trace,dbf_text);
643#endif /* CONFIG_QDIO_DEBUG */
644 if (q->qdio_error)
645 q->error_status_flags |=
646 QDIO_STATUS_MORE_THAN_ONE_QDIO_ERROR;
647 q->qdio_error = SLSB_P_INPUT_ERROR;
648 q->error_status_flags |= QDIO_STATUS_LOOK_FOR_ERROR;
649 atomic_sub(cnt, &q->number_of_buffers_used);
650 q->first_to_check = ftc;
651 break;
652 case SLSB_P_INPUT_PRIMED :
653 QDIO_DBF_TEXT3(0,trace,"inptprim");
654 sprintf(dbf_text,"%2x,%2x",ftc,count);
655 QDIO_DBF_TEXT3(1,trace,dbf_text);
656 tmp = 0;
657 ftc = q->first_to_check;
658#ifdef QDIO_USE_PROCESSING_STATE
659 if (cnt > 1) {
660 cnt -= 1;
661 tmp = set_slsb(q, &ftc, SLSB_P_INPUT_NOT_INIT, &cnt);
662 if (!tmp)
663 break;
664 }
665 cnt = 1;
666 tmp += set_slsb(q, &ftc,
667 SLSB_P_INPUT_PROCESSING, &cnt);
668 atomic_set(&q->polling, 1);
669#else
670 tmp = set_slsb(q, &ftc, SLSB_P_INPUT_NOT_INIT, &cnt);
671#endif
672 atomic_sub(tmp, &q->number_of_buffers_used);
673 q->first_to_check = ftc;
674 break;
675 case SLSB_CU_INPUT_EMPTY:
676 case SLSB_P_INPUT_NOT_INIT:
677 case SLSB_P_INPUT_PROCESSING:
678 QDIO_DBF_TEXT5(0,trace,"inpnipro");
679 break;
680 default:
681 break;
682 }
683 QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int));
684 return q->first_to_check;
685}
434 686
435static inline int 687static inline int
436qdio_get_outbound_buffer_frontier(struct qdio_q *q) 688qdio_get_outbound_buffer_frontier(struct qdio_q *q)
437{ 689{
438 int f,f_mod_no; 690 struct qdio_irq *irq;
439 volatile char *slsb; 691 volatile char *slsb;
440 int first_not_to_check; 692 unsigned int count = 1;
693 int first_not_to_check, f, f_mod_no;
441 char dbf_text[15]; 694 char dbf_text[15];
442 695
443 QDIO_DBF_TEXT4(0,trace,"getobfro"); 696 QDIO_DBF_TEXT4(0,trace,"getobfro");
444 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); 697 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
445 698
699 irq = (struct qdio_irq *) q->irq_ptr;
700 if (irq->is_qebsm)
701 return qdio_qebsm_get_outbound_buffer_frontier(q);
702
446 slsb=&q->slsb.acc.val[0]; 703 slsb=&q->slsb.acc.val[0];
447 f_mod_no=f=q->first_to_check; 704 f_mod_no=f=q->first_to_check;
448 /* 705 /*
@@ -484,7 +741,7 @@ check_next:
484 QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256); 741 QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256);
485 742
486 /* kind of process the buffer */ 743 /* kind of process the buffer */
487 set_slsb(&q->slsb.acc.val[f_mod_no], SLSB_P_OUTPUT_NOT_INIT); 744 set_slsb(q, &f_mod_no, SLSB_P_OUTPUT_NOT_INIT, &count);
488 745
489 /* 746 /*
490 * we increment the frontier, as this buffer 747 * we increment the frontier, as this buffer
@@ -597,48 +854,48 @@ qdio_kick_outbound_q(struct qdio_q *q)
597 854
598 result=qdio_siga_output(q); 855 result=qdio_siga_output(q);
599 856
600 switch (result) { 857 switch (result) {
601 case 0: 858 case 0:
602 /* went smooth this time, reset timestamp */ 859 /* went smooth this time, reset timestamp */
603#ifdef CONFIG_QDIO_DEBUG 860#ifdef CONFIG_QDIO_DEBUG
604 QDIO_DBF_TEXT3(0,trace,"cc2reslv"); 861 QDIO_DBF_TEXT3(0,trace,"cc2reslv");
605 sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no, 862 sprintf(dbf_text,"%4x%2x%2x",q->schid.sch_no,q->q_no,
606 atomic_read(&q->busy_siga_counter)); 863 atomic_read(&q->busy_siga_counter));
607 QDIO_DBF_TEXT3(0,trace,dbf_text); 864 QDIO_DBF_TEXT3(0,trace,dbf_text);
608#endif /* CONFIG_QDIO_DEBUG */ 865#endif /* CONFIG_QDIO_DEBUG */
609 q->timing.busy_start=0; 866 q->timing.busy_start=0;
867 break;
868 case (2|QDIO_SIGA_ERROR_B_BIT_SET):
869 /* cc=2 and busy bit: */
870 atomic_inc(&q->busy_siga_counter);
871
872 /* if the last siga was successful, save
873 * timestamp here */
874 if (!q->timing.busy_start)
875 q->timing.busy_start=NOW;
876
877 /* if we're in time, don't touch error_status_flags
878 * and siga_error */
879 if (NOW-q->timing.busy_start<QDIO_BUSY_BIT_GIVE_UP) {
880 qdio_mark_q(q);
610 break; 881 break;
611 case (2|QDIO_SIGA_ERROR_B_BIT_SET): 882 }
612 /* cc=2 and busy bit: */ 883 QDIO_DBF_TEXT2(0,trace,"cc2REPRT");
613 atomic_inc(&q->busy_siga_counter);
614
615 /* if the last siga was successful, save
616 * timestamp here */
617 if (!q->timing.busy_start)
618 q->timing.busy_start=NOW;
619
620 /* if we're in time, don't touch error_status_flags
621 * and siga_error */
622 if (NOW-q->timing.busy_start<QDIO_BUSY_BIT_GIVE_UP) {
623 qdio_mark_q(q);
624 break;
625 }
626 QDIO_DBF_TEXT2(0,trace,"cc2REPRT");
627#ifdef CONFIG_QDIO_DEBUG 884#ifdef CONFIG_QDIO_DEBUG
628 sprintf(dbf_text,"%4x%2x%2x",q->irq,q->q_no, 885 sprintf(dbf_text,"%4x%2x%2x",q->schid.sch_no,q->q_no,
629 atomic_read(&q->busy_siga_counter)); 886 atomic_read(&q->busy_siga_counter));
630 QDIO_DBF_TEXT3(0,trace,dbf_text); 887 QDIO_DBF_TEXT3(0,trace,dbf_text);
631#endif /* CONFIG_QDIO_DEBUG */ 888#endif /* CONFIG_QDIO_DEBUG */
632 /* else fallthrough and report error */ 889 /* else fallthrough and report error */
633 default: 890 default:
634 /* for plain cc=1, 2 or 3: */ 891 /* for plain cc=1, 2 or 3: */
635 if (q->siga_error) 892 if (q->siga_error)
636 q->error_status_flags|=
637 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR;
638 q->error_status_flags|= 893 q->error_status_flags|=
639 QDIO_STATUS_LOOK_FOR_ERROR; 894 QDIO_STATUS_MORE_THAN_ONE_SIGA_ERROR;
640 q->siga_error=result; 895 q->error_status_flags|=
641 } 896 QDIO_STATUS_LOOK_FOR_ERROR;
897 q->siga_error=result;
898 }
642} 899}
643 900
644static inline void 901static inline void
@@ -743,8 +1000,10 @@ qdio_outbound_processing(struct qdio_q *q)
743static inline int 1000static inline int
744qdio_get_inbound_buffer_frontier(struct qdio_q *q) 1001qdio_get_inbound_buffer_frontier(struct qdio_q *q)
745{ 1002{
1003 struct qdio_irq *irq;
746 int f,f_mod_no; 1004 int f,f_mod_no;
747 volatile char *slsb; 1005 volatile char *slsb;
1006 unsigned int count = 1;
748 int first_not_to_check; 1007 int first_not_to_check;
749#ifdef CONFIG_QDIO_DEBUG 1008#ifdef CONFIG_QDIO_DEBUG
750 char dbf_text[15]; 1009 char dbf_text[15];
@@ -756,6 +1015,10 @@ qdio_get_inbound_buffer_frontier(struct qdio_q *q)
756 QDIO_DBF_TEXT4(0,trace,"getibfro"); 1015 QDIO_DBF_TEXT4(0,trace,"getibfro");
757 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); 1016 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
758 1017
1018 irq = (struct qdio_irq *) q->irq_ptr;
1019 if (irq->is_qebsm)
1020 return qdio_qebsm_get_inbound_buffer_frontier(q);
1021
759 slsb=&q->slsb.acc.val[0]; 1022 slsb=&q->slsb.acc.val[0];
760 f_mod_no=f=q->first_to_check; 1023 f_mod_no=f=q->first_to_check;
761 /* 1024 /*
@@ -792,19 +1055,19 @@ check_next:
792 * kill VM in terms of CP overhead 1055 * kill VM in terms of CP overhead
793 */ 1056 */
794 if (q->siga_sync) { 1057 if (q->siga_sync) {
795 set_slsb(&slsb[f_mod_no],SLSB_P_INPUT_NOT_INIT); 1058 set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count);
796 } else { 1059 } else {
797 /* set the previous buffer to NOT_INIT. The current 1060 /* set the previous buffer to NOT_INIT. The current
798 * buffer will be set to PROCESSING at the end of 1061 * buffer will be set to PROCESSING at the end of
799 * this function to avoid further interrupts. */ 1062 * this function to avoid further interrupts. */
800 if (last_position>=0) 1063 if (last_position>=0)
801 set_slsb(&slsb[last_position], 1064 set_slsb(q, &last_position,
802 SLSB_P_INPUT_NOT_INIT); 1065 SLSB_P_INPUT_NOT_INIT, &count);
803 atomic_set(&q->polling,1); 1066 atomic_set(&q->polling,1);
804 last_position=f_mod_no; 1067 last_position=f_mod_no;
805 } 1068 }
806#else /* QDIO_USE_PROCESSING_STATE */ 1069#else /* QDIO_USE_PROCESSING_STATE */
807 set_slsb(&slsb[f_mod_no],SLSB_P_INPUT_NOT_INIT); 1070 set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count);
808#endif /* QDIO_USE_PROCESSING_STATE */ 1071#endif /* QDIO_USE_PROCESSING_STATE */
809 /* 1072 /*
810 * not needed, as the inbound queue will be synced on the next 1073 * not needed, as the inbound queue will be synced on the next
@@ -829,7 +1092,7 @@ check_next:
829 QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256); 1092 QDIO_DBF_HEX2(1,sbal,q->sbal[f_mod_no],256);
830 1093
831 /* kind of process the buffer */ 1094 /* kind of process the buffer */
832 set_slsb(&slsb[f_mod_no],SLSB_P_INPUT_NOT_INIT); 1095 set_slsb(q, &f_mod_no, SLSB_P_INPUT_NOT_INIT, &count);
833 1096
834 if (q->qdio_error) 1097 if (q->qdio_error)
835 q->error_status_flags|= 1098 q->error_status_flags|=
@@ -857,7 +1120,7 @@ out:
857 1120
858#ifdef QDIO_USE_PROCESSING_STATE 1121#ifdef QDIO_USE_PROCESSING_STATE
859 if (last_position>=0) 1122 if (last_position>=0)
860 set_slsb(&slsb[last_position],SLSB_P_INPUT_PROCESSING); 1123 set_slsb(q, &last_position, SLSB_P_INPUT_NOT_INIT, &count);
861#endif /* QDIO_USE_PROCESSING_STATE */ 1124#endif /* QDIO_USE_PROCESSING_STATE */
862 1125
863 QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int)); 1126 QDIO_DBF_HEX4(0,trace,&q->first_to_check,sizeof(int));
@@ -902,6 +1165,10 @@ static inline int
902tiqdio_is_inbound_q_done(struct qdio_q *q) 1165tiqdio_is_inbound_q_done(struct qdio_q *q)
903{ 1166{
904 int no_used; 1167 int no_used;
1168 unsigned int start_buf, count;
1169 unsigned char state = 0;
1170 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
1171
905#ifdef CONFIG_QDIO_DEBUG 1172#ifdef CONFIG_QDIO_DEBUG
906 char dbf_text[15]; 1173 char dbf_text[15];
907#endif 1174#endif
@@ -927,8 +1194,13 @@ tiqdio_is_inbound_q_done(struct qdio_q *q)
927 if (!q->siga_sync) 1194 if (!q->siga_sync)
928 /* we'll check for more primed buffers in qeth_stop_polling */ 1195 /* we'll check for more primed buffers in qeth_stop_polling */
929 return 0; 1196 return 0;
930 1197 if (irq->is_qebsm) {
931 if (q->slsb.acc.val[q->first_to_check]!=SLSB_P_INPUT_PRIMED) 1198 count = 1;
1199 start_buf = q->first_to_check;
1200 qdio_do_eqbs(q, &state, &start_buf, &count);
1201 } else
1202 state = q->slsb.acc.val[q->first_to_check];
1203 if (state != SLSB_P_INPUT_PRIMED)
932 /* 1204 /*
933 * nothing more to do, if next buffer is not PRIMED. 1205 * nothing more to do, if next buffer is not PRIMED.
934 * note that we did a SYNC_MEMORY before, that there 1206 * note that we did a SYNC_MEMORY before, that there
@@ -955,6 +1227,10 @@ static inline int
955qdio_is_inbound_q_done(struct qdio_q *q) 1227qdio_is_inbound_q_done(struct qdio_q *q)
956{ 1228{
957 int no_used; 1229 int no_used;
1230 unsigned int start_buf, count;
1231 unsigned char state = 0;
1232 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
1233
958#ifdef CONFIG_QDIO_DEBUG 1234#ifdef CONFIG_QDIO_DEBUG
959 char dbf_text[15]; 1235 char dbf_text[15];
960#endif 1236#endif
@@ -973,8 +1249,13 @@ qdio_is_inbound_q_done(struct qdio_q *q)
973 QDIO_DBF_TEXT4(0,trace,dbf_text); 1249 QDIO_DBF_TEXT4(0,trace,dbf_text);
974 return 1; 1250 return 1;
975 } 1251 }
976 1252 if (irq->is_qebsm) {
977 if (q->slsb.acc.val[q->first_to_check]==SLSB_P_INPUT_PRIMED) { 1253 count = 1;
1254 start_buf = q->first_to_check;
1255 qdio_do_eqbs(q, &state, &start_buf, &count);
1256 } else
1257 state = q->slsb.acc.val[q->first_to_check];
1258 if (state == SLSB_P_INPUT_PRIMED) {
978 /* we got something to do */ 1259 /* we got something to do */
979 QDIO_DBF_TEXT4(0,trace,"inqisntA"); 1260 QDIO_DBF_TEXT4(0,trace,"inqisntA");
980 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*)); 1261 QDIO_DBF_HEX4(0,trace,&q,sizeof(void*));
@@ -1456,7 +1737,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1456 void *ptr; 1737 void *ptr;
1457 int available; 1738 int available;
1458 1739
1459 sprintf(dbf_text,"qfqs%4x",cdev->private->irq); 1740 sprintf(dbf_text,"qfqs%4x",cdev->private->sch_no);
1460 QDIO_DBF_TEXT0(0,setup,dbf_text); 1741 QDIO_DBF_TEXT0(0,setup,dbf_text);
1461 for (i=0;i<no_input_qs;i++) { 1742 for (i=0;i<no_input_qs;i++) {
1462 q=irq_ptr->input_qs[i]; 1743 q=irq_ptr->input_qs[i];
@@ -1476,7 +1757,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1476 1757
1477 q->queue_type=q_format; 1758 q->queue_type=q_format;
1478 q->int_parm=int_parm; 1759 q->int_parm=int_parm;
1479 q->irq=irq_ptr->irq; 1760 q->schid = irq_ptr->schid;
1480 q->irq_ptr = irq_ptr; 1761 q->irq_ptr = irq_ptr;
1481 q->cdev = cdev; 1762 q->cdev = cdev;
1482 q->mask=1<<(31-i); 1763 q->mask=1<<(31-i);
@@ -1523,11 +1804,11 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1523 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*)); 1804 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1524 1805
1525 /* fill in slsb */ 1806 /* fill in slsb */
1526 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++) { 1807 if (!irq_ptr->is_qebsm) {
1527 set_slsb(&q->slsb.acc.val[j], 1808 unsigned int count = 1;
1528 SLSB_P_INPUT_NOT_INIT); 1809 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
1529/* q->sbal[j]->element[1].sbalf.i1.key=QDIO_STORAGE_KEY;*/ 1810 set_slsb(q, &j, SLSB_P_INPUT_NOT_INIT, &count);
1530 } 1811 }
1531 } 1812 }
1532 1813
1533 for (i=0;i<no_output_qs;i++) { 1814 for (i=0;i<no_output_qs;i++) {
@@ -1549,7 +1830,7 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1549 q->queue_type=q_format; 1830 q->queue_type=q_format;
1550 q->int_parm=int_parm; 1831 q->int_parm=int_parm;
1551 q->is_input_q=0; 1832 q->is_input_q=0;
1552 q->irq=irq_ptr->irq; 1833 q->schid = irq_ptr->schid;
1553 q->cdev = cdev; 1834 q->cdev = cdev;
1554 q->irq_ptr = irq_ptr; 1835 q->irq_ptr = irq_ptr;
1555 q->mask=1<<(31-i); 1836 q->mask=1<<(31-i);
@@ -1584,11 +1865,11 @@ qdio_fill_qs(struct qdio_irq *irq_ptr, struct ccw_device *cdev,
1584 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*)); 1865 QDIO_DBF_HEX2(0,setup,&ptr,sizeof(void*));
1585 1866
1586 /* fill in slsb */ 1867 /* fill in slsb */
1587 for (j=0;j<QDIO_MAX_BUFFERS_PER_Q;j++) { 1868 if (!irq_ptr->is_qebsm) {
1588 set_slsb(&q->slsb.acc.val[j], 1869 unsigned int count = 1;
1589 SLSB_P_OUTPUT_NOT_INIT); 1870 for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)
1590/* q->sbal[j]->element[1].sbalf.i1.key=QDIO_STORAGE_KEY;*/ 1871 set_slsb(q, &j, SLSB_P_OUTPUT_NOT_INIT, &count);
1591 } 1872 }
1592 } 1873 }
1593} 1874}
1594 1875
@@ -1656,7 +1937,7 @@ qdio_set_state(struct qdio_irq *irq_ptr, enum qdio_irq_states state)
1656 char dbf_text[15]; 1937 char dbf_text[15];
1657 1938
1658 QDIO_DBF_TEXT5(0,trace,"newstate"); 1939 QDIO_DBF_TEXT5(0,trace,"newstate");
1659 sprintf(dbf_text,"%4x%4x",irq_ptr->irq,state); 1940 sprintf(dbf_text,"%4x%4x",irq_ptr->schid.sch_no,state);
1660 QDIO_DBF_TEXT5(0,trace,dbf_text); 1941 QDIO_DBF_TEXT5(0,trace,dbf_text);
1661#endif /* CONFIG_QDIO_DEBUG */ 1942#endif /* CONFIG_QDIO_DEBUG */
1662 1943
@@ -1669,12 +1950,12 @@ qdio_set_state(struct qdio_irq *irq_ptr, enum qdio_irq_states state)
1669} 1950}
1670 1951
1671static inline void 1952static inline void
1672qdio_irq_check_sense(int irq, struct irb *irb) 1953qdio_irq_check_sense(struct subchannel_id schid, struct irb *irb)
1673{ 1954{
1674 char dbf_text[15]; 1955 char dbf_text[15];
1675 1956
1676 if (irb->esw.esw0.erw.cons) { 1957 if (irb->esw.esw0.erw.cons) {
1677 sprintf(dbf_text,"sens%4x",irq); 1958 sprintf(dbf_text,"sens%4x",schid.sch_no);
1678 QDIO_DBF_TEXT2(1,trace,dbf_text); 1959 QDIO_DBF_TEXT2(1,trace,dbf_text);
1679 QDIO_DBF_HEX0(0,sense,irb,QDIO_DBF_SENSE_LEN); 1960 QDIO_DBF_HEX0(0,sense,irb,QDIO_DBF_SENSE_LEN);
1680 1961
@@ -1785,21 +2066,22 @@ qdio_timeout_handler(struct ccw_device *cdev)
1785 2066
1786 switch (irq_ptr->state) { 2067 switch (irq_ptr->state) {
1787 case QDIO_IRQ_STATE_INACTIVE: 2068 case QDIO_IRQ_STATE_INACTIVE:
1788 QDIO_PRINT_ERR("establish queues on irq %04x: timed out\n", 2069 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: timed out\n",
1789 irq_ptr->irq); 2070 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
1790 QDIO_DBF_TEXT2(1,setup,"eq:timeo"); 2071 QDIO_DBF_TEXT2(1,setup,"eq:timeo");
1791 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); 2072 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
1792 break; 2073 break;
1793 case QDIO_IRQ_STATE_CLEANUP: 2074 case QDIO_IRQ_STATE_CLEANUP:
1794 QDIO_PRINT_INFO("Did not get interrupt on cleanup, irq=0x%x.\n", 2075 QDIO_PRINT_INFO("Did not get interrupt on cleanup, "
1795 irq_ptr->irq); 2076 "irq=0.%x.%x.\n",
2077 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
1796 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); 2078 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
1797 break; 2079 break;
1798 case QDIO_IRQ_STATE_ESTABLISHED: 2080 case QDIO_IRQ_STATE_ESTABLISHED:
1799 case QDIO_IRQ_STATE_ACTIVE: 2081 case QDIO_IRQ_STATE_ACTIVE:
1800 /* I/O has been terminated by common I/O layer. */ 2082 /* I/O has been terminated by common I/O layer. */
1801 QDIO_PRINT_INFO("Queues on irq %04x killed by cio.\n", 2083 QDIO_PRINT_INFO("Queues on irq 0.%x.%04x killed by cio.\n",
1802 irq_ptr->irq); 2084 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
1803 QDIO_DBF_TEXT2(1, trace, "cio:term"); 2085 QDIO_DBF_TEXT2(1, trace, "cio:term");
1804 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED); 2086 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_STOPPED);
1805 if (get_device(&cdev->dev)) { 2087 if (get_device(&cdev->dev)) {
@@ -1862,7 +2144,7 @@ qdio_handler(struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
1862 } 2144 }
1863 } 2145 }
1864 2146
1865 qdio_irq_check_sense(irq_ptr->irq, irb); 2147 qdio_irq_check_sense(irq_ptr->schid, irb);
1866 2148
1867#ifdef CONFIG_QDIO_DEBUG 2149#ifdef CONFIG_QDIO_DEBUG
1868 sprintf(dbf_text, "state:%d", irq_ptr->state); 2150 sprintf(dbf_text, "state:%d", irq_ptr->state);
@@ -1905,7 +2187,7 @@ int
1905qdio_synchronize(struct ccw_device *cdev, unsigned int flags, 2187qdio_synchronize(struct ccw_device *cdev, unsigned int flags,
1906 unsigned int queue_number) 2188 unsigned int queue_number)
1907{ 2189{
1908 int cc; 2190 int cc = 0;
1909 struct qdio_q *q; 2191 struct qdio_q *q;
1910 struct qdio_irq *irq_ptr; 2192 struct qdio_irq *irq_ptr;
1911 void *ptr; 2193 void *ptr;
@@ -1918,7 +2200,7 @@ qdio_synchronize(struct ccw_device *cdev, unsigned int flags,
1918 return -ENODEV; 2200 return -ENODEV;
1919 2201
1920#ifdef CONFIG_QDIO_DEBUG 2202#ifdef CONFIG_QDIO_DEBUG
1921 *((int*)(&dbf_text[4])) = irq_ptr->irq; 2203 *((int*)(&dbf_text[4])) = irq_ptr->schid.sch_no;
1922 QDIO_DBF_HEX4(0,trace,dbf_text,QDIO_DBF_TRACE_LEN); 2204 QDIO_DBF_HEX4(0,trace,dbf_text,QDIO_DBF_TRACE_LEN);
1923 *((int*)(&dbf_text[0]))=flags; 2205 *((int*)(&dbf_text[0]))=flags;
1924 *((int*)(&dbf_text[4]))=queue_number; 2206 *((int*)(&dbf_text[4]))=queue_number;
@@ -1929,12 +2211,14 @@ qdio_synchronize(struct ccw_device *cdev, unsigned int flags,
1929 q=irq_ptr->input_qs[queue_number]; 2211 q=irq_ptr->input_qs[queue_number];
1930 if (!q) 2212 if (!q)
1931 return -EINVAL; 2213 return -EINVAL;
1932 cc = do_siga_sync(q->irq, 0, q->mask); 2214 if (!(irq_ptr->is_qebsm))
2215 cc = do_siga_sync(q->schid, 0, q->mask);
1933 } else if (flags&QDIO_FLAG_SYNC_OUTPUT) { 2216 } else if (flags&QDIO_FLAG_SYNC_OUTPUT) {
1934 q=irq_ptr->output_qs[queue_number]; 2217 q=irq_ptr->output_qs[queue_number];
1935 if (!q) 2218 if (!q)
1936 return -EINVAL; 2219 return -EINVAL;
1937 cc = do_siga_sync(q->irq, q->mask, 0); 2220 if (!(irq_ptr->is_qebsm))
2221 cc = do_siga_sync(q->schid, q->mask, 0);
1938 } else 2222 } else
1939 return -EINVAL; 2223 return -EINVAL;
1940 2224
@@ -1945,15 +2229,54 @@ qdio_synchronize(struct ccw_device *cdev, unsigned int flags,
1945 return cc; 2229 return cc;
1946} 2230}
1947 2231
1948static unsigned char 2232static inline void
1949qdio_check_siga_needs(int sch) 2233qdio_check_subchannel_qebsm(struct qdio_irq *irq_ptr, unsigned char qdioac,
2234 unsigned long token)
2235{
2236 struct qdio_q *q;
2237 int i;
2238 unsigned int count, start_buf;
2239 char dbf_text[15];
2240
2241 /*check if QEBSM is disabled */
2242 if (!(irq_ptr->is_qebsm) || !(qdioac & 0x01)) {
2243 irq_ptr->is_qebsm = 0;
2244 irq_ptr->sch_token = 0;
2245 irq_ptr->qib.rflags &= ~QIB_RFLAGS_ENABLE_QEBSM;
2246 QDIO_DBF_TEXT0(0,setup,"noV=V");
2247 return;
2248 }
2249 irq_ptr->sch_token = token;
2250 /*input queue*/
2251 for (i = 0; i < irq_ptr->no_input_qs;i++) {
2252 q = irq_ptr->input_qs[i];
2253 count = QDIO_MAX_BUFFERS_PER_Q;
2254 start_buf = 0;
2255 set_slsb(q, &start_buf, SLSB_P_INPUT_NOT_INIT, &count);
2256 }
2257 sprintf(dbf_text,"V=V:%2x",irq_ptr->is_qebsm);
2258 QDIO_DBF_TEXT0(0,setup,dbf_text);
2259 sprintf(dbf_text,"%8lx",irq_ptr->sch_token);
2260 QDIO_DBF_TEXT0(0,setup,dbf_text);
2261 /*output queue*/
2262 for (i = 0; i < irq_ptr->no_output_qs; i++) {
2263 q = irq_ptr->output_qs[i];
2264 count = QDIO_MAX_BUFFERS_PER_Q;
2265 start_buf = 0;
2266 set_slsb(q, &start_buf, SLSB_P_OUTPUT_NOT_INIT, &count);
2267 }
2268}
2269
2270static void
2271qdio_get_ssqd_information(struct qdio_irq *irq_ptr)
1950{ 2272{
1951 int result; 2273 int result;
1952 unsigned char qdioac; 2274 unsigned char qdioac;
1953
1954 struct { 2275 struct {
1955 struct chsc_header request; 2276 struct chsc_header request;
1956 u16 reserved1; 2277 u16 reserved1:10;
2278 u16 ssid:2;
2279 u16 fmt:4;
1957 u16 first_sch; 2280 u16 first_sch;
1958 u16 reserved2; 2281 u16 reserved2;
1959 u16 last_sch; 2282 u16 last_sch;
@@ -1964,67 +2287,83 @@ qdio_check_siga_needs(int sch)
1964 u8 reserved5; 2287 u8 reserved5;
1965 u16 sch; 2288 u16 sch;
1966 u8 qfmt; 2289 u8 qfmt;
1967 u8 reserved6; 2290 u8 parm;
1968 u8 qdioac; 2291 u8 qdioac1;
1969 u8 sch_class; 2292 u8 sch_class;
1970 u8 reserved7; 2293 u8 reserved7;
1971 u8 icnt; 2294 u8 icnt;
1972 u8 reserved8; 2295 u8 reserved8;
1973 u8 ocnt; 2296 u8 ocnt;
2297 u8 reserved9;
2298 u8 mbccnt;
2299 u16 qdioac2;
2300 u64 sch_token;
1974 } *ssqd_area; 2301 } *ssqd_area;
1975 2302
2303 QDIO_DBF_TEXT0(0,setup,"getssqd");
2304 qdioac = 0;
1976 ssqd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 2305 ssqd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
1977 if (!ssqd_area) { 2306 if (!ssqd_area) {
1978 QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \ 2307 QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \
1979 "SIGAs for sch x%x.\n", sch); 2308 "SIGAs for sch x%x.\n", irq_ptr->schid.sch_no);
1980 return CHSC_FLAG_SIGA_INPUT_NECESSARY || 2309 irq_ptr->qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY ||
1981 CHSC_FLAG_SIGA_OUTPUT_NECESSARY || 2310 CHSC_FLAG_SIGA_OUTPUT_NECESSARY ||
1982 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ 2311 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */
2312 irq_ptr->is_qebsm = 0;
2313 irq_ptr->sch_token = 0;
2314 irq_ptr->qib.rflags &= ~QIB_RFLAGS_ENABLE_QEBSM;
2315 return;
1983 } 2316 }
2317
1984 ssqd_area->request = (struct chsc_header) { 2318 ssqd_area->request = (struct chsc_header) {
1985 .length = 0x0010, 2319 .length = 0x0010,
1986 .code = 0x0024, 2320 .code = 0x0024,
1987 }; 2321 };
1988 2322 ssqd_area->first_sch = irq_ptr->schid.sch_no;
1989 ssqd_area->first_sch = sch; 2323 ssqd_area->last_sch = irq_ptr->schid.sch_no;
1990 ssqd_area->last_sch = sch; 2324 ssqd_area->ssid = irq_ptr->schid.ssid;
1991 2325 result = chsc(ssqd_area);
1992 result=chsc(ssqd_area);
1993 2326
1994 if (result) { 2327 if (result) {
1995 QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \ 2328 QDIO_PRINT_WARN("CHSC returned cc %i. Using all " \
1996 "SIGAs for sch x%x.\n", 2329 "SIGAs for sch 0.%x.%x.\n", result,
1997 result,sch); 2330 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
1998 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || 2331 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY ||
1999 CHSC_FLAG_SIGA_OUTPUT_NECESSARY || 2332 CHSC_FLAG_SIGA_OUTPUT_NECESSARY ||
2000 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ 2333 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */
2334 irq_ptr->is_qebsm = 0;
2001 goto out; 2335 goto out;
2002 } 2336 }
2003 2337
2004 if (ssqd_area->response.code != QDIO_CHSC_RESPONSE_CODE_OK) { 2338 if (ssqd_area->response.code != QDIO_CHSC_RESPONSE_CODE_OK) {
2005 QDIO_PRINT_WARN("response upon checking SIGA needs " \ 2339 QDIO_PRINT_WARN("response upon checking SIGA needs " \
2006 "is 0x%x. Using all SIGAs for sch x%x.\n", 2340 "is 0x%x. Using all SIGAs for sch 0.%x.%x.\n",
2007 ssqd_area->response.code, sch); 2341 ssqd_area->response.code,
2342 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
2008 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY || 2343 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY ||
2009 CHSC_FLAG_SIGA_OUTPUT_NECESSARY || 2344 CHSC_FLAG_SIGA_OUTPUT_NECESSARY ||
2010 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */ 2345 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* all flags set */
2346 irq_ptr->is_qebsm = 0;
2011 goto out; 2347 goto out;
2012 } 2348 }
2013 if (!(ssqd_area->flags & CHSC_FLAG_QDIO_CAPABILITY) || 2349 if (!(ssqd_area->flags & CHSC_FLAG_QDIO_CAPABILITY) ||
2014 !(ssqd_area->flags & CHSC_FLAG_VALIDITY) || 2350 !(ssqd_area->flags & CHSC_FLAG_VALIDITY) ||
2015 (ssqd_area->sch != sch)) { 2351 (ssqd_area->sch != irq_ptr->schid.sch_no)) {
2016 QDIO_PRINT_WARN("huh? problems checking out sch x%x... " \ 2352 QDIO_PRINT_WARN("huh? problems checking out sch 0.%x.%x... " \
2017 "using all SIGAs.\n",sch); 2353 "using all SIGAs.\n",
2354 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
2018 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY | 2355 qdioac = CHSC_FLAG_SIGA_INPUT_NECESSARY |
2019 CHSC_FLAG_SIGA_OUTPUT_NECESSARY | 2356 CHSC_FLAG_SIGA_OUTPUT_NECESSARY |
2020 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* worst case */ 2357 CHSC_FLAG_SIGA_SYNC_NECESSARY; /* worst case */
2358 irq_ptr->is_qebsm = 0;
2021 goto out; 2359 goto out;
2022 } 2360 }
2023 2361 qdioac = ssqd_area->qdioac1;
2024 qdioac = ssqd_area->qdioac;
2025out: 2362out:
2363 qdio_check_subchannel_qebsm(irq_ptr, qdioac,
2364 ssqd_area->sch_token);
2026 free_page ((unsigned long) ssqd_area); 2365 free_page ((unsigned long) ssqd_area);
2027 return qdioac; 2366 irq_ptr->qdioac = qdioac;
2028} 2367}
2029 2368
2030static unsigned int 2369static unsigned int
@@ -2055,6 +2394,13 @@ tiqdio_check_chsc_availability(void)
2055 sprintf(dbf_text,"hydrati%1x", hydra_thinints); 2394 sprintf(dbf_text,"hydrati%1x", hydra_thinints);
2056 QDIO_DBF_TEXT0(0,setup,dbf_text); 2395 QDIO_DBF_TEXT0(0,setup,dbf_text);
2057 2396
2397#ifdef CONFIG_64BIT
2398 /* Check for QEBSM support in general (bit 58). */
2399 is_passthrough = css_general_characteristics.qebsm;
2400#endif
2401 sprintf(dbf_text,"cssQBS:%1x", is_passthrough);
2402 QDIO_DBF_TEXT0(0,setup,dbf_text);
2403
2058 /* Check for aif time delay disablement fac (bit 56). If installed, 2404 /* Check for aif time delay disablement fac (bit 56). If installed,
2059 * omit svs even under lpar (good point by rick again) */ 2405 * omit svs even under lpar (good point by rick again) */
2060 omit_svs = css_general_characteristics.aif_tdd; 2406 omit_svs = css_general_characteristics.aif_tdd;
@@ -2091,7 +2437,7 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero)
2091 /* set to 0x10000000 to enable 2437 /* set to 0x10000000 to enable
2092 * time delay disablement facility */ 2438 * time delay disablement facility */
2093 u32 reserved5; 2439 u32 reserved5;
2094 u32 subsystem_id; 2440 struct subchannel_id schid;
2095 u32 reserved6[1004]; 2441 u32 reserved6[1004];
2096 struct chsc_header response; 2442 struct chsc_header response;
2097 u32 reserved7; 2443 u32 reserved7;
@@ -2113,7 +2459,8 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero)
2113 scssc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 2459 scssc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
2114 if (!scssc_area) { 2460 if (!scssc_area) {
2115 QDIO_PRINT_WARN("No memory for setting indicators on " \ 2461 QDIO_PRINT_WARN("No memory for setting indicators on " \
2116 "subchannel x%x.\n", irq_ptr->irq); 2462 "subchannel 0.%x.%x.\n",
2463 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
2117 return -ENOMEM; 2464 return -ENOMEM;
2118 } 2465 }
2119 scssc_area->request = (struct chsc_header) { 2466 scssc_area->request = (struct chsc_header) {
@@ -2127,7 +2474,7 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero)
2127 scssc_area->ks = QDIO_STORAGE_KEY; 2474 scssc_area->ks = QDIO_STORAGE_KEY;
2128 scssc_area->kc = QDIO_STORAGE_KEY; 2475 scssc_area->kc = QDIO_STORAGE_KEY;
2129 scssc_area->isc = TIQDIO_THININT_ISC; 2476 scssc_area->isc = TIQDIO_THININT_ISC;
2130 scssc_area->subsystem_id = (1<<16) + irq_ptr->irq; 2477 scssc_area->schid = irq_ptr->schid;
2131 /* enables the time delay disablement facility. Don't care 2478 /* enables the time delay disablement facility. Don't care
2132 * whether it is really there (i.e. we haven't checked for 2479 * whether it is really there (i.e. we haven't checked for
2133 * it) */ 2480 * it) */
@@ -2137,12 +2484,11 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero)
2137 QDIO_PRINT_WARN("Time delay disablement facility " \ 2484 QDIO_PRINT_WARN("Time delay disablement facility " \
2138 "not available\n"); 2485 "not available\n");
2139 2486
2140
2141
2142 result = chsc(scssc_area); 2487 result = chsc(scssc_area);
2143 if (result) { 2488 if (result) {
2144 QDIO_PRINT_WARN("could not set indicators on irq x%x, " \ 2489 QDIO_PRINT_WARN("could not set indicators on irq 0.%x.%x, " \
2145 "cc=%i.\n",irq_ptr->irq,result); 2490 "cc=%i.\n",
2491 irq_ptr->schid.ssid, irq_ptr->schid.sch_no,result);
2146 result = -EIO; 2492 result = -EIO;
2147 goto out; 2493 goto out;
2148 } 2494 }
@@ -2198,7 +2544,8 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target)
2198 scsscf_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); 2544 scsscf_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
2199 if (!scsscf_area) { 2545 if (!scsscf_area) {
2200 QDIO_PRINT_WARN("No memory for setting delay target on " \ 2546 QDIO_PRINT_WARN("No memory for setting delay target on " \
2201 "subchannel x%x.\n", irq_ptr->irq); 2547 "subchannel 0.%x.%x.\n",
2548 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
2202 return -ENOMEM; 2549 return -ENOMEM;
2203 } 2550 }
2204 scsscf_area->request = (struct chsc_header) { 2551 scsscf_area->request = (struct chsc_header) {
@@ -2210,8 +2557,10 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target)
2210 2557
2211 result=chsc(scsscf_area); 2558 result=chsc(scsscf_area);
2212 if (result) { 2559 if (result) {
2213 QDIO_PRINT_WARN("could not set delay target on irq x%x, " \ 2560 QDIO_PRINT_WARN("could not set delay target on irq 0.%x.%x, " \
2214 "cc=%i. Continuing.\n",irq_ptr->irq,result); 2561 "cc=%i. Continuing.\n",
2562 irq_ptr->schid.ssid, irq_ptr->schid.sch_no,
2563 result);
2215 result = -EIO; 2564 result = -EIO;
2216 goto out; 2565 goto out;
2217 } 2566 }
@@ -2245,7 +2594,7 @@ qdio_cleanup(struct ccw_device *cdev, int how)
2245 if (!irq_ptr) 2594 if (!irq_ptr)
2246 return -ENODEV; 2595 return -ENODEV;
2247 2596
2248 sprintf(dbf_text,"qcln%4x",irq_ptr->irq); 2597 sprintf(dbf_text,"qcln%4x",irq_ptr->schid.sch_no);
2249 QDIO_DBF_TEXT1(0,trace,dbf_text); 2598 QDIO_DBF_TEXT1(0,trace,dbf_text);
2250 QDIO_DBF_TEXT0(0,setup,dbf_text); 2599 QDIO_DBF_TEXT0(0,setup,dbf_text);
2251 2600
@@ -2272,7 +2621,7 @@ qdio_shutdown(struct ccw_device *cdev, int how)
2272 2621
2273 down(&irq_ptr->setting_up_sema); 2622 down(&irq_ptr->setting_up_sema);
2274 2623
2275 sprintf(dbf_text,"qsqs%4x",irq_ptr->irq); 2624 sprintf(dbf_text,"qsqs%4x",irq_ptr->schid.sch_no);
2276 QDIO_DBF_TEXT1(0,trace,dbf_text); 2625 QDIO_DBF_TEXT1(0,trace,dbf_text);
2277 QDIO_DBF_TEXT0(0,setup,dbf_text); 2626 QDIO_DBF_TEXT0(0,setup,dbf_text);
2278 2627
@@ -2378,7 +2727,7 @@ qdio_free(struct ccw_device *cdev)
2378 2727
2379 down(&irq_ptr->setting_up_sema); 2728 down(&irq_ptr->setting_up_sema);
2380 2729
2381 sprintf(dbf_text,"qfqs%4x",irq_ptr->irq); 2730 sprintf(dbf_text,"qfqs%4x",irq_ptr->schid.sch_no);
2382 QDIO_DBF_TEXT1(0,trace,dbf_text); 2731 QDIO_DBF_TEXT1(0,trace,dbf_text);
2383 QDIO_DBF_TEXT0(0,setup,dbf_text); 2732 QDIO_DBF_TEXT0(0,setup,dbf_text);
2384 2733
@@ -2526,13 +2875,14 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat,
2526 irq_ptr = cdev->private->qdio_data; 2875 irq_ptr = cdev->private->qdio_data;
2527 2876
2528 if (cstat || (dstat & ~(DEV_STAT_CHN_END|DEV_STAT_DEV_END))) { 2877 if (cstat || (dstat & ~(DEV_STAT_CHN_END|DEV_STAT_DEV_END))) {
2529 sprintf(dbf_text,"ick1%4x",irq_ptr->irq); 2878 sprintf(dbf_text,"ick1%4x",irq_ptr->schid.sch_no);
2530 QDIO_DBF_TEXT2(1,trace,dbf_text); 2879 QDIO_DBF_TEXT2(1,trace,dbf_text);
2531 QDIO_DBF_HEX2(0,trace,&dstat,sizeof(int)); 2880 QDIO_DBF_HEX2(0,trace,&dstat,sizeof(int));
2532 QDIO_DBF_HEX2(0,trace,&cstat,sizeof(int)); 2881 QDIO_DBF_HEX2(0,trace,&cstat,sizeof(int));
2533 QDIO_PRINT_ERR("received check condition on establish " \ 2882 QDIO_PRINT_ERR("received check condition on establish " \
2534 "queues on irq 0x%x (cs=x%x, ds=x%x).\n", 2883 "queues on irq 0.%x.%x (cs=x%x, ds=x%x).\n",
2535 irq_ptr->irq,cstat,dstat); 2884 irq_ptr->schid.ssid, irq_ptr->schid.sch_no,
2885 cstat,dstat);
2536 qdio_set_state(irq_ptr,QDIO_IRQ_STATE_ERR); 2886 qdio_set_state(irq_ptr,QDIO_IRQ_STATE_ERR);
2537 } 2887 }
2538 2888
@@ -2540,9 +2890,10 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat,
2540 QDIO_DBF_TEXT2(1,setup,"eq:no de"); 2890 QDIO_DBF_TEXT2(1,setup,"eq:no de");
2541 QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat)); 2891 QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat));
2542 QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat)); 2892 QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat));
2543 QDIO_PRINT_ERR("establish queues on irq %04x: didn't get " 2893 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: didn't get "
2544 "device end: dstat=%02x, cstat=%02x\n", 2894 "device end: dstat=%02x, cstat=%02x\n",
2545 irq_ptr->irq, dstat, cstat); 2895 irq_ptr->schid.ssid, irq_ptr->schid.sch_no,
2896 dstat, cstat);
2546 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); 2897 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
2547 return 1; 2898 return 1;
2548 } 2899 }
@@ -2551,10 +2902,10 @@ qdio_establish_irq_check_for_errors(struct ccw_device *cdev, int cstat,
2551 QDIO_DBF_TEXT2(1,setup,"eq:badio"); 2902 QDIO_DBF_TEXT2(1,setup,"eq:badio");
2552 QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat)); 2903 QDIO_DBF_HEX2(0,setup,&dstat, sizeof(dstat));
2553 QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat)); 2904 QDIO_DBF_HEX2(0,setup,&cstat, sizeof(cstat));
2554 QDIO_PRINT_ERR("establish queues on irq %04x: got " 2905 QDIO_PRINT_ERR("establish queues on irq 0.%x.%04x: got "
2555 "the following devstat: dstat=%02x, " 2906 "the following devstat: dstat=%02x, "
2556 "cstat=%02x\n", 2907 "cstat=%02x\n", irq_ptr->schid.ssid,
2557 irq_ptr->irq, dstat, cstat); 2908 irq_ptr->schid.sch_no, dstat, cstat);
2558 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR); 2909 qdio_set_state(irq_ptr, QDIO_IRQ_STATE_ERR);
2559 return 1; 2910 return 1;
2560 } 2911 }
@@ -2569,7 +2920,7 @@ qdio_establish_handle_irq(struct ccw_device *cdev, int cstat, int dstat)
2569 2920
2570 irq_ptr = cdev->private->qdio_data; 2921 irq_ptr = cdev->private->qdio_data;
2571 2922
2572 sprintf(dbf_text,"qehi%4x",cdev->private->irq); 2923 sprintf(dbf_text,"qehi%4x",cdev->private->sch_no);
2573 QDIO_DBF_TEXT0(0,setup,dbf_text); 2924 QDIO_DBF_TEXT0(0,setup,dbf_text);
2574 QDIO_DBF_TEXT0(0,trace,dbf_text); 2925 QDIO_DBF_TEXT0(0,trace,dbf_text);
2575 2926
@@ -2588,7 +2939,7 @@ qdio_initialize(struct qdio_initialize *init_data)
2588 int rc; 2939 int rc;
2589 char dbf_text[15]; 2940 char dbf_text[15];
2590 2941
2591 sprintf(dbf_text,"qini%4x",init_data->cdev->private->irq); 2942 sprintf(dbf_text,"qini%4x",init_data->cdev->private->sch_no);
2592 QDIO_DBF_TEXT0(0,setup,dbf_text); 2943 QDIO_DBF_TEXT0(0,setup,dbf_text);
2593 QDIO_DBF_TEXT0(0,trace,dbf_text); 2944 QDIO_DBF_TEXT0(0,trace,dbf_text);
2594 2945
@@ -2609,7 +2960,7 @@ qdio_allocate(struct qdio_initialize *init_data)
2609 struct qdio_irq *irq_ptr; 2960 struct qdio_irq *irq_ptr;
2610 char dbf_text[15]; 2961 char dbf_text[15];
2611 2962
2612 sprintf(dbf_text,"qalc%4x",init_data->cdev->private->irq); 2963 sprintf(dbf_text,"qalc%4x",init_data->cdev->private->sch_no);
2613 QDIO_DBF_TEXT0(0,setup,dbf_text); 2964 QDIO_DBF_TEXT0(0,setup,dbf_text);
2614 QDIO_DBF_TEXT0(0,trace,dbf_text); 2965 QDIO_DBF_TEXT0(0,trace,dbf_text);
2615 if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) || 2966 if ( (init_data->no_input_qs>QDIO_MAX_QUEUES_PER_IRQ) ||
@@ -2682,7 +3033,7 @@ int qdio_fill_irq(struct qdio_initialize *init_data)
2682 3033
2683 irq_ptr->int_parm=init_data->int_parm; 3034 irq_ptr->int_parm=init_data->int_parm;
2684 3035
2685 irq_ptr->irq = init_data->cdev->private->irq; 3036 irq_ptr->schid = ccw_device_get_subchannel_id(init_data->cdev);
2686 irq_ptr->no_input_qs=init_data->no_input_qs; 3037 irq_ptr->no_input_qs=init_data->no_input_qs;
2687 irq_ptr->no_output_qs=init_data->no_output_qs; 3038 irq_ptr->no_output_qs=init_data->no_output_qs;
2688 3039
@@ -2698,11 +3049,12 @@ int qdio_fill_irq(struct qdio_initialize *init_data)
2698 QDIO_DBF_TEXT2(0,setup,dbf_text); 3049 QDIO_DBF_TEXT2(0,setup,dbf_text);
2699 3050
2700 if (irq_ptr->is_thinint_irq) { 3051 if (irq_ptr->is_thinint_irq) {
2701 irq_ptr->dev_st_chg_ind=qdio_get_indicator(); 3052 irq_ptr->dev_st_chg_ind = qdio_get_indicator();
2702 QDIO_DBF_HEX1(0,setup,&irq_ptr->dev_st_chg_ind,sizeof(void*)); 3053 QDIO_DBF_HEX1(0,setup,&irq_ptr->dev_st_chg_ind,sizeof(void*));
2703 if (!irq_ptr->dev_st_chg_ind) { 3054 if (!irq_ptr->dev_st_chg_ind) {
2704 QDIO_PRINT_WARN("no indicator location available " \ 3055 QDIO_PRINT_WARN("no indicator location available " \
2705 "for irq 0x%x\n",irq_ptr->irq); 3056 "for irq 0.%x.%x\n",
3057 irq_ptr->schid.ssid, irq_ptr->schid.sch_no);
2706 qdio_release_irq_memory(irq_ptr); 3058 qdio_release_irq_memory(irq_ptr);
2707 return -ENOBUFS; 3059 return -ENOBUFS;
2708 } 3060 }
@@ -2747,6 +3099,10 @@ int qdio_fill_irq(struct qdio_initialize *init_data)
2747 irq_ptr->qdr->qkey=QDIO_STORAGE_KEY; 3099 irq_ptr->qdr->qkey=QDIO_STORAGE_KEY;
2748 3100
2749 /* fill in qib */ 3101 /* fill in qib */
3102 irq_ptr->is_qebsm = is_passthrough;
3103 if (irq_ptr->is_qebsm)
3104 irq_ptr->qib.rflags |= QIB_RFLAGS_ENABLE_QEBSM;
3105
2750 irq_ptr->qib.qfmt=init_data->q_format; 3106 irq_ptr->qib.qfmt=init_data->q_format;
2751 if (init_data->no_input_qs) 3107 if (init_data->no_input_qs)
2752 irq_ptr->qib.isliba=(unsigned long)(irq_ptr->input_qs[0]->slib); 3108 irq_ptr->qib.isliba=(unsigned long)(irq_ptr->input_qs[0]->slib);
@@ -2829,7 +3185,7 @@ qdio_establish(struct qdio_initialize *init_data)
2829 tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET); 3185 tiqdio_set_delay_target(irq_ptr,TIQDIO_DELAY_TARGET);
2830 } 3186 }
2831 3187
2832 sprintf(dbf_text,"qest%4x",cdev->private->irq); 3188 sprintf(dbf_text,"qest%4x",cdev->private->sch_no);
2833 QDIO_DBF_TEXT0(0,setup,dbf_text); 3189 QDIO_DBF_TEXT0(0,setup,dbf_text);
2834 QDIO_DBF_TEXT0(0,trace,dbf_text); 3190 QDIO_DBF_TEXT0(0,trace,dbf_text);
2835 3191
@@ -2855,9 +3211,10 @@ qdio_establish(struct qdio_initialize *init_data)
2855 sprintf(dbf_text,"eq:io%4x",result); 3211 sprintf(dbf_text,"eq:io%4x",result);
2856 QDIO_DBF_TEXT2(1,setup,dbf_text); 3212 QDIO_DBF_TEXT2(1,setup,dbf_text);
2857 } 3213 }
2858 QDIO_PRINT_WARN("establish queues on irq %04x: do_IO " \ 3214 QDIO_PRINT_WARN("establish queues on irq 0.%x.%04x: do_IO " \
2859 "returned %i, next try returned %i\n", 3215 "returned %i, next try returned %i\n",
2860 irq_ptr->irq,result,result2); 3216 irq_ptr->schid.ssid, irq_ptr->schid.sch_no,
3217 result, result2);
2861 result=result2; 3218 result=result2;
2862 if (result) 3219 if (result)
2863 ccw_device_set_timeout(cdev, 0); 3220 ccw_device_set_timeout(cdev, 0);
@@ -2884,7 +3241,7 @@ qdio_establish(struct qdio_initialize *init_data)
2884 return -EIO; 3241 return -EIO;
2885 } 3242 }
2886 3243
2887 irq_ptr->qdioac=qdio_check_siga_needs(irq_ptr->irq); 3244 qdio_get_ssqd_information(irq_ptr);
2888 /* if this gets set once, we're running under VM and can omit SVSes */ 3245 /* if this gets set once, we're running under VM and can omit SVSes */
2889 if (irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_NECESSARY) 3246 if (irq_ptr->qdioac&CHSC_FLAG_SIGA_SYNC_NECESSARY)
2890 omit_svs=1; 3247 omit_svs=1;
@@ -2930,7 +3287,7 @@ qdio_activate(struct ccw_device *cdev, int flags)
2930 goto out; 3287 goto out;
2931 } 3288 }
2932 3289
2933 sprintf(dbf_text,"qact%4x", irq_ptr->irq); 3290 sprintf(dbf_text,"qact%4x", irq_ptr->schid.sch_no);
2934 QDIO_DBF_TEXT2(0,setup,dbf_text); 3291 QDIO_DBF_TEXT2(0,setup,dbf_text);
2935 QDIO_DBF_TEXT2(0,trace,dbf_text); 3292 QDIO_DBF_TEXT2(0,trace,dbf_text);
2936 3293
@@ -2955,9 +3312,10 @@ qdio_activate(struct ccw_device *cdev, int flags)
2955 sprintf(dbf_text,"aq:io%4x",result); 3312 sprintf(dbf_text,"aq:io%4x",result);
2956 QDIO_DBF_TEXT2(1,setup,dbf_text); 3313 QDIO_DBF_TEXT2(1,setup,dbf_text);
2957 } 3314 }
2958 QDIO_PRINT_WARN("activate queues on irq %04x: do_IO " \ 3315 QDIO_PRINT_WARN("activate queues on irq 0.%x.%04x: do_IO " \
2959 "returned %i, next try returned %i\n", 3316 "returned %i, next try returned %i\n",
2960 irq_ptr->irq,result,result2); 3317 irq_ptr->schid.ssid, irq_ptr->schid.sch_no,
3318 result, result2);
2961 result=result2; 3319 result=result2;
2962 } 3320 }
2963 3321
@@ -3015,30 +3373,40 @@ static inline void
3015qdio_do_qdio_fill_input(struct qdio_q *q, unsigned int qidx, 3373qdio_do_qdio_fill_input(struct qdio_q *q, unsigned int qidx,
3016 unsigned int count, struct qdio_buffer *buffers) 3374 unsigned int count, struct qdio_buffer *buffers)
3017{ 3375{
3376 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
3377 qidx &= (QDIO_MAX_BUFFERS_PER_Q - 1);
3378 if (irq->is_qebsm) {
3379 while (count)
3380 set_slsb(q, &qidx, SLSB_CU_INPUT_EMPTY, &count);
3381 return;
3382 }
3018 for (;;) { 3383 for (;;) {
3019 set_slsb(&q->slsb.acc.val[qidx],SLSB_CU_INPUT_EMPTY); 3384 set_slsb(q, &qidx, SLSB_CU_INPUT_EMPTY, &count);
3020 count--; 3385 count--;
3021 if (!count) break; 3386 if (!count) break;
3022 qidx=(qidx+1)&(QDIO_MAX_BUFFERS_PER_Q-1); 3387 qidx = (qidx + 1) & (QDIO_MAX_BUFFERS_PER_Q - 1);
3023 } 3388 }
3024
3025 /* not necessary, as the queues are synced during the SIGA read */
3026 /*SYNC_MEMORY;*/
3027} 3389}
3028 3390
3029static inline void 3391static inline void
3030qdio_do_qdio_fill_output(struct qdio_q *q, unsigned int qidx, 3392qdio_do_qdio_fill_output(struct qdio_q *q, unsigned int qidx,
3031 unsigned int count, struct qdio_buffer *buffers) 3393 unsigned int count, struct qdio_buffer *buffers)
3032{ 3394{
3395 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
3396
3397 qidx &= (QDIO_MAX_BUFFERS_PER_Q - 1);
3398 if (irq->is_qebsm) {
3399 while (count)
3400 set_slsb(q, &qidx, SLSB_CU_OUTPUT_PRIMED, &count);
3401 return;
3402 }
3403
3033 for (;;) { 3404 for (;;) {
3034 set_slsb(&q->slsb.acc.val[qidx],SLSB_CU_OUTPUT_PRIMED); 3405 set_slsb(q, &qidx, SLSB_CU_OUTPUT_PRIMED, &count);
3035 count--; 3406 count--;
3036 if (!count) break; 3407 if (!count) break;
3037 qidx=(qidx+1)&(QDIO_MAX_BUFFERS_PER_Q-1); 3408 qidx = (qidx + 1) & (QDIO_MAX_BUFFERS_PER_Q - 1);
3038 } 3409 }
3039
3040 /* SIGA write will sync the queues */
3041 /*SYNC_MEMORY;*/
3042} 3410}
3043 3411
3044static inline void 3412static inline void
@@ -3083,6 +3451,9 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
3083 struct qdio_buffer *buffers) 3451 struct qdio_buffer *buffers)
3084{ 3452{
3085 int used_elements; 3453 int used_elements;
3454 unsigned int cnt, start_buf;
3455 unsigned char state = 0;
3456 struct qdio_irq *irq = (struct qdio_irq *) q->irq_ptr;
3086 3457
3087 /* This is the outbound handling of queues */ 3458 /* This is the outbound handling of queues */
3088#ifdef QDIO_PERFORMANCE_STATS 3459#ifdef QDIO_PERFORMANCE_STATS
@@ -3115,9 +3486,15 @@ do_qdio_handle_outbound(struct qdio_q *q, unsigned int callflags,
3115 * SYNC_MEMORY :-/ ), we try to 3486 * SYNC_MEMORY :-/ ), we try to
3116 * fast-requeue buffers 3487 * fast-requeue buffers
3117 */ 3488 */
3118 if (q->slsb.acc.val[(qidx+QDIO_MAX_BUFFERS_PER_Q-1) 3489 if (irq->is_qebsm) {
3119 &(QDIO_MAX_BUFFERS_PER_Q-1)]!= 3490 cnt = 1;
3120 SLSB_CU_OUTPUT_PRIMED) { 3491 start_buf = ((qidx+QDIO_MAX_BUFFERS_PER_Q-1) &
3492 (QDIO_MAX_BUFFERS_PER_Q-1));
3493 qdio_do_eqbs(q, &state, &start_buf, &cnt);
3494 } else
3495 state = q->slsb.acc.val[(qidx+QDIO_MAX_BUFFERS_PER_Q-1)
3496 &(QDIO_MAX_BUFFERS_PER_Q-1) ];
3497 if (state != SLSB_CU_OUTPUT_PRIMED) {
3121 qdio_kick_outbound_q(q); 3498 qdio_kick_outbound_q(q);
3122 } else { 3499 } else {
3123 QDIO_DBF_TEXT3(0,trace, "fast-req"); 3500 QDIO_DBF_TEXT3(0,trace, "fast-req");
@@ -3150,7 +3527,7 @@ do_QDIO(struct ccw_device *cdev,unsigned int callflags,
3150#ifdef CONFIG_QDIO_DEBUG 3527#ifdef CONFIG_QDIO_DEBUG
3151 char dbf_text[20]; 3528 char dbf_text[20];
3152 3529
3153 sprintf(dbf_text,"doQD%04x",cdev->private->irq); 3530 sprintf(dbf_text,"doQD%04x",cdev->private->sch_no);
3154 QDIO_DBF_TEXT3(0,trace,dbf_text); 3531 QDIO_DBF_TEXT3(0,trace,dbf_text);
3155#endif /* CONFIG_QDIO_DEBUG */ 3532#endif /* CONFIG_QDIO_DEBUG */
3156 3533
diff --git a/drivers/s390/cio/qdio.h b/drivers/s390/cio/qdio.h
index 328e31cc6854..fa385e761fe1 100644
--- a/drivers/s390/cio/qdio.h
+++ b/drivers/s390/cio/qdio.h
@@ -3,14 +3,15 @@
3 3
4#include <asm/page.h> 4#include <asm/page.h>
5 5
6#define VERSION_CIO_QDIO_H "$Revision: 1.33 $" 6#include "schid.h"
7
8#define VERSION_CIO_QDIO_H "$Revision: 1.40 $"
7 9
8#ifdef CONFIG_QDIO_DEBUG 10#ifdef CONFIG_QDIO_DEBUG
9#define QDIO_VERBOSE_LEVEL 9 11#define QDIO_VERBOSE_LEVEL 9
10#else /* CONFIG_QDIO_DEBUG */ 12#else /* CONFIG_QDIO_DEBUG */
11#define QDIO_VERBOSE_LEVEL 5 13#define QDIO_VERBOSE_LEVEL 5
12#endif /* CONFIG_QDIO_DEBUG */ 14#endif /* CONFIG_QDIO_DEBUG */
13
14#define QDIO_USE_PROCESSING_STATE 15#define QDIO_USE_PROCESSING_STATE
15 16
16#ifdef CONFIG_QDIO_PERF_STATS 17#ifdef CONFIG_QDIO_PERF_STATS
@@ -265,12 +266,64 @@ QDIO_PRINT_##importance(header "%02x %02x %02x %02x %02x %02x %02x %02x " \
265/* 266/*
266 * Some instructions as assembly 267 * Some instructions as assembly
267 */ 268 */
269
270static inline int
271do_sqbs(unsigned long sch, unsigned char state, int queue,
272 unsigned int *start, unsigned int *count)
273{
274#ifdef CONFIG_64BIT
275 register unsigned long _ccq asm ("0") = *count;
276 register unsigned long _sch asm ("1") = sch;
277 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
278
279 asm volatile (
280 " .insn rsy,0xeb000000008A,%1,0,0(%2)\n\t"
281 : "+d" (_ccq), "+d" (_queuestart)
282 : "d" ((unsigned long)state), "d" (_sch)
283 : "memory", "cc"
284 );
285 *count = _ccq & 0xff;
286 *start = _queuestart & 0xff;
287
288 return (_ccq >> 32) & 0xff;
289#else
290 return 0;
291#endif
292}
293
294static inline int
295do_eqbs(unsigned long sch, unsigned char *state, int queue,
296 unsigned int *start, unsigned int *count)
297{
298#ifdef CONFIG_64BIT
299 register unsigned long _ccq asm ("0") = *count;
300 register unsigned long _sch asm ("1") = sch;
301 unsigned long _queuestart = ((unsigned long)queue << 32) | *start;
302 unsigned long _state = 0;
303
304 asm volatile (
305 " .insn rrf,0xB99c0000,%1,%2,0,0 \n\t"
306 : "+d" (_ccq), "+d" (_queuestart), "+d" (_state)
307 : "d" (_sch)
308 : "memory", "cc"
309 );
310 *count = _ccq & 0xff;
311 *start = _queuestart & 0xff;
312 *state = _state & 0xff;
313
314 return (_ccq >> 32) & 0xff;
315#else
316 return 0;
317#endif
318}
319
320
268static inline int 321static inline int
269do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2) 322do_siga_sync(struct subchannel_id schid, unsigned int mask1, unsigned int mask2)
270{ 323{
271 int cc; 324 int cc;
272 325
273#ifndef CONFIG_ARCH_S390X 326#ifndef CONFIG_64BIT
274 asm volatile ( 327 asm volatile (
275 "lhi 0,2 \n\t" 328 "lhi 0,2 \n\t"
276 "lr 1,%1 \n\t" 329 "lr 1,%1 \n\t"
@@ -280,10 +333,10 @@ do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2)
280 "ipm %0 \n\t" 333 "ipm %0 \n\t"
281 "srl %0,28 \n\t" 334 "srl %0,28 \n\t"
282 : "=d" (cc) 335 : "=d" (cc)
283 : "d" (0x10000|irq), "d" (mask1), "d" (mask2) 336 : "d" (schid), "d" (mask1), "d" (mask2)
284 : "cc", "0", "1", "2", "3" 337 : "cc", "0", "1", "2", "3"
285 ); 338 );
286#else /* CONFIG_ARCH_S390X */ 339#else /* CONFIG_64BIT */
287 asm volatile ( 340 asm volatile (
288 "lghi 0,2 \n\t" 341 "lghi 0,2 \n\t"
289 "llgfr 1,%1 \n\t" 342 "llgfr 1,%1 \n\t"
@@ -293,19 +346,19 @@ do_siga_sync(unsigned int irq, unsigned int mask1, unsigned int mask2)
293 "ipm %0 \n\t" 346 "ipm %0 \n\t"
294 "srl %0,28 \n\t" 347 "srl %0,28 \n\t"
295 : "=d" (cc) 348 : "=d" (cc)
296 : "d" (0x10000|irq), "d" (mask1), "d" (mask2) 349 : "d" (schid), "d" (mask1), "d" (mask2)
297 : "cc", "0", "1", "2", "3" 350 : "cc", "0", "1", "2", "3"
298 ); 351 );
299#endif /* CONFIG_ARCH_S390X */ 352#endif /* CONFIG_64BIT */
300 return cc; 353 return cc;
301} 354}
302 355
303static inline int 356static inline int
304do_siga_input(unsigned int irq, unsigned int mask) 357do_siga_input(struct subchannel_id schid, unsigned int mask)
305{ 358{
306 int cc; 359 int cc;
307 360
308#ifndef CONFIG_ARCH_S390X 361#ifndef CONFIG_64BIT
309 asm volatile ( 362 asm volatile (
310 "lhi 0,1 \n\t" 363 "lhi 0,1 \n\t"
311 "lr 1,%1 \n\t" 364 "lr 1,%1 \n\t"
@@ -314,10 +367,10 @@ do_siga_input(unsigned int irq, unsigned int mask)
314 "ipm %0 \n\t" 367 "ipm %0 \n\t"
315 "srl %0,28 \n\t" 368 "srl %0,28 \n\t"
316 : "=d" (cc) 369 : "=d" (cc)
317 : "d" (0x10000|irq), "d" (mask) 370 : "d" (schid), "d" (mask)
318 : "cc", "0", "1", "2", "memory" 371 : "cc", "0", "1", "2", "memory"
319 ); 372 );
320#else /* CONFIG_ARCH_S390X */ 373#else /* CONFIG_64BIT */
321 asm volatile ( 374 asm volatile (
322 "lghi 0,1 \n\t" 375 "lghi 0,1 \n\t"
323 "llgfr 1,%1 \n\t" 376 "llgfr 1,%1 \n\t"
@@ -326,21 +379,22 @@ do_siga_input(unsigned int irq, unsigned int mask)
326 "ipm %0 \n\t" 379 "ipm %0 \n\t"
327 "srl %0,28 \n\t" 380 "srl %0,28 \n\t"
328 : "=d" (cc) 381 : "=d" (cc)
329 : "d" (0x10000|irq), "d" (mask) 382 : "d" (schid), "d" (mask)
330 : "cc", "0", "1", "2", "memory" 383 : "cc", "0", "1", "2", "memory"
331 ); 384 );
332#endif /* CONFIG_ARCH_S390X */ 385#endif /* CONFIG_64BIT */
333 386
334 return cc; 387 return cc;
335} 388}
336 389
337static inline int 390static inline int
338do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb) 391do_siga_output(unsigned long schid, unsigned long mask, __u32 *bb,
392 unsigned int fc)
339{ 393{
340 int cc; 394 int cc;
341 __u32 busy_bit; 395 __u32 busy_bit;
342 396
343#ifndef CONFIG_ARCH_S390X 397#ifndef CONFIG_64BIT
344 asm volatile ( 398 asm volatile (
345 "lhi 0,0 \n\t" 399 "lhi 0,0 \n\t"
346 "lr 1,%2 \n\t" 400 "lr 1,%2 \n\t"
@@ -366,14 +420,14 @@ do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb)
366 ".long 0b,2b \n\t" 420 ".long 0b,2b \n\t"
367 ".previous \n\t" 421 ".previous \n\t"
368 : "=d" (cc), "=d" (busy_bit) 422 : "=d" (cc), "=d" (busy_bit)
369 : "d" (0x10000|irq), "d" (mask), 423 : "d" (schid), "d" (mask),
370 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION) 424 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION)
371 : "cc", "0", "1", "2", "memory" 425 : "cc", "0", "1", "2", "memory"
372 ); 426 );
373#else /* CONFIG_ARCH_S390X */ 427#else /* CONFIG_64BIT */
374 asm volatile ( 428 asm volatile (
375 "lghi 0,0 \n\t" 429 "llgfr 0,%5 \n\t"
376 "llgfr 1,%2 \n\t" 430 "lgr 1,%2 \n\t"
377 "llgfr 2,%3 \n\t" 431 "llgfr 2,%3 \n\t"
378 "siga 0 \n\t" 432 "siga 0 \n\t"
379 "0:" 433 "0:"
@@ -391,11 +445,11 @@ do_siga_output(unsigned long irq, unsigned long mask, __u32 *bb)
391 ".quad 0b,1b \n\t" 445 ".quad 0b,1b \n\t"
392 ".previous \n\t" 446 ".previous \n\t"
393 : "=d" (cc), "=d" (busy_bit) 447 : "=d" (cc), "=d" (busy_bit)
394 : "d" (0x10000|irq), "d" (mask), 448 : "d" (schid), "d" (mask),
395 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION) 449 "i" (QDIO_SIGA_ERROR_ACCESS_EXCEPTION), "d" (fc)
396 : "cc", "0", "1", "2", "memory" 450 : "cc", "0", "1", "2", "memory"
397 ); 451 );
398#endif /* CONFIG_ARCH_S390X */ 452#endif /* CONFIG_64BIT */
399 453
400 (*bb) = busy_bit; 454 (*bb) = busy_bit;
401 return cc; 455 return cc;
@@ -407,21 +461,21 @@ do_clear_global_summary(void)
407 461
408 unsigned long time; 462 unsigned long time;
409 463
410#ifndef CONFIG_ARCH_S390X 464#ifndef CONFIG_64BIT
411 asm volatile ( 465 asm volatile (
412 "lhi 1,3 \n\t" 466 "lhi 1,3 \n\t"
413 ".insn rre,0xb2650000,2,0 \n\t" 467 ".insn rre,0xb2650000,2,0 \n\t"
414 "lr %0,3 \n\t" 468 "lr %0,3 \n\t"
415 : "=d" (time) : : "cc", "1", "2", "3" 469 : "=d" (time) : : "cc", "1", "2", "3"
416 ); 470 );
417#else /* CONFIG_ARCH_S390X */ 471#else /* CONFIG_64BIT */
418 asm volatile ( 472 asm volatile (
419 "lghi 1,3 \n\t" 473 "lghi 1,3 \n\t"
420 ".insn rre,0xb2650000,2,0 \n\t" 474 ".insn rre,0xb2650000,2,0 \n\t"
421 "lgr %0,3 \n\t" 475 "lgr %0,3 \n\t"
422 : "=d" (time) : : "cc", "1", "2", "3" 476 : "=d" (time) : : "cc", "1", "2", "3"
423 ); 477 );
424#endif /* CONFIG_ARCH_S390X */ 478#endif /* CONFIG_64BIT */
425 479
426 return time; 480 return time;
427} 481}
@@ -488,42 +542,21 @@ struct qdio_perf_stats {
488 542
489#define MY_MODULE_STRING(x) #x 543#define MY_MODULE_STRING(x) #x
490 544
491#ifdef CONFIG_ARCH_S390X 545#ifdef CONFIG_64BIT
492#define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x) 546#define QDIO_GET_ADDR(x) ((__u32)(unsigned long)x)
493#else /* CONFIG_ARCH_S390X */ 547#else /* CONFIG_64BIT */
494#define QDIO_GET_ADDR(x) ((__u32)(long)x) 548#define QDIO_GET_ADDR(x) ((__u32)(long)x)
495#endif /* CONFIG_ARCH_S390X */ 549#endif /* CONFIG_64BIT */
496
497#ifdef CONFIG_QDIO_DEBUG
498#define set_slsb(x,y) \
499 if(q->queue_type==QDIO_TRACE_QTYPE) { \
500 if(q->is_input_q) { \
501 QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
502 } else { \
503 QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
504 } \
505 } \
506 qdio_set_slsb(x,y); \
507 if(q->queue_type==QDIO_TRACE_QTYPE) { \
508 if(q->is_input_q) { \
509 QDIO_DBF_HEX2(0,slsb_in,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
510 } else { \
511 QDIO_DBF_HEX2(0,slsb_out,&q->slsb,QDIO_MAX_BUFFERS_PER_Q); \
512 } \
513 }
514#else /* CONFIG_QDIO_DEBUG */
515#define set_slsb(x,y) qdio_set_slsb(x,y)
516#endif /* CONFIG_QDIO_DEBUG */
517 550
518struct qdio_q { 551struct qdio_q {
519 volatile struct slsb slsb; 552 volatile struct slsb slsb;
520 553
521 char unused[QDIO_MAX_BUFFERS_PER_Q]; 554 char unused[QDIO_MAX_BUFFERS_PER_Q];
522 555
523 __u32 * volatile dev_st_chg_ind; 556 __u32 * dev_st_chg_ind;
524 557
525 int is_input_q; 558 int is_input_q;
526 int irq; 559 struct subchannel_id schid;
527 struct ccw_device *cdev; 560 struct ccw_device *cdev;
528 561
529 unsigned int is_iqdio_q; 562 unsigned int is_iqdio_q;
@@ -568,6 +601,7 @@ struct qdio_q {
568 struct tasklet_struct tasklet; 601 struct tasklet_struct tasklet;
569#endif /* QDIO_USE_TIMERS_FOR_POLLING */ 602#endif /* QDIO_USE_TIMERS_FOR_POLLING */
570 603
604
571 enum qdio_irq_states state; 605 enum qdio_irq_states state;
572 606
573 /* used to store the error condition during a data transfer */ 607 /* used to store the error condition during a data transfer */
@@ -617,13 +651,17 @@ struct qdio_irq {
617 __u32 * volatile dev_st_chg_ind; 651 __u32 * volatile dev_st_chg_ind;
618 652
619 unsigned long int_parm; 653 unsigned long int_parm;
620 int irq; 654 struct subchannel_id schid;
621 655
622 unsigned int is_iqdio_irq; 656 unsigned int is_iqdio_irq;
623 unsigned int is_thinint_irq; 657 unsigned int is_thinint_irq;
624 unsigned int hydra_gives_outbound_pcis; 658 unsigned int hydra_gives_outbound_pcis;
625 unsigned int sync_done_on_outb_pcis; 659 unsigned int sync_done_on_outb_pcis;
626 660
661 /* QEBSM facility */
662 unsigned int is_qebsm;
663 unsigned long sch_token;
664
627 enum qdio_irq_states state; 665 enum qdio_irq_states state;
628 666
629 unsigned int no_input_qs; 667 unsigned int no_input_qs;
diff --git a/drivers/s390/cio/schid.h b/drivers/s390/cio/schid.h
new file mode 100644
index 000000000000..54328fec5ade
--- /dev/null
+++ b/drivers/s390/cio/schid.h
@@ -0,0 +1,26 @@
1#ifndef S390_SCHID_H
2#define S390_SCHID_H
3
4struct subchannel_id {
5 __u32 reserved:13;
6 __u32 ssid:2;
7 __u32 one:1;
8 __u32 sch_no:16;
9} __attribute__ ((packed,aligned(4)));
10
11
12/* Helper function for sane state of pre-allocated subchannel_id. */
13static inline void
14init_subchannel_id(struct subchannel_id *schid)
15{
16 memset(schid, 0, sizeof(struct subchannel_id));
17 schid->one = 1;
18}
19
20static inline int
21schid_equal(struct subchannel_id *schid1, struct subchannel_id *schid2)
22{
23 return !memcmp(schid1, schid2, sizeof(struct subchannel_id));
24}
25
26#endif /* S390_SCHID_H */
diff --git a/drivers/s390/crypto/z90common.h b/drivers/s390/crypto/z90common.h
index e319e78b5ea2..f87c785f2039 100644
--- a/drivers/s390/crypto/z90common.h
+++ b/drivers/s390/crypto/z90common.h
@@ -1,9 +1,9 @@
1/* 1/*
2 * linux/drivers/s390/crypto/z90common.h 2 * linux/drivers/s390/crypto/z90common.h
3 * 3 *
4 * z90crypt 1.3.2 4 * z90crypt 1.3.3
5 * 5 *
6 * Copyright (C) 2001, 2004 IBM Corporation 6 * Copyright (C) 2001, 2005 IBM Corporation
7 * Author(s): Robert Burroughs (burrough@us.ibm.com) 7 * Author(s): Robert Burroughs (burrough@us.ibm.com)
8 * Eric Rossman (edrossma@us.ibm.com) 8 * Eric Rossman (edrossma@us.ibm.com)
9 * 9 *
@@ -91,12 +91,13 @@ enum hdstat {
91#define TSQ_FATAL_ERROR 34 91#define TSQ_FATAL_ERROR 34
92#define RSQ_FATAL_ERROR 35 92#define RSQ_FATAL_ERROR 35
93 93
94#define Z90CRYPT_NUM_TYPES 5 94#define Z90CRYPT_NUM_TYPES 6
95#define PCICA 0 95#define PCICA 0
96#define PCICC 1 96#define PCICC 1
97#define PCIXCC_MCL2 2 97#define PCIXCC_MCL2 2
98#define PCIXCC_MCL3 3 98#define PCIXCC_MCL3 3
99#define CEX2C 4 99#define CEX2C 4
100#define CEX2A 5
100#define NILDEV -1 101#define NILDEV -1
101#define ANYDEV -1 102#define ANYDEV -1
102#define PCIXCC_UNK -2 103#define PCIXCC_UNK -2
@@ -105,7 +106,7 @@ enum hdevice_type {
105 PCICC_HW = 3, 106 PCICC_HW = 3,
106 PCICA_HW = 4, 107 PCICA_HW = 4,
107 PCIXCC_HW = 5, 108 PCIXCC_HW = 5,
108 OTHER_HW = 6, 109 CEX2A_HW = 6,
109 CEX2C_HW = 7 110 CEX2C_HW = 7
110}; 111};
111 112
diff --git a/drivers/s390/crypto/z90crypt.h b/drivers/s390/crypto/z90crypt.h
index 0a3bb5a10dd4..3a18443fdfa7 100644
--- a/drivers/s390/crypto/z90crypt.h
+++ b/drivers/s390/crypto/z90crypt.h
@@ -1,9 +1,9 @@
1/* 1/*
2 * linux/drivers/s390/crypto/z90crypt.h 2 * linux/drivers/s390/crypto/z90crypt.h
3 * 3 *
4 * z90crypt 1.3.2 4 * z90crypt 1.3.3
5 * 5 *
6 * Copyright (C) 2001, 2004 IBM Corporation 6 * Copyright (C) 2001, 2005 IBM Corporation
7 * Author(s): Robert Burroughs (burrough@us.ibm.com) 7 * Author(s): Robert Burroughs (burrough@us.ibm.com)
8 * Eric Rossman (edrossma@us.ibm.com) 8 * Eric Rossman (edrossma@us.ibm.com)
9 * 9 *
@@ -29,11 +29,11 @@
29 29
30#include <linux/ioctl.h> 30#include <linux/ioctl.h>
31 31
32#define VERSION_Z90CRYPT_H "$Revision: 1.11 $" 32#define VERSION_Z90CRYPT_H "$Revision: 1.2.2.4 $"
33 33
34#define z90crypt_VERSION 1 34#define z90crypt_VERSION 1
35#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards 35#define z90crypt_RELEASE 3 // 2 = PCIXCC, 3 = rewrite for coding standards
36#define z90crypt_VARIANT 2 // 2 = added PCIXCC MCL3 and CEX2C support 36#define z90crypt_VARIANT 3 // 3 = CEX2A support
37 37
38/** 38/**
39 * struct ica_rsa_modexpo 39 * struct ica_rsa_modexpo
@@ -122,6 +122,9 @@ struct ica_rsa_modexpo_crt {
122 * Z90STAT_CEX2CCOUNT 122 * Z90STAT_CEX2CCOUNT
123 * Return an integer count of all CEX2Cs. 123 * Return an integer count of all CEX2Cs.
124 * 124 *
125 * Z90STAT_CEX2ACOUNT
126 * Return an integer count of all CEX2As.
127 *
125 * Z90STAT_REQUESTQ_COUNT 128 * Z90STAT_REQUESTQ_COUNT
126 * Return an integer count of the number of entries waiting to be 129 * Return an integer count of the number of entries waiting to be
127 * sent to a device. 130 * sent to a device.
@@ -144,6 +147,7 @@ struct ica_rsa_modexpo_crt {
144 * 0x03: PCIXCC_MCL2 147 * 0x03: PCIXCC_MCL2
145 * 0x04: PCIXCC_MCL3 148 * 0x04: PCIXCC_MCL3
146 * 0x05: CEX2C 149 * 0x05: CEX2C
150 * 0x06: CEX2A
147 * 0x0d: device is disabled via the proc filesystem 151 * 0x0d: device is disabled via the proc filesystem
148 * 152 *
149 * Z90STAT_QDEPTH_MASK 153 * Z90STAT_QDEPTH_MASK
@@ -199,6 +203,7 @@ struct ica_rsa_modexpo_crt {
199#define Z90STAT_PCIXCCMCL2COUNT _IOR(Z90_IOCTL_MAGIC, 0x4b, int) 203#define Z90STAT_PCIXCCMCL2COUNT _IOR(Z90_IOCTL_MAGIC, 0x4b, int)
200#define Z90STAT_PCIXCCMCL3COUNT _IOR(Z90_IOCTL_MAGIC, 0x4c, int) 204#define Z90STAT_PCIXCCMCL3COUNT _IOR(Z90_IOCTL_MAGIC, 0x4c, int)
201#define Z90STAT_CEX2CCOUNT _IOR(Z90_IOCTL_MAGIC, 0x4d, int) 205#define Z90STAT_CEX2CCOUNT _IOR(Z90_IOCTL_MAGIC, 0x4d, int)
206#define Z90STAT_CEX2ACOUNT _IOR(Z90_IOCTL_MAGIC, 0x4e, int)
202#define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int) 207#define Z90STAT_REQUESTQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x44, int)
203#define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int) 208#define Z90STAT_PENDINGQ_COUNT _IOR(Z90_IOCTL_MAGIC, 0x45, int)
204#define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int) 209#define Z90STAT_TOTALOPEN_COUNT _IOR(Z90_IOCTL_MAGIC, 0x46, int)
diff --git a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c
index c215e0889736..d7f7494a0cbe 100644
--- a/drivers/s390/crypto/z90hardware.c
+++ b/drivers/s390/crypto/z90hardware.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * linux/drivers/s390/crypto/z90hardware.c 2 * linux/drivers/s390/crypto/z90hardware.c
3 * 3 *
4 * z90crypt 1.3.2 4 * z90crypt 1.3.3
5 * 5 *
6 * Copyright (C) 2001, 2004 IBM Corporation 6 * Copyright (C) 2001, 2005 IBM Corporation
7 * Author(s): Robert Burroughs (burrough@us.ibm.com) 7 * Author(s): Robert Burroughs (burrough@us.ibm.com)
8 * Eric Rossman (edrossma@us.ibm.com) 8 * Eric Rossman (edrossma@us.ibm.com)
9 * 9 *
@@ -648,6 +648,87 @@ static struct cca_public_sec static_cca_pub_sec = {
648#define RESPONSE_CPRB_SIZE 0x000006B8 648#define RESPONSE_CPRB_SIZE 0x000006B8
649#define RESPONSE_CPRBX_SIZE 0x00000724 649#define RESPONSE_CPRBX_SIZE 0x00000724
650 650
651struct type50_hdr {
652 u8 reserved1;
653 u8 msg_type_code;
654 u16 msg_len;
655 u8 reserved2;
656 u8 ignored;
657 u16 reserved3;
658};
659
660#define TYPE50_TYPE_CODE 0x50
661
662#define TYPE50_MEB1_LEN (sizeof(struct type50_meb1_msg))
663#define TYPE50_MEB2_LEN (sizeof(struct type50_meb2_msg))
664#define TYPE50_CRB1_LEN (sizeof(struct type50_crb1_msg))
665#define TYPE50_CRB2_LEN (sizeof(struct type50_crb2_msg))
666
667#define TYPE50_MEB1_FMT 0x0001
668#define TYPE50_MEB2_FMT 0x0002
669#define TYPE50_CRB1_FMT 0x0011
670#define TYPE50_CRB2_FMT 0x0012
671
672struct type50_meb1_msg {
673 struct type50_hdr header;
674 u16 keyblock_type;
675 u8 reserved[6];
676 u8 exponent[128];
677 u8 modulus[128];
678 u8 message[128];
679};
680
681struct type50_meb2_msg {
682 struct type50_hdr header;
683 u16 keyblock_type;
684 u8 reserved[6];
685 u8 exponent[256];
686 u8 modulus[256];
687 u8 message[256];
688};
689
690struct type50_crb1_msg {
691 struct type50_hdr header;
692 u16 keyblock_type;
693 u8 reserved[6];
694 u8 p[64];
695 u8 q[64];
696 u8 dp[64];
697 u8 dq[64];
698 u8 u[64];
699 u8 message[128];
700};
701
702struct type50_crb2_msg {
703 struct type50_hdr header;
704 u16 keyblock_type;
705 u8 reserved[6];
706 u8 p[128];
707 u8 q[128];
708 u8 dp[128];
709 u8 dq[128];
710 u8 u[128];
711 u8 message[256];
712};
713
714union type50_msg {
715 struct type50_meb1_msg meb1;
716 struct type50_meb2_msg meb2;
717 struct type50_crb1_msg crb1;
718 struct type50_crb2_msg crb2;
719};
720
721struct type80_hdr {
722 u8 reserved1;
723 u8 type;
724 u16 len;
725 u8 code;
726 u8 reserved2[3];
727 u8 reserved3[8];
728};
729
730#define TYPE80_RSP_CODE 0x80
731
651struct error_hdr { 732struct error_hdr {
652 unsigned char reserved1; 733 unsigned char reserved1;
653 unsigned char type; 734 unsigned char type;
@@ -657,6 +738,7 @@ struct error_hdr {
657}; 738};
658 739
659#define TYPE82_RSP_CODE 0x82 740#define TYPE82_RSP_CODE 0x82
741#define TYPE88_RSP_CODE 0x88
660 742
661#define REP82_ERROR_MACHINE_FAILURE 0x10 743#define REP82_ERROR_MACHINE_FAILURE 0x10
662#define REP82_ERROR_PREEMPT_FAILURE 0x12 744#define REP82_ERROR_PREEMPT_FAILURE 0x12
@@ -679,6 +761,22 @@ struct error_hdr {
679#define REP82_ERROR_PACKET_TRUNCATED 0xA0 761#define REP82_ERROR_PACKET_TRUNCATED 0xA0
680#define REP82_ERROR_ZERO_BUFFER_LEN 0xB0 762#define REP82_ERROR_ZERO_BUFFER_LEN 0xB0
681 763
764#define REP88_ERROR_MODULE_FAILURE 0x10
765#define REP88_ERROR_MODULE_TIMEOUT 0x11
766#define REP88_ERROR_MODULE_NOTINIT 0x13
767#define REP88_ERROR_MODULE_NOTAVAIL 0x14
768#define REP88_ERROR_MODULE_DISABLED 0x15
769#define REP88_ERROR_MODULE_IN_DIAGN 0x17
770#define REP88_ERROR_FASTPATH_DISABLD 0x19
771#define REP88_ERROR_MESSAGE_TYPE 0x20
772#define REP88_ERROR_MESSAGE_MALFORMD 0x22
773#define REP88_ERROR_MESSAGE_LENGTH 0x23
774#define REP88_ERROR_RESERVED_FIELD 0x24
775#define REP88_ERROR_KEY_TYPE 0x34
776#define REP88_ERROR_INVALID_KEY 0x82
777#define REP88_ERROR_OPERAND 0x84
778#define REP88_ERROR_OPERAND_EVEN_MOD 0x85
779
682#define CALLER_HEADER 12 780#define CALLER_HEADER 12
683 781
684static inline int 782static inline int
@@ -687,7 +785,7 @@ testq(int q_nr, int *q_depth, int *dev_type, struct ap_status_word *stat)
687 int ccode; 785 int ccode;
688 786
689 asm volatile 787 asm volatile
690#ifdef __s390x__ 788#ifdef CONFIG_64BIT
691 (" llgfr 0,%4 \n" 789 (" llgfr 0,%4 \n"
692 " slgr 1,1 \n" 790 " slgr 1,1 \n"
693 " lgr 2,1 \n" 791 " lgr 2,1 \n"
@@ -757,7 +855,7 @@ resetq(int q_nr, struct ap_status_word *stat_p)
757 int ccode; 855 int ccode;
758 856
759 asm volatile 857 asm volatile
760#ifdef __s390x__ 858#ifdef CONFIG_64BIT
761 (" llgfr 0,%2 \n" 859 (" llgfr 0,%2 \n"
762 " lghi 1,1 \n" 860 " lghi 1,1 \n"
763 " sll 1,24 \n" 861 " sll 1,24 \n"
@@ -823,7 +921,7 @@ sen(int msg_len, unsigned char *msg_ext, struct ap_status_word *stat)
823 int ccode; 921 int ccode;
824 922
825 asm volatile 923 asm volatile
826#ifdef __s390x__ 924#ifdef CONFIG_64BIT
827 (" lgr 6,%3 \n" 925 (" lgr 6,%3 \n"
828 " llgfr 7,%2 \n" 926 " llgfr 7,%2 \n"
829 " llgt 0,0(6) \n" 927 " llgt 0,0(6) \n"
@@ -902,7 +1000,7 @@ rec(int q_nr, int buff_l, unsigned char *rsp, unsigned char *id,
902 int ccode; 1000 int ccode;
903 1001
904 asm volatile 1002 asm volatile
905#ifdef __s390x__ 1003#ifdef CONFIG_64BIT
906 (" llgfr 0,%2 \n" 1004 (" llgfr 0,%2 \n"
907 " lgr 3,%4 \n" 1005 " lgr 3,%4 \n"
908 " lgr 6,%3 \n" 1006 " lgr 6,%3 \n"
@@ -1029,10 +1127,6 @@ query_online(int deviceNr, int cdx, int resetNr, int *q_depth, int *dev_type)
1029 stat = HD_ONLINE; 1127 stat = HD_ONLINE;
1030 *q_depth = t_depth + 1; 1128 *q_depth = t_depth + 1;
1031 switch (t_dev_type) { 1129 switch (t_dev_type) {
1032 case OTHER_HW:
1033 stat = HD_NOT_THERE;
1034 *dev_type = NILDEV;
1035 break;
1036 case PCICA_HW: 1130 case PCICA_HW:
1037 *dev_type = PCICA; 1131 *dev_type = PCICA;
1038 break; 1132 break;
@@ -1045,6 +1139,9 @@ query_online(int deviceNr, int cdx, int resetNr, int *q_depth, int *dev_type)
1045 case CEX2C_HW: 1139 case CEX2C_HW:
1046 *dev_type = CEX2C; 1140 *dev_type = CEX2C;
1047 break; 1141 break;
1142 case CEX2A_HW:
1143 *dev_type = CEX2A;
1144 break;
1048 default: 1145 default:
1049 *dev_type = NILDEV; 1146 *dev_type = NILDEV;
1050 break; 1147 break;
@@ -2029,6 +2126,177 @@ ICACRT_msg_to_type6CRT_msgX(struct ica_rsa_modexpo_crt *icaMsg_p, int cdx,
2029 return 0; 2126 return 0;
2030} 2127}
2031 2128
2129static int
2130ICAMEX_msg_to_type50MEX_msg(struct ica_rsa_modexpo *icaMex_p, int *z90cMsg_l_p,
2131 union type50_msg *z90cMsg_p)
2132{
2133 int mod_len, msg_size, mod_tgt_len, exp_tgt_len, inp_tgt_len;
2134 unsigned char *mod_tgt, *exp_tgt, *inp_tgt;
2135 union type50_msg *tmp_type50_msg;
2136
2137 mod_len = icaMex_p->inputdatalength;
2138
2139 msg_size = ((mod_len <= 128) ? TYPE50_MEB1_LEN : TYPE50_MEB2_LEN) +
2140 CALLER_HEADER;
2141
2142 memset(z90cMsg_p, 0, msg_size);
2143
2144 tmp_type50_msg = (union type50_msg *)
2145 ((unsigned char *) z90cMsg_p + CALLER_HEADER);
2146
2147 tmp_type50_msg->meb1.header.msg_type_code = TYPE50_TYPE_CODE;
2148
2149 if (mod_len <= 128) {
2150 tmp_type50_msg->meb1.header.msg_len = TYPE50_MEB1_LEN;
2151 tmp_type50_msg->meb1.keyblock_type = TYPE50_MEB1_FMT;
2152 mod_tgt = tmp_type50_msg->meb1.modulus;
2153 mod_tgt_len = sizeof(tmp_type50_msg->meb1.modulus);
2154 exp_tgt = tmp_type50_msg->meb1.exponent;
2155 exp_tgt_len = sizeof(tmp_type50_msg->meb1.exponent);
2156 inp_tgt = tmp_type50_msg->meb1.message;
2157 inp_tgt_len = sizeof(tmp_type50_msg->meb1.message);
2158 } else {
2159 tmp_type50_msg->meb2.header.msg_len = TYPE50_MEB2_LEN;
2160 tmp_type50_msg->meb2.keyblock_type = TYPE50_MEB2_FMT;
2161 mod_tgt = tmp_type50_msg->meb2.modulus;
2162 mod_tgt_len = sizeof(tmp_type50_msg->meb2.modulus);
2163 exp_tgt = tmp_type50_msg->meb2.exponent;
2164 exp_tgt_len = sizeof(tmp_type50_msg->meb2.exponent);
2165 inp_tgt = tmp_type50_msg->meb2.message;
2166 inp_tgt_len = sizeof(tmp_type50_msg->meb2.message);
2167 }
2168
2169 mod_tgt += (mod_tgt_len - mod_len);
2170 if (copy_from_user(mod_tgt, icaMex_p->n_modulus, mod_len))
2171 return SEN_RELEASED;
2172 if (is_empty(mod_tgt, mod_len))
2173 return SEN_USER_ERROR;
2174 exp_tgt += (exp_tgt_len - mod_len);
2175 if (copy_from_user(exp_tgt, icaMex_p->b_key, mod_len))
2176 return SEN_RELEASED;
2177 if (is_empty(exp_tgt, mod_len))
2178 return SEN_USER_ERROR;
2179 inp_tgt += (inp_tgt_len - mod_len);
2180 if (copy_from_user(inp_tgt, icaMex_p->inputdata, mod_len))
2181 return SEN_RELEASED;
2182 if (is_empty(inp_tgt, mod_len))
2183 return SEN_USER_ERROR;
2184
2185 *z90cMsg_l_p = msg_size - CALLER_HEADER;
2186
2187 return 0;
2188}
2189
2190static int
2191ICACRT_msg_to_type50CRT_msg(struct ica_rsa_modexpo_crt *icaMsg_p,
2192 int *z90cMsg_l_p, union type50_msg *z90cMsg_p)
2193{
2194 int mod_len, short_len, long_len, tmp_size, p_tgt_len, q_tgt_len,
2195 dp_tgt_len, dq_tgt_len, u_tgt_len, inp_tgt_len, long_offset;
2196 unsigned char *p_tgt, *q_tgt, *dp_tgt, *dq_tgt, *u_tgt, *inp_tgt,
2197 temp[8];
2198 union type50_msg *tmp_type50_msg;
2199
2200 mod_len = icaMsg_p->inputdatalength;
2201 short_len = mod_len / 2;
2202 long_len = mod_len / 2 + 8;
2203 long_offset = 0;
2204
2205 if (long_len > 128) {
2206 memset(temp, 0x00, sizeof(temp));
2207 if (copy_from_user(temp, icaMsg_p->np_prime, long_len-128))
2208 return SEN_RELEASED;
2209 if (!is_empty(temp, 8))
2210 return SEN_NOT_AVAIL;
2211 if (copy_from_user(temp, icaMsg_p->bp_key, long_len-128))
2212 return SEN_RELEASED;
2213 if (!is_empty(temp, 8))
2214 return SEN_NOT_AVAIL;
2215 if (copy_from_user(temp, icaMsg_p->u_mult_inv, long_len-128))
2216 return SEN_RELEASED;
2217 if (!is_empty(temp, 8))
2218 return SEN_NOT_AVAIL;
2219 long_offset = long_len - 128;
2220 long_len = 128;
2221 }
2222
2223 tmp_size = ((mod_len <= 128) ? TYPE50_CRB1_LEN : TYPE50_CRB2_LEN) +
2224 CALLER_HEADER;
2225
2226 memset(z90cMsg_p, 0, tmp_size);
2227
2228 tmp_type50_msg = (union type50_msg *)
2229 ((unsigned char *) z90cMsg_p + CALLER_HEADER);
2230
2231 tmp_type50_msg->crb1.header.msg_type_code = TYPE50_TYPE_CODE;
2232 if (long_len <= 64) {
2233 tmp_type50_msg->crb1.header.msg_len = TYPE50_CRB1_LEN;
2234 tmp_type50_msg->crb1.keyblock_type = TYPE50_CRB1_FMT;
2235 p_tgt = tmp_type50_msg->crb1.p;
2236 p_tgt_len = sizeof(tmp_type50_msg->crb1.p);
2237 q_tgt = tmp_type50_msg->crb1.q;
2238 q_tgt_len = sizeof(tmp_type50_msg->crb1.q);
2239 dp_tgt = tmp_type50_msg->crb1.dp;
2240 dp_tgt_len = sizeof(tmp_type50_msg->crb1.dp);
2241 dq_tgt = tmp_type50_msg->crb1.dq;
2242 dq_tgt_len = sizeof(tmp_type50_msg->crb1.dq);
2243 u_tgt = tmp_type50_msg->crb1.u;
2244 u_tgt_len = sizeof(tmp_type50_msg->crb1.u);
2245 inp_tgt = tmp_type50_msg->crb1.message;
2246 inp_tgt_len = sizeof(tmp_type50_msg->crb1.message);
2247 } else {
2248 tmp_type50_msg->crb2.header.msg_len = TYPE50_CRB2_LEN;
2249 tmp_type50_msg->crb2.keyblock_type = TYPE50_CRB2_FMT;
2250 p_tgt = tmp_type50_msg->crb2.p;
2251 p_tgt_len = sizeof(tmp_type50_msg->crb2.p);
2252 q_tgt = tmp_type50_msg->crb2.q;
2253 q_tgt_len = sizeof(tmp_type50_msg->crb2.q);
2254 dp_tgt = tmp_type50_msg->crb2.dp;
2255 dp_tgt_len = sizeof(tmp_type50_msg->crb2.dp);
2256 dq_tgt = tmp_type50_msg->crb2.dq;
2257 dq_tgt_len = sizeof(tmp_type50_msg->crb2.dq);
2258 u_tgt = tmp_type50_msg->crb2.u;
2259 u_tgt_len = sizeof(tmp_type50_msg->crb2.u);
2260 inp_tgt = tmp_type50_msg->crb2.message;
2261 inp_tgt_len = sizeof(tmp_type50_msg->crb2.message);
2262 }
2263
2264 p_tgt += (p_tgt_len - long_len);
2265 if (copy_from_user(p_tgt, icaMsg_p->np_prime + long_offset, long_len))
2266 return SEN_RELEASED;
2267 if (is_empty(p_tgt, long_len))
2268 return SEN_USER_ERROR;
2269 q_tgt += (q_tgt_len - short_len);
2270 if (copy_from_user(q_tgt, icaMsg_p->nq_prime, short_len))
2271 return SEN_RELEASED;
2272 if (is_empty(q_tgt, short_len))
2273 return SEN_USER_ERROR;
2274 dp_tgt += (dp_tgt_len - long_len);
2275 if (copy_from_user(dp_tgt, icaMsg_p->bp_key + long_offset, long_len))
2276 return SEN_RELEASED;
2277 if (is_empty(dp_tgt, long_len))
2278 return SEN_USER_ERROR;
2279 dq_tgt += (dq_tgt_len - short_len);
2280 if (copy_from_user(dq_tgt, icaMsg_p->bq_key, short_len))
2281 return SEN_RELEASED;
2282 if (is_empty(dq_tgt, short_len))
2283 return SEN_USER_ERROR;
2284 u_tgt += (u_tgt_len - long_len);
2285 if (copy_from_user(u_tgt, icaMsg_p->u_mult_inv + long_offset, long_len))
2286 return SEN_RELEASED;
2287 if (is_empty(u_tgt, long_len))
2288 return SEN_USER_ERROR;
2289 inp_tgt += (inp_tgt_len - mod_len);
2290 if (copy_from_user(inp_tgt, icaMsg_p->inputdata, mod_len))
2291 return SEN_RELEASED;
2292 if (is_empty(inp_tgt, mod_len))
2293 return SEN_USER_ERROR;
2294
2295 *z90cMsg_l_p = tmp_size - CALLER_HEADER;
2296
2297 return 0;
2298}
2299
2032int 2300int
2033convert_request(unsigned char *buffer, int func, unsigned short function, 2301convert_request(unsigned char *buffer, int func, unsigned short function,
2034 int cdx, int dev_type, int *msg_l_p, unsigned char *msg_p) 2302 int cdx, int dev_type, int *msg_l_p, unsigned char *msg_p)
@@ -2071,6 +2339,16 @@ convert_request(unsigned char *buffer, int func, unsigned short function,
2071 cdx, msg_l_p, (struct type6_msg *) msg_p, 2339 cdx, msg_l_p, (struct type6_msg *) msg_p,
2072 dev_type); 2340 dev_type);
2073 } 2341 }
2342 if (dev_type == CEX2A) {
2343 if (func == ICARSACRT)
2344 return ICACRT_msg_to_type50CRT_msg(
2345 (struct ica_rsa_modexpo_crt *) buffer,
2346 msg_l_p, (union type50_msg *) msg_p);
2347 else
2348 return ICAMEX_msg_to_type50MEX_msg(
2349 (struct ica_rsa_modexpo *) buffer,
2350 msg_l_p, (union type50_msg *) msg_p);
2351 }
2074 2352
2075 return 0; 2353 return 0;
2076} 2354}
@@ -2081,8 +2359,8 @@ unset_ext_bitlens(void)
2081{ 2359{
2082 if (!ext_bitlens_msg_count) { 2360 if (!ext_bitlens_msg_count) {
2083 PRINTK("Unable to use coprocessors for extended bitlengths. " 2361 PRINTK("Unable to use coprocessors for extended bitlengths. "
2084 "Using PCICAs (if present) for extended bitlengths. " 2362 "Using PCICAs/CEX2As (if present) for extended "
2085 "This is not an error.\n"); 2363 "bitlengths. This is not an error.\n");
2086 ext_bitlens_msg_count++; 2364 ext_bitlens_msg_count++;
2087 } 2365 }
2088 ext_bitlens = 0; 2366 ext_bitlens = 0;
@@ -2094,6 +2372,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
2094{ 2372{
2095 struct ica_rsa_modexpo *icaMsg_p = (struct ica_rsa_modexpo *) buffer; 2373 struct ica_rsa_modexpo *icaMsg_p = (struct ica_rsa_modexpo *) buffer;
2096 struct error_hdr *errh_p = (struct error_hdr *) response; 2374 struct error_hdr *errh_p = (struct error_hdr *) response;
2375 struct type80_hdr *t80h_p = (struct type80_hdr *) response;
2097 struct type84_hdr *t84h_p = (struct type84_hdr *) response; 2376 struct type84_hdr *t84h_p = (struct type84_hdr *) response;
2098 struct type86_fmt2_msg *t86m_p = (struct type86_fmt2_msg *) response; 2377 struct type86_fmt2_msg *t86m_p = (struct type86_fmt2_msg *) response;
2099 int reply_code, service_rc, service_rs, src_l; 2378 int reply_code, service_rc, service_rs, src_l;
@@ -2108,6 +2387,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
2108 src_l = 0; 2387 src_l = 0;
2109 switch (errh_p->type) { 2388 switch (errh_p->type) {
2110 case TYPE82_RSP_CODE: 2389 case TYPE82_RSP_CODE:
2390 case TYPE88_RSP_CODE:
2111 reply_code = errh_p->reply_code; 2391 reply_code = errh_p->reply_code;
2112 src_p = (unsigned char *)errh_p; 2392 src_p = (unsigned char *)errh_p;
2113 PRINTK("Hardware error: Type %02X Message Header: " 2393 PRINTK("Hardware error: Type %02X Message Header: "
@@ -2116,6 +2396,10 @@ convert_response(unsigned char *response, unsigned char *buffer,
2116 src_p[0], src_p[1], src_p[2], src_p[3], 2396 src_p[0], src_p[1], src_p[2], src_p[3],
2117 src_p[4], src_p[5], src_p[6], src_p[7]); 2397 src_p[4], src_p[5], src_p[6], src_p[7]);
2118 break; 2398 break;
2399 case TYPE80_RSP_CODE:
2400 src_l = icaMsg_p->outputdatalength;
2401 src_p = response + (int)t80h_p->len - src_l;
2402 break;
2119 case TYPE84_RSP_CODE: 2403 case TYPE84_RSP_CODE:
2120 src_l = icaMsg_p->outputdatalength; 2404 src_l = icaMsg_p->outputdatalength;
2121 src_p = response + (int)t84h_p->len - src_l; 2405 src_p = response + (int)t84h_p->len - src_l;
@@ -2202,6 +2486,7 @@ convert_response(unsigned char *response, unsigned char *buffer,
2202 if (reply_code) 2486 if (reply_code)
2203 switch (reply_code) { 2487 switch (reply_code) {
2204 case REP82_ERROR_OPERAND_INVALID: 2488 case REP82_ERROR_OPERAND_INVALID:
2489 case REP88_ERROR_MESSAGE_MALFORMD:
2205 return REC_OPERAND_INV; 2490 return REC_OPERAND_INV;
2206 case REP82_ERROR_OPERAND_SIZE: 2491 case REP82_ERROR_OPERAND_SIZE:
2207 return REC_OPERAND_SIZE; 2492 return REC_OPERAND_SIZE;
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 4010f2bb85af..135ae04e6e75 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -34,7 +34,6 @@
34#include <linux/miscdevice.h> 34#include <linux/miscdevice.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/moduleparam.h> 36#include <linux/moduleparam.h>
37#include <linux/kobject_uevent.h>
38#include <linux/proc_fs.h> 37#include <linux/proc_fs.h>
39#include <linux/syscalls.h> 38#include <linux/syscalls.h>
40#include "z90crypt.h" 39#include "z90crypt.h"
@@ -229,7 +228,7 @@ struct device_x {
229 */ 228 */
230struct device { 229struct device {
231 int dev_type; // PCICA, PCICC, PCIXCC_MCL2, 230 int dev_type; // PCICA, PCICC, PCIXCC_MCL2,
232 // PCIXCC_MCL3, CEX2C 231 // PCIXCC_MCL3, CEX2C, CEX2A
233 enum devstat dev_stat; // current device status 232 enum devstat dev_stat; // current device status
234 int dev_self_x; // Index in array 233 int dev_self_x; // Index in array
235 int disabled; // Set when device is in error 234 int disabled; // Set when device is in error
@@ -296,26 +295,30 @@ struct caller {
296/** 295/**
297 * Function prototypes from z90hardware.c 296 * Function prototypes from z90hardware.c
298 */ 297 */
299enum hdstat query_online(int, int, int, int *, int *); 298enum hdstat query_online(int deviceNr, int cdx, int resetNr, int *q_depth,
300enum devstat reset_device(int, int, int); 299 int *dev_type);
301enum devstat send_to_AP(int, int, int, unsigned char *); 300enum devstat reset_device(int deviceNr, int cdx, int resetNr);
302enum devstat receive_from_AP(int, int, int, unsigned char *, unsigned char *); 301enum devstat send_to_AP(int dev_nr, int cdx, int msg_len, unsigned char *msg_ext);
303int convert_request(unsigned char *, int, short, int, int, int *, 302enum devstat receive_from_AP(int dev_nr, int cdx, int resplen,
304 unsigned char *); 303 unsigned char *resp, unsigned char *psmid);
305int convert_response(unsigned char *, unsigned char *, int *, unsigned char *); 304int convert_request(unsigned char *buffer, int func, unsigned short function,
305 int cdx, int dev_type, int *msg_l_p, unsigned char *msg_p);
306int convert_response(unsigned char *response, unsigned char *buffer,
307 int *respbufflen_p, unsigned char *resp_buff);
306 308
307/** 309/**
308 * Low level function prototypes 310 * Low level function prototypes
309 */ 311 */
310static int create_z90crypt(int *); 312static int create_z90crypt(int *cdx_p);
311static int refresh_z90crypt(int *); 313static int refresh_z90crypt(int *cdx_p);
312static int find_crypto_devices(struct status *); 314static int find_crypto_devices(struct status *deviceMask);
313static int create_crypto_device(int); 315static int create_crypto_device(int index);
314static int destroy_crypto_device(int); 316static int destroy_crypto_device(int index);
315static void destroy_z90crypt(void); 317static void destroy_z90crypt(void);
316static int refresh_index_array(struct status *, struct device_x *); 318static int refresh_index_array(struct status *status_str,
317static int probe_device_type(struct device *); 319 struct device_x *index_array);
318static int probe_PCIXCC_type(struct device *); 320static int probe_device_type(struct device *devPtr);
321static int probe_PCIXCC_type(struct device *devPtr);
319 322
320/** 323/**
321 * proc fs definitions 324 * proc fs definitions
@@ -426,7 +429,7 @@ static struct miscdevice z90crypt_misc_device = {
426MODULE_AUTHOR("zSeries Linux Crypto Team: Robert H. Burroughs, Eric D. Rossman" 429MODULE_AUTHOR("zSeries Linux Crypto Team: Robert H. Burroughs, Eric D. Rossman"
427 "and Jochen Roehrig"); 430 "and Jochen Roehrig");
428MODULE_DESCRIPTION("zSeries Linux Cryptographic Coprocessor device driver, " 431MODULE_DESCRIPTION("zSeries Linux Cryptographic Coprocessor device driver, "
429 "Copyright 2001, 2004 IBM Corporation"); 432 "Copyright 2001, 2005 IBM Corporation");
430MODULE_LICENSE("GPL"); 433MODULE_LICENSE("GPL");
431module_param(domain, int, 0); 434module_param(domain, int, 0);
432MODULE_PARM_DESC(domain, "domain index for device"); 435MODULE_PARM_DESC(domain, "domain index for device");
@@ -861,6 +864,12 @@ get_status_CEX2Ccount(void)
861} 864}
862 865
863static inline int 866static inline int
867get_status_CEX2Acount(void)
868{
869 return z90crypt.hdware_info->type_mask[CEX2A].st_count;
870}
871
872static inline int
864get_status_requestq_count(void) 873get_status_requestq_count(void)
865{ 874{
866 return requestq_count; 875 return requestq_count;
@@ -1009,11 +1018,13 @@ static inline int
1009select_device_type(int *dev_type_p, int bytelength) 1018select_device_type(int *dev_type_p, int bytelength)
1010{ 1019{
1011 static int count = 0; 1020 static int count = 0;
1012 int PCICA_avail, PCIXCC_MCL3_avail, CEX2C_avail, index_to_use; 1021 int PCICA_avail, PCIXCC_MCL3_avail, CEX2C_avail, CEX2A_avail,
1022 index_to_use;
1013 struct status *stat; 1023 struct status *stat;
1014 if ((*dev_type_p != PCICC) && (*dev_type_p != PCICA) && 1024 if ((*dev_type_p != PCICC) && (*dev_type_p != PCICA) &&
1015 (*dev_type_p != PCIXCC_MCL2) && (*dev_type_p != PCIXCC_MCL3) && 1025 (*dev_type_p != PCIXCC_MCL2) && (*dev_type_p != PCIXCC_MCL3) &&
1016 (*dev_type_p != CEX2C) && (*dev_type_p != ANYDEV)) 1026 (*dev_type_p != CEX2C) && (*dev_type_p != CEX2A) &&
1027 (*dev_type_p != ANYDEV))
1017 return -1; 1028 return -1;
1018 if (*dev_type_p != ANYDEV) { 1029 if (*dev_type_p != ANYDEV) {
1019 stat = &z90crypt.hdware_info->type_mask[*dev_type_p]; 1030 stat = &z90crypt.hdware_info->type_mask[*dev_type_p];
@@ -1023,7 +1034,13 @@ select_device_type(int *dev_type_p, int bytelength)
1023 return -1; 1034 return -1;
1024 } 1035 }
1025 1036
1026 /* Assumption: PCICA, PCIXCC_MCL3, and CEX2C are all similar in speed */ 1037 /**
1038 * Assumption: PCICA, PCIXCC_MCL3, CEX2C, and CEX2A are all similar in
1039 * speed.
1040 *
1041 * PCICA and CEX2A do NOT co-exist, so it would be either one or the
1042 * other present.
1043 */
1027 stat = &z90crypt.hdware_info->type_mask[PCICA]; 1044 stat = &z90crypt.hdware_info->type_mask[PCICA];
1028 PCICA_avail = stat->st_count - 1045 PCICA_avail = stat->st_count -
1029 (stat->disabled_count + stat->user_disabled_count); 1046 (stat->disabled_count + stat->user_disabled_count);
@@ -1033,29 +1050,38 @@ select_device_type(int *dev_type_p, int bytelength)
1033 stat = &z90crypt.hdware_info->type_mask[CEX2C]; 1050 stat = &z90crypt.hdware_info->type_mask[CEX2C];
1034 CEX2C_avail = stat->st_count - 1051 CEX2C_avail = stat->st_count -
1035 (stat->disabled_count + stat->user_disabled_count); 1052 (stat->disabled_count + stat->user_disabled_count);
1036 if (PCICA_avail || PCIXCC_MCL3_avail || CEX2C_avail) { 1053 stat = &z90crypt.hdware_info->type_mask[CEX2A];
1054 CEX2A_avail = stat->st_count -
1055 (stat->disabled_count + stat->user_disabled_count);
1056 if (PCICA_avail || PCIXCC_MCL3_avail || CEX2C_avail || CEX2A_avail) {
1037 /** 1057 /**
1038 * bitlength is a factor, PCICA is the most capable, even with 1058 * bitlength is a factor, PCICA or CEX2A are the most capable,
1039 * the new MCL for PCIXCC. 1059 * even with the new MCL for PCIXCC.
1040 */ 1060 */
1041 if ((bytelength < PCIXCC_MIN_MOD_SIZE) || 1061 if ((bytelength < PCIXCC_MIN_MOD_SIZE) ||
1042 (!ext_bitlens && (bytelength < OLD_PCIXCC_MIN_MOD_SIZE))) { 1062 (!ext_bitlens && (bytelength < OLD_PCIXCC_MIN_MOD_SIZE))) {
1043 if (!PCICA_avail) 1063 if (PCICA_avail) {
1044 return -1;
1045 else {
1046 *dev_type_p = PCICA; 1064 *dev_type_p = PCICA;
1047 return 0; 1065 return 0;
1048 } 1066 }
1067 if (CEX2A_avail) {
1068 *dev_type_p = CEX2A;
1069 return 0;
1070 }
1071 return -1;
1049 } 1072 }
1050 1073
1051 index_to_use = count % (PCICA_avail + PCIXCC_MCL3_avail + 1074 index_to_use = count % (PCICA_avail + PCIXCC_MCL3_avail +
1052 CEX2C_avail); 1075 CEX2C_avail + CEX2A_avail);
1053 if (index_to_use < PCICA_avail) 1076 if (index_to_use < PCICA_avail)
1054 *dev_type_p = PCICA; 1077 *dev_type_p = PCICA;
1055 else if (index_to_use < (PCICA_avail + PCIXCC_MCL3_avail)) 1078 else if (index_to_use < (PCICA_avail + PCIXCC_MCL3_avail))
1056 *dev_type_p = PCIXCC_MCL3; 1079 *dev_type_p = PCIXCC_MCL3;
1057 else 1080 else if (index_to_use < (PCICA_avail + PCIXCC_MCL3_avail +
1081 CEX2C_avail))
1058 *dev_type_p = CEX2C; 1082 *dev_type_p = CEX2C;
1083 else
1084 *dev_type_p = CEX2A;
1059 count++; 1085 count++;
1060 return 0; 1086 return 0;
1061 } 1087 }
@@ -1360,7 +1386,7 @@ build_caller(struct work_element *we_p, short function)
1360 1386
1361 if ((we_p->devtype != PCICC) && (we_p->devtype != PCICA) && 1387 if ((we_p->devtype != PCICC) && (we_p->devtype != PCICA) &&
1362 (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) && 1388 (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) &&
1363 (we_p->devtype != CEX2C)) 1389 (we_p->devtype != CEX2C) && (we_p->devtype != CEX2A))
1364 return SEN_NOT_AVAIL; 1390 return SEN_NOT_AVAIL;
1365 1391
1366 memcpy(caller_p->caller_id, we_p->caller_id, 1392 memcpy(caller_p->caller_id, we_p->caller_id,
@@ -1429,7 +1455,8 @@ get_crypto_request_buffer(struct work_element *we_p)
1429 1455
1430 if ((we_p->devtype != PCICA) && (we_p->devtype != PCICC) && 1456 if ((we_p->devtype != PCICA) && (we_p->devtype != PCICC) &&
1431 (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) && 1457 (we_p->devtype != PCIXCC_MCL2) && (we_p->devtype != PCIXCC_MCL3) &&
1432 (we_p->devtype != CEX2C) && (we_p->devtype != ANYDEV)) { 1458 (we_p->devtype != CEX2C) && (we_p->devtype != CEX2A) &&
1459 (we_p->devtype != ANYDEV)) {
1433 PRINTK("invalid device type\n"); 1460 PRINTK("invalid device type\n");
1434 return SEN_USER_ERROR; 1461 return SEN_USER_ERROR;
1435 } 1462 }
@@ -1504,8 +1531,9 @@ get_crypto_request_buffer(struct work_element *we_p)
1504 1531
1505 function = PCI_FUNC_KEY_ENCRYPT; 1532 function = PCI_FUNC_KEY_ENCRYPT;
1506 switch (we_p->devtype) { 1533 switch (we_p->devtype) {
1507 /* PCICA does everything with a simple RSA mod-expo operation */ 1534 /* PCICA and CEX2A do everything with a simple RSA mod-expo operation */
1508 case PCICA: 1535 case PCICA:
1536 case CEX2A:
1509 function = PCI_FUNC_KEY_ENCRYPT; 1537 function = PCI_FUNC_KEY_ENCRYPT;
1510 break; 1538 break;
1511 /** 1539 /**
@@ -1663,7 +1691,8 @@ z90crypt_rsa(struct priv_data *private_data_p, pid_t pid,
1663 * trigger a fallback to software. 1691 * trigger a fallback to software.
1664 */ 1692 */
1665 case -EINVAL: 1693 case -EINVAL:
1666 if (we_p->devtype != PCICA) 1694 if ((we_p->devtype != PCICA) &&
1695 (we_p->devtype != CEX2A))
1667 rv = -EGETBUFF; 1696 rv = -EGETBUFF;
1668 break; 1697 break;
1669 case -ETIMEOUT: 1698 case -ETIMEOUT:
@@ -1780,6 +1809,12 @@ z90crypt_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
1780 ret = -EFAULT; 1809 ret = -EFAULT;
1781 break; 1810 break;
1782 1811
1812 case Z90STAT_CEX2ACOUNT:
1813 tempstat = get_status_CEX2Acount();
1814 if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0)
1815 ret = -EFAULT;
1816 break;
1817
1783 case Z90STAT_REQUESTQ_COUNT: 1818 case Z90STAT_REQUESTQ_COUNT:
1784 tempstat = get_status_requestq_count(); 1819 tempstat = get_status_requestq_count();
1785 if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0) 1820 if (copy_to_user((int __user *)arg, &tempstat, sizeof(int)) != 0)
@@ -2020,6 +2055,8 @@ z90crypt_status(char *resp_buff, char **start, off_t offset,
2020 get_status_PCIXCCMCL3count()); 2055 get_status_PCIXCCMCL3count());
2021 len += sprintf(resp_buff+len, "CEX2C count: %d\n", 2056 len += sprintf(resp_buff+len, "CEX2C count: %d\n",
2022 get_status_CEX2Ccount()); 2057 get_status_CEX2Ccount());
2058 len += sprintf(resp_buff+len, "CEX2A count: %d\n",
2059 get_status_CEX2Acount());
2023 len += sprintf(resp_buff+len, "requestq count: %d\n", 2060 len += sprintf(resp_buff+len, "requestq count: %d\n",
2024 get_status_requestq_count()); 2061 get_status_requestq_count());
2025 len += sprintf(resp_buff+len, "pendingq count: %d\n", 2062 len += sprintf(resp_buff+len, "pendingq count: %d\n",
@@ -2027,8 +2064,8 @@ z90crypt_status(char *resp_buff, char **start, off_t offset,
2027 len += sprintf(resp_buff+len, "Total open handles: %d\n\n", 2064 len += sprintf(resp_buff+len, "Total open handles: %d\n\n",
2028 get_status_totalopen_count()); 2065 get_status_totalopen_count());
2029 len += sprinthx( 2066 len += sprinthx(
2030 "Online devices: 1: PCICA, 2: PCICC, 3: PCIXCC (MCL2), " 2067 "Online devices: 1=PCICA 2=PCICC 3=PCIXCC(MCL2) "
2031 "4: PCIXCC (MCL3), 5: CEX2C", 2068 "4=PCIXCC(MCL3) 5=CEX2C 6=CEX2A",
2032 resp_buff+len, 2069 resp_buff+len,
2033 get_status_status_mask(workarea), 2070 get_status_status_mask(workarea),
2034 Z90CRYPT_NUM_APS); 2071 Z90CRYPT_NUM_APS);
@@ -2141,6 +2178,7 @@ z90crypt_status_write(struct file *file, const char __user *buffer,
2141 case '3': // PCIXCC_MCL2 2178 case '3': // PCIXCC_MCL2
2142 case '4': // PCIXCC_MCL3 2179 case '4': // PCIXCC_MCL3
2143 case '5': // CEX2C 2180 case '5': // CEX2C
2181 case '6': // CEX2A
2144 j++; 2182 j++;
2145 break; 2183 break;
2146 case 'd': 2184 case 'd':
@@ -3008,7 +3046,9 @@ create_crypto_device(int index)
3008 z90crypt.hdware_info->device_type_array[index] = 4; 3046 z90crypt.hdware_info->device_type_array[index] = 4;
3009 else if (deviceType == CEX2C) 3047 else if (deviceType == CEX2C)
3010 z90crypt.hdware_info->device_type_array[index] = 5; 3048 z90crypt.hdware_info->device_type_array[index] = 5;
3011 else 3049 else if (deviceType == CEX2A)
3050 z90crypt.hdware_info->device_type_array[index] = 6;
3051 else // No idea how this would happen.
3012 z90crypt.hdware_info->device_type_array[index] = -1; 3052 z90crypt.hdware_info->device_type_array[index] = -1;
3013 } 3053 }
3014 3054
diff --git a/drivers/s390/net/Kconfig b/drivers/s390/net/Kconfig
index a7efc394515e..548854754921 100644
--- a/drivers/s390/net/Kconfig
+++ b/drivers/s390/net/Kconfig
@@ -1,5 +1,5 @@
1menu "S/390 network device drivers" 1menu "S/390 network device drivers"
2 depends on NETDEVICES && ARCH_S390 2 depends on NETDEVICES && S390
3 3
4config LCS 4config LCS
5 tristate "Lan Channel Station Interface" 5 tristate "Lan Channel Station Interface"
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index 6b63d21612ec..e70af7f39946 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -1603,7 +1603,7 @@ dumpit(char* buf, int len)
1603 __u32 ct, sw, rm, dup; 1603 __u32 ct, sw, rm, dup;
1604 char *ptr, *rptr; 1604 char *ptr, *rptr;
1605 char tbuf[82], tdup[82]; 1605 char tbuf[82], tdup[82];
1606#if (CONFIG_ARCH_S390X) 1606#if (CONFIG_64BIT)
1607 char addr[22]; 1607 char addr[22];
1608#else 1608#else
1609 char addr[12]; 1609 char addr[12];
@@ -1619,7 +1619,7 @@ dumpit(char* buf, int len)
1619 dup = 0; 1619 dup = 0;
1620 for ( ct=0; ct < len; ct++, ptr++, rptr++ ) { 1620 for ( ct=0; ct < len; ct++, ptr++, rptr++ ) {
1621 if (sw == 0) { 1621 if (sw == 0) {
1622#if (CONFIG_ARCH_S390X) 1622#if (CONFIG_64BIT)
1623 sprintf(addr, "%16.16lX",(unsigned long)rptr); 1623 sprintf(addr, "%16.16lX",(unsigned long)rptr);
1624#else 1624#else
1625 sprintf(addr, "%8.8X",(__u32)rptr); 1625 sprintf(addr, "%8.8X",(__u32)rptr);
@@ -1634,7 +1634,7 @@ dumpit(char* buf, int len)
1634 if (sw == 8) { 1634 if (sw == 8) {
1635 strcat(bhex, " "); 1635 strcat(bhex, " ");
1636 } 1636 }
1637#if (CONFIG_ARCH_S390X) 1637#if (CONFIG_64BIT)
1638 sprintf(tbuf,"%2.2lX", (unsigned long)*ptr); 1638 sprintf(tbuf,"%2.2lX", (unsigned long)*ptr);
1639#else 1639#else
1640 sprintf(tbuf,"%2.2X", (__u32)*ptr); 1640 sprintf(tbuf,"%2.2X", (__u32)*ptr);
diff --git a/drivers/s390/net/cu3088.c b/drivers/s390/net/cu3088.c
index 0075894c71db..77dacb465732 100644
--- a/drivers/s390/net/cu3088.c
+++ b/drivers/s390/net/cu3088.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: cu3088.c,v 1.35 2005/03/30 19:28:52 richtera Exp $ 2 * $Id: cu3088.c,v 1.36 2005/10/25 14:37:17 cohuck Exp $
3 * 3 *
4 * CTC / LCS ccw_device driver 4 * CTC / LCS ccw_device driver
5 * 5 *
@@ -27,6 +27,7 @@
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/err.h> 28#include <linux/err.h>
29 29
30#include <asm/s390_rdev.h>
30#include <asm/ccwdev.h> 31#include <asm/ccwdev.h>
31#include <asm/ccwgroup.h> 32#include <asm/ccwgroup.h>
32 33
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index df7647c3c100..ea8177392564 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: iucv.c,v 1.45 2005/04/26 22:59:06 braunu Exp $ 2 * $Id: iucv.c,v 1.47 2005/11/21 11:35:22 mschwide Exp $
3 * 3 *
4 * IUCV network driver 4 * IUCV network driver
5 * 5 *
@@ -29,7 +29,7 @@
29 * along with this program; if not, write to the Free Software 29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 30 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 * 31 *
32 * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.45 $ 32 * RELEASE-TAG: IUCV lowlevel driver $Revision: 1.47 $
33 * 33 *
34 */ 34 */
35 35
@@ -54,7 +54,7 @@
54#include <asm/s390_ext.h> 54#include <asm/s390_ext.h>
55#include <asm/ebcdic.h> 55#include <asm/ebcdic.h>
56#include <asm/smp.h> 56#include <asm/smp.h>
57#include <asm/ccwdev.h> //for root device stuff 57#include <asm/s390_rdev.h>
58 58
59/* FLAGS: 59/* FLAGS:
60 * All flags are defined in the field IPFLAGS1 of each function 60 * All flags are defined in the field IPFLAGS1 of each function
@@ -355,7 +355,7 @@ do { \
355static void 355static void
356iucv_banner(void) 356iucv_banner(void)
357{ 357{
358 char vbuf[] = "$Revision: 1.45 $"; 358 char vbuf[] = "$Revision: 1.47 $";
359 char *version = vbuf; 359 char *version = vbuf;
360 360
361 if ((version = strchr(version, ':'))) { 361 if ((version = strchr(version, ':'))) {
@@ -477,7 +477,7 @@ grab_param(void)
477 ptr++; 477 ptr++;
478 if (ptr >= iucv_param_pool + PARAM_POOL_SIZE) 478 if (ptr >= iucv_param_pool + PARAM_POOL_SIZE)
479 ptr = iucv_param_pool; 479 ptr = iucv_param_pool;
480 } while (atomic_compare_and_swap(0, 1, &ptr->in_use)); 480 } while (atomic_cmpxchg(&ptr->in_use, 0, 1) != 0);
481 hint = ptr - iucv_param_pool; 481 hint = ptr - iucv_param_pool;
482 482
483 memset(&ptr->param, 0, sizeof(ptr->param)); 483 memset(&ptr->param, 0, sizeof(ptr->param));
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index 011915d5e243..f94f1f25eec6 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -62,7 +62,8 @@ qeth_eddp_free_context(struct qeth_eddp_context *ctx)
62 for (i = 0; i < ctx->num_pages; ++i) 62 for (i = 0; i < ctx->num_pages; ++i)
63 free_page((unsigned long)ctx->pages[i]); 63 free_page((unsigned long)ctx->pages[i]);
64 kfree(ctx->pages); 64 kfree(ctx->pages);
65 kfree(ctx->elements); 65 if (ctx->elements != NULL)
66 kfree(ctx->elements);
66 kfree(ctx); 67 kfree(ctx);
67} 68}
68 69
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index 99cceb242ec4..97f927c01a82 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.242 $) 3 * linux/drivers/s390/net/qeth_main.c ($Revision: 1.251 $)
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * 6 *
@@ -12,7 +12,7 @@
12 * Frank Pavlic (fpavlic@de.ibm.com) and 12 * Frank Pavlic (fpavlic@de.ibm.com) and
13 * Thomas Spatzier <tspat@de.ibm.com> 13 * Thomas Spatzier <tspat@de.ibm.com>
14 * 14 *
15 * $Revision: 1.242 $ $Date: 2005/05/04 20:19:18 $ 15 * $Revision: 1.251 $ $Date: 2005/05/04 20:19:18 $
16 * 16 *
17 * This program is free software; you can redistribute it and/or modify 17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by 18 * it under the terms of the GNU General Public License as published by
@@ -65,6 +65,7 @@
65#include <asm/timex.h> 65#include <asm/timex.h>
66#include <asm/semaphore.h> 66#include <asm/semaphore.h>
67#include <asm/uaccess.h> 67#include <asm/uaccess.h>
68#include <asm/s390_rdev.h>
68 69
69#include "qeth.h" 70#include "qeth.h"
70#include "qeth_mpc.h" 71#include "qeth_mpc.h"
@@ -72,7 +73,7 @@
72#include "qeth_eddp.h" 73#include "qeth_eddp.h"
73#include "qeth_tso.h" 74#include "qeth_tso.h"
74 75
75#define VERSION_QETH_C "$Revision: 1.242 $" 76#define VERSION_QETH_C "$Revision: 1.251 $"
76static const char *version = "qeth S/390 OSA-Express driver"; 77static const char *version = "qeth S/390 OSA-Express driver";
77 78
78/** 79/**
@@ -518,7 +519,8 @@ __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
518 519
519 QETH_DBF_TEXT(setup, 3, "setoffl"); 520 QETH_DBF_TEXT(setup, 3, "setoffl");
520 QETH_DBF_HEX(setup, 3, &card, sizeof(void *)); 521 QETH_DBF_HEX(setup, 3, &card, sizeof(void *));
521 522
523 netif_carrier_off(card->dev);
522 recover_flag = card->state; 524 recover_flag = card->state;
523 if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){ 525 if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){
524 PRINT_WARN("Stopping card %s interrupted by user!\n", 526 PRINT_WARN("Stopping card %s interrupted by user!\n",
@@ -1020,7 +1022,6 @@ void
1020qeth_schedule_recovery(struct qeth_card *card) 1022qeth_schedule_recovery(struct qeth_card *card)
1021{ 1023{
1022 QETH_DBF_TEXT(trace,2,"startrec"); 1024 QETH_DBF_TEXT(trace,2,"startrec");
1023
1024 if (qeth_set_thread_start_bit(card, QETH_RECOVER_THREAD) == 0) 1025 if (qeth_set_thread_start_bit(card, QETH_RECOVER_THREAD) == 0)
1025 schedule_work(&card->kernel_thread_starter); 1026 schedule_work(&card->kernel_thread_starter);
1026} 1027}
@@ -1396,7 +1397,7 @@ qeth_idx_activate_get_answer(struct qeth_channel *channel,
1396 channel->ccw.cda = (__u32) __pa(iob->data); 1397 channel->ccw.cda = (__u32) __pa(iob->data);
1397 1398
1398 wait_event(card->wait_q, 1399 wait_event(card->wait_q,
1399 atomic_compare_and_swap(0,1,&channel->irq_pending) == 0); 1400 atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0);
1400 QETH_DBF_TEXT(setup, 6, "noirqpnd"); 1401 QETH_DBF_TEXT(setup, 6, "noirqpnd");
1401 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 1402 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1402 rc = ccw_device_start(channel->ccwdev, 1403 rc = ccw_device_start(channel->ccwdev,
@@ -1463,7 +1464,7 @@ qeth_idx_activate_channel(struct qeth_channel *channel,
1463 memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob->data), &temp, 2); 1464 memcpy(QETH_IDX_ACT_QDIO_DEV_REALADDR(iob->data), &temp, 2);
1464 1465
1465 wait_event(card->wait_q, 1466 wait_event(card->wait_q,
1466 atomic_compare_and_swap(0,1,&channel->irq_pending) == 0); 1467 atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0);
1467 QETH_DBF_TEXT(setup, 6, "noirqpnd"); 1468 QETH_DBF_TEXT(setup, 6, "noirqpnd");
1468 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); 1469 spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags);
1469 rc = ccw_device_start(channel->ccwdev, 1470 rc = ccw_device_start(channel->ccwdev,
@@ -1616,7 +1617,7 @@ qeth_issue_next_read(struct qeth_card *card)
1616 } 1617 }
1617 qeth_setup_ccw(&card->read, iob->data, QETH_BUFSIZE); 1618 qeth_setup_ccw(&card->read, iob->data, QETH_BUFSIZE);
1618 wait_event(card->wait_q, 1619 wait_event(card->wait_q,
1619 atomic_compare_and_swap(0,1,&card->read.irq_pending) == 0); 1620 atomic_cmpxchg(&card->read.irq_pending, 0, 1) == 0);
1620 QETH_DBF_TEXT(trace, 6, "noirqpnd"); 1621 QETH_DBF_TEXT(trace, 6, "noirqpnd");
1621 rc = ccw_device_start(card->read.ccwdev, &card->read.ccw, 1622 rc = ccw_device_start(card->read.ccwdev, &card->read.ccw,
1622 (addr_t) iob, 0, 0); 1623 (addr_t) iob, 0, 0);
@@ -1710,7 +1711,6 @@ qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
1710 "IP address reset.\n", 1711 "IP address reset.\n",
1711 QETH_CARD_IFNAME(card), 1712 QETH_CARD_IFNAME(card),
1712 card->info.chpid); 1713 card->info.chpid);
1713 netif_carrier_on(card->dev);
1714 qeth_schedule_recovery(card); 1714 qeth_schedule_recovery(card);
1715 return NULL; 1715 return NULL;
1716 case IPA_CMD_MODCCID: 1716 case IPA_CMD_MODCCID:
@@ -1883,7 +1883,7 @@ qeth_send_control_data(struct qeth_card *card, int len,
1883 spin_unlock_irqrestore(&card->lock, flags); 1883 spin_unlock_irqrestore(&card->lock, flags);
1884 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN); 1884 QETH_DBF_HEX(control, 2, iob->data, QETH_DBF_CONTROL_LEN);
1885 wait_event(card->wait_q, 1885 wait_event(card->wait_q,
1886 atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0); 1886 atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0);
1887 qeth_prepare_control_data(card, len, iob); 1887 qeth_prepare_control_data(card, len, iob);
1888 if (IS_IPA(iob->data)) 1888 if (IS_IPA(iob->data))
1889 timer.expires = jiffies + QETH_IPA_TIMEOUT; 1889 timer.expires = jiffies + QETH_IPA_TIMEOUT;
@@ -1925,7 +1925,7 @@ qeth_osn_send_control_data(struct qeth_card *card, int len,
1925 QETH_DBF_TEXT(trace, 5, "osndctrd"); 1925 QETH_DBF_TEXT(trace, 5, "osndctrd");
1926 1926
1927 wait_event(card->wait_q, 1927 wait_event(card->wait_q,
1928 atomic_compare_and_swap(0,1,&card->write.irq_pending) == 0); 1928 atomic_cmpxchg(&card->write.irq_pending, 0, 1) == 0);
1929 qeth_prepare_control_data(card, len, iob); 1929 qeth_prepare_control_data(card, len, iob);
1930 QETH_DBF_TEXT(trace, 6, "osnoirqp"); 1930 QETH_DBF_TEXT(trace, 6, "osnoirqp");
1931 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags); 1931 spin_lock_irqsave(get_ccwdev_lock(card->write.ccwdev), flags);
@@ -1959,7 +1959,7 @@ qeth_osn_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1959{ 1959{
1960 u16 s1, s2; 1960 u16 s1, s2;
1961 1961
1962QETH_DBF_TEXT(trace,4,"osndipa"); 1962 QETH_DBF_TEXT(trace,4,"osndipa");
1963 1963
1964 qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2); 1964 qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2);
1965 s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len); 1965 s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len);
@@ -2203,24 +2203,21 @@ qeth_ulp_setup(struct qeth_card *card)
2203} 2203}
2204 2204
2205static inline int 2205static inline int
2206qeth_check_for_inbound_error(struct qeth_qdio_buffer *buf, 2206qeth_check_qdio_errors(struct qdio_buffer *buf, unsigned int qdio_error,
2207 unsigned int qdio_error, 2207 unsigned int siga_error, const char *dbftext)
2208 unsigned int siga_error)
2209{ 2208{
2210 int rc = 0;
2211
2212 if (qdio_error || siga_error) { 2209 if (qdio_error || siga_error) {
2213 QETH_DBF_TEXT(trace, 2, "qdinerr"); 2210 QETH_DBF_TEXT(trace, 2, dbftext);
2214 QETH_DBF_TEXT(qerr, 2, "qdinerr"); 2211 QETH_DBF_TEXT(qerr, 2, dbftext);
2215 QETH_DBF_TEXT_(qerr, 2, " F15=%02X", 2212 QETH_DBF_TEXT_(qerr, 2, " F15=%02X",
2216 buf->buffer->element[15].flags & 0xff); 2213 buf->element[15].flags & 0xff);
2217 QETH_DBF_TEXT_(qerr, 2, " F14=%02X", 2214 QETH_DBF_TEXT_(qerr, 2, " F14=%02X",
2218 buf->buffer->element[14].flags & 0xff); 2215 buf->element[14].flags & 0xff);
2219 QETH_DBF_TEXT_(qerr, 2, " qerr=%X", qdio_error); 2216 QETH_DBF_TEXT_(qerr, 2, " qerr=%X", qdio_error);
2220 QETH_DBF_TEXT_(qerr, 2, " serr=%X", siga_error); 2217 QETH_DBF_TEXT_(qerr, 2, " serr=%X", siga_error);
2221 rc = 1; 2218 return 1;
2222 } 2219 }
2223 return rc; 2220 return 0;
2224} 2221}
2225 2222
2226static inline struct sk_buff * 2223static inline struct sk_buff *
@@ -2769,8 +2766,9 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status,
2769 for (i = first_element; i < (first_element + count); ++i) { 2766 for (i = first_element; i < (first_element + count); ++i) {
2770 index = i % QDIO_MAX_BUFFERS_PER_Q; 2767 index = i % QDIO_MAX_BUFFERS_PER_Q;
2771 buffer = &card->qdio.in_q->bufs[index]; 2768 buffer = &card->qdio.in_q->bufs[index];
2772 if (!((status == QDIO_STATUS_LOOK_FOR_ERROR) && 2769 if (!((status & QDIO_STATUS_LOOK_FOR_ERROR) &&
2773 qeth_check_for_inbound_error(buffer, qdio_err, siga_err))) 2770 qeth_check_qdio_errors(buffer->buffer,
2771 qdio_err, siga_err,"qinerr")))
2774 qeth_process_inbound_buffer(card, buffer, index); 2772 qeth_process_inbound_buffer(card, buffer, index);
2775 /* clear buffer and give back to hardware */ 2773 /* clear buffer and give back to hardware */
2776 qeth_put_buffer_pool_entry(card, buffer->pool_entry); 2774 qeth_put_buffer_pool_entry(card, buffer->pool_entry);
@@ -2785,12 +2783,13 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status,
2785static inline int 2783static inline int
2786qeth_handle_send_error(struct qeth_card *card, 2784qeth_handle_send_error(struct qeth_card *card,
2787 struct qeth_qdio_out_buffer *buffer, 2785 struct qeth_qdio_out_buffer *buffer,
2788 int qdio_err, int siga_err) 2786 unsigned int qdio_err, unsigned int siga_err)
2789{ 2787{
2790 int sbalf15 = buffer->buffer->element[15].flags & 0xff; 2788 int sbalf15 = buffer->buffer->element[15].flags & 0xff;
2791 int cc = siga_err & 3; 2789 int cc = siga_err & 3;
2792 2790
2793 QETH_DBF_TEXT(trace, 6, "hdsnderr"); 2791 QETH_DBF_TEXT(trace, 6, "hdsnderr");
2792 qeth_check_qdio_errors(buffer->buffer, qdio_err, siga_err, "qouterr");
2794 switch (cc) { 2793 switch (cc) {
2795 case 0: 2794 case 0:
2796 if (qdio_err){ 2795 if (qdio_err){
@@ -3047,7 +3046,8 @@ qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status,
3047 for(i = first_element; i < (first_element + count); ++i){ 3046 for(i = first_element; i < (first_element + count); ++i){
3048 buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]; 3047 buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q];
3049 /*we only handle the KICK_IT error by doing a recovery */ 3048 /*we only handle the KICK_IT error by doing a recovery */
3050 if (qeth_handle_send_error(card, buffer, qdio_error, siga_error) 3049 if (qeth_handle_send_error(card, buffer,
3050 qdio_error, siga_error)
3051 == QETH_SEND_ERROR_KICK_IT){ 3051 == QETH_SEND_ERROR_KICK_IT){
3052 netif_stop_queue(card->dev); 3052 netif_stop_queue(card->dev);
3053 qeth_schedule_recovery(card); 3053 qeth_schedule_recovery(card);
@@ -3289,7 +3289,6 @@ qeth_init_qdio_info(struct qeth_card *card)
3289 card->qdio.in_buf_pool.buf_count = card->qdio.init_pool.buf_count; 3289 card->qdio.in_buf_pool.buf_count = card->qdio.init_pool.buf_count;
3290 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list); 3290 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list);
3291 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list); 3291 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list);
3292 /* outbound */
3293} 3292}
3294 3293
3295static int 3294static int
@@ -3731,6 +3730,9 @@ qeth_verify_vlan_dev(struct net_device *dev, struct qeth_card *card)
3731 break; 3730 break;
3732 } 3731 }
3733 } 3732 }
3733 if (rc && !(VLAN_DEV_INFO(dev)->real_dev->priv == (void *)card))
3734 return 0;
3735
3734#endif 3736#endif
3735 return rc; 3737 return rc;
3736} 3738}
@@ -3807,10 +3809,8 @@ qeth_open(struct net_device *dev)
3807 card->data.state = CH_STATE_UP; 3809 card->data.state = CH_STATE_UP;
3808 card->state = CARD_STATE_UP; 3810 card->state = CARD_STATE_UP;
3809 3811
3810 if (!card->lan_online){ 3812 if (!card->lan_online && netif_carrier_ok(dev))
3811 if (netif_carrier_ok(dev)) 3813 netif_carrier_off(dev);
3812 netif_carrier_off(dev);
3813 }
3814 return 0; 3814 return 0;
3815} 3815}
3816 3816
@@ -4237,9 +4237,8 @@ qeth_do_send_packet_fast(struct qeth_card *card, struct qeth_qdio_out_q *queue,
4237 QETH_DBF_TEXT(trace, 6, "dosndpfa"); 4237 QETH_DBF_TEXT(trace, 6, "dosndpfa");
4238 4238
4239 /* spin until we get the queue ... */ 4239 /* spin until we get the queue ... */
4240 while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED, 4240 while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED,
4241 QETH_OUT_Q_LOCKED, 4241 QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED);
4242 &queue->state));
4243 /* ... now we've got the queue */ 4242 /* ... now we've got the queue */
4244 index = queue->next_buf_to_fill; 4243 index = queue->next_buf_to_fill;
4245 buffer = &queue->bufs[queue->next_buf_to_fill]; 4244 buffer = &queue->bufs[queue->next_buf_to_fill];
@@ -4293,9 +4292,8 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
4293 QETH_DBF_TEXT(trace, 6, "dosndpkt"); 4292 QETH_DBF_TEXT(trace, 6, "dosndpkt");
4294 4293
4295 /* spin until we get the queue ... */ 4294 /* spin until we get the queue ... */
4296 while (atomic_compare_and_swap(QETH_OUT_Q_UNLOCKED, 4295 while (atomic_cmpxchg(&queue->state, QETH_OUT_Q_UNLOCKED,
4297 QETH_OUT_Q_LOCKED, 4296 QETH_OUT_Q_LOCKED) != QETH_OUT_Q_UNLOCKED);
4298 &queue->state));
4299 start_index = queue->next_buf_to_fill; 4297 start_index = queue->next_buf_to_fill;
4300 buffer = &queue->bufs[queue->next_buf_to_fill]; 4298 buffer = &queue->bufs[queue->next_buf_to_fill];
4301 /* 4299 /*
@@ -5870,10 +5868,8 @@ qeth_add_multicast_ipv6(struct qeth_card *card)
5870 struct inet6_dev *in6_dev; 5868 struct inet6_dev *in6_dev;
5871 5869
5872 QETH_DBF_TEXT(trace,4,"chkmcv6"); 5870 QETH_DBF_TEXT(trace,4,"chkmcv6");
5873 if ((card->options.layer2 == 0) && 5871 if (!qeth_is_supported(card, IPA_IPV6))
5874 (!qeth_is_supported(card, IPA_IPV6)) )
5875 return ; 5872 return ;
5876
5877 in6_dev = in6_dev_get(card->dev); 5873 in6_dev = in6_dev_get(card->dev);
5878 if (in6_dev == NULL) 5874 if (in6_dev == NULL)
5879 return; 5875 return;
@@ -7936,8 +7932,8 @@ __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode)
7936 QETH_DBF_TEXT_(setup, 2, "6err%d", rc); 7932 QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
7937 goto out_remove; 7933 goto out_remove;
7938 } 7934 }
7939/*maybe it was set offline without ifconfig down 7935 netif_carrier_on(card->dev);
7940 * we can also use this state for recovery purposes*/ 7936
7941 qeth_set_allowed_threads(card, 0xffffffff, 0); 7937 qeth_set_allowed_threads(card, 0xffffffff, 0);
7942 if (recover_flag == CARD_STATE_RECOVER) 7938 if (recover_flag == CARD_STATE_RECOVER)
7943 qeth_start_again(card, recovery_mode); 7939 qeth_start_again(card, recovery_mode);
diff --git a/drivers/s390/net/qeth_mpc.c b/drivers/s390/net/qeth_mpc.c
index f0a080a9e515..5f8754addc14 100644
--- a/drivers/s390/net/qeth_mpc.c
+++ b/drivers/s390/net/qeth_mpc.c
@@ -11,7 +11,7 @@
11#include <asm/cio.h> 11#include <asm/cio.h>
12#include "qeth_mpc.h" 12#include "qeth_mpc.h"
13 13
14const char *VERSION_QETH_MPC_C = "$Revision: 1.12 $"; 14const char *VERSION_QETH_MPC_C = "$Revision: 1.13 $";
15 15
16unsigned char IDX_ACTIVATE_READ[]={ 16unsigned char IDX_ACTIVATE_READ[]={
17 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00, 17 0x00,0x00,0x80,0x00, 0x00,0x00,0x00,0x00,
diff --git a/drivers/s390/net/qeth_mpc.h b/drivers/s390/net/qeth_mpc.h
index 5f71486e708c..864cec5f6c62 100644
--- a/drivers/s390/net/qeth_mpc.h
+++ b/drivers/s390/net/qeth_mpc.h
@@ -14,14 +14,14 @@
14 14
15#include <asm/qeth.h> 15#include <asm/qeth.h>
16 16
17#define VERSION_QETH_MPC_H "$Revision: 1.44 $" 17#define VERSION_QETH_MPC_H "$Revision: 1.46 $"
18 18
19extern const char *VERSION_QETH_MPC_C; 19extern const char *VERSION_QETH_MPC_C;
20 20
21#define IPA_PDU_HEADER_SIZE 0x40 21#define IPA_PDU_HEADER_SIZE 0x40
22#define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer+0x0e) 22#define QETH_IPA_PDU_LEN_TOTAL(buffer) (buffer+0x0e)
23#define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer+0x26) 23#define QETH_IPA_PDU_LEN_PDU1(buffer) (buffer+0x26)
24#define QETH_IPA_PDU_LEN_PDU2(buffer) (buffer+0x2a) 24#define QETH_IPA_PDU_LEN_PDU2(buffer) (buffer+0x29)
25#define QETH_IPA_PDU_LEN_PDU3(buffer) (buffer+0x3a) 25#define QETH_IPA_PDU_LEN_PDU3(buffer) (buffer+0x3a)
26 26
27extern unsigned char IPA_PDU_HEADER[]; 27extern unsigned char IPA_PDU_HEADER[];
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c
index f2ccfea8fdb8..7bf35098831e 100644
--- a/drivers/s390/net/qeth_proc.c
+++ b/drivers/s390/net/qeth_proc.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_fs.c ($Revision: 1.13 $) 3 * linux/drivers/s390/net/qeth_fs.c ($Revision: 1.16 $)
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to procfs. 6 * This file contains code related to procfs.
@@ -21,7 +21,7 @@
21#include "qeth_mpc.h" 21#include "qeth_mpc.h"
22#include "qeth_fs.h" 22#include "qeth_fs.h"
23 23
24const char *VERSION_QETH_PROC_C = "$Revision: 1.13 $"; 24const char *VERSION_QETH_PROC_C = "$Revision: 1.16 $";
25 25
26/***** /proc/qeth *****/ 26/***** /proc/qeth *****/
27#define QETH_PROCFILE_NAME "qeth" 27#define QETH_PROCFILE_NAME "qeth"
@@ -30,30 +30,26 @@ static struct proc_dir_entry *qeth_procfile;
30static int 30static int
31qeth_procfile_seq_match(struct device *dev, void *data) 31qeth_procfile_seq_match(struct device *dev, void *data)
32{ 32{
33 return 1; 33 return(dev ? 1 : 0);
34} 34}
35 35
36static void * 36static void *
37qeth_procfile_seq_start(struct seq_file *s, loff_t *offset) 37qeth_procfile_seq_start(struct seq_file *s, loff_t *offset)
38{ 38{
39 struct device *dev; 39 struct device *dev = NULL;
40 loff_t nr; 40 loff_t nr = 0;
41 41
42 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem); 42 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
43 43 if (*offset == 0)
44 nr = *offset;
45 if (nr == 0)
46 return SEQ_START_TOKEN; 44 return SEQ_START_TOKEN;
47 45 while (1) {
48 dev = driver_find_device(&qeth_ccwgroup_driver.driver, NULL,
49 NULL, qeth_procfile_seq_match);
50
51 /* get card at pos *offset */
52 nr = *offset;
53 while (nr-- > 1 && dev)
54 dev = driver_find_device(&qeth_ccwgroup_driver.driver, dev, 46 dev = driver_find_device(&qeth_ccwgroup_driver.driver, dev,
55 NULL, qeth_procfile_seq_match); 47 NULL, qeth_procfile_seq_match);
56 return (void *) dev; 48 if (++nr == *offset)
49 break;
50 put_device(dev);
51 }
52 return dev;
57} 53}
58 54
59static void 55static void
@@ -66,19 +62,14 @@ static void *
66qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset) 62qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
67{ 63{
68 struct device *prev, *next; 64 struct device *prev, *next;
69 65
70 if (it == SEQ_START_TOKEN) { 66 if (it == SEQ_START_TOKEN)
71 next = driver_find_device(&qeth_ccwgroup_driver.driver, 67 prev = NULL;
72 NULL, NULL, qeth_procfile_seq_match); 68 else
73 if (next) 69 prev = (struct device *) it;
74 (*offset)++;
75 return (void *) next;
76 }
77 prev = (struct device *) it;
78 next = driver_find_device(&qeth_ccwgroup_driver.driver, 70 next = driver_find_device(&qeth_ccwgroup_driver.driver,
79 prev, NULL, qeth_procfile_seq_match); 71 prev, NULL, qeth_procfile_seq_match);
80 if (next) 72 (*offset)++;
81 (*offset)++;
82 return (void *) next; 73 return (void *) next;
83} 74}
84 75
@@ -87,7 +78,7 @@ qeth_get_router_str(struct qeth_card *card, int ipv)
87{ 78{
88 int routing_type = 0; 79 int routing_type = 0;
89 80
90 if (ipv == 4){ 81 if (ipv == 4) {
91 routing_type = card->options.route4.type; 82 routing_type = card->options.route4.type;
92 } else { 83 } else {
93#ifdef CONFIG_QETH_IPV6 84#ifdef CONFIG_QETH_IPV6
@@ -154,6 +145,7 @@ qeth_procfile_seq_show(struct seq_file *s, void *it)
154 card->qdio.in_buf_pool.buf_count); 145 card->qdio.in_buf_pool.buf_count);
155 else 146 else
156 seq_printf(s, " +++ LAN OFFLINE +++\n"); 147 seq_printf(s, " +++ LAN OFFLINE +++\n");
148 put_device(device);
157 } 149 }
158 return 0; 150 return 0;
159} 151}
@@ -184,51 +176,16 @@ static struct file_operations qeth_procfile_fops = {
184static struct proc_dir_entry *qeth_perf_procfile; 176static struct proc_dir_entry *qeth_perf_procfile;
185 177
186#ifdef CONFIG_QETH_PERF_STATS 178#ifdef CONFIG_QETH_PERF_STATS
187
188static void *
189qeth_perf_procfile_seq_start(struct seq_file *s, loff_t *offset)
190{
191 struct device *dev = NULL;
192 int nr;
193
194 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
195 /* get card at pos *offset */
196 dev = driver_find_device(&qeth_ccwgroup_driver.driver, NULL, NULL,
197 qeth_procfile_seq_match);
198
199 /* get card at pos *offset */
200 nr = *offset;
201 while (nr-- > 1 && dev)
202 dev = driver_find_device(&qeth_ccwgroup_driver.driver, dev,
203 NULL, qeth_procfile_seq_match);
204 return (void *) dev;
205}
206
207static void
208qeth_perf_procfile_seq_stop(struct seq_file *s, void* it)
209{
210 up_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
211}
212
213static void *
214qeth_perf_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
215{
216 struct device *prev, *next;
217
218 prev = (struct device *) it;
219 next = driver_find_device(&qeth_ccwgroup_driver.driver, prev,
220 NULL, qeth_procfile_seq_match);
221 if (next)
222 (*offset)++;
223 return (void *) next;
224}
225
226static int 179static int
227qeth_perf_procfile_seq_show(struct seq_file *s, void *it) 180qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
228{ 181{
229 struct device *device; 182 struct device *device;
230 struct qeth_card *card; 183 struct qeth_card *card;
231 184
185
186 if (it == SEQ_START_TOKEN)
187 return 0;
188
232 device = (struct device *) it; 189 device = (struct device *) it;
233 card = device->driver_data; 190 card = device->driver_data;
234 seq_printf(s, "For card with devnos %s/%s/%s (%s):\n", 191 seq_printf(s, "For card with devnos %s/%s/%s (%s):\n",
@@ -295,13 +252,14 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
295 card->perf_stats.outbound_do_qdio_time, 252 card->perf_stats.outbound_do_qdio_time,
296 card->perf_stats.outbound_do_qdio_cnt 253 card->perf_stats.outbound_do_qdio_cnt
297 ); 254 );
255 put_device(device);
298 return 0; 256 return 0;
299} 257}
300 258
301static struct seq_operations qeth_perf_procfile_seq_ops = { 259static struct seq_operations qeth_perf_procfile_seq_ops = {
302 .start = qeth_perf_procfile_seq_start, 260 .start = qeth_procfile_seq_start,
303 .stop = qeth_perf_procfile_seq_stop, 261 .stop = qeth_procfile_seq_stop,
304 .next = qeth_perf_procfile_seq_next, 262 .next = qeth_procfile_seq_next,
305 .show = qeth_perf_procfile_seq_show, 263 .show = qeth_perf_procfile_seq_show,
306}; 264};
307 265
@@ -324,93 +282,6 @@ static struct file_operations qeth_perf_procfile_fops = {
324#define qeth_perf_procfile_created 1 282#define qeth_perf_procfile_created 1
325#endif /* CONFIG_QETH_PERF_STATS */ 283#endif /* CONFIG_QETH_PERF_STATS */
326 284
327/***** /proc/qeth_ipa_takeover *****/
328#define QETH_IPATO_PROCFILE_NAME "qeth_ipa_takeover"
329static struct proc_dir_entry *qeth_ipato_procfile;
330
331static void *
332qeth_ipato_procfile_seq_start(struct seq_file *s, loff_t *offset)
333{
334 struct device *dev;
335 loff_t nr;
336
337 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
338 /* TODO: finish this */
339 /*
340 * maybe SEQ_SATRT_TOKEN can be returned for offset 0
341 * output driver settings then;
342 * else output setting for respective card
343 */
344
345 dev = driver_find_device(&qeth_ccwgroup_driver.driver, NULL, NULL,
346 qeth_procfile_seq_match);
347
348 /* get card at pos *offset */
349 nr = *offset;
350 while (nr-- > 1 && dev)
351 dev = driver_find_device(&qeth_ccwgroup_driver.driver, dev,
352 NULL, qeth_procfile_seq_match);
353 return (void *) dev;
354}
355
356static void
357qeth_ipato_procfile_seq_stop(struct seq_file *s, void* it)
358{
359 up_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
360}
361
362static void *
363qeth_ipato_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
364{
365 struct device *prev, *next;
366
367 prev = (struct device *) it;
368 next = driver_find_device(&qeth_ccwgroup_driver.driver, prev,
369 NULL, qeth_procfile_seq_match);
370 if (next)
371 (*offset)++;
372 return (void *) next;
373}
374
375static int
376qeth_ipato_procfile_seq_show(struct seq_file *s, void *it)
377{
378 struct device *device;
379 struct qeth_card *card;
380
381 /* TODO: finish this */
382 /*
383 * maybe SEQ_SATRT_TOKEN can be returned for offset 0
384 * output driver settings then;
385 * else output setting for respective card
386 */
387 device = (struct device *) it;
388 card = device->driver_data;
389
390 return 0;
391}
392
393static struct seq_operations qeth_ipato_procfile_seq_ops = {
394 .start = qeth_ipato_procfile_seq_start,
395 .stop = qeth_ipato_procfile_seq_stop,
396 .next = qeth_ipato_procfile_seq_next,
397 .show = qeth_ipato_procfile_seq_show,
398};
399
400static int
401qeth_ipato_procfile_open(struct inode *inode, struct file *file)
402{
403 return seq_open(file, &qeth_ipato_procfile_seq_ops);
404}
405
406static struct file_operations qeth_ipato_procfile_fops = {
407 .owner = THIS_MODULE,
408 .open = qeth_ipato_procfile_open,
409 .read = seq_read,
410 .llseek = seq_lseek,
411 .release = seq_release,
412};
413
414int __init 285int __init
415qeth_create_procfs_entries(void) 286qeth_create_procfs_entries(void)
416{ 287{
@@ -426,13 +297,7 @@ qeth_create_procfs_entries(void)
426 qeth_perf_procfile->proc_fops = &qeth_perf_procfile_fops; 297 qeth_perf_procfile->proc_fops = &qeth_perf_procfile_fops;
427#endif /* CONFIG_QETH_PERF_STATS */ 298#endif /* CONFIG_QETH_PERF_STATS */
428 299
429 qeth_ipato_procfile = create_proc_entry(QETH_IPATO_PROCFILE_NAME,
430 S_IFREG | 0444, NULL);
431 if (qeth_ipato_procfile)
432 qeth_ipato_procfile->proc_fops = &qeth_ipato_procfile_fops;
433
434 if (qeth_procfile && 300 if (qeth_procfile &&
435 qeth_ipato_procfile &&
436 qeth_perf_procfile_created) 301 qeth_perf_procfile_created)
437 return 0; 302 return 0;
438 else 303 else
@@ -446,62 +311,5 @@ qeth_remove_procfs_entries(void)
446 remove_proc_entry(QETH_PROCFILE_NAME, NULL); 311 remove_proc_entry(QETH_PROCFILE_NAME, NULL);
447 if (qeth_perf_procfile) 312 if (qeth_perf_procfile)
448 remove_proc_entry(QETH_PERF_PROCFILE_NAME, NULL); 313 remove_proc_entry(QETH_PERF_PROCFILE_NAME, NULL);
449 if (qeth_ipato_procfile)
450 remove_proc_entry(QETH_IPATO_PROCFILE_NAME, NULL);
451} 314}
452 315
453
454/* ONLY FOR DEVELOPMENT! -> make it as module */
455/*
456static void
457qeth_create_sysfs_entries(void)
458{
459 struct device *dev;
460
461 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
462
463 list_for_each_entry(dev, &qeth_ccwgroup_driver.driver.devices,
464 driver_list)
465 qeth_create_device_attributes(dev);
466
467 up_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
468}
469
470static void
471qeth_remove_sysfs_entries(void)
472{
473 struct device *dev;
474
475 down_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
476
477 list_for_each_entry(dev, &qeth_ccwgroup_driver.driver.devices,
478 driver_list)
479 qeth_remove_device_attributes(dev);
480
481 up_read(&qeth_ccwgroup_driver.driver.bus->subsys.rwsem);
482}
483
484static int __init
485qeth_fs_init(void)
486{
487 printk(KERN_INFO "qeth_fs_init\n");
488 qeth_create_procfs_entries();
489 qeth_create_sysfs_entries();
490
491 return 0;
492}
493
494static void __exit
495qeth_fs_exit(void)
496{
497 printk(KERN_INFO "qeth_fs_exit\n");
498 qeth_remove_procfs_entries();
499 qeth_remove_sysfs_entries();
500}
501
502
503module_init(qeth_fs_init);
504module_exit(qeth_fs_exit);
505
506MODULE_LICENSE("GPL");
507*/
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index ddd6019ba092..0ea185f70f75 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * 2 *
3 * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.58 $) 3 * linux/drivers/s390/net/qeth_sys.c ($Revision: 1.60 $)
4 * 4 *
5 * Linux on zSeries OSA Express and HiperSockets support 5 * Linux on zSeries OSA Express and HiperSockets support
6 * This file contains code related to sysfs. 6 * This file contains code related to sysfs.
@@ -20,7 +20,7 @@
20#include "qeth_mpc.h" 20#include "qeth_mpc.h"
21#include "qeth_fs.h" 21#include "qeth_fs.h"
22 22
23const char *VERSION_QETH_SYS_C = "$Revision: 1.58 $"; 23const char *VERSION_QETH_SYS_C = "$Revision: 1.60 $";
24 24
25/*****************************************************************************/ 25/*****************************************************************************/
26/* */ 26/* */
@@ -160,7 +160,7 @@ qeth_dev_portname_store(struct device *dev, struct device_attribute *attr, const
160 return -EPERM; 160 return -EPERM;
161 161
162 tmp = strsep((char **) &buf, "\n"); 162 tmp = strsep((char **) &buf, "\n");
163 if ((strlen(tmp) > 8) || (strlen(tmp) < 2)) 163 if ((strlen(tmp) > 8) || (strlen(tmp) == 0))
164 return -EINVAL; 164 return -EINVAL;
165 165
166 card->info.portname[0] = strlen(tmp); 166 card->info.portname[0] = strlen(tmp);
diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h
index e245af3c4cbd..3c50b6f24f51 100644
--- a/drivers/s390/net/qeth_tso.h
+++ b/drivers/s390/net/qeth_tso.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.7 $) 2 * linux/drivers/s390/net/qeth_tso.h ($Revision: 1.8 $)
3 * 3 *
4 * Header file for qeth TCP Segmentation Offload support. 4 * Header file for qeth TCP Segmentation Offload support.
5 * 5 *
@@ -7,7 +7,7 @@
7 * 7 *
8 * Author(s): Frank Pavlic <fpavlic@de.ibm.com> 8 * Author(s): Frank Pavlic <fpavlic@de.ibm.com>
9 * 9 *
10 * $Revision: 1.7 $ $Date: 2005/05/04 20:19:18 $ 10 * $Revision: 1.8 $ $Date: 2005/05/04 20:19:18 $
11 * 11 *
12 */ 12 */
13#ifndef __QETH_TSO_H__ 13#ifndef __QETH_TSO_H__
diff --git a/drivers/s390/s390_rdev.c b/drivers/s390/s390_rdev.c
new file mode 100644
index 000000000000..566cc3d185b6
--- /dev/null
+++ b/drivers/s390/s390_rdev.c
@@ -0,0 +1,53 @@
1/*
2 * drivers/s390/s390_rdev.c
3 * s390 root device
4 * $Revision: 1.2 $
5 *
6 * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
7 * IBM Corporation
8 * Author(s): Cornelia Huck (cohuck@de.ibm.com)
9 * Carsten Otte (cotte@de.ibm.com)
10 */
11
12#include <linux/slab.h>
13#include <linux/err.h>
14#include <linux/device.h>
15#include <asm/s390_rdev.h>
16
17static void
18s390_root_dev_release(struct device *dev)
19{
20 kfree(dev);
21}
22
23struct device *
24s390_root_dev_register(const char *name)
25{
26 struct device *dev;
27 int ret;
28
29 if (!strlen(name))
30 return ERR_PTR(-EINVAL);
31 dev = kmalloc(sizeof(struct device), GFP_KERNEL);
32 if (!dev)
33 return ERR_PTR(-ENOMEM);
34 memset(dev, 0, sizeof(struct device));
35 strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
36 dev->release = s390_root_dev_release;
37 ret = device_register(dev);
38 if (ret) {
39 kfree(dev);
40 return ERR_PTR(ret);
41 }
42 return dev;
43}
44
45void
46s390_root_dev_unregister(struct device *dev)
47{
48 if (dev)
49 device_unregister(dev);
50}
51
52EXPORT_SYMBOL(s390_root_dev_register);
53EXPORT_SYMBOL(s390_root_dev_unregister);
diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c
index 4191fd9d4d11..3bf466603512 100644
--- a/drivers/s390/s390mach.c
+++ b/drivers/s390/s390mach.c
@@ -23,7 +23,7 @@
23 23
24static struct semaphore m_sem; 24static struct semaphore m_sem;
25 25
26extern int css_process_crw(int); 26extern int css_process_crw(int, int);
27extern int chsc_process_crw(void); 27extern int chsc_process_crw(void);
28extern int chp_process_crw(int, int); 28extern int chp_process_crw(int, int);
29extern void css_reiterate_subchannels(void); 29extern void css_reiterate_subchannels(void);
@@ -49,9 +49,10 @@ s390_handle_damage(char *msg)
49static int 49static int
50s390_collect_crw_info(void *param) 50s390_collect_crw_info(void *param)
51{ 51{
52 struct crw crw; 52 struct crw crw[2];
53 int ccode, ret, slow; 53 int ccode, ret, slow;
54 struct semaphore *sem; 54 struct semaphore *sem;
55 unsigned int chain;
55 56
56 sem = (struct semaphore *)param; 57 sem = (struct semaphore *)param;
57 /* Set a nice name. */ 58 /* Set a nice name. */
@@ -59,25 +60,50 @@ s390_collect_crw_info(void *param)
59repeat: 60repeat:
60 down_interruptible(sem); 61 down_interruptible(sem);
61 slow = 0; 62 slow = 0;
63 chain = 0;
62 while (1) { 64 while (1) {
63 ccode = stcrw(&crw); 65 if (unlikely(chain > 1)) {
66 struct crw tmp_crw;
67
68 printk(KERN_WARNING"%s: Code does not support more "
69 "than two chained crws; please report to "
70 "linux390@de.ibm.com!\n", __FUNCTION__);
71 ccode = stcrw(&tmp_crw);
72 printk(KERN_WARNING"%s: crw reports slct=%d, oflw=%d, "
73 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
74 __FUNCTION__, tmp_crw.slct, tmp_crw.oflw,
75 tmp_crw.chn, tmp_crw.rsc, tmp_crw.anc,
76 tmp_crw.erc, tmp_crw.rsid);
77 printk(KERN_WARNING"%s: This was crw number %x in the "
78 "chain\n", __FUNCTION__, chain);
79 if (ccode != 0)
80 break;
81 chain = tmp_crw.chn ? chain + 1 : 0;
82 continue;
83 }
84 ccode = stcrw(&crw[chain]);
64 if (ccode != 0) 85 if (ccode != 0)
65 break; 86 break;
66 DBG(KERN_DEBUG "crw_info : CRW reports slct=%d, oflw=%d, " 87 DBG(KERN_DEBUG "crw_info : CRW reports slct=%d, oflw=%d, "
67 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n", 88 "chn=%d, rsc=%X, anc=%d, erc=%X, rsid=%X\n",
68 crw.slct, crw.oflw, crw.chn, crw.rsc, crw.anc, 89 crw[chain].slct, crw[chain].oflw, crw[chain].chn,
69 crw.erc, crw.rsid); 90 crw[chain].rsc, crw[chain].anc, crw[chain].erc,
91 crw[chain].rsid);
70 /* Check for overflows. */ 92 /* Check for overflows. */
71 if (crw.oflw) { 93 if (crw[chain].oflw) {
72 pr_debug("%s: crw overflow detected!\n", __FUNCTION__); 94 pr_debug("%s: crw overflow detected!\n", __FUNCTION__);
73 css_reiterate_subchannels(); 95 css_reiterate_subchannels();
96 chain = 0;
74 slow = 1; 97 slow = 1;
75 continue; 98 continue;
76 } 99 }
77 switch (crw.rsc) { 100 switch (crw[chain].rsc) {
78 case CRW_RSC_SCH: 101 case CRW_RSC_SCH:
79 pr_debug("source is subchannel %04X\n", crw.rsid); 102 if (crw[0].chn && !chain)
80 ret = css_process_crw (crw.rsid); 103 break;
104 pr_debug("source is subchannel %04X\n", crw[0].rsid);
105 ret = css_process_crw (crw[0].rsid,
106 chain ? crw[1].rsid : 0);
81 if (ret == -EAGAIN) 107 if (ret == -EAGAIN)
82 slow = 1; 108 slow = 1;
83 break; 109 break;
@@ -85,18 +111,18 @@ repeat:
85 pr_debug("source is monitoring facility\n"); 111 pr_debug("source is monitoring facility\n");
86 break; 112 break;
87 case CRW_RSC_CPATH: 113 case CRW_RSC_CPATH:
88 pr_debug("source is channel path %02X\n", crw.rsid); 114 pr_debug("source is channel path %02X\n", crw[0].rsid);
89 switch (crw.erc) { 115 switch (crw[0].erc) {
90 case CRW_ERC_IPARM: /* Path has come. */ 116 case CRW_ERC_IPARM: /* Path has come. */
91 ret = chp_process_crw(crw.rsid, 1); 117 ret = chp_process_crw(crw[0].rsid, 1);
92 break; 118 break;
93 case CRW_ERC_PERRI: /* Path has gone. */ 119 case CRW_ERC_PERRI: /* Path has gone. */
94 case CRW_ERC_PERRN: 120 case CRW_ERC_PERRN:
95 ret = chp_process_crw(crw.rsid, 0); 121 ret = chp_process_crw(crw[0].rsid, 0);
96 break; 122 break;
97 default: 123 default:
98 pr_debug("Don't know how to handle erc=%x\n", 124 pr_debug("Don't know how to handle erc=%x\n",
99 crw.erc); 125 crw[0].erc);
100 ret = 0; 126 ret = 0;
101 } 127 }
102 if (ret == -EAGAIN) 128 if (ret == -EAGAIN)
@@ -115,6 +141,8 @@ repeat:
115 pr_debug("unknown source\n"); 141 pr_debug("unknown source\n");
116 break; 142 break;
117 } 143 }
144 /* chain is always 0 or 1 here. */
145 chain = crw[chain].chn ? chain + 1 : 0;
118 } 146 }
119 if (slow) 147 if (slow)
120 queue_work(slow_path_wq, &slow_path_work); 148 queue_work(slow_path_wq, &slow_path_work);
@@ -218,7 +246,7 @@ s390_revalidate_registers(struct mci *mci)
218 */ 246 */
219 kill_task = 1; 247 kill_task = 1;
220 248
221#ifndef __s390x__ 249#ifndef CONFIG_64BIT
222 asm volatile("ld 0,0(%0)\n" 250 asm volatile("ld 0,0(%0)\n"
223 "ld 2,8(%0)\n" 251 "ld 2,8(%0)\n"
224 "ld 4,16(%0)\n" 252 "ld 4,16(%0)\n"
@@ -227,7 +255,7 @@ s390_revalidate_registers(struct mci *mci)
227#endif 255#endif
228 256
229 if (MACHINE_HAS_IEEE) { 257 if (MACHINE_HAS_IEEE) {
230#ifdef __s390x__ 258#ifdef CONFIG_64BIT
231 fpt_save_area = &S390_lowcore.floating_pt_save_area; 259 fpt_save_area = &S390_lowcore.floating_pt_save_area;
232 fpt_creg_save_area = &S390_lowcore.fpt_creg_save_area; 260 fpt_creg_save_area = &S390_lowcore.fpt_creg_save_area;
233#else 261#else
@@ -286,7 +314,7 @@ s390_revalidate_registers(struct mci *mci)
286 */ 314 */
287 s390_handle_damage("invalid control registers."); 315 s390_handle_damage("invalid control registers.");
288 else 316 else
289#ifdef __s390x__ 317#ifdef CONFIG_64BIT
290 asm volatile("lctlg 0,15,0(%0)" 318 asm volatile("lctlg 0,15,0(%0)"
291 : : "a" (&S390_lowcore.cregs_save_area)); 319 : : "a" (&S390_lowcore.cregs_save_area));
292#else 320#else
@@ -299,7 +327,7 @@ s390_revalidate_registers(struct mci *mci)
299 * can't write something sensible into that register. 327 * can't write something sensible into that register.
300 */ 328 */
301 329
302#ifdef __s390x__ 330#ifdef CONFIG_64BIT
303 /* 331 /*
304 * See if we can revalidate the TOD programmable register with its 332 * See if we can revalidate the TOD programmable register with its
305 * old contents (should be zero) otherwise set it to zero. 333 * old contents (should be zero) otherwise set it to zero.
@@ -356,7 +384,7 @@ s390_do_machine_check(struct pt_regs *regs)
356 if (mci->b) { 384 if (mci->b) {
357 /* Processing backup -> verify if we can survive this */ 385 /* Processing backup -> verify if we can survive this */
358 u64 z_mcic, o_mcic, t_mcic; 386 u64 z_mcic, o_mcic, t_mcic;
359#ifdef __s390x__ 387#ifdef CONFIG_64BIT
360 z_mcic = (1ULL<<63 | 1ULL<<59 | 1ULL<<29); 388 z_mcic = (1ULL<<63 | 1ULL<<59 | 1ULL<<29);
361 o_mcic = (1ULL<<43 | 1ULL<<42 | 1ULL<<41 | 1ULL<<40 | 389 o_mcic = (1ULL<<43 | 1ULL<<42 | 1ULL<<41 | 1ULL<<40 |
362 1ULL<<36 | 1ULL<<35 | 1ULL<<34 | 1ULL<<32 | 390 1ULL<<36 | 1ULL<<35 | 1ULL<<34 | 1ULL<<32 |
diff --git a/drivers/s390/sysinfo.c b/drivers/s390/sysinfo.c
index 87c2db1bd4f5..66da840c9316 100644
--- a/drivers/s390/sysinfo.c
+++ b/drivers/s390/sysinfo.c
@@ -106,7 +106,7 @@ static inline int stsi (void *sysinfo,
106{ 106{
107 int cc, retv; 107 int cc, retv;
108 108
109#ifndef CONFIG_ARCH_S390X 109#ifndef CONFIG_64BIT
110 __asm__ __volatile__ ( "lr\t0,%2\n" 110 __asm__ __volatile__ ( "lr\t0,%2\n"
111 "\tlr\t1,%3\n" 111 "\tlr\t1,%3\n"
112 "\tstsi\t0(%4)\n" 112 "\tstsi\t0(%4)\n"
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c
index c12c5046e2fa..14631ac11bc7 100644
--- a/drivers/sbus/char/jsflash.c
+++ b/drivers/sbus/char/jsflash.c
@@ -249,11 +249,11 @@ static loff_t jsf_lseek(struct file * file, loff_t offset, int orig)
249/* 249/*
250 * OS SIMM Cannot be read in other size but a 32bits word. 250 * OS SIMM Cannot be read in other size but a 32bits word.
251 */ 251 */
252static ssize_t jsf_read(struct file * file, char * buf, 252static ssize_t jsf_read(struct file * file, char __user * buf,
253 size_t togo, loff_t *ppos) 253 size_t togo, loff_t *ppos)
254{ 254{
255 unsigned long p = *ppos; 255 unsigned long p = *ppos;
256 char *tmp = buf; 256 char __user *tmp = buf;
257 257
258 union byte4 { 258 union byte4 {
259 char s[4]; 259 char s[4];
@@ -305,7 +305,7 @@ static ssize_t jsf_read(struct file * file, char * buf,
305 return tmp-buf; 305 return tmp-buf;
306} 306}
307 307
308static ssize_t jsf_write(struct file * file, const char * buf, 308static ssize_t jsf_write(struct file * file, const char __user * buf,
309 size_t count, loff_t *ppos) 309 size_t count, loff_t *ppos)
310{ 310{
311 return -ENOSPC; 311 return -ENOSPC;
@@ -356,10 +356,10 @@ static int jsf_ioctl_erase(unsigned long arg)
356 * Program a block of flash. 356 * Program a block of flash.
357 * Very simple because we can do it byte by byte anyway. 357 * Very simple because we can do it byte by byte anyway.
358 */ 358 */
359static int jsf_ioctl_program(unsigned long arg) 359static int jsf_ioctl_program(void __user *arg)
360{ 360{
361 struct jsflash_program_arg abuf; 361 struct jsflash_program_arg abuf;
362 char *uptr; 362 char __user *uptr;
363 unsigned long p; 363 unsigned long p;
364 unsigned int togo; 364 unsigned int togo;
365 union { 365 union {
@@ -367,13 +367,13 @@ static int jsf_ioctl_program(unsigned long arg)
367 char s[4]; 367 char s[4];
368 } b; 368 } b;
369 369
370 if (copy_from_user(&abuf, (char *)arg, JSFPRGSZ)) 370 if (copy_from_user(&abuf, arg, JSFPRGSZ))
371 return -EFAULT; 371 return -EFAULT;
372 p = abuf.off; 372 p = abuf.off;
373 togo = abuf.size; 373 togo = abuf.size;
374 if ((togo & 3) || (p & 3)) return -EINVAL; 374 if ((togo & 3) || (p & 3)) return -EINVAL;
375 375
376 uptr = (char *) (unsigned long) abuf.data; 376 uptr = (char __user *) (unsigned long) abuf.data;
377 while (togo != 0) { 377 while (togo != 0) {
378 togo -= 4; 378 togo -= 4;
379 if (copy_from_user(&b.s[0], uptr, 4)) 379 if (copy_from_user(&b.s[0], uptr, 4))
@@ -390,19 +390,20 @@ static int jsf_ioctl(struct inode *inode, struct file *f, unsigned int cmd,
390 unsigned long arg) 390 unsigned long arg)
391{ 391{
392 int error = -ENOTTY; 392 int error = -ENOTTY;
393 void __user *argp = (void __user *)arg;
393 394
394 if (!capable(CAP_SYS_ADMIN)) 395 if (!capable(CAP_SYS_ADMIN))
395 return -EPERM; 396 return -EPERM;
396 switch (cmd) { 397 switch (cmd) {
397 case JSFLASH_IDENT: 398 case JSFLASH_IDENT:
398 if (copy_to_user((void *)arg, &jsf0.id, JSFIDSZ)) 399 if (copy_to_user(argp, &jsf0.id, JSFIDSZ))
399 return -EFAULT; 400 return -EFAULT;
400 break; 401 break;
401 case JSFLASH_ERASE: 402 case JSFLASH_ERASE:
402 error = jsf_ioctl_erase(arg); 403 error = jsf_ioctl_erase(arg);
403 break; 404 break;
404 case JSFLASH_PROGRAM: 405 case JSFLASH_PROGRAM:
405 error = jsf_ioctl_program(arg); 406 error = jsf_ioctl_program(argp);
406 break; 407 break;
407 } 408 }
408 409
diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c
index 858cc683f85c..e2d9a7c85427 100644
--- a/drivers/sbus/char/uctrl.c
+++ b/drivers/sbus/char/uctrl.c
@@ -309,7 +309,7 @@ static void uctrl_do_txn(struct uctrl_txn *txn)
309 } 309 }
310} 310}
311 311
312void uctrl_get_event_status() 312void uctrl_get_event_status(void)
313{ 313{
314 struct uctrl_driver *driver = &drv; 314 struct uctrl_driver *driver = &drv;
315 struct uctrl_txn txn; 315 struct uctrl_txn txn;
@@ -318,7 +318,7 @@ void uctrl_get_event_status()
318 txn.opcode = READ_EVENT_STATUS; 318 txn.opcode = READ_EVENT_STATUS;
319 txn.inbits = 0; 319 txn.inbits = 0;
320 txn.outbits = 2; 320 txn.outbits = 2;
321 txn.inbuf = 0; 321 txn.inbuf = NULL;
322 txn.outbuf = outbits; 322 txn.outbuf = outbits;
323 323
324 uctrl_do_txn(&txn); 324 uctrl_do_txn(&txn);
@@ -329,7 +329,7 @@ void uctrl_get_event_status()
329 dprintk(("ev is %x\n", driver->status.event_status)); 329 dprintk(("ev is %x\n", driver->status.event_status));
330} 330}
331 331
332void uctrl_get_external_status() 332void uctrl_get_external_status(void)
333{ 333{
334 struct uctrl_driver *driver = &drv; 334 struct uctrl_driver *driver = &drv;
335 struct uctrl_txn txn; 335 struct uctrl_txn txn;
@@ -339,7 +339,7 @@ void uctrl_get_external_status()
339 txn.opcode = READ_EXTERNAL_STATUS; 339 txn.opcode = READ_EXTERNAL_STATUS;
340 txn.inbits = 0; 340 txn.inbits = 0;
341 txn.outbits = 2; 341 txn.outbits = 2;
342 txn.inbuf = 0; 342 txn.inbuf = NULL;
343 txn.outbuf = outbits; 343 txn.outbuf = outbits;
344 344
345 uctrl_do_txn(&txn); 345 uctrl_do_txn(&txn);
@@ -414,7 +414,7 @@ static void __exit ts102_uctrl_cleanup(void)
414 if (driver->irq) 414 if (driver->irq)
415 free_irq(driver->irq, driver); 415 free_irq(driver->irq, driver);
416 if (driver->regs) 416 if (driver->regs)
417 driver->regs = 0; 417 driver->regs = NULL;
418} 418}
419 419
420module_init(ts102_uctrl_init); 420module_init(ts102_uctrl_init);
diff --git a/drivers/sbus/char/vfc.h b/drivers/sbus/char/vfc.h
index a7782e7da42e..8045cd5e7cb3 100644
--- a/drivers/sbus/char/vfc.h
+++ b/drivers/sbus/char/vfc.h
@@ -125,7 +125,7 @@ struct vfc_regs {
125 125
126 126
127struct vfc_dev { 127struct vfc_dev {
128 volatile struct vfc_regs *regs; 128 volatile struct vfc_regs __iomem *regs;
129 struct vfc_regs *phys_regs; 129 struct vfc_regs *phys_regs;
130 unsigned int control_reg; 130 unsigned int control_reg;
131 struct semaphore device_lock_sem; 131 struct semaphore device_lock_sem;
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c
index 7a103698fa3c..dfdd6be551f3 100644
--- a/drivers/sbus/char/vfc_dev.c
+++ b/drivers/sbus/char/vfc_dev.c
@@ -149,7 +149,7 @@ int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev, int instance)
149 } 149 }
150 printk("Initializing vfc%d\n",instance); 150 printk("Initializing vfc%d\n",instance);
151 dev->regs = NULL; 151 dev->regs = NULL;
152 dev->regs = (volatile struct vfc_regs *) 152 dev->regs = (volatile struct vfc_regs __iomem *)
153 sbus_ioremap(&sdev->resource[0], 0, 153 sbus_ioremap(&sdev->resource[0], 0,
154 sizeof(struct vfc_regs), vfcstr); 154 sizeof(struct vfc_regs), vfcstr);
155 dev->which_io = sdev->reg_addrs[0].which_io; 155 dev->which_io = sdev->reg_addrs[0].which_io;
@@ -319,7 +319,7 @@ int vfc_capture_poll(struct vfc_dev *dev)
319 int timeout = 1000; 319 int timeout = 1000;
320 320
321 while (!timeout--) { 321 while (!timeout--) {
322 if (dev->regs->control & VFC_STATUS_CAPTURE) 322 if (sbus_readl(&dev->regs->control) & VFC_STATUS_CAPTURE)
323 break; 323 break;
324 vfc_i2c_delay_no_busy(dev, 100); 324 vfc_i2c_delay_no_busy(dev, 100);
325 } 325 }
@@ -718,7 +718,7 @@ static void deinit_vfc_device(struct vfc_dev *dev)
718 if(dev == NULL) 718 if(dev == NULL)
719 return; 719 return;
720 devfs_remove("vfc/%d", dev->instance); 720 devfs_remove("vfc/%d", dev->instance);
721 sbus_iounmap((unsigned long)dev->regs, sizeof(struct vfc_regs)); 721 sbus_iounmap(dev->regs, sizeof(struct vfc_regs));
722 kfree(dev); 722 kfree(dev);
723} 723}
724 724
diff --git a/drivers/scsi/.gitignore b/drivers/scsi/.gitignore
new file mode 100644
index 000000000000..b385af314356
--- /dev/null
+++ b/drivers/scsi/.gitignore
@@ -0,0 +1,3 @@
153c700_d.h
253c7xx_d.h
353c7xx_u.h
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index e7ad269041a4..4ce7438608ec 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -857,7 +857,7 @@ process_extended_message(struct Scsi_Host *host,
857 printk(KERN_INFO "scsi%d (%d:%d): Unexpected message %s: ", 857 printk(KERN_INFO "scsi%d (%d:%d): Unexpected message %s: ",
858 host->host_no, pun, lun, 858 host->host_no, pun, lun,
859 NCR_700_phase[(dsps & 0xf00) >> 8]); 859 NCR_700_phase[(dsps & 0xf00) >> 8]);
860 scsi_print_msg(hostdata->msgin); 860 spi_print_msg(hostdata->msgin);
861 printk("\n"); 861 printk("\n");
862 /* just reject it */ 862 /* just reject it */
863 hostdata->msgout[0] = A_REJECT_MSG; 863 hostdata->msgout[0] = A_REJECT_MSG;
@@ -887,7 +887,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
887#ifdef NCR_700_DEBUG 887#ifdef NCR_700_DEBUG
888 printk("scsi%d (%d:%d): message %s: ", host->host_no, pun, lun, 888 printk("scsi%d (%d:%d): message %s: ", host->host_no, pun, lun,
889 NCR_700_phase[(dsps & 0xf00) >> 8]); 889 NCR_700_phase[(dsps & 0xf00) >> 8]);
890 scsi_print_msg(hostdata->msgin); 890 spi_print_msg(hostdata->msgin);
891 printk("\n"); 891 printk("\n");
892#endif 892#endif
893 893
@@ -939,7 +939,7 @@ process_message(struct Scsi_Host *host, struct NCR_700_Host_Parameters *hostdata
939 host->host_no, pun, lun, 939 host->host_no, pun, lun,
940 NCR_700_phase[(dsps & 0xf00) >> 8]); 940 NCR_700_phase[(dsps & 0xf00) >> 8]);
941 941
942 scsi_print_msg(hostdata->msgin); 942 spi_print_msg(hostdata->msgin);
943 printk("\n"); 943 printk("\n");
944 /* just reject it */ 944 /* just reject it */
945 hostdata->msgout[0] = A_REJECT_MSG; 945 hostdata->msgout[0] = A_REJECT_MSG;
diff --git a/drivers/scsi/53c700.h b/drivers/scsi/53c700.h
index 362d78483d09..a8c83bb03630 100644
--- a/drivers/scsi/53c700.h
+++ b/drivers/scsi/53c700.h
@@ -238,21 +238,23 @@ struct NCR_700_Host_Parameters {
238#ifdef CONFIG_53C700_LE_ON_BE 238#ifdef CONFIG_53C700_LE_ON_BE
239#define bE (hostdata->force_le_on_be ? 0 : 3) 239#define bE (hostdata->force_le_on_be ? 0 : 3)
240#define bSWAP (hostdata->force_le_on_be) 240#define bSWAP (hostdata->force_le_on_be)
241/* This is terrible, but there's no raw version of ioread32. That means 241#define bEBus (!hostdata->force_le_on_be)
242 * that on a be board we swap twice (once in ioread32 and once again to
243 * get the value correct) */
244#define bS_to_io(x) ((hostdata->force_le_on_be) ? (x) : cpu_to_le32(x))
245#elif defined(__BIG_ENDIAN) 242#elif defined(__BIG_ENDIAN)
246#define bE 3 243#define bE 3
247#define bSWAP 0 244#define bSWAP 0
248#define bS_to_io(x) (x)
249#elif defined(__LITTLE_ENDIAN) 245#elif defined(__LITTLE_ENDIAN)
250#define bE 0 246#define bE 0
251#define bSWAP 0 247#define bSWAP 0
252#define bS_to_io(x) (x)
253#else 248#else
254#error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined, did you include byteorder.h?" 249#error "__BIG_ENDIAN or __LITTLE_ENDIAN must be defined, did you include byteorder.h?"
255#endif 250#endif
251#ifndef bEBus
252#ifdef CONFIG_53C700_BE_BUS
253#define bEBus 1
254#else
255#define bEBus 0
256#endif
257#endif
256#define bS_to_cpu(x) (bSWAP ? le32_to_cpu(x) : (x)) 258#define bS_to_cpu(x) (bSWAP ? le32_to_cpu(x) : (x))
257#define bS_to_host(x) (bSWAP ? cpu_to_le32(x) : (x)) 259#define bS_to_host(x) (bSWAP ? cpu_to_le32(x) : (x))
258 260
@@ -466,14 +468,15 @@ NCR_700_readl(struct Scsi_Host *host, __u32 reg)
466{ 468{
467 const struct NCR_700_Host_Parameters *hostdata 469 const struct NCR_700_Host_Parameters *hostdata
468 = (struct NCR_700_Host_Parameters *)host->hostdata[0]; 470 = (struct NCR_700_Host_Parameters *)host->hostdata[0];
469 __u32 value = ioread32(hostdata->base + reg); 471 __u32 value = bEBus ? ioread32be(hostdata->base + reg) :
472 ioread32(hostdata->base + reg);
470#if 1 473#if 1
471 /* sanity check the register */ 474 /* sanity check the register */
472 if((reg & 0x3) != 0) 475 if((reg & 0x3) != 0)
473 BUG(); 476 BUG();
474#endif 477#endif
475 478
476 return bS_to_io(value); 479 return value;
477} 480}
478 481
479static inline void 482static inline void
@@ -497,7 +500,8 @@ NCR_700_writel(__u32 value, struct Scsi_Host *host, __u32 reg)
497 BUG(); 500 BUG();
498#endif 501#endif
499 502
500 iowrite32(bS_to_io(value), hostdata->base + reg); 503 bEBus ? iowrite32be(value, hostdata->base + reg):
504 iowrite32(value, hostdata->base + reg);
501} 505}
502 506
503#endif 507#endif
diff --git a/drivers/scsi/53c7xx.c b/drivers/scsi/53c7xx.c
index 9cb5dd48383f..7894b8ea84bd 100644
--- a/drivers/scsi/53c7xx.c
+++ b/drivers/scsi/53c7xx.c
@@ -282,6 +282,7 @@
282#include "scsi.h" 282#include "scsi.h"
283#include <scsi/scsi_dbg.h> 283#include <scsi/scsi_dbg.h>
284#include <scsi/scsi_host.h> 284#include <scsi/scsi_host.h>
285#include <scsi/scsi_transport_spi.h>
285#include "53c7xx.h" 286#include "53c7xx.h"
286#include <linux/stat.h> 287#include <linux/stat.h>
287#include <linux/stddef.h> 288#include <linux/stddef.h>
@@ -1724,7 +1725,7 @@ NCR53c7xx_run_tests (struct Scsi_Host *host) {
1724 printk ("scsi%d : status ", host->host_no); 1725 printk ("scsi%d : status ", host->host_no);
1725 scsi_print_status (status); 1726 scsi_print_status (status);
1726 printk ("\nscsi%d : message ", host->host_no); 1727 printk ("\nscsi%d : message ", host->host_no);
1727 scsi_print_msg (&msg); 1728 spi_print_msg(&msg);
1728 printk ("\n"); 1729 printk ("\n");
1729 } else if (hostdata->test_completed == 3) { 1730 } else if (hostdata->test_completed == 3) {
1730 printk("scsi%d : test 2 no connection with target %d\n", 1731 printk("scsi%d : test 2 no connection with target %d\n",
@@ -2313,7 +2314,7 @@ NCR53c7x0_dstat_sir_intr (struct Scsi_Host *host, struct
2313 printk ("scsi%d : received message", host->host_no); 2314 printk ("scsi%d : received message", host->host_no);
2314 if (c) 2315 if (c)
2315 printk (" from target %d lun %d ", c->device->id, c->device->lun); 2316 printk (" from target %d lun %d ", c->device->id, c->device->lun);
2316 scsi_print_msg ((unsigned char *) hostdata->msg_buf); 2317 spi_print_msg((unsigned char *) hostdata->msg_buf);
2317 printk("\n"); 2318 printk("\n");
2318 } 2319 }
2319 2320
@@ -5540,7 +5541,7 @@ print_dsa (struct Scsi_Host *host, u32 *dsa, const char *prefix) {
5540 i > 0 && !check_address ((unsigned long) ptr, 1); 5541 i > 0 && !check_address ((unsigned long) ptr, 1);
5541 ptr += len, i -= len) { 5542 ptr += len, i -= len) {
5542 printk(" "); 5543 printk(" ");
5543 len = scsi_print_msg (ptr); 5544 len = spi_print_msg(ptr);
5544 printk("\n"); 5545 printk("\n");
5545 if (!len) 5546 if (!len)
5546 break; 5547 break;
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 20dd85a77813..3c606cf8c8ca 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -336,6 +336,7 @@ config SCSI_ACARD
336config SCSI_AHA152X 336config SCSI_AHA152X
337 tristate "Adaptec AHA152X/2825 support" 337 tristate "Adaptec AHA152X/2825 support"
338 depends on ISA && SCSI && !64BIT 338 depends on ISA && SCSI && !64BIT
339 select SCSI_SPI_ATTRS
339 ---help--- 340 ---help---
340 This is a driver for the AHA-1510, AHA-1520, AHA-1522, and AHA-2825 341 This is a driver for the AHA-1510, AHA-1520, AHA-1522, and AHA-2825
341 SCSI host adapters. It also works for the AVA-1505, but the IRQ etc. 342 SCSI host adapters. It also works for the AVA-1505, but the IRQ etc.
@@ -623,6 +624,7 @@ config SCSI_OMIT_FLASHPOINT
623config SCSI_DMX3191D 624config SCSI_DMX3191D
624 tristate "DMX3191D SCSI support" 625 tristate "DMX3191D SCSI support"
625 depends on PCI && SCSI 626 depends on PCI && SCSI
627 select SCSI_SPI_ATTRS
626 help 628 help
627 This is support for Domex DMX3191D SCSI Host Adapters. 629 This is support for Domex DMX3191D SCSI Host Adapters.
628 630
@@ -632,6 +634,7 @@ config SCSI_DMX3191D
632config SCSI_DTC3280 634config SCSI_DTC3280
633 tristate "DTC3180/3280 SCSI support" 635 tristate "DTC3180/3280 SCSI support"
634 depends on ISA && SCSI 636 depends on ISA && SCSI
637 select SCSI_SPI_ATTRS
635 help 638 help
636 This is support for DTC 3180/3280 SCSI Host Adapters. Please read 639 This is support for DTC 3180/3280 SCSI Host Adapters. Please read
637 the SCSI-HOWTO, available from 640 the SCSI-HOWTO, available from
@@ -752,6 +755,7 @@ config SCSI_GDTH
752config SCSI_GENERIC_NCR5380 755config SCSI_GENERIC_NCR5380
753 tristate "Generic NCR5380/53c400 SCSI PIO support" 756 tristate "Generic NCR5380/53c400 SCSI PIO support"
754 depends on ISA && SCSI 757 depends on ISA && SCSI
758 select SCSI_SPI_ATTRS
755 ---help--- 759 ---help---
756 This is a driver for the old NCR 53c80 series of SCSI controllers 760 This is a driver for the old NCR 53c80 series of SCSI controllers
757 on boards using PIO. Most boards such as the Trantor T130 fit this 761 on boards using PIO. Most boards such as the Trantor T130 fit this
@@ -771,6 +775,7 @@ config SCSI_GENERIC_NCR5380
771config SCSI_GENERIC_NCR5380_MMIO 775config SCSI_GENERIC_NCR5380_MMIO
772 tristate "Generic NCR5380/53c400 SCSI MMIO support" 776 tristate "Generic NCR5380/53c400 SCSI MMIO support"
773 depends on ISA && SCSI 777 depends on ISA && SCSI
778 select SCSI_SPI_ATTRS
774 ---help--- 779 ---help---
775 This is a driver for the old NCR 53c80 series of SCSI controllers 780 This is a driver for the old NCR 53c80 series of SCSI controllers
776 on boards using memory mapped I/O. 781 on boards using memory mapped I/O.
@@ -909,7 +914,7 @@ config SCSI_INIA100
909 914
910config SCSI_PPA 915config SCSI_PPA
911 tristate "IOMEGA parallel port (ppa - older drives)" 916 tristate "IOMEGA parallel port (ppa - older drives)"
912 depends on SCSI && PARPORT 917 depends on SCSI && PARPORT_PC
913 ---help--- 918 ---help---
914 This driver supports older versions of IOMEGA's parallel port ZIP 919 This driver supports older versions of IOMEGA's parallel port ZIP
915 drive (a 100 MB removable media device). 920 drive (a 100 MB removable media device).
@@ -936,7 +941,7 @@ config SCSI_PPA
936 941
937config SCSI_IMM 942config SCSI_IMM
938 tristate "IOMEGA parallel port (imm - newer drives)" 943 tristate "IOMEGA parallel port (imm - newer drives)"
939 depends on SCSI && PARPORT 944 depends on SCSI && PARPORT_PC
940 ---help--- 945 ---help---
941 This driver supports newer versions of IOMEGA's parallel port ZIP 946 This driver supports newer versions of IOMEGA's parallel port ZIP
942 drive (a 100 MB removable media device). 947 drive (a 100 MB removable media device).
@@ -963,7 +968,7 @@ config SCSI_IMM
963 968
964config SCSI_IZIP_EPP16 969config SCSI_IZIP_EPP16
965 bool "ppa/imm option - Use slow (but safe) EPP-16" 970 bool "ppa/imm option - Use slow (but safe) EPP-16"
966 depends on PARPORT && (SCSI_PPA || SCSI_IMM) 971 depends on SCSI_PPA || SCSI_IMM
967 ---help--- 972 ---help---
968 EPP (Enhanced Parallel Port) is a standard for parallel ports which 973 EPP (Enhanced Parallel Port) is a standard for parallel ports which
969 allows them to act as expansion buses that can handle up to 64 974 allows them to act as expansion buses that can handle up to 64
@@ -978,7 +983,7 @@ config SCSI_IZIP_EPP16
978 983
979config SCSI_IZIP_SLOW_CTR 984config SCSI_IZIP_SLOW_CTR
980 bool "ppa/imm option - Assume slow parport control register" 985 bool "ppa/imm option - Assume slow parport control register"
981 depends on PARPORT && (SCSI_PPA || SCSI_IMM) 986 depends on SCSI_PPA || SCSI_IMM
982 help 987 help
983 Some parallel ports are known to have excessive delays between 988 Some parallel ports are known to have excessive delays between
984 changing the parallel port control register and good data being 989 changing the parallel port control register and good data being
@@ -1254,6 +1259,7 @@ config SCSI_MCA_53C9X
1254config SCSI_PAS16 1259config SCSI_PAS16
1255 tristate "PAS16 SCSI support" 1260 tristate "PAS16 SCSI support"
1256 depends on ISA && SCSI 1261 depends on ISA && SCSI
1262 select SCSI_SPI_ATTRS
1257 ---help--- 1263 ---help---
1258 This is support for a SCSI host adapter. It is explained in section 1264 This is support for a SCSI host adapter. It is explained in section
1259 3.10 of the SCSI-HOWTO, available from 1265 3.10 of the SCSI-HOWTO, available from
@@ -1423,6 +1429,7 @@ config SCSI_DC390T
1423config SCSI_T128 1429config SCSI_T128
1424 tristate "Trantor T128/T128F/T228 SCSI support" 1430 tristate "Trantor T128/T128F/T228 SCSI support"
1425 depends on ISA && SCSI 1431 depends on ISA && SCSI
1432 select SCSI_SPI_ATTRS
1426 ---help--- 1433 ---help---
1427 This is support for a SCSI host adapter. It is explained in section 1434 This is support for a SCSI host adapter. It is explained in section
1428 3.11 of the SCSI-HOWTO, available from 1435 3.11 of the SCSI-HOWTO, available from
@@ -1681,6 +1688,7 @@ config OKTAGON_SCSI
1681config ATARI_SCSI 1688config ATARI_SCSI
1682 tristate "Atari native SCSI support" 1689 tristate "Atari native SCSI support"
1683 depends on ATARI && SCSI && BROKEN 1690 depends on ATARI && SCSI && BROKEN
1691 select SCSI_SPI_ATTRS
1684 ---help--- 1692 ---help---
1685 If you have an Atari with built-in NCR5380 SCSI controller (TT, 1693 If you have an Atari with built-in NCR5380 SCSI controller (TT,
1686 Falcon, ...) say Y to get it supported. Of course also, if you have 1694 Falcon, ...) say Y to get it supported. Of course also, if you have
@@ -1722,6 +1730,7 @@ config TT_DMA_EMUL
1722config MAC_SCSI 1730config MAC_SCSI
1723 bool "Macintosh NCR5380 SCSI" 1731 bool "Macintosh NCR5380 SCSI"
1724 depends on MAC && SCSI=y 1732 depends on MAC && SCSI=y
1733 select SCSI_SPI_ATTRS
1725 help 1734 help
1726 This is the NCR 5380 SCSI controller included on most of the 68030 1735 This is the NCR 5380 SCSI controller included on most of the 68030
1727 based Macintoshes. If you have one of these say Y and read the 1736 based Macintoshes. If you have one of these say Y and read the
@@ -1743,6 +1752,7 @@ config SCSI_MAC_ESP
1743config MVME147_SCSI 1752config MVME147_SCSI
1744 bool "WD33C93 SCSI driver for MVME147" 1753 bool "WD33C93 SCSI driver for MVME147"
1745 depends on MVME147 && SCSI=y 1754 depends on MVME147 && SCSI=y
1755 select SCSI_SPI_ATTRS
1746 help 1756 help
1747 Support for the on-board SCSI controller on the Motorola MVME147 1757 Support for the on-board SCSI controller on the Motorola MVME147
1748 single-board computer. 1758 single-board computer.
@@ -1750,6 +1760,7 @@ config MVME147_SCSI
1750config MVME16x_SCSI 1760config MVME16x_SCSI
1751 bool "NCR53C710 SCSI driver for MVME16x" 1761 bool "NCR53C710 SCSI driver for MVME16x"
1752 depends on MVME16x && SCSI && BROKEN 1762 depends on MVME16x && SCSI && BROKEN
1763 select SCSI_SPI_ATTRS
1753 help 1764 help
1754 The Motorola MVME162, 166, 167, 172 and 177 boards use the NCR53C710 1765 The Motorola MVME162, 166, 167, 172 and 177 boards use the NCR53C710
1755 SCSI controller chip. Almost everyone using one of these boards 1766 SCSI controller chip. Almost everyone using one of these boards
@@ -1758,6 +1769,7 @@ config MVME16x_SCSI
1758config BVME6000_SCSI 1769config BVME6000_SCSI
1759 bool "NCR53C710 SCSI driver for BVME6000" 1770 bool "NCR53C710 SCSI driver for BVME6000"
1760 depends on BVME6000 && SCSI && BROKEN 1771 depends on BVME6000 && SCSI && BROKEN
1772 select SCSI_SPI_ATTRS
1761 help 1773 help
1762 The BVME4000 and BVME6000 boards from BVM Ltd use the NCR53C710 1774 The BVME4000 and BVME6000 boards from BVM Ltd use the NCR53C710
1763 SCSI controller chip. Almost everyone using one of these boards 1775 SCSI controller chip. Almost everyone using one of these boards
@@ -1774,6 +1786,7 @@ config SCSI_NCR53C7xx_FAST
1774config SUN3_SCSI 1786config SUN3_SCSI
1775 tristate "Sun3 NCR5380 SCSI" 1787 tristate "Sun3 NCR5380 SCSI"
1776 depends on SUN3 && SCSI && BROKEN 1788 depends on SUN3 && SCSI && BROKEN
1789 select SCSI_SPI_ATTRS
1777 help 1790 help
1778 This option will enable support for the OBIO (onboard io) NCR5380 1791 This option will enable support for the OBIO (onboard io) NCR5380
1779 SCSI controller found in the Sun 3/50 and 3/60, as well as for 1792 SCSI controller found in the Sun 3/50 and 3/60, as well as for
@@ -1802,7 +1815,7 @@ config SCSI_SUNESP
1802 1815
1803config ZFCP 1816config ZFCP
1804 tristate "FCP host bus adapter driver for IBM eServer zSeries" 1817 tristate "FCP host bus adapter driver for IBM eServer zSeries"
1805 depends on ARCH_S390 && QDIO && SCSI 1818 depends on S390 && QDIO && SCSI
1806 select SCSI_FC_ATTRS 1819 select SCSI_FC_ATTRS
1807 help 1820 help
1808 If you want to access SCSI devices attached to your IBM eServer 1821 If you want to access SCSI devices attached to your IBM eServer
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index cba9655d0f14..9f0ddbe6dc76 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -87,6 +87,7 @@
87 * the high level code. 87 * the high level code.
88 */ 88 */
89#include <scsi/scsi_dbg.h> 89#include <scsi/scsi_dbg.h>
90#include <scsi/scsi_transport_spi.h>
90 91
91#ifndef NDEBUG 92#ifndef NDEBUG
92#define NDEBUG 0 93#define NDEBUG 0
@@ -2377,7 +2378,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
2377 * 3..length+1 arguments 2378 * 3..length+1 arguments
2378 * 2379 *
2379 * Start the extended message buffer with the EXTENDED_MESSAGE 2380 * Start the extended message buffer with the EXTENDED_MESSAGE
2380 * byte, since scsi_print_msg() wants the whole thing. 2381 * byte, since spi_print_msg() wants the whole thing.
2381 */ 2382 */
2382 extended_msg[0] = EXTENDED_MESSAGE; 2383 extended_msg[0] = EXTENDED_MESSAGE;
2383 /* Accept first byte by clearing ACK */ 2384 /* Accept first byte by clearing ACK */
@@ -2424,7 +2425,7 @@ static void NCR5380_information_transfer(struct Scsi_Host *instance) {
2424 default: 2425 default:
2425 if (!tmp) { 2426 if (!tmp) {
2426 printk("scsi%d: rejecting message ", instance->host_no); 2427 printk("scsi%d: rejecting message ", instance->host_no);
2427 scsi_print_msg(extended_msg); 2428 spi_print_msg(extended_msg);
2428 printk("\n"); 2429 printk("\n");
2429 } else if (tmp != EXTENDED_MESSAGE) 2430 } else if (tmp != EXTENDED_MESSAGE)
2430 scmd_printk(KERN_INFO, cmd, 2431 scmd_printk(KERN_INFO, cmd,
@@ -2560,7 +2561,7 @@ static void NCR5380_reselect(struct Scsi_Host *instance) {
2560 2561
2561 if (!(msg[0] & 0x80)) { 2562 if (!(msg[0] & 0x80)) {
2562 printk(KERN_ERR "scsi%d : expecting IDENTIFY message, got ", instance->host_no); 2563 printk(KERN_ERR "scsi%d : expecting IDENTIFY message, got ", instance->host_no);
2563 scsi_print_msg(msg); 2564 spi_print_msg(msg);
2564 abort = 1; 2565 abort = 1;
2565 } else { 2566 } else {
2566 /* Accept message by clearing ACK */ 2567 /* Accept message by clearing ACK */
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 9df23b654cec..cb2ee25f213f 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -259,6 +259,7 @@
259#include "scsi.h" 259#include "scsi.h"
260#include <scsi/scsi_dbg.h> 260#include <scsi/scsi_dbg.h>
261#include <scsi/scsi_host.h> 261#include <scsi/scsi_host.h>
262#include <scsi/scsi_transport_spi.h>
262#include "aha152x.h" 263#include "aha152x.h"
263 264
264 265
@@ -1845,7 +1846,7 @@ static void msgi_run(struct Scsi_Host *shpnt)
1845#if defined(AHA152X_DEBUG) 1846#if defined(AHA152X_DEBUG)
1846 if (HOSTDATA(shpnt)->debug & debug_msgi) { 1847 if (HOSTDATA(shpnt)->debug & debug_msgi) {
1847 printk(INFO_LEAD "inbound message %02x ", CMDINFO(CURRENT_SC), MSGI(0)); 1848 printk(INFO_LEAD "inbound message %02x ", CMDINFO(CURRENT_SC), MSGI(0));
1848 scsi_print_msg(&MSGI(0)); 1849 spi_print_msg(&MSGI(0));
1849 printk("\n"); 1850 printk("\n");
1850 } 1851 }
1851#endif 1852#endif
@@ -1933,7 +1934,7 @@ static void msgi_run(struct Scsi_Host *shpnt)
1933 break; 1934 break;
1934 1935
1935 printk(INFO_LEAD, CMDINFO(CURRENT_SC)); 1936 printk(INFO_LEAD, CMDINFO(CURRENT_SC));
1936 scsi_print_msg(&MSGI(0)); 1937 spi_print_msg(&MSGI(0));
1937 printk("\n"); 1938 printk("\n");
1938 1939
1939 ticks = (MSGI(3) * 4 + 49) / 50; 1940 ticks = (MSGI(3) * 4 + 49) / 50;
@@ -2031,7 +2032,7 @@ static void msgo_init(struct Scsi_Host *shpnt)
2031 int i; 2032 int i;
2032 2033
2033 printk(DEBUG_LEAD "messages( ", CMDINFO(CURRENT_SC)); 2034 printk(DEBUG_LEAD "messages( ", CMDINFO(CURRENT_SC));
2034 for (i=0; i<MSGOLEN; i+=scsi_print_msg(&MSGO(i)), printk(" ")) 2035 for (i=0; i<MSGOLEN; i+=spi_print_msg(&MSGO(i)), printk(" "))
2035 ; 2036 ;
2036 printk(")\n"); 2037 printk(")\n");
2037 } 2038 }
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 83467a05dc8e..d113290b5fc0 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -214,7 +214,6 @@ static struct scsi_host_template ahci_sht = {
214 .dma_boundary = AHCI_DMA_BOUNDARY, 214 .dma_boundary = AHCI_DMA_BOUNDARY,
215 .slave_configure = ata_scsi_slave_config, 215 .slave_configure = ata_scsi_slave_config,
216 .bios_param = ata_std_bios_param, 216 .bios_param = ata_std_bios_param,
217 .ordered_flush = 1,
218}; 217};
219 218
220static const struct ata_port_operations ahci_ops = { 219static const struct ata_port_operations ahci_ops = {
@@ -243,7 +242,7 @@ static const struct ata_port_operations ahci_ops = {
243 .port_stop = ahci_port_stop, 242 .port_stop = ahci_port_stop,
244}; 243};
245 244
246static struct ata_port_info ahci_port_info[] = { 245static const struct ata_port_info ahci_port_info[] = {
247 /* board_ahci */ 246 /* board_ahci */
248 { 247 {
249 .sht = &ahci_sht, 248 .sht = &ahci_sht,
@@ -643,7 +642,8 @@ static void ahci_eng_timeout(struct ata_port *ap)
643 * not being called from the SCSI EH. 642 * not being called from the SCSI EH.
644 */ 643 */
645 qc->scsidone = scsi_finish_command; 644 qc->scsidone = scsi_finish_command;
646 ata_qc_complete(qc, AC_ERR_OTHER); 645 qc->err_mask |= AC_ERR_OTHER;
646 ata_qc_complete(qc);
647 } 647 }
648 648
649 spin_unlock_irqrestore(&host_set->lock, flags); 649 spin_unlock_irqrestore(&host_set->lock, flags);
@@ -664,7 +664,8 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
664 ci = readl(port_mmio + PORT_CMD_ISSUE); 664 ci = readl(port_mmio + PORT_CMD_ISSUE);
665 if (likely((ci & 0x1) == 0)) { 665 if (likely((ci & 0x1) == 0)) {
666 if (qc) { 666 if (qc) {
667 ata_qc_complete(qc, 0); 667 assert(qc->err_mask == 0);
668 ata_qc_complete(qc);
668 qc = NULL; 669 qc = NULL;
669 } 670 }
670 } 671 }
@@ -681,8 +682,10 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
681 /* command processing has stopped due to error; restart */ 682 /* command processing has stopped due to error; restart */
682 ahci_restart_port(ap, status); 683 ahci_restart_port(ap, status);
683 684
684 if (qc) 685 if (qc) {
685 ata_qc_complete(qc, err_mask); 686 qc->err_mask |= AC_ERR_OTHER;
687 ata_qc_complete(qc);
688 }
686 } 689 }
687 690
688 return 1; 691 return 1;
diff --git a/drivers/scsi/aic7xxx/.gitignore b/drivers/scsi/aic7xxx/.gitignore
new file mode 100644
index 000000000000..b8ee24d5748a
--- /dev/null
+++ b/drivers/scsi/aic7xxx/.gitignore
@@ -0,0 +1,6 @@
1aic79xx_reg.h
2aic79xx_reg_print.c
3aic79xx_seq.h
4aic7xxx_reg.h
5aic7xxx_reg_print.c
6aic7xxx_seq.h
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 6aab9dacdeea..1c8f872e2dd4 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -1064,6 +1064,7 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
1064 struct Scsi_Host *host; 1064 struct Scsi_Host *host;
1065 char *new_name; 1065 char *new_name;
1066 u_long s; 1066 u_long s;
1067 int retval;
1067 1068
1068 template->name = ahd->description; 1069 template->name = ahd->description;
1069 host = scsi_host_alloc(template, sizeof(struct ahd_softc *)); 1070 host = scsi_host_alloc(template, sizeof(struct ahd_softc *));
@@ -1096,9 +1097,15 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
1096 1097
1097 host->transportt = ahd_linux_transport_template; 1098 host->transportt = ahd_linux_transport_template;
1098 1099
1099 scsi_add_host(host, &ahd->dev_softc->dev); /* XXX handle failure */ 1100 retval = scsi_add_host(host, &ahd->dev_softc->dev);
1101 if (retval) {
1102 printk(KERN_WARNING "aic79xx: scsi_add_host failed\n");
1103 scsi_host_put(host);
1104 return retval;
1105 }
1106
1100 scsi_scan_host(host); 1107 scsi_scan_host(host);
1101 return (0); 1108 return 0;
1102} 1109}
1103 1110
1104uint64_t 1111uint64_t
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index d866213f42b8..fd389e9f9460 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -1061,10 +1061,11 @@ uint32_t aic7xxx_verbose;
1061int 1061int
1062ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template) 1062ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *template)
1063{ 1063{
1064 char buf[80]; 1064 char buf[80];
1065 struct Scsi_Host *host; 1065 struct Scsi_Host *host;
1066 char *new_name; 1066 char *new_name;
1067 u_long s; 1067 u_long s;
1068 int retval;
1068 1069
1069 template->name = ahc->description; 1070 template->name = ahc->description;
1070 host = scsi_host_alloc(template, sizeof(struct ahc_softc *)); 1071 host = scsi_host_alloc(template, sizeof(struct ahc_softc *));
@@ -1097,9 +1098,16 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
1097 1098
1098 host->transportt = ahc_linux_transport_template; 1099 host->transportt = ahc_linux_transport_template;
1099 1100
1100 scsi_add_host(host, (ahc->dev_softc ? &ahc->dev_softc->dev : NULL)); /* XXX handle failure */ 1101 retval = scsi_add_host(host,
1102 (ahc->dev_softc ? &ahc->dev_softc->dev : NULL));
1103 if (retval) {
1104 printk(KERN_WARNING "aic7xxx: scsi_add_host failed\n");
1105 scsi_host_put(host);
1106 return retval;
1107 }
1108
1101 scsi_scan_host(host); 1109 scsi_scan_host(host);
1102 return (0); 1110 return 0;
1103} 1111}
1104 1112
1105/* 1113/*
diff --git a/drivers/scsi/arm/Kconfig b/drivers/scsi/arm/Kconfig
index 13f23043c8a3..06d7601cdf56 100644
--- a/drivers/scsi/arm/Kconfig
+++ b/drivers/scsi/arm/Kconfig
@@ -4,6 +4,7 @@
4config SCSI_ACORNSCSI_3 4config SCSI_ACORNSCSI_3
5 tristate "Acorn SCSI card (aka30) support" 5 tristate "Acorn SCSI card (aka30) support"
6 depends on ARCH_ACORN && SCSI && BROKEN 6 depends on ARCH_ACORN && SCSI && BROKEN
7 select SCSI_SPI_ATTRS
7 help 8 help
8 This enables support for the Acorn SCSI card (aka30). If you have an 9 This enables support for the Acorn SCSI card (aka30). If you have an
9 Acorn system with one of these, say Y. If unsure, say N. 10 Acorn system with one of these, say Y. If unsure, say N.
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index b7b20c689c24..09ed05727bcb 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -152,6 +152,7 @@
152#include "../scsi.h" 152#include "../scsi.h"
153#include <scsi/scsi_dbg.h> 153#include <scsi/scsi_dbg.h>
154#include <scsi/scsi_host.h> 154#include <scsi/scsi_host.h>
155#include <scsi/scsi_transport_spi.h>
155#include "acornscsi.h" 156#include "acornscsi.h"
156#include "msgqueue.h" 157#include "msgqueue.h"
157#include "scsi.h" 158#include "scsi.h"
@@ -1370,7 +1371,7 @@ void acornscsi_sendmessage(AS_Host *host)
1370 1371
1371 host->scsi.last_message = msg->msg[0]; 1372 host->scsi.last_message = msg->msg[0];
1372#if (DEBUG & DEBUG_MESSAGES) 1373#if (DEBUG & DEBUG_MESSAGES)
1373 scsi_print_msg(msg->msg); 1374 spi_print_msg(msg->msg);
1374#endif 1375#endif
1375 break; 1376 break;
1376 1377
@@ -1392,7 +1393,7 @@ void acornscsi_sendmessage(AS_Host *host)
1392 while ((msg = msgqueue_getmsg(&host->scsi.msgs, msgnr++)) != NULL) { 1393 while ((msg = msgqueue_getmsg(&host->scsi.msgs, msgnr++)) != NULL) {
1393 unsigned int i; 1394 unsigned int i;
1394#if (DEBUG & DEBUG_MESSAGES) 1395#if (DEBUG & DEBUG_MESSAGES)
1395 scsi_print_msg(msg); 1396 spi_print_msg(msg);
1396#endif 1397#endif
1397 i = 0; 1398 i = 0;
1398 if (acornscsi_write_pio(host, msg->msg, &i, msg->length, 1000000)) 1399 if (acornscsi_write_pio(host, msg->msg, &i, msg->length, 1000000))
@@ -1488,7 +1489,7 @@ void acornscsi_message(AS_Host *host)
1488#if (DEBUG & DEBUG_MESSAGES) 1489#if (DEBUG & DEBUG_MESSAGES)
1489 printk("scsi%d.%c: message in: ", 1490 printk("scsi%d.%c: message in: ",
1490 host->host->host_no, acornscsi_target(host)); 1491 host->host->host_no, acornscsi_target(host));
1491 scsi_print_msg(message); 1492 spi_print_msg(message);
1492 printk("\n"); 1493 printk("\n");
1493#endif 1494#endif
1494 1495
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index 333d69dd84ef..557788ec4eec 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -37,6 +37,49 @@
37 * 37 *
38 * Hardware documentation available at http://developer.intel.com/ 38 * Hardware documentation available at http://developer.intel.com/
39 * 39 *
40 * Documentation
41 * Publically available from Intel web site. Errata documentation
42 * is also publically available. As an aide to anyone hacking on this
43 * driver the list of errata that are relevant is below.going back to
44 * PIIX4. Older device documentation is now a bit tricky to find.
45 *
46 * The chipsets all follow very much the same design. The orginal Triton
47 * series chipsets do _not_ support independant device timings, but this
48 * is fixed in Triton II. With the odd mobile exception the chips then
49 * change little except in gaining more modes until SATA arrives. This
50 * driver supports only the chips with independant timing (that is those
51 * with SITRE and the 0x44 timing register). See pata_oldpiix and pata_mpiix
52 * for the early chip drivers.
53 *
54 * Errata of note:
55 *
56 * Unfixable
57 * PIIX4 errata #9 - Only on ultra obscure hw
58 * ICH3 errata #13 - Not observed to affect real hw
59 * by Intel
60 *
61 * Things we must deal with
62 * PIIX4 errata #10 - BM IDE hang with non UDMA
63 * (must stop/start dma to recover)
64 * 440MX errata #15 - As PIIX4 errata #10
65 * PIIX4 errata #15 - Must not read control registers
66 * during a PIO transfer
67 * 440MX errata #13 - As PIIX4 errata #15
68 * ICH2 errata #21 - DMA mode 0 doesn't work right
69 * ICH0/1 errata #55 - As ICH2 errata #21
70 * ICH2 spec c #9 - Extra operations needed to handle
71 * drive hotswap [NOT YET SUPPORTED]
72 * ICH2 spec c #20 - IDE PRD must not cross a 64K boundary
73 * and must be dword aligned
74 * ICH2 spec c #24 - UDMA mode 4,5 t85/86 should be 6ns not 3.3
75 *
76 * Should have been BIOS fixed:
77 * 450NX: errata #19 - DMA hangs on old 450NX
78 * 450NX: errata #20 - DMA hangs on old 450NX
79 * 450NX: errata #25 - Corruption with DMA on old 450NX
80 * ICH3 errata #15 - IDE deadlock under high load
81 * (BIOS must set dev 31 fn 0 bit 23)
82 * ICH3 errata #18 - Don't use native mode
40 */ 83 */
41 84
42#include <linux/kernel.h> 85#include <linux/kernel.h>
@@ -78,9 +121,7 @@ enum {
78 ich5_sata = 1, 121 ich5_sata = 1,
79 piix4_pata = 2, 122 piix4_pata = 2,
80 ich6_sata = 3, 123 ich6_sata = 3,
81 ich6_sata_rm = 4, 124 ich6_sata_ahci = 4,
82 ich7_sata = 5,
83 esb2_sata = 6,
84 125
85 PIIX_AHCI_DEVICE = 6, 126 PIIX_AHCI_DEVICE = 6,
86}; 127};
@@ -111,11 +152,11 @@ static const struct pci_device_id piix_pci_tbl[] = {
111 { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 152 { 0x8086, 0x25a3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
112 { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata }, 153 { 0x8086, 0x25b0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_sata },
113 { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata }, 154 { 0x8086, 0x2651, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata },
114 { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_rm }, 155 { 0x8086, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
115 { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_rm }, 156 { 0x8086, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
116 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7_sata }, 157 { 0x8086, 0x27c0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
117 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich7_sata }, 158 { 0x8086, 0x27c4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
118 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, esb2_sata }, 159 { 0x8086, 0x2680, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich6_sata_ahci },
119 160
120 { } /* terminate list */ 161 { } /* terminate list */
121}; 162};
@@ -125,6 +166,8 @@ static struct pci_driver piix_pci_driver = {
125 .id_table = piix_pci_tbl, 166 .id_table = piix_pci_tbl,
126 .probe = piix_init_one, 167 .probe = piix_init_one,
127 .remove = ata_pci_remove_one, 168 .remove = ata_pci_remove_one,
169 .suspend = ata_pci_device_suspend,
170 .resume = ata_pci_device_resume,
128}; 171};
129 172
130static struct scsi_host_template piix_sht = { 173static struct scsi_host_template piix_sht = {
@@ -144,7 +187,8 @@ static struct scsi_host_template piix_sht = {
144 .dma_boundary = ATA_DMA_BOUNDARY, 187 .dma_boundary = ATA_DMA_BOUNDARY,
145 .slave_configure = ata_scsi_slave_config, 188 .slave_configure = ata_scsi_slave_config,
146 .bios_param = ata_std_bios_param, 189 .bios_param = ata_std_bios_param,
147 .ordered_flush = 1, 190 .resume = ata_scsi_device_resume,
191 .suspend = ata_scsi_device_suspend,
148}; 192};
149 193
150static const struct ata_port_operations piix_pata_ops = { 194static const struct ata_port_operations piix_pata_ops = {
@@ -258,31 +302,7 @@ static struct ata_port_info piix_port_info[] = {
258 .port_ops = &piix_sata_ops, 302 .port_ops = &piix_sata_ops,
259 }, 303 },
260 304
261 /* ich6_sata_rm */ 305 /* ich6_sata_ahci */
262 {
263 .sht = &piix_sht,
264 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST |
265 PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR |
266 ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI,
267 .pio_mask = 0x1f, /* pio0-4 */
268 .mwdma_mask = 0x07, /* mwdma0-2 */
269 .udma_mask = 0x7f, /* udma0-6 */
270 .port_ops = &piix_sata_ops,
271 },
272
273 /* ich7_sata */
274 {
275 .sht = &piix_sht,
276 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST |
277 PIIX_FLAG_COMBINED | PIIX_FLAG_CHECKINTR |
278 ATA_FLAG_SLAVE_POSS | PIIX_FLAG_AHCI,
279 .pio_mask = 0x1f, /* pio0-4 */
280 .mwdma_mask = 0x07, /* mwdma0-2 */
281 .udma_mask = 0x7f, /* udma0-6 */
282 .port_ops = &piix_sata_ops,
283 },
284
285 /* esb2_sata */
286 { 306 {
287 .sht = &piix_sht, 307 .sht = &piix_sht,
288 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST | 308 .host_flags = ATA_FLAG_SATA | ATA_FLAG_SRST |
@@ -603,6 +623,40 @@ static int piix_disable_ahci(struct pci_dev *pdev)
603} 623}
604 624
605/** 625/**
626 * piix_check_450nx_errata - Check for problem 450NX setup
627 *
628 * Check for the present of 450NX errata #19 and errata #25. If
629 * they are found return an error code so we can turn off DMA
630 */
631
632static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
633{
634 struct pci_dev *pdev = NULL;
635 u16 cfg;
636 u8 rev;
637 int no_piix_dma = 0;
638
639 while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL)
640 {
641 /* Look for 450NX PXB. Check for problem configurations
642 A PCI quirk checks bit 6 already */
643 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev);
644 pci_read_config_word(pdev, 0x41, &cfg);
645 /* Only on the original revision: IDE DMA can hang */
646 if(rev == 0x00)
647 no_piix_dma = 1;
648 /* On all revisions below 5 PXB bus lock must be disabled for IDE */
649 else if(cfg & (1<<14) && rev < 5)
650 no_piix_dma = 2;
651 }
652 if(no_piix_dma)
653 dev_printk(KERN_WARNING, &ata_dev->dev, "450NX errata present, disabling IDE DMA.\n");
654 if(no_piix_dma == 2)
655 dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n");
656 return no_piix_dma;
657}
658
659/**
606 * piix_init_one - Register PIIX ATA PCI device with kernel services 660 * piix_init_one - Register PIIX ATA PCI device with kernel services
607 * @pdev: PCI device to register 661 * @pdev: PCI device to register
608 * @ent: Entry in piix_pci_tbl matching with @pdev 662 * @ent: Entry in piix_pci_tbl matching with @pdev
@@ -676,7 +730,15 @@ static int piix_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
676 "combined mode detected (p=%u, s=%u)\n", 730 "combined mode detected (p=%u, s=%u)\n",
677 pata_chan, sata_chan); 731 pata_chan, sata_chan);
678 } 732 }
679 733 if (piix_check_450nx_errata(pdev)) {
734 /* This writes into the master table but it does not
735 really matter for this errata as we will apply it to
736 all the PIIX devices on the board */
737 port_info[0]->mwdma_mask = 0;
738 port_info[0]->udma_mask = 0;
739 port_info[1]->mwdma_mask = 0;
740 port_info[1]->udma_mask = 0;
741 }
680 return ata_pci_init_one(pdev, port_info, 2); 742 return ata_pci_init_one(pdev, port_info, 2);
681} 743}
682 744
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 2ae31ceb32a8..57295bcea3e7 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -74,6 +74,7 @@
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 78
78#if (NDEBUG & NDEBUG_LISTS) 79#if (NDEBUG & NDEBUG_LISTS)
79#define LIST(x,y) \ 80#define LIST(x,y) \
@@ -2355,7 +2356,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2355 * 3..length+1 arguments 2356 * 3..length+1 arguments
2356 * 2357 *
2357 * Start the extended message buffer with the EXTENDED_MESSAGE 2358 * Start the extended message buffer with the EXTENDED_MESSAGE
2358 * byte, since scsi_print_msg() wants the whole thing. 2359 * byte, since spi_print_msg() wants the whole thing.
2359 */ 2360 */
2360 extended_msg[0] = EXTENDED_MESSAGE; 2361 extended_msg[0] = EXTENDED_MESSAGE;
2361 /* Accept first byte by clearing ACK */ 2362 /* Accept first byte by clearing ACK */
@@ -2408,7 +2409,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2408 default: 2409 default:
2409 if (!tmp) { 2410 if (!tmp) {
2410 printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO); 2411 printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO);
2411 scsi_print_msg (extended_msg); 2412 spi_print_msg(extended_msg);
2412 printk("\n"); 2413 printk("\n");
2413 } else if (tmp != EXTENDED_MESSAGE) 2414 } else if (tmp != EXTENDED_MESSAGE)
2414 printk(KERN_DEBUG "scsi%d: rejecting unknown " 2415 printk(KERN_DEBUG "scsi%d: rejecting unknown "
@@ -2541,7 +2542,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2541 2542
2542 if (!(msg[0] & 0x80)) { 2543 if (!(msg[0] & 0x80)) {
2543 printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO); 2544 printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO);
2544 scsi_print_msg(msg); 2545 spi_print_msg(msg);
2545 do_abort(instance); 2546 do_abort(instance);
2546 return; 2547 return;
2547 } 2548 }
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c
index ccbbae2bf478..0920220f3313 100644
--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -75,7 +75,7 @@ static int vendor_counts[CH_TYPES-4];
75module_param_array(vendor_firsts, int, NULL, 0444); 75module_param_array(vendor_firsts, int, NULL, 0444);
76module_param_array(vendor_counts, int, NULL, 0444); 76module_param_array(vendor_counts, int, NULL, 0444);
77 77
78static char *vendor_labels[CH_TYPES-4] = { 78static const char * vendor_labels[CH_TYPES-4] = {
79 "v0", "v1", "v2", "v3" 79 "v0", "v1", "v2", "v3"
80}; 80};
81// module_param_string_array(vendor_labels, NULL, 0444); 81// module_param_string_array(vendor_labels, NULL, 0444);
@@ -140,7 +140,7 @@ static struct file_operations changer_fops =
140#endif 140#endif
141}; 141};
142 142
143static struct { 143static const struct {
144 unsigned char sense; 144 unsigned char sense;
145 unsigned char asc; 145 unsigned char asc;
146 unsigned char ascq; 146 unsigned char ascq;
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 09bc81557b6e..30a335349cee 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1065,7 +1065,7 @@ struct error_info2 {
1065 const char * fmt; 1065 const char * fmt;
1066}; 1066};
1067 1067
1068static struct error_info2 additional2[] = 1068static const struct error_info2 additional2[] =
1069{ 1069{
1070 {0x40,0x00,0x7f,"Ram failure (%x)"}, 1070 {0x40,0x00,0x7f,"Ram failure (%x)"},
1071 {0x40,0x80,0xff,"Diagnostic failure on component (%x)"}, 1071 {0x40,0x80,0xff,"Diagnostic failure on component (%x)"},
@@ -1077,7 +1077,7 @@ static struct error_info2 additional2[] =
1077}; 1077};
1078 1078
1079/* description of the sense key values */ 1079/* description of the sense key values */
1080static const char *snstext[] = { 1080static const char * const snstext[] = {
1081 "No Sense", /* 0: There is no sense information */ 1081 "No Sense", /* 0: There is no sense information */
1082 "Recovered Error", /* 1: The last command completed successfully 1082 "Recovered Error", /* 1: The last command completed successfully
1083 but used error correction */ 1083 but used error correction */
@@ -1278,114 +1278,6 @@ void scsi_print_req_sense(const char *devclass, struct scsi_request *sreq)
1278} 1278}
1279EXPORT_SYMBOL(scsi_print_req_sense); 1279EXPORT_SYMBOL(scsi_print_req_sense);
1280 1280
1281#ifdef CONFIG_SCSI_CONSTANTS
1282static const char *one_byte_msgs[] = {
1283/* 0x00 */ "Command Complete", NULL, "Save Pointers",
1284/* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error",
1285/* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error",
1286/* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",
1287/* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue",
1288/* 0x0f */ "Initiate Recovery", "Release Recovery"
1289};
1290#define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *))
1291
1292static const char *two_byte_msgs[] = {
1293/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag"
1294/* 0x23 */ "Ignore Wide Residue"
1295};
1296#define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))
1297
1298static const char *extended_msgs[] = {
1299/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
1300/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request"
1301};
1302#define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))
1303
1304
1305int scsi_print_msg (const unsigned char *msg)
1306{
1307 int len = 0, i;
1308 if (msg[0] == EXTENDED_MESSAGE) {
1309 len = 3 + msg[1];
1310 if (msg[2] < NO_EXTENDED_MSGS)
1311 printk ("%s ", extended_msgs[msg[2]]);
1312 else
1313 printk ("Extended Message, reserved code (0x%02x) ",
1314 (int) msg[2]);
1315 switch (msg[2]) {
1316 case EXTENDED_MODIFY_DATA_POINTER:
1317 printk("pointer = %d", (int) (msg[3] << 24) |
1318 (msg[4] << 16) | (msg[5] << 8) | msg[6]);
1319 break;
1320 case EXTENDED_SDTR:
1321 printk("period = %d ns, offset = %d",
1322 (int) msg[3] * 4, (int) msg[4]);
1323 break;
1324 case EXTENDED_WDTR:
1325 printk("width = 2^%d bytes", msg[3]);
1326 break;
1327 default:
1328 for (i = 2; i < len; ++i)
1329 printk("%02x ", msg[i]);
1330 }
1331 /* Identify */
1332 } else if (msg[0] & 0x80) {
1333 printk("Identify disconnect %sallowed %s %d ",
1334 (msg[0] & 0x40) ? "" : "not ",
1335 (msg[0] & 0x20) ? "target routine" : "lun",
1336 msg[0] & 0x7);
1337 len = 1;
1338 /* Normal One byte */
1339 } else if (msg[0] < 0x1f) {
1340 if (msg[0] < NO_ONE_BYTE_MSGS)
1341 printk(one_byte_msgs[msg[0]]);
1342 else
1343 printk("reserved (%02x) ", msg[0]);
1344 len = 1;
1345 /* Two byte */
1346 } else if (msg[0] <= 0x2f) {
1347 if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS)
1348 printk("%s %02x ", two_byte_msgs[msg[0] - 0x20],
1349 msg[1]);
1350 else
1351 printk("reserved two byte (%02x %02x) ",
1352 msg[0], msg[1]);
1353 len = 2;
1354 } else
1355 printk("reserved");
1356 return len;
1357}
1358EXPORT_SYMBOL(scsi_print_msg);
1359
1360#else /* ifndef CONFIG_SCSI_CONSTANTS */
1361
1362int scsi_print_msg (const unsigned char *msg)
1363{
1364 int len = 0, i;
1365
1366 if (msg[0] == EXTENDED_MESSAGE) {
1367 len = 3 + msg[1];
1368 for (i = 0; i < len; ++i)
1369 printk("%02x ", msg[i]);
1370 /* Identify */
1371 } else if (msg[0] & 0x80) {
1372 printk("%02x ", msg[0]);
1373 len = 1;
1374 /* Normal One byte */
1375 } else if (msg[0] < 0x1f) {
1376 printk("%02x ", msg[0]);
1377 len = 1;
1378 /* Two byte */
1379 } else if (msg[0] <= 0x2f) {
1380 printk("%02x %02x", msg[0], msg[1]);
1381 len = 2;
1382 } else
1383 printk("%02x ", msg[0]);
1384 return len;
1385}
1386EXPORT_SYMBOL(scsi_print_msg);
1387#endif /* ! CONFIG_SCSI_CONSTANTS */
1388
1389void scsi_print_command(struct scsi_cmnd *cmd) 1281void scsi_print_command(struct scsi_cmnd *cmd)
1390{ 1282{
1391 /* Assume appended output (i.e. not at start of line) */ 1283 /* Assume appended output (i.e. not at start of line) */
@@ -1397,7 +1289,7 @@ EXPORT_SYMBOL(scsi_print_command);
1397 1289
1398#ifdef CONFIG_SCSI_CONSTANTS 1290#ifdef CONFIG_SCSI_CONSTANTS
1399 1291
1400static const char * hostbyte_table[]={ 1292static const char * const hostbyte_table[]={
1401"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", 1293"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
1402"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR", 1294"DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
1403"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"}; 1295"DID_PASSTHROUGH", "DID_SOFT_ERROR", "DID_IMM_RETRY"};
@@ -1422,12 +1314,12 @@ void scsi_print_hostbyte(int scsiresult)
1422 1314
1423#ifdef CONFIG_SCSI_CONSTANTS 1315#ifdef CONFIG_SCSI_CONSTANTS
1424 1316
1425static const char * driverbyte_table[]={ 1317static const char * const driverbyte_table[]={
1426"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", 1318"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR",
1427"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"}; 1319"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
1428#define NUM_DRIVERBYTE_STRS (sizeof(driverbyte_table) / sizeof(const char *)) 1320#define NUM_DRIVERBYTE_STRS (sizeof(driverbyte_table) / sizeof(const char *))
1429 1321
1430static const char * driversuggest_table[]={"SUGGEST_OK", 1322static const char * const driversuggest_table[]={"SUGGEST_OK",
1431"SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE", 1323"SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
1432"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"}; 1324"SUGGEST_5", "SUGGEST_6", "SUGGEST_7", "SUGGEST_SENSE"};
1433#define NUM_SUGGEST_STRS (sizeof(driversuggest_table) / sizeof(const char *)) 1325#define NUM_SUGGEST_STRS (sizeof(driversuggest_table) / sizeof(const char *))
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 418fc7b896ac..6252b9ddc01e 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -660,7 +660,12 @@ static int adpt_abort(struct scsi_cmnd * cmd)
660 msg[2] = 0; 660 msg[2] = 0;
661 msg[3]= 0; 661 msg[3]= 0;
662 msg[4] = (u32)cmd; 662 msg[4] = (u32)cmd;
663 if( (rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER)) != 0){ 663 if (pHba->host)
664 spin_lock_irq(pHba->host->host_lock);
665 rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER);
666 if (pHba->host)
667 spin_unlock_irq(pHba->host->host_lock);
668 if (rcode != 0) {
664 if(rcode == -EOPNOTSUPP ){ 669 if(rcode == -EOPNOTSUPP ){
665 printk(KERN_INFO"%s: Abort cmd not supported\n",pHba->name); 670 printk(KERN_INFO"%s: Abort cmd not supported\n",pHba->name);
666 return FAILED; 671 return FAILED;
@@ -697,10 +702,15 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
697 msg[2] = 0; 702 msg[2] = 0;
698 msg[3] = 0; 703 msg[3] = 0;
699 704
705 if (pHba->host)
706 spin_lock_irq(pHba->host->host_lock);
700 old_state = d->state; 707 old_state = d->state;
701 d->state |= DPTI_DEV_RESET; 708 d->state |= DPTI_DEV_RESET;
702 if( (rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER)) ){ 709 rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER);
703 d->state = old_state; 710 d->state = old_state;
711 if (pHba->host)
712 spin_unlock_irq(pHba->host->host_lock);
713 if (rcode != 0) {
704 if(rcode == -EOPNOTSUPP ){ 714 if(rcode == -EOPNOTSUPP ){
705 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name); 715 printk(KERN_INFO"%s: Device reset not supported\n",pHba->name);
706 return FAILED; 716 return FAILED;
@@ -708,7 +718,6 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
708 printk(KERN_INFO"%s: Device reset failed\n",pHba->name); 718 printk(KERN_INFO"%s: Device reset failed\n",pHba->name);
709 return FAILED; 719 return FAILED;
710 } else { 720 } else {
711 d->state = old_state;
712 printk(KERN_INFO"%s: Device reset successful\n",pHba->name); 721 printk(KERN_INFO"%s: Device reset successful\n",pHba->name);
713 return SUCCESS; 722 return SUCCESS;
714 } 723 }
@@ -721,6 +730,7 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd)
721{ 730{
722 adpt_hba* pHba; 731 adpt_hba* pHba;
723 u32 msg[4]; 732 u32 msg[4];
733 u32 rcode;
724 734
725 pHba = (adpt_hba*)cmd->device->host->hostdata[0]; 735 pHba = (adpt_hba*)cmd->device->host->hostdata[0];
726 memset(msg, 0, sizeof(msg)); 736 memset(msg, 0, sizeof(msg));
@@ -729,7 +739,12 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd)
729 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid); 739 msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid);
730 msg[2] = 0; 740 msg[2] = 0;
731 msg[3] = 0; 741 msg[3] = 0;
732 if(adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER) ){ 742 if (pHba->host)
743 spin_lock_irq(pHba->host->host_lock);
744 rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER);
745 if (pHba->host)
746 spin_unlock_irq(pHba->host->host_lock);
747 if (rcode != 0) {
733 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name); 748 printk(KERN_WARNING"%s: Bus reset failed.\n",pHba->name);
734 return FAILED; 749 return FAILED;
735 } else { 750 } else {
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 5b9c2c5a7f0e..66783c860a19 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -347,17 +347,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
347 shost->cmd_per_lun = sht->cmd_per_lun; 347 shost->cmd_per_lun = sht->cmd_per_lun;
348 shost->unchecked_isa_dma = sht->unchecked_isa_dma; 348 shost->unchecked_isa_dma = sht->unchecked_isa_dma;
349 shost->use_clustering = sht->use_clustering; 349 shost->use_clustering = sht->use_clustering;
350 shost->ordered_flush = sht->ordered_flush;
351 shost->ordered_tag = sht->ordered_tag; 350 shost->ordered_tag = sht->ordered_tag;
352 351
353 /*
354 * hosts/devices that do queueing must support ordered tags
355 */
356 if (shost->can_queue > 1 && shost->ordered_flush) {
357 printk(KERN_ERR "scsi: ordered flushes don't support queueing\n");
358 shost->ordered_flush = 0;
359 }
360
361 if (sht->max_host_blocked) 352 if (sht->max_host_blocked)
362 shost->max_host_blocked = sht->max_host_blocked; 353 shost->max_host_blocked = sht->max_host_blocked;
363 else 354 else
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.h b/drivers/scsi/ibmvscsi/ibmvscsi.h
index 8bec0438dc8a..5b0edd1f1921 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.h
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.h
@@ -100,7 +100,7 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
100void ibmvscsi_release_crq_queue(struct crq_queue *queue, 100void ibmvscsi_release_crq_queue(struct crq_queue *queue,
101 struct ibmvscsi_host_data *hostdata, 101 struct ibmvscsi_host_data *hostdata,
102 int max_requests); 102 int max_requests);
103void ibmvscsi_reset_crq_queue(struct crq_queue *queue, 103int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
104 struct ibmvscsi_host_data *hostdata); 104 struct ibmvscsi_host_data *hostdata);
105 105
106void ibmvscsi_handle_crq(struct viosrp_crq *crq, 106void ibmvscsi_handle_crq(struct viosrp_crq *crq,
diff --git a/drivers/scsi/ibmvscsi/iseries_vscsi.c b/drivers/scsi/ibmvscsi/iseries_vscsi.c
index 1045872b0175..ce15d9e39621 100644
--- a/drivers/scsi/ibmvscsi/iseries_vscsi.c
+++ b/drivers/scsi/ibmvscsi/iseries_vscsi.c
@@ -117,9 +117,10 @@ void ibmvscsi_release_crq_queue(struct crq_queue *queue,
117 * 117 *
118 * no-op for iSeries 118 * no-op for iSeries
119 */ 119 */
120void ibmvscsi_reset_crq_queue(struct crq_queue *queue, 120int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
121 struct ibmvscsi_host_data *hostdata) 121 struct ibmvscsi_host_data *hostdata)
122{ 122{
123 return 0;
123} 124}
124 125
125/** 126/**
diff --git a/drivers/scsi/ibmvscsi/rpa_vscsi.c b/drivers/scsi/ibmvscsi/rpa_vscsi.c
index 8bf5652f1060..75db2f5c545e 100644
--- a/drivers/scsi/ibmvscsi/rpa_vscsi.c
+++ b/drivers/scsi/ibmvscsi/rpa_vscsi.c
@@ -230,6 +230,11 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
230 rc = plpar_hcall_norets(H_REG_CRQ, 230 rc = plpar_hcall_norets(H_REG_CRQ,
231 vdev->unit_address, 231 vdev->unit_address,
232 queue->msg_token, PAGE_SIZE); 232 queue->msg_token, PAGE_SIZE);
233 if (rc == H_Resource)
234 /* maybe kexecing and resource is busy. try a reset */
235 rc = ibmvscsi_reset_crq_queue(queue,
236 hostdata);
237
233 if (rc == 2) { 238 if (rc == 2) {
234 /* Adapter is good, but other end is not ready */ 239 /* Adapter is good, but other end is not ready */
235 printk(KERN_WARNING "ibmvscsi: Partner adapter not ready\n"); 240 printk(KERN_WARNING "ibmvscsi: Partner adapter not ready\n");
@@ -281,7 +286,7 @@ int ibmvscsi_init_crq_queue(struct crq_queue *queue,
281 * @hostdata: ibmvscsi_host_data of host 286 * @hostdata: ibmvscsi_host_data of host
282 * 287 *
283 */ 288 */
284void ibmvscsi_reset_crq_queue(struct crq_queue *queue, 289int ibmvscsi_reset_crq_queue(struct crq_queue *queue,
285 struct ibmvscsi_host_data *hostdata) 290 struct ibmvscsi_host_data *hostdata)
286{ 291{
287 int rc; 292 int rc;
@@ -309,4 +314,5 @@ void ibmvscsi_reset_crq_queue(struct crq_queue *queue,
309 printk(KERN_WARNING 314 printk(KERN_WARNING
310 "ibmvscsi: couldn't register crq--rc 0x%x\n", rc); 315 "ibmvscsi: couldn't register crq--rc 0x%x\n", rc);
311 } 316 }
317 return rc;
312} 318}
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 4cb1f3ed9100..3c688ef54660 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -1046,7 +1046,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
1046 1046
1047 /* kill current request */ 1047 /* kill current request */
1048 blkdev_dequeue_request(req); 1048 blkdev_dequeue_request(req);
1049 end_that_request_last(req); 1049 end_that_request_last(req, 0);
1050 if (req->flags & REQ_SENSE) 1050 if (req->flags & REQ_SENSE)
1051 kfree(scsi->pc->buffer); 1051 kfree(scsi->pc->buffer);
1052 kfree(scsi->pc); 1052 kfree(scsi->pc);
@@ -1056,7 +1056,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
1056 /* now nuke the drive queue */ 1056 /* now nuke the drive queue */
1057 while ((req = elv_next_request(drive->queue))) { 1057 while ((req = elv_next_request(drive->queue))) {
1058 blkdev_dequeue_request(req); 1058 blkdev_dequeue_request(req);
1059 end_that_request_last(req); 1059 end_that_request_last(req, 0);
1060 } 1060 }
1061 1061
1062 HWGROUP(drive)->rq = NULL; 1062 HWGROUP(drive)->rq = NULL;
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index fa2cb3582cfa..27acf78cf8d8 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2132,7 +2132,7 @@ restart:
2132 } 2132 }
2133 2133
2134 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 2134 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2135 kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE, NULL); 2135 kobject_uevent(&ioa_cfg->host->shost_classdev.kobj, KOBJ_CHANGE);
2136 LEAVE; 2136 LEAVE;
2137} 2137}
2138 2138
@@ -5887,7 +5887,12 @@ static int __devinit ipr_probe_ioa_part2(struct ipr_ioa_cfg *ioa_cfg)
5887 ENTER; 5887 ENTER;
5888 spin_lock_irqsave(ioa_cfg->host->host_lock, host_lock_flags); 5888 spin_lock_irqsave(ioa_cfg->host->host_lock, host_lock_flags);
5889 dev_dbg(&ioa_cfg->pdev->dev, "ioa_cfg adx: 0x%p\n", ioa_cfg); 5889 dev_dbg(&ioa_cfg->pdev->dev, "ioa_cfg adx: 0x%p\n", ioa_cfg);
5890 _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_enable_ioa, IPR_SHUTDOWN_NONE); 5890 if (ioa_cfg->needs_hard_reset) {
5891 ioa_cfg->needs_hard_reset = 0;
5892 ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
5893 } else
5894 _ipr_initiate_ioa_reset(ioa_cfg, ipr_reset_enable_ioa,
5895 IPR_SHUTDOWN_NONE);
5891 5896
5892 spin_unlock_irqrestore(ioa_cfg->host->host_lock, host_lock_flags); 5897 spin_unlock_irqrestore(ioa_cfg->host->host_lock, host_lock_flags);
5893 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload); 5898 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
@@ -6264,6 +6269,7 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
6264 unsigned long ipr_regs_pci; 6269 unsigned long ipr_regs_pci;
6265 void __iomem *ipr_regs; 6270 void __iomem *ipr_regs;
6266 u32 rc = PCIBIOS_SUCCESSFUL; 6271 u32 rc = PCIBIOS_SUCCESSFUL;
6272 volatile u32 mask, uproc;
6267 6273
6268 ENTER; 6274 ENTER;
6269 6275
@@ -6356,6 +6362,15 @@ static int __devinit ipr_probe_ioa(struct pci_dev *pdev,
6356 goto cleanup_nomem; 6362 goto cleanup_nomem;
6357 } 6363 }
6358 6364
6365 /*
6366 * If HRRQ updated interrupt is not masked, or reset alert is set,
6367 * the card is in an unknown state and needs a hard reset
6368 */
6369 mask = readl(ioa_cfg->regs.sense_interrupt_mask_reg);
6370 uproc = readl(ioa_cfg->regs.sense_uproc_interrupt_reg);
6371 if ((mask & IPR_PCII_HRRQ_UPDATED) == 0 || (uproc & IPR_UPROCI_RESET_ALERT))
6372 ioa_cfg->needs_hard_reset = 1;
6373
6359 ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER); 6374 ipr_mask_and_clear_interrupts(ioa_cfg, ~IPR_PCII_IOA_TRANS_TO_OPER);
6360 rc = request_irq(pdev->irq, ipr_isr, SA_SHIRQ, IPR_NAME, ioa_cfg); 6375 rc = request_irq(pdev->irq, ipr_isr, SA_SHIRQ, IPR_NAME, ioa_cfg);
6361 6376
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 6bec673c925c..b639332131f1 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -36,8 +36,8 @@
36/* 36/*
37 * Literals 37 * Literals
38 */ 38 */
39#define IPR_DRIVER_VERSION "2.1.0" 39#define IPR_DRIVER_VERSION "2.1.1"
40#define IPR_DRIVER_DATE "(October 31, 2005)" 40#define IPR_DRIVER_DATE "(November 15, 2005)"
41 41
42/* 42/*
43 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding 43 * IPR_MAX_CMD_PER_LUN: This defines the maximum number of outstanding
@@ -922,6 +922,7 @@ struct ipr_ioa_cfg {
922 u8 dump_taken:1; 922 u8 dump_taken:1;
923 u8 allow_cmds:1; 923 u8 allow_cmds:1;
924 u8 allow_ml_add_del:1; 924 u8 allow_ml_add_del:1;
925 u8 needs_hard_reset:1;
925 926
926 enum ipr_cache_state cache_state; 927 enum ipr_cache_state cache_state;
927 u16 type; /* CCIN of the card */ 928 u16 type; /* CCIN of the card */
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 4fea3e4edaa7..10bcf42cb65c 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -49,7 +49,7 @@ MODULE_AUTHOR("Dmitry Yusupov <dmitry_yus@yahoo.com>, "
49 "Alex Aizman <itn780@yahoo.com>"); 49 "Alex Aizman <itn780@yahoo.com>");
50MODULE_DESCRIPTION("iSCSI/TCP data-path"); 50MODULE_DESCRIPTION("iSCSI/TCP data-path");
51MODULE_LICENSE("GPL"); 51MODULE_LICENSE("GPL");
52MODULE_VERSION("0:4.409"); 52MODULE_VERSION("0:4.445");
53/* #define DEBUG_TCP */ 53/* #define DEBUG_TCP */
54/* #define DEBUG_SCSI */ 54/* #define DEBUG_SCSI */
55#define DEBUG_ASSERT 55#define DEBUG_ASSERT
@@ -581,10 +581,16 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
581 crypto_digest_digest(conn->rx_tfm, &sg, 1, (u8 *)&cdgst); 581 crypto_digest_digest(conn->rx_tfm, &sg, 1, (u8 *)&cdgst);
582 rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) + 582 rdgst = *(uint32_t*)((char*)hdr + sizeof(struct iscsi_hdr) +
583 conn->in.ahslen); 583 conn->in.ahslen);
584 if (cdgst != rdgst) {
585 printk(KERN_ERR "iscsi_tcp: itt %x: hdrdgst error "
586 "recv 0x%x calc 0x%x\n", conn->in.itt, rdgst,
587 cdgst);
588 return ISCSI_ERR_HDR_DGST;
589 }
584 } 590 }
585 591
586 /* save opcode for later */ 592 /* save opcode for later */
587 conn->in.opcode = hdr->opcode; 593 conn->in.opcode = hdr->opcode & ISCSI_OPCODE_MASK;
588 594
589 /* verify itt (itt encoding: age+cid+itt) */ 595 /* verify itt (itt encoding: age+cid+itt) */
590 if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) { 596 if (hdr->itt != cpu_to_be32(ISCSI_RESERVED_TAG)) {
@@ -610,13 +616,6 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
610 conn->in.ahslen, conn->in.datalen); 616 conn->in.ahslen, conn->in.datalen);
611 617
612 if (conn->in.itt < session->cmds_max) { 618 if (conn->in.itt < session->cmds_max) {
613 if (conn->hdrdgst_en && cdgst != rdgst) {
614 printk(KERN_ERR "iscsi_tcp: itt %x: hdrdgst error "
615 "recv 0x%x calc 0x%x\n", conn->in.itt, rdgst,
616 cdgst);
617 return ISCSI_ERR_HDR_DGST;
618 }
619
620 ctask = (struct iscsi_cmd_task *)session->cmds[conn->in.itt]; 619 ctask = (struct iscsi_cmd_task *)session->cmds[conn->in.itt];
621 620
622 if (!ctask->sc) { 621 if (!ctask->sc) {
@@ -642,9 +641,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
642 switch(conn->in.opcode) { 641 switch(conn->in.opcode) {
643 case ISCSI_OP_SCSI_CMD_RSP: 642 case ISCSI_OP_SCSI_CMD_RSP:
644 BUG_ON((void*)ctask != ctask->sc->SCp.ptr); 643 BUG_ON((void*)ctask != ctask->sc->SCp.ptr);
645 if (ctask->hdr.flags & ISCSI_FLAG_CMD_WRITE) 644 if (!conn->in.datalen)
646 rc = iscsi_cmd_rsp(conn, ctask);
647 else if (!conn->in.datalen)
648 rc = iscsi_cmd_rsp(conn, ctask); 645 rc = iscsi_cmd_rsp(conn, ctask);
649 else 646 else
650 /* 647 /*
@@ -666,8 +663,7 @@ iscsi_hdr_recv(struct iscsi_conn *conn)
666 break; 663 break;
667 case ISCSI_OP_R2T: 664 case ISCSI_OP_R2T:
668 BUG_ON((void*)ctask != ctask->sc->SCp.ptr); 665 BUG_ON((void*)ctask != ctask->sc->SCp.ptr);
669 if (ctask->hdr.flags & ISCSI_FLAG_CMD_WRITE && 666 if (ctask->sc->sc_data_direction == DMA_TO_DEVICE)
670 ctask->sc->sc_data_direction == DMA_TO_DEVICE)
671 rc = iscsi_r2t_rsp(conn, ctask); 667 rc = iscsi_r2t_rsp(conn, ctask);
672 else 668 else
673 rc = ISCSI_ERR_PROTO; 669 rc = ISCSI_ERR_PROTO;
@@ -906,11 +902,20 @@ partial_sg_digest_update(struct iscsi_conn *conn, struct scatterlist *sg,
906 crypto_digest_update(conn->data_rx_tfm, &temp, 1); 902 crypto_digest_update(conn->data_rx_tfm, &temp, 1);
907} 903}
908 904
905static void
906iscsi_recv_digest_update(struct iscsi_conn *conn, char* buf, int len)
907{
908 struct scatterlist tmp;
909
910 sg_init_one(&tmp, buf, len);
911 crypto_digest_update(conn->data_rx_tfm, &tmp, 1);
912}
913
909static int iscsi_scsi_data_in(struct iscsi_conn *conn) 914static int iscsi_scsi_data_in(struct iscsi_conn *conn)
910{ 915{
911 struct iscsi_cmd_task *ctask = conn->in.ctask; 916 struct iscsi_cmd_task *ctask = conn->in.ctask;
912 struct scsi_cmnd *sc = ctask->sc; 917 struct scsi_cmnd *sc = ctask->sc;
913 struct scatterlist tmp, *sg; 918 struct scatterlist *sg;
914 int i, offset, rc = 0; 919 int i, offset, rc = 0;
915 920
916 BUG_ON((void*)ctask != sc->SCp.ptr); 921 BUG_ON((void*)ctask != sc->SCp.ptr);
@@ -924,10 +929,8 @@ static int iscsi_scsi_data_in(struct iscsi_conn *conn)
924 sc->request_bufflen, ctask->data_offset); 929 sc->request_bufflen, ctask->data_offset);
925 if (rc == -EAGAIN) 930 if (rc == -EAGAIN)
926 return rc; 931 return rc;
927 if (conn->datadgst_en) { 932 if (conn->datadgst_en)
928 sg_init_one(&tmp, sc->request_buffer, i); 933 iscsi_recv_digest_update(conn, sc->request_buffer, i);
929 crypto_digest_update(conn->data_rx_tfm, &tmp, 1);
930 }
931 rc = 0; 934 rc = 0;
932 goto done; 935 goto done;
933 } 936 }
@@ -1021,6 +1024,9 @@ iscsi_data_recv(struct iscsi_conn *conn)
1021 conn->in.hdr = &conn->hdr; 1024 conn->in.hdr = &conn->hdr;
1022 conn->senselen = (conn->data[0] << 8) | conn->data[1]; 1025 conn->senselen = (conn->data[0] << 8) | conn->data[1];
1023 rc = iscsi_cmd_rsp(conn, conn->in.ctask); 1026 rc = iscsi_cmd_rsp(conn, conn->in.ctask);
1027 if (!rc && conn->datadgst_en)
1028 iscsi_recv_digest_update(conn, conn->data,
1029 conn->in.datalen);
1024 } 1030 }
1025 break; 1031 break;
1026 case ISCSI_OP_TEXT_RSP: 1032 case ISCSI_OP_TEXT_RSP:
@@ -1045,6 +1051,11 @@ iscsi_data_recv(struct iscsi_conn *conn)
1045 rc = iscsi_recv_pdu(iscsi_handle(conn), conn->in.hdr, 1051 rc = iscsi_recv_pdu(iscsi_handle(conn), conn->in.hdr,
1046 conn->data, conn->in.datalen); 1052 conn->data, conn->in.datalen);
1047 1053
1054 if (!rc && conn->datadgst_en &&
1055 conn->in.opcode != ISCSI_OP_LOGIN_RSP)
1056 iscsi_recv_digest_update(conn, conn->data,
1057 conn->in.datalen);
1058
1048 if (mtask && conn->login_mtask != mtask) { 1059 if (mtask && conn->login_mtask != mtask) {
1049 spin_lock(&session->lock); 1060 spin_lock(&session->lock);
1050 __kfifo_put(session->mgmtpool.queue, (void*)&mtask, 1061 __kfifo_put(session->mgmtpool.queue, (void*)&mtask,
@@ -1053,6 +1064,8 @@ iscsi_data_recv(struct iscsi_conn *conn)
1053 } 1064 }
1054 } 1065 }
1055 break; 1066 break;
1067 case ISCSI_OP_ASYNC_EVENT:
1068 case ISCSI_OP_REJECT:
1056 default: 1069 default:
1057 BUG_ON(1); 1070 BUG_ON(1);
1058 } 1071 }
@@ -1114,8 +1127,7 @@ more:
1114 */ 1127 */
1115 rc = iscsi_hdr_recv(conn); 1128 rc = iscsi_hdr_recv(conn);
1116 if (!rc && conn->in.datalen) { 1129 if (!rc && conn->in.datalen) {
1117 if (conn->datadgst_en && 1130 if (conn->datadgst_en) {
1118 conn->in.opcode == ISCSI_OP_SCSI_DATA_IN) {
1119 BUG_ON(!conn->data_rx_tfm); 1131 BUG_ON(!conn->data_rx_tfm);
1120 crypto_digest_init(conn->data_rx_tfm); 1132 crypto_digest_init(conn->data_rx_tfm);
1121 } 1133 }
@@ -1127,26 +1139,24 @@ more:
1127 } 1139 }
1128 1140
1129 if (conn->in_progress == IN_PROGRESS_DDIGEST_RECV) { 1141 if (conn->in_progress == IN_PROGRESS_DDIGEST_RECV) {
1142 uint32_t recv_digest;
1130 debug_tcp("extra data_recv offset %d copy %d\n", 1143 debug_tcp("extra data_recv offset %d copy %d\n",
1131 conn->in.offset, conn->in.copy); 1144 conn->in.offset, conn->in.copy);
1132 if (conn->in.opcode == ISCSI_OP_SCSI_DATA_IN) { 1145 skb_copy_bits(conn->in.skb, conn->in.offset,
1133 uint32_t recv_digest; 1146 &recv_digest, 4);
1134 skb_copy_bits(conn->in.skb, conn->in.offset, 1147 conn->in.offset += 4;
1135 &recv_digest, 4); 1148 conn->in.copy -= 4;
1136 conn->in.offset += 4; 1149 if (recv_digest != conn->in.datadgst) {
1137 conn->in.copy -= 4; 1150 debug_tcp("iscsi_tcp: data digest error!"
1138 if (recv_digest != conn->in.datadgst) { 1151 "0x%x != 0x%x\n", recv_digest,
1139 debug_tcp("iscsi_tcp: data digest error!" 1152 conn->in.datadgst);
1140 "0x%x != 0x%x\n", recv_digest, 1153 iscsi_conn_failure(conn, ISCSI_ERR_DATA_DGST);
1141 conn->in.datadgst); 1154 return 0;
1142 iscsi_conn_failure(conn, ISCSI_ERR_DATA_DGST); 1155 } else {
1143 return 0; 1156 debug_tcp("iscsi_tcp: data digest match!"
1144 } else { 1157 "0x%x == 0x%x\n", recv_digest,
1145 debug_tcp("iscsi_tcp: data digest match!" 1158 conn->in.datadgst);
1146 "0x%x == 0x%x\n", recv_digest, 1159 conn->in_progress = IN_PROGRESS_WAIT_HEADER;
1147 conn->in.datadgst);
1148 conn->in_progress = IN_PROGRESS_WAIT_HEADER;
1149 }
1150 } 1160 }
1151 } 1161 }
1152 1162
@@ -1167,8 +1177,7 @@ more:
1167 } 1177 }
1168 conn->in.copy -= conn->in.padding; 1178 conn->in.copy -= conn->in.padding;
1169 conn->in.offset += conn->in.padding; 1179 conn->in.offset += conn->in.padding;
1170 if (conn->datadgst_en && 1180 if (conn->datadgst_en) {
1171 conn->in.opcode == ISCSI_OP_SCSI_DATA_IN) {
1172 if (conn->in.padding) { 1181 if (conn->in.padding) {
1173 debug_tcp("padding -> %d\n", conn->in.padding); 1182 debug_tcp("padding -> %d\n", conn->in.padding);
1174 memset(pad, 0, conn->in.padding); 1183 memset(pad, 0, conn->in.padding);
@@ -1237,8 +1246,9 @@ iscsi_tcp_state_change(struct sock *sk)
1237 conn = (struct iscsi_conn*)sk->sk_user_data; 1246 conn = (struct iscsi_conn*)sk->sk_user_data;
1238 session = conn->session; 1247 session = conn->session;
1239 1248
1240 if (sk->sk_state == TCP_CLOSE_WAIT || 1249 if ((sk->sk_state == TCP_CLOSE_WAIT ||
1241 sk->sk_state == TCP_CLOSE) { 1250 sk->sk_state == TCP_CLOSE) &&
1251 !atomic_read(&sk->sk_rmem_alloc)) {
1242 debug_tcp("iscsi_tcp_state_change: TCP_CLOSE|TCP_CLOSE_WAIT\n"); 1252 debug_tcp("iscsi_tcp_state_change: TCP_CLOSE|TCP_CLOSE_WAIT\n");
1243 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 1253 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
1244 } 1254 }
@@ -2389,6 +2399,15 @@ fault:
2389} 2399}
2390 2400
2391static int 2401static int
2402iscsi_change_queue_depth(struct scsi_device *sdev, int depth)
2403{
2404 if (depth > ISCSI_MAX_CMD_PER_LUN)
2405 depth = ISCSI_MAX_CMD_PER_LUN;
2406 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), depth);
2407 return sdev->queue_depth;
2408}
2409
2410static int
2392iscsi_pool_init(struct iscsi_queue *q, int max, void ***items, int item_size) 2411iscsi_pool_init(struct iscsi_queue *q, int max, void ***items, int item_size)
2393{ 2412{
2394 int i; 2413 int i;
@@ -2853,8 +2872,11 @@ iscsi_conn_stop(iscsi_connh_t connh, int flag)
2853 * in hdr_extract() and will be re-negotiated at 2872 * in hdr_extract() and will be re-negotiated at
2854 * set_param() time. 2873 * set_param() time.
2855 */ 2874 */
2856 if (flag == STOP_CONN_RECOVER) 2875 if (flag == STOP_CONN_RECOVER) {
2857 conn->hdr_size = sizeof(struct iscsi_hdr); 2876 conn->hdr_size = sizeof(struct iscsi_hdr);
2877 conn->hdrdgst_en = 0;
2878 conn->datadgst_en = 0;
2879 }
2858 } 2880 }
2859 up(&conn->xmitsema); 2881 up(&conn->xmitsema);
2860} 2882}
@@ -3247,13 +3269,14 @@ iscsi_r2tpool_free(struct iscsi_session *session)
3247static struct scsi_host_template iscsi_sht = { 3269static struct scsi_host_template iscsi_sht = {
3248 .name = "iSCSI Initiator over TCP/IP, v." 3270 .name = "iSCSI Initiator over TCP/IP, v."
3249 ISCSI_VERSION_STR, 3271 ISCSI_VERSION_STR,
3250 .queuecommand = iscsi_queuecommand, 3272 .queuecommand = iscsi_queuecommand,
3273 .change_queue_depth = iscsi_change_queue_depth,
3251 .can_queue = ISCSI_XMIT_CMDS_MAX - 1, 3274 .can_queue = ISCSI_XMIT_CMDS_MAX - 1,
3252 .sg_tablesize = ISCSI_SG_TABLESIZE, 3275 .sg_tablesize = ISCSI_SG_TABLESIZE,
3253 .cmd_per_lun = ISCSI_CMD_PER_LUN, 3276 .cmd_per_lun = ISCSI_DEF_CMD_PER_LUN,
3254 .eh_abort_handler = iscsi_eh_abort, 3277 .eh_abort_handler = iscsi_eh_abort,
3255 .eh_host_reset_handler = iscsi_eh_host_reset, 3278 .eh_host_reset_handler = iscsi_eh_host_reset,
3256 .use_clustering = DISABLE_CLUSTERING, 3279 .use_clustering = DISABLE_CLUSTERING,
3257 .proc_name = "iscsi_tcp", 3280 .proc_name = "iscsi_tcp",
3258 .this_id = -1, 3281 .this_id = -1,
3259}; 3282};
@@ -3368,7 +3391,7 @@ iscsi_conn_set_param(iscsi_connh_t connh, enum iscsi_param param,
3368 switch(param) { 3391 switch(param) {
3369 case ISCSI_PARAM_MAX_RECV_DLENGTH: { 3392 case ISCSI_PARAM_MAX_RECV_DLENGTH: {
3370 char *saveptr = conn->data; 3393 char *saveptr = conn->data;
3371 int flags = GFP_KERNEL; 3394 gfp_t flags = GFP_KERNEL;
3372 3395
3373 if (conn->data_size >= value) { 3396 if (conn->data_size >= value) {
3374 conn->max_recv_dlength = value; 3397 conn->max_recv_dlength = value;
diff --git a/drivers/scsi/iscsi_tcp.h b/drivers/scsi/iscsi_tcp.h
index d23ae68fae0d..855f2dfd18af 100644
--- a/drivers/scsi/iscsi_tcp.h
+++ b/drivers/scsi/iscsi_tcp.h
@@ -71,7 +71,8 @@
71#define ISCSI_MGMT_CMDS_MAX 32 /* must be power of 2 */ 71#define ISCSI_MGMT_CMDS_MAX 32 /* must be power of 2 */
72#define ISCSI_MGMT_ITT_OFFSET 0xa00 72#define ISCSI_MGMT_ITT_OFFSET 0xa00
73#define ISCSI_SG_TABLESIZE SG_ALL 73#define ISCSI_SG_TABLESIZE SG_ALL
74#define ISCSI_CMD_PER_LUN 128 74#define ISCSI_DEF_CMD_PER_LUN 32
75#define ISCSI_MAX_CMD_PER_LUN 128
75#define ISCSI_TCP_MAX_CMD_LEN 16 76#define ISCSI_TCP_MAX_CMD_LEN 16
76 77
77#define ITT_MASK (0xfff) 78#define ITT_MASK (0xfff)
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 665ae79e1fd6..f55b9b3f7b37 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -562,16 +562,28 @@ static const u8 ata_rw_cmds[] = {
562 ATA_CMD_WRITE_MULTI, 562 ATA_CMD_WRITE_MULTI,
563 ATA_CMD_READ_MULTI_EXT, 563 ATA_CMD_READ_MULTI_EXT,
564 ATA_CMD_WRITE_MULTI_EXT, 564 ATA_CMD_WRITE_MULTI_EXT,
565 0,
566 0,
567 0,
568 ATA_CMD_WRITE_MULTI_FUA_EXT,
565 /* pio */ 569 /* pio */
566 ATA_CMD_PIO_READ, 570 ATA_CMD_PIO_READ,
567 ATA_CMD_PIO_WRITE, 571 ATA_CMD_PIO_WRITE,
568 ATA_CMD_PIO_READ_EXT, 572 ATA_CMD_PIO_READ_EXT,
569 ATA_CMD_PIO_WRITE_EXT, 573 ATA_CMD_PIO_WRITE_EXT,
574 0,
575 0,
576 0,
577 0,
570 /* dma */ 578 /* dma */
571 ATA_CMD_READ, 579 ATA_CMD_READ,
572 ATA_CMD_WRITE, 580 ATA_CMD_WRITE,
573 ATA_CMD_READ_EXT, 581 ATA_CMD_READ_EXT,
574 ATA_CMD_WRITE_EXT 582 ATA_CMD_WRITE_EXT,
583 0,
584 0,
585 0,
586 ATA_CMD_WRITE_FUA_EXT
575}; 587};
576 588
577/** 589/**
@@ -584,28 +596,35 @@ static const u8 ata_rw_cmds[] = {
584 * LOCKING: 596 * LOCKING:
585 * caller. 597 * caller.
586 */ 598 */
587void ata_rwcmd_protocol(struct ata_queued_cmd *qc) 599int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
588{ 600{
589 struct ata_taskfile *tf = &qc->tf; 601 struct ata_taskfile *tf = &qc->tf;
590 struct ata_device *dev = qc->dev; 602 struct ata_device *dev = qc->dev;
603 u8 cmd;
591 604
592 int index, lba48, write; 605 int index, fua, lba48, write;
593 606
607 fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0;
594 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0; 608 lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0;
595 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0; 609 write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0;
596 610
597 if (dev->flags & ATA_DFLAG_PIO) { 611 if (dev->flags & ATA_DFLAG_PIO) {
598 tf->protocol = ATA_PROT_PIO; 612 tf->protocol = ATA_PROT_PIO;
599 index = dev->multi_count ? 0 : 4; 613 index = dev->multi_count ? 0 : 8;
600 } else { 614 } else {
601 tf->protocol = ATA_PROT_DMA; 615 tf->protocol = ATA_PROT_DMA;
602 index = 8; 616 index = 16;
603 } 617 }
604 618
605 tf->command = ata_rw_cmds[index + lba48 + write]; 619 cmd = ata_rw_cmds[index + fua + lba48 + write];
620 if (cmd) {
621 tf->command = cmd;
622 return 0;
623 }
624 return -1;
606} 625}
607 626
608static const char * xfer_mode_str[] = { 627static const char * const xfer_mode_str[] = {
609 "UDMA/16", 628 "UDMA/16",
610 "UDMA/25", 629 "UDMA/25",
611 "UDMA/33", 630 "UDMA/33",
@@ -1046,28 +1065,103 @@ static unsigned int ata_pio_modes(const struct ata_device *adev)
1046 return modes; 1065 return modes;
1047} 1066}
1048 1067
1049static int ata_qc_wait_err(struct ata_queued_cmd *qc, 1068struct ata_exec_internal_arg {
1050 struct completion *wait) 1069 unsigned int err_mask;
1070 struct ata_taskfile *tf;
1071 struct completion *waiting;
1072};
1073
1074int ata_qc_complete_internal(struct ata_queued_cmd *qc)
1051{ 1075{
1052 int rc = 0; 1076 struct ata_exec_internal_arg *arg = qc->private_data;
1077 struct completion *waiting = arg->waiting;
1053 1078
1054 if (wait_for_completion_timeout(wait, 30 * HZ) < 1) { 1079 if (!(qc->err_mask & ~AC_ERR_DEV))
1055 /* timeout handling */ 1080 qc->ap->ops->tf_read(qc->ap, arg->tf);
1056 unsigned int err_mask = ac_err_mask(ata_chk_status(qc->ap)); 1081 arg->err_mask = qc->err_mask;
1082 arg->waiting = NULL;
1083 complete(waiting);
1057 1084
1058 if (!err_mask) { 1085 return 0;
1059 printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n", 1086}
1060 qc->ap->id, qc->tf.command); 1087
1061 } else { 1088/**
1062 printk(KERN_WARNING "ata%u: qc timeout (cmd %x)\n", 1089 * ata_exec_internal - execute libata internal command
1063 qc->ap->id, qc->tf.command); 1090 * @ap: Port to which the command is sent
1064 rc = -EIO; 1091 * @dev: Device to which the command is sent
1092 * @tf: Taskfile registers for the command and the result
1093 * @dma_dir: Data tranfer direction of the command
1094 * @buf: Data buffer of the command
1095 * @buflen: Length of data buffer
1096 *
1097 * Executes libata internal command with timeout. @tf contains
1098 * command on entry and result on return. Timeout and error
1099 * conditions are reported via return value. No recovery action
1100 * is taken after a command times out. It's caller's duty to
1101 * clean up after timeout.
1102 *
1103 * LOCKING:
1104 * None. Should be called with kernel context, might sleep.
1105 */
1106
1107static unsigned
1108ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
1109 struct ata_taskfile *tf,
1110 int dma_dir, void *buf, unsigned int buflen)
1111{
1112 u8 command = tf->command;
1113 struct ata_queued_cmd *qc;
1114 DECLARE_COMPLETION(wait);
1115 unsigned long flags;
1116 struct ata_exec_internal_arg arg;
1117
1118 spin_lock_irqsave(&ap->host_set->lock, flags);
1119
1120 qc = ata_qc_new_init(ap, dev);
1121 BUG_ON(qc == NULL);
1122
1123 qc->tf = *tf;
1124 qc->dma_dir = dma_dir;
1125 if (dma_dir != DMA_NONE) {
1126 ata_sg_init_one(qc, buf, buflen);
1127 qc->nsect = buflen / ATA_SECT_SIZE;
1128 }
1129
1130 arg.waiting = &wait;
1131 arg.tf = tf;
1132 qc->private_data = &arg;
1133 qc->complete_fn = ata_qc_complete_internal;
1134
1135 if (ata_qc_issue(qc))
1136 goto issue_fail;
1137
1138 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1139
1140 if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) {
1141 spin_lock_irqsave(&ap->host_set->lock, flags);
1142
1143 /* We're racing with irq here. If we lose, the
1144 * following test prevents us from completing the qc
1145 * again. If completion irq occurs after here but
1146 * before the caller cleans up, it will result in a
1147 * spurious interrupt. We can live with that.
1148 */
1149 if (arg.waiting) {
1150 qc->err_mask = AC_ERR_OTHER;
1151 ata_qc_complete(qc);
1152 printk(KERN_WARNING "ata%u: qc timeout (cmd 0x%x)\n",
1153 ap->id, command);
1065 } 1154 }
1066 1155
1067 ata_qc_complete(qc, err_mask); 1156 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1068 } 1157 }
1069 1158
1070 return rc; 1159 return arg.err_mask;
1160
1161 issue_fail:
1162 ata_qc_free(qc);
1163 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1164 return AC_ERR_OTHER;
1071} 1165}
1072 1166
1073/** 1167/**
@@ -1099,9 +1193,8 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1099 u16 tmp; 1193 u16 tmp;
1100 unsigned long xfer_modes; 1194 unsigned long xfer_modes;
1101 unsigned int using_edd; 1195 unsigned int using_edd;
1102 DECLARE_COMPLETION(wait); 1196 struct ata_taskfile tf;
1103 struct ata_queued_cmd *qc; 1197 unsigned int err_mask;
1104 unsigned long flags;
1105 int rc; 1198 int rc;
1106 1199
1107 if (!ata_dev_present(dev)) { 1200 if (!ata_dev_present(dev)) {
@@ -1122,40 +1215,26 @@ static void ata_dev_identify(struct ata_port *ap, unsigned int device)
1122 1215
1123 ata_dev_select(ap, device, 1, 1); /* select device 0/1 */ 1216 ata_dev_select(ap, device, 1, 1); /* select device 0/1 */
1124 1217
1125 qc = ata_qc_new_init(ap, dev);
1126 BUG_ON(qc == NULL);
1127
1128 ata_sg_init_one(qc, dev->id, sizeof(dev->id));
1129 qc->dma_dir = DMA_FROM_DEVICE;
1130 qc->tf.protocol = ATA_PROT_PIO;
1131 qc->nsect = 1;
1132
1133retry: 1218retry:
1219 ata_tf_init(ap, &tf, device);
1220
1134 if (dev->class == ATA_DEV_ATA) { 1221 if (dev->class == ATA_DEV_ATA) {
1135 qc->tf.command = ATA_CMD_ID_ATA; 1222 tf.command = ATA_CMD_ID_ATA;
1136 DPRINTK("do ATA identify\n"); 1223 DPRINTK("do ATA identify\n");
1137 } else { 1224 } else {
1138 qc->tf.command = ATA_CMD_ID_ATAPI; 1225 tf.command = ATA_CMD_ID_ATAPI;
1139 DPRINTK("do ATAPI identify\n"); 1226 DPRINTK("do ATAPI identify\n");
1140 } 1227 }
1141 1228
1142 qc->waiting = &wait; 1229 tf.protocol = ATA_PROT_PIO;
1143 qc->complete_fn = ata_qc_complete_noop;
1144
1145 spin_lock_irqsave(&ap->host_set->lock, flags);
1146 rc = ata_qc_issue(qc);
1147 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1148 1230
1149 if (rc) 1231 err_mask = ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
1150 goto err_out; 1232 dev->id, sizeof(dev->id));
1151 else
1152 ata_qc_wait_err(qc, &wait);
1153 1233
1154 spin_lock_irqsave(&ap->host_set->lock, flags); 1234 if (err_mask) {
1155 ap->ops->tf_read(ap, &qc->tf); 1235 if (err_mask & ~AC_ERR_DEV)
1156 spin_unlock_irqrestore(&ap->host_set->lock, flags); 1236 goto err_out;
1157 1237
1158 if (qc->tf.command & ATA_ERR) {
1159 /* 1238 /*
1160 * arg! EDD works for all test cases, but seems to return 1239 * arg! EDD works for all test cases, but seems to return
1161 * the ATA signature for some ATAPI devices. Until the 1240 * the ATA signature for some ATAPI devices. Until the
@@ -1168,13 +1247,9 @@ retry:
1168 * to have this problem. 1247 * to have this problem.
1169 */ 1248 */
1170 if ((using_edd) && (dev->class == ATA_DEV_ATA)) { 1249 if ((using_edd) && (dev->class == ATA_DEV_ATA)) {
1171 u8 err = qc->tf.feature; 1250 u8 err = tf.feature;
1172 if (err & ATA_ABORTED) { 1251 if (err & ATA_ABORTED) {
1173 dev->class = ATA_DEV_ATAPI; 1252 dev->class = ATA_DEV_ATAPI;
1174 qc->cursg = 0;
1175 qc->cursg_ofs = 0;
1176 qc->cursect = 0;
1177 qc->nsect = 1;
1178 goto retry; 1253 goto retry;
1179 } 1254 }
1180 } 1255 }
@@ -1444,11 +1519,23 @@ void __sata_phy_reset(struct ata_port *ap)
1444 } while (time_before(jiffies, timeout)); 1519 } while (time_before(jiffies, timeout));
1445 1520
1446 /* TODO: phy layer with polling, timeouts, etc. */ 1521 /* TODO: phy layer with polling, timeouts, etc. */
1447 if (sata_dev_present(ap)) 1522 sstatus = scr_read(ap, SCR_STATUS);
1523 if (sata_dev_present(ap)) {
1524 const char *speed;
1525 u32 tmp;
1526
1527 tmp = (sstatus >> 4) & 0xf;
1528 if (tmp & (1 << 0))
1529 speed = "1.5";
1530 else if (tmp & (1 << 1))
1531 speed = "3.0";
1532 else
1533 speed = "<unknown>";
1534 printk(KERN_INFO "ata%u: SATA link up %s Gbps (SStatus %X)\n",
1535 ap->id, speed, sstatus);
1448 ata_port_probe(ap); 1536 ata_port_probe(ap);
1449 else { 1537 } else {
1450 sstatus = scr_read(ap, SCR_STATUS); 1538 printk(KERN_INFO "ata%u: SATA link down (SStatus %X)\n",
1451 printk(KERN_INFO "ata%u: no device found (phy stat %08x)\n",
1452 ap->id, sstatus); 1539 ap->id, sstatus);
1453 ata_port_disable(ap); 1540 ata_port_disable(ap);
1454 } 1541 }
@@ -2071,7 +2158,7 @@ static void ata_pr_blacklisted(const struct ata_port *ap,
2071 ap->id, dev->devno); 2158 ap->id, dev->devno);
2072} 2159}
2073 2160
2074static const char * ata_dma_blacklist [] = { 2161static const char * const ata_dma_blacklist [] = {
2075 "WDC AC11000H", 2162 "WDC AC11000H",
2076 "WDC AC22100H", 2163 "WDC AC22100H",
2077 "WDC AC32500H", 2164 "WDC AC32500H",
@@ -2266,34 +2353,23 @@ static int ata_choose_xfer_mode(const struct ata_port *ap,
2266 2353
2267static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev) 2354static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
2268{ 2355{
2269 DECLARE_COMPLETION(wait); 2356 struct ata_taskfile tf;
2270 struct ata_queued_cmd *qc;
2271 int rc;
2272 unsigned long flags;
2273 2357
2274 /* set up set-features taskfile */ 2358 /* set up set-features taskfile */
2275 DPRINTK("set features - xfer mode\n"); 2359 DPRINTK("set features - xfer mode\n");
2276 2360
2277 qc = ata_qc_new_init(ap, dev); 2361 ata_tf_init(ap, &tf, dev->devno);
2278 BUG_ON(qc == NULL); 2362 tf.command = ATA_CMD_SET_FEATURES;
2279 2363 tf.feature = SETFEATURES_XFER;
2280 qc->tf.command = ATA_CMD_SET_FEATURES; 2364 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2281 qc->tf.feature = SETFEATURES_XFER; 2365 tf.protocol = ATA_PROT_NODATA;
2282 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 2366 tf.nsect = dev->xfer_mode;
2283 qc->tf.protocol = ATA_PROT_NODATA;
2284 qc->tf.nsect = dev->xfer_mode;
2285
2286 qc->waiting = &wait;
2287 qc->complete_fn = ata_qc_complete_noop;
2288
2289 spin_lock_irqsave(&ap->host_set->lock, flags);
2290 rc = ata_qc_issue(qc);
2291 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2292 2367
2293 if (rc) 2368 if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) {
2369 printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n",
2370 ap->id);
2294 ata_port_disable(ap); 2371 ata_port_disable(ap);
2295 else 2372 }
2296 ata_qc_wait_err(qc, &wait);
2297 2373
2298 DPRINTK("EXIT\n"); 2374 DPRINTK("EXIT\n");
2299} 2375}
@@ -2308,41 +2384,25 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
2308 2384
2309static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev) 2385static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
2310{ 2386{
2311 DECLARE_COMPLETION(wait); 2387 struct ata_taskfile tf;
2312 struct ata_queued_cmd *qc;
2313 unsigned long flags;
2314 int rc;
2315
2316 qc = ata_qc_new_init(ap, dev);
2317 BUG_ON(qc == NULL);
2318 2388
2319 ata_sg_init_one(qc, dev->id, sizeof(dev->id)); 2389 ata_tf_init(ap, &tf, dev->devno);
2320 qc->dma_dir = DMA_FROM_DEVICE;
2321 2390
2322 if (dev->class == ATA_DEV_ATA) { 2391 if (dev->class == ATA_DEV_ATA) {
2323 qc->tf.command = ATA_CMD_ID_ATA; 2392 tf.command = ATA_CMD_ID_ATA;
2324 DPRINTK("do ATA identify\n"); 2393 DPRINTK("do ATA identify\n");
2325 } else { 2394 } else {
2326 qc->tf.command = ATA_CMD_ID_ATAPI; 2395 tf.command = ATA_CMD_ID_ATAPI;
2327 DPRINTK("do ATAPI identify\n"); 2396 DPRINTK("do ATAPI identify\n");
2328 } 2397 }
2329 2398
2330 qc->tf.flags |= ATA_TFLAG_DEVICE; 2399 tf.flags |= ATA_TFLAG_DEVICE;
2331 qc->tf.protocol = ATA_PROT_PIO; 2400 tf.protocol = ATA_PROT_PIO;
2332 qc->nsect = 1;
2333
2334 qc->waiting = &wait;
2335 qc->complete_fn = ata_qc_complete_noop;
2336 2401
2337 spin_lock_irqsave(&ap->host_set->lock, flags); 2402 if (ata_exec_internal(ap, dev, &tf, DMA_FROM_DEVICE,
2338 rc = ata_qc_issue(qc); 2403 dev->id, sizeof(dev->id)))
2339 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2340
2341 if (rc)
2342 goto err_out; 2404 goto err_out;
2343 2405
2344 ata_qc_wait_err(qc, &wait);
2345
2346 swap_buf_le16(dev->id, ATA_ID_WORDS); 2406 swap_buf_le16(dev->id, ATA_ID_WORDS);
2347 2407
2348 ata_dump_id(dev); 2408 ata_dump_id(dev);
@@ -2351,6 +2411,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
2351 2411
2352 return; 2412 return;
2353err_out: 2413err_out:
2414 printk(KERN_ERR "ata%u: failed to reread ID, disabled\n", ap->id);
2354 ata_port_disable(ap); 2415 ata_port_disable(ap);
2355} 2416}
2356 2417
@@ -2364,10 +2425,7 @@ err_out:
2364 2425
2365static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev) 2426static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
2366{ 2427{
2367 DECLARE_COMPLETION(wait); 2428 struct ata_taskfile tf;
2368 struct ata_queued_cmd *qc;
2369 int rc;
2370 unsigned long flags;
2371 u16 sectors = dev->id[6]; 2429 u16 sectors = dev->id[6];
2372 u16 heads = dev->id[3]; 2430 u16 heads = dev->id[3];
2373 2431
@@ -2378,26 +2436,18 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
2378 /* set up init dev params taskfile */ 2436 /* set up init dev params taskfile */
2379 DPRINTK("init dev params \n"); 2437 DPRINTK("init dev params \n");
2380 2438
2381 qc = ata_qc_new_init(ap, dev); 2439 ata_tf_init(ap, &tf, dev->devno);
2382 BUG_ON(qc == NULL); 2440 tf.command = ATA_CMD_INIT_DEV_PARAMS;
2383 2441 tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
2384 qc->tf.command = ATA_CMD_INIT_DEV_PARAMS; 2442 tf.protocol = ATA_PROT_NODATA;
2385 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 2443 tf.nsect = sectors;
2386 qc->tf.protocol = ATA_PROT_NODATA; 2444 tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
2387 qc->tf.nsect = sectors;
2388 qc->tf.device |= (heads - 1) & 0x0f; /* max head = num. of heads - 1 */
2389
2390 qc->waiting = &wait;
2391 qc->complete_fn = ata_qc_complete_noop;
2392
2393 spin_lock_irqsave(&ap->host_set->lock, flags);
2394 rc = ata_qc_issue(qc);
2395 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2396 2445
2397 if (rc) 2446 if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) {
2447 printk(KERN_ERR "ata%u: failed to init parameters, disabled\n",
2448 ap->id);
2398 ata_port_disable(ap); 2449 ata_port_disable(ap);
2399 else 2450 }
2400 ata_qc_wait_err(qc, &wait);
2401 2451
2402 DPRINTK("EXIT\n"); 2452 DPRINTK("EXIT\n");
2403} 2453}
@@ -2443,7 +2493,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2443 struct scatterlist *psg = &qc->pad_sgent; 2493 struct scatterlist *psg = &qc->pad_sgent;
2444 void *addr = kmap_atomic(psg->page, KM_IRQ0); 2494 void *addr = kmap_atomic(psg->page, KM_IRQ0);
2445 memcpy(addr + psg->offset, pad_buf, qc->pad_len); 2495 memcpy(addr + psg->offset, pad_buf, qc->pad_len);
2446 kunmap_atomic(psg->page, KM_IRQ0); 2496 kunmap_atomic(addr, KM_IRQ0);
2447 } 2497 }
2448 } else { 2498 } else {
2449 if (sg_dma_len(&sg[0]) > 0) 2499 if (sg_dma_len(&sg[0]) > 0)
@@ -2717,7 +2767,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2717 if (qc->tf.flags & ATA_TFLAG_WRITE) { 2767 if (qc->tf.flags & ATA_TFLAG_WRITE) {
2718 void *addr = kmap_atomic(psg->page, KM_IRQ0); 2768 void *addr = kmap_atomic(psg->page, KM_IRQ0);
2719 memcpy(pad_buf, addr + psg->offset, qc->pad_len); 2769 memcpy(pad_buf, addr + psg->offset, qc->pad_len);
2720 kunmap_atomic(psg->page, KM_IRQ0); 2770 kunmap_atomic(addr, KM_IRQ0);
2721 } 2771 }
2722 2772
2723 sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ); 2773 sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ);
@@ -2765,7 +2815,7 @@ skip_map:
2765 * None. (grabs host lock) 2815 * None. (grabs host lock)
2766 */ 2816 */
2767 2817
2768void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) 2818void ata_poll_qc_complete(struct ata_queued_cmd *qc)
2769{ 2819{
2770 struct ata_port *ap = qc->ap; 2820 struct ata_port *ap = qc->ap;
2771 unsigned long flags; 2821 unsigned long flags;
@@ -2773,7 +2823,7 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2773 spin_lock_irqsave(&ap->host_set->lock, flags); 2823 spin_lock_irqsave(&ap->host_set->lock, flags);
2774 ap->flags &= ~ATA_FLAG_NOINTR; 2824 ap->flags &= ~ATA_FLAG_NOINTR;
2775 ata_irq_on(ap); 2825 ata_irq_on(ap);
2776 ata_qc_complete(qc, err_mask); 2826 ata_qc_complete(qc);
2777 spin_unlock_irqrestore(&ap->host_set->lock, flags); 2827 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2778} 2828}
2779 2829
@@ -2790,10 +2840,14 @@ void ata_poll_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2790 2840
2791static unsigned long ata_pio_poll(struct ata_port *ap) 2841static unsigned long ata_pio_poll(struct ata_port *ap)
2792{ 2842{
2843 struct ata_queued_cmd *qc;
2793 u8 status; 2844 u8 status;
2794 unsigned int poll_state = HSM_ST_UNKNOWN; 2845 unsigned int poll_state = HSM_ST_UNKNOWN;
2795 unsigned int reg_state = HSM_ST_UNKNOWN; 2846 unsigned int reg_state = HSM_ST_UNKNOWN;
2796 2847
2848 qc = ata_qc_from_tag(ap, ap->active_tag);
2849 assert(qc != NULL);
2850
2797 switch (ap->hsm_task_state) { 2851 switch (ap->hsm_task_state) {
2798 case HSM_ST: 2852 case HSM_ST:
2799 case HSM_ST_POLL: 2853 case HSM_ST_POLL:
@@ -2813,6 +2867,7 @@ static unsigned long ata_pio_poll(struct ata_port *ap)
2813 status = ata_chk_status(ap); 2867 status = ata_chk_status(ap);
2814 if (status & ATA_BUSY) { 2868 if (status & ATA_BUSY) {
2815 if (time_after(jiffies, ap->pio_task_timeout)) { 2869 if (time_after(jiffies, ap->pio_task_timeout)) {
2870 qc->err_mask |= AC_ERR_ATA_BUS;
2816 ap->hsm_task_state = HSM_ST_TMOUT; 2871 ap->hsm_task_state = HSM_ST_TMOUT;
2817 return 0; 2872 return 0;
2818 } 2873 }
@@ -2847,29 +2902,31 @@ static int ata_pio_complete (struct ata_port *ap)
2847 * msecs, then chk-status again. If still busy, fall back to 2902 * msecs, then chk-status again. If still busy, fall back to
2848 * HSM_ST_POLL state. 2903 * HSM_ST_POLL state.
2849 */ 2904 */
2850 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); 2905 drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
2851 if (drv_stat & (ATA_BUSY | ATA_DRQ)) { 2906 if (drv_stat & ATA_BUSY) {
2852 msleep(2); 2907 msleep(2);
2853 drv_stat = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 10); 2908 drv_stat = ata_busy_wait(ap, ATA_BUSY, 10);
2854 if (drv_stat & (ATA_BUSY | ATA_DRQ)) { 2909 if (drv_stat & ATA_BUSY) {
2855 ap->hsm_task_state = HSM_ST_LAST_POLL; 2910 ap->hsm_task_state = HSM_ST_LAST_POLL;
2856 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO; 2911 ap->pio_task_timeout = jiffies + ATA_TMOUT_PIO;
2857 return 0; 2912 return 0;
2858 } 2913 }
2859 } 2914 }
2860 2915
2916 qc = ata_qc_from_tag(ap, ap->active_tag);
2917 assert(qc != NULL);
2918
2861 drv_stat = ata_wait_idle(ap); 2919 drv_stat = ata_wait_idle(ap);
2862 if (!ata_ok(drv_stat)) { 2920 if (!ata_ok(drv_stat)) {
2921 qc->err_mask |= __ac_err_mask(drv_stat);
2863 ap->hsm_task_state = HSM_ST_ERR; 2922 ap->hsm_task_state = HSM_ST_ERR;
2864 return 0; 2923 return 0;
2865 } 2924 }
2866 2925
2867 qc = ata_qc_from_tag(ap, ap->active_tag);
2868 assert(qc != NULL);
2869
2870 ap->hsm_task_state = HSM_ST_IDLE; 2926 ap->hsm_task_state = HSM_ST_IDLE;
2871 2927
2872 ata_poll_qc_complete(qc, 0); 2928 assert(qc->err_mask == 0);
2929 ata_poll_qc_complete(qc);
2873 2930
2874 /* another command may start at this point */ 2931 /* another command may start at this point */
2875 2932
@@ -3177,6 +3234,7 @@ static void atapi_pio_bytes(struct ata_queued_cmd *qc)
3177err_out: 3234err_out:
3178 printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n", 3235 printk(KERN_INFO "ata%u: dev %u: ATAPI check failed\n",
3179 ap->id, dev->devno); 3236 ap->id, dev->devno);
3237 qc->err_mask |= AC_ERR_ATA_BUS;
3180 ap->hsm_task_state = HSM_ST_ERR; 3238 ap->hsm_task_state = HSM_ST_ERR;
3181} 3239}
3182 3240
@@ -3215,8 +3273,16 @@ static void ata_pio_block(struct ata_port *ap)
3215 qc = ata_qc_from_tag(ap, ap->active_tag); 3273 qc = ata_qc_from_tag(ap, ap->active_tag);
3216 assert(qc != NULL); 3274 assert(qc != NULL);
3217 3275
3276 /* check error */
3277 if (status & (ATA_ERR | ATA_DF)) {
3278 qc->err_mask |= AC_ERR_DEV;
3279 ap->hsm_task_state = HSM_ST_ERR;
3280 return;
3281 }
3282
3283 /* transfer data if any */
3218 if (is_atapi_taskfile(&qc->tf)) { 3284 if (is_atapi_taskfile(&qc->tf)) {
3219 /* no more data to transfer or unsupported ATAPI command */ 3285 /* DRQ=0 means no more data to transfer */
3220 if ((status & ATA_DRQ) == 0) { 3286 if ((status & ATA_DRQ) == 0) {
3221 ap->hsm_task_state = HSM_ST_LAST; 3287 ap->hsm_task_state = HSM_ST_LAST;
3222 return; 3288 return;
@@ -3226,6 +3292,7 @@ static void ata_pio_block(struct ata_port *ap)
3226 } else { 3292 } else {
3227 /* handle BSY=0, DRQ=0 as error */ 3293 /* handle BSY=0, DRQ=0 as error */
3228 if ((status & ATA_DRQ) == 0) { 3294 if ((status & ATA_DRQ) == 0) {
3295 qc->err_mask |= AC_ERR_ATA_BUS;
3229 ap->hsm_task_state = HSM_ST_ERR; 3296 ap->hsm_task_state = HSM_ST_ERR;
3230 return; 3297 return;
3231 } 3298 }
@@ -3243,9 +3310,14 @@ static void ata_pio_error(struct ata_port *ap)
3243 qc = ata_qc_from_tag(ap, ap->active_tag); 3310 qc = ata_qc_from_tag(ap, ap->active_tag);
3244 assert(qc != NULL); 3311 assert(qc != NULL);
3245 3312
3313 /* make sure qc->err_mask is available to
3314 * know what's wrong and recover
3315 */
3316 assert(qc->err_mask);
3317
3246 ap->hsm_task_state = HSM_ST_IDLE; 3318 ap->hsm_task_state = HSM_ST_IDLE;
3247 3319
3248 ata_poll_qc_complete(qc, AC_ERR_ATA_BUS); 3320 ata_poll_qc_complete(qc);
3249} 3321}
3250 3322
3251static void ata_pio_task(void *_data) 3323static void ata_pio_task(void *_data)
@@ -3347,7 +3419,8 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3347 ap->id, qc->tf.command, drv_stat, host_stat); 3419 ap->id, qc->tf.command, drv_stat, host_stat);
3348 3420
3349 /* complete taskfile transaction */ 3421 /* complete taskfile transaction */
3350 ata_qc_complete(qc, ac_err_mask(drv_stat)); 3422 qc->err_mask |= ac_err_mask(drv_stat);
3423 ata_qc_complete(qc);
3351 break; 3424 break;
3352 } 3425 }
3353 3426
@@ -3446,15 +3519,10 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3446 return qc; 3519 return qc;
3447} 3520}
3448 3521
3449int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask)
3450{
3451 return 0;
3452}
3453
3454static void __ata_qc_complete(struct ata_queued_cmd *qc) 3522static void __ata_qc_complete(struct ata_queued_cmd *qc)
3455{ 3523{
3456 struct ata_port *ap = qc->ap; 3524 struct ata_port *ap = qc->ap;
3457 unsigned int tag, do_clear = 0; 3525 unsigned int tag;
3458 3526
3459 qc->flags = 0; 3527 qc->flags = 0;
3460 tag = qc->tag; 3528 tag = qc->tag;
@@ -3462,17 +3530,8 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
3462 if (tag == ap->active_tag) 3530 if (tag == ap->active_tag)
3463 ap->active_tag = ATA_TAG_POISON; 3531 ap->active_tag = ATA_TAG_POISON;
3464 qc->tag = ATA_TAG_POISON; 3532 qc->tag = ATA_TAG_POISON;
3465 do_clear = 1;
3466 }
3467
3468 if (qc->waiting) {
3469 struct completion *waiting = qc->waiting;
3470 qc->waiting = NULL;
3471 complete(waiting);
3472 }
3473
3474 if (likely(do_clear))
3475 clear_bit(tag, &ap->qactive); 3533 clear_bit(tag, &ap->qactive);
3534 }
3476} 3535}
3477 3536
3478/** 3537/**
@@ -3488,7 +3547,6 @@ static void __ata_qc_complete(struct ata_queued_cmd *qc)
3488void ata_qc_free(struct ata_queued_cmd *qc) 3547void ata_qc_free(struct ata_queued_cmd *qc)
3489{ 3548{
3490 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */ 3549 assert(qc != NULL); /* ata_qc_from_tag _might_ return NULL */
3491 assert(qc->waiting == NULL); /* nothing should be waiting */
3492 3550
3493 __ata_qc_complete(qc); 3551 __ata_qc_complete(qc);
3494} 3552}
@@ -3505,7 +3563,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
3505 * spin_lock_irqsave(host_set lock) 3563 * spin_lock_irqsave(host_set lock)
3506 */ 3564 */
3507 3565
3508void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) 3566void ata_qc_complete(struct ata_queued_cmd *qc)
3509{ 3567{
3510 int rc; 3568 int rc;
3511 3569
@@ -3522,7 +3580,7 @@ void ata_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
3522 qc->flags &= ~ATA_QCFLAG_ACTIVE; 3580 qc->flags &= ~ATA_QCFLAG_ACTIVE;
3523 3581
3524 /* call completion callback */ 3582 /* call completion callback */
3525 rc = qc->complete_fn(qc, err_mask); 3583 rc = qc->complete_fn(qc);
3526 3584
3527 /* if callback indicates not to complete command (non-zero), 3585 /* if callback indicates not to complete command (non-zero),
3528 * return immediately 3586 * return immediately
@@ -3960,7 +4018,8 @@ inline unsigned int ata_host_intr (struct ata_port *ap,
3960 ap->ops->irq_clear(ap); 4018 ap->ops->irq_clear(ap);
3961 4019
3962 /* complete taskfile transaction */ 4020 /* complete taskfile transaction */
3963 ata_qc_complete(qc, ac_err_mask(status)); 4021 qc->err_mask |= ac_err_mask(status);
4022 ata_qc_complete(qc);
3964 break; 4023 break;
3965 4024
3966 default: 4025 default:
@@ -4054,13 +4113,17 @@ static void atapi_packet_task(void *_data)
4054 4113
4055 /* sleep-wait for BSY to clear */ 4114 /* sleep-wait for BSY to clear */
4056 DPRINTK("busy wait\n"); 4115 DPRINTK("busy wait\n");
4057 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) 4116 if (ata_busy_sleep(ap, ATA_TMOUT_CDB_QUICK, ATA_TMOUT_CDB)) {
4058 goto err_out_status; 4117 qc->err_mask |= AC_ERR_ATA_BUS;
4118 goto err_out;
4119 }
4059 4120
4060 /* make sure DRQ is set */ 4121 /* make sure DRQ is set */
4061 status = ata_chk_status(ap); 4122 status = ata_chk_status(ap);
4062 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) 4123 if ((status & (ATA_BUSY | ATA_DRQ)) != ATA_DRQ) {
4124 qc->err_mask |= AC_ERR_ATA_BUS;
4063 goto err_out; 4125 goto err_out;
4126 }
4064 4127
4065 /* send SCSI cdb */ 4128 /* send SCSI cdb */
4066 DPRINTK("send cdb\n"); 4129 DPRINTK("send cdb\n");
@@ -4092,10 +4155,8 @@ static void atapi_packet_task(void *_data)
4092 4155
4093 return; 4156 return;
4094 4157
4095err_out_status:
4096 status = ata_chk_status(ap);
4097err_out: 4158err_out:
4098 ata_poll_qc_complete(qc, __ac_err_mask(status)); 4159 ata_poll_qc_complete(qc);
4099} 4160}
4100 4161
4101 4162
@@ -4112,6 +4173,96 @@ err_out:
4112 * Inherited from caller. 4173 * Inherited from caller.
4113 */ 4174 */
4114 4175
4176/*
4177 * Execute a 'simple' command, that only consists of the opcode 'cmd' itself,
4178 * without filling any other registers
4179 */
4180static int ata_do_simple_cmd(struct ata_port *ap, struct ata_device *dev,
4181 u8 cmd)
4182{
4183 struct ata_taskfile tf;
4184 int err;
4185
4186 ata_tf_init(ap, &tf, dev->devno);
4187
4188 tf.command = cmd;
4189 tf.flags |= ATA_TFLAG_DEVICE;
4190 tf.protocol = ATA_PROT_NODATA;
4191
4192 err = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
4193 if (err)
4194 printk(KERN_ERR "%s: ata command failed: %d\n",
4195 __FUNCTION__, err);
4196
4197 return err;
4198}
4199
4200static int ata_flush_cache(struct ata_port *ap, struct ata_device *dev)
4201{
4202 u8 cmd;
4203
4204 if (!ata_try_flush_cache(dev))
4205 return 0;
4206
4207 if (ata_id_has_flush_ext(dev->id))
4208 cmd = ATA_CMD_FLUSH_EXT;
4209 else
4210 cmd = ATA_CMD_FLUSH;
4211
4212 return ata_do_simple_cmd(ap, dev, cmd);
4213}
4214
4215static int ata_standby_drive(struct ata_port *ap, struct ata_device *dev)
4216{
4217 return ata_do_simple_cmd(ap, dev, ATA_CMD_STANDBYNOW1);
4218}
4219
4220static int ata_start_drive(struct ata_port *ap, struct ata_device *dev)
4221{
4222 return ata_do_simple_cmd(ap, dev, ATA_CMD_IDLEIMMEDIATE);
4223}
4224
4225/**
4226 * ata_device_resume - wakeup a previously suspended devices
4227 *
4228 * Kick the drive back into action, by sending it an idle immediate
4229 * command and making sure its transfer mode matches between drive
4230 * and host.
4231 *
4232 */
4233int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
4234{
4235 if (ap->flags & ATA_FLAG_SUSPENDED) {
4236 ap->flags &= ~ATA_FLAG_SUSPENDED;
4237 ata_set_mode(ap);
4238 }
4239 if (!ata_dev_present(dev))
4240 return 0;
4241 if (dev->class == ATA_DEV_ATA)
4242 ata_start_drive(ap, dev);
4243
4244 return 0;
4245}
4246
4247/**
4248 * ata_device_suspend - prepare a device for suspend
4249 *
4250 * Flush the cache on the drive, if appropriate, then issue a
4251 * standbynow command.
4252 *
4253 */
4254int ata_device_suspend(struct ata_port *ap, struct ata_device *dev)
4255{
4256 if (!ata_dev_present(dev))
4257 return 0;
4258 if (dev->class == ATA_DEV_ATA)
4259 ata_flush_cache(ap, dev);
4260
4261 ata_standby_drive(ap, dev);
4262 ap->flags |= ATA_FLAG_SUSPENDED;
4263 return 0;
4264}
4265
4115int ata_port_start (struct ata_port *ap) 4266int ata_port_start (struct ata_port *ap)
4116{ 4267{
4117 struct device *dev = ap->host_set->dev; 4268 struct device *dev = ap->host_set->dev;
@@ -4860,6 +5011,23 @@ int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
4860 5011
4861 return (tmp == bits->val) ? 1 : 0; 5012 return (tmp == bits->val) ? 1 : 0;
4862} 5013}
5014
5015int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state)
5016{
5017 pci_save_state(pdev);
5018 pci_disable_device(pdev);
5019 pci_set_power_state(pdev, PCI_D3hot);
5020 return 0;
5021}
5022
5023int ata_pci_device_resume(struct pci_dev *pdev)
5024{
5025 pci_set_power_state(pdev, PCI_D0);
5026 pci_restore_state(pdev);
5027 pci_enable_device(pdev);
5028 pci_set_master(pdev);
5029 return 0;
5030}
4863#endif /* CONFIG_PCI */ 5031#endif /* CONFIG_PCI */
4864 5032
4865 5033
@@ -4963,4 +5131,11 @@ EXPORT_SYMBOL_GPL(ata_pci_host_stop);
4963EXPORT_SYMBOL_GPL(ata_pci_init_native_mode); 5131EXPORT_SYMBOL_GPL(ata_pci_init_native_mode);
4964EXPORT_SYMBOL_GPL(ata_pci_init_one); 5132EXPORT_SYMBOL_GPL(ata_pci_init_one);
4965EXPORT_SYMBOL_GPL(ata_pci_remove_one); 5133EXPORT_SYMBOL_GPL(ata_pci_remove_one);
5134EXPORT_SYMBOL_GPL(ata_pci_device_suspend);
5135EXPORT_SYMBOL_GPL(ata_pci_device_resume);
4966#endif /* CONFIG_PCI */ 5136#endif /* CONFIG_PCI */
5137
5138EXPORT_SYMBOL_GPL(ata_device_suspend);
5139EXPORT_SYMBOL_GPL(ata_device_resume);
5140EXPORT_SYMBOL_GPL(ata_scsi_device_suspend);
5141EXPORT_SYMBOL_GPL(ata_scsi_device_resume);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index 379e87089764..cfbceb504718 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -396,6 +396,22 @@ void ata_dump_status(unsigned id, struct ata_taskfile *tf)
396 } 396 }
397} 397}
398 398
399int ata_scsi_device_resume(struct scsi_device *sdev)
400{
401 struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
402 struct ata_device *dev = &ap->device[sdev->id];
403
404 return ata_device_resume(ap, dev);
405}
406
407int ata_scsi_device_suspend(struct scsi_device *sdev)
408{
409 struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
410 struct ata_device *dev = &ap->device[sdev->id];
411
412 return ata_device_suspend(ap, dev);
413}
414
399/** 415/**
400 * ata_to_sense_error - convert ATA error to SCSI error 416 * ata_to_sense_error - convert ATA error to SCSI error
401 * @id: ATA device number 417 * @id: ATA device number
@@ -418,7 +434,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
418 int i; 434 int i;
419 435
420 /* Based on the 3ware driver translation table */ 436 /* Based on the 3ware driver translation table */
421 static unsigned char sense_table[][4] = { 437 static const unsigned char sense_table[][4] = {
422 /* BBD|ECC|ID|MAR */ 438 /* BBD|ECC|ID|MAR */
423 {0xd1, ABORTED_COMMAND, 0x00, 0x00}, // Device busy Aborted command 439 {0xd1, ABORTED_COMMAND, 0x00, 0x00}, // Device busy Aborted command
424 /* BBD|ECC|ID */ 440 /* BBD|ECC|ID */
@@ -449,7 +465,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
449 {0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error 465 {0x80, MEDIUM_ERROR, 0x11, 0x04}, // Block marked bad Medium error, unrecovered read error
450 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark 466 {0xFF, 0xFF, 0xFF, 0xFF}, // END mark
451 }; 467 };
452 static unsigned char stat_table[][4] = { 468 static const unsigned char stat_table[][4] = {
453 /* Must be first because BUSY means no other bits valid */ 469 /* Must be first because BUSY means no other bits valid */
454 {0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now 470 {0x80, ABORTED_COMMAND, 0x47, 0x00}, // Busy, fake parity for now
455 {0x20, HARDWARE_ERROR, 0x00, 0x00}, // Device fault 471 {0x20, HARDWARE_ERROR, 0x00, 0x00}, // Device fault
@@ -1080,11 +1096,13 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1080 scsicmd[0] == WRITE_16) 1096 scsicmd[0] == WRITE_16)
1081 tf->flags |= ATA_TFLAG_WRITE; 1097 tf->flags |= ATA_TFLAG_WRITE;
1082 1098
1083 /* Calculate the SCSI LBA and transfer length. */ 1099 /* Calculate the SCSI LBA, transfer length and FUA. */
1084 switch (scsicmd[0]) { 1100 switch (scsicmd[0]) {
1085 case READ_10: 1101 case READ_10:
1086 case WRITE_10: 1102 case WRITE_10:
1087 scsi_10_lba_len(scsicmd, &block, &n_block); 1103 scsi_10_lba_len(scsicmd, &block, &n_block);
1104 if (unlikely(scsicmd[1] & (1 << 3)))
1105 tf->flags |= ATA_TFLAG_FUA;
1088 break; 1106 break;
1089 case READ_6: 1107 case READ_6:
1090 case WRITE_6: 1108 case WRITE_6:
@@ -1099,6 +1117,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1099 case READ_16: 1117 case READ_16:
1100 case WRITE_16: 1118 case WRITE_16:
1101 scsi_16_lba_len(scsicmd, &block, &n_block); 1119 scsi_16_lba_len(scsicmd, &block, &n_block);
1120 if (unlikely(scsicmd[1] & (1 << 3)))
1121 tf->flags |= ATA_TFLAG_FUA;
1102 break; 1122 break;
1103 default: 1123 default:
1104 DPRINTK("no-byte command\n"); 1124 DPRINTK("no-byte command\n");
@@ -1142,7 +1162,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1142 tf->device |= (block >> 24) & 0xf; 1162 tf->device |= (block >> 24) & 0xf;
1143 } 1163 }
1144 1164
1145 ata_rwcmd_protocol(qc); 1165 if (unlikely(ata_rwcmd_protocol(qc) < 0))
1166 goto invalid_fld;
1146 1167
1147 qc->nsect = n_block; 1168 qc->nsect = n_block;
1148 tf->nsect = n_block & 0xff; 1169 tf->nsect = n_block & 0xff;
@@ -1160,7 +1181,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1160 if ((block >> 28) || (n_block > 256)) 1181 if ((block >> 28) || (n_block > 256))
1161 goto out_of_range; 1182 goto out_of_range;
1162 1183
1163 ata_rwcmd_protocol(qc); 1184 if (unlikely(ata_rwcmd_protocol(qc) < 0))
1185 goto invalid_fld;
1164 1186
1165 /* Convert LBA to CHS */ 1187 /* Convert LBA to CHS */
1166 track = (u32)block / dev->sectors; 1188 track = (u32)block / dev->sectors;
@@ -1203,12 +1225,11 @@ nothing_to_do:
1203 return 1; 1225 return 1;
1204} 1226}
1205 1227
1206static int ata_scsi_qc_complete(struct ata_queued_cmd *qc, 1228static int ata_scsi_qc_complete(struct ata_queued_cmd *qc)
1207 unsigned int err_mask)
1208{ 1229{
1209 struct scsi_cmnd *cmd = qc->scsicmd; 1230 struct scsi_cmnd *cmd = qc->scsicmd;
1210 u8 *cdb = cmd->cmnd; 1231 u8 *cdb = cmd->cmnd;
1211 int need_sense = (err_mask != 0); 1232 int need_sense = (qc->err_mask != 0);
1212 1233
1213 /* For ATA pass thru (SAT) commands, generate a sense block if 1234 /* For ATA pass thru (SAT) commands, generate a sense block if
1214 * user mandated it or if there's an error. Note that if we 1235 * user mandated it or if there's an error. Note that if we
@@ -1532,7 +1553,7 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
1532 return 0; 1553 return 0;
1533} 1554}
1534 1555
1535static const char *inq_83_str = "Linux ATA-SCSI simulator"; 1556static const char * const inq_83_str = "Linux ATA-SCSI simulator";
1536 1557
1537/** 1558/**
1538 * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity 1559 * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
@@ -1696,6 +1717,7 @@ static unsigned int ata_msense_rw_recovery(u8 **ptr_io, const u8 *last)
1696unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf, 1717unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1697 unsigned int buflen) 1718 unsigned int buflen)
1698{ 1719{
1720 struct ata_device *dev = args->dev;
1699 u8 *scsicmd = args->cmd->cmnd, *p, *last; 1721 u8 *scsicmd = args->cmd->cmnd, *p, *last;
1700 const u8 sat_blk_desc[] = { 1722 const u8 sat_blk_desc[] = {
1701 0, 0, 0, 0, /* number of blocks: sat unspecified */ 1723 0, 0, 0, 0, /* number of blocks: sat unspecified */
@@ -1704,6 +1726,7 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1704 }; 1726 };
1705 u8 pg, spg; 1727 u8 pg, spg;
1706 unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen; 1728 unsigned int ebd, page_control, six_byte, output_len, alloc_len, minlen;
1729 u8 dpofua;
1707 1730
1708 VPRINTK("ENTER\n"); 1731 VPRINTK("ENTER\n");
1709 1732
@@ -1772,9 +1795,17 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1772 1795
1773 if (minlen < 1) 1796 if (minlen < 1)
1774 return 0; 1797 return 0;
1798
1799 dpofua = 0;
1800 if (ata_id_has_fua(args->id) && dev->flags & ATA_DFLAG_LBA48 &&
1801 (!(dev->flags & ATA_DFLAG_PIO) || dev->multi_count))
1802 dpofua = 1 << 4;
1803
1775 if (six_byte) { 1804 if (six_byte) {
1776 output_len--; 1805 output_len--;
1777 rbuf[0] = output_len; 1806 rbuf[0] = output_len;
1807 if (minlen > 2)
1808 rbuf[2] |= dpofua;
1778 if (ebd) { 1809 if (ebd) {
1779 if (minlen > 3) 1810 if (minlen > 3)
1780 rbuf[3] = sizeof(sat_blk_desc); 1811 rbuf[3] = sizeof(sat_blk_desc);
@@ -1787,6 +1818,8 @@ unsigned int ata_scsiop_mode_sense(struct ata_scsi_args *args, u8 *rbuf,
1787 rbuf[0] = output_len >> 8; 1818 rbuf[0] = output_len >> 8;
1788 if (minlen > 1) 1819 if (minlen > 1)
1789 rbuf[1] = output_len; 1820 rbuf[1] = output_len;
1821 if (minlen > 3)
1822 rbuf[3] |= dpofua;
1790 if (ebd) { 1823 if (ebd) {
1791 if (minlen > 7) 1824 if (minlen > 7)
1792 rbuf[7] = sizeof(sat_blk_desc); 1825 rbuf[7] = sizeof(sat_blk_desc);
@@ -1955,9 +1988,9 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8
1955 done(cmd); 1988 done(cmd);
1956} 1989}
1957 1990
1958static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask) 1991static int atapi_sense_complete(struct ata_queued_cmd *qc)
1959{ 1992{
1960 if (err_mask && ((err_mask & AC_ERR_DEV) == 0)) 1993 if (qc->err_mask && ((qc->err_mask & AC_ERR_DEV) == 0))
1961 /* FIXME: not quite right; we don't want the 1994 /* FIXME: not quite right; we don't want the
1962 * translation of taskfile registers into 1995 * translation of taskfile registers into
1963 * a sense descriptors, since that's only 1996 * a sense descriptors, since that's only
@@ -2015,15 +2048,18 @@ static void atapi_request_sense(struct ata_queued_cmd *qc)
2015 2048
2016 qc->complete_fn = atapi_sense_complete; 2049 qc->complete_fn = atapi_sense_complete;
2017 2050
2018 if (ata_qc_issue(qc)) 2051 if (ata_qc_issue(qc)) {
2019 ata_qc_complete(qc, AC_ERR_OTHER); 2052 qc->err_mask |= AC_ERR_OTHER;
2053 ata_qc_complete(qc);
2054 }
2020 2055
2021 DPRINTK("EXIT\n"); 2056 DPRINTK("EXIT\n");
2022} 2057}
2023 2058
2024static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask) 2059static int atapi_qc_complete(struct ata_queued_cmd *qc)
2025{ 2060{
2026 struct scsi_cmnd *cmd = qc->scsicmd; 2061 struct scsi_cmnd *cmd = qc->scsicmd;
2062 unsigned int err_mask = qc->err_mask;
2027 2063
2028 VPRINTK("ENTER, err_mask 0x%X\n", err_mask); 2064 VPRINTK("ENTER, err_mask 0x%X\n", err_mask);
2029 2065
@@ -2044,7 +2080,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2044 else { 2080 else {
2045 u8 *scsicmd = cmd->cmnd; 2081 u8 *scsicmd = cmd->cmnd;
2046 2082
2047 if (scsicmd[0] == INQUIRY) { 2083 if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) {
2048 u8 *buf = NULL; 2084 u8 *buf = NULL;
2049 unsigned int buflen; 2085 unsigned int buflen;
2050 2086
@@ -2058,9 +2094,6 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2058 * device. 2) Ensure response data format / ATAPI information 2094 * device. 2) Ensure response data format / ATAPI information
2059 * are always correct. 2095 * are always correct.
2060 */ 2096 */
2061 /* FIXME: do we ever override EVPD pages and the like, with
2062 * this code?
2063 */
2064 if (buf[2] == 0) { 2097 if (buf[2] == 0) {
2065 buf[2] = 0x5; 2098 buf[2] = 0x5;
2066 buf[3] = 0x32; 2099 buf[3] = 0x32;
@@ -2173,9 +2206,12 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
2173 if (unlikely(!ata_dev_present(dev))) 2206 if (unlikely(!ata_dev_present(dev)))
2174 return NULL; 2207 return NULL;
2175 2208
2176 if (!atapi_enabled) { 2209 if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) {
2177 if (unlikely(dev->class == ATA_DEV_ATAPI)) 2210 if (unlikely(dev->class == ATA_DEV_ATAPI)) {
2211 printk(KERN_WARNING "ata%u(%u): WARNING: ATAPI is %s, device ignored.\n",
2212 ap->id, dev->devno, atapi_enabled ? "not supported with this driver" : "disabled");
2178 return NULL; 2213 return NULL;
2214 }
2179 } 2215 }
2180 2216
2181 return dev; 2217 return dev;
@@ -2444,7 +2480,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
2444 if (xlat_func) 2480 if (xlat_func)
2445 ata_scsi_translate(ap, dev, cmd, done, xlat_func); 2481 ata_scsi_translate(ap, dev, cmd, done, xlat_func);
2446 else 2482 else
2447 ata_scsi_simulate(dev->id, cmd, done); 2483 ata_scsi_simulate(ap, dev, cmd, done);
2448 } else 2484 } else
2449 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat); 2485 ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
2450 2486
@@ -2467,14 +2503,16 @@ out_unlock:
2467 * spin_lock_irqsave(host_set lock) 2503 * spin_lock_irqsave(host_set lock)
2468 */ 2504 */
2469 2505
2470void ata_scsi_simulate(u16 *id, 2506void ata_scsi_simulate(struct ata_port *ap, struct ata_device *dev,
2471 struct scsi_cmnd *cmd, 2507 struct scsi_cmnd *cmd,
2472 void (*done)(struct scsi_cmnd *)) 2508 void (*done)(struct scsi_cmnd *))
2473{ 2509{
2474 struct ata_scsi_args args; 2510 struct ata_scsi_args args;
2475 const u8 *scsicmd = cmd->cmnd; 2511 const u8 *scsicmd = cmd->cmnd;
2476 2512
2477 args.id = id; 2513 args.ap = ap;
2514 args.dev = dev;
2515 args.id = dev->id;
2478 args.cmd = cmd; 2516 args.cmd = cmd;
2479 args.done = done; 2517 args.done = done;
2480 2518
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index 8ebaa694d18e..e03ce48b7b4b 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -32,6 +32,8 @@
32#define DRV_VERSION "1.20" /* must be exactly four chars */ 32#define DRV_VERSION "1.20" /* must be exactly four chars */
33 33
34struct ata_scsi_args { 34struct ata_scsi_args {
35 struct ata_port *ap;
36 struct ata_device *dev;
35 u16 *id; 37 u16 *id;
36 struct scsi_cmnd *cmd; 38 struct scsi_cmnd *cmd;
37 void (*done)(struct scsi_cmnd *); 39 void (*done)(struct scsi_cmnd *);
@@ -39,10 +41,9 @@ struct ata_scsi_args {
39 41
40/* libata-core.c */ 42/* libata-core.c */
41extern int atapi_enabled; 43extern int atapi_enabled;
42extern int ata_qc_complete_noop(struct ata_queued_cmd *qc, unsigned int err_mask);
43extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap, 44extern struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
44 struct ata_device *dev); 45 struct ata_device *dev);
45extern void ata_rwcmd_protocol(struct ata_queued_cmd *qc); 46extern int ata_rwcmd_protocol(struct ata_queued_cmd *qc);
46extern void ata_qc_free(struct ata_queued_cmd *qc); 47extern void ata_qc_free(struct ata_queued_cmd *qc);
47extern int ata_qc_issue(struct ata_queued_cmd *qc); 48extern int ata_qc_issue(struct ata_queued_cmd *qc);
48extern int ata_check_atapi_dma(struct ata_queued_cmd *qc); 49extern int ata_check_atapi_dma(struct ata_queued_cmd *qc);
diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
index 3062b39fbdb9..38ffa8d6e629 100644
--- a/drivers/scsi/lpfc/lpfc.h
+++ b/drivers/scsi/lpfc/lpfc.h
@@ -29,9 +29,10 @@ struct lpfc_sli2_slim;
29#define LPFC_LC_HBA_Q_DEPTH 1024 /* max cmds per low cost hba */ 29#define LPFC_LC_HBA_Q_DEPTH 1024 /* max cmds per low cost hba */
30#define LPFC_LP101_HBA_Q_DEPTH 128 /* max cmds per low cost hba */ 30#define LPFC_LP101_HBA_Q_DEPTH 128 /* max cmds per low cost hba */
31 31
32#define LPFC_CMD_PER_LUN 30 /* max outstanding cmds per lun */ 32#define LPFC_CMD_PER_LUN 3 /* max outstanding cmds per lun */
33#define LPFC_SG_SEG_CNT 64 /* sg element count per scsi cmnd */ 33#define LPFC_SG_SEG_CNT 64 /* sg element count per scsi cmnd */
34#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */ 34#define LPFC_IOCB_LIST_CNT 2250 /* list of IOCBs for fast-path usage. */
35#define LPFC_Q_RAMP_UP_INTERVAL 120 /* lun q_depth ramp up interval */
35 36
36/* Define macros for 64 bit support */ 37/* Define macros for 64 bit support */
37#define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr))) 38#define putPaddrLow(addr) ((uint32_t) (0xffffffff & (u64)(addr)))
@@ -45,6 +46,11 @@ struct lpfc_sli2_slim;
45 46
46#define MAX_HBAEVT 32 47#define MAX_HBAEVT 32
47 48
49enum lpfc_polling_flags {
50 ENABLE_FCP_RING_POLLING = 0x1,
51 DISABLE_FCP_RING_INT = 0x2
52};
53
48/* Provide DMA memory definitions the driver uses per port instance. */ 54/* Provide DMA memory definitions the driver uses per port instance. */
49struct lpfc_dmabuf { 55struct lpfc_dmabuf {
50 struct list_head list; 56 struct list_head list;
@@ -167,6 +173,7 @@ struct lpfc_hba {
167 dma_addr_t slim2p_mapping; 173 dma_addr_t slim2p_mapping;
168 uint16_t pci_cfg_value; 174 uint16_t pci_cfg_value;
169 175
176 struct semaphore hba_can_block;
170 uint32_t hba_state; 177 uint32_t hba_state;
171 178
172#define LPFC_INIT_START 1 /* Initial state after board reset */ 179#define LPFC_INIT_START 1 /* Initial state after board reset */
@@ -286,6 +293,8 @@ struct lpfc_hba {
286 uint32_t cfg_fcp_bind_method; 293 uint32_t cfg_fcp_bind_method;
287 uint32_t cfg_discovery_threads; 294 uint32_t cfg_discovery_threads;
288 uint32_t cfg_max_luns; 295 uint32_t cfg_max_luns;
296 uint32_t cfg_poll;
297 uint32_t cfg_poll_tmo;
289 uint32_t cfg_sg_seg_cnt; 298 uint32_t cfg_sg_seg_cnt;
290 uint32_t cfg_sg_dma_buf_size; 299 uint32_t cfg_sg_dma_buf_size;
291 300
@@ -337,7 +346,9 @@ struct lpfc_hba {
337#define VPD_PORT 0x8 /* valid vpd port data */ 346#define VPD_PORT 0x8 /* valid vpd port data */
338#define VPD_MASK 0xf /* mask for any vpd data */ 347#define VPD_MASK 0xf /* mask for any vpd data */
339 348
349 struct timer_list fcp_poll_timer;
340 struct timer_list els_tmofunc; 350 struct timer_list els_tmofunc;
351
341 /* 352 /*
342 * stat counters 353 * stat counters
343 */ 354 */
@@ -348,6 +359,7 @@ struct lpfc_hba {
348 struct lpfc_sysfs_mbox sysfs_mbox; 359 struct lpfc_sysfs_mbox sysfs_mbox;
349 360
350 /* fastpath list. */ 361 /* fastpath list. */
362 spinlock_t scsi_buf_list_lock;
351 struct list_head lpfc_scsi_buf_list; 363 struct list_head lpfc_scsi_buf_list;
352 uint32_t total_scsi_bufs; 364 uint32_t total_scsi_bufs;
353 struct list_head lpfc_iocb_list; 365 struct list_head lpfc_iocb_list;
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 89e8222bc7cc..5625a8c2a8fd 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -278,6 +278,71 @@ lpfc_board_online_store(struct class_device *cdev, const char *buf,
278 return -EIO; 278 return -EIO;
279} 279}
280 280
281static ssize_t
282lpfc_poll_show(struct class_device *cdev, char *buf)
283{
284 struct Scsi_Host *host = class_to_shost(cdev);
285 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
286
287 return snprintf(buf, PAGE_SIZE, "%#x\n", phba->cfg_poll);
288}
289
290static ssize_t
291lpfc_poll_store(struct class_device *cdev, const char *buf,
292 size_t count)
293{
294 struct Scsi_Host *host = class_to_shost(cdev);
295 struct lpfc_hba *phba = (struct lpfc_hba*)host->hostdata[0];
296 uint32_t creg_val;
297 uint32_t old_val;
298 int val=0;
299
300 if (!isdigit(buf[0]))
301 return -EINVAL;
302
303 if (sscanf(buf, "%i", &val) != 1)
304 return -EINVAL;
305
306 if ((val & 0x3) != val)
307 return -EINVAL;
308
309 spin_lock_irq(phba->host->host_lock);
310
311 old_val = phba->cfg_poll;
312
313 if (val & ENABLE_FCP_RING_POLLING) {
314 if ((val & DISABLE_FCP_RING_INT) &&
315 !(old_val & DISABLE_FCP_RING_INT)) {
316 creg_val = readl(phba->HCregaddr);
317 creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
318 writel(creg_val, phba->HCregaddr);
319 readl(phba->HCregaddr); /* flush */
320
321 lpfc_poll_start_timer(phba);
322 }
323 } else if (val != 0x0) {
324 spin_unlock_irq(phba->host->host_lock);
325 return -EINVAL;
326 }
327
328 if (!(val & DISABLE_FCP_RING_INT) &&
329 (old_val & DISABLE_FCP_RING_INT))
330 {
331 spin_unlock_irq(phba->host->host_lock);
332 del_timer(&phba->fcp_poll_timer);
333 spin_lock_irq(phba->host->host_lock);
334 creg_val = readl(phba->HCregaddr);
335 creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
336 writel(creg_val, phba->HCregaddr);
337 readl(phba->HCregaddr); /* flush */
338 }
339
340 phba->cfg_poll = val;
341
342 spin_unlock_irq(phba->host->host_lock);
343
344 return strlen(buf);
345}
281 346
282#define lpfc_param_show(attr) \ 347#define lpfc_param_show(attr) \
283static ssize_t \ 348static ssize_t \
@@ -416,6 +481,15 @@ static CLASS_DEVICE_ATTR(management_version, S_IRUGO, management_version_show,
416static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR, 481static CLASS_DEVICE_ATTR(board_online, S_IRUGO | S_IWUSR,
417 lpfc_board_online_show, lpfc_board_online_store); 482 lpfc_board_online_show, lpfc_board_online_store);
418 483
484static int lpfc_poll = 0;
485module_param(lpfc_poll, int, 0);
486MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
487 " 0 - none,"
488 " 1 - poll with interrupts enabled"
489 " 3 - poll and disable FCP ring interrupts");
490
491static CLASS_DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR,
492 lpfc_poll_show, lpfc_poll_store);
419 493
420/* 494/*
421# lpfc_log_verbose: Only turn this flag on if you are willing to risk being 495# lpfc_log_verbose: Only turn this flag on if you are willing to risk being
@@ -523,10 +597,10 @@ LPFC_ATTR_R(ack0, 0, 0, 1, "Enable ACK0 support");
523# is 0. Default value of cr_count is 1. The cr_count feature is disabled if 597# is 0. Default value of cr_count is 1. The cr_count feature is disabled if
524# cr_delay is set to 0. 598# cr_delay is set to 0.
525*/ 599*/
526LPFC_ATTR(cr_delay, 0, 0, 63, "A count of milliseconds after which an" 600LPFC_ATTR_RW(cr_delay, 0, 0, 63, "A count of milliseconds after which an"
527 "interrupt response is generated"); 601 "interrupt response is generated");
528 602
529LPFC_ATTR(cr_count, 1, 1, 255, "A count of I/O completions after which an" 603LPFC_ATTR_RW(cr_count, 1, 1, 255, "A count of I/O completions after which an"
530 "interrupt response is generated"); 604 "interrupt response is generated");
531 605
532/* 606/*
@@ -553,6 +627,13 @@ LPFC_ATTR(discovery_threads, 32, 1, 64, "Maximum number of ELS commands"
553LPFC_ATTR_R(max_luns, 256, 1, 32768, 627LPFC_ATTR_R(max_luns, 256, 1, 32768,
554 "Maximum number of LUNs per target driver will support"); 628 "Maximum number of LUNs per target driver will support");
555 629
630/*
631# lpfc_poll_tmo: .Milliseconds driver will wait between polling FCP ring.
632# Value range is [1,255], default value is 10.
633*/
634LPFC_ATTR_RW(poll_tmo, 10, 1, 255,
635 "Milliseconds driver will wait between polling FCP ring");
636
556struct class_device_attribute *lpfc_host_attrs[] = { 637struct class_device_attribute *lpfc_host_attrs[] = {
557 &class_device_attr_info, 638 &class_device_attr_info,
558 &class_device_attr_serialnum, 639 &class_device_attr_serialnum,
@@ -575,11 +656,15 @@ struct class_device_attribute *lpfc_host_attrs[] = {
575 &class_device_attr_lpfc_topology, 656 &class_device_attr_lpfc_topology,
576 &class_device_attr_lpfc_scan_down, 657 &class_device_attr_lpfc_scan_down,
577 &class_device_attr_lpfc_link_speed, 658 &class_device_attr_lpfc_link_speed,
659 &class_device_attr_lpfc_cr_delay,
660 &class_device_attr_lpfc_cr_count,
578 &class_device_attr_lpfc_fdmi_on, 661 &class_device_attr_lpfc_fdmi_on,
579 &class_device_attr_lpfc_max_luns, 662 &class_device_attr_lpfc_max_luns,
580 &class_device_attr_nport_evt_cnt, 663 &class_device_attr_nport_evt_cnt,
581 &class_device_attr_management_version, 664 &class_device_attr_management_version,
582 &class_device_attr_board_online, 665 &class_device_attr_board_online,
666 &class_device_attr_lpfc_poll,
667 &class_device_attr_lpfc_poll_tmo,
583 NULL, 668 NULL,
584}; 669};
585 670
@@ -1292,6 +1377,9 @@ lpfc_get_cfgparam(struct lpfc_hba *phba)
1292 lpfc_fdmi_on_init(phba, lpfc_fdmi_on); 1377 lpfc_fdmi_on_init(phba, lpfc_fdmi_on);
1293 lpfc_discovery_threads_init(phba, lpfc_discovery_threads); 1378 lpfc_discovery_threads_init(phba, lpfc_discovery_threads);
1294 lpfc_max_luns_init(phba, lpfc_max_luns); 1379 lpfc_max_luns_init(phba, lpfc_max_luns);
1380 lpfc_poll_tmo_init(phba, lpfc_poll_tmo);
1381
1382 phba->cfg_poll = lpfc_poll;
1295 1383
1296 /* 1384 /*
1297 * The total number of segments is the configuration value plus 2 1385 * The total number of segments is the configuration value plus 2
diff --git a/drivers/scsi/lpfc/lpfc_crtn.h b/drivers/scsi/lpfc/lpfc_crtn.h
index d527d05a607f..f1e708946e66 100644
--- a/drivers/scsi/lpfc/lpfc_crtn.h
+++ b/drivers/scsi/lpfc/lpfc_crtn.h
@@ -143,6 +143,9 @@ LPFC_MBOXQ_t *lpfc_mbox_get(struct lpfc_hba *);
143int lpfc_mem_alloc(struct lpfc_hba *); 143int lpfc_mem_alloc(struct lpfc_hba *);
144void lpfc_mem_free(struct lpfc_hba *); 144void lpfc_mem_free(struct lpfc_hba *);
145 145
146void lpfc_poll_timeout(unsigned long ptr);
147void lpfc_poll_start_timer(struct lpfc_hba * phba);
148void lpfc_sli_poll_fcp_ring(struct lpfc_hba * hba);
146struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *); 149struct lpfc_iocbq * lpfc_sli_get_iocbq(struct lpfc_hba *);
147void lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb); 150void lpfc_sli_release_iocbq(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
148uint16_t lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocb); 151uint16_t lpfc_sli_next_iotag(struct lpfc_hba * phba, struct lpfc_iocbq * iocb);
diff --git a/drivers/scsi/lpfc/lpfc_disc.h b/drivers/scsi/lpfc/lpfc_disc.h
index 084e7628ce17..ed6c81660e03 100644
--- a/drivers/scsi/lpfc/lpfc_disc.h
+++ b/drivers/scsi/lpfc/lpfc_disc.h
@@ -73,6 +73,8 @@ struct lpfc_nodelist {
73 struct lpfc_hba *nlp_phba; 73 struct lpfc_hba *nlp_phba;
74 struct lpfc_work_evt nodev_timeout_evt; 74 struct lpfc_work_evt nodev_timeout_evt;
75 struct lpfc_work_evt els_retry_evt; 75 struct lpfc_work_evt els_retry_evt;
76 unsigned long last_ramp_up_time; /* jiffy of last ramp up */
77 unsigned long last_q_full_time; /* jiffy of last queue full */
76}; 78};
77 79
78/* Defines for nlp_flag (uint32) */ 80/* Defines for nlp_flag (uint32) */
diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c
index bcc29ec126dc..20f1a0713db2 100644
--- a/drivers/scsi/lpfc/lpfc_els.c
+++ b/drivers/scsi/lpfc/lpfc_els.c
@@ -720,6 +720,7 @@ lpfc_cmpl_els_plogi(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
720 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 720 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
721 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 721 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
722 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 722 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
723 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) ||
723 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 724 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) {
724 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); 725 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
725 } 726 }
@@ -869,6 +870,7 @@ lpfc_cmpl_els_prli(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
869 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 870 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
870 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 871 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
871 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 872 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
873 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) ||
872 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 874 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) {
873 goto out; 875 goto out;
874 } 876 }
@@ -1054,6 +1056,7 @@ lpfc_cmpl_els_adisc(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1054 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 1056 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
1055 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1057 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
1056 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 1058 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
1059 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) ||
1057 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 1060 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) {
1058 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC); 1061 disc = (ndlp->nlp_flag & NLP_NPR_2B_DISC);
1059 } 1062 }
@@ -1205,6 +1208,7 @@ lpfc_cmpl_els_logo(struct lpfc_hba * phba, struct lpfc_iocbq * cmdiocb,
1205 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */ 1208 /* Do not call DSM for lpfc_els_abort'ed ELS cmds */
1206 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && 1209 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) &&
1207 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) || 1210 ((irsp->un.ulpWord[4] == IOERR_SLI_ABORTED) ||
1211 (irsp->un.ulpWord[4] == IOERR_LINK_DOWN) ||
1208 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) { 1212 (irsp->un.ulpWord[4] == IOERR_SLI_DOWN))) {
1209 goto out; 1213 goto out;
1210 } 1214 }
diff --git a/drivers/scsi/lpfc/lpfc_hbadisc.c b/drivers/scsi/lpfc/lpfc_hbadisc.c
index 259eeb161b82..a1f751e79405 100644
--- a/drivers/scsi/lpfc/lpfc_hbadisc.c
+++ b/drivers/scsi/lpfc/lpfc_hbadisc.c
@@ -1017,12 +1017,7 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
1017 rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn); 1017 rport_ids.port_name = wwn_to_u64(ndlp->nlp_portname.u.wwn);
1018 rport_ids.port_id = ndlp->nlp_DID; 1018 rport_ids.port_id = ndlp->nlp_DID;
1019 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; 1019 rport_ids.roles = FC_RPORT_ROLE_UNKNOWN;
1020 if (ndlp->nlp_type & NLP_FCP_TARGET)
1021 rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
1022 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
1023 rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
1024 1020
1025 scsi_block_requests(phba->host);
1026 ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids); 1021 ndlp->rport = rport = fc_remote_port_add(phba->host, 0, &rport_ids);
1027 if (!rport) { 1022 if (!rport) {
1028 dev_printk(KERN_WARNING, &phba->pcidev->dev, 1023 dev_printk(KERN_WARNING, &phba->pcidev->dev,
@@ -1039,7 +1034,16 @@ lpfc_register_remote_port(struct lpfc_hba * phba,
1039 } 1034 }
1040 rdata = rport->dd_data; 1035 rdata = rport->dd_data;
1041 rdata->pnode = ndlp; 1036 rdata->pnode = ndlp;
1042 scsi_unblock_requests(phba->host); 1037
1038 if (ndlp->nlp_type & NLP_FCP_TARGET)
1039 rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET;
1040 if (ndlp->nlp_type & NLP_FCP_INITIATOR)
1041 rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR;
1042
1043
1044 if (rport_ids.roles != FC_RPORT_ROLE_UNKNOWN)
1045 fc_remote_port_rolechg(rport, rport_ids.roles);
1046
1043 1047
1044 return; 1048 return;
1045} 1049}
@@ -1053,9 +1057,7 @@ lpfc_unregister_remote_port(struct lpfc_hba * phba,
1053 1057
1054 ndlp->rport = NULL; 1058 ndlp->rport = NULL;
1055 rdata->pnode = NULL; 1059 rdata->pnode = NULL;
1056 scsi_block_requests(phba->host);
1057 fc_remote_port_delete(rport); 1060 fc_remote_port_delete(rport);
1058 scsi_unblock_requests(phba->host);
1059 1061
1060 return; 1062 return;
1061} 1063}
diff --git a/drivers/scsi/lpfc/lpfc_hw.h b/drivers/scsi/lpfc/lpfc_hw.h
index 86c41981188b..1ea565e0561f 100644
--- a/drivers/scsi/lpfc/lpfc_hw.h
+++ b/drivers/scsi/lpfc/lpfc_hw.h
@@ -266,9 +266,11 @@ struct lpfc_name {
266 struct { 266 struct {
267#ifdef __BIG_ENDIAN_BITFIELD 267#ifdef __BIG_ENDIAN_BITFIELD
268 uint8_t nameType:4; /* FC Word 0, bit 28:31 */ 268 uint8_t nameType:4; /* FC Word 0, bit 28:31 */
269 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */ 269 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit
270 8:11 of IEEE ext */
270#else /* __LITTLE_ENDIAN_BITFIELD */ 271#else /* __LITTLE_ENDIAN_BITFIELD */
271 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit 8:11 of IEEE ext */ 272 uint8_t IEEEextMsn:4; /* FC Word 0, bit 24:27, bit
273 8:11 of IEEE ext */
272 uint8_t nameType:4; /* FC Word 0, bit 28:31 */ 274 uint8_t nameType:4; /* FC Word 0, bit 28:31 */
273#endif 275#endif
274 276
@@ -278,7 +280,8 @@ struct lpfc_name {
278#define NAME_IP_TYPE 0x4 /* IP address */ 280#define NAME_IP_TYPE 0x4 /* IP address */
279#define NAME_CCITT_TYPE 0xC 281#define NAME_CCITT_TYPE 0xC
280#define NAME_CCITT_GR_TYPE 0xE 282#define NAME_CCITT_GR_TYPE 0xE
281 uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE extended Lsb */ 283 uint8_t IEEEextLsb; /* FC Word 0, bit 16:23, IEEE
284 extended Lsb */
282 uint8_t IEEE[6]; /* FC IEEE address */ 285 uint8_t IEEE[6]; /* FC IEEE address */
283 } s; 286 } s;
284 uint8_t wwn[8]; 287 uint8_t wwn[8];
@@ -1024,23 +1027,38 @@ typedef struct {
1024/* Start FireFly Register definitions */ 1027/* Start FireFly Register definitions */
1025#define PCI_VENDOR_ID_EMULEX 0x10df 1028#define PCI_VENDOR_ID_EMULEX 0x10df
1026#define PCI_DEVICE_ID_FIREFLY 0x1ae5 1029#define PCI_DEVICE_ID_FIREFLY 0x1ae5
1027#define PCI_DEVICE_ID_SUPERFLY 0xf700
1028#define PCI_DEVICE_ID_DRAGONFLY 0xf800
1029#define PCI_DEVICE_ID_RFLY 0xf095 1030#define PCI_DEVICE_ID_RFLY 0xf095
1030#define PCI_DEVICE_ID_PFLY 0xf098 1031#define PCI_DEVICE_ID_PFLY 0xf098
1032#define PCI_DEVICE_ID_LP101 0xf0a1
1031#define PCI_DEVICE_ID_TFLY 0xf0a5 1033#define PCI_DEVICE_ID_TFLY 0xf0a5
1034#define PCI_DEVICE_ID_BSMB 0xf0d1
1035#define PCI_DEVICE_ID_BMID 0xf0d5
1036#define PCI_DEVICE_ID_ZSMB 0xf0e1
1037#define PCI_DEVICE_ID_ZMID 0xf0e5
1038#define PCI_DEVICE_ID_NEPTUNE 0xf0f5
1039#define PCI_DEVICE_ID_NEPTUNE_SCSP 0xf0f6
1040#define PCI_DEVICE_ID_NEPTUNE_DCSP 0xf0f7
1041#define PCI_DEVICE_ID_SUPERFLY 0xf700
1042#define PCI_DEVICE_ID_DRAGONFLY 0xf800
1032#define PCI_DEVICE_ID_CENTAUR 0xf900 1043#define PCI_DEVICE_ID_CENTAUR 0xf900
1033#define PCI_DEVICE_ID_PEGASUS 0xf980 1044#define PCI_DEVICE_ID_PEGASUS 0xf980
1034#define PCI_DEVICE_ID_THOR 0xfa00 1045#define PCI_DEVICE_ID_THOR 0xfa00
1035#define PCI_DEVICE_ID_VIPER 0xfb00 1046#define PCI_DEVICE_ID_VIPER 0xfb00
1047#define PCI_DEVICE_ID_LP10000S 0xfc00
1048#define PCI_DEVICE_ID_LP11000S 0xfc10
1049#define PCI_DEVICE_ID_LPE11000S 0xfc20
1036#define PCI_DEVICE_ID_HELIOS 0xfd00 1050#define PCI_DEVICE_ID_HELIOS 0xfd00
1037#define PCI_DEVICE_ID_BMID 0xf0d5 1051#define PCI_DEVICE_ID_HELIOS_SCSP 0xfd11
1038#define PCI_DEVICE_ID_BSMB 0xf0d1 1052#define PCI_DEVICE_ID_HELIOS_DCSP 0xfd12
1039#define PCI_DEVICE_ID_ZEPHYR 0xfe00 1053#define PCI_DEVICE_ID_ZEPHYR 0xfe00
1040#define PCI_DEVICE_ID_ZMID 0xf0e5 1054#define PCI_DEVICE_ID_ZEPHYR_SCSP 0xfe11
1041#define PCI_DEVICE_ID_ZSMB 0xf0e1 1055#define PCI_DEVICE_ID_ZEPHYR_DCSP 0xfe12
1042#define PCI_DEVICE_ID_LP101 0xf0a1 1056
1043#define PCI_DEVICE_ID_LP10000S 0xfc00 1057#define PCI_SUBSYSTEM_ID_LP11000S 0xfc11
1058#define PCI_SUBSYSTEM_ID_LP11002S 0xfc12
1059#define PCI_SUBSYSTEM_ID_LPE11000S 0xfc21
1060#define PCI_SUBSYSTEM_ID_LPE11002S 0xfc22
1061#define PCI_SUBSYSTEM_ID_LPE11010S 0xfc2A
1044 1062
1045#define JEDEC_ID_ADDRESS 0x0080001c 1063#define JEDEC_ID_ADDRESS 0x0080001c
1046#define FIREFLY_JEDEC_ID 0x1ACC 1064#define FIREFLY_JEDEC_ID 0x1ACC
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 07498118359d..b7a603a45328 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -126,34 +126,26 @@ lpfc_config_port_prep(struct lpfc_hba * phba)
126 return -ERESTART; 126 return -ERESTART;
127 } 127 }
128 128
129 /* The HBA's current state is provided by the ProgType and rr fields. 129 /*
130 * Read and check the value of these fields before continuing to config 130 * The value of rr must be 1 since the driver set the cv field to 1.
131 * this port. 131 * This setting requires the FW to set all revision fields.
132 */ 132 */
133 if (mb->un.varRdRev.rr == 0 || mb->un.varRdRev.un.b.ProgType != 2) { 133 if (mb->un.varRdRev.rr == 0) {
134 /* Old firmware */
135 vp->rev.rBit = 0; 134 vp->rev.rBit = 0;
136 lpfc_printf_log(phba, 135 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
137 KERN_ERR, 136 "%d:0440 Adapter failed to init, READ_REV has "
138 LOG_INIT, 137 "missing revision information.\n",
139 "%d:0440 Adapter failed to init, mbxCmd x%x " 138 phba->brd_no);
140 "READ_REV detected outdated firmware"
141 "Data: x%x\n",
142 phba->brd_no,
143 mb->mbxCommand, 0);
144 mempool_free(pmb, phba->mbox_mem_pool); 139 mempool_free(pmb, phba->mbox_mem_pool);
145 return -ERESTART; 140 return -ERESTART;
146 } else {
147 vp->rev.rBit = 1;
148 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev;
149 memcpy(vp->rev.sli1FwName,
150 (char*)mb->un.varRdRev.sli1FwName, 16);
151 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev;
152 memcpy(vp->rev.sli2FwName,
153 (char *)mb->un.varRdRev.sli2FwName, 16);
154 } 141 }
155 142
156 /* Save information as VPD data */ 143 /* Save information as VPD data */
144 vp->rev.rBit = 1;
145 vp->rev.sli1FwRev = mb->un.varRdRev.sli1FwRev;
146 memcpy(vp->rev.sli1FwName, (char*) mb->un.varRdRev.sli1FwName, 16);
147 vp->rev.sli2FwRev = mb->un.varRdRev.sli2FwRev;
148 memcpy(vp->rev.sli2FwName, (char *) mb->un.varRdRev.sli2FwName, 16);
157 vp->rev.biuRev = mb->un.varRdRev.biuRev; 149 vp->rev.biuRev = mb->un.varRdRev.biuRev;
158 vp->rev.smRev = mb->un.varRdRev.smRev; 150 vp->rev.smRev = mb->un.varRdRev.smRev;
159 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev; 151 vp->rev.smFwRev = mb->un.varRdRev.un.smFwRev;
@@ -378,6 +370,10 @@ lpfc_config_port_post(struct lpfc_hba * phba)
378 if (psli->num_rings > 3) 370 if (psli->num_rings > 3)
379 status |= HC_R3INT_ENA; 371 status |= HC_R3INT_ENA;
380 372
373 if ((phba->cfg_poll & ENABLE_FCP_RING_POLLING) &&
374 (phba->cfg_poll & DISABLE_FCP_RING_INT))
375 status &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
376
381 writel(status, phba->HCregaddr); 377 writel(status, phba->HCregaddr);
382 readl(phba->HCregaddr); /* flush */ 378 readl(phba->HCregaddr); /* flush */
383 spin_unlock_irq(phba->host->host_lock); 379 spin_unlock_irq(phba->host->host_lock);
@@ -571,6 +567,8 @@ lpfc_handle_latt(struct lpfc_hba * phba)
571 567
572 rc = -EIO; 568 rc = -EIO;
573 569
570 /* Cleanup any outstanding ELS commands */
571 lpfc_els_flush_cmd(phba);
574 572
575 psli->slistat.link_event++; 573 psli->slistat.link_event++;
576 lpfc_read_la(phba, pmb, mp); 574 lpfc_read_la(phba, pmb, mp);
@@ -765,96 +763,139 @@ static void
765lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp) 763lpfc_get_hba_model_desc(struct lpfc_hba * phba, uint8_t * mdp, uint8_t * descp)
766{ 764{
767 lpfc_vpd_t *vp; 765 lpfc_vpd_t *vp;
768 uint32_t id; 766 uint16_t dev_id = phba->pcidev->device;
769 uint8_t hdrtype; 767 uint16_t dev_subid = phba->pcidev->subsystem_device;
770 char str[16]; 768 uint8_t hdrtype = phba->pcidev->hdr_type;
769 char *model_str = "";
771 770
772 vp = &phba->vpd; 771 vp = &phba->vpd;
773 pci_read_config_dword(phba->pcidev, PCI_VENDOR_ID, &id);
774 pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype);
775 772
776 switch ((id >> 16) & 0xffff) { 773 switch (dev_id) {
777 case PCI_DEVICE_ID_FIREFLY: 774 case PCI_DEVICE_ID_FIREFLY:
778 strcpy(str, "LP6000 1"); 775 model_str = "LP6000 1Gb PCI";
779 break; 776 break;
780 case PCI_DEVICE_ID_SUPERFLY: 777 case PCI_DEVICE_ID_SUPERFLY:
781 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3) 778 if (vp->rev.biuRev >= 1 && vp->rev.biuRev <= 3)
782 strcpy(str, "LP7000 1"); 779 model_str = "LP7000 1Gb PCI";
783 else 780 else
784 strcpy(str, "LP7000E 1"); 781 model_str = "LP7000E 1Gb PCI";
785 break; 782 break;
786 case PCI_DEVICE_ID_DRAGONFLY: 783 case PCI_DEVICE_ID_DRAGONFLY:
787 strcpy(str, "LP8000 1"); 784 model_str = "LP8000 1Gb PCI";
788 break; 785 break;
789 case PCI_DEVICE_ID_CENTAUR: 786 case PCI_DEVICE_ID_CENTAUR:
790 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID) 787 if (FC_JEDEC_ID(vp->rev.biuRev) == CENTAUR_2G_JEDEC_ID)
791 strcpy(str, "LP9002 2"); 788 model_str = "LP9002 2Gb PCI";
792 else 789 else
793 strcpy(str, "LP9000 1"); 790 model_str = "LP9000 1Gb PCI";
794 break; 791 break;
795 case PCI_DEVICE_ID_RFLY: 792 case PCI_DEVICE_ID_RFLY:
796 strcpy(str, "LP952 2"); 793 model_str = "LP952 2Gb PCI";
797 break; 794 break;
798 case PCI_DEVICE_ID_PEGASUS: 795 case PCI_DEVICE_ID_PEGASUS:
799 strcpy(str, "LP9802 2"); 796 model_str = "LP9802 2Gb PCI-X";
800 break; 797 break;
801 case PCI_DEVICE_ID_THOR: 798 case PCI_DEVICE_ID_THOR:
802 if (hdrtype == 0x80) 799 if (hdrtype == 0x80)
803 strcpy(str, "LP10000DC 2"); 800 model_str = "LP10000DC 2Gb 2-port PCI-X";
804 else 801 else
805 strcpy(str, "LP10000 2"); 802 model_str = "LP10000 2Gb PCI-X";
806 break; 803 break;
807 case PCI_DEVICE_ID_VIPER: 804 case PCI_DEVICE_ID_VIPER:
808 strcpy(str, "LPX1000 10"); 805 model_str = "LPX1000 10Gb PCI-X";
809 break; 806 break;
810 case PCI_DEVICE_ID_PFLY: 807 case PCI_DEVICE_ID_PFLY:
811 strcpy(str, "LP982 2"); 808 model_str = "LP982 2Gb PCI-X";
812 break; 809 break;
813 case PCI_DEVICE_ID_TFLY: 810 case PCI_DEVICE_ID_TFLY:
814 if (hdrtype == 0x80) 811 if (hdrtype == 0x80)
815 strcpy(str, "LP1050DC 2"); 812 model_str = "LP1050DC 2Gb 2-port PCI-X";
816 else 813 else
817 strcpy(str, "LP1050 2"); 814 model_str = "LP1050 2Gb PCI-X";
818 break; 815 break;
819 case PCI_DEVICE_ID_HELIOS: 816 case PCI_DEVICE_ID_HELIOS:
820 if (hdrtype == 0x80) 817 if (hdrtype == 0x80)
821 strcpy(str, "LP11002 4"); 818 model_str = "LP11002 4Gb 2-port PCI-X2";
819 else
820 model_str = "LP11000 4Gb PCI-X2";
821 break;
822 case PCI_DEVICE_ID_HELIOS_SCSP:
823 model_str = "LP11000-SP 4Gb PCI-X2";
824 break;
825 case PCI_DEVICE_ID_HELIOS_DCSP:
826 model_str = "LP11002-SP 4Gb 2-port PCI-X2";
827 break;
828 case PCI_DEVICE_ID_NEPTUNE:
829 if (hdrtype == 0x80)
830 model_str = "LPe1002 4Gb 2-port";
822 else 831 else
823 strcpy(str, "LP11000 4"); 832 model_str = "LPe1000 4Gb PCIe";
833 break;
834 case PCI_DEVICE_ID_NEPTUNE_SCSP:
835 model_str = "LPe1000-SP 4Gb PCIe";
836 break;
837 case PCI_DEVICE_ID_NEPTUNE_DCSP:
838 model_str = "LPe1002-SP 4Gb 2-port PCIe";
824 break; 839 break;
825 case PCI_DEVICE_ID_BMID: 840 case PCI_DEVICE_ID_BMID:
826 strcpy(str, "LP1150 4"); 841 model_str = "LP1150 4Gb PCI-X2";
827 break; 842 break;
828 case PCI_DEVICE_ID_BSMB: 843 case PCI_DEVICE_ID_BSMB:
829 strcpy(str, "LP111 4"); 844 model_str = "LP111 4Gb PCI-X2";
830 break; 845 break;
831 case PCI_DEVICE_ID_ZEPHYR: 846 case PCI_DEVICE_ID_ZEPHYR:
832 if (hdrtype == 0x80) 847 if (hdrtype == 0x80)
833 strcpy(str, "LPe11002 4"); 848 model_str = "LPe11002 4Gb 2-port PCIe";
834 else 849 else
835 strcpy(str, "LPe11000 4"); 850 model_str = "LPe11000 4Gb PCIe";
851 break;
852 case PCI_DEVICE_ID_ZEPHYR_SCSP:
853 model_str = "LPe11000-SP 4Gb PCIe";
854 break;
855 case PCI_DEVICE_ID_ZEPHYR_DCSP:
856 model_str = "LPe11002-SP 4Gb 2-port PCIe";
836 break; 857 break;
837 case PCI_DEVICE_ID_ZMID: 858 case PCI_DEVICE_ID_ZMID:
838 strcpy(str, "LPe1150 4"); 859 model_str = "LPe1150 4Gb PCIe";
839 break; 860 break;
840 case PCI_DEVICE_ID_ZSMB: 861 case PCI_DEVICE_ID_ZSMB:
841 strcpy(str, "LPe111 4"); 862 model_str = "LPe111 4Gb PCIe";
842 break; 863 break;
843 case PCI_DEVICE_ID_LP101: 864 case PCI_DEVICE_ID_LP101:
844 strcpy(str, "LP101 2"); 865 model_str = "LP101 2Gb PCI-X";
845 break; 866 break;
846 case PCI_DEVICE_ID_LP10000S: 867 case PCI_DEVICE_ID_LP10000S:
847 strcpy(str, "LP10000-S 2"); 868 model_str = "LP10000-S 2Gb PCI";
869 break;
870 case PCI_DEVICE_ID_LP11000S:
871 case PCI_DEVICE_ID_LPE11000S:
872 switch (dev_subid) {
873 case PCI_SUBSYSTEM_ID_LP11000S:
874 model_str = "LP11002-S 4Gb PCI-X2";
875 break;
876 case PCI_SUBSYSTEM_ID_LP11002S:
877 model_str = "LP11000-S 4Gb 2-port PCI-X2";
878 break;
879 case PCI_SUBSYSTEM_ID_LPE11000S:
880 model_str = "LPe11002-S 4Gb PCIe";
881 break;
882 case PCI_SUBSYSTEM_ID_LPE11002S:
883 model_str = "LPe11002-S 4Gb 2-port PCIe";
884 break;
885 case PCI_SUBSYSTEM_ID_LPE11010S:
886 model_str = "LPe11010-S 4Gb 10-port PCIe";
887 break;
888 default:
889 break;
890 }
848 break; 891 break;
849 default: 892 default:
850 memset(str, 0, 16);
851 break; 893 break;
852 } 894 }
853 if (mdp) 895 if (mdp)
854 sscanf(str, "%s", mdp); 896 sscanf(model_str, "%s", mdp);
855 if (descp) 897 if (descp)
856 sprintf(descp, "Emulex LightPulse %s Gigabit PCI Fibre " 898 sprintf(descp, "Emulex %s Fibre Channel Adapter", model_str);
857 "Channel Adapter", str);
858} 899}
859 900
860/**************************************************/ 901/**************************************************/
@@ -1196,6 +1237,7 @@ lpfc_stop_timer(struct lpfc_hba * phba)
1196 } 1237 }
1197 } 1238 }
1198 1239
1240 del_timer_sync(&phba->fcp_poll_timer);
1199 del_timer_sync(&phba->fc_estabtmo); 1241 del_timer_sync(&phba->fc_estabtmo);
1200 del_timer_sync(&phba->fc_disctmo); 1242 del_timer_sync(&phba->fc_disctmo);
1201 del_timer_sync(&phba->fc_fdmitmo); 1243 del_timer_sync(&phba->fc_fdmitmo);
@@ -1351,7 +1393,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1351 goto out_put_host; 1393 goto out_put_host;
1352 1394
1353 host->unique_id = phba->brd_no; 1395 host->unique_id = phba->brd_no;
1354 1396 init_MUTEX(&phba->hba_can_block);
1355 INIT_LIST_HEAD(&phba->ctrspbuflist); 1397 INIT_LIST_HEAD(&phba->ctrspbuflist);
1356 INIT_LIST_HEAD(&phba->rnidrspbuflist); 1398 INIT_LIST_HEAD(&phba->rnidrspbuflist);
1357 INIT_LIST_HEAD(&phba->freebufList); 1399 INIT_LIST_HEAD(&phba->freebufList);
@@ -1375,6 +1417,10 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1375 psli->mbox_tmo.function = lpfc_mbox_timeout; 1417 psli->mbox_tmo.function = lpfc_mbox_timeout;
1376 psli->mbox_tmo.data = (unsigned long)phba; 1418 psli->mbox_tmo.data = (unsigned long)phba;
1377 1419
1420 init_timer(&phba->fcp_poll_timer);
1421 phba->fcp_poll_timer.function = lpfc_poll_timeout;
1422 phba->fcp_poll_timer.data = (unsigned long)phba;
1423
1378 /* 1424 /*
1379 * Get all the module params for configuring this host and then 1425 * Get all the module params for configuring this host and then
1380 * establish the host parameters. 1426 * establish the host parameters.
@@ -1489,6 +1535,7 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1489 host->max_cmd_len = 16; 1535 host->max_cmd_len = 16;
1490 1536
1491 /* Initialize the list of scsi buffers used by driver for scsi IO. */ 1537 /* Initialize the list of scsi buffers used by driver for scsi IO. */
1538 spin_lock_init(&phba->scsi_buf_list_lock);
1492 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list); 1539 INIT_LIST_HEAD(&phba->lpfc_scsi_buf_list);
1493 1540
1494 host->transportt = lpfc_transport_template; 1541 host->transportt = lpfc_transport_template;
@@ -1520,6 +1567,12 @@ lpfc_pci_probe_one(struct pci_dev *pdev, const struct pci_device_id *pid)
1520 if (error) 1567 if (error)
1521 goto out_free_irq; 1568 goto out_free_irq;
1522 1569
1570 if (phba->cfg_poll & DISABLE_FCP_RING_INT) {
1571 spin_lock_irq(phba->host->host_lock);
1572 lpfc_poll_start_timer(phba);
1573 spin_unlock_irq(phba->host->host_lock);
1574 }
1575
1523 /* 1576 /*
1524 * set fixed host attributes 1577 * set fixed host attributes
1525 * Must done after lpfc_sli_hba_setup() 1578 * Must done after lpfc_sli_hba_setup()
@@ -1679,14 +1732,28 @@ static struct pci_device_id lpfc_id_table[] = {
1679 PCI_ANY_ID, PCI_ANY_ID, }, 1732 PCI_ANY_ID, PCI_ANY_ID, },
1680 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY, 1733 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_PFLY,
1681 PCI_ANY_ID, PCI_ANY_ID, }, 1734 PCI_ANY_ID, PCI_ANY_ID, },
1735 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE,
1736 PCI_ANY_ID, PCI_ANY_ID, },
1737 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_SCSP,
1738 PCI_ANY_ID, PCI_ANY_ID, },
1739 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_NEPTUNE_DCSP,
1740 PCI_ANY_ID, PCI_ANY_ID, },
1682 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS, 1741 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS,
1683 PCI_ANY_ID, PCI_ANY_ID, }, 1742 PCI_ANY_ID, PCI_ANY_ID, },
1743 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_SCSP,
1744 PCI_ANY_ID, PCI_ANY_ID, },
1745 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_HELIOS_DCSP,
1746 PCI_ANY_ID, PCI_ANY_ID, },
1684 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID, 1747 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BMID,
1685 PCI_ANY_ID, PCI_ANY_ID, }, 1748 PCI_ANY_ID, PCI_ANY_ID, },
1686 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB, 1749 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_BSMB,
1687 PCI_ANY_ID, PCI_ANY_ID, }, 1750 PCI_ANY_ID, PCI_ANY_ID, },
1688 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR, 1751 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR,
1689 PCI_ANY_ID, PCI_ANY_ID, }, 1752 PCI_ANY_ID, PCI_ANY_ID, },
1753 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_SCSP,
1754 PCI_ANY_ID, PCI_ANY_ID, },
1755 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZEPHYR_DCSP,
1756 PCI_ANY_ID, PCI_ANY_ID, },
1690 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID, 1757 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZMID,
1691 PCI_ANY_ID, PCI_ANY_ID, }, 1758 PCI_ANY_ID, PCI_ANY_ID, },
1692 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB, 1759 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_ZSMB,
@@ -1697,6 +1764,10 @@ static struct pci_device_id lpfc_id_table[] = {
1697 PCI_ANY_ID, PCI_ANY_ID, }, 1764 PCI_ANY_ID, PCI_ANY_ID, },
1698 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S, 1765 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP10000S,
1699 PCI_ANY_ID, PCI_ANY_ID, }, 1766 PCI_ANY_ID, PCI_ANY_ID, },
1767 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LP11000S,
1768 PCI_ANY_ID, PCI_ANY_ID, },
1769 {PCI_VENDOR_ID_EMULEX, PCI_DEVICE_ID_LPE11000S,
1770 PCI_ANY_ID, PCI_ANY_ID, },
1700 { 0 } 1771 { 0 }
1701}; 1772};
1702 1773
diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c
index 507a6af56f42..fbead786031f 100644
--- a/drivers/scsi/lpfc/lpfc_nportdisc.c
+++ b/drivers/scsi/lpfc/lpfc_nportdisc.c
@@ -55,55 +55,76 @@ lpfc_check_adisc(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
55 return (1); 55 return (1);
56} 56}
57 57
58
59int 58int
60lpfc_check_sparm(struct lpfc_hba * phba, 59lpfc_check_sparm(struct lpfc_hba * phba,
61 struct lpfc_nodelist * ndlp, struct serv_parm * sp, 60 struct lpfc_nodelist * ndlp, struct serv_parm * sp,
62 uint32_t class) 61 uint32_t class)
63{ 62{
64 volatile struct serv_parm *hsp = &phba->fc_sparam; 63 volatile struct serv_parm *hsp = &phba->fc_sparam;
65 /* First check for supported version */ 64 uint16_t hsp_value, ssp_value = 0;
66 65
67 /* Next check for class validity */ 66 /*
67 * The receive data field size and buffer-to-buffer receive data field
68 * size entries are 16 bits but are represented as two 8-bit fields in
69 * the driver data structure to account for rsvd bits and other control
70 * bits. Reconstruct and compare the fields as a 16-bit values before
71 * correcting the byte values.
72 */
68 if (sp->cls1.classValid) { 73 if (sp->cls1.classValid) {
69 74 hsp_value = (hsp->cls1.rcvDataSizeMsb << 8) |
70 if (sp->cls1.rcvDataSizeMsb > hsp->cls1.rcvDataSizeMsb) 75 hsp->cls1.rcvDataSizeLsb;
71 sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb; 76 ssp_value = (sp->cls1.rcvDataSizeMsb << 8) |
72 if (sp->cls1.rcvDataSizeLsb > hsp->cls1.rcvDataSizeLsb) 77 sp->cls1.rcvDataSizeLsb;
78 if (ssp_value > hsp_value) {
73 sp->cls1.rcvDataSizeLsb = hsp->cls1.rcvDataSizeLsb; 79 sp->cls1.rcvDataSizeLsb = hsp->cls1.rcvDataSizeLsb;
80 sp->cls1.rcvDataSizeMsb = hsp->cls1.rcvDataSizeMsb;
81 }
74 } else if (class == CLASS1) { 82 } else if (class == CLASS1) {
75 return (0); 83 return 0;
76 } 84 }
77 85
78 if (sp->cls2.classValid) { 86 if (sp->cls2.classValid) {
79 87 hsp_value = (hsp->cls2.rcvDataSizeMsb << 8) |
80 if (sp->cls2.rcvDataSizeMsb > hsp->cls2.rcvDataSizeMsb) 88 hsp->cls2.rcvDataSizeLsb;
81 sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb; 89 ssp_value = (sp->cls2.rcvDataSizeMsb << 8) |
82 if (sp->cls2.rcvDataSizeLsb > hsp->cls2.rcvDataSizeLsb) 90 sp->cls2.rcvDataSizeLsb;
91 if (ssp_value > hsp_value) {
83 sp->cls2.rcvDataSizeLsb = hsp->cls2.rcvDataSizeLsb; 92 sp->cls2.rcvDataSizeLsb = hsp->cls2.rcvDataSizeLsb;
93 sp->cls2.rcvDataSizeMsb = hsp->cls2.rcvDataSizeMsb;
94 }
84 } else if (class == CLASS2) { 95 } else if (class == CLASS2) {
85 return (0); 96 return 0;
86 } 97 }
87 98
88 if (sp->cls3.classValid) { 99 if (sp->cls3.classValid) {
89 100 hsp_value = (hsp->cls3.rcvDataSizeMsb << 8) |
90 if (sp->cls3.rcvDataSizeMsb > hsp->cls3.rcvDataSizeMsb) 101 hsp->cls3.rcvDataSizeLsb;
91 sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb; 102 ssp_value = (sp->cls3.rcvDataSizeMsb << 8) |
92 if (sp->cls3.rcvDataSizeLsb > hsp->cls3.rcvDataSizeLsb) 103 sp->cls3.rcvDataSizeLsb;
104 if (ssp_value > hsp_value) {
93 sp->cls3.rcvDataSizeLsb = hsp->cls3.rcvDataSizeLsb; 105 sp->cls3.rcvDataSizeLsb = hsp->cls3.rcvDataSizeLsb;
106 sp->cls3.rcvDataSizeMsb = hsp->cls3.rcvDataSizeMsb;
107 }
94 } else if (class == CLASS3) { 108 } else if (class == CLASS3) {
95 return (0); 109 return 0;
96 } 110 }
97 111
98 if (sp->cmn.bbRcvSizeMsb > hsp->cmn.bbRcvSizeMsb) 112 /*
99 sp->cmn.bbRcvSizeMsb = hsp->cmn.bbRcvSizeMsb; 113 * Preserve the upper four bits of the MSB from the PLOGI response.
100 if (sp->cmn.bbRcvSizeLsb > hsp->cmn.bbRcvSizeLsb) 114 * These bits contain the Buffer-to-Buffer State Change Number
115 * from the target and need to be passed to the FW.
116 */
117 hsp_value = (hsp->cmn.bbRcvSizeMsb << 8) | hsp->cmn.bbRcvSizeLsb;
118 ssp_value = (sp->cmn.bbRcvSizeMsb << 8) | sp->cmn.bbRcvSizeLsb;
119 if (ssp_value > hsp_value) {
101 sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb; 120 sp->cmn.bbRcvSizeLsb = hsp->cmn.bbRcvSizeLsb;
121 sp->cmn.bbRcvSizeMsb = (sp->cmn.bbRcvSizeMsb & 0xF0) |
122 (hsp->cmn.bbRcvSizeMsb & 0x0F);
123 }
102 124
103 /* If check is good, copy wwpn wwnn into ndlp */
104 memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name)); 125 memcpy(&ndlp->nlp_nodename, &sp->nodeName, sizeof (struct lpfc_name));
105 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name)); 126 memcpy(&ndlp->nlp_portname, &sp->portName, sizeof (struct lpfc_name));
106 return (1); 127 return 1;
107} 128}
108 129
109static void * 130static void *
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index c63275e66e2e..9ee8218404c0 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -41,6 +41,20 @@
41#define LPFC_ABORT_WAIT 2 41#define LPFC_ABORT_WAIT 2
42 42
43 43
44static inline void
45lpfc_block_requests(struct lpfc_hba * phba)
46{
47 down(&phba->hba_can_block);
48 scsi_block_requests(phba->host);
49}
50
51static inline void
52lpfc_unblock_requests(struct lpfc_hba * phba)
53{
54 scsi_unblock_requests(phba->host);
55 up(&phba->hba_can_block);
56}
57
44/* 58/*
45 * This routine allocates a scsi buffer, which contains all the necessary 59 * This routine allocates a scsi buffer, which contains all the necessary
46 * information needed to initiate a SCSI I/O. The non-DMAable buffer region 60 * information needed to initiate a SCSI I/O. The non-DMAable buffer region
@@ -137,18 +151,22 @@ lpfc_new_scsi_buf(struct lpfc_hba * phba)
137} 151}
138 152
139struct lpfc_scsi_buf* 153struct lpfc_scsi_buf*
140lpfc_sli_get_scsi_buf(struct lpfc_hba * phba) 154lpfc_get_scsi_buf(struct lpfc_hba * phba)
141{ 155{
142 struct lpfc_scsi_buf * lpfc_cmd = NULL; 156 struct lpfc_scsi_buf * lpfc_cmd = NULL;
143 struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list; 157 struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list;
158 unsigned long iflag = 0;
144 159
160 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag);
145 list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list); 161 list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list);
162 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag);
146 return lpfc_cmd; 163 return lpfc_cmd;
147} 164}
148 165
149static void 166static void
150lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb) 167lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb)
151{ 168{
169 unsigned long iflag = 0;
152 /* 170 /*
153 * There are only two special cases to consider. (1) the scsi command 171 * There are only two special cases to consider. (1) the scsi command
154 * requested scatter-gather usage or (2) the scsi command allocated 172 * requested scatter-gather usage or (2) the scsi command allocated
@@ -166,8 +184,10 @@ lpfc_release_scsi_buf(struct lpfc_hba * phba, struct lpfc_scsi_buf * psb)
166 } 184 }
167 } 185 }
168 186
187 spin_lock_irqsave(&phba->scsi_buf_list_lock, iflag);
169 psb->pCmd = NULL; 188 psb->pCmd = NULL;
170 list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list); 189 list_add_tail(&psb->list, &phba->lpfc_scsi_buf_list);
190 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, iflag);
171} 191}
172 192
173static int 193static int
@@ -389,7 +409,9 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
389 struct lpfc_rport_data *rdata = lpfc_cmd->rdata; 409 struct lpfc_rport_data *rdata = lpfc_cmd->rdata;
390 struct lpfc_nodelist *pnode = rdata->pnode; 410 struct lpfc_nodelist *pnode = rdata->pnode;
391 struct scsi_cmnd *cmd = lpfc_cmd->pCmd; 411 struct scsi_cmnd *cmd = lpfc_cmd->pCmd;
392 unsigned long iflag; 412 int result;
413 struct scsi_device *sdev, *tmp_sdev;
414 int depth = 0;
393 415
394 lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4]; 416 lpfc_cmd->result = pIocbOut->iocb.un.ulpWord[4];
395 lpfc_cmd->status = pIocbOut->iocb.ulpStatus; 417 lpfc_cmd->status = pIocbOut->iocb.ulpStatus;
@@ -441,11 +463,64 @@ lpfc_scsi_cmd_iocb_cmpl(struct lpfc_hba *phba, struct lpfc_iocbq *pIocbIn,
441 *lp, *(lp + 3), cmd->retries, cmd->resid); 463 *lp, *(lp + 3), cmd->retries, cmd->resid);
442 } 464 }
443 465
466 result = cmd->result;
467 sdev = cmd->device;
444 cmd->scsi_done(cmd); 468 cmd->scsi_done(cmd);
445 469
446 spin_lock_irqsave(phba->host->host_lock, iflag); 470 if (!result &&
471 ((jiffies - pnode->last_ramp_up_time) >
472 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
473 ((jiffies - pnode->last_q_full_time) >
474 LPFC_Q_RAMP_UP_INTERVAL * HZ) &&
475 (phba->cfg_lun_queue_depth > sdev->queue_depth)) {
476 shost_for_each_device(tmp_sdev, sdev->host) {
477 if (phba->cfg_lun_queue_depth > tmp_sdev->queue_depth) {
478 if (tmp_sdev->id != sdev->id)
479 continue;
480 if (tmp_sdev->ordered_tags)
481 scsi_adjust_queue_depth(tmp_sdev,
482 MSG_ORDERED_TAG,
483 tmp_sdev->queue_depth+1);
484 else
485 scsi_adjust_queue_depth(tmp_sdev,
486 MSG_SIMPLE_TAG,
487 tmp_sdev->queue_depth+1);
488
489 pnode->last_ramp_up_time = jiffies;
490 }
491 }
492 }
493
494 /*
495 * Check for queue full. If the lun is reporting queue full, then
496 * back off the lun queue depth to prevent target overloads.
497 */
498 if (result == SAM_STAT_TASK_SET_FULL) {
499 pnode->last_q_full_time = jiffies;
500
501 shost_for_each_device(tmp_sdev, sdev->host) {
502 if (tmp_sdev->id != sdev->id)
503 continue;
504 depth = scsi_track_queue_full(tmp_sdev,
505 tmp_sdev->queue_depth - 1);
506 }
507 /*
508 * The queue depth cannot be lowered any more.
509 * Modify the returned error code to store
510 * the final depth value set by
511 * scsi_track_queue_full.
512 */
513 if (depth == -1)
514 depth = sdev->host->cmd_per_lun;
515
516 if (depth) {
517 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
518 "%d:0711 detected queue full - lun queue depth "
519 " adjusted to %d.\n", phba->brd_no, depth);
520 }
521 }
522
447 lpfc_release_scsi_buf(phba, lpfc_cmd); 523 lpfc_release_scsi_buf(phba, lpfc_cmd);
448 spin_unlock_irqrestore(phba->host->host_lock, iflag);
449} 524}
450 525
451static void 526static void
@@ -693,6 +768,37 @@ lpfc_info(struct Scsi_Host *host)
693 return lpfcinfobuf; 768 return lpfcinfobuf;
694} 769}
695 770
771static __inline__ void lpfc_poll_rearm_timer(struct lpfc_hba * phba)
772{
773 unsigned long poll_tmo_expires =
774 (jiffies + msecs_to_jiffies(phba->cfg_poll_tmo));
775
776 if (phba->sli.ring[LPFC_FCP_RING].txcmplq_cnt)
777 mod_timer(&phba->fcp_poll_timer,
778 poll_tmo_expires);
779}
780
781void lpfc_poll_start_timer(struct lpfc_hba * phba)
782{
783 lpfc_poll_rearm_timer(phba);
784}
785
786void lpfc_poll_timeout(unsigned long ptr)
787{
788 struct lpfc_hba *phba = (struct lpfc_hba *)ptr;
789 unsigned long iflag;
790
791 spin_lock_irqsave(phba->host->host_lock, iflag);
792
793 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
794 lpfc_sli_poll_fcp_ring (phba);
795 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
796 lpfc_poll_rearm_timer(phba);
797 }
798
799 spin_unlock_irqrestore(phba->host->host_lock, iflag);
800}
801
696static int 802static int
697lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *)) 803lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
698{ 804{
@@ -719,10 +825,11 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
719 cmnd->result = ScsiResult(DID_BUS_BUSY, 0); 825 cmnd->result = ScsiResult(DID_BUS_BUSY, 0);
720 goto out_fail_command; 826 goto out_fail_command;
721 } 827 }
722 lpfc_cmd = lpfc_sli_get_scsi_buf (phba); 828 lpfc_cmd = lpfc_get_scsi_buf (phba);
723 if (lpfc_cmd == NULL) { 829 if (lpfc_cmd == NULL) {
724 printk(KERN_WARNING "%s: No buffer available - list empty, " 830 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
725 "total count %d\n", __FUNCTION__, phba->total_scsi_bufs); 831 "%d:0707 driver's buffer pool is empty, "
832 "IO busied\n", phba->brd_no);
726 goto out_host_busy; 833 goto out_host_busy;
727 } 834 }
728 835
@@ -746,11 +853,17 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
746 &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB); 853 &lpfc_cmd->cur_iocbq, SLI_IOCB_RET_IOCB);
747 if (err) 854 if (err)
748 goto out_host_busy_free_buf; 855 goto out_host_busy_free_buf;
856
857 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
858 lpfc_sli_poll_fcp_ring(phba);
859 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
860 lpfc_poll_rearm_timer(phba);
861 }
862
749 return 0; 863 return 0;
750 864
751 out_host_busy_free_buf: 865 out_host_busy_free_buf:
752 lpfc_release_scsi_buf(phba, lpfc_cmd); 866 lpfc_release_scsi_buf(phba, lpfc_cmd);
753 cmnd->host_scribble = NULL;
754 out_host_busy: 867 out_host_busy:
755 return SCSI_MLQUEUE_HOST_BUSY; 868 return SCSI_MLQUEUE_HOST_BUSY;
756 869
@@ -759,11 +872,12 @@ lpfc_queuecommand(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd *))
759 return 0; 872 return 0;
760} 873}
761 874
875
762static int 876static int
763__lpfc_abort_handler(struct scsi_cmnd *cmnd) 877lpfc_abort_handler(struct scsi_cmnd *cmnd)
764{ 878{
765 struct lpfc_hba *phba = 879 struct Scsi_Host *shost = cmnd->device->host;
766 (struct lpfc_hba *)cmnd->device->host->hostdata[0]; 880 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0];
767 struct lpfc_sli_ring *pring = &phba->sli.ring[phba->sli.fcp_ring]; 881 struct lpfc_sli_ring *pring = &phba->sli.ring[phba->sli.fcp_ring];
768 struct lpfc_iocbq *iocb; 882 struct lpfc_iocbq *iocb;
769 struct lpfc_iocbq *abtsiocb; 883 struct lpfc_iocbq *abtsiocb;
@@ -772,6 +886,8 @@ __lpfc_abort_handler(struct scsi_cmnd *cmnd)
772 unsigned int loop_count = 0; 886 unsigned int loop_count = 0;
773 int ret = SUCCESS; 887 int ret = SUCCESS;
774 888
889 lpfc_block_requests(phba);
890 spin_lock_irq(shost->host_lock);
775 891
776 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble; 892 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;
777 BUG_ON(!lpfc_cmd); 893 BUG_ON(!lpfc_cmd);
@@ -821,9 +937,15 @@ __lpfc_abort_handler(struct scsi_cmnd *cmnd)
821 goto out; 937 goto out;
822 } 938 }
823 939
940 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
941 lpfc_sli_poll_fcp_ring (phba);
942
824 /* Wait for abort to complete */ 943 /* Wait for abort to complete */
825 while (lpfc_cmd->pCmd == cmnd) 944 while (lpfc_cmd->pCmd == cmnd)
826 { 945 {
946 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
947 lpfc_sli_poll_fcp_ring (phba);
948
827 spin_unlock_irq(phba->host->host_lock); 949 spin_unlock_irq(phba->host->host_lock);
828 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ); 950 schedule_timeout_uninterruptible(LPFC_ABORT_WAIT*HZ);
829 spin_lock_irq(phba->host->host_lock); 951 spin_lock_irq(phba->host->host_lock);
@@ -844,26 +966,19 @@ __lpfc_abort_handler(struct scsi_cmnd *cmnd)
844 966
845 out: 967 out:
846 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP, 968 lpfc_printf_log(phba, KERN_WARNING, LOG_FCP,
847 "%d:0749 SCSI layer issued abort device: ret %#x, " 969 "%d:0749 SCSI Layer I/O Abort Request "
848 "ID %d, LUN %d, snum %#lx\n", 970 "Status x%x ID %d LUN %d snum %#lx\n",
849 phba->brd_no, ret, cmnd->device->id, 971 phba->brd_no, ret, cmnd->device->id,
850 cmnd->device->lun, cmnd->serial_number); 972 cmnd->device->lun, cmnd->serial_number);
851 973
852 return ret; 974 spin_unlock_irq(shost->host_lock);
853} 975 lpfc_unblock_requests(phba);
854 976
855static int 977 return ret;
856lpfc_abort_handler(struct scsi_cmnd *cmnd)
857{
858 int rc;
859 spin_lock_irq(cmnd->device->host->host_lock);
860 rc = __lpfc_abort_handler(cmnd);
861 spin_unlock_irq(cmnd->device->host->host_lock);
862 return rc;
863} 978}
864 979
865static int 980static int
866__lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) 981lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
867{ 982{
868 struct Scsi_Host *shost = cmnd->device->host; 983 struct Scsi_Host *shost = cmnd->device->host;
869 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; 984 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0];
@@ -871,9 +986,12 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
871 struct lpfc_iocbq *iocbq, *iocbqrsp; 986 struct lpfc_iocbq *iocbq, *iocbqrsp;
872 struct lpfc_rport_data *rdata = cmnd->device->hostdata; 987 struct lpfc_rport_data *rdata = cmnd->device->hostdata;
873 struct lpfc_nodelist *pnode = rdata->pnode; 988 struct lpfc_nodelist *pnode = rdata->pnode;
989 uint32_t cmd_result = 0, cmd_status = 0;
874 int ret = FAILED; 990 int ret = FAILED;
875 int cnt, loopcnt; 991 int cnt, loopcnt;
876 992
993 lpfc_block_requests(phba);
994 spin_lock_irq(shost->host_lock);
877 /* 995 /*
878 * If target is not in a MAPPED state, delay the reset until 996 * If target is not in a MAPPED state, delay the reset until
879 * target is rediscovered or nodev timeout expires. 997 * target is rediscovered or nodev timeout expires.
@@ -891,7 +1009,7 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
891 break; 1009 break;
892 } 1010 }
893 1011
894 lpfc_cmd = lpfc_sli_get_scsi_buf (phba); 1012 lpfc_cmd = lpfc_get_scsi_buf (phba);
895 if (lpfc_cmd == NULL) 1013 if (lpfc_cmd == NULL)
896 goto out; 1014 goto out;
897 1015
@@ -916,26 +1034,28 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
916 if (ret == IOCB_SUCCESS) 1034 if (ret == IOCB_SUCCESS)
917 ret = SUCCESS; 1035 ret = SUCCESS;
918 1036
919 lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4]; 1037
920 lpfc_cmd->status = iocbqrsp->iocb.ulpStatus; 1038 cmd_result = iocbqrsp->iocb.un.ulpWord[4];
921 if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT) 1039 cmd_status = iocbqrsp->iocb.ulpStatus;
922 if (lpfc_cmd->result & IOERR_DRVR_MASK) 1040
923 lpfc_cmd->status = IOSTAT_DRIVER_REJECT; 1041 lpfc_sli_release_iocbq(phba, iocbqrsp);
1042 lpfc_release_scsi_buf(phba, lpfc_cmd);
924 1043
925 /* 1044 /*
926 * All outstanding txcmplq I/Os should have been aborted by the target. 1045 * All outstanding txcmplq I/Os should have been aborted by the device.
927 * Unfortunately, some targets do not abide by this forcing the driver 1046 * Unfortunately, some targets do not abide by this forcing the driver
928 * to double check. 1047 * to double check.
929 */ 1048 */
930 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring], 1049 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
931 cmnd->device->id, cmnd->device->lun, 0, 1050 cmnd->device->id, cmnd->device->lun,
932 LPFC_CTX_LUN); 1051 LPFC_CTX_LUN);
933 1052 if (cnt)
1053 lpfc_sli_abort_iocb(phba,
1054 &phba->sli.ring[phba->sli.fcp_ring],
1055 cmnd->device->id, cmnd->device->lun,
1056 0, LPFC_CTX_LUN);
934 loopcnt = 0; 1057 loopcnt = 0;
935 while((cnt = lpfc_sli_sum_iocb(phba, 1058 while(cnt) {
936 &phba->sli.ring[phba->sli.fcp_ring],
937 cmnd->device->id, cmnd->device->lun,
938 LPFC_CTX_LUN))) {
939 spin_unlock_irq(phba->host->host_lock); 1059 spin_unlock_irq(phba->host->host_lock);
940 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); 1060 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
941 spin_lock_irq(phba->host->host_lock); 1061 spin_lock_irq(phba->host->host_lock);
@@ -943,6 +1063,11 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
943 if (++loopcnt 1063 if (++loopcnt
944 > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT) 1064 > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT)
945 break; 1065 break;
1066
1067 cnt = lpfc_sli_sum_iocb(phba,
1068 &phba->sli.ring[phba->sli.fcp_ring],
1069 cmnd->device->id, cmnd->device->lun,
1070 LPFC_CTX_LUN);
946 } 1071 }
947 1072
948 if (cnt) { 1073 if (cnt) {
@@ -952,35 +1077,21 @@ __lpfc_reset_lun_handler(struct scsi_cmnd *cmnd)
952 ret = FAILED; 1077 ret = FAILED;
953 } 1078 }
954 1079
955 lpfc_sli_release_iocbq(phba, iocbqrsp);
956
957out_free_scsi_buf: 1080out_free_scsi_buf:
958 lpfc_printf_log(phba, KERN_ERR, LOG_FCP, 1081 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
959 "%d:0713 SCSI layer issued LUN reset (%d, %d) " 1082 "%d:0713 SCSI layer issued LUN reset (%d, %d) "
960 "Data: x%x x%x x%x\n", 1083 "Data: x%x x%x x%x\n",
961 phba->brd_no, lpfc_cmd->pCmd->device->id, 1084 phba->brd_no, cmnd->device->id,cmnd->device->lun,
962 lpfc_cmd->pCmd->device->lun, ret, lpfc_cmd->status, 1085 ret, cmd_status, cmd_result);
963 lpfc_cmd->result); 1086
964 lpfc_release_scsi_buf(phba, lpfc_cmd);
965out: 1087out:
1088 spin_unlock_irq(shost->host_lock);
1089 lpfc_unblock_requests(phba);
966 return ret; 1090 return ret;
967} 1091}
968 1092
969static int 1093static int
970lpfc_reset_lun_handler(struct scsi_cmnd *cmnd) 1094lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
971{
972 int rc;
973 spin_lock_irq(cmnd->device->host->host_lock);
974 rc = __lpfc_reset_lun_handler(cmnd);
975 spin_unlock_irq(cmnd->device->host->host_lock);
976 return rc;
977}
978
979/*
980 * Note: midlayer calls this function with the host_lock held
981 */
982static int
983__lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
984{ 1095{
985 struct Scsi_Host *shost = cmnd->device->host; 1096 struct Scsi_Host *shost = cmnd->device->host;
986 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0]; 1097 struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0];
@@ -991,7 +1102,10 @@ __lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
991 unsigned int midlayer_id = 0; 1102 unsigned int midlayer_id = 0;
992 struct lpfc_scsi_buf * lpfc_cmd; 1103 struct lpfc_scsi_buf * lpfc_cmd;
993 1104
994 lpfc_cmd = lpfc_sli_get_scsi_buf (phba); 1105 lpfc_block_requests(phba);
1106 spin_lock_irq(shost->host_lock);
1107
1108 lpfc_cmd = lpfc_get_scsi_buf(phba);
995 if (lpfc_cmd == NULL) 1109 if (lpfc_cmd == NULL)
996 goto out; 1110 goto out;
997 1111
@@ -1022,18 +1136,31 @@ __lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
1022 lpfc_cmd->pCmd->device->hostdata = ndlp->rport->dd_data; 1136 lpfc_cmd->pCmd->device->hostdata = ndlp->rport->dd_data;
1023 ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba); 1137 ret = lpfc_scsi_tgt_reset(lpfc_cmd, phba);
1024 if (ret != SUCCESS) { 1138 if (ret != SUCCESS) {
1025 lpfc_printf_log(phba, KERN_INFO, LOG_FCP, 1139 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1026 "%d:0713 Bus Reset on target %d failed\n", 1140 "%d:0713 Bus Reset on target %d failed\n",
1027 phba->brd_no, i); 1141 phba->brd_no, i);
1028 err_count++; 1142 err_count++;
1029 } 1143 }
1030 } 1144 }
1031 1145
1146 if (err_count == 0)
1147 ret = SUCCESS;
1148
1149 lpfc_release_scsi_buf(phba, lpfc_cmd);
1150
1151 /*
1152 * All outstanding txcmplq I/Os should have been aborted by
1153 * the targets. Unfortunately, some targets do not abide by
1154 * this forcing the driver to double check.
1155 */
1032 cmnd->device->id = midlayer_id; 1156 cmnd->device->id = midlayer_id;
1157 cnt = lpfc_sli_sum_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
1158 0, 0, LPFC_CTX_HOST);
1159 if (cnt)
1160 lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],
1161 0, 0, 0, LPFC_CTX_HOST);
1033 loopcnt = 0; 1162 loopcnt = 0;
1034 while((cnt = lpfc_sli_sum_iocb(phba, 1163 while(cnt) {
1035 &phba->sli.ring[phba->sli.fcp_ring],
1036 0, 0, LPFC_CTX_HOST))) {
1037 spin_unlock_irq(phba->host->host_lock); 1164 spin_unlock_irq(phba->host->host_lock);
1038 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ); 1165 schedule_timeout_uninterruptible(LPFC_RESET_WAIT*HZ);
1039 spin_lock_irq(phba->host->host_lock); 1166 spin_lock_irq(phba->host->host_lock);
@@ -1041,45 +1168,31 @@ __lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
1041 if (++loopcnt 1168 if (++loopcnt
1042 > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT) 1169 > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT)
1043 break; 1170 break;
1171
1172 cnt = lpfc_sli_sum_iocb(phba,
1173 &phba->sli.ring[phba->sli.fcp_ring],
1174 0, 0, LPFC_CTX_HOST);
1044 } 1175 }
1045 1176
1046 if (cnt) { 1177 if (cnt) {
1047 /* flush all outstanding commands on the host */ 1178 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,
1048 i = lpfc_sli_abort_iocb(phba,
1049 &phba->sli.ring[phba->sli.fcp_ring], 0, 0, 0,
1050 LPFC_CTX_HOST);
1051
1052 lpfc_printf_log(phba, KERN_INFO, LOG_FCP,
1053 "%d:0715 Bus Reset I/O flush failure: cnt x%x left x%x\n", 1179 "%d:0715 Bus Reset I/O flush failure: cnt x%x left x%x\n",
1054 phba->brd_no, cnt, i); 1180 phba->brd_no, cnt, i);
1055 }
1056
1057 if (cnt == 0)
1058 ret = SUCCESS;
1059 else
1060 ret = FAILED; 1181 ret = FAILED;
1182 }
1061 1183
1062 lpfc_release_scsi_buf(phba, lpfc_cmd);
1063 lpfc_printf_log(phba, 1184 lpfc_printf_log(phba,
1064 KERN_ERR, 1185 KERN_ERR,
1065 LOG_FCP, 1186 LOG_FCP,
1066 "%d:0714 SCSI layer issued Bus Reset Data: x%x\n", 1187 "%d:0714 SCSI layer issued Bus Reset Data: x%x\n",
1067 phba->brd_no, ret); 1188 phba->brd_no, ret);
1068out: 1189out:
1190 spin_unlock_irq(shost->host_lock);
1191 lpfc_unblock_requests(phba);
1069 return ret; 1192 return ret;
1070} 1193}
1071 1194
1072static int 1195static int
1073lpfc_reset_bus_handler(struct scsi_cmnd *cmnd)
1074{
1075 int rc;
1076 spin_lock_irq(cmnd->device->host->host_lock);
1077 rc = __lpfc_reset_bus_handler(cmnd);
1078 spin_unlock_irq(cmnd->device->host->host_lock);
1079 return rc;
1080}
1081
1082static int
1083lpfc_slave_alloc(struct scsi_device *sdev) 1196lpfc_slave_alloc(struct scsi_device *sdev)
1084{ 1197{
1085 struct lpfc_hba *phba = (struct lpfc_hba *)sdev->host->hostdata[0]; 1198 struct lpfc_hba *phba = (struct lpfc_hba *)sdev->host->hostdata[0];
@@ -1127,10 +1240,10 @@ lpfc_slave_alloc(struct scsi_device *sdev)
1127 break; 1240 break;
1128 } 1241 }
1129 1242
1130 spin_lock_irqsave(phba->host->host_lock, flags); 1243 spin_lock_irqsave(&phba->scsi_buf_list_lock, flags);
1131 phba->total_scsi_bufs++; 1244 phba->total_scsi_bufs++;
1132 list_add_tail(&scsi_buf->list, &phba->lpfc_scsi_buf_list); 1245 list_add_tail(&scsi_buf->list, &phba->lpfc_scsi_buf_list);
1133 spin_unlock_irqrestore(phba->host->host_lock, flags); 1246 spin_unlock_irqrestore(&phba->scsi_buf_list_lock, flags);
1134 } 1247 }
1135 return 0; 1248 return 0;
1136} 1249}
@@ -1154,6 +1267,12 @@ lpfc_slave_configure(struct scsi_device *sdev)
1154 */ 1267 */
1155 rport->dev_loss_tmo = phba->cfg_nodev_tmo + 5; 1268 rport->dev_loss_tmo = phba->cfg_nodev_tmo + 5;
1156 1269
1270 if (phba->cfg_poll & ENABLE_FCP_RING_POLLING) {
1271 lpfc_sli_poll_fcp_ring(phba);
1272 if (phba->cfg_poll & DISABLE_FCP_RING_INT)
1273 lpfc_poll_rearm_timer(phba);
1274 }
1275
1157 return 0; 1276 return 0;
1158} 1277}
1159 1278
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c
index e2c08c5d83fb..7b785ade8b07 100644
--- a/drivers/scsi/lpfc/lpfc_sli.c
+++ b/drivers/scsi/lpfc/lpfc_sli.c
@@ -886,6 +886,182 @@ lpfc_sli_process_sol_iocb(struct lpfc_hba * phba, struct lpfc_sli_ring * pring,
886 return rc; 886 return rc;
887} 887}
888 888
889static void lpfc_sli_rsp_pointers_error(struct lpfc_hba * phba,
890 struct lpfc_sli_ring * pring)
891{
892 struct lpfc_pgp *pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno];
893 /*
894 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then
895 * rsp ring <portRspMax>
896 */
897 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
898 "%d:0312 Ring %d handler: portRspPut %d "
899 "is bigger then rsp ring %d\n",
900 phba->brd_no, pring->ringno,
901 le32_to_cpu(pgp->rspPutInx),
902 pring->numRiocb);
903
904 phba->hba_state = LPFC_HBA_ERROR;
905
906 /*
907 * All error attention handlers are posted to
908 * worker thread
909 */
910 phba->work_ha |= HA_ERATT;
911 phba->work_hs = HS_FFER3;
912 if (phba->work_wait)
913 wake_up(phba->work_wait);
914
915 return;
916}
917
918void lpfc_sli_poll_fcp_ring(struct lpfc_hba * phba)
919{
920 struct lpfc_sli * psli = &phba->sli;
921 struct lpfc_sli_ring * pring = &psli->ring[LPFC_FCP_RING];
922 IOCB_t *irsp = NULL;
923 IOCB_t *entry = NULL;
924 struct lpfc_iocbq *cmdiocbq = NULL;
925 struct lpfc_iocbq rspiocbq;
926 struct lpfc_pgp *pgp;
927 uint32_t status;
928 uint32_t portRspPut, portRspMax;
929 int type;
930 uint32_t rsp_cmpl = 0;
931 void __iomem *to_slim;
932 uint32_t ha_copy;
933
934 pring->stats.iocb_event++;
935
936 /* The driver assumes SLI-2 mode */
937 pgp = &phba->slim2p->mbx.us.s2.port[pring->ringno];
938
939 /*
940 * The next available response entry should never exceed the maximum
941 * entries. If it does, treat it as an adapter hardware error.
942 */
943 portRspMax = pring->numRiocb;
944 portRspPut = le32_to_cpu(pgp->rspPutInx);
945 if (unlikely(portRspPut >= portRspMax)) {
946 lpfc_sli_rsp_pointers_error(phba, pring);
947 return;
948 }
949
950 rmb();
951 while (pring->rspidx != portRspPut) {
952
953 entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx);
954
955 if (++pring->rspidx >= portRspMax)
956 pring->rspidx = 0;
957
958 lpfc_sli_pcimem_bcopy((uint32_t *) entry,
959 (uint32_t *) &rspiocbq.iocb,
960 sizeof (IOCB_t));
961 irsp = &rspiocbq.iocb;
962 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK);
963 pring->stats.iocb_rsp++;
964 rsp_cmpl++;
965
966 if (unlikely(irsp->ulpStatus)) {
967 /* Rsp ring <ringno> error: IOCB */
968 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,
969 "%d:0326 Rsp Ring %d error: IOCB Data: "
970 "x%x x%x x%x x%x x%x x%x x%x x%x\n",
971 phba->brd_no, pring->ringno,
972 irsp->un.ulpWord[0],
973 irsp->un.ulpWord[1],
974 irsp->un.ulpWord[2],
975 irsp->un.ulpWord[3],
976 irsp->un.ulpWord[4],
977 irsp->un.ulpWord[5],
978 *(((uint32_t *) irsp) + 6),
979 *(((uint32_t *) irsp) + 7));
980 }
981
982 switch (type) {
983 case LPFC_ABORT_IOCB:
984 case LPFC_SOL_IOCB:
985 /*
986 * Idle exchange closed via ABTS from port. No iocb
987 * resources need to be recovered.
988 */
989 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {
990 printk(KERN_INFO "%s: IOCB cmd 0x%x processed."
991 " Skipping completion\n", __FUNCTION__,
992 irsp->ulpCommand);
993 break;
994 }
995
996 cmdiocbq = lpfc_sli_iocbq_lookup(phba, pring,
997 &rspiocbq);
998 if ((cmdiocbq) && (cmdiocbq->iocb_cmpl)) {
999 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq,
1000 &rspiocbq);
1001 }
1002 break;
1003 default:
1004 if (irsp->ulpCommand == CMD_ADAPTER_MSG) {
1005 char adaptermsg[LPFC_MAX_ADPTMSG];
1006 memset(adaptermsg, 0, LPFC_MAX_ADPTMSG);
1007 memcpy(&adaptermsg[0], (uint8_t *) irsp,
1008 MAX_MSG_DATA);
1009 dev_warn(&((phba->pcidev)->dev), "lpfc%d: %s",
1010 phba->brd_no, adaptermsg);
1011 } else {
1012 /* Unknown IOCB command */
1013 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
1014 "%d:0321 Unknown IOCB command "
1015 "Data: x%x, x%x x%x x%x x%x\n",
1016 phba->brd_no, type,
1017 irsp->ulpCommand,
1018 irsp->ulpStatus,
1019 irsp->ulpIoTag,
1020 irsp->ulpContext);
1021 }
1022 break;
1023 }
1024
1025 /*
1026 * The response IOCB has been processed. Update the ring
1027 * pointer in SLIM. If the port response put pointer has not
1028 * been updated, sync the pgp->rspPutInx and fetch the new port
1029 * response put pointer.
1030 */
1031 to_slim = phba->MBslimaddr +
1032 (SLIMOFF + (pring->ringno * 2) + 1) * 4;
1033 writeb(pring->rspidx, to_slim);
1034
1035 if (pring->rspidx == portRspPut)
1036 portRspPut = le32_to_cpu(pgp->rspPutInx);
1037 }
1038
1039 ha_copy = readl(phba->HAregaddr);
1040 ha_copy >>= (LPFC_FCP_RING * 4);
1041
1042 if ((rsp_cmpl > 0) && (ha_copy & HA_R0RE_REQ)) {
1043 pring->stats.iocb_rsp_full++;
1044 status = ((CA_R0ATT | CA_R0RE_RSP) << (LPFC_FCP_RING * 4));
1045 writel(status, phba->CAregaddr);
1046 readl(phba->CAregaddr);
1047 }
1048 if ((ha_copy & HA_R0CE_RSP) &&
1049 (pring->flag & LPFC_CALL_RING_AVAILABLE)) {
1050 pring->flag &= ~LPFC_CALL_RING_AVAILABLE;
1051 pring->stats.iocb_cmd_empty++;
1052
1053 /* Force update of the local copy of cmdGetInx */
1054 pring->local_getidx = le32_to_cpu(pgp->cmdGetInx);
1055 lpfc_sli_resume_iocb(phba, pring);
1056
1057 if ((pring->lpfc_sli_cmd_available))
1058 (pring->lpfc_sli_cmd_available) (phba, pring);
1059
1060 }
1061
1062 return;
1063}
1064
889/* 1065/*
890 * This routine presumes LPFC_FCP_RING handling and doesn't bother 1066 * This routine presumes LPFC_FCP_RING handling and doesn't bother
891 * to check it explicitly. 1067 * to check it explicitly.
@@ -917,24 +1093,7 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
917 portRspMax = pring->numRiocb; 1093 portRspMax = pring->numRiocb;
918 portRspPut = le32_to_cpu(pgp->rspPutInx); 1094 portRspPut = le32_to_cpu(pgp->rspPutInx);
919 if (unlikely(portRspPut >= portRspMax)) { 1095 if (unlikely(portRspPut >= portRspMax)) {
920 /* 1096 lpfc_sli_rsp_pointers_error(phba, pring);
921 * Ring <ringno> handler: portRspPut <portRspPut> is bigger then
922 * rsp ring <portRspMax>
923 */
924 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
925 "%d:0312 Ring %d handler: portRspPut %d "
926 "is bigger then rsp ring %d\n",
927 phba->brd_no, pring->ringno, portRspPut,
928 portRspMax);
929
930 phba->hba_state = LPFC_HBA_ERROR;
931
932 /* All error attention handlers are posted to worker thread */
933 phba->work_ha |= HA_ERATT;
934 phba->work_hs = HS_FFER3;
935 if (phba->work_wait)
936 wake_up(phba->work_wait);
937
938 spin_unlock_irqrestore(phba->host->host_lock, iflag); 1097 spin_unlock_irqrestore(phba->host->host_lock, iflag);
939 return 1; 1098 return 1;
940 } 1099 }
@@ -947,6 +1106,10 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
947 * network byte order and pci byte orders are different. 1106 * network byte order and pci byte orders are different.
948 */ 1107 */
949 entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx); 1108 entry = IOCB_ENTRY(pring->rspringaddr, pring->rspidx);
1109
1110 if (++pring->rspidx >= portRspMax)
1111 pring->rspidx = 0;
1112
950 lpfc_sli_pcimem_bcopy((uint32_t *) entry, 1113 lpfc_sli_pcimem_bcopy((uint32_t *) entry,
951 (uint32_t *) &rspiocbq.iocb, 1114 (uint32_t *) &rspiocbq.iocb,
952 sizeof (IOCB_t)); 1115 sizeof (IOCB_t));
@@ -1020,9 +1183,6 @@ lpfc_sli_handle_fast_ring_event(struct lpfc_hba * phba,
1020 * been updated, sync the pgp->rspPutInx and fetch the new port 1183 * been updated, sync the pgp->rspPutInx and fetch the new port
1021 * response put pointer. 1184 * response put pointer.
1022 */ 1185 */
1023 if (++pring->rspidx >= portRspMax)
1024 pring->rspidx = 0;
1025
1026 to_slim = phba->MBslimaddr + 1186 to_slim = phba->MBslimaddr +
1027 (SLIMOFF + (pring->ringno * 2) + 1) * 4; 1187 (SLIMOFF + (pring->ringno * 2) + 1) * 4;
1028 writel(pring->rspidx, to_slim); 1188 writel(pring->rspidx, to_slim);
@@ -2615,6 +2775,7 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
2615 DECLARE_WAIT_QUEUE_HEAD(done_q); 2775 DECLARE_WAIT_QUEUE_HEAD(done_q);
2616 long timeleft, timeout_req = 0; 2776 long timeleft, timeout_req = 0;
2617 int retval = IOCB_SUCCESS; 2777 int retval = IOCB_SUCCESS;
2778 uint32_t creg_val;
2618 2779
2619 /* 2780 /*
2620 * If the caller has provided a response iocbq buffer, then context2 2781 * If the caller has provided a response iocbq buffer, then context2
@@ -2630,6 +2791,13 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
2630 piocb->context_un.wait_queue = &done_q; 2791 piocb->context_un.wait_queue = &done_q;
2631 piocb->iocb_flag &= ~LPFC_IO_WAKE; 2792 piocb->iocb_flag &= ~LPFC_IO_WAKE;
2632 2793
2794 if (phba->cfg_poll & DISABLE_FCP_RING_INT) {
2795 creg_val = readl(phba->HCregaddr);
2796 creg_val |= (HC_R0INT_ENA << LPFC_FCP_RING);
2797 writel(creg_val, phba->HCregaddr);
2798 readl(phba->HCregaddr); /* flush */
2799 }
2800
2633 retval = lpfc_sli_issue_iocb(phba, pring, piocb, 0); 2801 retval = lpfc_sli_issue_iocb(phba, pring, piocb, 0);
2634 if (retval == IOCB_SUCCESS) { 2802 if (retval == IOCB_SUCCESS) {
2635 timeout_req = timeout * HZ; 2803 timeout_req = timeout * HZ;
@@ -2663,6 +2831,13 @@ lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
2663 retval = IOCB_ERROR; 2831 retval = IOCB_ERROR;
2664 } 2832 }
2665 2833
2834 if (phba->cfg_poll & DISABLE_FCP_RING_INT) {
2835 creg_val = readl(phba->HCregaddr);
2836 creg_val &= ~(HC_R0INT_ENA << LPFC_FCP_RING);
2837 writel(creg_val, phba->HCregaddr);
2838 readl(phba->HCregaddr); /* flush */
2839 }
2840
2666 if (prspiocbq) 2841 if (prspiocbq)
2667 piocb->context2 = NULL; 2842 piocb->context2 = NULL;
2668 2843
diff --git a/drivers/scsi/lpfc/lpfc_version.h b/drivers/scsi/lpfc/lpfc_version.h
index 4f0466fbd5f2..fa681a934ffe 100644
--- a/drivers/scsi/lpfc/lpfc_version.h
+++ b/drivers/scsi/lpfc/lpfc_version.h
@@ -18,7 +18,7 @@
18 * included with this package. * 18 * included with this package. *
19 *******************************************************************/ 19 *******************************************************************/
20 20
21#define LPFC_DRIVER_VERSION "8.1.0" 21#define LPFC_DRIVER_VERSION "8.1.1"
22 22
23#define LPFC_DRIVER_NAME "lpfc" 23#define LPFC_DRIVER_NAME "lpfc"
24 24
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index f9792528e33f..4a6feb1e5e3d 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * Linux MegaRAID device driver 3 * Linux MegaRAID device driver
4 * 4 *
5 * Copyright © 2002 LSI Logic Corporation. 5 * Copyright (c) 2002 LSI Logic Corporation.
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License 8 * modify it under the terms of the GNU General Public License
@@ -17,7 +17,8 @@
17 * Copyright (c) 2003 Christoph Hellwig <hch@lst.de> 17 * Copyright (c) 2003 Christoph Hellwig <hch@lst.de>
18 * - new-style, hotplug-aware pci probing and scsi registration 18 * - new-style, hotplug-aware pci probing and scsi registration
19 * 19 *
20 * Version : v2.00.3 (Feb 19, 2003) - Atul Mukker <Atul.Mukker@lsil.com> 20 * Version : v2.00.4 Mon Nov 14 14:02:43 EST 2005 - Seokmann Ju
21 * <Seokmann.Ju@lsil.com>
21 * 22 *
22 * Description: Linux device driver for LSI Logic MegaRAID controller 23 * Description: Linux device driver for LSI Logic MegaRAID controller
23 * 24 *
@@ -51,10 +52,10 @@
51 52
52#include "megaraid.h" 53#include "megaraid.h"
53 54
54#define MEGARAID_MODULE_VERSION "2.00.3" 55#define MEGARAID_MODULE_VERSION "2.00.4"
55 56
56MODULE_AUTHOR ("LSI Logic Corporation"); 57MODULE_AUTHOR ("sju@lsil.com");
57MODULE_DESCRIPTION ("LSI Logic MegaRAID driver"); 58MODULE_DESCRIPTION ("LSI Logic MegaRAID legacy driver");
58MODULE_LICENSE ("GPL"); 59MODULE_LICENSE ("GPL");
59MODULE_VERSION(MEGARAID_MODULE_VERSION); 60MODULE_VERSION(MEGARAID_MODULE_VERSION);
60 61
@@ -664,7 +665,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
664 sg->offset; 665 sg->offset;
665 } else 666 } else
666 buf = cmd->request_buffer; 667 buf = cmd->request_buffer;
667 memset(cmd->request_buffer, 0, cmd->cmnd[4]); 668 memset(buf, 0, cmd->cmnd[4]);
668 if (cmd->use_sg) { 669 if (cmd->use_sg) {
669 struct scatterlist *sg; 670 struct scatterlist *sg;
670 671
@@ -4553,7 +4554,7 @@ mega_internal_done(Scsi_Cmnd *scmd)
4553static struct scsi_host_template megaraid_template = { 4554static struct scsi_host_template megaraid_template = {
4554 .module = THIS_MODULE, 4555 .module = THIS_MODULE,
4555 .name = "MegaRAID", 4556 .name = "MegaRAID",
4556 .proc_name = "megaraid", 4557 .proc_name = "megaraid_legacy",
4557 .info = megaraid_info, 4558 .info = megaraid_info,
4558 .queuecommand = megaraid_queue, 4559 .queuecommand = megaraid_queue,
4559 .bios_param = megaraid_biosparam, 4560 .bios_param = megaraid_biosparam,
@@ -5037,22 +5038,12 @@ megaraid_shutdown(struct pci_dev *pdev)
5037} 5038}
5038 5039
5039static struct pci_device_id megaraid_pci_tbl[] = { 5040static struct pci_device_id megaraid_pci_tbl[] = {
5040 {PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_DISCOVERY,
5041 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
5042 {PCI_VENDOR_ID_DELL, PCI_DEVICE_ID_PERC4_DI,
5043 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BOARD_64BIT},
5044 {PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_PERC4_QC_VERDE,
5045 PCI_ANY_ID, PCI_ANY_ID, 0, 0, BOARD_64BIT},
5046 {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID, 5041 {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID,
5047 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 5042 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
5048 {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID2, 5043 {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID2,
5049 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 5044 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
5050 {PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID3,
5051 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
5052 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_AMI_MEGARAID3, 5045 {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_AMI_MEGARAID3,
5053 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 5046 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
5054 {PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_AMI_MEGARAID3,
5055 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
5056 {0,} 5047 {0,}
5057}; 5048};
5058MODULE_DEVICE_TABLE(pci, megaraid_pci_tbl); 5049MODULE_DEVICE_TABLE(pci, megaraid_pci_tbl);
@@ -5095,7 +5086,7 @@ static int __init megaraid_init(void)
5095 * First argument (major) to register_chrdev implies a dynamic 5086 * First argument (major) to register_chrdev implies a dynamic
5096 * major number allocation. 5087 * major number allocation.
5097 */ 5088 */
5098 major = register_chrdev(0, "megadev", &megadev_fops); 5089 major = register_chrdev(0, "megadev_legacy", &megadev_fops);
5099 if (!major) { 5090 if (!major) {
5100 printk(KERN_WARNING 5091 printk(KERN_WARNING
5101 "megaraid: failed to register char device\n"); 5092 "megaraid: failed to register char device\n");
@@ -5109,7 +5100,7 @@ static void __exit megaraid_exit(void)
5109 /* 5100 /*
5110 * Unregister the character device interface to the driver. 5101 * Unregister the character device interface to the driver.
5111 */ 5102 */
5112 unregister_chrdev(major, "megadev"); 5103 unregister_chrdev(major, "megadev_legacy");
5113 5104
5114 pci_unregister_driver(&megaraid_pci_driver); 5105 pci_unregister_driver(&megaraid_pci_driver);
5115 5106
diff --git a/drivers/scsi/megaraid/Kconfig.megaraid b/drivers/scsi/megaraid/Kconfig.megaraid
index 7363e12663ac..17419e30ffc8 100644
--- a/drivers/scsi/megaraid/Kconfig.megaraid
+++ b/drivers/scsi/megaraid/Kconfig.megaraid
@@ -64,7 +64,6 @@ config MEGARAID_MAILBOX
64 To compile this driver as a module, choose M here: the 64 To compile this driver as a module, choose M here: the
65 module will be called megaraid_mbox 65 module will be called megaraid_mbox
66 66
67if MEGARAID_NEWGEN=n
68config MEGARAID_LEGACY 67config MEGARAID_LEGACY
69 tristate "LSI Logic Legacy MegaRAID Driver" 68 tristate "LSI Logic Legacy MegaRAID Driver"
70 depends on PCI && SCSI 69 depends on PCI && SCSI
@@ -75,7 +74,6 @@ config MEGARAID_LEGACY
75 74
76 To compile this driver as a module, choose M here: the 75 To compile this driver as a module, choose M here: the
77 module will be called megaraid 76 module will be called megaraid
78endif
79 77
80config MEGARAID_SAS 78config MEGARAID_SAS
81 tristate "LSI Logic MegaRAID SAS RAID Module" 79 tristate "LSI Logic MegaRAID SAS RAID Module"
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 4b5d420d2f4d..d18a4bc2498c 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -10,12 +10,13 @@
10 * 2 of the License, or (at your option) any later version. 10 * 2 of the License, or (at your option) any later version.
11 * 11 *
12 * FILE : megaraid_mbox.c 12 * FILE : megaraid_mbox.c
13 * Version : v2.20.4.6 (Mar 07 2005) 13 * Version : v2.20.4.7 (Nov 14 2005)
14 * 14 *
15 * Authors: 15 * Authors:
16 * Atul Mukker <Atul.Mukker@lsil.com> 16 * Atul Mukker <Atul.Mukker@lsil.com>
17 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com> 17 * Sreenivas Bagalkote <Sreenivas.Bagalkote@lsil.com>
18 * Manoj Jose <Manoj.Jose@lsil.com> 18 * Manoj Jose <Manoj.Jose@lsil.com>
19 * Seokmann Ju <Seokmann.Ju@lsil.com>
19 * 20 *
20 * List of supported controllers 21 * List of supported controllers
21 * 22 *
@@ -136,7 +137,7 @@ static int wait_till_fw_empty(adapter_t *);
136 137
137 138
138 139
139MODULE_AUTHOR("LSI Logic Corporation"); 140MODULE_AUTHOR("sju@lsil.com");
140MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver"); 141MODULE_DESCRIPTION("LSI Logic MegaRAID Mailbox Driver");
141MODULE_LICENSE("GPL"); 142MODULE_LICENSE("GPL");
142MODULE_VERSION(MEGARAID_VERSION); 143MODULE_VERSION(MEGARAID_VERSION);
@@ -278,68 +279,14 @@ static struct pci_device_id pci_id_table_g[] = {
278 { 279 {
279 PCI_VENDOR_ID_AMI, 280 PCI_VENDOR_ID_AMI,
280 PCI_DEVICE_ID_AMI_MEGARAID3, 281 PCI_DEVICE_ID_AMI_MEGARAID3,
281 PCI_VENDOR_ID_DELL, 282 PCI_ANY_ID,
282 PCI_SUBSYS_ID_PERC3_QC, 283 PCI_ANY_ID,
283 },
284 {
285 PCI_VENDOR_ID_AMI,
286 PCI_DEVICE_ID_AMI_MEGARAID3,
287 PCI_VENDOR_ID_DELL,
288 PCI_SUBSYS_ID_PERC3_DC,
289 },
290 {
291 PCI_VENDOR_ID_AMI,
292 PCI_DEVICE_ID_AMI_MEGARAID3,
293 PCI_VENDOR_ID_DELL,
294 PCI_SUBSYS_ID_PERC3_SC,
295 },
296 {
297 PCI_VENDOR_ID_AMI,
298 PCI_DEVICE_ID_AMI_MEGARAID3,
299 PCI_VENDOR_ID_AMI,
300 PCI_SUBSYS_ID_PERC3_SC,
301 },
302 {
303 PCI_VENDOR_ID_AMI,
304 PCI_DEVICE_ID_AMI_MEGARAID3,
305 PCI_VENDOR_ID_AMI,
306 PCI_SUBSYS_ID_PERC3_DC,
307 },
308 {
309 PCI_VENDOR_ID_LSI_LOGIC,
310 PCI_DEVICE_ID_MEGARAID_SCSI_320_0,
311 PCI_VENDOR_ID_LSI_LOGIC,
312 PCI_SUBSYS_ID_MEGARAID_SCSI_320_0,
313 },
314 {
315 PCI_VENDOR_ID_LSI_LOGIC,
316 PCI_DEVICE_ID_MEGARAID_SCSI_320_1,
317 PCI_VENDOR_ID_LSI_LOGIC,
318 PCI_SUBSYS_ID_MEGARAID_SCSI_320_1,
319 },
320 {
321 PCI_VENDOR_ID_LSI_LOGIC,
322 PCI_DEVICE_ID_MEGARAID_SCSI_320_2,
323 PCI_VENDOR_ID_LSI_LOGIC,
324 PCI_SUBSYS_ID_MEGARAID_SCSI_320_2,
325 },
326 {
327 PCI_VENDOR_ID_LSI_LOGIC,
328 PCI_DEVICE_ID_MEGARAID_I4_133_RAID,
329 PCI_VENDOR_ID_LSI_LOGIC,
330 PCI_SUBSYS_ID_MEGARAID_I4_133_RAID,
331 },
332 {
333 PCI_VENDOR_ID_LSI_LOGIC,
334 PCI_DEVICE_ID_MEGARAID_SATA_150_4,
335 PCI_VENDOR_ID_LSI_LOGIC,
336 PCI_SUBSYS_ID_MEGARAID_SATA_150_4,
337 }, 284 },
338 { 285 {
339 PCI_VENDOR_ID_LSI_LOGIC, 286 PCI_VENDOR_ID_LSI_LOGIC,
340 PCI_DEVICE_ID_MEGARAID_SATA_150_6, 287 PCI_DEVICE_ID_AMI_MEGARAID3,
341 PCI_VENDOR_ID_LSI_LOGIC, 288 PCI_ANY_ID,
342 PCI_SUBSYS_ID_MEGARAID_SATA_150_6, 289 PCI_ANY_ID,
343 }, 290 },
344 { 291 {
345 PCI_VENDOR_ID_LSI_LOGIC, 292 PCI_VENDOR_ID_LSI_LOGIC,
@@ -347,18 +294,6 @@ static struct pci_device_id pci_id_table_g[] = {
347 PCI_ANY_ID, 294 PCI_ANY_ID,
348 PCI_ANY_ID, 295 PCI_ANY_ID,
349 }, 296 },
350 {
351 PCI_VENDOR_ID_LSI_LOGIC,
352 PCI_DEVICE_ID_INTEL_RAID_SRCS16,
353 PCI_VENDOR_ID_INTEL,
354 PCI_SUBSYS_ID_INTEL_RAID_SRCS16,
355 },
356 {
357 PCI_VENDOR_ID_LSI_LOGIC,
358 PCI_DEVICE_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK,
359 PCI_VENDOR_ID_INTEL,
360 PCI_SUBSYS_ID_INTEL_RAID_SRCU41L_LAKE_SHETEK,
361 },
362 {0} /* Terminating entry */ 297 {0} /* Terminating entry */
363}; 298};
364MODULE_DEVICE_TABLE(pci, pci_id_table_g); 299MODULE_DEVICE_TABLE(pci, pci_id_table_g);
@@ -2985,6 +2920,7 @@ mbox_post_sync_cmd_fast(adapter_t *adapter, uint8_t raw_mbox[])
2985 2920
2986 for (i = 0; i < 0xFFFFF; i++) { 2921 for (i = 0; i < 0xFFFFF; i++) {
2987 if (mbox->numstatus != 0xFF) break; 2922 if (mbox->numstatus != 0xFF) break;
2923 rmb();
2988 } 2924 }
2989 2925
2990 if (i == 0xFFFFF) { 2926 if (i == 0xFFFFF) {
diff --git a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h
index 644b91bdb028..882fb1a0b575 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.h
+++ b/drivers/scsi/megaraid/megaraid_mbox.h
@@ -21,8 +21,8 @@
21#include "megaraid_ioctl.h" 21#include "megaraid_ioctl.h"
22 22
23 23
24#define MEGARAID_VERSION "2.20.4.6" 24#define MEGARAID_VERSION "2.20.4.7"
25#define MEGARAID_EXT_VERSION "(Release Date: Mon Mar 07 12:27:22 EST 2005)" 25#define MEGARAID_EXT_VERSION "(Release Date: Mon Nov 14 12:27:22 EST 2005)"
26 26
27 27
28/* 28/*
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 243470936fab..32350707b940 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -131,7 +131,739 @@
131#define NAME53C "ncr53c" 131#define NAME53C "ncr53c"
132#define NAME53C8XX "ncr53c8xx" 132#define NAME53C8XX "ncr53c8xx"
133 133
134#include "sym53c8xx_comm.h" 134
135/*==========================================================
136**
137** Debugging tags
138**
139**==========================================================
140*/
141
142#define DEBUG_ALLOC (0x0001)
143#define DEBUG_PHASE (0x0002)
144#define DEBUG_QUEUE (0x0008)
145#define DEBUG_RESULT (0x0010)
146#define DEBUG_POINTER (0x0020)
147#define DEBUG_SCRIPT (0x0040)
148#define DEBUG_TINY (0x0080)
149#define DEBUG_TIMING (0x0100)
150#define DEBUG_NEGO (0x0200)
151#define DEBUG_TAGS (0x0400)
152#define DEBUG_SCATTER (0x0800)
153#define DEBUG_IC (0x1000)
154
155/*
156** Enable/Disable debug messages.
157** Can be changed at runtime too.
158*/
159
160#ifdef SCSI_NCR_DEBUG_INFO_SUPPORT
161static int ncr_debug = SCSI_NCR_DEBUG_FLAGS;
162 #define DEBUG_FLAGS ncr_debug
163#else
164 #define DEBUG_FLAGS SCSI_NCR_DEBUG_FLAGS
165#endif
166
167static inline struct list_head *ncr_list_pop(struct list_head *head)
168{
169 if (!list_empty(head)) {
170 struct list_head *elem = head->next;
171
172 list_del(elem);
173 return elem;
174 }
175
176 return NULL;
177}
178
179/*==========================================================
180**
181** Simple power of two buddy-like allocator.
182**
183** This simple code is not intended to be fast, but to
184** provide power of 2 aligned memory allocations.
185** Since the SCRIPTS processor only supplies 8 bit
186** arithmetic, this allocator allows simple and fast
187** address calculations from the SCRIPTS code.
188** In addition, cache line alignment is guaranteed for
189** power of 2 cache line size.
190** Enhanced in linux-2.3.44 to provide a memory pool
191** per pcidev to support dynamic dma mapping. (I would
192** have preferred a real bus astraction, btw).
193**
194**==========================================================
195*/
196
197#define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */
198#if PAGE_SIZE >= 8192
199#define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */
200#else
201#define MEMO_PAGE_ORDER 1 /* 2 PAGES maximum */
202#endif
203#define MEMO_FREE_UNUSED /* Free unused pages immediately */
204#define MEMO_WARN 1
205#define MEMO_GFP_FLAGS GFP_ATOMIC
206#define MEMO_CLUSTER_SHIFT (PAGE_SHIFT+MEMO_PAGE_ORDER)
207#define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT)
208#define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
209
210typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */
211typedef struct device *m_bush_t; /* Something that addresses DMAable */
212
213typedef struct m_link { /* Link between free memory chunks */
214 struct m_link *next;
215} m_link_s;
216
217typedef struct m_vtob { /* Virtual to Bus address translation */
218 struct m_vtob *next;
219 m_addr_t vaddr;
220 m_addr_t baddr;
221} m_vtob_s;
222#define VTOB_HASH_SHIFT 5
223#define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT)
224#define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
225#define VTOB_HASH_CODE(m) \
226 ((((m_addr_t) (m)) >> MEMO_CLUSTER_SHIFT) & VTOB_HASH_MASK)
227
228typedef struct m_pool { /* Memory pool of a given kind */
229 m_bush_t bush;
230 m_addr_t (*getp)(struct m_pool *);
231 void (*freep)(struct m_pool *, m_addr_t);
232 int nump;
233 m_vtob_s *(vtob[VTOB_HASH_SIZE]);
234 struct m_pool *next;
235 struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1];
236} m_pool_s;
237
238static void *___m_alloc(m_pool_s *mp, int size)
239{
240 int i = 0;
241 int s = (1 << MEMO_SHIFT);
242 int j;
243 m_addr_t a;
244 m_link_s *h = mp->h;
245
246 if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
247 return NULL;
248
249 while (size > s) {
250 s <<= 1;
251 ++i;
252 }
253
254 j = i;
255 while (!h[j].next) {
256 if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
257 h[j].next = (m_link_s *)mp->getp(mp);
258 if (h[j].next)
259 h[j].next->next = NULL;
260 break;
261 }
262 ++j;
263 s <<= 1;
264 }
265 a = (m_addr_t) h[j].next;
266 if (a) {
267 h[j].next = h[j].next->next;
268 while (j > i) {
269 j -= 1;
270 s >>= 1;
271 h[j].next = (m_link_s *) (a+s);
272 h[j].next->next = NULL;
273 }
274 }
275#ifdef DEBUG
276 printk("___m_alloc(%d) = %p\n", size, (void *) a);
277#endif
278 return (void *) a;
279}
280
281static void ___m_free(m_pool_s *mp, void *ptr, int size)
282{
283 int i = 0;
284 int s = (1 << MEMO_SHIFT);
285 m_link_s *q;
286 m_addr_t a, b;
287 m_link_s *h = mp->h;
288
289#ifdef DEBUG
290 printk("___m_free(%p, %d)\n", ptr, size);
291#endif
292
293 if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
294 return;
295
296 while (size > s) {
297 s <<= 1;
298 ++i;
299 }
300
301 a = (m_addr_t) ptr;
302
303 while (1) {
304#ifdef MEMO_FREE_UNUSED
305 if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
306 mp->freep(mp, a);
307 break;
308 }
309#endif
310 b = a ^ s;
311 q = &h[i];
312 while (q->next && q->next != (m_link_s *) b) {
313 q = q->next;
314 }
315 if (!q->next) {
316 ((m_link_s *) a)->next = h[i].next;
317 h[i].next = (m_link_s *) a;
318 break;
319 }
320 q->next = q->next->next;
321 a = a & b;
322 s <<= 1;
323 ++i;
324 }
325}
326
327static DEFINE_SPINLOCK(ncr53c8xx_lock);
328
329static void *__m_calloc2(m_pool_s *mp, int size, char *name, int uflags)
330{
331 void *p;
332
333 p = ___m_alloc(mp, size);
334
335 if (DEBUG_FLAGS & DEBUG_ALLOC)
336 printk ("new %-10s[%4d] @%p.\n", name, size, p);
337
338 if (p)
339 memset(p, 0, size);
340 else if (uflags & MEMO_WARN)
341 printk (NAME53C8XX ": failed to allocate %s[%d]\n", name, size);
342
343 return p;
344}
345
346#define __m_calloc(mp, s, n) __m_calloc2(mp, s, n, MEMO_WARN)
347
348static void __m_free(m_pool_s *mp, void *ptr, int size, char *name)
349{
350 if (DEBUG_FLAGS & DEBUG_ALLOC)
351 printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr);
352
353 ___m_free(mp, ptr, size);
354
355}
356
357/*
358 * With pci bus iommu support, we use a default pool of unmapped memory
359 * for memory we donnot need to DMA from/to and one pool per pcidev for
360 * memory accessed by the PCI chip. `mp0' is the default not DMAable pool.
361 */
362
363static m_addr_t ___mp0_getp(m_pool_s *mp)
364{
365 m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER);
366 if (m)
367 ++mp->nump;
368 return m;
369}
370
371static void ___mp0_freep(m_pool_s *mp, m_addr_t m)
372{
373 free_pages(m, MEMO_PAGE_ORDER);
374 --mp->nump;
375}
376
377static m_pool_s mp0 = {NULL, ___mp0_getp, ___mp0_freep};
378
379/*
380 * DMAable pools.
381 */
382
383/*
384 * With pci bus iommu support, we maintain one pool per pcidev and a
385 * hashed reverse table for virtual to bus physical address translations.
386 */
387static m_addr_t ___dma_getp(m_pool_s *mp)
388{
389 m_addr_t vp;
390 m_vtob_s *vbp;
391
392 vbp = __m_calloc(&mp0, sizeof(*vbp), "VTOB");
393 if (vbp) {
394 dma_addr_t daddr;
395 vp = (m_addr_t) dma_alloc_coherent(mp->bush,
396 PAGE_SIZE<<MEMO_PAGE_ORDER,
397 &daddr, GFP_ATOMIC);
398 if (vp) {
399 int hc = VTOB_HASH_CODE(vp);
400 vbp->vaddr = vp;
401 vbp->baddr = daddr;
402 vbp->next = mp->vtob[hc];
403 mp->vtob[hc] = vbp;
404 ++mp->nump;
405 return vp;
406 }
407 }
408 if (vbp)
409 __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
410 return 0;
411}
412
413static void ___dma_freep(m_pool_s *mp, m_addr_t m)
414{
415 m_vtob_s **vbpp, *vbp;
416 int hc = VTOB_HASH_CODE(m);
417
418 vbpp = &mp->vtob[hc];
419 while (*vbpp && (*vbpp)->vaddr != m)
420 vbpp = &(*vbpp)->next;
421 if (*vbpp) {
422 vbp = *vbpp;
423 *vbpp = (*vbpp)->next;
424 dma_free_coherent(mp->bush, PAGE_SIZE<<MEMO_PAGE_ORDER,
425 (void *)vbp->vaddr, (dma_addr_t)vbp->baddr);
426 __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
427 --mp->nump;
428 }
429}
430
431static inline m_pool_s *___get_dma_pool(m_bush_t bush)
432{
433 m_pool_s *mp;
434 for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next);
435 return mp;
436}
437
438static m_pool_s *___cre_dma_pool(m_bush_t bush)
439{
440 m_pool_s *mp;
441 mp = __m_calloc(&mp0, sizeof(*mp), "MPOOL");
442 if (mp) {
443 memset(mp, 0, sizeof(*mp));
444 mp->bush = bush;
445 mp->getp = ___dma_getp;
446 mp->freep = ___dma_freep;
447 mp->next = mp0.next;
448 mp0.next = mp;
449 }
450 return mp;
451}
452
453static void ___del_dma_pool(m_pool_s *p)
454{
455 struct m_pool **pp = &mp0.next;
456
457 while (*pp && *pp != p)
458 pp = &(*pp)->next;
459 if (*pp) {
460 *pp = (*pp)->next;
461 __m_free(&mp0, p, sizeof(*p), "MPOOL");
462 }
463}
464
465static void *__m_calloc_dma(m_bush_t bush, int size, char *name)
466{
467 u_long flags;
468 struct m_pool *mp;
469 void *m = NULL;
470
471 spin_lock_irqsave(&ncr53c8xx_lock, flags);
472 mp = ___get_dma_pool(bush);
473 if (!mp)
474 mp = ___cre_dma_pool(bush);
475 if (mp)
476 m = __m_calloc(mp, size, name);
477 if (mp && !mp->nump)
478 ___del_dma_pool(mp);
479 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
480
481 return m;
482}
483
484static void __m_free_dma(m_bush_t bush, void *m, int size, char *name)
485{
486 u_long flags;
487 struct m_pool *mp;
488
489 spin_lock_irqsave(&ncr53c8xx_lock, flags);
490 mp = ___get_dma_pool(bush);
491 if (mp)
492 __m_free(mp, m, size, name);
493 if (mp && !mp->nump)
494 ___del_dma_pool(mp);
495 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
496}
497
498static m_addr_t __vtobus(m_bush_t bush, void *m)
499{
500 u_long flags;
501 m_pool_s *mp;
502 int hc = VTOB_HASH_CODE(m);
503 m_vtob_s *vp = NULL;
504 m_addr_t a = ((m_addr_t) m) & ~MEMO_CLUSTER_MASK;
505
506 spin_lock_irqsave(&ncr53c8xx_lock, flags);
507 mp = ___get_dma_pool(bush);
508 if (mp) {
509 vp = mp->vtob[hc];
510 while (vp && (m_addr_t) vp->vaddr != a)
511 vp = vp->next;
512 }
513 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
514 return vp ? vp->baddr + (((m_addr_t) m) - a) : 0;
515}
516
517#define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
518#define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
519#define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
520#define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
521#define _vtobus(np, p) __vtobus(np->dev, p)
522#define vtobus(p) _vtobus(np, p)
523
524/*
525 * Deal with DMA mapping/unmapping.
526 */
527
528/* To keep track of the dma mapping (sg/single) that has been set */
529#define __data_mapped SCp.phase
530#define __data_mapping SCp.have_data_in
531
532static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd)
533{
534 switch(cmd->__data_mapped) {
535 case 2:
536 dma_unmap_sg(dev, cmd->buffer, cmd->use_sg,
537 cmd->sc_data_direction);
538 break;
539 case 1:
540 dma_unmap_single(dev, cmd->__data_mapping,
541 cmd->request_bufflen,
542 cmd->sc_data_direction);
543 break;
544 }
545 cmd->__data_mapped = 0;
546}
547
548static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd)
549{
550 dma_addr_t mapping;
551
552 if (cmd->request_bufflen == 0)
553 return 0;
554
555 mapping = dma_map_single(dev, cmd->request_buffer,
556 cmd->request_bufflen,
557 cmd->sc_data_direction);
558 cmd->__data_mapped = 1;
559 cmd->__data_mapping = mapping;
560
561 return mapping;
562}
563
564static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
565{
566 int use_sg;
567
568 if (cmd->use_sg == 0)
569 return 0;
570
571 use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg,
572 cmd->sc_data_direction);
573 cmd->__data_mapped = 2;
574 cmd->__data_mapping = use_sg;
575
576 return use_sg;
577}
578
579#define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
580#define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd)
581#define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
582
583/*==========================================================
584**
585** Driver setup.
586**
587** This structure is initialized from linux config
588** options. It can be overridden at boot-up by the boot
589** command line.
590**
591**==========================================================
592*/
593static struct ncr_driver_setup
594 driver_setup = SCSI_NCR_DRIVER_SETUP;
595
596#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
597static struct ncr_driver_setup
598 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP;
599#endif
600
601#define initverbose (driver_setup.verbose)
602#define bootverbose (np->verbose)
603
604
605/*===================================================================
606**
607** Driver setup from the boot command line
608**
609**===================================================================
610*/
611
612#ifdef MODULE
613#define ARG_SEP ' '
614#else
615#define ARG_SEP ','
616#endif
617
618#define OPT_TAGS 1
619#define OPT_MASTER_PARITY 2
620#define OPT_SCSI_PARITY 3
621#define OPT_DISCONNECTION 4
622#define OPT_SPECIAL_FEATURES 5
623#define OPT_UNUSED_1 6
624#define OPT_FORCE_SYNC_NEGO 7
625#define OPT_REVERSE_PROBE 8
626#define OPT_DEFAULT_SYNC 9
627#define OPT_VERBOSE 10
628#define OPT_DEBUG 11
629#define OPT_BURST_MAX 12
630#define OPT_LED_PIN 13
631#define OPT_MAX_WIDE 14
632#define OPT_SETTLE_DELAY 15
633#define OPT_DIFF_SUPPORT 16
634#define OPT_IRQM 17
635#define OPT_PCI_FIX_UP 18
636#define OPT_BUS_CHECK 19
637#define OPT_OPTIMIZE 20
638#define OPT_RECOVERY 21
639#define OPT_SAFE_SETUP 22
640#define OPT_USE_NVRAM 23
641#define OPT_EXCLUDE 24
642#define OPT_HOST_ID 25
643
644#ifdef SCSI_NCR_IARB_SUPPORT
645#define OPT_IARB 26
646#endif
647
648static char setup_token[] __initdata =
649 "tags:" "mpar:"
650 "spar:" "disc:"
651 "specf:" "ultra:"
652 "fsn:" "revprob:"
653 "sync:" "verb:"
654 "debug:" "burst:"
655 "led:" "wide:"
656 "settle:" "diff:"
657 "irqm:" "pcifix:"
658 "buschk:" "optim:"
659 "recovery:"
660 "safe:" "nvram:"
661 "excl:" "hostid:"
662#ifdef SCSI_NCR_IARB_SUPPORT
663 "iarb:"
664#endif
665 ; /* DONNOT REMOVE THIS ';' */
666
667#ifdef MODULE
668#define ARG_SEP ' '
669#else
670#define ARG_SEP ','
671#endif
672
673static int __init get_setup_token(char *p)
674{
675 char *cur = setup_token;
676 char *pc;
677 int i = 0;
678
679 while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
680 ++pc;
681 ++i;
682 if (!strncmp(p, cur, pc - cur))
683 return i;
684 cur = pc;
685 }
686 return 0;
687}
688
689
690static int __init sym53c8xx__setup(char *str)
691{
692#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
693 char *cur = str;
694 char *pc, *pv;
695 int i, val, c;
696 int xi = 0;
697
698 while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
699 char *pe;
700
701 val = 0;
702 pv = pc;
703 c = *++pv;
704
705 if (c == 'n')
706 val = 0;
707 else if (c == 'y')
708 val = 1;
709 else
710 val = (int) simple_strtoul(pv, &pe, 0);
711
712 switch (get_setup_token(cur)) {
713 case OPT_TAGS:
714 driver_setup.default_tags = val;
715 if (pe && *pe == '/') {
716 i = 0;
717 while (*pe && *pe != ARG_SEP &&
718 i < sizeof(driver_setup.tag_ctrl)-1) {
719 driver_setup.tag_ctrl[i++] = *pe++;
720 }
721 driver_setup.tag_ctrl[i] = '\0';
722 }
723 break;
724 case OPT_MASTER_PARITY:
725 driver_setup.master_parity = val;
726 break;
727 case OPT_SCSI_PARITY:
728 driver_setup.scsi_parity = val;
729 break;
730 case OPT_DISCONNECTION:
731 driver_setup.disconnection = val;
732 break;
733 case OPT_SPECIAL_FEATURES:
734 driver_setup.special_features = val;
735 break;
736 case OPT_FORCE_SYNC_NEGO:
737 driver_setup.force_sync_nego = val;
738 break;
739 case OPT_REVERSE_PROBE:
740 driver_setup.reverse_probe = val;
741 break;
742 case OPT_DEFAULT_SYNC:
743 driver_setup.default_sync = val;
744 break;
745 case OPT_VERBOSE:
746 driver_setup.verbose = val;
747 break;
748 case OPT_DEBUG:
749 driver_setup.debug = val;
750 break;
751 case OPT_BURST_MAX:
752 driver_setup.burst_max = val;
753 break;
754 case OPT_LED_PIN:
755 driver_setup.led_pin = val;
756 break;
757 case OPT_MAX_WIDE:
758 driver_setup.max_wide = val? 1:0;
759 break;
760 case OPT_SETTLE_DELAY:
761 driver_setup.settle_delay = val;
762 break;
763 case OPT_DIFF_SUPPORT:
764 driver_setup.diff_support = val;
765 break;
766 case OPT_IRQM:
767 driver_setup.irqm = val;
768 break;
769 case OPT_PCI_FIX_UP:
770 driver_setup.pci_fix_up = val;
771 break;
772 case OPT_BUS_CHECK:
773 driver_setup.bus_check = val;
774 break;
775 case OPT_OPTIMIZE:
776 driver_setup.optimize = val;
777 break;
778 case OPT_RECOVERY:
779 driver_setup.recovery = val;
780 break;
781 case OPT_USE_NVRAM:
782 driver_setup.use_nvram = val;
783 break;
784 case OPT_SAFE_SETUP:
785 memcpy(&driver_setup, &driver_safe_setup,
786 sizeof(driver_setup));
787 break;
788 case OPT_EXCLUDE:
789 if (xi < SCSI_NCR_MAX_EXCLUDES)
790 driver_setup.excludes[xi++] = val;
791 break;
792 case OPT_HOST_ID:
793 driver_setup.host_id = val;
794 break;
795#ifdef SCSI_NCR_IARB_SUPPORT
796 case OPT_IARB:
797 driver_setup.iarb = val;
798 break;
799#endif
800 default:
801 printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur);
802 break;
803 }
804
805 if ((cur = strchr(cur, ARG_SEP)) != NULL)
806 ++cur;
807 }
808#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */
809 return 1;
810}
811
812/*===================================================================
813**
814** Get device queue depth from boot command line.
815**
816**===================================================================
817*/
818#define DEF_DEPTH (driver_setup.default_tags)
819#define ALL_TARGETS -2
820#define NO_TARGET -1
821#define ALL_LUNS -2
822#define NO_LUN -1
823
824static int device_queue_depth(int unit, int target, int lun)
825{
826 int c, h, t, u, v;
827 char *p = driver_setup.tag_ctrl;
828 char *ep;
829
830 h = -1;
831 t = NO_TARGET;
832 u = NO_LUN;
833 while ((c = *p++) != 0) {
834 v = simple_strtoul(p, &ep, 0);
835 switch(c) {
836 case '/':
837 ++h;
838 t = ALL_TARGETS;
839 u = ALL_LUNS;
840 break;
841 case 't':
842 if (t != target)
843 t = (target == v) ? v : NO_TARGET;
844 u = ALL_LUNS;
845 break;
846 case 'u':
847 if (u != lun)
848 u = (lun == v) ? v : NO_LUN;
849 break;
850 case 'q':
851 if (h == unit &&
852 (t == ALL_TARGETS || t == target) &&
853 (u == ALL_LUNS || u == lun))
854 return v;
855 break;
856 case '-':
857 t = ALL_TARGETS;
858 u = ALL_LUNS;
859 break;
860 default:
861 break;
862 }
863 p = ep;
864 }
865 return DEF_DEPTH;
866}
135 867
136 868
137/*========================================================== 869/*==========================================================
@@ -2971,21 +3703,10 @@ struct host_data {
2971 3703
2972static void ncr_print_msg(struct ccb *cp, char *label, u_char *msg) 3704static void ncr_print_msg(struct ccb *cp, char *label, u_char *msg)
2973{ 3705{
2974 int i;
2975 PRINT_ADDR(cp->cmd, "%s: ", label); 3706 PRINT_ADDR(cp->cmd, "%s: ", label);
2976 3707
2977 printk ("%x",*msg); 3708 spi_print_msg(msg);
2978 if (*msg == M_EXTENDED) { 3709 printk("\n");
2979 for (i = 1; i < 8; i++) {
2980 if (i - 1 > msg[1])
2981 break;
2982 printk ("-%x",msg[i]);
2983 }
2984 } else if ((*msg & 0xf0) == 0x20) {
2985 printk ("-%x",msg[1]);
2986 }
2987
2988 printk(".\n");
2989} 3710}
2990 3711
2991/*========================================================== 3712/*==========================================================
diff --git a/drivers/scsi/ncr53c8xx.h b/drivers/scsi/ncr53c8xx.h
index 05c7b83cef09..6a7bef2e6118 100644
--- a/drivers/scsi/ncr53c8xx.h
+++ b/drivers/scsi/ncr53c8xx.h
@@ -2,6 +2,7 @@
2** Device driver for the PCI-SCSI NCR538XX controller family. 2** Device driver for the PCI-SCSI NCR538XX controller family.
3** 3**
4** Copyright (C) 1994 Wolfgang Stanglmeier 4** Copyright (C) 1994 Wolfgang Stanglmeier
5** Copyright (C) 1998-2001 Gerard Roudier <groudier@free.fr>
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 as published by 8** it under the terms of the GNU General Public License as published by
@@ -36,15 +37,1275 @@
36** And has been ported to NetBSD by 37** And has been ported to NetBSD by
37** Charles M. Hannum <mycroft@gnu.ai.mit.edu> 38** Charles M. Hannum <mycroft@gnu.ai.mit.edu>
38** 39**
40** NVRAM detection and reading.
41** Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
42**
43** Added support for MIPS big endian systems.
44** Carsten Langgaard, carstenl@mips.com
45** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
46**
47** Added support for HP PARISC big endian systems.
48** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
49**
39******************************************************************************* 50*******************************************************************************
40*/ 51*/
41 52
42#ifndef NCR53C8XX_H 53#ifndef NCR53C8XX_H
43#define NCR53C8XX_H 54#define NCR53C8XX_H
44 55
56#include <linux/config.h>
45#include <scsi/scsi_host.h> 57#include <scsi/scsi_host.h>
46 58
47#include "sym53c8xx_defs.h" 59/*
60** If you want a driver as small as possible, do not define the
61** following options.
62*/
63#define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
64#define SCSI_NCR_DEBUG_INFO_SUPPORT
65
66/*
67** To disable integrity checking, do not define the
68** following option.
69*/
70#ifdef CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK
71# define SCSI_NCR_ENABLE_INTEGRITY_CHECK
72#endif
73
74/* ---------------------------------------------------------------------
75** Take into account kernel configured parameters.
76** Most of these options can be overridden at startup by a command line.
77** ---------------------------------------------------------------------
78*/
79
80/*
81 * For Ultra2 and Ultra3 SCSI support option, use special features.
82 *
83 * Value (default) means:
84 * bit 0 : all features enabled, except:
85 * bit 1 : PCI Write And Invalidate.
86 * bit 2 : Data Phase Mismatch handling from SCRIPTS.
87 *
88 * Use boot options ncr53c8xx=specf:1 if you want all chip features to be
89 * enabled by the driver.
90 */
91#define SCSI_NCR_SETUP_SPECIAL_FEATURES (3)
92
93#define SCSI_NCR_MAX_SYNC (80)
94
95/*
96 * Allow tags from 2 to 256, default 8
97 */
98#ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS
99#if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2
100#define SCSI_NCR_MAX_TAGS (2)
101#elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256
102#define SCSI_NCR_MAX_TAGS (256)
103#else
104#define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS
105#endif
106#else
107#define SCSI_NCR_MAX_TAGS (8)
108#endif
109
110/*
111 * Allow tagged command queuing support if configured with default number
112 * of tags set to max (see above).
113 */
114#ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
115#define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
116#elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE
117#define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS
118#else
119#define SCSI_NCR_SETUP_DEFAULT_TAGS (0)
120#endif
121
122/*
123 * Immediate arbitration
124 */
125#if defined(CONFIG_SCSI_NCR53C8XX_IARB)
126#define SCSI_NCR_IARB_SUPPORT
127#endif
128
129/*
130 * Sync transfer frequency at startup.
131 * Allow from 5Mhz to 80Mhz default 20 Mhz.
132 */
133#ifndef CONFIG_SCSI_NCR53C8XX_SYNC
134#define CONFIG_SCSI_NCR53C8XX_SYNC (20)
135#elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC
136#undef CONFIG_SCSI_NCR53C8XX_SYNC
137#define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC
138#endif
139
140#if CONFIG_SCSI_NCR53C8XX_SYNC == 0
141#define SCSI_NCR_SETUP_DEFAULT_SYNC (255)
142#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 5
143#define SCSI_NCR_SETUP_DEFAULT_SYNC (50)
144#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 20
145#define SCSI_NCR_SETUP_DEFAULT_SYNC (250/(CONFIG_SCSI_NCR53C8XX_SYNC))
146#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 33
147#define SCSI_NCR_SETUP_DEFAULT_SYNC (11)
148#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 40
149#define SCSI_NCR_SETUP_DEFAULT_SYNC (10)
150#else
151#define SCSI_NCR_SETUP_DEFAULT_SYNC (9)
152#endif
153
154/*
155 * Disallow disconnections at boot-up
156 */
157#ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT
158#define SCSI_NCR_SETUP_DISCONNECTION (0)
159#else
160#define SCSI_NCR_SETUP_DISCONNECTION (1)
161#endif
162
163/*
164 * Force synchronous negotiation for all targets
165 */
166#ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO
167#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (1)
168#else
169#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (0)
170#endif
171
172/*
173 * Disable master parity checking (flawed hardwares need that)
174 */
175#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK
176#define SCSI_NCR_SETUP_MASTER_PARITY (0)
177#else
178#define SCSI_NCR_SETUP_MASTER_PARITY (1)
179#endif
180
181/*
182 * Disable scsi parity checking (flawed devices may need that)
183 */
184#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK
185#define SCSI_NCR_SETUP_SCSI_PARITY (0)
186#else
187#define SCSI_NCR_SETUP_SCSI_PARITY (1)
188#endif
189
190/*
191 * Settle time after reset at boot-up
192 */
193#define SCSI_NCR_SETUP_SETTLE_TIME (2)
194
195/*
196** Bridge quirks work-around option defaulted to 1.
197*/
198#ifndef SCSI_NCR_PCIQ_WORK_AROUND_OPT
199#define SCSI_NCR_PCIQ_WORK_AROUND_OPT 1
200#endif
201
202/*
203** Work-around common bridge misbehaviour.
204**
205** - Do not flush posted writes in the opposite
206** direction on read.
207** - May reorder DMA writes to memory.
208**
209** This option should not affect performances
210** significantly, so it is the default.
211*/
212#if SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1
213#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
214#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
215#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
216
217/*
218** Same as option 1, but also deal with
219** misconfigured interrupts.
220**
221** - Edge triggerred instead of level sensitive.
222** - No interrupt line connected.
223** - IRQ number misconfigured.
224**
225** If no interrupt is delivered, the driver will
226** catch the interrupt conditions 10 times per
227** second. No need to say that this option is
228** not recommended.
229*/
230#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2
231#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
232#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
233#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
234#define SCSI_NCR_PCIQ_BROKEN_INTR
235
236/*
237** Some bridge designers decided to flush
238** everything prior to deliver the interrupt.
239** This option tries to deal with such a
240** behaviour.
241*/
242#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3
243#define SCSI_NCR_PCIQ_SYNC_ON_INTR
244#endif
245
246/*
247** Other parameters not configurable with "make config"
248** Avoid to change these constants, unless you know what you are doing.
249*/
250
251#define SCSI_NCR_ALWAYS_SIMPLE_TAG
252#define SCSI_NCR_MAX_SCATTER (127)
253#define SCSI_NCR_MAX_TARGET (16)
254
255/*
256** Compute some desirable value for CAN_QUEUE
257** and CMD_PER_LUN.
258** The driver will use lower values if these
259** ones appear to be too large.
260*/
261#define SCSI_NCR_CAN_QUEUE (8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)
262#define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS)
263
264#define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER)
265#define SCSI_NCR_TIMER_INTERVAL (HZ)
266
267#if 1 /* defined CONFIG_SCSI_MULTI_LUN */
268#define SCSI_NCR_MAX_LUN (16)
269#else
270#define SCSI_NCR_MAX_LUN (1)
271#endif
272
273/*
274 * IO functions definition for big/little endian CPU support.
275 * For now, the NCR is only supported in little endian addressing mode,
276 */
277
278#ifdef __BIG_ENDIAN
279
280#define inw_l2b inw
281#define inl_l2b inl
282#define outw_b2l outw
283#define outl_b2l outl
284
285#define readb_raw readb
286#define writeb_raw writeb
287
288#if defined(SCSI_NCR_BIG_ENDIAN)
289#define readw_l2b __raw_readw
290#define readl_l2b __raw_readl
291#define writew_b2l __raw_writew
292#define writel_b2l __raw_writel
293#define readw_raw __raw_readw
294#define readl_raw __raw_readl
295#define writew_raw __raw_writew
296#define writel_raw __raw_writel
297#else /* Other big-endian */
298#define readw_l2b readw
299#define readl_l2b readl
300#define writew_b2l writew
301#define writel_b2l writel
302#define readw_raw readw
303#define readl_raw readl
304#define writew_raw writew
305#define writel_raw writel
306#endif
307
308#else /* little endian */
309
310#define inw_raw inw
311#define inl_raw inl
312#define outw_raw outw
313#define outl_raw outl
314
315#define readb_raw readb
316#define readw_raw readw
317#define readl_raw readl
318#define writeb_raw writeb
319#define writew_raw writew
320#define writel_raw writel
321
322#endif
323
324#if !defined(__hppa__) && !defined(__mips__)
325#ifdef SCSI_NCR_BIG_ENDIAN
326#error "The NCR in BIG ENDIAN addressing mode is not (yet) supported"
327#endif
328#endif
329
330#define MEMORY_BARRIER() mb()
331
332
333/*
334 * If the NCR uses big endian addressing mode over the
335 * PCI, actual io register addresses for byte and word
336 * accesses must be changed according to lane routing.
337 * Btw, ncr_offb() and ncr_offw() macros only apply to
338 * constants and so donnot generate bloated code.
339 */
340
341#if defined(SCSI_NCR_BIG_ENDIAN)
342
343#define ncr_offb(o) (((o)&~3)+((~((o)&3))&3))
344#define ncr_offw(o) (((o)&~3)+((~((o)&3))&2))
345
346#else
347
348#define ncr_offb(o) (o)
349#define ncr_offw(o) (o)
350
351#endif
352
353/*
354 * If the CPU and the NCR use same endian-ness addressing,
355 * no byte reordering is needed for script patching.
356 * Macro cpu_to_scr() is to be used for script patching.
357 * Macro scr_to_cpu() is to be used for getting a DWORD
358 * from the script.
359 */
360
361#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
362
363#define cpu_to_scr(dw) cpu_to_le32(dw)
364#define scr_to_cpu(dw) le32_to_cpu(dw)
365
366#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
367
368#define cpu_to_scr(dw) cpu_to_be32(dw)
369#define scr_to_cpu(dw) be32_to_cpu(dw)
370
371#else
372
373#define cpu_to_scr(dw) (dw)
374#define scr_to_cpu(dw) (dw)
375
376#endif
377
378/*
379 * Access to the controller chip.
380 *
381 * If the CPU and the NCR use same endian-ness addressing,
382 * no byte reordering is needed for accessing chip io
383 * registers. Functions suffixed by '_raw' are assumed
384 * to access the chip over the PCI without doing byte
385 * reordering. Functions suffixed by '_l2b' are
386 * assumed to perform little-endian to big-endian byte
387 * reordering, those suffixed by '_b2l' blah, blah,
388 * blah, ...
389 */
390
391/*
392 * MEMORY mapped IO input / output
393 */
394
395#define INB_OFF(o) readb_raw((char __iomem *)np->reg + ncr_offb(o))
396#define OUTB_OFF(o, val) writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))
397
398#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
399
400#define INW_OFF(o) readw_l2b((char __iomem *)np->reg + ncr_offw(o))
401#define INL_OFF(o) readl_l2b((char __iomem *)np->reg + (o))
402
403#define OUTW_OFF(o, val) writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))
404#define OUTL_OFF(o, val) writel_b2l((val), (char __iomem *)np->reg + (o))
405
406#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
407
408#define INW_OFF(o) readw_b2l((char __iomem *)np->reg + ncr_offw(o))
409#define INL_OFF(o) readl_b2l((char __iomem *)np->reg + (o))
410
411#define OUTW_OFF(o, val) writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))
412#define OUTL_OFF(o, val) writel_l2b((val), (char __iomem *)np->reg + (o))
413
414#else
415
416#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
417/* Only 8 or 32 bit transfers allowed */
418#define INW_OFF(o) (readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))
419#else
420#define INW_OFF(o) readw_raw((char __iomem *)np->reg + ncr_offw(o))
421#endif
422#define INL_OFF(o) readl_raw((char __iomem *)np->reg + (o))
423
424#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
425/* Only 8 or 32 bit transfers allowed */
426#define OUTW_OFF(o, val) do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0)
427#else
428#define OUTW_OFF(o, val) writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))
429#endif
430#define OUTL_OFF(o, val) writel_raw((val), (char __iomem *)np->reg + (o))
431
432#endif
433
434#define INB(r) INB_OFF (offsetof(struct ncr_reg,r))
435#define INW(r) INW_OFF (offsetof(struct ncr_reg,r))
436#define INL(r) INL_OFF (offsetof(struct ncr_reg,r))
437
438#define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val))
439#define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val))
440#define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val))
441
442/*
443 * Set bit field ON, OFF
444 */
445
446#define OUTONB(r, m) OUTB(r, INB(r) | (m))
447#define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m))
448#define OUTONW(r, m) OUTW(r, INW(r) | (m))
449#define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m))
450#define OUTONL(r, m) OUTL(r, INL(r) | (m))
451#define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m))
452
453/*
454 * We normally want the chip to have a consistent view
455 * of driver internal data structures when we restart it.
456 * Thus these macros.
457 */
458#define OUTL_DSP(v) \
459 do { \
460 MEMORY_BARRIER(); \
461 OUTL (nc_dsp, (v)); \
462 } while (0)
463
464#define OUTONB_STD() \
465 do { \
466 MEMORY_BARRIER(); \
467 OUTONB (nc_dcntl, (STD|NOCOM)); \
468 } while (0)
469
470
471/*
472** NCR53C8XX devices features table.
473*/
474struct ncr_chip {
475 unsigned short revision_id;
476 unsigned char burst_max; /* log-base-2 of max burst */
477 unsigned char offset_max;
478 unsigned char nr_divisor;
479 unsigned int features;
480#define FE_LED0 (1<<0)
481#define FE_WIDE (1<<1) /* Wide data transfers */
482#define FE_ULTRA (1<<2) /* Ultra speed 20Mtrans/sec */
483#define FE_DBLR (1<<4) /* Clock doubler present */
484#define FE_QUAD (1<<5) /* Clock quadrupler present */
485#define FE_ERL (1<<6) /* Enable read line */
486#define FE_CLSE (1<<7) /* Cache line size enable */
487#define FE_WRIE (1<<8) /* Write & Invalidate enable */
488#define FE_ERMP (1<<9) /* Enable read multiple */
489#define FE_BOF (1<<10) /* Burst opcode fetch */
490#define FE_DFS (1<<11) /* DMA fifo size */
491#define FE_PFEN (1<<12) /* Prefetch enable */
492#define FE_LDSTR (1<<13) /* Load/Store supported */
493#define FE_RAM (1<<14) /* On chip RAM present */
494#define FE_VARCLK (1<<15) /* SCSI clock may vary */
495#define FE_RAM8K (1<<16) /* On chip RAM sized 8Kb */
496#define FE_64BIT (1<<17) /* Have a 64-bit PCI interface */
497#define FE_IO256 (1<<18) /* Requires full 256 bytes in PCI space */
498#define FE_NOPM (1<<19) /* Scripts handles phase mismatch */
499#define FE_LEDC (1<<20) /* Hardware control of LED */
500#define FE_DIFF (1<<21) /* Support Differential SCSI */
501#define FE_66MHZ (1<<23) /* 66MHz PCI Support */
502#define FE_DAC (1<<24) /* Support DAC cycles (64 bit addressing) */
503#define FE_ISTAT1 (1<<25) /* Have ISTAT1, MBOX0, MBOX1 registers */
504#define FE_DAC_IN_USE (1<<26) /* Platform does DAC cycles */
505#define FE_EHP (1<<27) /* 720: Even host parity */
506#define FE_MUX (1<<28) /* 720: Multiplexed bus */
507#define FE_EA (1<<29) /* 720: Enable Ack */
508
509#define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
510#define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80)
511#define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM)
512};
513
514
515/*
516** Driver setup structure.
517**
518** This structure is initialized from linux config options.
519** It can be overridden at boot-up by the boot command line.
520*/
521#define SCSI_NCR_MAX_EXCLUDES 8
522struct ncr_driver_setup {
523 u8 master_parity;
524 u8 scsi_parity;
525 u8 disconnection;
526 u8 special_features;
527 u8 force_sync_nego;
528 u8 reverse_probe;
529 u8 pci_fix_up;
530 u8 use_nvram;
531 u8 verbose;
532 u8 default_tags;
533 u16 default_sync;
534 u16 debug;
535 u8 burst_max;
536 u8 led_pin;
537 u8 max_wide;
538 u8 settle_delay;
539 u8 diff_support;
540 u8 irqm;
541 u8 bus_check;
542 u8 optimize;
543 u8 recovery;
544 u8 host_id;
545 u16 iarb;
546 u32 excludes[SCSI_NCR_MAX_EXCLUDES];
547 char tag_ctrl[100];
548};
549
550/*
551** Initial setup.
552** Can be overriden at startup by a command line.
553*/
554#define SCSI_NCR_DRIVER_SETUP \
555{ \
556 SCSI_NCR_SETUP_MASTER_PARITY, \
557 SCSI_NCR_SETUP_SCSI_PARITY, \
558 SCSI_NCR_SETUP_DISCONNECTION, \
559 SCSI_NCR_SETUP_SPECIAL_FEATURES, \
560 SCSI_NCR_SETUP_FORCE_SYNC_NEGO, \
561 0, \
562 0, \
563 1, \
564 0, \
565 SCSI_NCR_SETUP_DEFAULT_TAGS, \
566 SCSI_NCR_SETUP_DEFAULT_SYNC, \
567 0x00, \
568 7, \
569 0, \
570 1, \
571 SCSI_NCR_SETUP_SETTLE_TIME, \
572 0, \
573 0, \
574 1, \
575 0, \
576 0, \
577 255, \
578 0x00 \
579}
580
581/*
582** Boot fail safe setup.
583** Override initial setup from boot command line:
584** ncr53c8xx=safe:y
585*/
586#define SCSI_NCR_DRIVER_SAFE_SETUP \
587{ \
588 0, \
589 1, \
590 0, \
591 0, \
592 0, \
593 0, \
594 0, \
595 1, \
596 2, \
597 0, \
598 255, \
599 0x00, \
600 255, \
601 0, \
602 0, \
603 10, \
604 1, \
605 1, \
606 1, \
607 0, \
608 0, \
609 255 \
610}
611
612/**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/
613
614/*-----------------------------------------------------------------
615**
616** The ncr 53c810 register structure.
617**
618**-----------------------------------------------------------------
619*/
620
621struct ncr_reg {
622/*00*/ u8 nc_scntl0; /* full arb., ena parity, par->ATN */
623
624/*01*/ u8 nc_scntl1; /* no reset */
625 #define ISCON 0x10 /* connected to scsi */
626 #define CRST 0x08 /* force reset */
627 #define IARB 0x02 /* immediate arbitration */
628
629/*02*/ u8 nc_scntl2; /* no disconnect expected */
630 #define SDU 0x80 /* cmd: disconnect will raise error */
631 #define CHM 0x40 /* sta: chained mode */
632 #define WSS 0x08 /* sta: wide scsi send [W]*/
633 #define WSR 0x01 /* sta: wide scsi received [W]*/
634
635/*03*/ u8 nc_scntl3; /* cnf system clock dependent */
636 #define EWS 0x08 /* cmd: enable wide scsi [W]*/
637 #define ULTRA 0x80 /* cmd: ULTRA enable */
638 /* bits 0-2, 7 rsvd for C1010 */
639
640/*04*/ u8 nc_scid; /* cnf host adapter scsi address */
641 #define RRE 0x40 /* r/w:e enable response to resel. */
642 #define SRE 0x20 /* r/w:e enable response to select */
643
644/*05*/ u8 nc_sxfer; /* ### Sync speed and count */
645 /* bits 6-7 rsvd for C1010 */
646
647/*06*/ u8 nc_sdid; /* ### Destination-ID */
648
649/*07*/ u8 nc_gpreg; /* ??? IO-Pins */
650
651/*08*/ u8 nc_sfbr; /* ### First byte in phase */
652
653/*09*/ u8 nc_socl;
654 #define CREQ 0x80 /* r/w: SCSI-REQ */
655 #define CACK 0x40 /* r/w: SCSI-ACK */
656 #define CBSY 0x20 /* r/w: SCSI-BSY */
657 #define CSEL 0x10 /* r/w: SCSI-SEL */
658 #define CATN 0x08 /* r/w: SCSI-ATN */
659 #define CMSG 0x04 /* r/w: SCSI-MSG */
660 #define CC_D 0x02 /* r/w: SCSI-C_D */
661 #define CI_O 0x01 /* r/w: SCSI-I_O */
662
663/*0a*/ u8 nc_ssid;
664
665/*0b*/ u8 nc_sbcl;
666
667/*0c*/ u8 nc_dstat;
668 #define DFE 0x80 /* sta: dma fifo empty */
669 #define MDPE 0x40 /* int: master data parity error */
670 #define BF 0x20 /* int: script: bus fault */
671 #define ABRT 0x10 /* int: script: command aborted */
672 #define SSI 0x08 /* int: script: single step */
673 #define SIR 0x04 /* int: script: interrupt instruct. */
674 #define IID 0x01 /* int: script: illegal instruct. */
675
676/*0d*/ u8 nc_sstat0;
677 #define ILF 0x80 /* sta: data in SIDL register lsb */
678 #define ORF 0x40 /* sta: data in SODR register lsb */
679 #define OLF 0x20 /* sta: data in SODL register lsb */
680 #define AIP 0x10 /* sta: arbitration in progress */
681 #define LOA 0x08 /* sta: arbitration lost */
682 #define WOA 0x04 /* sta: arbitration won */
683 #define IRST 0x02 /* sta: scsi reset signal */
684 #define SDP 0x01 /* sta: scsi parity signal */
685
686/*0e*/ u8 nc_sstat1;
687 #define FF3210 0xf0 /* sta: bytes in the scsi fifo */
688
689/*0f*/ u8 nc_sstat2;
690 #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/
691 #define ORF1 0x40 /* sta: data in SODR register msb[W]*/
692 #define OLF1 0x20 /* sta: data in SODL register msb[W]*/
693 #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */
694 #define LDSC 0x02 /* sta: disconnect & reconnect */
695
696/*10*/ u8 nc_dsa; /* --> Base page */
697/*11*/ u8 nc_dsa1;
698/*12*/ u8 nc_dsa2;
699/*13*/ u8 nc_dsa3;
700
701/*14*/ u8 nc_istat; /* --> Main Command and status */
702 #define CABRT 0x80 /* cmd: abort current operation */
703 #define SRST 0x40 /* mod: reset chip */
704 #define SIGP 0x20 /* r/w: message from host to ncr */
705 #define SEM 0x10 /* r/w: message between host + ncr */
706 #define CON 0x08 /* sta: connected to scsi */
707 #define INTF 0x04 /* sta: int on the fly (reset by wr)*/
708 #define SIP 0x02 /* sta: scsi-interrupt */
709 #define DIP 0x01 /* sta: host/script interrupt */
710
711/*15*/ u8 nc_istat1; /* 896 and later cores only */
712 #define FLSH 0x04 /* sta: chip is flushing */
713 #define SRUN 0x02 /* sta: scripts are running */
714 #define SIRQD 0x01 /* r/w: disable INT pin */
715
716/*16*/ u8 nc_mbox0; /* 896 and later cores only */
717/*17*/ u8 nc_mbox1; /* 896 and later cores only */
718
719/*18*/ u8 nc_ctest0;
720 #define EHP 0x04 /* 720 even host parity */
721/*19*/ u8 nc_ctest1;
722
723/*1a*/ u8 nc_ctest2;
724 #define CSIGP 0x40
725 /* bits 0-2,7 rsvd for C1010 */
726
727/*1b*/ u8 nc_ctest3;
728 #define FLF 0x08 /* cmd: flush dma fifo */
729 #define CLF 0x04 /* cmd: clear dma fifo */
730 #define FM 0x02 /* mod: fetch pin mode */
731 #define WRIE 0x01 /* mod: write and invalidate enable */
732 /* bits 4-7 rsvd for C1010 */
733
734/*1c*/ u32 nc_temp; /* ### Temporary stack */
735
736/*20*/ u8 nc_dfifo;
737/*21*/ u8 nc_ctest4;
738 #define MUX 0x80 /* 720 host bus multiplex mode */
739 #define BDIS 0x80 /* mod: burst disable */
740 #define MPEE 0x08 /* mod: master parity error enable */
741
742/*22*/ u8 nc_ctest5;
743 #define DFS 0x20 /* mod: dma fifo size */
744 /* bits 0-1, 3-7 rsvd for C1010 */
745/*23*/ u8 nc_ctest6;
746
747/*24*/ u32 nc_dbc; /* ### Byte count and command */
748/*28*/ u32 nc_dnad; /* ### Next command register */
749/*2c*/ u32 nc_dsp; /* --> Script Pointer */
750/*30*/ u32 nc_dsps; /* --> Script pointer save/opcode#2 */
751
752/*34*/ u8 nc_scratcha; /* Temporary register a */
753/*35*/ u8 nc_scratcha1;
754/*36*/ u8 nc_scratcha2;
755/*37*/ u8 nc_scratcha3;
756
757/*38*/ u8 nc_dmode;
758 #define BL_2 0x80 /* mod: burst length shift value +2 */
759 #define BL_1 0x40 /* mod: burst length shift value +1 */
760 #define ERL 0x08 /* mod: enable read line */
761 #define ERMP 0x04 /* mod: enable read multiple */
762 #define BOF 0x02 /* mod: burst op code fetch */
763
764/*39*/ u8 nc_dien;
765/*3a*/ u8 nc_sbr;
766
767/*3b*/ u8 nc_dcntl; /* --> Script execution control */
768 #define CLSE 0x80 /* mod: cache line size enable */
769 #define PFF 0x40 /* cmd: pre-fetch flush */
770 #define PFEN 0x20 /* mod: pre-fetch enable */
771 #define EA 0x20 /* mod: 720 enable-ack */
772 #define SSM 0x10 /* mod: single step mode */
773 #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */
774 #define STD 0x04 /* cmd: start dma mode */
775 #define IRQD 0x02 /* mod: irq disable */
776 #define NOCOM 0x01 /* cmd: protect sfbr while reselect */
777 /* bits 0-1 rsvd for C1010 */
778
779/*3c*/ u32 nc_adder;
780
781/*40*/ u16 nc_sien; /* -->: interrupt enable */
782/*42*/ u16 nc_sist; /* <--: interrupt status */
783 #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
784 #define STO 0x0400/* sta: timeout (select) */
785 #define GEN 0x0200/* sta: timeout (general) */
786 #define HTH 0x0100/* sta: timeout (handshake) */
787 #define MA 0x80 /* sta: phase mismatch */
788 #define CMP 0x40 /* sta: arbitration complete */
789 #define SEL 0x20 /* sta: selected by another device */
790 #define RSL 0x10 /* sta: reselected by another device*/
791 #define SGE 0x08 /* sta: gross error (over/underflow)*/
792 #define UDC 0x04 /* sta: unexpected disconnect */
793 #define RST 0x02 /* sta: scsi bus reset detected */
794 #define PAR 0x01 /* sta: scsi parity error */
795
796/*44*/ u8 nc_slpar;
797/*45*/ u8 nc_swide;
798/*46*/ u8 nc_macntl;
799/*47*/ u8 nc_gpcntl;
800/*48*/ u8 nc_stime0; /* cmd: timeout for select&handshake*/
801/*49*/ u8 nc_stime1; /* cmd: timeout user defined */
802/*4a*/ u16 nc_respid; /* sta: Reselect-IDs */
803
804/*4c*/ u8 nc_stest0;
805
806/*4d*/ u8 nc_stest1;
807 #define SCLK 0x80 /* Use the PCI clock as SCSI clock */
808 #define DBLEN 0x08 /* clock doubler running */
809 #define DBLSEL 0x04 /* clock doubler selected */
810
811
812/*4e*/ u8 nc_stest2;
813 #define ROF 0x40 /* reset scsi offset (after gross error!) */
814 #define DIF 0x20 /* 720 SCSI differential mode */
815 #define EXT 0x02 /* extended filtering */
816
817/*4f*/ u8 nc_stest3;
818 #define TE 0x80 /* c: tolerAnt enable */
819 #define HSC 0x20 /* c: Halt SCSI Clock */
820 #define CSF 0x02 /* c: clear scsi fifo */
821
822/*50*/ u16 nc_sidl; /* Lowlevel: latched from scsi data */
823/*52*/ u8 nc_stest4;
824 #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */
825 #define SMODE_HVD 0x40 /* High Voltage Differential */
826 #define SMODE_SE 0x80 /* Single Ended */
827 #define SMODE_LVD 0xc0 /* Low Voltage Differential */
828 #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */
829 /* bits 0-5 rsvd for C1010 */
830
831/*53*/ u8 nc_53_;
832/*54*/ u16 nc_sodl; /* Lowlevel: data out to scsi data */
833/*56*/ u8 nc_ccntl0; /* Chip Control 0 (896) */
834 #define ENPMJ 0x80 /* Enable Phase Mismatch Jump */
835 #define PMJCTL 0x40 /* Phase Mismatch Jump Control */
836 #define ENNDJ 0x20 /* Enable Non Data PM Jump */
837 #define DISFC 0x10 /* Disable Auto FIFO Clear */
838 #define DILS 0x02 /* Disable Internal Load/Store */
839 #define DPR 0x01 /* Disable Pipe Req */
840
841/*57*/ u8 nc_ccntl1; /* Chip Control 1 (896) */
842 #define ZMOD 0x80 /* High Impedance Mode */
843 #define DIC 0x10 /* Disable Internal Cycles */
844 #define DDAC 0x08 /* Disable Dual Address Cycle */
845 #define XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode */
846 #define EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV */
847 #define EXDBMV 0x01 /* Enable 64-bit Direct BMOV */
848
849/*58*/ u16 nc_sbdl; /* Lowlevel: data from scsi data */
850/*5a*/ u16 nc_5a_;
851
852/*5c*/ u8 nc_scr0; /* Working register B */
853/*5d*/ u8 nc_scr1; /* */
854/*5e*/ u8 nc_scr2; /* */
855/*5f*/ u8 nc_scr3; /* */
856
857/*60*/ u8 nc_scrx[64]; /* Working register C-R */
858/*a0*/ u32 nc_mmrs; /* Memory Move Read Selector */
859/*a4*/ u32 nc_mmws; /* Memory Move Write Selector */
860/*a8*/ u32 nc_sfs; /* Script Fetch Selector */
861/*ac*/ u32 nc_drs; /* DSA Relative Selector */
862/*b0*/ u32 nc_sbms; /* Static Block Move Selector */
863/*b4*/ u32 nc_dbms; /* Dynamic Block Move Selector */
864/*b8*/ u32 nc_dnad64; /* DMA Next Address 64 */
865/*bc*/ u16 nc_scntl4; /* C1010 only */
866 #define U3EN 0x80 /* Enable Ultra 3 */
867 #define AIPEN 0x40 /* Allow check upper byte lanes */
868 #define XCLKH_DT 0x08 /* Extra clock of data hold on DT
869 transfer edge */
870 #define XCLKH_ST 0x04 /* Extra clock of data hold on ST
871 transfer edge */
872
873/*be*/ u8 nc_aipcntl0; /* Epat Control 1 C1010 only */
874/*bf*/ u8 nc_aipcntl1; /* AIP Control C1010_66 Only */
875
876/*c0*/ u32 nc_pmjad1; /* Phase Mismatch Jump Address 1 */
877/*c4*/ u32 nc_pmjad2; /* Phase Mismatch Jump Address 2 */
878/*c8*/ u8 nc_rbc; /* Remaining Byte Count */
879/*c9*/ u8 nc_rbc1; /* */
880/*ca*/ u8 nc_rbc2; /* */
881/*cb*/ u8 nc_rbc3; /* */
882
883/*cc*/ u8 nc_ua; /* Updated Address */
884/*cd*/ u8 nc_ua1; /* */
885/*ce*/ u8 nc_ua2; /* */
886/*cf*/ u8 nc_ua3; /* */
887/*d0*/ u32 nc_esa; /* Entry Storage Address */
888/*d4*/ u8 nc_ia; /* Instruction Address */
889/*d5*/ u8 nc_ia1;
890/*d6*/ u8 nc_ia2;
891/*d7*/ u8 nc_ia3;
892/*d8*/ u32 nc_sbc; /* SCSI Byte Count (3 bytes only) */
893/*dc*/ u32 nc_csbc; /* Cumulative SCSI Byte Count */
894
895 /* Following for C1010 only */
896/*e0*/ u16 nc_crcpad; /* CRC Value */
897/*e2*/ u8 nc_crccntl0; /* CRC control register */
898 #define SNDCRC 0x10 /* Send CRC Request */
899/*e3*/ u8 nc_crccntl1; /* CRC control register */
900/*e4*/ u32 nc_crcdata; /* CRC data register */
901/*e8*/ u32 nc_e8_; /* rsvd */
902/*ec*/ u32 nc_ec_; /* rsvd */
903/*f0*/ u16 nc_dfbc; /* DMA FIFO byte count */
904
905};
906
907/*-----------------------------------------------------------
908**
909** Utility macros for the script.
910**
911**-----------------------------------------------------------
912*/
913
914#define REGJ(p,r) (offsetof(struct ncr_reg, p ## r))
915#define REG(r) REGJ (nc_, r)
916
917typedef u32 ncrcmd;
918
919/*-----------------------------------------------------------
920**
921** SCSI phases
922**
923** DT phases illegal for ncr driver.
924**
925**-----------------------------------------------------------
926*/
927
928#define SCR_DATA_OUT 0x00000000
929#define SCR_DATA_IN 0x01000000
930#define SCR_COMMAND 0x02000000
931#define SCR_STATUS 0x03000000
932#define SCR_DT_DATA_OUT 0x04000000
933#define SCR_DT_DATA_IN 0x05000000
934#define SCR_MSG_OUT 0x06000000
935#define SCR_MSG_IN 0x07000000
936
937#define SCR_ILG_OUT 0x04000000
938#define SCR_ILG_IN 0x05000000
939
940/*-----------------------------------------------------------
941**
942** Data transfer via SCSI.
943**
944**-----------------------------------------------------------
945**
946** MOVE_ABS (LEN)
947** <<start address>>
948**
949** MOVE_IND (LEN)
950** <<dnad_offset>>
951**
952** MOVE_TBL
953** <<dnad_offset>>
954**
955**-----------------------------------------------------------
956*/
957
958#define OPC_MOVE 0x08000000
959
960#define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
961#define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
962#define SCR_MOVE_TBL (0x10000000 | OPC_MOVE)
963
964#define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
965#define SCR_CHMOV_IND(l) ((0x20000000) | (l))
966#define SCR_CHMOV_TBL (0x10000000)
967
968struct scr_tblmove {
969 u32 size;
970 u32 addr;
971};
972
973/*-----------------------------------------------------------
974**
975** Selection
976**
977**-----------------------------------------------------------
978**
979** SEL_ABS | SCR_ID (0..15) [ | REL_JMP]
980** <<alternate_address>>
981**
982** SEL_TBL | << dnad_offset>> [ | REL_JMP]
983** <<alternate_address>>
984**
985**-----------------------------------------------------------
986*/
987
988#define SCR_SEL_ABS 0x40000000
989#define SCR_SEL_ABS_ATN 0x41000000
990#define SCR_SEL_TBL 0x42000000
991#define SCR_SEL_TBL_ATN 0x43000000
992
993
994#ifdef SCSI_NCR_BIG_ENDIAN
995struct scr_tblsel {
996 u8 sel_scntl3;
997 u8 sel_id;
998 u8 sel_sxfer;
999 u8 sel_scntl4;
1000};
1001#else
1002struct scr_tblsel {
1003 u8 sel_scntl4;
1004 u8 sel_sxfer;
1005 u8 sel_id;
1006 u8 sel_scntl3;
1007};
1008#endif
1009
1010#define SCR_JMP_REL 0x04000000
1011#define SCR_ID(id) (((u32)(id)) << 16)
1012
1013/*-----------------------------------------------------------
1014**
1015** Waiting for Disconnect or Reselect
1016**
1017**-----------------------------------------------------------
1018**
1019** WAIT_DISC
1020** dummy: <<alternate_address>>
1021**
1022** WAIT_RESEL
1023** <<alternate_address>>
1024**
1025**-----------------------------------------------------------
1026*/
1027
1028#define SCR_WAIT_DISC 0x48000000
1029#define SCR_WAIT_RESEL 0x50000000
1030
1031/*-----------------------------------------------------------
1032**
1033** Bit Set / Reset
1034**
1035**-----------------------------------------------------------
1036**
1037** SET (flags {|.. })
1038**
1039** CLR (flags {|.. })
1040**
1041**-----------------------------------------------------------
1042*/
1043
1044#define SCR_SET(f) (0x58000000 | (f))
1045#define SCR_CLR(f) (0x60000000 | (f))
1046
1047#define SCR_CARRY 0x00000400
1048#define SCR_TRG 0x00000200
1049#define SCR_ACK 0x00000040
1050#define SCR_ATN 0x00000008
1051
1052
1053
1054
1055/*-----------------------------------------------------------
1056**
1057** Memory to memory move
1058**
1059**-----------------------------------------------------------
1060**
1061** COPY (bytecount)
1062** << source_address >>
1063** << destination_address >>
1064**
1065** SCR_COPY sets the NO FLUSH option by default.
1066** SCR_COPY_F does not set this option.
1067**
1068** For chips which do not support this option,
1069** ncr_copy_and_bind() will remove this bit.
1070**-----------------------------------------------------------
1071*/
1072
1073#define SCR_NO_FLUSH 0x01000000
1074
1075#define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
1076#define SCR_COPY_F(n) (0xc0000000 | (n))
1077
1078/*-----------------------------------------------------------
1079**
1080** Register move and binary operations
1081**
1082**-----------------------------------------------------------
1083**
1084** SFBR_REG (reg, op, data) reg = SFBR op data
1085** << 0 >>
1086**
1087** REG_SFBR (reg, op, data) SFBR = reg op data
1088** << 0 >>
1089**
1090** REG_REG (reg, op, data) reg = reg op data
1091** << 0 >>
1092**
1093**-----------------------------------------------------------
1094** On 810A, 860, 825A, 875, 895 and 896 chips the content
1095** of SFBR register can be used as data (SCR_SFBR_DATA).
1096** The 896 has additionnal IO registers starting at
1097** offset 0x80. Bit 7 of register offset is stored in
1098** bit 7 of the SCRIPTS instruction first DWORD.
1099**-----------------------------------------------------------
1100*/
1101
1102#define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
1103
1104#define SCR_SFBR_REG(reg,op,data) \
1105 (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1106
1107#define SCR_REG_SFBR(reg,op,data) \
1108 (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1109
1110#define SCR_REG_REG(reg,op,data) \
1111 (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1112
1113
1114#define SCR_LOAD 0x00000000
1115#define SCR_SHL 0x01000000
1116#define SCR_OR 0x02000000
1117#define SCR_XOR 0x03000000
1118#define SCR_AND 0x04000000
1119#define SCR_SHR 0x05000000
1120#define SCR_ADD 0x06000000
1121#define SCR_ADDC 0x07000000
1122
1123#define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */
1124
1125/*-----------------------------------------------------------
1126**
1127** FROM_REG (reg) SFBR = reg
1128** << 0 >>
1129**
1130** TO_REG (reg) reg = SFBR
1131** << 0 >>
1132**
1133** LOAD_REG (reg, data) reg = <data>
1134** << 0 >>
1135**
1136** LOAD_SFBR(data) SFBR = <data>
1137** << 0 >>
1138**
1139**-----------------------------------------------------------
1140*/
1141
1142#define SCR_FROM_REG(reg) \
1143 SCR_REG_SFBR(reg,SCR_OR,0)
1144
1145#define SCR_TO_REG(reg) \
1146 SCR_SFBR_REG(reg,SCR_OR,0)
1147
1148#define SCR_LOAD_REG(reg,data) \
1149 SCR_REG_REG(reg,SCR_LOAD,data)
1150
1151#define SCR_LOAD_SFBR(data) \
1152 (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
1153
1154/*-----------------------------------------------------------
1155**
1156** LOAD from memory to register.
1157** STORE from register to memory.
1158**
1159** Only supported by 810A, 860, 825A, 875, 895 and 896.
1160**
1161**-----------------------------------------------------------
1162**
1163** LOAD_ABS (LEN)
1164** <<start address>>
1165**
1166** LOAD_REL (LEN) (DSA relative)
1167** <<dsa_offset>>
1168**
1169**-----------------------------------------------------------
1170*/
1171
1172#define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
1173#define SCR_NO_FLUSH2 0x02000000
1174#define SCR_DSA_REL2 0x10000000
1175
1176#define SCR_LOAD_R(reg, how, n) \
1177 (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1178
1179#define SCR_STORE_R(reg, how, n) \
1180 (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1181
1182#define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
1183#define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
1184#define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
1185#define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
1186
1187#define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
1188#define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
1189#define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
1190#define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
1191
1192
1193/*-----------------------------------------------------------
1194**
1195** Waiting for Disconnect or Reselect
1196**
1197**-----------------------------------------------------------
1198**
1199** JUMP [ | IFTRUE/IFFALSE ( ... ) ]
1200** <<address>>
1201**
1202** JUMPR [ | IFTRUE/IFFALSE ( ... ) ]
1203** <<distance>>
1204**
1205** CALL [ | IFTRUE/IFFALSE ( ... ) ]
1206** <<address>>
1207**
1208** CALLR [ | IFTRUE/IFFALSE ( ... ) ]
1209** <<distance>>
1210**
1211** RETURN [ | IFTRUE/IFFALSE ( ... ) ]
1212** <<dummy>>
1213**
1214** INT [ | IFTRUE/IFFALSE ( ... ) ]
1215** <<ident>>
1216**
1217** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ]
1218** <<ident>>
1219**
1220** Conditions:
1221** WHEN (phase)
1222** IF (phase)
1223** CARRYSET
1224** DATA (data, mask)
1225**
1226**-----------------------------------------------------------
1227*/
1228
1229#define SCR_NO_OP 0x80000000
1230#define SCR_JUMP 0x80080000
1231#define SCR_JUMP64 0x80480000
1232#define SCR_JUMPR 0x80880000
1233#define SCR_CALL 0x88080000
1234#define SCR_CALLR 0x88880000
1235#define SCR_RETURN 0x90080000
1236#define SCR_INT 0x98080000
1237#define SCR_INT_FLY 0x98180000
1238
1239#define IFFALSE(arg) (0x00080000 | (arg))
1240#define IFTRUE(arg) (0x00000000 | (arg))
1241
1242#define WHEN(phase) (0x00030000 | (phase))
1243#define IF(phase) (0x00020000 | (phase))
1244
1245#define DATA(D) (0x00040000 | ((D) & 0xff))
1246#define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
1247
1248#define CARRYSET (0x00200000)
1249
1250/*-----------------------------------------------------------
1251**
1252** SCSI constants.
1253**
1254**-----------------------------------------------------------
1255*/
1256
1257/*
1258** Messages
1259*/
1260
1261#define M_COMPLETE COMMAND_COMPLETE
1262#define M_EXTENDED EXTENDED_MESSAGE
1263#define M_SAVE_DP SAVE_POINTERS
1264#define M_RESTORE_DP RESTORE_POINTERS
1265#define M_DISCONNECT DISCONNECT
1266#define M_ID_ERROR INITIATOR_ERROR
1267#define M_ABORT ABORT_TASK_SET
1268#define M_REJECT MESSAGE_REJECT
1269#define M_NOOP NOP
1270#define M_PARITY MSG_PARITY_ERROR
1271#define M_LCOMPLETE LINKED_CMD_COMPLETE
1272#define M_FCOMPLETE LINKED_FLG_CMD_COMPLETE
1273#define M_RESET TARGET_RESET
1274#define M_ABORT_TAG ABORT_TASK
1275#define M_CLEAR_QUEUE CLEAR_TASK_SET
1276#define M_INIT_REC INITIATE_RECOVERY
1277#define M_REL_REC RELEASE_RECOVERY
1278#define M_TERMINATE (0x11)
1279#define M_SIMPLE_TAG SIMPLE_QUEUE_TAG
1280#define M_HEAD_TAG HEAD_OF_QUEUE_TAG
1281#define M_ORDERED_TAG ORDERED_QUEUE_TAG
1282#define M_IGN_RESIDUE IGNORE_WIDE_RESIDUE
1283#define M_IDENTIFY (0x80)
1284
1285#define M_X_MODIFY_DP EXTENDED_MODIFY_DATA_POINTER
1286#define M_X_SYNC_REQ EXTENDED_SDTR
1287#define M_X_WIDE_REQ EXTENDED_WDTR
1288#define M_X_PPR_REQ EXTENDED_PPR
1289
1290/*
1291** Status
1292*/
1293
1294#define S_GOOD (0x00)
1295#define S_CHECK_COND (0x02)
1296#define S_COND_MET (0x04)
1297#define S_BUSY (0x08)
1298#define S_INT (0x10)
1299#define S_INT_COND_MET (0x14)
1300#define S_CONFLICT (0x18)
1301#define S_TERMINATED (0x20)
1302#define S_QUEUE_FULL (0x28)
1303#define S_ILLEGAL (0xff)
1304#define S_SENSE (0x80)
1305
1306/*
1307 * End of ncrreg from FreeBSD
1308 */
48 1309
49/* 1310/*
50 Build a scatter/gather entry. 1311 Build a scatter/gather entry.
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 7c5306499832..0c9edb7051f4 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -95,27 +95,21 @@ typedef struct scsi_info_t {
95} scsi_info_t; 95} scsi_info_t;
96 96
97static void aha152x_release_cs(dev_link_t *link); 97static void aha152x_release_cs(dev_link_t *link);
98static int aha152x_event(event_t event, int priority, 98static void aha152x_detach(struct pcmcia_device *p_dev);
99 event_callback_args_t *args); 99static void aha152x_config_cs(dev_link_t *link);
100
101static dev_link_t *aha152x_attach(void);
102static void aha152x_detach(dev_link_t *);
103 100
104static dev_link_t *dev_list; 101static dev_link_t *dev_list;
105static dev_info_t dev_info = "aha152x_cs";
106 102
107static dev_link_t *aha152x_attach(void) 103static int aha152x_attach(struct pcmcia_device *p_dev)
108{ 104{
109 scsi_info_t *info; 105 scsi_info_t *info;
110 client_reg_t client_reg;
111 dev_link_t *link; 106 dev_link_t *link;
112 int ret;
113 107
114 DEBUG(0, "aha152x_attach()\n"); 108 DEBUG(0, "aha152x_attach()\n");
115 109
116 /* Create new SCSI device */ 110 /* Create new SCSI device */
117 info = kmalloc(sizeof(*info), GFP_KERNEL); 111 info = kmalloc(sizeof(*info), GFP_KERNEL);
118 if (!info) return NULL; 112 if (!info) return -ENOMEM;
119 memset(info, 0, sizeof(*info)); 113 memset(info, 0, sizeof(*info));
120 link = &info->link; link->priv = info; 114 link = &info->link; link->priv = info;
121 115
@@ -129,26 +123,20 @@ static dev_link_t *aha152x_attach(void)
129 link->conf.IntType = INT_MEMORY_AND_IO; 123 link->conf.IntType = INT_MEMORY_AND_IO;
130 link->conf.Present = PRESENT_OPTION; 124 link->conf.Present = PRESENT_OPTION;
131 125
132 /* Register with Card Services */ 126 link->handle = p_dev;
133 link->next = dev_list; 127 p_dev->instance = link;
134 dev_list = link; 128
135 client_reg.dev_info = &dev_info; 129 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
136 client_reg.Version = 0x0210; 130 aha152x_config_cs(link);
137 client_reg.event_callback_args.client_data = link; 131
138 ret = pcmcia_register_client(&link->handle, &client_reg); 132 return 0;
139 if (ret != 0) {
140 cs_error(link->handle, RegisterClient, ret);
141 aha152x_detach(link);
142 return NULL;
143 }
144
145 return link;
146} /* aha152x_attach */ 133} /* aha152x_attach */
147 134
148/*====================================================================*/ 135/*====================================================================*/
149 136
150static void aha152x_detach(dev_link_t *link) 137static void aha152x_detach(struct pcmcia_device *p_dev)
151{ 138{
139 dev_link_t *link = dev_to_instance(p_dev);
152 dev_link_t **linkp; 140 dev_link_t **linkp;
153 141
154 DEBUG(0, "aha152x_detach(0x%p)\n", link); 142 DEBUG(0, "aha152x_detach(0x%p)\n", link);
@@ -162,9 +150,6 @@ static void aha152x_detach(dev_link_t *link)
162 if (link->state & DEV_CONFIG) 150 if (link->state & DEV_CONFIG)
163 aha152x_release_cs(link); 151 aha152x_release_cs(link);
164 152
165 if (link->handle)
166 pcmcia_deregister_client(link->handle);
167
168 /* Unlink device structure, free bits */ 153 /* Unlink device structure, free bits */
169 *linkp = link->next; 154 *linkp = link->next;
170 kfree(link->priv); 155 kfree(link->priv);
@@ -272,44 +257,31 @@ static void aha152x_release_cs(dev_link_t *link)
272 link->state &= ~DEV_CONFIG; 257 link->state &= ~DEV_CONFIG;
273} 258}
274 259
275static int aha152x_event(event_t event, int priority, 260static int aha152x_suspend(struct pcmcia_device *dev)
276 event_callback_args_t *args)
277{ 261{
278 dev_link_t *link = args->client_data; 262 dev_link_t *link = dev_to_instance(dev);
279 scsi_info_t *info = link->priv; 263
280
281 DEBUG(0, "aha152x_event(0x%06x)\n", event);
282
283 switch (event) {
284 case CS_EVENT_CARD_REMOVAL:
285 link->state &= ~DEV_PRESENT;
286 if (link->state & DEV_CONFIG)
287 aha152x_release_cs(link);
288 break;
289 case CS_EVENT_CARD_INSERTION:
290 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
291 aha152x_config_cs(link);
292 break;
293 case CS_EVENT_PM_SUSPEND:
294 link->state |= DEV_SUSPEND; 264 link->state |= DEV_SUSPEND;
295 /* Fall through... */
296 case CS_EVENT_RESET_PHYSICAL:
297 if (link->state & DEV_CONFIG) 265 if (link->state & DEV_CONFIG)
298 pcmcia_release_configuration(link->handle); 266 pcmcia_release_configuration(link->handle);
299 break; 267
300 case CS_EVENT_PM_RESUME: 268 return 0;
269}
270
271static int aha152x_resume(struct pcmcia_device *dev)
272{
273 dev_link_t *link = dev_to_instance(dev);
274 scsi_info_t *info = link->priv;
275
301 link->state &= ~DEV_SUSPEND; 276 link->state &= ~DEV_SUSPEND;
302 /* Fall through... */
303 case CS_EVENT_CARD_RESET:
304 if (link->state & DEV_CONFIG) { 277 if (link->state & DEV_CONFIG) {
305 Scsi_Cmnd tmp; 278 Scsi_Cmnd tmp;
306 pcmcia_request_configuration(link->handle, &link->conf); 279 pcmcia_request_configuration(link->handle, &link->conf);
307 tmp.device->host = info->host; 280 tmp.device->host = info->host;
308 aha152x_host_reset(&tmp); 281 aha152x_host_reset(&tmp);
309 } 282 }
310 break; 283
311 } 284 return 0;
312 return 0;
313} 285}
314 286
315static struct pcmcia_device_id aha152x_ids[] = { 287static struct pcmcia_device_id aha152x_ids[] = {
@@ -327,10 +299,11 @@ static struct pcmcia_driver aha152x_cs_driver = {
327 .drv = { 299 .drv = {
328 .name = "aha152x_cs", 300 .name = "aha152x_cs",
329 }, 301 },
330 .attach = aha152x_attach, 302 .probe = aha152x_attach,
331 .event = aha152x_event, 303 .remove = aha152x_detach,
332 .detach = aha152x_detach,
333 .id_table = aha152x_ids, 304 .id_table = aha152x_ids,
305 .suspend = aha152x_suspend,
306 .resume = aha152x_resume,
334}; 307};
335 308
336static int __init init_aha152x_cs(void) 309static int __init init_aha152x_cs(void)
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index db8f5cd85ffe..788c58d805f3 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -80,29 +80,19 @@ typedef struct scsi_info_t {
80 80
81 81
82static void fdomain_release(dev_link_t *link); 82static void fdomain_release(dev_link_t *link);
83static int fdomain_event(event_t event, int priority, 83static void fdomain_detach(struct pcmcia_device *p_dev);
84 event_callback_args_t *args); 84static void fdomain_config(dev_link_t *link);
85 85
86static dev_link_t *fdomain_attach(void); 86static int fdomain_attach(struct pcmcia_device *p_dev)
87static void fdomain_detach(dev_link_t *);
88
89
90static dev_link_t *dev_list = NULL;
91
92static dev_info_t dev_info = "fdomain_cs";
93
94static dev_link_t *fdomain_attach(void)
95{ 87{
96 scsi_info_t *info; 88 scsi_info_t *info;
97 client_reg_t client_reg;
98 dev_link_t *link; 89 dev_link_t *link;
99 int ret; 90
100
101 DEBUG(0, "fdomain_attach()\n"); 91 DEBUG(0, "fdomain_attach()\n");
102 92
103 /* Create new SCSI device */ 93 /* Create new SCSI device */
104 info = kmalloc(sizeof(*info), GFP_KERNEL); 94 info = kmalloc(sizeof(*info), GFP_KERNEL);
105 if (!info) return NULL; 95 if (!info) return -ENOMEM;
106 memset(info, 0, sizeof(*info)); 96 memset(info, 0, sizeof(*info));
107 link = &info->link; link->priv = info; 97 link = &info->link; link->priv = info;
108 link->io.NumPorts1 = 0x10; 98 link->io.NumPorts1 = 0x10;
@@ -115,46 +105,27 @@ static dev_link_t *fdomain_attach(void)
115 link->conf.IntType = INT_MEMORY_AND_IO; 105 link->conf.IntType = INT_MEMORY_AND_IO;
116 link->conf.Present = PRESENT_OPTION; 106 link->conf.Present = PRESENT_OPTION;
117 107
118 /* Register with Card Services */ 108 link->handle = p_dev;
119 link->next = dev_list; 109 p_dev->instance = link;
120 dev_list = link; 110
121 client_reg.dev_info = &dev_info; 111 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
122 client_reg.Version = 0x0210; 112 fdomain_config(link);
123 client_reg.event_callback_args.client_data = link; 113
124 ret = pcmcia_register_client(&link->handle, &client_reg); 114 return 0;
125 if (ret != 0) {
126 cs_error(link->handle, RegisterClient, ret);
127 fdomain_detach(link);
128 return NULL;
129 }
130
131 return link;
132} /* fdomain_attach */ 115} /* fdomain_attach */
133 116
134/*====================================================================*/ 117/*====================================================================*/
135 118
136static void fdomain_detach(dev_link_t *link) 119static void fdomain_detach(struct pcmcia_device *p_dev)
137{ 120{
138 dev_link_t **linkp; 121 dev_link_t *link = dev_to_instance(p_dev);
139 122
140 DEBUG(0, "fdomain_detach(0x%p)\n", link); 123 DEBUG(0, "fdomain_detach(0x%p)\n", link);
141
142 /* Locate device structure */
143 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
144 if (*linkp == link) break;
145 if (*linkp == NULL)
146 return;
147 124
148 if (link->state & DEV_CONFIG) 125 if (link->state & DEV_CONFIG)
149 fdomain_release(link); 126 fdomain_release(link);
150 127
151 if (link->handle) 128 kfree(link->priv);
152 pcmcia_deregister_client(link->handle);
153
154 /* Unlink device structure, free bits */
155 *linkp = link->next;
156 kfree(link->priv);
157
158} /* fdomain_detach */ 129} /* fdomain_detach */
159 130
160/*====================================================================*/ 131/*====================================================================*/
@@ -256,43 +227,29 @@ static void fdomain_release(dev_link_t *link)
256 227
257/*====================================================================*/ 228/*====================================================================*/
258 229
259static int fdomain_event(event_t event, int priority, 230static int fdomain_suspend(struct pcmcia_device *dev)
260 event_callback_args_t *args)
261{ 231{
262 dev_link_t *link = args->client_data; 232 dev_link_t *link = dev_to_instance(dev);
263 233
264 DEBUG(1, "fdomain_event(0x%06x)\n", event);
265
266 switch (event) {
267 case CS_EVENT_CARD_REMOVAL:
268 link->state &= ~DEV_PRESENT;
269 if (link->state & DEV_CONFIG)
270 fdomain_release(link);
271 break;
272 case CS_EVENT_CARD_INSERTION:
273 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
274 fdomain_config(link);
275 break;
276 case CS_EVENT_PM_SUSPEND:
277 link->state |= DEV_SUSPEND; 234 link->state |= DEV_SUSPEND;
278 /* Fall through... */
279 case CS_EVENT_RESET_PHYSICAL:
280 if (link->state & DEV_CONFIG) 235 if (link->state & DEV_CONFIG)
281 pcmcia_release_configuration(link->handle); 236 pcmcia_release_configuration(link->handle);
282 break; 237
283 case CS_EVENT_PM_RESUME: 238 return 0;
239}
240
241static int fdomain_resume(struct pcmcia_device *dev)
242{
243 dev_link_t *link = dev_to_instance(dev);
244
284 link->state &= ~DEV_SUSPEND; 245 link->state &= ~DEV_SUSPEND;
285 /* Fall through... */
286 case CS_EVENT_CARD_RESET:
287 if (link->state & DEV_CONFIG) { 246 if (link->state & DEV_CONFIG) {
288 pcmcia_request_configuration(link->handle, &link->conf); 247 pcmcia_request_configuration(link->handle, &link->conf);
289 fdomain_16x0_bus_reset(NULL); 248 fdomain_16x0_bus_reset(NULL);
290 } 249 }
291 break;
292 }
293 return 0;
294} /* fdomain_event */
295 250
251 return 0;
252}
296 253
297static struct pcmcia_device_id fdomain_ids[] = { 254static struct pcmcia_device_id fdomain_ids[] = {
298 PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20), 255 PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20),
@@ -307,10 +264,11 @@ static struct pcmcia_driver fdomain_cs_driver = {
307 .drv = { 264 .drv = {
308 .name = "fdomain_cs", 265 .name = "fdomain_cs",
309 }, 266 },
310 .attach = fdomain_attach, 267 .probe = fdomain_attach,
311 .event = fdomain_event, 268 .remove = fdomain_detach,
312 .detach = fdomain_detach,
313 .id_table = fdomain_ids, 269 .id_table = fdomain_ids,
270 .suspend = fdomain_suspend,
271 .resume = fdomain_resume,
314}; 272};
315 273
316static int __init init_fdomain_cs(void) 274static int __init init_fdomain_cs(void)
@@ -321,7 +279,6 @@ static int __init init_fdomain_cs(void)
321static void __exit exit_fdomain_cs(void) 279static void __exit exit_fdomain_cs(void)
322{ 280{
323 pcmcia_unregister_driver(&fdomain_cs_driver); 281 pcmcia_unregister_driver(&fdomain_cs_driver);
324 BUG_ON(dev_list != NULL);
325} 282}
326 283
327module_init(init_fdomain_cs); 284module_init(init_fdomain_cs);
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 050ea13ff80b..9e3ab3fd5355 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -104,9 +104,6 @@ static struct scsi_host_template nsp_driver_template = {
104#endif 104#endif
105}; 105};
106 106
107static dev_link_t *dev_list = NULL;
108static dev_info_t dev_info = {"nsp_cs"};
109
110static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ 107static nsp_hw_data nsp_data_base; /* attach <-> detect glue */
111 108
112 109
@@ -1596,19 +1593,17 @@ static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt)
1596 configure the card at this point -- we wait until we receive a 1593 configure the card at this point -- we wait until we receive a
1597 card insertion event. 1594 card insertion event.
1598======================================================================*/ 1595======================================================================*/
1599static dev_link_t *nsp_cs_attach(void) 1596static int nsp_cs_attach(struct pcmcia_device *p_dev)
1600{ 1597{
1601 scsi_info_t *info; 1598 scsi_info_t *info;
1602 client_reg_t client_reg;
1603 dev_link_t *link; 1599 dev_link_t *link;
1604 int ret;
1605 nsp_hw_data *data = &nsp_data_base; 1600 nsp_hw_data *data = &nsp_data_base;
1606 1601
1607 nsp_dbg(NSP_DEBUG_INIT, "in"); 1602 nsp_dbg(NSP_DEBUG_INIT, "in");
1608 1603
1609 /* Create new SCSI device */ 1604 /* Create new SCSI device */
1610 info = kmalloc(sizeof(*info), GFP_KERNEL); 1605 info = kmalloc(sizeof(*info), GFP_KERNEL);
1611 if (info == NULL) { return NULL; } 1606 if (info == NULL) { return -ENOMEM; }
1612 memset(info, 0, sizeof(*info)); 1607 memset(info, 0, sizeof(*info));
1613 link = &info->link; 1608 link = &info->link;
1614 link->priv = info; 1609 link->priv = info;
@@ -1636,23 +1631,14 @@ static dev_link_t *nsp_cs_attach(void)
1636 link->conf.IntType = INT_MEMORY_AND_IO; 1631 link->conf.IntType = INT_MEMORY_AND_IO;
1637 link->conf.Present = PRESENT_OPTION; 1632 link->conf.Present = PRESENT_OPTION;
1638 1633
1634 link->handle = p_dev;
1635 p_dev->instance = link;
1639 1636
1640 /* Register with Card Services */ 1637 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1641 link->next = dev_list; 1638 nsp_cs_config(link);
1642 dev_list = link;
1643 client_reg.dev_info = &dev_info;
1644 client_reg.Version = 0x0210;
1645 client_reg.event_callback_args.client_data = link;
1646 ret = pcmcia_register_client(&link->handle, &client_reg);
1647 if (ret != CS_SUCCESS) {
1648 cs_error(link->handle, RegisterClient, ret);
1649 nsp_cs_detach(link);
1650 return NULL;
1651 }
1652
1653 1639
1654 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); 1640 nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link);
1655 return link; 1641 return 0;
1656} /* nsp_cs_attach */ 1642} /* nsp_cs_attach */
1657 1643
1658 1644
@@ -1662,35 +1648,19 @@ static dev_link_t *nsp_cs_attach(void)
1662 structures are freed. Otherwise, the structures will be freed 1648 structures are freed. Otherwise, the structures will be freed
1663 when the device is released. 1649 when the device is released.
1664======================================================================*/ 1650======================================================================*/
1665static void nsp_cs_detach(dev_link_t *link) 1651static void nsp_cs_detach(struct pcmcia_device *p_dev)
1666{ 1652{
1667 dev_link_t **linkp; 1653 dev_link_t *link = dev_to_instance(p_dev);
1668 1654
1669 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link); 1655 nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", link);
1670 1656
1671 /* Locate device structure */ 1657 if (link->state & DEV_CONFIG) {
1672 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) { 1658 ((scsi_info_t *)link->priv)->stop = 1;
1673 if (*linkp == link) {
1674 break;
1675 }
1676 }
1677 if (*linkp == NULL) {
1678 return;
1679 }
1680
1681 if (link->state & DEV_CONFIG)
1682 nsp_cs_release(link); 1659 nsp_cs_release(link);
1683
1684 /* Break the link with Card Services */
1685 if (link->handle) {
1686 pcmcia_deregister_client(link->handle);
1687 } 1660 }
1688 1661
1689 /* Unlink device structure, free bits */
1690 *linkp = link->next;
1691 kfree(link->priv); 1662 kfree(link->priv);
1692 link->priv = NULL; 1663 link->priv = NULL;
1693
1694} /* nsp_cs_detach */ 1664} /* nsp_cs_detach */
1695 1665
1696 1666
@@ -2021,99 +1991,58 @@ static void nsp_cs_release(dev_link_t *link)
2021#endif 1991#endif
2022} /* nsp_cs_release */ 1992} /* nsp_cs_release */
2023 1993
2024/*====================================================================== 1994static int nsp_cs_suspend(struct pcmcia_device *dev)
2025
2026 The card status event handler. Mostly, this schedules other
2027 stuff to run after an event is received. A CARD_REMOVAL event
2028 also sets some flags to discourage the net drivers from trying
2029 to talk to the card any more.
2030
2031 When a CARD_REMOVAL event is received, we immediately set a flag
2032 to block future accesses to this device. All the functions that
2033 actually access the device should check this flag to make sure
2034 the card is still present.
2035
2036======================================================================*/
2037static int nsp_cs_event(event_t event,
2038 int priority,
2039 event_callback_args_t *args)
2040{ 1995{
2041 dev_link_t *link = args->client_data; 1996 dev_link_t *link = dev_to_instance(dev);
2042 scsi_info_t *info = link->priv; 1997 scsi_info_t *info = link->priv;
2043 nsp_hw_data *data; 1998 nsp_hw_data *data;
2044 1999
2045 nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); 2000 link->state |= DEV_SUSPEND;
2046 2001
2047 switch (event) { 2002 nsp_dbg(NSP_DEBUG_INIT, "event: suspend");
2048 case CS_EVENT_CARD_REMOVAL:
2049 nsp_dbg(NSP_DEBUG_INIT, "event: remove");
2050 link->state &= ~DEV_PRESENT;
2051 if (link->state & DEV_CONFIG) {
2052 ((scsi_info_t *)link->priv)->stop = 1;
2053 nsp_cs_release(link);
2054 }
2055 break;
2056 2003
2057 case CS_EVENT_CARD_INSERTION: 2004 if (info->host != NULL) {
2058 nsp_dbg(NSP_DEBUG_INIT, "event: insert"); 2005 nsp_msg(KERN_INFO, "clear SDTR status");
2059 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2060#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68))
2061 info->bus = args->bus;
2062#endif
2063 nsp_cs_config(link);
2064 break;
2065 2006
2066 case CS_EVENT_PM_SUSPEND: 2007 data = (nsp_hw_data *)info->host->hostdata;
2067 nsp_dbg(NSP_DEBUG_INIT, "event: suspend");
2068 link->state |= DEV_SUSPEND;
2069 /* Fall through... */
2070 case CS_EVENT_RESET_PHYSICAL:
2071 /* Mark the device as stopped, to block IO until later */
2072 nsp_dbg(NSP_DEBUG_INIT, "event: reset physical");
2073 2008
2074 if (info->host != NULL) { 2009 nsphw_init_sync(data);
2075 nsp_msg(KERN_INFO, "clear SDTR status"); 2010 }
2076 2011
2077 data = (nsp_hw_data *)info->host->hostdata; 2012 info->stop = 1;
2078 2013
2079 nsphw_init_sync(data); 2014 if (link->state & DEV_CONFIG)
2080 } 2015 pcmcia_release_configuration(link->handle);
2081 2016
2082 info->stop = 1; 2017 return 0;
2083 if (link->state & DEV_CONFIG) { 2018}
2084 pcmcia_release_configuration(link->handle);
2085 }
2086 break;
2087 2019
2088 case CS_EVENT_PM_RESUME: 2020static int nsp_cs_resume(struct pcmcia_device *dev)
2089 nsp_dbg(NSP_DEBUG_INIT, "event: resume"); 2021{
2090 link->state &= ~DEV_SUSPEND; 2022 dev_link_t *link = dev_to_instance(dev);
2091 /* Fall through... */ 2023 scsi_info_t *info = link->priv;
2092 case CS_EVENT_CARD_RESET: 2024 nsp_hw_data *data;
2093 nsp_dbg(NSP_DEBUG_INIT, "event: reset");
2094 if (link->state & DEV_CONFIG) {
2095 pcmcia_request_configuration(link->handle, &link->conf);
2096 }
2097 info->stop = 0;
2098 2025
2099 if (info->host != NULL) { 2026 nsp_dbg(NSP_DEBUG_INIT, "event: resume");
2100 nsp_msg(KERN_INFO, "reset host and bus");
2101 2027
2102 data = (nsp_hw_data *)info->host->hostdata; 2028 link->state &= ~DEV_SUSPEND;
2103 2029
2104 nsphw_init (data); 2030 if (link->state & DEV_CONFIG)
2105 nsp_bus_reset(data); 2031 pcmcia_request_configuration(link->handle, &link->conf);
2106 }
2107 2032
2108 break; 2033 info->stop = 0;
2109 2034
2110 default: 2035 if (info->host != NULL) {
2111 nsp_dbg(NSP_DEBUG_INIT, "event: unknown"); 2036 nsp_msg(KERN_INFO, "reset host and bus");
2112 break; 2037
2038 data = (nsp_hw_data *)info->host->hostdata;
2039
2040 nsphw_init (data);
2041 nsp_bus_reset(data);
2113 } 2042 }
2114 nsp_dbg(NSP_DEBUG_INIT, "end"); 2043
2115 return 0; 2044 return 0;
2116} /* nsp_cs_event */ 2045}
2117 2046
2118/*======================================================================* 2047/*======================================================================*
2119 * module entry point 2048 * module entry point
@@ -2136,10 +2065,11 @@ static struct pcmcia_driver nsp_driver = {
2136 .drv = { 2065 .drv = {
2137 .name = "nsp_cs", 2066 .name = "nsp_cs",
2138 }, 2067 },
2139 .attach = nsp_cs_attach, 2068 .probe = nsp_cs_attach,
2140 .event = nsp_cs_event, 2069 .remove = nsp_cs_detach,
2141 .detach = nsp_cs_detach,
2142 .id_table = nsp_cs_ids, 2070 .id_table = nsp_cs_ids,
2071 .suspend = nsp_cs_suspend,
2072 .resume = nsp_cs_resume,
2143}; 2073};
2144#endif 2074#endif
2145 2075
@@ -2171,7 +2101,6 @@ static void __exit nsp_cs_exit(void)
2171 2101
2172#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) 2102#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68))
2173 pcmcia_unregister_driver(&nsp_driver); 2103 pcmcia_unregister_driver(&nsp_driver);
2174 BUG_ON(dev_list != NULL);
2175#else 2104#else
2176 unregister_pcmcia_driver(&dev_info); 2105 unregister_pcmcia_driver(&dev_info);
2177 /* XXX: this really needs to move into generic code.. */ 2106 /* XXX: this really needs to move into generic code.. */
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index f8b943082717..b66b140a745e 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -296,11 +296,9 @@ typedef struct _nsp_hw_data {
296 */ 296 */
297 297
298/* Card service functions */ 298/* Card service functions */
299static dev_link_t *nsp_cs_attach (void); 299static void nsp_cs_detach (struct pcmcia_device *p_dev);
300static void nsp_cs_detach (dev_link_t *link);
301static void nsp_cs_release(dev_link_t *link); 300static void nsp_cs_release(dev_link_t *link);
302static void nsp_cs_config (dev_link_t *link); 301static void nsp_cs_config (dev_link_t *link);
303static int nsp_cs_event (event_t event, int priority, event_callback_args_t *args);
304 302
305/* Linux SCSI subsystem specific functions */ 303/* Linux SCSI subsystem specific functions */
306static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht); 304static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht);
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index bb091a45a880..dce7e687fd4a 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -98,15 +98,8 @@ typedef struct scsi_info_t {
98} scsi_info_t; 98} scsi_info_t;
99 99
100static void qlogic_release(dev_link_t *link); 100static void qlogic_release(dev_link_t *link);
101static int qlogic_event(event_t event, int priority, event_callback_args_t * args); 101static void qlogic_detach(struct pcmcia_device *p_dev);
102 102static void qlogic_config(dev_link_t * link);
103static dev_link_t *qlogic_attach(void);
104static void qlogic_detach(dev_link_t *);
105
106
107static dev_link_t *dev_list = NULL;
108
109static dev_info_t dev_info = "qlogic_cs";
110 103
111static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host, 104static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,
112 dev_link_t *link, int qbase, int qlirq) 105 dev_link_t *link, int qbase, int qlirq)
@@ -163,19 +156,17 @@ free_scsi_host:
163err: 156err:
164 return NULL; 157 return NULL;
165} 158}
166static dev_link_t *qlogic_attach(void) 159static int qlogic_attach(struct pcmcia_device *p_dev)
167{ 160{
168 scsi_info_t *info; 161 scsi_info_t *info;
169 client_reg_t client_reg;
170 dev_link_t *link; 162 dev_link_t *link;
171 int ret;
172 163
173 DEBUG(0, "qlogic_attach()\n"); 164 DEBUG(0, "qlogic_attach()\n");
174 165
175 /* Create new SCSI device */ 166 /* Create new SCSI device */
176 info = kmalloc(sizeof(*info), GFP_KERNEL); 167 info = kmalloc(sizeof(*info), GFP_KERNEL);
177 if (!info) 168 if (!info)
178 return NULL; 169 return -ENOMEM;
179 memset(info, 0, sizeof(*info)); 170 memset(info, 0, sizeof(*info));
180 link = &info->link; 171 link = &info->link;
181 link->priv = info; 172 link->priv = info;
@@ -189,45 +180,26 @@ static dev_link_t *qlogic_attach(void)
189 link->conf.IntType = INT_MEMORY_AND_IO; 180 link->conf.IntType = INT_MEMORY_AND_IO;
190 link->conf.Present = PRESENT_OPTION; 181 link->conf.Present = PRESENT_OPTION;
191 182
192 /* Register with Card Services */ 183 link->handle = p_dev;
193 link->next = dev_list; 184 p_dev->instance = link;
194 dev_list = link;
195 client_reg.dev_info = &dev_info;
196 client_reg.Version = 0x0210;
197 client_reg.event_callback_args.client_data = link;
198 ret = pcmcia_register_client(&link->handle, &client_reg);
199 if (ret != 0) {
200 cs_error(link->handle, RegisterClient, ret);
201 qlogic_detach(link);
202 return NULL;
203 }
204 185
205 return link; 186 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
187 qlogic_config(link);
188
189 return 0;
206} /* qlogic_attach */ 190} /* qlogic_attach */
207 191
208/*====================================================================*/ 192/*====================================================================*/
209 193
210static void qlogic_detach(dev_link_t * link) 194static void qlogic_detach(struct pcmcia_device *p_dev)
211{ 195{
212 dev_link_t **linkp; 196 dev_link_t *link = dev_to_instance(p_dev);
213 197
214 DEBUG(0, "qlogic_detach(0x%p)\n", link); 198 DEBUG(0, "qlogic_detach(0x%p)\n", link);
215 199
216 /* Locate device structure */
217 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
218 if (*linkp == link)
219 break;
220 if (*linkp == NULL)
221 return;
222
223 if (link->state & DEV_CONFIG) 200 if (link->state & DEV_CONFIG)
224 qlogic_release(link); 201 qlogic_release(link);
225 202
226 if (link->handle)
227 pcmcia_deregister_client(link->handle);
228
229 /* Unlink device structure, free bits */
230 *linkp = link->next;
231 kfree(link->priv); 203 kfree(link->priv);
232 204
233} /* qlogic_detach */ 205} /* qlogic_detach */
@@ -349,48 +321,39 @@ static void qlogic_release(dev_link_t *link)
349 321
350/*====================================================================*/ 322/*====================================================================*/
351 323
352static int qlogic_event(event_t event, int priority, event_callback_args_t * args) 324static int qlogic_suspend(struct pcmcia_device *dev)
353{ 325{
354 dev_link_t *link = args->client_data; 326 dev_link_t *link = dev_to_instance(dev);
355 327
356 DEBUG(1, "qlogic_event(0x%06x)\n", event); 328 link->state |= DEV_SUSPEND;
357 329 if (link->state & DEV_CONFIG)
358 switch (event) { 330 pcmcia_release_configuration(link->handle);
359 case CS_EVENT_CARD_REMOVAL: 331
360 link->state &= ~DEV_PRESENT; 332 return 0;
361 if (link->state & DEV_CONFIG) 333}
362 qlogic_release(link); 334
363 break; 335static int qlogic_resume(struct pcmcia_device *dev)
364 case CS_EVENT_CARD_INSERTION: 336{
365 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 337 dev_link_t *link = dev_to_instance(dev);
366 qlogic_config(link); 338
367 break; 339 link->state &= ~DEV_SUSPEND;
368 case CS_EVENT_PM_SUSPEND: 340 if (link->state & DEV_CONFIG) {
369 link->state |= DEV_SUSPEND; 341 scsi_info_t *info = link->priv;
370 /* Fall through... */ 342
371 case CS_EVENT_RESET_PHYSICAL: 343 pcmcia_request_configuration(link->handle, &link->conf);
372 if (link->state & DEV_CONFIG) 344 if ((info->manf_id == MANFID_MACNICA) ||
373 pcmcia_release_configuration(link->handle); 345 (info->manf_id == MANFID_PIONEER) ||
374 break; 346 (info->manf_id == 0x0098)) {
375 case CS_EVENT_PM_RESUME: 347 outb(0x80, link->io.BasePort1 + 0xd);
376 link->state &= ~DEV_SUSPEND; 348 outb(0x24, link->io.BasePort1 + 0x9);
377 /* Fall through... */ 349 outb(0x04, link->io.BasePort1 + 0xd);
378 case CS_EVENT_CARD_RESET:
379 if (link->state & DEV_CONFIG) {
380 scsi_info_t *info = link->priv;
381 pcmcia_request_configuration(link->handle, &link->conf);
382 if ((info->manf_id == MANFID_MACNICA) || (info->manf_id == MANFID_PIONEER) || (info->manf_id == 0x0098)) {
383 outb(0x80, link->io.BasePort1 + 0xd);
384 outb(0x24, link->io.BasePort1 + 0x9);
385 outb(0x04, link->io.BasePort1 + 0xd);
386 }
387 /* Ugggglllyyyy!!! */
388 qlogicfas408_bus_reset(NULL);
389 } 350 }
390 break; 351 /* Ugggglllyyyy!!! */
352 qlogicfas408_bus_reset(NULL);
391 } 353 }
354
392 return 0; 355 return 0;
393} /* qlogic_event */ 356}
394 357
395static struct pcmcia_device_id qlogic_ids[] = { 358static struct pcmcia_device_id qlogic_ids[] = {
396 PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6), 359 PCMCIA_DEVICE_PROD_ID12("EIger Labs", "PCMCIA-to-SCSI Adapter", 0x88395fa7, 0x33b7a5e6),
@@ -419,10 +382,11 @@ static struct pcmcia_driver qlogic_cs_driver = {
419 .drv = { 382 .drv = {
420 .name = "qlogic_cs", 383 .name = "qlogic_cs",
421 }, 384 },
422 .attach = qlogic_attach, 385 .probe = qlogic_attach,
423 .event = qlogic_event, 386 .remove = qlogic_detach,
424 .detach = qlogic_detach,
425 .id_table = qlogic_ids, 387 .id_table = qlogic_ids,
388 .suspend = qlogic_suspend,
389 .resume = qlogic_resume,
426}; 390};
427 391
428static int __init init_qlogic_cs(void) 392static int __init init_qlogic_cs(void)
@@ -433,7 +397,6 @@ static int __init init_qlogic_cs(void)
433static void __exit exit_qlogic_cs(void) 397static void __exit exit_qlogic_cs(void)
434{ 398{
435 pcmcia_unregister_driver(&qlogic_cs_driver); 399 pcmcia_unregister_driver(&qlogic_cs_driver);
436 BUG_ON(dev_list != NULL);
437} 400}
438 401
439MODULE_AUTHOR("Tom Zerucha, Michael Griffith"); 402MODULE_AUTHOR("Tom Zerucha, Michael Griffith");
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 98b64b2aa8ee..3a4dd6f5b81f 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -228,15 +228,6 @@ enum Phase {
228 228
229/* ================================================================== */ 229/* ================================================================== */
230 230
231/*
232* Global (within this module) variables other than
233* sym53c500_driver_template (the scsi_host_template).
234*/
235static dev_link_t *dev_list;
236static dev_info_t dev_info = "sym53c500_cs";
237
238/* ================================================================== */
239
240static void 231static void
241chip_init(int io_port) 232chip_init(int io_port)
242{ 233{
@@ -872,96 +863,70 @@ cs_failed:
872 return; 863 return;
873} /* SYM53C500_config */ 864} /* SYM53C500_config */
874 865
875static int 866static int sym53c500_suspend(struct pcmcia_device *dev)
876SYM53C500_event(event_t event, int priority, event_callback_args_t *args)
877{ 867{
878 dev_link_t *link = args->client_data; 868 dev_link_t *link = dev_to_instance(dev);
879 struct scsi_info_t *info = link->priv;
880 869
881 DEBUG(1, "SYM53C500_event(0x%06x)\n", event); 870 link->state |= DEV_SUSPEND;
871 if (link->state & DEV_CONFIG)
872 pcmcia_release_configuration(link->handle);
882 873
883 switch (event) { 874 return 0;
884 case CS_EVENT_CARD_REMOVAL: 875}
885 link->state &= ~DEV_PRESENT; 876
886 if (link->state & DEV_CONFIG) 877static int sym53c500_resume(struct pcmcia_device *dev)
887 SYM53C500_release(link); 878{
888 break; 879 dev_link_t *link = dev_to_instance(dev);
889 case CS_EVENT_CARD_INSERTION: 880 struct scsi_info_t *info = link->priv;
890 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 881
891 SYM53C500_config(link); 882 link->state &= ~DEV_SUSPEND;
892 break; 883 if (link->state & DEV_CONFIG) {
893 case CS_EVENT_PM_SUSPEND: 884 pcmcia_request_configuration(link->handle, &link->conf);
894 link->state |= DEV_SUSPEND; 885
895 /* Fall through... */ 886 /* See earlier comment about manufacturer IDs. */
896 case CS_EVENT_RESET_PHYSICAL: 887 if ((info->manf_id == MANFID_MACNICA) ||
897 if (link->state & DEV_CONFIG) 888 (info->manf_id == MANFID_PIONEER) ||
898 pcmcia_release_configuration(link->handle); 889 (info->manf_id == 0x0098)) {
899 break; 890 outb(0x80, link->io.BasePort1 + 0xd);
900 case CS_EVENT_PM_RESUME: 891 outb(0x24, link->io.BasePort1 + 0x9);
901 link->state &= ~DEV_SUSPEND; 892 outb(0x04, link->io.BasePort1 + 0xd);
902 /* Fall through... */
903 case CS_EVENT_CARD_RESET:
904 if (link->state & DEV_CONFIG) {
905 pcmcia_request_configuration(link->handle, &link->conf);
906 /* See earlier comment about manufacturer IDs. */
907 if ((info->manf_id == MANFID_MACNICA) ||
908 (info->manf_id == MANFID_PIONEER) ||
909 (info->manf_id == 0x0098)) {
910 outb(0x80, link->io.BasePort1 + 0xd);
911 outb(0x24, link->io.BasePort1 + 0x9);
912 outb(0x04, link->io.BasePort1 + 0xd);
913 }
914 /*
915 * If things don't work after a "resume",
916 * this is a good place to start looking.
917 */
918 SYM53C500_int_host_reset(link->io.BasePort1);
919 } 893 }
920 break; 894 /*
895 * If things don't work after a "resume",
896 * this is a good place to start looking.
897 */
898 SYM53C500_int_host_reset(link->io.BasePort1);
921 } 899 }
900
922 return 0; 901 return 0;
923} /* SYM53C500_event */ 902}
924 903
925static void 904static void
926SYM53C500_detach(dev_link_t *link) 905SYM53C500_detach(struct pcmcia_device *p_dev)
927{ 906{
928 dev_link_t **linkp; 907 dev_link_t *link = dev_to_instance(p_dev);
929 908
930 DEBUG(0, "SYM53C500_detach(0x%p)\n", link); 909 DEBUG(0, "SYM53C500_detach(0x%p)\n", link);
931 910
932 /* Locate device structure */
933 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
934 if (*linkp == link)
935 break;
936 if (*linkp == NULL)
937 return;
938
939 if (link->state & DEV_CONFIG) 911 if (link->state & DEV_CONFIG)
940 SYM53C500_release(link); 912 SYM53C500_release(link);
941 913
942 if (link->handle)
943 pcmcia_deregister_client(link->handle);
944
945 /* Unlink device structure, free bits. */
946 *linkp = link->next;
947 kfree(link->priv); 914 kfree(link->priv);
948 link->priv = NULL; 915 link->priv = NULL;
949} /* SYM53C500_detach */ 916} /* SYM53C500_detach */
950 917
951static dev_link_t * 918static int
952SYM53C500_attach(void) 919SYM53C500_attach(struct pcmcia_device *p_dev)
953{ 920{
954 struct scsi_info_t *info; 921 struct scsi_info_t *info;
955 client_reg_t client_reg;
956 dev_link_t *link; 922 dev_link_t *link;
957 int ret;
958 923
959 DEBUG(0, "SYM53C500_attach()\n"); 924 DEBUG(0, "SYM53C500_attach()\n");
960 925
961 /* Create new SCSI device */ 926 /* Create new SCSI device */
962 info = kmalloc(sizeof(*info), GFP_KERNEL); 927 info = kmalloc(sizeof(*info), GFP_KERNEL);
963 if (!info) 928 if (!info)
964 return NULL; 929 return -ENOMEM;
965 memset(info, 0, sizeof(*info)); 930 memset(info, 0, sizeof(*info));
966 link = &info->link; 931 link = &info->link;
967 link->priv = info; 932 link->priv = info;
@@ -975,20 +940,13 @@ SYM53C500_attach(void)
975 link->conf.IntType = INT_MEMORY_AND_IO; 940 link->conf.IntType = INT_MEMORY_AND_IO;
976 link->conf.Present = PRESENT_OPTION; 941 link->conf.Present = PRESENT_OPTION;
977 942
978 /* Register with Card Services */ 943 link->handle = p_dev;
979 link->next = dev_list; 944 p_dev->instance = link;
980 dev_list = link; 945
981 client_reg.dev_info = &dev_info; 946 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
982 client_reg.Version = 0x0210; 947 SYM53C500_config(link);
983 client_reg.event_callback_args.client_data = link;
984 ret = pcmcia_register_client(&link->handle, &client_reg);
985 if (ret != 0) {
986 cs_error(link->handle, RegisterClient, ret);
987 SYM53C500_detach(link);
988 return NULL;
989 }
990 948
991 return link; 949 return 0;
992} /* SYM53C500_attach */ 950} /* SYM53C500_attach */
993 951
994MODULE_AUTHOR("Bob Tracy <rct@frus.com>"); 952MODULE_AUTHOR("Bob Tracy <rct@frus.com>");
@@ -1008,10 +966,11 @@ static struct pcmcia_driver sym53c500_cs_driver = {
1008 .drv = { 966 .drv = {
1009 .name = "sym53c500_cs", 967 .name = "sym53c500_cs",
1010 }, 968 },
1011 .attach = SYM53C500_attach, 969 .probe = SYM53C500_attach,
1012 .event = SYM53C500_event, 970 .remove = SYM53C500_detach,
1013 .detach = SYM53C500_detach,
1014 .id_table = sym53c500_ids, 971 .id_table = sym53c500_ids,
972 .suspend = sym53c500_suspend,
973 .resume = sym53c500_resume,
1015}; 974};
1016 975
1017static int __init 976static int __init
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index f557f17ca00c..e8df0c9ec1e6 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -464,14 +464,12 @@ static inline unsigned int adma_intr_pkt(struct ata_host_set *host_set)
464 continue; 464 continue;
465 qc = ata_qc_from_tag(ap, ap->active_tag); 465 qc = ata_qc_from_tag(ap, ap->active_tag);
466 if (qc && (!(qc->tf.ctl & ATA_NIEN))) { 466 if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
467 unsigned int err_mask = 0;
468
469 if ((status & (aPERR | aPSD | aUIRQ))) 467 if ((status & (aPERR | aPSD | aUIRQ)))
470 err_mask = AC_ERR_OTHER; 468 qc->err_mask |= AC_ERR_OTHER;
471 else if (pp->pkt[0] != cDONE) 469 else if (pp->pkt[0] != cDONE)
472 err_mask = AC_ERR_OTHER; 470 qc->err_mask |= AC_ERR_OTHER;
473 471
474 ata_qc_complete(qc, err_mask); 472 ata_qc_complete(qc);
475 } 473 }
476 } 474 }
477 return handled; 475 return handled;
@@ -501,7 +499,8 @@ static inline unsigned int adma_intr_mmio(struct ata_host_set *host_set)
501 499
502 /* complete taskfile transaction */ 500 /* complete taskfile transaction */
503 pp->state = adma_state_idle; 501 pp->state = adma_state_idle;
504 ata_qc_complete(qc, ac_err_mask(status)); 502 qc->err_mask |= ac_err_mask(status);
503 ata_qc_complete(qc);
505 handled = 1; 504 handled = 1;
506 } 505 }
507 } 506 }
diff --git a/drivers/scsi/qla2xxx/Kconfig b/drivers/scsi/qla2xxx/Kconfig
index c1c1c687bcbd..5205c4e7d6ff 100644
--- a/drivers/scsi/qla2xxx/Kconfig
+++ b/drivers/scsi/qla2xxx/Kconfig
@@ -1,55 +1,70 @@
1config SCSI_QLA2XXX 1config SCSI_QLA2XXX
2 tristate 2 tristate "QLogic QLA2XXX Fibre Channel Support"
3 default (SCSI && PCI) 3 depends on PCI && SCSI
4 depends on SCSI && PCI 4 select SCSI_FC_ATTRS
5 select FW_LOADER
6 ---help---
7 This qla2xxx driver supports all QLogic Fibre Channel
8 PCI and PCIe host adapters.
5 9
6config SCSI_QLA21XX 10 By default, firmware for the ISP parts will be loaded
7 tristate "QLogic ISP2100 host adapter family support" 11 via the Firmware Loader interface.
12
13 ISP Firmware Filename
14 ---------- -----------------
15 21xx ql2100_fw.bin
16 22xx ql2200_fw.bin
17 2300, 2312 ql2300_fw.bin
18 2322 ql2322_fw.bin
19 6312, 6322 ql6312_fw.bin
20 24xx ql2400_fw.bin
21
22 Upon request, the driver caches the firmware image until
23 the driver is unloaded.
24
25 NOTE: The original method of building firmware-loader
26 modules has been deprecated as the firmware-images will
27 be removed from the kernel sources.
28
29config SCSI_QLA2XXX_EMBEDDED_FIRMWARE
30 bool " Use firmware-loader modules (DEPRECATED)"
8 depends on SCSI_QLA2XXX 31 depends on SCSI_QLA2XXX
9 select SCSI_FC_ATTRS 32
10 select FW_LOADER 33config SCSI_QLA21XX
34 tristate " Build QLogic ISP2100 firmware-module"
35 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE
11 ---help--- 36 ---help---
12 This driver supports the QLogic 21xx (ISP2100) host adapter family. 37 This driver supports the QLogic 21xx (ISP2100) host adapter family.
13 38
14config SCSI_QLA22XX 39config SCSI_QLA22XX
15 tristate "QLogic ISP2200 host adapter family support" 40 tristate " Build QLogic ISP2200 firmware-module"
16 depends on SCSI_QLA2XXX 41 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE
17 select SCSI_FC_ATTRS
18 select FW_LOADER
19 ---help--- 42 ---help---
20 This driver supports the QLogic 22xx (ISP2200) host adapter family. 43 This driver supports the QLogic 22xx (ISP2200) host adapter family.
21 44
22config SCSI_QLA2300 45config SCSI_QLA2300
23 tristate "QLogic ISP2300 host adapter family support" 46 tristate " Build QLogic ISP2300 firmware-module"
24 depends on SCSI_QLA2XXX 47 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE
25 select SCSI_FC_ATTRS
26 select FW_LOADER
27 ---help--- 48 ---help---
28 This driver supports the QLogic 2300 (ISP2300 and ISP2312) host 49 This driver supports the QLogic 2300 (ISP2300 and ISP2312) host
29 adapter family. 50 adapter family.
30 51
31config SCSI_QLA2322 52config SCSI_QLA2322
32 tristate "QLogic ISP2322 host adapter family support" 53 tristate " Build QLogic ISP2322 firmware-module"
33 depends on SCSI_QLA2XXX 54 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE
34 select SCSI_FC_ATTRS
35 select FW_LOADER
36 ---help--- 55 ---help---
37 This driver supports the QLogic 2322 (ISP2322) host adapter family. 56 This driver supports the QLogic 2322 (ISP2322) host adapter family.
38 57
39config SCSI_QLA6312 58config SCSI_QLA6312
40 tristate "QLogic ISP63xx host adapter family support" 59 tristate " Build QLogic ISP63xx firmware-module"
41 depends on SCSI_QLA2XXX 60 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE
42 select SCSI_FC_ATTRS
43 select FW_LOADER
44 ---help--- 61 ---help---
45 This driver supports the QLogic 63xx (ISP6312 and ISP6322) host 62 This driver supports the QLogic 63xx (ISP6312 and ISP6322) host
46 adapter family. 63 adapter family.
47 64
48config SCSI_QLA24XX 65config SCSI_QLA24XX
49 tristate "QLogic ISP24xx host adapter family support" 66 tristate " Build QLogic ISP24xx firmware-module"
50 depends on SCSI_QLA2XXX 67 depends on SCSI_QLA2XXX_EMBEDDED_FIRMWARE
51 select SCSI_FC_ATTRS
52 select FW_LOADER
53 ---help--- 68 ---help---
54 This driver supports the QLogic 24xx (ISP2422 and ISP2432) host 69 This driver supports the QLogic 24xx (ISP2422 and ISP2432) host
55 adapter family. 70 adapter family.
diff --git a/drivers/scsi/qla2xxx/Makefile b/drivers/scsi/qla2xxx/Makefile
index b169687d08ff..40c0de125889 100644
--- a/drivers/scsi/qla2xxx/Makefile
+++ b/drivers/scsi/qla2xxx/Makefile
@@ -3,15 +3,18 @@ EXTRA_CFLAGS += -DUNIQUE_FW_NAME
3qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \ 3qla2xxx-y := qla_os.o qla_init.o qla_mbx.o qla_iocb.o qla_isr.o qla_gs.o \
4 qla_dbg.o qla_sup.o qla_rscn.o qla_attr.o 4 qla_dbg.o qla_sup.o qla_rscn.o qla_attr.o
5 5
6obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx.o
7
6qla2100-y := ql2100.o ql2100_fw.o 8qla2100-y := ql2100.o ql2100_fw.o
7qla2200-y := ql2200.o ql2200_fw.o 9qla2200-y := ql2200.o ql2200_fw.o
8qla2300-y := ql2300.o ql2300_fw.o 10qla2300-y := ql2300.o ql2300_fw.o
9qla2322-y := ql2322.o ql2322_fw.o 11qla2322-y := ql2322.o ql2322_fw.o
10qla6312-y := ql6312.o ql6312_fw.o 12qla6312-y := ql6312.o ql6312_fw.o
13qla2400-y := ql2400.o ql2400_fw.o
11 14
12obj-$(CONFIG_SCSI_QLA21XX) += qla2xxx.o qla2100.o 15obj-$(CONFIG_SCSI_QLA21XX) += qla2xxx.o qla2100.o
13obj-$(CONFIG_SCSI_QLA22XX) += qla2xxx.o qla2200.o 16obj-$(CONFIG_SCSI_QLA22XX) += qla2xxx.o qla2200.o
14obj-$(CONFIG_SCSI_QLA2300) += qla2xxx.o qla2300.o 17obj-$(CONFIG_SCSI_QLA2300) += qla2xxx.o qla2300.o
15obj-$(CONFIG_SCSI_QLA2322) += qla2xxx.o qla2322.o 18obj-$(CONFIG_SCSI_QLA2322) += qla2xxx.o qla2322.o
16obj-$(CONFIG_SCSI_QLA6312) += qla2xxx.o qla6312.o 19obj-$(CONFIG_SCSI_QLA6312) += qla2xxx.o qla6312.o
17obj-$(CONFIG_SCSI_QLA24XX) += qla2xxx.o 20obj-$(CONFIG_SCSI_QLA24XX) += qla2xxx.o qla2400.o
diff --git a/drivers/scsi/qla2xxx/ql2400.c b/drivers/scsi/qla2xxx/ql2400.c
new file mode 100644
index 000000000000..6c7165f47e29
--- /dev/null
+++ b/drivers/scsi/qla2xxx/ql2400.c
@@ -0,0 +1,111 @@
1/*
2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
4 *
5 * See LICENSE.qla2xxx for copyright and licensing details.
6 */
7#include <linux/init.h>
8#include <linux/module.h>
9#include <linux/pci.h>
10
11#include "qla_def.h"
12
13static char qla_driver_name[] = "qla2400";
14
15extern uint32_t fw2400_version_str[];
16extern uint32_t fw2400_addr01;
17extern uint32_t fw2400_code01[];
18extern uint32_t fw2400_length01;
19extern uint32_t fw2400_addr02;
20extern uint32_t fw2400_code02[];
21extern uint32_t fw2400_length02;
22
23static struct qla_fw_info qla_fw_tbl[] = {
24 {
25 .addressing = FW_INFO_ADDR_EXTENDED,
26 .fwcode = (unsigned short *)&fw2400_code01[0],
27 .fwlen = (unsigned short *)&fw2400_length01,
28 .lfwstart = (unsigned long *)&fw2400_addr01,
29 },
30 {
31 .addressing = FW_INFO_ADDR_EXTENDED,
32 .fwcode = (unsigned short *)&fw2400_code02[0],
33 .fwlen = (unsigned short *)&fw2400_length02,
34 .lfwstart = (unsigned long *)&fw2400_addr02,
35 },
36 { FW_INFO_ADDR_NOMORE, },
37};
38
39static struct qla_board_info qla_board_tbl[] = {
40 {
41 .drv_name = qla_driver_name,
42 .isp_name = "ISP2422",
43 .fw_info = qla_fw_tbl,
44 .fw_fname = "ql2400_fw.bin",
45 },
46 {
47 .drv_name = qla_driver_name,
48 .isp_name = "ISP2432",
49 .fw_info = qla_fw_tbl,
50 .fw_fname = "ql2400_fw.bin",
51 },
52};
53
54static struct pci_device_id qla24xx_pci_tbl[] = {
55 {
56 .vendor = PCI_VENDOR_ID_QLOGIC,
57 .device = PCI_DEVICE_ID_QLOGIC_ISP2422,
58 .subvendor = PCI_ANY_ID,
59 .subdevice = PCI_ANY_ID,
60 .driver_data = (unsigned long)&qla_board_tbl[0],
61 },
62 {
63 .vendor = PCI_VENDOR_ID_QLOGIC,
64 .device = PCI_DEVICE_ID_QLOGIC_ISP2432,
65 .subvendor = PCI_ANY_ID,
66 .subdevice = PCI_ANY_ID,
67 .driver_data = (unsigned long)&qla_board_tbl[1],
68 },
69 {0, 0},
70};
71MODULE_DEVICE_TABLE(pci, qla24xx_pci_tbl);
72
73static int __devinit
74qla24xx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
75{
76 return qla2x00_probe_one(pdev,
77 (struct qla_board_info *)id->driver_data);
78}
79
80static void __devexit
81qla24xx_remove_one(struct pci_dev *pdev)
82{
83 qla2x00_remove_one(pdev);
84}
85
86static struct pci_driver qla24xx_pci_driver = {
87 .name = "qla2400",
88 .id_table = qla24xx_pci_tbl,
89 .probe = qla24xx_probe_one,
90 .remove = __devexit_p(qla24xx_remove_one),
91};
92
93static int __init
94qla24xx_init(void)
95{
96 return pci_module_init(&qla24xx_pci_driver);
97}
98
99static void __exit
100qla24xx_exit(void)
101{
102 pci_unregister_driver(&qla24xx_pci_driver);
103}
104
105module_init(qla24xx_init);
106module_exit(qla24xx_exit);
107
108MODULE_AUTHOR("QLogic Corporation");
109MODULE_DESCRIPTION("QLogic ISP24xx FC-SCSI Host Bus Adapter driver");
110MODULE_LICENSE("GPL");
111MODULE_VERSION(QLA2XXX_VERSION);
diff --git a/drivers/scsi/qla2xxx/ql2400_fw.c b/drivers/scsi/qla2xxx/ql2400_fw.c
new file mode 100644
index 000000000000..5977795854f8
--- /dev/null
+++ b/drivers/scsi/qla2xxx/ql2400_fw.c
@@ -0,0 +1,12376 @@
1/*
2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 QLogic Corporation
4 *
5 * See LICENSE.qla2xxx for copyright and licensing details.
6 */
7#include <linux/types.h>
8
9/*
10 * Firmware Version 4.00.16 (08:09 Oct 26, 2005)
11 */
12
13#ifdef UNIQUE_FW_NAME
14uint32_t fw2400_version = 4*1024+0;
15#else
16uint32_t risc_code_version = 4*1024+0;
17#endif
18
19#ifdef UNIQUE_FW_NAME
20uint32_t fw2400_version_str[] = {4, 0,16};
21#else
22uint32_t firmware_version[] = {4, 0,16};
23#endif
24
25#ifdef UNIQUE_FW_NAME
26#define fw2400_VERSION_STRING "4.00.16"
27#else
28#define FW_VERSION_STRING "4.00.16"
29#endif
30
31#ifdef UNIQUE_FW_NAME
32uint32_t fw2400_addr01 = 0x00100000 ;
33#else
34uint32_t risc_code_addr01 = 0x00100000 ;
35#endif
36
37#ifdef UNIQUE_FW_NAME
38uint32_t fw2400_code01[] = {
39#else
40uint32_t risc_code01[] = {
41#endif
42 0x0401f17c, 0x0010e000, 0x00100000, 0x0000ab4a,
43 0x00000004, 0x00000000, 0x00000010, 0x00000002,
44 0x00000003, 0x00000000, 0x20434f50, 0x59524947,
45 0x48542032, 0x30303520, 0x514c4f47, 0x49432043,
46 0x4f52504f, 0x52415449, 0x4f4e2020, 0x20495350,
47 0x32347878, 0x20466972, 0x6d776172, 0x65202020,
48 0x56657273, 0x696f6e20, 0x342e302e, 0x31362020,
49 0x20202024, 0x00000000, 0x00000000, 0x00000000,
50 0x00000000, 0x00000000, 0x00000000, 0x00000000,
51 0x00000000, 0x00000000, 0x00000000, 0x00000000,
52 0x00000000, 0x00000000, 0x00000000, 0x00000000,
53 0x00000000, 0x00000000, 0x00000000, 0x00000000,
54 0x42001800, 0x0010014f, 0x42002000, 0x0010b8fe,
55 0x500c0800, 0x800c1800, 0x500c1000, 0x800c1800,
56 0x54042000, 0x80102000, 0x80040800, 0x80081040,
57 0x040207fc, 0x500c0800, 0x800409c0, 0x040207f6,
58 0x44002000, 0x80102000, 0x40100000, 0x44040000,
59 0x80000000, 0x44080000, 0x80000000, 0x440c0000,
60 0x80000000, 0x44100000, 0x80000000, 0x44140000,
61 0x80000000, 0x44180000, 0x80000000, 0x441c0000,
62 0x80000000, 0x44200000, 0x80000000, 0x44240000,
63 0x80000000, 0x44280000, 0x80000000, 0x442c0000,
64 0x80000000, 0x44300000, 0x80000000, 0x44340000,
65 0x80000000, 0x44380000, 0x80000000, 0x443c0000,
66 0x80000000, 0x44400000, 0x80000000, 0x44440000,
67 0x80000000, 0x44480000, 0x80000000, 0x444c0000,
68 0x80000000, 0x44500000, 0x80000000, 0x44540000,
69 0x80000000, 0x44580000, 0x80000000, 0x445c0000,
70 0x80000000, 0x44600000, 0x80000000, 0x44640000,
71 0x80000000, 0x44680000, 0x80000000, 0x446c0000,
72 0x80000000, 0x44700000, 0x80000000, 0x44740000,
73 0x80000000, 0x44780000, 0x80000000, 0x447c0000,
74 0x80000000, 0x44800000, 0x80000000, 0x44840000,
75 0x80000000, 0x44880000, 0x80000000, 0x448c0000,
76 0x80000000, 0x44900000, 0x80000000, 0x44940000,
77 0x80000000, 0x44980000, 0x80000000, 0x449c0000,
78 0x80000000, 0x44a00000, 0x80000000, 0x44a40000,
79 0x80000000, 0x44a80000, 0x80000000, 0x44ac0000,
80 0x80000000, 0x44b00000, 0x80000000, 0x44b40000,
81 0x80000000, 0x44b80000, 0x80000000, 0x44bc0000,
82 0x80000000, 0x44c00000, 0x80000000, 0x44c40000,
83 0x80000000, 0x44c80000, 0x80000000, 0x44cc0000,
84 0x80000000, 0x44d00000, 0x80000000, 0x44d80000,
85 0x80000000, 0x44d40000, 0x80000000, 0x44dc0000,
86 0x80000000, 0x44e00000, 0x80000000, 0x44e40000,
87 0x80000000, 0x44e80000, 0x80000000, 0x44ec0000,
88 0x80000000, 0x44f00000, 0x80000000, 0x44f40000,
89 0x80000000, 0x44f80000, 0x80000000, 0x44fc0000,
90 0x80000000, 0x45000000, 0x80000000, 0x45040000,
91 0x80000000, 0x45080000, 0x80000000, 0x450c0000,
92 0x80000000, 0x45100000, 0x80000000, 0x45140000,
93 0x80000000, 0x45180000, 0x80000000, 0x451c0000,
94 0x80000000, 0x45200000, 0x80000000, 0x45240000,
95 0x80000000, 0x45280000, 0x80000000, 0x452c0000,
96 0x80000000, 0x45300000, 0x80000000, 0x45340000,
97 0x80000000, 0x45380000, 0x80000000, 0x453c0000,
98 0x80000000, 0x45400000, 0x80000000, 0x45440000,
99 0x80000000, 0x45480000, 0x80000000, 0x454c0000,
100 0x80000000, 0x45500000, 0x80000000, 0x45540000,
101 0x80000000, 0x45580000, 0x80000000, 0x455c0000,
102 0x80000000, 0x45600000, 0x80000000, 0x45640000,
103 0x80000000, 0x45680000, 0x80000000, 0x456c0000,
104 0x80000000, 0x45700000, 0x80000000, 0x45740000,
105 0x80000000, 0x45780000, 0x80000000, 0x457c0000,
106 0x80000000, 0x45800000, 0x80000000, 0x45840000,
107 0x80000000, 0x45880000, 0x80000000, 0x458c0000,
108 0x80000000, 0x45900000, 0x80000000, 0x45940000,
109 0x80000000, 0x45980000, 0x80000000, 0x459c0000,
110 0x80000000, 0x45a00000, 0x80000000, 0x45a40000,
111 0x80000000, 0x45a80000, 0x80000000, 0x45ac0000,
112 0x80000000, 0x45b00000, 0x80000000, 0x45b40000,
113 0x80000000, 0x45b80000, 0x80000000, 0x45bc0000,
114 0x80000000, 0x45c00000, 0x80000000, 0x45c40000,
115 0x80000000, 0x45c80000, 0x80000000, 0x45cc0000,
116 0x80000000, 0x45d00000, 0x80000000, 0x45d40000,
117 0x80000000, 0x45d80000, 0x80000000, 0x45dc0000,
118 0x80000000, 0x45e00000, 0x80000000, 0x45e40000,
119 0x80000000, 0x45e80000, 0x80000000, 0x45ec0000,
120 0x80000000, 0x45f00000, 0x80000000, 0x45f40000,
121 0x80000000, 0x45f80000, 0x80000000, 0x45fc0000,
122 0x4a03c020, 0x00004000, 0x4a03c011, 0x40000010,
123 0x04006000, 0x4203e000, 0x40000000, 0x59e00017,
124 0x8c000508, 0x04000003, 0x4a03c017, 0x00000000,
125 0x4203e000, 0x30000001, 0x0401f000, 0x0000bf00,
126 0x00000080, 0x0000bfe0, 0x00000020, 0x0000ff00,
127 0x00000080, 0x0000ffd0, 0x00000030, 0x00007100,
128 0x00000010, 0x00007200, 0x00000008, 0x00007209,
129 0x00000007, 0x00007300, 0x00000008, 0x00007309,
130 0x00000007, 0x00007400, 0x00000008, 0x00007409,
131 0x00000007, 0x00007600, 0x000000b0, 0x00007700,
132 0x00000040, 0x00003000, 0x00000070, 0x00004000,
133 0x000000c0, 0x00006000, 0x00000050, 0x00006100,
134 0x00000010, 0x00006130, 0x00000010, 0x00006150,
135 0x00000010, 0x00006170, 0x00000010, 0x00006190,
136 0x00000010, 0x000061b0, 0x00000010, 0x00000000,
137 0x42000000, 0x00000100, 0x4202f000, 0x00000000,
138 0x42000800, 0x00021f00, 0x45780800, 0x80040800,
139 0x80000040, 0x040207fd, 0x4203f000, 0x00021fff,
140 0x40000000, 0x4203e000, 0x90000100, 0x40000000,
141 0x0201f800, 0x001006fd, 0x42000000, 0x00001000,
142 0x50000000, 0x82000480, 0x24320002, 0x04020015,
143 0x42000800, 0x00000064, 0x80040840, 0x04000007,
144 0x4a030000, 0x00000001, 0x40000000, 0x59800000,
145 0x8c000500, 0x040007f9, 0x04000008, 0x42000800,
146 0x00007a17, 0x50040000, 0x8c00050e, 0x04020003,
147 0x8400054e, 0x44000800, 0x4a030000, 0x00000000,
148 0x4a03c020, 0x00000004, 0x4203e000, 0x6000000f,
149 0x59e00023, 0x8c000500, 0x04020039, 0x42000000,
150 0x00100001, 0x50000800, 0x82040c00, 0x00000004,
151 0x58042003, 0x42001000, 0xffffffff, 0x0201f800,
152 0x001006f4, 0x0402004e, 0x58042003, 0x42001000,
153 0xffffffff, 0x0201f800, 0x001006f4, 0x04020048,
154 0x58042003, 0x42001000, 0x00ffffff, 0x0201f800,
155 0x001006f4, 0x04020042, 0x58042003, 0x42001000,
156 0x00ffffff, 0x0201f800, 0x001006f4, 0x0402003c,
157 0x42000000, 0x00100001, 0x5000a000, 0x8250a400,
158 0x00000004, 0x4200a800, 0x00020000, 0x5850b003,
159 0x0201f800, 0x0010ab17, 0x8250a400, 0x00000005,
160 0x4a0370e8, 0x00000003, 0x4200a800, 0x0000c000,
161 0x5850b003, 0x0201f800, 0x0010ab17, 0x4a0378e8,
162 0x00000003, 0x4200a800, 0x00008000, 0x5850b003,
163 0x0201f800, 0x0010ab17, 0x0401f02b, 0x42000800,
164 0x00020000, 0x58042003, 0x42001000, 0xffffffff,
165 0x0201f800, 0x001006f4, 0x04020019, 0x4a0370e8,
166 0x00000003, 0x42000800, 0x0000c000, 0x58042003,
167 0x82102500, 0x00ffffff, 0x42001000, 0x00ffffff,
168 0x0201f800, 0x001006f4, 0x0402000d, 0x4a0378e8,
169 0x00000003, 0x42000800, 0x00008000, 0x58042003,
170 0x82102500, 0x00ffffff, 0x42001000, 0x00ffffff,
171 0x0201f800, 0x001006f4, 0x0400000b, 0x4a03c020,
172 0x00004010, 0x4a03c011, 0x40100011, 0x04006000,
173 0x4203e000, 0x40000000, 0x4203e000, 0x30000001,
174 0x0401f000, 0x0201f800, 0x00100791, 0x42001000,
175 0x0010ab4a, 0x40080000, 0x80140480, 0x82001d00,
176 0xffffff00, 0x04020003, 0x40001800, 0x0401f003,
177 0x42001800, 0x000000ff, 0x480bc840, 0x480fc842,
178 0x04011000, 0x400c0000, 0x80081400, 0x40140000,
179 0x80080580, 0x040207f0, 0x4817500d, 0x45782800,
180 0x59c40000, 0x82000500, 0xffff0000, 0x80000120,
181 0x82000580, 0x00002422, 0x04020005, 0x59a80005,
182 0x8400054e, 0x48035005, 0x0401f008, 0x59e00003,
183 0x82000500, 0x00030000, 0x04000004, 0x59a80005,
184 0x84000554, 0x48035005, 0x42000800, 0x00000040,
185 0x59a80005, 0x8c000514, 0x0402000e, 0x42000800,
186 0x00001000, 0x82141480, 0x0017ffff, 0x04021009,
187 0x80040902, 0x82141480, 0x0013ffff, 0x04021005,
188 0x80040902, 0x82141480, 0x0011ffff, 0x04001b8d,
189 0x4807500e, 0x42001000, 0x00000024, 0x0201f800,
190 0x00106681, 0x82040c00, 0x0010d1c0, 0x4807500b,
191 0x4a03c810, 0x00100000, 0x4a03c811, 0x0010ab4a,
192 0x4a03c829, 0x00000004, 0x59e40001, 0x82000540,
193 0x0003001d, 0x4803c801, 0x4a03c014, 0x001c001c,
194 0x42001000, 0x0000001c, 0x0201f800, 0x001006e2,
195 0x4202c000, 0x0010d1c0, 0x59aab00b, 0x59aaa00b,
196 0x59aaa80b, 0x59aac80e, 0x49675069, 0x59a8000b,
197 0x4803500c, 0x0401fbf5, 0x0201f800, 0x00107903,
198 0x0201f800, 0x001007be, 0x0201f800, 0x00100807,
199 0x0201f800, 0x00101a05, 0x0201f800, 0x00101354,
200 0x0201f800, 0x00100969, 0x0201f800, 0x00101354,
201 0x0201f800, 0x00100f4c, 0x0201f800, 0x001066c1,
202 0x0401fb1a, 0x0201f800, 0x0010220e, 0x0201f800,
203 0x001053bb, 0x0201f800, 0x00104c90, 0x0201f800,
204 0x00106194, 0x0201f800, 0x00105f28, 0x0201f800,
205 0x001013ed, 0x0201f800, 0x0010126f, 0x4203e000,
206 0xf0000001, 0x42000000, 0x00001000, 0x50000000,
207 0x82000480, 0x24220001, 0x04000016, 0x59e00002,
208 0x8c00051e, 0x42000000, 0x7ffe00fe, 0x04020003,
209 0x42000000, 0x7ffe01fe, 0x50000800, 0x48075058,
210 0x80040920, 0x82040580, 0x0000013a, 0x04000004,
211 0x82040580, 0x0000013b, 0x04020006, 0x59a80005,
212 0x84000552, 0x48035005, 0x4a0378e4, 0x000c0000,
213 0x4a03c018, 0x0000000f, 0x4203e000, 0x20000511,
214 0x4203e000, 0x50010000, 0x4a03c020, 0x00000000,
215 0x04027013, 0x59e00020, 0x82000580, 0x00000002,
216 0x0402000f, 0x4a03c020, 0x00004000, 0x4a03c011,
217 0x40000010, 0x04006000, 0x4203e000, 0x40000000,
218 0x59e00017, 0x8c000508, 0x04000003, 0x4a03c017,
219 0x00000000, 0x4203e000, 0x30000001, 0x4202d800,
220 0x00000000, 0x4203e000, 0xb0600000, 0x59a80005,
221 0x42000800, 0x00000002, 0x8c000512, 0x04020007,
222 0x42000800, 0x0000000f, 0x8c000514, 0x04020003,
223 0x42000800, 0x00000001, 0x4007f800, 0x59a80005,
224 0x8c000514, 0x02020000, 0x00020004, 0x59e00003,
225 0x82000500, 0x00030000, 0x82000580, 0x00000000,
226 0x04020af8, 0x0201f000, 0x00020004, 0x4df00000,
227 0x4203e000, 0x50000000, 0x416c0000, 0x82000c80,
228 0x00000008, 0x04021aef, 0x0c01f804, 0x5c03e000,
229 0x0201f000, 0x00020008, 0x001002f7, 0x0010030a,
230 0x001003d7, 0x001002f6, 0x00100452, 0x001002f6,
231 0x001002f6, 0x00100593, 0x0401fae2, 0x42000800,
232 0x0010b4a4, 0x5804001d, 0x4803c857, 0x8c000500,
233 0x0400000d, 0x84000500, 0x4800081d, 0x4202d800,
234 0x00000004, 0x0401fbd3, 0x49f3c857, 0x5c000800,
235 0x5c000000, 0x82000540, 0x00003e00, 0x4c000000,
236 0x4c040000, 0x1c01f000, 0x0401fbbd, 0x0201f800,
237 0x0010513b, 0x04000009, 0x0201f800, 0x00105151,
238 0x0402002e, 0x59c40006, 0x82000540, 0x000000c0,
239 0x48038806, 0x0401f029, 0x0201f800, 0x001050a2,
240 0x836c0580, 0x00000001, 0x040200bc, 0x59a80017,
241 0x82000580, 0x00000009, 0x040200b8, 0x497b5010,
242 0x4a038893, 0x00000001, 0x42001000, 0x000000f0,
243 0x0201f800, 0x0010193d, 0x0201f800, 0x00105149,
244 0x59c41006, 0x04020006, 0x82081540, 0x000000f1,
245 0x82081500, 0xbbffffff, 0x0401f003, 0x82081540,
246 0x440000f1, 0x480b8806, 0x0201f800, 0x0010609e,
247 0x4a0378e4, 0x00002000, 0x42000000, 0x0010b83a,
248 0x0201f800, 0x0010aa47, 0x42001000, 0x00008030,
249 0x497b5013, 0x0401f035, 0x0201f800, 0x00103b38,
250 0x59c400a4, 0x82000500, 0x0000000f, 0x82000480,
251 0x00000007, 0x04021091, 0x0201f800, 0x0010609e,
252 0x59c400a3, 0x82000500, 0xffefffff, 0x480388a3,
253 0x59a8004b, 0x800001c0, 0x04020004, 0x0201f800,
254 0x00104139, 0x0401f085, 0x59a80015, 0x84000546,
255 0x48035015, 0x0201f800, 0x00105141, 0x59c41006,
256 0x04020006, 0x82081540, 0x44000001, 0x82081500,
257 0xffffff0f, 0x0401f003, 0x82081540, 0x440000f1,
258 0x480b8806, 0x497b9005, 0x4a038802, 0x0000ffff,
259 0x4a0378e4, 0x00003000, 0x42000000, 0x0010b80c,
260 0x0201f800, 0x0010aa47, 0x59a81010, 0x42000800,
261 0x00000003, 0x0201f800, 0x00106c78, 0x42001000,
262 0x00008010, 0x59a8180a, 0x0201f800, 0x00103a3e,
263 0x0201f800, 0x00101815, 0x59a80805, 0x82040d00,
264 0xffffffdf, 0x48075005, 0x0201f800, 0x0010483d,
265 0x0201f800, 0x0010513b, 0x0400000a, 0x0201f800,
266 0x0010413e, 0x04000007, 0x4a035013, 0x00000001,
267 0x497b5021, 0x0201f800, 0x00103c80, 0x0401f04f,
268 0x0201f800, 0x001048ec, 0x04000005, 0x59c41002,
269 0x8408150c, 0x480b8802, 0x0401f012, 0x0201f800,
270 0x0010513b, 0x04020006, 0x59a8001d, 0x80000540,
271 0x02000800, 0x0010930f, 0x0401f00a, 0x0201f800,
272 0x0010930f, 0x59a80026, 0x8c000506, 0x04020005,
273 0x59a8001d, 0x80000540, 0x02020800, 0x00104245,
274 0x497b5028, 0x497b5027, 0x497b5018, 0x0201f800,
275 0x0010513b, 0x59a81026, 0x0402000a, 0x0201f800,
276 0x0010162a, 0x80001580, 0x59a8002a, 0x82000500,
277 0xffff0000, 0x80040d40, 0x4807502a, 0x0401f005,
278 0x59a8002a, 0x82000500, 0xffff0000, 0x4803502a,
279 0x599c0017, 0x8c00050a, 0x04000002, 0x84081544,
280 0x480b5026, 0x0201f800, 0x0010513b, 0x04000004,
281 0x0201f800, 0x0010162a, 0x48078880, 0x42001000,
282 0x00000005, 0x0201f800, 0x001070b0, 0x497b5028,
283 0x497b501b, 0x4a03501c, 0x0000ffff, 0x4a0378e4,
284 0x000000c0, 0x4202d800, 0x00000002, 0x0201f800,
285 0x0010513b, 0x04000007, 0x59a80026, 0x82000500,
286 0x0000000c, 0x82000580, 0x00000004, 0x04000003,
287 0x0201f800, 0x00101e45, 0x1c01f000, 0x59a8001c,
288 0x82000580, 0x0000ffff, 0x04000004, 0x0201f800,
289 0x00101e45, 0x0401f074, 0x59a80026, 0x8c00050a,
290 0x04020003, 0x8c000506, 0x0400001c, 0x8c000500,
291 0x0400001a, 0x4a038802, 0x0000ffbf, 0x8c000502,
292 0x04000016, 0x599c0018, 0x8c000516, 0x04020010,
293 0x59a80027, 0x82000580, 0x0000ffff, 0x0400000c,
294 0x0201f800, 0x00101f9a, 0x59a80026, 0x8c000504,
295 0x0402005d, 0x42001000, 0x00000003, 0x417a5800,
296 0x0201f800, 0x00101fbf, 0x0401f057, 0x59a80028,
297 0x80000540, 0x04020054, 0x59a80026, 0x8c000508,
298 0x04020005, 0x59a8001b, 0x80000540, 0x0402004e,
299 0x0401f003, 0x8c000516, 0x0400004b, 0x0201f800,
300 0x001048ec, 0x04020048, 0x599c0018, 0x8c000516,
301 0x04020004, 0x0201f800, 0x00104c51, 0x04020042,
302 0x599c0017, 0x8c00050a, 0x0400000d, 0x4200b000,
303 0x000007f0, 0x417a8800, 0x0201f800, 0x00020245,
304 0x04020004, 0x59340200, 0x8c00051a, 0x04020036,
305 0x81468800, 0x8058b040, 0x040207f8, 0x4a038802,
306 0x0000ffff, 0x42001800, 0x0010b4eb, 0x0401fb8c,
307 0x42001800, 0x0010b4f8, 0x0401fb89, 0x59a80005,
308 0x84000502, 0x48035005, 0x4a0378e4, 0x00000080,
309 0x4202d800, 0x00000003, 0x4a03501c, 0x0000ffff,
310 0x0401fa7f, 0x80000580, 0x0201f800, 0x00101590,
311 0x599c0018, 0x8c000516, 0x04000004, 0x0201f800,
312 0x00103b10, 0x0401f009, 0x42001800, 0x0000ffff,
313 0x42002000, 0x00000006, 0x42003000, 0x00000000,
314 0x0201f800, 0x00103aae, 0x0201f800, 0x00105151,
315 0x0400000b, 0x59c40006, 0x0201f800, 0x0010513b,
316 0x04000004, 0x82000500, 0xffffff0f, 0x0401f003,
317 0x82000500, 0xfbffffff, 0x48038806, 0x0201f800,
318 0x00106f36, 0x1c01f000, 0x4c040000, 0x4c080000,
319 0x4c100000, 0x59a8003e, 0x82000c80, 0x00000004,
320 0x04021980, 0x0c01f805, 0x5c002000, 0x5c001000,
321 0x5c000800, 0x1c01f000, 0x00100462, 0x001004ea,
322 0x00100516, 0x00100577, 0x42000000, 0x00000001,
323 0x0201f800, 0x00101590, 0x0201f800, 0x0010609e,
324 0x59c408a3, 0x82040d00, 0xfffffff7, 0x480788a3,
325 0x0201f800, 0x00105141, 0x0400000e, 0x0201f800,
326 0x00105151, 0x0400000b, 0x0201f800, 0x00105149,
327 0x04020964, 0x59c400a3, 0x84000532, 0x84000570,
328 0x480388a3, 0x4a038808, 0x00000008, 0x0401f010,
329 0x59c400a3, 0x84000530, 0x82000500, 0xbf7fffff,
330 0x480388a3, 0x42000800, 0x000000f8, 0x0201f800,
331 0x00104200, 0x59c400a3, 0x82000540, 0x00018000,
332 0x8400051c, 0x480388a3, 0x497b8808, 0x59c40006,
333 0x82000500, 0xfbffff0e, 0x48038806, 0x497b2822,
334 0x497b2823, 0x42000800, 0x000001f4, 0x42001000,
335 0x00100591, 0x0201f800, 0x00105f83, 0x59c40805,
336 0x42001000, 0x00000001, 0x0201f800, 0x0010193d,
337 0x0201f800, 0x0010163b, 0x0402000a, 0x42000000,
338 0x00000001, 0x0201f800, 0x0010188c, 0x42000000,
339 0x00000001, 0x0201f800, 0x00101821, 0x0401f022,
340 0x0201f800, 0x00101642, 0x04020008, 0x41780000,
341 0x0201f800, 0x0010188c, 0x41780000, 0x0201f800,
342 0x00101821, 0x0401f018, 0x0201f800, 0x00101649,
343 0x0402000a, 0x42000000, 0x00000002, 0x0201f800,
344 0x0010188c, 0x42000000, 0x00000002, 0x0201f800,
345 0x00101821, 0x0401f00c, 0x0201f800, 0x00101650,
346 0x04020918, 0x59a80049, 0x800001c0, 0x04000006,
347 0x0201f800, 0x00101656, 0x4a03503e, 0x00000001,
348 0x0401f021, 0x0201f800, 0x00101927, 0x4a03503e,
349 0x00000001, 0x0201f800, 0x00105141, 0x0400000c,
350 0x0201f800, 0x00105151, 0x04000009, 0x0201f800,
351 0x00105149, 0x04020903, 0x4a035033, 0x00000001,
352 0x0201f800, 0x001050a2, 0x0401f00f, 0x59c400a4,
353 0x82000500, 0x0000000f, 0x82000580, 0x00000008,
354 0x04000003, 0x4a038805, 0x04000000, 0x59c400a3,
355 0x82000540, 0x0001c000, 0x480388a3, 0x84000520,
356 0x480388a3, 0x1c01f000, 0x0401f8a3, 0x04020004,
357 0x4a03503e, 0x00000003, 0x0401f027, 0x0201f800,
358 0x00101650, 0x04020011, 0x59a80049, 0x800001c0,
359 0x0400000e, 0x0201f800, 0x00101656, 0x59a80048,
360 0x8c00051e, 0x0400001c, 0x0201f800, 0x00105149,
361 0x04020009, 0x4a035033, 0x00000001, 0x0201f800,
362 0x001050a2, 0x0401f004, 0x0201f800, 0x001018d3,
363 0x04020011, 0x0201f800, 0x00101815, 0x4a03503e,
364 0x00000002, 0x497b5049, 0x59c400a3, 0x84000520,
365 0x480388a3, 0x497b2822, 0x497b2823, 0x42000800,
366 0x0000002d, 0x42001000, 0x00100591, 0x0201f800,
367 0x00105f83, 0x1c01f000, 0x0401f877, 0x04020004,
368 0x4a03503e, 0x00000003, 0x0401f05b, 0x4a038805,
369 0x000000f0, 0x0201f800, 0x001018d3, 0x04020050,
370 0x0201f800, 0x00105149, 0x04000044, 0x59c400a4,
371 0x82000500, 0x0000000f, 0x82000580, 0x00000008,
372 0x04000020, 0x59c40005, 0x8c000534, 0x0402001d,
373 0x59940022, 0x82000580, 0x00000001, 0x04020046,
374 0x0201f800, 0x00105151, 0x04020043, 0x4a038805,
375 0x000000f0, 0x0201f800, 0x00105196, 0x4a035032,
376 0x0000aaaa, 0x4a035033, 0x00000000, 0x59c408a3,
377 0x82040d40, 0x00000008, 0x480788a3, 0x4202d800,
378 0x00000001, 0x4a03503e, 0x00000000, 0x4a038805,
379 0x00000001, 0x497b2822, 0x497b2823, 0x0401f01f,
380 0x0201f800, 0x00105151, 0x04020007, 0x59a80032,
381 0x82000580, 0x0000aaaa, 0x04020003, 0x4a035010,
382 0x00ffffff, 0x497b5032, 0x59c40006, 0x82000540,
383 0x04000001, 0x48038806, 0x59a80805, 0x8c040d06,
384 0x04020005, 0x59c408a3, 0x82040d40, 0x00000008,
385 0x480788a3, 0x4202d800, 0x00000001, 0x4a03503e,
386 0x00000000, 0x4a038805, 0x00000001, 0x497b2822,
387 0x497b2823, 0x0401f010, 0x59c40005, 0x82000500,
388 0x000000c0, 0x0400000c, 0x59c40006, 0x82000540,
389 0x000000f1, 0x48038806, 0x0401f7ef, 0x0201f800,
390 0x00101650, 0x04020004, 0x59a80049, 0x800001c0,
391 0x040207a4, 0x497b8885, 0x1c01f000, 0x4803c856,
392 0x42000000, 0x00000001, 0x0201f800, 0x00101590,
393 0x4a03503e, 0x00000000, 0x0201f800, 0x00101650,
394 0x0402000b, 0x59a80052, 0x800001c0, 0x04000004,
395 0x80000040, 0x48035052, 0x04020005, 0x4a035052,
396 0x0000000a, 0x4a035049, 0x00000001, 0x497b8885,
397 0x0401f0ed, 0x59940022, 0x59940823, 0x80040540,
398 0x1c01f000, 0x497b2823, 0x1c01f000, 0x4c080000,
399 0x42001000, 0x000000f0, 0x0201f800, 0x0010193d,
400 0x5c001000, 0x1c01f000, 0x4a03505c, 0x00000004,
401 0x4a03505d, 0x00000000, 0x4a03505e, 0x00000010,
402 0x4a03505f, 0x00000002, 0x4a035010, 0x00ffffff,
403 0x0201f800, 0x0010930f, 0x4a03502a, 0x20200000,
404 0x4a03502b, 0x88000200, 0x4a03502c, 0x00ff001f,
405 0x4a03502d, 0x000007d0, 0x4a03502e, 0x80000000,
406 0x4a03502f, 0x00000200, 0x4a035030, 0x00ff0000,
407 0x4a035031, 0x00010000, 0x4a03503a, 0x514c4f47,
408 0x4a03503b, 0x49432020, 0x1c01f000, 0x4d440000,
409 0x417a8800, 0x41780800, 0x0201f800, 0x00020245,
410 0x04020005, 0x0201f800, 0x001049e7, 0x04020002,
411 0x80040800, 0x81468800, 0x83440580, 0x000007f0,
412 0x040207f6, 0x5c028800, 0x1c01f000, 0x4803c857,
413 0x5c000000, 0x4c000000, 0x4803c857, 0x0401f809,
414 0x485fc857, 0x4203e000, 0x50000000, 0x5c000000,
415 0x4d780000, 0x4200b800, 0x00008002, 0x0401f006,
416 0x485fc857, 0x4203e000, 0x50000000, 0x4200b800,
417 0x00008002, 0x04006000, 0x4c000000, 0x4c040000,
418 0x59bc00ea, 0x82000500, 0x00000007, 0x82000580,
419 0x00000001, 0x04020005, 0x42000800, 0x00000000,
420 0x0201f800, 0x00106c6c, 0x5c000800, 0x4807c025,
421 0x80040920, 0x4807c026, 0x5c000000, 0x4803c023,
422 0x80000120, 0x4803c024, 0x5c000000, 0x4803c857,
423 0x4803c021, 0x80000120, 0x4803c022, 0x41f80000,
424 0x4803c027, 0x80000120, 0x4803c028, 0x42000000,
425 0x00001000, 0x50000000, 0x82000480, 0x24320001,
426 0x4803c857, 0x0400104f, 0x42000800, 0x00000064,
427 0x80040840, 0x04000007, 0x4a030000, 0x00000001,
428 0x40000000, 0x59800000, 0x8c000500, 0x040007f9,
429 0x04000042, 0x42000800, 0x0010c1a3, 0x46000800,
430 0xfaceface, 0x80040800, 0x42001000, 0x00007a00,
431 0x58080013, 0x44000800, 0x80040800, 0x58080019,
432 0x44000800, 0x80040800, 0x5808001a, 0x44000800,
433 0x80040800, 0x5808001b, 0x44000800, 0x80040800,
434 0x5808001c, 0x44000800, 0x80040800, 0x5808001f,
435 0x44000800, 0x80040800, 0x42001000, 0x00007a40,
436 0x42001800, 0x0000000b, 0x50080000, 0x44000800,
437 0x80081000, 0x80040800, 0x800c1840, 0x040207fb,
438 0x42001800, 0x00000003, 0x42001000, 0x00007b00,
439 0x480c1003, 0x58080005, 0x44000800, 0x80040800,
440 0x800c1840, 0x040217fb, 0x42001000, 0x00007c00,
441 0x58080002, 0x44000800, 0x80040800, 0x58080003,
442 0x44000800, 0x80040800, 0x58080020, 0x44000800,
443 0x80040800, 0x58080021, 0x44000800, 0x80040800,
444 0x58080022, 0x44000800, 0x80040800, 0x58080023,
445 0x44000800, 0x80040800, 0x4a030000, 0x00000000,
446 0x485fc020, 0x905cb9c0, 0x825cbd40, 0x00000012,
447 0x485fc011, 0x4203e000, 0x40000000, 0x4202d800,
448 0x00000005, 0x59e00017, 0x8c000508, 0x04000003,
449 0x4a03c017, 0x00000002, 0x4203e000, 0x30000001,
450 0x0401f81a, 0x0401f7ff, 0x4a03c850, 0x0010c1bf,
451 0x4a03c851, 0x0010d1be, 0x4a03c853, 0x00000800,
452 0x4a03c855, 0x0001eb5a, 0x59e40001, 0x82000540,
453 0x00003f00, 0x4803c801, 0x4a03b104, 0x70000002,
454 0x4a03a804, 0x70000002, 0x4a03b004, 0x70000002,
455 0x42000000, 0x0010b8ec, 0x49780001, 0x49780002,
456 0x1c01f000, 0x1c01f000, 0x59a8006b, 0x8c000530,
457 0x040207fe, 0x4c080000, 0x42001000, 0x00000004,
458 0x0401f862, 0x5c001000, 0x4201d000, 0x00028b0a,
459 0x0201f800, 0x0010608e, 0x4c080000, 0x42001000,
460 0x00000008, 0x0401f859, 0x5c001000, 0x4201d000,
461 0x00028b0a, 0x0201f800, 0x0010608e, 0x4c080000,
462 0x42001000, 0x00000010, 0x0401f850, 0x5c001000,
463 0x4201d000, 0x00028b0a, 0x0201f800, 0x0010608e,
464 0x0401f7e2, 0x8c00050c, 0x59a8086b, 0x04020003,
465 0x84040d30, 0x0401f006, 0x84040d70, 0x4807506b,
466 0x42001000, 0x00000000, 0x0401f040, 0x4807506b,
467 0x836c0500, 0x00000007, 0x0c01f001, 0x001006e1,
468 0x001006c7, 0x001006c7, 0x001006af, 0x001006d4,
469 0x001006c7, 0x001006c7, 0x001006d4, 0x59a80005,
470 0x8c000514, 0x04020013, 0x59c40801, 0x82040d00,
471 0x00018000, 0x82040580, 0x00010000, 0x0400000a,
472 0x82040580, 0x00008000, 0x04000004, 0x42001000,
473 0x42004000, 0x0401f006, 0x42001000, 0x22002000,
474 0x0401f003, 0x42001000, 0x12001000, 0x0401f025,
475 0x42001000, 0x00001004, 0x0401f022, 0x59a80005,
476 0x8c000514, 0x04020008, 0x59a8006b, 0x8c000534,
477 0x04020004, 0x42001000, 0x74057005, 0x0401f819,
478 0x1c01f000, 0x42001000, 0x00002008, 0x0401f7fc,
479 0x59a8006b, 0x8c000534, 0x0402000a, 0x59a80005,
480 0x8c000514, 0x04000004, 0x42001000, 0x24052005,
481 0x0401f00c, 0x42001000, 0x74057005, 0x0401f009,
482 0x1c01f000, 0x1c01f000, 0x82081500, 0x0000001c,
483 0x82081540, 0x001c0000, 0x480bc013, 0x1c01f000,
484 0x59a8006b, 0x8c000530, 0x04000002, 0x84081570,
485 0x480b506b, 0x8c000530, 0x04020005, 0x82081500,
486 0x00007000, 0x80081114, 0x0401fff0, 0x1c01f000,
487 0x41780000, 0x50041800, 0x800c0400, 0x80040800,
488 0x80102040, 0x040207fc, 0x80080500, 0x80000540,
489 0x1c01f000, 0x4202f000, 0x00000000, 0x41780000,
490 0x41780800, 0x41781000, 0x41781800, 0x41782000,
491 0x41782800, 0x41783000, 0x41783800, 0x41784000,
492 0x41784800, 0x41785000, 0x41785800, 0x41786000,
493 0x41786800, 0x41787000, 0x41787800, 0x41788000,
494 0x41788800, 0x41789000, 0x41789800, 0x4178a000,
495 0x4178a800, 0x4178b000, 0x4178b800, 0x4178c000,
496 0x4178c800, 0x4178d000, 0x4178d800, 0x4178e000,
497 0x4178e800, 0x4178f000, 0x4178f800, 0x41790000,
498 0x41790800, 0x41791000, 0x41791800, 0x41792000,
499 0x41792800, 0x41793000, 0x41793800, 0x41794000,
500 0x41794800, 0x41795000, 0x41795800, 0x41796000,
501 0x41796800, 0x41797000, 0x41797800, 0x41798000,
502 0x41798800, 0x42019000, 0x0010b537, 0x42019800,
503 0x0010b50e, 0x4179a000, 0x4179b000, 0x4179a800,
504 0x4179b800, 0x4179c800, 0x4179c000, 0x4179d000,
505 0x4179d800, 0x4179e000, 0x4179e800, 0x4179f000,
506 0x4179f800, 0x417a0000, 0x417a0800, 0x417a1000,
507 0x417a1800, 0x417a2000, 0x42022800, 0x00006100,
508 0x417a3000, 0x417a3800, 0x417a4000, 0x417a4800,
509 0x417a5000, 0x417a5800, 0x417a6000, 0x417a6800,
510 0x417a7000, 0x417a7800, 0x417a8000, 0x417a8800,
511 0x417a9000, 0x417a9800, 0x417ae800, 0x417af800,
512 0x42030000, 0x00007c00, 0x42031000, 0x0010b806,
513 0x42031800, 0x0000bf1d, 0x42032000, 0x0000bf32,
514 0x42032800, 0x0010b7ce, 0x42033000, 0x0010b46e,
515 0x42034000, 0x0010b4a4, 0x42033800, 0x0010b4c3,
516 0x42034800, 0x0010b544, 0x42035000, 0x0010b400,
517 0x42035800, 0x0010ac00, 0x42030800, 0x0010b505,
518 0x417b6000, 0x42036800, 0x00006f00, 0x4203c800,
519 0x00003000, 0x42037000, 0x0000ff00, 0x42037800,
520 0x0000bf00, 0x42038000, 0x00007700, 0x42038800,
521 0x00004000, 0x42039000, 0x00006000, 0x42039800,
522 0x0010bedb, 0x4203a000, 0x00007600, 0x4203a800,
523 0x00007400, 0x4203b000, 0x00007200, 0x4203b800,
524 0x00007100, 0x4203c000, 0x00007000, 0x4203d000,
525 0x00000000, 0x4203e800, 0x00101b95, 0x417bd800,
526 0x1c01f000, 0x42000800, 0x00100000, 0x50040000,
527 0x4c000000, 0x42000000, 0x0000aaaa, 0x44000800,
528 0x42001800, 0x00005555, 0x41782000, 0x82102400,
529 0x00010000, 0x40100000, 0x80042c00, 0x440c2800,
530 0x42003000, 0x0000000a, 0x80183040, 0x040207ff,
531 0x50140000, 0x800c0580, 0x04020004, 0x50040000,
532 0x800c0580, 0x040207f2, 0x5c000000, 0x44000800,
533 0x80142840, 0x4817c861, 0x1c01f000, 0x59a8081f,
534 0x800409c0, 0x04020009, 0x49781c0c, 0x4a001a0c,
535 0x00000200, 0x4a001804, 0x07000000, 0x59a80010,
536 0x9c0001c0, 0x48001805, 0x0401fe01, 0x9c0409c0,
537 0x48041806, 0x1c01f000, 0x59a8080c, 0x4006d000,
538 0x4202b800, 0x00000001, 0x59a8180d, 0x480fc857,
539 0x82041400, 0x00000014, 0x82082400, 0x00000014,
540 0x40100000, 0x800c0480, 0x04001006, 0x44080800,
541 0x40080800, 0x40101000, 0x815eb800, 0x0401f7f7,
542 0x45780800, 0x495f5020, 0x1c01f000, 0x835c0480,
543 0x00000020, 0x04001009, 0x496bc857, 0x815eb840,
544 0x416a5800, 0x592ed000, 0x497a5800, 0x497a5801,
545 0x812e59c0, 0x1c01f000, 0x42000000, 0x0010b853,
546 0x0201f800, 0x0010aa47, 0x417a5800, 0x0401f7f9,
547 0x815eb840, 0x04001008, 0x416a5800, 0x492fc857,
548 0x592ed000, 0x497a5800, 0x497a5801, 0x812e59c0,
549 0x1c01f000, 0x42000000, 0x0010b853, 0x0201f800,
550 0x0010aa47, 0x417ab800, 0x417a5800, 0x0401f7f8,
551 0x492fc857, 0x496a5800, 0x412ed000, 0x815eb800,
552 0x59c80000, 0x82000540, 0x00001200, 0x48039000,
553 0x1c01f000, 0x492fc857, 0x812e59c0, 0x04000007,
554 0x592c0001, 0x497a5801, 0x4c000000, 0x0401fff1,
555 0x5c025800, 0x0401f7f9, 0x1c01f000, 0x4807c856,
556 0x42007000, 0x0010b7f8, 0x4a007001, 0x00000000,
557 0x59e00003, 0x82000540, 0x00008080, 0x4803c003,
558 0x4a03b805, 0x90000001, 0x59dc0006, 0x4a03b805,
559 0x70000000, 0x59dc0006, 0x4a03b805, 0x30000000,
560 0x4200b000, 0x00000020, 0x497bb807, 0x8058b040,
561 0x040207fe, 0x4a03b805, 0x30000000, 0x59dc0006,
562 0x4a03b805, 0x60000001, 0x59dc0006, 0x4a03b805,
563 0x70000001, 0x59dc0006, 0x4a03b805, 0x30000002,
564 0x4200b000, 0x00000020, 0x497bb807, 0x8058b040,
565 0x040207fe, 0x4a03b805, 0x30000000, 0x59dc0006,
566 0x4a03b805, 0x60000001, 0x0401ffa1, 0x04000da5,
567 0x42001000, 0x0010b7f6, 0x452c1000, 0x4a025801,
568 0x00000001, 0x4a025802, 0x00000100, 0x4a025809,
569 0x00107149, 0x497a580a, 0x497a580b, 0x497a580c,
570 0x0401ff93, 0x04000d97, 0x42001000, 0x0010b7f7,
571 0x452c1000, 0x4a025801, 0x00000000, 0x4a025802,
572 0x00000100, 0x4a025809, 0x001011bc, 0x497a5803,
573 0x497a5807, 0x497a5808, 0x497a580a, 0x59a80005,
574 0x8c00050e, 0x04000006, 0x4a03b805, 0xe0000001,
575 0x59dc0006, 0x8c000522, 0x040007fc, 0x1c01f000,
576 0x4df00000, 0x4203e000, 0x50000000, 0x4c380000,
577 0x40087000, 0x480bc857, 0x4a007002, 0x00000000,
578 0x42007000, 0x0010b7f8, 0x82080400, 0x00000000,
579 0x45780000, 0x58380005, 0x48087005, 0x80000540,
580 0x04000005, 0x82000400, 0x00000000, 0x44080000,
581 0x0401f003, 0x480bc857, 0x48087006, 0x58380001,
582 0x80000540, 0x0400080c, 0x5c007000, 0x5c03e000,
583 0x1c01f000, 0x4c380000, 0x42007000, 0x0010b7f8,
584 0x58380001, 0x80000540, 0x04000803, 0x5c007000,
585 0x1c01f000, 0x42007000, 0x0010b7f8, 0x58380001,
586 0x82000580, 0x00000000, 0x04020012, 0x58380000,
587 0x0c01f001, 0x0010088e, 0x0010088d, 0x0010088d,
588 0x0010088d, 0x0010088d, 0x0010088d, 0x0010088d,
589 0x0010088d, 0x0401fd4b, 0x58380808, 0x800409c0,
590 0x04020024, 0x58380006, 0x80000540, 0x04020002,
591 0x1c01f000, 0x4803c857, 0x48007002, 0x40006800,
592 0x58340000, 0x80000540, 0x04020002, 0x48007005,
593 0x48007006, 0x4a03b805, 0x20000000, 0x59dc0006,
594 0x4a03b805, 0x30000000, 0x58340007, 0x4803b800,
595 0x58340008, 0x4803b801, 0x58340004, 0x48007003,
596 0x58340003, 0x48007004, 0x4803b803, 0x58340001,
597 0x8c000500, 0x04000004, 0x4a007001, 0x00000001,
598 0x0401f028, 0x4a007001, 0x00000002, 0x0401f03d,
599 0x0201f800, 0x001093ea, 0x0201f800, 0x0010a69d,
600 0x04000017, 0x4a03b805, 0x20000000, 0x59dc0006,
601 0x4a03b805, 0x30000000, 0x4807b800, 0x480bb801,
602 0x4a007003, 0x00000010, 0x480c7009, 0x42001000,
603 0x00100875, 0x0201f800, 0x00105f9a, 0x58380008,
604 0x82000400, 0x00000004, 0x48007004, 0x4803b803,
605 0x4a007001, 0x00000007, 0x0401f022, 0x0201f800,
606 0x00109402, 0x42000800, 0x00000001, 0x42001000,
607 0x00100875, 0x0201f800, 0x00105f76, 0x0401f7ba,
608 0x4c040000, 0x4c080000, 0x58380803, 0x42001000,
609 0x00003fff, 0x82040480, 0x00003fff, 0x04021003,
610 0x40041000, 0x80000580, 0x48007003, 0x800800c4,
611 0x4803b802, 0x4a03b805, 0x30000002, 0x59dc0006,
612 0x4a03b805, 0x70000001, 0x59dc0006, 0x4a03b805,
613 0x10000000, 0x5c001000, 0x5c000800, 0x1c01f000,
614 0x483bc857, 0x4c040000, 0x4c080000, 0x58380803,
615 0x42001000, 0x00003fff, 0x82040480, 0x00003fff,
616 0x04021003, 0x40041000, 0x80000580, 0x48007003,
617 0x800800c4, 0x4803b802, 0x4a03b805, 0x10000002,
618 0x5c001000, 0x5c000800, 0x1c01f000, 0x4c040000,
619 0x4c380000, 0x42007000, 0x0010b7f8, 0x59dc0806,
620 0x4807c857, 0x4a03b805, 0x20000000, 0x8c040d3e,
621 0x04000007, 0x8c040d08, 0x04020cca, 0x58380001,
622 0x82000500, 0x00000007, 0x0c01f804, 0x5c007000,
623 0x5c000800, 0x1c01f000, 0x0010087d, 0x0010091e,
624 0x0010092e, 0x001005d8, 0x001005d8, 0x001005d8,
625 0x001005d8, 0x001011ea, 0x4807c856, 0x82040d00,
626 0x43000f80, 0x04020009, 0x58380003, 0x80000540,
627 0x0400001c, 0x59dc0000, 0x4803b800, 0x59dc0001,
628 0x4803b801, 0x0401f7af, 0x58380802, 0x4a000802,
629 0x00000200, 0x0401f01e, 0x4807c856, 0x82040d00,
630 0x43000f80, 0x04020009, 0x58380003, 0x80000540,
631 0x0400000c, 0x59dc0000, 0x4803b800, 0x59dc0001,
632 0x4803b801, 0x0401f7b7, 0x58380002, 0x82000400,
633 0x00000002, 0x46000000, 0x00000200, 0x0401f00c,
634 0x4c340000, 0x58386802, 0x59dc0000, 0x4803c857,
635 0x48006807, 0x59dc0001, 0x4803c857, 0x48006808,
636 0x4a006802, 0x00000100, 0x5c006800, 0x4a007001,
637 0x00000000, 0x4c300000, 0x58386002, 0x0401f80c,
638 0x04000009, 0x58300009, 0x82000c80, 0x0010ab4a,
639 0x04021c84, 0x82000c80, 0x00020000, 0x04001c81,
640 0x0801f800, 0x5c006000, 0x0401f723, 0x4833c857,
641 0x803061c0, 0x04000009, 0x59a8000c, 0x80300480,
642 0x04001007, 0x59a8000d, 0x80300480, 0x04021004,
643 0x82000540, 0x00000001, 0x1c01f000, 0x80000580,
644 0x1c01f000, 0x4803c856, 0x4dc00000, 0x42007000,
645 0x0010b803, 0x4a007400, 0x00000000, 0x49787001,
646 0x42038000, 0x00007720, 0x4a038006, 0x60000001,
647 0x4a038009, 0xf4f60000, 0x42038000, 0x00007700,
648 0x4a038006, 0x60000001, 0x4a038009, 0xf4f60000,
649 0x4a03c822, 0x00000010, 0x4a0370e8, 0x00000000,
650 0x0401f809, 0x4a0370e9, 0x00003a0f, 0x4a0370e8,
651 0x00000000, 0x4a0370e8, 0x00000001, 0x5c038000,
652 0x1c01f000, 0x4c5c0000, 0x4178b800, 0x0401f80a,
653 0x5c00b800, 0x1c01f000, 0x4803c856, 0x4c5c0000,
654 0x825cbd40, 0x00000001, 0x0401f803, 0x5c00b800,
655 0x1c01f000, 0x4803c856, 0x4dc00000, 0x4c500000,
656 0x4c580000, 0x4c540000, 0x4a0370e8, 0x00000000,
657 0x805cb9c0, 0x04000009, 0x4a038807, 0x00000004,
658 0x59b800ea, 0x8c000510, 0x04000004, 0x59b800e0,
659 0x0401f87b, 0x0401f7fb, 0x42038000, 0x00007720,
660 0x0201f800, 0x00100ec1, 0x59c00007, 0x4a038006,
661 0x20000000, 0x59c00007, 0x4a038006, 0x8000000a,
662 0x59c00007, 0x4a038006, 0x8000000b, 0x59c00007,
663 0x4a038006, 0x40000001, 0x83c00580, 0x00007700,
664 0x04000004, 0x42038000, 0x00007700, 0x0401f7ed,
665 0x42038000, 0x00007720, 0x42000800, 0x00000800,
666 0x59c00007, 0x8c00051e, 0x04000006, 0x4a038006,
667 0x90000001, 0x80040840, 0x040207fa, 0x0401fc11,
668 0x83c00580, 0x00007700, 0x04000004, 0x42038000,
669 0x00007700, 0x0401f7f1, 0x805cb9c0, 0x0402001d,
670 0x4200b000, 0x00000020, 0x83b8ac00, 0x00000020,
671 0x0201f800, 0x0010ab20, 0x4a0370fb, 0x00000001,
672 0x4a037020, 0x001010bd, 0x59a80039, 0x82000500,
673 0x0000ffff, 0x48037021, 0x4a037035, 0x0010bddb,
674 0x4a037030, 0x0010b410, 0x4a037031, 0x0010ac00,
675 0x4a037032, 0x0010b519, 0x4a037036, 0x0010b524,
676 0x59840002, 0x48037034, 0x4a037038, 0x001010b4,
677 0x4a0370fb, 0x00000001, 0x4178a000, 0x4200b000,
678 0x00000020, 0x83b8ac00, 0x00000000, 0x0201f800,
679 0x0010ab20, 0x4200b000, 0x00000040, 0x83b8ac00,
680 0x00000040, 0x0201f800, 0x0010ab20, 0x805cb9c0,
681 0x04020004, 0x4a0370e4, 0xaaaaaaaa, 0x0401f003,
682 0x4a0370e4, 0xa2aaaa82, 0x4a0370e5, 0xaaaaaaaa,
683 0x4a0370e6, 0xaaaaaaaa, 0x4a0370fb, 0x00000000,
684 0x4a0370e6, 0xaaaaaaaa, 0x42038000, 0x00007720,
685 0x4a038006, 0x90000000, 0x59c00007, 0x8c00051e,
686 0x02020800, 0x001005d8, 0x42038000, 0x00007700,
687 0x4a038006, 0x90000000, 0x59c00007, 0x8c00051e,
688 0x02020800, 0x001005d8, 0x5c00a800, 0x5c00b000,
689 0x5c00a000, 0x5c038000, 0x1c01f000, 0x4d300000,
690 0x4d380000, 0x40026000, 0x82000500, 0x7f000000,
691 0x82000580, 0x00000003, 0x0402000f, 0x83326500,
692 0x00ffffff, 0x59300203, 0x82000580, 0x00000004,
693 0x04020009, 0x59300c06, 0x82040580, 0x00000009,
694 0x04020005, 0x42027000, 0x00000047, 0x0201f800,
695 0x000207a1, 0x5c027000, 0x5c026000, 0x1c01f000,
696 0x4d300000, 0x4d2c0000, 0x4d340000, 0x4d400000,
697 0x4cfc0000, 0x4d380000, 0x4d3c0000, 0x4d440000,
698 0x4d4c0000, 0x4d480000, 0x4c5c0000, 0x4c600000,
699 0x4c640000, 0x4cc80000, 0x4ccc0000, 0x4cf00000,
700 0x4cf40000, 0x4cf80000, 0x4cfc0000, 0x4d000000,
701 0x4d040000, 0x0201f800, 0x00020015, 0x5c020800,
702 0x5c020000, 0x5c01f800, 0x5c01f000, 0x5c01e800,
703 0x5c01e000, 0x5c019800, 0x5c019000, 0x5c00c800,
704 0x5c00c000, 0x5c00b800, 0x5c029000, 0x5c029800,
705 0x5c028800, 0x5c027800, 0x5c027000, 0x5c01f800,
706 0x5c028000, 0x5c026800, 0x5c025800, 0x5c026000,
707 0x1c01f000, 0x493bc857, 0x0201f000, 0x00020044,
708 0x83300500, 0x1f000000, 0x04000008, 0x81326580,
709 0x80000130, 0x82000c80, 0x00000014, 0x02021800,
710 0x001005d8, 0x0c01f013, 0x83300500, 0x000000ff,
711 0x82000c80, 0x00000007, 0x02021800, 0x001005d8,
712 0x0c01f025, 0x1c01f000, 0x82000d00, 0xc0000038,
713 0x02020800, 0x001005d0, 0x0201f800, 0x001005d8,
714 0x00000000, 0x00000048, 0x00000054, 0x00000053,
715 0x00100a9b, 0x00100abf, 0x00100aba, 0x00100adf,
716 0x00100aa6, 0x00100ab2, 0x00100a9b, 0x00100ada,
717 0x00100b1a, 0x00100a9b, 0x00100a9b, 0x00100a9b,
718 0x00100a9b, 0x00100b1d, 0x00100b23, 0x00100b34,
719 0x00100b45, 0x00100a9b, 0x00100b4e, 0x00100b5a,
720 0x00100a9b, 0x00100a9b, 0x00100a9b, 0x0201f800,
721 0x001005d8, 0x00100aa4, 0x00100bff, 0x00100aec,
722 0x00100b0f, 0x00100aa4, 0x00100aa4, 0x00100aa4,
723 0x0201f800, 0x001005d8, 0x4803c856, 0x59300004,
724 0x8c00053e, 0x04020005, 0x42027000, 0x00000055,
725 0x0201f000, 0x000207a1, 0x0201f800, 0x00106f60,
726 0x040007fa, 0x1c01f000, 0x4803c856, 0x0401f8a9,
727 0x40002800, 0x41782000, 0x42027000, 0x00000056,
728 0x0201f000, 0x000207a1, 0x4803c856, 0x42027000,
729 0x00000057, 0x0201f000, 0x000207a1, 0x4803c856,
730 0x59300007, 0x8c00051a, 0x04020010, 0x59325808,
731 0x812e59c0, 0x04000014, 0x592c0408, 0x8c00051c,
732 0x04020003, 0x4a026011, 0xffffffff, 0x59300004,
733 0x8c00053e, 0x04020009, 0x42027000, 0x00000048,
734 0x0201f000, 0x000207a1, 0x59325808, 0x4a025a06,
735 0x00000007, 0x0401f7f4, 0x0201f800, 0x00106f60,
736 0x040007f6, 0x1c01f000, 0x4803c856, 0x83300500,
737 0x00ffffff, 0x0201f000, 0x001064d7, 0x1c01f000,
738 0x4c040000, 0x59b808ea, 0x82040d00, 0x00000007,
739 0x82040580, 0x00000003, 0x04000004, 0x42000000,
740 0x60000000, 0x0401f8ab, 0x5c000800, 0x1c01f000,
741 0x0401f8f9, 0x59325808, 0x812e59c0, 0x04000018,
742 0x592c0204, 0x82000500, 0x000000ff, 0x82000d80,
743 0x00000029, 0x04020012, 0x59300203, 0x82000580,
744 0x00000003, 0x0400000b, 0x59300807, 0x84040d26,
745 0x48066007, 0x0201f800, 0x00020086, 0x4a03900d,
746 0x00000040, 0x4a0370e5, 0x00000008, 0x1c01f000,
747 0x0201f800, 0x00106f60, 0x040007f4, 0x59880052,
748 0x80000000, 0x48031052, 0x4a03900d, 0x00000040,
749 0x42000000, 0xc0000000, 0x0401f05a, 0x42007800,
750 0x0010bde2, 0x42002000, 0x00003000, 0x42003000,
751 0x00000105, 0x0201f800, 0x00105e04, 0x4a0370e4,
752 0x02000000, 0x1c01f000, 0x4933c857, 0x0201f000,
753 0x0002077d, 0x41300800, 0x800409c0, 0x02020800,
754 0x001005d8, 0x0201f800, 0x001005d0, 0x4933c857,
755 0x813261c0, 0x02000800, 0x001005d8, 0x0401f835,
756 0x40002800, 0x0201f800, 0x0010a99c, 0x0401f8ae,
757 0x04000007, 0x59326809, 0x59340200, 0x8c00050e,
758 0x59300414, 0x02020800, 0x001092ce, 0x1c01f000,
759 0x4933c857, 0x813261c0, 0x02000800, 0x001005d8,
760 0x0401f8a1, 0x0400000b, 0x59325808, 0x0201f800,
761 0x00109037, 0x04000007, 0x592c0208, 0x8400054e,
762 0x48025a08, 0x417a7800, 0x0201f800, 0x00108be3,
763 0x1c01f000, 0x485fc857, 0x5c000000, 0x4d780000,
764 0x4203e000, 0x50000000, 0x4200b800, 0x00008005,
765 0x0201f000, 0x001005dd, 0x4933c857, 0x83300480,
766 0x00000020, 0x02021800, 0x001005d8, 0x83300c00,
767 0x0010b8cc, 0x50040000, 0x80000000, 0x04001002,
768 0x44000800, 0x1c01f000, 0x4933c857, 0x0401f7f4,
769 0x4807c856, 0x59b800ea, 0x8c000510, 0x040007fd,
770 0x59b800e0, 0x4803c857, 0x1c01f000, 0x4803c856,
771 0x42000000, 0x10000000, 0x41300800, 0x0401f02d,
772 0x82000500, 0xf0000000, 0x82040d00, 0x0fffffff,
773 0x80040d40, 0x4807c857, 0x59b800ea, 0x8c000516,
774 0x04020003, 0x480770e1, 0x1c01f000, 0x8c000510,
775 0x040007fa, 0x4c040000, 0x0401f809, 0x5c000800,
776 0x82100480, 0x00000008, 0x040017f4, 0x4c040000,
777 0x0401febc, 0x5c000800, 0x0401f7f0, 0x59b800e2,
778 0x59b820e2, 0x80100580, 0x040207fd, 0x80102114,
779 0x0401f006, 0x59b800e2, 0x59b820e2, 0x80100580,
780 0x040207fd, 0x0401f001, 0x40101800, 0x800c190a,
781 0x82100500, 0x0000001f, 0x820c1d00, 0x0000001f,
782 0x800c2480, 0x82102500, 0x0000001f, 0x1c01f000,
783 0x82000500, 0xf0000000, 0x82040d00, 0x0fffffff,
784 0x80040d40, 0x4807c857, 0x42001000, 0x0010b804,
785 0x50080000, 0x80000540, 0x04020005, 0x4a0370e5,
786 0x00000003, 0x4a0370e4, 0x00000300, 0x80000000,
787 0x44001000, 0x42001000, 0x00000400, 0x59b800ea,
788 0x8c000510, 0x0400000c, 0x0401ffd5, 0x82100480,
789 0x00000008, 0x04001007, 0x4c040000, 0x4c080000,
790 0x0401fe88, 0x5c001000, 0x5c000800, 0x0401f020,
791 0x59b800ea, 0x8c000516, 0x0402001d, 0x4a0370e4,
792 0x00300000, 0x480770e1, 0x42001000, 0x0000ff00,
793 0x80081040, 0x04000012, 0x59b808e4, 0x8c040d28,
794 0x040207fc, 0x42001000, 0x0010b804, 0x50080000,
795 0x80000040, 0x04020005, 0x4a0370e5, 0x00000002,
796 0x4a0370e4, 0x00000200, 0x02001800, 0x001005d8,
797 0x44001000, 0x8c040d2c, 0x1c01f000, 0x41f80000,
798 0x50000000, 0x0201f800, 0x001005d8, 0x80081040,
799 0x040207d3, 0x41f80000, 0x50000000, 0x0201f800,
800 0x001005d8, 0x4d380000, 0x59300c06, 0x82040580,
801 0x00000009, 0x04020006, 0x42027000, 0x00000047,
802 0x0201f800, 0x000207a1, 0x80000580, 0x5c027000,
803 0x1c01f000, 0x4c500000, 0x4a03900d, 0x00000001,
804 0x59c8a020, 0x4a03900d, 0x00000002, 0x59c80820,
805 0x8c50a52e, 0x04000002, 0x900409c0, 0x82040d00,
806 0x0000ffff, 0x0201f800, 0x00105dd7, 0x02000800,
807 0x001005d8, 0x4933c857, 0x8250a500, 0xff000000,
808 0x82500580, 0x05000000, 0x04000003, 0x82000540,
809 0x00000001, 0x5c00a000, 0x1c01f000, 0x0401ffe6,
810 0x4933c857, 0x59300406, 0x82000580, 0x00000000,
811 0x04000040, 0x59c82021, 0x4a03900d, 0x00000001,
812 0x59c82821, 0x82142d00, 0x0000ffff, 0x59325808,
813 0x812e59c0, 0x04000037, 0x59326809, 0x0201f800,
814 0x001048d9, 0x02020800, 0x001092b6, 0x599c0019,
815 0x8c00050c, 0x04020018, 0x0201f800, 0x001048d9,
816 0x04020015, 0x59300811, 0x4807c857, 0x592c0408,
817 0x8c00051c, 0x0402000e, 0x8400055c, 0x48025c08,
818 0x592c0a04, 0x82040d00, 0x000000ff, 0x82040580,
819 0x00000048, 0x04000004, 0x82040580, 0x00000018,
820 0x04020003, 0x59300811, 0x48065803, 0x4a026011,
821 0x7fffffff, 0x48166013, 0x0201f800, 0x001010dd,
822 0x04020014, 0x0401f9fd, 0x40280000, 0x4802600d,
823 0x04000005, 0x4832600b, 0x50200000, 0x4802600a,
824 0x4822600c, 0x59300414, 0x8c00051c, 0x04020004,
825 0x599c0019, 0x8c00050c, 0x0402086e, 0x4a03900d,
826 0x00000040, 0x4a0370e5, 0x00000008, 0x1c01f000,
827 0x59880052, 0x80000000, 0x48031052, 0x4a03900d,
828 0x00000040, 0x42000000, 0xc0000000, 0x0401f71d,
829 0x4cf80000, 0x58f40000, 0x8001f540, 0x0401f820,
830 0x41781800, 0x0401f8e4, 0x04020014, 0x44140800,
831 0x0401f82a, 0x04000011, 0x40043800, 0x42001800,
832 0x00000001, 0x40142000, 0x0401f8db, 0x0402000b,
833 0x801c3800, 0x501c0000, 0x44000800, 0x0401f810,
834 0x801c0580, 0x04000004, 0x44103800, 0x801c3840,
835 0x44143800, 0x0401f819, 0x5c01f000, 0x1c01f000,
836 0x80f9f1c0, 0x04020003, 0x58f41202, 0x0401f003,
837 0x42001000, 0x00000007, 0x1c01f000, 0x80f9f1c0,
838 0x04020006, 0x58f40401, 0x82000480, 0x00000002,
839 0x80f40400, 0x0401f005, 0x58f80401, 0x82000480,
840 0x00000002, 0x80f80400, 0x50002800, 0x80000000,
841 0x50002000, 0x1c01f000, 0x80f9f1c0, 0x04020008,
842 0x58f40401, 0x82000480, 0x00000002, 0x02001800,
843 0x001005d8, 0x4801ec01, 0x0401f00b, 0x58f80401,
844 0x82000480, 0x00000002, 0x02001800, 0x001005d8,
845 0x4801f401, 0x82000580, 0x00000002, 0x04020002,
846 0x0401f809, 0x58f40202, 0x80000040, 0x4801ea02,
847 0x02000800, 0x001005d8, 0x82000580, 0x00000001,
848 0x1c01f000, 0x4d2c0000, 0x40fa5800, 0x0201f800,
849 0x001007f4, 0x4979e800, 0x4179f000, 0x5c025800,
850 0x1c01f000, 0x80f5e9c0, 0x04000009, 0x80f9f1c0,
851 0x04020ff5, 0x4d2c0000, 0x40f65800, 0x0201f800,
852 0x001007f4, 0x4179e800, 0x5c025800, 0x1c01f000,
853 0x4cf40000, 0x59300807, 0x82040500, 0x00003100,
854 0x04020032, 0x8c040d22, 0x04000032, 0x5930001f,
855 0x8001ed40, 0x02000800, 0x001005d8, 0x82000580,
856 0xffffffff, 0x04000029, 0x58f40201, 0x82000580,
857 0x0000dcb3, 0x02020800, 0x001005d8, 0x58f40a02,
858 0x82040500, 0x0000fffe, 0x04000003, 0x0401ff89,
859 0x58f40a02, 0x82040480, 0x0000000f, 0x04021059,
860 0x80040800, 0x4805ea02, 0x82040580, 0x00000008,
861 0x0400005d, 0x82040480, 0x00000008, 0x0400100a,
862 0x58f40000, 0x8001ed40, 0x02000800, 0x001005d8,
863 0x58f40201, 0x82000580, 0x0000ddb9, 0x02020800,
864 0x001005d8, 0x58f40401, 0x82000c00, 0x00000002,
865 0x4805ec01, 0x80f40400, 0x59300812, 0x44040000,
866 0x80000000, 0x45780000, 0x5c01e800, 0x1c01f000,
867 0x42001000, 0x00000400, 0x59b800e4, 0x8c000524,
868 0x04020023, 0x4a0370e4, 0x00030000, 0x40000000,
869 0x59b800e4, 0x8c000524, 0x0402001b, 0x59300807,
870 0x84040d62, 0x48066007, 0x4a0370e4, 0x00020000,
871 0x4d2c0000, 0x0201f800, 0x001007d3, 0x04000025,
872 0x492e601f, 0x4a025a01, 0x0000dcb3, 0x59300008,
873 0x80001d40, 0x02000800, 0x001005d8, 0x580c080f,
874 0x48065803, 0x59301811, 0x40040000, 0x800c0580,
875 0x0402000d, 0x497a5a02, 0x4a025c01, 0x00000004,
876 0x0401f011, 0x4a0370e4, 0x00020000, 0x40000000,
877 0x40000000, 0x80081040, 0x02000800, 0x001005d8,
878 0x0401f7d6, 0x4a025a02, 0x00000001, 0x4a025c01,
879 0x00000006, 0x497a5804, 0x400c0000, 0x80040480,
880 0x48025805, 0x412de800, 0x5c025800, 0x0401f7a9,
881 0x5c025800, 0x4a02601f, 0xffffffff, 0x0401f7c3,
882 0x4d2c0000, 0x58f65800, 0x0201f800, 0x001007f4,
883 0x40f65800, 0x0201f800, 0x001007f4, 0x5c025800,
884 0x0401f7f5, 0x4d2c0000, 0x0201f800, 0x001007d3,
885 0x040007f8, 0x4a025a01, 0x0000ddb9, 0x4a025c01,
886 0x00000002, 0x492de800, 0x412de800, 0x5c025800,
887 0x0401f7a5, 0x0401ff33, 0x82f40400, 0x00000004,
888 0x800c0400, 0x40000800, 0x50040000, 0x80100580,
889 0x04000016, 0x82040c00, 0x00000002, 0x80081040,
890 0x040207fa, 0x80f9f1c0, 0x04000011, 0x58f41202,
891 0x82081480, 0x00000007, 0x82f80400, 0x00000002,
892 0x800c0400, 0x40000800, 0x50040000, 0x80100580,
893 0x04000006, 0x82040c00, 0x00000002, 0x80081040,
894 0x040207fa, 0x0401f002, 0x1c01f000, 0x82000540,
895 0x00000001, 0x0401f7fd, 0x4cf40000, 0x4cf80000,
896 0x4001e800, 0x592c0a06, 0x800409c0, 0x0402001d,
897 0x82f40580, 0xffffffff, 0x04000017, 0x58f40201,
898 0x82000580, 0x0000dcb3, 0x02020800, 0x001005d8,
899 0x58f40000, 0x8001f540, 0x04000006, 0x58f80201,
900 0x82000580, 0x0000ddb9, 0x02020800, 0x001005d8,
901 0x41783800, 0x0401f839, 0x04020006, 0x0401ff32,
902 0x497a601f, 0x5c01f000, 0x5c01e800, 0x1c01f000,
903 0x0401ff2d, 0x4a025a06, 0x00000011, 0x0401f7f9,
904 0x82f40580, 0xffffffff, 0x04020f27, 0x0401f7f5,
905 0x4cf40000, 0x4cf80000, 0x4001e800, 0x82040580,
906 0x00000001, 0x0402001f, 0x82f40580, 0xffffffff,
907 0x04000019, 0x58f40201, 0x82000580, 0x0000dcb3,
908 0x02020800, 0x001005d8, 0x58f40000, 0x8001f540,
909 0x04000006, 0x58f80201, 0x82000580, 0x0000ddb9,
910 0x02020800, 0x001005d8, 0x41783800, 0x0401f813,
911 0x04020008, 0x0401ff0c, 0x42000800, 0x00000001,
912 0x497a601f, 0x5c01f000, 0x5c01e800, 0x1c01f000,
913 0x0401ff05, 0x42000800, 0x00000011, 0x0401f7f9,
914 0x4c040000, 0x82f40580, 0xffffffff, 0x04020efe,
915 0x5c000800, 0x0401f7f3, 0x4803c856, 0x401c2000,
916 0x41781800, 0x0401ff8c, 0x0402002c, 0x58f42003,
917 0x42001800, 0x00000001, 0x0401ff87, 0x04020027,
918 0x0401feb8, 0x40082800, 0x82f40400, 0x00000004,
919 0x40003000, 0x50182000, 0x40100000, 0x801c0580,
920 0x04000005, 0x42001800, 0x00000001, 0x0401ff7a,
921 0x0402001a, 0x82183400, 0x00000002, 0x80142840,
922 0x040207f5, 0x80f9f1c0, 0x04000013, 0x58f42a02,
923 0x82142c80, 0x00000007, 0x82f80400, 0x00000003,
924 0x40003000, 0x50182000, 0x40100000, 0x801c0580,
925 0x04000005, 0x42001800, 0x00000001, 0x0401ff66,
926 0x04020006, 0x82183400, 0x00000002, 0x80142840,
927 0x040207f5, 0x1c01f000, 0x82000540, 0x00000001,
928 0x0401f7fd, 0x0201f800, 0x001005d8, 0x58380207,
929 0x8c000502, 0x040007fc, 0x50200000, 0x80387c00,
930 0x583c2800, 0x583c2001, 0x58380404, 0x80001540,
931 0x04020002, 0x58381407, 0x58c83401, 0x58380c08,
932 0x59303807, 0x497a6012, 0x497a6013, 0x0201f000,
933 0x000200be, 0x592c0408, 0x8c000502, 0x040007ea,
934 0x592c0409, 0x80000540, 0x040007e7, 0x82000c80,
935 0x00000002, 0x04001011, 0x58380001, 0x80007540,
936 0x02000800, 0x001005d8, 0x58380204, 0x82000500,
937 0x0000000f, 0x82000400, 0x001010bd, 0x50004000,
938 0x40040000, 0x800409c0, 0x04000005, 0x82040c80,
939 0x00000005, 0x040217f1, 0x80204400, 0x50200000,
940 0x80387c00, 0x583c2800, 0x583c2001, 0x583c1002,
941 0x592c0a07, 0x592c4c08, 0x592c300d, 0x59303807,
942 0x497a6012, 0x497a6013, 0x4816600e, 0x4812600f,
943 0x480a6010, 0x481a6011, 0x80040840, 0x4806600d,
944 0x02000000, 0x000200c6, 0x80204000, 0x50201800,
945 0x800c19c0, 0x0402000c, 0x58380001, 0x80007540,
946 0x02000800, 0x001005d8, 0x58380204, 0x82000500,
947 0x0000000f, 0x82000400, 0x001010bd, 0x50004000,
948 0x50201800, 0x483a600b, 0x480e600a, 0x4822600c,
949 0x0201f000, 0x000200c6, 0x4803c856, 0x592c0208,
950 0x8c00051e, 0x04020017, 0x50200000, 0x80306c00,
951 0x40240000, 0x0c01f001, 0x00100e46, 0x00100e46,
952 0x00100e4f, 0x00100e46, 0x00100e46, 0x00100e46,
953 0x00100e46, 0x00100e46, 0x00100e4f, 0x00100e46,
954 0x00100e4f, 0x00100e46, 0x00100e46, 0x00100e4f,
955 0x00100e46, 0x00100e46, 0x0201f800, 0x001005d8,
956 0x8400051e, 0x48025a08, 0x50200000, 0x80306c00,
957 0x58343801, 0x481e600f, 0x0401f007, 0x58341802,
958 0x58342800, 0x58343801, 0x480e6010, 0x4816600e,
959 0x481e600f, 0x0401f246, 0x4933c857, 0x5931f808,
960 0x59300a06, 0x800409c0, 0x04000005, 0x80040906,
961 0x04020002, 0x80040800, 0x4805fc06, 0x4a026206,
962 0x00000002, 0x592c0409, 0x82000500, 0x00000008,
963 0x0400000b, 0x0401f834, 0x59300203, 0x82000580,
964 0x00000004, 0x04020005, 0x42027000, 0x00000048,
965 0x0201f800, 0x000207a1, 0x1c01f000, 0x4cfc0000,
966 0x58fc0204, 0x82000500, 0x000000ff, 0x82000580,
967 0x00000048, 0x0402000c, 0x58fc000b, 0x800001c0,
968 0x04000009, 0x58fc0407, 0x800001c0, 0x04000006,
969 0x58fc080b, 0x8c040d16, 0x04000017, 0x58fc0007,
970 0x0401f00a, 0x58fc0408, 0x8c000512, 0x04020014,
971 0x58fc0c09, 0x8c040d16, 0x04020003, 0x5c01f800,
972 0x1c01f000, 0x58fc000a, 0x59300811, 0x80040580,
973 0x04020009, 0x59300007, 0x84000500, 0x48026007,
974 0x42027000, 0x00000048, 0x5c01f800, 0x0201f000,
975 0x000207a1, 0x5c01f800, 0x1c01f000, 0x58fdf809,
976 0x0401f7ec, 0x4933c857, 0x59b808ea, 0x82040d00,
977 0x00000007, 0x82040580, 0x00000000, 0x0400001e,
978 0x82040580, 0x00000003, 0x0400001b, 0x59300406,
979 0x4c000000, 0x4a026406, 0x00000000, 0x42003000,
980 0x00000041, 0x42000000, 0x50000000, 0x41300800,
981 0x4c180000, 0x0401fce7, 0x5c003000, 0x0400000b,
982 0x42000000, 0x0000001e, 0x80000040, 0x040207ff,
983 0x80183040, 0x040207f4, 0x42000000, 0x40000000,
984 0x41300800, 0x0401fcdb, 0x5c000000, 0x48026406,
985 0x1c01f000, 0x59300007, 0x84000500, 0x48026007,
986 0x0401f7fc, 0x59c00007, 0x4a038006, 0x30000000,
987 0x40000000, 0x59c00007, 0x8c00050a, 0x040207fe,
988 0x1c01f000, 0x5c000000, 0x4c000000, 0x4803c857,
989 0x4dc00000, 0x4a0370e8, 0x00000000, 0x42038000,
990 0x00007720, 0x0401fff0, 0x42038000, 0x00007700,
991 0x0401ffed, 0x0201f800, 0x0010513b, 0x04020013,
992 0x4a038891, 0x0000ffff, 0x497b8880, 0x497b8892,
993 0x42001000, 0x00000190, 0x40000000, 0x40000000,
994 0x80081040, 0x040207fd, 0x42000000, 0x0010b8a6,
995 0x0201f800, 0x0010aa47, 0x0401f80e, 0x5c038000,
996 0x0201f000, 0x00105258, 0x0401f82d, 0x42000000,
997 0x0010b8a7, 0x0201f800, 0x0010aa47, 0x0401f805,
998 0x48178892, 0x480b8880, 0x5c038000, 0x1c01f000,
999 0x496fc857, 0x836c0580, 0x00000003, 0x0402000b,
1000 0x4c080000, 0x4c0c0000, 0x42001000, 0x00008048,
1001 0x42001800, 0x0000ffff, 0x0201f800, 0x00103a3e,
1002 0x5c001800, 0x5c001000, 0x42000800, 0x0000003c,
1003 0x0201f800, 0x00101345, 0x59a8006c, 0x80000540,
1004 0x04000006, 0x59a8106d, 0x800811c0, 0x04000003,
1005 0x0201f800, 0x00101aaf, 0x4a038891, 0x0000ffff,
1006 0x4a03900d, 0x00000040, 0x0201f800, 0x0010098e,
1007 0x4a0370e8, 0x00000001, 0x1c01f000, 0x5c000000,
1008 0x4c000000, 0x4803c857, 0x59c41080, 0x497b8880,
1009 0x59c42892, 0x497b8892, 0x0201f800, 0x0010513b,
1010 0x04020002, 0x1c01f000, 0x42002000, 0x00000260,
1011 0x59c418a4, 0x820c1d00, 0x0000000f, 0x820c0580,
1012 0x00000000, 0x04000010, 0x59c41805, 0x820c1d00,
1013 0x00000001, 0x0402000e, 0x59c418a4, 0x820c1d00,
1014 0x0000000f, 0x820c0480, 0x00000007, 0x04001004,
1015 0x820c0480, 0x0000000c, 0x04001003, 0x80102040,
1016 0x040207ec, 0x497b8891, 0x1c01f000, 0x4c100000,
1017 0x42002000, 0x00000019, 0x46000000, 0x00000001,
1018 0x0201f800, 0x00101937, 0x50001800, 0x820c1d00,
1019 0x00000001, 0x04000005, 0x80102040, 0x040207f7,
1020 0x5c002000, 0x0401f7f0, 0x5c002000, 0x0401f7ec,
1021 0x4803c856, 0x1c01f000, 0x4d2c0000, 0x59325808,
1022 0x592c0a04, 0x4807c857, 0x82040d00, 0x000000ff,
1023 0x82040500, 0x0000000f, 0x0c01f001, 0x00100f67,
1024 0x00100f67, 0x00100f67, 0x00100f7f, 0x00100f67,
1025 0x00100f67, 0x00100f67, 0x00100f67, 0x00100f67,
1026 0x00100f7f, 0x00100f67, 0x00100f69, 0x00100f67,
1027 0x00100f67, 0x00100f67, 0x00100f67, 0x0201f800,
1028 0x001005d8, 0x82040580, 0x0000003b, 0x02020800,
1029 0x001005d8, 0x592c020a, 0x8c000500, 0x0400005f,
1030 0x592c1a07, 0x82040500, 0x0000000f, 0x82000400,
1031 0x001010bd, 0x50001000, 0x50080000, 0x59302013,
1032 0x4802600a, 0x492e600b, 0x480a600c, 0x480e600d,
1033 0x48126012, 0x5c025800, 0x1c01f000, 0x82040500,
1034 0x0000000f, 0x82000400, 0x001010bd, 0x50001000,
1035 0x50080000, 0x592c1a07, 0x4802600a, 0x492e600b,
1036 0x480a600c, 0x480e600d, 0x497a6012, 0x0401f7f2,
1037 0x8c040d00, 0x04020041, 0x82040d00, 0x00000080,
1038 0x0400003e, 0x0201f000, 0x000200cf, 0x59300013,
1039 0x59301012, 0x80080580, 0x0402000c, 0x42007800,
1040 0x80000005, 0x592c1208, 0x82080500, 0xffff7fff,
1041 0x48025a08, 0x8c08151e, 0x0402002d, 0x823c7d40,
1042 0x00000020, 0x0401f02a, 0x480bc857, 0x42000000,
1043 0x0010b851, 0x0201f800, 0x0010aa47, 0x59300414,
1044 0x4803c857, 0x8c000514, 0x04020007, 0x599c1819,
1045 0x8c0c1d12, 0x04020004, 0x820c1d40, 0x00000001,
1046 0x0401f01d, 0x59302013, 0x0401f92b, 0x0402001a,
1047 0x42007800, 0x80000005, 0x5930500d, 0x592c0208,
1048 0x4803c857, 0x8c00051e, 0x04020005, 0x823c7d40,
1049 0x00000020, 0x5930400c, 0x0401f004, 0x8400051e,
1050 0x48025a08, 0x0401f8da, 0x50201800, 0x480e600a,
1051 0x4832600b, 0x4822600c, 0x482a600d, 0x480fc857,
1052 0x4833c857, 0x4823c857, 0x482bc857, 0x80000580,
1053 0x483e6004, 0x1c01f000, 0x0201f800, 0x001005d8,
1054 0x4933c857, 0x4d2c0000, 0x59900004, 0x81300580,
1055 0x02020800, 0x001005d8, 0x0201f800, 0x00109037,
1056 0x02000800, 0x001005d8, 0x59325808, 0x4d3c0000,
1057 0x4d400000, 0x59300004, 0x4803c857, 0x4c000000,
1058 0x0201f800, 0x00106dc3, 0x0201f800, 0x00106b8a,
1059 0x5c000000, 0x8c000516, 0x04000010, 0x592c000f,
1060 0x4803c857, 0x48025807, 0x41780800, 0x42028000,
1061 0x00000002, 0x0201f800, 0x00104e70, 0x4a025c06,
1062 0x0000ffff, 0x0201f800, 0x000202da, 0x0201f800,
1063 0x00107911, 0x0401f015, 0x4a026203, 0x00000002,
1064 0x592c0208, 0x8400054e, 0x48025a08, 0x59300406,
1065 0x82000580, 0x00000006, 0x04020009, 0x811800ca,
1066 0x81c80c00, 0x58040939, 0x592c000d, 0x80040480,
1067 0x592c080f, 0x80040480, 0x4802580b, 0x417a7800,
1068 0x0201f800, 0x00108be3, 0x5c028000, 0x5c027800,
1069 0x5c025800, 0x1c01f000, 0x4933c857, 0x4d2c0000,
1070 0x59900004, 0x81300580, 0x02020800, 0x001005d8,
1071 0x0201f800, 0x00109037, 0x02000800, 0x001005d8,
1072 0x59325808, 0x592c0208, 0x84000540, 0x48025a08,
1073 0x0401f7bf, 0x491bc857, 0x49d3c857, 0x4dd00000,
1074 0x41780800, 0x8007a0ca, 0x83d3a400, 0x00007600,
1075 0x4a03a005, 0x80000002, 0x42000000, 0x00001000,
1076 0x50000000, 0x82000480, 0x24220001, 0x04020029,
1077 0x59d01006, 0x82080500, 0x00006000, 0x82000580,
1078 0x00006000, 0x0400002f, 0x82080500, 0x40008000,
1079 0x040007f8, 0x800409c0, 0x0402002a, 0x811a31c0,
1080 0x04000028, 0x42000000, 0x00001002, 0x50001000,
1081 0x46000000, 0x00000512, 0x42001800, 0x0000000a,
1082 0x59e00000, 0x8c00051a, 0x040207fc, 0x800c1840,
1083 0x040207fc, 0x42000000, 0x00001002, 0x46000000,
1084 0x00000514, 0x42001800, 0x0000000a, 0x59e00000,
1085 0x8c00053a, 0x040207fc, 0x800c1840, 0x040207fc,
1086 0x42000000, 0x00001002, 0x44080000, 0x0401f00d,
1087 0x59d01006, 0x82080500, 0x00006000, 0x82000580,
1088 0x00006000, 0x04000007, 0x8c08151e, 0x040007f9,
1089 0x59d01006, 0x82080500, 0x00006000, 0x040207f5,
1090 0x83d3a400, 0x00000020, 0x80040800, 0x82040480,
1091 0x00000005, 0x040017bf, 0x5c03a000, 0x1c01f000,
1092 0x491bc857, 0x49d3c857, 0x4dd00000, 0x41780800,
1093 0x8007a0ca, 0x83d3a400, 0x00007600, 0x4a03a005,
1094 0x80000001, 0x59d00006, 0x83d3a400, 0x00000020,
1095 0x80040800, 0x82040480, 0x00000005, 0x040017f8,
1096 0x5c03a000, 0x1c01f000, 0x59d00006, 0x8c00053e,
1097 0x0400001e, 0x59902804, 0x4817c857, 0x801429c0,
1098 0x04000013, 0x5990000a, 0x5990080b, 0x5990100c,
1099 0x5990180d, 0x4800280a, 0x4804280b, 0x4808280c,
1100 0x480c280d, 0x59d00000, 0x59d00801, 0x59d01002,
1101 0x59d01803, 0x59d02004, 0x4800280e, 0x4804280f,
1102 0x48082810, 0x480c2811, 0x48102812, 0x59900006,
1103 0x82000500, 0xffff0000, 0x48032006, 0x4a03a005,
1104 0x30000000, 0x59d00006, 0x1c01f000, 0x4803c856,
1105 0x80204000, 0x50200000, 0x80000540, 0x04000003,
1106 0x80285040, 0x1c01f000, 0x58300001, 0x80000540,
1107 0x0400000e, 0x4802600b, 0x40006000, 0x58300204,
1108 0x82000500, 0x0000000f, 0x82000400, 0x001010bd,
1109 0x50004000, 0x802041c0, 0x02000800, 0x001005d8,
1110 0x80285040, 0x1c01f000, 0x40005000, 0x1c01f000,
1111 0x00000005, 0x00000008, 0x0000000b, 0x0000000e,
1112 0x00000011, 0x00000000, 0x00000000, 0x0000000b,
1113 0x00000000, 0x00000000, 0x00000000, 0x001010b8,
1114 0x001010b7, 0x00000000, 0x00000000, 0x00000000,
1115 0x00000000, 0x001010b8, 0x001010b7, 0x001010b4,
1116 0x001010b8, 0x001010b7, 0x00000000, 0x00000000,
1117 0x00000000, 0x00000000, 0x00000000, 0x001010b8,
1118 0x00000000, 0x00000000, 0x00000000, 0x00000000,
1119 0x00000000, 0x001010b8, 0x001010b8, 0x001010b8,
1120 0x00000000, 0x001010b8, 0x00000000, 0x00000000,
1121 0x00000000, 0x4813c857, 0x492fc857, 0x4933c857,
1122 0x48126012, 0x592c5207, 0x802851c0, 0x0400004a,
1123 0x412c6000, 0x0401f84b, 0x04000009, 0x82240580,
1124 0x00000002, 0x04020003, 0x5830000d, 0x80102480,
1125 0x50200000, 0x80004540, 0x0400003f, 0x50200000,
1126 0x80000540, 0x0400000b, 0x80301400, 0x58080002,
1127 0x80102480, 0x0400101e, 0x801021c0, 0x04000009,
1128 0x80285040, 0x04000034, 0x80204000, 0x0401f7f4,
1129 0x58300001, 0x80006540, 0x0400002f, 0x0401f7e6,
1130 0x80285040, 0x0400002c, 0x80204000, 0x50200000,
1131 0x80000540, 0x0402000a, 0x58300001, 0x80006540,
1132 0x04000025, 0x58300204, 0x82004d00, 0x0000000f,
1133 0x82244400, 0x001010bd, 0x50204000, 0x592c0208,
1134 0x8400051e, 0x48025a08, 0x0401f013, 0x80102080,
1135 0x80102000, 0x48126010, 0x4813c857, 0x58080802,
1136 0x40100000, 0x80042480, 0x02001800, 0x001005d8,
1137 0x58080000, 0x58081801, 0x80102400, 0x4812600e,
1138 0x480e600f, 0x4813c857, 0x592c0208, 0x8400055e,
1139 0x48025a08, 0x4833c857, 0x4823c857, 0x482bc857,
1140 0x4832600b, 0x4822600c, 0x482a600d, 0x80000580,
1141 0x0401f003, 0x82000540, 0x00000001, 0x1c01f000,
1142 0x58300204, 0x82004d00, 0x0000000f, 0x82244400,
1143 0x001010bd, 0x82000500, 0x000000ff, 0x82000580,
1144 0x00000029, 0x0402001b, 0x50204000, 0x592c0409,
1145 0x80000540, 0x02000800, 0x001005d8, 0x82000c80,
1146 0x00000002, 0x04001011, 0x58300001, 0x80006540,
1147 0x02000800, 0x001005d8, 0x58300204, 0x82000500,
1148 0x0000000f, 0x82000400, 0x001010bd, 0x50004000,
1149 0x40040000, 0x800409c0, 0x04000006, 0x82040c80,
1150 0x00000005, 0x040217f1, 0x80204400, 0x80000580,
1151 0x1c01f000, 0x59e00004, 0x8c00050e, 0x02020000,
1152 0x00100903, 0x1c01f000, 0x4c5c0000, 0x59e4b800,
1153 0x485fc857, 0x825c0500, 0x0000001f, 0x04000004,
1154 0x59e40862, 0x0201f800, 0x001005d8, 0x825c0500,
1155 0x000000e0, 0x02000800, 0x001005d8, 0x8c5cbd0e,
1156 0x04020807, 0x8c5cbd0c, 0x04020809, 0x8c5cbd0a,
1157 0x04020878, 0x5c00b800, 0x1c01f000, 0x4803c856,
1158 0x4a03c800, 0x00000080, 0x1c01f000, 0x4d2c0000,
1159 0x42007800, 0x0010b8ec, 0x583c0001, 0x583c0802,
1160 0x80040540, 0x0400003f, 0x42000800, 0x0010b7f7,
1161 0x50065800, 0x592c0002, 0x82000580, 0x00000000,
1162 0x0400000e, 0x59e40850, 0x59e41853, 0x400c0000,
1163 0x80040400, 0x59e40852, 0x4807c857, 0x80041480,
1164 0x04021008, 0x40001000, 0x480bc857, 0x4a007800,
1165 0x00000001, 0x0401f006, 0x4803c857, 0x0401f029,
1166 0x59e41050, 0x480bc857, 0x49787800, 0x480bc857,
1167 0x480fc857, 0x592c0003, 0x80000540, 0x04000006,
1168 0x80080580, 0x04020004, 0x592c0003, 0x4803c857,
1169 0x480bc857, 0x480a5803, 0x592c0007, 0x800001c0,
1170 0x04000007, 0x592c1007, 0x480bc857, 0x583c0003,
1171 0x4803c857, 0x80080480, 0x04001003, 0x583c1001,
1172 0x480bc857, 0x583c0802, 0x480bc857, 0x4807c857,
1173 0x4a025801, 0x00000000, 0x4a025809, 0x001011bc,
1174 0x480a5807, 0x48065808, 0x59e40053, 0x48025804,
1175 0x412c1000, 0x492fc857, 0x0201f800, 0x00100858,
1176 0x5c025800, 0x4a03c800, 0x00000040, 0x1c01f000,
1177 0x42007800, 0x0010b7f7, 0x503c7800, 0x4a007802,
1178 0x00000100, 0x42007800, 0x0010b8ec, 0x583c0000,
1179 0x4803c857, 0x82000d80, 0x00000001, 0x04000004,
1180 0x80000000, 0x48007800, 0x0401f019, 0x49787800,
1181 0x583c1806, 0x583c0005, 0x800c1800, 0x480c7806,
1182 0x800c0580, 0x04020002, 0x49787806, 0x583c0807,
1183 0x800409c0, 0x0400000e, 0x583c0008, 0x80000000,
1184 0x48007808, 0x80040580, 0x04020009, 0x49787808,
1185 0x583c2006, 0x42001800, 0x00000001, 0x42001000,
1186 0x00008028, 0x0201f800, 0x00103a3e, 0x1c01f000,
1187 0x4a03c800, 0x00000020, 0x0201f800, 0x0010aa40,
1188 0x59e40000, 0x1c01f000, 0x4d2c0000, 0x4a007001,
1189 0x00000000, 0x82040d00, 0x43000f80, 0x02020800,
1190 0x001005d8, 0x58380009, 0x4803c00f, 0x0201f800,
1191 0x00109402, 0x583a5808, 0x592c0000, 0x48007008,
1192 0x800001c0, 0x04020002, 0x49787007, 0x0201f800,
1193 0x001007f4, 0x5c025800, 0x0201f000, 0x0010087d,
1194 0x4803c856, 0x4c3c0000, 0x4d2c0000, 0x4d300000,
1195 0x5830000a, 0x80025d40, 0x02000800, 0x001005d8,
1196 0x592e6008, 0x4c300000, 0x0201f800, 0x0010941a,
1197 0x5c006000, 0x02000800, 0x001005d8, 0x58300002,
1198 0x82000580, 0x00000100, 0x04020010, 0x5930780b,
1199 0x583c0001, 0x80000540, 0x0400000e, 0x4802600b,
1200 0x40007800, 0x82000400, 0x00000002, 0x48006003,
1201 0x583c0000, 0x48006004, 0x40301000, 0x0201f800,
1202 0x00100858, 0x0401f00c, 0x4a025a06, 0x00000002,
1203 0x4c300000, 0x0201f800, 0x000202da, 0x5c006000,
1204 0x40325800, 0x0201f800, 0x001007f4, 0x0201f800,
1205 0x0002077d, 0x5c026000, 0x5c025800, 0x5c007800,
1206 0x1c01f000, 0x4803c856, 0x4d2c0000, 0x4d300000,
1207 0x42007000, 0x0010b7f8, 0x58380801, 0x82040580,
1208 0x00000002, 0x04020011, 0x58386002, 0x5830000a,
1209 0x812c0580, 0x0402000d, 0x59e00004, 0x8c00050e,
1210 0x040007fe, 0x59dc0006, 0x4803c857, 0x4a03b805,
1211 0x20000000, 0x8c00053e, 0x040007f8, 0x4a007001,
1212 0x00000000, 0x0401f019, 0x58386006, 0x40305000,
1213 0x803061c0, 0x02000800, 0x001005d8, 0x5830000a,
1214 0x812c0580, 0x04000004, 0x40305000, 0x58306000,
1215 0x0401f7f8, 0x40280000, 0x80300580, 0x58300000,
1216 0x04000006, 0x48005000, 0x800001c0, 0x04020007,
1217 0x48287005, 0x0401f005, 0x800001c0, 0x04020002,
1218 0x48007005, 0x48007006, 0x40325800, 0x0201f800,
1219 0x001007f4, 0x42007000, 0x0010b7f8, 0x58380001,
1220 0x82000580, 0x00000000, 0x02000800, 0x0010087d,
1221 0x5c026000, 0x5c025800, 0x1c01f000, 0x4803c856,
1222 0x42000800, 0x0000003c, 0x48079000, 0x59c80000,
1223 0x80040500, 0x040207fe, 0x497b9005, 0x4a039035,
1224 0x00880200, 0x59a8000e, 0x800000e0, 0x4803900e,
1225 0x4a039011, 0x00000024, 0x4a03900f, 0x0010d1c0,
1226 0x4a039010, 0x0010d1c0, 0x4a039015, 0x0000007f,
1227 0x4a03900d, 0x00000040, 0x4a039000, 0x00001600,
1228 0x1c01f000, 0x59c80007, 0x8c000508, 0x040208b7,
1229 0x59c80800, 0x8c040d16, 0x04020004, 0x82000500,
1230 0x00000006, 0x0c01f005, 0x4807c857, 0x82000500,
1231 0x0000000e, 0x0c01f001, 0x001012a8, 0x001012a6,
1232 0x00105999, 0x001012a6, 0x001012aa, 0x001012a6,
1233 0x001012aa, 0x001012aa, 0x001012a6, 0x001012a6,
1234 0x001012a6, 0x001012a6, 0x001012aa, 0x001012a6,
1235 0x001012aa, 0x001012a6, 0x0201f800, 0x001005d8,
1236 0x4803c857, 0x1c01f000, 0x59c8080c, 0x4807c857,
1237 0x82040500, 0x00006000, 0x04000004, 0x0201f800,
1238 0x0010aa03, 0x0401f006, 0x82040500, 0x007f0000,
1239 0x04000006, 0x0201f800, 0x0010a9d5, 0x0201f800,
1240 0x00106eb3, 0x0401f02b, 0x82040500, 0x00000014,
1241 0x04000014, 0x0201f800, 0x0010aa32, 0x836c0580,
1242 0x00000003, 0x0400000d, 0x0201f800, 0x0010513b,
1243 0x04000004, 0x0201f800, 0x0010411d, 0x0401f007,
1244 0x4a035033, 0x00000001, 0x4202d800, 0x00000001,
1245 0x0201f800, 0x001050a2, 0x0401f817, 0x0401f015,
1246 0x82040500, 0x00001c00, 0x04000005, 0x0201f800,
1247 0x0010aa11, 0x0401f810, 0x0401f00e, 0x82040500,
1248 0x00000140, 0x04000005, 0x0201f800, 0x0010aa24,
1249 0x0401f809, 0x0401f007, 0x82040500, 0x00008000,
1250 0x04000004, 0x0201f800, 0x0010a9fc, 0x0401f802,
1251 0x1c01f000, 0x4c0c0000, 0x4c100000, 0x4c140000,
1252 0x0201f800, 0x00100ec9, 0x5c002800, 0x5c002000,
1253 0x5c001800, 0x1c01f000, 0x4803c856, 0x59a80804,
1254 0x59a8002b, 0x82000500, 0xfffff000, 0x80040540,
1255 0x4803502b, 0x59a8002f, 0x82000500, 0xfffff000,
1256 0x80040540, 0x4803502f, 0x48078882, 0x82041c00,
1257 0x0000000f, 0x800c1908, 0x820c1c00, 0x00000004,
1258 0x400c2000, 0x901029c0, 0x82040480, 0x000001e4,
1259 0x04021005, 0x42001000, 0x00000008, 0x801020c6,
1260 0x0401f031, 0x82040480, 0x00000230, 0x04021009,
1261 0x42001000, 0x00000007, 0x801000c2, 0x800000c2,
1262 0x80100400, 0x80100400, 0x80102400, 0x0401f026,
1263 0x82040480, 0x00000298, 0x04021008, 0x42001000,
1264 0x00000006, 0x801000c2, 0x800000c2, 0x80100400,
1265 0x80102400, 0x0401f01c, 0x82040480, 0x00000328,
1266 0x04021007, 0x42001000, 0x00000005, 0x801000c2,
1267 0x800000c2, 0x80102400, 0x0401f013, 0x82040480,
1268 0x00000404, 0x04021005, 0x42001000, 0x00000004,
1269 0x801020c4, 0x0401f00c, 0x82040480, 0x0000056c,
1270 0x04021006, 0x42001000, 0x00000003, 0x801000c2,
1271 0x80102400, 0x0401f004, 0x42001000, 0x00000002,
1272 0x801020c2, 0x82100480, 0x00000110, 0x80000080,
1273 0x80002000, 0x800800d0, 0x80140540, 0x80100540,
1274 0x48039035, 0x1c01f000, 0x59c80815, 0x0201f800,
1275 0x001005d0, 0x82040d00, 0x0000007c, 0x48079000,
1276 0x59c80000, 0x80040500, 0x040207fe, 0x8c040d04,
1277 0x04000003, 0x59c80035, 0x48039035, 0x59c80000,
1278 0x82000540, 0x00001200, 0x48039000, 0x1c01f000,
1279 0x4803c856, 0x497b88a9, 0x4a038807, 0x00000001,
1280 0x497b8807, 0x59c40005, 0x48038805, 0x0201f800,
1281 0x00101815, 0x4201d000, 0x000001f4, 0x0201f800,
1282 0x0010608e, 0x497b880e, 0x4200b000, 0x000001f4,
1283 0x42000000, 0x00000001, 0x42000800, 0x00000014,
1284 0x0201f800, 0x00101944, 0x42000800, 0x00000014,
1285 0x0201f800, 0x0010193f, 0x8c040d00, 0x04000005,
1286 0x8058b040, 0x040207f3, 0x0201f800, 0x001005d8,
1287 0x4200b000, 0x00000032, 0x42000000, 0x00000001,
1288 0x42000800, 0x000000b4, 0x0201f800, 0x00101944,
1289 0x42000800, 0x000000b4, 0x0201f800, 0x0010193f,
1290 0x8c040d00, 0x04000005, 0x8058b040, 0x040207f3,
1291 0x0201f800, 0x001005d8, 0x59c40005, 0x48038805,
1292 0x42000000, 0x00000089, 0x800008d0, 0x48075054,
1293 0x48075055, 0x48075056, 0x42000800, 0x000000e0,
1294 0x0201f800, 0x00101944, 0x42000800, 0x000000f4,
1295 0x0201f800, 0x0010193f, 0x82040500, 0xffffffd1,
1296 0x82000540, 0x00000002, 0x42000800, 0x000000f4,
1297 0x0201f800, 0x00101944, 0x42000800, 0x000000a0,
1298 0x0201f800, 0x0010193f, 0x82040540, 0x00000001,
1299 0x42000800, 0x000000a0, 0x0201f800, 0x00101944,
1300 0x42000800, 0x00000000, 0x0201f800, 0x0010193f,
1301 0x82040540, 0x00000001, 0x42000800, 0x00000000,
1302 0x0201f800, 0x00101944, 0x4201d000, 0x0001d4c0,
1303 0x0201f800, 0x0010608e, 0x0401fa2b, 0x4a0388a7,
1304 0x0000f7f7, 0x4a0388a3, 0x8000403c, 0x4a0388ae,
1305 0x000061a8, 0x4a038801, 0x00032063, 0x4a038810,
1306 0x00410108, 0x4a038811, 0x00520608, 0x4a038812,
1307 0x00450320, 0x4a038813, 0x00440405, 0x4a03881c,
1308 0x004132e1, 0x4a038850, 0x80000108, 0x4a038860,
1309 0x00000008, 0x4a038870, 0x00000008, 0x4a038851,
1310 0x80000508, 0x4a038861, 0x00800000, 0x4a038871,
1311 0x00800000, 0x4a038852, 0x80000708, 0x4a038862,
1312 0x00800000, 0x4a038872, 0x00800000, 0x4a038853,
1313 0x80000608, 0x497b8863, 0x4a038873, 0x00800000,
1314 0x4a038882, 0x00000840, 0x4a0388a5, 0x0000001e,
1315 0x4a0388a6, 0x0000001e, 0x4a0388b0, 0x00007530,
1316 0x4a038802, 0x0000ffff, 0x4a038806, 0xc0e00800,
1317 0x1c01f000, 0x497b5022, 0x4a035021, 0x00000001,
1318 0x42000800, 0x00000040, 0x0201f800, 0x0010193f,
1319 0x82040500, 0xffffffaf, 0x82000540, 0x00000000,
1320 0x42000800, 0x00000040, 0x0201f800, 0x00101944,
1321 0x42000800, 0x000000f4, 0x0201f800, 0x0010193f,
1322 0x4c040000, 0x40040000, 0x84000548, 0x42000800,
1323 0x000000f4, 0x0201f800, 0x00101944, 0x42000800,
1324 0x00000000, 0x0201f800, 0x0010193f, 0x82040500,
1325 0xffffffc1, 0x82000540, 0x00000038, 0x42000800,
1326 0x00000000, 0x0201f800, 0x00101944, 0x5c000000,
1327 0x42000800, 0x000000f4, 0x0201f000, 0x00101944,
1328 0x59c40805, 0x4807c857, 0x59c40006, 0x80040d00,
1329 0x02000800, 0x001005d8, 0x82040500, 0x00e00800,
1330 0x04020004, 0x8c040d3e, 0x040208c4, 0x0401f007,
1331 0x82040500, 0x00800800, 0x02020800, 0x001005d0,
1332 0x0201f800, 0x001005d8, 0x4c5c0000, 0x4c600000,
1333 0x59c4b805, 0x485fc857, 0x59c40006, 0x8c000500,
1334 0x04000003, 0x8c5cbd00, 0x04020079, 0x0201f800,
1335 0x0010513b, 0x04000014, 0x59c40005, 0x82000500,
1336 0x000000c0, 0x04000036, 0x0201f800, 0x00105151,
1337 0x04020033, 0x4a038805, 0x04000000, 0x59c400a3,
1338 0x82000500, 0xbf203fff, 0x480388a3, 0x497b5049,
1339 0x4a038805, 0x000000c0, 0x0201f800, 0x00105065,
1340 0x0401f063, 0x8c5cbd34, 0x04020025, 0x59c40005,
1341 0x8c00050c, 0x04020012, 0x8c00050e, 0x04020013,
1342 0x8c00050a, 0x04020014, 0x8c000508, 0x0400000b,
1343 0x59a80017, 0x82000580, 0x00000009, 0x04020007,
1344 0x42000000, 0x0010b844, 0x0201f800, 0x0010aa47,
1345 0x0201f800, 0x00105318, 0x0401f04b, 0x4a035033,
1346 0x00000000, 0x0401f00b, 0x4a035033, 0x00000002,
1347 0x0401f008, 0x42000000, 0x0010b846, 0x0201f800,
1348 0x0010aa47, 0x0201f800, 0x001052c2, 0x0401f03e,
1349 0x0201f800, 0x00105378, 0x0401f03b, 0x8c5cbd34,
1350 0x04000037, 0x59c40005, 0x8c00053a, 0x04020005,
1351 0x42000000, 0x0010b818, 0x0201f800, 0x0010aa47,
1352 0x4a038805, 0x02000000, 0x0201f800, 0x0010513b,
1353 0x04020010, 0x4a038805, 0x04000000, 0x0201f800,
1354 0x00105149, 0x04020008, 0x4a035033, 0x00000001,
1355 0x4202d800, 0x00000001, 0x0201f800, 0x001050a2,
1356 0x0401f05b, 0x41780000, 0x0201f800, 0x00105113,
1357 0x0201f800, 0x001019fe, 0x4000c000, 0x0201f800,
1358 0x00101963, 0x836c1580, 0x00000004, 0x0402000d,
1359 0x8c5cbd00, 0x04020012, 0x59a81005, 0x8c081506,
1360 0x04020005, 0x59c410a3, 0x82081540, 0x00000008,
1361 0x480b88a3, 0x59c41006, 0x84081540, 0x480b8806,
1362 0x4a038805, 0x04000000, 0x4202d800, 0x00000001,
1363 0x497b5014, 0x0201f800, 0x00103b38, 0x8c5cbd3c,
1364 0x04020858, 0x8c5cbd00, 0x04000036, 0x42000000,
1365 0x0010b8ca, 0x0201f800, 0x0010aa47, 0x4a038805,
1366 0x00000001, 0x4200b000, 0x000003e8, 0x4201d000,
1367 0x00000064, 0x4c580000, 0x0201f800, 0x0010608e,
1368 0x0201f800, 0x001018d3, 0x5c00b000, 0x04000004,
1369 0x8058b040, 0x040207f6, 0x0401f004, 0x4a038805,
1370 0x00000001, 0x0401f01f, 0x59c40006, 0x84000500,
1371 0x48038806, 0x0201f800, 0x00106ede, 0x497b8880,
1372 0x0201f800, 0x0010a9c0, 0x59c4000d, 0x8c000500,
1373 0x02020800, 0x0010a9ce, 0x59c400a3, 0x82000500,
1374 0xfcf8ffff, 0x480388a3, 0x4a03504c, 0x00000002,
1375 0x4202d800, 0x00000004, 0x4a038805, 0x00000001,
1376 0x0201f800, 0x001006d4, 0x0401fb3b, 0x497b5052,
1377 0x4a035049, 0x00000001, 0x0201f800, 0x00100452,
1378 0x825cbd00, 0xbbfffffe, 0x485f8805, 0x5c00c000,
1379 0x5c00b800, 0x1c01f000, 0x59c41004, 0x480bc857,
1380 0x8c081500, 0x04000006, 0x4803c856, 0x497b2807,
1381 0x0201f800, 0x00106fa4, 0x0401f00a, 0x82080500,
1382 0x000001f0, 0x04000007, 0x4803c856, 0x417a3000,
1383 0x0201f800, 0x00106062, 0x0201f800, 0x00106fc6,
1384 0x4a038805, 0x80000000, 0x1c01f000, 0x59c408a3,
1385 0x4807c857, 0x84040d40, 0x480788a3, 0x1c01f000,
1386 0x4d900000, 0x4dd00000, 0x4da40000, 0x4d140000,
1387 0x4a038805, 0x40000000, 0x42000000, 0x0010b8c6,
1388 0x0201f800, 0x0010aa47, 0x0201f800, 0x00106c55,
1389 0x59c41004, 0x8c081500, 0x04000054, 0x598e600d,
1390 0x497b2807, 0x813261c0, 0x04000032, 0x59300403,
1391 0x82000580, 0x00000032, 0x0402002e, 0x5930001c,
1392 0x48038833, 0x4a038807, 0x00018000, 0x4201d000,
1393 0x00000002, 0x0201f800, 0x0010608e, 0x497b8807,
1394 0x4201d000, 0x00000002, 0x0201f800, 0x0010608e,
1395 0x0201f800, 0x00106e21, 0x4201d000, 0x00007530,
1396 0x0201f800, 0x0010608e, 0x59c408a4, 0x82040d00,
1397 0x0000000f, 0x82040d80, 0x00000000, 0x04000005,
1398 0x42000000, 0x00200000, 0x0201f800, 0x00101949,
1399 0x0201f800, 0x00106bbf, 0x59300008, 0x80000540,
1400 0x02000800, 0x001005d8, 0x40025800, 0x4a025a04,
1401 0x00000103, 0x5931d821, 0x58ef400b, 0x58ec0009,
1402 0x0801f800, 0x0201f800, 0x0002077d, 0x0401f047,
1403 0x598c000f, 0x82001c80, 0x000000c8, 0x0402100f,
1404 0x80000000, 0x4803180f, 0x59c400a4, 0x82000500,
1405 0x0000000f, 0x82000580, 0x00000002, 0x04020004,
1406 0x42000000, 0x00200000, 0x0401fbf7, 0x0201f800,
1407 0x0010604d, 0x0401f035, 0x4933c857, 0x0201f800,
1408 0x00106e21, 0x813261c0, 0x04000030, 0x4a026203,
1409 0x00000001, 0x42027000, 0x00000027, 0x0201f800,
1410 0x000207a1, 0x0401f029, 0x8c081508, 0x04000027,
1411 0x417a3000, 0x0201f800, 0x001070d8, 0x42032000,
1412 0x0000bf32, 0x0201f800, 0x00106062, 0x59926004,
1413 0x813261c0, 0x04000012, 0x42001800, 0x000000c8,
1414 0x0201f800, 0x001070a4, 0x0402000d, 0x59c400a4,
1415 0x82000500, 0x0000000f, 0x82000580, 0x00000002,
1416 0x04020004, 0x42000000, 0x00200000, 0x0401fbce,
1417 0x0201f800, 0x00106052, 0x0401f00c, 0x4933c857,
1418 0x0201f800, 0x00106dc3, 0x813261c0, 0x04000007,
1419 0x42027000, 0x0000004f, 0x4a026203, 0x00000003,
1420 0x0201f800, 0x000207a1, 0x5c022800, 0x5c034800,
1421 0x5c03a000, 0x5c032000, 0x0201f000, 0x00106c4b,
1422 0x4803c857, 0x59a80821, 0x48035021, 0x80041580,
1423 0x04000045, 0x800409c0, 0x04000023, 0x497b504c,
1424 0x42000000, 0x0010b80d, 0x0201f800, 0x0010aa47,
1425 0x0201f800, 0x0010aaf9, 0x42001000, 0x00008011,
1426 0x59c40001, 0x82000500, 0x00018000, 0x82001d80,
1427 0x00000000, 0x04000009, 0x82001d80, 0x00008000,
1428 0x04000009, 0x82001d80, 0x00010000, 0x04000009,
1429 0x0201f800, 0x001005d8, 0x42001800, 0x00000000,
1430 0x0401f006, 0x42001800, 0x00000001, 0x0401f003,
1431 0x42001800, 0x00000003, 0x0201f800, 0x00103a3e,
1432 0x0401f021, 0x59a8084c, 0x800409c0, 0x04020007,
1433 0x59c4000d, 0x8c000520, 0x04000004, 0x42001800,
1434 0x00000003, 0x0401f002, 0x40041800, 0x0201f800,
1435 0x0010aadd, 0x42001000, 0x00008012, 0x0201f800,
1436 0x00103a3e, 0x0201f800, 0x001006d4, 0x0201f800,
1437 0x0010ab33, 0x0402000c, 0x0401f853, 0x4d400000,
1438 0x4d3c0000, 0x42028000, 0x00000028, 0x42027800,
1439 0x00000408, 0x0201f800, 0x00101fe5, 0x5c027800,
1440 0x5c028000, 0x1c01f000, 0x4803c857, 0x82000400,
1441 0x0010210e, 0x50000800, 0x82040d00, 0x000000ff,
1442 0x1c01f000, 0x4803c856, 0x4c580000, 0x4200b000,
1443 0x00000010, 0x497b88ac, 0x497b88ad, 0x8058b040,
1444 0x040207fe, 0x5c00b000, 0x1c01f000, 0x4807c857,
1445 0x48075010, 0x80041108, 0x4200b000, 0x00000010,
1446 0x497b88ac, 0x80000580, 0x800811c0, 0x04020006,
1447 0x82040500, 0x0000000f, 0x82000400, 0x0010ab38,
1448 0x50000000, 0x480388ad, 0x80081040, 0x8058b040,
1449 0x040207f5, 0x1c01f000, 0x59a80005, 0x04000003,
1450 0x84000546, 0x0401f002, 0x84000506, 0x48035005,
1451 0x4803c857, 0x1c01f000, 0x4803c857, 0x4c080000,
1452 0x4c040000, 0x4c000000, 0x59c40892, 0x4807c857,
1453 0x80041580, 0x04000010, 0x80041480, 0x04021007,
1454 0x80081080, 0x80081000, 0x4008b000, 0x42000000,
1455 0x00000201, 0x0401f004, 0x4008b000, 0x42000000,
1456 0x00000210, 0x48038886, 0x8058b040, 0x040207fe,
1457 0x497b8886, 0x5c000000, 0x5c000800, 0x5c001000,
1458 0x1c01f000, 0x4803c856, 0x0201f800, 0x00103b25,
1459 0x04000005, 0x42028000, 0x0000002e, 0x0201f000,
1460 0x0010a449, 0x1c01f000, 0x42000800, 0x00000002,
1461 0x59a80005, 0x8c000514, 0x0402000b, 0x59c80835,
1462 0x82040d00, 0x00001f00, 0x80040910, 0x80040800,
1463 0x59a8006c, 0x80000540, 0x04000003, 0x42000800,
1464 0x0000025a, 0x4807c857, 0x1c01f000, 0x4c000000,
1465 0x59a80053, 0x4803c857, 0x82000580, 0x00000000,
1466 0x5c000000, 0x1c01f000, 0x4c000000, 0x59a80053,
1467 0x4803c857, 0x82000580, 0x00000001, 0x5c000000,
1468 0x1c01f000, 0x4c000000, 0x59a80053, 0x4803c857,
1469 0x82000580, 0x00000003, 0x5c000000, 0x1c01f000,
1470 0x4c000000, 0x59a80053, 0x82000580, 0x00000002,
1471 0x5c000000, 0x1c01f000, 0x4c000000, 0x4c040000,
1472 0x4c080000, 0x4c380000, 0x59a80040, 0x82000c80,
1473 0x00000007, 0x02021800, 0x001005d8, 0x0c01f806,
1474 0x5c007000, 0x5c001000, 0x5c000800, 0x5c000000,
1475 0x1c01f000, 0x0010166c, 0x0010167f, 0x00101693,
1476 0x00101695, 0x001016bc, 0x001016be, 0x001016c0,
1477 0x4803c856, 0x4a035042, 0x00000000, 0x42000000,
1478 0x00000002, 0x0401fa1b, 0x42000000, 0x00000002,
1479 0x0401f9ad, 0x0401fab2, 0x4803c856, 0x4a035040,
1480 0x00000006, 0x42000800, 0x0000001e, 0x42001000,
1481 0x001016c1, 0x0201f000, 0x0010606e, 0x497b5045,
1482 0x4a035050, 0x00000036, 0x4a03504f, 0x0000002a,
1483 0x4803c856, 0x4a035042, 0x00000001, 0x42000000,
1484 0x00000002, 0x0401f998, 0x4803c856, 0x4a035040,
1485 0x00000006, 0x42000800, 0x0000001e, 0x42001000,
1486 0x001016c1, 0x0201f000, 0x0010606e, 0x0201f800,
1487 0x001005d8, 0x4a035050, 0x00000036, 0x4803c856,
1488 0x4a035042, 0x00000003, 0x42000800, 0x00000000,
1489 0x0401faa3, 0x82040d00, 0x00000090, 0x82040580,
1490 0x00000090, 0x04000009, 0x82040580, 0x00000010,
1491 0x04000009, 0x82040580, 0x00000000, 0x04000008,
1492 0x0201f800, 0x001005d8, 0x42000000, 0x00000001,
1493 0x0401f005, 0x41780000, 0x0401f003, 0x42000000,
1494 0x00000002, 0x0401f970, 0x497b5046, 0x4803c856,
1495 0x4a035040, 0x00000006, 0x42000800, 0x0000001e,
1496 0x42001000, 0x001016c1, 0x0201f000, 0x0010606e,
1497 0x0201f800, 0x001005d8, 0x0201f800, 0x001005d8,
1498 0x1c01f000, 0x4c000000, 0x4c040000, 0x4c080000,
1499 0x4c380000, 0x59a80042, 0x82000c80, 0x00000007,
1500 0x02021800, 0x001005d8, 0x0c01f806, 0x5c007000,
1501 0x5c001000, 0x5c000800, 0x5c000000, 0x1c01f000,
1502 0x001016d7, 0x001016f6, 0x0010174a, 0x00101761,
1503 0x00101778, 0x00101781, 0x00101783, 0x0401f9fc,
1504 0x0402001b, 0x59a81048, 0x42000800, 0x00000000,
1505 0x0401fa63, 0x82040d00, 0x00000090, 0x82040580,
1506 0x00000090, 0x04000009, 0x82040580, 0x00000010,
1507 0x04000008, 0x82040580, 0x00000000, 0x04000007,
1508 0x0201f800, 0x001005d8, 0x84081540, 0x0401f004,
1509 0x84081542, 0x0401f002, 0x84081544, 0x480b5048,
1510 0x4a035040, 0x00000001, 0x0401f003, 0x0401f8cb,
1511 0x0401ff82, 0x1c01f000, 0x0401f88f, 0x04000052,
1512 0x0401f9db, 0x0402002a, 0x42000800, 0x00000000,
1513 0x0401fa43, 0x82040d00, 0x00000090, 0x82040580,
1514 0x00000000, 0x04000044, 0x82040580, 0x00000010,
1515 0x04000006, 0x82040580, 0x00000090, 0x04000009,
1516 0x0201f800, 0x001005d8, 0x59c40801, 0x82040d00,
1517 0x00018000, 0x82040580, 0x00000000, 0x04000036,
1518 0x42000800, 0x00000000, 0x0401fa2d, 0x82040d00,
1519 0x00000090, 0x82040580, 0x00000010, 0x04000006,
1520 0x82040580, 0x00000090, 0x04000006, 0x02020800,
1521 0x001005d8, 0x59a80048, 0x84000542, 0x0401f003,
1522 0x59a80048, 0x84000540, 0x48035048, 0x59a80045,
1523 0x80000000, 0x48035045, 0x82000580, 0x00000005,
1524 0x04000003, 0x0401f861, 0x0401f01e, 0x497b5045,
1525 0x59c40801, 0x82040d00, 0x00018000, 0x82040580,
1526 0x00000000, 0x04000009, 0x82040580, 0x00008000,
1527 0x04000009, 0x82040580, 0x00010000, 0x04000008,
1528 0x0201f800, 0x001005d8, 0x42000000, 0x00000001,
1529 0x0401f005, 0x41780000, 0x0401f003, 0x42000000,
1530 0x00000002, 0x0401f94b, 0x4a035042, 0x00000002,
1531 0x0401f004, 0x4a035040, 0x00000003, 0x0401f002,
1532 0x0401ff42, 0x1c01f000, 0x0401f83b, 0x04000015,
1533 0x59a8004f, 0x80000040, 0x4803504f, 0x0401f984,
1534 0x04020005, 0x4a035040, 0x00000003, 0x497b5041,
1535 0x0401f00c, 0x59a8004f, 0x80000540, 0x04020003,
1536 0x0401f89e, 0x0401f002, 0x0401f84b, 0x0401f82f,
1537 0x497b5045, 0x4a035042, 0x00000001, 0x0401ff2b,
1538 0x1c01f000, 0x0401f824, 0x04000015, 0x0401f970,
1539 0x0402000f, 0x59a80046, 0x80000000, 0x48035046,
1540 0x82000580, 0x00000007, 0x0402000c, 0x4a035052,
1541 0x0000000a, 0x497b5049, 0x59a80048, 0x8400055e,
1542 0x48035048, 0x4803c857, 0x0401f005, 0x0401f817,
1543 0x4a035042, 0x00000004, 0x0401ff3d, 0x1c01f000,
1544 0x0401f80d, 0x04000007, 0x0401f959, 0x04020003,
1545 0x0401ff1b, 0x0401f003, 0x0401f80c, 0x0401ff34,
1546 0x1c01f000, 0x0201f800, 0x001005d8, 0x0201f800,
1547 0x001005d8, 0x59a80050, 0x80000040, 0x48035050,
1548 0x0400088d, 0x1c01f000, 0x4c040000, 0x42000800,
1549 0x00000000, 0x0401f9b2, 0x82040d00, 0x00000090,
1550 0x82040580, 0x00000090, 0x04000009, 0x82040580,
1551 0x00000010, 0x04000009, 0x82040580, 0x00000000,
1552 0x04000009, 0x0201f800, 0x001005d8, 0x42000000,
1553 0x00000002, 0x0401f005, 0x42000000, 0x00000001,
1554 0x0401f002, 0x41780000, 0x0401f8ea, 0x5c000800,
1555 0x1c01f000, 0x4c040000, 0x59c40801, 0x82040d00,
1556 0x00018000, 0x82040580, 0x00000000, 0x04000009,
1557 0x82040580, 0x00008000, 0x04000009, 0x82040580,
1558 0x00010000, 0x04000009, 0x0201f800, 0x001005d8,
1559 0x42000000, 0x00000002, 0x0401f005, 0x42000000,
1560 0x00000001, 0x0401f002, 0x41780000, 0x0401f866,
1561 0x5c000800, 0x1c01f000, 0x4c040000, 0x59a80045,
1562 0x80000000, 0x48035045, 0x82000580, 0x00000005,
1563 0x04020018, 0x497b5045, 0x59c40801, 0x82040d00,
1564 0x00018000, 0x82040580, 0x00000000, 0x04000009,
1565 0x82040580, 0x00008000, 0x04000009, 0x82040580,
1566 0x00010000, 0x04000009, 0x0201f800, 0x001005d8,
1567 0x42000000, 0x00000002, 0x0401f005, 0x42000000,
1568 0x00000001, 0x0401f002, 0x41780000, 0x0401f846,
1569 0x42000800, 0x00000000, 0x0401f961, 0x82040d00,
1570 0x00000090, 0x82040580, 0x00000090, 0x04000009,
1571 0x82040580, 0x00000010, 0x04000009, 0x82040580,
1572 0x00000000, 0x04000009, 0x0201f800, 0x001005d8,
1573 0x42000000, 0x00000002, 0x0401f005, 0x42000000,
1574 0x00000001, 0x0401f002, 0x41780000, 0x0401f899,
1575 0x5c000800, 0x1c01f000, 0x4c200000, 0x59a80048,
1576 0x82000500, 0x00007fff, 0x02000800, 0x001005d8,
1577 0x59a84047, 0x80204102, 0x02001800, 0x001005d8,
1578 0x48235047, 0x80204500, 0x040007fa, 0x8c000504,
1579 0x04020007, 0x8c000502, 0x04020008, 0x8c000500,
1580 0x04020008, 0x0201f800, 0x001005d8, 0x42000000,
1581 0x00000002, 0x0401f005, 0x41780000, 0x0401f003,
1582 0x42000000, 0x00000001, 0x0401f80f, 0x5c004000,
1583 0x1c01f000, 0x04011000, 0x4a03c840, 0x0010b440,
1584 0x4a03c842, 0x00000009, 0x40000000, 0x040117ff,
1585 0x4a035047, 0x00000004, 0x4a03503e, 0x00000000,
1586 0x1c01f000, 0x59a80858, 0x82040d80, 0x01391077,
1587 0x04020008, 0x59e00813, 0x8c040d00, 0x04000005,
1588 0x82000d80, 0x00000002, 0x04020002, 0x41780000,
1589 0x4c000000, 0x0401f9b1, 0x5c000000, 0x800001c0,
1590 0x04000040, 0x82000d80, 0x00000001, 0x0402001d,
1591 0x42000800, 0x000000a0, 0x0401f909, 0x82040540,
1592 0x00000004, 0x42000800, 0x000000a0, 0x0401f909,
1593 0x42000800, 0x000000c0, 0x0401f901, 0x82040540,
1594 0x00000020, 0x42000800, 0x000000c0, 0x0401f901,
1595 0x59c40001, 0x82000500, 0xfffe7fff, 0x82000540,
1596 0x00000000, 0x48038801, 0x59a80054, 0x80000110,
1597 0x42000800, 0x000000e0, 0x0401f8f6, 0x0401f03c,
1598 0x82000d80, 0x00000002, 0x02020800, 0x001005d8,
1599 0x42000800, 0x000000a0, 0x0401f8e9, 0x82040500,
1600 0xfffffffb, 0x42000800, 0x000000a0, 0x0401f8e9,
1601 0x42000800, 0x000000c0, 0x0401f8e1, 0x82040500,
1602 0xffffffdf, 0x42000800, 0x000000c0, 0x0401f8e1,
1603 0x59c40001, 0x82000500, 0xfffe7fff, 0x82000540,
1604 0x00010000, 0x48038801, 0x59a80056, 0x80000110,
1605 0x42000800, 0x000000e0, 0x0401f8d6, 0x0401f01c,
1606 0x42000800, 0x000000a0, 0x0401f8cd, 0x82040540,
1607 0x00000004, 0x42000800, 0x000000a0, 0x0401f8cd,
1608 0x42000800, 0x000000c0, 0x0401f8c5, 0x82040500,
1609 0xffffffdf, 0x42000800, 0x000000c0, 0x0401f8c5,
1610 0x59c40001, 0x82000500, 0xfffe7fff, 0x82000540,
1611 0x00008000, 0x48038801, 0x59a80055, 0x80000110,
1612 0x42000800, 0x000000e0, 0x0401f8ba, 0x0401f163,
1613 0x4803c857, 0x59a80858, 0x82040d80, 0x01391077,
1614 0x04020008, 0x59e00813, 0x8c040d00, 0x04000005,
1615 0x82000d80, 0x00000002, 0x04020002, 0x41780000,
1616 0x4c000000, 0x0401f94d, 0x5c000000, 0x800001c0,
1617 0x04000026, 0x82000d80, 0x00000001, 0x04020010,
1618 0x59a8006c, 0x80000540, 0x04000004, 0x42001000,
1619 0x00000000, 0x0401fa0a, 0x42000800, 0x00000000,
1620 0x0401f897, 0x82040540, 0x00000090, 0x42000800,
1621 0x00000000, 0x0401f897, 0x0401f024, 0x82000d80,
1622 0x00000002, 0x02020800, 0x001005d8, 0x59a8006c,
1623 0x80000540, 0x04000004, 0x42001000, 0x00010000,
1624 0x0401f9f7, 0x42000800, 0x00000000, 0x0401f884,
1625 0x82040500, 0xffffff6f, 0x42000800, 0x00000000,
1626 0x0401f884, 0x0401f011, 0x59a8006c, 0x80000540,
1627 0x04000004, 0x42001000, 0x00008000, 0x0401f9e8,
1628 0x42000800, 0x00000000, 0x0401f875, 0x82040500,
1629 0xffffff6f, 0x82000540, 0x00000010, 0x42000800,
1630 0x00000000, 0x0401f873, 0x0401f124, 0x4c580000,
1631 0x4200b000, 0x00000014, 0x8058b040, 0x04000043,
1632 0x59c4000d, 0x8c000520, 0x040207fc, 0x0401f85c,
1633 0x59c4000d, 0x8c000520, 0x040207f8, 0x59c40808,
1634 0x84040d50, 0x48078808, 0x4200b000, 0x000000c8,
1635 0x8058b040, 0x040207ff, 0x4200b000, 0x00000014,
1636 0x8058b040, 0x04000031, 0x59c4000d, 0x8c000520,
1637 0x0402002e, 0x42000800, 0x00001000, 0x50040800,
1638 0x82040c80, 0x24220001, 0x04020003, 0x8c000504,
1639 0x040007f4, 0x0401f842, 0x59c4000d, 0x8c000520,
1640 0x04020022, 0x42000800, 0x00001000, 0x50040800,
1641 0x82040c80, 0x24220001, 0x04020003, 0x8c000504,
1642 0x040007e8, 0x4200b000, 0x0000000a, 0x8058b040,
1643 0x04000003, 0x0401f832, 0x0401f7fd, 0x4200b000,
1644 0x00000064, 0x59c4000d, 0x8c00051e, 0x0400000f,
1645 0x8058b040, 0x040207fc, 0x42000000, 0x00001000,
1646 0x50000000, 0x82000480, 0x24220001, 0x04020004,
1647 0x59c40808, 0x84040d10, 0x48078808, 0x80000580,
1648 0x4803c857, 0x0401f00c, 0x42000000, 0x00001000,
1649 0x50000000, 0x82000480, 0x24220001, 0x04020004,
1650 0x59c40808, 0x84040d10, 0x48078808, 0x82000540,
1651 0x00000001, 0x5c00b000, 0x1c01f000, 0x42000800,
1652 0x000000a0, 0x0401f816, 0x82040500, 0xfffffffe,
1653 0x42000800, 0x000000a0, 0x0401f816, 0x42000800,
1654 0x00000000, 0x0401f80e, 0x82040500, 0xfffffffe,
1655 0x42000800, 0x00000000, 0x0401f00e, 0x40000000,
1656 0x40000000, 0x40000000, 0x40000000, 0x40000000,
1657 0x1c01f000, 0x480b8805, 0x1c01f000, 0x4807880e,
1658 0x59c4080f, 0x82040d00, 0x000000ff, 0x1c01f000,
1659 0x900001c0, 0x80040d40, 0x84040d40, 0x4807880e,
1660 0x1c01f000, 0x82000d80, 0x00200000, 0x04000009,
1661 0x82000d80, 0x02000000, 0x04000006, 0x82000d80,
1662 0x01000000, 0x04000006, 0x59c408a3, 0x0401f006,
1663 0x59c408a3, 0x84040d30, 0x0401f003, 0x59c408a3,
1664 0x84040d32, 0x80040540, 0x480388a3, 0x480788a3,
1665 0x1c01f000, 0x59c400a3, 0x84000556, 0x480388a3,
1666 0x84000516, 0x480388a3, 0x1c01f000, 0x485fc857,
1667 0x4863c857, 0x4c640000, 0x4d3c0000, 0x4d400000,
1668 0x0201f800, 0x00106ede, 0x4863500a, 0x0201f800,
1669 0x0010ab33, 0x0402006c, 0x82600d00, 0x0000ff00,
1670 0x800409c0, 0x0400000c, 0x4200c800, 0x00000001,
1671 0x59a80010, 0x82000500, 0x000000ff, 0x80041110,
1672 0x80081580, 0x04000021, 0x82041580, 0x0000ff00,
1673 0x0400000a, 0x59c410a3, 0x82081500, 0x00008000,
1674 0x04000009, 0x59c410a7, 0x82081500, 0x0000ff00,
1675 0x82081580, 0x0000ff00, 0x4200c800, 0x00000000,
1676 0x04000012, 0x59a80005, 0x8c000502, 0x04020008,
1677 0x8c000500, 0x0402000d, 0x599c1017, 0x8c08151a,
1678 0x0400003e, 0x84000542, 0x48035005, 0x4200c800,
1679 0x00000002, 0x42028000, 0x00000004, 0x42027800,
1680 0x00000008, 0x0401f008, 0x59a80805, 0x84040d40,
1681 0x48075005, 0x42028000, 0x00000004, 0x42027800,
1682 0x00000400, 0x59a80006, 0x8c000502, 0x04020006,
1683 0x59a80805, 0x8c040d0a, 0x04020033, 0x84040d4a,
1684 0x48075005, 0x42000000, 0x0010b812, 0x0201f800,
1685 0x0010aa47, 0x59a8180a, 0x42001000, 0x00008013,
1686 0x0201f800, 0x00103a3e, 0x0201f800, 0x00103b25,
1687 0x04000015, 0x4d400000, 0x82600500, 0x000000ff,
1688 0x42028800, 0x0000ffff, 0x40643000, 0x42028000,
1689 0x0000000e, 0x0201f800, 0x0010a446, 0x42000800,
1690 0x00000001, 0x42001000, 0x00000100, 0x0201f800,
1691 0x0010618b, 0x5c028000, 0x599c0817, 0x8c040d0a,
1692 0x04020011, 0x493fc857, 0x4943c857, 0x0201f800,
1693 0x00101fe5, 0x0401f00c, 0x0201f800, 0x00103b25,
1694 0x04000009, 0x42028000, 0x0000000f, 0x42028800,
1695 0x0000ffff, 0x42003000, 0x00000000, 0x0201f800,
1696 0x0010a449, 0x497b8880, 0x5c028000, 0x5c027800,
1697 0x5c00c800, 0x1c01f000, 0x42000800, 0x000000a0,
1698 0x0401ff5f, 0x82040540, 0x00000002, 0x42000800,
1699 0x000000a0, 0x0401f75f, 0x42000800, 0x00000000,
1700 0x0401ff57, 0x82040540, 0x00000002, 0x42000800,
1701 0x00000000, 0x0401f757, 0x42000800, 0x000000a0,
1702 0x0401ff4f, 0x82040500, 0xfffffffd, 0x42000800,
1703 0x000000a0, 0x0401f74f, 0x42000800, 0x00000000,
1704 0x0401ff47, 0x82040500, 0xfffffffd, 0x42000800,
1705 0x00000000, 0x0401f747, 0x59c408a8, 0x0401ff38,
1706 0x0401ff37, 0x59c400a8, 0x80040d80, 0x040207fb,
1707 0x1c01f000, 0x4803c856, 0x4a038807, 0x00000001,
1708 0x497b8807, 0x59c40005, 0x48038805, 0x497b506c,
1709 0x497b506d, 0x41785800, 0x42006000, 0x00000001,
1710 0x42006800, 0x00000003, 0x0401f824, 0x0401f82f,
1711 0x40400000, 0x4803c857, 0x82408580, 0x00000000,
1712 0x0402001d, 0x41785800, 0x42006000, 0x0000001e,
1713 0x42006800, 0x00000014, 0x0401f818, 0x0401f823,
1714 0x40400000, 0x4803c857, 0x82408580, 0x00000800,
1715 0x04020011, 0x42005800, 0x00000001, 0x42006000,
1716 0x0000001e, 0x42006800, 0x00000014, 0x0401f80b,
1717 0x0401f816, 0x40400000, 0x4803c857, 0x82408580,
1718 0x0000ffff, 0x04020004, 0x4a03506c, 0x00000001,
1719 0x4803c856, 0x1c01f000, 0x41785000, 0x0401f812,
1720 0x0401f838, 0x40347000, 0x40340800, 0x0401f03d,
1721 0x42005000, 0x00000001, 0x0401f80b, 0x0401f831,
1722 0x40340800, 0x0401f037, 0x42005000, 0x00000002,
1723 0x0401f805, 0x0401f81d, 0x0401f835, 0x40048000,
1724 0x1c01f000, 0x0401f808, 0x0401f814, 0x40280800,
1725 0x0401f826, 0x402c0800, 0x0401f827, 0x40300800,
1726 0x0401f025, 0x42000800, 0x0000ffff, 0x42001000,
1727 0x00000001, 0x0401f829, 0x42001000, 0x00000010,
1728 0x0401f826, 0x42000800, 0x0000ffff, 0x42001000,
1729 0x00000010, 0x0401f021, 0x41780800, 0x42001000,
1730 0x00000002, 0x0401f01d, 0x0401f92e, 0x4a03d000,
1731 0x00050004, 0x0401f92b, 0x4a03d000, 0x00050005,
1732 0x0401f928, 0x4a03d000, 0x00050004, 0x42000800,
1733 0x00000001, 0x42001000, 0x00000001, 0x0401f00f,
1734 0x42000800, 0x00000002, 0x42001000, 0x00000002,
1735 0x0401f00a, 0x42001000, 0x00000005, 0x0401f007,
1736 0x42001000, 0x00000010, 0x0401f004, 0x42001000,
1737 0x00000010, 0x0401f01b, 0x0401f912, 0x82082c00,
1738 0x0010ab38, 0x50142800, 0x82081500, 0xffffffff,
1739 0x04000013, 0x0401f90b, 0x80081040, 0x80142902,
1740 0x40040000, 0x80140500, 0x04000007, 0x4a03d000,
1741 0x00070006, 0x0401f903, 0x4a03d000, 0x00070007,
1742 0x0401f006, 0x4a03d000, 0x00070004, 0x0401f8fd,
1743 0x4a03d000, 0x00070005, 0x0401f7ec, 0x1c01f000,
1744 0x41780800, 0x82082c00, 0x0010ab38, 0x50142800,
1745 0x82081500, 0xffffffff, 0x04000010, 0x0401f8f1,
1746 0x4a03d000, 0x00050001, 0x0401f8ee, 0x59e81800,
1747 0x80081040, 0x80142902, 0x8c0c1d06, 0x04000004,
1748 0x40140000, 0x80040d40, 0x0401f8e6, 0x4a03d000,
1749 0x00070000, 0x0401f7ef, 0x1c01f000, 0x480bc857,
1750 0x480b506d, 0x59c40001, 0x82000500, 0xffffefff,
1751 0x48038801, 0x41781800, 0x0401f8c4, 0x41785800,
1752 0x42006000, 0x0000001e, 0x42006800, 0x00000004,
1753 0x0401ff7a, 0x42006800, 0x0000003c, 0x0401ff7d,
1754 0x41785800, 0x42006000, 0x0000001e, 0x42006800,
1755 0x00000004, 0x0401ff71, 0x41786800, 0x0401ff75,
1756 0x41785800, 0x42006000, 0x0000001e, 0x41786800,
1757 0x0401ff6a, 0x42006800, 0x00000002, 0x0401ff6d,
1758 0x42006800, 0x00000001, 0x0401ff64, 0x42006800,
1759 0x000000f5, 0x0401ff67, 0x41785800, 0x42006000,
1760 0x0000001e, 0x42006800, 0x00000004, 0x0401ff5b,
1761 0x42006800, 0x00000020, 0x0401ff5e, 0x59a8106d,
1762 0x0401f865, 0x42001800, 0x000200f5, 0x0401f897,
1763 0x59a8106d, 0x0401f879, 0x41785800, 0x42006000,
1764 0x0000001e, 0x42006800, 0x00000004, 0x0401ff4b,
1765 0x41786800, 0x0401ff4f, 0x59c40001, 0x82000540,
1766 0x00001000, 0x48038801, 0x41785800, 0x42006000,
1767 0x0000001e, 0x42006800, 0x00000015, 0x0401ff3f,
1768 0x0401ff4a, 0x40400000, 0x82000540, 0x00000002,
1769 0x4c000000, 0x41785800, 0x42006000, 0x0000001e,
1770 0x42006800, 0x00000015, 0x0401ff34, 0x5c000000,
1771 0x40006800, 0x0401ff37, 0x41785800, 0x42006000,
1772 0x0000001e, 0x42006800, 0x00000015, 0x0401ff2b,
1773 0x0401ff36, 0x40400000, 0x82000500, 0x0000fffd,
1774 0x4c000000, 0x41785800, 0x42006000, 0x0000001e,
1775 0x42006800, 0x00000015, 0x0401ff20, 0x5c000000,
1776 0x40006800, 0x0401ff23, 0x41785800, 0x42006000,
1777 0x0000001e, 0x42006800, 0x00000014, 0x0401ff17,
1778 0x0401ff22, 0x40400000, 0x82000540, 0x00000040,
1779 0x4c000000, 0x41785800, 0x42006000, 0x0000001e,
1780 0x42006800, 0x00000014, 0x0401ff0c, 0x5c000000,
1781 0x40006800, 0x0401ff0f, 0x41785800, 0x42006000,
1782 0x0000001e, 0x42006800, 0x00000014, 0x0401ff03,
1783 0x0401ff0e, 0x40400000, 0x82000500, 0x0000ffbf,
1784 0x4c000000, 0x41785800, 0x42006000, 0x0000001e,
1785 0x42006800, 0x00000014, 0x0401fef8, 0x5c000000,
1786 0x40006800, 0x0401fefb, 0x4a038886, 0x00002020,
1787 0x0401f04c, 0x480bc857, 0x82080580, 0x00010000,
1788 0x04020007, 0x82040d40, 0x00010000, 0x42001800,
1789 0x00000001, 0x0401f82d, 0x0401f00f, 0x82080580,
1790 0x00008000, 0x04000007, 0x82040d40, 0x00000000,
1791 0x42001800, 0x00900001, 0x0401f824, 0x0401f006,
1792 0x82040d40, 0x00008000, 0x42001800, 0x00100001,
1793 0x0401f81e, 0x1c01f000, 0x480bc857, 0x82080580,
1794 0x00010000, 0x04020008, 0x42001800, 0x000000a1,
1795 0x0401f816, 0x42001800, 0x000000c1, 0x0401f813,
1796 0x0401f011, 0x82080580, 0x00008000, 0x04000008,
1797 0x42001800, 0x000400a1, 0x0401f80c, 0x42001800,
1798 0x002000c1, 0x0401f809, 0x0401f007, 0x42001800,
1799 0x000400a1, 0x0401f805, 0x42001800, 0x000000c1,
1800 0x0401f802, 0x1c01f000, 0x480fc857, 0x41785800,
1801 0x42006000, 0x0000001e, 0x41786800, 0x0401feb7,
1802 0x400c6800, 0x80346960, 0x0401feba, 0x42006800,
1803 0x00000001, 0x0401feb1, 0x400c6800, 0x0401feb5,
1804 0x42006800, 0x00000003, 0x0401feac, 0x0401feb7,
1805 0x40400000, 0x8c000504, 0x040207fc, 0x1c01f000,
1806 0x42000000, 0x00000064, 0x80000040, 0x040207ff,
1807 0x1c01f000, 0x00020103, 0x00101bd5, 0x00101bdb,
1808 0x00101be1, 0x00101be9, 0x00101bef, 0x00101bf7,
1809 0x00101bff, 0x00101c09, 0x00101c0f, 0x00101c17,
1810 0x00101c1f, 0x00101c29, 0x00101c31, 0x00101c3b,
1811 0x00101c45, 0x000200f8, 0x00101c51, 0x00101c59,
1812 0x00101c61, 0x00101c6b, 0x00101c73, 0x00101c7d,
1813 0x00101c87, 0x00101c93, 0x00101c9b, 0x00101ca5,
1814 0x00101caf, 0x00101cbb, 0x00101cc5, 0x00101cd1,
1815 0x00101cdd, 0x000200fd, 0x00101ceb, 0x00101cf3,
1816 0x00101cfb, 0x00101d05, 0x00101d0d, 0x00101d17,
1817 0x00101d21, 0x00101d2d, 0x00101d35, 0x00101d3f,
1818 0x00101d49, 0x00101d55, 0x00101d5f, 0x00101d6b,
1819 0x00101d77, 0x00101d85, 0x00101d8d, 0x00101d97,
1820 0x00101da1, 0x00101dad, 0x00101db7, 0x00101dc3,
1821 0x00101dcf, 0x00101ddd, 0x00101de7, 0x00101df3,
1822 0x00101dff, 0x00101e0d, 0x00101e19, 0x00101e27,
1823 0x00101e35, 0x4c000000, 0x4df00000, 0x0201f800,
1824 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1825 0x4df00000, 0x0201f800, 0x00101418, 0x0201f000,
1826 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1827 0x00101418, 0x0201f800, 0x00020104, 0x0201f000,
1828 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1829 0x00101155, 0x0201f000, 0x00020101, 0x4c000000,
1830 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1831 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1832 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1833 0x00101418, 0x0201f000, 0x00020101, 0x4c000000,
1834 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1835 0x00101418, 0x0201f800, 0x00020104, 0x0201f000,
1836 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1837 0x00101289, 0x0201f000, 0x00020101, 0x4c000000,
1838 0x4df00000, 0x0201f800, 0x00101289, 0x0201f800,
1839 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1840 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1841 0x00101289, 0x0201f000, 0x00020101, 0x4c000000,
1842 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1843 0x00101289, 0x0201f800, 0x00020104, 0x0201f000,
1844 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1845 0x00101155, 0x0201f800, 0x00101289, 0x0201f000,
1846 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1847 0x00101155, 0x0201f800, 0x00101289, 0x0201f800,
1848 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1849 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1850 0x00101418, 0x0201f800, 0x00101289, 0x0201f000,
1851 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1852 0x00101155, 0x0201f800, 0x00101418, 0x0201f800,
1853 0x00101289, 0x0201f800, 0x00020104, 0x0201f000,
1854 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1855 0x00020729, 0x0201f800, 0x00020104, 0x0201f000,
1856 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1857 0x00101418, 0x0201f800, 0x00020729, 0x0201f000,
1858 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1859 0x00101418, 0x0201f800, 0x00020729, 0x0201f800,
1860 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1861 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1862 0x00020729, 0x0201f000, 0x00020101, 0x4c000000,
1863 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1864 0x00020729, 0x0201f800, 0x00020104, 0x0201f000,
1865 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1866 0x00101155, 0x0201f800, 0x00101418, 0x0201f800,
1867 0x00020729, 0x0201f000, 0x00020101, 0x4c000000,
1868 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1869 0x00101418, 0x0201f800, 0x00020729, 0x0201f800,
1870 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1871 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800,
1872 0x00101289, 0x0201f000, 0x00020101, 0x4c000000,
1873 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800,
1874 0x00101289, 0x0201f800, 0x00020104, 0x0201f000,
1875 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1876 0x00101418, 0x0201f800, 0x00020729, 0x0201f800,
1877 0x00101289, 0x0201f000, 0x00020101, 0x4c000000,
1878 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1879 0x00020729, 0x0201f800, 0x00101289, 0x0201f800,
1880 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1881 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1882 0x00020729, 0x0201f800, 0x00101289, 0x0201f000,
1883 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1884 0x00101155, 0x0201f800, 0x00020729, 0x0201f800,
1885 0x00101289, 0x0201f800, 0x00020104, 0x0201f000,
1886 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1887 0x00101155, 0x0201f800, 0x00101418, 0x0201f800,
1888 0x00020729, 0x0201f800, 0x00101289, 0x0201f000,
1889 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1890 0x00101155, 0x0201f800, 0x00101418, 0x0201f800,
1891 0x00020729, 0x0201f800, 0x00101289, 0x0201f800,
1892 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1893 0x4df00000, 0x0201f800, 0x00020015, 0x0201f800,
1894 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1895 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1896 0x00020015, 0x0201f000, 0x00020101, 0x4c000000,
1897 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1898 0x00020015, 0x0201f800, 0x00020104, 0x0201f000,
1899 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1900 0x00101155, 0x0201f800, 0x00020015, 0x0201f000,
1901 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1902 0x00101155, 0x0201f800, 0x00020015, 0x0201f800,
1903 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1904 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1905 0x00101155, 0x0201f800, 0x00020015, 0x0201f000,
1906 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1907 0x00101418, 0x0201f800, 0x00101155, 0x0201f800,
1908 0x00020015, 0x0201f800, 0x00020104, 0x0201f000,
1909 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1910 0x00020015, 0x0201f800, 0x00101289, 0x0201f000,
1911 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1912 0x00020015, 0x0201f800, 0x00101289, 0x0201f800,
1913 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1914 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1915 0x00020015, 0x0201f800, 0x00101289, 0x0201f000,
1916 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1917 0x00101418, 0x0201f800, 0x00020015, 0x0201f800,
1918 0x00101289, 0x0201f800, 0x00020104, 0x0201f000,
1919 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1920 0x00020015, 0x0201f800, 0x00101289, 0x0201f800,
1921 0x00101155, 0x0201f000, 0x00020101, 0x4c000000,
1922 0x4df00000, 0x0201f800, 0x00020015, 0x0201f800,
1923 0x00101289, 0x0201f800, 0x00101155, 0x0201f800,
1924 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1925 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1926 0x00020015, 0x0201f800, 0x00101289, 0x0201f800,
1927 0x00101155, 0x0201f000, 0x00020101, 0x4c000000,
1928 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1929 0x00020015, 0x0201f800, 0x00101289, 0x0201f800,
1930 0x00101155, 0x0201f800, 0x00020104, 0x0201f000,
1931 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1932 0x00020729, 0x0201f800, 0x00020015, 0x0201f000,
1933 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1934 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1935 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1936 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1937 0x00020729, 0x0201f800, 0x00020015, 0x0201f000,
1938 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1939 0x00101418, 0x0201f800, 0x00020729, 0x0201f800,
1940 0x00020015, 0x0201f800, 0x00020104, 0x0201f000,
1941 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1942 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1943 0x00101155, 0x0201f000, 0x00020101, 0x4c000000,
1944 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800,
1945 0x00020015, 0x0201f800, 0x00101155, 0x0201f800,
1946 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1947 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1948 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1949 0x00101155, 0x0201f000, 0x00020101, 0x4c000000,
1950 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1951 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1952 0x00101155, 0x0201f800, 0x00020104, 0x0201f000,
1953 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1954 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1955 0x00101289, 0x0201f000, 0x00020101, 0x4c000000,
1956 0x4df00000, 0x0201f800, 0x00020729, 0x0201f800,
1957 0x00020015, 0x0201f800, 0x00101289, 0x0201f800,
1958 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1959 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1960 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1961 0x00101289, 0x0201f000, 0x00020101, 0x4c000000,
1962 0x4df00000, 0x0201f800, 0x00101418, 0x0201f800,
1963 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1964 0x00101289, 0x0201f800, 0x00020104, 0x0201f000,
1965 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1966 0x00101155, 0x0201f800, 0x00020729, 0x0201f800,
1967 0x00020015, 0x0201f800, 0x00101289, 0x0201f000,
1968 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1969 0x00101155, 0x0201f800, 0x00020729, 0x0201f800,
1970 0x00020015, 0x0201f800, 0x00101289, 0x0201f800,
1971 0x00020104, 0x0201f000, 0x00020101, 0x4c000000,
1972 0x4df00000, 0x0201f800, 0x00101155, 0x0201f800,
1973 0x00101418, 0x0201f800, 0x00020729, 0x0201f800,
1974 0x00020015, 0x0201f800, 0x00101289, 0x0201f000,
1975 0x00020101, 0x4c000000, 0x4df00000, 0x0201f800,
1976 0x00101155, 0x0201f800, 0x00101418, 0x0201f800,
1977 0x00020729, 0x0201f800, 0x00020015, 0x0201f800,
1978 0x00101289, 0x0201f800, 0x00020104, 0x0201f000,
1979 0x00020101, 0x4c5c0000, 0x4c600000, 0x4178b800,
1980 0x0201f800, 0x001048ec, 0x040200fd, 0x59a8c026,
1981 0x0201f800, 0x0010513b, 0x04000003, 0x8c60c506,
1982 0x0400000e, 0x8c60c500, 0x04020004, 0x8c60c50e,
1983 0x040008f6, 0x0401f0f2, 0x0401fab4, 0x040200f0,
1984 0x0201f800, 0x0010513b, 0x04020004, 0x4a03501c,
1985 0x0000ffff, 0x0401f0ea, 0x8c60c504, 0x04000004,
1986 0x4a03501c, 0x0000ffff, 0x0401f0e5, 0x59a8c010,
1987 0x8260c500, 0x000000ff, 0x59a81013, 0x8c081500,
1988 0x0400005d, 0x8c081502, 0x0402005b, 0x59a8b81c,
1989 0x825c0d80, 0x0000ffff, 0x04020003, 0x4200b800,
1990 0x00000001, 0x805c1104, 0x82086400, 0x0010be21,
1991 0x50300800, 0x825c0500, 0x00000003, 0x0c01f001,
1992 0x00101e81, 0x00101e7c, 0x00101e80, 0x00101e7e,
1993 0x80040910, 0x0401f004, 0x80040930, 0x0401f002,
1994 0x80040920, 0x82040500, 0x000000ff, 0x82000d80,
1995 0x000000ff, 0x0400000f, 0x4c000000, 0x82000400,
1996 0x0010210e, 0x50000800, 0x80040910, 0x82040580,
1997 0x00000080, 0x5c000000, 0x04000030, 0x80600d80,
1998 0x0400002e, 0x80000540, 0x0400002c, 0x0401f00b,
1999 0x59a81005, 0x82081500, 0x00000003, 0x0402002b,
2000 0x59a81013, 0x84081542, 0x480b5013, 0x4a03501c,
2001 0x0000ffff, 0x0401f028, 0x4c000000, 0x59a80005,
2002 0x8c000514, 0x42001000, 0x00000010, 0x02020800,
2003 0x00104c6d, 0x5c000000, 0x0402001c, 0x417a8800,
2004 0x0201f800, 0x00105c9a, 0x04020016, 0x0201f800,
2005 0x001045e5, 0x04000006, 0x0201f800, 0x00104c62,
2006 0x0401f8b1, 0x0400000f, 0x0401f00c, 0x599c0019,
2007 0x8c00050e, 0x04020009, 0x0201f800, 0x001045a6,
2008 0x04020008, 0x0201f800, 0x00104c62, 0x0401f9e1,
2009 0x0401f8be, 0x04000003, 0x805cb800, 0x0401f7b2,
2010 0x485f501c, 0x0401f086, 0x4a03501c, 0x0000ffff,
2011 0x0401f083, 0x42003000, 0x0000007e, 0x59a8001c,
2012 0x82001580, 0x0000ffff, 0x04020005, 0x80000d80,
2013 0x4018b000, 0x4803c856, 0x0401f009, 0x8018b480,
2014 0x04001004, 0x40000800, 0x4803c856, 0x0401f004,
2015 0x4a03501c, 0x0000ffff, 0x0401f071, 0x4c040000,
2016 0x4c580000, 0x82040400, 0x0010210e, 0x50000000,
2017 0x82000500, 0x000000ff, 0x80604580, 0x0400005c,
2018 0x0201f800, 0x00105c9b, 0x04020061, 0x59a80005,
2019 0x8c000514, 0x42001000, 0x00000010, 0x02020800,
2020 0x00104c6d, 0x5c00b000, 0x5c000800, 0x040207d7,
2021 0x4c040000, 0x4c580000, 0x845cbd00, 0x0201f800,
2022 0x00020245, 0x04000008, 0x599c0019, 0x8c00050e,
2023 0x04020047, 0x0201f800, 0x001045ab, 0x0402004c,
2024 0x0401f002, 0x845cbd40, 0x0201f800, 0x00104c62,
2025 0x0201f800, 0x001049e7, 0x04020007, 0x59a80005,
2026 0x8c000502, 0x04000033, 0x59340200, 0x8c00050e,
2027 0x04020030, 0x59a81013, 0x8c081502, 0x04000025,
2028 0x0201f800, 0x00104a09, 0x04000031, 0x8c5cbd00,
2029 0x04020004, 0x0201f800, 0x001045ff, 0x0401f02c,
2030 0x0401f9cd, 0x0400002a, 0x42026000, 0x0010bde9,
2031 0x49366009, 0x497a6008, 0x417a7800, 0x0401f925,
2032 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
2033 0x0201f800, 0x00103b25, 0x0400001d, 0x41782800,
2034 0x42003000, 0x00000008, 0x4d400000, 0x4d440000,
2035 0x59368c03, 0x42028000, 0x00000029, 0x0201f800,
2036 0x0010a446, 0x5c028800, 0x5c028000, 0x0401f010,
2037 0x4937c857, 0x599c0019, 0x8c00050e, 0x0402000c,
2038 0x0401f96c, 0x0401f849, 0x04000011, 0x0401f008,
2039 0x59a80013, 0x8c000500, 0x04000003, 0x0401f9a6,
2040 0x04000003, 0x0401f828, 0x04000009, 0x5c00b000,
2041 0x5c000800, 0x80040800, 0x8058b040, 0x04020798,
2042 0x4a03501c, 0x0000ffff, 0x0401f005, 0x4937c857,
2043 0x5c00b000, 0x5c000800, 0x4807501c, 0x5c00c000,
2044 0x5c00b800, 0x1c01f000, 0x4803c856, 0x4a03501c,
2045 0x00000001, 0x42028800, 0x000007fe, 0x42003000,
2046 0x00fffffe, 0x0201f800, 0x001045a6, 0x0402000c,
2047 0x0401f948, 0x0401f825, 0x04000009, 0x59a80026,
2048 0x8400054e, 0x48035026, 0x0201f800, 0x0010930f,
2049 0x82000540, 0x00000001, 0x1c01f000, 0x80000580,
2050 0x0401f7fe, 0x4937c857, 0x0201f800, 0x00107942,
2051 0x04000015, 0x49366009, 0x4a026406, 0x00000001,
2052 0x417a7800, 0x0201f800, 0x00104567, 0x59a8001b,
2053 0x80000000, 0x4803501b, 0x42027000, 0x00000004,
2054 0x599c0019, 0x8c00050e, 0x04000003, 0x42027000,
2055 0x00000000, 0x0201f800, 0x000207a1, 0x82000540,
2056 0x00000001, 0x1c01f000, 0x4937c857, 0x0201f800,
2057 0x00107942, 0x0400001c, 0x49366009, 0x59340403,
2058 0x82000580, 0x000007fe, 0x04000005, 0x4d3c0000,
2059 0x417a7800, 0x0401f8b7, 0x5c027800, 0x4a026406,
2060 0x00000001, 0x417a7800, 0x0201f800, 0x00104567,
2061 0x42000800, 0x00000003, 0x0201f800, 0x00104571,
2062 0x59a8001b, 0x80000000, 0x4803501b, 0x42027000,
2063 0x00000002, 0x0201f800, 0x000207a1, 0x82000540,
2064 0x00000001, 0x1c01f000, 0x4803c856, 0x42028800,
2065 0x000007fc, 0x42003000, 0x00fffffc, 0x0201f800,
2066 0x001045a6, 0x04020005, 0x0401f805, 0x04000003,
2067 0x4a035027, 0x0000ffff, 0x1c01f000, 0x4937c857,
2068 0x0201f800, 0x00107942, 0x04000014, 0x49366009,
2069 0x4a026406, 0x00000001, 0x417a7800, 0x0201f800,
2070 0x00104567, 0x42000800, 0x00000003, 0x0201f800,
2071 0x00104571, 0x59a80028, 0x80000000, 0x48035028,
2072 0x42027000, 0x00000002, 0x0201f800, 0x000207a1,
2073 0x82000540, 0x00000001, 0x1c01f000, 0x480bc857,
2074 0x492fc857, 0x4c5c0000, 0x4008b800, 0x42028800,
2075 0x000007fd, 0x42003000, 0x00fffffd, 0x0201f800,
2076 0x001045a6, 0x0402001a, 0x0201f800, 0x0002075a,
2077 0x04000017, 0x49366009, 0x5934000a, 0x84000544,
2078 0x4802680a, 0x812e59c0, 0x04000005, 0x592c0404,
2079 0x8c00051e, 0x04000002, 0x48ee6021, 0x492e6008,
2080 0x4a026406, 0x00000001, 0x485e601c, 0x42027000,
2081 0x00000022, 0x0201f800, 0x000207a1, 0x82000540,
2082 0x00000001, 0x5c00b800, 0x1c01f000, 0x80000580,
2083 0x0401f7fd, 0x5c000000, 0x4c000000, 0x4803c857,
2084 0x4943c857, 0x493fc857, 0x4d340000, 0x4d440000,
2085 0x4c580000, 0x4d2c0000, 0x4c5c0000, 0x0201f800,
2086 0x00106c55, 0x4df00000, 0x0201f800, 0x001069f1,
2087 0x0201f800, 0x00106aac, 0x0201f800, 0x00106737,
2088 0x0201f800, 0x0010848a, 0x5c03e000, 0x02000800,
2089 0x00106c4b, 0x4200b000, 0x000007f0, 0x417a8800,
2090 0x0201f800, 0x00020245, 0x0402001f, 0x8d3e7d14,
2091 0x04000005, 0x59340212, 0x82000500, 0x0000ff00,
2092 0x04000019, 0x8d3e7d06, 0x04000004, 0x59340200,
2093 0x8c00050e, 0x04020014, 0x8d3e7d18, 0x0400000f,
2094 0x5934b80f, 0x805cb9c0, 0x04000009, 0x49425a06,
2095 0x592cb800, 0x0201f800, 0x000202ce, 0x805cb9c0,
2096 0x040207fb, 0x497a680f, 0x497a6810, 0x4a026c00,
2097 0x00000707, 0x0401f004, 0x4937c857, 0x0201f800,
2098 0x001042b4, 0x81468800, 0x8058b040, 0x040207dd,
2099 0x8d3e7d02, 0x04000011, 0x497b501d, 0x42028800,
2100 0x000007f0, 0x4200b000, 0x00000010, 0x0201f800,
2101 0x00020245, 0x04020006, 0x4937c857, 0x4a026c00,
2102 0x00000707, 0x0201f800, 0x001042b4, 0x81468800,
2103 0x8058b040, 0x040207f6, 0x5c00b800, 0x5c025800,
2104 0x5c00b000, 0x5c028800, 0x5c026800, 0x1c01f000,
2105 0x5c000000, 0x4c000000, 0x4803c857, 0x4933c857,
2106 0x493fc857, 0x4d340000, 0x4d400000, 0x4d440000,
2107 0x4d2c0000, 0x4c5c0000, 0x0201f800, 0x00106c55,
2108 0x4df00000, 0x59326809, 0x813669c0, 0x04000020,
2109 0x59368c03, 0x42028000, 0x00000029, 0x0201f800,
2110 0x00106a50, 0x0201f800, 0x00106ab4, 0x0201f800,
2111 0x001067fd, 0x0201f800, 0x0010a2ff, 0x4937c857,
2112 0x8d3e7d18, 0x04000010, 0x5934b80f, 0x805cb9c0,
2113 0x0400000a, 0x405e5800, 0x49425a06, 0x592cb800,
2114 0x0201f800, 0x000202ce, 0x805cb9c0, 0x040207fa,
2115 0x497a680f, 0x497a6810, 0x4a026c00, 0x00000707,
2116 0x0401f003, 0x0201f800, 0x001042b4, 0x5c03e000,
2117 0x02000800, 0x00106c4b, 0x5c00b800, 0x5c025800,
2118 0x5c028800, 0x5c028000, 0x5c026800, 0x1c01f000,
2119 0x4933c857, 0x59a80026, 0x8c000508, 0x04020012,
2120 0x59305009, 0x482bc857, 0x836c0580, 0x00000002,
2121 0x0402000d, 0x0401f813, 0x0402000b, 0x58280403,
2122 0x82000580, 0x000007fc, 0x04000008, 0x59a8001b,
2123 0x80000040, 0x4803c857, 0x02001800, 0x001005d8,
2124 0x4803501b, 0x1c01f000, 0x59a80028, 0x80000040,
2125 0x4803c857, 0x040017fc, 0x48035028, 0x1c01f000,
2126 0x59300008, 0x800001c0, 0x04020009, 0x59300403,
2127 0x82000580, 0x00000001, 0x04020004, 0x82000540,
2128 0x00000001, 0x0401f002, 0x80000580, 0x1c01f000,
2129 0x4937c857, 0x59340200, 0x84000502, 0x48026a00,
2130 0x1c01f000, 0x4933c857, 0x493fc857, 0x4947c857,
2131 0x4d3c0000, 0x4d400000, 0x4d340000, 0x4d440000,
2132 0x4c580000, 0x0201f800, 0x00106c55, 0x4df00000,
2133 0x813e79c0, 0x04020004, 0x4200b000, 0x00000001,
2134 0x0401f004, 0x4200b000, 0x000007f0, 0x417a8800,
2135 0x41440000, 0x81ac0400, 0x50000000, 0x80026d40,
2136 0x04000019, 0x42027800, 0x00000001, 0x0201f800,
2137 0x001048f6, 0x42028000, 0x00000029, 0x417a7800,
2138 0x0201f800, 0x00106a50, 0x0201f800, 0x00106ab4,
2139 0x0201f800, 0x001067fd, 0x0201f800, 0x001049e7,
2140 0x04020005, 0x4937c857, 0x4a026c00, 0x00000404,
2141 0x0401f003, 0x0201f800, 0x00104a14, 0x0201f800,
2142 0x0010a2ff, 0x81468800, 0x8058b040, 0x040207e1,
2143 0x5c03e000, 0x02000800, 0x00106c4b, 0x5c00b000,
2144 0x5c028800, 0x5c026800, 0x5c028000, 0x5c027800,
2145 0x1c01f000, 0x4937c857, 0x4947c857, 0x4c5c0000,
2146 0x4c600000, 0x4c640000, 0x59a80013, 0x8c000500,
2147 0x0400001f, 0x599c0017, 0x8c00050a, 0x0402001c,
2148 0x5934ba02, 0x825cbd00, 0x000000ff, 0x485fc857,
2149 0x4178c000, 0x4178c800, 0x82600400, 0x0010be21,
2150 0x50002000, 0x8060c1c0, 0x04000008, 0x82100500,
2151 0x000000ff, 0x82002d80, 0x000000ff, 0x0400000c,
2152 0x805c0580, 0x0400000d, 0x80102110, 0x8064c800,
2153 0x82640580, 0x00000004, 0x040207f5, 0x8060c000,
2154 0x82600580, 0x00000020, 0x040207eb, 0x4813c857,
2155 0x82000540, 0x00000001, 0x5c00c800, 0x5c00c000,
2156 0x5c00b800, 0x1c01f000, 0x59a80026, 0x4803c857,
2157 0x8c000512, 0x1c01f000, 0x00007eef, 0x00007de8,
2158 0x00007ce4, 0x000080e2, 0x00007be1, 0x000080e0,
2159 0x000080dc, 0x000080da, 0x00007ad9, 0x000080d6,
2160 0x000080d5, 0x000080d4, 0x000080d3, 0x000080d2,
2161 0x000080d1, 0x000079ce, 0x000078cd, 0x000080cc,
2162 0x000080cb, 0x000080ca, 0x000080c9, 0x000080c7,
2163 0x000080c6, 0x000077c5, 0x000076c3, 0x000080bc,
2164 0x000080ba, 0x000075b9, 0x000080b6, 0x000074b5,
2165 0x000073b4, 0x000072b3, 0x000080b2, 0x000080b1,
2166 0x000080ae, 0x000071ad, 0x000080ac, 0x000070ab,
2167 0x00006faa, 0x00006ea9, 0x000080a7, 0x00006da6,
2168 0x00006ca5, 0x00006ba3, 0x00006a9f, 0x0000699e,
2169 0x0000689d, 0x0000809b, 0x00008098, 0x00006797,
2170 0x00006690, 0x0000658f, 0x00006488, 0x00006384,
2171 0x00006282, 0x00008081, 0x00008080, 0x0000617c,
2172 0x0000607a, 0x00008079, 0x00005f76, 0x00008075,
2173 0x00008074, 0x00008073, 0x00008072, 0x00008071,
2174 0x0000806e, 0x00005e6d, 0x0000806c, 0x00005d6b,
2175 0x00005c6a, 0x00005b69, 0x00008067, 0x00005a66,
2176 0x00005965, 0x00005863, 0x0000575c, 0x0000565a,
2177 0x00005559, 0x00008056, 0x00008055, 0x00005454,
2178 0x00005353, 0x00005252, 0x00005151, 0x0000504e,
2179 0x00004f4d, 0x0000804c, 0x0000804b, 0x00004e4a,
2180 0x00004d49, 0x00008047, 0x00004c46, 0x00008045,
2181 0x00008043, 0x0000803c, 0x0000803a, 0x00008039,
2182 0x00008036, 0x00004b35, 0x00008034, 0x00004a33,
2183 0x00004932, 0x00004831, 0x0000802e, 0x0000472d,
2184 0x0000462c, 0x0000452b, 0x0000442a, 0x00004329,
2185 0x00004227, 0x00008026, 0x00008025, 0x00004123,
2186 0x0000401f, 0x00003f1e, 0x00003e1d, 0x00003d1b,
2187 0x00003c18, 0x00008017, 0x00008010, 0x00003b0f,
2188 0x00003a08, 0x00008004, 0x00003902, 0x00008001,
2189 0x00008000, 0x00008000, 0x00003800, 0x00003700,
2190 0x00003600, 0x00008000, 0x00003500, 0x00008000,
2191 0x00008000, 0x00008000, 0x00003400, 0x00008000,
2192 0x00008000, 0x00008000, 0x00008000, 0x00008000,
2193 0x00008000, 0x00003300, 0x00003200, 0x00008000,
2194 0x00008000, 0x00008000, 0x00008000, 0x00008000,
2195 0x00008000, 0x00003100, 0x00003000, 0x00008000,
2196 0x00008000, 0x00002f00, 0x00008000, 0x00002e00,
2197 0x00002d00, 0x00002c00, 0x00008000, 0x00008000,
2198 0x00008000, 0x00002b00, 0x00008000, 0x00002a00,
2199 0x00002900, 0x00002800, 0x00008000, 0x00002700,
2200 0x00002600, 0x00002500, 0x00002400, 0x00002300,
2201 0x00002200, 0x00008000, 0x00008000, 0x00002100,
2202 0x00002000, 0x00001f00, 0x00001e00, 0x00001d00,
2203 0x00001c00, 0x00008000, 0x00008000, 0x00001b00,
2204 0x00001a00, 0x00008000, 0x00001900, 0x00008000,
2205 0x00008000, 0x00008000, 0x00008000, 0x00008000,
2206 0x00008000, 0x00001800, 0x00008000, 0x00001700,
2207 0x00001600, 0x00001500, 0x00008000, 0x00001400,
2208 0x00001300, 0x00001200, 0x00001100, 0x00001000,
2209 0x00000f00, 0x00008000, 0x00008000, 0x00000e00,
2210 0x00000d00, 0x00000c00, 0x00000b00, 0x00000a00,
2211 0x00000900, 0x00008000, 0x00008000, 0x00000800,
2212 0x00000700, 0x00008000, 0x00000600, 0x00008000,
2213 0x00008000, 0x00008000, 0x00000500, 0x00000400,
2214 0x00000300, 0x00008000, 0x00000200, 0x00008000,
2215 0x00008000, 0x00008000, 0x00000100, 0x00008000,
2216 0x00008000, 0x00008000, 0x00008000, 0x00008000,
2217 0x00008000, 0x00000000, 0x00008000, 0x00008000,
2218 0x00008000, 0x00008000, 0x00008000, 0x00008000,
2219 0x00008000, 0x00008000, 0x00008000, 0x00008000,
2220 0x00008000, 0x00008000, 0x00008000, 0x00008000,
2221 0x00008000, 0x00008000, 0x0201f800, 0x001007d3,
2222 0x02000800, 0x001005d8, 0x492f4016, 0x1c01f000,
2223 0x83a0ac00, 0x00000006, 0x83a00580, 0x0010b4a4,
2224 0x0400000c, 0x492fc857, 0x812e59c0, 0x02000800,
2225 0x001005d8, 0x832ca400, 0x00000006, 0x4200b000,
2226 0x0000000d, 0x0201f800, 0x0010ab17, 0x0401f00f,
2227 0x4200b000, 0x00000010, 0x83e0a400, 0x00000020,
2228 0x50500000, 0x8050a000, 0x50500800, 0x900409c0,
2229 0x80040540, 0x4400a800, 0x8050a000, 0x8054a800,
2230 0x8058b040, 0x040207f7, 0x1c01f000, 0x59a00206,
2231 0x4803c857, 0x82000c80, 0x0000007f, 0x040210c9,
2232 0x59a80821, 0x0c01f001, 0x001022c0, 0x00102300,
2233 0x00102300, 0x0010234b, 0x0010236d, 0x00102300,
2234 0x001022c0, 0x0010238f, 0x001023a0, 0x00102300,
2235 0x00102300, 0x001023ad, 0x001023c5, 0x001023dd,
2236 0x00102300, 0x001023e7, 0x001023f4, 0x00102300,
2237 0x0010241d, 0x00102300, 0x0010247a, 0x00102300,
2238 0x00102300, 0x00102300, 0x00102300, 0x00102300,
2239 0x00102300, 0x00102300, 0x00102300, 0x00102300,
2240 0x00102300, 0x00102300, 0x00102491, 0x00102300,
2241 0x001024e3, 0x00102300, 0x00102300, 0x00102300,
2242 0x00102300, 0x001024e8, 0x00102560, 0x00102300,
2243 0x00102567, 0x00102300, 0x00102300, 0x00102300,
2244 0x00102300, 0x00102300, 0x00102569, 0x001025ea,
2245 0x00102727, 0x00102300, 0x00102300, 0x00102300,
2246 0x00102300, 0x00102300, 0x00102736, 0x00102300,
2247 0x00102300, 0x00102300, 0x00102300, 0x00102300,
2248 0x00102300, 0x00102300, 0x00102753, 0x001027a6,
2249 0x00102802, 0x00102816, 0x00102835, 0x00102a70,
2250 0x00102dff, 0x00102300, 0x00102300, 0x00102300,
2251 0x00102300, 0x00102300, 0x00102300, 0x00102300,
2252 0x00102300, 0x00102300, 0x00102300, 0x00102300,
2253 0x00102300, 0x00102fb4, 0x00103028, 0x00102300,
2254 0x00102300, 0x00103094, 0x00102300, 0x00103126,
2255 0x001031d8, 0x00102300, 0x00102300, 0x0010320f,
2256 0x0010326b, 0x00102300, 0x001032bd, 0x00103419,
2257 0x00102300, 0x0010342d, 0x001034b8, 0x00102300,
2258 0x00102300, 0x00102300, 0x00102300, 0x00103522,
2259 0x00103526, 0x00103545, 0x00102300, 0x001035e7,
2260 0x00102300, 0x00102300, 0x00103615, 0x00102300,
2261 0x00103643, 0x00102300, 0x00102300, 0x001036aa,
2262 0x001037b7, 0x00103814, 0x00102300, 0x0010387a,
2263 0x00102300, 0x00102300, 0x001038d3, 0x00103936,
2264 0x00102300, 0x48efc857, 0x4031d800, 0x58ef400b,
2265 0x58ec0002, 0x82000580, 0x00000200, 0x04000045,
2266 0x48efc857, 0x4a034206, 0x00004000, 0x0201f800,
2267 0x00103a15, 0x83a00580, 0x0010b4a4, 0x0400000d,
2268 0x58ee580a, 0x4d2c0000, 0x0401f856, 0x41a25800,
2269 0x0201f800, 0x001007f4, 0x40ee5800, 0x0201f800,
2270 0x001007f4, 0x5c025800, 0x0201f000, 0x000202da,
2271 0x04026007, 0x59a0001d, 0x84000542, 0x4803401d,
2272 0x4a01d809, 0x001022d4, 0x1c01f000, 0x59a00206,
2273 0x82000d80, 0x00004000, 0x04000006, 0x900001c0,
2274 0x82000540, 0x00000011, 0x4803c011, 0x0401f005,
2275 0x900001c0, 0x82000540, 0x00000010, 0x4803c011,
2276 0x0401f845, 0x59e00017, 0x8c000508, 0x0402000c,
2277 0x4203e000, 0x30000001, 0x4203e000, 0x40000000,
2278 0x40ee5800, 0x0201f800, 0x001007f4, 0x59a0001d,
2279 0x84000504, 0x4803401d, 0x1c01f000, 0x4a03c017,
2280 0x00000000, 0x59a00206, 0x82000d80, 0x00004000,
2281 0x040007f0, 0x4a03c017, 0x00000001, 0x0401f7ed,
2282 0x4803c856, 0x4a034206, 0x00004001, 0x0401f7c0,
2283 0x4803c856, 0x4a034206, 0x00004002, 0x0401f7bc,
2284 0x4803c856, 0x4a034206, 0x00004003, 0x0401f7b8,
2285 0x4803c856, 0x4a034206, 0x00004005, 0x0401f7b4,
2286 0x4803c856, 0x4a034206, 0x00004006, 0x0401f7b0,
2287 0x4803c856, 0x4a034206, 0x0000400b, 0x0401f7ac,
2288 0x4803c856, 0x4a034206, 0x0000400c, 0x0401f7a8,
2289 0x4803c856, 0x4a034206, 0x0000400c, 0x0401f7a4,
2290 0x48efc857, 0x58eca80a, 0x8054a9c0, 0x02000800,
2291 0x001005d8, 0x83a0a400, 0x00000006, 0x8254ac00,
2292 0x00000006, 0x4200b000, 0x0000000d, 0x0201f000,
2293 0x0010ab17, 0x59a00206, 0x4803c857, 0x59a00406,
2294 0x4803c857, 0x59a00207, 0x4803c857, 0x59a00407,
2295 0x4803c857, 0x59a00208, 0x4803c857, 0x59a00408,
2296 0x4803c857, 0x59a00209, 0x4803c857, 0x83e0ac00,
2297 0x00000020, 0x83a0a400, 0x00000006, 0x4200b000,
2298 0x00000010, 0x50500000, 0x4400a800, 0x8054a800,
2299 0x900001c0, 0x4400a800, 0x8054a800, 0x8050a000,
2300 0x8058b040, 0x040207f8, 0x1c01f000, 0x59a00406,
2301 0x800000c2, 0x59a00a07, 0x900409c0, 0x80040540,
2302 0x84000540, 0x59a00c07, 0x8c040d00, 0x04000018,
2303 0x59a80805, 0x8c040d0e, 0x040207ba, 0x42000800,
2304 0x00000064, 0x80040840, 0x04000007, 0x4a030000,
2305 0x00000001, 0x40000000, 0x59801000, 0x8c081500,
2306 0x040007f9, 0x04000005, 0x48030004, 0x4a030000,
2307 0x00000000, 0x0401f75b, 0x4a030000, 0x00000000,
2308 0x4a034406, 0x00000004, 0x040007a2, 0x4803880e,
2309 0x0401f754, 0x59a00406, 0x800000c2, 0x59a00c07,
2310 0x8c040d00, 0x0400001a, 0x59a80805, 0x8c040d0e,
2311 0x0402079c, 0x42000800, 0x00000064, 0x80040840,
2312 0x04000007, 0x4a030000, 0x00000001, 0x40000000,
2313 0x59801000, 0x8c081500, 0x040007f9, 0x04000007,
2314 0x48030004, 0x59800805, 0x48074406, 0x4a030000,
2315 0x00000000, 0x0401f73b, 0x4a030000, 0x00000000,
2316 0x4a034406, 0x00000004, 0x04000782, 0x4803880e,
2317 0x59c4080f, 0x48074406, 0x0401f732, 0x59a01c06,
2318 0x59a00207, 0x900c19c0, 0x800c1d40, 0x580c0803,
2319 0x80000580, 0x500c1000, 0x80080400, 0x800c1800,
2320 0x80040840, 0x040207fc, 0x48034406, 0x900001c0,
2321 0x48034207, 0x800001c0, 0x04000722, 0x0401f769,
2322 0x4a034406, 0x00000004, 0x4a034207, 0x00000000,
2323 0x4a034407, 0x00000010, 0x59a8000d, 0x48034208,
2324 0x900001c0, 0x48034408, 0x4a034209, 0x00000002,
2325 0x0401f714, 0x59a00407, 0x59a01207, 0x900811c0,
2326 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0,
2327 0x800c1d40, 0x59a00a08, 0x59a00408, 0x900409c0,
2328 0x80040d40, 0x59a0020a, 0x82002480, 0x00000010,
2329 0x04001754, 0x59a02406, 0x900001c0, 0x80100540,
2330 0x59a8280d, 0x80142480, 0x0400174e, 0x0201f000,
2331 0x00103a25, 0x59a00407, 0x59a01207, 0x900811c0,
2332 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0,
2333 0x800c1d40, 0x59a00a08, 0x59a00408, 0x900409c0,
2334 0x80040d40, 0x59a0020a, 0x82002480, 0x00000010,
2335 0x0400173c, 0x59a02406, 0x900001c0, 0x80100540,
2336 0x59a8280d, 0x80142480, 0x04001736, 0x0201f000,
2337 0x00103a28, 0x59a00a0a, 0x59a00406, 0x900409c0,
2338 0x80040d40, 0x59a01407, 0x59a00207, 0x900811c0,
2339 0x80081540, 0x44080800, 0x0401f6da, 0x59a00a0a,
2340 0x59a00406, 0x900409c0, 0x80040d40, 0x50040000,
2341 0x82000d00, 0x0000ffff, 0x48074207, 0x82000d00,
2342 0xffff0000, 0x900409c0, 0x48074407, 0x0401f6cd,
2343 0x59a00406, 0x8c000500, 0x04000020, 0x59a01207,
2344 0x59a01c07, 0x59a02208, 0x480b5054, 0x480f5055,
2345 0x48135056, 0x59c40801, 0x82040d00, 0x00018000,
2346 0x82040580, 0x00000000, 0x04000009, 0x82040580,
2347 0x00008000, 0x04000008, 0x82040580, 0x00010000,
2348 0x04000007, 0x0201f800, 0x001005d8, 0x40080000,
2349 0x0401f004, 0x400c0000, 0x0401f002, 0x40100000,
2350 0x80000110, 0x42000800, 0x000000e0, 0x0201f800,
2351 0x00101944, 0x0401f007, 0x59a81054, 0x59a81855,
2352 0x59a82056, 0x480b4207, 0x480f4407, 0x48134208,
2353 0x0401f6a4, 0x4d2c0000, 0x4d340000, 0x4d300000,
2354 0x4d440000, 0x59a28c06, 0x0201f800, 0x00020245,
2355 0x04000006, 0x5c028800, 0x5c026000, 0x5c026800,
2356 0x5c025800, 0x0401f6e7, 0x59a04407, 0x59a00207,
2357 0x900001c0, 0x80204540, 0x0401f81e, 0x04000009,
2358 0x4a034208, 0x00000001, 0x4a034406, 0x0000ffff,
2359 0x4a034207, 0x0000ffff, 0x497b4407, 0x0401f00b,
2360 0x0401f822, 0x0400000e, 0x4a034208, 0x00000002,
2361 0x59300402, 0x48034406, 0x59300202, 0x48034207,
2362 0x59300206, 0x48034407, 0x5c028800, 0x5c026000,
2363 0x5c026800, 0x5c025800, 0x0401f67a, 0x5c028800,
2364 0x5c026000, 0x5c026800, 0x5c025800, 0x0401f6c1,
2365 0x4937c856, 0x4823c856, 0x4d2c0000, 0x5934000f,
2366 0x80025d40, 0x04000007, 0x592c0005, 0x80200580,
2367 0x592c0000, 0x040207fb, 0x82000540, 0x00000001,
2368 0x5c025800, 0x1c01f000, 0x4823c857, 0x4d2c0000,
2369 0x4d300000, 0x42026000, 0x0010d1c0, 0x59300406,
2370 0x82000d80, 0x00000003, 0x04000004, 0x82000d80,
2371 0x00000006, 0x04020007, 0x59325808, 0x812e59c0,
2372 0x04000004, 0x592c0005, 0x80200580, 0x0400000a,
2373 0x83326400, 0x00000024, 0x41580000, 0x81300480,
2374 0x040017ef, 0x80000580, 0x5c026000, 0x5c025800,
2375 0x1c01f000, 0x82000540, 0x00000001, 0x5c026000,
2376 0x5c025800, 0x1c01f000, 0x83a00580, 0x0010b4a4,
2377 0x04020684, 0x59a80005, 0x8c00050e, 0x04020003,
2378 0x4a030000, 0x00000000, 0x4a034206, 0x00004000,
2379 0x4a03c011, 0x40000010, 0x0401fea7, 0x59e00017,
2380 0x8c000508, 0x04000003, 0x4a03c017, 0x00000000,
2381 0x4203e000, 0x30000001, 0x4203e000, 0x40000000,
2382 0x0401f000, 0x800409c0, 0x04000004, 0x4a034406,
2383 0x00000001, 0x0401f677, 0x836c0580, 0x00000003,
2384 0x04020010, 0x59a80010, 0x497b4406, 0x0201f800,
2385 0x0010513b, 0x0400000f, 0x82000d00, 0x00ffff00,
2386 0x0402000c, 0x82000c00, 0x0010210e, 0x50040800,
2387 0x80040910, 0x82041580, 0x00000080, 0x04020004,
2388 0x4a034406, 0x00000007, 0x0401f662, 0x48074406,
2389 0x82000d00, 0x0000ffff, 0x48074207, 0x80000120,
2390 0x48034407, 0x59a80026, 0x82001500, 0x00000100,
2391 0x480b4409, 0x8c000502, 0x0400001f, 0x8c000506,
2392 0x04000009, 0x82000d00, 0x0000000a, 0x82040d80,
2393 0x0000000a, 0x04020004, 0x4a034209, 0x00000001,
2394 0x0401f022, 0x8c00050a, 0x04000009, 0x82000d00,
2395 0x00000022, 0x82040d80, 0x00000022, 0x04020004,
2396 0x4a034209, 0x00000003, 0x0401f018, 0x8c000508,
2397 0x04000009, 0x82000d00, 0x00000012, 0x82040d80,
2398 0x00000012, 0x04020004, 0x4a034209, 0x00000002,
2399 0x0401f00e, 0x0201f800, 0x0010513b, 0x04020004,
2400 0x4a034209, 0x00000004, 0x0401f5e6, 0x8c000506,
2401 0x04000004, 0x4a034406, 0x00000005, 0x0401f62d,
2402 0x4a034209, 0x00000000, 0x0401f5de, 0x59a80037,
2403 0x48034407, 0x59a80038, 0x48034209, 0x0401f5d9,
2404 0x42007800, 0x0010b8ec, 0x59a00406, 0x4803c857,
2405 0x82000c80, 0x00000006, 0x04021622, 0x0c01f001,
2406 0x001024f6, 0x001024f7, 0x00102505, 0x00102518,
2407 0x00102539, 0x001024f6, 0x0401f61a, 0x836c0580,
2408 0x00000000, 0x04000613, 0x59a00a07, 0x59a00407,
2409 0x900001c0, 0x80040d40, 0x4807c857, 0x59a00a08,
2410 0x59a00408, 0x900001c0, 0x80040d40, 0x4807c857,
2411 0x0401f056, 0x836c0580, 0x00000000, 0x04000605,
2412 0x59a00407, 0x59a01207, 0x900001c0, 0x80081540,
2413 0x59a00408, 0x59a01a08, 0x900001c0, 0x800c1d40,
2414 0x42000000, 0x0010c1bf, 0x480fc857, 0x480bc857,
2415 0x42000800, 0x00001000, 0x0201f000, 0x00103a28,
2416 0x59a00a07, 0x59a00407, 0x900001c0, 0x80041d40,
2417 0x820c0c80, 0x0010ab4a, 0x040215f2, 0x820c0c80,
2418 0x00100000, 0x040015ef, 0x480fc857, 0x823c7c00,
2419 0x00000009, 0x503c0800, 0x800409c0, 0x04000006,
2420 0x823c0580, 0x0000000d, 0x040005e6, 0x803c7800,
2421 0x0401f7f9, 0x59e41001, 0x82080d00, 0xfffeffcf,
2422 0x4807c801, 0x440c7800, 0x46001800, 0x0201f800,
2423 0x800c1800, 0x46001800, 0x001005cb, 0x480bc801,
2424 0x0401f022, 0x59a01a07, 0x59a00407, 0x900001c0,
2425 0x800c1d40, 0x480c7801, 0x59a02208, 0x59a00408,
2426 0x900001c0, 0x80102540, 0x48107802, 0x59a00209,
2427 0x80000040, 0x040015cb, 0x48007806, 0x80000000,
2428 0x48007805, 0x42000800, 0x00004000, 0x40001000,
2429 0x0201f800, 0x00106681, 0x80000540, 0x04000003,
2430 0x49787801, 0x0401f5bf, 0x40040000, 0x800c1c00,
2431 0x040015bc, 0x480c7803, 0x48107804, 0x49787808,
2432 0x59a00409, 0x48007807, 0x59e40001, 0x4803c857,
2433 0x82000540, 0x00040000, 0x4803c801, 0x0401f561,
2434 0x59a80006, 0x48034406, 0x59a80007, 0x48034207,
2435 0x59a80008, 0x48034407, 0x0401f55a, 0x0201f800,
2436 0x001005d8, 0x4803c856, 0x4a03c013, 0x03800300,
2437 0x4a03c014, 0x03800380, 0x59a00c06, 0x82040580,
2438 0x000000a0, 0x04000004, 0x82040580, 0x000000a2,
2439 0x0402002b, 0x59a0140a, 0x82080480, 0x00000100,
2440 0x04021027, 0x59a0020b, 0x8c000500, 0x0402002e,
2441 0x59a00a0a, 0x800409c0, 0x04000021, 0x82040480,
2442 0x00000041, 0x0402101e, 0x82040c00, 0x00000003,
2443 0x82040d00, 0x000000fc, 0x80040904, 0x59a00407,
2444 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409,
2445 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x0201f800,
2446 0x00103a00, 0x04020006, 0x4a034406, 0x00000002,
2447 0x4a03c014, 0x03800000, 0x0401f576, 0x832e5c00,
2448 0x00000004, 0x412c0000, 0x0201f800, 0x00103a25,
2449 0x4a01d809, 0x001025a2, 0x1c01f000, 0x4a03c014,
2450 0x03800000, 0x0401f56f, 0x4031d800, 0x58ef400b,
2451 0x58ee580d, 0x58ec0002, 0x82000580, 0x00000200,
2452 0x0400055c, 0x59a00c06, 0x59a0140a, 0x59a0020b,
2453 0x8c000500, 0x04020031, 0x832e5c00, 0x00000004,
2454 0x41783800, 0x59a04a0a, 0x401c0000, 0x812c0400,
2455 0x50004000, 0x82201d00, 0x000000ff, 0x4c040000,
2456 0x0401f8ac, 0x5c000800, 0x0400002d, 0x80244840,
2457 0x04000028, 0x80081000, 0x82201d00, 0x0000ff00,
2458 0x800c1910, 0x4c040000, 0x0401f8a2, 0x5c000800,
2459 0x04000023, 0x80244840, 0x0400001e, 0x80081000,
2460 0x82201d00, 0x00ff0000, 0x800c1920, 0x4c040000,
2461 0x0401f898, 0x5c000800, 0x04000019, 0x80244840,
2462 0x04000014, 0x80081000, 0x82201d00, 0xff000000,
2463 0x800c1930, 0x4c040000, 0x0401f88e, 0x5c000800,
2464 0x0400000f, 0x80244840, 0x0400000a, 0x80081000,
2465 0x801c3800, 0x0401f7d5, 0x59a0020a, 0x82000500,
2466 0x000000ff, 0x40001800, 0x0401f882, 0x04000004,
2467 0x4a03c014, 0x03800000, 0x0401f4da, 0x4a03c014,
2468 0x03800000, 0x0401f523, 0x4803c856, 0x4a03c013,
2469 0x03800300, 0x4a03c014, 0x03800380, 0x59a00c06,
2470 0x82040580, 0x000000a0, 0x04000004, 0x82040580,
2471 0x000000a2, 0x0402006c, 0x59a0140a, 0x82080480,
2472 0x00000100, 0x04021068, 0x59a0020b, 0x8c000500,
2473 0x0402005c, 0x59a01a0a, 0x800c19c0, 0x04000062,
2474 0x820c0480, 0x00000041, 0x0402105f, 0x0201f800,
2475 0x00103a00, 0x04020006, 0x4a034406, 0x00000002,
2476 0x4a03c014, 0x03800000, 0x0401f502, 0x832e5c00,
2477 0x00000004, 0x41783800, 0x59a04a0a, 0x401c0000,
2478 0x812c0400, 0x40004000, 0x4c040000, 0x4c080000,
2479 0x0401f874, 0x5c001000, 0x5c000800, 0x04000047,
2480 0x44144000, 0x80244840, 0x0400002b, 0x80081000,
2481 0x4c040000, 0x4c080000, 0x0401f86a, 0x5c001000,
2482 0x5c000800, 0x0400003d, 0x50200000, 0x801428d0,
2483 0x80140540, 0x44004000, 0x80244840, 0x0400001e,
2484 0x80081000, 0x4c040000, 0x4c080000, 0x0401f85d,
2485 0x5c001000, 0x5c000800, 0x04000030, 0x50200000,
2486 0x801428e0, 0x80140540, 0x44004000, 0x80244840,
2487 0x04000011, 0x80081000, 0x4c040000, 0x4c080000,
2488 0x0401f850, 0x5c001000, 0x5c000800, 0x04000023,
2489 0x50200000, 0x801428f0, 0x80140540, 0x44004000,
2490 0x80244840, 0x04000004, 0x80081000, 0x801c3800,
2491 0x0401f7cb, 0x59a00a0a, 0x82040c00, 0x00000003,
2492 0x82040d00, 0x000000fc, 0x80040904, 0x59a00407,
2493 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409,
2494 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x4a03c014,
2495 0x03800000, 0x412c0000, 0x0201f000, 0x00103a28,
2496 0x0401f830, 0x04000005, 0x48174406, 0x4a03c014,
2497 0x03800000, 0x0401f463, 0x4a03c014, 0x03800000,
2498 0x0401f4ac, 0x4a03c014, 0x03800000, 0x0401f4ad,
2499 0x0401f836, 0x04000010, 0x0401f862, 0x0402000f,
2500 0x40080800, 0x0401f85f, 0x0402000c, 0x400c0800,
2501 0x0401f85c, 0x04020009, 0x0401f84b, 0x42000000,
2502 0x00030d40, 0x80000040, 0x040207ff, 0x82000540,
2503 0x00000001, 0x1c01f000, 0x0401f843, 0x80000580,
2504 0x0401f7fd, 0x0401f821, 0x0400000a, 0x82040d40,
2505 0x00000001, 0x0401f84b, 0x04020007, 0x0401f87e,
2506 0x0401f898, 0x0401f838, 0x82000540, 0x00000001,
2507 0x1c01f000, 0x0401f834, 0x80000580, 0x0401f7fd,
2508 0x40041800, 0x0401f811, 0x0400000c, 0x0401f83d,
2509 0x0402000b, 0x40080800, 0x0401f83a, 0x04020008,
2510 0x400c0800, 0x0401ffe8, 0x04000004, 0x0401f826,
2511 0x82000540, 0x00000001, 0x1c01f000, 0x0401f822,
2512 0x80000580, 0x0401f7fd, 0x4c040000, 0x42000800,
2513 0x00000064, 0x4a03c013, 0x03800300, 0x80040840,
2514 0x04000016, 0x59e00013, 0x82000500, 0x00000300,
2515 0x82000580, 0x00000300, 0x040207f7, 0x42000000,
2516 0x00000064, 0x80000040, 0x040207ff, 0x4a03c013,
2517 0x01000000, 0x42000000, 0x00000064, 0x80000040,
2518 0x040207ff, 0x4a03c013, 0x02000000, 0x82000540,
2519 0x00000001, 0x0401f002, 0x80000580, 0x5c000800,
2520 0x1c01f000, 0x4a03c013, 0x01000000, 0x42000000,
2521 0x00000064, 0x80000040, 0x040207ff, 0x4a03c013,
2522 0x02000200, 0x42000000, 0x00000064, 0x80000040,
2523 0x040207ff, 0x4a03c013, 0x01000100, 0x1c01f000,
2524 0x42002000, 0x00000008, 0x82040500, 0x00000080,
2525 0x800000c2, 0x82000540, 0x01000000, 0x4803c013,
2526 0x42000000, 0x00000064, 0x80000040, 0x040207ff,
2527 0x4a03c013, 0x02000200, 0x42000000, 0x00000064,
2528 0x80000040, 0x040207ff, 0x4a03c013, 0x02000000,
2529 0x800408c2, 0x80102040, 0x040207ec, 0x4a03c013,
2530 0x01000100, 0x42000000, 0x00000064, 0x80000040,
2531 0x040207ff, 0x4a03c013, 0x02000200, 0x42000000,
2532 0x00000064, 0x80000040, 0x040207ff, 0x59e00013,
2533 0x82000500, 0x00000100, 0x4a03c013, 0x02000000,
2534 0x4c040000, 0x42000800, 0x00000064, 0x59e00013,
2535 0x82000500, 0x00000100, 0x80040840, 0x04000003,
2536 0x80000540, 0x040207fa, 0x80000540, 0x5c000800,
2537 0x1c01f000, 0x4a03c013, 0x01000100, 0x42001000,
2538 0x00000008, 0x80000d80, 0x42000000, 0x00000064,
2539 0x80000040, 0x040207ff, 0x4a03c013, 0x02000200,
2540 0x42000000, 0x00000064, 0x80000040, 0x040207ff,
2541 0x59e00013, 0x82000500, 0x00000100, 0x80000110,
2542 0x800408c2, 0x80040d40, 0x4a03c013, 0x02000000,
2543 0x80081040, 0x040207ed, 0x40042800, 0x1c01f000,
2544 0x4a03c013, 0x01000100, 0x42000000, 0x00000064,
2545 0x80000040, 0x040207ff, 0x4a03c013, 0x02000200,
2546 0x42000000, 0x00000064, 0x80000040, 0x040207ff,
2547 0x4a03c013, 0x02000000, 0x1c01f000, 0x59a00407,
2548 0x59a80837, 0x48035037, 0x48074407, 0x59a00a09,
2549 0x82040480, 0x00000014, 0x04021003, 0x42000800,
2550 0x000007d0, 0x59a80038, 0x48075038, 0x48034209,
2551 0x0201f000, 0x001022c0, 0x836c0580, 0x00000000,
2552 0x0400000e, 0x59a80006, 0x59a00c06, 0x80041580,
2553 0x82081500, 0x00000040, 0x02000000, 0x001022c0,
2554 0x80080580, 0x48035006, 0x0201f800, 0x00100699,
2555 0x0201f000, 0x001022c0, 0x59a00406, 0x59a80806,
2556 0x48035006, 0x80040d80, 0x8c040d0c, 0x02020800,
2557 0x00100699, 0x59a00207, 0x48035007, 0x59a00407,
2558 0x48035008, 0x0201f000, 0x001022c0, 0x800409c0,
2559 0x04000005, 0x4a034406, 0x00000001, 0x0201f000,
2560 0x0010230c, 0x0201f800, 0x0010513b, 0x04020005,
2561 0x4a034406, 0x00000016, 0x0201f000, 0x0010230c,
2562 0x836c0580, 0x00000003, 0x04000005, 0x4a034406,
2563 0x00000007, 0x0201f000, 0x0010230c, 0x59a00c06,
2564 0x82040500, 0xffffff00, 0x02020000, 0x00102310,
2565 0x82041580, 0x000000ff, 0x04020007, 0x59a80010,
2566 0x82000500, 0x000000ff, 0x82001540, 0x0000ff00,
2567 0x0401f011, 0x82040400, 0x0010210e, 0x50000000,
2568 0x80000110, 0x82000580, 0x00000080, 0x02000000,
2569 0x00102310, 0x59a80010, 0x82000500, 0x000000ff,
2570 0x80041580, 0x02000000, 0x00102310, 0x840409c0,
2571 0x80041540, 0x0201f800, 0x0002075a, 0x04020005,
2572 0x4a034406, 0x00000003, 0x0201f000, 0x0010230c,
2573 0x48ee6021, 0x480a621c, 0x4a02641c, 0x0000bc09,
2574 0x4a026406, 0x00000001, 0x0201f800, 0x00103a00,
2575 0x04020007, 0x0201f800, 0x0002077d, 0x4a034406,
2576 0x00000002, 0x0201f000, 0x0010230c, 0x497a5a04,
2577 0x497a5805, 0x4a025c04, 0x00008000, 0x4a01d809,
2578 0x001027f9, 0x492e6008, 0x42027000, 0x00000032,
2579 0x0201f000, 0x000207a1, 0x800409c0, 0x04000005,
2580 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c,
2581 0x0201f800, 0x0010513b, 0x04020005, 0x4a034406,
2582 0x00000016, 0x0201f000, 0x0010230c, 0x836c0580,
2583 0x00000003, 0x04000005, 0x4a034406, 0x00000007,
2584 0x0201f000, 0x0010230c, 0x59a00c06, 0x82040500,
2585 0xffffff00, 0x02020000, 0x00102310, 0x82041580,
2586 0x000000ff, 0x04020007, 0x59a80010, 0x82000500,
2587 0x000000ff, 0x82001540, 0x0000ff00, 0x0401f011,
2588 0x82040400, 0x0010210e, 0x50000000, 0x80000110,
2589 0x82000580, 0x00000080, 0x02000000, 0x00102310,
2590 0x59a80010, 0x82000500, 0x000000ff, 0x80041580,
2591 0x02000000, 0x00102310, 0x840409c0, 0x80041540,
2592 0x0201f800, 0x0002075a, 0x04020005, 0x4a034406,
2593 0x00000003, 0x0201f000, 0x0010230c, 0x48ee6021,
2594 0x480a621c, 0x4a02641c, 0x0000bc05, 0x4a026406,
2595 0x00000001, 0x0201f800, 0x00103a00, 0x04020007,
2596 0x0201f800, 0x0002077d, 0x4a034406, 0x00000002,
2597 0x0201f000, 0x0010230c, 0x497a5a04, 0x497a5805,
2598 0x4a025c04, 0x00008000, 0x4a01d809, 0x001027f9,
2599 0x492e6008, 0x42027000, 0x00000032, 0x0201f000,
2600 0x000207a1, 0x592c0005, 0x82000580, 0x01000000,
2601 0x02020000, 0x001022c0, 0x4a034406, 0x00000004,
2602 0x0201f000, 0x0010230c, 0x497b4406, 0x497b4207,
2603 0x0201f800, 0x00103b25, 0x04000008, 0x59a80066,
2604 0x59a8086a, 0x80040480, 0x59a80867, 0x48074406,
2605 0x80041480, 0x480b4207, 0x49674407, 0x59a8000e,
2606 0x48034209, 0x495f4409, 0x59a80020, 0x4803420b,
2607 0x0201f000, 0x001022c0, 0x800409c0, 0x04000005,
2608 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c,
2609 0x59a00406, 0x8c000500, 0x0402000f, 0x59a80069,
2610 0x81640480, 0x04001008, 0x59a8000b, 0x81500580,
2611 0x04000009, 0x59a8006a, 0x59a81066, 0x80080580,
2612 0x04000005, 0x4a034406, 0x00000018, 0x0201f000,
2613 0x0010230c, 0x82000540, 0x00000001, 0x0201f800,
2614 0x001015fe, 0x0201f800, 0x00103c80, 0x0201f000,
2615 0x001022c0, 0x4803c856, 0x800409c0, 0x02020000,
2616 0x00102314, 0x59a00406, 0x8c00051e, 0x04000008,
2617 0x4803c856, 0x59a0020b, 0x82000480, 0x00000800,
2618 0x04001015, 0x0201f000, 0x00102310, 0x4803c856,
2619 0x59a0020b, 0x599c0a01, 0x80040480, 0x04021003,
2620 0x0201f000, 0x00102310, 0x59a8000e, 0x81640580,
2621 0x04000009, 0x4a034406, 0x00000018, 0x0201f000,
2622 0x0010230c, 0x4a034406, 0x00000005, 0x0201f000,
2623 0x0010230c, 0x59a80026, 0x8c00050a, 0x040007fa,
2624 0x59a00406, 0x8c00051e, 0x04000036, 0x0201f800,
2625 0x0002075a, 0x040007f4, 0x0201f800, 0x00103a00,
2626 0x040007f1, 0x497a5a04, 0x59a00406, 0x4802620a,
2627 0x59a00209, 0x4802640a, 0x59a00409, 0x4802620b,
2628 0x59a0020d, 0x4802620c, 0x59a0040d, 0x4802640c,
2629 0x59a0020e, 0x4802620d, 0x59a0040e, 0x4802640d,
2630 0x59a00210, 0x4802620e, 0x59a00410, 0x4802640e,
2631 0x59a0020b, 0x82000500, 0x0000fffc, 0x80000104,
2632 0x4802640b, 0x0401f9d9, 0x040007d7, 0x48ee6021,
2633 0x58ee580d, 0x5930020e, 0x59301c0e, 0x900c19c0,
2634 0x800c1d40, 0x5930020c, 0x5930140c, 0x900811c0,
2635 0x80081540, 0x592c0a05, 0x832c0400, 0x00000006,
2636 0x0201f800, 0x00103a25, 0x4a01d809, 0x001029e5,
2637 0x4a034000, 0x00000001, 0x49334001, 0x1c01f000,
2638 0x0201f800, 0x00106c55, 0x0201f800, 0x00100ae0,
2639 0x0401f86d, 0x497b5057, 0x4201d000, 0x00002710,
2640 0x0201f800, 0x001060c6, 0x59c40880, 0x4c040000,
2641 0x59c408a3, 0x4c040000, 0x497b4002, 0x0401f876,
2642 0x0401f893, 0x4a03a005, 0x10000000, 0x0401f8b4,
2643 0x0401f901, 0x04000048, 0x59c80001, 0x800001c0,
2644 0x040007fc, 0x59c80018, 0x82000500, 0xf0000000,
2645 0x59c00808, 0x82040d00, 0x0fffffff, 0x80040540,
2646 0x48038008, 0x0201f800, 0x00100ec1, 0x59c00006,
2647 0x4a038006, 0x10000000, 0x59c00009, 0x82000d00,
2648 0x00e00000, 0x04020024, 0x4a03900d, 0x00000000,
2649 0x59c80020, 0x82000500, 0xff000000, 0x82000580,
2650 0x32000000, 0x0402001c, 0x4a03900d, 0x00000001,
2651 0x59c80020, 0x82000500, 0xff000000, 0x82000580,
2652 0xe1000000, 0x04020014, 0x4a03900d, 0x00000000,
2653 0x59c80020, 0x82000500, 0x00ffffff, 0x4a03900d,
2654 0x00000000, 0x59c80821, 0x82040d00, 0x00ffffff,
2655 0x80040580, 0x04020008, 0x59a80010, 0x80040580,
2656 0x04020005, 0x59c40005, 0x82000500, 0x000000f0,
2657 0x04000006, 0x4803c856, 0x0401f8d7, 0x4a035057,
2658 0x00000001, 0x0401f002, 0x0401f8e1, 0x42000000,
2659 0x00000064, 0x80000040, 0x02000800, 0x001005d8,
2660 0x59c00807, 0x82040d00, 0x0000000c, 0x040007fa,
2661 0x0401f003, 0x4a035057, 0x00000001, 0x0401f8da,
2662 0x0201f800, 0x00106f36, 0x0401f818, 0x4201d000,
2663 0x000186a0, 0x0201f800, 0x001060c6, 0x5c000800,
2664 0x480788a3, 0x5c000800, 0x48078880, 0x59a80057,
2665 0x800001c0, 0x02000000, 0x001022c0, 0x0201f000,
2666 0x00102318, 0x599c0201, 0x48035059, 0x41780800,
2667 0x42001000, 0x00003b10, 0x0201f800, 0x001066a0,
2668 0x480b505a, 0x1c01f000, 0x0201f800, 0x00106c4b,
2669 0x59b800ea, 0x82000500, 0x00000007, 0x82000580,
2670 0x00000003, 0x04020003, 0x4a0370e8, 0x00000001,
2671 0x1c01f000, 0x42038000, 0x00007700, 0x4a038006,
2672 0x30000000, 0x59c00007, 0x8c00050a, 0x040207fe,
2673 0x59c00006, 0x59a00209, 0x59a00c09, 0x900409c0,
2674 0x80040d40, 0x48078001, 0x59a0020e, 0x59a00c0e,
2675 0x900409c0, 0x80040d40, 0x48078000, 0x59a0020b,
2676 0x82000500, 0x0000fffc, 0x48038002, 0x48038003,
2677 0x48038005, 0x497b9009, 0x59e00003, 0x82000540,
2678 0x00008060, 0x4803c003, 0x1c01f000, 0x41780800,
2679 0x8007a0ca, 0x83d3a400, 0x00007600, 0x42000800,
2680 0x00000040, 0x0201f800, 0x00101345, 0x4a03a00a,
2681 0x00000001, 0x4a03a005, 0x20000000, 0x59d00006,
2682 0x4a03a005, 0x30000000, 0x59d00006, 0x8c00050a,
2683 0x040207fe, 0x59d00005, 0x59a00210, 0x59a00c10,
2684 0x900409c0, 0x80040d40, 0x4807a001, 0x59a0020d,
2685 0x59a00c0d, 0x900409c0, 0x80040d40, 0x4807a000,
2686 0x59a0020b, 0x82000500, 0x0000fffc, 0x4803a003,
2687 0x4803a002, 0x4803a008, 0x1c01f000, 0x59a00002,
2688 0x4803c857, 0x800001c0, 0x0402004a, 0x59a8005a,
2689 0x48038880, 0x59c400a3, 0x82000540, 0x00002008,
2690 0x8400053a, 0x480388a3, 0x59c40008, 0x8400054e,
2691 0x82000500, 0xffffffe1, 0x48038808, 0x59c80040,
2692 0x84000534, 0x48039040, 0x0401f902, 0x04020013,
2693 0x59a80010, 0x800000d0, 0x82000540, 0x00000011,
2694 0x48039120, 0x59a80010, 0x82000500, 0x00ffffff,
2695 0x82000540, 0x32000000, 0x48039121, 0x4a039123,
2696 0xe1290008, 0x59a80010, 0x82000500, 0x00ffffff,
2697 0x48039122, 0x0401f016, 0x59a80010, 0x82000500,
2698 0x000000ff, 0x900009c0, 0x840001c0, 0x80040540,
2699 0x82000540, 0x00000000, 0x48039120, 0x59a80010,
2700 0x82000500, 0x000000ff, 0x82000540, 0x01000000,
2701 0x48039121, 0x4a039123, 0x08210008, 0x59a80010,
2702 0x82000500, 0x000000ff, 0x48039122, 0x497b9124,
2703 0x59a80c5b, 0x80040800, 0x4807545b, 0x900409c0,
2704 0x82040540, 0x0000aaaa, 0x48039125, 0x497b9126,
2705 0x497b9127, 0x0401f8cf, 0x04020004, 0x4a039100,
2706 0x0000e980, 0x0401f003, 0x4a039100, 0x0000e9a0,
2707 0x1c01f000, 0x82000540, 0x00000001, 0x0402500d,
2708 0x4203e000, 0x80000000, 0x40e81000, 0x41780800,
2709 0x42000000, 0x00000064, 0x0201f800, 0x001066a0,
2710 0x59940024, 0x80080400, 0x48032824, 0x80000580,
2711 0x1c01f000, 0x4d900000, 0x4dd00000, 0x4da40000,
2712 0x4d140000, 0x417a3000, 0x0201f800, 0x001070d8,
2713 0x0201f800, 0x00106dc3, 0x5c022800, 0x5c034800,
2714 0x5c03a000, 0x5c032000, 0x1c01f000, 0x59c80007,
2715 0x8c000500, 0x04000003, 0x4a03900d, 0x00000030,
2716 0x1c01f000, 0x4a038805, 0x00020000, 0x42000800,
2717 0x0000003c, 0x0201f800, 0x00101345, 0x4a038891,
2718 0x0000ffff, 0x59c80035, 0x48039035, 0x4a03900d,
2719 0x00000040, 0x42038000, 0x00007700, 0x0201f800,
2720 0x00100ec1, 0x42038000, 0x00007720, 0x0201f800,
2721 0x00100ec1, 0x4a03a005, 0x20000000, 0x4a03a005,
2722 0x30000000, 0x59d00806, 0x8c040d0a, 0x040207fe,
2723 0x1c01f000, 0x4d300000, 0x4031d800, 0x58ef400b,
2724 0x58ee580d, 0x58ec0002, 0x82000580, 0x00000200,
2725 0x5c026000, 0x02000000, 0x00102304, 0x4d300000,
2726 0x59a26001, 0x59a00000, 0x4000b000, 0x80000000,
2727 0x48034000, 0x592c0001, 0x80000540, 0x0400001e,
2728 0x40025800, 0x8058b040, 0x040207fb, 0x58ec1007,
2729 0x58ec1808, 0x592c0a05, 0x4d2c0000, 0x58ec000d,
2730 0x40025800, 0x592c0204, 0x5c025800, 0x82000580,
2731 0x00000103, 0x04000008, 0x832c0400, 0x00000006,
2732 0x0201f800, 0x00103a25, 0x4a01d809, 0x001029e5,
2733 0x0401f007, 0x832c0400, 0x00000006, 0x0201f800,
2734 0x00103a28, 0x4a01d809, 0x001029e5, 0x5c026000,
2735 0x1c01f000, 0x58ec000d, 0x40025800, 0x592c0204,
2736 0x82000580, 0x00000103, 0x04020006, 0x0201f800,
2737 0x0002077d, 0x5c026000, 0x0201f000, 0x001022c0,
2738 0x58ec000d, 0x40025800, 0x592c0404, 0x8400055e,
2739 0x48025c04, 0x42028800, 0x000007fd, 0x42003000,
2740 0x00fffffd, 0x0201f800, 0x001045a6, 0x04000003,
2741 0x80000580, 0x0401f004, 0x59a26001, 0x0201f800,
2742 0x0010937d, 0x5c026000, 0x02000000, 0x0010230c,
2743 0x4d300000, 0x4a01d809, 0x00102a38, 0x0401f7dc,
2744 0x592c0005, 0x82000580, 0x01000000, 0x02000000,
2745 0x00102318, 0x4d300000, 0x59a26001, 0x5930020b,
2746 0x59301c0a, 0x900001c0, 0x800c1d40, 0x5930040d,
2747 0x5930120d, 0x900001c0, 0x80081540, 0x592c0a05,
2748 0x832c0400, 0x00000006, 0x0201f800, 0x00103a28,
2749 0x4a01d809, 0x001029e5, 0x4a034000, 0x00000001,
2750 0x5c026000, 0x1c01f000, 0x4933c857, 0x4c300000,
2751 0x5930040b, 0x82000c80, 0x0000000e, 0x04001004,
2752 0x4a025a05, 0x0000000e, 0x0401f003, 0x48025a05,
2753 0x0401f00c, 0x800409c0, 0x0400000a, 0x4c040000,
2754 0x0201f800, 0x00103a00, 0x5c000800, 0x04000003,
2755 0x40040000, 0x0401f7f0, 0x80000580, 0x0401f003,
2756 0x82000540, 0x00000001, 0x5c006000, 0x1c01f000,
2757 0x59a00206, 0x82000580, 0x00000044, 0x1c01f000,
2758 0x4807c857, 0x800409c0, 0x0400000c, 0x0201f800,
2759 0x00101650, 0x04020009, 0x42000000, 0x00000002,
2760 0x0201f800, 0x0010188c, 0x42000000, 0x00000002,
2761 0x0201f800, 0x00101821, 0x59a00406, 0x82000500,
2762 0x00000007, 0x0c01f001, 0x00102a8c, 0x00102aa1,
2763 0x00102ab7, 0x00102a8a, 0x00102a8a, 0x00102a8a,
2764 0x00102a8a, 0x00102a8a, 0x0201f000, 0x00102310,
2765 0x42000800, 0x000000c0, 0x0201f800, 0x0010193f,
2766 0x82040540, 0x00000002, 0x42000800, 0x000000c0,
2767 0x0201f800, 0x00101944, 0x42000800, 0x00000000,
2768 0x0201f800, 0x0010193f, 0x82040540, 0x00000008,
2769 0x42000800, 0x00000000, 0x0201f800, 0x00101944,
2770 0x0401f00b, 0x42000800, 0x000000c0, 0x0201f800,
2771 0x0010193f, 0x82040540, 0x00000001, 0x42000800,
2772 0x000000c0, 0x0201f800, 0x00101944, 0x59c80040,
2773 0x4c000000, 0x59a80010, 0x4c000000, 0x59c400a3,
2774 0x4c000000, 0x59c40008, 0x4c000000, 0x0401f911,
2775 0x04000021, 0x0201f800, 0x001005d8, 0x59a80821,
2776 0x800409c0, 0x02020000, 0x00102314, 0x0201f800,
2777 0x0010513b, 0x04020005, 0x4a034406, 0x00000016,
2778 0x0201f000, 0x0010230c, 0x836c0580, 0x00000003,
2779 0x02020000, 0x00102314, 0x59c408a4, 0x82040d00,
2780 0x0000000f, 0x82040580, 0x00000000, 0x02020000,
2781 0x00102314, 0x59c80040, 0x4c000000, 0x59a80010,
2782 0x4c000000, 0x59c400a3, 0x4c000000, 0x59c40008,
2783 0x4c000000, 0x59c40080, 0x4c000000, 0x59a0020f,
2784 0x59a0bc0f, 0x905cb9c0, 0x805cbd40, 0x41784800,
2785 0x41785000, 0x41785800, 0x41789000, 0x41789800,
2786 0x0401fe21, 0x0201f800, 0x00106c55, 0x0201f800,
2787 0x00100ae0, 0x4178c000, 0x497b4002, 0x0401f95c,
2788 0x0401f9aa, 0x59a0020c, 0x59a00c0c, 0x80040d40,
2789 0x04000002, 0x0401f9fb, 0x0401f9fa, 0x0401fe68,
2790 0x8060c1c0, 0x04020014, 0x0401fa98, 0x0401feb2,
2791 0x0402000e, 0x0201f800, 0x001018d3, 0x04020008,
2792 0x4a034406, 0x00000017, 0x0201f800, 0x0010230c,
2793 0x4203e000, 0x50000000, 0x0401f000, 0x42005800,
2794 0x0000aaaa, 0x0401f058, 0x59c80001, 0x800001c0,
2795 0x040007ee, 0x59c80801, 0x800409c0, 0x04000006,
2796 0x0401fa70, 0x40240000, 0x80280540, 0x802c0540,
2797 0x0402004d, 0x59a00002, 0x82000580, 0xfeedbeef,
2798 0x04000004, 0x42008800, 0x10000000, 0x0401f003,
2799 0x42008800, 0x10000004, 0x0401fa19, 0x4a034002,
2800 0xfeedbeef, 0x0401fa71, 0x0401fa97, 0x0401fea8,
2801 0x59c40005, 0x8c000534, 0x04000004, 0x42005800,
2802 0x0000bbbb, 0x0401f038, 0x0401fe83, 0x04020007,
2803 0x42005800, 0x0000cccc, 0x485f420f, 0x905cb9c0,
2804 0x485f440f, 0x0401f030, 0x59a0040c, 0x800001c0,
2805 0x0400000e, 0x59a26000, 0x5930000d, 0x800001c0,
2806 0x040207be, 0x59a26001, 0x5930080d, 0x800409c0,
2807 0x040207ba, 0x804891c0, 0x040207b8, 0x804c99c0,
2808 0x040207b6, 0x0401f87a, 0x805cb840, 0x04000005,
2809 0x40240000, 0x80280540, 0x802c0540, 0x0402001a,
2810 0x42000000, 0x00030d40, 0x80000040, 0x04020012,
2811 0x59c00007, 0x82000500, 0x000501c0, 0x0402000b,
2812 0x0201f800, 0x001018d3, 0x04020008, 0x4a034406,
2813 0x00000017, 0x0201f800, 0x0010230c, 0x4203e000,
2814 0x50000000, 0x0401f000, 0x42005800, 0x0000dddd,
2815 0x0401f005, 0x59c00807, 0x82040d00, 0x0000000c,
2816 0x040007ea, 0x0401fe5c, 0x59a0040c, 0x800001c0,
2817 0x04000002, 0x0401f856, 0x0401fe6b, 0x40240000,
2818 0x80280540, 0x802c0540, 0x04020003, 0x805cb9c0,
2819 0x04020781, 0x0201f800, 0x00106f36, 0x0401fda3,
2820 0x4201d000, 0x000186a0, 0x0201f800, 0x001060c6,
2821 0x5c000800, 0x48078880, 0x5c000800, 0x48078808,
2822 0x5c000800, 0x480788a3, 0x5c000800, 0x48075010,
2823 0x5c000800, 0x48079040, 0x0201f800, 0x00100969,
2824 0x59a00406, 0x82000500, 0x00000003, 0x82000580,
2825 0x00000002, 0x0400002c, 0x42000800, 0x000000c0,
2826 0x0201f800, 0x0010193f, 0x82040500, 0xfffffffc,
2827 0x42000800, 0x000000c0, 0x0201f800, 0x00101944,
2828 0x42000800, 0x00000000, 0x0201f800, 0x0010193f,
2829 0x82040500, 0xfffffff7, 0x42000800, 0x00000000,
2830 0x0201f800, 0x00101944, 0x42000800, 0x00000000,
2831 0x0201f800, 0x0010193f, 0x82040500, 0xfffffffb,
2832 0x42000800, 0x00000000, 0x0201f800, 0x00101944,
2833 0x4a0388a7, 0x0000f7f7, 0x42006000, 0xbeffffff,
2834 0x42006800, 0x80018000, 0x0201f800, 0x0010427d,
2835 0x42006000, 0xfffeffff, 0x41786800, 0x0201f800,
2836 0x0010427d, 0x402c0000, 0x80280540, 0x80240540,
2837 0x02000000, 0x001022c0, 0x48274406, 0x482b4207,
2838 0x482f4407, 0x0201f000, 0x0010231c, 0x59a26000,
2839 0x813261c0, 0x0400000e, 0x59325808, 0x812e59c0,
2840 0x0400000b, 0x0201f800, 0x0002077d, 0x0201f800,
2841 0x001007fd, 0x59a26001, 0x59325808, 0x0201f800,
2842 0x0002077d, 0x0201f800, 0x001007fd, 0x1c01f000,
2843 0x42000800, 0x000000ef, 0x0201f800, 0x001015eb,
2844 0x59c400a3, 0x8400055a, 0x8400053a, 0x480388a3,
2845 0x0201f800, 0x0010163b, 0x0402000a, 0x42000000,
2846 0x00000001, 0x0201f800, 0x0010188c, 0x42000000,
2847 0x00000001, 0x0201f800, 0x00101821, 0x0401f013,
2848 0x0201f800, 0x00101642, 0x04020008, 0x41780000,
2849 0x0201f800, 0x0010188c, 0x41780000, 0x0201f800,
2850 0x00101821, 0x0401f009, 0x42000000, 0x00000002,
2851 0x0201f800, 0x0010188c, 0x42000000, 0x00000002,
2852 0x0201f800, 0x00101821, 0x42000800, 0x00000000,
2853 0x0201f800, 0x0010193f, 0x82040540, 0x00000004,
2854 0x42000800, 0x00000000, 0x0201f800, 0x00101944,
2855 0x4201d000, 0x00000014, 0x0201f800, 0x0010608e,
2856 0x59c40008, 0x8400054e, 0x82000500, 0xffffffe1,
2857 0x48038808, 0x4a0388a7, 0x0000f7f7, 0x42001000,
2858 0x04000001, 0x0201f800, 0x0010193d, 0x42006000,
2859 0xbe20bfff, 0x42006800, 0x80018000, 0x0201f800,
2860 0x0010427d, 0x42006000, 0xfffeffff, 0x41786800,
2861 0x0201f800, 0x0010427d, 0x4200b000, 0x00001388,
2862 0x4201d000, 0x00000014, 0x4c580000, 0x0201f800,
2863 0x0010608e, 0x0201f800, 0x001018d3, 0x5c00b000,
2864 0x04000004, 0x8058b040, 0x040207f6, 0x0401f025,
2865 0x59c40005, 0x8c000534, 0x04020007, 0x59c400a4,
2866 0x82000500, 0x0000000f, 0x82000580, 0x00000008,
2867 0x0402001c, 0x42006000, 0x00020000, 0x0201f800,
2868 0x00104282, 0x4201d000, 0x00000064, 0x0201f800,
2869 0x0010608e, 0x42006000, 0xfeffffff, 0x42006800,
2870 0x02000000, 0x0201f800, 0x0010427d, 0x42006000,
2871 0xfdffffff, 0x41786800, 0x0201f800, 0x0010427d,
2872 0x4a038805, 0x04000001, 0x59c400a4, 0x82000500,
2873 0x0000000f, 0x82000580, 0x00000000, 0x04000003,
2874 0x82000540, 0x00000001, 0x1c01f000, 0x4803c856,
2875 0x42038000, 0x00007700, 0x0201f800, 0x00100ec1,
2876 0x59c00006, 0x59a0040c, 0x800001c0, 0x0400003f,
2877 0x59a03c0c, 0x59a00209, 0x59a01c09, 0x900c19c0,
2878 0x800c1d40, 0x59a0020e, 0x59a0240e, 0x901021c0,
2879 0x80102540, 0x59a0020b, 0x82000500, 0x0000fffc,
2880 0x59a0140b, 0x900811c0, 0x80081540, 0x480b8003,
2881 0x0201f800, 0x0002075a, 0x02000800, 0x001005d8,
2882 0x49334000, 0x0201f800, 0x001007e4, 0x4a025a04,
2883 0x00000018, 0x4a025805, 0x00abcdef, 0x492e6008,
2884 0x492e600b, 0x481e600d, 0x4a02600c, 0x00000004,
2885 0x832c0400, 0x00000011, 0x4802600a, 0x42001000,
2886 0x0000000c, 0x821c0d80, 0x00000001, 0x04000004,
2887 0x801c3840, 0x0401f963, 0x0401f004, 0x41783800,
2888 0x0401f960, 0x0401f011, 0x821c0c80, 0x00000005,
2889 0x04001005, 0x40043800, 0x42001000, 0x0000003c,
2890 0x0401f006, 0x80001580, 0x82081400, 0x0000000c,
2891 0x801c3840, 0x040207fd, 0x832c0400, 0x00000005,
2892 0x0401f950, 0x040207f1, 0x497b9009, 0x59e00003,
2893 0x82000540, 0x00008060, 0x4803c003, 0x4a038009,
2894 0x00e00000, 0x1c01f000, 0x4803c856, 0x41780800,
2895 0x8007a0ca, 0x83d3a400, 0x00007600, 0x42000800,
2896 0x00000040, 0x0201f800, 0x00101345, 0x4a03a00a,
2897 0x00000001, 0x4a03a005, 0x20000000, 0x59d00006,
2898 0x4a03a005, 0x30000000, 0x59d00006, 0x8c00050a,
2899 0x040207fe, 0x59d00005, 0x59a0020c, 0x800001c0,
2900 0x0400003f, 0x59a03a0c, 0x59a00210, 0x59a01c10,
2901 0x900c19c0, 0x800c1d40, 0x59a0020d, 0x59a0240d,
2902 0x901021c0, 0x80102540, 0x59a0120b, 0x82081500,
2903 0x0000fffc, 0x59a0040b, 0x900001c0, 0x80081540,
2904 0x480ba003, 0x0201f800, 0x0002075a, 0x02000800,
2905 0x001005d8, 0x49334001, 0x0201f800, 0x001007e4,
2906 0x4a025a04, 0x00000018, 0x4a025805, 0x00abcdef,
2907 0x492e6008, 0x492e600b, 0x481e600d, 0x4a02600c,
2908 0x00000004, 0x832c0400, 0x00000011, 0x4802600a,
2909 0x42001000, 0x0000000c, 0x821c0d80, 0x00000001,
2910 0x04000004, 0x801c3840, 0x0401f906, 0x0401f004,
2911 0x41783800, 0x0401f903, 0x0401f011, 0x821c0c80,
2912 0x00000005, 0x04001005, 0x40043800, 0x42001000,
2913 0x0000003c, 0x0401f006, 0x80001580, 0x82081400,
2914 0x0000000c, 0x801c3840, 0x040207fd, 0x832c0400,
2915 0x00000005, 0x0401f8f3, 0x040207f1, 0x1c01f000,
2916 0x4803c856, 0x59a0020c, 0x800001c0, 0x04000024,
2917 0x824c0580, 0x00000002, 0x04000040, 0x59a26001,
2918 0x5930380d, 0x801c39c0, 0x0400003c, 0x801c3840,
2919 0x481e600d, 0x5932580b, 0x5930080a, 0x50042000,
2920 0x58041801, 0x58041002, 0x82081500, 0xfffffffc,
2921 0x5930000c, 0x80000000, 0x82000d80, 0x00000005,
2922 0x04020009, 0x497a600c, 0x592e5801, 0x812e59c0,
2923 0x0400001a, 0x492e600b, 0x832c0c00, 0x00000005,
2924 0x0401f005, 0x4802600c, 0x5930080a, 0x82040c00,
2925 0x00000003, 0x4806600a, 0x0401f010, 0x59a0120b,
2926 0x82081500, 0x0000fffc, 0x59a0040b, 0x900001c0,
2927 0x80081540, 0x480ba003, 0x59a0020d, 0x59a0240d,
2928 0x901021c0, 0x80102540, 0x59a00210, 0x59a01c10,
2929 0x900c19c0, 0x800c1d40, 0x4201d000, 0x00003a98,
2930 0x0201f800, 0x001060c6, 0x480ba002, 0x59a80059,
2931 0x4803a008, 0x4813a000, 0x480fa001, 0x4a03a005,
2932 0x10000000, 0x02005800, 0x001005d8, 0x804c9800,
2933 0x82000540, 0x00000001, 0x1c01f000, 0x4847c857,
2934 0x59a0040c, 0x800001c0, 0x04000024, 0x82480580,
2935 0x00000002, 0x04000042, 0x59a26000, 0x5930380d,
2936 0x801c39c0, 0x0400003e, 0x801c3840, 0x481e600d,
2937 0x5932580b, 0x5930080a, 0x50042000, 0x58041801,
2938 0x58041002, 0x82081500, 0xfffffffc, 0x5930000c,
2939 0x80000000, 0x82000d80, 0x00000005, 0x04020009,
2940 0x497a600c, 0x592e5801, 0x812e59c0, 0x0400001d,
2941 0x492e600b, 0x832c0c00, 0x00000005, 0x0401f005,
2942 0x4802600c, 0x5930080a, 0x82040c00, 0x00000003,
2943 0x4806600a, 0x0401f013, 0x82440580, 0x10000000,
2944 0x0402001f, 0x59a0020e, 0x59a0240e, 0x901021c0,
2945 0x80102540, 0x59a00209, 0x59a01c09, 0x900c19c0,
2946 0x800c1d40, 0x59a0020b, 0x82000500, 0x0000fffc,
2947 0x59a0140b, 0x900811c0, 0x80081540, 0x480b8003,
2948 0x48138000, 0x480f8001, 0x480b8002, 0x59c80018,
2949 0x82000500, 0xf0000000, 0x59c02008, 0x82102500,
2950 0x0fffffff, 0x80100540, 0x48038008, 0x48478006,
2951 0x80489000, 0x8260c540, 0x00000001, 0x1c01f000,
2952 0x59c00009, 0x4803c857, 0x82000d00, 0x00e00000,
2953 0x0400000d, 0x485f420f, 0x905cb9c0, 0x485f440f,
2954 0x8c00052e, 0x04000002, 0x80285000, 0x8c00052c,
2955 0x04000002, 0x80244800, 0x8c00052a, 0x04000002,
2956 0x802c5800, 0x1c01f000, 0x59a0020c, 0x800001c0,
2957 0x04000024, 0x59d00806, 0x4807c857, 0x8c040d3e,
2958 0x04000020, 0x4a03a005, 0x20000000, 0x4a03a005,
2959 0x30000000, 0x59d00806, 0x8c040d0a, 0x040207fe,
2960 0x824c0480, 0x00000003, 0x02021800, 0x001005d8,
2961 0x404c0000, 0x0c01f001, 0x00102da1, 0x00102da3,
2962 0x00102da9, 0x0201f800, 0x001005d8, 0x80000040,
2963 0x40009800, 0x0401ff43, 0x0400000a, 0x0401ff41,
2964 0x0401f008, 0x80000040, 0x40009800, 0x59d00806,
2965 0x4807c857, 0x8c040d3e, 0x040207e3, 0x0401ff39,
2966 0x1c01f000, 0x59a0040c, 0x800001c0, 0x04000024,
2967 0x59c00807, 0x4807c857, 0x8c040d3e, 0x04000020,
2968 0x59c00807, 0x4a038006, 0x20000000, 0x82480480,
2969 0x00000003, 0x02021800, 0x001005d8, 0x40480000,
2970 0x0c01f001, 0x00102dc4, 0x00102dc6, 0x00102dce,
2971 0x0201f800, 0x001005d8, 0x80000040, 0x40009000,
2972 0x42008800, 0x10000004, 0x0401ff65, 0x0400000c,
2973 0x0401ff63, 0x0401f00a, 0x80000040, 0x40009000,
2974 0x59c00807, 0x4807c857, 0x8c040d3e, 0x040207e5,
2975 0x42008800, 0x10000004, 0x0401ff59, 0x1c01f000,
2976 0x492fc857, 0x4000a800, 0x4a03b805, 0x20000000,
2977 0x59dc0006, 0x4a03b805, 0x30000000, 0x4813b800,
2978 0x480fb801, 0x480bb802, 0x4857b803, 0x4a03b805,
2979 0x30000002, 0x59dc0006, 0x4a03b805, 0x70000001,
2980 0x59dc0006, 0x4a03b805, 0x10000000, 0x59dc0006,
2981 0x8c00053e, 0x040007fe, 0x4a03b805, 0x20000000,
2982 0x59dc0006, 0x59dc2000, 0x59dc1801, 0x801c39c0,
2983 0x0400000a, 0x4d2c0000, 0x0201f800, 0x001007e4,
2984 0x5c000800, 0x02000800, 0x001005d8, 0x4a025a04,
2985 0x0000000a, 0x492c0801, 0x1c01f000, 0x42006000,
2986 0x00102fb2, 0x0201f800, 0x00101345, 0x4a03902c,
2987 0x00200000, 0x4200b000, 0x000001f4, 0x59c8002c,
2988 0x8c00052c, 0x04000007, 0x8058b040, 0x040207fc,
2989 0x42000000, 0x00004003, 0x41781000, 0x0401f196,
2990 0x50301000, 0x41784800, 0x4a03902d, 0x00008000,
2991 0x4200b000, 0x000001f4, 0x59c8002c, 0x8c000534,
2992 0x04000007, 0x8058b040, 0x040207fc, 0x42000000,
2993 0x00004003, 0x41781000, 0x0401f187, 0x0401f8f8,
2994 0x80244800, 0x40240000, 0x82000580, 0x000003b1,
2995 0x040207fb, 0x0401f988, 0x41784800, 0x0401f920,
2996 0x80244800, 0x40240000, 0x82000580, 0x000003b1,
2997 0x040207fb, 0x80306000, 0x82300580, 0x00102fb4,
2998 0x040207e0, 0x59a80863, 0x800409c0, 0x04000007,
2999 0x42000000, 0x00004004, 0x42001000, 0x00000002,
3000 0x59a81862, 0x0401f16c, 0x42006000, 0x00102fb2,
3001 0x4a035064, 0x00000004, 0x50301000, 0x41784800,
3002 0x4a03902d, 0x00004000, 0x4200b000, 0x000001f4,
3003 0x59c8002c, 0x8c000532, 0x04000007, 0x8058b040,
3004 0x040207fc, 0x42000000, 0x00004003, 0x41781000,
3005 0x0401f159, 0x0401f8ca, 0x80244800, 0x40240000,
3006 0x82000580, 0x00000154, 0x040207fb, 0x0401f95a,
3007 0x41784800, 0x0401f8f2, 0x80244800, 0x40240000,
3008 0x82000580, 0x00000154, 0x040207fb, 0x80306000,
3009 0x82300580, 0x00102fb4, 0x040207e0, 0x59a80863,
3010 0x800409c0, 0x04000007, 0x42000000, 0x00004004,
3011 0x42001000, 0x00000004, 0x59a81862, 0x0401f13e,
3012 0x42006000, 0x00102fb2, 0x497b5064, 0x50301000,
3013 0x41784800, 0x4a03902d, 0x00001000, 0x4200b000,
3014 0x000001f4, 0x59c8002c, 0x8c00052e, 0x04000007,
3015 0x8058b040, 0x040207fc, 0x42000000, 0x00004003,
3016 0x41781000, 0x0401f12c, 0x0401f89d, 0x80244800,
3017 0x40240000, 0x82000580, 0x00000088, 0x040207fb,
3018 0x0401f92d, 0x41784800, 0x0401f8c5, 0x80244800,
3019 0x40240000, 0x82000580, 0x00000088, 0x040207fb,
3020 0x80306000, 0x82300580, 0x00102fb4, 0x040207e0,
3021 0x59a80863, 0x800409c0, 0x04000007, 0x42000000,
3022 0x00004004, 0x42001000, 0x00000001, 0x59a81862,
3023 0x0401f111, 0x42006000, 0x00102fb2, 0x50301000,
3024 0x41784800, 0x4a03902d, 0x00000800, 0x0401f87c,
3025 0x80244800, 0x40240000, 0x82000580, 0x00000018,
3026 0x040207fb, 0x0401f90c, 0x41784800, 0x0401f8a4,
3027 0x80244800, 0x40240000, 0x82000580, 0x00000018,
3028 0x040207fb, 0x80306000, 0x82300580, 0x00102fb4,
3029 0x040207eb, 0x59a80863, 0x800409c0, 0x04000007,
3030 0x42000000, 0x00004004, 0x42001000, 0x00000010,
3031 0x59a81862, 0x0401f0f0, 0x42006000, 0x00102fb2,
3032 0x50301000, 0x41784800, 0x4a03902d, 0x00000400,
3033 0x0401f85b, 0x80244800, 0x40240000, 0x82000580,
3034 0x00000088, 0x040207fb, 0x0401f8eb, 0x41784800,
3035 0x0401f883, 0x80244800, 0x40240000, 0x82000580,
3036 0x00000088, 0x040207fb, 0x80306000, 0x82300580,
3037 0x00102fb4, 0x040207eb, 0x59a80863, 0x800409c0,
3038 0x04000007, 0x42000000, 0x00004004, 0x42001000,
3039 0x00000008, 0x59a81862, 0x0401f0cf, 0x42006000,
3040 0x00102fb2, 0x50301000, 0x41784800, 0x4a03902d,
3041 0x00002000, 0x4200b000, 0x000001f4, 0x59c8002c,
3042 0x8c000530, 0x04000007, 0x8058b040, 0x040207fc,
3043 0x42000000, 0x00004003, 0x41781000, 0x0401f0be,
3044 0x59c8002c, 0x82000500, 0xffe0ffff, 0x82080d00,
3045 0x001f0000, 0x80040540, 0x4803902c, 0x0401f828,
3046 0x80244800, 0x40240000, 0x82000580, 0x00000110,
3047 0x040207fb, 0x0401f8b8, 0x41784800, 0x0401f850,
3048 0x59c80034, 0x82080d00, 0x001f0000, 0x82000500,
3049 0x001f0000, 0x80040580, 0x04000006, 0x59a80063,
3050 0x80000000, 0x48035063, 0x40240000, 0x48035062,
3051 0x80244800, 0x40240000, 0x82000580, 0x00000110,
3052 0x040207ef, 0x80306000, 0x82300580, 0x00102fb4,
3053 0x040207cd, 0x59a80863, 0x800409c0, 0x04000006,
3054 0x42000000, 0x00004004, 0x42001000, 0x00000020,
3055 0x59a81862, 0x0201f000, 0x001022c0, 0x59c8002c,
3056 0x82000500, 0xffff0000, 0x82080d00, 0x0000ffff,
3057 0x80040540, 0x4803902c, 0x40080000, 0x48039028,
3058 0x48039029, 0x59a80064, 0x82000580, 0x00000004,
3059 0x04000004, 0x40080000, 0x4803902a, 0x4803902b,
3060 0x59c8082d, 0x82040d00, 0xfffffc00, 0x40240000,
3061 0x80040d40, 0x4807902d, 0x4200b000, 0x000001f4,
3062 0x59c8002c, 0x82000500, 0x18000000, 0x04000007,
3063 0x8058b040, 0x040207fb, 0x42000000, 0x00004003,
3064 0x41781000, 0x0401f06c, 0x4a03902e, 0x00000001,
3065 0x4200b000, 0x000001f4, 0x59c8002e, 0x8c000500,
3066 0x04000006, 0x8058b040, 0x040207fc, 0x42000000,
3067 0x00004003, 0x0401f060, 0x1c01f000, 0x41783800,
3068 0x59c8082d, 0x82040d00, 0xfffffc00, 0x40240000,
3069 0x80040d40, 0x4807902d, 0x4200b000, 0x000001f4,
3070 0x59c8002c, 0x82000500, 0x18000000, 0x04000007,
3071 0x8058b040, 0x040207fb, 0x42000000, 0x00004003,
3072 0x41781000, 0x0401f04c, 0x59c80030, 0x59c80830,
3073 0x80040580, 0x040207fd, 0x40041800, 0x59c80031,
3074 0x59c80831, 0x80040580, 0x040207fd, 0x40042000,
3075 0x59c80032, 0x59c80832, 0x80040580, 0x040207fd,
3076 0x40042800, 0x59c80033, 0x59c80833, 0x80040580,
3077 0x040207fd, 0x40043000, 0x400c0000, 0x80080580,
3078 0x04000002, 0x801c3800, 0x40100000, 0x80080580,
3079 0x04000002, 0x801c3800, 0x59a80064, 0x82000580,
3080 0x00000004, 0x04000009, 0x40140000, 0x80080580,
3081 0x04000002, 0x801c3800, 0x40180000, 0x80080580,
3082 0x04000002, 0x801c3800, 0x59a80064, 0x82000580,
3083 0x00000004, 0x0400000d, 0x59c80034, 0x59c80834,
3084 0x80040580, 0x040207fd, 0x82040500, 0x0000ffff,
3085 0x82080d00, 0x0000ffff, 0x80040580, 0x0400000e,
3086 0x801c3800, 0x0401f00c, 0x59c80034, 0x59c80834,
3087 0x80040580, 0x040207fd, 0x82040500, 0x000000ff,
3088 0x82080d00, 0x000000ff, 0x80040580, 0x04000002,
3089 0x801c3800, 0x801c39c0, 0x04000006, 0x59a80063,
3090 0x801c0400, 0x48035063, 0x40240000, 0x48035062,
3091 0x1c01f000, 0x48034206, 0x48074406, 0x480b4207,
3092 0x480f4407, 0x48134208, 0x48174408, 0x0201f000,
3093 0x001022c3, 0x42000000, 0x00600000, 0x80000040,
3094 0x040207ff, 0x1c01f000, 0x5a5a5a5a, 0xa5a5a5a5,
3095 0x59a00c0a, 0x800409c0, 0x02000000, 0x00102310,
3096 0x82040480, 0x00000021, 0x02021000, 0x00102310,
3097 0x82040480, 0x00000011, 0x04001003, 0x42000800,
3098 0x00000010, 0x59a00208, 0x59a01407, 0x900811c0,
3099 0x80081540, 0x59a00207, 0x59a01c06, 0x900c19c0,
3100 0x800c1d40, 0x0201f800, 0x00103a00, 0x04000006,
3101 0x0201f800, 0x00103a25, 0x4a01d809, 0x00102fd5,
3102 0x1c01f000, 0x4a034406, 0x00000002, 0x0201f000,
3103 0x0010230c, 0x4031d800, 0x58ef400b, 0x58ec0002,
3104 0x82000580, 0x00000200, 0x02000000, 0x00102304,
3105 0x59a00c0a, 0x82040480, 0x00000011, 0x04001003,
3106 0x42000800, 0x00000010, 0x59a0040b, 0x59a0120b,
3107 0x900811c0, 0x80081540, 0x59a00209, 0x59a01c08,
3108 0x900c19c0, 0x800c1d40, 0x58ec0003, 0x0201f800,
3109 0x00103a28, 0x4a01d809, 0x00102ff0, 0x1c01f000,
3110 0x4031d800, 0x58ef400b, 0x58ec0002, 0x82000580,
3111 0x00000200, 0x02000000, 0x00102304, 0x59a00c0a,
3112 0x82040480, 0x00000011, 0x02001000, 0x001022c0,
3113 0x82040c80, 0x00000010, 0x59a00208, 0x59a01407,
3114 0x900811c0, 0x80081540, 0x59a00207, 0x59a01c06,
3115 0x900c19c0, 0x800c1d40, 0x82081400, 0x00000040,
3116 0x58ec0003, 0x0201f800, 0x00103a25, 0x4a01d809,
3117 0x0010300e, 0x1c01f000, 0x4031d800, 0x58ef400b,
3118 0x58ec0002, 0x82000580, 0x00000200, 0x02000000,
3119 0x00102304, 0x59a0040a, 0x82000c80, 0x00000010,
3120 0x59a0040b, 0x59a0120b, 0x900811c0, 0x80081540,
3121 0x59a00209, 0x59a01c08, 0x900c19c0, 0x800c1d40,
3122 0x82081400, 0x00000040, 0x58ec0003, 0x0201f800,
3123 0x00103a28, 0x4a01d809, 0x001022b9, 0x1c01f000,
3124 0x48efc857, 0x59a00207, 0x59a01407, 0x900001c0,
3125 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0,
3126 0x800c1d40, 0x59a00406, 0x48034000, 0x480b4001,
3127 0x480f4002, 0x0201f800, 0x00103a00, 0x04020005,
3128 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c,
3129 0x42000800, 0x00000010, 0x0201f800, 0x00103a25,
3130 0x4a01d809, 0x00103043, 0x1c01f000, 0x4031d800,
3131 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580,
3132 0x00000200, 0x02000000, 0x00102304, 0x48efc857,
3133 0x49a3c857, 0x492fc857, 0x592c0a04, 0x80040910,
3134 0x04020005, 0x4a034406, 0x00000019, 0x0201f000,
3135 0x0010230c, 0x4805d80c, 0x0401f00a, 0x4031d800,
3136 0x58ef400b, 0x58ec0002, 0x82000580, 0x00000200,
3137 0x02000000, 0x00102304, 0x48efc857, 0x49a3c857,
3138 0x48efc857, 0x49a3c857, 0x58ec000c, 0x80000040,
3139 0x04000012, 0x4801d80c, 0x0201f800, 0x00103a00,
3140 0x04020005, 0x4a034406, 0x00000002, 0x0201f000,
3141 0x0010230c, 0x42000800, 0x00000010, 0x58ec1007,
3142 0x58ec1808, 0x0201f800, 0x00103a25, 0x4a01d809,
3143 0x00103057, 0x1c01f000, 0x58ee580d, 0x48efc857,
3144 0x49a3c857, 0x492fc857, 0x492f3006, 0x592c0404,
3145 0x8400055e, 0x48025c04, 0x4a01d809, 0x00103081,
3146 0x1c01f000, 0x58ee580d, 0x48efc857, 0x49a3c857,
3147 0x492fc857, 0x592c0404, 0x8400051e, 0x48025c04,
3148 0x59a00000, 0x59a01001, 0x59a01802, 0x80081400,
3149 0x820c1c40, 0x00000000, 0x832c0400, 0x00000004,
3150 0x42000800, 0x00000010, 0x0201f000, 0x00103a28,
3151 0x800409c0, 0x04000005, 0x4a034406, 0x00000001,
3152 0x0201f000, 0x0010230c, 0x836c0580, 0x00000003,
3153 0x04000005, 0x4a034406, 0x00000007, 0x0201f000,
3154 0x0010230c, 0x59a0320b, 0x82183500, 0x000000ff,
3155 0x59a28c06, 0x0201f800, 0x00020245, 0x02020000,
3156 0x00102310, 0x83440580, 0x000007fd, 0x04000008,
3157 0x0201f800, 0x001049e7, 0x04000005, 0x4a034406,
3158 0x00000009, 0x0201f000, 0x0010230c, 0x0201f800,
3159 0x00103a00, 0x04020005, 0x4a034406, 0x00000002,
3160 0x0201f000, 0x0010230c, 0x801831c0, 0x0400000a,
3161 0x412c0800, 0x0201f800, 0x00103a00, 0x04020005,
3162 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c,
3163 0x40065800, 0x4a025c04, 0x00008000, 0x497a5a04,
3164 0x0201f800, 0x00109100, 0x04020005, 0x4a034406,
3165 0x00000003, 0x0201f000, 0x0010230c, 0x4a01d809,
3166 0x001030d2, 0x1c01f000, 0x592c0005, 0x82000580,
3167 0x01000000, 0x04020005, 0x4a034406, 0x00000004,
3168 0x0201f000, 0x0010230c, 0x592c0406, 0x82002d00,
3169 0x0000ff00, 0x82000500, 0x000000ff, 0x80000904,
3170 0x80040800, 0x82040480, 0x00000006, 0x04001003,
3171 0x42000800, 0x00000005, 0x832ca400, 0x00000006,
3172 0x4050a800, 0x4004b000, 0x0201f800, 0x0010ab28,
3173 0x59a00407, 0x59a01207, 0x900811c0, 0x80081540,
3174 0x59a00409, 0x59a01a09, 0x900c19c0, 0x800c1d40,
3175 0x832c0400, 0x00000006, 0x4c140000, 0x0201f800,
3176 0x00103a28, 0x5c002800, 0x801429c0, 0x04000003,
3177 0x4a01d809, 0x001030ff, 0x1c01f000, 0x4031d800,
3178 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580,
3179 0x00000200, 0x02000000, 0x00102304, 0x812e59c0,
3180 0x02000800, 0x001005d8, 0x592c0006, 0x82000500,
3181 0xff000000, 0x80000904, 0x800409c0, 0x02000000,
3182 0x00102304, 0x82040480, 0x0000000e, 0x04001003,
3183 0x42000800, 0x0000000d, 0x592e5801, 0x812e59c0,
3184 0x02000800, 0x001005d8, 0x832ca400, 0x00000005,
3185 0x4050a800, 0x4004b000, 0x0201f800, 0x0010ab28,
3186 0x58ec1007, 0x58ec1808, 0x832c0400, 0x00000005,
3187 0x0201f000, 0x00103a28, 0x0201f800, 0x00103a00,
3188 0x04020005, 0x4a034406, 0x00000002, 0x0201f000,
3189 0x0010230c, 0x59a00c06, 0x82040500, 0x0000ff00,
3190 0x840001c0, 0x82001480, 0x00000007, 0x02021000,
3191 0x00102310, 0x0c01f001, 0x0010313d, 0x00103144,
3192 0x0010314b, 0x0010314b, 0x0010314b, 0x0010314d,
3193 0x00103152, 0x42000800, 0x0000000d, 0x42003800,
3194 0x00103166, 0x4a034000, 0x0010b4eb, 0x0401f013,
3195 0x42000800, 0x0000000d, 0x42003800, 0x00103166,
3196 0x4a034000, 0x0010b4f8, 0x0401f00c, 0x0201f000,
3197 0x00102310, 0x42000800, 0x00000008, 0x42003800,
3198 0x00103179, 0x0401f005, 0x42000800, 0x00000004,
3199 0x42003800, 0x001031c3, 0x59a00207, 0x59a01407,
3200 0x900001c0, 0x80081540, 0x59a00209, 0x59a01c09,
3201 0x900001c0, 0x800c1d40, 0x832c0400, 0x00000005,
3202 0x4c1c0000, 0x0201f800, 0x00103a25, 0x5c003800,
3203 0x481dd809, 0x1c01f000, 0x4031d800, 0x58ef400b,
3204 0x58ee580d, 0x58ec0002, 0x82000580, 0x00000200,
3205 0x02000000, 0x00102304, 0x4a03501f, 0x00000001,
3206 0x4200b000, 0x0000000d, 0x59a0a800, 0x832ca400,
3207 0x00000005, 0x0201f800, 0x0010ab17, 0x0201f000,
3208 0x001022c0, 0x4031d800, 0x58ef400b, 0x58ee580d,
3209 0x58ec0002, 0x82000580, 0x00000200, 0x02000000,
3210 0x00102304, 0x832ca400, 0x00000005, 0x50500000,
3211 0x82001500, 0x000c0016, 0x02020000, 0x00102310,
3212 0x82500c00, 0x00000003, 0x50040000, 0x82001500,
3213 0x00000001, 0x02020000, 0x00102310, 0x50500000,
3214 0x82001500, 0x00000028, 0x0400001d, 0x82081580,
3215 0x00000028, 0x02020000, 0x00102310, 0x80500800,
3216 0x50040000, 0x82001500, 0x00000013, 0x82081580,
3217 0x00000013, 0x02020000, 0x00102310, 0x80040800,
3218 0x50040000, 0x82001500, 0x00010000, 0x82081580,
3219 0x00010000, 0x02020000, 0x00102310, 0x836c0580,
3220 0x00000000, 0x04000012, 0x599c0019, 0x8c00050e,
3221 0x0402000f, 0x0201f000, 0x00102310, 0x80500800,
3222 0x50040000, 0x82001500, 0x00000013, 0x02020000,
3223 0x00102310, 0x80040800, 0x50040000, 0x82001500,
3224 0x00010000, 0x02020000, 0x00102310, 0x4200b000,
3225 0x00000008, 0x4200a800, 0x0010b4e3, 0x0201f800,
3226 0x0010ab17, 0x0201f000, 0x001022c0, 0x4031d800,
3227 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580,
3228 0x00000200, 0x02000000, 0x00102304, 0x4200b000,
3229 0x00000004, 0x4200a800, 0x0010b8fa, 0x832ca400,
3230 0x00000005, 0x0201f800, 0x0010ab17, 0x59a80005,
3231 0x84000550, 0x48035005, 0x0201f000, 0x001022c0,
3232 0x0201f800, 0x00103a00, 0x04020005, 0x4a034406,
3233 0x00000002, 0x0201f000, 0x0010230c, 0x59a00c06,
3234 0x82040500, 0x0000ff00, 0x840001c0, 0x82001480,
3235 0x00000006, 0x02021000, 0x00102310, 0x0c01f001,
3236 0x001031ee, 0x001031f3, 0x001031f8, 0x001031f8,
3237 0x001031f8, 0x001031fa, 0x42000800, 0x0000000d,
3238 0x4200a000, 0x0010b4eb, 0x0401f00c, 0x42000800,
3239 0x0000000d, 0x4200a000, 0x0010b4f8, 0x0401f007,
3240 0x0201f000, 0x00102310, 0x42000800, 0x00000008,
3241 0x4200a000, 0x0010b4e3, 0x4004b000, 0x832cac00,
3242 0x00000005, 0x0201f800, 0x0010ab17, 0x59a00207,
3243 0x59a01407, 0x900001c0, 0x80081540, 0x59a00209,
3244 0x59a01c09, 0x900001c0, 0x800c1d40, 0x832c0400,
3245 0x00000005, 0x0201f000, 0x00103a28, 0x836c0580,
3246 0x00000000, 0x04020005, 0x4a034406, 0x00000007,
3247 0x0201f000, 0x0010230c, 0x59a00406, 0x800001c0,
3248 0x0400001a, 0x59a80005, 0x8c000514, 0x04000005,
3249 0x42000000, 0x00000001, 0x40000800, 0x0401f003,
3250 0x59a00207, 0x59a80853, 0x48035053, 0x0201f800,
3251 0x0010163b, 0x04000022, 0x0201f800, 0x00101642,
3252 0x0400001f, 0x0201f800, 0x00101649, 0x0400001c,
3253 0x0201f800, 0x00101650, 0x04000019, 0x48075053,
3254 0x0201f000, 0x00102310, 0x59c40801, 0x82040d00,
3255 0x00018000, 0x82040580, 0x00000000, 0x04020004,
3256 0x4a034406, 0x00000000, 0x0401f00d, 0x82040580,
3257 0x00008000, 0x04020004, 0x4a034406, 0x00000001,
3258 0x0401f007, 0x82040580, 0x00010000, 0x02020800,
3259 0x001005d8, 0x4a034406, 0x00000003, 0x59a00406,
3260 0x82000580, 0x00000002, 0x0402001f, 0x59c40006,
3261 0x84000500, 0x48038806, 0x0201f800, 0x00106ede,
3262 0x497b8880, 0x0201f800, 0x0010a9c0, 0x0201f800,
3263 0x0010a9ce, 0x42000000, 0x0010b8ca, 0x0201f800,
3264 0x0010aa47, 0x82000540, 0x00000001, 0x0201f800,
3265 0x0010518c, 0x4a038808, 0x00000000, 0x4202d800,
3266 0x00000004, 0x42001000, 0x00000001, 0x0201f800,
3267 0x0010193d, 0x4a035049, 0x00000001, 0x0201f800,
3268 0x001006d4, 0x0201f000, 0x001022c0, 0x800409c0,
3269 0x04000005, 0x4a034406, 0x00000001, 0x0201f000,
3270 0x0010230c, 0x836c0580, 0x00000003, 0x04000005,
3271 0x4a034406, 0x00000007, 0x0201f000, 0x0010230c,
3272 0x59a28c06, 0x59a0320b, 0x82183500, 0x000000ff,
3273 0x0201f800, 0x00020245, 0x02020000, 0x00102310,
3274 0x83440580, 0x000007fd, 0x04000008, 0x0201f800,
3275 0x001049e7, 0x04000005, 0x42000800, 0x00000009,
3276 0x0201f000, 0x0010230c, 0x0201f800, 0x00103a00,
3277 0x04020005, 0x4a034406, 0x00000002, 0x0201f000,
3278 0x0010230c, 0x497a5a04, 0x4a025c04, 0x00008000,
3279 0x0201f800, 0x00109115, 0x04020005, 0x4a034406,
3280 0x00000003, 0x0201f000, 0x0010230c, 0x4a01d809,
3281 0x0010329e, 0x1c01f000, 0x592c0005, 0x82000d00,
3282 0x0000ffff, 0x82000500, 0xffff0000, 0x82000580,
3283 0x01000000, 0x04020005, 0x4a034406, 0x00000004,
3284 0x0201f000, 0x0010230c, 0x80040904, 0x832ca400,
3285 0x00000005, 0x4050a800, 0x4004b000, 0x0201f800,
3286 0x0010ab28, 0x59a00207, 0x59a01407, 0x900001c0,
3287 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0,
3288 0x800c1d40, 0x832c0400, 0x00000005, 0x0201f000,
3289 0x00103a28, 0x496fc857, 0x836c0580, 0x00000000,
3290 0x04000005, 0x4a034406, 0x0000001a, 0x0201f000,
3291 0x0010230c, 0x0201f800, 0x0010513b, 0x02020800,
3292 0x00104142, 0x42000800, 0x00000020, 0x59a00407,
3293 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409,
3294 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x419c0000,
3295 0x49a3c857, 0x0201f800, 0x00103a25, 0x4a01d809,
3296 0x001032da, 0x1c01f000, 0x4833c857, 0x4031d800,
3297 0x58ef400b, 0x58ec0002, 0x82000580, 0x00000200,
3298 0x02000000, 0x00102304, 0x599c0200, 0x800001c0,
3299 0x02000000, 0x00102310, 0x59a80005, 0x8c000512,
3300 0x04000004, 0x599c0019, 0x8400050c, 0x48033819,
3301 0x0201f800, 0x001097d7, 0x59a80005, 0x8c000514,
3302 0x04000004, 0x599c0017, 0x84000508, 0x48033817,
3303 0x0201f800, 0x00103b25, 0x04020004, 0x8c00050a,
3304 0x02020000, 0x00102310, 0x4803c857, 0x8c000504,
3305 0x04020004, 0x59c408a3, 0x84040d7a, 0x480788a3,
3306 0x8c000502, 0x04020004, 0x59c408a3, 0x84040d08,
3307 0x480788a3, 0x599c0c02, 0x8c000500, 0x04020004,
3308 0x8c000516, 0x04000012, 0x0401f001, 0x82041480,
3309 0x0000007f, 0x02021000, 0x00102310, 0x82041400,
3310 0x0010210e, 0x50081000, 0x82081500, 0x000000ff,
3311 0x8c000500, 0x04020006, 0x480b5010, 0x42000800,
3312 0x00000003, 0x0201f800, 0x00106c78, 0x599c0019,
3313 0x8c00050e, 0x0402000b, 0x59a80806, 0x8c040d14,
3314 0x04000008, 0x42000800, 0x0010b4e3, 0x50040800,
3315 0x82040d00, 0x00000028, 0x02020000, 0x00102310,
3316 0x82000500, 0x00000030, 0x04000003, 0x80000108,
3317 0x0401f003, 0x42000000, 0x00000002, 0x48039040,
3318 0x42000800, 0x00000002, 0x82000400, 0x00103415,
3319 0x50001000, 0x0201f800, 0x00106c78, 0x599c0201,
3320 0x82000c80, 0x00000100, 0x02001000, 0x00102310,
3321 0x82000c80, 0x00000841, 0x02021000, 0x00102310,
3322 0x82000500, 0x00000007, 0x02020000, 0x00102310,
3323 0x599c0401, 0x80000540, 0x02000000, 0x00102310,
3324 0x599c0409, 0x599c0c07, 0x80040c80, 0x02021000,
3325 0x00102310, 0x80000040, 0x02000000, 0x00102310,
3326 0x599c0209, 0x599c0a07, 0x80040c80, 0x02021000,
3327 0x00102310, 0x80000040, 0x02000000, 0x00102310,
3328 0x0201f800, 0x001053cd, 0x0201f800, 0x00104cb6,
3329 0x599c0201, 0x48035004, 0x0201f800, 0x001012ee,
3330 0x599c020a, 0x800001c0, 0x04000003, 0x4803504d,
3331 0x0401f003, 0x4a03504d, 0x000000c8, 0x0201f800,
3332 0x00103b25, 0x04000004, 0x0201f800, 0x001060df,
3333 0x417a5000, 0x836c0580, 0x00000000, 0x04020098,
3334 0x599c0003, 0x599c0804, 0x9c0001c0, 0x9c0409c0,
3335 0x48035002, 0x48075003, 0x599c1017, 0x8c08151c,
3336 0x04000006, 0x599c0005, 0x599c0806, 0x9c0001c0,
3337 0x9c0409c0, 0x0401f003, 0x82000500, 0xf0ffffff,
3338 0x48035000, 0x48075001, 0x42001000, 0x0010b4eb,
3339 0x48001000, 0x48041001, 0x42001000, 0x0010b4f8,
3340 0x48001000, 0x48041001, 0x59a80005, 0x8c000514,
3341 0x04020015, 0x599c1019, 0x82081500, 0x0000e000,
3342 0x82080580, 0x00000000, 0x0402000c, 0x4a035053,
3343 0x00000000, 0x42000000, 0x00000001, 0x0201f800,
3344 0x0010188c, 0x42000000, 0x00000001, 0x0201f800,
3345 0x00101821, 0x0401f02b, 0x82080580, 0x00002000,
3346 0x0402000a, 0x4a035053, 0x00000001, 0x41780000,
3347 0x0201f800, 0x0010188c, 0x41780000, 0x0201f800,
3348 0x00101821, 0x0401f01f, 0x82080580, 0x00004000,
3349 0x04020006, 0x4a035053, 0x00000002, 0x4a035049,
3350 0x00000001, 0x0401f017, 0x82080580, 0x00006000,
3351 0x02020000, 0x00102310, 0x59a80858, 0x82040d80,
3352 0x01391077, 0x04020005, 0x59e00813, 0x8c040d00,
3353 0x02020000, 0x00102310, 0x4a035053, 0x00000003,
3354 0x42000000, 0x00000002, 0x0201f800, 0x0010188c,
3355 0x42000000, 0x00000002, 0x0201f800, 0x00101821,
3356 0x599c0019, 0x8c000520, 0x0400000d, 0x42000000,
3357 0x00000004, 0x42000800, 0x00000040, 0x0201f800,
3358 0x00101944, 0x42000000, 0x00000010, 0x42000800,
3359 0x000000c0, 0x0201f800, 0x00101944, 0x4a035032,
3360 0x0000aaaa, 0x599c1018, 0x82081500, 0x00000030,
3361 0x59a8006c, 0x80000540, 0x0400000c, 0x82080580,
3362 0x00000000, 0x02000000, 0x00102310, 0x599c1018,
3363 0x82081500, 0xffffffcf, 0x82081540, 0x00000010,
3364 0x480b3818, 0x0401f010, 0x82080d80, 0x00000000,
3365 0x04000007, 0x82080d80, 0x00000010, 0x0400000a,
3366 0x82080d80, 0x00000020, 0x04020002, 0x48075032,
3367 0x0201f800, 0x00103aba, 0x04000008, 0x0201f800,
3368 0x001015fe, 0x0201f800, 0x0010162a, 0x59a8002a,
3369 0x80040540, 0x4803502a, 0x49f3c857, 0x42001000,
3370 0x00105065, 0x0201f800, 0x00105f90, 0x42001000,
3371 0x00105058, 0x0201f800, 0x00106084, 0x4a038805,
3372 0xffffffff, 0x4a03c014, 0x00400040, 0x4a03c013,
3373 0x00400000, 0x0201f800, 0x001048c7, 0x59a0001d,
3374 0x84000540, 0x4803401d, 0x49f3c857, 0x0201f000,
3375 0x001022c0, 0x00000018, 0x0000000c, 0x00000018,
3376 0x00000020, 0x836c0580, 0x00000000, 0x04020005,
3377 0x42000800, 0x00000007, 0x0201f000, 0x0010230c,
3378 0x42000800, 0x00000020, 0x59a00407, 0x59a01207,
3379 0x900811c0, 0x80081540, 0x59a00409, 0x59a01a09,
3380 0x900c19c0, 0x800c1d40, 0x419c0000, 0x0201f000,
3381 0x00103a28, 0x800409c0, 0x04000005, 0x4a034406,
3382 0x00000001, 0x0201f000, 0x0010230c, 0x0201f800,
3383 0x0010513b, 0x04020005, 0x4a034406, 0x00000016,
3384 0x0201f000, 0x0010230c, 0x59a80013, 0x8c000500,
3385 0x04000011, 0x4a034406, 0x00000000, 0x42000800,
3386 0x00000020, 0x59a00407, 0x59a01207, 0x900811c0,
3387 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0,
3388 0x800c1d40, 0x42000000, 0x0010be21, 0x0201f000,
3389 0x00103a28, 0x4a034406, 0x00000001, 0x4200b000,
3390 0x00000020, 0x4200a800, 0x0010be21, 0x4200a000,
3391 0xffffffff, 0x4450a800, 0x8054a800, 0x8058b040,
3392 0x040207fd, 0x4d440000, 0x4d340000, 0x42028800,
3393 0xffffffff, 0x42002000, 0xffffffff, 0x42003000,
3394 0x00000001, 0x42003800, 0x00000001, 0x42001800,
3395 0x0010be21, 0x59a81010, 0x82081500, 0x000000ff,
3396 0x40180000, 0x0c01f001, 0x0010346e, 0x00103471,
3397 0x00103475, 0x00103479, 0x82102500, 0xffffff00,
3398 0x0401f014, 0x82102500, 0xffff00ff, 0x840811c0,
3399 0x0401f010, 0x82102500, 0xff00ffff, 0x900811c0,
3400 0x0401f00c, 0x82102500, 0x00ffffff, 0x9c0801c0,
3401 0x80102540, 0x44101800, 0x42003000, 0xffffffff,
3402 0x42002000, 0xffffffff, 0x800c1800, 0x0401f003,
3403 0x40080000, 0x80102540, 0x81468800, 0x83442c80,
3404 0x0000007f, 0x04021014, 0x4c080000, 0x4c0c0000,
3405 0x4c180000, 0x4c1c0000, 0x0201f800, 0x00020245,
3406 0x5c003800, 0x5c003000, 0x5c001800, 0x5c001000,
3407 0x040207f2, 0x0201f800, 0x001049f3, 0x040207ef,
3408 0x80183000, 0x801c3800, 0x59341202, 0x40180000,
3409 0x0c01f7ce, 0x82100580, 0xffffffff, 0x04000002,
3410 0x44101800, 0x42001800, 0x0010be21, 0x500c0000,
3411 0x82000500, 0xffffff00, 0x801c0540, 0x44001800,
3412 0x5c026800, 0x5c028800, 0x42000800, 0x00000020,
3413 0x59a00407, 0x59a01207, 0x900811c0, 0x80081540,
3414 0x59a00409, 0x59a01a09, 0x900c19c0, 0x800c1d40,
3415 0x42000000, 0x0010be21, 0x0201f000, 0x00103a28,
3416 0x59a28c06, 0x59a0020b, 0x8c000500, 0x0400000e,
3417 0x59a01208, 0x59a00408, 0x82000500, 0x000000ff,
3418 0x900001c0, 0x80081540, 0x41784000, 0x0201f800,
3419 0x00104919, 0x04000008, 0x48034406, 0x0201f000,
3420 0x00102310, 0x0201f800, 0x00020245, 0x02020000,
3421 0x00102310, 0x0201f800, 0x00103a00, 0x04020005,
3422 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c,
3423 0x59a0020b, 0x8c000500, 0x04000005, 0x0201f800,
3424 0x001049f3, 0x02020000, 0x00103ac4, 0x59a0020b,
3425 0x8c000502, 0x04000019, 0x83440480, 0x000007f0,
3426 0x04021016, 0x0201f800, 0x001049fc, 0x04020013,
3427 0x497a5a04, 0x4a025c04, 0x00008000, 0x0201f800,
3428 0x001090e6, 0x04020005, 0x4a034406, 0x00000003,
3429 0x0201f000, 0x0010230c, 0x4a01d809, 0x001034f1,
3430 0x1c01f000, 0x59a28c06, 0x0201f800, 0x00020245,
3431 0x02020000, 0x00102310, 0x4200b000, 0x0000000a,
3432 0x4134a000, 0x832e5c00, 0x00000002, 0x412ca800,
3433 0x0201f800, 0x0010ab17, 0x832cac00, 0x00000006,
3434 0x4054a000, 0x4200b000, 0x00000004, 0x0201f800,
3435 0x0010ab28, 0x592c0802, 0x82040500, 0x00ff00ff,
3436 0x900001c0, 0x82041500, 0xff00ff00, 0x80080540,
3437 0x48025802, 0x592c0801, 0x82040500, 0x00ff00ff,
3438 0x900001c0, 0x82041500, 0xff00ff00, 0x80080540,
3439 0x48025801, 0x42000800, 0x0000000a, 0x59a00407,
3440 0x59a01207, 0x900811c0, 0x80081540, 0x59a00409,
3441 0x59a01a09, 0x900c19c0, 0x800c1d40, 0x412c0000,
3442 0x0201f000, 0x00103a28, 0x496fc857, 0x496f4406,
3443 0x0201f000, 0x001022c0, 0x59a28c06, 0x0201f800,
3444 0x00020245, 0x02020000, 0x00102310, 0x836c0580,
3445 0x00000003, 0x04000005, 0x4a034406, 0x00000007,
3446 0x0201f000, 0x0010230c, 0x83340c00, 0x00000006,
3447 0x59a0020b, 0x8c000500, 0x04000003, 0x83340c00,
3448 0x00000008, 0x58040001, 0x48034409, 0x900001c0,
3449 0x48034209, 0x50040000, 0x48034407, 0x900001c0,
3450 0x48034207, 0x59340200, 0x48034406, 0x0201f000,
3451 0x001022c0, 0x800409c0, 0x04000005, 0x4a034406,
3452 0x00000001, 0x0201f000, 0x0010230c, 0x59a0220b,
3453 0x8c102500, 0x0402002e, 0x8c102506, 0x04020006,
3454 0x59a03208, 0x82180480, 0x00000003, 0x02021000,
3455 0x00102310, 0x59a28c06, 0x0201f800, 0x00020245,
3456 0x02020000, 0x00102310, 0x0201f800, 0x001049e7,
3457 0x04000005, 0x4a034406, 0x00000009, 0x0201f000,
3458 0x0010230c, 0x0201f800, 0x00103a00, 0x04020005,
3459 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c,
3460 0x59a0220b, 0x8c102506, 0x04000004, 0x59343002,
3461 0x82183500, 0x00ffffff, 0x497a5a04, 0x4a025c04,
3462 0x00008000, 0x0201f800, 0x001090a8, 0x04020005,
3463 0x4a034406, 0x00000003, 0x0201f000, 0x0010230c,
3464 0x4a01d809, 0x001035d1, 0x1c01f000, 0x59a28c06,
3465 0x0201f800, 0x00020245, 0x02020000, 0x00102310,
3466 0x0201f800, 0x001049e7, 0x04000005, 0x4a034406,
3467 0x00000009, 0x0201f000, 0x0010230c, 0x0201f800,
3468 0x00103a00, 0x04020005, 0x4a034406, 0x00000002,
3469 0x0201f000, 0x0010230c, 0x497a5a04, 0x4a025c04,
3470 0x00008000, 0x0201f800, 0x00103a00, 0x04020005,
3471 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c,
3472 0x592e5800, 0x0201f800, 0x001090bd, 0x04020005,
3473 0x4a034406, 0x00000003, 0x0201f000, 0x0010230c,
3474 0x4a01d809, 0x001035a3, 0x1c01f000, 0x592c2805,
3475 0x82140d80, 0x01000000, 0x04020005, 0x4a034406,
3476 0x00000004, 0x0201f000, 0x0010230c, 0x42000800,
3477 0x00000008, 0x59a00207, 0x59a01407, 0x900001c0,
3478 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0,
3479 0x800c1d40, 0x832c0400, 0x00000005, 0x0201f800,
3480 0x00103a28, 0x8c142d00, 0x04000003, 0x4a01d809,
3481 0x001035be, 0x1c01f000, 0x4031d800, 0x58ef400b,
3482 0x58ee580e, 0x58ec0002, 0x82000580, 0x00000200,
3483 0x02000000, 0x00102304, 0x812e59c0, 0x02000800,
3484 0x001005d8, 0x42000800, 0x00000008, 0x832c0400,
3485 0x00000005, 0x58ec1007, 0x58ec1808, 0x0201f000,
3486 0x00103a28, 0x592c0005, 0x82000580, 0x01000000,
3487 0x04020005, 0x4a034406, 0x00000004, 0x0201f000,
3488 0x0010230c, 0x59a00207, 0x59a01407, 0x900001c0,
3489 0x80081540, 0x59a00209, 0x59a01c09, 0x900001c0,
3490 0x800c1d40, 0x42000800, 0x00000006, 0x832c0400,
3491 0x00000006, 0x0201f000, 0x00103a28, 0x59a00a0a,
3492 0x800409c0, 0x02000000, 0x00102310, 0x82040480,
3493 0x000000e7, 0x04001003, 0x42000800, 0x000000e6,
3494 0x59a00207, 0x59a01407, 0x900001c0, 0x80081540,
3495 0x59a00209, 0x59a01c09, 0x900001c0, 0x800c1d40,
3496 0x83880400, 0x00000000, 0x0201f800, 0x00103a28,
3497 0x4a01d809, 0x001035ff, 0x1c01f000, 0x4031d800,
3498 0x58ef400b, 0x58ec0002, 0x82000580, 0x00000200,
3499 0x02000000, 0x00102304, 0x58ef400b, 0x59a0020b,
3500 0x8c000500, 0x04000008, 0x83880400, 0x00000000,
3501 0x4803c840, 0x4a03c842, 0x00000006, 0x04011000,
3502 0x497b8885, 0x4a034207, 0x000000e6, 0x0201f000,
3503 0x001022c0, 0x800409c0, 0x04000005, 0x4a034406,
3504 0x00000001, 0x0201f000, 0x0010230c, 0x0401fbe5,
3505 0x04020005, 0x4a034406, 0x00000002, 0x0201f000,
3506 0x0010230c, 0x497a5a04, 0x4a025c04, 0x00008000,
3507 0x59a00406, 0x800001c0, 0x02000000, 0x00102310,
3508 0x82001580, 0x000000ff, 0x04000005, 0x82001480,
3509 0x00000004, 0x02021000, 0x00102310, 0x40001000,
3510 0x0201f800, 0x00101fbf, 0x04020005, 0x4a034406,
3511 0x00000003, 0x0201f000, 0x0010230c, 0x4a01d809,
3512 0x0010363a, 0x1c01f000, 0x592c0005, 0x82000580,
3513 0x01000000, 0x02020000, 0x001022c0, 0x4a034406,
3514 0x00000004, 0x0201f000, 0x0010230c, 0x59a01406,
3515 0x8c081508, 0x04020007, 0x800409c0, 0x04000005,
3516 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c,
3517 0x59a01c07, 0x820c0480, 0x00001000, 0x02021000,
3518 0x00102310, 0x497b2804, 0x497b2805, 0x497b281c,
3519 0x497b281d, 0x497b281f, 0x497b2820, 0x497b2822,
3520 0x497b2823, 0x80000580, 0x0201f800, 0x001015fe,
3521 0x59a80805, 0x8c081500, 0x04000004, 0x82040d40,
3522 0x00000011, 0x0401f004, 0x8c081506, 0x04000002,
3523 0x84040d42, 0x84040d0a, 0x48075005, 0x4202d800,
3524 0x00000001, 0x82081500, 0x000000e0, 0x8008010a,
3525 0x0c020036, 0x0201f800, 0x0010513b, 0x04020009,
3526 0x4a035033, 0x00000001, 0x0201f800, 0x001050a2,
3527 0x0401f01f, 0x4a035033, 0x00000000, 0x0401f7fb,
3528 0x497b5032, 0x0201f800, 0x00104142, 0x0201f800,
3529 0x00106c55, 0x0201f800, 0x00106ede, 0x0201f800,
3530 0x00106c4b, 0x59a00a07, 0x480788a7, 0x59c400a3,
3531 0x82000500, 0xfeffffff, 0x82000540, 0x80018000,
3532 0x40000800, 0x84040d20, 0x480388a3, 0x480788a3,
3533 0x497b504e, 0x42000800, 0x0000002d, 0x42001000,
3534 0x001041bc, 0x0201f800, 0x00105f69, 0x59a00407,
3535 0x800000c2, 0x800008c4, 0x8005d400, 0x42000000,
3536 0x0000ffff, 0x0201f800, 0x0010513b, 0x04000003,
3537 0x59a00207, 0x80000110, 0x0201f800, 0x00103afc,
3538 0x0201f000, 0x001022c0, 0x0010366d, 0x00103670,
3539 0x00103678, 0x00102310, 0x00103675, 0x00102310,
3540 0x00102310, 0x00102310, 0x836c0580, 0x00000003,
3541 0x04000005, 0x4a034406, 0x00000007, 0x0201f000,
3542 0x0010230c, 0x59a03c06, 0x59a00407, 0x59a04a07,
3543 0x902449c0, 0x80244d40, 0x59a00409, 0x59a05209,
3544 0x902851c0, 0x80285540, 0x0401fb46, 0x04020005,
3545 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c,
3546 0x417a8800, 0x41783000, 0x497b4001, 0x497b4004,
3547 0x832c4400, 0x00000005, 0x48234002, 0x8c1c3d04,
3548 0x04020078, 0x0201f800, 0x00020245, 0x0402002a,
3549 0x0201f800, 0x001049e7, 0x04000004, 0x0201f800,
3550 0x001048e3, 0x04020024, 0x8c1c3d00, 0x04000008,
3551 0x59340009, 0x44004000, 0x59340008, 0x80204000,
3552 0x44004000, 0x80204000, 0x0401f007, 0x59340007,
3553 0x44004000, 0x59340006, 0x80204000, 0x44004000,
3554 0x80204000, 0x83440580, 0x000007fe, 0x0400000d,
3555 0x83440580, 0x000007fc, 0x0400000a, 0x0201f800,
3556 0x001049f3, 0x04000003, 0x85468d5e, 0x0401f005,
3557 0x0201f800, 0x00104838, 0x04020002, 0x85468d5e,
3558 0x45444000, 0x85468d1e, 0x80204000, 0x82183400,
3559 0x00000003, 0x81468800, 0x83440480, 0x000007f0,
3560 0x0400100e, 0x8c1c3d06, 0x04000010, 0x83440580,
3561 0x000007f0, 0x04020004, 0x42028800, 0x000007fe,
3562 0x0401f006, 0x83440580, 0x000007ff, 0x04020007,
3563 0x42028800, 0x000007fc, 0x82180580, 0x0000000f,
3564 0x0400000b, 0x0401f7c0, 0x801831c0, 0x04020006,
3565 0x59a00801, 0x800408c4, 0x48074406, 0x0201f000,
3566 0x001022c0, 0x4a034004, 0x00000001, 0x49474000,
3567 0x59a00001, 0x80180400, 0x48034001, 0x481f4003,
3568 0x4a01d801, 0x00000000, 0x4819d804, 0x59a00002,
3569 0x4801d803, 0x4825d807, 0x4829d808, 0x4000a800,
3570 0x4000a000, 0x4018b000, 0x0201f800, 0x0010ab17,
3571 0x40ec1000, 0x0201f800, 0x00100858, 0x4a01d809,
3572 0x0010372a, 0x1c01f000, 0x4031d800, 0x58ef400b,
3573 0x58ec0002, 0x82000580, 0x00000200, 0x02000000,
3574 0x00102304, 0x59a00004, 0x80000540, 0x04020008,
3575 0x59a28800, 0x59a04002, 0x59a03803, 0x41783000,
3576 0x58ec4807, 0x58ec5008, 0x0401f78f, 0x59a00801,
3577 0x800408c4, 0x48074406, 0x0201f000, 0x001022c0,
3578 0x0201f800, 0x00020245, 0x0402002f, 0x0201f800,
3579 0x001049e7, 0x04000004, 0x0201f800, 0x001048e3,
3580 0x04020029, 0x83440580, 0x000007fe, 0x04000011,
3581 0x83440580, 0x000007fc, 0x0400000e, 0x0201f800,
3582 0x001049f3, 0x04000005, 0x59340403, 0x8400055e,
3583 0x48026c03, 0x0401f007, 0x0201f800, 0x00104838,
3584 0x04020004, 0x59340403, 0x8400055e, 0x48026c03,
3585 0x4134a000, 0x4020a800, 0x4200b000, 0x00000006,
3586 0x0201f800, 0x0010ab17, 0x59340007, 0x4400a800,
3587 0x59340006, 0x4800a801, 0x59340009, 0x4800a802,
3588 0x59340008, 0x4800a803, 0x59340403, 0x8400051e,
3589 0x48026c03, 0x82204400, 0x0000000a, 0x82183400,
3590 0x0000000a, 0x81468800, 0x83440480, 0x000007f0,
3591 0x0400100e, 0x8c1c3d06, 0x04000010, 0x83440580,
3592 0x000007f0, 0x04020004, 0x42028800, 0x000007fe,
3593 0x0401f006, 0x83440580, 0x000007ff, 0x04020007,
3594 0x42028800, 0x000007fc, 0x82180580, 0x0000000a,
3595 0x0400000b, 0x0401f7bb, 0x801831c0, 0x04020006,
3596 0x59a00801, 0x800408c4, 0x48074406, 0x0201f000,
3597 0x001022c0, 0x4a034004, 0x00000001, 0x49474000,
3598 0x59a00001, 0x80180400, 0x48034001, 0x481f4003,
3599 0x4a01d801, 0x00000000, 0x4819d804, 0x59a00002,
3600 0x4801d803, 0x4825d807, 0x4829d808, 0x40ec1000,
3601 0x0201f800, 0x00100858, 0x4a01d809, 0x001037a1,
3602 0x1c01f000, 0x4031d800, 0x58ef400b, 0x58ec0002,
3603 0x82000580, 0x00000200, 0x02000000, 0x00102304,
3604 0x59a00004, 0x80000540, 0x04020008, 0x59a28800,
3605 0x59a04002, 0x59a03803, 0x41783000, 0x58ec4807,
3606 0x58ec5008, 0x0401f78f, 0x59a00801, 0x800408c4,
3607 0x48074406, 0x0201f000, 0x001022c0, 0x42002800,
3608 0x0000007e, 0x59a00c06, 0x59a01207, 0x59a01c07,
3609 0x59a02209, 0x82040500, 0x0000ff00, 0x840001c0,
3610 0x82003480, 0x00000020, 0x02001000, 0x00102310,
3611 0x80140480, 0x02001000, 0x00102310, 0x82040500,
3612 0x000000ff, 0x82003480, 0x00000020, 0x02001000,
3613 0x00102310, 0x80140480, 0x02001000, 0x00102310,
3614 0x82080500, 0x0000ff00, 0x840001c0, 0x82003480,
3615 0x00000020, 0x02001000, 0x00102310, 0x80140480,
3616 0x02001000, 0x00102310, 0x82080500, 0x000000ff,
3617 0x82003480, 0x00000020, 0x02001000, 0x00102310,
3618 0x80140480, 0x02001000, 0x00102310, 0x820c0500,
3619 0x0000ff00, 0x840001c0, 0x82003480, 0x00000020,
3620 0x02001000, 0x00102310, 0x80140480, 0x02001000,
3621 0x00102310, 0x820c0500, 0x000000ff, 0x82003480,
3622 0x00000020, 0x02001000, 0x00102310, 0x80140480,
3623 0x02001000, 0x00102310, 0x82100500, 0x0000ff00,
3624 0x840001c0, 0x82003480, 0x00000020, 0x02001000,
3625 0x00102310, 0x80140480, 0x02001000, 0x00102310,
3626 0x82100500, 0x000000ff, 0x82003480, 0x00000020,
3627 0x02001000, 0x00102310, 0x80140480, 0x02001000,
3628 0x00102310, 0x900401c0, 0x80080d40, 0x900c01c0,
3629 0x80101d40, 0x83a83400, 0x0000003a, 0x44043000,
3630 0x80183000, 0x440c3000, 0x0201f000, 0x001022c0,
3631 0x0401f9ec, 0x04020005, 0x4a034406, 0x00000002,
3632 0x0201f000, 0x0010230c, 0x42000800, 0x0000000c,
3633 0x0401f853, 0x4a01d809, 0x00103820, 0x1c01f000,
3634 0x4031d800, 0x58ee580d, 0x58ef400b, 0x58ec0002,
3635 0x82000580, 0x00000200, 0x02000000, 0x00102304,
3636 0x832ca400, 0x00000004, 0x4200b000, 0x0000000c,
3637 0x40c8a800, 0x0201f800, 0x0010ab17, 0x58c80200,
3638 0x80000540, 0x04000034, 0x58c80400, 0x82000500,
3639 0xfffffffb, 0x04020030, 0x58c80401, 0x80000540,
3640 0x0400002d, 0x82000480, 0x0000ff01, 0x0402102a,
3641 0x58c80202, 0x82000480, 0x0000005c, 0x04001026,
3642 0x0201f800, 0x001063a3, 0x58c80c08, 0x58c80204,
3643 0x80040480, 0x04001020, 0x58c80204, 0x82000480,
3644 0x00000005, 0x0402101c, 0x58c80205, 0x58c80c08,
3645 0x80040902, 0x80040480, 0x04001017, 0x58c80c08,
3646 0x0201f800, 0x001062f1, 0x0400001b, 0x0201f800,
3647 0x001061b9, 0x04020012, 0x4979940b, 0x59c408a3,
3648 0x82040d40, 0x00000002, 0x480788a3, 0x4a038830,
3649 0x00000001, 0x4a038832, 0x01ffffff, 0x58c80202,
3650 0x48030804, 0x0201f800, 0x0010619b, 0x0201f000,
3651 0x001022c0, 0x0201f000, 0x00102310, 0x0201f800,
3652 0x001063f5, 0x0201f800, 0x00106402, 0x0201f800,
3653 0x001062e4, 0x0201f000, 0x0010230c, 0x4c000000,
3654 0x59a01207, 0x59a00407, 0x900811c0, 0x80081540,
3655 0x59a01a09, 0x59a00409, 0x900c19c0, 0x800c1d40,
3656 0x5c000000, 0x0401f1ac, 0x59840000, 0x82000580,
3657 0x00000000, 0x04000054, 0x59840002, 0x8c000504,
3658 0x04000051, 0x84000546, 0x48030802, 0x0201f800,
3659 0x001062e4, 0x59c408a3, 0x82040d00, 0xfffffffd,
3660 0x480788a3, 0x4c5c0000, 0x4200b800, 0x0010ac00,
3661 0x505e6800, 0x813669c0, 0x04000008, 0x5936600e,
3662 0x813261c0, 0x04000005, 0x0201f800, 0x001062d5,
3663 0x02000800, 0x001064ad, 0x805cb800, 0x825c0580,
3664 0x0010b3f0, 0x040207f3, 0x59866003, 0x813261c0,
3665 0x0400000b, 0x59300406, 0x82000580, 0x00000009,
3666 0x02020800, 0x001005d8, 0x5930b800, 0x0201f800,
3667 0x001062c1, 0x405e6000, 0x0401f7f5, 0x497b0803,
3668 0x4200b800, 0x0010b51b, 0x505e6000, 0x813261c0,
3669 0x04000011, 0x59300406, 0x82000580, 0x00000009,
3670 0x0402000d, 0x59300203, 0x82000580, 0x00000004,
3671 0x04020009, 0x59326809, 0x813669c0, 0x02020800,
3672 0x001005d8, 0x0201f800, 0x00100e99, 0x0201f800,
3673 0x001062c1, 0x4578b800, 0x805cb800, 0x825c0580,
3674 0x0010b523, 0x040207e9, 0x42000800, 0x0010b519,
3675 0x49780801, 0x49780800, 0x59a80069, 0x82000400,
3676 0x00000007, 0x48035069, 0x0201f800, 0x001063f5,
3677 0x0201f800, 0x00106402, 0x5c00b800, 0x0201f800,
3678 0x001061b4, 0x0201f000, 0x001022c0, 0x836c0580,
3679 0x00000003, 0x04000005, 0x4a034406, 0x00000007,
3680 0x0201f000, 0x0010230c, 0x59a00407, 0x59a02207,
3681 0x901021c0, 0x80102540, 0x59a00409, 0x59a02a09,
3682 0x901429c0, 0x80142d40, 0x0401f91e, 0x04020005,
3683 0x4a034406, 0x00000002, 0x0201f000, 0x0010230c,
3684 0x417a8800, 0x41781800, 0x497b4001, 0x497b4003,
3685 0x832c3400, 0x00000004, 0x481b4002, 0x41440000,
3686 0x81ac0400, 0x50026800, 0x813669c0, 0x0400000b,
3687 0x0201f800, 0x001049e7, 0x04020008, 0x59340002,
3688 0x48003000, 0x49443001, 0x82183400, 0x00000002,
3689 0x820c1c00, 0x00000002, 0x81468800, 0x83440480,
3690 0x00000800, 0x04000005, 0x820c0480, 0x00000010,
3691 0x0402100b, 0x0401f7ea, 0x800c19c0, 0x04020006,
3692 0x59a00801, 0x80040902, 0x48074406, 0x0201f000,
3693 0x001022c0, 0x4a034003, 0x00000001, 0x49474000,
3694 0x59a00001, 0x800c0400, 0x48034001, 0x40ec1000,
3695 0x4a001001, 0x00000000, 0x480c1004, 0x59a00002,
3696 0x48001003, 0x48101007, 0x48141008, 0x0201f800,
3697 0x00100858, 0x4a01d809, 0x00103920, 0x1c01f000,
3698 0x4031d800, 0x58ef400b, 0x58ec0002, 0x82000580,
3699 0x00000200, 0x02000000, 0x00102304, 0x59a00003,
3700 0x80000540, 0x04020008, 0x59a28800, 0x59a03002,
3701 0x41781800, 0x40ec1000, 0x58082007, 0x58082808,
3702 0x0401f7bf, 0x59a00801, 0x80040902, 0x48074406,
3703 0x0201f000, 0x001022c0, 0x800409c0, 0x04000005,
3704 0x4a034406, 0x00000001, 0x0201f000, 0x0010230c,
3705 0x59a80026, 0x8c00050a, 0x04020007, 0x8c000506,
3706 0x04020005, 0x4a034406, 0x00000016, 0x0201f000,
3707 0x0010230c, 0x0401f8bb, 0x04020005, 0x4a034406,
3708 0x00000002, 0x0201f000, 0x0010230c, 0x59a00c06,
3709 0x80040902, 0x59a00407, 0x59a01207, 0x900811c0,
3710 0x80081540, 0x59a00409, 0x59a01a09, 0x900c19c0,
3711 0x800c1d40, 0x832c0400, 0x00000005, 0x0401f8ce,
3712 0x4a01d809, 0x0010395b, 0x1c01f000, 0x4031d800,
3713 0x58ef400b, 0x58ee580d, 0x58ec0002, 0x82000580,
3714 0x00000200, 0x02000000, 0x00102304, 0x592c0009,
3715 0x0201f800, 0x00105c9a, 0x02000800, 0x001045a6,
3716 0x02020000, 0x00102310, 0x49474001, 0x481a6802,
3717 0x592c000a, 0x82001d80, 0x70000000, 0x04020007,
3718 0x0401f890, 0x04020011, 0x4a034406, 0x00000002,
3719 0x0201f000, 0x0010230c, 0x82001d80, 0x72000000,
3720 0x02020000, 0x00102310, 0x0401f886, 0x04020885,
3721 0x04020884, 0x04020005, 0x4a034406, 0x00000002,
3722 0x0201f000, 0x0010230c, 0x58ee580d, 0x4a025c04,
3723 0x00008000, 0x497a5a04, 0x592c3208, 0x80183102,
3724 0x592c1801, 0x4a001805, 0x01000000, 0x0201f800,
3725 0x001090d1, 0x04020005, 0x4a034406, 0x00000003,
3726 0x0201f000, 0x0010230c, 0x4a01d809, 0x00103995,
3727 0x1c01f000, 0x592c4000, 0x592c0005, 0x82000580,
3728 0x01000000, 0x04020005, 0x4a034406, 0x00000004,
3729 0x0201f000, 0x0010230c, 0x832c3c00, 0x00000005,
3730 0x401ca000, 0x401ca800, 0x5820280a, 0x4200b000,
3731 0x00000002, 0x82143580, 0x70000000, 0x04000003,
3732 0x4200b000, 0x0000000f, 0x0201f800, 0x0010ab28,
3733 0x401c0000, 0x58201006, 0x58201807, 0x58202205,
3734 0x80102102, 0x82143580, 0x70000000, 0x04020008,
3735 0x82103480, 0x00000002, 0x02001000, 0x00102310,
3736 0x42000800, 0x00000002, 0x0401f06e, 0x82143580,
3737 0x72000000, 0x02020000, 0x00102310, 0x82103480,
3738 0x0000002a, 0x02001000, 0x00102310, 0x42000800,
3739 0x0000000f, 0x0401f863, 0x4a01d809, 0x001039c9,
3740 0x1c01f000, 0x4031d800, 0x58ef400b, 0x58ee580e,
3741 0x58ec0002, 0x82000580, 0x00000200, 0x02000000,
3742 0x00102304, 0x592e5800, 0x832c0c00, 0x00000005,
3743 0x4004a000, 0x4004a800, 0x4200b000, 0x0000000f,
3744 0x0201f800, 0x0010ab28, 0x40ec1000, 0x4a001001,
3745 0x00000000, 0x4a001004, 0x0000000f, 0x48041003,
3746 0x0201f800, 0x00100858, 0x4a01d809, 0x001039e5,
3747 0x1c01f000, 0x4031d800, 0x58ef400b, 0x58ee580e,
3748 0x58ec0002, 0x82000580, 0x00000200, 0x02000000,
3749 0x00102304, 0x832c0c00, 0x00000005, 0x4004a000,
3750 0x4004a800, 0x4200b000, 0x0000000c, 0x0201f800,
3751 0x0010ab28, 0x40ec1000, 0x4a001001, 0x00000000,
3752 0x4a001004, 0x0000000c, 0x48041003, 0x0201f800,
3753 0x00100858, 0x4a01d809, 0x001022b9, 0x1c01f000,
3754 0x0201f800, 0x001007e4, 0x04000010, 0x497a5800,
3755 0x58ec000d, 0x80000540, 0x04020004, 0x492dd80d,
3756 0x492dd80e, 0x0401f007, 0x58ec000e, 0x48025800,
3757 0x82000400, 0x00000001, 0x452c0000, 0x492dd80e,
3758 0x832c0400, 0x00000004, 0x492fc857, 0x4803c857,
3759 0x1c01f000, 0x4d2c0000, 0x48efc857, 0x58ec400d,
3760 0x4823c857, 0x802041c0, 0x04000007, 0x40225800,
3761 0x592c4001, 0x497a5801, 0x0201f800, 0x001007f4,
3762 0x0401f7f8, 0x4979d80d, 0x4979d80e, 0x5c025800,
3763 0x1c01f000, 0x42003000, 0x00000001, 0x0401f003,
3764 0x42003000, 0x00000000, 0x4803c857, 0x4807c857,
3765 0x480bc857, 0x480fc857, 0x481bc857, 0x48efc857,
3766 0x4819d801, 0x800409c0, 0x02000800, 0x001005d8,
3767 0x4805d804, 0x4801d803, 0x4809d807, 0x480dd808,
3768 0x40ec1000, 0x0201f800, 0x00100858, 0x4a01d809,
3769 0x001022b9, 0x1c01f000, 0x80002d80, 0x480bc857,
3770 0x480fc857, 0x4813c857, 0x4817c857, 0x4d2c0000,
3771 0x4da00000, 0x42034000, 0x0010b4a4, 0x59a00017,
3772 0x800001c0, 0x04020013, 0x04006012, 0x480bc020,
3773 0x480fc021, 0x4813c022, 0x4817c023, 0x900811c0,
3774 0x82081540, 0x00000012, 0x480bc011, 0x59e00017,
3775 0x8c000508, 0x04020004, 0x4203e000, 0x30000001,
3776 0x0401f053, 0x4a03c017, 0x00000002, 0x0401f7fb,
3777 0x4c040000, 0x4c1c0000, 0x80000800, 0x48074017,
3778 0x59a0381a, 0x481fc857, 0x801c39c0, 0x04020027,
3779 0x82000480, 0x0000000a, 0x04021010, 0x59a00018,
3780 0x80000000, 0x48034018, 0x59a00219, 0x82000400,
3781 0x00000002, 0x82000c80, 0x00000013, 0x48034219,
3782 0x04001003, 0x497b4219, 0x41780000, 0x59a03816,
3783 0x801c3c00, 0x0401f030, 0x4803c856, 0x0201f800,
3784 0x001007e4, 0x04000007, 0x492f401a, 0x492f401b,
3785 0x412c3800, 0x497b421c, 0x497a5813, 0x0401f026,
3786 0x59880051, 0x80000000, 0x48031051, 0x59a00017,
3787 0x80000040, 0x48034017, 0x59a00219, 0x59a03816,
3788 0x801c3c00, 0x0401f01c, 0x59a0021c, 0x82000400,
3789 0x00000002, 0x82000c80, 0x00000012, 0x04021004,
3790 0x4803421c, 0x801c3c00, 0x0401f013, 0x0201f800,
3791 0x001007e4, 0x0402000b, 0x59880051, 0x80000000,
3792 0x48031051, 0x59a00017, 0x80000040, 0x48034017,
3793 0x4803c856, 0x59a0021c, 0x801c3c00, 0x0401f006,
3794 0x492f401a, 0x492c3813, 0x412c3800, 0x497b421c,
3795 0x497a5813, 0x48083c00, 0x480c3a00, 0x48103c01,
3796 0x48143a01, 0x5c003800, 0x5c000800, 0x5c034000,
3797 0x5c025800, 0x1c01f000, 0x480fc857, 0x4813c857,
3798 0x481bc857, 0x42000000, 0x0010b813, 0x0201f800,
3799 0x0010aa47, 0x801800d0, 0x40002800, 0x42001000,
3800 0x00008014, 0x0401f786, 0x4c000000, 0x599c0017,
3801 0x8c000512, 0x5c000000, 0x1c01f000, 0x4c000000,
3802 0x599c0018, 0x8c00050e, 0x5c000000, 0x1c01f000,
3803 0x59a80821, 0x800409c0, 0x04000005, 0x4a034406,
3804 0x00000001, 0x0201f000, 0x0010230c, 0x836c0580,
3805 0x00000003, 0x04000005, 0x4a034406, 0x00000007,
3806 0x0201f000, 0x0010230c, 0x599c0017, 0x8c00050a,
3807 0x04000005, 0x4a034406, 0x00000008, 0x0201f000,
3808 0x0010230c, 0x59340405, 0x8c000508, 0x04020004,
3809 0x8c00050a, 0x02020000, 0x001034db, 0x497a5a04,
3810 0x497a5805, 0x4a025c04, 0x00008000, 0x0201f800,
3811 0x00109176, 0x04020005, 0x4a034406, 0x00000003,
3812 0x0201f000, 0x0010230c, 0x4a01d809, 0x00103aed,
3813 0x1c01f000, 0x592c0005, 0x82000580, 0x01000000,
3814 0x04020005, 0x4a034406, 0x00000004, 0x0201f000,
3815 0x0010230c, 0x59a28c06, 0x0201f800, 0x00020245,
3816 0x02020000, 0x00102310, 0x0201f000, 0x001034db,
3817 0x82001580, 0x0000ffff, 0x04000009, 0x0201f800,
3818 0x00105c9a, 0x02000800, 0x00020245, 0x0402000c,
3819 0x0201f800, 0x00105fae, 0x0401f009, 0x42028800,
3820 0x000007ef, 0x0201f800, 0x00020245, 0x02000800,
3821 0x00105fae, 0x81468840, 0x040217fb, 0x1c01f000,
3822 0x4803c856, 0x4c0c0000, 0x4d340000, 0x4d440000,
3823 0x42028800, 0x000007fe, 0x0201f800, 0x00020245,
3824 0x04020009, 0x5934180a, 0x820c1d00, 0x00000001,
3825 0x820c1d80, 0x00000001, 0x42001000, 0x0000801b,
3826 0x0401ff1e, 0x5c028800, 0x5c026800, 0x5c001800,
3827 0x1c01f000, 0x599c0017, 0x8c000508, 0x1c01f000,
3828 0x48efc857, 0x04011000, 0x48efc840, 0x4a03c842,
3829 0x00000011, 0x40000000, 0x040117ff, 0x4a01d80f,
3830 0xbeefbeef, 0x1c01f000, 0x497b4000, 0x497b4001,
3831 0x497b4002, 0x497b4003, 0x497b4004, 0x1c01f000,
3832 0x59c400a4, 0x4c580000, 0x4c500000, 0x4c540000,
3833 0x82000500, 0x0000000f, 0x82000480, 0x00000007,
3834 0x0400100a, 0x82006c80, 0x00000006, 0x02021800,
3835 0x001005d8, 0x0c01f807, 0x5c00a800, 0x5c00a000,
3836 0x5c00b000, 0x1c01f000, 0x0401f906, 0x0401f7fb,
3837 0x00103b51, 0x00103b57, 0x00103b7c, 0x00103b9e,
3838 0x00103c59, 0x59c40806, 0x8c040d00, 0x04020003,
3839 0x84040d40, 0x48078806, 0x1c01f000, 0x59c40005,
3840 0x8c000534, 0x02020000, 0x0010429e, 0x4a038805,
3841 0xffffffff, 0x42006000, 0x00020000, 0x0201f800,
3842 0x00104282, 0x59a80015, 0x82000500, 0xfffffffa,
3843 0x84000542, 0x48035015, 0x497b5026, 0x42000800,
3844 0x0010be21, 0x45780800, 0x497b5013, 0x42006000,
3845 0xffefffff, 0x42006800, 0x40000000, 0x0201f800,
3846 0x0010427d, 0x59c40006, 0x82000500, 0xffffff0f,
3847 0x48038806, 0x42000800, 0x00000010, 0x42001000,
3848 0x001041f3, 0x0201f800, 0x00105f83, 0x0401f001,
3849 0x42006000, 0xffffffff, 0x42006800, 0x00800000,
3850 0x0201f800, 0x0010427d, 0x4200b000, 0x000000c8,
3851 0x59c400a4, 0x82000500, 0x0000000f, 0x82000580,
3852 0x0000000a, 0x0400000f, 0x8058b040, 0x040207f9,
3853 0x497b5014, 0x42006000, 0xbf7fffff, 0x42006800,
3854 0x00018000, 0x0201f800, 0x0010427d, 0x42006000,
3855 0xfffeffff, 0x41786800, 0x0201f000, 0x0010427d,
3856 0x497b5014, 0x4a035012, 0x00000000, 0x80000580,
3857 0x0201f000, 0x00104289, 0x4a038805, 0xffffffff,
3858 0x59a80012, 0x82000c80, 0x00000004, 0x02021800,
3859 0x001005d8, 0x0c01f001, 0x00103ba9, 0x00103bd6,
3860 0x00103c4f, 0x4803c856, 0x59c400a3, 0x8400051e,
3861 0x480388a3, 0x4a035012, 0x00000001, 0x59c40008,
3862 0x8400054e, 0x48038808, 0x0201f800, 0x00104263,
3863 0x42007800, 0x0010b54c, 0x4a007806, 0x11010000,
3864 0x4200a000, 0x0010b402, 0x4200a800, 0x0010b553,
3865 0x4200b000, 0x00000002, 0x0201f800, 0x0010ab17,
3866 0x497b8802, 0x42000800, 0x00000003, 0x497b504a,
3867 0x0201f800, 0x0010416e, 0x4a03504a, 0x00000001,
3868 0x497b5016, 0x0201f800, 0x00104290, 0x42006000,
3869 0xffffffff, 0x42006800, 0x00080000, 0x0201f800,
3870 0x0010427d, 0x42006000, 0xfff7ffff, 0x41786800,
3871 0x0201f000, 0x0010427d, 0x59a80016, 0x497b5016,
3872 0x80002540, 0x04000066, 0x59c40004, 0x82000500,
3873 0x00000003, 0x04020071, 0x59a80815, 0x8c040d02,
3874 0x0400004b, 0x82100580, 0x0000000c, 0x0402004f,
3875 0x82100400, 0x00000018, 0x8000b104, 0x41cc1000,
3876 0x42001800, 0x0010b54c, 0x50080800, 0x500c0000,
3877 0x80040580, 0x0402001a, 0x80081000, 0x800c1800,
3878 0x8058b040, 0x040207f9, 0x0201f800, 0x00104290,
3879 0x42006000, 0xffffffff, 0x42006800, 0x00500000,
3880 0x0201f800, 0x0010427d, 0x4a035012, 0x00000002,
3881 0x4a035014, 0x00000002, 0x42000800, 0x000007d0,
3882 0x42001000, 0x00104148, 0x0201f800, 0x0010606e,
3883 0x0201f800, 0x00104263, 0x0401f048, 0x59cc0806,
3884 0x82040d80, 0x11010000, 0x04020028, 0x59cc0800,
3885 0x82040500, 0x00ffffff, 0x0400001a, 0x82000580,
3886 0x000000ef, 0x04020017, 0x59cc0801, 0x82040500,
3887 0x00ffffff, 0x82000580, 0x000000ef, 0x04020011,
3888 0x83cca400, 0x00000007, 0x4200a800, 0x0010b402,
3889 0x4200b000, 0x00000002, 0x50500800, 0x50540000,
3890 0x80040480, 0x04001007, 0x04020010, 0x8050a000,
3891 0x8054a800, 0x8058b040, 0x040207f8, 0x0401f00b,
3892 0x59a80015, 0x84000502, 0x48035015, 0x41cca000,
3893 0x4200a800, 0x0010b54c, 0x4200b000, 0x00000009,
3894 0x0201f800, 0x0010ab17, 0x0201f800, 0x00104290,
3895 0x42006000, 0xffffffff, 0x42006800, 0x00080000,
3896 0x0201f800, 0x0010427d, 0x42006000, 0xfff7ffff,
3897 0x41786800, 0x0201f800, 0x0010427d, 0x42006000,
3898 0xffffffff, 0x42006800, 0x00004000, 0x0201f800,
3899 0x0010427d, 0x59c40004, 0x82000500, 0x00000003,
3900 0x04020006, 0x497b5016, 0x42000800, 0x00000003,
3901 0x0201f000, 0x0010416e, 0x1c01f000, 0x1c01f000,
3902 0x59a80014, 0x82006d80, 0x0000000f, 0x04000005,
3903 0x82000580, 0x0000001b, 0x02020800, 0x00104139,
3904 0x1c01f000, 0x59a80015, 0x84000506, 0x48035015,
3905 0x497b504a, 0x59a80014, 0x82000c80, 0x0000001e,
3906 0x02021800, 0x001005d8, 0x0c01f001, 0x00103c97,
3907 0x00103cac, 0x00103cd5, 0x00103cf0, 0x00103d14,
3908 0x00103d45, 0x00103d68, 0x00103d9b, 0x00103dbe,
3909 0x00103de4, 0x00103e21, 0x00103e48, 0x00103e5f,
3910 0x00103e71, 0x00103e8a, 0x00103ea0, 0x00103ea5,
3911 0x00103ecd, 0x00103ef0, 0x00103f16, 0x00103f39,
3912 0x00103f6c, 0x00103fae, 0x00103fd8, 0x00103ff0,
3913 0x00104030, 0x00104049, 0x0010405c, 0x0010405d,
3914 0x4803c856, 0x4202d800, 0x00000007, 0x0201f800,
3915 0x0010513b, 0x04000007, 0x42006000, 0xffffffd7,
3916 0x41786800, 0x0201f800, 0x0010427d, 0x0401f00b,
3917 0x59c40006, 0x82000500, 0xffffff0f, 0x48038806,
3918 0x42001000, 0x000000f0, 0x0201f800, 0x0010193d,
3919 0x0201f800, 0x00105098, 0x1c01f000, 0x4803c856,
3920 0x42006000, 0xbf7fffff, 0x42006800, 0x00400000,
3921 0x0201f800, 0x0010427d, 0x4a035014, 0x00000001,
3922 0x42001000, 0x001041f3, 0x0201f800, 0x00105fa4,
3923 0x0201f800, 0x001041f8, 0x42000800, 0x000007d0,
3924 0x42001000, 0x00104148, 0x0201f000, 0x0010606e,
3925 0x59a80016, 0x82000580, 0x00000014, 0x04020025,
3926 0x4803c857, 0x42006000, 0xffbfffff, 0x41786800,
3927 0x0201f800, 0x0010427d, 0x59c40004, 0x82000500,
3928 0x00000003, 0x0402001b, 0x59cc1006, 0x82081580,
3929 0x11020000, 0x04020016, 0x59cc1007, 0x8c08153e,
3930 0x0400000b, 0x59a80015, 0x8c000504, 0x04020008,
3931 0x42000000, 0x0010b83f, 0x0201f800, 0x0010aa47,
3932 0x59a80015, 0x84000544, 0x48035015, 0x42001000,
3933 0x00104148, 0x0201f800, 0x00105f90, 0x4a035014,
3934 0x00000010, 0x0401f9d4, 0x0401f002, 0x497b5016,
3935 0x1c01f000, 0x4803c856, 0x4a035014, 0x00000003,
3936 0x42006000, 0xbf3fffff, 0x42006800, 0x00100000,
3937 0x0201f800, 0x0010427d, 0x42001000, 0x001041f3,
3938 0x0201f800, 0x00105fa4, 0x0201f800, 0x001041f8,
3939 0x42001000, 0x00104148, 0x0201f800, 0x00105f90,
3940 0x42007800, 0x0010b552, 0x46007800, 0x11020000,
3941 0x42000800, 0x00000005, 0x0201f000, 0x0010416e,
3942 0x59a80016, 0x80000540, 0x04000021, 0x4803c857,
3943 0x42001000, 0x00104148, 0x0201f800, 0x00105f90,
3944 0x59a80016, 0x82000580, 0x00000014, 0x04020016,
3945 0x59cc1006, 0x82081580, 0x11020000, 0x04020012,
3946 0x59cc1007, 0x8c08153e, 0x0400000b, 0x59a80015,
3947 0x8c000504, 0x04020008, 0x42000000, 0x0010b83f,
3948 0x0201f800, 0x0010aa47, 0x59a80015, 0x84000544,
3949 0x48035015, 0x4a035014, 0x00000004, 0x0401f805,
3950 0x0401f003, 0x0201f800, 0x00104139, 0x1c01f000,
3951 0x4803c856, 0x4a035014, 0x00000005, 0x83cca400,
3952 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000,
3953 0x00000005, 0x0201f800, 0x0010ab17, 0x42007800,
3954 0x0010b552, 0x46007800, 0x11030000, 0x0201f800,
3955 0x0010413e, 0x04020014, 0x59a80015, 0x8c000500,
3956 0x04020011, 0x59a80810, 0x82040580, 0x00ffffff,
3957 0x0400000d, 0x82040d00, 0x000000ff, 0x82040400,
3958 0x0010210e, 0x50000800, 0x80040910, 0x42001000,
3959 0x00000004, 0x0401fb9b, 0x0400000b, 0x0201f800,
3960 0x0010420d, 0x4200b000, 0x00000004, 0x83cca400,
3961 0x00000007, 0x4200a800, 0x0010b553, 0x0201f800,
3962 0x0010ab17, 0x42000800, 0x00000005, 0x0201f000,
3963 0x0010416e, 0x59a80016, 0x80000540, 0x04000020,
3964 0x4803c857, 0x42001000, 0x00104148, 0x0201f800,
3965 0x00105f90, 0x59a80016, 0x82000580, 0x00000014,
3966 0x04020016, 0x59cc1006, 0x82081580, 0x11030000,
3967 0x04020012, 0x59cc1007, 0x8c08153e, 0x0400000b,
3968 0x59a80015, 0x8c000504, 0x04020008, 0x42000000,
3969 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015,
3970 0x84000544, 0x48035015, 0x4a035014, 0x00000006,
3971 0x0401f804, 0x0401f002, 0x0401fbd3, 0x1c01f000,
3972 0x4803c856, 0x4a035014, 0x00000007, 0x83cca400,
3973 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000,
3974 0x00000005, 0x0201f800, 0x0010ab17, 0x42007800,
3975 0x0010b552, 0x46007800, 0x11040000, 0x0401fbc7,
3976 0x04020020, 0x59a80015, 0x8c000500, 0x0402001d,
3977 0x599c0017, 0x8c000500, 0x0400001a, 0x599c1402,
3978 0x82080480, 0x0000007f, 0x02021800, 0x001005d8,
3979 0x4c080000, 0x82081400, 0x0010210e, 0x50081000,
3980 0x82081500, 0x000000ff, 0x480b5010, 0x42000800,
3981 0x00000003, 0x0201f800, 0x00106c78, 0x5c000800,
3982 0x42001000, 0x00000004, 0x0401fb3e, 0x04000005,
3983 0x0401fd2b, 0x04000003, 0x0201f800, 0x001015fe,
3984 0x42000800, 0x00000005, 0x0401f3d4, 0x59a80016,
3985 0x80000540, 0x04000020, 0x4803c857, 0x42001000,
3986 0x00104148, 0x0201f800, 0x00105f90, 0x59a80016,
3987 0x82000580, 0x00000014, 0x04020016, 0x59cc1006,
3988 0x82081580, 0x11040000, 0x04020012, 0x59cc1007,
3989 0x8c08153e, 0x0400000b, 0x59a80015, 0x8c000504,
3990 0x04020008, 0x42000000, 0x0010b83f, 0x0201f800,
3991 0x0010aa47, 0x59a80015, 0x84000544, 0x48035015,
3992 0x4a035014, 0x00000008, 0x0401f804, 0x0401f002,
3993 0x0401fb7d, 0x1c01f000, 0x4803c856, 0x4a035014,
3994 0x00000009, 0x83cca400, 0x00000006, 0x4200a800,
3995 0x0010b552, 0x4200b000, 0x00000005, 0x0201f800,
3996 0x0010ab17, 0x42007800, 0x0010b552, 0x46007800,
3997 0x11050100, 0x0401fb71, 0x0402000a, 0x59a80015,
3998 0x8c000500, 0x04020007, 0x0401fa8c, 0x04020005,
3999 0x82000540, 0x00000001, 0x0201f800, 0x001015fe,
4000 0x42000800, 0x00000005, 0x0401fb94, 0x0401fb63,
4001 0x04020ea4, 0x4d3c0000, 0x42027800, 0x00000001,
4002 0x0201f800, 0x00109874, 0x5c027800, 0x1c01f000,
4003 0x59a80016, 0x80000540, 0x0400003a, 0x4803c857,
4004 0x42001000, 0x00104148, 0x0201f800, 0x00105f90,
4005 0x59a80016, 0x82000580, 0x00000014, 0x04020030,
4006 0x59cc1006, 0x82080500, 0x11050000, 0x82000580,
4007 0x11050000, 0x0402002a, 0x8c081510, 0x04000014,
4008 0x59cc1007, 0x8c08153e, 0x0400000b, 0x59a80015,
4009 0x8c000504, 0x04020008, 0x42000000, 0x0010b83f,
4010 0x0201f800, 0x0010aa47, 0x59a80015, 0x84000544,
4011 0x48035015, 0x4a035013, 0x00000001, 0x4a035014,
4012 0x0000000a, 0x0401f818, 0x0401f016, 0x80000540,
4013 0x04020013, 0x59cc1007, 0x8c08153e, 0x0400000b,
4014 0x59a80015, 0x8c000504, 0x04020008, 0x42000000,
4015 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015,
4016 0x84000544, 0x48035015, 0x497b5013, 0x4a035014,
4017 0x0000000e, 0x0401f86d, 0x0401f002, 0x0401fb1a,
4018 0x1c01f000, 0x4803c856, 0x4a035014, 0x0000000b,
4019 0x42001000, 0x0010b553, 0x4008a800, 0x4200b000,
4020 0x00000020, 0x4600a800, 0xffffffff, 0x8054a800,
4021 0x8058b040, 0x040207fc, 0x42007800, 0x0010b552,
4022 0x46007800, 0x11060000, 0x42001000, 0x0010b553,
4023 0x0401fb0a, 0x04000005, 0x50080000, 0x46001000,
4024 0x00ffffff, 0x0401f00c, 0x50080800, 0x82040d00,
4025 0x0000ffff, 0x59a80010, 0x82000500, 0x000000ff,
4026 0x82000540, 0x00000100, 0x800000e0, 0x80040d40,
4027 0x44041000, 0x42000800, 0x00000021, 0x0401f327,
4028 0x59a80016, 0x80000540, 0x04000014, 0x4803c857,
4029 0x59a80016, 0x42001000, 0x00104148, 0x0201f800,
4030 0x00105f90, 0x59a80016, 0x82000580, 0x00000084,
4031 0x04020009, 0x59cc1006, 0x82081580, 0x11060000,
4032 0x04020005, 0x4a035014, 0x0000000c, 0x0401f804,
4033 0x0401f002, 0x0401fadc, 0x1c01f000, 0x4803c856,
4034 0x4a035014, 0x0000000d, 0x83cca400, 0x00000006,
4035 0x4200a800, 0x0010b552, 0x4200b000, 0x00000021,
4036 0x0201f800, 0x0010ab17, 0x42007800, 0x0010b552,
4037 0x46007800, 0x11070000, 0x42000800, 0x00000021,
4038 0x0401f2fe, 0x59a80016, 0x80000540, 0x04000016,
4039 0x4803c857, 0x59a80016, 0x42001000, 0x00104148,
4040 0x0201f800, 0x00105f90, 0x82000580, 0x00000084,
4041 0x0402000c, 0x59cc1006, 0x82081580, 0x11070000,
4042 0x04020008, 0x4a035013, 0x00000001, 0x0401fa91,
4043 0x4a035014, 0x0000000e, 0x0401f804, 0x0401f002,
4044 0x0401fab1, 0x1c01f000, 0x4803c856, 0x82040d40,
4045 0x00000001, 0x0401fbfc, 0x4a035014, 0x0000000f,
4046 0x497b5016, 0x42006000, 0xffffffff, 0x42006800,
4047 0x00300000, 0x0401fbe8, 0x42006000, 0xffdfffff,
4048 0x41786800, 0x0401fbe4, 0x42000800, 0x000007d0,
4049 0x42001000, 0x00104148, 0x0201f000, 0x00105f69,
4050 0x4803c856, 0x59a80016, 0x80000540, 0x04020296,
4051 0x1c01f000, 0x4803c856, 0x4a035014, 0x00000011,
4052 0x83cca400, 0x00000006, 0x4200a800, 0x0010b552,
4053 0x4200b000, 0x00000005, 0x0201f800, 0x0010ab17,
4054 0x4200a800, 0x0010b552, 0x4600a800, 0x11020000,
4055 0x0401fa8a, 0x04020015, 0x59a80010, 0x82000d00,
4056 0xffff0000, 0x04000011, 0x82000500, 0x000000ff,
4057 0x0400000e, 0x82000c00, 0x0010210e, 0x50040800,
4058 0x80040910, 0x82040580, 0x0000007e, 0x04000007,
4059 0x82040580, 0x00000080, 0x04000004, 0x42001000,
4060 0x00000004, 0x0401fa07, 0x42000800, 0x00000005,
4061 0x0401f2a2, 0x59a80016, 0x80000540, 0x04000020,
4062 0x4803c857, 0x42001000, 0x00104148, 0x0201f800,
4063 0x00105f90, 0x59a80016, 0x82000580, 0x00000014,
4064 0x04020016, 0x59cc1006, 0x82081580, 0x11030000,
4065 0x04020012, 0x59cc1007, 0x8c08153e, 0x0400000b,
4066 0x59a80015, 0x8c000504, 0x04020008, 0x42000000,
4067 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015,
4068 0x84000544, 0x48035015, 0x4a035014, 0x00000012,
4069 0x0401f804, 0x0401f002, 0x0401fa4b, 0x1c01f000,
4070 0x4803c856, 0x4a035014, 0x00000013, 0x83cca400,
4071 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000,
4072 0x00000005, 0x0201f800, 0x0010ab17, 0x4200a800,
4073 0x0010b552, 0x4600a800, 0x11030000, 0x0401fa3f,
4074 0x04020013, 0x59a80015, 0x8c000500, 0x04020010,
4075 0x59a80810, 0x82040580, 0x00ffffff, 0x0400000c,
4076 0x82040d00, 0x000000ff, 0x82040400, 0x0010210e,
4077 0x50000800, 0x80040910, 0x42001000, 0x00000004,
4078 0x0401f9c0, 0x04000002, 0x0401fafb, 0x42000800,
4079 0x00000005, 0x0401f259, 0x59a80016, 0x80000540,
4080 0x04000020, 0x4803c857, 0x42001000, 0x00104148,
4081 0x0201f800, 0x00105f90, 0x59a80016, 0x82000580,
4082 0x00000014, 0x04020016, 0x59cc1006, 0x82081580,
4083 0x11040000, 0x04020012, 0x59cc1007, 0x8c08153e,
4084 0x0400000b, 0x59a80015, 0x8c000504, 0x04020008,
4085 0x42000000, 0x0010b83f, 0x0201f800, 0x0010aa47,
4086 0x59a80015, 0x84000544, 0x48035015, 0x4a035014,
4087 0x00000014, 0x0401f804, 0x0401f002, 0x0401fa02,
4088 0x1c01f000, 0x4803c856, 0x4a035014, 0x00000015,
4089 0x83cca400, 0x00000006, 0x4200a800, 0x0010b552,
4090 0x4200b000, 0x00000005, 0x0201f800, 0x0010ab17,
4091 0x4200a800, 0x0010b552, 0x4600a800, 0x11040000,
4092 0x0401f9f6, 0x04020020, 0x59a80015, 0x8c000500,
4093 0x0402001d, 0x599c0017, 0x8c000500, 0x0400001a,
4094 0x599c1402, 0x82080480, 0x0000007f, 0x02021800,
4095 0x001005d8, 0x4c080000, 0x82081400, 0x0010210e,
4096 0x50081000, 0x82081500, 0x000000ff, 0x480b5010,
4097 0x42000800, 0x00000003, 0x0201f800, 0x00106c78,
4098 0x5c000800, 0x42001000, 0x00000004, 0x0401f96d,
4099 0x04000005, 0x0201f800, 0x00103abf, 0x02020800,
4100 0x001015fe, 0x42000800, 0x00000005, 0x0401f203,
4101 0x59a80016, 0x80000540, 0x0400003f, 0x4803c857,
4102 0x42001000, 0x00104148, 0x0201f800, 0x00105f90,
4103 0x59a80016, 0x82000580, 0x00000014, 0x04020035,
4104 0x59cc1006, 0x82080500, 0x11050000, 0x82000580,
4105 0x11050000, 0x0402002f, 0x8c081510, 0x04000010,
4106 0x0401fb09, 0x59cc1007, 0x8c08153e, 0x0400000b,
4107 0x59a80015, 0x8c000504, 0x04020008, 0x42000000,
4108 0x0010b83f, 0x0201f800, 0x0010aa47, 0x59a80015,
4109 0x84000544, 0x48035015, 0x0401f013, 0x59cc1007,
4110 0x8c08153e, 0x0400000b, 0x59a80015, 0x8c000504,
4111 0x04020008, 0x42000000, 0x0010b83f, 0x0201f800,
4112 0x0010aa47, 0x59a80015, 0x84000544, 0x48035015,
4113 0x82000540, 0x00000001, 0x0401faeb, 0x497b5013,
4114 0x0401f003, 0x4a035013, 0x00000001, 0x59cc1007,
4115 0x8c08153c, 0x04000003, 0x4a035026, 0x00000008,
4116 0x4a035014, 0x00000016, 0x0401f804, 0x0401f002,
4117 0x0401f98d, 0x1c01f000, 0x4803c856, 0x83cca400,
4118 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000,
4119 0x00000005, 0x0201f800, 0x0010ab17, 0x4a035014,
4120 0x00000017, 0x59a80013, 0x8c000500, 0x04000006,
4121 0x42001000, 0x0010b552, 0x46001000, 0x11050100,
4122 0x0401f003, 0x4a035014, 0x0000001b, 0x0401f97b,
4123 0x0402000a, 0x59a80015, 0x8c000500, 0x04020007,
4124 0x0401f896, 0x04020005, 0x82000540, 0x00000001,
4125 0x0201f800, 0x001015fe, 0x42000800, 0x00000005,
4126 0x0401f99e, 0x4d3c0000, 0x42027800, 0x00000001,
4127 0x0201f800, 0x00109874, 0x5c027800, 0x1c01f000,
4128 0x59a80016, 0x80000540, 0x04000015, 0x4803c857,
4129 0x42001000, 0x00104148, 0x0201f800, 0x00105f90,
4130 0x59a80016, 0x82000580, 0x00000084, 0x0402000b,
4131 0x59cc1006, 0x82081580, 0x11060000, 0x04020007,
4132 0x80000580, 0x0401faa0, 0x4a035014, 0x00000018,
4133 0x0401f804, 0x0401f002, 0x0401f94b, 0x1c01f000,
4134 0x4803c856, 0x4a035014, 0x00000019, 0x83cca400,
4135 0x00000006, 0x4200a800, 0x0010b552, 0x4200b000,
4136 0x00000021, 0x0201f800, 0x0010ab17, 0x42003800,
4137 0x0010b553, 0x0401f941, 0x04020018, 0x401c2800,
4138 0x50141000, 0x80080130, 0x80000000, 0x40001800,
4139 0x82081500, 0x00ffffff, 0x800000f0, 0x80080540,
4140 0x44002800, 0x59a80810, 0x82040d00, 0x000000ff,
4141 0x400c1000, 0x80081104, 0x82082400, 0x0010b553,
4142 0x50101000, 0x820c0500, 0x00000003, 0x0c01f806,
4143 0x80081540, 0x44082000, 0x42000800, 0x00000021,
4144 0x0401f156, 0x0010401d, 0x00104022, 0x00104027,
4145 0x0010402c, 0x800408f0, 0x40040000, 0x82081500,
4146 0x00ffffff, 0x1c01f000, 0x800408e0, 0x40040000,
4147 0x82081500, 0xff00ffff, 0x1c01f000, 0x800408d0,
4148 0x40040000, 0x82081500, 0xffff00ff, 0x1c01f000,
4149 0x40040000, 0x82081500, 0xffffff00, 0x1c01f000,
4150 0x59a80016, 0x80000540, 0x04000016, 0x4803c857,
4151 0x42001000, 0x00104148, 0x0201f800, 0x00105f90,
4152 0x59a80016, 0x82000580, 0x00000084, 0x0402000c,
4153 0x59cc1006, 0x82081580, 0x11070000, 0x04020008,
4154 0x4a035013, 0x00000001, 0x0401f8d2, 0x4a035014,
4155 0x0000001a, 0x0401f804, 0x0401f002, 0x0401f8f2,
4156 0x1c01f000, 0x82000540, 0x00000001, 0x0401fa3e,
4157 0x4a035014, 0x0000001b, 0x83cca400, 0x00000006,
4158 0x4200a800, 0x0010b552, 0x59a82016, 0x40100000,
4159 0x8000b104, 0x40580800, 0x5450a800, 0x8050a000,
4160 0x8054a800, 0x8058b040, 0x040207fc, 0x0401f113,
4161 0x1c01f000, 0x1c01f000, 0x4803c856, 0x42003000,
4162 0x00000004, 0x42004000, 0x0010b553, 0x599c2817,
4163 0x8c142d14, 0x0402001f, 0x42001000, 0x00000003,
4164 0x40200000, 0x80080400, 0x50000800, 0x82042580,
4165 0xffffffff, 0x04020005, 0x80081040, 0x80183040,
4166 0x040207f8, 0x0401f05e, 0x800811c0, 0x04020006,
4167 0x82042580, 0x3fffffff, 0x04000058, 0x82040d40,
4168 0xc0000000, 0x4200b000, 0x00000020, 0x42001800,
4169 0x00000001, 0x40042000, 0x80102102, 0x04021021,
4170 0x800c18c2, 0x8058b040, 0x040207fc, 0x0401f04b,
4171 0x41781000, 0x40200000, 0x80080400, 0x50000800,
4172 0x82042580, 0xffffffff, 0x04020005, 0x80081000,
4173 0x80183040, 0x040207f8, 0x0401f040, 0x800811c0,
4174 0x04020003, 0x82040d40, 0xc0000000, 0x4200b000,
4175 0x00000001, 0x42001800, 0x80000000, 0x40042000,
4176 0x801020c2, 0x04021007, 0x800c1902, 0x8058b000,
4177 0x82580480, 0x00000021, 0x040017fa, 0x0401f02f,
4178 0x40200000, 0x80082400, 0x50100000, 0x800c0540,
4179 0x44002000, 0x59a80015, 0x84000540, 0x48035015,
4180 0x40580000, 0x42002800, 0x00000020, 0x80142c80,
4181 0x40080000, 0x42003800, 0x00000003, 0x801c0480,
4182 0x800000ca, 0x80142d40, 0x82144c00, 0x0010210e,
4183 0x50242800, 0x82142d00, 0x000000ff, 0x48175010,
4184 0x4c040000, 0x40140800, 0x0201f800, 0x001015eb,
4185 0x5c000800, 0x40001800, 0x500c0000, 0x80100540,
4186 0x44001800, 0x59a80015, 0x84000540, 0x48035015,
4187 0x4200a800, 0x0010b553, 0x4020a000, 0x4200b000,
4188 0x00000004, 0x0201f800, 0x0010ab17, 0x82000540,
4189 0x00000001, 0x0401f002, 0x80000580, 0x1c01f000,
4190 0x4807c857, 0x480bc857, 0x4008b000, 0x83cca400,
4191 0x00000007, 0x4200a800, 0x0010b553, 0x40541000,
4192 0x0201f800, 0x0010ab17, 0x40041800, 0x41782000,
4193 0x42000000, 0x00000003, 0x820c1c80, 0x00000020,
4194 0x04001004, 0x80102000, 0x80000040, 0x0401f7fb,
4195 0x40041800, 0x801021c0, 0x04000005, 0x820c1c80,
4196 0x00000020, 0x80102040, 0x040207fd, 0x42002000,
4197 0x00000001, 0x800c19c0, 0x04000004, 0x801020c2,
4198 0x800c1840, 0x040207fe, 0x80083c00, 0x83cc2c00,
4199 0x00000007, 0x80142c00, 0x50140000, 0x80102d00,
4200 0x04020012, 0x80100540, 0x44003800, 0x82042400,
4201 0x0010210e, 0x50102800, 0x82142d00, 0x000000ff,
4202 0x48175010, 0x4c040000, 0x40140800, 0x0201f800,
4203 0x001015eb, 0x5c000800, 0x59a80015, 0x84000540,
4204 0x48035015, 0x80000580, 0x1c01f000, 0x4807c856,
4205 0x42001000, 0x00008017, 0x59a8184e, 0x0201f800,
4206 0x0010aa4f, 0x0201f800, 0x00103a3e, 0x1c01f000,
4207 0x4807c856, 0x4200b000, 0x00000020, 0x83cca400,
4208 0x00000007, 0x4200a800, 0x0010be21, 0x0201f000,
4209 0x0010ab28, 0x4807c856, 0x0201f800, 0x00106ede,
4210 0x42000800, 0x000000f7, 0x0401f8de, 0x497b2804,
4211 0x497b2805, 0x497b281c, 0x497b281d, 0x4202d800,
4212 0x00000001, 0x42006000, 0xbf7fffff, 0x42006800,
4213 0x00018000, 0x0401f950, 0x42006000, 0xfffeffff,
4214 0x41786800, 0x0401f94c, 0x497b504e, 0x42000800,
4215 0x0000002d, 0x42001000, 0x001041bc, 0x0201f000,
4216 0x00105f69, 0x4807c856, 0x0401ffe3, 0x497b5014,
4217 0x497b5016, 0x1c01f000, 0x4807c856, 0x59a80005,
4218 0x8c000506, 0x1c01f000, 0x4807c856, 0x42006000,
4219 0xffffffff, 0x42006800, 0x00000028, 0x0401f136,
4220 0x4807c856, 0x0401ffc2, 0x0201f800, 0x00106c55,
4221 0x4df00000, 0x0201f800, 0x00106e21, 0x5c03e000,
4222 0x02000800, 0x00106c4b, 0x59c400a4, 0x82000500,
4223 0x0000000f, 0x82000580, 0x00000002, 0x0402000a,
4224 0x42006000, 0xffffffff, 0x42006800, 0x00200000,
4225 0x0401f921, 0x42006000, 0xffdfffff, 0x41786800,
4226 0x0401f91d, 0x497b5014, 0x42000800, 0x000000f7,
4227 0x0401f89c, 0x59c400a3, 0x82000500, 0xbf20bfff,
4228 0x82000540, 0x0001c000, 0x480388a3, 0x84000520,
4229 0x480388a3, 0x1c01f000, 0x497b5016, 0x59b400f5,
4230 0x8c000500, 0x04020004, 0x82000540, 0x00000001,
4231 0x480368f5, 0x800400c4, 0x82000400, 0x00002000,
4232 0x4803910a, 0x59b400f6, 0x82000500, 0x00000018,
4233 0x040207fd, 0x4a0368f0, 0x0010b54b, 0x42000000,
4234 0x0010b552, 0x480368f1, 0x82040400, 0x0000dc00,
4235 0x480368f3, 0x59c400a4, 0x82000500, 0x0000000f,
4236 0x82000580, 0x00000008, 0x04020017, 0x4c5c0000,
4237 0x4c600000, 0x59c4b805, 0x8c5cbd3a, 0x04020005,
4238 0x42000000, 0x0010b818, 0x0201f800, 0x0010aa47,
4239 0x4a038805, 0x02000000, 0x0201f800, 0x001019fe,
4240 0x4000c000, 0x0201f800, 0x00101963, 0x4202d800,
4241 0x00000001, 0x497b5014, 0x5c00c000, 0x5c00b800,
4242 0x1c01f000, 0x59c8010b, 0x8c000502, 0x040007e2,
4243 0x59c408a4, 0x82040d00, 0x0000000f, 0x82040d80,
4244 0x0000000b, 0x04020005, 0x59a80814, 0x82040d40,
4245 0x00002000, 0x0401f004, 0x59a80812, 0x82040d40,
4246 0x00001000, 0x4807504e, 0x59a8084a, 0x800409c0,
4247 0x04020007, 0x42000800, 0x000007d0, 0x42001000,
4248 0x00104148, 0x0201f800, 0x0010606e, 0x1c01f000,
4249 0x4807c856, 0x0401ff4e, 0x0201f800, 0x00106c55,
4250 0x4df00000, 0x0201f800, 0x00106e21, 0x5c03e000,
4251 0x02000800, 0x00106c4b, 0x59c400a4, 0x82000500,
4252 0x0000000f, 0x82000580, 0x00000002, 0x0402000a,
4253 0x42006000, 0xffffffff, 0x42006800, 0x00200000,
4254 0x0401f8ad, 0x42006000, 0xffdfffff, 0x41786800,
4255 0x0401f8a9, 0x0201f800, 0x00105141, 0x04000014,
4256 0x0201f800, 0x00105151, 0x04020011, 0x4a035032,
4257 0x0000aaaa, 0x4c040000, 0x0201f800, 0x0010162a,
4258 0x59a8002a, 0x82000500, 0xffff0000, 0x80040540,
4259 0x4803502a, 0x5c000800, 0x4a035033, 0x00000000,
4260 0x0201f800, 0x001050a2, 0x0401f008, 0x4a03504c,
4261 0x00000005, 0x42000000, 0x00000001, 0x0201f800,
4262 0x00101590, 0x0401ff2c, 0x1c01f000, 0x0401f805,
4263 0x42006000, 0xbf7f7fff, 0x41786800, 0x0401f086,
4264 0x0201f800, 0x00105151, 0x04020005, 0x59c40006,
4265 0x82000540, 0x000000f0, 0x48038806, 0x1c01f000,
4266 0x800408d0, 0x59a80015, 0x8c000506, 0x04000006,
4267 0x59a80010, 0x82000500, 0x000000ff, 0x80040540,
4268 0x0401f003, 0x82040540, 0x000000f7, 0x480388a7,
4269 0x1c01f000, 0x4807c856, 0x42000000, 0x0010b83b,
4270 0x0201f800, 0x0010aa47, 0x42003000, 0x00000005,
4271 0x4d3c0000, 0x4c180000, 0x42003000, 0x0000000d,
4272 0x42027800, 0x00000002, 0x0401f038, 0x4807c856,
4273 0x42000000, 0x0010b86b, 0x0201f800, 0x0010aa47,
4274 0x42003000, 0x00000000, 0x4d3c0000, 0x4c180000,
4275 0x42003000, 0x0000000f, 0x42027800, 0x00000002,
4276 0x0401f02a, 0x4807c856, 0x42000000, 0x0010b86a,
4277 0x0201f800, 0x0010aa47, 0x42003000, 0x00000003,
4278 0x4d3c0000, 0x4c180000, 0x42003000, 0x0000000e,
4279 0x42027800, 0x00000202, 0x0401f01c, 0x4807c856,
4280 0x42000000, 0x0010b869, 0x0201f800, 0x0010aa47,
4281 0x42003000, 0x00000004, 0x4d3c0000, 0x4c180000,
4282 0x42003000, 0x00000010, 0x42027800, 0x00000202,
4283 0x0401f00e, 0x4807c856, 0x42000000, 0x0010b83e,
4284 0x0201f800, 0x0010aa47, 0x42003000, 0x00000001,
4285 0x4d3c0000, 0x4c180000, 0x42003000, 0x0000000c,
4286 0x42027800, 0x00000202, 0x42001800, 0x0000ffff,
4287 0x42002000, 0x00000007, 0x0201f800, 0x00103aae,
4288 0x5c003000, 0x4d400000, 0x0201f800, 0x0010a95d,
4289 0x42028000, 0x0000002a, 0x0201f800, 0x00101fe5,
4290 0x5c028000, 0x5c027800, 0x1c01f000, 0x4807c856,
4291 0x04011000, 0x4a03c840, 0x0010b54b, 0x4a03c842,
4292 0x00000040, 0x40000000, 0x040117ff, 0x42007800,
4293 0x0010b54b, 0x46007800, 0x00000011, 0x803c7800,
4294 0x4a007800, 0x220000ef, 0x4a007801, 0x000000ef,
4295 0x4a007802, 0x01380000, 0x4a007803, 0x00000000,
4296 0x4a007804, 0xffffffff, 0x4a007805, 0x00000000,
4297 0x1c01f000, 0x59c400a3, 0x80300500, 0x80340540,
4298 0x480388a3, 0x1c01f000, 0x4833c857, 0x59c400a3,
4299 0x80300540, 0x480388a3, 0x80300580, 0x480388a3,
4300 0x1c01f000, 0x4803c856, 0x04000004, 0x4a03504b,
4301 0x00000001, 0x0401f002, 0x497b504b, 0x1c01f000,
4302 0x4803c856, 0x59c80002, 0x80000540, 0x0400000a,
4303 0x80000040, 0x04000008, 0x4a039005, 0x00000140,
4304 0x42000000, 0x00000006, 0x80000040, 0x040207ff,
4305 0x0401f7f4, 0x1c01f000, 0x4c5c0000, 0x4c600000,
4306 0x59c4b805, 0x485fc856, 0x8c5cbd3a, 0x04020005,
4307 0x42000000, 0x0010b818, 0x0201f800, 0x0010aa47,
4308 0x4a038805, 0x02000000, 0x0201f800, 0x001019fe,
4309 0x4000c000, 0x0201f800, 0x00101963, 0x4a038805,
4310 0x04000000, 0x5c00c000, 0x5c00b800, 0x1c01f000,
4311 0x497a6a00, 0x4937c857, 0x4a026c00, 0x00000707,
4312 0x497a6801, 0x497a6808, 0x497a6809, 0x497a6806,
4313 0x497a6807, 0x497a6c0b, 0x497a680c, 0x0201f800,
4314 0x00103b25, 0x04020006, 0x5934080f, 0x59340010,
4315 0x80040540, 0x02020800, 0x001005d8, 0x4a026a04,
4316 0x00000100, 0x497a6a03, 0x59340402, 0x82000500,
4317 0x000000ff, 0x48026c02, 0x497a6c04, 0x497a6a05,
4318 0x497a6c05, 0x497a6811, 0x4d2c0000, 0x5934000d,
4319 0x49466c03, 0x80025d40, 0x04000004, 0x0201f800,
4320 0x001007fd, 0x497a680d, 0x5c025800, 0x599c0401,
4321 0x48026a0b, 0x599c0208, 0x48026c12, 0x497a680a,
4322 0x0201f000, 0x00104c62, 0x42000000, 0x00000005,
4323 0x80000d80, 0x0401f02d, 0x0201f800, 0x00104a09,
4324 0x04020017, 0x59a80026, 0x8c00050a, 0x04020010,
4325 0x59340212, 0x82000500, 0x0000ff00, 0x4803c857,
4326 0x0400000b, 0x59340a00, 0x8c040d1e, 0x02000000,
4327 0x000201c4, 0x42000000, 0x00000029, 0x42000800,
4328 0x00001000, 0x492fc857, 0x0401f018, 0x492fc857,
4329 0x42000000, 0x00000028, 0x0401f012, 0x59a80805,
4330 0x8c040d02, 0x04020003, 0x8c040d00, 0x04000004,
4331 0x42000000, 0x00000004, 0x0401f00a, 0x42000000,
4332 0x00000029, 0x59340a00, 0x8c040d1e, 0x04000005,
4333 0x492fc857, 0x42000800, 0x00001000, 0x0401f003,
4334 0x492fc857, 0x80000d80, 0x4803c857, 0x80028540,
4335 0x1c01f000, 0x4803c857, 0x59a80005, 0x8c000500,
4336 0x040207ec, 0x0201f800, 0x001049e7, 0x040207e4,
4337 0x59340200, 0x8c00050e, 0x040007e1, 0x0201f000,
4338 0x000201c4, 0x0201f800, 0x001047eb, 0x040007bf,
4339 0x0201f000, 0x000201c8, 0x592c0206, 0x492fc857,
4340 0x82000d80, 0x000007ff, 0x04020006, 0x4a025c0a,
4341 0x00000030, 0x42026800, 0x0010b524, 0x0401f021,
4342 0x82000c80, 0x000007f0, 0x04021046, 0x81ac0400,
4343 0x50000000, 0x80026d40, 0x04000038, 0x0201f800,
4344 0x001048e3, 0x04020038, 0x592c040a, 0x8c00050a,
4345 0x04020014, 0x592e6009, 0x83300480, 0x0010d1c0,
4346 0x0400103b, 0x41580000, 0x81300480, 0x04021038,
4347 0x59300c06, 0x82040580, 0x00000009, 0x04020037,
4348 0x4a025a06, 0x00000000, 0x497a5800, 0x59300008,
4349 0x80000540, 0x04020018, 0x492e6008, 0x0401f010,
4350 0x0201f800, 0x0002075a, 0x04000019, 0x592c0206,
4351 0x49366009, 0x492e6008, 0x4a026406, 0x00000009,
4352 0x497a6015, 0x49325809, 0x82000d80, 0x000007ff,
4353 0x04020003, 0x4a026015, 0x00008000, 0x42027000,
4354 0x00000043, 0x0201f800, 0x000207a1, 0x80000580,
4355 0x0401f020, 0x40000800, 0x58040000, 0x80000d40,
4356 0x040207fd, 0x492c0800, 0x0401f01a, 0x42000000,
4357 0x0000002c, 0x0401f016, 0x42000000, 0x00000028,
4358 0x0401f013, 0x59a80805, 0x82040500, 0x00000003,
4359 0x04000004, 0x42000000, 0x00000004, 0x0401f00c,
4360 0x42000000, 0x00000029, 0x0401f009, 0x42000000,
4361 0x00000008, 0x0401f006, 0x82040580, 0x00000007,
4362 0x040207fb, 0x42000000, 0x00000005, 0x80000540,
4363 0x1c01f000, 0x492fc857, 0x592e8c06, 0x83440d80,
4364 0x000007fc, 0x04000004, 0x83440480, 0x000007f0,
4365 0x04021014, 0x0201f800, 0x00020245, 0x04020011,
4366 0x0201f800, 0x001049f3, 0x04020011, 0x0201f800,
4367 0x0002075a, 0x0400001c, 0x49366009, 0x492e6008,
4368 0x4a026406, 0x0000000a, 0x42027000, 0x00000040,
4369 0x0201f800, 0x000207a1, 0x80000580, 0x0401f011,
4370 0x42000000, 0x00000028, 0x0401f00d, 0x0201f800,
4371 0x00104a09, 0x040007fb, 0x59a80805, 0x82040d00,
4372 0x00000003, 0x04000004, 0x42000000, 0x00000004,
4373 0x0401f003, 0x42000000, 0x00000029, 0x80000540,
4374 0x1c01f000, 0x42000000, 0x0000002c, 0x0401f7fc,
4375 0x492fc857, 0x592e8c06, 0x4947c857, 0x83440c80,
4376 0x00000800, 0x42000000, 0x0000000a, 0x04021176,
4377 0x592c4207, 0x4823c857, 0x82200500, 0x0000000f,
4378 0x0c01f001, 0x001043d5, 0x0010445d, 0x001044a9,
4379 0x001044b4, 0x001044bf, 0x001043d1, 0x001043d1,
4380 0x001043d1, 0x001044cf, 0x00104513, 0x00104530,
4381 0x001043d1, 0x001043d1, 0x001043d1, 0x001043d1,
4382 0x001043d1, 0x4803c857, 0x42000000, 0x0000000c,
4383 0x0401f15d, 0x592c1008, 0x82081500, 0x00ffffff,
4384 0x59a80010, 0x80084d80, 0x42000000, 0x00000010,
4385 0x04000155, 0x0201f800, 0x00104919, 0x04000036,
4386 0x4803c857, 0x82004d80, 0x0000001d, 0x0402001a,
4387 0x0201f800, 0x00105755, 0x59340405, 0x4c000000,
4388 0x0201f800, 0x001049e7, 0x5c000000, 0x04000004,
4389 0x8c20450a, 0x04000028, 0x80000580, 0x44002800,
4390 0x59340008, 0x48002802, 0x59340009, 0x48002801,
4391 0x59340006, 0x48002804, 0x59340007, 0x48002803,
4392 0x4200b000, 0x00000005, 0x0201f800, 0x0010955f,
4393 0x0401f166, 0x4803c857, 0x82004d80, 0x0000001a,
4394 0x04020003, 0x40101000, 0x0401f136, 0x4803c857,
4395 0x82004d80, 0x0000001b, 0x04020003, 0x40181000,
4396 0x0401f130, 0x4803c857, 0x82004d80, 0x0000001c,
4397 0x04000131, 0x82004d80, 0x00000019, 0x42000000,
4398 0x0000000a, 0x04000120, 0x42000000, 0x0000000a,
4399 0x04020137, 0x59a80005, 0x8c000514, 0x0400001b,
4400 0x0201f800, 0x001049e7, 0x04000018, 0x59340212,
4401 0x82000500, 0x0000ff00, 0x42001000, 0x00000010,
4402 0x0402000c, 0x42001000, 0x00000008, 0x59a80026,
4403 0x8c000506, 0x04020009, 0x59340002, 0x82000500,
4404 0x00ff0000, 0x82000580, 0x00ff0000, 0x04000007,
4405 0x0201f800, 0x00104c6d, 0x42000000, 0x0000001c,
4406 0x40181000, 0x04020107, 0x0201f800, 0x0002075a,
4407 0x04000111, 0x49366009, 0x492e6008, 0x4a026406,
4408 0x00000001, 0x8c20450a, 0x04000004, 0x592c0404,
4409 0x8400055c, 0x48025c04, 0x4c200000, 0x4d3c0000,
4410 0x42027800, 0x00001000, 0x0201f800, 0x0010203c,
4411 0x5c027800, 0x5c004000, 0x8c204512, 0x0400000b,
4412 0x599c0018, 0x8c000518, 0x04000008, 0x592c0009,
4413 0x82000500, 0x00000380, 0x5934080a, 0x80040d40,
4414 0x84040d54, 0x4806680a, 0x417a7800, 0x0401f914,
4415 0x42000800, 0x00000003, 0x0401f91b, 0x42027000,
4416 0x00000002, 0x0201f800, 0x000207a1, 0x80000580,
4417 0x0401f10a, 0x0201f800, 0x00020245, 0x040200ec,
4418 0x0201f800, 0x001049ed, 0x04000008, 0x0201f800,
4419 0x001049e7, 0x040200ec, 0x417a7800, 0x417a6000,
4420 0x0201f800, 0x001020a1, 0x59a80005, 0x8c000514,
4421 0x0400001b, 0x0201f800, 0x001049e7, 0x04000018,
4422 0x59340212, 0x82000500, 0x0000ff00, 0x42001000,
4423 0x00000010, 0x0402000c, 0x42001000, 0x00000008,
4424 0x59a80026, 0x8c000506, 0x04020009, 0x59340002,
4425 0x82000500, 0x00ff0000, 0x82000580, 0x00ff0000,
4426 0x04000007, 0x0201f800, 0x00104c6d, 0x42000000,
4427 0x0000001c, 0x40181000, 0x040200b2, 0x0201f800,
4428 0x0002075a, 0x040000bc, 0x5934080a, 0x8c204512,
4429 0x0400000c, 0x599c0018, 0x8c000518, 0x04000009,
4430 0x592c0009, 0x82000500, 0x00000380, 0x82041500,
4431 0xfffffc7f, 0x80080d40, 0x84040d54, 0x0401f002,
4432 0x84040d14, 0x4806680a, 0x49366009, 0x492e6008,
4433 0x4a026406, 0x00000001, 0x417a7800, 0x0401f8c8,
4434 0x42000800, 0x00000005, 0x0401f8cf, 0x42027000,
4435 0x00000003, 0x0201f800, 0x000207a1, 0x80000580,
4436 0x0401f0be, 0x0201f800, 0x00020245, 0x040200a0,
4437 0x0201f800, 0x001049fc, 0x040200a3, 0x0201f800,
4438 0x00109517, 0x04000094, 0x80000580, 0x0401f0b3,
4439 0x0201f800, 0x00020245, 0x04020095, 0x0201f800,
4440 0x001049fc, 0x04020098, 0x0201f800, 0x001090e6,
4441 0x04000089, 0x80000580, 0x0401f0a8, 0x0201f800,
4442 0x00020245, 0x0402008a, 0x83444d80, 0x000007fe,
4443 0x42000000, 0x0000000a, 0x0402006b, 0x0201f800,
4444 0x001049e7, 0x04020088, 0x0201f800, 0x0010952f,
4445 0x04000079, 0x80000580, 0x0401f098, 0x82200500,
4446 0x00000070, 0x04020005, 0x8c20450e, 0x42000000,
4447 0x0000000c, 0x0402005c, 0x8c20450a, 0x0400000d,
4448 0x4d3c0000, 0x42027800, 0x00001000, 0x8c20450e,
4449 0x04020002, 0x853e7d56, 0x82200500, 0x000000a0,
4450 0x0201f800, 0x001049d3, 0x5c027800, 0x0401f07f,
4451 0x0201f800, 0x00020245, 0x04020065, 0x8c204508,
4452 0x04000010, 0x4d3c0000, 0x42027800, 0x00001000,
4453 0x8c20450e, 0x04020002, 0x853e7d56, 0x82200500,
4454 0x00000090, 0x0201f800, 0x001049bb, 0x5c027800,
4455 0x42000000, 0x0000000a, 0x0402003b, 0x0401f06b,
4456 0x836c0580, 0x00000003, 0x42000800, 0x00000007,
4457 0x0402000f, 0x0201f800, 0x001049f3, 0x04000007,
4458 0x4c000000, 0x0201f800, 0x00104a1f, 0x5c000000,
4459 0x0400004d, 0x0401f05d, 0x0201f800, 0x001094c5,
4460 0x04000007, 0x80000580, 0x0401f05c, 0x0201f800,
4461 0x00104a1f, 0x04000051, 0x0401f054, 0x0201f800,
4462 0x00104a1f, 0x04000034, 0x0401f050, 0x0201f800,
4463 0x00020245, 0x04020036, 0x836c0580, 0x00000003,
4464 0x04020040, 0x8c204508, 0x04000006, 0x417a7800,
4465 0x417a6000, 0x0201f800, 0x001020a1, 0x0401f043,
4466 0x0201f800, 0x001049ed, 0x04000008, 0x0201f800,
4467 0x001049e7, 0x0402002c, 0x417a7800, 0x417a6000,
4468 0x0201f800, 0x001020a1, 0x480bc856, 0x0201f800,
4469 0x00109332, 0x04000018, 0x80000580, 0x0401f037,
4470 0x0401f7e3, 0x480bc857, 0x42000800, 0x00000019,
4471 0x40001000, 0x4200b000, 0x00000002, 0x0401f00a,
4472 0x480bc857, 0x40000800, 0x4200b000, 0x00000002,
4473 0x0401f005, 0x480bc857, 0x40000800, 0x4200b000,
4474 0x00000001, 0x480bc857, 0x42028000, 0x00000031,
4475 0x0401f020, 0x480bc857, 0x42000800, 0x00000003,
4476 0x4200b000, 0x00000001, 0x0401f7f7, 0x480bc857,
4477 0x42000800, 0x0000000a, 0x4200b000, 0x00000001,
4478 0x0401f7f1, 0x480bc857, 0x42000800, 0x00000009,
4479 0x40001000, 0x4200b000, 0x00000002, 0x0401f7ea,
4480 0x480bc857, 0x42000800, 0x00000007, 0x4200b000,
4481 0x00000001, 0x0401f7e4, 0x480bc857, 0x4200b000,
4482 0x00000001, 0x0401f7e0, 0x80028580, 0x4178b000,
4483 0x82000540, 0x00000001, 0x1c01f000, 0x4937c857,
4484 0x59326809, 0x59341200, 0x813e79c0, 0x04000003,
4485 0x84081540, 0x0401f002, 0x84081500, 0x480a6a00,
4486 0x1c01f000, 0x59326809, 0x5c000000, 0x4c000000,
4487 0x4803c857, 0x4937c857, 0x82040580, 0x00000006,
4488 0x04020004, 0x42000000, 0x00000606, 0x0401f021,
4489 0x82040580, 0x00000004, 0x04020004, 0x42000000,
4490 0x00000404, 0x0401f01b, 0x82040580, 0x00000007,
4491 0x42000000, 0x00000707, 0x04000016, 0x82040580,
4492 0x00000003, 0x42000000, 0x00000703, 0x04000011,
4493 0x82040580, 0x00000005, 0x42000000, 0x00000405,
4494 0x0400000c, 0x82040580, 0x00000009, 0x42000000,
4495 0x00000409, 0x04000007, 0x82040580, 0x0000000b,
4496 0x42000000, 0x0000070b, 0x02020800, 0x001005d8,
4497 0x4803c857, 0x48026c00, 0x82040d80, 0x00000006,
4498 0x04020005, 0x59341404, 0x800811c0, 0x02000800,
4499 0x001005d8, 0x1c01f000, 0x5c000000, 0x4c000000,
4500 0x4803c857, 0x4947c857, 0x481bc857, 0x83440480,
4501 0x00000800, 0x04021034, 0x83441400, 0x0010ac00,
4502 0x50080000, 0x80026d40, 0x04020011, 0x4c180000,
4503 0x4d2c0000, 0x0201f800, 0x001007d3, 0x412e6800,
4504 0x5c025800, 0x5c003000, 0x04000027, 0x45341000,
4505 0x497a680d, 0x497a6810, 0x497a680f, 0x497a680e,
4506 0x4c180000, 0x0401fcf3, 0x5c003000, 0x59340a12,
4507 0x4c040000, 0x0201f800, 0x0010513b, 0x5c000800,
4508 0x04000009, 0x82180500, 0x00ffff00, 0x04000008,
4509 0x59a81010, 0x82081500, 0x00ffff00, 0x80080580,
4510 0x04000003, 0x80000580, 0x0401f004, 0x82180500,
4511 0x000000ff, 0x800000d0, 0x80040d80, 0x04000003,
4512 0x4803c857, 0x48026a12, 0x59340002, 0x80180580,
4513 0x04000003, 0x481bc857, 0x481a6802, 0x80000580,
4514 0x1c01f000, 0x4803c856, 0x82000540, 0x00000001,
4515 0x0401f7fc, 0x4947c857, 0x83440480, 0x00000800,
4516 0x04021011, 0x83441400, 0x0010ac00, 0x50080000,
4517 0x80026d40, 0x0400000b, 0x0401fbf9, 0x0402000a,
4518 0x59a80005, 0x8c000502, 0x04000004, 0x59340200,
4519 0x8c00050e, 0x04000004, 0x82000540, 0x00000001,
4520 0x1c01f000, 0x80000580, 0x0401f7fe, 0x5c000000,
4521 0x4c000000, 0x4803c857, 0x4947c857, 0x4d2c0000,
4522 0x4d300000, 0x83440480, 0x00000800, 0x04021024,
4523 0x83441400, 0x0010ac00, 0x50080000, 0x80026d40,
4524 0x0400001b, 0x45781000, 0x5934000d, 0x80025d40,
4525 0x02020800, 0x001007fd, 0x59366011, 0x813261c0,
4526 0x0400000e, 0x4c640000, 0x5930c800, 0x59325808,
4527 0x0201f800, 0x00109037, 0x02020800, 0x001007fd,
4528 0x0201f800, 0x0002077d, 0x82666540, 0x00000000,
4529 0x040207f6, 0x5c00c800, 0x0201f800, 0x00104c62,
4530 0x41365800, 0x0201f800, 0x001007f5, 0x80000580,
4531 0x5c026000, 0x5c025800, 0x1c01f000, 0x82000540,
4532 0x00000001, 0x0401f7fb, 0x4937c857, 0x4c580000,
4533 0x59cc0001, 0x82000500, 0x00ffffff, 0x48026802,
4534 0x497a6c01, 0x497a6a01, 0x59340200, 0x84000502,
4535 0x48026a00, 0x0201f800, 0x0010513b, 0x04020017,
4536 0x59340403, 0x82000580, 0x000007fe, 0x04000005,
4537 0x59a80026, 0x8c00050a, 0x04020010, 0x0401f008,
4538 0x59cc0408, 0x8c000518, 0x0400000c, 0x59cc0009,
4539 0x48035035, 0x59cc000a, 0x48035036, 0x59cc0207,
4540 0x80000540, 0x04020003, 0x42000000, 0x00000001,
4541 0x48038893, 0x4803501e, 0x59cc0a09, 0x82040d00,
4542 0x00000010, 0x59cc0408, 0x82000500, 0x00000020,
4543 0x04000002, 0x84040d40, 0x5934000a, 0x82000500,
4544 0xffffffee, 0x80040540, 0x4802680a, 0x83cca400,
4545 0x0000000b, 0x8334ac00, 0x00000006, 0x4200b000,
4546 0x00000002, 0x0201f800, 0x0010ab17, 0x83cca400,
4547 0x0000000d, 0x8334ac00, 0x00000008, 0x4200b000,
4548 0x00000002, 0x0201f800, 0x0010ab17, 0x59cc0a18,
4549 0x82040480, 0x00000800, 0x0402100c, 0x82040480,
4550 0x00000400, 0x04001004, 0x42000800, 0x00000400,
4551 0x0401f006, 0x82040480, 0x00000200, 0x04001003,
4552 0x42000800, 0x00000200, 0x48066a04, 0x59340403,
4553 0x82000580, 0x000007fe, 0x04020003, 0x59cc0a08,
4554 0x48066a04, 0x42000800, 0x00000004, 0x59cc1207,
4555 0x800811c0, 0x04000005, 0x82080480, 0x00000004,
4556 0x04021002, 0x40080800, 0x48066c04, 0x5c00b000,
4557 0x1c01f000, 0x4937c857, 0x59a80026, 0x8c000508,
4558 0x04000004, 0x84000556, 0x4803c857, 0x48035026,
4559 0x59cc0207, 0x4803c857, 0x48026a05, 0x59cc020a,
4560 0x4803c857, 0x48026c05, 0x59341200, 0x599c0818,
4561 0x5934180a, 0x4807c857, 0x480bc857, 0x480fc857,
4562 0x59cc2006, 0x82102500, 0xff000000, 0x82102580,
4563 0x02000000, 0x04000007, 0x8c00050e, 0x04000009,
4564 0x8c0c1d14, 0x04000003, 0x8c0c1d0e, 0x04000005,
4565 0x8c040d18, 0x04000003, 0x8408154a, 0x0401f002,
4566 0x8408150a, 0x8c000510, 0x04000009, 0x8c0c1d14,
4567 0x04000003, 0x8c0c1d10, 0x04000005, 0x8c040d18,
4568 0x04000003, 0x8408154e, 0x0401f002, 0x8408150e,
4569 0x8c000512, 0x04000009, 0x8c0c1d14, 0x04000003,
4570 0x8c0c1d12, 0x04000005, 0x8c040d18, 0x04000003,
4571 0x8408155c, 0x0401f002, 0x8408151c, 0x480a6a00,
4572 0x1c01f000, 0x4803c856, 0x4c5c0000, 0x4d2c0000,
4573 0x4c580000, 0x5934000d, 0x80025d40, 0x04000029,
4574 0x592c0003, 0x82000480, 0x00000008, 0x0400100b,
4575 0x412cb800, 0x592c0001, 0x80025d40, 0x040207f9,
4576 0x0201f800, 0x001007e4, 0x04000037, 0x492fc857,
4577 0x492cb801, 0x0401f020, 0x832c0c00, 0x00000004,
4578 0x4200b000, 0x00000008, 0x50040000, 0x82000580,
4579 0xffffffff, 0x04020006, 0x80041000, 0x50080000,
4580 0x82000580, 0xffffffff, 0x04000007, 0x82040c00,
4581 0x00000002, 0x8058b040, 0x040207f4, 0x0201f800,
4582 0x001005d8, 0x45480800, 0x454c1000, 0x592c1803,
4583 0x800c1800, 0x480e5803, 0x480fc857, 0x0401f014,
4584 0x0201f800, 0x001007e4, 0x04000017, 0x492fc857,
4585 0x492e680d, 0x497a5802, 0x4a025803, 0x00000001,
4586 0x494a5804, 0x494e5805, 0x832c0c00, 0x00000006,
4587 0x4200b000, 0x0000000e, 0x46000800, 0xffffffff,
4588 0x80040800, 0x8058b040, 0x040207fc, 0x82000540,
4589 0x00000001, 0x5c00b000, 0x5c025800, 0x5c00b800,
4590 0x1c01f000, 0x80000580, 0x0401f7fb, 0x4803c856,
4591 0x4d3c0000, 0x4d2c0000, 0x5934000d, 0x80025d40,
4592 0x0400001f, 0x592c0002, 0x80000540, 0x0402001f,
4593 0x412e7800, 0x0401f8ce, 0x0402001c, 0x46000800,
4594 0xffffffff, 0x46001000, 0xffffffff, 0x4813c857,
4595 0x480fc857, 0x580c0003, 0x82000c80, 0x00000002,
4596 0x04021014, 0x480fc857, 0x400c0000, 0x812c0580,
4597 0x04020004, 0x580c0001, 0x4802680d, 0x0401f003,
4598 0x580c0001, 0x48002001, 0x400e5800, 0x0201f800,
4599 0x001007f4, 0x82000540, 0x00000001, 0x5c025800,
4600 0x5c027800, 0x1c01f000, 0x80000580, 0x0401f7fc,
4601 0x80000040, 0x48001803, 0x4803c857, 0x0401f7f6,
4602 0x0201f800, 0x00020086, 0x59300007, 0x8400054e,
4603 0x48026007, 0x592c1a04, 0x820c1d00, 0x000000ff,
4604 0x820c0580, 0x00000048, 0x04000013, 0x0201f000,
4605 0x0002028e, 0x8c000500, 0x02020800, 0x000200e5,
4606 0x4a026203, 0x00000002, 0x592c1a04, 0x820c1d00,
4607 0x000000ff, 0x820c0580, 0x00000018, 0x02000000,
4608 0x0002028e, 0x820c0580, 0x00000048, 0x02020000,
4609 0x0002028e, 0x42000800, 0x80000804, 0x0201f800,
4610 0x00106721, 0x0201f000, 0x00020297, 0x4a025a06,
4611 0x00000008, 0x0201f000, 0x000202da, 0x4a025a06,
4612 0x00000029, 0x0201f000, 0x000202da, 0x4a025a06,
4613 0x0000002a, 0x0201f000, 0x000202da, 0x4a025a06,
4614 0x00000028, 0x0201f000, 0x000202da, 0x4943c857,
4615 0x4d440000, 0x4d340000, 0x4d2c0000, 0x4c580000,
4616 0x4200b000, 0x000007f0, 0x417a8800, 0x0201f800,
4617 0x00020245, 0x0402000d, 0x8d3e7d14, 0x04000005,
4618 0x59340212, 0x82000500, 0x0000ff00, 0x04000007,
4619 0x8d3e7d06, 0x04000004, 0x59340200, 0x8c00050e,
4620 0x04020002, 0x0401f813, 0x81468800, 0x8058b040,
4621 0x040207ef, 0x83440480, 0x00000800, 0x04021008,
4622 0x8d3e7d02, 0x04000006, 0x42028800, 0x000007f0,
4623 0x4200b000, 0x00000010, 0x0401f7e5, 0x5c00b000,
4624 0x5c025800, 0x5c026800, 0x5c028800, 0x1c01f000,
4625 0x4d2c0000, 0x41783000, 0x5936580f, 0x812e59c0,
4626 0x04000029, 0x592c0204, 0x82000500, 0x000000ff,
4627 0x82000580, 0x00000012, 0x04000020, 0x8d3e7d00,
4628 0x04000003, 0x0401f83c, 0x0402001c, 0x592c2000,
4629 0x497a5800, 0x801831c0, 0x04020009, 0x59340010,
4630 0x812c0580, 0x04020004, 0x497a680f, 0x497a6810,
4631 0x0401f008, 0x4812680f, 0x0401f006, 0x48103000,
4632 0x59340010, 0x812c0580, 0x04020002, 0x481a6810,
4633 0x4a025a04, 0x00000103, 0x49425a06, 0x497a5c09,
4634 0x0201f800, 0x001091c6, 0x0201f800, 0x000202da,
4635 0x40125800, 0x0401f7da, 0x412c3000, 0x592e5800,
4636 0x0401f7d7, 0x5c025800, 0x1c01f000, 0x4803c856,
4637 0x41781800, 0x5934000f, 0x80025d40, 0x04000010,
4638 0x592c0005, 0x80200580, 0x592c0000, 0x04000003,
4639 0x412c1800, 0x0401f7f9, 0x497a5800, 0x800c19c0,
4640 0x04000008, 0x48001800, 0x80000540, 0x04020004,
4641 0x480e6810, 0x82000540, 0x00000001, 0x1c01f000,
4642 0x4802680f, 0x80000540, 0x040207fd, 0x497a6810,
4643 0x0401f7f9, 0x592c0008, 0x81480580, 0x04020003,
4644 0x592c0009, 0x814c0580, 0x1c01f000, 0x4803c856,
4645 0x4c580000, 0x413c1800, 0x400c2000, 0x593c0002,
4646 0x80000540, 0x04020018, 0x4200b000, 0x00000008,
4647 0x820c0c00, 0x00000004, 0x50040000, 0x81480580,
4648 0x04020005, 0x80041000, 0x50080000, 0x814c0580,
4649 0x0400000d, 0x82040c00, 0x00000002, 0x8058b040,
4650 0x040207f6, 0x400c2000, 0x580c0001, 0x80001d40,
4651 0x040207ee, 0x82000540, 0x00000001, 0x5c00b000,
4652 0x1c01f000, 0x80000580, 0x0401f7fd, 0x4937c857,
4653 0x4c580000, 0x4d2c0000, 0x5934000d, 0x80025d40,
4654 0x04020016, 0x0201f800, 0x001007e4, 0x04000010,
4655 0x492e680d, 0x4a025802, 0x00000001, 0x497a5803,
4656 0x832c0c00, 0x00000004, 0x4200b000, 0x00000010,
4657 0x46000800, 0xffffffff, 0x80040800, 0x8058b040,
4658 0x040207fc, 0x82000540, 0x00000001, 0x5c025800,
4659 0x5c00b000, 0x1c01f000, 0x4d2c0000, 0x592e5801,
4660 0x0201f800, 0x001007fd, 0x5c025800, 0x0401f7ea,
4661 0x4d2c0000, 0x5936580d, 0x812e59c0, 0x04000007,
4662 0x4937c857, 0x497a680d, 0x0201f800, 0x001007fd,
4663 0x82000540, 0x00000001, 0x5c025800, 0x1c01f000,
4664 0x59340405, 0x4937c857, 0x4803c857, 0x8c000508,
4665 0x1c01f000, 0x4803c856, 0x0201f800, 0x0010513b,
4666 0x04000011, 0x59a80815, 0x8c040d04, 0x0402000e,
4667 0x59a80826, 0x8c040d06, 0x0400000b, 0x83ac0400,
4668 0x000007fe, 0x50000000, 0x80026d40, 0x04000006,
4669 0x0401f9a7, 0x04020004, 0x59340200, 0x8400055a,
4670 0x48026a00, 0x599c0017, 0x8c000508, 0x04000015,
4671 0x4200b000, 0x000007f0, 0x417a8800, 0x0201f800,
4672 0x00020245, 0x0402000c, 0x0401f999, 0x0402000a,
4673 0x59a80010, 0x59340802, 0x80040580, 0x82000500,
4674 0x00ffff00, 0x04020004, 0x59340200, 0x8400055a,
4675 0x48026a00, 0x81468800, 0x8058b040, 0x040207f0,
4676 0x0401f884, 0x04000003, 0x59a80836, 0x0401f006,
4677 0x599c0017, 0x8c000508, 0x04000007, 0x42000800,
4678 0x000007d0, 0x42001000, 0x00104876, 0x0201f800,
4679 0x0010606e, 0x1c01f000, 0x4803c856, 0x4d340000,
4680 0x4d440000, 0x4d3c0000, 0x4c580000, 0x42001000,
4681 0x00104876, 0x0201f800, 0x00105f90, 0x59a80826,
4682 0x8c040d06, 0x04000015, 0x0401f86a, 0x04000013,
4683 0x83ae6c00, 0x000007fe, 0x51366800, 0x59340200,
4684 0x8400051a, 0x48026a00, 0x599c0017, 0x8c000508,
4685 0x04000007, 0x42000800, 0x000007d0, 0x42001000,
4686 0x00104876, 0x0201f800, 0x0010606e, 0x0201f800,
4687 0x00101e45, 0x0401f027, 0x4200b000, 0x000007f0,
4688 0x80028d80, 0x0201f800, 0x00020245, 0x0402001e,
4689 0x59340200, 0x8c00051a, 0x0400001b, 0x59368c03,
4690 0x417a7800, 0x42028000, 0x00000029, 0x41783000,
4691 0x0201f800, 0x0010a446, 0x59340200, 0x84000558,
4692 0x8400051a, 0x48026a00, 0x4937c857, 0x4a026c00,
4693 0x00000707, 0x42028000, 0x00000029, 0x0201f800,
4694 0x00106ab4, 0x417a7800, 0x0201f800, 0x001067fd,
4695 0x80000d80, 0x0201f800, 0x0010a2ff, 0x0201f800,
4696 0x00106c4b, 0x81468800, 0x8058b040, 0x040207de,
4697 0x5c00b000, 0x5c027800, 0x5c028800, 0x5c026800,
4698 0x1c01f000, 0x4933c857, 0x59303809, 0x581c0200,
4699 0x8400051a, 0x48003a00, 0x1c01f000, 0x4803c856,
4700 0x42026800, 0x0010b524, 0x497a680e, 0x42028800,
4701 0x000007ff, 0x0201f800, 0x001042b4, 0x4937c857,
4702 0x4a026c00, 0x00000606, 0x4a026802, 0x00ffffff,
4703 0x4a026a04, 0x00000200, 0x4a026c04, 0x00000002,
4704 0x1c01f000, 0x59300009, 0x50000000, 0x4933c857,
4705 0x4803c857, 0x8c00050e, 0x1c01f000, 0x59300009,
4706 0x50000000, 0x8c00050a, 0x1c01f000, 0x4933c856,
4707 0x0401f90f, 0x04000006, 0x59340400, 0x82000d00,
4708 0x000000ff, 0x82041580, 0x00000005, 0x1c01f000,
4709 0x4d340000, 0x83ac0400, 0x000007fe, 0x50000000,
4710 0x80026d40, 0x04000003, 0x59340200, 0x8c00051a,
4711 0x5c026800, 0x1c01f000, 0x4937c857, 0x493fc857,
4712 0x59340403, 0x81ac0400, 0x50000000, 0x81340580,
4713 0x02020800, 0x001005d8, 0x59341200, 0x813e79c0,
4714 0x04000003, 0x8408155e, 0x0401f002, 0x8408151e,
4715 0x480a6a00, 0x1c01f000, 0x4937c857, 0x0201f800,
4716 0x0010210a, 0x04000006, 0x59a80835, 0x42001000,
4717 0x00104910, 0x0201f800, 0x0010606e, 0x1c01f000,
4718 0x4937c857, 0x42001000, 0x00104910, 0x0201f800,
4719 0x00105f90, 0x59a81026, 0x84081512, 0x480b5026,
4720 0x1c01f000, 0x4c380000, 0x4c340000, 0x4c240000,
4721 0x4c600000, 0x4008c000, 0x83440480, 0x00000800,
4722 0x04021045, 0x80002d80, 0x41442000, 0x83447400,
4723 0x0010ac00, 0x4200b000, 0x000007f0, 0x83444c80,
4724 0x000007f0, 0x04001003, 0x4200b000, 0x00000010,
4725 0x50380000, 0x80000540, 0x0402001e, 0x41440000,
4726 0x80100580, 0x04020043, 0x40102800, 0x82104c80,
4727 0x000007f0, 0x04001015, 0x82104d80, 0x000007fc,
4728 0x04020005, 0x82604d80, 0x00fffffc, 0x0402002a,
4729 0x0401f00e, 0x82104d80, 0x000007fd, 0x04020005,
4730 0x82604d80, 0x00fffffd, 0x04020023, 0x0401f007,
4731 0x82104d80, 0x000007ff, 0x0402001f, 0x82604d80,
4732 0x00ffffff, 0x0402001c, 0x84142d5e, 0x0401f029,
4733 0x40006800, 0x58343002, 0x82183500, 0x00ffffff,
4734 0x40180000, 0x80600580, 0x04020019, 0x40100000,
4735 0x81440580, 0x0402000a, 0x40366800, 0x8c204508,
4736 0x04000053, 0x0401ff8a, 0x04020051, 0x4947c857,
4737 0x42000000, 0x0000001d, 0x0401f04e, 0x4947c857,
4738 0x480bc857, 0x4823c857, 0x42000000, 0x0000001a,
4739 0x0401f048, 0x4947c857, 0x4863c857, 0x4813c857,
4740 0x42000000, 0x00000019, 0x0401f042, 0x40100000,
4741 0x81440580, 0x04020007, 0x58343002, 0x4947c857,
4742 0x481bc857, 0x42000000, 0x0000001b, 0x0401f039,
4743 0x80102000, 0x80387000, 0x83444c80, 0x000007f0,
4744 0x04001009, 0x82104d80, 0x00000800, 0x0402000c,
4745 0x42002000, 0x000007f0, 0x42007000, 0x0010b3f0,
4746 0x0401f007, 0x82104d80, 0x000007f0, 0x04020004,
4747 0x41782000, 0x42007000, 0x0010ac00, 0x8058b040,
4748 0x040207a4, 0x801429c0, 0x04020007, 0x0201f800,
4749 0x001005d8, 0x4947c857, 0x42000000, 0x0000000a,
4750 0x0401f01c, 0x4d2c0000, 0x4c180000, 0x40603000,
4751 0x0401fc12, 0x4947c857, 0x4937c857, 0x5c003000,
4752 0x5c025800, 0x040207f4, 0x497a6a12, 0x59a80026,
4753 0x8c00050a, 0x0402000d, 0x82600500, 0x00ffff00,
4754 0x04000006, 0x59a84810, 0x82244d00, 0x00ffff00,
4755 0x80240580, 0x04020005, 0x82600500, 0x000000ff,
4756 0x800000d0, 0x48026a12, 0x48626802, 0x80000580,
4757 0x80000540, 0x5c00c000, 0x5c004800, 0x5c006800,
4758 0x5c007000, 0x1c01f000, 0x5934000f, 0x5934140b,
4759 0x80081040, 0x04001002, 0x480a6c0b, 0x80000540,
4760 0x02020800, 0x00020253, 0x1c01f000, 0x4803c857,
4761 0x4947c857, 0x4c300000, 0x82006500, 0x00000030,
4762 0x04000006, 0x4c000000, 0x0201f800, 0x0010942a,
4763 0x5c000000, 0x0402000b, 0x8c00050e, 0x04000006,
4764 0x0201f800, 0x00020245, 0x04020006, 0x4937c857,
4765 0x0401fc2f, 0x80000580, 0x5c006000, 0x1c01f000,
4766 0x82000540, 0x00000001, 0x0401f7fc, 0x4803c857,
4767 0x4c580000, 0x4d440000, 0x40001000, 0x80000d80,
4768 0x4200b000, 0x000007f0, 0x4c040000, 0x40068800,
4769 0x4c080000, 0x40080000, 0x0401ffdd, 0x5c001000,
4770 0x5c000800, 0x80040800, 0x8058b040, 0x040207f7,
4771 0x5c028800, 0x5c00b000, 0x1c01f000, 0x4c5c0000,
4772 0x59340400, 0x8200bd80, 0x00000606, 0x5c00b800,
4773 0x1c01f000, 0x4c5c0000, 0x59340400, 0x8200bd80,
4774 0x00000404, 0x5c00b800, 0x1c01f000, 0x4c5c0000,
4775 0x59340400, 0x8200bd80, 0x00000404, 0x04000003,
4776 0x8200bd80, 0x00000606, 0x5c00b800, 0x1c01f000,
4777 0x4c5c0000, 0x4c600000, 0x59340400, 0x8200bd00,
4778 0x0000ff00, 0x825cc580, 0x00000400, 0x04000003,
4779 0x825cc580, 0x00000600, 0x5c00c000, 0x5c00b800,
4780 0x1c01f000, 0x4c5c0000, 0x59340400, 0x82000500,
4781 0x000000ff, 0x8200bd80, 0x00000003, 0x04000003,
4782 0x8200bd80, 0x00000005, 0x5c00b800, 0x1c01f000,
4783 0x4c5c0000, 0x59340400, 0x82000500, 0x0000ff00,
4784 0x8400b9c0, 0x805c0580, 0x4937c857, 0x4803c857,
4785 0x48026c00, 0x5c00b800, 0x1c01f000, 0x4c040000,
4786 0x4c080000, 0x592c0207, 0x8c00050c, 0x0400000f,
4787 0x592e8c06, 0x82000500, 0x00000080, 0x84000548,
4788 0x4d3c0000, 0x42027800, 0x00001000, 0x0401ff90,
4789 0x5c027800, 0x82000540, 0x00000001, 0x5c001000,
4790 0x5c000800, 0x1c01f000, 0x80000580, 0x0401f7fc,
4791 0x592c040b, 0x82000500, 0x0000e000, 0x82000580,
4792 0x00006000, 0x04000019, 0x836c0580, 0x00000003,
4793 0x04000016, 0x836c0580, 0x00000002, 0x040200ff,
4794 0x59a80026, 0x82000d00, 0x00000038, 0x04020005,
4795 0x59a80832, 0x800409c0, 0x0400000c, 0x0401f0f7,
4796 0x82000d00, 0x00000003, 0x82040d80, 0x00000003,
4797 0x040200f2, 0x82000d00, 0x00000028, 0x04020003,
4798 0x8c00050c, 0x040000ed, 0x592c100a, 0x82080500,
4799 0xff000000, 0x040200ce, 0x59a80010, 0x80080580,
4800 0x040000c8, 0x592c0c0b, 0x82040d00, 0x0000e000,
4801 0x82040480, 0x00008000, 0x040210c8, 0x592e8c06,
4802 0x83440480, 0x00000800, 0x04001007, 0x83440580,
4803 0x0000ffff, 0x040200af, 0x800409c0, 0x040200f7,
4804 0x0401f0ac, 0x800409c0, 0x040200f4, 0x41784000,
4805 0x0401fead, 0x040200db, 0x42027000, 0x00000053,
4806 0x592c2409, 0x82100500, 0xffffff00, 0x040200aa,
4807 0x4813c857, 0x592c000c, 0x800001c0, 0x04000083,
4808 0x82100580, 0x00000004, 0x040000a0, 0x82100580,
4809 0x00000051, 0x0400009d, 0x82100580, 0x00000003,
4810 0x04000016, 0x82100580, 0x00000020, 0x0400004b,
4811 0x82100580, 0x00000024, 0x04000042, 0x82100580,
4812 0x00000021, 0x04000042, 0x82100580, 0x00000050,
4813 0x04000037, 0x82100580, 0x00000052, 0x04000031,
4814 0x82100580, 0x00000005, 0x0402006b, 0x42027000,
4815 0x00000001, 0x0401f01b, 0x42027000, 0x00000002,
4816 0x59a80005, 0x8c000514, 0x04000016, 0x0401ff4c,
4817 0x04000014, 0x59340212, 0x82000500, 0x0000ff00,
4818 0x42001000, 0x00000010, 0x0402000c, 0x59a80026,
4819 0x8c000506, 0x0402006f, 0x42001000, 0x00000008,
4820 0x59340002, 0x82000500, 0x00ff0000, 0x82000580,
4821 0x00ff0000, 0x04000003, 0x0401f9bf, 0x04020065,
4822 0x0201f800, 0x0002075a, 0x0400007e, 0x4a026406,
4823 0x00000010, 0x49366009, 0x42000800, 0x00000003,
4824 0x83380580, 0x00000002, 0x04000003, 0x42000800,
4825 0x0000000b, 0x0201f800, 0x00104571, 0x0401f044,
4826 0x42027000, 0x00000000, 0x0401f003, 0x42027000,
4827 0x00000004, 0x0401ff37, 0x04020071, 0x0401f036,
4828 0x42027000, 0x00000033, 0x0401f006, 0x42027000,
4829 0x00000005, 0x0401f003, 0x42027000, 0x00000003,
4830 0x0401ff23, 0x04020066, 0x59a80005, 0x8c000514,
4831 0x04000016, 0x0401ff12, 0x04000014, 0x59340212,
4832 0x82000500, 0x0000ff00, 0x42001000, 0x00000010,
4833 0x0402000c, 0x59a80026, 0x8c000506, 0x04020035,
4834 0x42001000, 0x00000008, 0x59340002, 0x82000500,
4835 0x00ff0000, 0x82000580, 0x00ff0000, 0x04000003,
4836 0x0401f985, 0x0402002b, 0x0201f800, 0x0002075a,
4837 0x04000044, 0x4a026406, 0x00000010, 0x49366009,
4838 0x42000800, 0x00000005, 0x83380580, 0x00000003,
4839 0x04000003, 0x42000800, 0x00000009, 0x0201f800,
4840 0x00104571, 0x0401f00a, 0x82102580, 0x00000011,
4841 0x0402002d, 0x0201f800, 0x0002075a, 0x04000031,
4842 0x4a026406, 0x00000010, 0x49366009, 0x492e6008,
4843 0x49325808, 0x813669c0, 0x04000007, 0x592c0c0b,
4844 0x8c040d18, 0x04000004, 0x59340200, 0x84000514,
4845 0x48026a00, 0x0201f800, 0x000207a1, 0x80000580,
4846 0x1c01f000, 0x82000540, 0x00000001, 0x0401f7fd,
4847 0x42001000, 0x0000000a, 0x0401f015, 0x42001000,
4848 0x00000010, 0x0401f012, 0x42001000, 0x00000016,
4849 0x0401f00f, 0x42001000, 0x00000017, 0x0401f00c,
4850 0x42001000, 0x00000018, 0x0401f009, 0x42001000,
4851 0x0000001b, 0x0401f006, 0x42001000, 0x0000001e,
4852 0x0401f003, 0x42001000, 0x00000020, 0x42000800,
4853 0x00000019, 0x42028000, 0x00000031, 0x0401f7e2,
4854 0x42000800, 0x00000003, 0x0401f003, 0x42000800,
4855 0x0000000a, 0x41781000, 0x0401f7f7, 0x42000800,
4856 0x00000009, 0x59341400, 0x0401f7f3, 0x42028000,
4857 0x00000008, 0x0401f005, 0x42000800, 0x00000007,
4858 0x416c1000, 0x0401f7ec, 0x41780800, 0x41781000,
4859 0x0401f7cd, 0x42028000, 0x00000000, 0x0401f7fb,
4860 0x82004d80, 0x0000001d, 0x02000800, 0x001005d8,
4861 0x82004d80, 0x0000001a, 0x04020004, 0x40101000,
4862 0x40000800, 0x0401f7dc, 0x82004d80, 0x0000001b,
4863 0x04020003, 0x40181000, 0x0401f7fa, 0x82004d80,
4864 0x0000001c, 0x040007f7, 0x82004d80, 0x00000019,
4865 0x040007b8, 0x0401f7d6, 0x592e6008, 0x0201f800,
4866 0x0010941a, 0x040007b6, 0x59300c06, 0x82040580,
4867 0x00000011, 0x040207d6, 0x83440580, 0x0000ffff,
4868 0x04020005, 0x59326809, 0x813669c0, 0x0400000e,
4869 0x0401f7cf, 0x592c100a, 0x82081500, 0x00ffffff,
4870 0x41784000, 0x0401fda8, 0x040207d6, 0x59300009,
4871 0x800001c0, 0x04000003, 0x81340580, 0x040207c4,
4872 0x49366009, 0x592c0c0b, 0x82041500, 0x0000e000,
4873 0x82080580, 0x00006000, 0x04000009, 0x59300a03,
4874 0x82040580, 0x00000007, 0x040207b9, 0x492e6008,
4875 0x42027000, 0x00000054, 0x0401f77f, 0x0201f800,
4876 0x0010a8d4, 0x040007bc, 0x0401f7b1, 0x492fc857,
4877 0x59a80021, 0x800001c0, 0x04020073, 0x592e6008,
4878 0x4933c857, 0x0201f800, 0x0010941a, 0x04000041,
4879 0x59301406, 0x82080580, 0x00000005, 0x0402005b,
4880 0x59301203, 0x82080580, 0x00000007, 0x04020057,
4881 0x592e8c06, 0x83440480, 0x00000800, 0x04021032,
4882 0x41784000, 0x592c1009, 0x82081500, 0x00ffffff,
4883 0x0401fd75, 0x0402005f, 0x59300009, 0x800001c0,
4884 0x04000003, 0x81340580, 0x04020048, 0x4d300000,
4885 0x592e6013, 0x4933c857, 0x83300580, 0xffffffff,
4886 0x0400000d, 0x0201f800, 0x0010941a, 0x5c026000,
4887 0x04000029, 0x591c1406, 0x82080580, 0x00000006,
4888 0x04000046, 0x82080580, 0x00000011, 0x04000043,
4889 0x0401f002, 0x5c026000, 0x59a80010, 0x592c100a,
4890 0x82081500, 0x00ffffff, 0x80081580, 0x04020017,
4891 0x592c1009, 0x82081500, 0x00ffffff, 0x80081580,
4892 0x0400000f, 0x49366009, 0x492e6008, 0x42027000,
4893 0x00000092, 0x0201f800, 0x000207a1, 0x80000580,
4894 0x1c01f000, 0x42001000, 0x0000000a, 0x0401f00c,
4895 0x42001000, 0x00000010, 0x0401f009, 0x42001000,
4896 0x00000014, 0x0401f006, 0x42001000, 0x00000018,
4897 0x0401f003, 0x42001000, 0x0000003c, 0x492fc857,
4898 0x480bc857, 0x42000800, 0x00000019, 0x42028000,
4899 0x00000031, 0x82000540, 0x00000001, 0x0401f7e9,
4900 0x492fc857, 0x4803c857, 0x480bc857, 0x40000800,
4901 0x0401f7f7, 0x492fc857, 0x42000800, 0x0000000a,
4902 0x41781000, 0x0401f7f2, 0x4933c857, 0x59300406,
4903 0x4803c857, 0x59300203, 0x4803c857, 0x59300009,
4904 0x4803c857, 0x42028000, 0x00000008, 0x41780800,
4905 0x41781000, 0x0401f7e8, 0x42000800, 0x0000001e,
4906 0x0401f7f0, 0x42000800, 0x00000001, 0x0401f7ed,
4907 0x82004d80, 0x0000001d, 0x02000800, 0x001005d8,
4908 0x82004d80, 0x0000001a, 0x04020003, 0x40101000,
4909 0x0401f7dc, 0x82004d80, 0x0000001b, 0x04020003,
4910 0x40181000, 0x0401f7d7, 0x82004d80, 0x0000001c,
4911 0x040007d4, 0x82004d80, 0x00000019, 0x040007d1,
4912 0x0401f7d5, 0x59302009, 0x801021c0, 0x04000035,
4913 0x58101400, 0x82081d00, 0x000000ff, 0x59300c03,
4914 0x82040580, 0x00000008, 0x04000022, 0x82040580,
4915 0x0000000a, 0x04000017, 0x82040580, 0x0000000c,
4916 0x04000010, 0x82040580, 0x00000002, 0x04000019,
4917 0x82040580, 0x00000001, 0x04000012, 0x82040580,
4918 0x00000003, 0x0400000b, 0x82040580, 0x00000005,
4919 0x04000004, 0x82040580, 0x00000033, 0x04020019,
4920 0x820c0580, 0x00000009, 0x0400000d, 0x0401f015,
4921 0x820c0580, 0x00000005, 0x04000009, 0x0401f011,
4922 0x820c0580, 0x0000000b, 0x04000005, 0x0401f00d,
4923 0x820c0580, 0x00000003, 0x0402000a, 0x82081d00,
4924 0xffffff00, 0x840c01c0, 0x800c0540, 0x4813c857,
4925 0x480bc857, 0x4807c857, 0x4803c857, 0x48002400,
4926 0x1c01f000, 0x599c0017, 0x8c00050a, 0x04000003,
4927 0x80000580, 0x1c01f000, 0x59a80026, 0x82000500,
4928 0x00000028, 0x04000008, 0x42028800, 0x000007fd,
4929 0x0201f800, 0x00020245, 0x04020003, 0x5934000a,
4930 0x8c000504, 0x1c01f000, 0x4d300000, 0x5934000e,
4931 0x80026540, 0x04000006, 0x0201f800, 0x001062d5,
4932 0x02000800, 0x001064ad, 0x497a680e, 0x5c026000,
4933 0x1c01f000, 0x4d440000, 0x4d340000, 0x80000580,
4934 0x40001800, 0x40028800, 0x82080580, 0x00000008,
4935 0x04020003, 0x42001800, 0x00000001, 0x0201f800,
4936 0x00020245, 0x0402000a, 0x0401fd6d, 0x04020008,
4937 0x800c19c0, 0x04000004, 0x59340405, 0x8c000508,
4938 0x04000003, 0x80081040, 0x04000009, 0x81468800,
4939 0x83440480, 0x00000800, 0x040017f1, 0x80000580,
4940 0x5c026800, 0x5c028800, 0x1c01f000, 0x82000540,
4941 0x00000001, 0x5c026800, 0x5c028800, 0x1c01f000,
4942 0x4a033020, 0x00000000, 0x497b3026, 0x497b3027,
4943 0x497b3028, 0x497b3029, 0x497b302b, 0x497b3021,
4944 0x4a03b104, 0x60000001, 0x1c01f000, 0x4803c856,
4945 0x599c0018, 0x497b3024, 0x497b3025, 0x82000500,
4946 0x0000000f, 0x82000d80, 0x00000005, 0x04000006,
4947 0x82000580, 0x00000006, 0x0400000d, 0x497b3022,
4948 0x1c01f000, 0x4a033022, 0x00000005, 0x599c0216,
4949 0x82000500, 0x0000ffff, 0x04020003, 0x42000000,
4950 0x00000002, 0x48033023, 0x1c01f000, 0x4a033022,
4951 0x00000006, 0x0401f7f6, 0x0401ffe5, 0x4a03c826,
4952 0x00000004, 0x599c0209, 0x80000540, 0x0400001f,
4953 0x599c0207, 0x80000540, 0x04000007, 0x800000cc,
4954 0x599c080d, 0x80040400, 0x4803b100, 0x497bb102,
4955 0x59d80101, 0x599c000d, 0x4803b100, 0x599c000e,
4956 0x4803b101, 0x599c0207, 0x80000540, 0x04020002,
4957 0x497bb102, 0x599c0a09, 0x82040540, 0x00400000,
4958 0x59980822, 0x4803b103, 0x4a03b109, 0x00000004,
4959 0x4a03b104, 0x10000001, 0x800409c0, 0x04020004,
4960 0x4a033020, 0x00000001, 0x1c01f000, 0x4a033020,
4961 0x00000002, 0x0401f7fd, 0x59980022, 0x4803c856,
4962 0x80000540, 0x02000000, 0x000202de, 0x0401f017,
4963 0x42034000, 0x0010b4a4, 0x59a1d81e, 0x80edd9c0,
4964 0x02000800, 0x001005d8, 0x58ec0009, 0x48efc857,
4965 0x49a3c857, 0x492fc857, 0x4803c857, 0x800001c0,
4966 0x08020000, 0x0201f800, 0x001005d8, 0x5931d821,
4967 0x58ef400b, 0x58ec0009, 0x800001c0, 0x08020000,
4968 0x0201f800, 0x001005d8, 0x497a5800, 0x59980026,
4969 0x80000540, 0x0402008c, 0x59d80105, 0x82000d00,
4970 0x00018780, 0x040201da, 0x80000106, 0x82000500,
4971 0x00000003, 0x0c01f001, 0x00104d0a, 0x00104d89,
4972 0x00104d22, 0x00104d50, 0x592c0001, 0x492fc857,
4973 0x492fb107, 0x80000d40, 0x04020007, 0x59940019,
4974 0x80000540, 0x04022003, 0x59980023, 0x48032819,
4975 0x1c01f000, 0x497a5801, 0x40065800, 0x592c0001,
4976 0x496a5800, 0x815eb800, 0x412ed000, 0x80000d40,
4977 0x040207f9, 0x59c80000, 0x82000540, 0x00001200,
4978 0x48039000, 0x0401f7ee, 0x492fc857, 0x492fb107,
4979 0x592c0001, 0x80000d40, 0x04020012, 0x59da5908,
4980 0x835c0480, 0x00000020, 0x0400101c, 0x0402b01a,
4981 0x492fb007, 0x0400e7fa, 0x59d80105, 0x82000500,
4982 0x00018780, 0x040201aa, 0x59940019, 0x80000540,
4983 0x04022003, 0x59980023, 0x48032819, 0x1c01f000,
4984 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800,
4985 0x815eb800, 0x412ed000, 0x80000d40, 0x040207f9,
4986 0x59c80000, 0x82000540, 0x00001200, 0x48039000,
4987 0x0401f7e3, 0x0400f009, 0x496a5800, 0x412ed000,
4988 0x815eb800, 0x59c80000, 0x82000540, 0x00001200,
4989 0x48039000, 0x0401f7e0, 0x492fa807, 0x0401f7de,
4990 0x492fc857, 0x59d81108, 0x45681000, 0x400ad000,
4991 0x815eb800, 0x0400e7fc, 0x59c80000, 0x82000540,
4992 0x00001200, 0x48039000, 0x0402d00c, 0x592c0001,
4993 0x492fc857, 0x492fb107, 0x80000d40, 0x0402001d,
4994 0x59940019, 0x80000540, 0x04022003, 0x59980023,
4995 0x48032819, 0x1c01f000, 0x59d80105, 0x82000500,
4996 0x00018780, 0x04020172, 0x42000000, 0x0010b855,
4997 0x0201f800, 0x0010aa47, 0x59980026, 0x59980828,
4998 0x80000000, 0x48033026, 0x492fc857, 0x800409c0,
4999 0x492f3028, 0x04000003, 0x492c0800, 0x0401f002,
5000 0x492f3029, 0x592c0001, 0x80000d40, 0x040007e5,
5001 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800,
5002 0x815eb800, 0x412ed000, 0x80000d40, 0x040207f9,
5003 0x59c80000, 0x82000540, 0x00001200, 0x48039000,
5004 0x0401f7d8, 0x59980026, 0x59980828, 0x80000000,
5005 0x48033026, 0x492fc857, 0x800409c0, 0x492f3028,
5006 0x04000003, 0x492c0800, 0x0401f002, 0x492f3029,
5007 0x592c0001, 0x80000d40, 0x04020027, 0x0402d00e,
5008 0x59980029, 0x80025d40, 0x0400000f, 0x59980026,
5009 0x80000040, 0x48033026, 0x04020002, 0x48033028,
5010 0x592c0000, 0x48033029, 0x492fc857, 0x492fb107,
5011 0x0400d7f4, 0x42000000, 0x0010b855, 0x0201f800,
5012 0x0010aa47, 0x0402e00a, 0x59da5908, 0x496a5800,
5013 0x412ed000, 0x815eb800, 0x0400e7fc, 0x59c80000,
5014 0x82000540, 0x00001200, 0x48039000, 0x59d80105,
5015 0x82000500, 0x00018780, 0x04020125, 0x59940019,
5016 0x80000540, 0x04022003, 0x59980023, 0x48032819,
5017 0x1c01f000, 0x497a5801, 0x40065800, 0x592c0001,
5018 0x496a5800, 0x815eb800, 0x412ed000, 0x80000d40,
5019 0x040207f9, 0x59c80000, 0x82000540, 0x00001200,
5020 0x48039000, 0x0401f7ce, 0x592c0204, 0x4803c856,
5021 0x04000008, 0x42034000, 0x0010b4a4, 0x59a1d81e,
5022 0x80edd9c0, 0x02000800, 0x001005d8, 0x0401f003,
5023 0x5931d821, 0x58ef400b, 0x58ec0009, 0x800001c0,
5024 0x08020000, 0x0201f800, 0x001005d8, 0x497a5801,
5025 0x40065800, 0x592c0001, 0x496a5800, 0x412ed000,
5026 0x815eb800, 0x80000d40, 0x040207f9, 0x59c80000,
5027 0x82000540, 0x00001200, 0x48039000, 0x1c01f000,
5028 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800,
5029 0x412ed000, 0x815eb800, 0x80000d40, 0x040207f9,
5030 0x59c80000, 0x82000540, 0x00001200, 0x48039000,
5031 0x0200e000, 0x000202fb, 0x0201f000, 0x00020302,
5032 0x5998002b, 0x84000540, 0x4803302b, 0x0201f000,
5033 0x0002035e, 0x42000000, 0x0010b855, 0x0201f800,
5034 0x0010aa47, 0x492fc857, 0x59980026, 0x59980828,
5035 0x80000000, 0x48033026, 0x800409c0, 0x492f3028,
5036 0x04000003, 0x492c0800, 0x0401f002, 0x492f3029,
5037 0x592c0001, 0x80000d40, 0x04020002, 0x1c01f000,
5038 0x497a5801, 0x40065800, 0x592c0001, 0x496a5800,
5039 0x412ed000, 0x815eb800, 0x80000d40, 0x040207f9,
5040 0x59c80000, 0x82000540, 0x00001200, 0x48039000,
5041 0x1c01f000, 0x59980026, 0x59980828, 0x80000000,
5042 0x48033026, 0x492fc857, 0x800409c0, 0x492f3028,
5043 0x04000003, 0x492c0800, 0x0401f002, 0x492f3029,
5044 0x592c0001, 0x80000d40, 0x04020039, 0x0402d00e,
5045 0x59980029, 0x80025d40, 0x0400000f, 0x59980026,
5046 0x80000040, 0x48033026, 0x04020002, 0x48033028,
5047 0x592c0000, 0x48033029, 0x492fc857, 0x492fb107,
5048 0x0400d7f4, 0x42000000, 0x0010b855, 0x0201f800,
5049 0x0010aa47, 0x0402e01d, 0x59da5908, 0x496a5800,
5050 0x412ed000, 0x815eb800, 0x0400e7fc, 0x59c80000,
5051 0x82000540, 0x00001200, 0x48039000, 0x04006018,
5052 0x59d8010a, 0x59d8090a, 0x80040d80, 0x040207fd,
5053 0x900001c0, 0x82000540, 0x00000013, 0x4803c011,
5054 0x5998002b, 0x84000500, 0x4803302b, 0x59e00017,
5055 0x8c000508, 0x04000003, 0x4a03c017, 0x00000003,
5056 0x4203e000, 0x30000001, 0x59d80105, 0x82000500,
5057 0x00018780, 0x0402007e, 0x1c01f000, 0x5998002b,
5058 0x84000540, 0x4803302b, 0x0401f7f8, 0x497a5801,
5059 0x40065800, 0x592c0001, 0x496a5800, 0x412ed000,
5060 0x815eb800, 0x80000d40, 0x040207f9, 0x59c80000,
5061 0x82000540, 0x00001200, 0x48039000, 0x0401f7bc,
5062 0x5c000000, 0x4c000000, 0x4803c857, 0x492fc857,
5063 0x4943c857, 0x4807c857, 0x4a025a04, 0x00000103,
5064 0x49425a06, 0x48065a08, 0x4a025c06, 0x0000ffff,
5065 0x813261c0, 0x04000003, 0x59300402, 0x48025c06,
5066 0x832c0400, 0x00000009, 0x04011000, 0x4803c840,
5067 0x4a03c842, 0x0000000b, 0x04011000, 0x1c01f000,
5068 0x4df00000, 0x4203e000, 0x50000000, 0x599cb817,
5069 0x59940019, 0x80000540, 0x04002023, 0x0400000e,
5070 0x59980022, 0x82000580, 0x00000005, 0x0400001e,
5071 0x59a80069, 0x81640580, 0x0402001b, 0x8c5cbd08,
5072 0x04000005, 0x59a8006a, 0x59a80866, 0x80040580,
5073 0x04020015, 0x8c5cbd08, 0x04020030, 0x59d8090b,
5074 0x59d8010a, 0x80040580, 0x0400000d, 0x0400600e,
5075 0x4a03c011, 0x80400012, 0x4a03c020, 0x00008040,
5076 0x59e00017, 0x8c000508, 0x04000003, 0x4a03c017,
5077 0x00000002, 0x4203e000, 0x30000001, 0x4a032819,
5078 0xffff0000, 0x04026835, 0x04006003, 0x8c5cbd08,
5079 0x04020860, 0x59980029, 0x80025d40, 0x04000010,
5080 0x59d80105, 0x82000500, 0x00018780, 0x04020020,
5081 0x0402d00d, 0x59980026, 0x492fc857, 0x80000040,
5082 0x48033026, 0x592c0000, 0x492fb107, 0x48033029,
5083 0x04020003, 0x4803c856, 0x48033028, 0x5c03e000,
5084 0x1c01f000, 0x42000000, 0x0010b855, 0x0201f800,
5085 0x0010aa47, 0x0401f7fa, 0x59e0000f, 0x59e0080f,
5086 0x80040580, 0x040207fd, 0x59e00010, 0x59e01010,
5087 0x80081580, 0x040207fd, 0x40065000, 0x80041580,
5088 0x040007c7, 0x040067dc, 0x0401f7ca, 0x4803c857,
5089 0x485fc857, 0x8c00050e, 0x02020800, 0x001005d0,
5090 0x4203e000, 0x50000000, 0x4200b800, 0x00008004,
5091 0x0201f000, 0x001005dd, 0x5998002b, 0x8c000500,
5092 0x04000013, 0x84000500, 0x4803302b, 0x59d8010a,
5093 0x59d8090a, 0x80040580, 0x040207fd, 0x800408e0,
5094 0x82040d40, 0x00000013, 0x4807c011, 0x59e00017,
5095 0x8c000508, 0x04000003, 0x4a03c017, 0x00000003,
5096 0x4203e000, 0x30000001, 0x1c01f000, 0x0402e014,
5097 0x59da5908, 0x496a5800, 0x412ed000, 0x815eb800,
5098 0x0400e7fc, 0x59c80000, 0x82000540, 0x00001200,
5099 0x48039000, 0x59d8090b, 0x59980024, 0x48073024,
5100 0x80040480, 0x04020004, 0x59940019, 0x80000540,
5101 0x04022003, 0x59980823, 0x48072819, 0x59d80105,
5102 0x82000500, 0x00018780, 0x040207c9, 0x1c01f000,
5103 0x59981025, 0x59e00010, 0x59e00810, 0x80041d80,
5104 0x040207fd, 0x80080580, 0x04000013, 0x48073025,
5105 0x59e0000f, 0x59e0100f, 0x80081d80, 0x040207fd,
5106 0x81280580, 0x04000008, 0x400a5000, 0x40080000,
5107 0x80040580, 0x04000003, 0x59980823, 0x48072819,
5108 0x1c01f000, 0x59940019, 0x80000540, 0x040227f8,
5109 0x0401f7fc, 0x59e0000f, 0x59e0100f, 0x80081d80,
5110 0x040207fd, 0x81280580, 0x040007f6, 0x400a5000,
5111 0x59940019, 0x80000540, 0x040027ed, 0x0401f7f1,
5112 0x59a80017, 0x82000c80, 0x0000000a, 0x02021800,
5113 0x001005d8, 0x0c01f809, 0x4a038805, 0x000000f0,
5114 0x59c400a3, 0x82000500, 0x02870000, 0x02020800,
5115 0x001005d8, 0x1c01f000, 0x00104fc5, 0x00104f51,
5116 0x00104f6c, 0x00104f95, 0x00104fb8, 0x00104ff2,
5117 0x00105004, 0x00104f6c, 0x00104fd6, 0x00104f50,
5118 0x1c01f000, 0x4a038808, 0x00000004, 0x0401f8f9,
5119 0x0201f800, 0x001053ab, 0x59c40805, 0x8c040d0e,
5120 0x04020013, 0x8c040d0a, 0x0402000b, 0x8c040d0c,
5121 0x04020006, 0x8c040d08, 0x0400000d, 0x4a035017,
5122 0x00000003, 0x0401f00a, 0x4a035017, 0x00000000,
5123 0x0401f007, 0x42000000, 0x0010b844, 0x0201f800,
5124 0x0010aa47, 0x4a035017, 0x00000002, 0x1c01f000,
5125 0x4a038808, 0x00000002, 0x0401f8de, 0x59c40805,
5126 0x8c040d08, 0x04020021, 0x8c040d0c, 0x0402001c,
5127 0x8c040d0e, 0x04020017, 0x82040500, 0x000000f0,
5128 0x0402001c, 0x0201f800, 0x001053ab, 0x4a038808,
5129 0x00000080, 0x59c40002, 0x8400050c, 0x48038802,
5130 0x0401f9d9, 0x4d3c0000, 0x42027800, 0x00000001,
5131 0x0201f800, 0x00109874, 0x5c027800, 0x4a038808,
5132 0x00000080, 0x4a035017, 0x00000009, 0x0401f009,
5133 0x4a035017, 0x00000001, 0x0401f006, 0x4a035017,
5134 0x00000000, 0x0401f003, 0x4a035017, 0x00000003,
5135 0x1c01f000, 0x0401f8b7, 0x4a038808, 0x00000080,
5136 0x59c40805, 0x8c040d0a, 0x0402001b, 0x8c040d0c,
5137 0x04020016, 0x8c040d0e, 0x04020011, 0x82040500,
5138 0x000000f0, 0x04020016, 0x59c40002, 0x8400050c,
5139 0x48038802, 0x0401f9b4, 0x4d3c0000, 0x42027800,
5140 0x00000001, 0x0201f800, 0x00109874, 0x5c027800,
5141 0x4a035017, 0x00000009, 0x0401f009, 0x4a035017,
5142 0x00000001, 0x0401f006, 0x4a035017, 0x00000000,
5143 0x0401f003, 0x4a035017, 0x00000002, 0x1c01f000,
5144 0x4a038808, 0x00000008, 0x59c40805, 0x8c040d0c,
5145 0x04020006, 0x8c040d0e, 0x04000006, 0x4a035017,
5146 0x00000001, 0x0401f003, 0x4a035017, 0x00000000,
5147 0x1c01f000, 0x0401f8d3, 0x59c40805, 0x8c040d0c,
5148 0x0402000d, 0x4c040000, 0x0401f882, 0x5c000800,
5149 0x8c040d0a, 0x04020006, 0x8c040d0e, 0x04000006,
5150 0x4a035017, 0x00000001, 0x0401f003, 0x4a035017,
5151 0x00000002, 0x1c01f000, 0x4a038808, 0x00000008,
5152 0x42001000, 0x00105058, 0x0201f800, 0x00106084,
5153 0x59c40805, 0x8c040d0a, 0x0402000d, 0x8c040d08,
5154 0x0402000b, 0x8c040d0c, 0x04020006, 0x8c040d0e,
5155 0x0400000d, 0x4a035017, 0x00000001, 0x0401f00a,
5156 0x4a035017, 0x00000000, 0x0401f007, 0x42000000,
5157 0x0010b844, 0x0201f800, 0x0010aa47, 0x4a035017,
5158 0x00000004, 0x1c01f000, 0x0401f8a6, 0x0401f859,
5159 0x59c40805, 0x8c040d0a, 0x0402000b, 0x8c040d0c,
5160 0x04020006, 0x8c040d0e, 0x04000009, 0x4a035017,
5161 0x00000001, 0x0401f006, 0x4a035017, 0x00000000,
5162 0x0401f003, 0x4a035017, 0x00000002, 0x1c01f000,
5163 0x4a038808, 0x00000004, 0x0401f846, 0x59c40805,
5164 0x8c040d0a, 0x04020010, 0x8c040d08, 0x0402000b,
5165 0x8c040d0c, 0x04020006, 0x8c040d0e, 0x0400000c,
5166 0x4a035017, 0x00000001, 0x0401f009, 0x4a035017,
5167 0x00000000, 0x0401f006, 0x4a035017, 0x00000003,
5168 0x0401f003, 0x4a035017, 0x00000002, 0x1c01f000,
5169 0x0401f91f, 0x02020800, 0x001005d8, 0x59a80805,
5170 0x8c040d0c, 0x04000015, 0x84040d0c, 0x48075005,
5171 0x4a038805, 0x00000010, 0x0201f800, 0x00101937,
5172 0x59c40005, 0x8c000508, 0x04000008, 0x4a038808,
5173 0x00000008, 0x4a035033, 0x00000001, 0x4202d800,
5174 0x00000001, 0x0401f01a, 0x59c40006, 0x84000548,
5175 0x48038806, 0x0401f016, 0x59a80017, 0x82000580,
5176 0x00000001, 0x0400000c, 0x59a80017, 0x82000580,
5177 0x00000005, 0x0402000c, 0x42000000, 0x0010b844,
5178 0x0201f800, 0x0010aa47, 0x4a035017, 0x00000008,
5179 0x0401f007, 0x42000000, 0x0010b844, 0x0201f800,
5180 0x0010aa47, 0x4a035017, 0x00000004, 0x1c01f000,
5181 0x4803c856, 0x4c040000, 0x4c080000, 0x42000800,
5182 0x00000064, 0x42001000, 0x00105058, 0x0201f800,
5183 0x00106079, 0x5c001000, 0x5c000800, 0x1c01f000,
5184 0x4803c856, 0x4c040000, 0x0201f800, 0x00106c55,
5185 0x4df00000, 0x0201f800, 0x00106e21, 0x5c03e000,
5186 0x02000800, 0x00106c4b, 0x0401ffba, 0x5c000800,
5187 0x1c01f000, 0x4803c856, 0x4c040000, 0x4c080000,
5188 0x0201f800, 0x00106c55, 0x4df00000, 0x0201f800,
5189 0x00106e21, 0x5c03e000, 0x02000800, 0x00106c4b,
5190 0x59c40006, 0x84000500, 0x48038806, 0x0201f800,
5191 0x00106ede, 0x497b8880, 0x0201f800, 0x0010a9c0,
5192 0x0201f800, 0x0010a9ce, 0x0201f800, 0x00101815,
5193 0x4a03504c, 0x00000004, 0x4202d800, 0x00000004,
5194 0x4a038805, 0x00000001, 0x42001000, 0x00105058,
5195 0x0201f800, 0x00106084, 0x0201f800, 0x001006d4,
5196 0x0401f8c1, 0x04000006, 0x42006000, 0xfeffffff,
5197 0x41786800, 0x0201f800, 0x0010427d, 0x0201f800,
5198 0x00100452, 0x42000000, 0x00000001, 0x0201f800,
5199 0x00101590, 0x5c001000, 0x5c000800, 0x1c01f000,
5200 0x59c40008, 0x8c000508, 0x04020007, 0x4a038808,
5201 0x00000010, 0x4201d000, 0x00001388, 0x0201f800,
5202 0x0010608e, 0x1c01f000, 0x4c040000, 0x59a80833,
5203 0x82040580, 0x00000000, 0x0400000b, 0x82040580,
5204 0x00000001, 0x0400000b, 0x82040580, 0x00000002,
5205 0x0400000b, 0x82040580, 0x00000003, 0x0400000b,
5206 0x0401f057, 0x4a035017, 0x00000000, 0x0401f009,
5207 0x4a035017, 0x00000004, 0x0401f006, 0x4a035017,
5208 0x00000001, 0x0401f003, 0x4a035017, 0x00000007,
5209 0x497b8880, 0x4a038893, 0x00000001, 0x41780000,
5210 0x0201f800, 0x00101606, 0x0201f800, 0x00106ede,
5211 0x836c0d80, 0x00000004, 0x04000008, 0x59c40006,
5212 0x82000500, 0xffffff0f, 0x82000540, 0x04000001,
5213 0x48038806, 0x0401f007, 0x59c40006, 0x82000500,
5214 0xffffff0f, 0x82000540, 0x04000000, 0x48038806,
5215 0x0401f875, 0x04020005, 0x59c40806, 0x82040d00,
5216 0xfbffff0f, 0x48078806, 0x4200b000, 0x00000005,
5217 0x59c40005, 0x8c000534, 0x04020033, 0x42006000,
5218 0xfc18ffff, 0x42006800, 0x01000000, 0x0201f800,
5219 0x0010427d, 0x0201f800, 0x00101937, 0x59c408a4,
5220 0x82040d00, 0x0000000f, 0x82040d80, 0x0000000c,
5221 0x0400000a, 0x42006000, 0xfeffffff, 0x42006800,
5222 0x02000000, 0x0201f800, 0x0010427d, 0x8058b040,
5223 0x040207e8, 0x0401f8a1, 0x0401f853, 0x04000006,
5224 0x42006000, 0xfeffffff, 0x41786800, 0x0201f800,
5225 0x0010427d, 0x836c0d80, 0x00000004, 0x04000006,
5226 0x59a8084d, 0x42001000, 0x00105065, 0x0201f800,
5227 0x0010606e, 0x4a035033, 0x00000004, 0x0401fe31,
5228 0x0401f841, 0x04020008, 0x59c408a4, 0x82040d00,
5229 0x0000000f, 0x82040580, 0x0000000c, 0x02020800,
5230 0x001005d8, 0x5c000800, 0x1c01f000, 0x4803c856,
5231 0x4c000000, 0x0201f800, 0x0010609e, 0x4a035010,
5232 0x00ffffff, 0x497b5032, 0x59a8002a, 0x82000500,
5233 0xffff0000, 0x4803502a, 0x497b8880, 0x497b8893,
5234 0x41780000, 0x0201f800, 0x00101606, 0x59c40001,
5235 0x82000500, 0xfffffcff, 0x48038801, 0x42006000,
5236 0xfc18ffff, 0x41786800, 0x0201f800, 0x0010427d,
5237 0x4a038808, 0x00000000, 0x5c000000, 0x800001c0,
5238 0x02020800, 0x0010411d, 0x4a038805, 0x040000f0,
5239 0x59c40006, 0x82000500, 0xffffffcf, 0x82000540,
5240 0x440000c1, 0x48038806, 0x1c01f000, 0x4c5c0000,
5241 0x59a8b832, 0x825cbd80, 0x0000aaaa, 0x5c00b800,
5242 0x1c01f000, 0x4c5c0000, 0x599cb818, 0x825cbd00,
5243 0x00000030, 0x825cbd80, 0x00000000, 0x5c00b800,
5244 0x1c01f000, 0x4c5c0000, 0x599cb818, 0x825cbd00,
5245 0x00000030, 0x825cbd80, 0x00000010, 0x5c00b800,
5246 0x1c01f000, 0x4c5c0000, 0x599cb818, 0x825cbd00,
5247 0x00000030, 0x825cbd80, 0x00000020, 0x5c00b800,
5248 0x1c01f000, 0x59a80005, 0x4803c857, 0x82000d00,
5249 0x00000013, 0x04000025, 0x599c1017, 0x4d3c0000,
5250 0x82000500, 0x00000011, 0x04000007, 0x42027800,
5251 0x00000400, 0x0201f800, 0x00103b25, 0x0402000a,
5252 0x0401f012, 0x42027800, 0x00000408, 0x0201f800,
5253 0x00103b25, 0x0400000d, 0x42003000, 0x00000003,
5254 0x0401f003, 0x42003000, 0x00000004, 0x42028000,
5255 0x0000000e, 0x0201f800, 0x0010a449, 0x599c1017,
5256 0x8c08150a, 0x04020007, 0x42028000, 0x00000004,
5257 0x0201f800, 0x00101fe5, 0x80000580, 0x0401f80d,
5258 0x5c027800, 0x0401f00a, 0x0201f800, 0x00103b25,
5259 0x04000007, 0x42028000, 0x0000000f, 0x42003000,
5260 0x00000001, 0x0201f800, 0x0010a449, 0x1c01f000,
5261 0x59a80005, 0x04000004, 0x82000540, 0x00000010,
5262 0x0401f003, 0x82000500, 0xffffffef, 0x48035005,
5263 0x4803c857, 0x1c01f000, 0x4803c856, 0x4c580000,
5264 0x42000000, 0x0010b8cb, 0x0201f800, 0x0010aa47,
5265 0x42000800, 0x0010c0f1, 0x59c40003, 0x44000800,
5266 0x59c40004, 0x48000801, 0x59c4000b, 0x48000802,
5267 0x59c4008e, 0x48000803, 0x59c4008f, 0x48000804,
5268 0x59c40090, 0x48000805, 0x59c40091, 0x48000806,
5269 0x59c40092, 0x48000807, 0x59c40093, 0x48000808,
5270 0x59c40099, 0x48000809, 0x59c4009e, 0x4800080a,
5271 0x59c400aa, 0x4800080b, 0x59c400af, 0x4800080c,
5272 0x59c400b2, 0x4800080d, 0x59c400b1, 0x4800080e,
5273 0x82040c00, 0x0000000f, 0x41c41800, 0x4200b000,
5274 0x00000030, 0x580c0050, 0x44000800, 0x80040800,
5275 0x800c1800, 0x8058b040, 0x040207fb, 0x41c41800,
5276 0x4200b000, 0x00000020, 0x580c0010, 0x44000800,
5277 0x80040800, 0x800c1800, 0x8058b040, 0x040207fb,
5278 0x497b8830, 0x4200b000, 0x00000040, 0x59c40031,
5279 0x44000800, 0x80040800, 0x8058b040, 0x040207fc,
5280 0x497b88ac, 0x4200b000, 0x00000010, 0x59c400ad,
5281 0x44000800, 0x80040800, 0x8058b040, 0x040207fc,
5282 0x59c41001, 0x4c080000, 0x8408150c, 0x480b8801,
5283 0x4a0370e4, 0x00000300, 0x4a0370e5, 0xb0000000,
5284 0x42000800, 0x00000800, 0x80040840, 0x02000800,
5285 0x001005d8, 0x59b800e5, 0x8c000538, 0x040207fb,
5286 0x4a0370e4, 0x00000200, 0x42006000, 0xffffffff,
5287 0x42006800, 0x80000000, 0x0201f800, 0x0010427d,
5288 0x4a038807, 0x00000001, 0x497b8807, 0x4a038808,
5289 0x00000010, 0x42006000, 0xfcf8ffff, 0x42006800,
5290 0x01000000, 0x0201f800, 0x0010427d, 0x5c001000,
5291 0x480b8801, 0x42000800, 0x0010c0f1, 0x50040000,
5292 0x48038803, 0x58040001, 0x48038804, 0x58040002,
5293 0x4803880b, 0x58040003, 0x4803888e, 0x58040004,
5294 0x4803888f, 0x58040005, 0x48038890, 0x58040006,
5295 0x48038891, 0x58040007, 0x48038892, 0x58040008,
5296 0x48038893, 0x58040009, 0x48038899, 0x5804000a,
5297 0x4803889e, 0x5804000b, 0x480388aa, 0x5804000c,
5298 0x480388af, 0x5804000d, 0x480388b2, 0x5804000e,
5299 0x480388b1, 0x82040c00, 0x0000000f, 0x41c41800,
5300 0x4200b000, 0x00000030, 0x50040000, 0x48001850,
5301 0x80040800, 0x800c1800, 0x8058b040, 0x040207fb,
5302 0x41c41800, 0x4200b000, 0x00000020, 0x50040000,
5303 0x48001810, 0x80040800, 0x800c1800, 0x8058b040,
5304 0x040207fb, 0x497b8830, 0x4200b000, 0x00000040,
5305 0x50040000, 0x48038831, 0x80040800, 0x8058b040,
5306 0x040207fc, 0x497b88ac, 0x4200b000, 0x00000010,
5307 0x50040000, 0x480388ad, 0x80040800, 0x8058b040,
5308 0x040207fc, 0x497b8880, 0x41780000, 0x0201f800,
5309 0x00101606, 0x59c408a4, 0x82040d00, 0x0000000f,
5310 0x82040580, 0x0000000c, 0x02020800, 0x001005d8,
5311 0x4a038805, 0x04000000, 0x5c00b000, 0x1c01f000,
5312 0x4803c856, 0x4c580000, 0x4ce80000, 0x42000000,
5313 0x0010b845, 0x0201f800, 0x0010aa47, 0x59c41008,
5314 0x4c080000, 0x82080500, 0xffffff7f, 0x48038808,
5315 0x59c40004, 0x82000500, 0x00003e02, 0x04000005,
5316 0x4201d000, 0x00000014, 0x0201f800, 0x0010608e,
5317 0x59c40006, 0x82000500, 0xffffff0f, 0x48038806,
5318 0x4a038805, 0x00000010, 0x4a038808, 0x00000004,
5319 0x4200b000, 0x00000065, 0x59c40005, 0x8c000508,
5320 0x04020012, 0x4201d000, 0x000003e8, 0x0201f800,
5321 0x0010608e, 0x8058b040, 0x040207f8, 0x0201f800,
5322 0x00106ede, 0x4a038808, 0x00000008, 0x4a035033,
5323 0x00000001, 0x4202d800, 0x00000001, 0x82000540,
5324 0x00000001, 0x0401f030, 0x0201f800, 0x00100ae0,
5325 0x42000000, 0x0010b8a8, 0x0201f800, 0x0010aa47,
5326 0x0201f800, 0x00100ef4, 0x497b8880, 0x59a8002a,
5327 0x82000500, 0x0000ffff, 0x4c000000, 0x0201f800,
5328 0x00101606, 0x5c000000, 0x48038880, 0x4a038808,
5329 0x00000000, 0x4200b000, 0x00000065, 0x4a038805,
5330 0x000000f0, 0x0201f800, 0x00101937, 0x42000800,
5331 0x000000f0, 0x59c40005, 0x80040d00, 0x04000008,
5332 0x4201d000, 0x000003e8, 0x0201f800, 0x0010608e,
5333 0x8058b040, 0x040207f2, 0x0401f7d1, 0x59c40006,
5334 0x82000540, 0x000000f0, 0x48038806, 0x59a8001e,
5335 0x80000540, 0x04020002, 0x80000000, 0x48038893,
5336 0x80000580, 0x5c001000, 0x4df00000, 0x0201f800,
5337 0x0010195d, 0x5c03e000, 0x480b8808, 0x5c01d000,
5338 0x5c00b000, 0x1c01f000, 0x4803c856, 0x4c580000,
5339 0x4ce80000, 0x59c41008, 0x82080500, 0xffffff7f,
5340 0x48038808, 0x4c080000, 0x59c40004, 0x82000500,
5341 0x00003e02, 0x04000005, 0x4201d000, 0x00000014,
5342 0x0201f800, 0x0010608e, 0x0201f800, 0x00100ae0,
5343 0x42000000, 0x0010b8a9, 0x0201f800, 0x0010aa47,
5344 0x0201f800, 0x00100ef4, 0x4a038808, 0x00000002,
5345 0x80000580, 0x48038880, 0x48038893, 0x0201f800,
5346 0x00101606, 0x4200b000, 0x00000384, 0x4a038805,
5347 0x000000f0, 0x0201f800, 0x00101937, 0x42000800,
5348 0x000000f0, 0x59c40005, 0x80040d00, 0x04000015,
5349 0x82000500, 0x000000d0, 0x04020012, 0x4201d000,
5350 0x00000067, 0x0201f800, 0x0010608e, 0x8058b040,
5351 0x040207ef, 0x0201f800, 0x00106ede, 0x4a038808,
5352 0x00000008, 0x4a035033, 0x00000001, 0x4202d800,
5353 0x00000001, 0x82000540, 0x00000001, 0x0401f010,
5354 0x497b8880, 0x59a8001e, 0x80000540, 0x04020002,
5355 0x80000000, 0x48038893, 0x59a8002a, 0x82000500,
5356 0x0000ffff, 0x4c000000, 0x0201f800, 0x00101606,
5357 0x5c000000, 0x48038880, 0x80000580, 0x5c001000,
5358 0x4df00000, 0x0201f800, 0x0010195d, 0x5c03e000,
5359 0x480b8808, 0x5c01d000, 0x5c00b000, 0x1c01f000,
5360 0x4803c856, 0x59c40004, 0x82000500, 0x00003e02,
5361 0x0400000a, 0x0201f800, 0x00106ede, 0x4a038808,
5362 0x00000008, 0x4a035033, 0x00000001, 0x4202d800,
5363 0x00000001, 0x0401f052, 0x0201f800, 0x00100ae0,
5364 0x42000000, 0x0010b8aa, 0x0201f800, 0x0010aa47,
5365 0x0201f800, 0x00100ef4, 0x59c40006, 0x84000508,
5366 0x48038806, 0x4a038805, 0x00000010, 0x59a80805,
5367 0x84040d4c, 0x48075005, 0x42000800, 0x00000064,
5368 0x42001000, 0x00105058, 0x0201f800, 0x0010606e,
5369 0x4a038808, 0x00000000, 0x497b8880, 0x4a038805,
5370 0x000000f0, 0x0201f800, 0x00101937, 0x42000800,
5371 0x000000f0, 0x59c40005, 0x80040d00, 0x0400000e,
5372 0x82000500, 0x000000e0, 0x0402000b, 0x4201d000,
5373 0x000003e8, 0x0201f800, 0x0010608e, 0x0201f800,
5374 0x00105f48, 0x59940004, 0x80000540, 0x040207ec,
5375 0x0401f023, 0x4c080000, 0x42001000, 0x00105065,
5376 0x0201f800, 0x00105f90, 0x42001000, 0x00105058,
5377 0x0201f800, 0x00106084, 0x5c001000, 0x497b8880,
5378 0x59a8001e, 0x80000540, 0x04020002, 0x80000000,
5379 0x48038893, 0x59a8002a, 0x82000500, 0x0000ffff,
5380 0x4c000000, 0x0201f800, 0x00101606, 0x5c000000,
5381 0x48038880, 0x59a80805, 0x84040d0c, 0x48075005,
5382 0x59c40006, 0x84000548, 0x48038806, 0x0201f800,
5383 0x0010195d, 0x4a038808, 0x00000080, 0x1c01f000,
5384 0x4803c856, 0x4d400000, 0x4d3c0000, 0x0201f800,
5385 0x00106ede, 0x0201f800, 0x0010ab33, 0x04020025,
5386 0x599c1017, 0x59a80805, 0x8c040d00, 0x0402000c,
5387 0x8c08151a, 0x0400001f, 0x84040d42, 0x48075005,
5388 0x42028000, 0x00000004, 0x42027800, 0x0000000c,
5389 0x8c081508, 0x04020008, 0x0401f012, 0x42028000,
5390 0x00000004, 0x42027800, 0x00000004, 0x8c081508,
5391 0x0400000c, 0x4d400000, 0x42028000, 0x0000000e,
5392 0x42028800, 0x0000ffff, 0x0201f800, 0x0010a446,
5393 0x5c028000, 0x599c0817, 0x8c040d0a, 0x04020005,
5394 0x4943c857, 0x493fc857, 0x0201f800, 0x00101fe5,
5395 0x497b8880, 0x4202d800, 0x00000001, 0x0401fcfb,
5396 0x5c027800, 0x5c028000, 0x1c01f000, 0x0201f800,
5397 0x00100ae0, 0x42000000, 0x0010b8ab, 0x0201f800,
5398 0x0010aa47, 0x0201f800, 0x00100ef4, 0x42000000,
5399 0x00000001, 0x0201f800, 0x00101606, 0x4a038880,
5400 0x00000001, 0x0201f000, 0x0010195d, 0x4202e000,
5401 0x00000000, 0x4a033015, 0x00000001, 0x497b301d,
5402 0x497b3006, 0x4a03b004, 0x60000001, 0x59d80005,
5403 0x4a03b004, 0x90000001, 0x4a03a804, 0x60000001,
5404 0x59d40005, 0x4a03a804, 0x90000001, 0x0201f000,
5405 0x00105983, 0x4a03c825, 0x00000004, 0x4a03c827,
5406 0x00000004, 0x599c0409, 0x80000d40, 0x04000020,
5407 0x599c0407, 0x80000540, 0x04000007, 0x800000cc,
5408 0x599c100b, 0x80080400, 0x4803b000, 0x497bb002,
5409 0x59d80001, 0x599c000b, 0x4803b000, 0x599c000c,
5410 0x4803b001, 0x599c0407, 0x80000540, 0x04020002,
5411 0x497bb002, 0x599c0c09, 0x82040540, 0x00400000,
5412 0x4803b003, 0x4a03b009, 0x00000004, 0x4a03b004,
5413 0x10000001, 0x59e00803, 0x82040d00, 0xfffffeff,
5414 0x82040d40, 0x00008000, 0x4807c003, 0x599c040a,
5415 0x80000540, 0x04000020, 0x599c0408, 0x80000540,
5416 0x04000007, 0x800000cc, 0x599c100f, 0x80080400,
5417 0x4803a800, 0x497ba802, 0x59d40001, 0x599c000f,
5418 0x4803a800, 0x599c0010, 0x4803a801, 0x599c0408,
5419 0x80000540, 0x04020002, 0x497ba802, 0x599c0c0a,
5420 0x82040540, 0x00400000, 0x4803a803, 0x4a03a809,
5421 0x00000004, 0x4a03a804, 0x10000001, 0x59e00803,
5422 0x82040d00, 0xfffffbff, 0x82040d40, 0x00008000,
5423 0x4807c003, 0x800409c0, 0x04000007, 0x4202e000,
5424 0x00000001, 0x0200b800, 0x00020551, 0x0200f000,
5425 0x00020566, 0x1c01f000, 0x0201f800, 0x001005d8,
5426 0x1c01f000, 0x4df00000, 0x4203e000, 0x50000000,
5427 0x59981005, 0x800811c0, 0x0400001e, 0x58080005,
5428 0x82000d00, 0x43018780, 0x02020000, 0x00105846,
5429 0x8c000508, 0x04000015, 0x580a5808, 0x592c0204,
5430 0x497a5800, 0x497a5801, 0x82000500, 0x000000ff,
5431 0x82000c80, 0x0000004b, 0x0402100b, 0x0c01f80f,
5432 0x5c03e000, 0x83700580, 0x00000003, 0x040007e6,
5433 0x0200f800, 0x00020566, 0x0200b000, 0x00020551,
5434 0x1c01f000, 0x0401f850, 0x5c03e000, 0x0401f7f9,
5435 0x0401f8de, 0x0401f7fd, 0x00105491, 0x00105491,
5436 0x00105491, 0x00105491, 0x001054a1, 0x00105491,
5437 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5438 0x00105519, 0x00105491, 0x00105491, 0x001054a1,
5439 0x001054a1, 0x00105491, 0x00105491, 0x00105491,
5440 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5441 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5442 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5443 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5444 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5445 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5446 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5447 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5448 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5449 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5450 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5451 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5452 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5453 0x00105491, 0x00105491, 0x00105491, 0x00105491,
5454 0x00105491, 0x492fc857, 0x42000000, 0x0010b85e,
5455 0x0201f800, 0x0010aa47, 0x42000000, 0x00000400,
5456 0x0401f019, 0x492fc857, 0x42000000, 0x0010b85d,
5457 0x0201f800, 0x0010aa47, 0x42000000, 0x00001000,
5458 0x0401f011, 0x492fc857, 0x42000000, 0x0010b85c,
5459 0x0201f800, 0x0010aa47, 0x42000000, 0x00002000,
5460 0x0401f009, 0x492fc857, 0x42000000, 0x0010b85f,
5461 0x0201f800, 0x0010aa47, 0x42000000, 0x00000800,
5462 0x0401f001, 0x4803c857, 0x4202e000, 0x00000001,
5463 0x592c0c04, 0x82040d00, 0xffff80ff, 0x80040540,
5464 0x48025c04, 0x0201f000, 0x000202da, 0x592c0204,
5465 0x492fc857, 0x80000110, 0x040007db, 0x80000040,
5466 0x04000025, 0x48033002, 0x492f3003, 0x492f3004,
5467 0x4a033008, 0x001054e5, 0x4202e000, 0x00000003,
5468 0x1c01f000, 0x592c0204, 0x492fc857, 0x80000110,
5469 0x040007cd, 0x80000040, 0x04000033, 0x48033002,
5470 0x492f3003, 0x492f3004, 0x4a033008, 0x00105501,
5471 0x4202e000, 0x00000003, 0x1c01f000, 0x0201f800,
5472 0x0010ab33, 0x02020000, 0x000204d9, 0x42028000,
5473 0x00000028, 0x41780800, 0x417a6000, 0x0201f800,
5474 0x00104e70, 0x0201f800, 0x001091c6, 0x0201f000,
5475 0x000202da, 0x592c0a0a, 0x8c040d02, 0x04020016,
5476 0x59a80021, 0x492fc857, 0x80000540, 0x0402000f,
5477 0x592c0207, 0x80000540, 0x04000005, 0x0201f800,
5478 0x00104326, 0x04020004, 0x1c01f000, 0x42000000,
5479 0x00000000, 0x592c0a06, 0x48065c06, 0x48025a06,
5480 0x0201f000, 0x000202da, 0x42000000, 0x00000028,
5481 0x0401f7f9, 0x42000800, 0x00000009, 0x0201f000,
5482 0x0010665b, 0x592c0208, 0x492fc857, 0x82000c80,
5483 0x0000199a, 0x040217a4, 0x592c0408, 0x80000540,
5484 0x040207a1, 0x59a80821, 0x800409c0, 0x04020009,
5485 0x592c0207, 0x80000540, 0x0400079b, 0x497a5a06,
5486 0x0201f800, 0x00104385, 0x04020004, 0x1c01f000,
5487 0x42000000, 0x00000028, 0x48025a06, 0x0201f000,
5488 0x000202da, 0x59980804, 0x59980002, 0x48065800,
5489 0x492c0801, 0x492f3004, 0x80000040, 0x48033002,
5490 0x04000002, 0x1c01f000, 0x599a5803, 0x59980008,
5491 0x4202e000, 0x00000001, 0x0801f000, 0x592e8a06,
5492 0x592c0406, 0x4803c856, 0x82000500, 0x000000ff,
5493 0x4200b800, 0x00000001, 0x82000d80, 0x00000001,
5494 0x04000015, 0x417a8800, 0x4200b800, 0x000007f0,
5495 0x82000d80, 0x00000002, 0x0400000f, 0x80000540,
5496 0x02020000, 0x000202da, 0x592e8a06, 0x0201f800,
5497 0x00020245, 0x02020000, 0x000202da, 0x592e9008,
5498 0x592e9809, 0x0201f800, 0x00104713, 0x0201f000,
5499 0x000202da, 0x59a80805, 0x84040d00, 0x48075005,
5500 0x0201f800, 0x00020245, 0x02000800, 0x0010482c,
5501 0x81468800, 0x805cb840, 0x040207fa, 0x0201f000,
5502 0x000202da, 0x592c0a08, 0x4807c857, 0x82040580,
5503 0x0000000e, 0x04000045, 0x82040580, 0x00000046,
5504 0x04000046, 0x82040580, 0x00000045, 0x04000020,
5505 0x82040580, 0x00000029, 0x04000010, 0x82040580,
5506 0x0000002a, 0x04000009, 0x82040580, 0x0000000f,
5507 0x040001fc, 0x82040580, 0x0000002e, 0x040001f9,
5508 0x4807c856, 0x0401f1f2, 0x59a80805, 0x84040d04,
5509 0x48075005, 0x0401f1f3, 0x592e8a06, 0x0201f800,
5510 0x00020245, 0x040201ef, 0x59340200, 0x84000518,
5511 0x48026a00, 0x592e6009, 0x4933c857, 0x83300580,
5512 0xffffffff, 0x0402002a, 0x0401f1e6, 0x592c1407,
5513 0x480bc857, 0x0201f800, 0x00109410, 0x411e6000,
5514 0x04020003, 0x4803c856, 0x0401f1d9, 0x592e3809,
5515 0x591c1414, 0x84081516, 0x84081554, 0x480a3c14,
5516 0x4a026403, 0x0000003a, 0x592c040b, 0x80000540,
5517 0x04000007, 0x4a026403, 0x0000003b, 0x592c020c,
5518 0x4802641a, 0x592c040c, 0x4802621a, 0x4a026203,
5519 0x00000001, 0x42000800, 0x80000040, 0x0201f800,
5520 0x00020721, 0x0401f1c7, 0x59a80068, 0x84000510,
5521 0x48035068, 0x0401f1c3, 0x592c1207, 0x8c081500,
5522 0x040201c0, 0x592e8a06, 0x592e6009, 0x0201f800,
5523 0x0010941a, 0x04020003, 0x4803c856, 0x0401f1b4,
5524 0x59300c06, 0x82040580, 0x00000004, 0x04000003,
5525 0x4803c856, 0x0401f1ae, 0x59300a03, 0x82040580,
5526 0x00000007, 0x04000003, 0x4803c856, 0x0401f1a8,
5527 0x59300c03, 0x82040580, 0x00000001, 0x04000021,
5528 0x82040580, 0x00000003, 0x04000016, 0x82040580,
5529 0x00000006, 0x04000020, 0x82040580, 0x00000008,
5530 0x04000015, 0x82040580, 0x0000000a, 0x0400000a,
5531 0x82040580, 0x0000000c, 0x04000004, 0x82040580,
5532 0x0000002e, 0x04020018, 0x42000800, 0x00000009,
5533 0x0401f013, 0x42000800, 0x00000005, 0x0401f010,
5534 0x417a7800, 0x0201f800, 0x0010203c, 0x4a026406,
5535 0x00000001, 0x42000800, 0x00000003, 0x0401f008,
5536 0x417a7800, 0x0201f800, 0x0010203c, 0x4a026406,
5537 0x00000001, 0x42000800, 0x0000000b, 0x0201f800,
5538 0x00104571, 0x4a026203, 0x00000001, 0x0201f800,
5539 0x0010672b, 0x0401f17b, 0x40000800, 0x58040000,
5540 0x80000540, 0x040207fd, 0x492c0800, 0x1c01f000,
5541 0x492fc857, 0x59300c06, 0x82040580, 0x00000006,
5542 0x04020094, 0x0201f800, 0x001049e7, 0x04020005,
5543 0x59340200, 0x8c00051a, 0x02000000, 0x00020533,
5544 0x59340200, 0x8c00050e, 0x0400008a, 0x59300203,
5545 0x42027800, 0x00000001, 0x82000580, 0x00000007,
5546 0x02020000, 0x00020533, 0x4a026203, 0x00000002,
5547 0x0201f000, 0x00020533, 0x42028000, 0x00000002,
5548 0x4a026206, 0x00000014, 0x4d2c0000, 0x0201f800,
5549 0x0010a1d1, 0x5c025800, 0x59300c06, 0x4807c857,
5550 0x82040580, 0x00000007, 0x04020063, 0x492fc857,
5551 0x4a025a06, 0x00000001, 0x0201f000, 0x000202da,
5552 0x592c240a, 0x492fc857, 0x4813c857, 0x8c10251c,
5553 0x04020016, 0x8c10251a, 0x04000003, 0x8c10250a,
5554 0x04000069, 0x59340a00, 0x8c040d0e, 0x04000003,
5555 0x8c10251e, 0x04000064, 0x0201f800, 0x0002075a,
5556 0x0400006b, 0x592c240a, 0x49366009, 0x49325809,
5557 0x4a026406, 0x00000006, 0x4a026203, 0x00000007,
5558 0x0201f000, 0x0002052f, 0x592c0a0c, 0x5934000f,
5559 0x41784000, 0x80001540, 0x0400006d, 0x58080204,
5560 0x82000500, 0x000000ff, 0x82000580, 0x00000012,
5561 0x04020004, 0x5808020c, 0x80040580, 0x04000004,
5562 0x58080000, 0x40084000, 0x0401f7f3, 0x58080000,
5563 0x49781000, 0x802041c0, 0x04000006, 0x48004000,
5564 0x80000540, 0x04020007, 0x48226810, 0x0401f005,
5565 0x4802680f, 0x80000540, 0x04020002, 0x497a6810,
5566 0x4d2c0000, 0x400a5800, 0x4a025a06, 0x00000002,
5567 0x0201f800, 0x000202da, 0x5c025800, 0x0401f7bc,
5568 0x592c040a, 0x8c00051c, 0x04000016, 0x592c0206,
5569 0x82000580, 0x0000ffff, 0x04020012, 0x592e6009,
5570 0x83300580, 0xffffffff, 0x040007b1, 0x83300480,
5571 0x0010d1c0, 0x04001010, 0x59a8000b, 0x81300480,
5572 0x0402100d, 0x59300008, 0x800001c0, 0x04020005,
5573 0x59300203, 0x82000580, 0x00000007, 0x04000797,
5574 0x492fc857, 0x4a025a06, 0x00000029, 0x0201f000,
5575 0x000202da, 0x492fc857, 0x4a025a06, 0x00000008,
5576 0x0201f000, 0x000202da, 0x492fc857, 0x4a025a06,
5577 0x00000045, 0x0201f000, 0x000202da, 0x492fc857,
5578 0x4a025a06, 0x0000002a, 0x0201f000, 0x000202da,
5579 0x492fc857, 0x4a025a06, 0x00000028, 0x0201f000,
5580 0x000202da, 0x492fc857, 0x4a025a06, 0x00000006,
5581 0x0201f000, 0x000202da, 0x492fc857, 0x4a025a06,
5582 0x0000000e, 0x0201f000, 0x000202da, 0x59340010,
5583 0x492e6810, 0x492fc857, 0x80000d40, 0x04000003,
5584 0x492c0800, 0x1c01f000, 0x5934040b, 0x492e680f,
5585 0x492fc857, 0x4803c857, 0x80000540, 0x04020003,
5586 0x4a026a03, 0x00000001, 0x1c01f000, 0x59a8000e,
5587 0x81640480, 0x0402176e, 0x42026000, 0x0010d1c0,
5588 0x59300009, 0x81340580, 0x04020004, 0x59300202,
5589 0x80040580, 0x04000759, 0x83326400, 0x00000024,
5590 0x41580000, 0x81300480, 0x040017f6, 0x0401f760,
5591 0x492fc857, 0x592c0407, 0x82000c80, 0x0000199a,
5592 0x040215f1, 0x592c0204, 0x80000112, 0x040205de,
5593 0x592e8a06, 0x0201f800, 0x00020245, 0x04020059,
5594 0x0201f800, 0x001049e7, 0x04020059, 0x592e780a,
5595 0x493fc857, 0x8d3e7d3e, 0x04020007, 0x59a80021,
5596 0x80000540, 0x0402004f, 0x0201f800, 0x00104838,
5597 0x040005dd, 0x833c1d00, 0x0000001f, 0x040005da,
5598 0x592c0207, 0x82000c80, 0x00001000, 0x040215d6,
5599 0x800000c2, 0x800008c4, 0x8005d400, 0x592e9008,
5600 0x592e9809, 0x5934080d, 0x800409c0, 0x0402002e,
5601 0x833c1d00, 0x0000001f, 0x81780040, 0x80000000,
5602 0x800c1902, 0x040217fe, 0x040205c7, 0x0c01f001,
5603 0x001056e9, 0x001056ec, 0x001056f9, 0x001056fc,
5604 0x001056ff, 0x0201f800, 0x0010903e, 0x0401f01a,
5605 0x0201f800, 0x0010480b, 0x04000027, 0x80e9d1c0,
5606 0x02020800, 0x00105fae, 0x42028000, 0x00000005,
5607 0x417a9000, 0x417a9800, 0x0201f800, 0x0010904e,
5608 0x0401f00d, 0x42027000, 0x0000004d, 0x0401f006,
5609 0x42027000, 0x0000004e, 0x0401f003, 0x42027000,
5610 0x00000052, 0x0201f800, 0x001046c9, 0x02020800,
5611 0x0010907e, 0x04000010, 0x8d3e7d3e, 0x04020017,
5612 0x1c01f000, 0x58040002, 0x80000540, 0x04020007,
5613 0x4d3c0000, 0x40067800, 0x0201f800, 0x001047eb,
5614 0x5c027800, 0x040207cb, 0x4a025a06, 0x00000030,
5615 0x0401f00d, 0x4a025a06, 0x0000002c, 0x0401f00a,
5616 0x4a025a06, 0x00000028, 0x0401f007, 0x4a025a06,
5617 0x00000029, 0x0401f004, 0x497a5c09, 0x4a025a06,
5618 0x00000000, 0x4a025a04, 0x00000103, 0x0201f000,
5619 0x000202da, 0x492fc857, 0x592c0204, 0x80000110,
5620 0x80000040, 0x04000002, 0x0401f56f, 0x592c0207,
5621 0x82000500, 0x000003ff, 0x48025a07, 0x8c000506,
5622 0x04000004, 0x82000500, 0x00000070, 0x04020004,
5623 0x59a80821, 0x800409c0, 0x04020018, 0x4a025a06,
5624 0x0000dead, 0x592c0408, 0x82000500, 0x0000f0ff,
5625 0x48025c08, 0x0201f800, 0x001043b4, 0x04020002,
5626 0x1c01f000, 0x49425a06, 0x8058b1c0, 0x04000009,
5627 0x0201f800, 0x0010955f, 0x0401f80f, 0x44042800,
5628 0x82580580, 0x00000002, 0x04020002, 0x48082801,
5629 0x0201f000, 0x000202da, 0x42028000, 0x00000031,
5630 0x42000800, 0x00000001, 0x4200b000, 0x00000001,
5631 0x0401f7ed, 0x592c0408, 0x80000118, 0x832c2c00,
5632 0x00000009, 0x80142c00, 0x1c01f000, 0x492fc857,
5633 0x4a025a08, 0x00000006, 0x0201f000, 0x000202da,
5634 0x492fc857, 0x4a025a08, 0x00000001, 0x0201f000,
5635 0x000202da, 0x492fc857, 0x592c040a, 0x82000500,
5636 0x00000003, 0x04000020, 0x0201f800, 0x0002075a,
5637 0x04000021, 0x592c0204, 0x492e6008, 0x82000500,
5638 0x000000ff, 0x82000580, 0x00000045, 0x0400000e,
5639 0x592c000b, 0x0201f800, 0x00105c9a, 0x02000800,
5640 0x00020245, 0x04020018, 0x42027000, 0x00000041,
5641 0x49366009, 0x4a026406, 0x00000001, 0x0201f000,
5642 0x000207a1, 0x59300015, 0x8400055e, 0x48026015,
5643 0x42026800, 0x0010b524, 0x42027000, 0x00000040,
5644 0x0401f7f4, 0x4a025a06, 0x00000101, 0x0201f000,
5645 0x000202da, 0x4a025a06, 0x0000002c, 0x0201f000,
5646 0x000202da, 0x4a025a06, 0x00000028, 0x0201f800,
5647 0x000202da, 0x0201f000, 0x0002077d, 0x492fc857,
5648 0x0201f800, 0x001062e1, 0x0400000b, 0x592c0204,
5649 0x80000110, 0x80000040, 0x040204fb, 0x592c0c06,
5650 0x800409c0, 0x04000009, 0x42000000, 0x00000102,
5651 0x0401f003, 0x42000000, 0x00000104, 0x48025a06,
5652 0x0201f000, 0x000202da, 0x592c0c07, 0x800409c0,
5653 0x04000024, 0x82040480, 0x00000005, 0x04021021,
5654 0x4c040000, 0x80040800, 0x0201f800, 0x00106306,
5655 0x5c001000, 0x04020018, 0x832c0400, 0x00000008,
5656 0x4000a000, 0x0201f800, 0x0010632f, 0x04020012,
5657 0x592c1207, 0x82cc0580, 0x0010b50e, 0x04020009,
5658 0x58c80c0b, 0x84040d00, 0x84040d02, 0x8c081500,
5659 0x04000002, 0x84040d5e, 0x4805940b, 0x0401f001,
5660 0x42000000, 0x00000000, 0x48025a06, 0x0201f000,
5661 0x000202da, 0x42000000, 0x00000103, 0x0401f7fb,
5662 0x42000000, 0x00000102, 0x0401f7f8, 0x492fc857,
5663 0x592e7c06, 0x833c0500, 0xfffffffe, 0x04020043,
5664 0x592c4007, 0x42026000, 0x0010d1c0, 0x41581800,
5665 0x400c0000, 0x81300480, 0x04021023, 0x59300203,
5666 0x82000580, 0x00000000, 0x04000007, 0x59300008,
5667 0x80000d40, 0x04000004, 0x58040005, 0x80200580,
5668 0x04000004, 0x83326400, 0x00000024, 0x0401f7f1,
5669 0x58040204, 0x82000500, 0x000000ff, 0x82000d80,
5670 0x00000053, 0x04000007, 0x82000d80, 0x00000048,
5671 0x04000004, 0x82000580, 0x00000018, 0x04020023,
5672 0x4d2c0000, 0x0201f800, 0x00108be3, 0x5c025800,
5673 0x0400001e, 0x4a025a06, 0x00000000, 0x0201f000,
5674 0x000202da, 0x592e8a06, 0x83440480, 0x000007f0,
5675 0x04021016, 0x83440400, 0x0010ac00, 0x50000000,
5676 0x80026d40, 0x04000011, 0x4d2c0000, 0x0201f800,
5677 0x001047cb, 0x0400000c, 0x42028000, 0x00000005,
5678 0x592c0a08, 0x0201f800, 0x00104e70, 0x0201f800,
5679 0x001091cc, 0x0201f800, 0x000202da, 0x5c025800,
5680 0x0401f7e5, 0x5c025800, 0x4a025a06, 0x00000031,
5681 0x0201f000, 0x000202da, 0x492fc857, 0x4d2c0000,
5682 0x0201f800, 0x001007e4, 0x04000016, 0x492fc857,
5683 0x412f4000, 0x0201f800, 0x001007e4, 0x0400000e,
5684 0x492fc857, 0x412dd800, 0x0201f800, 0x00103b28,
5685 0x0201f800, 0x00103b32, 0x49a1d80b, 0x5c025800,
5686 0x492dd80a, 0x0201f800, 0x00102214, 0x0201f000,
5687 0x00102233, 0x41a25800, 0x0201f800, 0x001007f4,
5688 0x5c025800, 0x4a025a06, 0x00004005, 0x4a025c06,
5689 0x00000002, 0x0201f000, 0x000202da, 0x4807c857,
5690 0x485fc857, 0x4200b800, 0x00000001, 0x5c000800,
5691 0x4c5c0000, 0x0401f005, 0x4807c857, 0x485fc857,
5692 0x5c000800, 0x4d780000, 0x4803c857, 0x492fc857,
5693 0x8c00050e, 0x02020800, 0x001005d0, 0x4203e000,
5694 0x50000000, 0x4200b800, 0x00008003, 0x0201f000,
5695 0x001005dd, 0x592c0204, 0x80000110, 0x80000040,
5696 0x04020441, 0x0201f800, 0x00104a34, 0x04020002,
5697 0x1c01f000, 0x49425a06, 0x4806580d, 0x480a580e,
5698 0x4943c857, 0x4807c857, 0x480bc857, 0x0201f000,
5699 0x000202da, 0x592c0204, 0x80000110, 0x80000040,
5700 0x04020431, 0x0201f800, 0x00104b8b, 0x04020002,
5701 0x1c01f000, 0x49425a06, 0x48065811, 0x480a5812,
5702 0x0201f000, 0x000202da, 0x592c0204, 0x80000110,
5703 0x04000425, 0x80000040, 0x0402000c, 0x4202e000,
5704 0x00000001, 0x592c020a, 0x8c000504, 0x02000000,
5705 0x000204d0, 0x592c0207, 0x82000c80, 0x00001001,
5706 0x04021429, 0x0401f009, 0x4202e000, 0x00000003,
5707 0x48033002, 0x492f3003, 0x492f3004, 0x4a033008,
5708 0x000204d0, 0x1c01f000, 0x4202e000, 0x00000002,
5709 0x42000000, 0x0010beda, 0x50007000, 0x492c700b,
5710 0x4978700e, 0x4978700c, 0x592c0011, 0x592c0812,
5711 0x48007007, 0x48047008, 0x592c1013, 0x82080500,
5712 0xffff0000, 0x04000003, 0x0201f800, 0x001005d8,
5713 0x4978700d, 0x82080480, 0x00000180, 0x4803c857,
5714 0x04001007, 0x4800700f, 0x4a007005, 0x00000180,
5715 0x4a007004, 0x00000060, 0x0401f005, 0x4978700f,
5716 0x48087005, 0x80081104, 0x48087004, 0x5838000a,
5717 0x48007003, 0x40381000, 0x0201f000, 0x00100858,
5718 0x0201f800, 0x001007d3, 0x04000003, 0x59980007,
5719 0x0801f000, 0x1c01f000, 0x40307000, 0x5838000b,
5720 0x80025d40, 0x0400001b, 0x58380002, 0x82000580,
5721 0x00000100, 0x0400001d, 0x4c380000, 0x592c0204,
5722 0x82000500, 0x000000ff, 0x82000580, 0x00000012,
5723 0x0400000b, 0x592c0208, 0x8400054e, 0x48025a08,
5724 0x4a025a06, 0x00000002, 0x4a025a04, 0x00000103,
5725 0x0201f800, 0x000202c1, 0x0401f005, 0x4a025a06,
5726 0x00000010, 0x0201f800, 0x000202da, 0x5c007000,
5727 0x4202e000, 0x00000001, 0x4a007002, 0x00000100,
5728 0x49787010, 0x1c01f000, 0x58380004, 0x82000480,
5729 0x00000003, 0x04000087, 0x58380010, 0x8c000500,
5730 0x04020019, 0x4200b000, 0x00000003, 0x832cac00,
5731 0x00000011, 0x5838000a, 0x5838100d, 0x8008a400,
5732 0x4c380000, 0x0201f800, 0x0010ab17, 0x5c007000,
5733 0x5838000d, 0x82000400, 0x00000003, 0x4800700d,
5734 0x4a007010, 0x00000001, 0x58380004, 0x82000480,
5735 0x00000003, 0x48007004, 0x82000580, 0x00000003,
5736 0x0400006c, 0x5838000e, 0x80001d40, 0x04020020,
5737 0x4c380000, 0x0201f800, 0x001007d3, 0x5c007000,
5738 0x04000010, 0x4a025a04, 0x0000010a, 0x42001800,
5739 0x00000005, 0x480c700e, 0x5838000c, 0x80000540,
5740 0x04020002, 0x5838000b, 0x40000800, 0x492c0801,
5741 0x492c700c, 0x42000800, 0x0000000f, 0x0401f011,
5742 0x4202e000, 0x00000008, 0x4a033007, 0x00105915,
5743 0x1c01f000, 0x4202e000, 0x00000002, 0x42000000,
5744 0x0010beda, 0x50007000, 0x0401f7e7, 0x583a580c,
5745 0x400c0000, 0x42000800, 0x00000014, 0x80040c80,
5746 0x58381004, 0x5838000f, 0x41783000, 0x80000540,
5747 0x04020005, 0x84183540, 0x82081480, 0x00000003,
5748 0x0400003c, 0x40080000, 0x80040480, 0x04001002,
5749 0x40080800, 0x4004b000, 0x412c0000, 0x800c0400,
5750 0x4000a800, 0x5838000a, 0x5838100d, 0x8008a400,
5751 0x4c080000, 0x4c040000, 0x4c0c0000, 0x4c380000,
5752 0x0201f800, 0x0010ab17, 0x5c007000, 0x5c001800,
5753 0x5c000800, 0x40040000, 0x58381004, 0x80080480,
5754 0x48007004, 0x82000580, 0x00000003, 0x04000002,
5755 0x84183500, 0x5c000000, 0x80041400, 0x82080480,
5756 0x00000060, 0x04020003, 0x84183542, 0x41781000,
5757 0x400c0000, 0x80041c00, 0x820c0480, 0x00000014,
5758 0x04020003, 0x84183544, 0x40001800, 0x40080800,
5759 0x4804700d, 0x480c700e, 0x40180000, 0x0c01f001,
5760 0x00105960, 0x00105964, 0x00105962, 0x00105960,
5761 0x001058fc, 0x00105964, 0x00105962, 0x00105960,
5762 0x0201f800, 0x001005d8, 0x5838100f, 0x0401f739,
5763 0x5838080d, 0x82040400, 0x00000002, 0x5838100a,
5764 0x80080400, 0x50001000, 0x800811c0, 0x0402000f,
5765 0x4202e000, 0x00000001, 0x583a580b, 0x4978700b,
5766 0x49787010, 0x592c0204, 0x82000500, 0x000000ff,
5767 0x82000580, 0x00000012, 0x02000000, 0x00020507,
5768 0x0201f000, 0x000204d0, 0x5838000a, 0x80040c00,
5769 0x82381c00, 0x00000007, 0x54041800, 0x80040800,
5770 0x800c1800, 0x54041800, 0x0401f71a, 0x0201f800,
5771 0x001007d3, 0x02000800, 0x001005d8, 0x4a02580a,
5772 0x0010be79, 0x42000800, 0x0010beda, 0x452c0800,
5773 0x497a580b, 0x497a580c, 0x497a580d, 0x497a580e,
5774 0x497a580f, 0x4a025809, 0x001058b6, 0x497a5810,
5775 0x4a025802, 0x00000100, 0x4a025801, 0x00000001,
5776 0x1c01f000, 0x59c80007, 0x8c000502, 0x04000070,
5777 0x835c2c80, 0x00000005, 0x02001000, 0x00105f23,
5778 0x59c82817, 0x497b9005, 0x82140500, 0x00e00000,
5779 0x0402004f, 0x82140500, 0x000003ff, 0x82001c00,
5780 0x00000006, 0x41cc2000, 0x42003000, 0x00006080,
5781 0x820c0480, 0x00000040, 0x04001006, 0x42001000,
5782 0x00000040, 0x820c1c80, 0x00000040, 0x0401f003,
5783 0x400c1000, 0x41781800, 0x54182000, 0x80102000,
5784 0x80183000, 0x80081040, 0x040207fc, 0x800c19c0,
5785 0x04000005, 0x59c80005, 0x80000000, 0x48039005,
5786 0x0401f7ea, 0x82140500, 0x01f60000, 0x04020029,
5787 0x82140500, 0x0000f000, 0x0400000b, 0x82000c80,
5788 0x00002000, 0x0402100f, 0x82140500, 0x0e000000,
5789 0x80000132, 0x0c01f840, 0x4a039005, 0x00000140,
5790 0x1c01f000, 0x59cc0400, 0x82000500, 0x0000ff00,
5791 0x82000580, 0x00008100, 0x040007f4, 0x0401f01c,
5792 0x4817c857, 0x82140500, 0x000003ff, 0x04020007,
5793 0x59cc0400, 0x82000500, 0x0000ff00, 0x82000580,
5794 0x00008100, 0x04020012, 0x42000000, 0x0010b8bd,
5795 0x0201f800, 0x0010aa47, 0x0201f800, 0x00105dfa,
5796 0x4803c856, 0x4a039005, 0x00000140, 0x0401f020,
5797 0x4817c857, 0x82140500, 0x00f60000, 0x04020004,
5798 0x0201f800, 0x00105e35, 0x040207d2, 0x0201f800,
5799 0x0010513b, 0x04000010, 0x59c400a4, 0x4803c857,
5800 0x82000500, 0x0000000f, 0x82000580, 0x0000000a,
5801 0x04020009, 0x497b5016, 0x59c400a3, 0x82000540,
5802 0x00080000, 0x480388a3, 0x82000500, 0xfff7ffff,
5803 0x480388a3, 0x4817c856, 0x0201f800, 0x0010a978,
5804 0x4a039005, 0x00000140, 0x0401f842, 0x4803c856,
5805 0x1c01f000, 0x00105a1d, 0x00105cf4, 0x00105a15,
5806 0x00105a15, 0x00105a15, 0x00105a15, 0x00105a15,
5807 0x00105a15, 0x4803c857, 0x42000000, 0x0010b85a,
5808 0x0201f800, 0x0010aa47, 0x4a039005, 0x00000140,
5809 0x1c01f000, 0x4817c857, 0x59cc0400, 0x4803c857,
5810 0x82000d00, 0x0000ff00, 0x82041500, 0x0000f000,
5811 0x840409c0, 0x82140500, 0x000003ff, 0x800018c4,
5812 0x8c142d14, 0x04000005, 0x59cc0002, 0x82000500,
5813 0x00000003, 0x800c1c80, 0x480f5016, 0x82080580,
5814 0x00002000, 0x04020011, 0x836c0580, 0x00000001,
5815 0x0402000c, 0x59cc0006, 0x82000500, 0xff000000,
5816 0x82000580, 0x11000000, 0x04020011, 0x0201f800,
5817 0x00103b38, 0x0201f800, 0x00105f48, 0x0401f00c,
5818 0x0401f81f, 0x0401f00a, 0x82080580, 0x00003000,
5819 0x04020003, 0x0401fa06, 0x0401f005, 0x82080580,
5820 0x00008000, 0x04020002, 0x0401fafc, 0x1c01f000,
5821 0x4817c857, 0x42000000, 0x0010b859, 0x0201f800,
5822 0x0010aa47, 0x836c0580, 0x00000003, 0x0402000b,
5823 0x4c080000, 0x4c0c0000, 0x42001000, 0x00008048,
5824 0x40141800, 0x80142120, 0x0201f800, 0x00103a3e,
5825 0x5c001800, 0x5c001000, 0x1c01f000, 0x4807c857,
5826 0x59cc0002, 0x82000500, 0xff000000, 0x82001580,
5827 0x01000000, 0x04000004, 0x82001580, 0x23000000,
5828 0x04020192, 0x82040580, 0x00000023, 0x0402003f,
5829 0x0401fb6a, 0x0400018d, 0x59300c06, 0x82040580,
5830 0x00000010, 0x04000013, 0x82040580, 0x00000011,
5831 0x04000010, 0x82040580, 0x00000001, 0x0400000d,
5832 0x82040580, 0x00000004, 0x0400000a, 0x82040580,
5833 0x00000008, 0x04000007, 0x82040580, 0x0000000a,
5834 0x04000004, 0x4933c857, 0x4807c857, 0x0401f177,
5835 0x59300004, 0x82000500, 0x80010000, 0x04000004,
5836 0x0201f800, 0x00106f60, 0x04020170, 0x59cc0a04,
5837 0x48066202, 0x59cc0006, 0x82000500, 0xffff0000,
5838 0x82000d80, 0x02000000, 0x04020005, 0x42027000,
5839 0x00000015, 0x0201f000, 0x000207a1, 0x82000d80,
5840 0x02140000, 0x040007fa, 0x82000d80, 0x02100000,
5841 0x040007f7, 0x82000d80, 0x02100000, 0x040007f4,
5842 0x82000d80, 0x01000000, 0x04020158, 0x59cc0006,
5843 0x82000500, 0x0000ffff, 0x04020154, 0x42027000,
5844 0x00000016, 0x0401f7ec, 0x82040580, 0x00000022,
5845 0x0402014e, 0x59a80806, 0x8c040d14, 0x04000011,
5846 0x0401f967, 0x0402000f, 0x0401f97d, 0x0400000d,
5847 0x42027000, 0x0000004c, 0x59cc0001, 0x82000500,
5848 0x00ffffff, 0x0201f800, 0x00105eec, 0x0400012a,
5849 0x42028800, 0x0000ffff, 0x417a6800, 0x0401f126,
5850 0x59cc0006, 0x82000500, 0xffff0000, 0x82000d80,
5851 0x03000000, 0x04020021, 0x59a80026, 0x8c000508,
5852 0x04000017, 0x8400054c, 0x48035026, 0x59cc0800,
5853 0x82040d00, 0x00ffffff, 0x48075010, 0x497b8830,
5854 0x84040d70, 0x48078832, 0x59c40802, 0x84040d4c,
5855 0x48078802, 0x59cc0007, 0x82000500, 0x0000ffff,
5856 0x48038893, 0x4803501e, 0x42000800, 0x00000003,
5857 0x59a81010, 0x0201f800, 0x00106c78, 0x59cc0006,
5858 0x82000500, 0x0000ffff, 0x04020118, 0x42027000,
5859 0x00000017, 0x0401f0d9, 0x82000d80, 0x04000000,
5860 0x04020011, 0x59cc0006, 0x82000500, 0x0000ffff,
5861 0x0402010e, 0x0201f800, 0x0010513b, 0x04000004,
5862 0x42027000, 0x0000001d, 0x0401f0cc, 0x59a80026,
5863 0x84000548, 0x48035026, 0x42027000, 0x00000030,
5864 0x0401f0c6, 0x82000d80, 0x05000000, 0x04020008,
5865 0x59cc0006, 0x82000500, 0x0000ffff, 0x040200fb,
5866 0x42027000, 0x00000018, 0x0401f0bc, 0x82000d80,
5867 0x20100000, 0x04020004, 0x42027000, 0x00000019,
5868 0x0401f0b6, 0x82000d80, 0x21100000, 0x04020004,
5869 0x42027000, 0x0000001a, 0x0401f0b0, 0x82000d80,
5870 0x52000000, 0x04020008, 0x59cc0006, 0x82000500,
5871 0x0000ffff, 0x040200e5, 0x42027000, 0x0000001b,
5872 0x0401f0a6, 0x82000d80, 0x50000000, 0x04020008,
5873 0x59cc0006, 0x82000500, 0x0000ffff, 0x040200db,
5874 0x42027000, 0x0000001c, 0x0401f09c, 0x82000d80,
5875 0x13000000, 0x04020004, 0x42027000, 0x00000034,
5876 0x0401f096, 0x82000d80, 0x12000000, 0x04020008,
5877 0x59cc0006, 0x82000500, 0x0000ffff, 0x040200cb,
5878 0x42027000, 0x00000024, 0x0401f08c, 0x82000d00,
5879 0xff000000, 0x82040d80, 0x24000000, 0x04020004,
5880 0x42027000, 0x0000002d, 0x0401f084, 0x82000d00,
5881 0xff000000, 0x82040d80, 0x53000000, 0x04020004,
5882 0x42027000, 0x0000002a, 0x0401f07c, 0x82000d80,
5883 0x0f000000, 0x04020004, 0x42027000, 0x00000020,
5884 0x0401f076, 0x82000d80, 0x61040000, 0x04020036,
5885 0x83cc1400, 0x00000006, 0x80080800, 0x50080000,
5886 0x82000500, 0x0000ffff, 0x82000480, 0x00000004,
5887 0x4c580000, 0x8000b104, 0x8058b1c0, 0x04000026,
5888 0x4c100000, 0x50041800, 0x820c1500, 0x03000000,
5889 0x80081130, 0x42000000, 0x0010b817, 0x82082580,
5890 0x00000000, 0x04020004, 0x42000000, 0x0010b814,
5891 0x0401f00c, 0x82082580, 0x00000001, 0x04020004,
5892 0x42000000, 0x0010b815, 0x0401f006, 0x82082580,
5893 0x00000002, 0x04020003, 0x42000000, 0x0010b816,
5894 0x0201f800, 0x0010aa47, 0x42001000, 0x00008015,
5895 0x820c2500, 0x0000ffff, 0x800c1920, 0x0201f800,
5896 0x00103a3e, 0x5c002000, 0x80040800, 0x8058b040,
5897 0x040207da, 0x5c00b000, 0x42027000, 0x00000023,
5898 0x0401f03e, 0x82000d80, 0x60000000, 0x04020004,
5899 0x42027000, 0x0000003f, 0x0401f038, 0x82000d80,
5900 0x54000000, 0x04020006, 0x0401fb12, 0x0402006f,
5901 0x42027000, 0x00000046, 0x0401f030, 0x82000d80,
5902 0x55000000, 0x04020009, 0x0401fb32, 0x04020004,
5903 0x42027000, 0x00000041, 0x0401f028, 0x42027000,
5904 0x00000042, 0x0401f025, 0x82000d80, 0x78000000,
5905 0x04020004, 0x42027000, 0x00000045, 0x0401f01f,
5906 0x82000d80, 0x10000000, 0x04020004, 0x42027000,
5907 0x0000004e, 0x0401f019, 0x82000d80, 0x63000000,
5908 0x04020004, 0x42027000, 0x0000004a, 0x0401f013,
5909 0x82000d00, 0xff000000, 0x82040d80, 0x56000000,
5910 0x04020004, 0x42027000, 0x0000004f, 0x0401f00b,
5911 0x82000d00, 0xff000000, 0x82040d80, 0x57000000,
5912 0x04020004, 0x42027000, 0x00000050, 0x0401f003,
5913 0x42027000, 0x0000001d, 0x59cc3800, 0x821c3d00,
5914 0x00ffffff, 0x821c0580, 0x00fffffe, 0x59cc0001,
5915 0x04020005, 0x40003000, 0x42028800, 0x000007fe,
5916 0x0401f003, 0x0401f8d1, 0x04020030, 0x0201f800,
5917 0x001045a6, 0x0402002d, 0x83380580, 0x00000046,
5918 0x04020004, 0x59a80010, 0x80180580, 0x04000027,
5919 0x59340200, 0x8c000514, 0x0400000f, 0x83380580,
5920 0x00000030, 0x0400000c, 0x83380580, 0x0000003f,
5921 0x04000009, 0x83380580, 0x00000034, 0x04000006,
5922 0x83380580, 0x00000024, 0x04000003, 0x42027000,
5923 0x0000004c, 0x0201f800, 0x0002075a, 0x04000018,
5924 0x49366009, 0x4a026406, 0x00000004, 0x59cc0c04,
5925 0x48066202, 0x83380580, 0x0000004c, 0x04020009,
5926 0x4a026406, 0x00000011, 0x813669c0, 0x04020005,
5927 0x59cc0001, 0x82000500, 0x00ffffff, 0x4802601e,
5928 0x0201f000, 0x000207a1, 0x59880052, 0x4803c857,
5929 0x80000000, 0x48031052, 0x1c01f000, 0x42001000,
5930 0x00008049, 0x59cc1806, 0x800c1930, 0x0201f800,
5931 0x00103a3e, 0x0201f800, 0x00107942, 0x040007f3,
5932 0x49366009, 0x4a026406, 0x00000004, 0x59cc0c04,
5933 0x48066202, 0x4a026403, 0x00000009, 0x4a02641a,
5934 0x00000009, 0x4a02621a, 0x00002900, 0x4a026203,
5935 0x00000001, 0x0201f000, 0x0010672b, 0x59a80026,
5936 0x4803c857, 0x8c000508, 0x04000010, 0x59cc0006,
5937 0x82000500, 0xff000000, 0x82000d80, 0x03000000,
5938 0x0400000c, 0x82000d80, 0x20000000, 0x04000009,
5939 0x82000d80, 0x05000000, 0x04000006, 0x82000d80,
5940 0x21000000, 0x04000003, 0x80000580, 0x1c01f000,
5941 0x82000540, 0x00000001, 0x0401f7fd, 0x59cc2006,
5942 0x82102500, 0xff000000, 0x9c1021c0, 0x0401f807,
5943 0x820c1c00, 0x0010b4e3, 0x500c1800, 0x800c0500,
5944 0x4803c857, 0x1c01f000, 0x40100800, 0x41781800,
5945 0x82040480, 0x00000020, 0x04001004, 0x800c1800,
5946 0x40000800, 0x0401f7fb, 0x82040500, 0x0000000f,
5947 0x82000400, 0x0010ab38, 0x50000000, 0x8c040d08,
5948 0x04000002, 0x900001c0, 0x1c01f000, 0x4803c856,
5949 0x0401fac3, 0x0402000a, 0x0201f800, 0x0010210a,
5950 0x04020007, 0x59cc0002, 0x82000500, 0xff000000,
5951 0x82000d80, 0x08000000, 0x04000802, 0x1c01f000,
5952 0x4803c856, 0x59cc0400, 0x82000d00, 0x0000ff00,
5953 0x840409c0, 0x82040580, 0x00000033, 0x0402001f,
5954 0x0401f976, 0x04000038, 0x59cc0a04, 0x48066202,
5955 0x59cc0006, 0x4803c857, 0x82000500, 0xffff0000,
5956 0x82000d80, 0x02000000, 0x04020009, 0x59cc0006,
5957 0x82000500, 0x0000ffff, 0x0402002b, 0x42027000,
5958 0x00000015, 0x0201f000, 0x000207a1, 0x82000d80,
5959 0x01000000, 0x04020024, 0x59cc0006, 0x82000500,
5960 0x0000ffff, 0x04020020, 0x42027000, 0x00000016,
5961 0x0201f000, 0x000207a1, 0x82040580, 0x00000032,
5962 0x04020019, 0x59cc0006, 0x82000500, 0xffff0000,
5963 0x82000d80, 0x14000000, 0x04020013, 0x42027000,
5964 0x00000038, 0x59cc0001, 0x0401f810, 0x0402000e,
5965 0x0201f800, 0x001045a6, 0x0402000b, 0x0201f800,
5966 0x0002075a, 0x04000008, 0x49366009, 0x4a026406,
5967 0x00000004, 0x59cc0c04, 0x48066202, 0x0201f000,
5968 0x000207a1, 0x1c01f000, 0x4803c857, 0x4c580000,
5969 0x4c100000, 0x4c380000, 0x4c340000, 0x82003500,
5970 0x00ffffff, 0x82181500, 0x00ff0000, 0x82081580,
5971 0x00ff0000, 0x04020016, 0x82181480, 0x00fffffc,
5972 0x04001013, 0x82181580, 0x00fffffd, 0x04020004,
5973 0x42028800, 0x000007fd, 0x0401f040, 0x82181580,
5974 0x00fffffe, 0x04020004, 0x42028800, 0x000007fe,
5975 0x0401f03a, 0x82181580, 0x00fffffc, 0x04020004,
5976 0x42028800, 0x000007fc, 0x0401f034, 0x41781000,
5977 0x42002000, 0x00000000, 0x4200b000, 0x000007f0,
5978 0x41ac7000, 0x50380000, 0x80006d40, 0x04020005,
5979 0x800811c0, 0x0402001e, 0x8410155e, 0x0401f01c,
5980 0x58340212, 0x82000500, 0x0000ff00, 0x04000011,
5981 0x59a84010, 0x82204500, 0x00ffff00, 0x82180500,
5982 0x00ffff00, 0x04000002, 0x80200580, 0x58340002,
5983 0x0402000f, 0x82000500, 0x000000ff, 0x82184500,
5984 0x000000ff, 0x80204580, 0x04020009, 0x0401f006,
5985 0x58340002, 0x82000500, 0x00ffffff, 0x80184580,
5986 0x04020003, 0x40128800, 0x0401f00c, 0x80102000,
5987 0x80387000, 0x8058b040, 0x040207db, 0x800811c0,
5988 0x04020005, 0x481bc857, 0x82000540, 0x00000001,
5989 0x0401f003, 0x840a8d1e, 0x80000580, 0x5c006800,
5990 0x5c007000, 0x5c002000, 0x5c00b000, 0x1c01f000,
5991 0x59a80026, 0x8c00050e, 0x04000003, 0x8c000502,
5992 0x04000006, 0x59cc0c00, 0x80040910, 0x82040500,
5993 0x0000000f, 0x0c01f002, 0x1c01f000, 0x00105d0f,
5994 0x00105d0f, 0x00105d0f, 0x00105de5, 0x00105d0f,
5995 0x00105d11, 0x00105d29, 0x00105d2c, 0x00105d0f,
5996 0x00105d0f, 0x00105d0f, 0x00105d0f, 0x00105d0f,
5997 0x00105d0f, 0x00105d0f, 0x00105d0f, 0x4803c856,
5998 0x1c01f000, 0x0401f8c5, 0x04000014, 0x82140500,
5999 0x000003ff, 0x800000c4, 0x82000480, 0x00000008,
6000 0x0400100e, 0x59cc0001, 0x59326809, 0x59340802,
6001 0x80040580, 0x82000500, 0x00ffffff, 0x04020007,
6002 0x59cc0a04, 0x48066202, 0x42027000, 0x00000046,
6003 0x0201f000, 0x000207a1, 0x59cc0004, 0x4803c857,
6004 0x1c01f000, 0x59cc0004, 0x4803c857, 0x1c01f000,
6005 0x0401f8aa, 0x04000016, 0x82140500, 0x000003ff,
6006 0x800000c4, 0x82000480, 0x0000000c, 0x04001010,
6007 0x59cc0001, 0x82000500, 0x00ffffff, 0x59326809,
6008 0x59340802, 0x82040d00, 0x00ffffff, 0x80040580,
6009 0x04020007, 0x59cc0a04, 0x48066202, 0x42027000,
6010 0x00000045, 0x0201f000, 0x000207a1, 0x59cc0004,
6011 0x4803c857, 0x1c01f000, 0x4817c857, 0x0401f9c8,
6012 0x04020011, 0x0201f800, 0x0010210a, 0x0402000e,
6013 0x59cc0002, 0x82000500, 0xff000000, 0x82000580,
6014 0x00000000, 0x04020008, 0x82040500, 0x0000000f,
6015 0x82000c80, 0x00000006, 0x04021003, 0x4803c857,
6016 0x0c01f002, 0x1c01f000, 0x00105d60, 0x00105d64,
6017 0x00105d60, 0x00105d60, 0x00105db2, 0x00105dc3,
6018 0x4803c857, 0x59cc0004, 0x4803c857, 0x1c01f000,
6019 0x59cc0004, 0x4803c857, 0x59a80016, 0x800001c0,
6020 0x040207f8, 0x59cc0802, 0x8c040d2e, 0x0402001d,
6021 0x0201f800, 0x00107942, 0x02000800, 0x001005d8,
6022 0x59cc0001, 0x4803c857, 0x0401ff28, 0x0402000d,
6023 0x0201f800, 0x00020245, 0x0402000a, 0x4a026406,
6024 0x00000005, 0x49366009, 0x59cc0c04, 0x48066202,
6025 0x42027000, 0x00000088, 0x0201f000, 0x000207a1,
6026 0x42028800, 0x0000ffff, 0x417a6800, 0x59cc0001,
6027 0x82000500, 0x00ffffff, 0x4802601e, 0x0401f7f0,
6028 0x59cc0001, 0x4803c857, 0x0401ff10, 0x040207d5,
6029 0x0201f800, 0x001045a6, 0x040207d2, 0x59cc0005,
6030 0x8c000500, 0x04020004, 0x59340200, 0x8c00050e,
6031 0x040207cc, 0x0201f800, 0x001049f3, 0x0402000f,
6032 0x0401f83e, 0x040007c7, 0x0201f800, 0x0002075a,
6033 0x040007c4, 0x49366009, 0x4a026406, 0x00000002,
6034 0x59cc0c04, 0x48066202, 0x42027000, 0x00000088,
6035 0x0201f000, 0x000207a1, 0x0201f800, 0x0002075a,
6036 0x040007b8, 0x49366009, 0x4a026406, 0x00000004,
6037 0x59cc0c04, 0x48066202, 0x42027000, 0x00000001,
6038 0x0201f000, 0x000207a1, 0x59cc0004, 0x4803c857,
6039 0x59cc0802, 0x8c040d2e, 0x0400000b, 0x0401f81f,
6040 0x04000009, 0x0401f960, 0x04020007, 0x59cc0a04,
6041 0x48066202, 0x42027000, 0x00000089, 0x0201f000,
6042 0x000207a1, 0x4933c857, 0x1c01f000, 0x59cc0004,
6043 0x4803c857, 0x59cc0802, 0x8c040d2e, 0x0400000b,
6044 0x0401f80e, 0x04000009, 0x0401f94f, 0x04020007,
6045 0x59cc0a04, 0x48066202, 0x42027000, 0x0000008a,
6046 0x0201f000, 0x000207a1, 0x4933c857, 0x1c01f000,
6047 0x59cc0a04, 0x0401f002, 0x59cc0c04, 0x59a8000e,
6048 0x59a81067, 0x80080400, 0x80040480, 0x04021008,
6049 0x40040000, 0x800000c4, 0x800408ca, 0x80040c00,
6050 0x82066400, 0x0010d1c0, 0x1c01f000, 0x80000580,
6051 0x0401f7fe, 0x59cc0802, 0x8c040d2e, 0x04020010,
6052 0x0401ffec, 0x0400000e, 0x59cc0001, 0x82000500,
6053 0x00ffffff, 0x59326809, 0x59340802, 0x82040d00,
6054 0x00ffffff, 0x80040580, 0x04020005, 0x42027000,
6055 0x00000051, 0x0201f000, 0x000207a1, 0x59cc0004,
6056 0x4803c857, 0x1c01f000, 0x4803c856, 0x42003000,
6057 0x00000105, 0x0401f001, 0x4803c856, 0x4c3c0000,
6058 0x41cc7800, 0x0401f803, 0x5c007800, 0x1c01f000,
6059 0x4803c856, 0x4c580000, 0x583c0400, 0x82000500,
6060 0x0000f000, 0x82000580, 0x0000c000, 0x04000024,
6061 0x0201f800, 0x0002075a, 0x04000021, 0x4c180000,
6062 0x583c0001, 0x0401fe89, 0x0402001f, 0x0201f800,
6063 0x001045a6, 0x0402001c, 0x49366009, 0x0201f800,
6064 0x001007e4, 0x04000018, 0x492e6017, 0x497a5800,
6065 0x497a5a04, 0x48125c04, 0x832cac00, 0x00000005,
6066 0x4200b000, 0x00000007, 0x403ca000, 0x0201f800,
6067 0x0010ab17, 0x5c003000, 0x481a641a, 0x4a026403,
6068 0x0000003e, 0x4a026406, 0x00000001, 0x4a026203,
6069 0x00000001, 0x0201f800, 0x0010672b, 0x5c00b000,
6070 0x1c01f000, 0x0201f800, 0x0002077d, 0x5c003000,
6071 0x0401f7fb, 0x4803c856, 0x59cc0400, 0x82000d00,
6072 0x0000ff00, 0x82040500, 0x0000f000, 0x840409c0,
6073 0x82000580, 0x00002000, 0x04020049, 0x82040580,
6074 0x00000022, 0x0402003a, 0x59c400a4, 0x82000500,
6075 0x0000000f, 0x82000c80, 0x00000007, 0x04001004,
6076 0x82000480, 0x0000000c, 0x0400103f, 0x59cc0006,
6077 0x82000500, 0xffff0000, 0x82000d80, 0x04000000,
6078 0x04000039, 0x82000d80, 0x60000000, 0x04000036,
6079 0x82000d80, 0x54000000, 0x04000033, 0x82000d80,
6080 0x03000000, 0x04020015, 0x59a80826, 0x8c040d02,
6081 0x0402002d, 0x8c040d08, 0x0402002b, 0x0201f800,
6082 0x001048ec, 0x0400002b, 0x59a8001d, 0x800000d0,
6083 0x59a80810, 0x82040d00, 0x000000ff, 0x80040540,
6084 0x59cc0800, 0x82040d00, 0x00ffffff, 0x80040580,
6085 0x0402001b, 0x0401f01c, 0x59c40802, 0x8c040d0c,
6086 0x04020017, 0x82000d80, 0x52000000, 0x040007ec,
6087 0x82000d80, 0x05000000, 0x040007e9, 0x82000d80,
6088 0x50000000, 0x040007e6, 0x0401f00d, 0x82040580,
6089 0x00000023, 0x0402000a, 0x0401ff58, 0x04000008,
6090 0x59300c03, 0x82040580, 0x00000002, 0x04000006,
6091 0x82040580, 0x00000051, 0x04000003, 0x80000580,
6092 0x0401f003, 0x82000540, 0x00000001, 0x1c01f000,
6093 0x59cc0006, 0x82000500, 0xffff0000, 0x82000d80,
6094 0x03000000, 0x04000004, 0x82000d80, 0x52000000,
6095 0x040207f3, 0x59a80026, 0x82000500, 0x00000009,
6096 0x82000580, 0x00000008, 0x040007ef, 0x0401f7ec,
6097 0x4803c856, 0x4c5c0000, 0x4c580000, 0x59a80016,
6098 0x82000580, 0x0000004c, 0x0402001f, 0x59ccb807,
6099 0x9c5cb9c0, 0x825cbd00, 0x00000007, 0x8c5cbd00,
6100 0x0400000a, 0x4200b000, 0x00000002, 0x83a81c00,
6101 0x00000002, 0x83cc1400, 0x0000000d, 0x0201f800,
6102 0x0010855a, 0x04020010, 0x8c5cbd02, 0x0400000a,
6103 0x4200b000, 0x00000002, 0x83a81c00, 0x00000000,
6104 0x83cc1400, 0x0000000f, 0x0201f800, 0x0010855a,
6105 0x04020005, 0x8c5cbd04, 0x04000003, 0x82000540,
6106 0x00000001, 0x5c00b000, 0x5c00b800, 0x1c01f000,
6107 0x4803c856, 0x4c5c0000, 0x4c580000, 0x59a80016,
6108 0x82000580, 0x0000004c, 0x0402001f, 0x59ccb807,
6109 0x9c5cb9c0, 0x825cbd00, 0x00000007, 0x8c5cbd00,
6110 0x0400000a, 0x4200b000, 0x00000002, 0x83a81c00,
6111 0x00000002, 0x83cc1400, 0x00000009, 0x0201f800,
6112 0x0010855a, 0x04020010, 0x8c5cbd02, 0x0400000a,
6113 0x4200b000, 0x00000002, 0x83a81c00, 0x00000000,
6114 0x83cc1400, 0x0000000b, 0x0201f800, 0x0010855a,
6115 0x04020005, 0x8c5cbd04, 0x04000003, 0x82000540,
6116 0x00000001, 0x5c00b000, 0x5c00b800, 0x1c01f000,
6117 0x4803c857, 0x4c580000, 0x40003000, 0x42002000,
6118 0x000007f0, 0x4200b000, 0x00000010, 0x83ac7400,
6119 0x000007f0, 0x50380000, 0x80026d40, 0x04000006,
6120 0x59340002, 0x82000500, 0x00ffffff, 0x80180580,
6121 0x04000010, 0x80102000, 0x80387000, 0x8058b040,
6122 0x040207f5, 0x82100480, 0x00000800, 0x42002000,
6123 0x00000000, 0x4200b000, 0x000007f0, 0x41ac7000,
6124 0x040217ed, 0x82000540, 0x00000001, 0x0401f002,
6125 0x40128800, 0x5c00b000, 0x1c01f000, 0x59a80026,
6126 0x8c00050e, 0x04000004, 0x8c000502, 0x04000003,
6127 0x80000580, 0x1c01f000, 0x82000540, 0x00000001,
6128 0x0401f7fd, 0x59300c06, 0x82040580, 0x00000002,
6129 0x04000006, 0x82040580, 0x00000005, 0x04000003,
6130 0x82000540, 0x00000001, 0x1c01f000, 0x59c80000,
6131 0x84000558, 0x84000512, 0x48039000, 0x1c01f000,
6132 0x4a03281a, 0x000003e8, 0x4a032802, 0x0010d1c0,
6133 0x4a032800, 0x00000000, 0x4a032808, 0x00107049,
6134 0x42000000, 0x00000005, 0x83947c00, 0x00000009,
6135 0x49787801, 0x4a007802, 0x00106fff, 0x823c7c00,
6136 0x00000003, 0x80000040, 0x040207fa, 0x4a032819,
6137 0xffff0000, 0x4201d000, 0x00000064, 0x0401f96e,
6138 0x4201d000, 0x000186a0, 0x0401f184, 0x00000000,
6139 0x00000003, 0x00000006, 0x00000009, 0x0000000c,
6140 0x4d300000, 0x4d2c0000, 0x4d340000, 0x4d400000,
6141 0x4cfc0000, 0x4d380000, 0x4d3c0000, 0x4d440000,
6142 0x4d4c0000, 0x4d480000, 0x4c5c0000, 0x4c600000,
6143 0x4c640000, 0x4cc80000, 0x4ccc0000, 0x0201f800,
6144 0x0002057b, 0x5c019800, 0x5c019000, 0x5c00c800,
6145 0x5c00c000, 0x5c00b800, 0x5c029000, 0x5c029800,
6146 0x5c028800, 0x5c027800, 0x5c027000, 0x5c01f800,
6147 0x5c028000, 0x5c026800, 0x5c025800, 0x5c026000,
6148 0x1c01f000, 0x59940004, 0x80000540, 0x0402000a,
6149 0x59940025, 0x80040400, 0x02001800, 0x001005d8,
6150 0x48032804, 0x480b2805, 0x4a032803, 0x0000000a,
6151 0x80000580, 0x1c01f000, 0x5994001f, 0x80000540,
6152 0x0402000a, 0x59940025, 0x80040400, 0x02001800,
6153 0x001005d8, 0x4803281f, 0x480b2820, 0x4a03281e,
6154 0x00000001, 0x80000580, 0x1c01f000, 0x59940022,
6155 0x80000540, 0x0402000a, 0x59940025, 0x80040400,
6156 0x02001800, 0x001005d8, 0x48032822, 0x480b2823,
6157 0x4a032821, 0x0000000a, 0x80000580, 0x1c01f000,
6158 0x4c000000, 0x59940005, 0x4803c857, 0x480bc857,
6159 0x80080580, 0x04020003, 0x497b2804, 0x497b2805,
6160 0x5c000000, 0x1c01f000, 0x4c000000, 0x59940020,
6161 0x4803c857, 0x480bc857, 0x80080580, 0x04020003,
6162 0x497b281f, 0x497b2820, 0x5c000000, 0x1c01f000,
6163 0x4c000000, 0x59940023, 0x4803c857, 0x480bc857,
6164 0x80080580, 0x04020003, 0x497b2822, 0x497b2823,
6165 0x5c000000, 0x1c01f000, 0x4937c857, 0x48ebc857,
6166 0x59340203, 0x80e80480, 0x04001002, 0x48ea6a03,
6167 0x1c01f000, 0x5c03e000, 0x1c01f000, 0x4d440000,
6168 0x42007800, 0x00000010, 0x59968801, 0x0201f800,
6169 0x00020245, 0x04020012, 0x59341a03, 0x800c1840,
6170 0x0400100f, 0x59940027, 0x800c0480, 0x04000003,
6171 0x48026a03, 0x0402100a, 0x5934000f, 0x497a6a03,
6172 0x80000540, 0x04000006, 0x4c3c0000, 0x5934140b,
6173 0x0201f800, 0x00020253, 0x5c007800, 0x81468800,
6174 0x83440480, 0x00000800, 0x04021007, 0x803c7840,
6175 0x040207e7, 0x49472801, 0x5c028800, 0x5c03e000,
6176 0x1c01f000, 0x4a032800, 0x00000002, 0x497b2801,
6177 0x0401f7fa, 0x42007800, 0x00000010, 0x59966002,
6178 0x59300205, 0x80000d40, 0x04000006, 0x59940027,
6179 0x80040480, 0x48026205, 0x0400102d, 0x0400002c,
6180 0x59300206, 0x80000d40, 0x04000014, 0x59b800e4,
6181 0x8c000524, 0x04020011, 0x4a0370e4, 0x00030000,
6182 0x40000000, 0x59b800e4, 0x8c000524, 0x04000004,
6183 0x4a0370e4, 0x00020000, 0x0401f008, 0x59940027,
6184 0x80040480, 0x48026206, 0x4a0370e4, 0x00020000,
6185 0x0400101c, 0x0400001b, 0x83326400, 0x00000024,
6186 0x49332802, 0x41540000, 0x81300480, 0x04021005,
6187 0x803c7840, 0x040207db, 0x5c03e000, 0x1c01f000,
6188 0x59940026, 0x48032827, 0x4a032802, 0x0010d1c0,
6189 0x497b2826, 0x80000540, 0x0400000f, 0x4a032800,
6190 0x00000001, 0x5c03e000, 0x1c01f000, 0x4c3c0000,
6191 0x0201f800, 0x001091db, 0x5c007800, 0x0401f7d1,
6192 0x4c3c0000, 0x0201f800, 0x00108d5d, 0x5c007800,
6193 0x0401f7e2, 0x4a032800, 0x00000000, 0x5c03e000,
6194 0x1c01f000, 0x59a8086b, 0x8c040d30, 0x04020029,
6195 0x8c040d32, 0x0400000f, 0x59a80069, 0x81640480,
6196 0x04001019, 0x59a8000b, 0x81500580, 0x04000005,
6197 0x59a8006a, 0x59a81066, 0x80080580, 0x04020012,
6198 0x900411c0, 0x82081500, 0x00007000, 0x0401f012,
6199 0x82040500, 0x0000001f, 0x04000016, 0x80040840,
6200 0x82040500, 0x0000001f, 0x04000003, 0x4807506b,
6201 0x0401f010, 0x900401c0, 0x82000500, 0x0000001f,
6202 0x80040d40, 0x900401c0, 0x80040580, 0x82001500,
6203 0x00007000, 0x82040500, 0xffff8fff, 0x80080540,
6204 0x4803506b, 0x80081114, 0x0201f800, 0x001006e2,
6205 0x1c01f000, 0x4a032807, 0x000007d0, 0x4a032806,
6206 0x0000000a, 0x1c01f000, 0x42000800, 0x000007d0,
6207 0x83180480, 0x00000005, 0x02021800, 0x001005d8,
6208 0x83947c00, 0x00000009, 0x83180400, 0x00105f43,
6209 0x50000000, 0x803c7c00, 0x48047801, 0x4a007800,
6210 0x0000000a, 0x1c01f000, 0x83180480, 0x00000005,
6211 0x02021800, 0x001005d8, 0x83947c00, 0x00000009,
6212 0x83180400, 0x00105f43, 0x50000000, 0x803c7c00,
6213 0x49787801, 0x1c01f000, 0x4807c857, 0x480bc857,
6214 0x59940025, 0x80040400, 0x02001800, 0x001005d8,
6215 0x48032804, 0x480b2805, 0x4a032803, 0x0000000a,
6216 0x1c01f000, 0x4807c857, 0x480bc857, 0x59940025,
6217 0x80040400, 0x02001800, 0x001005d8, 0x4803281c,
6218 0x480b281d, 0x4a03281b, 0x0000000a, 0x1c01f000,
6219 0x4c000000, 0x5994001d, 0x4803c857, 0x480bc857,
6220 0x80080580, 0x04020003, 0x4803281c, 0x4803281d,
6221 0x5c000000, 0x1c01f000, 0x80e9d1c0, 0x0400000e,
6222 0x0401f836, 0x04025000, 0x4203e000, 0x80000000,
6223 0x40e81000, 0x41780800, 0x42000000, 0x00000064,
6224 0x0201f800, 0x001066a0, 0x59940024, 0x80080400,
6225 0x48032824, 0x1c01f000, 0x42001000, 0x00105065,
6226 0x0401fef0, 0x42001000, 0x00105058, 0x0401ffe1,
6227 0x42001000, 0x00104148, 0x0401feea, 0x42001000,
6228 0x001041bc, 0x0401fee7, 0x42001000, 0x001041f3,
6229 0x0401f6f8, 0x4203e000, 0x70000000, 0x4203e000,
6230 0xb0300000, 0x41fc0000, 0x40ebf800, 0x80e80480,
6231 0x04001011, 0x04000004, 0x82000480, 0x00000003,
6232 0x0402100d, 0x42000000, 0x0000000f, 0x04004004,
6233 0x80000040, 0x040207fe, 0x0401f007, 0x4203e000,
6234 0x70000000, 0x42000000, 0x0010b87e, 0x0201f800,
6235 0x0010aa47, 0x1c01f000, 0x4203e000, 0x80000000,
6236 0x4203e000, 0xb0400000, 0x41fc0000, 0x40ebf800,
6237 0x80e80480, 0x04001011, 0x04000004, 0x82000480,
6238 0x00000003, 0x0402100d, 0x42000000, 0x0000000f,
6239 0x04005004, 0x80000040, 0x040207fe, 0x0401f007,
6240 0x4203e000, 0x80000000, 0x42000000, 0x0010b87f,
6241 0x0201f800, 0x0010aa47, 0x1c01f000, 0x59a8000e,
6242 0x82000480, 0x00000100, 0x599c0a02, 0x800409c0,
6243 0x04020002, 0x80040800, 0x80041480, 0x04001002,
6244 0x40000800, 0x48075067, 0x59a8100e, 0x40040000,
6245 0x800acc80, 0x4967500e, 0x49675069, 0x59aaa80b,
6246 0x41640800, 0x42001000, 0x00000024, 0x0201f800,
6247 0x00106681, 0x8206a400, 0x0010d1c0, 0x49535065,
6248 0x4152b000, 0x42006000, 0x0010be65, 0x4a006004,
6249 0x0000012c, 0x4a006005, 0xda10da10, 0x4a006008,
6250 0x00000011, 0x4a006009, 0x0010be65, 0x4a00600a,
6251 0x001010b8, 0x599c0014, 0x48006011, 0x599c0015,
6252 0x48006012, 0x42006000, 0x0010be41, 0x4a006203,
6253 0x00000008, 0x4a006406, 0x00000006, 0x4a006002,
6254 0xffff0000, 0x4a006008, 0x0010be65, 0x4a006014,
6255 0x0010be65, 0x599c0014, 0x48006015, 0x599c0015,
6256 0x48006016, 0x599c0413, 0x48006017, 0x49506018,
6257 0x49546019, 0x59a80067, 0x4800601a, 0x4a00601b,
6258 0x0010b465, 0x4a00601c, 0x0010b466, 0x4a00601d,
6259 0x0010b46a, 0x42000000, 0xb0000000, 0x42000800,
6260 0x0010be41, 0x0201f800, 0x00100b68, 0x1c01f000,
6261 0x82000d00, 0x000000c0, 0x04000004, 0x82040d80,
6262 0x000000c0, 0x04020055, 0x82000d00, 0x00002020,
6263 0x59300414, 0x84000512, 0x82040d80, 0x00002020,
6264 0x0400000b, 0x8c000514, 0x0402000f, 0x48026414,
6265 0x813e79c0, 0x02020000, 0x000206d0, 0x42027000,
6266 0x00000043, 0x0201f000, 0x000207a1, 0x59326809,
6267 0x59340a00, 0x8c040d0a, 0x040007f3, 0x84000552,
6268 0x0401f7f1, 0x84000514, 0x592c080d, 0x48066015,
6269 0x0401f7ef, 0x59326809, 0x59340a00, 0x8c040d0a,
6270 0x02000000, 0x000206e3, 0x59300c14, 0x84040d52,
6271 0x48066414, 0x0201f000, 0x000206e3, 0x0201f800,
6272 0x00020086, 0x813e79c0, 0x02020000, 0x000206d0,
6273 0x0201f000, 0x000206f1, 0x8c00051e, 0x02000000,
6274 0x000206fd, 0x82000d00, 0x00002020, 0x82040d80,
6275 0x00002020, 0x04000014, 0x82000500, 0x000000c0,
6276 0x82000d80, 0x00000080, 0x04000008, 0x813e79c0,
6277 0x02020000, 0x000206d0, 0x42027000, 0x00000041,
6278 0x0201f000, 0x000207a1, 0x813e79c0, 0x02020000,
6279 0x000206d0, 0x42027000, 0x00000043, 0x0201f000,
6280 0x000207a1, 0x59326809, 0x59340a00, 0x8c040d0a,
6281 0x040007ea, 0x59300c14, 0x84040d52, 0x48066414,
6282 0x0401f7e6, 0x492fc857, 0x42000800, 0x00000006,
6283 0x0201f000, 0x000206f8, 0x492fc857, 0x42000800,
6284 0x00000004, 0x0201f000, 0x000206f8, 0x4807c856,
6285 0x59a80068, 0x800409c0, 0x04000003, 0x80080540,
6286 0x0401f002, 0x80080500, 0x48035068, 0x1c01f000,
6287 0x4a030800, 0x00000000, 0x4a030802, 0x00000001,
6288 0x497b0803, 0x497b0804, 0x1c01f000, 0x59840002,
6289 0x8c000500, 0x04000004, 0x84000500, 0x4a030800,
6290 0x00000001, 0x84000544, 0x84000506, 0x48030802,
6291 0x82000d00, 0x0fffffff, 0x42000000, 0x90000000,
6292 0x0201f800, 0x00100b94, 0x59a80069, 0x82000480,
6293 0x00000007, 0x48035069, 0x80000580, 0x42000800,
6294 0x0010b519, 0x48000800, 0x48000801, 0x1c01f000,
6295 0x59a80069, 0x82000480, 0x00000007, 0x48035069,
6296 0x1c01f000, 0x83640480, 0x00000008, 0x0400101b,
6297 0x58c80a03, 0x80000580, 0x82000400, 0x00000008,
6298 0x80040840, 0x040207fd, 0x815c0480, 0x04001013,
6299 0x4200b000, 0x00000007, 0x0201f800, 0x0002075a,
6300 0x4a026203, 0x00000004, 0x4a026406, 0x00000009,
6301 0x4a026203, 0x00000004, 0x4a026007, 0x00000101,
6302 0x0401f809, 0x0401f880, 0x8058b040, 0x040207f3,
6303 0x80000580, 0x1c01f000, 0x82000540, 0x00000001,
6304 0x0401f7fd, 0x0201f800, 0x001007e4, 0x492e6008,
6305 0x58c80a03, 0x4a025a04, 0x0000002c, 0x497a5800,
6306 0x497a5801, 0x497a5c04, 0x497a5c06, 0x497a5805,
6307 0x4a025a08, 0x00000005, 0x4a025a07, 0x00000002,
6308 0x58c80201, 0x48025c04, 0x58c80202, 0x48025c07,
6309 0x58c80204, 0x48025c08, 0x4a02580d, 0x0000ffff,
6310 0x80040840, 0x0400000c, 0x412c2000, 0x0201f800,
6311 0x001007e4, 0x4a025a04, 0x0000000a, 0x497a5c04,
6312 0x48125800, 0x492c2001, 0x412c2000, 0x80040840,
6313 0x040207f7, 0x1c01f000, 0x4d7c0000, 0x4202f800,
6314 0x00000010, 0x4df00000, 0x4203e000, 0x50000000,
6315 0x59847803, 0x803c79c0, 0x0400001e, 0x4c5c0000,
6316 0x583cb808, 0x585c3408, 0x801831c0, 0x0400000b,
6317 0x0401f84a, 0x04000016, 0x42001000, 0x0010b519,
6318 0x0401f87f, 0x04000012, 0x0201f800, 0x001007d3,
6319 0x0400000f, 0x492cb805, 0x585c0005, 0x80000540,
6320 0x02000800, 0x001005d8, 0x0401f830, 0x585c5408,
6321 0x0401f80b, 0x5c00b800, 0x5c03e000, 0x817ef840,
6322 0x040207e1, 0x5c02f800, 0x1c01f000, 0x5c00b800,
6323 0x5c03e000, 0x5c02f800, 0x1c01f000, 0x4803c856,
6324 0x405c6000, 0x802851c0, 0x04000018, 0x585c0204,
6325 0x82000d00, 0x0000000f, 0x82040c00, 0x001010bd,
6326 0x50044000, 0x4cf00000, 0x4d000000, 0x4d040000,
6327 0x4021e000, 0x40320800, 0x59860004, 0x4c280000,
6328 0x0401f934, 0x5c005000, 0x40f04000, 0x41046000,
6329 0x0201f800, 0x0010109b, 0x040207f6, 0x5c020800,
6330 0x5c020000, 0x5c01e000, 0x58c80204, 0x4800bc08,
6331 0x0201f800, 0x00020086, 0x4a026007, 0x00000101,
6332 0x497a6009, 0x0401f055, 0x4803c856, 0x59840003,
6333 0x80026540, 0x04000003, 0x59300000, 0x48030803,
6334 0x1c01f000, 0x4803c856, 0x59840003, 0x48026000,
6335 0x49330803, 0x1c01f000, 0x58cc0805, 0x40180000,
6336 0x80040480, 0x0400100d, 0x82cc0580, 0x0010b50e,
6337 0x02020800, 0x001005d8, 0x58c80205, 0x80040480,
6338 0x0400101d, 0x82000540, 0x00000001, 0x1c01f000,
6339 0x80003580, 0x0401f7fe, 0x82cc0580, 0x0010b50e,
6340 0x02020800, 0x001005d8, 0x58c80400, 0x8c000504,
6341 0x040007f8, 0x58c8040b, 0x8c00051e, 0x040007f5,
6342 0x8c000500, 0x040207f3, 0x84000540, 0x4801940b,
6343 0x42000000, 0x0010b839, 0x0201f800, 0x0010aa47,
6344 0x42001000, 0x00008026, 0x0201f800, 0x00103a3e,
6345 0x0401f7e8, 0x58c8040b, 0x8c00051e, 0x040007e2,
6346 0x8c000502, 0x040207e0, 0x84000542, 0x4801940b,
6347 0x42000000, 0x0010b838, 0x0201f800, 0x0010aa47,
6348 0x42001000, 0x00008025, 0x42001800, 0x00000000,
6349 0x0201f800, 0x00103a3e, 0x0401f7d3, 0x4803c856,
6350 0x58080000, 0x42001800, 0x00000007, 0x58080801,
6351 0x80040480, 0x04020004, 0x400c0000, 0x80000540,
6352 0x0401f005, 0x04001003, 0x800c0480, 0x0401f002,
6353 0x80000080, 0x1c01f000, 0x4803c856, 0x59300008,
6354 0x80000d40, 0x02000800, 0x001005d8, 0x58040005,
6355 0x80000540, 0x02000800, 0x001005d8, 0x59300007,
6356 0x82000500, 0x00000101, 0x82000580, 0x00000101,
6357 0x02020800, 0x001005d8, 0x42001000, 0x0010b519,
6358 0x58080801, 0x82040400, 0x0010b51b, 0x497a6414,
6359 0x4a026015, 0x0000ffff, 0x45300000, 0x80040800,
6360 0x82040480, 0x00000008, 0x04001002, 0x80000d80,
6361 0x48041001, 0x82040400, 0x0010b51b, 0x45780000,
6362 0x1c01f000, 0x4933c857, 0x59300808, 0x800409c0,
6363 0x02000800, 0x001005d8, 0x4d2c0000, 0x58065805,
6364 0x812e59c0, 0x02020800, 0x001007f4, 0x49780805,
6365 0x40065800, 0x0201f800, 0x001007fd, 0x5c025800,
6366 0x4d300000, 0x0201f800, 0x0002077d, 0x5c026000,
6367 0x1c01f000, 0x59300406, 0x82000580, 0x00000009,
6368 0x04020006, 0x59300007, 0x8c000510, 0x04000003,
6369 0x80000580, 0x1c01f000, 0x82000540, 0x00000001,
6370 0x1c01f000, 0x59840802, 0x8c040d04, 0x1c01f000,
6371 0x4803c856, 0x59840802, 0x84040d04, 0x84040d40,
6372 0x4a030800, 0x00000000, 0x48070802, 0x82040d00,
6373 0x0fffffff, 0x42000000, 0x90000000, 0x0201f000,
6374 0x00100b94, 0x4807c857, 0x4805980a, 0x49799801,
6375 0x49799803, 0x49799806, 0x49799807, 0x49799808,
6376 0x49799805, 0x49799809, 0x0401f8c9, 0x0400000a,
6377 0x0401f8eb, 0x04000008, 0x48359800, 0x48359802,
6378 0x48359806, 0x4a019804, 0x00000001, 0x4a019807,
6379 0x00000005, 0x1c01f000, 0x4807c857, 0x58cc1007,
6380 0x40040000, 0x80080480, 0x04021020, 0x4c040000,
6381 0x4c080000, 0x0401f8da, 0x5c001000, 0x5c000800,
6382 0x0400001c, 0x58cc0006, 0x80006540, 0x0402000b,
6383 0x48359800, 0x48359802, 0x48359806, 0x49799801,
6384 0x49799803, 0x49786801, 0x49786800, 0x49799804,
6385 0x49799807, 0x0401f005, 0x48306801, 0x48346000,
6386 0x48359806, 0x49786800, 0x58cc0004, 0x58cc1007,
6387 0x80000000, 0x82081400, 0x00000005, 0x48019804,
6388 0x48099807, 0x0401f7df, 0x80000580, 0x1c01f000,
6389 0x82000540, 0x00000001, 0x1c01f000, 0x480bc857,
6390 0x4c500000, 0x4c540000, 0x4c580000, 0x40083000,
6391 0x58cc0801, 0x82040480, 0x00000005, 0x02021800,
6392 0x001005d8, 0x82040400, 0x00106418, 0x50000000,
6393 0x58cca800, 0x8054ac00, 0x42001800, 0x00000005,
6394 0x40040000, 0x800c0480, 0x80082480, 0x04021002,
6395 0x40080000, 0x8000b0c2, 0x8058b400, 0x5450a800,
6396 0x8050a000, 0x8054a800, 0x8058b040, 0x040207fc,
6397 0x40001000, 0x58cc2805, 0x58cc0807, 0x58cc2001,
6398 0x80142c00, 0x80040c80, 0x80102400, 0x48159805,
6399 0x48059807, 0x48119801, 0x82100580, 0x00000005,
6400 0x0400000c, 0x48119801, 0x40080000, 0x80181480,
6401 0x40083000, 0x04000003, 0x040217d6, 0x80000580,
6402 0x5c00b000, 0x5c00a800, 0x5c00a000, 0x1c01f000,
6403 0x58cc0800, 0x800409c0, 0x02000800, 0x001005d8,
6404 0x58040800, 0x48059800, 0x41782000, 0x0401f7ee,
6405 0x0401f813, 0x50f00000, 0x81040400, 0x40001800,
6406 0x585c0204, 0x4803c857, 0x82000580, 0x0000002c,
6407 0x02020800, 0x001005d8, 0x58040202, 0x800000e0,
6408 0x81000540, 0x48001802, 0x58040000, 0x48001800,
6409 0x58040001, 0x48001801, 0x1c01f000, 0x4807c856,
6410 0x58cc0005, 0x80000040, 0x02001800, 0x001005d8,
6411 0x48019805, 0x58cc1003, 0x82080480, 0x00000005,
6412 0x02021800, 0x001005d8, 0x82080400, 0x00106418,
6413 0x50000000, 0x58cc0802, 0x80040c00, 0x80081000,
6414 0x82080480, 0x00000005, 0x0402000f, 0x58cc2002,
6415 0x58100000, 0x80006d40, 0x04000009, 0x4c340000,
6416 0x0401f858, 0x5c006800, 0x49786801, 0x48359802,
6417 0x58cc0004, 0x80000040, 0x48019804, 0x49799803,
6418 0x0401f002, 0x48099803, 0x1c01f000, 0x4807c856,
6419 0x41781800, 0x58c80201, 0x80000540, 0x04000002,
6420 0x800c1800, 0x58c80c01, 0x80040c80, 0x0400100a,
6421 0x04000009, 0x800c1800, 0x58c80202, 0x80041480,
6422 0x04001005, 0x04000004, 0x800c1800, 0x40080800,
6423 0x0401f7fb, 0x480d9204, 0x400c0000, 0x42002000,
6424 0x00000001, 0x80000040, 0x04000007, 0x04001006,
6425 0x80102000, 0x82000480, 0x00000005, 0x04000002,
6426 0x040217fc, 0x48119203, 0x1c01f000, 0x4807c856,
6427 0x4d2c0000, 0x58cc000a, 0x80000540, 0x02000800,
6428 0x001005d8, 0x82002400, 0x00000005, 0x0201f800,
6429 0x001007d3, 0x04000012, 0x492d9809, 0x497a5800,
6430 0x497a5801, 0x0201f800, 0x001007d3, 0x0400000c,
6431 0x58cc0009, 0x48025800, 0x497a5801, 0x492d9809,
6432 0x82102480, 0x00000005, 0x040217f7, 0x82000540,
6433 0x00000001, 0x5c025800, 0x1c01f000, 0x58cc0009,
6434 0x80025d40, 0x040007fc, 0x592c2000, 0x0201f800,
6435 0x001007f4, 0x40100000, 0x0401f7fa, 0x58cc0009,
6436 0x48cfc857, 0x80006d40, 0x04000005, 0x50340000,
6437 0x48019809, 0x49786800, 0x49786801, 0x1c01f000,
6438 0x4813c857, 0x58cc0009, 0x48002000, 0x48119809,
6439 0x1c01f000, 0x4807c856, 0x4d2c0000, 0x58cc0009,
6440 0x80025d40, 0x04000007, 0x592c0000, 0x4c000000,
6441 0x0201f800, 0x001007f4, 0x5c000000, 0x0401f7f9,
6442 0x5c025800, 0x1c01f000, 0x4807c856, 0x4d2c0000,
6443 0x58cc0002, 0x80025d40, 0x04000007, 0x592c0000,
6444 0x4c000000, 0x0201f800, 0x001007f4, 0x5c000000,
6445 0x0401f7f9, 0x49799800, 0x49799802, 0x49799801,
6446 0x49799803, 0x49799806, 0x49799807, 0x49799808,
6447 0x49799809, 0x4979980a, 0x5c025800, 0x1c01f000,
6448 0x00000003, 0x00000006, 0x00000009, 0x0000000c,
6449 0x0000000f, 0x00000012, 0x4803c856, 0x0401f857,
6450 0x4a00c204, 0x0000003c, 0x59301009, 0x82080580,
6451 0x0010b524, 0x04000013, 0x58080802, 0x82040d00,
6452 0x00ffffff, 0x58080403, 0x4804c005, 0x4800c406,
6453 0x4a00c207, 0x00000003, 0x59300811, 0x585c0404,
6454 0x4978c206, 0x4804c407, 0x80000540, 0x0400000d,
6455 0x58600206, 0x84000540, 0x4800c206, 0x0401f009,
6456 0x585c080a, 0x82040d00, 0x00ffffff, 0x4804c005,
6457 0x4a00c406, 0x000007ff, 0x4978c207, 0x0401f7ef,
6458 0x82603c00, 0x00000008, 0x58605404, 0x40282000,
6459 0x405c6000, 0x585c0a04, 0x82040d00, 0x0000000f,
6460 0x82040c00, 0x001010bd, 0x50044000, 0x80004d80,
6461 0x50200000, 0x80307400, 0x58380402, 0x8c244d00,
6462 0x04020003, 0x48003a00, 0x0401f003, 0x48003c00,
6463 0x801c3800, 0x80244800, 0x80102040, 0x04000006,
6464 0x0201f800, 0x0010109b, 0x02000800, 0x001005d8,
6465 0x0401f7f0, 0x1c01f000, 0x4803c856, 0x4d340000,
6466 0x59300009, 0x80026d40, 0x02000800, 0x001005d8,
6467 0x59340401, 0x80000540, 0x0400000e, 0x59840000,
6468 0x80000540, 0x0400000b, 0x836c0580, 0x00000003,
6469 0x04020008, 0x59341c03, 0x42002000, 0x00000004,
6470 0x42003000, 0x00000004, 0x0201f800, 0x00103aae,
6471 0x5c026800, 0x1c01f000, 0x4803c856, 0x80001580,
6472 0x58c80c01, 0x59300011, 0x80040c80, 0x48066011,
6473 0x58c80201, 0x80000540, 0x04000005, 0x80081000,
6474 0x80040c80, 0x04001007, 0x04000006, 0x58c80202,
6475 0x80081000, 0x80040c80, 0x04001002, 0x040207fd,
6476 0x4808bc08, 0x4808c404, 0x1c01f000, 0x4803c856,
6477 0x4a0370e5, 0x00020000, 0x59b800e5, 0x8c000524,
6478 0x040207fc, 0x4a0370e5, 0x00030000, 0x40000000,
6479 0x40000000, 0x59b800e5, 0x8c000524, 0x040207f5,
6480 0x5934000e, 0x80006d40, 0x04000010, 0x81300580,
6481 0x04020004, 0x58340000, 0x4802680e, 0x0401f00a,
6482 0x40347800, 0x58340000, 0x80006d40, 0x02000800,
6483 0x001005d8, 0x81300580, 0x040207fa, 0x58340000,
6484 0x48007800, 0x497a6000, 0x4a0370e5, 0x00020000,
6485 0x1c01f000, 0x4803c856, 0x4d300000, 0x4d2c0000,
6486 0x42000800, 0x000003ff, 0x4a0370e5, 0x00020000,
6487 0x59b800e5, 0x8c000524, 0x04000005, 0x80040840,
6488 0x040207fa, 0x0201f800, 0x001005d8, 0x4a0370e5,
6489 0x00030000, 0x40000000, 0x40000000, 0x59b800e5,
6490 0x8c000524, 0x040207f1, 0x5934000e, 0x80026540,
6491 0x0400000e, 0x4933c857, 0x59300000, 0x4802680e,
6492 0x4a026203, 0x00000004, 0x497a6206, 0x497a6009,
6493 0x4a026007, 0x00000101, 0x59325808, 0x497a5c08,
6494 0x0401fd81, 0x0401f7f1, 0x4a0370e5, 0x00020000,
6495 0x5c025800, 0x5c026000, 0x1c01f000, 0x4803c856,
6496 0x4c000000, 0x0201f800, 0x00105c9a, 0x04020011,
6497 0x0201f800, 0x001045a6, 0x02020800, 0x001005d8,
6498 0x5c000000, 0x48026802, 0x0201f800, 0x0002075a,
6499 0x04000009, 0x49366009, 0x4a026406, 0x00000001,
6500 0x42027000, 0x00000001, 0x0201f000, 0x000207a1,
6501 0x5c000000, 0x1c01f000, 0x59300203, 0x82000c80,
6502 0x0000000e, 0x02021800, 0x001005d8, 0x4803c857,
6503 0x0c01f001, 0x00106503, 0x00106503, 0x00106503,
6504 0x00106505, 0x00106565, 0x00106503, 0x00106503,
6505 0x001065b7, 0x001065b8, 0x00106503, 0x00106503,
6506 0x00106503, 0x00106503, 0x00106503, 0x0201f800,
6507 0x001005d8, 0x493bc857, 0x83380480, 0x00000050,
6508 0x02021800, 0x001005d8, 0x83380480, 0x00000049,
6509 0x02001800, 0x001005d8, 0x0c01f001, 0x00106518,
6510 0x0010653a, 0x00106516, 0x00106516, 0x00106516,
6511 0x00106516, 0x00106549, 0x0201f800, 0x001005d8,
6512 0x4d2c0000, 0x59325808, 0x592c0206, 0x48025c06,
6513 0x4a025a06, 0x00000000, 0x4c5c0000, 0x592cbc0a,
6514 0x592c0000, 0x48026008, 0x0201f800, 0x00104cde,
6515 0x59300008, 0x80000540, 0x04000008, 0x4a026203,
6516 0x00000007, 0x42027000, 0x00000043, 0x5c00b800,
6517 0x5c025800, 0x0401f08a, 0x8c5cbd08, 0x04020006,
6518 0x4a026203, 0x00000007, 0x497a6206, 0x497a6008,
6519 0x0401f003, 0x0201f800, 0x0002077d, 0x5c00b800,
6520 0x5c025800, 0x1c01f000, 0x0201f800, 0x00106b8a,
6521 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037,
6522 0x04000006, 0x4d400000, 0x42028000, 0x00000001,
6523 0x0401f8f8, 0x5c028000, 0x5c025800, 0x0201f000,
6524 0x0002077d, 0x0201f800, 0x00106b8a, 0x4d3c0000,
6525 0x417a7800, 0x0201f800, 0x0010203c, 0x5c027800,
6526 0x42003000, 0x00000014, 0x0201f800, 0x0010a942,
6527 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
6528 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037,
6529 0x04000006, 0x4d400000, 0x42028000, 0x00000029,
6530 0x0401f8dc, 0x5c028000, 0x5c025800, 0x0201f000,
6531 0x0002077d, 0x493bc857, 0x497a6206, 0x83380480,
6532 0x00000054, 0x02021800, 0x001005d8, 0x83380480,
6533 0x00000047, 0x02001800, 0x001005d8, 0x0c01f001,
6534 0x001065b6, 0x0010657f, 0x0010657d, 0x0010657d,
6535 0x0010657d, 0x0010657d, 0x0010657d, 0x0010657d,
6536 0x0010657d, 0x0010657d, 0x0010657d, 0x0010657d,
6537 0x00106583, 0x0201f800, 0x001005d8, 0x59300011,
6538 0x82000500, 0xffff0000, 0x04020034, 0x59840802,
6539 0x8c040d04, 0x04000025, 0x59300009, 0x80026d40,
6540 0x0400001f, 0x4c5c0000, 0x4c600000, 0x497a6206,
6541 0x5930b808, 0x585c0005, 0x8000c540, 0x02000800,
6542 0x001005d8, 0x0401fe8d, 0x40625800, 0x0201f800,
6543 0x00104cde, 0x4978b805, 0x0401fef5, 0x497a6009,
6544 0x585c3408, 0x0401fcbd, 0x0400000e, 0x42001000,
6545 0x0010b519, 0x0401fcf2, 0x0400000a, 0x0201f800,
6546 0x001007e4, 0x04000007, 0x492cb805, 0x585c5408,
6547 0x0401fc83, 0x5c00c000, 0x5c00b800, 0x1c01f000,
6548 0x0401fca9, 0x0401f7fc, 0x8c040d06, 0x040207fc,
6549 0x59300009, 0x80026d40, 0x04000006, 0x5934000e,
6550 0x80000540, 0x02020800, 0x001005d8, 0x497a6009,
6551 0x0401fd0d, 0x0401f7f2, 0x0401f06f, 0x4803c856,
6552 0x4803c856, 0x83380580, 0x00000043, 0x02020800,
6553 0x001005d8, 0x4a026203, 0x00000003, 0x493a6403,
6554 0x59325808, 0x592c000f, 0x48026011, 0x497a6013,
6555 0x592c0406, 0x800000c2, 0x800010c4, 0x80081400,
6556 0x480a6206, 0x0201f800, 0x00100f4e, 0x42000800,
6557 0x80000060, 0x0401f154, 0x42000000, 0x0010b875,
6558 0x0201f800, 0x0010aa47, 0x59300203, 0x82000c80,
6559 0x0000000e, 0x02021800, 0x001005d8, 0x4803c857,
6560 0x82000d80, 0x00000003, 0x04000006, 0x82000d80,
6561 0x00000004, 0x04000045, 0x0201f800, 0x001005d8,
6562 0x0201f800, 0x00106c55, 0x59300004, 0x8c00053e,
6563 0x04020007, 0x0201f800, 0x00106b6c, 0x02020800,
6564 0x001005d8, 0x0201f000, 0x00106c4b, 0x0401f9c3,
6565 0x0201f800, 0x00106c4b, 0x59325808, 0x42028000,
6566 0x00000006, 0x0401f84b, 0x0201f000, 0x0002077d,
6567 0x4803c856, 0x59300203, 0x82000c80, 0x0000000e,
6568 0x02021800, 0x001005d8, 0x82000d80, 0x00000003,
6569 0x04000006, 0x82000d80, 0x00000004, 0x04000023,
6570 0x0201f800, 0x001005d8, 0x4803c856, 0x0201f800,
6571 0x00106c55, 0x4df00000, 0x59300004, 0x8c00053e,
6572 0x04020006, 0x0201f800, 0x00106f60, 0x02020800,
6573 0x001005d8, 0x0401f010, 0x0201f800, 0x00108cd6,
6574 0x04020004, 0x0201f800, 0x00106e62, 0x0402000a,
6575 0x0401f99a, 0x02020800, 0x001005d8, 0x5c03e000,
6576 0x02000800, 0x00106c4b, 0x82000540, 0x00000001,
6577 0x1c01f000, 0x5c03e000, 0x02000800, 0x00106c4b,
6578 0x80000580, 0x1c01f000, 0x4933c857, 0x0201f800,
6579 0x00100e99, 0x4933c857, 0x4c5c0000, 0x4d340000,
6580 0x497a6206, 0x5930b808, 0x59300009, 0x80026d40,
6581 0x04020e5f, 0x42001000, 0x0010b519, 0x0401fc60,
6582 0x04000009, 0x58c80204, 0x4800bc08, 0x41785000,
6583 0x0201f800, 0x00106227, 0x5c026800, 0x5c00b800,
6584 0x1c01f000, 0x4978bc08, 0x0401fc17, 0x0401f7fb,
6585 0x4803c856, 0x0201f800, 0x00109037, 0x0400000f,
6586 0x592c0000, 0x80000d40, 0x04000009, 0x497a5800,
6587 0x49425a06, 0x4c040000, 0x0201f800, 0x000202da,
6588 0x5c000800, 0x40065800, 0x0401f7f6, 0x49425a06,
6589 0x0201f800, 0x000202da, 0x1c01f000, 0x4933c857,
6590 0x59300c06, 0x82040580, 0x0000000e, 0x04000004,
6591 0x82040580, 0x00000009, 0x04020004, 0x0401ffe5,
6592 0x497a6008, 0x80000580, 0x1c01f000, 0x592e6009,
6593 0x83300480, 0x0010d1c0, 0x04001016, 0x41580000,
6594 0x81300480, 0x04021013, 0x40040000, 0x59300c06,
6595 0x80040580, 0x04020012, 0x59300a03, 0x82040580,
6596 0x00000007, 0x02020800, 0x001005d8, 0x59300008,
6597 0x80000540, 0x02020800, 0x001005d8, 0x0201f800,
6598 0x0002077d, 0x42000000, 0x00000000, 0x0401f009,
6599 0x42000000, 0x00000008, 0x0401f006, 0x82040580,
6600 0x00000007, 0x040207fb, 0x42000000, 0x00000005,
6601 0x592c0a06, 0x48065c06, 0x48025a06, 0x0201f000,
6602 0x000202da, 0x4c0c0000, 0x4c100000, 0x4c140000,
6603 0x4c180000, 0x80001d80, 0x80002580, 0x42003000,
6604 0x00000020, 0x82040500, 0x00000001, 0x04000003,
6605 0x40080000, 0x800c1c00, 0x400c2800, 0x800c1902,
6606 0x80102102, 0x82140500, 0x00000001, 0x04000003,
6607 0x82102540, 0x80000000, 0x80040902, 0x80183040,
6608 0x040207f1, 0x40100800, 0x400c0000, 0x5c003000,
6609 0x5c002800, 0x5c002000, 0x5c001800, 0x1c01f000,
6610 0x4c580000, 0x4200b000, 0x00000020, 0x80000540,
6611 0x04000018, 0x80041c80, 0x04021016, 0x800810c2,
6612 0x80040982, 0x04001006, 0x80041c80, 0x04021005,
6613 0x8058b040, 0x040207fa, 0x0401f006, 0x80041c80,
6614 0x400c0800, 0x80081000, 0x8058b040, 0x040207f4,
6615 0x4c000000, 0x41f00000, 0x82000500, 0xf7ffffff,
6616 0x4003e000, 0x5c000000, 0x5c00b000, 0x1c01f000,
6617 0x4c000000, 0x41f00000, 0x82000540, 0x08000000,
6618 0x0401f7f8, 0x4a0378e8, 0x00000000, 0x4a03c821,
6619 0x00000010, 0x4a03c823, 0x00000004, 0x0401f82c,
6620 0x4a0378e9, 0x00003a0d, 0x4a0378e8, 0x00000001,
6621 0x42000000, 0x00001000, 0x50000000, 0x82000480,
6622 0x24220001, 0x04000004, 0x59e00002, 0x84000548,
6623 0x4803c002, 0x42000800, 0x00000005, 0x4203a000,
6624 0x00007600, 0x42000000, 0x00001000, 0x50000000,
6625 0x82000480, 0x24320001, 0x04021003, 0x4a03a005,
6626 0xd0000001, 0x59d00006, 0x4a03a005, 0x90000001,
6627 0x83d3a400, 0x00000020, 0x80040840, 0x040207fa,
6628 0x59e00003, 0x82000500, 0xffffffe0, 0x82000540,
6629 0x00008000, 0x4803c003, 0x59c40006, 0x82000500,
6630 0xfffcffff, 0x48038806, 0x1c01f000, 0x4d900000,
6631 0x4d180000, 0x4a0378e7, 0xaaaaaaaa, 0x4a0378e6,
6632 0xaaaaaaaa, 0x4a0378e5, 0xaaaaaaaa, 0x4a0378e4,
6633 0xaaaaaaaa, 0x42000800, 0x0000bf00, 0x4a00081a,
6634 0x0010b7d4, 0x4a00081b, 0x001010bd, 0x4a00081c,
6635 0x001010cd, 0x4a031800, 0x00000000, 0x4a031801,
6636 0x0010b544, 0x4a031802, 0x0010b54b, 0x42000800,
6637 0x0010b7d7, 0x417a3000, 0x811b20c8, 0x83932400,
6638 0x0000bf32, 0x48072000, 0x4a032001, 0x00000000,
6639 0x83180400, 0x001070ea, 0x50000000, 0x48032002,
6640 0x82040c00, 0x00000003, 0x811a3000, 0x83180480,
6641 0x00000005, 0x040017f1, 0x5c023000, 0x5c032000,
6642 0x1c01f000, 0x48066004, 0x497a6000, 0x497a6001,
6643 0x59bc00ea, 0x8c000516, 0x040207fe, 0x83300400,
6644 0xa0000000, 0x480378e1, 0x1c01f000, 0x4933c857,
6645 0x42000800, 0x80000040, 0x48066004, 0x497a6000,
6646 0x59bc00ea, 0x8c000516, 0x040207fe, 0x83300400,
6647 0x60000000, 0x480378e1, 0x1c01f000, 0x0201f800,
6648 0x00106c55, 0x4df00000, 0x4d300000, 0x4d340000,
6649 0x4d2c0000, 0x4d180000, 0x4c5c0000, 0x4c600000,
6650 0x4d900000, 0x4dd00000, 0x4da40000, 0x4d140000,
6651 0x42003000, 0x0000bf2e, 0x581a6001, 0x813261c0,
6652 0x0400002c, 0x41302800, 0x4178c000, 0x59300000,
6653 0x4c000000, 0x59326809, 0x5930b801, 0x59300406,
6654 0x82000d80, 0x00000006, 0x04020003, 0x8d3e7d18,
6655 0x04000010, 0x8d3e7d06, 0x04000007, 0x82000580,
6656 0x00000003, 0x04020004, 0x59340200, 0x8c00050e,
6657 0x04020008, 0x0401f92f, 0x4c0c0000, 0x4c140000,
6658 0x0401fb5f, 0x5c002800, 0x5c001800, 0x0401f005,
6659 0x41301800, 0x8060c1c0, 0x04020002, 0x400cc000,
6660 0x805cb9c0, 0x04000003, 0x405e6000, 0x0401f7e3,
6661 0x5c026000, 0x813261c0, 0x04000006, 0x8060c1c0,
6662 0x04000002, 0x40602800, 0x4178c000, 0x0401f7d8,
6663 0x417a3000, 0x0201f800, 0x001070d8, 0x59926004,
6664 0x813261c0, 0x04000023, 0x59326809, 0x4130c000,
6665 0x59300001, 0x8000bd40, 0x04000016, 0x40026000,
6666 0x40602800, 0x5930b801, 0x59300406, 0x82000d80,
6667 0x00000006, 0x0400000e, 0x8d3e7d06, 0x04000007,
6668 0x82000580, 0x00000003, 0x04020004, 0x59340200,
6669 0x8c00050e, 0x04020006, 0x0401f8dc, 0x4c140000,
6670 0x0401fb2f, 0x5c002800, 0x0401f002, 0x41302800,
6671 0x405e6000, 0x813261c0, 0x040207eb, 0x8060c1c0,
6672 0x04000004, 0x40626000, 0x4178c000, 0x0401f7e7,
6673 0x811a3000, 0x83180480, 0x00000005, 0x040017d6,
6674 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000,
6675 0x5c00c000, 0x5c00b800, 0x5c023000, 0x5c025800,
6676 0x5c026800, 0x5c026000, 0x5c03e000, 0x02000800,
6677 0x00106c4b, 0x1c01f000, 0x4933c857, 0x0201f800,
6678 0x00106c55, 0x4df00000, 0x4d340000, 0x4d180000,
6679 0x4d900000, 0x42003000, 0x0000bf2e, 0x59326809,
6680 0x58182001, 0x40102800, 0x801021c0, 0x04000016,
6681 0x41300000, 0x80100580, 0x04000011, 0x58100009,
6682 0x81340580, 0x0402000b, 0x40101800, 0x58102001,
6683 0x41300000, 0x801021c0, 0x0400000b, 0x80100d80,
6684 0x04000007, 0x40101800, 0x58102001, 0x0401f7fa,
6685 0x40102800, 0x58102000, 0x0401f7ec, 0x0401f8bd,
6686 0x0401f01a, 0x42032000, 0x0000bf32, 0x417a3000,
6687 0x59902004, 0x40102800, 0x801021c0, 0x0400000b,
6688 0x58100009, 0x81340580, 0x04020008, 0x41300000,
6689 0x80100580, 0x0400000c, 0x40102800, 0x58102001,
6690 0x801021c0, 0x040207fa, 0x811a3000, 0x83180480,
6691 0x00000005, 0x0402100d, 0x83932400, 0x00000010,
6692 0x0401f7ec, 0x0401f881, 0x5c032000, 0x5c023000,
6693 0x5c026800, 0x5c03e000, 0x02000800, 0x00106c4b,
6694 0x80000580, 0x1c01f000, 0x0401fb6f, 0x040007f7,
6695 0x5c032000, 0x5c023000, 0x5c026800, 0x5c03e000,
6696 0x02000800, 0x00106c4b, 0x82000540, 0x00000001,
6697 0x1c01f000, 0x0201f800, 0x00106c55, 0x4df00000,
6698 0x4d300000, 0x4d340000, 0x4d180000, 0x4d2c0000,
6699 0x4c5c0000, 0x4c600000, 0x4d900000, 0x4dd00000,
6700 0x4da40000, 0x4d140000, 0x42003000, 0x0000bf2e,
6701 0x581a6001, 0x813261c0, 0x04000023, 0x41302800,
6702 0x5930b800, 0x59326809, 0x59340403, 0x81440580,
6703 0x04000006, 0x805cb9c0, 0x0400001b, 0x41302800,
6704 0x405e6000, 0x0401f7f7, 0x5930b801, 0x8d3e7d00,
6705 0x04000003, 0x0401fb67, 0x0402000e, 0x59300406,
6706 0x82000580, 0x00000006, 0x04020003, 0x8d3e7d18,
6707 0x04000008, 0x0401f867, 0x4c0c0000, 0x4c140000,
6708 0x0401fa97, 0x5c002800, 0x5c001800, 0x0401f002,
6709 0x41301800, 0x405e6000, 0x813261c0, 0x040207eb,
6710 0x0401f02d, 0x417a3000, 0x0201f800, 0x001070d8,
6711 0x59926004, 0x813261c0, 0x04000005, 0x59326809,
6712 0x59340403, 0x81440580, 0x04000006, 0x811a3000,
6713 0x83180480, 0x00000005, 0x040017f4, 0x0401f01e,
6714 0x4130c000, 0x59300001, 0x8000bd40, 0x04000012,
6715 0x40026000, 0x40602800, 0x5930b801, 0x8d3e7d00,
6716 0x04000003, 0x0401fb3b, 0x0402000a, 0x59300406,
6717 0x82000580, 0x00000006, 0x04000006, 0x0401f81b,
6718 0x4c140000, 0x0401fa6e, 0x5c002800, 0x0401f002,
6719 0x41302800, 0x405e6000, 0x813261c0, 0x040207ef,
6720 0x8060c1c0, 0x04000004, 0x40626000, 0x4178c000,
6721 0x0401f7eb, 0x5c022800, 0x5c034800, 0x5c03a000,
6722 0x5c032000, 0x5c00c000, 0x5c00b800, 0x5c025800,
6723 0x5c023000, 0x5c026800, 0x5c026000, 0x5c03e000,
6724 0x04000be3, 0x1c01f000, 0x0401fbc8, 0x59900004,
6725 0x81300580, 0x04020018, 0x4c140000, 0x0201f800,
6726 0x00106dc3, 0x0401fbb8, 0x5c002800, 0x59300001,
6727 0x800001c0, 0x04020003, 0x497a680c, 0x1c01f000,
6728 0x42003000, 0x0000bf2e, 0x497a6001, 0x58180801,
6729 0x800409c0, 0x04020004, 0x48003000, 0x48003001,
6730 0x1c01f000, 0x58180800, 0x48000800, 0x48003000,
6731 0x1c01f000, 0x59300001, 0x48002801, 0x800001c0,
6732 0x04020002, 0x4816680c, 0x497a6001, 0x1c01f000,
6733 0x0401fba6, 0x42003000, 0x0000bf2e, 0x58180001,
6734 0x81300580, 0x0402001c, 0x59300801, 0x800409c0,
6735 0x0400000e, 0x59300000, 0x800001c0, 0x04020005,
6736 0x48043001, 0x48043000, 0x497a6001, 0x1c01f000,
6737 0x59300000, 0x48000800, 0x48043001, 0x497a6000,
6738 0x497a6001, 0x1c01f000, 0x59300800, 0x800409c0,
6739 0x04020005, 0x49783001, 0x49783000, 0x497a680c,
6740 0x1c01f000, 0x48043001, 0x497a6000, 0x497a680c,
6741 0x1c01f000, 0x58180000, 0x81300580, 0x0402000c,
6742 0x59300001, 0x800001c0, 0x04020005, 0x48143000,
6743 0x49782800, 0x497a680c, 0x1c01f000, 0x48003000,
6744 0x48002800, 0x497a6001, 0x1c01f000, 0x59300000,
6745 0x800001c0, 0x04020008, 0x59300001, 0x48001801,
6746 0x800001c0, 0x04020002, 0x480e680c, 0x497a6001,
6747 0x1c01f000, 0x59300801, 0x800409c0, 0x04020006,
6748 0x59300800, 0x48042800, 0x497a6000, 0x497a680c,
6749 0x1c01f000, 0x59300000, 0x48000800, 0x48042800,
6750 0x497a6000, 0x497a6001, 0x1c01f000, 0x0401fb82,
6751 0x4df00000, 0x0401f839, 0x040208c4, 0x04020945,
6752 0x04020a89, 0x04020005, 0x5c03e000, 0x04000b70,
6753 0x80000580, 0x1c01f000, 0x5c03e000, 0x04000b6c,
6754 0x82000540, 0x00000001, 0x1c01f000, 0x4d2c0000,
6755 0x4d340000, 0x4d300000, 0x41783000, 0x598e6009,
6756 0x813261c0, 0x04000021, 0x59300406, 0x82000580,
6757 0x00000006, 0x04020004, 0x8d3e7d18, 0x0402000a,
6758 0x0401f017, 0x82040580, 0x00000005, 0x04020006,
6759 0x8d3e7d16, 0x04000004, 0x59300420, 0x8c000500,
6760 0x0402000f, 0x0401fa4e, 0x59300000, 0x4c000000,
6761 0x8d3e7d06, 0x04000004, 0x0201f800, 0x001092d7,
6762 0x04000005, 0x0401f867, 0x4c180000, 0x0401f9bc,
6763 0x5c003000, 0x5c026000, 0x0401f7e2, 0x41303000,
6764 0x59326000, 0x0401f7df, 0x5c026000, 0x5c026800,
6765 0x5c025800, 0x1c01f000, 0x4933c857, 0x4c5c0000,
6766 0x813261c0, 0x02000800, 0x001005d8, 0x41300000,
6767 0x598cb809, 0x41783000, 0x805cb9c0, 0x04000013,
6768 0x805c0d80, 0x04000004, 0x405c3000, 0x5818b800,
6769 0x0401f7fa, 0x0401f84b, 0x598c000d, 0x81300580,
6770 0x02000800, 0x001070b9, 0x59300403, 0x82000580,
6771 0x00000042, 0x04020002, 0x497a6007, 0x80000580,
6772 0x5c00b800, 0x1c01f000, 0x82000540, 0x00000001,
6773 0x5c00b800, 0x1c01f000, 0x0401fb27, 0x4df00000,
6774 0x4d2c0000, 0x4d340000, 0x4d300000, 0x41783000,
6775 0x598e6009, 0x813261c0, 0x0400002c, 0x59300c06,
6776 0x82040580, 0x00000006, 0x04020004, 0x8d3e7d18,
6777 0x0402000a, 0x0401f022, 0x82040580, 0x00000005,
6778 0x04020006, 0x8d3e7d18, 0x04000004, 0x59300420,
6779 0x8c000500, 0x0402001a, 0x59326809, 0x59340403,
6780 0x81440580, 0x04020016, 0x8d3e7d00, 0x04000006,
6781 0x82040580, 0x00000003, 0x04020011, 0x0401fa35,
6782 0x0402000f, 0x0401f9f6, 0x59300000, 0x4c000000,
6783 0x8d3e7d06, 0x04000004, 0x0201f800, 0x001092d7,
6784 0x04000005, 0x0401f80f, 0x4c180000, 0x0401f964,
6785 0x5c003000, 0x5c026000, 0x0401f7d7, 0x41303000,
6786 0x59326000, 0x0401f7d4, 0x5c026000, 0x5c026800,
6787 0x5c025800, 0x5c03e000, 0x04000ae5, 0x1c01f000,
6788 0x59300800, 0x497a6000, 0x0401fac8, 0x801831c0,
6789 0x04020009, 0x598c0008, 0x81300580, 0x04020004,
6790 0x48031808, 0x48031809, 0x0401f008, 0x48071809,
6791 0x0401f006, 0x48043000, 0x598c0008, 0x81300580,
6792 0x04020002, 0x481b1808, 0x0401f2ca, 0x4d2c0000,
6793 0x4d300000, 0x4d340000, 0x41783000, 0x598e600b,
6794 0x813261c0, 0x04000013, 0x8d3e7d06, 0x04000005,
6795 0x59326809, 0x59340200, 0x8c00050e, 0x0402000a,
6796 0x0401f9bf, 0x59300000, 0x4c000000, 0x0401f853,
6797 0x4c180000, 0x0401f932, 0x5c003000, 0x5c026000,
6798 0x0401f7f0, 0x41303000, 0x59326000, 0x0401f7ed,
6799 0x0201f800, 0x00104773, 0x5c026800, 0x5c026000,
6800 0x5c025800, 0x1c01f000, 0x4933c857, 0x4c5c0000,
6801 0x813261c0, 0x02000800, 0x001005d8, 0x41300000,
6802 0x598cb80b, 0x41783000, 0x805cb9c0, 0x0400000f,
6803 0x805c0d80, 0x04000004, 0x405c3000, 0x5818b800,
6804 0x0401f7fa, 0x0401f835, 0x598c000d, 0x81300580,
6805 0x02000800, 0x001070b9, 0x497a6007, 0x80000580,
6806 0x5c00b800, 0x1c01f000, 0x82000540, 0x00000001,
6807 0x5c00b800, 0x1c01f000, 0x0401fa9f, 0x4df00000,
6808 0x4d340000, 0x4d300000, 0x4d2c0000, 0x0201f800,
6809 0x00020245, 0x02020800, 0x001005d8, 0x41783000,
6810 0x598e600b, 0x813261c0, 0x04000014, 0x59300009,
6811 0x81340580, 0x0402000e, 0x8d3e7d00, 0x04000003,
6812 0x0401f9bc, 0x0402000a, 0x0401f97d, 0x59300000,
6813 0x4c000000, 0x0401f811, 0x4c180000, 0x0401f8f0,
6814 0x5c003000, 0x5c026000, 0x0401f7ef, 0x41303000,
6815 0x59326000, 0x0401f7ec, 0x0201f800, 0x0010479c,
6816 0x5c025800, 0x5c026000, 0x5c026800, 0x5c03e000,
6817 0x04000a6f, 0x1c01f000, 0x59300800, 0x497a6000,
6818 0x0401fa52, 0x801831c0, 0x04020009, 0x598c000a,
6819 0x81300580, 0x04020004, 0x4803180a, 0x4803180b,
6820 0x0401f008, 0x4807180b, 0x0401f006, 0x48043000,
6821 0x598c000a, 0x81300580, 0x04020002, 0x481b180a,
6822 0x0401f254, 0x0401fa64, 0x4df00000, 0x4d300000,
6823 0x598e6005, 0x813261c0, 0x04000020, 0x59300000,
6824 0x4c000000, 0x59300c06, 0x82040580, 0x00000011,
6825 0x04020007, 0x833c0500, 0x00001800, 0x04000015,
6826 0x8d3e7d16, 0x04020013, 0x0401f009, 0x82040580,
6827 0x00000004, 0x04020006, 0x8d3e7d16, 0x04000004,
6828 0x59300420, 0x8c000500, 0x0402000a, 0x0201f800,
6829 0x0010914e, 0x02000800, 0x0010801c, 0x0201f800,
6830 0x00109326, 0x0201f800, 0x0002077d, 0x0401fa31,
6831 0x5c026000, 0x0401f7e0, 0x497b1805, 0x497b1804,
6832 0x5c026000, 0x5c03e000, 0x04000a31, 0x1c01f000,
6833 0x4933c857, 0x4c5c0000, 0x4c600000, 0x813261c0,
6834 0x02000800, 0x001005d8, 0x41300000, 0x598cb805,
6835 0x405cc000, 0x805cb9c0, 0x04000025, 0x805c0d80,
6836 0x04000004, 0x405cc000, 0x5860b800, 0x0401f7fa,
6837 0x598c000d, 0x81300580, 0x02000800, 0x001070b9,
6838 0x0401fa02, 0x598c0005, 0x805c0580, 0x04020009,
6839 0x585c0000, 0x48031805, 0x4978b800, 0x598c0004,
6840 0x805c0580, 0x0402000d, 0x497b1804, 0x0401f00b,
6841 0x598c0004, 0x805c0580, 0x04020005, 0x48631804,
6842 0x4978b800, 0x4978c000, 0x0401f004, 0x585c0000,
6843 0x4800c000, 0x4978b800, 0x0401f9fe, 0x80000580,
6844 0x5c00c000, 0x5c00b800, 0x1c01f000, 0x82000540,
6845 0x00000001, 0x5c00c000, 0x5c00b800, 0x1c01f000,
6846 0x4933c857, 0x0401fa04, 0x4df00000, 0x4d2c0000,
6847 0x4d340000, 0x4d300000, 0x4c5c0000, 0x4178b800,
6848 0x8d3e7d18, 0x0400000d, 0x8d3e7d16, 0x0402000b,
6849 0x0201f800, 0x00109037, 0x04000008, 0x0201f800,
6850 0x00109597, 0x04020005, 0x592c0207, 0x492fc857,
6851 0x8200bd00, 0x0000000f, 0x41783000, 0x598e6005,
6852 0x813261c0, 0x04000029, 0x59326809, 0x813669c0,
6853 0x04000023, 0x59340403, 0x81440580, 0x04020020,
6854 0x59300c06, 0x82040580, 0x00000011, 0x0400001a,
6855 0x82040580, 0x00000004, 0x04020004, 0x59300420,
6856 0x8c000500, 0x04020016, 0x0201f800, 0x00109037,
6857 0x04000008, 0x0201f800, 0x00109597, 0x04020005,
6858 0x59300403, 0x82000580, 0x00000043, 0x0400000c,
6859 0x0401f8c3, 0x59300000, 0x4c000000, 0x0401f812,
6860 0x4c180000, 0x0401f836, 0x5c003000, 0x5c026000,
6861 0x0401f7dc, 0x805cb9c0, 0x040207ec, 0x41303000,
6862 0x59326000, 0x0401f7d7, 0x5c00b800, 0x5c026000,
6863 0x5c026800, 0x5c025800, 0x5c03e000, 0x040009b4,
6864 0x1c01f000, 0x59300800, 0x497a6000, 0x0401f997,
6865 0x801831c0, 0x04020009, 0x598c0004, 0x81300580,
6866 0x04020004, 0x48031804, 0x48031805, 0x0401f008,
6867 0x48071805, 0x0401f006, 0x48043000, 0x598c0004,
6868 0x81300580, 0x04020002, 0x481b1804, 0x0401f199,
6869 0x4943c857, 0x0401f9a8, 0x4df00000, 0x0401fe34,
6870 0x0401fecb, 0x5c03e000, 0x04000999, 0x1c01f000,
6871 0x4947c857, 0x0401f9a0, 0x4df00000, 0x4d3c0000,
6872 0x853e7d00, 0x0401fe75, 0x0401fefc, 0x5c027800,
6873 0x5c03e000, 0x0400098e, 0x1c01f000, 0x5c000000,
6874 0x4c000000, 0x4803c857, 0x4d340000, 0x4d2c0000,
6875 0x59326809, 0x59325808, 0x59300406, 0x82000c80,
6876 0x00000012, 0x02021800, 0x001005d8, 0x4933c857,
6877 0x4943c857, 0x493fc857, 0x4803c857, 0x0c01f804,
6878 0x5c025800, 0x5c026800, 0x1c01f000, 0x00106ae5,
6879 0x00106ae7, 0x00106af1, 0x00106b0b, 0x00106ae7,
6880 0x00106afb, 0x00106b23, 0x00106ae5, 0x00106ae5,
6881 0x00106b36, 0x00106b2d, 0x00106ae5, 0x00106ae5,
6882 0x00106ae5, 0x00106ae5, 0x00106ae5, 0x00106b3c,
6883 0x00106b3c, 0x0201f800, 0x001005d8, 0x0201f800,
6884 0x00109134, 0x02000800, 0x00102074, 0x0201f800,
6885 0x00109326, 0x0201f800, 0x0010801c, 0x0201f000,
6886 0x00107911, 0x812e59c0, 0x02020800, 0x001005d8,
6887 0x5930021d, 0x82000580, 0x00000003, 0x02000800,
6888 0x0010912a, 0x0201f000, 0x00107911, 0x0201f800,
6889 0x00109037, 0x02000000, 0x00107911, 0x592c1204,
6890 0x82081500, 0x000000ff, 0x82080580, 0x00000055,
6891 0x02020800, 0x001005d8, 0x49425a06, 0x0201f800,
6892 0x000202da, 0x0201f000, 0x00107911, 0x59300004,
6893 0x8400055c, 0x48026004, 0x59300007, 0x8c000500,
6894 0x02020800, 0x00100e99, 0x0201f800, 0x00109037,
6895 0x0400000d, 0x4a025a04, 0x00000103, 0x49425a06,
6896 0x497a5c09, 0x0201f800, 0x001091c6, 0x0201f800,
6897 0x0010a693, 0x0201f800, 0x000202da, 0x0201f800,
6898 0x0010912a, 0x0201f000, 0x00107911, 0x59300007,
6899 0x8c000500, 0x02020800, 0x00100e99, 0x0201f800,
6900 0x00109037, 0x02020800, 0x0010a3ef, 0x0201f000,
6901 0x00107911, 0x0201f800, 0x00109037, 0x04000005,
6902 0x49425a06, 0x497a5c09, 0x0201f800, 0x000202da,
6903 0x0201f000, 0x00107911, 0x0201f800, 0x00109037,
6904 0x02020800, 0x0010664f, 0x0201f000, 0x00107911,
6905 0x0201f800, 0x00109037, 0x04000004, 0x49425a06,
6906 0x0201f800, 0x000202da, 0x59325817, 0x0201f800,
6907 0x001007fd, 0x0201f000, 0x00107911, 0x598c000d,
6908 0x81300580, 0x04000003, 0x497a6007, 0x1c01f000,
6909 0x59c40004, 0x82000500, 0x0000000c, 0x04000005,
6910 0x4a038804, 0x0000000c, 0x497b2807, 0x0401f00a,
6911 0x0401facd, 0x59300403, 0x82000d80, 0x00000040,
6912 0x04000004, 0x82000580, 0x00000042, 0x04020002,
6913 0x497a6007, 0x0201f800, 0x001070b9, 0x80000580,
6914 0x1c01f000, 0x59300804, 0x8c040d3e, 0x04020004,
6915 0x82000540, 0x00000001, 0x0401f005, 0x4933c857,
6916 0x84040d3e, 0x48066004, 0x80000580, 0x1c01f000,
6917 0x59300804, 0x8c040d20, 0x04020004, 0x82000540,
6918 0x00000001, 0x1c01f000, 0x4933c857, 0x4d380000,
6919 0x59300804, 0x84040d20, 0x48066004, 0x42027000,
6920 0x00000049, 0x59300203, 0x82000580, 0x00000003,
6921 0x04000003, 0x42027000, 0x00000013, 0x0201f800,
6922 0x000207a1, 0x80000580, 0x5c027000, 0x1c01f000,
6923 0x59300017, 0x81480580, 0x04020003, 0x59300018,
6924 0x814c0580, 0x1c01f000, 0x4d2c0000, 0x4d300000,
6925 0x0401f8c9, 0x4df00000, 0x0201f800, 0x00106062,
6926 0x59900001, 0x82000500, 0x00000003, 0x0c01f001,
6927 0x00106bba, 0x00106b9a, 0x00106b98, 0x00106b98,
6928 0x0201f800, 0x001005d8, 0x59926004, 0x0401f88e,
6929 0x813261c0, 0x0400001d, 0x59300004, 0x8c000516,
6930 0x04000004, 0x59325808, 0x497a5808, 0x497a5809,
6931 0x0401f88e, 0x59300001, 0x800001c0, 0x0400000e,
6932 0x497a6001, 0x42003000, 0x0000bf2e, 0x58180801,
6933 0x800409c0, 0x04020004, 0x48003001, 0x48003000,
6934 0x0401f00a, 0x58180800, 0x48000800, 0x48003000,
6935 0x0401f006, 0x59300809, 0x800409c0, 0x02000800,
6936 0x001005d8, 0x4978080c, 0x5c03e000, 0x04000890,
6937 0x5c026000, 0x5c025800, 0x1c01f000, 0x4d300000,
6938 0x497b2807, 0x0401f894, 0x4df00000, 0x598c0000,
6939 0x82000500, 0x00000007, 0x4803c857, 0x0c01f001,
6940 0x00106bef, 0x00106bd2, 0x00106bdb, 0x00106bdf,
6941 0x00106bea, 0x00106bef, 0x00106bd0, 0x00106bd0,
6942 0x0201f800, 0x001005d8, 0x598c000d, 0x80026540,
6943 0x04000004, 0x0401f81e, 0x02020800, 0x001005d8,
6944 0x0201f800, 0x001070b9, 0x0401f015, 0x0401f827,
6945 0x0201f800, 0x001070b9, 0x0401f011, 0x598c000d,
6946 0x80026540, 0x0400000e, 0x0401f838, 0x04000004,
6947 0x0401f80f, 0x04000002, 0x0401f81c, 0x0201f800,
6948 0x001070b9, 0x0401f006, 0x0401f830, 0x02020800,
6949 0x001005d8, 0x0201f800, 0x001070b9, 0x5c03e000,
6950 0x0400085b, 0x5c026000, 0x1c01f000, 0x598c0009,
6951 0x81300580, 0x0402000c, 0x0401f84e, 0x0401f83b,
6952 0x59300000, 0x800001c0, 0x04000004, 0x48031809,
6953 0x497a6000, 0x0401f003, 0x497b1809, 0x497b1808,
6954 0x80000580, 0x1c01f000, 0x4d2c0000, 0x59300406,
6955 0x82000580, 0x00000003, 0x04020012, 0x598c000b,
6956 0x81300580, 0x0402000f, 0x0401f83a, 0x59325808,
6957 0x497a5808, 0x497a5809, 0x0401f824, 0x59300000,
6958 0x800001c0, 0x04000004, 0x4803180b, 0x497a6000,
6959 0x0401f003, 0x497b180a, 0x497b180b, 0x80000580,
6960 0x5c025800, 0x1c01f000, 0x598c0005, 0x81300580,
6961 0x0402000c, 0x0401f827, 0x0401f814, 0x59300000,
6962 0x800001c0, 0x04000004, 0x48031805, 0x497a6000,
6963 0x0401f003, 0x497b1805, 0x497b1804, 0x80000580,
6964 0x1c01f000, 0x4a032001, 0x00000000, 0x497b2004,
6965 0x497b2005, 0x59900006, 0x82000500, 0x0000ffff,
6966 0x48032006, 0x1c01f000, 0x4c040000, 0x59300004,
6967 0x82000500, 0x7ffeffff, 0x48026004, 0x59bc00e4,
6968 0x8c000514, 0x04000009, 0x42000800, 0x0000bf00,
6969 0x58040012, 0x81300580, 0x04020004, 0x49780812,
6970 0x4a0378e4, 0x00000800, 0x5c000800, 0x1c01f000,
6971 0x4803c856, 0x598c000c, 0x80000540, 0x04000003,
6972 0x80000040, 0x4803180c, 0x1c01f000, 0x59bc00ea,
6973 0x82000500, 0x00000007, 0x82000580, 0x00000003,
6974 0x04020004, 0x4803c856, 0x4a0378e8, 0x00000001,
6975 0x1c01f000, 0x59bc00ea, 0x82000500, 0x00000007,
6976 0x82000580, 0x00000001, 0x04020011, 0x4803c856,
6977 0x42000800, 0x00000000, 0x0401f80e, 0x42000800,
6978 0x00001000, 0x59bc00ea, 0x82000500, 0x00000007,
6979 0x82000580, 0x00000003, 0x04000005, 0x80040840,
6980 0x040207f9, 0x0201f800, 0x001005d8, 0x1c01f000,
6981 0x59bc00ea, 0x82000500, 0x00000007, 0x82000580,
6982 0x00000001, 0x02020800, 0x001005d8, 0x59bc00ea,
6983 0x8c000516, 0x040207fe, 0x480778e1, 0x1c01f000,
6984 0x59bc00ea, 0x8c000516, 0x040207fe, 0x480778e1,
6985 0x59bc00ea, 0x8c000516, 0x040207fe, 0x480b78e1,
6986 0x1c01f000, 0x82000d00, 0x80000018, 0x02020800,
6987 0x001005d0, 0x0201f800, 0x001005d8, 0x00106c97,
6988 0x00106d3b, 0x00106d55, 0x00106c97, 0x00106c99,
6989 0x00106cba, 0x00106cd9, 0x00106d0d, 0x00106c97,
6990 0x00106d39, 0x00106c97, 0x00106c97, 0x00106c97,
6991 0x00106c97, 0x00106c97, 0x00106c97, 0x0201f800,
6992 0x001005d8, 0x4d300000, 0x4d900000, 0x4dd00000,
6993 0x4da40000, 0x4d140000, 0x0201f800, 0x001070d8,
6994 0x59bc00ea, 0x8c000510, 0x040007fe, 0x59be60e0,
6995 0x59300004, 0x8c000520, 0x04000011, 0x82000500,
6996 0xfffefeff, 0x48026004, 0x4a026203, 0x00000003,
6997 0x0401ffa9, 0x0201f800, 0x00100fd0, 0x5c022800,
6998 0x5c034800, 0x5c03a000, 0x5c032000, 0x5c026000,
6999 0x4a0378e4, 0x00000008, 0x0401f795, 0x84000510,
7000 0x48026004, 0x0401f7f6, 0x4d300000, 0x4d900000,
7001 0x4dd00000, 0x4da40000, 0x4d140000, 0x0201f800,
7002 0x001070d8, 0x59bc00ea, 0x8c000510, 0x040007fe,
7003 0x59be60e0, 0x59300004, 0x8c000520, 0x0400000f,
7004 0x82000500, 0xfffefeff, 0x48026004, 0x0401ff8a,
7005 0x0201f800, 0x0010100e, 0x5c022800, 0x5c034800,
7006 0x5c03a000, 0x5c032000, 0x5c026000, 0x4a0378e4,
7007 0x00000008, 0x0401f776, 0x84000510, 0x48026004,
7008 0x0401f7f6, 0x4d300000, 0x4d2c0000, 0x4d340000,
7009 0x4da40000, 0x4cd00000, 0x59bc00ea, 0x8c000510,
7010 0x040007fe, 0x59be60e0, 0x813261c0, 0x02000800,
7011 0x001005d8, 0x59300004, 0x8c000520, 0x0400001d,
7012 0x82000500, 0xfffefeff, 0x48026004, 0x59326809,
7013 0x42034800, 0x0010b544, 0x04011000, 0x4a03c840,
7014 0x0010b54b, 0x4a03c842, 0x00000012, 0x04011000,
7015 0x4a03c840, 0x0010b55d, 0x4a03c842, 0x000000ff,
7016 0x04011000, 0x4a03c840, 0x0010b65c, 0x4a03c842,
7017 0x000000ff, 0x0401fbf2, 0x5c01a000, 0x5c034800,
7018 0x5c026800, 0x5c025800, 0x5c026000, 0x1c01f000,
7019 0x84000510, 0x48026004, 0x5c01a000, 0x5c034800,
7020 0x5c026800, 0x5c025800, 0x5c026000, 0x1c01f000,
7021 0x1c01f000, 0x4d300000, 0x4d2c0000, 0x4d340000,
7022 0x4cd00000, 0x4d900000, 0x4dd00000, 0x4da40000,
7023 0x4d140000, 0x0401fbc3, 0x59bc00ea, 0x8c000510,
7024 0x040007fe, 0x59be60e0, 0x813261c0, 0x02000800,
7025 0x001005d8, 0x59300004, 0x8c000520, 0x0400000f,
7026 0x82000500, 0xfffefeff, 0x48026004, 0x0201f800,
7027 0x0010783a, 0x5c022800, 0x5c034800, 0x5c03a000,
7028 0x5c032000, 0x5c01a000, 0x5c026800, 0x5c025800,
7029 0x5c026000, 0x1c01f000, 0x84000510, 0x48026004,
7030 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000,
7031 0x5c01a000, 0x5c026800, 0x5c025800, 0x5c026000,
7032 0x1c01f000, 0x0201f800, 0x001005d8, 0x4d300000,
7033 0x4d380000, 0x42000000, 0x0010b8c4, 0x0201f800,
7034 0x0010aa47, 0x0401ff14, 0x598e600d, 0x59c40004,
7035 0x8c000506, 0x04000004, 0x0401f8db, 0x4a038804,
7036 0x00000008, 0x813261c0, 0x04000006, 0x0401fb87,
7037 0x42027000, 0x00000014, 0x0201f800, 0x000207a1,
7038 0x4a0378e4, 0x00000002, 0x5c027000, 0x5c026000,
7039 0x0401f6f7, 0x4d180000, 0x4d300000, 0x4d380000,
7040 0x4d900000, 0x4dd00000, 0x4da40000, 0x4d140000,
7041 0x0401fef9, 0x417a3000, 0x59c40804, 0x83180400,
7042 0x0010709f, 0x50000000, 0x80040500, 0x0400001b,
7043 0x42000000, 0x0010b8c5, 0x0201f800, 0x0010aa47,
7044 0x0401fb70, 0x59926004, 0x0401f859, 0x83180400,
7045 0x0010709f, 0x50000000, 0x48038804, 0x813261c0,
7046 0x0400000a, 0x59300004, 0x8c00050c, 0x04020003,
7047 0x4a026203, 0x00000003, 0x42027000, 0x0000004a,
7048 0x0201f800, 0x000207a1, 0x59c40004, 0x82000500,
7049 0x00f80000, 0x04000005, 0x811a3000, 0x83180480,
7050 0x00000005, 0x040017dd, 0x4a0378e4, 0x00000008,
7051 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000,
7052 0x5c027000, 0x5c026000, 0x5c023000, 0x0401f6c0,
7053 0x4d2c0000, 0x4d340000, 0x59326809, 0x598c0800,
7054 0x82040580, 0x00000004, 0x04020004, 0x838c1400,
7055 0x00000005, 0x0401f00c, 0x82040580, 0x00000001,
7056 0x04020004, 0x838c1400, 0x00000009, 0x0401f006,
7057 0x82040580, 0x00000002, 0x04020022, 0x838c1400,
7058 0x0000000b, 0x41306800, 0x58340000, 0x80007d40,
7059 0x0400001c, 0x583c0009, 0x81340580, 0x04020006,
7060 0x403c6800, 0x583c0000, 0x80007d40, 0x040207fa,
7061 0x0401f014, 0x4933c857, 0x483fc857, 0x583c0000,
7062 0x48006800, 0x49307800, 0x443c1000, 0x80000580,
7063 0x4803180d, 0x4803180f, 0x598c0000, 0x82000580,
7064 0x00000003, 0x04000003, 0x4a031800, 0x00000000,
7065 0x80000580, 0x5c026800, 0x5c025800, 0x1c01f000,
7066 0x82000540, 0x00000001, 0x0401f7fb, 0x491bc857,
7067 0x59c80840, 0x82040540, 0x00000010, 0x48039040,
7068 0x59c41008, 0x82080500, 0xffffff7f, 0x48038808,
7069 0x4c040000, 0x4c080000, 0x0401fabb, 0x04020007,
7070 0x0401fabf, 0x04000022, 0x48038804, 0x0201f800,
7071 0x0010107a, 0x0401f042, 0x4a038803, 0x00000008,
7072 0x59c40003, 0x82000500, 0x00000003, 0x040007fd,
7073 0x8c000502, 0x04020007, 0x0401fab1, 0x04000014,
7074 0x48038804, 0x0201f800, 0x0010107a, 0x0401f034,
7075 0x59c80040, 0x8400056a, 0x48039040, 0x59c80040,
7076 0x8c00052a, 0x040207fe, 0x59c40005, 0x82000500,
7077 0xc0000000, 0x04000006, 0x59c400a3, 0x84000540,
7078 0x480388a3, 0x4a038805, 0xc0000000, 0x0201f800,
7079 0x0010101d, 0x4a03a005, 0x30000000, 0x59d00006,
7080 0x4a03a005, 0x30000000, 0x59900006, 0x82000500,
7081 0xffff0000, 0x48032006, 0x59d00005, 0x8c000504,
7082 0x040207fe, 0x42000800, 0x00007600, 0x83180540,
7083 0x60000000, 0x480008a1, 0x811800dc, 0x59c80840,
7084 0x80040540, 0x48039040, 0x82000540, 0x00003000,
7085 0x48039040, 0x59c80040, 0x82000500, 0x00003000,
7086 0x040207fd, 0x0201f800, 0x00101068, 0x83180400,
7087 0x0010709f, 0x50000000, 0x48038804, 0x80000580,
7088 0x4df00000, 0x0201f800, 0x00106062, 0x5c03e000,
7089 0x5c001000, 0x5c000800, 0x480b8808, 0x48079040,
7090 0x1c01f000, 0x4803c856, 0x59c80840, 0x82040540,
7091 0x00000010, 0x48039040, 0x59c41008, 0x82080500,
7092 0xffffff7f, 0x48038808, 0x4c040000, 0x4c080000,
7093 0x59c40004, 0x82000500, 0x00000003, 0x04020010,
7094 0x59c40004, 0x82000500, 0x0000000c, 0x04000005,
7095 0x4a038804, 0x0000000c, 0x8c000504, 0x0401f025,
7096 0x59c80040, 0x8400056e, 0x48039040, 0x59c80040,
7097 0x8c00052e, 0x040207fe, 0x0401f01e, 0x4a038803,
7098 0x00000008, 0x59c40003, 0x82000500, 0x00000003,
7099 0x040007fd, 0x8c000502, 0x04020006, 0x59c40004,
7100 0x4a038804, 0x0000000c, 0x8c000504, 0x0401f011,
7101 0x59c80040, 0x8400056a, 0x48039040, 0x59c80040,
7102 0x8c00052a, 0x040207fe, 0x59c40005, 0x82000500,
7103 0xc0000000, 0x04000007, 0x59c400a3, 0x84000540,
7104 0x480388a3, 0x4a038805, 0xc0000000, 0x80000580,
7105 0x497b2807, 0x5c001000, 0x5c000800, 0x480b8808,
7106 0x48079040, 0x1c01f000, 0x4933c857, 0x4d900000,
7107 0x4dd00000, 0x4da40000, 0x4d140000, 0x0401fdee,
7108 0x4df00000, 0x0401fa6f, 0x59900004, 0x800001c0,
7109 0x04000011, 0x81300580, 0x0402000f, 0x59300004,
7110 0x84000520, 0x48026004, 0x0401ff51, 0x04020009,
7111 0x5c03e000, 0x04000dd6, 0x80000580, 0x5c022800,
7112 0x5c034800, 0x5c03a000, 0x5c032000, 0x1c01f000,
7113 0x0401fd0e, 0x42027000, 0x00000049, 0x59300004,
7114 0x84000520, 0x48026004, 0x8c00050c, 0x02020800,
7115 0x000207a1, 0x5c03e000, 0x04000dc5, 0x82000540,
7116 0x00000001, 0x5c022800, 0x5c034800, 0x5c03a000,
7117 0x5c032000, 0x1c01f000, 0x4933c857, 0x0401fdc6,
7118 0x4df00000, 0x598c000d, 0x80026540, 0x04000012,
7119 0x59300004, 0x84000520, 0x48026004, 0x0401ff8a,
7120 0x04000017, 0x0401fd26, 0x42027000, 0x00000013,
7121 0x59300004, 0x8c00050c, 0x02020800, 0x000207a1,
7122 0x5c03e000, 0x04000daa, 0x82000540, 0x00000001,
7123 0x1c01f000, 0x836c1580, 0x00000001, 0x040007f9,
7124 0x836c1580, 0x00000004, 0x040007f6, 0x42001000,
7125 0x00104148, 0x0201f800, 0x00105f90, 0x5c03e000,
7126 0x04000d9b, 0x80000580, 0x1c01f000, 0x4d300000,
7127 0x4d180000, 0x4d3c0000, 0x0401fd9f, 0x4df00000,
7128 0x4a0378e4, 0x0000000f, 0x0401f9ff, 0x417a3000,
7129 0x59926004, 0x813261c0, 0x04000010, 0x417a7800,
7130 0x0201f800, 0x001048d9, 0x0400000a, 0x59300c06,
7131 0x82040580, 0x00000003, 0x04000004, 0x82040580,
7132 0x00000006, 0x04020003, 0x42027800, 0x00000002,
7133 0x0201f800, 0x00108be3, 0x811a3000, 0x83180480,
7134 0x00000005, 0x040017eb, 0x42000800, 0x00000040,
7135 0x0201f800, 0x00101345, 0x4a0378e4, 0x0000000a,
7136 0x5c03e000, 0x04000d72, 0x5c027800, 0x5c023000,
7137 0x5c026000, 0x1c01f000, 0x4803c856, 0x4d300000,
7138 0x0401fd75, 0x4df00000, 0x59c80840, 0x82040540,
7139 0x00000010, 0x48039040, 0x59c41008, 0x82080500,
7140 0xffffff7f, 0x48038808, 0x4c040000, 0x4c080000,
7141 0x42001000, 0x00000003, 0x0401f9c2, 0x598e600d,
7142 0x813261c0, 0x04020f9d, 0x040009c7, 0x497b2807,
7143 0x0401f80a, 0x5c001000, 0x5c000800, 0x480b8808,
7144 0x84040d74, 0x48079040, 0x5c03e000, 0x04000d50,
7145 0x5c026000, 0x1c01f000, 0x4d380000, 0x4d180000,
7146 0x4d300000, 0x4d900000, 0x4dd00000, 0x4da40000,
7147 0x4d140000, 0x59c41004, 0x480bc857, 0x82080500,
7148 0x00003ff0, 0x04000025, 0x417a3000, 0x4c080000,
7149 0x0201f800, 0x00106062, 0x5c001000, 0x82080500,
7150 0x00000210, 0x04020004, 0x811a3000, 0x80081102,
7151 0x0401f7f7, 0x0401f9c3, 0x59926004, 0x4933c857,
7152 0x813261c0, 0x04020005, 0x59c400a3, 0x8c00051a,
7153 0x02000800, 0x001005d8, 0x0401fea5, 0x04000009,
7154 0x0401fc6a, 0x42027000, 0x00000049, 0x59300004,
7155 0x8c00050c, 0x02020800, 0x000207a1, 0x0401f007,
7156 0x42027000, 0x0000004a, 0x4a026203, 0x00000003,
7157 0x0201f800, 0x000207a1, 0x5c022800, 0x5c034800,
7158 0x5c03a000, 0x5c032000, 0x5c026000, 0x5c023000,
7159 0x5c027000, 0x1c01f000, 0x4d300000, 0x4d180000,
7160 0x4d900000, 0x0401fd1c, 0x42001000, 0x00000000,
7161 0x598c0000, 0x82000580, 0x00000005, 0x04000971,
7162 0x417a3000, 0x811b20c8, 0x83932400, 0x0000bf32,
7163 0x59900001, 0x82000580, 0x00000001, 0x0402000d,
7164 0x42000800, 0x000007d0, 0x59926004, 0x59300011,
7165 0x82000500, 0xfff00000, 0x80000540, 0x04000003,
7166 0x42000800, 0x00001b58, 0x0201f800, 0x00106054,
7167 0x811a3000, 0x83180480, 0x00000005, 0x040017ea,
7168 0x59c81040, 0x84081534, 0x480b9040, 0x0401fcf0,
7169 0x5c032000, 0x5c023000, 0x5c026000, 0x1c01f000,
7170 0x4933c857, 0x4d900000, 0x4dd00000, 0x4da40000,
7171 0x4d140000, 0x4d380000, 0x0401fcef, 0x4df00000,
7172 0x59300004, 0x8c00053e, 0x04020007, 0x8c000520,
7173 0x04000025, 0x0201f800, 0x00106b6c, 0x04000022,
7174 0x0401f02a, 0x598c000d, 0x81300580, 0x04000011,
7175 0x0201f800, 0x00108cd6, 0x04020024, 0x0401f918,
7176 0x04000022, 0x48038804, 0x0401f95e, 0x0201f800,
7177 0x0010107a, 0x0401fc0d, 0x42027000, 0x00000049,
7178 0x59300004, 0x8c00050c, 0x0402000d, 0x0401f00e,
7179 0x59c40004, 0x8c000504, 0x04000014, 0x4a038804,
7180 0x00000004, 0x0401fc36, 0x42027000, 0x00000013,
7181 0x59300004, 0x8c00050c, 0x04000003, 0x0201f800,
7182 0x000207a1, 0x5c03e000, 0x04000cb9, 0x5c027000,
7183 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000,
7184 0x80000580, 0x1c01f000, 0x5c03e000, 0x04000cb0,
7185 0x5c027000, 0x5c022800, 0x5c034800, 0x5c03a000,
7186 0x5c032000, 0x82000540, 0x00000001, 0x1c01f000,
7187 0x497b2807, 0x0401fcb0, 0x59c400af, 0x800001c0,
7188 0x04020004, 0x0401fca2, 0x0201f000, 0x001014fb,
7189 0x598c000f, 0x82001480, 0x00000002, 0x04021007,
7190 0x80000000, 0x4803180f, 0x80000580, 0x0201f800,
7191 0x0010604d, 0x0400000e, 0x0401fed8, 0x0402000c,
7192 0x0401fdd4, 0x0400000a, 0x0201f800, 0x0010a9c7,
7193 0x0401f916, 0x4d380000, 0x42027000, 0x00000014,
7194 0x0201f800, 0x000207a1, 0x5c027000, 0x0401fc88,
7195 0x0201f000, 0x001014fb, 0x4d900000, 0x4dd00000,
7196 0x4da40000, 0x4d140000, 0x4d300000, 0x0201f800,
7197 0x00106062, 0x0401fc88, 0x59c400af, 0x800001c0,
7198 0x04000027, 0x0401f907, 0x59926004, 0x4933c857,
7199 0x59300004, 0x8c000516, 0x0400000b, 0x0401fe8b,
7200 0x0402001f, 0x0201f800, 0x00106b8a, 0x0401fc70,
7201 0x42000800, 0x80000804, 0x0201f800, 0x00106721,
7202 0x0401f017, 0x42001800, 0x00007530, 0x0401f8c1,
7203 0x04020004, 0x0201f800, 0x00106052, 0x0401f010,
7204 0x0401fe7a, 0x0402000e, 0x0201f800, 0x0010a9c7,
7205 0x59300004, 0x8c00050c, 0x04020003, 0x4a026203,
7206 0x00000003, 0x4d380000, 0x42027000, 0x0000004a,
7207 0x0201f800, 0x000207a1, 0x5c027000, 0x0401fc54,
7208 0x5c026000, 0x5c022800, 0x5c034800, 0x5c03a000,
7209 0x5c032000, 0x0201f000, 0x001014fb, 0x4d900000,
7210 0x4dd00000, 0x4da40000, 0x4d140000, 0x4d300000,
7211 0x4d2c0000, 0x0401fc50, 0x0401f8d2, 0x59926004,
7212 0x4933c857, 0x0401f880, 0x04000016, 0x0201f800,
7213 0x00106062, 0x813261c0, 0x04000034, 0x59325808,
7214 0x812e59c0, 0x02000800, 0x001005d8, 0x0201f800,
7215 0x0010513b, 0x0402001d, 0x592c0208, 0x84000550,
7216 0x48025a08, 0x0201f800, 0x00105258, 0x04020027,
7217 0x592c0208, 0x84000510, 0x48025a08, 0x0401f023,
7218 0x0201f800, 0x00106052, 0x0401f020, 0x0201f800,
7219 0x0010a9c7, 0x0401fd9e, 0x592c0208, 0x84000550,
7220 0x48025a08, 0x4d380000, 0x42027000, 0x0000004a,
7221 0x4a026203, 0x00000003, 0x0201f800, 0x000207a1,
7222 0x5c027000, 0x0401f011, 0x59900006, 0x82000500,
7223 0xffff0000, 0x040207ee, 0x59c408af, 0x82040480,
7224 0x000003e8, 0x040217ea, 0x59900006, 0x82000400,
7225 0x00010000, 0x48032006, 0x0201f800, 0x00106052,
7226 0x0201f800, 0x0010411d, 0x5c025800, 0x5c026000,
7227 0x5c022800, 0x5c034800, 0x5c03a000, 0x5c032000,
7228 0x0401f403, 0x4d300000, 0x4d2c0000, 0x0401fc0a,
7229 0x598e600d, 0x4933c857, 0x59c41004, 0x8c081500,
7230 0x04000007, 0x0201f800, 0x0010513b, 0x04020007,
7231 0x0201f800, 0x00105258, 0x0402002f, 0x0201f800,
7232 0x0010604d, 0x0401f02c, 0x598c000f, 0x80000540,
7233 0x04020011, 0x59c408af, 0x82040480, 0x000003e8,
7234 0x0402100d, 0x598c080f, 0x80040800, 0x4807180f,
7235 0x0201f800, 0x0010604d, 0x42000000, 0x0010b852,
7236 0x0201f800, 0x0010aa47, 0x0201f800, 0x0010411d,
7237 0x0401f019, 0x0401fdb4, 0x813261c0, 0x04020003,
7238 0x0401f849, 0x0401f014, 0x0201f800, 0x0010a9c7,
7239 0x59300406, 0x82000580, 0x00000003, 0x04020007,
7240 0x59325808, 0x812e59c0, 0x04000004, 0x592c0208,
7241 0x84000550, 0x48025a08, 0x0401f854, 0x4d380000,
7242 0x42027000, 0x00000014, 0x0201f800, 0x000207a1,
7243 0x5c027000, 0x5c025800, 0x5c026000, 0x0201f000,
7244 0x00106c4b, 0x59c40804, 0x83180400, 0x00107095,
7245 0x50000000, 0x80040500, 0x1c01f000, 0x59c40804,
7246 0x83180400, 0x0010709a, 0x50000000, 0x80040500,
7247 0x1c01f000, 0x00000210, 0x00000420, 0x00000840,
7248 0x00001080, 0x00002100, 0x00004000, 0x00008000,
7249 0x00010000, 0x00020000, 0x00040000, 0x00080000,
7250 0x00100000, 0x00200000, 0x00400000, 0x00800000,
7251 0x59900806, 0x80040120, 0x800c0480, 0x04021004,
7252 0x82000540, 0x00000001, 0x0401f005, 0x82040c00,
7253 0x00010000, 0x48072006, 0x80000580, 0x1c01f000,
7254 0x480bc857, 0x0201f800, 0x00106c55, 0x4df00000,
7255 0x480b1800, 0x5c03e000, 0x02000800, 0x00106c4b,
7256 0x1c01f000, 0x4803c856, 0x0201f800, 0x00106c55,
7257 0x4df00000, 0x497b180d, 0x497b1803, 0x497b180e,
7258 0x497b180f, 0x497b1810, 0x598c0000, 0x82000580,
7259 0x00000003, 0x04000009, 0x836c0580, 0x00000002,
7260 0x04020004, 0x4a031800, 0x00000005, 0x0401f003,
7261 0x4a031800, 0x00000000, 0x5c03e000, 0x02000800,
7262 0x00106c4b, 0x1c01f000, 0x59300004, 0x8c00050c,
7263 0x04020003, 0x4a026203, 0x00000001, 0x1c01f000,
7264 0x83180480, 0x00000005, 0x02021800, 0x001005d8,
7265 0x491bc857, 0x811b20c8, 0x83932400, 0x0000bf32,
7266 0x811ba0ca, 0x83d3a400, 0x00007600, 0x83180400,
7267 0x001070ea, 0x50034800, 0x811a28c2, 0x83162c00,
7268 0x00006100, 0x1c01f000, 0x0010b75b, 0x0010b772,
7269 0x0010b789, 0x0010b7a0, 0x0010b7b7, 0x4933c857,
7270 0x59300406, 0x82000c80, 0x00000012, 0x04021016,
7271 0x4803c857, 0x04011000, 0x0c01f001, 0x00107109,
7272 0x00107198, 0x001074d1, 0x00107556, 0x00107198,
7273 0x001074d1, 0x00107556, 0x00107109, 0x00107198,
7274 0x00107109, 0x00107109, 0x00107109, 0x00107109,
7275 0x00107109, 0x00107109, 0x00107109, 0x0010710f,
7276 0x0010710f, 0x0201f800, 0x00106c55, 0x0201f800,
7277 0x00106bbf, 0x0201f000, 0x00106c4b, 0x42001000,
7278 0x0010b7f6, 0x50081000, 0x4930100c, 0x58080002,
7279 0x82000580, 0x00000100, 0x04020032, 0x59325808,
7280 0x812e59c0, 0x02000800, 0x001005d8, 0x59326809,
7281 0x813669c0, 0x04000019, 0x592c040b, 0x82000500,
7282 0x0000e000, 0x04000003, 0x0401fba8, 0x0401f002,
7283 0x0401fb98, 0x42001000, 0x0010b7f6, 0x50081000,
7284 0x4930100b, 0x492c100a, 0x82d00400, 0x00000006,
7285 0x48001003, 0x592c000d, 0x80000104, 0x48001004,
7286 0x592c000e, 0x48001007, 0x592c000f, 0x48001008,
7287 0x0201f000, 0x00100858, 0x42026800, 0x0010be0d,
7288 0x592c080a, 0x48066802, 0x82040500, 0x00ffff00,
7289 0x04000007, 0x497a6a12, 0x59a81010, 0x82081500,
7290 0x00ffff00, 0x80080580, 0x040207dc, 0x82040d00,
7291 0x000000ff, 0x800408d0, 0x48066a12, 0x0401f7d7,
7292 0x1c01f000, 0x4d2c0000, 0x4d300000, 0x4c580000,
7293 0x4c540000, 0x4c500000, 0x5832580a, 0x812e59c0,
7294 0x02000800, 0x001005d8, 0x58300002, 0x4a006002,
7295 0x00000100, 0x82000580, 0x00000100, 0x0402001c,
7296 0x5830000b, 0x5832600c, 0x81300580, 0x04020010,
7297 0x0401f828, 0x04020010, 0x592c080d, 0x80040904,
7298 0x4004b000, 0x4200a000, 0x0010b54b, 0x4050a800,
7299 0x0201f800, 0x0010ab28, 0x42001000, 0x0000dc00,
7300 0x0201f800, 0x001078bc, 0x0401f003, 0x0401f819,
7301 0x04000fa3, 0x5c00a000, 0x5c00a800, 0x5c00b000,
7302 0x5c026000, 0x5c025800, 0x1c01f000, 0x5830000b,
7303 0x5832600c, 0x81300580, 0x040207f5, 0x0401f80d,
7304 0x040207f5, 0x0201f800, 0x001068d3, 0x02020800,
7305 0x001005d8, 0x4a025a06, 0x00000002, 0x0201f800,
7306 0x000202da, 0x0201f800, 0x00107911, 0x0401f7ea,
7307 0x0201f800, 0x00106c55, 0x4df00000, 0x598c000d,
7308 0x81300580, 0x04020009, 0x598c0005, 0x81300580,
7309 0x04020006, 0x5c03e000, 0x02000800, 0x00106c4b,
7310 0x80000580, 0x1c01f000, 0x5c03e000, 0x02000800,
7311 0x00106c4b, 0x82000540, 0x00000001, 0x1c01f000,
7312 0x59300403, 0x82000c80, 0x00000056, 0x02021800,
7313 0x001005d8, 0x4803c857, 0x0c01f001, 0x00107302,
7314 0x0010731d, 0x0010732e, 0x00107431, 0x001073f1,
7315 0x001073f5, 0x00107406, 0x0010741a, 0x0010740f,
7316 0x0010741a, 0x00107455, 0x0010741a, 0x00107497,
7317 0x0010741a, 0x001074a5, 0x0010741a, 0x0010740f,
7318 0x0010741a, 0x001074a9, 0x001071f5, 0x001071f5,
7319 0x001071f5, 0x001071f5, 0x001071f5, 0x001071f5,
7320 0x001071f5, 0x001071f5, 0x001071f5, 0x001071f5,
7321 0x001071f5, 0x00107574, 0x00107593, 0x0010759d,
7322 0x001071f5, 0x001075b3, 0x00107406, 0x001071f5,
7323 0x00107406, 0x0010741a, 0x001071f5, 0x0010732e,
7324 0x00107431, 0x001071f5, 0x00107603, 0x0010741a,
7325 0x001071f5, 0x00107613, 0x0010741a, 0x001071f5,
7326 0x0010740f, 0x001072f3, 0x001071f7, 0x001071f5,
7327 0x0010762a, 0x0010765d, 0x001076d7, 0x001071f5,
7328 0x001076e7, 0x00107404, 0x001076da, 0x001071f5,
7329 0x001075bf, 0x00107700, 0x001071f5, 0x00107735,
7330 0x00107788, 0x001071f5, 0x0010720c, 0x00107265,
7331 0x00107272, 0x001071f5, 0x00107406, 0x001071f5,
7332 0x001072b9, 0x001072c4, 0x001071f5, 0x001071f5,
7333 0x00107220, 0x00107245, 0x001077c7, 0x00107808,
7334 0x0010782e, 0x001071f5, 0x001071f5, 0x001071f5,
7335 0x001077fc, 0x0201f800, 0x001005d8, 0x0401fac5,
7336 0x59325808, 0x592c0009, 0x4801a006, 0x592c000a,
7337 0x4801a007, 0x592c000b, 0x4801a008, 0x592c000c,
7338 0x4801a009, 0x592c000d, 0x4801a00a, 0x4979a00b,
7339 0x592c0809, 0x82040d00, 0x00000fff, 0x80040904,
7340 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc,
7341 0x4a026202, 0x0000ffff, 0x0401faae, 0x4d2c0000,
7342 0x4a01a006, 0x05000000, 0x59325808, 0x592c0009,
7343 0x4801a007, 0x592c000a, 0x4801a008, 0x592c000b,
7344 0x4801a009, 0x42000800, 0x00000004, 0x42001000,
7345 0x0000dc00, 0x5c025800, 0x0201f000, 0x001078bc,
7346 0x4c580000, 0x4c500000, 0x4c540000, 0x4d2c0000,
7347 0x0401fa98, 0x59325808, 0x5930040b, 0x800000c2,
7348 0x4200a800, 0x0010b54b, 0x592cb205, 0x832ca400,
7349 0x00000006, 0x0201f800, 0x0010ab17, 0x40580000,
7350 0x8054ac00, 0x592c0001, 0x80000540, 0x04000003,
7351 0x40025800, 0x0401f7f5, 0x4200a000, 0x0010b54b,
7352 0x4050a800, 0x5930b40b, 0x0201f800, 0x0010ab28,
7353 0x59300c0b, 0x42001000, 0x0000dc00, 0x5c025800,
7354 0x5c00a800, 0x5c00b000, 0x5c00a000, 0x0201f000,
7355 0x001078bc, 0x4c580000, 0x4c500000, 0x4c540000,
7356 0x4d2c0000, 0x42034800, 0x0010b544, 0x0401fa7f,
7357 0x59325808, 0x4a025805, 0x02000000, 0x592c0802,
7358 0x82d0ac00, 0x00000006, 0x592cb011, 0x832ca400,
7359 0x00000005, 0x0201f800, 0x0010ab17, 0x40580000,
7360 0x8054ac00, 0x592e5801, 0x41780000, 0x812e5d40,
7361 0x040207f6, 0x42001000, 0x0000dc00, 0x5c025800,
7362 0x5c00a800, 0x5c00b000, 0x5c00a000, 0x0201f000,
7363 0x001078bc, 0x0401fa57, 0x4a01a006, 0x78000000,
7364 0x5930001c, 0x840001c0, 0x4801a407, 0x4979a207,
7365 0x42000800, 0x00000002, 0x42001000, 0x0000dc00,
7366 0x0201f000, 0x001078bc, 0x4c580000, 0x4c540000,
7367 0x4c500000, 0x0401fa55, 0x4a01a006, 0x02000000,
7368 0x59a80002, 0x4801a008, 0x59a80003, 0x4801a009,
7369 0x59a80000, 0x4801a00a, 0x59a80001, 0x4801a00b,
7370 0x5930001c, 0x82000d80, 0x0000e000, 0x04000016,
7371 0x82000d80, 0x0000df00, 0x04000006, 0x4a01a407,
7372 0x00000010, 0x42000800, 0x00000006, 0x0401f027,
7373 0x4a03c840, 0x0010b4eb, 0x4a03c842, 0x0000000d,
7374 0x42001800, 0x0010b4eb, 0x0201f800, 0x001007af,
7375 0x42000000, 0x0000df00, 0x4200a000, 0x0010b4eb,
7376 0x0401f00d, 0x4a03c840, 0x0010b4f8, 0x4a03c842,
7377 0x0000000d, 0x42001800, 0x0010b4f8, 0x0201f800,
7378 0x001007af, 0x42000000, 0x0000e000, 0x4200a000,
7379 0x0010b4f8, 0x82000540, 0x00000010, 0x4801a407,
7380 0x4a01a207, 0x00000034, 0x4200b000, 0x0000000d,
7381 0x82d0ac00, 0x0000000c, 0x0201f800, 0x0010ab17,
7382 0x42000800, 0x00000013, 0x42001000, 0x0000dc00,
7383 0x5c00a000, 0x5c00a800, 0x5c00b000, 0x0201f000,
7384 0x001078bc, 0x0401fa03, 0x4a01a006, 0x63000028,
7385 0x5930001c, 0x4801a007, 0x42000800, 0x00000002,
7386 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc,
7387 0x0401fa06, 0x41780000, 0x41780800, 0x42002000,
7388 0x00080000, 0x0c01f81b, 0x80000000, 0x80040800,
7389 0x42001000, 0x0000000c, 0x59841802, 0x8c0c1d00,
7390 0x04020008, 0x42002000, 0x00050000, 0x0c01f811,
7391 0x80000000, 0x80040800, 0x82081400, 0x00000004,
7392 0x82080540, 0x02000000, 0x4801a006, 0x800408e0,
7393 0x5930001c, 0x80040540, 0x4801a007, 0x80080904,
7394 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc,
7395 0x001072e9, 0x001072eb, 0x001072ed, 0x001072ef,
7396 0x001072f1, 0x4811a008, 0x1c01f000, 0x4811a009,
7397 0x1c01f000, 0x4811a00a, 0x1c01f000, 0x4811a00b,
7398 0x1c01f000, 0x4811a00c, 0x1c01f000, 0x4a026009,
7399 0x0010be0d, 0x59a80010, 0x82000500, 0x000000ff,
7400 0x800000d0, 0x42026800, 0x0010be0d, 0x48026a12,
7401 0x0401fa3b, 0x41780800, 0x42001000, 0x00005c00,
7402 0x0201f000, 0x001078bc, 0x0401f9ba, 0x4a01a006,
7403 0x52000000, 0x4979a007, 0x599c0017, 0x8c000500,
7404 0x04000005, 0x599c0402, 0x0201f800, 0x001015da,
7405 0x4805a007, 0x59a80002, 0x4801a008, 0x59a80003,
7406 0x4801a009, 0x59a80000, 0x4801a00a, 0x59a80001,
7407 0x4801a00b, 0x59a80010, 0x4801a00c, 0x42000800,
7408 0x00000007, 0x42001000, 0x0000dc00, 0x0201f000,
7409 0x001078bc, 0x4a026202, 0x0000ffff, 0x0401f99d,
7410 0x4a01a006, 0x05000000, 0x59a80010, 0x4801a007,
7411 0x59a80002, 0x59a80803, 0x4801a008, 0x4805a009,
7412 0x42000800, 0x00000004, 0x42001000, 0x0000dc00,
7413 0x0201f000, 0x001078bc, 0x4a026202, 0x0000ffff,
7414 0x0401f98c, 0x4d3c0000, 0x417a7800, 0x0201f800,
7415 0x001048f6, 0x5c027800, 0x4a01a006, 0x03000000,
7416 0x59340403, 0x82000580, 0x000007fe, 0x0402006e,
7417 0x4a01a006, 0x04000000, 0x81a40800, 0x4a000800,
7418 0x22fffffe, 0x5934000a, 0x84000500, 0x4802680a,
7419 0x59c41002, 0x8408150c, 0x480b8802, 0x59a80026,
7420 0x8c000508, 0x04000010, 0x59a8002a, 0x4801a007,
7421 0x59a8002b, 0x82000500, 0xffff2000, 0x599c0818,
7422 0x8c040d16, 0x04000002, 0x8400056a, 0x4801a008,
7423 0x4a01a009, 0x00002710, 0x59a8002d, 0x4801a00a,
7424 0x0401f039, 0x59a8002a, 0x4801a007, 0x0201f800,
7425 0x0010513b, 0x04020009, 0x497b8880, 0x82000500,
7426 0x0000ffff, 0x4c000000, 0x0201f800, 0x00101606,
7427 0x5c000000, 0x48038880, 0x59a8002b, 0x0201f800,
7428 0x0010513b, 0x04020004, 0x82000500, 0x37ffffff,
7429 0x0401f003, 0x82000500, 0x3fffffff, 0x599c0818,
7430 0x8c040d16, 0x04000002, 0x8400056a, 0x59a80805,
7431 0x8c040d10, 0x04000019, 0x59300c03, 0x82041580,
7432 0x00000051, 0x04000015, 0x82041580, 0x00000031,
7433 0x04000012, 0x4c580000, 0x4c500000, 0x4c540000,
7434 0x4200b000, 0x00000004, 0x4200a000, 0x0010b8fa,
7435 0x82d0ac00, 0x0000001f, 0x4c000000, 0x0201f800,
7436 0x0010ab17, 0x5c000000, 0x5c00a800, 0x5c00a000,
7437 0x5c00b000, 0x8400057a, 0x4801a008, 0x4979a009,
7438 0x4979a00a, 0x59a80002, 0x59a80803, 0x4801a00b,
7439 0x4805a00c, 0x59a80000, 0x59a80801, 0x4801a00d,
7440 0x4805a00e, 0x4979a00f, 0x4979a010, 0x4979a011,
7441 0x4979a012, 0x4979a013, 0x4979a014, 0x4979a015,
7442 0x4979a016, 0x59a8002e, 0x84000576, 0x4801a017,
7443 0x59a8002f, 0x4801a018, 0x4979a019, 0x4979a01a,
7444 0x0401f043, 0x59a80026, 0x8c000508, 0x0400000d,
7445 0x59a8002a, 0x82000500, 0x0000ffff, 0x59c40880,
7446 0x80040d80, 0x04000007, 0x497b8880, 0x4c000000,
7447 0x0201f800, 0x00101606, 0x5c000000, 0x48038880,
7448 0x59a8002a, 0x4801a007, 0x4c640000, 0x4d2c0000,
7449 0x59a8c82b, 0x0201f800, 0x00109037, 0x0400000d,
7450 0x0201f800, 0x00109597, 0x0402000a, 0x592c0207,
7451 0x8c00050e, 0x04000007, 0x8264cd00, 0x0000ffff,
7452 0x592c0009, 0x82000500, 0xffff0000, 0x8064cd40,
7453 0x4865a008, 0x5c025800, 0x5c00c800, 0x59a8002c,
7454 0x4801a009, 0x59a8002d, 0x4801a00a, 0x59a80002,
7455 0x59a80803, 0x4801a00b, 0x4805a00c, 0x59a80000,
7456 0x59a80801, 0x4801a00d, 0x4805a00e, 0x4979a00f,
7457 0x4979a010, 0x4979a011, 0x4979a012, 0x4979a013,
7458 0x4979a014, 0x4979a015, 0x4979a016, 0x59a8002e,
7459 0x4801a017, 0x59a8002f, 0x4801a018, 0x59a80030,
7460 0x4801a019, 0x59a80031, 0x4801a01a, 0x42000800,
7461 0x0000001d, 0x42001000, 0x0000dc00, 0x0201f000,
7462 0x001078bc, 0x0401f8cb, 0x4a01a006, 0x50000000,
7463 0x0401f7b5, 0x0401f8c7, 0x4a01a406, 0x21000010,
7464 0x4a01a206, 0x00000014, 0x4979a007, 0x4979a008,
7465 0x4979a009, 0x4979a00a, 0x42000800, 0x00000005,
7466 0x42001000, 0x0000dc00, 0x0201f000, 0x001078bc,
7467 0x0401f8bf, 0x0401f002, 0x0401f8c4, 0x4a01a006,
7468 0x02000000, 0x42000800, 0x00000001, 0x42001000,
7469 0x0000dc00, 0x0201f000, 0x001078bc, 0x0401f8bb,
7470 0x4a01a006, 0x02000000, 0x59300403, 0x82000580,
7471 0x00000031, 0x04020794, 0x81a40800, 0x4a000801,
7472 0x00fffffe, 0x0401f72b, 0x0401f8b0, 0x4a01a006,
7473 0x01000000, 0x5930041a, 0x80000540, 0x04000003,
7474 0x4801a407, 0x0401f003, 0x4a01a407, 0x00000003,
7475 0x5930021a, 0x80000540, 0x04000003, 0x4801a207,
7476 0x0401f003, 0x4a01a207, 0x00002a00, 0x42000800,
7477 0x00000002, 0x42001000, 0x0000dc00, 0x0201f000,
7478 0x001078bc, 0x4a026202, 0x0000ffff, 0x0401f889,
7479 0x4a01a406, 0x00002010, 0x4a01a206, 0x00000014,
7480 0x4a01a407, 0x00000800, 0x4a01a207, 0x00002000,
7481 0x80000580, 0x599c0817, 0x8c040d0a, 0x04020003,
7482 0x82000540, 0x00000020, 0x8c040d08, 0x04000003,
7483 0x82000540, 0x00000010, 0x82000540, 0x00000002,
7484 0x5934080a, 0x8c040d14, 0x04000005, 0x82040d00,
7485 0x00000380, 0x80040540, 0x0401f006, 0x599c0818,
7486 0x8c040d18, 0x04000003, 0x82000540, 0x00000380,
7487 0x0401f03c, 0x0401f875, 0x4a01a406, 0x00000210,
7488 0x4a01a206, 0x00000014, 0x4a01a407, 0x00000800,
7489 0x5934000a, 0x8c000516, 0x04000014, 0x59340c05,
7490 0x82040500, 0x00000030, 0x04000013, 0x59340a05,
7491 0x82040500, 0x0000c000, 0x04020009, 0x8c040d1a,
7492 0x04000004, 0x4a01a207, 0x00002100, 0x0401f00c,
7493 0x4a01a207, 0x00000100, 0x0401f009, 0x4a01a207,
7494 0x00000400, 0x0401f006, 0x4a01a207, 0x00000700,
7495 0x0401f003, 0x4a01a207, 0x00000800, 0x80000580,
7496 0x599c0817, 0x8c040d0a, 0x04020003, 0x82000540,
7497 0x00000020, 0x8c040d08, 0x04000003, 0x82000540,
7498 0x00000010, 0x82000540, 0x00000002, 0x59340a00,
7499 0x8c040d0e, 0x0400000b, 0x84000550, 0x599c1017,
7500 0x8c08150a, 0x04020004, 0x8c040d0a, 0x04000002,
7501 0x8400054e, 0x8c040d1c, 0x04000002, 0x84000552,
7502 0x4801a20a, 0x42000800, 0x00000005, 0x42001000,
7503 0x0000dc00, 0x0201f000, 0x001078bc, 0x0401f833,
7504 0x4a01a006, 0x02100014, 0x4a01a007, 0x01000000,
7505 0x4979a008, 0x4979a009, 0x4979a00a, 0x42000800,
7506 0x00000005, 0x42001000, 0x0000dc00, 0x0201f000,
7507 0x001078bc, 0x0401f825, 0x4a01a006, 0x02000000,
7508 0x0401f65d, 0x4933c857, 0x0401f820, 0x4a01a006,
7509 0x01000000, 0x4a01a407, 0x0000000b, 0x42000800,
7510 0x00000002, 0x42001000, 0x0000dc00, 0x0201f000,
7511 0x001078bc, 0x42005000, 0x32000000, 0x42006000,
7512 0x08290000, 0x41786800, 0x41787800, 0x0401f3df,
7513 0x42005000, 0x22000000, 0x42006000, 0x01290000,
7514 0x41786800, 0x41787800, 0x0401f3d8, 0x42005000,
7515 0x33000000, 0x42006000, 0x08980000, 0x41786800,
7516 0x41787800, 0x0401f3d1, 0x42005000, 0x23000000,
7517 0x42006000, 0x01980000, 0x41786800, 0x41787800,
7518 0x0401f3ca, 0x59300403, 0x82000c80, 0x00000085,
7519 0x02001800, 0x001005d8, 0x82000c80, 0x00000093,
7520 0x02021800, 0x001005d8, 0x82000480, 0x00000085,
7521 0x0c01f001, 0x001074eb, 0x001074ed, 0x001074fb,
7522 0x001074eb, 0x001074eb, 0x001074eb, 0x001074eb,
7523 0x001074eb, 0x001074eb, 0x001074eb, 0x001074eb,
7524 0x001074eb, 0x001074eb, 0x00107506, 0x0201f800,
7525 0x001005d8, 0x4933c857, 0x0401f850, 0x59300402,
7526 0x4801a407, 0x5930001c, 0x4801a207, 0x4979a408,
7527 0x4a01a208, 0x0000ffff, 0x42000800, 0x00000003,
7528 0x42001000, 0x0000dc00, 0x0401f3c2, 0x4933c857,
7529 0x0401f84e, 0x4a01a406, 0x00000003, 0x4a01a206,
7530 0x00000300, 0x42000800, 0x00000001, 0x42001000,
7531 0x0000dc00, 0x0401f3b7, 0x4d2c0000, 0x59325808,
7532 0x4933c857, 0x492fc857, 0x812e59c0, 0x02000800,
7533 0x001005d8, 0x59340a12, 0x82040d00, 0x0000ff00,
7534 0x592c000a, 0x82000500, 0x000000ff, 0x900001c0,
7535 0x80040540, 0x82000540, 0x00000011, 0x44034800,
7536 0x81a5a000, 0x42001000, 0x00000009, 0x42000800,
7537 0x00000003, 0x592c0009, 0x82000500, 0xff000000,
7538 0x82001d80, 0x84000000, 0x04000009, 0x82001d80,
7539 0x85000000, 0x02020800, 0x001005d8, 0x42001000,
7540 0x00000007, 0x42000800, 0x00000001, 0x832c1c00,
7541 0x00000009, 0x500c0000, 0x4401a000, 0x800c1800,
7542 0x80d1a000, 0x80081040, 0x040207fb, 0x42001000,
7543 0x0000dc00, 0x5c025800, 0x0401f386, 0x42005000,
7544 0x81000000, 0x42006000, 0x00090000, 0x41786800,
7545 0x41787800, 0x0401f35d, 0x42005000, 0x84000000,
7546 0x42006000, 0x00990000, 0x59300406, 0x82000580,
7547 0x00000005, 0x04000002, 0x8430652e, 0x41786800,
7548 0x41787800, 0x0401f351, 0x42005000, 0x85000000,
7549 0x42006000, 0x00990000, 0x59300406, 0x82000580,
7550 0x00000005, 0x04000002, 0x8430652e, 0x41786800,
7551 0x41787800, 0x0401f345, 0x59300403, 0x82000c80,
7552 0x00000053, 0x02021800, 0x001005d8, 0x82000480,
7553 0x0000004b, 0x02001800, 0x001005d8, 0x59326809,
7554 0x59368c03, 0x4803c857, 0x0c01f001, 0x001075da,
7555 0x001075e2, 0x001075ea, 0x001075f2, 0x0010756b,
7556 0x0010756b, 0x0010756b, 0x001075d2, 0x0201f800,
7557 0x001005d8, 0x42005000, 0x06000000, 0x42006000,
7558 0x08290000, 0x41786800, 0x41787800, 0x0401f327,
7559 0x4933c857, 0x0401ff47, 0x4a01a006, 0x12000000,
7560 0x59300406, 0x82000580, 0x00000004, 0x04020003,
7561 0x59340002, 0x0401f002, 0x59a80010, 0x82000500,
7562 0x00ffffff, 0x4801a007, 0x59300419, 0x4801a408,
7563 0x59300219, 0x4801a208, 0x4979a009, 0x4979a00a,
7564 0x4979a00b, 0x4979a00c, 0x4979a00d, 0x4979a00e,
7565 0x4979a00f, 0x4979a010, 0x42000800, 0x0000000b,
7566 0x42001000, 0x0000dc00, 0x0401f32a, 0x0401ff29,
7567 0x4a01a006, 0x0f000000, 0x5930001c, 0x4801a007,
7568 0x42000800, 0x00000002, 0x42001000, 0x0000dc00,
7569 0x0401f320, 0x0401ff2d, 0x4a01a006, 0x02000000,
7570 0x59c40085, 0x48031004, 0x59880000, 0x4801a007,
7571 0x59880001, 0x4801a008, 0x59880002, 0x4801a009,
7572 0x59880003, 0x4801a00a, 0x59880004, 0x4801a00b,
7573 0x59880005, 0x4801a00c, 0x42000800, 0x00000007,
7574 0x42001000, 0x0000dc00, 0x0401f30a, 0x4a026202,
7575 0x0000ffff, 0x0401ff07, 0x4a01a006, 0x62000000,
7576 0x5930001c, 0x4801a007, 0x42000800, 0x00000002,
7577 0x42001000, 0x0000dc00, 0x0401f2fe, 0x0401fefd,
7578 0x59300808, 0x4c500000, 0x4c540000, 0x4c580000,
7579 0x8204a400, 0x0000000a, 0x5930b01c, 0x82d0ac00,
7580 0x00000006, 0x0201f800, 0x0010ab17, 0x5930081c,
7581 0x42001000, 0x0000dc00, 0x5c00b000, 0x5c00a800,
7582 0x5c00a000, 0x0401f2eb, 0x0401ff9b, 0x59300017,
7583 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008,
7584 0x00001000, 0x0401f020, 0x0401ff93, 0x59300017,
7585 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008,
7586 0x00004000, 0x0401f018, 0x0401ff8b, 0x59300017,
7587 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008,
7588 0x00002000, 0x0401f010, 0x0401ff83, 0x59300017,
7589 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008,
7590 0x00000400, 0x0401f008, 0x0401ff7b, 0x59300017,
7591 0x4801a006, 0x59300018, 0x4801a007, 0x4a01a008,
7592 0x00000200, 0x4979a009, 0x4979a00a, 0x4979a00b,
7593 0x4979a00c, 0x4979a00d, 0x42000800, 0x00000008,
7594 0x42001000, 0x0000dc00, 0x0401f2ba, 0x0401fec7,
7595 0x4a01a006, 0x02000014, 0x4979a407, 0x4979a207,
7596 0x59a8003a, 0x4801a008, 0x59a8003b, 0x4801a009,
7597 0x4a01a00a, 0x00047878, 0x42000800, 0x00000005,
7598 0x42001000, 0x0000dc00, 0x0401f2aa, 0x0401feb7,
7599 0x4a01a006, 0x02140018, 0x4a01a407, 0x00000800,
7600 0x5930001c, 0x82000d00, 0xff000000, 0x900409c0,
7601 0x4805a207, 0x82000500, 0x00ffffff, 0x4801a00a,
7602 0x4979a408, 0x4979a208, 0x4979a409, 0x4979a209,
7603 0x4979a00b, 0x42000800, 0x00000006, 0x42001000,
7604 0x0000dc00, 0x0401f293, 0x4803c856, 0x4d380000,
7605 0x4d1c0000, 0x42027000, 0x00000035, 0x0201f800,
7606 0x001093ba, 0x0402001e, 0x0401fe8a, 0x4a01a006,
7607 0x13000000, 0x5932381e, 0x591c0019, 0x4801a005,
7608 0x591c0406, 0x82000580, 0x00000003, 0x04000007,
7609 0x59300809, 0x58040002, 0x82000500, 0x00ffffff,
7610 0x4801a007, 0x0401f003, 0x59a80010, 0x4801a007,
7611 0x59300419, 0x4801a408, 0x59300219, 0x4801a208,
7612 0x42000800, 0x00000003, 0x42001000, 0x0000dc00,
7613 0x5c023800, 0x5c027000, 0x0401f26e, 0x0201f800,
7614 0x00106c55, 0x598c000d, 0x81300580, 0x02020800,
7615 0x001005d8, 0x0201f800, 0x00106bbf, 0x0201f800,
7616 0x0002077d, 0x5c023800, 0x5c027000, 0x0201f000,
7617 0x00106c4b, 0x4803c856, 0x4d2c0000, 0x4d1c0000,
7618 0x5932381e, 0x811e39c0, 0x02000800, 0x001005d8,
7619 0x591c0c06, 0x82040580, 0x00000006, 0x0400000d,
7620 0x82040580, 0x00000003, 0x04000036, 0x4a026403,
7621 0x00000037, 0x4a02641a, 0x00000003, 0x4a02621a,
7622 0x00001700, 0x5c023800, 0x5c025800, 0x0401f064,
7623 0x0401f84b, 0x42001000, 0x40000000, 0x591c0203,
7624 0x591c0804, 0x8c040d3e, 0x04020023, 0x82000c80,
7625 0x0000000e, 0x0c001003, 0x0201f800, 0x001005d8,
7626 0x00107691, 0x0010769d, 0x00107693, 0x0010769d,
7627 0x00107699, 0x00107691, 0x00107691, 0x0010769d,
7628 0x0010769d, 0x00107691, 0x00107691, 0x00107691,
7629 0x00107691, 0x00107691, 0x0010769d, 0x00107691,
7630 0x0010769d, 0x0201f800, 0x001005d8, 0x591c0414,
7631 0x4803c857, 0x8c000518, 0x04000003, 0x8c000512,
7632 0x04000003, 0x80001580, 0x0401f003, 0x42001000,
7633 0x20000000, 0x591c0015, 0x4801a00a, 0x0401f018,
7634 0x0401f81f, 0x591e5808, 0x812e59c0, 0x02000800,
7635 0x001005d8, 0x592c100f, 0x591c0011, 0x80080480,
7636 0x4801a00a, 0x591c0203, 0x591c0804, 0x8c040d3e,
7637 0x04020007, 0x82000d80, 0x00000002, 0x04000007,
7638 0x82000d80, 0x00000004, 0x04000004, 0x42001000,
7639 0x40000000, 0x0401f002, 0x80001580, 0x4809a00b,
7640 0x42000800, 0x00000006, 0x42001000, 0x0000dc00,
7641 0x5c023800, 0x5c025800, 0x0401f1fe, 0x4803c856,
7642 0x0401fe0a, 0x4a01a006, 0x02000000, 0x59300c19,
7643 0x4805a407, 0x59300a19, 0x4805a207, 0x59a81010,
7644 0x59300809, 0x58041802, 0x820c1d00, 0x00ffffff,
7645 0x5930081e, 0x58040406, 0x82000580, 0x00000003,
7646 0x04020004, 0x4809a008, 0x480da009, 0x0401f003,
7647 0x480da008, 0x4809a009, 0x1c01f000, 0x4803c856,
7648 0x0401fdf2, 0x0401f003, 0x4803c856, 0x0401fde8,
7649 0x4a01a006, 0x01000000, 0x5930041a, 0x4801a407,
7650 0x5930021a, 0x4801a207, 0x42000800, 0x00000002,
7651 0x42001000, 0x0000dc00, 0x0401f1d6, 0x4803c856,
7652 0x4d1c0000, 0x0401fdcc, 0x4a01a006, 0x14000000,
7653 0x5932381e, 0x591c0019, 0x4801a005, 0x59300419,
7654 0x4801a407, 0x59300219, 0x4801a207, 0x59300015,
7655 0x4801a008, 0x59300216, 0x82000500, 0x000000ff,
7656 0x840001c0, 0x4801a409, 0x42000800, 0x00000004,
7657 0x42001000, 0x0000dc00, 0x5c023800, 0x0401f1bd,
7658 0x4803c856, 0x0401f80b, 0x5930041a, 0x900001c0,
7659 0x4801a005, 0x0401f9ec, 0x41780800, 0x42001000,
7660 0x00005c00, 0x0401f9b3, 0x0201f000, 0x0010604d,
7661 0x4803c856, 0x59300817, 0x82041c00, 0x00000005,
7662 0x46034800, 0x00000021, 0x58040404, 0x82000500,
7663 0x0000f000, 0x82000580, 0x00003000, 0x04000003,
7664 0x46034800, 0x00000041, 0x81a5a000, 0x580c0001,
7665 0x82000d00, 0x00ffffff, 0x82040d40, 0xc2000000,
7666 0x4805a000, 0x580c0800, 0x82041500, 0x00ffffff,
7667 0x82000500, 0xff000000, 0x80080540, 0x4801a001,
7668 0x580c0002, 0x82000580, 0x00c00000, 0x82000500,
7669 0x00fd0300, 0x4801a002, 0x580c0003, 0x4801a003,
7670 0x580c0404, 0x4801a404, 0x580c0204, 0x4801a204,
7671 0x1c01f000, 0x4803c856, 0x59a80026, 0x82000500,
7672 0x00000028, 0x04020009, 0x59a80026, 0x82000500,
7673 0x00000028, 0x04000003, 0x497a6a12, 0x0401f003,
7674 0x4a026a12, 0x0000ff00, 0x42005000, 0x22000000,
7675 0x42006000, 0x01380000, 0x41786800, 0x41787800,
7676 0x0401f952, 0x59301008, 0x4a01a006, 0x54000000,
7677 0x59a80010, 0x82000500, 0x00ffffff, 0x58080c0a,
7678 0x800408f0, 0x80040540, 0x4801a007, 0x5808000a,
7679 0x82000500, 0xff000000, 0x4801a008, 0x59a80002,
7680 0x4801a009, 0x59a80003, 0x4801a00a, 0x59a80000,
7681 0x4801a00b, 0x59a80001, 0x4801a00c, 0x5808000c,
7682 0x9c0001c0, 0x4801a00d, 0x5808000d, 0x9c0001c0,
7683 0x4801a00e, 0x5808000e, 0x9c0001c0, 0x4801a00f,
7684 0x5808000f, 0x9c0001c0, 0x4801a010, 0x58080010,
7685 0x9c0001c0, 0x4801a011, 0x58080011, 0x9c0001c0,
7686 0x4801a012, 0x58080012, 0x9c0001c0, 0x4801a013,
7687 0x58080013, 0x9c0001c0, 0x4801a014, 0x58080010,
7688 0x9c0001c0, 0x4801a015, 0x58080011, 0x9c0001c0,
7689 0x4801a016, 0x58080012, 0x9c0001c0, 0x4801a017,
7690 0x58080013, 0x9c0001c0, 0x4801a018, 0x42000800,
7691 0x00000013, 0x42001000, 0x0000dc00, 0x0401f135,
7692 0x4803c856, 0x42005000, 0x22000000, 0x42006000,
7693 0x01290000, 0x41786800, 0x41787800, 0x0401f90b,
7694 0x59301008, 0x4a01a006, 0x55000000, 0x5808000b,
7695 0x82000500, 0x00ffffff, 0x58080c0a, 0x800408f0,
7696 0x80040540, 0x4801a007, 0x5808080a, 0x82040d00,
7697 0xff000000, 0x59a80010, 0x82000500, 0x00ffffff,
7698 0x80040540, 0x4801a008, 0x5808000c, 0x9c0001c0,
7699 0x4801a009, 0x5808000d, 0x9c0001c0, 0x4801a00a,
7700 0x5808000e, 0x9c0001c0, 0x4801a00b, 0x5808000f,
7701 0x9c0001c0, 0x4801a00c, 0x59a80002, 0x4801a00d,
7702 0x59a80003, 0x4801a00e, 0x59a80000, 0x4801a00f,
7703 0x59a80001, 0x4801a010, 0x58080010, 0x4801a011,
7704 0x58080011, 0x4801a012, 0x58080012, 0x4801a013,
7705 0x58080013, 0x4801a014, 0x4979a015, 0x4979a016,
7706 0x4979a017, 0x4979a018, 0x42000800, 0x00000013,
7707 0x42001000, 0x0000dc00, 0x0401f0f6, 0x0401fd03,
7708 0x5930001c, 0x800001c0, 0x04000008, 0x4a01a006,
7709 0x01000000, 0x4a01a407, 0x00000003, 0x42000800,
7710 0x00000002, 0x0401f028, 0x4a01a006, 0x02000000,
7711 0x41780800, 0x836c0580, 0x00000004, 0x04020003,
7712 0x84040d42, 0x0401f00d, 0x0201f800, 0x0010513b,
7713 0x04020003, 0x84040d4a, 0x0401f002, 0x84040d48,
7714 0x59a80026, 0x8c000506, 0x04020003, 0x8c00050a,
7715 0x04000002, 0x84040d46, 0x4805a207, 0x59c40085,
7716 0x48031004, 0x4c580000, 0x4c500000, 0x4c540000,
7717 0x4200b000, 0x00000006, 0x8388a400, 0x00000000,
7718 0x82d0ac00, 0x00000008, 0x0201f800, 0x0010ab17,
7719 0x5c00a800, 0x5c00a000, 0x5c00b000, 0x42000800,
7720 0x00000008, 0x42001000, 0x0000dc00, 0x0401f0c1,
7721 0x0401fcc0, 0x4a01a006, 0x56000000, 0x59340006,
7722 0x4801a007, 0x59340007, 0x4801a008, 0x42000800,
7723 0x00000003, 0x42001000, 0x0000dc00, 0x0401f0b5,
7724 0x4803c856, 0x0401fcc1, 0x5930081c, 0x800409c0,
7725 0x0400000e, 0x82040580, 0x0000ffff, 0x04000004,
7726 0x82040480, 0x00000007, 0x04021008, 0x4a01a006,
7727 0x01000000, 0x4a01a407, 0x00000003, 0x42000800,
7728 0x00000002, 0x0401f012, 0x4a01a006, 0x0200001c,
7729 0x4a01a007, 0x00000001, 0x42001000, 0x0010b4f0,
7730 0x50080000, 0x9c0001c0, 0x4801a009, 0x59a80010,
7731 0x4801a00a, 0x59a80002, 0x59a80803, 0x4801a00b,
7732 0x4805a00c, 0x42000800, 0x00000007, 0x42001000,
7733 0x0000dc00, 0x0401f08f, 0x4d2c0000, 0x0401fc8d,
7734 0x59325808, 0x592c0008, 0x82000500, 0x00ffffff,
7735 0x4801a001, 0x4a01a006, 0x51000000, 0x5c025800,
7736 0x0201f000, 0x00107344, 0x4803c856, 0x59a80810,
7737 0x82040d00, 0x000000ff, 0x59325808, 0x59326809,
7738 0x59a83026, 0x8c18350a, 0x04020008, 0x8c00050e,
7739 0x04020006, 0x80001d80, 0x59a82010, 0x82102500,
7740 0x000000ff, 0x0401f001, 0x59300406, 0x4803c857,
7741 0x82000d80, 0x00000009, 0x04000006, 0x82000d80,
7742 0x0000000a, 0x0400002e, 0x0201f800, 0x001005d8,
7743 0x59300015, 0x8c00051e, 0x04020020, 0x42005000,
7744 0x04000000, 0x42006000, 0x05000000, 0x592c040a,
7745 0x82000500, 0x00000030, 0x800000e0, 0x80306540,
7746 0x5934000a, 0x8c000508, 0x04000002, 0x84306546,
7747 0x41786800, 0x41787800, 0x0401f831, 0x59300c14,
7748 0x80040000, 0x48026414, 0x40040000, 0x800000d0,
7749 0x82000540, 0x00000020, 0x4801a403, 0x83180d40,
7750 0x00000038, 0x42001000, 0x0000c920, 0x0401f860,
7751 0x0201f000, 0x00106052, 0x59a80026, 0x82000500,
7752 0x00000028, 0x04000003, 0x497a6a12, 0x0401f7dc,
7753 0x4a026a12, 0x0000ff00, 0x0401f7d9, 0x42005000,
7754 0x02000000, 0x42006000, 0x20290000, 0x41786800,
7755 0x41787800, 0x0401f812, 0x83180d40, 0x00000038,
7756 0x42001000, 0x0000c9a0, 0x0401f849, 0x42000800,
7757 0x000007d0, 0x59300011, 0x82000500, 0xfff00000,
7758 0x80000540, 0x04000003, 0x42000800, 0x00001b58,
7759 0x41781000, 0x0201f000, 0x00106054, 0x4201a000,
7760 0x00000000, 0x0401f003, 0x4201a000, 0x00000011,
7761 0x59340a12, 0x82040d00, 0x0000ff00, 0x59a80010,
7762 0x82000500, 0x000000ff, 0x900001c0, 0x80040540,
7763 0x80d00540, 0x44034800, 0x81a5a000, 0x59340002,
7764 0x82000500, 0x00ffffff, 0x80280540, 0x4801a000,
7765 0x59a80010, 0x4801a001, 0x4831a002, 0x82340540,
7766 0x00000000, 0x4801a003, 0x59300402, 0x4801a404,
7767 0x59300a02, 0x4805a204, 0x8c30652e, 0x04000003,
7768 0x4805a404, 0x4801a204, 0x483da005, 0x1c01f000,
7769 0x4803c856, 0x4c040000, 0x0401f822, 0x5c000800,
7770 0x40040000, 0x80081540, 0x800000c4, 0x82000540,
7771 0x00002000, 0x4803910a, 0x59b400f6, 0x82000500,
7772 0x00000018, 0x040207fd, 0x4a0368f0, 0x0010b544,
7773 0x4a0368f1, 0x0010b54b, 0x480b68f3, 0x4a0378e4,
7774 0x00008000, 0x0201f000, 0x0010604d, 0x4807c857,
7775 0x480a2800, 0x4c040000, 0x0401f80a, 0x5c000800,
7776 0x59b400f6, 0x8c00050a, 0x040207fe, 0x49a768f2,
7777 0x480768f4, 0x4a0378e4, 0x00008000, 0x1c01f000,
7778 0x4a0378e4, 0x0000c000, 0x59bc00e4, 0x8c000520,
7779 0x0400000c, 0x4a0378e4, 0x00008000, 0x42007000,
7780 0x000003e8, 0x59bc00e4, 0x8c000520, 0x040007f5,
7781 0x80387040, 0x02000800, 0x001005d8, 0x0401f7fa,
7782 0x1c01f000, 0x82000500, 0xffff0000, 0x82000580,
7783 0x01050000, 0x0402000d, 0x599c0818, 0x8c040d10,
7784 0x0400000a, 0x59a80807, 0x8c040d0a, 0x04000007,
7785 0x42001000, 0x0000804f, 0x41781800, 0x41782000,
7786 0x0201f800, 0x00103a3e, 0x1c01f000, 0x41781000,
7787 0x42026000, 0x0010d1c0, 0x59a8180e, 0x480a6402,
7788 0x4a026202, 0x0000ffff, 0x80081000, 0x800c1840,
7789 0x04000004, 0x83326400, 0x00000024, 0x0401f7f8,
7790 0x1c01f000, 0x4933c857, 0x59300203, 0x82000580,
7791 0x00000000, 0x0400002c, 0x59300406, 0x4803c857,
7792 0x82000d80, 0x00000004, 0x04000011, 0x82000d80,
7793 0x00000001, 0x0400000e, 0x82000d80, 0x00000003,
7794 0x04000006, 0x82000d80, 0x00000006, 0x04020011,
7795 0x0201f800, 0x0010a5df, 0x5930001c, 0x800001c0,
7796 0x02020800, 0x0010984e, 0x0401f00a, 0x5930081e,
7797 0x4807c857, 0x800409c0, 0x04000006, 0x5804001c,
7798 0x4803c857, 0x81300580, 0x04020002, 0x4978081c,
7799 0x497a6008, 0x4a026004, 0x00004000, 0x59a80037,
7800 0x82000c80, 0x00000051, 0x04001002, 0x80000102,
7801 0x48026206, 0x497a6205, 0x497a6009, 0x4a026406,
7802 0x00000007, 0x1c01f000, 0x8166c9c0, 0x0400001c,
7803 0x41626000, 0x41580000, 0x59300a03, 0x82040d80,
7804 0x00000000, 0x04000008, 0x83326400, 0x00000024,
7805 0x81300c80, 0x040017f9, 0x42026000, 0x0010d1c0,
7806 0x0401f7f6, 0x4933c857, 0x8166c840, 0x83300c00,
7807 0x00000024, 0x80040480, 0x04021006, 0x4006c000,
7808 0x4a026203, 0x00000008, 0x813261c0, 0x1c01f000,
7809 0x4202c000, 0x0010d1c0, 0x0401f7fa, 0x42000000,
7810 0x0010b854, 0x0201f800, 0x0010aa47, 0x4933c856,
7811 0x417a6000, 0x0401f7f5, 0x4933c857, 0x83380580,
7812 0x00000013, 0x0402000b, 0x59300004, 0x8c00053e,
7813 0x04000007, 0x0201f800, 0x00106c55, 0x0201f800,
7814 0x00106bbf, 0x0201f800, 0x00106c4b, 0x1c01f000,
7815 0x4933c857, 0x59880052, 0x80000000, 0x48031052,
7816 0x1c01f000, 0x4933c857, 0x59300203, 0x82003480,
7817 0x0000000e, 0x02021800, 0x001005d8, 0x4d2c0000,
7818 0x0c01f803, 0x5c025800, 0x1c01f000, 0x00107991,
7819 0x00107efd, 0x0010804a, 0x00107991, 0x001080b0,
7820 0x00107af5, 0x00107991, 0x00107991, 0x00107e93,
7821 0x00107991, 0x00107991, 0x00107991, 0x00107991,
7822 0x00107991, 0x0201f800, 0x001005d8, 0x4933c857,
7823 0x59300203, 0x82003480, 0x0000000e, 0x02021800,
7824 0x001005d8, 0x0c01f001, 0x001079a8, 0x00108a3d,
7825 0x001079a8, 0x001079a8, 0x001079a8, 0x001079a8,
7826 0x001079a8, 0x001079a8, 0x001089e5, 0x00108a58,
7827 0x00108ac6, 0x00108a58, 0x00108ac6, 0x001079a8,
7828 0x0201f800, 0x001005d8, 0x0201f800, 0x001005d8,
7829 0x4933c857, 0x4d2c0000, 0x59325808, 0x59300203,
7830 0x82003480, 0x0000000e, 0x02021800, 0x001005d8,
7831 0x0c01f803, 0x5c025800, 0x1c01f000, 0x001079c5,
7832 0x001079c5, 0x001079c5, 0x001079e1, 0x00107a2d,
7833 0x001079c5, 0x001079c5, 0x001079c5, 0x001079c7,
7834 0x001079c5, 0x001079c5, 0x001079c5, 0x001079c5,
7835 0x001079c5, 0x0201f800, 0x001005d8, 0x4933c857,
7836 0x83380580, 0x00000040, 0x02020800, 0x001005d8,
7837 0x4a026007, 0x00082000, 0x4a026203, 0x00000003,
7838 0x493a6403, 0x4a025c08, 0x00000001, 0x592c000d,
7839 0x48026011, 0x497a6013, 0x592c0208, 0x800000c2,
7840 0x800010c4, 0x80081400, 0x480a6206, 0x0201f800,
7841 0x00100f4e, 0x42000800, 0x80000060, 0x0201f000,
7842 0x00106721, 0x4933c857, 0x83380480, 0x00000050,
7843 0x02021800, 0x001005d8, 0x83380480, 0x00000049,
7844 0x02001800, 0x001005d8, 0x0c01f001, 0x001079f4,
7845 0x001079ff, 0x001079f2, 0x001079f2, 0x001079f2,
7846 0x001079f2, 0x00107a0a, 0x0201f800, 0x001005d8,
7847 0x4a026203, 0x00000004, 0x4a025c08, 0x00000002,
7848 0x592c0207, 0x48025c09, 0x592c0209, 0x48025a07,
7849 0x592c000c, 0x4802580d, 0x1c01f000, 0x0201f800,
7850 0x00106b8a, 0x0201f800, 0x00109037, 0x04000005,
7851 0x4a025a06, 0x00000006, 0x0201f800, 0x000202da,
7852 0x0201f000, 0x0002077d, 0x0201f800, 0x00106b8a,
7853 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c,
7854 0x5c027800, 0x42003000, 0x00000014, 0x41782800,
7855 0x42002000, 0x00000002, 0x4d400000, 0x4d440000,
7856 0x59368c03, 0x42028000, 0x00000029, 0x0201f800,
7857 0x0010985e, 0x5c028800, 0x5c028000, 0x42000000,
7858 0x0010b864, 0x0201f800, 0x0010aa47, 0x0201f800,
7859 0x00109037, 0x02000000, 0x0002077d, 0x4a025a06,
7860 0x00000029, 0x0201f800, 0x000202da, 0x0201f000,
7861 0x0002077d, 0x4933c857, 0x83380580, 0x00000048,
7862 0x04000005, 0x83380580, 0x00000053, 0x02020800,
7863 0x001005d8, 0x592c0206, 0x82000580, 0x00000007,
7864 0x04000009, 0x59300011, 0x80000540, 0x04000006,
7865 0x592c080c, 0x80040480, 0x4802580c, 0x4a025a06,
7866 0x00000015, 0x592c0206, 0x80000540, 0x04020003,
7867 0x4a025a06, 0x00000000, 0x0201f800, 0x000202da,
7868 0x0201f000, 0x0002077d, 0x4933c857, 0x4d2c0000,
7869 0x4c500000, 0x4c540000, 0x4c580000, 0x0201f800,
7870 0x001007e4, 0x02000800, 0x001005d8, 0x497a5a06,
7871 0x59c80017, 0x82000500, 0x0000f000, 0x48025c07,
7872 0x59a80816, 0x82040c00, 0x00000018, 0x48065a07,
7873 0x412c7800, 0x4d2c0000, 0x41cca000, 0x42002800,
7874 0x00000001, 0x42001000, 0x0000002c, 0x82040480,
7875 0x0000002d, 0x04021006, 0x832cac00, 0x00000009,
7876 0x0201f800, 0x00108b96, 0x0401f02e, 0x40043000,
7877 0x42000800, 0x0000002c, 0x832cac00, 0x00000009,
7878 0x0201f800, 0x00108b96, 0x82183480, 0x0000002c,
7879 0x0201f800, 0x001007e4, 0x0400001a, 0x80142800,
7880 0x4a025804, 0x00000110, 0x492c7801, 0x82180c80,
7881 0x0000003d, 0x04021007, 0x40180800, 0x832cac00,
7882 0x00000005, 0x0201f800, 0x00108b96, 0x0401f015,
7883 0x82081400, 0x0000003c, 0x82183480, 0x0000003c,
7884 0x42000800, 0x0000003c, 0x412c7800, 0x832cac00,
7885 0x00000005, 0x0201f800, 0x00108b96, 0x0401f7e5,
7886 0x5c025800, 0x592c0206, 0x8400055e, 0x48025a06,
7887 0x592c0407, 0x80080540, 0x48025c07, 0x0401f002,
7888 0x5c025800, 0x813669c0, 0x04000003, 0x59343403,
7889 0x0401f003, 0x42003000, 0x0000ffff, 0x49325808,
7890 0x481a5c06, 0x82100580, 0x00000054, 0x04020002,
7891 0x491e5813, 0x841401c0, 0x80100540, 0x48025804,
7892 0x592c0001, 0x497a5801, 0x4c000000, 0x0201f800,
7893 0x000202da, 0x5c025800, 0x812e59c0, 0x040207f9,
7894 0x5c00b000, 0x5c00a800, 0x5c00a000, 0x5c025800,
7895 0x1c01f000, 0x4803c856, 0x4c5c0000, 0x4d2c0000,
7896 0x4c500000, 0x4c540000, 0x4c580000, 0x412cb800,
7897 0x592c040b, 0x8c000516, 0x04000003, 0x41cca000,
7898 0x0401f003, 0x83cca400, 0x00000006, 0x4008b000,
7899 0x41781000, 0x82580480, 0x00000012, 0x04001004,
7900 0x4200b000, 0x00000012, 0x40001000, 0x4c080000,
7901 0x4d2c0000, 0x0201f800, 0x001007e4, 0x04000023,
7902 0x5c001800, 0x492c1801, 0x485a5800, 0x832cac00,
7903 0x00000002, 0x0201f800, 0x0010ab28, 0x585c040b,
7904 0x8c000500, 0x0400000e, 0x832c1400, 0x00000002,
7905 0x8c000516, 0x04000003, 0x82081400, 0x00000006,
7906 0x46001000, 0x00000001, 0x80081000, 0x46001000,
7907 0x00000900, 0x84000500, 0x4800bc0b, 0x5c001000,
7908 0x800811c0, 0x040207da, 0x82000540, 0x00000001,
7909 0x5c00b000, 0x5c00a800, 0x5c00a000, 0x5c025800,
7910 0x5c00b800, 0x1c01f000, 0x5c025800, 0x5c001000,
7911 0x0401f7f8, 0x4933c857, 0x83380d80, 0x00000015,
7912 0x04020003, 0x0201f000, 0x0002077d, 0x83380d80,
7913 0x00000016, 0x02020800, 0x001005d8, 0x0201f000,
7914 0x0002077d, 0x4933c857, 0x4d2c0000, 0x4c500000,
7915 0x4c540000, 0x4c580000, 0x59325808, 0x83cca400,
7916 0x00000006, 0x59cc1806, 0x820c0580, 0x01000000,
7917 0x04020004, 0x4200b000, 0x00000002, 0x0401f00f,
7918 0x4200b000, 0x00000008, 0x832cac00, 0x00000005,
7919 0x0201f800, 0x0010ab17, 0x8c0c1d00, 0x0400000b,
7920 0x4200b000, 0x00000008, 0x592e5801, 0x812e59c0,
7921 0x02000800, 0x001005d8, 0x832cac00, 0x00000005,
7922 0x0201f800, 0x0010ab17, 0x0401f816, 0x5c00b000,
7923 0x5c00a800, 0x5c00a000, 0x5c025800, 0x1c01f000,
7924 0x4933c857, 0x4c500000, 0x4c540000, 0x4c580000,
7925 0x83cca400, 0x00000006, 0x5930a808, 0x8254ac00,
7926 0x00000005, 0x4200b000, 0x00000007, 0x0201f800,
7927 0x0010ab17, 0x5c00b000, 0x5c00a800, 0x5c00a000,
7928 0x4933c857, 0x0201f800, 0x00109037, 0x02000000,
7929 0x0002077d, 0x4d2c0000, 0x0201f800, 0x00109597,
7930 0x0402000b, 0x41780800, 0x4d400000, 0x42028000,
7931 0x00000000, 0x0201f800, 0x0010943b, 0x5c028000,
7932 0x5c025800, 0x0201f000, 0x0002077d, 0x5931d821,
7933 0x58ef400b, 0x58ee580d, 0x4a025a04, 0x00000103,
7934 0x58ec0009, 0x0801f800, 0x5c025800, 0x0201f000,
7935 0x0002077d, 0x4933c857, 0x59cc1806, 0x820c0580,
7936 0x02000000, 0x04020014, 0x4a026802, 0x00fffffd,
7937 0x5934000a, 0x84000504, 0x4802680a, 0x59300808,
7938 0x800409c0, 0x02000000, 0x0002077d, 0x4a000a04,
7939 0x00000103, 0x480c0805, 0x5931d821, 0x58ef400b,
7940 0x58ee580d, 0x58ec0009, 0x0801f800, 0x0201f000,
7941 0x0002077d, 0x42000000, 0x0010b86c, 0x0201f800,
7942 0x0010aa47, 0x4c0c0000, 0x0401f804, 0x5c001800,
7943 0x040207eb, 0x1c01f000, 0x4933c857, 0x4d2c0000,
7944 0x59325808, 0x812e59c0, 0x04020009, 0x497a6206,
7945 0x497a6205, 0x4d380000, 0x42027000, 0x00000022,
7946 0x0401fb77, 0x5c027000, 0x80000580, 0x5c025800,
7947 0x1c01f000, 0x4933c857, 0x4d2c0000, 0x4c500000,
7948 0x4c540000, 0x4c580000, 0x59325808, 0x592e5801,
7949 0x832cac00, 0x00000005, 0x83cca400, 0x00000006,
7950 0x59c80817, 0x82040d00, 0x000003ff, 0x82041480,
7951 0x0000000f, 0x0400101b, 0x4200b000, 0x0000000f,
7952 0x0201f800, 0x0010ab17, 0x592e5801, 0x832cac00,
7953 0x00000005, 0x82080c80, 0x0000000f, 0x0400100d,
7954 0x4200b000, 0x0000000f, 0x0201f800, 0x0010ab17,
7955 0x592e5801, 0x832cac00, 0x00000005, 0x82041480,
7956 0x0000000f, 0x04001007, 0x42001000, 0x0000000f,
7957 0x4008b000, 0x0201f800, 0x0010ab17, 0x0401f004,
7958 0x4004b000, 0x0201f800, 0x0010ab17, 0x5931d821,
7959 0x58ef400b, 0x58ee580d, 0x4a025a04, 0x00000103,
7960 0x592e5801, 0x58ec0009, 0x0801f800, 0x0201f800,
7961 0x0002077d, 0x5c00b000, 0x5c00a800, 0x5c00a000,
7962 0x5c025800, 0x1c01f000, 0x4933c857, 0x4d2c0000,
7963 0x4c500000, 0x4c540000, 0x4c580000, 0x59cc0006,
7964 0x82000d80, 0x01000000, 0x0400002c, 0x59cc0007,
7965 0x9000b1c0, 0x8258b500, 0x000000ff, 0x8058b104,
7966 0x8258b400, 0x00000002, 0x82580c80, 0x00000007,
7967 0x04001003, 0x4200b000, 0x00000006, 0x83cca400,
7968 0x00000006, 0x59301008, 0x800811c0, 0x02000800,
7969 0x001005d8, 0x8208ac00, 0x00000005, 0x0201f800,
7970 0x0010ab17, 0x82000d00, 0xff000000, 0x800409c0,
7971 0x04000019, 0x8200b500, 0x000000ff, 0x8058b104,
7972 0x82580c80, 0x0000000e, 0x04001003, 0x4200b000,
7973 0x0000000d, 0x58081001, 0x800811c0, 0x02000800,
7974 0x001005d8, 0x8208ac00, 0x00000005, 0x0201f800,
7975 0x0010ab17, 0x0401f008, 0x59301008, 0x800811c0,
7976 0x02000800, 0x001005d8, 0x48001005, 0x59cc0007,
7977 0x48001006, 0x0401ff3b, 0x5c00b000, 0x5c00a800,
7978 0x5c00a000, 0x5c025800, 0x1c01f000, 0x4933c857,
7979 0x42000800, 0x00000000, 0x59cc0006, 0x82000580,
7980 0x02000000, 0x04000003, 0x42000800, 0x00000001,
7981 0x4d2c0000, 0x59325808, 0x812e59c0, 0x02000800,
7982 0x001005d8, 0x48065a06, 0x0201f800, 0x000202da,
7983 0x5c025800, 0x0201f000, 0x0002077d, 0x4933c857,
7984 0x4d2c0000, 0x4c500000, 0x4c540000, 0x4c580000,
7985 0x4200b000, 0x00000002, 0x59cc0806, 0x82040580,
7986 0x01000000, 0x04000004, 0x8204b500, 0x0000ffff,
7987 0x8058b104, 0x83cca400, 0x00000006, 0x59300008,
7988 0x8200ac00, 0x00000005, 0x0201f800, 0x0010ab17,
7989 0x0401ff0c, 0x5c00b000, 0x5c00a800, 0x5c00a000,
7990 0x5c025800, 0x1c01f000, 0x4933c857, 0x4803c857,
7991 0x4807c857, 0x480bc857, 0x480fc857, 0x4813c857,
7992 0x481bc857, 0x492fc857, 0x4d2c0000, 0x4c000000,
7993 0x0201f800, 0x001007d3, 0x5c000000, 0x0400000f,
7994 0x48025803, 0x5c000000, 0x4802580a, 0x4c000000,
7995 0x481a5801, 0x48125809, 0x48065804, 0x480a5807,
7996 0x480e5808, 0x412c1000, 0x0201f800, 0x00100858,
7997 0x82000540, 0x00000001, 0x5c025800, 0x1c01f000,
7998 0x4933c857, 0x4d1c0000, 0x59cc0001, 0x82000500,
7999 0x00ffffff, 0x59341002, 0x82081500, 0x00ffffff,
8000 0x80080580, 0x0402001f, 0x497a6205, 0x4d380000,
8001 0x42027000, 0x00000035, 0x0201f800, 0x001093ba,
8002 0x5c027000, 0x04020012, 0x591c001c, 0x800001c0,
8003 0x0400000f, 0x497a381c, 0x591c0414, 0x8c000502,
8004 0x02000800, 0x001005d8, 0x84000502, 0x48023c14,
8005 0x591c1406, 0x82080580, 0x00000003, 0x04000006,
8006 0x82080580, 0x00000006, 0x04000005, 0x0401fc9e,
8007 0x0401f004, 0x0401f805, 0x0401f002, 0x0401f8c0,
8008 0x5c023800, 0x1c01f000, 0x4d2c0000, 0x591e5808,
8009 0x4933c857, 0x491fc857, 0x493bc857, 0x492fc857,
8010 0x83380580, 0x00000015, 0x040000b3, 0x83380580,
8011 0x00000016, 0x040200ae, 0x4d300000, 0x411e6000,
8012 0x59cc0207, 0x4803c857, 0x82000d00, 0x0000ff00,
8013 0x82040580, 0x00001700, 0x04000004, 0x82040580,
8014 0x00000300, 0x0402005b, 0x591c0203, 0x4803c857,
8015 0x82000580, 0x0000000d, 0x0400003f, 0x812e59c0,
8016 0x0400009a, 0x591c0202, 0x4803c857, 0x82000580,
8017 0x0000ffff, 0x0402007e, 0x592c020a, 0x4803c857,
8018 0x82000500, 0x00000003, 0x82000580, 0x00000002,
8019 0x04020007, 0x592c080f, 0x591c0011, 0x4803c857,
8020 0x4807c857, 0x80040580, 0x04020071, 0x591c0414,
8021 0x4803c857, 0x8c000500, 0x0402006d, 0x41780800,
8022 0x591c1206, 0x42000000, 0x0000000a, 0x0201f800,
8023 0x001066a0, 0x592c0406, 0x4803c857, 0x800001c0,
8024 0x0400000c, 0x80080c80, 0x04001004, 0x02020800,
8025 0x001005d8, 0x80001040, 0x480a5c06, 0x800811c0,
8026 0x04020004, 0x0201f800, 0x00108d88, 0x0401f06b,
8027 0x0201f800, 0x0010912a, 0x591c0817, 0x591c0018,
8028 0x48065808, 0x48025809, 0x59300007, 0x8c000500,
8029 0x02020800, 0x00100e99, 0x497a3808, 0x0201f800,
8030 0x000201ba, 0x0402004a, 0x411e6000, 0x0401fc3e,
8031 0x0401f05a, 0x0401fc6d, 0x04000013, 0x49366009,
8032 0x4a026406, 0x00000003, 0x492e6008, 0x591c0817,
8033 0x591c1018, 0x48066017, 0x480a6018, 0x4d380000,
8034 0x591e7403, 0x4d300000, 0x411e6000, 0x0401fc2e,
8035 0x5c026000, 0x0201f800, 0x000207a1, 0x5c027000,
8036 0x0401f046, 0x59a80039, 0x48023a05, 0x0401f043,
8037 0x59cc0407, 0x82000580, 0x0000000b, 0x04020025,
8038 0x59340a00, 0x84040d0e, 0x48066a00, 0x592c0a04,
8039 0x82040d00, 0x000000ff, 0x82040d80, 0x00000014,
8040 0x04000003, 0x4a02621d, 0x00000003, 0x59300007,
8041 0x8c000500, 0x02020800, 0x00100e99, 0x4d400000,
8042 0x42028000, 0x00000003, 0x592c0a08, 0x0201f800,
8043 0x00104e70, 0x0201f800, 0x000202da, 0x5c028000,
8044 0x497a6008, 0x4a026403, 0x00000085, 0x4a026203,
8045 0x00000009, 0x4a026406, 0x00000002, 0x42000800,
8046 0x8000404b, 0x0201f800, 0x00020721, 0x0401f01b,
8047 0x59cc0207, 0x82000580, 0x00002a00, 0x04020004,
8048 0x59a80039, 0x48023a05, 0x0401f014, 0x812e59c0,
8049 0x02000800, 0x001005d8, 0x4a025a04, 0x00000103,
8050 0x591c0007, 0x8c000500, 0x02020800, 0x00100e99,
8051 0x591c0402, 0x48025c06, 0x4a025a06, 0x00000003,
8052 0x0201f800, 0x000202c1, 0x0201f800, 0x00107911,
8053 0x0201f800, 0x001049b2, 0x5c026000, 0x0201f800,
8054 0x0002077d, 0x0401f002, 0x5c026000, 0x5c025800,
8055 0x1c01f000, 0x0401f819, 0x0401f7fd, 0x4933c857,
8056 0x83380580, 0x00000015, 0x04020004, 0x59a80039,
8057 0x48023a05, 0x0401f00d, 0x83380580, 0x00000016,
8058 0x0402000d, 0x4d300000, 0x411e6000, 0x0201f800,
8059 0x0010a5df, 0x0201f800, 0x000206fd, 0x0201f800,
8060 0x0002077d, 0x5c026000, 0x497a381c, 0x0201f800,
8061 0x0002077d, 0x1c01f000, 0x591c0414, 0x84000540,
8062 0x48023c14, 0x59cc100b, 0x4933c857, 0x491fc857,
8063 0x492fc857, 0x4803c857, 0x480bc857, 0x8c08153c,
8064 0x04000006, 0x59a80039, 0x48023a05, 0x497a381c,
8065 0x0201f000, 0x0002077d, 0x4d300000, 0x411e6000,
8066 0x0201f800, 0x00108bd7, 0x5c026000, 0x591c0406,
8067 0x82000580, 0x00000000, 0x02000000, 0x0002077d,
8068 0x591c0403, 0x82000580, 0x00000050, 0x0402000d,
8069 0x4d300000, 0x411e6000, 0x4a026203, 0x00000001,
8070 0x42000800, 0x80000043, 0x0201f800, 0x00020721,
8071 0x5c026000, 0x497a381c, 0x0201f000, 0x0002077d,
8072 0x591c0203, 0x82000580, 0x0000000d, 0x04000014,
8073 0x812e59c0, 0x02000800, 0x001005d8, 0x591c0203,
8074 0x82000580, 0x00000004, 0x04020011, 0x592c020a,
8075 0x8c000502, 0x0400000e, 0x4a023812, 0x0fffffff,
8076 0x592c0208, 0x8400051e, 0x48025a08, 0x42000000,
8077 0x00000001, 0x48023a14, 0x0401f021, 0x42000000,
8078 0x00000007, 0x48023a14, 0x0401f01d, 0x592c020a,
8079 0x4803c857, 0x8c000500, 0x0402000b, 0x8c000502,
8080 0x040007f7, 0x591c0414, 0x8c00051c, 0x040207eb,
8081 0x591c0011, 0x4803c857, 0x800001c0, 0x040007f0,
8082 0x0401f7e6, 0x8c08153a, 0x040207ed, 0x59cc000a,
8083 0x592c180f, 0x4803c857, 0x480fc857, 0x800c0580,
8084 0x040007e7, 0x59cc000a, 0x4803c857, 0x48023816,
8085 0x42000000, 0x00000005, 0x48023a14, 0x0201f000,
8086 0x00109259, 0x4933c857, 0x4d1c0000, 0x59cc0001,
8087 0x59341002, 0x80080580, 0x82000500, 0x00ffffff,
8088 0x04020041, 0x59301419, 0x0201f800, 0x00109410,
8089 0x02000800, 0x001005d8, 0x591c1406, 0x82080580,
8090 0x00000007, 0x04000038, 0x82080580, 0x00000002,
8091 0x04000035, 0x82080580, 0x00000000, 0x04000032,
8092 0x591c0202, 0x82000d80, 0x0000ffff, 0x04000004,
8093 0x59301a19, 0x800c0580, 0x0402002b, 0x83380580,
8094 0x00000015, 0x04000026, 0x4d300000, 0x4d2c0000,
8095 0x411e6000, 0x59325808, 0x0201f800, 0x00109037,
8096 0x02000800, 0x001005d8, 0x592c0204, 0x82000500,
8097 0x000000ff, 0x82000580, 0x00000014, 0x04000003,
8098 0x4a02621d, 0x00000003, 0x42028000, 0x00000003,
8099 0x592c0a08, 0x0201f800, 0x00104e70, 0x0201f800,
8100 0x000202da, 0x5c025800, 0x497a6008, 0x4a026403,
8101 0x00000085, 0x4a026203, 0x00000009, 0x4a026406,
8102 0x00000002, 0x42000800, 0x8000404b, 0x0201f800,
8103 0x00020721, 0x5c026000, 0x0401f003, 0x59a80039,
8104 0x48023a05, 0x497a381c, 0x0201f800, 0x0002077d,
8105 0x5c023800, 0x1c01f000, 0x4933c857, 0x4c580000,
8106 0x4d2c0000, 0x59325808, 0x83383580, 0x00000015,
8107 0x04000010, 0x59342200, 0x84102502, 0x48126a00,
8108 0x0201f800, 0x00109037, 0x04000066, 0x0201f800,
8109 0x00109597, 0x04020005, 0x4200b000, 0x00000002,
8110 0x0201f800, 0x0010957d, 0x0401fa0a, 0x0401f079,
8111 0x83cc1400, 0x00000008, 0x4200b000, 0x00000002,
8112 0x83341c00, 0x00000006, 0x0201f800, 0x0010855a,
8113 0x04020015, 0x83cc1400, 0x0000000a, 0x4200b000,
8114 0x00000002, 0x83341c00, 0x00000008, 0x0201f800,
8115 0x0010855a, 0x0402000c, 0x0201f800, 0x00102074,
8116 0x59342200, 0x59cc1007, 0x800811c0, 0x04000003,
8117 0x480a6801, 0x84102542, 0x8410251a, 0x48126a00,
8118 0x0401f05f, 0x4d3c0000, 0x417a7800, 0x0201f800,
8119 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864,
8120 0x0201f800, 0x0010aa47, 0x59340200, 0x84000558,
8121 0x48026a00, 0x4d300000, 0x0201f800, 0x0002075a,
8122 0x02000800, 0x001005d8, 0x49366009, 0x497a6008,
8123 0x4a026406, 0x00000001, 0x4a026403, 0x00000001,
8124 0x42003000, 0x00000003, 0x0201f800, 0x0010a942,
8125 0x0201f800, 0x00103b25, 0x04000011, 0x41782800,
8126 0x42003000, 0x00000001, 0x4d400000, 0x42028000,
8127 0x00000029, 0x0201f800, 0x0010a43e, 0x5c028000,
8128 0x4a026406, 0x00000004, 0x4a026203, 0x00000007,
8129 0x4a026420, 0x00000001, 0x0401f009, 0x4a026203,
8130 0x00000001, 0x42000800, 0x0000000b, 0x0201f800,
8131 0x00104571, 0x0201f800, 0x0010672b, 0x5c026000,
8132 0x0201f800, 0x00109037, 0x04000022, 0x0201f800,
8133 0x00109597, 0x04020022, 0x0401f9ae, 0x0401f01d,
8134 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c,
8135 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
8136 0x59340200, 0x84000558, 0x48026a00, 0x42003000,
8137 0x00000003, 0x41782800, 0x42002000, 0x00000005,
8138 0x4d400000, 0x4d440000, 0x59368c03, 0x42028000,
8139 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800,
8140 0x5c028000, 0x5c027800, 0x0201f800, 0x00102074,
8141 0x0201f800, 0x0002077d, 0x0401f002, 0x0401fca9,
8142 0x5c025800, 0x5c00b000, 0x1c01f000, 0x4933c857,
8143 0x41380000, 0x83383480, 0x00000056, 0x02021800,
8144 0x001005d8, 0x0c01f001, 0x00107ef7, 0x00107ef2,
8145 0x00107ef7, 0x00107ef7, 0x00107ef7, 0x00107ef7,
8146 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8147 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8148 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8149 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8150 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8151 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8152 0x00107ef0, 0x00107ef7, 0x00107ef0, 0x00107ef7,
8153 0x00107ef7, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8154 0x00107ef0, 0x00107ef0, 0x00107ef7, 0x00107ef0,
8155 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8156 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8157 0x00107ef7, 0x00107ef7, 0x00107ef0, 0x00107ef0,
8158 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef0,
8159 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7,
8160 0x00107ef0, 0x00107ef0, 0x00107ef7, 0x00107ef7,
8161 0x00107ef0, 0x00107ef7, 0x00107ef7, 0x00107ef0,
8162 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7,
8163 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7,
8164 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7,
8165 0x00107ef0, 0x00107ef0, 0x00107ef0, 0x00107ef7,
8166 0x0201f800, 0x001005d8, 0x4a026203, 0x00000001,
8167 0x493a6403, 0x0201f000, 0x0010672b, 0x4933c857,
8168 0x4a026203, 0x00000001, 0x493a6403, 0x0201f000,
8169 0x0010672b, 0x4933c857, 0x59300403, 0x82003480,
8170 0x00000056, 0x02021800, 0x001005d8, 0x83383580,
8171 0x00000013, 0x04000093, 0x83383580, 0x00000027,
8172 0x0402004b, 0x0201f800, 0x00106bbf, 0x0201f800,
8173 0x00109134, 0x0400000b, 0x0201f800, 0x0010914e,
8174 0x04000041, 0x59300403, 0x82000d80, 0x00000022,
8175 0x04020038, 0x0401fc61, 0x0400003a, 0x0401f03a,
8176 0x0201f800, 0x00102074, 0x42000800, 0x00000007,
8177 0x0201f800, 0x00104571, 0x0401f8fe, 0x4d440000,
8178 0x59368c03, 0x83440580, 0x000007fe, 0x04020008,
8179 0x59a81026, 0x84081540, 0x0201f800, 0x0010513b,
8180 0x04020002, 0x8408154a, 0x480b5026, 0x42028000,
8181 0x00000029, 0x4d3c0000, 0x417a7800, 0x0201f800,
8182 0x0010203c, 0x5c027800, 0x836c0580, 0x00000003,
8183 0x0400000c, 0x59326809, 0x59340008, 0x800001c0,
8184 0x04020008, 0x59368c03, 0x4933c857, 0x4937c857,
8185 0x4947c857, 0x0201f800, 0x001045fb, 0x0401f00c,
8186 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
8187 0x42003000, 0x00000015, 0x41782800, 0x42002000,
8188 0x00000003, 0x0201f800, 0x0010985e, 0x5c028800,
8189 0x0201f800, 0x00109326, 0x0201f000, 0x0002077d,
8190 0x1c01f000, 0x0401f8cb, 0x0401f7fa, 0x83380580,
8191 0x00000014, 0x0400000b, 0x0201f800, 0x00106f60,
8192 0x02020000, 0x00107974, 0x59300203, 0x82000580,
8193 0x00000002, 0x040000ed, 0x0201f800, 0x001005d8,
8194 0x0201f800, 0x00106bbf, 0x4d3c0000, 0x417a7800,
8195 0x0201f800, 0x0010203c, 0x5c027800, 0x42003000,
8196 0x00000016, 0x41782800, 0x4d400000, 0x4d440000,
8197 0x59368c03, 0x42002000, 0x00000009, 0x42028000,
8198 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800,
8199 0x5c028000, 0x42000000, 0x0010b864, 0x0201f800,
8200 0x0010aa47, 0x0201f800, 0x00109134, 0x0402000c,
8201 0x0201f800, 0x00102074, 0x0401f89e, 0x59340c03,
8202 0x82040580, 0x000007fe, 0x040207ca, 0x59a80826,
8203 0x84040d40, 0x48075026, 0x0401f7c6, 0x0201f800,
8204 0x0010914e, 0x04020003, 0x0401f892, 0x0401f7c1,
8205 0x59300403, 0x82000d80, 0x00000032, 0x04020004,
8206 0x0201f800, 0x0010230c, 0x0401f7ba, 0x59300403,
8207 0x82000d80, 0x00000022, 0x04000886, 0x0401f7b5,
8208 0x4803c857, 0x0c01f001, 0x00108016, 0x00108016,
8209 0x00108016, 0x00108016, 0x00108016, 0x00108016,
8210 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8211 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8212 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8213 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8214 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8215 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8216 0x00107ff9, 0x00108016, 0x00107ff0, 0x00108016,
8217 0x00108016, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8218 0x00107ff0, 0x00107ff0, 0x00108016, 0x00108016,
8219 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8220 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00107ff0,
8221 0x00108007, 0x00108016, 0x00107ff0, 0x00108000,
8222 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108000,
8223 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016,
8224 0x00108003, 0x00107ff0, 0x00107ff2, 0x00108016,
8225 0x00107ff0, 0x00108016, 0x00108016, 0x00107ff0,
8226 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016,
8227 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016,
8228 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016,
8229 0x00107ff0, 0x00107ff0, 0x00107ff0, 0x00108016,
8230 0x0201f800, 0x001005d8, 0x4d2c0000, 0x59325808,
8231 0x0201f800, 0x000202da, 0x5c025800, 0x0201f000,
8232 0x0002077d, 0x4a026203, 0x00000005, 0x59a80039,
8233 0x48026205, 0x59a80037, 0x48026206, 0x1c01f000,
8234 0x5930081e, 0x49780a05, 0x0401f014, 0x0201f800,
8235 0x00109326, 0x0201f000, 0x0002077d, 0x0201f800,
8236 0x0010230c, 0x0201f800, 0x00106c55, 0x04000005,
8237 0x0201f800, 0x00106bbf, 0x0201f000, 0x0002077d,
8238 0x0201f800, 0x00106bbf, 0x0201f800, 0x0002077d,
8239 0x0201f000, 0x00106c4b, 0x4933c857, 0x4a026203,
8240 0x00000002, 0x59a80037, 0x48026206, 0x1c01f000,
8241 0x4933c857, 0x0201f800, 0x00109037, 0x0400002a,
8242 0x4d2c0000, 0x0201f800, 0x00109597, 0x0402000a,
8243 0x4d400000, 0x42028000, 0x00000031, 0x42000800,
8244 0x00000004, 0x0201f800, 0x0010943b, 0x5c028000,
8245 0x0401f01c, 0x59300c06, 0x82040580, 0x00000010,
8246 0x04000004, 0x82040580, 0x00000011, 0x0402000a,
8247 0x4a025a06, 0x00000031, 0x4a02580d, 0x00000004,
8248 0x4a02580e, 0x000000ff, 0x0201f800, 0x000202da,
8249 0x0401f00c, 0x592c0404, 0x8c00051e, 0x04000009,
8250 0x4a025a04, 0x00000103, 0x4a025805, 0x01000000,
8251 0x5931d821, 0x58ef400b, 0x58ec0009, 0x0801f800,
8252 0x5c025800, 0x1c01f000, 0x4933c857, 0x59340400,
8253 0x82000500, 0x000000ff, 0x82003480, 0x0000000c,
8254 0x02021800, 0x001005d8, 0x59303403, 0x82180d80,
8255 0x0000004d, 0x02000000, 0x0010938b, 0x82180d80,
8256 0x00000033, 0x02000000, 0x00109349, 0x82180d80,
8257 0x00000028, 0x02000000, 0x0010918f, 0x82180d80,
8258 0x00000029, 0x02000000, 0x001091a3, 0x82180d80,
8259 0x0000001f, 0x02000000, 0x00107b28, 0x82180d80,
8260 0x00000055, 0x02000000, 0x00107b01, 0x82180d80,
8261 0x00000000, 0x04000591, 0x82180d80, 0x00000022,
8262 0x02000000, 0x00107b55, 0x82180d80, 0x00000035,
8263 0x02000000, 0x00107c50, 0x82180d80, 0x00000039,
8264 0x04000539, 0x82180d80, 0x0000003d, 0x02000000,
8265 0x00107b85, 0x82180d80, 0x00000044, 0x02000000,
8266 0x00107bc2, 0x82180d80, 0x00000049, 0x02000000,
8267 0x00107c17, 0x82180d80, 0x00000041, 0x02000000,
8268 0x00107c03, 0x82180d80, 0x00000043, 0x02000000,
8269 0x001094dc, 0x82180d80, 0x00000051, 0x02000000,
8270 0x00109542, 0x82180d80, 0x00000004, 0x04020003,
8271 0x42000000, 0x00000001, 0x83380d80, 0x00000015,
8272 0x04000006, 0x83380d80, 0x00000016, 0x02020000,
8273 0x00107974, 0x0401f20f, 0x4d2c0000, 0x4d3c0000,
8274 0x0c01f804, 0x5c027800, 0x5c025800, 0x1c01f000,
8275 0x001080b8, 0x001080bc, 0x001080b8, 0x00108131,
8276 0x001080b8, 0x00108226, 0x001082bf, 0x001080b8,
8277 0x001080b8, 0x00108288, 0x001080b8, 0x0010829a,
8278 0x4933c857, 0x497a6007, 0x59300808, 0x58040000,
8279 0x4a000a04, 0x00000103, 0x0201f000, 0x0002077d,
8280 0x4933c857, 0x40000000, 0x40000000, 0x1c01f000,
8281 0x4933c857, 0x59a80016, 0x82000580, 0x00000074,
8282 0x0402005c, 0x0201f800, 0x0010a2c8, 0x04020016,
8283 0x0401f85c, 0x0201f800, 0x00109037, 0x0400000c,
8284 0x0201f800, 0x00109597, 0x04020009, 0x41780800,
8285 0x4d400000, 0x42028000, 0x00000000, 0x0201f800,
8286 0x0010943b, 0x5c028000, 0x0401f003, 0x0201f800,
8287 0x00102074, 0x0201f800, 0x001048c1, 0x0201f000,
8288 0x0002077d, 0x0201f800, 0x00109037, 0x04000007,
8289 0x0201f800, 0x00109597, 0x04020004, 0x0401ff3d,
8290 0x0201f000, 0x0002077d, 0x417a7800, 0x0201f800,
8291 0x0010203c, 0x42000000, 0x0010b864, 0x0201f800,
8292 0x0010aa47, 0x59340200, 0x84000558, 0x48026a00,
8293 0x42003000, 0x00000003, 0x0201f800, 0x0010a942,
8294 0x4d300000, 0x0201f800, 0x0002075a, 0x02000800,
8295 0x001005d8, 0x49366009, 0x497a6008, 0x4a026406,
8296 0x00000001, 0x4a026403, 0x00000001, 0x0201f800,
8297 0x00103b25, 0x04000011, 0x4a026406, 0x00000004,
8298 0x4a026203, 0x00000007, 0x4a026420, 0x00000001,
8299 0x42003000, 0x00000001, 0x4d400000, 0x42028000,
8300 0x00000029, 0x41782800, 0x0201f800, 0x0010a43e,
8301 0x5c028000, 0x0401f009, 0x42000800, 0x0000000b,
8302 0x0201f800, 0x00104571, 0x4a026203, 0x00000001,
8303 0x0201f800, 0x0010672b, 0x5c026000, 0x0401ff05,
8304 0x0201f800, 0x00102074, 0x0201f000, 0x0002077d,
8305 0x0401ff00, 0x42000000, 0x00000001, 0x0401f0c7,
8306 0x4933c857, 0x59340200, 0x8c000500, 0x0400000d,
8307 0x4d3c0000, 0x417a7800, 0x0201f800, 0x00104567,
8308 0x5c027800, 0x0201f800, 0x00103b25, 0x04000005,
8309 0x42000800, 0x00000006, 0x0201f800, 0x00104571,
8310 0x1c01f000, 0x4933c857, 0x59a80816, 0x82040580,
8311 0x00000074, 0x0400000e, 0x4807c857, 0x82040580,
8312 0x00000100, 0x040200a0, 0x59cc0408, 0x4803c857,
8313 0x8c000500, 0x0400009c, 0x59341403, 0x82080580,
8314 0x000007fe, 0x04000006, 0x0401f097, 0x59341403,
8315 0x82080580, 0x000007fe, 0x04020003, 0x0401fa9c,
8316 0x0401f04c, 0x0201f800, 0x0010462a, 0x59341403,
8317 0x82080580, 0x000007fc, 0x0402001f, 0x4a026802,
8318 0x00fffffc, 0x0201f800, 0x00109037, 0x04000012,
8319 0x0201f800, 0x00109597, 0x0402000f, 0x0401f8a9,
8320 0x41780800, 0x4d400000, 0x42028000, 0x00000000,
8321 0x0201f800, 0x0010943b, 0x5c028000, 0x42000800,
8322 0x00000004, 0x0201f800, 0x00104571, 0x0201f000,
8323 0x0002077d, 0x42000800, 0x00000004, 0x0201f800,
8324 0x00104571, 0x0201f800, 0x00102074, 0x0201f000,
8325 0x0002077d, 0x59a80005, 0x8c000514, 0x04000011,
8326 0x0201f800, 0x0010513b, 0x42001000, 0x00000010,
8327 0x04020009, 0x59340002, 0x82000500, 0x00ff0000,
8328 0x82000580, 0x00ff0000, 0x04000006, 0x42001000,
8329 0x00000008, 0x0201f800, 0x00104c6d, 0x0402005a,
8330 0x0201f800, 0x00109037, 0x0400005b, 0x0201f800,
8331 0x00109597, 0x04020005, 0x592c0404, 0x8c00051c,
8332 0x040207c9, 0x0401f877, 0x42000800, 0x00000005,
8333 0x0201f800, 0x00104571, 0x4a026203, 0x00000001,
8334 0x4a026403, 0x00000003, 0x0201f000, 0x0010672b,
8335 0x59cc0408, 0x8c000518, 0x04000010, 0x0201f800,
8336 0x001092e5, 0x0201f800, 0x0010513b, 0x04000004,
8337 0x59cc0408, 0x8c000516, 0x040207b3, 0x59a80026,
8338 0x8400054a, 0x48035026, 0x59a80010, 0x84000570,
8339 0x48038832, 0x0401f7ac, 0x42001000, 0x000000ef,
8340 0x480b5010, 0x497b8830, 0x84081570, 0x480b8832,
8341 0x59c40802, 0x84040d4c, 0x48078802, 0x0201f800,
8342 0x0010930f, 0x59a80026, 0x84000548, 0x48035026,
8343 0x0201f800, 0x0010a3da, 0x0402079b, 0x59a80026,
8344 0x8400054c, 0x48035026, 0x42000800, 0x00000006,
8345 0x0201f800, 0x00104571, 0x417a7800, 0x0201f800,
8346 0x00104567, 0x42000000, 0x000000e8, 0x0201f800,
8347 0x00105c9a, 0x02000800, 0x001045a6, 0x02020800,
8348 0x001005d8, 0x49366009, 0x59340200, 0x8400051a,
8349 0x48026a00, 0x42000800, 0x00000003, 0x0201f800,
8350 0x00104571, 0x4a026406, 0x00000001, 0x4a026203,
8351 0x00000001, 0x4a026403, 0x00000002, 0x0201f000,
8352 0x0010672b, 0x0401fe43, 0x42000000, 0x00000001,
8353 0x0401f00a, 0x599c0017, 0x8c00050a, 0x040007ab,
8354 0x42000800, 0x00000004, 0x0201f800, 0x00104571,
8355 0x0201f000, 0x0002077d, 0x4933c857, 0x80003540,
8356 0x04000005, 0x42000800, 0x00000007, 0x0201f800,
8357 0x00104571, 0x801831c0, 0x0402000e, 0x59302008,
8358 0x801021c0, 0x04000004, 0x58100404, 0x8c00051e,
8359 0x04020008, 0x59341c03, 0x42002000, 0x00000004,
8360 0x42003000, 0x00000012, 0x0201f800, 0x00103aae,
8361 0x0201f800, 0x00102074, 0x0201f000, 0x0002077d,
8362 0x4c5c0000, 0x4d2c0000, 0x59325808, 0x0201f800,
8363 0x00105755, 0x5c025800, 0x59cc0008, 0x48002805,
8364 0x59cc0009, 0x48002806, 0x49782807, 0x49782808,
8365 0x49782809, 0x4978280a, 0x59cc0013, 0x8c00053e,
8366 0x04000009, 0x59cc0414, 0x900001c0, 0x59ccbc15,
8367 0x805c0540, 0x48002807, 0x59cc0416, 0x900001c0,
8368 0x48002808, 0x59cc0017, 0x8c00053e, 0x04000009,
8369 0x59cc0418, 0x900001c0, 0x59ccbc19, 0x805c0540,
8370 0x48002809, 0x59cc041a, 0x900001c0, 0x4800280a,
8371 0x5c00b800, 0x1c01f000, 0x4933c857, 0x59a80016,
8372 0x82000580, 0x00000014, 0x04020048, 0x59a80005,
8373 0x8c000514, 0x04000015, 0x0201f800, 0x0010513b,
8374 0x42001000, 0x00000010, 0x04020009, 0x59340002,
8375 0x82000500, 0x00ff0000, 0x82000580, 0x00ff0000,
8376 0x0400000a, 0x42001000, 0x00000008, 0x0201f800,
8377 0x00104c6d, 0x04000005, 0x59a80005, 0x84000556,
8378 0x48035005, 0x0401f031, 0x836c0580, 0x00000003,
8379 0x0402000b, 0x59300008, 0x80000540, 0x04020008,
8380 0x59341c03, 0x42002000, 0x00000006, 0x42003000,
8381 0x00000013, 0x0201f800, 0x00103aae, 0x0201f800,
8382 0x0010468d, 0x0401fecf, 0x0401fa1d, 0x0402001f,
8383 0x59340404, 0x80000540, 0x0400001c, 0x42000800,
8384 0x00000006, 0x0201f800, 0x00104571, 0x0201f800,
8385 0x00109037, 0x04000011, 0x0201f800, 0x00109597,
8386 0x0402000a, 0x41780800, 0x4d400000, 0x42028000,
8387 0x00000000, 0x0201f800, 0x0010943b, 0x5c028000,
8388 0x0201f000, 0x0002077d, 0x4a025a04, 0x00000103,
8389 0x4a025805, 0x02000000, 0x0201f800, 0x00102074,
8390 0x0201f000, 0x0002077d, 0x0201f800, 0x00104c19,
8391 0x0201f800, 0x00109037, 0x04000007, 0x0201f800,
8392 0x00109597, 0x04020004, 0x0401fda2, 0x0201f000,
8393 0x0002077d, 0x0401fd9f, 0x80000580, 0x59a80005,
8394 0x8c000516, 0x04000005, 0x84000516, 0x48035005,
8395 0x82000540, 0x00000001, 0x0401ff60, 0x1c01f000,
8396 0x4933c857, 0x59a80016, 0x82000580, 0x00000014,
8397 0x0402000b, 0x42000800, 0x0000000b, 0x0201f800,
8398 0x00104571, 0x4a026203, 0x00000001, 0x4a026403,
8399 0x00000001, 0x0201f000, 0x0010672b, 0x42000000,
8400 0x00000001, 0x0401f74d, 0x4933c857, 0x40003000,
8401 0x59a80016, 0x82000580, 0x00000004, 0x0402000a,
8402 0x82183580, 0x0000000b, 0x04020005, 0x42000800,
8403 0x00000007, 0x0201f800, 0x00104571, 0x0201f000,
8404 0x0002077d, 0x42000000, 0x00000001, 0x0401f73b,
8405 0x4803c857, 0x4d2c0000, 0x4d3c0000, 0x0c01f804,
8406 0x5c027800, 0x5c025800, 0x1c01f000, 0x001080b8,
8407 0x001082ce, 0x001080b8, 0x00108323, 0x001080b8,
8408 0x00108391, 0x001082bf, 0x001080b8, 0x001080b8,
8409 0x001083b1, 0x001080b8, 0x001083c1, 0x4933c857,
8410 0x4d1c0000, 0x59301403, 0x82080580, 0x00000003,
8411 0x04000008, 0x82081580, 0x0000001e, 0x04020003,
8412 0x0201f800, 0x0002077d, 0x5c023800, 0x1c01f000,
8413 0x0401ff5a, 0x0401f7fd, 0x4933c857, 0x0201f800,
8414 0x00109037, 0x0400000b, 0x0201f800, 0x00109597,
8415 0x04020008, 0x4200b000, 0x00000002, 0x0201f800,
8416 0x0010957d, 0x0401fd43, 0x0201f000, 0x0002077d,
8417 0x0401f8f5, 0x04020030, 0x417a7800, 0x0201f800,
8418 0x00104567, 0x417a7800, 0x0201f800, 0x0010203c,
8419 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
8420 0x59340200, 0x84000558, 0x48026a00, 0x4a026403,
8421 0x00000002, 0x42003000, 0x00000003, 0x0201f800,
8422 0x0010a942, 0x0201f800, 0x00103b25, 0x04000011,
8423 0x4d400000, 0x41782800, 0x42003000, 0x00000005,
8424 0x42028000, 0x00000029, 0x0201f800, 0x0010a43e,
8425 0x5c028000, 0x4a026203, 0x00000007, 0x4a026406,
8426 0x00000004, 0x4a026420, 0x00000001, 0x1c01f000,
8427 0x42000800, 0x00000003, 0x0201f800, 0x00104571,
8428 0x4a026203, 0x00000001, 0x0201f800, 0x0010672b,
8429 0x0401f7f7, 0x59cc0407, 0x82000580, 0x00000009,
8430 0x0402000a, 0x59340412, 0x82000500, 0x000000ff,
8431 0x0400000c, 0x80000040, 0x48026c12, 0x4a026206,
8432 0x0000000a, 0x0401f7ea, 0x59cc0207, 0x82000500,
8433 0x0000ff00, 0x82000580, 0x00001900, 0x040007c2,
8434 0x0401fcfc, 0x80000580, 0x0401f6c4, 0x4933c857,
8435 0x59a80032, 0x80000540, 0x04000015, 0x59340403,
8436 0x82000580, 0x000007fe, 0x04020011, 0x59a80010,
8437 0x80000000, 0x48035010, 0x417a7800, 0x0201f800,
8438 0x00104567, 0x42000800, 0x00000003, 0x0201f800,
8439 0x00104571, 0x4a026203, 0x00000001, 0x4a026403,
8440 0x00000002, 0x0201f000, 0x0010672b, 0x0201f800,
8441 0x00109037, 0x04000011, 0x0201f800, 0x00109597,
8442 0x0402000e, 0x4c580000, 0x4200b000, 0x00000002,
8443 0x0201f800, 0x0010957d, 0x5c00b000, 0x0401fcd5,
8444 0x42000800, 0x00000007, 0x0201f800, 0x00104571,
8445 0x0201f000, 0x0002077d, 0x0401fcce, 0x59cc3407,
8446 0x82183500, 0x000000ff, 0x82180580, 0x00000005,
8447 0x0400001c, 0x82180580, 0x0000000b, 0x04000016,
8448 0x59cc0207, 0x82000500, 0x0000ff00, 0x04020004,
8449 0x82180580, 0x00000009, 0x04000012, 0x82000580,
8450 0x00001900, 0x0402000c, 0x82180580, 0x00000009,
8451 0x0400000c, 0x42000800, 0x00000004, 0x0201f800,
8452 0x00104571, 0x0201f800, 0x00102074, 0x0201f000,
8453 0x0002077d, 0x42000000, 0x00000001, 0x0401f677,
8454 0x0201f800, 0x00109037, 0x59325808, 0x04000008,
8455 0x592c0204, 0x82000580, 0x00000139, 0x040007f6,
8456 0x592c0404, 0x8c00051e, 0x040207f3, 0x59340403,
8457 0x82000580, 0x000007fe, 0x04020007, 0x59a80026,
8458 0x84000540, 0x48035026, 0x0201f800, 0x00104229,
8459 0x0401f7e9, 0x417a7800, 0x0201f800, 0x0010203c,
8460 0x42003000, 0x00000005, 0x0201f800, 0x0010a942,
8461 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
8462 0x0401f7dd, 0x4933c857, 0x0401f84d, 0x0402000b,
8463 0x42000800, 0x00000005, 0x0201f800, 0x00104571,
8464 0x4a026203, 0x00000001, 0x4a026403, 0x00000003,
8465 0x0201f000, 0x0010672b, 0x42000800, 0x00000004,
8466 0x0201f800, 0x00104571, 0x0201f800, 0x00109597,
8467 0x0402000a, 0x4c580000, 0x4200b000, 0x00000002,
8468 0x0201f800, 0x0010957d, 0x5c00b000, 0x0401fc71,
8469 0x0201f000, 0x0002077d, 0x0401fc6e, 0x80000580,
8470 0x0401f636, 0x4933c857, 0x0401f82d, 0x0402000b,
8471 0x42000800, 0x00000009, 0x0201f800, 0x00104571,
8472 0x4a026203, 0x00000001, 0x4a026403, 0x00000005,
8473 0x0201f000, 0x0010672b, 0x42000000, 0x00000001,
8474 0x0401f626, 0x4933c857, 0x0401f81d, 0x0402000b,
8475 0x42000800, 0x0000000b, 0x0201f800, 0x00104571,
8476 0x4a026203, 0x00000001, 0x4a026403, 0x00000001,
8477 0x0201f000, 0x0010672b, 0x42000000, 0x00000001,
8478 0x0401f616, 0x4933c857, 0x59cc0407, 0x82000580,
8479 0x00000003, 0x04020009, 0x59cc0207, 0x82000500,
8480 0x0000ff00, 0x82000d80, 0x00002a00, 0x04000003,
8481 0x82000d80, 0x00001e00, 0x1c01f000, 0x4933c857,
8482 0x82000540, 0x00000001, 0x1c01f000, 0x4933c857,
8483 0x4d400000, 0x4c580000, 0x59a80026, 0x82000540,
8484 0x00000003, 0x48035026, 0x0401f85c, 0x04000038,
8485 0x4d340000, 0x4d440000, 0x59a80026, 0x84000552,
8486 0x48035026, 0x0201f800, 0x00103b25, 0x0400000c,
8487 0x42028000, 0x0000002a, 0x42028800, 0x0000ffff,
8488 0x42003000, 0x00000002, 0x0201f800, 0x0010a446,
8489 0x59a80805, 0x84040d44, 0x48075005, 0x42028000,
8490 0x0000002a, 0x4d3c0000, 0x42027800, 0x00000204,
8491 0x0201f800, 0x00101fe5, 0x5c027800, 0x42000000,
8492 0x0010b864, 0x0201f800, 0x0010aa47, 0x0201f800,
8493 0x00101e45, 0x4200b000, 0x00000010, 0x42028800,
8494 0x000007f0, 0x4d2c0000, 0x83440580, 0x000007fe,
8495 0x04000003, 0x0201f800, 0x001045fb, 0x81468800,
8496 0x8058b040, 0x040207f9, 0x5c025800, 0x59cc0408,
8497 0x8c00051e, 0x04000004, 0x59a80026, 0x84000512,
8498 0x48035026, 0x5c028800, 0x5c026800, 0x0201f800,
8499 0x0010462a, 0x4a026802, 0x00fffffe, 0x59a80826,
8500 0x84040d50, 0x59cc0013, 0x8c00053e, 0x04000003,
8501 0x8c000536, 0x04000004, 0x59cc0017, 0x8c000536,
8502 0x04020002, 0x84040d10, 0x48075026, 0x59cc0800,
8503 0x82040d00, 0x00ffffff, 0x48075010, 0x80040110,
8504 0x4803501d, 0x48038881, 0x0201f800, 0x0010513b,
8505 0x04000007, 0x59cc0009, 0x48035035, 0x59cc000a,
8506 0x48035036, 0x0201f800, 0x001092e5, 0x5c00b000,
8507 0x5c028000, 0x1c01f000, 0x4933c857, 0x4c580000,
8508 0x59a80010, 0x82000500, 0x00ffff00, 0x04000022,
8509 0x59cc1000, 0x82081500, 0x00ffff00, 0x80080580,
8510 0x04000004, 0x42000000, 0x0010b83b, 0x0401f016,
8511 0x83cc1400, 0x0000000b, 0x4200b000, 0x00000002,
8512 0x83341c00, 0x00000006, 0x0401f900, 0x04000004,
8513 0x42000000, 0x0010b83c, 0x0401f00b, 0x83cc1400,
8514 0x0000000d, 0x4200b000, 0x00000002, 0x83341c00,
8515 0x00000008, 0x0401f8f5, 0x04000007, 0x42000000,
8516 0x0010b83d, 0x0201f800, 0x0010aa47, 0x82000540,
8517 0x00000001, 0x5c00b000, 0x1c01f000, 0x4933c857,
8518 0x59cc0206, 0x82000580, 0x00000014, 0x04020016,
8519 0x59cc0407, 0x82000580, 0x00000800, 0x04020012,
8520 0x59cc0207, 0x8c00051a, 0x0400000d, 0x82000500,
8521 0x00000f00, 0x82000580, 0x00000100, 0x04020008,
8522 0x59cc020a, 0x8c000508, 0x04020003, 0x8c00050a,
8523 0x04000003, 0x80000580, 0x1c01f000, 0x82000540,
8524 0x00000001, 0x1c01f000, 0x4933c857, 0x4943c857,
8525 0x493fc857, 0x4c5c0000, 0x4d300000, 0x4d340000,
8526 0x4d2c0000, 0x4d380000, 0x4130b800, 0x42026000,
8527 0x0010d1c0, 0x59a8000e, 0x81640480, 0x040210bd,
8528 0x8d3e7d12, 0x04000004, 0x405c0000, 0x81300580,
8529 0x040000b3, 0x59300406, 0x82000c80, 0x00000012,
8530 0x04021015, 0x59326809, 0x0c01f001, 0x0010854f,
8531 0x001084bc, 0x001084d3, 0x001084de, 0x001084b7,
8532 0x001084ce, 0x00108507, 0x0010854f, 0x001084b5,
8533 0x0010851b, 0x0010852a, 0x001084b5, 0x001084b5,
8534 0x001084b5, 0x001084b5, 0x0010854f, 0x00108540,
8535 0x00108538, 0x0201f800, 0x001005d8, 0x8d3e7d18,
8536 0x04000004, 0x59300420, 0x8c000500, 0x04020094,
8537 0x59300403, 0x82000580, 0x00000043, 0x04000090,
8538 0x0201f800, 0x00109134, 0x02000800, 0x00102074,
8539 0x0201f800, 0x0010914e, 0x02000800, 0x0010801c,
8540 0x8d3e7d06, 0x04000084, 0x0201f800, 0x001092d7,
8541 0x04000083, 0x0401f080, 0x8d3e7d16, 0x04000004,
8542 0x59300420, 0x8c000500, 0x0402007d, 0x59325808,
8543 0x0201f800, 0x00109037, 0x04000077, 0x49425a06,
8544 0x497a5c09, 0x0201f800, 0x000202da, 0x0201f800,
8545 0x0010912a, 0x0401f070, 0x813669c0, 0x02000800,
8546 0x001005d8, 0x8d3e7d06, 0x04000004, 0x59340200,
8547 0x8c00050e, 0x0402006a, 0x59300004, 0x8400055c,
8548 0x48026004, 0x59300203, 0x82000580, 0x00000004,
8549 0x02000800, 0x00100e99, 0x59325808, 0x0201f800,
8550 0x00109037, 0x0400005c, 0x4a025a04, 0x00000103,
8551 0x59300402, 0x48025c06, 0x592c0408, 0x8c000512,
8552 0x04000006, 0x4d2c0000, 0x592e5809, 0x0201f800,
8553 0x001007fd, 0x5c025800, 0x49425a06, 0x497a5c09,
8554 0x0201f800, 0x0010959c, 0x0201f800, 0x000202da,
8555 0x0201f800, 0x0010912a, 0x0401f047, 0x8c000518,
8556 0x04000047, 0x59300203, 0x82000580, 0x00000004,
8557 0x02000800, 0x00100e99, 0x59325808, 0x0201f800,
8558 0x00109037, 0x0400003c, 0x49425a06, 0x497a5c09,
8559 0x0201f800, 0x0010a693, 0x0201f800, 0x0010959c,
8560 0x0201f800, 0x000202da, 0x0401f033, 0x0201f800,
8561 0x001062d5, 0x04000032, 0x59300203, 0x82000580,
8562 0x00000004, 0x04020004, 0x0201f800, 0x00100e99,
8563 0x0401f02b, 0x42027000, 0x00000047, 0x0201f800,
8564 0x000207a1, 0x0401f026, 0x59300203, 0x82000580,
8565 0x00000004, 0x02000800, 0x00100e99, 0x59325808,
8566 0x0201f800, 0x00109037, 0x0400001b, 0x49425a06,
8567 0x497a5c09, 0x0201f800, 0x000202da, 0x0401f016,
8568 0x833c0500, 0x00001800, 0x04000015, 0x8d3e7d16,
8569 0x04020013, 0x59325817, 0x0201f800, 0x001007fd,
8570 0x59300203, 0x82000580, 0x00000004, 0x02000800,
8571 0x00100e99, 0x59325808, 0x0201f800, 0x00109037,
8572 0x04000005, 0x49425a06, 0x497a5c09, 0x0201f800,
8573 0x000202da, 0x0201f800, 0x00107911, 0x83326400,
8574 0x00000024, 0x41580000, 0x81300480, 0x04001742,
8575 0x5c027000, 0x5c025800, 0x5c026800, 0x5c026000,
8576 0x5c00b800, 0x1c01f000, 0x5c000000, 0x4c000000,
8577 0x4803c857, 0x480bc857, 0x480fc857, 0x485bc857,
8578 0x50080800, 0x500c0000, 0x80042580, 0x04020007,
8579 0x80081000, 0x800c1800, 0x8058b040, 0x040207f9,
8580 0x80000580, 0x1c01f000, 0x4803c857, 0x4807c857,
8581 0x480bc857, 0x480fc857, 0x80040480, 0x04001006,
8582 0x42000000, 0x00000001, 0x82040d40, 0x00000001,
8583 0x1c01f000, 0x41780000, 0x0401f7fc, 0x83380480,
8584 0x00000053, 0x02021800, 0x001005d8, 0x83380480,
8585 0x0000004b, 0x02001800, 0x001005d8, 0x0c01f001,
8586 0x0010858a, 0x0010858a, 0x0010858a, 0x0010858a,
8587 0x00108588, 0x00108588, 0x00108588, 0x0010858a,
8588 0x0201f800, 0x001005d8, 0x493bc857, 0x4a026203,
8589 0x0000000d, 0x493a6403, 0x42000800, 0x80000000,
8590 0x0201f000, 0x00020721, 0x83380580, 0x00000013,
8591 0x04020008, 0x59300403, 0x82000580, 0x00000050,
8592 0x02020800, 0x001005d8, 0x0201f000, 0x0002077d,
8593 0x4933c857, 0x83380580, 0x00000027, 0x04020030,
8594 0x4933c857, 0x0201f800, 0x00106bbf, 0x4d3c0000,
8595 0x417a7800, 0x0201f800, 0x0010203c, 0x5c027800,
8596 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
8597 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037,
8598 0x492fc857, 0x0400000d, 0x4a025a04, 0x00000103,
8599 0x59300c02, 0x48065c06, 0x4a025a06, 0x00000029,
8600 0x497a5c09, 0x592c0c08, 0x84040d50, 0x48065c08,
8601 0x0201f800, 0x000202da, 0x5c025800, 0x42003000,
8602 0x00000015, 0x41782800, 0x42002000, 0x00000003,
8603 0x4d400000, 0x4d440000, 0x59368c03, 0x42028000,
8604 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800,
8605 0x5c028000, 0x0201f000, 0x0002077d, 0x83380580,
8606 0x00000014, 0x0402000c, 0x59300403, 0x82000c80,
8607 0x00000053, 0x02021800, 0x001005d8, 0x82000480,
8608 0x00000040, 0x02001800, 0x001005d8, 0x4803c857,
8609 0x0c01f00e, 0x83380580, 0x00000053, 0x0400000a,
8610 0x83380580, 0x00000048, 0x02020800, 0x001005d8,
8611 0x59300403, 0x82000580, 0x00000050, 0x02020800,
8612 0x001005d8, 0x1c01f000, 0x001085ff, 0x001085fd,
8613 0x001085fd, 0x001085fd, 0x001085fd, 0x001085fd,
8614 0x001085fd, 0x001085fd, 0x001085fd, 0x001085fd,
8615 0x001085fd, 0x00108616, 0x00108616, 0x00108616,
8616 0x00108616, 0x001085fd, 0x00108616, 0x001085fd,
8617 0x00108616, 0x0201f800, 0x001005d8, 0x4933c857,
8618 0x0201f800, 0x00106bbf, 0x0201f800, 0x00109037,
8619 0x02000000, 0x0002077d, 0x4d2c0000, 0x59325808,
8620 0x4a025a04, 0x00000103, 0x59300402, 0x48025c06,
8621 0x4a025a06, 0x00000006, 0x497a5c09, 0x0201f800,
8622 0x000202da, 0x5c025800, 0x0201f800, 0x0010912a,
8623 0x0201f000, 0x0002077d, 0x4933c857, 0x0201f800,
8624 0x00106bbf, 0x0201f000, 0x0002077d, 0x0201f800,
8625 0x001005d8, 0x5930001c, 0x800001c0, 0x02020800,
8626 0x0010984e, 0x59300004, 0x8c00053e, 0x04020029,
8627 0x59325808, 0x592c0c08, 0x59cc2a08, 0x82141d00,
8628 0x00000c00, 0x04000002, 0x59cc1809, 0x84040d58,
8629 0x48065c08, 0x82143500, 0x00000fff, 0x04020027,
8630 0x59340200, 0x8c00050e, 0x04020080, 0x0201f800,
8631 0x0002082b, 0x04020006, 0x4a025a06, 0x00000000,
8632 0x59300811, 0x800409c0, 0x0402094b, 0x4a025a04,
8633 0x00000103, 0x48065807, 0x480e580a, 0x48165c09,
8634 0x59300c02, 0x48065c06, 0x0201f800, 0x000202c1,
8635 0x0201f800, 0x001049b2, 0x59cc0208, 0x8c000518,
8636 0x02020000, 0x001091d1, 0x0201f000, 0x0002077d,
8637 0x0201f800, 0x00106f60, 0x040007d6, 0x4d3c0000,
8638 0x42027800, 0x00000002, 0x0201f800, 0x00108be3,
8639 0x5c027800, 0x0401f7cf, 0x4817c857, 0x480fc857,
8640 0x82180500, 0x000000ff, 0x0400000e, 0x592c0204,
8641 0x82000500, 0x000000ff, 0x82000580, 0x00000048,
8642 0x04020008, 0x592c0407, 0x800001c0, 0x04000005,
8643 0x0201f800, 0x0010973f, 0x0201f000, 0x00109787,
8644 0x82180d00, 0x00000c00, 0x04000004, 0x59340200,
8645 0x8c00050e, 0x04020032, 0x4a025a06, 0x00000000,
8646 0x41782000, 0x8c183510, 0x04000007, 0x59cc000c,
8647 0x82000500, 0x000000ff, 0x04000002, 0x4803c857,
8648 0x59cc200b, 0x4812580c, 0x41780000, 0x8c183512,
8649 0x04000002, 0x59cc000a, 0x4802580b, 0x80100c00,
8650 0x040007b8, 0x82041480, 0x0000001d, 0x04001006,
8651 0x592c0404, 0x8c00051e, 0x0400000e, 0x42000800,
8652 0x0000001c, 0x4c500000, 0x4c540000, 0x83cca400,
8653 0x0000000c, 0x832cac00, 0x0000000d, 0x0201f800,
8654 0x00108b9f, 0x5c00a800, 0x5c00a000, 0x0401f7a5,
8655 0x59300011, 0x59301402, 0x480a5c06, 0x48025807,
8656 0x480e580a, 0x48165c09, 0x0201f800, 0x00108b48,
8657 0x0201f800, 0x00108b84, 0x0401f7a6, 0x592c020a,
8658 0x8c000502, 0x040007cd, 0x592c0208, 0x8c00050e,
8659 0x040207ca, 0x59300011, 0x800c0d80, 0x040007c7,
8660 0x4803c857, 0x480fc857, 0x8c183514, 0x02000000,
8661 0x0010920f, 0x80000540, 0x040007c0, 0x4807c856,
8662 0x0201f000, 0x0010920f, 0x592c020a, 0x8c000502,
8663 0x04000782, 0x59300011, 0x800001c0, 0x0400077f,
8664 0x592c0208, 0x8c00050e, 0x0402077c, 0x0201f000,
8665 0x0010920f, 0x59cc2006, 0x59cc2807, 0x0401f035,
8666 0x0401f034, 0x1c01f000, 0x4933c857, 0x5930001c,
8667 0x800001c0, 0x02020800, 0x0010984e, 0x59325808,
8668 0x592c0c08, 0x41782800, 0x41781800, 0x84040d58,
8669 0x48065c08, 0x41783000, 0x59340200, 0x8c00050e,
8670 0x04020018, 0x0201f800, 0x0002082b, 0x04020007,
8671 0x4a025a06, 0x00000000, 0x59300811, 0x4807c857,
8672 0x800409c0, 0x040208ac, 0x4a025a04, 0x00000103,
8673 0x48065807, 0x480e580a, 0x48165c09, 0x4933c857,
8674 0x59300c02, 0x48065c06, 0x0201f800, 0x000202c1,
8675 0x0201f800, 0x001049b2, 0x0201f000, 0x0002077d,
8676 0x592c020a, 0x8c000502, 0x040007ea, 0x59300011,
8677 0x4803c857, 0x800001c0, 0x040007e6, 0x592c0208,
8678 0x8c00050e, 0x040207e3, 0x0201f000, 0x0010920f,
8679 0x5930001c, 0x800001c0, 0x4c100000, 0x4c140000,
8680 0x02020800, 0x0010984e, 0x5c002800, 0x5c002000,
8681 0x4a026203, 0x00000002, 0x4a026403, 0x00000043,
8682 0x59325808, 0x592c020a, 0x8c000502, 0x04020018,
8683 0x40100000, 0x592c080f, 0x80040c80, 0x40140000,
8684 0x80040480, 0x04001014, 0x48126013, 0x48166011,
8685 0x59300004, 0x8c00053e, 0x04020008, 0x497a6205,
8686 0x0201f800, 0x00100f93, 0x04020009, 0x59300804,
8687 0x0201f000, 0x00106721, 0x0201f800, 0x00106f60,
8688 0x040007f7, 0x0201f000, 0x00107974, 0x4933c857,
8689 0x1c01f000, 0x4807c857, 0x40042800, 0x0401f7eb,
8690 0x83380480, 0x00000058, 0x04021005, 0x83380480,
8691 0x00000040, 0x04001002, 0x0c01f002, 0x1c01f000,
8692 0x00108740, 0x00108740, 0x00108740, 0x00108740,
8693 0x00108740, 0x00108740, 0x00108740, 0x00108740,
8694 0x00108740, 0x00108740, 0x00108742, 0x00108740,
8695 0x00108740, 0x00108740, 0x00108740, 0x0010874f,
8696 0x00108740, 0x00108740, 0x00108740, 0x00108740,
8697 0x0010877d, 0x00108740, 0x00108740, 0x00108740,
8698 0x0201f800, 0x001005d8, 0x4933c857, 0x0201f800,
8699 0x00106dc3, 0x4a026203, 0x00000002, 0x59a80039,
8700 0x48026205, 0x59300011, 0x59300815, 0x80040c80,
8701 0x48066015, 0x0201f000, 0x00106b8a, 0x4933c857,
8702 0x0201f800, 0x00106b8a, 0x4d3c0000, 0x417a7800,
8703 0x0201f800, 0x0010203c, 0x5c027800, 0x42000000,
8704 0x0010b864, 0x0201f800, 0x0010aa47, 0x0201f800,
8705 0x00109037, 0x04000010, 0x4d2c0000, 0x59325808,
8706 0x4a025a04, 0x00000103, 0x59300402, 0x48025c06,
8707 0x4a025a06, 0x00000029, 0x497a5c09, 0x592c0c08,
8708 0x84040d50, 0x48065c08, 0x0201f800, 0x000202da,
8709 0x5c025800, 0x42003000, 0x00000014, 0x41782800,
8710 0x4d400000, 0x4d440000, 0x59368c03, 0x42002000,
8711 0x00000002, 0x42028000, 0x00000029, 0x0201f800,
8712 0x0010985e, 0x5c028800, 0x5c028000, 0x0201f000,
8713 0x0002077d, 0x4933c857, 0x59300808, 0x49780c09,
8714 0x4978080a, 0x58041408, 0x84081558, 0x48080c08,
8715 0x1c01f000, 0x4807c857, 0x8c040d3e, 0x04020023,
8716 0x497a5a06, 0x5930001f, 0x80000540, 0x04000017,
8717 0x497a5a06, 0x4c040000, 0x4c080000, 0x4c0c0000,
8718 0x4c100000, 0x4c140000, 0x58f41003, 0x40040000,
8719 0x80081480, 0x5930001f, 0x4809e803, 0x0201f800,
8720 0x00100d56, 0x5c002800, 0x5c002000, 0x5c001800,
8721 0x5c001000, 0x5c000800, 0x592c0206, 0x80000540,
8722 0x04020009, 0x0401f005, 0x592c0408, 0x8c00051c,
8723 0x04000002, 0x592c0803, 0x4807c857, 0x4a025a06,
8724 0x00000015, 0x1c01f000, 0x5930001f, 0x80000540,
8725 0x04000009, 0x4a025a06, 0x00000011, 0x5930001f,
8726 0x4c040000, 0x0201f800, 0x00100d56, 0x5c000800,
8727 0x0401f7f5, 0x4807c856, 0x4a025a06, 0x00000007,
8728 0x1c01f000, 0x83380480, 0x00000058, 0x04021007,
8729 0x83380480, 0x00000040, 0x04001004, 0x4d2c0000,
8730 0x0c01f803, 0x5c025800, 0x1c01f000, 0x001087db,
8731 0x001087db, 0x001087db, 0x001087db, 0x001087db,
8732 0x001087dd, 0x001087db, 0x001087db, 0x00108860,
8733 0x001087db, 0x001087db, 0x001087db, 0x001087db,
8734 0x001087db, 0x001087db, 0x001087db, 0x001087db,
8735 0x001087db, 0x001087db, 0x00108910, 0x00108939,
8736 0x00108918, 0x001087db, 0x00108945, 0x0201f800,
8737 0x001005d8, 0x5930001c, 0x800001c0, 0x02020800,
8738 0x0010984e, 0x59300007, 0x8c00050e, 0x0400007c,
8739 0x8c000500, 0x0400006e, 0x8c00051c, 0x04000009,
8740 0x84000500, 0x48026007, 0x59325808, 0x592c3c08,
8741 0x841c3d58, 0x481e5c08, 0x0201f000, 0x000207dd,
8742 0x59325808, 0x592c3c08, 0x841c3d58, 0x59300007,
8743 0x8c00051c, 0x040207f3, 0x481e5c08, 0x42000000,
8744 0x00000005, 0x40000000, 0x80000040, 0x040207fe,
8745 0x59300007, 0x8c00051c, 0x040207ea, 0x59cc0a08,
8746 0x592c0204, 0x82000500, 0x000000ff, 0x82000580,
8747 0x00000048, 0x0402000c, 0x497a580b, 0x82040500,
8748 0x000000ff, 0x04000008, 0x592c0407, 0x800001c0,
8749 0x04000005, 0x0201f800, 0x0010973f, 0x0201f000,
8750 0x00100e56, 0x48065c09, 0x41782000, 0x82040500,
8751 0x00000c00, 0x04000002, 0x59cc2009, 0x82043500,
8752 0x00000fff, 0x04020027, 0x481e5c08, 0x4a025a06,
8753 0x00000000, 0x801831c0, 0x02000000, 0x00100e56,
8754 0x41782000, 0x8c183510, 0x04000002, 0x59cc200b,
8755 0x4812580c, 0x41780000, 0x8c183512, 0x04000002,
8756 0x59cc000a, 0x4802580b, 0x80100c00, 0x02001800,
8757 0x001005d8, 0x02000000, 0x00100e56, 0x82041480,
8758 0x0000001d, 0x0402100c, 0x4c500000, 0x4c540000,
8759 0x83cca400, 0x0000000c, 0x832cac00, 0x0000000d,
8760 0x0401fb67, 0x5c00a800, 0x5c00a000, 0x0201f000,
8761 0x00100e56, 0x0401fb0b, 0x0201f000, 0x00100e56,
8762 0x412c7800, 0x0201f800, 0x001007e4, 0x02000800,
8763 0x001005d8, 0x492c7809, 0x841c3d52, 0x481c7c08,
8764 0x4a025a04, 0x00000103, 0x4812580a, 0x48065c09,
8765 0x583c0404, 0x583c1005, 0x583c2208, 0x48025c04,
8766 0x480a5805, 0x48125a08, 0x0401f7c8, 0x8c000524,
8767 0x04000794, 0x59325808, 0x4c000000, 0x592c0408,
8768 0x8c00051c, 0x5c000000, 0x04020003, 0x4a026011,
8769 0xffffffff, 0x84000524, 0x0401f78a, 0x1c01f000,
8770 0x59a80039, 0x48026205, 0x59325808, 0x4a026203,
8771 0x00000002, 0x592c2408, 0x59300807, 0x4933c857,
8772 0x4807c857, 0x592c0204, 0x82000500, 0x000000ff,
8773 0x82000580, 0x00000048, 0x04020004, 0x8c102500,
8774 0x02020000, 0x00109787, 0x4a025a06, 0x00000000,
8775 0x8c040d1e, 0x04000027, 0x41780800, 0x497a5c09,
8776 0x592c1c09, 0x59300011, 0x59341200, 0x497a6205,
8777 0x8c08150e, 0x0402006e, 0x4807c857, 0x4806580a,
8778 0x80000d40, 0x04020f04, 0x59300402, 0x48025c06,
8779 0x48065807, 0x4a025a04, 0x00000103, 0x4c040000,
8780 0x4c0c0000, 0x4c100000, 0x0201f800, 0x0010959c,
8781 0x5c002000, 0x5c001800, 0x5c000800, 0x8c102512,
8782 0x0402001a, 0x4c0c0000, 0x0201f800, 0x000202c1,
8783 0x0201f800, 0x001049b2, 0x5c001800, 0x8c0c1d18,
8784 0x02000000, 0x0002077d, 0x0201f000, 0x001091d1,
8785 0x4813c857, 0x8c102518, 0x0400004b, 0x41780800,
8786 0x592c1c09, 0x820c0580, 0x00001000, 0x040007d6,
8787 0x8c102512, 0x040007d4, 0x592c7809, 0x583c080a,
8788 0x583c1c09, 0x0401f7d0, 0x4807c857, 0x592c7809,
8789 0x59300402, 0x592c1404, 0x8c08151e, 0x0402000d,
8790 0x592c1206, 0x48007c06, 0x48047807, 0x48087a06,
8791 0x84102512, 0x48107c08, 0x4c0c0000, 0x0201f800,
8792 0x001007fd, 0x403e5800, 0x0401faca, 0x0401f7d9,
8793 0x48025c06, 0x48065807, 0x583c080c, 0x583c000b,
8794 0x80040c00, 0x82041480, 0x0000001d, 0x04001006,
8795 0x583c1001, 0x480a5801, 0x49787801, 0x42000800,
8796 0x0000001c, 0x82040c00, 0x00000014, 0x4c0c0000,
8797 0x4c500000, 0x4c540000, 0x823ca400, 0x00000008,
8798 0x832cac00, 0x00000008, 0x4c100000, 0x4c3c0000,
8799 0x0401facb, 0x5c007800, 0x5c002000, 0x5c00a800,
8800 0x5c00a000, 0x84102512, 0x48125c08, 0x403e5800,
8801 0x0201f800, 0x001007fd, 0x42034000, 0x0010b4a4,
8802 0x59a1d81e, 0x80edd9c0, 0x02000800, 0x001005d8,
8803 0x48efc857, 0x58ec0009, 0x4803c857, 0x0801f800,
8804 0x0401f7ac, 0x4933c857, 0x1c01f000, 0x59301414,
8805 0x480bc857, 0x8c08151c, 0x0402000e, 0x80000540,
8806 0x4803c857, 0x0400078d, 0x80042c80, 0x0402178b,
8807 0x8c081514, 0x04020005, 0x592c080f, 0x4807c857,
8808 0x80040480, 0x48026016, 0x8408155c, 0x480a6414,
8809 0x59301007, 0x8408151e, 0x480a6007, 0x4a025c09,
8810 0x00000001, 0x0201f800, 0x0010959c, 0x497a5c09,
8811 0x8c102512, 0x04000006, 0x4d2c0000, 0x403e5800,
8812 0x0201f800, 0x001007fd, 0x5c025800, 0x82102500,
8813 0xffffedff, 0x48125c08, 0x0201f000, 0x0010920f,
8814 0x59325808, 0x592c0408, 0x8c000518, 0x04000004,
8815 0x412df800, 0x0201f000, 0x00100e6f, 0x1c01f000,
8816 0x4933c857, 0x59325808, 0x497a5c09, 0x4a025a06,
8817 0x00000000, 0x4a025a04, 0x00000103, 0x59300811,
8818 0x4807c857, 0x800409c0, 0x0402000a, 0x48065807,
8819 0x59300c02, 0x48065c06, 0x0201f800, 0x000202c1,
8820 0x0201f800, 0x001049b2, 0x0201f000, 0x0002077d,
8821 0x59340200, 0x8c00050e, 0x04020005, 0x59300811,
8822 0x0401fe55, 0x48065807, 0x0401f7f2, 0x592c0208,
8823 0x8c00050e, 0x040207fa, 0x4933c857, 0x0201f000,
8824 0x0010920f, 0x4933c857, 0x59325808, 0x812e59c0,
8825 0x02000800, 0x001005d8, 0x592c020a, 0x8c000502,
8826 0x02000800, 0x001005d8, 0x4a026206, 0x00000002,
8827 0x1c01f000, 0x5930001c, 0x800001c0, 0x02020800,
8828 0x0010984e, 0x59300007, 0x4933c857, 0x4803c857,
8829 0x8c00050e, 0x04000037, 0x8c000500, 0x04000029,
8830 0x8c00051c, 0x0400000a, 0x84000500, 0x48026007,
8831 0x59325808, 0x592c3c08, 0x481fc857, 0x841c3d58,
8832 0x481e5c08, 0x0201f000, 0x000207dd, 0x59325808,
8833 0x592c3c08, 0x841c3d58, 0x59300007, 0x8c00051c,
8834 0x040207f2, 0x481e5c08, 0x42000000, 0x00000005,
8835 0x40000000, 0x80000040, 0x040207fe, 0x59300007,
8836 0x8c00051c, 0x040207e9, 0x592c0204, 0x82000500,
8837 0x000000ff, 0x82000580, 0x00000048, 0x04020003,
8838 0x497a580b, 0x0401f002, 0x497a5c09, 0x481e5c08,
8839 0x4a025a06, 0x00000000, 0x0201f000, 0x00100e56,
8840 0x8c000524, 0x040007d9, 0x59325808, 0x4c000000,
8841 0x592c0408, 0x8c00051c, 0x5c000000, 0x04020003,
8842 0x4a026011, 0xffffffff, 0x84000524, 0x0401f7cf,
8843 0x1c01f000, 0x4933c857, 0x41780800, 0x83380480,
8844 0x00000058, 0x0402100b, 0x83380480, 0x00000040,
8845 0x04001008, 0x4d2c0000, 0x59325808, 0x812e59c0,
8846 0x0c020806, 0x5c025800, 0x0201f000, 0x0002077d,
8847 0x493bc857, 0x1c01f000, 0x001089ae, 0x001089ae,
8848 0x001089ae, 0x001089ae, 0x001089ae, 0x001089b0,
8849 0x001089ae, 0x001089ae, 0x001089ae, 0x001089ae,
8850 0x001089ae, 0x001089ae, 0x001089ae, 0x001089ae,
8851 0x001089ae, 0x001089ae, 0x001089ae, 0x001089ae,
8852 0x001089ae, 0x001089ae, 0x001089b5, 0x001089ae,
8853 0x001089ae, 0x001089ae, 0x0201f800, 0x001005d8,
8854 0x59cc0a08, 0x497a5807, 0x4807c857, 0x82040d00,
8855 0x00000fff, 0x59300402, 0x48025c06, 0x4a025a04,
8856 0x00000103, 0x48065c09, 0x4a025a06, 0x00000000,
8857 0x800409c0, 0x02000000, 0x000202c1, 0x59cc0009,
8858 0x4802580a, 0x82042500, 0x00000100, 0x04000002,
8859 0x59cc200b, 0x4812580c, 0x82040500, 0x00000200,
8860 0x04000002, 0x59cc000a, 0x4802580b, 0x80100c00,
8861 0x02001800, 0x001005d8, 0x02000000, 0x000202da,
8862 0x82041480, 0x0000001d, 0x04001006, 0x592c0404,
8863 0x8c00051e, 0x0400000e, 0x42000800, 0x0000001c,
8864 0x4c500000, 0x4c540000, 0x83cca400, 0x0000000c,
8865 0x832cac00, 0x0000000d, 0x0401f9c1, 0x5c00a800,
8866 0x5c00a000, 0x0201f000, 0x000202da, 0x0401f965,
8867 0x0401f1a0, 0x83380480, 0x00000093, 0x02021800,
8868 0x001005d8, 0x83380480, 0x00000085, 0x02001800,
8869 0x001005d8, 0x0c01f001, 0x001089fd, 0x001089fb,
8870 0x001089fb, 0x00108a04, 0x001089fb, 0x001089fb,
8871 0x001089fb, 0x001089fb, 0x001089fb, 0x001089fb,
8872 0x001089fb, 0x001089fb, 0x001089fb, 0x0201f800,
8873 0x001005d8, 0x4a026203, 0x00000001, 0x493a6403,
8874 0x42000800, 0x80000040, 0x0201f000, 0x00020721,
8875 0x4933c857, 0x59cc1204, 0x480a601c, 0x59cc1404,
8876 0x0201f800, 0x00109410, 0x0400001b, 0x591c0203,
8877 0x82000580, 0x00000000, 0x04000017, 0x591c0009,
8878 0x81340580, 0x04020014, 0x4d300000, 0x4d1c0000,
8879 0x411e6000, 0x0401f9c2, 0x5c023800, 0x5c026000,
8880 0x0400000b, 0x59cc0005, 0x8c000500, 0x04020003,
8881 0x0401f98c, 0x0401f003, 0x4a023a03, 0x00000002,
8882 0x4a026403, 0x00000086, 0x0401f005, 0x0401f9a6,
8883 0x040007f5, 0x4a026403, 0x00000087, 0x4a026203,
8884 0x00000001, 0x42000800, 0x80000040, 0x0201f800,
8885 0x00020721, 0x59340200, 0x8c00050e, 0x0400000d,
8886 0x59cc1404, 0x0201f800, 0x00109410, 0x04000009,
8887 0x591c0414, 0x8c00051a, 0x04000006, 0x4d300000,
8888 0x411e6000, 0x0201f800, 0x0010921e, 0x5c026000,
8889 0x1c01f000, 0x83380580, 0x00000013, 0x0402000a,
8890 0x59300403, 0x82000d80, 0x00000086, 0x04000012,
8891 0x82000d80, 0x00000087, 0x02020800, 0x001005d8,
8892 0x0401f00d, 0x83380580, 0x00000027, 0x04000005,
8893 0x83380580, 0x00000014, 0x02020800, 0x001005d8,
8894 0x493bc857, 0x0201f800, 0x00106bbf, 0x0201f000,
8895 0x00107911, 0x4933c857, 0x0201f000, 0x00107911,
8896 0x83380580, 0x00000013, 0x04020005, 0x59300403,
8897 0x82000480, 0x00000085, 0x0c01f04d, 0x83380580,
8898 0x00000027, 0x04020041, 0x4933c857, 0x0201f800,
8899 0x00106bbf, 0x4d3c0000, 0x417a7800, 0x0201f800,
8900 0x0010203c, 0x5c027800, 0x42003000, 0x00000015,
8901 0x41782800, 0x42002000, 0x00000003, 0x42028000,
8902 0x00000029, 0x4d400000, 0x4d440000, 0x59368c03,
8903 0x0201f800, 0x0010985e, 0x5c028800, 0x5c028000,
8904 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
8905 0x0201f800, 0x00109037, 0x0400000c, 0x4d2c0000,
8906 0x59325808, 0x4a025a04, 0x00000103, 0x59300402,
8907 0x48025c06, 0x497a5c09, 0x49425a06, 0x0201f800,
8908 0x000202da, 0x5c025800, 0x0201f800, 0x0010912a,
8909 0x0201f000, 0x0002077d, 0x83380580, 0x00000089,
8910 0x04000005, 0x83380580, 0x0000008a, 0x02020000,
8911 0x00107974, 0x0201f800, 0x00106f60, 0x02020000,
8912 0x00107974, 0x59300a03, 0x82040580, 0x0000000a,
8913 0x0400002a, 0x82040580, 0x0000000c, 0x04000027,
8914 0x0201f800, 0x001005d8, 0x83380580, 0x00000014,
8915 0x040207ea, 0x4933c857, 0x0201f800, 0x00106bbf,
8916 0x42028000, 0x00000006, 0x0401f7d2, 0x00108aba,
8917 0x00108ab8, 0x00108ab8, 0x00108ab8, 0x00108ab8,
8918 0x00108ab8, 0x00108ac0, 0x00108ab8, 0x00108ab8,
8919 0x00108ab8, 0x00108ab8, 0x00108ab8, 0x00108ab8,
8920 0x0201f800, 0x001005d8, 0x4933c857, 0x59a80037,
8921 0x48026206, 0x4a026203, 0x0000000a, 0x1c01f000,
8922 0x4933c857, 0x59a80037, 0x48026206, 0x4a026203,
8923 0x0000000c, 0x1c01f000, 0x83380580, 0x00000089,
8924 0x04000008, 0x83380580, 0x0000008a, 0x04000032,
8925 0x4933c857, 0x493bc857, 0x0201f000, 0x00107974,
8926 0x4933c857, 0x59325808, 0x59300a1d, 0x82040580,
8927 0x00000003, 0x04020004, 0x0201f800, 0x001049b2,
8928 0x0401f00c, 0x5930021d, 0x82000580, 0x00000001,
8929 0x04020008, 0x59300c16, 0x82040580, 0x00000039,
8930 0x0400002c, 0x82040580, 0x00000035, 0x04000029,
8931 0x4c340000, 0x41306800, 0x0201f800, 0x0002075a,
8932 0x04000010, 0x4a026203, 0x00000001, 0x4a026403,
8933 0x0000001e, 0x59cc0c07, 0x48066419, 0x59cc0a07,
8934 0x48066219, 0x49366009, 0x4a026406, 0x00000001,
8935 0x42000800, 0x80000040, 0x0201f800, 0x00020721,
8936 0x40366000, 0x0201f800, 0x0002077d, 0x5c006800,
8937 0x1c01f000, 0x4933c857, 0x5930021d, 0x82000580,
8938 0x00000001, 0x04020040, 0x59300c16, 0x82040580,
8939 0x00000035, 0x04000007, 0x82040580, 0x0000001e,
8940 0x04000004, 0x82040580, 0x00000039, 0x04020036,
8941 0x4933c857, 0x4c500000, 0x4d1c0000, 0x4130a000,
8942 0x40067000, 0x0201f800, 0x001093ba, 0x04020029,
8943 0x0201f800, 0x0002075a, 0x04000026, 0x491fc857,
8944 0x4933c857, 0x83380580, 0x00000035, 0x04000004,
8945 0x83380580, 0x00000039, 0x04020002, 0x4932381c,
8946 0x493a6403, 0x4a026203, 0x00000001, 0x4a026406,
8947 0x00000001, 0x58500809, 0x4807c857, 0x48066009,
8948 0x58500c15, 0x4807c857, 0x48066415, 0x58500a15,
8949 0x4807c857, 0x48066215, 0x58500a16, 0x4807c857,
8950 0x48066216, 0x58500c19, 0x4807c857, 0x48066419,
8951 0x58500a19, 0x4807c857, 0x48066219, 0x491e601e,
8952 0x42000800, 0x80000040, 0x0201f800, 0x00020721,
8953 0x40526000, 0x5c023800, 0x5c00a000, 0x0201f000,
8954 0x0002077d, 0x5930021d, 0x82000580, 0x00000003,
8955 0x02000800, 0x001049b2, 0x0201f000, 0x0002077d,
8956 0x4803c856, 0x4c500000, 0x4c540000, 0x412c7800,
8957 0x4c3c0000, 0x42002800, 0x00000001, 0x82040480,
8958 0x00000101, 0x04001003, 0x42000800, 0x00000100,
8959 0x40043000, 0x42000800, 0x0000001c, 0x83cca400,
8960 0x0000000c, 0x832cac00, 0x0000000d, 0x0401f844,
8961 0x82183480, 0x0000001c, 0x592e5801, 0x812e59c0,
8962 0x02020800, 0x001007fd, 0x0201f800, 0x001007e4,
8963 0x04000017, 0x80142800, 0x4a025a04, 0x00000110,
8964 0x497a5c04, 0x492c7801, 0x82180c80, 0x0000003d,
8965 0x04021006, 0x40180800, 0x832cac00, 0x00000005,
8966 0x0401f82f, 0x0401f00a, 0x82183480, 0x0000003c,
8967 0x42000800, 0x0000003c, 0x412c7800, 0x832cac00,
8968 0x00000005, 0x0401f826, 0x0401f7e8, 0x5c007800,
8969 0x841429c0, 0x82142d40, 0x00000003, 0x48147a04,
8970 0x403e5800, 0x5c00a800, 0x5c00a000, 0x1c01f000,
8971 0x492fc857, 0x812e59c0, 0x0400000f, 0x4d2c0000,
8972 0x4c3c0000, 0x592c7801, 0x803c79c0, 0x04000006,
8973 0x497a5801, 0x0201f800, 0x000202da, 0x403e5800,
8974 0x0401f7f9, 0x5c007800, 0x0201f800, 0x000202da,
8975 0x5c025800, 0x1c01f000, 0x4803c856, 0x4c580000,
8976 0x82040c00, 0x00000003, 0x8004b104, 0x0201f800,
8977 0x0010ab17, 0x5c00b000, 0x1c01f000, 0x4803c856,
8978 0x4c580000, 0x82040c00, 0x00000003, 0x8004b104,
8979 0x0201f800, 0x0010ab17, 0x5c00b000, 0x1c01f000,
8980 0x591c0c06, 0x82040580, 0x00000003, 0x04000004,
8981 0x82040580, 0x00000002, 0x0402001a, 0x4d300000,
8982 0x4d2c0000, 0x411e6000, 0x59325808, 0x0201f800,
8983 0x00109037, 0x0400000f, 0x4d400000, 0x42028000,
8984 0x00000013, 0x592c0a08, 0x84040d54, 0x0201f800,
8985 0x00104e70, 0x5c028000, 0x0201f800, 0x0010959c,
8986 0x0201f800, 0x000202da, 0x0201f800, 0x0010912a,
8987 0x0201f800, 0x00107911, 0x5c025800, 0x5c026000,
8988 0x1c01f000, 0x59cc0005, 0x8c000500, 0x0402000b,
8989 0x591c0406, 0x82000580, 0x00000002, 0x04020007,
8990 0x591c0c03, 0x82040580, 0x00000085, 0x04000003,
8991 0x82040580, 0x0000008b, 0x1c01f000, 0x4933c857,
8992 0x4d3c0000, 0x42027800, 0x00000002, 0x59300406,
8993 0x82000c80, 0x00000012, 0x02021800, 0x001005d8,
8994 0x0c01f80a, 0x5c027800, 0x1c01f000, 0x4933c857,
8995 0x59300406, 0x82000c80, 0x00000012, 0x02021800,
8996 0x001005d8, 0x0c01f001, 0x00108c01, 0x00108bfe,
8997 0x00108bfe, 0x00108c29, 0x00108bfc, 0x00108bfe,
8998 0x00108c1a, 0x00108bfe, 0x00108bfc, 0x001065f4,
8999 0x00108bfe, 0x00108bfe, 0x00108bfe, 0x00108bfc,
9000 0x00108bfc, 0x00108bfc, 0x00108cf9, 0x00108bfe,
9001 0x0201f800, 0x001005d8, 0x4803c856, 0x80000580,
9002 0x1c01f000, 0x4803c856, 0x8d3e7d02, 0x04020016,
9003 0x0201f800, 0x00109037, 0x0400000f, 0x59325808,
9004 0x41780800, 0x4d400000, 0x42028000, 0x00000005,
9005 0x0201f800, 0x00104e70, 0x5c028000, 0x0201f800,
9006 0x0010959c, 0x0201f800, 0x001091cc, 0x0201f800,
9007 0x000202da, 0x0201f800, 0x00107911, 0x82000540,
9008 0x00000001, 0x1c01f000, 0x4933c857, 0x0201f800,
9009 0x001048d9, 0x0402000c, 0x4d400000, 0x42028000,
9010 0x00000010, 0x0201f800, 0x0010a1d1, 0x4a026406,
9011 0x00000006, 0x4a026203, 0x00000007, 0x5c028000,
9012 0x1c01f000, 0x4933c857, 0x0201f800, 0x00106c55,
9013 0x4df00000, 0x0401f8b8, 0x82000c80, 0x0000000e,
9014 0x02021800, 0x001005d8, 0x0c01f001, 0x00108c43,
9015 0x00108cb0, 0x00108c5a, 0x00108cc3, 0x00108cab,
9016 0x00108c41, 0x00108c43, 0x00108c43, 0x00108c47,
9017 0x00108c43, 0x00108c43, 0x00108c43, 0x00108c43,
9018 0x00108c5a, 0x0201f800, 0x001005d8, 0x5c03e000,
9019 0x02000800, 0x00106c4b, 0x0401f7b8, 0x5c03e000,
9020 0x02000800, 0x00106c4b, 0x59300406, 0x82000580,
9021 0x00000003, 0x040207b4, 0x59300203, 0x82000580,
9022 0x0000000d, 0x040007b0, 0x8d3e7d02, 0x040207ae,
9023 0x4d340000, 0x59326809, 0x0201f800, 0x001049b2,
9024 0x5c026800, 0x0401f7a8, 0x59300004, 0x8400055c,
9025 0x48026004, 0x0201f800, 0x00106c4b, 0x59300406,
9026 0x82000580, 0x00000006, 0x04000043, 0x8d3e7d02,
9027 0x04020041, 0x497a621d, 0x59300203, 0x82000580,
9028 0x0000000d, 0x04000003, 0x4a02621d, 0x00000003,
9029 0x0401fbcb, 0x04000024, 0x4d2c0000, 0x4d400000,
9030 0x59325808, 0x0201f800, 0x001091cc, 0x592c0408,
9031 0x8c000512, 0x04000009, 0x4d2c0000, 0x84000512,
9032 0x48025c08, 0x592c0809, 0x40065800, 0x0201f800,
9033 0x001007fd, 0x5c025800, 0x4d400000, 0x42028000,
9034 0x00000005, 0x592c0a08, 0x8c040d0e, 0x04000004,
9035 0x42028000, 0x00000002, 0x0401f001, 0x0201f800,
9036 0x00104e70, 0x5c028000, 0x0201f800, 0x0010959c,
9037 0x0201f800, 0x000202da, 0x497a6008, 0x5c028000,
9038 0x5c025800, 0x8d3e7d00, 0x04000009, 0x4d340000,
9039 0x59326809, 0x0201f800, 0x001049b2, 0x5c026800,
9040 0x0201f800, 0x00107911, 0x0401f00b, 0x4a026403,
9041 0x00000085, 0x4a026203, 0x00000009, 0x4a026406,
9042 0x00000002, 0x42000800, 0x8000404b, 0x0201f800,
9043 0x00020721, 0x5c03e000, 0x02020800, 0x00106c55,
9044 0x82000540, 0x00000001, 0x1c01f000, 0x0201f800,
9045 0x00106c4b, 0x0201f800, 0x00100e99, 0x0401f7ab,
9046 0x598c000d, 0x81300580, 0x04020004, 0x0201f800,
9047 0x00106e8e, 0x0402001b, 0x0201f800, 0x001068d3,
9048 0x04020006, 0x59300c03, 0x82040580, 0x00000040,
9049 0x0400078b, 0x0401f79d, 0x0201f800, 0x00106b6c,
9050 0x04000010, 0x0201f800, 0x001005d8, 0x0401f813,
9051 0x04020004, 0x0201f800, 0x00106e62, 0x04020009,
9052 0x0201f800, 0x001067ae, 0x040207f4, 0x59300c03,
9053 0x82040580, 0x00000040, 0x04000779, 0x0401f78b,
9054 0x59300203, 0x82000c80, 0x0000000e, 0x02021800,
9055 0x001005d8, 0x0c01f75e, 0x417a3000, 0x42032000,
9056 0x0000bf32, 0x59900004, 0x81300580, 0x04000009,
9057 0x83932400, 0x00000010, 0x811a3000, 0x83180480,
9058 0x00000005, 0x040017f8, 0x82000540, 0x00000001,
9059 0x1c01f000, 0x59300004, 0x8c00053e, 0x04000010,
9060 0x8c00050c, 0x0402000e, 0x8c000516, 0x04020006,
9061 0x82000d00, 0x0000001f, 0x82040580, 0x00000005,
9062 0x04020004, 0x42000000, 0x00000003, 0x0401f005,
9063 0x42000000, 0x00000001, 0x0401f002, 0x59300203,
9064 0x1c01f000, 0x4933c857, 0x0201f800, 0x00106c55,
9065 0x4df00000, 0x59300203, 0x82000c80, 0x0000000e,
9066 0x02021800, 0x001005d8, 0x0c01f001, 0x00108d13,
9067 0x00108d30, 0x00108d17, 0x00108d11, 0x00108d11,
9068 0x00108d11, 0x00108d11, 0x00108d11, 0x00108d11,
9069 0x00108d11, 0x00108d11, 0x00108d11, 0x00108d11,
9070 0x00108d11, 0x0201f800, 0x001005d8, 0x5c03e000,
9071 0x02000800, 0x00106c4b, 0x0401f6e8, 0x5c03e000,
9072 0x02000800, 0x00106c4b, 0x4d2c0000, 0x59325808,
9073 0x59300403, 0x82000580, 0x00000052, 0x02000800,
9074 0x00101231, 0x0401fb16, 0x02000800, 0x001005d8,
9075 0x4a025a06, 0x00000005, 0x0201f800, 0x000202da,
9076 0x0201f800, 0x00104c19, 0x0201f800, 0x00107911,
9077 0x5c025800, 0x82000540, 0x00000001, 0x1c01f000,
9078 0x598c000d, 0x81300580, 0x0402001a, 0x59300004,
9079 0x8c000520, 0x04000004, 0x84000520, 0x48026004,
9080 0x0401f01a, 0x42001000, 0x0010b7f6, 0x50081000,
9081 0x58080002, 0x82000580, 0x00000100, 0x0400000a,
9082 0x5808000c, 0x81300580, 0x02020800, 0x001005d8,
9083 0x0201f800, 0x001068d3, 0x02020800, 0x001005d8,
9084 0x0401f7cf, 0x0201f800, 0x00106e8e, 0x0402000c,
9085 0x59300004, 0x8c000520, 0x04000004, 0x84000520,
9086 0x48026004, 0x0401f7c6, 0x0201f800, 0x001068d3,
9087 0x040007c3, 0x0201f800, 0x001005d8, 0x59300203,
9088 0x82000c80, 0x0000000e, 0x02021800, 0x001005d8,
9089 0x0c01f7a7, 0x59300406, 0x4933c857, 0x4803c857,
9090 0x82000c80, 0x00000012, 0x02021800, 0x001005d8,
9091 0x0c01f001, 0x00108d7c, 0x00108e41, 0x00108f79,
9092 0x00108d88, 0x00107911, 0x00108d7c, 0x0010a1c0,
9093 0x0002077d, 0x00108e41, 0x001065ce, 0x00108fda,
9094 0x00108d77, 0x00108d77, 0x00108d77, 0x00108d77,
9095 0x00108d77, 0x001096eb, 0x001096eb, 0x0201f800,
9096 0x001005d8, 0x0401fbd5, 0x02000000, 0x0010801c,
9097 0x1c01f000, 0x0201f800, 0x00106c55, 0x0201f800,
9098 0x00106bbf, 0x0201f800, 0x00106c4b, 0x0201f000,
9099 0x0002077d, 0x4a026206, 0x00000001, 0x1c01f000,
9100 0x42000000, 0x0010b872, 0x0201f800, 0x0010aa47,
9101 0x4d2c0000, 0x4d400000, 0x417a5800, 0x0401faa8,
9102 0x04000007, 0x59325808, 0x592c0208, 0x8400054c,
9103 0x48025a08, 0x42028000, 0x00000006, 0x0201f800,
9104 0x00106c55, 0x0401ff4c, 0x4803c857, 0x82000c80,
9105 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f806,
9106 0x0201f800, 0x00106c4b, 0x5c028000, 0x5c025800,
9107 0x1c01f000, 0x00108e40, 0x00108db5, 0x00108dc3,
9108 0x00108de5, 0x00108e11, 0x00108db3, 0x00108d7c,
9109 0x00108d7c, 0x00108d7c, 0x00108db3, 0x00108db3,
9110 0x00108db3, 0x00108db3, 0x00108dc3, 0x0201f800,
9111 0x001005d8, 0x598c000d, 0x81300580, 0x04020004,
9112 0x0201f800, 0x00106e8e, 0x04020038, 0x0201f800,
9113 0x001068d3, 0x0400003b, 0x0201f800, 0x00106b6c,
9114 0x04000032, 0x0201f800, 0x001005d8, 0x497a621d,
9115 0x812e59c0, 0x02000800, 0x001005d8, 0x592c0204,
9116 0x82000500, 0x000000ff, 0x82000580, 0x00000014,
9117 0x04000003, 0x4a02621d, 0x00000003, 0x592c0a08,
9118 0x0201f800, 0x00104e70, 0x0201f800, 0x0010959c,
9119 0x0201f800, 0x000202da, 0x497a6008, 0x4a026403,
9120 0x00000085, 0x4a026203, 0x00000009, 0x4a026406,
9121 0x00000002, 0x4a026004, 0x8000404b, 0x0201f800,
9122 0x00106c4b, 0x42000800, 0x8000404b, 0x0201f000,
9123 0x00020721, 0x0401fef1, 0x04020004, 0x0201f800,
9124 0x00106e62, 0x04020009, 0x0201f800, 0x001067ae,
9125 0x040207d2, 0x59300c03, 0x82040580, 0x00000040,
9126 0x04000008, 0x0401f7d2, 0x59300203, 0x82000c80,
9127 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f7ae,
9128 0x0201f800, 0x00106c4b, 0x812e59c0, 0x04000013,
9129 0x592c0a08, 0x0201f800, 0x00104e70, 0x0201f800,
9130 0x0010959c, 0x0201f800, 0x000202da, 0x59300203,
9131 0x82000580, 0x0000000d, 0x04000008, 0x0201f800,
9132 0x00106c4b, 0x4d340000, 0x59326809, 0x0201f800,
9133 0x001049b2, 0x5c026800, 0x0201f800, 0x00107911,
9134 0x0401f030, 0x812e59c0, 0x02000800, 0x001005d8,
9135 0x0201f800, 0x0010940a, 0x04020004, 0x0201f800,
9136 0x00100e99, 0x0401f7aa, 0x0201f800, 0x00106c4b,
9137 0x592c0208, 0x8400050c, 0x48025a08, 0x592c0406,
9138 0x800000c2, 0x800008c4, 0x80040c00, 0x48066206,
9139 0x42000000, 0x10000000, 0x41300800, 0x0201f800,
9140 0x00100b94, 0x0400000d, 0x592c0208, 0x8c00051c,
9141 0x04020006, 0x8400055c, 0x48025a08, 0x4a026206,
9142 0x00000002, 0x0401f00f, 0x4d300000, 0x0201f800,
9143 0x001012e5, 0x5c026000, 0x59300203, 0x82000580,
9144 0x00000004, 0x04020007, 0x4d380000, 0x42027000,
9145 0x00000048, 0x0201f800, 0x000207a1, 0x5c027000,
9146 0x1c01f000, 0x42000000, 0x0010b86e, 0x0201f800,
9147 0x0010aa47, 0x59300203, 0x82000c80, 0x0000000e,
9148 0x02021800, 0x001005d8, 0x4803c857, 0x0c01f001,
9149 0x00108e5a, 0x00108d85, 0x00108e5c, 0x00108e5a,
9150 0x00108e5c, 0x00108e5c, 0x00108d7d, 0x00108e5a,
9151 0x00108d79, 0x00108e5a, 0x00108e5a, 0x00108e5a,
9152 0x00108e5a, 0x00108e5a, 0x0201f800, 0x001005d8,
9153 0x4d340000, 0x4d2c0000, 0x59326809, 0x59340400,
9154 0x82000500, 0x000000ff, 0x82000c80, 0x0000000c,
9155 0x02021800, 0x001005d8, 0x59303403, 0x82180d80,
9156 0x00000004, 0x04020004, 0x42000000, 0x00000001,
9157 0x0401f006, 0x82180d80, 0x00000000, 0x04020003,
9158 0x42000000, 0x00000001, 0x4803c857, 0x0c01f804,
9159 0x5c025800, 0x5c026800, 0x1c01f000, 0x00108e83,
9160 0x00108f22, 0x00108e85, 0x00108eba, 0x00108e85,
9161 0x00108f3f, 0x00108e85, 0x00108e8f, 0x00108e83,
9162 0x00108f3f, 0x00108e83, 0x00108e9e, 0x0201f800,
9163 0x001005d8, 0x59300403, 0x82000d80, 0x00000016,
9164 0x0400002e, 0x82000d80, 0x00000004, 0x0400002b,
9165 0x82000d80, 0x00000002, 0x04000028, 0x0401fabf,
9166 0x04000079, 0x59300403, 0x82000d80, 0x00000022,
9167 0x040000ae, 0x82000d80, 0x00000039, 0x040000b3,
9168 0x82000d80, 0x00000035, 0x040000b0, 0x82000d80,
9169 0x0000001e, 0x0400001b, 0x0401f999, 0x04000007,
9170 0x0201f800, 0x00109597, 0x04020004, 0x0201f800,
9171 0x00104a14, 0x0401f011, 0x59300403, 0x82000d80,
9172 0x00000001, 0x04020004, 0x0201f800, 0x001049e7,
9173 0x0400000a, 0x4d3c0000, 0x417a7800, 0x0201f800,
9174 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864,
9175 0x0201f800, 0x0010aa47, 0x0201f800, 0x0010801c,
9176 0x0201f000, 0x00107911, 0x0401f97d, 0x04000004,
9177 0x0201f800, 0x00109597, 0x040000a9, 0x59300c03,
9178 0x82040580, 0x00000016, 0x04000056, 0x82040580,
9179 0x00000002, 0x04020034, 0x59a80026, 0x8c000502,
9180 0x04020013, 0x0201f800, 0x0010513b, 0x04020010,
9181 0x0201f800, 0x00105151, 0x04020006, 0x42000000,
9182 0x00000001, 0x0201f800, 0x00105113, 0x0401f094,
9183 0x4a035033, 0x00000001, 0x4202d800, 0x00000001,
9184 0x0201f800, 0x001050a2, 0x0401f08d, 0x59340403,
9185 0x82000580, 0x000007fc, 0x04000008, 0x59a80026,
9186 0x8c00050a, 0x04020084, 0x59340212, 0x82000500,
9187 0x0000ff00, 0x04000082, 0x59340412, 0x82000500,
9188 0x000000ff, 0x04000010, 0x80000040, 0x48026c12,
9189 0x497a6008, 0x4a026406, 0x00000007, 0x4a026206,
9190 0x00000398, 0x497a6205, 0x0201f800, 0x0002075a,
9191 0x04000005, 0x49366009, 0x4a026406, 0x00000001,
9192 0x0401f020, 0x59300403, 0x82000d80, 0x00000002,
9193 0x0402000d, 0x59340403, 0x82000580, 0x000007fe,
9194 0x04020009, 0x59a80026, 0x84000540, 0x48035026,
9195 0x0201f800, 0x00104237, 0x0201f800, 0x0010801c,
9196 0x0401f00c, 0x0201f800, 0x0010801c, 0x4d3c0000,
9197 0x417a7800, 0x0201f800, 0x0010203c, 0x5c027800,
9198 0x42000000, 0x0010b864, 0x0201f800, 0x0010aa47,
9199 0x0201f800, 0x00102074, 0x0201f000, 0x00107911,
9200 0x42000800, 0x00000003, 0x0201f800, 0x00104571,
9201 0x4a026203, 0x00000001, 0x4a026403, 0x00000002,
9202 0x0201f000, 0x0010672b, 0x0401f915, 0x04020793,
9203 0x0201f800, 0x00102074, 0x4d3c0000, 0x417a7800,
9204 0x0201f800, 0x0010203c, 0x5c027800, 0x42000000,
9205 0x0010b864, 0x0201f800, 0x0010aa47, 0x42003000,
9206 0x00000018, 0x41782800, 0x42002000, 0x00000000,
9207 0x4d400000, 0x4d440000, 0x59368c03, 0x42028000,
9208 0x00000029, 0x0201f800, 0x0010985e, 0x5c028800,
9209 0x5c028000, 0x0201f000, 0x00107911, 0x0201f800,
9210 0x00104a14, 0x0401f7c8, 0x42000000, 0x0010b86d,
9211 0x0201f800, 0x0010aa47, 0x0201f800, 0x00107b76,
9212 0x040207c1, 0x1c01f000, 0x4d380000, 0x59327403,
9213 0x0201f800, 0x001093ba, 0x5c027000, 0x02020000,
9214 0x0002077d, 0x836c0580, 0x00000003, 0x04000004,
9215 0x4a026206, 0x00000002, 0x1c01f000, 0x59300403,
9216 0x48026416, 0x4a02621d, 0x00000001, 0x4a026403,
9217 0x00000085, 0x4a026203, 0x00000009, 0x4a026406,
9218 0x00000002, 0x42000800, 0x8000004b, 0x0201f000,
9219 0x00020721, 0x0201f800, 0x00102074, 0x0201f800,
9220 0x0010801c, 0x4d3c0000, 0x417a7800, 0x0201f800,
9221 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864,
9222 0x0201f800, 0x0010aa47, 0x497a6008, 0x4a026406,
9223 0x00000007, 0x4a026206, 0x00000398, 0x497a6205,
9224 0x1c01f000, 0x42000000, 0x0010b870, 0x0201f800,
9225 0x0010aa47, 0x4d340000, 0x59326809, 0x59300203,
9226 0x82000c80, 0x0000000e, 0x02021800, 0x001005d8,
9227 0x4803c857, 0x0c01f803, 0x5c026800, 0x1c01f000,
9228 0x00108f96, 0x00108d85, 0x00108f96, 0x00108f96,
9229 0x00108f96, 0x00108f96, 0x00108f96, 0x00108f96,
9230 0x00108f96, 0x00108d85, 0x00108f98, 0x00108d85,
9231 0x00108fa0, 0x00108f96, 0x0201f800, 0x001005d8,
9232 0x4a026403, 0x0000008b, 0x4a026203, 0x0000000b,
9233 0x42000800, 0x8000404b, 0x0201f000, 0x00020721,
9234 0x59300a1d, 0x4d3c0000, 0x417a7800, 0x0201f800,
9235 0x0010203c, 0x5c027800, 0x42003000, 0x00000011,
9236 0x0201f800, 0x0010a942, 0x42000000, 0x0010b864,
9237 0x0201f800, 0x0010aa47, 0x41306800, 0x0201f800,
9238 0x0002075a, 0x04000008, 0x49366009, 0x4d300000,
9239 0x40366000, 0x0201f800, 0x00107911, 0x5c026000,
9240 0x0401f002, 0x40366000, 0x497a6008, 0x4a026406,
9241 0x00000001, 0x4a026403, 0x00000001, 0x0201f800,
9242 0x00103b25, 0x04000011, 0x4a026406, 0x00000004,
9243 0x4a026203, 0x00000007, 0x4a026420, 0x00000001,
9244 0x42003000, 0x00000004, 0x4d400000, 0x42028000,
9245 0x00000029, 0x41782800, 0x0201f800, 0x0010a43e,
9246 0x5c028000, 0x1c01f000, 0x42000800, 0x0000000b,
9247 0x0201f800, 0x00104571, 0x4a026203, 0x00000001,
9248 0x0201f000, 0x0010672b, 0x42000000, 0x0010b876,
9249 0x0201f800, 0x0010aa47, 0x59300203, 0x82000c80,
9250 0x0000000e, 0x02021800, 0x001005d8, 0x4803c857,
9251 0x0c01f001, 0x0010900b, 0x00108ff3, 0x00108ff7,
9252 0x0010900c, 0x00108ff5, 0x00108ff3, 0x00108ff3,
9253 0x00108ff3, 0x00108ff3, 0x00108ff3, 0x00108ff3,
9254 0x00108ff3, 0x00108ff3, 0x00108ff3, 0x0201f800,
9255 0x001005d8, 0x0201f800, 0x00100e99, 0x4d2c0000,
9256 0x59325808, 0x4a025a06, 0x00000006, 0x0201f800,
9257 0x000202da, 0x5c025800, 0x497a6008, 0x4a02621d,
9258 0x0000000a, 0x4a026403, 0x00000085, 0x4a026203,
9259 0x00000009, 0x4a026406, 0x00000002, 0x42000800,
9260 0x8000404b, 0x0201f000, 0x00020721, 0x1c01f000,
9261 0x0201f800, 0x00106c55, 0x4df00000, 0x0401fcc7,
9262 0x04020004, 0x0201f800, 0x00106e62, 0x0402000c,
9263 0x0201f800, 0x001067ae, 0x04020005, 0x5c03e000,
9264 0x0201f800, 0x00106c4b, 0x0401f7dd, 0x0201f800,
9265 0x00106b6c, 0x02020800, 0x001005d8, 0x5c03e000,
9266 0x0201f800, 0x00106c4b, 0x59300203, 0x82000d80,
9267 0x00000003, 0x02000800, 0x001005d8, 0x82000c80,
9268 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f7ba,
9269 0x4803c856, 0x59a8000e, 0x59a80867, 0x80040400,
9270 0x80080480, 0x04021004, 0x82000540, 0x00000001,
9271 0x1c01f000, 0x80000580, 0x1c01f000, 0x4803c856,
9272 0x4c080000, 0x59301008, 0x82081500, 0xfff00000,
9273 0x5c001000, 0x1c01f000, 0x4803c856, 0x4d300000,
9274 0x0201f800, 0x0002075a, 0x0400000a, 0x0401f82f,
9275 0x4d380000, 0x42027000, 0x0000004b, 0x0201f800,
9276 0x000207a1, 0x5c027000, 0x82000540, 0x00000001,
9277 0x5c026000, 0x1c01f000, 0x4803c856, 0x4d300000,
9278 0x0201f800, 0x00107942, 0x0400001b, 0x0401f81f,
9279 0x4d300000, 0x0201f800, 0x00106c55, 0x4d3c0000,
9280 0x417a7800, 0x0201f800, 0x00106ab4, 0x0201f800,
9281 0x001067fd, 0x5c027800, 0x0201f800, 0x0010a2ff,
9282 0x0201f800, 0x00106c4b, 0x5c026000, 0x8d3e7d3e,
9283 0x0402000b, 0x4d380000, 0x42027000, 0x0000004c,
9284 0x0201f800, 0x000207a1, 0x5c027000, 0x82000540,
9285 0x00000001, 0x5c026000, 0x1c01f000, 0x0201f800,
9286 0x0002077d, 0x0401f7fa, 0x592c0407, 0x494a6017,
9287 0x494e6018, 0x49366009, 0x492e6008, 0x4a026406,
9288 0x00000003, 0x800000c2, 0x800008c4, 0x80040400,
9289 0x48026206, 0x1c01f000, 0x493bc857, 0x4d300000,
9290 0x0201f800, 0x0002075a, 0x0400000d, 0x0401ffef,
9291 0x4d400000, 0x42028000, 0x00000005, 0x0401f80d,
9292 0x5c028000, 0x8d3e7d3e, 0x04020007, 0x0201f800,
9293 0x000207a1, 0x82000540, 0x00000001, 0x5c026000,
9294 0x1c01f000, 0x0201f800, 0x0002077d, 0x0401f7fa,
9295 0x4803c856, 0x0201f800, 0x00106c55, 0x4d3c0000,
9296 0x4d440000, 0x59368c03, 0x42027800, 0x00000001,
9297 0x0201f800, 0x001069b6, 0x0201f800, 0x0010692e,
9298 0x0201f800, 0x001067fd, 0x0201f800, 0x0010a2ff,
9299 0x5c028800, 0x5c027800, 0x0201f000, 0x00106c4b,
9300 0x4803c856, 0x4d300000, 0x0201f800, 0x0002075a,
9301 0x0400000f, 0x481a601c, 0x48ee6021, 0x49366009,
9302 0x4a026406, 0x00000001, 0x492e6008, 0x4d380000,
9303 0x42027000, 0x0000001f, 0x0201f800, 0x000207a1,
9304 0x5c027000, 0x82000540, 0x00000001, 0x5c026000,
9305 0x1c01f000, 0x4803c856, 0x4d300000, 0x0201f800,
9306 0x0002075a, 0x0400000e, 0x48ee6021, 0x49366009,
9307 0x4a026406, 0x00000001, 0x492e6008, 0x4d380000,
9308 0x42027000, 0x00000055, 0x0201f800, 0x000207a1,
9309 0x5c027000, 0x82000540, 0x00000001, 0x5c026000,
9310 0x1c01f000, 0x4803c856, 0x4d300000, 0x0201f800,
9311 0x0002075a, 0x0400000f, 0x481a601c, 0x48ee6021,
9312 0x49366009, 0x4a026406, 0x00000001, 0x492e6008,
9313 0x4d380000, 0x42027000, 0x0000003d, 0x0201f800,
9314 0x000207a1, 0x5c027000, 0x82000540, 0x00000001,
9315 0x5c026000, 0x1c01f000, 0x4803c856, 0x4d300000,
9316 0x0201f800, 0x00107942, 0x04000014, 0x49366009,
9317 0x492fc857, 0x4933c857, 0x592c0404, 0x8c00051e,
9318 0x04000003, 0x48efc857, 0x48ee6021, 0x4a026406,
9319 0x00000001, 0x492e6008, 0x4d380000, 0x42027000,
9320 0x00000000, 0x0201f800, 0x000207a1, 0x5c027000,
9321 0x82000540, 0x00000001, 0x5c026000, 0x1c01f000,
9322 0x4803c856, 0x4d300000, 0x0201f800, 0x0002075a,
9323 0x0400000f, 0x48ee6021, 0x481a601c, 0x49366009,
9324 0x4a026406, 0x00000001, 0x492e6008, 0x4d380000,
9325 0x42027000, 0x00000044, 0x0201f800, 0x000207a1,
9326 0x5c027000, 0x82000540, 0x00000001, 0x5c026000,
9327 0x1c01f000, 0x4803c856, 0x4d300000, 0x0201f800,
9328 0x0002075a, 0x0400000f, 0x481a601c, 0x48ee6021,
9329 0x49366009, 0x4a026406, 0x00000001, 0x492e6008,
9330 0x4d380000, 0x42027000, 0x00000049, 0x0201f800,
9331 0x000207a1, 0x5c027000, 0x82000540, 0x00000001,
9332 0x5c026000, 0x1c01f000, 0x59300009, 0x80001540,
9333 0x02000800, 0x001005d8, 0x5808040b, 0x4803c856,
9334 0x80000040, 0x04001002, 0x4800140b, 0x1c01f000,
9335 0x4803c856, 0x59300403, 0x82000d80, 0x00000002,
9336 0x04000015, 0x82000d80, 0x00000003, 0x04000012,
9337 0x82000d80, 0x00000004, 0x0400000f, 0x82000d80,
9338 0x00000008, 0x0400000c, 0x82000d80, 0x0000000a,
9339 0x04000009, 0x599c0819, 0x8c040d0e, 0x04000004,
9340 0x82000d80, 0x00000000, 0x04000003, 0x82000540,
9341 0x00000001, 0x1c01f000, 0x4803c856, 0x4c000000,
9342 0x4d2c0000, 0x59300406, 0x82000580, 0x00000004,
9343 0x0400001d, 0x59300008, 0x80025d40, 0x800001c0,
9344 0x04000019, 0x0201f800, 0x00109597, 0x04000014,
9345 0x59300406, 0x82004580, 0x00000010, 0x04000010,
9346 0x82004580, 0x00000011, 0x0400000d, 0x82004580,
9347 0x00000003, 0x0400000c, 0x82004580, 0x00000002,
9348 0x04000009, 0x82004580, 0x0000000a, 0x04000006,
9349 0x592c0404, 0x8c00051e, 0x04000003, 0x80000580,
9350 0x0401f003, 0x82000540, 0x00000001, 0x5c025800,
9351 0x5c000000, 0x1c01f000, 0x4803c856, 0x4d300000,
9352 0x0201f800, 0x00107942, 0x04000013, 0x49366009,
9353 0x48ee6021, 0x4a026406, 0x00000001, 0x492e6008,
9354 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c,
9355 0x5c027800, 0x4d380000, 0x42027000, 0x00000028,
9356 0x0201f800, 0x000207a1, 0x5c027000, 0x82000540,
9357 0x00000001, 0x5c026000, 0x1c01f000, 0x4803c856,
9358 0x83380580, 0x00000015, 0x0402000d, 0x59a80016,
9359 0x82000580, 0x00000074, 0x04020009, 0x0201f800,
9360 0x0010462a, 0x4a026203, 0x00000001, 0x4a026403,
9361 0x00000029, 0x0201f000, 0x0010672b, 0x0201f800,
9362 0x0010801c, 0x0201f000, 0x0002077d, 0x4803c856,
9363 0x83380580, 0x00000016, 0x04020007, 0x42000800,
9364 0x00000004, 0x0201f800, 0x00104571, 0x0201f000,
9365 0x00107b38, 0x83380580, 0x00000015, 0x04020013,
9366 0x59a80016, 0x82000580, 0x00000014, 0x0402000f,
9367 0x0201f800, 0x0010468d, 0x0201f800, 0x0010846f,
9368 0x0402000a, 0x59340404, 0x80000540, 0x04000007,
9369 0x42000800, 0x00000006, 0x0201f800, 0x00104571,
9370 0x0201f000, 0x00107b38, 0x0201f800, 0x0010801c,
9371 0x0201f000, 0x0002077d, 0x4803c856, 0x592c0206,
9372 0x82000580, 0x00000005, 0x04000002, 0x1c01f000,
9373 0x4803c856, 0x592c0208, 0x8400054a, 0x48025a08,
9374 0x1c01f000, 0x497a6205, 0x497a6008, 0x4a026203,
9375 0x00000001, 0x4a026403, 0x00000050, 0x42000800,
9376 0x80000043, 0x0201f000, 0x00020721, 0x4933c857,
9377 0x4d340000, 0x59326809, 0x59340200, 0x8c00050e,
9378 0x04000006, 0x59300406, 0x82000c80, 0x00000012,
9379 0x04021004, 0x0c01f806, 0x5c026800, 0x1c01f000,
9380 0x0201f800, 0x00108d7c, 0x0401f7fc, 0x00108d7c,
9381 0x001091fd, 0x00109201, 0x00109204, 0x0010a49b,
9382 0x0010a4b8, 0x0010a4bc, 0x00108d7c, 0x00108d7c,
9383 0x00108d7c, 0x00108d7c, 0x00108d7c, 0x00108d7c,
9384 0x00108d7c, 0x00108d7c, 0x00108d7c, 0x00108d7c,
9385 0x00108d7c, 0x4803c856, 0x40000000, 0x40000000,
9386 0x1c01f000, 0x40000000, 0x40000000, 0x1c01f000,
9387 0x5930001c, 0x4803c857, 0x59300414, 0x4933c857,
9388 0x4803c857, 0x8c000502, 0x04000005, 0x84000502,
9389 0x84000540, 0x48026414, 0x1c01f000, 0x42000000,
9390 0xd0000000, 0x41300800, 0x0201f800, 0x00100b94,
9391 0x0401f80a, 0x04020008, 0x59a80037, 0x82000400,
9392 0x0000000a, 0x48026205, 0x59300414, 0x84000542,
9393 0x48026414, 0x1c01f000, 0x4933c857, 0x4d340000,
9394 0x59326809, 0x59340200, 0x8c00050e, 0x02000800,
9395 0x001005d8, 0x5930001c, 0x80000540, 0x0402002f,
9396 0x59a80021, 0x80000540, 0x0402002a, 0x4d1c0000,
9397 0x41323800, 0x0201f800, 0x0002075a, 0x04000023,
9398 0x4932381c, 0x591c0414, 0x84000542, 0x48023c14,
9399 0x49366009, 0x591c0406, 0x82000580, 0x00000003,
9400 0x04000006, 0x591c0202, 0x48026419, 0x591c0402,
9401 0x48026219, 0x0401f005, 0x591c0202, 0x48026219,
9402 0x591c0402, 0x48026419, 0x491e601e, 0x4a026406,
9403 0x00000001, 0x4a026403, 0x00000035, 0x4a026203,
9404 0x00000001, 0x42000800, 0x80000040, 0x0201f800,
9405 0x00020721, 0x411e6000, 0x5c023800, 0x80000580,
9406 0x5c026800, 0x1c01f000, 0x411e6000, 0x5c023800,
9407 0x59a80039, 0x48026205, 0x82000540, 0x00000001,
9408 0x0401f7f8, 0x4933c857, 0x4d2c0000, 0x4932381c,
9409 0x4a026202, 0x0000ffff, 0x591e5808, 0x591c0007,
9410 0x8c00051e, 0x04000005, 0x8400051e, 0x48023807,
9411 0x497a5c09, 0x0401f014, 0x592c0408, 0x8c000518,
9412 0x04000011, 0x84000518, 0x48025c08, 0x4a025c09,
9413 0x00000001, 0x0401fb2f, 0x497a5c09, 0x592c0408,
9414 0x8c000512, 0x04000008, 0x4d2c0000, 0x84000512,
9415 0x48025c08, 0x592e5809, 0x0201f800, 0x001007fd,
9416 0x5c025800, 0x59a80039, 0x48026205, 0x591c0214,
9417 0x48026216, 0x82000d80, 0x00000001, 0x04000008,
9418 0x4a023a03, 0x00000002, 0x82000580, 0x00000005,
9419 0x04000008, 0x497a6015, 0x0401f01e, 0x591c0007,
9420 0x84000540, 0x48023807, 0x4a023a03, 0x00000004,
9421 0x591c0414, 0x4803c857, 0x8400051c, 0x84000554,
9422 0x48023c14, 0x592c000f, 0x40001000, 0x591c0816,
9423 0x80040480, 0x040217f0, 0x591c0016, 0x82000500,
9424 0xfffffffc, 0x48026015, 0x48023816, 0x591c0a14,
9425 0x4807c857, 0x82040d80, 0x00000005, 0x04020005,
9426 0x480bc857, 0x4803c857, 0x4a023812, 0xffffffff,
9427 0x591c0402, 0x48026419, 0x591c0202, 0x48026219,
9428 0x591e6809, 0x49366009, 0x4a026406, 0x00000001,
9429 0x4a026403, 0x00000039, 0x4a026203, 0x00000001,
9430 0x42000800, 0x80000040, 0x0201f800, 0x00020721,
9431 0x5c025800, 0x1c01f000, 0x4933c857, 0x59300414,
9432 0x8c000514, 0x04000015, 0x8c00051c, 0x04020012,
9433 0x59300016, 0x80100480, 0x04001006, 0x04000005,
9434 0x59300414, 0x84000514, 0x8400055c, 0x0401f009,
9435 0x48126016, 0x48126012, 0x40100000, 0x592c180f,
9436 0x800c0480, 0x48026011, 0x59300414, 0x84000514,
9437 0x48026414, 0x1c01f000, 0x4933c857, 0x8c00051c,
9438 0x04020006, 0x59300012, 0x48026016, 0x59300414,
9439 0x8400055c, 0x48026414, 0x1c01f000, 0x59300c03,
9440 0x4933c857, 0x4807c857, 0x82040480, 0x00000034,
9441 0x04001006, 0x82040480, 0x0000003c, 0x04021003,
9442 0x80000580, 0x1c01f000, 0x82000540, 0x00000001,
9443 0x0401f7fd, 0x41780800, 0x59a81035, 0x42000000,
9444 0x00000032, 0x0201f800, 0x001066a0, 0x800811c0,
9445 0x04020003, 0x42001000, 0x00000014, 0x480b5037,
9446 0x59a81036, 0x480b502d, 0x41780800, 0x42000000,
9447 0x00000064, 0x0201f800, 0x001066a0, 0x800811c0,
9448 0x04020003, 0x42001000, 0x00000014, 0x480b5038,
9449 0x82081400, 0x0000000a, 0x480b5039, 0x42000800,
9450 0x00000001, 0x0201f800, 0x00106c78, 0x42000000,
9451 0x30000000, 0x40080800, 0x0201f800, 0x00100b68,
9452 0x42000800, 0x00000003, 0x59a81010, 0x0201f800,
9453 0x00106c78, 0x0201f000, 0x00104906, 0x4a035037,
9454 0x00000028, 0x4a035038, 0x00000014, 0x4a03502d,
9455 0x000007d0, 0x42001000, 0x0000001e, 0x480b5039,
9456 0x42000800, 0x00000001, 0x0201f800, 0x00106c78,
9457 0x42000000, 0x30000000, 0x40080800, 0x0201f800,
9458 0x00100b68, 0x42000800, 0x00000003, 0x59a81010,
9459 0x0201f000, 0x00106c78, 0x4933c857, 0x4d2c0000,
9460 0x59300403, 0x82000580, 0x0000003e, 0x04020005,
9461 0x59325817, 0x812e59c0, 0x02020800, 0x001007f4,
9462 0x5c025800, 0x1c01f000, 0x4937c857, 0x4d300000,
9463 0x0201f800, 0x0002075a, 0x04000011, 0x49366009,
9464 0x4a026406, 0x00000001, 0x492e6008, 0x42000800,
9465 0x00000009, 0x0201f800, 0x00104571, 0x4d380000,
9466 0x42027000, 0x00000033, 0x0201f800, 0x000207a1,
9467 0x5c027000, 0x82000540, 0x00000001, 0x5c026000,
9468 0x1c01f000, 0x4933c857, 0x4d2c0000, 0x4c580000,
9469 0x4d3c0000, 0x59325808, 0x83380580, 0x00000015,
9470 0x04020022, 0x59a8b016, 0x82580c80, 0x00000019,
9471 0x04001003, 0x4200b000, 0x00000018, 0x8058b104,
9472 0x0401fa07, 0x80000580, 0x0401fa17, 0x832cac00,
9473 0x00000009, 0x83cca400, 0x00000006, 0x0201f800,
9474 0x0010ab17, 0x42027800, 0x00000001, 0x592c100a,
9475 0x8c081518, 0x04020006, 0x59a80010, 0x592c100d,
9476 0x80080580, 0x04020006, 0x417a7800, 0x59301009,
9477 0x58081403, 0x0201f800, 0x001020a1, 0x0201f800,
9478 0x00107b38, 0x0401f008, 0x4200b000, 0x00000002,
9479 0x0401fa09, 0x0201f800, 0x0010801c, 0x0201f800,
9480 0x0002077d, 0x5c027800, 0x5c00b000, 0x5c025800,
9481 0x1c01f000, 0x4933c856, 0x49366009, 0x4a026406,
9482 0x00000001, 0x492e6008, 0x4d380000, 0x42027000,
9483 0x0000004d, 0x0201f800, 0x000207a1, 0x5c027000,
9484 0x82000540, 0x00000001, 0x1c01f000, 0x4803c856,
9485 0x4d2c0000, 0x83380580, 0x00000015, 0x04020027,
9486 0x59a80816, 0x59325808, 0x5930040b, 0x800000c4,
9487 0x80040580, 0x04020021, 0x4c500000, 0x4c540000,
9488 0x4c580000, 0x83cca400, 0x00000006, 0x4050a800,
9489 0x5930b40b, 0x0201f800, 0x0010ab28, 0x83cca400,
9490 0x00000006, 0x592cb205, 0x832cac00, 0x00000006,
9491 0x0201f800, 0x0010ab17, 0x592e5801, 0x812e59c0,
9492 0x040207f9, 0x5931d821, 0x58ef400b, 0x58ee580d,
9493 0x4a025a04, 0x00000103, 0x58ec0009, 0x0801f800,
9494 0x59300402, 0x5c00b000, 0x5c00a800, 0x5c00a000,
9495 0x5c025800, 0x1c01f000, 0x0201f800, 0x0010801c,
9496 0x5c025800, 0x1c01f000, 0x4933c857, 0x83380580,
9497 0x00000035, 0x04000005, 0x59301419, 0x0401f851,
9498 0x04000027, 0x0401f006, 0x4d300000, 0x5932601e,
9499 0x0401f856, 0x5c026000, 0x04000020, 0x591c0c06,
9500 0x82040580, 0x00000003, 0x04000004, 0x82040580,
9501 0x00000006, 0x0402001c, 0x591c0c02, 0x59300419,
9502 0x80040580, 0x04000009, 0x59300219, 0x80040580,
9503 0x04020015, 0x591c0a02, 0x59300419, 0x80040580,
9504 0x04020011, 0x0401f009, 0x59300a19, 0x82040580,
9505 0x0000ffff, 0x04000005, 0x591c0202, 0x59300a19,
9506 0x80040580, 0x04020008, 0x591c0009, 0x59300809,
9507 0x80040580, 0x1c01f000, 0x417a3800, 0x82000540,
9508 0x00000001, 0x1c01f000, 0x4803c856, 0x59b800e4,
9509 0x8c000538, 0x02020800, 0x001005d8, 0x42000800,
9510 0x0000012c, 0x4a0370e4, 0x20000000, 0x59b800e4,
9511 0x80040840, 0x02000800, 0x001005d8, 0x8c00053c,
9512 0x040207f9, 0x4a0370e4, 0x30000000, 0x40000000,
9513 0x40000000, 0x40000000, 0x59b800e4, 0x8c00053c,
9514 0x040207f1, 0x1c01f000, 0x4803c856, 0x4a0370e4,
9515 0x20000000, 0x40000000, 0x59b800e4, 0x8c000538,
9516 0x040207fb, 0x1c01f000, 0x59300807, 0x8c040d1e,
9517 0x592c0c08, 0x04020002, 0x8c040d18, 0x1c01f000,
9518 0x0401fc1c, 0x04000008, 0x42000800, 0x00000024,
9519 0x0201f800, 0x00106681, 0x82063c00, 0x0010d1c0,
9520 0x491fc857, 0x1c01f000, 0x83300480, 0x0010d1c0,
9521 0x0400100a, 0x59a8000b, 0x81300480, 0x04021007,
9522 0x59301402, 0x0401ffef, 0x04000007, 0x411c0000,
9523 0x81300580, 0x04000003, 0x81780500, 0x0401f002,
9524 0x81300540, 0x1c01f000, 0x4947c857, 0x4d300000,
9525 0x0201f800, 0x00020245, 0x0402000a, 0x42026000,
9526 0x0010bde9, 0x49366009, 0x492e6008, 0x0201f800,
9527 0x0010203c, 0x80000580, 0x5c026000, 0x1c01f000,
9528 0x82000540, 0x00000001, 0x0401f7fc, 0x4933c857,
9529 0x0201f800, 0x00109037, 0x02000800, 0x001005d8,
9530 0x4d2c0000, 0x4d340000, 0x4d440000, 0x4c580000,
9531 0x59325808, 0x59326809, 0x49425a06, 0x0201f800,
9532 0x00105755, 0x592e8c06, 0x592c4207, 0x82200500,
9533 0x0000000f, 0x0c01f806, 0x5c00b000, 0x5c028800,
9534 0x5c026800, 0x5c025800, 0x1c01f000, 0x00109466,
9535 0x00109488, 0x0010948f, 0x00109493, 0x0010949c,
9536 0x00109463, 0x00109463, 0x00109463, 0x001094a0,
9537 0x001094ac, 0x001094ac, 0x00109463, 0x00109463,
9538 0x00109463, 0x00109463, 0x00109463, 0x4803c857,
9539 0x0201f800, 0x001005d8, 0x814281c0, 0x04020012,
9540 0x41785800, 0x592c0404, 0x8c00051c, 0x04020002,
9541 0x59345c05, 0x442c2800, 0x59340008, 0x48002802,
9542 0x59340009, 0x48002801, 0x59340006, 0x48002804,
9543 0x59340007, 0x48002803, 0x4200b000, 0x0000000b,
9544 0x0401f037, 0x592c0207, 0x8c00051e, 0x4200b000,
9545 0x00000002, 0x04020032, 0x8204b540, 0x00000000,
9546 0x0400002f, 0x44042800, 0x59326809, 0x59340400,
9547 0x48002801, 0x4200b000, 0x00000002, 0x0401f028,
9548 0x814281c0, 0x04020030, 0x59345c05, 0x442c2800,
9549 0x4200b000, 0x00000001, 0x0401f021, 0x8340b540,
9550 0x00000000, 0x0400001e, 0x0401f027, 0x814281c0,
9551 0x04020025, 0x59340200, 0x44002800, 0x59340001,
9552 0x48002801, 0x4200b000, 0x00000002, 0x0401f014,
9553 0x8340b540, 0x00000000, 0x0402001b, 0x0401f010,
9554 0x8340b540, 0x00000000, 0x0400000d, 0x0201f800,
9555 0x00104a1f, 0x04000014, 0x8c20450e, 0x04000002,
9556 0x497a6009, 0x4178b000, 0x497a5a06, 0x0401f004,
9557 0x8340b540, 0x00000000, 0x0402000b, 0x592c0404,
9558 0x8400051c, 0x48025c04, 0x592c0207, 0x8400051e,
9559 0x48025a07, 0x0401f8aa, 0x497a6008, 0x0201f000,
9560 0x000202da, 0x592c0207, 0x8c00051e, 0x4200b000,
9561 0x00000002, 0x040207f2, 0x8204b540, 0x00000000,
9562 0x040007ef, 0x44042800, 0x4200b000, 0x00000001,
9563 0x0401f7eb, 0x4937c857, 0x4d300000, 0x0201f800,
9564 0x0002075a, 0x04000011, 0x49366009, 0x4a026406,
9565 0x00000001, 0x492e6008, 0x42000800, 0x0000000b,
9566 0x0201f800, 0x00104571, 0x4d380000, 0x42027000,
9567 0x00000043, 0x0201f800, 0x000207a1, 0x5c027000,
9568 0x82000540, 0x00000001, 0x5c026000, 0x1c01f000,
9569 0x4937c857, 0x4d2c0000, 0x59325808, 0x83380580,
9570 0x00000015, 0x04020025, 0x59a80016, 0x82000580,
9571 0x00000004, 0x04020021, 0x59a80010, 0x592c1009,
9572 0x80080580, 0x04020010, 0x4d440000, 0x592e8c06,
9573 0x592c0207, 0x4803c856, 0x82000500, 0x00000080,
9574 0x84000548, 0x4d3c0000, 0x42027800, 0x00001000,
9575 0x0201f800, 0x001049bb, 0x5c027800, 0x5c028800,
9576 0x0401f004, 0x4803c856, 0x0201f800, 0x00104a1f,
9577 0x0201f800, 0x00109037, 0x04000017, 0x4d400000,
9578 0x42028000, 0x00000000, 0x41780800, 0x0401ff38,
9579 0x5c028000, 0x0401f00e, 0x0201f800, 0x00104a1f,
9580 0x040207f4, 0x0201f800, 0x00109037, 0x0400000a,
9581 0x4c580000, 0x4200b000, 0x00000002, 0x0401f86e,
9582 0x5c00b000, 0x0201f800, 0x0010801c, 0x0201f800,
9583 0x0002077d, 0x5c025800, 0x1c01f000, 0x4937c857,
9584 0x4d300000, 0x0201f800, 0x0002075a, 0x04000012,
9585 0x49366009, 0x4a026406, 0x00000001, 0x4d3c0000,
9586 0x4d380000, 0x417a7800, 0x0201f800, 0x00104567,
9587 0x492e6008, 0x42027000, 0x00000004, 0x0201f800,
9588 0x000207a1, 0x5c027000, 0x5c027800, 0x82000540,
9589 0x00000001, 0x5c026000, 0x1c01f000, 0x4937c857,
9590 0x4d300000, 0x0201f800, 0x00107942, 0x0400000d,
9591 0x49366009, 0x4a026406, 0x00000001, 0x492e6008,
9592 0x4d380000, 0x42027000, 0x00000051, 0x0201f800,
9593 0x000207a1, 0x5c027000, 0x82000540, 0x00000001,
9594 0x5c026000, 0x1c01f000, 0x4933c857, 0x4c580000,
9595 0x59325808, 0x83383580, 0x00000015, 0x04020011,
9596 0x592c0008, 0x82000500, 0x00ffffff, 0x0402000a,
9597 0x0201f800, 0x00105755, 0x59cc0000, 0x82000500,
9598 0x00ffffff, 0x44002800, 0x4200b000, 0x00000001,
9599 0x0401f80b, 0x0201f800, 0x00107b38, 0x0401f006,
9600 0x4200b000, 0x00000002, 0x0401f823, 0x0201f800,
9601 0x0010801c, 0x5c00b000, 0x1c01f000, 0x492fc857,
9602 0x4c580000, 0x4c000000, 0x8058b1c0, 0x0400000b,
9603 0x82580500, 0xfffffff0, 0x02020800, 0x001005d8,
9604 0x8058b0d0, 0x592c0408, 0x82000500, 0xfffff0ff,
9605 0x80580540, 0x48025c08, 0x5c000000, 0x5c00b000,
9606 0x1c01f000, 0x492fc857, 0x4c000000, 0x4c040000,
9607 0x800000d8, 0x592c0c08, 0x82040d00, 0xffff0fff,
9608 0x80040540, 0x48025c08, 0x5c000800, 0x5c000000,
9609 0x1c01f000, 0x4933c857, 0x4d2c0000, 0x59325808,
9610 0x592c0207, 0x8400055e, 0x48025a07, 0x4c500000,
9611 0x4c540000, 0x4c580000, 0x0401ffd9, 0x0201f800,
9612 0x00105755, 0x46002800, 0x00000018, 0x80142800,
9613 0x8058b040, 0x83cca400, 0x00000007, 0x4014a800,
9614 0x0201f800, 0x0010ab17, 0x5c00b000, 0x5c00a800,
9615 0x5c00a000, 0x5c025800, 0x1c01f000, 0x59325808,
9616 0x592c0204, 0x82000580, 0x00000152, 0x1c01f000,
9617 0x5930001f, 0x80000540, 0x02020800, 0x00100d56,
9618 0x1c01f000, 0x4d2c0000, 0x59325808, 0x59300203,
9619 0x4933c857, 0x492fc857, 0x493bc857, 0x4803c857,
9620 0x82003480, 0x0000000e, 0x02021800, 0x001005d8,
9621 0x0c01f803, 0x5c025800, 0x1c01f000, 0x001095bd,
9622 0x001095c8, 0x00109603, 0x001095bd, 0x001095bd,
9623 0x001095bd, 0x001095bd, 0x001095bd, 0x001095bf,
9624 0x001095bd, 0x001095bd, 0x001095bd, 0x001095bd,
9625 0x001095bd, 0x0201f800, 0x001005d8, 0x83383480,
9626 0x00000056, 0x02021800, 0x001005d8, 0x493a6403,
9627 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b,
9628 0x83380580, 0x00000013, 0x0402000f, 0x592c000c,
9629 0x800001c0, 0x04000006, 0x4a026203, 0x00000002,
9630 0x59a80037, 0x48026206, 0x1c01f000, 0x4a025a06,
9631 0x00000000, 0x0201f800, 0x000202da, 0x0201f000,
9632 0x0002077d, 0x83380580, 0x00000027, 0x0400001a,
9633 0x83380580, 0x00000014, 0x04000012, 0x83380580,
9634 0x00000015, 0x04000005, 0x83380580, 0x00000016,
9635 0x02020800, 0x001005d8, 0x0201f800, 0x00106f60,
9636 0x02020000, 0x00107974, 0x59300203, 0x82000580,
9637 0x00000002, 0x02020800, 0x001005d8, 0x0401f014,
9638 0x0201f800, 0x00106bbf, 0x4a02580e, 0x00000011,
9639 0x0401f005, 0x0201f800, 0x00106bbf, 0x4a02580e,
9640 0x00000010, 0x4a025a06, 0x00000031, 0x4a02580d,
9641 0x00000004, 0x0201f800, 0x000202da, 0x0201f800,
9642 0x00104c19, 0x0201f000, 0x00107911, 0x59341400,
9643 0x82081d00, 0x000000ff, 0x59300c03, 0x480bc857,
9644 0x4807c857, 0x82040580, 0x00000053, 0x0400002e,
9645 0x82040580, 0x00000002, 0x04000016, 0x82040580,
9646 0x00000001, 0x04000017, 0x82040580, 0x00000003,
9647 0x0400001c, 0x82040580, 0x00000005, 0x0400001d,
9648 0x82040580, 0x00000033, 0x0400001a, 0x82040580,
9649 0x00000000, 0x0400001b, 0x82040580, 0x00000004,
9650 0x02020800, 0x001005d8, 0x0401f8a1, 0x0401f016,
9651 0x820c0580, 0x00000003, 0x0400084c, 0x0401f012,
9652 0x820c0580, 0x0000000b, 0x0402000f, 0x42000800,
9653 0x00000007, 0x0201f800, 0x00104571, 0x0401f00a,
9654 0x820c0580, 0x00000005, 0x04000864, 0x0401f006,
9655 0x820c0580, 0x00000009, 0x04000889, 0x0401f002,
9656 0x0401f893, 0x4a026403, 0x00000052, 0x59a81016,
9657 0x592c040b, 0x8c000500, 0x04000003, 0x42001000,
9658 0x00000008, 0x592c040b, 0x8c000516, 0x04000003,
9659 0x82081400, 0x00000018, 0x592c000c, 0x497a580d,
9660 0x497a580e, 0x80080c80, 0x04000009, 0x04001005,
9661 0x4a025a06, 0x00000007, 0x40001000, 0x0401f006,
9662 0x4a025a06, 0x00000015, 0x0401f003, 0x4a025a06,
9663 0x00000000, 0x480a580c, 0x82081400, 0x00000003,
9664 0x80081104, 0x0201f800, 0x00107ab5, 0x04000010,
9665 0x592c1001, 0x480a600b, 0x58080800, 0x82080400,
9666 0x00000002, 0x592c1011, 0x592c1812, 0x42003000,
9667 0x00000000, 0x42002000, 0x00101200, 0x0201f800,
9668 0x00107c32, 0x04000002, 0x1c01f000, 0x4a025a06,
9669 0x0000002c, 0x497a580c, 0x0201f800, 0x000202da,
9670 0x0201f000, 0x0002077d, 0x83380580, 0x00000015,
9671 0x0402000a, 0x59a80005, 0x8c000514, 0x0402000b,
9672 0x0201f800, 0x0010462a, 0x42000800, 0x00000004,
9673 0x0201f000, 0x00104571, 0x42000800, 0x00000007,
9674 0x0201f000, 0x00104571, 0x0201f800, 0x0010513b,
9675 0x42001000, 0x00000010, 0x04020009, 0x59340002,
9676 0x82000500, 0x00ff0000, 0x82000580, 0x00ff0000,
9677 0x040007ec, 0x42001000, 0x00000008, 0x0201f800,
9678 0x00104c6d, 0x040007e7, 0x592c040b, 0x84000540,
9679 0x48025c0b, 0x0401f7e9, 0x83380580, 0x00000015,
9680 0x0402000f, 0x59a80005, 0x8c000514, 0x04020010,
9681 0x0201f800, 0x0010468d, 0x4d3c0000, 0x417a7800,
9682 0x0201f800, 0x00104567, 0x5c027800, 0x42000800,
9683 0x00000006, 0x0201f000, 0x00104571, 0x42000800,
9684 0x00000004, 0x0201f000, 0x00104571, 0x0201f800,
9685 0x0010513b, 0x42001000, 0x00000010, 0x04020009,
9686 0x59340002, 0x82000500, 0x00ff0000, 0x82000580,
9687 0x00ff0000, 0x040007e7, 0x42001000, 0x00000008,
9688 0x0201f800, 0x00104c6d, 0x040007e2, 0x592c040b,
9689 0x84000540, 0x48025c0b, 0x0401f7e9, 0x42000800,
9690 0x00000004, 0x0201f000, 0x00104571, 0x83380580,
9691 0x00000015, 0x04020005, 0x0201f800, 0x0010a2c8,
9692 0x02000800, 0x001048c1, 0x1c01f000, 0x83380580,
9693 0x00000015, 0x0402001d, 0x4c580000, 0x83cc1400,
9694 0x00000008, 0x4200b000, 0x00000002, 0x83341c00,
9695 0x00000006, 0x0201f800, 0x0010855a, 0x04020012,
9696 0x83cc1400, 0x0000000a, 0x4200b000, 0x00000002,
9697 0x83341c00, 0x00000008, 0x0201f800, 0x0010855a,
9698 0x04020009, 0x59342200, 0x59cc1007, 0x800811c0,
9699 0x04000003, 0x480a6801, 0x84102542, 0x8410251a,
9700 0x48126a00, 0x5c00b000, 0x1c01f000, 0x42000000,
9701 0x0010b87b, 0x0201f800, 0x0010aa47, 0x0201f800,
9702 0x00106c55, 0x59300203, 0x4933c857, 0x4803c857,
9703 0x82000c80, 0x0000000e, 0x02021800, 0x001005d8,
9704 0x0c01f803, 0x0201f000, 0x00106c4b, 0x0010970b,
9705 0x0010971a, 0x0010970c, 0x00109709, 0x00109709,
9706 0x00109709, 0x00109709, 0x00109709, 0x00109709,
9707 0x00109709, 0x00109709, 0x00109709, 0x00109709,
9708 0x00109709, 0x0201f800, 0x001005d8, 0x1c01f000,
9709 0x59300403, 0x82000580, 0x00000052, 0x02000000,
9710 0x00108d85, 0x0201f800, 0x00104c19, 0x59325808,
9711 0x4a025a06, 0x00000006, 0x0201f800, 0x000202da,
9712 0x0201f000, 0x00107911, 0x59301804, 0x840c0520,
9713 0x48026004, 0x598c000d, 0x81300580, 0x04020010,
9714 0x8c0c1d20, 0x04020010, 0x42001000, 0x0010b7f6,
9715 0x50081000, 0x58080002, 0x82000580, 0x00000100,
9716 0x0400000e, 0x5808000c, 0x81300580, 0x02020800,
9717 0x001005d8, 0x4978100c, 0x0401f003, 0x8c0c1d20,
9718 0x040207dc, 0x0201f800, 0x001068d3, 0x040007d9,
9719 0x0201f800, 0x001005d8, 0x0201f800, 0x00106e8e,
9720 0x040007f9, 0x59300203, 0x82000c80, 0x0000000e,
9721 0x02021800, 0x001005d8, 0x0c01f7bd, 0x4933c857,
9722 0x4c500000, 0x4c540000, 0x4c580000, 0x592c0c07,
9723 0x4806580a, 0x59cc0809, 0x48065807, 0x59cc0a08,
9724 0x4806580b, 0x59c80817, 0x82040500, 0x000003ff,
9725 0x800010c4, 0x8c040d14, 0x04000005, 0x59cc0002,
9726 0x82000500, 0x00000003, 0x80081480, 0x82080480,
9727 0x000000f1, 0x02021800, 0x001005d8, 0x480a621a,
9728 0x412c0800, 0x0201f800, 0x001007d3, 0x02000800,
9729 0x001005d8, 0x492c0809, 0x58040408, 0x84000552,
9730 0x84000540, 0x48000c08, 0x82081400, 0x00000003,
9731 0x80081104, 0x83cca400, 0x00000006, 0x832cac00,
9732 0x00000004, 0x42000800, 0x00000010, 0x82080480,
9733 0x00000010, 0x04021003, 0x40080800, 0x80000580,
9734 0x4004b000, 0x4c000000, 0x0201f800, 0x0010ab28,
9735 0x5c000000, 0x800001c0, 0x0400000d, 0x412c1000,
9736 0x4c000000, 0x0201f800, 0x001007d3, 0x02000800,
9737 0x001005d8, 0x492c1001, 0x832cac00, 0x00000004,
9738 0x5c000000, 0x40001000, 0x0401f7e9, 0x5c00b000,
9739 0x5c00a800, 0x5c00a000, 0x1c01f000, 0x4933c857,
9740 0x4d2c0000, 0x4c380000, 0x59325808, 0x5930021a,
9741 0x48025a08, 0x59301011, 0x800811c0, 0x04020008,
9742 0x4a025a06, 0x00000000, 0x592c000b, 0x82000500,
9743 0x00000c00, 0x0400000b, 0x0401f00b, 0x8c08153e,
9744 0x04000006, 0x4a025a06, 0x00000007, 0x80081080,
9745 0x80081000, 0x0401f003, 0x4a025a06, 0x00000015,
9746 0x480a5807, 0x42000000, 0x0010bed9, 0x50007000,
9747 0x5838000b, 0x80000540, 0x04020008, 0x4930700c,
9748 0x4930700b, 0x58380002, 0x82000580, 0x00000000,
9749 0x04020809, 0x0401f005, 0x82001400, 0x00000000,
9750 0x45301000, 0x4930700b, 0x5c007000, 0x5c025800,
9751 0x1c01f000, 0x4933c857, 0x592c0009, 0x40001000,
9752 0x4800700a, 0x82080400, 0x00000004, 0x48007003,
9753 0x592c000d, 0x592c100e, 0x48007007, 0x48087008,
9754 0x592c000a, 0x592c1208, 0x80080c80, 0x04001002,
9755 0x40001000, 0x82081400, 0x00000003, 0x80081104,
9756 0x82080480, 0x00000010, 0x04021003, 0x80000580,
9757 0x0401f003, 0x42001000, 0x00000010, 0x4800700d,
9758 0x48087004, 0x800810c4, 0x48087005, 0x40381000,
9759 0x0201f800, 0x00100858, 0x1c01f000, 0x4d2c0000,
9760 0x0201f800, 0x001007d3, 0x02000800, 0x001005d8,
9761 0x42000800, 0x0010bed9, 0x452c0800, 0x497a580b,
9762 0x497a580c, 0x497a580d, 0x4a025809, 0x001097ea,
9763 0x4a025802, 0x00000100, 0x4a025801, 0x00000000,
9764 0x5c025800, 0x1c01f000, 0x4833c857, 0x4d300000,
9765 0x4d2c0000, 0x4c5c0000, 0x4030b800, 0x585c000a,
9766 0x80025d40, 0x04020004, 0x585c000c, 0x4c000000,
9767 0x0401f044, 0x585c0002, 0x82000580, 0x00000100,
9768 0x04020022, 0x592c0801, 0x4c040000, 0x0201f800,
9769 0x001007f4, 0x5c000800, 0x800409c0, 0x0400001c,
9770 0x4804b80a, 0x585c100d, 0x800811c0, 0x04020005,
9771 0x40065800, 0x0201f800, 0x001007fd, 0x0401f014,
9772 0x82080480, 0x00000010, 0x04021003, 0x80000580,
9773 0x0401f003, 0x42001000, 0x00000010, 0x4800b80d,
9774 0x4808b804, 0x800810c4, 0x4808b805, 0x82040400,
9775 0x00000004, 0x4800b803, 0x405c1000, 0x0201f800,
9776 0x00100858, 0x0401f025, 0x0401f828, 0x585c000c,
9777 0x80026540, 0x59300000, 0x80000d40, 0x04020002,
9778 0x4800b80b, 0x4800b80c, 0x497a6000, 0x4c000000,
9779 0x4978b80a, 0x59325808, 0x4a025a04, 0x00000103,
9780 0x59300402, 0x48025c06, 0x592c100b, 0x4c080000,
9781 0x0201f800, 0x000202c1, 0x0201f800, 0x0010912a,
9782 0x5c001000, 0x8c081518, 0x04000004, 0x0201f800,
9783 0x001091d1, 0x0401f003, 0x0201f800, 0x0002077d,
9784 0x405c7000, 0x5c000000, 0x80026540, 0x04000003,
9785 0x59325808, 0x0401ff78, 0x5c00b800, 0x5c025800,
9786 0x5c026000, 0x1c01f000, 0x483bc857, 0x5838000a,
9787 0x40025800, 0x0201f800, 0x001007fd, 0x5838000c,
9788 0x80026540, 0x59300008, 0x80025d40, 0x4a025a06,
9789 0x00000002, 0x1c01f000, 0x4803c857, 0x4d1c0000,
9790 0x497a601c, 0x41323800, 0x40026000, 0x4d3c0000,
9791 0x42027800, 0x00000005, 0x0401f83c, 0x5c027800,
9792 0x411e6000, 0x59300414, 0x84000502, 0x48026414,
9793 0x5c023800, 0x1c01f000, 0x481bc857, 0x4933c857,
9794 0x4c5c0000, 0x4c600000, 0x4010b800, 0x4014c000,
9795 0x0201f800, 0x0010a942, 0x0201f800, 0x00103b25,
9796 0x04000008, 0x40602800, 0x405c3000, 0x0201f800,
9797 0x0010a446, 0x82000540, 0x00000001, 0x0401f002,
9798 0x80000580, 0x5c00c000, 0x5c00b800, 0x1c01f000,
9799 0x4803c856, 0x4d300000, 0x42026000, 0x0010d1c0,
9800 0x59a8000e, 0x81640580, 0x04000016, 0x59300c06,
9801 0x82040580, 0x00000001, 0x04000009, 0x82040580,
9802 0x00000004, 0x04000006, 0x82040580, 0x00000010,
9803 0x02000800, 0x00108cf9, 0x0401f005, 0x4807c857,
9804 0x0201f800, 0x001092d7, 0x04020808, 0x83326400,
9805 0x00000024, 0x41580000, 0x81300480, 0x040017e9,
9806 0x5c026000, 0x1c01f000, 0x4933c857, 0x59300403,
9807 0x4803c857, 0x0201f800, 0x00106c55, 0x4df00000,
9808 0x59300406, 0x4803c857, 0x82000d80, 0x00000002,
9809 0x04000018, 0x82000d80, 0x00000001, 0x04000009,
9810 0x82000d80, 0x00000004, 0x04000006, 0x4933c856,
9811 0x5c03e000, 0x02000800, 0x00106c4b, 0x0401f03c,
9812 0x59300203, 0x82000d80, 0x00000001, 0x04000018,
9813 0x82000d80, 0x00000002, 0x04000026, 0x82000d80,
9814 0x00000005, 0x04000023, 0x0201f800, 0x001005d8,
9815 0x59300203, 0x82000d80, 0x00000009, 0x0400000c,
9816 0x82000d80, 0x0000000b, 0x04000009, 0x82000d80,
9817 0x0000000a, 0x04000017, 0x82000d80, 0x0000000c,
9818 0x04000014, 0x0201f800, 0x001005d8, 0x598c000d,
9819 0x81300580, 0x04020004, 0x0201f800, 0x00106e8e,
9820 0x0402000c, 0x59300004, 0x4803c857, 0x8c000520,
9821 0x04000004, 0x84000520, 0x48026004, 0x0401f005,
9822 0x0201f800, 0x001068d3, 0x02020800, 0x001005d8,
9823 0x5c03e000, 0x02000800, 0x00106c4b, 0x59300406,
9824 0x82000d80, 0x00000002, 0x04000009, 0x0201f800,
9825 0x00104c19, 0x0201f800, 0x0010914e, 0x02000800,
9826 0x0010801c, 0x8d3e7d00, 0x04000003, 0x0201f000,
9827 0x00107911, 0x4a02621d, 0x00000001, 0x4a026403,
9828 0x00000085, 0x4a026203, 0x00000009, 0x4a026406,
9829 0x00000002, 0x42000800, 0x8000004b, 0x0201f000,
9830 0x00020721, 0x4933c857, 0x59368c03, 0x4c180000,
9831 0x59300203, 0x82003480, 0x0000000e, 0x02021800,
9832 0x001005d8, 0x0c01f803, 0x5c003000, 0x1c01f000,
9833 0x0010990a, 0x00109dcf, 0x00109edb, 0x0010990a,
9834 0x0010990a, 0x0010990a, 0x0010990a, 0x0010990a,
9835 0x0010992d, 0x0010990a, 0x0010990a, 0x0010990a,
9836 0x0010990a, 0x0010990a, 0x0201f800, 0x001005d8,
9837 0x4933c857, 0x42028800, 0x0000ffff, 0x813669c0,
9838 0x04000002, 0x59368c03, 0x4c180000, 0x59300203,
9839 0x82003480, 0x0000000e, 0x02021800, 0x001005d8,
9840 0x0c01f803, 0x5c003000, 0x1c01f000, 0x00109929,
9841 0x0010a180, 0x00109929, 0x00109929, 0x00109929,
9842 0x00109929, 0x00109929, 0x0010a952, 0x0010a0ed,
9843 0x0010a52c, 0x0010a562, 0x0010a52c, 0x0010a562,
9844 0x00109929, 0x0201f800, 0x001005d8, 0x0201f800,
9845 0x001005d8, 0x83383480, 0x00000051, 0x02021800,
9846 0x001005d8, 0x41380000, 0x493bc857, 0x4d1c0000,
9847 0x4d400000, 0x0c01f804, 0x5c028000, 0x5c023800,
9848 0x1c01f000, 0x0010998a, 0x00109b69, 0x0010998a,
9849 0x0010998a, 0x0010998a, 0x00109b74, 0x0010998a,
9850 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a,
9851 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a,
9852 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a,
9853 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a,
9854 0x001099ac, 0x001099f5, 0x00109a0c, 0x00109a62,
9855 0x00109ac6, 0x00109b04, 0x00109b34, 0x0010998a,
9856 0x0010998a, 0x00109b7c, 0x0010998a, 0x0010998a,
9857 0x00109b8a, 0x00109b93, 0x0010998a, 0x0010998a,
9858 0x0010998a, 0x0010998a, 0x0010998a, 0x00109c15,
9859 0x0010998a, 0x0010998a, 0x00109a9a, 0x0010998a,
9860 0x0010998a, 0x00109bec, 0x0010998a, 0x0010998a,
9861 0x0010998a, 0x00109c23, 0x0010998a, 0x0010998a,
9862 0x0010998a, 0x00109c6c, 0x0010998a, 0x0010998a,
9863 0x0010998a, 0x0010998a, 0x0010998a, 0x0010998a,
9864 0x00109cb9, 0x0010998a, 0x00109ce5, 0x00109cf0,
9865 0x0010998a, 0x0010998a, 0x0010998c, 0x00109cfb,
9866 0x0010998a, 0x0010998a, 0x0010998a, 0x0010999b,
9867 0x0010998a, 0x0010998a, 0x0010998a, 0x00109d02,
9868 0x00109d0a, 0x00109d28, 0x0201f800, 0x001005d8,
9869 0x4933c857, 0x0201f800, 0x0010a592, 0x040203a4,
9870 0x0201f800, 0x0010210a, 0x040203a1, 0x59cc0407,
9871 0x4802601c, 0x4a026403, 0x00000045, 0x4a026203,
9872 0x00000001, 0x0201f000, 0x0010672b, 0x4933c857,
9873 0x0201f800, 0x0010a592, 0x04020395, 0x0201f800,
9874 0x0010210a, 0x04020392, 0x0401fbce, 0x040201a0,
9875 0x59cc0007, 0x4802601c, 0x4a026403, 0x0000004a,
9876 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b,
9877 0x4933c857, 0x0201f800, 0x0010210a, 0x04020009,
9878 0x0201f800, 0x001048ec, 0x04020006, 0x82000500,
9879 0x00000009, 0x82000580, 0x00000008, 0x04020008,
9880 0x4a026403, 0x00000009, 0x4a02641a, 0x00000009,
9881 0x4a02621a, 0x00000000, 0x0401f1b2, 0x0201f800,
9882 0x001048c1, 0x0201f800, 0x00104a09, 0x04000021,
9883 0x0201f800, 0x001049ed, 0x0400001e, 0x0201f800,
9884 0x0010a252, 0x04020025, 0x42028000, 0x00000029,
9885 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c,
9886 0x5c027800, 0x0201f800, 0x0010462a, 0x836c0580,
9887 0x00000002, 0x04020004, 0x59a8001b, 0x80000000,
9888 0x4803501b, 0x4a026403, 0x00000008, 0x42003000,
9889 0x00000003, 0x0201f800, 0x00103b25, 0x04000191,
9890 0x4a026203, 0x00000007, 0x41782800, 0x0401f180,
9891 0x0201f800, 0x0010a3da, 0x040207e1, 0x4a026403,
9892 0x00000009, 0x4a02641a, 0x0000000e, 0x4a02621a,
9893 0x00001900, 0x0401f183, 0x4a026403, 0x00000009,
9894 0x4a02641a, 0x00000003, 0x4a02621a, 0x00000f00,
9895 0x0401f17c, 0x4933c857, 0x0201f800, 0x0010210a,
9896 0x0402033b, 0x0201f800, 0x001048ec, 0x04020338,
9897 0x493a6403, 0x0201f800, 0x0010a22d, 0x04020006,
9898 0x42003000, 0x00000005, 0x4a026403, 0x00000006,
9899 0x0401f7d9, 0x4a026403, 0x00000007, 0x4a02641a,
9900 0x00000009, 0x4a02621a, 0x00000000, 0x0401f165,
9901 0x4933c857, 0x0201f800, 0x001048ec, 0x04020324,
9902 0x0201f800, 0x0010a592, 0x02000800, 0x0010210a,
9903 0x0402031f, 0x0201f800, 0x00104a09, 0x04020005,
9904 0x42027800, 0x00000001, 0x0201f800, 0x00104567,
9905 0x0201f800, 0x001049fc, 0x0402002b, 0x59cc0206,
9906 0x82003500, 0x00000003, 0x0402002e, 0x82003480,
9907 0x00000014, 0x0400102b, 0x5934300a, 0x84183516,
9908 0x82000580, 0x00000014, 0x04020002, 0x84183556,
9909 0x481a680a, 0x59cc0406, 0x82000500, 0x00000003,
9910 0x04020020, 0x0201f800, 0x0010a29f, 0x04020028,
9911 0x0201f800, 0x001049e7, 0x0402000c, 0x417a7800,
9912 0x0201f800, 0x001020a1, 0x42003000, 0x00000006,
9913 0x0201f800, 0x0010a93a, 0x42000000, 0x0010b865,
9914 0x0201f800, 0x0010aa47, 0x0201f800, 0x0010468d,
9915 0x4a026403, 0x0000000a, 0x42003000, 0x00000020,
9916 0x0401f795, 0x4a026403, 0x0000000b, 0x4a02641a,
9917 0x00000009, 0x4a02621a, 0x00001e00, 0x0401f121,
9918 0x42000000, 0x0010b860, 0x0201f800, 0x0010aa47,
9919 0x4a026403, 0x0000000b, 0x4a02641a, 0x00000007,
9920 0x4a02621a, 0x00000000, 0x0401f116, 0x4a026403,
9921 0x0000000b, 0x4a02641a, 0x00000003, 0x4a02621a,
9922 0x00000000, 0x0401f10f, 0x4933c857, 0x0201f800,
9923 0x001048ec, 0x040202ce, 0x0201f800, 0x0010a592,
9924 0x040202cb, 0x0201f800, 0x0010210a, 0x040202c8,
9925 0x59cc0206, 0x82003500, 0x00000003, 0x0402001d,
9926 0x82003480, 0x00000014, 0x0400101a, 0x59cc0406,
9927 0x82000500, 0x00000003, 0x04020016, 0x59340400,
9928 0x82000580, 0x00000707, 0x04000019, 0x417a7800,
9929 0x0201f800, 0x001020a1, 0x42003000, 0x0000000a,
9930 0x0201f800, 0x0010a93a, 0x42000000, 0x0010b862,
9931 0x0201f800, 0x0010aa47, 0x4a026403, 0x0000000c,
9932 0x41782800, 0x42003000, 0x00000021, 0x0401f752,
9933 0x4a026403, 0x0000000d, 0x4a02641a, 0x00000007,
9934 0x4a02621a, 0x00000000, 0x0401f0de, 0x4a026403,
9935 0x0000000d, 0x4a02641a, 0x00000009, 0x4a02621a,
9936 0x00001e00, 0x0401f0d7, 0x4933c857, 0x0201f800,
9937 0x001048ec, 0x04020296, 0x0201f800, 0x0010a592,
9938 0x04020293, 0x0201f800, 0x0010210a, 0x04020290,
9939 0x0401facc, 0x0402001a, 0x493a6403, 0x4c5c0000,
9940 0x0401fad2, 0x0402000e, 0x4a026403, 0x0000002e,
9941 0x405c2800, 0x42003000, 0x00000024, 0x0201f800,
9942 0x00103b25, 0x0400000c, 0x4a026203, 0x00000007,
9943 0x405c2800, 0x5c00b800, 0x0401f0ad, 0x4a026403,
9944 0x0000000d, 0x4a02641a, 0x00000007, 0x4a02621a,
9945 0x00000000, 0x5c00b800, 0x0401f0b2, 0x4a026403,
9946 0x0000000d, 0x4a02641a, 0x00000009, 0x4a02621a,
9947 0x00001e00, 0x0401f0ab, 0x4933c857, 0x0201f800,
9948 0x001048ec, 0x040206ef, 0x59a80026, 0x82000500,
9949 0x00000009, 0x82000580, 0x00000008, 0x040006e9,
9950 0x0201f800, 0x001049fc, 0x0402002d, 0x0201f800,
9951 0x0010a2a7, 0x04020007, 0x4a026403, 0x0000000e,
9952 0x41782800, 0x42003000, 0x00000052, 0x0401f702,
9953 0x4933c857, 0x42003000, 0x00000003, 0x0201f800,
9954 0x0010a942, 0x4d3c0000, 0x417a7800, 0x0201f800,
9955 0x0010203c, 0x5c027800, 0x42000000, 0x0010b864,
9956 0x0201f800, 0x0010aa47, 0x59340200, 0x84000558,
9957 0x48026a00, 0x42000800, 0x0000000b, 0x0201f800,
9958 0x00104571, 0x0201f800, 0x00103b25, 0x04000076,
9959 0x42003000, 0x00000007, 0x0401f062, 0x4933c857,
9960 0x4a026403, 0x0000000f, 0x4a02641a, 0x00000003,
9961 0x4a02621a, 0x00001e00, 0x0401f072, 0x59340400,
9962 0x82000580, 0x00000703, 0x040007f5, 0x0401f040,
9963 0x4933c857, 0x0201f800, 0x001048ec, 0x0402022c,
9964 0x59a80026, 0x82000500, 0x00000009, 0x82000580,
9965 0x00000008, 0x04000226, 0x0201f800, 0x001049f3,
9966 0x0402002f, 0x0201f800, 0x0010a2c8, 0x02000800,
9967 0x0010a252, 0x04020007, 0x4a026403, 0x00000010,
9968 0x41782800, 0x42003000, 0x00000050, 0x0401f6c2,
9969 0x4d3c0000, 0x417a7800, 0x0201f800, 0x0010203c,
9970 0x5c027800, 0x42003000, 0x00000003, 0x0201f800,
9971 0x0010a942, 0x42000000, 0x0010b864, 0x0201f800,
9972 0x0010aa47, 0x59340200, 0x84000558, 0x48026a00,
9973 0x0401f7c5, 0x4a026403, 0x00000011, 0x4a02641a,
9974 0x00000003, 0x4a02621a, 0x00001e00, 0x0401f03d,
9975 0x4933c857, 0x0201f800, 0x0010210a, 0x02000800,
9976 0x0010a592, 0x040201fa, 0x0401fa36, 0x04020008,
9977 0x4a026403, 0x00000012, 0x0401f032, 0x59340400,
9978 0x82000580, 0x00000703, 0x040007eb, 0x4d3c0000,
9979 0x417a7800, 0x42028000, 0x00000029, 0x0201f800,
9980 0x0010203c, 0x5c027800, 0x42003000, 0x00000017,
9981 0x0201f800, 0x0010a942, 0x42000000, 0x0010b864,
9982 0x0201f800, 0x0010aa47, 0x0201f800, 0x00103b25,
9983 0x04000015, 0x42003000, 0x00000006, 0x41782800,
9984 0x42028000, 0x00000029, 0x4933c857, 0x4a026403,
9985 0x00000001, 0x4a026203, 0x00000007, 0x0201f800,
9986 0x0010a974, 0x0201f000, 0x0010a43e, 0x42028000,
9987 0x00000046, 0x0201f800, 0x0010a974, 0x0201f000,
9988 0x0010a43e, 0x4933c857, 0x4a026403, 0x00000001,
9989 0x42000800, 0x0000000b, 0x0201f800, 0x00104571,
9990 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b,
9991 0x4933c857, 0x42000800, 0x00000009, 0x0201f800,
9992 0x00104571, 0x4a026403, 0x00000005, 0x0401f7f5,
9993 0x0201f800, 0x0010a592, 0x040201b5, 0x0201f800,
9994 0x0010210a, 0x040201b2, 0x0401f9ee, 0x040207c0,
9995 0x4a026403, 0x00000020, 0x4a026203, 0x00000001,
9996 0x0201f000, 0x0010672b, 0x0201f800, 0x0010210a,
9997 0x040201a7, 0x4a026403, 0x00000023, 0x4a026203,
9998 0x00000001, 0x0201f000, 0x0010672b, 0x0201f800,
9999 0x0010a592, 0x02000800, 0x0010210a, 0x0402019c,
10000 0x0401f9d8, 0x040207aa, 0x40300800, 0x59a81010,
10001 0x59cc0007, 0x82000500, 0x00ffffff, 0x80080580,
10002 0x04000019, 0x59cc1408, 0x0201f800, 0x0010902c,
10003 0x0400002d, 0x59cc0c08, 0x4d300000, 0x0201f800,
10004 0x00105dd7, 0x41323800, 0x5c026000, 0x04000026,
10005 0x591c0202, 0x82000580, 0x0000ffff, 0x04000005,
10006 0x59cc1208, 0x591c0202, 0x80080580, 0x0402001e,
10007 0x591c0406, 0x82000580, 0x00000007, 0x0402001a,
10008 0x0401f02c, 0x59cc1208, 0x82080580, 0x0000ffff,
10009 0x0400000c, 0x0201f800, 0x00109410, 0x04000012,
10010 0x59cc1408, 0x591c0202, 0x80080580, 0x0402000e,
10011 0x591c0009, 0x81340580, 0x04000016, 0x0401f00a,
10012 0x59cc1408, 0x417a7800, 0x0201f800, 0x0010a405,
10013 0x04020010, 0x59cc1208, 0x82080580, 0x0000ffff,
10014 0x04000019, 0x4a026403, 0x00000026, 0x4a02621a,
10015 0x00001700, 0x59cc1204, 0x82081580, 0x0000ffff,
10016 0x04020798, 0x4a026403, 0x00000025, 0x0401f795,
10017 0x591c0406, 0x82000580, 0x00000007, 0x040207f2,
10018 0x591c0403, 0x82000580, 0x00000024, 0x04020006,
10019 0x4d300000, 0x411e6000, 0x0201f800, 0x0002077d,
10020 0x5c026000, 0x4a026403, 0x00000025, 0x0401f785,
10021 0x4933c857, 0x4d3c0000, 0x42027800, 0x00000001,
10022 0x0201f800, 0x00104567, 0x5c027800, 0x4c580000,
10023 0x4200b000, 0x00000002, 0x83a81c00, 0x00000002,
10024 0x83cc1400, 0x0000000b, 0x0201f800, 0x0010855a,
10025 0x5c00b000, 0x04000004, 0x4a026403, 0x00000031,
10026 0x0401f770, 0x0201f800, 0x00107911, 0x0201f800,
10027 0x0010513b, 0x0402000f, 0x0201f800, 0x00105149,
10028 0x04020008, 0x4a035033, 0x00000001, 0x4202d800,
10029 0x00000001, 0x0201f800, 0x001050a2, 0x0401f005,
10030 0x42000000, 0x00000001, 0x0201f800, 0x00105113,
10031 0x1c01f000, 0x0201f800, 0x0010210a, 0x0402011c,
10032 0x0401f958, 0x0402072a, 0x493a6403, 0x0401f996,
10033 0x04020004, 0x4a026403, 0x0000002b, 0x0401f751,
10034 0x4a026403, 0x0000002c, 0x0401f74e, 0x4933c857,
10035 0x0201f800, 0x0010210a, 0x0402010d, 0x0201f800,
10036 0x001049e7, 0x04020740, 0x0201f800, 0x001048d9,
10037 0x0400003c, 0x59cc0408, 0x48026419, 0x59cc0208,
10038 0x48026219, 0x59cc0807, 0x59340002, 0x82000500,
10039 0x00ffffff, 0x80040580, 0x04000012, 0x59a80010,
10040 0x80040580, 0x04020021, 0x59cc1408, 0x0201f800,
10041 0x00109410, 0x04000023, 0x0201f800, 0x0010a4ca,
10042 0x04000020, 0x0201f800, 0x0010a921, 0x0400001d,
10043 0x491e601e, 0x4a026403, 0x00000036, 0x0401f0e6,
10044 0x59cc1208, 0x82080580, 0x0000ffff, 0x04000009,
10045 0x0201f800, 0x00109410, 0x04000012, 0x591c0202,
10046 0x59cc0c08, 0x80040580, 0x0402000e, 0x0401f7eb,
10047 0x59cc1408, 0x41327800, 0x0201f800, 0x0010a405,
10048 0x04000008, 0x0401f7e5, 0x4803c856, 0x4a02641a,
10049 0x00000009, 0x4a02621a, 0x00001500, 0x0401f006,
10050 0x4803c856, 0x4a02641a, 0x00000003, 0x4a02621a,
10051 0x00001700, 0x4a026403, 0x00000037, 0x0401f0c6,
10052 0x4803c856, 0x4a026403, 0x00000012, 0x0401f0c2,
10053 0x4933c857, 0x0201f800, 0x0010210a, 0x040200c4,
10054 0x0201f800, 0x001049e7, 0x040206f7, 0x0201f800,
10055 0x001048d9, 0x0400003e, 0x59cc0407, 0x48026419,
10056 0x59cc1207, 0x480a6219, 0x82080580, 0x0000ffff,
10057 0x04000005, 0x0201f800, 0x00109410, 0x0400002c,
10058 0x0401f006, 0x59cc1407, 0x41327800, 0x0201f800,
10059 0x0010a405, 0x04000026, 0x59cc0c07, 0x591c0202,
10060 0x80040580, 0x04020022, 0x4d300000, 0x411e6000,
10061 0x0201f800, 0x00108bd7, 0x5c026000, 0x59cc0c09,
10062 0x82040d00, 0x0000ff00, 0x840409c0, 0x0201f800,
10063 0x0010a921, 0x04000016, 0x82040580, 0x00000001,
10064 0x0400000a, 0x82040580, 0x00000005, 0x04000004,
10065 0x82040580, 0x00000007, 0x04020007, 0x591c0008,
10066 0x80000540, 0x04000004, 0x59cc2808, 0x0201f000,
10067 0x0010a4de, 0x4803c856, 0x4a02641a, 0x00000009,
10068 0x4a02621a, 0x00002a00, 0x0401f006, 0x4803c856,
10069 0x4a02641a, 0x00000003, 0x4a02621a, 0x00000300,
10070 0x4a026403, 0x0000003b, 0x0401f07b, 0x4803c856,
10071 0x4a02641a, 0x0000000b, 0x4a02621a, 0x00000000,
10072 0x0401f7f8, 0x4c080000, 0x0201f800, 0x001048ec,
10073 0x04000026, 0x0201f800, 0x001048c1, 0x0201f800,
10074 0x0010a601, 0x0402001e, 0x59a80026, 0x82000540,
10075 0x00000003, 0x48035026, 0x59a8001d, 0x800000d0,
10076 0x59a80810, 0x82040d00, 0x000000ff, 0x80041540,
10077 0x480b5010, 0x42000800, 0x00000003, 0x0201f800,
10078 0x00106c78, 0x497b5028, 0x0201f800, 0x00103b25,
10079 0x04000003, 0x4a032804, 0x000007d0, 0x8c00050a,
10080 0x0402000a, 0x0201f800, 0x0002077d, 0x0201f800,
10081 0x00101e45, 0x5c001000, 0x1c01f000, 0x0201f800,
10082 0x0010a623, 0x0401f7fc, 0x5c001000, 0x0201f000,
10083 0x0002077d, 0x0201f800, 0x0010210a, 0x0402004c,
10084 0x0201f800, 0x0010a628, 0x4a026403, 0x00000047,
10085 0x4a026203, 0x00000001, 0x0201f000, 0x0010672b,
10086 0x0201f800, 0x0010210a, 0x04020041, 0x0201f800,
10087 0x0010a628, 0x4a026403, 0x00000047, 0x4a026203,
10088 0x00000001, 0x0201f000, 0x0010672b, 0x0201f800,
10089 0x0010210a, 0x04020036, 0x0201f800, 0x0010a628,
10090 0x0201f000, 0x0002077d, 0x0401f834, 0x04000030,
10091 0x4a026403, 0x0000004e, 0x4a026203, 0x00000001,
10092 0x0201f000, 0x0010672b, 0x4a026403, 0x0000004f,
10093 0x497a601c, 0x59cc0a06, 0x82040d00, 0x000000ff,
10094 0x800409c0, 0x0400065f, 0x82040580, 0x00000001,
10095 0x04020005, 0x59cc0808, 0x59a80005, 0x80040580,
10096 0x04000658, 0x82040580, 0x00000002, 0x0402000a,
10097 0x83cc1400, 0x0000000b, 0x4200b000, 0x00000002,
10098 0x83341c00, 0x00000006, 0x0201f800, 0x0010855a,
10099 0x0400064c, 0x4a02601c, 0x00000001, 0x0401f649,
10100 0x4a026403, 0x00000050, 0x59cc0207, 0x4802601c,
10101 0x0401f644, 0x4a026203, 0x00000001, 0x42000800,
10102 0x80000040, 0x0201f000, 0x00020721, 0x4803c857,
10103 0x0201f000, 0x0002077d, 0x4d2c0000, 0x4c500000,
10104 0x4c580000, 0x4c540000, 0x59a80016, 0x82000c80,
10105 0x00000829, 0x04021029, 0x0201f800, 0x001007d3,
10106 0x04000026, 0x492e6008, 0x59a80016, 0x80000104,
10107 0x48025802, 0x83cca400, 0x00000006, 0x82000c80,
10108 0x0000000b, 0x04001013, 0x4a025811, 0x0000000b,
10109 0x4200b000, 0x0000000b, 0x832c0400, 0x00000005,
10110 0x4000a800, 0x0201f800, 0x0010ab17, 0x412c7000,
10111 0x0201f800, 0x001007d3, 0x04000010, 0x492c7001,
10112 0x40040000, 0x800409c0, 0x04000009, 0x0401f7ec,
10113 0x48025811, 0x4000b000, 0x832c0400, 0x00000005,
10114 0x4000a800, 0x0201f800, 0x0010ab17, 0x82000540,
10115 0x00000001, 0x0401f006, 0x497b5016, 0x59325808,
10116 0x0201f800, 0x001007fd, 0x80000580, 0x5c00a800,
10117 0x5c00b000, 0x5c00a000, 0x5c025800, 0x1c01f000,
10118 0x4d340000, 0x59326809, 0x59343400, 0x4933c857,
10119 0x4937c857, 0x481bc857, 0x0201f800, 0x001049f3,
10120 0x5c026800, 0x1c01f000, 0x4933c857, 0x4c5c0000,
10121 0x4d3c0000, 0x0401f840, 0x0402002c, 0x59cc0207,
10122 0x82000d00, 0x0000ff00, 0x900411c0, 0x59cc000a,
10123 0x82000500, 0x00ffffff, 0x80081540, 0x480a601c,
10124 0x8c040d18, 0x0400000e, 0x42003000, 0x00000008,
10125 0x0201f800, 0x0010a932, 0x42000000, 0x0010b863,
10126 0x0201f800, 0x0010aa47, 0x4200b800, 0x00000002,
10127 0x42027800, 0x00000001, 0x0401f011, 0x4178b800,
10128 0x8c040d1a, 0x04000011, 0x59cc000a, 0x0201f800,
10129 0x00105c9a, 0x0402000d, 0x42003000, 0x00000009,
10130 0x0201f800, 0x0010a93a, 0x42000000, 0x0010b863,
10131 0x0201f800, 0x0010aa47, 0x417a7800, 0x0201f800,
10132 0x001020a1, 0x0401f004, 0x82000540, 0x00000001,
10133 0x0401f002, 0x80000580, 0x5c027800, 0x5c00b800,
10134 0x1c01f000, 0x4933c857, 0x59cc0206, 0x82000480,
10135 0x00000010, 0x04021006, 0x4a02621a, 0x00000000,
10136 0x82000540, 0x00000001, 0x0401f002, 0x80000580,
10137 0x1c01f000, 0x4933c857, 0x4a02621a, 0x00000000,
10138 0x59cc0407, 0x82000500, 0x0000ff00, 0x82000580,
10139 0x00000800, 0x04020009, 0x59cc0006, 0x82000500,
10140 0x00ff0000, 0x82000d80, 0x00140000, 0x04000003,
10141 0x82000d80, 0x00100000, 0x1c01f000, 0x4933c857,
10142 0x59300403, 0x82003480, 0x00000051, 0x02021800,
10143 0x001005d8, 0x83383580, 0x00000013, 0x04020003,
10144 0x4803c857, 0x0c01f012, 0x83383580, 0x00000027,
10145 0x04000005, 0x83383580, 0x00000014, 0x02020800,
10146 0x001005d8, 0x0201f800, 0x001048c1, 0x42000800,
10147 0x00000007, 0x0201f800, 0x00104571, 0x0201f800,
10148 0x00106bbf, 0x0201f000, 0x00107911, 0x00109e3c,
10149 0x00109e45, 0x00109e3c, 0x00109e3c, 0x00109e3c,
10150 0x00109e45, 0x00109e50, 0x00109ecd, 0x00109e95,
10151 0x00109ecd, 0x00109ead, 0x00109ecd, 0x00109ebe,
10152 0x00109ecd, 0x00109ec6, 0x00109ecd, 0x00109ec6,
10153 0x00109ecd, 0x00109ecd, 0x00109e3c, 0x00109e3c,
10154 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c,
10155 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c,
10156 0x00109e3c, 0x00109e45, 0x00109e3c, 0x00109ecd,
10157 0x00109e3c, 0x00109e3c, 0x00109ecd, 0x00109e3c,
10158 0x00109eca, 0x00109ecd, 0x00109e3c, 0x00109e3c,
10159 0x00109e3c, 0x00109e3c, 0x00109ecd, 0x00109ecd,
10160 0x00109e3c, 0x00109ec3, 0x00109ecd, 0x00109e3c,
10161 0x00109e4a, 0x00109e3c, 0x00109e3c, 0x00109e3c,
10162 0x00109e3c, 0x00109ec9, 0x00109ecd, 0x00109e3c,
10163 0x00109e3c, 0x00109ecd, 0x00109ecd, 0x00109e3c,
10164 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c,
10165 0x00109e3c, 0x00109e3c, 0x00109e3c, 0x00109e3c,
10166 0x00109e3e, 0x00109e3c, 0x00109e3e, 0x00109e3c,
10167 0x00109e3c, 0x00109e3e, 0x00109e3c, 0x00109e3c,
10168 0x00109e3c, 0x00109e3e, 0x00109e3e, 0x00109e3e,
10169 0x0201f800, 0x001005d8, 0x4d2c0000, 0x59325808,
10170 0x0201f800, 0x001007fd, 0x5c025800, 0x0201f000,
10171 0x0002077d, 0x59a80037, 0x48026206, 0x4a026203,
10172 0x00000002, 0x1c01f000, 0x4d3c0000, 0x417a7800,
10173 0x0201f800, 0x00104567, 0x5c027800, 0x0401f07e,
10174 0x42000800, 0x00000007, 0x0201f800, 0x00104571,
10175 0x59a80026, 0x8c000508, 0x04000012, 0x59326809,
10176 0x4c580000, 0x4200b000, 0x00000002, 0x83a81c00,
10177 0x00000002, 0x83341400, 0x00000006, 0x0201f800,
10178 0x0010855a, 0x80000540, 0x5c00b000, 0x0402006a,
10179 0x59340200, 0x8400051a, 0x48026a00, 0x0401f01b,
10180 0x599c0017, 0x8c00050a, 0x04020063, 0x4d3c0000,
10181 0x417a7800, 0x0201f800, 0x00104567, 0x5c027800,
10182 0x42000800, 0x00000007, 0x0201f800, 0x00104571,
10183 0x59340212, 0x82000500, 0x0000ff00, 0x04000056,
10184 0x599c0019, 0x8c00050e, 0x04020053, 0x416c0000,
10185 0x82000580, 0x00000002, 0x04020004, 0x59a8001b,
10186 0x80000000, 0x4803501b, 0x42000800, 0x00000003,
10187 0x0201f800, 0x00104571, 0x4a026406, 0x00000001,
10188 0x4a026203, 0x00000001, 0x4a026403, 0x00000002,
10189 0x0201f800, 0x0010672b, 0x4ce80000, 0x4201d000,
10190 0x00000001, 0x0201f800, 0x00105fae, 0x5c01d000,
10191 0x1c01f000, 0x0201f800, 0x001049f3, 0x04000036,
10192 0x0201f800, 0x0010645e, 0x42000800, 0x00000004,
10193 0x0201f800, 0x00104571, 0x0201f800, 0x0010a96a,
10194 0x0402002d, 0x42000800, 0x00000005, 0x0201f800,
10195 0x00104571, 0x4a026406, 0x00000001, 0x4a026203,
10196 0x00000001, 0x4a026403, 0x00000003, 0x0201f000,
10197 0x0010672b, 0x42000800, 0x00000006, 0x0401f820,
10198 0x59303009, 0x599c0017, 0x8c00050a, 0x0402001a,
10199 0x59a80026, 0x8c000508, 0x04000017, 0x0201f800,
10200 0x001049e7, 0x04000014, 0x59a8001b, 0x80000000,
10201 0x4803501b, 0x0401f7c5, 0x42000800, 0x00000004,
10202 0x0201f800, 0x00104571, 0x0401f792, 0x42000800,
10203 0x00000004, 0x0401f006, 0x0201f800, 0x001048c1,
10204 0x0401f005, 0x0401f004, 0x0401f003, 0x0201f800,
10205 0x00104571, 0x0201f000, 0x0002077d, 0x4933c857,
10206 0x4807c857, 0x0201f800, 0x00104571, 0x4d3c0000,
10207 0x417a7800, 0x0201f800, 0x00104567, 0x5c027800,
10208 0x0201f800, 0x00102074, 0x1c01f000, 0x4933c857,
10209 0x59340400, 0x80000110, 0x82003480, 0x0000000c,
10210 0x02021800, 0x001005d8, 0x83383580, 0x00000015,
10211 0x04020002, 0x0c01f006, 0x83383580, 0x00000016,
10212 0x02020800, 0x001005d8, 0x0c01f00d, 0x001080b8,
10213 0x001080b8, 0x001080b8, 0x001080b8, 0x001080b8,
10214 0x001080b8, 0x00109f30, 0x00109f03, 0x001080b8,
10215 0x001080b8, 0x001080b8, 0x001080b8, 0x001080b8,
10216 0x001080b8, 0x001080b8, 0x001080b8, 0x001080b8,
10217 0x001080b8, 0x00109f30, 0x00109f37, 0x001080b8,
10218 0x001080b8, 0x001080b8, 0x001080b8, 0x4933c857,
10219 0x599c0017, 0x8c00050a, 0x0402001b, 0x813669c0,
10220 0x04000019, 0x59340212, 0x82000500, 0x0000ff00,
10221 0x04000015, 0x599c0019, 0x8c00050e, 0x04020012,
10222 0x4d3c0000, 0x417a7800, 0x0201f800, 0x00104567,
10223 0x5c027800, 0x42000800, 0x00000003, 0x0201f800,
10224 0x00104571, 0x4a026406, 0x00000001, 0x4a026203,
10225 0x00000001, 0x4a026403, 0x00000002, 0x0201f000,
10226 0x0010672b, 0x59cc0001, 0x0201f800, 0x00105c9a,
10227 0x0402000b, 0x0201f800, 0x00020245, 0x02020000,
10228 0x0002077d, 0x59345002, 0x0201f800, 0x001042b4,
10229 0x482a6802, 0x0201f000, 0x0002077d, 0x1c01f000,
10230 0x4933c857, 0x59303403, 0x82183580, 0x0000001e,
10231 0x02000000, 0x0002077d, 0x1c01f000, 0x4933c857,
10232 0x0201f800, 0x001083df, 0x02020000, 0x0002077d,
10233 0x4a026203, 0x00000001, 0x4a026403, 0x00000001,
10234 0x0201f000, 0x0010672b, 0x493bc857, 0x83380580,
10235 0x00000051, 0x0402000b, 0x0201f800, 0x00106f60,
10236 0x02020000, 0x00107974, 0x59300203, 0x82000580,
10237 0x00000002, 0x0400006d, 0x0201f800, 0x001005d8,
10238 0x83380580, 0x00000027, 0x04000014, 0x83380580,
10239 0x00000048, 0x04000006, 0x83380580, 0x00000014,
10240 0x0400000e, 0x02020800, 0x001005d8, 0x0201f800,
10241 0x00106f60, 0x02020000, 0x00107974, 0x59300203,
10242 0x82000580, 0x00000004, 0x02000000, 0x0002086e,
10243 0x0201f800, 0x001005d8, 0x59300403, 0x82000c80,
10244 0x00000044, 0x02021800, 0x001005d8, 0x82000480,
10245 0x00000040, 0x02001800, 0x001005d8, 0x40027000,
10246 0x4803c857, 0x0c01f001, 0x00109f76, 0x00109f78,
10247 0x00109f78, 0x00109f93, 0x0201f800, 0x001005d8,
10248 0x0201f800, 0x00106bbf, 0x59325808, 0x812e59c0,
10249 0x04000016, 0x832c0500, 0x00ff0000, 0x04000013,
10250 0x4a026203, 0x00000002, 0x59326809, 0x59340200,
10251 0x8c00050e, 0x0402000d, 0x42028000, 0x00000004,
10252 0x0201f800, 0x0010a3ef, 0x497a6008, 0x59300206,
10253 0x80000540, 0x04020003, 0x59a80038, 0x48026206,
10254 0x4a026203, 0x00000007, 0x1c01f000, 0x0201f800,
10255 0x00106bbf, 0x0201f800, 0x00109037, 0x02000000,
10256 0x00107911, 0x59325808, 0x0201f800, 0x001007f4,
10257 0x0201f000, 0x00107911, 0x0201f800, 0x001005d8,
10258 0x59325808, 0x592c040a, 0x8c000502, 0x04000007,
10259 0x4a026203, 0x00000007, 0x42027000, 0x00000043,
10260 0x0201f000, 0x000207a1, 0x4a026203, 0x00000004,
10261 0x1c01f000, 0x0201f800, 0x0010a597, 0x02000000,
10262 0x0002086c, 0x1c01f000, 0x4a026203, 0x00000001,
10263 0x4a026403, 0x00000041, 0x42027800, 0x80002042,
10264 0x0201f000, 0x00020721, 0x83380580, 0x00000051,
10265 0x04000006, 0x83380580, 0x00000041, 0x02020800,
10266 0x001005d8, 0x1c01f000, 0x0201f800, 0x000206fd,
10267 0x0201f800, 0x0010a5df, 0x0201f000, 0x0002077d,
10268 0x83380480, 0x00000050, 0x02021800, 0x001005d8,
10269 0x83380480, 0x00000049, 0x02001800, 0x001005d8,
10270 0x0c01f001, 0x00109fda, 0x00109ffb, 0x00109fd8,
10271 0x00109fd8, 0x00109fd8, 0x00109fd8, 0x00109ffb,
10272 0x0201f800, 0x001005d8, 0x59325808, 0x592c040a,
10273 0x8c00051e, 0x0400000d, 0x82000d00, 0x000000c0,
10274 0x82040d80, 0x00000080, 0x0400000d, 0x59300804,
10275 0x8c040d18, 0x0402000a, 0x42027000, 0x00000041,
10276 0x0201f000, 0x0002088d, 0x4a026203, 0x00000007,
10277 0x497a6206, 0x0201f000, 0x000206fd, 0x59325808,
10278 0x592c0c0a, 0x8c040d1a, 0x04020005, 0x0201f800,
10279 0x000206fd, 0x0201f000, 0x0002077d, 0x0201f800,
10280 0x0010a597, 0x040007fa, 0x1c01f000, 0x0201f800,
10281 0x00106b8a, 0x59325808, 0x59326809, 0x59340200,
10282 0x8c00050e, 0x0400000e, 0x592c040a, 0x82000500,
10283 0x000000c0, 0x82000580, 0x00000080, 0x04000005,
10284 0x592c000f, 0x59301815, 0x800c1c80, 0x480e6015,
10285 0x4a026203, 0x00000002, 0x0401f00d, 0x42028000,
10286 0x00000004, 0x0401fbde, 0x59300206, 0x80000540,
10287 0x04020004, 0x59a80038, 0x800000c2, 0x48026206,
10288 0x497a6008, 0x4a026203, 0x00000007, 0x1c01f000,
10289 0x4a026203, 0x00000007, 0x497a6206, 0x0201f000,
10290 0x000206fd, 0x4a026203, 0x00000007, 0x497a6206,
10291 0x0201f000, 0x000206f8, 0x59300414, 0x8c00051c,
10292 0x02020000, 0x0002087e, 0x59325808, 0x592c200f,
10293 0x40080000, 0x80102480, 0x59300015, 0x80102400,
10294 0x48126015, 0x0201f000, 0x0002087e, 0x8c040d0e,
10295 0x0402000a, 0x4a026203, 0x00000006, 0x0401f823,
10296 0x5930001f, 0x80000540, 0x02020800, 0x00100d7c,
10297 0x0201f000, 0x000206f8, 0x4a026203, 0x00000002,
10298 0x1c01f000, 0x42000800, 0x00000001, 0x0201f800,
10299 0x00100d7c, 0x82040580, 0x00000001, 0x02000000,
10300 0x00020885, 0x0401f7d8, 0x59300414, 0x8c00051c,
10301 0x04000006, 0x0201f800, 0x00100b63, 0x02000000,
10302 0x00020877, 0x1c01f000, 0x59300011, 0x80000540,
10303 0x04020005, 0x0201f800, 0x00100b63, 0x02000000,
10304 0x00020877, 0x1c01f000, 0x492fc857, 0x480bc857,
10305 0x8c08153e, 0x04000006, 0x80081080, 0x80081000,
10306 0x42000800, 0x00000009, 0x0401f003, 0x42000800,
10307 0x00000015, 0x480a580b, 0x1c01f000, 0x83380580,
10308 0x00000013, 0x04000005, 0x83380580, 0x00000014,
10309 0x02020800, 0x001005d8, 0x59300414, 0x8c000516,
10310 0x02000800, 0x001005d8, 0x1c01f000, 0x0201f800,
10311 0x001005d8, 0x59300008, 0x80000540, 0x02020800,
10312 0x001005d8, 0x1c01f000, 0x59300414, 0x8c000516,
10313 0x02000800, 0x001005d8, 0x1c01f000, 0x4a026203,
10314 0x00000004, 0x493a6403, 0x42000800, 0x80002001,
10315 0x0201f000, 0x00020721, 0x4a026203, 0x00000003,
10316 0x493a6403, 0x0201f800, 0x000200c9, 0x59325808,
10317 0x592c040a, 0x8c00051e, 0x04000012, 0x82000500,
10318 0x000000c0, 0x82000580, 0x00000080, 0x04000011,
10319 0x59300414, 0x8c000512, 0x0402000a, 0x8c000510,
10320 0x04020008, 0x592c040c, 0x80000540, 0x04020005,
10321 0x82080d40, 0x80003065, 0x0201f000, 0x00106721,
10322 0x82080d40, 0x80002065, 0x0201f000, 0x00106721,
10323 0x82080d40, 0x80002042, 0x0201f000, 0x00106721,
10324 0x4933c857, 0x493bc857, 0x83380480, 0x00000044,
10325 0x02021800, 0x001005d8, 0x83380480, 0x00000041,
10326 0x02001800, 0x001005d8, 0x0c01f001, 0x0010a0b6,
10327 0x0010a0c6, 0x0010a0db, 0x59325808, 0x592c040a,
10328 0x8c00051e, 0x0400001d, 0x82001d00, 0x000000c0,
10329 0x820c1d80, 0x000000c0, 0x04000018, 0x4a026203,
10330 0x00000001, 0x493a6403, 0x42000800, 0x80002042,
10331 0x0201f000, 0x00020721, 0x59325808, 0x592c040a,
10332 0x8c00051e, 0x0400000d, 0x82001d00, 0x000000c0,
10333 0x820c1d80, 0x000000c0, 0x04000008, 0x4a026203,
10334 0x00000001, 0x493a6403, 0x42000800, 0x80002001,
10335 0x0201f000, 0x00020721, 0x497a6008, 0x497a6206,
10336 0x42028000, 0x00000004, 0x0401f315, 0x59325808,
10337 0x592c040a, 0x8c00051e, 0x040007f8, 0x82001d00,
10338 0x000000c0, 0x820c1d80, 0x000000c0, 0x040007f3,
10339 0x4a026203, 0x00000003, 0x493a6403, 0x0201f800,
10340 0x000200c9, 0x82080d40, 0x80002065, 0x0201f000,
10341 0x00106721, 0x4933c857, 0x493bc857, 0x83380580,
10342 0x00000085, 0x04000006, 0x83380580, 0x00000088,
10343 0x0400000a, 0x0201f800, 0x001005d8, 0x4a026203,
10344 0x00000009, 0x493a6403, 0x42000800, 0x8000004b,
10345 0x0201f000, 0x00020721, 0x4d1c0000, 0x813669c0,
10346 0x04000004, 0x0201f800, 0x0010a592, 0x04020044,
10347 0x59cc1404, 0x0401f846, 0x04000018, 0x591c0406,
10348 0x82000500, 0x0000001f, 0x82002580, 0x00000006,
10349 0x04000007, 0x82002580, 0x00000004, 0x0400002e,
10350 0x82002580, 0x00000011, 0x0402000c, 0x497a3a05,
10351 0x42002000, 0x00000054, 0x0201f800, 0x00107a4a,
10352 0x4a026203, 0x00000007, 0x493a6403, 0x0201f800,
10353 0x0010a974, 0x0401f02c, 0x0201f800, 0x00103b25,
10354 0x04000004, 0x42023800, 0xffffffff, 0x0401f7f1,
10355 0x813669c0, 0x04020009, 0x59cc0001, 0x0201f800,
10356 0x00105c9a, 0x0402001e, 0x0201f800, 0x001045a6,
10357 0x0402001b, 0x49366009, 0x4a026403, 0x00000087,
10358 0x59cc1204, 0x82081580, 0x0000ffff, 0x04020003,
10359 0x4a026403, 0x00000086, 0x4a026203, 0x00000001,
10360 0x42000800, 0x80000040, 0x0201f800, 0x00020721,
10361 0x0401f00d, 0x591c0203, 0x82000580, 0x00000007,
10362 0x040207de, 0x4d300000, 0x411e6000, 0x0201f800,
10363 0x00107911, 0x5c026000, 0x0401f7d8, 0x0201f800,
10364 0x00107911, 0x5c023800, 0x1c01f000, 0x4933c857,
10365 0x480bc857, 0x42002800, 0x0010d1c0, 0x41300000,
10366 0x80140580, 0x04000017, 0x58140203, 0x82000580,
10367 0x00000000, 0x04000013, 0x58140202, 0x80080580,
10368 0x04020010, 0x58141c06, 0x820c0580, 0x00000005,
10369 0x0400000c, 0x820c0580, 0x00000009, 0x0400001d,
10370 0x59302009, 0x58140009, 0x800001c0, 0x0400000b,
10371 0x801021c0, 0x04000003, 0x80100580, 0x04000010,
10372 0x82142c00, 0x00000024, 0x41540000, 0x80140480,
10373 0x0402100e, 0x0401f7e2, 0x5814001e, 0x801021c0,
10374 0x04000005, 0x58102002, 0x82102500, 0x00ffffff,
10375 0x0401f7f2, 0x5810201e, 0x0401f7f0, 0x40163800,
10376 0x81300540, 0x0401f002, 0x80000580, 0x1c01f000,
10377 0x58141807, 0x8c0c1d10, 0x040207ea, 0x0401f7e1,
10378 0x4933c857, 0x493bc857, 0x83380580, 0x00000013,
10379 0x0402000e, 0x59300403, 0x82000c80, 0x00000085,
10380 0x02001800, 0x001005d8, 0x82000c80, 0x00000093,
10381 0x02021800, 0x001005d8, 0x82000480, 0x00000085,
10382 0x4803c857, 0x0c01f018, 0x83380580, 0x00000027,
10383 0x04000005, 0x83380580, 0x00000014, 0x02020000,
10384 0x00107974, 0x0201f800, 0x00106bbf, 0x59325808,
10385 0x812e59c0, 0x02000000, 0x00107911, 0x4a025a06,
10386 0x00000031, 0x4a025811, 0x00000004, 0x4a025812,
10387 0x000000ff, 0x0201f800, 0x000202da, 0x0201f000,
10388 0x00107911, 0x0010a1b7, 0x0010a1be, 0x0010a1be,
10389 0x0010a1b7, 0x0010a1b7, 0x0010a1b7, 0x0010a1b7,
10390 0x0010a1b7, 0x0010a1b7, 0x0010a1b7, 0x0010a1b7,
10391 0x0010a1b7, 0x0010a1b7, 0x0010a1b9, 0x0201f800,
10392 0x001005d8, 0x59325808, 0x4a025a06, 0x00000000,
10393 0x0201f800, 0x000202da, 0x0201f000, 0x00107911,
10394 0x4933c857, 0x42000000, 0x0010b873, 0x0201f800,
10395 0x0010aa47, 0x0201f800, 0x0010a5df, 0x497a6205,
10396 0x42028000, 0x0000000b, 0x0401f807, 0x4a026406,
10397 0x00000006, 0x4a026203, 0x00000007, 0x497a6206,
10398 0x1c01f000, 0x4933c857, 0x4943c857, 0x59300406,
10399 0x82000580, 0x00000007, 0x04020002, 0x1c01f000,
10400 0x0201f800, 0x00106c55, 0x4df00000, 0x0201f800,
10401 0x00108ce5, 0x82000c80, 0x0000000e, 0x02021800,
10402 0x001005d8, 0x0c01f001, 0x0010a205, 0x0010a209,
10403 0x0010a1f0, 0x0010a217, 0x0010a22a, 0x0010a1f0,
10404 0x0010a1f0, 0x0010a1f0, 0x0010a1f0, 0x0010a1f0,
10405 0x0010a1f0, 0x0010a1f0, 0x0010a1f0, 0x0010a1f0,
10406 0x4d400000, 0x5930001f, 0x80000540, 0x04000005,
10407 0x41400800, 0x0201f800, 0x00100d7c, 0x40068000,
10408 0x4d2c0000, 0x59325808, 0x0201f800, 0x00109037,
10409 0x040209f3, 0x4c5c0000, 0x5930b809, 0x0201f800,
10410 0x00107911, 0x485e6009, 0x5c00b800, 0x5c025800,
10411 0x5c028000, 0x5c03e000, 0x02000000, 0x00106c4b,
10412 0x1c01f000, 0x598c000d, 0x81300580, 0x04020004,
10413 0x0201f800, 0x00106e8e, 0x04020016, 0x0201f800,
10414 0x001068d3, 0x040007df, 0x0201f800, 0x00106b6c,
10415 0x04000010, 0x0201f800, 0x001005d8, 0x0201f800,
10416 0x00108cd6, 0x04020004, 0x0201f800, 0x00106e62,
10417 0x04020008, 0x0201f800, 0x001067ae, 0x040007d1,
10418 0x0201f800, 0x00106b6c, 0x02020800, 0x001005d8,
10419 0x59300203, 0x82000c80, 0x0000000e, 0x02021800,
10420 0x001005d8, 0x0c01f7b9, 0x0201f800, 0x00100e99,
10421 0x0401f7c4, 0x4933c857, 0x4d440000, 0x4d340000,
10422 0x59cc0007, 0x0201f800, 0x00105c9a, 0x02000800,
10423 0x00020245, 0x0402001a, 0x59300009, 0x4c000000,
10424 0x49366009, 0x42003000, 0x0000000b, 0x0201f800,
10425 0x0010a942, 0x42000000, 0x0010b861, 0x0201f800,
10426 0x0010aa47, 0x4d3c0000, 0x4d400000, 0x42028000,
10427 0x00000029, 0x417a7800, 0x0201f800, 0x0010203c,
10428 0x5c028000, 0x5c027800, 0x5c000000, 0x48026009,
10429 0x59cc0007, 0x48026802, 0x80000580, 0x5c026800,
10430 0x5c028800, 0x1c01f000, 0x4933c857, 0x4c040000,
10431 0x59a80016, 0x82000580, 0x00000074, 0x04020040,
10432 0x59cc0a08, 0x82040480, 0x00000100, 0x04001033,
10433 0x59cc0c08, 0x82040500, 0x00008000, 0x04000035,
10434 0x59a80032, 0x80000540, 0x04020009, 0x59301009,
10435 0x58080212, 0x82000500, 0x0000ff00, 0x04000004,
10436 0x82040500, 0x00000800, 0x0400002a, 0x59cc0c09,
10437 0x80040840, 0x04001024, 0x59a80826, 0x8c040d06,
10438 0x04000004, 0x59cc0c0f, 0x8c040d1e, 0x04020012,
10439 0x59cc0a17, 0x800409c0, 0x04020012, 0x59cc0a18,
10440 0x82040480, 0x00000100, 0x04001014, 0x59cc0c18,
10441 0x800409c0, 0x0402000e, 0x59cc0c19, 0x80040840,
10442 0x04001011, 0x59cc0c1a, 0x80040840, 0x04001011,
10443 0x0401f018, 0x4a02621a, 0x00000100, 0x0401f012,
10444 0x4a02621a, 0x00000300, 0x0401f00f, 0x4a02621a,
10445 0x00000500, 0x0401f00c, 0x4a02621a, 0x00000700,
10446 0x0401f009, 0x4a02621a, 0x00000900, 0x0401f006,
10447 0x4a02621a, 0x00000f00, 0x0401f003, 0x4a02621a,
10448 0x00002d00, 0x82000540, 0x00000001, 0x0401f002,
10449 0x80000580, 0x5c000800, 0x1c01f000, 0x59cc0407,
10450 0x4803c857, 0x82000580, 0x00000800, 0x04000003,
10451 0x4a02621a, 0x00000000, 0x1c01f000, 0x4933c857,
10452 0x4c040000, 0x4c080000, 0x4c0c0000, 0x4c580000,
10453 0x59cc000c, 0x0201f800, 0x00105c9a, 0x02000800,
10454 0x00020245, 0x04020012, 0x83cc1400, 0x00000008,
10455 0x4200b000, 0x00000002, 0x83341c00, 0x00000006,
10456 0x0201f800, 0x0010855a, 0x04020009, 0x83cc1400,
10457 0x0000000a, 0x4200b000, 0x00000002, 0x83341c00,
10458 0x00000008, 0x0201f800, 0x0010855a, 0x5c00b000,
10459 0x5c001800, 0x5c001000, 0x5c000800, 0x1c01f000,
10460 0x4933c857, 0x4c000000, 0x4c040000, 0x4c080000,
10461 0x4c0c0000, 0x4c580000, 0x59cc0001, 0x0201f800,
10462 0x00105c9a, 0x02000800, 0x00020245, 0x04020014,
10463 0x83cc1400, 0x0000000b, 0x4200b000, 0x00000002,
10464 0x83341c00, 0x00000006, 0x0201f800, 0x0010855a,
10465 0x0402000c, 0x83cc1400, 0x0000000d, 0x4200b000,
10466 0x00000002, 0x83341c00, 0x00000008, 0x0201f800,
10467 0x0010855a, 0x04000014, 0x4933c856, 0x4933c856,
10468 0x4933c857, 0x59340009, 0x4803c857, 0x5934000e,
10469 0x4803c857, 0x59340008, 0x4803c857, 0x5934000d,
10470 0x4803c857, 0x59340007, 0x4803c857, 0x5934000c,
10471 0x4803c857, 0x59340006, 0x4803c857, 0x5934000b,
10472 0x4803c857, 0x5c00b000, 0x5c001800, 0x5c001000,
10473 0x5c000800, 0x5c000000, 0x1c01f000, 0x4933c857,
10474 0x4947c857, 0x4943c857, 0x4c600000, 0x0201f800,
10475 0x00106c55, 0x4df00000, 0x4d2c0000, 0x4d300000,
10476 0x4d340000, 0x4130c000, 0x42026000, 0x0010d1c0,
10477 0x59a8000e, 0x8060c1c0, 0x04000005, 0x82601580,
10478 0x0010bde9, 0x04000002, 0x80000040, 0x81640480,
10479 0x040210be, 0x40600000, 0x81300580, 0x040000b6,
10480 0x0401f97a, 0x040200b4, 0x59326809, 0x59300406,
10481 0x82000c80, 0x00000012, 0x02021800, 0x001005d8,
10482 0x0c01f001, 0x0010a3cd, 0x0010a338, 0x0010a351,
10483 0x0010a35c, 0x0010a335, 0x0010a34c, 0x0010a387,
10484 0x0010a3cd, 0x0010a333, 0x0010a39a, 0x0010a3ae,
10485 0x0010a333, 0x0010a333, 0x0010a333, 0x0010a333,
10486 0x0010a3cd, 0x0010a3c4, 0x0010a3bc, 0x0201f800,
10487 0x001005d8, 0x59300420, 0x8c000500, 0x04020096,
10488 0x59300403, 0x82000580, 0x00000043, 0x04000092,
10489 0x0201f800, 0x00109134, 0x04000007, 0x0201f800,
10490 0x0010914e, 0x0402008a, 0x0201f800, 0x0010801c,
10491 0x0401f087, 0x0201f800, 0x00102074, 0x0201f800,
10492 0x0010914e, 0x02000800, 0x0010801c, 0x0401f080,
10493 0x8d3e7d18, 0x04000004, 0x59300420, 0x8c000500,
10494 0x0402007d, 0x59325808, 0x0201f800, 0x00109037,
10495 0x04000077, 0x49425a06, 0x497a5c09, 0x0201f800,
10496 0x000202da, 0x0201f800, 0x0010912a, 0x0401f070,
10497 0x8d3e7d00, 0x04000007, 0x59300017, 0x81480580,
10498 0x0402006d, 0x59300018, 0x814c0580, 0x0402006a,
10499 0x59300203, 0x82000580, 0x00000004, 0x02000800,
10500 0x00100e99, 0x59325808, 0x0201f800, 0x00109037,
10501 0x0400005f, 0x4a025a04, 0x00000103, 0x59300004,
10502 0x8400055c, 0x48026004, 0x592c0408, 0x8c000512,
10503 0x04000007, 0x4d2c0000, 0x592c0009, 0x40025800,
10504 0x0201f800, 0x001007fd, 0x5c025800, 0x49425a06,
10505 0x497a5c09, 0x0401fb16, 0x0201f800, 0x0010959c,
10506 0x0201f800, 0x001091c6, 0x0201f800, 0x000202da,
10507 0x0201f800, 0x0010912a, 0x0401f045, 0x8d3e7d18,
10508 0x04000045, 0x59300203, 0x82000580, 0x00000004,
10509 0x02000800, 0x00100e99, 0x59325808, 0x0201f800,
10510 0x00109037, 0x0400003a, 0x49425a06, 0x497a5c09,
10511 0x0401faff, 0x0201f800, 0x0010959c, 0x0201f800,
10512 0x000202da, 0x0401f032, 0x0201f800, 0x001062d5,
10513 0x04000031, 0x59300203, 0x82000580, 0x00000004,
10514 0x0400002d, 0x59300203, 0x82000580, 0x00000003,
10515 0x04020029, 0x0201f800, 0x00106b8a, 0x59325808,
10516 0x0201f800, 0x00109037, 0x04000021, 0x0201f800,
10517 0x000202da, 0x0401f01e, 0x59300203, 0x82000580,
10518 0x00000004, 0x02000800, 0x00100e99, 0x59325808,
10519 0x0201f800, 0x00109037, 0x04000015, 0x49425a06,
10520 0x497a5c09, 0x0201f800, 0x000202da, 0x0401f010,
10521 0x833c0500, 0x00001800, 0x0400000f, 0x8d3e7d16,
10522 0x0402000d, 0x59325817, 0x0201f800, 0x001007fd,
10523 0x59325808, 0x0201f800, 0x00109037, 0x04000004,
10524 0x49425a06, 0x0201f800, 0x000202da, 0x0201f800,
10525 0x00107911, 0x83326400, 0x00000024, 0x41580000,
10526 0x81300480, 0x0400173b, 0x5c026800, 0x5c026000,
10527 0x5c025800, 0x5c03e000, 0x02000800, 0x00106c4b,
10528 0x5c00c000, 0x1c01f000, 0x5c000000, 0x4c000000,
10529 0x4803c857, 0x4d3c0000, 0x42027800, 0x00000001,
10530 0x0201f800, 0x00104567, 0x5c027800, 0x4c580000,
10531 0x4200b000, 0x00000002, 0x83a81c00, 0x00000002,
10532 0x83cc1400, 0x0000000b, 0x0201f800, 0x0010855a,
10533 0x5c00b000, 0x80000540, 0x1c01f000, 0x492fc857,
10534 0x4943c857, 0x59a8000c, 0x812c0480, 0x04001011,
10535 0x59a8000d, 0x812c0480, 0x0402100e, 0x592c0000,
10536 0x80005d40, 0x04000008, 0x497a5800, 0x49425a06,
10537 0x4c2c0000, 0x0201f800, 0x000202da, 0x5c025800,
10538 0x0401f7f7, 0x49425a06, 0x0201f000, 0x000202da,
10539 0x1c01f000, 0x493fc857, 0x4933c857, 0x480bc857,
10540 0x0201f800, 0x00103b25, 0x0400002e, 0x41502800,
10541 0x813e79c0, 0x04020006, 0x59a80066, 0x80000000,
10542 0x59a8086a, 0x80040580, 0x04000026, 0x41300000,
10543 0x80140580, 0x0400001a, 0x58140203, 0x82000580,
10544 0x00000000, 0x04000016, 0x58140202, 0x80080580,
10545 0x04020013, 0x58141c06, 0x820c0580, 0x00000005,
10546 0x0400000f, 0x820c0580, 0x00000009, 0x04000017,
10547 0x59300009, 0x58142009, 0x801021c0, 0x04020006,
10548 0x5814201e, 0x59301809, 0x580c0002, 0x82000500,
10549 0x00ffffff, 0x80100580, 0x04000007, 0x82142c00,
10550 0x00000024, 0x41540000, 0x80140480, 0x04021005,
10551 0x0401f7df, 0x40163800, 0x81300540, 0x0401f002,
10552 0x80000580, 0x1c01f000, 0x58141807, 0x8c0c1d10,
10553 0x040207f3, 0x0401f7e7, 0x42002000, 0x0000ffff,
10554 0x59301009, 0x800811c0, 0x04000002, 0x58082403,
10555 0x41301000, 0x0401f007, 0x41781000, 0x41442000,
10556 0x0401f004, 0x41781000, 0x42002000, 0x0000ffff,
10557 0x5c000000, 0x4c000000, 0x4803c857, 0x480bc857,
10558 0x4813c857, 0x492fc857, 0x4943c857, 0x4d2c0000,
10559 0x0201f800, 0x001007e4, 0x02000800, 0x001005d8,
10560 0x4a025a04, 0x0000010d, 0x800811c0, 0x04000017,
10561 0x83400580, 0x00000029, 0x04020010, 0x82180580,
10562 0x00000002, 0x0400000a, 0x82180580, 0x00000003,
10563 0x04000007, 0x82180580, 0x00000008, 0x04000004,
10564 0x82180580, 0x00000009, 0x04020004, 0x4a025809,
10565 0xffffffff, 0x0401f002, 0x480a5809, 0x58080202,
10566 0x48025c13, 0x0401f005, 0x4a025809, 0xffffffff,
10567 0x4a025c13, 0x0000ffff, 0x49425a08, 0x48125a06,
10568 0x82100580, 0x0000ffff, 0x0400000e, 0x4d440000,
10569 0x4d340000, 0x40128800, 0x0201f800, 0x00020245,
10570 0x02020800, 0x001005d8, 0x59340002, 0x82000500,
10571 0x00ffffff, 0x48025812, 0x5c026800, 0x5c028800,
10572 0x497a5800, 0x497a5c04, 0x83400580, 0x00000046,
10573 0x04020002, 0x48165a07, 0x481a5c08, 0x0401fbed,
10574 0x5c025800, 0x1c01f000, 0x59300809, 0x800409c0,
10575 0x04000004, 0x58040403, 0x81440580, 0x1c01f000,
10576 0x82000540, 0x00000001, 0x0401f7fd, 0x4933c857,
10577 0x4c040000, 0x59300403, 0x82000d80, 0x0000001e,
10578 0x04020016, 0x800000d0, 0x59300a16, 0x82040d00,
10579 0x000000ff, 0x80040540, 0x4803c857, 0x48026416,
10580 0x4a026403, 0x00000085, 0x4a026203, 0x00000009,
10581 0x4a026406, 0x00000005, 0x4a02621d, 0x00000004,
10582 0x59a80038, 0x48026206, 0x42000800, 0x8000004b,
10583 0x0201f800, 0x00020721, 0x5c000800, 0x1c01f000,
10584 0x4933c857, 0x40000000, 0x40000000, 0x1c01f000,
10585 0x59300414, 0x4933c857, 0x4803c857, 0x8c000518,
10586 0x04000009, 0x8c000512, 0x02020000, 0x0010921e,
10587 0x0401f91b, 0x0201f800, 0x000206fd, 0x0201f800,
10588 0x0002077d, 0x1c01f000, 0x591c0406, 0x4803c857,
10589 0x82000c80, 0x00000009, 0x0402100b, 0x0c01f001,
10590 0x0010a4d9, 0x0010a4d9, 0x0010a4d9, 0x0010a4db,
10591 0x0010a4d9, 0x0010a4db, 0x0010a4db, 0x0010a4d9,
10592 0x0010a4db, 0x80000580, 0x1c01f000, 0x82000540,
10593 0x00000001, 0x1c01f000, 0x591c0406, 0x82000500,
10594 0x0000001f, 0x82000580, 0x00000006, 0x0400000e,
10595 0x4803c857, 0x4a026403, 0x0000003b, 0x4a02641a,
10596 0x00000009, 0x4a02621a, 0x00002a00, 0x4a026203,
10597 0x00000001, 0x42000800, 0x80000040, 0x0201f000,
10598 0x00020721, 0x4803c856, 0x4c040000, 0x4c140000,
10599 0x4d300000, 0x411e6000, 0x0401f8e9, 0x497a6205,
10600 0x59300414, 0x4803c857, 0x82000500, 0xffffadff,
10601 0x48026414, 0x497a6405, 0x5c026000, 0x0201f800,
10602 0x001007e4, 0x02000800, 0x001005d8, 0x5c002800,
10603 0x5c000800, 0x4a025a04, 0x0000010d, 0x497a5800,
10604 0x497a5c04, 0x4a025a08, 0x00000045, 0x491e5809,
10605 0x59300402, 0x48025c07, 0x59300419, 0x48025c0b,
10606 0x591c0414, 0x84000556, 0x48023c14, 0x591c1809,
10607 0x580c0403, 0x48025a06, 0x4816580a, 0x48065a0b,
10608 0x0401f99d, 0x4d400000, 0x42028000, 0x00000045,
10609 0x591c0202, 0x4c000000, 0x4d300000, 0x411e6000,
10610 0x0401fcb1, 0x5c026000, 0x5c000000, 0x48023a02,
10611 0x5c028000, 0x4a023c06, 0x00000006, 0x4a023a03,
10612 0x00000007, 0x497a3a06, 0x497a3a05, 0x1c01f000,
10613 0x4933c857, 0x83380580, 0x00000013, 0x0402000b,
10614 0x59300403, 0x4803c857, 0x82000d80, 0x00000085,
10615 0x0400002b, 0x82000d80, 0x0000008b, 0x04000028,
10616 0x0201f800, 0x001005d8, 0x83380580, 0x00000027,
10617 0x0402000c, 0x0201f800, 0x00106bbf, 0x4d2c0000,
10618 0x4d400000, 0x59325808, 0x42028000, 0x00000004,
10619 0x0401feab, 0x5c028000, 0x5c025800, 0x1c01f000,
10620 0x83380580, 0x00000014, 0x040007f3, 0x83380580,
10621 0x00000089, 0x04000005, 0x83380580, 0x0000008a,
10622 0x02020000, 0x00107974, 0x0201f800, 0x00106f60,
10623 0x02020000, 0x00107974, 0x59300a03, 0x82040580,
10624 0x0000000a, 0x04000009, 0x82040580, 0x0000000c,
10625 0x04000006, 0x0201f800, 0x001005d8, 0x4a026203,
10626 0x0000000a, 0x1c01f000, 0x83380480, 0x00000093,
10627 0x0402100c, 0x83380480, 0x00000085, 0x04001009,
10628 0x83380580, 0x00000089, 0x0400000a, 0x83380580,
10629 0x0000008a, 0x04000022, 0x0201f800, 0x001005d8,
10630 0x493bc857, 0x4933c857, 0x0201f000, 0x00107974,
10631 0x4933c857, 0x4c340000, 0x41306800, 0x0201f800,
10632 0x0002075a, 0x04000011, 0x4a026203, 0x00000001,
10633 0x4a026403, 0x0000001e, 0x59cc0c07, 0x48066419,
10634 0x59cc0a07, 0x48066219, 0x58340809, 0x48066009,
10635 0x4a026406, 0x00000004, 0x42000800, 0x80000040,
10636 0x0201f800, 0x00020721, 0x40366000, 0x0201f800,
10637 0x0002077d, 0x5c006800, 0x1c01f000, 0x4933c857,
10638 0x0201f000, 0x0002077d, 0x4933c857, 0x59300809,
10639 0x58040200, 0x8c00051a, 0x1c01f000, 0x0201f800,
10640 0x001048df, 0x0400001e, 0x4a026203, 0x00000002,
10641 0x59300414, 0x84000558, 0x48026414, 0x8c000512,
10642 0x04000004, 0x59a80039, 0x48026205, 0x0401f007,
10643 0x59a80839, 0x59a80037, 0x80040400, 0x82000400,
10644 0x0000000a, 0x48026205, 0x59300009, 0x82000c00,
10645 0x00000011, 0x50040000, 0x80000540, 0x04000004,
10646 0x82000c00, 0x00000000, 0x0401f7fb, 0x45300800,
10647 0x497a6000, 0x82000540, 0x00000001, 0x1c01f000,
10648 0x82100500, 0xfffffeef, 0x04020020, 0x4d2c0000,
10649 0x4937c857, 0x59340811, 0x83341400, 0x00000011,
10650 0x800409c0, 0x0400000e, 0x40040000, 0x81300580,
10651 0x04000005, 0x58040800, 0x82041400, 0x00000000,
10652 0x0401f7f8, 0x59300800, 0x497a6000, 0x44041000,
10653 0x0201f800, 0x000206fd, 0x0401f002, 0x4933c857,
10654 0x592c0000, 0x80000540, 0x02020800, 0x001005d8,
10655 0x5c025800, 0x492e6008, 0x0201f800, 0x000206fd,
10656 0x0201f000, 0x0002077d, 0x492fc857, 0x4a025a06,
10657 0x00000006, 0x0201f000, 0x000202da, 0x4c340000,
10658 0x59300009, 0x800001c0, 0x04000010, 0x82006c00,
10659 0x00000011, 0x50340000, 0x80000540, 0x04000009,
10660 0x81300580, 0x04000005, 0x50340000, 0x82006c00,
10661 0x00000000, 0x0401f7f8, 0x59300000, 0x44006800,
10662 0x5c006800, 0x1c01f000, 0x59300c06, 0x82040580,
10663 0x00000005, 0x040007fb, 0x82040580, 0x00000011,
10664 0x040007f8, 0x82040580, 0x00000006, 0x040007f5,
10665 0x82040580, 0x00000001, 0x040007f2, 0x0201f800,
10666 0x001005d8, 0x4933c857, 0x4c080000, 0x4c0c0000,
10667 0x4c580000, 0x59a8101d, 0x59cc1807, 0x820c1d00,
10668 0x00ffffff, 0x800c0110, 0x80083580, 0x04020014,
10669 0x83cc1400, 0x00000008, 0x4200b000, 0x00000002,
10670 0x59300009, 0x82001c00, 0x00000006, 0x0201f800,
10671 0x0010855a, 0x0402000a, 0x83cc1400, 0x0000000a,
10672 0x4200b000, 0x00000002, 0x59300009, 0x82001c00,
10673 0x00000008, 0x0201f800, 0x0010855a, 0x5c00b000,
10674 0x5c001800, 0x5c001000, 0x1c01f000, 0x4933c856,
10675 0x0201f800, 0x0010421b, 0x0201f000, 0x00101e45,
10676 0x493bc857, 0x4d2c0000, 0x0201f800, 0x001007e4,
10677 0x02000800, 0x001005d8, 0x832cac00, 0x00000005,
10678 0x4c580000, 0x4c540000, 0x4200b000, 0x00000006,
10679 0x4578a800, 0x8054a800, 0x8058b040, 0x040207fd,
10680 0x83380580, 0x00000046, 0x04020004, 0x4a025a04,
10681 0x00000144, 0x0401f008, 0x4a025a04, 0x00000146,
10682 0x83380580, 0x00000041, 0x04000003, 0x4a025a06,
10683 0x00000001, 0x59cc0007, 0x82000500, 0xff000000,
10684 0x80000110, 0x59cc1008, 0x82081500, 0xff000000,
10685 0x80081540, 0x480a580a, 0x83380580, 0x00000046,
10686 0x04020006, 0x59cc0007, 0x82000500, 0x00ffffff,
10687 0x4802580b, 0x0401f005, 0x59cc0008, 0x82000500,
10688 0x00ffffff, 0x4802580b, 0x83380580, 0x00000046,
10689 0x04020004, 0x83cc1400, 0x00000009, 0x0401f003,
10690 0x83cc1400, 0x0000000d, 0x50080000, 0x9c0001c0,
10691 0x4802580c, 0x80081000, 0x50080000, 0x9c0001c0,
10692 0x4802580d, 0x83380580, 0x00000046, 0x04020008,
10693 0x59cc000b, 0x9c0001c0, 0x4802580e, 0x59cc000c,
10694 0x9c0001c0, 0x4802580f, 0x0401f007, 0x59cc000f,
10695 0x9c0001c0, 0x4802580e, 0x59cc0010, 0x9c0001c0,
10696 0x4802580f, 0x83380580, 0x00000046, 0x04020004,
10697 0x83cc1400, 0x00000011, 0x0401f003, 0x83cc1400,
10698 0x00000015, 0x412c3000, 0x82183400, 0x00000010,
10699 0x4200b000, 0x00000004, 0x50080000, 0x9c0001c0,
10700 0x44003000, 0x80081000, 0x80183000, 0x8058b040,
10701 0x040207fa, 0x5c00a800, 0x5c00b000, 0x0201f800,
10702 0x000202da, 0x5c025800, 0x1c01f000, 0x4933c857,
10703 0x492fc857, 0x59300809, 0x58040200, 0x8c00051e,
10704 0x04000004, 0x592c0208, 0x84000558, 0x48025a08,
10705 0x1c01f000, 0x59e0180f, 0x599c0413, 0x800c1000,
10706 0x80080580, 0x04020002, 0x41781000, 0x59e00010,
10707 0x59e00810, 0x80040d80, 0x040207fd, 0x80080580,
10708 0x0400000b, 0x4c080000, 0x599c0814, 0x599c1015,
10709 0x800c00cc, 0x80040c00, 0x82081440, 0x00000000,
10710 0x5c001800, 0x82000540, 0x00000001, 0x4803c857,
10711 0x1c01f000, 0x492fc857, 0x42007000, 0x0010b7f8,
10712 0x58380807, 0x800409c0, 0x04020005, 0x492c7008,
10713 0x492c7007, 0x0201f000, 0x00100875, 0x492c0800,
10714 0x492c7007, 0x1c01f000, 0x59300203, 0x4933c857,
10715 0x4937c857, 0x493bc857, 0x4803c857, 0x82003480,
10716 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f001,
10717 0x0010a6da, 0x0010a82c, 0x0010a6da, 0x0010a6da,
10718 0x0010a6da, 0x0010a6da, 0x0010a6da, 0x0010a791,
10719 0x0010a6dc, 0x0010a6da, 0x0010a6da, 0x0010a6da,
10720 0x0010a6da, 0x0010a6da, 0x0201f800, 0x001005d8,
10721 0x83380580, 0x0000004c, 0x02020800, 0x001005d8,
10722 0x0201f800, 0x001048ec, 0x04020020, 0x59a80826,
10723 0x82040500, 0x00000009, 0x82000580, 0x00000008,
10724 0x0400001a, 0x8c040d12, 0x0400003d, 0x59cc0806,
10725 0x82040d00, 0xff000000, 0x82040580, 0x03000000,
10726 0x0400001f, 0x82040580, 0x50000000, 0x04000005,
10727 0x82040580, 0x52000000, 0x02020000, 0x0002077d,
10728 0x813669c0, 0x04000006, 0x4d3c0000, 0x417a7800,
10729 0x0201f800, 0x0010203c, 0x5c027800, 0x4a026403,
10730 0x00000001, 0x0401f014, 0x59cc0806, 0x82040d00,
10731 0xff000000, 0x82040580, 0x03000000, 0x04000008,
10732 0x82040580, 0x50000000, 0x04000005, 0x82040580,
10733 0x52000000, 0x02020000, 0x0002077d, 0x4a026403,
10734 0x00000009, 0x4a02641a, 0x00000009, 0x4a02621a,
10735 0x00000000, 0x813669c0, 0x0402000b, 0x59cc0001,
10736 0x0201f800, 0x00105c9a, 0x02020000, 0x0002077d,
10737 0x0201f800, 0x001045a6, 0x02020000, 0x0002077d,
10738 0x49366009, 0x4a026406, 0x00000004, 0x4a026203,
10739 0x00000001, 0x0201f000, 0x0010672b, 0x0201f800,
10740 0x00103b25, 0x04000023, 0x59cc0806, 0x4807c857,
10741 0x82040d00, 0xff000000, 0x82040580, 0x03000000,
10742 0x04000033, 0x82040580, 0x20000000, 0x04000041,
10743 0x82040580, 0x21000000, 0x04000052, 0x82040580,
10744 0x24000000, 0x0400004f, 0x82040580, 0x50000000,
10745 0x0400004c, 0x82040580, 0x52000000, 0x04000049,
10746 0x82040580, 0x05000000, 0x0402000d, 0x59cc0806,
10747 0x82040d00, 0xff000000, 0x9c0431c0, 0x42028000,
10748 0x00000046, 0x42002800, 0x00000001, 0x0401fcf3,
10749 0x0401f93c, 0x02000800, 0x001005d8, 0x42002000,
10750 0x00000051, 0x0201f800, 0x00107a4a, 0x59cc0000,
10751 0x82000500, 0x00ffffff, 0x82000580, 0x00ffffff,
10752 0x04000005, 0x4a026203, 0x00000007, 0x493a6403,
10753 0x1c01f000, 0x59325817, 0x812e59c0, 0x02020800,
10754 0x001007fd, 0x0201f000, 0x0002077d, 0x813669c0,
10755 0x040007df, 0x59340400, 0x82000500, 0x000000ff,
10756 0x82000580, 0x00000003, 0x040207d9, 0x0401fc6f,
10757 0x040207d7, 0x4a026403, 0x00000009, 0x4a02641a,
10758 0x0000000e, 0x4a02621a, 0x00001900, 0x0401f7a2,
10759 0x813669c0, 0x0400000c, 0x59340c00, 0x82040500,
10760 0x000000ff, 0x82000580, 0x00000009, 0x04000794,
10761 0x82040500, 0x0000ff00, 0x82000580, 0x00000700,
10762 0x040207c3, 0x4a026403, 0x00000009, 0x4a02641a,
10763 0x00000009, 0x4a02621a, 0x00001e00, 0x0401f78e,
10764 0x813669c0, 0x040007f8, 0x59340c00, 0x82040500,
10765 0x0000ff00, 0x82000580, 0x00000700, 0x040007f2,
10766 0x0401f7b3, 0x4d2c0000, 0x4c580000, 0x4c500000,
10767 0x4c540000, 0x41385000, 0x83380580, 0x00000054,
10768 0x02020800, 0x001005d8, 0x59325808, 0x592c0c0b,
10769 0x82040d00, 0x0000e000, 0x82040580, 0x00002000,
10770 0x04020076, 0x59300817, 0x800409c0, 0x04000014,
10771 0x58041404, 0x41cca800, 0x8204a400, 0x00000005,
10772 0x82080480, 0x00000010, 0x04021004, 0x4008b000,
10773 0x0401fb6b, 0x0401f00a, 0x40001000, 0x4200b000,
10774 0x0000000f, 0x0401fb66, 0x58040801, 0x800409c0,
10775 0x040207f2, 0x0201f800, 0x001005d8, 0x813669c0,
10776 0x0400005e, 0x59344c00, 0x592c0c09, 0x4807c857,
10777 0x4827c857, 0x82040d00, 0x000000ff, 0x82040580,
10778 0x00000003, 0x0400002a, 0x82040580, 0x00000005,
10779 0x04000032, 0x82040580, 0x00000020, 0x04000036,
10780 0x82040580, 0x00000052, 0x04000042, 0x82040580,
10781 0x00000050, 0x04000042, 0x82040580, 0x00000021,
10782 0x04000004, 0x82040580, 0x00000024, 0x04020043,
10783 0x82240500, 0x0000ff00, 0x82000580, 0x00000007,
10784 0x04000008, 0x42000800, 0x00000009, 0x0201f800,
10785 0x00104571, 0x42005000, 0x0000000c, 0x0401f037,
10786 0x4a025a06, 0x00000031, 0x4a02580d, 0x00000009,
10787 0x59340400, 0x4802580e, 0x0201f800, 0x000202da,
10788 0x0201f800, 0x00107911, 0x0401f03d, 0x0201f800,
10789 0x001042b4, 0x0201f800, 0x0010462a, 0x42000800,
10790 0x00000003, 0x0201f800, 0x00104571, 0x42005000,
10791 0x00000008, 0x0401f021, 0x59cc0007, 0x0201f800,
10792 0x00105eec, 0x0402001d, 0x0201f800, 0x001042b4,
10793 0x0401f01a, 0x82240500, 0x0000ff00, 0x82000580,
10794 0x00000007, 0x040007df, 0x82240500, 0x000000ff,
10795 0x82000580, 0x00000009, 0x040007da, 0x0201f800,
10796 0x0010468d, 0x42005000, 0x0000000a, 0x0401f00b,
10797 0x42005000, 0x0000000e, 0x0401f003, 0x42005000,
10798 0x00000010, 0x82240500, 0x0000ff00, 0x82000580,
10799 0x00000007, 0x040007cb, 0x482a6403, 0x4a026203,
10800 0x00000001, 0x592c000d, 0x48026011, 0x497a6013,
10801 0x59a80038, 0x48026206, 0x417a7800, 0x0201f800,
10802 0x0010672b, 0x59325817, 0x812e59c0, 0x04000004,
10803 0x0201f800, 0x001007fd, 0x497a6017, 0x5c00a800,
10804 0x5c00a000, 0x5c00b000, 0x5c025800, 0x1c01f000,
10805 0x4d2c0000, 0x59325808, 0x83380580, 0x00000013,
10806 0x04020029, 0x59300c03, 0x82040580, 0x00000054,
10807 0x0400001e, 0x82040580, 0x00000010, 0x04000018,
10808 0x82040580, 0x0000000e, 0x04000015, 0x82040580,
10809 0x00000008, 0x0400000d, 0x82040580, 0x0000000c,
10810 0x0400000a, 0x82040580, 0x0000000a, 0x02020800,
10811 0x001005d8, 0x42000800, 0x00000006, 0x0201f800,
10812 0x00104571, 0x0401f009, 0x42000800, 0x00000004,
10813 0x0201f800, 0x00104571, 0x0401f004, 0x59340200,
10814 0x8400051a, 0x48026a00, 0x4a025a06, 0x00000000,
10815 0x0201f800, 0x000202da, 0x0201f800, 0x0002077d,
10816 0x0401f022, 0x83380580, 0x00000027, 0x0400000e,
10817 0x83380580, 0x00000014, 0x02020800, 0x001005d8,
10818 0x0201f800, 0x00106bbf, 0x42028000, 0x00000031,
10819 0x42000800, 0x00000004, 0x42001000, 0x000000ff,
10820 0x0401f009, 0x0201f800, 0x00106bbf, 0x42028000,
10821 0x00000031, 0x42000800, 0x00000004, 0x42001000,
10822 0x00000010, 0x49425a06, 0x4806580d, 0x480a580e,
10823 0x0201f800, 0x000202da, 0x0201f800, 0x00104c19,
10824 0x0201f800, 0x00107911, 0x5c025800, 0x1c01f000,
10825 0x42007000, 0x0010b7f8, 0x58380807, 0x800409c0,
10826 0x04020005, 0x492c7008, 0x492c7007, 0x0201f000,
10827 0x00100875, 0x492c0800, 0x492c7007, 0x1c01f000,
10828 0x4d2c0000, 0x4c580000, 0x4c500000, 0x4c540000,
10829 0x4933c857, 0x4937c857, 0x59cc0806, 0x4807c857,
10830 0x82040d00, 0xff000000, 0x82040580, 0x03000000,
10831 0x0400000d, 0x82040580, 0x05000000, 0x0400000a,
10832 0x82040580, 0x21000000, 0x04000030, 0x82040580,
10833 0x24000000, 0x0400002d, 0x82040580, 0x20000000,
10834 0x0402002f, 0x0201f800, 0x001007e4, 0x0400002c,
10835 0x492fc857, 0x492e6017, 0x59a8b016, 0x8258b400,
10836 0x0000001b, 0x8258b500, 0xfffffffc, 0x8058b104,
10837 0x485a5c04, 0x412c7800, 0x41cca000, 0x82580480,
10838 0x00000010, 0x04021005, 0x832cac00, 0x00000005,
10839 0x0401fa63, 0x0401f015, 0x40580800, 0x4200b000,
10840 0x0000000f, 0x832cac00, 0x00000005, 0x0401fa5c,
10841 0x8204b480, 0x0000000f, 0x0201f800, 0x001007e4,
10842 0x04000004, 0x492c7801, 0x412c7800, 0x0401f7ec,
10843 0x59325817, 0x0201f800, 0x001007fd, 0x497a6017,
10844 0x80000580, 0x0401f006, 0x59340200, 0x84000554,
10845 0x48026a00, 0x82000540, 0x00000001, 0x5c00a800,
10846 0x5c00a000, 0x5c00b000, 0x5c025800, 0x1c01f000,
10847 0x4933c857, 0x492fc857, 0x4d2c0000, 0x59300a03,
10848 0x82040580, 0x00000007, 0x04000036, 0x82040580,
10849 0x00000001, 0x02020800, 0x001005d8, 0x0201f800,
10850 0x00106c55, 0x4df00000, 0x598c000d, 0x81300580,
10851 0x04020016, 0x59300004, 0x8c000520, 0x04000004,
10852 0x84000520, 0x48026004, 0x0401f016, 0x42001000,
10853 0x0010b7f6, 0x50081000, 0x58080002, 0x82000580,
10854 0x00000100, 0x04000006, 0x5808000c, 0x81300580,
10855 0x02020800, 0x001005d8, 0x0401f00a, 0x0201f800,
10856 0x00106e8e, 0x04020020, 0x59300004, 0x8c000520,
10857 0x04000004, 0x84000520, 0x48026004, 0x0401f003,
10858 0x0201f800, 0x001068d3, 0x5c03e000, 0x02000800,
10859 0x00106c4b, 0x0201f800, 0x00109037, 0x02000800,
10860 0x001005d8, 0x59325808, 0x4a025a06, 0x00000005,
10861 0x0201f800, 0x000202da, 0x0201f800, 0x00104c19,
10862 0x59325817, 0x812e59c0, 0x02020800, 0x001007fd,
10863 0x0201f800, 0x00107911, 0x80000580, 0x5c025800,
10864 0x1c01f000, 0x5c03e000, 0x02000800, 0x00106c4b,
10865 0x59300406, 0x82000580, 0x00000011, 0x040007b8,
10866 0x0401f7f7, 0x4c040000, 0x59340200, 0x4803c857,
10867 0x8c00051c, 0x04000009, 0x59cc0805, 0x591c0019,
10868 0x4803c857, 0x80040580, 0x04000004, 0x80000580,
10869 0x4803c856, 0x0401f003, 0x82000540, 0x00000001,
10870 0x5c000800, 0x1c01f000, 0x4c000000, 0x4c0c0000,
10871 0x4c100000, 0x42001800, 0x0000ffff, 0x42002000,
10872 0x00000004, 0x0401f010, 0x4c000000, 0x4c0c0000,
10873 0x4c100000, 0x59302009, 0x58101c03, 0x42002000,
10874 0x00000004, 0x0401f008, 0x4c000000, 0x4c0c0000,
10875 0x4c100000, 0x59302009, 0x58101c03, 0x42002000,
10876 0x00000007, 0x480fc857, 0x4813c857, 0x481bc857,
10877 0x0201f800, 0x00103aae, 0x5c002000, 0x5c001800,
10878 0x5c000000, 0x1c01f000, 0x83380580, 0x00000092,
10879 0x02020800, 0x001005d8, 0x42000800, 0x80000040,
10880 0x4a026203, 0x00000001, 0x493a6403, 0x0201f000,
10881 0x00020721, 0x4d400000, 0x0201f800, 0x00103b25,
10882 0x04000008, 0x59a80005, 0x84000544, 0x48035005,
10883 0x42028000, 0x0000002a, 0x0201f800, 0x0010a449,
10884 0x5c028000, 0x1c01f000, 0x59a80026, 0x8c000508,
10885 0x04000005, 0x599c0017, 0x8c00050a, 0x04020002,
10886 0x1c01f000, 0x82000540, 0x00000001, 0x1c01f000,
10887 0x59300420, 0x84000540, 0x48026420, 0x1c01f000,
10888 0x4817c857, 0x4c000000, 0x4c040000, 0x8c142d2a,
10889 0x04000004, 0x598800b8, 0x80000000, 0x480310b8,
10890 0x8c142d2e, 0x04000004, 0x598800b9, 0x80000000,
10891 0x480310b9, 0x8c142d2c, 0x04000013, 0x40140000,
10892 0x82000500, 0x00070000, 0x82000d80, 0x00030000,
10893 0x0400000d, 0x82000d80, 0x00040000, 0x0400000a,
10894 0x82000d80, 0x00050000, 0x04000007, 0x59880005,
10895 0x80000000, 0x48031005, 0x598800ba, 0x80000000,
10896 0x480310ba, 0x5c000800, 0x5c000000, 0x1c01f000,
10897 0x4817c857, 0x4c000000, 0x4c040000, 0x8c142d2a,
10898 0x04000004, 0x598800bb, 0x80000000, 0x480310bb,
10899 0x8c142d2e, 0x04000004, 0x598800bc, 0x80000000,
10900 0x480310bc, 0x8c142d2c, 0x04000013, 0x40140000,
10901 0x82000500, 0x00070000, 0x82000d80, 0x00030000,
10902 0x0400000d, 0x82000d80, 0x00040000, 0x0400000a,
10903 0x82000d80, 0x00050000, 0x04000007, 0x59880005,
10904 0x80000000, 0x48031005, 0x598800bd, 0x80000000,
10905 0x480310bd, 0x5c000800, 0x5c000000, 0x1c01f000,
10906 0x4c000000, 0x59880001, 0x80000000, 0x4803c857,
10907 0x48031001, 0x5c000000, 0x1c01f000, 0x4c000000,
10908 0x59880000, 0x80000000, 0x4803c857, 0x48031000,
10909 0x5c000000, 0x1c01f000, 0x4c000000, 0x59880002,
10910 0x80000000, 0x4803c857, 0x48031002, 0x5c000000,
10911 0x1c01f000, 0x4807c857, 0x4c000000, 0x8c040d2c,
10912 0x04000004, 0x598800a6, 0x80000000, 0x480310a6,
10913 0x8c040d2a, 0x04000004, 0x598800a7, 0x80000000,
10914 0x480310a7, 0x8c040d28, 0x04000004, 0x598800a8,
10915 0x80000000, 0x480310a8, 0x8c040d26, 0x04000004,
10916 0x598800a9, 0x80000000, 0x480310a9, 0x8c040d24,
10917 0x04000004, 0x598800aa, 0x80000000, 0x480310aa,
10918 0x8c040d22, 0x04000004, 0x598800ab, 0x80000000,
10919 0x480310ab, 0x8c040d20, 0x04000004, 0x598800ac,
10920 0x80000000, 0x480310ac, 0x5c000000, 0x1c01f000,
10921 0x4807c857, 0x4c000000, 0x598800ad, 0x80000000,
10922 0x480310ad, 0x5c000000, 0x1c01f000, 0x4807c857,
10923 0x4c000000, 0x8c040d1c, 0x04000004, 0x598800ae,
10924 0x80000000, 0x480310ae, 0x8c040d1a, 0x04000004,
10925 0x598800af, 0x80000000, 0x480310af, 0x5c000000,
10926 0x1c01f000, 0x4807c857, 0x4c000000, 0x8c040d18,
10927 0x04000004, 0x598800b0, 0x80000000, 0x480310b0,
10928 0x8c040d16, 0x04000004, 0x598800b1, 0x80000000,
10929 0x480310b1, 0x8c040d14, 0x04000004, 0x598800b2,
10930 0x80000000, 0x480310b2, 0x5c000000, 0x1c01f000,
10931 0x4807c857, 0x4c000000, 0x8c040d10, 0x04000004,
10932 0x598800b3, 0x80000000, 0x480310b3, 0x8c040d0c,
10933 0x04000004, 0x598800b4, 0x80000000, 0x480310b4,
10934 0x5c000000, 0x1c01f000, 0x4807c857, 0x4c000000,
10935 0x8c040d08, 0x04000004, 0x598800b5, 0x80000000,
10936 0x480310b5, 0x8c040d04, 0x04000004, 0x598800b6,
10937 0x80000000, 0x480310b6, 0x5c000000, 0x1c01f000,
10938 0x4807c856, 0x4c000000, 0x5988007f, 0x80000000,
10939 0x4803107f, 0x5c000000, 0x1c01f000, 0x4803c857,
10940 0x4c040000, 0x50000800, 0x80040800, 0x4807c857,
10941 0x44040000, 0x5c000800, 0x1c01f000, 0x480fc857,
10942 0x4c000000, 0x820c0580, 0x00000000, 0x04020004,
10943 0x42000000, 0x0010b819, 0x0401f014, 0x820c0580,
10944 0x00001001, 0x04020004, 0x42000000, 0x0010b81a,
10945 0x0401f00e, 0x820c0580, 0x00001002, 0x04020004,
10946 0x42000000, 0x0010b81b, 0x0401f008, 0x820c0c80,
10947 0x0000201c, 0x02021800, 0x001005d8, 0x820c0500,
10948 0x0000001f, 0x0c01f804, 0x0401ffdd, 0x5c000000,
10949 0x1c01f000, 0x0010aa89, 0x0010aa8c, 0x0010aa8f,
10950 0x0010aa92, 0x0010aa95, 0x0010aa98, 0x0010aa9b,
10951 0x0010aa9e, 0x0010aaa1, 0x0010aaa4, 0x0010aaa7,
10952 0x0010aaaa, 0x0010aaad, 0x0010aab0, 0x0010aab3,
10953 0x0010aab6, 0x0010aab9, 0x0010aabc, 0x0010aabf,
10954 0x0010aac2, 0x0010aac5, 0x0010aac8, 0x0010aacb,
10955 0x0010aace, 0x0010aad1, 0x0010aad4, 0x0010aad7,
10956 0x0010aada, 0x42000000, 0x0010b81c, 0x1c01f000,
10957 0x42000000, 0x0010b81d, 0x1c01f000, 0x42000000,
10958 0x0010b81e, 0x1c01f000, 0x42000000, 0x0010b81f,
10959 0x1c01f000, 0x42000000, 0x0010b820, 0x1c01f000,
10960 0x42000000, 0x0010b821, 0x1c01f000, 0x42000000,
10961 0x0010b822, 0x1c01f000, 0x42000000, 0x0010b823,
10962 0x1c01f000, 0x42000000, 0x0010b824, 0x1c01f000,
10963 0x42000000, 0x0010b825, 0x1c01f000, 0x42000000,
10964 0x0010b826, 0x1c01f000, 0x42000000, 0x0010b827,
10965 0x1c01f000, 0x42000000, 0x0010b828, 0x1c01f000,
10966 0x42000000, 0x0010b829, 0x1c01f000, 0x42000000,
10967 0x0010b82a, 0x1c01f000, 0x42000000, 0x0010b82b,
10968 0x1c01f000, 0x42000000, 0x0010b82c, 0x1c01f000,
10969 0x42000000, 0x0010b82d, 0x1c01f000, 0x42000000,
10970 0x0010b82e, 0x1c01f000, 0x42000000, 0x0010b82f,
10971 0x1c01f000, 0x42000000, 0x0010b830, 0x1c01f000,
10972 0x42000000, 0x0010b831, 0x1c01f000, 0x42000000,
10973 0x0010b832, 0x1c01f000, 0x42000000, 0x0010b833,
10974 0x1c01f000, 0x42000000, 0x0010b834, 0x1c01f000,
10975 0x42000000, 0x0010b835, 0x1c01f000, 0x42000000,
10976 0x0010b836, 0x1c01f000, 0x42000000, 0x0010b837,
10977 0x1c01f000, 0x480fc857, 0x4c000000, 0x820c0580,
10978 0x00000001, 0x04020004, 0x42000000, 0x0010b80e,
10979 0x0401f012, 0x820c0580, 0x00000002, 0x04020004,
10980 0x42000000, 0x0010b80f, 0x0401f00c, 0x820c0580,
10981 0x00000003, 0x04020004, 0x42000000, 0x0010b810,
10982 0x0401f006, 0x820c0580, 0x00000004, 0x04020004,
10983 0x42000000, 0x0010b811, 0x0401ff51, 0x5c000000,
10984 0x1c01f000, 0x4c000000, 0x59a80026, 0x4803c857,
10985 0x8c000502, 0x04000010, 0x8c000506, 0x04000004,
10986 0x42000000, 0x0010b841, 0x0401f012, 0x8c00050a,
10987 0x04000004, 0x42000000, 0x0010b840, 0x0401f00d,
10988 0x8c000508, 0x04000004, 0x42000000, 0x0010b843,
10989 0x0401f008, 0x0201f800, 0x0010513b, 0x04000006,
10990 0x8c000506, 0x04020004, 0x42000000, 0x0010b842,
10991 0x0401ff33, 0x5c000000, 0x1c01f000, 0x8058b1c0,
10992 0x02000800, 0x001005d8, 0x5450a800, 0x8050a000,
10993 0x8054a800, 0x8058b040, 0x040207fc, 0x1c01f000,
10994 0x8058b1c0, 0x02000800, 0x001005d8, 0x4450a800,
10995 0x8054a800, 0x8058b040, 0x040207fd, 0x1c01f000,
10996 0x8058b1c0, 0x02000800, 0x001005d8, 0x50500000,
10997 0x9c0001c0, 0x4400a800, 0x8050a000, 0x8054a800,
10998 0x8058b040, 0x040207fa, 0x1c01f000, 0x4c000000,
10999 0x59a80008, 0x8c00051c, 0x5c000000, 0x1c01f000,
11000 0x00000001, 0x00000002, 0x00000004, 0x00000008,
11001 0x00000010, 0x00000020, 0x00000040, 0x00000080,
11002 0x00000100, 0x00000200, 0x00000400, 0x00000800,
11003 0x00001000, 0x00002000, 0x00004000, 0x00008000,
11004 0x00010000, 0xa5f2b3ac
11005};
11006
11007#ifdef UNIQUE_FW_NAME
11008uint32_t fw2400_length01 = 0x0000ab4a ;
11009#else
11010uint32_t risc_code_length01 = 0x0000ab4a ;
11011#endif
11012
11013
11014#ifdef UNIQUE_FW_NAME
11015uint32_t fw2400_addr02 = 0x0010e000 ;
11016#else
11017uint32_t risc_code_addr02 = 0x0010e000 ;
11018#endif
11019
11020#ifdef UNIQUE_FW_NAME
11021uint32_t fw2400_code02[] = {
11022#else
11023uint32_t risc_code02[] = {
11024#endif
11025 0x00000000, 0x00000000, 0x0010e000, 0x000014ff,
11026 0x00000000, 0x00000000, 0x00020000, 0x000008c0,
11027 0x836c0580, 0x00000003, 0x02020000, 0x001002e3,
11028 0x42000000, 0x0010b4bb, 0x50000000, 0x800001c0,
11029 0x04020956, 0x0401f923, 0x0401fbe3, 0x0401fb5c,
11030 0x0201f800, 0x00020718, 0x0201f800, 0x0002057b,
11031 0x0401f7f0, 0x59b800ea, 0x82000d00, 0xf0000038,
11032 0x02020000, 0x00100a7a, 0x8c000510, 0x02000000,
11033 0x00100a79, 0x59ba60e0, 0x81300182, 0x0402104e,
11034 0x04002030, 0x8532653e, 0x59300406, 0x82000580,
11035 0x00000003, 0x04020028, 0x59300203, 0x82000580,
11036 0x00000004, 0x04020024, 0x59325808, 0x59300402,
11037 0x4a025a04, 0x00000103, 0x900001c0, 0x48025806,
11038 0x497a5807, 0x497a5c09, 0x5930001f, 0x80000540,
11039 0x02020800, 0x00100d56, 0x59300004, 0x8c00053e,
11040 0x04020010, 0x0401fa88, 0x59326809, 0x0201f800,
11041 0x0002077d, 0x5934000f, 0x5934140b, 0x80081040,
11042 0x04001002, 0x480a6c0b, 0x80000540, 0x04020a10,
11043 0x59b800ea, 0x8c000510, 0x040207d7, 0x1c01f000,
11044 0x0201f800, 0x00106f60, 0x040007ef, 0x0201f000,
11045 0x00100a65, 0x42027000, 0x00000055, 0x0401f027,
11046 0x83326500, 0x3fffffff, 0x59300406, 0x82000580,
11047 0x00000003, 0x04020015, 0x59325808, 0x59326809,
11048 0x59301402, 0x4a025a04, 0x00000103, 0x900811c0,
11049 0x480a5806, 0x497a5c09, 0x497a5807, 0x0401fa62,
11050 0x0201f800, 0x0002077d, 0x5934000f, 0x5934140b,
11051 0x80081040, 0x04001002, 0x480a6c0b, 0x80000540,
11052 0x040209eb, 0x0401f7db, 0x42027000, 0x00000054,
11053 0x0401f00a, 0x83300500, 0x60000000, 0x02000000,
11054 0x00100a68, 0x81326580, 0x8000013a, 0x82000400,
11055 0x00100a80, 0x50027000, 0x59300c06, 0x82040580,
11056 0x00000002, 0x02000000, 0x00100a65, 0x59300004,
11057 0x8c00053e, 0x04020004, 0x0201f800, 0x000207a1,
11058 0x0401f7c4, 0x0201f800, 0x00106f60, 0x040007fb,
11059 0x0201f000, 0x00100a65, 0x59325808, 0x412c7000,
11060 0x58380a04, 0x82040500, 0x0000000f, 0x82000c00,
11061 0x001010bd, 0x50044000, 0x0c01f001, 0x00100dd9,
11062 0x00100dd9, 0x0002009f, 0x00100dd9, 0x00100dd9,
11063 0x00100dd9, 0x00100dd9, 0x00100dd9, 0x000200af,
11064 0x00100ded, 0x00100dd9, 0x00100dd9, 0x00100ddb,
11065 0x00100dd9, 0x00100dd9, 0x00100dd9, 0x5838040a,
11066 0x8c000500, 0x02000800, 0x001005d8, 0x50200000,
11067 0x80387c00, 0x583c1002, 0x583c2800, 0x583c2001,
11068 0x58380a07, 0x5838300f, 0x59303807, 0x58384c08,
11069 0x5838000d, 0x48026012, 0x0401f010, 0x5838020a,
11070 0x8c000502, 0x02000000, 0x00100dd9, 0x50200000,
11071 0x80387c00, 0x583c2800, 0x583c2001, 0x583c1002,
11072 0x592c0a07, 0x592c4c08, 0x592c300f, 0x59303807,
11073 0x497a6012, 0x497a6013, 0x4816600e, 0x4812600f,
11074 0x480a6010, 0x481a6011, 0x80040840, 0x4806600d,
11075 0x02020000, 0x00100e1a, 0x841c3d40, 0x481e6007,
11076 0x1c01f000, 0x41787800, 0x59325808, 0x592c0c0a,
11077 0x8c040d02, 0x02000000, 0x00100f8c, 0x592c000d,
11078 0x592c100f, 0x592c0a04, 0x480a6011, 0x48026012,
11079 0x48026013, 0x412c3000, 0x82040500, 0x0000000f,
11080 0x82000400, 0x001010bd, 0x50003800, 0x501c0000,
11081 0x401c1000, 0x592c1a07, 0x4802600a, 0x481a600b,
11082 0x480a600c, 0x480e600d, 0x843c7d4a, 0x403c1000,
11083 0x1c01f000, 0x41787800, 0x497a6012, 0x592c0a04,
11084 0x412c3000, 0x592c1a07, 0x82040500, 0x0000000f,
11085 0x82000400, 0x001010bd, 0x50004000, 0x50200000,
11086 0x40201000, 0x4802600a, 0x481a600b, 0x480a600c,
11087 0x480e600d, 0x80000580, 0x483e6004, 0x1c01f000,
11088 0x4c000000, 0x4df00000, 0x0201f800, 0x00020729,
11089 0x0401f005, 0x4c000000, 0x4df00000, 0x0401ff16,
11090 0x0401f001, 0x5c03e000, 0x5c000000, 0x1801f000,
11091 0x4203e000, 0xb0100000, 0x41fc0000, 0x82000500,
11092 0x00000011, 0x0c01f001, 0x0002012a, 0x00020697,
11093 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a,
11094 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a,
11095 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a,
11096 0x0002012a, 0x0002012a, 0x0010115a, 0x0002012c,
11097 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a,
11098 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a,
11099 0x0002012a, 0x0002012a, 0x0002012a, 0x0002012a,
11100 0x0002012a, 0x0002012a, 0x0201f800, 0x001005d8,
11101 0x0201f800, 0x00020697, 0x0201f000, 0x0010115a,
11102 0x42000000, 0x0010b4c1, 0x50000000, 0x8c000504,
11103 0x04000014, 0x42000000, 0x0010b4c1, 0x50000000,
11104 0x8c000502, 0x04020002, 0x1c01f000, 0x4df00000,
11105 0x4203e000, 0x50000000, 0x42034000, 0x0010b4a4,
11106 0x59a0001d, 0x59a1d81e, 0x84000502, 0x4803401d,
11107 0x58ec0009, 0x0801f800, 0x5c03e000, 0x1c01f000,
11108 0x04027002, 0x04026002, 0x1c01f000, 0x4df00000,
11109 0x4203e000, 0x50000000, 0x0201f800, 0x001007e4,
11110 0x04000010, 0x412dd800, 0x48efc857, 0x0201f800,
11111 0x00103b28, 0x42034000, 0x0010b4a4, 0x49a1d80b,
11112 0x48ef401e, 0x59a0001d, 0x84000544, 0x4803401d,
11113 0x0201f800, 0x00102214, 0x0201f800, 0x00102233,
11114 0x5c03e000, 0x1c01f000, 0x4da00000, 0x4df00000,
11115 0x4203e000, 0x50000000, 0x04006051, 0x40001000,
11116 0x42034000, 0x0010b4a4, 0x59a01818, 0x800c19c0,
11117 0x04020008, 0x59a0381b, 0x801c39c0, 0x02000800,
11118 0x001005d8, 0x59a0041c, 0x801c3c00, 0x0401f00c,
11119 0x59a00419, 0x82000400, 0x00000002, 0x48034419,
11120 0x82000c80, 0x00000013, 0x04001003, 0x497b4419,
11121 0x41780000, 0x59a03816, 0x801c3c00, 0x80081040,
11122 0x480b4017, 0x581c0200, 0x4803c021, 0x581c0401,
11123 0x4803c022, 0x581c0201, 0x4803c023, 0x581c0400,
11124 0x4803c020, 0x900001c0, 0x82000540, 0x00000012,
11125 0x4803c011, 0x59e00017, 0x8c000508, 0x04000003,
11126 0x4a03c017, 0x00000002, 0x4203e000, 0x30000001,
11127 0x800c19c0, 0x04000007, 0x800c1840, 0x480f4018,
11128 0x0402001f, 0x497b4419, 0x497b4219, 0x0401f01c,
11129 0x800811c0, 0x0402000b, 0x4d2c0000, 0x59a2581b,
11130 0x0201f800, 0x001007f4, 0x5c025800, 0x497b401b,
11131 0x497b401a, 0x497b441c, 0x497b421c, 0x0401f010,
11132 0x59a0041c, 0x82000400, 0x00000002, 0x82000c80,
11133 0x00000012, 0x4803441c, 0x04001009, 0x4d2c0000,
11134 0x59a2581b, 0x592c3813, 0x481f401b, 0x497b441c,
11135 0x0201f800, 0x001007f4, 0x5c025800, 0x5c03e000,
11136 0x5c034000, 0x1c01f000, 0x59a80005, 0x82000500,
11137 0x00000003, 0x02020000, 0x00104315, 0x59340400,
11138 0x82000580, 0x00000606, 0x02020000, 0x001042e6,
11139 0x5934000d, 0x80027d40, 0x02020000, 0x00104321,
11140 0x0401f803, 0x80000580, 0x1c01f000, 0x5934000f,
11141 0x59341203, 0x80080540, 0x0402006f, 0x5934020b,
11142 0x5934140b, 0x80080480, 0x0402106b, 0x0201f800,
11143 0x0002075a, 0x04000064, 0x80081000, 0x592c0406,
11144 0x480a6c0b, 0x49366009, 0x492e6008, 0x4a026406,
11145 0x00000003, 0x4a026403, 0x00000040, 0x800000c2,
11146 0x800018c4, 0x800c0400, 0x48026206, 0x592c0808,
11147 0x592c1809, 0x592c020a, 0x48066017, 0x480e6018,
11148 0x8c000502, 0x04000030, 0x4a026203, 0x00000004,
11149 0x592c0207, 0x80000040, 0x04020020, 0x59a80005,
11150 0x8c000514, 0x42000000, 0x00000055, 0x04020003,
11151 0x42000000, 0x00000033, 0x80000040, 0x040207ff,
11152 0x592c0204, 0x82000500, 0x000000ff, 0x82000580,
11153 0x00000018, 0x04020011, 0x592c180f, 0x59300007,
11154 0x82000540, 0x00000091, 0x480e6011, 0x48026007,
11155 0x42000000, 0x80000004, 0x48026004, 0x59bc00ea,
11156 0x8c000516, 0x040207fe, 0x83300400, 0x20000000,
11157 0x480378e1, 0x1c01f000, 0x0401fe78, 0x59300007,
11158 0x8400054e, 0x48026007, 0x592c1a04, 0x820c1d00,
11159 0x000000ff, 0x820c0580, 0x00000048, 0x04000017,
11160 0x0401f7ec, 0x8c000500, 0x04020ecb, 0x4a026203,
11161 0x00000002, 0x59a80805, 0x82040500, 0x00000600,
11162 0x04020012, 0x42000000, 0x00000030, 0x80000040,
11163 0x040207ff, 0x592c1a04, 0x820c1d00, 0x000000ff,
11164 0x820c0580, 0x00000018, 0x040007da, 0x820c0580,
11165 0x00000048, 0x040207d7, 0x42000800, 0x80000804,
11166 0x0201f000, 0x00106721, 0x8c040d12, 0x42000000,
11167 0x00000010, 0x040207ee, 0x42000000, 0x00000051,
11168 0x0401f7eb, 0x800811c0, 0x04020003, 0x4a026a03,
11169 0x00000001, 0x59340010, 0x492e6810, 0x80000d40,
11170 0x04020003, 0x492e680f, 0x1c01f000, 0x492c0800,
11171 0x1c01f000, 0x83440c80, 0x00000800, 0x04021009,
11172 0x83440400, 0x0010ac00, 0x50000000, 0x80000540,
11173 0x04000004, 0x40026800, 0x80000580, 0x1c01f000,
11174 0x82000540, 0x00000001, 0x1c01f000, 0x59340203,
11175 0x80000540, 0x0402004b, 0x4d300000, 0x4d2c0000,
11176 0x5934000f, 0x80025d40, 0x04000044, 0x0201f800,
11177 0x0002075a, 0x0400003f, 0x592c0000, 0x4802680f,
11178 0x80000540, 0x04020002, 0x48026810, 0x592c2a04,
11179 0x80081000, 0x480a6c0b, 0x49366009, 0x492e6008,
11180 0x82142d00, 0x000000ff, 0x82140580, 0x00000012,
11181 0x04000035, 0x4a026406, 0x00000003, 0x4a026403,
11182 0x00000040, 0x592c0406, 0x800000c2, 0x800018c4,
11183 0x800c0400, 0x48026206, 0x592c0808, 0x592c1809,
11184 0x592c020a, 0x48066017, 0x480e6018, 0x8c000502,
11185 0x02000000, 0x0010474d, 0x4a026203, 0x00000004,
11186 0x592c0207, 0x80000040, 0x02020000, 0x00104740,
11187 0x82140580, 0x00000018, 0x02020000, 0x00104740,
11188 0x592c180f, 0x59300007, 0x82000540, 0x00000091,
11189 0x480e6011, 0x48026007, 0x42000000, 0x80000004,
11190 0x48026004, 0x59bc00ea, 0x8c000516, 0x040207fe,
11191 0x83300400, 0x20000000, 0x480378e1, 0x5934020b,
11192 0x5934140b, 0x80080480, 0x040017be, 0x0401f003,
11193 0x4a026a03, 0x00000001, 0x5c025800, 0x5c026000,
11194 0x1c01f000, 0x497a5800, 0x49325809, 0x4a026406,
11195 0x00000006, 0x4a026203, 0x00000007, 0x0401f802,
11196 0x0401f7ef, 0x59a80021, 0x800001c0, 0x02020000,
11197 0x0010476f, 0x59a80005, 0x8c000504, 0x02020000,
11198 0x0010476b, 0x59340200, 0x8c000518, 0x02020000,
11199 0x00104767, 0x592c0a0c, 0x48066202, 0x4a025a06,
11200 0x00000000, 0x8c000508, 0x02020000, 0x00104763,
11201 0x4d3c0000, 0x417a7800, 0x0401fbdf, 0x5c027800,
11202 0x1c01f000, 0x592c0404, 0x8c00051e, 0x02020000,
11203 0x00104ce4, 0x59980022, 0x80000540, 0x04000017,
11204 0x592c0a06, 0x592c0409, 0x80040540, 0x04020013,
11205 0x0201f000, 0x00104cfa, 0x592c0404, 0x8c00051e,
11206 0x02020000, 0x00104cf3, 0x59980022, 0x80000540,
11207 0x0400000a, 0x82040580, 0x00000001, 0x04020007,
11208 0x0201f000, 0x00104cfa, 0x592c0404, 0x8c00051e,
11209 0x02020000, 0x00104dca, 0x59980026, 0x497a5800,
11210 0x80000540, 0x02020000, 0x00104e1d, 0x59d80105,
11211 0x82000d00, 0x00018780, 0x02020000, 0x00104edb,
11212 0x80000106, 0x82000500, 0x00000003, 0x0c01f001,
11213 0x000202f0, 0x00104e1d, 0x000202f6, 0x00020341,
11214 0x592c0001, 0x492fb107, 0x80000d40, 0x02020000,
11215 0x00104ddb, 0x1c01f000, 0x592c0001, 0x492fb107,
11216 0x80000d40, 0x02020000, 0x00104de8, 0x59da5908,
11217 0x835c0480, 0x00000020, 0x0400102c, 0x0402b034,
11218 0x492fb007, 0x0400e7fa, 0x59d80105, 0x82000500,
11219 0x00018780, 0x02020000, 0x00104edb, 0x0400601f,
11220 0x59d8010a, 0x59d8090a, 0x80040580, 0x040207fd,
11221 0x800408e0, 0x599c1017, 0x8c081508, 0x04020028,
11222 0x82040d40, 0x00000013, 0x5998002b, 0x4807c011,
11223 0x84000500, 0x4803302b, 0x59e00017, 0x8c000508,
11224 0x04020004, 0x4203e000, 0x30000001, 0x1c01f000,
11225 0x4a03c017, 0x00000003, 0x82040500, 0x000000ff,
11226 0x82000580, 0x0000001d, 0x040207f7, 0x4a03c017,
11227 0x0000000d, 0x0401f7f4, 0x5998082b, 0x84040d40,
11228 0x4807302b, 0x1c01f000, 0x496a5800, 0x412ed000,
11229 0x815eb800, 0x59c80000, 0x82000540, 0x00001200,
11230 0x48039000, 0x0400e7ca, 0x0401f7d0, 0x0402f7f7,
11231 0x492fa807, 0x0400e7c6, 0x0401f7cc, 0x59e0000f,
11232 0x59e0100f, 0x80081580, 0x040207fd, 0x81281580,
11233 0x040007d4, 0x40025000, 0x82040d40, 0x0000001d,
11234 0x0401f7d2, 0x59d80908, 0x45680800, 0x4006d000,
11235 0x815eb800, 0x0400e7fc, 0x59c80000, 0x82000540,
11236 0x00001200, 0x48039000, 0x02006000, 0x00104df8,
11237 0x59d8010a, 0x59d8090a, 0x80040d80, 0x040207fd,
11238 0x900001c0, 0x82000540, 0x00000013, 0x4803c011,
11239 0x5998002b, 0x84000500, 0x4803302b, 0x59e00017,
11240 0x8c000508, 0x04000003, 0x4a03c017, 0x00000003,
11241 0x4203e000, 0x30000001, 0x59d80105, 0x82000500,
11242 0x00018780, 0x02020000, 0x00104edb, 0x0202d000,
11243 0x00104dfd, 0x592c0001, 0x492fb107, 0x80000d40,
11244 0x02020000, 0x00104e10, 0x1c01f000, 0x59980020,
11245 0x0c01f001, 0x00020370, 0x00020371, 0x00104e88,
11246 0x1c01f000, 0x4df00000, 0x4203e000, 0x50000000,
11247 0x0402681e, 0x04006004, 0x599c0017, 0x8c000508,
11248 0x04020865, 0x59980029, 0x80025d40, 0x0400000a,
11249 0x0402d00b, 0x59980026, 0x80000040, 0x48033026,
11250 0x592c0000, 0x492fb107, 0x48033029, 0x04020002,
11251 0x48033028, 0x5c03e000, 0x1c01f000, 0x59d80105,
11252 0x82000500, 0x00018780, 0x02020000, 0x00104edb,
11253 0x42000000, 0x0010b855, 0x0201f800, 0x0010aa47,
11254 0x5c03e000, 0x1c01f000, 0x5998002b, 0x8c000500,
11255 0x0402003b, 0x0400e007, 0x59d80105, 0x82000500,
11256 0x00018780, 0x02020000, 0x00104edb, 0x1c01f000,
11257 0x59da5908, 0x835c0c80, 0x00000020, 0x04001003,
11258 0x0400b029, 0x0400f02b, 0x496a5800, 0x412ed000,
11259 0x815eb800, 0x59c80000, 0x82000540, 0x00001200,
11260 0x48039000, 0x0400e7f3, 0x59d8010a, 0x59d8090a,
11261 0x80040580, 0x040207fd, 0x800408e0, 0x599c1017,
11262 0x8c081508, 0x04020022, 0x82040d40, 0x00000013,
11263 0x4807c011, 0x59e00017, 0x8c000508, 0x0400000a,
11264 0x4a03c017, 0x00000003, 0x82040500, 0x000000ff,
11265 0x82000580, 0x0000001d, 0x04020003, 0x4a03c017,
11266 0x0000000d, 0x4203e000, 0x30000001, 0x59d80105,
11267 0x82000500, 0x00018780, 0x02020000, 0x00104edb,
11268 0x1c01f000, 0x492fb007, 0x0400e7d2, 0x0401f7df,
11269 0x492fa807, 0x0400e7cf, 0x0401f7dc, 0x84000500,
11270 0x4803302b, 0x0400e7cb, 0x0401f7d8, 0x59e0000f,
11271 0x59e0100f, 0x80081580, 0x040207fd, 0x81281580,
11272 0x040007da, 0x40025000, 0x82040d40, 0x0000001d,
11273 0x0401f7d8, 0x59e0000f, 0x59e0100f, 0x80080d80,
11274 0x040207fd, 0x81280580, 0x04020002, 0x1c01f000,
11275 0x400a5000, 0x900811c0, 0x82081540, 0x0000001c,
11276 0x480bc011, 0x59e00017, 0x8c000508, 0x04000003,
11277 0x4a03c017, 0x0000000c, 0x4203e000, 0x30000001,
11278 0x1c01f000, 0x41700000, 0x0c01f001, 0x00105420,
11279 0x000203fc, 0x00105420, 0x00105421, 0x0010541e,
11280 0x0010541e, 0x0010541e, 0x0010541e, 0x001058b0,
11281 0x04010037, 0x59980006, 0x80000540, 0x0402003c,
11282 0x0402c01c, 0x4202f800, 0x00000010, 0x4df00000,
11283 0x4203e000, 0x50000000, 0x49db3005, 0x59da5808,
11284 0x592c0204, 0x497a5800, 0x497a5801, 0x82000500,
11285 0x000000ff, 0x82000c80, 0x00000079, 0x04021036,
11286 0x0c01f839, 0x5c03e000, 0x817ef840, 0x04000009,
11287 0x836c0580, 0x00000003, 0x04020006, 0x83700580,
11288 0x00000001, 0x04020010, 0x0401001b, 0x0400c7e8,
11289 0x0400f94a, 0x0400b134, 0x59d40005, 0x82000500,
11290 0x43018780, 0x02020000, 0x0010583f, 0x59d80005,
11291 0x82000500, 0x43018780, 0x02020000, 0x00105846,
11292 0x1c01f000, 0x83700580, 0x00000003, 0x02000800,
11293 0x00105421, 0x83700580, 0x00000001, 0x040207ed,
11294 0x04010005, 0x0400c7d2, 0x0401f7ea, 0x4202f800,
11295 0x00000010, 0x4df00000, 0x4203e000, 0x50000000,
11296 0x49d73005, 0x59d65808, 0x0401f7ce, 0x4df00000,
11297 0x4203e000, 0x50000000, 0x40025800, 0x592c0204,
11298 0x497b3005, 0x497b3006, 0x4202f800, 0x00000010,
11299 0x0401f7c7, 0x0201f800, 0x00105491, 0x5c03e000,
11300 0x0401f7d4, 0x00105491, 0x00105491, 0x00105491,
11301 0x00105491, 0x00105527, 0x00105491, 0x00105491,
11302 0x00105491, 0x00105491, 0x00105491, 0x001054a1,
11303 0x00105491, 0x00105491, 0x00105491, 0x00105551,
11304 0x00105491, 0x00105491, 0x00105491, 0x000204ef,
11305 0x00105491, 0x001056b4, 0x00105491, 0x00105491,
11306 0x00105491, 0x000204c2, 0x00105491, 0x00105491,
11307 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11308 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11309 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11310 0x00105491, 0x00105491, 0x001054c9, 0x00105491,
11311 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11312 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11313 0x001057d3, 0x00105491, 0x00105491, 0x00105491,
11314 0x00105491, 0x00105491, 0x0010581e, 0x00105491,
11315 0x001054bb, 0x00105491, 0x00105797, 0x00105491,
11316 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11317 0x00105491, 0x00105491, 0x00105765, 0x00105491,
11318 0x00105765, 0x00105872, 0x00105491, 0x00105491,
11319 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11320 0x00105491, 0x00105491, 0x00105491, 0x00105725,
11321 0x00105855, 0x00105491, 0x00105865, 0x00105491,
11322 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11323 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11324 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11325 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11326 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11327 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11328 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11329 0x00105491, 0x00105491, 0x00105491, 0x00105491,
11330 0x00105491, 0x00105491, 0x592c0204, 0x80000110,
11331 0x02000000, 0x00105499, 0x80000040, 0x04000009,
11332 0x48033002, 0x492f3003, 0x492f3004, 0x4a033008,
11333 0x000204d0, 0x4202e000, 0x00000003, 0x1c01f000,
11334 0x592c0406, 0x82000c80, 0x0000199a, 0x02021000,
11335 0x001054a9, 0x59a80021, 0x80000540, 0x02020000,
11336 0x001054d7, 0x592e8a06, 0x83440c80, 0x000007f0,
11337 0x02021000, 0x001054a9, 0x83440400, 0x0010ac00,
11338 0x50000000, 0x80026d40, 0x02000000, 0x001054db,
11339 0x59340002, 0x592c0810, 0x80040580, 0x82000500,
11340 0x00ffffff, 0x02020000, 0x001054a9, 0x0401fccf,
11341 0x02020000, 0x001054de, 0x1c01f000, 0x592c0204,
11342 0x80000110, 0x02000000, 0x00105499, 0x80000040,
11343 0x0402000b, 0x592c040a, 0x8c000504, 0x04000010,
11344 0x592c0207, 0x82000c80, 0x00001001, 0x02021000,
11345 0x001054a9, 0x0201f000, 0x0010588a, 0x48033002,
11346 0x492f3003, 0x492f3004, 0x4a033008, 0x00020507,
11347 0x4202e000, 0x00000003, 0x1c01f000, 0x592c0406,
11348 0x82000c80, 0x0000199a, 0x02021000, 0x001054a9,
11349 0x592e8a06, 0x417a7800, 0x0401fd37, 0x02020000,
11350 0x00105658, 0x59340002, 0x592c0808, 0x80040580,
11351 0x82000500, 0x00ffffff, 0x02020000, 0x001054a9,
11352 0x497a5808, 0x592e6009, 0x83300580, 0xffffffff,
11353 0x02000000, 0x00105618, 0x83300480, 0x0010d1c0,
11354 0x02001000, 0x00105675, 0x59a8000b, 0x81300480,
11355 0x02021000, 0x00105675, 0x592c240a, 0x49366009,
11356 0x8c10251c, 0x02020000, 0x00105606, 0x59a80068,
11357 0x8c000510, 0x02020000, 0x0010568e, 0x59a80821,
11358 0x800409c0, 0x02020000, 0x001055ec, 0x59a80805,
11359 0x8c040d04, 0x02020000, 0x0010567f, 0x59340200,
11360 0x8c000518, 0x02020000, 0x00105670, 0x59300c06,
11361 0x82040580, 0x00000006, 0x02020000, 0x00105610,
11362 0x59300414, 0x8c000516, 0x02020000, 0x0010567a,
11363 0x8c102508, 0x02020000, 0x0010a5b8, 0x59300808,
11364 0x4a025a06, 0x00000000, 0x800409c0, 0x02020000,
11365 0x001055e7, 0x592c0a0c, 0x48066202, 0x492e6008,
11366 0x0401f14d, 0x4df00000, 0x4203e000, 0x50000000,
11367 0x0402b00b, 0x835c0480, 0x00000020, 0x0400100d,
11368 0x815eb840, 0x416a5800, 0x592ed000, 0x492fb007,
11369 0x497a5800, 0x497a5801, 0x0400b7f7, 0x59d80005,
11370 0x82000500, 0x43018780, 0x02020000, 0x00105846,
11371 0x5c03e000, 0x1c01f000, 0x4df00000, 0x4203e000,
11372 0x50000000, 0x0402f00b, 0x835c0480, 0x00000020,
11373 0x0400100d, 0x815eb840, 0x416a5800, 0x592ed000,
11374 0x492fa807, 0x497a5800, 0x497a5801, 0x0400f7f7,
11375 0x59d40005, 0x82000500, 0x43018780, 0x02020000,
11376 0x0010583f, 0x5c03e000, 0x1c01f000, 0x4df00000,
11377 0x4203e000, 0x50000000, 0x59940024, 0x80000540,
11378 0x04000112, 0x4c000000, 0x42000000, 0x00001000,
11379 0x50000000, 0x82000480, 0x24320001, 0x04020015,
11380 0x42000800, 0x00000064, 0x80040840, 0x04000007,
11381 0x4a030000, 0x00000001, 0x40000000, 0x59800000,
11382 0x8c000500, 0x040007f9, 0x04000008, 0x42000800,
11383 0x00007a01, 0x50040000, 0x8c000510, 0x04000003,
11384 0x84000510, 0x44000800, 0x4a030000, 0x00000000,
11385 0x59e00002, 0x8c00051e, 0x0402001b, 0x42000000,
11386 0x00001000, 0x50000000, 0x82000480, 0x24320002,
11387 0x04020015, 0x42000800, 0x00000064, 0x80040840,
11388 0x04000007, 0x4a030000, 0x00000001, 0x40000000,
11389 0x59800000, 0x8c000500, 0x040007f9, 0x04000008,
11390 0x42000800, 0x00007a17, 0x50040000, 0x8c00050e,
11391 0x04020003, 0x8400054e, 0x44000800, 0x4a030000,
11392 0x00000000, 0x5c000000, 0x5994781a, 0x48032825,
11393 0x803c0480, 0x04001004, 0x04000003, 0x4803281a,
11394 0x0401f022, 0x41787800, 0x803c7800, 0x82000400,
11395 0x000003e8, 0x040027fd, 0x4803281a, 0x59a80024,
11396 0x803c1400, 0x480b5024, 0x803c0040, 0x04000002,
11397 0x483fc857, 0x59e40852, 0x59a80025, 0x80040580,
11398 0x04000004, 0x480bc857, 0x59e40052, 0x48035025,
11399 0x59940026, 0x803c0400, 0x48032826, 0x0201f800,
11400 0x00106021, 0x59940000, 0x82000580, 0x00000000,
11401 0x04020006, 0x59940026, 0x48032827, 0x497b2826,
11402 0x4a032800, 0x00000001, 0x4c0c0000, 0x59940007,
11403 0x80000d40, 0x0400001d, 0x59941006, 0x59940025,
11404 0x80081c80, 0x04001004, 0x04000003, 0x480f2806,
11405 0x0401f016, 0x80040840, 0x48072807, 0x82040580,
11406 0x000003e8, 0x04020007, 0x4c040000, 0x4c0c0000,
11407 0x59940008, 0x0801f800, 0x5c001800, 0x5c000800,
11408 0x800409c0, 0x04020004, 0x59940008, 0x0801f800,
11409 0x0401f006, 0x400c0000, 0x820c1c00, 0x0000000a,
11410 0x040027ed, 0x480f2806, 0x5c001800, 0x4d180000,
11411 0x59c40008, 0x8c000534, 0x04020025, 0x417a3000,
11412 0x83947c00, 0x00000009, 0x583c0001, 0x80000d40,
11413 0x04020008, 0x823c7c00, 0x00000003, 0x811a3000,
11414 0x83180580, 0x00000005, 0x040207f8, 0x0401f018,
11415 0x583c1000, 0x59940025, 0x80080480, 0x04001005,
11416 0x04000004, 0x48007800, 0x80000040, 0x04021010,
11417 0x80040840, 0x48047801, 0x04000008, 0x82000400,
11418 0x0000000a, 0x48007800, 0x040027fa, 0x82040500,
11419 0x0000007f, 0x0401f7e8, 0x583c0002, 0x4c3c0000,
11420 0x0801f800, 0x5c007800, 0x0401f7e3, 0x5c023000,
11421 0x59940019, 0x80001540, 0x04000008, 0x04002007,
11422 0x59940025, 0x80080480, 0x497b2819, 0x04001003,
11423 0x04000002, 0x48032819, 0x59940004, 0x80000d40,
11424 0x0400002a, 0x4c040000, 0x5994001c, 0x80000d40,
11425 0x04000013, 0x5994101b, 0x59940025, 0x80080480,
11426 0x04001005, 0x04000004, 0x4803281b, 0x80000040,
11427 0x0402100b, 0x80040840, 0x4807281c, 0x04020004,
11428 0x5994001d, 0x0801f800, 0x0401f005, 0x82000400,
11429 0x0000000a, 0x4803281b, 0x040027f7, 0x5c000800,
11430 0x59941003, 0x59940025, 0x80080480, 0x04001005,
11431 0x04000004, 0x48032803, 0x80000040, 0x0402100b,
11432 0x80040840, 0x48072804, 0x04020004, 0x59940005,
11433 0x0801f800, 0x0401f005, 0x82000400, 0x0000000a,
11434 0x48032803, 0x040027f7, 0x5994001f, 0x80000d40,
11435 0x04000013, 0x5994101e, 0x59940025, 0x80080480,
11436 0x04001005, 0x04000004, 0x4803281e, 0x80000040,
11437 0x0402100b, 0x80040840, 0x4807281f, 0x04020004,
11438 0x59940020, 0x0801f800, 0x0401f005, 0x82000400,
11439 0x00000001, 0x4803281e, 0x040027f7, 0x59940022,
11440 0x80000d40, 0x04000013, 0x59941021, 0x59940025,
11441 0x80080480, 0x04001005, 0x04000004, 0x48032821,
11442 0x80000040, 0x0402100b, 0x80040840, 0x48072822,
11443 0x04020004, 0x59940023, 0x0801f800, 0x0401f005,
11444 0x82000400, 0x0000000a, 0x48032821, 0x040027f7,
11445 0x59940824, 0x59940025, 0x80040480, 0x02001800,
11446 0x001005d8, 0x48032824, 0x59940000, 0x0c01f001,
11447 0x00105fb5, 0x00105fb7, 0x00105fdd, 0x59940024,
11448 0x80000000, 0x48032824, 0x4203e000, 0x70000000,
11449 0x1c01f000, 0x592c0406, 0x800000c2, 0x800008c4,
11450 0x80040c00, 0x592c040a, 0x48066206, 0x82000d00,
11451 0x00000003, 0x02000000, 0x0010615e, 0x8c000500,
11452 0x04020029, 0x8c00051e, 0x02000000, 0x00106139,
11453 0x82000d00, 0x000000c0, 0x02020000, 0x0010612f,
11454 0x82000d00, 0x00002020, 0x02020000, 0x0010612c,
11455 0x813e79c0, 0x02020000, 0x0010612c, 0x592c0c0c,
11456 0x800409c0, 0x02020000, 0x0010612c, 0x59300a03,
11457 0x82040d80, 0x00000007, 0x02020000, 0x0010612c,
11458 0x4a026203, 0x00000003, 0x4a026403, 0x00000043,
11459 0x0201f800, 0x000200c9, 0x82080d40, 0x80003465,
11460 0x48066004, 0x497a6000, 0x59bc00ea, 0x8c000516,
11461 0x040207fe, 0x83300400, 0xa0000000, 0x480378e1,
11462 0x1c01f000, 0x8c000502, 0x02020000, 0x00106181,
11463 0x8c00051e, 0x0400000e, 0x82000d00, 0x000000c0,
11464 0x04000005, 0x82040d80, 0x000000c0, 0x02020000,
11465 0x00106186, 0x82000d00, 0x00002020, 0x82040d80,
11466 0x00002020, 0x02000000, 0x0010614d, 0x592c0207,
11467 0x80000040, 0x02020000, 0x00106157, 0x592c180d,
11468 0x800c19c0, 0x02020000, 0x00106157, 0x592c180f,
11469 0x59300007, 0x82000540, 0x00000011, 0x480e6011,
11470 0x48026007, 0x4a026203, 0x00000004, 0x4a026403,
11471 0x00000042, 0x42000800, 0x80002001, 0x0401f02a,
11472 0x5c000000, 0x4c000000, 0x4803c857, 0x4807c857,
11473 0x0401f003, 0x42000800, 0x00000001, 0x59325808,
11474 0x832c0500, 0x00ff0000, 0x0400000d, 0x592c0000,
11475 0x48065a06, 0x48026008, 0x592c040a, 0x8c000510,
11476 0x04020008, 0x0201f800, 0x000202ce, 0x417a7800,
11477 0x59300008, 0x80025d40, 0x0402078f, 0x1c01f000,
11478 0x456a5800, 0x412ed000, 0x815eb800, 0x59c80000,
11479 0x82000540, 0x00001200, 0x48039000, 0x0401f7f4,
11480 0x59840000, 0x80000540, 0x04020002, 0x1c01f000,
11481 0x59840003, 0x80000540, 0x02020000, 0x001061fe,
11482 0x1c01f000, 0x48066004, 0x59bc00ea, 0x8c000516,
11483 0x040207fe, 0x83300400, 0x40000000, 0x480378e1,
11484 0x1c01f000, 0x59bc00ea, 0x82001500, 0xb0000018,
11485 0x02020000, 0x00106c81, 0x8c000510, 0x0400002a,
11486 0x59bc10e0, 0x82080500, 0xfffff000, 0x0402000a,
11487 0x80080108, 0x820a3500, 0x0000000f, 0x4803c857,
11488 0x1201f000, 0x00106c87, 0x84000510, 0x48026004,
11489 0x0401f016, 0x840a653e, 0x59300004, 0x8c000520,
11490 0x040007fa, 0x82000500, 0xfffefeff, 0x48026004,
11491 0x8c08153e, 0x04020005, 0x42027000, 0x00000013,
11492 0x0401f859, 0x0401f009, 0x59300004, 0x8c000514,
11493 0x04000003, 0x0401ffb0, 0x0401f02f, 0x42027000,
11494 0x00000049, 0x0401f850, 0x59bc00ea, 0x82001500,
11495 0xb0000018, 0x02020000, 0x00106c81, 0x8c000510,
11496 0x040207d8, 0x1c01f000, 0x83640480, 0x00000010,
11497 0x0400101a, 0x41626000, 0x41580000, 0x59300a03,
11498 0x82040d80, 0x00000000, 0x04000008, 0x83326400,
11499 0x00000024, 0x81300c80, 0x040017f9, 0x42026000,
11500 0x0010d1c0, 0x0401f7f6, 0x8166c840, 0x83300c00,
11501 0x00000024, 0x80040480, 0x04021005, 0x4006c000,
11502 0x4a026203, 0x00000008, 0x1c01f000, 0x837ac540,
11503 0x0010d1c0, 0x0401f7fb, 0x42000000, 0x0010b854,
11504 0x0201f800, 0x0010aa47, 0x4967c857, 0x80026580,
11505 0x1c01f000, 0x83300480, 0x0010d1c0, 0x02001800,
11506 0x001005d8, 0x41580000, 0x81300480, 0x0402100c,
11507 0x04011000, 0x457a6000, 0x4a026202, 0x0000ffff,
11508 0x83300400, 0x00000003, 0x4803c840, 0x4a03c842,
11509 0x00000021, 0x8166c800, 0x1c01f000, 0x41540000,
11510 0x81300480, 0x02021800, 0x001005d8, 0x04011000,
11511 0x457a6000, 0x4a026202, 0x0000ffff, 0x83300400,
11512 0x00000003, 0x4803c840, 0x4a03c842, 0x00000021,
11513 0x59a80066, 0x49335065, 0x80000000, 0x48035066,
11514 0x1c01f000, 0x4d340000, 0x59326809, 0x59300406,
11515 0x82000500, 0x0000001f, 0x0c01f803, 0x5c026800,
11516 0x1c01f000, 0x00107966, 0x00107979, 0x00107993,
11517 0x000207c9, 0x001098f1, 0x0010990c, 0x0002083e,
11518 0x00107966, 0x00107979, 0x001064ee, 0x001079ac,
11519 0x00107966, 0x00107966, 0x00107966, 0x00107966,
11520 0x00107966, 0x001095a1, 0x0010a6c2, 0x00107966,
11521 0x00107966, 0x00107966, 0x00107966, 0x00107966,
11522 0x00107966, 0x00107966, 0x00107966, 0x00107966,
11523 0x00107966, 0x00107966, 0x00107966, 0x00107966,
11524 0x00107966, 0x59300203, 0x82000c80, 0x0000000e,
11525 0x02021800, 0x001005d8, 0x0c01f001, 0x001079aa,
11526 0x00108592, 0x000207dd, 0x00108720, 0x001087b9,
11527 0x001079aa, 0x001079aa, 0x001079aa, 0x00108577,
11528 0x001079aa, 0x001079aa, 0x001079aa, 0x001079aa,
11529 0x00108985, 0x83380480, 0x00000058, 0x04021007,
11530 0x83380480, 0x00000040, 0x04001004, 0x4d2c0000,
11531 0x0c01f803, 0x5c025800, 0x1c01f000, 0x0010861b,
11532 0x0010861b, 0x0010861b, 0x0010861b, 0x0010861b,
11533 0x0010861d, 0x001086bd, 0x0010861b, 0x0010861b,
11534 0x0010861b, 0x0010861b, 0x0010861b, 0x0010861b,
11535 0x0010861b, 0x0010861b, 0x0010861b, 0x0010861b,
11536 0x0010861b, 0x0010861b, 0x001086c1, 0x000207ff,
11537 0x0010861b, 0x001086c0, 0x001086c2, 0x59325808,
11538 0x59300811, 0x59301402, 0x59340200, 0x8c00050e,
11539 0x0402001c, 0x0401f826, 0x04000005, 0x4a025a04,
11540 0x00000103, 0x497a5c09, 0x0401f009, 0x4a025a04,
11541 0x00000103, 0x4a025a06, 0x00000000, 0x497a5c09,
11542 0x800409c0, 0x02020800, 0x00108785, 0x48065807,
11543 0x480a5c06, 0x0201f800, 0x000202c1, 0x5934000f,
11544 0x5934140b, 0x80081040, 0x04001002, 0x480a6c0b,
11545 0x80000540, 0x02020800, 0x00020253, 0x0401f75e,
11546 0x592c020a, 0x8c000502, 0x040007e9, 0x800409c0,
11547 0x040007e7, 0x592c0208, 0x8c00050e, 0x040207e4,
11548 0x4933c857, 0x0201f000, 0x0010920f, 0x592c020a,
11549 0x8c000500, 0x04000010, 0x59300015, 0x592c380f,
11550 0x801c3c80, 0x0400000c, 0x4a025a06, 0x00000015,
11551 0x8c1c3d3e, 0x04000005, 0x4a025a06, 0x00000007,
11552 0x801c3880, 0x801c3800, 0x481fc857, 0x821c0d40,
11553 0x00000000, 0x1c01f000, 0x59300203, 0x82003480,
11554 0x0000000e, 0x02021800, 0x001005d8, 0x0c01f001,
11555 0x0010992b, 0x00020852, 0x00109fba, 0x00109fc8,
11556 0x0002086e, 0x0010992b, 0x0010a0a8, 0x0002088d,
11557 0x0010992b, 0x0010992b, 0x0010992b, 0x0010992b,
11558 0x0010992b, 0x0010992b, 0x83380580, 0x00000013,
11559 0x02020000, 0x00109f42, 0x59300403, 0x82027480,
11560 0x00000044, 0x02021800, 0x001005d8, 0x82000480,
11561 0x00000040, 0x02001800, 0x001005d8, 0x0c01f001,
11562 0x00109f9e, 0x00020864, 0x00109fa0, 0x00109fb2,
11563 0x59325808, 0x832c0500, 0x00ff0000, 0x04000005,
11564 0x592c0c0a, 0x8c040d1a, 0x02020000, 0x00109fad,
11565 0x0401fe91, 0x0401f710, 0x83380580, 0x00000048,
11566 0x04000007, 0x83380580, 0x00000053, 0x02000000,
11567 0x0010a04a, 0x0201f800, 0x001005d8, 0x5930001f,
11568 0x59301011, 0x59300809, 0x58040a00, 0x8c040d0e,
11569 0x02020000, 0x0010a026, 0x800811c0, 0x02020000,
11570 0x0010a033, 0x5930001f, 0x80000540, 0x02020000,
11571 0x0010a041, 0x59325808, 0x592c040a, 0x8c00051e,
11572 0x02000000, 0x0010a01c, 0x42027000, 0x00000041,
11573 0x0401f001, 0x83380480, 0x00000054, 0x02021800,
11574 0x001005d8, 0x83380480, 0x00000040, 0x02001000,
11575 0x0010a067, 0x0c01f001, 0x0010a073, 0x000208aa,
11576 0x0010a07f, 0x0010a086, 0x0010a073, 0x0010a073,
11577 0x0010a073, 0x0010a073, 0x0010a075, 0x0010a07a,
11578 0x0010a07a, 0x0010a073, 0x0010a073, 0x0010a073,
11579 0x0010a073, 0x0010a07a, 0x0010a073, 0x0010a07a,
11580 0x0010a073, 0x0010a075, 0x4a026203, 0x00000001,
11581 0x493a6403, 0x42000800, 0x80002042, 0x0401f672,
11582 0x00000000, 0x00000000, 0x00000000, 0x00000000,
11583 0x00000000, 0x00000000, 0x00000000, 0x00000000,
11584 0x00000000, 0x00000000, 0x00000000, 0x00000000,
11585 0x00000000, 0x00000000, 0x00000000, 0x14aa62b1,
11586 0x00000000, 0x00000000, 0x00000000, 0x00000005,
11587 0xfffffffb, 0x02800004, 0x00000000, 0x0000c000,
11588 0x0000071d, 0x073fca5a, 0x0705a5a5, 0x01928009,
11589 0x070ff0e1, 0x03800006, 0x04958010, 0x05308000,
11590 0x05008000, 0x0600902f, 0x04a004dc, 0x0202f051,
11591 0x042e4020, 0x018f021b, 0x033e5000, 0x03020000,
11592 0x078d0018, 0x0493041a, 0x0092041c, 0x038a0305,
11593 0x078b0303, 0x048e8010, 0x0678aae5, 0x06000001,
11594 0x07818174, 0x040010e6, 0x0448e0e6, 0x04818010,
11595 0x002fb008, 0x0448e0e6, 0x04818010, 0x060ff0e6,
11596 0x00580401, 0x054880ff, 0x04818010, 0x022a5001,
11597 0x030430d4, 0x06780043, 0x030e0000, 0x030450ff,
11598 0x06780043, 0x03019000, 0x058185c6, 0x027c0045,
11599 0x03020000, 0x06810037, 0x027c0045, 0x03040000,
11600 0x068100c7, 0x027c0045, 0x03080000, 0x0781061e,
11601 0x04908037, 0x029105c4, 0x010410a6, 0x0379ff41,
11602 0x037fffff, 0x072d6000, 0x07601241, 0x050f80ff,
11603 0x032fa009, 0x05600400, 0x050f80ff, 0x056c04ff,
11604 0x068105dc, 0x073fa009, 0x06000001, 0x0279ff02,
11605 0x0700ffff, 0x070ff0d1, 0x0179feff, 0x0700ffff,
11606 0x045c0402, 0x048185dc, 0x060ff0d0, 0x0179feff,
11607 0x0700ffff, 0x057dfeff, 0x0700ffff, 0x078105be,
11608 0x05600e41, 0x050f80ff, 0x032fa069, 0x07480000,
11609 0x068105d0, 0x06780043, 0x070000f0, 0x0781005f,
11610 0x037c00ff, 0x06000010, 0x0781005f, 0x038005cc,
11611 0x0379ff00, 0x070fffff, 0x06780043, 0x07f00000,
11612 0x075a0000, 0x020ef001, 0x028605ce, 0x05484000,
11613 0x02a1819e, 0x062d6001, 0x002fb001, 0x070ff069,
11614 0x01868072, 0x060ff079, 0x055c0441, 0x06810010,
11615 0x012fb000, 0x060560fb, 0x03800078, 0x060ff079,
11616 0x02868198, 0x070ff069, 0x055c0441, 0x06810010,
11617 0x060560fb, 0x0400d0d0, 0x062d6002, 0x0648300d,
11618 0x06810086, 0x070ff0d1, 0x062d6001, 0x045c040b,
11619 0x06810089, 0x05488000, 0x04818086, 0x072e500c,
11620 0x00208001, 0x05a004e1, 0x02800010, 0x062d6001,
11621 0x07f00000, 0x07f00000, 0x070ff0d1, 0x0179feff,
11622 0x070000ff, 0x055c040c, 0x058180bb, 0x0007b001,
11623 0x03079041, 0x0307a000, 0x06600a79, 0x050f80ff,
11624 0x053fa80a, 0x06000010, 0x072d5003, 0x078d0096,
11625 0x0307c003, 0x0007d004, 0x0107e005, 0x0307f006,
11626 0x02080007, 0x00081008, 0x01082009, 0x0308300a,
11627 0x0008400b, 0x0308500c, 0x068d00a1, 0x0678007a,
11628 0x07f00000, 0x010880ff, 0x03386000, 0x03010000,
11629 0x072e6300, 0x020ef07f, 0x02860010, 0x070ff07d,
11630 0x0450047c, 0x050f80ff, 0x002fa819, 0x068d00ae,
11631 0x02080001, 0x00081002, 0x0448807a, 0x068100b5,
11632 0x0379ff03, 0x070000ff, 0x01082003, 0x068d00b6,
11633 0x02386004, 0x03010000, 0x072e6c00, 0x02800010,
11634 0x06780043, 0x070000f0, 0x078105d7, 0x050020ff,
11635 0x027c0002, 0x06000010, 0x078100c3, 0x038005d7,
11636 0x0700c0d1, 0x0379ff0c, 0x070000ff, 0x0380008e,
11637 0x0204a051, 0x06780043, 0x070000f0, 0x037c00ff,
11638 0x06000010, 0x0781816a, 0x072d6000, 0x019485c0,
11639 0x050fb056, 0x044880e6, 0x04818010, 0x060ff0d0,
11640 0x0179feff, 0x0700ffff, 0x057dfeff, 0x0700ffff,
11641 0x078105be, 0x05a00212, 0x0349c0e4, 0x0781811d,
11642 0x070ff093, 0x050010ff, 0x070ff093, 0x045c0401,
11643 0x058180db, 0x02046092, 0x04002046, 0x04600202,
11644 0x00540401, 0x048280e6, 0x04500425, 0x070060ff,
11645 0x0730ffff, 0x0700000f, 0x0742000f, 0x05810190,
11646 0x07a005a6, 0x0648a002, 0x048180e9, 0x00047089,
11647 0x070ff047, 0x045c0443, 0x077800ff, 0x07f00000,
11648 0x0781818e, 0x07780047, 0x0500e000, 0x048185ad,
11649 0x070ff006, 0x01860117, 0x0179fe47, 0x0700000f,
11650 0x010480ff, 0x056c7048, 0x06818102, 0x007a0d4a,
11651 0x04003801, 0x0220f001, 0x0180010f, 0x07608e48,
11652 0x034a60ff, 0x0700f0ff, 0x074b88ff, 0x037000ff,
11653 0x07000600, 0x05500448, 0x074d00ff, 0x045a044a,
11654 0x0304a0ff, 0x070ff00f, 0x01540406, 0x05820117,
11655 0x04950120, 0x05a001bd, 0x02868123, 0x0134bfff,
11656 0x070fffff, 0x0104102e, 0x050fd041, 0x00800126,
11657 0x0595011d, 0x05a001bd, 0x0186011d, 0x0202f00e,
11658 0x052e4030, 0x040fd02f, 0x070fc0ff, 0x05a00218,
11659 0x02800010, 0x0400e02f, 0x042e4020, 0x0202f051,
11660 0x0004100e, 0x0004b00e, 0x050fd041, 0x024a6c46,
11661 0x04500423, 0x050070ff, 0x03620024, 0x050080ff,
11662 0x04004046, 0x0700500f, 0x03206000, 0x05601048,
11663 0x0700a0ff, 0x0700900a, 0x070ff005, 0x04500446,
11664 0x00540425, 0x04820157, 0x05601622, 0x050f80ff,
11665 0x063fa032, 0x06000002, 0x03203000, 0x01204000,
11666 0x03205000, 0x0120b000, 0x0320c000, 0x07601441,
11667 0x050f80ff, 0x043fa852, 0x06000001, 0x070ff056,
11668 0x056c02ff, 0x050fb0ff, 0x070560ff, 0x03079041,
11669 0x05600e41, 0x050f80ff, 0x073fa011, 0x0600003d,
11670 0x06780043, 0x07f00000, 0x065a007a, 0x010880ff,
11671 0x04a001b6, 0x058d0150, 0x0208a04a, 0x0108b04b,
11672 0x02386001, 0x03010000, 0x072e6300, 0x028000a8,
11673 0x0500d00a, 0x05500405, 0x014a68ff, 0x070090ff,
11674 0x0154040a, 0x0700c0ff, 0x0600a023, 0x0500b024,
11675 0x02206001, 0x05601622, 0x050f80ff, 0x063fa04a,
11676 0x06000002, 0x05601022, 0x050f80ff, 0x043fa819,
11677 0x06000001, 0x0600a00d, 0x0180013c, 0x06780043,
11678 0x070000f0, 0x050010ff, 0x027c0001, 0x07000030,
11679 0x078105b4, 0x027c0001, 0x06000020, 0x078105b4,
11680 0x038005cc, 0x054880ff, 0x06810010, 0x070ff056,
11681 0x050fb0ff, 0x044880e5, 0x0581017d, 0x044880e6,
11682 0x04818010, 0x00800183, 0x056c02ff, 0x050fb0ff,
11683 0x070560ff, 0x072e5300, 0x044880e6, 0x04818010,
11684 0x072d5003, 0x06780043, 0x07f00000, 0x010880ff,
11685 0x058d0187, 0x03386005, 0x03010000, 0x033e6000,
11686 0x0700000c, 0x052e5200, 0x02800010, 0x0120918e,
11687 0x018004e4, 0x01209190, 0x018004e4, 0x00209192,
11688 0x018004e4, 0x03209000, 0x018004e4, 0x01209196,
11689 0x018004e4, 0x00209198, 0x018004e4, 0x02493075,
11690 0x06810510, 0x0120919a, 0x018004e4, 0x06601e01,
11691 0x050f80ff, 0x063fa029, 0x06000008, 0x02015010,
11692 0x02016051, 0x00017051, 0x00011051, 0x05601a41,
11693 0x050f80ff, 0x053fa83a, 0x06000008, 0x05600e41,
11694 0x050f80ff, 0x01464000, 0x032fa00a, 0x07006011,
11695 0x05007012, 0x04008013, 0x07009014, 0x0600a015,
11696 0x0400b016, 0x0700c017, 0x07c00000, 0x072d5003,
11697 0x06601479, 0x050f80ff, 0x048d01b9, 0x063fa051,
11698 0x0600003e, 0x07c00000, 0x06005051, 0x0400e02c,
11699 0x0660060e, 0x050f80ff, 0x032fa009, 0x0379ff00,
11700 0x070000ff, 0x076c0000, 0x058101dd, 0x0660480e,
11701 0x0500e0ff, 0x034000ff, 0x01540427, 0x0582020a,
11702 0x03400005, 0x070ff005, 0x055c0428, 0x0481020e,
11703 0x01680e05, 0x056c0405, 0x068181bf, 0x040f8029,
11704 0x053fa809, 0x07000024, 0x06600649, 0x050f80ff,
11705 0x032fa009, 0x0379ff00, 0x070000ff, 0x076c0000,
11706 0x068181bf, 0x0400e049, 0x0340002d, 0x050f802b,
11707 0x053fa80a, 0x06000016, 0x0660480e, 0x0302c0ff,
11708 0x034000ff, 0x01540427, 0x0582020c, 0x072d6000,
11709 0x0460040e, 0x050f80ff, 0x0104e0d1, 0x0379ff4e,
11710 0x0700ffff, 0x062d6002, 0x032fa009, 0x0004d0d0,
11711 0x074b004d, 0x07780000, 0x07ffff00, 0x055a044d,
11712 0x070000ff, 0x00201008, 0x04002051, 0x06003051,
11713 0x05304000, 0x07000060, 0x03205009, 0x07006022,
11714 0x0460040e, 0x050f80ff, 0x032fa03a, 0x06603c0e,
11715 0x050f80ff, 0x073fa00a, 0x07000027, 0x050010d1,
11716 0x0460320e, 0x050f80ff, 0x012fa80a, 0x060ff00e,
11717 0x055c042e, 0x04810210, 0x07c00000, 0x0400e026,
11718 0x008001cb, 0x0202c026, 0x008001e6, 0x0500e02e,
11719 0x008001e6, 0x0400e051, 0x01800209, 0x0349c0e4,
11720 0x04810215, 0x07c00000, 0x013e4000, 0x070c0000,
11721 0x07c00000, 0x013e4000, 0x03080000, 0x07c00000,
11722 0x009702f4, 0x022a5002, 0x0790821d, 0x00910291,
11723 0x030400a6, 0x0678aae5, 0x06000001, 0x00a1860e,
11724 0x06600c40, 0x050f80ff, 0x032fa021, 0x074b0000,
11725 0x076c0600, 0x07818293, 0x05600403, 0x050f80ff,
11726 0x073fa009, 0x06000002, 0x0279ff04, 0x0700ffff,
11727 0x010440d7, 0x0179fe44, 0x0700ffff, 0x045c0404,
11728 0x07818295, 0x0349f044, 0x0681829e, 0x02495001,
11729 0x06818297, 0x060ff079, 0x045c0440, 0x0781823c,
11730 0x0644f07a, 0x002fb008, 0x060ff079, 0x045c0440,
11731 0x07818241, 0x0644f07a, 0x002fb008, 0x0648f001,
11732 0x07818288, 0x04600e40, 0x050f80ff, 0x06480001,
11733 0x04810257, 0x0448e001, 0x04810273, 0x02460001,
11734 0x0644f001, 0x012fa80a, 0x04008040, 0x05a004ee,
11735 0x0286828c, 0x05a004d8, 0x062da001, 0x013e4000,
11736 0x06000080, 0x06930013, 0x02920013, 0x02800010,
11737 0x0644f001, 0x012fa80a, 0x020ef002, 0x00860275,
11738 0x04600840, 0x050f80ff, 0x053fa809, 0x06000002,
11739 0x05780105, 0x00800440, 0x017c0105, 0x05000400,
11740 0x06818275, 0x06601e02, 0x050f80ff, 0x053fa809,
11741 0x06000002, 0x04602a40, 0x050f80ff, 0x070ff005,
11742 0x053fa809, 0x06000002, 0x055c0405, 0x06818275,
11743 0x04008040, 0x0045e008, 0x05a004d8, 0x00800251,
11744 0x0644f001, 0x012fa80a, 0x050020d8, 0x04600440,
11745 0x050f80ff, 0x073fa00a, 0x06000001, 0x06480001,
11746 0x07818281, 0x05308000, 0x03040000, 0x06009040,
11747 0x04a004dc, 0x00800251, 0x06a0060e, 0x054b0800,
11748 0x056a0700, 0x06600c40, 0x050f80ff, 0x032fa00a,
11749 0x00800251, 0x013e4000, 0x06000080, 0x01209288,
11750 0x018004e4, 0x06009008, 0x05308000, 0x05004000,
11751 0x04a004dc, 0x00800251, 0x02209002, 0x008002e5,
11752 0x03209000, 0x008002e5, 0x02209004, 0x008002e5,
11753 0x04a002fd, 0x062da001, 0x05308000, 0x05002000,
11754 0x06009040, 0x04a004dc, 0x02800013, 0x013e4000,
11755 0x06000080, 0x02495001, 0x078182db, 0x04600840,
11756 0x050f80ff, 0x053fa809, 0x06000001, 0x0721f000,
11757 0x0349f003, 0x058102aa, 0x0245f01f, 0x06000002,
11758 0x018602db, 0x07601400, 0x050f80ff, 0x012fa809,
11759 0x06480001, 0x058102db, 0x06602440, 0x050f80ff,
11760 0x012fa809, 0x020ef001, 0x038682db, 0x019b02db,
11761 0x050020d8, 0x062da001, 0x06303002, 0x05000430,
11762 0x04600440, 0x050f80ff, 0x073fa012, 0x06000001,
11763 0x028f82bf, 0x050040d8, 0x062da001, 0x07601e00,
11764 0x050f80ff, 0x073fa009, 0x06000001, 0x060ff004,
11765 0x00540402, 0x048202d9, 0x06005051, 0x06006051,
11766 0x06602240, 0x050f80ff, 0x063fa01a, 0x06000002,
11767 0x06600a40, 0x050f80ff, 0x073fa00a, 0x07000003,
11768 0x060ff040, 0x045a041f, 0x010eb0ff, 0x06930013,
11769 0x02920013, 0x02800010, 0x04004002, 0x018002c9,
11770 0x04a002fd, 0x062da001, 0x05308000, 0x07005000,
11771 0x06009040, 0x04a004dc, 0x050080d8, 0x05a004e1,
11772 0x062da001, 0x02800013, 0x050fd009, 0x050fd041,
11773 0x013e4000, 0x06000080, 0x05308000, 0x03013000,
11774 0x04a004dc, 0x010440d7, 0x0349f044, 0x048102f2,
11775 0x062da001, 0x008f02f2, 0x03e00000, 0x062da001,
11776 0x02800013, 0x0249c0e5, 0x06810013, 0x062da001,
11777 0x07f00000, 0x07f00000, 0x033e5000, 0x070c0000,
11778 0x018f02f6, 0x03800011, 0x050020d8, 0x04600440,
11779 0x050f80ff, 0x073fa00a, 0x06000001, 0x07c00000,
11780 0x002fb001, 0x03800306, 0x012fb000, 0x03075087,
11781 0x068d0307, 0x03386000, 0x03020000, 0x04482075,
11782 0x06810352, 0x0648a0e6, 0x07810347, 0x0642007f,
11783 0x06810345, 0x0340007e, 0x060ff038, 0x0154047e,
11784 0x02d00334, 0x0560027d, 0x050f80ff, 0x032fa009,
11785 0x030ef000, 0x02860504, 0x0107d000, 0x05600800,
11786 0x050f80ff, 0x032fa009, 0x03681e00, 0x04500420,
11787 0x050f80ff, 0x073fa009, 0x0700003f, 0x03800311,
11788 0x070ff07d, 0x0450047c, 0x050f80ff, 0x002fa819,
11789 0x078d0327, 0x02080001, 0x00081002, 0x0448807a,
11790 0x0781032e, 0x0379ff03, 0x070000ff, 0x01082003,
11791 0x068d032f, 0x02386004, 0x03010000, 0x072e6c00,
11792 0x02800352, 0x0380033a, 0x0380033c, 0x0280033e,
11793 0x02800340, 0x03800342, 0x03800344, 0x0727c005,
11794 0x02800323, 0x0627c008, 0x02800323, 0x0627c00b,
11795 0x02800323, 0x0627c00e, 0x02800323, 0x0727c011,
11796 0x02800323, 0x03800314, 0x052e6800, 0x02800352,
11797 0x044880e6, 0x07810533, 0x052e6200, 0x070ff088,
11798 0x0179feff, 0x070fffff, 0x04818501, 0x060ff083,
11799 0x0086836d, 0x033e6000, 0x07000003, 0x068d0352,
11800 0x07286000, 0x07f00000, 0x078d0355, 0x038c0306,
11801 0x0648c0e6, 0x05818372, 0x0448e0e6, 0x0781036a,
11802 0x004920e6, 0x07810365, 0x07a0056f, 0x05001088,
11803 0x00700101, 0x03100000, 0x00088001, 0x033e6000,
11804 0x07000088, 0x03800560, 0x02386001, 0x07030000,
11805 0x033e6000, 0x06000008, 0x028003f1, 0x02799075,
11806 0x0500040f, 0x06810010, 0x06601479, 0x050080ff,
11807 0x06309052, 0x0600003e, 0x02800376, 0x06602279,
11808 0x050080ff, 0x05309812, 0x07000041, 0x0648007a,
11809 0x0781037e, 0x04488075, 0x0581837e, 0x040f8008,
11810 0x070fa009, 0x0049107a, 0x01a183f3, 0x00798075,
11811 0x06000507, 0x05818521, 0x0448b075, 0x06810385,
11812 0x02493075, 0x0681050e, 0x0249c0e6, 0x048183e0,
11813 0x0648c0e6, 0x0581839a, 0x068d0389, 0x02386001,
11814 0x07030000, 0x0049107a, 0x07810390, 0x020ef083,
11815 0x0386039a, 0x06483075, 0x068103ef, 0x0678007a,
11816 0x07000035, 0x03a184cf, 0x05308000, 0x07060000,
11817 0x06009079, 0x04a004dc, 0x028003ef, 0x0448807a,
11818 0x0681039e, 0x06483075, 0x058104f9, 0x0448d07a,
11819 0x068103a2, 0x06483075, 0x058104f9, 0x068d03a2,
11820 0x02386001, 0x07030000, 0x0444e07a, 0x0648307a,
11821 0x048183c7, 0x0448707a, 0x068103ea, 0x0648f07a,
11822 0x078103b2, 0x05a004cf, 0x04008079, 0x05a004ee,
11823 0x008683c2, 0x05a004d8, 0x028003ef, 0x0560107b,
11824 0x050f80ff, 0x032fa009, 0x0349c000, 0x058183c0,
11825 0x04600e79, 0x050f80ff, 0x073fa00a, 0x0600003d,
11826 0x06600a79, 0x050f80ff, 0x053fa80a, 0x06000010,
11827 0x028003ef, 0x0046e07a, 0x028003ea, 0x06009008,
11828 0x05308000, 0x05004000, 0x04a004dc, 0x028003ef,
11829 0x0560167b, 0x050f80ff, 0x032fa011, 0x070ff000,
11830 0x04500401, 0x030460ff, 0x060ff025, 0x00540446,
11831 0x078203d1, 0x030460ff, 0x04092046, 0x05a00218,
11832 0x06600679, 0x050f80ff, 0x00201007, 0x012fa80a,
11833 0x0046047a, 0x034630ff, 0x050020ff, 0x06003051,
11834 0x04600e79, 0x050f80ff, 0x073fa012, 0x06000001,
11835 0x028003ef, 0x033e6a00, 0x0202000e, 0x02079051,
11836 0x07000088, 0x078d03e4, 0x0744c000, 0x01088000,
11837 0x03386006, 0x03010000, 0x02800010, 0x05a004cf,
11838 0x05308000, 0x03020000, 0x06009079, 0x04a004dc,
11839 0x033e6a00, 0x0302000a, 0x02079051, 0x02800010,
11840 0x04603e79, 0x050f80ff, 0x032fa009, 0x070ff000,
11841 0x0186040c, 0x057dfeff, 0x07ffffff, 0x0581040c,
11842 0x050f8000, 0x012fa811, 0x0079fe02, 0x070000ff,
11843 0x077d66ff, 0x060000dc, 0x0781840c, 0x060ff001,
11844 0x0286840d, 0x064b0002, 0x06420002, 0x060ff002,
11845 0x05500400, 0x050f80ff, 0x05004084, 0x073fa00a,
11846 0x06000002, 0x07c00000, 0x04600201, 0x050f80ff,
11847 0x073fa009, 0x06000001, 0x0079fe02, 0x070000ff,
11848 0x077d72ff, 0x070000dd, 0x0781840c, 0x064b0002,
11849 0x06420002, 0x06000001, 0x01800406, 0x0605004c,
11850 0x0180041e, 0x0493041a, 0x04a004d5, 0x054bc450,
11851 0x05810421, 0x01d00422, 0x01800421, 0x00800432,
11852 0x00800434, 0x00800432, 0x008004a7, 0x0180043f,
11853 0x00800434, 0x01800471, 0x00800432, 0x00800432,
11854 0x008004ab, 0x00800432, 0x018004af, 0x008004c4,
11855 0x01800488, 0x00800432, 0x00800432, 0x00209432,
11856 0x018004e4, 0x0379ff50, 0x070fffff, 0x060ff079,
11857 0x055c0450, 0x048104a4, 0x002fb008, 0x060ff079,
11858 0x055c0450, 0x058104a3, 0x04a004c7, 0x0180049c,
11859 0x0179fe50, 0x070fffff, 0x070050ff, 0x060ff079,
11860 0x055c0405, 0x04810449, 0x002fb008, 0x060ff079,
11861 0x055c0405, 0x078184a0, 0x070ff087, 0x017980ff,
11862 0x06000507, 0x06818451, 0x02203040, 0x05002087,
11863 0x0049d002, 0x0481046b, 0x04930458, 0x01257000,
11864 0x073c3fff, 0x0700000f, 0x052e4003, 0x072e5030,
11865 0x0304c050, 0x02400057, 0x06740057, 0x06000002,
11866 0x06820016, 0x04002083, 0x07003084, 0x04004085,
11867 0x06602279, 0x050f80ff, 0x063fa01a, 0x06000001,
11868 0x05a004cf, 0x07a00578, 0x033e6a00, 0x0302000a,
11869 0x062e5020, 0x003e4002, 0x07000a00, 0x028003f1,
11870 0x07420003, 0x0781844e, 0x00798002, 0x06000507,
11871 0x06818451, 0x0180045c, 0x05930478, 0x01257000,
11872 0x073c3fff, 0x0700000f, 0x052e4003, 0x072e5030,
11873 0x0304c050, 0x067800e6, 0x07000041, 0x0581047d,
11874 0x07a00581, 0x04818016, 0x002fb008, 0x067800e6,
11875 0x07000041, 0x04810483, 0x07a00581, 0x04818016,
11876 0x062e5020, 0x003e4002, 0x07000a00, 0x03e00000,
11877 0x02800010, 0x0379ff50, 0x070fffff, 0x060ff079,
11878 0x055c0450, 0x0781848e, 0x0245507a, 0x002fb008,
11879 0x060ff079, 0x055c0450, 0x07818493, 0x0245507a,
11880 0x002fb008, 0x05600e50, 0x050f80ff, 0x012fa809,
11881 0x02455001, 0x05600e50, 0x050f80ff, 0x012fa80a,
11882 0x0080049d, 0x002fb008, 0x003e4002, 0x07000a00,
11883 0x02800016, 0x079384a3, 0x062e5020, 0x042e4002,
11884 0x002fb008, 0x013e4000, 0x05000e00, 0x02800016,
11885 0x0179fe50, 0x070fffff, 0x010210ff, 0x02800016,
11886 0x0179fe50, 0x070fffff, 0x050340ff, 0x0080049d,
11887 0x0179fe50, 0x070fffff, 0x0102e0ff, 0x0760282e,
11888 0x050f80ff, 0x05222000, 0x07223000, 0x05224000,
11889 0x07225000, 0x07226000, 0x05227000, 0x05228000,
11890 0x07229000, 0x0722a000, 0x0522b000, 0x063fa051,
11891 0x07000011, 0x0202c026, 0x0522d000, 0x052e400c,
11892 0x02800016, 0x030430d4, 0x062e5008, 0x00800176,
11893 0x05600e50, 0x050f80ff, 0x032fa009, 0x03460000,
11894 0x018004d2, 0x0246007a, 0x0045207a, 0x008004d0,
11895 0x0246007a, 0x0600007a, 0x04600e79, 0x050f80ff,
11896 0x032fa00a, 0x07c00000, 0x029284d5, 0x070500e1,
11897 0x07c00000, 0x0245f008, 0x048404d9, 0x020e0008,
11898 0x07c00000, 0x070ff009, 0x065a0008, 0x058404de,
11899 0x020e0008, 0x07c00000, 0x058404e1, 0x020e0008,
11900 0x07c00000, 0x05308000, 0x0500d000, 0x04a004dc,
11901 0x04a004e9, 0x02800010, 0x052e4300, 0x072e500c,
11902 0x073c3fff, 0x0700000f, 0x07c00000, 0x06602208,
11903 0x050f80ff, 0x032fa011, 0x076a0000, 0x068184f7,
11904 0x066a0001, 0x048104f7, 0x04002051, 0x07c00000,
11905 0x00202001, 0x07c00000, 0x0648307a, 0x00a18608,
11906 0x05a004cc, 0x05308000, 0x05001000, 0x06009079,
11907 0x04a004dc, 0x03800560, 0x0249c0e6, 0x058104f9,
11908 0x0280036d, 0x0648307a, 0x07818196, 0x05a004cf,
11909 0x05308000, 0x03013000, 0x03209006, 0x04a004dc,
11910 0x033e6000, 0x07030000, 0x02800345, 0x02490075,
11911 0x0781051e, 0x04002089, 0x04780102, 0x07f00000,
11912 0x05001088, 0x07a0056f, 0x04740101, 0x03100000,
11913 0x060ff002, 0x045c0401, 0x0481851f, 0x00088001,
11914 0x033e6000, 0x070000c0, 0x0380055c, 0x07f00000,
11915 0x0220951f, 0x018004e4, 0x0648307a, 0x07810527,
11916 0x06780075, 0x06000007, 0x0581852e, 0x06a00608,
11917 0x06486075, 0x06818194, 0x02490075, 0x0781819a,
11918 0x04487075, 0x05818536, 0x0280053d, 0x05308000,
11919 0x03010000, 0x06009079, 0x04a004dc, 0x02800010,
11920 0x0448e0e6, 0x04818352, 0x00800192, 0x05308000,
11921 0x0500e000, 0x06009079, 0x04a004dc, 0x04008089,
11922 0x05a004e1, 0x0380055c, 0x05a004cc, 0x05308000,
11923 0x0700f000, 0x06009079, 0x07000088, 0x06a00545,
11924 0x04a004dc, 0x02800010, 0x03386000, 0x07030000,
11925 0x07f00000, 0x078d0548, 0x033e6a00, 0x0202000e,
11926 0x02079051, 0x0448b075, 0x07810553, 0x02493075,
11927 0x07810553, 0x05301005, 0x03010000, 0x03800555,
11928 0x05301006, 0x03010000, 0x05002087, 0x06485002,
11929 0x05818555, 0x0744c000, 0x01088000, 0x02086001,
11930 0x07c00000, 0x05001088, 0x07a0056f, 0x0644c001,
11931 0x00088001, 0x033e6a00, 0x0202000e, 0x004920e6,
11932 0x05818565, 0x02079051, 0x078d0565, 0x060ff089,
11933 0x034990ff, 0x0781056c, 0x03386005, 0x03010000,
11934 0x02800010, 0x03386006, 0x03010000, 0x02800010,
11935 0x078d056f, 0x03386000, 0x07030000, 0x07f00000,
11936 0x068d0573, 0x070ff087, 0x074850ff, 0x05818574,
11937 0x07c00000, 0x078d0578, 0x02386001, 0x07030000,
11938 0x07f00000, 0x068d057c, 0x070ff087, 0x074850ff,
11939 0x0581857d, 0x07c00000, 0x05002087, 0x0049d002,
11940 0x05818590, 0x002fb008, 0x067800e6, 0x07000041,
11941 0x002fb008, 0x05818590, 0x07a005a6, 0x0448e002,
11942 0x07810593, 0x0648a002, 0x0481859d, 0x06486002,
11943 0x06810597, 0x02400057, 0x056a02ff, 0x07c00000,
11944 0x07a005a6, 0x06788102, 0x06000004, 0x05818590,
11945 0x04002089, 0x070ff0d4, 0x045c0402, 0x077800ff,
11946 0x07f00000, 0x05818590, 0x00202010, 0x038c0590,
11947 0x07f00000, 0x06420002, 0x0481859e, 0x07a00578,
11948 0x033e6a00, 0x0302000a, 0x07c00000, 0x07f00000,
11949 0x060ff0a2, 0x050020ff, 0x060ff0a2, 0x045c0402,
11950 0x048185a7, 0x07c00000, 0x05a00218, 0x03495047,
11951 0x078105b2, 0x0320901d, 0x02800604, 0x0220901f,
11952 0x02800604, 0x014980e4, 0x04818010, 0x013e4000,
11953 0x07003000, 0x05600e35, 0x050f80ff, 0x07a006fc,
11954 0x01208003, 0x05a004e1, 0x038005cc, 0x03209009,
11955 0x02800604, 0x03209011, 0x02800604, 0x02209007,
11956 0x02800604, 0x03209003, 0x02800604, 0x00498043,
11957 0x058185be, 0x00497043, 0x048185c2, 0x02209001,
11958 0x02800604, 0x0220900d, 0x02800604, 0x0320900f,
11959 0x02800604, 0x03493000, 0x068105d5, 0x027c0045,
11960 0x070a0000, 0x078105de, 0x0220900b, 0x02800604,
11961 0x02209013, 0x05308000, 0x01012000, 0x04a004dc,
11962 0x00800183, 0x03209005, 0x02800604, 0x072e500c,
11963 0x00208002, 0x05a004e1, 0x02800010, 0x02209015,
11964 0x02800604, 0x072d6000, 0x05308000, 0x05007000,
11965 0x07f00000, 0x070090d1, 0x0379ff09, 0x0700ffff,
11966 0x04a004dc, 0x03209017, 0x02800604, 0x033e5000,
11967 0x06000080, 0x02209019, 0x02800604, 0x072d6000,
11968 0x033e5000, 0x06000080, 0x07f00000, 0x060ff0d0,
11969 0x0179feff, 0x0700ffff, 0x057dfeff, 0x0700ffff,
11970 0x04818010, 0x02400058, 0x00642058, 0x06820010,
11971 0x033e5000, 0x06000080, 0x04058051, 0x0320901b,
11972 0x02800604, 0x05308000, 0x01012000, 0x04a004dc,
11973 0x00800176, 0x05a00218, 0x05308000, 0x05008000,
11974 0x06009079, 0x04a004dc, 0x07c00000, 0x034900e4,
11975 0x05818618, 0x013e4000, 0x070000c0, 0x07f00000,
11976 0x034900e4, 0x04818616, 0x07c00000, 0x013e4000,
11977 0x06000080, 0x07f00000, 0x07f00000, 0x07f00000,
11978 0x034900e4, 0x06810610, 0x03800618, 0x072d6000,
11979 0x00498043, 0x06810632, 0x060ff0d0, 0x0179feff,
11980 0x0700ffff, 0x057dfeff, 0x0700ffff, 0x058185e2,
11981 0x050f8030, 0x032fa009, 0x0379ff00, 0x0700ffff,
11982 0x070ff0d1, 0x0179feff, 0x0700ffff, 0x055c0400,
11983 0x078105e2, 0x04004051, 0x0280067a, 0x06a006dc,
11984 0x062d6001, 0x020ef004, 0x038605e4, 0x06600004,
11985 0x050f80ff, 0x032fa009, 0x074b0000, 0x05002000,
11986 0x0769ff00, 0x01640800, 0x078205e4, 0x01640e00,
11987 0x058285e4, 0x070ff036, 0x045c0404, 0x0581864d,
11988 0x072d6000, 0x050f8030, 0x032fa009, 0x0379ff00,
11989 0x0700ffff, 0x070ff0d1, 0x0179feff, 0x0700ffff,
11990 0x055c0400, 0x078105e2, 0x04482034, 0x078105ff,
11991 0x06483034, 0x058185ff, 0x070ff0d4, 0x077800ff,
11992 0x070000f0, 0x037c00ff, 0x06000010, 0x0681067a,
11993 0x06a006d6, 0x024900e5, 0x0681065d, 0x033e5000,
11994 0x06000080, 0x02800010, 0x04601c04, 0x050f80ff,
11995 0x053fa809, 0x06000020, 0x030ef041, 0x038605ee,
11996 0x062d6002, 0x05602a41, 0x050f80ff, 0x012fa809,
11997 0x060ff0d0, 0x074b00ff, 0x045c0401, 0x05818678,
11998 0x062d6001, 0x07602841, 0x050f80ff, 0x053fa809,
11999 0x06000001, 0x070ff0d1, 0x054b80ff, 0x074b0003,
12000 0x055c0403, 0x05818678, 0x033e5000, 0x06000080,
12001 0x0080070e, 0x07600041, 0x0280065e, 0x06a006d6,
12002 0x024900e5, 0x06810680, 0x033e5000, 0x06000080,
12003 0x02800010, 0x06a006c2, 0x030ef041, 0x028605f2,
12004 0x04058051, 0x072d6000, 0x05601041, 0x050f80ff,
12005 0x012fa809, 0x0600a0d0, 0x0500b0d1, 0x062d6001,
12006 0x07f00000, 0x07f00000, 0x0600c0d0, 0x0500d0d1,
12007 0x062d6002, 0x0279ff0d, 0x07ff0000, 0x044d800d,
12008 0x060ff0d0, 0x074b00ff, 0x065a000d, 0x06601201,
12009 0x050f80ff, 0x073fa022, 0x07000005, 0x0079fe0d,
12010 0x070000ff, 0x050020ff, 0x05602a41, 0x050f80ff,
12011 0x073fa00a, 0x06000001, 0x020ef004, 0x028606bf,
12012 0x04601c04, 0x050f80ff, 0x053fa809, 0x06000001,
12013 0x050f80ff, 0x053fa80a, 0x06000020, 0x07602841,
12014 0x050f80ff, 0x073fa009, 0x06000001, 0x0279ff02,
12015 0x070000ff, 0x0678000d, 0x0700ff00, 0x065a0002,
12016 0x07602841, 0x050f80ff, 0x073fa00a, 0x06000001,
12017 0x07600041, 0x050f80ff, 0x053fa80a, 0x06000001,
12018 0x07601241, 0x050f80ff, 0x073fa00a, 0x06000002,
12019 0x033e5000, 0x06000080, 0x0080070e, 0x040f8032,
12020 0x073fa011, 0x06000001, 0x060ff002, 0x055c0403,
12021 0x058186ca, 0x00041051, 0x07c00000, 0x04600402,
12022 0x04500432, 0x050f80ff, 0x053fa809, 0x06000020,
12023 0x00400402, 0x01680eff, 0x070030ff, 0x040f8032,
12024 0x053fa80a, 0x06000001, 0x07c00000, 0x024900e5,
12025 0x068106d9, 0x07c00000, 0x033e5000, 0x070000c0,
12026 0x07c00000, 0x05004036, 0x060000d0, 0x0179fe00,
12027 0x0700ffff, 0x057dfeff, 0x0700ffff, 0x068106fb,
12028 0x070000d1, 0x0379ff00, 0x0700ffff, 0x06005051,
12029 0x060ff031, 0x05500405, 0x050f80ff, 0x073fa009,
12030 0x06000002, 0x020ef004, 0x038606f5, 0x04600404,
12031 0x050f80ff, 0x012fa809, 0x0079fe01, 0x0700ffff,
12032 0x055c0400, 0x068106fb, 0x01400405, 0x070050ff,
12033 0x057de0ff, 0x06000007, 0x058186e7, 0x04004051,
12034 0x07c00000, 0x072d6000, 0x07f00000, 0x07f00000,
12035 0x000110d0, 0x010120d1, 0x062d6001, 0x07f00000,
12036 0x07f00000, 0x020130d0, 0x010140d1, 0x062d6002,
12037 0x010170d4, 0x07f00000, 0x020150d0, 0x030160d1,
12038 0x053fa83a, 0x06000008, 0x07c00000, 0x07600c41,
12039 0x050f80ff, 0x073fa009, 0x06000001, 0x04780102,
12040 0x07ffff00, 0x046a0702, 0x050f80ff, 0x073fa00a,
12041 0x06000001, 0x05600e41, 0x050f80ff, 0x032fa069,
12042 0x03800053, 0xba6b4e34, 0x02800004, 0x00000000,
12043 0x00008000, 0x00000518, 0x040f801f, 0x012fa8c9,
12044 0x040f801f, 0x073fa081, 0x06000010, 0x03200005,
12045 0x07420000, 0x050fb000, 0x040f801f, 0x073fa011,
12046 0x06000038, 0x040f801f, 0x053fa859, 0x0700003a,
12047 0x050fe000, 0x0581800a, 0x0684003d, 0x04958019,
12048 0x030e0011, 0x072e4200, 0x03800014, 0x0291001f,
12049 0x050010c0, 0x04482001, 0x058180e8, 0x06483001,
12050 0x0781814b, 0x02920029, 0x068b0029, 0x018a0150,
12051 0x050010c0, 0x06780001, 0x050007c0, 0x06818223,
12052 0x06780001, 0x0500f800, 0x07818263, 0x03910030,
12053 0x040fe029, 0x03860030, 0x076c001d, 0x04810294,
12054 0x076c0a1d, 0x048102b9, 0x0292003d, 0x040fe02f,
12055 0x0286003d, 0x06000013, 0x050fb000, 0x066c0073,
12056 0x068103c2, 0x0297003d, 0x014920e4, 0x0481803d,
12057 0x03400000, 0x076c0a00, 0x04818034, 0x0796003f,
12058 0x03b900b8, 0x05908014, 0x010170e1, 0x07780017,
12059 0x03e00000, 0x06810092, 0x050010ff, 0x0179fe17,
12060 0x031fffff, 0x070000ff, 0x05600800, 0x050f80ff,
12061 0x073fa009, 0x06000001, 0x06780002, 0x02800040,
12062 0x037c00ff, 0x03800000, 0x0681005e, 0x0249f002,
12063 0x068100ab, 0x0448e002, 0x0681005e, 0x07600c00,
12064 0x050f80ff, 0x073fa009, 0x06000001, 0x06780002,
12065 0x07ffff00, 0x037c00ff, 0x05000200, 0x048180ab,
12066 0x064bd401, 0x03d00060, 0x038000a9, 0x02800068,
12067 0x03800072, 0x0280007c, 0x02800086, 0x03800090,
12068 0x038000a9, 0x038000a9, 0x050fe027, 0x0186806c,
12069 0x01028000, 0x0380006f, 0x07600027, 0x050f80ff,
12070 0x032fa00a, 0x01027000, 0x02400029, 0x028000ab,
12071 0x040fe025, 0x00868076, 0x03026000, 0x02800079,
12072 0x06600025, 0x050f80ff, 0x032fa00a, 0x03025000,
12073 0x02400029, 0x028000ab, 0x050fe021, 0x00868080,
12074 0x01022000, 0x02800083, 0x07600021, 0x050f80ff,
12075 0x032fa00a, 0x01021000, 0x02400029, 0x028000ab,
12076 0x040fe023, 0x0086808a, 0x01024000, 0x0380008d,
12077 0x06600023, 0x050f80ff, 0x032fa00a, 0x03023000,
12078 0x02400029, 0x028000ab, 0x06a000c8, 0x028000ab,
12079 0x01640817, 0x058280a9, 0x070ff017, 0x03d00096,
12080 0x0280009e, 0x038000a0, 0x038000a3, 0x038000a6,
12081 0x038000a9, 0x038000a9, 0x038000a9, 0x038000a9,
12082 0x03e00000, 0x03800014, 0x059080a0, 0x030160e1,
12083 0x028000ab, 0x059080a3, 0x030150e1, 0x028000ab,
12084 0x059080a6, 0x010140e1, 0x028000ab, 0x060fc013,
12085 0x06a00510, 0x03800014, 0x072e4800, 0x07000012,
12086 0x038000bb, 0x0747f000, 0x05600800, 0x050f80ff,
12087 0x012fa809, 0x0249f001, 0x078100bb, 0x01012000,
12088 0x052e4c00, 0x07c00000, 0x070000eb, 0x0349f000,
12089 0x058180af, 0x05600800, 0x050f80ff, 0x012fa809,
12090 0x0448e001, 0x068100c1, 0x07c00000, 0x0079c101,
12091 0x07ffffff, 0x027a4b01, 0x03800000, 0x05600800,
12092 0x050f80ff, 0x012fa80a, 0x07600c00, 0x050f80ff,
12093 0x012fa821, 0x06780001, 0x07ffff00, 0x037c00ff,
12094 0x05000700, 0x078100dd, 0x06601804, 0x070030ff,
12095 0x050f80ff, 0x012fa809, 0x05002000, 0x050f8003,
12096 0x073fa00a, 0x06000001, 0x040fe001, 0x038600de,
12097 0x04600201, 0x050f80ff, 0x032fa00a, 0x07c00000,
12098 0x050fe02e, 0x008680e3, 0x0102e000, 0x0302f000,
12099 0x038000e7, 0x0760002e, 0x050f80ff, 0x032fa00a,
12100 0x0102e000, 0x07c00000, 0x022c0004, 0x056c041d,
12101 0x078100fc, 0x056c021d, 0x04810113, 0x056c081d,
12102 0x04810125, 0x076c061d, 0x0581013f, 0x0521d000,
12103 0x0202c013, 0x0202a013, 0x02020013, 0x0460021a,
12104 0x050f80ff, 0x053fa80a, 0x07000009, 0x03b600ac,
12105 0x0484801f, 0x0280003d, 0x040fe02a, 0x028600f2,
12106 0x06000013, 0x04001013, 0x0560102b, 0x050f80ff,
12107 0x032fa012, 0x06420029, 0x0660002a, 0x050f80ff,
12108 0x053fa809, 0x06000001, 0x050fe003, 0x00860110,
12109 0x01028003, 0x0660002a, 0x050f80ff, 0x053fa80a,
12110 0x07000009, 0x00800140, 0x00028013, 0x00027013,
12111 0x00800140, 0x040fe02a, 0x028600f1, 0x06420029,
12112 0x0660002a, 0x050f80ff, 0x053fa809, 0x06000001,
12113 0x050fe003, 0x01860122, 0x03026003, 0x0660002a,
12114 0x050f80ff, 0x053fa80a, 0x07000009, 0x00800140,
12115 0x02026013, 0x02025013, 0x00800140, 0x040fe02a,
12116 0x028600f1, 0x06420029, 0x0660002a, 0x050f80ff,
12117 0x053fa809, 0x06000001, 0x050fe003, 0x00860134,
12118 0x01022003, 0x0660002a, 0x050f80ff, 0x053fa80a,
12119 0x07000009, 0x01800136, 0x00022013, 0x00021013,
12120 0x0647f020, 0x007a0120, 0x04000101, 0x04a00285,
12121 0x0400802a, 0x05a004f5, 0x009480f1, 0x0521d005,
12122 0x028000f2, 0x038000fa, 0x0647f020, 0x06486020,
12123 0x06818145, 0x04a00285, 0x028000f1, 0x007a0120,
12124 0x04000101, 0x04a00285, 0x0400802a, 0x05a004f5,
12125 0x028000f1, 0x040fd02a, 0x052e4003, 0x00208010,
12126 0x05a004f5, 0x038000fa, 0x00018098, 0x07480018,
12127 0x06818161, 0x05481018, 0x0781815f, 0x05482018,
12128 0x0681815d, 0x07483018, 0x0681815b, 0x002fb004,
12129 0x00800162, 0x012fb003, 0x00800162, 0x002fb002,
12130 0x00800162, 0x002fb001, 0x00800162, 0x012fb000,
12131 0x0179fe78, 0x070000ff, 0x030190ff, 0x00017086,
12132 0x058b0166, 0x03385000, 0x03020000, 0x07780017,
12133 0x00430407, 0x078181ee, 0x046c0419, 0x048101a2,
12134 0x046c0219, 0x05810172, 0x07219000, 0x00800186,
12135 0x07219000, 0x07483017, 0x0481018c, 0x05482017,
12136 0x05810193, 0x0448b075, 0x06818186, 0x06601476,
12137 0x050f80ff, 0x073fa022, 0x0600003e, 0x06000080,
12138 0x05001081, 0x05002082, 0x06003083, 0x05004084,
12139 0x04601c76, 0x050f80ff, 0x022fa02a, 0x07219000,
12140 0x07780078, 0x07ffff00, 0x045a0419, 0x010780ff,
12141 0x0484801f, 0x0280003d, 0x040fe07f, 0x0086019b,
12142 0x05a001bb, 0x00920186, 0x040fe07f, 0x07a681bb,
12143 0x00800186, 0x0560107b, 0x050f80ff, 0x032fa009,
12144 0x0744f000, 0x0560107b, 0x050f80ff, 0x032fa00a,
12145 0x00800179, 0x052e400c, 0x040080fb, 0x046aa108,
12146 0x06009076, 0x04002075, 0x05a004fc, 0x00800186,
12147 0x06219001, 0x05482017, 0x058101af, 0x058b01a5,
12148 0x060ff086, 0x0349f0ff, 0x07818165, 0x07483017,
12149 0x058101ac, 0x050fd0ff, 0x040fe07f, 0x07a681bb,
12150 0x00800186, 0x05004084, 0x05a00205, 0x00920186,
12151 0x070ff07d, 0x0450047c, 0x056004ff, 0x050f80ff,
12152 0x032fa009, 0x070ff000, 0x00540479, 0x030790ff,
12153 0x01800193, 0x060ff079, 0x0054047a, 0x058201e7,
12154 0x058101e7, 0x070ff07d, 0x0450047c, 0x050f80ff,
12155 0x002fa819, 0x058b01c3, 0x02080001, 0x00081002,
12156 0x01082003, 0x048b01c7, 0x03385000, 0x03010000,
12157 0x02400019, 0x070ff003, 0x04500479, 0x030790ff,
12158 0x0340007e, 0x0642007f, 0x058101e7, 0x070ff07e,
12159 0x050f80ff, 0x032fa009, 0x050fe000, 0x028681e6,
12160 0x070ff07d, 0x056002ff, 0x050f80ff, 0x032fa009,
12161 0x0107d000, 0x018601e8, 0x0560087d, 0x050f80ff,
12162 0x032fa009, 0x0569fe00, 0x0550041b, 0x050f80ff,
12163 0x032fa009, 0x0107e000, 0x070ff07e, 0x018001d2,
12164 0x0307c000, 0x07c00000, 0x052e400c, 0x040080fb,
12165 0x046aa108, 0x06009076, 0x04002075, 0x018004fc,
12166 0x040fd076, 0x050fd017, 0x060ff086, 0x077800ff,
12167 0x07000060, 0x037c00ff, 0x07000060, 0x078181f0,
12168 0x07780078, 0x07ffff00, 0x045a0419, 0x010780ff,
12169 0x06601476, 0x050f80ff, 0x073fa022, 0x0600003e,
12170 0x052e400c, 0x040080fb, 0x066a8108, 0x06009076,
12171 0x04002075, 0x05a004fc, 0x02800029, 0x0240007f,
12172 0x0742007e, 0x050f807e, 0x032fa009, 0x050fe000,
12173 0x0286821f, 0x070ff07d, 0x055c047b, 0x05810214,
12174 0x0760007d, 0x050f80ff, 0x032fa009, 0x050fe000,
12175 0x03868214, 0x070ff07b, 0x0107d0ff, 0x0560087d,
12176 0x050f80ff, 0x032fa009, 0x03681e00, 0x0450041c,
12177 0x0107e0ff, 0x050f80ff, 0x032fa009, 0x050fe000,
12178 0x01860221, 0x0307c000, 0x07c00000, 0x040fd076,
12179 0x02800510, 0x010180c0, 0x0548e018, 0x0781823c,
12180 0x0748f018, 0x06818238, 0x03490018, 0x06818234,
12181 0x01491018, 0x07818230, 0x073c0000, 0x06000040,
12182 0x02200004, 0x0180023f, 0x073c0000, 0x06000020,
12183 0x03200003, 0x0180023f, 0x073c0000, 0x06000010,
12184 0x02200002, 0x0180023f, 0x073c0000, 0x06000008,
12185 0x02200001, 0x0180023f, 0x073c0000, 0x06000004,
12186 0x06000013, 0x050fb000, 0x040fe076, 0x00860258,
12187 0x046c0273, 0x04810268, 0x066c0073, 0x04810249,
12188 0x040fd076, 0x06a00510, 0x03800014, 0x040fd076,
12189 0x0080024c, 0x00452075, 0x00077013, 0x0647f075,
12190 0x06486075, 0x06818252, 0x05a0028b, 0x00800258,
12191 0x007a0175, 0x04000101, 0x05a0028b, 0x04008076,
12192 0x0245f008, 0x05a004f5, 0x07273000, 0x05600272,
12193 0x050f80ff, 0x053fa80a, 0x07000009, 0x0379ff78,
12194 0x070000ff, 0x02076013, 0x02075013, 0x0484801f,
12195 0x0280003d, 0x070fc0ff, 0x052e400c, 0x00208020,
12196 0x05a004f5, 0x00800261, 0x04600276, 0x050010ff,
12197 0x040f8001, 0x032fa009, 0x040f8001, 0x053fa80a,
12198 0x07000009, 0x070ff000, 0x0286827a, 0x06601276,
12199 0x050f80ff, 0x073fa009, 0x0700000c, 0x07601818,
12200 0x050f80ff, 0x053fa80a, 0x07000009, 0x0180027b,
12201 0x07a000de, 0x0448b075, 0x0581024b, 0x06000013,
12202 0x04001013, 0x0560107b, 0x050f80ff, 0x032fa012,
12203 0x0046b075, 0x03b600ac, 0x0080024c, 0x06000020,
12204 0x04001016, 0x0460082a, 0x050f80ff, 0x032fa012,
12205 0x07c00000, 0x06000075, 0x040010a2, 0x044b0801,
12206 0x060ff016, 0x065a0001, 0x04600876, 0x050f80ff,
12207 0x032fa012, 0x07c00000, 0x050fe022, 0x0186029a,
12208 0x0421d004, 0x0302a022, 0x04a002c1, 0x018002b1,
12209 0x040fe026, 0x008602b3, 0x0421d001, 0x0202a026,
12210 0x04a002c1, 0x0202c013, 0x00683e20, 0x070060ff,
12211 0x056c0206, 0x048102f4, 0x056c0406, 0x0781030a,
12212 0x076c0606, 0x06810379, 0x056c1606, 0x078182b1,
12213 0x04488020, 0x07810387, 0x040fd02a, 0x0521d000,
12214 0x0202a013, 0x02020013, 0x008002b3, 0x04a004ec,
12215 0x008002bf, 0x050fe028, 0x008602bf, 0x0302a028,
12216 0x0421d002, 0x04a002c1, 0x008002c8, 0x050fe022,
12217 0x008602bf, 0x0421d004, 0x0302a022, 0x04a002c1,
12218 0x04a004ec, 0x05848030, 0x0280003d, 0x0460082a,
12219 0x050f80ff, 0x022fa031, 0x03020000, 0x0002b004,
12220 0x01018005, 0x07c00000, 0x0400702a, 0x06a003ba,
12221 0x007a0101, 0x07060000, 0x07303000, 0x07008290,
12222 0x07600018, 0x050f80ff, 0x053fa809, 0x07000003,
12223 0x0448e007, 0x068182d6, 0x06006013, 0x018002dd,
12224 0x02400010, 0x048102d6, 0x06006010, 0x0460322a,
12225 0x050f80ff, 0x073fa00a, 0x07000003, 0x050f801e,
12226 0x032fa03a, 0x063aa020, 0x06000002, 0x013e4000,
12227 0x07000030, 0x009802e3, 0x070ff0f6, 0x036830ff,
12228 0x078182e4, 0x070f001e, 0x0560102b, 0x050f10ff,
12229 0x063f3c08, 0x0600000d, 0x013e4000, 0x06000020,
12230 0x040f801a, 0x0320000a, 0x022017d0, 0x032fa012,
12231 0x0202c013, 0x008002bf, 0x04007013, 0x06a003ba,
12232 0x007a0101, 0x07050000, 0x07303000, 0x07008890,
12233 0x074d0005, 0x06006013, 0x050f801e, 0x032fa03a,
12234 0x05601a2b, 0x050f80ff, 0x022fa019, 0x04001002,
12235 0x04002013, 0x040f801f, 0x022fa01a, 0x073aa00c,
12236 0x06000002, 0x07300c03, 0x0600000d, 0x028003a7,
12237 0x04007013, 0x06a003ba, 0x007a0101, 0x03070000,
12238 0x0660282a, 0x050f80ff, 0x073fa009, 0x06000004,
12239 0x02499008, 0x07810317, 0x07303000, 0x07008890,
12240 0x02800319, 0x07303000, 0x04008980, 0x05007003,
12241 0x074d0005, 0x06006013, 0x050f801e, 0x032fa03a,
12242 0x0760142b, 0x050f80ff, 0x032fa021, 0x064b0002,
12243 0x02499008, 0x06810325, 0x0644c002, 0x054b0400,
12244 0x050040ff, 0x06698104, 0x0581833a, 0x06000013,
12245 0x04001013, 0x04780102, 0x06000010, 0x06003013,
12246 0x04004013, 0x06005013, 0x06006013, 0x04007013,
12247 0x00644015, 0x07820336, 0x04448002, 0x02205008,
12248 0x040f801f, 0x032fa042, 0x04008015, 0x03800371,
12249 0x046c8004, 0x05818348, 0x01208018, 0x06780002,
12250 0x07000003, 0x0581834b, 0x06003001, 0x06000013,
12251 0x04001013, 0x04004013, 0x06005013, 0x040f801f,
12252 0x022fa032, 0x03800371, 0x040fd02a, 0x06a00510,
12253 0x03800014, 0x04488002, 0x07810350, 0x070ff003,
12254 0x04500408, 0x050080ff, 0x06489002, 0x06810357,
12255 0x0379ff00, 0x070000ff, 0x070ff000, 0x04500408,
12256 0x050080ff, 0x07005003, 0x05004000, 0x06003001,
12257 0x06000013, 0x04001013, 0x040f801f, 0x022fa032,
12258 0x05601c2b, 0x050f80ff, 0x022fa031, 0x06600c1f,
12259 0x050f80ff, 0x022fa032, 0x02680608, 0x07810371,
12260 0x016408ff, 0x057dfeff, 0x07ffffff, 0x034000ff,
12261 0x045a0407, 0x070000ff, 0x0760061e, 0x050f80ff,
12262 0x032fa00a, 0x06600908, 0x0669f908, 0x027a0008,
12263 0x06000020, 0x070aa0ff, 0x014a20ff, 0x037a00ff,
12264 0x060000dc, 0x070000ff, 0x028003a7, 0x04007013,
12265 0x06a003ba, 0x007a0101, 0x07030000, 0x07303000,
12266 0x07008190, 0x06006013, 0x050f801e, 0x032fa03a,
12267 0x073aa000, 0x06000002, 0x07300c00, 0x07000005,
12268 0x028003a7, 0x04007013, 0x06a003ba, 0x007a0101,
12269 0x07810000, 0x07303000, 0x07000090, 0x06006013,
12270 0x06600c2a, 0x050f80ff, 0x053fa809, 0x07000003,
12271 0x04780107, 0x07ffff00, 0x007c0107, 0x07000500,
12272 0x0581839a, 0x07303000, 0x05000890, 0x074d0005,
12273 0x0660282a, 0x050f80ff, 0x053fa809, 0x07000003,
12274 0x0049d007, 0x068103a1, 0x02206001, 0x050f801e,
12275 0x032fa03a, 0x073aa000, 0x06000002, 0x07300c00,
12276 0x07000005, 0x013e4000, 0x07000030, 0x039803a9,
12277 0x070ff0f6, 0x036830ff, 0x058183aa, 0x070f001e,
12278 0x040f101f, 0x070f3000, 0x013e4000, 0x06000020,
12279 0x040f801a, 0x0320000a, 0x022017d0, 0x032fa012,
12280 0x008002bf, 0x03200000, 0x06006076, 0x028003bc,
12281 0x03200011, 0x0600602a, 0x05a00441, 0x05600406,
12282 0x050f80ff, 0x053fa809, 0x06000002, 0x07c00000,
12283 0x0207602f, 0x04600876, 0x050f80ff, 0x022fa031,
12284 0x03075000, 0x0007b004, 0x01018005, 0x06600076,
12285 0x050020ff, 0x050f80ff, 0x012fa809, 0x0202f001,
12286 0x008683d0, 0x0002e013, 0x040f8002, 0x053fa80a,
12287 0x07000009, 0x06273001, 0x0448b075, 0x048183da,
12288 0x04602076, 0x050f80ff, 0x053fa811, 0x0700003c,
12289 0x0179fe78, 0x070000ff, 0x030190ff, 0x018683e2,
12290 0x07a003f6, 0x00078019, 0x039203f5, 0x0180043a,
12291 0x040fd076, 0x040fd019, 0x04600276, 0x050020ff,
12292 0x050f80ff, 0x032fa009, 0x040f8002, 0x053fa80a,
12293 0x07000009, 0x050fe000, 0x008683f2, 0x07601818,
12294 0x050f80ff, 0x053fa80a, 0x07000009, 0x038003f3,
12295 0x07a000de, 0x07273000, 0x02076013, 0x0280003d,
12296 0x078b03f6, 0x03385000, 0x07030000, 0x05600818,
12297 0x050f80ff, 0x032fa009, 0x054b0400, 0x0308a0ff,
12298 0x0179fe00, 0x070000ff, 0x010880ff, 0x0448b075,
12299 0x04810410, 0x0760147b, 0x050f80ff, 0x002fa819,
12300 0x064b0001, 0x02080002, 0x01081003, 0x00082001,
12301 0x02083001, 0x02079001, 0x0207a001, 0x00084013,
12302 0x0207f013, 0x00800432, 0x06485075, 0x05810428,
12303 0x02465075, 0x06601476, 0x050f80ff, 0x073fa021,
12304 0x0600003e, 0x070ff07d, 0x0450047c, 0x050f80ff,
12305 0x002fa819, 0x058b041b, 0x02080001, 0x00081002,
12306 0x01082003, 0x03079003, 0x0208307a, 0x0340007e,
12307 0x0642007f, 0x0581042d, 0x070ff07e, 0x05a001d2,
12308 0x0392842d, 0x01800439, 0x058b0428, 0x06601476,
12309 0x050f80ff, 0x073fa041, 0x0600003e, 0x06602476,
12310 0x050f80ff, 0x073fa009, 0x06000007, 0x0008400e,
12311 0x048b0432, 0x03385000, 0x03010000, 0x06219001,
12312 0x040fe07f, 0x01860439, 0x018001bb, 0x07c00000,
12313 0x00683e75, 0x0581043f, 0x0448d075, 0x05810465,
12314 0x01800493, 0x05a004f0, 0x038003f5, 0x0297844c,
12315 0x07602418, 0x050f80ff, 0x012fa809, 0x06780001,
12316 0x070000ff, 0x075a0000, 0x070ff014, 0x0569feff,
12317 0x054b08ff, 0x075a0000, 0x05600418, 0x050f80ff,
12318 0x012fa809, 0x040fe007, 0x03868453, 0x01204000,
12319 0x00800461, 0x00700101, 0x03010000, 0x06780001,
12320 0x07ff0000, 0x076c00ff, 0x0681845b, 0x00700101,
12321 0x03010000, 0x05600418, 0x050f80ff, 0x012fa80a,
12322 0x06780001, 0x07ff0000, 0x050040ff, 0x0279ff01,
12323 0x0700ffff, 0x05002014, 0x07c00000, 0x04007076,
12324 0x0448b075, 0x0481047f, 0x03200011, 0x06006076,
12325 0x06a003bc, 0x007a0101, 0x07060000, 0x07303000,
12326 0x07008290, 0x07600018, 0x050f80ff, 0x053fa809,
12327 0x07000003, 0x0448e007, 0x07818477, 0x06006013,
12328 0x0180048e, 0x02400010, 0x05810477, 0x06006010,
12329 0x04603276, 0x050f80ff, 0x073fa00a, 0x07000003,
12330 0x0180048e, 0x04602a76, 0x050f80ff, 0x032fa009,
12331 0x060ff07a, 0x05500400, 0x070000ff, 0x04602a76,
12332 0x050f80ff, 0x032fa00a, 0x07a003b7, 0x007a0101,
12333 0x03010000, 0x06303008, 0x05008000, 0x0600600e,
12334 0x050f8074, 0x032fa03a, 0x053079a0, 0x0700000c,
12335 0x008004d3, 0x00683e75, 0x076c0aff, 0x058104b2,
12336 0x04007013, 0x03200011, 0x06006076, 0x06a003bc,
12337 0x007a0101, 0x03070000, 0x06602876, 0x050f80ff,
12338 0x053fa809, 0x06000001, 0x03499003, 0x048104a7,
12339 0x07303000, 0x07008890, 0x053079a0, 0x0700000c,
12340 0x008004ab, 0x07303000, 0x04008980, 0x04307920,
12341 0x0700000c, 0x074d0005, 0x06006013, 0x050f8074,
12342 0x032fa03a, 0x04307920, 0x0700000c, 0x008004d3,
12343 0x04602a76, 0x050f80ff, 0x032fa009, 0x060ff07a,
12344 0x05500400, 0x070000ff, 0x04602a76, 0x050f80ff,
12345 0x032fa00a, 0x04007076, 0x07a003b7, 0x007a0101,
12346 0x03010000, 0x06303008, 0x07008800, 0x074d0005,
12347 0x06600a76, 0x050f80ff, 0x073fa009, 0x07000003,
12348 0x054b0406, 0x045a0404, 0x050040ff, 0x0600600e,
12349 0x050f8074, 0x032fa03a, 0x0648c075, 0x058104d1,
12350 0x06307d20, 0x0700000c, 0x008004d3, 0x04307920,
12351 0x0700000c, 0x013e4000, 0x07000030, 0x009804d5,
12352 0x070ff0f6, 0x074850ff, 0x068184d6, 0x050f2074,
12353 0x060a0007, 0x040070fb, 0x046a7007, 0x050f40ff,
12354 0x013e4000, 0x06000020, 0x0678007a, 0x07fff000,
12355 0x068184e6, 0x0320000a, 0x022017d0, 0x008004e9,
12356 0x0320000a, 0x06301b58, 0x06000001, 0x050f8072,
12357 0x032fa012, 0x038003f5, 0x01208060, 0x0600902a,
12358 0x04002020, 0x018004fc, 0x040080fb, 0x066ae108,
12359 0x06009076, 0x04002075, 0x018004fc, 0x03201100,
12360 0x078484fa, 0x06420001, 0x078184f6, 0x02800513,
12361 0x020e0008, 0x07c00000, 0x050fd009, 0x040fd008,
12362 0x03201100, 0x05848503, 0x06420001, 0x078184ff,
12363 0x02800513, 0x007a0102, 0x04000101, 0x05600809,
12364 0x050f80ff, 0x073fa00a, 0x06000001, 0x020e0008,
12365 0x0684050d, 0x030e0009, 0x07c00000, 0x01011009,
12366 0x052e4300, 0x07c00000, 0x052e400f, 0x01208090,
12367 0x018004f5, 0x070fc0ff, 0x040f8013, 0x032fa009,
12368 0x02800516, 0x15416ea9, 0xffef0b01
12369};
12370
12371#ifdef UNIQUE_FW_NAME
12372uint32_t fw2400_length02 = 0x000014ff ;
12373#else
12374uint32_t risc_code_length02 = 0x000014ff ;
12375#endif
12376
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 48e460eef05a..2efca52dff50 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -232,7 +232,7 @@ static ssize_t
232qla2x00_isp_name_show(struct class_device *cdev, char *buf) 232qla2x00_isp_name_show(struct class_device *cdev, char *buf)
233{ 233{
234 scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev)); 234 scsi_qla_host_t *ha = to_qla_host(class_to_shost(cdev));
235 return snprintf(buf, PAGE_SIZE, "%s\n", ha->brd_info->isp_name); 235 return snprintf(buf, PAGE_SIZE, "ISP%04X\n", ha->pdev->device);
236} 236}
237 237
238static ssize_t 238static ssize_t
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 7096945ea234..79d8a914f9d0 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -22,6 +22,7 @@
22#include <linux/completion.h> 22#include <linux/completion.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/workqueue.h> 24#include <linux/workqueue.h>
25#include <linux/firmware.h>
25#include <asm/semaphore.h> 26#include <asm/semaphore.h>
26 27
27#include <scsi/scsi.h> 28#include <scsi/scsi.h>
@@ -29,6 +30,7 @@
29#include <scsi/scsi_device.h> 30#include <scsi/scsi_device.h>
30#include <scsi/scsi_cmnd.h> 31#include <scsi/scsi_cmnd.h>
31 32
33#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
32#if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE) 34#if defined(CONFIG_SCSI_QLA21XX) || defined(CONFIG_SCSI_QLA21XX_MODULE)
33#define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100) 35#define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100)
34#else 36#else
@@ -79,9 +81,23 @@
79#define IS_QLA2522(ha) 0 81#define IS_QLA2522(ha) 0
80#endif 82#endif
81 83
84#else /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */
85
86#define IS_QLA2100(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2100)
87#define IS_QLA2200(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2200)
88#define IS_QLA2300(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2300)
89#define IS_QLA2312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2312)
90#define IS_QLA2322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2322)
91#define IS_QLA6312(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6312)
92#define IS_QLA6322(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP6322)
93#define IS_QLA2422(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422)
94#define IS_QLA2432(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432)
95#define IS_QLA2512(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2512)
96#define IS_QLA2522(ha) ((ha)->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2522)
97#endif
98
82#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \ 99#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
83 IS_QLA6312(ha) || IS_QLA6322(ha)) 100 IS_QLA6312(ha) || IS_QLA6322(ha))
84
85#define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha)) 101#define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
86#define IS_QLA25XX(ha) (IS_QLA2512(ha) || IS_QLA2522(ha)) 102#define IS_QLA25XX(ha) (IS_QLA2512(ha) || IS_QLA2522(ha))
87 103
@@ -2124,6 +2140,12 @@ struct qla_board_info {
2124 struct scsi_host_template *sht; 2140 struct scsi_host_template *sht;
2125}; 2141};
2126 2142
2143struct fw_blob {
2144 char *name;
2145 uint32_t segs[4];
2146 const struct firmware *fw;
2147};
2148
2127/* Return data from MBC_GET_ID_LIST call. */ 2149/* Return data from MBC_GET_ID_LIST call. */
2128struct gid_list_info { 2150struct gid_list_info {
2129 uint8_t al_pa; 2151 uint8_t al_pa;
@@ -2476,17 +2498,9 @@ typedef struct scsi_qla_host {
2476 */ 2498 */
2477#define LOOP_TRANSITION(ha) \ 2499#define LOOP_TRANSITION(ha) \
2478 (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \ 2500 (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
2479 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) 2501 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
2480
2481#define LOOP_NOT_READY(ha) \
2482 ((test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
2483 test_bit(ABORT_ISP_ACTIVE, &ha->dpc_flags) || \
2484 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags) || \
2485 test_bit(LOOP_RESYNC_ACTIVE, &ha->dpc_flags)) || \
2486 atomic_read(&ha->loop_state) == LOOP_DOWN) 2502 atomic_read(&ha->loop_state) == LOOP_DOWN)
2487 2503
2488#define LOOP_RDY(ha) (!LOOP_NOT_READY(ha))
2489
2490#define TGT_Q(ha, t) (ha->otgt[t]) 2504#define TGT_Q(ha, t) (ha->otgt[t])
2491 2505
2492#define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata) 2506#define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata)
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index fedcb0d3fc72..bec81adcf4fd 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -33,8 +33,8 @@ extern int qla24xx_nvram_config(struct scsi_qla_host *);
33extern void qla2x00_update_fw_options(struct scsi_qla_host *); 33extern void qla2x00_update_fw_options(struct scsi_qla_host *);
34extern void qla24xx_update_fw_options(scsi_qla_host_t *); 34extern void qla24xx_update_fw_options(scsi_qla_host_t *);
35extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *); 35extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *);
36extern int qla24xx_load_risc(scsi_qla_host_t *, uint32_t *);
36extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *); 37extern int qla24xx_load_risc_flash(scsi_qla_host_t *, uint32_t *);
37extern int qla24xx_load_risc_hotplug(scsi_qla_host_t *, uint32_t *);
38 38
39extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t); 39extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, gfp_t);
40 40
@@ -76,6 +76,8 @@ extern void qla2x00_blink_led(scsi_qla_host_t *);
76 76
77extern int qla2x00_down_timeout(struct semaphore *, unsigned long); 77extern int qla2x00_down_timeout(struct semaphore *, unsigned long);
78 78
79extern struct fw_blob *qla2x00_request_firmware(scsi_qla_host_t *);
80
79/* 81/*
80 * Global Function Prototypes in qla_iocb.c source file. 82 * Global Function Prototypes in qla_iocb.c source file.
81 */ 83 */
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 2d720121a0d3..7d973bd9022b 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -8,7 +8,6 @@
8 8
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/vmalloc.h> 10#include <linux/vmalloc.h>
11#include <linux/firmware.h>
12#include <scsi/scsi_transport_fc.h> 11#include <scsi/scsi_transport_fc.h>
13 12
14#include "qla_devtbl.h" 13#include "qla_devtbl.h"
@@ -1259,7 +1258,7 @@ qla2x00_configure_hba(scsi_qla_host_t *ha)
1259 rval = qla2x00_get_adapter_id(ha, 1258 rval = qla2x00_get_adapter_id(ha,
1260 &loop_id, &al_pa, &area, &domain, &topo); 1259 &loop_id, &al_pa, &area, &domain, &topo);
1261 if (rval != QLA_SUCCESS) { 1260 if (rval != QLA_SUCCESS) {
1262 if (LOOP_NOT_READY(ha) || atomic_read(&ha->loop_down_timer) || 1261 if (LOOP_TRANSITION(ha) || atomic_read(&ha->loop_down_timer) ||
1263 (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) { 1262 (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) {
1264 DEBUG2(printk("%s(%ld) Loop is in a transition state\n", 1263 DEBUG2(printk("%s(%ld) Loop is in a transition state\n",
1265 __func__, ha->host_no)); 1264 __func__, ha->host_no));
@@ -1796,7 +1795,7 @@ qla2x00_configure_loop(scsi_qla_host_t *ha)
1796 } 1795 }
1797 1796
1798 if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) { 1797 if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) {
1799 if (LOOP_NOT_READY(ha)) { 1798 if (LOOP_TRANSITION(ha)) {
1800 rval = QLA_FUNCTION_FAILED; 1799 rval = QLA_FUNCTION_FAILED;
1801 } else { 1800 } else {
1802 rval = qla2x00_configure_fabric(ha); 1801 rval = qla2x00_configure_fabric(ha);
@@ -2369,7 +2368,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2369 if (qla2x00_is_reserved_id(ha, loop_id)) 2368 if (qla2x00_is_reserved_id(ha, loop_id))
2370 continue; 2369 continue;
2371 2370
2372 if (atomic_read(&ha->loop_down_timer) || LOOP_NOT_READY(ha)) 2371 if (atomic_read(&ha->loop_down_timer) || LOOP_TRANSITION(ha))
2373 break; 2372 break;
2374 2373
2375 if (swl != NULL) { 2374 if (swl != NULL) {
@@ -3484,17 +3483,16 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3484 return (rval); 3483 return (rval);
3485} 3484}
3486 3485
3486#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
3487
3487int 3488int
3488qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) 3489qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3489{ 3490{
3490 int rval; 3491 int rval, num, i;
3491 uint16_t cnt; 3492 uint32_t cnt;
3492 uint16_t *risc_code; 3493 uint16_t *risc_code;
3493 unsigned long risc_address; 3494 uint32_t risc_addr, risc_size;
3494 unsigned long risc_code_size; 3495 uint16_t *req_ring;
3495 int num;
3496 int i;
3497 uint16_t *req_ring;
3498 struct qla_fw_info *fw_iter; 3496 struct qla_fw_info *fw_iter;
3499 3497
3500 rval = QLA_SUCCESS; 3498 rval = QLA_SUCCESS;
@@ -3504,37 +3502,29 @@ qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3504 *srisc_addr = *ha->brd_info->fw_info->fwstart; 3502 *srisc_addr = *ha->brd_info->fw_info->fwstart;
3505 while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) { 3503 while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) {
3506 risc_code = fw_iter->fwcode; 3504 risc_code = fw_iter->fwcode;
3507 risc_code_size = *fw_iter->fwlen; 3505 risc_size = *fw_iter->fwlen;
3508 3506 if (fw_iter->addressing == FW_INFO_ADDR_NORMAL)
3509 if (fw_iter->addressing == FW_INFO_ADDR_NORMAL) { 3507 risc_addr = *fw_iter->fwstart;
3510 risc_address = *fw_iter->fwstart; 3508 else
3511 } else { 3509 risc_addr = *fw_iter->lfwstart;
3512 /* Extended address */
3513 risc_address = *fw_iter->lfwstart;
3514 }
3515 3510
3516 num = 0; 3511 num = 0;
3517 rval = 0; 3512 rval = 0;
3518 while (risc_code_size > 0 && !rval) { 3513 while (risc_size > 0 && !rval) {
3519 cnt = (uint16_t)(ha->fw_transfer_size >> 1); 3514 cnt = (uint16_t)(ha->fw_transfer_size >> 1);
3520 if (cnt > risc_code_size) 3515 if (cnt > risc_size)
3521 cnt = risc_code_size; 3516 cnt = risc_size;
3522 3517
3523 DEBUG7(printk("scsi(%ld): Loading risc segment@ " 3518 DEBUG7(printk("scsi(%ld): Loading risc segment@ "
3524 "addr %p, number of bytes 0x%x, offset 0x%lx.\n", 3519 "addr %p, number of bytes 0x%x, offset 0x%lx.\n",
3525 ha->host_no, risc_code, cnt, risc_address)); 3520 ha->host_no, risc_code, cnt, risc_addr));
3526 3521
3527 req_ring = (uint16_t *)ha->request_ring; 3522 req_ring = (uint16_t *)ha->request_ring;
3528 for (i = 0; i < cnt; i++) 3523 for (i = 0; i < cnt; i++)
3529 req_ring[i] = cpu_to_le16(risc_code[i]); 3524 req_ring[i] = cpu_to_le16(risc_code[i]);
3530 3525
3531 if (fw_iter->addressing == FW_INFO_ADDR_NORMAL) { 3526 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3532 rval = qla2x00_load_ram(ha, ha->request_dma, 3527 cnt);
3533 risc_address, cnt);
3534 } else {
3535 rval = qla2x00_load_ram_ext(ha,
3536 ha->request_dma, risc_address, cnt);
3537 }
3538 if (rval) { 3528 if (rval) {
3539 DEBUG(printk("scsi(%ld): [ERROR] Failed to " 3529 DEBUG(printk("scsi(%ld): [ERROR] Failed to "
3540 "load segment %d of firmware\n", 3530 "load segment %d of firmware\n",
@@ -3548,16 +3538,76 @@ qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3548 } 3538 }
3549 3539
3550 risc_code += cnt; 3540 risc_code += cnt;
3551 risc_address += cnt; 3541 risc_addr += cnt;
3552 risc_code_size -= cnt; 3542 risc_size -= cnt;
3553 num++; 3543 num++;
3554 } 3544 }
3555 3545
3556 /* Next firmware sequence */ 3546 /* Next firmware sequence */
3557 fw_iter++; 3547 fw_iter++;
3558 } 3548 }
3549 return rval;
3550}
3559 3551
3560 return (rval); 3552int
3553qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3554{
3555 int rval, num, i;
3556 uint32_t cnt;
3557 uint32_t *risc_code;
3558 uint32_t risc_addr, risc_size;
3559 uint32_t *req_ring;
3560 struct qla_fw_info *fw_iter;
3561
3562 rval = QLA_SUCCESS;
3563
3564 /* Load firmware sequences */
3565 fw_iter = ha->brd_info->fw_info;
3566 *srisc_addr = *((uint32_t *)fw_iter->lfwstart);
3567 while (fw_iter->addressing != FW_INFO_ADDR_NOMORE) {
3568 risc_code = (uint32_t *)fw_iter->fwcode;
3569 risc_size = *((uint32_t *)fw_iter->fwlen);
3570 risc_addr = *((uint32_t *)fw_iter->lfwstart);
3571
3572 num = 0;
3573 rval = 0;
3574 while (risc_size > 0 && !rval) {
3575 cnt = (uint32_t)(ha->fw_transfer_size >> 2);
3576 if (cnt > risc_size)
3577 cnt = risc_size;
3578
3579 DEBUG7(printk("scsi(%ld): Loading risc segment@ "
3580 "addr %p, number of bytes 0x%x, offset 0x%lx.\n",
3581 ha->host_no, risc_code, cnt, risc_addr));
3582
3583 req_ring = (uint32_t *)ha->request_ring;
3584 for (i = 0; i < cnt; i++)
3585 req_ring[i] = cpu_to_le32(risc_code[i]);
3586
3587 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3588 cnt);
3589 if (rval) {
3590 DEBUG(printk("scsi(%ld): [ERROR] Failed to "
3591 "load segment %d of firmware\n",
3592 ha->host_no, num));
3593 qla_printk(KERN_WARNING, ha,
3594 "[ERROR] Failed to load segment %d of "
3595 "firmware\n", num);
3596
3597 qla2x00_dump_regs(ha);
3598 break;
3599 }
3600
3601 risc_code += cnt;
3602 risc_addr += cnt;
3603 risc_size -= cnt;
3604 num++;
3605 }
3606
3607 /* Next firmware sequence */
3608 fw_iter++;
3609 }
3610 return rval;
3561} 3611}
3562 3612
3563int 3613int
@@ -3642,8 +3692,108 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3642 return rval; 3692 return rval;
3643} 3693}
3644 3694
3695#else /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */
3696
3645int 3697int
3646qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr) 3698qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3699{
3700 int rval;
3701 int i, fragment;
3702 uint16_t *wcode, *fwcode;
3703 uint32_t risc_addr, risc_size, fwclen, wlen, *seg;
3704 struct fw_blob *blob;
3705
3706 /* Load firmware blob. */
3707 blob = qla2x00_request_firmware(ha);
3708 if (!blob) {
3709 qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n");
3710 return QLA_FUNCTION_FAILED;
3711 }
3712
3713 rval = QLA_SUCCESS;
3714
3715 wcode = (uint16_t *)ha->request_ring;
3716 *srisc_addr = 0;
3717 fwcode = (uint16_t *)blob->fw->data;
3718 fwclen = 0;
3719
3720 /* Validate firmware image by checking version. */
3721 if (blob->fw->size < 8 * sizeof(uint16_t)) {
3722 qla_printk(KERN_WARNING, ha,
3723 "Unable to verify integrity of firmware image (%Zd)!\n",
3724 blob->fw->size);
3725 goto fail_fw_integrity;
3726 }
3727 for (i = 0; i < 4; i++)
3728 wcode[i] = be16_to_cpu(fwcode[i + 4]);
3729 if ((wcode[0] == 0xffff && wcode[1] == 0xffff && wcode[2] == 0xffff &&
3730 wcode[3] == 0xffff) || (wcode[0] == 0 && wcode[1] == 0 &&
3731 wcode[2] == 0 && wcode[3] == 0)) {
3732 qla_printk(KERN_WARNING, ha,
3733 "Unable to verify integrity of firmware image!\n");
3734 qla_printk(KERN_WARNING, ha,
3735 "Firmware data: %04x %04x %04x %04x!\n", wcode[0],
3736 wcode[1], wcode[2], wcode[3]);
3737 goto fail_fw_integrity;
3738 }
3739
3740 seg = blob->segs;
3741 while (*seg && rval == QLA_SUCCESS) {
3742 risc_addr = *seg;
3743 *srisc_addr = *srisc_addr == 0 ? *seg : *srisc_addr;
3744 risc_size = be16_to_cpu(fwcode[3]);
3745
3746 /* Validate firmware image size. */
3747 fwclen += risc_size * sizeof(uint16_t);
3748 if (blob->fw->size < fwclen) {
3749 qla_printk(KERN_WARNING, ha,
3750 "Unable to verify integrity of firmware image "
3751 "(%Zd)!\n", blob->fw->size);
3752 goto fail_fw_integrity;
3753 }
3754
3755 fragment = 0;
3756 while (risc_size > 0 && rval == QLA_SUCCESS) {
3757 wlen = (uint16_t)(ha->fw_transfer_size >> 1);
3758 if (wlen > risc_size)
3759 wlen = risc_size;
3760
3761 DEBUG7(printk("scsi(%ld): Loading risc segment@ risc "
3762 "addr %x, number of words 0x%x.\n", ha->host_no,
3763 risc_addr, wlen));
3764
3765 for (i = 0; i < wlen; i++)
3766 wcode[i] = swab16(fwcode[i]);
3767
3768 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3769 wlen);
3770 if (rval) {
3771 DEBUG(printk("scsi(%ld):[ERROR] Failed to load "
3772 "segment %d of firmware\n", ha->host_no,
3773 fragment));
3774 qla_printk(KERN_WARNING, ha,
3775 "[ERROR] Failed to load segment %d of "
3776 "firmware\n", fragment);
3777 break;
3778 }
3779
3780 fwcode += wlen;
3781 risc_addr += wlen;
3782 risc_size -= wlen;
3783 fragment++;
3784 }
3785
3786 /* Next segment. */
3787 seg++;
3788 }
3789 return rval;
3790
3791fail_fw_integrity:
3792 return QLA_FUNCTION_FAILED;
3793}
3794
3795int
3796qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3647{ 3797{
3648 int rval; 3798 int rval;
3649 int segments, fragment; 3799 int segments, fragment;
@@ -3651,14 +3801,13 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3651 uint32_t risc_addr; 3801 uint32_t risc_addr;
3652 uint32_t risc_size; 3802 uint32_t risc_size;
3653 uint32_t i; 3803 uint32_t i;
3654 const struct firmware *fw_entry; 3804 struct fw_blob *blob;
3655 uint32_t *fwcode, fwclen; 3805 uint32_t *fwcode, fwclen;
3656 3806
3657 if (request_firmware(&fw_entry, ha->brd_info->fw_fname, 3807 /* Load firmware blob. */
3658 &ha->pdev->dev)) { 3808 blob = qla2x00_request_firmware(ha);
3659 qla_printk(KERN_ERR, ha, 3809 if (!blob) {
3660 "Firmware image file not available: '%s'\n", 3810 qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n");
3661 ha->brd_info->fw_fname);
3662 return QLA_FUNCTION_FAILED; 3811 return QLA_FUNCTION_FAILED;
3663 } 3812 }
3664 3813
@@ -3667,14 +3816,14 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3667 segments = FA_RISC_CODE_SEGMENTS; 3816 segments = FA_RISC_CODE_SEGMENTS;
3668 dcode = (uint32_t *)ha->request_ring; 3817 dcode = (uint32_t *)ha->request_ring;
3669 *srisc_addr = 0; 3818 *srisc_addr = 0;
3670 fwcode = (uint32_t *)fw_entry->data; 3819 fwcode = (uint32_t *)blob->fw->data;
3671 fwclen = 0; 3820 fwclen = 0;
3672 3821
3673 /* Validate firmware image by checking version. */ 3822 /* Validate firmware image by checking version. */
3674 if (fw_entry->size < 8 * sizeof(uint32_t)) { 3823 if (blob->fw->size < 8 * sizeof(uint32_t)) {
3675 qla_printk(KERN_WARNING, ha, 3824 qla_printk(KERN_WARNING, ha,
3676 "Unable to verify integrity of flash firmware image " 3825 "Unable to verify integrity of firmware image (%Zd)!\n",
3677 "(%Zd)!\n", fw_entry->size); 3826 blob->fw->size);
3678 goto fail_fw_integrity; 3827 goto fail_fw_integrity;
3679 } 3828 }
3680 for (i = 0; i < 4; i++) 3829 for (i = 0; i < 4; i++)
@@ -3684,7 +3833,7 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3684 (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && 3833 (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 &&
3685 dcode[3] == 0)) { 3834 dcode[3] == 0)) {
3686 qla_printk(KERN_WARNING, ha, 3835 qla_printk(KERN_WARNING, ha,
3687 "Unable to verify integrity of flash firmware image!\n"); 3836 "Unable to verify integrity of firmware image!\n");
3688 qla_printk(KERN_WARNING, ha, 3837 qla_printk(KERN_WARNING, ha,
3689 "Firmware data: %08x %08x %08x %08x!\n", dcode[0], 3838 "Firmware data: %08x %08x %08x %08x!\n", dcode[0],
3690 dcode[1], dcode[2], dcode[3]); 3839 dcode[1], dcode[2], dcode[3]);
@@ -3698,10 +3847,11 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3698 3847
3699 /* Validate firmware image size. */ 3848 /* Validate firmware image size. */
3700 fwclen += risc_size * sizeof(uint32_t); 3849 fwclen += risc_size * sizeof(uint32_t);
3701 if (fw_entry->size < fwclen) { 3850 if (blob->fw->size < fwclen) {
3702 qla_printk(KERN_WARNING, ha, 3851 qla_printk(KERN_WARNING, ha,
3703 "Unable to verify integrity of flash firmware " 3852 "Unable to verify integrity of firmware image "
3704 "image (%Zd)!\n", fw_entry->size); 3853 "(%Zd)!\n", blob->fw->size);
3854
3705 goto fail_fw_integrity; 3855 goto fail_fw_integrity;
3706 } 3856 }
3707 3857
@@ -3739,13 +3889,9 @@ qla24xx_load_risc_hotplug(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3739 /* Next segment. */ 3889 /* Next segment. */
3740 segments--; 3890 segments--;
3741 } 3891 }
3742
3743 release_firmware(fw_entry);
3744 return rval; 3892 return rval;
3745 3893
3746fail_fw_integrity: 3894fail_fw_integrity:
3747
3748 release_firmware(fw_entry);
3749 return QLA_FUNCTION_FAILED; 3895 return QLA_FUNCTION_FAILED;
3750
3751} 3896}
3897#endif
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 09afc0f06bd4..5181d966fecb 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -909,6 +909,21 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
909 resid = resid_len; 909 resid = resid_len;
910 cp->resid = resid; 910 cp->resid = resid;
911 CMD_RESID_LEN(cp) = resid; 911 CMD_RESID_LEN(cp) = resid;
912
913 if (!lscsi_status &&
914 ((unsigned)(cp->request_bufflen - resid) <
915 cp->underflow)) {
916 qla_printk(KERN_INFO, ha,
917 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
918 "detected (%x of %x bytes)...returning "
919 "error status.\n", ha->host_no,
920 cp->device->channel, cp->device->id,
921 cp->device->lun, resid,
922 cp->request_bufflen);
923
924 cp->result = DID_ERROR << 16;
925 break;
926 }
912 } 927 }
913 cp->result = DID_OK << 16 | lscsi_status; 928 cp->result = DID_OK << 16 | lscsi_status;
914 929
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index c58c9d97b041..24304300d7b5 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -54,10 +54,12 @@ module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
54MODULE_PARM_DESC(ql2xloginretrycount, 54MODULE_PARM_DESC(ql2xloginretrycount,
55 "Specify an alternate value for the NVRAM login retry count."); 55 "Specify an alternate value for the NVRAM login retry count.");
56 56
57int ql2xfwloadbin=1; 57#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
58module_param(ql2xfwloadbin, int, S_IRUGO|S_IRUSR); 58int ql2xfwloadflash;
59MODULE_PARM_DESC(ql2xfwloadbin, 59module_param(ql2xfwloadflash, int, S_IRUGO|S_IRUSR);
60 "Load ISP2xxx firmware image via hotplug."); 60MODULE_PARM_DESC(ql2xfwloadflash,
61 "Load ISP24xx firmware image from FLASH (onboard memory).");
62#endif
61 63
62static void qla2x00_free_device(scsi_qla_host_t *); 64static void qla2x00_free_device(scsi_qla_host_t *);
63 65
@@ -1261,12 +1263,16 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1261 char pci_info[20]; 1263 char pci_info[20];
1262 char fw_str[30]; 1264 char fw_str[30];
1263 fc_port_t *fcport; 1265 fc_port_t *fcport;
1266 struct scsi_host_template *sht;
1264 1267
1265 if (pci_enable_device(pdev)) 1268 if (pci_enable_device(pdev))
1266 goto probe_out; 1269 goto probe_out;
1267 1270
1268 host = scsi_host_alloc(brd_info->sht ? brd_info->sht: 1271 sht = &qla2x00_driver_template;
1269 &qla2x00_driver_template, sizeof(scsi_qla_host_t)); 1272 if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 ||
1273 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432)
1274 sht = &qla24xx_driver_template;
1275 host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t));
1270 if (host == NULL) { 1276 if (host == NULL) {
1271 printk(KERN_WARNING 1277 printk(KERN_WARNING
1272 "qla2xxx: Couldn't allocate host from scsi layer!\n"); 1278 "qla2xxx: Couldn't allocate host from scsi layer!\n");
@@ -1291,8 +1297,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1291 goto probe_failed; 1297 goto probe_failed;
1292 1298
1293 qla_printk(KERN_INFO, ha, 1299 qla_printk(KERN_INFO, ha,
1294 "Found an %s, irq %d, iobase 0x%p\n", ha->brd_info->isp_name, 1300 "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev->device, pdev->irq,
1295 pdev->irq, ha->iobase); 1301 ha->iobase);
1296 1302
1297 spin_lock_init(&ha->hardware_lock); 1303 spin_lock_init(&ha->hardware_lock);
1298 1304
@@ -1368,9 +1374,11 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1368 ha->isp_ops.reset_adapter = qla24xx_reset_adapter; 1374 ha->isp_ops.reset_adapter = qla24xx_reset_adapter;
1369 ha->isp_ops.nvram_config = qla24xx_nvram_config; 1375 ha->isp_ops.nvram_config = qla24xx_nvram_config;
1370 ha->isp_ops.update_fw_options = qla24xx_update_fw_options; 1376 ha->isp_ops.update_fw_options = qla24xx_update_fw_options;
1371 ha->isp_ops.load_risc = qla24xx_load_risc_flash; 1377 ha->isp_ops.load_risc = qla24xx_load_risc;
1372 if (ql2xfwloadbin) 1378#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
1373 ha->isp_ops.load_risc = qla24xx_load_risc_hotplug; 1379 if (ql2xfwloadflash)
1380 ha->isp_ops.load_risc = qla24xx_load_risc_flash;
1381#endif
1374 ha->isp_ops.pci_info_str = qla24xx_pci_info_str; 1382 ha->isp_ops.pci_info_str = qla24xx_pci_info_str;
1375 ha->isp_ops.fw_version_str = qla24xx_fw_version_str; 1383 ha->isp_ops.fw_version_str = qla24xx_fw_version_str;
1376 ha->isp_ops.intr_handler = qla24xx_intr_handler; 1384 ha->isp_ops.intr_handler = qla24xx_intr_handler;
@@ -1531,11 +1539,12 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1531 qla_printk(KERN_INFO, ha, "\n" 1539 qla_printk(KERN_INFO, ha, "\n"
1532 " QLogic Fibre Channel HBA Driver: %s\n" 1540 " QLogic Fibre Channel HBA Driver: %s\n"
1533 " QLogic %s - %s\n" 1541 " QLogic %s - %s\n"
1534 " %s: %s @ %s hdma%c, host#=%ld, fw=%s\n", qla2x00_version_str, 1542 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
1535 ha->model_number, ha->model_desc ? ha->model_desc: "", 1543 qla2x00_version_str, ha->model_number,
1536 ha->brd_info->isp_name, ha->isp_ops.pci_info_str(ha, pci_info), 1544 ha->model_desc ? ha->model_desc: "", pdev->device,
1537 pci_name(pdev), ha->flags.enable_64bit_addressing ? '+': '-', 1545 ha->isp_ops.pci_info_str(ha, pci_info), pci_name(pdev),
1538 ha->host_no, ha->isp_ops.fw_version_str(ha, fw_str)); 1546 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no,
1547 ha->isp_ops.fw_version_str(ha, fw_str));
1539 1548
1540 /* Go with fc_rport registration. */ 1549 /* Go with fc_rport registration. */
1541 list_for_each_entry(fcport, &ha->fcports, list) 1550 list_for_each_entry(fcport, &ha->fcports, list)
@@ -2483,45 +2492,115 @@ qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
2483 return -ETIMEDOUT; 2492 return -ETIMEDOUT;
2484} 2493}
2485 2494
2486static struct qla_board_info qla_board_tbl[] = { 2495#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
2487 { 2496
2488 .drv_name = "qla2400", 2497#define qla2x00_release_firmware() do { } while (0)
2489 .isp_name = "ISP2422", 2498#define qla2x00_pci_module_init() (0)
2490 .fw_fname = "ql2400_fw.bin", 2499#define qla2x00_pci_module_exit() do { } while (0)
2491 .sht = &qla24xx_driver_template, 2500
2492 }, 2501#else /* !defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE) */
2493 { 2502
2494 .drv_name = "qla2400", 2503/* Firmware interface routines. */
2495 .isp_name = "ISP2432", 2504
2496 .fw_fname = "ql2400_fw.bin", 2505#define FW_BLOBS 6
2497 .sht = &qla24xx_driver_template, 2506#define FW_ISP21XX 0
2498 }, 2507#define FW_ISP22XX 1
2508#define FW_ISP2300 2
2509#define FW_ISP2322 3
2510#define FW_ISP63XX 4
2511#define FW_ISP24XX 5
2512
2513static DECLARE_MUTEX(qla_fw_lock);
2514
2515static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
2516 { .name = "ql2100_fw.bin", .segs = { 0x1000, 0 }, },
2517 { .name = "ql2200_fw.bin", .segs = { 0x1000, 0 }, },
2518 { .name = "ql2300_fw.bin", .segs = { 0x800, 0 }, },
2519 { .name = "ql2322_fw.bin", .segs = { 0x800, 0x1c000, 0x1e000, 0 }, },
2520 { .name = "ql6312_fw.bin", .segs = { 0x800, 0 }, },
2521 { .name = "ql2400_fw.bin", },
2522};
2523
2524struct fw_blob *
2525qla2x00_request_firmware(scsi_qla_host_t *ha)
2526{
2527 struct fw_blob *blob;
2528
2529 blob = NULL;
2530 if (IS_QLA2100(ha)) {
2531 blob = &qla_fw_blobs[FW_ISP21XX];
2532 } else if (IS_QLA2200(ha)) {
2533 blob = &qla_fw_blobs[FW_ISP22XX];
2534 } else if (IS_QLA2300(ha) || IS_QLA2312(ha)) {
2535 blob = &qla_fw_blobs[FW_ISP2300];
2536 } else if (IS_QLA2322(ha)) {
2537 blob = &qla_fw_blobs[FW_ISP2322];
2538 } else if (IS_QLA6312(ha) || IS_QLA6322(ha)) {
2539 blob = &qla_fw_blobs[FW_ISP63XX];
2540 } else if (IS_QLA24XX(ha)) {
2541 blob = &qla_fw_blobs[FW_ISP24XX];
2542 }
2543
2544 down(&qla_fw_lock);
2545 if (blob->fw)
2546 goto out;
2547
2548 if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) {
2549 DEBUG2(printk("scsi(%ld): Failed to load firmware image "
2550 "(%s).\n", ha->host_no, blob->name));
2551 blob->fw = NULL;
2552 blob = NULL;
2553 goto out;
2554 }
2555
2556out:
2557 up(&qla_fw_lock);
2558 return blob;
2559}
2560
2561static void
2562qla2x00_release_firmware(void)
2563{
2564 int idx;
2565
2566 down(&qla_fw_lock);
2567 for (idx = 0; idx < FW_BLOBS; idx++)
2568 if (qla_fw_blobs[idx].fw)
2569 release_firmware(qla_fw_blobs[idx].fw);
2570 up(&qla_fw_lock);
2571}
2572
2573static struct qla_board_info qla_board_tbl = {
2574 .drv_name = "qla2xxx",
2499}; 2575};
2500 2576
2501static struct pci_device_id qla2xxx_pci_tbl[] = { 2577static struct pci_device_id qla2xxx_pci_tbl[] = {
2502 { 2578 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100,
2503 .vendor = PCI_VENDOR_ID_QLOGIC, 2579 PCI_ANY_ID, PCI_ANY_ID, },
2504 .device = PCI_DEVICE_ID_QLOGIC_ISP2422, 2580 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200,
2505 .subvendor = PCI_ANY_ID, 2581 PCI_ANY_ID, PCI_ANY_ID, },
2506 .subdevice = PCI_ANY_ID, 2582 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300,
2507 .driver_data = (unsigned long)&qla_board_tbl[0], 2583 PCI_ANY_ID, PCI_ANY_ID, },
2508 }, 2584 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312,
2509 { 2585 PCI_ANY_ID, PCI_ANY_ID, },
2510 .vendor = PCI_VENDOR_ID_QLOGIC, 2586 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322,
2511 .device = PCI_DEVICE_ID_QLOGIC_ISP2432, 2587 PCI_ANY_ID, PCI_ANY_ID, },
2512 .subvendor = PCI_ANY_ID, 2588 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312,
2513 .subdevice = PCI_ANY_ID, 2589 PCI_ANY_ID, PCI_ANY_ID, },
2514 .driver_data = (unsigned long)&qla_board_tbl[1], 2590 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322,
2515 }, 2591 PCI_ANY_ID, PCI_ANY_ID, },
2516 {0, 0}, 2592 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422,
2593 PCI_ANY_ID, PCI_ANY_ID, },
2594 { PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432,
2595 PCI_ANY_ID, PCI_ANY_ID, },
2596 { 0 },
2517}; 2597};
2518MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); 2598MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
2519 2599
2520static int __devinit 2600static int __devinit
2521qla2xxx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) 2601qla2xxx_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
2522{ 2602{
2523 return qla2x00_probe_one(pdev, 2603 return qla2x00_probe_one(pdev, &qla_board_tbl);
2524 (struct qla_board_info *)id->driver_data);
2525} 2604}
2526 2605
2527static void __devexit 2606static void __devexit
@@ -2532,11 +2611,28 @@ qla2xxx_remove_one(struct pci_dev *pdev)
2532 2611
2533static struct pci_driver qla2xxx_pci_driver = { 2612static struct pci_driver qla2xxx_pci_driver = {
2534 .name = "qla2xxx", 2613 .name = "qla2xxx",
2614 .driver = {
2615 .owner = THIS_MODULE,
2616 },
2535 .id_table = qla2xxx_pci_tbl, 2617 .id_table = qla2xxx_pci_tbl,
2536 .probe = qla2xxx_probe_one, 2618 .probe = qla2xxx_probe_one,
2537 .remove = __devexit_p(qla2xxx_remove_one), 2619 .remove = __devexit_p(qla2xxx_remove_one),
2538}; 2620};
2539 2621
2622static inline int
2623qla2x00_pci_module_init(void)
2624{
2625 return pci_module_init(&qla2xxx_pci_driver);
2626}
2627
2628static inline void
2629qla2x00_pci_module_exit(void)
2630{
2631 pci_unregister_driver(&qla2xxx_pci_driver);
2632}
2633
2634#endif
2635
2540/** 2636/**
2541 * qla2x00_module_init - Module initialization. 2637 * qla2x00_module_init - Module initialization.
2542 **/ 2638 **/
@@ -2556,6 +2652,9 @@ qla2x00_module_init(void)
2556 2652
2557 /* Derive version string. */ 2653 /* Derive version string. */
2558 strcpy(qla2x00_version_str, QLA2XXX_VERSION); 2654 strcpy(qla2x00_version_str, QLA2XXX_VERSION);
2655#if defined(CONFIG_SCSI_QLA2XXX_EMBEDDED_FIRMWARE)
2656 strcat(qla2x00_version_str, "-fw");
2657#endif
2559#if DEBUG_QLA2100 2658#if DEBUG_QLA2100
2560 strcat(qla2x00_version_str, "-debug"); 2659 strcat(qla2x00_version_str, "-debug");
2561#endif 2660#endif
@@ -2565,7 +2664,7 @@ qla2x00_module_init(void)
2565 return -ENODEV; 2664 return -ENODEV;
2566 2665
2567 printk(KERN_INFO "QLogic Fibre Channel HBA Driver\n"); 2666 printk(KERN_INFO "QLogic Fibre Channel HBA Driver\n");
2568 ret = pci_module_init(&qla2xxx_pci_driver); 2667 ret = qla2x00_pci_module_init();
2569 if (ret) { 2668 if (ret) {
2570 kmem_cache_destroy(srb_cachep); 2669 kmem_cache_destroy(srb_cachep);
2571 fc_release_transport(qla2xxx_transport_template); 2670 fc_release_transport(qla2xxx_transport_template);
@@ -2579,7 +2678,8 @@ qla2x00_module_init(void)
2579static void __exit 2678static void __exit
2580qla2x00_module_exit(void) 2679qla2x00_module_exit(void)
2581{ 2680{
2582 pci_unregister_driver(&qla2xxx_pci_driver); 2681 qla2x00_pci_module_exit();
2682 qla2x00_release_firmware();
2583 kmem_cache_destroy(srb_cachep); 2683 kmem_cache_destroy(srb_cachep);
2584 fc_release_transport(qla2xxx_transport_template); 2684 fc_release_transport(qla2xxx_transport_template);
2585} 2685}
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c
index 5b1c12041a4f..5ec5f44602ac 100644
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -115,7 +115,7 @@ static DECLARE_TRANSPORT_CLASS(raid_class,
115 raid_remove, 115 raid_remove,
116 NULL); 116 NULL);
117 117
118static struct { 118static const struct {
119 enum raid_state value; 119 enum raid_state value;
120 char *name; 120 char *name;
121} raid_states[] = { 121} raid_states[] = {
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index ab7432a5778e..cd54244058b5 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -86,7 +86,8 @@ enum {
86 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ 86 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */
87 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ 87 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */
88 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 88 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
89 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO), 89 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
90 ATA_FLAG_NO_ATAPI),
90 MV_6XXX_FLAGS = MV_FLAG_IRQ_COALESCE, 91 MV_6XXX_FLAGS = MV_FLAG_IRQ_COALESCE,
91 92
92 CRQB_FLAG_READ = (1 << 0), 93 CRQB_FLAG_READ = (1 << 0),
@@ -373,7 +374,6 @@ static struct scsi_host_template mv_sht = {
373 .dma_boundary = MV_DMA_BOUNDARY, 374 .dma_boundary = MV_DMA_BOUNDARY,
374 .slave_configure = ata_scsi_slave_config, 375 .slave_configure = ata_scsi_slave_config,
375 .bios_param = ata_std_bios_param, 376 .bios_param = ata_std_bios_param,
376 .ordered_flush = 1,
377}; 377};
378 378
379static const struct ata_port_operations mv5_ops = { 379static const struct ata_port_operations mv5_ops = {
@@ -430,7 +430,7 @@ static const struct ata_port_operations mv6_ops = {
430 .host_stop = mv_host_stop, 430 .host_stop = mv_host_stop,
431}; 431};
432 432
433static struct ata_port_info mv_port_info[] = { 433static const struct ata_port_info mv_port_info[] = {
434 { /* chip_504x */ 434 { /* chip_504x */
435 .sht = &mv_sht, 435 .sht = &mv_sht,
436 .host_flags = MV_COMMON_FLAGS, 436 .host_flags = MV_COMMON_FLAGS,
@@ -1242,8 +1242,10 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1242 VPRINTK("port %u IRQ found for qc, " 1242 VPRINTK("port %u IRQ found for qc, "
1243 "ata_status 0x%x\n", port,ata_status); 1243 "ata_status 0x%x\n", port,ata_status);
1244 /* mark qc status appropriately */ 1244 /* mark qc status appropriately */
1245 if (!(qc->tf.ctl & ATA_NIEN)) 1245 if (!(qc->tf.ctl & ATA_NIEN)) {
1246 ata_qc_complete(qc, err_mask); 1246 qc->err_mask |= err_mask;
1247 ata_qc_complete(qc);
1248 }
1247 } 1249 }
1248 } 1250 }
1249 } 1251 }
@@ -1864,7 +1866,8 @@ static void mv_eng_timeout(struct ata_port *ap)
1864 */ 1866 */
1865 spin_lock_irqsave(&ap->host_set->lock, flags); 1867 spin_lock_irqsave(&ap->host_set->lock, flags);
1866 qc->scsidone = scsi_finish_command; 1868 qc->scsidone = scsi_finish_command;
1867 ata_qc_complete(qc, AC_ERR_OTHER); 1869 qc->err_mask |= AC_ERR_OTHER;
1870 ata_qc_complete(qc);
1868 spin_unlock_irqrestore(&ap->host_set->lock, flags); 1871 spin_unlock_irqrestore(&ap->host_set->lock, flags);
1869 } 1872 }
1870} 1873}
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 4954896dfdb9..c0cf52cb975a 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -235,7 +235,6 @@ static struct scsi_host_template nv_sht = {
235 .dma_boundary = ATA_DMA_BOUNDARY, 235 .dma_boundary = ATA_DMA_BOUNDARY,
236 .slave_configure = ata_scsi_slave_config, 236 .slave_configure = ata_scsi_slave_config,
237 .bios_param = ata_std_bios_param, 237 .bios_param = ata_std_bios_param,
238 .ordered_flush = 1,
239}; 238};
240 239
241static const struct ata_port_operations nv_ops = { 240static const struct ata_port_operations nv_ops = {
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 8a8e3e3ef0ed..3d1ea09a06a1 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -70,6 +70,9 @@ enum {
70 PDC_HAS_PATA = (1 << 1), /* PDC20375 has PATA */ 70 PDC_HAS_PATA = (1 << 1), /* PDC20375 has PATA */
71 71
72 PDC_RESET = (1 << 11), /* HDMA reset */ 72 PDC_RESET = (1 << 11), /* HDMA reset */
73
74 PDC_COMMON_FLAGS = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST |
75 ATA_FLAG_MMIO | ATA_FLAG_NO_ATAPI,
73}; 76};
74 77
75 78
@@ -111,7 +114,6 @@ static struct scsi_host_template pdc_ata_sht = {
111 .dma_boundary = ATA_DMA_BOUNDARY, 114 .dma_boundary = ATA_DMA_BOUNDARY,
112 .slave_configure = ata_scsi_slave_config, 115 .slave_configure = ata_scsi_slave_config,
113 .bios_param = ata_std_bios_param, 116 .bios_param = ata_std_bios_param,
114 .ordered_flush = 1,
115}; 117};
116 118
117static const struct ata_port_operations pdc_sata_ops = { 119static const struct ata_port_operations pdc_sata_ops = {
@@ -158,12 +160,11 @@ static const struct ata_port_operations pdc_pata_ops = {
158 .host_stop = ata_pci_host_stop, 160 .host_stop = ata_pci_host_stop,
159}; 161};
160 162
161static struct ata_port_info pdc_port_info[] = { 163static const struct ata_port_info pdc_port_info[] = {
162 /* board_2037x */ 164 /* board_2037x */
163 { 165 {
164 .sht = &pdc_ata_sht, 166 .sht = &pdc_ata_sht,
165 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 167 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
166 ATA_FLAG_SRST | ATA_FLAG_MMIO,
167 .pio_mask = 0x1f, /* pio0-4 */ 168 .pio_mask = 0x1f, /* pio0-4 */
168 .mwdma_mask = 0x07, /* mwdma0-2 */ 169 .mwdma_mask = 0x07, /* mwdma0-2 */
169 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 170 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -173,8 +174,7 @@ static struct ata_port_info pdc_port_info[] = {
173 /* board_20319 */ 174 /* board_20319 */
174 { 175 {
175 .sht = &pdc_ata_sht, 176 .sht = &pdc_ata_sht,
176 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 177 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
177 ATA_FLAG_SRST | ATA_FLAG_MMIO,
178 .pio_mask = 0x1f, /* pio0-4 */ 178 .pio_mask = 0x1f, /* pio0-4 */
179 .mwdma_mask = 0x07, /* mwdma0-2 */ 179 .mwdma_mask = 0x07, /* mwdma0-2 */
180 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 180 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -184,8 +184,7 @@ static struct ata_port_info pdc_port_info[] = {
184 /* board_20619 */ 184 /* board_20619 */
185 { 185 {
186 .sht = &pdc_ata_sht, 186 .sht = &pdc_ata_sht,
187 .host_flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST | 187 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS,
188 ATA_FLAG_MMIO | ATA_FLAG_SLAVE_POSS,
189 .pio_mask = 0x1f, /* pio0-4 */ 188 .pio_mask = 0x1f, /* pio0-4 */
190 .mwdma_mask = 0x07, /* mwdma0-2 */ 189 .mwdma_mask = 0x07, /* mwdma0-2 */
191 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 190 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -401,7 +400,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
401 case ATA_PROT_NODATA: 400 case ATA_PROT_NODATA:
402 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 401 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
403 drv_stat = ata_wait_idle(ap); 402 drv_stat = ata_wait_idle(ap);
404 ata_qc_complete(qc, __ac_err_mask(drv_stat)); 403 qc->err_mask |= __ac_err_mask(drv_stat);
404 ata_qc_complete(qc);
405 break; 405 break;
406 406
407 default: 407 default:
@@ -410,7 +410,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
410 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", 410 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
411 ap->id, qc->tf.command, drv_stat); 411 ap->id, qc->tf.command, drv_stat);
412 412
413 ata_qc_complete(qc, ac_err_mask(drv_stat)); 413 qc->err_mask |= ac_err_mask(drv_stat);
414 ata_qc_complete(qc);
414 break; 415 break;
415 } 416 }
416 417
@@ -422,21 +423,21 @@ out:
422static inline unsigned int pdc_host_intr( struct ata_port *ap, 423static inline unsigned int pdc_host_intr( struct ata_port *ap,
423 struct ata_queued_cmd *qc) 424 struct ata_queued_cmd *qc)
424{ 425{
425 unsigned int handled = 0, err_mask = 0; 426 unsigned int handled = 0;
426 u32 tmp; 427 u32 tmp;
427 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL; 428 void __iomem *mmio = (void __iomem *) ap->ioaddr.cmd_addr + PDC_GLOBAL_CTL;
428 429
429 tmp = readl(mmio); 430 tmp = readl(mmio);
430 if (tmp & PDC_ERR_MASK) { 431 if (tmp & PDC_ERR_MASK) {
431 err_mask = AC_ERR_DEV; 432 qc->err_mask |= AC_ERR_DEV;
432 pdc_reset_port(ap); 433 pdc_reset_port(ap);
433 } 434 }
434 435
435 switch (qc->tf.protocol) { 436 switch (qc->tf.protocol) {
436 case ATA_PROT_DMA: 437 case ATA_PROT_DMA:
437 case ATA_PROT_NODATA: 438 case ATA_PROT_NODATA:
438 err_mask |= ac_err_mask(ata_wait_idle(ap)); 439 qc->err_mask |= ac_err_mask(ata_wait_idle(ap));
439 ata_qc_complete(qc, err_mask); 440 ata_qc_complete(qc);
440 handled = 1; 441 handled = 1;
441 break; 442 break;
442 443
@@ -703,7 +704,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
703 probe_ent->port[3].scr_addr = base + 0x700; 704 probe_ent->port[3].scr_addr = base + 0x700;
704 break; 705 break;
705 case board_2037x: 706 case board_2037x:
706 probe_ent->n_ports = 2; 707 probe_ent->n_ports = 2;
707 break; 708 break;
708 case board_20619: 709 case board_20619:
709 probe_ent->n_ports = 4; 710 probe_ent->n_ports = 4;
@@ -713,7 +714,7 @@ static int pdc_ata_init_one (struct pci_dev *pdev, const struct pci_device_id *e
713 714
714 probe_ent->port[2].scr_addr = base + 0x600; 715 probe_ent->port[2].scr_addr = base + 0x600;
715 probe_ent->port[3].scr_addr = base + 0x700; 716 probe_ent->port[3].scr_addr = base + 0x700;
716 break; 717 break;
717 default: 718 default:
718 BUG(); 719 BUG();
719 break; 720 break;
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index a8987f5ff5cc..de05e2883f9c 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -170,7 +170,7 @@ static const struct ata_port_operations qs_ata_ops = {
170 .bmdma_status = qs_bmdma_status, 170 .bmdma_status = qs_bmdma_status,
171}; 171};
172 172
173static struct ata_port_info qs_port_info[] = { 173static const struct ata_port_info qs_port_info[] = {
174 /* board_2068_idx */ 174 /* board_2068_idx */
175 { 175 {
176 .sht = &qs_ata_sht, 176 .sht = &qs_ata_sht,
@@ -409,8 +409,8 @@ static inline unsigned int qs_intr_pkt(struct ata_host_set *host_set)
409 case 3: /* device error */ 409 case 3: /* device error */
410 pp->state = qs_state_idle; 410 pp->state = qs_state_idle;
411 qs_enter_reg_mode(qc->ap); 411 qs_enter_reg_mode(qc->ap);
412 ata_qc_complete(qc, 412 qc->err_mask |= ac_err_mask(sDST);
413 ac_err_mask(sDST)); 413 ata_qc_complete(qc);
414 break; 414 break;
415 default: 415 default:
416 break; 416 break;
@@ -447,7 +447,8 @@ static inline unsigned int qs_intr_mmio(struct ata_host_set *host_set)
447 447
448 /* complete taskfile transaction */ 448 /* complete taskfile transaction */
449 pp->state = qs_state_idle; 449 pp->state = qs_state_idle;
450 ata_qc_complete(qc, ac_err_mask(status)); 450 qc->err_mask |= ac_err_mask(status);
451 ata_qc_complete(qc);
451 handled = 1; 452 handled = 1;
452 } 453 }
453 } 454 }
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 36091868560d..b017f85e6d6a 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -147,7 +147,6 @@ static struct scsi_host_template sil_sht = {
147 .dma_boundary = ATA_DMA_BOUNDARY, 147 .dma_boundary = ATA_DMA_BOUNDARY,
148 .slave_configure = ata_scsi_slave_config, 148 .slave_configure = ata_scsi_slave_config,
149 .bios_param = ata_std_bios_param, 149 .bios_param = ata_std_bios_param,
150 .ordered_flush = 1,
151}; 150};
152 151
153static const struct ata_port_operations sil_ops = { 152static const struct ata_port_operations sil_ops = {
@@ -176,7 +175,7 @@ static const struct ata_port_operations sil_ops = {
176 .host_stop = ata_pci_host_stop, 175 .host_stop = ata_pci_host_stop,
177}; 176};
178 177
179static struct ata_port_info sil_port_info[] = { 178static const struct ata_port_info sil_port_info[] = {
180 /* sil_3112 */ 179 /* sil_3112 */
181 { 180 {
182 .sht = &sil_sht, 181 .sht = &sil_sht,
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index e0d6f194f54f..923130185a9e 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -292,7 +292,6 @@ static struct scsi_host_template sil24_sht = {
292 .dma_boundary = ATA_DMA_BOUNDARY, 292 .dma_boundary = ATA_DMA_BOUNDARY,
293 .slave_configure = ata_scsi_slave_config, 293 .slave_configure = ata_scsi_slave_config,
294 .bios_param = ata_std_bios_param, 294 .bios_param = ata_std_bios_param,
295 .ordered_flush = 1, /* NCQ not supported yet */
296}; 295};
297 296
298static const struct ata_port_operations sil24_ops = { 297static const struct ata_port_operations sil24_ops = {
@@ -654,7 +653,8 @@ static void sil24_eng_timeout(struct ata_port *ap)
654 */ 653 */
655 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 654 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
656 qc->scsidone = scsi_finish_command; 655 qc->scsidone = scsi_finish_command;
657 ata_qc_complete(qc, AC_ERR_OTHER); 656 qc->err_mask |= AC_ERR_OTHER;
657 ata_qc_complete(qc);
658 658
659 sil24_reset_controller(ap); 659 sil24_reset_controller(ap);
660} 660}
@@ -711,8 +711,10 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
711 sil24_reset_controller(ap); 711 sil24_reset_controller(ap);
712 } 712 }
713 713
714 if (qc) 714 if (qc) {
715 ata_qc_complete(qc, err_mask); 715 qc->err_mask |= err_mask;
716 ata_qc_complete(qc);
717 }
716} 718}
717 719
718static inline void sil24_host_intr(struct ata_port *ap) 720static inline void sil24_host_intr(struct ata_port *ap)
@@ -734,8 +736,10 @@ static inline void sil24_host_intr(struct ata_port *ap)
734 */ 736 */
735 sil24_update_tf(ap); 737 sil24_update_tf(ap);
736 738
737 if (qc) 739 if (qc) {
738 ata_qc_complete(qc, ac_err_mask(pp->tf.command)); 740 qc->err_mask |= ac_err_mask(pp->tf.command);
741 ata_qc_complete(qc);
742 }
739 } else 743 } else
740 sil24_error_intr(ap, slot_stat); 744 sil24_error_intr(ap, slot_stat);
741} 745}
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index 32e12620b162..2df8c5632ac3 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -99,7 +99,6 @@ static struct scsi_host_template sis_sht = {
99 .dma_boundary = ATA_DMA_BOUNDARY, 99 .dma_boundary = ATA_DMA_BOUNDARY,
100 .slave_configure = ata_scsi_slave_config, 100 .slave_configure = ata_scsi_slave_config,
101 .bios_param = ata_std_bios_param, 101 .bios_param = ata_std_bios_param,
102 .ordered_flush = 1,
103}; 102};
104 103
105static const struct ata_port_operations sis_ops = { 104static const struct ata_port_operations sis_ops = {
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 6e7f7c83a75a..668373590aa4 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -303,7 +303,6 @@ static struct scsi_host_template k2_sata_sht = {
303 .proc_info = k2_sata_proc_info, 303 .proc_info = k2_sata_proc_info,
304#endif 304#endif
305 .bios_param = ata_std_bios_param, 305 .bios_param = ata_std_bios_param,
306 .ordered_flush = 1,
307}; 306};
308 307
309 308
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index dcc3ad9a9d6e..bc87c16c80d2 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -194,7 +194,6 @@ static struct scsi_host_template pdc_sata_sht = {
194 .dma_boundary = ATA_DMA_BOUNDARY, 194 .dma_boundary = ATA_DMA_BOUNDARY,
195 .slave_configure = ata_scsi_slave_config, 195 .slave_configure = ata_scsi_slave_config,
196 .bios_param = ata_std_bios_param, 196 .bios_param = ata_std_bios_param,
197 .ordered_flush = 1,
198}; 197};
199 198
200static const struct ata_port_operations pdc_20621_ops = { 199static const struct ata_port_operations pdc_20621_ops = {
@@ -215,12 +214,13 @@ static const struct ata_port_operations pdc_20621_ops = {
215 .host_stop = pdc20621_host_stop, 214 .host_stop = pdc20621_host_stop,
216}; 215};
217 216
218static struct ata_port_info pdc_port_info[] = { 217static const struct ata_port_info pdc_port_info[] = {
219 /* board_20621 */ 218 /* board_20621 */
220 { 219 {
221 .sht = &pdc_sata_sht, 220 .sht = &pdc_sata_sht,
222 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 221 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
223 ATA_FLAG_SRST | ATA_FLAG_MMIO, 222 ATA_FLAG_SRST | ATA_FLAG_MMIO |
223 ATA_FLAG_NO_ATAPI,
224 .pio_mask = 0x1f, /* pio0-4 */ 224 .pio_mask = 0x1f, /* pio0-4 */
225 .mwdma_mask = 0x07, /* mwdma0-2 */ 225 .mwdma_mask = 0x07, /* mwdma0-2 */
226 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 226 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -718,7 +718,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
718 VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id, 718 VPRINTK("ata%u: read hdma, 0x%x 0x%x\n", ap->id,
719 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); 719 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
720 /* get drive status; clear intr; complete txn */ 720 /* get drive status; clear intr; complete txn */
721 ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); 721 qc->err_mask |= ac_err_mask(ata_wait_idle(ap));
722 ata_qc_complete(qc);
722 pdc20621_pop_hdma(qc); 723 pdc20621_pop_hdma(qc);
723 } 724 }
724 725
@@ -756,7 +757,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
756 VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id, 757 VPRINTK("ata%u: write ata, 0x%x 0x%x\n", ap->id,
757 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT)); 758 readl(mmio + 0x104), readl(mmio + PDC_HDMA_CTLSTAT));
758 /* get drive status; clear intr; complete txn */ 759 /* get drive status; clear intr; complete txn */
759 ata_qc_complete(qc, ac_err_mask(ata_wait_idle(ap))); 760 qc->err_mask |= ac_err_mask(ata_wait_idle(ap));
761 ata_qc_complete(qc);
760 pdc20621_pop_hdma(qc); 762 pdc20621_pop_hdma(qc);
761 } 763 }
762 handled = 1; 764 handled = 1;
@@ -766,7 +768,8 @@ static inline unsigned int pdc20621_host_intr( struct ata_port *ap,
766 768
767 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); 769 status = ata_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
768 DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status); 770 DPRINTK("BUS_NODATA (drv_stat 0x%X)\n", status);
769 ata_qc_complete(qc, ac_err_mask(status)); 771 qc->err_mask |= ac_err_mask(status);
772 ata_qc_complete(qc);
770 handled = 1; 773 handled = 1;
771 774
772 } else { 775 } else {
@@ -881,7 +884,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
881 case ATA_PROT_DMA: 884 case ATA_PROT_DMA:
882 case ATA_PROT_NODATA: 885 case ATA_PROT_NODATA:
883 printk(KERN_ERR "ata%u: command timeout\n", ap->id); 886 printk(KERN_ERR "ata%u: command timeout\n", ap->id);
884 ata_qc_complete(qc, __ac_err_mask(ata_wait_idle(ap))); 887 qc->err_mask |= __ac_err_mask(ata_wait_idle(ap));
888 ata_qc_complete(qc);
885 break; 889 break;
886 890
887 default: 891 default:
@@ -890,7 +894,8 @@ static void pdc_eng_timeout(struct ata_port *ap)
890 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n", 894 printk(KERN_ERR "ata%u: unknown timeout, cmd 0x%x stat 0x%x\n",
891 ap->id, qc->tf.command, drv_stat); 895 ap->id, qc->tf.command, drv_stat);
892 896
893 ata_qc_complete(qc, ac_err_mask(drv_stat)); 897 qc->err_mask |= ac_err_mask(drv_stat);
898 ata_qc_complete(qc);
894 break; 899 break;
895 } 900 }
896 901
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index b2422a0f25c8..9635ca700977 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -87,7 +87,6 @@ static struct scsi_host_template uli_sht = {
87 .dma_boundary = ATA_DMA_BOUNDARY, 87 .dma_boundary = ATA_DMA_BOUNDARY,
88 .slave_configure = ata_scsi_slave_config, 88 .slave_configure = ata_scsi_slave_config,
89 .bios_param = ata_std_bios_param, 89 .bios_param = ata_std_bios_param,
90 .ordered_flush = 1,
91}; 90};
92 91
93static const struct ata_port_operations uli_ops = { 92static const struct ata_port_operations uli_ops = {
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index c76215692da2..6d5b0a794cfd 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -106,7 +106,6 @@ static struct scsi_host_template svia_sht = {
106 .dma_boundary = ATA_DMA_BOUNDARY, 106 .dma_boundary = ATA_DMA_BOUNDARY,
107 .slave_configure = ata_scsi_slave_config, 107 .slave_configure = ata_scsi_slave_config,
108 .bios_param = ata_std_bios_param, 108 .bios_param = ata_std_bios_param,
109 .ordered_flush = 1,
110}; 109};
111 110
112static const struct ata_port_operations svia_sata_ops = { 111static const struct ata_port_operations svia_sata_ops = {
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index fcfa486965b4..2e2c3b7acb0c 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -235,7 +235,6 @@ static struct scsi_host_template vsc_sata_sht = {
235 .dma_boundary = ATA_DMA_BOUNDARY, 235 .dma_boundary = ATA_DMA_BOUNDARY,
236 .slave_configure = ata_scsi_slave_config, 236 .slave_configure = ata_scsi_slave_config,
237 .bios_param = ata_std_bios_param, 237 .bios_param = ata_std_bios_param,
238 .ordered_flush = 1,
239}; 238};
240 239
241 240
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index e69477d1889b..f01ec0a7c506 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -354,8 +354,9 @@ static int scsi_dev_info_list_add_str(char *dev_list)
354 * @model, if found, return the matching flags value, else return 354 * @model, if found, return the matching flags value, else return
355 * the host or global default settings. 355 * the host or global default settings.
356 **/ 356 **/
357int scsi_get_device_flags(struct scsi_device *sdev, unsigned char *vendor, 357int scsi_get_device_flags(struct scsi_device *sdev,
358 unsigned char *model) 358 const unsigned char *vendor,
359 const unsigned char *model)
359{ 360{
360 struct scsi_dev_info_list *devinfo; 361 struct scsi_dev_info_list *devinfo;
361 unsigned int bflags; 362 unsigned int bflags;
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 18c5d2523014..a2333d2c7af0 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -422,10 +422,15 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
422 **/ 422 **/
423static void scsi_eh_done(struct scsi_cmnd *scmd) 423static void scsi_eh_done(struct scsi_cmnd *scmd)
424{ 424{
425 struct completion *eh_action;
426
425 SCSI_LOG_ERROR_RECOVERY(3, 427 SCSI_LOG_ERROR_RECOVERY(3,
426 printk("%s scmd: %p result: %x\n", 428 printk("%s scmd: %p result: %x\n",
427 __FUNCTION__, scmd, scmd->result)); 429 __FUNCTION__, scmd, scmd->result));
428 complete(scmd->device->host->eh_action); 430
431 eh_action = scmd->device->host->eh_action;
432 if (eh_action)
433 complete(eh_action);
429} 434}
430 435
431/** 436/**
@@ -1315,23 +1320,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
1315} 1320}
1316 1321
1317/** 1322/**
1318 * scsi_eh_lock_done - done function for eh door lock request
1319 * @scmd: SCSI command block for the door lock request
1320 *
1321 * Notes:
1322 * We completed the asynchronous door lock request, and it has either
1323 * locked the door or failed. We must free the command structures
1324 * associated with this request.
1325 **/
1326static void scsi_eh_lock_done(struct scsi_cmnd *scmd)
1327{
1328 struct scsi_request *sreq = scmd->sc_request;
1329
1330 scsi_release_request(sreq);
1331}
1332
1333
1334/**
1335 * scsi_eh_lock_door - Prevent medium removal for the specified device 1323 * scsi_eh_lock_door - Prevent medium removal for the specified device
1336 * @sdev: SCSI device to prevent medium removal 1324 * @sdev: SCSI device to prevent medium removal
1337 * 1325 *
@@ -1353,29 +1341,17 @@ static void scsi_eh_lock_done(struct scsi_cmnd *scmd)
1353 **/ 1341 **/
1354static void scsi_eh_lock_door(struct scsi_device *sdev) 1342static void scsi_eh_lock_door(struct scsi_device *sdev)
1355{ 1343{
1356 struct scsi_request *sreq = scsi_allocate_request(sdev, GFP_KERNEL); 1344 unsigned char cmnd[MAX_COMMAND_SIZE];
1357 1345
1358 if (unlikely(!sreq)) { 1346 cmnd[0] = ALLOW_MEDIUM_REMOVAL;
1359 printk(KERN_ERR "%s: request allocate failed," 1347 cmnd[1] = 0;
1360 "prevent media removal cmd not sent\n", __FUNCTION__); 1348 cmnd[2] = 0;
1361 return; 1349 cmnd[3] = 0;
1362 } 1350 cmnd[4] = SCSI_REMOVAL_PREVENT;
1351 cmnd[5] = 0;
1363 1352
1364 sreq->sr_cmnd[0] = ALLOW_MEDIUM_REMOVAL; 1353 scsi_execute_async(sdev, cmnd, DMA_NONE, NULL, 0, 0, 10 * HZ,
1365 sreq->sr_cmnd[1] = 0; 1354 5, NULL, NULL, GFP_KERNEL);
1366 sreq->sr_cmnd[2] = 0;
1367 sreq->sr_cmnd[3] = 0;
1368 sreq->sr_cmnd[4] = SCSI_REMOVAL_PREVENT;
1369 sreq->sr_cmnd[5] = 0;
1370 sreq->sr_data_direction = DMA_NONE;
1371 sreq->sr_bufflen = 0;
1372 sreq->sr_buffer = NULL;
1373 sreq->sr_allowed = 5;
1374 sreq->sr_done = scsi_eh_lock_done;
1375 sreq->sr_timeout_per_command = 10 * HZ;
1376 sreq->sr_cmd_len = COMMAND_SIZE(sreq->sr_cmnd[0]);
1377
1378 scsi_insert_special_req(sreq, 1);
1379} 1355}
1380 1356
1381 1357
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 4afef5cdcb17..ba93d6e66d48 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -63,39 +63,6 @@ static struct scsi_host_sg_pool scsi_sg_pools[] = {
63}; 63};
64#undef SP 64#undef SP
65 65
66
67/*
68 * Function: scsi_insert_special_req()
69 *
70 * Purpose: Insert pre-formed request into request queue.
71 *
72 * Arguments: sreq - request that is ready to be queued.
73 * at_head - boolean. True if we should insert at head
74 * of queue, false if we should insert at tail.
75 *
76 * Lock status: Assumed that lock is not held upon entry.
77 *
78 * Returns: Nothing
79 *
80 * Notes: This function is called from character device and from
81 * ioctl types of functions where the caller knows exactly
82 * what SCSI command needs to be issued. The idea is that
83 * we merely inject the command into the queue (at the head
84 * for now), and then call the queue request function to actually
85 * process it.
86 */
87int scsi_insert_special_req(struct scsi_request *sreq, int at_head)
88{
89 /*
90 * Because users of this function are apt to reuse requests with no
91 * modification, we have to sanitise the request flags here
92 */
93 sreq->sr_request->flags &= ~REQ_DONTPREP;
94 blk_insert_request(sreq->sr_device->request_queue, sreq->sr_request,
95 at_head, sreq);
96 return 0;
97}
98
99static void scsi_run_queue(struct request_queue *q); 66static void scsi_run_queue(struct request_queue *q);
100 67
101/* 68/*
@@ -249,8 +216,13 @@ void scsi_do_req(struct scsi_request *sreq, const void *cmnd,
249 216
250 /* 217 /*
251 * head injection *required* here otherwise quiesce won't work 218 * head injection *required* here otherwise quiesce won't work
219 *
220 * Because users of this function are apt to reuse requests with no
221 * modification, we have to sanitise the request flags here
252 */ 222 */
253 scsi_insert_special_req(sreq, 1); 223 sreq->sr_request->flags &= ~REQ_DONTPREP;
224 blk_insert_request(sreq->sr_device->request_queue, sreq->sr_request,
225 1, sreq);
254} 226}
255EXPORT_SYMBOL(scsi_do_req); 227EXPORT_SYMBOL(scsi_do_req);
256 228
@@ -287,6 +259,7 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
287 memcpy(req->cmd, cmd, req->cmd_len); 259 memcpy(req->cmd, cmd, req->cmd_len);
288 req->sense = sense; 260 req->sense = sense;
289 req->sense_len = 0; 261 req->sense_len = 0;
262 req->retries = retries;
290 req->timeout = timeout; 263 req->timeout = timeout;
291 req->flags |= flags | REQ_BLOCK_PC | REQ_SPECIAL | REQ_QUIET; 264 req->flags |= flags | REQ_BLOCK_PC | REQ_SPECIAL | REQ_QUIET;
292 265
@@ -327,6 +300,200 @@ int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
327} 300}
328EXPORT_SYMBOL(scsi_execute_req); 301EXPORT_SYMBOL(scsi_execute_req);
329 302
303struct scsi_io_context {
304 void *data;
305 void (*done)(void *data, char *sense, int result, int resid);
306 char sense[SCSI_SENSE_BUFFERSIZE];
307};
308
309static kmem_cache_t *scsi_io_context_cache;
310
311static void scsi_end_async(struct request *req, int uptodate)
312{
313 struct scsi_io_context *sioc = req->end_io_data;
314
315 if (sioc->done)
316 sioc->done(sioc->data, sioc->sense, req->errors, req->data_len);
317
318 kmem_cache_free(scsi_io_context_cache, sioc);
319 __blk_put_request(req->q, req);
320}
321
322static int scsi_merge_bio(struct request *rq, struct bio *bio)
323{
324 struct request_queue *q = rq->q;
325
326 bio->bi_flags &= ~(1 << BIO_SEG_VALID);
327 if (rq_data_dir(rq) == WRITE)
328 bio->bi_rw |= (1 << BIO_RW);
329 blk_queue_bounce(q, &bio);
330
331 if (!rq->bio)
332 blk_rq_bio_prep(q, rq, bio);
333 else if (!q->back_merge_fn(q, rq, bio))
334 return -EINVAL;
335 else {
336 rq->biotail->bi_next = bio;
337 rq->biotail = bio;
338 rq->hard_nr_sectors += bio_sectors(bio);
339 rq->nr_sectors = rq->hard_nr_sectors;
340 }
341
342 return 0;
343}
344
345static int scsi_bi_endio(struct bio *bio, unsigned int bytes_done, int error)
346{
347 if (bio->bi_size)
348 return 1;
349
350 bio_put(bio);
351 return 0;
352}
353
354/**
355 * scsi_req_map_sg - map a scatterlist into a request
356 * @rq: request to fill
357 * @sg: scatterlist
358 * @nsegs: number of elements
359 * @bufflen: len of buffer
360 * @gfp: memory allocation flags
361 *
362 * scsi_req_map_sg maps a scatterlist into a request so that the
363 * request can be sent to the block layer. We do not trust the scatterlist
364 * sent to use, as some ULDs use that struct to only organize the pages.
365 */
366static int scsi_req_map_sg(struct request *rq, struct scatterlist *sgl,
367 int nsegs, unsigned bufflen, gfp_t gfp)
368{
369 struct request_queue *q = rq->q;
370 int nr_pages = (bufflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
371 unsigned int data_len = 0, len, bytes, off;
372 struct page *page;
373 struct bio *bio = NULL;
374 int i, err, nr_vecs = 0;
375
376 for (i = 0; i < nsegs; i++) {
377 page = sgl[i].page;
378 off = sgl[i].offset;
379 len = sgl[i].length;
380 data_len += len;
381
382 while (len > 0) {
383 bytes = min_t(unsigned int, len, PAGE_SIZE - off);
384
385 if (!bio) {
386 nr_vecs = min_t(int, BIO_MAX_PAGES, nr_pages);
387 nr_pages -= nr_vecs;
388
389 bio = bio_alloc(gfp, nr_vecs);
390 if (!bio) {
391 err = -ENOMEM;
392 goto free_bios;
393 }
394 bio->bi_end_io = scsi_bi_endio;
395 }
396
397 if (bio_add_pc_page(q, bio, page, bytes, off) !=
398 bytes) {
399 bio_put(bio);
400 err = -EINVAL;
401 goto free_bios;
402 }
403
404 if (bio->bi_vcnt >= nr_vecs) {
405 err = scsi_merge_bio(rq, bio);
406 if (err) {
407 bio_endio(bio, bio->bi_size, 0);
408 goto free_bios;
409 }
410 bio = NULL;
411 }
412
413 page++;
414 len -= bytes;
415 off = 0;
416 }
417 }
418
419 rq->buffer = rq->data = NULL;
420 rq->data_len = data_len;
421 return 0;
422
423free_bios:
424 while ((bio = rq->bio) != NULL) {
425 rq->bio = bio->bi_next;
426 /*
427 * call endio instead of bio_put incase it was bounced
428 */
429 bio_endio(bio, bio->bi_size, 0);
430 }
431
432 return err;
433}
434
435/**
436 * scsi_execute_async - insert request
437 * @sdev: scsi device
438 * @cmd: scsi command
439 * @data_direction: data direction
440 * @buffer: data buffer (this can be a kernel buffer or scatterlist)
441 * @bufflen: len of buffer
442 * @use_sg: if buffer is a scatterlist this is the number of elements
443 * @timeout: request timeout in seconds
444 * @retries: number of times to retry request
445 * @flags: or into request flags
446 **/
447int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
448 int data_direction, void *buffer, unsigned bufflen,
449 int use_sg, int timeout, int retries, void *privdata,
450 void (*done)(void *, char *, int, int), gfp_t gfp)
451{
452 struct request *req;
453 struct scsi_io_context *sioc;
454 int err = 0;
455 int write = (data_direction == DMA_TO_DEVICE);
456
457 sioc = kmem_cache_alloc(scsi_io_context_cache, gfp);
458 if (!sioc)
459 return DRIVER_ERROR << 24;
460 memset(sioc, 0, sizeof(*sioc));
461
462 req = blk_get_request(sdev->request_queue, write, gfp);
463 if (!req)
464 goto free_sense;
465 req->flags |= REQ_BLOCK_PC | REQ_QUIET;
466
467 if (use_sg)
468 err = scsi_req_map_sg(req, buffer, use_sg, bufflen, gfp);
469 else if (bufflen)
470 err = blk_rq_map_kern(req->q, req, buffer, bufflen, gfp);
471
472 if (err)
473 goto free_req;
474
475 req->cmd_len = COMMAND_SIZE(cmd[0]);
476 memcpy(req->cmd, cmd, req->cmd_len);
477 req->sense = sioc->sense;
478 req->sense_len = 0;
479 req->timeout = timeout;
480 req->retries = retries;
481 req->end_io_data = sioc;
482
483 sioc->data = privdata;
484 sioc->done = done;
485
486 blk_execute_rq_nowait(req->q, NULL, req, 1, scsi_end_async);
487 return 0;
488
489free_req:
490 blk_put_request(req);
491free_sense:
492 kfree(sioc);
493 return DRIVER_ERROR << 24;
494}
495EXPORT_SYMBOL_GPL(scsi_execute_async);
496
330/* 497/*
331 * Function: scsi_init_cmd_errh() 498 * Function: scsi_init_cmd_errh()
332 * 499 *
@@ -542,10 +709,17 @@ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
542 709
543void scsi_next_command(struct scsi_cmnd *cmd) 710void scsi_next_command(struct scsi_cmnd *cmd)
544{ 711{
545 struct request_queue *q = cmd->device->request_queue; 712 struct scsi_device *sdev = cmd->device;
713 struct request_queue *q = sdev->request_queue;
714
715 /* need to hold a reference on the device before we let go of the cmd */
716 get_device(&sdev->sdev_gendev);
546 717
547 scsi_put_command(cmd); 718 scsi_put_command(cmd);
548 scsi_run_queue(q); 719 scsi_run_queue(q);
720
721 /* ok to remove device now */
722 put_device(&sdev->sdev_gendev);
549} 723}
550 724
551void scsi_run_host_queues(struct Scsi_Host *shost) 725void scsi_run_host_queues(struct Scsi_Host *shost)
@@ -617,7 +791,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int uptodate,
617 spin_lock_irqsave(q->queue_lock, flags); 791 spin_lock_irqsave(q->queue_lock, flags);
618 if (blk_rq_tagged(req)) 792 if (blk_rq_tagged(req))
619 blk_queue_end_tag(q, req); 793 blk_queue_end_tag(q, req);
620 end_that_request_last(req); 794 end_that_request_last(req, uptodate);
621 spin_unlock_irqrestore(q->queue_lock, flags); 795 spin_unlock_irqrestore(q->queue_lock, flags);
622 796
623 /* 797 /*
@@ -758,9 +932,6 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
758 int sense_valid = 0; 932 int sense_valid = 0;
759 int sense_deferred = 0; 933 int sense_deferred = 0;
760 934
761 if (blk_complete_barrier_rq(q, req, good_bytes >> 9))
762 return;
763
764 /* 935 /*
765 * Free up any indirection buffers we allocated for DMA purposes. 936 * Free up any indirection buffers we allocated for DMA purposes.
766 * For the case of a READ, we need to copy the data out of the 937 * For the case of a READ, we need to copy the data out of the
@@ -877,7 +1048,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes,
877 * system where READ CAPACITY failed, we may have read 1048 * system where READ CAPACITY failed, we may have read
878 * past the end of the disk. 1049 * past the end of the disk.
879 */ 1050 */
880 if (cmd->device->use_10_for_rw && 1051 if ((cmd->device->use_10_for_rw &&
1052 sshdr.asc == 0x20 && sshdr.ascq == 0x00) &&
881 (cmd->cmnd[0] == READ_10 || 1053 (cmd->cmnd[0] == READ_10 ||
882 cmd->cmnd[0] == WRITE_10)) { 1054 cmd->cmnd[0] == WRITE_10)) {
883 cmd->device->use_10_for_rw = 0; 1055 cmd->device->use_10_for_rw = 0;
@@ -1024,38 +1196,6 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
1024 return BLKPREP_KILL; 1196 return BLKPREP_KILL;
1025} 1197}
1026 1198
1027static int scsi_prepare_flush_fn(request_queue_t *q, struct request *rq)
1028{
1029 struct scsi_device *sdev = q->queuedata;
1030 struct scsi_driver *drv;
1031
1032 if (sdev->sdev_state == SDEV_RUNNING) {
1033 drv = *(struct scsi_driver **) rq->rq_disk->private_data;
1034
1035 if (drv->prepare_flush)
1036 return drv->prepare_flush(q, rq);
1037 }
1038
1039 return 0;
1040}
1041
1042static void scsi_end_flush_fn(request_queue_t *q, struct request *rq)
1043{
1044 struct scsi_device *sdev = q->queuedata;
1045 struct request *flush_rq = rq->end_io_data;
1046 struct scsi_driver *drv;
1047
1048 if (flush_rq->errors) {
1049 printk("scsi: barrier error, disabling flush support\n");
1050 blk_queue_ordered(q, QUEUE_ORDERED_NONE);
1051 }
1052
1053 if (sdev->sdev_state == SDEV_RUNNING) {
1054 drv = *(struct scsi_driver **) rq->rq_disk->private_data;
1055 drv->end_flush(q, rq);
1056 }
1057}
1058
1059static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk, 1199static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
1060 sector_t *error_sector) 1200 sector_t *error_sector)
1061{ 1201{
@@ -1075,8 +1215,34 @@ static int scsi_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
1075static void scsi_generic_done(struct scsi_cmnd *cmd) 1215static void scsi_generic_done(struct scsi_cmnd *cmd)
1076{ 1216{
1077 BUG_ON(!blk_pc_request(cmd->request)); 1217 BUG_ON(!blk_pc_request(cmd->request));
1078 scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0); 1218 /*
1219 * This will complete the whole command with uptodate=1 so
1220 * as far as the block layer is concerned the command completed
1221 * successfully. Since this is a REQ_BLOCK_PC command the
1222 * caller should check the request's errors value
1223 */
1224 scsi_io_completion(cmd, cmd->bufflen, 0);
1225}
1226
1227void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd)
1228{
1229 struct request *req = cmd->request;
1230
1231 BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1232 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1233 cmd->cmd_len = req->cmd_len;
1234 if (!req->data_len)
1235 cmd->sc_data_direction = DMA_NONE;
1236 else if (rq_data_dir(req) == WRITE)
1237 cmd->sc_data_direction = DMA_TO_DEVICE;
1238 else
1239 cmd->sc_data_direction = DMA_FROM_DEVICE;
1240
1241 cmd->transfersize = req->data_len;
1242 cmd->allowed = req->retries;
1243 cmd->timeout_per_command = req->timeout;
1079} 1244}
1245EXPORT_SYMBOL_GPL(scsi_setup_blk_pc_cmnd);
1080 1246
1081static int scsi_prep_fn(struct request_queue *q, struct request *req) 1247static int scsi_prep_fn(struct request_queue *q, struct request *req)
1082{ 1248{
@@ -1213,18 +1379,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1213 goto kill; 1379 goto kill;
1214 } 1380 }
1215 } else { 1381 } else {
1216 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1382 scsi_setup_blk_pc_cmnd(cmd);
1217 cmd->cmd_len = req->cmd_len;
1218 if (rq_data_dir(req) == WRITE)
1219 cmd->sc_data_direction = DMA_TO_DEVICE;
1220 else if (req->data_len)
1221 cmd->sc_data_direction = DMA_FROM_DEVICE;
1222 else
1223 cmd->sc_data_direction = DMA_NONE;
1224
1225 cmd->transfersize = req->data_len;
1226 cmd->allowed = 3;
1227 cmd->timeout_per_command = req->timeout;
1228 cmd->done = scsi_generic_done; 1383 cmd->done = scsi_generic_done;
1229 } 1384 }
1230 } 1385 }
@@ -1513,17 +1668,6 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
1513 blk_queue_segment_boundary(q, shost->dma_boundary); 1668 blk_queue_segment_boundary(q, shost->dma_boundary);
1514 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); 1669 blk_queue_issue_flush_fn(q, scsi_issue_flush_fn);
1515 1670
1516 /*
1517 * ordered tags are superior to flush ordering
1518 */
1519 if (shost->ordered_tag)
1520 blk_queue_ordered(q, QUEUE_ORDERED_TAG);
1521 else if (shost->ordered_flush) {
1522 blk_queue_ordered(q, QUEUE_ORDERED_FLUSH);
1523 q->prepare_flush_fn = scsi_prepare_flush_fn;
1524 q->end_flush_fn = scsi_end_flush_fn;
1525 }
1526
1527 if (!shost->use_clustering) 1671 if (!shost->use_clustering)
1528 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags); 1672 clear_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags);
1529 return q; 1673 return q;
@@ -1587,6 +1731,14 @@ int __init scsi_init_queue(void)
1587{ 1731{
1588 int i; 1732 int i;
1589 1733
1734 scsi_io_context_cache = kmem_cache_create("scsi_io_context",
1735 sizeof(struct scsi_io_context),
1736 0, 0, NULL, NULL);
1737 if (!scsi_io_context_cache) {
1738 printk(KERN_ERR "SCSI: can't init scsi io context cache\n");
1739 return -ENOMEM;
1740 }
1741
1590 for (i = 0; i < SG_MEMPOOL_NR; i++) { 1742 for (i = 0; i < SG_MEMPOOL_NR; i++) {
1591 struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; 1743 struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
1592 int size = sgp->size * sizeof(struct scatterlist); 1744 int size = sgp->size * sizeof(struct scatterlist);
@@ -1614,6 +1766,8 @@ void scsi_exit_queue(void)
1614{ 1766{
1615 int i; 1767 int i;
1616 1768
1769 kmem_cache_destroy(scsi_io_context_cache);
1770
1617 for (i = 0; i < SG_MEMPOOL_NR; i++) { 1771 for (i = 0; i < SG_MEMPOOL_NR; i++) {
1618 struct scsi_host_sg_pool *sgp = scsi_sg_pools + i; 1772 struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
1619 mempool_destroy(sgp->pool); 1773 mempool_destroy(sgp->pool);
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index d632d9e1493c..f04e7e11f57a 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -40,7 +40,6 @@ extern void scsi_exit_hosts(void);
40extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd); 40extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd);
41extern int scsi_setup_command_freelist(struct Scsi_Host *shost); 41extern int scsi_setup_command_freelist(struct Scsi_Host *shost);
42extern void scsi_destroy_command_freelist(struct Scsi_Host *shost); 42extern void scsi_destroy_command_freelist(struct Scsi_Host *shost);
43extern int scsi_insert_special_req(struct scsi_request *sreq, int);
44extern void scsi_init_cmd_from_req(struct scsi_cmnd *cmd, 43extern void scsi_init_cmd_from_req(struct scsi_cmnd *cmd,
45 struct scsi_request *sreq); 44 struct scsi_request *sreq);
46extern void __scsi_release_request(struct scsi_request *sreq); 45extern void __scsi_release_request(struct scsi_request *sreq);
@@ -57,7 +56,8 @@ static inline void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
57 56
58/* scsi_devinfo.c */ 57/* scsi_devinfo.c */
59extern int scsi_get_device_flags(struct scsi_device *sdev, 58extern int scsi_get_device_flags(struct scsi_device *sdev,
60 unsigned char *vendor, unsigned char *model); 59 const unsigned char *vendor,
60 const unsigned char *model);
61extern int __init scsi_init_devinfo(void); 61extern int __init scsi_init_devinfo(void);
62extern void scsi_exit_devinfo(void); 62extern void scsi_exit_devinfo(void);
63 63
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 374853df9cca..05ebb9cef961 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -74,7 +74,7 @@
74#define SCSI_SCAN_TARGET_PRESENT 1 74#define SCSI_SCAN_TARGET_PRESENT 1
75#define SCSI_SCAN_LUN_PRESENT 2 75#define SCSI_SCAN_LUN_PRESENT 2
76 76
77static char *scsi_null_device_strs = "nullnullnullnull"; 77static const char *scsi_null_device_strs = "nullnullnullnull";
78 78
79#define MAX_SCSI_LUNS 512 79#define MAX_SCSI_LUNS 512
80 80
@@ -266,8 +266,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
266 /* 266 /*
267 * if LLDD reports slave not present, don't clutter 267 * if LLDD reports slave not present, don't clutter
268 * console with alloc failure messages 268 * console with alloc failure messages
269
270
271 */ 269 */
272 if (ret == -ENXIO) 270 if (ret == -ENXIO)
273 display_failure_msg = 0; 271 display_failure_msg = 0;
@@ -279,7 +277,6 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
279 277
280out_device_destroy: 278out_device_destroy:
281 transport_destroy_device(&sdev->sdev_gendev); 279 transport_destroy_device(&sdev->sdev_gendev);
282 scsi_free_queue(sdev->request_queue);
283 put_device(&sdev->sdev_gendev); 280 put_device(&sdev->sdev_gendev);
284out: 281out:
285 if (display_failure_msg) 282 if (display_failure_msg)
@@ -403,6 +400,36 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
403 return found_target; 400 return found_target;
404} 401}
405 402
403struct work_queue_wrapper {
404 struct work_struct work;
405 struct scsi_target *starget;
406};
407
408static void scsi_target_reap_work(void *data) {
409 struct work_queue_wrapper *wqw = (struct work_queue_wrapper *)data;
410 struct scsi_target *starget = wqw->starget;
411 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
412 unsigned long flags;
413
414 kfree(wqw);
415
416 spin_lock_irqsave(shost->host_lock, flags);
417
418 if (--starget->reap_ref == 0 && list_empty(&starget->devices)) {
419 list_del_init(&starget->siblings);
420 spin_unlock_irqrestore(shost->host_lock, flags);
421 transport_remove_device(&starget->dev);
422 device_del(&starget->dev);
423 transport_destroy_device(&starget->dev);
424 put_device(&starget->dev);
425 return;
426
427 }
428 spin_unlock_irqrestore(shost->host_lock, flags);
429
430 return;
431}
432
406/** 433/**
407 * scsi_target_reap - check to see if target is in use and destroy if not 434 * scsi_target_reap - check to see if target is in use and destroy if not
408 * 435 *
@@ -414,19 +441,18 @@ static struct scsi_target *scsi_alloc_target(struct device *parent,
414 */ 441 */
415void scsi_target_reap(struct scsi_target *starget) 442void scsi_target_reap(struct scsi_target *starget)
416{ 443{
417 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 444 struct work_queue_wrapper *wqw =
418 unsigned long flags; 445 kzalloc(sizeof(struct work_queue_wrapper), GFP_ATOMIC);
419 spin_lock_irqsave(shost->host_lock, flags);
420 446
421 if (--starget->reap_ref == 0 && list_empty(&starget->devices)) { 447 if (!wqw) {
422 list_del_init(&starget->siblings); 448 starget_printk(KERN_ERR, starget,
423 spin_unlock_irqrestore(shost->host_lock, flags); 449 "Failed to allocate memory in scsi_reap_target()\n");
424 device_del(&starget->dev);
425 transport_unregister_device(&starget->dev);
426 put_device(&starget->dev);
427 return; 450 return;
428 } 451 }
429 spin_unlock_irqrestore(shost->host_lock, flags); 452
453 INIT_WORK(&wqw->work, scsi_target_reap_work, wqw);
454 wqw->starget = starget;
455 schedule_work(&wqw->work);
430} 456}
431 457
432/** 458/**
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 46349293de08..ea7f3a433572 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -21,7 +21,7 @@
21#include "scsi_priv.h" 21#include "scsi_priv.h"
22#include "scsi_logging.h" 22#include "scsi_logging.h"
23 23
24static struct { 24static const struct {
25 enum scsi_device_state value; 25 enum scsi_device_state value;
26 char *name; 26 char *name;
27} sdev_states[] = { 27} sdev_states[] = {
@@ -48,7 +48,7 @@ const char *scsi_device_state_name(enum scsi_device_state state)
48 return name; 48 return name;
49} 49}
50 50
51static struct { 51static const struct {
52 enum scsi_host_state value; 52 enum scsi_host_state value;
53 char *name; 53 char *name;
54} shost_states[] = { 54} shost_states[] = {
@@ -263,9 +263,40 @@ static int scsi_bus_match(struct device *dev, struct device_driver *gendrv)
263 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; 263 return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0;
264} 264}
265 265
266static int scsi_bus_suspend(struct device * dev, pm_message_t state)
267{
268 struct scsi_device *sdev = to_scsi_device(dev);
269 struct scsi_host_template *sht = sdev->host->hostt;
270 int err;
271
272 err = scsi_device_quiesce(sdev);
273 if (err)
274 return err;
275
276 if (sht->suspend)
277 err = sht->suspend(sdev);
278
279 return err;
280}
281
282static int scsi_bus_resume(struct device * dev)
283{
284 struct scsi_device *sdev = to_scsi_device(dev);
285 struct scsi_host_template *sht = sdev->host->hostt;
286 int err = 0;
287
288 if (sht->resume)
289 err = sht->resume(sdev);
290
291 scsi_device_resume(sdev);
292 return err;
293}
294
266struct bus_type scsi_bus_type = { 295struct bus_type scsi_bus_type = {
267 .name = "scsi", 296 .name = "scsi",
268 .match = scsi_bus_match, 297 .match = scsi_bus_match,
298 .suspend = scsi_bus_suspend,
299 .resume = scsi_bus_resume,
269}; 300};
270 301
271int scsi_sysfs_register(void) 302int scsi_sysfs_register(void)
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 6cd5931d9a54..685b997306cf 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -105,13 +105,14 @@ static struct {
105 { FC_PORTSTATE_LINKDOWN, "Linkdown" }, 105 { FC_PORTSTATE_LINKDOWN, "Linkdown" },
106 { FC_PORTSTATE_ERROR, "Error" }, 106 { FC_PORTSTATE_ERROR, "Error" },
107 { FC_PORTSTATE_LOOPBACK, "Loopback" }, 107 { FC_PORTSTATE_LOOPBACK, "Loopback" },
108 { FC_PORTSTATE_DELETED, "Deleted" },
108}; 109};
109fc_enum_name_search(port_state, fc_port_state, fc_port_state_names) 110fc_enum_name_search(port_state, fc_port_state, fc_port_state_names)
110#define FC_PORTSTATE_MAX_NAMELEN 20 111#define FC_PORTSTATE_MAX_NAMELEN 20
111 112
112 113
113/* Convert fc_tgtid_binding_type values to ascii string name */ 114/* Convert fc_tgtid_binding_type values to ascii string name */
114static struct { 115static const struct {
115 enum fc_tgtid_binding_type value; 116 enum fc_tgtid_binding_type value;
116 char *name; 117 char *name;
117 int matchlen; 118 int matchlen;
@@ -149,7 +150,7 @@ get_fc_##title##_names(u32 table_key, char *buf) \
149 150
150 151
151/* Convert FC_COS bit values to ascii string name */ 152/* Convert FC_COS bit values to ascii string name */
152static struct { 153static const struct {
153 u32 value; 154 u32 value;
154 char *name; 155 char *name;
155} fc_cos_names[] = { 156} fc_cos_names[] = {
@@ -163,7 +164,7 @@ fc_bitfield_name_search(cos, fc_cos_names)
163 164
164 165
165/* Convert FC_PORTSPEED bit values to ascii string name */ 166/* Convert FC_PORTSPEED bit values to ascii string name */
166static struct { 167static const struct {
167 u32 value; 168 u32 value;
168 char *name; 169 char *name;
169} fc_port_speed_names[] = { 170} fc_port_speed_names[] = {
@@ -189,7 +190,7 @@ show_fc_fc4s (char *buf, u8 *fc4_list)
189 190
190 191
191/* Convert FC_RPORT_ROLE bit values to ascii string name */ 192/* Convert FC_RPORT_ROLE bit values to ascii string name */
192static struct { 193static const struct {
193 u32 value; 194 u32 value;
194 char *name; 195 char *name;
195} fc_remote_port_role_names[] = { 196} fc_remote_port_role_names[] = {
@@ -211,6 +212,7 @@ fc_bitfield_name_search(remote_port_roles, fc_remote_port_role_names)
211#define FC_MGMTSRVR_PORTID 0x00000a 212#define FC_MGMTSRVR_PORTID 0x00000a
212 213
213 214
215static void fc_shost_remove_rports(void *data);
214static void fc_timeout_deleted_rport(void *data); 216static void fc_timeout_deleted_rport(void *data);
215static void fc_scsi_scan_rport(void *data); 217static void fc_scsi_scan_rport(void *data);
216static void fc_rport_terminate(struct fc_rport *rport); 218static void fc_rport_terminate(struct fc_rport *rport);
@@ -318,6 +320,8 @@ static int fc_host_setup(struct transport_container *tc, struct device *dev,
318 fc_host_next_rport_number(shost) = 0; 320 fc_host_next_rport_number(shost) = 0;
319 fc_host_next_target_id(shost) = 0; 321 fc_host_next_target_id(shost) = 0;
320 322
323 fc_host_flags(shost) = 0;
324 INIT_WORK(&fc_host_rport_del_work(shost), fc_shost_remove_rports, shost);
321 return 0; 325 return 0;
322} 326}
323 327
@@ -387,6 +391,7 @@ show_fc_rport_##field (struct class_device *cdev, char *buf) \
387 struct fc_internal *i = to_fc_internal(shost->transportt); \ 391 struct fc_internal *i = to_fc_internal(shost->transportt); \
388 if ((i->f->get_rport_##field) && \ 392 if ((i->f->get_rport_##field) && \
389 !((rport->port_state == FC_PORTSTATE_BLOCKED) || \ 393 !((rport->port_state == FC_PORTSTATE_BLOCKED) || \
394 (rport->port_state == FC_PORTSTATE_DELETED) || \
390 (rport->port_state == FC_PORTSTATE_NOTPRESENT))) \ 395 (rport->port_state == FC_PORTSTATE_NOTPRESENT))) \
391 i->f->get_rport_##field(rport); \ 396 i->f->get_rport_##field(rport); \
392 return snprintf(buf, sz, format_string, cast rport->field); \ 397 return snprintf(buf, sz, format_string, cast rport->field); \
@@ -402,6 +407,7 @@ store_fc_rport_##field(struct class_device *cdev, const char *buf, \
402 struct Scsi_Host *shost = rport_to_shost(rport); \ 407 struct Scsi_Host *shost = rport_to_shost(rport); \
403 struct fc_internal *i = to_fc_internal(shost->transportt); \ 408 struct fc_internal *i = to_fc_internal(shost->transportt); \
404 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || \ 409 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || \
410 (rport->port_state == FC_PORTSTATE_DELETED) || \
405 (rport->port_state == FC_PORTSTATE_NOTPRESENT)) \ 411 (rport->port_state == FC_PORTSTATE_NOTPRESENT)) \
406 return -EBUSY; \ 412 return -EBUSY; \
407 val = simple_strtoul(buf, NULL, 0); \ 413 val = simple_strtoul(buf, NULL, 0); \
@@ -519,6 +525,7 @@ store_fc_rport_dev_loss_tmo(struct class_device *cdev, const char *buf,
519 struct Scsi_Host *shost = rport_to_shost(rport); 525 struct Scsi_Host *shost = rport_to_shost(rport);
520 struct fc_internal *i = to_fc_internal(shost->transportt); 526 struct fc_internal *i = to_fc_internal(shost->transportt);
521 if ((rport->port_state == FC_PORTSTATE_BLOCKED) || 527 if ((rport->port_state == FC_PORTSTATE_BLOCKED) ||
528 (rport->port_state == FC_PORTSTATE_DELETED) ||
522 (rport->port_state == FC_PORTSTATE_NOTPRESENT)) 529 (rport->port_state == FC_PORTSTATE_NOTPRESENT))
523 return -EBUSY; 530 return -EBUSY;
524 val = simple_strtoul(buf, NULL, 0); 531 val = simple_strtoul(buf, NULL, 0);
@@ -1769,7 +1776,7 @@ fc_timeout_deleted_rport(void *data)
1769 rport->maxframe_size = -1; 1776 rport->maxframe_size = -1;
1770 rport->supported_classes = FC_COS_UNSPECIFIED; 1777 rport->supported_classes = FC_COS_UNSPECIFIED;
1771 rport->roles = FC_RPORT_ROLE_UNKNOWN; 1778 rport->roles = FC_RPORT_ROLE_UNKNOWN;
1772 rport->port_state = FC_PORTSTATE_NOTPRESENT; 1779 rport->port_state = FC_PORTSTATE_DELETED;
1773 1780
1774 /* remove the identifiers that aren't used in the consisting binding */ 1781 /* remove the identifiers that aren't used in the consisting binding */
1775 switch (fc_host_tgtid_bind_type(shost)) { 1782 switch (fc_host_tgtid_bind_type(shost)) {
@@ -1789,14 +1796,23 @@ fc_timeout_deleted_rport(void *data)
1789 break; 1796 break;
1790 } 1797 }
1791 1798
1792 spin_unlock_irqrestore(shost->host_lock, flags);
1793
1794 /* 1799 /*
1795 * As this only occurs if the remote port (scsi target) 1800 * As this only occurs if the remote port (scsi target)
1796 * went away and didn't come back - we'll remove 1801 * went away and didn't come back - we'll remove
1797 * all attached scsi devices. 1802 * all attached scsi devices.
1803 *
1804 * We'll schedule the shost work item to perform the actual removal
1805 * to avoid recursion in the different flush calls if we perform
1806 * the removal in each target - and there are lots of targets
1807 * whose timeouts fire at the same time.
1798 */ 1808 */
1799 fc_rport_tgt_remove(rport); 1809
1810 if ( !(fc_host_flags(shost) & FC_SHOST_RPORT_DEL_SCHEDULED)) {
1811 fc_host_flags(shost) |= FC_SHOST_RPORT_DEL_SCHEDULED;
1812 scsi_queue_work(shost, &fc_host_rport_del_work(shost));
1813 }
1814
1815 spin_unlock_irqrestore(shost->host_lock, flags);
1800} 1816}
1801 1817
1802/** 1818/**
@@ -1818,6 +1834,41 @@ fc_scsi_scan_rport(void *data)
1818} 1834}
1819 1835
1820 1836
1837/**
1838 * fc_shost_remove_rports - called to remove all rports that are marked
1839 * as in a deleted (not connected) state.
1840 *
1841 * @data: shost whose rports are to be looked at
1842 **/
1843static void
1844fc_shost_remove_rports(void *data)
1845{
1846 struct Scsi_Host *shost = (struct Scsi_Host *)data;
1847 struct fc_rport *rport, *next_rport;
1848 unsigned long flags;
1849
1850 spin_lock_irqsave(shost->host_lock, flags);
1851 while (fc_host_flags(shost) & FC_SHOST_RPORT_DEL_SCHEDULED) {
1852
1853 fc_host_flags(shost) &= ~FC_SHOST_RPORT_DEL_SCHEDULED;
1854
1855restart_search:
1856 list_for_each_entry_safe(rport, next_rport,
1857 &fc_host_rport_bindings(shost), peers) {
1858 if (rport->port_state == FC_PORTSTATE_DELETED) {
1859 rport->port_state = FC_PORTSTATE_NOTPRESENT;
1860 spin_unlock_irqrestore(shost->host_lock, flags);
1861 fc_rport_tgt_remove(rport);
1862 spin_lock_irqsave(shost->host_lock, flags);
1863 goto restart_search;
1864 }
1865 }
1866
1867 }
1868 spin_unlock_irqrestore(shost->host_lock, flags);
1869}
1870
1871
1821MODULE_AUTHOR("Martin Hicks"); 1872MODULE_AUTHOR("Martin Hicks");
1822MODULE_DESCRIPTION("FC Transport Attributes"); 1873MODULE_DESCRIPTION("FC Transport Attributes");
1823MODULE_LICENSE("GPL"); 1874MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 49fd18c1a9c6..e08462d50c97 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -249,7 +249,7 @@ static inline struct list_head *skb_to_lh(struct sk_buff *skb)
249} 249}
250 250
251static void* 251static void*
252mempool_zone_alloc_skb(unsigned int gfp_mask, void *pool_data) 252mempool_zone_alloc_skb(gfp_t gfp_mask, void *pool_data)
253{ 253{
254 struct mempool_zone *zone = pool_data; 254 struct mempool_zone *zone = pool_data;
255 255
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index 38a53b5f9e9a..46da6fe10ad5 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -18,6 +18,7 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 20 */
21#include <linux/config.h>
21#include <linux/ctype.h> 22#include <linux/ctype.h>
22#include <linux/init.h> 23#include <linux/init.h>
23#include <linux/module.h> 24#include <linux/module.h>
@@ -378,9 +379,7 @@ static CLASS_DEVICE_ATTR(revalidate, S_IWUSR, NULL, store_spi_revalidate);
378 379
379/* Translate the period into ns according to the current spec 380/* Translate the period into ns according to the current spec
380 * for SDTR/PPR messages */ 381 * for SDTR/PPR messages */
381static ssize_t 382static int period_to_str(char *buf, int period)
382show_spi_transport_period_helper(struct class_device *cdev, char *buf,
383 int period)
384{ 383{
385 int len, picosec; 384 int len, picosec;
386 385
@@ -398,6 +397,14 @@ show_spi_transport_period_helper(struct class_device *cdev, char *buf,
398 len = sprint_frac(buf, picosec, 1000); 397 len = sprint_frac(buf, picosec, 1000);
399 } 398 }
400 399
400 return len;
401}
402
403static ssize_t
404show_spi_transport_period_helper(struct class_device *cdev, char *buf,
405 int period)
406{
407 int len = period_to_str(buf, period);
401 buf[len++] = '\n'; 408 buf[len++] = '\n';
402 buf[len] = '\0'; 409 buf[len] = '\0';
403 return len; 410 return len;
@@ -1041,12 +1048,133 @@ void spi_display_xfer_agreement(struct scsi_target *starget)
1041 tp->hold_mcs ? " HMCS" : "", 1048 tp->hold_mcs ? " HMCS" : "",
1042 tmp, tp->offset); 1049 tmp, tp->offset);
1043 } else { 1050 } else {
1044 dev_info(&starget->dev, "%sasynchronous.\n", 1051 dev_info(&starget->dev, "%sasynchronous\n",
1045 tp->width ? "wide " : ""); 1052 tp->width ? "wide " : "");
1046 } 1053 }
1047} 1054}
1048EXPORT_SYMBOL(spi_display_xfer_agreement); 1055EXPORT_SYMBOL(spi_display_xfer_agreement);
1049 1056
1057#ifdef CONFIG_SCSI_CONSTANTS
1058static const char * const one_byte_msgs[] = {
1059/* 0x00 */ "Command Complete", NULL, "Save Pointers",
1060/* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error",
1061/* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error",
1062/* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",
1063/* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue",
1064/* 0x0f */ "Initiate Recovery", "Release Recovery"
1065};
1066
1067static const char * const two_byte_msgs[] = {
1068/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag",
1069/* 0x23 */ "Ignore Wide Residue"
1070};
1071
1072static const char * const extended_msgs[] = {
1073/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
1074/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request",
1075/* 0x04 */ "Parallel Protocol Request"
1076};
1077
1078void print_nego(const unsigned char *msg, int per, int off, int width)
1079{
1080 if (per) {
1081 char buf[20];
1082 period_to_str(buf, msg[per]);
1083 printk("period = %s ns ", buf);
1084 }
1085
1086 if (off)
1087 printk("offset = %d ", msg[off]);
1088 if (width)
1089 printk("width = %d ", 8 << msg[width]);
1090}
1091
1092int spi_print_msg(const unsigned char *msg)
1093{
1094 int len = 0, i;
1095 if (msg[0] == EXTENDED_MESSAGE) {
1096 len = 3 + msg[1];
1097 if (msg[2] < ARRAY_SIZE(extended_msgs))
1098 printk ("%s ", extended_msgs[msg[2]]);
1099 else
1100 printk ("Extended Message, reserved code (0x%02x) ",
1101 (int) msg[2]);
1102 switch (msg[2]) {
1103 case EXTENDED_MODIFY_DATA_POINTER:
1104 printk("pointer = %d", (int) (msg[3] << 24) |
1105 (msg[4] << 16) | (msg[5] << 8) | msg[6]);
1106 break;
1107 case EXTENDED_SDTR:
1108 print_nego(msg, 3, 4, 0);
1109 break;
1110 case EXTENDED_WDTR:
1111 print_nego(msg, 0, 0, 3);
1112 break;
1113 case EXTENDED_PPR:
1114 print_nego(msg, 3, 5, 6);
1115 break;
1116 default:
1117 for (i = 2; i < len; ++i)
1118 printk("%02x ", msg[i]);
1119 }
1120 /* Identify */
1121 } else if (msg[0] & 0x80) {
1122 printk("Identify disconnect %sallowed %s %d ",
1123 (msg[0] & 0x40) ? "" : "not ",
1124 (msg[0] & 0x20) ? "target routine" : "lun",
1125 msg[0] & 0x7);
1126 len = 1;
1127 /* Normal One byte */
1128 } else if (msg[0] < 0x1f) {
1129 if (msg[0] < ARRAY_SIZE(one_byte_msgs))
1130 printk(one_byte_msgs[msg[0]]);
1131 else
1132 printk("reserved (%02x) ", msg[0]);
1133 len = 1;
1134 /* Two byte */
1135 } else if (msg[0] <= 0x2f) {
1136 if ((msg[0] - 0x20) < ARRAY_SIZE(two_byte_msgs))
1137 printk("%s %02x ", two_byte_msgs[msg[0] - 0x20],
1138 msg[1]);
1139 else
1140 printk("reserved two byte (%02x %02x) ",
1141 msg[0], msg[1]);
1142 len = 2;
1143 } else
1144 printk("reserved");
1145 return len;
1146}
1147EXPORT_SYMBOL(spi_print_msg);
1148
1149#else /* ifndef CONFIG_SCSI_CONSTANTS */
1150
1151int spi_print_msg(const unsigned char *msg)
1152{
1153 int len = 0, i;
1154
1155 if (msg[0] == EXTENDED_MESSAGE) {
1156 len = 3 + msg[1];
1157 for (i = 0; i < len; ++i)
1158 printk("%02x ", msg[i]);
1159 /* Identify */
1160 } else if (msg[0] & 0x80) {
1161 printk("%02x ", msg[0]);
1162 len = 1;
1163 /* Normal One byte */
1164 } else if (msg[0] < 0x1f) {
1165 printk("%02x ", msg[0]);
1166 len = 1;
1167 /* Two byte */
1168 } else if (msg[0] <= 0x2f) {
1169 printk("%02x %02x", msg[0], msg[1]);
1170 len = 2;
1171 } else
1172 printk("%02x ", msg[0]);
1173 return len;
1174}
1175EXPORT_SYMBOL(spi_print_msg);
1176#endif /* ! CONFIG_SCSI_CONSTANTS */
1177
1050#define SETUP_ATTRIBUTE(field) \ 1178#define SETUP_ATTRIBUTE(field) \
1051 i->private_attrs[count] = class_device_attr_##field; \ 1179 i->private_attrs[count] = class_device_attr_##field; \
1052 if (!i->f->set_##field) { \ 1180 if (!i->f->set_##field) { \
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 8613a1317712..32d4d8d7b9f3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -102,6 +102,7 @@ struct scsi_disk {
102 u8 write_prot; 102 u8 write_prot;
103 unsigned WCE : 1; /* state of disk WCE bit */ 103 unsigned WCE : 1; /* state of disk WCE bit */
104 unsigned RCD : 1; /* state of disk RCD bit, unused */ 104 unsigned RCD : 1; /* state of disk RCD bit, unused */
105 unsigned DPOFUA : 1; /* state of disk DPOFUA bit */
105}; 106};
106 107
107static DEFINE_IDR(sd_index_idr); 108static DEFINE_IDR(sd_index_idr);
@@ -121,8 +122,7 @@ static void sd_shutdown(struct device *dev);
121static void sd_rescan(struct device *); 122static void sd_rescan(struct device *);
122static int sd_init_command(struct scsi_cmnd *); 123static int sd_init_command(struct scsi_cmnd *);
123static int sd_issue_flush(struct device *, sector_t *); 124static int sd_issue_flush(struct device *, sector_t *);
124static void sd_end_flush(request_queue_t *, struct request *); 125static void sd_prepare_flush(request_queue_t *, struct request *);
125static int sd_prepare_flush(request_queue_t *, struct request *);
126static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname, 126static void sd_read_capacity(struct scsi_disk *sdkp, char *diskname,
127 unsigned char *buffer); 127 unsigned char *buffer);
128 128
@@ -137,8 +137,6 @@ static struct scsi_driver sd_template = {
137 .rescan = sd_rescan, 137 .rescan = sd_rescan,
138 .init_command = sd_init_command, 138 .init_command = sd_init_command,
139 .issue_flush = sd_issue_flush, 139 .issue_flush = sd_issue_flush,
140 .prepare_flush = sd_prepare_flush,
141 .end_flush = sd_end_flush,
142}; 140};
143 141
144/* 142/*
@@ -245,24 +243,10 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
245 * SG_IO from block layer already setup, just copy cdb basically 243 * SG_IO from block layer already setup, just copy cdb basically
246 */ 244 */
247 if (blk_pc_request(rq)) { 245 if (blk_pc_request(rq)) {
248 if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd)) 246 scsi_setup_blk_pc_cmnd(SCpnt);
249 return 0;
250
251 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
252 SCpnt->cmd_len = rq->cmd_len;
253 if (rq_data_dir(rq) == WRITE)
254 SCpnt->sc_data_direction = DMA_TO_DEVICE;
255 else if (rq->data_len)
256 SCpnt->sc_data_direction = DMA_FROM_DEVICE;
257 else
258 SCpnt->sc_data_direction = DMA_NONE;
259
260 this_count = rq->data_len;
261 if (rq->timeout) 247 if (rq->timeout)
262 timeout = rq->timeout; 248 timeout = rq->timeout;
263 249
264 SCpnt->transfersize = rq->data_len;
265 SCpnt->allowed = SD_PASSTHROUGH_RETRIES;
266 goto queue; 250 goto queue;
267 } 251 }
268 252
@@ -360,6 +344,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
360 344
361 if (block > 0xffffffff) { 345 if (block > 0xffffffff) {
362 SCpnt->cmnd[0] += READ_16 - READ_6; 346 SCpnt->cmnd[0] += READ_16 - READ_6;
347 SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0;
363 SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0; 348 SCpnt->cmnd[2] = sizeof(block) > 4 ? (unsigned char) (block >> 56) & 0xff : 0;
364 SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0; 349 SCpnt->cmnd[3] = sizeof(block) > 4 ? (unsigned char) (block >> 48) & 0xff : 0;
365 SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0; 350 SCpnt->cmnd[4] = sizeof(block) > 4 ? (unsigned char) (block >> 40) & 0xff : 0;
@@ -379,6 +364,7 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
379 this_count = 0xffff; 364 this_count = 0xffff;
380 365
381 SCpnt->cmnd[0] += READ_10 - READ_6; 366 SCpnt->cmnd[0] += READ_10 - READ_6;
367 SCpnt->cmnd[1] |= blk_fua_rq(rq) ? 0x8 : 0;
382 SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff; 368 SCpnt->cmnd[2] = (unsigned char) (block >> 24) & 0xff;
383 SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff; 369 SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff;
384 SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff; 370 SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;
@@ -387,6 +373,17 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
387 SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff; 373 SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff;
388 SCpnt->cmnd[8] = (unsigned char) this_count & 0xff; 374 SCpnt->cmnd[8] = (unsigned char) this_count & 0xff;
389 } else { 375 } else {
376 if (unlikely(blk_fua_rq(rq))) {
377 /*
378 * This happens only if this drive failed
379 * 10byte rw command with ILLEGAL_REQUEST
380 * during operation and thus turned off
381 * use_10_for_rw.
382 */
383 printk(KERN_ERR "sd: FUA write on READ/WRITE(6) drive\n");
384 return 0;
385 }
386
390 SCpnt->cmnd[1] |= (unsigned char) ((block >> 16) & 0x1f); 387 SCpnt->cmnd[1] |= (unsigned char) ((block >> 16) & 0x1f);
391 SCpnt->cmnd[2] = (unsigned char) ((block >> 8) & 0xff); 388 SCpnt->cmnd[2] = (unsigned char) ((block >> 8) & 0xff);
392 SCpnt->cmnd[3] = (unsigned char) block & 0xff; 389 SCpnt->cmnd[3] = (unsigned char) block & 0xff;
@@ -743,42 +740,13 @@ static int sd_issue_flush(struct device *dev, sector_t *error_sector)
743 return ret; 740 return ret;
744} 741}
745 742
746static void sd_end_flush(request_queue_t *q, struct request *flush_rq) 743static void sd_prepare_flush(request_queue_t *q, struct request *rq)
747{
748 struct request *rq = flush_rq->end_io_data;
749 struct scsi_cmnd *cmd = rq->special;
750 unsigned int bytes = rq->hard_nr_sectors << 9;
751
752 if (!flush_rq->errors) {
753 spin_unlock(q->queue_lock);
754 scsi_io_completion(cmd, bytes, 0);
755 spin_lock(q->queue_lock);
756 } else if (blk_barrier_postflush(rq)) {
757 spin_unlock(q->queue_lock);
758 scsi_io_completion(cmd, 0, bytes);
759 spin_lock(q->queue_lock);
760 } else {
761 /*
762 * force journal abort of barriers
763 */
764 end_that_request_first(rq, -EOPNOTSUPP, rq->hard_nr_sectors);
765 end_that_request_last(rq);
766 }
767}
768
769static int sd_prepare_flush(request_queue_t *q, struct request *rq)
770{ 744{
771 struct scsi_device *sdev = q->queuedata;
772 struct scsi_disk *sdkp = dev_get_drvdata(&sdev->sdev_gendev);
773
774 if (!sdkp || !sdkp->WCE)
775 return 0;
776
777 memset(rq->cmd, 0, sizeof(rq->cmd)); 745 memset(rq->cmd, 0, sizeof(rq->cmd));
778 rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; 746 rq->flags |= REQ_BLOCK_PC;
779 rq->timeout = SD_TIMEOUT; 747 rq->timeout = SD_TIMEOUT;
780 rq->cmd[0] = SYNCHRONIZE_CACHE; 748 rq->cmd[0] = SYNCHRONIZE_CACHE;
781 return 1; 749 rq->cmd_len = 10;
782} 750}
783 751
784static void sd_rescan(struct device *dev) 752static void sd_rescan(struct device *dev)
@@ -1441,10 +1409,18 @@ sd_read_cache_type(struct scsi_disk *sdkp, char *diskname,
1441 sdkp->RCD = 0; 1409 sdkp->RCD = 0;
1442 } 1410 }
1443 1411
1412 sdkp->DPOFUA = (data.device_specific & 0x10) != 0;
1413 if (sdkp->DPOFUA && !sdkp->device->use_10_for_rw) {
1414 printk(KERN_NOTICE "SCSI device %s: uses "
1415 "READ/WRITE(6), disabling FUA\n", diskname);
1416 sdkp->DPOFUA = 0;
1417 }
1418
1444 ct = sdkp->RCD + 2*sdkp->WCE; 1419 ct = sdkp->RCD + 2*sdkp->WCE;
1445 1420
1446 printk(KERN_NOTICE "SCSI device %s: drive cache: %s\n", 1421 printk(KERN_NOTICE "SCSI device %s: drive cache: %s%s\n",
1447 diskname, types[ct]); 1422 diskname, types[ct],
1423 sdkp->DPOFUA ? " w/ FUA" : "");
1448 1424
1449 return; 1425 return;
1450 } 1426 }
@@ -1476,6 +1452,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
1476 struct scsi_disk *sdkp = scsi_disk(disk); 1452 struct scsi_disk *sdkp = scsi_disk(disk);
1477 struct scsi_device *sdp = sdkp->device; 1453 struct scsi_device *sdp = sdkp->device;
1478 unsigned char *buffer; 1454 unsigned char *buffer;
1455 unsigned ordered;
1479 1456
1480 SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name)); 1457 SCSI_LOG_HLQUEUE(3, printk("sd_revalidate_disk: disk=%s\n", disk->disk_name));
1481 1458
@@ -1509,12 +1486,24 @@ static int sd_revalidate_disk(struct gendisk *disk)
1509 */ 1486 */
1510 if (sdkp->media_present) { 1487 if (sdkp->media_present) {
1511 sd_read_capacity(sdkp, disk->disk_name, buffer); 1488 sd_read_capacity(sdkp, disk->disk_name, buffer);
1512 if (sdp->removable) 1489 sd_read_write_protect_flag(sdkp, disk->disk_name, buffer);
1513 sd_read_write_protect_flag(sdkp, disk->disk_name,
1514 buffer);
1515 sd_read_cache_type(sdkp, disk->disk_name, buffer); 1490 sd_read_cache_type(sdkp, disk->disk_name, buffer);
1516 } 1491 }
1517 1492
1493 /*
1494 * We now have all cache related info, determine how we deal
1495 * with ordered requests. Note that as the current SCSI
1496 * dispatch function can alter request order, we cannot use
1497 * QUEUE_ORDERED_TAG_* even when ordered tag is supported.
1498 */
1499 if (sdkp->WCE)
1500 ordered = sdkp->DPOFUA
1501 ? QUEUE_ORDERED_DRAIN_FUA : QUEUE_ORDERED_DRAIN_FLUSH;
1502 else
1503 ordered = QUEUE_ORDERED_DRAIN;
1504
1505 blk_queue_ordered(sdkp->disk->queue, ordered, sd_prepare_flush);
1506
1518 set_capacity(disk, sdkp->capacity); 1507 set_capacity(disk, sdkp->capacity);
1519 kfree(buffer); 1508 kfree(buffer);
1520 1509
@@ -1614,6 +1603,7 @@ static int sd_probe(struct device *dev)
1614 strcpy(gd->devfs_name, sdp->devfs_name); 1603 strcpy(gd->devfs_name, sdp->devfs_name);
1615 1604
1616 gd->private_data = &sdkp->driver; 1605 gd->private_data = &sdkp->driver;
1606 gd->queue = sdkp->device->request_queue;
1617 1607
1618 sd_revalidate_disk(gd); 1608 sd_revalidate_disk(gd);
1619 1609
@@ -1621,7 +1611,6 @@ static int sd_probe(struct device *dev)
1621 gd->flags = GENHD_FL_DRIVERFS; 1611 gd->flags = GENHD_FL_DRIVERFS;
1622 if (sdp->removable) 1612 if (sdp->removable)
1623 gd->flags |= GENHD_FL_REMOVABLE; 1613 gd->flags |= GENHD_FL_REMOVABLE;
1624 gd->queue = sdkp->device->request_queue;
1625 1614
1626 dev_set_drvdata(dev, sdkp); 1615 dev_set_drvdata(dev, sdkp);
1627 add_disk(gd); 1616 add_disk(gd);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index b55c2a8a547c..221e96e2620a 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -104,8 +104,6 @@ static int sg_allow_dio = SG_ALLOW_DIO_DEF;
104static int sg_add(struct class_device *, struct class_interface *); 104static int sg_add(struct class_device *, struct class_interface *);
105static void sg_remove(struct class_device *, struct class_interface *); 105static void sg_remove(struct class_device *, struct class_interface *);
106 106
107static Scsi_Request *dummy_cmdp; /* only used for sizeof */
108
109static DEFINE_RWLOCK(sg_dev_arr_lock); /* Also used to lock 107static DEFINE_RWLOCK(sg_dev_arr_lock); /* Also used to lock
110 file descriptor list for device */ 108 file descriptor list for device */
111 109
@@ -119,7 +117,7 @@ typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */
119 unsigned short sglist_len; /* size of malloc'd scatter-gather list ++ */ 117 unsigned short sglist_len; /* size of malloc'd scatter-gather list ++ */
120 unsigned bufflen; /* Size of (aggregate) data buffer */ 118 unsigned bufflen; /* Size of (aggregate) data buffer */
121 unsigned b_malloc_len; /* actual len malloc'ed in buffer */ 119 unsigned b_malloc_len; /* actual len malloc'ed in buffer */
122 void *buffer; /* Data buffer or scatter list (k_use_sg>0) */ 120 struct scatterlist *buffer;/* scatter list */
123 char dio_in_use; /* 0->indirect IO (or mmap), 1->dio */ 121 char dio_in_use; /* 0->indirect IO (or mmap), 1->dio */
124 unsigned char cmd_opcode; /* first byte of command */ 122 unsigned char cmd_opcode; /* first byte of command */
125} Sg_scatter_hold; 123} Sg_scatter_hold;
@@ -128,12 +126,11 @@ struct sg_device; /* forward declarations */
128struct sg_fd; 126struct sg_fd;
129 127
130typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */ 128typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */
131 Scsi_Request *my_cmdp; /* != 0 when request with lower levels */
132 struct sg_request *nextrp; /* NULL -> tail request (slist) */ 129 struct sg_request *nextrp; /* NULL -> tail request (slist) */
133 struct sg_fd *parentfp; /* NULL -> not in use */ 130 struct sg_fd *parentfp; /* NULL -> not in use */
134 Sg_scatter_hold data; /* hold buffer, perhaps scatter list */ 131 Sg_scatter_hold data; /* hold buffer, perhaps scatter list */
135 sg_io_hdr_t header; /* scsi command+info, see <scsi/sg.h> */ 132 sg_io_hdr_t header; /* scsi command+info, see <scsi/sg.h> */
136 unsigned char sense_b[sizeof (dummy_cmdp->sr_sense_buffer)]; 133 unsigned char sense_b[SCSI_SENSE_BUFFERSIZE];
137 char res_used; /* 1 -> using reserve buffer, 0 -> not ... */ 134 char res_used; /* 1 -> using reserve buffer, 0 -> not ... */
138 char orphan; /* 1 -> drop on sight, 0 -> normal */ 135 char orphan; /* 1 -> drop on sight, 0 -> normal */
139 char sg_io_owned; /* 1 -> packet belongs to SG_IO */ 136 char sg_io_owned; /* 1 -> packet belongs to SG_IO */
@@ -174,7 +171,8 @@ typedef struct sg_device { /* holds the state of each scsi generic device */
174} Sg_device; 171} Sg_device;
175 172
176static int sg_fasync(int fd, struct file *filp, int mode); 173static int sg_fasync(int fd, struct file *filp, int mode);
177static void sg_cmd_done(Scsi_Cmnd * SCpnt); /* tasklet or soft irq callback */ 174/* tasklet or soft irq callback */
175static void sg_cmd_done(void *data, char *sense, int result, int resid);
178static int sg_start_req(Sg_request * srp); 176static int sg_start_req(Sg_request * srp);
179static void sg_finish_rem_req(Sg_request * srp); 177static void sg_finish_rem_req(Sg_request * srp);
180static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size); 178static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size);
@@ -195,8 +193,8 @@ static void sg_remove_scat(Sg_scatter_hold * schp);
195static void sg_build_reserve(Sg_fd * sfp, int req_size); 193static void sg_build_reserve(Sg_fd * sfp, int req_size);
196static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size); 194static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size);
197static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp); 195static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp);
198static char *sg_page_malloc(int rqSz, int lowDma, int *retSzp); 196static struct page *sg_page_malloc(int rqSz, int lowDma, int *retSzp);
199static void sg_page_free(char *buff, int size); 197static void sg_page_free(struct page *page, int size);
200static Sg_fd *sg_add_sfp(Sg_device * sdp, int dev); 198static Sg_fd *sg_add_sfp(Sg_device * sdp, int dev);
201static int sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); 199static int sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp);
202static void __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); 200static void __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp);
@@ -207,7 +205,6 @@ static int sg_res_in_use(Sg_fd * sfp);
207static int sg_allow_access(unsigned char opcode, char dev_type); 205static int sg_allow_access(unsigned char opcode, char dev_type);
208static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len); 206static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len);
209static Sg_device *sg_get_dev(int dev); 207static Sg_device *sg_get_dev(int dev);
210static inline unsigned char *sg_scatg2virt(const struct scatterlist *sclp);
211#ifdef CONFIG_SCSI_PROC_FS 208#ifdef CONFIG_SCSI_PROC_FS
212static int sg_last_dev(void); 209static int sg_last_dev(void);
213#endif 210#endif
@@ -226,6 +223,7 @@ sg_open(struct inode *inode, struct file *filp)
226{ 223{
227 int dev = iminor(inode); 224 int dev = iminor(inode);
228 int flags = filp->f_flags; 225 int flags = filp->f_flags;
226 struct request_queue *q;
229 Sg_device *sdp; 227 Sg_device *sdp;
230 Sg_fd *sfp; 228 Sg_fd *sfp;
231 int res; 229 int res;
@@ -287,7 +285,9 @@ sg_open(struct inode *inode, struct file *filp)
287 } 285 }
288 if (!sdp->headfp) { /* no existing opens on this device */ 286 if (!sdp->headfp) { /* no existing opens on this device */
289 sdp->sgdebug = 0; 287 sdp->sgdebug = 0;
290 sdp->sg_tablesize = sdp->device->host->sg_tablesize; 288 q = sdp->device->request_queue;
289 sdp->sg_tablesize = min(q->max_hw_segments,
290 q->max_phys_segments);
291 } 291 }
292 if ((sfp = sg_add_sfp(sdp, dev))) 292 if ((sfp = sg_add_sfp(sdp, dev)))
293 filp->private_data = sfp; 293 filp->private_data = sfp;
@@ -340,6 +340,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
340 return -ENXIO; 340 return -ENXIO;
341 SCSI_LOG_TIMEOUT(3, printk("sg_read: %s, count=%d\n", 341 SCSI_LOG_TIMEOUT(3, printk("sg_read: %s, count=%d\n",
342 sdp->disk->disk_name, (int) count)); 342 sdp->disk->disk_name, (int) count));
343
343 if (!access_ok(VERIFY_WRITE, buf, count)) 344 if (!access_ok(VERIFY_WRITE, buf, count))
344 return -EFAULT; 345 return -EFAULT;
345 if (sfp->force_packid && (count >= SZ_SG_HEADER)) { 346 if (sfp->force_packid && (count >= SZ_SG_HEADER)) {
@@ -491,7 +492,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp)
491 if ((hp->mx_sb_len > 0) && hp->sbp) { 492 if ((hp->mx_sb_len > 0) && hp->sbp) {
492 if ((CHECK_CONDITION & hp->masked_status) || 493 if ((CHECK_CONDITION & hp->masked_status) ||
493 (DRIVER_SENSE & hp->driver_status)) { 494 (DRIVER_SENSE & hp->driver_status)) {
494 int sb_len = sizeof (dummy_cmdp->sr_sense_buffer); 495 int sb_len = SCSI_SENSE_BUFFERSIZE;
495 sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len; 496 sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len;
496 len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ 497 len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */
497 len = (len > sb_len) ? sb_len : len; 498 len = (len > sb_len) ? sb_len : len;
@@ -525,7 +526,7 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
525 Sg_request *srp; 526 Sg_request *srp;
526 struct sg_header old_hdr; 527 struct sg_header old_hdr;
527 sg_io_hdr_t *hp; 528 sg_io_hdr_t *hp;
528 unsigned char cmnd[sizeof (dummy_cmdp->sr_cmnd)]; 529 unsigned char cmnd[MAX_COMMAND_SIZE];
529 530
530 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) 531 if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp)))
531 return -ENXIO; 532 return -ENXIO;
@@ -624,7 +625,7 @@ sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count,
624 int k; 625 int k;
625 Sg_request *srp; 626 Sg_request *srp;
626 sg_io_hdr_t *hp; 627 sg_io_hdr_t *hp;
627 unsigned char cmnd[sizeof (dummy_cmdp->sr_cmnd)]; 628 unsigned char cmnd[MAX_COMMAND_SIZE];
628 int timeout; 629 int timeout;
629 unsigned long ul_timeout; 630 unsigned long ul_timeout;
630 631
@@ -692,11 +693,9 @@ static int
692sg_common_write(Sg_fd * sfp, Sg_request * srp, 693sg_common_write(Sg_fd * sfp, Sg_request * srp,
693 unsigned char *cmnd, int timeout, int blocking) 694 unsigned char *cmnd, int timeout, int blocking)
694{ 695{
695 int k; 696 int k, data_dir;
696 Scsi_Request *SRpnt;
697 Sg_device *sdp = sfp->parentdp; 697 Sg_device *sdp = sfp->parentdp;
698 sg_io_hdr_t *hp = &srp->header; 698 sg_io_hdr_t *hp = &srp->header;
699 request_queue_t *q;
700 699
701 srp->data.cmd_opcode = cmnd[0]; /* hold opcode of command */ 700 srp->data.cmd_opcode = cmnd[0]; /* hold opcode of command */
702 hp->status = 0; 701 hp->status = 0;
@@ -723,51 +722,36 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
723 sg_finish_rem_req(srp); 722 sg_finish_rem_req(srp);
724 return -ENODEV; 723 return -ENODEV;
725 } 724 }
726 SRpnt = scsi_allocate_request(sdp->device, GFP_ATOMIC);
727 if (SRpnt == NULL) {
728 SCSI_LOG_TIMEOUT(1, printk("sg_write: no mem\n"));
729 sg_finish_rem_req(srp);
730 return -ENOMEM;
731 }
732 725
733 srp->my_cmdp = SRpnt;
734 q = SRpnt->sr_device->request_queue;
735 SRpnt->sr_request->rq_disk = sdp->disk;
736 SRpnt->sr_sense_buffer[0] = 0;
737 SRpnt->sr_cmd_len = hp->cmd_len;
738 SRpnt->sr_use_sg = srp->data.k_use_sg;
739 SRpnt->sr_sglist_len = srp->data.sglist_len;
740 SRpnt->sr_bufflen = srp->data.bufflen;
741 SRpnt->sr_underflow = 0;
742 SRpnt->sr_buffer = srp->data.buffer;
743 switch (hp->dxfer_direction) { 726 switch (hp->dxfer_direction) {
744 case SG_DXFER_TO_FROM_DEV: 727 case SG_DXFER_TO_FROM_DEV:
745 case SG_DXFER_FROM_DEV: 728 case SG_DXFER_FROM_DEV:
746 SRpnt->sr_data_direction = DMA_FROM_DEVICE; 729 data_dir = DMA_FROM_DEVICE;
747 break; 730 break;
748 case SG_DXFER_TO_DEV: 731 case SG_DXFER_TO_DEV:
749 SRpnt->sr_data_direction = DMA_TO_DEVICE; 732 data_dir = DMA_TO_DEVICE;
750 break; 733 break;
751 case SG_DXFER_UNKNOWN: 734 case SG_DXFER_UNKNOWN:
752 SRpnt->sr_data_direction = DMA_BIDIRECTIONAL; 735 data_dir = DMA_BIDIRECTIONAL;
753 break; 736 break;
754 default: 737 default:
755 SRpnt->sr_data_direction = DMA_NONE; 738 data_dir = DMA_NONE;
756 break; 739 break;
757 } 740 }
758 SRpnt->upper_private_data = srp;
759 srp->data.k_use_sg = 0;
760 srp->data.sglist_len = 0;
761 srp->data.bufflen = 0;
762 srp->data.buffer = NULL;
763 hp->duration = jiffies_to_msecs(jiffies); 741 hp->duration = jiffies_to_msecs(jiffies);
764/* Now send everything of to mid-level. The next time we hear about this 742/* Now send everything of to mid-level. The next time we hear about this
765 packet is when sg_cmd_done() is called (i.e. a callback). */ 743 packet is when sg_cmd_done() is called (i.e. a callback). */
766 scsi_do_req(SRpnt, (void *) cmnd, 744 if (scsi_execute_async(sdp->device, cmnd, data_dir, srp->data.buffer,
767 (void *) SRpnt->sr_buffer, hp->dxfer_len, 745 hp->dxfer_len, srp->data.k_use_sg, timeout,
768 sg_cmd_done, timeout, SG_DEFAULT_RETRIES); 746 SG_DEFAULT_RETRIES, srp, sg_cmd_done,
769 /* dxfer_len overwrites SRpnt->sr_bufflen, hence need for b_malloc_len */ 747 GFP_ATOMIC)) {
770 return 0; 748 SCSI_LOG_TIMEOUT(1, printk("sg_write: scsi_execute_async failed\n"));
749 /*
750 * most likely out of mem, but could also be a bad map
751 */
752 return -ENOMEM;
753 } else
754 return 0;
771} 755}
772 756
773static int 757static int
@@ -1156,45 +1140,22 @@ sg_fasync(int fd, struct file *filp, int mode)
1156 return (retval < 0) ? retval : 0; 1140 return (retval < 0) ? retval : 0;
1157} 1141}
1158 1142
1159static inline unsigned char *
1160sg_scatg2virt(const struct scatterlist *sclp)
1161{
1162 return (sclp && sclp->page) ?
1163 (unsigned char *) page_address(sclp->page) + sclp->offset : NULL;
1164}
1165
1166/* When startFinish==1 increments page counts for pages other than the 1143/* When startFinish==1 increments page counts for pages other than the
1167 first of scatter gather elements obtained from __get_free_pages(). 1144 first of scatter gather elements obtained from alloc_pages().
1168 When startFinish==0 decrements ... */ 1145 When startFinish==0 decrements ... */
1169static void 1146static void
1170sg_rb_correct4mmap(Sg_scatter_hold * rsv_schp, int startFinish) 1147sg_rb_correct4mmap(Sg_scatter_hold * rsv_schp, int startFinish)
1171{ 1148{
1172 void *page_ptr; 1149 struct scatterlist *sg = rsv_schp->buffer;
1173 struct page *page; 1150 struct page *page;
1174 int k, m; 1151 int k, m;
1175 1152
1176 SCSI_LOG_TIMEOUT(3, printk("sg_rb_correct4mmap: startFinish=%d, scatg=%d\n", 1153 SCSI_LOG_TIMEOUT(3, printk("sg_rb_correct4mmap: startFinish=%d, scatg=%d\n",
1177 startFinish, rsv_schp->k_use_sg)); 1154 startFinish, rsv_schp->k_use_sg));
1178 /* N.B. correction _not_ applied to base page of each allocation */ 1155 /* N.B. correction _not_ applied to base page of each allocation */
1179 if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ 1156 for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) {
1180 struct scatterlist *sclp = rsv_schp->buffer; 1157 for (m = PAGE_SIZE; m < sg->length; m += PAGE_SIZE) {
1181 1158 page = sg->page;
1182 for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sclp) {
1183 for (m = PAGE_SIZE; m < sclp->length; m += PAGE_SIZE) {
1184 page_ptr = sg_scatg2virt(sclp) + m;
1185 page = virt_to_page(page_ptr);
1186 if (startFinish)
1187 get_page(page);
1188 else {
1189 if (page_count(page) > 0)
1190 __put_page(page);
1191 }
1192 }
1193 }
1194 } else { /* reserve buffer is just a single allocation */
1195 for (m = PAGE_SIZE; m < rsv_schp->bufflen; m += PAGE_SIZE) {
1196 page_ptr = (unsigned char *) rsv_schp->buffer + m;
1197 page = virt_to_page(page_ptr);
1198 if (startFinish) 1159 if (startFinish)
1199 get_page(page); 1160 get_page(page);
1200 else { 1161 else {
@@ -1210,9 +1171,10 @@ sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type)
1210{ 1171{
1211 Sg_fd *sfp; 1172 Sg_fd *sfp;
1212 struct page *page = NOPAGE_SIGBUS; 1173 struct page *page = NOPAGE_SIGBUS;
1213 void *page_ptr = NULL; 1174 unsigned long offset, len, sa;
1214 unsigned long offset;
1215 Sg_scatter_hold *rsv_schp; 1175 Sg_scatter_hold *rsv_schp;
1176 struct scatterlist *sg;
1177 int k;
1216 1178
1217 if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data))) 1179 if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data)))
1218 return page; 1180 return page;
@@ -1222,30 +1184,21 @@ sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type)
1222 return page; 1184 return page;
1223 SCSI_LOG_TIMEOUT(3, printk("sg_vma_nopage: offset=%lu, scatg=%d\n", 1185 SCSI_LOG_TIMEOUT(3, printk("sg_vma_nopage: offset=%lu, scatg=%d\n",
1224 offset, rsv_schp->k_use_sg)); 1186 offset, rsv_schp->k_use_sg));
1225 if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ 1187 sg = rsv_schp->buffer;
1226 int k; 1188 sa = vma->vm_start;
1227 unsigned long sa = vma->vm_start; 1189 for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end);
1228 unsigned long len; 1190 ++k, ++sg) {
1229 struct scatterlist *sclp = rsv_schp->buffer; 1191 len = vma->vm_end - sa;
1230 1192 len = (len < sg->length) ? len : sg->length;
1231 for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); 1193 if (offset < len) {
1232 ++k, ++sclp) { 1194 page = sg->page;
1233 len = vma->vm_end - sa; 1195 get_page(page); /* increment page count */
1234 len = (len < sclp->length) ? len : sclp->length; 1196 break;
1235 if (offset < len) {
1236 page_ptr = sg_scatg2virt(sclp) + offset;
1237 page = virt_to_page(page_ptr);
1238 get_page(page); /* increment page count */
1239 break;
1240 }
1241 sa += len;
1242 offset -= len;
1243 } 1197 }
1244 } else { /* reserve buffer is just a single allocation */ 1198 sa += len;
1245 page_ptr = (unsigned char *) rsv_schp->buffer + offset; 1199 offset -= len;
1246 page = virt_to_page(page_ptr);
1247 get_page(page); /* increment page count */
1248 } 1200 }
1201
1249 if (type) 1202 if (type)
1250 *type = VM_FAULT_MINOR; 1203 *type = VM_FAULT_MINOR;
1251 return page; 1204 return page;
@@ -1259,8 +1212,10 @@ static int
1259sg_mmap(struct file *filp, struct vm_area_struct *vma) 1212sg_mmap(struct file *filp, struct vm_area_struct *vma)
1260{ 1213{
1261 Sg_fd *sfp; 1214 Sg_fd *sfp;
1262 unsigned long req_sz; 1215 unsigned long req_sz, len, sa;
1263 Sg_scatter_hold *rsv_schp; 1216 Sg_scatter_hold *rsv_schp;
1217 int k;
1218 struct scatterlist *sg;
1264 1219
1265 if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) 1220 if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data)))
1266 return -ENXIO; 1221 return -ENXIO;
@@ -1273,24 +1228,15 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
1273 if (req_sz > rsv_schp->bufflen) 1228 if (req_sz > rsv_schp->bufflen)
1274 return -ENOMEM; /* cannot map more than reserved buffer */ 1229 return -ENOMEM; /* cannot map more than reserved buffer */
1275 1230
1276 if (rsv_schp->k_use_sg) { /* reserve buffer is a scatter gather list */ 1231 sa = vma->vm_start;
1277 int k; 1232 sg = rsv_schp->buffer;
1278 unsigned long sa = vma->vm_start; 1233 for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end);
1279 unsigned long len; 1234 ++k, ++sg) {
1280 struct scatterlist *sclp = rsv_schp->buffer; 1235 len = vma->vm_end - sa;
1281 1236 len = (len < sg->length) ? len : sg->length;
1282 for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); 1237 sa += len;
1283 ++k, ++sclp) {
1284 if (0 != sclp->offset)
1285 return -EFAULT; /* non page aligned memory ?? */
1286 len = vma->vm_end - sa;
1287 len = (len < sclp->length) ? len : sclp->length;
1288 sa += len;
1289 }
1290 } else { /* reserve buffer is just a single allocation */
1291 if ((unsigned long) rsv_schp->buffer & (PAGE_SIZE - 1))
1292 return -EFAULT; /* non page aligned memory ?? */
1293 } 1238 }
1239
1294 if (0 == sfp->mmap_called) { 1240 if (0 == sfp->mmap_called) {
1295 sg_rb_correct4mmap(rsv_schp, 1); /* do only once per fd lifetime */ 1241 sg_rb_correct4mmap(rsv_schp, 1); /* do only once per fd lifetime */
1296 sfp->mmap_called = 1; 1242 sfp->mmap_called = 1;
@@ -1304,21 +1250,16 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
1304/* This function is a "bottom half" handler that is called by the 1250/* This function is a "bottom half" handler that is called by the
1305 * mid level when a command is completed (or has failed). */ 1251 * mid level when a command is completed (or has failed). */
1306static void 1252static void
1307sg_cmd_done(Scsi_Cmnd * SCpnt) 1253sg_cmd_done(void *data, char *sense, int result, int resid)
1308{ 1254{
1309 Scsi_Request *SRpnt = NULL; 1255 Sg_request *srp = data;
1310 Sg_device *sdp = NULL; 1256 Sg_device *sdp = NULL;
1311 Sg_fd *sfp; 1257 Sg_fd *sfp;
1312 Sg_request *srp = NULL;
1313 unsigned long iflags; 1258 unsigned long iflags;
1314 unsigned int ms; 1259 unsigned int ms;
1315 1260
1316 if (SCpnt && (SRpnt = SCpnt->sc_request))
1317 srp = (Sg_request *) SRpnt->upper_private_data;
1318 if (NULL == srp) { 1261 if (NULL == srp) {
1319 printk(KERN_ERR "sg_cmd_done: NULL request\n"); 1262 printk(KERN_ERR "sg_cmd_done: NULL request\n");
1320 if (SRpnt)
1321 scsi_release_request(SRpnt);
1322 return; 1263 return;
1323 } 1264 }
1324 sfp = srp->parentfp; 1265 sfp = srp->parentfp;
@@ -1326,49 +1267,34 @@ sg_cmd_done(Scsi_Cmnd * SCpnt)
1326 sdp = sfp->parentdp; 1267 sdp = sfp->parentdp;
1327 if ((NULL == sdp) || sdp->detached) { 1268 if ((NULL == sdp) || sdp->detached) {
1328 printk(KERN_INFO "sg_cmd_done: device detached\n"); 1269 printk(KERN_INFO "sg_cmd_done: device detached\n");
1329 scsi_release_request(SRpnt);
1330 return; 1270 return;
1331 } 1271 }
1332 1272
1333 /* First transfer ownership of data buffers to sg_device object. */
1334 srp->data.k_use_sg = SRpnt->sr_use_sg;
1335 srp->data.sglist_len = SRpnt->sr_sglist_len;
1336 srp->data.bufflen = SRpnt->sr_bufflen;
1337 srp->data.buffer = SRpnt->sr_buffer;
1338 /* now clear out request structure */
1339 SRpnt->sr_use_sg = 0;
1340 SRpnt->sr_sglist_len = 0;
1341 SRpnt->sr_bufflen = 0;
1342 SRpnt->sr_buffer = NULL;
1343 SRpnt->sr_underflow = 0;
1344 SRpnt->sr_request->rq_disk = NULL; /* "sg" _disowns_ request blk */
1345
1346 srp->my_cmdp = NULL;
1347 1273
1348 SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n", 1274 SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n",
1349 sdp->disk->disk_name, srp->header.pack_id, (int) SRpnt->sr_result)); 1275 sdp->disk->disk_name, srp->header.pack_id, result));
1350 srp->header.resid = SCpnt->resid; 1276 srp->header.resid = resid;
1351 ms = jiffies_to_msecs(jiffies); 1277 ms = jiffies_to_msecs(jiffies);
1352 srp->header.duration = (ms > srp->header.duration) ? 1278 srp->header.duration = (ms > srp->header.duration) ?
1353 (ms - srp->header.duration) : 0; 1279 (ms - srp->header.duration) : 0;
1354 if (0 != SRpnt->sr_result) { 1280 if (0 != result) {
1355 struct scsi_sense_hdr sshdr; 1281 struct scsi_sense_hdr sshdr;
1356 1282
1357 memcpy(srp->sense_b, SRpnt->sr_sense_buffer, 1283 memcpy(srp->sense_b, sense, sizeof (srp->sense_b));
1358 sizeof (srp->sense_b)); 1284 srp->header.status = 0xff & result;
1359 srp->header.status = 0xff & SRpnt->sr_result; 1285 srp->header.masked_status = status_byte(result);
1360 srp->header.masked_status = status_byte(SRpnt->sr_result); 1286 srp->header.msg_status = msg_byte(result);
1361 srp->header.msg_status = msg_byte(SRpnt->sr_result); 1287 srp->header.host_status = host_byte(result);
1362 srp->header.host_status = host_byte(SRpnt->sr_result); 1288 srp->header.driver_status = driver_byte(result);
1363 srp->header.driver_status = driver_byte(SRpnt->sr_result);
1364 if ((sdp->sgdebug > 0) && 1289 if ((sdp->sgdebug > 0) &&
1365 ((CHECK_CONDITION == srp->header.masked_status) || 1290 ((CHECK_CONDITION == srp->header.masked_status) ||
1366 (COMMAND_TERMINATED == srp->header.masked_status))) 1291 (COMMAND_TERMINATED == srp->header.masked_status)))
1367 scsi_print_req_sense("sg_cmd_done", SRpnt); 1292 __scsi_print_sense("sg_cmd_done", sense,
1293 SCSI_SENSE_BUFFERSIZE);
1368 1294
1369 /* Following if statement is a patch supplied by Eric Youngdale */ 1295 /* Following if statement is a patch supplied by Eric Youngdale */
1370 if (driver_byte(SRpnt->sr_result) != 0 1296 if (driver_byte(result) != 0
1371 && scsi_command_normalize_sense(SCpnt, &sshdr) 1297 && scsi_normalize_sense(sense, SCSI_SENSE_BUFFERSIZE, &sshdr)
1372 && !scsi_sense_is_deferred(&sshdr) 1298 && !scsi_sense_is_deferred(&sshdr)
1373 && sshdr.sense_key == UNIT_ATTENTION 1299 && sshdr.sense_key == UNIT_ATTENTION
1374 && sdp->device->removable) { 1300 && sdp->device->removable) {
@@ -1379,8 +1305,6 @@ sg_cmd_done(Scsi_Cmnd * SCpnt)
1379 } 1305 }
1380 /* Rely on write phase to clean out srp status values, so no "else" */ 1306 /* Rely on write phase to clean out srp status values, so no "else" */
1381 1307
1382 scsi_release_request(SRpnt);
1383 SRpnt = NULL;
1384 if (sfp->closed) { /* whoops this fd already released, cleanup */ 1308 if (sfp->closed) { /* whoops this fd already released, cleanup */
1385 SCSI_LOG_TIMEOUT(1, printk("sg_cmd_done: already closed, freeing ...\n")); 1309 SCSI_LOG_TIMEOUT(1, printk("sg_cmd_done: already closed, freeing ...\n"));
1386 sg_finish_rem_req(srp); 1310 sg_finish_rem_req(srp);
@@ -1431,6 +1355,7 @@ static int sg_sysfs_valid = 0;
1431 1355
1432static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp) 1356static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1433{ 1357{
1358 struct request_queue *q = scsidp->request_queue;
1434 Sg_device *sdp; 1359 Sg_device *sdp;
1435 unsigned long iflags; 1360 unsigned long iflags;
1436 void *old_sg_dev_arr = NULL; 1361 void *old_sg_dev_arr = NULL;
@@ -1473,7 +1398,7 @@ static int sg_alloc(struct gendisk *disk, struct scsi_device *scsidp)
1473 sdp->disk = disk; 1398 sdp->disk = disk;
1474 sdp->device = scsidp; 1399 sdp->device = scsidp;
1475 init_waitqueue_head(&sdp->o_excl_wait); 1400 init_waitqueue_head(&sdp->o_excl_wait);
1476 sdp->sg_tablesize = scsidp->host ? scsidp->host->sg_tablesize : 0; 1401 sdp->sg_tablesize = min(q->max_hw_segments, q->max_phys_segments);
1477 1402
1478 sg_nr_dev++; 1403 sg_nr_dev++;
1479 sg_dev_arr[k] = sdp; 1404 sg_dev_arr[k] = sdp;
@@ -1753,36 +1678,35 @@ sg_finish_rem_req(Sg_request * srp)
1753static int 1678static int
1754sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) 1679sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize)
1755{ 1680{
1756 int ret_sz; 1681 int sg_bufflen = tablesize * sizeof(struct scatterlist);
1757 int elem_sz = sizeof (struct scatterlist); 1682 unsigned int gfp_flags = GFP_ATOMIC | __GFP_NOWARN;
1758 int sg_bufflen = tablesize * elem_sz;
1759 int mx_sc_elems = tablesize;
1760 1683
1761 schp->buffer = sg_page_malloc(sg_bufflen, sfp->low_dma, &ret_sz); 1684 /*
1685 * TODO: test without low_dma, we should not need it since
1686 * the block layer will bounce the buffer for us
1687 *
1688 * XXX(hch): we shouldn't need GFP_DMA for the actual S/G list.
1689 */
1690 if (sfp->low_dma)
1691 gfp_flags |= GFP_DMA;
1692 schp->buffer = kzalloc(sg_bufflen, gfp_flags);
1762 if (!schp->buffer) 1693 if (!schp->buffer)
1763 return -ENOMEM; 1694 return -ENOMEM;
1764 else if (ret_sz != sg_bufflen) {
1765 sg_bufflen = ret_sz;
1766 mx_sc_elems = sg_bufflen / elem_sz;
1767 }
1768 schp->sglist_len = sg_bufflen; 1695 schp->sglist_len = sg_bufflen;
1769 memset(schp->buffer, 0, sg_bufflen); 1696 return tablesize; /* number of scat_gath elements allocated */
1770 return mx_sc_elems; /* number of scat_gath elements allocated */
1771} 1697}
1772 1698
1773#ifdef SG_ALLOW_DIO_CODE 1699#ifdef SG_ALLOW_DIO_CODE
1774/* vvvvvvvv following code borrowed from st driver's direct IO vvvvvvvvv */ 1700/* vvvvvvvv following code borrowed from st driver's direct IO vvvvvvvvv */
1775 /* hopefully this generic code will moved to a library */ 1701 /* TODO: hopefully we can use the generic block layer code */
1776 1702
1777/* Pin down user pages and put them into a scatter gather list. Returns <= 0 if 1703/* Pin down user pages and put them into a scatter gather list. Returns <= 0 if
1778 - mapping of all pages not successful 1704 - mapping of all pages not successful
1779 - any page is above max_pfn
1780 (i.e., either completely successful or fails) 1705 (i.e., either completely successful or fails)
1781*/ 1706*/
1782static int 1707static int
1783st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, 1708st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1784 unsigned long uaddr, size_t count, int rw, 1709 unsigned long uaddr, size_t count, int rw)
1785 unsigned long max_pfn)
1786{ 1710{
1787 unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT; 1711 unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
1788 unsigned long start = uaddr >> PAGE_SHIFT; 1712 unsigned long start = uaddr >> PAGE_SHIFT;
@@ -1828,21 +1752,17 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1828 * probably wrong function for rw==WRITE 1752 * probably wrong function for rw==WRITE
1829 */ 1753 */
1830 flush_dcache_page(pages[i]); 1754 flush_dcache_page(pages[i]);
1831 if (page_to_pfn(pages[i]) > max_pfn)
1832 goto out_unlock;
1833 /* ?? Is locking needed? I don't think so */ 1755 /* ?? Is locking needed? I don't think so */
1834 /* if (TestSetPageLocked(pages[i])) 1756 /* if (TestSetPageLocked(pages[i]))
1835 goto out_unlock; */ 1757 goto out_unlock; */
1836 } 1758 }
1837 1759
1838 /* Populate the scatter/gather list */ 1760 sgl[0].page = pages[0];
1839 sgl[0].page = pages[0];
1840 sgl[0].offset = uaddr & ~PAGE_MASK; 1761 sgl[0].offset = uaddr & ~PAGE_MASK;
1841 if (nr_pages > 1) { 1762 if (nr_pages > 1) {
1842 sgl[0].length = PAGE_SIZE - sgl[0].offset; 1763 sgl[0].length = PAGE_SIZE - sgl[0].offset;
1843 count -= sgl[0].length; 1764 count -= sgl[0].length;
1844 for (i=1; i < nr_pages ; i++) { 1765 for (i=1; i < nr_pages ; i++) {
1845 sgl[i].offset = 0;
1846 sgl[i].page = pages[i]; 1766 sgl[i].page = pages[i];
1847 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE; 1767 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE;
1848 count -= PAGE_SIZE; 1768 count -= PAGE_SIZE;
@@ -1855,10 +1775,6 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1855 kfree(pages); 1775 kfree(pages);
1856 return nr_pages; 1776 return nr_pages;
1857 1777
1858 out_unlock:
1859 /* for (j=0; j < i; j++)
1860 unlock_page(pages[j]); */
1861 res = 0;
1862 out_unmap: 1778 out_unmap:
1863 if (res > 0) { 1779 if (res > 0) {
1864 for (j=0; j < res; j++) 1780 for (j=0; j < res; j++)
@@ -1904,20 +1820,20 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len)
1904 sg_io_hdr_t *hp = &srp->header; 1820 sg_io_hdr_t *hp = &srp->header;
1905 Sg_scatter_hold *schp = &srp->data; 1821 Sg_scatter_hold *schp = &srp->data;
1906 int sg_tablesize = sfp->parentdp->sg_tablesize; 1822 int sg_tablesize = sfp->parentdp->sg_tablesize;
1907 struct scatterlist *sgl;
1908 int mx_sc_elems, res; 1823 int mx_sc_elems, res;
1909 struct scsi_device *sdev = sfp->parentdp->device; 1824 struct scsi_device *sdev = sfp->parentdp->device;
1910 1825
1911 if (((unsigned long)hp->dxferp & 1826 if (((unsigned long)hp->dxferp &
1912 queue_dma_alignment(sdev->request_queue)) != 0) 1827 queue_dma_alignment(sdev->request_queue)) != 0)
1913 return 1; 1828 return 1;
1829
1914 mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); 1830 mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize);
1915 if (mx_sc_elems <= 0) { 1831 if (mx_sc_elems <= 0) {
1916 return 1; 1832 return 1;
1917 } 1833 }
1918 sgl = (struct scatterlist *)schp->buffer; 1834 res = st_map_user_pages(schp->buffer, mx_sc_elems,
1919 res = st_map_user_pages(sgl, mx_sc_elems, (unsigned long)hp->dxferp, dxfer_len, 1835 (unsigned long)hp->dxferp, dxfer_len,
1920 (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0, ULONG_MAX); 1836 (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0);
1921 if (res <= 0) 1837 if (res <= 0)
1922 return 1; 1838 return 1;
1923 schp->k_use_sg = res; 1839 schp->k_use_sg = res;
@@ -1932,9 +1848,11 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len)
1932static int 1848static int
1933sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) 1849sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1934{ 1850{
1935 int ret_sz; 1851 struct scatterlist *sg;
1852 int ret_sz = 0, k, rem_sz, num, mx_sc_elems;
1853 int sg_tablesize = sfp->parentdp->sg_tablesize;
1936 int blk_size = buff_size; 1854 int blk_size = buff_size;
1937 unsigned char *p = NULL; 1855 struct page *p = NULL;
1938 1856
1939 if ((blk_size < 0) || (!sfp)) 1857 if ((blk_size < 0) || (!sfp))
1940 return -EFAULT; 1858 return -EFAULT;
@@ -1944,59 +1862,35 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1944 blk_size = (blk_size + SG_SECTOR_MSK) & (~SG_SECTOR_MSK); 1862 blk_size = (blk_size + SG_SECTOR_MSK) & (~SG_SECTOR_MSK);
1945 SCSI_LOG_TIMEOUT(4, printk("sg_build_indirect: buff_size=%d, blk_size=%d\n", 1863 SCSI_LOG_TIMEOUT(4, printk("sg_build_indirect: buff_size=%d, blk_size=%d\n",
1946 buff_size, blk_size)); 1864 buff_size, blk_size));
1947 if (blk_size <= SG_SCATTER_SZ) { 1865
1948 p = sg_page_malloc(blk_size, sfp->low_dma, &ret_sz); 1866 /* N.B. ret_sz carried into this block ... */
1949 if (!p) 1867 mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize);
1950 return -ENOMEM; 1868 if (mx_sc_elems < 0)
1951 if (blk_size == ret_sz) { /* got it on the first attempt */ 1869 return mx_sc_elems; /* most likely -ENOMEM */
1952 schp->k_use_sg = 0; 1870
1953 schp->buffer = p; 1871 for (k = 0, sg = schp->buffer, rem_sz = blk_size;
1954 schp->bufflen = blk_size; 1872 (rem_sz > 0) && (k < mx_sc_elems);
1955 schp->b_malloc_len = blk_size; 1873 ++k, rem_sz -= ret_sz, ++sg) {
1956 return 0; 1874
1957 } 1875 num = (rem_sz > SG_SCATTER_SZ) ? SG_SCATTER_SZ : rem_sz;
1958 } else { 1876 p = sg_page_malloc(num, sfp->low_dma, &ret_sz);
1959 p = sg_page_malloc(SG_SCATTER_SZ, sfp->low_dma, &ret_sz);
1960 if (!p) 1877 if (!p)
1961 return -ENOMEM; 1878 return -ENOMEM;
1962 } 1879
1963/* Want some local declarations, so start new block ... */ 1880 sg->page = p;
1964 { /* lets try and build a scatter gather list */ 1881 sg->length = ret_sz;
1965 struct scatterlist *sclp; 1882
1966 int k, rem_sz, num; 1883 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n",
1967 int mx_sc_elems; 1884 k, p, ret_sz));
1968 int sg_tablesize = sfp->parentdp->sg_tablesize; 1885 } /* end of for loop */
1969 int first = 1; 1886
1970 1887 schp->k_use_sg = k;
1971 /* N.B. ret_sz carried into this block ... */ 1888 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz));
1972 mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); 1889
1973 if (mx_sc_elems < 0) 1890 schp->bufflen = blk_size;
1974 return mx_sc_elems; /* most likely -ENOMEM */ 1891 if (rem_sz > 0) /* must have failed */
1975 1892 return -ENOMEM;
1976 for (k = 0, sclp = schp->buffer, rem_sz = blk_size; 1893
1977 (rem_sz > 0) && (k < mx_sc_elems);
1978 ++k, rem_sz -= ret_sz, ++sclp) {
1979 if (first)
1980 first = 0;
1981 else {
1982 num =
1983 (rem_sz >
1984 SG_SCATTER_SZ) ? SG_SCATTER_SZ : rem_sz;
1985 p = sg_page_malloc(num, sfp->low_dma, &ret_sz);
1986 if (!p)
1987 break;
1988 }
1989 sg_set_buf(sclp, p, ret_sz);
1990
1991 SCSI_LOG_TIMEOUT(5, printk("sg_build_build: k=%d, a=0x%p, len=%d\n",
1992 k, sg_scatg2virt(sclp), ret_sz));
1993 } /* end of for loop */
1994 schp->k_use_sg = k;
1995 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, rem_sz=%d\n", k, rem_sz));
1996 schp->bufflen = blk_size;
1997 if (rem_sz > 0) /* must have failed */
1998 return -ENOMEM;
1999 }
2000 return 0; 1894 return 0;
2001} 1895}
2002 1896
@@ -2005,6 +1899,7 @@ sg_write_xfer(Sg_request * srp)
2005{ 1899{
2006 sg_io_hdr_t *hp = &srp->header; 1900 sg_io_hdr_t *hp = &srp->header;
2007 Sg_scatter_hold *schp = &srp->data; 1901 Sg_scatter_hold *schp = &srp->data;
1902 struct scatterlist *sg = schp->buffer;
2008 int num_xfer = 0; 1903 int num_xfer = 0;
2009 int j, k, onum, usglen, ksglen, res; 1904 int j, k, onum, usglen, ksglen, res;
2010 int iovec_count = (int) hp->iovec_count; 1905 int iovec_count = (int) hp->iovec_count;
@@ -2033,63 +1928,45 @@ sg_write_xfer(Sg_request * srp)
2033 } else 1928 } else
2034 onum = 1; 1929 onum = 1;
2035 1930
2036 if (0 == schp->k_use_sg) { /* kernel has single buffer */ 1931 ksglen = sg->length;
2037 for (j = 0, p = schp->buffer; j < onum; ++j) { 1932 p = page_address(sg->page);
2038 res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); 1933 for (j = 0, k = 0; j < onum; ++j) {
2039 if (res) 1934 res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up);
2040 return res; 1935 if (res)
2041 usglen = (num_xfer > usglen) ? usglen : num_xfer; 1936 return res;
2042 if (__copy_from_user(p, up, usglen)) 1937
2043 return -EFAULT; 1938 for (; p; ++sg, ksglen = sg->length,
2044 p += usglen; 1939 p = page_address(sg->page)) {
2045 num_xfer -= usglen; 1940 if (usglen <= 0)
2046 if (num_xfer <= 0) 1941 break;
2047 return 0; 1942 if (ksglen > usglen) {
2048 } 1943 if (usglen >= num_xfer) {
2049 } else { /* kernel using scatter gather list */ 1944 if (__copy_from_user(p, up, num_xfer))
2050 struct scatterlist *sclp = (struct scatterlist *) schp->buffer;
2051
2052 ksglen = (int) sclp->length;
2053 p = sg_scatg2virt(sclp);
2054 for (j = 0, k = 0; j < onum; ++j) {
2055 res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up);
2056 if (res)
2057 return res;
2058
2059 for (; p; ++sclp, ksglen = (int) sclp->length,
2060 p = sg_scatg2virt(sclp)) {
2061 if (usglen <= 0)
2062 break;
2063 if (ksglen > usglen) {
2064 if (usglen >= num_xfer) {
2065 if (__copy_from_user
2066 (p, up, num_xfer))
2067 return -EFAULT;
2068 return 0;
2069 }
2070 if (__copy_from_user(p, up, usglen))
2071 return -EFAULT;
2072 p += usglen;
2073 ksglen -= usglen;
2074 break;
2075 } else {
2076 if (ksglen >= num_xfer) {
2077 if (__copy_from_user
2078 (p, up, num_xfer))
2079 return -EFAULT;
2080 return 0;
2081 }
2082 if (__copy_from_user(p, up, ksglen))
2083 return -EFAULT; 1945 return -EFAULT;
2084 up += ksglen; 1946 return 0;
2085 usglen -= ksglen;
2086 } 1947 }
2087 ++k; 1948 if (__copy_from_user(p, up, usglen))
2088 if (k >= schp->k_use_sg) 1949 return -EFAULT;
1950 p += usglen;
1951 ksglen -= usglen;
1952 break;
1953 } else {
1954 if (ksglen >= num_xfer) {
1955 if (__copy_from_user(p, up, num_xfer))
1956 return -EFAULT;
2089 return 0; 1957 return 0;
1958 }
1959 if (__copy_from_user(p, up, ksglen))
1960 return -EFAULT;
1961 up += ksglen;
1962 usglen -= ksglen;
2090 } 1963 }
1964 ++k;
1965 if (k >= schp->k_use_sg)
1966 return 0;
2091 } 1967 }
2092 } 1968 }
1969
2093 return 0; 1970 return 0;
2094} 1971}
2095 1972
@@ -2127,29 +2004,25 @@ sg_remove_scat(Sg_scatter_hold * schp)
2127{ 2004{
2128 SCSI_LOG_TIMEOUT(4, printk("sg_remove_scat: k_use_sg=%d\n", schp->k_use_sg)); 2005 SCSI_LOG_TIMEOUT(4, printk("sg_remove_scat: k_use_sg=%d\n", schp->k_use_sg));
2129 if (schp->buffer && (schp->sglist_len > 0)) { 2006 if (schp->buffer && (schp->sglist_len > 0)) {
2130 struct scatterlist *sclp = (struct scatterlist *) schp->buffer; 2007 struct scatterlist *sg = schp->buffer;
2131 2008
2132 if (schp->dio_in_use) { 2009 if (schp->dio_in_use) {
2133#ifdef SG_ALLOW_DIO_CODE 2010#ifdef SG_ALLOW_DIO_CODE
2134 st_unmap_user_pages(sclp, schp->k_use_sg, TRUE); 2011 st_unmap_user_pages(sg, schp->k_use_sg, TRUE);
2135#endif 2012#endif
2136 } else { 2013 } else {
2137 int k; 2014 int k;
2138 2015
2139 for (k = 0; (k < schp->k_use_sg) && sg_scatg2virt(sclp); 2016 for (k = 0; (k < schp->k_use_sg) && sg->page;
2140 ++k, ++sclp) { 2017 ++k, ++sg) {
2141 SCSI_LOG_TIMEOUT(5, printk( 2018 SCSI_LOG_TIMEOUT(5, printk(
2142 "sg_remove_scat: k=%d, a=0x%p, len=%d\n", 2019 "sg_remove_scat: k=%d, a=0x%p, len=%d\n",
2143 k, sg_scatg2virt(sclp), sclp->length)); 2020 k, sg->page, sg->length));
2144 sg_page_free(sg_scatg2virt(sclp), sclp->length); 2021 sg_page_free(sg->page, sg->length);
2145 sclp->page = NULL;
2146 sclp->offset = 0;
2147 sclp->length = 0;
2148 } 2022 }
2149 } 2023 }
2150 sg_page_free(schp->buffer, schp->sglist_len); 2024 kfree(schp->buffer);
2151 } else if (schp->buffer) 2025 }
2152 sg_page_free(schp->buffer, schp->b_malloc_len);
2153 memset(schp, 0, sizeof (*schp)); 2026 memset(schp, 0, sizeof (*schp));
2154} 2027}
2155 2028
@@ -2158,6 +2031,7 @@ sg_read_xfer(Sg_request * srp)
2158{ 2031{
2159 sg_io_hdr_t *hp = &srp->header; 2032 sg_io_hdr_t *hp = &srp->header;
2160 Sg_scatter_hold *schp = &srp->data; 2033 Sg_scatter_hold *schp = &srp->data;
2034 struct scatterlist *sg = schp->buffer;
2161 int num_xfer = 0; 2035 int num_xfer = 0;
2162 int j, k, onum, usglen, ksglen, res; 2036 int j, k, onum, usglen, ksglen, res;
2163 int iovec_count = (int) hp->iovec_count; 2037 int iovec_count = (int) hp->iovec_count;
@@ -2186,63 +2060,45 @@ sg_read_xfer(Sg_request * srp)
2186 } else 2060 } else
2187 onum = 1; 2061 onum = 1;
2188 2062
2189 if (0 == schp->k_use_sg) { /* kernel has single buffer */ 2063 p = page_address(sg->page);
2190 for (j = 0, p = schp->buffer; j < onum; ++j) { 2064 ksglen = sg->length;
2191 res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); 2065 for (j = 0, k = 0; j < onum; ++j) {
2192 if (res) 2066 res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up);
2193 return res; 2067 if (res)
2194 usglen = (num_xfer > usglen) ? usglen : num_xfer; 2068 return res;
2195 if (__copy_to_user(up, p, usglen)) 2069
2196 return -EFAULT; 2070 for (; p; ++sg, ksglen = sg->length,
2197 p += usglen; 2071 p = page_address(sg->page)) {
2198 num_xfer -= usglen; 2072 if (usglen <= 0)
2199 if (num_xfer <= 0) 2073 break;
2200 return 0; 2074 if (ksglen > usglen) {
2201 } 2075 if (usglen >= num_xfer) {
2202 } else { /* kernel using scatter gather list */ 2076 if (__copy_to_user(up, p, num_xfer))
2203 struct scatterlist *sclp = (struct scatterlist *) schp->buffer;
2204
2205 ksglen = (int) sclp->length;
2206 p = sg_scatg2virt(sclp);
2207 for (j = 0, k = 0; j < onum; ++j) {
2208 res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up);
2209 if (res)
2210 return res;
2211
2212 for (; p; ++sclp, ksglen = (int) sclp->length,
2213 p = sg_scatg2virt(sclp)) {
2214 if (usglen <= 0)
2215 break;
2216 if (ksglen > usglen) {
2217 if (usglen >= num_xfer) {
2218 if (__copy_to_user
2219 (up, p, num_xfer))
2220 return -EFAULT;
2221 return 0;
2222 }
2223 if (__copy_to_user(up, p, usglen))
2224 return -EFAULT;
2225 p += usglen;
2226 ksglen -= usglen;
2227 break;
2228 } else {
2229 if (ksglen >= num_xfer) {
2230 if (__copy_to_user
2231 (up, p, num_xfer))
2232 return -EFAULT;
2233 return 0;
2234 }
2235 if (__copy_to_user(up, p, ksglen))
2236 return -EFAULT; 2077 return -EFAULT;
2237 up += ksglen; 2078 return 0;
2238 usglen -= ksglen;
2239 } 2079 }
2240 ++k; 2080 if (__copy_to_user(up, p, usglen))
2241 if (k >= schp->k_use_sg) 2081 return -EFAULT;
2082 p += usglen;
2083 ksglen -= usglen;
2084 break;
2085 } else {
2086 if (ksglen >= num_xfer) {
2087 if (__copy_to_user(up, p, num_xfer))
2088 return -EFAULT;
2242 return 0; 2089 return 0;
2090 }
2091 if (__copy_to_user(up, p, ksglen))
2092 return -EFAULT;
2093 up += ksglen;
2094 usglen -= ksglen;
2243 } 2095 }
2096 ++k;
2097 if (k >= schp->k_use_sg)
2098 return 0;
2244 } 2099 }
2245 } 2100 }
2101
2246 return 0; 2102 return 0;
2247} 2103}
2248 2104
@@ -2250,37 +2106,32 @@ static int
2250sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) 2106sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer)
2251{ 2107{
2252 Sg_scatter_hold *schp = &srp->data; 2108 Sg_scatter_hold *schp = &srp->data;
2109 struct scatterlist *sg = schp->buffer;
2110 int k, num;
2253 2111
2254 SCSI_LOG_TIMEOUT(4, printk("sg_read_oxfer: num_read_xfer=%d\n", 2112 SCSI_LOG_TIMEOUT(4, printk("sg_read_oxfer: num_read_xfer=%d\n",
2255 num_read_xfer)); 2113 num_read_xfer));
2256 if ((!outp) || (num_read_xfer <= 0)) 2114 if ((!outp) || (num_read_xfer <= 0))
2257 return 0; 2115 return 0;
2258 if (schp->k_use_sg > 0) { 2116
2259 int k, num; 2117 for (k = 0; (k < schp->k_use_sg) && sg->page; ++k, ++sg) {
2260 struct scatterlist *sclp = (struct scatterlist *) schp->buffer; 2118 num = sg->length;
2261 2119 if (num > num_read_xfer) {
2262 for (k = 0; (k < schp->k_use_sg) && sg_scatg2virt(sclp); 2120 if (__copy_to_user(outp, page_address(sg->page),
2263 ++k, ++sclp) { 2121 num_read_xfer))
2264 num = (int) sclp->length; 2122 return -EFAULT;
2265 if (num > num_read_xfer) { 2123 break;
2266 if (__copy_to_user 2124 } else {
2267 (outp, sg_scatg2virt(sclp), num_read_xfer)) 2125 if (__copy_to_user(outp, page_address(sg->page),
2268 return -EFAULT; 2126 num))
2127 return -EFAULT;
2128 num_read_xfer -= num;
2129 if (num_read_xfer <= 0)
2269 break; 2130 break;
2270 } else { 2131 outp += num;
2271 if (__copy_to_user
2272 (outp, sg_scatg2virt(sclp), num))
2273 return -EFAULT;
2274 num_read_xfer -= num;
2275 if (num_read_xfer <= 0)
2276 break;
2277 outp += num;
2278 }
2279 } 2132 }
2280 } else {
2281 if (__copy_to_user(outp, schp->buffer, num_read_xfer))
2282 return -EFAULT;
2283 } 2133 }
2134
2284 return 0; 2135 return 0;
2285} 2136}
2286 2137
@@ -2306,44 +2157,31 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size)
2306{ 2157{
2307 Sg_scatter_hold *req_schp = &srp->data; 2158 Sg_scatter_hold *req_schp = &srp->data;
2308 Sg_scatter_hold *rsv_schp = &sfp->reserve; 2159 Sg_scatter_hold *rsv_schp = &sfp->reserve;
2160 struct scatterlist *sg = rsv_schp->buffer;
2161 int k, num, rem;
2309 2162
2310 srp->res_used = 1; 2163 srp->res_used = 1;
2311 SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); 2164 SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size));
2312 size = (size + 1) & (~1); /* round to even for aha1542 */ 2165 rem = size = (size + 1) & (~1); /* round to even for aha1542 */
2313 if (rsv_schp->k_use_sg > 0) { 2166
2314 int k, num; 2167 for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) {
2315 int rem = size; 2168 num = sg->length;
2316 struct scatterlist *sclp = 2169 if (rem <= num) {
2317 (struct scatterlist *) rsv_schp->buffer; 2170 sfp->save_scat_len = num;
2318 2171 sg->length = rem;
2319 for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sclp) { 2172 req_schp->k_use_sg = k + 1;
2320 num = (int) sclp->length; 2173 req_schp->sglist_len = rsv_schp->sglist_len;
2321 if (rem <= num) { 2174 req_schp->buffer = rsv_schp->buffer;
2322 if (0 == k) { 2175
2323 req_schp->k_use_sg = 0; 2176 req_schp->bufflen = size;
2324 req_schp->buffer = sg_scatg2virt(sclp); 2177 req_schp->b_malloc_len = rsv_schp->b_malloc_len;
2325 } else { 2178 break;
2326 sfp->save_scat_len = num; 2179 } else
2327 sclp->length = (unsigned) rem; 2180 rem -= num;
2328 req_schp->k_use_sg = k + 1;
2329 req_schp->sglist_len =
2330 rsv_schp->sglist_len;
2331 req_schp->buffer = rsv_schp->buffer;
2332 }
2333 req_schp->bufflen = size;
2334 req_schp->b_malloc_len = rsv_schp->b_malloc_len;
2335 break;
2336 } else
2337 rem -= num;
2338 }
2339 if (k >= rsv_schp->k_use_sg)
2340 SCSI_LOG_TIMEOUT(1, printk("sg_link_reserve: BAD size\n"));
2341 } else {
2342 req_schp->k_use_sg = 0;
2343 req_schp->bufflen = size;
2344 req_schp->buffer = rsv_schp->buffer;
2345 req_schp->b_malloc_len = rsv_schp->b_malloc_len;
2346 } 2181 }
2182
2183 if (k >= rsv_schp->k_use_sg)
2184 SCSI_LOG_TIMEOUT(1, printk("sg_link_reserve: BAD size\n"));
2347} 2185}
2348 2186
2349static void 2187static void
@@ -2355,11 +2193,10 @@ sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp)
2355 SCSI_LOG_TIMEOUT(4, printk("sg_unlink_reserve: req->k_use_sg=%d\n", 2193 SCSI_LOG_TIMEOUT(4, printk("sg_unlink_reserve: req->k_use_sg=%d\n",
2356 (int) req_schp->k_use_sg)); 2194 (int) req_schp->k_use_sg));
2357 if ((rsv_schp->k_use_sg > 0) && (req_schp->k_use_sg > 0)) { 2195 if ((rsv_schp->k_use_sg > 0) && (req_schp->k_use_sg > 0)) {
2358 struct scatterlist *sclp = 2196 struct scatterlist *sg = rsv_schp->buffer;
2359 (struct scatterlist *) rsv_schp->buffer;
2360 2197
2361 if (sfp->save_scat_len > 0) 2198 if (sfp->save_scat_len > 0)
2362 (sclp + (req_schp->k_use_sg - 1))->length = 2199 (sg + (req_schp->k_use_sg - 1))->length =
2363 (unsigned) sfp->save_scat_len; 2200 (unsigned) sfp->save_scat_len;
2364 else 2201 else
2365 SCSI_LOG_TIMEOUT(1, printk ("sg_unlink_reserve: BAD save_scat_len\n")); 2202 SCSI_LOG_TIMEOUT(1, printk ("sg_unlink_reserve: BAD save_scat_len\n"));
@@ -2445,7 +2282,6 @@ sg_add_request(Sg_fd * sfp)
2445 if (resp) { 2282 if (resp) {
2446 resp->nextrp = NULL; 2283 resp->nextrp = NULL;
2447 resp->header.duration = jiffies_to_msecs(jiffies); 2284 resp->header.duration = jiffies_to_msecs(jiffies);
2448 resp->my_cmdp = NULL;
2449 } 2285 }
2450 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); 2286 write_unlock_irqrestore(&sfp->rq_list_lock, iflags);
2451 return resp; 2287 return resp;
@@ -2463,8 +2299,6 @@ sg_remove_request(Sg_fd * sfp, Sg_request * srp)
2463 if ((!sfp) || (!srp) || (!sfp->headrp)) 2299 if ((!sfp) || (!srp) || (!sfp->headrp))
2464 return res; 2300 return res;
2465 write_lock_irqsave(&sfp->rq_list_lock, iflags); 2301 write_lock_irqsave(&sfp->rq_list_lock, iflags);
2466 if (srp->my_cmdp)
2467 srp->my_cmdp->upper_private_data = NULL;
2468 prev_rp = sfp->headrp; 2302 prev_rp = sfp->headrp;
2469 if (srp == prev_rp) { 2303 if (srp == prev_rp) {
2470 sfp->headrp = prev_rp->nextrp; 2304 sfp->headrp = prev_rp->nextrp;
@@ -2507,10 +2341,10 @@ sg_add_sfp(Sg_device * sdp, int dev)
2507 Sg_fd *sfp; 2341 Sg_fd *sfp;
2508 unsigned long iflags; 2342 unsigned long iflags;
2509 2343
2510 sfp = (Sg_fd *) sg_page_malloc(sizeof (Sg_fd), 0, NULL); 2344 sfp = kzalloc(sizeof(*sfp), GFP_ATOMIC | __GFP_NOWARN);
2511 if (!sfp) 2345 if (!sfp)
2512 return NULL; 2346 return NULL;
2513 memset(sfp, 0, sizeof (Sg_fd)); 2347
2514 init_waitqueue_head(&sfp->read_wait); 2348 init_waitqueue_head(&sfp->read_wait);
2515 rwlock_init(&sfp->rq_list_lock); 2349 rwlock_init(&sfp->rq_list_lock);
2516 2350
@@ -2567,7 +2401,7 @@ __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp)
2567 } 2401 }
2568 sfp->parentdp = NULL; 2402 sfp->parentdp = NULL;
2569 SCSI_LOG_TIMEOUT(6, printk("__sg_remove_sfp: sfp=0x%p\n", sfp)); 2403 SCSI_LOG_TIMEOUT(6, printk("__sg_remove_sfp: sfp=0x%p\n", sfp));
2570 sg_page_free((char *) sfp, sizeof (Sg_fd)); 2404 kfree(sfp);
2571} 2405}
2572 2406
2573/* Returns 0 in normal case, 1 when detached and sdp object removed */ 2407/* Returns 0 in normal case, 1 when detached and sdp object removed */
@@ -2632,10 +2466,10 @@ sg_res_in_use(Sg_fd * sfp)
2632} 2466}
2633 2467
2634/* If retSzp==NULL want exact size or fail */ 2468/* If retSzp==NULL want exact size or fail */
2635static char * 2469static struct page *
2636sg_page_malloc(int rqSz, int lowDma, int *retSzp) 2470sg_page_malloc(int rqSz, int lowDma, int *retSzp)
2637{ 2471{
2638 char *resp = NULL; 2472 struct page *resp = NULL;
2639 gfp_t page_mask; 2473 gfp_t page_mask;
2640 int order, a_size; 2474 int order, a_size;
2641 int resSz = rqSz; 2475 int resSz = rqSz;
@@ -2650,11 +2484,11 @@ sg_page_malloc(int rqSz, int lowDma, int *retSzp)
2650 2484
2651 for (order = 0, a_size = PAGE_SIZE; a_size < rqSz; 2485 for (order = 0, a_size = PAGE_SIZE; a_size < rqSz;
2652 order++, a_size <<= 1) ; 2486 order++, a_size <<= 1) ;
2653 resp = (char *) __get_free_pages(page_mask, order); 2487 resp = alloc_pages(page_mask, order);
2654 while ((!resp) && order && retSzp) { 2488 while ((!resp) && order && retSzp) {
2655 --order; 2489 --order;
2656 a_size >>= 1; /* divide by 2, until PAGE_SIZE */ 2490 a_size >>= 1; /* divide by 2, until PAGE_SIZE */
2657 resp = (char *) __get_free_pages(page_mask, order); /* try half */ 2491 resp = alloc_pages(page_mask, order); /* try half */
2658 resSz = a_size; 2492 resSz = a_size;
2659 } 2493 }
2660 if (resp) { 2494 if (resp) {
@@ -2667,15 +2501,15 @@ sg_page_malloc(int rqSz, int lowDma, int *retSzp)
2667} 2501}
2668 2502
2669static void 2503static void
2670sg_page_free(char *buff, int size) 2504sg_page_free(struct page *page, int size)
2671{ 2505{
2672 int order, a_size; 2506 int order, a_size;
2673 2507
2674 if (!buff) 2508 if (!page)
2675 return; 2509 return;
2676 for (order = 0, a_size = PAGE_SIZE; a_size < size; 2510 for (order = 0, a_size = PAGE_SIZE; a_size < size;
2677 order++, a_size <<= 1) ; 2511 order++, a_size <<= 1) ;
2678 free_pages((unsigned long) buff, order); 2512 __free_pages(page, order);
2679} 2513}
2680 2514
2681#ifndef MAINTENANCE_IN_CMD 2515#ifndef MAINTENANCE_IN_CMD
@@ -3067,13 +2901,11 @@ static void sg_proc_debug_helper(struct seq_file *s, Sg_device * sdp)
3067 cp = " "; 2901 cp = " ";
3068 } 2902 }
3069 seq_printf(s, cp); 2903 seq_printf(s, cp);
3070 blen = srp->my_cmdp ? 2904 blen = srp->data.bufflen;
3071 srp->my_cmdp->sr_bufflen : srp->data.bufflen; 2905 usg = srp->data.k_use_sg;
3072 usg = srp->my_cmdp ?
3073 srp->my_cmdp->sr_use_sg : srp->data.k_use_sg;
3074 seq_printf(s, srp->done ? 2906 seq_printf(s, srp->done ?
3075 ((1 == srp->done) ? "rcv:" : "fin:") 2907 ((1 == srp->done) ? "rcv:" : "fin:")
3076 : (srp->my_cmdp ? "act:" : "prior:")); 2908 : "act:");
3077 seq_printf(s, " id=%d blen=%d", 2909 seq_printf(s, " id=%d blen=%d",
3078 srp->header.pack_id, blen); 2910 srp->header.pack_id, blen);
3079 if (srp->done) 2911 if (srp->done)
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index d68cea753bb2..a4d9be7c6874 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -320,25 +320,11 @@ static int sr_init_command(struct scsi_cmnd * SCpnt)
320 * these are already setup, just copy cdb basically 320 * these are already setup, just copy cdb basically
321 */ 321 */
322 if (SCpnt->request->flags & REQ_BLOCK_PC) { 322 if (SCpnt->request->flags & REQ_BLOCK_PC) {
323 struct request *rq = SCpnt->request; 323 scsi_setup_blk_pc_cmnd(SCpnt);
324 324
325 if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd)) 325 if (SCpnt->timeout_per_command)
326 return 0; 326 timeout = SCpnt->timeout_per_command;
327
328 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
329 SCpnt->cmd_len = rq->cmd_len;
330 if (!rq->data_len)
331 SCpnt->sc_data_direction = DMA_NONE;
332 else if (rq_data_dir(rq) == WRITE)
333 SCpnt->sc_data_direction = DMA_TO_DEVICE;
334 else
335 SCpnt->sc_data_direction = DMA_FROM_DEVICE;
336
337 this_count = rq->data_len;
338 if (rq->timeout)
339 timeout = rq->timeout;
340 327
341 SCpnt->transfersize = rq->data_len;
342 goto queue; 328 goto queue;
343 } 329 }
344 330
@@ -730,7 +716,7 @@ static void get_capabilities(struct scsi_cd *cd)
730 unsigned int the_result; 716 unsigned int the_result;
731 int retries, rc, n; 717 int retries, rc, n;
732 718
733 static char *loadmech[] = 719 static const char *loadmech[] =
734 { 720 {
735 "caddy", 721 "caddy",
736 "tray", 722 "tray",
diff --git a/drivers/scsi/sr_vendor.c b/drivers/scsi/sr_vendor.c
index 78274dc91f5c..9dde8df2f5c9 100644
--- a/drivers/scsi/sr_vendor.c
+++ b/drivers/scsi/sr_vendor.c
@@ -68,8 +68,8 @@ void sr_vendor_init(Scsi_CD *cd)
68#ifndef CONFIG_BLK_DEV_SR_VENDOR 68#ifndef CONFIG_BLK_DEV_SR_VENDOR
69 cd->vendor = VENDOR_SCSI3; 69 cd->vendor = VENDOR_SCSI3;
70#else 70#else
71 char *vendor = cd->device->vendor; 71 const char *vendor = cd->device->vendor;
72 char *model = cd->device->model; 72 const char *model = cd->device->model;
73 73
74 /* default */ 74 /* default */
75 cd->vendor = VENDOR_SCSI3; 75 cd->vendor = VENDOR_SCSI3;
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 7ac6ea141fff..c4aade8f5345 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -17,7 +17,7 @@
17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support 17 Last modified: 18-JAN-1998 Richard Gooch <rgooch@atnf.csiro.au> Devfs support
18 */ 18 */
19 19
20static char *verstr = "20050830"; 20static const char *verstr = "20050830";
21 21
22#include <linux/module.h> 22#include <linux/module.h>
23 23
@@ -50,7 +50,6 @@ static char *verstr = "20050830";
50#include <scsi/scsi_eh.h> 50#include <scsi/scsi_eh.h>
51#include <scsi/scsi_host.h> 51#include <scsi/scsi_host.h>
52#include <scsi/scsi_ioctl.h> 52#include <scsi/scsi_ioctl.h>
53#include <scsi/scsi_request.h>
54#include <scsi/sg.h> 53#include <scsi/sg.h>
55 54
56 55
@@ -134,7 +133,7 @@ static struct st_dev_parm {
134#endif 133#endif
135/* Bit reversed order to get same names for same minors with all 134/* Bit reversed order to get same names for same minors with all
136 mode counts */ 135 mode counts */
137static char *st_formats[] = { 136static const char *st_formats[] = {
138 "", "r", "k", "s", "l", "t", "o", "u", 137 "", "r", "k", "s", "l", "t", "o", "u",
139 "m", "v", "p", "x", "a", "y", "q", "z"}; 138 "m", "v", "p", "x", "a", "y", "q", "z"};
140 139
@@ -188,8 +187,6 @@ static int from_buffer(struct st_buffer *, char __user *, int);
188static void move_buffer_data(struct st_buffer *, int); 187static void move_buffer_data(struct st_buffer *, int);
189static void buf_to_sg(struct st_buffer *, unsigned int); 188static void buf_to_sg(struct st_buffer *, unsigned int);
190 189
191static int st_map_user_pages(struct scatterlist *, const unsigned int,
192 unsigned long, size_t, int, unsigned long);
193static int sgl_map_user_pages(struct scatterlist *, const unsigned int, 190static int sgl_map_user_pages(struct scatterlist *, const unsigned int,
194 unsigned long, size_t, int); 191 unsigned long, size_t, int);
195static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int); 192static int sgl_unmap_user_pages(struct scatterlist *, const unsigned int, int);
@@ -313,12 +310,13 @@ static inline char *tape_name(struct scsi_tape *tape)
313} 310}
314 311
315 312
316static void st_analyze_sense(struct scsi_request *SRpnt, struct st_cmdstatus *s) 313static void st_analyze_sense(struct st_request *SRpnt, struct st_cmdstatus *s)
317{ 314{
318 const u8 *ucp; 315 const u8 *ucp;
319 const u8 *sense = SRpnt->sr_sense_buffer; 316 const u8 *sense = SRpnt->sense;
320 317
321 s->have_sense = scsi_request_normalize_sense(SRpnt, &s->sense_hdr); 318 s->have_sense = scsi_normalize_sense(SRpnt->sense,
319 SCSI_SENSE_BUFFERSIZE, &s->sense_hdr);
322 s->flags = 0; 320 s->flags = 0;
323 321
324 if (s->have_sense) { 322 if (s->have_sense) {
@@ -345,9 +343,9 @@ static void st_analyze_sense(struct scsi_request *SRpnt, struct st_cmdstatus *s)
345 343
346 344
347/* Convert the result to success code */ 345/* Convert the result to success code */
348static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt) 346static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)
349{ 347{
350 int result = SRpnt->sr_result; 348 int result = SRpnt->result;
351 u8 scode; 349 u8 scode;
352 DEB(const char *stp;) 350 DEB(const char *stp;)
353 char *name = tape_name(STp); 351 char *name = tape_name(STp);
@@ -366,13 +364,12 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt)
366 364
367 DEB( 365 DEB(
368 if (debugging) { 366 if (debugging) {
369 printk(ST_DEB_MSG "%s: Error: %x, cmd: %x %x %x %x %x %x Len: %d\n", 367 printk(ST_DEB_MSG "%s: Error: %x, cmd: %x %x %x %x %x %x\n",
370 name, result, 368 name, result,
371 SRpnt->sr_cmnd[0], SRpnt->sr_cmnd[1], SRpnt->sr_cmnd[2], 369 SRpnt->cmd[0], SRpnt->cmd[1], SRpnt->cmd[2],
372 SRpnt->sr_cmnd[3], SRpnt->sr_cmnd[4], SRpnt->sr_cmnd[5], 370 SRpnt->cmd[3], SRpnt->cmd[4], SRpnt->cmd[5]);
373 SRpnt->sr_bufflen);
374 if (cmdstatp->have_sense) 371 if (cmdstatp->have_sense)
375 scsi_print_req_sense("st", SRpnt); 372 __scsi_print_sense("st", SRpnt->sense, SCSI_SENSE_BUFFERSIZE);
376 } ) /* end DEB */ 373 } ) /* end DEB */
377 if (!debugging) { /* Abnormal conditions for tape */ 374 if (!debugging) { /* Abnormal conditions for tape */
378 if (!cmdstatp->have_sense) 375 if (!cmdstatp->have_sense)
@@ -386,20 +383,21 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt)
386 /* scode != UNIT_ATTENTION && */ 383 /* scode != UNIT_ATTENTION && */
387 scode != BLANK_CHECK && 384 scode != BLANK_CHECK &&
388 scode != VOLUME_OVERFLOW && 385 scode != VOLUME_OVERFLOW &&
389 SRpnt->sr_cmnd[0] != MODE_SENSE && 386 SRpnt->cmd[0] != MODE_SENSE &&
390 SRpnt->sr_cmnd[0] != TEST_UNIT_READY) { 387 SRpnt->cmd[0] != TEST_UNIT_READY) {
391 printk(KERN_WARNING "%s: Error with sense data: ", name); 388 printk(KERN_WARNING "%s: Error with sense data: ", name);
392 scsi_print_req_sense("st", SRpnt); 389 __scsi_print_sense("st", SRpnt->sense,
390 SCSI_SENSE_BUFFERSIZE);
393 } 391 }
394 } 392 }
395 393
396 if (cmdstatp->fixed_format && 394 if (cmdstatp->fixed_format &&
397 STp->cln_mode >= EXTENDED_SENSE_START) { /* Only fixed format sense */ 395 STp->cln_mode >= EXTENDED_SENSE_START) { /* Only fixed format sense */
398 if (STp->cln_sense_value) 396 if (STp->cln_sense_value)
399 STp->cleaning_req |= ((SRpnt->sr_sense_buffer[STp->cln_mode] & 397 STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] &
400 STp->cln_sense_mask) == STp->cln_sense_value); 398 STp->cln_sense_mask) == STp->cln_sense_value);
401 else 399 else
402 STp->cleaning_req |= ((SRpnt->sr_sense_buffer[STp->cln_mode] & 400 STp->cleaning_req |= ((SRpnt->sense[STp->cln_mode] &
403 STp->cln_sense_mask) != 0); 401 STp->cln_sense_mask) != 0);
404 } 402 }
405 if (cmdstatp->have_sense && 403 if (cmdstatp->have_sense &&
@@ -411,8 +409,8 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt)
411 if (cmdstatp->have_sense && 409 if (cmdstatp->have_sense &&
412 scode == RECOVERED_ERROR 410 scode == RECOVERED_ERROR
413#if ST_RECOVERED_WRITE_FATAL 411#if ST_RECOVERED_WRITE_FATAL
414 && SRpnt->sr_cmnd[0] != WRITE_6 412 && SRpnt->cmd[0] != WRITE_6
415 && SRpnt->sr_cmnd[0] != WRITE_FILEMARKS 413 && SRpnt->cmd[0] != WRITE_FILEMARKS
416#endif 414#endif
417 ) { 415 ) {
418 STp->recover_count++; 416 STp->recover_count++;
@@ -420,9 +418,9 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt)
420 418
421 DEB( 419 DEB(
422 if (debugging) { 420 if (debugging) {
423 if (SRpnt->sr_cmnd[0] == READ_6) 421 if (SRpnt->cmd[0] == READ_6)
424 stp = "read"; 422 stp = "read";
425 else if (SRpnt->sr_cmnd[0] == WRITE_6) 423 else if (SRpnt->cmd[0] == WRITE_6)
426 stp = "write"; 424 stp = "write";
427 else 425 else
428 stp = "ioctl"; 426 stp = "ioctl";
@@ -438,28 +436,37 @@ static int st_chk_result(struct scsi_tape *STp, struct scsi_request * SRpnt)
438 436
439 437
440/* Wakeup from interrupt */ 438/* Wakeup from interrupt */
441static void st_sleep_done(struct scsi_cmnd * SCpnt) 439static void st_sleep_done(void *data, char *sense, int result, int resid)
442{ 440{
443 struct scsi_tape *STp = container_of(SCpnt->request->rq_disk->private_data, 441 struct st_request *SRpnt = data;
444 struct scsi_tape, driver); 442 struct scsi_tape *STp = SRpnt->stp;
445 443
446 (STp->buffer)->cmdstat.midlevel_result = SCpnt->result; 444 memcpy(SRpnt->sense, sense, SCSI_SENSE_BUFFERSIZE);
447 SCpnt->request->rq_status = RQ_SCSI_DONE; 445 (STp->buffer)->cmdstat.midlevel_result = SRpnt->result = result;
448 DEB( STp->write_pending = 0; ) 446 DEB( STp->write_pending = 0; )
449 447
450 if (SCpnt->request->waiting) 448 if (SRpnt->waiting)
451 complete(SCpnt->request->waiting); 449 complete(SRpnt->waiting);
450}
451
452static struct st_request *st_allocate_request(void)
453{
454 return kzalloc(sizeof(struct st_request), GFP_KERNEL);
455}
456
457static void st_release_request(struct st_request *streq)
458{
459 kfree(streq);
452} 460}
453 461
454/* Do the scsi command. Waits until command performed if do_wait is true. 462/* Do the scsi command. Waits until command performed if do_wait is true.
455 Otherwise write_behind_check() is used to check that the command 463 Otherwise write_behind_check() is used to check that the command
456 has finished. */ 464 has finished. */
457static struct scsi_request * 465static struct st_request *
458st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd, 466st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd,
459 int bytes, int direction, int timeout, int retries, int do_wait) 467 int bytes, int direction, int timeout, int retries, int do_wait)
460{ 468{
461 struct completion *waiting; 469 struct completion *waiting;
462 unsigned char *bp;
463 470
464 /* if async, make sure there's no command outstanding */ 471 /* if async, make sure there's no command outstanding */
465 if (!do_wait && ((STp->buffer)->last_SRpnt)) { 472 if (!do_wait && ((STp->buffer)->last_SRpnt)) {
@@ -473,7 +480,7 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c
473 } 480 }
474 481
475 if (SRpnt == NULL) { 482 if (SRpnt == NULL) {
476 SRpnt = scsi_allocate_request(STp->device, GFP_ATOMIC); 483 SRpnt = st_allocate_request();
477 if (SRpnt == NULL) { 484 if (SRpnt == NULL) {
478 DEBC( printk(KERN_ERR "%s: Can't get SCSI request.\n", 485 DEBC( printk(KERN_ERR "%s: Can't get SCSI request.\n",
479 tape_name(STp)); ); 486 tape_name(STp)); );
@@ -483,6 +490,7 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c
483 (STp->buffer)->syscall_result = (-EBUSY); 490 (STp->buffer)->syscall_result = (-EBUSY);
484 return NULL; 491 return NULL;
485 } 492 }
493 SRpnt->stp = STp;
486 } 494 }
487 495
488 /* If async IO, set last_SRpnt. This ptr tells write_behind_check 496 /* If async IO, set last_SRpnt. This ptr tells write_behind_check
@@ -492,32 +500,28 @@ st_do_scsi(struct scsi_request * SRpnt, struct scsi_tape * STp, unsigned char *c
492 500
493 waiting = &STp->wait; 501 waiting = &STp->wait;
494 init_completion(waiting); 502 init_completion(waiting);
495 SRpnt->sr_use_sg = STp->buffer->do_dio || (bytes > (STp->buffer)->frp[0].length); 503 SRpnt->waiting = waiting;
496 if (SRpnt->sr_use_sg) {
497 if (!STp->buffer->do_dio)
498 buf_to_sg(STp->buffer, bytes);
499 SRpnt->sr_use_sg = (STp->buffer)->sg_segs;
500 bp = (char *) &((STp->buffer)->sg[0]);
501 } else
502 bp = (STp->buffer)->b_data;
503 SRpnt->sr_data_direction = direction;
504 SRpnt->sr_cmd_len = 0;
505 SRpnt->sr_request->waiting = waiting;
506 SRpnt->sr_request->rq_status = RQ_SCSI_BUSY;
507 SRpnt->sr_request->rq_disk = STp->disk;
508 SRpnt->sr_request->end_io = blk_end_sync_rq;
509 STp->buffer->cmdstat.have_sense = 0;
510 504
511 scsi_do_req(SRpnt, (void *) cmd, bp, bytes, 505 if (!STp->buffer->do_dio)
512 st_sleep_done, timeout, retries); 506 buf_to_sg(STp->buffer, bytes);
513 507
514 if (do_wait) { 508 memcpy(SRpnt->cmd, cmd, sizeof(SRpnt->cmd));
509 STp->buffer->cmdstat.have_sense = 0;
510 STp->buffer->syscall_result = 0;
511
512 if (scsi_execute_async(STp->device, cmd, direction,
513 &((STp->buffer)->sg[0]), bytes, (STp->buffer)->sg_segs,
514 timeout, retries, SRpnt, st_sleep_done, GFP_KERNEL)) {
515 /* could not allocate the buffer or request was too large */
516 (STp->buffer)->syscall_result = (-EBUSY);
517 (STp->buffer)->last_SRpnt = NULL;
518 }
519 else if (do_wait) {
515 wait_for_completion(waiting); 520 wait_for_completion(waiting);
516 SRpnt->sr_request->waiting = NULL; 521 SRpnt->waiting = NULL;
517 if (SRpnt->sr_request->rq_status != RQ_SCSI_DONE)
518 SRpnt->sr_result |= (DRIVER_ERROR << 24);
519 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); 522 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt);
520 } 523 }
524
521 return SRpnt; 525 return SRpnt;
522} 526}
523 527
@@ -532,7 +536,7 @@ static int write_behind_check(struct scsi_tape * STp)
532 struct st_buffer *STbuffer; 536 struct st_buffer *STbuffer;
533 struct st_partstat *STps; 537 struct st_partstat *STps;
534 struct st_cmdstatus *cmdstatp; 538 struct st_cmdstatus *cmdstatp;
535 struct scsi_request *SRpnt; 539 struct st_request *SRpnt;
536 540
537 STbuffer = STp->buffer; 541 STbuffer = STp->buffer;
538 if (!STbuffer->writing) 542 if (!STbuffer->writing)
@@ -548,12 +552,10 @@ static int write_behind_check(struct scsi_tape * STp)
548 wait_for_completion(&(STp->wait)); 552 wait_for_completion(&(STp->wait));
549 SRpnt = STbuffer->last_SRpnt; 553 SRpnt = STbuffer->last_SRpnt;
550 STbuffer->last_SRpnt = NULL; 554 STbuffer->last_SRpnt = NULL;
551 SRpnt->sr_request->waiting = NULL; 555 SRpnt->waiting = NULL;
552 if (SRpnt->sr_request->rq_status != RQ_SCSI_DONE)
553 SRpnt->sr_result |= (DRIVER_ERROR << 24);
554 556
555 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt); 557 (STp->buffer)->syscall_result = st_chk_result(STp, SRpnt);
556 scsi_release_request(SRpnt); 558 st_release_request(SRpnt);
557 559
558 STbuffer->buffer_bytes -= STbuffer->writing; 560 STbuffer->buffer_bytes -= STbuffer->writing;
559 STps = &(STp->ps[STp->partition]); 561 STps = &(STp->ps[STp->partition]);
@@ -593,7 +595,7 @@ static int write_behind_check(struct scsi_tape * STp)
593 it messes up the block number). */ 595 it messes up the block number). */
594static int cross_eof(struct scsi_tape * STp, int forward) 596static int cross_eof(struct scsi_tape * STp, int forward)
595{ 597{
596 struct scsi_request *SRpnt; 598 struct st_request *SRpnt;
597 unsigned char cmd[MAX_COMMAND_SIZE]; 599 unsigned char cmd[MAX_COMMAND_SIZE];
598 600
599 cmd[0] = SPACE; 601 cmd[0] = SPACE;
@@ -613,7 +615,7 @@ static int cross_eof(struct scsi_tape * STp, int forward)
613 if (!SRpnt) 615 if (!SRpnt)
614 return (STp->buffer)->syscall_result; 616 return (STp->buffer)->syscall_result;
615 617
616 scsi_release_request(SRpnt); 618 st_release_request(SRpnt);
617 SRpnt = NULL; 619 SRpnt = NULL;
618 620
619 if ((STp->buffer)->cmdstat.midlevel_result != 0) 621 if ((STp->buffer)->cmdstat.midlevel_result != 0)
@@ -630,7 +632,7 @@ static int flush_write_buffer(struct scsi_tape * STp)
630 int offset, transfer, blks; 632 int offset, transfer, blks;
631 int result; 633 int result;
632 unsigned char cmd[MAX_COMMAND_SIZE]; 634 unsigned char cmd[MAX_COMMAND_SIZE];
633 struct scsi_request *SRpnt; 635 struct st_request *SRpnt;
634 struct st_partstat *STps; 636 struct st_partstat *STps;
635 637
636 result = write_behind_check(STp); 638 result = write_behind_check(STp);
@@ -688,7 +690,7 @@ static int flush_write_buffer(struct scsi_tape * STp)
688 STp->dirty = 0; 690 STp->dirty = 0;
689 (STp->buffer)->buffer_bytes = 0; 691 (STp->buffer)->buffer_bytes = 0;
690 } 692 }
691 scsi_release_request(SRpnt); 693 st_release_request(SRpnt);
692 SRpnt = NULL; 694 SRpnt = NULL;
693 } 695 }
694 return result; 696 return result;
@@ -785,7 +787,7 @@ static int set_mode_densblk(struct scsi_tape * STp, struct st_modedef * STm)
785} 787}
786 788
787 789
788/* Lock or unlock the drive door. Don't use when scsi_request allocated. */ 790/* Lock or unlock the drive door. Don't use when st_request allocated. */
789static int do_door_lock(struct scsi_tape * STp, int do_lock) 791static int do_door_lock(struct scsi_tape * STp, int do_lock)
790{ 792{
791 int retval, cmd; 793 int retval, cmd;
@@ -844,7 +846,7 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
844 int attentions, waits, max_wait, scode; 846 int attentions, waits, max_wait, scode;
845 int retval = CHKRES_READY, new_session = 0; 847 int retval = CHKRES_READY, new_session = 0;
846 unsigned char cmd[MAX_COMMAND_SIZE]; 848 unsigned char cmd[MAX_COMMAND_SIZE];
847 struct scsi_request *SRpnt = NULL; 849 struct st_request *SRpnt = NULL;
848 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat; 850 struct st_cmdstatus *cmdstatp = &STp->buffer->cmdstat;
849 851
850 max_wait = do_wait ? ST_BLOCK_SECONDS : 0; 852 max_wait = do_wait ? ST_BLOCK_SECONDS : 0;
@@ -903,7 +905,7 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
903 } 905 }
904 906
905 if (SRpnt != NULL) 907 if (SRpnt != NULL)
906 scsi_release_request(SRpnt); 908 st_release_request(SRpnt);
907 return retval; 909 return retval;
908} 910}
909 911
@@ -918,7 +920,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
918 int i, retval, new_session = 0, do_wait; 920 int i, retval, new_session = 0, do_wait;
919 unsigned char cmd[MAX_COMMAND_SIZE], saved_cleaning; 921 unsigned char cmd[MAX_COMMAND_SIZE], saved_cleaning;
920 unsigned short st_flags = filp->f_flags; 922 unsigned short st_flags = filp->f_flags;
921 struct scsi_request *SRpnt = NULL; 923 struct st_request *SRpnt = NULL;
922 struct st_modedef *STm; 924 struct st_modedef *STm;
923 struct st_partstat *STps; 925 struct st_partstat *STps;
924 char *name = tape_name(STp); 926 char *name = tape_name(STp);
@@ -993,7 +995,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
993 goto err_out; 995 goto err_out;
994 } 996 }
995 997
996 if (!SRpnt->sr_result && !STp->buffer->cmdstat.have_sense) { 998 if (!SRpnt->result && !STp->buffer->cmdstat.have_sense) {
997 STp->max_block = ((STp->buffer)->b_data[1] << 16) | 999 STp->max_block = ((STp->buffer)->b_data[1] << 16) |
998 ((STp->buffer)->b_data[2] << 8) | (STp->buffer)->b_data[3]; 1000 ((STp->buffer)->b_data[2] << 8) | (STp->buffer)->b_data[3];
999 STp->min_block = ((STp->buffer)->b_data[4] << 8) | 1001 STp->min_block = ((STp->buffer)->b_data[4] << 8) |
@@ -1045,7 +1047,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp)
1045 } 1047 }
1046 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0; 1048 STp->drv_write_prot = ((STp->buffer)->b_data[2] & 0x80) != 0;
1047 } 1049 }
1048 scsi_release_request(SRpnt); 1050 st_release_request(SRpnt);
1049 SRpnt = NULL; 1051 SRpnt = NULL;
1050 STp->inited = 1; 1052 STp->inited = 1;
1051 1053
@@ -1196,7 +1198,7 @@ static int st_flush(struct file *filp)
1196{ 1198{
1197 int result = 0, result2; 1199 int result = 0, result2;
1198 unsigned char cmd[MAX_COMMAND_SIZE]; 1200 unsigned char cmd[MAX_COMMAND_SIZE];
1199 struct scsi_request *SRpnt; 1201 struct st_request *SRpnt;
1200 struct scsi_tape *STp = filp->private_data; 1202 struct scsi_tape *STp = filp->private_data;
1201 struct st_modedef *STm = &(STp->modes[STp->current_mode]); 1203 struct st_modedef *STm = &(STp->modes[STp->current_mode]);
1202 struct st_partstat *STps = &(STp->ps[STp->partition]); 1204 struct st_partstat *STps = &(STp->ps[STp->partition]);
@@ -1249,7 +1251,7 @@ static int st_flush(struct file *filp)
1249 cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) && 1251 cmdstatp->sense_hdr.sense_key == RECOVERED_ERROR) &&
1250 (!cmdstatp->remainder_valid || cmdstatp->uremainder64 == 0))) { 1252 (!cmdstatp->remainder_valid || cmdstatp->uremainder64 == 0))) {
1251 /* Write successful at EOM */ 1253 /* Write successful at EOM */
1252 scsi_release_request(SRpnt); 1254 st_release_request(SRpnt);
1253 SRpnt = NULL; 1255 SRpnt = NULL;
1254 if (STps->drv_file >= 0) 1256 if (STps->drv_file >= 0)
1255 STps->drv_file++; 1257 STps->drv_file++;
@@ -1259,7 +1261,7 @@ static int st_flush(struct file *filp)
1259 STps->eof = ST_FM; 1261 STps->eof = ST_FM;
1260 } 1262 }
1261 else { /* Write error */ 1263 else { /* Write error */
1262 scsi_release_request(SRpnt); 1264 st_release_request(SRpnt);
1263 SRpnt = NULL; 1265 SRpnt = NULL;
1264 printk(KERN_ERR "%s: Error on write filemark.\n", name); 1266 printk(KERN_ERR "%s: Error on write filemark.\n", name);
1265 if (result == 0) 1267 if (result == 0)
@@ -1400,11 +1402,11 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf,
1400 i = STp->try_dio && try_rdio; 1402 i = STp->try_dio && try_rdio;
1401 else 1403 else
1402 i = STp->try_dio && try_wdio; 1404 i = STp->try_dio && try_wdio;
1405
1403 if (i && ((unsigned long)buf & queue_dma_alignment( 1406 if (i && ((unsigned long)buf & queue_dma_alignment(
1404 STp->device->request_queue)) == 0) { 1407 STp->device->request_queue)) == 0) {
1405 i = st_map_user_pages(&(STbp->sg[0]), STbp->use_sg, 1408 i = sgl_map_user_pages(&(STbp->sg[0]), STbp->use_sg,
1406 (unsigned long)buf, count, (is_read ? READ : WRITE), 1409 (unsigned long)buf, count, (is_read ? READ : WRITE));
1407 STp->max_pfn);
1408 if (i > 0) { 1410 if (i > 0) {
1409 STbp->do_dio = i; 1411 STbp->do_dio = i;
1410 STbp->buffer_bytes = 0; /* can be used as transfer counter */ 1412 STbp->buffer_bytes = 0; /* can be used as transfer counter */
@@ -1449,14 +1451,15 @@ static int setup_buffering(struct scsi_tape *STp, const char __user *buf,
1449 1451
1450 1452
1451/* Can be called more than once after each setup_buffer() */ 1453/* Can be called more than once after each setup_buffer() */
1452static void release_buffering(struct scsi_tape *STp) 1454static void release_buffering(struct scsi_tape *STp, int is_read)
1453{ 1455{
1454 struct st_buffer *STbp; 1456 struct st_buffer *STbp;
1455 1457
1456 STbp = STp->buffer; 1458 STbp = STp->buffer;
1457 if (STbp->do_dio) { 1459 if (STbp->do_dio) {
1458 sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, 0); 1460 sgl_unmap_user_pages(&(STbp->sg[0]), STbp->do_dio, is_read);
1459 STbp->do_dio = 0; 1461 STbp->do_dio = 0;
1462 STbp->sg_segs = 0;
1460 } 1463 }
1461} 1464}
1462 1465
@@ -1472,7 +1475,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1472 int async_write; 1475 int async_write;
1473 unsigned char cmd[MAX_COMMAND_SIZE]; 1476 unsigned char cmd[MAX_COMMAND_SIZE];
1474 const char __user *b_point; 1477 const char __user *b_point;
1475 struct scsi_request *SRpnt = NULL; 1478 struct st_request *SRpnt = NULL;
1476 struct scsi_tape *STp = filp->private_data; 1479 struct scsi_tape *STp = filp->private_data;
1477 struct st_modedef *STm; 1480 struct st_modedef *STm;
1478 struct st_partstat *STps; 1481 struct st_partstat *STps;
@@ -1624,7 +1627,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1624 retval = STbp->syscall_result; 1627 retval = STbp->syscall_result;
1625 goto out; 1628 goto out;
1626 } 1629 }
1627 if (async_write) { 1630 if (async_write && !STbp->syscall_result) {
1628 STbp->writing = transfer; 1631 STbp->writing = transfer;
1629 STp->dirty = !(STbp->writing == 1632 STp->dirty = !(STbp->writing ==
1630 STbp->buffer_bytes); 1633 STbp->buffer_bytes);
@@ -1698,7 +1701,7 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1698 } else { 1701 } else {
1699 count += do_count; 1702 count += do_count;
1700 STps->drv_block = (-1); /* Too cautious? */ 1703 STps->drv_block = (-1); /* Too cautious? */
1701 retval = (-EIO); 1704 retval = STbp->syscall_result;
1702 } 1705 }
1703 1706
1704 } 1707 }
@@ -1728,8 +1731,8 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1728 1731
1729 out: 1732 out:
1730 if (SRpnt != NULL) 1733 if (SRpnt != NULL)
1731 scsi_release_request(SRpnt); 1734 st_release_request(SRpnt);
1732 release_buffering(STp); 1735 release_buffering(STp, 0);
1733 up(&STp->lock); 1736 up(&STp->lock);
1734 1737
1735 return retval; 1738 return retval;
@@ -1742,11 +1745,11 @@ st_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
1742 Does release user buffer mapping if it is set. 1745 Does release user buffer mapping if it is set.
1743*/ 1746*/
1744static long read_tape(struct scsi_tape *STp, long count, 1747static long read_tape(struct scsi_tape *STp, long count,
1745 struct scsi_request ** aSRpnt) 1748 struct st_request ** aSRpnt)
1746{ 1749{
1747 int transfer, blks, bytes; 1750 int transfer, blks, bytes;
1748 unsigned char cmd[MAX_COMMAND_SIZE]; 1751 unsigned char cmd[MAX_COMMAND_SIZE];
1749 struct scsi_request *SRpnt; 1752 struct st_request *SRpnt;
1750 struct st_modedef *STm; 1753 struct st_modedef *STm;
1751 struct st_partstat *STps; 1754 struct st_partstat *STps;
1752 struct st_buffer *STbp; 1755 struct st_buffer *STbp;
@@ -1787,7 +1790,7 @@ static long read_tape(struct scsi_tape *STp, long count,
1787 SRpnt = *aSRpnt; 1790 SRpnt = *aSRpnt;
1788 SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE, 1791 SRpnt = st_do_scsi(SRpnt, STp, cmd, bytes, DMA_FROM_DEVICE,
1789 STp->device->timeout, MAX_RETRIES, 1); 1792 STp->device->timeout, MAX_RETRIES, 1);
1790 release_buffering(STp); 1793 release_buffering(STp, 1);
1791 *aSRpnt = SRpnt; 1794 *aSRpnt = SRpnt;
1792 if (!SRpnt) 1795 if (!SRpnt)
1793 return STbp->syscall_result; 1796 return STbp->syscall_result;
@@ -1802,10 +1805,10 @@ static long read_tape(struct scsi_tape *STp, long count,
1802 retval = 1; 1805 retval = 1;
1803 DEBC(printk(ST_DEB_MSG "%s: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n", 1806 DEBC(printk(ST_DEB_MSG "%s: Sense: %2x %2x %2x %2x %2x %2x %2x %2x\n",
1804 name, 1807 name,
1805 SRpnt->sr_sense_buffer[0], SRpnt->sr_sense_buffer[1], 1808 SRpnt->sense[0], SRpnt->sense[1],
1806 SRpnt->sr_sense_buffer[2], SRpnt->sr_sense_buffer[3], 1809 SRpnt->sense[2], SRpnt->sense[3],
1807 SRpnt->sr_sense_buffer[4], SRpnt->sr_sense_buffer[5], 1810 SRpnt->sense[4], SRpnt->sense[5],
1808 SRpnt->sr_sense_buffer[6], SRpnt->sr_sense_buffer[7])); 1811 SRpnt->sense[6], SRpnt->sense[7]));
1809 if (cmdstatp->have_sense) { 1812 if (cmdstatp->have_sense) {
1810 1813
1811 if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK) 1814 if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK)
@@ -1835,7 +1838,7 @@ static long read_tape(struct scsi_tape *STp, long count,
1835 } 1838 }
1836 STbp->buffer_bytes = bytes - transfer; 1839 STbp->buffer_bytes = bytes - transfer;
1837 } else { 1840 } else {
1838 scsi_release_request(SRpnt); 1841 st_release_request(SRpnt);
1839 SRpnt = *aSRpnt = NULL; 1842 SRpnt = *aSRpnt = NULL;
1840 if (transfer == blks) { /* We did not get anything, error */ 1843 if (transfer == blks) { /* We did not get anything, error */
1841 printk(KERN_NOTICE "%s: Incorrect block size.\n", name); 1844 printk(KERN_NOTICE "%s: Incorrect block size.\n", name);
@@ -1929,7 +1932,7 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
1929 ssize_t retval = 0; 1932 ssize_t retval = 0;
1930 ssize_t i, transfer; 1933 ssize_t i, transfer;
1931 int special, do_dio = 0; 1934 int special, do_dio = 0;
1932 struct scsi_request *SRpnt = NULL; 1935 struct st_request *SRpnt = NULL;
1933 struct scsi_tape *STp = filp->private_data; 1936 struct scsi_tape *STp = filp->private_data;
1934 struct st_modedef *STm; 1937 struct st_modedef *STm;
1935 struct st_partstat *STps; 1938 struct st_partstat *STps;
@@ -2054,11 +2057,11 @@ st_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
2054 2057
2055 out: 2058 out:
2056 if (SRpnt != NULL) { 2059 if (SRpnt != NULL) {
2057 scsi_release_request(SRpnt); 2060 st_release_request(SRpnt);
2058 SRpnt = NULL; 2061 SRpnt = NULL;
2059 } 2062 }
2060 if (do_dio) { 2063 if (do_dio) {
2061 release_buffering(STp); 2064 release_buffering(STp, 1);
2062 STbp->buffer_bytes = 0; 2065 STbp->buffer_bytes = 0;
2063 } 2066 }
2064 up(&STp->lock); 2067 up(&STp->lock);
@@ -2284,7 +2287,7 @@ static int st_set_options(struct scsi_tape *STp, long options)
2284static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs) 2287static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
2285{ 2288{
2286 unsigned char cmd[MAX_COMMAND_SIZE]; 2289 unsigned char cmd[MAX_COMMAND_SIZE];
2287 struct scsi_request *SRpnt = NULL; 2290 struct st_request *SRpnt = NULL;
2288 2291
2289 memset(cmd, 0, MAX_COMMAND_SIZE); 2292 memset(cmd, 0, MAX_COMMAND_SIZE);
2290 cmd[0] = MODE_SENSE; 2293 cmd[0] = MODE_SENSE;
@@ -2298,7 +2301,7 @@ static int read_mode_page(struct scsi_tape *STp, int page, int omit_block_descs)
2298 if (SRpnt == NULL) 2301 if (SRpnt == NULL)
2299 return (STp->buffer)->syscall_result; 2302 return (STp->buffer)->syscall_result;
2300 2303
2301 scsi_release_request(SRpnt); 2304 st_release_request(SRpnt);
2302 2305
2303 return (STp->buffer)->syscall_result; 2306 return (STp->buffer)->syscall_result;
2304} 2307}
@@ -2310,7 +2313,7 @@ static int write_mode_page(struct scsi_tape *STp, int page, int slow)
2310{ 2313{
2311 int pgo; 2314 int pgo;
2312 unsigned char cmd[MAX_COMMAND_SIZE]; 2315 unsigned char cmd[MAX_COMMAND_SIZE];
2313 struct scsi_request *SRpnt = NULL; 2316 struct st_request *SRpnt = NULL;
2314 2317
2315 memset(cmd, 0, MAX_COMMAND_SIZE); 2318 memset(cmd, 0, MAX_COMMAND_SIZE);
2316 cmd[0] = MODE_SELECT; 2319 cmd[0] = MODE_SELECT;
@@ -2329,7 +2332,7 @@ static int write_mode_page(struct scsi_tape *STp, int page, int slow)
2329 if (SRpnt == NULL) 2332 if (SRpnt == NULL)
2330 return (STp->buffer)->syscall_result; 2333 return (STp->buffer)->syscall_result;
2331 2334
2332 scsi_release_request(SRpnt); 2335 st_release_request(SRpnt);
2333 2336
2334 return (STp->buffer)->syscall_result; 2337 return (STp->buffer)->syscall_result;
2335} 2338}
@@ -2412,7 +2415,7 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
2412 DEB( char *name = tape_name(STp); ) 2415 DEB( char *name = tape_name(STp); )
2413 unsigned char cmd[MAX_COMMAND_SIZE]; 2416 unsigned char cmd[MAX_COMMAND_SIZE];
2414 struct st_partstat *STps; 2417 struct st_partstat *STps;
2415 struct scsi_request *SRpnt; 2418 struct st_request *SRpnt;
2416 2419
2417 if (STp->ready != ST_READY && !load_code) { 2420 if (STp->ready != ST_READY && !load_code) {
2418 if (STp->ready == ST_NO_TAPE) 2421 if (STp->ready == ST_NO_TAPE)
@@ -2455,7 +2458,7 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_cod
2455 return (STp->buffer)->syscall_result; 2458 return (STp->buffer)->syscall_result;
2456 2459
2457 retval = (STp->buffer)->syscall_result; 2460 retval = (STp->buffer)->syscall_result;
2458 scsi_release_request(SRpnt); 2461 st_release_request(SRpnt);
2459 2462
2460 if (!retval) { /* SCSI command successful */ 2463 if (!retval) { /* SCSI command successful */
2461 2464
@@ -2503,7 +2506,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2503 int ioctl_result; 2506 int ioctl_result;
2504 int chg_eof = 1; 2507 int chg_eof = 1;
2505 unsigned char cmd[MAX_COMMAND_SIZE]; 2508 unsigned char cmd[MAX_COMMAND_SIZE];
2506 struct scsi_request *SRpnt; 2509 struct st_request *SRpnt;
2507 struct st_partstat *STps; 2510 struct st_partstat *STps;
2508 int fileno, blkno, at_sm, undone; 2511 int fileno, blkno, at_sm, undone;
2509 int datalen = 0, direction = DMA_NONE; 2512 int datalen = 0, direction = DMA_NONE;
@@ -2757,7 +2760,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2757 ioctl_result = (STp->buffer)->syscall_result; 2760 ioctl_result = (STp->buffer)->syscall_result;
2758 2761
2759 if (!ioctl_result) { /* SCSI command successful */ 2762 if (!ioctl_result) { /* SCSI command successful */
2760 scsi_release_request(SRpnt); 2763 st_release_request(SRpnt);
2761 SRpnt = NULL; 2764 SRpnt = NULL;
2762 STps->drv_block = blkno; 2765 STps->drv_block = blkno;
2763 STps->drv_file = fileno; 2766 STps->drv_file = fileno;
@@ -2872,7 +2875,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2872 /* Try the other possible state of Page Format if not 2875 /* Try the other possible state of Page Format if not
2873 already tried */ 2876 already tried */
2874 STp->use_pf = !STp->use_pf | PF_TESTED; 2877 STp->use_pf = !STp->use_pf | PF_TESTED;
2875 scsi_release_request(SRpnt); 2878 st_release_request(SRpnt);
2876 SRpnt = NULL; 2879 SRpnt = NULL;
2877 return st_int_ioctl(STp, cmd_in, arg); 2880 return st_int_ioctl(STp, cmd_in, arg);
2878 } 2881 }
@@ -2882,7 +2885,7 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
2882 if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK) 2885 if (cmdstatp->sense_hdr.sense_key == BLANK_CHECK)
2883 STps->eof = ST_EOD; 2886 STps->eof = ST_EOD;
2884 2887
2885 scsi_release_request(SRpnt); 2888 st_release_request(SRpnt);
2886 SRpnt = NULL; 2889 SRpnt = NULL;
2887 } 2890 }
2888 2891
@@ -2898,7 +2901,7 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
2898{ 2901{
2899 int result; 2902 int result;
2900 unsigned char scmd[MAX_COMMAND_SIZE]; 2903 unsigned char scmd[MAX_COMMAND_SIZE];
2901 struct scsi_request *SRpnt; 2904 struct st_request *SRpnt;
2902 DEB( char *name = tape_name(STp); ) 2905 DEB( char *name = tape_name(STp); )
2903 2906
2904 if (STp->ready != ST_READY) 2907 if (STp->ready != ST_READY)
@@ -2944,7 +2947,7 @@ static int get_location(struct scsi_tape *STp, unsigned int *block, int *partiti
2944 DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name, 2947 DEBC(printk(ST_DEB_MSG "%s: Got tape pos. blk %d part %d.\n", name,
2945 *block, *partition)); 2948 *block, *partition));
2946 } 2949 }
2947 scsi_release_request(SRpnt); 2950 st_release_request(SRpnt);
2948 SRpnt = NULL; 2951 SRpnt = NULL;
2949 2952
2950 return result; 2953 return result;
@@ -2961,7 +2964,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
2961 unsigned int blk; 2964 unsigned int blk;
2962 int timeout; 2965 int timeout;
2963 unsigned char scmd[MAX_COMMAND_SIZE]; 2966 unsigned char scmd[MAX_COMMAND_SIZE];
2964 struct scsi_request *SRpnt; 2967 struct st_request *SRpnt;
2965 DEB( char *name = tape_name(STp); ) 2968 DEB( char *name = tape_name(STp); )
2966 2969
2967 if (STp->ready != ST_READY) 2970 if (STp->ready != ST_READY)
@@ -3047,7 +3050,7 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3047 result = 0; 3050 result = 0;
3048 } 3051 }
3049 3052
3050 scsi_release_request(SRpnt); 3053 st_release_request(SRpnt);
3051 SRpnt = NULL; 3054 SRpnt = NULL;
3052 3055
3053 return result; 3056 return result;
@@ -3577,7 +3580,7 @@ static long st_compat_ioctl(struct file *file, unsigned int cmd, unsigned long a
3577static struct st_buffer * 3580static struct st_buffer *
3578 new_tape_buffer(int from_initialization, int need_dma, int max_sg) 3581 new_tape_buffer(int from_initialization, int need_dma, int max_sg)
3579{ 3582{
3580 int i, got = 0, segs = 0; 3583 int i, got = 0;
3581 gfp_t priority; 3584 gfp_t priority;
3582 struct st_buffer *tb; 3585 struct st_buffer *tb;
3583 3586
@@ -3594,10 +3597,8 @@ static struct st_buffer *
3594 return NULL; 3597 return NULL;
3595 } 3598 }
3596 memset(tb, 0, i); 3599 memset(tb, 0, i);
3597 tb->frp_segs = tb->orig_frp_segs = segs; 3600 tb->frp_segs = tb->orig_frp_segs = 0;
3598 tb->use_sg = max_sg; 3601 tb->use_sg = max_sg;
3599 if (segs > 0)
3600 tb->b_data = page_address(tb->sg[0].page);
3601 tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg); 3602 tb->frp = (struct st_buf_fragment *)(&(tb->sg[0]) + max_sg);
3602 3603
3603 tb->in_use = 1; 3604 tb->in_use = 1;
@@ -3628,7 +3629,7 @@ static int enlarge_buffer(struct st_buffer * STbuffer, int new_size, int need_dm
3628 priority = GFP_KERNEL | __GFP_NOWARN; 3629 priority = GFP_KERNEL | __GFP_NOWARN;
3629 if (need_dma) 3630 if (need_dma)
3630 priority |= GFP_DMA; 3631 priority |= GFP_DMA;
3631 for (b_size = PAGE_SIZE, order=0; 3632 for (b_size = PAGE_SIZE, order=0; order <= 6 &&
3632 b_size < new_size - STbuffer->buffer_size; 3633 b_size < new_size - STbuffer->buffer_size;
3633 order++, b_size *= 2) 3634 order++, b_size *= 2)
3634 ; /* empty */ 3635 ; /* empty */
@@ -3670,6 +3671,7 @@ static void normalize_buffer(struct st_buffer * STbuffer)
3670 } 3671 }
3671 STbuffer->frp_segs = STbuffer->orig_frp_segs; 3672 STbuffer->frp_segs = STbuffer->orig_frp_segs;
3672 STbuffer->frp_sg_current = 0; 3673 STbuffer->frp_sg_current = 0;
3674 STbuffer->sg_segs = 0;
3673} 3675}
3674 3676
3675 3677
@@ -3882,7 +3884,6 @@ static int st_probe(struct device *dev)
3882 struct st_buffer *buffer; 3884 struct st_buffer *buffer;
3883 int i, j, mode, dev_num, error; 3885 int i, j, mode, dev_num, error;
3884 char *stp; 3886 char *stp;
3885 u64 bounce_limit;
3886 3887
3887 if (SDp->type != TYPE_TAPE) 3888 if (SDp->type != TYPE_TAPE)
3888 return -ENODEV; 3889 return -ENODEV;
@@ -3892,7 +3893,8 @@ static int st_probe(struct device *dev)
3892 return -ENODEV; 3893 return -ENODEV;
3893 } 3894 }
3894 3895
3895 i = SDp->host->sg_tablesize; 3896 i = min(SDp->request_queue->max_hw_segments,
3897 SDp->request_queue->max_phys_segments);
3896 if (st_max_sg_segs < i) 3898 if (st_max_sg_segs < i)
3897 i = st_max_sg_segs; 3899 i = st_max_sg_segs;
3898 buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i); 3900 buffer = new_tape_buffer(1, (SDp->host)->unchecked_isa_dma, i);
@@ -3994,11 +3996,6 @@ static int st_probe(struct device *dev)
3994 tpnt->long_timeout = ST_LONG_TIMEOUT; 3996 tpnt->long_timeout = ST_LONG_TIMEOUT;
3995 tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma; 3997 tpnt->try_dio = try_direct_io && !SDp->host->unchecked_isa_dma;
3996 3998
3997 bounce_limit = scsi_calculate_bounce_limit(SDp->host) >> PAGE_SHIFT;
3998 if (bounce_limit > ULONG_MAX)
3999 bounce_limit = ULONG_MAX;
4000 tpnt->max_pfn = bounce_limit;
4001
4002 for (i = 0; i < ST_NBR_MODES; i++) { 3999 for (i = 0; i < ST_NBR_MODES; i++) {
4003 STm = &(tpnt->modes[i]); 4000 STm = &(tpnt->modes[i]);
4004 STm->defined = 0; 4001 STm->defined = 0;
@@ -4077,9 +4074,9 @@ static int st_probe(struct device *dev)
4077 4074
4078 sdev_printk(KERN_WARNING, SDp, 4075 sdev_printk(KERN_WARNING, SDp,
4079 "Attached scsi tape %s", tape_name(tpnt)); 4076 "Attached scsi tape %s", tape_name(tpnt));
4080 printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B), max page reachable by HBA %lu\n", 4077 printk(KERN_WARNING "%s: try direct i/o: %s (alignment %d B)\n",
4081 tape_name(tpnt), tpnt->try_dio ? "yes" : "no", 4078 tape_name(tpnt), tpnt->try_dio ? "yes" : "no",
4082 queue_dma_alignment(SDp->request_queue) + 1, tpnt->max_pfn); 4079 queue_dma_alignment(SDp->request_queue) + 1);
4083 4080
4084 return 0; 4081 return 0;
4085 4082
@@ -4185,7 +4182,11 @@ static void scsi_tape_release(struct kref *kref)
4185 4182
4186static void st_intr(struct scsi_cmnd *SCpnt) 4183static void st_intr(struct scsi_cmnd *SCpnt)
4187{ 4184{
4188 scsi_io_completion(SCpnt, (SCpnt->result ? 0: SCpnt->bufflen), 1); 4185 /*
4186 * The caller should be checking the request's errors
4187 * value.
4188 */
4189 scsi_io_completion(SCpnt, SCpnt->bufflen, 0);
4189} 4190}
4190 4191
4191/* 4192/*
@@ -4194,27 +4195,10 @@ static void st_intr(struct scsi_cmnd *SCpnt)
4194 */ 4195 */
4195static int st_init_command(struct scsi_cmnd *SCpnt) 4196static int st_init_command(struct scsi_cmnd *SCpnt)
4196{ 4197{
4197 struct request *rq;
4198
4199 if (!(SCpnt->request->flags & REQ_BLOCK_PC)) 4198 if (!(SCpnt->request->flags & REQ_BLOCK_PC))
4200 return 0; 4199 return 0;
4201 4200
4202 rq = SCpnt->request; 4201 scsi_setup_blk_pc_cmnd(SCpnt);
4203 if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
4204 return 0;
4205
4206 memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
4207 SCpnt->cmd_len = rq->cmd_len;
4208
4209 if (rq_data_dir(rq) == WRITE)
4210 SCpnt->sc_data_direction = DMA_TO_DEVICE;
4211 else if (rq->data_len)
4212 SCpnt->sc_data_direction = DMA_FROM_DEVICE;
4213 else
4214 SCpnt->sc_data_direction = DMA_NONE;
4215
4216 SCpnt->timeout_per_command = rq->timeout;
4217 SCpnt->transfersize = rq->data_len;
4218 SCpnt->done = st_intr; 4202 SCpnt->done = st_intr;
4219 return 1; 4203 return 1;
4220} 4204}
@@ -4407,34 +4391,6 @@ static void do_create_class_files(struct scsi_tape *STp, int dev_num, int mode)
4407 return; 4391 return;
4408} 4392}
4409 4393
4410
4411/* Pin down user pages and put them into a scatter gather list. Returns <= 0 if
4412 - mapping of all pages not successful
4413 - any page is above max_pfn
4414 (i.e., either completely successful or fails)
4415*/
4416static int st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
4417 unsigned long uaddr, size_t count, int rw,
4418 unsigned long max_pfn)
4419{
4420 int i, nr_pages;
4421
4422 nr_pages = sgl_map_user_pages(sgl, max_pages, uaddr, count, rw);
4423 if (nr_pages <= 0)
4424 return nr_pages;
4425
4426 for (i=0; i < nr_pages; i++) {
4427 if (page_to_pfn(sgl[i].page) > max_pfn)
4428 goto out_unmap;
4429 }
4430 return nr_pages;
4431
4432 out_unmap:
4433 sgl_unmap_user_pages(sgl, nr_pages, 0);
4434 return 0;
4435}
4436
4437
4438/* The following functions may be useful for a larger audience. */ 4394/* The following functions may be useful for a larger audience. */
4439static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, 4395static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
4440 unsigned long uaddr, size_t count, int rw) 4396 unsigned long uaddr, size_t count, int rw)
diff --git a/drivers/scsi/st.h b/drivers/scsi/st.h
index 790acac160bc..411209048d74 100644
--- a/drivers/scsi/st.h
+++ b/drivers/scsi/st.h
@@ -4,6 +4,7 @@
4 4
5#include <linux/completion.h> 5#include <linux/completion.h>
6#include <linux/kref.h> 6#include <linux/kref.h>
7#include <scsi/scsi_cmnd.h>
7 8
8/* Descriptor for analyzed sense data */ 9/* Descriptor for analyzed sense data */
9struct st_cmdstatus { 10struct st_cmdstatus {
@@ -17,6 +18,17 @@ struct st_cmdstatus {
17 u8 deferred; 18 u8 deferred;
18}; 19};
19 20
21struct scsi_tape;
22
23/* scsi tape command */
24struct st_request {
25 unsigned char cmd[MAX_COMMAND_SIZE];
26 unsigned char sense[SCSI_SENSE_BUFFERSIZE];
27 int result;
28 struct scsi_tape *stp;
29 struct completion *waiting;
30};
31
20/* The tape buffer descriptor. */ 32/* The tape buffer descriptor. */
21struct st_buffer { 33struct st_buffer {
22 unsigned char in_use; 34 unsigned char in_use;
@@ -28,7 +40,7 @@ struct st_buffer {
28 int read_pointer; 40 int read_pointer;
29 int writing; 41 int writing;
30 int syscall_result; 42 int syscall_result;
31 struct scsi_request *last_SRpnt; 43 struct st_request *last_SRpnt;
32 struct st_cmdstatus cmdstat; 44 struct st_cmdstatus cmdstat;
33 unsigned char *b_data; 45 unsigned char *b_data;
34 unsigned short use_sg; /* zero or max number of s/g segments for this adapter */ 46 unsigned short use_sg; /* zero or max number of s/g segments for this adapter */
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index c041bfd56e12..25cced91c8a6 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -70,6 +70,7 @@
70 * 70 *
71 */ 71 */
72#include <scsi/scsi_dbg.h> 72#include <scsi/scsi_dbg.h>
73#include <scsi/scsi_transport_spi.h>
73 74
74/* 75/*
75 * Further development / testing that should be done : 76 * Further development / testing that should be done :
@@ -2378,7 +2379,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2378 * 3..length+1 arguments 2379 * 3..length+1 arguments
2379 * 2380 *
2380 * Start the extended message buffer with the EXTENDED_MESSAGE 2381 * Start the extended message buffer with the EXTENDED_MESSAGE
2381 * byte, since scsi_print_msg() wants the whole thing. 2382 * byte, since spi_print_msg() wants the whole thing.
2382 */ 2383 */
2383 extended_msg[0] = EXTENDED_MESSAGE; 2384 extended_msg[0] = EXTENDED_MESSAGE;
2384 /* Accept first byte by clearing ACK */ 2385 /* Accept first byte by clearing ACK */
@@ -2431,7 +2432,7 @@ static void NCR5380_information_transfer (struct Scsi_Host *instance)
2431 default: 2432 default:
2432 if (!tmp) { 2433 if (!tmp) {
2433 printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO); 2434 printk(KERN_DEBUG "scsi%d: rejecting message ", HOSTNO);
2434 scsi_print_msg (extended_msg); 2435 spi_print_msg(extended_msg);
2435 printk("\n"); 2436 printk("\n");
2436 } else if (tmp != EXTENDED_MESSAGE) 2437 } else if (tmp != EXTENDED_MESSAGE)
2437 printk(KERN_DEBUG "scsi%d: rejecting unknown " 2438 printk(KERN_DEBUG "scsi%d: rejecting unknown "
@@ -2566,7 +2567,7 @@ static void NCR5380_reselect (struct Scsi_Host *instance)
2566 2567
2567 if (!(msg[0] & 0x80)) { 2568 if (!(msg[0] & 0x80)) {
2568 printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO); 2569 printk(KERN_DEBUG "scsi%d: expecting IDENTIFY message, got ", HOSTNO);
2569 scsi_print_msg(msg); 2570 spi_print_msg(msg);
2570 do_abort(instance); 2571 do_abort(instance);
2571 return; 2572 return;
2572 } 2573 }
diff --git a/drivers/scsi/sym53c8xx_2/sym_defs.h b/drivers/scsi/sym53c8xx_2/sym_defs.h
index 2d9437d7242b..3659dd7b9d76 100644
--- a/drivers/scsi/sym53c8xx_2/sym_defs.h
+++ b/drivers/scsi/sym53c8xx_2/sym_defs.h
@@ -40,7 +40,7 @@
40#ifndef SYM_DEFS_H 40#ifndef SYM_DEFS_H
41#define SYM_DEFS_H 41#define SYM_DEFS_H
42 42
43#define SYM_VERSION "2.2.1" 43#define SYM_VERSION "2.2.2"
44#define SYM_DRIVER_NAME "sym-" SYM_VERSION 44#define SYM_DRIVER_NAME "sym-" SYM_VERSION
45 45
46/* 46/*
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.c b/drivers/scsi/sym53c8xx_2/sym_fw.c
index fd36cf9858cb..9916a2a22558 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw.c
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.c
@@ -37,11 +37,7 @@
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 */ 38 */
39 39
40#ifdef __FreeBSD__
41#include <dev/sym/sym_glue.h>
42#else
43#include "sym_glue.h" 40#include "sym_glue.h"
44#endif
45 41
46/* 42/*
47 * Macros used for all firmwares. 43 * Macros used for all firmwares.
@@ -60,19 +56,12 @@
60#define SYM_FWA_SCR sym_fw1a_scr 56#define SYM_FWA_SCR sym_fw1a_scr
61#define SYM_FWB_SCR sym_fw1b_scr 57#define SYM_FWB_SCR sym_fw1b_scr
62#define SYM_FWZ_SCR sym_fw1z_scr 58#define SYM_FWZ_SCR sym_fw1z_scr
63#ifdef __FreeBSD__
64#include <dev/sym/sym_fw1.h>
65#else
66#include "sym_fw1.h" 59#include "sym_fw1.h"
67#endif
68static struct sym_fwa_ofs sym_fw1a_ofs = { 60static struct sym_fwa_ofs sym_fw1a_ofs = {
69 SYM_GEN_FW_A(struct SYM_FWA_SCR) 61 SYM_GEN_FW_A(struct SYM_FWA_SCR)
70}; 62};
71static struct sym_fwb_ofs sym_fw1b_ofs = { 63static struct sym_fwb_ofs sym_fw1b_ofs = {
72 SYM_GEN_FW_B(struct SYM_FWB_SCR) 64 SYM_GEN_FW_B(struct SYM_FWB_SCR)
73#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
74 SYM_GEN_B(struct SYM_FWB_SCR, data_io)
75#endif
76}; 65};
77static struct sym_fwz_ofs sym_fw1z_ofs = { 66static struct sym_fwz_ofs sym_fw1z_ofs = {
78 SYM_GEN_FW_Z(struct SYM_FWZ_SCR) 67 SYM_GEN_FW_Z(struct SYM_FWZ_SCR)
@@ -88,19 +77,12 @@ static struct sym_fwz_ofs sym_fw1z_ofs = {
88#define SYM_FWA_SCR sym_fw2a_scr 77#define SYM_FWA_SCR sym_fw2a_scr
89#define SYM_FWB_SCR sym_fw2b_scr 78#define SYM_FWB_SCR sym_fw2b_scr
90#define SYM_FWZ_SCR sym_fw2z_scr 79#define SYM_FWZ_SCR sym_fw2z_scr
91#ifdef __FreeBSD__
92#include <dev/sym/sym_fw2.h>
93#else
94#include "sym_fw2.h" 80#include "sym_fw2.h"
95#endif
96static struct sym_fwa_ofs sym_fw2a_ofs = { 81static struct sym_fwa_ofs sym_fw2a_ofs = {
97 SYM_GEN_FW_A(struct SYM_FWA_SCR) 82 SYM_GEN_FW_A(struct SYM_FWA_SCR)
98}; 83};
99static struct sym_fwb_ofs sym_fw2b_ofs = { 84static struct sym_fwb_ofs sym_fw2b_ofs = {
100 SYM_GEN_FW_B(struct SYM_FWB_SCR) 85 SYM_GEN_FW_B(struct SYM_FWB_SCR)
101#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
102 SYM_GEN_B(struct SYM_FWB_SCR, data_io)
103#endif
104 SYM_GEN_B(struct SYM_FWB_SCR, start64) 86 SYM_GEN_B(struct SYM_FWB_SCR, start64)
105 SYM_GEN_B(struct SYM_FWB_SCR, pm_handle) 87 SYM_GEN_B(struct SYM_FWB_SCR, pm_handle)
106}; 88};
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw.h b/drivers/scsi/sym53c8xx_2/sym_fw.h
index 43f6810a4045..66ec35beab5b 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw.h
+++ b/drivers/scsi/sym53c8xx_2/sym_fw.h
@@ -92,9 +92,6 @@ struct sym_fwa_ofs {
92}; 92};
93struct sym_fwb_ofs { 93struct sym_fwb_ofs {
94 SYM_GEN_FW_B(u_short) 94 SYM_GEN_FW_B(u_short)
95#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
96 SYM_GEN_B(u_short, data_io)
97#endif
98 SYM_GEN_B(u_short, start64) 95 SYM_GEN_B(u_short, start64)
99 SYM_GEN_B(u_short, pm_handle) 96 SYM_GEN_B(u_short, pm_handle)
100}; 97};
@@ -111,9 +108,6 @@ struct sym_fwa_ba {
111}; 108};
112struct sym_fwb_ba { 109struct sym_fwb_ba {
113 SYM_GEN_FW_B(u32) 110 SYM_GEN_FW_B(u32)
114#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
115 SYM_GEN_B(u32, data_io)
116#endif
117 SYM_GEN_B(u32, start64); 111 SYM_GEN_B(u32, start64);
118 SYM_GEN_B(u32, pm_handle); 112 SYM_GEN_B(u32, pm_handle);
119}; 113};
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw1.h b/drivers/scsi/sym53c8xx_2/sym_fw1.h
index cdd92d82f4b2..7b39f4a35e98 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw1.h
+++ b/drivers/scsi/sym53c8xx_2/sym_fw1.h
@@ -197,12 +197,6 @@ struct SYM_FWB_SCR {
197 u32 bad_status [ 7]; 197 u32 bad_status [ 7];
198 u32 wsr_ma_helper [ 4]; 198 u32 wsr_ma_helper [ 4];
199 199
200#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
201 /* Unknown direction handling */
202 u32 data_io [ 2];
203 u32 data_io_com [ 8];
204 u32 data_io_out [ 7];
205#endif
206 /* Data area */ 200 /* Data area */
207 u32 zero [ 1]; 201 u32 zero [ 1];
208 u32 scratch [ 1]; 202 u32 scratch [ 1];
@@ -1747,48 +1741,6 @@ static struct SYM_FWB_SCR SYM_FWB_SCR = {
1747 SCR_JUMP, 1741 SCR_JUMP,
1748 PADDR_A (dispatch), 1742 PADDR_A (dispatch),
1749 1743
1750#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1751}/*-------------------------< DATA_IO >--------------------------*/,{
1752 /*
1753 * We jump here if the data direction was unknown at the
1754 * time we had to queue the command to the scripts processor.
1755 * Pointers had been set as follow in this situation:
1756 * savep --> DATA_IO
1757 * lastp --> start pointer when DATA_IN
1758 * wlastp --> start pointer when DATA_OUT
1759 * This script sets savep and lastp according to the
1760 * direction chosen by the target.
1761 */
1762 SCR_JUMP ^ IFTRUE (WHEN (SCR_DATA_OUT)),
1763 PADDR_B (data_io_out),
1764}/*-------------------------< DATA_IO_COM >----------------------*/,{
1765 /*
1766 * Direction is DATA IN.
1767 */
1768 SCR_COPY (4),
1769 HADDR_1 (ccb_head.lastp),
1770 HADDR_1 (ccb_head.savep),
1771 /*
1772 * Jump to the SCRIPTS according to actual direction.
1773 */
1774 SCR_COPY (4),
1775 HADDR_1 (ccb_head.savep),
1776 RADDR_1 (temp),
1777 SCR_RETURN,
1778 0,
1779}/*-------------------------< DATA_IO_OUT >----------------------*/,{
1780 /*
1781 * Direction is DATA OUT.
1782 */
1783 SCR_REG_REG (HF_REG, SCR_AND, (~HF_DATA_IN)),
1784 0,
1785 SCR_COPY (4),
1786 HADDR_1 (ccb_head.wlastp),
1787 HADDR_1 (ccb_head.lastp),
1788 SCR_JUMP,
1789 PADDR_B(data_io_com),
1790#endif /* SYM_OPT_HANDLE_DIR_UNKNOWN */
1791
1792}/*-------------------------< ZERO >-----------------------------*/,{ 1744}/*-------------------------< ZERO >-----------------------------*/,{
1793 SCR_DATA_ZERO, 1745 SCR_DATA_ZERO,
1794}/*-------------------------< SCRATCH >--------------------------*/,{ 1746}/*-------------------------< SCRATCH >--------------------------*/,{
diff --git a/drivers/scsi/sym53c8xx_2/sym_fw2.h b/drivers/scsi/sym53c8xx_2/sym_fw2.h
index 7ea7151f5d1d..851f2706f220 100644
--- a/drivers/scsi/sym53c8xx_2/sym_fw2.h
+++ b/drivers/scsi/sym53c8xx_2/sym_fw2.h
@@ -191,13 +191,6 @@ struct SYM_FWB_SCR {
191 u32 pm_wsr_handle [ 38]; 191 u32 pm_wsr_handle [ 38];
192 u32 wsr_ma_helper [ 4]; 192 u32 wsr_ma_helper [ 4];
193 193
194#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
195 /* Unknown direction handling */
196 u32 data_io [ 2];
197 u32 data_io_in [ 2];
198 u32 data_io_com [ 6];
199 u32 data_io_out [ 8];
200#endif
201 /* Data area */ 194 /* Data area */
202 u32 zero [ 1]; 195 u32 zero [ 1];
203 u32 scratch [ 1]; 196 u32 scratch [ 1];
@@ -1838,51 +1831,6 @@ static struct SYM_FWB_SCR SYM_FWB_SCR = {
1838 SCR_JUMP, 1831 SCR_JUMP,
1839 PADDR_A (dispatch), 1832 PADDR_A (dispatch),
1840 1833
1841#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1842}/*-------------------------< DATA_IO >--------------------------*/,{
1843 /*
1844 * We jump here if the data direction was unknown at the
1845 * time we had to queue the command to the scripts processor.
1846 * Pointers had been set as follow in this situation:
1847 * savep --> DATA_IO
1848 * lastp --> start pointer when DATA_IN
1849 * wlastp --> start pointer when DATA_OUT
1850 * This script sets savep and lastp according to the
1851 * direction chosen by the target.
1852 */
1853 SCR_JUMP ^ IFTRUE (WHEN (SCR_DATA_OUT)),
1854 PADDR_B (data_io_out),
1855}/*-------------------------< DATA_IO_IN >-----------------------*/,{
1856 /*
1857 * Direction is DATA IN.
1858 */
1859 SCR_LOAD_REL (scratcha, 4),
1860 offsetof (struct sym_ccb, phys.head.lastp),
1861}/*-------------------------< DATA_IO_COM >----------------------*/,{
1862 SCR_STORE_REL (scratcha, 4),
1863 offsetof (struct sym_ccb, phys.head.savep),
1864
1865 /*
1866 * Jump to the SCRIPTS according to actual direction.
1867 */
1868 SCR_LOAD_REL (temp, 4),
1869 offsetof (struct sym_ccb, phys.head.savep),
1870 SCR_RETURN,
1871 0,
1872}/*-------------------------< DATA_IO_OUT >----------------------*/,{
1873 /*
1874 * Direction is DATA OUT.
1875 */
1876 SCR_REG_REG (HF_REG, SCR_AND, (~HF_DATA_IN)),
1877 0,
1878 SCR_LOAD_REL (scratcha, 4),
1879 offsetof (struct sym_ccb, phys.head.wlastp),
1880 SCR_STORE_REL (scratcha, 4),
1881 offsetof (struct sym_ccb, phys.head.lastp),
1882 SCR_JUMP,
1883 PADDR_B(data_io_com),
1884#endif /* SYM_OPT_HANDLE_DIR_UNKNOWN */
1885
1886}/*-------------------------< ZERO >-----------------------------*/,{ 1834}/*-------------------------< ZERO >-----------------------------*/,{
1887 SCR_DATA_ZERO, 1835 SCR_DATA_ZERO,
1888}/*-------------------------< SCRATCH >--------------------------*/,{ 1836}/*-------------------------< SCRATCH >--------------------------*/,{
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 7fc0b97173e1..1fffd2b3c654 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -514,9 +514,10 @@ static inline int sym_setup_cdb(struct sym_hcb *np, struct scsi_cmnd *cmd, struc
514 */ 514 */
515int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp) 515int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct sym_ccb *cp)
516{ 516{
517 int dir;
518 struct sym_tcb *tp = &np->target[cp->target]; 517 struct sym_tcb *tp = &np->target[cp->target];
519 struct sym_lcb *lp = sym_lp(tp, cp->lun); 518 struct sym_lcb *lp = sym_lp(tp, cp->lun);
519 u32 lastp, goalp;
520 int dir;
520 521
521 /* 522 /*
522 * Build the CDB. 523 * Build the CDB.
@@ -534,15 +535,47 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s
534 sym_set_cam_status(cmd, DID_ERROR); 535 sym_set_cam_status(cmd, DID_ERROR);
535 goto out_abort; 536 goto out_abort;
536 } 537 }
538
539 /*
540 * No segments means no data.
541 */
542 if (!cp->segments)
543 dir = DMA_NONE;
537 } else { 544 } else {
538 cp->data_len = 0; 545 cp->data_len = 0;
539 cp->segments = 0; 546 cp->segments = 0;
540 } 547 }
541 548
542 /* 549 /*
543 * Set data pointers. 550 * Set the data pointer.
544 */ 551 */
545 sym_setup_data_pointers(np, cp, dir); 552 switch (dir) {
553 case DMA_BIDIRECTIONAL:
554 printk("%s: got DMA_BIDIRECTIONAL command", sym_name(np));
555 sym_set_cam_status(cmd, DID_ERROR);
556 goto out_abort;
557 case DMA_TO_DEVICE:
558 goalp = SCRIPTA_BA(np, data_out2) + 8;
559 lastp = goalp - 8 - (cp->segments * (2*4));
560 break;
561 case DMA_FROM_DEVICE:
562 cp->host_flags |= HF_DATA_IN;
563 goalp = SCRIPTA_BA(np, data_in2) + 8;
564 lastp = goalp - 8 - (cp->segments * (2*4));
565 break;
566 case DMA_NONE:
567 default:
568 lastp = goalp = SCRIPTB_BA(np, no_data);
569 break;
570 }
571
572 /*
573 * Set all pointers values needed by SCRIPTS.
574 */
575 cp->phys.head.lastp = cpu_to_scr(lastp);
576 cp->phys.head.savep = cpu_to_scr(lastp);
577 cp->startp = cp->phys.head.savep;
578 cp->goalp = cpu_to_scr(goalp);
546 579
547 /* 580 /*
548 * When `#ifed 1', the code below makes the driver 581 * When `#ifed 1', the code below makes the driver
@@ -563,10 +596,7 @@ int sym_setup_data_and_start(struct sym_hcb *np, struct scsi_cmnd *cmd, struct s
563 /* 596 /*
564 * activate this job. 597 * activate this job.
565 */ 598 */
566 if (lp) 599 sym_start_next_ccbs(np, lp, 2);
567 sym_start_next_ccbs(np, lp, 2);
568 else
569 sym_put_start_queue(np, cp);
570 return 0; 600 return 0;
571 601
572out_abort: 602out_abort:
@@ -981,15 +1011,14 @@ static int device_queue_depth(struct sym_hcb *np, int target, int lun)
981 1011
982static int sym53c8xx_slave_alloc(struct scsi_device *sdev) 1012static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
983{ 1013{
984 struct sym_hcb *np; 1014 struct sym_hcb *np = sym_get_hcb(sdev->host);
985 struct sym_tcb *tp; 1015 struct sym_tcb *tp = &np->target[sdev->id];
1016 struct sym_lcb *lp;
986 1017
987 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN) 1018 if (sdev->id >= SYM_CONF_MAX_TARGET || sdev->lun >= SYM_CONF_MAX_LUN)
988 return -ENXIO; 1019 return -ENXIO;
989 1020
990 np = sym_get_hcb(sdev->host); 1021 tp->starget = sdev->sdev_target;
991 tp = &np->target[sdev->id];
992
993 /* 1022 /*
994 * Fail the device init if the device is flagged NOSCAN at BOOT in 1023 * Fail the device init if the device is flagged NOSCAN at BOOT in
995 * the NVRAM. This may speed up boot and maintain coherency with 1024 * the NVRAM. This may speed up boot and maintain coherency with
@@ -999,35 +1028,41 @@ static int sym53c8xx_slave_alloc(struct scsi_device *sdev)
999 * lun devices behave badly when asked for a non zero LUN. 1028 * lun devices behave badly when asked for a non zero LUN.
1000 */ 1029 */
1001 1030
1002 if ((tp->usrflags & SYM_SCAN_BOOT_DISABLED) || 1031 if (tp->usrflags & SYM_SCAN_BOOT_DISABLED) {
1003 ((tp->usrflags & SYM_SCAN_LUNS_DISABLED) && sdev->lun != 0)) {
1004 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED; 1032 tp->usrflags &= ~SYM_SCAN_BOOT_DISABLED;
1033 starget_printk(KERN_INFO, tp->starget,
1034 "Scan at boot disabled in NVRAM\n");
1005 return -ENXIO; 1035 return -ENXIO;
1006 } 1036 }
1007 1037
1008 tp->starget = sdev->sdev_target; 1038 if (tp->usrflags & SYM_SCAN_LUNS_DISABLED) {
1039 if (sdev->lun != 0)
1040 return -ENXIO;
1041 starget_printk(KERN_INFO, tp->starget,
1042 "Multiple LUNs disabled in NVRAM\n");
1043 }
1044
1045 lp = sym_alloc_lcb(np, sdev->id, sdev->lun);
1046 if (!lp)
1047 return -ENOMEM;
1048
1049 spi_min_period(tp->starget) = tp->usr_period;
1050 spi_max_width(tp->starget) = tp->usr_width;
1051
1009 return 0; 1052 return 0;
1010} 1053}
1011 1054
1012/* 1055/*
1013 * Linux entry point for device queue sizing. 1056 * Linux entry point for device queue sizing.
1014 */ 1057 */
1015static int sym53c8xx_slave_configure(struct scsi_device *device) 1058static int sym53c8xx_slave_configure(struct scsi_device *sdev)
1016{ 1059{
1017 struct sym_hcb *np = sym_get_hcb(device->host); 1060 struct sym_hcb *np = sym_get_hcb(sdev->host);
1018 struct sym_tcb *tp = &np->target[device->id]; 1061 struct sym_tcb *tp = &np->target[sdev->id];
1019 struct sym_lcb *lp; 1062 struct sym_lcb *lp = sym_lp(tp, sdev->lun);
1020 int reqtags, depth_to_use; 1063 int reqtags, depth_to_use;
1021 1064
1022 /* 1065 /*
1023 * Allocate the LCB if not yet.
1024 * If it fail, we may well be in the sh*t. :)
1025 */
1026 lp = sym_alloc_lcb(np, device->id, device->lun);
1027 if (!lp)
1028 return -ENOMEM;
1029
1030 /*
1031 * Get user flags. 1066 * Get user flags.
1032 */ 1067 */
1033 lp->curr_flags = lp->user_flags; 1068 lp->curr_flags = lp->user_flags;
@@ -1038,10 +1073,10 @@ static int sym53c8xx_slave_configure(struct scsi_device *device)
1038 * Use at least 2. 1073 * Use at least 2.
1039 * Donnot use more than our maximum. 1074 * Donnot use more than our maximum.
1040 */ 1075 */
1041 reqtags = device_queue_depth(np, device->id, device->lun); 1076 reqtags = device_queue_depth(np, sdev->id, sdev->lun);
1042 if (reqtags > tp->usrtags) 1077 if (reqtags > tp->usrtags)
1043 reqtags = tp->usrtags; 1078 reqtags = tp->usrtags;
1044 if (!device->tagged_supported) 1079 if (!sdev->tagged_supported)
1045 reqtags = 0; 1080 reqtags = 0;
1046#if 1 /* Avoid to locally queue commands for no good reasons */ 1081#if 1 /* Avoid to locally queue commands for no good reasons */
1047 if (reqtags > SYM_CONF_MAX_TAG) 1082 if (reqtags > SYM_CONF_MAX_TAG)
@@ -1050,19 +1085,30 @@ static int sym53c8xx_slave_configure(struct scsi_device *device)
1050#else 1085#else
1051 depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2); 1086 depth_to_use = (reqtags ? SYM_CONF_MAX_TAG : 2);
1052#endif 1087#endif
1053 scsi_adjust_queue_depth(device, 1088 scsi_adjust_queue_depth(sdev,
1054 (device->tagged_supported ? 1089 (sdev->tagged_supported ?
1055 MSG_SIMPLE_TAG : 0), 1090 MSG_SIMPLE_TAG : 0),
1056 depth_to_use); 1091 depth_to_use);
1057 lp->s.scdev_depth = depth_to_use; 1092 lp->s.scdev_depth = depth_to_use;
1058 sym_tune_dev_queuing(tp, device->lun, reqtags); 1093 sym_tune_dev_queuing(tp, sdev->lun, reqtags);
1059 1094
1060 if (!spi_initial_dv(device->sdev_target)) 1095 if (!spi_initial_dv(sdev->sdev_target))
1061 spi_dv_device(device); 1096 spi_dv_device(sdev);
1062 1097
1063 return 0; 1098 return 0;
1064} 1099}
1065 1100
1101static void sym53c8xx_slave_destroy(struct scsi_device *sdev)
1102{
1103 struct sym_hcb *np = sym_get_hcb(sdev->host);
1104 struct sym_lcb *lp = sym_lp(&np->target[sdev->id], sdev->lun);
1105
1106 if (lp->itlq_tbl)
1107 sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK * 4, "ITLQ_TBL");
1108 kfree(lp->cb_tags);
1109 sym_mfree_dma(lp, sizeof(*lp), "LCB");
1110}
1111
1066/* 1112/*
1067 * Linux entry point for info() function 1113 * Linux entry point for info() function
1068 */ 1114 */
@@ -1497,7 +1543,7 @@ static int sym_setup_bus_dma_mask(struct sym_hcb *np)
1497{ 1543{
1498#if SYM_CONF_DMA_ADDRESSING_MODE > 0 1544#if SYM_CONF_DMA_ADDRESSING_MODE > 0
1499#if SYM_CONF_DMA_ADDRESSING_MODE == 1 1545#if SYM_CONF_DMA_ADDRESSING_MODE == 1
1500#define DMA_DAC_MASK 0x000000ffffffffffULL /* 40-bit */ 1546#define DMA_DAC_MASK DMA_40BIT_MASK
1501#elif SYM_CONF_DMA_ADDRESSING_MODE == 2 1547#elif SYM_CONF_DMA_ADDRESSING_MODE == 2
1502#define DMA_DAC_MASK DMA_64BIT_MASK 1548#define DMA_DAC_MASK DMA_64BIT_MASK
1503#endif 1549#endif
@@ -1926,6 +1972,7 @@ static struct scsi_host_template sym2_template = {
1926 .queuecommand = sym53c8xx_queue_command, 1972 .queuecommand = sym53c8xx_queue_command,
1927 .slave_alloc = sym53c8xx_slave_alloc, 1973 .slave_alloc = sym53c8xx_slave_alloc,
1928 .slave_configure = sym53c8xx_slave_configure, 1974 .slave_configure = sym53c8xx_slave_configure,
1975 .slave_destroy = sym53c8xx_slave_destroy,
1929 .eh_abort_handler = sym53c8xx_eh_abort_handler, 1976 .eh_abort_handler = sym53c8xx_eh_abort_handler,
1930 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler, 1977 .eh_device_reset_handler = sym53c8xx_eh_device_reset_handler,
1931 .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler, 1978 .eh_bus_reset_handler = sym53c8xx_eh_bus_reset_handler,
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.h b/drivers/scsi/sym53c8xx_2/sym_glue.h
index d3d52f14d7c0..cc92d0c70cd7 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.h
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.h
@@ -68,7 +68,6 @@
68 */ 68 */
69#define SYM_CONF_TIMER_INTERVAL ((HZ+1)/2) 69#define SYM_CONF_TIMER_INTERVAL ((HZ+1)/2)
70 70
71#define SYM_OPT_HANDLE_DIR_UNKNOWN
72#define SYM_OPT_HANDLE_DEVICE_QUEUEING 71#define SYM_OPT_HANDLE_DEVICE_QUEUEING
73#define SYM_OPT_LIMIT_COMMAND_REORDERING 72#define SYM_OPT_LIMIT_COMMAND_REORDERING
74 73
@@ -268,6 +267,5 @@ void sym_xpt_async_bus_reset(struct sym_hcb *np);
268void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target); 267void sym_xpt_async_sent_bdr(struct sym_hcb *np, int target);
269int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp); 268int sym_setup_data_and_start (struct sym_hcb *np, struct scsi_cmnd *csio, struct sym_ccb *cp);
270void sym_log_bus_error(struct sym_hcb *np); 269void sym_log_bus_error(struct sym_hcb *np);
271void sym_sniff_inquiry(struct sym_hcb *np, struct scsi_cmnd *cmd, int resid);
272 270
273#endif /* SYM_GLUE_H */ 271#endif /* SYM_GLUE_H */
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index a7420cad4547..8260f040d39c 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -40,6 +40,7 @@
40 40
41#include <linux/slab.h> 41#include <linux/slab.h>
42#include <asm/param.h> /* for timeouts in units of HZ */ 42#include <asm/param.h> /* for timeouts in units of HZ */
43#include <scsi/scsi_dbg.h>
43 44
44#include "sym_glue.h" 45#include "sym_glue.h"
45#include "sym_nvram.h" 46#include "sym_nvram.h"
@@ -70,32 +71,12 @@ static void sym_printl_hex(u_char *p, int n)
70 printf (".\n"); 71 printf (".\n");
71} 72}
72 73
73/*
74 * Print out the content of a SCSI message.
75 */
76static int sym_show_msg (u_char * msg)
77{
78 u_char i;
79 printf ("%x",*msg);
80 if (*msg==M_EXTENDED) {
81 for (i=1;i<8;i++) {
82 if (i-1>msg[1]) break;
83 printf ("-%x",msg[i]);
84 }
85 return (i+1);
86 } else if ((*msg & 0xf0) == 0x20) {
87 printf ("-%x",msg[1]);
88 return (2);
89 }
90 return (1);
91}
92
93static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg) 74static void sym_print_msg(struct sym_ccb *cp, char *label, u_char *msg)
94{ 75{
95 sym_print_addr(cp->cmd, "%s: ", label); 76 sym_print_addr(cp->cmd, "%s: ", label);
96 77
97 sym_show_msg(msg); 78 spi_print_msg(msg);
98 printf(".\n"); 79 printf("\n");
99} 80}
100 81
101static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg) 82static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_char *msg)
@@ -103,8 +84,8 @@ static void sym_print_nego_msg(struct sym_hcb *np, int target, char *label, u_ch
103 struct sym_tcb *tp = &np->target[target]; 84 struct sym_tcb *tp = &np->target[target];
104 dev_info(&tp->starget->dev, "%s: ", label); 85 dev_info(&tp->starget->dev, "%s: ", label);
105 86
106 sym_show_msg(msg); 87 spi_print_msg(msg);
107 printf(".\n"); 88 printf("\n");
108} 89}
109 90
110/* 91/*
@@ -635,29 +616,6 @@ static __inline void sym_init_burst(struct sym_hcb *np, u_char bc)
635 } 616 }
636} 617}
637 618
638
639/*
640 * Print out the list of targets that have some flag disabled by user.
641 */
642static void sym_print_targets_flag(struct sym_hcb *np, int mask, char *msg)
643{
644 int cnt;
645 int i;
646
647 for (cnt = 0, i = 0 ; i < SYM_CONF_MAX_TARGET ; i++) {
648 if (i == np->myaddr)
649 continue;
650 if (np->target[i].usrflags & mask) {
651 if (!cnt++)
652 printf("%s: %s disabled for targets",
653 sym_name(np), msg);
654 printf(" %d", i);
655 }
656 }
657 if (cnt)
658 printf(".\n");
659}
660
661/* 619/*
662 * Save initial settings of some IO registers. 620 * Save initial settings of some IO registers.
663 * Assumed to have been set by BIOS. 621 * Assumed to have been set by BIOS.
@@ -962,7 +920,7 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
962 tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED); 920 tp->usrflags |= (SYM_DISC_ENABLED | SYM_TAGS_ENABLED);
963 tp->usrtags = SYM_SETUP_MAX_TAG; 921 tp->usrtags = SYM_SETUP_MAX_TAG;
964 922
965 sym_nvram_setup_target(np, i, nvram); 923 sym_nvram_setup_target(tp, i, nvram);
966 924
967 if (!tp->usrtags) 925 if (!tp->usrtags)
968 tp->usrflags &= ~SYM_TAGS_ENABLED; 926 tp->usrflags &= ~SYM_TAGS_ENABLED;
@@ -1005,13 +963,6 @@ static int sym_prepare_setting(struct Scsi_Host *shost, struct sym_hcb *np, stru
1005 sym_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl, 963 sym_name(np), np->rv_scntl3, np->rv_dmode, np->rv_dcntl,
1006 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5); 964 np->rv_ctest3, np->rv_ctest4, np->rv_ctest5);
1007 } 965 }
1008 /*
1009 * Let user be aware of targets that have some disable flags set.
1010 */
1011 sym_print_targets_flag(np, SYM_SCAN_BOOT_DISABLED, "SCAN AT BOOT");
1012 if (sym_verbose)
1013 sym_print_targets_flag(np, SYM_SCAN_LUNS_DISABLED,
1014 "SCAN FOR LUNS");
1015 966
1016 return 0; 967 return 0;
1017} 968}
@@ -1405,7 +1356,6 @@ static void sym_check_goals(struct sym_hcb *np, struct scsi_target *starget,
1405 goal->iu = 0; 1356 goal->iu = 0;
1406 goal->dt = 0; 1357 goal->dt = 0;
1407 goal->qas = 0; 1358 goal->qas = 0;
1408 goal->period = 0;
1409 goal->offset = 0; 1359 goal->offset = 0;
1410 return; 1360 return;
1411 } 1361 }
@@ -1465,7 +1415,8 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp
1465 * Many devices implement PPR in a buggy way, so only use it if we 1415 * Many devices implement PPR in a buggy way, so only use it if we
1466 * really want to. 1416 * really want to.
1467 */ 1417 */
1468 if (goal->iu || goal->dt || goal->qas || (goal->period < 0xa)) { 1418 if (goal->offset &&
1419 (goal->iu || goal->dt || goal->qas || (goal->period < 0xa))) {
1469 nego = NS_PPR; 1420 nego = NS_PPR;
1470 } else if (spi_width(starget) != goal->width) { 1421 } else if (spi_width(starget) != goal->width) {
1471 nego = NS_WIDE; 1422 nego = NS_WIDE;
@@ -1523,7 +1474,7 @@ static int sym_prepare_nego(struct sym_hcb *np, struct sym_ccb *cp, u_char *msgp
1523/* 1474/*
1524 * Insert a job into the start queue. 1475 * Insert a job into the start queue.
1525 */ 1476 */
1526void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp) 1477static void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp)
1527{ 1478{
1528 u_short qidx; 1479 u_short qidx;
1529 1480
@@ -3654,7 +3605,7 @@ static int sym_evaluate_dp(struct sym_hcb *np, struct sym_ccb *cp, u32 scr, int
3654 * If result is dp_sg = SYM_CONF_MAX_SG, then we are at the 3605 * If result is dp_sg = SYM_CONF_MAX_SG, then we are at the
3655 * end of the data. 3606 * end of the data.
3656 */ 3607 */
3657 tmp = scr_to_cpu(sym_goalp(cp)); 3608 tmp = scr_to_cpu(cp->goalp);
3658 dp_sg = SYM_CONF_MAX_SG; 3609 dp_sg = SYM_CONF_MAX_SG;
3659 if (dp_scr != tmp) 3610 if (dp_scr != tmp)
3660 dp_sg -= (tmp - 8 - (int)dp_scr) / (2*4); 3611 dp_sg -= (tmp - 8 - (int)dp_scr) / (2*4);
@@ -3761,7 +3712,7 @@ static void sym_modify_dp(struct sym_hcb *np, struct sym_tcb *tp, struct sym_ccb
3761 * And our alchemy:) allows to easily calculate the data 3712 * And our alchemy:) allows to easily calculate the data
3762 * script address we want to return for the next data phase. 3713 * script address we want to return for the next data phase.
3763 */ 3714 */
3764 dp_ret = cpu_to_scr(sym_goalp(cp)); 3715 dp_ret = cpu_to_scr(cp->goalp);
3765 dp_ret = dp_ret - 8 - (SYM_CONF_MAX_SG - dp_sg) * (2*4); 3716 dp_ret = dp_ret - 8 - (SYM_CONF_MAX_SG - dp_sg) * (2*4);
3766 3717
3767 /* 3718 /*
@@ -3857,7 +3808,7 @@ int sym_compute_residual(struct sym_hcb *np, struct sym_ccb *cp)
3857 * If all data has been transferred, 3808 * If all data has been transferred,
3858 * there is no residual. 3809 * there is no residual.
3859 */ 3810 */
3860 if (cp->phys.head.lastp == sym_goalp(cp)) 3811 if (cp->phys.head.lastp == cp->goalp)
3861 return resid; 3812 return resid;
3862 3813
3863 /* 3814 /*
@@ -4664,30 +4615,7 @@ struct sym_ccb *sym_get_ccb (struct sym_hcb *np, struct scsi_cmnd *cmd, u_char t
4664 goto out; 4615 goto out;
4665 cp = sym_que_entry(qp, struct sym_ccb, link_ccbq); 4616 cp = sym_que_entry(qp, struct sym_ccb, link_ccbq);
4666 4617
4667#ifndef SYM_OPT_HANDLE_DEVICE_QUEUEING 4618 {
4668 /*
4669 * If the LCB is not yet available and the LUN
4670 * has been probed ok, try to allocate the LCB.
4671 */
4672 if (!lp && sym_is_bit(tp->lun_map, ln)) {
4673 lp = sym_alloc_lcb(np, tn, ln);
4674 if (!lp)
4675 goto out_free;
4676 }
4677#endif
4678
4679 /*
4680 * If the LCB is not available here, then the
4681 * logical unit is not yet discovered. For those
4682 * ones only accept 1 SCSI IO per logical unit,
4683 * since we cannot allow disconnections.
4684 */
4685 if (!lp) {
4686 if (!sym_is_bit(tp->busy0_map, ln))
4687 sym_set_bit(tp->busy0_map, ln);
4688 else
4689 goto out_free;
4690 } else {
4691 /* 4619 /*
4692 * If we have been asked for a tagged command. 4620 * If we have been asked for a tagged command.
4693 */ 4621 */
@@ -4840,12 +4768,6 @@ void sym_free_ccb (struct sym_hcb *np, struct sym_ccb *cp)
4840 lp->head.resel_sa = 4768 lp->head.resel_sa =
4841 cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun)); 4769 cpu_to_scr(SCRIPTB_BA(np, resel_bad_lun));
4842 } 4770 }
4843 /*
4844 * Otherwise, we only accept 1 IO per LUN.
4845 * Clear the bit that keeps track of this IO.
4846 */
4847 else
4848 sym_clr_bit(tp->busy0_map, cp->lun);
4849 4771
4850 /* 4772 /*
4851 * We donnot queue more than 1 ccb per target 4773 * We donnot queue more than 1 ccb per target
@@ -4997,20 +4919,7 @@ static void sym_init_tcb (struct sym_hcb *np, u_char tn)
4997struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln) 4919struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln)
4998{ 4920{
4999 struct sym_tcb *tp = &np->target[tn]; 4921 struct sym_tcb *tp = &np->target[tn];
5000 struct sym_lcb *lp = sym_lp(tp, ln); 4922 struct sym_lcb *lp = NULL;
5001
5002 /*
5003 * Already done, just return.
5004 */
5005 if (lp)
5006 return lp;
5007
5008 /*
5009 * Donnot allow LUN control block
5010 * allocation for not probed LUNs.
5011 */
5012 if (!sym_is_bit(tp->lun_map, ln))
5013 return NULL;
5014 4923
5015 /* 4924 /*
5016 * Initialize the target control block if not yet. 4925 * Initialize the target control block if not yet.
@@ -5082,13 +4991,7 @@ struct sym_lcb *sym_alloc_lcb (struct sym_hcb *np, u_char tn, u_char ln)
5082 lp->started_max = SYM_CONF_MAX_TASK; 4991 lp->started_max = SYM_CONF_MAX_TASK;
5083 lp->started_limit = SYM_CONF_MAX_TASK; 4992 lp->started_limit = SYM_CONF_MAX_TASK;
5084#endif 4993#endif
5085 /* 4994
5086 * If we are busy, count the IO.
5087 */
5088 if (sym_is_bit(tp->busy0_map, ln)) {
5089 lp->busy_itl = 1;
5090 sym_clr_bit(tp->busy0_map, ln);
5091 }
5092fail: 4995fail:
5093 return lp; 4996 return lp;
5094} 4997}
@@ -5103,12 +5006,6 @@ static void sym_alloc_lcb_tags (struct sym_hcb *np, u_char tn, u_char ln)
5103 int i; 5006 int i;
5104 5007
5105 /* 5008 /*
5106 * If LCB not available, try to allocate it.
5107 */
5108 if (!lp && !(lp = sym_alloc_lcb(np, tn, ln)))
5109 goto fail;
5110
5111 /*
5112 * Allocate the task table and and the tag allocation 5009 * Allocate the task table and and the tag allocation
5113 * circular buffer. We want both or none. 5010 * circular buffer. We want both or none.
5114 */ 5011 */
@@ -5481,8 +5378,7 @@ finish:
5481 /* 5378 /*
5482 * Donnot start more than 1 command after an error. 5379 * Donnot start more than 1 command after an error.
5483 */ 5380 */
5484 if (lp) 5381 sym_start_next_ccbs(np, lp, 1);
5485 sym_start_next_ccbs(np, lp, 1);
5486#endif 5382#endif
5487} 5383}
5488 5384
@@ -5521,17 +5417,11 @@ void sym_complete_ok (struct sym_hcb *np, struct sym_ccb *cp)
5521 lp = sym_lp(tp, cp->lun); 5417 lp = sym_lp(tp, cp->lun);
5522 5418
5523 /* 5419 /*
5524 * Assume device discovered on first success.
5525 */
5526 if (!lp)
5527 sym_set_bit(tp->lun_map, cp->lun);
5528
5529 /*
5530 * If all data have been transferred, given than no 5420 * If all data have been transferred, given than no
5531 * extended error did occur, there is no residual. 5421 * extended error did occur, there is no residual.
5532 */ 5422 */
5533 resid = 0; 5423 resid = 0;
5534 if (cp->phys.head.lastp != sym_goalp(cp)) 5424 if (cp->phys.head.lastp != cp->goalp)
5535 resid = sym_compute_residual(np, cp); 5425 resid = sym_compute_residual(np, cp);
5536 5426
5537 /* 5427 /*
@@ -5551,15 +5441,6 @@ if (resid)
5551 */ 5441 */
5552 sym_set_cam_result_ok(cp, cmd, resid); 5442 sym_set_cam_result_ok(cp, cmd, resid);
5553 5443
5554#ifdef SYM_OPT_SNIFF_INQUIRY
5555 /*
5556 * On standard INQUIRY response (EVPD and CmDt
5557 * not set), sniff out device capabilities.
5558 */
5559 if (cp->cdb_buf[0] == INQUIRY && !(cp->cdb_buf[1] & 0x3))
5560 sym_sniff_inquiry(np, cmd, resid);
5561#endif
5562
5563#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING 5444#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
5564 /* 5445 /*
5565 * If max number of started ccbs had been reduced, 5446 * If max number of started ccbs had been reduced,
@@ -5587,7 +5468,7 @@ if (resid)
5587 /* 5468 /*
5588 * Requeue a couple of awaiting scsi commands. 5469 * Requeue a couple of awaiting scsi commands.
5589 */ 5470 */
5590 if (lp && !sym_que_empty(&lp->waiting_ccbq)) 5471 if (!sym_que_empty(&lp->waiting_ccbq))
5591 sym_start_next_ccbs(np, lp, 2); 5472 sym_start_next_ccbs(np, lp, 2);
5592#endif 5473#endif
5593 /* 5474 /*
@@ -5830,8 +5711,7 @@ void sym_hcb_free(struct sym_hcb *np)
5830 SYM_QUEHEAD *qp; 5711 SYM_QUEHEAD *qp;
5831 struct sym_ccb *cp; 5712 struct sym_ccb *cp;
5832 struct sym_tcb *tp; 5713 struct sym_tcb *tp;
5833 struct sym_lcb *lp; 5714 int target;
5834 int target, lun;
5835 5715
5836 if (np->scriptz0) 5716 if (np->scriptz0)
5837 sym_mfree_dma(np->scriptz0, np->scriptz_sz, "SCRIPTZ0"); 5717 sym_mfree_dma(np->scriptz0, np->scriptz_sz, "SCRIPTZ0");
@@ -5857,16 +5737,6 @@ void sym_hcb_free(struct sym_hcb *np)
5857 5737
5858 for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) { 5738 for (target = 0; target < SYM_CONF_MAX_TARGET ; target++) {
5859 tp = &np->target[target]; 5739 tp = &np->target[target];
5860 for (lun = 0 ; lun < SYM_CONF_MAX_LUN ; lun++) {
5861 lp = sym_lp(tp, lun);
5862 if (!lp)
5863 continue;
5864 if (lp->itlq_tbl)
5865 sym_mfree_dma(lp->itlq_tbl, SYM_CONF_MAX_TASK*4,
5866 "ITLQ_TBL");
5867 kfree(lp->cb_tags);
5868 sym_mfree_dma(lp, sizeof(*lp), "LCB");
5869 }
5870#if SYM_CONF_MAX_LUN > 1 5740#if SYM_CONF_MAX_LUN > 1
5871 kfree(tp->lunmp); 5741 kfree(tp->lunmp);
5872#endif 5742#endif
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.h b/drivers/scsi/sym53c8xx_2/sym_hipd.h
index 3a264a408216..2456090bb241 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.h
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.h
@@ -48,12 +48,6 @@
48 * They may be defined in platform specific headers, if they 48 * They may be defined in platform specific headers, if they
49 * are useful. 49 * are useful.
50 * 50 *
51 * SYM_OPT_HANDLE_DIR_UNKNOWN
52 * When this option is set, the SCRIPTS used by the driver
53 * are able to handle SCSI transfers with direction not
54 * supplied by user.
55 * (set for Linux-2.0.X)
56 *
57 * SYM_OPT_HANDLE_DEVICE_QUEUEING 51 * SYM_OPT_HANDLE_DEVICE_QUEUEING
58 * When this option is set, the driver will use a queue per 52 * When this option is set, the driver will use a queue per
59 * device and handle QUEUE FULL status requeuing internally. 53 * device and handle QUEUE FULL status requeuing internally.
@@ -64,7 +58,6 @@
64 * (set for Linux) 58 * (set for Linux)
65 */ 59 */
66#if 0 60#if 0
67#define SYM_OPT_HANDLE_DIR_UNKNOWN
68#define SYM_OPT_HANDLE_DEVICE_QUEUEING 61#define SYM_OPT_HANDLE_DEVICE_QUEUEING
69#define SYM_OPT_LIMIT_COMMAND_REORDERING 62#define SYM_OPT_LIMIT_COMMAND_REORDERING
70#endif 63#endif
@@ -416,19 +409,6 @@ struct sym_tcb {
416 struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */ 409 struct sym_lcb **lunmp; /* Other LCBs [1..MAX_LUN] */
417#endif 410#endif
418 411
419 /*
420 * Bitmap that tells about LUNs that succeeded at least
421 * 1 IO and therefore assumed to be a real device.
422 * Avoid useless allocation of the LCB structure.
423 */
424 u32 lun_map[(SYM_CONF_MAX_LUN+31)/32];
425
426 /*
427 * Bitmap that tells about LUNs that haven't yet an LCB
428 * allocated (not discovered or LCB allocation failed).
429 */
430 u32 busy0_map[(SYM_CONF_MAX_LUN+31)/32];
431
432#ifdef SYM_HAVE_STCB 412#ifdef SYM_HAVE_STCB
433 /* 413 /*
434 * O/S specific data structure. 414 * O/S specific data structure.
@@ -454,8 +434,10 @@ struct sym_tcb {
454 * Other user settable limits and options. 434 * Other user settable limits and options.
455 * These limits are read from the NVRAM if present. 435 * These limits are read from the NVRAM if present.
456 */ 436 */
457 u_char usrflags; 437 unsigned char usrflags;
458 u_short usrtags; 438 unsigned char usr_period;
439 unsigned char usr_width;
440 unsigned short usrtags;
459 struct scsi_target *starget; 441 struct scsi_target *starget;
460}; 442};
461 443
@@ -672,9 +654,6 @@ struct sym_ccbh {
672 */ 654 */
673 u32 savep; /* Jump address to saved data pointer */ 655 u32 savep; /* Jump address to saved data pointer */
674 u32 lastp; /* SCRIPTS address at end of data */ 656 u32 lastp; /* SCRIPTS address at end of data */
675#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
676 u32 wlastp;
677#endif
678 657
679 /* 658 /*
680 * Status fields. 659 * Status fields.
@@ -804,9 +783,6 @@ struct sym_ccb {
804 SYM_QUEHEAD link_ccbq; /* Link to free/busy CCB queue */ 783 SYM_QUEHEAD link_ccbq; /* Link to free/busy CCB queue */
805 u32 startp; /* Initial data pointer */ 784 u32 startp; /* Initial data pointer */
806 u32 goalp; /* Expected last data pointer */ 785 u32 goalp; /* Expected last data pointer */
807#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
808 u32 wgoalp;
809#endif
810 int ext_sg; /* Extreme data pointer, used */ 786 int ext_sg; /* Extreme data pointer, used */
811 int ext_ofs; /* to calculate the residual. */ 787 int ext_ofs; /* to calculate the residual. */
812#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING 788#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
@@ -821,12 +797,6 @@ struct sym_ccb {
821 797
822#define CCB_BA(cp,lbl) cpu_to_scr(cp->ccb_ba + offsetof(struct sym_ccb, lbl)) 798#define CCB_BA(cp,lbl) cpu_to_scr(cp->ccb_ba + offsetof(struct sym_ccb, lbl))
823 799
824#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
825#define sym_goalp(cp) ((cp->host_flags & HF_DATA_IN) ? cp->goalp : cp->wgoalp)
826#else
827#define sym_goalp(cp) (cp->goalp)
828#endif
829
830typedef struct device *m_pool_ident_t; 800typedef struct device *m_pool_ident_t;
831 801
832/* 802/*
@@ -1077,7 +1047,6 @@ char *sym_driver_name(void);
1077void sym_print_xerr(struct scsi_cmnd *cmd, int x_status); 1047void sym_print_xerr(struct scsi_cmnd *cmd, int x_status);
1078int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int); 1048int sym_reset_scsi_bus(struct sym_hcb *np, int enab_int);
1079struct sym_chip *sym_lookup_chip_table(u_short device_id, u_char revision); 1049struct sym_chip *sym_lookup_chip_table(u_short device_id, u_char revision);
1080void sym_put_start_queue(struct sym_hcb *np, struct sym_ccb *cp);
1081#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING 1050#ifdef SYM_OPT_HANDLE_DEVICE_QUEUEING
1082void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn); 1051void sym_start_next_ccbs(struct sym_hcb *np, struct sym_lcb *lp, int maxn);
1083#endif 1052#endif
@@ -1136,71 +1105,6 @@ bad:
1136#endif 1105#endif
1137 1106
1138/* 1107/*
1139 * Set up data pointers used by SCRIPTS.
1140 * Called from O/S specific code.
1141 */
1142static inline void sym_setup_data_pointers(struct sym_hcb *np,
1143 struct sym_ccb *cp, int dir)
1144{
1145 u32 lastp, goalp;
1146
1147 /*
1148 * No segments means no data.
1149 */
1150 if (!cp->segments)
1151 dir = DMA_NONE;
1152
1153 /*
1154 * Set the data pointer.
1155 */
1156 switch(dir) {
1157#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1158 case DMA_BIDIRECTIONAL:
1159#endif
1160 case DMA_TO_DEVICE:
1161 goalp = SCRIPTA_BA(np, data_out2) + 8;
1162 lastp = goalp - 8 - (cp->segments * (2*4));
1163#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1164 cp->wgoalp = cpu_to_scr(goalp);
1165 if (dir != DMA_BIDIRECTIONAL)
1166 break;
1167 cp->phys.head.wlastp = cpu_to_scr(lastp);
1168 /* fall through */
1169#else
1170 break;
1171#endif
1172 case DMA_FROM_DEVICE:
1173 cp->host_flags |= HF_DATA_IN;
1174 goalp = SCRIPTA_BA(np, data_in2) + 8;
1175 lastp = goalp - 8 - (cp->segments * (2*4));
1176 break;
1177 case DMA_NONE:
1178 default:
1179#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1180 cp->host_flags |= HF_DATA_IN;
1181#endif
1182 lastp = goalp = SCRIPTB_BA(np, no_data);
1183 break;
1184 }
1185
1186 /*
1187 * Set all pointers values needed by SCRIPTS.
1188 */
1189 cp->phys.head.lastp = cpu_to_scr(lastp);
1190 cp->phys.head.savep = cpu_to_scr(lastp);
1191 cp->startp = cp->phys.head.savep;
1192 cp->goalp = cpu_to_scr(goalp);
1193
1194#ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1195 /*
1196 * If direction is unknown, start at data_io.
1197 */
1198 if (dir == DMA_BIDIRECTIONAL)
1199 cp->phys.head.savep = cpu_to_scr(SCRIPTB_BA(np, data_io));
1200#endif
1201}
1202
1203/*
1204 * MEMORY ALLOCATOR. 1108 * MEMORY ALLOCATOR.
1205 */ 1109 */
1206 1110
diff --git a/drivers/scsi/sym53c8xx_2/sym_malloc.c b/drivers/scsi/sym53c8xx_2/sym_malloc.c
index a34d403ccc6c..92bf9b14a7a2 100644
--- a/drivers/scsi/sym53c8xx_2/sym_malloc.c
+++ b/drivers/scsi/sym53c8xx_2/sym_malloc.c
@@ -37,11 +37,7 @@
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 */ 38 */
39 39
40#ifdef __FreeBSD__
41#include <dev/sym/sym_glue.h>
42#else
43#include "sym_glue.h" 40#include "sym_glue.h"
44#endif
45 41
46/* 42/*
47 * Simple power of two buddy-like generic allocator. 43 * Simple power of two buddy-like generic allocator.
diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.c b/drivers/scsi/sym53c8xx_2/sym_nvram.c
index 994b7566bcac..15d69298ab6e 100644
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.c
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.c
@@ -92,29 +92,32 @@ void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sy
92 * Get target set-up from Symbios format NVRAM. 92 * Get target set-up from Symbios format NVRAM.
93 */ 93 */
94static void 94static void
95sym_Symbios_setup_target(struct sym_hcb *np, int target, Symbios_nvram *nvram) 95sym_Symbios_setup_target(struct sym_tcb *tp, int target, Symbios_nvram *nvram)
96{ 96{
97 struct sym_tcb *tp = &np->target[target];
98 Symbios_target *tn = &nvram->target[target]; 97 Symbios_target *tn = &nvram->target[target];
99 98
100 tp->usrtags = 99 if (!(tn->flags & SYMBIOS_QUEUE_TAGS_ENABLED))
101 (tn->flags & SYMBIOS_QUEUE_TAGS_ENABLED)? SYM_SETUP_MAX_TAG : 0; 100 tp->usrtags = 0;
102
103 if (!(tn->flags & SYMBIOS_DISCONNECT_ENABLE)) 101 if (!(tn->flags & SYMBIOS_DISCONNECT_ENABLE))
104 tp->usrflags &= ~SYM_DISC_ENABLED; 102 tp->usrflags &= ~SYM_DISC_ENABLED;
105 if (!(tn->flags & SYMBIOS_SCAN_AT_BOOT_TIME)) 103 if (!(tn->flags & SYMBIOS_SCAN_AT_BOOT_TIME))
106 tp->usrflags |= SYM_SCAN_BOOT_DISABLED; 104 tp->usrflags |= SYM_SCAN_BOOT_DISABLED;
107 if (!(tn->flags & SYMBIOS_SCAN_LUNS)) 105 if (!(tn->flags & SYMBIOS_SCAN_LUNS))
108 tp->usrflags |= SYM_SCAN_LUNS_DISABLED; 106 tp->usrflags |= SYM_SCAN_LUNS_DISABLED;
107 tp->usr_period = (tn->sync_period + 3) / 4;
108 tp->usr_width = (tn->bus_width == 0x8) ? 0 : 1;
109} 109}
110 110
111static const unsigned char Tekram_sync[16] = {
112 25, 31, 37, 43, 50, 62, 75, 125, 12, 15, 18, 21, 6, 7, 9, 10
113};
114
111/* 115/*
112 * Get target set-up from Tekram format NVRAM. 116 * Get target set-up from Tekram format NVRAM.
113 */ 117 */
114static void 118static void
115sym_Tekram_setup_target(struct sym_hcb *np, int target, Tekram_nvram *nvram) 119sym_Tekram_setup_target(struct sym_tcb *tp, int target, Tekram_nvram *nvram)
116{ 120{
117 struct sym_tcb *tp = &np->target[target];
118 struct Tekram_target *tn = &nvram->target[target]; 121 struct Tekram_target *tn = &nvram->target[target];
119 122
120 if (tn->flags & TEKRAM_TAGGED_COMMANDS) { 123 if (tn->flags & TEKRAM_TAGGED_COMMANDS) {
@@ -124,22 +127,22 @@ sym_Tekram_setup_target(struct sym_hcb *np, int target, Tekram_nvram *nvram)
124 if (tn->flags & TEKRAM_DISCONNECT_ENABLE) 127 if (tn->flags & TEKRAM_DISCONNECT_ENABLE)
125 tp->usrflags |= SYM_DISC_ENABLED; 128 tp->usrflags |= SYM_DISC_ENABLED;
126 129
127 /* If any device does not support parity, we will not use this option */ 130 if (tn->flags & TEKRAM_SYNC_NEGO)
128 if (!(tn->flags & TEKRAM_PARITY_CHECK)) 131 tp->usr_period = Tekram_sync[tn->sync_index & 0xf];
129 np->rv_scntl0 &= ~0x0a; /* SCSI parity checking disabled */ 132 tp->usr_width = (tn->flags & TEKRAM_WIDE_NEGO) ? 1 : 0;
130} 133}
131 134
132/* 135/*
133 * Get target setup from NVRAM. 136 * Get target setup from NVRAM.
134 */ 137 */
135void sym_nvram_setup_target(struct sym_hcb *np, int target, struct sym_nvram *nvp) 138void sym_nvram_setup_target(struct sym_tcb *tp, int target, struct sym_nvram *nvp)
136{ 139{
137 switch (nvp->type) { 140 switch (nvp->type) {
138 case SYM_SYMBIOS_NVRAM: 141 case SYM_SYMBIOS_NVRAM:
139 sym_Symbios_setup_target(np, target, &nvp->data.Symbios); 142 sym_Symbios_setup_target(tp, target, &nvp->data.Symbios);
140 break; 143 break;
141 case SYM_TEKRAM_NVRAM: 144 case SYM_TEKRAM_NVRAM:
142 sym_Tekram_setup_target(np, target, &nvp->data.Tekram); 145 sym_Tekram_setup_target(tp, target, &nvp->data.Tekram);
143 break; 146 break;
144 default: 147 default:
145 break; 148 break;
diff --git a/drivers/scsi/sym53c8xx_2/sym_nvram.h b/drivers/scsi/sym53c8xx_2/sym_nvram.h
index 1538bede5277..bdfbbb083b69 100644
--- a/drivers/scsi/sym53c8xx_2/sym_nvram.h
+++ b/drivers/scsi/sym53c8xx_2/sym_nvram.h
@@ -194,12 +194,12 @@ struct sym_nvram {
194 194
195#if SYM_CONF_NVRAM_SUPPORT 195#if SYM_CONF_NVRAM_SUPPORT
196void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram); 196void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram);
197void sym_nvram_setup_target (struct sym_hcb *np, int target, struct sym_nvram *nvp); 197void sym_nvram_setup_target (struct sym_tcb *tp, int target, struct sym_nvram *nvp);
198int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp); 198int sym_read_nvram (struct sym_device *np, struct sym_nvram *nvp);
199char *sym_nvram_type(struct sym_nvram *nvp); 199char *sym_nvram_type(struct sym_nvram *nvp);
200#else 200#else
201static inline void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { } 201static inline void sym_nvram_setup_host(struct Scsi_Host *shost, struct sym_hcb *np, struct sym_nvram *nvram) { }
202static inline void sym_nvram_setup_target(struct sym_hcb *np, struct sym_nvram *nvram) { } 202static inline void sym_nvram_setup_target(struct sym_tcb *tp, struct sym_nvram *nvram) { }
203static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp) 203static inline int sym_read_nvram(struct sym_device *np, struct sym_nvram *nvp)
204{ 204{
205 nvp->type = 0; 205 nvp->type = 0;
diff --git a/drivers/scsi/sym53c8xx_comm.h b/drivers/scsi/sym53c8xx_comm.h
deleted file mode 100644
index 20ae2b17df58..000000000000
--- a/drivers/scsi/sym53c8xx_comm.h
+++ /dev/null
@@ -1,792 +0,0 @@
1/******************************************************************************
2** High Performance device driver for the Symbios 53C896 controller.
3**
4** Copyright (C) 1998-2001 Gerard Roudier <groudier@free.fr>
5**
6** This driver also supports all the Symbios 53C8XX controller family,
7** except 53C810 revisions < 16, 53C825 revisions < 16 and all
8** revisions of 53C815 controllers.
9**
10** This driver is based on the Linux port of the FreeBSD ncr driver.
11**
12** Copyright (C) 1994 Wolfgang Stanglmeier
13**
14**-----------------------------------------------------------------------------
15**
16** This program is free software; you can redistribute it and/or modify
17** it under the terms of the GNU General Public License as published by
18** the Free Software Foundation; either version 2 of the License, or
19** (at your option) any later version.
20**
21** This program is distributed in the hope that it will be useful,
22** but WITHOUT ANY WARRANTY; without even the implied warranty of
23** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24** GNU General Public License for more details.
25**
26** You should have received a copy of the GNU General Public License
27** along with this program; if not, write to the Free Software
28** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29**
30**-----------------------------------------------------------------------------
31**
32** The Linux port of the FreeBSD ncr driver has been achieved in
33** november 1995 by:
34**
35** Gerard Roudier <groudier@free.fr>
36**
37** Being given that this driver originates from the FreeBSD version, and
38** in order to keep synergy on both, any suggested enhancements and corrections
39** received on Linux are automatically a potential candidate for the FreeBSD
40** version.
41**
42** The original driver has been written for 386bsd and FreeBSD by
43** Wolfgang Stanglmeier <wolf@cologne.de>
44** Stefan Esser <se@mi.Uni-Koeln.de>
45**
46**-----------------------------------------------------------------------------
47**
48** Major contributions:
49** --------------------
50**
51** NVRAM detection and reading.
52** Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
53**
54*******************************************************************************
55*/
56
57/*==========================================================
58**
59** Debugging tags
60**
61**==========================================================
62*/
63
64#define DEBUG_ALLOC (0x0001)
65#define DEBUG_PHASE (0x0002)
66#define DEBUG_QUEUE (0x0008)
67#define DEBUG_RESULT (0x0010)
68#define DEBUG_POINTER (0x0020)
69#define DEBUG_SCRIPT (0x0040)
70#define DEBUG_TINY (0x0080)
71#define DEBUG_TIMING (0x0100)
72#define DEBUG_NEGO (0x0200)
73#define DEBUG_TAGS (0x0400)
74#define DEBUG_SCATTER (0x0800)
75#define DEBUG_IC (0x1000)
76
77/*
78** Enable/Disable debug messages.
79** Can be changed at runtime too.
80*/
81
82#ifdef SCSI_NCR_DEBUG_INFO_SUPPORT
83static int ncr_debug = SCSI_NCR_DEBUG_FLAGS;
84 #define DEBUG_FLAGS ncr_debug
85#else
86 #define DEBUG_FLAGS SCSI_NCR_DEBUG_FLAGS
87#endif
88
89static inline struct list_head *ncr_list_pop(struct list_head *head)
90{
91 if (!list_empty(head)) {
92 struct list_head *elem = head->next;
93
94 list_del(elem);
95 return elem;
96 }
97
98 return NULL;
99}
100
101#ifdef __sparc__
102#include <asm/irq.h>
103#endif
104
105/*==========================================================
106**
107** Simple power of two buddy-like allocator.
108**
109** This simple code is not intended to be fast, but to
110** provide power of 2 aligned memory allocations.
111** Since the SCRIPTS processor only supplies 8 bit
112** arithmetic, this allocator allows simple and fast
113** address calculations from the SCRIPTS code.
114** In addition, cache line alignment is guaranteed for
115** power of 2 cache line size.
116** Enhanced in linux-2.3.44 to provide a memory pool
117** per pcidev to support dynamic dma mapping. (I would
118** have preferred a real bus astraction, btw).
119**
120**==========================================================
121*/
122
123#define MEMO_SHIFT 4 /* 16 bytes minimum memory chunk */
124#if PAGE_SIZE >= 8192
125#define MEMO_PAGE_ORDER 0 /* 1 PAGE maximum */
126#else
127#define MEMO_PAGE_ORDER 1 /* 2 PAGES maximum */
128#endif
129#define MEMO_FREE_UNUSED /* Free unused pages immediately */
130#define MEMO_WARN 1
131#define MEMO_GFP_FLAGS GFP_ATOMIC
132#define MEMO_CLUSTER_SHIFT (PAGE_SHIFT+MEMO_PAGE_ORDER)
133#define MEMO_CLUSTER_SIZE (1UL << MEMO_CLUSTER_SHIFT)
134#define MEMO_CLUSTER_MASK (MEMO_CLUSTER_SIZE-1)
135
136typedef u_long m_addr_t; /* Enough bits to bit-hack addresses */
137typedef struct device *m_bush_t; /* Something that addresses DMAable */
138
139typedef struct m_link { /* Link between free memory chunks */
140 struct m_link *next;
141} m_link_s;
142
143typedef struct m_vtob { /* Virtual to Bus address translation */
144 struct m_vtob *next;
145 m_addr_t vaddr;
146 m_addr_t baddr;
147} m_vtob_s;
148#define VTOB_HASH_SHIFT 5
149#define VTOB_HASH_SIZE (1UL << VTOB_HASH_SHIFT)
150#define VTOB_HASH_MASK (VTOB_HASH_SIZE-1)
151#define VTOB_HASH_CODE(m) \
152 ((((m_addr_t) (m)) >> MEMO_CLUSTER_SHIFT) & VTOB_HASH_MASK)
153
154typedef struct m_pool { /* Memory pool of a given kind */
155 m_bush_t bush;
156 m_addr_t (*getp)(struct m_pool *);
157 void (*freep)(struct m_pool *, m_addr_t);
158 int nump;
159 m_vtob_s *(vtob[VTOB_HASH_SIZE]);
160 struct m_pool *next;
161 struct m_link h[PAGE_SHIFT-MEMO_SHIFT+MEMO_PAGE_ORDER+1];
162} m_pool_s;
163
164static void *___m_alloc(m_pool_s *mp, int size)
165{
166 int i = 0;
167 int s = (1 << MEMO_SHIFT);
168 int j;
169 m_addr_t a;
170 m_link_s *h = mp->h;
171
172 if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
173 return NULL;
174
175 while (size > s) {
176 s <<= 1;
177 ++i;
178 }
179
180 j = i;
181 while (!h[j].next) {
182 if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
183 h[j].next = (m_link_s *)mp->getp(mp);
184 if (h[j].next)
185 h[j].next->next = NULL;
186 break;
187 }
188 ++j;
189 s <<= 1;
190 }
191 a = (m_addr_t) h[j].next;
192 if (a) {
193 h[j].next = h[j].next->next;
194 while (j > i) {
195 j -= 1;
196 s >>= 1;
197 h[j].next = (m_link_s *) (a+s);
198 h[j].next->next = NULL;
199 }
200 }
201#ifdef DEBUG
202 printk("___m_alloc(%d) = %p\n", size, (void *) a);
203#endif
204 return (void *) a;
205}
206
207static void ___m_free(m_pool_s *mp, void *ptr, int size)
208{
209 int i = 0;
210 int s = (1 << MEMO_SHIFT);
211 m_link_s *q;
212 m_addr_t a, b;
213 m_link_s *h = mp->h;
214
215#ifdef DEBUG
216 printk("___m_free(%p, %d)\n", ptr, size);
217#endif
218
219 if (size > (PAGE_SIZE << MEMO_PAGE_ORDER))
220 return;
221
222 while (size > s) {
223 s <<= 1;
224 ++i;
225 }
226
227 a = (m_addr_t) ptr;
228
229 while (1) {
230#ifdef MEMO_FREE_UNUSED
231 if (s == (PAGE_SIZE << MEMO_PAGE_ORDER)) {
232 mp->freep(mp, a);
233 break;
234 }
235#endif
236 b = a ^ s;
237 q = &h[i];
238 while (q->next && q->next != (m_link_s *) b) {
239 q = q->next;
240 }
241 if (!q->next) {
242 ((m_link_s *) a)->next = h[i].next;
243 h[i].next = (m_link_s *) a;
244 break;
245 }
246 q->next = q->next->next;
247 a = a & b;
248 s <<= 1;
249 ++i;
250 }
251}
252
253static DEFINE_SPINLOCK(ncr53c8xx_lock);
254
255static void *__m_calloc2(m_pool_s *mp, int size, char *name, int uflags)
256{
257 void *p;
258
259 p = ___m_alloc(mp, size);
260
261 if (DEBUG_FLAGS & DEBUG_ALLOC)
262 printk ("new %-10s[%4d] @%p.\n", name, size, p);
263
264 if (p)
265 memset(p, 0, size);
266 else if (uflags & MEMO_WARN)
267 printk (NAME53C8XX ": failed to allocate %s[%d]\n", name, size);
268
269 return p;
270}
271
272#define __m_calloc(mp, s, n) __m_calloc2(mp, s, n, MEMO_WARN)
273
274static void __m_free(m_pool_s *mp, void *ptr, int size, char *name)
275{
276 if (DEBUG_FLAGS & DEBUG_ALLOC)
277 printk ("freeing %-10s[%4d] @%p.\n", name, size, ptr);
278
279 ___m_free(mp, ptr, size);
280
281}
282
283/*
284 * With pci bus iommu support, we use a default pool of unmapped memory
285 * for memory we donnot need to DMA from/to and one pool per pcidev for
286 * memory accessed by the PCI chip. `mp0' is the default not DMAable pool.
287 */
288
289static m_addr_t ___mp0_getp(m_pool_s *mp)
290{
291 m_addr_t m = __get_free_pages(MEMO_GFP_FLAGS, MEMO_PAGE_ORDER);
292 if (m)
293 ++mp->nump;
294 return m;
295}
296
297static void ___mp0_freep(m_pool_s *mp, m_addr_t m)
298{
299 free_pages(m, MEMO_PAGE_ORDER);
300 --mp->nump;
301}
302
303static m_pool_s mp0 = {NULL, ___mp0_getp, ___mp0_freep};
304
305/*
306 * DMAable pools.
307 */
308
309/*
310 * With pci bus iommu support, we maintain one pool per pcidev and a
311 * hashed reverse table for virtual to bus physical address translations.
312 */
313static m_addr_t ___dma_getp(m_pool_s *mp)
314{
315 m_addr_t vp;
316 m_vtob_s *vbp;
317
318 vbp = __m_calloc(&mp0, sizeof(*vbp), "VTOB");
319 if (vbp) {
320 dma_addr_t daddr;
321 vp = (m_addr_t) dma_alloc_coherent(mp->bush,
322 PAGE_SIZE<<MEMO_PAGE_ORDER,
323 &daddr, GFP_ATOMIC);
324 if (vp) {
325 int hc = VTOB_HASH_CODE(vp);
326 vbp->vaddr = vp;
327 vbp->baddr = daddr;
328 vbp->next = mp->vtob[hc];
329 mp->vtob[hc] = vbp;
330 ++mp->nump;
331 return vp;
332 }
333 }
334 if (vbp)
335 __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
336 return 0;
337}
338
339static void ___dma_freep(m_pool_s *mp, m_addr_t m)
340{
341 m_vtob_s **vbpp, *vbp;
342 int hc = VTOB_HASH_CODE(m);
343
344 vbpp = &mp->vtob[hc];
345 while (*vbpp && (*vbpp)->vaddr != m)
346 vbpp = &(*vbpp)->next;
347 if (*vbpp) {
348 vbp = *vbpp;
349 *vbpp = (*vbpp)->next;
350 dma_free_coherent(mp->bush, PAGE_SIZE<<MEMO_PAGE_ORDER,
351 (void *)vbp->vaddr, (dma_addr_t)vbp->baddr);
352 __m_free(&mp0, vbp, sizeof(*vbp), "VTOB");
353 --mp->nump;
354 }
355}
356
357static inline m_pool_s *___get_dma_pool(m_bush_t bush)
358{
359 m_pool_s *mp;
360 for (mp = mp0.next; mp && mp->bush != bush; mp = mp->next);
361 return mp;
362}
363
364static m_pool_s *___cre_dma_pool(m_bush_t bush)
365{
366 m_pool_s *mp;
367 mp = __m_calloc(&mp0, sizeof(*mp), "MPOOL");
368 if (mp) {
369 memset(mp, 0, sizeof(*mp));
370 mp->bush = bush;
371 mp->getp = ___dma_getp;
372 mp->freep = ___dma_freep;
373 mp->next = mp0.next;
374 mp0.next = mp;
375 }
376 return mp;
377}
378
379static void ___del_dma_pool(m_pool_s *p)
380{
381 struct m_pool **pp = &mp0.next;
382
383 while (*pp && *pp != p)
384 pp = &(*pp)->next;
385 if (*pp) {
386 *pp = (*pp)->next;
387 __m_free(&mp0, p, sizeof(*p), "MPOOL");
388 }
389}
390
391static void *__m_calloc_dma(m_bush_t bush, int size, char *name)
392{
393 u_long flags;
394 struct m_pool *mp;
395 void *m = NULL;
396
397 spin_lock_irqsave(&ncr53c8xx_lock, flags);
398 mp = ___get_dma_pool(bush);
399 if (!mp)
400 mp = ___cre_dma_pool(bush);
401 if (mp)
402 m = __m_calloc(mp, size, name);
403 if (mp && !mp->nump)
404 ___del_dma_pool(mp);
405 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
406
407 return m;
408}
409
410static void __m_free_dma(m_bush_t bush, void *m, int size, char *name)
411{
412 u_long flags;
413 struct m_pool *mp;
414
415 spin_lock_irqsave(&ncr53c8xx_lock, flags);
416 mp = ___get_dma_pool(bush);
417 if (mp)
418 __m_free(mp, m, size, name);
419 if (mp && !mp->nump)
420 ___del_dma_pool(mp);
421 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
422}
423
424static m_addr_t __vtobus(m_bush_t bush, void *m)
425{
426 u_long flags;
427 m_pool_s *mp;
428 int hc = VTOB_HASH_CODE(m);
429 m_vtob_s *vp = NULL;
430 m_addr_t a = ((m_addr_t) m) & ~MEMO_CLUSTER_MASK;
431
432 spin_lock_irqsave(&ncr53c8xx_lock, flags);
433 mp = ___get_dma_pool(bush);
434 if (mp) {
435 vp = mp->vtob[hc];
436 while (vp && (m_addr_t) vp->vaddr != a)
437 vp = vp->next;
438 }
439 spin_unlock_irqrestore(&ncr53c8xx_lock, flags);
440 return vp ? vp->baddr + (((m_addr_t) m) - a) : 0;
441}
442
443#define _m_calloc_dma(np, s, n) __m_calloc_dma(np->dev, s, n)
444#define _m_free_dma(np, p, s, n) __m_free_dma(np->dev, p, s, n)
445#define m_calloc_dma(s, n) _m_calloc_dma(np, s, n)
446#define m_free_dma(p, s, n) _m_free_dma(np, p, s, n)
447#define _vtobus(np, p) __vtobus(np->dev, p)
448#define vtobus(p) _vtobus(np, p)
449
450/*
451 * Deal with DMA mapping/unmapping.
452 */
453
454/* To keep track of the dma mapping (sg/single) that has been set */
455#define __data_mapped SCp.phase
456#define __data_mapping SCp.have_data_in
457
458static void __unmap_scsi_data(struct device *dev, struct scsi_cmnd *cmd)
459{
460 switch(cmd->__data_mapped) {
461 case 2:
462 dma_unmap_sg(dev, cmd->buffer, cmd->use_sg,
463 cmd->sc_data_direction);
464 break;
465 case 1:
466 dma_unmap_single(dev, cmd->__data_mapping,
467 cmd->request_bufflen,
468 cmd->sc_data_direction);
469 break;
470 }
471 cmd->__data_mapped = 0;
472}
473
474static u_long __map_scsi_single_data(struct device *dev, struct scsi_cmnd *cmd)
475{
476 dma_addr_t mapping;
477
478 if (cmd->request_bufflen == 0)
479 return 0;
480
481 mapping = dma_map_single(dev, cmd->request_buffer,
482 cmd->request_bufflen,
483 cmd->sc_data_direction);
484 cmd->__data_mapped = 1;
485 cmd->__data_mapping = mapping;
486
487 return mapping;
488}
489
490static int __map_scsi_sg_data(struct device *dev, struct scsi_cmnd *cmd)
491{
492 int use_sg;
493
494 if (cmd->use_sg == 0)
495 return 0;
496
497 use_sg = dma_map_sg(dev, cmd->buffer, cmd->use_sg,
498 cmd->sc_data_direction);
499 cmd->__data_mapped = 2;
500 cmd->__data_mapping = use_sg;
501
502 return use_sg;
503}
504
505#define unmap_scsi_data(np, cmd) __unmap_scsi_data(np->dev, cmd)
506#define map_scsi_single_data(np, cmd) __map_scsi_single_data(np->dev, cmd)
507#define map_scsi_sg_data(np, cmd) __map_scsi_sg_data(np->dev, cmd)
508
509/*==========================================================
510**
511** Driver setup.
512**
513** This structure is initialized from linux config
514** options. It can be overridden at boot-up by the boot
515** command line.
516**
517**==========================================================
518*/
519static struct ncr_driver_setup
520 driver_setup = SCSI_NCR_DRIVER_SETUP;
521
522#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
523static struct ncr_driver_setup
524 driver_safe_setup __initdata = SCSI_NCR_DRIVER_SAFE_SETUP;
525#endif
526
527#define initverbose (driver_setup.verbose)
528#define bootverbose (np->verbose)
529
530
531/*===================================================================
532**
533** Driver setup from the boot command line
534**
535**===================================================================
536*/
537
538#ifdef MODULE
539#define ARG_SEP ' '
540#else
541#define ARG_SEP ','
542#endif
543
544#define OPT_TAGS 1
545#define OPT_MASTER_PARITY 2
546#define OPT_SCSI_PARITY 3
547#define OPT_DISCONNECTION 4
548#define OPT_SPECIAL_FEATURES 5
549#define OPT_UNUSED_1 6
550#define OPT_FORCE_SYNC_NEGO 7
551#define OPT_REVERSE_PROBE 8
552#define OPT_DEFAULT_SYNC 9
553#define OPT_VERBOSE 10
554#define OPT_DEBUG 11
555#define OPT_BURST_MAX 12
556#define OPT_LED_PIN 13
557#define OPT_MAX_WIDE 14
558#define OPT_SETTLE_DELAY 15
559#define OPT_DIFF_SUPPORT 16
560#define OPT_IRQM 17
561#define OPT_PCI_FIX_UP 18
562#define OPT_BUS_CHECK 19
563#define OPT_OPTIMIZE 20
564#define OPT_RECOVERY 21
565#define OPT_SAFE_SETUP 22
566#define OPT_USE_NVRAM 23
567#define OPT_EXCLUDE 24
568#define OPT_HOST_ID 25
569
570#ifdef SCSI_NCR_IARB_SUPPORT
571#define OPT_IARB 26
572#endif
573
574static char setup_token[] __initdata =
575 "tags:" "mpar:"
576 "spar:" "disc:"
577 "specf:" "ultra:"
578 "fsn:" "revprob:"
579 "sync:" "verb:"
580 "debug:" "burst:"
581 "led:" "wide:"
582 "settle:" "diff:"
583 "irqm:" "pcifix:"
584 "buschk:" "optim:"
585 "recovery:"
586 "safe:" "nvram:"
587 "excl:" "hostid:"
588#ifdef SCSI_NCR_IARB_SUPPORT
589 "iarb:"
590#endif
591 ; /* DONNOT REMOVE THIS ';' */
592
593#ifdef MODULE
594#define ARG_SEP ' '
595#else
596#define ARG_SEP ','
597#endif
598
599static int __init get_setup_token(char *p)
600{
601 char *cur = setup_token;
602 char *pc;
603 int i = 0;
604
605 while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
606 ++pc;
607 ++i;
608 if (!strncmp(p, cur, pc - cur))
609 return i;
610 cur = pc;
611 }
612 return 0;
613}
614
615
616static int __init sym53c8xx__setup(char *str)
617{
618#ifdef SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
619 char *cur = str;
620 char *pc, *pv;
621 int i, val, c;
622 int xi = 0;
623
624 while (cur != NULL && (pc = strchr(cur, ':')) != NULL) {
625 char *pe;
626
627 val = 0;
628 pv = pc;
629 c = *++pv;
630
631 if (c == 'n')
632 val = 0;
633 else if (c == 'y')
634 val = 1;
635 else
636 val = (int) simple_strtoul(pv, &pe, 0);
637
638 switch (get_setup_token(cur)) {
639 case OPT_TAGS:
640 driver_setup.default_tags = val;
641 if (pe && *pe == '/') {
642 i = 0;
643 while (*pe && *pe != ARG_SEP &&
644 i < sizeof(driver_setup.tag_ctrl)-1) {
645 driver_setup.tag_ctrl[i++] = *pe++;
646 }
647 driver_setup.tag_ctrl[i] = '\0';
648 }
649 break;
650 case OPT_MASTER_PARITY:
651 driver_setup.master_parity = val;
652 break;
653 case OPT_SCSI_PARITY:
654 driver_setup.scsi_parity = val;
655 break;
656 case OPT_DISCONNECTION:
657 driver_setup.disconnection = val;
658 break;
659 case OPT_SPECIAL_FEATURES:
660 driver_setup.special_features = val;
661 break;
662 case OPT_FORCE_SYNC_NEGO:
663 driver_setup.force_sync_nego = val;
664 break;
665 case OPT_REVERSE_PROBE:
666 driver_setup.reverse_probe = val;
667 break;
668 case OPT_DEFAULT_SYNC:
669 driver_setup.default_sync = val;
670 break;
671 case OPT_VERBOSE:
672 driver_setup.verbose = val;
673 break;
674 case OPT_DEBUG:
675 driver_setup.debug = val;
676 break;
677 case OPT_BURST_MAX:
678 driver_setup.burst_max = val;
679 break;
680 case OPT_LED_PIN:
681 driver_setup.led_pin = val;
682 break;
683 case OPT_MAX_WIDE:
684 driver_setup.max_wide = val? 1:0;
685 break;
686 case OPT_SETTLE_DELAY:
687 driver_setup.settle_delay = val;
688 break;
689 case OPT_DIFF_SUPPORT:
690 driver_setup.diff_support = val;
691 break;
692 case OPT_IRQM:
693 driver_setup.irqm = val;
694 break;
695 case OPT_PCI_FIX_UP:
696 driver_setup.pci_fix_up = val;
697 break;
698 case OPT_BUS_CHECK:
699 driver_setup.bus_check = val;
700 break;
701 case OPT_OPTIMIZE:
702 driver_setup.optimize = val;
703 break;
704 case OPT_RECOVERY:
705 driver_setup.recovery = val;
706 break;
707 case OPT_USE_NVRAM:
708 driver_setup.use_nvram = val;
709 break;
710 case OPT_SAFE_SETUP:
711 memcpy(&driver_setup, &driver_safe_setup,
712 sizeof(driver_setup));
713 break;
714 case OPT_EXCLUDE:
715 if (xi < SCSI_NCR_MAX_EXCLUDES)
716 driver_setup.excludes[xi++] = val;
717 break;
718 case OPT_HOST_ID:
719 driver_setup.host_id = val;
720 break;
721#ifdef SCSI_NCR_IARB_SUPPORT
722 case OPT_IARB:
723 driver_setup.iarb = val;
724 break;
725#endif
726 default:
727 printk("sym53c8xx_setup: unexpected boot option '%.*s' ignored\n", (int)(pc-cur+1), cur);
728 break;
729 }
730
731 if ((cur = strchr(cur, ARG_SEP)) != NULL)
732 ++cur;
733 }
734#endif /* SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT */
735 return 1;
736}
737
738/*===================================================================
739**
740** Get device queue depth from boot command line.
741**
742**===================================================================
743*/
744#define DEF_DEPTH (driver_setup.default_tags)
745#define ALL_TARGETS -2
746#define NO_TARGET -1
747#define ALL_LUNS -2
748#define NO_LUN -1
749
750static int device_queue_depth(int unit, int target, int lun)
751{
752 int c, h, t, u, v;
753 char *p = driver_setup.tag_ctrl;
754 char *ep;
755
756 h = -1;
757 t = NO_TARGET;
758 u = NO_LUN;
759 while ((c = *p++) != 0) {
760 v = simple_strtoul(p, &ep, 0);
761 switch(c) {
762 case '/':
763 ++h;
764 t = ALL_TARGETS;
765 u = ALL_LUNS;
766 break;
767 case 't':
768 if (t != target)
769 t = (target == v) ? v : NO_TARGET;
770 u = ALL_LUNS;
771 break;
772 case 'u':
773 if (u != lun)
774 u = (lun == v) ? v : NO_LUN;
775 break;
776 case 'q':
777 if (h == unit &&
778 (t == ALL_TARGETS || t == target) &&
779 (u == ALL_LUNS || u == lun))
780 return v;
781 break;
782 case '-':
783 t = ALL_TARGETS;
784 u = ALL_LUNS;
785 break;
786 default:
787 break;
788 }
789 p = ep;
790 }
791 return DEF_DEPTH;
792}
diff --git a/drivers/scsi/sym53c8xx_defs.h b/drivers/scsi/sym53c8xx_defs.h
deleted file mode 100644
index 139cd0e12e62..000000000000
--- a/drivers/scsi/sym53c8xx_defs.h
+++ /dev/null
@@ -1,1320 +0,0 @@
1/******************************************************************************
2** High Performance device driver for the Symbios 53C896 controller.
3**
4** Copyright (C) 1998-2001 Gerard Roudier <groudier@free.fr>
5**
6** This driver also supports all the Symbios 53C8XX controller family,
7** except 53C810 revisions < 16, 53C825 revisions < 16 and all
8** revisions of 53C815 controllers.
9**
10** This driver is based on the Linux port of the FreeBSD ncr driver.
11**
12** Copyright (C) 1994 Wolfgang Stanglmeier
13**
14**-----------------------------------------------------------------------------
15**
16** This program is free software; you can redistribute it and/or modify
17** it under the terms of the GNU General Public License as published by
18** the Free Software Foundation; either version 2 of the License, or
19** (at your option) any later version.
20**
21** This program is distributed in the hope that it will be useful,
22** but WITHOUT ANY WARRANTY; without even the implied warranty of
23** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24** GNU General Public License for more details.
25**
26** You should have received a copy of the GNU General Public License
27** along with this program; if not, write to the Free Software
28** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29**
30**-----------------------------------------------------------------------------
31**
32** The Linux port of the FreeBSD ncr driver has been achieved in
33** november 1995 by:
34**
35** Gerard Roudier <groudier@free.fr>
36**
37** Being given that this driver originates from the FreeBSD version, and
38** in order to keep synergy on both, any suggested enhancements and corrections
39** received on Linux are automatically a potential candidate for the FreeBSD
40** version.
41**
42** The original driver has been written for 386bsd and FreeBSD by
43** Wolfgang Stanglmeier <wolf@cologne.de>
44** Stefan Esser <se@mi.Uni-Koeln.de>
45**
46**-----------------------------------------------------------------------------
47**
48** Major contributions:
49** --------------------
50**
51** NVRAM detection and reading.
52** Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
53**
54** Added support for MIPS big endian systems.
55** Carsten Langgaard, carstenl@mips.com
56** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
57**
58** Added support for HP PARISC big endian systems.
59** Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
60**
61*******************************************************************************
62*/
63
64#ifndef SYM53C8XX_DEFS_H
65#define SYM53C8XX_DEFS_H
66
67#include <linux/config.h>
68
69/*
70** If you want a driver as small as possible, donnot define the
71** following options.
72*/
73#define SCSI_NCR_BOOT_COMMAND_LINE_SUPPORT
74#define SCSI_NCR_DEBUG_INFO_SUPPORT
75
76/*
77** To disable integrity checking, do not define the
78** following option.
79*/
80#ifdef CONFIG_SCSI_NCR53C8XX_INTEGRITY_CHECK
81# define SCSI_NCR_ENABLE_INTEGRITY_CHECK
82#endif
83
84/* ---------------------------------------------------------------------
85** Take into account kernel configured parameters.
86** Most of these options can be overridden at startup by a command line.
87** ---------------------------------------------------------------------
88*/
89
90/*
91 * For Ultra2 and Ultra3 SCSI support option, use special features.
92 *
93 * Value (default) means:
94 * bit 0 : all features enabled, except:
95 * bit 1 : PCI Write And Invalidate.
96 * bit 2 : Data Phase Mismatch handling from SCRIPTS.
97 *
98 * Use boot options ncr53c8xx=specf:1 if you want all chip features to be
99 * enabled by the driver.
100 */
101#define SCSI_NCR_SETUP_SPECIAL_FEATURES (3)
102
103#define SCSI_NCR_MAX_SYNC (80)
104
105/*
106 * Allow tags from 2 to 256, default 8
107 */
108#ifdef CONFIG_SCSI_NCR53C8XX_MAX_TAGS
109#if CONFIG_SCSI_NCR53C8XX_MAX_TAGS < 2
110#define SCSI_NCR_MAX_TAGS (2)
111#elif CONFIG_SCSI_NCR53C8XX_MAX_TAGS > 256
112#define SCSI_NCR_MAX_TAGS (256)
113#else
114#define SCSI_NCR_MAX_TAGS CONFIG_SCSI_NCR53C8XX_MAX_TAGS
115#endif
116#else
117#define SCSI_NCR_MAX_TAGS (8)
118#endif
119
120/*
121 * Allow tagged command queuing support if configured with default number
122 * of tags set to max (see above).
123 */
124#ifdef CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
125#define SCSI_NCR_SETUP_DEFAULT_TAGS CONFIG_SCSI_NCR53C8XX_DEFAULT_TAGS
126#elif defined CONFIG_SCSI_NCR53C8XX_TAGGED_QUEUE
127#define SCSI_NCR_SETUP_DEFAULT_TAGS SCSI_NCR_MAX_TAGS
128#else
129#define SCSI_NCR_SETUP_DEFAULT_TAGS (0)
130#endif
131
132/*
133 * Immediate arbitration
134 */
135#if defined(CONFIG_SCSI_NCR53C8XX_IARB)
136#define SCSI_NCR_IARB_SUPPORT
137#endif
138
139/*
140 * Sync transfer frequency at startup.
141 * Allow from 5Mhz to 80Mhz default 20 Mhz.
142 */
143#ifndef CONFIG_SCSI_NCR53C8XX_SYNC
144#define CONFIG_SCSI_NCR53C8XX_SYNC (20)
145#elif CONFIG_SCSI_NCR53C8XX_SYNC > SCSI_NCR_MAX_SYNC
146#undef CONFIG_SCSI_NCR53C8XX_SYNC
147#define CONFIG_SCSI_NCR53C8XX_SYNC SCSI_NCR_MAX_SYNC
148#endif
149
150#if CONFIG_SCSI_NCR53C8XX_SYNC == 0
151#define SCSI_NCR_SETUP_DEFAULT_SYNC (255)
152#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 5
153#define SCSI_NCR_SETUP_DEFAULT_SYNC (50)
154#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 20
155#define SCSI_NCR_SETUP_DEFAULT_SYNC (250/(CONFIG_SCSI_NCR53C8XX_SYNC))
156#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 33
157#define SCSI_NCR_SETUP_DEFAULT_SYNC (11)
158#elif CONFIG_SCSI_NCR53C8XX_SYNC <= 40
159#define SCSI_NCR_SETUP_DEFAULT_SYNC (10)
160#else
161#define SCSI_NCR_SETUP_DEFAULT_SYNC (9)
162#endif
163
164/*
165 * Disallow disconnections at boot-up
166 */
167#ifdef CONFIG_SCSI_NCR53C8XX_NO_DISCONNECT
168#define SCSI_NCR_SETUP_DISCONNECTION (0)
169#else
170#define SCSI_NCR_SETUP_DISCONNECTION (1)
171#endif
172
173/*
174 * Force synchronous negotiation for all targets
175 */
176#ifdef CONFIG_SCSI_NCR53C8XX_FORCE_SYNC_NEGO
177#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (1)
178#else
179#define SCSI_NCR_SETUP_FORCE_SYNC_NEGO (0)
180#endif
181
182/*
183 * Disable master parity checking (flawed hardwares need that)
184 */
185#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_MPARITY_CHECK
186#define SCSI_NCR_SETUP_MASTER_PARITY (0)
187#else
188#define SCSI_NCR_SETUP_MASTER_PARITY (1)
189#endif
190
191/*
192 * Disable scsi parity checking (flawed devices may need that)
193 */
194#ifdef CONFIG_SCSI_NCR53C8XX_DISABLE_PARITY_CHECK
195#define SCSI_NCR_SETUP_SCSI_PARITY (0)
196#else
197#define SCSI_NCR_SETUP_SCSI_PARITY (1)
198#endif
199
200/*
201 * Settle time after reset at boot-up
202 */
203#define SCSI_NCR_SETUP_SETTLE_TIME (2)
204
205/*
206** Bridge quirks work-around option defaulted to 1.
207*/
208#ifndef SCSI_NCR_PCIQ_WORK_AROUND_OPT
209#define SCSI_NCR_PCIQ_WORK_AROUND_OPT 1
210#endif
211
212/*
213** Work-around common bridge misbehaviour.
214**
215** - Do not flush posted writes in the opposite
216** direction on read.
217** - May reorder DMA writes to memory.
218**
219** This option should not affect performances
220** significantly, so it is the default.
221*/
222#if SCSI_NCR_PCIQ_WORK_AROUND_OPT == 1
223#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
224#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
225#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
226
227/*
228** Same as option 1, but also deal with
229** misconfigured interrupts.
230**
231** - Edge triggerred instead of level sensitive.
232** - No interrupt line connected.
233** - IRQ number misconfigured.
234**
235** If no interrupt is delivered, the driver will
236** catch the interrupt conditions 10 times per
237** second. No need to say that this option is
238** not recommended.
239*/
240#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 2
241#define SCSI_NCR_PCIQ_MAY_NOT_FLUSH_PW_UPSTREAM
242#define SCSI_NCR_PCIQ_MAY_REORDER_WRITES
243#define SCSI_NCR_PCIQ_MAY_MISS_COMPLETIONS
244#define SCSI_NCR_PCIQ_BROKEN_INTR
245
246/*
247** Some bridge designers decided to flush
248** everything prior to deliver the interrupt.
249** This option tries to deal with such a
250** behaviour.
251*/
252#elif SCSI_NCR_PCIQ_WORK_AROUND_OPT == 3
253#define SCSI_NCR_PCIQ_SYNC_ON_INTR
254#endif
255
256/*
257** Other parameters not configurable with "make config"
258** Avoid to change these constants, unless you know what you are doing.
259*/
260
261#define SCSI_NCR_ALWAYS_SIMPLE_TAG
262#define SCSI_NCR_MAX_SCATTER (127)
263#define SCSI_NCR_MAX_TARGET (16)
264
265/*
266** Compute some desirable value for CAN_QUEUE
267** and CMD_PER_LUN.
268** The driver will use lower values if these
269** ones appear to be too large.
270*/
271#define SCSI_NCR_CAN_QUEUE (8*SCSI_NCR_MAX_TAGS + 2*SCSI_NCR_MAX_TARGET)
272#define SCSI_NCR_CMD_PER_LUN (SCSI_NCR_MAX_TAGS)
273
274#define SCSI_NCR_SG_TABLESIZE (SCSI_NCR_MAX_SCATTER)
275#define SCSI_NCR_TIMER_INTERVAL (HZ)
276
277#if 1 /* defined CONFIG_SCSI_MULTI_LUN */
278#define SCSI_NCR_MAX_LUN (16)
279#else
280#define SCSI_NCR_MAX_LUN (1)
281#endif
282
283/*
284 * IO functions definition for big/little endian CPU support.
285 * For now, the NCR is only supported in little endian addressing mode,
286 */
287
288#ifdef __BIG_ENDIAN
289
290#define inw_l2b inw
291#define inl_l2b inl
292#define outw_b2l outw
293#define outl_b2l outl
294
295#define readb_raw readb
296#define writeb_raw writeb
297
298#if defined(SCSI_NCR_BIG_ENDIAN)
299#define readw_l2b __raw_readw
300#define readl_l2b __raw_readl
301#define writew_b2l __raw_writew
302#define writel_b2l __raw_writel
303#define readw_raw __raw_readw
304#define readl_raw __raw_readl
305#define writew_raw __raw_writew
306#define writel_raw __raw_writel
307#else /* Other big-endian */
308#define readw_l2b readw
309#define readl_l2b readl
310#define writew_b2l writew
311#define writel_b2l writel
312#define readw_raw readw
313#define readl_raw readl
314#define writew_raw writew
315#define writel_raw writel
316#endif
317
318#else /* little endian */
319
320#define inw_raw inw
321#define inl_raw inl
322#define outw_raw outw
323#define outl_raw outl
324
325#define readb_raw readb
326#define readw_raw readw
327#define readl_raw readl
328#define writeb_raw writeb
329#define writew_raw writew
330#define writel_raw writel
331
332#endif
333
334#if !defined(__hppa__) && !defined(__mips__)
335#ifdef SCSI_NCR_BIG_ENDIAN
336#error "The NCR in BIG ENDIAN addressing mode is not (yet) supported"
337#endif
338#endif
339
340#define MEMORY_BARRIER() mb()
341
342
343/*
344 * If the NCR uses big endian addressing mode over the
345 * PCI, actual io register addresses for byte and word
346 * accesses must be changed according to lane routing.
347 * Btw, ncr_offb() and ncr_offw() macros only apply to
348 * constants and so donnot generate bloated code.
349 */
350
351#if defined(SCSI_NCR_BIG_ENDIAN)
352
353#define ncr_offb(o) (((o)&~3)+((~((o)&3))&3))
354#define ncr_offw(o) (((o)&~3)+((~((o)&3))&2))
355
356#else
357
358#define ncr_offb(o) (o)
359#define ncr_offw(o) (o)
360
361#endif
362
363/*
364 * If the CPU and the NCR use same endian-ness addressing,
365 * no byte reordering is needed for script patching.
366 * Macro cpu_to_scr() is to be used for script patching.
367 * Macro scr_to_cpu() is to be used for getting a DWORD
368 * from the script.
369 */
370
371#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
372
373#define cpu_to_scr(dw) cpu_to_le32(dw)
374#define scr_to_cpu(dw) le32_to_cpu(dw)
375
376#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
377
378#define cpu_to_scr(dw) cpu_to_be32(dw)
379#define scr_to_cpu(dw) be32_to_cpu(dw)
380
381#else
382
383#define cpu_to_scr(dw) (dw)
384#define scr_to_cpu(dw) (dw)
385
386#endif
387
388/*
389 * Access to the controller chip.
390 *
391 * If the CPU and the NCR use same endian-ness addressing,
392 * no byte reordering is needed for accessing chip io
393 * registers. Functions suffixed by '_raw' are assumed
394 * to access the chip over the PCI without doing byte
395 * reordering. Functions suffixed by '_l2b' are
396 * assumed to perform little-endian to big-endian byte
397 * reordering, those suffixed by '_b2l' blah, blah,
398 * blah, ...
399 */
400
401/*
402 * MEMORY mapped IO input / output
403 */
404
405#define INB_OFF(o) readb_raw((char __iomem *)np->reg + ncr_offb(o))
406#define OUTB_OFF(o, val) writeb_raw((val), (char __iomem *)np->reg + ncr_offb(o))
407
408#if defined(__BIG_ENDIAN) && !defined(SCSI_NCR_BIG_ENDIAN)
409
410#define INW_OFF(o) readw_l2b((char __iomem *)np->reg + ncr_offw(o))
411#define INL_OFF(o) readl_l2b((char __iomem *)np->reg + (o))
412
413#define OUTW_OFF(o, val) writew_b2l((val), (char __iomem *)np->reg + ncr_offw(o))
414#define OUTL_OFF(o, val) writel_b2l((val), (char __iomem *)np->reg + (o))
415
416#elif defined(__LITTLE_ENDIAN) && defined(SCSI_NCR_BIG_ENDIAN)
417
418#define INW_OFF(o) readw_b2l((char __iomem *)np->reg + ncr_offw(o))
419#define INL_OFF(o) readl_b2l((char __iomem *)np->reg + (o))
420
421#define OUTW_OFF(o, val) writew_l2b((val), (char __iomem *)np->reg + ncr_offw(o))
422#define OUTL_OFF(o, val) writel_l2b((val), (char __iomem *)np->reg + (o))
423
424#else
425
426#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
427/* Only 8 or 32 bit transfers allowed */
428#define INW_OFF(o) (readb((char __iomem *)np->reg + ncr_offw(o)) << 8 | readb((char __iomem *)np->reg + ncr_offw(o) + 1))
429#else
430#define INW_OFF(o) readw_raw((char __iomem *)np->reg + ncr_offw(o))
431#endif
432#define INL_OFF(o) readl_raw((char __iomem *)np->reg + (o))
433
434#ifdef CONFIG_SCSI_NCR53C8XX_NO_WORD_TRANSFERS
435/* Only 8 or 32 bit transfers allowed */
436#define OUTW_OFF(o, val) do { writeb((char)((val) >> 8), (char __iomem *)np->reg + ncr_offw(o)); writeb((char)(val), (char __iomem *)np->reg + ncr_offw(o) + 1); } while (0)
437#else
438#define OUTW_OFF(o, val) writew_raw((val), (char __iomem *)np->reg + ncr_offw(o))
439#endif
440#define OUTL_OFF(o, val) writel_raw((val), (char __iomem *)np->reg + (o))
441
442#endif
443
444#define INB(r) INB_OFF (offsetof(struct ncr_reg,r))
445#define INW(r) INW_OFF (offsetof(struct ncr_reg,r))
446#define INL(r) INL_OFF (offsetof(struct ncr_reg,r))
447
448#define OUTB(r, val) OUTB_OFF (offsetof(struct ncr_reg,r), (val))
449#define OUTW(r, val) OUTW_OFF (offsetof(struct ncr_reg,r), (val))
450#define OUTL(r, val) OUTL_OFF (offsetof(struct ncr_reg,r), (val))
451
452/*
453 * Set bit field ON, OFF
454 */
455
456#define OUTONB(r, m) OUTB(r, INB(r) | (m))
457#define OUTOFFB(r, m) OUTB(r, INB(r) & ~(m))
458#define OUTONW(r, m) OUTW(r, INW(r) | (m))
459#define OUTOFFW(r, m) OUTW(r, INW(r) & ~(m))
460#define OUTONL(r, m) OUTL(r, INL(r) | (m))
461#define OUTOFFL(r, m) OUTL(r, INL(r) & ~(m))
462
463/*
464 * We normally want the chip to have a consistent view
465 * of driver internal data structures when we restart it.
466 * Thus these macros.
467 */
468#define OUTL_DSP(v) \
469 do { \
470 MEMORY_BARRIER(); \
471 OUTL (nc_dsp, (v)); \
472 } while (0)
473
474#define OUTONB_STD() \
475 do { \
476 MEMORY_BARRIER(); \
477 OUTONB (nc_dcntl, (STD|NOCOM)); \
478 } while (0)
479
480
481/*
482** NCR53C8XX devices features table.
483*/
484struct ncr_chip {
485 unsigned short revision_id;
486 unsigned char burst_max; /* log-base-2 of max burst */
487 unsigned char offset_max;
488 unsigned char nr_divisor;
489 unsigned int features;
490#define FE_LED0 (1<<0)
491#define FE_WIDE (1<<1) /* Wide data transfers */
492#define FE_ULTRA (1<<2) /* Ultra speed 20Mtrans/sec */
493#define FE_DBLR (1<<4) /* Clock doubler present */
494#define FE_QUAD (1<<5) /* Clock quadrupler present */
495#define FE_ERL (1<<6) /* Enable read line */
496#define FE_CLSE (1<<7) /* Cache line size enable */
497#define FE_WRIE (1<<8) /* Write & Invalidate enable */
498#define FE_ERMP (1<<9) /* Enable read multiple */
499#define FE_BOF (1<<10) /* Burst opcode fetch */
500#define FE_DFS (1<<11) /* DMA fifo size */
501#define FE_PFEN (1<<12) /* Prefetch enable */
502#define FE_LDSTR (1<<13) /* Load/Store supported */
503#define FE_RAM (1<<14) /* On chip RAM present */
504#define FE_VARCLK (1<<15) /* SCSI clock may vary */
505#define FE_RAM8K (1<<16) /* On chip RAM sized 8Kb */
506#define FE_64BIT (1<<17) /* Have a 64-bit PCI interface */
507#define FE_IO256 (1<<18) /* Requires full 256 bytes in PCI space */
508#define FE_NOPM (1<<19) /* Scripts handles phase mismatch */
509#define FE_LEDC (1<<20) /* Hardware control of LED */
510#define FE_DIFF (1<<21) /* Support Differential SCSI */
511#define FE_66MHZ (1<<23) /* 66MHz PCI Support */
512#define FE_DAC (1<<24) /* Support DAC cycles (64 bit addressing) */
513#define FE_ISTAT1 (1<<25) /* Have ISTAT1, MBOX0, MBOX1 registers */
514#define FE_DAC_IN_USE (1<<26) /* Platform does DAC cycles */
515#define FE_EHP (1<<27) /* 720: Even host parity */
516#define FE_MUX (1<<28) /* 720: Multiplexed bus */
517#define FE_EA (1<<29) /* 720: Enable Ack */
518
519#define FE_CACHE_SET (FE_ERL|FE_CLSE|FE_WRIE|FE_ERMP)
520#define FE_SCSI_SET (FE_WIDE|FE_ULTRA|FE_DBLR|FE_QUAD|F_CLK80)
521#define FE_SPECIAL_SET (FE_CACHE_SET|FE_BOF|FE_DFS|FE_LDSTR|FE_PFEN|FE_RAM)
522};
523
524
525/*
526** Driver setup structure.
527**
528** This structure is initialized from linux config options.
529** It can be overridden at boot-up by the boot command line.
530*/
531#define SCSI_NCR_MAX_EXCLUDES 8
532struct ncr_driver_setup {
533 u8 master_parity;
534 u8 scsi_parity;
535 u8 disconnection;
536 u8 special_features;
537 u8 force_sync_nego;
538 u8 reverse_probe;
539 u8 pci_fix_up;
540 u8 use_nvram;
541 u8 verbose;
542 u8 default_tags;
543 u16 default_sync;
544 u16 debug;
545 u8 burst_max;
546 u8 led_pin;
547 u8 max_wide;
548 u8 settle_delay;
549 u8 diff_support;
550 u8 irqm;
551 u8 bus_check;
552 u8 optimize;
553 u8 recovery;
554 u8 host_id;
555 u16 iarb;
556 u32 excludes[SCSI_NCR_MAX_EXCLUDES];
557 char tag_ctrl[100];
558};
559
560/*
561** Initial setup.
562** Can be overriden at startup by a command line.
563*/
564#define SCSI_NCR_DRIVER_SETUP \
565{ \
566 SCSI_NCR_SETUP_MASTER_PARITY, \
567 SCSI_NCR_SETUP_SCSI_PARITY, \
568 SCSI_NCR_SETUP_DISCONNECTION, \
569 SCSI_NCR_SETUP_SPECIAL_FEATURES, \
570 SCSI_NCR_SETUP_FORCE_SYNC_NEGO, \
571 0, \
572 0, \
573 1, \
574 0, \
575 SCSI_NCR_SETUP_DEFAULT_TAGS, \
576 SCSI_NCR_SETUP_DEFAULT_SYNC, \
577 0x00, \
578 7, \
579 0, \
580 1, \
581 SCSI_NCR_SETUP_SETTLE_TIME, \
582 0, \
583 0, \
584 1, \
585 0, \
586 0, \
587 255, \
588 0x00 \
589}
590
591/*
592** Boot fail safe setup.
593** Override initial setup from boot command line:
594** ncr53c8xx=safe:y
595*/
596#define SCSI_NCR_DRIVER_SAFE_SETUP \
597{ \
598 0, \
599 1, \
600 0, \
601 0, \
602 0, \
603 0, \
604 0, \
605 1, \
606 2, \
607 0, \
608 255, \
609 0x00, \
610 255, \
611 0, \
612 0, \
613 10, \
614 1, \
615 1, \
616 1, \
617 0, \
618 0, \
619 255 \
620}
621
622/**************** ORIGINAL CONTENT of ncrreg.h from FreeBSD ******************/
623
624/*-----------------------------------------------------------------
625**
626** The ncr 53c810 register structure.
627**
628**-----------------------------------------------------------------
629*/
630
631struct ncr_reg {
632/*00*/ u8 nc_scntl0; /* full arb., ena parity, par->ATN */
633
634/*01*/ u8 nc_scntl1; /* no reset */
635 #define ISCON 0x10 /* connected to scsi */
636 #define CRST 0x08 /* force reset */
637 #define IARB 0x02 /* immediate arbitration */
638
639/*02*/ u8 nc_scntl2; /* no disconnect expected */
640 #define SDU 0x80 /* cmd: disconnect will raise error */
641 #define CHM 0x40 /* sta: chained mode */
642 #define WSS 0x08 /* sta: wide scsi send [W]*/
643 #define WSR 0x01 /* sta: wide scsi received [W]*/
644
645/*03*/ u8 nc_scntl3; /* cnf system clock dependent */
646 #define EWS 0x08 /* cmd: enable wide scsi [W]*/
647 #define ULTRA 0x80 /* cmd: ULTRA enable */
648 /* bits 0-2, 7 rsvd for C1010 */
649
650/*04*/ u8 nc_scid; /* cnf host adapter scsi address */
651 #define RRE 0x40 /* r/w:e enable response to resel. */
652 #define SRE 0x20 /* r/w:e enable response to select */
653
654/*05*/ u8 nc_sxfer; /* ### Sync speed and count */
655 /* bits 6-7 rsvd for C1010 */
656
657/*06*/ u8 nc_sdid; /* ### Destination-ID */
658
659/*07*/ u8 nc_gpreg; /* ??? IO-Pins */
660
661/*08*/ u8 nc_sfbr; /* ### First byte in phase */
662
663/*09*/ u8 nc_socl;
664 #define CREQ 0x80 /* r/w: SCSI-REQ */
665 #define CACK 0x40 /* r/w: SCSI-ACK */
666 #define CBSY 0x20 /* r/w: SCSI-BSY */
667 #define CSEL 0x10 /* r/w: SCSI-SEL */
668 #define CATN 0x08 /* r/w: SCSI-ATN */
669 #define CMSG 0x04 /* r/w: SCSI-MSG */
670 #define CC_D 0x02 /* r/w: SCSI-C_D */
671 #define CI_O 0x01 /* r/w: SCSI-I_O */
672
673/*0a*/ u8 nc_ssid;
674
675/*0b*/ u8 nc_sbcl;
676
677/*0c*/ u8 nc_dstat;
678 #define DFE 0x80 /* sta: dma fifo empty */
679 #define MDPE 0x40 /* int: master data parity error */
680 #define BF 0x20 /* int: script: bus fault */
681 #define ABRT 0x10 /* int: script: command aborted */
682 #define SSI 0x08 /* int: script: single step */
683 #define SIR 0x04 /* int: script: interrupt instruct. */
684 #define IID 0x01 /* int: script: illegal instruct. */
685
686/*0d*/ u8 nc_sstat0;
687 #define ILF 0x80 /* sta: data in SIDL register lsb */
688 #define ORF 0x40 /* sta: data in SODR register lsb */
689 #define OLF 0x20 /* sta: data in SODL register lsb */
690 #define AIP 0x10 /* sta: arbitration in progress */
691 #define LOA 0x08 /* sta: arbitration lost */
692 #define WOA 0x04 /* sta: arbitration won */
693 #define IRST 0x02 /* sta: scsi reset signal */
694 #define SDP 0x01 /* sta: scsi parity signal */
695
696/*0e*/ u8 nc_sstat1;
697 #define FF3210 0xf0 /* sta: bytes in the scsi fifo */
698
699/*0f*/ u8 nc_sstat2;
700 #define ILF1 0x80 /* sta: data in SIDL register msb[W]*/
701 #define ORF1 0x40 /* sta: data in SODR register msb[W]*/
702 #define OLF1 0x20 /* sta: data in SODL register msb[W]*/
703 #define DM 0x04 /* sta: DIFFSENS mismatch (895/6 only) */
704 #define LDSC 0x02 /* sta: disconnect & reconnect */
705
706/*10*/ u8 nc_dsa; /* --> Base page */
707/*11*/ u8 nc_dsa1;
708/*12*/ u8 nc_dsa2;
709/*13*/ u8 nc_dsa3;
710
711/*14*/ u8 nc_istat; /* --> Main Command and status */
712 #define CABRT 0x80 /* cmd: abort current operation */
713 #define SRST 0x40 /* mod: reset chip */
714 #define SIGP 0x20 /* r/w: message from host to ncr */
715 #define SEM 0x10 /* r/w: message between host + ncr */
716 #define CON 0x08 /* sta: connected to scsi */
717 #define INTF 0x04 /* sta: int on the fly (reset by wr)*/
718 #define SIP 0x02 /* sta: scsi-interrupt */
719 #define DIP 0x01 /* sta: host/script interrupt */
720
721/*15*/ u8 nc_istat1; /* 896 and later cores only */
722 #define FLSH 0x04 /* sta: chip is flushing */
723 #define SRUN 0x02 /* sta: scripts are running */
724 #define SIRQD 0x01 /* r/w: disable INT pin */
725
726/*16*/ u8 nc_mbox0; /* 896 and later cores only */
727/*17*/ u8 nc_mbox1; /* 896 and later cores only */
728
729/*18*/ u8 nc_ctest0;
730 #define EHP 0x04 /* 720 even host parity */
731/*19*/ u8 nc_ctest1;
732
733/*1a*/ u8 nc_ctest2;
734 #define CSIGP 0x40
735 /* bits 0-2,7 rsvd for C1010 */
736
737/*1b*/ u8 nc_ctest3;
738 #define FLF 0x08 /* cmd: flush dma fifo */
739 #define CLF 0x04 /* cmd: clear dma fifo */
740 #define FM 0x02 /* mod: fetch pin mode */
741 #define WRIE 0x01 /* mod: write and invalidate enable */
742 /* bits 4-7 rsvd for C1010 */
743
744/*1c*/ u32 nc_temp; /* ### Temporary stack */
745
746/*20*/ u8 nc_dfifo;
747/*21*/ u8 nc_ctest4;
748 #define MUX 0x80 /* 720 host bus multiplex mode */
749 #define BDIS 0x80 /* mod: burst disable */
750 #define MPEE 0x08 /* mod: master parity error enable */
751
752/*22*/ u8 nc_ctest5;
753 #define DFS 0x20 /* mod: dma fifo size */
754 /* bits 0-1, 3-7 rsvd for C1010 */
755/*23*/ u8 nc_ctest6;
756
757/*24*/ u32 nc_dbc; /* ### Byte count and command */
758/*28*/ u32 nc_dnad; /* ### Next command register */
759/*2c*/ u32 nc_dsp; /* --> Script Pointer */
760/*30*/ u32 nc_dsps; /* --> Script pointer save/opcode#2 */
761
762/*34*/ u8 nc_scratcha; /* Temporary register a */
763/*35*/ u8 nc_scratcha1;
764/*36*/ u8 nc_scratcha2;
765/*37*/ u8 nc_scratcha3;
766
767/*38*/ u8 nc_dmode;
768 #define BL_2 0x80 /* mod: burst length shift value +2 */
769 #define BL_1 0x40 /* mod: burst length shift value +1 */
770 #define ERL 0x08 /* mod: enable read line */
771 #define ERMP 0x04 /* mod: enable read multiple */
772 #define BOF 0x02 /* mod: burst op code fetch */
773
774/*39*/ u8 nc_dien;
775/*3a*/ u8 nc_sbr;
776
777/*3b*/ u8 nc_dcntl; /* --> Script execution control */
778 #define CLSE 0x80 /* mod: cache line size enable */
779 #define PFF 0x40 /* cmd: pre-fetch flush */
780 #define PFEN 0x20 /* mod: pre-fetch enable */
781 #define EA 0x20 /* mod: 720 enable-ack */
782 #define SSM 0x10 /* mod: single step mode */
783 #define IRQM 0x08 /* mod: irq mode (1 = totem pole !) */
784 #define STD 0x04 /* cmd: start dma mode */
785 #define IRQD 0x02 /* mod: irq disable */
786 #define NOCOM 0x01 /* cmd: protect sfbr while reselect */
787 /* bits 0-1 rsvd for C1010 */
788
789/*3c*/ u32 nc_adder;
790
791/*40*/ u16 nc_sien; /* -->: interrupt enable */
792/*42*/ u16 nc_sist; /* <--: interrupt status */
793 #define SBMC 0x1000/* sta: SCSI Bus Mode Change (895/6 only) */
794 #define STO 0x0400/* sta: timeout (select) */
795 #define GEN 0x0200/* sta: timeout (general) */
796 #define HTH 0x0100/* sta: timeout (handshake) */
797 #define MA 0x80 /* sta: phase mismatch */
798 #define CMP 0x40 /* sta: arbitration complete */
799 #define SEL 0x20 /* sta: selected by another device */
800 #define RSL 0x10 /* sta: reselected by another device*/
801 #define SGE 0x08 /* sta: gross error (over/underflow)*/
802 #define UDC 0x04 /* sta: unexpected disconnect */
803 #define RST 0x02 /* sta: scsi bus reset detected */
804 #define PAR 0x01 /* sta: scsi parity error */
805
806/*44*/ u8 nc_slpar;
807/*45*/ u8 nc_swide;
808/*46*/ u8 nc_macntl;
809/*47*/ u8 nc_gpcntl;
810/*48*/ u8 nc_stime0; /* cmd: timeout for select&handshake*/
811/*49*/ u8 nc_stime1; /* cmd: timeout user defined */
812/*4a*/ u16 nc_respid; /* sta: Reselect-IDs */
813
814/*4c*/ u8 nc_stest0;
815
816/*4d*/ u8 nc_stest1;
817 #define SCLK 0x80 /* Use the PCI clock as SCSI clock */
818 #define DBLEN 0x08 /* clock doubler running */
819 #define DBLSEL 0x04 /* clock doubler selected */
820
821
822/*4e*/ u8 nc_stest2;
823 #define ROF 0x40 /* reset scsi offset (after gross error!) */
824 #define DIF 0x20 /* 720 SCSI differential mode */
825 #define EXT 0x02 /* extended filtering */
826
827/*4f*/ u8 nc_stest3;
828 #define TE 0x80 /* c: tolerAnt enable */
829 #define HSC 0x20 /* c: Halt SCSI Clock */
830 #define CSF 0x02 /* c: clear scsi fifo */
831
832/*50*/ u16 nc_sidl; /* Lowlevel: latched from scsi data */
833/*52*/ u8 nc_stest4;
834 #define SMODE 0xc0 /* SCSI bus mode (895/6 only) */
835 #define SMODE_HVD 0x40 /* High Voltage Differential */
836 #define SMODE_SE 0x80 /* Single Ended */
837 #define SMODE_LVD 0xc0 /* Low Voltage Differential */
838 #define LCKFRQ 0x20 /* Frequency Lock (895/6 only) */
839 /* bits 0-5 rsvd for C1010 */
840
841/*53*/ u8 nc_53_;
842/*54*/ u16 nc_sodl; /* Lowlevel: data out to scsi data */
843/*56*/ u8 nc_ccntl0; /* Chip Control 0 (896) */
844 #define ENPMJ 0x80 /* Enable Phase Mismatch Jump */
845 #define PMJCTL 0x40 /* Phase Mismatch Jump Control */
846 #define ENNDJ 0x20 /* Enable Non Data PM Jump */
847 #define DISFC 0x10 /* Disable Auto FIFO Clear */
848 #define DILS 0x02 /* Disable Internal Load/Store */
849 #define DPR 0x01 /* Disable Pipe Req */
850
851/*57*/ u8 nc_ccntl1; /* Chip Control 1 (896) */
852 #define ZMOD 0x80 /* High Impedance Mode */
853 #define DIC 0x10 /* Disable Internal Cycles */
854 #define DDAC 0x08 /* Disable Dual Address Cycle */
855 #define XTIMOD 0x04 /* 64-bit Table Ind. Indexing Mode */
856 #define EXTIBMV 0x02 /* Enable 64-bit Table Ind. BMOV */
857 #define EXDBMV 0x01 /* Enable 64-bit Direct BMOV */
858
859/*58*/ u16 nc_sbdl; /* Lowlevel: data from scsi data */
860/*5a*/ u16 nc_5a_;
861
862/*5c*/ u8 nc_scr0; /* Working register B */
863/*5d*/ u8 nc_scr1; /* */
864/*5e*/ u8 nc_scr2; /* */
865/*5f*/ u8 nc_scr3; /* */
866
867/*60*/ u8 nc_scrx[64]; /* Working register C-R */
868/*a0*/ u32 nc_mmrs; /* Memory Move Read Selector */
869/*a4*/ u32 nc_mmws; /* Memory Move Write Selector */
870/*a8*/ u32 nc_sfs; /* Script Fetch Selector */
871/*ac*/ u32 nc_drs; /* DSA Relative Selector */
872/*b0*/ u32 nc_sbms; /* Static Block Move Selector */
873/*b4*/ u32 nc_dbms; /* Dynamic Block Move Selector */
874/*b8*/ u32 nc_dnad64; /* DMA Next Address 64 */
875/*bc*/ u16 nc_scntl4; /* C1010 only */
876 #define U3EN 0x80 /* Enable Ultra 3 */
877 #define AIPEN 0x40 /* Allow check upper byte lanes */
878 #define XCLKH_DT 0x08 /* Extra clock of data hold on DT
879 transfer edge */
880 #define XCLKH_ST 0x04 /* Extra clock of data hold on ST
881 transfer edge */
882
883/*be*/ u8 nc_aipcntl0; /* Epat Control 1 C1010 only */
884/*bf*/ u8 nc_aipcntl1; /* AIP Control C1010_66 Only */
885
886/*c0*/ u32 nc_pmjad1; /* Phase Mismatch Jump Address 1 */
887/*c4*/ u32 nc_pmjad2; /* Phase Mismatch Jump Address 2 */
888/*c8*/ u8 nc_rbc; /* Remaining Byte Count */
889/*c9*/ u8 nc_rbc1; /* */
890/*ca*/ u8 nc_rbc2; /* */
891/*cb*/ u8 nc_rbc3; /* */
892
893/*cc*/ u8 nc_ua; /* Updated Address */
894/*cd*/ u8 nc_ua1; /* */
895/*ce*/ u8 nc_ua2; /* */
896/*cf*/ u8 nc_ua3; /* */
897/*d0*/ u32 nc_esa; /* Entry Storage Address */
898/*d4*/ u8 nc_ia; /* Instruction Address */
899/*d5*/ u8 nc_ia1;
900/*d6*/ u8 nc_ia2;
901/*d7*/ u8 nc_ia3;
902/*d8*/ u32 nc_sbc; /* SCSI Byte Count (3 bytes only) */
903/*dc*/ u32 nc_csbc; /* Cumulative SCSI Byte Count */
904
905 /* Following for C1010 only */
906/*e0*/ u16 nc_crcpad; /* CRC Value */
907/*e2*/ u8 nc_crccntl0; /* CRC control register */
908 #define SNDCRC 0x10 /* Send CRC Request */
909/*e3*/ u8 nc_crccntl1; /* CRC control register */
910/*e4*/ u32 nc_crcdata; /* CRC data register */
911/*e8*/ u32 nc_e8_; /* rsvd */
912/*ec*/ u32 nc_ec_; /* rsvd */
913/*f0*/ u16 nc_dfbc; /* DMA FIFO byte count */
914
915};
916
917/*-----------------------------------------------------------
918**
919** Utility macros for the script.
920**
921**-----------------------------------------------------------
922*/
923
924#define REGJ(p,r) (offsetof(struct ncr_reg, p ## r))
925#define REG(r) REGJ (nc_, r)
926
927typedef u32 ncrcmd;
928
929/*-----------------------------------------------------------
930**
931** SCSI phases
932**
933** DT phases illegal for ncr driver.
934**
935**-----------------------------------------------------------
936*/
937
938#define SCR_DATA_OUT 0x00000000
939#define SCR_DATA_IN 0x01000000
940#define SCR_COMMAND 0x02000000
941#define SCR_STATUS 0x03000000
942#define SCR_DT_DATA_OUT 0x04000000
943#define SCR_DT_DATA_IN 0x05000000
944#define SCR_MSG_OUT 0x06000000
945#define SCR_MSG_IN 0x07000000
946
947#define SCR_ILG_OUT 0x04000000
948#define SCR_ILG_IN 0x05000000
949
950/*-----------------------------------------------------------
951**
952** Data transfer via SCSI.
953**
954**-----------------------------------------------------------
955**
956** MOVE_ABS (LEN)
957** <<start address>>
958**
959** MOVE_IND (LEN)
960** <<dnad_offset>>
961**
962** MOVE_TBL
963** <<dnad_offset>>
964**
965**-----------------------------------------------------------
966*/
967
968#define OPC_MOVE 0x08000000
969
970#define SCR_MOVE_ABS(l) ((0x00000000 | OPC_MOVE) | (l))
971#define SCR_MOVE_IND(l) ((0x20000000 | OPC_MOVE) | (l))
972#define SCR_MOVE_TBL (0x10000000 | OPC_MOVE)
973
974#define SCR_CHMOV_ABS(l) ((0x00000000) | (l))
975#define SCR_CHMOV_IND(l) ((0x20000000) | (l))
976#define SCR_CHMOV_TBL (0x10000000)
977
978struct scr_tblmove {
979 u32 size;
980 u32 addr;
981};
982
983/*-----------------------------------------------------------
984**
985** Selection
986**
987**-----------------------------------------------------------
988**
989** SEL_ABS | SCR_ID (0..15) [ | REL_JMP]
990** <<alternate_address>>
991**
992** SEL_TBL | << dnad_offset>> [ | REL_JMP]
993** <<alternate_address>>
994**
995**-----------------------------------------------------------
996*/
997
998#define SCR_SEL_ABS 0x40000000
999#define SCR_SEL_ABS_ATN 0x41000000
1000#define SCR_SEL_TBL 0x42000000
1001#define SCR_SEL_TBL_ATN 0x43000000
1002
1003
1004#ifdef SCSI_NCR_BIG_ENDIAN
1005struct scr_tblsel {
1006 u8 sel_scntl3;
1007 u8 sel_id;
1008 u8 sel_sxfer;
1009 u8 sel_scntl4;
1010};
1011#else
1012struct scr_tblsel {
1013 u8 sel_scntl4;
1014 u8 sel_sxfer;
1015 u8 sel_id;
1016 u8 sel_scntl3;
1017};
1018#endif
1019
1020#define SCR_JMP_REL 0x04000000
1021#define SCR_ID(id) (((u32)(id)) << 16)
1022
1023/*-----------------------------------------------------------
1024**
1025** Waiting for Disconnect or Reselect
1026**
1027**-----------------------------------------------------------
1028**
1029** WAIT_DISC
1030** dummy: <<alternate_address>>
1031**
1032** WAIT_RESEL
1033** <<alternate_address>>
1034**
1035**-----------------------------------------------------------
1036*/
1037
1038#define SCR_WAIT_DISC 0x48000000
1039#define SCR_WAIT_RESEL 0x50000000
1040
1041/*-----------------------------------------------------------
1042**
1043** Bit Set / Reset
1044**
1045**-----------------------------------------------------------
1046**
1047** SET (flags {|.. })
1048**
1049** CLR (flags {|.. })
1050**
1051**-----------------------------------------------------------
1052*/
1053
1054#define SCR_SET(f) (0x58000000 | (f))
1055#define SCR_CLR(f) (0x60000000 | (f))
1056
1057#define SCR_CARRY 0x00000400
1058#define SCR_TRG 0x00000200
1059#define SCR_ACK 0x00000040
1060#define SCR_ATN 0x00000008
1061
1062
1063
1064
1065/*-----------------------------------------------------------
1066**
1067** Memory to memory move
1068**
1069**-----------------------------------------------------------
1070**
1071** COPY (bytecount)
1072** << source_address >>
1073** << destination_address >>
1074**
1075** SCR_COPY sets the NO FLUSH option by default.
1076** SCR_COPY_F does not set this option.
1077**
1078** For chips which do not support this option,
1079** ncr_copy_and_bind() will remove this bit.
1080**-----------------------------------------------------------
1081*/
1082
1083#define SCR_NO_FLUSH 0x01000000
1084
1085#define SCR_COPY(n) (0xc0000000 | SCR_NO_FLUSH | (n))
1086#define SCR_COPY_F(n) (0xc0000000 | (n))
1087
1088/*-----------------------------------------------------------
1089**
1090** Register move and binary operations
1091**
1092**-----------------------------------------------------------
1093**
1094** SFBR_REG (reg, op, data) reg = SFBR op data
1095** << 0 >>
1096**
1097** REG_SFBR (reg, op, data) SFBR = reg op data
1098** << 0 >>
1099**
1100** REG_REG (reg, op, data) reg = reg op data
1101** << 0 >>
1102**
1103**-----------------------------------------------------------
1104** On 810A, 860, 825A, 875, 895 and 896 chips the content
1105** of SFBR register can be used as data (SCR_SFBR_DATA).
1106** The 896 has additionnal IO registers starting at
1107** offset 0x80. Bit 7 of register offset is stored in
1108** bit 7 of the SCRIPTS instruction first DWORD.
1109**-----------------------------------------------------------
1110*/
1111
1112#define SCR_REG_OFS(ofs) ((((ofs) & 0x7f) << 16ul) + ((ofs) & 0x80))
1113
1114#define SCR_SFBR_REG(reg,op,data) \
1115 (0x68000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1116
1117#define SCR_REG_SFBR(reg,op,data) \
1118 (0x70000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1119
1120#define SCR_REG_REG(reg,op,data) \
1121 (0x78000000 | (SCR_REG_OFS(REG(reg))) | (op) | (((data)&0xff)<<8ul))
1122
1123
1124#define SCR_LOAD 0x00000000
1125#define SCR_SHL 0x01000000
1126#define SCR_OR 0x02000000
1127#define SCR_XOR 0x03000000
1128#define SCR_AND 0x04000000
1129#define SCR_SHR 0x05000000
1130#define SCR_ADD 0x06000000
1131#define SCR_ADDC 0x07000000
1132
1133#define SCR_SFBR_DATA (0x00800000>>8ul) /* Use SFBR as data */
1134
1135/*-----------------------------------------------------------
1136**
1137** FROM_REG (reg) SFBR = reg
1138** << 0 >>
1139**
1140** TO_REG (reg) reg = SFBR
1141** << 0 >>
1142**
1143** LOAD_REG (reg, data) reg = <data>
1144** << 0 >>
1145**
1146** LOAD_SFBR(data) SFBR = <data>
1147** << 0 >>
1148**
1149**-----------------------------------------------------------
1150*/
1151
1152#define SCR_FROM_REG(reg) \
1153 SCR_REG_SFBR(reg,SCR_OR,0)
1154
1155#define SCR_TO_REG(reg) \
1156 SCR_SFBR_REG(reg,SCR_OR,0)
1157
1158#define SCR_LOAD_REG(reg,data) \
1159 SCR_REG_REG(reg,SCR_LOAD,data)
1160
1161#define SCR_LOAD_SFBR(data) \
1162 (SCR_REG_SFBR (gpreg, SCR_LOAD, data))
1163
1164/*-----------------------------------------------------------
1165**
1166** LOAD from memory to register.
1167** STORE from register to memory.
1168**
1169** Only supported by 810A, 860, 825A, 875, 895 and 896.
1170**
1171**-----------------------------------------------------------
1172**
1173** LOAD_ABS (LEN)
1174** <<start address>>
1175**
1176** LOAD_REL (LEN) (DSA relative)
1177** <<dsa_offset>>
1178**
1179**-----------------------------------------------------------
1180*/
1181
1182#define SCR_REG_OFS2(ofs) (((ofs) & 0xff) << 16ul)
1183#define SCR_NO_FLUSH2 0x02000000
1184#define SCR_DSA_REL2 0x10000000
1185
1186#define SCR_LOAD_R(reg, how, n) \
1187 (0xe1000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1188
1189#define SCR_STORE_R(reg, how, n) \
1190 (0xe0000000 | how | (SCR_REG_OFS2(REG(reg))) | (n))
1191
1192#define SCR_LOAD_ABS(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2, n)
1193#define SCR_LOAD_REL(reg, n) SCR_LOAD_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2, n)
1194#define SCR_LOAD_ABS_F(reg, n) SCR_LOAD_R(reg, 0, n)
1195#define SCR_LOAD_REL_F(reg, n) SCR_LOAD_R(reg, SCR_DSA_REL2, n)
1196
1197#define SCR_STORE_ABS(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2, n)
1198#define SCR_STORE_REL(reg, n) SCR_STORE_R(reg, SCR_NO_FLUSH2|SCR_DSA_REL2,n)
1199#define SCR_STORE_ABS_F(reg, n) SCR_STORE_R(reg, 0, n)
1200#define SCR_STORE_REL_F(reg, n) SCR_STORE_R(reg, SCR_DSA_REL2, n)
1201
1202
1203/*-----------------------------------------------------------
1204**
1205** Waiting for Disconnect or Reselect
1206**
1207**-----------------------------------------------------------
1208**
1209** JUMP [ | IFTRUE/IFFALSE ( ... ) ]
1210** <<address>>
1211**
1212** JUMPR [ | IFTRUE/IFFALSE ( ... ) ]
1213** <<distance>>
1214**
1215** CALL [ | IFTRUE/IFFALSE ( ... ) ]
1216** <<address>>
1217**
1218** CALLR [ | IFTRUE/IFFALSE ( ... ) ]
1219** <<distance>>
1220**
1221** RETURN [ | IFTRUE/IFFALSE ( ... ) ]
1222** <<dummy>>
1223**
1224** INT [ | IFTRUE/IFFALSE ( ... ) ]
1225** <<ident>>
1226**
1227** INT_FLY [ | IFTRUE/IFFALSE ( ... ) ]
1228** <<ident>>
1229**
1230** Conditions:
1231** WHEN (phase)
1232** IF (phase)
1233** CARRYSET
1234** DATA (data, mask)
1235**
1236**-----------------------------------------------------------
1237*/
1238
1239#define SCR_NO_OP 0x80000000
1240#define SCR_JUMP 0x80080000
1241#define SCR_JUMP64 0x80480000
1242#define SCR_JUMPR 0x80880000
1243#define SCR_CALL 0x88080000
1244#define SCR_CALLR 0x88880000
1245#define SCR_RETURN 0x90080000
1246#define SCR_INT 0x98080000
1247#define SCR_INT_FLY 0x98180000
1248
1249#define IFFALSE(arg) (0x00080000 | (arg))
1250#define IFTRUE(arg) (0x00000000 | (arg))
1251
1252#define WHEN(phase) (0x00030000 | (phase))
1253#define IF(phase) (0x00020000 | (phase))
1254
1255#define DATA(D) (0x00040000 | ((D) & 0xff))
1256#define MASK(D,M) (0x00040000 | (((M ^ 0xff) & 0xff) << 8ul)|((D) & 0xff))
1257
1258#define CARRYSET (0x00200000)
1259
1260/*-----------------------------------------------------------
1261**
1262** SCSI constants.
1263**
1264**-----------------------------------------------------------
1265*/
1266
1267/*
1268** Messages
1269*/
1270
1271#define M_COMPLETE COMMAND_COMPLETE
1272#define M_EXTENDED EXTENDED_MESSAGE
1273#define M_SAVE_DP SAVE_POINTERS
1274#define M_RESTORE_DP RESTORE_POINTERS
1275#define M_DISCONNECT DISCONNECT
1276#define M_ID_ERROR INITIATOR_ERROR
1277#define M_ABORT ABORT_TASK_SET
1278#define M_REJECT MESSAGE_REJECT
1279#define M_NOOP NOP
1280#define M_PARITY MSG_PARITY_ERROR
1281#define M_LCOMPLETE LINKED_CMD_COMPLETE
1282#define M_FCOMPLETE LINKED_FLG_CMD_COMPLETE
1283#define M_RESET TARGET_RESET
1284#define M_ABORT_TAG ABORT_TASK
1285#define M_CLEAR_QUEUE CLEAR_TASK_SET
1286#define M_INIT_REC INITIATE_RECOVERY
1287#define M_REL_REC RELEASE_RECOVERY
1288#define M_TERMINATE (0x11)
1289#define M_SIMPLE_TAG SIMPLE_QUEUE_TAG
1290#define M_HEAD_TAG HEAD_OF_QUEUE_TAG
1291#define M_ORDERED_TAG ORDERED_QUEUE_TAG
1292#define M_IGN_RESIDUE IGNORE_WIDE_RESIDUE
1293#define M_IDENTIFY (0x80)
1294
1295#define M_X_MODIFY_DP EXTENDED_MODIFY_DATA_POINTER
1296#define M_X_SYNC_REQ EXTENDED_SDTR
1297#define M_X_WIDE_REQ EXTENDED_WDTR
1298#define M_X_PPR_REQ EXTENDED_PPR
1299
1300/*
1301** Status
1302*/
1303
1304#define S_GOOD (0x00)
1305#define S_CHECK_COND (0x02)
1306#define S_COND_MET (0x04)
1307#define S_BUSY (0x08)
1308#define S_INT (0x10)
1309#define S_INT_COND_MET (0x14)
1310#define S_CONFLICT (0x18)
1311#define S_TERMINATED (0x20)
1312#define S_QUEUE_FULL (0x28)
1313#define S_ILLEGAL (0xff)
1314#define S_SENSE (0x80)
1315
1316/*
1317 * End of ncrreg from FreeBSD
1318 */
1319
1320#endif /* defined SYM53C8XX_DEFS_H */
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 8d92adfbb8bd..8adca0ce267f 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -516,7 +516,7 @@ pci_timedia_setup(struct serial_private *priv, struct pciserial_board *board,
516 break; 516 break;
517 case 3: 517 case 3:
518 offset = board->uart_offset; 518 offset = board->uart_offset;
519 bar = 1; 519 /* FALLTHROUGH */
520 case 4: /* BAR 2 */ 520 case 4: /* BAR 2 */
521 case 5: /* BAR 3 */ 521 case 5: /* BAR 3 */
522 case 6: /* BAR 4 */ 522 case 6: /* BAR 4 */
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index ad47c1b84c3f..812bae62c8ec 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -10,7 +10,7 @@ menu "Serial drivers"
10# The new 8250/16550 serial drivers 10# The new 8250/16550 serial drivers
11config SERIAL_8250 11config SERIAL_8250
12 tristate "8250/16550 and compatible serial support" 12 tristate "8250/16550 and compatible serial support"
13 depends on (BROKEN || !(SPARC64 || SPARC32)) 13 depends on (BROKEN || !SPARC)
14 select SERIAL_CORE 14 select SERIAL_CORE
15 ---help--- 15 ---help---
16 This selects whether you want to include the driver for the standard 16 This selects whether you want to include the driver for the standard
@@ -469,14 +469,14 @@ config SERIAL_IMX_CONSOLE
469 469
470config SERIAL_SUNCORE 470config SERIAL_SUNCORE
471 bool 471 bool
472 depends on SPARC32 || SPARC64 472 depends on SPARC
473 select SERIAL_CORE 473 select SERIAL_CORE
474 select SERIAL_CORE_CONSOLE 474 select SERIAL_CORE_CONSOLE
475 default y 475 default y
476 476
477config SERIAL_SUNZILOG 477config SERIAL_SUNZILOG
478 tristate "Sun Zilog8530 serial support" 478 tristate "Sun Zilog8530 serial support"
479 depends on SPARC32 || SPARC64 479 depends on SPARC
480 help 480 help
481 This driver supports the Zilog8530 serial ports found on many Sparc 481 This driver supports the Zilog8530 serial ports found on many Sparc
482 systems. Say Y or M if you want to be able to these serial ports. 482 systems. Say Y or M if you want to be able to these serial ports.
@@ -491,7 +491,7 @@ config SERIAL_SUNZILOG_CONSOLE
491 491
492config SERIAL_SUNSU 492config SERIAL_SUNSU
493 tristate "Sun SU serial support" 493 tristate "Sun SU serial support"
494 depends on (SPARC32 || SPARC64) && PCI 494 depends on SPARC && PCI
495 help 495 help
496 This driver supports the 8250 serial ports that run the keyboard and 496 This driver supports the 8250 serial ports that run the keyboard and
497 mouse on (PCI) UltraSPARC systems. Say Y or M if you want to be able 497 mouse on (PCI) UltraSPARC systems. Say Y or M if you want to be able
@@ -547,7 +547,7 @@ config PDC_CONSOLE
547 547
548config SERIAL_SUNSAB 548config SERIAL_SUNSAB
549 tristate "Sun Siemens SAB82532 serial support" 549 tristate "Sun Siemens SAB82532 serial support"
550 depends on (SPARC32 || SPARC64) && PCI 550 depends on SPARC && PCI
551 help 551 help
552 This driver supports the Siemens SAB82532 DUSCC serial ports on newer 552 This driver supports the Siemens SAB82532 DUSCC serial ports on newer
553 (PCI) UltraSPARC systems. Say Y or M if you want to be able to these 553 (PCI) UltraSPARC systems. Say Y or M if you want to be able to these
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 89d7bd3eaee3..d84476ee6592 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -160,7 +160,7 @@ pl011_rx_chars(struct uart_amba_port *uap)
160 flag = TTY_FRAME; 160 flag = TTY_FRAME;
161 } 161 }
162 162
163 if (uart_handle_sysrq_char(&uap->port, ch, regs)) 163 if (uart_handle_sysrq_char(&uap->port, ch & 255, regs))
164 goto ignore_char; 164 goto ignore_char;
165 165
166 uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag); 166 uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index b8727d9bf690..1288d6203e94 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -37,11 +37,11 @@
37 * by the bootloader or in the platform init code. 37 * by the bootloader or in the platform init code.
38 * 38 *
39 * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2, 39 * The idx field must be equal to the PSC index ( e.g. 0 for PSC1, 1 for PSC2,
40 * and so on). So the PSC1 is mapped to /dev/ttyS0, PSC2 to /dev/ttyS1 and so 40 * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and
41 * on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly for 41 * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly
42 * the console code : without this 1:1 mapping, at early boot time, when we are 42 * fpr the console code : without this 1:1 mapping, at early boot time, when we
43 * parsing the kernel args console=ttyS?, we wouldn't know wich PSC it will be 43 * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it
44 * mapped to. 44 * will be mapped to.
45 */ 45 */
46 46
47#include <linux/config.h> 47#include <linux/config.h>
@@ -65,6 +65,10 @@
65#include <linux/serial_core.h> 65#include <linux/serial_core.h>
66 66
67 67
68/* We've been assigned a range on the "Low-density serial ports" major */
69#define SERIAL_PSC_MAJOR 204
70#define SERIAL_PSC_MINOR 148
71
68 72
69#define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */ 73#define ISR_PASS_LIMIT 256 /* Max number of iteration in the interrupt */
70 74
@@ -668,15 +672,15 @@ mpc52xx_console_setup(struct console *co, char *options)
668} 672}
669 673
670 674
671extern struct uart_driver mpc52xx_uart_driver; 675static struct uart_driver mpc52xx_uart_driver;
672 676
673static struct console mpc52xx_console = { 677static struct console mpc52xx_console = {
674 .name = "ttyS", 678 .name = "ttyPSC",
675 .write = mpc52xx_console_write, 679 .write = mpc52xx_console_write,
676 .device = uart_console_device, 680 .device = uart_console_device,
677 .setup = mpc52xx_console_setup, 681 .setup = mpc52xx_console_setup,
678 .flags = CON_PRINTBUFFER, 682 .flags = CON_PRINTBUFFER,
679 .index = -1, /* Specified on the cmdline (e.g. console=ttyS0 ) */ 683 .index = -1, /* Specified on the cmdline (e.g. console=ttyPSC0 ) */
680 .data = &mpc52xx_uart_driver, 684 .data = &mpc52xx_uart_driver,
681}; 685};
682 686
@@ -703,10 +707,10 @@ console_initcall(mpc52xx_console_init);
703static struct uart_driver mpc52xx_uart_driver = { 707static struct uart_driver mpc52xx_uart_driver = {
704 .owner = THIS_MODULE, 708 .owner = THIS_MODULE,
705 .driver_name = "mpc52xx_psc_uart", 709 .driver_name = "mpc52xx_psc_uart",
706 .dev_name = "ttyS", 710 .dev_name = "ttyPSC",
707 .devfs_name = "ttyS", 711 .devfs_name = "ttyPSC",
708 .major = TTY_MAJOR, 712 .major = SERIAL_PSC_MAJOR,
709 .minor = 64, 713 .minor = SERIAL_PSC_MINOR,
710 .nr = MPC52xx_PSC_MAXNUM, 714 .nr = MPC52xx_PSC_MAXNUM,
711 .cons = MPC52xx_PSC_CONSOLE, 715 .cons = MPC52xx_PSC_CONSOLE,
712}; 716};
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index ff5e6309d682..cc998b99a19f 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -361,7 +361,7 @@ static int serial_pxa_startup(struct uart_port *port)
361 if (port->line == 3) /* HWUART */ 361 if (port->line == 3) /* HWUART */
362 up->mcr |= UART_MCR_AFE; 362 up->mcr |= UART_MCR_AFE;
363 else 363 else
364 up->mcr = 0; 364 up->mcr = 0;
365 365
366 /* 366 /*
367 * Allocate the IRQ 367 * Allocate the IRQ
@@ -641,7 +641,7 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
641 int i; 641 int i;
642 642
643 /* 643 /*
644 * First save the UER then disable the interrupts 644 * First save the IER then disable the interrupts
645 */ 645 */
646 ier = serial_in(up, UART_IER); 646 ier = serial_in(up, UART_IER);
647 serial_out(up, UART_IER, UART_IER_UUE); 647 serial_out(up, UART_IER, UART_IER_UUE);
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 7ce0c7e66d37..96969cb960a9 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -114,15 +114,7 @@ struct serial_cfg_mem {
114 114
115 115
116static void serial_config(dev_link_t * link); 116static void serial_config(dev_link_t * link);
117static int serial_event(event_t event, int priority,
118 event_callback_args_t * args);
119 117
120static dev_info_t dev_info = "serial_cs";
121
122static dev_link_t *serial_attach(void);
123static void serial_detach(dev_link_t *);
124
125static dev_link_t *dev_list = NULL;
126 118
127/*====================================================================== 119/*======================================================================
128 120
@@ -159,8 +151,9 @@ static void serial_remove(dev_link_t *link)
159 } 151 }
160} 152}
161 153
162static void serial_suspend(dev_link_t *link) 154static int serial_suspend(struct pcmcia_device *dev)
163{ 155{
156 dev_link_t *link = dev_to_instance(dev);
164 link->state |= DEV_SUSPEND; 157 link->state |= DEV_SUSPEND;
165 158
166 if (link->state & DEV_CONFIG) { 159 if (link->state & DEV_CONFIG) {
@@ -173,10 +166,13 @@ static void serial_suspend(dev_link_t *link)
173 if (!info->slave) 166 if (!info->slave)
174 pcmcia_release_configuration(link->handle); 167 pcmcia_release_configuration(link->handle);
175 } 168 }
169
170 return 0;
176} 171}
177 172
178static void serial_resume(dev_link_t *link) 173static int serial_resume(struct pcmcia_device *dev)
179{ 174{
175 dev_link_t *link = dev_to_instance(dev);
180 link->state &= ~DEV_SUSPEND; 176 link->state &= ~DEV_SUSPEND;
181 177
182 if (DEV_OK(link)) { 178 if (DEV_OK(link)) {
@@ -189,6 +185,8 @@ static void serial_resume(dev_link_t *link)
189 for (i = 0; i < info->ndev; i++) 185 for (i = 0; i < info->ndev; i++)
190 serial8250_resume_port(info->line[i]); 186 serial8250_resume_port(info->line[i]);
191 } 187 }
188
189 return 0;
192} 190}
193 191
194/*====================================================================== 192/*======================================================================
@@ -199,19 +197,17 @@ static void serial_resume(dev_link_t *link)
199 197
200======================================================================*/ 198======================================================================*/
201 199
202static dev_link_t *serial_attach(void) 200static int serial_probe(struct pcmcia_device *p_dev)
203{ 201{
204 struct serial_info *info; 202 struct serial_info *info;
205 client_reg_t client_reg;
206 dev_link_t *link; 203 dev_link_t *link;
207 int ret;
208 204
209 DEBUG(0, "serial_attach()\n"); 205 DEBUG(0, "serial_attach()\n");
210 206
211 /* Create new serial device */ 207 /* Create new serial device */
212 info = kmalloc(sizeof (*info), GFP_KERNEL); 208 info = kmalloc(sizeof (*info), GFP_KERNEL);
213 if (!info) 209 if (!info)
214 return NULL; 210 return -ENOMEM;
215 memset(info, 0, sizeof (*info)); 211 memset(info, 0, sizeof (*info));
216 link = &info->link; 212 link = &info->link;
217 link->priv = info; 213 link->priv = info;
@@ -227,20 +223,12 @@ static dev_link_t *serial_attach(void)
227 } 223 }
228 link->conf.IntType = INT_MEMORY_AND_IO; 224 link->conf.IntType = INT_MEMORY_AND_IO;
229 225
230 /* Register with Card Services */ 226 link->handle = p_dev;
231 link->next = dev_list; 227 p_dev->instance = link;
232 dev_list = link; 228 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
233 client_reg.dev_info = &dev_info; 229 serial_config(link);
234 client_reg.Version = 0x0210;
235 client_reg.event_callback_args.client_data = link;
236 ret = pcmcia_register_client(&link->handle, &client_reg);
237 if (ret != CS_SUCCESS) {
238 cs_error(link->handle, RegisterClient, ret);
239 serial_detach(link);
240 return NULL;
241 }
242 230
243 return link; 231 return 0;
244} 232}
245 233
246/*====================================================================== 234/*======================================================================
@@ -252,21 +240,13 @@ static dev_link_t *serial_attach(void)
252 240
253======================================================================*/ 241======================================================================*/
254 242
255static void serial_detach(dev_link_t * link) 243static void serial_detach(struct pcmcia_device *p_dev)
256{ 244{
245 dev_link_t *link = dev_to_instance(p_dev);
257 struct serial_info *info = link->priv; 246 struct serial_info *info = link->priv;
258 dev_link_t **linkp;
259 int ret;
260 247
261 DEBUG(0, "serial_detach(0x%p)\n", link); 248 DEBUG(0, "serial_detach(0x%p)\n", link);
262 249
263 /* Locate device structure */
264 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next)
265 if (*linkp == link)
266 break;
267 if (*linkp == NULL)
268 return;
269
270 /* 250 /*
271 * Ensure any outstanding scheduled tasks are completed. 251 * Ensure any outstanding scheduled tasks are completed.
272 */ 252 */
@@ -277,14 +257,7 @@ static void serial_detach(dev_link_t * link)
277 */ 257 */
278 serial_remove(link); 258 serial_remove(link);
279 259
280 if (link->handle) { 260 /* free bits */
281 ret = pcmcia_deregister_client(link->handle);
282 if (ret != CS_SUCCESS)
283 cs_error(link->handle, DeregisterClient, ret);
284 }
285
286 /* Unlink device structure, free bits */
287 *linkp = link->next;
288 kfree(info); 261 kfree(info);
289} 262}
290 263
@@ -718,54 +691,6 @@ void serial_config(dev_link_t * link)
718 kfree(cfg_mem); 691 kfree(cfg_mem);
719} 692}
720 693
721/*======================================================================
722
723 The card status event handler. Mostly, this schedules other
724 stuff to run after an event is received. A CARD_REMOVAL event
725 also sets some flags to discourage the serial drivers from
726 talking to the ports.
727
728======================================================================*/
729
730static int
731serial_event(event_t event, int priority, event_callback_args_t * args)
732{
733 dev_link_t *link = args->client_data;
734 struct serial_info *info = link->priv;
735
736 DEBUG(1, "serial_event(0x%06x)\n", event);
737
738 switch (event) {
739 case CS_EVENT_CARD_REMOVAL:
740 serial_remove(link);
741 break;
742
743 case CS_EVENT_CARD_INSERTION:
744 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
745 serial_config(link);
746 break;
747
748 case CS_EVENT_PM_SUSPEND:
749 serial_suspend(link);
750 break;
751
752 case CS_EVENT_RESET_PHYSICAL:
753 if ((link->state & DEV_CONFIG) && !info->slave)
754 pcmcia_release_configuration(link->handle);
755 break;
756
757 case CS_EVENT_PM_RESUME:
758 serial_resume(link);
759 break;
760
761 case CS_EVENT_CARD_RESET:
762 if (DEV_OK(link) && !info->slave)
763 pcmcia_request_configuration(link->handle, &link->conf);
764 break;
765 }
766 return 0;
767}
768
769static struct pcmcia_device_id serial_ids[] = { 694static struct pcmcia_device_id serial_ids[] = {
770 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021), 695 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0057, 0x0021),
771 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a), 696 PCMCIA_PFC_DEVICE_MANF_CARD(1, 0x0089, 0x110a),
@@ -877,10 +802,11 @@ static struct pcmcia_driver serial_cs_driver = {
877 .drv = { 802 .drv = {
878 .name = "serial_cs", 803 .name = "serial_cs",
879 }, 804 },
880 .attach = serial_attach, 805 .probe = serial_probe,
881 .event = serial_event, 806 .remove = serial_detach,
882 .detach = serial_detach,
883 .id_table = serial_ids, 807 .id_table = serial_ids,
808 .suspend = serial_suspend,
809 .resume = serial_resume,
884}; 810};
885 811
886static int __init init_serial_cs(void) 812static int __init init_serial_cs(void)
@@ -891,7 +817,6 @@ static int __init init_serial_cs(void)
891static void __exit exit_serial_cs(void) 817static void __exit exit_serial_cs(void)
892{ 818{
893 pcmcia_unregister_driver(&serial_cs_driver); 819 pcmcia_unregister_driver(&serial_cs_driver);
894 BUG_ON(dev_list != NULL);
895} 820}
896 821
897module_init(init_serial_cs); 822module_init(init_serial_cs);
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index 57c0c6e3fbed..d3a7b0c3d38b 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -34,24 +34,19 @@ typedef struct ixj_info_t {
34 struct ixj *port; 34 struct ixj *port;
35} ixj_info_t; 35} ixj_info_t;
36 36
37static dev_link_t *ixj_attach(void); 37static void ixj_detach(struct pcmcia_device *p_dev);
38static void ixj_detach(dev_link_t *);
39static void ixj_config(dev_link_t * link); 38static void ixj_config(dev_link_t * link);
40static void ixj_cs_release(dev_link_t * link); 39static void ixj_cs_release(dev_link_t * link);
41static int ixj_event(event_t event, int priority, event_callback_args_t * args);
42static dev_info_t dev_info = "ixj_cs";
43static dev_link_t *dev_list = NULL;
44 40
45static dev_link_t *ixj_attach(void) 41static int ixj_attach(struct pcmcia_device *p_dev)
46{ 42{
47 client_reg_t client_reg;
48 dev_link_t *link; 43 dev_link_t *link;
49 int ret; 44
50 DEBUG(0, "ixj_attach()\n"); 45 DEBUG(0, "ixj_attach()\n");
51 /* Create new ixj device */ 46 /* Create new ixj device */
52 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL); 47 link = kmalloc(sizeof(struct dev_link_t), GFP_KERNEL);
53 if (!link) 48 if (!link)
54 return NULL; 49 return -ENOMEM;
55 memset(link, 0, sizeof(struct dev_link_t)); 50 memset(link, 0, sizeof(struct dev_link_t));
56 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 51 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
57 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8; 52 link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
@@ -61,44 +56,29 @@ static dev_link_t *ixj_attach(void)
61 link->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL); 56 link->priv = kmalloc(sizeof(struct ixj_info_t), GFP_KERNEL);
62 if (!link->priv) { 57 if (!link->priv) {
63 kfree(link); 58 kfree(link);
64 return NULL; 59 return -ENOMEM;
65 } 60 }
66 memset(link->priv, 0, sizeof(struct ixj_info_t)); 61 memset(link->priv, 0, sizeof(struct ixj_info_t));
67 /* Register with Card Services */ 62
68 link->next = dev_list; 63 link->handle = p_dev;
69 dev_list = link; 64 p_dev->instance = link;
70 client_reg.dev_info = &dev_info; 65
71 client_reg.Version = 0x0210; 66 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
72 client_reg.event_callback_args.client_data = link; 67 ixj_config(link);
73 ret = pcmcia_register_client(&link->handle, &client_reg); 68
74 if (ret != CS_SUCCESS) { 69 return 0;
75 cs_error(link->handle, RegisterClient, ret);
76 ixj_detach(link);
77 return NULL;
78 }
79 return link;
80} 70}
81 71
82static void ixj_detach(dev_link_t * link) 72static void ixj_detach(struct pcmcia_device *p_dev)
83{ 73{
84 dev_link_t **linkp; 74 dev_link_t *link = dev_to_instance(p_dev);
85 int ret; 75
86 DEBUG(0, "ixj_detach(0x%p)\n", link); 76 DEBUG(0, "ixj_detach(0x%p)\n", link);
87 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) 77
88 if (*linkp == link)
89 break;
90 if (*linkp == NULL)
91 return;
92 link->state &= ~DEV_RELEASE_PENDING; 78 link->state &= ~DEV_RELEASE_PENDING;
93 if (link->state & DEV_CONFIG) 79 if (link->state & DEV_CONFIG)
94 ixj_cs_release(link); 80 ixj_cs_release(link);
95 if (link->handle) { 81
96 ret = pcmcia_deregister_client(link->handle);
97 if (ret != CS_SUCCESS)
98 cs_error(link->handle, DeregisterClient, ret);
99 }
100 /* Unlink device structure, free bits */
101 *linkp = link->next;
102 kfree(link->priv); 82 kfree(link->priv);
103 kfree(link); 83 kfree(link);
104} 84}
@@ -255,37 +235,25 @@ static void ixj_cs_release(dev_link_t *link)
255 link->state &= ~DEV_CONFIG; 235 link->state &= ~DEV_CONFIG;
256} 236}
257 237
258static int ixj_event(event_t event, int priority, event_callback_args_t * args) 238static int ixj_suspend(struct pcmcia_device *dev)
259{ 239{
260 dev_link_t *link = args->client_data; 240 dev_link_t *link = dev_to_instance(dev);
261 DEBUG(1, "ixj_event(0x%06x)\n", event); 241
262 switch (event) { 242 link->state |= DEV_SUSPEND;
263 case CS_EVENT_CARD_REMOVAL: 243 if (link->state & DEV_CONFIG)
264 link->state &= ~DEV_PRESENT; 244 pcmcia_release_configuration(link->handle);
265 if (link->state & DEV_CONFIG) { 245
266 link->state |= DEV_RELEASE_PENDING; 246 return 0;
267 ixj_cs_release(link); 247}
268 } 248
269 break; 249static int ixj_resume(struct pcmcia_device *dev)
270 case CS_EVENT_CARD_INSERTION: 250{
271 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 251 dev_link_t *link = dev_to_instance(dev);
272 ixj_config(link); 252
273 break; 253 link->state &= ~DEV_SUSPEND;
274 case CS_EVENT_PM_SUSPEND: 254 if (DEV_OK(link))
275 link->state |= DEV_SUSPEND; 255 pcmcia_request_configuration(link->handle, &link->conf);
276 /* Fall through... */ 256
277 case CS_EVENT_RESET_PHYSICAL:
278 if (link->state & DEV_CONFIG)
279 pcmcia_release_configuration(link->handle);
280 break;
281 case CS_EVENT_PM_RESUME:
282 link->state &= ~DEV_SUSPEND;
283 /* Fall through... */
284 case CS_EVENT_CARD_RESET:
285 if (DEV_OK(link))
286 pcmcia_request_configuration(link->handle, &link->conf);
287 break;
288 }
289 return 0; 257 return 0;
290} 258}
291 259
@@ -300,10 +268,11 @@ static struct pcmcia_driver ixj_driver = {
300 .drv = { 268 .drv = {
301 .name = "ixj_cs", 269 .name = "ixj_cs",
302 }, 270 },
303 .attach = ixj_attach, 271 .probe = ixj_attach,
304 .event = ixj_event, 272 .remove = ixj_detach,
305 .detach = ixj_detach,
306 .id_table = ixj_ids, 273 .id_table = ixj_ids,
274 .suspend = ixj_suspend,
275 .resume = ixj_resume,
307}; 276};
308 277
309static int __init ixj_pcmcia_init(void) 278static int __init ixj_pcmcia_init(void)
@@ -314,7 +283,6 @@ static int __init ixj_pcmcia_init(void)
314static void ixj_pcmcia_exit(void) 283static void ixj_pcmcia_exit(void)
315{ 284{
316 pcmcia_unregister_driver(&ixj_driver); 285 pcmcia_unregister_driver(&ixj_driver);
317 BUG_ON(dev_list != NULL);
318} 286}
319 287
320module_init(ixj_pcmcia_init); 288module_init(ixj_pcmcia_init);
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index a50c2bc506f2..3639c3f8d357 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -22,6 +22,7 @@ obj-$(CONFIG_USB_MIDI) += class/
22obj-$(CONFIG_USB_PRINTER) += class/ 22obj-$(CONFIG_USB_PRINTER) += class/
23 23
24obj-$(CONFIG_USB_STORAGE) += storage/ 24obj-$(CONFIG_USB_STORAGE) += storage/
25obj-$(CONFIG_USB) += storage/
25 26
26obj-$(CONFIG_USB_AIPTEK) += input/ 27obj-$(CONFIG_USB_AIPTEK) += input/
27obj-$(CONFIG_USB_ATI_REMOTE) += input/ 28obj-$(CONFIG_USB_ATI_REMOTE) += input/
diff --git a/drivers/usb/atm/Kconfig b/drivers/usb/atm/Kconfig
index f429862e0974..550ddfa71a43 100644
--- a/drivers/usb/atm/Kconfig
+++ b/drivers/usb/atm/Kconfig
@@ -44,6 +44,19 @@ config USB_CXACRU
44 To compile this driver as a module, choose M here: the 44 To compile this driver as a module, choose M here: the
45 module will be called cxacru. 45 module will be called cxacru.
46 46
47config USB_UEAGLEATM
48 tristate "ADI 930 and eagle USB DSL modem"
49 depends on USB_ATM
50 select FW_LOADER
51 help
52 Say Y here if you have an ADSL USB modem based on the ADI 930
53 or eagle chipset. In order to use your modem you will need to
54 install firmwares and CMV (Command Management Variables); see
55 <https://gna.org/projects/ueagleatm/> for details.
56
57 To compile this driver as a module, choose M here: the
58 module will be called ueagle-atm.
59
47config USB_XUSBATM 60config USB_XUSBATM
48 tristate "Other USB DSL modem support" 61 tristate "Other USB DSL modem support"
49 depends on USB_ATM 62 depends on USB_ATM
diff --git a/drivers/usb/atm/Makefile b/drivers/usb/atm/Makefile
index 85099718c683..4c4a776ab1cd 100644
--- a/drivers/usb/atm/Makefile
+++ b/drivers/usb/atm/Makefile
@@ -4,6 +4,7 @@
4 4
5obj-$(CONFIG_USB_CXACRU) += cxacru.o 5obj-$(CONFIG_USB_CXACRU) += cxacru.o
6obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o 6obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o
7obj-$(CONFIG_USB_UEAGLEATM) += ueagle-atm.o
7obj-$(CONFIG_USB_ATM) += usbatm.o 8obj-$(CONFIG_USB_ATM) += usbatm.o
8obj-$(CONFIG_USB_XUSBATM) += xusbatm.o 9obj-$(CONFIG_USB_XUSBATM) += xusbatm.o
9 10
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 9d59dc62e6d2..af0a41e7870e 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -853,7 +853,6 @@ static int cxacru_usb_probe(struct usb_interface *intf, const struct usb_device_
853} 853}
854 854
855static struct usb_driver cxacru_usb_driver = { 855static struct usb_driver cxacru_usb_driver = {
856 .owner = THIS_MODULE,
857 .name = cxacru_driver_name, 856 .name = cxacru_driver_name,
858 .probe = cxacru_usb_probe, 857 .probe = cxacru_usb_probe,
859 .disconnect = usbatm_usb_disconnect, 858 .disconnect = usbatm_usb_disconnect,
diff --git a/drivers/usb/atm/speedtch.c b/drivers/usb/atm/speedtch.c
index d0cbbb7f0385..b28336148658 100644
--- a/drivers/usb/atm/speedtch.c
+++ b/drivers/usb/atm/speedtch.c
@@ -659,7 +659,6 @@ MODULE_DEVICE_TABLE(usb, speedtch_usb_ids);
659static int speedtch_usb_probe(struct usb_interface *, const struct usb_device_id *); 659static int speedtch_usb_probe(struct usb_interface *, const struct usb_device_id *);
660 660
661static struct usb_driver speedtch_usb_driver = { 661static struct usb_driver speedtch_usb_driver = {
662 .owner = THIS_MODULE,
663 .name = speedtch_driver_name, 662 .name = speedtch_driver_name,
664 .probe = speedtch_usb_probe, 663 .probe = speedtch_usb_probe,
665 .disconnect = usbatm_usb_disconnect, 664 .disconnect = usbatm_usb_disconnect,
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
new file mode 100644
index 000000000000..7d2a679989ed
--- /dev/null
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -0,0 +1,1820 @@
1/*-
2 * Copyright (c) 2003, 2004
3 * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved.
4 *
5 * Copyright (c) 2005 Matthieu Castet <castet.matthieu@free.fr>
6 *
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * BSD license below:
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice unmodified, this list of conditions, and the following
18 * disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * GPL license :
36 * This program is free software; you can redistribute it and/or
37 * modify it under the terms of the GNU General Public License
38 * as published by the Free Software Foundation; either version 2
39 * of the License, or (at your option) any later version.
40 *
41 * This program is distributed in the hope that it will be useful,
42 * but WITHOUT ANY WARRANTY; without even the implied warranty of
43 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 * GNU General Public License for more details.
45 *
46 * You should have received a copy of the GNU General Public License
47 * along with this program; if not, write to the Free Software
48 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
49 *
50 *
51 * HISTORY : some part of the code was base on ueagle 1.3 BSD driver,
52 * Damien Bergamini agree to put his code under a DUAL GPL/BSD license.
53 *
54 * The rest of the code was was rewritten from scratch.
55 */
56
57#include <linux/module.h>
58#include <linux/moduleparam.h>
59#include <linux/init.h>
60#include <linux/crc32.h>
61#include <linux/usb.h>
62#include <linux/firmware.h>
63#include <linux/ctype.h>
64#include <linux/kthread.h>
65#include <linux/version.h>
66#include <asm/unaligned.h>
67
68#include "usbatm.h"
69
70#define EAGLEUSBVERSION "ueagle 1.1"
71
72
73/*
74 * Debug macros
75 */
76#define uea_dbg(usb_dev, format, args...) \
77 do { \
78 if (debug >= 1) \
79 dev_dbg(&(usb_dev)->dev, \
80 "[ueagle-atm dbg] %s: " format, \
81 __FUNCTION__, ##args); \
82 } while (0)
83
84#define uea_vdbg(usb_dev, format, args...) \
85 do { \
86 if (debug >= 2) \
87 dev_dbg(&(usb_dev)->dev, \
88 "[ueagle-atm vdbg] " format, ##args); \
89 } while (0)
90
91#define uea_enters(usb_dev) \
92 uea_vdbg(usb_dev, "entering %s\n", __FUNCTION__)
93
94#define uea_leaves(usb_dev) \
95 uea_vdbg(usb_dev, "leaving %s\n", __FUNCTION__)
96
97#define uea_err(usb_dev, format,args...) \
98 dev_err(&(usb_dev)->dev ,"[UEAGLE-ATM] " format , ##args)
99
100#define uea_warn(usb_dev, format,args...) \
101 dev_warn(&(usb_dev)->dev ,"[Ueagle-atm] " format, ##args)
102
103#define uea_info(usb_dev, format,args...) \
104 dev_info(&(usb_dev)->dev ,"[ueagle-atm] " format, ##args)
105
106struct uea_cmvs {
107 u32 address;
108 u16 offset;
109 u32 data;
110} __attribute__ ((packed));
111
112struct uea_softc {
113 struct usb_device *usb_dev;
114 struct usbatm_data *usbatm;
115
116 int modem_index;
117 unsigned int driver_info;
118
119 int booting;
120 int reset;
121
122 wait_queue_head_t sync_q;
123
124 struct task_struct *kthread;
125 u32 data;
126 wait_queue_head_t cmv_ack_wait;
127 int cmv_ack;
128
129 struct work_struct task;
130 u16 pageno;
131 u16 ovl;
132
133 const struct firmware *dsp_firm;
134 struct urb *urb_int;
135
136 u8 cmv_function;
137 u16 cmv_idx;
138 u32 cmv_address;
139 u16 cmv_offset;
140
141 /* keep in sync with eaglectl */
142 struct uea_stats {
143 struct {
144 u32 state;
145 u32 flags;
146 u32 mflags;
147 u32 vidcpe;
148 u32 vidco;
149 u32 dsrate;
150 u32 usrate;
151 u32 dsunc;
152 u32 usunc;
153 u32 dscorr;
154 u32 uscorr;
155 u32 txflow;
156 u32 rxflow;
157 u32 usattenuation;
158 u32 dsattenuation;
159 u32 dsmargin;
160 u32 usmargin;
161 u32 firmid;
162 } phy;
163 } stats;
164};
165
166/*
167 * Elsa IDs
168 */
169#define ELSA_VID 0x05CC
170#define ELSA_PID_PSTFIRM 0x3350
171#define ELSA_PID_PREFIRM 0x3351
172
173/*
174 * Sagem USB IDs
175 */
176#define EAGLE_VID 0x1110
177#define EAGLE_I_PID_PREFIRM 0x9010 /* Eagle I */
178#define EAGLE_I_PID_PSTFIRM 0x900F /* Eagle I */
179
180#define EAGLE_IIC_PID_PREFIRM 0x9024 /* Eagle IIC */
181#define EAGLE_IIC_PID_PSTFIRM 0x9023 /* Eagle IIC */
182
183#define EAGLE_II_PID_PREFIRM 0x9022 /* Eagle II */
184#define EAGLE_II_PID_PSTFIRM 0x9021 /* Eagle II */
185
186/*
187 * Eagle III Pid
188 */
189#define EAGLE_III_PID_PREFIRM 0x9032 /* Eagle III */
190#define EAGLE_III_PID_PSTFIRM 0x9031 /* Eagle III */
191
192/*
193 * USR USB IDs
194 */
195#define USR_VID 0x0BAF
196#define MILLER_A_PID_PREFIRM 0x00F2
197#define MILLER_A_PID_PSTFIRM 0x00F1
198#define MILLER_B_PID_PREFIRM 0x00FA
199#define MILLER_B_PID_PSTFIRM 0x00F9
200#define HEINEKEN_A_PID_PREFIRM 0x00F6
201#define HEINEKEN_A_PID_PSTFIRM 0x00F5
202#define HEINEKEN_B_PID_PREFIRM 0x00F8
203#define HEINEKEN_B_PID_PSTFIRM 0x00F7
204
205#define PREFIRM 0
206#define PSTFIRM (1<<7)
207enum {
208 ADI930 = 0,
209 EAGLE_I,
210 EAGLE_II,
211 EAGLE_III
212};
213
214/* macros for both struct usb_device_id and struct uea_softc */
215#define UEA_IS_PREFIRM(x) \
216 (!((x)->driver_info & PSTFIRM))
217#define UEA_CHIP_VERSION(x) \
218 ((x)->driver_info & 0xf)
219
220#define IS_ISDN(sc) \
221 (le16_to_cpu(sc->usb_dev->descriptor.bcdDevice) & 0x80)
222
223#define INS_TO_USBDEV(ins) ins->usb_dev
224
225#define GET_STATUS(data) \
226 ((data >> 8) & 0xf)
227#define IS_OPERATIONAL(sc) \
228 (GET_STATUS(sc->stats.phy.state) == 2)
229
230/*
231 * Set of macros to handle unaligned data in the firmware blob.
232 * The FW_GET_BYTE() macro is provided only for consistency.
233 */
234
235#define FW_GET_BYTE(p) *((__u8 *) (p))
236#define FW_GET_WORD(p) le16_to_cpu(get_unaligned((__le16 *) (p)))
237#define FW_GET_LONG(p) le32_to_cpu(get_unaligned((__le32 *) (p)))
238
239#define FW_DIR "ueagle-atm/"
240#define NB_MODEM 4
241
242#define BULK_TIMEOUT 300
243#define CTRL_TIMEOUT 1000
244
245#define ACK_TIMEOUT msecs_to_jiffies(1500)
246
247#define UEA_INTR_IFACE_NO 0
248#define UEA_US_IFACE_NO 1
249#define UEA_DS_IFACE_NO 2
250
251#define FASTEST_ISO_INTF 8
252
253#define UEA_BULK_DATA_PIPE 0x02
254#define UEA_IDMA_PIPE 0x04
255#define UEA_INTR_PIPE 0x04
256#define UEA_ISO_DATA_PIPE 0x08
257
258#define UEA_SET_BLOCK 0x0001
259#define UEA_SET_MODE 0x0003
260#define UEA_SET_2183_DATA 0x0004
261#define UEA_SET_TIMEOUT 0x0011
262
263#define UEA_LOOPBACK_OFF 0x0002
264#define UEA_LOOPBACK_ON 0x0003
265#define UEA_BOOT_IDMA 0x0006
266#define UEA_START_RESET 0x0007
267#define UEA_END_RESET 0x0008
268
269#define UEA_SWAP_MAILBOX (0x3fcd | 0x4000)
270#define UEA_MPTX_START (0x3fce | 0x4000)
271#define UEA_MPTX_MAILBOX (0x3fd6 | 0x4000)
272#define UEA_MPRX_MAILBOX (0x3fdf | 0x4000)
273
274/* structure describing a block within a DSP page */
275struct block_info {
276 __le16 wHdr;
277#define UEA_BIHDR 0xabcd
278 __le16 wAddress;
279 __le16 wSize;
280 __le16 wOvlOffset;
281 __le16 wOvl; /* overlay */
282 __le16 wLast;
283} __attribute__ ((packed));
284#define BLOCK_INFO_SIZE 12
285
286/* structure representing a CMV (Configuration and Management Variable) */
287struct cmv {
288 __le16 wPreamble;
289#define PREAMBLE 0x535c
290 __u8 bDirection;
291#define MODEMTOHOST 0x01
292#define HOSTTOMODEM 0x10
293 __u8 bFunction;
294#define FUNCTION_TYPE(f) ((f) >> 4)
295#define MEMACCESS 0x1
296#define ADSLDIRECTIVE 0x7
297
298#define FUNCTION_SUBTYPE(f) ((f) & 0x0f)
299/* for MEMACCESS */
300#define REQUESTREAD 0x0
301#define REQUESTWRITE 0x1
302#define REPLYREAD 0x2
303#define REPLYWRITE 0x3
304/* for ADSLDIRECTIVE */
305#define KERNELREADY 0x0
306#define MODEMREADY 0x1
307
308#define MAKEFUNCTION(t, s) (((t) & 0xf) << 4 | ((s) & 0xf))
309 __le16 wIndex;
310 __le32 dwSymbolicAddress;
311#define MAKESA(a, b, c, d) \
312 (((c) & 0xff) << 24 | \
313 ((d) & 0xff) << 16 | \
314 ((a) & 0xff) << 8 | \
315 ((b) & 0xff))
316
317#define SA_CNTL MAKESA('C', 'N', 'T', 'L')
318#define SA_DIAG MAKESA('D', 'I', 'A', 'G')
319#define SA_INFO MAKESA('I', 'N', 'F', 'O')
320#define SA_OPTN MAKESA('O', 'P', 'T', 'N')
321#define SA_RATE MAKESA('R', 'A', 'T', 'E')
322#define SA_STAT MAKESA('S', 'T', 'A', 'T')
323 __le16 wOffsetAddress;
324 __le32 dwData;
325} __attribute__ ((packed));
326#define CMV_SIZE 16
327
328/* structure representing swap information */
329struct swap_info {
330 __u8 bSwapPageNo;
331 __u8 bOvl; /* overlay */
332} __attribute__ ((packed));
333
334/* structure representing interrupt data */
335struct intr_pkt {
336 __u8 bType;
337 __u8 bNotification;
338 __le16 wValue;
339 __le16 wIndex;
340 __le16 wLength;
341 __le16 wInterrupt;
342#define INT_LOADSWAPPAGE 0x0001
343#define INT_INCOMINGCMV 0x0002
344 union {
345 struct {
346 struct swap_info swapinfo;
347 __le16 wDataSize;
348 } __attribute__ ((packed)) s1;
349
350 struct {
351 struct cmv cmv;
352 __le16 wDataSize;
353 } __attribute__ ((packed)) s2;
354 } __attribute__ ((packed)) u;
355#define bSwapPageNo u.s1.swapinfo.bSwapPageNo
356#define bOvl u.s1.swapinfo.bOvl
357} __attribute__ ((packed));
358#define INTR_PKT_SIZE 28
359
360static struct usb_driver uea_driver;
361static DECLARE_MUTEX(uea_semaphore);
362static const char *chip_name[] = {"ADI930", "Eagle I", "Eagle II", "Eagle III"};
363
364static int modem_index;
365static unsigned int debug;
366static int sync_wait[NB_MODEM];
367static char *cmv_file[NB_MODEM];
368
369module_param(debug, uint, 0644);
370MODULE_PARM_DESC(debug, "module debug level (0=off,1=on,2=verbose)");
371module_param_array(sync_wait, bool, NULL, 0644);
372MODULE_PARM_DESC(sync_wait, "wait the synchronisation before starting ATM");
373module_param_array(cmv_file, charp, NULL, 0644);
374MODULE_PARM_DESC(cmv_file,
375 "file name with configuration and management variables");
376
377#define UPDATE_ATM_STAT(type, val) \
378 do { \
379 if (sc->usbatm->atm_dev) \
380 sc->usbatm->atm_dev->type = val; \
381 } while (0)
382
383/* Firmware loading */
384#define LOAD_INTERNAL 0xA0
385#define F8051_USBCS 0x7f92
386
387/**
388 * uea_send_modem_cmd - Send a command for pre-firmware devices.
389 */
390static int uea_send_modem_cmd(struct usb_device *usb,
391 u16 addr, u16 size, u8 * buff)
392{
393 int ret = -ENOMEM;
394 u8 *xfer_buff;
395
396 xfer_buff = kmalloc(size, GFP_KERNEL);
397 if (xfer_buff) {
398 memcpy(xfer_buff, buff, size);
399 ret = usb_control_msg(usb,
400 usb_sndctrlpipe(usb, 0),
401 LOAD_INTERNAL,
402 USB_DIR_OUT | USB_TYPE_VENDOR |
403 USB_RECIP_DEVICE, addr, 0, xfer_buff,
404 size, CTRL_TIMEOUT);
405 kfree(xfer_buff);
406 }
407
408 if (ret < 0)
409 return ret;
410
411 return (ret == size) ? 0 : -EIO;
412}
413
414static void uea_upload_pre_firmware(const struct firmware *fw_entry, void *context)
415{
416 struct usb_device *usb = context;
417 u8 *pfw, value;
418 u32 crc = 0;
419 int ret, size;
420
421 uea_enters(usb);
422 if (!fw_entry) {
423 uea_err(usb, "firmware is not available\n");
424 goto err;
425 }
426
427 pfw = fw_entry->data;
428 size = fw_entry->size;
429 if (size < 4)
430 goto err_fw_corrupted;
431
432 crc = FW_GET_LONG(pfw);
433 pfw += 4;
434 size -= 4;
435 if (crc32_be(0, pfw, size) != crc)
436 goto err_fw_corrupted;
437
438 /*
439 * Start to upload formware : send reset
440 */
441 value = 1;
442 ret = uea_send_modem_cmd(usb, F8051_USBCS, sizeof(value), &value);
443
444 if (ret < 0) {
445 uea_err(usb, "modem reset failed with error %d\n", ret);
446 goto err;
447 }
448
449 while (size > 3) {
450 u8 len = FW_GET_BYTE(pfw);
451 u16 add = FW_GET_WORD(pfw + 1);
452
453 size -= len + 3;
454 if (size < 0)
455 goto err_fw_corrupted;
456
457 ret = uea_send_modem_cmd(usb, add, len, pfw + 3);
458 if (ret < 0) {
459 uea_err(usb, "uploading firmware data failed "
460 "with error %d\n", ret);
461 goto err;
462 }
463 pfw += len + 3;
464 }
465
466 if (size != 0)
467 goto err_fw_corrupted;
468
469 /*
470 * Tell the modem we finish : de-assert reset
471 */
472 value = 0;
473 ret = uea_send_modem_cmd(usb, F8051_USBCS, 1, &value);
474 if (ret < 0)
475 uea_err(usb, "modem de-assert failed with error %d\n", ret);
476 else
477 uea_info(usb, "firmware uploaded\n");
478
479 uea_leaves(usb);
480 return;
481
482err_fw_corrupted:
483 uea_err(usb, "firmware is corrupted\n");
484err:
485 uea_leaves(usb);
486}
487
488/**
489 * uea_load_firmware - Load usb firmware for pre-firmware devices.
490 */
491static int uea_load_firmware(struct usb_device *usb, unsigned int ver)
492{
493 int ret;
494 char *fw_name = FW_DIR "eagle.fw";
495
496 uea_enters(usb);
497 uea_info(usb, "pre-firmware device, uploading firmware\n");
498
499 switch (ver) {
500 case ADI930:
501 fw_name = FW_DIR "adi930.fw";
502 break;
503 case EAGLE_I:
504 fw_name = FW_DIR "eagleI.fw";
505 break;
506 case EAGLE_II:
507 fw_name = FW_DIR "eagleII.fw";
508 break;
509 case EAGLE_III:
510 fw_name = FW_DIR "eagleIII.fw";
511 break;
512 }
513
514 ret = request_firmware_nowait(THIS_MODULE, 1, fw_name, &usb->dev, usb, uea_upload_pre_firmware);
515 if (ret)
516 uea_err(usb, "firmware %s is not available\n", fw_name);
517 else
518 uea_info(usb, "loading firmware %s\n", fw_name);
519
520 uea_leaves(usb);
521 return ret;
522}
523
524/* modem management : dsp firmware, send/read CMV, monitoring statistic
525 */
526
527/*
528 * Make sure that the DSP code provided is safe to use.
529 */
530static int check_dsp(u8 *dsp, unsigned int len)
531{
532 u8 pagecount, blockcount;
533 u16 blocksize;
534 u32 pageoffset;
535 unsigned int i, j, p, pp;
536
537 pagecount = FW_GET_BYTE(dsp);
538 p = 1;
539
540 /* enough space for page offsets? */
541 if (p + 4 * pagecount > len)
542 return 1;
543
544 for (i = 0; i < pagecount; i++) {
545
546 pageoffset = FW_GET_LONG(dsp + p);
547 p += 4;
548
549 if (pageoffset == 0)
550 continue;
551
552 /* enough space for blockcount? */
553 if (pageoffset >= len)
554 return 1;
555
556 pp = pageoffset;
557 blockcount = FW_GET_BYTE(dsp + pp);
558 pp += 1;
559
560 for (j = 0; j < blockcount; j++) {
561
562 /* enough space for block header? */
563 if (pp + 4 > len)
564 return 1;
565
566 pp += 2; /* skip blockaddr */
567 blocksize = FW_GET_WORD(dsp + pp);
568 pp += 2;
569
570 /* enough space for block data? */
571 if (pp + blocksize > len)
572 return 1;
573
574 pp += blocksize;
575 }
576 }
577
578 return 0;
579}
580
581/*
582 * send data to the idma pipe
583 * */
584static int uea_idma_write(struct uea_softc *sc, void *data, u32 size)
585{
586 int ret = -ENOMEM;
587 u8 *xfer_buff;
588 int bytes_read;
589
590 xfer_buff = kmalloc(size, GFP_KERNEL);
591 if (!xfer_buff) {
592 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
593 return ret;
594 }
595
596 memcpy(xfer_buff, data, size);
597
598 ret = usb_bulk_msg(sc->usb_dev,
599 usb_sndbulkpipe(sc->usb_dev, UEA_IDMA_PIPE),
600 xfer_buff, size, &bytes_read, BULK_TIMEOUT);
601
602 kfree(xfer_buff);
603 if (ret < 0)
604 return ret;
605 if (size != bytes_read) {
606 uea_err(INS_TO_USBDEV(sc), "size != bytes_read %d %d\n", size,
607 bytes_read);
608 return -EIO;
609 }
610
611 return 0;
612}
613
614static int request_dsp(struct uea_softc *sc)
615{
616 int ret;
617 char *dsp_name;
618
619 if (UEA_CHIP_VERSION(sc) == ADI930) {
620 if (IS_ISDN(sc))
621 dsp_name = FW_DIR "DSP9i.bin";
622 else
623 dsp_name = FW_DIR "DSP9p.bin";
624 } else {
625 if (IS_ISDN(sc))
626 dsp_name = FW_DIR "DSPei.bin";
627 else
628 dsp_name = FW_DIR "DSPep.bin";
629 }
630
631 ret = request_firmware(&sc->dsp_firm,
632 dsp_name, &sc->usb_dev->dev);
633 if (ret < 0) {
634 uea_err(INS_TO_USBDEV(sc),
635 "requesting firmware %s failed with error %d\n",
636 dsp_name, ret);
637 return ret;
638 }
639
640 if (check_dsp(sc->dsp_firm->data, sc->dsp_firm->size)) {
641 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
642 dsp_name);
643 release_firmware(sc->dsp_firm);
644 sc->dsp_firm = NULL;
645 return -EILSEQ;
646 }
647
648 return 0;
649}
650
651/*
652 * The uea_load_page() function must be called within a process context
653 */
654static void uea_load_page(void *xsc)
655{
656 struct uea_softc *sc = xsc;
657 u16 pageno = sc->pageno;
658 u16 ovl = sc->ovl;
659 struct block_info bi;
660
661 u8 *p;
662 u8 pagecount, blockcount;
663 u16 blockaddr, blocksize;
664 u32 pageoffset;
665 int i;
666
667 /* reload firmware when reboot start and it's loaded already */
668 if (ovl == 0 && pageno == 0 && sc->dsp_firm) {
669 release_firmware(sc->dsp_firm);
670 sc->dsp_firm = NULL;
671 }
672
673 if (sc->dsp_firm == NULL && request_dsp(sc) < 0)
674 return;
675
676 p = sc->dsp_firm->data;
677 pagecount = FW_GET_BYTE(p);
678 p += 1;
679
680 if (pageno >= pagecount)
681 goto bad1;
682
683 p += 4 * pageno;
684 pageoffset = FW_GET_LONG(p);
685
686 if (pageoffset == 0)
687 goto bad1;
688
689 p = sc->dsp_firm->data + pageoffset;
690 blockcount = FW_GET_BYTE(p);
691 p += 1;
692
693 uea_dbg(INS_TO_USBDEV(sc),
694 "sending %u blocks for DSP page %u\n", blockcount, pageno);
695
696 bi.wHdr = cpu_to_le16(UEA_BIHDR);
697 bi.wOvl = cpu_to_le16(ovl);
698 bi.wOvlOffset = cpu_to_le16(ovl | 0x8000);
699
700 for (i = 0; i < blockcount; i++) {
701 blockaddr = FW_GET_WORD(p);
702 p += 2;
703
704 blocksize = FW_GET_WORD(p);
705 p += 2;
706
707 bi.wSize = cpu_to_le16(blocksize);
708 bi.wAddress = cpu_to_le16(blockaddr);
709 bi.wLast = cpu_to_le16((i == blockcount - 1) ? 1 : 0);
710
711 /* send block info through the IDMA pipe */
712 if (uea_idma_write(sc, &bi, BLOCK_INFO_SIZE))
713 goto bad2;
714
715 /* send block data through the IDMA pipe */
716 if (uea_idma_write(sc, p, blocksize))
717 goto bad2;
718
719 p += blocksize;
720 }
721
722 return;
723
724bad2:
725 uea_err(INS_TO_USBDEV(sc), "sending DSP block %u failed\n", i);
726 return;
727bad1:
728 uea_err(INS_TO_USBDEV(sc), "invalid DSP page %u requested\n",pageno);
729}
730
731static inline void wake_up_cmv_ack(struct uea_softc *sc)
732{
733 sc->cmv_ack = 1;
734 wake_up(&sc->cmv_ack_wait);
735}
736
737static inline int wait_cmv_ack(struct uea_softc *sc)
738{
739 int ret = wait_event_timeout(sc->cmv_ack_wait,
740 sc->cmv_ack, ACK_TIMEOUT);
741 sc->cmv_ack = 0;
742
743 if (ret < 0)
744 return ret;
745
746 return (ret == 0) ? -ETIMEDOUT : 0;
747
748}
749
750#define UCDC_SEND_ENCAPSULATED_COMMAND 0x00
751
752static int uea_request(struct uea_softc *sc,
753 u16 value, u16 index, u16 size, void *data)
754{
755 u8 *xfer_buff;
756 int ret = -ENOMEM;
757
758 xfer_buff = kmalloc(size, GFP_KERNEL);
759 if (!xfer_buff) {
760 uea_err(INS_TO_USBDEV(sc), "can't allocate xfer_buff\n");
761 return ret;
762 }
763 memcpy(xfer_buff, data, size);
764
765 ret = usb_control_msg(sc->usb_dev, usb_sndctrlpipe(sc->usb_dev, 0),
766 UCDC_SEND_ENCAPSULATED_COMMAND,
767 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
768 value, index, xfer_buff, size, CTRL_TIMEOUT);
769
770 kfree(xfer_buff);
771 if (ret < 0) {
772 uea_err(INS_TO_USBDEV(sc), "usb_control_msg error %d\n", ret);
773 return ret;
774 }
775
776 if (ret != size) {
777 uea_err(INS_TO_USBDEV(sc),
778 "usb_control_msg send only %d bytes (instead of %d)\n",
779 ret, size);
780 return -EIO;
781 }
782
783 return 0;
784}
785
786static int uea_cmv(struct uea_softc *sc,
787 u8 function, u32 address, u16 offset, u32 data)
788{
789 struct cmv cmv;
790 int ret;
791
792 /* we send a request, but we expect a reply */
793 sc->cmv_function = function | 0x2;
794 sc->cmv_idx++;
795 sc->cmv_address = address;
796 sc->cmv_offset = offset;
797
798 cmv.wPreamble = cpu_to_le16(PREAMBLE);
799 cmv.bDirection = HOSTTOMODEM;
800 cmv.bFunction = function;
801 cmv.wIndex = cpu_to_le16(sc->cmv_idx);
802 put_unaligned(cpu_to_le32(address), &cmv.dwSymbolicAddress);
803 cmv.wOffsetAddress = cpu_to_le16(offset);
804 put_unaligned(cpu_to_le32(data >> 16 | data << 16), &cmv.dwData);
805
806 ret = uea_request(sc, UEA_SET_BLOCK, UEA_MPTX_START, CMV_SIZE, &cmv);
807 if (ret < 0)
808 return ret;
809 return wait_cmv_ack(sc);
810}
811
812static inline int uea_read_cmv(struct uea_softc *sc,
813 u32 address, u16 offset, u32 *data)
814{
815 int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTREAD),
816 address, offset, 0);
817 if (ret < 0)
818 uea_err(INS_TO_USBDEV(sc),
819 "reading cmv failed with error %d\n", ret);
820 else
821 *data = sc->data;
822
823 return ret;
824}
825
826static inline int uea_write_cmv(struct uea_softc *sc,
827 u32 address, u16 offset, u32 data)
828{
829 int ret = uea_cmv(sc, MAKEFUNCTION(MEMACCESS, REQUESTWRITE),
830 address, offset, data);
831 if (ret < 0)
832 uea_err(INS_TO_USBDEV(sc),
833 "writing cmv failed with error %d\n", ret);
834
835 return ret;
836}
837
838/*
839 * Monitor the modem and update the stat
840 * return 0 if everything is ok
841 * return < 0 if an error occurs (-EAGAIN reboot needed)
842 */
843static int uea_stat(struct uea_softc *sc)
844{
845 u32 data;
846 int ret;
847
848 uea_enters(INS_TO_USBDEV(sc));
849 data = sc->stats.phy.state;
850
851 ret = uea_read_cmv(sc, SA_STAT, 0, &sc->stats.phy.state);
852 if (ret < 0)
853 return ret;
854
855 switch (GET_STATUS(sc->stats.phy.state)) {
856 case 0: /* not yet synchronized */
857 uea_dbg(INS_TO_USBDEV(sc),
858 "modem not yet synchronized\n");
859 return 0;
860
861 case 1: /* initialization */
862 uea_dbg(INS_TO_USBDEV(sc), "modem initializing\n");
863 return 0;
864
865 case 2: /* operational */
866 uea_vdbg(INS_TO_USBDEV(sc), "modem operational\n");
867 break;
868
869 case 3: /* fail ... */
870 uea_info(INS_TO_USBDEV(sc), "modem synchronization failed\n");
871 return -EAGAIN;
872
873 case 4 ... 6: /* test state */
874 uea_warn(INS_TO_USBDEV(sc),
875 "modem in test mode - not supported\n");
876 return -EAGAIN;
877
878 case 7: /* fast-retain ... */
879 uea_info(INS_TO_USBDEV(sc), "modem in fast-retain mode\n");
880 return 0;
881 default:
882 uea_err(INS_TO_USBDEV(sc), "modem invalid SW mode %d\n",
883 GET_STATUS(sc->stats.phy.state));
884 return -EAGAIN;
885 }
886
887 if (GET_STATUS(data) != 2) {
888 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_OFF, 0, NULL);
889 uea_info(INS_TO_USBDEV(sc), "modem operational\n");
890
891 /* release the dsp firmware as it is not needed until
892 * the next failure
893 */
894 if (sc->dsp_firm) {
895 release_firmware(sc->dsp_firm);
896 sc->dsp_firm = NULL;
897 }
898
899 ret = uea_read_cmv(sc, SA_INFO, 10, &sc->stats.phy.firmid);
900 if (ret < 0)
901 return ret;
902 uea_info(INS_TO_USBDEV(sc), "ATU-R firmware version : %x\n",
903 sc->stats.phy.firmid);
904 }
905
906 /* always update it as atm layer could not be init when we switch to
907 * operational state
908 */
909 UPDATE_ATM_STAT(signal, ATM_PHY_SIG_FOUND);
910
911 /* wake up processes waiting for synchronization */
912 wake_up(&sc->sync_q);
913
914 ret = uea_read_cmv(sc, SA_DIAG, 2, &sc->stats.phy.flags);
915 if (ret < 0)
916 return ret;
917 sc->stats.phy.mflags |= sc->stats.phy.flags;
918
919 /* in case of a flags ( for example delineation LOSS (& 0x10)),
920 * we check the status again in order to detect the failure earlier
921 */
922 if (sc->stats.phy.flags) {
923 uea_dbg(INS_TO_USBDEV(sc), "Stat flag = %d\n",
924 sc->stats.phy.flags);
925 return 0;
926 }
927
928 ret = uea_read_cmv(sc, SA_RATE, 0, &data);
929 if (ret < 0)
930 return ret;
931
932 /* in bulk mode the modem have problem with high rate
933 * changing internal timing could improve things, but the
934 * value is misterious.
935 * ADI930 don't support it (-EPIPE error).
936 */
937 if (UEA_CHIP_VERSION(sc) != ADI930
938 && sc->stats.phy.dsrate != (data >> 16) * 32) {
939 /* Original timming from ADI(used in windows driver)
940 * 0x20ffff>>16 * 32 = 32 * 32 = 1Mbits
941 */
942 u16 timeout = (data <= 0x20ffff) ? 0 : 1;
943 ret = uea_request(sc, UEA_SET_TIMEOUT, timeout, 0, NULL);
944 uea_info(INS_TO_USBDEV(sc),
945 "setting new timeout %d%s\n", timeout,
946 ret < 0?" failed":"");
947 }
948 sc->stats.phy.dsrate = (data >> 16) * 32;
949 sc->stats.phy.usrate = (data & 0xffff) * 32;
950 UPDATE_ATM_STAT(link_rate, sc->stats.phy.dsrate * 1000 / 424);
951
952 ret = uea_read_cmv(sc, SA_DIAG, 23, &data);
953 if (ret < 0)
954 return ret;
955 sc->stats.phy.dsattenuation = (data & 0xff) / 2;
956
957 ret = uea_read_cmv(sc, SA_DIAG, 47, &data);
958 if (ret < 0)
959 return ret;
960 sc->stats.phy.usattenuation = (data & 0xff) / 2;
961
962 ret = uea_read_cmv(sc, SA_DIAG, 25, &sc->stats.phy.dsmargin);
963 if (ret < 0)
964 return ret;
965
966 ret = uea_read_cmv(sc, SA_DIAG, 49, &sc->stats.phy.usmargin);
967 if (ret < 0)
968 return ret;
969
970 ret = uea_read_cmv(sc, SA_DIAG, 51, &sc->stats.phy.rxflow);
971 if (ret < 0)
972 return ret;
973
974 ret = uea_read_cmv(sc, SA_DIAG, 52, &sc->stats.phy.txflow);
975 if (ret < 0)
976 return ret;
977
978 ret = uea_read_cmv(sc, SA_DIAG, 54, &sc->stats.phy.dsunc);
979 if (ret < 0)
980 return ret;
981
982 /* only for atu-c */
983 ret = uea_read_cmv(sc, SA_DIAG, 58, &sc->stats.phy.usunc);
984 if (ret < 0)
985 return ret;
986
987 ret = uea_read_cmv(sc, SA_DIAG, 53, &sc->stats.phy.dscorr);
988 if (ret < 0)
989 return ret;
990
991 /* only for atu-c */
992 ret = uea_read_cmv(sc, SA_DIAG, 57, &sc->stats.phy.uscorr);
993 if (ret < 0)
994 return ret;
995
996 ret = uea_read_cmv(sc, SA_INFO, 8, &sc->stats.phy.vidco);
997 if (ret < 0)
998 return ret;
999
1000 ret = uea_read_cmv(sc, SA_INFO, 13, &sc->stats.phy.vidcpe);
1001 if (ret < 0)
1002 return ret;
1003
1004 return 0;
1005}
1006
1007static int request_cmvs(struct uea_softc *sc,
1008 struct uea_cmvs **cmvs, const struct firmware **fw)
1009{
1010 int ret, size;
1011 u8 *data;
1012 char *file;
1013 static char cmv_name[256] = FW_DIR;
1014
1015 if (cmv_file[sc->modem_index] == NULL) {
1016 if (UEA_CHIP_VERSION(sc) == ADI930)
1017 file = (IS_ISDN(sc)) ? "CMV9i.bin" : "CMV9p.bin";
1018 else
1019 file = (IS_ISDN(sc)) ? "CMVei.bin" : "CMVep.bin";
1020 } else
1021 file = cmv_file[sc->modem_index];
1022
1023 strcpy(cmv_name, FW_DIR);
1024 strlcat(cmv_name, file, sizeof(cmv_name));
1025
1026 ret = request_firmware(fw, cmv_name, &sc->usb_dev->dev);
1027 if (ret < 0) {
1028 uea_err(INS_TO_USBDEV(sc),
1029 "requesting firmware %s failed with error %d\n",
1030 cmv_name, ret);
1031 return ret;
1032 }
1033
1034 data = (u8 *) (*fw)->data;
1035 size = *data * sizeof(struct uea_cmvs) + 1;
1036 if (size != (*fw)->size) {
1037 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
1038 cmv_name);
1039 release_firmware(*fw);
1040 return -EILSEQ;
1041 }
1042
1043 *cmvs = (struct uea_cmvs *)(data + 1);
1044 return *data;
1045}
1046
1047/* Start boot post firmware modem:
1048 * - send reset commands through usb control pipe
1049 * - start workqueue for DSP loading
1050 * - send CMV options to modem
1051 */
1052
1053static int uea_start_reset(struct uea_softc *sc)
1054{
1055 u16 zero = 0; /* ;-) */
1056 int i, len, ret;
1057 struct uea_cmvs *cmvs;
1058 const struct firmware *cmvs_fw;
1059
1060 uea_enters(INS_TO_USBDEV(sc));
1061 uea_info(INS_TO_USBDEV(sc), "(re)booting started\n");
1062
1063 sc->booting = 1;
1064 UPDATE_ATM_STAT(signal, ATM_PHY_SIG_LOST);
1065
1066 /* reset statistics */
1067 memset(&sc->stats, 0, sizeof(struct uea_stats));
1068
1069 /* tell the modem that we want to boot in IDMA mode */
1070 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
1071 uea_request(sc, UEA_SET_MODE, UEA_BOOT_IDMA, 0, NULL);
1072
1073 /* enter reset mode */
1074 uea_request(sc, UEA_SET_MODE, UEA_START_RESET, 0, NULL);
1075
1076 /* original driver use 200ms, but windows driver use 100ms */
1077 msleep(100);
1078
1079 /* leave reset mode */
1080 uea_request(sc, UEA_SET_MODE, UEA_END_RESET, 0, NULL);
1081
1082 /* clear tx and rx mailboxes */
1083 uea_request(sc, UEA_SET_2183_DATA, UEA_MPTX_MAILBOX, 2, &zero);
1084 uea_request(sc, UEA_SET_2183_DATA, UEA_MPRX_MAILBOX, 2, &zero);
1085 uea_request(sc, UEA_SET_2183_DATA, UEA_SWAP_MAILBOX, 2, &zero);
1086
1087 msleep(1000);
1088 sc->cmv_function = MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY);
1089 sc->booting = 0;
1090
1091 /* start loading DSP */
1092 sc->pageno = 0;
1093 sc->ovl = 0;
1094 schedule_work(&sc->task);
1095
1096 /* wait for modem ready CMV */
1097 ret = wait_cmv_ack(sc);
1098 if (ret < 0)
1099 return ret;
1100
1101 /* Enter in R-IDLE (cmv) until instructed otherwise */
1102 ret = uea_write_cmv(sc, SA_CNTL, 0, 1);
1103 if (ret < 0)
1104 return ret;
1105
1106 /* get options */
1107 ret = len = request_cmvs(sc, &cmvs, &cmvs_fw);
1108 if (ret < 0)
1109 return ret;
1110
1111 /* send options */
1112 for (i = 0; i < len; i++) {
1113 ret = uea_write_cmv(sc, FW_GET_LONG(&cmvs[i].address),
1114 FW_GET_WORD(&cmvs[i].offset),
1115 FW_GET_LONG(&cmvs[i].data));
1116 if (ret < 0)
1117 goto out;
1118 }
1119 /* Enter in R-ACT-REQ */
1120 ret = uea_write_cmv(sc, SA_CNTL, 0, 2);
1121out:
1122 release_firmware(cmvs_fw);
1123 sc->reset = 0;
1124 uea_leaves(INS_TO_USBDEV(sc));
1125 return ret;
1126}
1127
1128/*
1129 * In case of an error wait 1s before rebooting the modem
1130 * if the modem don't request reboot (-EAGAIN).
1131 * Monitor the modem every 1s.
1132 */
1133
1134static int uea_kthread(void *data)
1135{
1136 struct uea_softc *sc = data;
1137 int ret = -EAGAIN;
1138
1139 uea_enters(INS_TO_USBDEV(sc));
1140 while (!kthread_should_stop()) {
1141 if (ret < 0 || sc->reset)
1142 ret = uea_start_reset(sc);
1143 if (!ret)
1144 ret = uea_stat(sc);
1145 if (ret != -EAGAIN)
1146 msleep(1000);
1147 }
1148 uea_leaves(INS_TO_USBDEV(sc));
1149 return ret;
1150}
1151
1152/* Load second usb firmware for ADI930 chip */
1153static int load_XILINX_firmware(struct uea_softc *sc)
1154{
1155 const struct firmware *fw_entry;
1156 int ret, size, u, ln;
1157 u8 *pfw, value;
1158 char *fw_name = FW_DIR "930-fpga.bin";
1159
1160 uea_enters(INS_TO_USBDEV(sc));
1161
1162 ret = request_firmware(&fw_entry, fw_name, &sc->usb_dev->dev);
1163 if (ret) {
1164 uea_err(INS_TO_USBDEV(sc), "firmware %s is not available\n",
1165 fw_name);
1166 goto err0;
1167 }
1168
1169 pfw = fw_entry->data;
1170 size = fw_entry->size;
1171 if (size != 0x577B) {
1172 uea_err(INS_TO_USBDEV(sc), "firmware %s is corrupted\n",
1173 fw_name);
1174 ret = -EILSEQ;
1175 goto err1;
1176 }
1177 for (u = 0; u < size; u += ln) {
1178 ln = min(size - u, 64);
1179 ret = uea_request(sc, 0xe, 0, ln, pfw + u);
1180 if (ret < 0) {
1181 uea_err(INS_TO_USBDEV(sc),
1182 "elsa download data failed (%d)\n", ret);
1183 goto err1;
1184 }
1185 }
1186
1187 /* finish to send the fpga
1188 */
1189 ret = uea_request(sc, 0xe, 1, 0, NULL);
1190 if (ret < 0) {
1191 uea_err(INS_TO_USBDEV(sc),
1192 "elsa download data failed (%d)\n", ret);
1193 goto err1;
1194 }
1195
1196 /*
1197 * Tell the modem we finish : de-assert reset
1198 */
1199 value = 0;
1200 ret = uea_send_modem_cmd(sc->usb_dev, 0xe, 1, &value);
1201 if (ret < 0)
1202 uea_err(sc->usb_dev, "elsa de-assert failed with error %d\n", ret);
1203
1204
1205err1:
1206 release_firmware(fw_entry);
1207err0:
1208 uea_leaves(INS_TO_USBDEV(sc));
1209 return ret;
1210}
1211
1212static void uea_dispatch_cmv(struct uea_softc *sc, struct cmv* cmv)
1213{
1214 uea_enters(INS_TO_USBDEV(sc));
1215 if (le16_to_cpu(cmv->wPreamble) != PREAMBLE)
1216 goto bad1;
1217
1218 if (cmv->bDirection != MODEMTOHOST)
1219 goto bad1;
1220
1221 /* FIXME : ADI930 reply wrong preambule (func = 2, sub = 2) to
1222 * the first MEMACESS cmv. Ignore it...
1223 */
1224 if (cmv->bFunction != sc->cmv_function) {
1225 if (UEA_CHIP_VERSION(sc) == ADI930
1226 && cmv->bFunction == MAKEFUNCTION(2, 2)) {
1227 cmv->wIndex = cpu_to_le16(sc->cmv_idx);
1228 put_unaligned(cpu_to_le32(sc->cmv_address), &cmv->dwSymbolicAddress);
1229 cmv->wOffsetAddress = cpu_to_le16(sc->cmv_offset);
1230 }
1231 else
1232 goto bad2;
1233 }
1234
1235 if (cmv->bFunction == MAKEFUNCTION(ADSLDIRECTIVE, MODEMREADY)) {
1236 wake_up_cmv_ack(sc);
1237 return;
1238 }
1239
1240 /* in case of MEMACCESS */
1241 if (le16_to_cpu(cmv->wIndex) != sc->cmv_idx ||
1242 le32_to_cpu(get_unaligned(&cmv->dwSymbolicAddress)) !=
1243 sc->cmv_address
1244 || le16_to_cpu(cmv->wOffsetAddress) != sc->cmv_offset)
1245 goto bad2;
1246
1247 sc->data = le32_to_cpu(get_unaligned(&cmv->dwData));
1248 sc->data = sc->data << 16 | sc->data >> 16;
1249
1250 wake_up_cmv_ack(sc);
1251 return;
1252
1253bad2:
1254 uea_err(INS_TO_USBDEV(sc), "unexpected cmv received,"
1255 "Function : %d, Subfunction : %d\n",
1256 FUNCTION_TYPE(cmv->bFunction),
1257 FUNCTION_SUBTYPE(cmv->bFunction));
1258 return;
1259
1260bad1:
1261 uea_err(INS_TO_USBDEV(sc), "invalid cmv received, "
1262 "wPreamble %d, bDirection %d\n",
1263 le16_to_cpu(cmv->wPreamble), cmv->bDirection);
1264}
1265
1266/*
1267 * interrupt handler
1268 */
1269static void uea_intr(struct urb *urb, struct pt_regs *regs)
1270{
1271 struct uea_softc *sc = (struct uea_softc *)urb->context;
1272 struct intr_pkt *intr;
1273 uea_enters(INS_TO_USBDEV(sc));
1274
1275 if (urb->status < 0) {
1276 uea_err(INS_TO_USBDEV(sc), "uea_intr() failed with %d\n",
1277 urb->status);
1278 return;
1279 }
1280
1281 intr = (struct intr_pkt *) urb->transfer_buffer;
1282
1283 /* device-to-host interrupt */
1284 if (intr->bType != 0x08 || sc->booting) {
1285 uea_err(INS_TO_USBDEV(sc), "wrong intr\n");
1286 // rebooting ?
1287 // sc->reset = 1;
1288 goto resubmit;
1289 }
1290
1291 switch (le16_to_cpu(intr->wInterrupt)) {
1292 case INT_LOADSWAPPAGE:
1293 sc->pageno = intr->bSwapPageNo;
1294 sc->ovl = intr->bOvl >> 4 | intr->bOvl << 4;
1295 schedule_work(&sc->task);
1296 break;
1297
1298 case INT_INCOMINGCMV:
1299 uea_dispatch_cmv(sc, &intr->u.s2.cmv);
1300 break;
1301
1302 default:
1303 uea_err(INS_TO_USBDEV(sc), "unknown intr %u\n",
1304 le16_to_cpu(intr->wInterrupt));
1305 }
1306
1307resubmit:
1308 usb_submit_urb(sc->urb_int, GFP_ATOMIC);
1309}
1310
1311/*
1312 * Start the modem : init the data and start kernel thread
1313 */
1314static int uea_boot(struct uea_softc *sc)
1315{
1316 int ret;
1317 struct intr_pkt *intr;
1318
1319 uea_enters(INS_TO_USBDEV(sc));
1320
1321 INIT_WORK(&sc->task, uea_load_page, sc);
1322 init_waitqueue_head(&sc->sync_q);
1323 init_waitqueue_head(&sc->cmv_ack_wait);
1324
1325 if (UEA_CHIP_VERSION(sc) == ADI930)
1326 load_XILINX_firmware(sc);
1327
1328 intr = kmalloc(INTR_PKT_SIZE, GFP_KERNEL);
1329 if (!intr) {
1330 uea_err(INS_TO_USBDEV(sc),
1331 "cannot allocate interrupt package\n");
1332 uea_leaves(INS_TO_USBDEV(sc));
1333 return -ENOMEM;
1334 }
1335
1336 sc->urb_int = usb_alloc_urb(0, GFP_KERNEL);
1337 if (!sc->urb_int) {
1338 uea_err(INS_TO_USBDEV(sc), "cannot allocate interrupt URB\n");
1339 goto err;
1340 }
1341
1342 usb_fill_int_urb(sc->urb_int, sc->usb_dev,
1343 usb_rcvintpipe(sc->usb_dev, UEA_INTR_PIPE),
1344 intr, INTR_PKT_SIZE, uea_intr, sc,
1345 sc->usb_dev->actconfig->interface[0]->altsetting[0].
1346 endpoint[0].desc.bInterval);
1347
1348 ret = usb_submit_urb(sc->urb_int, GFP_KERNEL);
1349 if (ret < 0) {
1350 uea_err(INS_TO_USBDEV(sc),
1351 "urb submition failed with error %d\n", ret);
1352 goto err1;
1353 }
1354
1355 sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm");
1356 if (sc->kthread == ERR_PTR(-ENOMEM)) {
1357 uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
1358 goto err2;
1359 }
1360
1361 uea_leaves(INS_TO_USBDEV(sc));
1362 return 0;
1363
1364err2:
1365 usb_kill_urb(sc->urb_int);
1366err1:
1367 kfree(intr);
1368err:
1369 usb_free_urb(sc->urb_int);
1370 uea_leaves(INS_TO_USBDEV(sc));
1371 return -ENOMEM;
1372}
1373
1374/*
1375 * Stop the modem : kill kernel thread and free data
1376 */
1377static void uea_stop(struct uea_softc *sc)
1378{
1379 int ret;
1380 uea_enters(INS_TO_USBDEV(sc));
1381 ret = kthread_stop(sc->kthread);
1382 uea_info(INS_TO_USBDEV(sc), "kthread finish with status %d\n", ret);
1383
1384 /* stop any pending boot process */
1385 flush_scheduled_work();
1386
1387 uea_request(sc, UEA_SET_MODE, UEA_LOOPBACK_ON, 0, NULL);
1388
1389 usb_kill_urb(sc->urb_int);
1390 kfree(sc->urb_int->transfer_buffer);
1391 usb_free_urb(sc->urb_int);
1392
1393 if (sc->dsp_firm)
1394 release_firmware(sc->dsp_firm);
1395 uea_leaves(INS_TO_USBDEV(sc));
1396}
1397
1398/* syfs interface */
1399static struct uea_softc *dev_to_uea(struct device *dev)
1400{
1401 struct usb_interface *intf;
1402 struct usbatm_data *usbatm;
1403
1404 intf = to_usb_interface(dev);
1405 if (!intf)
1406 return NULL;
1407
1408 usbatm = usb_get_intfdata(intf);
1409 if (!usbatm)
1410 return NULL;
1411
1412 return usbatm->driver_data;
1413}
1414
1415static ssize_t read_status(struct device *dev, struct device_attribute *attr,
1416 char *buf)
1417{
1418 int ret = -ENODEV;
1419 struct uea_softc *sc;
1420
1421 down(&uea_semaphore);
1422 sc = dev_to_uea(dev);
1423 if (!sc)
1424 goto out;
1425 ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.state);
1426out:
1427 up(&uea_semaphore);
1428 return ret;
1429}
1430
1431static ssize_t reboot(struct device *dev, struct device_attribute *attr,
1432 const char *buf, size_t count)
1433{
1434 int ret = -ENODEV;
1435 struct uea_softc *sc;
1436
1437 down(&uea_semaphore);
1438 sc = dev_to_uea(dev);
1439 if (!sc)
1440 goto out;
1441 sc->reset = 1;
1442 ret = count;
1443out:
1444 up(&uea_semaphore);
1445 return ret;
1446}
1447
1448static DEVICE_ATTR(stat_status, S_IWUGO | S_IRUGO, read_status, reboot);
1449
1450static ssize_t read_human_status(struct device *dev, struct device_attribute *attr,
1451 char *buf)
1452{
1453 int ret = -ENODEV;
1454 struct uea_softc *sc;
1455
1456 down(&uea_semaphore);
1457 sc = dev_to_uea(dev);
1458 if (!sc)
1459 goto out;
1460
1461 switch (GET_STATUS(sc->stats.phy.state)) {
1462 case 0:
1463 ret = sprintf(buf, "Modem is booting\n");
1464 break;
1465 case 1:
1466 ret = sprintf(buf, "Modem is initializing\n");
1467 break;
1468 case 2:
1469 ret = sprintf(buf, "Modem is operational\n");
1470 break;
1471 default:
1472 ret = sprintf(buf, "Modem synchronization failed\n");
1473 break;
1474 }
1475out:
1476 up(&uea_semaphore);
1477 return ret;
1478}
1479
1480static DEVICE_ATTR(stat_human_status, S_IWUGO | S_IRUGO, read_human_status, NULL);
1481
1482static ssize_t read_delin(struct device *dev, struct device_attribute *attr,
1483 char *buf)
1484{
1485 int ret = -ENODEV;
1486 struct uea_softc *sc;
1487
1488 down(&uea_semaphore);
1489 sc = dev_to_uea(dev);
1490 if (!sc)
1491 goto out;
1492
1493 if (sc->stats.phy.flags & 0x0C00)
1494 ret = sprintf(buf, "ERROR\n");
1495 else if (sc->stats.phy.flags & 0x0030)
1496 ret = sprintf(buf, "LOSS\n");
1497 else
1498 ret = sprintf(buf, "GOOD\n");
1499out:
1500 up(&uea_semaphore);
1501 return ret;
1502}
1503
1504static DEVICE_ATTR(stat_delin, S_IWUGO | S_IRUGO, read_delin, NULL);
1505
1506#define UEA_ATTR(name, reset) \
1507 \
1508static ssize_t read_##name(struct device *dev, \
1509 struct device_attribute *attr, char *buf) \
1510{ \
1511 int ret = -ENODEV; \
1512 struct uea_softc *sc; \
1513 \
1514 down(&uea_semaphore); \
1515 sc = dev_to_uea(dev); \
1516 if (!sc) \
1517 goto out; \
1518 ret = snprintf(buf, 10, "%08x\n", sc->stats.phy.name); \
1519 if (reset) \
1520 sc->stats.phy.name = 0; \
1521out: \
1522 up(&uea_semaphore); \
1523 return ret; \
1524} \
1525 \
1526static DEVICE_ATTR(stat_##name, S_IRUGO, read_##name, NULL)
1527
1528UEA_ATTR(mflags, 1);
1529UEA_ATTR(vidcpe, 0);
1530UEA_ATTR(usrate, 0);
1531UEA_ATTR(dsrate, 0);
1532UEA_ATTR(usattenuation, 0);
1533UEA_ATTR(dsattenuation, 0);
1534UEA_ATTR(usmargin, 0);
1535UEA_ATTR(dsmargin, 0);
1536UEA_ATTR(txflow, 0);
1537UEA_ATTR(rxflow, 0);
1538UEA_ATTR(uscorr, 0);
1539UEA_ATTR(dscorr, 0);
1540UEA_ATTR(usunc, 0);
1541UEA_ATTR(dsunc, 0);
1542
1543/* Retrieve the device End System Identifier (MAC) */
1544
1545#define htoi(x) (isdigit(x) ? x-'0' : toupper(x)-'A'+10)
1546static int uea_getesi(struct uea_softc *sc, u_char * esi)
1547{
1548 unsigned char mac_str[2 * ETH_ALEN + 1];
1549 int i;
1550 if (usb_string
1551 (sc->usb_dev, sc->usb_dev->descriptor.iSerialNumber, mac_str,
1552 sizeof(mac_str)) != 2 * ETH_ALEN)
1553 return 1;
1554
1555 for (i = 0; i < ETH_ALEN; i++)
1556 esi[i] = htoi(mac_str[2 * i]) * 16 + htoi(mac_str[2 * i + 1]);
1557
1558 return 0;
1559}
1560
1561/* ATM stuff */
1562static int uea_atm_open(struct usbatm_data *usbatm, struct atm_dev *atm_dev)
1563{
1564 struct uea_softc *sc = usbatm->driver_data;
1565
1566 return uea_getesi(sc, atm_dev->esi);
1567}
1568
1569static int uea_heavy(struct usbatm_data *usbatm, struct usb_interface *intf)
1570{
1571 struct uea_softc *sc = usbatm->driver_data;
1572
1573 wait_event(sc->sync_q, IS_OPERATIONAL(sc));
1574
1575 return 0;
1576
1577}
1578
1579static int claim_interface(struct usb_device *usb_dev,
1580 struct usbatm_data *usbatm, int ifnum)
1581{
1582 int ret;
1583 struct usb_interface *intf = usb_ifnum_to_if(usb_dev, ifnum);
1584
1585 if (!intf) {
1586 uea_err(usb_dev, "interface %d not found\n", ifnum);
1587 return -ENODEV;
1588 }
1589
1590 ret = usb_driver_claim_interface(&uea_driver, intf, usbatm);
1591 if (ret != 0)
1592 uea_err(usb_dev, "can't claim interface %d, error %d\n", ifnum,
1593 ret);
1594 return ret;
1595}
1596
1597static void create_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
1598{
1599 /* sysfs interface */
1600 device_create_file(&intf->dev, &dev_attr_stat_status);
1601 device_create_file(&intf->dev, &dev_attr_stat_mflags);
1602 device_create_file(&intf->dev, &dev_attr_stat_human_status);
1603 device_create_file(&intf->dev, &dev_attr_stat_delin);
1604 device_create_file(&intf->dev, &dev_attr_stat_vidcpe);
1605 device_create_file(&intf->dev, &dev_attr_stat_usrate);
1606 device_create_file(&intf->dev, &dev_attr_stat_dsrate);
1607 device_create_file(&intf->dev, &dev_attr_stat_usattenuation);
1608 device_create_file(&intf->dev, &dev_attr_stat_dsattenuation);
1609 device_create_file(&intf->dev, &dev_attr_stat_usmargin);
1610 device_create_file(&intf->dev, &dev_attr_stat_dsmargin);
1611 device_create_file(&intf->dev, &dev_attr_stat_txflow);
1612 device_create_file(&intf->dev, &dev_attr_stat_rxflow);
1613 device_create_file(&intf->dev, &dev_attr_stat_uscorr);
1614 device_create_file(&intf->dev, &dev_attr_stat_dscorr);
1615 device_create_file(&intf->dev, &dev_attr_stat_usunc);
1616 device_create_file(&intf->dev, &dev_attr_stat_dsunc);
1617}
1618
1619static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf,
1620 const struct usb_device_id *id, int *heavy)
1621{
1622 struct usb_device *usb = interface_to_usbdev(intf);
1623 struct uea_softc *sc;
1624 int ret, ifnum = intf->altsetting->desc.bInterfaceNumber;
1625
1626 uea_enters(usb);
1627
1628 /* interface 0 is for firmware/monitoring */
1629 if (ifnum != UEA_INTR_IFACE_NO)
1630 return -ENODEV;
1631
1632 *heavy = sync_wait[modem_index];
1633
1634 /* interface 1 is for outbound traffic */
1635 ret = claim_interface(usb, usbatm, UEA_US_IFACE_NO);
1636 if (ret < 0)
1637 return ret;
1638
1639 /* ADI930 has only 2 interfaces and inbound traffic
1640 * is on interface 1
1641 */
1642 if (UEA_CHIP_VERSION(id) != ADI930) {
1643 /* interface 2 is for inbound traffic */
1644 ret = claim_interface(usb, usbatm, UEA_DS_IFACE_NO);
1645 if (ret < 0)
1646 return ret;
1647 }
1648
1649 sc = kzalloc(sizeof(struct uea_softc), GFP_KERNEL);
1650 if (!sc) {
1651 uea_err(INS_TO_USBDEV(sc), "uea_init: not enough memory !\n");
1652 return -ENOMEM;
1653 }
1654
1655 sc->usb_dev = usb;
1656 usbatm->driver_data = sc;
1657 sc->usbatm = usbatm;
1658 sc->modem_index = (modem_index < NB_MODEM) ? modem_index++ : 0;
1659 sc->driver_info = id->driver_info;
1660
1661 ret = uea_boot(sc);
1662 if (ret < 0) {
1663 kfree(sc);
1664 return ret;
1665 }
1666
1667 create_fs_entries(sc, intf);
1668 return 0;
1669}
1670
1671static void destroy_fs_entries(struct uea_softc *sc, struct usb_interface *intf)
1672{
1673 /* sysfs interface */
1674 device_remove_file(&intf->dev, &dev_attr_stat_status);
1675 device_remove_file(&intf->dev, &dev_attr_stat_mflags);
1676 device_remove_file(&intf->dev, &dev_attr_stat_human_status);
1677 device_remove_file(&intf->dev, &dev_attr_stat_delin);
1678 device_remove_file(&intf->dev, &dev_attr_stat_vidcpe);
1679 device_remove_file(&intf->dev, &dev_attr_stat_usrate);
1680 device_remove_file(&intf->dev, &dev_attr_stat_dsrate);
1681 device_remove_file(&intf->dev, &dev_attr_stat_usattenuation);
1682 device_remove_file(&intf->dev, &dev_attr_stat_dsattenuation);
1683 device_remove_file(&intf->dev, &dev_attr_stat_usmargin);
1684 device_remove_file(&intf->dev, &dev_attr_stat_dsmargin);
1685 device_remove_file(&intf->dev, &dev_attr_stat_txflow);
1686 device_remove_file(&intf->dev, &dev_attr_stat_rxflow);
1687 device_remove_file(&intf->dev, &dev_attr_stat_uscorr);
1688 device_remove_file(&intf->dev, &dev_attr_stat_dscorr);
1689 device_remove_file(&intf->dev, &dev_attr_stat_usunc);
1690 device_remove_file(&intf->dev, &dev_attr_stat_dsunc);
1691}
1692
1693static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf)
1694{
1695 struct uea_softc *sc = usbatm->driver_data;
1696
1697 destroy_fs_entries(sc, intf);
1698 uea_stop(sc);
1699 kfree(sc);
1700}
1701
1702static struct usbatm_driver uea_usbatm_driver = {
1703 .driver_name = "ueagle-atm",
1704 .owner = THIS_MODULE,
1705 .bind = uea_bind,
1706 .atm_start = uea_atm_open,
1707 .unbind = uea_unbind,
1708 .heavy_init = uea_heavy,
1709 .in = UEA_BULK_DATA_PIPE,
1710 .out = UEA_BULK_DATA_PIPE,
1711};
1712
1713static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
1714{
1715 struct usb_device *usb = interface_to_usbdev(intf);
1716
1717 uea_enters(usb);
1718 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) : %s\n",
1719 le16_to_cpu(usb->descriptor.idVendor),
1720 le16_to_cpu(usb->descriptor.idProduct),
1721 chip_name[UEA_CHIP_VERSION(id)]);
1722
1723 usb_reset_device(usb);
1724
1725 if (UEA_IS_PREFIRM(id))
1726 return uea_load_firmware(usb, UEA_CHIP_VERSION(id));
1727
1728 return usbatm_usb_probe(intf, id, &uea_usbatm_driver);
1729}
1730
1731static void uea_disconnect(struct usb_interface *intf)
1732{
1733 struct usb_device *usb = interface_to_usbdev(intf);
1734 int ifnum = intf->altsetting->desc.bInterfaceNumber;
1735 uea_enters(usb);
1736
1737 /* ADI930 has 2 interfaces and eagle 3 interfaces.
1738 * Pre-firmware device has one interface
1739 */
1740 if (usb->config->desc.bNumInterfaces != 1 && ifnum == 0) {
1741 down(&uea_semaphore);
1742 usbatm_usb_disconnect(intf);
1743 up(&uea_semaphore);
1744 uea_info(usb, "ADSL device removed\n");
1745 }
1746
1747 uea_leaves(usb);
1748}
1749
1750/*
1751 * List of supported VID/PID
1752 */
1753static const struct usb_device_id uea_ids[] = {
1754 {USB_DEVICE(ELSA_VID, ELSA_PID_PREFIRM), .driver_info = ADI930 | PREFIRM},
1755 {USB_DEVICE(ELSA_VID, ELSA_PID_PSTFIRM), .driver_info = ADI930 | PSTFIRM},
1756 {USB_DEVICE(EAGLE_VID, EAGLE_I_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM},
1757 {USB_DEVICE(EAGLE_VID, EAGLE_I_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM},
1758 {USB_DEVICE(EAGLE_VID, EAGLE_II_PID_PREFIRM), .driver_info = EAGLE_II | PREFIRM},
1759 {USB_DEVICE(EAGLE_VID, EAGLE_II_PID_PSTFIRM), .driver_info = EAGLE_II | PSTFIRM},
1760 {USB_DEVICE(EAGLE_VID, EAGLE_IIC_PID_PREFIRM), .driver_info = EAGLE_II | PREFIRM},
1761 {USB_DEVICE(EAGLE_VID, EAGLE_IIC_PID_PSTFIRM), .driver_info = EAGLE_II | PSTFIRM},
1762 {USB_DEVICE(EAGLE_VID, EAGLE_III_PID_PREFIRM), .driver_info = EAGLE_III | PREFIRM},
1763 {USB_DEVICE(EAGLE_VID, EAGLE_III_PID_PSTFIRM), .driver_info = EAGLE_III | PSTFIRM},
1764 {USB_DEVICE(USR_VID, MILLER_A_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM},
1765 {USB_DEVICE(USR_VID, MILLER_A_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM},
1766 {USB_DEVICE(USR_VID, MILLER_B_PID_PREFIRM), .driver_info = EAGLE_I | PREFIRM},
1767 {USB_DEVICE(USR_VID, MILLER_B_PID_PSTFIRM), .driver_info = EAGLE_I | PSTFIRM},
1768 {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PREFIRM),.driver_info = EAGLE_I | PREFIRM},
1769 {USB_DEVICE(USR_VID, HEINEKEN_A_PID_PSTFIRM),.driver_info = EAGLE_I | PSTFIRM},
1770 {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PREFIRM),.driver_info = EAGLE_I | PREFIRM},
1771 {USB_DEVICE(USR_VID, HEINEKEN_B_PID_PSTFIRM),.driver_info = EAGLE_I | PSTFIRM},
1772 {}
1773};
1774
1775/*
1776 * USB driver descriptor
1777 */
1778static struct usb_driver uea_driver = {
1779 .name = "ueagle-atm",
1780 .id_table = uea_ids,
1781 .probe = uea_probe,
1782 .disconnect = uea_disconnect,
1783};
1784
1785MODULE_DEVICE_TABLE(usb, uea_ids);
1786
1787/**
1788 * uea_init - Initialize the module.
1789 * Register to USB subsystem
1790 */
1791static int __init uea_init(void)
1792{
1793 printk(KERN_INFO "[ueagle-atm] driver " EAGLEUSBVERSION " loaded\n");
1794
1795 usb_register(&uea_driver);
1796
1797 return 0;
1798}
1799
1800module_init(uea_init);
1801
1802/**
1803 * uea_exit - Destroy module
1804 * Deregister with USB subsystem
1805 */
1806static void __exit uea_exit(void)
1807{
1808 /*
1809 * This calls automatically the uea_disconnect method if necessary:
1810 */
1811 usb_deregister(&uea_driver);
1812
1813 printk(KERN_INFO "[ueagle-atm] driver unloaded\n");
1814}
1815
1816module_exit(uea_exit);
1817
1818MODULE_AUTHOR("Damien Bergamini/Matthieu Castet/Stanislaw W. Gruszka");
1819MODULE_DESCRIPTION("ADI 930/Eagle USB ADSL Modem driver");
1820MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index 2e6593e6c1bd..9baa6296fc95 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -646,14 +646,14 @@ static void usbatm_destroy_instance(struct kref *kref)
646 kfree(instance); 646 kfree(instance);
647} 647}
648 648
649void usbatm_get_instance(struct usbatm_data *instance) 649static void usbatm_get_instance(struct usbatm_data *instance)
650{ 650{
651 dbg("%s", __func__); 651 dbg("%s", __func__);
652 652
653 kref_get(&instance->refcount); 653 kref_get(&instance->refcount);
654} 654}
655 655
656void usbatm_put_instance(struct usbatm_data *instance) 656static void usbatm_put_instance(struct usbatm_data *instance)
657{ 657{
658 dbg("%s", __func__); 658 dbg("%s", __func__);
659 659
diff --git a/drivers/usb/atm/xusbatm.c b/drivers/usb/atm/xusbatm.c
index 7fe7fb484d10..5c76e3aaaa5e 100644
--- a/drivers/usb/atm/xusbatm.c
+++ b/drivers/usb/atm/xusbatm.c
@@ -140,7 +140,6 @@ static int xusbatm_usb_probe(struct usb_interface *intf,
140} 140}
141 141
142static struct usb_driver xusbatm_usb_driver = { 142static struct usb_driver xusbatm_usb_driver = {
143 .owner = THIS_MODULE,
144 .name = xusbatm_driver_name, 143 .name = xusbatm_driver_name,
145 .probe = xusbatm_usb_probe, 144 .probe = xusbatm_usb_probe,
146 .disconnect = usbatm_usb_disconnect, 145 .disconnect = usbatm_usb_disconnect,
diff --git a/drivers/usb/class/audio.c b/drivers/usb/class/audio.c
index 50858273f8d3..3ad9ee8b84a9 100644
--- a/drivers/usb/class/audio.c
+++ b/drivers/usb/class/audio.c
@@ -2732,7 +2732,6 @@ static struct usb_device_id usb_audio_ids [] = {
2732MODULE_DEVICE_TABLE (usb, usb_audio_ids); 2732MODULE_DEVICE_TABLE (usb, usb_audio_ids);
2733 2733
2734static struct usb_driver usb_audio_driver = { 2734static struct usb_driver usb_audio_driver = {
2735 .owner = THIS_MODULE,
2736 .name = "audio", 2735 .name = "audio",
2737 .probe = usb_audio_probe, 2736 .probe = usb_audio_probe,
2738 .disconnect = usb_audio_disconnect, 2737 .disconnect = usb_audio_disconnect,
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index 1b4751412970..248279e44c99 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -6,6 +6,7 @@
6 * Copyright (c) 1999 Johannes Erdfelt <johannes@erdfelt.com> 6 * Copyright (c) 1999 Johannes Erdfelt <johannes@erdfelt.com>
7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz> 7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
8 * Copyright (c) 2004 Oliver Neukum <oliver@neukum.name> 8 * Copyright (c) 2004 Oliver Neukum <oliver@neukum.name>
9 * Copyright (c) 2005 David Kubicek <dave@awk.cz>
9 * 10 *
10 * USB Abstract Control Model driver for USB modems and ISDN adapters 11 * USB Abstract Control Model driver for USB modems and ISDN adapters
11 * 12 *
@@ -29,6 +30,7 @@
29 * config we want, sysadmin changes bConfigurationValue in sysfs. 30 * config we want, sysadmin changes bConfigurationValue in sysfs.
30 * v0.23 - use softirq for rx processing, as needed by tty layer 31 * v0.23 - use softirq for rx processing, as needed by tty layer
31 * v0.24 - change probe method to evaluate CDC union descriptor 32 * v0.24 - change probe method to evaluate CDC union descriptor
33 * v0.25 - downstream tasks paralelized to maximize throughput
32 */ 34 */
33 35
34/* 36/*
@@ -63,14 +65,15 @@
63#include <linux/usb_cdc.h> 65#include <linux/usb_cdc.h>
64#include <asm/byteorder.h> 66#include <asm/byteorder.h>
65#include <asm/unaligned.h> 67#include <asm/unaligned.h>
68#include <linux/list.h>
66 69
67#include "cdc-acm.h" 70#include "cdc-acm.h"
68 71
69/* 72/*
70 * Version Information 73 * Version Information
71 */ 74 */
72#define DRIVER_VERSION "v0.23" 75#define DRIVER_VERSION "v0.25"
73#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik" 76#define DRIVER_AUTHOR "Armin Fuerst, Pavel Machek, Johannes Erdfelt, Vojtech Pavlik, David Kubicek"
74#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters" 77#define DRIVER_DESC "USB Abstract Control Model driver for USB modems and ISDN adapters"
75 78
76static struct usb_driver acm_driver; 79static struct usb_driver acm_driver;
@@ -284,7 +287,9 @@ exit:
284/* data interface returns incoming bytes, or we got unthrottled */ 287/* data interface returns incoming bytes, or we got unthrottled */
285static void acm_read_bulk(struct urb *urb, struct pt_regs *regs) 288static void acm_read_bulk(struct urb *urb, struct pt_regs *regs)
286{ 289{
287 struct acm *acm = urb->context; 290 struct acm_rb *buf;
291 struct acm_ru *rcv = urb->context;
292 struct acm *acm = rcv->instance;
288 dbg("Entering acm_read_bulk with status %d\n", urb->status); 293 dbg("Entering acm_read_bulk with status %d\n", urb->status);
289 294
290 if (!ACM_READY(acm)) 295 if (!ACM_READY(acm))
@@ -293,49 +298,109 @@ static void acm_read_bulk(struct urb *urb, struct pt_regs *regs)
293 if (urb->status) 298 if (urb->status)
294 dev_dbg(&acm->data->dev, "bulk rx status %d\n", urb->status); 299 dev_dbg(&acm->data->dev, "bulk rx status %d\n", urb->status);
295 300
296 /* calling tty_flip_buffer_push() in_irq() isn't allowed */ 301 buf = rcv->buffer;
297 tasklet_schedule(&acm->bh); 302 buf->size = urb->actual_length;
303
304 spin_lock(&acm->read_lock);
305 list_add_tail(&rcv->list, &acm->spare_read_urbs);
306 list_add_tail(&buf->list, &acm->filled_read_bufs);
307 spin_unlock(&acm->read_lock);
308
309 tasklet_schedule(&acm->urb_task);
298} 310}
299 311
300static void acm_rx_tasklet(unsigned long _acm) 312static void acm_rx_tasklet(unsigned long _acm)
301{ 313{
302 struct acm *acm = (void *)_acm; 314 struct acm *acm = (void *)_acm;
303 struct urb *urb = acm->readurb; 315 struct acm_rb *buf;
304 struct tty_struct *tty = acm->tty; 316 struct tty_struct *tty = acm->tty;
305 unsigned char *data = urb->transfer_buffer; 317 struct acm_ru *rcv;
318 //unsigned long flags;
306 int i = 0; 319 int i = 0;
307 dbg("Entering acm_rx_tasklet"); 320 dbg("Entering acm_rx_tasklet");
308 321
309 if (urb->actual_length > 0 && !acm->throttle) { 322 if (!ACM_READY(acm) || acm->throttle)
310 for (i = 0; i < urb->actual_length && !acm->throttle; i++) { 323 return;
311 /* if we insert more than TTY_FLIPBUF_SIZE characters, 324
312 * we drop them. */ 325next_buffer:
313 if (tty->flip.count >= TTY_FLIPBUF_SIZE) { 326 spin_lock(&acm->read_lock);
314 tty_flip_buffer_push(tty); 327 if (list_empty(&acm->filled_read_bufs)) {
315 } 328 spin_unlock(&acm->read_lock);
316 tty_insert_flip_char(tty, data[i], 0); 329 goto urbs;
317 }
318 dbg("Handed %d bytes to tty layer", i+1);
319 tty_flip_buffer_push(tty);
320 } 330 }
331 buf = list_entry(acm->filled_read_bufs.next,
332 struct acm_rb, list);
333 list_del(&buf->list);
334 spin_unlock(&acm->read_lock);
335
336 dbg("acm_rx_tasklet: procesing buf 0x%p, size = %d\n", buf, buf->size);
337
338 for (i = 0; i < buf->size && !acm->throttle; i++) {
339 /* if we insert more than TTY_FLIPBUF_SIZE characters,
340 we drop them. */
341 if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
342 tty_flip_buffer_push(tty);
343 }
344 tty_insert_flip_char(tty, buf->base[i], 0);
345 }
346 tty_flip_buffer_push(tty);
321 347
322 spin_lock(&acm->throttle_lock); 348 spin_lock(&acm->throttle_lock);
323 if (acm->throttle) { 349 if (acm->throttle) {
324 dbg("Throtteling noticed"); 350 dbg("Throtteling noticed");
325 memmove(data, data + i, urb->actual_length - i); 351 memmove(buf->base, buf->base + i, buf->size - i);
326 urb->actual_length -= i; 352 buf->size -= i;
327 acm->resubmit_to_unthrottle = 1;
328 spin_unlock(&acm->throttle_lock); 353 spin_unlock(&acm->throttle_lock);
354 spin_lock(&acm->read_lock);
355 list_add(&buf->list, &acm->filled_read_bufs);
356 spin_unlock(&acm->read_lock);
329 return; 357 return;
330 } 358 }
331 spin_unlock(&acm->throttle_lock); 359 spin_unlock(&acm->throttle_lock);
332 360
333 urb->actual_length = 0; 361 spin_lock(&acm->read_lock);
334 urb->dev = acm->dev; 362 list_add(&buf->list, &acm->spare_read_bufs);
335 363 spin_unlock(&acm->read_lock);
336 i = usb_submit_urb(urb, GFP_ATOMIC); 364 goto next_buffer;
337 if (i) 365
338 dev_dbg(&acm->data->dev, "bulk rx resubmit %d\n", i); 366urbs:
367 while (!list_empty(&acm->spare_read_bufs)) {
368 spin_lock(&acm->read_lock);
369 if (list_empty(&acm->spare_read_urbs)) {
370 spin_unlock(&acm->read_lock);
371 return;
372 }
373 rcv = list_entry(acm->spare_read_urbs.next,
374 struct acm_ru, list);
375 list_del(&rcv->list);
376 spin_unlock(&acm->read_lock);
377
378 buf = list_entry(acm->spare_read_bufs.next,
379 struct acm_rb, list);
380 list_del(&buf->list);
381
382 rcv->buffer = buf;
383
384 usb_fill_bulk_urb(rcv->urb, acm->dev,
385 acm->rx_endpoint,
386 buf->base,
387 acm->readsize,
388 acm_read_bulk, rcv);
389 rcv->urb->transfer_dma = buf->dma;
390 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
391
392 dbg("acm_rx_tasklet: sending urb 0x%p, rcv 0x%p, buf 0x%p\n", rcv->urb, rcv, buf);
393
394 /* This shouldn't kill the driver as unsuccessful URBs are returned to the
395 free-urbs-pool and resubmited ASAP */
396 if (usb_submit_urb(rcv->urb, GFP_ATOMIC) < 0) {
397 list_add(&buf->list, &acm->spare_read_bufs);
398 spin_lock(&acm->read_lock);
399 list_add(&rcv->list, &acm->spare_read_urbs);
400 spin_unlock(&acm->read_lock);
401 return;
402 }
403 }
339} 404}
340 405
341/* data interface wrote those outgoing bytes */ 406/* data interface wrote those outgoing bytes */
@@ -369,6 +434,7 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
369{ 434{
370 struct acm *acm; 435 struct acm *acm;
371 int rv = -EINVAL; 436 int rv = -EINVAL;
437 int i;
372 dbg("Entering acm_tty_open.\n"); 438 dbg("Entering acm_tty_open.\n");
373 439
374 down(&open_sem); 440 down(&open_sem);
@@ -382,7 +448,9 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
382 tty->driver_data = acm; 448 tty->driver_data = acm;
383 acm->tty = tty; 449 acm->tty = tty;
384 450
385 451 /* force low_latency on so that our tty_push actually forces the data through,
452 otherwise it is scheduled, and with high data rates data can get lost. */
453 tty->low_latency = 1;
386 454
387 if (acm->used++) { 455 if (acm->used++) {
388 goto done; 456 goto done;
@@ -394,18 +462,20 @@ static int acm_tty_open(struct tty_struct *tty, struct file *filp)
394 goto bail_out; 462 goto bail_out;
395 } 463 }
396 464
397 acm->readurb->dev = acm->dev;
398 if (usb_submit_urb(acm->readurb, GFP_KERNEL)) {
399 dbg("usb_submit_urb(read bulk) failed");
400 goto bail_out_and_unlink;
401 }
402
403 if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS)) 465 if (0 > acm_set_control(acm, acm->ctrlout = ACM_CTRL_DTR | ACM_CTRL_RTS))
404 goto full_bailout; 466 goto full_bailout;
405 467
406 /* force low_latency on so that our tty_push actually forces the data through, 468 INIT_LIST_HEAD(&acm->spare_read_urbs);
407 otherwise it is scheduled, and with high data rates data can get lost. */ 469 INIT_LIST_HEAD(&acm->spare_read_bufs);
408 tty->low_latency = 1; 470 INIT_LIST_HEAD(&acm->filled_read_bufs);
471 for (i = 0; i < ACM_NRU; i++) {
472 list_add(&(acm->ru[i].list), &acm->spare_read_urbs);
473 }
474 for (i = 0; i < ACM_NRB; i++) {
475 list_add(&(acm->rb[i].list), &acm->spare_read_bufs);
476 }
477
478 tasklet_schedule(&acm->urb_task);
409 479
410done: 480done:
411err_out: 481err_out:
@@ -413,8 +483,6 @@ err_out:
413 return rv; 483 return rv;
414 484
415full_bailout: 485full_bailout:
416 usb_kill_urb(acm->readurb);
417bail_out_and_unlink:
418 usb_kill_urb(acm->ctrlurb); 486 usb_kill_urb(acm->ctrlurb);
419bail_out: 487bail_out:
420 acm->used--; 488 acm->used--;
@@ -424,18 +492,22 @@ bail_out:
424 492
425static void acm_tty_unregister(struct acm *acm) 493static void acm_tty_unregister(struct acm *acm)
426{ 494{
495 int i;
496
427 tty_unregister_device(acm_tty_driver, acm->minor); 497 tty_unregister_device(acm_tty_driver, acm->minor);
428 usb_put_intf(acm->control); 498 usb_put_intf(acm->control);
429 acm_table[acm->minor] = NULL; 499 acm_table[acm->minor] = NULL;
430 usb_free_urb(acm->ctrlurb); 500 usb_free_urb(acm->ctrlurb);
431 usb_free_urb(acm->readurb);
432 usb_free_urb(acm->writeurb); 501 usb_free_urb(acm->writeurb);
502 for (i = 0; i < ACM_NRU; i++)
503 usb_free_urb(acm->ru[i].urb);
433 kfree(acm); 504 kfree(acm);
434} 505}
435 506
436static void acm_tty_close(struct tty_struct *tty, struct file *filp) 507static void acm_tty_close(struct tty_struct *tty, struct file *filp)
437{ 508{
438 struct acm *acm = tty->driver_data; 509 struct acm *acm = tty->driver_data;
510 int i;
439 511
440 if (!acm || !acm->used) 512 if (!acm || !acm->used)
441 return; 513 return;
@@ -446,7 +518,8 @@ static void acm_tty_close(struct tty_struct *tty, struct file *filp)
446 acm_set_control(acm, acm->ctrlout = 0); 518 acm_set_control(acm, acm->ctrlout = 0);
447 usb_kill_urb(acm->ctrlurb); 519 usb_kill_urb(acm->ctrlurb);
448 usb_kill_urb(acm->writeurb); 520 usb_kill_urb(acm->writeurb);
449 usb_kill_urb(acm->readurb); 521 for (i = 0; i < ACM_NRU; i++)
522 usb_kill_urb(acm->ru[i].urb);
450 } else 523 } else
451 acm_tty_unregister(acm); 524 acm_tty_unregister(acm);
452 } 525 }
@@ -528,10 +601,7 @@ static void acm_tty_unthrottle(struct tty_struct *tty)
528 spin_lock_bh(&acm->throttle_lock); 601 spin_lock_bh(&acm->throttle_lock);
529 acm->throttle = 0; 602 acm->throttle = 0;
530 spin_unlock_bh(&acm->throttle_lock); 603 spin_unlock_bh(&acm->throttle_lock);
531 if (acm->resubmit_to_unthrottle) { 604 tasklet_schedule(&acm->urb_task);
532 acm->resubmit_to_unthrottle = 0;
533 acm_read_bulk(acm->readurb, NULL);
534 }
535} 605}
536 606
537static void acm_tty_break_ctl(struct tty_struct *tty, int state) 607static void acm_tty_break_ctl(struct tty_struct *tty, int state)
@@ -588,7 +658,7 @@ static int acm_tty_ioctl(struct tty_struct *tty, struct file *file, unsigned int
588 return -ENOIOCTLCMD; 658 return -ENOIOCTLCMD;
589} 659}
590 660
591static __u32 acm_tty_speed[] = { 661static const __u32 acm_tty_speed[] = {
592 0, 50, 75, 110, 134, 150, 200, 300, 600, 662 0, 50, 75, 110, 134, 150, 200, 300, 600,
593 1200, 1800, 2400, 4800, 9600, 19200, 38400, 663 1200, 1800, 2400, 4800, 9600, 19200, 38400,
594 57600, 115200, 230400, 460800, 500000, 576000, 664 57600, 115200, 230400, 460800, 500000, 576000,
@@ -596,7 +666,7 @@ static __u32 acm_tty_speed[] = {
596 2500000, 3000000, 3500000, 4000000 666 2500000, 3000000, 3500000, 4000000
597}; 667};
598 668
599static __u8 acm_tty_size[] = { 669static const __u8 acm_tty_size[] = {
600 5, 6, 7, 8 670 5, 6, 7, 8
601}; 671};
602 672
@@ -694,6 +764,7 @@ static int acm_probe (struct usb_interface *intf,
694 int call_interface_num = -1; 764 int call_interface_num = -1;
695 int data_interface_num; 765 int data_interface_num;
696 unsigned long quirks; 766 unsigned long quirks;
767 int i;
697 768
698 /* handle quirks deadly to normal probing*/ 769 /* handle quirks deadly to normal probing*/
699 quirks = (unsigned long)id->driver_info; 770 quirks = (unsigned long)id->driver_info;
@@ -833,7 +904,7 @@ skip_normal_probe:
833 } 904 }
834 905
835 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize); 906 ctrlsize = le16_to_cpu(epctrl->wMaxPacketSize);
836 readsize = le16_to_cpu(epread->wMaxPacketSize); 907 readsize = le16_to_cpu(epread->wMaxPacketSize)*2;
837 acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize); 908 acm->writesize = le16_to_cpu(epwrite->wMaxPacketSize);
838 acm->control = control_interface; 909 acm->control = control_interface;
839 acm->data = data_interface; 910 acm->data = data_interface;
@@ -842,12 +913,14 @@ skip_normal_probe:
842 acm->ctrl_caps = ac_management_function; 913 acm->ctrl_caps = ac_management_function;
843 acm->ctrlsize = ctrlsize; 914 acm->ctrlsize = ctrlsize;
844 acm->readsize = readsize; 915 acm->readsize = readsize;
845 acm->bh.func = acm_rx_tasklet; 916 acm->urb_task.func = acm_rx_tasklet;
846 acm->bh.data = (unsigned long) acm; 917 acm->urb_task.data = (unsigned long) acm;
847 INIT_WORK(&acm->work, acm_softint, acm); 918 INIT_WORK(&acm->work, acm_softint, acm);
848 spin_lock_init(&acm->throttle_lock); 919 spin_lock_init(&acm->throttle_lock);
849 spin_lock_init(&acm->write_lock); 920 spin_lock_init(&acm->write_lock);
921 spin_lock_init(&acm->read_lock);
850 acm->write_ready = 1; 922 acm->write_ready = 1;
923 acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
851 924
852 buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma); 925 buf = usb_buffer_alloc(usb_dev, ctrlsize, GFP_KERNEL, &acm->ctrl_dma);
853 if (!buf) { 926 if (!buf) {
@@ -856,13 +929,6 @@ skip_normal_probe:
856 } 929 }
857 acm->ctrl_buffer = buf; 930 acm->ctrl_buffer = buf;
858 931
859 buf = usb_buffer_alloc(usb_dev, readsize, GFP_KERNEL, &acm->read_dma);
860 if (!buf) {
861 dev_dbg(&intf->dev, "out of memory (read buffer alloc)\n");
862 goto alloc_fail3;
863 }
864 acm->read_buffer = buf;
865
866 if (acm_write_buffers_alloc(acm) < 0) { 932 if (acm_write_buffers_alloc(acm) < 0) {
867 dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n"); 933 dev_dbg(&intf->dev, "out of memory (write buffer alloc)\n");
868 goto alloc_fail4; 934 goto alloc_fail4;
@@ -873,10 +939,25 @@ skip_normal_probe:
873 dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n"); 939 dev_dbg(&intf->dev, "out of memory (ctrlurb kmalloc)\n");
874 goto alloc_fail5; 940 goto alloc_fail5;
875 } 941 }
876 acm->readurb = usb_alloc_urb(0, GFP_KERNEL); 942 for (i = 0; i < ACM_NRU; i++) {
877 if (!acm->readurb) { 943 struct acm_ru *rcv = &(acm->ru[i]);
878 dev_dbg(&intf->dev, "out of memory (readurb kmalloc)\n"); 944
879 goto alloc_fail6; 945 if (!(rcv->urb = usb_alloc_urb(0, GFP_KERNEL))) {
946 dev_dbg(&intf->dev, "out of memory (read urbs usb_alloc_urb)\n");
947 goto alloc_fail7;
948 }
949
950 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
951 rcv->instance = acm;
952 }
953 for (i = 0; i < ACM_NRB; i++) {
954 struct acm_rb *buf = &(acm->rb[i]);
955
956 // Using usb_buffer_alloc instead of kmalloc as Oliver suggested
957 if (!(buf->base = usb_buffer_alloc(acm->dev, readsize, GFP_KERNEL, &buf->dma))) {
958 dev_dbg(&intf->dev, "out of memory (read bufs usb_buffer_alloc)\n");
959 goto alloc_fail7;
960 }
880 } 961 }
881 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL); 962 acm->writeurb = usb_alloc_urb(0, GFP_KERNEL);
882 if (!acm->writeurb) { 963 if (!acm->writeurb) {
@@ -889,15 +970,9 @@ skip_normal_probe:
889 acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 970 acm->ctrlurb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
890 acm->ctrlurb->transfer_dma = acm->ctrl_dma; 971 acm->ctrlurb->transfer_dma = acm->ctrl_dma;
891 972
892 usb_fill_bulk_urb(acm->readurb, usb_dev, usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress),
893 acm->read_buffer, readsize, acm_read_bulk, acm);
894 acm->readurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP;
895 acm->readurb->transfer_dma = acm->read_dma;
896
897 usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress), 973 usb_fill_bulk_urb(acm->writeurb, usb_dev, usb_sndbulkpipe(usb_dev, epwrite->bEndpointAddress),
898 NULL, acm->writesize, acm_write_bulk, acm); 974 NULL, acm->writesize, acm_write_bulk, acm);
899 acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP; 975 acm->writeurb->transfer_flags |= URB_NO_FSBR | URB_NO_TRANSFER_DMA_MAP;
900 /* acm->writeurb->transfer_dma = 0; */
901 976
902 dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor); 977 dev_info(&intf->dev, "ttyACM%d: USB ACM device\n", minor);
903 978
@@ -917,14 +992,14 @@ skip_normal_probe:
917 return 0; 992 return 0;
918 993
919alloc_fail7: 994alloc_fail7:
920 usb_free_urb(acm->readurb); 995 for (i = 0; i < ACM_NRB; i++)
921alloc_fail6: 996 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma);
997 for (i = 0; i < ACM_NRU; i++)
998 usb_free_urb(acm->ru[i].urb);
922 usb_free_urb(acm->ctrlurb); 999 usb_free_urb(acm->ctrlurb);
923alloc_fail5: 1000alloc_fail5:
924 acm_write_buffers_free(acm); 1001 acm_write_buffers_free(acm);
925alloc_fail4: 1002alloc_fail4:
926 usb_buffer_free(usb_dev, readsize, acm->read_buffer, acm->read_dma);
927alloc_fail3:
928 usb_buffer_free(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); 1003 usb_buffer_free(usb_dev, ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
929alloc_fail2: 1004alloc_fail2:
930 kfree(acm); 1005 kfree(acm);
@@ -936,6 +1011,7 @@ static void acm_disconnect(struct usb_interface *intf)
936{ 1011{
937 struct acm *acm = usb_get_intfdata (intf); 1012 struct acm *acm = usb_get_intfdata (intf);
938 struct usb_device *usb_dev = interface_to_usbdev(intf); 1013 struct usb_device *usb_dev = interface_to_usbdev(intf);
1014 int i;
939 1015
940 if (!acm || !acm->dev) { 1016 if (!acm || !acm->dev) {
941 dbg("disconnect on nonexisting interface"); 1017 dbg("disconnect on nonexisting interface");
@@ -946,15 +1022,24 @@ static void acm_disconnect(struct usb_interface *intf)
946 acm->dev = NULL; 1022 acm->dev = NULL;
947 usb_set_intfdata (intf, NULL); 1023 usb_set_intfdata (intf, NULL);
948 1024
1025 tasklet_disable(&acm->urb_task);
1026
949 usb_kill_urb(acm->ctrlurb); 1027 usb_kill_urb(acm->ctrlurb);
950 usb_kill_urb(acm->readurb);
951 usb_kill_urb(acm->writeurb); 1028 usb_kill_urb(acm->writeurb);
1029 for (i = 0; i < ACM_NRU; i++)
1030 usb_kill_urb(acm->ru[i].urb);
1031
1032 INIT_LIST_HEAD(&acm->filled_read_bufs);
1033 INIT_LIST_HEAD(&acm->spare_read_bufs);
1034
1035 tasklet_enable(&acm->urb_task);
952 1036
953 flush_scheduled_work(); /* wait for acm_softint */ 1037 flush_scheduled_work(); /* wait for acm_softint */
954 1038
955 acm_write_buffers_free(acm); 1039 acm_write_buffers_free(acm);
956 usb_buffer_free(usb_dev, acm->readsize, acm->read_buffer, acm->read_dma);
957 usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma); 1040 usb_buffer_free(usb_dev, acm->ctrlsize, acm->ctrl_buffer, acm->ctrl_dma);
1041 for (i = 0; i < ACM_NRB; i++)
1042 usb_buffer_free(usb_dev, acm->readsize, acm->rb[i].base, acm->rb[i].dma);
958 1043
959 usb_driver_release_interface(&acm_driver, acm->data); 1044 usb_driver_release_interface(&acm_driver, acm->data);
960 1045
@@ -1003,7 +1088,6 @@ static struct usb_device_id acm_ids[] = {
1003MODULE_DEVICE_TABLE (usb, acm_ids); 1088MODULE_DEVICE_TABLE (usb, acm_ids);
1004 1089
1005static struct usb_driver acm_driver = { 1090static struct usb_driver acm_driver = {
1006 .owner = THIS_MODULE,
1007 .name = "cdc_acm", 1091 .name = "cdc_acm",
1008 .probe = acm_probe, 1092 .probe = acm_probe,
1009 .disconnect = acm_disconnect, 1093 .disconnect = acm_disconnect,
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 963a5dfd2096..fd2aaccdcbac 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -59,6 +59,9 @@
59 * when processing onlcr, so we only need 2 buffers. 59 * when processing onlcr, so we only need 2 buffers.
60 */ 60 */
61#define ACM_NWB 2 61#define ACM_NWB 2
62#define ACM_NRU 16
63#define ACM_NRB 16
64
62struct acm_wb { 65struct acm_wb {
63 unsigned char *buf; 66 unsigned char *buf;
64 dma_addr_t dmah; 67 dma_addr_t dmah;
@@ -66,22 +69,43 @@ struct acm_wb {
66 int use; 69 int use;
67}; 70};
68 71
72struct acm_rb {
73 struct list_head list;
74 int size;
75 unsigned char *base;
76 dma_addr_t dma;
77};
78
79struct acm_ru {
80 struct list_head list;
81 struct acm_rb *buffer;
82 struct urb *urb;
83 struct acm *instance;
84};
85
69struct acm { 86struct acm {
70 struct usb_device *dev; /* the corresponding usb device */ 87 struct usb_device *dev; /* the corresponding usb device */
71 struct usb_interface *control; /* control interface */ 88 struct usb_interface *control; /* control interface */
72 struct usb_interface *data; /* data interface */ 89 struct usb_interface *data; /* data interface */
73 struct tty_struct *tty; /* the corresponding tty */ 90 struct tty_struct *tty; /* the corresponding tty */
74 struct urb *ctrlurb, *readurb, *writeurb; /* urbs */ 91 struct urb *ctrlurb, *writeurb; /* urbs */
75 u8 *ctrl_buffer, *read_buffer; /* buffers of urbs */ 92 u8 *ctrl_buffer; /* buffers of urbs */
76 dma_addr_t ctrl_dma, read_dma; /* dma handles of buffers */ 93 dma_addr_t ctrl_dma; /* dma handles of buffers */
77 struct acm_wb wb[ACM_NWB]; 94 struct acm_wb wb[ACM_NWB];
95 struct acm_ru ru[ACM_NRU];
96 struct acm_rb rb[ACM_NRB];
97 int rx_endpoint;
98 spinlock_t read_lock;
99 struct list_head spare_read_urbs;
100 struct list_head spare_read_bufs;
101 struct list_head filled_read_bufs;
78 int write_current; /* current write buffer */ 102 int write_current; /* current write buffer */
79 int write_used; /* number of non-empty write buffers */ 103 int write_used; /* number of non-empty write buffers */
80 int write_ready; /* write urb is not running */ 104 int write_ready; /* write urb is not running */
81 spinlock_t write_lock; 105 spinlock_t write_lock;
82 struct usb_cdc_line_coding line; /* bits, stop, parity */ 106 struct usb_cdc_line_coding line; /* bits, stop, parity */
83 struct work_struct work; /* work queue entry for line discipline waking up */ 107 struct work_struct work; /* work queue entry for line discipline waking up */
84 struct tasklet_struct bh; /* rx processing */ 108 struct tasklet_struct urb_task; /* rx processing */
85 spinlock_t throttle_lock; /* synchronize throtteling and read callback */ 109 spinlock_t throttle_lock; /* synchronize throtteling and read callback */
86 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */ 110 unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
87 unsigned int ctrlout; /* output control lines (DTR, RTS) */ 111 unsigned int ctrlout; /* output control lines (DTR, RTS) */
@@ -91,7 +115,6 @@ struct acm {
91 unsigned int minor; /* acm minor number */ 115 unsigned int minor; /* acm minor number */
92 unsigned char throttle; /* throttled by tty layer */ 116 unsigned char throttle; /* throttled by tty layer */
93 unsigned char clocal; /* termios CLOCAL */ 117 unsigned char clocal; /* termios CLOCAL */
94 unsigned char resubmit_to_unthrottle; /* throtteling has disabled the read urb */
95 unsigned int ctrl_caps; /* control capabilities from the class specific header */ 118 unsigned int ctrl_caps; /* control capabilities from the class specific header */
96}; 119};
97 120
diff --git a/drivers/usb/class/usb-midi.c b/drivers/usb/class/usb-midi.c
index 5f8af35e7633..f13f004d311f 100644
--- a/drivers/usb/class/usb-midi.c
+++ b/drivers/usb/class/usb-midi.c
@@ -2027,7 +2027,6 @@ static struct usb_device_id id_table[] = {
2027}; 2027};
2028 2028
2029static struct usb_driver usb_midi_driver = { 2029static struct usb_driver usb_midi_driver = {
2030 .owner = THIS_MODULE,
2031 .name = "midi", 2030 .name = "midi",
2032 .probe = usb_midi_probe, 2031 .probe = usb_midi_probe,
2033 .disconnect = usb_midi_disconnect, 2032 .disconnect = usb_midi_disconnect,
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index 357e75335f17..dba4cc026077 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Copyright (c) 1999 Michael Gee <michael@linuxspecific.com> 4 * Copyright (c) 1999 Michael Gee <michael@linuxspecific.com>
5 * Copyright (c) 1999 Pavel Machek <pavel@suse.cz> 5 * Copyright (c) 1999 Pavel Machek <pavel@suse.cz>
6 * Copyright (c) 2000 Randy Dunlap <rddunlap@osdl.org> 6 * Copyright (c) 2000 Randy Dunlap <rdunlap@xenotime.net>
7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz> 7 * Copyright (c) 2000 Vojtech Pavlik <vojtech@suse.cz>
8 # Copyright (c) 2001 Pete Zaitcev <zaitcev@redhat.com> 8 # Copyright (c) 2001 Pete Zaitcev <zaitcev@redhat.com>
9 # Copyright (c) 2001 David Paschal <paschal@rcsis.com> 9 # Copyright (c) 2001 David Paschal <paschal@rcsis.com>
@@ -199,7 +199,7 @@ struct quirk_printer_struct {
199#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */ 199#define USBLP_QUIRK_BIDIR 0x1 /* reports bidir but requires unidirectional mode (no INs/reads) */
200#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */ 200#define USBLP_QUIRK_USB_INIT 0x2 /* needs vendor USB init string */
201 201
202static struct quirk_printer_struct quirk_printers[] = { 202static const struct quirk_printer_struct quirk_printers[] = {
203 { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */ 203 { 0x03f0, 0x0004, USBLP_QUIRK_BIDIR }, /* HP DeskJet 895C */
204 { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */ 204 { 0x03f0, 0x0104, USBLP_QUIRK_BIDIR }, /* HP DeskJet 880C */
205 { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */ 205 { 0x03f0, 0x0204, USBLP_QUIRK_BIDIR }, /* HP DeskJet 815C */
@@ -301,7 +301,7 @@ static void usblp_bulk_write(struct urb *urb, struct pt_regs *regs)
301 * Get and print printer errors. 301 * Get and print printer errors.
302 */ 302 */
303 303
304static char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" }; 304static const char *usblp_messages[] = { "ok", "out of paper", "off-line", "on fire" };
305 305
306static int usblp_check_status(struct usblp *usblp, int err) 306static int usblp_check_status(struct usblp *usblp, int err)
307{ 307{
@@ -438,7 +438,7 @@ static unsigned int usblp_poll(struct file *file, struct poll_table_struct *wait
438 | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM); 438 | (!usblp->wcomplete ? 0 : POLLOUT | POLLWRNORM);
439} 439}
440 440
441static int usblp_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 441static long usblp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
442{ 442{
443 struct usblp *usblp = file->private_data; 443 struct usblp *usblp = file->private_data;
444 int length, err, i; 444 int length, err, i;
@@ -838,7 +838,8 @@ static struct file_operations usblp_fops = {
838 .read = usblp_read, 838 .read = usblp_read,
839 .write = usblp_write, 839 .write = usblp_write,
840 .poll = usblp_poll, 840 .poll = usblp_poll,
841 .ioctl = usblp_ioctl, 841 .unlocked_ioctl = usblp_ioctl,
842 .compat_ioctl = usblp_ioctl,
842 .open = usblp_open, 843 .open = usblp_open,
843 .release = usblp_release, 844 .release = usblp_release,
844}; 845};
@@ -849,6 +850,20 @@ static struct usb_class_driver usblp_class = {
849 .minor_base = USBLP_MINOR_BASE, 850 .minor_base = USBLP_MINOR_BASE,
850}; 851};
851 852
853static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf)
854{
855 struct usb_interface *intf = to_usb_interface(dev);
856 struct usblp *usblp = usb_get_intfdata (intf);
857
858 if (usblp->device_id_string[0] == 0 &&
859 usblp->device_id_string[1] == 0)
860 return 0;
861
862 return sprintf(buf, "%s", usblp->device_id_string+2);
863}
864
865static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL);
866
852static int usblp_probe(struct usb_interface *intf, 867static int usblp_probe(struct usb_interface *intf,
853 const struct usb_device_id *id) 868 const struct usb_device_id *id)
854{ 869{
@@ -933,20 +948,12 @@ static int usblp_probe(struct usb_interface *intf,
933 948
934 /* Retrieve and store the device ID string. */ 949 /* Retrieve and store the device ID string. */
935 usblp_cache_device_id_string(usblp); 950 usblp_cache_device_id_string(usblp);
951 device_create_file(&intf->dev, &dev_attr_ieee1284_id);
936 952
937#ifdef DEBUG 953#ifdef DEBUG
938 usblp_check_status(usblp, 0); 954 usblp_check_status(usblp, 0);
939#endif 955#endif
940 956
941 info("usblp%d: USB %sdirectional printer dev %d "
942 "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X",
943 usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
944 usblp->ifnum,
945 usblp->protocol[usblp->current_protocol].alt_setting,
946 usblp->current_protocol,
947 le16_to_cpu(usblp->dev->descriptor.idVendor),
948 le16_to_cpu(usblp->dev->descriptor.idProduct));
949
950 usb_set_intfdata (intf, usblp); 957 usb_set_intfdata (intf, usblp);
951 958
952 usblp->present = 1; 959 usblp->present = 1;
@@ -957,11 +964,20 @@ static int usblp_probe(struct usb_interface *intf,
957 goto abort_intfdata; 964 goto abort_intfdata;
958 } 965 }
959 usblp->minor = intf->minor; 966 usblp->minor = intf->minor;
967 info("usblp%d: USB %sdirectional printer dev %d "
968 "if %d alt %d proto %d vid 0x%4.4X pid 0x%4.4X",
969 usblp->minor, usblp->bidir ? "Bi" : "Uni", dev->devnum,
970 usblp->ifnum,
971 usblp->protocol[usblp->current_protocol].alt_setting,
972 usblp->current_protocol,
973 le16_to_cpu(usblp->dev->descriptor.idVendor),
974 le16_to_cpu(usblp->dev->descriptor.idProduct));
960 975
961 return 0; 976 return 0;
962 977
963abort_intfdata: 978abort_intfdata:
964 usb_set_intfdata (intf, NULL); 979 usb_set_intfdata (intf, NULL);
980 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
965abort: 981abort:
966 if (usblp) { 982 if (usblp) {
967 if (usblp->writebuf) 983 if (usblp->writebuf)
@@ -1156,6 +1172,8 @@ static void usblp_disconnect(struct usb_interface *intf)
1156 BUG (); 1172 BUG ();
1157 } 1173 }
1158 1174
1175 device_remove_file(&intf->dev, &dev_attr_ieee1284_id);
1176
1159 down (&usblp_sem); 1177 down (&usblp_sem);
1160 down (&usblp->sem); 1178 down (&usblp->sem);
1161 usblp->present = 0; 1179 usblp->present = 0;
@@ -1186,7 +1204,6 @@ static struct usb_device_id usblp_ids [] = {
1186MODULE_DEVICE_TABLE (usb, usblp_ids); 1204MODULE_DEVICE_TABLE (usb, usblp_ids);
1187 1205
1188static struct usb_driver usblp_driver = { 1206static struct usb_driver usblp_driver = {
1189 .owner = THIS_MODULE,
1190 .name = "usblp", 1207 .name = "usblp",
1191 .probe = usblp_probe, 1208 .probe = usblp_probe,
1192 .disconnect = usblp_disconnect, 1209 .disconnect = usblp_disconnect,
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index 86d5c380892d..28329ddf187c 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -2,7 +2,7 @@
2# Makefile for USB Core files and filesystem 2# Makefile for USB Core files and filesystem
3# 3#
4 4
5usbcore-objs := usb.o hub.o hcd.o urb.o message.o \ 5usbcore-objs := usb.o hub.o hcd.o urb.o message.o driver.o \
6 config.o file.o buffer.o sysfs.o devio.o notify.o 6 config.o file.o buffer.o sysfs.o devio.o notify.o
7 7
8ifeq ($(CONFIG_PCI),y) 8ifeq ($(CONFIG_PCI),y)
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 419c9943a7cb..ad742cec94fa 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -55,6 +55,9 @@ int hcd_buffer_create (struct usb_hcd *hcd)
55 char name [16]; 55 char name [16];
56 int i, size; 56 int i, size;
57 57
58 if (!hcd->self.controller->dma_mask)
59 return 0;
60
58 for (i = 0; i < HCD_BUFFER_POOLS; i++) { 61 for (i = 0; i < HCD_BUFFER_POOLS; i++) {
59 if (!(size = pool_max [i])) 62 if (!(size = pool_max [i]))
60 continue; 63 continue;
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
index 83e815d3cd52..2684e15b813b 100644
--- a/drivers/usb/core/devices.c
+++ b/drivers/usb/core/devices.c
@@ -67,45 +67,45 @@
67/* Define ALLOW_SERIAL_NUMBER if you want to see the serial number of devices */ 67/* Define ALLOW_SERIAL_NUMBER if you want to see the serial number of devices */
68#define ALLOW_SERIAL_NUMBER 68#define ALLOW_SERIAL_NUMBER
69 69
70static char *format_topo = 70static const char *format_topo =
71/* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd */ 71/* T: Bus=dd Lev=dd Prnt=dd Port=dd Cnt=dd Dev#=ddd Spd=ddd MxCh=dd */
72"\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%3s MxCh=%2d\n"; 72"\nT: Bus=%2.2d Lev=%2.2d Prnt=%2.2d Port=%2.2d Cnt=%2.2d Dev#=%3d Spd=%3s MxCh=%2d\n";
73 73
74static char *format_string_manufacturer = 74static const char *format_string_manufacturer =
75/* S: Manufacturer=xxxx */ 75/* S: Manufacturer=xxxx */
76 "S: Manufacturer=%.100s\n"; 76 "S: Manufacturer=%.100s\n";
77 77
78static char *format_string_product = 78static const char *format_string_product =
79/* S: Product=xxxx */ 79/* S: Product=xxxx */
80 "S: Product=%.100s\n"; 80 "S: Product=%.100s\n";
81 81
82#ifdef ALLOW_SERIAL_NUMBER 82#ifdef ALLOW_SERIAL_NUMBER
83static char *format_string_serialnumber = 83static const char *format_string_serialnumber =
84/* S: SerialNumber=xxxx */ 84/* S: SerialNumber=xxxx */
85 "S: SerialNumber=%.100s\n"; 85 "S: SerialNumber=%.100s\n";
86#endif 86#endif
87 87
88static char *format_bandwidth = 88static const char *format_bandwidth =
89/* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */ 89/* B: Alloc=ddd/ddd us (xx%), #Int=ddd, #Iso=ddd */
90 "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n"; 90 "B: Alloc=%3d/%3d us (%2d%%), #Int=%3d, #Iso=%3d\n";
91 91
92static char *format_device1 = 92static const char *format_device1 =
93/* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */ 93/* D: Ver=xx.xx Cls=xx(sssss) Sub=xx Prot=xx MxPS=dd #Cfgs=dd */
94 "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n"; 94 "D: Ver=%2x.%02x Cls=%02x(%-5s) Sub=%02x Prot=%02x MxPS=%2d #Cfgs=%3d\n";
95 95
96static char *format_device2 = 96static const char *format_device2 =
97/* P: Vendor=xxxx ProdID=xxxx Rev=xx.xx */ 97/* P: Vendor=xxxx ProdID=xxxx Rev=xx.xx */
98 "P: Vendor=%04x ProdID=%04x Rev=%2x.%02x\n"; 98 "P: Vendor=%04x ProdID=%04x Rev=%2x.%02x\n";
99 99
100static char *format_config = 100static const char *format_config =
101/* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */ 101/* C: #Ifs=dd Cfg#=dd Atr=xx MPwr=dddmA */
102 "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n"; 102 "C:%c #Ifs=%2d Cfg#=%2d Atr=%02x MxPwr=%3dmA\n";
103 103
104static char *format_iface = 104static const char *format_iface =
105/* I: If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=xxxx*/ 105/* I: If#=dd Alt=dd #EPs=dd Cls=xx(sssss) Sub=xx Prot=xx Driver=xxxx*/
106 "I: If#=%2d Alt=%2d #EPs=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x Driver=%s\n"; 106 "I: If#=%2d Alt=%2d #EPs=%2d Cls=%02x(%-5s) Sub=%02x Prot=%02x Driver=%s\n";
107 107
108static char *format_endpt = 108static const char *format_endpt =
109/* E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=D?s */ 109/* E: Ad=xx(s) Atr=xx(ssss) MxPS=dddd Ivl=D?s */
110 "E: Ad=%02x(%c) Atr=%02x(%-4s) MxPS=%4d Ivl=%d%cs\n"; 110 "E: Ad=%02x(%c) Atr=%02x(%-4s) MxPS=%4d Ivl=%d%cs\n";
111 111
@@ -545,10 +545,10 @@ static ssize_t usb_device_dump(char __user **buffer, size_t *nbytes, loff_t *ski
545 struct usb_device *childdev = usbdev->children[chix]; 545 struct usb_device *childdev = usbdev->children[chix];
546 546
547 if (childdev) { 547 if (childdev) {
548 down(&childdev->serialize); 548 usb_lock_device(childdev);
549 ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, childdev, 549 ret = usb_device_dump(buffer, nbytes, skip_bytes, file_offset, childdev,
550 bus, level + 1, chix, ++cnt); 550 bus, level + 1, chix, ++cnt);
551 up(&childdev->serialize); 551 usb_unlock_device(childdev);
552 if (ret == -EFAULT) 552 if (ret == -EFAULT)
553 return total_written; 553 return total_written;
554 total_written += ret; 554 total_written += ret;
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index b1d6e9af732d..2b68998fe4b3 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -402,7 +402,6 @@ static void driver_disconnect(struct usb_interface *intf)
402} 402}
403 403
404struct usb_driver usbfs_driver = { 404struct usb_driver usbfs_driver = {
405 .owner = THIS_MODULE,
406 .name = "usbfs", 405 .name = "usbfs",
407 .probe = driver_probe, 406 .probe = driver_probe,
408 .disconnect = driver_disconnect, 407 .disconnect = driver_disconnect,
@@ -1350,9 +1349,7 @@ static int proc_ioctl(struct dev_state *ps, struct usbdevfs_ioctl *ctl)
1350 /* let kernel drivers try to (re)bind to the interface */ 1349 /* let kernel drivers try to (re)bind to the interface */
1351 case USBDEVFS_CONNECT: 1350 case USBDEVFS_CONNECT:
1352 usb_unlock_device(ps->dev); 1351 usb_unlock_device(ps->dev);
1353 usb_lock_all_devices();
1354 bus_rescan_devices(intf->dev.bus); 1352 bus_rescan_devices(intf->dev.bus);
1355 usb_unlock_all_devices();
1356 usb_lock_device(ps->dev); 1353 usb_lock_device(ps->dev);
1357 break; 1354 break;
1358 1355
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
new file mode 100644
index 000000000000..076462c8ba2a
--- /dev/null
+++ b/drivers/usb/core/driver.c
@@ -0,0 +1,472 @@
1/*
2 * drivers/usb/driver.c - most of the driver model stuff for usb
3 *
4 * (C) Copyright 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * based on drivers/usb/usb.c which had the following copyrights:
7 * (C) Copyright Linus Torvalds 1999
8 * (C) Copyright Johannes Erdfelt 1999-2001
9 * (C) Copyright Andreas Gal 1999
10 * (C) Copyright Gregory P. Smith 1999
11 * (C) Copyright Deti Fliegl 1999 (new USB architecture)
12 * (C) Copyright Randy Dunlap 2000
13 * (C) Copyright David Brownell 2000-2004
14 * (C) Copyright Yggdrasil Computing, Inc. 2000
15 * (usb_device_id matching changes by Adam J. Richter)
16 * (C) Copyright Greg Kroah-Hartman 2002-2003
17 *
18 * NOTE! This is not actually a driver at all, rather this is
19 * just a collection of helper routines that implement the
20 * generic USB things that the real drivers can use..
21 *
22 */
23
24#include <linux/config.h>
25#include <linux/device.h>
26#include <linux/usb.h>
27#include "hcd.h"
28#include "usb.h"
29
30static int usb_match_one_id(struct usb_interface *interface,
31 const struct usb_device_id *id);
32
33struct usb_dynid {
34 struct list_head node;
35 struct usb_device_id id;
36};
37
38
39static int generic_probe(struct device *dev)
40{
41 return 0;
42}
43static int generic_remove(struct device *dev)
44{
45 struct usb_device *udev = to_usb_device(dev);
46
47 /* if this is only an unbind, not a physical disconnect, then
48 * unconfigure the device */
49 if (udev->state == USB_STATE_CONFIGURED)
50 usb_set_configuration(udev, 0);
51
52 /* in case the call failed or the device was suspended */
53 if (udev->state >= USB_STATE_CONFIGURED)
54 usb_disable_device(udev, 0);
55 return 0;
56}
57
58struct device_driver usb_generic_driver = {
59 .owner = THIS_MODULE,
60 .name = "usb",
61 .bus = &usb_bus_type,
62 .probe = generic_probe,
63 .remove = generic_remove,
64};
65
66/* Fun hack to determine if the struct device is a
67 * usb device or a usb interface. */
68int usb_generic_driver_data;
69
70#ifdef CONFIG_HOTPLUG
71
72/*
73 * Adds a new dynamic USBdevice ID to this driver,
74 * and cause the driver to probe for all devices again.
75 */
76static ssize_t store_new_id(struct device_driver *driver,
77 const char *buf, size_t count)
78{
79 struct usb_driver *usb_drv = to_usb_driver(driver);
80 struct usb_dynid *dynid;
81 u32 idVendor = 0;
82 u32 idProduct = 0;
83 int fields = 0;
84
85 fields = sscanf(buf, "%x %x", &idVendor, &idProduct);
86 if (fields < 2)
87 return -EINVAL;
88
89 dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
90 if (!dynid)
91 return -ENOMEM;
92
93 INIT_LIST_HEAD(&dynid->node);
94 dynid->id.idVendor = idVendor;
95 dynid->id.idProduct = idProduct;
96 dynid->id.match_flags = USB_DEVICE_ID_MATCH_DEVICE;
97
98 spin_lock(&usb_drv->dynids.lock);
99 list_add_tail(&usb_drv->dynids.list, &dynid->node);
100 spin_unlock(&usb_drv->dynids.lock);
101
102 if (get_driver(driver)) {
103 driver_attach(driver);
104 put_driver(driver);
105 }
106
107 return count;
108}
109static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
110
111static int usb_create_newid_file(struct usb_driver *usb_drv)
112{
113 int error = 0;
114
115 if (usb_drv->no_dynamic_id)
116 goto exit;
117
118 if (usb_drv->probe != NULL)
119 error = sysfs_create_file(&usb_drv->driver.kobj,
120 &driver_attr_new_id.attr);
121exit:
122 return error;
123}
124
125static void usb_remove_newid_file(struct usb_driver *usb_drv)
126{
127 if (usb_drv->no_dynamic_id)
128 return;
129
130 if (usb_drv->probe != NULL)
131 sysfs_remove_file(&usb_drv->driver.kobj,
132 &driver_attr_new_id.attr);
133}
134
135static void usb_free_dynids(struct usb_driver *usb_drv)
136{
137 struct usb_dynid *dynid, *n;
138
139 spin_lock(&usb_drv->dynids.lock);
140 list_for_each_entry_safe(dynid, n, &usb_drv->dynids.list, node) {
141 list_del(&dynid->node);
142 kfree(dynid);
143 }
144 spin_unlock(&usb_drv->dynids.lock);
145}
146#else
147static inline int usb_create_newid_file(struct usb_driver *usb_drv)
148{
149 return 0;
150}
151
152static void usb_remove_newid_file(struct usb_driver *usb_drv)
153{
154}
155
156static inline void usb_free_dynids(struct usb_driver *usb_drv)
157{
158}
159#endif
160
161static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf,
162 struct usb_driver *drv)
163{
164 struct usb_dynid *dynid;
165
166 spin_lock(&drv->dynids.lock);
167 list_for_each_entry(dynid, &drv->dynids.list, node) {
168 if (usb_match_one_id(intf, &dynid->id)) {
169 spin_unlock(&drv->dynids.lock);
170 return &dynid->id;
171 }
172 }
173 spin_unlock(&drv->dynids.lock);
174 return NULL;
175}
176
177
178/* called from driver core with usb_bus_type.subsys writelock */
179static int usb_probe_interface(struct device *dev)
180{
181 struct usb_interface * intf = to_usb_interface(dev);
182 struct usb_driver * driver = to_usb_driver(dev->driver);
183 const struct usb_device_id *id;
184 int error = -ENODEV;
185
186 dev_dbg(dev, "%s\n", __FUNCTION__);
187
188 if (!driver->probe)
189 return error;
190 /* FIXME we'd much prefer to just resume it ... */
191 if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED)
192 return -EHOSTUNREACH;
193
194 id = usb_match_id(intf, driver->id_table);
195 if (!id)
196 id = usb_match_dynamic_id(intf, driver);
197 if (id) {
198 dev_dbg(dev, "%s - got id\n", __FUNCTION__);
199
200 /* Interface "power state" doesn't correspond to any hardware
201 * state whatsoever. We use it to record when it's bound to
202 * a driver that may start I/0: it's not frozen/quiesced.
203 */
204 mark_active(intf);
205 intf->condition = USB_INTERFACE_BINDING;
206 error = driver->probe(intf, id);
207 if (error) {
208 mark_quiesced(intf);
209 intf->condition = USB_INTERFACE_UNBOUND;
210 } else
211 intf->condition = USB_INTERFACE_BOUND;
212 }
213
214 return error;
215}
216
217/* called from driver core with usb_bus_type.subsys writelock */
218static int usb_unbind_interface(struct device *dev)
219{
220 struct usb_interface *intf = to_usb_interface(dev);
221 struct usb_driver *driver = to_usb_driver(intf->dev.driver);
222
223 intf->condition = USB_INTERFACE_UNBINDING;
224
225 /* release all urbs for this interface */
226 usb_disable_interface(interface_to_usbdev(intf), intf);
227
228 if (driver && driver->disconnect)
229 driver->disconnect(intf);
230
231 /* reset other interface state */
232 usb_set_interface(interface_to_usbdev(intf),
233 intf->altsetting[0].desc.bInterfaceNumber,
234 0);
235 usb_set_intfdata(intf, NULL);
236 intf->condition = USB_INTERFACE_UNBOUND;
237 mark_quiesced(intf);
238
239 return 0;
240}
241
242/* returns 0 if no match, 1 if match */
243static int usb_match_one_id(struct usb_interface *interface,
244 const struct usb_device_id *id)
245{
246 struct usb_host_interface *intf;
247 struct usb_device *dev;
248
249 /* proc_connectinfo in devio.c may call us with id == NULL. */
250 if (id == NULL)
251 return 0;
252
253 intf = interface->cur_altsetting;
254 dev = interface_to_usbdev(interface);
255
256 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
257 id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
258 return 0;
259
260 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
261 id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
262 return 0;
263
264 /* No need to test id->bcdDevice_lo != 0, since 0 is never
265 greater than any unsigned number. */
266 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
267 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
268 return 0;
269
270 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
271 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
272 return 0;
273
274 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
275 (id->bDeviceClass != dev->descriptor.bDeviceClass))
276 return 0;
277
278 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
279 (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass))
280 return 0;
281
282 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
283 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
284 return 0;
285
286 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
287 (id->bInterfaceClass != intf->desc.bInterfaceClass))
288 return 0;
289
290 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
291 (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass))
292 return 0;
293
294 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
295 (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol))
296 return 0;
297
298 return 1;
299}
300/**
301 * usb_match_id - find first usb_device_id matching device or interface
302 * @interface: the interface of interest
303 * @id: array of usb_device_id structures, terminated by zero entry
304 *
305 * usb_match_id searches an array of usb_device_id's and returns
306 * the first one matching the device or interface, or null.
307 * This is used when binding (or rebinding) a driver to an interface.
308 * Most USB device drivers will use this indirectly, through the usb core,
309 * but some layered driver frameworks use it directly.
310 * These device tables are exported with MODULE_DEVICE_TABLE, through
311 * modutils, to support the driver loading functionality of USB hotplugging.
312 *
313 * What Matches:
314 *
315 * The "match_flags" element in a usb_device_id controls which
316 * members are used. If the corresponding bit is set, the
317 * value in the device_id must match its corresponding member
318 * in the device or interface descriptor, or else the device_id
319 * does not match.
320 *
321 * "driver_info" is normally used only by device drivers,
322 * but you can create a wildcard "matches anything" usb_device_id
323 * as a driver's "modules.usbmap" entry if you provide an id with
324 * only a nonzero "driver_info" field. If you do this, the USB device
325 * driver's probe() routine should use additional intelligence to
326 * decide whether to bind to the specified interface.
327 *
328 * What Makes Good usb_device_id Tables:
329 *
330 * The match algorithm is very simple, so that intelligence in
331 * driver selection must come from smart driver id records.
332 * Unless you have good reasons to use another selection policy,
333 * provide match elements only in related groups, and order match
334 * specifiers from specific to general. Use the macros provided
335 * for that purpose if you can.
336 *
337 * The most specific match specifiers use device descriptor
338 * data. These are commonly used with product-specific matches;
339 * the USB_DEVICE macro lets you provide vendor and product IDs,
340 * and you can also match against ranges of product revisions.
341 * These are widely used for devices with application or vendor
342 * specific bDeviceClass values.
343 *
344 * Matches based on device class/subclass/protocol specifications
345 * are slightly more general; use the USB_DEVICE_INFO macro, or
346 * its siblings. These are used with single-function devices
347 * where bDeviceClass doesn't specify that each interface has
348 * its own class.
349 *
350 * Matches based on interface class/subclass/protocol are the
351 * most general; they let drivers bind to any interface on a
352 * multiple-function device. Use the USB_INTERFACE_INFO
353 * macro, or its siblings, to match class-per-interface style
354 * devices (as recorded in bDeviceClass).
355 *
356 * Within those groups, remember that not all combinations are
357 * meaningful. For example, don't give a product version range
358 * without vendor and product IDs; or specify a protocol without
359 * its associated class and subclass.
360 */
361const struct usb_device_id *usb_match_id(struct usb_interface *interface,
362 const struct usb_device_id *id)
363{
364 /* proc_connectinfo in devio.c may call us with id == NULL. */
365 if (id == NULL)
366 return NULL;
367
368 /* It is important to check that id->driver_info is nonzero,
369 since an entry that is all zeroes except for a nonzero
370 id->driver_info is the way to create an entry that
371 indicates that the driver want to examine every
372 device and interface. */
373 for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass ||
374 id->driver_info; id++) {
375 if (usb_match_one_id(interface, id))
376 return id;
377 }
378
379 return NULL;
380}
381EXPORT_SYMBOL_GPL(usb_match_id);
382
383int usb_device_match(struct device *dev, struct device_driver *drv)
384{
385 struct usb_interface *intf;
386 struct usb_driver *usb_drv;
387 const struct usb_device_id *id;
388
389 /* check for generic driver, which we don't match any device with */
390 if (drv == &usb_generic_driver)
391 return 0;
392
393 intf = to_usb_interface(dev);
394 usb_drv = to_usb_driver(drv);
395
396 id = usb_match_id(intf, usb_drv->id_table);
397 if (id)
398 return 1;
399
400 id = usb_match_dynamic_id(intf, usb_drv);
401 if (id)
402 return 1;
403 return 0;
404}
405
406/**
407 * usb_register_driver - register a USB driver
408 * @new_driver: USB operations for the driver
409 * @owner: module owner of this driver.
410 *
411 * Registers a USB driver with the USB core. The list of unattached
412 * interfaces will be rescanned whenever a new driver is added, allowing
413 * the new driver to attach to any recognized devices.
414 * Returns a negative error code on failure and 0 on success.
415 *
416 * NOTE: if you want your driver to use the USB major number, you must call
417 * usb_register_dev() to enable that functionality. This function no longer
418 * takes care of that.
419 */
420int usb_register_driver(struct usb_driver *new_driver, struct module *owner)
421{
422 int retval = 0;
423
424 if (usb_disabled())
425 return -ENODEV;
426
427 new_driver->driver.name = (char *)new_driver->name;
428 new_driver->driver.bus = &usb_bus_type;
429 new_driver->driver.probe = usb_probe_interface;
430 new_driver->driver.remove = usb_unbind_interface;
431 new_driver->driver.owner = owner;
432 spin_lock_init(&new_driver->dynids.lock);
433 INIT_LIST_HEAD(&new_driver->dynids.list);
434
435 retval = driver_register(&new_driver->driver);
436
437 if (!retval) {
438 pr_info("%s: registered new driver %s\n",
439 usbcore_name, new_driver->name);
440 usbfs_update_special();
441 usb_create_newid_file(new_driver);
442 } else {
443 printk(KERN_ERR "%s: error %d registering driver %s\n",
444 usbcore_name, retval, new_driver->name);
445 }
446
447 return retval;
448}
449EXPORT_SYMBOL_GPL(usb_register_driver);
450
451/**
452 * usb_deregister - unregister a USB driver
453 * @driver: USB operations of the driver to unregister
454 * Context: must be able to sleep
455 *
456 * Unlinks the specified driver from the internal USB driver list.
457 *
458 * NOTE: If you called usb_register_dev(), you still need to call
459 * usb_deregister_dev() to clean up your driver's allocated minor numbers,
460 * this * call will no longer do it for you.
461 */
462void usb_deregister(struct usb_driver *driver)
463{
464 pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name);
465
466 usb_remove_newid_file(driver);
467 usb_free_dynids(driver);
468 driver_unregister(&driver->driver);
469
470 usbfs_update_special();
471}
472EXPORT_SYMBOL_GPL(usb_deregister);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index da24c31ee00d..0018bbc4de34 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -857,9 +857,7 @@ static int register_root_hub (struct usb_device *usb_dev,
857 return (retval < 0) ? retval : -EMSGSIZE; 857 return (retval < 0) ? retval : -EMSGSIZE;
858 } 858 }
859 859
860 usb_lock_device (usb_dev);
861 retval = usb_new_device (usb_dev); 860 retval = usb_new_device (usb_dev);
862 usb_unlock_device (usb_dev);
863 if (retval) { 861 if (retval) {
864 usb_dev->bus->root_hub = NULL; 862 usb_dev->bus->root_hub = NULL;
865 dev_err (parent_dev, "can't register root hub for %s, %d\n", 863 dev_err (parent_dev, "can't register root hub for %s, %d\n",
@@ -1827,8 +1825,6 @@ int usb_add_hcd(struct usb_hcd *hcd,
1827 retval = -ENOMEM; 1825 retval = -ENOMEM;
1828 goto err_allocate_root_hub; 1826 goto err_allocate_root_hub;
1829 } 1827 }
1830 rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH :
1831 USB_SPEED_FULL;
1832 1828
1833 /* Although in principle hcd->driver->start() might need to use rhdev, 1829 /* Although in principle hcd->driver->start() might need to use rhdev,
1834 * none of the current drivers do. 1830 * none of the current drivers do.
@@ -1846,6 +1842,9 @@ int usb_add_hcd(struct usb_hcd *hcd,
1846 dev_dbg(hcd->self.controller, "supports USB remote wakeup\n"); 1842 dev_dbg(hcd->self.controller, "supports USB remote wakeup\n");
1847 hcd->remote_wakeup = hcd->can_wakeup; 1843 hcd->remote_wakeup = hcd->can_wakeup;
1848 1844
1845 rhdev->speed = (hcd->driver->flags & HCD_USB2) ? USB_SPEED_HIGH :
1846 USB_SPEED_FULL;
1847 rhdev->bus_mA = min(500u, hcd->power_budget);
1849 if ((retval = register_root_hub(rhdev, hcd)) != 0) 1848 if ((retval = register_root_hub(rhdev, hcd)) != 0)
1850 goto err_register_root_hub; 1849 goto err_register_root_hub;
1851 1850
@@ -1891,7 +1890,10 @@ void usb_remove_hcd(struct usb_hcd *hcd)
1891 spin_lock_irq (&hcd_root_hub_lock); 1890 spin_lock_irq (&hcd_root_hub_lock);
1892 hcd->rh_registered = 0; 1891 hcd->rh_registered = 0;
1893 spin_unlock_irq (&hcd_root_hub_lock); 1892 spin_unlock_irq (&hcd_root_hub_lock);
1893
1894 down(&usb_bus_list_lock);
1894 usb_disconnect(&hcd->self.root_hub); 1895 usb_disconnect(&hcd->self.root_hub);
1896 up(&usb_bus_list_lock);
1895 1897
1896 hcd->poll_rh = 0; 1898 hcd->poll_rh = 0;
1897 del_timer_sync(&hcd->rh_timer); 1899 del_timer_sync(&hcd->rh_timer);
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index c8a1b350e2cf..591b5aad1a18 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -380,6 +380,7 @@ extern int usb_find_interface_driver (struct usb_device *dev,
380#ifdef CONFIG_PM 380#ifdef CONFIG_PM
381extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd); 381extern void usb_hcd_suspend_root_hub (struct usb_hcd *hcd);
382extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd); 382extern void usb_hcd_resume_root_hub (struct usb_hcd *hcd);
383extern void usb_root_hub_lost_power (struct usb_device *rhdev);
383extern int hcd_bus_suspend (struct usb_bus *bus); 384extern int hcd_bus_suspend (struct usb_bus *bus);
384extern int hcd_bus_resume (struct usb_bus *bus); 385extern int hcd_bus_resume (struct usb_bus *bus);
385#else 386#else
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index f78bd124d290..650d5ee5871b 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -32,7 +32,7 @@
32#include "hub.h" 32#include "hub.h"
33 33
34/* Protect struct usb_device->state and ->children members 34/* Protect struct usb_device->state and ->children members
35 * Note: Both are also protected by ->serialize, except that ->state can 35 * Note: Both are also protected by ->dev.sem, except that ->state can
36 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ 36 * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */
37static DEFINE_SPINLOCK(device_state_lock); 37static DEFINE_SPINLOCK(device_state_lock);
38 38
@@ -515,6 +515,31 @@ static int hub_port_disable(struct usb_hub *hub, int port1, int set_state)
515 return ret; 515 return ret;
516} 516}
517 517
518
519/* caller has locked the hub device */
520static void hub_pre_reset(struct usb_hub *hub, int disable_ports)
521{
522 struct usb_device *hdev = hub->hdev;
523 int port1;
524
525 for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
526 if (hdev->children[port1 - 1]) {
527 usb_disconnect(&hdev->children[port1 - 1]);
528 if (disable_ports)
529 hub_port_disable(hub, port1, 0);
530 }
531 }
532 hub_quiesce(hub);
533}
534
535/* caller has locked the hub device */
536static void hub_post_reset(struct usb_hub *hub)
537{
538 hub_activate(hub);
539 hub_power_on(hub);
540}
541
542
518static int hub_configure(struct usb_hub *hub, 543static int hub_configure(struct usb_hub *hub,
519 struct usb_endpoint_descriptor *endpoint) 544 struct usb_endpoint_descriptor *endpoint)
520{ 545{
@@ -677,26 +702,40 @@ static int hub_configure(struct usb_hub *hub,
677 * and battery-powered root hubs (may provide just 8 mA). 702 * and battery-powered root hubs (may provide just 8 mA).
678 */ 703 */
679 ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus); 704 ret = usb_get_status(hdev, USB_RECIP_DEVICE, 0, &hubstatus);
680 if (ret < 0) { 705 if (ret < 2) {
681 message = "can't get hub status"; 706 message = "can't get hub status";
682 goto fail; 707 goto fail;
683 } 708 }
684 le16_to_cpus(&hubstatus); 709 le16_to_cpus(&hubstatus);
685 if (hdev == hdev->bus->root_hub) { 710 if (hdev == hdev->bus->root_hub) {
686 struct usb_hcd *hcd = 711 if (hdev->bus_mA == 0 || hdev->bus_mA >= 500)
687 container_of(hdev->bus, struct usb_hcd, self); 712 hub->mA_per_port = 500;
688 713 else {
689 hub->power_budget = min(500u, hcd->power_budget) / 2; 714 hub->mA_per_port = hdev->bus_mA;
715 hub->limited_power = 1;
716 }
690 } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) { 717 } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) {
691 dev_dbg(hub_dev, "hub controller current requirement: %dmA\n", 718 dev_dbg(hub_dev, "hub controller current requirement: %dmA\n",
692 hub->descriptor->bHubContrCurrent); 719 hub->descriptor->bHubContrCurrent);
693 hub->power_budget = (501 - hub->descriptor->bHubContrCurrent) 720 hub->limited_power = 1;
694 / 2; 721 if (hdev->maxchild > 0) {
722 int remaining = hdev->bus_mA -
723 hub->descriptor->bHubContrCurrent;
724
725 if (remaining < hdev->maxchild * 100)
726 dev_warn(hub_dev,
727 "insufficient power available "
728 "to use all downstream ports\n");
729 hub->mA_per_port = 100; /* 7.2.1.1 */
730 }
731 } else { /* Self-powered external hub */
732 /* FIXME: What about battery-powered external hubs that
733 * provide less current per port? */
734 hub->mA_per_port = 500;
695 } 735 }
696 if (hub->power_budget) 736 if (hub->mA_per_port < 500)
697 dev_dbg(hub_dev, "%dmA bus power budget for children\n", 737 dev_dbg(hub_dev, "%umA bus power budget for each child\n",
698 hub->power_budget * 2); 738 hub->mA_per_port);
699
700 739
701 ret = hub_hub_status(hub, &hubstatus, &hubchange); 740 ret = hub_hub_status(hub, &hubstatus, &hubchange);
702 if (ret < 0) { 741 if (ret < 0) {
@@ -750,29 +789,10 @@ fail:
750 789
751static unsigned highspeed_hubs; 790static unsigned highspeed_hubs;
752 791
753/* Called after the hub driver is unbound from a hub with children */
754static void hub_remove_children_work(void *__hub)
755{
756 struct usb_hub *hub = __hub;
757 struct usb_device *hdev = hub->hdev;
758 int i;
759
760 kfree(hub);
761
762 usb_lock_device(hdev);
763 for (i = 0; i < hdev->maxchild; ++i) {
764 if (hdev->children[i])
765 usb_disconnect(&hdev->children[i]);
766 }
767 usb_unlock_device(hdev);
768 usb_put_dev(hdev);
769}
770
771static void hub_disconnect(struct usb_interface *intf) 792static void hub_disconnect(struct usb_interface *intf)
772{ 793{
773 struct usb_hub *hub = usb_get_intfdata (intf); 794 struct usb_hub *hub = usb_get_intfdata (intf);
774 struct usb_device *hdev; 795 struct usb_device *hdev;
775 int n, port1;
776 796
777 usb_set_intfdata (intf, NULL); 797 usb_set_intfdata (intf, NULL);
778 hdev = hub->hdev; 798 hdev = hub->hdev;
@@ -780,7 +800,9 @@ static void hub_disconnect(struct usb_interface *intf)
780 if (hdev->speed == USB_SPEED_HIGH) 800 if (hdev->speed == USB_SPEED_HIGH)
781 highspeed_hubs--; 801 highspeed_hubs--;
782 802
783 hub_quiesce(hub); 803 /* Disconnect all children and quiesce the hub */
804 hub_pre_reset(hub, 1);
805
784 usb_free_urb(hub->urb); 806 usb_free_urb(hub->urb);
785 hub->urb = NULL; 807 hub->urb = NULL;
786 808
@@ -800,27 +822,7 @@ static void hub_disconnect(struct usb_interface *intf)
800 hub->buffer = NULL; 822 hub->buffer = NULL;
801 } 823 }
802 824
803 /* If there are any children then this is an unbind only, not a 825 kfree(hub);
804 * physical disconnection. The active ports must be disabled
805 * and later on we must call usb_disconnect(). We can't call
806 * it now because we may not hold the hub's device lock.
807 */
808 n = 0;
809 for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
810 if (hdev->children[port1 - 1]) {
811 ++n;
812 hub_port_disable(hub, port1, 1);
813 }
814 }
815
816 if (n == 0)
817 kfree(hub);
818 else {
819 /* Reuse the hub->leds work_struct for our own purposes */
820 INIT_WORK(&hub->leds, hub_remove_children_work, hub);
821 schedule_work(&hub->leds);
822 usb_get_dev(hdev);
823 }
824} 826}
825 827
826static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id) 828static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -917,26 +919,6 @@ hub_ioctl(struct usb_interface *intf, unsigned int code, void *user_data)
917 } 919 }
918} 920}
919 921
920/* caller has locked the hub device */
921static void hub_pre_reset(struct usb_hub *hub)
922{
923 struct usb_device *hdev = hub->hdev;
924 int i;
925
926 for (i = 0; i < hdev->maxchild; ++i) {
927 if (hdev->children[i])
928 usb_disconnect(&hdev->children[i]);
929 }
930 hub_quiesce(hub);
931}
932
933/* caller has locked the hub device */
934static void hub_post_reset(struct usb_hub *hub)
935{
936 hub_activate(hub);
937 hub_power_on(hub);
938}
939
940 922
941/* grab device/port lock, returning index of that port (zero based). 923/* grab device/port lock, returning index of that port (zero based).
942 * protects the upstream link used by this device from concurrent 924 * protects the upstream link used by this device from concurrent
@@ -964,24 +946,21 @@ static int locktree(struct usb_device *udev)
964 t = locktree(hdev); 946 t = locktree(hdev);
965 if (t < 0) 947 if (t < 0)
966 return t; 948 return t;
967 for (t = 0; t < hdev->maxchild; t++) {
968 if (hdev->children[t] == udev) {
969 /* everything is fail-fast once disconnect
970 * processing starts
971 */
972 if (udev->state == USB_STATE_NOTATTACHED)
973 break;
974 949
975 /* when everyone grabs locks top->bottom, 950 /* everything is fail-fast once disconnect
976 * non-overlapping work may be concurrent 951 * processing starts
977 */ 952 */
978 down(&udev->serialize); 953 if (udev->state == USB_STATE_NOTATTACHED) {
979 up(&hdev->serialize); 954 usb_unlock_device(hdev);
980 return t + 1; 955 return -ENODEV;
981 }
982 } 956 }
957
958 /* when everyone grabs locks top->bottom,
959 * non-overlapping work may be concurrent
960 */
961 usb_lock_device(udev);
983 usb_unlock_device(hdev); 962 usb_unlock_device(hdev);
984 return -ENODEV; 963 return udev->portnum;
985} 964}
986 965
987static void recursively_mark_NOTATTACHED(struct usb_device *udev) 966static void recursively_mark_NOTATTACHED(struct usb_device *udev)
@@ -1039,6 +1018,39 @@ void usb_set_device_state(struct usb_device *udev,
1039EXPORT_SYMBOL(usb_set_device_state); 1018EXPORT_SYMBOL(usb_set_device_state);
1040 1019
1041 1020
1021#ifdef CONFIG_PM
1022
1023/**
1024 * usb_root_hub_lost_power - called by HCD if the root hub lost Vbus power
1025 * @rhdev: struct usb_device for the root hub
1026 *
1027 * The USB host controller driver calls this function when its root hub
1028 * is resumed and Vbus power has been interrupted or the controller
1029 * has been reset. The routine marks all the children of the root hub
1030 * as NOTATTACHED and marks logical connect-change events on their ports.
1031 */
1032void usb_root_hub_lost_power(struct usb_device *rhdev)
1033{
1034 struct usb_hub *hub;
1035 int port1;
1036 unsigned long flags;
1037
1038 dev_warn(&rhdev->dev, "root hub lost power or was reset\n");
1039 spin_lock_irqsave(&device_state_lock, flags);
1040 hub = hdev_to_hub(rhdev);
1041 for (port1 = 1; port1 <= rhdev->maxchild; ++port1) {
1042 if (rhdev->children[port1 - 1]) {
1043 recursively_mark_NOTATTACHED(
1044 rhdev->children[port1 - 1]);
1045 set_bit(port1, hub->change_bits);
1046 }
1047 }
1048 spin_unlock_irqrestore(&device_state_lock, flags);
1049}
1050EXPORT_SYMBOL_GPL(usb_root_hub_lost_power);
1051
1052#endif
1053
1042static void choose_address(struct usb_device *udev) 1054static void choose_address(struct usb_device *udev)
1043{ 1055{
1044 int devnum; 1056 int devnum;
@@ -1099,16 +1111,10 @@ void usb_disconnect(struct usb_device **pdev)
1099 * this quiesces everyting except pending urbs. 1111 * this quiesces everyting except pending urbs.
1100 */ 1112 */
1101 usb_set_device_state(udev, USB_STATE_NOTATTACHED); 1113 usb_set_device_state(udev, USB_STATE_NOTATTACHED);
1102
1103 /* lock the bus list on behalf of HCDs unregistering their root hubs */
1104 if (!udev->parent) {
1105 down(&usb_bus_list_lock);
1106 usb_lock_device(udev);
1107 } else
1108 down(&udev->serialize);
1109
1110 dev_info (&udev->dev, "USB disconnect, address %d\n", udev->devnum); 1114 dev_info (&udev->dev, "USB disconnect, address %d\n", udev->devnum);
1111 1115
1116 usb_lock_device(udev);
1117
1112 /* Free up all the children before we remove this device */ 1118 /* Free up all the children before we remove this device */
1113 for (i = 0; i < USB_MAXCHILDREN; i++) { 1119 for (i = 0; i < USB_MAXCHILDREN; i++) {
1114 if (udev->children[i]) 1120 if (udev->children[i])
@@ -1136,54 +1142,112 @@ void usb_disconnect(struct usb_device **pdev)
1136 *pdev = NULL; 1142 *pdev = NULL;
1137 spin_unlock_irq(&device_state_lock); 1143 spin_unlock_irq(&device_state_lock);
1138 1144
1139 if (!udev->parent) { 1145 usb_unlock_device(udev);
1140 usb_unlock_device(udev);
1141 up(&usb_bus_list_lock);
1142 } else
1143 up(&udev->serialize);
1144 1146
1145 device_unregister(&udev->dev); 1147 device_unregister(&udev->dev);
1146} 1148}
1147 1149
1150static inline const char *plural(int n)
1151{
1152 return (n == 1 ? "" : "s");
1153}
1154
1148static int choose_configuration(struct usb_device *udev) 1155static int choose_configuration(struct usb_device *udev)
1149{ 1156{
1150 int c, i; 1157 int i;
1158 u16 devstatus;
1159 int bus_powered;
1160 int num_configs;
1161 struct usb_host_config *c, *best;
1162
1163 /* If this fails, assume the device is bus-powered */
1164 devstatus = 0;
1165 usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus);
1166 le16_to_cpus(&devstatus);
1167 bus_powered = ((devstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0);
1168 dev_dbg(&udev->dev, "device is %s-powered\n",
1169 bus_powered ? "bus" : "self");
1170
1171 best = NULL;
1172 c = udev->config;
1173 num_configs = udev->descriptor.bNumConfigurations;
1174 for (i = 0; i < num_configs; (i++, c++)) {
1175 struct usb_interface_descriptor *desc =
1176 &c->intf_cache[0]->altsetting->desc;
1177
1178 /*
1179 * HP's USB bus-powered keyboard has only one configuration
1180 * and it claims to be self-powered; other devices may have
1181 * similar errors in their descriptors. If the next test
1182 * were allowed to execute, such configurations would always
1183 * be rejected and the devices would not work as expected.
1184 */
1185#if 0
1186 /* Rule out self-powered configs for a bus-powered device */
1187 if (bus_powered && (c->desc.bmAttributes &
1188 USB_CONFIG_ATT_SELFPOWER))
1189 continue;
1190#endif
1151 1191
1152 /* NOTE: this should interact with hub power budgeting */ 1192 /*
1193 * The next test may not be as effective as it should be.
1194 * Some hubs have errors in their descriptor, claiming
1195 * to be self-powered when they are really bus-powered.
1196 * We will overestimate the amount of current such hubs
1197 * make available for each port.
1198 *
1199 * This is a fairly benign sort of failure. It won't
1200 * cause us to reject configurations that we should have
1201 * accepted.
1202 */
1153 1203
1154 c = udev->config[0].desc.bConfigurationValue; 1204 /* Rule out configs that draw too much bus current */
1155 if (udev->descriptor.bNumConfigurations != 1) { 1205 if (c->desc.bMaxPower * 2 > udev->bus_mA)
1156 for (i = 0; i < udev->descriptor.bNumConfigurations; i++) { 1206 continue;
1157 struct usb_interface_descriptor *desc;
1158 1207
1159 /* heuristic: Linux is more likely to have class 1208 /* If the first config's first interface is COMM/2/0xff
1160 * drivers, so avoid vendor-specific interfaces. 1209 * (MSFT RNDIS), rule it out unless Linux has host-side
1161 */ 1210 * RNDIS support. */
1162 desc = &udev->config[i].intf_cache[0] 1211 if (i == 0 && desc->bInterfaceClass == USB_CLASS_COMM
1163 ->altsetting->desc; 1212 && desc->bInterfaceSubClass == 2
1164 if (desc->bInterfaceClass == USB_CLASS_VENDOR_SPEC) 1213 && desc->bInterfaceProtocol == 0xff) {
1165 continue; 1214#ifndef CONFIG_USB_NET_RNDIS
1166 /* COMM/2/all is CDC ACM, except 0xff is MSFT RNDIS. 1215 continue;
1167 * MSFT needs this to be the first config; never use 1216#else
1168 * it as the default unless Linux has host-side RNDIS. 1217 best = c;
1169 * A second config would ideally be CDC-Ethernet, but 1218#endif
1170 * may instead be the "vendor specific" CDC subset 1219 }
1171 * long used by ARM Linux for sa1100 or pxa255. 1220
1172 */ 1221 /* From the remaining configs, choose the first one whose
1173 if (desc->bInterfaceClass == USB_CLASS_COMM 1222 * first interface is for a non-vendor-specific class.
1174 && desc->bInterfaceSubClass == 2 1223 * Reason: Linux is more likely to have a class driver
1175 && desc->bInterfaceProtocol == 0xff) { 1224 * than a vendor-specific driver. */
1176 c = udev->config[1].desc.bConfigurationValue; 1225 else if (udev->descriptor.bDeviceClass !=
1177 continue; 1226 USB_CLASS_VENDOR_SPEC &&
1178 } 1227 desc->bInterfaceClass !=
1179 c = udev->config[i].desc.bConfigurationValue; 1228 USB_CLASS_VENDOR_SPEC) {
1229 best = c;
1180 break; 1230 break;
1181 } 1231 }
1232
1233 /* If all the remaining configs are vendor-specific,
1234 * choose the first one. */
1235 else if (!best)
1236 best = c;
1237 }
1238
1239 if (best) {
1240 i = best->desc.bConfigurationValue;
1182 dev_info(&udev->dev, 1241 dev_info(&udev->dev,
1183 "configuration #%d chosen from %d choices\n", 1242 "configuration #%d chosen from %d choice%s\n",
1184 c, udev->descriptor.bNumConfigurations); 1243 i, num_configs, plural(num_configs));
1244 } else {
1245 i = -1;
1246 dev_warn(&udev->dev,
1247 "no configuration chosen from %d choice%s\n",
1248 num_configs, plural(num_configs));
1185 } 1249 }
1186 return c; 1250 return i;
1187} 1251}
1188 1252
1189#ifdef DEBUG 1253#ifdef DEBUG
@@ -1210,8 +1274,8 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1210 * 1274 *
1211 * This is called with devices which have been enumerated, but not yet 1275 * This is called with devices which have been enumerated, but not yet
1212 * configured. The device descriptor is available, but not descriptors 1276 * configured. The device descriptor is available, but not descriptors
1213 * for any device configuration. The caller must have locked udev and 1277 * for any device configuration. The caller must have locked either
1214 * either the parent hub (if udev is a normal device) or else the 1278 * the parent hub (if udev is a normal device) or else the
1215 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to 1279 * usb_bus_list_lock (if udev is a root hub). The parent's pointer to
1216 * udev has already been installed, but udev is not yet visible through 1280 * udev has already been installed, but udev is not yet visible through
1217 * sysfs or other filesystem code. 1281 * sysfs or other filesystem code.
@@ -1221,8 +1285,7 @@ static inline void show_string(struct usb_device *udev, char *id, char *string)
1221 * 1285 *
1222 * This call is synchronous, and may not be used in an interrupt context. 1286 * This call is synchronous, and may not be used in an interrupt context.
1223 * 1287 *
1224 * Only the hub driver should ever call this; root hub registration 1288 * Only the hub driver or root-hub registrar should ever call this.
1225 * uses it indirectly.
1226 */ 1289 */
1227int usb_new_device(struct usb_device *udev) 1290int usb_new_device(struct usb_device *udev)
1228{ 1291{
@@ -1269,15 +1332,9 @@ int usb_new_device(struct usb_device *udev)
1269 le16_to_cpu(udev->config[0].desc.wTotalLength), 1332 le16_to_cpu(udev->config[0].desc.wTotalLength),
1270 USB_DT_OTG, (void **) &desc) == 0) { 1333 USB_DT_OTG, (void **) &desc) == 0) {
1271 if (desc->bmAttributes & USB_OTG_HNP) { 1334 if (desc->bmAttributes & USB_OTG_HNP) {
1272 unsigned port1; 1335 unsigned port1 = udev->portnum;
1273 struct usb_device *root = udev->parent; 1336 struct usb_device *root = udev->parent;
1274 1337
1275 for (port1 = 1; port1 <= root->maxchild;
1276 port1++) {
1277 if (root->children[port1-1] == udev)
1278 break;
1279 }
1280
1281 dev_info(&udev->dev, 1338 dev_info(&udev->dev,
1282 "Dual-Role OTG device on %sHNP port\n", 1339 "Dual-Role OTG device on %sHNP port\n",
1283 (port1 == bus->otg_port) 1340 (port1 == bus->otg_port)
@@ -1331,27 +1388,27 @@ int usb_new_device(struct usb_device *udev)
1331 } 1388 }
1332 usb_create_sysfs_dev_files (udev); 1389 usb_create_sysfs_dev_files (udev);
1333 1390
1391 usb_lock_device(udev);
1392
1334 /* choose and set the configuration. that registers the interfaces 1393 /* choose and set the configuration. that registers the interfaces
1335 * with the driver core, and lets usb device drivers bind to them. 1394 * with the driver core, and lets usb device drivers bind to them.
1336 */ 1395 */
1337 c = choose_configuration(udev); 1396 c = choose_configuration(udev);
1338 if (c < 0) 1397 if (c >= 0) {
1339 dev_warn(&udev->dev,
1340 "can't choose an initial configuration\n");
1341 else {
1342 err = usb_set_configuration(udev, c); 1398 err = usb_set_configuration(udev, c);
1343 if (err) { 1399 if (err) {
1344 dev_err(&udev->dev, "can't set config #%d, error %d\n", 1400 dev_err(&udev->dev, "can't set config #%d, error %d\n",
1345 c, err); 1401 c, err);
1346 usb_remove_sysfs_dev_files(udev); 1402 /* This need not be fatal. The user can try to
1347 device_del(&udev->dev); 1403 * set other configurations. */
1348 goto fail;
1349 } 1404 }
1350 } 1405 }
1351 1406
1352 /* USB device state == configured ... usable */ 1407 /* USB device state == configured ... usable */
1353 usb_notify_add_device(udev); 1408 usb_notify_add_device(udev);
1354 1409
1410 usb_unlock_device(udev);
1411
1355 return 0; 1412 return 0;
1356 1413
1357fail: 1414fail:
@@ -1654,15 +1711,9 @@ static int __usb_suspend_device (struct usb_device *udev, int port1)
1654int usb_suspend_device(struct usb_device *udev) 1711int usb_suspend_device(struct usb_device *udev)
1655{ 1712{
1656#ifdef CONFIG_USB_SUSPEND 1713#ifdef CONFIG_USB_SUSPEND
1657 int port1, status; 1714 if (udev->state == USB_STATE_NOTATTACHED)
1658 1715 return -ENODEV;
1659 port1 = locktree(udev); 1716 return __usb_suspend_device(udev, udev->portnum);
1660 if (port1 < 0)
1661 return port1;
1662
1663 status = __usb_suspend_device(udev, port1);
1664 usb_unlock_device(udev);
1665 return status;
1666#else 1717#else
1667 /* NOTE: udev->state unchanged, it's not lying ... */ 1718 /* NOTE: udev->state unchanged, it's not lying ... */
1668 udev->dev.power.power_state = PMSG_SUSPEND; 1719 udev->dev.power.power_state = PMSG_SUSPEND;
@@ -1694,13 +1745,14 @@ static int finish_device_resume(struct usb_device *udev)
1694 usb_set_device_state(udev, udev->actconfig 1745 usb_set_device_state(udev, udev->actconfig
1695 ? USB_STATE_CONFIGURED 1746 ? USB_STATE_CONFIGURED
1696 : USB_STATE_ADDRESS); 1747 : USB_STATE_ADDRESS);
1748 udev->dev.power.power_state = PMSG_ON;
1697 1749
1698 /* 10.5.4.5 says be sure devices in the tree are still there. 1750 /* 10.5.4.5 says be sure devices in the tree are still there.
1699 * For now let's assume the device didn't go crazy on resume, 1751 * For now let's assume the device didn't go crazy on resume,
1700 * and device drivers will know about any resume quirks. 1752 * and device drivers will know about any resume quirks.
1701 */ 1753 */
1702 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus); 1754 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, &devstatus);
1703 if (status < 0) 1755 if (status < 2)
1704 dev_dbg(&udev->dev, 1756 dev_dbg(&udev->dev,
1705 "gone after usb resume? status %d\n", 1757 "gone after usb resume? status %d\n",
1706 status); 1758 status);
@@ -1709,7 +1761,7 @@ static int finish_device_resume(struct usb_device *udev)
1709 int (*resume)(struct device *); 1761 int (*resume)(struct device *);
1710 1762
1711 le16_to_cpus(&devstatus); 1763 le16_to_cpus(&devstatus);
1712 if (devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP) 1764 if ((devstatus & (1 << USB_DEVICE_REMOTE_WAKEUP))
1713 && udev->parent) { 1765 && udev->parent) {
1714 status = usb_control_msg(udev, 1766 status = usb_control_msg(udev,
1715 usb_sndctrlpipe(udev, 0), 1767 usb_sndctrlpipe(udev, 0),
@@ -1729,8 +1781,14 @@ static int finish_device_resume(struct usb_device *udev)
1729 * may have a child resume event to deal with soon 1781 * may have a child resume event to deal with soon
1730 */ 1782 */
1731 resume = udev->dev.bus->resume; 1783 resume = udev->dev.bus->resume;
1732 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) 1784 for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) {
1733 (void) resume(&udev->actconfig->interface[i]->dev); 1785 struct device *dev =
1786 &udev->actconfig->interface[i]->dev;
1787
1788 down(&dev->sem);
1789 (void) resume(dev);
1790 up(&dev->sem);
1791 }
1734 status = 0; 1792 status = 0;
1735 1793
1736 } else if (udev->devnum <= 0) { 1794 } else if (udev->devnum <= 0) {
@@ -1813,11 +1871,10 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev)
1813 */ 1871 */
1814int usb_resume_device(struct usb_device *udev) 1872int usb_resume_device(struct usb_device *udev)
1815{ 1873{
1816 int port1, status; 1874 int status;
1817 1875
1818 port1 = locktree(udev); 1876 if (udev->state == USB_STATE_NOTATTACHED)
1819 if (port1 < 0) 1877 return -ENODEV;
1820 return port1;
1821 1878
1822#ifdef CONFIG_USB_SUSPEND 1879#ifdef CONFIG_USB_SUSPEND
1823 /* selective resume of one downstream hub-to-device port */ 1880 /* selective resume of one downstream hub-to-device port */
@@ -1826,7 +1883,7 @@ int usb_resume_device(struct usb_device *udev)
1826 // NOTE swsusp may bork us, device state being wrong... 1883 // NOTE swsusp may bork us, device state being wrong...
1827 // NOTE this fails if parent is also suspended... 1884 // NOTE this fails if parent is also suspended...
1828 status = hub_port_resume(hdev_to_hub(udev->parent), 1885 status = hub_port_resume(hdev_to_hub(udev->parent),
1829 port1, udev); 1886 udev->portnum, udev);
1830 } else 1887 } else
1831 status = 0; 1888 status = 0;
1832 } else 1889 } else
@@ -1836,13 +1893,11 @@ int usb_resume_device(struct usb_device *udev)
1836 dev_dbg(&udev->dev, "can't resume, status %d\n", 1893 dev_dbg(&udev->dev, "can't resume, status %d\n",
1837 status); 1894 status);
1838 1895
1839 usb_unlock_device(udev);
1840
1841 /* rebind drivers that had no suspend() */ 1896 /* rebind drivers that had no suspend() */
1842 if (status == 0) { 1897 if (status == 0) {
1843 usb_lock_all_devices(); 1898 usb_unlock_device(udev);
1844 bus_rescan_devices(&usb_bus_type); 1899 bus_rescan_devices(&usb_bus_type);
1845 usb_unlock_all_devices(); 1900 usb_lock_device(udev);
1846 } 1901 }
1847 return status; 1902 return status;
1848} 1903}
@@ -1856,14 +1911,14 @@ static int remote_wakeup(struct usb_device *udev)
1856 /* don't repeat RESUME sequence if this device 1911 /* don't repeat RESUME sequence if this device
1857 * was already woken up by some other task 1912 * was already woken up by some other task
1858 */ 1913 */
1859 down(&udev->serialize); 1914 usb_lock_device(udev);
1860 if (udev->state == USB_STATE_SUSPENDED) { 1915 if (udev->state == USB_STATE_SUSPENDED) {
1861 dev_dbg(&udev->dev, "RESUME (wakeup)\n"); 1916 dev_dbg(&udev->dev, "RESUME (wakeup)\n");
1862 /* TRSMRCY = 10 msec */ 1917 /* TRSMRCY = 10 msec */
1863 msleep(10); 1918 msleep(10);
1864 status = finish_device_resume(udev); 1919 status = finish_device_resume(udev);
1865 } 1920 }
1866 up(&udev->serialize); 1921 usb_unlock_device(udev);
1867#endif 1922#endif
1868 return status; 1923 return status;
1869} 1924}
@@ -1964,7 +2019,7 @@ static int hub_resume(struct usb_interface *intf)
1964 2019
1965 if (!udev || status < 0) 2020 if (!udev || status < 0)
1966 continue; 2021 continue;
1967 down (&udev->serialize); 2022 usb_lock_device(udev);
1968 if (portstat & USB_PORT_STAT_SUSPEND) 2023 if (portstat & USB_PORT_STAT_SUSPEND)
1969 status = hub_port_resume(hub, port1, udev); 2024 status = hub_port_resume(hub, port1, udev);
1970 else { 2025 else {
@@ -1975,7 +2030,7 @@ static int hub_resume(struct usb_interface *intf)
1975 hub_port_logical_disconnect(hub, port1); 2030 hub_port_logical_disconnect(hub, port1);
1976 } 2031 }
1977 } 2032 }
1978 up(&udev->serialize); 2033 usb_unlock_device(udev);
1979 } 2034 }
1980 } 2035 }
1981#endif 2036#endif
@@ -2359,39 +2414,36 @@ hub_power_remaining (struct usb_hub *hub)
2359{ 2414{
2360 struct usb_device *hdev = hub->hdev; 2415 struct usb_device *hdev = hub->hdev;
2361 int remaining; 2416 int remaining;
2362 unsigned i; 2417 int port1;
2363 2418
2364 remaining = hub->power_budget; 2419 if (!hub->limited_power)
2365 if (!remaining) /* self-powered */
2366 return 0; 2420 return 0;
2367 2421
2368 for (i = 0; i < hdev->maxchild; i++) { 2422 remaining = hdev->bus_mA - hub->descriptor->bHubContrCurrent;
2369 struct usb_device *udev = hdev->children[i]; 2423 for (port1 = 1; port1 <= hdev->maxchild; ++port1) {
2370 int delta, ceiling; 2424 struct usb_device *udev = hdev->children[port1 - 1];
2425 int delta;
2371 2426
2372 if (!udev) 2427 if (!udev)
2373 continue; 2428 continue;
2374 2429
2375 /* 100mA per-port ceiling, or 8mA for OTG ports */ 2430 /* Unconfigured devices may not use more than 100mA,
2376 if (i != (udev->bus->otg_port - 1) || hdev->parent) 2431 * or 8mA for OTG ports */
2377 ceiling = 50;
2378 else
2379 ceiling = 4;
2380
2381 if (udev->actconfig) 2432 if (udev->actconfig)
2382 delta = udev->actconfig->desc.bMaxPower; 2433 delta = udev->actconfig->desc.bMaxPower * 2;
2434 else if (port1 != udev->bus->otg_port || hdev->parent)
2435 delta = 100;
2383 else 2436 else
2384 delta = ceiling; 2437 delta = 8;
2385 // dev_dbg(&udev->dev, "budgeted %dmA\n", 2 * delta); 2438 if (delta > hub->mA_per_port)
2386 if (delta > ceiling) 2439 dev_warn(&udev->dev, "%dmA is over %umA budget "
2387 dev_warn(&udev->dev, "%dmA over %dmA budget!\n", 2440 "for port %d!\n",
2388 2 * (delta - ceiling), 2 * ceiling); 2441 delta, hub->mA_per_port, port1);
2389 remaining -= delta; 2442 remaining -= delta;
2390 } 2443 }
2391 if (remaining < 0) { 2444 if (remaining < 0) {
2392 dev_warn(hub->intfdev, 2445 dev_warn(hub->intfdev, "%dmA over power budget!\n",
2393 "%dmA over power budget!\n", 2446 - remaining);
2394 -2 * remaining);
2395 remaining = 0; 2447 remaining = 0;
2396 } 2448 }
2397 return remaining; 2449 return remaining;
@@ -2486,7 +2538,8 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2486 2538
2487 usb_set_device_state(udev, USB_STATE_POWERED); 2539 usb_set_device_state(udev, USB_STATE_POWERED);
2488 udev->speed = USB_SPEED_UNKNOWN; 2540 udev->speed = USB_SPEED_UNKNOWN;
2489 2541 udev->bus_mA = hub->mA_per_port;
2542
2490 /* set the address */ 2543 /* set the address */
2491 choose_address(udev); 2544 choose_address(udev);
2492 if (udev->devnum <= 0) { 2545 if (udev->devnum <= 0) {
@@ -2506,16 +2559,16 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2506 * on the parent. 2559 * on the parent.
2507 */ 2560 */
2508 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB 2561 if (udev->descriptor.bDeviceClass == USB_CLASS_HUB
2509 && hub->power_budget) { 2562 && udev->bus_mA <= 100) {
2510 u16 devstat; 2563 u16 devstat;
2511 2564
2512 status = usb_get_status(udev, USB_RECIP_DEVICE, 0, 2565 status = usb_get_status(udev, USB_RECIP_DEVICE, 0,
2513 &devstat); 2566 &devstat);
2514 if (status < 0) { 2567 if (status < 2) {
2515 dev_dbg(&udev->dev, "get status %d ?\n", status); 2568 dev_dbg(&udev->dev, "get status %d ?\n", status);
2516 goto loop_disable; 2569 goto loop_disable;
2517 } 2570 }
2518 cpu_to_le16s(&devstat); 2571 le16_to_cpus(&devstat);
2519 if ((devstat & (1 << USB_DEVICE_SELF_POWERED)) == 0) { 2572 if ((devstat & (1 << USB_DEVICE_SELF_POWERED)) == 0) {
2520 dev_err(&udev->dev, 2573 dev_err(&udev->dev,
2521 "can't connect bus-powered hub " 2574 "can't connect bus-powered hub "
@@ -2540,7 +2593,6 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2540 * udev becomes globally accessible, although presumably 2593 * udev becomes globally accessible, although presumably
2541 * no one will look at it until hdev is unlocked. 2594 * no one will look at it until hdev is unlocked.
2542 */ 2595 */
2543 down (&udev->serialize);
2544 status = 0; 2596 status = 0;
2545 2597
2546 /* We mustn't add new devices if the parent hub has 2598 /* We mustn't add new devices if the parent hub has
@@ -2564,15 +2616,12 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
2564 } 2616 }
2565 } 2617 }
2566 2618
2567 up (&udev->serialize);
2568 if (status) 2619 if (status)
2569 goto loop_disable; 2620 goto loop_disable;
2570 2621
2571 status = hub_power_remaining(hub); 2622 status = hub_power_remaining(hub);
2572 if (status) 2623 if (status)
2573 dev_dbg(hub_dev, 2624 dev_dbg(hub_dev, "%dmA power budget left\n", status);
2574 "%dmA power budget left\n",
2575 2 * status);
2576 2625
2577 return; 2626 return;
2578 2627
@@ -2648,6 +2697,8 @@ static void hub_events(void)
2648 if (i) { 2697 if (i) {
2649 dpm_runtime_resume(&hdev->dev); 2698 dpm_runtime_resume(&hdev->dev);
2650 dpm_runtime_resume(&intf->dev); 2699 dpm_runtime_resume(&intf->dev);
2700 usb_put_intf(intf);
2701 continue;
2651 } 2702 }
2652 2703
2653 /* Lock the device, then check to see if we were 2704 /* Lock the device, then check to see if we were
@@ -2661,7 +2712,7 @@ static void hub_events(void)
2661 2712
2662 /* If the hub has died, clean up after it */ 2713 /* If the hub has died, clean up after it */
2663 if (hdev->state == USB_STATE_NOTATTACHED) { 2714 if (hdev->state == USB_STATE_NOTATTACHED) {
2664 hub_pre_reset(hub); 2715 hub_pre_reset(hub, 0);
2665 goto loop; 2716 goto loop;
2666 } 2717 }
2667 2718
@@ -2784,6 +2835,11 @@ static void hub_events(void)
2784 if (hubchange & HUB_CHANGE_LOCAL_POWER) { 2835 if (hubchange & HUB_CHANGE_LOCAL_POWER) {
2785 dev_dbg (hub_dev, "power change\n"); 2836 dev_dbg (hub_dev, "power change\n");
2786 clear_hub_feature(hdev, C_HUB_LOCAL_POWER); 2837 clear_hub_feature(hdev, C_HUB_LOCAL_POWER);
2838 if (hubstatus & HUB_STATUS_LOCAL_POWER)
2839 /* FIXME: Is this always true? */
2840 hub->limited_power = 0;
2841 else
2842 hub->limited_power = 1;
2787 } 2843 }
2788 if (hubchange & HUB_CHANGE_OVERCURRENT) { 2844 if (hubchange & HUB_CHANGE_OVERCURRENT) {
2789 dev_dbg (hub_dev, "overcurrent change\n"); 2845 dev_dbg (hub_dev, "overcurrent change\n");
@@ -2832,7 +2888,6 @@ static struct usb_device_id hub_id_table [] = {
2832MODULE_DEVICE_TABLE (usb, hub_id_table); 2888MODULE_DEVICE_TABLE (usb, hub_id_table);
2833 2889
2834static struct usb_driver hub_driver = { 2890static struct usb_driver hub_driver = {
2835 .owner = THIS_MODULE,
2836 .name = "hub", 2891 .name = "hub",
2837 .probe = hub_probe, 2892 .probe = hub_probe,
2838 .disconnect = hub_disconnect, 2893 .disconnect = hub_disconnect,
@@ -2944,7 +2999,8 @@ int usb_reset_device(struct usb_device *udev)
2944 struct usb_hub *parent_hub; 2999 struct usb_hub *parent_hub;
2945 struct usb_device_descriptor descriptor = udev->descriptor; 3000 struct usb_device_descriptor descriptor = udev->descriptor;
2946 struct usb_hub *hub = NULL; 3001 struct usb_hub *hub = NULL;
2947 int i, ret = 0, port1 = -1; 3002 int i, ret = 0;
3003 int port1 = udev->portnum;
2948 3004
2949 if (udev->state == USB_STATE_NOTATTACHED || 3005 if (udev->state == USB_STATE_NOTATTACHED ||
2950 udev->state == USB_STATE_SUSPENDED) { 3006 udev->state == USB_STATE_SUSPENDED) {
@@ -2958,18 +3014,6 @@ int usb_reset_device(struct usb_device *udev)
2958 dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__); 3014 dev_dbg(&udev->dev, "%s for root hub!\n", __FUNCTION__);
2959 return -EISDIR; 3015 return -EISDIR;
2960 } 3016 }
2961
2962 for (i = 0; i < parent_hdev->maxchild; i++)
2963 if (parent_hdev->children[i] == udev) {
2964 port1 = i + 1;
2965 break;
2966 }
2967
2968 if (port1 < 0) {
2969 /* If this ever happens, it's very bad */
2970 dev_err(&udev->dev, "Can't locate device's port!\n");
2971 return -ENOENT;
2972 }
2973 parent_hub = hdev_to_hub(parent_hdev); 3017 parent_hub = hdev_to_hub(parent_hdev);
2974 3018
2975 /* If we're resetting an active hub, take some special actions */ 3019 /* If we're resetting an active hub, take some special actions */
@@ -2977,7 +3021,7 @@ int usb_reset_device(struct usb_device *udev)
2977 udev->actconfig->interface[0]->dev.driver == 3021 udev->actconfig->interface[0]->dev.driver ==
2978 &hub_driver.driver && 3022 &hub_driver.driver &&
2979 (hub = hdev_to_hub(udev)) != NULL) { 3023 (hub = hdev_to_hub(udev)) != NULL) {
2980 hub_pre_reset(hub); 3024 hub_pre_reset(hub, 0);
2981 } 3025 }
2982 3026
2983 set_bit(port1, parent_hub->busy_bits); 3027 set_bit(port1, parent_hub->busy_bits);
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h
index bf23f8978024..29d5f45a8456 100644
--- a/drivers/usb/core/hub.h
+++ b/drivers/usb/core/hub.h
@@ -220,8 +220,9 @@ struct usb_hub {
220 struct usb_hub_descriptor *descriptor; /* class descriptor */ 220 struct usb_hub_descriptor *descriptor; /* class descriptor */
221 struct usb_tt tt; /* Transaction Translator */ 221 struct usb_tt tt; /* Transaction Translator */
222 222
223 u8 power_budget; /* in 2mA units; or zero */ 223 unsigned mA_per_port; /* current for each child */
224 224
225 unsigned limited_power:1;
225 unsigned quiescing:1; 226 unsigned quiescing:1;
226 unsigned activating:1; 227 unsigned activating:1;
227 unsigned resume_root_hub:1; 228 unsigned resume_root_hub:1;
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index fe74f99ca5f4..319de03944e7 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -1387,6 +1387,12 @@ free_interfaces:
1387 if (dev->state != USB_STATE_ADDRESS) 1387 if (dev->state != USB_STATE_ADDRESS)
1388 usb_disable_device (dev, 1); // Skip ep0 1388 usb_disable_device (dev, 1); // Skip ep0
1389 1389
1390 i = dev->bus_mA - cp->desc.bMaxPower * 2;
1391 if (i < 0)
1392 dev_warn(&dev->dev, "new config #%d exceeds power "
1393 "limit by %dmA\n",
1394 configuration, -i);
1395
1390 if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 1396 if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
1391 USB_REQ_SET_CONFIGURATION, 0, configuration, 0, 1397 USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
1392 NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) 1398 NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index e197ce9353de..13d1d367f7f1 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -32,7 +32,6 @@
32#include <linux/spinlock.h> 32#include <linux/spinlock.h>
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/smp_lock.h> 34#include <linux/smp_lock.h>
35#include <linux/rwsem.h>
36#include <linux/usb.h> 35#include <linux/usb.h>
37 36
38#include <asm/io.h> 37#include <asm/io.h>
@@ -47,165 +46,7 @@
47const char *usbcore_name = "usbcore"; 46const char *usbcore_name = "usbcore";
48 47
49static int nousb; /* Disable USB when built into kernel image */ 48static int nousb; /* Disable USB when built into kernel image */
50 /* Not honored on modular build */
51 49
52static DECLARE_RWSEM(usb_all_devices_rwsem);
53
54
55static int generic_probe (struct device *dev)
56{
57 return 0;
58}
59static int generic_remove (struct device *dev)
60{
61 struct usb_device *udev = to_usb_device(dev);
62
63 /* if this is only an unbind, not a physical disconnect, then
64 * unconfigure the device */
65 if (udev->state == USB_STATE_CONFIGURED)
66 usb_set_configuration(udev, 0);
67
68 /* in case the call failed or the device was suspended */
69 if (udev->state >= USB_STATE_CONFIGURED)
70 usb_disable_device(udev, 0);
71 return 0;
72}
73
74static struct device_driver usb_generic_driver = {
75 .owner = THIS_MODULE,
76 .name = "usb",
77 .bus = &usb_bus_type,
78 .probe = generic_probe,
79 .remove = generic_remove,
80};
81
82static int usb_generic_driver_data;
83
84/* called from driver core with usb_bus_type.subsys writelock */
85static int usb_probe_interface(struct device *dev)
86{
87 struct usb_interface * intf = to_usb_interface(dev);
88 struct usb_driver * driver = to_usb_driver(dev->driver);
89 const struct usb_device_id *id;
90 int error = -ENODEV;
91
92 dev_dbg(dev, "%s\n", __FUNCTION__);
93
94 if (!driver->probe)
95 return error;
96 /* FIXME we'd much prefer to just resume it ... */
97 if (interface_to_usbdev(intf)->state == USB_STATE_SUSPENDED)
98 return -EHOSTUNREACH;
99
100 id = usb_match_id (intf, driver->id_table);
101 if (id) {
102 dev_dbg (dev, "%s - got id\n", __FUNCTION__);
103
104 /* Interface "power state" doesn't correspond to any hardware
105 * state whatsoever. We use it to record when it's bound to
106 * a driver that may start I/0: it's not frozen/quiesced.
107 */
108 mark_active(intf);
109 intf->condition = USB_INTERFACE_BINDING;
110 error = driver->probe (intf, id);
111 if (error) {
112 mark_quiesced(intf);
113 intf->condition = USB_INTERFACE_UNBOUND;
114 } else
115 intf->condition = USB_INTERFACE_BOUND;
116 }
117
118 return error;
119}
120
121/* called from driver core with usb_bus_type.subsys writelock */
122static int usb_unbind_interface(struct device *dev)
123{
124 struct usb_interface *intf = to_usb_interface(dev);
125 struct usb_driver *driver = to_usb_driver(intf->dev.driver);
126
127 intf->condition = USB_INTERFACE_UNBINDING;
128
129 /* release all urbs for this interface */
130 usb_disable_interface(interface_to_usbdev(intf), intf);
131
132 if (driver && driver->disconnect)
133 driver->disconnect(intf);
134
135 /* reset other interface state */
136 usb_set_interface(interface_to_usbdev(intf),
137 intf->altsetting[0].desc.bInterfaceNumber,
138 0);
139 usb_set_intfdata(intf, NULL);
140 intf->condition = USB_INTERFACE_UNBOUND;
141 mark_quiesced(intf);
142
143 return 0;
144}
145
146/**
147 * usb_register - register a USB driver
148 * @new_driver: USB operations for the driver
149 *
150 * Registers a USB driver with the USB core. The list of unattached
151 * interfaces will be rescanned whenever a new driver is added, allowing
152 * the new driver to attach to any recognized devices.
153 * Returns a negative error code on failure and 0 on success.
154 *
155 * NOTE: if you want your driver to use the USB major number, you must call
156 * usb_register_dev() to enable that functionality. This function no longer
157 * takes care of that.
158 */
159int usb_register(struct usb_driver *new_driver)
160{
161 int retval = 0;
162
163 if (nousb)
164 return -ENODEV;
165
166 new_driver->driver.name = (char *)new_driver->name;
167 new_driver->driver.bus = &usb_bus_type;
168 new_driver->driver.probe = usb_probe_interface;
169 new_driver->driver.remove = usb_unbind_interface;
170 new_driver->driver.owner = new_driver->owner;
171
172 usb_lock_all_devices();
173 retval = driver_register(&new_driver->driver);
174 usb_unlock_all_devices();
175
176 if (!retval) {
177 pr_info("%s: registered new driver %s\n",
178 usbcore_name, new_driver->name);
179 usbfs_update_special();
180 } else {
181 printk(KERN_ERR "%s: error %d registering driver %s\n",
182 usbcore_name, retval, new_driver->name);
183 }
184
185 return retval;
186}
187
188/**
189 * usb_deregister - unregister a USB driver
190 * @driver: USB operations of the driver to unregister
191 * Context: must be able to sleep
192 *
193 * Unlinks the specified driver from the internal USB driver list.
194 *
195 * NOTE: If you called usb_register_dev(), you still need to call
196 * usb_deregister_dev() to clean up your driver's allocated minor numbers,
197 * this * call will no longer do it for you.
198 */
199void usb_deregister(struct usb_driver *driver)
200{
201 pr_info("%s: deregistering driver %s\n", usbcore_name, driver->name);
202
203 usb_lock_all_devices();
204 driver_unregister (&driver->driver);
205 usb_unlock_all_devices();
206
207 usbfs_update_special();
208}
209 50
210/** 51/**
211 * usb_ifnum_to_if - get the interface object with a given interface number 52 * usb_ifnum_to_if - get the interface object with a given interface number
@@ -352,151 +193,23 @@ void usb_driver_release_interface(struct usb_driver *driver,
352 mark_quiesced(iface); 193 mark_quiesced(iface);
353} 194}
354 195
355/** 196struct find_interface_arg {
356 * usb_match_id - find first usb_device_id matching device or interface 197 int minor;
357 * @interface: the interface of interest 198 struct usb_interface *interface;
358 * @id: array of usb_device_id structures, terminated by zero entry 199};
359 *
360 * usb_match_id searches an array of usb_device_id's and returns
361 * the first one matching the device or interface, or null.
362 * This is used when binding (or rebinding) a driver to an interface.
363 * Most USB device drivers will use this indirectly, through the usb core,
364 * but some layered driver frameworks use it directly.
365 * These device tables are exported with MODULE_DEVICE_TABLE, through
366 * modutils and "modules.usbmap", to support the driver loading
367 * functionality of USB hotplugging.
368 *
369 * What Matches:
370 *
371 * The "match_flags" element in a usb_device_id controls which
372 * members are used. If the corresponding bit is set, the
373 * value in the device_id must match its corresponding member
374 * in the device or interface descriptor, or else the device_id
375 * does not match.
376 *
377 * "driver_info" is normally used only by device drivers,
378 * but you can create a wildcard "matches anything" usb_device_id
379 * as a driver's "modules.usbmap" entry if you provide an id with
380 * only a nonzero "driver_info" field. If you do this, the USB device
381 * driver's probe() routine should use additional intelligence to
382 * decide whether to bind to the specified interface.
383 *
384 * What Makes Good usb_device_id Tables:
385 *
386 * The match algorithm is very simple, so that intelligence in
387 * driver selection must come from smart driver id records.
388 * Unless you have good reasons to use another selection policy,
389 * provide match elements only in related groups, and order match
390 * specifiers from specific to general. Use the macros provided
391 * for that purpose if you can.
392 *
393 * The most specific match specifiers use device descriptor
394 * data. These are commonly used with product-specific matches;
395 * the USB_DEVICE macro lets you provide vendor and product IDs,
396 * and you can also match against ranges of product revisions.
397 * These are widely used for devices with application or vendor
398 * specific bDeviceClass values.
399 *
400 * Matches based on device class/subclass/protocol specifications
401 * are slightly more general; use the USB_DEVICE_INFO macro, or
402 * its siblings. These are used with single-function devices
403 * where bDeviceClass doesn't specify that each interface has
404 * its own class.
405 *
406 * Matches based on interface class/subclass/protocol are the
407 * most general; they let drivers bind to any interface on a
408 * multiple-function device. Use the USB_INTERFACE_INFO
409 * macro, or its siblings, to match class-per-interface style
410 * devices (as recorded in bDeviceClass).
411 *
412 * Within those groups, remember that not all combinations are
413 * meaningful. For example, don't give a product version range
414 * without vendor and product IDs; or specify a protocol without
415 * its associated class and subclass.
416 */
417const struct usb_device_id *
418usb_match_id(struct usb_interface *interface, const struct usb_device_id *id)
419{
420 struct usb_host_interface *intf;
421 struct usb_device *dev;
422
423 /* proc_connectinfo in devio.c may call us with id == NULL. */
424 if (id == NULL)
425 return NULL;
426
427 intf = interface->cur_altsetting;
428 dev = interface_to_usbdev(interface);
429
430 /* It is important to check that id->driver_info is nonzero,
431 since an entry that is all zeroes except for a nonzero
432 id->driver_info is the way to create an entry that
433 indicates that the driver want to examine every
434 device and interface. */
435 for (; id->idVendor || id->bDeviceClass || id->bInterfaceClass ||
436 id->driver_info; id++) {
437
438 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
439 id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
440 continue;
441
442 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
443 id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
444 continue;
445
446 /* No need to test id->bcdDevice_lo != 0, since 0 is never
447 greater than any unsigned number. */
448 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
449 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
450 continue;
451
452 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
453 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
454 continue;
455
456 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
457 (id->bDeviceClass != dev->descriptor.bDeviceClass))
458 continue;
459
460 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
461 (id->bDeviceSubClass!= dev->descriptor.bDeviceSubClass))
462 continue;
463
464 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
465 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
466 continue;
467
468 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) &&
469 (id->bInterfaceClass != intf->desc.bInterfaceClass))
470 continue;
471
472 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_SUBCLASS) &&
473 (id->bInterfaceSubClass != intf->desc.bInterfaceSubClass))
474 continue;
475
476 if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_PROTOCOL) &&
477 (id->bInterfaceProtocol != intf->desc.bInterfaceProtocol))
478 continue;
479
480 return id;
481 }
482
483 return NULL;
484}
485
486 200
487static int __find_interface(struct device * dev, void * data) 201static int __find_interface(struct device * dev, void * data)
488{ 202{
489 struct usb_interface ** ret = (struct usb_interface **)data; 203 struct find_interface_arg *arg = data;
490 struct usb_interface * intf = *ret; 204 struct usb_interface *intf;
491 int *minor = (int *)data;
492 205
493 /* can't look at usb devices, only interfaces */ 206 /* can't look at usb devices, only interfaces */
494 if (dev->driver == &usb_generic_driver) 207 if (dev->driver == &usb_generic_driver)
495 return 0; 208 return 0;
496 209
497 intf = to_usb_interface(dev); 210 intf = to_usb_interface(dev);
498 if (intf->minor != -1 && intf->minor == *minor) { 211 if (intf->minor != -1 && intf->minor == arg->minor) {
499 *ret = intf; 212 arg->interface = intf;
500 return 1; 213 return 1;
501 } 214 }
502 return 0; 215 return 0;
@@ -513,42 +226,18 @@ static int __find_interface(struct device * dev, void * data)
513 */ 226 */
514struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor) 227struct usb_interface *usb_find_interface(struct usb_driver *drv, int minor)
515{ 228{
516 struct usb_interface *intf = (struct usb_interface *)(long)minor; 229 struct find_interface_arg argb;
517 int ret;
518
519 ret = driver_for_each_device(&drv->driver, NULL, &intf, __find_interface);
520 230
521 return ret ? intf : NULL; 231 argb.minor = minor;
232 argb.interface = NULL;
233 driver_for_each_device(&drv->driver, NULL, &argb, __find_interface);
234 return argb.interface;
522} 235}
523 236
524static int usb_device_match (struct device *dev, struct device_driver *drv)
525{
526 struct usb_interface *intf;
527 struct usb_driver *usb_drv;
528 const struct usb_device_id *id;
529
530 /* check for generic driver, which we don't match any device with */
531 if (drv == &usb_generic_driver)
532 return 0;
533
534 intf = to_usb_interface(dev);
535 usb_drv = to_usb_driver(drv);
536
537 id = usb_match_id (intf, usb_drv->id_table);
538 if (id)
539 return 1;
540
541 return 0;
542}
543
544
545#ifdef CONFIG_HOTPLUG 237#ifdef CONFIG_HOTPLUG
546 238
547/* 239/*
548 * USB hotplugging invokes what /proc/sys/kernel/hotplug says 240 * This sends an uevent to userspace, typically helping to load driver
549 * (normally /sbin/hotplug) when USB devices get added or removed.
550 *
551 * This invokes a user mode policy agent, typically helping to load driver
552 * or other modules, configure the device, and more. Drivers can provide 241 * or other modules, configure the device, and more. Drivers can provide
553 * a MODULE_DEVICE_TABLE to help with module loading subtasks. 242 * a MODULE_DEVICE_TABLE to help with module loading subtasks.
554 * 243 *
@@ -557,8 +246,8 @@ static int usb_device_match (struct device *dev, struct device_driver *drv)
557 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the 246 * delays in event delivery. Use sysfs (and DEVPATH) to make sure the
558 * device (and this configuration!) are still present. 247 * device (and this configuration!) are still present.
559 */ 248 */
560static int usb_hotplug (struct device *dev, char **envp, int num_envp, 249static int usb_uevent(struct device *dev, char **envp, int num_envp,
561 char *buffer, int buffer_size) 250 char *buffer, int buffer_size)
562{ 251{
563 struct usb_interface *intf; 252 struct usb_interface *intf;
564 struct usb_device *usb_dev; 253 struct usb_device *usb_dev;
@@ -570,7 +259,7 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
570 return -ENODEV; 259 return -ENODEV;
571 260
572 /* driver is often null here; dev_dbg() would oops */ 261 /* driver is often null here; dev_dbg() would oops */
573 pr_debug ("usb %s: hotplug\n", dev->bus_id); 262 pr_debug ("usb %s: uevent\n", dev->bus_id);
574 263
575 /* Must check driver_data here, as on remove driver is always NULL */ 264 /* Must check driver_data here, as on remove driver is always NULL */
576 if ((dev->driver == &usb_generic_driver) || 265 if ((dev->driver == &usb_generic_driver) ||
@@ -597,51 +286,51 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
597 * 286 *
598 * FIXME reduce hardwired intelligence here 287 * FIXME reduce hardwired intelligence here
599 */ 288 */
600 if (add_hotplug_env_var(envp, num_envp, &i, 289 if (add_uevent_var(envp, num_envp, &i,
601 buffer, buffer_size, &length, 290 buffer, buffer_size, &length,
602 "DEVICE=/proc/bus/usb/%03d/%03d", 291 "DEVICE=/proc/bus/usb/%03d/%03d",
603 usb_dev->bus->busnum, usb_dev->devnum)) 292 usb_dev->bus->busnum, usb_dev->devnum))
604 return -ENOMEM; 293 return -ENOMEM;
605#endif 294#endif
606 295
607 /* per-device configurations are common */ 296 /* per-device configurations are common */
608 if (add_hotplug_env_var(envp, num_envp, &i, 297 if (add_uevent_var(envp, num_envp, &i,
609 buffer, buffer_size, &length, 298 buffer, buffer_size, &length,
610 "PRODUCT=%x/%x/%x", 299 "PRODUCT=%x/%x/%x",
611 le16_to_cpu(usb_dev->descriptor.idVendor), 300 le16_to_cpu(usb_dev->descriptor.idVendor),
612 le16_to_cpu(usb_dev->descriptor.idProduct), 301 le16_to_cpu(usb_dev->descriptor.idProduct),
613 le16_to_cpu(usb_dev->descriptor.bcdDevice))) 302 le16_to_cpu(usb_dev->descriptor.bcdDevice)))
614 return -ENOMEM; 303 return -ENOMEM;
615 304
616 /* class-based driver binding models */ 305 /* class-based driver binding models */
617 if (add_hotplug_env_var(envp, num_envp, &i, 306 if (add_uevent_var(envp, num_envp, &i,
618 buffer, buffer_size, &length, 307 buffer, buffer_size, &length,
619 "TYPE=%d/%d/%d", 308 "TYPE=%d/%d/%d",
620 usb_dev->descriptor.bDeviceClass, 309 usb_dev->descriptor.bDeviceClass,
621 usb_dev->descriptor.bDeviceSubClass, 310 usb_dev->descriptor.bDeviceSubClass,
622 usb_dev->descriptor.bDeviceProtocol)) 311 usb_dev->descriptor.bDeviceProtocol))
623 return -ENOMEM; 312 return -ENOMEM;
624 313
625 if (add_hotplug_env_var(envp, num_envp, &i, 314 if (add_uevent_var(envp, num_envp, &i,
626 buffer, buffer_size, &length, 315 buffer, buffer_size, &length,
627 "INTERFACE=%d/%d/%d", 316 "INTERFACE=%d/%d/%d",
628 alt->desc.bInterfaceClass, 317 alt->desc.bInterfaceClass,
629 alt->desc.bInterfaceSubClass, 318 alt->desc.bInterfaceSubClass,
630 alt->desc.bInterfaceProtocol)) 319 alt->desc.bInterfaceProtocol))
631 return -ENOMEM; 320 return -ENOMEM;
632 321
633 if (add_hotplug_env_var(envp, num_envp, &i, 322 if (add_uevent_var(envp, num_envp, &i,
634 buffer, buffer_size, &length, 323 buffer, buffer_size, &length,
635 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X", 324 "MODALIAS=usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02Xic%02Xisc%02Xip%02X",
636 le16_to_cpu(usb_dev->descriptor.idVendor), 325 le16_to_cpu(usb_dev->descriptor.idVendor),
637 le16_to_cpu(usb_dev->descriptor.idProduct), 326 le16_to_cpu(usb_dev->descriptor.idProduct),
638 le16_to_cpu(usb_dev->descriptor.bcdDevice), 327 le16_to_cpu(usb_dev->descriptor.bcdDevice),
639 usb_dev->descriptor.bDeviceClass, 328 usb_dev->descriptor.bDeviceClass,
640 usb_dev->descriptor.bDeviceSubClass, 329 usb_dev->descriptor.bDeviceSubClass,
641 usb_dev->descriptor.bDeviceProtocol, 330 usb_dev->descriptor.bDeviceProtocol,
642 alt->desc.bInterfaceClass, 331 alt->desc.bInterfaceClass,
643 alt->desc.bInterfaceSubClass, 332 alt->desc.bInterfaceSubClass,
644 alt->desc.bInterfaceProtocol)) 333 alt->desc.bInterfaceProtocol))
645 return -ENOMEM; 334 return -ENOMEM;
646 335
647 envp[i] = NULL; 336 envp[i] = NULL;
@@ -651,7 +340,7 @@ static int usb_hotplug (struct device *dev, char **envp, int num_envp,
651 340
652#else 341#else
653 342
654static int usb_hotplug (struct device *dev, char **envp, 343static int usb_uevent(struct device *dev, char **envp,
655 int num_envp, char *buffer, int buffer_size) 344 int num_envp, char *buffer, int buffer_size)
656{ 345{
657 return -ENODEV; 346 return -ENODEV;
@@ -750,12 +439,11 @@ usb_alloc_dev(struct usb_device *parent, struct usb_bus *bus, unsigned port1)
750 /* hub driver sets up TT records */ 439 /* hub driver sets up TT records */
751 } 440 }
752 441
442 dev->portnum = port1;
753 dev->bus = bus; 443 dev->bus = bus;
754 dev->parent = parent; 444 dev->parent = parent;
755 INIT_LIST_HEAD(&dev->filelist); 445 INIT_LIST_HEAD(&dev->filelist);
756 446
757 init_MUTEX(&dev->serialize);
758
759 return dev; 447 return dev;
760} 448}
761 449
@@ -828,76 +516,21 @@ void usb_put_intf(struct usb_interface *intf)
828 516
829/* USB device locking 517/* USB device locking
830 * 518 *
831 * Although locking USB devices should be straightforward, it is 519 * USB devices and interfaces are locked using the semaphore in their
832 * complicated by the way the driver-model core works. When a new USB 520 * embedded struct device. The hub driver guarantees that whenever a
833 * driver is registered or unregistered, the core will automatically 521 * device is connected or disconnected, drivers are called with the
834 * probe or disconnect all matching interfaces on all USB devices while 522 * USB device locked as well as their particular interface.
835 * holding the USB subsystem writelock. There's no good way for us to
836 * tell which devices will be used or to lock them beforehand; our only
837 * option is to effectively lock all the USB devices.
838 *
839 * We do that by using a private rw-semaphore, usb_all_devices_rwsem.
840 * When locking an individual device you must first acquire the rwsem's
841 * readlock. When a driver is registered or unregistered the writelock
842 * must be held. These actions are encapsulated in the subroutines
843 * below, so all a driver needs to do is call usb_lock_device() and
844 * usb_unlock_device().
845 * 523 *
846 * Complications arise when several devices are to be locked at the same 524 * Complications arise when several devices are to be locked at the same
847 * time. Only hub-aware drivers that are part of usbcore ever have to 525 * time. Only hub-aware drivers that are part of usbcore ever have to
848 * do this; nobody else needs to worry about it. The problem is that 526 * do this; nobody else needs to worry about it. The rule for locking
849 * usb_lock_device() must not be called to lock a second device since it 527 * is simple:
850 * would acquire the rwsem's readlock reentrantly, leading to deadlock if
851 * another thread was waiting for the writelock. The solution is simple:
852 *
853 * When locking more than one device, call usb_lock_device()
854 * to lock the first one. Lock the others by calling
855 * down(&udev->serialize) directly.
856 *
857 * When unlocking multiple devices, use up(&udev->serialize)
858 * to unlock all but the last one. Unlock the last one by
859 * calling usb_unlock_device().
860 * 528 *
861 * When locking both a device and its parent, always lock the 529 * When locking both a device and its parent, always lock the
862 * the parent first. 530 * the parent first.
863 */ 531 */
864 532
865/** 533/**
866 * usb_lock_device - acquire the lock for a usb device structure
867 * @udev: device that's being locked
868 *
869 * Use this routine when you don't hold any other device locks;
870 * to acquire nested inner locks call down(&udev->serialize) directly.
871 * This is necessary for proper interaction with usb_lock_all_devices().
872 */
873void usb_lock_device(struct usb_device *udev)
874{
875 down_read(&usb_all_devices_rwsem);
876 down(&udev->serialize);
877}
878
879/**
880 * usb_trylock_device - attempt to acquire the lock for a usb device structure
881 * @udev: device that's being locked
882 *
883 * Don't use this routine if you already hold a device lock;
884 * use down_trylock(&udev->serialize) instead.
885 * This is necessary for proper interaction with usb_lock_all_devices().
886 *
887 * Returns 1 if successful, 0 if contention.
888 */
889int usb_trylock_device(struct usb_device *udev)
890{
891 if (!down_read_trylock(&usb_all_devices_rwsem))
892 return 0;
893 if (down_trylock(&udev->serialize)) {
894 up_read(&usb_all_devices_rwsem);
895 return 0;
896 }
897 return 1;
898}
899
900/**
901 * usb_lock_device_for_reset - cautiously acquire the lock for a 534 * usb_lock_device_for_reset - cautiously acquire the lock for a
902 * usb device structure 535 * usb device structure
903 * @udev: device that's being locked 536 * @udev: device that's being locked
@@ -935,7 +568,7 @@ int usb_lock_device_for_reset(struct usb_device *udev,
935 } 568 }
936 } 569 }
937 570
938 while (!usb_trylock_device(udev)) { 571 while (usb_trylock_device(udev) != 0) {
939 572
940 /* If we can't acquire the lock after waiting one second, 573 /* If we can't acquire the lock after waiting one second,
941 * we're probably deadlocked */ 574 * we're probably deadlocked */
@@ -953,39 +586,6 @@ int usb_lock_device_for_reset(struct usb_device *udev,
953 return 1; 586 return 1;
954} 587}
955 588
956/**
957 * usb_unlock_device - release the lock for a usb device structure
958 * @udev: device that's being unlocked
959 *
960 * Use this routine when releasing the only device lock you hold;
961 * to release inner nested locks call up(&udev->serialize) directly.
962 * This is necessary for proper interaction with usb_lock_all_devices().
963 */
964void usb_unlock_device(struct usb_device *udev)
965{
966 up(&udev->serialize);
967 up_read(&usb_all_devices_rwsem);
968}
969
970/**
971 * usb_lock_all_devices - acquire the lock for all usb device structures
972 *
973 * This is necessary when registering a new driver or probing a bus,
974 * since the driver-model core may try to use any usb_device.
975 */
976void usb_lock_all_devices(void)
977{
978 down_write(&usb_all_devices_rwsem);
979}
980
981/**
982 * usb_unlock_all_devices - release the lock for all usb device structures
983 */
984void usb_unlock_all_devices(void)
985{
986 up_write(&usb_all_devices_rwsem);
987}
988
989 589
990static struct usb_device *match_device(struct usb_device *dev, 590static struct usb_device *match_device(struct usb_device *dev,
991 u16 vendor_id, u16 product_id) 591 u16 vendor_id, u16 product_id)
@@ -1008,10 +608,10 @@ static struct usb_device *match_device(struct usb_device *dev,
1008 /* look through all of the children of this device */ 608 /* look through all of the children of this device */
1009 for (child = 0; child < dev->maxchild; ++child) { 609 for (child = 0; child < dev->maxchild; ++child) {
1010 if (dev->children[child]) { 610 if (dev->children[child]) {
1011 down(&dev->children[child]->serialize); 611 usb_lock_device(dev->children[child]);
1012 ret_dev = match_device(dev->children[child], 612 ret_dev = match_device(dev->children[child],
1013 vendor_id, product_id); 613 vendor_id, product_id);
1014 up(&dev->children[child]->serialize); 614 usb_unlock_device(dev->children[child]);
1015 if (ret_dev) 615 if (ret_dev)
1016 goto exit; 616 goto exit;
1017 } 617 }
@@ -1432,7 +1032,8 @@ static int usb_generic_suspend(struct device *dev, pm_message_t message)
1432 mark_quiesced(intf); 1032 mark_quiesced(intf);
1433 } else { 1033 } else {
1434 // FIXME else if there's no suspend method, disconnect... 1034 // FIXME else if there's no suspend method, disconnect...
1435 dev_warn(dev, "no %s?\n", "suspend"); 1035 dev_warn(dev, "no suspend for driver %s?\n", driver->name);
1036 mark_quiesced(intf);
1436 status = 0; 1037 status = 0;
1437 } 1038 }
1438 return status; 1039 return status;
@@ -1460,8 +1061,10 @@ static int usb_generic_resume(struct device *dev)
1460 } 1061 }
1461 1062
1462 if ((dev->driver == NULL) || 1063 if ((dev->driver == NULL) ||
1463 (dev->driver_data == &usb_generic_driver_data)) 1064 (dev->driver_data == &usb_generic_driver_data)) {
1065 dev->power.power_state.event = PM_EVENT_FREEZE;
1464 return 0; 1066 return 0;
1067 }
1465 1068
1466 intf = to_usb_interface(dev); 1069 intf = to_usb_interface(dev);
1467 driver = to_usb_driver(dev->driver); 1070 driver = to_usb_driver(dev->driver);
@@ -1481,30 +1084,20 @@ static int usb_generic_resume(struct device *dev)
1481 mark_quiesced(intf); 1084 mark_quiesced(intf);
1482 } 1085 }
1483 } else 1086 } else
1484 dev_warn(dev, "no %s?\n", "resume"); 1087 dev_warn(dev, "no resume for driver %s?\n", driver->name);
1485 return 0; 1088 return 0;
1486} 1089}
1487 1090
1488struct bus_type usb_bus_type = { 1091struct bus_type usb_bus_type = {
1489 .name = "usb", 1092 .name = "usb",
1490 .match = usb_device_match, 1093 .match = usb_device_match,
1491 .hotplug = usb_hotplug, 1094 .uevent = usb_uevent,
1492 .suspend = usb_generic_suspend, 1095 .suspend = usb_generic_suspend,
1493 .resume = usb_generic_resume, 1096 .resume = usb_generic_resume,
1494}; 1097};
1495 1098
1496#ifndef MODULE
1497
1498static int __init usb_setup_disable(char *str)
1499{
1500 nousb = 1;
1501 return 1;
1502}
1503
1504/* format to disable USB on kernel command line is: nousb */ 1099/* format to disable USB on kernel command line is: nousb */
1505__setup("nousb", usb_setup_disable); 1100__module_param_call("", nousb, param_set_bool, param_get_bool, &nousb, 0444);
1506
1507#endif
1508 1101
1509/* 1102/*
1510 * for external read access to <nousb> 1103 * for external read access to <nousb>
@@ -1595,8 +1188,6 @@ module_exit(usb_exit);
1595 * driver modules to use. 1188 * driver modules to use.
1596 */ 1189 */
1597 1190
1598EXPORT_SYMBOL(usb_register);
1599EXPORT_SYMBOL(usb_deregister);
1600EXPORT_SYMBOL(usb_disabled); 1191EXPORT_SYMBOL(usb_disabled);
1601 1192
1602EXPORT_SYMBOL_GPL(usb_get_intf); 1193EXPORT_SYMBOL_GPL(usb_get_intf);
@@ -1607,14 +1198,10 @@ EXPORT_SYMBOL(usb_put_dev);
1607EXPORT_SYMBOL(usb_get_dev); 1198EXPORT_SYMBOL(usb_get_dev);
1608EXPORT_SYMBOL(usb_hub_tt_clear_buffer); 1199EXPORT_SYMBOL(usb_hub_tt_clear_buffer);
1609 1200
1610EXPORT_SYMBOL(usb_lock_device);
1611EXPORT_SYMBOL(usb_trylock_device);
1612EXPORT_SYMBOL(usb_lock_device_for_reset); 1201EXPORT_SYMBOL(usb_lock_device_for_reset);
1613EXPORT_SYMBOL(usb_unlock_device);
1614 1202
1615EXPORT_SYMBOL(usb_driver_claim_interface); 1203EXPORT_SYMBOL(usb_driver_claim_interface);
1616EXPORT_SYMBOL(usb_driver_release_interface); 1204EXPORT_SYMBOL(usb_driver_release_interface);
1617EXPORT_SYMBOL(usb_match_id);
1618EXPORT_SYMBOL(usb_find_interface); 1205EXPORT_SYMBOL(usb_find_interface);
1619EXPORT_SYMBOL(usb_ifnum_to_if); 1206EXPORT_SYMBOL(usb_ifnum_to_if);
1620EXPORT_SYMBOL(usb_altnum_to_altsetting); 1207EXPORT_SYMBOL(usb_altnum_to_altsetting);
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
index 1c4a68499dce..4647e1ebc68d 100644
--- a/drivers/usb/core/usb.h
+++ b/drivers/usb/core/usb.h
@@ -16,9 +16,6 @@ extern int usb_get_device_descriptor(struct usb_device *dev,
16extern char *usb_cache_string(struct usb_device *udev, int index); 16extern char *usb_cache_string(struct usb_device *udev, int index);
17extern int usb_set_configuration(struct usb_device *dev, int configuration); 17extern int usb_set_configuration(struct usb_device *dev, int configuration);
18 18
19extern void usb_lock_all_devices(void);
20extern void usb_unlock_all_devices(void);
21
22extern void usb_kick_khubd(struct usb_device *dev); 19extern void usb_kick_khubd(struct usb_device *dev);
23extern void usb_suspend_root_hub(struct usb_device *hdev); 20extern void usb_suspend_root_hub(struct usb_device *hdev);
24extern void usb_resume_root_hub(struct usb_device *dev); 21extern void usb_resume_root_hub(struct usb_device *dev);
@@ -33,6 +30,9 @@ extern void usb_host_cleanup(void);
33extern int usb_suspend_device(struct usb_device *dev); 30extern int usb_suspend_device(struct usb_device *dev);
34extern int usb_resume_device(struct usb_device *dev); 31extern int usb_resume_device(struct usb_device *dev);
35 32
33extern struct device_driver usb_generic_driver;
34extern int usb_generic_driver_data;
35extern int usb_device_match(struct device *dev, struct device_driver *drv);
36 36
37/* Interfaces and their "power state" are owned by usbcore */ 37/* Interfaces and their "power state" are owned by usbcore */
38 38
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index c655d46c8aed..9734cb76dd6c 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -138,7 +138,7 @@ static const char *const ep_name [] = {
138 /* or like sa1100: two fixed function endpoints */ 138 /* or like sa1100: two fixed function endpoints */
139 "ep1out-bulk", "ep2in-bulk", 139 "ep1out-bulk", "ep2in-bulk",
140}; 140};
141#define DUMMY_ENDPOINTS (sizeof(ep_name)/sizeof(char *)) 141#define DUMMY_ENDPOINTS ARRAY_SIZE(ep_name)
142 142
143/*-------------------------------------------------------------------------*/ 143/*-------------------------------------------------------------------------*/
144 144
@@ -896,7 +896,7 @@ dummy_gadget_release (struct device *dev)
896#endif 896#endif
897} 897}
898 898
899static int dummy_udc_probe (struct platform_device *dev) 899static int dummy_udc_probe (struct platform_device *pdev)
900{ 900{
901 struct dummy *dum = the_controller; 901 struct dummy *dum = the_controller;
902 int rc; 902 int rc;
@@ -909,7 +909,7 @@ static int dummy_udc_probe (struct platform_device *dev)
909 dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0); 909 dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0);
910 910
911 strcpy (dum->gadget.dev.bus_id, "gadget"); 911 strcpy (dum->gadget.dev.bus_id, "gadget");
912 dum->gadget.dev.parent = &dev->dev; 912 dum->gadget.dev.parent = &pdev->dev;
913 dum->gadget.dev.release = dummy_gadget_release; 913 dum->gadget.dev.release = dummy_gadget_release;
914 rc = device_register (&dum->gadget.dev); 914 rc = device_register (&dum->gadget.dev);
915 if (rc < 0) 915 if (rc < 0)
@@ -919,47 +919,47 @@ static int dummy_udc_probe (struct platform_device *dev)
919 usb_bus_get (&dummy_to_hcd (dum)->self); 919 usb_bus_get (&dummy_to_hcd (dum)->self);
920#endif 920#endif
921 921
922 platform_set_drvdata (dev, dum); 922 platform_set_drvdata (pdev, dum);
923 device_create_file (&dum->gadget.dev, &dev_attr_function); 923 device_create_file (&dum->gadget.dev, &dev_attr_function);
924 return rc; 924 return rc;
925} 925}
926 926
927static int dummy_udc_remove (struct platform_device *dev) 927static int dummy_udc_remove (struct platform_device *pdev)
928{ 928{
929 struct dummy *dum = platform_get_drvdata (dev); 929 struct dummy *dum = platform_get_drvdata (pdev);
930 930
931 platform_set_drvdata (dev, NULL); 931 platform_set_drvdata (pdev, NULL);
932 device_remove_file (&dum->gadget.dev, &dev_attr_function); 932 device_remove_file (&dum->gadget.dev, &dev_attr_function);
933 device_unregister (&dum->gadget.dev); 933 device_unregister (&dum->gadget.dev);
934 return 0; 934 return 0;
935} 935}
936 936
937static int dummy_udc_suspend (struct platform_device *dev, pm_message_t state) 937static int dummy_udc_suspend (struct platform_device *pdev, pm_message_t state)
938{ 938{
939 struct dummy *dum = platform_get_drvdata(dev); 939 struct dummy *dum = platform_get_drvdata(pdev);
940 940
941 dev_dbg (&dev->dev, "%s\n", __FUNCTION__); 941 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__);
942 spin_lock_irq (&dum->lock); 942 spin_lock_irq (&dum->lock);
943 dum->udc_suspended = 1; 943 dum->udc_suspended = 1;
944 set_link_state (dum); 944 set_link_state (dum);
945 spin_unlock_irq (&dum->lock); 945 spin_unlock_irq (&dum->lock);
946 946
947 dev->dev.power.power_state = state; 947 pdev->dev.power.power_state = state;
948 usb_hcd_poll_rh_status (dummy_to_hcd (dum)); 948 usb_hcd_poll_rh_status (dummy_to_hcd (dum));
949 return 0; 949 return 0;
950} 950}
951 951
952static int dummy_udc_resume (struct platform_device *dev) 952static int dummy_udc_resume (struct platform_device *pdev)
953{ 953{
954 struct dummy *dum = platform_get_drvdata(dev); 954 struct dummy *dum = platform_get_drvdata(pdev);
955 955
956 dev_dbg (&dev->dev, "%s\n", __FUNCTION__); 956 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__);
957 spin_lock_irq (&dum->lock); 957 spin_lock_irq (&dum->lock);
958 dum->udc_suspended = 0; 958 dum->udc_suspended = 0;
959 set_link_state (dum); 959 set_link_state (dum);
960 spin_unlock_irq (&dum->lock); 960 spin_unlock_irq (&dum->lock);
961 961
962 dev->dev.power.power_state = PMSG_ON; 962 pdev->dev.power.power_state = PMSG_ON;
963 usb_hcd_poll_rh_status (dummy_to_hcd (dum)); 963 usb_hcd_poll_rh_status (dummy_to_hcd (dum));
964 return 0; 964 return 0;
965} 965}
@@ -1576,7 +1576,7 @@ static int dummy_hub_status (struct usb_hcd *hcd, char *buf)
1576 dum = hcd_to_dummy (hcd); 1576 dum = hcd_to_dummy (hcd);
1577 1577
1578 spin_lock_irqsave (&dum->lock, flags); 1578 spin_lock_irqsave (&dum->lock, flags);
1579 if (hcd->state != HC_STATE_RUNNING) 1579 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))
1580 goto done; 1580 goto done;
1581 1581
1582 if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) { 1582 if (dum->resuming && time_after_eq (jiffies, dum->re_timeout)) {
@@ -1623,7 +1623,7 @@ static int dummy_hub_control (
1623 int retval = 0; 1623 int retval = 0;
1624 unsigned long flags; 1624 unsigned long flags;
1625 1625
1626 if (hcd->state != HC_STATE_RUNNING) 1626 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))
1627 return -ETIMEDOUT; 1627 return -ETIMEDOUT;
1628 1628
1629 dum = hcd_to_dummy (hcd); 1629 dum = hcd_to_dummy (hcd);
@@ -1756,9 +1756,12 @@ static int dummy_bus_suspend (struct usb_hcd *hcd)
1756{ 1756{
1757 struct dummy *dum = hcd_to_dummy (hcd); 1757 struct dummy *dum = hcd_to_dummy (hcd);
1758 1758
1759 dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__);
1760
1759 spin_lock_irq (&dum->lock); 1761 spin_lock_irq (&dum->lock);
1760 dum->rh_state = DUMMY_RH_SUSPENDED; 1762 dum->rh_state = DUMMY_RH_SUSPENDED;
1761 set_link_state (dum); 1763 set_link_state (dum);
1764 hcd->state = HC_STATE_SUSPENDED;
1762 spin_unlock_irq (&dum->lock); 1765 spin_unlock_irq (&dum->lock);
1763 return 0; 1766 return 0;
1764} 1767}
@@ -1766,14 +1769,23 @@ static int dummy_bus_suspend (struct usb_hcd *hcd)
1766static int dummy_bus_resume (struct usb_hcd *hcd) 1769static int dummy_bus_resume (struct usb_hcd *hcd)
1767{ 1770{
1768 struct dummy *dum = hcd_to_dummy (hcd); 1771 struct dummy *dum = hcd_to_dummy (hcd);
1772 int rc = 0;
1773
1774 dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__);
1769 1775
1770 spin_lock_irq (&dum->lock); 1776 spin_lock_irq (&dum->lock);
1771 dum->rh_state = DUMMY_RH_RUNNING; 1777 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
1772 set_link_state (dum); 1778 dev_warn (&hcd->self.root_hub->dev, "HC isn't running!\n");
1773 if (!list_empty(&dum->urbp_list)) 1779 rc = -ENODEV;
1774 mod_timer (&dum->timer, jiffies); 1780 } else {
1781 dum->rh_state = DUMMY_RH_RUNNING;
1782 set_link_state (dum);
1783 if (!list_empty(&dum->urbp_list))
1784 mod_timer (&dum->timer, jiffies);
1785 hcd->state = HC_STATE_RUNNING;
1786 }
1775 spin_unlock_irq (&dum->lock); 1787 spin_unlock_irq (&dum->lock);
1776 return 0; 1788 return rc;
1777} 1789}
1778 1790
1779/*-------------------------------------------------------------------------*/ 1791/*-------------------------------------------------------------------------*/
@@ -1899,14 +1911,14 @@ static const struct hc_driver dummy_hcd = {
1899 .bus_resume = dummy_bus_resume, 1911 .bus_resume = dummy_bus_resume,
1900}; 1912};
1901 1913
1902static int dummy_hcd_probe (struct platform_device *dev) 1914static int dummy_hcd_probe(struct platform_device *pdev)
1903{ 1915{
1904 struct usb_hcd *hcd; 1916 struct usb_hcd *hcd;
1905 int retval; 1917 int retval;
1906 1918
1907 dev_info(&dev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); 1919 dev_info(&pdev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc);
1908 1920
1909 hcd = usb_create_hcd (&dummy_hcd, &dev->dev, dev->dev.bus_id); 1921 hcd = usb_create_hcd(&dummy_hcd, &pdev->dev, pdev->dev.bus_id);
1910 if (!hcd) 1922 if (!hcd)
1911 return -ENOMEM; 1923 return -ENOMEM;
1912 the_controller = hcd_to_dummy (hcd); 1924 the_controller = hcd_to_dummy (hcd);
@@ -1919,36 +1931,43 @@ static int dummy_hcd_probe (struct platform_device *dev)
1919 return retval; 1931 return retval;
1920} 1932}
1921 1933
1922static int dummy_hcd_remove (struct platform_device *dev) 1934static int dummy_hcd_remove (struct platform_device *pdev)
1923{ 1935{
1924 struct usb_hcd *hcd; 1936 struct usb_hcd *hcd;
1925 1937
1926 hcd = platform_get_drvdata (dev); 1938 hcd = platform_get_drvdata (pdev);
1927 usb_remove_hcd (hcd); 1939 usb_remove_hcd (hcd);
1928 usb_put_hcd (hcd); 1940 usb_put_hcd (hcd);
1929 the_controller = NULL; 1941 the_controller = NULL;
1930 return 0; 1942 return 0;
1931} 1943}
1932 1944
1933static int dummy_hcd_suspend (struct platform_device *dev, pm_message_t state) 1945static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state)
1934{ 1946{
1935 struct usb_hcd *hcd; 1947 struct usb_hcd *hcd;
1948 struct dummy *dum;
1949 int rc = 0;
1936 1950
1937 dev_dbg (&dev->dev, "%s\n", __FUNCTION__); 1951 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__);
1938 hcd = platform_get_drvdata (dev);
1939 1952
1940 hcd->state = HC_STATE_SUSPENDED; 1953 hcd = platform_get_drvdata (pdev);
1941 return 0; 1954 dum = hcd_to_dummy (hcd);
1955 if (dum->rh_state == DUMMY_RH_RUNNING) {
1956 dev_warn(&pdev->dev, "Root hub isn't suspended!\n");
1957 rc = -EBUSY;
1958 } else
1959 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1960 return rc;
1942} 1961}
1943 1962
1944static int dummy_hcd_resume (struct platform_device *dev) 1963static int dummy_hcd_resume (struct platform_device *pdev)
1945{ 1964{
1946 struct usb_hcd *hcd; 1965 struct usb_hcd *hcd;
1947 1966
1948 dev_dbg (&dev->dev, "%s\n", __FUNCTION__); 1967 dev_dbg (&pdev->dev, "%s\n", __FUNCTION__);
1949 hcd = platform_get_drvdata (dev);
1950 hcd->state = HC_STATE_RUNNING;
1951 1968
1969 hcd = platform_get_drvdata (pdev);
1970 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1952 usb_hcd_poll_rh_status (hcd); 1971 usb_hcd_poll_rh_status (hcd);
1953 return 0; 1972 return 0;
1954} 1973}
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c
index ea09aaa3cab6..0cea9782d7d4 100644
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -224,6 +224,7 @@
224#include <linux/fs.h> 224#include <linux/fs.h>
225#include <linux/init.h> 225#include <linux/init.h>
226#include <linux/kernel.h> 226#include <linux/kernel.h>
227#include <linux/kref.h>
227#include <linux/kthread.h> 228#include <linux/kthread.h>
228#include <linux/limits.h> 229#include <linux/limits.h>
229#include <linux/list.h> 230#include <linux/list.h>
@@ -238,7 +239,6 @@
238#include <linux/string.h> 239#include <linux/string.h>
239#include <linux/suspend.h> 240#include <linux/suspend.h>
240#include <linux/utsname.h> 241#include <linux/utsname.h>
241#include <linux/wait.h>
242 242
243#include <linux/usb_ch9.h> 243#include <linux/usb_ch9.h>
244#include <linux/usb_gadget.h> 244#include <linux/usb_gadget.h>
@@ -250,7 +250,7 @@
250 250
251#define DRIVER_DESC "File-backed Storage Gadget" 251#define DRIVER_DESC "File-backed Storage Gadget"
252#define DRIVER_NAME "g_file_storage" 252#define DRIVER_NAME "g_file_storage"
253#define DRIVER_VERSION "20 October 2004" 253#define DRIVER_VERSION "28 November 2005"
254 254
255static const char longname[] = DRIVER_DESC; 255static const char longname[] = DRIVER_DESC;
256static const char shortname[] = DRIVER_NAME; 256static const char shortname[] = DRIVER_NAME;
@@ -335,8 +335,8 @@ MODULE_LICENSE("Dual BSD/GPL");
335#define MAX_LUNS 8 335#define MAX_LUNS 8
336 336
337 /* Arggh! There should be a module_param_array_named macro! */ 337 /* Arggh! There should be a module_param_array_named macro! */
338static char *file[MAX_LUNS] = {NULL, }; 338static char *file[MAX_LUNS];
339static int ro[MAX_LUNS] = {0, }; 339static int ro[MAX_LUNS];
340 340
341static struct { 341static struct {
342 int num_filenames; 342 int num_filenames;
@@ -587,7 +587,7 @@ enum fsg_buffer_state {
587struct fsg_buffhd { 587struct fsg_buffhd {
588 void *buf; 588 void *buf;
589 dma_addr_t dma; 589 dma_addr_t dma;
590 volatile enum fsg_buffer_state state; 590 enum fsg_buffer_state state;
591 struct fsg_buffhd *next; 591 struct fsg_buffhd *next;
592 592
593 /* The NetChip 2280 is faster, and handles some protocol faults 593 /* The NetChip 2280 is faster, and handles some protocol faults
@@ -596,9 +596,9 @@ struct fsg_buffhd {
596 unsigned int bulk_out_intended_length; 596 unsigned int bulk_out_intended_length;
597 597
598 struct usb_request *inreq; 598 struct usb_request *inreq;
599 volatile int inreq_busy; 599 int inreq_busy;
600 struct usb_request *outreq; 600 struct usb_request *outreq;
601 volatile int outreq_busy; 601 int outreq_busy;
602}; 602};
603 603
604enum fsg_state { 604enum fsg_state {
@@ -631,13 +631,16 @@ struct fsg_dev {
631 /* filesem protects: backing files in use */ 631 /* filesem protects: backing files in use */
632 struct rw_semaphore filesem; 632 struct rw_semaphore filesem;
633 633
634 /* reference counting: wait until all LUNs are released */
635 struct kref ref;
636
634 struct usb_ep *ep0; // Handy copy of gadget->ep0 637 struct usb_ep *ep0; // Handy copy of gadget->ep0
635 struct usb_request *ep0req; // For control responses 638 struct usb_request *ep0req; // For control responses
636 volatile unsigned int ep0_req_tag; 639 unsigned int ep0_req_tag;
637 const char *ep0req_name; 640 const char *ep0req_name;
638 641
639 struct usb_request *intreq; // For interrupt responses 642 struct usb_request *intreq; // For interrupt responses
640 volatile int intreq_busy; 643 int intreq_busy;
641 struct fsg_buffhd *intr_buffhd; 644 struct fsg_buffhd *intr_buffhd;
642 645
643 unsigned int bulk_out_maxpacket; 646 unsigned int bulk_out_maxpacket;
@@ -667,7 +670,6 @@ struct fsg_dev {
667 struct fsg_buffhd *next_buffhd_to_drain; 670 struct fsg_buffhd *next_buffhd_to_drain;
668 struct fsg_buffhd buffhds[NUM_BUFFERS]; 671 struct fsg_buffhd buffhds[NUM_BUFFERS];
669 672
670 wait_queue_head_t thread_wqh;
671 int thread_wakeup_needed; 673 int thread_wakeup_needed;
672 struct completion thread_notifier; 674 struct completion thread_notifier;
673 struct task_struct *thread_task; 675 struct task_struct *thread_task;
@@ -694,7 +696,6 @@ struct fsg_dev {
694 unsigned int nluns; 696 unsigned int nluns;
695 struct lun *luns; 697 struct lun *luns;
696 struct lun *curlun; 698 struct lun *curlun;
697 struct completion lun_released;
698}; 699};
699 700
700typedef void (*fsg_routine_t)(struct fsg_dev *); 701typedef void (*fsg_routine_t)(struct fsg_dev *);
@@ -1073,11 +1074,13 @@ static int populate_config_buf(struct usb_gadget *gadget,
1073 1074
1074/* These routines may be called in process context or in_irq */ 1075/* These routines may be called in process context or in_irq */
1075 1076
1077/* Caller must hold fsg->lock */
1076static void wakeup_thread(struct fsg_dev *fsg) 1078static void wakeup_thread(struct fsg_dev *fsg)
1077{ 1079{
1078 /* Tell the main thread that something has happened */ 1080 /* Tell the main thread that something has happened */
1079 fsg->thread_wakeup_needed = 1; 1081 fsg->thread_wakeup_needed = 1;
1080 wake_up_all(&fsg->thread_wqh); 1082 if (fsg->thread_task)
1083 wake_up_process(fsg->thread_task);
1081} 1084}
1082 1085
1083 1086
@@ -1164,11 +1167,12 @@ static void bulk_in_complete(struct usb_ep *ep, struct usb_request *req)
1164 usb_ep_fifo_flush(ep); 1167 usb_ep_fifo_flush(ep);
1165 1168
1166 /* Hold the lock while we update the request and buffer states */ 1169 /* Hold the lock while we update the request and buffer states */
1170 smp_wmb();
1167 spin_lock(&fsg->lock); 1171 spin_lock(&fsg->lock);
1168 bh->inreq_busy = 0; 1172 bh->inreq_busy = 0;
1169 bh->state = BUF_STATE_EMPTY; 1173 bh->state = BUF_STATE_EMPTY;
1170 spin_unlock(&fsg->lock);
1171 wakeup_thread(fsg); 1174 wakeup_thread(fsg);
1175 spin_unlock(&fsg->lock);
1172} 1176}
1173 1177
1174static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req) 1178static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
@@ -1185,11 +1189,12 @@ static void bulk_out_complete(struct usb_ep *ep, struct usb_request *req)
1185 usb_ep_fifo_flush(ep); 1189 usb_ep_fifo_flush(ep);
1186 1190
1187 /* Hold the lock while we update the request and buffer states */ 1191 /* Hold the lock while we update the request and buffer states */
1192 smp_wmb();
1188 spin_lock(&fsg->lock); 1193 spin_lock(&fsg->lock);
1189 bh->outreq_busy = 0; 1194 bh->outreq_busy = 0;
1190 bh->state = BUF_STATE_FULL; 1195 bh->state = BUF_STATE_FULL;
1191 spin_unlock(&fsg->lock);
1192 wakeup_thread(fsg); 1196 wakeup_thread(fsg);
1197 spin_unlock(&fsg->lock);
1193} 1198}
1194 1199
1195 1200
@@ -1206,11 +1211,12 @@ static void intr_in_complete(struct usb_ep *ep, struct usb_request *req)
1206 usb_ep_fifo_flush(ep); 1211 usb_ep_fifo_flush(ep);
1207 1212
1208 /* Hold the lock while we update the request and buffer states */ 1213 /* Hold the lock while we update the request and buffer states */
1214 smp_wmb();
1209 spin_lock(&fsg->lock); 1215 spin_lock(&fsg->lock);
1210 fsg->intreq_busy = 0; 1216 fsg->intreq_busy = 0;
1211 bh->state = BUF_STATE_EMPTY; 1217 bh->state = BUF_STATE_EMPTY;
1212 spin_unlock(&fsg->lock);
1213 wakeup_thread(fsg); 1218 wakeup_thread(fsg);
1219 spin_unlock(&fsg->lock);
1214} 1220}
1215 1221
1216#else 1222#else
@@ -1261,8 +1267,8 @@ static void received_cbi_adsc(struct fsg_dev *fsg, struct fsg_buffhd *bh)
1261 fsg->cbbuf_cmnd_size = req->actual; 1267 fsg->cbbuf_cmnd_size = req->actual;
1262 memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size); 1268 memcpy(fsg->cbbuf_cmnd, req->buf, fsg->cbbuf_cmnd_size);
1263 1269
1264 spin_unlock(&fsg->lock);
1265 wakeup_thread(fsg); 1270 wakeup_thread(fsg);
1271 spin_unlock(&fsg->lock);
1266} 1272}
1267 1273
1268#else 1274#else
@@ -1514,8 +1520,8 @@ static int fsg_setup(struct usb_gadget *gadget,
1514 1520
1515/* Use this for bulk or interrupt transfers, not ep0 */ 1521/* Use this for bulk or interrupt transfers, not ep0 */
1516static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep, 1522static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
1517 struct usb_request *req, volatile int *pbusy, 1523 struct usb_request *req, int *pbusy,
1518 volatile enum fsg_buffer_state *state) 1524 enum fsg_buffer_state *state)
1519{ 1525{
1520 int rc; 1526 int rc;
1521 1527
@@ -1523,8 +1529,11 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
1523 dump_msg(fsg, "bulk-in", req->buf, req->length); 1529 dump_msg(fsg, "bulk-in", req->buf, req->length);
1524 else if (ep == fsg->intr_in) 1530 else if (ep == fsg->intr_in)
1525 dump_msg(fsg, "intr-in", req->buf, req->length); 1531 dump_msg(fsg, "intr-in", req->buf, req->length);
1532
1533 spin_lock_irq(&fsg->lock);
1526 *pbusy = 1; 1534 *pbusy = 1;
1527 *state = BUF_STATE_BUSY; 1535 *state = BUF_STATE_BUSY;
1536 spin_unlock_irq(&fsg->lock);
1528 rc = usb_ep_queue(ep, req, GFP_KERNEL); 1537 rc = usb_ep_queue(ep, req, GFP_KERNEL);
1529 if (rc != 0) { 1538 if (rc != 0) {
1530 *pbusy = 0; 1539 *pbusy = 0;
@@ -1544,14 +1553,23 @@ static void start_transfer(struct fsg_dev *fsg, struct usb_ep *ep,
1544 1553
1545static int sleep_thread(struct fsg_dev *fsg) 1554static int sleep_thread(struct fsg_dev *fsg)
1546{ 1555{
1547 int rc; 1556 int rc = 0;
1548 1557
1549 /* Wait until a signal arrives or we are woken up */ 1558 /* Wait until a signal arrives or we are woken up */
1550 rc = wait_event_interruptible(fsg->thread_wqh, 1559 for (;;) {
1551 fsg->thread_wakeup_needed); 1560 try_to_freeze();
1561 set_current_state(TASK_INTERRUPTIBLE);
1562 if (signal_pending(current)) {
1563 rc = -EINTR;
1564 break;
1565 }
1566 if (fsg->thread_wakeup_needed)
1567 break;
1568 schedule();
1569 }
1570 __set_current_state(TASK_RUNNING);
1552 fsg->thread_wakeup_needed = 0; 1571 fsg->thread_wakeup_needed = 0;
1553 try_to_freeze(); 1572 return rc;
1554 return (rc ? -EINTR : 0);
1555} 1573}
1556 1574
1557 1575
@@ -1788,6 +1806,7 @@ static int do_write(struct fsg_dev *fsg)
1788 if (bh->state == BUF_STATE_EMPTY && !get_some_more) 1806 if (bh->state == BUF_STATE_EMPTY && !get_some_more)
1789 break; // We stopped early 1807 break; // We stopped early
1790 if (bh->state == BUF_STATE_FULL) { 1808 if (bh->state == BUF_STATE_FULL) {
1809 smp_rmb();
1791 fsg->next_buffhd_to_drain = bh->next; 1810 fsg->next_buffhd_to_drain = bh->next;
1792 bh->state = BUF_STATE_EMPTY; 1811 bh->state = BUF_STATE_EMPTY;
1793 1812
@@ -2356,6 +2375,7 @@ static int throw_away_data(struct fsg_dev *fsg)
2356 2375
2357 /* Throw away the data in a filled buffer */ 2376 /* Throw away the data in a filled buffer */
2358 if (bh->state == BUF_STATE_FULL) { 2377 if (bh->state == BUF_STATE_FULL) {
2378 smp_rmb();
2359 bh->state = BUF_STATE_EMPTY; 2379 bh->state = BUF_STATE_EMPTY;
2360 fsg->next_buffhd_to_drain = bh->next; 2380 fsg->next_buffhd_to_drain = bh->next;
2361 2381
@@ -3021,6 +3041,7 @@ static int get_next_command(struct fsg_dev *fsg)
3021 if ((rc = sleep_thread(fsg)) != 0) 3041 if ((rc = sleep_thread(fsg)) != 0)
3022 return rc; 3042 return rc;
3023 } 3043 }
3044 smp_rmb();
3024 rc = received_cbw(fsg, bh); 3045 rc = received_cbw(fsg, bh);
3025 bh->state = BUF_STATE_EMPTY; 3046 bh->state = BUF_STATE_EMPTY;
3026 3047
@@ -3642,11 +3663,19 @@ static DEVICE_ATTR(file, 0444, show_file, NULL);
3642 3663
3643/*-------------------------------------------------------------------------*/ 3664/*-------------------------------------------------------------------------*/
3644 3665
3666static void fsg_release(struct kref *ref)
3667{
3668 struct fsg_dev *fsg = container_of(ref, struct fsg_dev, ref);
3669
3670 kfree(fsg->luns);
3671 kfree(fsg);
3672}
3673
3645static void lun_release(struct device *dev) 3674static void lun_release(struct device *dev)
3646{ 3675{
3647 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev); 3676 struct fsg_dev *fsg = (struct fsg_dev *) dev_get_drvdata(dev);
3648 3677
3649 complete(&fsg->lun_released); 3678 kref_put(&fsg->ref, fsg_release);
3650} 3679}
3651 3680
3652static void fsg_unbind(struct usb_gadget *gadget) 3681static void fsg_unbind(struct usb_gadget *gadget)
@@ -3660,14 +3689,12 @@ static void fsg_unbind(struct usb_gadget *gadget)
3660 clear_bit(REGISTERED, &fsg->atomic_bitflags); 3689 clear_bit(REGISTERED, &fsg->atomic_bitflags);
3661 3690
3662 /* Unregister the sysfs attribute files and the LUNs */ 3691 /* Unregister the sysfs attribute files and the LUNs */
3663 init_completion(&fsg->lun_released);
3664 for (i = 0; i < fsg->nluns; ++i) { 3692 for (i = 0; i < fsg->nluns; ++i) {
3665 curlun = &fsg->luns[i]; 3693 curlun = &fsg->luns[i];
3666 if (curlun->registered) { 3694 if (curlun->registered) {
3667 device_remove_file(&curlun->dev, &dev_attr_ro); 3695 device_remove_file(&curlun->dev, &dev_attr_ro);
3668 device_remove_file(&curlun->dev, &dev_attr_file); 3696 device_remove_file(&curlun->dev, &dev_attr_file);
3669 device_unregister(&curlun->dev); 3697 device_unregister(&curlun->dev);
3670 wait_for_completion(&fsg->lun_released);
3671 curlun->registered = 0; 3698 curlun->registered = 0;
3672 } 3699 }
3673 } 3700 }
@@ -3846,6 +3873,7 @@ static int __init fsg_bind(struct usb_gadget *gadget)
3846 curlun->dev.release = lun_release; 3873 curlun->dev.release = lun_release;
3847 device_create_file(&curlun->dev, &dev_attr_ro); 3874 device_create_file(&curlun->dev, &dev_attr_ro);
3848 device_create_file(&curlun->dev, &dev_attr_file); 3875 device_create_file(&curlun->dev, &dev_attr_file);
3876 kref_get(&fsg->ref);
3849 } 3877 }
3850 3878
3851 if (file[i] && *file[i]) { 3879 if (file[i] && *file[i]) {
@@ -4061,7 +4089,7 @@ static int __init fsg_alloc(void)
4061 return -ENOMEM; 4089 return -ENOMEM;
4062 spin_lock_init(&fsg->lock); 4090 spin_lock_init(&fsg->lock);
4063 init_rwsem(&fsg->filesem); 4091 init_rwsem(&fsg->filesem);
4064 init_waitqueue_head(&fsg->thread_wqh); 4092 kref_init(&fsg->ref);
4065 init_completion(&fsg->thread_notifier); 4093 init_completion(&fsg->thread_notifier);
4066 4094
4067 the_fsg = fsg; 4095 the_fsg = fsg;
@@ -4069,13 +4097,6 @@ static int __init fsg_alloc(void)
4069} 4097}
4070 4098
4071 4099
4072static void fsg_free(struct fsg_dev *fsg)
4073{
4074 kfree(fsg->luns);
4075 kfree(fsg);
4076}
4077
4078
4079static int __init fsg_init(void) 4100static int __init fsg_init(void)
4080{ 4101{
4081 int rc; 4102 int rc;
@@ -4085,7 +4106,7 @@ static int __init fsg_init(void)
4085 return rc; 4106 return rc;
4086 fsg = the_fsg; 4107 fsg = the_fsg;
4087 if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0) 4108 if ((rc = usb_gadget_register_driver(&fsg_driver)) != 0)
4088 fsg_free(fsg); 4109 kref_put(&fsg->ref, fsg_release);
4089 return rc; 4110 return rc;
4090} 4111}
4091module_init(fsg_init); 4112module_init(fsg_init);
@@ -4103,6 +4124,6 @@ static void __exit fsg_cleanup(void)
4103 wait_for_completion(&fsg->thread_notifier); 4124 wait_for_completion(&fsg->thread_notifier);
4104 4125
4105 close_all_backing_files(fsg); 4126 close_all_backing_files(fsg);
4106 fsg_free(fsg); 4127 kref_put(&fsg->ref, fsg_release);
4107} 4128}
4108module_exit(fsg_cleanup); 4129module_exit(fsg_cleanup);
diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c
index b35ac6d334f8..65e084a2c87e 100644
--- a/drivers/usb/gadget/serial.c
+++ b/drivers/usb/gadget/serial.c
@@ -890,10 +890,12 @@ static void gs_close(struct tty_struct *tty, struct file *file)
890 /* wait for write buffer to drain, or */ 890 /* wait for write buffer to drain, or */
891 /* at most GS_CLOSE_TIMEOUT seconds */ 891 /* at most GS_CLOSE_TIMEOUT seconds */
892 if (gs_buf_data_avail(port->port_write_buf) > 0) { 892 if (gs_buf_data_avail(port->port_write_buf) > 0) {
893 spin_unlock_irqrestore(&port->port_lock, flags);
893 wait_cond_interruptible_timeout(port->port_write_wait, 894 wait_cond_interruptible_timeout(port->port_write_wait,
894 port->port_dev == NULL 895 port->port_dev == NULL
895 || gs_buf_data_avail(port->port_write_buf) == 0, 896 || gs_buf_data_avail(port->port_write_buf) == 0,
896 &port->port_lock, flags, GS_CLOSE_TIMEOUT * HZ); 897 &port->port_lock, flags, GS_CLOSE_TIMEOUT * HZ);
898 spin_lock_irqsave(&port->port_lock, flags);
897 } 899 }
898 900
899 /* free disconnected port on final close */ 901 /* free disconnected port on final close */
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 58321d3f314c..e3020f4b17be 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -2,6 +2,10 @@
2# Makefile for USB Host Controller Drivers 2# Makefile for USB Host Controller Drivers
3# 3#
4 4
5ifeq ($(CONFIG_USB_DEBUG),y)
6 EXTRA_CFLAGS += -DDEBUG
7endif
8
5obj-$(CONFIG_PCI) += pci-quirks.o 9obj-$(CONFIG_PCI) += pci-quirks.o
6 10
7obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o 11obj-$(CONFIG_USB_EHCI_HCD) += ehci-hcd.o
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 29f52a44b928..9dd3d14c64f3 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -17,13 +17,6 @@
17 */ 17 */
18 18
19#include <linux/config.h> 19#include <linux/config.h>
20
21#ifdef CONFIG_USB_DEBUG
22 #define DEBUG
23#else
24 #undef DEBUG
25#endif
26
27#include <linux/module.h> 20#include <linux/module.h>
28#include <linux/pci.h> 21#include <linux/pci.h>
29#include <linux/dmapool.h> 22#include <linux/dmapool.h>
@@ -624,7 +617,7 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
624 } 617 }
625 618
626 /* remote wakeup [4.3.1] */ 619 /* remote wakeup [4.3.1] */
627 if ((status & STS_PCD) && hcd->remote_wakeup) { 620 if (status & STS_PCD) {
628 unsigned i = HCS_N_PORTS (ehci->hcs_params); 621 unsigned i = HCS_N_PORTS (ehci->hcs_params);
629 622
630 /* resume root hub? */ 623 /* resume root hub? */
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 82caf336e9b6..69b0b9be7a64 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -59,7 +59,7 @@ static int ehci_bus_suspend (struct usb_hcd *hcd)
59 59
60 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER)) 60 if ((t1 & PORT_PE) && !(t1 & PORT_OWNER))
61 t2 |= PORT_SUSPEND; 61 t2 |= PORT_SUSPEND;
62 if (hcd->remote_wakeup) 62 if (device_may_wakeup(&hcd->self.root_hub->dev))
63 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E; 63 t2 |= PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E;
64 else 64 else
65 t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E); 65 t2 &= ~(PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E);
@@ -517,7 +517,7 @@ static int ehci_hub_control (
517 if ((temp & PORT_PE) == 0 517 if ((temp & PORT_PE) == 0
518 || (temp & PORT_RESET) != 0) 518 || (temp & PORT_RESET) != 0)
519 goto error; 519 goto error;
520 if (hcd->remote_wakeup) 520 if (device_may_wakeup(&hcd->self.root_hub->dev))
521 temp |= PORT_WAKE_BITS; 521 temp |= PORT_WAKE_BITS;
522 writel (temp | PORT_SUSPEND, 522 writel (temp | PORT_SUSPEND,
523 &ehci->regs->port_status [wIndex]); 523 &ehci->regs->port_status [wIndex]);
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 13f73a836e45..08ca0f849dab 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -210,7 +210,16 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
210 /* Serial Bus Release Number is at PCI 0x60 offset */ 210 /* Serial Bus Release Number is at PCI 0x60 offset */
211 pci_read_config_byte(pdev, 0x60, &ehci->sbrn); 211 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
212 212
213 /* REVISIT: per-port wake capability (PCI 0x62) currently unused */ 213 /* Workaround current PCI init glitch: wakeup bits aren't
214 * being set from PCI PM capability.
215 */
216 if (!device_can_wakeup(&pdev->dev)) {
217 u16 port_wake;
218
219 pci_read_config_word(pdev, 0x62, &port_wake);
220 if (port_wake & 0x0001)
221 device_init_wakeup(&pdev->dev, 1);
222 }
214 223
215 retval = ehci_pci_reinit(ehci, pdev); 224 retval = ehci_pci_reinit(ehci, pdev);
216done: 225done:
@@ -269,7 +278,6 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
269{ 278{
270 struct ehci_hcd *ehci = hcd_to_ehci(hcd); 279 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
271 unsigned port; 280 unsigned port;
272 struct usb_device *root = hcd->self.root_hub;
273 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 281 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
274 int retval = -EINVAL; 282 int retval = -EINVAL;
275 283
@@ -303,13 +311,7 @@ static int ehci_pci_resume(struct usb_hcd *hcd)
303 311
304restart: 312restart:
305 ehci_dbg(ehci, "lost power, restarting\n"); 313 ehci_dbg(ehci, "lost power, restarting\n");
306 for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) { 314 usb_root_hub_lost_power(hcd->self.root_hub);
307 port--;
308 if (!root->children [port])
309 continue;
310 usb_set_device_state(root->children[port],
311 USB_STATE_NOTATTACHED);
312 }
313 315
314 /* Else reset, to cope with power loss or flush-to-storage 316 /* Else reset, to cope with power loss or flush-to-storage
315 * style "resume" having let BIOS kick in during reboot. 317 * style "resume" having let BIOS kick in during reboot.
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index bf03ec0d8ee2..9b13bf2fa98d 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -514,18 +514,18 @@ qh_urb_transaction (
514 qtd->urb = urb; 514 qtd->urb = urb;
515 qtd_prev->hw_next = QTD_NEXT (qtd->qtd_dma); 515 qtd_prev->hw_next = QTD_NEXT (qtd->qtd_dma);
516 list_add_tail (&qtd->qtd_list, head); 516 list_add_tail (&qtd->qtd_list, head);
517
518 /* for zero length DATA stages, STATUS is always IN */
519 if (len == 0)
520 token |= (1 /* "in" */ << 8);
517 } 521 }
518 522
519 /* 523 /*
520 * data transfer stage: buffer setup 524 * data transfer stage: buffer setup
521 */ 525 */
522 if (likely (len > 0)) 526 buf = urb->transfer_dma;
523 buf = urb->transfer_dma;
524 else
525 buf = 0;
526 527
527 /* for zero length DATA stages, STATUS is always IN */ 528 if (is_input)
528 if (!buf || is_input)
529 token |= (1 /* "in" */ << 8); 529 token |= (1 /* "in" */ << 8);
530 /* else it's already initted to "out" pid (0 << 8) */ 530 /* else it's already initted to "out" pid (0 << 8) */
531 531
@@ -572,7 +572,7 @@ qh_urb_transaction (
572 * control requests may need a terminating data "status" ack; 572 * control requests may need a terminating data "status" ack;
573 * bulk ones may need a terminating short packet (zero length). 573 * bulk ones may need a terminating short packet (zero length).
574 */ 574 */
575 if (likely (buf != 0)) { 575 if (likely (urb->transfer_buffer_length != 0)) {
576 int one_more = 0; 576 int one_more = 0;
577 577
578 if (usb_pipecontrol (urb->pipe)) { 578 if (usb_pipecontrol (urb->pipe)) {
diff --git a/drivers/usb/host/hc_crisv10.c b/drivers/usb/host/hc_crisv10.c
index 0eaabeb37ac3..641268d7e6f3 100644
--- a/drivers/usb/host/hc_crisv10.c
+++ b/drivers/usb/host/hc_crisv10.c
@@ -4397,7 +4397,7 @@ static int __init etrax_usb_hc_init(void)
4397 device_initialize(&fake_device); 4397 device_initialize(&fake_device);
4398 kobject_set_name(&fake_device.kobj, "etrax_usb"); 4398 kobject_set_name(&fake_device.kobj, "etrax_usb");
4399 kobject_add(&fake_device.kobj); 4399 kobject_add(&fake_device.kobj);
4400 kobject_hotplug(&fake_device.kobj, KOBJ_ADD); 4400 kobject_uevent(&fake_device.kobj, KOBJ_ADD);
4401 hc->bus->controller = &fake_device; 4401 hc->bus->controller = &fake_device;
4402 usb_register_bus(hc->bus); 4402 usb_register_bus(hc->bus);
4403 4403
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index 82f64986bc22..584b8dc65119 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -55,19 +55,13 @@
55/* enqueuing/finishing log of urbs */ 55/* enqueuing/finishing log of urbs */
56//#define URB_TRACE 56//#define URB_TRACE
57 57
58#include <linux/config.h>
59#include <linux/module.h> 58#include <linux/module.h>
60#include <linux/moduleparam.h>
61#include <linux/kernel.h>
62#include <linux/delay.h> 59#include <linux/delay.h>
63#include <linux/ioport.h> 60#include <linux/debugfs.h>
64#include <linux/sched.h> 61#include <linux/seq_file.h>
65#include <linux/slab.h>
66#include <linux/smp_lock.h>
67#include <linux/errno.h> 62#include <linux/errno.h>
68#include <linux/init.h> 63#include <linux/init.h>
69#include <linux/list.h> 64#include <linux/list.h>
70#include <linux/interrupt.h>
71#include <linux/usb.h> 65#include <linux/usb.h>
72#include <linux/usb_isp116x.h> 66#include <linux/usb_isp116x.h>
73#include <linux/platform_device.h> 67#include <linux/platform_device.h>
@@ -77,14 +71,10 @@
77#include <asm/system.h> 71#include <asm/system.h>
78#include <asm/byteorder.h> 72#include <asm/byteorder.h>
79 73
80#ifndef DEBUG
81# define STUB_DEBUG_FILE
82#endif
83
84#include "../core/hcd.h" 74#include "../core/hcd.h"
85#include "isp116x.h" 75#include "isp116x.h"
86 76
87#define DRIVER_VERSION "05 Aug 2005" 77#define DRIVER_VERSION "03 Nov 2005"
88#define DRIVER_DESC "ISP116x USB Host Controller Driver" 78#define DRIVER_DESC "ISP116x USB Host Controller Driver"
89 79
90MODULE_DESCRIPTION(DRIVER_DESC); 80MODULE_DESCRIPTION(DRIVER_DESC);
@@ -164,13 +154,11 @@ static void pack_fifo(struct isp116x *isp116x)
164 struct ptd *ptd; 154 struct ptd *ptd;
165 int buflen = isp116x->atl_last_dir == PTD_DIR_IN 155 int buflen = isp116x->atl_last_dir == PTD_DIR_IN
166 ? isp116x->atl_bufshrt : isp116x->atl_buflen; 156 ? isp116x->atl_bufshrt : isp116x->atl_buflen;
167 int ptd_count = 0;
168 157
169 isp116x_write_reg16(isp116x, HCuPINT, HCuPINT_AIIEOT); 158 isp116x_write_reg16(isp116x, HCuPINT, HCuPINT_AIIEOT);
170 isp116x_write_reg16(isp116x, HCXFERCTR, buflen); 159 isp116x_write_reg16(isp116x, HCXFERCTR, buflen);
171 isp116x_write_addr(isp116x, HCATLPORT | ISP116x_WRITE_OFFSET); 160 isp116x_write_addr(isp116x, HCATLPORT | ISP116x_WRITE_OFFSET);
172 for (ep = isp116x->atl_active; ep; ep = ep->active) { 161 for (ep = isp116x->atl_active; ep; ep = ep->active) {
173 ++ptd_count;
174 ptd = &ep->ptd; 162 ptd = &ep->ptd;
175 dump_ptd(ptd); 163 dump_ptd(ptd);
176 dump_ptd_out_data(ptd, ep->data); 164 dump_ptd_out_data(ptd, ep->data);
@@ -305,9 +293,8 @@ static void postproc_atl_queue(struct isp116x *isp116x)
305 udev = urb->dev; 293 udev = urb->dev;
306 ptd = &ep->ptd; 294 ptd = &ep->ptd;
307 cc = PTD_GET_CC(ptd); 295 cc = PTD_GET_CC(ptd);
308
309 spin_lock(&urb->lock);
310 short_not_ok = 1; 296 short_not_ok = 1;
297 spin_lock(&urb->lock);
311 298
312 /* Data underrun is special. For allowed underrun 299 /* Data underrun is special. For allowed underrun
313 we clear the error and continue as normal. For 300 we clear the error and continue as normal. For
@@ -420,7 +407,7 @@ static void postproc_atl_queue(struct isp116x *isp116x)
420 ep->nextpid = 0; 407 ep->nextpid = 0;
421 break; 408 break;
422 default: 409 default:
423 BUG_ON(1); 410 BUG();
424 } 411 }
425 spin_unlock(&urb->lock); 412 spin_unlock(&urb->lock);
426 } 413 }
@@ -628,8 +615,12 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs)
628 u32 intstat = isp116x_read_reg32(isp116x, HCINTSTAT); 615 u32 intstat = isp116x_read_reg32(isp116x, HCINTSTAT);
629 isp116x_write_reg32(isp116x, HCINTSTAT, intstat); 616 isp116x_write_reg32(isp116x, HCINTSTAT, intstat);
630 if (intstat & HCINT_UE) { 617 if (intstat & HCINT_UE) {
631 ERR("Unrecoverable error\n"); 618 ERR("Unrecoverable error, HC is dead!\n");
632 /* What should we do here? Reset? */ 619 /* IRQ's are off, we do no DMA,
620 perfectly ready to die ... */
621 hcd->state = HC_STATE_HALT;
622 ret = IRQ_HANDLED;
623 goto done;
633 } 624 }
634 if (intstat & HCINT_RHSC) 625 if (intstat & HCINT_RHSC)
635 /* When root hub or any of its ports is going 626 /* When root hub or any of its ports is going
@@ -640,7 +631,6 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs)
640 if (intstat & HCINT_RD) { 631 if (intstat & HCINT_RD) {
641 DBG("---- remote wakeup\n"); 632 DBG("---- remote wakeup\n");
642 usb_hcd_resume_root_hub(hcd); 633 usb_hcd_resume_root_hub(hcd);
643 ret = IRQ_HANDLED;
644 } 634 }
645 irqstat &= ~HCuPINT_OPR; 635 irqstat &= ~HCuPINT_OPR;
646 ret = IRQ_HANDLED; 636 ret = IRQ_HANDLED;
@@ -651,6 +641,7 @@ static irqreturn_t isp116x_irq(struct usb_hcd *hcd, struct pt_regs *regs)
651 } 641 }
652 642
653 isp116x_write_reg16(isp116x, HCuPINTENB, isp116x->irqenb); 643 isp116x_write_reg16(isp116x, HCuPINTENB, isp116x->irqenb);
644 done:
654 spin_unlock(&isp116x->lock); 645 spin_unlock(&isp116x->lock);
655 return ret; 646 return ret;
656} 647}
@@ -724,6 +715,7 @@ static int isp116x_urb_enqueue(struct usb_hcd *hcd,
724 715
725 spin_lock_irqsave(&isp116x->lock, flags); 716 spin_lock_irqsave(&isp116x->lock, flags);
726 if (!HC_IS_RUNNING(hcd->state)) { 717 if (!HC_IS_RUNNING(hcd->state)) {
718 kfree(ep);
727 ret = -ENODEV; 719 ret = -ENODEV;
728 goto fail; 720 goto fail;
729 } 721 }
@@ -888,7 +880,7 @@ static void isp116x_endpoint_disable(struct usb_hcd *hcd,
888 struct usb_host_endpoint *hep) 880 struct usb_host_endpoint *hep)
889{ 881{
890 int i; 882 int i;
891 struct isp116x_ep *ep = hep->hcpriv;; 883 struct isp116x_ep *ep = hep->hcpriv;
892 884
893 if (!ep) 885 if (!ep)
894 return; 886 return;
@@ -916,8 +908,6 @@ static int isp116x_get_frame(struct usb_hcd *hcd)
916 return (int)fmnum; 908 return (int)fmnum;
917} 909}
918 910
919/*----------------------------------------------------------------*/
920
921/* 911/*
922 Adapted from ohci-hub.c. Currently we don't support autosuspend. 912 Adapted from ohci-hub.c. Currently we don't support autosuspend.
923*/ 913*/
@@ -968,11 +958,10 @@ static void isp116x_hub_descriptor(struct isp116x *isp116x,
968 desc->bHubContrCurrent = 0; 958 desc->bHubContrCurrent = 0;
969 desc->bNbrPorts = (u8) (reg & 0x3); 959 desc->bNbrPorts = (u8) (reg & 0x3);
970 /* Power switching, device type, overcurrent. */ 960 /* Power switching, device type, overcurrent. */
971 desc->wHubCharacteristics = 961 desc->wHubCharacteristics = cpu_to_le16((u16) ((reg >> 8) & 0x1f));
972 (__force __u16) cpu_to_le16((u16) ((reg >> 8) & 0x1f));
973 desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff); 962 desc->bPwrOn2PwrGood = (u8) ((reg >> 24) & 0xff);
974 /* two bitmaps: ports removable, and legacy PortPwrCtrlMask */ 963 /* two bitmaps: ports removable, and legacy PortPwrCtrlMask */
975 desc->bitmap[0] = desc->bNbrPorts == 1 ? 1 << 1 : 3 << 1; 964 desc->bitmap[0] = 0;
976 desc->bitmap[1] = ~0; 965 desc->bitmap[1] = ~0;
977} 966}
978 967
@@ -1159,135 +1148,9 @@ static int isp116x_hub_control(struct usb_hcd *hcd,
1159 return ret; 1148 return ret;
1160} 1149}
1161 1150
1162#ifdef CONFIG_PM
1163
1164static int isp116x_bus_suspend(struct usb_hcd *hcd)
1165{
1166 struct isp116x *isp116x = hcd_to_isp116x(hcd);
1167 unsigned long flags;
1168 u32 val;
1169 int ret = 0;
1170
1171 spin_lock_irqsave(&isp116x->lock, flags);
1172
1173 val = isp116x_read_reg32(isp116x, HCCONTROL);
1174 switch (val & HCCONTROL_HCFS) {
1175 case HCCONTROL_USB_OPER:
1176 hcd->state = HC_STATE_QUIESCING;
1177 val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE);
1178 val |= HCCONTROL_USB_SUSPEND;
1179 if (hcd->remote_wakeup)
1180 val |= HCCONTROL_RWE;
1181 /* Wait for usb transfers to finish */
1182 mdelay(2);
1183 isp116x_write_reg32(isp116x, HCCONTROL, val);
1184 hcd->state = HC_STATE_SUSPENDED;
1185 /* Wait for devices to suspend */
1186 mdelay(5);
1187 case HCCONTROL_USB_SUSPEND:
1188 break;
1189 case HCCONTROL_USB_RESUME:
1190 isp116x_write_reg32(isp116x, HCCONTROL,
1191 (val & ~HCCONTROL_HCFS) |
1192 HCCONTROL_USB_RESET);
1193 case HCCONTROL_USB_RESET:
1194 ret = -EBUSY;
1195 break;
1196 default:
1197 ret = -EINVAL;
1198 }
1199
1200 spin_unlock_irqrestore(&isp116x->lock, flags);
1201 return ret;
1202}
1203
1204static int isp116x_bus_resume(struct usb_hcd *hcd)
1205{
1206 struct isp116x *isp116x = hcd_to_isp116x(hcd);
1207 u32 val;
1208 int ret = -EINPROGRESS;
1209
1210 msleep(5);
1211 spin_lock_irq(&isp116x->lock);
1212
1213 val = isp116x_read_reg32(isp116x, HCCONTROL);
1214 switch (val & HCCONTROL_HCFS) {
1215 case HCCONTROL_USB_SUSPEND:
1216 val &= ~HCCONTROL_HCFS;
1217 val |= HCCONTROL_USB_RESUME;
1218 isp116x_write_reg32(isp116x, HCCONTROL, val);
1219 case HCCONTROL_USB_RESUME:
1220 break;
1221 case HCCONTROL_USB_OPER:
1222 /* Without setting power_state here the
1223 SUSPENDED state won't be removed from
1224 sysfs/usbN/power.state as a response to remote
1225 wakeup. Maybe in the future. */
1226 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1227 ret = 0;
1228 break;
1229 default:
1230 ret = -EBUSY;
1231 }
1232
1233 if (ret != -EINPROGRESS) {
1234 spin_unlock_irq(&isp116x->lock);
1235 return ret;
1236 }
1237
1238 val = isp116x->rhdesca & RH_A_NDP;
1239 while (val--) {
1240 u32 stat =
1241 isp116x_read_reg32(isp116x, val ? HCRHPORT2 : HCRHPORT1);
1242 /* force global, not selective, resume */
1243 if (!(stat & RH_PS_PSS))
1244 continue;
1245 DBG("%s: Resuming port %d\n", __func__, val);
1246 isp116x_write_reg32(isp116x, RH_PS_POCI, val
1247 ? HCRHPORT2 : HCRHPORT1);
1248 }
1249 spin_unlock_irq(&isp116x->lock);
1250
1251 hcd->state = HC_STATE_RESUMING;
1252 mdelay(20);
1253
1254 /* Go operational */
1255 spin_lock_irq(&isp116x->lock);
1256 val = isp116x_read_reg32(isp116x, HCCONTROL);
1257 isp116x_write_reg32(isp116x, HCCONTROL,
1258 (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER);
1259 spin_unlock_irq(&isp116x->lock);
1260 /* see analogous comment above */
1261 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1262 hcd->state = HC_STATE_RUNNING;
1263
1264 return 0;
1265}
1266
1267
1268#else
1269
1270#define isp116x_bus_suspend NULL
1271#define isp116x_bus_resume NULL
1272
1273#endif
1274
1275/*-----------------------------------------------------------------*/ 1151/*-----------------------------------------------------------------*/
1276 1152
1277#ifdef STUB_DEBUG_FILE 1153#ifdef CONFIG_DEBUG_FS
1278
1279static inline void create_debug_file(struct isp116x *isp116x)
1280{
1281}
1282
1283static inline void remove_debug_file(struct isp116x *isp116x)
1284{
1285}
1286
1287#else
1288
1289#include <linux/proc_fs.h>
1290#include <linux/seq_file.h>
1291 1154
1292static void dump_irq(struct seq_file *s, char *label, u16 mask) 1155static void dump_irq(struct seq_file *s, char *label, u16 mask)
1293{ 1156{
@@ -1311,13 +1174,9 @@ static void dump_int(struct seq_file *s, char *label, u32 mask)
1311 mask & HCINT_SF ? " sof" : "", mask & HCINT_SO ? " so" : ""); 1174 mask & HCINT_SF ? " sof" : "", mask & HCINT_SO ? " so" : "");
1312} 1175}
1313 1176
1314static int proc_isp116x_show(struct seq_file *s, void *unused) 1177static int isp116x_show_dbg(struct seq_file *s, void *unused)
1315{ 1178{
1316 struct isp116x *isp116x = s->private; 1179 struct isp116x *isp116x = s->private;
1317 struct isp116x_ep *ep;
1318 struct urb *urb;
1319 unsigned i;
1320 char *str;
1321 1180
1322 seq_printf(s, "%s\n%s version %s\n", 1181 seq_printf(s, "%s\n%s version %s\n",
1323 isp116x_to_hcd(isp116x)->product_desc, hcd_name, 1182 isp116x_to_hcd(isp116x)->product_desc, hcd_name,
@@ -1333,105 +1192,50 @@ static int proc_isp116x_show(struct seq_file *s, void *unused)
1333 } 1192 }
1334 1193
1335 spin_lock_irq(&isp116x->lock); 1194 spin_lock_irq(&isp116x->lock);
1336
1337 dump_irq(s, "hc_irq_enable", isp116x_read_reg16(isp116x, HCuPINTENB)); 1195 dump_irq(s, "hc_irq_enable", isp116x_read_reg16(isp116x, HCuPINTENB));
1338 dump_irq(s, "hc_irq_status", isp116x_read_reg16(isp116x, HCuPINT)); 1196 dump_irq(s, "hc_irq_status", isp116x_read_reg16(isp116x, HCuPINT));
1339 dump_int(s, "hc_int_enable", isp116x_read_reg32(isp116x, HCINTENB)); 1197 dump_int(s, "hc_int_enable", isp116x_read_reg32(isp116x, HCINTENB));
1340 dump_int(s, "hc_int_status", isp116x_read_reg32(isp116x, HCINTSTAT)); 1198 dump_int(s, "hc_int_status", isp116x_read_reg32(isp116x, HCINTSTAT));
1341 1199 isp116x_show_regs_seq(isp116x, s);
1342 list_for_each_entry(ep, &isp116x->async, schedule) {
1343
1344 switch (ep->nextpid) {
1345 case USB_PID_IN:
1346 str = "in";
1347 break;
1348 case USB_PID_OUT:
1349 str = "out";
1350 break;
1351 case USB_PID_SETUP:
1352 str = "setup";
1353 break;
1354 case USB_PID_ACK:
1355 str = "status";
1356 break;
1357 default:
1358 str = "?";
1359 break;
1360 };
1361 seq_printf(s, "%p, ep%d%s, maxpacket %d:\n", ep,
1362 ep->epnum, str, ep->maxpacket);
1363 list_for_each_entry(urb, &ep->hep->urb_list, urb_list) {
1364 seq_printf(s, " urb%p, %d/%d\n", urb,
1365 urb->actual_length,
1366 urb->transfer_buffer_length);
1367 }
1368 }
1369 if (!list_empty(&isp116x->async))
1370 seq_printf(s, "\n");
1371
1372 seq_printf(s, "periodic size= %d\n", PERIODIC_SIZE);
1373
1374 for (i = 0; i < PERIODIC_SIZE; i++) {
1375 ep = isp116x->periodic[i];
1376 if (!ep)
1377 continue;
1378 seq_printf(s, "%2d [%3d]:\n", i, isp116x->load[i]);
1379
1380 /* DUMB: prints shared entries multiple times */
1381 do {
1382 seq_printf(s, " %d/%p (%sdev%d ep%d%s max %d)\n",
1383 ep->period, ep,
1384 (ep->udev->speed ==
1385 USB_SPEED_FULL) ? "" : "ls ",
1386 ep->udev->devnum, ep->epnum,
1387 (ep->epnum ==
1388 0) ? "" : ((ep->nextpid ==
1389 USB_PID_IN) ? "in" : "out"),
1390 ep->maxpacket);
1391 ep = ep->next;
1392 } while (ep);
1393 }
1394 spin_unlock_irq(&isp116x->lock); 1200 spin_unlock_irq(&isp116x->lock);
1395 seq_printf(s, "\n"); 1201 seq_printf(s, "\n");
1396 1202
1397 return 0; 1203 return 0;
1398} 1204}
1399 1205
1400static int proc_isp116x_open(struct inode *inode, struct file *file) 1206static int isp116x_open_seq(struct inode *inode, struct file *file)
1401{ 1207{
1402 return single_open(file, proc_isp116x_show, PDE(inode)->data); 1208 return single_open(file, isp116x_show_dbg, inode->u.generic_ip);
1403} 1209}
1404 1210
1405static struct file_operations proc_ops = { 1211static struct file_operations isp116x_debug_fops = {
1406 .open = proc_isp116x_open, 1212 .open = isp116x_open_seq,
1407 .read = seq_read, 1213 .read = seq_read,
1408 .llseek = seq_lseek, 1214 .llseek = seq_lseek,
1409 .release = single_release, 1215 .release = single_release,
1410}; 1216};
1411 1217
1412/* expect just one isp116x per system */ 1218static int create_debug_file(struct isp116x *isp116x)
1413static const char proc_filename[] = "driver/isp116x";
1414
1415static void create_debug_file(struct isp116x *isp116x)
1416{ 1219{
1417 struct proc_dir_entry *pde; 1220 isp116x->dentry = debugfs_create_file(hcd_name,
1418 1221 S_IRUGO, NULL, isp116x,
1419 pde = create_proc_entry(proc_filename, 0, NULL); 1222 &isp116x_debug_fops);
1420 if (pde == NULL) 1223 if (!isp116x->dentry)
1421 return; 1224 return -ENOMEM;
1422 1225 return 0;
1423 pde->proc_fops = &proc_ops;
1424 pde->data = isp116x;
1425 isp116x->pde = pde;
1426} 1226}
1427 1227
1428static void remove_debug_file(struct isp116x *isp116x) 1228static void remove_debug_file(struct isp116x *isp116x)
1429{ 1229{
1430 if (isp116x->pde) 1230 debugfs_remove(isp116x->dentry);
1431 remove_proc_entry(proc_filename, NULL);
1432} 1231}
1433 1232
1434#endif 1233#else
1234
1235#define create_debug_file(d) 0
1236#define remove_debug_file(d) do{}while(0)
1237
1238#endif /* CONFIG_DEBUG_FS */
1435 1239
1436/*-----------------------------------------------------------------*/ 1240/*-----------------------------------------------------------------*/
1437 1241
@@ -1466,7 +1270,7 @@ static int isp116x_reset(struct usb_hcd *hcd)
1466 struct isp116x *isp116x = hcd_to_isp116x(hcd); 1270 struct isp116x *isp116x = hcd_to_isp116x(hcd);
1467 unsigned long t; 1271 unsigned long t;
1468 u16 clkrdy = 0; 1272 u16 clkrdy = 0;
1469 int ret = 0, timeout = 15 /* ms */ ; 1273 int ret, timeout = 15 /* ms */ ;
1470 1274
1471 ret = isp116x_sw_reset(isp116x); 1275 ret = isp116x_sw_reset(isp116x);
1472 if (ret) 1276 if (ret)
@@ -1482,7 +1286,7 @@ static int isp116x_reset(struct usb_hcd *hcd)
1482 break; 1286 break;
1483 } 1287 }
1484 if (!clkrdy) { 1288 if (!clkrdy) {
1485 ERR("Clock not ready after 20ms\n"); 1289 ERR("Clock not ready after %dms\n", timeout);
1486 /* After sw_reset the clock won't report to be ready, if 1290 /* After sw_reset the clock won't report to be ready, if
1487 H_WAKEUP pin is high. */ 1291 H_WAKEUP pin is high. */
1488 ERR("Please make sure that the H_WAKEUP pin is pulled low!\n"); 1292 ERR("Please make sure that the H_WAKEUP pin is pulled low!\n");
@@ -1572,7 +1376,8 @@ static int isp116x_start(struct usb_hcd *hcd)
1572 1376
1573 val = 0; 1377 val = 0;
1574 if (board->remote_wakeup_enable) { 1378 if (board->remote_wakeup_enable) {
1575 hcd->can_wakeup = 1; 1379 if (!device_can_wakeup(hcd->self.controller))
1380 device_init_wakeup(hcd->self.controller, 1);
1576 val |= RH_HS_DRWE; 1381 val |= RH_HS_DRWE;
1577 } 1382 }
1578 isp116x_write_reg32(isp116x, HCRHSTATUS, val); 1383 isp116x_write_reg32(isp116x, HCRHSTATUS, val);
@@ -1600,12 +1405,126 @@ static int isp116x_start(struct usb_hcd *hcd)
1600 isp116x_write_reg32(isp116x, HCRHPORT1, RH_PS_CCS); 1405 isp116x_write_reg32(isp116x, HCRHPORT1, RH_PS_CCS);
1601 isp116x_write_reg32(isp116x, HCRHPORT2, RH_PS_CCS); 1406 isp116x_write_reg32(isp116x, HCRHPORT2, RH_PS_CCS);
1602 1407
1603 isp116x_show_regs(isp116x); 1408 isp116x_show_regs_log(isp116x);
1604 spin_unlock_irqrestore(&isp116x->lock, flags); 1409 spin_unlock_irqrestore(&isp116x->lock, flags);
1605 return 0; 1410 return 0;
1606} 1411}
1607 1412
1608/*-----------------------------------------------------------------*/ 1413#ifdef CONFIG_PM
1414
1415static int isp116x_bus_suspend(struct usb_hcd *hcd)
1416{
1417 struct isp116x *isp116x = hcd_to_isp116x(hcd);
1418 unsigned long flags;
1419 u32 val;
1420 int ret = 0;
1421
1422 spin_lock_irqsave(&isp116x->lock, flags);
1423
1424 val = isp116x_read_reg32(isp116x, HCCONTROL);
1425 switch (val & HCCONTROL_HCFS) {
1426 case HCCONTROL_USB_OPER:
1427 val &= (~HCCONTROL_HCFS & ~HCCONTROL_RWE);
1428 val |= HCCONTROL_USB_SUSPEND;
1429 if (device_may_wakeup(&hcd->self.root_hub->dev))
1430 val |= HCCONTROL_RWE;
1431 /* Wait for usb transfers to finish */
1432 mdelay(2);
1433 isp116x_write_reg32(isp116x, HCCONTROL, val);
1434 /* Wait for devices to suspend */
1435 mdelay(5);
1436 case HCCONTROL_USB_SUSPEND:
1437 break;
1438 case HCCONTROL_USB_RESUME:
1439 isp116x_write_reg32(isp116x, HCCONTROL,
1440 (val & ~HCCONTROL_HCFS) |
1441 HCCONTROL_USB_RESET);
1442 case HCCONTROL_USB_RESET:
1443 ret = -EBUSY;
1444 break;
1445 default:
1446 ret = -EINVAL;
1447 }
1448
1449 spin_unlock_irqrestore(&isp116x->lock, flags);
1450 return ret;
1451}
1452
1453static int isp116x_bus_resume(struct usb_hcd *hcd)
1454{
1455 struct isp116x *isp116x = hcd_to_isp116x(hcd);
1456 u32 val;
1457
1458 msleep(5);
1459 spin_lock_irq(&isp116x->lock);
1460
1461 val = isp116x_read_reg32(isp116x, HCCONTROL);
1462 switch (val & HCCONTROL_HCFS) {
1463 case HCCONTROL_USB_SUSPEND:
1464 val &= ~HCCONTROL_HCFS;
1465 val |= HCCONTROL_USB_RESUME;
1466 isp116x_write_reg32(isp116x, HCCONTROL, val);
1467 case HCCONTROL_USB_RESUME:
1468 break;
1469 case HCCONTROL_USB_OPER:
1470 spin_unlock_irq(&isp116x->lock);
1471 /* Without setting power_state here the
1472 SUSPENDED state won't be removed from
1473 sysfs/usbN/power.state as a response to remote
1474 wakeup. Maybe in the future. */
1475 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1476 return 0;
1477 default:
1478 /* HCCONTROL_USB_RESET: this may happen, when during
1479 suspension the HC lost power. Reinitialize completely */
1480 spin_unlock_irq(&isp116x->lock);
1481 DBG("Chip has been reset while suspended. Reinit from scratch.\n");
1482 isp116x_reset(hcd);
1483 isp116x_start(hcd);
1484 isp116x_hub_control(hcd, SetPortFeature,
1485 USB_PORT_FEAT_POWER, 1, NULL, 0);
1486 if ((isp116x->rhdesca & RH_A_NDP) == 2)
1487 isp116x_hub_control(hcd, SetPortFeature,
1488 USB_PORT_FEAT_POWER, 2, NULL, 0);
1489 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1490 return 0;
1491 }
1492
1493 val = isp116x->rhdesca & RH_A_NDP;
1494 while (val--) {
1495 u32 stat =
1496 isp116x_read_reg32(isp116x, val ? HCRHPORT2 : HCRHPORT1);
1497 /* force global, not selective, resume */
1498 if (!(stat & RH_PS_PSS))
1499 continue;
1500 DBG("%s: Resuming port %d\n", __func__, val);
1501 isp116x_write_reg32(isp116x, RH_PS_POCI, val
1502 ? HCRHPORT2 : HCRHPORT1);
1503 }
1504 spin_unlock_irq(&isp116x->lock);
1505
1506 hcd->state = HC_STATE_RESUMING;
1507 msleep(20);
1508
1509 /* Go operational */
1510 spin_lock_irq(&isp116x->lock);
1511 val = isp116x_read_reg32(isp116x, HCCONTROL);
1512 isp116x_write_reg32(isp116x, HCCONTROL,
1513 (val & ~HCCONTROL_HCFS) | HCCONTROL_USB_OPER);
1514 spin_unlock_irq(&isp116x->lock);
1515 /* see analogous comment above */
1516 hcd->self.root_hub->dev.power.power_state = PMSG_ON;
1517 hcd->state = HC_STATE_RUNNING;
1518
1519 return 0;
1520}
1521
1522#else
1523
1524#define isp116x_bus_suspend NULL
1525#define isp116x_bus_resume NULL
1526
1527#endif
1609 1528
1610static struct hc_driver isp116x_hc_driver = { 1529static struct hc_driver isp116x_hc_driver = {
1611 .description = hcd_name, 1530 .description = hcd_name,
@@ -1735,12 +1654,19 @@ static int __init isp116x_probe(struct platform_device *pdev)
1735 } 1654 }
1736 1655
1737 ret = usb_add_hcd(hcd, irq, SA_INTERRUPT); 1656 ret = usb_add_hcd(hcd, irq, SA_INTERRUPT);
1738 if (ret != 0) 1657 if (ret)
1739 goto err6; 1658 goto err6;
1740 1659
1741 create_debug_file(isp116x); 1660 ret = create_debug_file(isp116x);
1661 if (ret) {
1662 ERR("Couldn't create debugfs entry\n");
1663 goto err7;
1664 }
1665
1742 return 0; 1666 return 0;
1743 1667
1668 err7:
1669 usb_remove_hcd(hcd);
1744 err6: 1670 err6:
1745 usb_put_hcd(hcd); 1671 usb_put_hcd(hcd);
1746 err5: 1672 err5:
@@ -1762,13 +1688,9 @@ static int __init isp116x_probe(struct platform_device *pdev)
1762*/ 1688*/
1763static int isp116x_suspend(struct platform_device *dev, pm_message_t state) 1689static int isp116x_suspend(struct platform_device *dev, pm_message_t state)
1764{ 1690{
1765 int ret = 0; 1691 VDBG("%s: state %x\n", __func__, state.event);
1766
1767 VDBG("%s: state %x\n", __func__, state);
1768
1769 dev->dev.power.power_state = state; 1692 dev->dev.power.power_state = state;
1770 1693 return 0;
1771 return ret;
1772} 1694}
1773 1695
1774/* 1696/*
@@ -1776,13 +1698,9 @@ static int isp116x_suspend(struct platform_device *dev, pm_message_t state)
1776*/ 1698*/
1777static int isp116x_resume(struct platform_device *dev) 1699static int isp116x_resume(struct platform_device *dev)
1778{ 1700{
1779 int ret = 0; 1701 VDBG("%s: state %x\n", __func__, dev->power.power_state.event);
1780
1781 VDBG("%s: state %x\n", __func__, dev->dev.power.power_state);
1782
1783 dev->dev.power.power_state = PMSG_ON; 1702 dev->dev.power.power_state = PMSG_ON;
1784 1703 return 0;
1785 return ret;
1786} 1704}
1787 1705
1788#else 1706#else
diff --git a/drivers/usb/host/isp116x.h b/drivers/usb/host/isp116x.h
index c6fec96785fe..a1b7c3813d3a 100644
--- a/drivers/usb/host/isp116x.h
+++ b/drivers/usb/host/isp116x.h
@@ -259,7 +259,7 @@ struct isp116x {
259 259
260 struct isp116x_platform_data *board; 260 struct isp116x_platform_data *board;
261 261
262 struct proc_dir_entry *pde; 262 struct dentry *dentry;
263 unsigned long stat1, stat2, stat4, stat8, stat16; 263 unsigned long stat1, stat2, stat4, stat8, stat16;
264 264
265 /* HC registers */ 265 /* HC registers */
@@ -450,7 +450,7 @@ static void isp116x_write_reg32(struct isp116x *isp116x, unsigned reg,
450 isp116x_write_data32(isp116x, (u32) val); 450 isp116x_write_data32(isp116x, (u32) val);
451} 451}
452 452
453#define isp116x_show_reg(d,r) { \ 453#define isp116x_show_reg_log(d,r,s) { \
454 if ((r) < 0x20) { \ 454 if ((r) < 0x20) { \
455 DBG("%-12s[%02x]: %08x\n", #r, \ 455 DBG("%-12s[%02x]: %08x\n", #r, \
456 r, isp116x_read_reg32(d, r)); \ 456 r, isp116x_read_reg32(d, r)); \
@@ -459,35 +459,60 @@ static void isp116x_write_reg32(struct isp116x *isp116x, unsigned reg,
459 r, isp116x_read_reg16(d, r)); \ 459 r, isp116x_read_reg16(d, r)); \
460 } \ 460 } \
461} 461}
462#define isp116x_show_reg_seq(d,r,s) { \
463 if ((r) < 0x20) { \
464 seq_printf(s, "%-12s[%02x]: %08x\n", #r, \
465 r, isp116x_read_reg32(d, r)); \
466 } else { \
467 seq_printf(s, "%-12s[%02x]: %04x\n", #r, \
468 r, isp116x_read_reg16(d, r)); \
469 } \
470}
462 471
463static inline void isp116x_show_regs(struct isp116x *isp116x) 472#define isp116x_show_regs(d,type,s) { \
473 isp116x_show_reg_##type(d, HCREVISION, s); \
474 isp116x_show_reg_##type(d, HCCONTROL, s); \
475 isp116x_show_reg_##type(d, HCCMDSTAT, s); \
476 isp116x_show_reg_##type(d, HCINTSTAT, s); \
477 isp116x_show_reg_##type(d, HCINTENB, s); \
478 isp116x_show_reg_##type(d, HCFMINTVL, s); \
479 isp116x_show_reg_##type(d, HCFMREM, s); \
480 isp116x_show_reg_##type(d, HCFMNUM, s); \
481 isp116x_show_reg_##type(d, HCLSTHRESH, s); \
482 isp116x_show_reg_##type(d, HCRHDESCA, s); \
483 isp116x_show_reg_##type(d, HCRHDESCB, s); \
484 isp116x_show_reg_##type(d, HCRHSTATUS, s); \
485 isp116x_show_reg_##type(d, HCRHPORT1, s); \
486 isp116x_show_reg_##type(d, HCRHPORT2, s); \
487 isp116x_show_reg_##type(d, HCHWCFG, s); \
488 isp116x_show_reg_##type(d, HCDMACFG, s); \
489 isp116x_show_reg_##type(d, HCXFERCTR, s); \
490 isp116x_show_reg_##type(d, HCuPINT, s); \
491 isp116x_show_reg_##type(d, HCuPINTENB, s); \
492 isp116x_show_reg_##type(d, HCCHIPID, s); \
493 isp116x_show_reg_##type(d, HCSCRATCH, s); \
494 isp116x_show_reg_##type(d, HCITLBUFLEN, s); \
495 isp116x_show_reg_##type(d, HCATLBUFLEN, s); \
496 isp116x_show_reg_##type(d, HCBUFSTAT, s); \
497 isp116x_show_reg_##type(d, HCRDITL0LEN, s); \
498 isp116x_show_reg_##type(d, HCRDITL1LEN, s); \
499}
500
501/*
502 Dump registers for debugfs.
503*/
504static inline void isp116x_show_regs_seq(struct isp116x *isp116x,
505 struct seq_file *s)
506{
507 isp116x_show_regs(isp116x, seq, s);
508}
509
510/*
511 Dump registers to syslog.
512*/
513static inline void isp116x_show_regs_log(struct isp116x *isp116x)
464{ 514{
465 isp116x_show_reg(isp116x, HCREVISION); 515 isp116x_show_regs(isp116x, log, NULL);
466 isp116x_show_reg(isp116x, HCCONTROL);
467 isp116x_show_reg(isp116x, HCCMDSTAT);
468 isp116x_show_reg(isp116x, HCINTSTAT);
469 isp116x_show_reg(isp116x, HCINTENB);
470 isp116x_show_reg(isp116x, HCFMINTVL);
471 isp116x_show_reg(isp116x, HCFMREM);
472 isp116x_show_reg(isp116x, HCFMNUM);
473 isp116x_show_reg(isp116x, HCLSTHRESH);
474 isp116x_show_reg(isp116x, HCRHDESCA);
475 isp116x_show_reg(isp116x, HCRHDESCB);
476 isp116x_show_reg(isp116x, HCRHSTATUS);
477 isp116x_show_reg(isp116x, HCRHPORT1);
478 isp116x_show_reg(isp116x, HCRHPORT2);
479 isp116x_show_reg(isp116x, HCHWCFG);
480 isp116x_show_reg(isp116x, HCDMACFG);
481 isp116x_show_reg(isp116x, HCXFERCTR);
482 isp116x_show_reg(isp116x, HCuPINT);
483 isp116x_show_reg(isp116x, HCuPINTENB);
484 isp116x_show_reg(isp116x, HCCHIPID);
485 isp116x_show_reg(isp116x, HCSCRATCH);
486 isp116x_show_reg(isp116x, HCITLBUFLEN);
487 isp116x_show_reg(isp116x, HCATLBUFLEN);
488 isp116x_show_reg(isp116x, HCBUFSTAT);
489 isp116x_show_reg(isp116x, HCRDITL0LEN);
490 isp116x_show_reg(isp116x, HCRDITL1LEN);
491} 516}
492 517
493#if defined(URB_TRACE) 518#if defined(URB_TRACE)
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index bf1d9abc07ac..a4b12404ae08 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -75,13 +75,6 @@
75 */ 75 */
76 76
77#include <linux/config.h> 77#include <linux/config.h>
78
79#ifdef CONFIG_USB_DEBUG
80# define DEBUG
81#else
82# undef DEBUG
83#endif
84
85#include <linux/module.h> 78#include <linux/module.h>
86#include <linux/moduleparam.h> 79#include <linux/moduleparam.h>
87#include <linux/pci.h> 80#include <linux/pci.h>
@@ -802,7 +795,6 @@ static int ohci_restart (struct ohci_hcd *ohci)
802 int temp; 795 int temp;
803 int i; 796 int i;
804 struct urb_priv *priv; 797 struct urb_priv *priv;
805 struct usb_device *root = ohci_to_hcd(ohci)->self.root_hub;
806 798
807 /* mark any devices gone, so they do nothing till khubd disconnects. 799 /* mark any devices gone, so they do nothing till khubd disconnects.
808 * recycle any "live" eds/tds (and urbs) right away. 800 * recycle any "live" eds/tds (and urbs) right away.
@@ -811,11 +803,7 @@ static int ohci_restart (struct ohci_hcd *ohci)
811 */ 803 */
812 spin_lock_irq(&ohci->lock); 804 spin_lock_irq(&ohci->lock);
813 disable (ohci); 805 disable (ohci);
814 for (i = 0; i < root->maxchild; i++) { 806 usb_root_hub_lost_power(ohci_to_hcd(ohci)->self.root_hub);
815 if (root->children [i])
816 usb_set_device_state (root->children[i],
817 USB_STATE_NOTATTACHED);
818 }
819 if (!list_empty (&ohci->pending)) 807 if (!list_empty (&ohci->pending))
820 ohci_dbg(ohci, "abort schedule...\n"); 808 ohci_dbg(ohci, "abort schedule...\n");
821 list_for_each_entry (priv, &ohci->pending, pending) { 809 list_for_each_entry (priv, &ohci->pending, pending) {
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index 72e3b12a1926..4b2226d77b34 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -372,7 +372,7 @@ done:
372 & ohci->hc_control) 372 & ohci->hc_control)
373 == OHCI_USB_OPER 373 == OHCI_USB_OPER
374 && time_after (jiffies, ohci->next_statechange) 374 && time_after (jiffies, ohci->next_statechange)
375 && usb_trylock_device (hcd->self.root_hub) 375 && usb_trylock_device (hcd->self.root_hub) == 0
376 ) { 376 ) {
377 ohci_vdbg (ohci, "autosuspend\n"); 377 ohci_vdbg (ohci, "autosuspend\n");
378 (void) ohci_bus_suspend (hcd); 378 (void) ohci_bus_suspend (hcd);
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 9d65ec307990..acde8868da21 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -26,18 +26,12 @@
26#include <asm/mach-types.h> 26#include <asm/mach-types.h>
27#include <asm/hardware.h> 27#include <asm/hardware.h>
28#include <asm/arch/pxa-regs.h> 28#include <asm/arch/pxa-regs.h>
29 29#include <asm/arch/ohci.h>
30
31#define PMM_NPS_MODE 1
32#define PMM_GLOBAL_MODE 2
33#define PMM_PERPORT_MODE 3
34 30
35#define PXA_UHC_MAX_PORTNUM 3 31#define PXA_UHC_MAX_PORTNUM 3
36 32
37#define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 ) 33#define UHCRHPS(x) __REG2( 0x4C000050, (x)<<2 )
38 34
39static int pxa27x_ohci_pmm_state;
40
41/* 35/*
42 PMM_NPS_MODE -- PMM Non-power switching mode 36 PMM_NPS_MODE -- PMM Non-power switching mode
43 Ports are powered continuously. 37 Ports are powered continuously.
@@ -50,8 +44,6 @@ static int pxa27x_ohci_pmm_state;
50 */ 44 */
51static int pxa27x_ohci_select_pmm( int mode ) 45static int pxa27x_ohci_select_pmm( int mode )
52{ 46{
53 pxa27x_ohci_pmm_state = mode;
54
55 switch ( mode ) { 47 switch ( mode ) {
56 case PMM_NPS_MODE: 48 case PMM_NPS_MODE:
57 UHCRHDA |= RH_A_NPS; 49 UHCRHDA |= RH_A_NPS;
@@ -71,7 +63,6 @@ static int pxa27x_ohci_select_pmm( int mode )
71 "Invalid mode %d, set to non-power switch mode.\n", 63 "Invalid mode %d, set to non-power switch mode.\n",
72 mode ); 64 mode );
73 65
74 pxa27x_ohci_pmm_state = PMM_NPS_MODE;
75 UHCRHDA |= RH_A_NPS; 66 UHCRHDA |= RH_A_NPS;
76 } 67 }
77 68
@@ -82,8 +73,13 @@ extern int usb_disabled(void);
82 73
83/*-------------------------------------------------------------------------*/ 74/*-------------------------------------------------------------------------*/
84 75
85static void pxa27x_start_hc(struct platform_device *dev) 76static int pxa27x_start_hc(struct device *dev)
86{ 77{
78 int retval = 0;
79 struct pxaohci_platform_data *inf;
80
81 inf = dev->platform_data;
82
87 pxa_set_cken(CKEN10_USBHOST, 1); 83 pxa_set_cken(CKEN10_USBHOST, 1);
88 84
89 UHCHR |= UHCHR_FHR; 85 UHCHR |= UHCHR_FHR;
@@ -94,21 +90,11 @@ static void pxa27x_start_hc(struct platform_device *dev)
94 while (UHCHR & UHCHR_FSBIR) 90 while (UHCHR & UHCHR_FSBIR)
95 cpu_relax(); 91 cpu_relax();
96 92
97 /* This could be properly abstracted away through the 93 if (inf->init)
98 device data the day more machines are supported and 94 retval = inf->init(dev);
99 their differences can be figured out correctly. */
100 if (machine_is_mainstone()) {
101 /* setup Port1 GPIO pin. */
102 pxa_gpio_mode( 88 | GPIO_ALT_FN_1_IN); /* USBHPWR1 */
103 pxa_gpio_mode( 89 | GPIO_ALT_FN_2_OUT); /* USBHPEN1 */
104
105 /* Set the Power Control Polarity Low and Power Sense
106 Polarity Low to active low. Supply power to USB ports. */
107 UHCHR = (UHCHR | UHCHR_PCPL | UHCHR_PSPL) &
108 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
109 95
110 pxa27x_ohci_pmm_state = PMM_PERPORT_MODE; 96 if (retval < 0)
111 } 97 return retval;
112 98
113 UHCHR &= ~UHCHR_SSE; 99 UHCHR &= ~UHCHR_SSE;
114 100
@@ -117,10 +103,19 @@ static void pxa27x_start_hc(struct platform_device *dev)
117 /* Clear any OTG Pin Hold */ 103 /* Clear any OTG Pin Hold */
118 if (PSSR & PSSR_OTGPH) 104 if (PSSR & PSSR_OTGPH)
119 PSSR |= PSSR_OTGPH; 105 PSSR |= PSSR_OTGPH;
106
107 return 0;
120} 108}
121 109
122static void pxa27x_stop_hc(struct platform_device *dev) 110static void pxa27x_stop_hc(struct device *dev)
123{ 111{
112 struct pxaohci_platform_data *inf;
113
114 inf = dev->platform_data;
115
116 if (inf->exit)
117 inf->exit(dev);
118
124 UHCHR |= UHCHR_FHR; 119 UHCHR |= UHCHR_FHR;
125 udelay(11); 120 udelay(11);
126 UHCHR &= ~UHCHR_FHR; 121 UHCHR &= ~UHCHR_FHR;
@@ -147,22 +142,27 @@ static void pxa27x_stop_hc(struct platform_device *dev)
147 * through the hotplug entry's driver_data. 142 * through the hotplug entry's driver_data.
148 * 143 *
149 */ 144 */
150int usb_hcd_pxa27x_probe (const struct hc_driver *driver, 145int usb_hcd_pxa27x_probe (const struct hc_driver *driver, struct platform_device *pdev)
151 struct platform_device *dev)
152{ 146{
153 int retval; 147 int retval;
154 struct usb_hcd *hcd; 148 struct usb_hcd *hcd;
149 struct pxaohci_platform_data *inf;
155 150
156 if (dev->resource[1].flags != IORESOURCE_IRQ) { 151 inf = pdev->dev.platform_data;
152
153 if (!inf)
154 return -ENODEV;
155
156 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
157 pr_debug ("resource[1] is not IORESOURCE_IRQ"); 157 pr_debug ("resource[1] is not IORESOURCE_IRQ");
158 return -ENOMEM; 158 return -ENOMEM;
159 } 159 }
160 160
161 hcd = usb_create_hcd (driver, &dev->dev, "pxa27x"); 161 hcd = usb_create_hcd (driver, &pdev->dev, "pxa27x");
162 if (!hcd) 162 if (!hcd)
163 return -ENOMEM; 163 return -ENOMEM;
164 hcd->rsrc_start = dev->resource[0].start; 164 hcd->rsrc_start = pdev->resource[0].start;
165 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; 165 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
166 166
167 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 167 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
168 pr_debug("request_mem_region failed"); 168 pr_debug("request_mem_region failed");
@@ -177,18 +177,22 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver,
177 goto err2; 177 goto err2;
178 } 178 }
179 179
180 pxa27x_start_hc(dev); 180 if ((retval = pxa27x_start_hc(&pdev->dev)) < 0) {
181 pr_debug("pxa27x_start_hc failed");
182 goto err3;
183 }
181 184
182 /* Select Power Management Mode */ 185 /* Select Power Management Mode */
183 pxa27x_ohci_select_pmm(pxa27x_ohci_pmm_state); 186 pxa27x_ohci_select_pmm(inf->port_mode);
184 187
185 ohci_hcd_init(hcd_to_ohci(hcd)); 188 ohci_hcd_init(hcd_to_ohci(hcd));
186 189
187 retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT); 190 retval = usb_add_hcd(hcd, pdev->resource[1].start, SA_INTERRUPT);
188 if (retval == 0) 191 if (retval == 0)
189 return retval; 192 return retval;
190 193
191 pxa27x_stop_hc(dev); 194 pxa27x_stop_hc(&pdev->dev);
195 err3:
192 iounmap(hcd->regs); 196 iounmap(hcd->regs);
193 err2: 197 err2:
194 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 198 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
@@ -211,10 +215,10 @@ int usb_hcd_pxa27x_probe (const struct hc_driver *driver,
211 * context, normally "rmmod", "apmd", or something similar. 215 * context, normally "rmmod", "apmd", or something similar.
212 * 216 *
213 */ 217 */
214void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *dev) 218void usb_hcd_pxa27x_remove (struct usb_hcd *hcd, struct platform_device *pdev)
215{ 219{
216 usb_remove_hcd(hcd); 220 usb_remove_hcd(hcd);
217 pxa27x_stop_hc(dev); 221 pxa27x_stop_hc(&pdev->dev);
218 iounmap(hcd->regs); 222 iounmap(hcd->regs);
219 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 223 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
220 usb_put_hcd(hcd); 224 usb_put_hcd(hcd);
@@ -292,15 +296,12 @@ static const struct hc_driver ohci_pxa27x_hc_driver = {
292 296
293static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev) 297static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev)
294{ 298{
295 int ret;
296
297 pr_debug ("In ohci_hcd_pxa27x_drv_probe"); 299 pr_debug ("In ohci_hcd_pxa27x_drv_probe");
298 300
299 if (usb_disabled()) 301 if (usb_disabled())
300 return -ENODEV; 302 return -ENODEV;
301 303
302 ret = usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev); 304 return usb_hcd_pxa27x_probe(&ohci_pxa27x_hc_driver, pdev);
303 return ret;
304} 305}
305 306
306static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev) 307static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
@@ -308,31 +309,55 @@ static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
308 struct usb_hcd *hcd = platform_get_drvdata(pdev); 309 struct usb_hcd *hcd = platform_get_drvdata(pdev);
309 310
310 usb_hcd_pxa27x_remove(hcd, pdev); 311 usb_hcd_pxa27x_remove(hcd, pdev);
312 platform_set_drvdata(pdev, NULL);
311 return 0; 313 return 0;
312} 314}
313 315
314static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *dev, pm_message_t state) 316#ifdef CONFIG_PM
317static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *pdev, pm_message_t state)
315{ 318{
316// struct usb_hcd *hcd = platform_get_drvdata(dev); 319 struct usb_hcd *hcd = platform_get_drvdata(pdev);
317 printk("%s: not implemented yet\n", __FUNCTION__); 320 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
321
322 if (time_before(jiffies, ohci->next_statechange))
323 msleep(5);
324 ohci->next_statechange = jiffies;
325
326 pxa27x_stop_hc(&pdev->dev);
327 hcd->state = HC_STATE_SUSPENDED;
328 pdev->dev.power.power_state = PMSG_SUSPEND;
318 329
319 return 0; 330 return 0;
320} 331}
321 332
322static int ohci_hcd_pxa27x_drv_resume(struct platform_device *dev) 333static int ohci_hcd_pxa27x_drv_resume(struct platform_device *pdev)
323{ 334{
324// struct usb_hcd *hcd = platform_get_drvdata(dev); 335 struct usb_hcd *hcd = platform_get_drvdata(pdev);
325 printk("%s: not implemented yet\n", __FUNCTION__); 336 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
337 int status;
338
339 if (time_before(jiffies, ohci->next_statechange))
340 msleep(5);
341 ohci->next_statechange = jiffies;
342
343 if ((status = pxa27x_start_hc(&pdev->dev)) < 0)
344 return status;
345
346 pdev->dev.power.power_state = PMSG_ON;
347 usb_hcd_resume_root_hub(hcd);
326 348
327 return 0; 349 return 0;
328} 350}
351#endif
329 352
330 353
331static struct platform_driver ohci_hcd_pxa27x_driver = { 354static struct platform_driver ohci_hcd_pxa27x_driver = {
332 .probe = ohci_hcd_pxa27x_drv_probe, 355 .probe = ohci_hcd_pxa27x_drv_probe,
333 .remove = ohci_hcd_pxa27x_drv_remove, 356 .remove = ohci_hcd_pxa27x_drv_remove,
357#ifdef CONFIG_PM
334 .suspend = ohci_hcd_pxa27x_drv_suspend, 358 .suspend = ohci_hcd_pxa27x_drv_suspend,
335 .resume = ohci_hcd_pxa27x_drv_resume, 359 .resume = ohci_hcd_pxa27x_drv_resume,
360#endif
336 .driver = { 361 .driver = {
337 .name = "pxa27x-ohci", 362 .name = "pxa27x-ohci",
338 }, 363 },
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c
index e46528c825bf..3ef2c0cdf1db 100644
--- a/drivers/usb/host/pci-quirks.c
+++ b/drivers/usb/host/pci-quirks.c
@@ -9,12 +9,6 @@
9 */ 9 */
10 10
11#include <linux/config.h> 11#include <linux/config.h>
12#ifdef CONFIG_USB_DEBUG
13#define DEBUG
14#else
15#undef DEBUG
16#endif
17
18#include <linux/types.h> 12#include <linux/types.h>
19#include <linux/kernel.h> 13#include <linux/kernel.h>
20#include <linux/pci.h> 14#include <linux/pci.h>
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index a7722a6a5a5b..517360b77d8e 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -32,13 +32,6 @@
32#undef PACKET_TRACE 32#undef PACKET_TRACE
33 33
34#include <linux/config.h> 34#include <linux/config.h>
35
36#ifdef CONFIG_USB_DEBUG
37# define DEBUG
38#else
39# undef DEBUG
40#endif
41
42#include <linux/module.h> 35#include <linux/module.h>
43#include <linux/moduleparam.h> 36#include <linux/moduleparam.h>
44#include <linux/kernel.h> 37#include <linux/kernel.h>
@@ -1581,7 +1574,9 @@ sl811h_start(struct usb_hcd *hcd)
1581 hcd->state = HC_STATE_RUNNING; 1574 hcd->state = HC_STATE_RUNNING;
1582 1575
1583 if (sl811->board) { 1576 if (sl811->board) {
1584 hcd->can_wakeup = sl811->board->can_wakeup; 1577 if (!device_can_wakeup(hcd->self.controller))
1578 device_init_wakeup(hcd->self.controller,
1579 sl811->board->can_wakeup);
1585 hcd->power_budget = sl811->board->power * 2; 1580 hcd->power_budget = sl811->board->power * 2;
1586 } 1581 }
1587 1582
@@ -1805,9 +1800,10 @@ sl811h_resume(struct platform_device *dev)
1805 * let's assume it'd only be powered to enable remote wakeup. 1800 * let's assume it'd only be powered to enable remote wakeup.
1806 */ 1801 */
1807 if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND 1802 if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND
1808 || !hcd->can_wakeup) { 1803 || !device_can_wakeup(&hcd->self.root_hub->dev)) {
1809 sl811->port1 = 0; 1804 sl811->port1 = 0;
1810 port_power(sl811, 1); 1805 port_power(sl811, 1);
1806 usb_root_hub_lost_power(hcd->self.root_hub);
1811 return 0; 1807 return 0;
1812 } 1808 }
1813 1809
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index e73faf831b24..466384d7c79f 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -38,7 +38,7 @@ MODULE_LICENSE("GPL");
38/* MACROS */ 38/* MACROS */
39/*====================================================================*/ 39/*====================================================================*/
40 40
41#if defined(DEBUG) || defined(CONFIG_USB_DEBUG) || defined(PCMCIA_DEBUG) 41#if defined(DEBUG) || defined(PCMCIA_DEBUG)
42 42
43static int pc_debug = 0; 43static int pc_debug = 0;
44module_param(pc_debug, int, 0644); 44module_param(pc_debug, int, 0644);
@@ -66,13 +66,13 @@ module_param(pc_debug, int, 0644);
66 66
67static const char driver_name[DEV_NAME_LEN] = "sl811_cs"; 67static const char driver_name[DEV_NAME_LEN] = "sl811_cs";
68 68
69static dev_link_t *dev_list = NULL;
70
71typedef struct local_info_t { 69typedef struct local_info_t {
72 dev_link_t link; 70 dev_link_t link;
73 dev_node_t node; 71 dev_node_t node;
74} local_info_t; 72} local_info_t;
75 73
74static void sl811_cs_release(dev_link_t * link);
75
76/*====================================================================*/ 76/*====================================================================*/
77 77
78static void release_platform_dev(struct device * dev) 78static void release_platform_dev(struct device * dev)
@@ -129,7 +129,8 @@ static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq)
129 resources[2].end = base_addr + 1; 129 resources[2].end = base_addr + 1;
130 130
131 /* The driver core will probe for us. We know sl811-hcd has been 131 /* The driver core will probe for us. We know sl811-hcd has been
132 * initialized already because of the link order dependency. 132 * initialized already because of the link order dependency created
133 * by referencing "sl811h_driver".
133 */ 134 */
134 platform_dev.name = sl811h_driver.name; 135 platform_dev.name = sl811h_driver.name;
135 return platform_device_register(&platform_dev); 136 return platform_device_register(&platform_dev);
@@ -137,26 +138,16 @@ static int sl811_hc_init(struct device *parent, ioaddr_t base_addr, int irq)
137 138
138/*====================================================================*/ 139/*====================================================================*/
139 140
140static void sl811_cs_detach(dev_link_t *link) 141static void sl811_cs_detach(struct pcmcia_device *p_dev)
141{ 142{
142 dev_link_t **linkp; 143 dev_link_t *link = dev_to_instance(p_dev);
143 144
144 DBG(0, "sl811_cs_detach(0x%p)\n", link); 145 DBG(0, "sl811_cs_detach(0x%p)\n", link);
145 146
146 /* Locate device structure */ 147 link->state &= ~DEV_PRESENT;
147 for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) { 148 if (link->state & DEV_CONFIG)
148 if (*linkp == link) 149 sl811_cs_release(link);
149 break;
150 }
151 if (*linkp == NULL)
152 return;
153
154 /* Break the link with Card Services */
155 if (link->handle)
156 pcmcia_deregister_client(link->handle);
157 150
158 /* Unlink device structure, and free it */
159 *linkp = link->next;
160 /* This points to the parent local_info_t struct */ 151 /* This points to the parent local_info_t struct */
161 kfree(link->priv); 152 kfree(link->priv);
162} 153}
@@ -166,13 +157,6 @@ static void sl811_cs_release(dev_link_t * link)
166 157
167 DBG(0, "sl811_cs_release(0x%p)\n", link); 158 DBG(0, "sl811_cs_release(0x%p)\n", link);
168 159
169 if (link->open) {
170 DBG(1, "sl811_cs: release postponed, '%s' still open\n",
171 link->dev->dev_name);
172 link->state |= DEV_STALE_CONFIG;
173 return;
174 }
175
176 /* Unlink the device chain */ 160 /* Unlink the device chain */
177 link->dev = NULL; 161 link->dev = NULL;
178 162
@@ -183,9 +167,6 @@ static void sl811_cs_release(dev_link_t * link)
183 if (link->irq.AssignedIRQ) 167 if (link->irq.AssignedIRQ)
184 pcmcia_release_irq(link->handle, &link->irq); 168 pcmcia_release_irq(link->handle, &link->irq);
185 link->state &= ~DEV_CONFIG; 169 link->state &= ~DEV_CONFIG;
186
187 if (link->state & DEV_STALE_LINK)
188 sl811_cs_detach(link);
189} 170}
190 171
191static void sl811_cs_config(dev_link_t *link) 172static void sl811_cs_config(dev_link_t *link)
@@ -322,55 +303,36 @@ cs_failed:
322 } 303 }
323} 304}
324 305
325static int 306static int sl811_suspend(struct pcmcia_device *dev)
326sl811_cs_event(event_t event, int priority, event_callback_args_t *args)
327{ 307{
328 dev_link_t *link = args->client_data; 308 dev_link_t *link = dev_to_instance(dev);
329 309
330 DBG(1, "sl811_cs_event(0x%06x)\n", event); 310 link->state |= DEV_SUSPEND;
311 if (link->state & DEV_CONFIG)
312 pcmcia_release_configuration(link->handle);
331 313
332 switch (event) { 314 return 0;
333 case CS_EVENT_CARD_REMOVAL: 315}
334 link->state &= ~DEV_PRESENT;
335 if (link->state & DEV_CONFIG)
336 sl811_cs_release(link);
337 break;
338 316
339 case CS_EVENT_CARD_INSERTION: 317static int sl811_resume(struct pcmcia_device *dev)
340 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; 318{
341 sl811_cs_config(link); 319 dev_link_t *link = dev_to_instance(dev);
342 break;
343 320
344 case CS_EVENT_PM_SUSPEND: 321 link->state &= ~DEV_SUSPEND;
345 link->state |= DEV_SUSPEND; 322 if (link->state & DEV_CONFIG)
346 /* Fall through... */ 323 pcmcia_request_configuration(link->handle, &link->conf);
347 case CS_EVENT_RESET_PHYSICAL:
348 if (link->state & DEV_CONFIG)
349 pcmcia_release_configuration(link->handle);
350 break;
351 324
352 case CS_EVENT_PM_RESUME:
353 link->state &= ~DEV_SUSPEND;
354 /* Fall through... */
355 case CS_EVENT_CARD_RESET:
356 if (link->state & DEV_CONFIG)
357 pcmcia_request_configuration(link->handle, &link->conf);
358 DBG(0, "reset sl811-hcd here?\n");
359 break;
360 }
361 return 0; 325 return 0;
362} 326}
363 327
364static dev_link_t *sl811_cs_attach(void) 328static int sl811_cs_attach(struct pcmcia_device *p_dev)
365{ 329{
366 local_info_t *local; 330 local_info_t *local;
367 dev_link_t *link; 331 dev_link_t *link;
368 client_reg_t client_reg;
369 int ret;
370 332
371 local = kmalloc(sizeof(local_info_t), GFP_KERNEL); 333 local = kmalloc(sizeof(local_info_t), GFP_KERNEL);
372 if (!local) 334 if (!local)
373 return NULL; 335 return -ENOMEM;
374 memset(local, 0, sizeof(local_info_t)); 336 memset(local, 0, sizeof(local_info_t));
375 link = &local->link; 337 link = &local->link;
376 link->priv = local; 338 link->priv = local;
@@ -384,21 +346,13 @@ static dev_link_t *sl811_cs_attach(void)
384 link->conf.Vcc = 33; 346 link->conf.Vcc = 33;
385 link->conf.IntType = INT_MEMORY_AND_IO; 347 link->conf.IntType = INT_MEMORY_AND_IO;
386 348
387 /* Register with Card Services */ 349 link->handle = p_dev;
388 link->next = dev_list; 350 p_dev->instance = link;
389 dev_list = link;
390 client_reg.dev_info = (dev_info_t *) &driver_name;
391 client_reg.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE;
392 client_reg.Version = 0x0210;
393 client_reg.event_callback_args.client_data = link;
394 ret = pcmcia_register_client(&link->handle, &client_reg);
395 if (ret != CS_SUCCESS) {
396 cs_error(link->handle, RegisterClient, ret);
397 sl811_cs_detach(link);
398 return NULL;
399 }
400 351
401 return link; 352 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
353 sl811_cs_config(link);
354
355 return 0;
402} 356}
403 357
404static struct pcmcia_device_id sl811_ids[] = { 358static struct pcmcia_device_id sl811_ids[] = {
@@ -412,10 +366,11 @@ static struct pcmcia_driver sl811_cs_driver = {
412 .drv = { 366 .drv = {
413 .name = (char *)driver_name, 367 .name = (char *)driver_name,
414 }, 368 },
415 .attach = sl811_cs_attach, 369 .probe = sl811_cs_attach,
416 .event = sl811_cs_event, 370 .remove = sl811_cs_detach,
417 .detach = sl811_cs_detach,
418 .id_table = sl811_ids, 371 .id_table = sl811_ids,
372 .suspend = sl811_suspend,
373 .resume = sl811_resume,
419}; 374};
420 375
421/*====================================================================*/ 376/*====================================================================*/
diff --git a/drivers/usb/host/uhci-debug.c b/drivers/usb/host/uhci-debug.c
index 151154df37fa..5832953086f8 100644
--- a/drivers/usb/host/uhci-debug.c
+++ b/drivers/usb/host/uhci-debug.c
@@ -2,8 +2,8 @@
2 * UHCI-specific debugging code. Invaluable when something 2 * UHCI-specific debugging code. Invaluable when something
3 * goes wrong, but don't get in my face. 3 * goes wrong, but don't get in my face.
4 * 4 *
5 * Kernel visible pointers are surrounded in []'s and bus 5 * Kernel visible pointers are surrounded in []s and bus
6 * visible pointers are surrounded in ()'s 6 * visible pointers are surrounded in ()s
7 * 7 *
8 * (C) Copyright 1999 Linus Torvalds 8 * (C) Copyright 1999 Linus Torvalds
9 * (C) Copyright 1999-2001 Johannes Erdfelt 9 * (C) Copyright 1999-2001 Johannes Erdfelt
@@ -19,7 +19,7 @@
19 19
20static struct dentry *uhci_debugfs_root = NULL; 20static struct dentry *uhci_debugfs_root = NULL;
21 21
22/* Handle REALLY large printk's so we don't overflow buffers */ 22/* Handle REALLY large printks so we don't overflow buffers */
23static inline void lprintk(char *buf) 23static inline void lprintk(char *buf)
24{ 24{
25 char *p; 25 char *p;
@@ -160,7 +160,7 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space)
160 } 160 }
161 161
162 if (active && ni > i) { 162 if (active && ni > i) {
163 out += sprintf(out, "%*s[skipped %d active TD's]\n", space, "", ni - i); 163 out += sprintf(out, "%*s[skipped %d active TDs]\n", space, "", ni - i);
164 tmp = ntmp; 164 tmp = ntmp;
165 td = ntd; 165 td = ntd;
166 i = ni; 166 i = ni;
@@ -173,7 +173,7 @@ static int uhci_show_qh(struct uhci_qh *qh, char *buf, int len, int space)
173 if (list_empty(&urbp->queue_list) || urbp->queued) 173 if (list_empty(&urbp->queue_list) || urbp->queued)
174 goto out; 174 goto out;
175 175
176 out += sprintf(out, "%*sQueued QH's:\n", -space, "--"); 176 out += sprintf(out, "%*sQueued QHs:\n", -space, "--");
177 177
178 head = &urbp->queue_list; 178 head = &urbp->queue_list;
179 tmp = head->next; 179 tmp = head->next;
@@ -197,7 +197,7 @@ out:
197 } 197 }
198 198
199#ifdef CONFIG_PROC_FS 199#ifdef CONFIG_PROC_FS
200static const char *qh_names[] = { 200static const char * const qh_names[] = {
201 "skel_int128_qh", "skel_int64_qh", 201 "skel_int128_qh", "skel_int64_qh",
202 "skel_int32_qh", "skel_int16_qh", 202 "skel_int32_qh", "skel_int16_qh",
203 "skel_int8_qh", "skel_int4_qh", 203 "skel_int8_qh", "skel_int4_qh",
@@ -464,7 +464,7 @@ static int uhci_sprint_schedule(struct uhci_hcd *uhci, char *buf, int len)
464 } while (tmp != head); 464 } while (tmp != head);
465 } 465 }
466 466
467 out += sprintf(out, "Skeleton QH's\n"); 467 out += sprintf(out, "Skeleton QHs\n");
468 468
469 for (i = 0; i < UHCI_NUM_SKELQH; ++i) { 469 for (i = 0; i < UHCI_NUM_SKELQH; ++i) {
470 int shown = 0; 470 int shown = 0;
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index ed550132db0b..dfe121d35887 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -23,11 +23,6 @@
23 */ 23 */
24 24
25#include <linux/config.h> 25#include <linux/config.h>
26#ifdef CONFIG_USB_DEBUG
27#define DEBUG
28#else
29#undef DEBUG
30#endif
31#include <linux/module.h> 26#include <linux/module.h>
32#include <linux/pci.h> 27#include <linux/pci.h>
33#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -67,10 +62,10 @@ Alan Stern"
67 62
68/* 63/*
69 * debug = 0, no debugging messages 64 * debug = 0, no debugging messages
70 * debug = 1, dump failed URB's except for stalls 65 * debug = 1, dump failed URBs except for stalls
71 * debug = 2, dump all failed URB's (including stalls) 66 * debug = 2, dump all failed URBs (including stalls)
72 * show all queues in /debug/uhci/[pci_addr] 67 * show all queues in /debug/uhci/[pci_addr]
73 * debug = 3, show all TD's in URB's when dumping 68 * debug = 3, show all TDs in URBs when dumping
74 */ 69 */
75#ifdef DEBUG 70#ifdef DEBUG
76static int debug = 1; 71static int debug = 1;
@@ -93,7 +88,7 @@ static void uhci_get_current_frame_number(struct uhci_hcd *uhci);
93#define FSBR_DELAY msecs_to_jiffies(50) 88#define FSBR_DELAY msecs_to_jiffies(50)
94 89
95/* When we timeout an idle transfer for FSBR, we'll switch it over to */ 90/* When we timeout an idle transfer for FSBR, we'll switch it over to */
96/* depth first traversal. We'll do it in groups of this number of TD's */ 91/* depth first traversal. We'll do it in groups of this number of TDs */
97/* to make sure it doesn't hog all of the bandwidth */ 92/* to make sure it doesn't hog all of the bandwidth */
98#define DEPTH_INTERVAL 5 93#define DEPTH_INTERVAL 5
99 94
@@ -478,8 +473,6 @@ static int uhci_start(struct usb_hcd *hcd)
478 struct dentry *dentry; 473 struct dentry *dentry;
479 474
480 hcd->uses_new_polling = 1; 475 hcd->uses_new_polling = 1;
481 if (pci_find_capability(to_pci_dev(uhci_dev(uhci)), PCI_CAP_ID_PM))
482 hcd->can_wakeup = 1; /* Assume it supports PME# */
483 476
484 dentry = debugfs_create_file(hcd->self.bus_name, 477 dentry = debugfs_create_file(hcd->self.bus_name,
485 S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, uhci, 478 S_IFREG|S_IRUGO|S_IWUSR, uhci_debugfs_root, uhci,
@@ -573,7 +566,7 @@ static int uhci_start(struct usb_hcd *hcd)
573 uhci->skel_bulk_qh->link = cpu_to_le32(uhci->skel_term_qh->dma_handle) | UHCI_PTR_QH; 566 uhci->skel_bulk_qh->link = cpu_to_le32(uhci->skel_term_qh->dma_handle) | UHCI_PTR_QH;
574 567
575 /* This dummy TD is to work around a bug in Intel PIIX controllers */ 568 /* This dummy TD is to work around a bug in Intel PIIX controllers */
576 uhci_fill_td(uhci->term_td, 0, (UHCI_NULL_DATA_SIZE << 21) | 569 uhci_fill_td(uhci->term_td, 0, uhci_explen(0) |
577 (0x7f << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_IN, 0); 570 (0x7f << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_IN, 0);
578 uhci->term_td->link = cpu_to_le32(uhci->term_td->dma_handle); 571 uhci->term_td->link = cpu_to_le32(uhci->term_td->dma_handle);
579 572
@@ -717,6 +710,7 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
717 * at the source, so we must turn off PIRQ. 710 * at the source, so we must turn off PIRQ.
718 */ 711 */
719 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); 712 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0);
713 mb();
720 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 714 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
721 uhci->hc_inaccessible = 1; 715 uhci->hc_inaccessible = 1;
722 hcd->poll_rh = 0; 716 hcd->poll_rh = 0;
@@ -734,10 +728,12 @@ static int uhci_resume(struct usb_hcd *hcd)
734 728
735 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); 729 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__);
736 730
737 /* We aren't in D3 state anymore, we do that even if dead as I 731 /* Since we aren't in D3 any more, it's safe to set this flag
738 * really don't want to keep a stale HCD_FLAG_HW_ACCESSIBLE=0 732 * even if the controller was dead. It might not even be dead
733 * any more, if the firmware or quirks code has reset it.
739 */ 734 */
740 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 735 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
736 mb();
741 737
742 if (uhci->rh_state == UHCI_RH_RESET) /* Dead */ 738 if (uhci->rh_state == UHCI_RH_RESET) /* Dead */
743 return 0; 739 return 0;
@@ -753,8 +749,12 @@ static int uhci_resume(struct usb_hcd *hcd)
753 check_and_reset_hc(uhci); 749 check_and_reset_hc(uhci);
754 configure_hc(uhci); 750 configure_hc(uhci);
755 751
756 if (uhci->rh_state == UHCI_RH_RESET) 752 if (uhci->rh_state == UHCI_RH_RESET) {
753
754 /* The controller had to be reset */
755 usb_root_hub_lost_power(hcd->self.root_hub);
757 suspend_rh(uhci, UHCI_RH_SUSPENDED); 756 suspend_rh(uhci, UHCI_RH_SUSPENDED);
757 }
758 758
759 spin_unlock_irq(&uhci->lock); 759 spin_unlock_irq(&uhci->lock);
760 760
@@ -880,7 +880,7 @@ static int __init uhci_hcd_init(void)
880 880
881init_failed: 881init_failed:
882 if (kmem_cache_destroy(uhci_up_cachep)) 882 if (kmem_cache_destroy(uhci_up_cachep))
883 warn("not all urb_priv's were freed!"); 883 warn("not all urb_privs were freed!");
884 884
885up_failed: 885up_failed:
886 debugfs_remove(uhci_debugfs_root); 886 debugfs_remove(uhci_debugfs_root);
@@ -898,7 +898,7 @@ static void __exit uhci_hcd_cleanup(void)
898 pci_unregister_driver(&uhci_pci_driver); 898 pci_unregister_driver(&uhci_pci_driver);
899 899
900 if (kmem_cache_destroy(uhci_up_cachep)) 900 if (kmem_cache_destroy(uhci_up_cachep))
901 warn("not all urb_priv's were freed!"); 901 warn("not all urb_privs were freed!");
902 902
903 debugfs_remove(uhci_debugfs_root); 903 debugfs_remove(uhci_debugfs_root);
904 kfree(errbuf); 904 kfree(errbuf);
diff --git a/drivers/usb/host/uhci-hcd.h b/drivers/usb/host/uhci-hcd.h
index e576db57a926..8b4b887a7d41 100644
--- a/drivers/usb/host/uhci-hcd.h
+++ b/drivers/usb/host/uhci-hcd.h
@@ -71,8 +71,6 @@
71#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */ 71#define USBLEGSUP_RWC 0x8f00 /* the R/WC bits */
72#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */ 72#define USBLEGSUP_RO 0x5040 /* R/O and reserved bits */
73 73
74#define UHCI_NULL_DATA_SIZE 0x7FF /* for UHCI controller TD */
75
76#define UHCI_PTR_BITS cpu_to_le32(0x000F) 74#define UHCI_PTR_BITS cpu_to_le32(0x000F)
77#define UHCI_PTR_TERM cpu_to_le32(0x0001) 75#define UHCI_PTR_TERM cpu_to_le32(0x0001)
78#define UHCI_PTR_QH cpu_to_le32(0x0002) 76#define UHCI_PTR_QH cpu_to_le32(0x0002)
@@ -168,9 +166,11 @@ static __le32 inline qh_element(struct uhci_qh *qh) {
168#define TD_TOKEN_EXPLEN_MASK 0x7FF /* expected length, encoded as n - 1 */ 166#define TD_TOKEN_EXPLEN_MASK 0x7FF /* expected length, encoded as n - 1 */
169#define TD_TOKEN_PID_MASK 0xFF 167#define TD_TOKEN_PID_MASK 0xFF
170 168
171#define uhci_explen(len) ((len) << TD_TOKEN_EXPLEN_SHIFT) 169#define uhci_explen(len) ((((len) - 1) & TD_TOKEN_EXPLEN_MASK) << \
170 TD_TOKEN_EXPLEN_SHIFT)
172 171
173#define uhci_expected_length(token) ((((token) >> 21) + 1) & TD_TOKEN_EXPLEN_MASK) 172#define uhci_expected_length(token) ((((token) >> TD_TOKEN_EXPLEN_SHIFT) + \
173 1) & TD_TOKEN_EXPLEN_MASK)
174#define uhci_toggle(token) (((token) >> TD_TOKEN_TOGGLE_SHIFT) & 1) 174#define uhci_toggle(token) (((token) >> TD_TOKEN_TOGGLE_SHIFT) & 1)
175#define uhci_endpoint(token) (((token) >> 15) & 0xf) 175#define uhci_endpoint(token) (((token) >> 15) & 0xf)
176#define uhci_devaddr(token) (((token) >> TD_TOKEN_DEVADDR_SHIFT) & 0x7f) 176#define uhci_devaddr(token) (((token) >> TD_TOKEN_DEVADDR_SHIFT) & 0x7f)
@@ -223,10 +223,10 @@ static u32 inline td_status(struct uhci_td *td) {
223 */ 223 */
224 224
225/* 225/*
226 * The UHCI driver places Interrupt, Control and Bulk into QH's both 226 * The UHCI driver places Interrupt, Control and Bulk into QHs both
227 * to group together TD's for one transfer, and also to faciliate queuing 227 * to group together TDs for one transfer, and also to facilitate queuing
228 * of URB's. To make it easy to insert entries into the schedule, we have 228 * of URBs. To make it easy to insert entries into the schedule, we have
229 * a skeleton of QH's for each predefined Interrupt latency, low-speed 229 * a skeleton of QHs for each predefined Interrupt latency, low-speed
230 * control, full-speed control and terminating QH (see explanation for 230 * control, full-speed control and terminating QH (see explanation for
231 * the terminating QH below). 231 * the terminating QH below).
232 * 232 *
@@ -257,8 +257,8 @@ static u32 inline td_status(struct uhci_td *td) {
257 * reclamation. 257 * reclamation.
258 * 258 *
259 * Isochronous transfers are stored before the start of the skeleton 259 * Isochronous transfers are stored before the start of the skeleton
260 * schedule and don't use QH's. While the UHCI spec doesn't forbid the 260 * schedule and don't use QHs. While the UHCI spec doesn't forbid the
261 * use of QH's for Isochronous, it doesn't use them either. And the spec 261 * use of QHs for Isochronous, it doesn't use them either. And the spec
262 * says that queues never advance on an error completion status, which 262 * says that queues never advance on an error completion status, which
263 * makes them totally unsuitable for Isochronous transfers. 263 * makes them totally unsuitable for Isochronous transfers.
264 */ 264 */
@@ -359,7 +359,7 @@ struct uhci_hcd {
359 struct dma_pool *td_pool; 359 struct dma_pool *td_pool;
360 360
361 struct uhci_td *term_td; /* Terminating TD, see UHCI bug */ 361 struct uhci_td *term_td; /* Terminating TD, see UHCI bug */
362 struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QH's */ 362 struct uhci_qh *skelqh[UHCI_NUM_SKELQH]; /* Skeleton QHs */
363 363
364 spinlock_t lock; 364 spinlock_t lock;
365 365
@@ -389,22 +389,22 @@ struct uhci_hcd {
389 unsigned long resuming_ports; 389 unsigned long resuming_ports;
390 unsigned long ports_timeout; /* Time to stop signalling */ 390 unsigned long ports_timeout; /* Time to stop signalling */
391 391
392 /* Main list of URB's currently controlled by this HC */ 392 /* Main list of URBs currently controlled by this HC */
393 struct list_head urb_list; 393 struct list_head urb_list;
394 394
395 /* List of QH's that are done, but waiting to be unlinked (race) */ 395 /* List of QHs that are done, but waiting to be unlinked (race) */
396 struct list_head qh_remove_list; 396 struct list_head qh_remove_list;
397 unsigned int qh_remove_age; /* Age in frames */ 397 unsigned int qh_remove_age; /* Age in frames */
398 398
399 /* List of TD's that are done, but waiting to be freed (race) */ 399 /* List of TDs that are done, but waiting to be freed (race) */
400 struct list_head td_remove_list; 400 struct list_head td_remove_list;
401 unsigned int td_remove_age; /* Age in frames */ 401 unsigned int td_remove_age; /* Age in frames */
402 402
403 /* List of asynchronously unlinked URB's */ 403 /* List of asynchronously unlinked URBs */
404 struct list_head urb_remove_list; 404 struct list_head urb_remove_list;
405 unsigned int urb_remove_age; /* Age in frames */ 405 unsigned int urb_remove_age; /* Age in frames */
406 406
407 /* List of URB's awaiting completion callback */ 407 /* List of URBs awaiting completion callback */
408 struct list_head complete_list; 408 struct list_head complete_list;
409 409
410 int rh_numports; /* Number of root-hub ports */ 410 int rh_numports; /* Number of root-hub ports */
diff --git a/drivers/usb/host/uhci-q.c b/drivers/usb/host/uhci-q.c
index 7e46887d9e12..b6076004a437 100644
--- a/drivers/usb/host/uhci-q.c
+++ b/drivers/usb/host/uhci-q.c
@@ -80,7 +80,7 @@ static inline void uhci_fill_td(struct uhci_td *td, u32 status,
80} 80}
81 81
82/* 82/*
83 * We insert Isochronous URB's directly into the frame list at the beginning 83 * We insert Isochronous URBs directly into the frame list at the beginning
84 */ 84 */
85static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td, unsigned framenum) 85static void uhci_insert_td_frame_list(struct uhci_hcd *uhci, struct uhci_td *td, unsigned framenum)
86{ 86{
@@ -369,7 +369,7 @@ static void uhci_append_queued_urb(struct uhci_hcd *uhci, struct urb *eurb, stru
369 uhci_fixup_toggle(urb, 369 uhci_fixup_toggle(urb,
370 uhci_toggle(td_token(lltd)) ^ 1)); 370 uhci_toggle(td_token(lltd)) ^ 1));
371 371
372 /* All qh's in the queue need to link to the next queue */ 372 /* All qhs in the queue need to link to the next queue */
373 urbp->qh->link = eurbp->qh->link; 373 urbp->qh->link = eurbp->qh->link;
374 374
375 wmb(); /* Make sure we flush everything */ 375 wmb(); /* Make sure we flush everything */
@@ -502,7 +502,7 @@ static void uhci_destroy_urb_priv(struct uhci_hcd *uhci, struct urb *urb)
502 } 502 }
503 503
504 /* Check to see if the remove list is empty. Set the IOC bit */ 504 /* Check to see if the remove list is empty. Set the IOC bit */
505 /* to force an interrupt so we can remove the TD's*/ 505 /* to force an interrupt so we can remove the TDs*/
506 if (list_empty(&uhci->td_remove_list)) 506 if (list_empty(&uhci->td_remove_list))
507 uhci_set_next_interrupt(uhci); 507 uhci_set_next_interrupt(uhci);
508 508
@@ -596,7 +596,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
596 return -ENOMEM; 596 return -ENOMEM;
597 597
598 uhci_add_td_to_urb(urb, td); 598 uhci_add_td_to_urb(urb, td);
599 uhci_fill_td(td, status, destination | uhci_explen(7), 599 uhci_fill_td(td, status, destination | uhci_explen(8),
600 urb->setup_dma); 600 urb->setup_dma);
601 601
602 /* 602 /*
@@ -612,7 +612,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
612 } 612 }
613 613
614 /* 614 /*
615 * Build the DATA TD's 615 * Build the DATA TDs
616 */ 616 */
617 while (len > 0) { 617 while (len > 0) {
618 int pktsze = len; 618 int pktsze = len;
@@ -628,7 +628,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
628 destination ^= TD_TOKEN_TOGGLE; 628 destination ^= TD_TOKEN_TOGGLE;
629 629
630 uhci_add_td_to_urb(urb, td); 630 uhci_add_td_to_urb(urb, td);
631 uhci_fill_td(td, status, destination | uhci_explen(pktsze - 1), 631 uhci_fill_td(td, status, destination | uhci_explen(pktsze),
632 data); 632 data);
633 633
634 data += pktsze; 634 data += pktsze;
@@ -658,7 +658,7 @@ static int uhci_submit_control(struct uhci_hcd *uhci, struct urb *urb, struct ur
658 658
659 uhci_add_td_to_urb(urb, td); 659 uhci_add_td_to_urb(urb, td);
660 uhci_fill_td(td, status | TD_CTRL_IOC, 660 uhci_fill_td(td, status | TD_CTRL_IOC,
661 destination | uhci_explen(UHCI_NULL_DATA_SIZE), 0); 661 destination | uhci_explen(0), 0);
662 662
663 qh = uhci_alloc_qh(uhci); 663 qh = uhci_alloc_qh(uhci);
664 if (!qh) 664 if (!qh)
@@ -744,7 +744,7 @@ static int uhci_result_control(struct uhci_hcd *uhci, struct urb *urb)
744 744
745 urb->actual_length = 0; 745 urb->actual_length = 0;
746 746
747 /* The rest of the TD's (but the last) are data */ 747 /* The rest of the TDs (but the last) are data */
748 tmp = tmp->next; 748 tmp = tmp->next;
749 while (tmp != head && tmp->next != head) { 749 while (tmp != head && tmp->next != head) {
750 unsigned int ctrlstat; 750 unsigned int ctrlstat;
@@ -848,7 +848,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
848 status |= TD_CTRL_SPD; 848 status |= TD_CTRL_SPD;
849 849
850 /* 850 /*
851 * Build the DATA TD's 851 * Build the DATA TDs
852 */ 852 */
853 do { /* Allow zero length packets */ 853 do { /* Allow zero length packets */
854 int pktsze = maxsze; 854 int pktsze = maxsze;
@@ -864,7 +864,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
864 return -ENOMEM; 864 return -ENOMEM;
865 865
866 uhci_add_td_to_urb(urb, td); 866 uhci_add_td_to_urb(urb, td);
867 uhci_fill_td(td, status, destination | uhci_explen(pktsze - 1) | 867 uhci_fill_td(td, status, destination | uhci_explen(pktsze) |
868 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), 868 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe),
869 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT), 869 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT),
870 data); 870 data);
@@ -890,7 +890,7 @@ static int uhci_submit_common(struct uhci_hcd *uhci, struct urb *urb, struct urb
890 return -ENOMEM; 890 return -ENOMEM;
891 891
892 uhci_add_td_to_urb(urb, td); 892 uhci_add_td_to_urb(urb, td);
893 uhci_fill_td(td, status, destination | uhci_explen(UHCI_NULL_DATA_SIZE) | 893 uhci_fill_td(td, status, destination | uhci_explen(0) |
894 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe), 894 (usb_gettoggle(urb->dev, usb_pipeendpoint(urb->pipe),
895 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT), 895 usb_pipeout(urb->pipe)) << TD_TOKEN_TOGGLE_SHIFT),
896 data); 896 data);
@@ -1025,7 +1025,7 @@ static int isochronous_find_limits(struct uhci_hcd *uhci, struct urb *urb, unsig
1025 list_for_each_entry(up, &uhci->urb_list, urb_list) { 1025 list_for_each_entry(up, &uhci->urb_list, urb_list) {
1026 struct urb *u = up->urb; 1026 struct urb *u = up->urb;
1027 1027
1028 /* look for pending URB's with identical pipe handle */ 1028 /* look for pending URBs with identical pipe handle */
1029 if ((urb->pipe == u->pipe) && (urb->dev == u->dev) && 1029 if ((urb->pipe == u->pipe) && (urb->dev == u->dev) &&
1030 (u->status == -EINPROGRESS) && (u != urb)) { 1030 (u->status == -EINPROGRESS) && (u != urb)) {
1031 if (!last_urb) 1031 if (!last_urb)
@@ -1092,7 +1092,7 @@ static int uhci_submit_isochronous(struct uhci_hcd *uhci, struct urb *urb)
1092 return -ENOMEM; 1092 return -ENOMEM;
1093 1093
1094 uhci_add_td_to_urb(urb, td); 1094 uhci_add_td_to_urb(urb, td);
1095 uhci_fill_td(td, status, destination | uhci_explen(urb->iso_frame_desc[i].length - 1), 1095 uhci_fill_td(td, status, destination | uhci_explen(urb->iso_frame_desc[i].length),
1096 urb->transfer_dma + urb->iso_frame_desc[i].offset); 1096 urb->transfer_dma + urb->iso_frame_desc[i].offset);
1097 1097
1098 if (i + 1 >= urb->number_of_packets) 1098 if (i + 1 >= urb->number_of_packets)
@@ -1355,7 +1355,7 @@ static void uhci_unlink_generic(struct uhci_hcd *uhci, struct urb *urb)
1355 1355
1356 uhci_delete_queued_urb(uhci, urb); 1356 uhci_delete_queued_urb(uhci, urb);
1357 1357
1358 /* The interrupt loop will reclaim the QH's */ 1358 /* The interrupt loop will reclaim the QHs */
1359 uhci_remove_qh(uhci, urbp->qh); 1359 uhci_remove_qh(uhci, urbp->qh);
1360 urbp->qh = NULL; 1360 urbp->qh = NULL;
1361} 1361}
@@ -1413,7 +1413,7 @@ static int uhci_fsbr_timeout(struct uhci_hcd *uhci, struct urb *urb)
1413 list_for_each_entry(td, head, list) { 1413 list_for_each_entry(td, head, list) {
1414 /* 1414 /*
1415 * Make sure we don't do the last one (since it'll have the 1415 * Make sure we don't do the last one (since it'll have the
1416 * TERM bit set) as well as we skip every so many TD's to 1416 * TERM bit set) as well as we skip every so many TDs to
1417 * make sure it doesn't hog the bandwidth 1417 * make sure it doesn't hog the bandwidth
1418 */ 1418 */
1419 if (td->list.next != head && (count % DEPTH_INTERVAL) == 1419 if (td->list.next != head && (count % DEPTH_INTERVAL) ==
diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 1d973bcf56aa..049871145d63 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -962,7 +962,6 @@ MODULE_DEVICE_TABLE (usb, mdc800_table);
962 */ 962 */
963static struct usb_driver mdc800_usb_driver = 963static struct usb_driver mdc800_usb_driver =
964{ 964{
965 .owner = THIS_MODULE,
966 .name = "mdc800", 965 .name = "mdc800",
967 .probe = mdc800_usb_probe, 966 .probe = mdc800_usb_probe,
968 .disconnect = mdc800_usb_disconnect, 967 .disconnect = mdc800_usb_disconnect,
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 950543aa5ac7..458f2acdeb0a 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -160,7 +160,6 @@ static void mts_usb_disconnect(struct usb_interface *intf);
160static struct usb_device_id mts_usb_ids []; 160static struct usb_device_id mts_usb_ids [];
161 161
162static struct usb_driver mts_usb_driver = { 162static struct usb_driver mts_usb_driver = {
163 .owner = THIS_MODULE,
164 .name = "microtekX6", 163 .name = "microtekX6",
165 .probe = mts_usb_probe, 164 .probe = mts_usb_probe,
166 .disconnect = mts_usb_disconnect, 165 .disconnect = mts_usb_disconnect,
diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
index 1e53934907c0..509dd0a04c54 100644
--- a/drivers/usb/input/Kconfig
+++ b/drivers/usb/input/Kconfig
@@ -273,6 +273,20 @@ config USB_ATI_REMOTE
273 To compile this driver as a module, choose M here: the module will be 273 To compile this driver as a module, choose M here: the module will be
274 called ati_remote. 274 called ati_remote.
275 275
276config USB_ATI_REMOTE2
277 tristate "ATI / Philips USB RF remote control"
278 depends on USB && INPUT
279 ---help---
280 Say Y here if you want to use an ATI or Philips USB RF remote control.
281 These are RF remotes with USB receivers.
282 ATI Remote Wonder II comes with some ATI's All-In-Wonder video cards
283 and is also available as a separate product.
284 This driver provides mouse pointer, left and right mouse buttons,
285 and maps all the other remote buttons to keypress events.
286
287 To compile this driver as a module, choose M here: the module will be
288 called ati_remote2.
289
276config USB_KEYSPAN_REMOTE 290config USB_KEYSPAN_REMOTE
277 tristate "Keyspan DMR USB remote control (EXPERIMENTAL)" 291 tristate "Keyspan DMR USB remote control (EXPERIMENTAL)"
278 depends on USB && INPUT && EXPERIMENTAL 292 depends on USB && INPUT && EXPERIMENTAL
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 07cb17db42fc..d512d9f488fe 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -28,6 +28,7 @@ endif
28 28
29obj-$(CONFIG_USB_AIPTEK) += aiptek.o 29obj-$(CONFIG_USB_AIPTEK) += aiptek.o
30obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o 30obj-$(CONFIG_USB_ATI_REMOTE) += ati_remote.o
31obj-$(CONFIG_USB_ATI_REMOTE2) += ati_remote2.o
31obj-$(CONFIG_USB_HID) += usbhid.o 32obj-$(CONFIG_USB_HID) += usbhid.o
32obj-$(CONFIG_USB_KBD) += usbkbd.o 33obj-$(CONFIG_USB_KBD) += usbkbd.o
33obj-$(CONFIG_USB_KBTAB) += kbtab.o 34obj-$(CONFIG_USB_KBTAB) += kbtab.o
diff --git a/drivers/usb/input/acecad.c b/drivers/usb/input/acecad.c
index a32558b4048e..df29b8078b54 100644
--- a/drivers/usb/input/acecad.c
+++ b/drivers/usb/input/acecad.c
@@ -261,7 +261,6 @@ static struct usb_device_id usb_acecad_id_table [] = {
261MODULE_DEVICE_TABLE(usb, usb_acecad_id_table); 261MODULE_DEVICE_TABLE(usb, usb_acecad_id_table);
262 262
263static struct usb_driver usb_acecad_driver = { 263static struct usb_driver usb_acecad_driver = {
264 .owner = THIS_MODULE,
265 .name = "usb_acecad", 264 .name = "usb_acecad",
266 .probe = usb_acecad_probe, 265 .probe = usb_acecad_probe,
267 .disconnect = usb_acecad_disconnect, 266 .disconnect = usb_acecad_disconnect,
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 1c3b472a3bca..a6693b0d1c4c 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -338,7 +338,7 @@ struct aiptek {
338 * the bitmap which comes from the tablet. This hides the 338 * the bitmap which comes from the tablet. This hides the
339 * issue that the F_keys are not sequentially numbered. 339 * issue that the F_keys are not sequentially numbered.
340 */ 340 */
341static int macroKeyEvents[] = { 341static const int macroKeyEvents[] = {
342 KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, 342 KEY_ESC, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5,
343 KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, 343 KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11,
344 KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17, 344 KEY_F12, KEY_F13, KEY_F14, KEY_F15, KEY_F16, KEY_F17,
@@ -2093,7 +2093,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2093 /* Programming the tablet macro keys needs to be done with a for loop 2093 /* Programming the tablet macro keys needs to be done with a for loop
2094 * as the keycodes are discontiguous. 2094 * as the keycodes are discontiguous.
2095 */ 2095 */
2096 for (i = 0; i < sizeof(macroKeyEvents) / sizeof(macroKeyEvents[0]); ++i) 2096 for (i = 0; i < ARRAY_SIZE(macroKeyEvents); ++i)
2097 set_bit(macroKeyEvents[i], inputdev->keybit); 2097 set_bit(macroKeyEvents[i], inputdev->keybit);
2098 2098
2099 /* 2099 /*
@@ -2103,7 +2103,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2103 * values. 2103 * values.
2104 */ 2104 */
2105 input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0); 2105 input_set_abs_params(inputdev, ABS_X, 0, 2999, 0, 0);
2106 input_set_abs_params(inputdev, ABS_X, 0, 2249, 0, 0); 2106 input_set_abs_params(inputdev, ABS_Y, 0, 2249, 0, 0);
2107 input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0); 2107 input_set_abs_params(inputdev, ABS_PRESSURE, 0, 511, 0, 0);
2108 input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); 2108 input_set_abs_params(inputdev, ABS_TILT_X, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);
2109 input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); 2109 input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0);
@@ -2135,7 +2135,7 @@ aiptek_probe(struct usb_interface *intf, const struct usb_device_id *id)
2135 * not an error :-) 2135 * not an error :-)
2136 */ 2136 */
2137 2137
2138 for (i = 0; i < sizeof(speeds) / sizeof(speeds[0]); ++i) { 2138 for (i = 0; i < ARRAY_SIZE(speeds); ++i) {
2139 aiptek->curSetting.programmableDelay = speeds[i]; 2139 aiptek->curSetting.programmableDelay = speeds[i];
2140 (void)aiptek_program_tablet(aiptek); 2140 (void)aiptek_program_tablet(aiptek);
2141 if (aiptek->inputdev->absmax[ABS_X] > 0) { 2141 if (aiptek->inputdev->absmax[ABS_X] > 0) {
@@ -2190,7 +2190,6 @@ fail1: input_free_device(inputdev);
2190static void aiptek_disconnect(struct usb_interface *intf); 2190static void aiptek_disconnect(struct usb_interface *intf);
2191 2191
2192static struct usb_driver aiptek_driver = { 2192static struct usb_driver aiptek_driver = {
2193 .owner = THIS_MODULE,
2194 .name = "aiptek", 2193 .name = "aiptek",
2195 .probe = aiptek_probe, 2194 .probe = aiptek_probe,
2196 .disconnect = aiptek_disconnect, 2195 .disconnect = aiptek_disconnect,
diff --git a/drivers/usb/input/appletouch.c b/drivers/usb/input/appletouch.c
index 15840db092a5..1949b54f41f2 100644
--- a/drivers/usb/input/appletouch.c
+++ b/drivers/usb/input/appletouch.c
@@ -452,7 +452,6 @@ static int atp_resume(struct usb_interface *iface)
452} 452}
453 453
454static struct usb_driver atp_driver = { 454static struct usb_driver atp_driver = {
455 .owner = THIS_MODULE,
456 .name = "appletouch", 455 .name = "appletouch",
457 .probe = atp_probe, 456 .probe = atp_probe,
458 .disconnect = atp_disconnect, 457 .disconnect = atp_disconnect,
diff --git a/drivers/usb/input/ati_remote.c b/drivers/usb/input/ati_remote.c
index 9a2a47db9494..f7bdc506e613 100644
--- a/drivers/usb/input/ati_remote.c
+++ b/drivers/usb/input/ati_remote.c
@@ -96,6 +96,7 @@
96#include <linux/usb.h> 96#include <linux/usb.h>
97#include <linux/usb_input.h> 97#include <linux/usb_input.h>
98#include <linux/wait.h> 98#include <linux/wait.h>
99#include <linux/jiffies.h>
99 100
100/* 101/*
101 * Module and Version Information, Module Parameters 102 * Module and Version Information, Module Parameters
@@ -146,7 +147,7 @@ static char init1[] = { 0x01, 0x00, 0x20, 0x14 };
146static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 }; 147static char init2[] = { 0x01, 0x00, 0x20, 0x14, 0x20, 0x20, 0x20 };
147 148
148/* Acceleration curve for directional control pad */ 149/* Acceleration curve for directional control pad */
149static char accel[] = { 1, 2, 4, 6, 9, 13, 20 }; 150static const char accel[] = { 1, 2, 4, 6, 9, 13, 20 };
150 151
151/* Duplicate event filtering time. 152/* Duplicate event filtering time.
152 * Sequential, identical KIND_FILTERED inputs with less than 153 * Sequential, identical KIND_FILTERED inputs with less than
@@ -197,7 +198,7 @@ struct ati_remote {
197#define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/ 198#define KIND_ACCEL 7 /* Directional keypad - left, right, up, down.*/
198 199
199/* Translation table from hardware messages to input events. */ 200/* Translation table from hardware messages to input events. */
200static struct { 201static const struct {
201 short kind; 202 short kind;
202 unsigned char data1, data2; 203 unsigned char data1, data2;
203 int type; 204 int type;
@@ -295,7 +296,6 @@ static void ati_remote_disconnect (struct usb_interface *interface);
295 296
296/* usb specific object to register with the usb subsystem */ 297/* usb specific object to register with the usb subsystem */
297static struct usb_driver ati_remote_driver = { 298static struct usb_driver ati_remote_driver = {
298 .owner = THIS_MODULE,
299 .name = "ati_remote", 299 .name = "ati_remote",
300 .probe = ati_remote_probe, 300 .probe = ati_remote_probe,
301 .disconnect = ati_remote_disconnect, 301 .disconnect = ati_remote_disconnect,
@@ -472,7 +472,7 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
472 /* Filter duplicate events which happen "too close" together. */ 472 /* Filter duplicate events which happen "too close" together. */
473 if ((ati_remote->old_data[0] == data[1]) && 473 if ((ati_remote->old_data[0] == data[1]) &&
474 (ati_remote->old_data[1] == data[2]) && 474 (ati_remote->old_data[1] == data[2]) &&
475 ((ati_remote->old_jiffies + FILTER_TIME) > jiffies)) { 475 time_before(jiffies, ati_remote->old_jiffies + FILTER_TIME)) {
476 ati_remote->repeat_count++; 476 ati_remote->repeat_count++;
477 } else { 477 } else {
478 ati_remote->repeat_count = 0; 478 ati_remote->repeat_count = 0;
@@ -507,16 +507,16 @@ static void ati_remote_input_report(struct urb *urb, struct pt_regs *regs)
507 * pad down, so we increase acceleration, ramping up over two seconds to 507 * pad down, so we increase acceleration, ramping up over two seconds to
508 * a maximum speed. The acceleration curve is #defined above. 508 * a maximum speed. The acceleration curve is #defined above.
509 */ 509 */
510 if ((jiffies - ati_remote->old_jiffies) > (HZ >> 2)) { 510 if (time_after(jiffies, ati_remote->old_jiffies + (HZ >> 2))) {
511 acc = 1; 511 acc = 1;
512 ati_remote->acc_jiffies = jiffies; 512 ati_remote->acc_jiffies = jiffies;
513 } 513 }
514 else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 3)) acc = accel[0]; 514 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 3))) acc = accel[0];
515 else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 2)) acc = accel[1]; 515 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 2))) acc = accel[1];
516 else if ((jiffies - ati_remote->acc_jiffies) < (HZ >> 1)) acc = accel[2]; 516 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ >> 1))) acc = accel[2];
517 else if ((jiffies - ati_remote->acc_jiffies) < HZ ) acc = accel[3]; 517 else if (time_before(jiffies, ati_remote->acc_jiffies + HZ)) acc = accel[3];
518 else if ((jiffies - ati_remote->acc_jiffies) < HZ+(HZ>>1)) acc = accel[4]; 518 else if (time_before(jiffies, ati_remote->acc_jiffies + HZ+(HZ>>1))) acc = accel[4];
519 else if ((jiffies - ati_remote->acc_jiffies) < (HZ << 1)) acc = accel[5]; 519 else if (time_before(jiffies, ati_remote->acc_jiffies + (HZ << 1))) acc = accel[5];
520 else acc = accel[6]; 520 else acc = accel[6];
521 521
522 input_regs(dev, regs); 522 input_regs(dev, regs);
diff --git a/drivers/usb/input/ati_remote2.c b/drivers/usb/input/ati_remote2.c
new file mode 100644
index 000000000000..ab1a1ae24be9
--- /dev/null
+++ b/drivers/usb/input/ati_remote2.c
@@ -0,0 +1,477 @@
1/*
2 * ati_remote2 - ATI/Philips USB RF remote driver
3 *
4 * Copyright (C) 2005 Ville Syrjala <syrjala@sci.fi>
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
8 * as published by the Free Software Foundation.
9 */
10
11#include <linux/usb_input.h>
12
13#define DRIVER_DESC "ATI/Philips USB RF remote driver"
14#define DRIVER_VERSION "0.1"
15
16MODULE_DESCRIPTION(DRIVER_DESC);
17MODULE_VERSION(DRIVER_VERSION);
18MODULE_AUTHOR("Ville Syrjala <syrjala@sci.fi>");
19MODULE_LICENSE("GPL");
20
21static unsigned int mode_mask = 0x1F;
22module_param(mode_mask, uint, 0644);
23MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>");
24
25static struct usb_device_id ati_remote2_id_table[] = {
26 { USB_DEVICE(0x0471, 0x0602) }, /* ATI Remote Wonder II */
27 { }
28};
29MODULE_DEVICE_TABLE(usb, ati_remote2_id_table);
30
31static struct {
32 int hw_code;
33 int key_code;
34} ati_remote2_key_table[] = {
35 { 0x00, KEY_0 },
36 { 0x01, KEY_1 },
37 { 0x02, KEY_2 },
38 { 0x03, KEY_3 },
39 { 0x04, KEY_4 },
40 { 0x05, KEY_5 },
41 { 0x06, KEY_6 },
42 { 0x07, KEY_7 },
43 { 0x08, KEY_8 },
44 { 0x09, KEY_9 },
45 { 0x0c, KEY_POWER },
46 { 0x0d, KEY_MUTE },
47 { 0x10, KEY_VOLUMEUP },
48 { 0x11, KEY_VOLUMEDOWN },
49 { 0x20, KEY_CHANNELUP },
50 { 0x21, KEY_CHANNELDOWN },
51 { 0x28, KEY_FORWARD },
52 { 0x29, KEY_REWIND },
53 { 0x2c, KEY_PLAY },
54 { 0x30, KEY_PAUSE },
55 { 0x31, KEY_STOP },
56 { 0x37, KEY_RECORD },
57 { 0x38, KEY_DVD },
58 { 0x39, KEY_TV },
59 { 0x54, KEY_MENU },
60 { 0x58, KEY_UP },
61 { 0x59, KEY_DOWN },
62 { 0x5a, KEY_LEFT },
63 { 0x5b, KEY_RIGHT },
64 { 0x5c, KEY_OK },
65 { 0x78, KEY_A },
66 { 0x79, KEY_B },
67 { 0x7a, KEY_C },
68 { 0x7b, KEY_D },
69 { 0x7c, KEY_E },
70 { 0x7d, KEY_F },
71 { 0x82, KEY_ENTER },
72 { 0x8e, KEY_VENDOR },
73 { 0x96, KEY_COFFEE },
74 { 0xa9, BTN_LEFT },
75 { 0xaa, BTN_RIGHT },
76 { 0xbe, KEY_QUESTION },
77 { 0xd5, KEY_FRONT },
78 { 0xd0, KEY_EDIT },
79 { 0xf9, KEY_INFO },
80 { (0x00 << 8) | 0x3f, KEY_PROG1 },
81 { (0x01 << 8) | 0x3f, KEY_PROG2 },
82 { (0x02 << 8) | 0x3f, KEY_PROG3 },
83 { (0x03 << 8) | 0x3f, KEY_PROG4 },
84 { (0x04 << 8) | 0x3f, KEY_PC },
85 { 0, KEY_RESERVED }
86};
87
88struct ati_remote2 {
89 struct input_dev *idev;
90 struct usb_device *udev;
91
92 struct usb_interface *intf[2];
93 struct usb_endpoint_descriptor *ep[2];
94 struct urb *urb[2];
95 void *buf[2];
96 dma_addr_t buf_dma[2];
97
98 unsigned long jiffies;
99 int mode;
100
101 char name[64];
102 char phys[64];
103};
104
105static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id);
106static void ati_remote2_disconnect(struct usb_interface *interface);
107
108static struct usb_driver ati_remote2_driver = {
109 .name = "ati_remote2",
110 .probe = ati_remote2_probe,
111 .disconnect = ati_remote2_disconnect,
112 .id_table = ati_remote2_id_table,
113};
114
115static int ati_remote2_open(struct input_dev *idev)
116{
117 struct ati_remote2 *ar2 = idev->private;
118 int r;
119
120 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL);
121 if (r) {
122 dev_err(&ar2->intf[0]->dev,
123 "%s: usb_submit_urb() = %d\n", __FUNCTION__, r);
124 return r;
125 }
126 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL);
127 if (r) {
128 usb_kill_urb(ar2->urb[0]);
129 dev_err(&ar2->intf[1]->dev,
130 "%s: usb_submit_urb() = %d\n", __FUNCTION__, r);
131 return r;
132 }
133
134 return 0;
135}
136
137static void ati_remote2_close(struct input_dev *idev)
138{
139 struct ati_remote2 *ar2 = idev->private;
140
141 usb_kill_urb(ar2->urb[0]);
142 usb_kill_urb(ar2->urb[1]);
143}
144
145static void ati_remote2_input_mouse(struct ati_remote2 *ar2, struct pt_regs *regs)
146{
147 struct input_dev *idev = ar2->idev;
148 u8 *data = ar2->buf[0];
149
150 if (data[0] > 4) {
151 dev_err(&ar2->intf[0]->dev,
152 "Unknown mode byte (%02x %02x %02x %02x)\n",
153 data[3], data[2], data[1], data[0]);
154 return;
155 }
156
157 if (!((1 << data[0]) & mode_mask))
158 return;
159
160 input_regs(idev, regs);
161 input_event(idev, EV_REL, REL_X, (s8) data[1]);
162 input_event(idev, EV_REL, REL_Y, (s8) data[2]);
163 input_sync(idev);
164}
165
166static int ati_remote2_lookup(unsigned int hw_code)
167{
168 int i;
169
170 for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++)
171 if (ati_remote2_key_table[i].hw_code == hw_code)
172 return i;
173
174 return -1;
175}
176
177static void ati_remote2_input_key(struct ati_remote2 *ar2, struct pt_regs *regs)
178{
179 struct input_dev *idev = ar2->idev;
180 u8 *data = ar2->buf[1];
181 int hw_code, index;
182
183 if (data[0] > 4) {
184 dev_err(&ar2->intf[1]->dev,
185 "Unknown mode byte (%02x %02x %02x %02x)\n",
186 data[3], data[2], data[1], data[0]);
187 return;
188 }
189
190 hw_code = data[2];
191 /*
192 * Mode keys (AUX1-AUX4, PC) all generate the same code byte.
193 * Use the mode byte to figure out which one was pressed.
194 */
195 if (hw_code == 0x3f) {
196 /*
197 * For some incomprehensible reason the mouse pad generates
198 * events which look identical to the events from the last
199 * pressed mode key. Naturally we don't want to generate key
200 * events for the mouse pad so we filter out any subsequent
201 * events from the same mode key.
202 */
203 if (ar2->mode == data[0])
204 return;
205
206 if (data[1] == 0)
207 ar2->mode = data[0];
208
209 hw_code |= data[0] << 8;
210 }
211
212 if (!((1 << data[0]) & mode_mask))
213 return;
214
215 index = ati_remote2_lookup(hw_code);
216 if (index < 0) {
217 dev_err(&ar2->intf[1]->dev,
218 "Unknown code byte (%02x %02x %02x %02x)\n",
219 data[3], data[2], data[1], data[0]);
220 return;
221 }
222
223 switch (data[1]) {
224 case 0: /* release */
225 break;
226 case 1: /* press */
227 ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_DELAY]);
228 break;
229 case 2: /* repeat */
230
231 /* No repeat for mouse buttons. */
232 if (ati_remote2_key_table[index].key_code == BTN_LEFT ||
233 ati_remote2_key_table[index].key_code == BTN_RIGHT)
234 return;
235
236 if (!time_after_eq(jiffies, ar2->jiffies))
237 return;
238
239 ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_PERIOD]);
240 break;
241 default:
242 dev_err(&ar2->intf[1]->dev,
243 "Unknown state byte (%02x %02x %02x %02x)\n",
244 data[3], data[2], data[1], data[0]);
245 return;
246 }
247
248 input_regs(idev, regs);
249 input_event(idev, EV_KEY, ati_remote2_key_table[index].key_code, data[1]);
250 input_sync(idev);
251}
252
253static void ati_remote2_complete_mouse(struct urb *urb, struct pt_regs *regs)
254{
255 struct ati_remote2 *ar2 = urb->context;
256 int r;
257
258 switch (urb->status) {
259 case 0:
260 ati_remote2_input_mouse(ar2, regs);
261 break;
262 case -ENOENT:
263 case -EILSEQ:
264 case -ECONNRESET:
265 case -ESHUTDOWN:
266 dev_dbg(&ar2->intf[0]->dev,
267 "%s(): urb status = %d\n", __FUNCTION__, urb->status);
268 return;
269 default:
270 dev_err(&ar2->intf[0]->dev,
271 "%s(): urb status = %d\n", __FUNCTION__, urb->status);
272 }
273
274 r = usb_submit_urb(urb, GFP_ATOMIC);
275 if (r)
276 dev_err(&ar2->intf[0]->dev,
277 "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r);
278}
279
280static void ati_remote2_complete_key(struct urb *urb, struct pt_regs *regs)
281{
282 struct ati_remote2 *ar2 = urb->context;
283 int r;
284
285 switch (urb->status) {
286 case 0:
287 ati_remote2_input_key(ar2, regs);
288 break;
289 case -ENOENT:
290 case -EILSEQ:
291 case -ECONNRESET:
292 case -ESHUTDOWN:
293 dev_dbg(&ar2->intf[1]->dev,
294 "%s(): urb status = %d\n", __FUNCTION__, urb->status);
295 return;
296 default:
297 dev_err(&ar2->intf[1]->dev,
298 "%s(): urb status = %d\n", __FUNCTION__, urb->status);
299 }
300
301 r = usb_submit_urb(urb, GFP_ATOMIC);
302 if (r)
303 dev_err(&ar2->intf[1]->dev,
304 "%s(): usb_submit_urb() = %d\n", __FUNCTION__, r);
305}
306
307static int ati_remote2_input_init(struct ati_remote2 *ar2)
308{
309 struct input_dev *idev;
310 int i;
311
312 idev = input_allocate_device();
313 if (!idev)
314 return -ENOMEM;
315
316 ar2->idev = idev;
317 idev->private = ar2;
318
319 idev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_REL);
320 idev->keybit[LONG(BTN_MOUSE)] = BIT(BTN_LEFT) | BIT(BTN_RIGHT);
321 idev->relbit[0] = BIT(REL_X) | BIT(REL_Y);
322 for (i = 0; ati_remote2_key_table[i].key_code != KEY_RESERVED; i++)
323 set_bit(ati_remote2_key_table[i].key_code, idev->keybit);
324
325 idev->rep[REP_DELAY] = 250;
326 idev->rep[REP_PERIOD] = 33;
327
328 idev->open = ati_remote2_open;
329 idev->close = ati_remote2_close;
330
331 idev->name = ar2->name;
332 idev->phys = ar2->phys;
333
334 usb_to_input_id(ar2->udev, &idev->id);
335 idev->cdev.dev = &ar2->udev->dev;
336
337 i = input_register_device(idev);
338 if (i)
339 input_free_device(idev);
340
341 return i;
342}
343
344static int ati_remote2_urb_init(struct ati_remote2 *ar2)
345{
346 struct usb_device *udev = ar2->udev;
347 int i, pipe, maxp;
348
349 for (i = 0; i < 2; i++) {
350 ar2->buf[i] = usb_buffer_alloc(udev, 4, GFP_KERNEL, &ar2->buf_dma[i]);
351 if (!ar2->buf[i])
352 return -ENOMEM;
353
354 ar2->urb[i] = usb_alloc_urb(0, GFP_KERNEL);
355 if (!ar2->urb[i])
356 return -ENOMEM;
357
358 pipe = usb_rcvintpipe(udev, ar2->ep[i]->bEndpointAddress);
359 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
360 maxp = maxp > 4 ? 4 : maxp;
361
362 usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
363 i ? ati_remote2_complete_key : ati_remote2_complete_mouse,
364 ar2, ar2->ep[i]->bInterval);
365 ar2->urb[i]->transfer_dma = ar2->buf_dma[i];
366 ar2->urb[i]->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
367 }
368
369 return 0;
370}
371
372static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2)
373{
374 int i;
375
376 for (i = 0; i < 2; i++) {
377 if (ar2->urb[i])
378 usb_free_urb(ar2->urb[i]);
379
380 if (ar2->buf[i])
381 usb_buffer_free(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]);
382 }
383}
384
385static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id)
386{
387 struct usb_device *udev = interface_to_usbdev(interface);
388 struct usb_host_interface *alt = interface->cur_altsetting;
389 struct ati_remote2 *ar2;
390 int r;
391
392 if (alt->desc.bInterfaceNumber)
393 return -ENODEV;
394
395 ar2 = kzalloc(sizeof (struct ati_remote2), GFP_KERNEL);
396 if (!ar2)
397 return -ENOMEM;
398
399 ar2->udev = udev;
400
401 ar2->intf[0] = interface;
402 ar2->ep[0] = &alt->endpoint[0].desc;
403
404 ar2->intf[1] = usb_ifnum_to_if(udev, 1);
405 r = usb_driver_claim_interface(&ati_remote2_driver, ar2->intf[1], ar2);
406 if (r)
407 goto fail1;
408 alt = ar2->intf[1]->cur_altsetting;
409 ar2->ep[1] = &alt->endpoint[0].desc;
410
411 r = ati_remote2_urb_init(ar2);
412 if (r)
413 goto fail2;
414
415 usb_make_path(udev, ar2->phys, sizeof(ar2->phys));
416 strlcat(ar2->phys, "/input0", sizeof(ar2->phys));
417
418 strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name));
419
420 r = ati_remote2_input_init(ar2);
421 if (r)
422 goto fail2;
423
424 usb_set_intfdata(interface, ar2);
425
426 return 0;
427
428 fail2:
429 ati_remote2_urb_cleanup(ar2);
430
431 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
432 fail1:
433 kfree(ar2);
434
435 return r;
436}
437
438static void ati_remote2_disconnect(struct usb_interface *interface)
439{
440 struct ati_remote2 *ar2;
441 struct usb_host_interface *alt = interface->cur_altsetting;
442
443 if (alt->desc.bInterfaceNumber)
444 return;
445
446 ar2 = usb_get_intfdata(interface);
447 usb_set_intfdata(interface, NULL);
448
449 input_unregister_device(ar2->idev);
450
451 ati_remote2_urb_cleanup(ar2);
452
453 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
454
455 kfree(ar2);
456}
457
458static int __init ati_remote2_init(void)
459{
460 int r;
461
462 r = usb_register(&ati_remote2_driver);
463 if (r)
464 printk(KERN_ERR "ati_remote2: usb_register() = %d\n", r);
465 else
466 printk(KERN_INFO "ati_remote2: " DRIVER_DESC " " DRIVER_VERSION "\n");
467
468 return r;
469}
470
471static void __exit ati_remote2_exit(void)
472{
473 usb_deregister(&ati_remote2_driver);
474}
475
476module_init(ati_remote2_init);
477module_exit(ati_remote2_exit);
diff --git a/drivers/usb/input/fixp-arith.h b/drivers/usb/input/fixp-arith.h
index 26ca5b890a61..b44d398de071 100644
--- a/drivers/usb/input/fixp-arith.h
+++ b/drivers/usb/input/fixp-arith.h
@@ -38,7 +38,7 @@ typedef s16 fixp_t;
38#define FRAC_MASK ((1<<FRAC_N)-1) 38#define FRAC_MASK ((1<<FRAC_N)-1)
39 39
40// Not to be used directly. Use fixp_{cos,sin} 40// Not to be used directly. Use fixp_{cos,sin}
41static fixp_t cos_table[45] = { 41static const fixp_t cos_table[45] = {
42 0x0100, 0x00FF, 0x00FF, 0x00FE, 0x00FD, 0x00FC, 0x00FA, 0x00F8, 42 0x0100, 0x00FF, 0x00FF, 0x00FE, 0x00FD, 0x00FC, 0x00FA, 0x00F8,
43 0x00F6, 0x00F3, 0x00F0, 0x00ED, 0x00E9, 0x00E6, 0x00E2, 0x00DD, 43 0x00F6, 0x00F3, 0x00F0, 0x00ED, 0x00E9, 0x00E6, 0x00E2, 0x00DD,
44 0x00D9, 0x00D4, 0x00CF, 0x00C9, 0x00C4, 0x00BE, 0x00B8, 0x00B1, 44 0x00D9, 0x00D4, 0x00CF, 0x00C9, 0x00C4, 0x00BE, 0x00B8, 0x00B1,
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 45f3130fadea..5f52979af1c7 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -893,8 +893,10 @@ static int hid_input_report(int type, struct urb *urb, int interrupt, struct pt_
893 893
894 size = ((report->size - 1) >> 3) + 1; 894 size = ((report->size - 1) >> 3) + 1;
895 895
896 if (len < size) 896 if (len < size) {
897 dbg("report %d is too short, (%d < %d)", report->id, len, size); 897 dbg("report %d is too short, (%d < %d)", report->id, len, size);
898 memset(data + len, 0, size - len);
899 }
898 900
899 if (hid->claimed & HID_CLAIMED_HIDDEV) 901 if (hid->claimed & HID_CLAIMED_HIDDEV)
900 hiddev_report_event(hid, report); 902 hiddev_report_event(hid, report);
@@ -1452,7 +1454,7 @@ void hid_init_reports(struct hid_device *hid)
1452 * Alphabetically sorted blacklist by quirk type. 1454 * Alphabetically sorted blacklist by quirk type.
1453 */ 1455 */
1454 1456
1455static struct hid_blacklist { 1457static const struct hid_blacklist {
1456 __u16 idVendor; 1458 __u16 idVendor;
1457 __u16 idProduct; 1459 __u16 idProduct;
1458 unsigned quirks; 1460 unsigned quirks;
@@ -1928,7 +1930,6 @@ static struct usb_device_id hid_usb_ids [] = {
1928MODULE_DEVICE_TABLE (usb, hid_usb_ids); 1930MODULE_DEVICE_TABLE (usb, hid_usb_ids);
1929 1931
1930static struct usb_driver hid_driver = { 1932static struct usb_driver hid_driver = {
1931 .owner = THIS_MODULE,
1932 .name = "usbhid", 1933 .name = "usbhid",
1933 .probe = hid_probe, 1934 .probe = hid_probe,
1934 .disconnect = hid_disconnect, 1935 .disconnect = hid_disconnect,
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 9ff25eb520a6..192a03b28971 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -39,7 +39,7 @@
39 39
40#define unk KEY_UNKNOWN 40#define unk KEY_UNKNOWN
41 41
42static unsigned char hid_keyboard[256] = { 42static const unsigned char hid_keyboard[256] = {
43 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 43 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
44 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3, 44 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
45 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26, 45 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
@@ -58,7 +58,7 @@ static unsigned char hid_keyboard[256] = {
58 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk 58 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk
59}; 59};
60 60
61static struct { 61static const struct {
62 __s32 x; 62 __s32 x;
63 __s32 y; 63 __s32 y;
64} hid_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}}; 64} hid_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
@@ -137,6 +137,7 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
137 switch (usage->hid & 0xffff) { 137 switch (usage->hid & 0xffff) {
138 case 0xba: map_abs(ABS_RUDDER); break; 138 case 0xba: map_abs(ABS_RUDDER); break;
139 case 0xbb: map_abs(ABS_THROTTLE); break; 139 case 0xbb: map_abs(ABS_THROTTLE); break;
140 default: goto ignore;
140 } 141 }
141 break; 142 break;
142 143
diff --git a/drivers/usb/input/hiddev.c b/drivers/usb/input/hiddev.c
index 440377c7a0da..4dff8473553d 100644
--- a/drivers/usb/input/hiddev.c
+++ b/drivers/usb/input/hiddev.c
@@ -826,7 +826,6 @@ static int hiddev_usbd_probe(struct usb_interface *intf,
826 826
827 827
828static /* const */ struct usb_driver hiddev_driver = { 828static /* const */ struct usb_driver hiddev_driver = {
829 .owner = THIS_MODULE,
830 .name = "hiddev", 829 .name = "hiddev",
831 .probe = hiddev_usbd_probe, 830 .probe = hiddev_usbd_probe,
832}; 831};
diff --git a/drivers/usb/input/itmtouch.c b/drivers/usb/input/itmtouch.c
index 4a50acb39d29..7618ae5c104f 100644
--- a/drivers/usb/input/itmtouch.c
+++ b/drivers/usb/input/itmtouch.c
@@ -250,7 +250,6 @@ static void itmtouch_disconnect(struct usb_interface *intf)
250MODULE_DEVICE_TABLE(usb, itmtouch_ids); 250MODULE_DEVICE_TABLE(usb, itmtouch_ids);
251 251
252static struct usb_driver itmtouch_driver = { 252static struct usb_driver itmtouch_driver = {
253 .owner = THIS_MODULE,
254 .name = "itmtouch", 253 .name = "itmtouch",
255 .probe = itmtouch_probe, 254 .probe = itmtouch_probe,
256 .disconnect = itmtouch_disconnect, 255 .disconnect = itmtouch_disconnect,
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index a248664b5d1d..f6d5cead542b 100644
--- a/drivers/usb/input/kbtab.c
+++ b/drivers/usb/input/kbtab.c
@@ -159,7 +159,7 @@ static int kbtab_probe(struct usb_interface *intf, const struct usb_device_id *i
159 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH); 159 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH);
160 input_dev->mscbit[0] |= BIT(MSC_SERIAL); 160 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
161 input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0); 161 input_set_abs_params(input_dev, ABS_X, 0, 0x2000, 4, 0);
162 input_set_abs_params(input_dev, ABS_X, 0, 0x1750, 4, 0); 162 input_set_abs_params(input_dev, ABS_Y, 0, 0x1750, 4, 0);
163 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0); 163 input_set_abs_params(input_dev, ABS_PRESSURE, 0, 0xff, 0, 0);
164 164
165 endpoint = &intf->cur_altsetting->endpoint[0].desc; 165 endpoint = &intf->cur_altsetting->endpoint[0].desc;
@@ -197,7 +197,6 @@ static void kbtab_disconnect(struct usb_interface *intf)
197} 197}
198 198
199static struct usb_driver kbtab_driver = { 199static struct usb_driver kbtab_driver = {
200 .owner = THIS_MODULE,
201 .name = "kbtab", 200 .name = "kbtab",
202 .probe = kbtab_probe, 201 .probe = kbtab_probe,
203 .disconnect = kbtab_disconnect, 202 .disconnect = kbtab_disconnect,
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index a32cfe51b77d..b4a051b549d1 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -95,7 +95,7 @@ struct usb_keyspan {
95 * Currently there are 15 and 17 button models so RESERVED codes 95 * Currently there are 15 and 17 button models so RESERVED codes
96 * are blank areas in the mapping. 96 * are blank areas in the mapping.
97 */ 97 */
98static int keyspan_key_table[] = { 98static const int keyspan_key_table[] = {
99 KEY_RESERVED, /* 0 is just a place holder. */ 99 KEY_RESERVED, /* 0 is just a place holder. */
100 KEY_RESERVED, 100 KEY_RESERVED,
101 KEY_STOP, 101 KEY_STOP,
@@ -559,7 +559,6 @@ static void keyspan_disconnect(struct usb_interface *interface)
559 */ 559 */
560static struct usb_driver keyspan_driver = 560static struct usb_driver keyspan_driver =
561{ 561{
562 .owner = THIS_MODULE,
563 .name = "keyspan_remote", 562 .name = "keyspan_remote",
564 .probe = keyspan_probe, 563 .probe = keyspan_probe,
565 .disconnect = keyspan_disconnect, 564 .disconnect = keyspan_disconnect,
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 52cc18cd247d..f018953a5485 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -310,7 +310,6 @@ static void mtouchusb_disconnect(struct usb_interface *intf)
310MODULE_DEVICE_TABLE(usb, mtouchusb_devices); 310MODULE_DEVICE_TABLE(usb, mtouchusb_devices);
311 311
312static struct usb_driver mtouchusb_driver = { 312static struct usb_driver mtouchusb_driver = {
313 .owner = THIS_MODULE,
314 .name = "mtouchusb", 313 .name = "mtouchusb",
315 .probe = mtouchusb_probe, 314 .probe = mtouchusb_probe,
316 .disconnect = mtouchusb_disconnect, 315 .disconnect = mtouchusb_disconnect,
diff --git a/drivers/usb/input/powermate.c b/drivers/usb/input/powermate.c
index b7476233ef5d..fdf0f788062c 100644
--- a/drivers/usb/input/powermate.c
+++ b/drivers/usb/input/powermate.c
@@ -441,7 +441,6 @@ static struct usb_device_id powermate_devices [] = {
441MODULE_DEVICE_TABLE (usb, powermate_devices); 441MODULE_DEVICE_TABLE (usb, powermate_devices);
442 442
443static struct usb_driver powermate_driver = { 443static struct usb_driver powermate_driver = {
444 .owner = THIS_MODULE,
445 .name = "powermate", 444 .name = "powermate",
446 .probe = powermate_probe, 445 .probe = powermate_probe,
447 .disconnect = powermate_disconnect, 446 .disconnect = powermate_disconnect,
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 7420c6b84284..3b3c7b4120a2 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -1,7 +1,7 @@
1/****************************************************************************** 1/******************************************************************************
2 * touchkitusb.c -- Driver for eGalax TouchKit USB Touchscreens 2 * touchkitusb.c -- Driver for eGalax TouchKit USB Touchscreens
3 * 3 *
4 * Copyright (C) 2004 by Daniel Ritz 4 * Copyright (C) 2004-2005 by Daniel Ritz <daniel.ritz@gmx.ch>
5 * Copyright (C) by Todd E. Johnson (mtouchusb.c) 5 * Copyright (C) by Todd E. Johnson (mtouchusb.c)
6 * 6 *
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
@@ -41,15 +41,13 @@
41#define TOUCHKIT_MAX_YC 0x07ff 41#define TOUCHKIT_MAX_YC 0x07ff
42#define TOUCHKIT_YC_FUZZ 0x0 42#define TOUCHKIT_YC_FUZZ 0x0
43#define TOUCHKIT_YC_FLAT 0x0 43#define TOUCHKIT_YC_FLAT 0x0
44#define TOUCHKIT_REPORT_DATA_SIZE 8 44#define TOUCHKIT_REPORT_DATA_SIZE 16
45 45
46#define TOUCHKIT_DOWN 0x01 46#define TOUCHKIT_DOWN 0x01
47#define TOUCHKIT_POINT_TOUCH 0x81
48#define TOUCHKIT_POINT_NOTOUCH 0x80
49 47
50#define TOUCHKIT_GET_TOUCHED(dat) ((((dat)[0]) & TOUCHKIT_DOWN) ? 1 : 0) 48#define TOUCHKIT_PKT_TYPE_MASK 0xFE
51#define TOUCHKIT_GET_X(dat) (((dat)[3] << 7) | (dat)[4]) 49#define TOUCHKIT_PKT_TYPE_REPT 0x80
52#define TOUCHKIT_GET_Y(dat) (((dat)[1] << 7) | (dat)[2]) 50#define TOUCHKIT_PKT_TYPE_DIAG 0x0A
53 51
54#define DRIVER_VERSION "v0.1" 52#define DRIVER_VERSION "v0.1"
55#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>" 53#define DRIVER_AUTHOR "Daniel Ritz <daniel.ritz@gmx.ch>"
@@ -62,6 +60,8 @@ MODULE_PARM_DESC(swap_xy, "If set X and Y axes are swapped.");
62struct touchkit_usb { 60struct touchkit_usb {
63 unsigned char *data; 61 unsigned char *data;
64 dma_addr_t data_dma; 62 dma_addr_t data_dma;
63 char buffer[TOUCHKIT_REPORT_DATA_SIZE];
64 int buf_len;
65 struct urb *irq; 65 struct urb *irq;
66 struct usb_device *udev; 66 struct usb_device *udev;
67 struct input_dev *input; 67 struct input_dev *input;
@@ -77,11 +77,128 @@ static struct usb_device_id touchkit_devices[] = {
77 {} 77 {}
78}; 78};
79 79
80/* helpers to read the data */
81static inline int touchkit_get_touched(char *data)
82{
83 return (data[0] & TOUCHKIT_DOWN) ? 1 : 0;
84}
85
86static inline int touchkit_get_x(char *data)
87{
88 return ((data[3] & 0x0F) << 7) | (data[4] & 0x7F);
89}
90
91static inline int touchkit_get_y(char *data)
92{
93 return ((data[1] & 0x0F) << 7) | (data[2] & 0x7F);
94}
95
96
97/* processes one input packet. */
98static void touchkit_process_pkt(struct touchkit_usb *touchkit,
99 struct pt_regs *regs, char *pkt)
100{
101 int x, y;
102
103 /* only process report packets */
104 if ((pkt[0] & TOUCHKIT_PKT_TYPE_MASK) != TOUCHKIT_PKT_TYPE_REPT)
105 return;
106
107 if (swap_xy) {
108 y = touchkit_get_x(pkt);
109 x = touchkit_get_y(pkt);
110 } else {
111 x = touchkit_get_x(pkt);
112 y = touchkit_get_y(pkt);
113 }
114
115 input_regs(touchkit->input, regs);
116 input_report_key(touchkit->input, BTN_TOUCH, touchkit_get_touched(pkt));
117 input_report_abs(touchkit->input, ABS_X, x);
118 input_report_abs(touchkit->input, ABS_Y, y);
119 input_sync(touchkit->input);
120}
121
122
123static int touchkit_get_pkt_len(char *buf)
124{
125 switch (buf[0] & TOUCHKIT_PKT_TYPE_MASK) {
126 case TOUCHKIT_PKT_TYPE_REPT:
127 return 5;
128
129 case TOUCHKIT_PKT_TYPE_DIAG:
130 return buf[1] + 2;
131 }
132
133 return 0;
134}
135
136static void touchkit_process(struct touchkit_usb *touchkit, int len,
137 struct pt_regs *regs)
138{
139 char *buffer;
140 int pkt_len, buf_len, pos;
141
142 /* if the buffer contains data, append */
143 if (unlikely(touchkit->buf_len)) {
144 int tmp;
145
146 /* if only 1 byte in buffer, add another one to get length */
147 if (touchkit->buf_len == 1)
148 touchkit->buffer[1] = touchkit->data[0];
149
150 pkt_len = touchkit_get_pkt_len(touchkit->buffer);
151
152 /* unknown packet: drop everything */
153 if (!pkt_len)
154 return;
155
156 /* append, process */
157 tmp = pkt_len - touchkit->buf_len;
158 memcpy(touchkit->buffer + touchkit->buf_len, touchkit->data, tmp);
159 touchkit_process_pkt(touchkit, regs, touchkit->buffer);
160
161 buffer = touchkit->data + tmp;
162 buf_len = len - tmp;
163 } else {
164 buffer = touchkit->data;
165 buf_len = len;
166 }
167
168 /* only one byte left in buffer */
169 if (unlikely(buf_len == 1)) {
170 touchkit->buffer[0] = buffer[0];
171 touchkit->buf_len = 1;
172 return;
173 }
174
175 /* loop over the buffer */
176 pos = 0;
177 while (pos < buf_len) {
178 /* get packet len */
179 pkt_len = touchkit_get_pkt_len(buffer + pos);
180
181 /* unknown packet: drop everything */
182 if (unlikely(!pkt_len))
183 return;
184
185 /* full packet: process */
186 if (likely(pkt_len <= buf_len)) {
187 touchkit_process_pkt(touchkit, regs, buffer + pos);
188 } else {
189 /* incomplete packet: save in buffer */
190 memcpy(touchkit->buffer, buffer + pos, buf_len - pos);
191 touchkit->buf_len = buf_len - pos;
192 }
193 pos += pkt_len;
194 }
195}
196
197
80static void touchkit_irq(struct urb *urb, struct pt_regs *regs) 198static void touchkit_irq(struct urb *urb, struct pt_regs *regs)
81{ 199{
82 struct touchkit_usb *touchkit = urb->context; 200 struct touchkit_usb *touchkit = urb->context;
83 int retval; 201 int retval;
84 int x, y;
85 202
86 switch (urb->status) { 203 switch (urb->status) {
87 case 0: 204 case 0:
@@ -105,20 +222,7 @@ static void touchkit_irq(struct urb *urb, struct pt_regs *regs)
105 goto exit; 222 goto exit;
106 } 223 }
107 224
108 if (swap_xy) { 225 touchkit_process(touchkit, urb->actual_length, regs);
109 y = TOUCHKIT_GET_X(touchkit->data);
110 x = TOUCHKIT_GET_Y(touchkit->data);
111 } else {
112 x = TOUCHKIT_GET_X(touchkit->data);
113 y = TOUCHKIT_GET_Y(touchkit->data);
114 }
115
116 input_regs(touchkit->input, regs);
117 input_report_key(touchkit->input, BTN_TOUCH,
118 TOUCHKIT_GET_TOUCHED(touchkit->data));
119 input_report_abs(touchkit->input, ABS_X, x);
120 input_report_abs(touchkit->input, ABS_Y, y);
121 input_sync(touchkit->input);
122 226
123exit: 227exit:
124 retval = usb_submit_urb(urb, GFP_ATOMIC); 228 retval = usb_submit_urb(urb, GFP_ATOMIC);
@@ -267,7 +371,6 @@ static void touchkit_disconnect(struct usb_interface *intf)
267MODULE_DEVICE_TABLE(usb, touchkit_devices); 371MODULE_DEVICE_TABLE(usb, touchkit_devices);
268 372
269static struct usb_driver touchkit_driver = { 373static struct usb_driver touchkit_driver = {
270 .owner = THIS_MODULE,
271 .name = "touchkitusb", 374 .name = "touchkitusb",
272 .probe = touchkit_probe, 375 .probe = touchkit_probe,
273 .disconnect = touchkit_disconnect, 376 .disconnect = touchkit_disconnect,
diff --git a/drivers/usb/input/usbkbd.c b/drivers/usb/input/usbkbd.c
index 226b6f90a907..2f3edc26cb50 100644
--- a/drivers/usb/input/usbkbd.c
+++ b/drivers/usb/input/usbkbd.c
@@ -345,7 +345,6 @@ static struct usb_device_id usb_kbd_id_table [] = {
345MODULE_DEVICE_TABLE (usb, usb_kbd_id_table); 345MODULE_DEVICE_TABLE (usb, usb_kbd_id_table);
346 346
347static struct usb_driver usb_kbd_driver = { 347static struct usb_driver usb_kbd_driver = {
348 .owner = THIS_MODULE,
349 .name = "usbkbd", 348 .name = "usbkbd",
350 .probe = usb_kbd_probe, 349 .probe = usb_kbd_probe,
351 .disconnect = usb_kbd_disconnect, 350 .disconnect = usb_kbd_disconnect,
diff --git a/drivers/usb/input/usbmouse.c b/drivers/usb/input/usbmouse.c
index 230f6b1b314a..af526135d210 100644
--- a/drivers/usb/input/usbmouse.c
+++ b/drivers/usb/input/usbmouse.c
@@ -226,7 +226,6 @@ static struct usb_device_id usb_mouse_id_table [] = {
226MODULE_DEVICE_TABLE (usb, usb_mouse_id_table); 226MODULE_DEVICE_TABLE (usb, usb_mouse_id_table);
227 227
228static struct usb_driver usb_mouse_driver = { 228static struct usb_driver usb_mouse_driver = {
229 .owner = THIS_MODULE,
230 .name = "usbmouse", 229 .name = "usbmouse",
231 .probe = usb_mouse_probe, 230 .probe = usb_mouse_probe,
232 .disconnect = usb_mouse_disconnect, 231 .disconnect = usb_mouse_disconnect,
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
index aea1cfae34cc..48df4cfd5a42 100644
--- a/drivers/usb/input/wacom.c
+++ b/drivers/usb/input/wacom.c
@@ -854,7 +854,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
854 854
855 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); 855 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
856 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); 856 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
857 input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0); 857 input_set_abs_params(input_dev, ABS_X, 0, wacom->features->x_max, 4, 0);
858 input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0); 858 input_set_abs_params(input_dev, ABS_Y, 0, wacom->features->y_max, 4, 0);
859 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0); 859 input_set_abs_params(input_dev, ABS_PRESSURE, 0, wacom->features->pressure_max, 0, 0);
860 860
@@ -945,7 +945,6 @@ static void wacom_disconnect(struct usb_interface *intf)
945} 945}
946 946
947static struct usb_driver wacom_driver = { 947static struct usb_driver wacom_driver = {
948 .owner = THIS_MODULE,
949 .name = "wacom", 948 .name = "wacom",
950 .probe = wacom_probe, 949 .probe = wacom_probe,
951 .disconnect = wacom_disconnect, 950 .disconnect = wacom_disconnect,
diff --git a/drivers/usb/input/xpad.c b/drivers/usb/input/xpad.c
index 43112f040b6d..e278489a80c6 100644
--- a/drivers/usb/input/xpad.c
+++ b/drivers/usb/input/xpad.c
@@ -70,7 +70,7 @@
70 70
71#define XPAD_PKT_LEN 32 71#define XPAD_PKT_LEN 32
72 72
73static struct xpad_device { 73static const struct xpad_device {
74 u16 idVendor; 74 u16 idVendor;
75 u16 idProduct; 75 u16 idProduct;
76 char *name; 76 char *name;
@@ -81,13 +81,13 @@ static struct xpad_device {
81 { 0x0000, 0x0000, "X-Box pad" } 81 { 0x0000, 0x0000, "X-Box pad" }
82}; 82};
83 83
84static signed short xpad_btn[] = { 84static const signed short xpad_btn[] = {
85 BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, /* "analog" buttons */ 85 BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, /* "analog" buttons */
86 BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */ 86 BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */
87 -1 /* terminating entry */ 87 -1 /* terminating entry */
88}; 88};
89 89
90static signed short xpad_abs[] = { 90static const signed short xpad_abs[] = {
91 ABS_X, ABS_Y, /* left stick */ 91 ABS_X, ABS_Y, /* left stick */
92 ABS_RX, ABS_RY, /* right stick */ 92 ABS_RX, ABS_RY, /* right stick */
93 ABS_Z, ABS_RZ, /* triggers left/right */ 93 ABS_Z, ABS_RZ, /* triggers left/right */
@@ -316,7 +316,6 @@ static void xpad_disconnect(struct usb_interface *intf)
316} 316}
317 317
318static struct usb_driver xpad_driver = { 318static struct usb_driver xpad_driver = {
319 .owner = THIS_MODULE,
320 .name = "xpad", 319 .name = "xpad",
321 .probe = xpad_probe, 320 .probe = xpad_probe,
322 .disconnect = xpad_disconnect, 321 .disconnect = xpad_disconnect,
diff --git a/drivers/usb/input/yealink.c b/drivers/usb/input/yealink.c
index f526aebea502..1bfc105ad4d6 100644
--- a/drivers/usb/input/yealink.c
+++ b/drivers/usb/input/yealink.c
@@ -987,7 +987,6 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
987} 987}
988 988
989static struct usb_driver yealink_driver = { 989static struct usb_driver yealink_driver = {
990 .owner = THIS_MODULE,
991 .name = "yealink", 990 .name = "yealink",
992 .probe = usb_probe, 991 .probe = usb_probe,
993 .disconnect = usb_disconnect, 992 .disconnect = usb_disconnect,
diff --git a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c
index 27b23c55bbc7..18d8eaf408d5 100644
--- a/drivers/usb/media/dabusb.c
+++ b/drivers/usb/media/dabusb.c
@@ -812,7 +812,6 @@ static struct usb_device_id dabusb_ids [] = {
812MODULE_DEVICE_TABLE (usb, dabusb_ids); 812MODULE_DEVICE_TABLE (usb, dabusb_ids);
813 813
814static struct usb_driver dabusb_driver = { 814static struct usb_driver dabusb_driver = {
815 .owner = THIS_MODULE,
816 .name = "dabusb", 815 .name = "dabusb",
817 .probe = dabusb_probe, 816 .probe = dabusb_probe,
818 .disconnect = dabusb_disconnect, 817 .disconnect = dabusb_disconnect,
diff --git a/drivers/usb/media/dsbr100.c b/drivers/usb/media/dsbr100.c
index 7503f5b96f59..6a5700e9d428 100644
--- a/drivers/usb/media/dsbr100.c
+++ b/drivers/usb/media/dsbr100.c
@@ -150,7 +150,6 @@ MODULE_DEVICE_TABLE (usb, usb_dsbr100_device_table);
150 150
151/* USB subsystem interface */ 151/* USB subsystem interface */
152static struct usb_driver usb_dsbr100_driver = { 152static struct usb_driver usb_dsbr100_driver = {
153 .owner = THIS_MODULE,
154 .name = "dsbr100", 153 .name = "dsbr100",
155 .probe = usb_dsbr100_probe, 154 .probe = usb_dsbr100_probe,
156 .disconnect = usb_dsbr100_disconnect, 155 .disconnect = usb_dsbr100_disconnect,
diff --git a/drivers/usb/media/ibmcam.c b/drivers/usb/media/ibmcam.c
index ba41fc7b95c2..a42c22294124 100644
--- a/drivers/usb/media/ibmcam.c
+++ b/drivers/usb/media/ibmcam.c
@@ -3457,7 +3457,7 @@ static void ibmcam_model3_setup_after_video_if(struct uvd *uvd)
3457 if(init_model3_input) { 3457 if(init_model3_input) {
3458 if (debug > 0) 3458 if (debug > 0)
3459 info("Setting input to RCA."); 3459 info("Setting input to RCA.");
3460 for (i=0; i < (sizeof(initData)/sizeof(initData[0])); i++) { 3460 for (i=0; i < ARRAY_SIZE(initData); i++) {
3461 ibmcam_veio(uvd, initData[i].req, initData[i].value, initData[i].index); 3461 ibmcam_veio(uvd, initData[i].req, initData[i].value, initData[i].index);
3462 } 3462 }
3463 } 3463 }
diff --git a/drivers/usb/media/konicawc.c b/drivers/usb/media/konicawc.c
index 9fe2c2710d13..e2ede583518f 100644
--- a/drivers/usb/media/konicawc.c
+++ b/drivers/usb/media/konicawc.c
@@ -77,14 +77,14 @@ static int saturation = MAX_SATURATION/2;
77static int sharpness = MAX_SHARPNESS/2; 77static int sharpness = MAX_SHARPNESS/2;
78static int whitebal = 3*(MAX_WHITEBAL/4); 78static int whitebal = 3*(MAX_WHITEBAL/4);
79 79
80static int spd_to_iface[] = { 1, 0, 3, 2, 4, 5, 6 }; 80static const int spd_to_iface[] = { 1, 0, 3, 2, 4, 5, 6 };
81 81
82/* These FPS speeds are from the windows config box. They are 82/* These FPS speeds are from the windows config box. They are
83 * indexed on size (0-2) and speed (0-6). Divide by 3 to get the 83 * indexed on size (0-2) and speed (0-6). Divide by 3 to get the
84 * real fps. 84 * real fps.
85 */ 85 */
86 86
87static int spd_to_fps[][7] = { { 24, 40, 48, 60, 72, 80, 100 }, 87static const int spd_to_fps[][7] = { { 24, 40, 48, 60, 72, 80, 100 },
88 { 24, 40, 48, 60, 72, 80, 100 }, 88 { 24, 40, 48, 60, 72, 80, 100 },
89 { 18, 30, 36, 45, 54, 60, 75 }, 89 { 18, 30, 36, 45, 54, 60, 75 },
90 { 6, 10, 12, 15, 18, 21, 25 } }; 90 { 6, 10, 12, 15, 18, 21, 25 } };
@@ -95,7 +95,7 @@ struct cam_size {
95 u8 cmd; 95 u8 cmd;
96}; 96};
97 97
98static struct cam_size camera_sizes[] = { { 160, 120, 0x7 }, 98static const struct cam_size camera_sizes[] = { { 160, 120, 0x7 },
99 { 160, 136, 0xa }, 99 { 160, 136, 0xa },
100 { 176, 144, 0x4 }, 100 { 176, 144, 0x4 },
101 { 320, 240, 0x5 } }; 101 { 320, 240, 0x5 } };
diff --git a/drivers/usb/media/ov511.c b/drivers/usb/media/ov511.c
index 036c485d1d1e..3a0e8ce67ebe 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/usb/media/ov511.c
@@ -211,7 +211,7 @@ static struct ov51x_decomp_ops *ov518_mmx_decomp_ops;
211 211
212/* Number of times to retry a failed I2C transaction. Increase this if you 212/* Number of times to retry a failed I2C transaction. Increase this if you
213 * are getting "Failed to read sensor ID..." */ 213 * are getting "Failed to read sensor ID..." */
214static int i2c_detect_tries = 5; 214static const int i2c_detect_tries = 5;
215 215
216/* MMX support is present in kernel and CPU. Checked upon decomp module load. */ 216/* MMX support is present in kernel and CPU. Checked upon decomp module load. */
217#if defined(__i386__) || defined(__x86_64__) 217#if defined(__i386__) || defined(__x86_64__)
@@ -6008,7 +6008,6 @@ ov51x_disconnect(struct usb_interface *intf)
6008} 6008}
6009 6009
6010static struct usb_driver ov511_driver = { 6010static struct usb_driver ov511_driver = {
6011 .owner = THIS_MODULE,
6012 .name = "ov511", 6011 .name = "ov511",
6013 .id_table = device_table, 6012 .id_table = device_table,
6014 .probe = ov51x_probe, 6013 .probe = ov51x_probe,
diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/usb/media/pwc/pwc-ctrl.c
index 53099190952c..359c4b2df735 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/usb/media/pwc/pwc-ctrl.c
@@ -109,7 +109,7 @@
109#define PT_RESET_CONTROL_FORMATTER 0x02 109#define PT_RESET_CONTROL_FORMATTER 0x02
110#define PT_STATUS_FORMATTER 0x03 110#define PT_STATUS_FORMATTER 0x03
111 111
112static char *size2name[PSZ_MAX] = 112static const char *size2name[PSZ_MAX] =
113{ 113{
114 "subQCIF", 114 "subQCIF",
115 "QSIF", 115 "QSIF",
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/usb/media/pwc/pwc-if.c
index 5524fd70210b..09ca6128ac20 100644
--- a/drivers/usb/media/pwc/pwc-if.c
+++ b/drivers/usb/media/pwc/pwc-if.c
@@ -111,7 +111,6 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
111static void usb_pwc_disconnect(struct usb_interface *intf); 111static void usb_pwc_disconnect(struct usb_interface *intf);
112 112
113static struct usb_driver pwc_driver = { 113static struct usb_driver pwc_driver = {
114 .owner = THIS_MODULE,
115 .name = "Philips webcam", /* name */ 114 .name = "Philips webcam", /* name */
116 .id_table = pwc_device_table, 115 .id_table = pwc_device_table,
117 .probe = usb_pwc_probe, /* probe() */ 116 .probe = usb_pwc_probe, /* probe() */
diff --git a/drivers/usb/media/se401.c b/drivers/usb/media/se401.c
index f69e443cd1bc..b2ae29af5940 100644
--- a/drivers/usb/media/se401.c
+++ b/drivers/usb/media/se401.c
@@ -1401,7 +1401,6 @@ static void se401_disconnect(struct usb_interface *intf)
1401} 1401}
1402 1402
1403static struct usb_driver se401_driver = { 1403static struct usb_driver se401_driver = {
1404 .owner = THIS_MODULE,
1405 .name = "se401", 1404 .name = "se401",
1406 .id_table = device_table, 1405 .id_table = device_table,
1407 .probe = se401_probe, 1406 .probe = se401_probe,
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index b2e66e3b90aa..8d1a1c357d5a 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -1316,7 +1316,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1316 struct v4l2_control ctrl; 1316 struct v4l2_control ctrl;
1317 struct v4l2_queryctrl *qctrl; 1317 struct v4l2_queryctrl *qctrl;
1318 struct v4l2_rect* rect; 1318 struct v4l2_rect* rect;
1319 u8 i = 0, n = 0; 1319 u8 i = 0;
1320 int err = 0; 1320 int err = 0;
1321 1321
1322 if (!(cam->state & DEV_INITIALIZED)) { 1322 if (!(cam->state & DEV_INITIALIZED)) {
@@ -1352,7 +1352,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1352 return err; 1352 return err;
1353 1353
1354 if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X) 1354 if (s->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X)
1355 DBG(3, "Compressed video format is active, quality %d", 1355 DBG(3, "Compressed video format is active, quality %d",
1356 cam->compression.quality) 1356 cam->compression.quality)
1357 else 1357 else
1358 DBG(3, "Uncompressed video format is active") 1358 DBG(3, "Uncompressed video format is active")
@@ -1364,9 +1364,8 @@ static int sn9c102_init(struct sn9c102_device* cam)
1364 } 1364 }
1365 1365
1366 if (s->set_ctrl) { 1366 if (s->set_ctrl) {
1367 n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); 1367 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1368 for (i = 0; i < n; i++) 1368 if (s->qctrl[i].id != 0 &&
1369 if (s->qctrl[i].id != 0 &&
1370 !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) { 1369 !(s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED)) {
1371 ctrl.id = s->qctrl[i].id; 1370 ctrl.id = s->qctrl[i].id;
1372 ctrl.value = qctrl[i].default_value; 1371 ctrl.value = qctrl[i].default_value;
@@ -1388,7 +1387,7 @@ static int sn9c102_init(struct sn9c102_device* cam)
1388 init_waitqueue_head(&cam->wait_stream); 1387 init_waitqueue_head(&cam->wait_stream);
1389 cam->nreadbuffers = 2; 1388 cam->nreadbuffers = 2;
1390 memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl)); 1389 memcpy(s->_qctrl, s->qctrl, sizeof(s->qctrl));
1391 memcpy(&(s->_rect), &(s->cropcap.defrect), 1390 memcpy(&(s->_rect), &(s->cropcap.defrect),
1392 sizeof(struct v4l2_rect)); 1391 sizeof(struct v4l2_rect));
1393 cam->state |= DEV_INITIALIZED; 1392 cam->state |= DEV_INITIALIZED;
1394 } 1393 }
@@ -1810,13 +1809,12 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
1810 { 1809 {
1811 struct sn9c102_sensor* s = cam->sensor; 1810 struct sn9c102_sensor* s = cam->sensor;
1812 struct v4l2_queryctrl qc; 1811 struct v4l2_queryctrl qc;
1813 u8 i, n; 1812 u8 i;
1814 1813
1815 if (copy_from_user(&qc, arg, sizeof(qc))) 1814 if (copy_from_user(&qc, arg, sizeof(qc)))
1816 return -EFAULT; 1815 return -EFAULT;
1817 1816
1818 n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); 1817 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1819 for (i = 0; i < n; i++)
1820 if (qc.id && qc.id == s->qctrl[i].id) { 1818 if (qc.id && qc.id == s->qctrl[i].id) {
1821 memcpy(&qc, &(s->qctrl[i]), sizeof(qc)); 1819 memcpy(&qc, &(s->qctrl[i]), sizeof(qc));
1822 if (copy_to_user(arg, &qc, sizeof(qc))) 1820 if (copy_to_user(arg, &qc, sizeof(qc)))
@@ -1852,7 +1850,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
1852 { 1850 {
1853 struct sn9c102_sensor* s = cam->sensor; 1851 struct sn9c102_sensor* s = cam->sensor;
1854 struct v4l2_control ctrl; 1852 struct v4l2_control ctrl;
1855 u8 i, n; 1853 u8 i;
1856 int err = 0; 1854 int err = 0;
1857 1855
1858 if (!s->set_ctrl) 1856 if (!s->set_ctrl)
@@ -1861,8 +1859,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
1861 if (copy_from_user(&ctrl, arg, sizeof(ctrl))) 1859 if (copy_from_user(&ctrl, arg, sizeof(ctrl)))
1862 return -EFAULT; 1860 return -EFAULT;
1863 1861
1864 n = sizeof(s->qctrl) / sizeof(s->qctrl[0]); 1862 for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
1865 for (i = 0; i < n; i++)
1866 if (ctrl.id == s->qctrl[i].id) { 1863 if (ctrl.id == s->qctrl[i].id) {
1867 if (ctrl.value < s->qctrl[i].minimum || 1864 if (ctrl.value < s->qctrl[i].minimum ||
1868 ctrl.value > s->qctrl[i].maximum) 1865 ctrl.value > s->qctrl[i].maximum)
@@ -2544,7 +2541,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
2544 unsigned int i, n; 2541 unsigned int i, n;
2545 int err = 0, r; 2542 int err = 0, r;
2546 2543
2547 n = sizeof(sn9c102_id_table)/sizeof(sn9c102_id_table[0]); 2544 n = ARRAY_SIZE(sn9c102_id_table);
2548 for (i = 0; i < n-1; i++) 2545 for (i = 0; i < n-1; i++)
2549 if (le16_to_cpu(udev->descriptor.idVendor) == 2546 if (le16_to_cpu(udev->descriptor.idVendor) ==
2550 sn9c102_id_table[i].idVendor && 2547 sn9c102_id_table[i].idVendor &&
@@ -2711,7 +2708,6 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf)
2711 2708
2712 2709
2713static struct usb_driver sn9c102_usb_driver = { 2710static struct usb_driver sn9c102_usb_driver = {
2714 .owner = THIS_MODULE,
2715 .name = "sn9c102", 2711 .name = "sn9c102",
2716 .id_table = sn9c102_id_table, 2712 .id_table = sn9c102_id_table,
2717 .probe = sn9c102_usb_probe, 2713 .probe = sn9c102_usb_probe,
diff --git a/drivers/usb/media/stv680.c b/drivers/usb/media/stv680.c
index 0fd0fa9fec21..774038b352cd 100644
--- a/drivers/usb/media/stv680.c
+++ b/drivers/usb/media/stv680.c
@@ -1477,7 +1477,6 @@ static void stv680_disconnect (struct usb_interface *intf)
1477} 1477}
1478 1478
1479static struct usb_driver stv680_driver = { 1479static struct usb_driver stv680_driver = {
1480 .owner = THIS_MODULE,
1481 .name = "stv680", 1480 .name = "stv680",
1482 .probe = stv680_probe, 1481 .probe = stv680_probe,
1483 .disconnect = stv680_disconnect, 1482 .disconnect = stv680_disconnect,
diff --git a/drivers/usb/media/stv680.h b/drivers/usb/media/stv680.h
index 445940612603..b0551cdb280b 100644
--- a/drivers/usb/media/stv680.h
+++ b/drivers/usb/media/stv680.h
@@ -151,7 +151,7 @@ struct usb_stv {
151}; 151};
152 152
153 153
154static unsigned char red[256] = { 154static const unsigned char red[256] = {
155 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 155 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
156 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42, 156 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42,
157 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69, 157 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69,
@@ -176,7 +176,7 @@ static unsigned char red[256] = {
176 220, 220, 221, 221 176 220, 220, 221, 221
177}; 177};
178 178
179static unsigned char green[256] = { 179static const unsigned char green[256] = {
180 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 180 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
181 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47, 181 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47,
182 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77, 182 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77,
@@ -201,7 +201,7 @@ static unsigned char green[256] = {
201 245, 245, 246, 246 201 245, 245, 246, 246
202}; 202};
203 203
204static unsigned char blue[256] = { 204static const unsigned char blue[256] = {
205 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 205 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
206 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51, 206 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51,
207 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84, 207 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84,
diff --git a/drivers/usb/media/usbvideo.c b/drivers/usb/media/usbvideo.c
index 24efb21969c6..4bd113325ef9 100644
--- a/drivers/usb/media/usbvideo.c
+++ b/drivers/usb/media/usbvideo.c
@@ -725,7 +725,7 @@ int usbvideo_register(
725 /* Allocate user_data separately because of kmalloc's limits */ 725 /* Allocate user_data separately because of kmalloc's limits */
726 if (num_extra > 0) { 726 if (num_extra > 0) {
727 up->user_size = num_cams * num_extra; 727 up->user_size = num_cams * num_extra;
728 up->user_data = (char *) kmalloc(up->user_size, GFP_KERNEL); 728 up->user_data = kmalloc(up->user_size, GFP_KERNEL);
729 if (up->user_data == NULL) { 729 if (up->user_data == NULL) {
730 err("%s: Failed to allocate user_data (%d. bytes)", 730 err("%s: Failed to allocate user_data (%d. bytes)",
731 __FUNCTION__, up->user_size); 731 __FUNCTION__, up->user_size);
@@ -955,7 +955,7 @@ static struct file_operations usbvideo_fops = {
955 .ioctl = usbvideo_v4l_ioctl, 955 .ioctl = usbvideo_v4l_ioctl,
956 .llseek = no_llseek, 956 .llseek = no_llseek,
957}; 957};
958static struct video_device usbvideo_template = { 958static const struct video_device usbvideo_template = {
959 .owner = THIS_MODULE, 959 .owner = THIS_MODULE,
960 .type = VID_TYPE_CAPTURE, 960 .type = VID_TYPE_CAPTURE,
961 .hardware = VID_HARDWARE_CPIA, 961 .hardware = VID_HARDWARE_CPIA,
diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c
index 0bc0b1247a6b..1c73155c8d77 100644
--- a/drivers/usb/media/vicam.c
+++ b/drivers/usb/media/vicam.c
@@ -1257,7 +1257,6 @@ static struct usb_device_id vicam_table[] = {
1257MODULE_DEVICE_TABLE(usb, vicam_table); 1257MODULE_DEVICE_TABLE(usb, vicam_table);
1258 1258
1259static struct usb_driver vicam_driver = { 1259static struct usb_driver vicam_driver = {
1260 .owner = THIS_MODULE,
1261 .name = "vicam", 1260 .name = "vicam",
1262 .probe = vicam_probe, 1261 .probe = vicam_probe,
1263 .disconnect = vicam_disconnect, 1262 .disconnect = vicam_disconnect,
diff --git a/drivers/usb/media/w9968cf.c b/drivers/usb/media/w9968cf.c
index 67612c81cb9f..3605a6f3067b 100644
--- a/drivers/usb/media/w9968cf.c
+++ b/drivers/usb/media/w9968cf.c
@@ -1533,12 +1533,12 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
1533 } 1533 }
1534 } else { 1534 } else {
1535 DBG(4, "Rejected client [%s] with driver [%s]", 1535 DBG(4, "Rejected client [%s] with driver [%s]",
1536 client->name, client->driver->name) 1536 client->name, client->driver->driver.name)
1537 return -EINVAL; 1537 return -EINVAL;
1538 } 1538 }
1539 1539
1540 DBG(5, "I2C attach client [%s] with driver [%s]", 1540 DBG(5, "I2C attach client [%s] with driver [%s]",
1541 client->name, client->driver->name) 1541 client->name, client->driver->driver.name)
1542 1542
1543 return 0; 1543 return 0;
1544} 1544}
@@ -2958,7 +2958,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
2958 }; 2958 };
2959 2959
2960 #define V4L1_IOCTL(cmd) \ 2960 #define V4L1_IOCTL(cmd) \
2961 ((_IOC_NR((cmd)) < sizeof(v4l1_ioctls)/sizeof(char*)) ? \ 2961 ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \
2962 v4l1_ioctls[_IOC_NR((cmd))] : "?") 2962 v4l1_ioctls[_IOC_NR((cmd))] : "?")
2963 2963
2964 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp)); 2964 cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
@@ -3554,7 +3554,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3554 3554
3555 3555
3556 /* Allocate 2 bytes of memory for camera control USB transfers */ 3556 /* Allocate 2 bytes of memory for camera control USB transfers */
3557 if (!(cam->control_buffer = (u16*)kmalloc(2, GFP_KERNEL))) { 3557 if (!(cam->control_buffer = kmalloc(2, GFP_KERNEL))) {
3558 DBG(1,"Couldn't allocate memory for camera control transfers") 3558 DBG(1,"Couldn't allocate memory for camera control transfers")
3559 err = -ENOMEM; 3559 err = -ENOMEM;
3560 goto fail; 3560 goto fail;
@@ -3562,7 +3562,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
3562 memset(cam->control_buffer, 0, 2); 3562 memset(cam->control_buffer, 0, 2);
3563 3563
3564 /* Allocate 8 bytes of memory for USB data transfers to the FSB */ 3564 /* Allocate 8 bytes of memory for USB data transfers to the FSB */
3565 if (!(cam->data_buffer = (u16*)kmalloc(8, GFP_KERNEL))) { 3565 if (!(cam->data_buffer = kmalloc(8, GFP_KERNEL))) {
3566 DBG(1, "Couldn't allocate memory for data " 3566 DBG(1, "Couldn't allocate memory for data "
3567 "transfers to the FSB") 3567 "transfers to the FSB")
3568 err = -ENOMEM; 3568 err = -ENOMEM;
@@ -3668,7 +3668,6 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf)
3668 3668
3669 3669
3670static struct usb_driver w9968cf_usb_driver = { 3670static struct usb_driver w9968cf_usb_driver = {
3671 .owner = THIS_MODULE,
3672 .name = "w9968cf", 3671 .name = "w9968cf",
3673 .id_table = winbond_id_table, 3672 .id_table = winbond_id_table,
3674 .probe = w9968cf_usb_probe, 3673 .probe = w9968cf_usb_probe,
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 2a28ceeaa66a..449b2501acf3 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -767,7 +767,7 @@ static int auerbuf_setup (pauerbufctl_t bcp, unsigned int numElements, unsigned
767 memset (bep, 0, sizeof (auerbuf_t)); 767 memset (bep, 0, sizeof (auerbuf_t));
768 bep->list = bcp; 768 bep->list = bcp;
769 INIT_LIST_HEAD (&bep->buff_list); 769 INIT_LIST_HEAD (&bep->buff_list);
770 bep->bufp = (char *) kmalloc (bufsize, GFP_KERNEL); 770 bep->bufp = kmalloc (bufsize, GFP_KERNEL);
771 if (!bep->bufp) 771 if (!bep->bufp)
772 goto bl_fail; 772 goto bl_fail;
773 bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL); 773 bep->dr = (struct usb_ctrlrequest *) kmalloc (sizeof (struct usb_ctrlrequest), GFP_KERNEL);
@@ -1123,7 +1123,7 @@ static int auerswald_int_open (pauerswald_t cp)
1123 } 1123 }
1124 } 1124 }
1125 if (!cp->intbufp) { 1125 if (!cp->intbufp) {
1126 cp->intbufp = (char *) kmalloc (irqsize, GFP_KERNEL); 1126 cp->intbufp = kmalloc (irqsize, GFP_KERNEL);
1127 if (!cp->intbufp) { 1127 if (!cp->intbufp) {
1128 ret = -ENOMEM; 1128 ret = -ENOMEM;
1129 goto intoend; 1129 goto intoend;
@@ -1696,7 +1696,7 @@ static ssize_t auerchar_write (struct file *file, const char __user *buf, size_t
1696 int ret; 1696 int ret;
1697 wait_queue_t wait; 1697 wait_queue_t wait;
1698 1698
1699 dbg ("auerchar_write %d bytes", len); 1699 dbg ("auerchar_write %zd bytes", len);
1700 1700
1701 /* Error checking */ 1701 /* Error checking */
1702 if (!ccp) 1702 if (!ccp)
@@ -2103,7 +2103,6 @@ MODULE_DEVICE_TABLE (usb, auerswald_ids);
2103 2103
2104/* Standard usb driver struct */ 2104/* Standard usb driver struct */
2105static struct usb_driver auerswald_driver = { 2105static struct usb_driver auerswald_driver = {
2106 .owner = THIS_MODULE,
2107 .name = "auerswald", 2106 .name = "auerswald",
2108 .probe = auerswald_probe, 2107 .probe = auerswald_probe,
2109 .disconnect = auerswald_disconnect, 2108 .disconnect = auerswald_disconnect,
diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c
index b33044d56a1e..6671317b495f 100644
--- a/drivers/usb/misc/cytherm.c
+++ b/drivers/usb/misc/cytherm.c
@@ -50,7 +50,6 @@ static void cytherm_disconnect(struct usb_interface *interface);
50 50
51/* usb specific object needed to register this driver with the usb subsystem */ 51/* usb specific object needed to register this driver with the usb subsystem */
52static struct usb_driver cytherm_driver = { 52static struct usb_driver cytherm_driver = {
53 .owner = THIS_MODULE,
54 .name = "cytherm", 53 .name = "cytherm",
55 .probe = cytherm_probe, 54 .probe = cytherm_probe,
56 .disconnect = cytherm_disconnect, 55 .disconnect = cytherm_disconnect,
diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c
index c8155209bf4b..3824df33094e 100644
--- a/drivers/usb/misc/emi26.c
+++ b/drivers/usb/misc/emi26.c
@@ -227,7 +227,6 @@ static void emi26_disconnect(struct usb_interface *intf)
227} 227}
228 228
229static struct usb_driver emi26_driver = { 229static struct usb_driver emi26_driver = {
230 .owner = THIS_MODULE,
231 .name = "emi26 - firmware loader", 230 .name = "emi26 - firmware loader",
232 .probe = emi26_probe, 231 .probe = emi26_probe,
233 .disconnect = emi26_disconnect, 232 .disconnect = emi26_disconnect,
diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c
index 189986af2ac7..52fea2e08db8 100644
--- a/drivers/usb/misc/emi62.c
+++ b/drivers/usb/misc/emi62.c
@@ -266,7 +266,6 @@ static void emi62_disconnect(struct usb_interface *intf)
266} 266}
267 267
268static struct usb_driver emi62_driver = { 268static struct usb_driver emi62_driver = {
269 .owner = THIS_MODULE,
270 .name = "emi62 - firmware loader", 269 .name = "emi62 - firmware loader",
271 .probe = emi62_probe, 270 .probe = emi62_probe,
272 .disconnect = emi62_disconnect, 271 .disconnect = emi62_disconnect,
diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c
index 1dc3e0f73014..d8cde1017985 100644
--- a/drivers/usb/misc/idmouse.c
+++ b/drivers/usb/misc/idmouse.c
@@ -114,7 +114,6 @@ static struct usb_class_driver idmouse_class = {
114 114
115/* usb specific object needed to register this driver with the usb subsystem */ 115/* usb specific object needed to register this driver with the usb subsystem */
116static struct usb_driver idmouse_driver = { 116static struct usb_driver idmouse_driver = {
117 .owner = THIS_MODULE,
118 .name = DRIVER_SHORT, 117 .name = DRIVER_SHORT,
119 .probe = idmouse_probe, 118 .probe = idmouse_probe,
120 .disconnect = idmouse_disconnect, 119 .disconnect = idmouse_disconnect,
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c
index 7e93ac96490f..981d8a5fbfd9 100644
--- a/drivers/usb/misc/ldusb.c
+++ b/drivers/usb/misc/ldusb.c
@@ -763,7 +763,6 @@ static void ld_usb_disconnect(struct usb_interface *intf)
763 763
764/* usb specific object needed to register this driver with the usb subsystem */ 764/* usb specific object needed to register this driver with the usb subsystem */
765static struct usb_driver ld_usb_driver = { 765static struct usb_driver ld_usb_driver = {
766 .owner = THIS_MODULE,
767 .name = "ldusb", 766 .name = "ldusb",
768 .probe = ld_usb_probe, 767 .probe = ld_usb_probe,
769 .disconnect = ld_usb_disconnect, 768 .disconnect = ld_usb_disconnect,
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 2703e205bc8f..1336745b8f55 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -282,7 +282,6 @@ static struct usb_class_driver tower_class = {
282 282
283/* usb specific object needed to register this driver with the usb subsystem */ 283/* usb specific object needed to register this driver with the usb subsystem */
284static struct usb_driver tower_driver = { 284static struct usb_driver tower_driver = {
285 .owner = THIS_MODULE,
286 .name = "legousbtower", 285 .name = "legousbtower",
287 .probe = tower_probe, 286 .probe = tower_probe,
288 .disconnect = tower_disconnect, 287 .disconnect = tower_disconnect,
diff --git a/drivers/usb/misc/phidgetkit.c b/drivers/usb/misc/phidgetkit.c
index 067a81486921..605a3c87e05c 100644
--- a/drivers/usb/misc/phidgetkit.c
+++ b/drivers/usb/misc/phidgetkit.c
@@ -555,7 +555,6 @@ static void interfacekit_disconnect(struct usb_interface *interface)
555} 555}
556 556
557static struct usb_driver interfacekit_driver = { 557static struct usb_driver interfacekit_driver = {
558 .owner = THIS_MODULE,
559 .name = "phidgetkit", 558 .name = "phidgetkit",
560 .probe = interfacekit_probe, 559 .probe = interfacekit_probe,
561 .disconnect = interfacekit_disconnect, 560 .disconnect = interfacekit_disconnect,
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index a30d4a6ee824..b3418d2bcc69 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -306,7 +306,6 @@ servo_disconnect(struct usb_interface *interface)
306} 306}
307 307
308static struct usb_driver servo_driver = { 308static struct usb_driver servo_driver = {
309 .owner = THIS_MODULE,
310 .name = "phidgetservo", 309 .name = "phidgetservo",
311 .probe = servo_probe, 310 .probe = servo_probe,
312 .disconnect = servo_disconnect, 311 .disconnect = servo_disconnect,
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
index 9590dbac5d9a..384fa3769805 100644
--- a/drivers/usb/misc/rio500.c
+++ b/drivers/usb/misc/rio500.c
@@ -465,14 +465,14 @@ static int probe_rio(struct usb_interface *intf,
465 465
466 rio->rio_dev = dev; 466 rio->rio_dev = dev;
467 467
468 if (!(rio->obuf = (char *) kmalloc(OBUF_SIZE, GFP_KERNEL))) { 468 if (!(rio->obuf = kmalloc(OBUF_SIZE, GFP_KERNEL))) {
469 err("probe_rio: Not enough memory for the output buffer"); 469 err("probe_rio: Not enough memory for the output buffer");
470 usb_deregister_dev(intf, &usb_rio_class); 470 usb_deregister_dev(intf, &usb_rio_class);
471 return -ENOMEM; 471 return -ENOMEM;
472 } 472 }
473 dbg("probe_rio: obuf address:%p", rio->obuf); 473 dbg("probe_rio: obuf address:%p", rio->obuf);
474 474
475 if (!(rio->ibuf = (char *) kmalloc(IBUF_SIZE, GFP_KERNEL))) { 475 if (!(rio->ibuf = kmalloc(IBUF_SIZE, GFP_KERNEL))) {
476 err("probe_rio: Not enough memory for the input buffer"); 476 err("probe_rio: Not enough memory for the input buffer");
477 usb_deregister_dev(intf, &usb_rio_class); 477 usb_deregister_dev(intf, &usb_rio_class);
478 kfree(rio->obuf); 478 kfree(rio->obuf);
@@ -522,7 +522,6 @@ static struct usb_device_id rio_table [] = {
522MODULE_DEVICE_TABLE (usb, rio_table); 522MODULE_DEVICE_TABLE (usb, rio_table);
523 523
524static struct usb_driver rio_driver = { 524static struct usb_driver rio_driver = {
525 .owner = THIS_MODULE,
526 .name = "rio500", 525 .name = "rio500",
527 .probe = probe_rio, 526 .probe = probe_rio,
528 .disconnect = disconnect_rio, 527 .disconnect = disconnect_rio,
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 41ef2b606751..3260d595441f 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -863,9 +863,6 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
863 863
864 switch (length) { 864 switch (length) {
865 865
866 case 0:
867 return ret;
868
869 case 1: 866 case 1:
870 if (userbuffer) { 867 if (userbuffer) {
871 if (get_user(swap8, (u8 __user *)userbuffer)) 868 if (get_user(swap8, (u8 __user *)userbuffer))
@@ -1221,9 +1218,6 @@ static int sisusb_read_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
1221 1218
1222 switch (length) { 1219 switch (length) {
1223 1220
1224 case 0:
1225 return ret;
1226
1227 case 1: 1221 case 1:
1228 1222
1229 ret |= sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM, 1223 ret |= sisusb_read_memio_byte(sisusb, SISUSB_TYPE_MEM,
@@ -2443,8 +2437,8 @@ sisusb_reset_text_mode(struct sisusb_usb_data *sisusb, int init)
2443 u8 *tempbuf; 2437 u8 *tempbuf;
2444 u16 *tempbufb; 2438 u16 *tempbufb;
2445 size_t written; 2439 size_t written;
2446 static char bootstring[] = "SiSUSB VGA text console, (C) 2005 Thomas Winischhofer."; 2440 static const char bootstring[] = "SiSUSB VGA text console, (C) 2005 Thomas Winischhofer.";
2447 static char bootlogo[] = "(o_ //\\ V_/_"; 2441 static const char bootlogo[] = "(o_ //\\ V_/_";
2448 2442
2449 /* sisusb->lock is down */ 2443 /* sisusb->lock is down */
2450 2444
@@ -3489,7 +3483,6 @@ static struct usb_device_id sisusb_table [] = {
3489MODULE_DEVICE_TABLE (usb, sisusb_table); 3483MODULE_DEVICE_TABLE (usb, sisusb_table);
3490 3484
3491static struct usb_driver sisusb_driver = { 3485static struct usb_driver sisusb_driver = {
3492 .owner = THIS_MODULE,
3493 .name = "sisusb", 3486 .name = "sisusb",
3494 .probe = sisusb_probe, 3487 .probe = sisusb_probe,
3495 .disconnect = sisusb_disconnect, 3488 .disconnect = sisusb_disconnect,
diff --git a/drivers/usb/misc/usblcd.c b/drivers/usb/misc/usblcd.c
index 85f3725334b0..cc3dae3f34e0 100644
--- a/drivers/usb/misc/usblcd.c
+++ b/drivers/usb/misc/usblcd.c
@@ -371,7 +371,6 @@ static void lcd_disconnect(struct usb_interface *interface)
371} 371}
372 372
373static struct usb_driver lcd_driver = { 373static struct usb_driver lcd_driver = {
374 .owner = THIS_MODULE,
375 .name = "usblcd", 374 .name = "usblcd",
376 .probe = lcd_probe, 375 .probe = lcd_probe,
377 .disconnect = lcd_disconnect, 376 .disconnect = lcd_disconnect,
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index 3c93921cb6b3..877b081a3a6e 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -148,7 +148,6 @@ static void led_disconnect(struct usb_interface *interface)
148} 148}
149 149
150static struct usb_driver led_driver = { 150static struct usb_driver led_driver = {
151 .owner = THIS_MODULE,
152 .name = "usbled", 151 .name = "usbled",
153 .probe = led_probe, 152 .probe = led_probe,
154 .disconnect = led_disconnect, 153 .disconnect = led_disconnect,
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 605a2afe34ed..84fa1728f052 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -2134,7 +2134,6 @@ static struct usb_device_id id_table [] = {
2134MODULE_DEVICE_TABLE (usb, id_table); 2134MODULE_DEVICE_TABLE (usb, id_table);
2135 2135
2136static struct usb_driver usbtest_driver = { 2136static struct usb_driver usbtest_driver = {
2137 .owner = THIS_MODULE,
2138 .name = "usbtest", 2137 .name = "usbtest",
2139 .id_table = id_table, 2138 .id_table = id_table,
2140 .probe = usbtest_probe, 2139 .probe = usbtest_probe,
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 1cabe7ed91f5..4081990b7d1a 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -780,7 +780,6 @@ MODULE_DEVICE_TABLE (usb, uss720_table);
780 780
781 781
782static struct usb_driver uss720_driver = { 782static struct usb_driver uss720_driver = {
783 .owner = THIS_MODULE,
784 .name = "uss720", 783 .name = "uss720",
785 .probe = uss720_probe, 784 .probe = uss720_probe,
786 .disconnect = uss720_disconnect, 785 .disconnect = uss720_disconnect,
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index 17d0190ef64e..611612146ae9 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -97,19 +97,12 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
97 if (len >= DATA_MAX) 97 if (len >= DATA_MAX)
98 len = DATA_MAX; 98 len = DATA_MAX;
99 99
100 /* 100 if (usb_pipein(pipe)) {
101 * Bulk is easy to shortcut reliably. 101 if (ev_type == 'S')
102 * XXX Other pipe types need consideration. Currently, we overdo it 102 return '<';
103 * and collect garbage for them: better more than less. 103 } else {
104 */ 104 if (ev_type == 'C')
105 if (usb_pipebulk(pipe) || usb_pipecontrol(pipe)) { 105 return '>';
106 if (usb_pipein(pipe)) {
107 if (ev_type == 'S')
108 return '<';
109 } else {
110 if (ev_type == 'C')
111 return '>';
112 }
113 } 106 }
114 107
115 /* 108 /*
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 542120ef1fd2..541181695040 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -912,13 +912,16 @@ static const struct usb_device_id products [] = {
912 // ASIX AX88772 10/100 912 // ASIX AX88772 10/100
913 USB_DEVICE (0x0b95, 0x7720), 913 USB_DEVICE (0x0b95, 0x7720),
914 .driver_info = (unsigned long) &ax88772_info, 914 .driver_info = (unsigned long) &ax88772_info,
915}, {
916 // Linksys USB200M Rev 2
917 USB_DEVICE (0x13b1, 0x0018),
918 .driver_info = (unsigned long) &ax88772_info,
915}, 919},
916 { }, // END 920 { }, // END
917}; 921};
918MODULE_DEVICE_TABLE(usb, products); 922MODULE_DEVICE_TABLE(usb, products);
919 923
920static struct usb_driver asix_driver = { 924static struct usb_driver asix_driver = {
921 .owner = THIS_MODULE,
922 .name = "asix", 925 .name = "asix",
923 .id_table = products, 926 .id_table = products,
924 .probe = usbnet_probe, 927 .probe = usbnet_probe,
diff --git a/drivers/usb/net/catc.c b/drivers/usb/net/catc.c
index 37ef365a2472..be5f5e142dd0 100644
--- a/drivers/usb/net/catc.c
+++ b/drivers/usb/net/catc.c
@@ -934,7 +934,6 @@ static struct usb_device_id catc_id_table [] = {
934MODULE_DEVICE_TABLE(usb, catc_id_table); 934MODULE_DEVICE_TABLE(usb, catc_id_table);
935 935
936static struct usb_driver catc_driver = { 936static struct usb_driver catc_driver = {
937 .owner = THIS_MODULE,
938 .name = driver_name, 937 .name = driver_name,
939 .probe = catc_probe, 938 .probe = catc_probe,
940 .disconnect = catc_disconnect, 939 .disconnect = catc_disconnect,
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index c008c981862b..63f1f3ba8e0b 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -476,7 +476,6 @@ static const struct usb_device_id products [] = {
476MODULE_DEVICE_TABLE(usb, products); 476MODULE_DEVICE_TABLE(usb, products);
477 477
478static struct usb_driver cdc_driver = { 478static struct usb_driver cdc_driver = {
479 .owner = THIS_MODULE,
480 .name = "cdc_ether", 479 .name = "cdc_ether",
481 .id_table = products, 480 .id_table = products,
482 .probe = usbnet_probe, 481 .probe = usbnet_probe,
diff --git a/drivers/usb/net/cdc_subset.c b/drivers/usb/net/cdc_subset.c
index f05cfb83c82d..ec801e8bb1bb 100644
--- a/drivers/usb/net/cdc_subset.c
+++ b/drivers/usb/net/cdc_subset.c
@@ -306,7 +306,6 @@ MODULE_DEVICE_TABLE(usb, products);
306/*-------------------------------------------------------------------------*/ 306/*-------------------------------------------------------------------------*/
307 307
308static struct usb_driver cdc_subset_driver = { 308static struct usb_driver cdc_subset_driver = {
309 .owner = THIS_MODULE,
310 .name = "cdc_subset", 309 .name = "cdc_subset",
311 .probe = usbnet_probe, 310 .probe = usbnet_probe,
312 .suspend = usbnet_suspend, 311 .suspend = usbnet_suspend,
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c
index 2455e9a85674..faf1e86be687 100644
--- a/drivers/usb/net/gl620a.c
+++ b/drivers/usb/net/gl620a.c
@@ -377,7 +377,6 @@ static const struct usb_device_id products [] = {
377MODULE_DEVICE_TABLE(usb, products); 377MODULE_DEVICE_TABLE(usb, products);
378 378
379static struct usb_driver gl620a_driver = { 379static struct usb_driver gl620a_driver = {
380 .owner = THIS_MODULE,
381 .name = "gl620a", 380 .name = "gl620a",
382 .id_table = products, 381 .id_table = products,
383 .probe = usbnet_probe, 382 .probe = usbnet_probe,
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index b5776518020f..def3bb8e2290 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -175,7 +175,6 @@ MODULE_DEVICE_TABLE (usb, usb_klsi_table);
175 * kaweth_driver 175 * kaweth_driver
176 ****************************************************************/ 176 ****************************************************************/
177static struct usb_driver kaweth_driver = { 177static struct usb_driver kaweth_driver = {
178 .owner = THIS_MODULE,
179 .name = driver_name, 178 .name = driver_name,
180 .probe = kaweth_probe, 179 .probe = kaweth_probe,
181 .disconnect = kaweth_disconnect, 180 .disconnect = kaweth_disconnect,
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index b3799b1a2b0d..78e6a43b1087 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -593,7 +593,6 @@ static const struct usb_device_id products [] = {
593MODULE_DEVICE_TABLE(usb, products); 593MODULE_DEVICE_TABLE(usb, products);
594 594
595static struct usb_driver net1080_driver = { 595static struct usb_driver net1080_driver = {
596 .owner = THIS_MODULE,
597 .name = "net1080", 596 .name = "net1080",
598 .id_table = products, 597 .id_table = products,
599 .probe = usbnet_probe, 598 .probe = usbnet_probe,
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 683e3df5d607..156a2f1cb39a 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -45,7 +45,7 @@
45/* 45/*
46 * Version Information 46 * Version Information
47 */ 47 */
48#define DRIVER_VERSION "v0.6.12 (2005/01/13)" 48#define DRIVER_VERSION "v0.6.13 (2005/11/13)"
49#define DRIVER_AUTHOR "Petko Manolov <petkan@users.sourceforge.net>" 49#define DRIVER_AUTHOR "Petko Manolov <petkan@users.sourceforge.net>"
50#define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver" 50#define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver"
51 51
@@ -57,12 +57,14 @@ static const char driver_name[] = "pegasus";
57 57
58static int loopback = 0; 58static int loopback = 0;
59static int mii_mode = 0; 59static int mii_mode = 0;
60static char *devid=NULL;
60 61
61static struct usb_eth_dev usb_dev_id[] = { 62static struct usb_eth_dev usb_dev_id[] = {
62#define PEGASUS_DEV(pn, vid, pid, flags) \ 63#define PEGASUS_DEV(pn, vid, pid, flags) \
63 {.name = pn, .vendor = vid, .device = pid, .private = flags}, 64 {.name = pn, .vendor = vid, .device = pid, .private = flags},
64#include "pegasus.h" 65#include "pegasus.h"
65#undef PEGASUS_DEV 66#undef PEGASUS_DEV
67 {NULL, 0, 0, 0},
66 {NULL, 0, 0, 0} 68 {NULL, 0, 0, 0}
67}; 69};
68 70
@@ -71,6 +73,7 @@ static struct usb_device_id pegasus_ids[] = {
71 {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid}, 73 {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid},
72#include "pegasus.h" 74#include "pegasus.h"
73#undef PEGASUS_DEV 75#undef PEGASUS_DEV
76 {},
74 {} 77 {}
75}; 78};
76 79
@@ -79,8 +82,10 @@ MODULE_DESCRIPTION(DRIVER_DESC);
79MODULE_LICENSE("GPL"); 82MODULE_LICENSE("GPL");
80module_param(loopback, bool, 0); 83module_param(loopback, bool, 0);
81module_param(mii_mode, bool, 0); 84module_param(mii_mode, bool, 0);
85module_param(devid, charp, 0);
82MODULE_PARM_DESC(loopback, "Enable MAC loopback mode (bit 0)"); 86MODULE_PARM_DESC(loopback, "Enable MAC loopback mode (bit 0)");
83MODULE_PARM_DESC(mii_mode, "Enable HomePNA mode (bit 0),default=MII mode = 0"); 87MODULE_PARM_DESC(mii_mode, "Enable HomePNA mode (bit 0),default=MII mode = 0");
88MODULE_PARM_DESC(devid, "The format is: 'DEV_name:VendorID:DeviceID:Flags'");
84 89
85/* use ethtool to change the level for any given device */ 90/* use ethtool to change the level for any given device */
86static int msg_level = -1; 91static int msg_level = -1;
@@ -113,7 +118,7 @@ static void ctrl_callback(struct urb *urb, struct pt_regs *regs)
113 break; 118 break;
114 default: 119 default:
115 if (netif_msg_drv(pegasus)) 120 if (netif_msg_drv(pegasus))
116 dev_err(&pegasus->intf->dev, "%s, status %d\n", 121 dev_dbg(&pegasus->intf->dev, "%s, status %d\n",
117 __FUNCTION__, urb->status); 122 __FUNCTION__, urb->status);
118 } 123 }
119 pegasus->flags &= ~ETH_REGS_CHANGED; 124 pegasus->flags &= ~ETH_REGS_CHANGED;
@@ -308,9 +313,9 @@ static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd)
308 __le16 regdi; 313 __le16 regdi;
309 int ret; 314 int ret;
310 315
311 ret = set_register(pegasus, PhyCtrl, 0); 316 set_register(pegasus, PhyCtrl, 0);
312 ret = set_registers(pegasus, PhyAddr, sizeof (data), data); 317 set_registers(pegasus, PhyAddr, sizeof (data), data);
313 ret = set_register(pegasus, PhyCtrl, (indx | PHY_READ)); 318 set_register(pegasus, PhyCtrl, (indx | PHY_READ));
314 for (i = 0; i < REG_TIMEOUT; i++) { 319 for (i = 0; i < REG_TIMEOUT; i++) {
315 ret = get_registers(pegasus, PhyCtrl, 1, data); 320 ret = get_registers(pegasus, PhyCtrl, 1, data);
316 if (data[0] & PHY_DONE) 321 if (data[0] & PHY_DONE)
@@ -319,12 +324,12 @@ static int read_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 * regd)
319 if (i < REG_TIMEOUT) { 324 if (i < REG_TIMEOUT) {
320 ret = get_registers(pegasus, PhyData, 2, &regdi); 325 ret = get_registers(pegasus, PhyData, 2, &regdi);
321 *regd = le16_to_cpu(regdi); 326 *regd = le16_to_cpu(regdi);
322 return 1; 327 return ret;
323 } 328 }
324 if (netif_msg_drv(pegasus)) 329 if (netif_msg_drv(pegasus))
325 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); 330 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__);
326 331
327 return 0; 332 return ret;
328} 333}
329 334
330static int mdio_read(struct net_device *dev, int phy_id, int loc) 335static int mdio_read(struct net_device *dev, int phy_id, int loc)
@@ -344,20 +349,20 @@ static int write_mii_word(pegasus_t * pegasus, __u8 phy, __u8 indx, __u16 regd)
344 349
345 data[1] = (u8) regd; 350 data[1] = (u8) regd;
346 data[2] = (u8) (regd >> 8); 351 data[2] = (u8) (regd >> 8);
347 ret = set_register(pegasus, PhyCtrl, 0); 352 set_register(pegasus, PhyCtrl, 0);
348 ret = set_registers(pegasus, PhyAddr, sizeof(data), data); 353 set_registers(pegasus, PhyAddr, sizeof(data), data);
349 ret = set_register(pegasus, PhyCtrl, (indx | PHY_WRITE)); 354 set_register(pegasus, PhyCtrl, (indx | PHY_WRITE));
350 for (i = 0; i < REG_TIMEOUT; i++) { 355 for (i = 0; i < REG_TIMEOUT; i++) {
351 ret = get_registers(pegasus, PhyCtrl, 1, data); 356 ret = get_registers(pegasus, PhyCtrl, 1, data);
352 if (data[0] & PHY_DONE) 357 if (data[0] & PHY_DONE)
353 break; 358 break;
354 } 359 }
355 if (i < REG_TIMEOUT) 360 if (i < REG_TIMEOUT)
356 return 0; 361 return ret;
357 362
358 if (netif_msg_drv(pegasus)) 363 if (netif_msg_drv(pegasus))
359 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); 364 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__);
360 return 1; 365 return -ETIMEDOUT;
361} 366}
362 367
363static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) 368static void mdio_write(struct net_device *dev, int phy_id, int loc, int val)
@@ -374,9 +379,9 @@ static int read_eprom_word(pegasus_t * pegasus, __u8 index, __u16 * retdata)
374 __le16 retdatai; 379 __le16 retdatai;
375 int ret; 380 int ret;
376 381
377 ret = set_register(pegasus, EpromCtrl, 0); 382 set_register(pegasus, EpromCtrl, 0);
378 ret = set_register(pegasus, EpromOffset, index); 383 set_register(pegasus, EpromOffset, index);
379 ret = set_register(pegasus, EpromCtrl, EPROM_READ); 384 set_register(pegasus, EpromCtrl, EPROM_READ);
380 385
381 for (i = 0; i < REG_TIMEOUT; i++) { 386 for (i = 0; i < REG_TIMEOUT; i++) {
382 ret = get_registers(pegasus, EpromCtrl, 1, &tmp); 387 ret = get_registers(pegasus, EpromCtrl, 1, &tmp);
@@ -386,12 +391,12 @@ static int read_eprom_word(pegasus_t * pegasus, __u8 index, __u16 * retdata)
386 if (i < REG_TIMEOUT) { 391 if (i < REG_TIMEOUT) {
387 ret = get_registers(pegasus, EpromData, 2, &retdatai); 392 ret = get_registers(pegasus, EpromData, 2, &retdatai);
388 *retdata = le16_to_cpu(retdatai); 393 *retdata = le16_to_cpu(retdatai);
389 return 0; 394 return ret;
390 } 395 }
391 396
392 if (netif_msg_drv(pegasus)) 397 if (netif_msg_drv(pegasus))
393 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); 398 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__);
394 return -1; 399 return -ETIMEDOUT;
395} 400}
396 401
397#ifdef PEGASUS_WRITE_EEPROM 402#ifdef PEGASUS_WRITE_EEPROM
@@ -400,8 +405,8 @@ static inline void enable_eprom_write(pegasus_t * pegasus)
400 __u8 tmp; 405 __u8 tmp;
401 int ret; 406 int ret;
402 407
403 ret = get_registers(pegasus, EthCtrl2, 1, &tmp); 408 get_registers(pegasus, EthCtrl2, 1, &tmp);
404 ret = set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE); 409 set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE);
405} 410}
406 411
407static inline void disable_eprom_write(pegasus_t * pegasus) 412static inline void disable_eprom_write(pegasus_t * pegasus)
@@ -409,9 +414,9 @@ static inline void disable_eprom_write(pegasus_t * pegasus)
409 __u8 tmp; 414 __u8 tmp;
410 int ret; 415 int ret;
411 416
412 ret = get_registers(pegasus, EthCtrl2, 1, &tmp); 417 get_registers(pegasus, EthCtrl2, 1, &tmp);
413 ret = set_register(pegasus, EpromCtrl, 0); 418 set_register(pegasus, EpromCtrl, 0);
414 ret = set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE); 419 set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE);
415} 420}
416 421
417static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data) 422static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data)
@@ -420,11 +425,11 @@ static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data)
420 __u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE }; 425 __u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE };
421 int ret; 426 int ret;
422 427
423 ret = set_registers(pegasus, EpromOffset, 4, d); 428 set_registers(pegasus, EpromOffset, 4, d);
424 enable_eprom_write(pegasus); 429 enable_eprom_write(pegasus);
425 ret = set_register(pegasus, EpromOffset, index); 430 set_register(pegasus, EpromOffset, index);
426 ret = set_registers(pegasus, EpromData, 2, &data); 431 set_registers(pegasus, EpromData, 2, &data);
427 ret = set_register(pegasus, EpromCtrl, EPROM_WRITE); 432 set_register(pegasus, EpromCtrl, EPROM_WRITE);
428 433
429 for (i = 0; i < REG_TIMEOUT; i++) { 434 for (i = 0; i < REG_TIMEOUT; i++) {
430 ret = get_registers(pegasus, EpromCtrl, 1, &tmp); 435 ret = get_registers(pegasus, EpromCtrl, 1, &tmp);
@@ -433,10 +438,10 @@ static int write_eprom_word(pegasus_t * pegasus, __u8 index, __u16 data)
433 } 438 }
434 disable_eprom_write(pegasus); 439 disable_eprom_write(pegasus);
435 if (i < REG_TIMEOUT) 440 if (i < REG_TIMEOUT)
436 return 0; 441 return ret;
437 if (netif_msg_drv(pegasus)) 442 if (netif_msg_drv(pegasus))
438 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__); 443 dev_warn(&pegasus->intf->dev, "fail %s\n", __FUNCTION__);
439 return -1; 444 return -ETIMEDOUT;
440} 445}
441#endif /* PEGASUS_WRITE_EEPROM */ 446#endif /* PEGASUS_WRITE_EEPROM */
442 447
@@ -454,10 +459,9 @@ static inline void get_node_id(pegasus_t * pegasus, __u8 * id)
454static void set_ethernet_addr(pegasus_t * pegasus) 459static void set_ethernet_addr(pegasus_t * pegasus)
455{ 460{
456 __u8 node_id[6]; 461 __u8 node_id[6];
457 int ret;
458 462
459 get_node_id(pegasus, node_id); 463 get_node_id(pegasus, node_id);
460 ret = set_registers(pegasus, EthID, sizeof (node_id), node_id); 464 set_registers(pegasus, EthID, sizeof (node_id), node_id);
461 memcpy(pegasus->net->dev_addr, node_id, sizeof (node_id)); 465 memcpy(pegasus->net->dev_addr, node_id, sizeof (node_id));
462} 466}
463 467
@@ -465,30 +469,29 @@ static inline int reset_mac(pegasus_t * pegasus)
465{ 469{
466 __u8 data = 0x8; 470 __u8 data = 0x8;
467 int i; 471 int i;
468 int ret;
469 472
470 ret = set_register(pegasus, EthCtrl1, data); 473 set_register(pegasus, EthCtrl1, data);
471 for (i = 0; i < REG_TIMEOUT; i++) { 474 for (i = 0; i < REG_TIMEOUT; i++) {
472 ret = get_registers(pegasus, EthCtrl1, 1, &data); 475 get_registers(pegasus, EthCtrl1, 1, &data);
473 if (~data & 0x08) { 476 if (~data & 0x08) {
474 if (loopback & 1) 477 if (loopback & 1)
475 break; 478 break;
476 if (mii_mode && (pegasus->features & HAS_HOME_PNA)) 479 if (mii_mode && (pegasus->features & HAS_HOME_PNA))
477 ret = set_register(pegasus, Gpio1, 0x34); 480 set_register(pegasus, Gpio1, 0x34);
478 else 481 else
479 ret = set_register(pegasus, Gpio1, 0x26); 482 set_register(pegasus, Gpio1, 0x26);
480 ret = set_register(pegasus, Gpio0, pegasus->features); 483 set_register(pegasus, Gpio0, pegasus->features);
481 ret = set_register(pegasus, Gpio0, DEFAULT_GPIO_SET); 484 set_register(pegasus, Gpio0, DEFAULT_GPIO_SET);
482 break; 485 break;
483 } 486 }
484 } 487 }
485 if (i == REG_TIMEOUT) 488 if (i == REG_TIMEOUT)
486 return 1; 489 return -ETIMEDOUT;
487 490
488 if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS || 491 if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS ||
489 usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) { 492 usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) {
490 ret = set_register(pegasus, Gpio0, 0x24); 493 set_register(pegasus, Gpio0, 0x24);
491 ret = set_register(pegasus, Gpio0, 0x26); 494 set_register(pegasus, Gpio0, 0x26);
492 } 495 }
493 if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_ELCON) { 496 if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_ELCON) {
494 __u16 auxmode; 497 __u16 auxmode;
@@ -527,7 +530,7 @@ static int enable_net_traffic(struct net_device *dev, struct usb_device *usb)
527 write_mii_word(pegasus, 0, 0x1b, auxmode | 4); 530 write_mii_word(pegasus, 0, 0x1b, auxmode | 4);
528 } 531 }
529 532
530 return 0; 533 return ret;
531} 534}
532 535
533static void fill_skb_pool(pegasus_t * pegasus) 536static void fill_skb_pool(pegasus_t * pegasus)
@@ -881,9 +884,8 @@ static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev)
881static inline void disable_net_traffic(pegasus_t * pegasus) 884static inline void disable_net_traffic(pegasus_t * pegasus)
882{ 885{
883 int tmp = 0; 886 int tmp = 0;
884 int ret;
885 887
886 ret = set_registers(pegasus, EthCtrl0, 2, &tmp); 888 set_registers(pegasus, EthCtrl0, 2, &tmp);
887} 889}
888 890
889static inline void get_interrupt_interval(pegasus_t * pegasus) 891static inline void get_interrupt_interval(pegasus_t * pegasus)
@@ -1206,18 +1208,17 @@ static __u8 mii_phy_probe(pegasus_t * pegasus)
1206static inline void setup_pegasus_II(pegasus_t * pegasus) 1208static inline void setup_pegasus_II(pegasus_t * pegasus)
1207{ 1209{
1208 __u8 data = 0xa5; 1210 __u8 data = 0xa5;
1209 int ret;
1210 1211
1211 ret = set_register(pegasus, Reg1d, 0); 1212 set_register(pegasus, Reg1d, 0);
1212 ret = set_register(pegasus, Reg7b, 1); 1213 set_register(pegasus, Reg7b, 1);
1213 mdelay(100); 1214 mdelay(100);
1214 if ((pegasus->features & HAS_HOME_PNA) && mii_mode) 1215 if ((pegasus->features & HAS_HOME_PNA) && mii_mode)
1215 ret = set_register(pegasus, Reg7b, 0); 1216 set_register(pegasus, Reg7b, 0);
1216 else 1217 else
1217 ret = set_register(pegasus, Reg7b, 2); 1218 set_register(pegasus, Reg7b, 2);
1218 1219
1219 ret = set_register(pegasus, 0x83, data); 1220 set_register(pegasus, 0x83, data);
1220 ret = get_registers(pegasus, 0x83, 1, &data); 1221 get_registers(pegasus, 0x83, 1, &data);
1221 1222
1222 if (data == 0xa5) { 1223 if (data == 0xa5) {
1223 pegasus->chip = 0x8513; 1224 pegasus->chip = 0x8513;
@@ -1225,14 +1226,14 @@ static inline void setup_pegasus_II(pegasus_t * pegasus)
1225 pegasus->chip = 0; 1226 pegasus->chip = 0;
1226 } 1227 }
1227 1228
1228 ret = set_register(pegasus, 0x80, 0xc0); 1229 set_register(pegasus, 0x80, 0xc0);
1229 ret = set_register(pegasus, 0x83, 0xff); 1230 set_register(pegasus, 0x83, 0xff);
1230 ret = set_register(pegasus, 0x84, 0x01); 1231 set_register(pegasus, 0x84, 0x01);
1231 1232
1232 if (pegasus->features & HAS_HOME_PNA && mii_mode) 1233 if (pegasus->features & HAS_HOME_PNA && mii_mode)
1233 ret = set_register(pegasus, Reg81, 6); 1234 set_register(pegasus, Reg81, 6);
1234 else 1235 else
1235 ret = set_register(pegasus, Reg81, 2); 1236 set_register(pegasus, Reg81, 2);
1236} 1237}
1237 1238
1238 1239
@@ -1414,9 +1415,42 @@ static struct usb_driver pegasus_driver = {
1414 .resume = pegasus_resume, 1415 .resume = pegasus_resume,
1415}; 1416};
1416 1417
1418static void parse_id(char *id)
1419{
1420 unsigned int vendor_id=0, device_id=0, flags=0, i=0;
1421 char *token, *name=NULL;
1422
1423 if ((token = strsep(&id, ":")) != NULL)
1424 name = token;
1425 /* name now points to a null terminated string*/
1426 if ((token = strsep(&id, ":")) != NULL)
1427 vendor_id = simple_strtoul(token, NULL, 16);
1428 if ((token = strsep(&id, ":")) != NULL)
1429 device_id = simple_strtoul(token, NULL, 16);
1430 flags = simple_strtoul(id, NULL, 16);
1431 pr_info("%s: new device %s, vendor ID 0x%04x, device ID 0x%04x, flags: 0x%x\n",
1432 driver_name, name, vendor_id, device_id, flags);
1433
1434 if (vendor_id > 0x10000 || vendor_id == 0)
1435 return;
1436 if (device_id > 0x10000 || device_id == 0)
1437 return;
1438
1439 for (i=0; usb_dev_id[i].name; i++);
1440 usb_dev_id[i].name = name;
1441 usb_dev_id[i].vendor = vendor_id;
1442 usb_dev_id[i].device = device_id;
1443 usb_dev_id[i].private = flags;
1444 pegasus_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
1445 pegasus_ids[i].idVendor = vendor_id;
1446 pegasus_ids[i].idProduct = device_id;
1447}
1448
1417static int __init pegasus_init(void) 1449static int __init pegasus_init(void)
1418{ 1450{
1419 pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION); 1451 pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION);
1452 if (devid)
1453 parse_id(devid);
1420 pegasus_workqueue = create_singlethread_workqueue("pegasus"); 1454 pegasus_workqueue = create_singlethread_workqueue("pegasus");
1421 if (!pegasus_workqueue) 1455 if (!pegasus_workqueue)
1422 return -ENOMEM; 1456 return -ENOMEM;
diff --git a/drivers/usb/net/plusb.c b/drivers/usb/net/plusb.c
index 89856aa0e3b8..4fe863389cb7 100644
--- a/drivers/usb/net/plusb.c
+++ b/drivers/usb/net/plusb.c
@@ -127,7 +127,6 @@ static const struct usb_device_id products [] = {
127MODULE_DEVICE_TABLE(usb, products); 127MODULE_DEVICE_TABLE(usb, products);
128 128
129static struct usb_driver plusb_driver = { 129static struct usb_driver plusb_driver = {
130 .owner = THIS_MODULE,
131 .name = "plusb", 130 .name = "plusb",
132 .id_table = products, 131 .id_table = products,
133 .probe = usbnet_probe, 132 .probe = usbnet_probe,
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index c0ecbab6f6ba..49991ac1bf3b 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -586,7 +586,6 @@ static const struct usb_device_id products [] = {
586MODULE_DEVICE_TABLE(usb, products); 586MODULE_DEVICE_TABLE(usb, products);
587 587
588static struct usb_driver rndis_driver = { 588static struct usb_driver rndis_driver = {
589 .owner = THIS_MODULE,
590 .name = "rndis_host", 589 .name = "rndis_host",
591 .id_table = products, 590 .id_table = products,
592 .probe = usbnet_probe, 591 .probe = usbnet_probe,
diff --git a/drivers/usb/net/rtl8150.c b/drivers/usb/net/rtl8150.c
index 787dd3591d6a..8ca52be23976 100644
--- a/drivers/usb/net/rtl8150.c
+++ b/drivers/usb/net/rtl8150.c
@@ -177,7 +177,6 @@ static int rtl8150_probe(struct usb_interface *intf,
177static const char driver_name [] = "rtl8150"; 177static const char driver_name [] = "rtl8150";
178 178
179static struct usb_driver rtl8150_driver = { 179static struct usb_driver rtl8150_driver = {
180 .owner = THIS_MODULE,
181 .name = driver_name, 180 .name = driver_name,
182 .probe = rtl8150_probe, 181 .probe = rtl8150_probe,
183 .disconnect = rtl8150_disconnect, 182 .disconnect = rtl8150_disconnect,
diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c
index 680d13957af4..9c5ab251370c 100644
--- a/drivers/usb/net/zaurus.c
+++ b/drivers/usb/net/zaurus.c
@@ -357,7 +357,6 @@ static const struct usb_device_id products [] = {
357MODULE_DEVICE_TABLE(usb, products); 357MODULE_DEVICE_TABLE(usb, products);
358 358
359static struct usb_driver zaurus_driver = { 359static struct usb_driver zaurus_driver = {
360 .owner = THIS_MODULE,
361 .name = "zaurus", 360 .name = "zaurus",
362 .id_table = products, 361 .id_table = products,
363 .probe = usbnet_probe, 362 .probe = usbnet_probe,
diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c
index 2f52261c7cc1..f3a8e2807c3b 100644
--- a/drivers/usb/net/zd1201.c
+++ b/drivers/usb/net/zd1201.c
@@ -1722,7 +1722,7 @@ static const struct iw_priv_args zd1201_private_args[] = {
1722 IW_PRIV_TYPE_NONE, "sethostauth" }, 1722 IW_PRIV_TYPE_NONE, "sethostauth" },
1723 { ZD1201GIWHOSTAUTH, IW_PRIV_TYPE_NONE, 1723 { ZD1201GIWHOSTAUTH, IW_PRIV_TYPE_NONE,
1724 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostauth" }, 1724 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostauth" },
1725 { ZD1201SIWAUTHSTA, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 1725 { ZD1201SIWAUTHSTA, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1,
1726 IW_PRIV_TYPE_NONE, "authstation" }, 1726 IW_PRIV_TYPE_NONE, "authstation" },
1727 { ZD1201SIWMAXASSOC, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 1727 { ZD1201SIWMAXASSOC, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
1728 IW_PRIV_TYPE_NONE, "setmaxassoc" }, 1728 IW_PRIV_TYPE_NONE, "setmaxassoc" },
@@ -1731,9 +1731,9 @@ static const struct iw_priv_args zd1201_private_args[] = {
1731}; 1731};
1732 1732
1733static const struct iw_handler_def zd1201_iw_handlers = { 1733static const struct iw_handler_def zd1201_iw_handlers = {
1734 .num_standard = sizeof(zd1201_iw_handler)/sizeof(iw_handler), 1734 .num_standard = ARRAY_SIZE(zd1201_iw_handler),
1735 .num_private = sizeof(zd1201_private_handler)/sizeof(iw_handler), 1735 .num_private = ARRAY_SIZE(zd1201_private_handler),
1736 .num_private_args = sizeof(zd1201_private_args)/sizeof(struct iw_priv_args), 1736 .num_private_args = ARRAY_SIZE(zd1201_private_args),
1737 .standard = (iw_handler *)zd1201_iw_handler, 1737 .standard = (iw_handler *)zd1201_iw_handler,
1738 .private = (iw_handler *)zd1201_private_handler, 1738 .private = (iw_handler *)zd1201_private_handler,
1739 .private_args = (struct iw_priv_args *) zd1201_private_args, 1739 .private_args = (struct iw_priv_args *) zd1201_private_args,
@@ -1829,6 +1829,8 @@ static int zd1201_probe(struct usb_interface *interface,
1829 if (err) 1829 if (err)
1830 goto err_net; 1830 goto err_net;
1831 1831
1832 SET_NETDEV_DEV(zd->dev, &usb->dev);
1833
1832 err = register_netdev(zd->dev); 1834 err = register_netdev(zd->dev);
1833 if (err) 1835 if (err)
1834 goto err_net; 1836 goto err_net;
@@ -1923,7 +1925,6 @@ static int zd1201_resume(struct usb_interface *interface)
1923#endif 1925#endif
1924 1926
1925static struct usb_driver zd1201_usb = { 1927static struct usb_driver zd1201_usb = {
1926 .owner = THIS_MODULE,
1927 .name = "zd1201", 1928 .name = "zd1201",
1928 .probe = zd1201_probe, 1929 .probe = zd1201_probe,
1929 .disconnect = zd1201_disconnect, 1930 .disconnect = zd1201_disconnect,
diff --git a/drivers/usb/serial/airprime.c b/drivers/usb/serial/airprime.c
index 1f29d8837327..dbf1f063098c 100644
--- a/drivers/usb/serial/airprime.c
+++ b/drivers/usb/serial/airprime.c
@@ -23,11 +23,11 @@ static struct usb_device_id id_table [] = {
23MODULE_DEVICE_TABLE(usb, id_table); 23MODULE_DEVICE_TABLE(usb, id_table);
24 24
25static struct usb_driver airprime_driver = { 25static struct usb_driver airprime_driver = {
26 .owner = THIS_MODULE,
27 .name = "airprime", 26 .name = "airprime",
28 .probe = usb_serial_probe, 27 .probe = usb_serial_probe,
29 .disconnect = usb_serial_disconnect, 28 .disconnect = usb_serial_disconnect,
30 .id_table = id_table, 29 .id_table = id_table,
30 .no_dynamic_id = 1,
31}; 31};
32 32
33static struct usb_serial_driver airprime_device = { 33static struct usb_serial_driver airprime_device = {
diff --git a/drivers/usb/serial/anydata.c b/drivers/usb/serial/anydata.c
index 18022a74a3dc..343f6f228220 100644
--- a/drivers/usb/serial/anydata.c
+++ b/drivers/usb/serial/anydata.c
@@ -27,11 +27,11 @@ static int buffer_size;
27static int debug; 27static int debug;
28 28
29static struct usb_driver anydata_driver = { 29static struct usb_driver anydata_driver = {
30 .owner = THIS_MODULE,
31 .name = "anydata", 30 .name = "anydata",
32 .probe = usb_serial_probe, 31 .probe = usb_serial_probe,
33 .disconnect = usb_serial_disconnect, 32 .disconnect = usb_serial_disconnect,
34 .id_table = id_table, 33 .id_table = id_table,
34 .no_dynamic_id = 1,
35}; 35};
36 36
37static int anydata_open(struct usb_serial_port *port, struct file *filp) 37static int anydata_open(struct usb_serial_port *port, struct file *filp)
diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c
index 84bc0ee4f061..4144777ea18b 100644
--- a/drivers/usb/serial/belkin_sa.c
+++ b/drivers/usb/serial/belkin_sa.c
@@ -113,11 +113,11 @@ static struct usb_device_id id_table_combined [] = {
113MODULE_DEVICE_TABLE (usb, id_table_combined); 113MODULE_DEVICE_TABLE (usb, id_table_combined);
114 114
115static struct usb_driver belkin_driver = { 115static struct usb_driver belkin_driver = {
116 .owner = THIS_MODULE,
117 .name = "belkin", 116 .name = "belkin",
118 .probe = usb_serial_probe, 117 .probe = usb_serial_probe,
119 .disconnect = usb_serial_disconnect, 118 .disconnect = usb_serial_disconnect,
120 .id_table = id_table_combined, 119 .id_table = id_table_combined,
120 .no_dynamic_id = 1,
121}; 121};
122 122
123/* All of the device info needed for the serial converters */ 123/* All of the device info needed for the serial converters */
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index c9787001cf2a..da46b351e188 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -67,11 +67,11 @@ static struct usb_device_id id_table [] = {
67MODULE_DEVICE_TABLE (usb, id_table); 67MODULE_DEVICE_TABLE (usb, id_table);
68 68
69static struct usb_driver cp2101_driver = { 69static struct usb_driver cp2101_driver = {
70 .owner = THIS_MODULE,
71 .name = "cp2101", 70 .name = "cp2101",
72 .probe = usb_serial_probe, 71 .probe = usb_serial_probe,
73 .disconnect = usb_serial_disconnect, 72 .disconnect = usb_serial_disconnect,
74 .id_table = id_table, 73 .id_table = id_table,
74 .no_dynamic_id = 1,
75}; 75};
76 76
77static struct usb_serial_driver cp2101_device = { 77static struct usb_serial_driver cp2101_device = {
diff --git a/drivers/usb/serial/cyberjack.c b/drivers/usb/serial/cyberjack.c
index e581e4ae8483..6d18d4eaba35 100644
--- a/drivers/usb/serial/cyberjack.c
+++ b/drivers/usb/serial/cyberjack.c
@@ -76,11 +76,11 @@ static struct usb_device_id id_table [] = {
76MODULE_DEVICE_TABLE (usb, id_table); 76MODULE_DEVICE_TABLE (usb, id_table);
77 77
78static struct usb_driver cyberjack_driver = { 78static struct usb_driver cyberjack_driver = {
79 .owner = THIS_MODULE,
80 .name = "cyberjack", 79 .name = "cyberjack",
81 .probe = usb_serial_probe, 80 .probe = usb_serial_probe,
82 .disconnect = usb_serial_disconnect, 81 .disconnect = usb_serial_disconnect,
83 .id_table = id_table, 82 .id_table = id_table,
83 .no_dynamic_id = 1,
84}; 84};
85 85
86static struct usb_serial_driver cyberjack_device = { 86static struct usb_serial_driver cyberjack_device = {
diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c
index af9290ed257b..af18355e94cc 100644
--- a/drivers/usb/serial/cypress_m8.c
+++ b/drivers/usb/serial/cypress_m8.c
@@ -112,6 +112,7 @@ static struct usb_driver cypress_driver = {
112 .probe = usb_serial_probe, 112 .probe = usb_serial_probe,
113 .disconnect = usb_serial_disconnect, 113 .disconnect = usb_serial_disconnect,
114 .id_table = id_table_combined, 114 .id_table = id_table_combined,
115 .no_dynamic_id = 1,
115}; 116};
116 117
117struct cypress_private { 118struct cypress_private {
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index dc74644a603d..8fc414bd5b24 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -493,11 +493,11 @@ static struct usb_device_id id_table_4 [] = {
493MODULE_DEVICE_TABLE (usb, id_table_combined); 493MODULE_DEVICE_TABLE (usb, id_table_combined);
494 494
495static struct usb_driver digi_driver = { 495static struct usb_driver digi_driver = {
496 .owner = THIS_MODULE,
497 .name = "digi_acceleport", 496 .name = "digi_acceleport",
498 .probe = usb_serial_probe, 497 .probe = usb_serial_probe,
499 .disconnect = usb_serial_disconnect, 498 .disconnect = usb_serial_disconnect,
500 .id_table = id_table_combined, 499 .id_table = id_table_combined,
500 .no_dynamic_id = 1,
501}; 501};
502 502
503 503
diff --git a/drivers/usb/serial/empeg.c b/drivers/usb/serial/empeg.c
index 0b0546dcc7b9..79a766e9ca23 100644
--- a/drivers/usb/serial/empeg.c
+++ b/drivers/usb/serial/empeg.c
@@ -105,11 +105,11 @@ static struct usb_device_id id_table [] = {
105MODULE_DEVICE_TABLE (usb, id_table); 105MODULE_DEVICE_TABLE (usb, id_table);
106 106
107static struct usb_driver empeg_driver = { 107static struct usb_driver empeg_driver = {
108 .owner = THIS_MODULE,
109 .name = "empeg", 108 .name = "empeg",
110 .probe = usb_serial_probe, 109 .probe = usb_serial_probe,
111 .disconnect = usb_serial_disconnect, 110 .disconnect = usb_serial_disconnect,
112 .id_table = id_table, 111 .id_table = id_table,
112 .no_dynamic_id = 1,
113}; 113};
114 114
115static struct usb_serial_driver empeg_device = { 115static struct usb_serial_driver empeg_device = {
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 06e04b442ff1..eb863b3f2d79 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -471,12 +471,15 @@ static struct usb_device_id id_table_combined [] = {
471 { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) }, 471 { USB_DEVICE(FTDI_VID, FTDI_ACTIVE_ROBOTS_PID) },
472 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) }, 472 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y6_PID) },
473 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) }, 473 { USB_DEVICE(FTDI_VID, FTDI_MHAM_Y8_PID) },
474 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_VCP_PID) },
475 { USB_DEVICE(FTDI_VID, FTDI_TERATRONIK_D2XX_PID) },
474 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) }, 476 { USB_DEVICE(EVOLUTION_VID, EVOLUTION_ER1_PID) },
475 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 477 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
476 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 478 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
477 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, 479 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) },
478 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) }, 480 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) },
479 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) }, 481 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) },
482 { USB_DEVICE(POSIFLEX_VID, POSIFLEX_PP7000_PID) },
480 { }, /* Optional parameter entry */ 483 { }, /* Optional parameter entry */
481 { } /* Terminating entry */ 484 { } /* Terminating entry */
482}; 485};
@@ -488,9 +491,10 @@ static struct usb_driver ftdi_driver = {
488 .probe = usb_serial_probe, 491 .probe = usb_serial_probe,
489 .disconnect = usb_serial_disconnect, 492 .disconnect = usb_serial_disconnect,
490 .id_table = id_table_combined, 493 .id_table = id_table_combined,
494 .no_dynamic_id = 1,
491}; 495};
492 496
493static char *ftdi_chip_name[] = { 497static const char *ftdi_chip_name[] = {
494 [SIO] = "SIO", /* the serial part of FT8U100AX */ 498 [SIO] = "SIO", /* the serial part of FT8U100AX */
495 [FT8U232AM] = "FT8U232AM", 499 [FT8U232AM] = "FT8U232AM",
496 [FT232BM] = "FT232BM", 500 [FT232BM] = "FT232BM",
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 773ea3eca086..00d45f8600de 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -343,6 +343,13 @@
343#define XSENS_CONVERTER_7_PID 0xD38F 343#define XSENS_CONVERTER_7_PID 0xD38F
344 344
345/* 345/*
346 * Teratronik product ids.
347 * Submitted by O. Wölfelschneider.
348 */
349#define FTDI_TERATRONIK_VCP_PID 0xEC88 /* Teratronik device (preferring VCP driver on windows) */
350#define FTDI_TERATRONIK_D2XX_PID 0xEC89 /* Teratronik device (preferring D2XX driver on windows) */
351
352/*
346 * Evolution Robotics products (http://www.evolution.com/). 353 * Evolution Robotics products (http://www.evolution.com/).
347 * Submitted by Shawn M. Lavelle. 354 * Submitted by Shawn M. Lavelle.
348 */ 355 */
@@ -352,6 +359,12 @@
352/* Pyramid Computer GmbH */ 359/* Pyramid Computer GmbH */
353#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */ 360#define FTDI_PYRAMID_PID 0xE6C8 /* Pyramid Appliance Display */
354 361
362/*
363 * Posiflex inc retail equipment (http://www.posiflex.com.tw)
364 */
365#define POSIFLEX_VID 0x0d3a /* Vendor ID */
366#define POSIFLEX_PP7000_PID 0x0300 /* PP-7000II thermal printer */
367
355/* Commands */ 368/* Commands */
356#define FTDI_SIO_RESET 0 /* Reset the port */ 369#define FTDI_SIO_RESET 0 /* Reset the port */
357#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */ 370#define FTDI_SIO_MODEM_CTRL 1 /* Set the modem control register */
@@ -714,7 +727,7 @@ typedef enum {
714 */ 727 */
715 728
716/* FTDI_SIO_GET_MODEM_STATUS */ 729/* FTDI_SIO_GET_MODEM_STATUS */
717/* Retreive the current value of the modem status register */ 730/* Retrieve the current value of the modem status register */
718 731
719#define FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE 0xc0 732#define FTDI_SIO_GET_MODEM_STATUS_REQUEST_TYPE 0xc0
720#define FTDI_SIO_GET_MODEM_STATUS_REQUEST FTDI_SIO_GET_MODEM_STATUS 733#define FTDI_SIO_GET_MODEM_STATUS_REQUEST FTDI_SIO_GET_MODEM_STATUS
diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 35820bda7ae1..452efce72714 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -222,11 +222,11 @@ static struct usb_device_id id_table [] = {
222MODULE_DEVICE_TABLE (usb, id_table); 222MODULE_DEVICE_TABLE (usb, id_table);
223 223
224static struct usb_driver garmin_driver = { 224static struct usb_driver garmin_driver = {
225 .owner = THIS_MODULE,
226 .name = "garmin_gps", 225 .name = "garmin_gps",
227 .probe = usb_serial_probe, 226 .probe = usb_serial_probe,
228 .disconnect = usb_serial_disconnect, 227 .disconnect = usb_serial_disconnect,
229 .id_table = id_table, 228 .id_table = id_table,
229 .no_dynamic_id = 1,
230}; 230};
231 231
232 232
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 53a47c31cd0e..4ddac620fc0c 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -68,11 +68,11 @@ static int generic_probe(struct usb_interface *interface,
68} 68}
69 69
70static struct usb_driver generic_driver = { 70static struct usb_driver generic_driver = {
71 .owner = THIS_MODULE,
72 .name = "usbserial_generic", 71 .name = "usbserial_generic",
73 .probe = generic_probe, 72 .probe = generic_probe,
74 .disconnect = usb_serial_disconnect, 73 .disconnect = usb_serial_disconnect,
75 .id_table = generic_serial_ids, 74 .id_table = generic_serial_ids,
75 .no_dynamic_id = 1,
76}; 76};
77#endif 77#endif
78 78
diff --git a/drivers/usb/serial/hp4x.c b/drivers/usb/serial/hp4x.c
index 8eadfb705601..e9719da2aca1 100644
--- a/drivers/usb/serial/hp4x.c
+++ b/drivers/usb/serial/hp4x.c
@@ -37,11 +37,11 @@ static struct usb_device_id id_table [] = {
37MODULE_DEVICE_TABLE(usb, id_table); 37MODULE_DEVICE_TABLE(usb, id_table);
38 38
39static struct usb_driver hp49gp_driver = { 39static struct usb_driver hp49gp_driver = {
40 .owner = THIS_MODULE,
41 .name = "hp4X", 40 .name = "hp4X",
42 .probe = usb_serial_probe, 41 .probe = usb_serial_probe,
43 .disconnect = usb_serial_disconnect, 42 .disconnect = usb_serial_disconnect,
44 .id_table = id_table, 43 .id_table = id_table,
44 .no_dynamic_id = 1,
45}; 45};
46 46
47static struct usb_serial_driver hp49gp_device = { 47static struct usb_serial_driver hp49gp_device = {
diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c
index dc4c498bd1ed..faedbeb6ba49 100644
--- a/drivers/usb/serial/io_edgeport.c
+++ b/drivers/usb/serial/io_edgeport.c
@@ -184,7 +184,7 @@ struct divisor_table_entry {
184// These assume a 3.6864MHz crystal, the standard /16, and 184// These assume a 3.6864MHz crystal, the standard /16, and
185// MCR.7 = 0. 185// MCR.7 = 0.
186// 186//
187static struct divisor_table_entry divisor_table[] = { 187static const struct divisor_table_entry divisor_table[] = {
188 { 50, 4608}, 188 { 50, 4608},
189 { 75, 3072}, 189 { 75, 3072},
190 { 110, 2095}, /* 2094.545455 => 230450 => .0217 % over */ 190 { 110, 2095}, /* 2094.545455 => 230450 => .0217 % over */
@@ -242,11 +242,11 @@ static void edge_shutdown (struct usb_serial *serial);
242#include "io_tables.h" /* all of the devices that this driver supports */ 242#include "io_tables.h" /* all of the devices that this driver supports */
243 243
244static struct usb_driver io_driver = { 244static struct usb_driver io_driver = {
245 .owner = THIS_MODULE,
246 .name = "io_edgeport", 245 .name = "io_edgeport",
247 .probe = usb_serial_probe, 246 .probe = usb_serial_probe,
248 .disconnect = usb_serial_disconnect, 247 .disconnect = usb_serial_disconnect,
249 .id_table = id_table_combined, 248 .id_table = id_table_combined,
249 .no_dynamic_id = 1,
250}; 250};
251 251
252/* function prototypes for all of our local functions */ 252/* function prototypes for all of our local functions */
@@ -2353,7 +2353,7 @@ static int calc_baud_rate_divisor (int baudrate, int *divisor)
2353 2353
2354 dbg("%s - %d", __FUNCTION__, baudrate); 2354 dbg("%s - %d", __FUNCTION__, baudrate);
2355 2355
2356 for (i = 0; i < NUM_ENTRIES(divisor_table); i++) { 2356 for (i = 0; i < ARRAY_SIZE(divisor_table); i++) {
2357 if ( divisor_table[i].BaudRate == baudrate ) { 2357 if ( divisor_table[i].BaudRate == baudrate ) {
2358 *divisor = divisor_table[i].Divisor; 2358 *divisor = divisor_table[i].Divisor;
2359 return 0; 2359 return 0;
diff --git a/drivers/usb/serial/io_edgeport.h b/drivers/usb/serial/io_edgeport.h
index 5112d7aac055..123fa8a904e6 100644
--- a/drivers/usb/serial/io_edgeport.h
+++ b/drivers/usb/serial/io_edgeport.h
@@ -31,9 +31,6 @@
31#ifndef HIGH8 31#ifndef HIGH8
32 #define HIGH8(a) ((unsigned char)((a & 0xff00) >> 8)) 32 #define HIGH8(a) ((unsigned char)((a & 0xff00) >> 8))
33#endif 33#endif
34#ifndef NUM_ENTRIES
35 #define NUM_ENTRIES(x) (sizeof(x)/sizeof((x)[0]))
36#endif
37 34
38#ifndef __KERNEL__ 35#ifndef __KERNEL__
39#define __KERNEL__ 36#define __KERNEL__
diff --git a/drivers/usb/serial/io_fw_boot2.h b/drivers/usb/serial/io_fw_boot2.h
index c7c3a3c305fe..e3463de99de4 100644
--- a/drivers/usb/serial/io_fw_boot2.h
+++ b/drivers/usb/serial/io_fw_boot2.h
@@ -537,7 +537,7 @@ static unsigned char IMAGE_ARRAY_NAME[] = {
537 537
538}; 538};
539 539
540static struct edge_firmware_version_info IMAGE_VERSION_NAME = { 540static const struct edge_firmware_version_info IMAGE_VERSION_NAME = {
541 2, 0, 3 }; // Major, Minor, Build 541 2, 0, 3 }; // Major, Minor, Build
542 542
543#undef IMAGE_VERSION_NAME 543#undef IMAGE_VERSION_NAME
diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c
index 832b6d6734c0..2edf9cabad20 100644
--- a/drivers/usb/serial/io_ti.c
+++ b/drivers/usb/serial/io_ti.c
@@ -216,11 +216,11 @@ static struct usb_device_id id_table_combined [] = {
216MODULE_DEVICE_TABLE (usb, id_table_combined); 216MODULE_DEVICE_TABLE (usb, id_table_combined);
217 217
218static struct usb_driver io_driver = { 218static struct usb_driver io_driver = {
219 .owner = THIS_MODULE,
220 .name = "io_ti", 219 .name = "io_ti",
221 .probe = usb_serial_probe, 220 .probe = usb_serial_probe,
222 .disconnect = usb_serial_disconnect, 221 .disconnect = usb_serial_disconnect,
223 .id_table = id_table_combined, 222 .id_table = id_table_combined,
223 .no_dynamic_id = 1,
224}; 224};
225 225
226 226
@@ -2843,7 +2843,7 @@ static struct edge_buf *edge_buf_alloc(unsigned int size)
2843 * Free the buffer and all associated memory. 2843 * Free the buffer and all associated memory.
2844 */ 2844 */
2845 2845
2846void edge_buf_free(struct edge_buf *eb) 2846static void edge_buf_free(struct edge_buf *eb)
2847{ 2847{
2848 if (eb) { 2848 if (eb) {
2849 kfree(eb->buf_buf); 2849 kfree(eb->buf_buf);
diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c
index d5d066488100..06d07cea0b70 100644
--- a/drivers/usb/serial/ipaq.c
+++ b/drivers/usb/serial/ipaq.c
@@ -542,11 +542,11 @@ static struct usb_device_id ipaq_id_table [] = {
542MODULE_DEVICE_TABLE (usb, ipaq_id_table); 542MODULE_DEVICE_TABLE (usb, ipaq_id_table);
543 543
544static struct usb_driver ipaq_driver = { 544static struct usb_driver ipaq_driver = {
545 .owner = THIS_MODULE,
546 .name = "ipaq", 545 .name = "ipaq",
547 .probe = usb_serial_probe, 546 .probe = usb_serial_probe,
548 .disconnect = usb_serial_disconnect, 547 .disconnect = usb_serial_disconnect,
549 .id_table = ipaq_id_table, 548 .id_table = ipaq_id_table,
549 .no_dynamic_id = 1,
550}; 550};
551 551
552 552
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index 7744b8148bc5..2dd191f5fe76 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -152,11 +152,11 @@ static struct usb_device_id usb_ipw_ids[] = {
152MODULE_DEVICE_TABLE(usb, usb_ipw_ids); 152MODULE_DEVICE_TABLE(usb, usb_ipw_ids);
153 153
154static struct usb_driver usb_ipw_driver = { 154static struct usb_driver usb_ipw_driver = {
155 .owner = THIS_MODULE,
156 .name = "ipwtty", 155 .name = "ipwtty",
157 .probe = usb_serial_probe, 156 .probe = usb_serial_probe,
158 .disconnect = usb_serial_disconnect, 157 .disconnect = usb_serial_disconnect,
159 .id_table = usb_ipw_ids, 158 .id_table = usb_ipw_ids,
159 .no_dynamic_id = 1,
160}; 160};
161 161
162static int debug; 162static int debug;
diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 19f329e9bdcf..a59010421444 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -125,11 +125,11 @@ static struct usb_device_id id_table [] = {
125MODULE_DEVICE_TABLE (usb, id_table); 125MODULE_DEVICE_TABLE (usb, id_table);
126 126
127static struct usb_driver ir_driver = { 127static struct usb_driver ir_driver = {
128 .owner = THIS_MODULE,
129 .name = "ir-usb", 128 .name = "ir-usb",
130 .probe = usb_serial_probe, 129 .probe = usb_serial_probe,
131 .disconnect = usb_serial_disconnect, 130 .disconnect = usb_serial_disconnect,
132 .id_table = id_table, 131 .id_table = id_table,
132 .no_dynamic_id = 1,
133}; 133};
134 134
135 135
diff --git a/drivers/usb/serial/keyspan.h b/drivers/usb/serial/keyspan.h
index 5cfc13b5e56f..7472ed6bf626 100644
--- a/drivers/usb/serial/keyspan.h
+++ b/drivers/usb/serial/keyspan.h
@@ -520,11 +520,11 @@ static struct usb_device_id keyspan_ids_combined[] = {
520MODULE_DEVICE_TABLE(usb, keyspan_ids_combined); 520MODULE_DEVICE_TABLE(usb, keyspan_ids_combined);
521 521
522static struct usb_driver keyspan_driver = { 522static struct usb_driver keyspan_driver = {
523 .owner = THIS_MODULE,
524 .name = "keyspan", 523 .name = "keyspan",
525 .probe = usb_serial_probe, 524 .probe = usb_serial_probe,
526 .disconnect = usb_serial_disconnect, 525 .disconnect = usb_serial_disconnect,
527 .id_table = keyspan_ids_combined, 526 .id_table = keyspan_ids_combined,
527 .no_dynamic_id = 1,
528}; 528};
529 529
530/* usb_device_id table for the pre-firmware download keyspan devices */ 530/* usb_device_id table for the pre-firmware download keyspan devices */
diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c
index cd4f48bd83b6..b0441c35f98f 100644
--- a/drivers/usb/serial/keyspan_pda.c
+++ b/drivers/usb/serial/keyspan_pda.c
@@ -150,11 +150,11 @@ static struct usb_device_id id_table_combined [] = {
150MODULE_DEVICE_TABLE (usb, id_table_combined); 150MODULE_DEVICE_TABLE (usb, id_table_combined);
151 151
152static struct usb_driver keyspan_pda_driver = { 152static struct usb_driver keyspan_pda_driver = {
153 .owner = THIS_MODULE,
154 .name = "keyspan_pda", 153 .name = "keyspan_pda",
155 .probe = usb_serial_probe, 154 .probe = usb_serial_probe,
156 .disconnect = usb_serial_disconnect, 155 .disconnect = usb_serial_disconnect,
157 .id_table = id_table_combined, 156 .id_table = id_table_combined,
157 .no_dynamic_id = 1,
158}; 158};
159 159
160static struct usb_device_id id_table_std [] = { 160static struct usb_device_id id_table_std [] = {
diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c
index a8951c0fd020..4e2f7dfb58b2 100644
--- a/drivers/usb/serial/kl5kusb105.c
+++ b/drivers/usb/serial/kl5kusb105.c
@@ -116,11 +116,11 @@ static struct usb_device_id id_table [] = {
116MODULE_DEVICE_TABLE (usb, id_table); 116MODULE_DEVICE_TABLE (usb, id_table);
117 117
118static struct usb_driver kl5kusb105d_driver = { 118static struct usb_driver kl5kusb105d_driver = {
119 .owner = THIS_MODULE,
120 .name = "kl5kusb105d", 119 .name = "kl5kusb105d",
121 .probe = usb_serial_probe, 120 .probe = usb_serial_probe,
122 .disconnect = usb_serial_disconnect, 121 .disconnect = usb_serial_disconnect,
123 .id_table = id_table, 122 .id_table = id_table,
123 .no_dynamic_id = 1,
124}; 124};
125 125
126static struct usb_serial_driver kl5kusb105d_device = { 126static struct usb_serial_driver kl5kusb105d_device = {
diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
index 9456dd9dd136..d9c21e275130 100644
--- a/drivers/usb/serial/kobil_sct.c
+++ b/drivers/usb/serial/kobil_sct.c
@@ -97,11 +97,11 @@ static struct usb_device_id id_table [] = {
97MODULE_DEVICE_TABLE (usb, id_table); 97MODULE_DEVICE_TABLE (usb, id_table);
98 98
99static struct usb_driver kobil_driver = { 99static struct usb_driver kobil_driver = {
100 .owner = THIS_MODULE,
101 .name = "kobil", 100 .name = "kobil",
102 .probe = usb_serial_probe, 101 .probe = usb_serial_probe,
103 .disconnect = usb_serial_disconnect, 102 .disconnect = usb_serial_disconnect,
104 .id_table = id_table, 103 .id_table = id_table,
104 .no_dynamic_id = 1,
105}; 105};
106 106
107 107
diff --git a/drivers/usb/serial/mct_u232.c b/drivers/usb/serial/mct_u232.c
index ca5dbadb9b7e..b6d6cab9c859 100644
--- a/drivers/usb/serial/mct_u232.c
+++ b/drivers/usb/serial/mct_u232.c
@@ -125,11 +125,11 @@ static struct usb_device_id id_table_combined [] = {
125MODULE_DEVICE_TABLE (usb, id_table_combined); 125MODULE_DEVICE_TABLE (usb, id_table_combined);
126 126
127static struct usb_driver mct_u232_driver = { 127static struct usb_driver mct_u232_driver = {
128 .owner = THIS_MODULE,
129 .name = "mct_u232", 128 .name = "mct_u232",
130 .probe = usb_serial_probe, 129 .probe = usb_serial_probe,
131 .disconnect = usb_serial_disconnect, 130 .disconnect = usb_serial_disconnect,
132 .id_table = id_table_combined, 131 .id_table = id_table_combined,
132 .no_dynamic_id = 1,
133}; 133};
134 134
135static struct usb_serial_driver mct_u232_device = { 135static struct usb_serial_driver mct_u232_device = {
diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c
index 3caf97072ac0..762d8ff9a1e4 100644
--- a/drivers/usb/serial/omninet.c
+++ b/drivers/usb/serial/omninet.c
@@ -80,11 +80,11 @@ static struct usb_device_id id_table [] = {
80MODULE_DEVICE_TABLE (usb, id_table); 80MODULE_DEVICE_TABLE (usb, id_table);
81 81
82static struct usb_driver omninet_driver = { 82static struct usb_driver omninet_driver = {
83 .owner = THIS_MODULE,
84 .name = "omninet", 83 .name = "omninet",
85 .probe = usb_serial_probe, 84 .probe = usb_serial_probe,
86 .disconnect = usb_serial_disconnect, 85 .disconnect = usb_serial_disconnect,
87 .id_table = id_table, 86 .id_table = id_table,
87 .no_dynamic_id = 1,
88}; 88};
89 89
90 90
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 7716000045b7..3fd2405304fd 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -95,11 +95,11 @@ static struct usb_device_id option_ids[] = {
95MODULE_DEVICE_TABLE(usb, option_ids); 95MODULE_DEVICE_TABLE(usb, option_ids);
96 96
97static struct usb_driver option_driver = { 97static struct usb_driver option_driver = {
98 .owner = THIS_MODULE,
99 .name = "option", 98 .name = "option",
100 .probe = usb_serial_probe, 99 .probe = usb_serial_probe,
101 .disconnect = usb_serial_disconnect, 100 .disconnect = usb_serial_disconnect,
102 .id_table = option_ids, 101 .id_table = option_ids,
102 .no_dynamic_id = 1,
103}; 103};
104 104
105/* The card has three separate interfaces, wich the serial driver 105/* The card has three separate interfaces, wich the serial driver
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 41a45a5025b2..f03721056190 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -82,11 +82,11 @@ static struct usb_device_id id_table [] = {
82MODULE_DEVICE_TABLE (usb, id_table); 82MODULE_DEVICE_TABLE (usb, id_table);
83 83
84static struct usb_driver pl2303_driver = { 84static struct usb_driver pl2303_driver = {
85 .owner = THIS_MODULE,
86 .name = "pl2303", 85 .name = "pl2303",
87 .probe = usb_serial_probe, 86 .probe = usb_serial_probe,
88 .disconnect = usb_serial_disconnect, 87 .disconnect = usb_serial_disconnect,
89 .id_table = id_table, 88 .id_table = id_table,
89 .no_dynamic_id = 1,
90}; 90};
91 91
92#define SET_LINE_REQUEST_TYPE 0x21 92#define SET_LINE_REQUEST_TYPE 0x21
@@ -810,7 +810,7 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
810 struct pl2303_private *priv = usb_get_serial_port_data(port); 810 struct pl2303_private *priv = usb_get_serial_port_data(port);
811 unsigned long flags; 811 unsigned long flags;
812 u8 status_idx = UART_STATE; 812 u8 status_idx = UART_STATE;
813 u8 length = UART_STATE; 813 u8 length = UART_STATE + 1;
814 814
815 if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && 815 if ((le16_to_cpu(port->serial->dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) &&
816 (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65 || 816 (le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X65 ||
diff --git a/drivers/usb/serial/safe_serial.c b/drivers/usb/serial/safe_serial.c
index c22bdc0c4dfd..f0215f850d2d 100644
--- a/drivers/usb/serial/safe_serial.c
+++ b/drivers/usb/serial/safe_serial.c
@@ -160,14 +160,14 @@ static struct usb_device_id id_table[] = {
160MODULE_DEVICE_TABLE (usb, id_table); 160MODULE_DEVICE_TABLE (usb, id_table);
161 161
162static struct usb_driver safe_driver = { 162static struct usb_driver safe_driver = {
163 .owner = THIS_MODULE,
164 .name = "safe_serial", 163 .name = "safe_serial",
165 .probe = usb_serial_probe, 164 .probe = usb_serial_probe,
166 .disconnect = usb_serial_disconnect, 165 .disconnect = usb_serial_disconnect,
167 .id_table = id_table, 166 .id_table = id_table,
167 .no_dynamic_id = 1,
168}; 168};
169 169
170static __u16 crc10_table[256] = { 170static const __u16 crc10_table[256] = {
171 0x000, 0x233, 0x255, 0x066, 0x299, 0x0aa, 0x0cc, 0x2ff, 0x301, 0x132, 0x154, 0x367, 0x198, 0x3ab, 0x3cd, 0x1fe, 171 0x000, 0x233, 0x255, 0x066, 0x299, 0x0aa, 0x0cc, 0x2ff, 0x301, 0x132, 0x154, 0x367, 0x198, 0x3ab, 0x3cd, 0x1fe,
172 0x031, 0x202, 0x264, 0x057, 0x2a8, 0x09b, 0x0fd, 0x2ce, 0x330, 0x103, 0x165, 0x356, 0x1a9, 0x39a, 0x3fc, 0x1cf, 172 0x031, 0x202, 0x264, 0x057, 0x2a8, 0x09b, 0x0fd, 0x2ce, 0x330, 0x103, 0x165, 0x356, 0x1a9, 0x39a, 0x3fc, 0x1cf,
173 0x062, 0x251, 0x237, 0x004, 0x2fb, 0x0c8, 0x0ae, 0x29d, 0x363, 0x150, 0x136, 0x305, 0x1fa, 0x3c9, 0x3af, 0x19c, 173 0x062, 0x251, 0x237, 0x004, 0x2fb, 0x0c8, 0x0ae, 0x29d, 0x363, 0x150, 0x136, 0x305, 0x1fa, 0x3c9, 0x3af, 0x19c,
@@ -425,7 +425,7 @@ static int __init safe_init (void)
425 if (vendor || product) { 425 if (vendor || product) {
426 info ("vendor: %x product: %x\n", vendor, product); 426 info ("vendor: %x product: %x\n", vendor, product);
427 427
428 for (i = 0; i < (sizeof (id_table) / sizeof (struct usb_device_id)); i++) { 428 for (i = 0; i < ARRAY_SIZE(id_table); i++) {
429 if (!id_table[i].idVendor && !id_table[i].idProduct) { 429 if (!id_table[i].idVendor && !id_table[i].idProduct) {
430 id_table[i].idVendor = vendor; 430 id_table[i].idVendor = vendor;
431 id_table[i].idProduct = product; 431 id_table[i].idProduct = product;
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c
index 205dbf7201da..abb830cb77bd 100644
--- a/drivers/usb/serial/ti_usb_3410_5052.c
+++ b/drivers/usb/serial/ti_usb_3410_5052.c
@@ -248,11 +248,11 @@ static struct usb_device_id ti_id_table_combined[] = {
248}; 248};
249 249
250static struct usb_driver ti_usb_driver = { 250static struct usb_driver ti_usb_driver = {
251 .owner = THIS_MODULE,
252 .name = "ti_usb_3410_5052", 251 .name = "ti_usb_3410_5052",
253 .probe = usb_serial_probe, 252 .probe = usb_serial_probe,
254 .disconnect = usb_serial_disconnect, 253 .disconnect = usb_serial_disconnect,
255 .id_table = ti_id_table_combined, 254 .id_table = ti_id_table_combined,
255 .no_dynamic_id = 1,
256}; 256};
257 257
258static struct usb_serial_driver ti_1port_device = { 258static struct usb_serial_driver ti_1port_device = {
@@ -351,17 +351,14 @@ static int __init ti_init(void)
351 int i,j; 351 int i,j;
352 int ret; 352 int ret;
353 353
354
355 /* insert extra vendor and product ids */ 354 /* insert extra vendor and product ids */
356 j = sizeof(ti_id_table_3410)/sizeof(struct usb_device_id) 355 j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
357 - TI_EXTRA_VID_PID_COUNT - 1;
358 for (i=0; i<min(vendor_3410_count,product_3410_count); i++,j++) { 356 for (i=0; i<min(vendor_3410_count,product_3410_count); i++,j++) {
359 ti_id_table_3410[j].idVendor = vendor_3410[i]; 357 ti_id_table_3410[j].idVendor = vendor_3410[i];
360 ti_id_table_3410[j].idProduct = product_3410[i]; 358 ti_id_table_3410[j].idProduct = product_3410[i];
361 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE; 359 ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
362 } 360 }
363 j = sizeof(ti_id_table_5052)/sizeof(struct usb_device_id) 361 j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1;
364 - TI_EXTRA_VID_PID_COUNT - 1;
365 for (i=0; i<min(vendor_5052_count,product_5052_count); i++,j++) { 362 for (i=0; i<min(vendor_5052_count,product_5052_count); i++,j++) {
366 ti_id_table_5052[j].idVendor = vendor_5052[i]; 363 ti_id_table_5052[j].idVendor = vendor_5052[i];
367 ti_id_table_5052[j].idProduct = product_5052[i]; 364 ti_id_table_5052[j].idProduct = product_5052[i];
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index 0c4881d18cd5..8bc8337c99c4 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -30,6 +30,7 @@
30#include <linux/list.h> 30#include <linux/list.h>
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
32#include <asm/uaccess.h> 32#include <asm/uaccess.h>
33#include <asm/semaphore.h>
33#include <linux/usb.h> 34#include <linux/usb.h>
34#include "usb-serial.h" 35#include "usb-serial.h"
35#include "pl2303.h" 36#include "pl2303.h"
@@ -42,10 +43,10 @@
42 43
43/* Driver structure we register with the USB core */ 44/* Driver structure we register with the USB core */
44static struct usb_driver usb_serial_driver = { 45static struct usb_driver usb_serial_driver = {
45 .owner = THIS_MODULE,
46 .name = "usbserial", 46 .name = "usbserial",
47 .probe = usb_serial_probe, 47 .probe = usb_serial_probe,
48 .disconnect = usb_serial_disconnect, 48 .disconnect = usb_serial_disconnect,
49 .no_dynamic_id = 1,
49}; 50};
50 51
51/* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead 52/* There is no MODULE_DEVICE_TABLE for usbserial.c. Instead
@@ -188,6 +189,11 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
188 189
189 portNumber = tty->index - serial->minor; 190 portNumber = tty->index - serial->minor;
190 port = serial->port[portNumber]; 191 port = serial->port[portNumber];
192 if (!port)
193 return -ENODEV;
194
195 if (down_interruptible(&port->sem))
196 return -ERESTARTSYS;
191 197
192 ++port->open_count; 198 ++port->open_count;
193 199
@@ -213,6 +219,7 @@ static int serial_open (struct tty_struct *tty, struct file * filp)
213 goto bailout_module_put; 219 goto bailout_module_put;
214 } 220 }
215 221
222 up(&port->sem);
216 return 0; 223 return 0;
217 224
218bailout_module_put: 225bailout_module_put:
@@ -220,6 +227,7 @@ bailout_module_put:
220bailout_kref_put: 227bailout_kref_put:
221 kref_put(&serial->kref, destroy_serial); 228 kref_put(&serial->kref, destroy_serial);
222 port->open_count = 0; 229 port->open_count = 0;
230 up(&port->sem);
223 return retval; 231 return retval;
224} 232}
225 233
@@ -232,8 +240,10 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
232 240
233 dbg("%s - port %d", __FUNCTION__, port->number); 241 dbg("%s - port %d", __FUNCTION__, port->number);
234 242
243 down(&port->sem);
244
235 if (port->open_count == 0) 245 if (port->open_count == 0)
236 return; 246 goto out;
237 247
238 --port->open_count; 248 --port->open_count;
239 if (port->open_count == 0) { 249 if (port->open_count == 0) {
@@ -251,6 +261,9 @@ static void serial_close(struct tty_struct *tty, struct file * filp)
251 } 261 }
252 262
253 kref_put(&port->serial->kref, destroy_serial); 263 kref_put(&port->serial->kref, destroy_serial);
264
265out:
266 up(&port->sem);
254} 267}
255 268
256static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count) 269static int serial_write (struct tty_struct * tty, const unsigned char *buf, int count)
@@ -258,6 +271,9 @@ static int serial_write (struct tty_struct * tty, const unsigned char *buf, int
258 struct usb_serial_port *port = tty->driver_data; 271 struct usb_serial_port *port = tty->driver_data;
259 int retval = -EINVAL; 272 int retval = -EINVAL;
260 273
274 if (!port)
275 goto exit;
276
261 dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count); 277 dbg("%s - port %d, %d byte(s)", __FUNCTION__, port->number, count);
262 278
263 if (!port->open_count) { 279 if (!port->open_count) {
@@ -277,6 +293,9 @@ static int serial_write_room (struct tty_struct *tty)
277 struct usb_serial_port *port = tty->driver_data; 293 struct usb_serial_port *port = tty->driver_data;
278 int retval = -EINVAL; 294 int retval = -EINVAL;
279 295
296 if (!port)
297 goto exit;
298
280 dbg("%s - port %d", __FUNCTION__, port->number); 299 dbg("%s - port %d", __FUNCTION__, port->number);
281 300
282 if (!port->open_count) { 301 if (!port->open_count) {
@@ -296,6 +315,9 @@ static int serial_chars_in_buffer (struct tty_struct *tty)
296 struct usb_serial_port *port = tty->driver_data; 315 struct usb_serial_port *port = tty->driver_data;
297 int retval = -EINVAL; 316 int retval = -EINVAL;
298 317
318 if (!port)
319 goto exit;
320
299 dbg("%s = port %d", __FUNCTION__, port->number); 321 dbg("%s = port %d", __FUNCTION__, port->number);
300 322
301 if (!port->open_count) { 323 if (!port->open_count) {
@@ -314,6 +336,9 @@ static void serial_throttle (struct tty_struct * tty)
314{ 336{
315 struct usb_serial_port *port = tty->driver_data; 337 struct usb_serial_port *port = tty->driver_data;
316 338
339 if (!port)
340 return;
341
317 dbg("%s - port %d", __FUNCTION__, port->number); 342 dbg("%s - port %d", __FUNCTION__, port->number);
318 343
319 if (!port->open_count) { 344 if (!port->open_count) {
@@ -330,6 +355,9 @@ static void serial_unthrottle (struct tty_struct * tty)
330{ 355{
331 struct usb_serial_port *port = tty->driver_data; 356 struct usb_serial_port *port = tty->driver_data;
332 357
358 if (!port)
359 return;
360
333 dbg("%s - port %d", __FUNCTION__, port->number); 361 dbg("%s - port %d", __FUNCTION__, port->number);
334 362
335 if (!port->open_count) { 363 if (!port->open_count) {
@@ -347,6 +375,9 @@ static int serial_ioctl (struct tty_struct *tty, struct file * file, unsigned in
347 struct usb_serial_port *port = tty->driver_data; 375 struct usb_serial_port *port = tty->driver_data;
348 int retval = -ENODEV; 376 int retval = -ENODEV;
349 377
378 if (!port)
379 goto exit;
380
350 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd); 381 dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
351 382
352 if (!port->open_count) { 383 if (!port->open_count) {
@@ -368,6 +399,9 @@ static void serial_set_termios (struct tty_struct *tty, struct termios * old)
368{ 399{
369 struct usb_serial_port *port = tty->driver_data; 400 struct usb_serial_port *port = tty->driver_data;
370 401
402 if (!port)
403 return;
404
371 dbg("%s - port %d", __FUNCTION__, port->number); 405 dbg("%s - port %d", __FUNCTION__, port->number);
372 406
373 if (!port->open_count) { 407 if (!port->open_count) {
@@ -384,6 +418,9 @@ static void serial_break (struct tty_struct *tty, int break_state)
384{ 418{
385 struct usb_serial_port *port = tty->driver_data; 419 struct usb_serial_port *port = tty->driver_data;
386 420
421 if (!port)
422 return;
423
387 dbg("%s - port %d", __FUNCTION__, port->number); 424 dbg("%s - port %d", __FUNCTION__, port->number);
388 425
389 if (!port->open_count) { 426 if (!port->open_count) {
@@ -445,6 +482,9 @@ static int serial_tiocmget (struct tty_struct *tty, struct file *file)
445{ 482{
446 struct usb_serial_port *port = tty->driver_data; 483 struct usb_serial_port *port = tty->driver_data;
447 484
485 if (!port)
486 goto exit;
487
448 dbg("%s - port %d", __FUNCTION__, port->number); 488 dbg("%s - port %d", __FUNCTION__, port->number);
449 489
450 if (!port->open_count) { 490 if (!port->open_count) {
@@ -464,6 +504,9 @@ static int serial_tiocmset (struct tty_struct *tty, struct file *file,
464{ 504{
465 struct usb_serial_port *port = tty->driver_data; 505 struct usb_serial_port *port = tty->driver_data;
466 506
507 if (!port)
508 goto exit;
509
467 dbg("%s - port %d", __FUNCTION__, port->number); 510 dbg("%s - port %d", __FUNCTION__, port->number);
468 511
469 if (!port->open_count) { 512 if (!port->open_count) {
@@ -742,6 +785,7 @@ int usb_serial_probe(struct usb_interface *interface,
742 port->number = i + serial->minor; 785 port->number = i + serial->minor;
743 port->serial = serial; 786 port->serial = serial;
744 spin_lock_init(&port->lock); 787 spin_lock_init(&port->lock);
788 sema_init(&port->sem, 1);
745 INIT_WORK(&port->work, usb_serial_port_softint, port); 789 INIT_WORK(&port->work, usb_serial_port_softint, port);
746 serial->port[i] = port; 790 serial->port[i] = port;
747 } 791 }
diff --git a/drivers/usb/serial/usb-serial.h b/drivers/usb/serial/usb-serial.h
index 238a5a871ed6..d7d27c3385b3 100644
--- a/drivers/usb/serial/usb-serial.h
+++ b/drivers/usb/serial/usb-serial.h
@@ -16,6 +16,7 @@
16 16
17#include <linux/config.h> 17#include <linux/config.h>
18#include <linux/kref.h> 18#include <linux/kref.h>
19#include <asm/semaphore.h>
19 20
20#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */ 21#define SERIAL_TTY_MAJOR 188 /* Nice legal number now */
21#define SERIAL_TTY_MINORS 255 /* loads of devices :) */ 22#define SERIAL_TTY_MINORS 255 /* loads of devices :) */
@@ -30,6 +31,8 @@
30 * @serial: pointer back to the struct usb_serial owner of this port. 31 * @serial: pointer back to the struct usb_serial owner of this port.
31 * @tty: pointer to the corresponding tty for this port. 32 * @tty: pointer to the corresponding tty for this port.
32 * @lock: spinlock to grab when updating portions of this structure. 33 * @lock: spinlock to grab when updating portions of this structure.
34 * @sem: semaphore used to synchronize serial_open() and serial_close()
35 * access for this port.
33 * @number: the number of the port (the minor number). 36 * @number: the number of the port (the minor number).
34 * @interrupt_in_buffer: pointer to the interrupt in buffer for this port. 37 * @interrupt_in_buffer: pointer to the interrupt in buffer for this port.
35 * @interrupt_in_urb: pointer to the interrupt in struct urb for this port. 38 * @interrupt_in_urb: pointer to the interrupt in struct urb for this port.
@@ -60,6 +63,7 @@ struct usb_serial_port {
60 struct usb_serial * serial; 63 struct usb_serial * serial;
61 struct tty_struct * tty; 64 struct tty_struct * tty;
62 spinlock_t lock; 65 spinlock_t lock;
66 struct semaphore sem;
63 unsigned char number; 67 unsigned char number;
64 68
65 unsigned char * interrupt_in_buffer; 69 unsigned char * interrupt_in_buffer;
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c
index a473c1c34559..49b1fbe61f25 100644
--- a/drivers/usb/serial/visor.c
+++ b/drivers/usb/serial/visor.c
@@ -173,11 +173,11 @@ static struct usb_device_id id_table_combined [] = {
173MODULE_DEVICE_TABLE (usb, id_table_combined); 173MODULE_DEVICE_TABLE (usb, id_table_combined);
174 174
175static struct usb_driver visor_driver = { 175static struct usb_driver visor_driver = {
176 .owner = THIS_MODULE,
177 .name = "visor", 176 .name = "visor",
178 .probe = usb_serial_probe, 177 .probe = usb_serial_probe,
179 .disconnect = usb_serial_disconnect, 178 .disconnect = usb_serial_disconnect,
180 .id_table = id_table_combined, 179 .id_table = id_table_combined,
180 .no_dynamic_id = 1,
181}; 181};
182 182
183/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */ 183/* All of the device info needed for the Handspring Visor, and Palm 4.0 devices */
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 18c3183be769..a7c3c4734d83 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -127,11 +127,11 @@ static struct usb_device_id id_table_combined [] = {
127MODULE_DEVICE_TABLE (usb, id_table_combined); 127MODULE_DEVICE_TABLE (usb, id_table_combined);
128 128
129static struct usb_driver whiteheat_driver = { 129static struct usb_driver whiteheat_driver = {
130 .owner = THIS_MODULE,
131 .name = "whiteheat", 130 .name = "whiteheat",
132 .probe = usb_serial_probe, 131 .probe = usb_serial_probe,
133 .disconnect = usb_serial_disconnect, 132 .disconnect = usb_serial_disconnect,
134 .id_table = id_table_combined, 133 .id_table = id_table_combined,
134 .no_dynamic_id = 1,
135}; 135};
136 136
137/* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */ 137/* function prototypes for the Connect Tech WhiteHEAT prerenumeration device */
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index c41d64dbb0f0..92be101feba7 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -112,6 +112,15 @@ config USB_STORAGE_JUMPSHOT
112 Say Y here to include additional code to support the Lexar Jumpshot 112 Say Y here to include additional code to support the Lexar Jumpshot
113 USB CompactFlash reader. 113 USB CompactFlash reader.
114 114
115config USB_STORAGE_ALAUDA
116 bool "Olympus MAUSB-10/Fuji DPC-R1 support (EXPERIMENTAL)"
117 depends on USB_STORAGE && EXPERIMENTAL
118 help
119 Say Y here to include additional code to support the Olympus MAUSB-10
120 and Fujifilm DPC-R1 USB Card reader/writer devices.
121
122 These devices are based on the Alauda chip and support support both
123 XD and SmartMedia cards.
115 124
116config USB_STORAGE_ONETOUCH 125config USB_STORAGE_ONETOUCH
117 bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" 126 bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)"
@@ -124,3 +133,17 @@ config USB_STORAGE_ONETOUCH
124 hard drive's as an input device. An action can be associated with 133 hard drive's as an input device. An action can be associated with
125 this input in any keybinding software. (e.g. gnome's keyboard short- 134 this input in any keybinding software. (e.g. gnome's keyboard short-
126 cuts) 135 cuts)
136
137config USB_LIBUSUAL
138 bool "The shared table of common (or usual) storage devices"
139 depends on USB
140 help
141 This module contains a table of common (or usual) devices
142 for usb-storage and ub drivers, and allows to switch binding
143 of these devices without rebuilding modules.
144
145 Typical syntax of /etc/modprobe.conf is:
146
147 options libusual bias="ub"
148
149 If unsure, say N.
diff --git a/drivers/usb/storage/Makefile b/drivers/usb/storage/Makefile
index 44ab8f9978fe..8cbba22508a4 100644
--- a/drivers/usb/storage/Makefile
+++ b/drivers/usb/storage/Makefile
@@ -18,7 +18,12 @@ usb-storage-obj-$(CONFIG_USB_STORAGE_DPCM) += dpcm.o
18usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o 18usb-storage-obj-$(CONFIG_USB_STORAGE_ISD200) += isd200.o
19usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o 19usb-storage-obj-$(CONFIG_USB_STORAGE_DATAFAB) += datafab.o
20usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o 20usb-storage-obj-$(CONFIG_USB_STORAGE_JUMPSHOT) += jumpshot.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ALAUDA) += alauda.o
21usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o 22usb-storage-obj-$(CONFIG_USB_STORAGE_ONETOUCH) += onetouch.o
22 23
23usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \ 24usb-storage-objs := scsiglue.o protocol.o transport.o usb.o \
24 initializers.o $(usb-storage-obj-y) 25 initializers.o $(usb-storage-obj-y)
26
27ifneq ($(CONFIG_USB_LIBUSUAL),)
28 obj-$(CONFIG_USB) += libusual.o
29endif
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
new file mode 100644
index 000000000000..4d3cbb12b713
--- /dev/null
+++ b/drivers/usb/storage/alauda.c
@@ -0,0 +1,1119 @@
1/*
2 * Driver for Alauda-based card readers
3 *
4 * Current development and maintenance by:
5 * (c) 2005 Daniel Drake <dsd@gentoo.org>
6 *
7 * The 'Alauda' is a chip manufacturered by RATOC for OEM use.
8 *
9 * Alauda implements a vendor-specific command set to access two media reader
10 * ports (XD, SmartMedia). This driver converts SCSI commands to the commands
11 * which are accepted by these devices.
12 *
13 * The driver was developed through reverse-engineering, with the help of the
14 * sddr09 driver which has many similarities, and with some help from the
15 * (very old) vendor-supplied GPL sma03 driver.
16 *
17 * For protocol info, see http://alauda.sourceforge.net
18 *
19 * This program is free software; you can redistribute it and/or modify it
20 * under the terms of the GNU General Public License as published by the
21 * Free Software Foundation; either version 2, or (at your option) any
22 * later version.
23 *
24 * This program is distributed in the hope that it will be useful, but
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 * General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License along
30 * with this program; if not, write to the Free Software Foundation, Inc.,
31 * 675 Mass Ave, Cambridge, MA 02139, USA.
32 */
33
34#include <scsi/scsi.h>
35#include <scsi/scsi_cmnd.h>
36#include <scsi/scsi_device.h>
37
38#include "usb.h"
39#include "transport.h"
40#include "protocol.h"
41#include "debug.h"
42#include "alauda.h"
43
44#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) )
45#define LSB_of(s) ((s)&0xFF)
46#define MSB_of(s) ((s)>>8)
47
48#define MEDIA_PORT(us) us->srb->device->lun
49#define MEDIA_INFO(us) ((struct alauda_info *)us->extra)->port[MEDIA_PORT(us)]
50
51#define PBA_LO(pba) ((pba & 0xF) << 5)
52#define PBA_HI(pba) (pba >> 3)
53#define PBA_ZONE(pba) (pba >> 11)
54
55/*
56 * Media handling
57 */
58
59struct alauda_card_info {
60 unsigned char id; /* id byte */
61 unsigned char chipshift; /* 1<<cs bytes total capacity */
62 unsigned char pageshift; /* 1<<ps bytes in a page */
63 unsigned char blockshift; /* 1<<bs pages per block */
64 unsigned char zoneshift; /* 1<<zs blocks per zone */
65};
66
67static struct alauda_card_info alauda_card_ids[] = {
68 /* NAND flash */
69 { 0x6e, 20, 8, 4, 8}, /* 1 MB */
70 { 0xe8, 20, 8, 4, 8}, /* 1 MB */
71 { 0xec, 20, 8, 4, 8}, /* 1 MB */
72 { 0x64, 21, 8, 4, 9}, /* 2 MB */
73 { 0xea, 21, 8, 4, 9}, /* 2 MB */
74 { 0x6b, 22, 9, 4, 9}, /* 4 MB */
75 { 0xe3, 22, 9, 4, 9}, /* 4 MB */
76 { 0xe5, 22, 9, 4, 9}, /* 4 MB */
77 { 0xe6, 23, 9, 4, 10}, /* 8 MB */
78 { 0x73, 24, 9, 5, 10}, /* 16 MB */
79 { 0x75, 25, 9, 5, 10}, /* 32 MB */
80 { 0x76, 26, 9, 5, 10}, /* 64 MB */
81 { 0x79, 27, 9, 5, 10}, /* 128 MB */
82 { 0x71, 28, 9, 5, 10}, /* 256 MB */
83
84 /* MASK ROM */
85 { 0x5d, 21, 9, 4, 8}, /* 2 MB */
86 { 0xd5, 22, 9, 4, 9}, /* 4 MB */
87 { 0xd6, 23, 9, 4, 10}, /* 8 MB */
88 { 0x57, 24, 9, 4, 11}, /* 16 MB */
89 { 0x58, 25, 9, 4, 12}, /* 32 MB */
90 { 0,}
91};
92
93static struct alauda_card_info *alauda_card_find_id(unsigned char id) {
94 int i;
95
96 for (i = 0; alauda_card_ids[i].id != 0; i++)
97 if (alauda_card_ids[i].id == id)
98 return &(alauda_card_ids[i]);
99 return NULL;
100}
101
102/*
103 * ECC computation.
104 */
105
106static unsigned char parity[256];
107static unsigned char ecc2[256];
108
109static void nand_init_ecc(void) {
110 int i, j, a;
111
112 parity[0] = 0;
113 for (i = 1; i < 256; i++)
114 parity[i] = (parity[i&(i-1)] ^ 1);
115
116 for (i = 0; i < 256; i++) {
117 a = 0;
118 for (j = 0; j < 8; j++) {
119 if (i & (1<<j)) {
120 if ((j & 1) == 0)
121 a ^= 0x04;
122 if ((j & 2) == 0)
123 a ^= 0x10;
124 if ((j & 4) == 0)
125 a ^= 0x40;
126 }
127 }
128 ecc2[i] = ~(a ^ (a<<1) ^ (parity[i] ? 0xa8 : 0));
129 }
130}
131
132/* compute 3-byte ecc on 256 bytes */
133static void nand_compute_ecc(unsigned char *data, unsigned char *ecc) {
134 int i, j, a;
135 unsigned char par, bit, bits[8];
136
137 par = 0;
138 for (j = 0; j < 8; j++)
139 bits[j] = 0;
140
141 /* collect 16 checksum bits */
142 for (i = 0; i < 256; i++) {
143 par ^= data[i];
144 bit = parity[data[i]];
145 for (j = 0; j < 8; j++)
146 if ((i & (1<<j)) == 0)
147 bits[j] ^= bit;
148 }
149
150 /* put 4+4+4 = 12 bits in the ecc */
151 a = (bits[3] << 6) + (bits[2] << 4) + (bits[1] << 2) + bits[0];
152 ecc[0] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0));
153
154 a = (bits[7] << 6) + (bits[6] << 4) + (bits[5] << 2) + bits[4];
155 ecc[1] = ~(a ^ (a<<1) ^ (parity[par] ? 0xaa : 0));
156
157 ecc[2] = ecc2[par];
158}
159
160static int nand_compare_ecc(unsigned char *data, unsigned char *ecc) {
161 return (data[0] == ecc[0] && data[1] == ecc[1] && data[2] == ecc[2]);
162}
163
164static void nand_store_ecc(unsigned char *data, unsigned char *ecc) {
165 memcpy(data, ecc, 3);
166}
167
168/*
169 * Alauda driver
170 */
171
172/*
173 * Forget our PBA <---> LBA mappings for a particular port
174 */
175static void alauda_free_maps (struct alauda_media_info *media_info)
176{
177 unsigned int shift = media_info->zoneshift
178 + media_info->blockshift + media_info->pageshift;
179 unsigned int num_zones = media_info->capacity >> shift;
180 unsigned int i;
181
182 if (media_info->lba_to_pba != NULL)
183 for (i = 0; i < num_zones; i++) {
184 kfree(media_info->lba_to_pba[i]);
185 media_info->lba_to_pba[i] = NULL;
186 }
187
188 if (media_info->pba_to_lba != NULL)
189 for (i = 0; i < num_zones; i++) {
190 kfree(media_info->pba_to_lba[i]);
191 media_info->pba_to_lba[i] = NULL;
192 }
193}
194
195/*
196 * Returns 2 bytes of status data
197 * The first byte describes media status, and second byte describes door status
198 */
199static int alauda_get_media_status(struct us_data *us, unsigned char *data)
200{
201 int rc;
202 unsigned char command;
203
204 if (MEDIA_PORT(us) == ALAUDA_PORT_XD)
205 command = ALAUDA_GET_XD_MEDIA_STATUS;
206 else
207 command = ALAUDA_GET_SM_MEDIA_STATUS;
208
209 rc = usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
210 command, 0xc0, 0, 1, data, 2);
211
212 US_DEBUGP("alauda_get_media_status: Media status %02X %02X\n",
213 data[0], data[1]);
214
215 return rc;
216}
217
218/*
219 * Clears the "media was changed" bit so that we know when it changes again
220 * in the future.
221 */
222static int alauda_ack_media(struct us_data *us)
223{
224 unsigned char command;
225
226 if (MEDIA_PORT(us) == ALAUDA_PORT_XD)
227 command = ALAUDA_ACK_XD_MEDIA_CHANGE;
228 else
229 command = ALAUDA_ACK_SM_MEDIA_CHANGE;
230
231 return usb_stor_ctrl_transfer(us, us->send_ctrl_pipe,
232 command, 0x40, 0, 1, NULL, 0);
233}
234
235/*
236 * Retrieves a 4-byte media signature, which indicates manufacturer, capacity,
237 * and some other details.
238 */
239static int alauda_get_media_signature(struct us_data *us, unsigned char *data)
240{
241 unsigned char command;
242
243 if (MEDIA_PORT(us) == ALAUDA_PORT_XD)
244 command = ALAUDA_GET_XD_MEDIA_SIG;
245 else
246 command = ALAUDA_GET_SM_MEDIA_SIG;
247
248 return usb_stor_ctrl_transfer(us, us->recv_ctrl_pipe,
249 command, 0xc0, 0, 0, data, 4);
250}
251
252/*
253 * Resets the media status (but not the whole device?)
254 */
255static int alauda_reset_media(struct us_data *us)
256{
257 unsigned char *command = us->iobuf;
258
259 memset(command, 0, 9);
260 command[0] = ALAUDA_BULK_CMD;
261 command[1] = ALAUDA_BULK_RESET_MEDIA;
262 command[8] = MEDIA_PORT(us);
263
264 return usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
265 command, 9, NULL);
266}
267
268/*
269 * Examines the media and deduces capacity, etc.
270 */
271static int alauda_init_media(struct us_data *us)
272{
273 unsigned char *data = us->iobuf;
274 int ready = 0;
275 struct alauda_card_info *media_info;
276 unsigned int num_zones;
277
278 while (ready == 0) {
279 msleep(20);
280
281 if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD)
282 return USB_STOR_TRANSPORT_ERROR;
283
284 if (data[0] & 0x10)
285 ready = 1;
286 }
287
288 US_DEBUGP("alauda_init_media: We are ready for action!\n");
289
290 if (alauda_ack_media(us) != USB_STOR_XFER_GOOD)
291 return USB_STOR_TRANSPORT_ERROR;
292
293 msleep(10);
294
295 if (alauda_get_media_status(us, data) != USB_STOR_XFER_GOOD)
296 return USB_STOR_TRANSPORT_ERROR;
297
298 if (data[0] != 0x14) {
299 US_DEBUGP("alauda_init_media: Media not ready after ack\n");
300 return USB_STOR_TRANSPORT_ERROR;
301 }
302
303 if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD)
304 return USB_STOR_TRANSPORT_ERROR;
305
306 US_DEBUGP("alauda_init_media: Media signature: %02X %02X %02X %02X\n",
307 data[0], data[1], data[2], data[3]);
308 media_info = alauda_card_find_id(data[1]);
309 if (media_info == NULL) {
310 printk("alauda_init_media: Unrecognised media signature: "
311 "%02X %02X %02X %02X\n",
312 data[0], data[1], data[2], data[3]);
313 return USB_STOR_TRANSPORT_ERROR;
314 }
315
316 MEDIA_INFO(us).capacity = 1 << media_info->chipshift;
317 US_DEBUGP("Found media with capacity: %ldMB\n",
318 MEDIA_INFO(us).capacity >> 20);
319
320 MEDIA_INFO(us).pageshift = media_info->pageshift;
321 MEDIA_INFO(us).blockshift = media_info->blockshift;
322 MEDIA_INFO(us).zoneshift = media_info->zoneshift;
323
324 MEDIA_INFO(us).pagesize = 1 << media_info->pageshift;
325 MEDIA_INFO(us).blocksize = 1 << media_info->blockshift;
326 MEDIA_INFO(us).zonesize = 1 << media_info->zoneshift;
327
328 MEDIA_INFO(us).uzonesize = ((1 << media_info->zoneshift) / 128) * 125;
329 MEDIA_INFO(us).blockmask = MEDIA_INFO(us).blocksize - 1;
330
331 num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift
332 + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift);
333 MEDIA_INFO(us).pba_to_lba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO);
334 MEDIA_INFO(us).lba_to_pba = kcalloc(num_zones, sizeof(u16*), GFP_NOIO);
335
336 if (alauda_reset_media(us) != USB_STOR_XFER_GOOD)
337 return USB_STOR_TRANSPORT_ERROR;
338
339 return USB_STOR_TRANSPORT_GOOD;
340}
341
342/*
343 * Examines the media status and does the right thing when the media has gone,
344 * appeared, or changed.
345 */
346static int alauda_check_media(struct us_data *us)
347{
348 struct alauda_info *info = (struct alauda_info *) us->extra;
349 unsigned char status[2];
350 int rc;
351
352 rc = alauda_get_media_status(us, status);
353
354 /* Check for no media or door open */
355 if ((status[0] & 0x80) || ((status[0] & 0x1F) == 0x10)
356 || ((status[1] & 0x01) == 0)) {
357 US_DEBUGP("alauda_check_media: No media, or door open\n");
358 alauda_free_maps(&MEDIA_INFO(us));
359 info->sense_key = 0x02;
360 info->sense_asc = 0x3A;
361 info->sense_ascq = 0x00;
362 return USB_STOR_TRANSPORT_FAILED;
363 }
364
365 /* Check for media change */
366 if (status[0] & 0x08) {
367 US_DEBUGP("alauda_check_media: Media change detected\n");
368 alauda_free_maps(&MEDIA_INFO(us));
369 alauda_init_media(us);
370
371 info->sense_key = UNIT_ATTENTION;
372 info->sense_asc = 0x28;
373 info->sense_ascq = 0x00;
374 return USB_STOR_TRANSPORT_FAILED;
375 }
376
377 return USB_STOR_TRANSPORT_GOOD;
378}
379
380/*
381 * Checks the status from the 2nd status register
382 * Returns 3 bytes of status data, only the first is known
383 */
384static int alauda_check_status2(struct us_data *us)
385{
386 int rc;
387 unsigned char command[] = {
388 ALAUDA_BULK_CMD, ALAUDA_BULK_GET_STATUS2,
389 0, 0, 0, 0, 3, 0, MEDIA_PORT(us)
390 };
391 unsigned char data[3];
392
393 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
394 command, 9, NULL);
395 if (rc != USB_STOR_XFER_GOOD)
396 return rc;
397
398 rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
399 data, 3, NULL);
400 if (rc != USB_STOR_XFER_GOOD)
401 return rc;
402
403 US_DEBUGP("alauda_check_status2: %02X %02X %02X\n", data[0], data[1], data[2]);
404 if (data[0] & ALAUDA_STATUS_ERROR)
405 return USB_STOR_XFER_ERROR;
406
407 return USB_STOR_XFER_GOOD;
408}
409
410/*
411 * Gets the redundancy data for the first page of a PBA
412 * Returns 16 bytes.
413 */
414static int alauda_get_redu_data(struct us_data *us, u16 pba, unsigned char *data)
415{
416 int rc;
417 unsigned char command[] = {
418 ALAUDA_BULK_CMD, ALAUDA_BULK_GET_REDU_DATA,
419 PBA_HI(pba), PBA_ZONE(pba), 0, PBA_LO(pba), 0, 0, MEDIA_PORT(us)
420 };
421
422 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
423 command, 9, NULL);
424 if (rc != USB_STOR_XFER_GOOD)
425 return rc;
426
427 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
428 data, 16, NULL);
429}
430
431/*
432 * Finds the first unused PBA in a zone
433 * Returns the absolute PBA of an unused PBA, or 0 if none found.
434 */
435static u16 alauda_find_unused_pba(struct alauda_media_info *info,
436 unsigned int zone)
437{
438 u16 *pba_to_lba = info->pba_to_lba[zone];
439 unsigned int i;
440
441 for (i = 0; i < info->zonesize; i++)
442 if (pba_to_lba[i] == UNDEF)
443 return (zone << info->zoneshift) + i;
444
445 return 0;
446}
447
448/*
449 * Reads the redundancy data for all PBA's in a zone
450 * Produces lba <--> pba mappings
451 */
452static int alauda_read_map(struct us_data *us, unsigned int zone)
453{
454 unsigned char *data = us->iobuf;
455 int result;
456 int i, j;
457 unsigned int zonesize = MEDIA_INFO(us).zonesize;
458 unsigned int uzonesize = MEDIA_INFO(us).uzonesize;
459 unsigned int lba_offset, lba_real, blocknum;
460 unsigned int zone_base_lba = zone * uzonesize;
461 unsigned int zone_base_pba = zone * zonesize;
462 u16 *lba_to_pba = kcalloc(zonesize, sizeof(u16), GFP_NOIO);
463 u16 *pba_to_lba = kcalloc(zonesize, sizeof(u16), GFP_NOIO);
464 if (lba_to_pba == NULL || pba_to_lba == NULL) {
465 result = USB_STOR_TRANSPORT_ERROR;
466 goto error;
467 }
468
469 US_DEBUGP("alauda_read_map: Mapping blocks for zone %d\n", zone);
470
471 /* 1024 PBA's per zone */
472 for (i = 0; i < zonesize; i++)
473 lba_to_pba[i] = pba_to_lba[i] = UNDEF;
474
475 for (i = 0; i < zonesize; i++) {
476 blocknum = zone_base_pba + i;
477
478 result = alauda_get_redu_data(us, blocknum, data);
479 if (result != USB_STOR_XFER_GOOD) {
480 result = USB_STOR_TRANSPORT_ERROR;
481 goto error;
482 }
483
484 /* special PBAs have control field 0^16 */
485 for (j = 0; j < 16; j++)
486 if (data[j] != 0)
487 goto nonz;
488 pba_to_lba[i] = UNUSABLE;
489 US_DEBUGP("alauda_read_map: PBA %d has no logical mapping\n", blocknum);
490 continue;
491
492 nonz:
493 /* unwritten PBAs have control field FF^16 */
494 for (j = 0; j < 16; j++)
495 if (data[j] != 0xff)
496 goto nonff;
497 continue;
498
499 nonff:
500 /* normal PBAs start with six FFs */
501 if (j < 6) {
502 US_DEBUGP("alauda_read_map: PBA %d has no logical mapping: "
503 "reserved area = %02X%02X%02X%02X "
504 "data status %02X block status %02X\n",
505 blocknum, data[0], data[1], data[2], data[3],
506 data[4], data[5]);
507 pba_to_lba[i] = UNUSABLE;
508 continue;
509 }
510
511 if ((data[6] >> 4) != 0x01) {
512 US_DEBUGP("alauda_read_map: PBA %d has invalid address "
513 "field %02X%02X/%02X%02X\n",
514 blocknum, data[6], data[7], data[11], data[12]);
515 pba_to_lba[i] = UNUSABLE;
516 continue;
517 }
518
519 /* check even parity */
520 if (parity[data[6] ^ data[7]]) {
521 printk("alauda_read_map: Bad parity in LBA for block %d"
522 " (%02X %02X)\n", i, data[6], data[7]);
523 pba_to_lba[i] = UNUSABLE;
524 continue;
525 }
526
527 lba_offset = short_pack(data[7], data[6]);
528 lba_offset = (lba_offset & 0x07FF) >> 1;
529 lba_real = lba_offset + zone_base_lba;
530
531 /*
532 * Every 1024 physical blocks ("zone"), the LBA numbers
533 * go back to zero, but are within a higher block of LBA's.
534 * Also, there is a maximum of 1000 LBA's per zone.
535 * In other words, in PBA 1024-2047 you will find LBA 0-999
536 * which are really LBA 1000-1999. This allows for 24 bad
537 * or special physical blocks per zone.
538 */
539
540 if (lba_offset >= uzonesize) {
541 printk("alauda_read_map: Bad low LBA %d for block %d\n",
542 lba_real, blocknum);
543 continue;
544 }
545
546 if (lba_to_pba[lba_offset] != UNDEF) {
547 printk("alauda_read_map: LBA %d seen for PBA %d and %d\n",
548 lba_real, lba_to_pba[lba_offset], blocknum);
549 continue;
550 }
551
552 pba_to_lba[i] = lba_real;
553 lba_to_pba[lba_offset] = blocknum;
554 continue;
555 }
556
557 MEDIA_INFO(us).lba_to_pba[zone] = lba_to_pba;
558 MEDIA_INFO(us).pba_to_lba[zone] = pba_to_lba;
559 result = 0;
560 goto out;
561
562error:
563 kfree(lba_to_pba);
564 kfree(pba_to_lba);
565out:
566 return result;
567}
568
569/*
570 * Checks to see whether we have already mapped a certain zone
571 * If we haven't, the map is generated
572 */
573static void alauda_ensure_map_for_zone(struct us_data *us, unsigned int zone)
574{
575 if (MEDIA_INFO(us).lba_to_pba[zone] == NULL
576 || MEDIA_INFO(us).pba_to_lba[zone] == NULL)
577 alauda_read_map(us, zone);
578}
579
580/*
581 * Erases an entire block
582 */
583static int alauda_erase_block(struct us_data *us, u16 pba)
584{
585 int rc;
586 unsigned char command[] = {
587 ALAUDA_BULK_CMD, ALAUDA_BULK_ERASE_BLOCK, PBA_HI(pba),
588 PBA_ZONE(pba), 0, PBA_LO(pba), 0x02, 0, MEDIA_PORT(us)
589 };
590 unsigned char buf[2];
591
592 US_DEBUGP("alauda_erase_block: Erasing PBA %d\n", pba);
593
594 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
595 command, 9, NULL);
596 if (rc != USB_STOR_XFER_GOOD)
597 return rc;
598
599 rc = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
600 buf, 2, NULL);
601 if (rc != USB_STOR_XFER_GOOD)
602 return rc;
603
604 US_DEBUGP("alauda_erase_block: Erase result: %02X %02X\n",
605 buf[0], buf[1]);
606 return rc;
607}
608
609/*
610 * Reads data from a certain offset page inside a PBA, including interleaved
611 * redundancy data. Returns (pagesize+64)*pages bytes in data.
612 */
613static int alauda_read_block_raw(struct us_data *us, u16 pba,
614 unsigned int page, unsigned int pages, unsigned char *data)
615{
616 int rc;
617 unsigned char command[] = {
618 ALAUDA_BULK_CMD, ALAUDA_BULK_READ_BLOCK, PBA_HI(pba),
619 PBA_ZONE(pba), 0, PBA_LO(pba) + page, pages, 0, MEDIA_PORT(us)
620 };
621
622 US_DEBUGP("alauda_read_block: pba %d page %d count %d\n",
623 pba, page, pages);
624
625 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
626 command, 9, NULL);
627 if (rc != USB_STOR_XFER_GOOD)
628 return rc;
629
630 return usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
631 data, (MEDIA_INFO(us).pagesize + 64) * pages, NULL);
632}
633
634/*
635 * Reads data from a certain offset page inside a PBA, excluding redundancy
636 * data. Returns pagesize*pages bytes in data. Note that data must be big enough
637 * to hold (pagesize+64)*pages bytes of data, but you can ignore those 'extra'
638 * trailing bytes outside this function.
639 */
640static int alauda_read_block(struct us_data *us, u16 pba,
641 unsigned int page, unsigned int pages, unsigned char *data)
642{
643 int i, rc;
644 unsigned int pagesize = MEDIA_INFO(us).pagesize;
645
646 rc = alauda_read_block_raw(us, pba, page, pages, data);
647 if (rc != USB_STOR_XFER_GOOD)
648 return rc;
649
650 /* Cut out the redundancy data */
651 for (i = 0; i < pages; i++) {
652 int dest_offset = i * pagesize;
653 int src_offset = i * (pagesize + 64);
654 memmove(data + dest_offset, data + src_offset, pagesize);
655 }
656
657 return rc;
658}
659
660/*
661 * Writes an entire block of data and checks status after write.
662 * Redundancy data must be already included in data. Data should be
663 * (pagesize+64)*blocksize bytes in length.
664 */
665static int alauda_write_block(struct us_data *us, u16 pba, unsigned char *data)
666{
667 int rc;
668 struct alauda_info *info = (struct alauda_info *) us->extra;
669 unsigned char command[] = {
670 ALAUDA_BULK_CMD, ALAUDA_BULK_WRITE_BLOCK, PBA_HI(pba),
671 PBA_ZONE(pba), 0, PBA_LO(pba), 32, 0, MEDIA_PORT(us)
672 };
673
674 US_DEBUGP("alauda_write_block: pba %d\n", pba);
675
676 rc = usb_stor_bulk_transfer_buf(us, us->send_bulk_pipe,
677 command, 9, NULL);
678 if (rc != USB_STOR_XFER_GOOD)
679 return rc;
680
681 rc = usb_stor_bulk_transfer_buf(us, info->wr_ep, data,
682 (MEDIA_INFO(us).pagesize + 64) * MEDIA_INFO(us).blocksize,
683 NULL);
684 if (rc != USB_STOR_XFER_GOOD)
685 return rc;
686
687 return alauda_check_status2(us);
688}
689
690/*
691 * Write some data to a specific LBA.
692 */
693static int alauda_write_lba(struct us_data *us, u16 lba,
694 unsigned int page, unsigned int pages,
695 unsigned char *ptr, unsigned char *blockbuffer)
696{
697 u16 pba, lbap, new_pba;
698 unsigned char *bptr, *cptr, *xptr;
699 unsigned char ecc[3];
700 int i, result;
701 unsigned int uzonesize = MEDIA_INFO(us).uzonesize;
702 unsigned int zonesize = MEDIA_INFO(us).zonesize;
703 unsigned int pagesize = MEDIA_INFO(us).pagesize;
704 unsigned int blocksize = MEDIA_INFO(us).blocksize;
705 unsigned int lba_offset = lba % uzonesize;
706 unsigned int new_pba_offset;
707 unsigned int zone = lba / uzonesize;
708
709 alauda_ensure_map_for_zone(us, zone);
710
711 pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset];
712 if (pba == 1) {
713 /* Maybe it is impossible to write to PBA 1.
714 Fake success, but don't do anything. */
715 printk("alauda_write_lba: avoid writing to pba 1\n");
716 return USB_STOR_TRANSPORT_GOOD;
717 }
718
719 new_pba = alauda_find_unused_pba(&MEDIA_INFO(us), zone);
720 if (!new_pba) {
721 printk("alauda_write_lba: Out of unused blocks\n");
722 return USB_STOR_TRANSPORT_ERROR;
723 }
724
725 /* read old contents */
726 if (pba != UNDEF) {
727 result = alauda_read_block_raw(us, pba, 0,
728 blocksize, blockbuffer);
729 if (result != USB_STOR_XFER_GOOD)
730 return result;
731 } else {
732 memset(blockbuffer, 0, blocksize * (pagesize + 64));
733 }
734
735 lbap = (lba_offset << 1) | 0x1000;
736 if (parity[MSB_of(lbap) ^ LSB_of(lbap)])
737 lbap ^= 1;
738
739 /* check old contents and fill lba */
740 for (i = 0; i < blocksize; i++) {
741 bptr = blockbuffer + (i * (pagesize + 64));
742 cptr = bptr + pagesize;
743 nand_compute_ecc(bptr, ecc);
744 if (!nand_compare_ecc(cptr+13, ecc)) {
745 US_DEBUGP("Warning: bad ecc in page %d- of pba %d\n",
746 i, pba);
747 nand_store_ecc(cptr+13, ecc);
748 }
749 nand_compute_ecc(bptr + (pagesize / 2), ecc);
750 if (!nand_compare_ecc(cptr+8, ecc)) {
751 US_DEBUGP("Warning: bad ecc in page %d+ of pba %d\n",
752 i, pba);
753 nand_store_ecc(cptr+8, ecc);
754 }
755 cptr[6] = cptr[11] = MSB_of(lbap);
756 cptr[7] = cptr[12] = LSB_of(lbap);
757 }
758
759 /* copy in new stuff and compute ECC */
760 xptr = ptr;
761 for (i = page; i < page+pages; i++) {
762 bptr = blockbuffer + (i * (pagesize + 64));
763 cptr = bptr + pagesize;
764 memcpy(bptr, xptr, pagesize);
765 xptr += pagesize;
766 nand_compute_ecc(bptr, ecc);
767 nand_store_ecc(cptr+13, ecc);
768 nand_compute_ecc(bptr + (pagesize / 2), ecc);
769 nand_store_ecc(cptr+8, ecc);
770 }
771
772 result = alauda_write_block(us, new_pba, blockbuffer);
773 if (result != USB_STOR_XFER_GOOD)
774 return result;
775
776 new_pba_offset = new_pba - (zone * zonesize);
777 MEDIA_INFO(us).pba_to_lba[zone][new_pba_offset] = lba;
778 MEDIA_INFO(us).lba_to_pba[zone][lba_offset] = new_pba;
779 US_DEBUGP("alauda_write_lba: Remapped LBA %d to PBA %d\n",
780 lba, new_pba);
781
782 if (pba != UNDEF) {
783 unsigned int pba_offset = pba - (zone * zonesize);
784 result = alauda_erase_block(us, pba);
785 if (result != USB_STOR_XFER_GOOD)
786 return result;
787 MEDIA_INFO(us).pba_to_lba[zone][pba_offset] = UNDEF;
788 }
789
790 return USB_STOR_TRANSPORT_GOOD;
791}
792
793/*
794 * Read data from a specific sector address
795 */
796static int alauda_read_data(struct us_data *us, unsigned long address,
797 unsigned int sectors)
798{
799 unsigned char *buffer;
800 u16 lba, max_lba;
801 unsigned int page, len, index, offset;
802 unsigned int blockshift = MEDIA_INFO(us).blockshift;
803 unsigned int pageshift = MEDIA_INFO(us).pageshift;
804 unsigned int blocksize = MEDIA_INFO(us).blocksize;
805 unsigned int pagesize = MEDIA_INFO(us).pagesize;
806 unsigned int uzonesize = MEDIA_INFO(us).uzonesize;
807 int result;
808
809 /*
810 * Since we only read in one block at a time, we have to create
811 * a bounce buffer and move the data a piece at a time between the
812 * bounce buffer and the actual transfer buffer.
813 * We make this buffer big enough to hold temporary redundancy data,
814 * which we use when reading the data blocks.
815 */
816
817 len = min(sectors, blocksize) * (pagesize + 64);
818 buffer = kmalloc(len, GFP_NOIO);
819 if (buffer == NULL) {
820 printk("alauda_read_data: Out of memory\n");
821 return USB_STOR_TRANSPORT_ERROR;
822 }
823
824 /* Figure out the initial LBA and page */
825 lba = address >> blockshift;
826 page = (address & MEDIA_INFO(us).blockmask);
827 max_lba = MEDIA_INFO(us).capacity >> (blockshift + pageshift);
828
829 result = USB_STOR_TRANSPORT_GOOD;
830 index = offset = 0;
831
832 while (sectors > 0) {
833 unsigned int zone = lba / uzonesize; /* integer division */
834 unsigned int lba_offset = lba - (zone * uzonesize);
835 unsigned int pages;
836 u16 pba;
837 alauda_ensure_map_for_zone(us, zone);
838
839 /* Not overflowing capacity? */
840 if (lba >= max_lba) {
841 US_DEBUGP("Error: Requested lba %u exceeds "
842 "maximum %u\n", lba, max_lba);
843 result = USB_STOR_TRANSPORT_ERROR;
844 break;
845 }
846
847 /* Find number of pages we can read in this block */
848 pages = min(sectors, blocksize - page);
849 len = pages << pageshift;
850
851 /* Find where this lba lives on disk */
852 pba = MEDIA_INFO(us).lba_to_pba[zone][lba_offset];
853
854 if (pba == UNDEF) { /* this lba was never written */
855 US_DEBUGP("Read %d zero pages (LBA %d) page %d\n",
856 pages, lba, page);
857
858 /* This is not really an error. It just means
859 that the block has never been written.
860 Instead of returning USB_STOR_TRANSPORT_ERROR
861 it is better to return all zero data. */
862
863 memset(buffer, 0, len);
864 } else {
865 US_DEBUGP("Read %d pages, from PBA %d"
866 " (LBA %d) page %d\n",
867 pages, pba, lba, page);
868
869 result = alauda_read_block(us, pba, page, pages, buffer);
870 if (result != USB_STOR_TRANSPORT_GOOD)
871 break;
872 }
873
874 /* Store the data in the transfer buffer */
875 usb_stor_access_xfer_buf(buffer, len, us->srb,
876 &index, &offset, TO_XFER_BUF);
877
878 page = 0;
879 lba++;
880 sectors -= pages;
881 }
882
883 kfree(buffer);
884 return result;
885}
886
887/*
888 * Write data to a specific sector address
889 */
890static int alauda_write_data(struct us_data *us, unsigned long address,
891 unsigned int sectors)
892{
893 unsigned char *buffer, *blockbuffer;
894 unsigned int page, len, index, offset;
895 unsigned int blockshift = MEDIA_INFO(us).blockshift;
896 unsigned int pageshift = MEDIA_INFO(us).pageshift;
897 unsigned int blocksize = MEDIA_INFO(us).blocksize;
898 unsigned int pagesize = MEDIA_INFO(us).pagesize;
899 u16 lba, max_lba;
900 int result;
901
902 /*
903 * Since we don't write the user data directly to the device,
904 * we have to create a bounce buffer and move the data a piece
905 * at a time between the bounce buffer and the actual transfer buffer.
906 */
907
908 len = min(sectors, blocksize) * pagesize;
909 buffer = kmalloc(len, GFP_NOIO);
910 if (buffer == NULL) {
911 printk("alauda_write_data: Out of memory\n");
912 return USB_STOR_TRANSPORT_ERROR;
913 }
914
915 /*
916 * We also need a temporary block buffer, where we read in the old data,
917 * overwrite parts with the new data, and manipulate the redundancy data
918 */
919 blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO);
920 if (blockbuffer == NULL) {
921 printk("alauda_write_data: Out of memory\n");
922 kfree(buffer);
923 return USB_STOR_TRANSPORT_ERROR;
924 }
925
926 /* Figure out the initial LBA and page */
927 lba = address >> blockshift;
928 page = (address & MEDIA_INFO(us).blockmask);
929 max_lba = MEDIA_INFO(us).capacity >> (pageshift + blockshift);
930
931 result = USB_STOR_TRANSPORT_GOOD;
932 index = offset = 0;
933
934 while (sectors > 0) {
935 /* Write as many sectors as possible in this block */
936 unsigned int pages = min(sectors, blocksize - page);
937 len = pages << pageshift;
938
939 /* Not overflowing capacity? */
940 if (lba >= max_lba) {
941 US_DEBUGP("alauda_write_data: Requested lba %u exceeds "
942 "maximum %u\n", lba, max_lba);
943 result = USB_STOR_TRANSPORT_ERROR;
944 break;
945 }
946
947 /* Get the data from the transfer buffer */
948 usb_stor_access_xfer_buf(buffer, len, us->srb,
949 &index, &offset, FROM_XFER_BUF);
950
951 result = alauda_write_lba(us, lba, page, pages, buffer,
952 blockbuffer);
953 if (result != USB_STOR_TRANSPORT_GOOD)
954 break;
955
956 page = 0;
957 lba++;
958 sectors -= pages;
959 }
960
961 kfree(buffer);
962 kfree(blockbuffer);
963 return result;
964}
965
966/*
967 * Our interface with the rest of the world
968 */
969
970static void alauda_info_destructor(void *extra)
971{
972 struct alauda_info *info = (struct alauda_info *) extra;
973 int port;
974
975 if (!info)
976 return;
977
978 for (port = 0; port < 2; port++) {
979 struct alauda_media_info *media_info = &info->port[port];
980
981 alauda_free_maps(media_info);
982 kfree(media_info->lba_to_pba);
983 kfree(media_info->pba_to_lba);
984 }
985}
986
987/*
988 * Initialize alauda_info struct and find the data-write endpoint
989 */
990int init_alauda(struct us_data *us)
991{
992 struct alauda_info *info;
993 struct usb_host_interface *altsetting = us->pusb_intf->cur_altsetting;
994 nand_init_ecc();
995
996 us->extra = kzalloc(sizeof(struct alauda_info), GFP_NOIO);
997 if (!us->extra) {
998 US_DEBUGP("init_alauda: Gah! Can't allocate storage for"
999 "alauda info struct!\n");
1000 return USB_STOR_TRANSPORT_ERROR;
1001 }
1002 info = (struct alauda_info *) us->extra;
1003 us->extra_destructor = alauda_info_destructor;
1004
1005 info->wr_ep = usb_sndbulkpipe(us->pusb_dev,
1006 altsetting->endpoint[0].desc.bEndpointAddress
1007 & USB_ENDPOINT_NUMBER_MASK);
1008
1009 return USB_STOR_TRANSPORT_GOOD;
1010}
1011
1012int alauda_transport(struct scsi_cmnd *srb, struct us_data *us)
1013{
1014 int rc;
1015 struct alauda_info *info = (struct alauda_info *) us->extra;
1016 unsigned char *ptr = us->iobuf;
1017 static unsigned char inquiry_response[36] = {
1018 0x00, 0x80, 0x00, 0x01, 0x1F, 0x00, 0x00, 0x00
1019 };
1020
1021 if (srb->cmnd[0] == INQUIRY) {
1022 US_DEBUGP("alauda_transport: INQUIRY. "
1023 "Returning bogus response.\n");
1024 memcpy(ptr, inquiry_response, sizeof(inquiry_response));
1025 fill_inquiry_response(us, ptr, 36);
1026 return USB_STOR_TRANSPORT_GOOD;
1027 }
1028
1029 if (srb->cmnd[0] == TEST_UNIT_READY) {
1030 US_DEBUGP("alauda_transport: TEST_UNIT_READY.\n");
1031 return alauda_check_media(us);
1032 }
1033
1034 if (srb->cmnd[0] == READ_CAPACITY) {
1035 unsigned int num_zones;
1036 unsigned long capacity;
1037
1038 rc = alauda_check_media(us);
1039 if (rc != USB_STOR_TRANSPORT_GOOD)
1040 return rc;
1041
1042 num_zones = MEDIA_INFO(us).capacity >> (MEDIA_INFO(us).zoneshift
1043 + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift);
1044
1045 capacity = num_zones * MEDIA_INFO(us).uzonesize
1046 * MEDIA_INFO(us).blocksize;
1047
1048 /* Report capacity and page size */
1049 ((__be32 *) ptr)[0] = cpu_to_be32(capacity - 1);
1050 ((__be32 *) ptr)[1] = cpu_to_be32(512);
1051
1052 usb_stor_set_xfer_buf(ptr, 8, srb);
1053 return USB_STOR_TRANSPORT_GOOD;
1054 }
1055
1056 if (srb->cmnd[0] == READ_10) {
1057 unsigned int page, pages;
1058
1059 rc = alauda_check_media(us);
1060 if (rc != USB_STOR_TRANSPORT_GOOD)
1061 return rc;
1062
1063 page = short_pack(srb->cmnd[3], srb->cmnd[2]);
1064 page <<= 16;
1065 page |= short_pack(srb->cmnd[5], srb->cmnd[4]);
1066 pages = short_pack(srb->cmnd[8], srb->cmnd[7]);
1067
1068 US_DEBUGP("alauda_transport: READ_10: page %d pagect %d\n",
1069 page, pages);
1070
1071 return alauda_read_data(us, page, pages);
1072 }
1073
1074 if (srb->cmnd[0] == WRITE_10) {
1075 unsigned int page, pages;
1076
1077 rc = alauda_check_media(us);
1078 if (rc != USB_STOR_TRANSPORT_GOOD)
1079 return rc;
1080
1081 page = short_pack(srb->cmnd[3], srb->cmnd[2]);
1082 page <<= 16;
1083 page |= short_pack(srb->cmnd[5], srb->cmnd[4]);
1084 pages = short_pack(srb->cmnd[8], srb->cmnd[7]);
1085
1086 US_DEBUGP("alauda_transport: WRITE_10: page %d pagect %d\n",
1087 page, pages);
1088
1089 return alauda_write_data(us, page, pages);
1090 }
1091
1092 if (srb->cmnd[0] == REQUEST_SENSE) {
1093 US_DEBUGP("alauda_transport: REQUEST_SENSE.\n");
1094
1095 memset(ptr, 0, 18);
1096 ptr[0] = 0xF0;
1097 ptr[2] = info->sense_key;
1098 ptr[7] = 11;
1099 ptr[12] = info->sense_asc;
1100 ptr[13] = info->sense_ascq;
1101 usb_stor_set_xfer_buf(ptr, 18, srb);
1102
1103 return USB_STOR_TRANSPORT_GOOD;
1104 }
1105
1106 if (srb->cmnd[0] == ALLOW_MEDIUM_REMOVAL) {
1107 /* sure. whatever. not like we can stop the user from popping
1108 the media out of the device (no locking doors, etc) */
1109 return USB_STOR_TRANSPORT_GOOD;
1110 }
1111
1112 US_DEBUGP("alauda_transport: Gah! Unknown command: %d (0x%x)\n",
1113 srb->cmnd[0], srb->cmnd[0]);
1114 info->sense_key = 0x05;
1115 info->sense_asc = 0x20;
1116 info->sense_ascq = 0x00;
1117 return USB_STOR_TRANSPORT_FAILED;
1118}
1119
diff --git a/drivers/usb/storage/alauda.h b/drivers/usb/storage/alauda.h
new file mode 100644
index 000000000000..a700f87d0803
--- /dev/null
+++ b/drivers/usb/storage/alauda.h
@@ -0,0 +1,100 @@
1/*
2 * Driver for Alauda-based card readers
3 *
4 * Current development and maintenance by:
5 * (c) 2005 Daniel Drake <dsd@gentoo.org>
6 *
7 * See alauda.c for more explanation.
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
11 * Free Software Foundation; either version 2, or (at your option) any
12 * later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#ifndef _USB_ALAUDA_H
25#define _USB_ALAUDA_H
26
27/*
28 * Status bytes
29 */
30#define ALAUDA_STATUS_ERROR 0x01
31#define ALAUDA_STATUS_READY 0x40
32
33/*
34 * Control opcodes (for request field)
35 */
36#define ALAUDA_GET_XD_MEDIA_STATUS 0x08
37#define ALAUDA_GET_SM_MEDIA_STATUS 0x98
38#define ALAUDA_ACK_XD_MEDIA_CHANGE 0x0a
39#define ALAUDA_ACK_SM_MEDIA_CHANGE 0x9a
40#define ALAUDA_GET_XD_MEDIA_SIG 0x86
41#define ALAUDA_GET_SM_MEDIA_SIG 0x96
42
43/*
44 * Bulk command identity (byte 0)
45 */
46#define ALAUDA_BULK_CMD 0x40
47
48/*
49 * Bulk opcodes (byte 1)
50 */
51#define ALAUDA_BULK_GET_REDU_DATA 0x85
52#define ALAUDA_BULK_READ_BLOCK 0x94
53#define ALAUDA_BULK_ERASE_BLOCK 0xa3
54#define ALAUDA_BULK_WRITE_BLOCK 0xb4
55#define ALAUDA_BULK_GET_STATUS2 0xb7
56#define ALAUDA_BULK_RESET_MEDIA 0xe0
57
58/*
59 * Port to operate on (byte 8)
60 */
61#define ALAUDA_PORT_XD 0x00
62#define ALAUDA_PORT_SM 0x01
63
64/*
65 * LBA and PBA are unsigned ints. Special values.
66 */
67#define UNDEF 0xffff
68#define SPARE 0xfffe
69#define UNUSABLE 0xfffd
70
71int init_alauda(struct us_data *us);
72int alauda_transport(struct scsi_cmnd *srb, struct us_data *us);
73
74struct alauda_media_info {
75 unsigned long capacity; /* total media size in bytes */
76 unsigned int pagesize; /* page size in bytes */
77 unsigned int blocksize; /* number of pages per block */
78 unsigned int uzonesize; /* number of usable blocks per zone */
79 unsigned int zonesize; /* number of blocks per zone */
80 unsigned int blockmask; /* mask to get page from address */
81
82 unsigned char pageshift;
83 unsigned char blockshift;
84 unsigned char zoneshift;
85
86 u16 **lba_to_pba; /* logical to physical block map */
87 u16 **pba_to_lba; /* physical to logical block map */
88};
89
90struct alauda_info {
91 struct alauda_media_info port[2];
92 int wr_ep; /* endpoint to write data out of */
93
94 unsigned char sense_key;
95 unsigned long sense_asc; /* additional sense code */
96 unsigned long sense_ascq; /* additional sense code qualifier */
97};
98
99#endif
100
diff --git a/drivers/usb/storage/debug.c b/drivers/usb/storage/debug.c
index 5a9321705a74..01e430654a13 100644
--- a/drivers/usb/storage/debug.c
+++ b/drivers/usb/storage/debug.c
@@ -132,6 +132,7 @@ void usb_stor_show_command(struct scsi_cmnd *srb)
132 case 0x5C: what = "READ BUFFER CAPACITY"; break; 132 case 0x5C: what = "READ BUFFER CAPACITY"; break;
133 case 0x5D: what = "SEND CUE SHEET"; break; 133 case 0x5D: what = "SEND CUE SHEET"; break;
134 case GPCMD_BLANK: what = "BLANK"; break; 134 case GPCMD_BLANK: what = "BLANK"; break;
135 case REPORT_LUNS: what = "REPORT LUNS"; break;
135 case MOVE_MEDIUM: what = "MOVE_MEDIUM or PLAY AUDIO (12)"; break; 136 case MOVE_MEDIUM: what = "MOVE_MEDIUM or PLAY AUDIO (12)"; break;
136 case READ_12: what = "READ_12"; break; 137 case READ_12: what = "READ_12"; break;
137 case WRITE_12: what = "WRITE_12"; break; 138 case WRITE_12: what = "WRITE_12"; break;
diff --git a/drivers/usb/storage/initializers.h b/drivers/usb/storage/initializers.h
index 7372386f33d5..4c1b2bd2e2e4 100644
--- a/drivers/usb/storage/initializers.h
+++ b/drivers/usb/storage/initializers.h
@@ -45,10 +45,6 @@
45 * mode */ 45 * mode */
46int usb_stor_euscsi_init(struct us_data *us); 46int usb_stor_euscsi_init(struct us_data *us);
47 47
48#ifdef CONFIG_USB_STORAGE_SDDR09
49int sddr09_init(struct us_data *us);
50#endif
51
52/* This function is required to activate all four slots on the UCR-61S2B 48/* This function is required to activate all four slots on the UCR-61S2B
53 * flash reader */ 49 * flash reader */
54int usb_stor_ucr61s2b_init(struct us_data *us); 50int usb_stor_ucr61s2b_init(struct us_data *us);
diff --git a/drivers/usb/storage/libusual.c b/drivers/usb/storage/libusual.c
new file mode 100644
index 000000000000..b28151d1b609
--- /dev/null
+++ b/drivers/usb/storage/libusual.c
@@ -0,0 +1,266 @@
1/*
2 * libusual
3 *
4 * The libusual contains the table of devices common for ub and usb-storage.
5 */
6#include <linux/kernel.h>
7#include <linux/module.h>
8#include <linux/usb.h>
9#include <linux/usb_usual.h>
10#include <linux/vmalloc.h>
11
12/*
13 */
14#define USU_MOD_FL_THREAD 1 /* Thread is running */
15#define USU_MOD_FL_PRESENT 2 /* The module is loaded */
16
17struct mod_status {
18 unsigned long fls;
19};
20
21static struct mod_status stat[3];
22static DEFINE_SPINLOCK(usu_lock);
23
24/*
25 */
26#define USB_US_DEFAULT_BIAS USB_US_TYPE_STOR
27static atomic_t usu_bias = ATOMIC_INIT(USB_US_DEFAULT_BIAS);
28
29#define BIAS_NAME_SIZE (sizeof("usb-storage"))
30static const char *bias_names[3] = { "none", "usb-storage", "ub" };
31
32static DECLARE_MUTEX_LOCKED(usu_init_notify);
33static DECLARE_COMPLETION(usu_end_notify);
34static atomic_t total_threads = ATOMIC_INIT(0);
35
36static int usu_probe_thread(void *arg);
37
38/*
39 * The table.
40 */
41#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
42 vendorName, productName,useProtocol, useTransport, \
43 initFunction, flags) \
44{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
45 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
46
47#define USUAL_DEV(useProto, useTrans, useType) \
48{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
49 .driver_info = ((useType)<<24) }
50
51struct usb_device_id storage_usb_ids [] = {
52# include "unusual_devs.h"
53 { } /* Terminating entry */
54};
55
56#undef USUAL_DEV
57#undef UNUSUAL_DEV
58
59MODULE_DEVICE_TABLE(usb, storage_usb_ids);
60EXPORT_SYMBOL_GPL(storage_usb_ids);
61
62/*
63 * @type: the module type as an integer
64 */
65void usb_usual_set_present(int type)
66{
67 struct mod_status *st;
68 unsigned long flags;
69
70 if (type <= 0 || type >= 3)
71 return;
72 st = &stat[type];
73 spin_lock_irqsave(&usu_lock, flags);
74 st->fls |= USU_MOD_FL_PRESENT;
75 spin_unlock_irqrestore(&usu_lock, flags);
76}
77EXPORT_SYMBOL_GPL(usb_usual_set_present);
78
79void usb_usual_clear_present(int type)
80{
81 struct mod_status *st;
82 unsigned long flags;
83
84 if (type <= 0 || type >= 3)
85 return;
86 st = &stat[type];
87 spin_lock_irqsave(&usu_lock, flags);
88 st->fls &= ~USU_MOD_FL_PRESENT;
89 spin_unlock_irqrestore(&usu_lock, flags);
90}
91EXPORT_SYMBOL_GPL(usb_usual_clear_present);
92
93/*
94 * Match the calling driver type against the table.
95 * Returns: 0 if the device matches.
96 */
97int usb_usual_check_type(const struct usb_device_id *id, int caller_type)
98{
99 int id_type = USB_US_TYPE(id->driver_info);
100
101 if (caller_type <= 0 || caller_type >= 3)
102 return -EINVAL;
103
104 /* Drivers grab fixed assignment devices */
105 if (id_type == caller_type)
106 return 0;
107 /* Drivers grab devices biased to them */
108 if (id_type == USB_US_TYPE_NONE && caller_type == atomic_read(&usu_bias))
109 return 0;
110 return -ENODEV;
111}
112EXPORT_SYMBOL_GPL(usb_usual_check_type);
113
114/*
115 */
116static int usu_probe(struct usb_interface *intf,
117 const struct usb_device_id *id)
118{
119 int type;
120 int rc;
121 unsigned long flags;
122
123 type = USB_US_TYPE(id->driver_info);
124 if (type == 0)
125 type = atomic_read(&usu_bias);
126
127 spin_lock_irqsave(&usu_lock, flags);
128 if ((stat[type].fls & (USU_MOD_FL_THREAD|USU_MOD_FL_PRESENT)) != 0) {
129 spin_unlock_irqrestore(&usu_lock, flags);
130 return -ENXIO;
131 }
132 stat[type].fls |= USU_MOD_FL_THREAD;
133 spin_unlock_irqrestore(&usu_lock, flags);
134
135 rc = kernel_thread(usu_probe_thread, (void*)type, CLONE_VM);
136 if (rc < 0) {
137 printk(KERN_WARNING "libusual: "
138 "Unable to start the thread for %s: %d\n",
139 bias_names[type], rc);
140 spin_lock_irqsave(&usu_lock, flags);
141 stat[type].fls &= ~USU_MOD_FL_THREAD;
142 spin_unlock_irqrestore(&usu_lock, flags);
143 return rc; /* Not being -ENXIO causes a message printed */
144 }
145 atomic_inc(&total_threads);
146
147 return -ENXIO;
148}
149
150static void usu_disconnect(struct usb_interface *intf)
151{
152 ; /* We should not be here. */
153}
154
155static struct usb_driver usu_driver = {
156 .name = "libusual",
157 .probe = usu_probe,
158 .disconnect = usu_disconnect,
159 .id_table = storage_usb_ids,
160};
161
162/*
163 * A whole new thread for a purpose of request_module seems quite stupid.
164 * The request_module forks once inside again. However, if we attempt
165 * to load a storage module from our own modprobe thread, that module
166 * references our symbols, which cannot be resolved until our module is
167 * initialized. I wish there was a way to wait for the end of initialization.
168 * The module notifier reports MODULE_STATE_COMING only.
169 * So, we wait until module->init ends as the next best thing.
170 */
171static int usu_probe_thread(void *arg)
172{
173 int type = (unsigned long) arg;
174 struct mod_status *st = &stat[type];
175 int rc;
176 unsigned long flags;
177
178 daemonize("libusual_%d", type); /* "usb-storage" is kinda too long */
179
180 /* A completion does not work here because it's counted. */
181 down(&usu_init_notify);
182 up(&usu_init_notify);
183
184 rc = request_module(bias_names[type]);
185 spin_lock_irqsave(&usu_lock, flags);
186 if (rc == 0 && (st->fls & USU_MOD_FL_PRESENT) == 0) {
187 /*
188 * This should not happen, but let us keep tabs on it.
189 */
190 printk(KERN_NOTICE "libusual: "
191 "modprobe for %s succeeded, but module is not present\n",
192 bias_names[type]);
193 }
194 st->fls &= ~USU_MOD_FL_THREAD;
195 spin_unlock_irqrestore(&usu_lock, flags);
196
197 complete_and_exit(&usu_end_notify, 0);
198}
199
200/*
201 */
202static int __init usb_usual_init(void)
203{
204 int rc;
205
206 rc = usb_register(&usu_driver);
207 up(&usu_init_notify);
208 return rc;
209}
210
211static void __exit usb_usual_exit(void)
212{
213 /*
214 * We do not check for any drivers present, because
215 * they keep us pinned with symbol references.
216 */
217
218 usb_deregister(&usu_driver);
219
220 while (atomic_read(&total_threads) > 0) {
221 wait_for_completion(&usu_end_notify);
222 atomic_dec(&total_threads);
223 }
224}
225
226/*
227 * Validate and accept the bias parameter.
228 */
229static int usu_set_bias(const char *bias_s, struct kernel_param *kp)
230{
231 int i;
232 int len;
233 int bias_n = 0;
234
235 len = strlen(bias_s);
236 if (len == 0)
237 return -EDOM;
238 if (bias_s[len-1] == '\n')
239 --len;
240
241 for (i = 1; i < 3; i++) {
242 if (strncmp(bias_s, bias_names[i], len) == 0) {
243 bias_n = i;
244 break;
245 }
246 }
247 if (bias_n == 0)
248 return -EINVAL;
249
250 atomic_set(&usu_bias, bias_n);
251 return 0;
252}
253
254static int usu_get_bias(char *buffer, struct kernel_param *kp)
255{
256 return strlen(strcpy(buffer, bias_names[atomic_read(&usu_bias)]));
257}
258
259module_init(usb_usual_init);
260module_exit(usb_usual_exit);
261
262module_param_call(bias, usu_set_bias, usu_get_bias, NULL, S_IRUGO|S_IWUSR);
263__MODULE_PARM_TYPE(bias, "string");
264MODULE_PARM_DESC(bias, "Bias to usb-storage or ub");
265
266MODULE_LICENSE("GPL");
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 89401a59f952..55ee2d36d585 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -52,6 +52,7 @@ struct usb_onetouch {
52 struct urb *irq; /* urb for interrupt in report */ 52 struct urb *irq; /* urb for interrupt in report */
53 unsigned char *data; /* input data */ 53 unsigned char *data; /* input data */
54 dma_addr_t data_dma; 54 dma_addr_t data_dma;
55 unsigned int is_open:1;
55}; 56};
56 57
57static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs) 58static void usb_onetouch_irq(struct urb *urb, struct pt_regs *regs)
@@ -89,6 +90,7 @@ static int usb_onetouch_open(struct input_dev *dev)
89{ 90{
90 struct usb_onetouch *onetouch = dev->private; 91 struct usb_onetouch *onetouch = dev->private;
91 92
93 onetouch->is_open = 1;
92 onetouch->irq->dev = onetouch->udev; 94 onetouch->irq->dev = onetouch->udev;
93 if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) { 95 if (usb_submit_urb(onetouch->irq, GFP_KERNEL)) {
94 err("usb_submit_urb failed"); 96 err("usb_submit_urb failed");
@@ -103,8 +105,30 @@ static void usb_onetouch_close(struct input_dev *dev)
103 struct usb_onetouch *onetouch = dev->private; 105 struct usb_onetouch *onetouch = dev->private;
104 106
105 usb_kill_urb(onetouch->irq); 107 usb_kill_urb(onetouch->irq);
108 onetouch->is_open = 0;
106} 109}
107 110
111#ifdef CONFIG_PM
112static void usb_onetouch_pm_hook(struct us_data *us, int action)
113{
114 struct usb_onetouch *onetouch = (struct usb_onetouch *) us->extra;
115
116 if (onetouch->is_open) {
117 switch (action) {
118 case US_SUSPEND:
119 usb_kill_urb(onetouch->irq);
120 break;
121 case US_RESUME:
122 if (usb_submit_urb(onetouch->irq, GFP_KERNEL) != 0)
123 err("usb_submit_urb failed");
124 break;
125 default:
126 break;
127 }
128 }
129}
130#endif /* CONFIG_PM */
131
108int onetouch_connect_input(struct us_data *ss) 132int onetouch_connect_input(struct us_data *ss)
109{ 133{
110 struct usb_device *udev = ss->pusb_dev; 134 struct usb_device *udev = ss->pusb_dev;
@@ -185,6 +209,9 @@ int onetouch_connect_input(struct us_data *ss)
185 209
186 ss->extra_destructor = onetouch_release_input; 210 ss->extra_destructor = onetouch_release_input;
187 ss->extra = onetouch; 211 ss->extra = onetouch;
212#ifdef CONFIG_PM
213 ss->suspend_resume_hook = usb_onetouch_pm_hook;
214#endif
188 215
189 input_register_device(onetouch->dev); 216 input_register_device(onetouch->dev);
190 217
diff --git a/drivers/usb/storage/protocol.h b/drivers/usb/storage/protocol.h
index 02bff01ab09c..845bed4b8031 100644
--- a/drivers/usb/storage/protocol.h
+++ b/drivers/usb/storage/protocol.h
@@ -41,20 +41,6 @@
41#ifndef _PROTOCOL_H_ 41#ifndef _PROTOCOL_H_
42#define _PROTOCOL_H_ 42#define _PROTOCOL_H_
43 43
44/* Sub Classes */
45
46#define US_SC_RBC 0x01 /* Typically, flash devices */
47#define US_SC_8020 0x02 /* CD-ROM */
48#define US_SC_QIC 0x03 /* QIC-157 Tapes */
49#define US_SC_UFI 0x04 /* Floppy */
50#define US_SC_8070 0x05 /* Removable media */
51#define US_SC_SCSI 0x06 /* Transparent */
52#define US_SC_ISD200 0x07 /* ISD200 ATA */
53#define US_SC_MIN US_SC_RBC
54#define US_SC_MAX US_SC_ISD200
55
56#define US_SC_DEVICE 0xff /* Use device's value */
57
58/* Protocol handling routines */ 44/* Protocol handling routines */
59extern void usb_stor_ATAPI_command(struct scsi_cmnd*, struct us_data*); 45extern void usb_stor_ATAPI_command(struct scsi_cmnd*, struct us_data*);
60extern void usb_stor_qic157_command(struct scsi_cmnd*, struct us_data*); 46extern void usb_stor_qic157_command(struct scsi_cmnd*, struct us_data*);
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 4837524eada7..4ef5527028c5 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -109,7 +109,7 @@ static int slave_configure(struct scsi_device *sdev)
109 * data comes from. 109 * data comes from.
110 */ 110 */
111 if (sdev->scsi_level < SCSI_2) 111 if (sdev->scsi_level < SCSI_2)
112 sdev->scsi_level = SCSI_2; 112 sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2;
113 113
114 /* According to the technical support people at Genesys Logic, 114 /* According to the technical support people at Genesys Logic,
115 * devices using their chips have problems transferring more than 115 * devices using their chips have problems transferring more than
@@ -162,7 +162,7 @@ static int slave_configure(struct scsi_device *sdev)
162 * a Get-Max-LUN request, we won't lose much by setting the 162 * a Get-Max-LUN request, we won't lose much by setting the
163 * revision level down to 2. The only devices that would be 163 * revision level down to 2. The only devices that would be
164 * affected are those with sparse LUNs. */ 164 * affected are those with sparse LUNs. */
165 sdev->scsi_level = SCSI_2; 165 sdev->scsi_level = sdev->sdev_target->scsi_level = SCSI_2;
166 166
167 /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable 167 /* USB-IDE bridges tend to report SK = 0x04 (Non-recoverable
168 * Hardware Error) when any low-level error occurs, 168 * Hardware Error) when any low-level error occurs,
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c
index 0ea2f5ab66ba..fb8bacaae27c 100644
--- a/drivers/usb/storage/sddr09.c
+++ b/drivers/usb/storage/sddr09.c
@@ -133,13 +133,11 @@ static struct nand_flash_dev nand_flash_ids[] = {
133 { 0,} 133 { 0,}
134}; 134};
135 135
136#define SIZE(a) (sizeof(a)/sizeof((a)[0]))
137
138static struct nand_flash_dev * 136static struct nand_flash_dev *
139nand_find_id(unsigned char id) { 137nand_find_id(unsigned char id) {
140 int i; 138 int i;
141 139
142 for (i = 0; i < SIZE(nand_flash_ids); i++) 140 for (i = 0; i < ARRAY_SIZE(nand_flash_ids); i++)
143 if (nand_flash_ids[i].model_id == id) 141 if (nand_flash_ids[i].model_id == id)
144 return &(nand_flash_ids[i]); 142 return &(nand_flash_ids[i]);
145 return NULL; 143 return NULL;
@@ -214,6 +212,20 @@ static void nand_store_ecc(unsigned char *data, unsigned char *ecc) {
214 * The actual driver starts here. 212 * The actual driver starts here.
215 */ 213 */
216 214
215struct sddr09_card_info {
216 unsigned long capacity; /* Size of card in bytes */
217 int pagesize; /* Size of page in bytes */
218 int pageshift; /* log2 of pagesize */
219 int blocksize; /* Size of block in pages */
220 int blockshift; /* log2 of blocksize */
221 int blockmask; /* 2^blockshift - 1 */
222 int *lba_to_pba; /* logical to physical map */
223 int *pba_to_lba; /* physical to logical map */
224 int lbact; /* number of available pages */
225 int flags;
226#define SDDR09_WP 1 /* write protected */
227};
228
217/* 229/*
218 * On my 16MB card, control blocks have size 64 (16 real control bytes, 230 * On my 16MB card, control blocks have size 64 (16 real control bytes,
219 * and 48 junk bytes). In reality of course the card uses 16 control bytes, 231 * and 48 junk bytes). In reality of course the card uses 16 control bytes,
@@ -237,7 +249,7 @@ static void nand_store_ecc(unsigned char *data, unsigned char *ecc) {
237#define SPARE 0xfffffffe 249#define SPARE 0xfffffffe
238#define UNUSABLE 0xfffffffd 250#define UNUSABLE 0xfffffffd
239 251
240static int erase_bad_lba_entries = 0; 252static const int erase_bad_lba_entries = 0;
241 253
242/* send vendor interface command (0x41) */ 254/* send vendor interface command (0x41) */
243/* called for requests 0, 1, 8 */ 255/* called for requests 0, 1, 8 */
@@ -260,8 +272,11 @@ sddr09_send_command(struct us_data *us,
260 272
261 rc = usb_stor_ctrl_transfer(us, pipe, request, requesttype, 273 rc = usb_stor_ctrl_transfer(us, pipe, request, requesttype,
262 0, 0, xfer_data, xfer_len); 274 0, 0, xfer_data, xfer_len);
263 return (rc == USB_STOR_XFER_GOOD ? USB_STOR_TRANSPORT_GOOD : 275 switch (rc) {
264 USB_STOR_TRANSPORT_ERROR); 276 case USB_STOR_XFER_GOOD: return 0;
277 case USB_STOR_XFER_STALLED: return -EPIPE;
278 default: return -EIO;
279 }
265} 280}
266 281
267static int 282static int
@@ -308,20 +323,12 @@ sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) {
308 command[4] = buflen; 323 command[4] = buflen;
309 324
310 result = sddr09_send_scsi_command(us, command, 12); 325 result = sddr09_send_scsi_command(us, command, 12);
311 if (result != USB_STOR_TRANSPORT_GOOD) { 326 if (result)
312 US_DEBUGP("request sense failed\n");
313 return result; 327 return result;
314 }
315 328
316 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 329 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
317 sensebuf, buflen, NULL); 330 sensebuf, buflen, NULL);
318 if (result != USB_STOR_XFER_GOOD) { 331 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO);
319 US_DEBUGP("request sense bulk in failed\n");
320 return USB_STOR_TRANSPORT_ERROR;
321 } else {
322 US_DEBUGP("request sense worked\n");
323 return USB_STOR_TRANSPORT_GOOD;
324 }
325} 332}
326 333
327/* 334/*
@@ -369,7 +376,7 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
369 376
370 result = sddr09_send_scsi_command(us, command, 12); 377 result = sddr09_send_scsi_command(us, command, 12);
371 378
372 if (result != USB_STOR_TRANSPORT_GOOD) { 379 if (result) {
373 US_DEBUGP("Result for send_control in sddr09_read2%d %d\n", 380 US_DEBUGP("Result for send_control in sddr09_read2%d %d\n",
374 x, result); 381 x, result);
375 return result; 382 return result;
@@ -381,9 +388,9 @@ sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
381 if (result != USB_STOR_XFER_GOOD) { 388 if (result != USB_STOR_XFER_GOOD) {
382 US_DEBUGP("Result for bulk_transfer in sddr09_read2%d %d\n", 389 US_DEBUGP("Result for bulk_transfer in sddr09_read2%d %d\n",
383 x, result); 390 x, result);
384 return USB_STOR_TRANSPORT_ERROR; 391 return -EIO;
385 } 392 }
386 return USB_STOR_TRANSPORT_GOOD; 393 return 0;
387} 394}
388 395
389/* 396/*
@@ -497,7 +504,7 @@ sddr09_erase(struct us_data *us, unsigned long Eaddress) {
497 504
498 result = sddr09_send_scsi_command(us, command, 12); 505 result = sddr09_send_scsi_command(us, command, 12);
499 506
500 if (result != USB_STOR_TRANSPORT_GOOD) 507 if (result)
501 US_DEBUGP("Result for send_control in sddr09_erase %d\n", 508 US_DEBUGP("Result for send_control in sddr09_erase %d\n",
502 result); 509 result);
503 510
@@ -555,7 +562,7 @@ sddr09_writeX(struct us_data *us,
555 562
556 result = sddr09_send_scsi_command(us, command, 12); 563 result = sddr09_send_scsi_command(us, command, 12);
557 564
558 if (result != USB_STOR_TRANSPORT_GOOD) { 565 if (result) {
559 US_DEBUGP("Result for send_control in sddr09_writeX %d\n", 566 US_DEBUGP("Result for send_control in sddr09_writeX %d\n",
560 result); 567 result);
561 return result; 568 return result;
@@ -567,9 +574,9 @@ sddr09_writeX(struct us_data *us,
567 if (result != USB_STOR_XFER_GOOD) { 574 if (result != USB_STOR_XFER_GOOD) {
568 US_DEBUGP("Result for bulk_transfer in sddr09_writeX %d\n", 575 US_DEBUGP("Result for bulk_transfer in sddr09_writeX %d\n",
569 result); 576 result);
570 return USB_STOR_TRANSPORT_ERROR; 577 return -EIO;
571 } 578 }
572 return USB_STOR_TRANSPORT_GOOD; 579 return 0;
573} 580}
574 581
575/* erase address, write same address */ 582/* erase address, write same address */
@@ -633,7 +640,7 @@ sddr09_read_sg_test_only(struct us_data *us) {
633 640
634 result = sddr09_send_scsi_command(us, command, 4*nsg+3); 641 result = sddr09_send_scsi_command(us, command, 4*nsg+3);
635 642
636 if (result != USB_STOR_TRANSPORT_GOOD) { 643 if (result) {
637 US_DEBUGP("Result for send_control in sddr09_read_sg %d\n", 644 US_DEBUGP("Result for send_control in sddr09_read_sg %d\n",
638 result); 645 result);
639 return result; 646 return result;
@@ -641,7 +648,7 @@ sddr09_read_sg_test_only(struct us_data *us) {
641 648
642 buf = (unsigned char *) kmalloc(bulklen, GFP_NOIO); 649 buf = (unsigned char *) kmalloc(bulklen, GFP_NOIO);
643 if (!buf) 650 if (!buf)
644 return USB_STOR_TRANSPORT_ERROR; 651 return -ENOMEM;
645 652
646 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 653 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
647 buf, bulklen, NULL); 654 buf, bulklen, NULL);
@@ -649,10 +656,10 @@ sddr09_read_sg_test_only(struct us_data *us) {
649 if (result != USB_STOR_XFER_GOOD) { 656 if (result != USB_STOR_XFER_GOOD) {
650 US_DEBUGP("Result for bulk_transfer in sddr09_read_sg %d\n", 657 US_DEBUGP("Result for bulk_transfer in sddr09_read_sg %d\n",
651 result); 658 result);
652 return USB_STOR_TRANSPORT_ERROR; 659 return -EIO;
653 } 660 }
654 661
655 return USB_STOR_TRANSPORT_GOOD; 662 return 0;
656} 663}
657#endif 664#endif
658 665
@@ -681,14 +688,13 @@ sddr09_read_status(struct us_data *us, unsigned char *status) {
681 command[1] = LUNBITS; 688 command[1] = LUNBITS;
682 689
683 result = sddr09_send_scsi_command(us, command, 12); 690 result = sddr09_send_scsi_command(us, command, 12);
684 if (result != USB_STOR_TRANSPORT_GOOD) 691 if (result)
685 return result; 692 return result;
686 693
687 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 694 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
688 data, 64, NULL); 695 data, 64, NULL);
689 *status = data[0]; 696 *status = data[0];
690 return (result == USB_STOR_XFER_GOOD ? 697 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO);
691 USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
692} 698}
693 699
694static int 700static int
@@ -703,6 +709,13 @@ sddr09_read_data(struct us_data *us,
703 unsigned int len, index, offset; 709 unsigned int len, index, offset;
704 int result; 710 int result;
705 711
712 // Figure out the initial LBA and page
713 lba = address >> info->blockshift;
714 page = (address & info->blockmask);
715 maxlba = info->capacity >> (info->pageshift + info->blockshift);
716 if (lba >= maxlba)
717 return -EIO;
718
706 // Since we only read in one block at a time, we have to create 719 // Since we only read in one block at a time, we have to create
707 // a bounce buffer and move the data a piece at a time between the 720 // a bounce buffer and move the data a piece at a time between the
708 // bounce buffer and the actual transfer buffer. 721 // bounce buffer and the actual transfer buffer.
@@ -711,18 +724,13 @@ sddr09_read_data(struct us_data *us,
711 buffer = kmalloc(len, GFP_NOIO); 724 buffer = kmalloc(len, GFP_NOIO);
712 if (buffer == NULL) { 725 if (buffer == NULL) {
713 printk("sddr09_read_data: Out of memory\n"); 726 printk("sddr09_read_data: Out of memory\n");
714 return USB_STOR_TRANSPORT_ERROR; 727 return -ENOMEM;
715 } 728 }
716 729
717 // Figure out the initial LBA and page
718 lba = address >> info->blockshift;
719 page = (address & info->blockmask);
720 maxlba = info->capacity >> (info->pageshift + info->blockshift);
721
722 // This could be made much more efficient by checking for 730 // This could be made much more efficient by checking for
723 // contiguous LBA's. Another exercise left to the student. 731 // contiguous LBA's. Another exercise left to the student.
724 732
725 result = USB_STOR_TRANSPORT_GOOD; 733 result = 0;
726 index = offset = 0; 734 index = offset = 0;
727 735
728 while (sectors > 0) { 736 while (sectors > 0) {
@@ -735,7 +743,7 @@ sddr09_read_data(struct us_data *us,
735 if (lba >= maxlba) { 743 if (lba >= maxlba) {
736 US_DEBUGP("Error: Requested lba %u exceeds " 744 US_DEBUGP("Error: Requested lba %u exceeds "
737 "maximum %u\n", lba, maxlba); 745 "maximum %u\n", lba, maxlba);
738 result = USB_STOR_TRANSPORT_ERROR; 746 result = -EIO;
739 break; 747 break;
740 } 748 }
741 749
@@ -749,7 +757,7 @@ sddr09_read_data(struct us_data *us,
749 757
750 /* This is not really an error. It just means 758 /* This is not really an error. It just means
751 that the block has never been written. 759 that the block has never been written.
752 Instead of returning USB_STOR_TRANSPORT_ERROR 760 Instead of returning an error
753 it is better to return all zero data. */ 761 it is better to return all zero data. */
754 762
755 memset(buffer, 0, len); 763 memset(buffer, 0, len);
@@ -764,7 +772,7 @@ sddr09_read_data(struct us_data *us,
764 772
765 result = sddr09_read20(us, address>>1, 773 result = sddr09_read20(us, address>>1,
766 pages, info->pageshift, buffer, 0); 774 pages, info->pageshift, buffer, 0);
767 if (result != USB_STOR_TRANSPORT_GOOD) 775 if (result)
768 break; 776 break;
769 } 777 }
770 778
@@ -830,7 +838,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
830 pba = sddr09_find_unused_pba(info, lba); 838 pba = sddr09_find_unused_pba(info, lba);
831 if (!pba) { 839 if (!pba) {
832 printk("sddr09_write_lba: Out of unused blocks\n"); 840 printk("sddr09_write_lba: Out of unused blocks\n");
833 return USB_STOR_TRANSPORT_ERROR; 841 return -ENOSPC;
834 } 842 }
835 info->pba_to_lba[pba] = lba; 843 info->pba_to_lba[pba] = lba;
836 info->lba_to_pba[lba] = pba; 844 info->lba_to_pba[lba] = pba;
@@ -841,7 +849,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
841 /* Maybe it is impossible to write to PBA 1. 849 /* Maybe it is impossible to write to PBA 1.
842 Fake success, but don't do anything. */ 850 Fake success, but don't do anything. */
843 printk("sddr09: avoid writing to pba 1\n"); 851 printk("sddr09: avoid writing to pba 1\n");
844 return USB_STOR_TRANSPORT_GOOD; 852 return 0;
845 } 853 }
846 854
847 pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT); 855 pagelen = (1 << info->pageshift) + (1 << CONTROL_SHIFT);
@@ -850,7 +858,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
850 address = (pba << (info->pageshift + info->blockshift)); 858 address = (pba << (info->pageshift + info->blockshift));
851 result = sddr09_read22(us, address>>1, info->blocksize, 859 result = sddr09_read22(us, address>>1, info->blocksize,
852 info->pageshift, blockbuffer, 0); 860 info->pageshift, blockbuffer, 0);
853 if (result != USB_STOR_TRANSPORT_GOOD) 861 if (result)
854 return result; 862 return result;
855 863
856 /* check old contents and fill lba */ 864 /* check old contents and fill lba */
@@ -897,7 +905,7 @@ sddr09_write_lba(struct us_data *us, unsigned int lba,
897 { 905 {
898 unsigned char status = 0; 906 unsigned char status = 0;
899 int result2 = sddr09_read_status(us, &status); 907 int result2 = sddr09_read_status(us, &status);
900 if (result2 != USB_STOR_TRANSPORT_GOOD) 908 if (result2)
901 US_DEBUGP("sddr09_write_inplace: cannot read status\n"); 909 US_DEBUGP("sddr09_write_inplace: cannot read status\n");
902 else if (status != 0xc0) 910 else if (status != 0xc0)
903 US_DEBUGP("sddr09_write_inplace: status after write: 0x%x\n", 911 US_DEBUGP("sddr09_write_inplace: status after write: 0x%x\n",
@@ -920,13 +928,20 @@ sddr09_write_data(struct us_data *us,
920 unsigned int sectors) { 928 unsigned int sectors) {
921 929
922 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra; 930 struct sddr09_card_info *info = (struct sddr09_card_info *) us->extra;
923 unsigned int lba, page, pages; 931 unsigned int lba, maxlba, page, pages;
924 unsigned int pagelen, blocklen; 932 unsigned int pagelen, blocklen;
925 unsigned char *blockbuffer; 933 unsigned char *blockbuffer;
926 unsigned char *buffer; 934 unsigned char *buffer;
927 unsigned int len, index, offset; 935 unsigned int len, index, offset;
928 int result; 936 int result;
929 937
938 // Figure out the initial LBA and page
939 lba = address >> info->blockshift;
940 page = (address & info->blockmask);
941 maxlba = info->capacity >> (info->pageshift + info->blockshift);
942 if (lba >= maxlba)
943 return -EIO;
944
930 // blockbuffer is used for reading in the old data, overwriting 945 // blockbuffer is used for reading in the old data, overwriting
931 // with the new data, and performing ECC calculations 946 // with the new data, and performing ECC calculations
932 947
@@ -938,7 +953,7 @@ sddr09_write_data(struct us_data *us,
938 blockbuffer = kmalloc(blocklen, GFP_NOIO); 953 blockbuffer = kmalloc(blocklen, GFP_NOIO);
939 if (!blockbuffer) { 954 if (!blockbuffer) {
940 printk("sddr09_write_data: Out of memory\n"); 955 printk("sddr09_write_data: Out of memory\n");
941 return USB_STOR_TRANSPORT_ERROR; 956 return -ENOMEM;
942 } 957 }
943 958
944 // Since we don't write the user data directly to the device, 959 // Since we don't write the user data directly to the device,
@@ -950,14 +965,10 @@ sddr09_write_data(struct us_data *us,
950 if (buffer == NULL) { 965 if (buffer == NULL) {
951 printk("sddr09_write_data: Out of memory\n"); 966 printk("sddr09_write_data: Out of memory\n");
952 kfree(blockbuffer); 967 kfree(blockbuffer);
953 return USB_STOR_TRANSPORT_ERROR; 968 return -ENOMEM;
954 } 969 }
955 970
956 // Figure out the initial LBA and page 971 result = 0;
957 lba = address >> info->blockshift;
958 page = (address & info->blockmask);
959
960 result = USB_STOR_TRANSPORT_GOOD;
961 index = offset = 0; 972 index = offset = 0;
962 973
963 while (sectors > 0) { 974 while (sectors > 0) {
@@ -967,13 +978,21 @@ sddr09_write_data(struct us_data *us,
967 pages = min(sectors, info->blocksize - page); 978 pages = min(sectors, info->blocksize - page);
968 len = (pages << info->pageshift); 979 len = (pages << info->pageshift);
969 980
981 /* Not overflowing capacity? */
982 if (lba >= maxlba) {
983 US_DEBUGP("Error: Requested lba %u exceeds "
984 "maximum %u\n", lba, maxlba);
985 result = -EIO;
986 break;
987 }
988
970 // Get the data from the transfer buffer 989 // Get the data from the transfer buffer
971 usb_stor_access_xfer_buf(buffer, len, us->srb, 990 usb_stor_access_xfer_buf(buffer, len, us->srb,
972 &index, &offset, FROM_XFER_BUF); 991 &index, &offset, FROM_XFER_BUF);
973 992
974 result = sddr09_write_lba(us, lba, page, pages, 993 result = sddr09_write_lba(us, lba, page, pages,
975 buffer, blockbuffer); 994 buffer, blockbuffer);
976 if (result != USB_STOR_TRANSPORT_GOOD) 995 if (result)
977 break; 996 break;
978 997
979 page = 0; 998 page = 0;
@@ -1022,7 +1041,7 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) {
1022 command[1] = LUNBITS; 1041 command[1] = LUNBITS;
1023 1042
1024 result = sddr09_send_scsi_command(us, command, 12); 1043 result = sddr09_send_scsi_command(us, command, 12);
1025 if (result != USB_STOR_TRANSPORT_GOOD) 1044 if (result)
1026 return result; 1045 return result;
1027 1046
1028 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe, 1047 result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
@@ -1031,8 +1050,7 @@ sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) {
1031 for (i = 0; i < 4; i++) 1050 for (i = 0; i < 4; i++)
1032 deviceID[i] = content[i]; 1051 deviceID[i] = content[i];
1033 1052
1034 return (result == USB_STOR_XFER_GOOD ? 1053 return (result == USB_STOR_XFER_GOOD ? 0 : -EIO);
1035 USB_STOR_TRANSPORT_GOOD : USB_STOR_TRANSPORT_ERROR);
1036} 1054}
1037 1055
1038static int 1056static int
@@ -1041,7 +1059,7 @@ sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) {
1041 unsigned char status; 1059 unsigned char status;
1042 1060
1043 result = sddr09_read_status(us, &status); 1061 result = sddr09_read_status(us, &status);
1044 if (result != USB_STOR_TRANSPORT_GOOD) { 1062 if (result) {
1045 US_DEBUGP("sddr09_get_wp: read_status fails\n"); 1063 US_DEBUGP("sddr09_get_wp: read_status fails\n");
1046 return result; 1064 return result;
1047 } 1065 }
@@ -1057,7 +1075,7 @@ sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) {
1057 if (status & 0x1) 1075 if (status & 0x1)
1058 US_DEBUGP(" Error"); 1076 US_DEBUGP(" Error");
1059 US_DEBUGP("\n"); 1077 US_DEBUGP("\n");
1060 return USB_STOR_TRANSPORT_GOOD; 1078 return 0;
1061} 1079}
1062 1080
1063#if 0 1081#if 0
@@ -1089,7 +1107,7 @@ sddr09_get_cardinfo(struct us_data *us, unsigned char flags) {
1089 1107
1090 result = sddr09_read_deviceID(us, deviceID); 1108 result = sddr09_read_deviceID(us, deviceID);
1091 1109
1092 if (result != USB_STOR_TRANSPORT_GOOD) { 1110 if (result) {
1093 US_DEBUGP("Result of read_deviceID is %d\n", result); 1111 US_DEBUGP("Result of read_deviceID is %d\n", result);
1094 printk("sddr09: could not read card info\n"); 1112 printk("sddr09: could not read card info\n");
1095 return NULL; 1113 return NULL;
@@ -1200,7 +1218,7 @@ sddr09_read_map(struct us_data *us) {
1200 us, address>>1, 1218 us, address>>1,
1201 min(alloc_blocks, numblocks - i), 1219 min(alloc_blocks, numblocks - i),
1202 buffer, 0); 1220 buffer, 0);
1203 if (result != USB_STOR_TRANSPORT_GOOD) { 1221 if (result) {
1204 result = -1; 1222 result = -1;
1205 goto done; 1223 goto done;
1206 } 1224 }
@@ -1342,29 +1360,53 @@ sddr09_card_info_destructor(void *extra) {
1342 kfree(info->pba_to_lba); 1360 kfree(info->pba_to_lba);
1343} 1361}
1344 1362
1345static void 1363static int
1346sddr09_init_card_info(struct us_data *us) { 1364sddr09_common_init(struct us_data *us) {
1347 if (!us->extra) { 1365 int result;
1348 us->extra = kmalloc(sizeof(struct sddr09_card_info), GFP_NOIO); 1366
1349 if (us->extra) { 1367 /* set the configuration -- STALL is an acceptable response here */
1350 memset(us->extra, 0, sizeof(struct sddr09_card_info)); 1368 if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) {
1351 us->extra_destructor = sddr09_card_info_destructor; 1369 US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev
1352 } 1370 ->actconfig->desc.bConfigurationValue);
1371 return -EINVAL;
1372 }
1373
1374 result = usb_reset_configuration(us->pusb_dev);
1375 US_DEBUGP("Result of usb_reset_configuration is %d\n", result);
1376 if (result == -EPIPE) {
1377 US_DEBUGP("-- stall on control interface\n");
1378 } else if (result != 0) {
1379 /* it's not a stall, but another error -- time to bail */
1380 US_DEBUGP("-- Unknown error. Rejecting device\n");
1381 return -EINVAL;
1353 } 1382 }
1383
1384 us->extra = kzalloc(sizeof(struct sddr09_card_info), GFP_NOIO);
1385 if (!us->extra)
1386 return -ENOMEM;
1387 us->extra_destructor = sddr09_card_info_destructor;
1388
1389 nand_init_ecc();
1390 return 0;
1354} 1391}
1355 1392
1393
1356/* 1394/*
1357 * This is needed at a very early stage. If this is not listed in the 1395 * This is needed at a very early stage. If this is not listed in the
1358 * unusual devices list but called from here then LUN 0 of the combo reader 1396 * unusual devices list but called from here then LUN 0 of the combo reader
1359 * is not recognized. But I do not know what precisely these calls do. 1397 * is not recognized. But I do not know what precisely these calls do.
1360 */ 1398 */
1361int 1399int
1362sddr09_init(struct us_data *us) { 1400usb_stor_sddr09_dpcm_init(struct us_data *us) {
1363 int result; 1401 int result;
1364 unsigned char *data = us->iobuf; 1402 unsigned char *data = us->iobuf;
1365 1403
1404 result = sddr09_common_init(us);
1405 if (result)
1406 return result;
1407
1366 result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2); 1408 result = sddr09_send_command(us, 0x01, USB_DIR_IN, data, 2);
1367 if (result != USB_STOR_TRANSPORT_GOOD) { 1409 if (result) {
1368 US_DEBUGP("sddr09_init: send_command fails\n"); 1410 US_DEBUGP("sddr09_init: send_command fails\n");
1369 return result; 1411 return result;
1370 } 1412 }
@@ -1373,7 +1415,7 @@ sddr09_init(struct us_data *us) {
1373 // get 07 02 1415 // get 07 02
1374 1416
1375 result = sddr09_send_command(us, 0x08, USB_DIR_IN, data, 2); 1417 result = sddr09_send_command(us, 0x08, USB_DIR_IN, data, 2);
1376 if (result != USB_STOR_TRANSPORT_GOOD) { 1418 if (result) {
1377 US_DEBUGP("sddr09_init: 2nd send_command fails\n"); 1419 US_DEBUGP("sddr09_init: 2nd send_command fails\n");
1378 return result; 1420 return result;
1379 } 1421 }
@@ -1382,7 +1424,7 @@ sddr09_init(struct us_data *us) {
1382 // get 07 00 1424 // get 07 00
1383 1425
1384 result = sddr09_request_sense(us, data, 18); 1426 result = sddr09_request_sense(us, data, 18);
1385 if (result == USB_STOR_TRANSPORT_GOOD && data[2] != 0) { 1427 if (result == 0 && data[2] != 0) {
1386 int j; 1428 int j;
1387 for (j=0; j<18; j++) 1429 for (j=0; j<18; j++)
1388 printk(" %02X", data[j]); 1430 printk(" %02X", data[j]);
@@ -1398,7 +1440,7 @@ sddr09_init(struct us_data *us) {
1398 1440
1399 // test unit ready 1441 // test unit ready
1400 1442
1401 return USB_STOR_TRANSPORT_GOOD; /* not result */ 1443 return 0; /* not result */
1402} 1444}
1403 1445
1404/* 1446/*
@@ -1427,13 +1469,6 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1427 }; 1469 };
1428 1470
1429 info = (struct sddr09_card_info *)us->extra; 1471 info = (struct sddr09_card_info *)us->extra;
1430 if (!info) {
1431 nand_init_ecc();
1432 sddr09_init_card_info(us);
1433 info = (struct sddr09_card_info *)us->extra;
1434 if (!info)
1435 return USB_STOR_TRANSPORT_ERROR;
1436 }
1437 1472
1438 if (srb->cmnd[0] == REQUEST_SENSE && havefakesense) { 1473 if (srb->cmnd[0] == REQUEST_SENSE && havefakesense) {
1439 /* for a faked command, we have to follow with a faked sense */ 1474 /* for a faked command, we have to follow with a faked sense */
@@ -1536,7 +1571,9 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1536 US_DEBUGP("READ_10: read page %d pagect %d\n", 1571 US_DEBUGP("READ_10: read page %d pagect %d\n",
1537 page, pages); 1572 page, pages);
1538 1573
1539 return sddr09_read_data(us, page, pages); 1574 result = sddr09_read_data(us, page, pages);
1575 return (result == 0 ? USB_STOR_TRANSPORT_GOOD :
1576 USB_STOR_TRANSPORT_ERROR);
1540 } 1577 }
1541 1578
1542 if (srb->cmnd[0] == WRITE_10) { 1579 if (srb->cmnd[0] == WRITE_10) {
@@ -1549,7 +1586,9 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1549 US_DEBUGP("WRITE_10: write page %d pagect %d\n", 1586 US_DEBUGP("WRITE_10: write page %d pagect %d\n",
1550 page, pages); 1587 page, pages);
1551 1588
1552 return sddr09_write_data(us, page, pages); 1589 result = sddr09_write_data(us, page, pages);
1590 return (result == 0 ? USB_STOR_TRANSPORT_GOOD :
1591 USB_STOR_TRANSPORT_ERROR);
1553 } 1592 }
1554 1593
1555 /* catch-all for all other commands, except 1594 /* catch-all for all other commands, except
@@ -1575,10 +1614,10 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1575 US_DEBUGP("SDDR09: Send control for command %s\n", ptr); 1614 US_DEBUGP("SDDR09: Send control for command %s\n", ptr);
1576 1615
1577 result = sddr09_send_scsi_command(us, srb->cmnd, 12); 1616 result = sddr09_send_scsi_command(us, srb->cmnd, 12);
1578 if (result != USB_STOR_TRANSPORT_GOOD) { 1617 if (result) {
1579 US_DEBUGP("sddr09_transport: sddr09_send_scsi_command " 1618 US_DEBUGP("sddr09_transport: sddr09_send_scsi_command "
1580 "returns %d\n", result); 1619 "returns %d\n", result);
1581 return result; 1620 return USB_STOR_TRANSPORT_ERROR;
1582 } 1621 }
1583 1622
1584 if (srb->request_bufflen == 0) 1623 if (srb->request_bufflen == 0)
@@ -1606,3 +1645,10 @@ int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
1606 return USB_STOR_TRANSPORT_GOOD; 1645 return USB_STOR_TRANSPORT_GOOD;
1607} 1646}
1608 1647
1648/*
1649 * Initialization routine for the sddr09 subdriver
1650 */
1651int
1652usb_stor_sddr09_init(struct us_data *us) {
1653 return sddr09_common_init(us);
1654}
diff --git a/drivers/usb/storage/sddr09.h b/drivers/usb/storage/sddr09.h
index c9d78d6188b1..c03089a9ec38 100644
--- a/drivers/usb/storage/sddr09.h
+++ b/drivers/usb/storage/sddr09.h
@@ -31,18 +31,7 @@
31 31
32extern int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us); 32extern int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us);
33 33
34struct sddr09_card_info { 34extern int usb_stor_sddr09_dpcm_init(struct us_data *us);
35 unsigned long capacity; /* Size of card in bytes */ 35extern int usb_stor_sddr09_init(struct us_data *us);
36 int pagesize; /* Size of page in bytes */
37 int pageshift; /* log2 of pagesize */
38 int blocksize; /* Size of block in pages */
39 int blockshift; /* log2 of blocksize */
40 int blockmask; /* 2^blockshift - 1 */
41 int *lba_to_pba; /* logical to physical map */
42 int *pba_to_lba; /* physical to logical map */
43 int lbact; /* number of available pages */
44 int flags;
45#define SDDR09_WP 1 /* write protected */
46};
47 36
48#endif 37#endif
diff --git a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
index 0a362cc781ad..633a715850a4 100644
--- a/drivers/usb/storage/transport.h
+++ b/drivers/usb/storage/transport.h
@@ -41,39 +41,8 @@
41#ifndef _TRANSPORT_H_ 41#ifndef _TRANSPORT_H_
42#define _TRANSPORT_H_ 42#define _TRANSPORT_H_
43 43
44#include <linux/config.h>
45#include <linux/blkdev.h> 44#include <linux/blkdev.h>
46 45
47/* Protocols */
48
49#define US_PR_CBI 0x00 /* Control/Bulk/Interrupt */
50#define US_PR_CB 0x01 /* Control/Bulk w/o interrupt */
51#define US_PR_BULK 0x50 /* bulk only */
52#ifdef CONFIG_USB_STORAGE_USBAT
53#define US_PR_USBAT 0x80 /* SCM-ATAPI bridge */
54#endif
55#ifdef CONFIG_USB_STORAGE_SDDR09
56#define US_PR_EUSB_SDDR09 0x81 /* SCM-SCSI bridge for SDDR-09 */
57#endif
58#ifdef CONFIG_USB_STORAGE_SDDR55
59#define US_PR_SDDR55 0x82 /* SDDR-55 (made up) */
60#endif
61#define US_PR_DPCM_USB 0xf0 /* Combination CB/SDDR09 */
62
63#ifdef CONFIG_USB_STORAGE_FREECOM
64#define US_PR_FREECOM 0xf1 /* Freecom */
65#endif
66
67#ifdef CONFIG_USB_STORAGE_DATAFAB
68#define US_PR_DATAFAB 0xf2 /* Datafab chipsets */
69#endif
70
71#ifdef CONFIG_USB_STORAGE_JUMPSHOT
72#define US_PR_JUMPSHOT 0xf3 /* Lexar Jumpshot */
73#endif
74
75#define US_PR_DEVICE 0xff /* Use device's value */
76
77/* 46/*
78 * Bulk only data structures 47 * Bulk only data structures
79 */ 48 */
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index f5f47a34b168..dc301e567cfc 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -79,13 +79,6 @@ UNUSUAL_DEV( 0x03f0, 0x0307, 0x0001, 0x0001,
79 US_SC_8070, US_PR_USBAT, init_usbat, 0), 79 US_SC_8070, US_PR_USBAT, init_usbat, 0),
80#endif 80#endif
81 81
82/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */
83UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003,
84 "VIA Technologies Inc.",
85 "USB 2.0 Card Reader",
86 US_SC_DEVICE, US_PR_DEVICE, NULL,
87 US_FL_IGNORE_RESIDUE ),
88
89/* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net> 82/* Reported by Sebastian Kapfer <sebastian_kapfer@gmx.net>
90 * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product) 83 * and Olaf Hering <olh@suse.de> (different bcd's, same vendor/product)
91 * for USB floppies that need the SINGLE_LUN enforcement. 84 * for USB floppies that need the SINGLE_LUN enforcement.
@@ -96,6 +89,13 @@ UNUSUAL_DEV( 0x0409, 0x0040, 0x0000, 0x9999,
96 US_SC_DEVICE, US_PR_DEVICE, NULL, 89 US_SC_DEVICE, US_PR_DEVICE, NULL,
97 US_FL_SINGLE_LUN ), 90 US_FL_SINGLE_LUN ),
98 91
92/* Patch submitted by Mihnea-Costin Grigore <mihnea@zulu.ro> */
93UNUSUAL_DEV( 0x040d, 0x6205, 0x0003, 0x0003,
94 "VIA Technologies Inc.",
95 "USB 2.0 Card Reader",
96 US_SC_DEVICE, US_PR_DEVICE, NULL,
97 US_FL_IGNORE_RESIDUE ),
98
99/* Deduced by Jonathan Woithe <jwoithe@physics.adelaide.edu.au> 99/* Deduced by Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
100 * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message 100 * Entry needed for flags: US_FL_FIX_INQUIRY because initial inquiry message
101 * always fails and confuses drive. 101 * always fails and confuses drive.
@@ -187,6 +187,14 @@ UNUSUAL_DEV( 0x04b0, 0x0405, 0x0100, 0x0100,
187 US_SC_DEVICE, US_PR_DEVICE, NULL, 187 US_SC_DEVICE, US_PR_DEVICE, NULL,
188 US_FL_FIX_CAPACITY), 188 US_FL_FIX_CAPACITY),
189 189
190/* Patch for Nikon coolpix 2000
191 * Submitted by Fabien Cosse <fabien.cosse@wanadoo.fr>*/
192UNUSUAL_DEV( 0x04b0, 0x0301, 0x0010, 0x0010,
193 "NIKON",
194 "NIKON DSC E2000",
195 US_SC_DEVICE, US_PR_DEVICE,NULL,
196 US_FL_NOT_LOCKABLE ),
197
190/* BENQ DC5330 198/* BENQ DC5330
191 * Reported by Manuel Fombuena <mfombuena@ya.com> and 199 * Reported by Manuel Fombuena <mfombuena@ya.com> and
192 * Frank Copeland <fjc@thingy.apana.org.au> */ 200 * Frank Copeland <fjc@thingy.apana.org.au> */
@@ -276,14 +284,14 @@ UNUSUAL_DEV( 0x04e6, 0x0002, 0x0100, 0x0100,
276UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999, 284UNUSUAL_DEV( 0x04e6, 0x0003, 0x0000, 0x9999,
277 "Sandisk", 285 "Sandisk",
278 "ImageMate SDDR09", 286 "ImageMate SDDR09",
279 US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, 287 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
280 US_FL_SINGLE_LUN ), 288 0),
281 289
282/* This entry is from Andries.Brouwer@cwi.nl */ 290/* This entry is from Andries.Brouwer@cwi.nl */
283UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208, 291UNUSUAL_DEV( 0x04e6, 0x0005, 0x0100, 0x0208,
284 "SCM Microsystems", 292 "SCM Microsystems",
285 "eUSB SmartMedia / CompactFlash Adapter", 293 "eUSB SmartMedia / CompactFlash Adapter",
286 US_SC_SCSI, US_PR_DPCM_USB, sddr09_init, 294 US_SC_SCSI, US_PR_DPCM_USB, usb_stor_sddr09_dpcm_init,
287 0), 295 0),
288#endif 296#endif
289 297
@@ -527,6 +535,13 @@ UNUSUAL_DEV( 0x057b, 0x0022, 0x0000, 0x9999,
527 "Silicon Media R/W", 535 "Silicon Media R/W",
528 US_SC_DEVICE, US_PR_DEVICE, NULL, 0), 536 US_SC_DEVICE, US_PR_DEVICE, NULL, 0),
529 537
538#ifdef CONFIG_USB_STORAGE_ALAUDA
539UNUSUAL_DEV( 0x0584, 0x0008, 0x0102, 0x0102,
540 "Fujifilm",
541 "DPC-R1 (Alauda)",
542 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
543#endif
544
530/* Fabrizio Fellini <fello@libero.it> */ 545/* Fabrizio Fellini <fello@libero.it> */
531UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210, 546UNUSUAL_DEV( 0x0595, 0x4343, 0x0000, 0x2210,
532 "Fujifilm", 547 "Fujifilm",
@@ -673,8 +688,8 @@ UNUSUAL_DEV( 0x0644, 0x0000, 0x0100, 0x0100,
673UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100, 688UNUSUAL_DEV( 0x066b, 0x0105, 0x0100, 0x0100,
674 "Olympus", 689 "Olympus",
675 "Camedia MAUSB-2", 690 "Camedia MAUSB-2",
676 US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, 691 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
677 US_FL_SINGLE_LUN ), 692 0),
678#endif 693#endif
679 694
680/* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */ 695/* Reported by Darsen Lu <darsen@micro.ee.nthu.edu.tw> */
@@ -739,8 +754,8 @@ UNUSUAL_DEV( 0x0781, 0x0100, 0x0100, 0x0100,
739UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999, 754UNUSUAL_DEV( 0x0781, 0x0200, 0x0000, 0x9999,
740 "Sandisk", 755 "Sandisk",
741 "ImageMate SDDR-09", 756 "ImageMate SDDR-09",
742 US_SC_SCSI, US_PR_EUSB_SDDR09, NULL, 757 US_SC_SCSI, US_PR_EUSB_SDDR09, usb_stor_sddr09_init,
743 US_FL_SINGLE_LUN ), 758 0),
744#endif 759#endif
745 760
746#ifdef CONFIG_USB_STORAGE_FREECOM 761#ifdef CONFIG_USB_STORAGE_FREECOM
@@ -776,6 +791,13 @@ UNUSUAL_DEV( 0x07af, 0x0006, 0x0100, 0x0100,
776 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ), 791 US_SC_SCSI, US_PR_DPCM_USB, NULL, 0 ),
777#endif 792#endif
778 793
794#ifdef CONFIG_USB_STORAGE_ALAUDA
795UNUSUAL_DEV( 0x07b4, 0x010a, 0x0102, 0x0102,
796 "Olympus",
797 "MAUSB-10 (Alauda)",
798 US_SC_SCSI, US_PR_ALAUDA, init_alauda, 0 ),
799#endif
800
779#ifdef CONFIG_USB_STORAGE_DATAFAB 801#ifdef CONFIG_USB_STORAGE_DATAFAB
780UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015, 802UNUSUAL_DEV( 0x07c4, 0xa000, 0x0000, 0x0015,
781 "Datafab", 803 "Datafab",
@@ -1134,3 +1156,27 @@ UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999,
1134 US_SC_SCSI, US_PR_SDDR55, NULL, 1156 US_SC_SCSI, US_PR_SDDR55, NULL,
1135 US_FL_SINGLE_LUN), 1157 US_FL_SINGLE_LUN),
1136#endif 1158#endif
1159
1160/* Control/Bulk transport for all SubClass values */
1161USUAL_DEV(US_SC_RBC, US_PR_CB, USB_US_TYPE_STOR),
1162USUAL_DEV(US_SC_8020, US_PR_CB, USB_US_TYPE_STOR),
1163USUAL_DEV(US_SC_QIC, US_PR_CB, USB_US_TYPE_STOR),
1164USUAL_DEV(US_SC_UFI, US_PR_CB, USB_US_TYPE_STOR),
1165USUAL_DEV(US_SC_8070, US_PR_CB, USB_US_TYPE_STOR),
1166USUAL_DEV(US_SC_SCSI, US_PR_CB, USB_US_TYPE_STOR),
1167
1168/* Control/Bulk/Interrupt transport for all SubClass values */
1169USUAL_DEV(US_SC_RBC, US_PR_CBI, USB_US_TYPE_STOR),
1170USUAL_DEV(US_SC_8020, US_PR_CBI, USB_US_TYPE_STOR),
1171USUAL_DEV(US_SC_QIC, US_PR_CBI, USB_US_TYPE_STOR),
1172USUAL_DEV(US_SC_UFI, US_PR_CBI, USB_US_TYPE_STOR),
1173USUAL_DEV(US_SC_8070, US_PR_CBI, USB_US_TYPE_STOR),
1174USUAL_DEV(US_SC_SCSI, US_PR_CBI, USB_US_TYPE_STOR),
1175
1176/* Bulk-only transport for all SubClass values */
1177USUAL_DEV(US_SC_RBC, US_PR_BULK, USB_US_TYPE_STOR),
1178USUAL_DEV(US_SC_8020, US_PR_BULK, USB_US_TYPE_STOR),
1179USUAL_DEV(US_SC_QIC, US_PR_BULK, USB_US_TYPE_STOR),
1180USUAL_DEV(US_SC_UFI, US_PR_BULK, USB_US_TYPE_STOR),
1181USUAL_DEV(US_SC_8070, US_PR_BULK, USB_US_TYPE_STOR),
1182USUAL_DEV(US_SC_SCSI, US_PR_BULK, 0),
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 3847ebed2aa4..dbcf23980ff1 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -94,6 +94,9 @@
94#ifdef CONFIG_USB_STORAGE_ONETOUCH 94#ifdef CONFIG_USB_STORAGE_ONETOUCH
95#include "onetouch.h" 95#include "onetouch.h"
96#endif 96#endif
97#ifdef CONFIG_USB_STORAGE_ALAUDA
98#include "alauda.h"
99#endif
97 100
98/* Some informational data */ 101/* Some informational data */
99MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>"); 102MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
@@ -112,49 +115,33 @@ static atomic_t total_threads = ATOMIC_INIT(0);
112static DECLARE_COMPLETION(threads_gone); 115static DECLARE_COMPLETION(threads_gone);
113 116
114 117
115/* The entries in this table, except for final ones here 118/*
116 * (USB_MASS_STORAGE_CLASS and the empty entry), correspond, 119 * The entries in this table correspond, line for line,
117 * line for line with the entries of us_unsuaul_dev_list[]. 120 * with the entries of us_unusual_dev_list[].
118 */ 121 */
122#ifndef CONFIG_USB_LIBUSUAL
119 123
120#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 124#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
121 vendorName, productName,useProtocol, useTransport, \ 125 vendorName, productName,useProtocol, useTransport, \
122 initFunction, flags) \ 126 initFunction, flags) \
123{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax) } 127{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
128 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
129
130#define USUAL_DEV(useProto, useTrans, useType) \
131{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
132 .driver_info = (USB_US_TYPE_STOR<<24) }
124 133
125static struct usb_device_id storage_usb_ids [] = { 134static struct usb_device_id storage_usb_ids [] = {
126 135
127# include "unusual_devs.h" 136# include "unusual_devs.h"
128#undef UNUSUAL_DEV 137#undef UNUSUAL_DEV
129 /* Control/Bulk transport for all SubClass values */ 138#undef USUAL_DEV
130 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_CB) },
131 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_CB) },
132 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_CB) },
133 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_CB) },
134 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_CB) },
135 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_CB) },
136
137 /* Control/Bulk/Interrupt transport for all SubClass values */
138 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_CBI) },
139 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_CBI) },
140 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_CBI) },
141 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_CBI) },
142 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_CBI) },
143 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_CBI) },
144
145 /* Bulk-only transport for all SubClass values */
146 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_RBC, US_PR_BULK) },
147 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8020, US_PR_BULK) },
148 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_QIC, US_PR_BULK) },
149 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_UFI, US_PR_BULK) },
150 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_8070, US_PR_BULK) },
151 { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, US_SC_SCSI, US_PR_BULK) },
152
153 /* Terminating entry */ 139 /* Terminating entry */
154 { } 140 { }
155}; 141};
156 142
157MODULE_DEVICE_TABLE (usb, storage_usb_ids); 143MODULE_DEVICE_TABLE (usb, storage_usb_ids);
144#endif /* CONFIG_USB_LIBUSUAL */
158 145
159/* This is the list of devices we recognize, along with their flag data */ 146/* This is the list of devices we recognize, along with their flag data */
160 147
@@ -167,7 +154,6 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
167 * are free to use as many characters as you like. 154 * are free to use as many characters as you like.
168 */ 155 */
169 156
170#undef UNUSUAL_DEV
171#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \ 157#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
172 vendor_name, product_name, use_protocol, use_transport, \ 158 vendor_name, product_name, use_protocol, use_transport, \
173 init_function, Flags) \ 159 init_function, Flags) \
@@ -177,53 +163,18 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
177 .useProtocol = use_protocol, \ 163 .useProtocol = use_protocol, \
178 .useTransport = use_transport, \ 164 .useTransport = use_transport, \
179 .initFunction = init_function, \ 165 .initFunction = init_function, \
180 .flags = Flags, \ 166}
167
168#define USUAL_DEV(use_protocol, use_transport, use_type) \
169{ \
170 .useProtocol = use_protocol, \
171 .useTransport = use_transport, \
181} 172}
182 173
183static struct us_unusual_dev us_unusual_dev_list[] = { 174static struct us_unusual_dev us_unusual_dev_list[] = {
184# include "unusual_devs.h" 175# include "unusual_devs.h"
185# undef UNUSUAL_DEV 176# undef UNUSUAL_DEV
186 /* Control/Bulk transport for all SubClass values */ 177# undef USUAL_DEV
187 { .useProtocol = US_SC_RBC,
188 .useTransport = US_PR_CB},
189 { .useProtocol = US_SC_8020,
190 .useTransport = US_PR_CB},
191 { .useProtocol = US_SC_QIC,
192 .useTransport = US_PR_CB},
193 { .useProtocol = US_SC_UFI,
194 .useTransport = US_PR_CB},
195 { .useProtocol = US_SC_8070,
196 .useTransport = US_PR_CB},
197 { .useProtocol = US_SC_SCSI,
198 .useTransport = US_PR_CB},
199
200 /* Control/Bulk/Interrupt transport for all SubClass values */
201 { .useProtocol = US_SC_RBC,
202 .useTransport = US_PR_CBI},
203 { .useProtocol = US_SC_8020,
204 .useTransport = US_PR_CBI},
205 { .useProtocol = US_SC_QIC,
206 .useTransport = US_PR_CBI},
207 { .useProtocol = US_SC_UFI,
208 .useTransport = US_PR_CBI},
209 { .useProtocol = US_SC_8070,
210 .useTransport = US_PR_CBI},
211 { .useProtocol = US_SC_SCSI,
212 .useTransport = US_PR_CBI},
213
214 /* Bulk-only transport for all SubClass values */
215 { .useProtocol = US_SC_RBC,
216 .useTransport = US_PR_BULK},
217 { .useProtocol = US_SC_8020,
218 .useTransport = US_PR_BULK},
219 { .useProtocol = US_SC_QIC,
220 .useTransport = US_PR_BULK},
221 { .useProtocol = US_SC_UFI,
222 .useTransport = US_PR_BULK},
223 { .useProtocol = US_SC_8070,
224 .useTransport = US_PR_BULK},
225 { .useProtocol = US_SC_SCSI,
226 .useTransport = US_PR_BULK},
227 178
228 /* Terminating entry */ 179 /* Terminating entry */
229 { NULL } 180 { NULL }
@@ -240,6 +191,8 @@ static int storage_suspend(struct usb_interface *iface, pm_message_t message)
240 down(&us->dev_semaphore); 191 down(&us->dev_semaphore);
241 192
242 US_DEBUGP("%s\n", __FUNCTION__); 193 US_DEBUGP("%s\n", __FUNCTION__);
194 if (us->suspend_resume_hook)
195 (us->suspend_resume_hook)(us, US_SUSPEND);
243 iface->dev.power.power_state.event = message.event; 196 iface->dev.power.power_state.event = message.event;
244 197
245 /* When runtime PM is working, we'll set a flag to indicate 198 /* When runtime PM is working, we'll set a flag to indicate
@@ -256,6 +209,8 @@ static int storage_resume(struct usb_interface *iface)
256 down(&us->dev_semaphore); 209 down(&us->dev_semaphore);
257 210
258 US_DEBUGP("%s\n", __FUNCTION__); 211 US_DEBUGP("%s\n", __FUNCTION__);
212 if (us->suspend_resume_hook)
213 (us->suspend_resume_hook)(us, US_RESUME);
259 iface->dev.power.power_state.event = PM_EVENT_ON; 214 iface->dev.power.power_state.event = PM_EVENT_ON;
260 215
261 up(&us->dev_semaphore); 216 up(&us->dev_semaphore);
@@ -484,14 +439,20 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
484 return 0; 439 return 0;
485} 440}
486 441
442/* Find an unusual_dev descriptor (always succeeds in the current code) */
443static struct us_unusual_dev *find_unusual(const struct usb_device_id *id)
444{
445 const int id_index = id - storage_usb_ids;
446 return &us_unusual_dev_list[id_index];
447}
448
487/* Get the unusual_devs entries and the string descriptors */ 449/* Get the unusual_devs entries and the string descriptors */
488static void get_device_info(struct us_data *us, int id_index) 450static void get_device_info(struct us_data *us, const struct usb_device_id *id)
489{ 451{
490 struct usb_device *dev = us->pusb_dev; 452 struct usb_device *dev = us->pusb_dev;
491 struct usb_interface_descriptor *idesc = 453 struct usb_interface_descriptor *idesc =
492 &us->pusb_intf->cur_altsetting->desc; 454 &us->pusb_intf->cur_altsetting->desc;
493 struct us_unusual_dev *unusual_dev = &us_unusual_dev_list[id_index]; 455 struct us_unusual_dev *unusual_dev = find_unusual(id);
494 struct usb_device_id *id = &storage_usb_ids[id_index];
495 456
496 /* Store the entries */ 457 /* Store the entries */
497 us->unusual_dev = unusual_dev; 458 us->unusual_dev = unusual_dev;
@@ -501,7 +462,7 @@ static void get_device_info(struct us_data *us, int id_index)
501 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ? 462 us->protocol = (unusual_dev->useTransport == US_PR_DEVICE) ?
502 idesc->bInterfaceProtocol : 463 idesc->bInterfaceProtocol :
503 unusual_dev->useTransport; 464 unusual_dev->useTransport;
504 us->flags = unusual_dev->flags; 465 us->flags = USB_US_ORIG_FLAGS(id->driver_info);
505 466
506 /* 467 /*
507 * This flag is only needed when we're in high-speed, so let's 468 * This flag is only needed when we're in high-speed, so let's
@@ -516,7 +477,7 @@ static void get_device_info(struct us_data *us, int id_index)
516 * from the unusual_devs.h table. 477 * from the unusual_devs.h table.
517 */ 478 */
518 if (id->idVendor || id->idProduct) { 479 if (id->idVendor || id->idProduct) {
519 static char *msgs[3] = { 480 static const char *msgs[3] = {
520 "an unneeded SubClass entry", 481 "an unneeded SubClass entry",
521 "an unneeded Protocol entry", 482 "an unneeded Protocol entry",
522 "unneeded SubClass and Protocol entries"}; 483 "unneeded SubClass and Protocol entries"};
@@ -529,7 +490,7 @@ static void get_device_info(struct us_data *us, int id_index)
529 if (unusual_dev->useTransport != US_PR_DEVICE && 490 if (unusual_dev->useTransport != US_PR_DEVICE &&
530 us->protocol == idesc->bInterfaceProtocol) 491 us->protocol == idesc->bInterfaceProtocol)
531 msg += 2; 492 msg += 2;
532 if (msg >= 0 && !(unusual_dev->flags & US_FL_NEED_OVERRIDE)) 493 if (msg >= 0 && !(us->flags & US_FL_NEED_OVERRIDE))
533 printk(KERN_NOTICE USB_STORAGE "This device " 494 printk(KERN_NOTICE USB_STORAGE "This device "
534 "(%04x,%04x,%04x S %02x P %02x)" 495 "(%04x,%04x,%04x S %02x P %02x)"
535 " has %s in unusual_devs.h\n" 496 " has %s in unusual_devs.h\n"
@@ -686,6 +647,15 @@ static int get_protocol(struct us_data *us)
686 break; 647 break;
687#endif 648#endif
688 649
650#ifdef CONFIG_USB_STORAGE_ALAUDA
651 case US_PR_ALAUDA:
652 us->transport_name = "Alauda Control/Bulk";
653 us->transport = alauda_transport;
654 us->transport_reset = usb_stor_Bulk_reset;
655 us->max_lun = 1;
656 break;
657#endif
658
689 default: 659 default:
690 return -EIO; 660 return -EIO;
691 } 661 }
@@ -921,10 +891,12 @@ static int storage_probe(struct usb_interface *intf,
921{ 891{
922 struct Scsi_Host *host; 892 struct Scsi_Host *host;
923 struct us_data *us; 893 struct us_data *us;
924 const int id_index = id - storage_usb_ids;
925 int result; 894 int result;
926 struct task_struct *th; 895 struct task_struct *th;
927 896
897 if (usb_usual_check_type(id, USB_US_TYPE_STOR))
898 return -ENXIO;
899
928 US_DEBUGP("USB Mass Storage device detected\n"); 900 US_DEBUGP("USB Mass Storage device detected\n");
929 901
930 /* 902 /*
@@ -957,29 +929,7 @@ static int storage_probe(struct usb_interface *intf,
957 * of the match from the usb_device_id table, so we can find the 929 * of the match from the usb_device_id table, so we can find the
958 * corresponding entry in the private table. 930 * corresponding entry in the private table.
959 */ 931 */
960 get_device_info(us, id_index); 932 get_device_info(us, id);
961
962#ifdef CONFIG_USB_STORAGE_SDDR09
963 if (us->protocol == US_PR_EUSB_SDDR09 ||
964 us->protocol == US_PR_DPCM_USB) {
965 /* set the configuration -- STALL is an acceptable response here */
966 if (us->pusb_dev->actconfig->desc.bConfigurationValue != 1) {
967 US_DEBUGP("active config #%d != 1 ??\n", us->pusb_dev
968 ->actconfig->desc.bConfigurationValue);
969 goto BadDevice;
970 }
971 result = usb_reset_configuration(us->pusb_dev);
972
973 US_DEBUGP("Result of usb_reset_configuration is %d\n", result);
974 if (result == -EPIPE) {
975 US_DEBUGP("-- stall on control interface\n");
976 } else if (result != 0) {
977 /* it's not a stall, but another error -- time to bail */
978 US_DEBUGP("-- Unknown error. Rejecting device\n");
979 goto BadDevice;
980 }
981 }
982#endif
983 933
984 /* Get the transport, protocol, and pipe settings */ 934 /* Get the transport, protocol, and pipe settings */
985 result = get_transport(us); 935 result = get_transport(us);
@@ -1044,7 +994,6 @@ static void storage_disconnect(struct usb_interface *intf)
1044 ***********************************************************************/ 994 ***********************************************************************/
1045 995
1046static struct usb_driver usb_storage_driver = { 996static struct usb_driver usb_storage_driver = {
1047 .owner = THIS_MODULE,
1048 .name = "usb-storage", 997 .name = "usb-storage",
1049 .probe = storage_probe, 998 .probe = storage_probe,
1050 .disconnect = storage_disconnect, 999 .disconnect = storage_disconnect,
@@ -1062,9 +1011,10 @@ static int __init usb_stor_init(void)
1062 1011
1063 /* register the driver, return usb_register return code if error */ 1012 /* register the driver, return usb_register return code if error */
1064 retval = usb_register(&usb_storage_driver); 1013 retval = usb_register(&usb_storage_driver);
1065 if (retval == 0) 1014 if (retval == 0) {
1066 printk(KERN_INFO "USB Mass Storage support registered.\n"); 1015 printk(KERN_INFO "USB Mass Storage support registered.\n");
1067 1016 usb_usual_set_present(USB_US_TYPE_STOR);
1017 }
1068 return retval; 1018 return retval;
1069} 1019}
1070 1020
@@ -1088,6 +1038,8 @@ static void __exit usb_stor_exit(void)
1088 wait_for_completion(&threads_gone); 1038 wait_for_completion(&threads_gone);
1089 atomic_dec(&total_threads); 1039 atomic_dec(&total_threads);
1090 } 1040 }
1041
1042 usb_usual_clear_present(USB_US_TYPE_STOR);
1091} 1043}
1092 1044
1093module_init(usb_stor_init); 1045module_init(usb_stor_init);
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 98b09711a739..7259fd1f6b0d 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -45,6 +45,7 @@
45#define _USB_H_ 45#define _USB_H_
46 46
47#include <linux/usb.h> 47#include <linux/usb.h>
48#include <linux/usb_usual.h>
48#include <linux/blkdev.h> 49#include <linux/blkdev.h>
49#include <linux/smp_lock.h> 50#include <linux/smp_lock.h>
50#include <linux/completion.h> 51#include <linux/completion.h>
@@ -63,38 +64,8 @@ struct us_unusual_dev {
63 __u8 useProtocol; 64 __u8 useProtocol;
64 __u8 useTransport; 65 __u8 useTransport;
65 int (*initFunction)(struct us_data *); 66 int (*initFunction)(struct us_data *);
66 unsigned int flags;
67}; 67};
68 68
69/*
70 * Static flag definitions. We use this roundabout technique so that the
71 * proc_info() routine can automatically display a message for each flag.
72 */
73#define US_DO_ALL_FLAGS \
74 US_FLAG(SINGLE_LUN, 0x00000001) \
75 /* allow access to only LUN 0 */ \
76 US_FLAG(NEED_OVERRIDE, 0x00000002) \
77 /* unusual_devs entry is necessary */ \
78 US_FLAG(SCM_MULT_TARG, 0x00000004) \
79 /* supports multiple targets */ \
80 US_FLAG(FIX_INQUIRY, 0x00000008) \
81 /* INQUIRY response needs faking */ \
82 US_FLAG(FIX_CAPACITY, 0x00000010) \
83 /* READ CAPACITY response too big */ \
84 US_FLAG(IGNORE_RESIDUE, 0x00000020) \
85 /* reported residue is wrong */ \
86 US_FLAG(BULK32, 0x00000040) \
87 /* Uses 32-byte CBW length */ \
88 US_FLAG(NOT_LOCKABLE, 0x00000080) \
89 /* PREVENT/ALLOW not supported */ \
90 US_FLAG(GO_SLOW, 0x00000100) \
91 /* Need delay after Command phase */ \
92 US_FLAG(NO_WP_DETECT, 0x00000200) \
93 /* Don't check for write-protect */ \
94
95#define US_FLAG(name, value) US_FL_##name = value ,
96enum { US_DO_ALL_FLAGS };
97#undef US_FLAG
98 69
99/* Dynamic flag definitions: used in set_bit() etc. */ 70/* Dynamic flag definitions: used in set_bit() etc. */
100#define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */ 71#define US_FLIDX_URB_ACTIVE 18 /* 0x00040000 current_urb is in use */
@@ -122,7 +93,11 @@ enum { US_DO_ALL_FLAGS };
122typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*); 93typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
123typedef int (*trans_reset)(struct us_data*); 94typedef int (*trans_reset)(struct us_data*);
124typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*); 95typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*);
125typedef void (*extra_data_destructor)(void *); /* extra data destructor */ 96typedef void (*extra_data_destructor)(void *); /* extra data destructor */
97typedef void (*pm_hook)(struct us_data *, int); /* power management hook */
98
99#define US_SUSPEND 0
100#define US_RESUME 1
126 101
127/* we allocate one of these for every device that we remember */ 102/* we allocate one of these for every device that we remember */
128struct us_data { 103struct us_data {
@@ -178,6 +153,9 @@ struct us_data {
178 /* subdriver information */ 153 /* subdriver information */
179 void *extra; /* Any extra data */ 154 void *extra; /* Any extra data */
180 extra_data_destructor extra_destructor;/* extra data destructor */ 155 extra_data_destructor extra_destructor;/* extra data destructor */
156#ifdef CONFIG_PM
157 pm_hook suspend_resume_hook;
158#endif
181}; 159};
182 160
183/* Convert between us_data and the corresponding Scsi_Host */ 161/* Convert between us_data and the corresponding Scsi_Host */
diff --git a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
index 6c3a53f8f26c..5d02f16b7d0e 100644
--- a/drivers/usb/usb-skeleton.c
+++ b/drivers/usb/usb-skeleton.c
@@ -39,10 +39,15 @@ MODULE_DEVICE_TABLE (usb, skel_table);
39/* Get a minor range for your devices from the usb maintainer */ 39/* Get a minor range for your devices from the usb maintainer */
40#define USB_SKEL_MINOR_BASE 192 40#define USB_SKEL_MINOR_BASE 192
41 41
42/* our private defines. if this grows any larger, use your own .h file */
43#define MAX_TRANSFER ( PAGE_SIZE - 512 )
44#define WRITES_IN_FLIGHT 8
45
42/* Structure to hold all of our device specific stuff */ 46/* Structure to hold all of our device specific stuff */
43struct usb_skel { 47struct usb_skel {
44 struct usb_device * udev; /* the usb device for this device */ 48 struct usb_device * udev; /* the usb device for this device */
45 struct usb_interface * interface; /* the interface for this device */ 49 struct usb_interface * interface; /* the interface for this device */
50 struct semaphore limit_sem; /* limiting the number of writes in progress */
46 unsigned char * bulk_in_buffer; /* the buffer to receive data */ 51 unsigned char * bulk_in_buffer; /* the buffer to receive data */
47 size_t bulk_in_size; /* the size of the receive buffer */ 52 size_t bulk_in_size; /* the size of the receive buffer */
48 __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */ 53 __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */
@@ -152,6 +157,7 @@ static void skel_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
152 /* free up our allocated buffer */ 157 /* free up our allocated buffer */
153 usb_buffer_free(urb->dev, urb->transfer_buffer_length, 158 usb_buffer_free(urb->dev, urb->transfer_buffer_length,
154 urb->transfer_buffer, urb->transfer_dma); 159 urb->transfer_buffer, urb->transfer_dma);
160 up(&dev->limit_sem);
155} 161}
156 162
157static ssize_t skel_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos) 163static ssize_t skel_write(struct file *file, const char *user_buffer, size_t count, loff_t *ppos)
@@ -160,6 +166,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
160 int retval = 0; 166 int retval = 0;
161 struct urb *urb = NULL; 167 struct urb *urb = NULL;
162 char *buf = NULL; 168 char *buf = NULL;
169 size_t writesize = min(count, (size_t)MAX_TRANSFER);
163 170
164 dev = (struct usb_skel *)file->private_data; 171 dev = (struct usb_skel *)file->private_data;
165 172
@@ -167,6 +174,12 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
167 if (count == 0) 174 if (count == 0)
168 goto exit; 175 goto exit;
169 176
177 /* limit the number of URBs in flight to stop a user from using up all RAM */
178 if (down_interruptible(&dev->limit_sem)) {
179 retval = -ERESTARTSYS;
180 goto exit;
181 }
182
170 /* create a urb, and a buffer for it, and copy the data to the urb */ 183 /* create a urb, and a buffer for it, and copy the data to the urb */
171 urb = usb_alloc_urb(0, GFP_KERNEL); 184 urb = usb_alloc_urb(0, GFP_KERNEL);
172 if (!urb) { 185 if (!urb) {
@@ -174,13 +187,13 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
174 goto error; 187 goto error;
175 } 188 }
176 189
177 buf = usb_buffer_alloc(dev->udev, count, GFP_KERNEL, &urb->transfer_dma); 190 buf = usb_buffer_alloc(dev->udev, writesize, GFP_KERNEL, &urb->transfer_dma);
178 if (!buf) { 191 if (!buf) {
179 retval = -ENOMEM; 192 retval = -ENOMEM;
180 goto error; 193 goto error;
181 } 194 }
182 195
183 if (copy_from_user(buf, user_buffer, count)) { 196 if (copy_from_user(buf, user_buffer, writesize)) {
184 retval = -EFAULT; 197 retval = -EFAULT;
185 goto error; 198 goto error;
186 } 199 }
@@ -188,7 +201,7 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
188 /* initialize the urb properly */ 201 /* initialize the urb properly */
189 usb_fill_bulk_urb(urb, dev->udev, 202 usb_fill_bulk_urb(urb, dev->udev,
190 usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr), 203 usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr),
191 buf, count, skel_write_bulk_callback, dev); 204 buf, writesize, skel_write_bulk_callback, dev);
192 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 205 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
193 206
194 /* send the data out the bulk port */ 207 /* send the data out the bulk port */
@@ -202,11 +215,12 @@ static ssize_t skel_write(struct file *file, const char *user_buffer, size_t cou
202 usb_free_urb(urb); 215 usb_free_urb(urb);
203 216
204exit: 217exit:
205 return count; 218 return writesize;
206 219
207error: 220error:
208 usb_buffer_free(dev->udev, count, buf, urb->transfer_dma); 221 usb_buffer_free(dev->udev, writesize, buf, urb->transfer_dma);
209 usb_free_urb(urb); 222 usb_free_urb(urb);
223 up(&dev->limit_sem);
210 return retval; 224 return retval;
211} 225}
212 226
@@ -238,13 +252,13 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
238 int retval = -ENOMEM; 252 int retval = -ENOMEM;
239 253
240 /* allocate memory for our device state and initialize it */ 254 /* allocate memory for our device state and initialize it */
241 dev = kmalloc(sizeof(*dev), GFP_KERNEL); 255 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
242 if (dev == NULL) { 256 if (dev == NULL) {
243 err("Out of memory"); 257 err("Out of memory");
244 goto error; 258 goto error;
245 } 259 }
246 memset(dev, 0x00, sizeof(*dev));
247 kref_init(&dev->kref); 260 kref_init(&dev->kref);
261 sema_init(&dev->limit_sem, WRITES_IN_FLIGHT);
248 262
249 dev->udev = usb_get_dev(interface_to_usbdev(interface)); 263 dev->udev = usb_get_dev(interface_to_usbdev(interface));
250 dev->interface = interface; 264 dev->interface = interface;
@@ -330,7 +344,6 @@ static void skel_disconnect(struct usb_interface *interface)
330} 344}
331 345
332static struct usb_driver skel_driver = { 346static struct usb_driver skel_driver = {
333 .owner = THIS_MODULE,
334 .name = "skeleton", 347 .name = "skeleton",
335 .probe = skel_probe, 348 .probe = skel_probe,
336 .disconnect = skel_disconnect, 349 .disconnect = skel_disconnect,
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 3e470c8b4193..cc8e3bf5001b 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -536,13 +536,13 @@ config FB_SUN3
536 536
537config FB_SBUS 537config FB_SBUS
538 bool "SBUS and UPA framebuffers" 538 bool "SBUS and UPA framebuffers"
539 depends on (FB = y) && (SPARC32 || SPARC64) 539 depends on (FB = y) && SPARC
540 help 540 help
541 Say Y if you want support for SBUS or UPA based frame buffer device. 541 Say Y if you want support for SBUS or UPA based frame buffer device.
542 542
543config FB_BW2 543config FB_BW2
544 bool "BWtwo support" 544 bool "BWtwo support"
545 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 545 depends on (FB = y) && (SPARC && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
546 select FB_CFB_FILLRECT 546 select FB_CFB_FILLRECT
547 select FB_CFB_COPYAREA 547 select FB_CFB_COPYAREA
548 select FB_CFB_IMAGEBLIT 548 select FB_CFB_IMAGEBLIT
@@ -551,7 +551,7 @@ config FB_BW2
551 551
552config FB_CG3 552config FB_CG3
553 bool "CGthree support" 553 bool "CGthree support"
554 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 554 depends on (FB = y) && (SPARC && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
555 select FB_CFB_FILLRECT 555 select FB_CFB_FILLRECT
556 select FB_CFB_COPYAREA 556 select FB_CFB_COPYAREA
557 select FB_CFB_IMAGEBLIT 557 select FB_CFB_IMAGEBLIT
@@ -560,7 +560,7 @@ config FB_CG3
560 560
561config FB_CG6 561config FB_CG6
562 bool "CGsix (GX,TurboGX) support" 562 bool "CGsix (GX,TurboGX) support"
563 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 563 depends on (FB = y) && (SPARC && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
564 select FB_CFB_COPYAREA 564 select FB_CFB_COPYAREA
565 select FB_CFB_IMAGEBLIT 565 select FB_CFB_IMAGEBLIT
566 help 566 help
@@ -1268,7 +1268,7 @@ config FB_LEO
1268 1268
1269config FB_PCI 1269config FB_PCI
1270 bool "PCI framebuffers" 1270 bool "PCI framebuffers"
1271 depends on (FB = y) && PCI && (SPARC64 || SPARC32) 1271 depends on (FB = y) && PCI && SPARC
1272 1272
1273config FB_IGA 1273config FB_IGA
1274 bool "IGA 168x display support" 1274 bool "IGA 168x display support"
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index 080db812ca48..2784f0a9d693 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -441,7 +441,7 @@ static int arcfb_ioctl(struct inode *inode, struct file *file,
441 * the fb. it's inefficient for them to do anything less than 64*8 441 * the fb. it's inefficient for them to do anything less than 64*8
442 * writes since we update the lcd in each write() anyway. 442 * writes since we update the lcd in each write() anyway.
443 */ 443 */
444static ssize_t arcfb_write(struct file *file, const char *buf, size_t count, 444static ssize_t arcfb_write(struct file *file, const char __user *buf, size_t count,
445 loff_t *ppos) 445 loff_t *ppos)
446{ 446{
447 /* modded from epson 1355 */ 447 /* modded from epson 1355 */
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 08edbfcfca58..3fefdb0cbf07 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -403,7 +403,7 @@ static struct {
403 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP)", 230, 83, 63, ATI_CHIP_264XL }, 403 { PCI_CHIP_MACH64GM, "3D RAGE XL (Mach64 GM, AGP)", 230, 83, 63, ATI_CHIP_264XL },
404 { PCI_CHIP_MACH64GN, "3D RAGE XL (Mach64 GN, AGP)", 230, 83, 63, ATI_CHIP_264XL }, 404 { PCI_CHIP_MACH64GN, "3D RAGE XL (Mach64 GN, AGP)", 230, 83, 63, ATI_CHIP_264XL },
405 { PCI_CHIP_MACH64GO, "3D RAGE XL (Mach64 GO, PCI-66/BGA)", 230, 83, 63, ATI_CHIP_264XL }, 405 { PCI_CHIP_MACH64GO, "3D RAGE XL (Mach64 GO, PCI-66/BGA)", 230, 83, 63, ATI_CHIP_264XL },
406 { PCI_CHIP_MACH64GR, "3D RAGE XL (Mach64 GR, PCI-33MHz)", 230, 83, 63, ATI_CHIP_264XL }, 406 { PCI_CHIP_MACH64GR, "3D RAGE XL (Mach64 GR, PCI-33MHz)", 235, 83, 63, ATI_CHIP_264XL | M64F_SDRAM_MAGIC_PLL },
407 { PCI_CHIP_MACH64GL, "3D RAGE XL (Mach64 GL, PCI)", 230, 83, 63, ATI_CHIP_264XL }, 407 { PCI_CHIP_MACH64GL, "3D RAGE XL (Mach64 GL, PCI)", 230, 83, 63, ATI_CHIP_264XL },
408 { PCI_CHIP_MACH64GS, "3D RAGE XL (Mach64 GS, PCI)", 230, 83, 63, ATI_CHIP_264XL }, 408 { PCI_CHIP_MACH64GS, "3D RAGE XL (Mach64 GS, PCI)", 230, 83, 63, ATI_CHIP_264XL },
409 409
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 4f01ccc02aa4..156db84cb363 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -594,7 +594,7 @@ static int __devinit radeon_probe_pll_params(struct radeonfb_info *rinfo)
594} 594}
595 595
596/* 596/*
597 * Retreive PLL infos by different means (BIOS, Open Firmware, register probing...) 597 * Retrieve PLL infos by different means (BIOS, Open Firmware, register probing...)
598 */ 598 */
599static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo) 599static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
600{ 600{
@@ -660,17 +660,17 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
660 660
661#ifdef CONFIG_PPC_OF 661#ifdef CONFIG_PPC_OF
662 /* 662 /*
663 * Retreive PLL infos from Open Firmware first 663 * Retrieve PLL infos from Open Firmware first
664 */ 664 */
665 if (!force_measure_pll && radeon_read_xtal_OF(rinfo) == 0) { 665 if (!force_measure_pll && radeon_read_xtal_OF(rinfo) == 0) {
666 printk(KERN_INFO "radeonfb: Retreived PLL infos from Open Firmware\n"); 666 printk(KERN_INFO "radeonfb: Retrieved PLL infos from Open Firmware\n");
667 goto found; 667 goto found;
668 } 668 }
669#endif /* CONFIG_PPC_OF */ 669#endif /* CONFIG_PPC_OF */
670 670
671 /* 671 /*
672 * Check out if we have an X86 which gave us some PLL informations 672 * Check out if we have an X86 which gave us some PLL informations
673 * and if yes, retreive them 673 * and if yes, retrieve them
674 */ 674 */
675 if (!force_measure_pll && rinfo->bios_seg) { 675 if (!force_measure_pll && rinfo->bios_seg) {
676 u16 pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30); 676 u16 pll_info_block = BIOS_IN16(rinfo->fp_bios_start + 0x30);
@@ -682,7 +682,7 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
682 rinfo->pll.ppll_min = BIOS_IN32(pll_info_block + 0x12); 682 rinfo->pll.ppll_min = BIOS_IN32(pll_info_block + 0x12);
683 rinfo->pll.ppll_max = BIOS_IN32(pll_info_block + 0x16); 683 rinfo->pll.ppll_max = BIOS_IN32(pll_info_block + 0x16);
684 684
685 printk(KERN_INFO "radeonfb: Retreived PLL infos from BIOS\n"); 685 printk(KERN_INFO "radeonfb: Retrieved PLL infos from BIOS\n");
686 goto found; 686 goto found;
687 } 687 }
688 688
@@ -691,7 +691,7 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
691 * probe them 691 * probe them
692 */ 692 */
693 if (radeon_probe_pll_params(rinfo) == 0) { 693 if (radeon_probe_pll_params(rinfo) == 0) {
694 printk(KERN_INFO "radeonfb: Retreived PLL infos from registers\n"); 694 printk(KERN_INFO "radeonfb: Retrieved PLL infos from registers\n");
695 goto found; 695 goto found;
696 } 696 }
697 697
@@ -702,7 +702,7 @@ static void __devinit radeon_get_pllinfo(struct radeonfb_info *rinfo)
702 702
703found: 703found:
704 /* 704 /*
705 * Some methods fail to retreive SCLK and MCLK values, we apply default 705 * Some methods fail to retrieve SCLK and MCLK values, we apply default
706 * settings in this case (200Mhz). If that really happne often, we could 706 * settings in this case (200Mhz). If that really happne often, we could
707 * fetch from registers instead... 707 * fetch from registers instead...
708 */ 708 */
@@ -2393,7 +2393,7 @@ static int radeonfb_pci_register (struct pci_dev *pdev,
2393 rinfo->mapped_vram/1024); 2393 rinfo->mapped_vram/1024);
2394 2394
2395 /* 2395 /*
2396 * Map the BIOS ROM if any and retreive PLL parameters from 2396 * Map the BIOS ROM if any and retrieve PLL parameters from
2397 * the BIOS. We skip that on mobility chips as the real panel 2397 * the BIOS. We skip that on mobility chips as the real panel
2398 * values we need aren't in the ROM but in the BIOS image in 2398 * values we need aren't in the ROM but in the BIOS image in
2399 * memory. This is definitely not the best meacnism though, 2399 * memory. This is definitely not the best meacnism though,
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index d3728f60961e..9248fe1fbb1a 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -121,7 +121,6 @@ struct bw2_par {
121 unsigned long fbsize; 121 unsigned long fbsize;
122 122
123 struct sbus_dev *sdev; 123 struct sbus_dev *sdev;
124 struct list_head list;
125}; 124};
126 125
127/** 126/**
diff --git a/drivers/video/cfbcopyarea.c b/drivers/video/cfbcopyarea.c
index cdc71572cf35..74415325b016 100644
--- a/drivers/video/cfbcopyarea.c
+++ b/drivers/video/cfbcopyarea.c
@@ -64,8 +64,8 @@ bitcpy(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem *src
64 int const shift = dst_idx-src_idx; 64 int const shift = dst_idx-src_idx;
65 int left, right; 65 int left, right;
66 66
67 first = ~0UL >> dst_idx; 67 first = FB_SHIFT_HIGH(~0UL, dst_idx);
68 last = ~(~0UL >> ((dst_idx+n) % bits)); 68 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
69 69
70 if (!shift) { 70 if (!shift) {
71 // Same alignment for source and dest 71 // Same alignment for source and dest
@@ -216,8 +216,8 @@ bitcpy_rev(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem
216 216
217 shift = dst_idx-src_idx; 217 shift = dst_idx-src_idx;
218 218
219 first = ~0UL << (bits - 1 - dst_idx); 219 first = FB_SHIFT_LOW(~0UL, bits - 1 - dst_idx);
220 last = ~(~0UL << (bits - 1 - ((dst_idx-n) % bits))); 220 last = ~(FB_SHIFT_LOW(~0UL, bits - 1 - ((dst_idx-n) % bits)));
221 221
222 if (!shift) { 222 if (!shift) {
223 // Same alignment for source and dest 223 // Same alignment for source and dest
diff --git a/drivers/video/cfbfillrect.c b/drivers/video/cfbfillrect.c
index 167d9314e6eb..e5ff62e9cfb8 100644
--- a/drivers/video/cfbfillrect.c
+++ b/drivers/video/cfbfillrect.c
@@ -110,8 +110,8 @@ bitfill_aligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat, unsi
110 if (!n) 110 if (!n)
111 return; 111 return;
112 112
113 first = ~0UL >> dst_idx; 113 first = FB_SHIFT_HIGH(~0UL, dst_idx);
114 last = ~(~0UL >> ((dst_idx+n) % bits)); 114 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
115 115
116 if (dst_idx+n <= bits) { 116 if (dst_idx+n <= bits) {
117 // Single word 117 // Single word
@@ -167,8 +167,8 @@ bitfill_unaligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
167 if (!n) 167 if (!n)
168 return; 168 return;
169 169
170 first = ~0UL >> dst_idx; 170 first = FB_SHIFT_HIGH(~0UL, dst_idx);
171 last = ~(~0UL >> ((dst_idx+n) % bits)); 171 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
172 172
173 if (dst_idx+n <= bits) { 173 if (dst_idx+n <= bits) {
174 // Single word 174 // Single word
@@ -221,8 +221,8 @@ bitfill_aligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
221 if (!n) 221 if (!n)
222 return; 222 return;
223 223
224 first = ~0UL >> dst_idx; 224 first = FB_SHIFT_HIGH(~0UL, dst_idx);
225 last = ~(~0UL >> ((dst_idx+n) % bits)); 225 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
226 226
227 if (dst_idx+n <= bits) { 227 if (dst_idx+n <= bits) {
228 // Single word 228 // Single word
@@ -290,8 +290,8 @@ bitfill_unaligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat
290 if (!n) 290 if (!n)
291 return; 291 return;
292 292
293 first = ~0UL >> dst_idx; 293 first = FB_SHIFT_HIGH(~0UL, dst_idx);
294 last = ~(~0UL >> ((dst_idx+n) % bits)); 294 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits));
295 295
296 if (dst_idx+n <= bits) { 296 if (dst_idx+n <= bits) {
297 // Single word 297 // Single word
diff --git a/drivers/video/cfbimgblt.c b/drivers/video/cfbimgblt.c
index a7770c4f17d0..910e2338a27e 100644
--- a/drivers/video/cfbimgblt.c
+++ b/drivers/video/cfbimgblt.c
@@ -76,18 +76,6 @@ static u32 cfb_tab32[] = {
76#define FB_WRITEL fb_writel 76#define FB_WRITEL fb_writel
77#define FB_READL fb_readl 77#define FB_READL fb_readl
78 78
79#if defined (__BIG_ENDIAN)
80#define LEFT_POS(bpp) (32 - bpp)
81#define SHIFT_HIGH(val, bits) ((val) >> (bits))
82#define SHIFT_LOW(val, bits) ((val) << (bits))
83#define BIT_NR(b) (7 - (b))
84#else
85#define LEFT_POS(bpp) (0)
86#define SHIFT_HIGH(val, bits) ((val) << (bits))
87#define SHIFT_LOW(val, bits) ((val) >> (bits))
88#define BIT_NR(b) (b)
89#endif
90
91static inline void color_imageblit(const struct fb_image *image, 79static inline void color_imageblit(const struct fb_image *image,
92 struct fb_info *p, u8 __iomem *dst1, 80 struct fb_info *p, u8 __iomem *dst1,
93 u32 start_index, 81 u32 start_index,
@@ -109,7 +97,7 @@ static inline void color_imageblit(const struct fb_image *image,
109 val = 0; 97 val = 0;
110 98
111 if (start_index) { 99 if (start_index) {
112 u32 start_mask = ~(SHIFT_HIGH(~(u32)0, start_index)); 100 u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0, start_index));
113 val = FB_READL(dst) & start_mask; 101 val = FB_READL(dst) & start_mask;
114 shift = start_index; 102 shift = start_index;
115 } 103 }
@@ -119,20 +107,20 @@ static inline void color_imageblit(const struct fb_image *image,
119 color = palette[*src]; 107 color = palette[*src];
120 else 108 else
121 color = *src; 109 color = *src;
122 color <<= LEFT_POS(bpp); 110 color <<= FB_LEFT_POS(bpp);
123 val |= SHIFT_HIGH(color, shift); 111 val |= FB_SHIFT_HIGH(color, shift);
124 if (shift >= null_bits) { 112 if (shift >= null_bits) {
125 FB_WRITEL(val, dst++); 113 FB_WRITEL(val, dst++);
126 114
127 val = (shift == null_bits) ? 0 : 115 val = (shift == null_bits) ? 0 :
128 SHIFT_LOW(color, 32 - shift); 116 FB_SHIFT_LOW(color, 32 - shift);
129 } 117 }
130 shift += bpp; 118 shift += bpp;
131 shift &= (32 - 1); 119 shift &= (32 - 1);
132 src++; 120 src++;
133 } 121 }
134 if (shift) { 122 if (shift) {
135 u32 end_mask = SHIFT_HIGH(~(u32)0, shift); 123 u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift);
136 124
137 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); 125 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
138 } 126 }
@@ -162,6 +150,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
162 u32 i, j, l; 150 u32 i, j, l;
163 151
164 dst2 = (u32 __iomem *) dst1; 152 dst2 = (u32 __iomem *) dst1;
153 fgcolor <<= FB_LEFT_POS(bpp);
154 bgcolor <<= FB_LEFT_POS(bpp);
165 155
166 for (i = image->height; i--; ) { 156 for (i = image->height; i--; ) {
167 shift = val = 0; 157 shift = val = 0;
@@ -172,22 +162,21 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
172 162
173 /* write leading bits */ 163 /* write leading bits */
174 if (start_index) { 164 if (start_index) {
175 u32 start_mask = ~(SHIFT_HIGH(~(u32)0, start_index)); 165 u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0,start_index));
176 val = FB_READL(dst) & start_mask; 166 val = FB_READL(dst) & start_mask;
177 shift = start_index; 167 shift = start_index;
178 } 168 }
179 169
180 while (j--) { 170 while (j--) {
181 l--; 171 l--;
182 color = (*s & 1 << (BIT_NR(l))) ? fgcolor : bgcolor; 172 color = (*s & 1 << (FB_BIT_NR(l))) ? fgcolor : bgcolor;
183 color <<= LEFT_POS(bpp); 173 val |= FB_SHIFT_HIGH(color, shift);
184 val |= SHIFT_HIGH(color, shift);
185 174
186 /* Did the bitshift spill bits to the next long? */ 175 /* Did the bitshift spill bits to the next long? */
187 if (shift >= null_bits) { 176 if (shift >= null_bits) {
188 FB_WRITEL(val, dst++); 177 FB_WRITEL(val, dst++);
189 val = (shift == null_bits) ? 0 : 178 val = (shift == null_bits) ? 0 :
190 SHIFT_LOW(color,32 - shift); 179 FB_SHIFT_LOW(color,32 - shift);
191 } 180 }
192 shift += bpp; 181 shift += bpp;
193 shift &= (32 - 1); 182 shift &= (32 - 1);
@@ -196,7 +185,7 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
196 185
197 /* write trailing bits */ 186 /* write trailing bits */
198 if (shift) { 187 if (shift) {
199 u32 end_mask = SHIFT_HIGH(~(u32)0, shift); 188 u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift);
200 189
201 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); 190 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
202 } 191 }
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c
index 1bed50f2a276..a56147102abb 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -206,7 +206,6 @@ struct cg14_par {
206 int mode; 206 int mode;
207 int ramsize; 207 int ramsize;
208 struct sbus_dev *sdev; 208 struct sbus_dev *sdev;
209 struct list_head list;
210}; 209};
211 210
212static void __cg14_reset(struct cg14_par *par) 211static void __cg14_reset(struct cg14_par *par)
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index a1354e7e0513..9fcd89608ed7 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -124,7 +124,6 @@ struct cg3_par {
124 unsigned long fbsize; 124 unsigned long fbsize;
125 125
126 struct sbus_dev *sdev; 126 struct sbus_dev *sdev;
127 struct list_head list;
128}; 127};
129 128
130/** 129/**
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index 9debe642fd2f..050835e39aa3 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -265,7 +265,6 @@ struct cg6_par {
265 unsigned long fbsize; 265 unsigned long fbsize;
266 266
267 struct sbus_dev *sdev; 267 struct sbus_dev *sdev;
268 struct list_head list;
269}; 268};
270 269
271static int cg6_sync(struct fb_info *info) 270static int cg6_sync(struct fb_info *info)
@@ -612,7 +611,7 @@ static void cg6_chip_init(struct fb_info *info)
612 struct cg6_par *par = (struct cg6_par *) info->par; 611 struct cg6_par *par = (struct cg6_par *) info->par;
613 struct cg6_tec __iomem *tec = par->tec; 612 struct cg6_tec __iomem *tec = par->tec;
614 struct cg6_fbc __iomem *fbc = par->fbc; 613 struct cg6_fbc __iomem *fbc = par->fbc;
615 u32 rev, conf, mode, tmp; 614 u32 rev, conf, mode;
616 int i; 615 int i;
617 616
618 /* Turn off stuff in the Transform Engine. */ 617 /* Turn off stuff in the Transform Engine. */
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 5f74df993406..a5d09e159cd1 100644
--- a/drivers/video/console/Kconfig
+++ b/drivers/video/console/Kconfig
@@ -6,7 +6,7 @@ menu "Console display driver support"
6 6
7config VGA_CONSOLE 7config VGA_CONSOLE
8 bool "VGA text console" if EMBEDDED || !X86 8 bool "VGA text console" if EMBEDDED || !X86
9 depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC32 && !SPARC64 && !M68K && !PARISC && !ARCH_VERSATILE 9 depends on !ARCH_ACORN && !ARCH_EBSA110 && !4xx && !8xx && !SPARC && !M68K && !PARISC && !ARCH_VERSATILE
10 default y 10 default y
11 help 11 help
12 Saying Y here will allow you to use Linux in text mode through a 12 Saying Y here will allow you to use Linux in text mode through a
@@ -68,7 +68,7 @@ config SGI_NEWPORT_CONSOLE
68 68
69config PROM_CONSOLE 69config PROM_CONSOLE
70 bool "PROM console" 70 bool "PROM console"
71 depends on SPARC32 || SPARC64 71 depends on SPARC
72 help 72 help
73 Say Y to build a console driver for Sun machines that uses the 73 Say Y to build a console driver for Sun machines that uses the
74 terminal emulation built into their console PROMS. 74 terminal emulation built into their console PROMS.
@@ -136,7 +136,7 @@ config FONTS
136config FONT_8x8 136config FONT_8x8
137 bool "VGA 8x8 font" if FONTS 137 bool "VGA 8x8 font" if FONTS
138 depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE 138 depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
139 default y if !SPARC32 && !SPARC64 && !FONTS 139 default y if !SPARC && !FONTS
140 help 140 help
141 This is the "high resolution" font for the VGA frame buffer (the one 141 This is the "high resolution" font for the VGA frame buffer (the one
142 provided by the text console 80x50 (and higher) modes). 142 provided by the text console 80x50 (and higher) modes).
@@ -150,7 +150,7 @@ config FONT_8x8
150config FONT_8x16 150config FONT_8x16
151 bool "VGA 8x16 font" if FONTS 151 bool "VGA 8x16 font" if FONTS
152 depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || STI_CONSOLE || USB_SISUSBVGA_CON 152 depends on FRAMEBUFFER_CONSOLE || SGI_NEWPORT_CONSOLE=y || STI_CONSOLE || USB_SISUSBVGA_CON
153 default y if !SPARC32 && !SPARC64 && !FONTS 153 default y if !SPARC && !FONTS
154 help 154 help
155 This is the "high resolution" font for the VGA frame buffer (the one 155 This is the "high resolution" font for the VGA frame buffer (the one
156 provided by the VGA text console 80x25 mode. 156 provided by the VGA text console 80x25 mode.
@@ -160,7 +160,7 @@ config FONT_8x16
160config FONT_6x11 160config FONT_6x11
161 bool "Mac console 6x11 font (not supported by all drivers)" if FONTS 161 bool "Mac console 6x11 font (not supported by all drivers)" if FONTS
162 depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE 162 depends on FRAMEBUFFER_CONSOLE || STI_CONSOLE
163 default y if !SPARC32 && !SPARC64 && !FONTS && MAC 163 default y if !SPARC && !FONTS && MAC
164 help 164 help
165 Small console font with Macintosh-style high-half glyphs. Some Mac 165 Small console font with Macintosh-style high-half glyphs. Some Mac
166 framebuffer drivers don't support this one at all. 166 framebuffer drivers don't support this one at all.
@@ -176,7 +176,7 @@ config FONT_7x14
176config FONT_PEARL_8x8 176config FONT_PEARL_8x8
177 bool "Pearl (old m68k) console 8x8 font" if FONTS 177 bool "Pearl (old m68k) console 8x8 font" if FONTS
178 depends on FRAMEBUFFER_CONSOLE 178 depends on FRAMEBUFFER_CONSOLE
179 default y if !SPARC32 && !SPARC64 && !FONTS && AMIGA 179 default y if !SPARC && !FONTS && AMIGA
180 help 180 help
181 Small console font with PC-style control-character and high-half 181 Small console font with PC-style control-character and high-half
182 glyphs. 182 glyphs.
@@ -184,24 +184,24 @@ config FONT_PEARL_8x8
184config FONT_ACORN_8x8 184config FONT_ACORN_8x8
185 bool "Acorn console 8x8 font" if FONTS 185 bool "Acorn console 8x8 font" if FONTS
186 depends on FRAMEBUFFER_CONSOLE 186 depends on FRAMEBUFFER_CONSOLE
187 default y if !SPARC32 && !SPARC64 && !FONTS && ARM && ARCH_ACORN 187 default y if !SPARC && !FONTS && ARM && ARCH_ACORN
188 help 188 help
189 Small console font with PC-style control characters and high-half 189 Small console font with PC-style control characters and high-half
190 glyphs. 190 glyphs.
191 191
192config FONT_MINI_4x6 192config FONT_MINI_4x6
193 bool "Mini 4x6 font" 193 bool "Mini 4x6 font"
194 depends on !SPARC32 && !SPARC64 && FONTS 194 depends on !SPARC && FONTS
195 195
196config FONT_SUN8x16 196config FONT_SUN8x16
197 bool "Sparc console 8x16 font" 197 bool "Sparc console 8x16 font"
198 depends on FRAMEBUFFER_CONSOLE && (!SPARC32 && !SPARC64 && FONTS || SPARC32 || SPARC64) 198 depends on FRAMEBUFFER_CONSOLE && (!SPARC && FONTS || SPARC)
199 help 199 help
200 This is the high resolution console font for Sun machines. Say Y. 200 This is the high resolution console font for Sun machines. Say Y.
201 201
202config FONT_SUN12x22 202config FONT_SUN12x22
203 bool "Sparc console 12x22 font (not supported by all drivers)" 203 bool "Sparc console 12x22 font (not supported by all drivers)"
204 depends on FRAMEBUFFER_CONSOLE && (!SPARC32 && !SPARC64 && FONTS || SPARC32 || SPARC64) 204 depends on FRAMEBUFFER_CONSOLE && (!SPARC && FONTS || SPARC)
205 help 205 help
206 This is the high resolution console font for Sun machines with very 206 This is the high resolution console font for Sun machines with very
207 big letters (like the letters used in the SPARC PROM). If the 207 big letters (like the letters used in the SPARC PROM). If the
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index bcea87c3cc06..3660e51b2612 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -2048,7 +2048,7 @@ static int fbcon_switch(struct vc_data *vc)
2048 struct fbcon_ops *ops; 2048 struct fbcon_ops *ops;
2049 struct display *p = &fb_display[vc->vc_num]; 2049 struct display *p = &fb_display[vc->vc_num];
2050 struct fb_var_screeninfo var; 2050 struct fb_var_screeninfo var;
2051 int i, prev_console; 2051 int i, prev_console, charcnt = 256;
2052 2052
2053 info = registered_fb[con2fb_map[vc->vc_num]]; 2053 info = registered_fb[con2fb_map[vc->vc_num]];
2054 ops = info->fbcon_par; 2054 ops = info->fbcon_par;
@@ -2103,7 +2103,8 @@ static int fbcon_switch(struct vc_data *vc)
2103 fb_set_var(info, &var); 2103 fb_set_var(info, &var);
2104 ops->var = info->var; 2104 ops->var = info->var;
2105 2105
2106 if (old_info != NULL && old_info != info) { 2106 if (old_info != NULL && (old_info != info ||
2107 info->flags & FBINFO_MISC_ALWAYS_SETPAR)) {
2107 if (info->fbops->fb_set_par) 2108 if (info->fbops->fb_set_par)
2108 info->fbops->fb_set_par(info); 2109 info->fbops->fb_set_par(info);
2109 fbcon_del_cursor_timer(old_info); 2110 fbcon_del_cursor_timer(old_info);
@@ -2120,6 +2121,13 @@ static int fbcon_switch(struct vc_data *vc)
2120 2121
2121 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1); 2122 vc->vc_can_do_color = (fb_get_color_depth(&info->var, &info->fix)!=1);
2122 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800; 2123 vc->vc_complement_mask = vc->vc_can_do_color ? 0x7700 : 0x0800;
2124
2125 if (p->userfont)
2126 charcnt = FNTCHARCNT(vc->vc_font.data);
2127
2128 if (charcnt > 256)
2129 vc->vc_complement_mask <<= 1;
2130
2123 updatescrollmode(p, info, vc); 2131 updatescrollmode(p, info, vc);
2124 2132
2125 switch (p->scrollmode) { 2133 switch (p->scrollmode) {
@@ -2139,8 +2147,12 @@ static int fbcon_switch(struct vc_data *vc)
2139 2147
2140 scrollback_max = 0; 2148 scrollback_max = 0;
2141 scrollback_current = 0; 2149 scrollback_current = 0;
2142 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; 2150
2143 ops->update_start(info); 2151 if (!fbcon_is_inactive(vc, info)) {
2152 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2153 ops->update_start(info);
2154 }
2155
2144 fbcon_set_palette(vc, color_table); 2156 fbcon_set_palette(vc, color_table);
2145 fbcon_clear_margins(vc, 0); 2157 fbcon_clear_margins(vc, 0);
2146 2158
@@ -2184,11 +2196,14 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2184 ops->graphics = 1; 2196 ops->graphics = 1;
2185 2197
2186 if (!blank) { 2198 if (!blank) {
2199 if (info->fbops->fb_save_state)
2200 info->fbops->fb_save_state(info);
2187 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE; 2201 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
2188 fb_set_var(info, &var); 2202 fb_set_var(info, &var);
2189 ops->graphics = 0; 2203 ops->graphics = 0;
2190 ops->var = info->var; 2204 ops->var = info->var;
2191 } 2205 } else if (info->fbops->fb_restore_state)
2206 info->fbops->fb_restore_state(info);
2192 } 2207 }
2193 2208
2194 if (!fbcon_is_inactive(vc, info)) { 2209 if (!fbcon_is_inactive(vc, info)) {
@@ -2736,8 +2751,12 @@ static void fbcon_modechanged(struct fb_info *info)
2736 updatescrollmode(p, info, vc); 2751 updatescrollmode(p, info, vc);
2737 scrollback_max = 0; 2752 scrollback_max = 0;
2738 scrollback_current = 0; 2753 scrollback_current = 0;
2739 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; 2754
2740 ops->update_start(info); 2755 if (!fbcon_is_inactive(vc, info)) {
2756 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0;
2757 ops->update_start(info);
2758 }
2759
2741 fbcon_set_palette(vc, color_table); 2760 fbcon_set_palette(vc, color_table);
2742 update_screen(vc); 2761 update_screen(vc);
2743 if (softback_buf) 2762 if (softback_buf)
@@ -2774,8 +2793,13 @@ static void fbcon_set_all_vcs(struct fb_info *info)
2774 updatescrollmode(p, info, vc); 2793 updatescrollmode(p, info, vc);
2775 scrollback_max = 0; 2794 scrollback_max = 0;
2776 scrollback_current = 0; 2795 scrollback_current = 0;
2777 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; 2796
2778 ops->update_start(info); 2797 if (!fbcon_is_inactive(vc, info)) {
2798 ops->var.xoffset = ops->var.yoffset =
2799 p->yscroll = 0;
2800 ops->update_start(info);
2801 }
2802
2779 fbcon_set_palette(vc, color_table); 2803 fbcon_set_palette(vc, color_table);
2780 update_screen(vc); 2804 update_screen(vc);
2781 if (softback_buf) 2805 if (softback_buf)
diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c
index c4d7c89212b4..9dd059e8b645 100644
--- a/drivers/video/console/fbcon_ud.c
+++ b/drivers/video/console/fbcon_ud.c
@@ -420,13 +420,15 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info,
420int ud_update_start(struct fb_info *info) 420int ud_update_start(struct fb_info *info)
421{ 421{
422 struct fbcon_ops *ops = info->fbcon_par; 422 struct fbcon_ops *ops = info->fbcon_par;
423 u32 xoffset, yoffset; 423 int xoffset, yoffset;
424 u32 vyres = GETVYRES(ops->p->scrollmode, info); 424 u32 vyres = GETVYRES(ops->p->scrollmode, info);
425 u32 vxres = GETVXRES(ops->p->scrollmode, info); 425 u32 vxres = GETVXRES(ops->p->scrollmode, info);
426 int err; 426 int err;
427 427
428 xoffset = (vxres - info->var.xres) - ops->var.xoffset; 428 xoffset = vxres - info->var.xres - ops->var.xoffset;
429 yoffset = (vyres - info->var.yres) - ops->var.yoffset; 429 yoffset = vyres - info->var.yres - ops->var.yoffset;
430 if (yoffset < 0)
431 yoffset += vyres;
430 ops->var.xoffset = xoffset; 432 ops->var.xoffset = xoffset;
431 ops->var.yoffset = yoffset; 433 ops->var.yoffset = yoffset;
432 err = fb_pan_display(info, &ops->var); 434 err = fb_pan_display(info, &ops->var);
diff --git a/drivers/video/cyber2000fb.c b/drivers/video/cyber2000fb.c
index c589d23e7f91..a9300f930ef2 100644
--- a/drivers/video/cyber2000fb.c
+++ b/drivers/video/cyber2000fb.c
@@ -1512,7 +1512,7 @@ static int cyberpro_pci_enable_mmio(struct cfb_info *cfb)
1512 * I/O cycles storing into a reserved memory space at 1512 * I/O cycles storing into a reserved memory space at
1513 * physical address 0x3000000 1513 * physical address 0x3000000
1514 */ 1514 */
1515 unsigned char *iop; 1515 unsigned char __iomem *iop;
1516 1516
1517 iop = ioremap(0x3000000, 0x5000); 1517 iop = ioremap(0x3000000, 0x5000);
1518 if (iop == NULL) { 1518 if (iop == NULL) {
@@ -1526,7 +1526,7 @@ static int cyberpro_pci_enable_mmio(struct cfb_info *cfb)
1526 writeb(EXT_BIU_MISC, iop + 0x3ce); 1526 writeb(EXT_BIU_MISC, iop + 0x3ce);
1527 writeb(EXT_BIU_MISC_LIN_ENABLE, iop + 0x3cf); 1527 writeb(EXT_BIU_MISC_LIN_ENABLE, iop + 0x3cf);
1528 1528
1529 iounmap((void *)iop); 1529 iounmap(iop);
1530#else 1530#else
1531 /* 1531 /*
1532 * Most other machine types are "normal", so 1532 * Most other machine types are "normal", so
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 6240aedb4154..10dfdf035264 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -722,14 +722,30 @@ static void try_to_load(int fb)
722int 722int
723fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var) 723fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
724{ 724{
725 struct fb_fix_screeninfo *fix = &info->fix;
725 int xoffset = var->xoffset; 726 int xoffset = var->xoffset;
726 int yoffset = var->yoffset; 727 int yoffset = var->yoffset;
727 int err; 728 int err = 0, yres = info->var.yres;
729
730 if (var->yoffset > 0) {
731 if (var->vmode & FB_VMODE_YWRAP) {
732 if (!fix->ywrapstep || (var->yoffset % fix->ywrapstep))
733 err = -EINVAL;
734 else
735 yres = 0;
736 } else if (!fix->ypanstep || (var->yoffset % fix->ypanstep))
737 err = -EINVAL;
738 }
739
740 if (var->xoffset > 0 && (!fix->xpanstep ||
741 (var->xoffset % fix->xpanstep)))
742 err = -EINVAL;
743
744 if (err || !info->fbops->fb_pan_display || xoffset < 0 ||
745 yoffset < 0 || var->yoffset + yres > info->var.yres_virtual ||
746 var->xoffset + info->var.xres > info->var.xres_virtual)
747 return -EINVAL;
728 748
729 if (xoffset < 0 || yoffset < 0 || !info->fbops->fb_pan_display ||
730 xoffset + info->var.xres > info->var.xres_virtual ||
731 yoffset + info->var.yres > info->var.yres_virtual)
732 return -EINVAL;
733 if ((err = info->fbops->fb_pan_display(var, info))) 749 if ((err = info->fbops->fb_pan_display(var, info)))
734 return err; 750 return err;
735 info->var.xoffset = var->xoffset; 751 info->var.xoffset = var->xoffset;
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 2584daec7bbf..c4870d559afc 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -359,7 +359,6 @@ struct ffb_par {
359 int prom_parent_node; 359 int prom_parent_node;
360 int dac_rev; 360 int dac_rev;
361 int board_type; 361 int board_type;
362 struct list_head list;
363}; 362};
364 363
365static void FFBFifo(struct ffb_par *par, int n) 364static void FFBFifo(struct ffb_par *par, int n)
diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h
index f077ca34faba..da29d007f215 100644
--- a/drivers/video/intelfb/intelfb.h
+++ b/drivers/video/intelfb/intelfb.h
@@ -41,6 +41,10 @@
41 41
42/*** hw-related values ***/ 42/*** hw-related values ***/
43 43
44/* Resource Allocation */
45#define INTELFB_FB_ACQUIRED 1
46#define INTELFB_MMIO_ACQUIRED 2
47
44/* PCI ids for supported devices */ 48/* PCI ids for supported devices */
45#define PCI_DEVICE_ID_INTEL_830M 0x3577 49#define PCI_DEVICE_ID_INTEL_830M 0x3577
46#define PCI_DEVICE_ID_INTEL_845G 0x2562 50#define PCI_DEVICE_ID_INTEL_845G 0x2562
@@ -257,6 +261,7 @@ struct intelfb_info {
257 int hwcursor; 261 int hwcursor;
258 int fixed_mode; 262 int fixed_mode;
259 int ring_active; 263 int ring_active;
264 int flag;
260 265
261 /* hw cursor */ 266 /* hw cursor */
262 int cursor_on; 267 int cursor_on;
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 427689e584da..0090544842f5 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -135,9 +135,6 @@
135static void __devinit get_initial_mode(struct intelfb_info *dinfo); 135static void __devinit get_initial_mode(struct intelfb_info *dinfo);
136static void update_dinfo(struct intelfb_info *dinfo, 136static void update_dinfo(struct intelfb_info *dinfo,
137 struct fb_var_screeninfo *var); 137 struct fb_var_screeninfo *var);
138static int intelfb_get_fix(struct fb_fix_screeninfo *fix,
139 struct fb_info *info);
140
141static int intelfb_check_var(struct fb_var_screeninfo *var, 138static int intelfb_check_var(struct fb_var_screeninfo *var,
142 struct fb_info *info); 139 struct fb_info *info);
143static int intelfb_set_par(struct fb_info *info); 140static int intelfb_set_par(struct fb_info *info);
@@ -473,9 +470,9 @@ cleanup(struct intelfb_info *dinfo)
473 if (dinfo->aperture.virtual) 470 if (dinfo->aperture.virtual)
474 iounmap((void __iomem *)dinfo->aperture.virtual); 471 iounmap((void __iomem *)dinfo->aperture.virtual);
475 472
476 if (dinfo->mmio_base_phys) 473 if (dinfo->flag & INTELFB_MMIO_ACQUIRED)
477 release_mem_region(dinfo->mmio_base_phys, INTEL_REG_SIZE); 474 release_mem_region(dinfo->mmio_base_phys, INTEL_REG_SIZE);
478 if (dinfo->aperture.physical) 475 if (dinfo->flag & INTELFB_FB_ACQUIRED)
479 release_mem_region(dinfo->aperture.physical, 476 release_mem_region(dinfo->aperture.physical,
480 dinfo->aperture.size); 477 dinfo->aperture.size);
481 framebuffer_release(dinfo->info); 478 framebuffer_release(dinfo->info);
@@ -572,6 +569,9 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
572 cleanup(dinfo); 569 cleanup(dinfo);
573 return -ENODEV; 570 return -ENODEV;
574 } 571 }
572
573 dinfo->flag |= INTELFB_FB_ACQUIRED;
574
575 if (!request_mem_region(dinfo->mmio_base_phys, 575 if (!request_mem_region(dinfo->mmio_base_phys,
576 INTEL_REG_SIZE, 576 INTEL_REG_SIZE,
577 INTELFB_MODULE_NAME)) { 577 INTELFB_MODULE_NAME)) {
@@ -580,6 +580,8 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent)
580 return -ENODEV; 580 return -ENODEV;
581 } 581 }
582 582
583 dinfo->flag |= INTELFB_MMIO_ACQUIRED;
584
583 /* Get the chipset info. */ 585 /* Get the chipset info. */
584 dinfo->pci_chipset = pdev->device; 586 dinfo->pci_chipset = pdev->device;
585 587
@@ -1091,7 +1093,17 @@ intelfb_set_fbinfo(struct intelfb_info *dinfo)
1091 return 1; 1093 return 1;
1092 1094
1093 info->pixmap.scan_align = 1; 1095 info->pixmap.scan_align = 1;
1094 1096 strcpy(info->fix.id, dinfo->name);
1097 info->fix.smem_start = dinfo->fb.physical;
1098 info->fix.smem_len = dinfo->fb.size;
1099 info->fix.type = FB_TYPE_PACKED_PIXELS;
1100 info->fix.type_aux = 0;
1101 info->fix.xpanstep = 8;
1102 info->fix.ypanstep = 1;
1103 info->fix.ywrapstep = 0;
1104 info->fix.mmio_start = dinfo->mmio_base_phys;
1105 info->fix.mmio_len = INTEL_REG_SIZE;
1106 info->fix.accel = FB_ACCEL_I830;
1095 update_dinfo(dinfo, &info->var); 1107 update_dinfo(dinfo, &info->var);
1096 1108
1097 return 0; 1109 return 0;
@@ -1109,7 +1121,8 @@ update_dinfo(struct intelfb_info *dinfo, struct fb_var_screeninfo *var)
1109 dinfo->yres = var->xres; 1121 dinfo->yres = var->xres;
1110 dinfo->pixclock = var->pixclock; 1122 dinfo->pixclock = var->pixclock;
1111 1123
1112 intelfb_get_fix(&dinfo->info->fix, dinfo->info); 1124 dinfo->info->fix.visual = dinfo->visual;
1125 dinfo->info->fix.line_length = dinfo->pitch;
1113 1126
1114 switch (dinfo->bpp) { 1127 switch (dinfo->bpp) {
1115 case 8: 1128 case 8:
@@ -1139,30 +1152,6 @@ update_dinfo(struct intelfb_info *dinfo, struct fb_var_screeninfo *var)
1139 1152
1140/* fbops functions */ 1153/* fbops functions */
1141 1154
1142static int
1143intelfb_get_fix(struct fb_fix_screeninfo *fix, struct fb_info *info)
1144{
1145 struct intelfb_info *dinfo = GET_DINFO(info);
1146
1147 DBG_MSG("intelfb_get_fix\n");
1148
1149 memset(fix, 0, sizeof(*fix));
1150 strcpy(fix->id, dinfo->name);
1151 fix->smem_start = dinfo->fb.physical;
1152 fix->smem_len = dinfo->fb.size;
1153 fix->type = FB_TYPE_PACKED_PIXELS;
1154 fix->type_aux = 0;
1155 fix->visual = dinfo->visual;
1156 fix->xpanstep = 8;
1157 fix->ypanstep = 1;
1158 fix->ywrapstep = 0;
1159 fix->line_length = dinfo->pitch;
1160 fix->mmio_start = dinfo->mmio_base_phys;
1161 fix->mmio_len = INTEL_REG_SIZE;
1162 fix->accel = FB_ACCEL_I830;
1163 return 0;
1164}
1165
1166/*************************************************************** 1155/***************************************************************
1167 * fbdev interface * 1156 * fbdev interface *
1168 ***************************************************************/ 1157 ***************************************************************/
diff --git a/drivers/video/leo.c b/drivers/video/leo.c
index 376d4a171ec7..494287f8f8bf 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -197,7 +197,6 @@ struct leo_par {
197 unsigned long fbsize; 197 unsigned long fbsize;
198 198
199 struct sbus_dev *sdev; 199 struct sbus_dev *sdev;
200 struct list_head list;
201}; 200};
202 201
203static void leo_wait(struct leo_lx_krn __iomem *lx_krn) 202static void leo_wait(struct leo_lx_krn __iomem *lx_krn)
diff --git a/drivers/video/logo/Kconfig b/drivers/video/logo/Kconfig
index 8cb7fb4db441..f0e6512c87ff 100644
--- a/drivers/video/logo/Kconfig
+++ b/drivers/video/logo/Kconfig
@@ -47,7 +47,7 @@ config LOGO_SGI_CLUT224
47 47
48config LOGO_SUN_CLUT224 48config LOGO_SUN_CLUT224
49 bool "224-color Sun Linux logo" 49 bool "224-color Sun Linux logo"
50 depends on LOGO && (SPARC32 || SPARC64) 50 depends on LOGO && SPARC
51 default y 51 default y
52 52
53config LOGO_SUPERH_MONO 53config LOGO_SUPERH_MONO
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c
index ad60bbb16cdf..a1f2c5e8fc88 100644
--- a/drivers/video/matrox/matroxfb_maven.c
+++ b/drivers/video/matrox/matroxfb_maven.c
@@ -1288,18 +1288,13 @@ static int maven_detach_client(struct i2c_client* client) {
1288 return 0; 1288 return 0;
1289} 1289}
1290 1290
1291static int maven_command(struct i2c_client* client, unsigned int cmd, void* arg) {
1292 return -ENOIOCTLCMD; /* or -EINVAL, depends on who will call this */
1293}
1294
1295static struct i2c_driver maven_driver={ 1291static struct i2c_driver maven_driver={
1296 .owner = THIS_MODULE, 1292 .driver = {
1297 .name = "maven", 1293 .name = "maven",
1294 },
1298 .id = I2C_DRIVERID_MGATVO, 1295 .id = I2C_DRIVERID_MGATVO,
1299 .flags = I2C_DF_NOTIFY,
1300 .attach_adapter = maven_attach_adapter, 1296 .attach_adapter = maven_attach_adapter,
1301 .detach_client = maven_detach_client, 1297 .detach_client = maven_detach_client,
1302 .command = maven_command,
1303}; 1298};
1304 1299
1305/* ************************** */ 1300/* ************************** */
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index 18bcda23d2cf..b251e754e16c 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -140,7 +140,6 @@ struct p9100_par {
140 unsigned long fbsize; 140 unsigned long fbsize;
141 141
142 struct sbus_dev *sdev; 142 struct sbus_dev *sdev;
143 struct list_head list;
144}; 143};
145 144
146/** 145/**
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index 7b4cd250bec8..9fc10b9e6f57 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -1396,7 +1396,8 @@ static struct platform_driver pxafb_driver = {
1396int __devinit pxafb_setup(char *options) 1396int __devinit pxafb_setup(char *options)
1397{ 1397{
1398# ifdef CONFIG_FB_PXA_PARAMETERS 1398# ifdef CONFIG_FB_PXA_PARAMETERS
1399 strlcpy(g_options, options, sizeof(g_options)); 1399 if (options)
1400 strlcpy(g_options, options, sizeof(g_options));
1400# endif 1401# endif
1401 return 0; 1402 return 0;
1402} 1403}
diff --git a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c
index 646c43f921c5..3a74a63dd4f2 100644
--- a/drivers/video/sbuslib.c
+++ b/drivers/video/sbuslib.c
@@ -46,6 +46,9 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,
46 unsigned long off; 46 unsigned long off;
47 int i; 47 int i;
48 48
49 if (!(vma->vm_flags & (VM_SHARED | VM_MAYSHARE)))
50 return -EINVAL;
51
49 size = vma->vm_end - vma->vm_start; 52 size = vma->vm_end - vma->vm_start;
50 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 53 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
51 return -EINVAL; 54 return -EINVAL;
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index fe4f63f3849d..2b27b4474001 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -125,7 +125,6 @@ struct tcx_par {
125 int lowdepth; 125 int lowdepth;
126 126
127 struct sbus_dev *sdev; 127 struct sbus_dev *sdev;
128 struct list_head list;
129}; 128};
130 129
131/* Reset control plane so that WID is 8-bit plane. */ 130/* Reset control plane so that WID is 8-bit plane. */
@@ -444,7 +443,7 @@ static void tcx_init_one(struct sbus_dev *sdev)
444 443
445 tcx_reset(&all->info); 444 tcx_reset(&all->info);
446 445
447 tcx_blank(0, &all->info); 446 tcx_blank(FB_BLANK_UNBLANK, &all->info);
448 447
449 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 448 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
450 printk(KERN_ERR "tcx: Could not allocate color map.\n"); 449 printk(KERN_ERR "tcx: Could not allocate color map.\n");
diff --git a/drivers/w1/dscore.c b/drivers/w1/dscore.c
index 15fb250451e5..b9146306df49 100644
--- a/drivers/w1/dscore.c
+++ b/drivers/w1/dscore.c
@@ -52,7 +52,6 @@ static int ds_send_control_cmd(struct ds_device *, u16, u16);
52 52
53 53
54static struct usb_driver ds_driver = { 54static struct usb_driver ds_driver = {
55 .owner = THIS_MODULE,
56 .name = "DS9490R", 55 .name = "DS9490R",
57 .probe = ds_probe, 56 .probe = ds_probe,
58 .disconnect = ds_disconnect, 57 .disconnect = ds_disconnect,
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 14016b1cd948..024206c4a0e4 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -142,12 +142,12 @@ static struct bin_attribute w1_slave_attr_bin_id = {
142/* Default family */ 142/* Default family */
143static struct w1_family w1_default_family; 143static struct w1_family w1_default_family;
144 144
145static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size); 145static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size);
146 146
147static struct bus_type w1_bus_type = { 147static struct bus_type w1_bus_type = {
148 .name = "w1", 148 .name = "w1",
149 .match = w1_master_match, 149 .match = w1_master_match,
150 .hotplug = w1_hotplug, 150 .uevent = w1_uevent,
151}; 151};
152 152
153struct device_driver w1_master_driver = { 153struct device_driver w1_master_driver = {
@@ -361,7 +361,7 @@ void w1_destroy_master_attributes(struct w1_master *master)
361} 361}
362 362
363#ifdef CONFIG_HOTPLUG 363#ifdef CONFIG_HOTPLUG
364static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 364static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
365{ 365{
366 struct w1_master *md = NULL; 366 struct w1_master *md = NULL;
367 struct w1_slave *sl = NULL; 367 struct w1_slave *sl = NULL;
@@ -377,7 +377,7 @@ static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffe
377 event_owner = "slave"; 377 event_owner = "slave";
378 name = sl->name; 378 name = sl->name;
379 } else { 379 } else {
380 dev_dbg(dev, "Unknown hotplug event.\n"); 380 dev_dbg(dev, "Unknown event.\n");
381 return -EINVAL; 381 return -EINVAL;
382 } 382 }
383 383
@@ -386,18 +386,18 @@ static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffe
386 if (dev->driver != &w1_slave_driver || !sl) 386 if (dev->driver != &w1_slave_driver || !sl)
387 return 0; 387 return 0;
388 388
389 err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family); 389 err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family);
390 if (err) 390 if (err)
391 return err; 391 return err;
392 392
393 err = add_hotplug_env_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id); 393 err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id);
394 if (err) 394 if (err)
395 return err; 395 return err;
396 396
397 return 0; 397 return 0;
398}; 398};
399#else 399#else
400static int w1_hotplug(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size) 400static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer, int buffer_size)
401{ 401{
402 return 0; 402 return 0;
403} 403}