aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/Makefile3
-rw-r--r--drivers/acpi/Kconfig1
-rw-r--r--drivers/acpi/Makefile2
-rw-r--r--drivers/acpi/bus.c3
-rw-r--r--drivers/acpi/glue.c1
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/processor_core.c15
-rw-r--r--drivers/acpi/processor_idle.c75
-rw-r--r--drivers/acpi/processor_thermal.c42
-rw-r--r--drivers/acpi/scan.c2
-rw-r--r--drivers/acpi/thermal.c163
-rw-r--r--drivers/acpi/utilities/utmisc.c18
-rw-r--r--drivers/acpi/video.c2
-rw-r--r--drivers/atm/Kconfig7
-rw-r--r--drivers/atm/Makefile1
-rw-r--r--drivers/atm/adummy.c168
-rw-r--r--drivers/atm/atmdev_init.c54
-rw-r--r--drivers/atm/atmtcp.c20
-rw-r--r--drivers/atm/horizon.c4
-rw-r--r--drivers/atm/lanai.c102
-rw-r--r--drivers/base/bus.c21
-rw-r--r--drivers/base/dd.c8
-rw-r--r--drivers/base/firmware_class.c15
-rw-r--r--drivers/base/memory.c1
-rw-r--r--drivers/base/platform.c73
-rw-r--r--drivers/block/acsi.c1
-rw-r--r--drivers/block/cciss.c227
-rw-r--r--drivers/block/cciss.h11
-rw-r--r--drivers/block/cciss_scsi.c80
-rw-r--r--drivers/block/floppy.c14
-rw-r--r--drivers/block/pktcdvd.c2
-rw-r--r--drivers/char/Kconfig22
-rw-r--r--drivers/char/agp/ali-agp.c1
-rw-r--r--drivers/char/agp/amd-k7-agp.c1
-rw-r--r--drivers/char/agp/amd64-agp.c22
-rw-r--r--drivers/char/agp/ati-agp.c1
-rw-r--r--drivers/char/agp/backend.c2
-rw-r--r--drivers/char/agp/efficeon-agp.c1
-rw-r--r--drivers/char/agp/i460-agp.c1
-rw-r--r--drivers/char/agp/intel-agp.c1
-rw-r--r--drivers/char/agp/nvidia-agp.c1
-rw-r--r--drivers/char/agp/sis-agp.c1
-rw-r--r--drivers/char/agp/sworks-agp.c1
-rw-r--r--drivers/char/agp/uninorth-agp.c5
-rw-r--r--drivers/char/agp/via-agp.c7
-rw-r--r--drivers/char/drm/drm_lock.c11
-rw-r--r--drivers/char/drm/drm_memory.c2
-rw-r--r--drivers/char/drm/drm_memory_debug.h2
-rw-r--r--drivers/char/drm/mga_drv.c2
-rw-r--r--drivers/char/drm/radeon_drv.h1
-rw-r--r--drivers/char/epca.c1
-rw-r--r--drivers/char/ftape/lowlevel/ftape-buffer.c1
-rw-r--r--drivers/char/i8k.c6
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c10
-rw-r--r--drivers/char/ipmi/ipmi_si_intf.c8
-rw-r--r--drivers/char/keyboard.c10
-rw-r--r--drivers/char/mwave/mwavepub.h2
-rw-r--r--drivers/char/pcmcia/Kconfig24
-rw-r--r--drivers/char/pcmcia/Makefile2
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c2079
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c841
-rw-r--r--drivers/char/pcmcia/cm4040_cs.h47
-rw-r--r--drivers/char/s3c2410-rtc.c50
-rw-r--r--drivers/char/sonypi.c19
-rw-r--r--drivers/char/synclink.c32
-rw-r--r--drivers/char/synclinkmp.c1
-rw-r--r--drivers/char/tb0219.c15
-rw-r--r--drivers/char/tpm/Kconfig2
-rw-r--r--drivers/char/tpm/tpm.c16
-rw-r--r--drivers/char/tpm/tpm.h7
-rw-r--r--drivers/char/tpm/tpm_atmel.c125
-rw-r--r--drivers/char/tpm/tpm_atmel.h131
-rw-r--r--drivers/char/vc_screen.c2
-rw-r--r--drivers/char/vr41xx_giu.c15
-rw-r--r--drivers/char/vr41xx_rtc.c17
-rw-r--r--drivers/char/watchdog/booke_wdt.c17
-rw-r--r--drivers/char/watchdog/mpcore_wdt.c34
-rw-r--r--drivers/char/watchdog/mv64x60_wdt.c20
-rw-r--r--drivers/char/watchdog/pcwd_pci.c1
-rw-r--r--drivers/char/watchdog/s3c2410_wdt.c30
-rw-r--r--drivers/char/watchdog/wdrtas.c2
-rw-r--r--drivers/char/watchdog/wdt_pci.c1
-rw-r--r--drivers/connector/cn_proc.c5
-rw-r--r--drivers/cpufreq/cpufreq.c14
-rw-r--r--drivers/fc4/Kconfig8
-rw-r--r--drivers/firmware/Kconfig1
-rw-r--r--drivers/firmware/dell_rbu.c6
-rw-r--r--drivers/hwmon/hdaps.c62
-rw-r--r--drivers/hwmon/it87.c7
-rw-r--r--drivers/hwmon/lm78.c2
-rw-r--r--drivers/hwmon/w83627hf.c8
-rw-r--r--drivers/hwmon/w83792d.c25
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c1
-rw-r--r--drivers/i2c/busses/i2c-ali1563.c1
-rw-r--r--drivers/i2c/busses/i2c-ali15x3.c1
-rw-r--r--drivers/i2c/busses/i2c-amd756.c1
-rw-r--r--drivers/i2c/busses/i2c-amd8111.c1
-rw-r--r--drivers/i2c/busses/i2c-hydra.c1
-rw-r--r--drivers/i2c/busses/i2c-i801.c1
-rw-r--r--drivers/i2c/busses/i2c-i810.c1
-rw-r--r--drivers/i2c/busses/i2c-iop3xx.c27
-rw-r--r--drivers/i2c/busses/i2c-ixp2000.c31
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c31
-rw-r--r--drivers/i2c/busses/i2c-mpc.c24
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c35
-rw-r--r--drivers/i2c/busses/i2c-nforce2.c1
-rw-r--r--drivers/i2c/busses/i2c-piix4.c1
-rw-r--r--drivers/i2c/busses/i2c-prosavage.c1
-rw-r--r--drivers/i2c/busses/i2c-pxa.c25
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c71
-rw-r--r--drivers/i2c/busses/i2c-savage4.c1
-rw-r--r--drivers/i2c/busses/i2c-sis5595.c1
-rw-r--r--drivers/i2c/busses/i2c-sis630.c1
-rw-r--r--drivers/i2c/busses/i2c-sis96x.c1
-rw-r--r--drivers/i2c/busses/i2c-via.c1
-rw-r--r--drivers/i2c/busses/i2c-viapro.c1
-rw-r--r--drivers/i2c/busses/i2c-voodoo3.c1
-rw-r--r--drivers/i2c/chips/isp1301_omap.c21
-rw-r--r--drivers/ide/Kconfig16
-rw-r--r--drivers/ide/Makefile2
-rw-r--r--drivers/ide/ide-cd.c13
-rw-r--r--drivers/ide/ide-cd.h1
-rw-r--r--drivers/ide/ide-disk.c8
-rw-r--r--drivers/ide/ide-dma.c15
-rw-r--r--drivers/ide/ide-floppy.c7
-rw-r--r--drivers/ide/ide-io.c6
-rw-r--r--drivers/ide/ide-lib.c8
-rw-r--r--drivers/ide/ide-tape.c7
-rw-r--r--drivers/ide/ide-taskfile.c27
-rw-r--r--drivers/ide/mips/Makefile4
-rw-r--r--drivers/ide/mips/au1xxx-ide.c1498
-rw-r--r--drivers/ide/mips/swarm.c201
-rw-r--r--drivers/ide/pci/aec62xx.c47
-rw-r--r--drivers/ide/pci/alim15x3.c9
-rw-r--r--drivers/ide/pci/cs5520.c5
-rw-r--r--drivers/ide/pci/sgiioc4.c8
-rw-r--r--drivers/ide/pci/siimage.c8
-rw-r--r--drivers/ide/pci/sis5513.c1
-rw-r--r--drivers/ide/pci/sl82c105.c83
-rw-r--r--drivers/ide/pci/via82cxxx.c408
-rw-r--r--drivers/ide/ppc/pmac.c25
-rw-r--r--drivers/ide/setup-pci.c12
-rw-r--r--drivers/ieee1394/hosts.h1
-rw-r--r--drivers/ieee1394/nodemgr.c67
-rw-r--r--drivers/ieee1394/sbp2.c6
-rw-r--r--drivers/infiniband/core/mad.c4
-rw-r--r--drivers/infiniband/core/user_mad.c172
-rw-r--r--drivers/infiniband/core/uverbs.h11
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c100
-rw-r--r--drivers/infiniband/core/uverbs_main.c21
-rw-r--r--drivers/infiniband/core/verbs.c12
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c16
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.h1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c176
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c22
-rw-r--r--drivers/infiniband/hw/mthca/mthca_wqe.h4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h15
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_fs.c177
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c4
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c83
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c36
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c7
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c17
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h1
-rw-r--r--drivers/input/gameport/gameport.c12
-rw-r--r--drivers/input/input.c63
-rw-r--r--drivers/input/joystick/warrior.c2
-rw-r--r--drivers/input/keyboard/atkbd.c99
-rw-r--r--drivers/input/keyboard/corgikbd.c29
-rw-r--r--drivers/input/keyboard/spitzkbd.c29
-rw-r--r--drivers/input/misc/Kconfig12
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/uinput.c325
-rw-r--r--drivers/input/misc/wistron_btns.c561
-rw-r--r--drivers/input/mouse/alps.c2
-rw-r--r--drivers/input/mouse/sermouse.c2
-rw-r--r--drivers/input/serio/i8042.c19
-rw-r--r--drivers/input/serio/i8042.h2
-rw-r--r--drivers/input/serio/rpckbd.c21
-rw-r--r--drivers/input/serio/serio.c12
-rw-r--r--drivers/input/touchscreen/corgi_ts.c32
-rw-r--r--drivers/isdn/hisax/Kconfig12
-rw-r--r--drivers/isdn/hisax/hfc_usb.c32
-rw-r--r--drivers/isdn/pcbit/Kconfig2
-rw-r--r--drivers/macintosh/therm_pm72.c8
-rw-r--r--drivers/macintosh/windfarm_pm81.c4
-rw-r--r--drivers/md/bitmap.c4
-rw-r--r--drivers/md/dm-bio-list.h3
-rw-r--r--drivers/md/dm-ioctl.c3
-rw-r--r--drivers/md/dm-log.c4
-rw-r--r--drivers/md/dm-mpath.c13
-rw-r--r--drivers/md/dm-raid1.c20
-rw-r--r--drivers/md/md.c42
-rw-r--r--drivers/md/raid1.c13
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c9
-rw-r--r--drivers/md/raid6main.c27
-rw-r--r--drivers/media/common/Kconfig6
-rw-r--r--drivers/media/common/Makefile4
-rw-r--r--drivers/media/common/ir-common.c61
-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/Kconfig1
-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-hw-filter.c2
-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.c11
-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.c71
-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.c73
-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.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dibusb-common.c18
-rw-r--r--drivers/media/dvb/dvb-usb/digitv.c2
-rw-r--r--drivers/media/dvb/dvb-usb/dvb-usb-init.c2
-rw-r--r--drivers/media/dvb/dvb-usb/vp702x-fe.c2
-rw-r--r--drivers/media/dvb/dvb-usb/vp7045-fe.c2
-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.c4
-rw-r--r--drivers/media/dvb/frontends/cx22702.h4
-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.c6
-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/frontends/ves1820.c14
-rw-r--r--drivers/media/dvb/ttpci/Kconfig1
-rw-r--r--drivers/media/dvb/ttpci/av7110.c29
-rw-r--r--drivers/media/dvb/ttpci/av7110_ca.c1
-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-av.c2
-rw-r--r--drivers/media/dvb/ttpci/budget-ci.c2
-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.c8
-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.c41
-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/Kconfig33
-rw-r--r--drivers/media/video/Makefile5
-rw-r--r--drivers/media/video/bt832.c14
-rw-r--r--drivers/media/video/bttv-cards.c30
-rw-r--r--drivers/media/video/bttv-driver.c153
-rw-r--r--drivers/media/video/bttv-gpio.c18
-rw-r--r--drivers/media/video/bttv.h3
-rw-r--r--drivers/media/video/bttvp.h3
-rw-r--r--drivers/media/video/cx25840/Makefile6
-rw-r--r--drivers/media/video/cx25840/cx25840-audio.c368
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c1056
-rw-r--r--drivers/media/video/cx25840/cx25840-firmware.c167
-rw-r--r--drivers/media/video/cx25840/cx25840-vbi.c315
-rw-r--r--drivers/media/video/cx25840/cx25840.h92
-rw-r--r--drivers/media/video/cx88/Kconfig20
-rw-r--r--drivers/media/video/cx88/Makefile27
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c2
-rw-r--r--drivers/media/video/cx88/cx88-cards.c45
-rw-r--r--drivers/media/video/cx88/cx88-core.c35
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c3
-rw-r--r--drivers/media/video/cx88/cx88-input.c2
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c28
-rw-r--r--drivers/media/video/cx88/cx88.h5
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c56
-rw-r--r--drivers/media/video/em28xx/em28xx-i2c.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-input.c3
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c23
-rw-r--r--drivers/media/video/ir-kbd-gpio.c293
-rw-r--r--drivers/media/video/ir-kbd-i2c.c63
-rw-r--r--drivers/media/video/msp3400.c18
-rw-r--r--drivers/media/video/saa6588.c1
-rw-r--r--drivers/media/video/saa7115.c1378
-rw-r--r--drivers/media/video/saa711x.c5
-rw-r--r--drivers/media/video/saa7127.c849
-rw-r--r--drivers/media/video/saa7134/Kconfig37
-rw-r--r--drivers/media/video/saa7134/Makefile29
-rw-r--r--drivers/media/video/saa7134/saa6752hs.c17
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c484
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c34
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c147
-rw-r--r--drivers/media/video/saa7134/saa7134-empress.c1
-rw-r--r--drivers/media/video/saa7134/saa7134-i2c.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-input.c111
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c187
-rw-r--r--drivers/media/video/saa7134/saa7134.h6
-rw-r--r--drivers/media/video/tda8290.c4
-rw-r--r--drivers/media/video/tda9887.c15
-rw-r--r--drivers/media/video/tuner-core.c11
-rw-r--r--drivers/media/video/tuner-simple.c4
-rw-r--r--drivers/media/video/tvaudio.c30
-rw-r--r--drivers/media/video/tveeprom.c69
-rw-r--r--drivers/media/video/tvp5150.c3
-rw-r--r--drivers/media/video/video-buf-dvb.c2
-rw-r--r--drivers/media/video/video-buf.c9
-rw-r--r--drivers/media/video/videodev.c26
-rw-r--r--drivers/media/video/wm8775.c7
-rw-r--r--drivers/message/fusion/mptbase.c70
-rw-r--r--drivers/message/fusion/mptbase.h5
-rw-r--r--drivers/message/fusion/mptscsih.c10
-rw-r--r--drivers/message/i2o/pci.c8
-rw-r--r--drivers/mfd/mcp-sa11x0.c32
-rw-r--r--drivers/mfd/ucb1x00-ts.c19
-rw-r--r--drivers/misc/hdpuftrs/hdpu_cpustate.c20
-rw-r--r--drivers/misc/hdpuftrs/hdpu_nexus.c20
-rw-r--r--drivers/mmc/mmc.c17
-rw-r--r--drivers/mmc/mmc_block.c14
-rw-r--r--drivers/mmc/mmci.c1
-rw-r--r--drivers/mmc/pxamci.c42
-rw-r--r--drivers/mmc/wbsd.c34
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0001.c10
-rw-r--r--drivers/mtd/chips/cfi_probe.c8
-rw-r--r--drivers/mtd/chips/sharp.c123
-rw-r--r--drivers/mtd/devices/blkmtd.c8
-rw-r--r--drivers/mtd/devices/block2mtd.c6
-rw-r--r--drivers/mtd/devices/ms02-nv.c6
-rw-r--r--drivers/mtd/ftl.c6
-rw-r--r--drivers/mtd/maps/Kconfig10
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/bast-flash.c33
-rw-r--r--drivers/mtd/maps/integrator-flash.c23
-rw-r--r--drivers/mtd/maps/ipaq-flash.c6
-rw-r--r--drivers/mtd/maps/ixp2000.c47
-rw-r--r--drivers/mtd/maps/ixp4xx.c103
-rw-r--r--drivers/mtd/maps/nettel.c4
-rw-r--r--drivers/mtd/maps/omap_nor.c23
-rw-r--r--drivers/mtd/maps/pci.c4
-rw-r--r--drivers/mtd/maps/physmap.c3
-rw-r--r--drivers/mtd/maps/plat-ram.c68
-rw-r--r--drivers/mtd/maps/sa1100-flash.c36
-rw-r--r--drivers/mtd/maps/sc520cdp.c4
-rw-r--r--drivers/mtd/nand/h1910.c2
-rw-r--r--drivers/mtd/nand/nandsim.c2
-rw-r--r--drivers/mtd/nand/s3c2410.c77
-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/mtd/rfd_ftl.c6
-rw-r--r--drivers/net/3c509.c13
-rw-r--r--drivers/net/Kconfig2
-rw-r--r--drivers/net/au1000_eth.c1
-rw-r--r--drivers/net/b44.c13
-rw-r--r--drivers/net/bnx2.c16
-rw-r--r--drivers/net/depca.c26
-rw-r--r--drivers/net/dgrs.c2
-rw-r--r--drivers/net/dm9000.c35
-rw-r--r--drivers/net/e100.c275
-rw-r--r--drivers/net/e1000/e1000_main.c14
-rw-r--r--drivers/net/fec_8xx/Kconfig2
-rw-r--r--drivers/net/forcedeth.c244
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c1
-rw-r--r--drivers/net/fs_enet/mac-fcc.c1
-rw-r--r--drivers/net/fs_enet/mac-fec.c1
-rw-r--r--drivers/net/fs_enet/mac-scc.c1
-rw-r--r--drivers/net/gianfar.c30
-rw-r--r--drivers/net/gianfar.h2
-rw-r--r--drivers/net/gianfar_ethtool.c2
-rw-r--r--drivers/net/gianfar_mii.c4
-rw-r--r--drivers/net/gianfar_mii.h2
-rw-r--r--drivers/net/gt96100eth.c10
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.c38
-rw-r--r--drivers/net/ibm_emac/ibm_emac_core.h2
-rw-r--r--drivers/net/ibmveth.c2
-rw-r--r--drivers/net/ioc3-eth.c2
-rw-r--r--drivers/net/irda/ali-ircc.c1
-rw-r--r--drivers/net/irda/nsc-ircc.c1
-rw-r--r--drivers/net/irda/sa1100_ir.c28
-rw-r--r--drivers/net/irda/smsc-ircc2.c27
-rw-r--r--drivers/net/jazzsonic.c25
-rw-r--r--drivers/net/macsonic.c21
-rw-r--r--drivers/net/mipsnet.h30
-rw-r--r--drivers/net/mv643xx_eth.c40
-rw-r--r--drivers/net/pcmcia/fmvj18x_cs.c32
-rw-r--r--drivers/net/pcnet32.c5
-rw-r--r--drivers/net/phy/phy_device.c4
-rw-r--r--drivers/net/ppp_generic.c3
-rw-r--r--drivers/net/r8169.c6
-rw-r--r--drivers/net/s2io.c10
-rw-r--r--drivers/net/saa9730.c613
-rw-r--r--drivers/net/saa9730.h36
-rw-r--r--drivers/net/sk98lin/Makefile5
-rw-r--r--drivers/net/sk98lin/h/skdrv2nd.h4
-rw-r--r--drivers/net/sk98lin/skcsum.c871
-rw-r--r--drivers/net/sk98lin/skethtool.c2
-rw-r--r--drivers/net/sk98lin/skge.c174
-rw-r--r--drivers/net/skge.c14
-rw-r--r--drivers/net/smc91x.c55
-rw-r--r--drivers/net/smc91x.h48
-rw-r--r--drivers/net/spider_net.c1
-rw-r--r--drivers/net/sungem.c6
-rw-r--r--drivers/net/tg3.c266
-rw-r--r--drivers/net/tg3.h14
-rw-r--r--drivers/net/tokenring/proteon.c17
-rw-r--r--drivers/net/tokenring/skisa.c17
-rw-r--r--drivers/net/wan/hdlc_cisco.c6
-rw-r--r--drivers/net/wan/hdlc_fr.c4
-rw-r--r--drivers/net/wan/hdlc_generic.c6
-rw-r--r--drivers/net/wan/sdladrv.c2
-rw-r--r--drivers/net/wireless/Kconfig2
-rw-r--r--drivers/net/wireless/airo.c4
-rw-r--r--drivers/net/wireless/atmel.c88
-rw-r--r--drivers/net/wireless/atmel.h4
-rw-r--r--drivers/net/wireless/atmel_cs.c176
-rw-r--r--drivers/net/wireless/atmel_pci.c2
-rw-r--r--drivers/net/wireless/hermes.c6
-rw-r--r--drivers/net/wireless/hermes.h6
-rw-r--r--drivers/net/wireless/i82593.h11
-rw-r--r--drivers/net/wireless/ipw2100.c29
-rw-r--r--drivers/net/wireless/ipw2100.h2
-rw-r--r--drivers/net/wireless/ipw2200.c7
-rw-r--r--drivers/net/wireless/orinoco.c3
-rw-r--r--drivers/net/wireless/orinoco_nortel.c6
-rw-r--r--drivers/net/wireless/prism54/isl_38xx.c4
-rw-r--r--drivers/parisc/iosapic.c26
-rw-r--r--drivers/parisc/superio.c35
-rw-r--r--drivers/pci/Makefile7
-rw-r--r--drivers/pci/access.c2
-rw-r--r--drivers/pci/hotplug/pciehp.h134
-rw-r--r--drivers/pci/hotplug/pciehp_core.c108
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c1980
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c125
-rw-r--r--drivers/pci/hotplug/pciehp_pci.c840
-rw-r--r--drivers/pci/hotplug/pciehprm.h52
-rw-r--r--drivers/pci/hotplug/pciehprm_acpi.c1727
-rw-r--r--drivers/pci/hotplug/pciehprm_nonacpi.c464
-rw-r--r--drivers/pci/hotplug/pciehprm_nonacpi.h56
-rw-r--r--drivers/pci/hotplug/rpadlpar_core.c81
-rw-r--r--drivers/pci/hotplug/rpaphp.h2
-rw-r--r--drivers/pci/hotplug/rpaphp_pci.c76
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c2
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c2
-rw-r--r--drivers/pci/msi.c20
-rw-r--r--drivers/pci/pci-acpi.c12
-rw-r--r--drivers/pci/pci-driver.c11
-rw-r--r--drivers/pci/pci.c46
-rw-r--r--drivers/pci/quirks.c19
-rw-r--r--drivers/pcmcia/Kconfig2
-rw-r--r--drivers/pcmcia/Makefile6
-rw-r--r--drivers/pcmcia/au1000_db1x00.c1
-rw-r--r--drivers/pcmcia/au1000_generic.h2
-rw-r--r--drivers/pcmcia/au1000_pb1x00.c1
-rw-r--r--drivers/pcmcia/au1000_xxs1500.c1
-rw-r--r--drivers/pcmcia/cs.c6
-rw-r--r--drivers/pcmcia/ds.c3
-rw-r--r--drivers/pcmcia/i82365.c21
-rw-r--r--drivers/pcmcia/m32r_cfc.c3
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c24
-rw-r--r--drivers/s390/char/raw3270.c4
-rw-r--r--drivers/s390/net/lcs.c4
-rw-r--r--drivers/s390/net/qeth.h77
-rw-r--r--drivers/s390/net/qeth_eddp.c3
-rw-r--r--drivers/s390/net/qeth_main.c316
-rw-r--r--drivers/s390/net/qeth_mpc.c4
-rw-r--r--drivers/s390/net/qeth_mpc.h15
-rw-r--r--drivers/s390/net/qeth_proc.c250
-rw-r--r--drivers/s390/net/qeth_sys.c10
-rw-r--r--drivers/s390/net/qeth_tso.h6
-rw-r--r--drivers/s390/scsi/zfcp_aux.c14
-rw-r--r--drivers/s390/scsi/zfcp_dbf.c4
-rw-r--r--drivers/s390/scsi/zfcp_erp.c94
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c110
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c2
-rw-r--r--drivers/sbus/char/aurora.c12
-rw-r--r--drivers/sbus/char/display7seg.c2
-rw-r--r--drivers/sbus/char/jsflash.c19
-rw-r--r--drivers/sbus/char/rtc.c22
-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/53c7xx.c6
-rw-r--r--drivers/scsi/53c7xx.h2
-rw-r--r--drivers/scsi/Kconfig31
-rw-r--r--drivers/scsi/Makefile1
-rw-r--r--drivers/scsi/NCR53C9x.c10
-rw-r--r--drivers/scsi/NCR53C9x.h6
-rw-r--r--drivers/scsi/NCR53c406a.c4
-rw-r--r--drivers/scsi/a2091.c4
-rw-r--r--drivers/scsi/a2091.h2
-rw-r--r--drivers/scsi/a3000.c4
-rw-r--r--drivers/scsi/a3000.h2
-rw-r--r--drivers/scsi/aacraid/aachba.c23
-rw-r--r--drivers/scsi/aacraid/commsup.c4
-rw-r--r--drivers/scsi/aacraid/linit.c2
-rw-r--r--drivers/scsi/advansys.c6
-rw-r--r--drivers/scsi/advansys.h2
-rw-r--r--drivers/scsi/aha152x.c4
-rw-r--r--drivers/scsi/aha1542.c4
-rw-r--r--drivers/scsi/aha1542.h2
-rw-r--r--drivers/scsi/aha1740.c2
-rw-r--r--drivers/scsi/ahci.c73
-rw-r--r--drivers/scsi/aic7xxx/aic79xx_osm.c39
-rw-r--r--drivers/scsi/aic7xxx/aic7xxx_osm.c41
-rw-r--r--drivers/scsi/aic7xxx_old.c18
-rw-r--r--drivers/scsi/amiga7xx.c8
-rw-r--r--drivers/scsi/amiga7xx.h2
-rw-r--r--drivers/scsi/arm/acornscsi.c6
-rw-r--r--drivers/scsi/arm/acornscsi.h2
-rw-r--r--drivers/scsi/arm/arxescsi.c8
-rw-r--r--drivers/scsi/arm/cumana_1.c2
-rw-r--r--drivers/scsi/arm/cumana_2.c8
-rw-r--r--drivers/scsi/arm/ecoscsi.c2
-rw-r--r--drivers/scsi/arm/eesox.c8
-rw-r--r--drivers/scsi/arm/fas216.c10
-rw-r--r--drivers/scsi/arm/fas216.h8
-rw-r--r--drivers/scsi/arm/oak.c2
-rw-r--r--drivers/scsi/arm/powertec.c6
-rw-r--r--drivers/scsi/arm/scsi.h8
-rw-r--r--drivers/scsi/ata_piix.c4
-rw-r--r--drivers/scsi/atari_NCR5380.c2
-rw-r--r--drivers/scsi/atari_scsi.c4
-rw-r--r--drivers/scsi/atari_scsi.h2
-rw-r--r--drivers/scsi/blz1230.c4
-rw-r--r--drivers/scsi/blz2060.c4
-rw-r--r--drivers/scsi/bvme6000.c4
-rw-r--r--drivers/scsi/bvme6000.h2
-rw-r--r--drivers/scsi/cyberstorm.c4
-rw-r--r--drivers/scsi/cyberstormII.c4
-rw-r--r--drivers/scsi/dec_esp.c2
-rw-r--r--drivers/scsi/dpt_i2o.c34
-rw-r--r--drivers/scsi/dpti.h2
-rw-r--r--drivers/scsi/dtc.c6
-rw-r--r--drivers/scsi/dtc.h2
-rw-r--r--drivers/scsi/fastlane.c4
-rw-r--r--drivers/scsi/fcal.c8
-rw-r--r--drivers/scsi/fcal.h4
-rw-r--r--drivers/scsi/fd_mcs.c4
-rw-r--r--drivers/scsi/g_NCR5380.c6
-rw-r--r--drivers/scsi/g_NCR5380.h2
-rw-r--r--drivers/scsi/gdth.c12
-rw-r--r--drivers/scsi/gdth.h4
-rw-r--r--drivers/scsi/gdth_proc.c10
-rw-r--r--drivers/scsi/gvp11.c4
-rw-r--r--drivers/scsi/gvp11.h2
-rw-r--r--drivers/scsi/ibmmca.c8
-rw-r--r--drivers/scsi/ibmmca.h2
-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/in2000.c4
-rw-r--r--drivers/scsi/in2000.h2
-rw-r--r--drivers/scsi/ipr.c904
-rw-r--r--drivers/scsi/ipr.h243
-rw-r--r--drivers/scsi/ips.c150
-rw-r--r--drivers/scsi/ips.h4
-rw-r--r--drivers/scsi/iscsi_tcp.c2
-rw-r--r--drivers/scsi/jazz_esp.c4
-rw-r--r--drivers/scsi/libata-core.c111
-rw-r--r--drivers/scsi/libata-scsi.c146
-rw-r--r--drivers/scsi/libata.h4
-rw-r--r--drivers/scsi/lpfc/lpfc_init.c1
-rw-r--r--drivers/scsi/mac_esp.c4
-rw-r--r--drivers/scsi/mac_scsi.c6
-rw-r--r--drivers/scsi/mca_53c9x.c4
-rw-r--r--drivers/scsi/megaraid.c63
-rw-r--r--drivers/scsi/megaraid.h10
-rw-r--r--drivers/scsi/megaraid/mega_common.h2
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c81
-rw-r--r--drivers/scsi/megaraid/megaraid_sas.c5
-rw-r--r--drivers/scsi/mvme147.c4
-rw-r--r--drivers/scsi/mvme147.h2
-rw-r--r--drivers/scsi/mvme16x.c4
-rw-r--r--drivers/scsi/mvme16x.h2
-rw-r--r--drivers/scsi/nsp32.c6
-rw-r--r--drivers/scsi/oktagon_esp.c4
-rw-r--r--drivers/scsi/pas16.c6
-rw-r--r--drivers/scsi/pas16.h2
-rw-r--r--drivers/scsi/pci2000.h2
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.c8
-rw-r--r--drivers/scsi/pcmcia/nsp_cs.h6
-rw-r--r--drivers/scsi/pcmcia/qlogic_stub.c4
-rw-r--r--drivers/scsi/pdc_adma.c2
-rw-r--r--drivers/scsi/pluto.c8
-rw-r--r--drivers/scsi/pluto.h4
-rw-r--r--drivers/scsi/psi240i.c4
-rw-r--r--drivers/scsi/qla1280.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h10
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c28
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c15
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c10
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h4
-rw-r--r--drivers/scsi/qlogicfas.c6
-rw-r--r--drivers/scsi/qlogicfc.c4
-rw-r--r--drivers/scsi/qlogicisp.c1934
-rw-r--r--drivers/scsi/qlogicisp_asm.c2034
-rw-r--r--drivers/scsi/raid_class.c96
-rw-r--r--drivers/scsi/sata_mv.c1001
-rw-r--r--drivers/scsi/sata_nv.c2
-rw-r--r--drivers/scsi/sata_promise.c16
-rw-r--r--drivers/scsi/sata_qstor.c13
-rw-r--r--drivers/scsi/sata_sil.c2
-rw-r--r--drivers/scsi/sata_sil24.c221
-rw-r--r--drivers/scsi/sata_sis.c2
-rw-r--r--drivers/scsi/sata_svw.c4
-rw-r--r--drivers/scsi/sata_sx4.c7
-rw-r--r--drivers/scsi/sata_uli.c2
-rw-r--r--drivers/scsi/sata_via.c2
-rw-r--r--drivers/scsi/sata_vsc.c4
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_debug.c2
-rw-r--r--drivers/scsi/scsi_error.c158
-rw-r--r--drivers/scsi/scsi_lib.c91
-rw-r--r--drivers/scsi/scsi_priv.h1
-rw-r--r--drivers/scsi/scsi_scan.c106
-rw-r--r--drivers/scsi/scsi_sysfs.c9
-rw-r--r--drivers/scsi/scsi_transport_fc.c59
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c2
-rw-r--r--drivers/scsi/scsi_transport_spi.c28
-rw-r--r--drivers/scsi/scsi_typedefs.h3
-rw-r--r--drivers/scsi/sd.c38
-rw-r--r--drivers/scsi/seagate.c4
-rw-r--r--drivers/scsi/seagate.h2
-rw-r--r--drivers/scsi/sg.c6
-rw-r--r--drivers/scsi/sgiwd93.c6
-rw-r--r--drivers/scsi/sr.c20
-rw-r--r--drivers/scsi/st.c22
-rw-r--r--drivers/scsi/sun3_NCR5380.c2
-rw-r--r--drivers/scsi/sun3_scsi.c6
-rw-r--r--drivers/scsi/sun3_scsi.h2
-rw-r--r--drivers/scsi/sun3_scsi_vme.c6
-rw-r--r--drivers/scsi/sun3x_esp.c4
-rw-r--r--drivers/scsi/sym53c416.c4
-rw-r--r--drivers/scsi/sym53c416.h2
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_glue.c5
-rw-r--r--drivers/scsi/sym53c8xx_2/sym_hipd.c4
-rw-r--r--drivers/scsi/t128.c6
-rw-r--r--drivers/scsi/t128.h2
-rw-r--r--drivers/scsi/u14-34f.c2
-rw-r--r--drivers/scsi/ultrastor.c8
-rw-r--r--drivers/scsi/ultrastor.h2
-rw-r--r--drivers/serial/68328serial.c7
-rw-r--r--drivers/serial/8250.c38
-rw-r--r--drivers/serial/8250_pci.c4
-rw-r--r--drivers/serial/8250_pnp.c2
-rw-r--r--drivers/serial/Kconfig12
-rw-r--r--drivers/serial/amba-pl011.c47
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_core.c2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm1.c2
-rw-r--r--drivers/serial/cpm_uart/cpm_uart_cpm2.c2
-rw-r--r--drivers/serial/dz.c48
-rw-r--r--drivers/serial/imx.c33
-rw-r--r--drivers/serial/mpc52xx_uart.c36
-rw-r--r--drivers/serial/mpsc.c65
-rw-r--r--drivers/serial/mux.c19
-rw-r--r--drivers/serial/pxa.c37
-rw-r--r--drivers/serial/s3c2410.c62
-rw-r--r--drivers/serial/sa1100.c37
-rw-r--r--drivers/serial/serial_core.c86
-rw-r--r--drivers/serial/serial_cs.c6
-rw-r--r--drivers/serial/vr41xx_siu.c27
-rw-r--r--drivers/tc/zs.c150
-rw-r--r--drivers/tc/zs.h13
-rw-r--r--drivers/usb/atm/Makefile4
-rw-r--r--drivers/usb/atm/cxacru.c3
-rw-r--r--drivers/usb/atm/usbatm.c4
-rw-r--r--drivers/usb/atm/usbatm.h5
-rw-r--r--drivers/usb/core/Makefile4
-rw-r--r--drivers/usb/core/buffer.c8
-rw-r--r--drivers/usb/core/config.c5
-rw-r--r--drivers/usb/core/devio.c6
-rw-r--r--drivers/usb/core/file.c6
-rw-r--r--drivers/usb/core/hcd-pci.c48
-rw-r--r--drivers/usb/core/hcd.c20
-rw-r--r--drivers/usb/core/hcd.h7
-rw-r--r--drivers/usb/core/hub.c6
-rw-r--r--drivers/usb/core/inode.c7
-rw-r--r--drivers/usb/core/message.c10
-rw-r--r--drivers/usb/core/notify.c6
-rw-r--r--drivers/usb/core/sysfs.c7
-rw-r--r--drivers/usb/core/urb.c6
-rw-r--r--drivers/usb/core/usb.c16
-rw-r--r--drivers/usb/gadget/dummy_hcd.c80
-rw-r--r--drivers/usb/gadget/goku_udc.c1
-rw-r--r--drivers/usb/gadget/lh7a40x_udc.c31
-rw-r--r--drivers/usb/gadget/net2280.c1
-rw-r--r--drivers/usb/gadget/omap_udc.c61
-rw-r--r--drivers/usb/gadget/pxa2xx_udc.c41
-rw-r--r--drivers/usb/host/ehci-hcd.c160
-rw-r--r--drivers/usb/host/ehci-hub.c7
-rw-r--r--drivers/usb/host/ehci-pci.c396
-rw-r--r--drivers/usb/host/ehci-q.c24
-rw-r--r--drivers/usb/host/ehci-sched.c18
-rw-r--r--drivers/usb/host/isp116x-hcd.c37
-rw-r--r--drivers/usb/host/ohci-au1xxx.c31
-rw-r--r--drivers/usb/host/ohci-hcd.c6
-rw-r--r--drivers/usb/host/ohci-hub.c24
-rw-r--r--drivers/usb/host/ohci-lh7a404.c31
-rw-r--r--drivers/usb/host/ohci-omap.c35
-rw-r--r--drivers/usb/host/ohci-pci.c60
-rw-r--r--drivers/usb/host/ohci-ppc-soc.c21
-rw-r--r--drivers/usb/host/ohci-pxa27x.c31
-rw-r--r--drivers/usb/host/ohci-s3c2410.c21
-rw-r--r--drivers/usb/host/sl811-hcd.c61
-rw-r--r--drivers/usb/host/uhci-hcd.c9
-rw-r--r--drivers/usb/image/microtek.c37
-rw-r--r--drivers/usb/image/microtek.h2
-rw-r--r--drivers/usb/input/Makefile4
-rw-r--r--drivers/usb/input/aiptek.c2
-rw-r--r--drivers/usb/input/hid-core.c16
-rw-r--r--drivers/usb/input/hid-input.c1
-rw-r--r--drivers/usb/input/itmtouch.c7
-rw-r--r--drivers/usb/input/kbtab.c2
-rw-r--r--drivers/usb/input/keyspan_remote.c5
-rw-r--r--drivers/usb/input/mtouchusb.c7
-rw-r--r--drivers/usb/input/pid.c2
-rw-r--r--drivers/usb/input/touchkitusb.c4
-rw-r--r--drivers/usb/input/wacom.c135
-rw-r--r--drivers/usb/media/sn9c102_core.c2
-rw-r--r--drivers/usb/misc/Makefile6
-rw-r--r--drivers/usb/misc/auerswald.c3
-rw-r--r--drivers/usb/misc/phidgetservo.c3
-rw-r--r--drivers/usb/misc/rio500.c2
-rw-r--r--drivers/usb/misc/usbled.c3
-rw-r--r--drivers/usb/misc/usbtest.c3
-rw-r--r--drivers/usb/misc/uss720.c2
-rw-r--r--drivers/usb/net/Makefile4
-rw-r--r--drivers/usb/net/asix.c3
-rw-r--r--drivers/usb/net/cdc_ether.c3
-rw-r--r--drivers/usb/net/cdc_subset.c3
-rw-r--r--drivers/usb/net/gl620a.c3
-rw-r--r--drivers/usb/net/kaweth.c13
-rw-r--r--drivers/usb/net/net1080.c3
-rw-r--r--drivers/usb/net/pegasus.c2
-rw-r--r--drivers/usb/net/plusb.c3
-rw-r--r--drivers/usb/net/rndis_host.c3
-rw-r--r--drivers/usb/net/usbnet.c3
-rw-r--r--drivers/usb/net/zaurus.c3
-rw-r--r--drivers/usb/serial/ChangeLog.history (renamed from drivers/usb/serial/ChangeLog.old)2
-rw-r--r--drivers/usb/serial/Kconfig18
-rw-r--r--drivers/usb/serial/Makefile2
-rw-r--r--drivers/usb/serial/anydata.c123
-rw-r--r--drivers/usb/serial/cp2101.c1
-rw-r--r--drivers/usb/serial/ftdi_sio.c2
-rw-r--r--drivers/usb/serial/ftdi_sio.h7
-rw-r--r--drivers/usb/serial/generic.c1
-rw-r--r--drivers/usb/serial/ipw.c1
-rw-r--r--drivers/usb/serial/nokia_dku2.c142
-rw-r--r--drivers/usb/serial/pl2303.c6
-rw-r--r--drivers/usb/serial/pl2303.h2
-rw-r--r--drivers/usb/storage/Kconfig2
-rw-r--r--drivers/usb/storage/scsiglue.c4
-rw-r--r--drivers/usb/storage/shuttle_usbat.c2
-rw-r--r--drivers/usb/storage/unusual_devs.h19
-rw-r--r--drivers/video/Kconfig21
-rw-r--r--drivers/video/acornfb.c13
-rw-r--r--drivers/video/arcfb.c24
-rw-r--r--drivers/video/backlight/corgi_bl.c27
-rw-r--r--drivers/video/bw2.c4
-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.c4
-rw-r--r--drivers/video/cg3.c4
-rw-r--r--drivers/video/cg6.c6
-rw-r--r--drivers/video/cirrusfb.c15
-rw-r--r--drivers/video/console/Kconfig27
-rw-r--r--drivers/video/console/Makefile1
-rw-r--r--drivers/video/console/fbcon.c57
-rw-r--r--drivers/video/console/fbcon.h3
-rw-r--r--drivers/video/console/fbcon_ccw.c16
-rw-r--r--drivers/video/console/fbcon_cw.c14
-rw-r--r--drivers/video/console/fbcon_rotate.h17
-rw-r--r--drivers/video/console/fbcon_ud.c30
-rw-r--r--drivers/video/console/font_rl.c4374
-rw-r--r--drivers/video/console/fonts.c4
-rw-r--r--drivers/video/console/vgacon.c1
-rw-r--r--drivers/video/cyber2000fb.c4
-rw-r--r--drivers/video/dnfb.c16
-rw-r--r--drivers/video/epson1355fb.c24
-rw-r--r--drivers/video/fbmem.c32
-rw-r--r--drivers/video/ffb.c4
-rw-r--r--drivers/video/gbefb.c25
-rw-r--r--drivers/video/imxfb.c45
-rw-r--r--drivers/video/intelfb/intelfb.h5
-rw-r--r--drivers/video/intelfb/intelfbdrv.c51
-rw-r--r--drivers/video/leo.c4
-rw-r--r--drivers/video/logo/Kconfig2
-rw-r--r--drivers/video/nvidia/nv_proto.h2
-rw-r--r--drivers/video/nvidia/nvidia.c2
-rw-r--r--drivers/video/offb.c41
-rw-r--r--drivers/video/p9100.c4
-rw-r--r--drivers/video/pxafb.c54
-rw-r--r--drivers/video/q40fb.c14
-rw-r--r--drivers/video/s1d13xxxfb.c49
-rw-r--r--drivers/video/s3c2410fb.c47
-rw-r--r--drivers/video/sa1100fb.c25
-rw-r--r--drivers/video/sbuslib.c110
-rw-r--r--drivers/video/sbuslib.h2
-rw-r--r--drivers/video/sgivwfb.c22
-rw-r--r--drivers/video/tcx.c6
-rw-r--r--drivers/video/vesafb.c16
-rw-r--r--drivers/video/vfb.c22
-rw-r--r--drivers/video/w100fb.c48
831 files changed, 23566 insertions, 26481 deletions
diff --git a/drivers/Makefile b/drivers/Makefile
index fac1e1603097..ea410b6b7644 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -5,7 +5,7 @@
5# Rewritten to use lists instead of if-statements. 5# Rewritten to use lists instead of if-statements.
6# 6#
7 7
8obj-$(CONFIG_PCI) += pci/ usb/ 8obj-$(CONFIG_PCI) += pci/
9obj-$(CONFIG_PARISC) += parisc/ 9obj-$(CONFIG_PARISC) += parisc/
10obj-$(CONFIG_RAPIDIO) += rapidio/ 10obj-$(CONFIG_RAPIDIO) += rapidio/
11obj-y += video/ 11obj-y += video/
@@ -49,6 +49,7 @@ obj-$(CONFIG_ATA_OVER_ETH) += block/aoe/
49obj-$(CONFIG_PARIDE) += block/paride/ 49obj-$(CONFIG_PARIDE) += block/paride/
50obj-$(CONFIG_TC) += tc/ 50obj-$(CONFIG_TC) += tc/
51obj-$(CONFIG_USB) += usb/ 51obj-$(CONFIG_USB) += usb/
52obj-$(CONFIG_PCI) += usb/
52obj-$(CONFIG_USB_GADGET) += usb/gadget/ 53obj-$(CONFIG_USB_GADGET) += usb/gadget/
53obj-$(CONFIG_GAMEPORT) += input/gameport/ 54obj-$(CONFIG_GAMEPORT) += input/gameport/
54obj-$(CONFIG_INPUT) += input/ 55obj-$(CONFIG_INPUT) += input/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index fe1e8126fbae..fce21c257523 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -197,7 +197,6 @@ config ACPI_ASUS
197config ACPI_IBM 197config ACPI_IBM
198 tristate "IBM ThinkPad Laptop Extras" 198 tristate "IBM ThinkPad Laptop Extras"
199 depends on X86 199 depends on X86
200 default y
201 ---help--- 200 ---help---
202 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds 201 This is a Linux ACPI driver for the IBM ThinkPad laptops. It adds
203 support for Fn-Fx key combinations, Bluetooth control, video 202 support for Fn-Fx key combinations, Bluetooth control, video
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index a18243488c66..5984b4f6715a 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -16,7 +16,7 @@ EXTRA_CFLAGS += $(ACPI_CFLAGS)
16# ACPI Boot-Time Table Parsing 16# ACPI Boot-Time Table Parsing
17# 17#
18obj-y += tables.o 18obj-y += tables.o
19obj-y += blacklist.o 19obj-$(CONFIG_X86) += blacklist.o
20 20
21# 21#
22# ACPI Core Subsystem (Interpreter) 22# ACPI Core Subsystem (Interpreter)
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index 6a4da417c16b..606f8733a776 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -28,6 +28,7 @@
28#include <linux/list.h> 28#include <linux/list.h>
29#include <linux/sched.h> 29#include <linux/sched.h>
30#include <linux/pm.h> 30#include <linux/pm.h>
31#include <linux/pm_legacy.h>
31#include <linux/device.h> 32#include <linux/device.h>
32#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
33#ifdef CONFIG_X86 34#ifdef CONFIG_X86
@@ -754,7 +755,7 @@ static int __init acpi_init(void)
754 result = acpi_bus_init(); 755 result = acpi_bus_init();
755 756
756 if (!result) { 757 if (!result) {
757#ifdef CONFIG_PM 758#ifdef CONFIG_PM_LEGACY
758 if (!PM_IS_ACTIVE()) 759 if (!PM_IS_ACTIVE())
759 pm_active = 1; 760 pm_active = 1;
760 else { 761 else {
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 3937adf4e5e5..aa993715d644 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -203,6 +203,7 @@ acpi_handle acpi_get_pci_rootbridge_handle(unsigned int seg, unsigned int bus)
203 acpi_get_devices(PCI_ROOT_HID_STRING, find_pci_rootbridge, &find, NULL); 203 acpi_get_devices(PCI_ROOT_HID_STRING, find_pci_rootbridge, &find, NULL);
204 return find.handle; 204 return find.handle;
205} 205}
206EXPORT_SYMBOL_GPL(acpi_get_pci_rootbridge_handle);
206 207
207/* Get device's handler per its address under its parent */ 208/* Get device's handler per its address under its parent */
208struct acpi_find_child { 209struct acpi_find_child {
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index 82292b77e5c6..78927c0f1551 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 421792562642..0c561c571f29 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -543,6 +543,8 @@ static int acpi_processor_get_info(struct acpi_processor *pr)
543 return_VALUE(0); 543 return_VALUE(0);
544} 544}
545 545
546static void *processor_device_array[NR_CPUS];
547
546static int acpi_processor_start(struct acpi_device *device) 548static int acpi_processor_start(struct acpi_device *device)
547{ 549{
548 int result = 0; 550 int result = 0;
@@ -561,6 +563,19 @@ static int acpi_processor_start(struct acpi_device *device)
561 563
562 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0)); 564 BUG_ON((pr->id >= NR_CPUS) || (pr->id < 0));
563 565
566 /*
567 * Buggy BIOS check
568 * ACPI id of processors can be reported wrongly by the BIOS.
569 * Don't trust it blindly
570 */
571 if (processor_device_array[pr->id] != NULL &&
572 processor_device_array[pr->id] != (void *)device) {
573 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "BIOS reporting wrong ACPI id"
574 "for the processor\n"));
575 return_VALUE(-ENODEV);
576 }
577 processor_device_array[pr->id] = (void *)device;
578
564 processors[pr->id] = pr; 579 processors[pr->id] = pr;
565 580
566 result = acpi_processor_add_fs(device); 581 result = acpi_processor_add_fs(device);
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 573b6a97bb1f..807b0df308f1 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -169,15 +169,11 @@ acpi_processor_power_activate(struct acpi_processor *pr,
169 169
170static void acpi_safe_halt(void) 170static void acpi_safe_halt(void)
171{ 171{
172 int polling = test_thread_flag(TIF_POLLING_NRFLAG); 172 clear_thread_flag(TIF_POLLING_NRFLAG);
173 if (polling) { 173 smp_mb__after_clear_bit();
174 clear_thread_flag(TIF_POLLING_NRFLAG);
175 smp_mb__after_clear_bit();
176 }
177 if (!need_resched()) 174 if (!need_resched())
178 safe_halt(); 175 safe_halt();
179 if (polling) 176 set_thread_flag(TIF_POLLING_NRFLAG);
180 set_thread_flag(TIF_POLLING_NRFLAG);
181} 177}
182 178
183static atomic_t c3_cpu_count; 179static atomic_t c3_cpu_count;
@@ -278,6 +274,17 @@ static void acpi_processor_idle(void)
278 } 274 }
279 } 275 }
280 276
277#ifdef CONFIG_HOTPLUG_CPU
278 /*
279 * Check for P_LVL2_UP flag before entering C2 and above on
280 * an SMP system. We do it here instead of doing it at _CST/P_LVL
281 * detection phase, to work cleanly with logical CPU hotplug.
282 */
283 if ((cx->type != ACPI_STATE_C1) && (num_online_cpus() > 1) &&
284 !pr->flags.has_cst && !acpi_fadt.plvl2_up)
285 cx = &pr->power.states[ACPI_STATE_C1];
286#endif
287
281 cx->usage++; 288 cx->usage++;
282 289
283 /* 290 /*
@@ -285,6 +292,16 @@ static void acpi_processor_idle(void)
285 * ------ 292 * ------
286 * Invoke the current Cx state to put the processor to sleep. 293 * Invoke the current Cx state to put the processor to sleep.
287 */ 294 */
295 if (cx->type == ACPI_STATE_C2 || cx->type == ACPI_STATE_C3) {
296 clear_thread_flag(TIF_POLLING_NRFLAG);
297 smp_mb__after_clear_bit();
298 if (need_resched()) {
299 set_thread_flag(TIF_POLLING_NRFLAG);
300 local_irq_enable();
301 return;
302 }
303 }
304
288 switch (cx->type) { 305 switch (cx->type) {
289 306
290 case ACPI_STATE_C1: 307 case ACPI_STATE_C1:
@@ -317,6 +334,7 @@ static void acpi_processor_idle(void)
317 t2 = inl(acpi_fadt.xpm_tmr_blk.address); 334 t2 = inl(acpi_fadt.xpm_tmr_blk.address);
318 /* Re-enable interrupts */ 335 /* Re-enable interrupts */
319 local_irq_enable(); 336 local_irq_enable();
337 set_thread_flag(TIF_POLLING_NRFLAG);
320 /* Compute time (ticks) that we were actually asleep */ 338 /* Compute time (ticks) that we were actually asleep */
321 sleep_ticks = 339 sleep_ticks =
322 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD; 340 ticks_elapsed(t1, t2) - cx->latency_ticks - C2_OVERHEAD;
@@ -356,6 +374,7 @@ static void acpi_processor_idle(void)
356 374
357 /* Re-enable interrupts */ 375 /* Re-enable interrupts */
358 local_irq_enable(); 376 local_irq_enable();
377 set_thread_flag(TIF_POLLING_NRFLAG);
359 /* Compute time (ticks) that we were actually asleep */ 378 /* Compute time (ticks) that we were actually asleep */
360 sleep_ticks = 379 sleep_ticks =
361 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD; 380 ticks_elapsed(t1, t2) - cx->latency_ticks - C3_OVERHEAD;
@@ -368,6 +387,15 @@ static void acpi_processor_idle(void)
368 387
369 next_state = pr->power.state; 388 next_state = pr->power.state;
370 389
390#ifdef CONFIG_HOTPLUG_CPU
391 /* Don't do promotion/demotion */
392 if ((cx->type == ACPI_STATE_C1) && (num_online_cpus() > 1) &&
393 !pr->flags.has_cst && !acpi_fadt.plvl2_up) {
394 next_state = cx;
395 goto end;
396 }
397#endif
398
371 /* 399 /*
372 * Promotion? 400 * Promotion?
373 * ---------- 401 * ----------
@@ -514,8 +542,6 @@ static int acpi_processor_set_power_policy(struct acpi_processor *pr)
514 542
515static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr) 543static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
516{ 544{
517 int i;
518
519 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt"); 545 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_fadt");
520 546
521 if (!pr) 547 if (!pr)
@@ -524,8 +550,7 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
524 if (!pr->pblk) 550 if (!pr->pblk)
525 return_VALUE(-ENODEV); 551 return_VALUE(-ENODEV);
526 552
527 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 553 memset(pr->power.states, 0, sizeof(pr->power.states));
528 memset(pr->power.states, 0, sizeof(struct acpi_processor_cx));
529 554
530 /* if info is obtained from pblk/fadt, type equals state */ 555 /* if info is obtained from pblk/fadt, type equals state */
531 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 556 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
@@ -537,6 +562,15 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
537 pr->power.states[ACPI_STATE_C0].valid = 1; 562 pr->power.states[ACPI_STATE_C0].valid = 1;
538 pr->power.states[ACPI_STATE_C1].valid = 1; 563 pr->power.states[ACPI_STATE_C1].valid = 1;
539 564
565#ifndef CONFIG_HOTPLUG_CPU
566 /*
567 * Check for P_LVL2_UP flag before entering C2 and above on
568 * an SMP system.
569 */
570 if ((num_online_cpus() > 1) && !acpi_fadt.plvl2_up)
571 return_VALUE(-ENODEV);
572#endif
573
540 /* determine C2 and C3 address from pblk */ 574 /* determine C2 and C3 address from pblk */
541 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4; 575 pr->power.states[ACPI_STATE_C2].address = pr->pblk + 4;
542 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5; 576 pr->power.states[ACPI_STATE_C3].address = pr->pblk + 5;
@@ -555,13 +589,9 @@ static int acpi_processor_get_power_info_fadt(struct acpi_processor *pr)
555 589
556static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr) 590static int acpi_processor_get_power_info_default_c1(struct acpi_processor *pr)
557{ 591{
558 int i;
559
560 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1"); 592 ACPI_FUNCTION_TRACE("acpi_processor_get_power_info_default_c1");
561 593
562 for (i = 0; i < ACPI_PROCESSOR_MAX_POWER; i++) 594 memset(pr->power.states, 0, sizeof(pr->power.states));
563 memset(&(pr->power.states[i]), 0,
564 sizeof(struct acpi_processor_cx));
565 595
566 /* if info is obtained from pblk/fadt, type equals state */ 596 /* if info is obtained from pblk/fadt, type equals state */
567 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1; 597 pr->power.states[ACPI_STATE_C1].type = ACPI_STATE_C1;
@@ -697,7 +727,7 @@ static int acpi_processor_get_power_info_cst(struct acpi_processor *pr)
697 727
698 /* Validate number of power states discovered */ 728 /* Validate number of power states discovered */
699 if (pr->power.count < 2) 729 if (pr->power.count < 2)
700 status = -ENODEV; 730 status = -EFAULT;
701 731
702 end: 732 end:
703 acpi_os_free(buffer.pointer); 733 acpi_os_free(buffer.pointer);
@@ -848,11 +878,11 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
848 * this function */ 878 * this function */
849 879
850 result = acpi_processor_get_power_info_cst(pr); 880 result = acpi_processor_get_power_info_cst(pr);
851 if ((result) || (acpi_processor_power_verify(pr) < 2)) { 881 if (result == -ENODEV)
852 result = acpi_processor_get_power_info_fadt(pr); 882 result = acpi_processor_get_power_info_fadt(pr);
853 if ((result) || (acpi_processor_power_verify(pr) < 2)) 883
854 result = acpi_processor_get_power_info_default_c1(pr); 884 if ((result) || (acpi_processor_power_verify(pr) < 2))
855 } 885 result = acpi_processor_get_power_info_default_c1(pr);
856 886
857 /* 887 /*
858 * Set Default Policy 888 * Set Default Policy
@@ -873,7 +903,8 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
873 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) { 903 for (i = 1; i < ACPI_PROCESSOR_MAX_POWER; i++) {
874 if (pr->power.states[i].valid) { 904 if (pr->power.states[i].valid) {
875 pr->power.count = i; 905 pr->power.count = i;
876 pr->flags.power = 1; 906 if (pr->power.states[i].type >= ACPI_STATE_C2)
907 pr->flags.power = 1;
877 } 908 }
878 } 909 }
879 910
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 37528c3b64b0..dc9817cfb882 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -101,11 +101,9 @@ static unsigned int acpi_thermal_cpufreq_is_init = 0;
101static int cpu_has_cpufreq(unsigned int cpu) 101static 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) 104 if (!acpi_thermal_cpufreq_is_init || cpufreq_get_policy(&policy, cpu))
105 return -ENODEV; 105 return 0;
106 if (!cpufreq_get_policy(&policy, cpu)) 106 return 1;
107 return -ENODEV;
108 return 0;
109} 107}
110 108
111static int acpi_thermal_cpufreq_increase(unsigned int cpu) 109static int acpi_thermal_cpufreq_increase(unsigned int cpu)
@@ -127,13 +125,13 @@ static int acpi_thermal_cpufreq_decrease(unsigned int cpu)
127 if (!cpu_has_cpufreq(cpu)) 125 if (!cpu_has_cpufreq(cpu))
128 return -ENODEV; 126 return -ENODEV;
129 127
130 if (cpufreq_thermal_reduction_pctg[cpu] >= 20) { 128 if (cpufreq_thermal_reduction_pctg[cpu] > 20)
131 cpufreq_thermal_reduction_pctg[cpu] -= 20; 129 cpufreq_thermal_reduction_pctg[cpu] -= 20;
132 cpufreq_update_policy(cpu); 130 else
133 return 0; 131 cpufreq_thermal_reduction_pctg[cpu] = 0;
134 } 132 cpufreq_update_policy(cpu);
135 133 /* We reached max freq again and can leave passive mode */
136 return -ERANGE; 134 return !cpufreq_thermal_reduction_pctg[cpu];
137} 135}
138 136
139static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb, 137static int acpi_thermal_cpufreq_notifier(struct notifier_block *nb,
@@ -200,7 +198,7 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
200 int result = 0; 198 int result = 0;
201 struct acpi_processor *pr = NULL; 199 struct acpi_processor *pr = NULL;
202 struct acpi_device *device = NULL; 200 struct acpi_device *device = NULL;
203 int tx = 0; 201 int tx = 0, max_tx_px = 0;
204 202
205 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit"); 203 ACPI_FUNCTION_TRACE("acpi_processor_set_thermal_limit");
206 204
@@ -259,19 +257,27 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
259 /* if going down: T-states first, P-states later */ 257 /* if going down: T-states first, P-states later */
260 258
261 if (pr->flags.throttling) { 259 if (pr->flags.throttling) {
262 if (tx == 0) 260 if (tx == 0) {
261 max_tx_px = 1;
263 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 262 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
264 "At minimum throttling state\n")); 263 "At minimum throttling state\n"));
265 else { 264 } else {
266 tx--; 265 tx--;
267 goto end; 266 goto end;
268 } 267 }
269 } 268 }
270 269
271 result = acpi_thermal_cpufreq_decrease(pr->id); 270 result = acpi_thermal_cpufreq_decrease(pr->id);
272 if (result == -ERANGE) 271 if (result) {
272 /*
273 * We only could get -ERANGE, 1 or 0.
274 * In the first two cases we reached max freq again.
275 */
273 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 276 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
274 "At minimum performance state\n")); 277 "At minimum performance state\n"));
278 max_tx_px = 1;
279 } else
280 max_tx_px = 0;
275 281
276 break; 282 break;
277 } 283 }
@@ -290,8 +296,10 @@ int acpi_processor_set_thermal_limit(acpi_handle handle, int type)
290 pr->limit.thermal.px, pr->limit.thermal.tx)); 296 pr->limit.thermal.px, pr->limit.thermal.tx));
291 } else 297 } else
292 result = 0; 298 result = 0;
293 299 if (max_tx_px)
294 return_VALUE(result); 300 return_VALUE(1);
301 else
302 return_VALUE(result);
295} 303}
296 304
297int acpi_processor_get_limit_info(struct acpi_processor *pr) 305int acpi_processor_get_limit_info(struct acpi_processor *pr)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 23e2c6968a11..31218e1d2a18 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1110,7 +1110,7 @@ acpi_add_single_object(struct acpi_device **child,
1110 * 1110 *
1111 * TBD: Assumes LDM provides driver hot-plug capability. 1111 * TBD: Assumes LDM provides driver hot-plug capability.
1112 */ 1112 */
1113 result = acpi_bus_find_driver(device); 1113 acpi_bus_find_driver(device);
1114 1114
1115 end: 1115 end:
1116 if (!result) 1116 if (!result)
diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index a24847c08f7f..19f3ea48475e 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -72,7 +72,7 @@
72#define _COMPONENT ACPI_THERMAL_COMPONENT 72#define _COMPONENT ACPI_THERMAL_COMPONENT
73ACPI_MODULE_NAME("acpi_thermal") 73ACPI_MODULE_NAME("acpi_thermal")
74 74
75 MODULE_AUTHOR("Paul Diefenbaugh"); 75MODULE_AUTHOR("Paul Diefenbaugh");
76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME); 76MODULE_DESCRIPTION(ACPI_THERMAL_DRIVER_NAME);
77MODULE_LICENSE("GPL"); 77MODULE_LICENSE("GPL");
78 78
@@ -517,9 +517,9 @@ static int acpi_thermal_hot(struct acpi_thermal *tz)
517 return_VALUE(0); 517 return_VALUE(0);
518} 518}
519 519
520static int acpi_thermal_passive(struct acpi_thermal *tz) 520static void acpi_thermal_passive(struct acpi_thermal *tz)
521{ 521{
522 int result = 0; 522 int result = 1;
523 struct acpi_thermal_passive *passive = NULL; 523 struct acpi_thermal_passive *passive = NULL;
524 int trend = 0; 524 int trend = 0;
525 int i = 0; 525 int i = 0;
@@ -527,7 +527,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
527 ACPI_FUNCTION_TRACE("acpi_thermal_passive"); 527 ACPI_FUNCTION_TRACE("acpi_thermal_passive");
528 528
529 if (!tz || !tz->trips.passive.flags.valid) 529 if (!tz || !tz->trips.passive.flags.valid)
530 return_VALUE(-EINVAL); 530 return;
531 531
532 passive = &(tz->trips.passive); 532 passive = &(tz->trips.passive);
533 533
@@ -547,7 +547,7 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
547 trend, passive->tc1, tz->temperature, 547 trend, passive->tc1, tz->temperature,
548 tz->last_temperature, passive->tc2, 548 tz->last_temperature, passive->tc2,
549 tz->temperature, passive->temperature)); 549 tz->temperature, passive->temperature));
550 tz->trips.passive.flags.enabled = 1; 550 passive->flags.enabled = 1;
551 /* Heating up? */ 551 /* Heating up? */
552 if (trend > 0) 552 if (trend > 0)
553 for (i = 0; i < passive->devices.count; i++) 553 for (i = 0; i < passive->devices.count; i++)
@@ -556,12 +556,32 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
556 handles[i], 556 handles[i],
557 ACPI_PROCESSOR_LIMIT_INCREMENT); 557 ACPI_PROCESSOR_LIMIT_INCREMENT);
558 /* Cooling off? */ 558 /* Cooling off? */
559 else if (trend < 0) 559 else if (trend < 0) {
560 for (i = 0; i < passive->devices.count; i++) 560 for (i = 0; i < passive->devices.count; i++)
561 acpi_processor_set_thermal_limit(passive-> 561 /*
562 devices. 562 * assume that we are on highest
563 handles[i], 563 * freq/lowest thrott and can leave
564 ACPI_PROCESSOR_LIMIT_DECREMENT); 564 * passive mode, even in error case
565 */
566 if (!acpi_processor_set_thermal_limit
567 (passive->devices.handles[i],
568 ACPI_PROCESSOR_LIMIT_DECREMENT))
569 result = 0;
570 /*
571 * Leave cooling mode, even if the temp might
572 * higher than trip point This is because some
573 * machines might have long thermal polling
574 * frequencies (tsp) defined. We will fall back
575 * into passive mode in next cycle (probably quicker)
576 */
577 if (result) {
578 passive->flags.enabled = 0;
579 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
580 "Disabling passive cooling, still above threshold,"
581 " but we are cooling down\n"));
582 }
583 }
584 return;
565 } 585 }
566 586
567 /* 587 /*
@@ -571,23 +591,21 @@ static int acpi_thermal_passive(struct acpi_thermal *tz)
571 * and avoid thrashing around the passive trip point. Note that we 591 * and avoid thrashing around the passive trip point. Note that we
572 * assume symmetry. 592 * assume symmetry.
573 */ 593 */
574 else if (tz->trips.passive.flags.enabled) { 594 if (!passive->flags.enabled)
575 for (i = 0; i < passive->devices.count; i++) 595 return;
576 result = 596 for (i = 0; i < passive->devices.count; i++)
577 acpi_processor_set_thermal_limit(passive->devices. 597 if (!acpi_processor_set_thermal_limit
578 handles[i], 598 (passive->devices.handles[i],
579 ACPI_PROCESSOR_LIMIT_DECREMENT); 599 ACPI_PROCESSOR_LIMIT_DECREMENT))
580 if (result == 1) { 600 result = 0;
581 tz->trips.passive.flags.enabled = 0; 601 if (result) {
582 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 602 passive->flags.enabled = 0;
583 "Disabling passive cooling (zone is cool)\n")); 603 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
584 } 604 "Disabling passive cooling (zone is cool)\n"));
585 } 605 }
586
587 return_VALUE(0);
588} 606}
589 607
590static int acpi_thermal_active(struct acpi_thermal *tz) 608static void acpi_thermal_active(struct acpi_thermal *tz)
591{ 609{
592 int result = 0; 610 int result = 0;
593 struct acpi_thermal_active *active = NULL; 611 struct acpi_thermal_active *active = NULL;
@@ -598,74 +616,66 @@ static int acpi_thermal_active(struct acpi_thermal *tz)
598 ACPI_FUNCTION_TRACE("acpi_thermal_active"); 616 ACPI_FUNCTION_TRACE("acpi_thermal_active");
599 617
600 if (!tz) 618 if (!tz)
601 return_VALUE(-EINVAL); 619 return;
602 620
603 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) { 621 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
604
605 active = &(tz->trips.active[i]); 622 active = &(tz->trips.active[i]);
606 if (!active || !active->flags.valid) 623 if (!active || !active->flags.valid)
607 break; 624 break;
608
609 /*
610 * Above Threshold?
611 * ----------------
612 * If not already enabled, turn ON all cooling devices
613 * associated with this active threshold.
614 */
615 if (tz->temperature >= active->temperature) { 625 if (tz->temperature >= active->temperature) {
626 /*
627 * Above Threshold?
628 * ----------------
629 * If not already enabled, turn ON all cooling devices
630 * associated with this active threshold.
631 */
616 if (active->temperature > maxtemp) 632 if (active->temperature > maxtemp)
617 tz->state.active_index = i, maxtemp = 633 tz->state.active_index = i;
618 active->temperature; 634 maxtemp = active->temperature;
619 if (!active->flags.enabled) { 635 if (active->flags.enabled)
620 for (j = 0; j < active->devices.count; j++) { 636 continue;
621 result =
622 acpi_bus_set_power(active->devices.
623 handles[j],
624 ACPI_STATE_D0);
625 if (result) {
626 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
627 "Unable to turn cooling device [%p] 'on'\n",
628 active->
629 devices.
630 handles[j]));
631 continue;
632 }
633 active->flags.enabled = 1;
634 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
635 "Cooling device [%p] now 'on'\n",
636 active->devices.
637 handles[j]));
638 }
639 }
640 }
641 /*
642 * Below Threshold?
643 * ----------------
644 * Turn OFF all cooling devices associated with this
645 * threshold.
646 */
647 else if (active->flags.enabled) {
648 for (j = 0; j < active->devices.count; j++) { 637 for (j = 0; j < active->devices.count; j++) {
649 result = 638 result =
650 acpi_bus_set_power(active->devices. 639 acpi_bus_set_power(active->devices.
651 handles[j], 640 handles[j],
652 ACPI_STATE_D3); 641 ACPI_STATE_D0);
653 if (result) { 642 if (result) {
654 ACPI_DEBUG_PRINT((ACPI_DB_WARN, 643 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
655 "Unable to turn cooling device [%p] 'off'\n", 644 "Unable to turn cooling device [%p] 'on'\n",
656 active->devices. 645 active->devices.
657 handles[j])); 646 handles[j]));
658 continue; 647 continue;
659 } 648 }
660 active->flags.enabled = 0; 649 active->flags.enabled = 1;
661 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 650 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
662 "Cooling device [%p] now 'off'\n", 651 "Cooling device [%p] now 'on'\n",
663 active->devices.handles[j])); 652 active->devices.handles[j]));
664 } 653 }
654 continue;
655 }
656 if (!active->flags.enabled)
657 continue;
658 /*
659 * Below Threshold?
660 * ----------------
661 * Turn OFF all cooling devices associated with this
662 * threshold.
663 */
664 for (j = 0; j < active->devices.count; j++) {
665 result = acpi_bus_set_power(active->devices.handles[j],
666 ACPI_STATE_D3);
667 if (result) {
668 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
669 "Unable to turn cooling device [%p] 'off'\n",
670 active->devices.handles[j]));
671 continue;
672 }
673 active->flags.enabled = 0;
674 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
675 "Cooling device [%p] now 'off'\n",
676 active->devices.handles[j]));
665 } 677 }
666 } 678 }
667
668 return_VALUE(0);
669} 679}
670 680
671static void acpi_thermal_check(void *context); 681static void acpi_thermal_check(void *context);
@@ -744,15 +754,12 @@ static void acpi_thermal_check(void *data)
744 * Again, separated from the above two to allow independent policy 754 * Again, separated from the above two to allow independent policy
745 * decisions. 755 * decisions.
746 */ 756 */
747 if (tz->trips.critical.flags.enabled) 757 tz->state.critical = tz->trips.critical.flags.enabled;
748 tz->state.critical = 1; 758 tz->state.hot = tz->trips.hot.flags.enabled;
749 if (tz->trips.hot.flags.enabled) 759 tz->state.passive = tz->trips.passive.flags.enabled;
750 tz->state.hot = 1; 760 tz->state.active = 0;
751 if (tz->trips.passive.flags.enabled)
752 tz->state.passive = 1;
753 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) 761 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++)
754 if (tz->trips.active[i].flags.enabled) 762 tz->state.active |= tz->trips.active[i].flags.enabled;
755 tz->state.active = 1;
756 763
757 /* 764 /*
758 * Calculate Sleep Time 765 * Calculate Sleep Time
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 0c5abc536c7a..2ce872d75890 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -84,14 +84,14 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
84 84
85 /* Find a free owner ID */ 85 /* Find a free owner ID */
86 86
87 for (i = 0; i < 32; i++) { 87 for (i = 0; i < 64; i++) {
88 if (!(acpi_gbl_owner_id_mask & (1 << i))) { 88 if (!(acpi_gbl_owner_id_mask & (1ULL << i))) {
89 ACPI_DEBUG_PRINT((ACPI_DB_VALUES, 89 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
90 "Current owner_id mask: %8.8X New ID: %2.2X\n", 90 "Current owner_id mask: %16.16LX New ID: %2.2X\n",
91 acpi_gbl_owner_id_mask, 91 acpi_gbl_owner_id_mask,
92 (unsigned int)(i + 1))); 92 (unsigned int)(i + 1)));
93 93
94 acpi_gbl_owner_id_mask |= (1 << i); 94 acpi_gbl_owner_id_mask |= (1ULL << i);
95 *owner_id = (acpi_owner_id) (i + 1); 95 *owner_id = (acpi_owner_id) (i + 1);
96 goto exit; 96 goto exit;
97 } 97 }
@@ -106,7 +106,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
106 */ 106 */
107 *owner_id = 0; 107 *owner_id = 0;
108 status = AE_OWNER_ID_LIMIT; 108 status = AE_OWNER_ID_LIMIT;
109 ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); 109 ACPI_REPORT_ERROR(("Could not allocate new owner_id (64 max), AE_OWNER_ID_LIMIT\n"));
110 110
111 exit: 111 exit:
112 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 112 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
@@ -123,7 +123,7 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
123 * control method or unloading a table. Either way, we would 123 * control method or unloading a table. Either way, we would
124 * ignore any error anyway. 124 * ignore any error anyway.
125 * 125 *
126 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32 126 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 64
127 * 127 *
128 ******************************************************************************/ 128 ******************************************************************************/
129 129
@@ -140,7 +140,7 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
140 140
141 /* Zero is not a valid owner_iD */ 141 /* Zero is not a valid owner_iD */
142 142
143 if ((owner_id == 0) || (owner_id > 32)) { 143 if ((owner_id == 0) || (owner_id > 64)) {
144 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id)); 144 ACPI_REPORT_ERROR(("Invalid owner_id: %2.2X\n", owner_id));
145 return_VOID; 145 return_VOID;
146 } 146 }
@@ -158,8 +158,8 @@ void acpi_ut_release_owner_id(acpi_owner_id * owner_id_ptr)
158 158
159 /* Free the owner ID only if it is valid */ 159 /* Free the owner ID only if it is valid */
160 160
161 if (acpi_gbl_owner_id_mask & (1 << owner_id)) { 161 if (acpi_gbl_owner_id_mask & (1ULL << owner_id)) {
162 acpi_gbl_owner_id_mask ^= (1 << owner_id); 162 acpi_gbl_owner_id_mask ^= (1ULL << owner_id);
163 } 163 }
164 164
165 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES); 165 (void)acpi_ut_release_mutex(ACPI_MTX_CACHES);
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index f051b151580d..d10668f14699 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -812,7 +812,7 @@ acpi_video_device_write_brightness(struct file *file,
812 812
813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness"); 813 ACPI_FUNCTION_TRACE("acpi_video_device_write_brightness");
814 814
815 if (!dev || count + 1 > sizeof str) 815 if (!dev || !dev->brightness || count + 1 > sizeof str)
816 return_VALUE(-EINVAL); 816 return_VALUE(-EINVAL);
817 817
818 if (copy_from_user(str, buffer, count)) 818 if (copy_from_user(str, buffer, count))
diff --git a/drivers/atm/Kconfig b/drivers/atm/Kconfig
index 489de81ea609..01a9f1cb7743 100644
--- a/drivers/atm/Kconfig
+++ b/drivers/atm/Kconfig
@@ -5,6 +5,13 @@
5menu "ATM drivers" 5menu "ATM drivers"
6 depends on NETDEVICES && ATM 6 depends on NETDEVICES && ATM
7 7
8config ATM_DUMMY
9 tristate "Dummy ATM driver"
10 depends on ATM
11 help
12 Dummy ATM driver. Useful for proxy signalling, testing,
13 and development. If unsure, say N.
14
8config ATM_TCP 15config ATM_TCP
9 tristate "ATM over TCP" 16 tristate "ATM over TCP"
10 depends on INET && ATM 17 depends on INET && ATM
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile
index 5b77188527a9..b5077ce8cb40 100644
--- a/drivers/atm/Makefile
+++ b/drivers/atm/Makefile
@@ -31,6 +31,7 @@ ifeq ($(CONFIG_ATM_IDT77252_USE_SUNI),y)
31 obj-$(CONFIG_ATM_IDT77252) += suni.o 31 obj-$(CONFIG_ATM_IDT77252) += suni.o
32endif 32endif
33 33
34obj-$(CONFIG_ATM_DUMMY) += adummy.o
34obj-$(CONFIG_ATM_TCP) += atmtcp.o 35obj-$(CONFIG_ATM_TCP) += atmtcp.o
35obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o 36obj-$(CONFIG_ATM_FIRESTREAM) += firestream.o
36obj-$(CONFIG_ATM_LANAI) += lanai.o 37obj-$(CONFIG_ATM_LANAI) += lanai.o
diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
new file mode 100644
index 000000000000..d1387cfe2d30
--- /dev/null
+++ b/drivers/atm/adummy.c
@@ -0,0 +1,168 @@
1/*
2 * adummy.c: a dummy ATM driver
3 */
4
5#include <linux/config.h>
6#include <linux/module.h>
7#include <linux/version.h>
8#include <linux/kernel.h>
9#include <linux/skbuff.h>
10#include <linux/pci.h>
11#include <linux/errno.h>
12#include <linux/types.h>
13#include <linux/string.h>
14#include <linux/delay.h>
15#include <linux/init.h>
16#include <linux/mm.h>
17#include <linux/sched.h>
18#include <linux/timer.h>
19#include <linux/interrupt.h>
20#include <asm/io.h>
21#include <asm/byteorder.h>
22#include <asm/uaccess.h>
23
24#include <linux/atmdev.h>
25#include <linux/atm.h>
26#include <linux/sonet.h>
27
28/* version definition */
29
30#define DRV_VERSION "1.0"
31
32#define DEV_LABEL "adummy"
33
34#define ADUMMY_DEV(dev) ((struct adummy_dev *) (dev)->dev_data)
35
36struct adummy_dev {
37 struct atm_dev *atm_dev;
38
39 struct list_head entry;
40};
41
42/* globals */
43
44static LIST_HEAD(adummy_devs);
45
46static int __init
47adummy_start(struct atm_dev *dev)
48{
49 dev->ci_range.vpi_bits = 4;
50 dev->ci_range.vci_bits = 12;
51
52 return 0;
53}
54
55static int
56adummy_open(struct atm_vcc *vcc)
57{
58 short vpi = vcc->vpi;
59 int vci = vcc->vci;
60
61 if (vci == ATM_VCI_UNSPEC || vpi == ATM_VPI_UNSPEC)
62 return 0;
63
64 set_bit(ATM_VF_ADDR, &vcc->flags);
65 set_bit(ATM_VF_READY, &vcc->flags);
66
67 return 0;
68}
69
70static void
71adummy_close(struct atm_vcc *vcc)
72{
73 clear_bit(ATM_VF_READY, &vcc->flags);
74 clear_bit(ATM_VF_ADDR, &vcc->flags);
75}
76
77static int
78adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
79{
80 if (vcc->pop)
81 vcc->pop(vcc, skb);
82 else
83 dev_kfree_skb_any(skb);
84 atomic_inc(&vcc->stats->tx);
85
86 return 0;
87}
88
89static int
90adummy_proc_read(struct atm_dev *dev, loff_t *pos, char *page)
91{
92 int left = *pos;
93
94 if (!left--)
95 return sprintf(page, "version %s\n", DRV_VERSION);
96
97 return 0;
98}
99
100static struct atmdev_ops adummy_ops =
101{
102 .open = adummy_open,
103 .close = adummy_close,
104 .send = adummy_send,
105 .proc_read = adummy_proc_read,
106 .owner = THIS_MODULE
107};
108
109static int __init adummy_init(void)
110{
111 struct atm_dev *atm_dev;
112 struct adummy_dev *adummy_dev;
113 int err = 0;
114
115 printk(KERN_ERR "adummy: version %s\n", DRV_VERSION);
116
117 adummy_dev = (struct adummy_dev *) kmalloc(sizeof(struct adummy_dev),
118 GFP_KERNEL);
119 if (!adummy_dev) {
120 printk(KERN_ERR DEV_LABEL ": kmalloc() failed\n");
121 err = -ENOMEM;
122 goto out;
123 }
124 memset(adummy_dev, 0, sizeof(struct adummy_dev));
125
126 atm_dev = atm_dev_register(DEV_LABEL, &adummy_ops, -1, NULL);
127 if (!atm_dev) {
128 printk(KERN_ERR DEV_LABEL ": atm_dev_register() failed\n");
129 err = -ENODEV;
130 goto out_kfree;
131 }
132
133 adummy_dev->atm_dev = atm_dev;
134 atm_dev->dev_data = adummy_dev;
135
136 if (adummy_start(atm_dev)) {
137 printk(KERN_ERR DEV_LABEL ": adummy_start() failed\n");
138 err = -ENODEV;
139 goto out_unregister;
140 }
141
142 list_add(&adummy_dev->entry, &adummy_devs);
143out:
144 return err;
145
146out_unregister:
147 atm_dev_deregister(atm_dev);
148out_kfree:
149 kfree(adummy_dev);
150 goto out;
151}
152
153static void __exit adummy_cleanup(void)
154{
155 struct adummy_dev *adummy_dev, *next;
156
157 list_for_each_entry_safe(adummy_dev, next, &adummy_devs, entry) {
158 atm_dev_deregister(adummy_dev->atm_dev);
159 kfree(adummy_dev);
160 }
161}
162
163module_init(adummy_init);
164module_exit(adummy_cleanup);
165
166MODULE_AUTHOR("chas williams <chas@cmf.nrl.navy.mil>");
167MODULE_DESCRIPTION("dummy ATM driver");
168MODULE_LICENSE("GPL");
diff --git a/drivers/atm/atmdev_init.c b/drivers/atm/atmdev_init.c
deleted file mode 100644
index 0e09e5c28e3f..000000000000
--- a/drivers/atm/atmdev_init.c
+++ /dev/null
@@ -1,54 +0,0 @@
1/* drivers/atm/atmdev_init.c - ATM device driver initialization */
2
3/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
4
5
6#include <linux/config.h>
7#include <linux/init.h>
8
9
10#ifdef CONFIG_ATM_ZATM
11extern int zatm_detect(void);
12#endif
13#ifdef CONFIG_ATM_AMBASSADOR
14extern int amb_detect(void);
15#endif
16#ifdef CONFIG_ATM_HORIZON
17extern int hrz_detect(void);
18#endif
19#ifdef CONFIG_ATM_FORE200E
20extern int fore200e_detect(void);
21#endif
22#ifdef CONFIG_ATM_LANAI
23extern int lanai_detect(void);
24#endif
25
26
27/*
28 * For historical reasons, atmdev_init returns the number of devices found.
29 * Note that some detections may not go via atmdev_init (e.g. eni.c), so this
30 * number is meaningless.
31 */
32
33int __init atmdev_init(void)
34{
35 int devs;
36
37 devs = 0;
38#ifdef CONFIG_ATM_ZATM
39 devs += zatm_detect();
40#endif
41#ifdef CONFIG_ATM_AMBASSADOR
42 devs += amb_detect();
43#endif
44#ifdef CONFIG_ATM_HORIZON
45 devs += hrz_detect();
46#endif
47#ifdef CONFIG_ATM_FORE200E
48 devs += fore200e_detect();
49#endif
50#ifdef CONFIG_ATM_LANAI
51 devs += lanai_detect();
52#endif
53 return devs;
54}
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index 57f1810fdccd..fc518d85543d 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -246,10 +246,6 @@ static void atmtcp_c_close(struct atm_vcc *vcc)
246{ 246{
247 struct atm_dev *atmtcp_dev; 247 struct atm_dev *atmtcp_dev;
248 struct atmtcp_dev_data *dev_data; 248 struct atmtcp_dev_data *dev_data;
249 struct sock *s;
250 struct hlist_node *node;
251 struct atm_vcc *walk;
252 int i;
253 249
254 atmtcp_dev = (struct atm_dev *) vcc->dev_data; 250 atmtcp_dev = (struct atm_dev *) vcc->dev_data;
255 dev_data = PRIV(atmtcp_dev); 251 dev_data = PRIV(atmtcp_dev);
@@ -257,20 +253,8 @@ static void atmtcp_c_close(struct atm_vcc *vcc)
257 if (dev_data->persist) return; 253 if (dev_data->persist) return;
258 atmtcp_dev->dev_data = NULL; 254 atmtcp_dev->dev_data = NULL;
259 kfree(dev_data); 255 kfree(dev_data);
260 shutdown_atm_dev(atmtcp_dev); 256 atm_dev_deregister(atmtcp_dev);
261 vcc->dev_data = NULL; 257 vcc->dev_data = NULL;
262 read_lock(&vcc_sklist_lock);
263 for(i = 0; i < VCC_HTABLE_SIZE; ++i) {
264 struct hlist_head *head = &vcc_hash[i];
265
266 sk_for_each(s, node, head) {
267 walk = atm_sk(s);
268 if (walk->dev != atmtcp_dev)
269 continue;
270 wake_up(s->sk_sleep);
271 }
272 }
273 read_unlock(&vcc_sklist_lock);
274 module_put(THIS_MODULE); 258 module_put(THIS_MODULE);
275} 259}
276 260
@@ -450,7 +434,7 @@ static int atmtcp_remove_persistent(int itf)
450 if (PRIV(dev)->vcc) return 0; 434 if (PRIV(dev)->vcc) return 0;
451 kfree(dev_data); 435 kfree(dev_data);
452 atm_dev_put(dev); 436 atm_dev_put(dev);
453 shutdown_atm_dev(dev); 437 atm_dev_deregister(dev);
454 return 0; 438 return 0;
455} 439}
456 440
diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
index 0cded0468003..821c81e8cd38 100644
--- a/drivers/atm/horizon.c
+++ b/drivers/atm/horizon.c
@@ -1511,8 +1511,8 @@ static inline short setup_idle_tx_channel (hrz_dev * dev, hrz_vcc * vcc) {
1511 // a.k.a. prepare the channel and remember that we have done so. 1511 // a.k.a. prepare the channel and remember that we have done so.
1512 1512
1513 tx_ch_desc * tx_desc = &memmap->tx_descs[tx_channel]; 1513 tx_ch_desc * tx_desc = &memmap->tx_descs[tx_channel];
1514 u16 rd_ptr; 1514 u32 rd_ptr;
1515 u16 wr_ptr; 1515 u32 wr_ptr;
1516 u16 channel = vcc->channel; 1516 u16 channel = vcc->channel;
1517 1517
1518 unsigned long flags; 1518 unsigned long flags;
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 51ec14787293..69f4c7ce9a63 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -39,7 +39,7 @@
39 * o lanai_change_qos() isn't written yet 39 * o lanai_change_qos() isn't written yet
40 * 40 *
41 * o There aren't any ioctl's yet -- I'd like to eventually support 41 * o There aren't any ioctl's yet -- I'd like to eventually support
42 * setting loopback and LED modes that way. (see lanai_ioctl) 42 * setting loopback and LED modes that way.
43 * 43 *
44 * o If the segmentation engine or DMA gets shut down we should restart 44 * o If the segmentation engine or DMA gets shut down we should restart
45 * card as per section 17.0i. (see lanai_reset) 45 * card as per section 17.0i. (see lanai_reset)
@@ -305,7 +305,7 @@ struct lanai_dev {
305 * vci with their bit set 305 * vci with their bit set
306 */ 306 */
307static void vci_bitfield_iterate(struct lanai_dev *lanai, 307static void vci_bitfield_iterate(struct lanai_dev *lanai,
308 /*const*/ unsigned long *lp, 308 const unsigned long *lp,
309 void (*func)(struct lanai_dev *,vci_t vci)) 309 void (*func)(struct lanai_dev *,vci_t vci))
310{ 310{
311 vci_t vci = find_first_bit(lp, NUM_VCI); 311 vci_t vci = find_first_bit(lp, NUM_VCI);
@@ -951,7 +951,7 @@ static int __devinit eeprom_read(struct lanai_dev *lanai)
951/* read a big-endian 4-byte value out of eeprom */ 951/* read a big-endian 4-byte value out of eeprom */
952static inline u32 eeprom_be4(const struct lanai_dev *lanai, int address) 952static inline u32 eeprom_be4(const struct lanai_dev *lanai, int address)
953{ 953{
954 return be32_to_cpup((u32 *) (&lanai->eeprom[address])); 954 return be32_to_cpup((const u32 *) &lanai->eeprom[address]);
955} 955}
956 956
957/* Checksum/validate EEPROM contents */ 957/* Checksum/validate EEPROM contents */
@@ -1160,7 +1160,7 @@ static inline int vcc_tx_space(const struct lanai_vcc *lvcc, int endptr)
1160} 1160}
1161 1161
1162/* test if VCC is currently backlogged */ 1162/* test if VCC is currently backlogged */
1163static inline int vcc_is_backlogged(/*const*/ struct lanai_vcc *lvcc) 1163static inline int vcc_is_backlogged(const struct lanai_vcc *lvcc)
1164{ 1164{
1165 return !skb_queue_empty(&lvcc->tx.backlog); 1165 return !skb_queue_empty(&lvcc->tx.backlog);
1166} 1166}
@@ -1395,7 +1395,8 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
1395{ 1395{
1396 int size; 1396 int size;
1397 struct sk_buff *skb; 1397 struct sk_buff *skb;
1398 /*const*/ u32 *x, *end = &lvcc->rx.buf.start[endptr * 4]; 1398 const u32 *x;
1399 u32 *end = &lvcc->rx.buf.start[endptr * 4];
1399 int n = ((unsigned long) end) - ((unsigned long) lvcc->rx.buf.ptr); 1400 int n = ((unsigned long) end) - ((unsigned long) lvcc->rx.buf.ptr);
1400 if (n < 0) 1401 if (n < 0)
1401 n += lanai_buf_size(&lvcc->rx.buf); 1402 n += lanai_buf_size(&lvcc->rx.buf);
@@ -2111,7 +2112,7 @@ static int lanai_normalize_ci(struct lanai_dev *lanai,
2111 * shifted by that much as we compute 2112 * shifted by that much as we compute
2112 * 2113 *
2113 */ 2114 */
2114static int pcr_to_cbricg(/*const*/ struct atm_qos *qos) 2115static int pcr_to_cbricg(const struct atm_qos *qos)
2115{ 2116{
2116 int rounddown = 0; /* 1 = Round PCR down, i.e. round ICG _up_ */ 2117 int rounddown = 0; /* 1 = Round PCR down, i.e. round ICG _up_ */
2117 int x, icg, pcr = atm_pcr_goal(&qos->txtp); 2118 int x, icg, pcr = atm_pcr_goal(&qos->txtp);
@@ -2434,93 +2435,6 @@ static int lanai_open(struct atm_vcc *atmvcc)
2434 return result; 2435 return result;
2435} 2436}
2436 2437
2437#if 0
2438/* ioctl operations for card */
2439/* NOTE: these are all DEBUGGING ONLY currently */
2440static int lanai_ioctl(struct atm_dev *atmdev, unsigned int cmd, void __user *arg)
2441{
2442 int result = 0;
2443 struct lanai_dev *lanai = (struct lanai_dev *) atmdev->dev_data;
2444 switch(cmd) {
2445 case 2106275:
2446 shutdown_atm_dev(atmdev);
2447 return 0;
2448 case 2200000: {
2449 unsigned long flags;
2450 spin_lock_irqsave(&lanai->servicelock, flags);
2451 run_service(lanai);
2452 spin_unlock_irqrestore(&lanai->servicelock, flags);
2453 return 0; }
2454 case 2200002:
2455 get_statistics(lanai);
2456 return 0;
2457 case 2200003: {
2458 unsigned int i;
2459 for (i = 0; i <= 0x5C ; i += 4) {
2460 if (i==0x48) /* Write-only butt reg */
2461 continue;
2462 printk(KERN_CRIT DEV_LABEL " 0x%02X: "
2463 "0x%08X\n", i,
2464 (unsigned int) readl(lanai->base + i));
2465 barrier(); mb();
2466 pcistatus_check(lanai, 0);
2467 barrier(); mb();
2468 }
2469 return 0; }
2470 case 2200004: {
2471 u8 b;
2472 u16 w;
2473 u32 dw;
2474 struct pci_dev *pci = lanai->pci;
2475 (void) pci_read_config_word(pci, PCI_VENDOR_ID, &w);
2476 DPRINTK("vendor = 0x%X\n", (unsigned int) w);
2477 (void) pci_read_config_word(pci, PCI_DEVICE_ID, &w);
2478 DPRINTK("device = 0x%X\n", (unsigned int) w);
2479 (void) pci_read_config_word(pci, PCI_COMMAND, &w);
2480 DPRINTK("command = 0x%X\n", (unsigned int) w);
2481 (void) pci_read_config_word(pci, PCI_STATUS, &w);
2482 DPRINTK("status = 0x%X\n", (unsigned int) w);
2483 (void) pci_read_config_dword(pci,
2484 PCI_CLASS_REVISION, &dw);
2485 DPRINTK("class/revision = 0x%X\n", (unsigned int) dw);
2486 (void) pci_read_config_byte(pci,
2487 PCI_CACHE_LINE_SIZE, &b);
2488 DPRINTK("cache line size = 0x%X\n", (unsigned int) b);
2489 (void) pci_read_config_byte(pci, PCI_LATENCY_TIMER, &b);
2490 DPRINTK("latency = %d (0x%X)\n",
2491 (int) b, (unsigned int) b);
2492 (void) pci_read_config_byte(pci, PCI_HEADER_TYPE, &b);
2493 DPRINTK("header type = 0x%X\n", (unsigned int) b);
2494 (void) pci_read_config_byte(pci, PCI_BIST, &b);
2495 DPRINTK("bist = 0x%X\n", (unsigned int) b);
2496 /* skipping a few here */
2497 (void) pci_read_config_byte(pci,
2498 PCI_INTERRUPT_LINE, &b);
2499 DPRINTK("pci_int_line = 0x%X\n", (unsigned int) b);
2500 (void) pci_read_config_byte(pci,
2501 PCI_INTERRUPT_PIN, &b);
2502 DPRINTK("pci_int_pin = 0x%X\n", (unsigned int) b);
2503 (void) pci_read_config_byte(pci, PCI_MIN_GNT, &b);
2504 DPRINTK("min_gnt = 0x%X\n", (unsigned int) b);
2505 (void) pci_read_config_byte(pci, PCI_MAX_LAT, &b);
2506 DPRINTK("max_lat = 0x%X\n", (unsigned int) b); }
2507 return 0;
2508#ifdef USE_POWERDOWN
2509 case 2200005:
2510 DPRINTK("Coming out of powerdown\n");
2511 lanai->conf1 &= ~CONFIG1_POWERDOWN;
2512 conf1_write(lanai);
2513 return 0;
2514#endif
2515 default:
2516 result = -ENOIOCTLCMD;
2517 }
2518 return result;
2519}
2520#else /* !0 */
2521#define lanai_ioctl NULL
2522#endif /* 0 */
2523
2524static int lanai_send(struct atm_vcc *atmvcc, struct sk_buff *skb) 2438static int lanai_send(struct atm_vcc *atmvcc, struct sk_buff *skb)
2525{ 2439{
2526 struct lanai_vcc *lvcc = (struct lanai_vcc *) atmvcc->dev_data; 2440 struct lanai_vcc *lvcc = (struct lanai_vcc *) atmvcc->dev_data;
@@ -2678,7 +2592,6 @@ static const struct atmdev_ops ops = {
2678 .dev_close = lanai_dev_close, 2592 .dev_close = lanai_dev_close,
2679 .open = lanai_open, 2593 .open = lanai_open,
2680 .close = lanai_close, 2594 .close = lanai_close,
2681 .ioctl = lanai_ioctl,
2682 .getsockopt = NULL, 2595 .getsockopt = NULL,
2683 .setsockopt = NULL, 2596 .setsockopt = NULL,
2684 .send = lanai_send, 2597 .send = lanai_send,
@@ -2760,6 +2673,7 @@ static void __exit lanai_module_exit(void)
2760 * gone, so there isn't much to do 2673 * gone, so there isn't much to do
2761 */ 2674 */
2762 DPRINTK("cleanup_module()\n"); 2675 DPRINTK("cleanup_module()\n");
2676 pci_unregister_driver(&lanai_driver);
2763} 2677}
2764 2678
2765module_init(lanai_module_init); 2679module_init(lanai_module_init);
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 03204bfd17af..fa601b085eba 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -133,7 +133,7 @@ static struct kobj_type ktype_bus = {
133decl_subsys(bus, &ktype_bus, NULL); 133decl_subsys(bus, &ktype_bus, NULL);
134 134
135 135
136/* Manually detach a device from it's associated driver. */ 136/* Manually detach a device from its associated driver. */
137static int driver_helper(struct device *dev, void *data) 137static int driver_helper(struct device *dev, void *data)
138{ 138{
139 const char *name = data; 139 const char *name = data;
@@ -151,14 +151,13 @@ static ssize_t driver_unbind(struct device_driver *drv,
151 int err = -ENODEV; 151 int err = -ENODEV;
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) && 154 if (dev && dev->driver == drv) {
155 (dev->driver == drv)) {
156 device_release_driver(dev); 155 device_release_driver(dev);
157 err = count; 156 err = count;
158 } 157 }
159 if (err) 158 put_device(dev);
160 return err; 159 put_bus(bus);
161 return count; 160 return err;
162} 161}
163static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind); 162static DRIVER_ATTR(unbind, S_IWUSR, NULL, driver_unbind);
164 163
@@ -175,16 +174,14 @@ static ssize_t driver_bind(struct device_driver *drv,
175 int err = -ENODEV; 174 int err = -ENODEV;
176 175
177 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper); 176 dev = bus_find_device(bus, NULL, (void *)buf, driver_helper);
178 if ((dev) && 177 if (dev && dev->driver == NULL) {
179 (dev->driver == NULL)) {
180 down(&dev->sem); 178 down(&dev->sem);
181 err = driver_probe_device(drv, dev); 179 err = driver_probe_device(drv, dev);
182 up(&dev->sem); 180 up(&dev->sem);
183 put_device(dev);
184 } 181 }
185 if (err) 182 put_device(dev);
186 return err; 183 put_bus(bus);
187 return count; 184 return err;
188} 185}
189static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind); 186static DRIVER_ATTR(bind, S_IWUSR, NULL, driver_bind);
190 187
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 3565e9795301..3b419c9a1e7e 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -62,7 +62,6 @@ void device_bind_driver(struct device * dev)
62 * because we don't know the format of the ID structures, nor what 62 * because we don't know the format of the ID structures, nor what
63 * is to be considered a match and what is not. 63 * is to be considered a match and what is not.
64 * 64 *
65 *
66 * 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
67 * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise. 66 * occurs (that is not -ENODEV or -ENXIO), and 0 otherwise.
68 * 67 *
@@ -158,7 +157,6 @@ static int __driver_attach(struct device * dev, void * data)
158 driver_probe_device(drv, dev); 157 driver_probe_device(drv, dev);
159 up(&dev->sem); 158 up(&dev->sem);
160 159
161
162 return 0; 160 return 0;
163} 161}
164 162
@@ -225,15 +223,15 @@ void driver_detach(struct device_driver * drv)
225 struct device * dev; 223 struct device * dev;
226 224
227 for (;;) { 225 for (;;) {
228 spin_lock_irq(&drv->klist_devices.k_lock); 226 spin_lock(&drv->klist_devices.k_lock);
229 if (list_empty(&drv->klist_devices.k_list)) { 227 if (list_empty(&drv->klist_devices.k_list)) {
230 spin_unlock_irq(&drv->klist_devices.k_lock); 228 spin_unlock(&drv->klist_devices.k_lock);
231 break; 229 break;
232 } 230 }
233 dev = list_entry(drv->klist_devices.k_list.prev, 231 dev = list_entry(drv->klist_devices.k_list.prev,
234 struct device, knode_driver.n_node); 232 struct device, knode_driver.n_node);
235 get_device(dev); 233 get_device(dev);
236 spin_unlock_irq(&drv->klist_devices.k_lock); 234 spin_unlock(&drv->klist_devices.k_lock);
237 235
238 down(&dev->sem); 236 down(&dev->sem);
239 if (dev->driver == drv) 237 if (dev->driver == drv)
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 98f6c02d6790..59dacb6552c0 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -526,18 +526,23 @@ request_firmware_work_func(void *arg)
526{ 526{
527 struct firmware_work *fw_work = arg; 527 struct firmware_work *fw_work = arg;
528 const struct firmware *fw; 528 const struct firmware *fw;
529 int ret;
529 if (!arg) { 530 if (!arg) {
530 WARN_ON(1); 531 WARN_ON(1);
531 return 0; 532 return 0;
532 } 533 }
533 daemonize("%s/%s", "firmware", fw_work->name); 534 daemonize("%s/%s", "firmware", fw_work->name);
534 _request_firmware(&fw, fw_work->name, fw_work->device, 535 ret = _request_firmware(&fw, fw_work->name, fw_work->device,
535 fw_work->hotplug); 536 fw_work->hotplug);
536 fw_work->cont(fw, fw_work->context); 537 if (ret < 0)
537 release_firmware(fw); 538 fw_work->cont(NULL, fw_work->context);
539 else {
540 fw_work->cont(fw, fw_work->context);
541 release_firmware(fw);
542 }
538 module_put(fw_work->module); 543 module_put(fw_work->module);
539 kfree(fw_work); 544 kfree(fw_work);
540 return 0; 545 return ret;
541} 546}
542 547
543/** 548/**
@@ -586,6 +591,8 @@ request_firmware_nowait(
586 591
587 if (ret < 0) { 592 if (ret < 0) {
588 fw_work->cont(NULL, fw_work->context); 593 fw_work->cont(NULL, fw_work->context);
594 module_put(fw_work->module);
595 kfree(fw_work);
589 return ret; 596 return ret;
590 } 597 }
591 return 0; 598 return 0;
diff --git a/drivers/base/memory.c b/drivers/base/memory.c
index b7ddd651d664..bc3ca6a656b2 100644
--- a/drivers/base/memory.c
+++ b/drivers/base/memory.c
@@ -28,7 +28,6 @@
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 char *memory_hotplug_name(struct kset *kset, struct kobject *kobj)
34{ 33{
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 6d4736e89f1a..8827dafba945 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -20,6 +20,8 @@
20 20
21#include "base.h" 21#include "base.h"
22 22
23#define to_platform_driver(drv) (container_of((drv), struct platform_driver, driver))
24
23struct device platform_bus = { 25struct device platform_bus = {
24 .bus_id = "platform", 26 .bus_id = "platform",
25}; 27};
@@ -354,6 +356,77 @@ error:
354 return ERR_PTR(retval); 356 return ERR_PTR(retval);
355} 357}
356 358
359static int platform_drv_probe(struct device *_dev)
360{
361 struct platform_driver *drv = to_platform_driver(_dev->driver);
362 struct platform_device *dev = to_platform_device(_dev);
363
364 return drv->probe(dev);
365}
366
367static int platform_drv_remove(struct device *_dev)
368{
369 struct platform_driver *drv = to_platform_driver(_dev->driver);
370 struct platform_device *dev = to_platform_device(_dev);
371
372 return drv->remove(dev);
373}
374
375static void platform_drv_shutdown(struct device *_dev)
376{
377 struct platform_driver *drv = to_platform_driver(_dev->driver);
378 struct platform_device *dev = to_platform_device(_dev);
379
380 drv->shutdown(dev);
381}
382
383static int platform_drv_suspend(struct device *_dev, pm_message_t state)
384{
385 struct platform_driver *drv = to_platform_driver(_dev->driver);
386 struct platform_device *dev = to_platform_device(_dev);
387
388 return drv->suspend(dev, state);
389}
390
391static int platform_drv_resume(struct device *_dev)
392{
393 struct platform_driver *drv = to_platform_driver(_dev->driver);
394 struct platform_device *dev = to_platform_device(_dev);
395
396 return drv->resume(dev);
397}
398
399/**
400 * platform_driver_register
401 * @drv: platform driver structure
402 */
403int platform_driver_register(struct platform_driver *drv)
404{
405 drv->driver.bus = &platform_bus_type;
406 if (drv->probe)
407 drv->driver.probe = platform_drv_probe;
408 if (drv->remove)
409 drv->driver.remove = platform_drv_remove;
410 if (drv->shutdown)
411 drv->driver.shutdown = platform_drv_shutdown;
412 if (drv->suspend)
413 drv->driver.suspend = platform_drv_suspend;
414 if (drv->resume)
415 drv->driver.resume = platform_drv_resume;
416 return driver_register(&drv->driver);
417}
418EXPORT_SYMBOL_GPL(platform_driver_register);
419
420/**
421 * platform_driver_unregister
422 * @drv: platform driver structure
423 */
424void platform_driver_unregister(struct platform_driver *drv)
425{
426 driver_unregister(&drv->driver);
427}
428EXPORT_SYMBOL_GPL(platform_driver_unregister);
429
357 430
358/** 431/**
359 * platform_match - bind platform device to platform driver. 432 * platform_match - bind platform device to platform driver.
diff --git a/drivers/block/acsi.c b/drivers/block/acsi.c
index 0e1f34fef0c8..5d2d649f7e8d 100644
--- a/drivers/block/acsi.c
+++ b/drivers/block/acsi.c
@@ -58,7 +58,6 @@
58#include <linux/slab.h> 58#include <linux/slab.h>
59#include <linux/interrupt.h> 59#include <linux/interrupt.h>
60#include <scsi/scsi.h> /* for SCSI_IOCTL_GET_IDLUN */ 60#include <scsi/scsi.h> /* for SCSI_IOCTL_GET_IDLUN */
61typedef void Scsi_Device; /* hack to avoid including scsi.h */
62#include <scsi/scsi_ioctl.h> 61#include <scsi/scsi_ioctl.h>
63#include <linux/hdreg.h> /* for HDIO_GETGEO */ 62#include <linux/hdreg.h> /* for HDIO_GETGEO */
64#include <linux/blkpg.h> 63#include <linux/blkpg.h>
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index a97c80b57737..c3441b3f086e 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -148,6 +148,7 @@ static struct board_type products[] = {
148static ctlr_info_t *hba[MAX_CTLR]; 148static ctlr_info_t *hba[MAX_CTLR];
149 149
150static void do_cciss_request(request_queue_t *q); 150static void do_cciss_request(request_queue_t *q);
151static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs);
151static int cciss_open(struct inode *inode, struct file *filep); 152static int cciss_open(struct inode *inode, struct file *filep);
152static int cciss_release(struct inode *inode, struct file *filep); 153static int cciss_release(struct inode *inode, struct file *filep);
153static int cciss_ioctl(struct inode *inode, struct file *filep, 154static int cciss_ioctl(struct inode *inode, struct file *filep,
@@ -1016,10 +1017,11 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1016 status = -ENOMEM; 1017 status = -ENOMEM;
1017 goto cleanup1; 1018 goto cleanup1;
1018 } 1019 }
1019 if (ioc->Request.Type.Direction == XFER_WRITE && 1020 if (ioc->Request.Type.Direction == XFER_WRITE) {
1020 copy_from_user(buff[sg_used], data_ptr, sz)) { 1021 if (copy_from_user(buff[sg_used], data_ptr, sz)) {
1021 status = -ENOMEM; 1022 status = -ENOMEM;
1022 goto cleanup1; 1023 goto cleanup1;
1024 }
1023 } else { 1025 } else {
1024 memset(buff[sg_used], 0, sz); 1026 memset(buff[sg_used], 0, sz);
1025 } 1027 }
@@ -1137,8 +1139,14 @@ static int revalidate_allvol(ctlr_info_t *host)
1137 1139
1138 for(i=0; i< NWD; i++) { 1140 for(i=0; i< NWD; i++) {
1139 struct gendisk *disk = host->gendisk[i]; 1141 struct gendisk *disk = host->gendisk[i];
1140 if (disk->flags & GENHD_FL_UP) 1142 if (disk) {
1141 del_gendisk(disk); 1143 request_queue_t *q = disk->queue;
1144
1145 if (disk->flags & GENHD_FL_UP)
1146 del_gendisk(disk);
1147 if (q)
1148 blk_cleanup_queue(q);
1149 }
1142 } 1150 }
1143 1151
1144 /* 1152 /*
@@ -1452,10 +1460,14 @@ static int deregister_disk(struct gendisk *disk, drive_info_struct *drv,
1452 * allows us to delete disk zero but keep the controller registered. 1460 * allows us to delete disk zero but keep the controller registered.
1453 */ 1461 */
1454 if (h->gendisk[0] != disk){ 1462 if (h->gendisk[0] != disk){
1455 if (disk->flags & GENHD_FL_UP){ 1463 if (disk) {
1456 blk_cleanup_queue(disk->queue); 1464 request_queue_t *q = disk->queue;
1457 del_gendisk(disk); 1465 if (disk->flags & GENHD_FL_UP)
1458 drv->queue = NULL; 1466 del_gendisk(disk);
1467 if (q) {
1468 blk_cleanup_queue(q);
1469 drv->queue = NULL;
1470 }
1459 } 1471 }
1460 } 1472 }
1461 1473
@@ -1583,6 +1595,24 @@ static int fill_cmd(CommandList_struct *c, __u8 cmd, int ctlr, void *buff,
1583 } 1595 }
1584 } else if (cmd_type == TYPE_MSG) { 1596 } else if (cmd_type == TYPE_MSG) {
1585 switch (cmd) { 1597 switch (cmd) {
1598 case 0: /* ABORT message */
1599 c->Request.CDBLen = 12;
1600 c->Request.Type.Attribute = ATTR_SIMPLE;
1601 c->Request.Type.Direction = XFER_WRITE;
1602 c->Request.Timeout = 0;
1603 c->Request.CDB[0] = cmd; /* abort */
1604 c->Request.CDB[1] = 0; /* abort a command */
1605 /* buff contains the tag of the command to abort */
1606 memcpy(&c->Request.CDB[4], buff, 8);
1607 break;
1608 case 1: /* RESET message */
1609 c->Request.CDBLen = 12;
1610 c->Request.Type.Attribute = ATTR_SIMPLE;
1611 c->Request.Type.Direction = XFER_WRITE;
1612 c->Request.Timeout = 0;
1613 memset(&c->Request.CDB[0], 0, sizeof(c->Request.CDB));
1614 c->Request.CDB[0] = cmd; /* reset */
1615 c->Request.CDB[1] = 0x04; /* reset a LUN */
1586 case 3: /* No-Op message */ 1616 case 3: /* No-Op message */
1587 c->Request.CDBLen = 1; 1617 c->Request.CDBLen = 1;
1588 c->Request.Type.Attribute = ATTR_SIMPLE; 1618 c->Request.Type.Attribute = ATTR_SIMPLE;
@@ -1869,6 +1899,52 @@ static unsigned long pollcomplete(int ctlr)
1869 /* Invalid address to tell caller we ran out of time */ 1899 /* Invalid address to tell caller we ran out of time */
1870 return 1; 1900 return 1;
1871} 1901}
1902
1903static int add_sendcmd_reject(__u8 cmd, int ctlr, unsigned long complete)
1904{
1905 /* We get in here if sendcmd() is polling for completions
1906 and gets some command back that it wasn't expecting --
1907 something other than that which it just sent down.
1908 Ordinarily, that shouldn't happen, but it can happen when
1909 the scsi tape stuff gets into error handling mode, and
1910 starts using sendcmd() to try to abort commands and
1911 reset tape drives. In that case, sendcmd may pick up
1912 completions of commands that were sent to logical drives
1913 through the block i/o system, or cciss ioctls completing, etc.
1914 In that case, we need to save those completions for later
1915 processing by the interrupt handler.
1916 */
1917
1918#ifdef CONFIG_CISS_SCSI_TAPE
1919 struct sendcmd_reject_list *srl = &hba[ctlr]->scsi_rejects;
1920
1921 /* If it's not the scsi tape stuff doing error handling, (abort */
1922 /* or reset) then we don't expect anything weird. */
1923 if (cmd != CCISS_RESET_MSG && cmd != CCISS_ABORT_MSG) {
1924#endif
1925 printk( KERN_WARNING "cciss cciss%d: SendCmd "
1926 "Invalid command list address returned! (%lx)\n",
1927 ctlr, complete);
1928 /* not much we can do. */
1929#ifdef CONFIG_CISS_SCSI_TAPE
1930 return 1;
1931 }
1932
1933 /* We've sent down an abort or reset, but something else
1934 has completed */
1935 if (srl->ncompletions >= (NR_CMDS + 2)) {
1936 /* Uh oh. No room to save it for later... */
1937 printk(KERN_WARNING "cciss%d: Sendcmd: Invalid command addr, "
1938 "reject list overflow, command lost!\n", ctlr);
1939 return 1;
1940 }
1941 /* Save it for later */
1942 srl->complete[srl->ncompletions] = complete;
1943 srl->ncompletions++;
1944#endif
1945 return 0;
1946}
1947
1872/* 1948/*
1873 * Send a command to the controller, and wait for it to complete. 1949 * Send a command to the controller, and wait for it to complete.
1874 * Only used at init time. 1950 * Only used at init time.
@@ -1891,7 +1967,7 @@ static int sendcmd(
1891 unsigned long complete; 1967 unsigned long complete;
1892 ctlr_info_t *info_p= hba[ctlr]; 1968 ctlr_info_t *info_p= hba[ctlr];
1893 u64bit buff_dma_handle; 1969 u64bit buff_dma_handle;
1894 int status; 1970 int status, done = 0;
1895 1971
1896 if ((c = cmd_alloc(info_p, 1)) == NULL) { 1972 if ((c = cmd_alloc(info_p, 1)) == NULL) {
1897 printk(KERN_WARNING "cciss: unable to get memory"); 1973 printk(KERN_WARNING "cciss: unable to get memory");
@@ -1913,7 +1989,9 @@ resend_cmd1:
1913 info_p->access.set_intr_mask(info_p, CCISS_INTR_OFF); 1989 info_p->access.set_intr_mask(info_p, CCISS_INTR_OFF);
1914 1990
1915 /* Make sure there is room in the command FIFO */ 1991 /* Make sure there is room in the command FIFO */
1916 /* Actually it should be completely empty at this time. */ 1992 /* Actually it should be completely empty at this time */
1993 /* unless we are in here doing error handling for the scsi */
1994 /* tape side of the driver. */
1917 for (i = 200000; i > 0; i--) 1995 for (i = 200000; i > 0; i--)
1918 { 1996 {
1919 /* if fifo isn't full go */ 1997 /* if fifo isn't full go */
@@ -1930,13 +2008,25 @@ resend_cmd1:
1930 * Send the cmd 2008 * Send the cmd
1931 */ 2009 */
1932 info_p->access.submit_command(info_p, c); 2010 info_p->access.submit_command(info_p, c);
1933 complete = pollcomplete(ctlr); 2011 done = 0;
2012 do {
2013 complete = pollcomplete(ctlr);
1934 2014
1935#ifdef CCISS_DEBUG 2015#ifdef CCISS_DEBUG
1936 printk(KERN_DEBUG "cciss: command completed\n"); 2016 printk(KERN_DEBUG "cciss: command completed\n");
1937#endif /* CCISS_DEBUG */ 2017#endif /* CCISS_DEBUG */
1938 2018
1939 if (complete != 1) { 2019 if (complete == 1) {
2020 printk( KERN_WARNING
2021 "cciss cciss%d: SendCmd Timeout out, "
2022 "No command list address returned!\n",
2023 ctlr);
2024 status = IO_ERROR;
2025 done = 1;
2026 break;
2027 }
2028
2029 /* This will need to change for direct lookup completions */
1940 if ( (complete & CISS_ERROR_BIT) 2030 if ( (complete & CISS_ERROR_BIT)
1941 && (complete & ~CISS_ERROR_BIT) == c->busaddr) 2031 && (complete & ~CISS_ERROR_BIT) == c->busaddr)
1942 { 2032 {
@@ -1976,6 +2066,10 @@ resend_cmd1:
1976 status = IO_ERROR; 2066 status = IO_ERROR;
1977 goto cleanup1; 2067 goto cleanup1;
1978 } 2068 }
2069 } else if (c->err_info->CommandStatus == CMD_UNABORTABLE) {
2070 printk(KERN_WARNING "cciss%d: command could not be aborted.\n", ctlr);
2071 status = IO_ERROR;
2072 goto cleanup1;
1979 } 2073 }
1980 printk(KERN_WARNING "ciss ciss%d: sendcmd" 2074 printk(KERN_WARNING "ciss ciss%d: sendcmd"
1981 " Error %x \n", ctlr, 2075 " Error %x \n", ctlr,
@@ -1990,20 +2084,15 @@ resend_cmd1:
1990 goto cleanup1; 2084 goto cleanup1;
1991 } 2085 }
1992 } 2086 }
2087 /* This will need changing for direct lookup completions */
1993 if (complete != c->busaddr) { 2088 if (complete != c->busaddr) {
1994 printk( KERN_WARNING "cciss cciss%d: SendCmd " 2089 if (add_sendcmd_reject(cmd, ctlr, complete) != 0) {
1995 "Invalid command list address returned! (%lx)\n", 2090 BUG(); /* we are pretty much hosed if we get here. */
1996 ctlr, complete); 2091 }
1997 status = IO_ERROR; 2092 continue;
1998 goto cleanup1; 2093 } else
1999 } 2094 done = 1;
2000 } else { 2095 } while (!done);
2001 printk( KERN_WARNING
2002 "cciss cciss%d: SendCmd Timeout out, "
2003 "No command list address returned!\n",
2004 ctlr);
2005 status = IO_ERROR;
2006 }
2007 2096
2008cleanup1: 2097cleanup1:
2009 /* unlock the data buffer from DMA */ 2098 /* unlock the data buffer from DMA */
@@ -2011,6 +2100,11 @@ cleanup1:
2011 buff_dma_handle.val32.upper = c->SG[0].Addr.upper; 2100 buff_dma_handle.val32.upper = c->SG[0].Addr.upper;
2012 pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val, 2101 pci_unmap_single(info_p->pdev, (dma_addr_t) buff_dma_handle.val,
2013 c->SG[0].Len, PCI_DMA_BIDIRECTIONAL); 2102 c->SG[0].Len, PCI_DMA_BIDIRECTIONAL);
2103#ifdef CONFIG_CISS_SCSI_TAPE
2104 /* if we saved some commands for later, process them now. */
2105 if (info_p->scsi_rejects.ncompletions > 0)
2106 do_cciss_intr(0, info_p, NULL);
2107#endif
2014 cmd_free(info_p, c, 1); 2108 cmd_free(info_p, c, 1);
2015 return (status); 2109 return (status);
2016} 2110}
@@ -2335,6 +2429,48 @@ startio:
2335 start_io(h); 2429 start_io(h);
2336} 2430}
2337 2431
2432static inline unsigned long get_next_completion(ctlr_info_t *h)
2433{
2434#ifdef CONFIG_CISS_SCSI_TAPE
2435 /* Any rejects from sendcmd() lying around? Process them first */
2436 if (h->scsi_rejects.ncompletions == 0)
2437 return h->access.command_completed(h);
2438 else {
2439 struct sendcmd_reject_list *srl;
2440 int n;
2441 srl = &h->scsi_rejects;
2442 n = --srl->ncompletions;
2443 /* printk("cciss%d: processing saved reject\n", h->ctlr); */
2444 printk("p");
2445 return srl->complete[n];
2446 }
2447#else
2448 return h->access.command_completed(h);
2449#endif
2450}
2451
2452static inline int interrupt_pending(ctlr_info_t *h)
2453{
2454#ifdef CONFIG_CISS_SCSI_TAPE
2455 return ( h->access.intr_pending(h)
2456 || (h->scsi_rejects.ncompletions > 0));
2457#else
2458 return h->access.intr_pending(h);
2459#endif
2460}
2461
2462static inline long interrupt_not_for_us(ctlr_info_t *h)
2463{
2464#ifdef CONFIG_CISS_SCSI_TAPE
2465 return (((h->access.intr_pending(h) == 0) ||
2466 (h->interrupts_enabled == 0))
2467 && (h->scsi_rejects.ncompletions == 0));
2468#else
2469 return (((h->access.intr_pending(h) == 0) ||
2470 (h->interrupts_enabled == 0)));
2471#endif
2472}
2473
2338static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs) 2474static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
2339{ 2475{
2340 ctlr_info_t *h = dev_id; 2476 ctlr_info_t *h = dev_id;
@@ -2344,19 +2480,15 @@ static irqreturn_t do_cciss_intr(int irq, void *dev_id, struct pt_regs *regs)
2344 int j; 2480 int j;
2345 int start_queue = h->next_to_run; 2481 int start_queue = h->next_to_run;
2346 2482
2347 /* Is this interrupt for us? */ 2483 if (interrupt_not_for_us(h))
2348 if (( h->access.intr_pending(h) == 0) || (h->interrupts_enabled == 0))
2349 return IRQ_NONE; 2484 return IRQ_NONE;
2350
2351 /* 2485 /*
2352 * If there are completed commands in the completion queue, 2486 * If there are completed commands in the completion queue,
2353 * we had better do something about it. 2487 * we had better do something about it.
2354 */ 2488 */
2355 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); 2489 spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags);
2356 while( h->access.intr_pending(h)) 2490 while (interrupt_pending(h)) {
2357 { 2491 while((a = get_next_completion(h)) != FIFO_EMPTY) {
2358 while((a = h->access.command_completed(h)) != FIFO_EMPTY)
2359 {
2360 a1 = a; 2492 a1 = a;
2361 if ((a & 0x04)) { 2493 if ((a & 0x04)) {
2362 a2 = (a >> 3); 2494 a2 = (a >> 3);
@@ -2963,7 +3095,15 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
2963 printk( KERN_ERR "cciss: out of memory"); 3095 printk( KERN_ERR "cciss: out of memory");
2964 goto clean4; 3096 goto clean4;
2965 } 3097 }
2966 3098#ifdef CONFIG_CISS_SCSI_TAPE
3099 hba[i]->scsi_rejects.complete =
3100 kmalloc(sizeof(hba[i]->scsi_rejects.complete[0]) *
3101 (NR_CMDS + 5), GFP_KERNEL);
3102 if (hba[i]->scsi_rejects.complete == NULL) {
3103 printk( KERN_ERR "cciss: out of memory");
3104 goto clean4;
3105 }
3106#endif
2967 spin_lock_init(&hba[i]->lock); 3107 spin_lock_init(&hba[i]->lock);
2968 3108
2969 /* Initialize the pdev driver private data. 3109 /* Initialize the pdev driver private data.
@@ -3031,6 +3171,10 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3031 return(1); 3171 return(1);
3032 3172
3033clean4: 3173clean4:
3174#ifdef CONFIG_CISS_SCSI_TAPE
3175 if(hba[i]->scsi_rejects.complete)
3176 kfree(hba[i]->scsi_rejects.complete);
3177#endif
3034 kfree(hba[i]->cmd_pool_bits); 3178 kfree(hba[i]->cmd_pool_bits);
3035 if(hba[i]->cmd_pool) 3179 if(hba[i]->cmd_pool)
3036 pci_free_consistent(hba[i]->pdev, 3180 pci_free_consistent(hba[i]->pdev,
@@ -3092,9 +3236,13 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev)
3092 /* remove it from the disk list */ 3236 /* remove it from the disk list */
3093 for (j = 0; j < NWD; j++) { 3237 for (j = 0; j < NWD; j++) {
3094 struct gendisk *disk = hba[i]->gendisk[j]; 3238 struct gendisk *disk = hba[i]->gendisk[j];
3095 if (disk->flags & GENHD_FL_UP) { 3239 if (disk) {
3096 del_gendisk(disk); 3240 request_queue_t *q = disk->queue;
3097 blk_cleanup_queue(disk->queue); 3241
3242 if (disk->flags & GENHD_FL_UP)
3243 del_gendisk(disk);
3244 if (q)
3245 blk_cleanup_queue(q);
3098 } 3246 }
3099 } 3247 }
3100 3248
@@ -3103,6 +3251,9 @@ static void __devexit cciss_remove_one (struct pci_dev *pdev)
3103 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct), 3251 pci_free_consistent(hba[i]->pdev, NR_CMDS * sizeof( ErrorInfo_struct),
3104 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle); 3252 hba[i]->errinfo_pool, hba[i]->errinfo_pool_dhandle);
3105 kfree(hba[i]->cmd_pool_bits); 3253 kfree(hba[i]->cmd_pool_bits);
3254#ifdef CONFIG_CISS_SCSI_TAPE
3255 kfree(hba[i]->scsi_rejects.complete);
3256#endif
3106 release_io_mem(hba[i]); 3257 release_io_mem(hba[i]);
3107 free_hba(i); 3258 free_hba(i);
3108} 3259}
diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
index ef277baee9fd..3b0858c83897 100644
--- a/drivers/block/cciss.h
+++ b/drivers/block/cciss.h
@@ -44,6 +44,14 @@ typedef struct _drive_info_struct
44 */ 44 */
45} drive_info_struct; 45} drive_info_struct;
46 46
47#ifdef CONFIG_CISS_SCSI_TAPE
48
49struct sendcmd_reject_list {
50 int ncompletions;
51 unsigned long *complete; /* array of NR_CMDS tags */
52};
53
54#endif
47struct ctlr_info 55struct ctlr_info
48{ 56{
49 int ctlr; 57 int ctlr;
@@ -100,6 +108,9 @@ struct ctlr_info
100 struct gendisk *gendisk[NWD]; 108 struct gendisk *gendisk[NWD];
101#ifdef CONFIG_CISS_SCSI_TAPE 109#ifdef CONFIG_CISS_SCSI_TAPE
102 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */ 110 void *scsi_ctlr; /* ptr to structure containing scsi related stuff */
111 /* list of block side commands the scsi error handling sucked up */
112 /* and saved for later processing */
113 struct sendcmd_reject_list scsi_rejects;
103#endif 114#endif
104 unsigned char alive; 115 unsigned char alive;
105}; 116};
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index ec27976a57da..2942d32280a5 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -42,6 +42,9 @@
42 42
43#include "cciss_scsi.h" 43#include "cciss_scsi.h"
44 44
45#define CCISS_ABORT_MSG 0x00
46#define CCISS_RESET_MSG 0x01
47
45/* some prototypes... */ 48/* some prototypes... */
46static int sendcmd( 49static int sendcmd(
47 __u8 cmd, 50 __u8 cmd,
@@ -67,6 +70,8 @@ static int cciss_scsi_proc_info(
67 70
68static int cciss_scsi_queue_command (struct scsi_cmnd *cmd, 71static int cciss_scsi_queue_command (struct scsi_cmnd *cmd,
69 void (* done)(struct scsi_cmnd *)); 72 void (* done)(struct scsi_cmnd *));
73static int cciss_eh_device_reset_handler(struct scsi_cmnd *);
74static int cciss_eh_abort_handler(struct scsi_cmnd *);
70 75
71static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = { 76static struct cciss_scsi_hba_t ccissscsi[MAX_CTLR] = {
72 { .name = "cciss0", .ndevices = 0 }, 77 { .name = "cciss0", .ndevices = 0 },
@@ -90,6 +95,9 @@ static struct scsi_host_template cciss_driver_template = {
90 .sg_tablesize = MAXSGENTRIES, 95 .sg_tablesize = MAXSGENTRIES,
91 .cmd_per_lun = 1, 96 .cmd_per_lun = 1,
92 .use_clustering = DISABLE_CLUSTERING, 97 .use_clustering = DISABLE_CLUSTERING,
98 /* Can't have eh_bus_reset_handler or eh_host_reset_handler for cciss */
99 .eh_device_reset_handler= cciss_eh_device_reset_handler,
100 .eh_abort_handler = cciss_eh_abort_handler,
93}; 101};
94 102
95#pragma pack(1) 103#pragma pack(1)
@@ -1448,6 +1456,78 @@ cciss_proc_tape_report(int ctlr, unsigned char *buffer, off_t *pos, off_t *len)
1448 *pos += size; *len += size; 1456 *pos += size; *len += size;
1449} 1457}
1450 1458
1459/* Need at least one of these error handlers to keep ../scsi/hosts.c from
1460 * complaining. Doing a host- or bus-reset can't do anything good here.
1461 * Despite what it might say in scsi_error.c, there may well be commands
1462 * on the controller, as the cciss driver registers twice, once as a block
1463 * device for the logical drives, and once as a scsi device, for any tape
1464 * drives. So we know there are no commands out on the tape drives, but we
1465 * don't know there are no commands on the controller, and it is likely
1466 * that there probably are, as the cciss block device is most commonly used
1467 * as a boot device (embedded controller on HP/Compaq systems.)
1468*/
1469
1470static int cciss_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
1471{
1472 int rc;
1473 CommandList_struct *cmd_in_trouble;
1474 ctlr_info_t **c;
1475 int ctlr;
1476
1477 /* find the controller to which the command to be aborted was sent */
1478 c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0];
1479 if (c == NULL) /* paranoia */
1480 return FAILED;
1481 ctlr = (*c)->ctlr;
1482 printk(KERN_WARNING "cciss%d: resetting tape drive or medium changer.\n", ctlr);
1483
1484 /* find the command that's giving us trouble */
1485 cmd_in_trouble = (CommandList_struct *) scsicmd->host_scribble;
1486 if (cmd_in_trouble == NULL) { /* paranoia */
1487 return FAILED;
1488 }
1489 /* send a reset to the SCSI LUN which the command was sent to */
1490 rc = sendcmd(CCISS_RESET_MSG, ctlr, NULL, 0, 2, 0, 0,
1491 (unsigned char *) &cmd_in_trouble->Header.LUN.LunAddrBytes[0],
1492 TYPE_MSG);
1493 /* sendcmd turned off interrputs on the board, turn 'em back on. */
1494 (*c)->access.set_intr_mask(*c, CCISS_INTR_ON);
1495 if (rc == 0)
1496 return SUCCESS;
1497 printk(KERN_WARNING "cciss%d: resetting device failed.\n", ctlr);
1498 return FAILED;
1499}
1500
1501static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd)
1502{
1503 int rc;
1504 CommandList_struct *cmd_to_abort;
1505 ctlr_info_t **c;
1506 int ctlr;
1507
1508 /* find the controller to which the command to be aborted was sent */
1509 c = (ctlr_info_t **) &scsicmd->device->host->hostdata[0];
1510 if (c == NULL) /* paranoia */
1511 return FAILED;
1512 ctlr = (*c)->ctlr;
1513 printk(KERN_WARNING "cciss%d: aborting tardy SCSI cmd\n", ctlr);
1514
1515 /* find the command to be aborted */
1516 cmd_to_abort = (CommandList_struct *) scsicmd->host_scribble;
1517 if (cmd_to_abort == NULL) /* paranoia */
1518 return FAILED;
1519 rc = sendcmd(CCISS_ABORT_MSG, ctlr, &cmd_to_abort->Header.Tag,
1520 0, 2, 0, 0,
1521 (unsigned char *) &cmd_to_abort->Header.LUN.LunAddrBytes[0],
1522 TYPE_MSG);
1523 /* sendcmd turned off interrputs on the board, turn 'em back on. */
1524 (*c)->access.set_intr_mask(*c, CCISS_INTR_ON);
1525 if (rc == 0)
1526 return SUCCESS;
1527 return FAILED;
1528
1529}
1530
1451#else /* no CONFIG_CISS_SCSI_TAPE */ 1531#else /* no CONFIG_CISS_SCSI_TAPE */
1452 1532
1453/* If no tape support, then these become defined out of existence */ 1533/* If no tape support, then these become defined out of existence */
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 28002de783b6..f7e765a1d313 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -98,6 +98,10 @@
98 */ 98 */
99 99
100/* 100/*
101 * 1998/1/21 -- Richard Gooch <rgooch@atnf.csiro.au> -- devfs support
102 */
103
104/*
101 * 1998/05/07 -- Russell King -- More portability cleanups; moved definition of 105 * 1998/05/07 -- Russell King -- More portability cleanups; moved definition of
102 * interrupt and dma channel to asm/floppy.h. Cleaned up some formatting & 106 * interrupt and dma channel to asm/floppy.h. Cleaned up some formatting &
103 * use of '0' for NULL. 107 * use of '0' for NULL.
@@ -158,10 +162,6 @@ static int print_unex = 1;
158#define FDPATCHES 162#define FDPATCHES
159#include <linux/fdreg.h> 163#include <linux/fdreg.h>
160 164
161/*
162 * 1998/1/21 -- Richard Gooch <rgooch@atnf.csiro.au> -- devfs support
163 */
164
165#include <linux/fd.h> 165#include <linux/fd.h>
166#include <linux/hdreg.h> 166#include <linux/hdreg.h>
167 167
@@ -3714,12 +3714,6 @@ static int floppy_open(struct inode *inode, struct file *filp)
3714 USETF(FD_VERIFY); 3714 USETF(FD_VERIFY);
3715 } 3715 }
3716 3716
3717 /* set underlying gendisk policy to reflect real ro/rw status */
3718 if (UTESTF(FD_DISK_WRITABLE))
3719 inode->i_bdev->bd_disk->policy = 0;
3720 else
3721 inode->i_bdev->bd_disk->policy = 1;
3722
3723 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL))) 3717 if (UDRS->fd_ref == -1 || (UDRS->fd_ref && (filp->f_flags & O_EXCL)))
3724 goto out2; 3718 goto out2;
3725 3719
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 59e5982a5db3..c0233efabeba 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -1188,7 +1188,7 @@ static void pkt_count_states(struct pktcdvd_device *pd, int *states)
1188 struct packet_data *pkt; 1188 struct packet_data *pkt;
1189 int i; 1189 int i;
1190 1190
1191 for (i = 0; i <= PACKET_NUM_STATES; i++) 1191 for (i = 0; i < PACKET_NUM_STATES; i++)
1192 states[i] = 0; 1192 states[i] = 0;
1193 1193
1194 spin_lock(&pd->cdrw.active_list_lock); 1194 spin_lock(&pd->cdrw.active_list_lock);
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index fdf4370db994..84e68cdd451b 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 && !PPC64 && !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,15 +983,6 @@ 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 || ARCH_S390
diff --git a/drivers/char/agp/ali-agp.c b/drivers/char/agp/ali-agp.c
index ba54b5872578..b02fc2267159 100644
--- a/drivers/char/agp/ali-agp.c
+++ b/drivers/char/agp/ali-agp.c
@@ -389,7 +389,6 @@ static struct pci_device_id agp_ali_pci_table[] = {
389MODULE_DEVICE_TABLE(pci, agp_ali_pci_table); 389MODULE_DEVICE_TABLE(pci, agp_ali_pci_table);
390 390
391static struct pci_driver agp_ali_pci_driver = { 391static struct pci_driver agp_ali_pci_driver = {
392 .owner = THIS_MODULE,
393 .name = "agpgart-ali", 392 .name = "agpgart-ali",
394 .id_table = agp_ali_pci_table, 393 .id_table = agp_ali_pci_table,
395 .probe = agp_ali_probe, 394 .probe = agp_ali_probe,
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c
index 40fcd88b2cea..1f776651ac64 100644
--- a/drivers/char/agp/amd-k7-agp.c
+++ b/drivers/char/agp/amd-k7-agp.c
@@ -515,7 +515,6 @@ static struct pci_device_id agp_amdk7_pci_table[] = {
515MODULE_DEVICE_TABLE(pci, agp_amdk7_pci_table); 515MODULE_DEVICE_TABLE(pci, agp_amdk7_pci_table);
516 516
517static struct pci_driver agp_amdk7_pci_driver = { 517static struct pci_driver agp_amdk7_pci_driver = {
518 .owner = THIS_MODULE,
519 .name = "agpgart-amdk7", 518 .name = "agpgart-amdk7",
520 .id_table = agp_amdk7_pci_table, 519 .id_table = agp_amdk7_pci_table,
521 .probe = agp_amdk7_probe, 520 .probe = agp_amdk7_probe,
diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 8f748fddca94..810679dcbbb0 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -57,9 +57,8 @@ static int nr_garts;
57static struct pci_dev * hammers[MAX_HAMMER_GARTS]; 57static struct pci_dev * hammers[MAX_HAMMER_GARTS];
58 58
59static struct resource *aperture_resource; 59static struct resource *aperture_resource;
60static int __initdata agp_try_unsupported; 60static int __initdata agp_try_unsupported = 1;
61 61
62static int gart_iterator;
63#define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++) 62#define for_each_nb() for(gart_iterator=0;gart_iterator<nr_garts;gart_iterator++)
64 63
65static void flush_amd64_tlb(struct pci_dev *dev) 64static void flush_amd64_tlb(struct pci_dev *dev)
@@ -73,6 +72,7 @@ static void flush_amd64_tlb(struct pci_dev *dev)
73 72
74static void amd64_tlbflush(struct agp_memory *temp) 73static void amd64_tlbflush(struct agp_memory *temp)
75{ 74{
75 int gart_iterator;
76 for_each_nb() 76 for_each_nb()
77 flush_amd64_tlb(hammers[gart_iterator]); 77 flush_amd64_tlb(hammers[gart_iterator]);
78} 78}
@@ -222,6 +222,7 @@ static struct aper_size_info_32 amd_8151_sizes[7] =
222static int amd_8151_configure(void) 222static int amd_8151_configure(void)
223{ 223{
224 unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real); 224 unsigned long gatt_bus = virt_to_gart(agp_bridge->gatt_table_real);
225 int gart_iterator;
225 226
226 /* Configure AGP regs in each x86-64 host bridge. */ 227 /* Configure AGP regs in each x86-64 host bridge. */
227 for_each_nb() { 228 for_each_nb() {
@@ -235,7 +236,7 @@ static int amd_8151_configure(void)
235static void amd64_cleanup(void) 236static void amd64_cleanup(void)
236{ 237{
237 u32 tmp; 238 u32 tmp;
238 239 int gart_iterator;
239 for_each_nb() { 240 for_each_nb() {
240 /* disable gart translation */ 241 /* disable gart translation */
241 pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp); 242 pci_read_config_dword (hammers[gart_iterator], AMD64_GARTAPERTURECTL, &tmp);
@@ -415,7 +416,7 @@ static void __devinit amd8151_init(struct pci_dev *pdev, struct agp_bridge_data
415} 416}
416 417
417 418
418static struct aper_size_info_32 uli_sizes[7] = 419static const struct aper_size_info_32 uli_sizes[7] =
419{ 420{
420 {256, 65536, 6, 10}, 421 {256, 65536, 6, 10},
421 {128, 32768, 5, 9}, 422 {128, 32768, 5, 9},
@@ -469,7 +470,7 @@ static int __devinit uli_agp_init(struct pci_dev *pdev)
469} 470}
470 471
471 472
472static struct aper_size_info_32 nforce3_sizes[5] = 473static const struct aper_size_info_32 nforce3_sizes[5] =
473{ 474{
474 {512, 131072, 7, 0x00000000 }, 475 {512, 131072, 7, 0x00000000 },
475 {256, 65536, 6, 0x00000008 }, 476 {256, 65536, 6, 0x00000008 },
@@ -697,13 +698,22 @@ static struct pci_device_id agp_amd64_pci_table[] = {
697 .subvendor = PCI_ANY_ID, 698 .subvendor = PCI_ANY_ID,
698 .subdevice = PCI_ANY_ID, 699 .subdevice = PCI_ANY_ID,
699 }, 700 },
701 /* ALI/ULI M1695 */
702 {
703 .class = (PCI_CLASS_BRIDGE_HOST << 8),
704 .class_mask = ~0,
705 .vendor = PCI_VENDOR_ID_AL,
706 .device = 0x1689,
707 .subvendor = PCI_ANY_ID,
708 .subdevice = PCI_ANY_ID,
709 },
710
700 { } 711 { }
701}; 712};
702 713
703MODULE_DEVICE_TABLE(pci, agp_amd64_pci_table); 714MODULE_DEVICE_TABLE(pci, agp_amd64_pci_table);
704 715
705static struct pci_driver agp_amd64_pci_driver = { 716static struct pci_driver agp_amd64_pci_driver = {
706 .owner = THIS_MODULE,
707 .name = "agpgart-amd64", 717 .name = "agpgart-amd64",
708 .id_table = agp_amd64_pci_table, 718 .id_table = agp_amd64_pci_table,
709 .probe = agp_amd64_probe, 719 .probe = agp_amd64_probe,
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
index fbd415565463..53372a83b675 100644
--- a/drivers/char/agp/ati-agp.c
+++ b/drivers/char/agp/ati-agp.c
@@ -521,7 +521,6 @@ static struct pci_device_id agp_ati_pci_table[] = {
521MODULE_DEVICE_TABLE(pci, agp_ati_pci_table); 521MODULE_DEVICE_TABLE(pci, agp_ati_pci_table);
522 522
523static struct pci_driver agp_ati_pci_driver = { 523static struct pci_driver agp_ati_pci_driver = {
524 .owner = THIS_MODULE,
525 .name = "agpgart-ati", 524 .name = "agpgart-ati",
526 .id_table = agp_ati_pci_table, 525 .id_table = agp_ati_pci_table,
527 .probe = agp_ati_probe, 526 .probe = agp_ati_probe,
diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index 27bca34b4a65..80ee17a8fc23 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -97,7 +97,7 @@ void agp_backend_release(struct agp_bridge_data *bridge)
97EXPORT_SYMBOL(agp_backend_release); 97EXPORT_SYMBOL(agp_backend_release);
98 98
99 99
100static struct { int mem, agp; } maxes_table[] = { 100static const struct { int mem, agp; } maxes_table[] = {
101 {0, 0}, 101 {0, 0},
102 {32, 4}, 102 {32, 4},
103 {64, 28}, 103 {64, 28},
diff --git a/drivers/char/agp/efficeon-agp.c b/drivers/char/agp/efficeon-agp.c
index d41e0a62e32e..e7aea77a60f9 100644
--- a/drivers/char/agp/efficeon-agp.c
+++ b/drivers/char/agp/efficeon-agp.c
@@ -429,7 +429,6 @@ static struct pci_device_id agp_efficeon_pci_table[] = {
429MODULE_DEVICE_TABLE(pci, agp_efficeon_pci_table); 429MODULE_DEVICE_TABLE(pci, agp_efficeon_pci_table);
430 430
431static struct pci_driver agp_efficeon_pci_driver = { 431static struct pci_driver agp_efficeon_pci_driver = {
432 .owner = THIS_MODULE,
433 .name = "agpgart-efficeon", 432 .name = "agpgart-efficeon",
434 .id_table = agp_efficeon_pci_table, 433 .id_table = agp_efficeon_pci_table,
435 .probe = agp_efficeon_probe, 434 .probe = agp_efficeon_probe,
diff --git a/drivers/char/agp/i460-agp.c b/drivers/char/agp/i460-agp.c
index 34a444658ffe..8ee19a4a6bce 100644
--- a/drivers/char/agp/i460-agp.c
+++ b/drivers/char/agp/i460-agp.c
@@ -622,7 +622,6 @@ static struct pci_device_id agp_intel_i460_pci_table[] = {
622MODULE_DEVICE_TABLE(pci, agp_intel_i460_pci_table); 622MODULE_DEVICE_TABLE(pci, agp_intel_i460_pci_table);
623 623
624static struct pci_driver agp_intel_i460_pci_driver = { 624static struct pci_driver agp_intel_i460_pci_driver = {
625 .owner = THIS_MODULE,
626 .name = "agpgart-intel-i460", 625 .name = "agpgart-intel-i460",
627 .id_table = agp_intel_i460_pci_table, 626 .id_table = agp_intel_i460_pci_table,
628 .probe = agp_intel_i460_probe, 627 .probe = agp_intel_i460_probe,
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c
index 027161ab88e9..e7bed5047dcc 100644
--- a/drivers/char/agp/intel-agp.c
+++ b/drivers/char/agp/intel-agp.c
@@ -1827,7 +1827,6 @@ static struct pci_device_id agp_intel_pci_table[] = {
1827MODULE_DEVICE_TABLE(pci, agp_intel_pci_table); 1827MODULE_DEVICE_TABLE(pci, agp_intel_pci_table);
1828 1828
1829static struct pci_driver agp_intel_pci_driver = { 1829static struct pci_driver agp_intel_pci_driver = {
1830 .owner = THIS_MODULE,
1831 .name = "agpgart-intel", 1830 .name = "agpgart-intel",
1832 .id_table = agp_intel_pci_table, 1831 .id_table = agp_intel_pci_table,
1833 .probe = agp_intel_probe, 1832 .probe = agp_intel_probe,
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 3aed0c5e2f92..80dafa3030bd 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -398,7 +398,6 @@ static struct pci_device_id agp_nvidia_pci_table[] = {
398MODULE_DEVICE_TABLE(pci, agp_nvidia_pci_table); 398MODULE_DEVICE_TABLE(pci, agp_nvidia_pci_table);
399 399
400static struct pci_driver agp_nvidia_pci_driver = { 400static struct pci_driver agp_nvidia_pci_driver = {
401 .owner = THIS_MODULE,
402 .name = "agpgart-nvidia", 401 .name = "agpgart-nvidia",
403 .id_table = agp_nvidia_pci_table, 402 .id_table = agp_nvidia_pci_table,
404 .probe = agp_nvidia_probe, 403 .probe = agp_nvidia_probe,
diff --git a/drivers/char/agp/sis-agp.c b/drivers/char/agp/sis-agp.c
index a701361a8890..ebc05554045c 100644
--- a/drivers/char/agp/sis-agp.c
+++ b/drivers/char/agp/sis-agp.c
@@ -332,7 +332,6 @@ static struct pci_device_id agp_sis_pci_table[] = {
332MODULE_DEVICE_TABLE(pci, agp_sis_pci_table); 332MODULE_DEVICE_TABLE(pci, agp_sis_pci_table);
333 333
334static struct pci_driver agp_sis_pci_driver = { 334static struct pci_driver agp_sis_pci_driver = {
335 .owner = THIS_MODULE,
336 .name = "agpgart-sis", 335 .name = "agpgart-sis",
337 .id_table = agp_sis_pci_table, 336 .id_table = agp_sis_pci_table,
338 .probe = agp_sis_probe, 337 .probe = agp_sis_probe,
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 5a5392dd1254..3f8f7fa6b0ff 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -545,7 +545,6 @@ static struct pci_device_id agp_serverworks_pci_table[] = {
545MODULE_DEVICE_TABLE(pci, agp_serverworks_pci_table); 545MODULE_DEVICE_TABLE(pci, agp_serverworks_pci_table);
546 546
547static struct pci_driver agp_serverworks_pci_driver = { 547static struct pci_driver agp_serverworks_pci_driver = {
548 .owner = THIS_MODULE,
549 .name = "agpgart-serverworks", 548 .name = "agpgart-serverworks",
550 .id_table = agp_serverworks_pci_table, 549 .id_table = agp_serverworks_pci_table,
551 .probe = agp_serverworks_probe, 550 .probe = agp_serverworks_probe,
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 183c50acab27..50947e38501a 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -557,6 +557,10 @@ static struct agp_device_ids uninorth_agp_device_ids[] __devinitdata = {
557 .device_id = PCI_DEVICE_ID_APPLE_U3H_AGP, 557 .device_id = PCI_DEVICE_ID_APPLE_U3H_AGP,
558 .chipset_name = "U3H", 558 .chipset_name = "U3H",
559 }, 559 },
560 {
561 .device_id = PCI_DEVICE_ID_APPLE_IPID2_AGP,
562 .chipset_name = "UniNorth/Intrepid2",
563 },
560}; 564};
561 565
562static int __devinit agp_uninorth_probe(struct pci_dev *pdev, 566static int __devinit agp_uninorth_probe(struct pci_dev *pdev,
@@ -658,7 +662,6 @@ static struct pci_device_id agp_uninorth_pci_table[] = {
658MODULE_DEVICE_TABLE(pci, agp_uninorth_pci_table); 662MODULE_DEVICE_TABLE(pci, agp_uninorth_pci_table);
659 663
660static struct pci_driver agp_uninorth_pci_driver = { 664static struct pci_driver agp_uninorth_pci_driver = {
661 .owner = THIS_MODULE,
662 .name = "agpgart-uninorth", 665 .name = "agpgart-uninorth",
663 .id_table = agp_uninorth_pci_table, 666 .id_table = agp_uninorth_pci_table,
664 .probe = agp_uninorth_probe, 667 .probe = agp_uninorth_probe,
diff --git a/drivers/char/agp/via-agp.c b/drivers/char/agp/via-agp.c
index 5d9a13700074..97b0a890ba7f 100644
--- a/drivers/char/agp/via-agp.c
+++ b/drivers/char/agp/via-agp.c
@@ -371,6 +371,11 @@ static struct agp_device_ids via_agp_device_ids[] __devinitdata =
371 .device_id = PCI_DEVICE_ID_VIA_3296_0, 371 .device_id = PCI_DEVICE_ID_VIA_3296_0,
372 .chipset_name = "P4M800", 372 .chipset_name = "P4M800",
373 }, 373 },
374 /* P4M800CE */
375 {
376 .device_id = PCI_DEVICE_ID_VIA_P4M800CE,
377 .chipset_name = "P4M800CE",
378 },
374 379
375 { }, /* dummy final entry, always present */ 380 { }, /* dummy final entry, always present */
376}; 381};
@@ -511,6 +516,7 @@ static struct pci_device_id agp_via_pci_table[] = {
511 ID(PCI_DEVICE_ID_VIA_3269_0), 516 ID(PCI_DEVICE_ID_VIA_3269_0),
512 ID(PCI_DEVICE_ID_VIA_83_87XX_1), 517 ID(PCI_DEVICE_ID_VIA_83_87XX_1),
513 ID(PCI_DEVICE_ID_VIA_3296_0), 518 ID(PCI_DEVICE_ID_VIA_3296_0),
519 ID(PCI_DEVICE_ID_VIA_P4M800CE),
514 { } 520 { }
515}; 521};
516 522
@@ -518,7 +524,6 @@ MODULE_DEVICE_TABLE(pci, agp_via_pci_table);
518 524
519 525
520static struct pci_driver agp_via_pci_driver = { 526static struct pci_driver agp_via_pci_driver = {
521 .owner = THIS_MODULE,
522 .name = "agpgart-via", 527 .name = "agpgart-via",
523 .id_table = agp_via_pci_table, 528 .id_table = agp_via_pci_table,
524 .probe = agp_via_probe, 529 .probe = agp_via_probe,
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index f970dc36c18f..f9e45303498d 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -104,8 +104,9 @@ int drm_lock(struct inode *inode, struct file *filp,
104 __set_current_state(TASK_RUNNING); 104 __set_current_state(TASK_RUNNING);
105 remove_wait_queue(&dev->lock.lock_queue, &entry); 105 remove_wait_queue(&dev->lock.lock_queue, &entry);
106 106
107 DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" ); 107 DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
108 if (ret) return ret; 108 if (ret)
109 return ret;
109 110
110 sigemptyset(&dev->sigmask); 111 sigemptyset(&dev->sigmask);
111 sigaddset(&dev->sigmask, SIGSTOP); 112 sigaddset(&dev->sigmask, SIGSTOP);
@@ -121,17 +122,19 @@ int drm_lock(struct inode *inode, struct file *filp,
121 122
122 if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) { 123 if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) {
123 if (dev->driver->dma_quiescent(dev)) { 124 if (dev->driver->dma_quiescent(dev)) {
124 DRM_DEBUG( "%d waiting for DMA quiescent\n", lock.context); 125 DRM_DEBUG("%d waiting for DMA quiescent\n", lock.context);
125 return DRM_ERR(EBUSY); 126 return DRM_ERR(EBUSY);
126 } 127 }
127 } 128 }
128 129
130 /* dev->driver->kernel_context_switch isn't used by any of the x86
131 * drivers but is used by the Sparc driver.
132 */
129 if (dev->driver->kernel_context_switch && 133 if (dev->driver->kernel_context_switch &&
130 dev->last_context != lock.context) { 134 dev->last_context != lock.context) {
131 dev->driver->kernel_context_switch(dev, dev->last_context, 135 dev->driver->kernel_context_switch(dev, dev->last_context,
132 lock.context); 136 lock.context);
133 } 137 }
134
135 return 0; 138 return 0;
136} 139}
137 140
diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c
index 7438741c29e9..8074771e348f 100644
--- a/drivers/char/drm/drm_memory.c
+++ b/drivers/char/drm/drm_memory.c
@@ -95,7 +95,7 @@ unsigned long drm_alloc_pages(int order, int area)
95 unsigned long addr; 95 unsigned long addr;
96 unsigned int sz; 96 unsigned int sz;
97 97
98 address = __get_free_pages(GFP_KERNEL, order); 98 address = __get_free_pages(GFP_KERNEL|__GFP_COMP, order);
99 if (!address) 99 if (!address)
100 return 0; 100 return 0;
101 101
diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h
index 706b75251ea1..e84605fc54af 100644
--- a/drivers/char/drm/drm_memory_debug.h
+++ b/drivers/char/drm/drm_memory_debug.h
@@ -220,7 +220,7 @@ unsigned long drm_alloc_pages (int order, int area) {
220 } 220 }
221 spin_unlock(&drm_mem_lock); 221 spin_unlock(&drm_mem_lock);
222 222
223 address = __get_free_pages(GFP_KERNEL, order); 223 address = __get_free_pages(GFP_KERNEL|__GFP_COMP, order);
224 if (!address) { 224 if (!address) {
225 spin_lock(&drm_mem_lock); 225 spin_lock(&drm_mem_lock);
226 ++drm_mem_stats[area].fail_count; 226 ++drm_mem_stats[area].fail_count;
diff --git a/drivers/char/drm/mga_drv.c b/drivers/char/drm/mga_drv.c
index 93f171e634c0..9f7ed0e0351b 100644
--- a/drivers/char/drm/mga_drv.c
+++ b/drivers/char/drm/mga_drv.c
@@ -131,7 +131,7 @@ static int mga_driver_device_is_agp(drm_device_t * dev)
131 * device. 131 * device.
132 */ 132 */
133 133
134 if ((pdev->device == 0x0525) 134 if ((pdev->device == 0x0525) && pdev->bus->self
135 && (pdev->bus->self->vendor == 0x3388) 135 && (pdev->bus->self->vendor == 0x3388)
136 && (pdev->bus->self->device == 0x0021)) { 136 && (pdev->bus->self->device == 0x0021)) {
137 return 0; 137 return 0;
diff --git a/drivers/char/drm/radeon_drv.h b/drivers/char/drm/radeon_drv.h
index 498b19b1d641..fac0d5196ce3 100644
--- a/drivers/char/drm/radeon_drv.h
+++ b/drivers/char/drm/radeon_drv.h
@@ -273,6 +273,7 @@ typedef struct drm_radeon_private {
273 273
274 /* starting from here on, data is preserved accross an open */ 274 /* starting from here on, data is preserved accross an open */
275 uint32_t flags; /* see radeon_chip_flags */ 275 uint32_t flags; /* see radeon_chip_flags */
276 int is_pci;
276} drm_radeon_private_t; 277} drm_radeon_private_t;
277 278
278typedef struct drm_radeon_buf_priv { 279typedef struct drm_radeon_buf_priv {
diff --git a/drivers/char/epca.c b/drivers/char/epca.c
index b7a0e4d6b934..407708a001e4 100644
--- a/drivers/char/epca.c
+++ b/drivers/char/epca.c
@@ -3113,7 +3113,6 @@ MODULE_DEVICE_TABLE(pci, epca_pci_tbl);
3113int __init init_PCI (void) 3113int __init init_PCI (void)
3114{ /* Begin init_PCI */ 3114{ /* Begin init_PCI */
3115 memset (&epca_driver, 0, sizeof (epca_driver)); 3115 memset (&epca_driver, 0, sizeof (epca_driver));
3116 epca_driver.owner = THIS_MODULE;
3117 epca_driver.name = "epca"; 3116 epca_driver.name = "epca";
3118 epca_driver.id_table = epca_pci_tbl; 3117 epca_driver.id_table = epca_pci_tbl;
3119 epca_driver.probe = epca_init_one; 3118 epca_driver.probe = epca_init_one;
diff --git a/drivers/char/ftape/lowlevel/ftape-buffer.c b/drivers/char/ftape/lowlevel/ftape-buffer.c
index 54af20cd9a2c..c706ff162771 100644
--- a/drivers/char/ftape/lowlevel/ftape-buffer.c
+++ b/drivers/char/ftape/lowlevel/ftape-buffer.c
@@ -33,6 +33,7 @@
33#include "../lowlevel/ftape-rw.h" 33#include "../lowlevel/ftape-rw.h"
34#include "../lowlevel/ftape-read.h" 34#include "../lowlevel/ftape-read.h"
35#include "../lowlevel/ftape-tracing.h" 35#include "../lowlevel/ftape-tracing.h"
36#include "../lowlevel/ftape-buffer.h"
36 37
37/* DMA'able memory allocation stuff. 38/* DMA'able memory allocation stuff.
38 */ 39 */
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index 6c4b3f986d0c..f3c3aaf4560e 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -99,7 +99,9 @@ struct smm_regs {
99 99
100static inline char *i8k_get_dmi_data(int field) 100static inline char *i8k_get_dmi_data(int field)
101{ 101{
102 return dmi_get_system_info(field) ? : "N/A"; 102 char *dmi_data = dmi_get_system_info(field);
103
104 return dmi_data && *dmi_data ? dmi_data : "?";
103} 105}
104 106
105/* 107/*
@@ -396,7 +398,7 @@ static int i8k_proc_show(struct seq_file *seq, void *offset)
396 return seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n", 398 return seq_printf(seq, "%s %s %s %d %d %d %d %d %d %d\n",
397 I8K_PROC_FMT, 399 I8K_PROC_FMT,
398 bios_version, 400 bios_version,
399 dmi_get_system_info(DMI_PRODUCT_SERIAL) ? : "N/A", 401 i8k_get_dmi_data(DMI_PRODUCT_SERIAL),
400 cpu_temp, 402 cpu_temp,
401 left_fan, right_fan, left_speed, right_speed, 403 left_fan, right_fan, left_speed, right_speed,
402 ac_power, fn_key); 404 ac_power, fn_key);
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index c1d06ba449b6..1f56b4cf0f58 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -48,7 +48,7 @@
48 48
49#define PFX "IPMI message handler: " 49#define PFX "IPMI message handler: "
50 50
51#define IPMI_DRIVER_VERSION "36.0" 51#define IPMI_DRIVER_VERSION "38.0"
52 52
53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void); 53static struct ipmi_recv_msg *ipmi_alloc_recv_msg(void);
54static int ipmi_init_msghandler(void); 54static int ipmi_init_msghandler(void);
@@ -2648,7 +2648,7 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
2648 spin_lock_irqsave(&intf->waiting_msgs_lock, flags); 2648 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
2649 if (!list_empty(&intf->waiting_msgs)) { 2649 if (!list_empty(&intf->waiting_msgs)) {
2650 list_add_tail(&msg->link, &intf->waiting_msgs); 2650 list_add_tail(&msg->link, &intf->waiting_msgs);
2651 spin_unlock(&intf->waiting_msgs_lock); 2651 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
2652 goto out; 2652 goto out;
2653 } 2653 }
2654 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags); 2654 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
@@ -2657,9 +2657,9 @@ void ipmi_smi_msg_received(ipmi_smi_t intf,
2657 if (rv > 0) { 2657 if (rv > 0) {
2658 /* Could not handle the message now, just add it to a 2658 /* Could not handle the message now, just add it to a
2659 list to handle later. */ 2659 list to handle later. */
2660 spin_lock(&intf->waiting_msgs_lock); 2660 spin_lock_irqsave(&intf->waiting_msgs_lock, flags);
2661 list_add_tail(&msg->link, &intf->waiting_msgs); 2661 list_add_tail(&msg->link, &intf->waiting_msgs);
2662 spin_unlock(&intf->waiting_msgs_lock); 2662 spin_unlock_irqrestore(&intf->waiting_msgs_lock, flags);
2663 } else if (rv == 0) { 2663 } else if (rv == 0) {
2664 ipmi_free_smi_msg(msg); 2664 ipmi_free_smi_msg(msg);
2665 } 2665 }
@@ -2986,7 +2986,7 @@ static void send_panic_events(char *str)
2986 msg.cmd = 2; /* Platform event command. */ 2986 msg.cmd = 2; /* Platform event command. */
2987 msg.data = data; 2987 msg.data = data;
2988 msg.data_len = 8; 2988 msg.data_len = 8;
2989 data[0] = 0x21; /* Kernel generator ID, IPMI table 5-4 */ 2989 data[0] = 0x41; /* Kernel generator ID, IPMI table 5-4 */
2990 data[1] = 0x03; /* This is for IPMI 1.0. */ 2990 data[1] = 0x03; /* This is for IPMI 1.0. */
2991 data[2] = 0x20; /* OS Critical Stop, IPMI table 36-3 */ 2991 data[2] = 0x20; /* OS Critical Stop, IPMI table 36-3 */
2992 data[4] = 0x6f; /* Sensor specific, IPMI table 36-1 */ 2992 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 ea89dca3dbb5..beea450ee4b2 100644
--- a/drivers/char/ipmi/ipmi_si_intf.c
+++ b/drivers/char/ipmi/ipmi_si_intf.c
@@ -2203,7 +2203,7 @@ static void setup_xaction_handlers(struct smi_info *smi_info)
2203 2203
2204static inline void wait_for_timer_and_thread(struct smi_info *smi_info) 2204static inline void wait_for_timer_and_thread(struct smi_info *smi_info)
2205{ 2205{
2206 if (smi_info->thread != ERR_PTR(-ENOMEM)) 2206 if (smi_info->thread != NULL && smi_info->thread != ERR_PTR(-ENOMEM))
2207 kthread_stop(smi_info->thread); 2207 kthread_stop(smi_info->thread);
2208 del_timer_sync(&smi_info->si_timer); 2208 del_timer_sync(&smi_info->si_timer);
2209} 2209}
@@ -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/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/pcmcia/Kconfig b/drivers/char/pcmcia/Kconfig
index d22bfdc13563..27c1179ee527 100644
--- a/drivers/char/pcmcia/Kconfig
+++ b/drivers/char/pcmcia/Kconfig
@@ -18,5 +18,29 @@ config SYNCLINK_CS
18 The module will be called synclinkmp. If you want to do that, say M 18 The module will be called synclinkmp. If you want to do that, say M
19 here. 19 here.
20 20
21config CARDMAN_4000
22 tristate "Omnikey Cardman 4000 support"
23 depends on PCMCIA
24 help
25 Enable support for the Omnikey Cardman 4000 PCMCIA Smartcard
26 reader.
27
28 This kernel driver requires additional userspace support, either
29 by the vendor-provided PC/SC ifd_handler (http://www.omnikey.com/),
30 or via the cm4000 backend of OpenCT (http://www.opensc.com/).
31
32config CARDMAN_4040
33 tristate "Omnikey CardMan 4040 support"
34 depends on PCMCIA
35 help
36 Enable support for the Omnikey CardMan 4040 PCMCIA Smartcard
37 reader.
38
39 This card is basically a USB CCID device connected to a FIFO
40 in I/O space. To use the kernel driver, you will need either the
41 PC/SC ifdhandler provided from the Omnikey homepage
42 (http://www.omnikey.com/), or a current development version of OpenCT
43 (http://www.opensc.org/).
44
21endmenu 45endmenu
22 46
diff --git a/drivers/char/pcmcia/Makefile b/drivers/char/pcmcia/Makefile
index 1fcd4c591958..0aae20985d57 100644
--- a/drivers/char/pcmcia/Makefile
+++ b/drivers/char/pcmcia/Makefile
@@ -5,3 +5,5 @@
5# 5#
6 6
7obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o 7obj-$(CONFIG_SYNCLINK_CS) += synclink_cs.o
8obj-$(CONFIG_CARDMAN_4000) += cm4000_cs.o
9obj-$(CONFIG_CARDMAN_4040) += cm4040_cs.o
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
new file mode 100644
index 000000000000..61681c9f3f72
--- /dev/null
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -0,0 +1,2079 @@
1 /*
2 * A driver for the PCMCIA Smartcard Reader "Omnikey CardMan Mobile 4000"
3 *
4 * cm4000_cs.c support.linux@omnikey.com
5 *
6 * Tue Oct 23 11:32:43 GMT 2001 herp - cleaned up header files
7 * Sun Jan 20 10:11:15 MET 2002 herp - added modversion header files
8 * Thu Nov 14 16:34:11 GMT 2002 mh - added PPS functionality
9 * Tue Nov 19 16:36:27 GMT 2002 mh - added SUSPEND/RESUME functionailty
10 * Wed Jul 28 12:55:01 CEST 2004 mh - kernel 2.6 adjustments
11 *
12 * current version: 2.4.0gm4
13 *
14 * (C) 2000,2001,2002,2003,2004 Omnikey AG
15 *
16 * (C) 2005 Harald Welte <laforge@gnumonks.org>
17 * - Adhere to Kernel CodingStyle
18 * - Port to 2.6.13 "new" style PCMCIA
19 * - Check for copy_{from,to}_user return values
20 * - Use nonseekable_open()
21 *
22 * All rights reserved. Licensed under dual BSD/GPL license.
23 */
24
25/* #define PCMCIA_DEBUG 6 */
26
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/slab.h>
30#include <linux/init.h>
31#include <linux/fs.h>
32#include <linux/delay.h>
33#include <asm/uaccess.h>
34#include <asm/io.h>
35
36#include <pcmcia/cs_types.h>
37#include <pcmcia/cs.h>
38#include <pcmcia/cistpl.h>
39#include <pcmcia/cisreg.h>
40#include <pcmcia/ciscode.h>
41#include <pcmcia/ds.h>
42
43#include <linux/cm4000_cs.h>
44
45/* #define ATR_CSUM */
46
47#ifdef PCMCIA_DEBUG
48#define reader_to_dev(x) (&handle_to_dev(x->link.handle))
49static int pc_debug = PCMCIA_DEBUG;
50module_param(pc_debug, int, 0600);
51#define DEBUGP(n, rdr, x, args...) do { \
52 if (pc_debug >= (n)) \
53 dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \
54 __FUNCTION__ , ## args); \
55 } while (0)
56#else
57#define DEBUGP(n, rdr, x, args...)
58#endif
59static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte";
60
61#define T_1SEC (HZ)
62#define T_10MSEC msecs_to_jiffies(10)
63#define T_20MSEC msecs_to_jiffies(20)
64#define T_40MSEC msecs_to_jiffies(40)
65#define T_50MSEC msecs_to_jiffies(50)
66#define T_100MSEC msecs_to_jiffies(100)
67#define T_500MSEC msecs_to_jiffies(500)
68
69static void cm4000_detach(dev_link_t *link);
70static void cm4000_release(dev_link_t *link);
71
72static int major; /* major number we get from the kernel */
73
74/* note: the first state has to have number 0 always */
75
76#define M_FETCH_ATR 0
77#define M_TIMEOUT_WAIT 1
78#define M_READ_ATR_LEN 2
79#define M_READ_ATR 3
80#define M_ATR_PRESENT 4
81#define M_BAD_CARD 5
82#define M_CARDOFF 6
83
84#define LOCK_IO 0
85#define LOCK_MONITOR 1
86
87#define IS_AUTOPPS_ACT 6
88#define IS_PROCBYTE_PRESENT 7
89#define IS_INVREV 8
90#define IS_ANY_T0 9
91#define IS_ANY_T1 10
92#define IS_ATR_PRESENT 11
93#define IS_ATR_VALID 12
94#define IS_CMM_ABSENT 13
95#define IS_BAD_LENGTH 14
96#define IS_BAD_CSUM 15
97#define IS_BAD_CARD 16
98
99#define REG_FLAGS0(x) (x + 0)
100#define REG_FLAGS1(x) (x + 1)
101#define REG_NUM_BYTES(x) (x + 2)
102#define REG_BUF_ADDR(x) (x + 3)
103#define REG_BUF_DATA(x) (x + 4)
104#define REG_NUM_SEND(x) (x + 5)
105#define REG_BAUDRATE(x) (x + 6)
106#define REG_STOPBITS(x) (x + 7)
107
108struct cm4000_dev {
109 dev_link_t link; /* pcmcia link */
110 dev_node_t node; /* OS node (major,minor) */
111
112 unsigned char atr[MAX_ATR];
113 unsigned char rbuf[512];
114 unsigned char sbuf[512];
115
116 wait_queue_head_t devq; /* when removing cardman must not be
117 zeroed! */
118
119 wait_queue_head_t ioq; /* if IO is locked, wait on this Q */
120 wait_queue_head_t atrq; /* wait for ATR valid */
121 wait_queue_head_t readq; /* used by write to wake blk.read */
122
123 /* warning: do not move this fields.
124 * initialising to zero depends on it - see ZERO_DEV below. */
125 unsigned char atr_csum;
126 unsigned char atr_len_retry;
127 unsigned short atr_len;
128 unsigned short rlen; /* bytes avail. after write */
129 unsigned short rpos; /* latest read pos. write zeroes */
130 unsigned char procbyte; /* T=0 procedure byte */
131 unsigned char mstate; /* state of card monitor */
132 unsigned char cwarn; /* slow down warning */
133 unsigned char flags0; /* cardman IO-flags 0 */
134 unsigned char flags1; /* cardman IO-flags 1 */
135 unsigned int mdelay; /* variable monitor speeds, in jiffies */
136
137 unsigned int baudv; /* baud value for speed */
138 unsigned char ta1;
139 unsigned char proto; /* T=0, T=1, ... */
140 unsigned long flags; /* lock+flags (MONITOR,IO,ATR) * for concurrent
141 access */
142
143 unsigned char pts[4];
144
145 struct timer_list timer; /* used to keep monitor running */
146 int monitor_running;
147};
148
149#define ZERO_DEV(dev) \
150 memset(&dev->atr_csum,0, \
151 sizeof(struct cm4000_dev) - \
152 /*link*/ sizeof(dev_link_t) - \
153 /*node*/ sizeof(dev_node_t) - \
154 /*atr*/ MAX_ATR*sizeof(char) - \
155 /*rbuf*/ 512*sizeof(char) - \
156 /*sbuf*/ 512*sizeof(char) - \
157 /*queue*/ 4*sizeof(wait_queue_head_t))
158
159static dev_info_t dev_info = MODULE_NAME;
160static dev_link_t *dev_table[CM4000_MAX_DEV];
161
162/* This table doesn't use spaces after the comma between fields and thus
163 * violates CodingStyle. However, I don't really think wrapping it around will
164 * make it any clearer to read -HW */
165static unsigned char fi_di_table[10][14] = {
166/*FI 00 01 02 03 04 05 06 07 08 09 10 11 12 13 */
167/*DI */
168/* 0 */ {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
169/* 1 */ {0x01,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x91,0x11,0x11,0x11,0x11},
170/* 2 */ {0x02,0x12,0x22,0x32,0x11,0x11,0x11,0x11,0x11,0x92,0xA2,0xB2,0x11,0x11},
171/* 3 */ {0x03,0x13,0x23,0x33,0x43,0x53,0x63,0x11,0x11,0x93,0xA3,0xB3,0xC3,0xD3},
172/* 4 */ {0x04,0x14,0x24,0x34,0x44,0x54,0x64,0x11,0x11,0x94,0xA4,0xB4,0xC4,0xD4},
173/* 5 */ {0x00,0x15,0x25,0x35,0x45,0x55,0x65,0x11,0x11,0x95,0xA5,0xB5,0xC5,0xD5},
174/* 6 */ {0x06,0x16,0x26,0x36,0x46,0x56,0x66,0x11,0x11,0x96,0xA6,0xB6,0xC6,0xD6},
175/* 7 */ {0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11},
176/* 8 */ {0x08,0x11,0x28,0x38,0x48,0x58,0x68,0x11,0x11,0x98,0xA8,0xB8,0xC8,0xD8},
177/* 9 */ {0x09,0x19,0x29,0x39,0x49,0x59,0x69,0x11,0x11,0x99,0xA9,0xB9,0xC9,0xD9}
178};
179
180#ifndef PCMCIA_DEBUG
181#define xoutb outb
182#define xinb inb
183#else
184static inline void xoutb(unsigned char val, unsigned short port)
185{
186 if (pc_debug >= 7)
187 printk(KERN_DEBUG "outb(val=%.2x,port=%.4x)\n", val, port);
188 outb(val, port);
189}
190static inline unsigned char xinb(unsigned short port)
191{
192 unsigned char val;
193
194 val = inb(port);
195 if (pc_debug >= 7)
196 printk(KERN_DEBUG "%.2x=inb(%.4x)\n", val, port);
197
198 return val;
199}
200#endif
201
202#define b_0000 15
203#define b_0001 14
204#define b_0010 13
205#define b_0011 12
206#define b_0100 11
207#define b_0101 10
208#define b_0110 9
209#define b_0111 8
210#define b_1000 7
211#define b_1001 6
212#define b_1010 5
213#define b_1011 4
214#define b_1100 3
215#define b_1101 2
216#define b_1110 1
217#define b_1111 0
218
219static unsigned char irtab[16] = {
220 b_0000, b_1000, b_0100, b_1100,
221 b_0010, b_1010, b_0110, b_1110,
222 b_0001, b_1001, b_0101, b_1101,
223 b_0011, b_1011, b_0111, b_1111
224};
225
226static void str_invert_revert(unsigned char *b, int len)
227{
228 int i;
229
230 for (i = 0; i < len; i++)
231 b[i] = (irtab[b[i] & 0x0f] << 4) | irtab[b[i] >> 4];
232}
233
234static unsigned char invert_revert(unsigned char ch)
235{
236 return (irtab[ch & 0x0f] << 4) | irtab[ch >> 4];
237}
238
239#define ATRLENCK(dev,pos) \
240 if (pos>=dev->atr_len || pos>=MAX_ATR) \
241 goto return_0;
242
243static unsigned int calc_baudv(unsigned char fidi)
244{
245 unsigned int wcrcf, wbrcf, fi_rfu, di_rfu;
246
247 fi_rfu = 372;
248 di_rfu = 1;
249
250 /* FI */
251 switch ((fidi >> 4) & 0x0F) {
252 case 0x00:
253 wcrcf = 372;
254 break;
255 case 0x01:
256 wcrcf = 372;
257 break;
258 case 0x02:
259 wcrcf = 558;
260 break;
261 case 0x03:
262 wcrcf = 744;
263 break;
264 case 0x04:
265 wcrcf = 1116;
266 break;
267 case 0x05:
268 wcrcf = 1488;
269 break;
270 case 0x06:
271 wcrcf = 1860;
272 break;
273 case 0x07:
274 wcrcf = fi_rfu;
275 break;
276 case 0x08:
277 wcrcf = fi_rfu;
278 break;
279 case 0x09:
280 wcrcf = 512;
281 break;
282 case 0x0A:
283 wcrcf = 768;
284 break;
285 case 0x0B:
286 wcrcf = 1024;
287 break;
288 case 0x0C:
289 wcrcf = 1536;
290 break;
291 case 0x0D:
292 wcrcf = 2048;
293 break;
294 default:
295 wcrcf = fi_rfu;
296 break;
297 }
298
299 /* DI */
300 switch (fidi & 0x0F) {
301 case 0x00:
302 wbrcf = di_rfu;
303 break;
304 case 0x01:
305 wbrcf = 1;
306 break;
307 case 0x02:
308 wbrcf = 2;
309 break;
310 case 0x03:
311 wbrcf = 4;
312 break;
313 case 0x04:
314 wbrcf = 8;
315 break;
316 case 0x05:
317 wbrcf = 16;
318 break;
319 case 0x06:
320 wbrcf = 32;
321 break;
322 case 0x07:
323 wbrcf = di_rfu;
324 break;
325 case 0x08:
326 wbrcf = 12;
327 break;
328 case 0x09:
329 wbrcf = 20;
330 break;
331 default:
332 wbrcf = di_rfu;
333 break;
334 }
335
336 return (wcrcf / wbrcf);
337}
338
339static unsigned short io_read_num_rec_bytes(ioaddr_t iobase, unsigned short *s)
340{
341 unsigned short tmp;
342
343 tmp = *s = 0;
344 do {
345 *s = tmp;
346 tmp = inb(REG_NUM_BYTES(iobase)) |
347 (inb(REG_FLAGS0(iobase)) & 4 ? 0x100 : 0);
348 } while (tmp != *s);
349
350 return *s;
351}
352
353static int parse_atr(struct cm4000_dev *dev)
354{
355 unsigned char any_t1, any_t0;
356 unsigned char ch, ifno;
357 int ix, done;
358
359 DEBUGP(3, dev, "-> parse_atr: dev->atr_len = %i\n", dev->atr_len);
360
361 if (dev->atr_len < 3) {
362 DEBUGP(5, dev, "parse_atr: atr_len < 3\n");
363 return 0;
364 }
365
366 if (dev->atr[0] == 0x3f)
367 set_bit(IS_INVREV, &dev->flags);
368 else
369 clear_bit(IS_INVREV, &dev->flags);
370 ix = 1;
371 ifno = 1;
372 ch = dev->atr[1];
373 dev->proto = 0; /* XXX PROTO */
374 any_t1 = any_t0 = done = 0;
375 dev->ta1 = 0x11; /* defaults to 9600 baud */
376 do {
377 if (ifno == 1 && (ch & 0x10)) {
378 /* read first interface byte and TA1 is present */
379 dev->ta1 = dev->atr[2];
380 DEBUGP(5, dev, "Card says FiDi is 0x%.2x\n", dev->ta1);
381 ifno++;
382 } else if ((ifno == 2) && (ch & 0x10)) { /* TA(2) */
383 dev->ta1 = 0x11;
384 ifno++;
385 }
386
387 DEBUGP(5, dev, "Yi=%.2x\n", ch & 0xf0);
388 ix += ((ch & 0x10) >> 4) /* no of int.face chars */
389 +((ch & 0x20) >> 5)
390 + ((ch & 0x40) >> 6)
391 + ((ch & 0x80) >> 7);
392 /* ATRLENCK(dev,ix); */
393 if (ch & 0x80) { /* TDi */
394 ch = dev->atr[ix];
395 if ((ch & 0x0f)) {
396 any_t1 = 1;
397 DEBUGP(5, dev, "card is capable of T=1\n");
398 } else {
399 any_t0 = 1;
400 DEBUGP(5, dev, "card is capable of T=0\n");
401 }
402 } else
403 done = 1;
404 } while (!done);
405
406 DEBUGP(5, dev, "ix=%d noHist=%d any_t1=%d\n",
407 ix, dev->atr[1] & 15, any_t1);
408 if (ix + 1 + (dev->atr[1] & 0x0f) + any_t1 != dev->atr_len) {
409 DEBUGP(5, dev, "length error\n");
410 return 0;
411 }
412 if (any_t0)
413 set_bit(IS_ANY_T0, &dev->flags);
414
415 if (any_t1) { /* compute csum */
416 dev->atr_csum = 0;
417#ifdef ATR_CSUM
418 for (i = 1; i < dev->atr_len; i++)
419 dev->atr_csum ^= dev->atr[i];
420 if (dev->atr_csum) {
421 set_bit(IS_BAD_CSUM, &dev->flags);
422 DEBUGP(5, dev, "bad checksum\n");
423 goto return_0;
424 }
425#endif
426 if (any_t0 == 0)
427 dev->proto = 1; /* XXX PROTO */
428 set_bit(IS_ANY_T1, &dev->flags);
429 }
430
431 return 1;
432}
433
434struct card_fixup {
435 char atr[12];
436 u_int8_t atr_len;
437 u_int8_t stopbits;
438};
439
440static struct card_fixup card_fixups[] = {
441 { /* ACOS */
442 .atr = { 0x3b, 0xb3, 0x11, 0x00, 0x00, 0x41, 0x01 },
443 .atr_len = 7,
444 .stopbits = 0x03,
445 },
446 { /* Motorola */
447 .atr = {0x3b, 0x76, 0x13, 0x00, 0x00, 0x80, 0x62, 0x07,
448 0x41, 0x81, 0x81 },
449 .atr_len = 11,
450 .stopbits = 0x04,
451 },
452};
453
454static void set_cardparameter(struct cm4000_dev *dev)
455{
456 int i;
457 ioaddr_t iobase = dev->link.io.BasePort1;
458 u_int8_t stopbits = 0x02; /* ISO default */
459
460 DEBUGP(3, dev, "-> set_cardparameter\n");
461
462 dev->flags1 = dev->flags1 | (((dev->baudv - 1) & 0x0100) >> 8);
463 xoutb(dev->flags1, REG_FLAGS1(iobase));
464 DEBUGP(5, dev, "flags1 = 0x%02x\n", dev->flags1);
465
466 /* set baudrate */
467 xoutb((unsigned char)((dev->baudv - 1) & 0xFF), REG_BAUDRATE(iobase));
468
469 DEBUGP(5, dev, "baudv = %i -> write 0x%02x\n", dev->baudv,
470 ((dev->baudv - 1) & 0xFF));
471
472 /* set stopbits */
473 for (i = 0; i < ARRAY_SIZE(card_fixups); i++) {
474 if (!memcmp(dev->atr, card_fixups[i].atr,
475 card_fixups[i].atr_len))
476 stopbits = card_fixups[i].stopbits;
477 }
478 xoutb(stopbits, REG_STOPBITS(iobase));
479
480 DEBUGP(3, dev, "<- set_cardparameter\n");
481}
482
483static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
484{
485
486 unsigned long tmp, i;
487 unsigned short num_bytes_read;
488 unsigned char pts_reply[4];
489 ssize_t rc;
490 ioaddr_t iobase = dev->link.io.BasePort1;
491
492 rc = 0;
493
494 DEBUGP(3, dev, "-> set_protocol\n");
495 DEBUGP(5, dev, "ptsreq->Protocol = 0x%.8x, ptsreq->Flags=0x%.8x, "
496 "ptsreq->pts1=0x%.2x, ptsreq->pts2=0x%.2x, "
497 "ptsreq->pts3=0x%.2x\n", (unsigned int)ptsreq->protocol,
498 (unsigned int)ptsreq->flags, ptsreq->pts1, ptsreq->pts2,
499 ptsreq->pts3);
500
501 /* Fill PTS structure */
502 dev->pts[0] = 0xff;
503 dev->pts[1] = 0x00;
504 tmp = ptsreq->protocol;
505 while ((tmp = (tmp >> 1)) > 0)
506 dev->pts[1]++;
507 dev->proto = dev->pts[1]; /* Set new protocol */
508 dev->pts[1] = (0x01 << 4) | (dev->pts[1]);
509
510 /* Correct Fi/Di according to CM4000 Fi/Di table */
511 DEBUGP(5, dev, "Ta(1) from ATR is 0x%.2x\n", dev->ta1);
512 /* set Fi/Di according to ATR TA(1) */
513 dev->pts[2] = fi_di_table[dev->ta1 & 0x0F][(dev->ta1 >> 4) & 0x0F];
514
515 /* Calculate PCK character */
516 dev->pts[3] = dev->pts[0] ^ dev->pts[1] ^ dev->pts[2];
517
518 DEBUGP(5, dev, "pts0=%.2x, pts1=%.2x, pts2=%.2x, pts3=%.2x\n",
519 dev->pts[0], dev->pts[1], dev->pts[2], dev->pts[3]);
520
521 /* check card convention */
522 if (test_bit(IS_INVREV, &dev->flags))
523 str_invert_revert(dev->pts, 4);
524
525 /* reset SM */
526 xoutb(0x80, REG_FLAGS0(iobase));
527
528 /* Enable access to the message buffer */
529 DEBUGP(5, dev, "Enable access to the messages buffer\n");
530 dev->flags1 = 0x20 /* T_Active */
531 | (test_bit(IS_INVREV, &dev->flags) ? 0x02 : 0x00) /* inv parity */
532 | ((dev->baudv >> 8) & 0x01); /* MSB-baud */
533 xoutb(dev->flags1, REG_FLAGS1(iobase));
534
535 DEBUGP(5, dev, "Enable message buffer -> flags1 = 0x%.2x\n",
536 dev->flags1);
537
538 /* write challenge to the buffer */
539 DEBUGP(5, dev, "Write challenge to buffer: ");
540 for (i = 0; i < 4; i++) {
541 xoutb(i, REG_BUF_ADDR(iobase));
542 xoutb(dev->pts[i], REG_BUF_DATA(iobase)); /* buf data */
543#ifdef PCMCIA_DEBUG
544 if (pc_debug >= 5)
545 printk("0x%.2x ", dev->pts[i]);
546 }
547 if (pc_debug >= 5)
548 printk("\n");
549#else
550 }
551#endif
552
553 /* set number of bytes to write */
554 DEBUGP(5, dev, "Set number of bytes to write\n");
555 xoutb(0x04, REG_NUM_SEND(iobase));
556
557 /* Trigger CARDMAN CONTROLLER */
558 xoutb(0x50, REG_FLAGS0(iobase));
559
560 /* Monitor progress */
561 /* wait for xmit done */
562 DEBUGP(5, dev, "Waiting for NumRecBytes getting valid\n");
563
564 for (i = 0; i < 100; i++) {
565 if (inb(REG_FLAGS0(iobase)) & 0x08) {
566 DEBUGP(5, dev, "NumRecBytes is valid\n");
567 break;
568 }
569 mdelay(10);
570 }
571 if (i == 100) {
572 DEBUGP(5, dev, "Timeout waiting for NumRecBytes getting "
573 "valid\n");
574 rc = -EIO;
575 goto exit_setprotocol;
576 }
577
578 DEBUGP(5, dev, "Reading NumRecBytes\n");
579 for (i = 0; i < 100; i++) {
580 io_read_num_rec_bytes(iobase, &num_bytes_read);
581 if (num_bytes_read >= 4) {
582 DEBUGP(2, dev, "NumRecBytes = %i\n", num_bytes_read);
583 break;
584 }
585 mdelay(10);
586 }
587
588 /* check whether it is a short PTS reply? */
589 if (num_bytes_read == 3)
590 i = 0;
591
592 if (i == 100) {
593 DEBUGP(5, dev, "Timeout reading num_bytes_read\n");
594 rc = -EIO;
595 goto exit_setprotocol;
596 }
597
598 DEBUGP(5, dev, "Reset the CARDMAN CONTROLLER\n");
599 xoutb(0x80, REG_FLAGS0(iobase));
600
601 /* Read PPS reply */
602 DEBUGP(5, dev, "Read PPS reply\n");
603 for (i = 0; i < num_bytes_read; i++) {
604 xoutb(i, REG_BUF_ADDR(iobase));
605 pts_reply[i] = inb(REG_BUF_DATA(iobase));
606 }
607
608#ifdef PCMCIA_DEBUG
609 DEBUGP(2, dev, "PTSreply: ");
610 for (i = 0; i < num_bytes_read; i++) {
611 if (pc_debug >= 5)
612 printk("0x%.2x ", pts_reply[i]);
613 }
614 printk("\n");
615#endif /* PCMCIA_DEBUG */
616
617 DEBUGP(5, dev, "Clear Tactive in Flags1\n");
618 xoutb(0x20, REG_FLAGS1(iobase));
619
620 /* Compare ptsreq and ptsreply */
621 if ((dev->pts[0] == pts_reply[0]) &&
622 (dev->pts[1] == pts_reply[1]) &&
623 (dev->pts[2] == pts_reply[2]) && (dev->pts[3] == pts_reply[3])) {
624 /* setcardparameter according to PPS */
625 dev->baudv = calc_baudv(dev->pts[2]);
626 set_cardparameter(dev);
627 } else if ((dev->pts[0] == pts_reply[0]) &&
628 ((dev->pts[1] & 0xef) == pts_reply[1]) &&
629 ((pts_reply[0] ^ pts_reply[1]) == pts_reply[2])) {
630 /* short PTS reply, set card parameter to default values */
631 dev->baudv = calc_baudv(0x11);
632 set_cardparameter(dev);
633 } else
634 rc = -EIO;
635
636exit_setprotocol:
637 DEBUGP(3, dev, "<- set_protocol\n");
638 return rc;
639}
640
641static int io_detect_cm4000(ioaddr_t iobase, struct cm4000_dev *dev)
642{
643
644 /* note: statemachine is assumed to be reset */
645 if (inb(REG_FLAGS0(iobase)) & 8) {
646 clear_bit(IS_ATR_VALID, &dev->flags);
647 set_bit(IS_CMM_ABSENT, &dev->flags);
648 return 0; /* detect CMM = 1 -> failure */
649 }
650 /* xoutb(0x40, REG_FLAGS1(iobase)); detectCMM */
651 xoutb(dev->flags1 | 0x40, REG_FLAGS1(iobase));
652 if ((inb(REG_FLAGS0(iobase)) & 8) == 0) {
653 clear_bit(IS_ATR_VALID, &dev->flags);
654 set_bit(IS_CMM_ABSENT, &dev->flags);
655 return 0; /* detect CMM=0 -> failure */
656 }
657 /* clear detectCMM again by restoring original flags1 */
658 xoutb(dev->flags1, REG_FLAGS1(iobase));
659 return 1;
660}
661
662static void terminate_monitor(struct cm4000_dev *dev)
663{
664
665 /* tell the monitor to stop and wait until
666 * it terminates.
667 */
668 DEBUGP(3, dev, "-> terminate_monitor\n");
669 wait_event_interruptible(dev->devq,
670 test_and_set_bit(LOCK_MONITOR,
671 (void *)&dev->flags));
672
673 /* now, LOCK_MONITOR has been set.
674 * allow a last cycle in the monitor.
675 * the monitor will indicate that it has
676 * finished by clearing this bit.
677 */
678 DEBUGP(5, dev, "Now allow last cycle of monitor!\n");
679 while (test_bit(LOCK_MONITOR, (void *)&dev->flags))
680 msleep(25);
681
682 DEBUGP(5, dev, "Delete timer\n");
683 del_timer_sync(&dev->timer);
684#ifdef PCMCIA_DEBUG
685 dev->monitor_running = 0;
686#endif
687
688 DEBUGP(3, dev, "<- terminate_monitor\n");
689}
690
691/*
692 * monitor the card every 50msec. as a side-effect, retrieve the
693 * atr once a card is inserted. another side-effect of retrieving the
694 * atr is that the card will be powered on, so there is no need to
695 * power on the card explictely from the application: the driver
696 * is already doing that for you.
697 */
698
699static void monitor_card(unsigned long p)
700{
701 struct cm4000_dev *dev = (struct cm4000_dev *) p;
702 ioaddr_t iobase = dev->link.io.BasePort1;
703 unsigned short s;
704 struct ptsreq ptsreq;
705 int i, atrc;
706
707 DEBUGP(7, dev, "-> monitor_card\n");
708
709 /* if someone has set the lock for us: we're done! */
710 if (test_and_set_bit(LOCK_MONITOR, &dev->flags)) {
711 DEBUGP(4, dev, "About to stop monitor\n");
712 /* no */
713 dev->rlen =
714 dev->rpos =
715 dev->atr_csum = dev->atr_len_retry = dev->cwarn = 0;
716 dev->mstate = M_FETCH_ATR;
717 clear_bit(LOCK_MONITOR, &dev->flags);
718 /* close et al. are sleeping on devq, so wake it */
719 wake_up_interruptible(&dev->devq);
720 DEBUGP(2, dev, "<- monitor_card (we are done now)\n");
721 return;
722 }
723
724 /* try to lock io: if it is already locked, just add another timer */
725 if (test_and_set_bit(LOCK_IO, (void *)&dev->flags)) {
726 DEBUGP(4, dev, "Couldn't get IO lock\n");
727 goto return_with_timer;
728 }
729
730 /* is a card/a reader inserted at all ? */
731 dev->flags0 = xinb(REG_FLAGS0(iobase));
732 DEBUGP(7, dev, "dev->flags0 = 0x%2x\n", dev->flags0);
733 DEBUGP(7, dev, "smartcard present: %s\n",
734 dev->flags0 & 1 ? "yes" : "no");
735 DEBUGP(7, dev, "cardman present: %s\n",
736 dev->flags0 == 0xff ? "no" : "yes");
737
738 if ((dev->flags0 & 1) == 0 /* no smartcard inserted */
739 || dev->flags0 == 0xff) { /* no cardman inserted */
740 /* no */
741 dev->rlen =
742 dev->rpos =
743 dev->atr_csum = dev->atr_len_retry = dev->cwarn = 0;
744 dev->mstate = M_FETCH_ATR;
745
746 dev->flags &= 0x000000ff; /* only keep IO and MONITOR locks */
747
748 if (dev->flags0 == 0xff) {
749 DEBUGP(4, dev, "set IS_CMM_ABSENT bit\n");
750 set_bit(IS_CMM_ABSENT, &dev->flags);
751 } else if (test_bit(IS_CMM_ABSENT, &dev->flags)) {
752 DEBUGP(4, dev, "clear IS_CMM_ABSENT bit "
753 "(card is removed)\n");
754 clear_bit(IS_CMM_ABSENT, &dev->flags);
755 }
756
757 goto release_io;
758 } else if ((dev->flags0 & 1) && test_bit(IS_CMM_ABSENT, &dev->flags)) {
759 /* cardman and card present but cardman was absent before
760 * (after suspend with inserted card) */
761 DEBUGP(4, dev, "clear IS_CMM_ABSENT bit (card is inserted)\n");
762 clear_bit(IS_CMM_ABSENT, &dev->flags);
763 }
764
765 if (test_bit(IS_ATR_VALID, &dev->flags) == 1) {
766 DEBUGP(7, dev, "believe ATR is already valid (do nothing)\n");
767 goto release_io;
768 }
769
770 switch (dev->mstate) {
771 unsigned char flags0;
772 case M_CARDOFF:
773 DEBUGP(4, dev, "M_CARDOFF\n");
774 flags0 = inb(REG_FLAGS0(iobase));
775 if (flags0 & 0x02) {
776 /* wait until Flags0 indicate power is off */
777 dev->mdelay = T_10MSEC;
778 } else {
779 /* Flags0 indicate power off and no card inserted now;
780 * Reset CARDMAN CONTROLLER */
781 xoutb(0x80, REG_FLAGS0(iobase));
782
783 /* prepare for fetching ATR again: after card off ATR
784 * is read again automatically */
785 dev->rlen =
786 dev->rpos =
787 dev->atr_csum =
788 dev->atr_len_retry = dev->cwarn = 0;
789 dev->mstate = M_FETCH_ATR;
790
791 /* minimal gap between CARDOFF and read ATR is 50msec */
792 dev->mdelay = T_50MSEC;
793 }
794 break;
795 case M_FETCH_ATR:
796 DEBUGP(4, dev, "M_FETCH_ATR\n");
797 xoutb(0x80, REG_FLAGS0(iobase));
798 DEBUGP(4, dev, "Reset BAUDV to 9600\n");
799 dev->baudv = 0x173; /* 9600 */
800 xoutb(0x02, REG_STOPBITS(iobase)); /* stopbits=2 */
801 xoutb(0x73, REG_BAUDRATE(iobase)); /* baud value */
802 xoutb(0x21, REG_FLAGS1(iobase)); /* T_Active=1, baud
803 value */
804 /* warm start vs. power on: */
805 xoutb(dev->flags0 & 2 ? 0x46 : 0x44, REG_FLAGS0(iobase));
806 dev->mdelay = T_40MSEC;
807 dev->mstate = M_TIMEOUT_WAIT;
808 break;
809 case M_TIMEOUT_WAIT:
810 DEBUGP(4, dev, "M_TIMEOUT_WAIT\n");
811 /* numRecBytes */
812 io_read_num_rec_bytes(iobase, &dev->atr_len);
813 dev->mdelay = T_10MSEC;
814 dev->mstate = M_READ_ATR_LEN;
815 break;
816 case M_READ_ATR_LEN:
817 DEBUGP(4, dev, "M_READ_ATR_LEN\n");
818 /* infinite loop possible, since there is no timeout */
819
820#define MAX_ATR_LEN_RETRY 100
821
822 if (dev->atr_len == io_read_num_rec_bytes(iobase, &s)) {
823 if (dev->atr_len_retry++ >= MAX_ATR_LEN_RETRY) { /* + XX msec */
824 dev->mdelay = T_10MSEC;
825 dev->mstate = M_READ_ATR;
826 }
827 } else {
828 dev->atr_len = s;
829 dev->atr_len_retry = 0; /* set new timeout */
830 }
831
832 DEBUGP(4, dev, "Current ATR_LEN = %i\n", dev->atr_len);
833 break;
834 case M_READ_ATR:
835 DEBUGP(4, dev, "M_READ_ATR\n");
836 xoutb(0x80, REG_FLAGS0(iobase)); /* reset SM */
837 for (i = 0; i < dev->atr_len; i++) {
838 xoutb(i, REG_BUF_ADDR(iobase));
839 dev->atr[i] = inb(REG_BUF_DATA(iobase));
840 }
841 /* Deactivate T_Active flags */
842 DEBUGP(4, dev, "Deactivate T_Active flags\n");
843 dev->flags1 = 0x01;
844 xoutb(dev->flags1, REG_FLAGS1(iobase));
845
846 /* atr is present (which doesnt mean it's valid) */
847 set_bit(IS_ATR_PRESENT, &dev->flags);
848 if (dev->atr[0] == 0x03)
849 str_invert_revert(dev->atr, dev->atr_len);
850 atrc = parse_atr(dev);
851 if (atrc == 0) { /* atr invalid */
852 dev->mdelay = 0;
853 dev->mstate = M_BAD_CARD;
854 } else {
855 dev->mdelay = T_50MSEC;
856 dev->mstate = M_ATR_PRESENT;
857 set_bit(IS_ATR_VALID, &dev->flags);
858 }
859
860 if (test_bit(IS_ATR_VALID, &dev->flags) == 1) {
861 DEBUGP(4, dev, "monitor_card: ATR valid\n");
862 /* if ta1 == 0x11, no PPS necessary (default values) */
863 /* do not do PPS with multi protocol cards */
864 if ((test_bit(IS_AUTOPPS_ACT, &dev->flags) == 0) &&
865 (dev->ta1 != 0x11) &&
866 !(test_bit(IS_ANY_T0, &dev->flags) &&
867 test_bit(IS_ANY_T1, &dev->flags))) {
868 DEBUGP(4, dev, "Perform AUTOPPS\n");
869 set_bit(IS_AUTOPPS_ACT, &dev->flags);
870 ptsreq.protocol = ptsreq.protocol =
871 (0x01 << dev->proto);
872 ptsreq.flags = 0x01;
873 ptsreq.pts1 = 0x00;
874 ptsreq.pts2 = 0x00;
875 ptsreq.pts3 = 0x00;
876 if (set_protocol(dev, &ptsreq) == 0) {
877 DEBUGP(4, dev, "AUTOPPS ret SUCC\n");
878 clear_bit(IS_AUTOPPS_ACT, &dev->flags);
879 wake_up_interruptible(&dev->atrq);
880 } else {
881 DEBUGP(4, dev, "AUTOPPS failed: "
882 "repower using defaults\n");
883 /* prepare for repowering */
884 clear_bit(IS_ATR_PRESENT, &dev->flags);
885 clear_bit(IS_ATR_VALID, &dev->flags);
886 dev->rlen =
887 dev->rpos =
888 dev->atr_csum =
889 dev->atr_len_retry = dev->cwarn = 0;
890 dev->mstate = M_FETCH_ATR;
891
892 dev->mdelay = T_50MSEC;
893 }
894 } else {
895 /* for cards which use slightly different
896 * params (extra guard time) */
897 set_cardparameter(dev);
898 if (test_bit(IS_AUTOPPS_ACT, &dev->flags) == 1)
899 DEBUGP(4, dev, "AUTOPPS already active "
900 "2nd try:use default values\n");
901 if (dev->ta1 == 0x11)
902 DEBUGP(4, dev, "No AUTOPPS necessary "
903 "TA(1)==0x11\n");
904 if (test_bit(IS_ANY_T0, &dev->flags)
905 && test_bit(IS_ANY_T1, &dev->flags))
906 DEBUGP(4, dev, "Do NOT perform AUTOPPS "
907 "with multiprotocol cards\n");
908 clear_bit(IS_AUTOPPS_ACT, &dev->flags);
909 wake_up_interruptible(&dev->atrq);
910 }
911 } else {
912 DEBUGP(4, dev, "ATR invalid\n");
913 wake_up_interruptible(&dev->atrq);
914 }
915 break;
916 case M_BAD_CARD:
917 DEBUGP(4, dev, "M_BAD_CARD\n");
918 /* slow down warning, but prompt immediately after insertion */
919 if (dev->cwarn == 0 || dev->cwarn == 10) {
920 set_bit(IS_BAD_CARD, &dev->flags);
921 printk(KERN_WARNING MODULE_NAME ": device %s: ",
922 dev->node.dev_name);
923 if (test_bit(IS_BAD_CSUM, &dev->flags)) {
924 DEBUGP(4, dev, "ATR checksum (0x%.2x, should "
925 "be zero) failed\n", dev->atr_csum);
926 }
927#ifdef PCMCIA_DEBUG
928 else if (test_bit(IS_BAD_LENGTH, &dev->flags)) {
929 DEBUGP(4, dev, "ATR length error\n");
930 } else {
931 DEBUGP(4, dev, "card damaged or wrong way "
932 "inserted\n");
933 }
934#endif
935 dev->cwarn = 0;
936 wake_up_interruptible(&dev->atrq); /* wake open */
937 }
938 dev->cwarn++;
939 dev->mdelay = T_100MSEC;
940 dev->mstate = M_FETCH_ATR;
941 break;
942 default:
943 DEBUGP(7, dev, "Unknown action\n");
944 break; /* nothing */
945 }
946
947release_io:
948 DEBUGP(7, dev, "release_io\n");
949 clear_bit(LOCK_IO, &dev->flags);
950 wake_up_interruptible(&dev->ioq); /* whoever needs IO */
951
952return_with_timer:
953 DEBUGP(7, dev, "<- monitor_card (returns with timer)\n");
954 dev->timer.expires = jiffies + dev->mdelay;
955 add_timer(&dev->timer);
956 clear_bit(LOCK_MONITOR, &dev->flags);
957}
958
959/* Interface to userland (file_operations) */
960
961static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
962 loff_t *ppos)
963{
964 struct cm4000_dev *dev = filp->private_data;
965 ioaddr_t iobase = dev->link.io.BasePort1;
966 ssize_t rc;
967 int i, j, k;
968
969 DEBUGP(2, dev, "-> cmm_read(%s,%d)\n", current->comm, current->pid);
970
971 if (count == 0) /* according to manpage */
972 return 0;
973
974 if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */
975 test_bit(IS_CMM_ABSENT, &dev->flags))
976 return -ENODEV;
977
978 if (test_bit(IS_BAD_CSUM, &dev->flags))
979 return -EIO;
980
981 /* also see the note about this in cmm_write */
982 if (wait_event_interruptible
983 (dev->atrq,
984 ((filp->f_flags & O_NONBLOCK)
985 || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags) != 0)))) {
986 if (filp->f_flags & O_NONBLOCK)
987 return -EAGAIN;
988 return -ERESTARTSYS;
989 }
990
991 if (test_bit(IS_ATR_VALID, &dev->flags) == 0)
992 return -EIO;
993
994 /* this one implements blocking IO */
995 if (wait_event_interruptible
996 (dev->readq,
997 ((filp->f_flags & O_NONBLOCK) || (dev->rpos < dev->rlen)))) {
998 if (filp->f_flags & O_NONBLOCK)
999 return -EAGAIN;
1000 return -ERESTARTSYS;
1001 }
1002
1003 /* lock io */
1004 if (wait_event_interruptible
1005 (dev->ioq,
1006 ((filp->f_flags & O_NONBLOCK)
1007 || (test_and_set_bit(LOCK_IO, (void *)&dev->flags) == 0)))) {
1008 if (filp->f_flags & O_NONBLOCK)
1009 return -EAGAIN;
1010 return -ERESTARTSYS;
1011 }
1012
1013 rc = 0;
1014 dev->flags0 = inb(REG_FLAGS0(iobase));
1015 if ((dev->flags0 & 1) == 0 /* no smartcard inserted */
1016 || dev->flags0 == 0xff) { /* no cardman inserted */
1017 clear_bit(IS_ATR_VALID, &dev->flags);
1018 if (dev->flags0 & 1) {
1019 set_bit(IS_CMM_ABSENT, &dev->flags);
1020 rc = -ENODEV;
1021 }
1022 rc = -EIO;
1023 goto release_io;
1024 }
1025
1026 DEBUGP(4, dev, "begin read answer\n");
1027 j = min(count, (size_t)(dev->rlen - dev->rpos));
1028 k = dev->rpos;
1029 if (k + j > 255)
1030 j = 256 - k;
1031 DEBUGP(4, dev, "read1 j=%d\n", j);
1032 for (i = 0; i < j; i++) {
1033 xoutb(k++, REG_BUF_ADDR(iobase));
1034 dev->rbuf[i] = xinb(REG_BUF_DATA(iobase));
1035 }
1036 j = min(count, (size_t)(dev->rlen - dev->rpos));
1037 if (k + j > 255) {
1038 DEBUGP(4, dev, "read2 j=%d\n", j);
1039 dev->flags1 |= 0x10; /* MSB buf addr set */
1040 xoutb(dev->flags1, REG_FLAGS1(iobase));
1041 for (; i < j; i++) {
1042 xoutb(k++, REG_BUF_ADDR(iobase));
1043 dev->rbuf[i] = xinb(REG_BUF_DATA(iobase));
1044 }
1045 }
1046
1047 if (dev->proto == 0 && count > dev->rlen - dev->rpos) {
1048 DEBUGP(4, dev, "T=0 and count > buffer\n");
1049 dev->rbuf[i] = dev->rbuf[i - 1];
1050 dev->rbuf[i - 1] = dev->procbyte;
1051 j++;
1052 }
1053 count = j;
1054
1055 dev->rpos = dev->rlen + 1;
1056
1057 /* Clear T1Active */
1058 DEBUGP(4, dev, "Clear T1Active\n");
1059 dev->flags1 &= 0xdf;
1060 xoutb(dev->flags1, REG_FLAGS1(iobase));
1061
1062 xoutb(0, REG_FLAGS1(iobase)); /* clear detectCMM */
1063 /* last check before exit */
1064 if (!io_detect_cm4000(iobase, dev))
1065 count = -ENODEV;
1066
1067 if (test_bit(IS_INVREV, &dev->flags) && count > 0)
1068 str_invert_revert(dev->rbuf, count);
1069
1070 if (copy_to_user(buf, dev->rbuf, count))
1071 return -EFAULT;
1072
1073release_io:
1074 clear_bit(LOCK_IO, &dev->flags);
1075 wake_up_interruptible(&dev->ioq);
1076
1077 DEBUGP(2, dev, "<- cmm_read returns: rc = %Zi\n",
1078 (rc < 0 ? rc : count));
1079 return rc < 0 ? rc : count;
1080}
1081
1082static ssize_t cmm_write(struct file *filp, const char __user *buf,
1083 size_t count, loff_t *ppos)
1084{
1085 struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data;
1086 ioaddr_t iobase = dev->link.io.BasePort1;
1087 unsigned short s;
1088 unsigned char tmp;
1089 unsigned char infolen;
1090 unsigned char sendT0;
1091 unsigned short nsend;
1092 unsigned short nr;
1093 ssize_t rc;
1094 int i;
1095
1096 DEBUGP(2, dev, "-> cmm_write(%s,%d)\n", current->comm, current->pid);
1097
1098 if (count == 0) /* according to manpage */
1099 return 0;
1100
1101 if (dev->proto == 0 && count < 4) {
1102 /* T0 must have at least 4 bytes */
1103 DEBUGP(4, dev, "T0 short write\n");
1104 return -EIO;
1105 }
1106
1107 nr = count & 0x1ff; /* max bytes to write */
1108
1109 sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0;
1110
1111 if ((dev->link.state & DEV_PRESENT) == 0 || /* socket removed */
1112 test_bit(IS_CMM_ABSENT, &dev->flags))
1113 return -ENODEV;
1114
1115 if (test_bit(IS_BAD_CSUM, &dev->flags)) {
1116 DEBUGP(4, dev, "bad csum\n");
1117 return -EIO;
1118 }
1119
1120 /*
1121 * wait for atr to become valid.
1122 * note: it is important to lock this code. if we dont, the monitor
1123 * could be run between test_bit and the the call the sleep on the
1124 * atr-queue. if *then* the monitor detects atr valid, it will wake up
1125 * any process on the atr-queue, *but* since we have been interrupted,
1126 * we do not yet sleep on this queue. this would result in a missed
1127 * wake_up and the calling process would sleep forever (until
1128 * interrupted). also, do *not* restore_flags before sleep_on, because
1129 * this could result in the same situation!
1130 */
1131 if (wait_event_interruptible
1132 (dev->atrq,
1133 ((filp->f_flags & O_NONBLOCK)
1134 || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags) != 0)))) {
1135 if (filp->f_flags & O_NONBLOCK)
1136 return -EAGAIN;
1137 return -ERESTARTSYS;
1138 }
1139
1140 if (test_bit(IS_ATR_VALID, &dev->flags) == 0) { /* invalid atr */
1141 DEBUGP(4, dev, "invalid ATR\n");
1142 return -EIO;
1143 }
1144
1145 /* lock io */
1146 if (wait_event_interruptible
1147 (dev->ioq,
1148 ((filp->f_flags & O_NONBLOCK)
1149 || (test_and_set_bit(LOCK_IO, (void *)&dev->flags) == 0)))) {
1150 if (filp->f_flags & O_NONBLOCK)
1151 return -EAGAIN;
1152 return -ERESTARTSYS;
1153 }
1154
1155 if (copy_from_user(dev->sbuf, buf, ((count > 512) ? 512 : count)))
1156 return -EFAULT;
1157
1158 rc = 0;
1159 dev->flags0 = inb(REG_FLAGS0(iobase));
1160 if ((dev->flags0 & 1) == 0 /* no smartcard inserted */
1161 || dev->flags0 == 0xff) { /* no cardman inserted */
1162 clear_bit(IS_ATR_VALID, &dev->flags);
1163 if (dev->flags0 & 1) {
1164 set_bit(IS_CMM_ABSENT, &dev->flags);
1165 rc = -ENODEV;
1166 } else {
1167 DEBUGP(4, dev, "IO error\n");
1168 rc = -EIO;
1169 }
1170 goto release_io;
1171 }
1172
1173 xoutb(0x80, REG_FLAGS0(iobase)); /* reset SM */
1174
1175 if (!io_detect_cm4000(iobase, dev)) {
1176 rc = -ENODEV;
1177 goto release_io;
1178 }
1179
1180 /* reflect T=0 send/read mode in flags1 */
1181 dev->flags1 |= (sendT0);
1182
1183 set_cardparameter(dev);
1184
1185 /* dummy read, reset flag procedure received */
1186 tmp = inb(REG_FLAGS1(iobase));
1187
1188 dev->flags1 = 0x20 /* T_Active */
1189 | (sendT0)
1190 | (test_bit(IS_INVREV, &dev->flags) ? 2 : 0)/* inverse parity */
1191 | (((dev->baudv - 1) & 0x0100) >> 8); /* MSB-Baud */
1192 DEBUGP(1, dev, "set dev->flags1 = 0x%.2x\n", dev->flags1);
1193 xoutb(dev->flags1, REG_FLAGS1(iobase));
1194
1195 /* xmit data */
1196 DEBUGP(4, dev, "Xmit data\n");
1197 for (i = 0; i < nr; i++) {
1198 if (i >= 256) {
1199 dev->flags1 = 0x20 /* T_Active */
1200 | (sendT0) /* SendT0 */
1201 /* inverse parity: */
1202 | (test_bit(IS_INVREV, &dev->flags) ? 2 : 0)
1203 | (((dev->baudv - 1) & 0x0100) >> 8) /* MSB-Baud */
1204 | 0x10; /* set address high */
1205 DEBUGP(4, dev, "dev->flags = 0x%.2x - set address "
1206 "high\n", dev->flags1);
1207 xoutb(dev->flags1, REG_FLAGS1(iobase));
1208 }
1209 if (test_bit(IS_INVREV, &dev->flags)) {
1210 DEBUGP(4, dev, "Apply inverse convention for 0x%.2x "
1211 "-> 0x%.2x\n", (unsigned char)dev->sbuf[i],
1212 invert_revert(dev->sbuf[i]));
1213 xoutb(i, REG_BUF_ADDR(iobase));
1214 xoutb(invert_revert(dev->sbuf[i]),
1215 REG_BUF_DATA(iobase));
1216 } else {
1217 xoutb(i, REG_BUF_ADDR(iobase));
1218 xoutb(dev->sbuf[i], REG_BUF_DATA(iobase));
1219 }
1220 }
1221 DEBUGP(4, dev, "Xmit done\n");
1222
1223 if (dev->proto == 0) {
1224 /* T=0 proto: 0 byte reply */
1225 if (nr == 4) {
1226 DEBUGP(4, dev, "T=0 assumes 0 byte reply\n");
1227 xoutb(i, REG_BUF_ADDR(iobase));
1228 if (test_bit(IS_INVREV, &dev->flags))
1229 xoutb(0xff, REG_BUF_DATA(iobase));
1230 else
1231 xoutb(0x00, REG_BUF_DATA(iobase));
1232 }
1233
1234 /* numSendBytes */
1235 if (sendT0)
1236 nsend = nr;
1237 else {
1238 if (nr == 4)
1239 nsend = 5;
1240 else {
1241 nsend = 5 + (unsigned char)dev->sbuf[4];
1242 if (dev->sbuf[4] == 0)
1243 nsend += 0x100;
1244 }
1245 }
1246 } else
1247 nsend = nr;
1248
1249 /* T0: output procedure byte */
1250 if (test_bit(IS_INVREV, &dev->flags)) {
1251 DEBUGP(4, dev, "T=0 set Procedure byte (inverse-reverse) "
1252 "0x%.2x\n", invert_revert(dev->sbuf[1]));
1253 xoutb(invert_revert(dev->sbuf[1]), REG_NUM_BYTES(iobase));
1254 } else {
1255 DEBUGP(4, dev, "T=0 set Procedure byte 0x%.2x\n", dev->sbuf[1]);
1256 xoutb(dev->sbuf[1], REG_NUM_BYTES(iobase));
1257 }
1258
1259 DEBUGP(1, dev, "set NumSendBytes = 0x%.2x\n",
1260 (unsigned char)(nsend & 0xff));
1261 xoutb((unsigned char)(nsend & 0xff), REG_NUM_SEND(iobase));
1262
1263 DEBUGP(1, dev, "Trigger CARDMAN CONTROLLER (0x%.2x)\n",
1264 0x40 /* SM_Active */
1265 | (dev->flags0 & 2 ? 0 : 4) /* power on if needed */
1266 |(dev->proto ? 0x10 : 0x08) /* T=1/T=0 */
1267 |(nsend & 0x100) >> 8 /* MSB numSendBytes */ );
1268 xoutb(0x40 /* SM_Active */
1269 | (dev->flags0 & 2 ? 0 : 4) /* power on if needed */
1270 |(dev->proto ? 0x10 : 0x08) /* T=1/T=0 */
1271 |(nsend & 0x100) >> 8, /* MSB numSendBytes */
1272 REG_FLAGS0(iobase));
1273
1274 /* wait for xmit done */
1275 if (dev->proto == 1) {
1276 DEBUGP(4, dev, "Wait for xmit done\n");
1277 for (i = 0; i < 1000; i++) {
1278 if (inb(REG_FLAGS0(iobase)) & 0x08)
1279 break;
1280 msleep_interruptible(10);
1281 }
1282 if (i == 1000) {
1283 DEBUGP(4, dev, "timeout waiting for xmit done\n");
1284 rc = -EIO;
1285 goto release_io;
1286 }
1287 }
1288
1289 /* T=1: wait for infoLen */
1290
1291 infolen = 0;
1292 if (dev->proto) {
1293 /* wait until infoLen is valid */
1294 for (i = 0; i < 6000; i++) { /* max waiting time of 1 min */
1295 io_read_num_rec_bytes(iobase, &s);
1296 if (s >= 3) {
1297 infolen = inb(REG_FLAGS1(iobase));
1298 DEBUGP(4, dev, "infolen=%d\n", infolen);
1299 break;
1300 }
1301 msleep_interruptible(10);
1302 }
1303 if (i == 6000) {
1304 DEBUGP(4, dev, "timeout waiting for infoLen\n");
1305 rc = -EIO;
1306 goto release_io;
1307 }
1308 } else
1309 clear_bit(IS_PROCBYTE_PRESENT, &dev->flags);
1310
1311 /* numRecBytes | bit9 of numRecytes */
1312 io_read_num_rec_bytes(iobase, &dev->rlen);
1313 for (i = 0; i < 600; i++) { /* max waiting time of 2 sec */
1314 if (dev->proto) {
1315 if (dev->rlen >= infolen + 4)
1316 break;
1317 }
1318 msleep_interruptible(10);
1319 /* numRecBytes | bit9 of numRecytes */
1320 io_read_num_rec_bytes(iobase, &s);
1321 if (s > dev->rlen) {
1322 DEBUGP(1, dev, "NumRecBytes inc (reset timeout)\n");
1323 i = 0; /* reset timeout */
1324 dev->rlen = s;
1325 }
1326 /* T=0: we are done when numRecBytes doesn't
1327 * increment any more and NoProcedureByte
1328 * is set and numRecBytes == bytes sent + 6
1329 * (header bytes + data + 1 for sw2)
1330 * except when the card replies an error
1331 * which means, no data will be sent back.
1332 */
1333 else if (dev->proto == 0) {
1334 if ((inb(REG_BUF_ADDR(iobase)) & 0x80)) {
1335 /* no procedure byte received since last read */
1336 DEBUGP(1, dev, "NoProcedure byte set\n");
1337 /* i=0; */
1338 } else {
1339 /* procedure byte received since last read */
1340 DEBUGP(1, dev, "NoProcedure byte unset "
1341 "(reset timeout)\n");
1342 dev->procbyte = inb(REG_FLAGS1(iobase));
1343 DEBUGP(1, dev, "Read procedure byte 0x%.2x\n",
1344 dev->procbyte);
1345 i = 0; /* resettimeout */
1346 }
1347 if (inb(REG_FLAGS0(iobase)) & 0x08) {
1348 DEBUGP(1, dev, "T0Done flag (read reply)\n");
1349 break;
1350 }
1351 }
1352 if (dev->proto)
1353 infolen = inb(REG_FLAGS1(iobase));
1354 }
1355 if (i == 600) {
1356 DEBUGP(1, dev, "timeout waiting for numRecBytes\n");
1357 rc = -EIO;
1358 goto release_io;
1359 } else {
1360 if (dev->proto == 0) {
1361 DEBUGP(1, dev, "Wait for T0Done bit to be set\n");
1362 for (i = 0; i < 1000; i++) {
1363 if (inb(REG_FLAGS0(iobase)) & 0x08)
1364 break;
1365 msleep_interruptible(10);
1366 }
1367 if (i == 1000) {
1368 DEBUGP(1, dev, "timeout waiting for T0Done\n");
1369 rc = -EIO;
1370 goto release_io;
1371 }
1372
1373 dev->procbyte = inb(REG_FLAGS1(iobase));
1374 DEBUGP(4, dev, "Read procedure byte 0x%.2x\n",
1375 dev->procbyte);
1376
1377 io_read_num_rec_bytes(iobase, &dev->rlen);
1378 DEBUGP(4, dev, "Read NumRecBytes = %i\n", dev->rlen);
1379
1380 }
1381 }
1382 /* T=1: read offset=zero, T=0: read offset=after challenge */
1383 dev->rpos = dev->proto ? 0 : nr == 4 ? 5 : nr > dev->rlen ? 5 : nr;
1384 DEBUGP(4, dev, "dev->rlen = %i, dev->rpos = %i, nr = %i\n",
1385 dev->rlen, dev->rpos, nr);
1386
1387release_io:
1388 DEBUGP(4, dev, "Reset SM\n");
1389 xoutb(0x80, REG_FLAGS0(iobase)); /* reset SM */
1390
1391 if (rc < 0) {
1392 DEBUGP(4, dev, "Write failed but clear T_Active\n");
1393 dev->flags1 &= 0xdf;
1394 xoutb(dev->flags1, REG_FLAGS1(iobase));
1395 }
1396
1397 clear_bit(LOCK_IO, &dev->flags);
1398 wake_up_interruptible(&dev->ioq);
1399 wake_up_interruptible(&dev->readq); /* tell read we have data */
1400
1401 /* ITSEC E2: clear write buffer */
1402 memset((char *)dev->sbuf, 0, 512);
1403
1404 /* return error or actually written bytes */
1405 DEBUGP(2, dev, "<- cmm_write\n");
1406 return rc < 0 ? rc : nr;
1407}
1408
1409static void start_monitor(struct cm4000_dev *dev)
1410{
1411 DEBUGP(3, dev, "-> start_monitor\n");
1412 if (!dev->monitor_running) {
1413 DEBUGP(5, dev, "create, init and add timer\n");
1414 init_timer(&dev->timer);
1415 dev->monitor_running = 1;
1416 dev->timer.expires = jiffies;
1417 dev->timer.data = (unsigned long) dev;
1418 dev->timer.function = monitor_card;
1419 add_timer(&dev->timer);
1420 } else
1421 DEBUGP(5, dev, "monitor already running\n");
1422 DEBUGP(3, dev, "<- start_monitor\n");
1423}
1424
1425static void stop_monitor(struct cm4000_dev *dev)
1426{
1427 DEBUGP(3, dev, "-> stop_monitor\n");
1428 if (dev->monitor_running) {
1429 DEBUGP(5, dev, "stopping monitor\n");
1430 terminate_monitor(dev);
1431 /* reset monitor SM */
1432 clear_bit(IS_ATR_VALID, &dev->flags);
1433 clear_bit(IS_ATR_PRESENT, &dev->flags);
1434 } else
1435 DEBUGP(5, dev, "monitor already stopped\n");
1436 DEBUGP(3, dev, "<- stop_monitor\n");
1437}
1438
1439static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
1440 unsigned long arg)
1441{
1442 struct cm4000_dev *dev = filp->private_data;
1443 ioaddr_t iobase = dev->link.io.BasePort1;
1444 dev_link_t *link;
1445 int size;
1446 int rc;
1447 void __user *argp = (void __user *)arg;
1448#ifdef PCMCIA_DEBUG
1449 char *ioctl_names[CM_IOC_MAXNR + 1] = {
1450 [_IOC_NR(CM_IOCGSTATUS)] "CM_IOCGSTATUS",
1451 [_IOC_NR(CM_IOCGATR)] "CM_IOCGATR",
1452 [_IOC_NR(CM_IOCARDOFF)] "CM_IOCARDOFF",
1453 [_IOC_NR(CM_IOCSPTS)] "CM_IOCSPTS",
1454 [_IOC_NR(CM_IOSDBGLVL)] "CM4000_DBGLVL",
1455 };
1456#endif
1457 DEBUGP(3, dev, "cmm_ioctl(device=%d.%d) %s\n", imajor(inode),
1458 iminor(inode), ioctl_names[_IOC_NR(cmd)]);
1459
1460 link = dev_table[iminor(inode)];
1461 if (!(DEV_OK(link))) {
1462 DEBUGP(4, dev, "DEV_OK false\n");
1463 return -ENODEV;
1464 }
1465
1466 if (test_bit(IS_CMM_ABSENT, &dev->flags)) {
1467 DEBUGP(4, dev, "CMM_ABSENT flag set\n");
1468 return -ENODEV;
1469 }
1470
1471 if (_IOC_TYPE(cmd) != CM_IOC_MAGIC) {
1472 DEBUGP(4, dev, "ioctype mismatch\n");
1473 return -EINVAL;
1474 }
1475 if (_IOC_NR(cmd) > CM_IOC_MAXNR) {
1476 DEBUGP(4, dev, "iocnr mismatch\n");
1477 return -EINVAL;
1478 }
1479 size = _IOC_SIZE(cmd);
1480 rc = 0;
1481 DEBUGP(4, dev, "iocdir=%.4x iocr=%.4x iocw=%.4x iocsize=%d cmd=%.4x\n",
1482 _IOC_DIR(cmd), _IOC_READ, _IOC_WRITE, size, cmd);
1483
1484 if (_IOC_DIR(cmd) & _IOC_READ) {
1485 if (!access_ok(VERIFY_WRITE, argp, size))
1486 return -EFAULT;
1487 }
1488 if (_IOC_DIR(cmd) & _IOC_WRITE) {
1489 if (!access_ok(VERIFY_READ, argp, size))
1490 return -EFAULT;
1491 }
1492
1493 switch (cmd) {
1494 case CM_IOCGSTATUS:
1495 DEBUGP(4, dev, " ... in CM_IOCGSTATUS\n");
1496 {
1497 int status;
1498
1499 /* clear other bits, but leave inserted & powered as
1500 * they are */
1501 status = dev->flags0 & 3;
1502 if (test_bit(IS_ATR_PRESENT, &dev->flags))
1503 status |= CM_ATR_PRESENT;
1504 if (test_bit(IS_ATR_VALID, &dev->flags))
1505 status |= CM_ATR_VALID;
1506 if (test_bit(IS_CMM_ABSENT, &dev->flags))
1507 status |= CM_NO_READER;
1508 if (test_bit(IS_BAD_CARD, &dev->flags))
1509 status |= CM_BAD_CARD;
1510 if (copy_to_user(argp, &status, sizeof(int)))
1511 return -EFAULT;
1512 }
1513 return 0;
1514 case CM_IOCGATR:
1515 DEBUGP(4, dev, "... in CM_IOCGATR\n");
1516 {
1517 struct atreq __user *atreq = argp;
1518 int tmp;
1519 /* allow nonblocking io and being interrupted */
1520 if (wait_event_interruptible
1521 (dev->atrq,
1522 ((filp->f_flags & O_NONBLOCK)
1523 || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags)
1524 != 0)))) {
1525 if (filp->f_flags & O_NONBLOCK)
1526 return -EAGAIN;
1527 return -ERESTARTSYS;
1528 }
1529
1530 if (test_bit(IS_ATR_VALID, &dev->flags) == 0) {
1531 tmp = -1;
1532 if (copy_to_user(&(atreq->atr_len), &tmp,
1533 sizeof(int)))
1534 return -EFAULT;
1535 } else {
1536 if (copy_to_user(atreq->atr, dev->atr,
1537 dev->atr_len))
1538 return -EFAULT;
1539
1540 tmp = dev->atr_len;
1541 if (copy_to_user(&(atreq->atr_len), &tmp, sizeof(int)))
1542 return -EFAULT;
1543 }
1544 return 0;
1545 }
1546 case CM_IOCARDOFF:
1547
1548#ifdef PCMCIA_DEBUG
1549 DEBUGP(4, dev, "... in CM_IOCARDOFF\n");
1550 if (dev->flags0 & 0x01) {
1551 DEBUGP(4, dev, " Card inserted\n");
1552 } else {
1553 DEBUGP(2, dev, " No card inserted\n");
1554 }
1555 if (dev->flags0 & 0x02) {
1556 DEBUGP(4, dev, " Card powered\n");
1557 } else {
1558 DEBUGP(2, dev, " Card not powered\n");
1559 }
1560#endif
1561
1562 /* is a card inserted and powered? */
1563 if ((dev->flags0 & 0x01) && (dev->flags0 & 0x02)) {
1564
1565 /* get IO lock */
1566 if (wait_event_interruptible
1567 (dev->ioq,
1568 ((filp->f_flags & O_NONBLOCK)
1569 || (test_and_set_bit(LOCK_IO, (void *)&dev->flags)
1570 == 0)))) {
1571 if (filp->f_flags & O_NONBLOCK)
1572 return -EAGAIN;
1573 return -ERESTARTSYS;
1574 }
1575 /* Set Flags0 = 0x42 */
1576 DEBUGP(4, dev, "Set Flags0=0x42 \n");
1577 xoutb(0x42, REG_FLAGS0(iobase));
1578 clear_bit(IS_ATR_PRESENT, &dev->flags);
1579 clear_bit(IS_ATR_VALID, &dev->flags);
1580 dev->mstate = M_CARDOFF;
1581 clear_bit(LOCK_IO, &dev->flags);
1582 if (wait_event_interruptible
1583 (dev->atrq,
1584 ((filp->f_flags & O_NONBLOCK)
1585 || (test_bit(IS_ATR_VALID, (void *)&dev->flags) !=
1586 0)))) {
1587 if (filp->f_flags & O_NONBLOCK)
1588 return -EAGAIN;
1589 return -ERESTARTSYS;
1590 }
1591 }
1592 /* release lock */
1593 clear_bit(LOCK_IO, &dev->flags);
1594 wake_up_interruptible(&dev->ioq);
1595
1596 return 0;
1597 case CM_IOCSPTS:
1598 {
1599 struct ptsreq krnptsreq;
1600
1601 if (copy_from_user(&krnptsreq, argp,
1602 sizeof(struct ptsreq)))
1603 return -EFAULT;
1604
1605 rc = 0;
1606 DEBUGP(4, dev, "... in CM_IOCSPTS\n");
1607 /* wait for ATR to get valid */
1608 if (wait_event_interruptible
1609 (dev->atrq,
1610 ((filp->f_flags & O_NONBLOCK)
1611 || (test_bit(IS_ATR_PRESENT, (void *)&dev->flags)
1612 != 0)))) {
1613 if (filp->f_flags & O_NONBLOCK)
1614 return -EAGAIN;
1615 return -ERESTARTSYS;
1616 }
1617 /* get IO lock */
1618 if (wait_event_interruptible
1619 (dev->ioq,
1620 ((filp->f_flags & O_NONBLOCK)
1621 || (test_and_set_bit(LOCK_IO, (void *)&dev->flags)
1622 == 0)))) {
1623 if (filp->f_flags & O_NONBLOCK)
1624 return -EAGAIN;
1625 return -ERESTARTSYS;
1626 }
1627
1628 if ((rc = set_protocol(dev, &krnptsreq)) != 0) {
1629 /* auto power_on again */
1630 dev->mstate = M_FETCH_ATR;
1631 clear_bit(IS_ATR_VALID, &dev->flags);
1632 }
1633 /* release lock */
1634 clear_bit(LOCK_IO, &dev->flags);
1635 wake_up_interruptible(&dev->ioq);
1636
1637 }
1638 return rc;
1639#ifdef PCMCIA_DEBUG
1640 case CM_IOSDBGLVL: /* set debug log level */
1641 {
1642 int old_pc_debug = 0;
1643
1644 old_pc_debug = pc_debug;
1645 if (copy_from_user(&pc_debug, argp, sizeof(int)))
1646 return -EFAULT;
1647
1648 if (old_pc_debug != pc_debug)
1649 DEBUGP(0, dev, "Changed debug log level "
1650 "to %i\n", pc_debug);
1651 }
1652 return rc;
1653#endif
1654 default:
1655 DEBUGP(4, dev, "... in default (unknown IOCTL code)\n");
1656 return -EINVAL;
1657 }
1658}
1659
1660static int cmm_open(struct inode *inode, struct file *filp)
1661{
1662 struct cm4000_dev *dev;
1663 dev_link_t *link;
1664 int rc, minor = iminor(inode);
1665
1666 if (minor >= CM4000_MAX_DEV)
1667 return -ENODEV;
1668
1669 link = dev_table[minor];
1670 if (link == NULL || !(DEV_OK(link)))
1671 return -ENODEV;
1672
1673 if (link->open)
1674 return -EBUSY;
1675
1676 dev = link->priv;
1677 filp->private_data = dev;
1678
1679 DEBUGP(2, dev, "-> cmm_open(device=%d.%d process=%s,%d)\n",
1680 imajor(inode), minor, current->comm, current->pid);
1681
1682 /* init device variables, they may be "polluted" after close
1683 * or, the device may never have been closed (i.e. open failed)
1684 */
1685
1686 ZERO_DEV(dev);
1687
1688 /* opening will always block since the
1689 * monitor will be started by open, which
1690 * means we have to wait for ATR becoming
1691 * vaild = block until valid (or card
1692 * inserted)
1693 */
1694 if (filp->f_flags & O_NONBLOCK)
1695 return -EAGAIN;
1696
1697 dev->mdelay = T_50MSEC;
1698
1699 /* start monitoring the cardstatus */
1700 start_monitor(dev);
1701
1702 link->open = 1; /* only one open per device */
1703 rc = 0;
1704
1705 DEBUGP(2, dev, "<- cmm_open\n");
1706 return nonseekable_open(inode, filp);
1707}
1708
1709static int cmm_close(struct inode *inode, struct file *filp)
1710{
1711 struct cm4000_dev *dev;
1712 dev_link_t *link;
1713 int minor = iminor(inode);
1714
1715 if (minor >= CM4000_MAX_DEV)
1716 return -ENODEV;
1717
1718 link = dev_table[minor];
1719 if (link == NULL)
1720 return -ENODEV;
1721
1722 dev = link->priv;
1723
1724 DEBUGP(2, dev, "-> cmm_close(maj/min=%d.%d)\n",
1725 imajor(inode), minor);
1726
1727 stop_monitor(dev);
1728
1729 ZERO_DEV(dev);
1730
1731 link->open = 0; /* only one open per device */
1732 wake_up(&dev->devq); /* socket removed? */
1733
1734 DEBUGP(2, dev, "cmm_close\n");
1735 return 0;
1736}
1737
1738static void cmm_cm4000_release(dev_link_t * link)
1739{
1740 struct cm4000_dev *dev = link->priv;
1741
1742 /* dont terminate the monitor, rather rely on
1743 * close doing that for us.
1744 */
1745 DEBUGP(3, dev, "-> cmm_cm4000_release\n");
1746 while (link->open) {
1747 printk(KERN_INFO MODULE_NAME ": delaying release until "
1748 "process has terminated\n");
1749 /* note: don't interrupt us:
1750 * close the applications which own
1751 * the devices _first_ !
1752 */
1753 wait_event(dev->devq, (link->open == 0));
1754 }
1755 /* dev->devq=NULL; this cannot be zeroed earlier */
1756 DEBUGP(3, dev, "<- cmm_cm4000_release\n");
1757 return;
1758}
1759
1760/*==== Interface to PCMCIA Layer =======================================*/
1761
1762static void cm4000_config(dev_link_t * link, int devno)
1763{
1764 client_handle_t handle = link->handle;
1765 struct cm4000_dev *dev;
1766 tuple_t tuple;
1767 cisparse_t parse;
1768 config_info_t conf;
1769 u_char buf[64];
1770 int fail_fn, fail_rc;
1771 int rc;
1772
1773 /* read the config-tuples */
1774 tuple.DesiredTuple = CISTPL_CONFIG;
1775 tuple.Attributes = 0;
1776 tuple.TupleData = buf;
1777 tuple.TupleDataMax = sizeof(buf);
1778 tuple.TupleOffset = 0;
1779
1780 if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) {
1781 fail_fn = GetFirstTuple;
1782 goto cs_failed;
1783 }
1784 if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) {
1785 fail_fn = GetTupleData;
1786 goto cs_failed;
1787 }
1788 if ((fail_rc =
1789 pcmcia_parse_tuple(handle, &tuple, &parse)) != CS_SUCCESS) {
1790 fail_fn = ParseTuple;
1791 goto cs_failed;
1792 }
1793 if ((fail_rc =
1794 pcmcia_get_configuration_info(handle, &conf)) != CS_SUCCESS) {
1795 fail_fn = GetConfigurationInfo;
1796 goto cs_failed;
1797 }
1798
1799 link->state |= DEV_CONFIG;
1800 link->conf.ConfigBase = parse.config.base;
1801 link->conf.Present = parse.config.rmask[0];
1802 link->conf.Vcc = conf.Vcc;
1803
1804 link->io.BasePort2 = 0;
1805 link->io.NumPorts2 = 0;
1806 link->io.Attributes2 = 0;
1807 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
1808 for (rc = pcmcia_get_first_tuple(handle, &tuple);
1809 rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(handle, &tuple)) {
1810
1811 rc = pcmcia_get_tuple_data(handle, &tuple);
1812 if (rc != CS_SUCCESS)
1813 continue;
1814 rc = pcmcia_parse_tuple(handle, &tuple, &parse);
1815 if (rc != CS_SUCCESS)
1816 continue;
1817
1818 link->conf.ConfigIndex = parse.cftable_entry.index;
1819
1820 if (!parse.cftable_entry.io.nwin)
1821 continue;
1822
1823 /* Get the IOaddr */
1824 link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
1825 link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
1826 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
1827 if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT))
1828 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
1829 if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT))
1830 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
1831 link->io.IOAddrLines = parse.cftable_entry.io.flags
1832 & CISTPL_IO_LINES_MASK;
1833
1834 rc = pcmcia_request_io(handle, &link->io);
1835 if (rc == CS_SUCCESS)
1836 break; /* we are done */
1837 }
1838 if (rc != CS_SUCCESS)
1839 goto cs_release;
1840
1841 link->conf.IntType = 00000002;
1842
1843 if ((fail_rc =
1844 pcmcia_request_configuration(handle, &link->conf)) != CS_SUCCESS) {
1845 fail_fn = RequestConfiguration;
1846 goto cs_release;
1847 }
1848
1849 dev = link->priv;
1850 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
1851 dev->node.major = major;
1852 dev->node.minor = devno;
1853 dev->node.next = NULL;
1854 link->dev = &dev->node;
1855 link->state &= ~DEV_CONFIG_PENDING;
1856
1857 return;
1858
1859cs_failed:
1860 cs_error(handle, fail_fn, fail_rc);
1861cs_release:
1862 cm4000_release(link);
1863
1864 link->state &= ~DEV_CONFIG_PENDING;
1865}
1866
1867static int cm4000_event(event_t event, int priority,
1868 event_callback_args_t *args)
1869{
1870 dev_link_t *link;
1871 struct cm4000_dev *dev;
1872 int devno;
1873
1874 link = args->client_data;
1875 dev = link->priv;
1876
1877 DEBUGP(3, dev, "-> cm4000_event\n");
1878 for (devno = 0; devno < CM4000_MAX_DEV; devno++)
1879 if (dev_table[devno] == link)
1880 break;
1881
1882 if (devno == CM4000_MAX_DEV)
1883 return CS_BAD_ADAPTER;
1884
1885 switch (event) {
1886 case CS_EVENT_CARD_INSERTION:
1887 DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n");
1888 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
1889 cm4000_config(link, devno);
1890 break;
1891 case CS_EVENT_CARD_REMOVAL:
1892 DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
1893 link->state &= ~DEV_PRESENT;
1894 stop_monitor(dev);
1895 break;
1896 case CS_EVENT_PM_SUSPEND:
1897 DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
1898 "(fall-through to CS_EVENT_RESET_PHYSICAL)\n");
1899 link->state |= DEV_SUSPEND;
1900 /* fall-through */
1901 case CS_EVENT_RESET_PHYSICAL:
1902 DEBUGP(5, dev, "CS_EVENT_RESET_PHYSICAL\n");
1903 if (link->state & DEV_CONFIG) {
1904 DEBUGP(5, dev, "ReleaseConfiguration\n");
1905 pcmcia_release_configuration(link->handle);
1906 }
1907 stop_monitor(dev);
1908 break;
1909 case CS_EVENT_PM_RESUME:
1910 DEBUGP(5, dev, "CS_EVENT_PM_RESUME "
1911 "(fall-through to CS_EVENT_CARD_RESET)\n");
1912 link->state &= ~DEV_SUSPEND;
1913 /* fall-through */
1914 case CS_EVENT_CARD_RESET:
1915 DEBUGP(5, dev, "CS_EVENT_CARD_RESET\n");
1916 if ((link->state & DEV_CONFIG)) {
1917 DEBUGP(5, dev, "RequestConfiguration\n");
1918 pcmcia_request_configuration(link->handle, &link->conf);
1919 }
1920 if (link->open)
1921 start_monitor(dev);
1922 break;
1923 default:
1924 DEBUGP(5, dev, "unknown event %.2x\n", event);
1925 break;
1926 }
1927 DEBUGP(3, dev, "<- cm4000_event\n");
1928 return CS_SUCCESS;
1929}
1930
1931static void cm4000_release(dev_link_t *link)
1932{
1933 cmm_cm4000_release(link->priv); /* delay release until device closed */
1934 pcmcia_release_configuration(link->handle);
1935 pcmcia_release_io(link->handle, &link->io);
1936}
1937
1938static dev_link_t *cm4000_attach(void)
1939{
1940 struct cm4000_dev *dev;
1941 dev_link_t *link;
1942 client_reg_t client_reg;
1943 int i;
1944
1945 for (i = 0; i < CM4000_MAX_DEV; i++)
1946 if (dev_table[i] == NULL)
1947 break;
1948
1949 if (i == CM4000_MAX_DEV) {
1950 printk(KERN_NOTICE MODULE_NAME ": all devices in use\n");
1951 return NULL;
1952 }
1953
1954 /* create a new cm4000_cs device */
1955 dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL);
1956 if (dev == NULL)
1957 return NULL;
1958
1959 link = &dev->link;
1960 link->priv = dev;
1961 link->conf.IntType = INT_MEMORY_AND_IO;
1962 dev_table[i] = link;
1963
1964 /* register with card services */
1965 client_reg.dev_info = &dev_info;
1966 client_reg.EventMask =
1967 CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL |
1968 CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET |
1969 CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME;
1970 client_reg.Version = 0x0210;
1971 client_reg.event_callback_args.client_data = link;
1972
1973 i = pcmcia_register_client(&link->handle, &client_reg);
1974 if (i) {
1975 cs_error(link->handle, RegisterClient, i);
1976 cm4000_detach(link);
1977 return NULL;
1978 }
1979
1980 init_waitqueue_head(&dev->devq);
1981 init_waitqueue_head(&dev->ioq);
1982 init_waitqueue_head(&dev->atrq);
1983 init_waitqueue_head(&dev->readq);
1984
1985 return link;
1986}
1987
1988static void cm4000_detach_by_devno(int devno, dev_link_t * link)
1989{
1990 struct cm4000_dev *dev = link->priv;
1991
1992 DEBUGP(3, dev, "-> detach_by_devno(devno=%d)\n", devno);
1993
1994 if (link->state & DEV_CONFIG) {
1995 DEBUGP(5, dev, "device still configured (try to release it)\n");
1996 cm4000_release(link);
1997 }
1998
1999 if (link->handle) {
2000 pcmcia_deregister_client(link->handle);
2001 }
2002
2003 dev_table[devno] = NULL;
2004 kfree(dev);
2005 return;
2006}
2007
2008static void cm4000_detach(dev_link_t * link)
2009{
2010 int i;
2011
2012 /* find device */
2013 for (i = 0; i < CM4000_MAX_DEV; i++)
2014 if (dev_table[i] == link)
2015 break;
2016
2017 if (i == CM4000_MAX_DEV)
2018 return;
2019
2020 cm4000_detach_by_devno(i, link);
2021 return;
2022}
2023
2024static struct file_operations cm4000_fops = {
2025 .owner = THIS_MODULE,
2026 .read = cmm_read,
2027 .write = cmm_write,
2028 .ioctl = cmm_ioctl,
2029 .open = cmm_open,
2030 .release= cmm_close,
2031};
2032
2033static struct pcmcia_device_id cm4000_ids[] = {
2034 PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0002),
2035 PCMCIA_DEVICE_PROD_ID12("CardMan", "4000", 0x2FB368CA, 0xA2BD8C39),
2036 PCMCIA_DEVICE_NULL,
2037};
2038MODULE_DEVICE_TABLE(pcmcia, cm4000_ids);
2039
2040static struct pcmcia_driver cm4000_driver = {
2041 .owner = THIS_MODULE,
2042 .drv = {
2043 .name = "cm4000_cs",
2044 },
2045 .attach = cm4000_attach,
2046 .detach = cm4000_detach,
2047 .event = cm4000_event,
2048 .id_table = cm4000_ids,
2049};
2050
2051static int __init cmm_init(void)
2052{
2053 printk(KERN_INFO "%s\n", version);
2054 pcmcia_register_driver(&cm4000_driver);
2055 major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
2056 if (major < 0) {
2057 printk(KERN_WARNING MODULE_NAME
2058 ": could not get major number\n");
2059 return -1;
2060 }
2061
2062 return 0;
2063}
2064
2065static void __exit cmm_exit(void)
2066{
2067 int i;
2068
2069 printk(KERN_INFO MODULE_NAME ": unloading\n");
2070 pcmcia_unregister_driver(&cm4000_driver);
2071 for (i = 0; i < CM4000_MAX_DEV; i++)
2072 if (dev_table[i])
2073 cm4000_detach_by_devno(i, dev_table[i]);
2074 unregister_chrdev(major, DEVICE_NAME);
2075};
2076
2077module_init(cmm_init);
2078module_exit(cmm_exit);
2079MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
new file mode 100644
index 000000000000..4c698d908ffa
--- /dev/null
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -0,0 +1,841 @@
1/*
2 * A driver for the Omnikey PCMCIA smartcard reader CardMan 4040
3 *
4 * (c) 2000-2004 Omnikey AG (http://www.omnikey.com/)
5 *
6 * (C) 2005 Harald Welte <laforge@gnumonks.org>
7 * - add support for poll()
8 * - driver cleanup
9 * - add waitqueues
10 * - adhere to linux kernel coding style and policies
11 * - support 2.6.13 "new style" pcmcia interface
12 *
13 * The device basically is a USB CCID compliant device that has been
14 * attached to an I/O-Mapped FIFO.
15 *
16 * All rights reserved, Dual BSD/GPL Licensed.
17 */
18
19/* #define PCMCIA_DEBUG 6 */
20
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/init.h>
25#include <linux/fs.h>
26#include <linux/delay.h>
27#include <linux/poll.h>
28#include <linux/wait.h>
29#include <asm/uaccess.h>
30#include <asm/io.h>
31
32#include <pcmcia/cs_types.h>
33#include <pcmcia/cs.h>
34#include <pcmcia/cistpl.h>
35#include <pcmcia/cisreg.h>
36#include <pcmcia/ciscode.h>
37#include <pcmcia/ds.h>
38
39#include "cm4040_cs.h"
40
41
42#ifdef PCMCIA_DEBUG
43#define reader_to_dev(x) (&handle_to_dev(x->link.handle))
44static int pc_debug = PCMCIA_DEBUG;
45module_param(pc_debug, int, 0600);
46#define DEBUGP(n, rdr, x, args...) do { \
47 if (pc_debug >= (n)) \
48 dev_printk(KERN_DEBUG, reader_to_dev(rdr), "%s:" x, \
49 __FUNCTION__ , ##args); \
50 } while (0)
51#else
52#define DEBUGP(n, rdr, x, args...)
53#endif
54
55static char *version =
56"OMNIKEY CardMan 4040 v1.1.0gm4 - All bugs added by Harald Welte";
57
58#define CCID_DRIVER_BULK_DEFAULT_TIMEOUT (150*HZ)
59#define CCID_DRIVER_ASYNC_POWERUP_TIMEOUT (35*HZ)
60#define CCID_DRIVER_MINIMUM_TIMEOUT (3*HZ)
61#define READ_WRITE_BUFFER_SIZE 512
62#define POLL_LOOP_COUNT 1000
63
64/* how often to poll for fifo status change */
65#define POLL_PERIOD msecs_to_jiffies(10)
66
67static void reader_release(dev_link_t *link);
68static void reader_detach(dev_link_t *link);
69
70static int major;
71
72#define BS_READABLE 0x01
73#define BS_WRITABLE 0x02
74
75struct reader_dev {
76 dev_link_t link;
77 dev_node_t node;
78 wait_queue_head_t devq;
79 wait_queue_head_t poll_wait;
80 wait_queue_head_t read_wait;
81 wait_queue_head_t write_wait;
82 unsigned long buffer_status;
83 unsigned long timeout;
84 unsigned char s_buf[READ_WRITE_BUFFER_SIZE];
85 unsigned char r_buf[READ_WRITE_BUFFER_SIZE];
86 struct timer_list poll_timer;
87};
88
89static dev_info_t dev_info = MODULE_NAME;
90static dev_link_t *dev_table[CM_MAX_DEV];
91
92#ifndef PCMCIA_DEBUG
93#define xoutb outb
94#define xinb inb
95#else
96static inline void xoutb(unsigned char val, unsigned short port)
97{
98 if (pc_debug >= 7)
99 printk(KERN_DEBUG "outb(val=%.2x,port=%.4x)\n", val, port);
100 outb(val, port);
101}
102
103static inline unsigned char xinb(unsigned short port)
104{
105 unsigned char val;
106
107 val = inb(port);
108 if (pc_debug >= 7)
109 printk(KERN_DEBUG "%.2x=inb(%.4x)\n", val, port);
110 return val;
111}
112#endif
113
114/* poll the device fifo status register. not to be confused with
115 * the poll syscall. */
116static void cm4040_do_poll(unsigned long dummy)
117{
118 struct reader_dev *dev = (struct reader_dev *) dummy;
119 unsigned int obs = xinb(dev->link.io.BasePort1
120 + REG_OFFSET_BUFFER_STATUS);
121
122 if ((obs & BSR_BULK_IN_FULL)) {
123 set_bit(BS_READABLE, &dev->buffer_status);
124 DEBUGP(4, dev, "waking up read_wait\n");
125 wake_up_interruptible(&dev->read_wait);
126 } else
127 clear_bit(BS_READABLE, &dev->buffer_status);
128
129 if (!(obs & BSR_BULK_OUT_FULL)) {
130 set_bit(BS_WRITABLE, &dev->buffer_status);
131 DEBUGP(4, dev, "waking up write_wait\n");
132 wake_up_interruptible(&dev->write_wait);
133 } else
134 clear_bit(BS_WRITABLE, &dev->buffer_status);
135
136 if (dev->buffer_status)
137 wake_up_interruptible(&dev->poll_wait);
138
139 mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);
140}
141
142static void cm4040_stop_poll(struct reader_dev *dev)
143{
144 del_timer_sync(&dev->poll_timer);
145}
146
147static int wait_for_bulk_out_ready(struct reader_dev *dev)
148{
149 int i, rc;
150 int iobase = dev->link.io.BasePort1;
151
152 for (i = 0; i < POLL_LOOP_COUNT; i++) {
153 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
154 & BSR_BULK_OUT_FULL) == 0) {
155 DEBUGP(4, dev, "BulkOut empty (i=%d)\n", i);
156 return 1;
157 }
158 }
159
160 DEBUGP(4, dev, "wait_event_interruptible_timeout(timeout=%ld\n",
161 dev->timeout);
162 rc = wait_event_interruptible_timeout(dev->write_wait,
163 test_and_clear_bit(BS_WRITABLE,
164 &dev->buffer_status),
165 dev->timeout);
166
167 if (rc > 0)
168 DEBUGP(4, dev, "woke up: BulkOut empty\n");
169 else if (rc == 0)
170 DEBUGP(4, dev, "woke up: BulkOut full, returning 0 :(\n");
171 else if (rc < 0)
172 DEBUGP(4, dev, "woke up: signal arrived\n");
173
174 return rc;
175}
176
177/* Write to Sync Control Register */
178static int write_sync_reg(unsigned char val, struct reader_dev *dev)
179{
180 int iobase = dev->link.io.BasePort1;
181 int rc;
182
183 rc = wait_for_bulk_out_ready(dev);
184 if (rc <= 0)
185 return rc;
186
187 xoutb(val, iobase + REG_OFFSET_SYNC_CONTROL);
188 rc = wait_for_bulk_out_ready(dev);
189 if (rc <= 0)
190 return rc;
191
192 return 1;
193}
194
195static int wait_for_bulk_in_ready(struct reader_dev *dev)
196{
197 int i, rc;
198 int iobase = dev->link.io.BasePort1;
199
200 for (i = 0; i < POLL_LOOP_COUNT; i++) {
201 if ((xinb(iobase + REG_OFFSET_BUFFER_STATUS)
202 & BSR_BULK_IN_FULL) == BSR_BULK_IN_FULL) {
203 DEBUGP(3, dev, "BulkIn full (i=%d)\n", i);
204 return 1;
205 }
206 }
207
208 DEBUGP(4, dev, "wait_event_interruptible_timeout(timeout=%ld\n",
209 dev->timeout);
210 rc = wait_event_interruptible_timeout(dev->read_wait,
211 test_and_clear_bit(BS_READABLE,
212 &dev->buffer_status),
213 dev->timeout);
214 if (rc > 0)
215 DEBUGP(4, dev, "woke up: BulkIn full\n");
216 else if (rc == 0)
217 DEBUGP(4, dev, "woke up: BulkIn not full, returning 0 :(\n");
218 else if (rc < 0)
219 DEBUGP(4, dev, "woke up: signal arrived\n");
220
221 return rc;
222}
223
224static ssize_t cm4040_read(struct file *filp, char __user *buf,
225 size_t count, loff_t *ppos)
226{
227 struct reader_dev *dev = filp->private_data;
228 int iobase = dev->link.io.BasePort1;
229 size_t bytes_to_read;
230 unsigned long i;
231 size_t min_bytes_to_read;
232 int rc;
233 unsigned char uc;
234
235 DEBUGP(2, dev, "-> cm4040_read(%s,%d)\n", current->comm, current->pid);
236
237 if (count == 0)
238 return 0;
239
240 if (count < 10)
241 return -EFAULT;
242
243 if (filp->f_flags & O_NONBLOCK) {
244 DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
245 DEBUGP(2, dev, "<- cm4040_read (failure)\n");
246 return -EAGAIN;
247 }
248
249 if ((dev->link.state & DEV_PRESENT)==0)
250 return -ENODEV;
251
252 for (i = 0; i < 5; i++) {
253 rc = wait_for_bulk_in_ready(dev);
254 if (rc <= 0) {
255 DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc);
256 DEBUGP(2, dev, "<- cm4040_read (failed)\n");
257 if (rc == -ERESTARTSYS)
258 return rc;
259 return -EIO;
260 }
261 dev->r_buf[i] = xinb(iobase + REG_OFFSET_BULK_IN);
262#ifdef PCMCIA_DEBUG
263 if (pc_debug >= 6)
264 printk(KERN_DEBUG "%lu:%2x ", i, dev->r_buf[i]);
265 }
266 printk("\n");
267#else
268 }
269#endif
270
271 bytes_to_read = 5 + le32_to_cpu(*(__le32 *)&dev->r_buf[1]);
272
273 DEBUGP(6, dev, "BytesToRead=%lu\n", bytes_to_read);
274
275 min_bytes_to_read = min(count, bytes_to_read + 5);
276
277 DEBUGP(6, dev, "Min=%lu\n", min_bytes_to_read);
278
279 for (i = 0; i < (min_bytes_to_read-5); i++) {
280 rc = wait_for_bulk_in_ready(dev);
281 if (rc <= 0) {
282 DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc);
283 DEBUGP(2, dev, "<- cm4040_read (failed)\n");
284 if (rc == -ERESTARTSYS)
285 return rc;
286 return -EIO;
287 }
288 dev->r_buf[i+5] = xinb(iobase + REG_OFFSET_BULK_IN);
289#ifdef PCMCIA_DEBUG
290 if (pc_debug >= 6)
291 printk(KERN_DEBUG "%lu:%2x ", i, dev->r_buf[i]);
292 }
293 printk("\n");
294#else
295 }
296#endif
297
298 *ppos = min_bytes_to_read;
299 if (copy_to_user(buf, dev->r_buf, min_bytes_to_read))
300 return -EFAULT;
301
302 rc = wait_for_bulk_in_ready(dev);
303 if (rc <= 0) {
304 DEBUGP(5, dev, "wait_for_bulk_in_ready rc=%.2x\n", rc);
305 DEBUGP(2, dev, "<- cm4040_read (failed)\n");
306 if (rc == -ERESTARTSYS)
307 return rc;
308 return -EIO;
309 }
310
311 rc = write_sync_reg(SCR_READER_TO_HOST_DONE, dev);
312 if (rc <= 0) {
313 DEBUGP(5, dev, "write_sync_reg c=%.2x\n", rc);
314 DEBUGP(2, dev, "<- cm4040_read (failed)\n");
315 if (rc == -ERESTARTSYS)
316 return rc;
317 else
318 return -EIO;
319 }
320
321 uc = xinb(iobase + REG_OFFSET_BULK_IN);
322
323 DEBUGP(2, dev, "<- cm4040_read (successfully)\n");
324 return min_bytes_to_read;
325}
326
327static ssize_t cm4040_write(struct file *filp, const char __user *buf,
328 size_t count, loff_t *ppos)
329{
330 struct reader_dev *dev = filp->private_data;
331 int iobase = dev->link.io.BasePort1;
332 ssize_t rc;
333 int i;
334 unsigned int bytes_to_write;
335
336 DEBUGP(2, dev, "-> cm4040_write(%s,%d)\n", current->comm, current->pid);
337
338 if (count == 0) {
339 DEBUGP(2, dev, "<- cm4040_write empty read (successfully)\n");
340 return 0;
341 }
342
343 if (count < 5) {
344 DEBUGP(2, dev, "<- cm4040_write buffersize=%Zd < 5\n", count);
345 return -EIO;
346 }
347
348 if (filp->f_flags & O_NONBLOCK) {
349 DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
350 DEBUGP(4, dev, "<- cm4040_write (failure)\n");
351 return -EAGAIN;
352 }
353
354 if ((dev->link.state & DEV_PRESENT) == 0)
355 return -ENODEV;
356
357 bytes_to_write = count;
358 if (copy_from_user(dev->s_buf, buf, bytes_to_write))
359 return -EFAULT;
360
361 switch (dev->s_buf[0]) {
362 case CMD_PC_TO_RDR_XFRBLOCK:
363 case CMD_PC_TO_RDR_SECURE:
364 case CMD_PC_TO_RDR_TEST_SECURE:
365 case CMD_PC_TO_RDR_OK_SECURE:
366 dev->timeout = CCID_DRIVER_BULK_DEFAULT_TIMEOUT;
367 break;
368
369 case CMD_PC_TO_RDR_ICCPOWERON:
370 dev->timeout = CCID_DRIVER_ASYNC_POWERUP_TIMEOUT;
371 break;
372
373 case CMD_PC_TO_RDR_GETSLOTSTATUS:
374 case CMD_PC_TO_RDR_ICCPOWEROFF:
375 case CMD_PC_TO_RDR_GETPARAMETERS:
376 case CMD_PC_TO_RDR_RESETPARAMETERS:
377 case CMD_PC_TO_RDR_SETPARAMETERS:
378 case CMD_PC_TO_RDR_ESCAPE:
379 case CMD_PC_TO_RDR_ICCCLOCK:
380 default:
381 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
382 break;
383 }
384
385 rc = write_sync_reg(SCR_HOST_TO_READER_START, dev);
386 if (rc <= 0) {
387 DEBUGP(5, dev, "write_sync_reg c=%.2Zx\n", rc);
388 DEBUGP(2, dev, "<- cm4040_write (failed)\n");
389 if (rc == -ERESTARTSYS)
390 return rc;
391 else
392 return -EIO;
393 }
394
395 DEBUGP(4, dev, "start \n");
396
397 for (i = 0; i < bytes_to_write; i++) {
398 rc = wait_for_bulk_out_ready(dev);
399 if (rc <= 0) {
400 DEBUGP(5, dev, "wait_for_bulk_out_ready rc=%.2Zx\n",
401 rc);
402 DEBUGP(2, dev, "<- cm4040_write (failed)\n");
403 if (rc == -ERESTARTSYS)
404 return rc;
405 else
406 return -EIO;
407 }
408
409 xoutb(dev->s_buf[i],iobase + REG_OFFSET_BULK_OUT);
410 }
411 DEBUGP(4, dev, "end\n");
412
413 rc = write_sync_reg(SCR_HOST_TO_READER_DONE, dev);
414
415 if (rc <= 0) {
416 DEBUGP(5, dev, "write_sync_reg c=%.2Zx\n", rc);
417 DEBUGP(2, dev, "<- cm4040_write (failed)\n");
418 if (rc == -ERESTARTSYS)
419 return rc;
420 else
421 return -EIO;
422 }
423
424 DEBUGP(2, dev, "<- cm4040_write (successfully)\n");
425 return count;
426}
427
428static unsigned int cm4040_poll(struct file *filp, poll_table *wait)
429{
430 struct reader_dev *dev = filp->private_data;
431 unsigned int mask = 0;
432
433 poll_wait(filp, &dev->poll_wait, wait);
434
435 if (test_and_clear_bit(BS_READABLE, &dev->buffer_status))
436 mask |= POLLIN | POLLRDNORM;
437 if (test_and_clear_bit(BS_WRITABLE, &dev->buffer_status))
438 mask |= POLLOUT | POLLWRNORM;
439
440 DEBUGP(2, dev, "<- cm4040_poll(%u)\n", mask);
441
442 return mask;
443}
444
445static int cm4040_open(struct inode *inode, struct file *filp)
446{
447 struct reader_dev *dev;
448 dev_link_t *link;
449 int minor = iminor(inode);
450
451 if (minor >= CM_MAX_DEV)
452 return -ENODEV;
453
454 link = dev_table[minor];
455 if (link == NULL || !(DEV_OK(link)))
456 return -ENODEV;
457
458 if (link->open)
459 return -EBUSY;
460
461 dev = link->priv;
462 filp->private_data = dev;
463
464 if (filp->f_flags & O_NONBLOCK) {
465 DEBUGP(4, dev, "filep->f_flags O_NONBLOCK set\n");
466 return -EAGAIN;
467 }
468
469 link->open = 1;
470
471 dev->poll_timer.data = (unsigned long) dev;
472 mod_timer(&dev->poll_timer, jiffies + POLL_PERIOD);
473
474 DEBUGP(2, dev, "<- cm4040_open (successfully)\n");
475 return nonseekable_open(inode, filp);
476}
477
478static int cm4040_close(struct inode *inode, struct file *filp)
479{
480 struct reader_dev *dev = filp->private_data;
481 dev_link_t *link;
482 int minor = iminor(inode);
483
484 DEBUGP(2, dev, "-> cm4040_close(maj/min=%d.%d)\n", imajor(inode),
485 iminor(inode));
486
487 if (minor >= CM_MAX_DEV)
488 return -ENODEV;
489
490 link = dev_table[minor];
491 if (link == NULL)
492 return -ENODEV;
493
494 cm4040_stop_poll(dev);
495
496 link->open = 0;
497 wake_up(&dev->devq);
498
499 DEBUGP(2, dev, "<- cm4040_close\n");
500 return 0;
501}
502
503static void cm4040_reader_release(dev_link_t *link)
504{
505 struct reader_dev *dev = link->priv;
506
507 DEBUGP(3, dev, "-> cm4040_reader_release\n");
508 while (link->open) {
509 DEBUGP(3, dev, KERN_INFO MODULE_NAME ": delaying release "
510 "until process has terminated\n");
511 wait_event(dev->devq, (link->open == 0));
512 }
513 DEBUGP(3, dev, "<- cm4040_reader_release\n");
514 return;
515}
516
517static void reader_config(dev_link_t *link, int devno)
518{
519 client_handle_t handle;
520 struct reader_dev *dev;
521 tuple_t tuple;
522 cisparse_t parse;
523 config_info_t conf;
524 u_char buf[64];
525 int fail_fn, fail_rc;
526 int rc;
527
528 handle = link->handle;
529
530 tuple.DesiredTuple = CISTPL_CONFIG;
531 tuple.Attributes = 0;
532 tuple.TupleData = buf;
533 tuple.TupleDataMax = sizeof(buf);
534 tuple.TupleOffset = 0;
535
536 if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) {
537 fail_fn = GetFirstTuple;
538 goto cs_failed;
539 }
540 if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) {
541 fail_fn = GetTupleData;
542 goto cs_failed;
543 }
544 if ((fail_rc = pcmcia_parse_tuple(handle, &tuple, &parse))
545 != CS_SUCCESS) {
546 fail_fn = ParseTuple;
547 goto cs_failed;
548 }
549 if ((fail_rc = pcmcia_get_configuration_info(handle, &conf))
550 != CS_SUCCESS) {
551 fail_fn = GetConfigurationInfo;
552 goto cs_failed;
553 }
554
555 link->state |= DEV_CONFIG;
556 link->conf.ConfigBase = parse.config.base;
557 link->conf.Present = parse.config.rmask[0];
558 link->conf.Vcc = conf.Vcc;
559
560 link->io.BasePort2 = 0;
561 link->io.NumPorts2 = 0;
562 link->io.Attributes2 = 0;
563 tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY;
564 for (rc = pcmcia_get_first_tuple(handle, &tuple);
565 rc == CS_SUCCESS;
566 rc = pcmcia_get_next_tuple(handle, &tuple)) {
567 rc = pcmcia_get_tuple_data(handle, &tuple);
568 if (rc != CS_SUCCESS)
569 continue;
570 rc = pcmcia_parse_tuple(handle, &tuple, &parse);
571 if (rc != CS_SUCCESS)
572 continue;
573
574 link->conf.ConfigIndex = parse.cftable_entry.index;
575
576 if (!parse.cftable_entry.io.nwin)
577 continue;
578
579 link->io.BasePort1 = parse.cftable_entry.io.win[0].base;
580 link->io.NumPorts1 = parse.cftable_entry.io.win[0].len;
581 link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
582 if (!(parse.cftable_entry.io.flags & CISTPL_IO_8BIT))
583 link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
584 if (!(parse.cftable_entry.io.flags & CISTPL_IO_16BIT))
585 link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
586 link->io.IOAddrLines = parse.cftable_entry.io.flags
587 & CISTPL_IO_LINES_MASK;
588 rc = pcmcia_request_io(handle, &link->io);
589
590 dev_printk(KERN_INFO, &handle_to_dev(handle), "foo");
591 if (rc == CS_SUCCESS)
592 break;
593 else
594 dev_printk(KERN_INFO, &handle_to_dev(handle),
595 "pcmcia_request_io failed 0x%x\n", rc);
596 }
597 if (rc != CS_SUCCESS)
598 goto cs_release;
599
600 link->conf.IntType = 00000002;
601
602 if ((fail_rc = pcmcia_request_configuration(handle,&link->conf))
603 !=CS_SUCCESS) {
604 fail_fn = RequestConfiguration;
605 dev_printk(KERN_INFO, &handle_to_dev(handle),
606 "pcmcia_request_configuration failed 0x%x\n",
607 fail_rc);
608 goto cs_release;
609 }
610
611 dev = link->priv;
612 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
613 dev->node.major = major;
614 dev->node.minor = devno;
615 dev->node.next = NULL;
616 link->dev = &dev->node;
617 link->state &= ~DEV_CONFIG_PENDING;
618
619 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
620 link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1);
621 DEBUGP(2, dev, "<- reader_config (succ)\n");
622
623 return;
624
625cs_failed:
626 cs_error(handle, fail_fn, fail_rc);
627cs_release:
628 reader_release(link);
629 link->state &= ~DEV_CONFIG_PENDING;
630}
631
632static int reader_event(event_t event, int priority,
633 event_callback_args_t *args)
634{
635 dev_link_t *link;
636 struct reader_dev *dev;
637 int devno;
638
639 link = args->client_data;
640 dev = link->priv;
641 DEBUGP(3, dev, "-> reader_event\n");
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
649 switch (event) {
650 case CS_EVENT_CARD_INSERTION:
651 DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n");
652 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
653 reader_config(link, devno);
654 break;
655 case CS_EVENT_CARD_REMOVAL:
656 DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n");
657 link->state &= ~DEV_PRESENT;
658 break;
659 case CS_EVENT_PM_SUSPEND:
660 DEBUGP(5, dev, "CS_EVENT_PM_SUSPEND "
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}
692
693static void reader_release(dev_link_t *link)
694{
695 cm4040_reader_release(link->priv);
696 pcmcia_release_configuration(link->handle);
697 pcmcia_release_io(link->handle, &link->io);
698}
699
700static dev_link_t *reader_attach(void)
701{
702 struct reader_dev *dev;
703 dev_link_t *link;
704 client_reg_t client_reg;
705 int i;
706
707 for (i = 0; i < CM_MAX_DEV; i++) {
708 if (dev_table[i] == NULL)
709 break;
710 }
711
712 if (i == CM_MAX_DEV)
713 return NULL;
714
715 dev = kzalloc(sizeof(struct reader_dev), GFP_KERNEL);
716 if (dev == NULL)
717 return NULL;
718
719 dev->timeout = CCID_DRIVER_MINIMUM_TIMEOUT;
720 dev->buffer_status = 0;
721
722 link = &dev->link;
723 link->priv = dev;
724
725 link->conf.IntType = INT_MEMORY_AND_IO;
726 dev_table[i] = link;
727
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);
743 init_waitqueue_head(&dev->poll_wait);
744 init_waitqueue_head(&dev->read_wait);
745 init_waitqueue_head(&dev->write_wait);
746 init_timer(&dev->poll_timer);
747 dev->poll_timer.function = &cm4040_do_poll;
748
749 return link;
750}
751
752static void reader_detach_by_devno(int devno, dev_link_t *link)
753{
754 struct reader_dev *dev = link->priv;
755
756 if (link->state & DEV_CONFIG) {
757 DEBUGP(5, dev, "device still configured (try to release it)\n");
758 reader_release(link);
759 }
760
761 pcmcia_deregister_client(link->handle);
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}
768
769static void reader_detach(dev_link_t *link)
770{
771 int i;
772
773 /* find device */
774 for (i = 0; i < CM_MAX_DEV; i++) {
775 if (dev_table[i] == link)
776 break;
777 }
778 if (i == CM_MAX_DEV)
779 return;
780
781 reader_detach_by_devno(i, link);
782 return;
783}
784
785static struct file_operations reader_fops = {
786 .owner = THIS_MODULE,
787 .read = cm4040_read,
788 .write = cm4040_write,
789 .open = cm4040_open,
790 .release = cm4040_close,
791 .poll = cm4040_poll,
792};
793
794static struct pcmcia_device_id cm4040_ids[] = {
795 PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0200),
796 PCMCIA_DEVICE_PROD_ID12("OMNIKEY", "CardMan 4040",
797 0xE32CDD8C, 0x8F23318B),
798 PCMCIA_DEVICE_NULL,
799};
800MODULE_DEVICE_TABLE(pcmcia, cm4040_ids);
801
802static struct pcmcia_driver reader_driver = {
803 .owner = THIS_MODULE,
804 .drv = {
805 .name = "cm4040_cs",
806 },
807 .attach = reader_attach,
808 .detach = reader_detach,
809 .event = reader_event,
810 .id_table = cm4040_ids,
811};
812
813static int __init cm4040_init(void)
814{
815 printk(KERN_INFO "%s\n", version);
816 pcmcia_register_driver(&reader_driver);
817 major = register_chrdev(0, DEVICE_NAME, &reader_fops);
818 if (major < 0) {
819 printk(KERN_WARNING MODULE_NAME
820 ": could not get major number\n");
821 return -1;
822 }
823 return 0;
824}
825
826static void __exit cm4040_exit(void)
827{
828 int i;
829
830 printk(KERN_INFO MODULE_NAME ": unloading\n");
831 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);
837}
838
839module_init(cm4040_init);
840module_exit(cm4040_exit);
841MODULE_LICENSE("Dual BSD/GPL");
diff --git a/drivers/char/pcmcia/cm4040_cs.h b/drivers/char/pcmcia/cm4040_cs.h
new file mode 100644
index 000000000000..9a8b805c5095
--- /dev/null
+++ b/drivers/char/pcmcia/cm4040_cs.h
@@ -0,0 +1,47 @@
1#ifndef _CM4040_H_
2#define _CM4040_H_
3
4#define CM_MAX_DEV 4
5
6#define DEVICE_NAME "cmx"
7#define MODULE_NAME "cm4040_cs"
8
9#define REG_OFFSET_BULK_OUT 0
10#define REG_OFFSET_BULK_IN 0
11#define REG_OFFSET_BUFFER_STATUS 1
12#define REG_OFFSET_SYNC_CONTROL 2
13
14#define BSR_BULK_IN_FULL 0x02
15#define BSR_BULK_OUT_FULL 0x01
16
17#define SCR_HOST_TO_READER_START 0x80
18#define SCR_ABORT 0x40
19#define SCR_EN_NOTIFY 0x20
20#define SCR_ACK_NOTIFY 0x10
21#define SCR_READER_TO_HOST_DONE 0x08
22#define SCR_HOST_TO_READER_DONE 0x04
23#define SCR_PULSE_INTERRUPT 0x02
24#define SCR_POWER_DOWN 0x01
25
26
27#define CMD_PC_TO_RDR_ICCPOWERON 0x62
28#define CMD_PC_TO_RDR_GETSLOTSTATUS 0x65
29#define CMD_PC_TO_RDR_ICCPOWEROFF 0x63
30#define CMD_PC_TO_RDR_SECURE 0x69
31#define CMD_PC_TO_RDR_GETPARAMETERS 0x6C
32#define CMD_PC_TO_RDR_RESETPARAMETERS 0x6D
33#define CMD_PC_TO_RDR_SETPARAMETERS 0x61
34#define CMD_PC_TO_RDR_XFRBLOCK 0x6F
35#define CMD_PC_TO_RDR_ESCAPE 0x6B
36#define CMD_PC_TO_RDR_ICCCLOCK 0x6E
37#define CMD_PC_TO_RDR_TEST_SECURE 0x74
38#define CMD_PC_TO_RDR_OK_SECURE 0x89
39
40
41#define CMD_RDR_TO_PC_SLOTSTATUS 0x81
42#define CMD_RDR_TO_PC_DATABLOCK 0x80
43#define CMD_RDR_TO_PC_PARAMETERS 0x82
44#define CMD_RDR_TO_PC_ESCAPE 0x83
45#define CMD_RDR_TO_PC_OK_SECURE 0x89
46
47#endif /* _CM4040_H_ */
diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c
index d724c0de4f28..3df7a574267b 100644
--- a/drivers/char/s3c2410-rtc.c
+++ b/drivers/char/s3c2410-rtc.c
@@ -382,7 +382,7 @@ static struct rtc_ops s3c2410_rtcops = {
382 .proc = s3c2410_rtc_proc, 382 .proc = s3c2410_rtc_proc,
383}; 383};
384 384
385static void s3c2410_rtc_enable(struct device *dev, int en) 385static void s3c2410_rtc_enable(struct platform_device *pdev, int en)
386{ 386{
387 unsigned int tmp; 387 unsigned int tmp;
388 388
@@ -399,21 +399,21 @@ static void s3c2410_rtc_enable(struct device *dev, int en)
399 /* re-enable the device, and check it is ok */ 399 /* re-enable the device, and check it is ok */
400 400
401 if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_RTCEN) == 0){ 401 if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_RTCEN) == 0){
402 dev_info(dev, "rtc disabled, re-enabling\n"); 402 dev_info(&pdev->dev, "rtc disabled, re-enabling\n");
403 403
404 tmp = readb(S3C2410_RTCCON); 404 tmp = readb(S3C2410_RTCCON);
405 writeb(tmp | S3C2410_RTCCON_RTCEN , S3C2410_RTCCON); 405 writeb(tmp | S3C2410_RTCCON_RTCEN , S3C2410_RTCCON);
406 } 406 }
407 407
408 if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CNTSEL)){ 408 if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CNTSEL)){
409 dev_info(dev, "removing S3C2410_RTCCON_CNTSEL\n"); 409 dev_info(&pdev->dev, "removing S3C2410_RTCCON_CNTSEL\n");
410 410
411 tmp = readb(S3C2410_RTCCON); 411 tmp = readb(S3C2410_RTCCON);
412 writeb(tmp& ~S3C2410_RTCCON_CNTSEL , S3C2410_RTCCON); 412 writeb(tmp& ~S3C2410_RTCCON_CNTSEL , S3C2410_RTCCON);
413 } 413 }
414 414
415 if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CLKRST)){ 415 if ((readb(S3C2410_RTCCON) & S3C2410_RTCCON_CLKRST)){
416 dev_info(dev, "removing S3C2410_RTCCON_CLKRST\n"); 416 dev_info(&pdev->dev, "removing S3C2410_RTCCON_CLKRST\n");
417 417
418 tmp = readb(S3C2410_RTCCON); 418 tmp = readb(S3C2410_RTCCON);
419 writeb(tmp & ~S3C2410_RTCCON_CLKRST, S3C2410_RTCCON); 419 writeb(tmp & ~S3C2410_RTCCON_CLKRST, S3C2410_RTCCON);
@@ -421,7 +421,7 @@ static void s3c2410_rtc_enable(struct device *dev, int en)
421 } 421 }
422} 422}
423 423
424static int s3c2410_rtc_remove(struct device *dev) 424static int s3c2410_rtc_remove(struct platform_device *dev)
425{ 425{
426 unregister_rtc(&s3c2410_rtcops); 426 unregister_rtc(&s3c2410_rtcops);
427 427
@@ -438,25 +438,24 @@ static int s3c2410_rtc_remove(struct device *dev)
438 return 0; 438 return 0;
439} 439}
440 440
441static int s3c2410_rtc_probe(struct device *dev) 441static int s3c2410_rtc_probe(struct platform_device *pdev)
442{ 442{
443 struct platform_device *pdev = to_platform_device(dev);
444 struct resource *res; 443 struct resource *res;
445 int ret; 444 int ret;
446 445
447 pr_debug("%s: probe=%p, device=%p\n", __FUNCTION__, pdev, dev); 446 pr_debug("%s: probe=%p\n", __FUNCTION__, pdev);
448 447
449 /* find the IRQs */ 448 /* find the IRQs */
450 449
451 s3c2410_rtc_tickno = platform_get_irq(pdev, 1); 450 s3c2410_rtc_tickno = platform_get_irq(pdev, 1);
452 if (s3c2410_rtc_tickno <= 0) { 451 if (s3c2410_rtc_tickno <= 0) {
453 dev_err(dev, "no irq for rtc tick\n"); 452 dev_err(&pdev->dev, "no irq for rtc tick\n");
454 return -ENOENT; 453 return -ENOENT;
455 } 454 }
456 455
457 s3c2410_rtc_alarmno = platform_get_irq(pdev, 0); 456 s3c2410_rtc_alarmno = platform_get_irq(pdev, 0);
458 if (s3c2410_rtc_alarmno <= 0) { 457 if (s3c2410_rtc_alarmno <= 0) {
459 dev_err(dev, "no irq for alarm\n"); 458 dev_err(&pdev->dev, "no irq for alarm\n");
460 return -ENOENT; 459 return -ENOENT;
461 } 460 }
462 461
@@ -467,7 +466,7 @@ static int s3c2410_rtc_probe(struct device *dev)
467 466
468 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 467 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
469 if (res == NULL) { 468 if (res == NULL) {
470 dev_err(dev, "failed to get memory region resource\n"); 469 dev_err(&pdev->dev, "failed to get memory region resource\n");
471 return -ENOENT; 470 return -ENOENT;
472 } 471 }
473 472
@@ -475,14 +474,14 @@ static int s3c2410_rtc_probe(struct device *dev)
475 pdev->name); 474 pdev->name);
476 475
477 if (s3c2410_rtc_mem == NULL) { 476 if (s3c2410_rtc_mem == NULL) {
478 dev_err(dev, "failed to reserve memory region\n"); 477 dev_err(&pdev->dev, "failed to reserve memory region\n");
479 ret = -ENOENT; 478 ret = -ENOENT;
480 goto exit_err; 479 goto exit_err;
481 } 480 }
482 481
483 s3c2410_rtc_base = ioremap(res->start, res->end - res->start + 1); 482 s3c2410_rtc_base = ioremap(res->start, res->end - res->start + 1);
484 if (s3c2410_rtc_base == NULL) { 483 if (s3c2410_rtc_base == NULL) {
485 dev_err(dev, "failed ioremap()\n"); 484 dev_err(&pdev->dev, "failed ioremap()\n");
486 ret = -EINVAL; 485 ret = -EINVAL;
487 goto exit_err; 486 goto exit_err;
488 } 487 }
@@ -494,7 +493,7 @@ static int s3c2410_rtc_probe(struct device *dev)
494 493
495 /* check to see if everything is setup correctly */ 494 /* check to see if everything is setup correctly */
496 495
497 s3c2410_rtc_enable(dev, 1); 496 s3c2410_rtc_enable(pdev, 1);
498 497
499 pr_debug("s3c2410_rtc: RTCCON=%02x\n", readb(S3C2410_RTCCON)); 498 pr_debug("s3c2410_rtc: RTCCON=%02x\n", readb(S3C2410_RTCCON));
500 499
@@ -506,7 +505,7 @@ static int s3c2410_rtc_probe(struct device *dev)
506 return 0; 505 return 0;
507 506
508 exit_err: 507 exit_err:
509 dev_err(dev, "error %d during initialisation\n", ret); 508 dev_err(&pdev->dev, "error %d during initialisation\n", ret);
510 509
511 return ret; 510 return ret;
512} 511}
@@ -519,7 +518,7 @@ static struct timespec s3c2410_rtc_delta;
519 518
520static int ticnt_save; 519static int ticnt_save;
521 520
522static int s3c2410_rtc_suspend(struct device *dev, pm_message_t state) 521static int s3c2410_rtc_suspend(struct platform_device *pdev, pm_message_t state)
523{ 522{
524 struct rtc_time tm; 523 struct rtc_time tm;
525 struct timespec time; 524 struct timespec time;
@@ -535,19 +534,19 @@ static int s3c2410_rtc_suspend(struct device *dev, pm_message_t state)
535 s3c2410_rtc_gettime(&tm); 534 s3c2410_rtc_gettime(&tm);
536 rtc_tm_to_time(&tm, &time.tv_sec); 535 rtc_tm_to_time(&tm, &time.tv_sec);
537 save_time_delta(&s3c2410_rtc_delta, &time); 536 save_time_delta(&s3c2410_rtc_delta, &time);
538 s3c2410_rtc_enable(dev, 0); 537 s3c2410_rtc_enable(pdev, 0);
539 538
540 return 0; 539 return 0;
541} 540}
542 541
543static int s3c2410_rtc_resume(struct device *dev) 542static int s3c2410_rtc_resume(struct platform_device *pdev)
544{ 543{
545 struct rtc_time tm; 544 struct rtc_time tm;
546 struct timespec time; 545 struct timespec time;
547 546
548 time.tv_nsec = 0; 547 time.tv_nsec = 0;
549 548
550 s3c2410_rtc_enable(dev, 1); 549 s3c2410_rtc_enable(pdev, 1);
551 s3c2410_rtc_gettime(&tm); 550 s3c2410_rtc_gettime(&tm);
552 rtc_tm_to_time(&tm, &time.tv_sec); 551 rtc_tm_to_time(&tm, &time.tv_sec);
553 restore_time_delta(&s3c2410_rtc_delta, &time); 552 restore_time_delta(&s3c2410_rtc_delta, &time);
@@ -560,14 +559,15 @@ static int s3c2410_rtc_resume(struct device *dev)
560#define s3c2410_rtc_resume NULL 559#define s3c2410_rtc_resume NULL
561#endif 560#endif
562 561
563static struct device_driver s3c2410_rtcdrv = { 562static struct platform_driver s3c2410_rtcdrv = {
564 .name = "s3c2410-rtc",
565 .owner = THIS_MODULE,
566 .bus = &platform_bus_type,
567 .probe = s3c2410_rtc_probe, 563 .probe = s3c2410_rtc_probe,
568 .remove = s3c2410_rtc_remove, 564 .remove = s3c2410_rtc_remove,
569 .suspend = s3c2410_rtc_suspend, 565 .suspend = s3c2410_rtc_suspend,
570 .resume = s3c2410_rtc_resume, 566 .resume = s3c2410_rtc_resume,
567 .driver = {
568 .name = "s3c2410-rtc",
569 .owner = THIS_MODULE,
570 },
571}; 571};
572 572
573static char __initdata banner[] = "S3C2410 RTC, (c) 2004 Simtec Electronics\n"; 573static char __initdata banner[] = "S3C2410 RTC, (c) 2004 Simtec Electronics\n";
@@ -575,12 +575,12 @@ static char __initdata banner[] = "S3C2410 RTC, (c) 2004 Simtec Electronics\n";
575static int __init s3c2410_rtc_init(void) 575static int __init s3c2410_rtc_init(void)
576{ 576{
577 printk(banner); 577 printk(banner);
578 return driver_register(&s3c2410_rtcdrv); 578 return platform_driver_register(&s3c2410_rtcdrv);
579} 579}
580 580
581static void __exit s3c2410_rtc_exit(void) 581static void __exit s3c2410_rtc_exit(void)
582{ 582{
583 driver_unregister(&s3c2410_rtcdrv); 583 platform_driver_unregister(&s3c2410_rtcdrv);
584} 584}
585 585
586module_init(s3c2410_rtc_init); 586module_init(s3c2410_rtc_init);
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
index d05067dcea01..51a07370e636 100644
--- a/drivers/char/sonypi.c
+++ b/drivers/char/sonypi.c
@@ -1168,7 +1168,7 @@ static int sonypi_disable(void)
1168#ifdef CONFIG_PM 1168#ifdef CONFIG_PM
1169static int old_camera_power; 1169static int old_camera_power;
1170 1170
1171static int sonypi_suspend(struct device *dev, pm_message_t state) 1171static int sonypi_suspend(struct platform_device *dev, pm_message_t state)
1172{ 1172{
1173 old_camera_power = sonypi_device.camera_power; 1173 old_camera_power = sonypi_device.camera_power;
1174 sonypi_disable(); 1174 sonypi_disable();
@@ -1176,26 +1176,27 @@ static int sonypi_suspend(struct device *dev, pm_message_t state)
1176 return 0; 1176 return 0;
1177} 1177}
1178 1178
1179static int sonypi_resume(struct device *dev) 1179static int sonypi_resume(struct platform_device *dev)
1180{ 1180{
1181 sonypi_enable(old_camera_power); 1181 sonypi_enable(old_camera_power);
1182 return 0; 1182 return 0;
1183} 1183}
1184#endif 1184#endif
1185 1185
1186static void sonypi_shutdown(struct device *dev) 1186static void sonypi_shutdown(struct platform_device *dev)
1187{ 1187{
1188 sonypi_disable(); 1188 sonypi_disable();
1189} 1189}
1190 1190
1191static struct device_driver sonypi_driver = { 1191static struct platform_driver sonypi_driver = {
1192 .name = "sonypi",
1193 .bus = &platform_bus_type,
1194#ifdef CONFIG_PM 1192#ifdef CONFIG_PM
1195 .suspend = sonypi_suspend, 1193 .suspend = sonypi_suspend,
1196 .resume = sonypi_resume, 1194 .resume = sonypi_resume,
1197#endif 1195#endif
1198 .shutdown = sonypi_shutdown, 1196 .shutdown = sonypi_shutdown,
1197 .driver = {
1198 .name = "sonypi",
1199 },
1199}; 1200};
1200 1201
1201static int __devinit sonypi_create_input_devices(void) 1202static int __devinit sonypi_create_input_devices(void)
@@ -1455,20 +1456,20 @@ static int __init sonypi_init(void)
1455 if (!dmi_check_system(sonypi_dmi_table)) 1456 if (!dmi_check_system(sonypi_dmi_table))
1456 return -ENODEV; 1457 return -ENODEV;
1457 1458
1458 ret = driver_register(&sonypi_driver); 1459 ret = platform_driver_register(&sonypi_driver);
1459 if (ret) 1460 if (ret)
1460 return ret; 1461 return ret;
1461 1462
1462 ret = sonypi_probe(); 1463 ret = sonypi_probe();
1463 if (ret) 1464 if (ret)
1464 driver_unregister(&sonypi_driver); 1465 platform_driver_unregister(&sonypi_driver);
1465 1466
1466 return ret; 1467 return ret;
1467} 1468}
1468 1469
1469static void __exit sonypi_exit(void) 1470static void __exit sonypi_exit(void)
1470{ 1471{
1471 driver_unregister(&sonypi_driver); 1472 platform_driver_unregister(&sonypi_driver);
1472 sonypi_remove(); 1473 sonypi_remove();
1473} 1474}
1474 1475
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index 5d1ffa3bd4c3..62aa0e534a6d 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/drivers/char/synclink.c 2 * linux/drivers/char/synclink.c
3 * 3 *
4 * $Id: synclink.c,v 4.37 2005/09/07 13:13:19 paulkf Exp $ 4 * $Id: synclink.c,v 4.38 2005/11/07 16:30:34 paulkf Exp $
5 * 5 *
6 * Device driver for Microgate SyncLink ISA and PCI 6 * Device driver for Microgate SyncLink ISA and PCI
7 * high speed multiprotocol serial adapters. 7 * high speed multiprotocol serial adapters.
@@ -101,6 +101,7 @@
101#include <linux/termios.h> 101#include <linux/termios.h>
102#include <linux/workqueue.h> 102#include <linux/workqueue.h>
103#include <linux/hdlc.h> 103#include <linux/hdlc.h>
104#include <linux/dma-mapping.h>
104 105
105#ifdef CONFIG_HDLC_MODULE 106#ifdef CONFIG_HDLC_MODULE
106#define CONFIG_HDLC 1 107#define CONFIG_HDLC 1
@@ -148,6 +149,7 @@ typedef struct _DMABUFFERENTRY
148 u32 link; /* 32-bit flat link to next buffer entry */ 149 u32 link; /* 32-bit flat link to next buffer entry */
149 char *virt_addr; /* virtual address of data buffer */ 150 char *virt_addr; /* virtual address of data buffer */
150 u32 phys_entry; /* physical address of this buffer entry */ 151 u32 phys_entry; /* physical address of this buffer entry */
152 dma_addr_t dma_addr;
151} DMABUFFERENTRY, *DMAPBUFFERENTRY; 153} DMABUFFERENTRY, *DMAPBUFFERENTRY;
152 154
153/* The queue of BH actions to be performed */ 155/* The queue of BH actions to be performed */
@@ -233,7 +235,8 @@ struct mgsl_struct {
233 int ri_chkcount; 235 int ri_chkcount;
234 236
235 char *buffer_list; /* virtual address of Rx & Tx buffer lists */ 237 char *buffer_list; /* virtual address of Rx & Tx buffer lists */
236 unsigned long buffer_list_phys; 238 u32 buffer_list_phys;
239 dma_addr_t buffer_list_dma_addr;
237 240
238 unsigned int rx_buffer_count; /* count of total allocated Rx buffers */ 241 unsigned int rx_buffer_count; /* count of total allocated Rx buffers */
239 DMABUFFERENTRY *rx_buffer_list; /* list of receive buffer entries */ 242 DMABUFFERENTRY *rx_buffer_list; /* list of receive buffer entries */
@@ -896,7 +899,7 @@ module_param_array(txdmabufs, int, NULL, 0);
896module_param_array(txholdbufs, int, NULL, 0); 899module_param_array(txholdbufs, int, NULL, 0);
897 900
898static char *driver_name = "SyncLink serial driver"; 901static char *driver_name = "SyncLink serial driver";
899static char *driver_version = "$Revision: 4.37 $"; 902static char *driver_version = "$Revision: 4.38 $";
900 903
901static int synclink_init_one (struct pci_dev *dev, 904static int synclink_init_one (struct pci_dev *dev,
902 const struct pci_device_id *ent); 905 const struct pci_device_id *ent);
@@ -912,7 +915,6 @@ MODULE_DEVICE_TABLE(pci, synclink_pci_tbl);
912MODULE_LICENSE("GPL"); 915MODULE_LICENSE("GPL");
913 916
914static struct pci_driver synclink_pci_driver = { 917static struct pci_driver synclink_pci_driver = {
915 .owner = THIS_MODULE,
916 .name = "synclink", 918 .name = "synclink",
917 .id_table = synclink_pci_tbl, 919 .id_table = synclink_pci_tbl,
918 .probe = synclink_init_one, 920 .probe = synclink_init_one,
@@ -3812,11 +3814,10 @@ static int mgsl_alloc_buffer_list_memory( struct mgsl_struct *info )
3812 /* inspect portions of the buffer while other portions are being */ 3814 /* inspect portions of the buffer while other portions are being */
3813 /* updated by the adapter using Bus Master DMA. */ 3815 /* updated by the adapter using Bus Master DMA. */
3814 3816
3815 info->buffer_list = kmalloc(BUFFERLISTSIZE, GFP_KERNEL | GFP_DMA); 3817 info->buffer_list = dma_alloc_coherent(NULL, BUFFERLISTSIZE, &info->buffer_list_dma_addr, GFP_KERNEL);
3816 if ( info->buffer_list == NULL ) 3818 if (info->buffer_list == NULL)
3817 return -ENOMEM; 3819 return -ENOMEM;
3818 3820 info->buffer_list_phys = (u32)(info->buffer_list_dma_addr);
3819 info->buffer_list_phys = isa_virt_to_bus(info->buffer_list);
3820 } 3821 }
3821 3822
3822 /* We got the memory for the buffer entry lists. */ 3823 /* We got the memory for the buffer entry lists. */
@@ -3883,8 +3884,8 @@ static int mgsl_alloc_buffer_list_memory( struct mgsl_struct *info )
3883 */ 3884 */
3884static void mgsl_free_buffer_list_memory( struct mgsl_struct *info ) 3885static void mgsl_free_buffer_list_memory( struct mgsl_struct *info )
3885{ 3886{
3886 if ( info->buffer_list && info->bus_type != MGSL_BUS_TYPE_PCI ) 3887 if (info->buffer_list && info->bus_type != MGSL_BUS_TYPE_PCI)
3887 kfree(info->buffer_list); 3888 dma_free_coherent(NULL, BUFFERLISTSIZE, info->buffer_list, info->buffer_list_dma_addr);
3888 3889
3889 info->buffer_list = NULL; 3890 info->buffer_list = NULL;
3890 info->rx_buffer_list = NULL; 3891 info->rx_buffer_list = NULL;
@@ -3911,7 +3912,7 @@ static void mgsl_free_buffer_list_memory( struct mgsl_struct *info )
3911static int mgsl_alloc_frame_memory(struct mgsl_struct *info,DMABUFFERENTRY *BufferList,int Buffercount) 3912static int mgsl_alloc_frame_memory(struct mgsl_struct *info,DMABUFFERENTRY *BufferList,int Buffercount)
3912{ 3913{
3913 int i; 3914 int i;
3914 unsigned long phys_addr; 3915 u32 phys_addr;
3915 3916
3916 /* Allocate page sized buffers for the receive buffer list */ 3917 /* Allocate page sized buffers for the receive buffer list */
3917 3918
@@ -3923,11 +3924,10 @@ static int mgsl_alloc_frame_memory(struct mgsl_struct *info,DMABUFFERENTRY *Buff
3923 info->last_mem_alloc += DMABUFFERSIZE; 3924 info->last_mem_alloc += DMABUFFERSIZE;
3924 } else { 3925 } else {
3925 /* ISA adapter uses system memory. */ 3926 /* ISA adapter uses system memory. */
3926 BufferList[i].virt_addr = 3927 BufferList[i].virt_addr = dma_alloc_coherent(NULL, DMABUFFERSIZE, &BufferList[i].dma_addr, GFP_KERNEL);
3927 kmalloc(DMABUFFERSIZE, GFP_KERNEL | GFP_DMA); 3928 if (BufferList[i].virt_addr == NULL)
3928 if ( BufferList[i].virt_addr == NULL )
3929 return -ENOMEM; 3929 return -ENOMEM;
3930 phys_addr = isa_virt_to_bus(BufferList[i].virt_addr); 3930 phys_addr = (u32)(BufferList[i].dma_addr);
3931 } 3931 }
3932 BufferList[i].phys_addr = phys_addr; 3932 BufferList[i].phys_addr = phys_addr;
3933 } 3933 }
@@ -3958,7 +3958,7 @@ static void mgsl_free_frame_memory(struct mgsl_struct *info, DMABUFFERENTRY *Buf
3958 for ( i = 0 ; i < Buffercount ; i++ ) { 3958 for ( i = 0 ; i < Buffercount ; i++ ) {
3959 if ( BufferList[i].virt_addr ) { 3959 if ( BufferList[i].virt_addr ) {
3960 if ( info->bus_type != MGSL_BUS_TYPE_PCI ) 3960 if ( info->bus_type != MGSL_BUS_TYPE_PCI )
3961 kfree(BufferList[i].virt_addr); 3961 dma_free_coherent(NULL, DMABUFFERSIZE, BufferList[i].virt_addr, BufferList[i].dma_addr);
3962 BufferList[i].virt_addr = NULL; 3962 BufferList[i].virt_addr = NULL;
3963 } 3963 }
3964 } 3964 }
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 7c063c5abc55..ee5a40be9f99 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -500,7 +500,6 @@ MODULE_DEVICE_TABLE(pci, synclinkmp_pci_tbl);
500MODULE_LICENSE("GPL"); 500MODULE_LICENSE("GPL");
501 501
502static struct pci_driver synclinkmp_pci_driver = { 502static struct pci_driver synclinkmp_pci_driver = {
503 .owner = THIS_MODULE,
504 .name = "synclinkmp", 503 .name = "synclinkmp",
505 .id_table = synclinkmp_pci_tbl, 504 .id_table = synclinkmp_pci_tbl,
506 .probe = synclinkmp_init_one, 505 .probe = synclinkmp_init_one,
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c
index 24355b23b2ca..b3d411a756fe 100644
--- a/drivers/char/tb0219.c
+++ b/drivers/char/tb0219.c
@@ -283,7 +283,7 @@ static void tb0219_pci_irq_init(void)
283 vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN, IRQ_LEVEL_LOW); 283 vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN, IRQ_LEVEL_LOW);
284} 284}
285 285
286static int tb0219_probe(struct device *dev) 286static int tb0219_probe(struct platform_device *dev)
287{ 287{
288 int retval; 288 int retval;
289 289
@@ -319,7 +319,7 @@ static int tb0219_probe(struct device *dev)
319 return 0; 319 return 0;
320} 320}
321 321
322static int tb0219_remove(struct device *dev) 322static int tb0219_remove(struct platform_device *dev)
323{ 323{
324 _machine_restart = old_machine_restart; 324 _machine_restart = old_machine_restart;
325 325
@@ -333,11 +333,12 @@ static int tb0219_remove(struct device *dev)
333 333
334static struct platform_device *tb0219_platform_device; 334static struct platform_device *tb0219_platform_device;
335 335
336static struct device_driver tb0219_device_driver = { 336static struct platform_driver tb0219_device_driver = {
337 .name = "TB0219",
338 .bus = &platform_bus_type,
339 .probe = tb0219_probe, 337 .probe = tb0219_probe,
340 .remove = tb0219_remove, 338 .remove = tb0219_remove,
339 .driver = {
340 .name = "TB0219",
341 },
341}; 342};
342 343
343static int __devinit tanbac_tb0219_init(void) 344static int __devinit tanbac_tb0219_init(void)
@@ -348,7 +349,7 @@ static int __devinit tanbac_tb0219_init(void)
348 if (IS_ERR(tb0219_platform_device)) 349 if (IS_ERR(tb0219_platform_device))
349 return PTR_ERR(tb0219_platform_device); 350 return PTR_ERR(tb0219_platform_device);
350 351
351 retval = driver_register(&tb0219_device_driver); 352 retval = platform_driver_register(&tb0219_device_driver);
352 if (retval < 0) 353 if (retval < 0)
353 platform_device_unregister(tb0219_platform_device); 354 platform_device_unregister(tb0219_platform_device);
354 355
@@ -357,7 +358,7 @@ static int __devinit tanbac_tb0219_init(void)
357 358
358static void __devexit tanbac_tb0219_exit(void) 359static void __devexit tanbac_tb0219_exit(void)
359{ 360{
360 driver_unregister(&tb0219_device_driver); 361 platform_driver_unregister(&tb0219_device_driver);
361 362
362 platform_device_unregister(tb0219_platform_device); 363 platform_device_unregister(tb0219_platform_device);
363} 364}
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig
index b58adfe3ed19..a6873bf89ffa 100644
--- a/drivers/char/tpm/Kconfig
+++ b/drivers/char/tpm/Kconfig
@@ -6,7 +6,7 @@ menu "TPM devices"
6 6
7config TCG_TPM 7config TCG_TPM
8 tristate "TPM Hardware Support" 8 tristate "TPM Hardware Support"
9 depends on EXPERIMENTAL && PCI 9 depends on EXPERIMENTAL
10 ---help--- 10 ---help---
11 If you have a TPM security chip in your system, which 11 If you have a TPM security chip in your system, which
12 implements the Trusted Computing Group's specification, 12 implements the Trusted Computing Group's specification,
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 303f15880466..a9be0e8eaea5 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -43,6 +43,13 @@ static void user_reader_timeout(unsigned long ptr)
43{ 43{
44 struct tpm_chip *chip = (struct tpm_chip *) ptr; 44 struct tpm_chip *chip = (struct tpm_chip *) ptr;
45 45
46 schedule_work(&chip->work);
47}
48
49static void timeout_work(void * ptr)
50{
51 struct tpm_chip *chip = ptr;
52
46 down(&chip->buffer_mutex); 53 down(&chip->buffer_mutex);
47 atomic_set(&chip->data_pending, 0); 54 atomic_set(&chip->data_pending, 0);
48 memset(chip->data_buffer, 0, TPM_BUFSIZE); 55 memset(chip->data_buffer, 0, TPM_BUFSIZE);
@@ -370,6 +377,7 @@ int tpm_release(struct inode *inode, struct file *file)
370 file->private_data = NULL; 377 file->private_data = NULL;
371 chip->num_opens--; 378 chip->num_opens--;
372 del_singleshot_timer_sync(&chip->user_read_timer); 379 del_singleshot_timer_sync(&chip->user_read_timer);
380 flush_scheduled_work();
373 atomic_set(&chip->data_pending, 0); 381 atomic_set(&chip->data_pending, 0);
374 put_device(chip->dev); 382 put_device(chip->dev);
375 kfree(chip->data_buffer); 383 kfree(chip->data_buffer);
@@ -421,6 +429,7 @@ ssize_t tpm_read(struct file * file, char __user *buf,
421 int ret_size; 429 int ret_size;
422 430
423 del_singleshot_timer_sync(&chip->user_read_timer); 431 del_singleshot_timer_sync(&chip->user_read_timer);
432 flush_scheduled_work();
424 ret_size = atomic_read(&chip->data_pending); 433 ret_size = atomic_read(&chip->data_pending);
425 atomic_set(&chip->data_pending, 0); 434 atomic_set(&chip->data_pending, 0);
426 if (ret_size > 0) { /* relay data */ 435 if (ret_size > 0) { /* relay data */
@@ -428,8 +437,7 @@ ssize_t tpm_read(struct file * file, char __user *buf,
428 ret_size = size; 437 ret_size = size;
429 438
430 down(&chip->buffer_mutex); 439 down(&chip->buffer_mutex);
431 if (copy_to_user 440 if (copy_to_user(buf, chip->data_buffer, ret_size))
432 ((void __user *) buf, chip->data_buffer, ret_size))
433 ret_size = -EFAULT; 441 ret_size = -EFAULT;
434 up(&chip->buffer_mutex); 442 up(&chip->buffer_mutex);
435 } 443 }
@@ -460,7 +468,7 @@ void tpm_remove_hardware(struct device *dev)
460 sysfs_remove_group(&dev->kobj, chip->vendor->attr_group); 468 sysfs_remove_group(&dev->kobj, chip->vendor->attr_group);
461 469
462 dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &= 470 dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &=
463 !(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES)); 471 ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES));
464 472
465 kfree(chip); 473 kfree(chip);
466 474
@@ -528,6 +536,8 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry)
528 init_MUTEX(&chip->tpm_mutex); 536 init_MUTEX(&chip->tpm_mutex);
529 INIT_LIST_HEAD(&chip->list); 537 INIT_LIST_HEAD(&chip->list);
530 538
539 INIT_WORK(&chip->work, timeout_work, chip);
540
531 init_timer(&chip->user_read_timer); 541 init_timer(&chip->user_read_timer);
532 chip->user_read_timer.function = user_reader_timeout; 542 chip->user_read_timer.function = user_reader_timeout;
533 chip->user_read_timer.data = (unsigned long) chip; 543 chip->user_read_timer.data = (unsigned long) chip;
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index 9293bcc4dc62..159882ca69dd 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -50,7 +50,11 @@ struct tpm_vendor_specific {
50 u8 req_complete_mask; 50 u8 req_complete_mask;
51 u8 req_complete_val; 51 u8 req_complete_val;
52 u8 req_canceled; 52 u8 req_canceled;
53 u16 base; /* TPM base address */ 53 void __iomem *iobase; /* ioremapped address */
54 unsigned long base; /* TPM base address */
55
56 int region_size;
57 int have_region;
54 58
55 int (*recv) (struct tpm_chip *, u8 *, size_t); 59 int (*recv) (struct tpm_chip *, u8 *, size_t);
56 int (*send) (struct tpm_chip *, u8 *, size_t); 60 int (*send) (struct tpm_chip *, u8 *, size_t);
@@ -73,6 +77,7 @@ struct tpm_chip {
73 struct semaphore buffer_mutex; 77 struct semaphore buffer_mutex;
74 78
75 struct timer_list user_read_timer; /* user needs to claim result */ 79 struct timer_list user_read_timer; /* user needs to claim result */
80 struct work_struct work;
76 struct semaphore tpm_mutex; /* tpm is processing */ 81 struct semaphore tpm_mutex; /* tpm is processing */
77 82
78 struct tpm_vendor_specific *vendor; 83 struct tpm_vendor_specific *vendor;
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c
index 32e01450c425..ff3654964fe3 100644
--- a/drivers/char/tpm/tpm_atmel.c
+++ b/drivers/char/tpm/tpm_atmel.c
@@ -19,14 +19,8 @@
19 * 19 *
20 */ 20 */
21 21
22#include <linux/platform_device.h>
23#include "tpm.h" 22#include "tpm.h"
24 23#include "tpm_atmel.h"
25/* Atmel definitions */
26enum tpm_atmel_addr {
27 TPM_ATMEL_BASE_ADDR_LO = 0x08,
28 TPM_ATMEL_BASE_ADDR_HI = 0x09
29};
30 24
31/* write status bits */ 25/* write status bits */
32enum tpm_atmel_write_status { 26enum tpm_atmel_write_status {
@@ -53,13 +47,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
53 return -EIO; 47 return -EIO;
54 48
55 for (i = 0; i < 6; i++) { 49 for (i = 0; i < 6; i++) {
56 status = inb(chip->vendor->base + 1); 50 status = ioread8(chip->vendor->iobase + 1);
57 if ((status & ATML_STATUS_DATA_AVAIL) == 0) { 51 if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
58 dev_err(chip->dev, 52 dev_err(chip->dev, "error reading header\n");
59 "error reading header\n");
60 return -EIO; 53 return -EIO;
61 } 54 }
62 *buf++ = inb(chip->vendor->base); 55 *buf++ = ioread8(chip->vendor->iobase);
63 } 56 }
64 57
65 /* size of the data received */ 58 /* size of the data received */
@@ -70,10 +63,9 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
70 dev_err(chip->dev, 63 dev_err(chip->dev,
71 "Recv size(%d) less than available space\n", size); 64 "Recv size(%d) less than available space\n", size);
72 for (; i < size; i++) { /* clear the waiting data anyway */ 65 for (; i < size; i++) { /* clear the waiting data anyway */
73 status = inb(chip->vendor->base + 1); 66 status = ioread8(chip->vendor->iobase + 1);
74 if ((status & ATML_STATUS_DATA_AVAIL) == 0) { 67 if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
75 dev_err(chip->dev, 68 dev_err(chip->dev, "error reading data\n");
76 "error reading data\n");
77 return -EIO; 69 return -EIO;
78 } 70 }
79 } 71 }
@@ -82,17 +74,17 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count)
82 74
83 /* read all the data available */ 75 /* read all the data available */
84 for (; i < size; i++) { 76 for (; i < size; i++) {
85 status = inb(chip->vendor->base + 1); 77 status = ioread8(chip->vendor->iobase + 1);
86 if ((status & ATML_STATUS_DATA_AVAIL) == 0) { 78 if ((status & ATML_STATUS_DATA_AVAIL) == 0) {
87 dev_err(chip->dev, 79 dev_err(chip->dev, "error reading data\n");
88 "error reading data\n");
89 return -EIO; 80 return -EIO;
90 } 81 }
91 *buf++ = inb(chip->vendor->base); 82 *buf++ = ioread8(chip->vendor->iobase);
92 } 83 }
93 84
94 /* make sure data available is gone */ 85 /* make sure data available is gone */
95 status = inb(chip->vendor->base + 1); 86 status = ioread8(chip->vendor->iobase + 1);
87
96 if (status & ATML_STATUS_DATA_AVAIL) { 88 if (status & ATML_STATUS_DATA_AVAIL) {
97 dev_err(chip->dev, "data available is stuck\n"); 89 dev_err(chip->dev, "data available is stuck\n");
98 return -EIO; 90 return -EIO;
@@ -108,7 +100,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
108 dev_dbg(chip->dev, "tpm_atml_send:\n"); 100 dev_dbg(chip->dev, "tpm_atml_send:\n");
109 for (i = 0; i < count; i++) { 101 for (i = 0; i < count; i++) {
110 dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]); 102 dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]);
111 outb(buf[i], chip->vendor->base); 103 iowrite8(buf[i], chip->vendor->iobase);
112 } 104 }
113 105
114 return count; 106 return count;
@@ -116,12 +108,12 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count)
116 108
117static void tpm_atml_cancel(struct tpm_chip *chip) 109static void tpm_atml_cancel(struct tpm_chip *chip)
118{ 110{
119 outb(ATML_STATUS_ABORT, chip->vendor->base + 1); 111 iowrite8(ATML_STATUS_ABORT, chip->vendor->iobase + 1);
120} 112}
121 113
122static u8 tpm_atml_status(struct tpm_chip *chip) 114static u8 tpm_atml_status(struct tpm_chip *chip)
123{ 115{
124 return inb(chip->vendor->base + 1); 116 return ioread8(chip->vendor->iobase + 1);
125} 117}
126 118
127static struct file_operations atmel_ops = { 119static struct file_operations atmel_ops = {
@@ -162,12 +154,17 @@ static struct tpm_vendor_specific tpm_atmel = {
162 154
163static struct platform_device *pdev; 155static struct platform_device *pdev;
164 156
165static void __devexit tpm_atml_remove(struct device *dev) 157static void atml_plat_remove(void)
166{ 158{
167 struct tpm_chip *chip = dev_get_drvdata(dev); 159 struct tpm_chip *chip = dev_get_drvdata(&pdev->dev);
160
168 if (chip) { 161 if (chip) {
169 release_region(chip->vendor->base, 2); 162 if (chip->vendor->have_region)
163 atmel_release_region(chip->vendor->base,
164 chip->vendor->region_size);
165 atmel_put_base_addr(chip->vendor);
170 tpm_remove_hardware(chip->dev); 166 tpm_remove_hardware(chip->dev);
167 platform_device_unregister(pdev);
171 } 168 }
172} 169}
173 170
@@ -182,72 +179,46 @@ static struct device_driver atml_drv = {
182static int __init init_atmel(void) 179static int __init init_atmel(void)
183{ 180{
184 int rc = 0; 181 int rc = 0;
185 int lo, hi;
186 182
187 driver_register(&atml_drv); 183 driver_register(&atml_drv);
188 184
189 lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); 185 if ((tpm_atmel.iobase = atmel_get_base_addr(&tpm_atmel)) == NULL) {
190 hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); 186 rc = -ENODEV;
191 187 goto err_unreg_drv;
192 tpm_atmel.base = (hi<<8)|lo;
193
194 /* verify that it is an Atmel part */
195 if (tpm_read_index(TPM_ADDR, 4) != 'A' || tpm_read_index(TPM_ADDR, 5) != 'T'
196 || tpm_read_index(TPM_ADDR, 6) != 'M' || tpm_read_index(TPM_ADDR, 7) != 'L') {
197 return -ENODEV;
198 } 188 }
199 189
200 /* verify chip version number is 1.1 */ 190 tpm_atmel.have_region =
201 if ( (tpm_read_index(TPM_ADDR, 0x00) != 0x01) || 191 (atmel_request_region
202 (tpm_read_index(TPM_ADDR, 0x01) != 0x01 )) 192 (tpm_atmel.base, tpm_atmel.region_size,
203 return -ENODEV; 193 "tpm_atmel0") == NULL) ? 0 : 1;
204
205 pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
206 if ( !pdev )
207 return -ENOMEM;
208
209 pdev->name = "tpm_atmel0";
210 pdev->id = -1;
211 pdev->num_resources = 0;
212 pdev->dev.release = tpm_atml_remove;
213 pdev->dev.driver = &atml_drv;
214
215 if ((rc = platform_device_register(pdev)) < 0) {
216 kfree(pdev);
217 pdev = NULL;
218 return rc;
219 }
220 194
221 if (request_region(tpm_atmel.base, 2, "tpm_atmel0") == NULL ) { 195 if (IS_ERR
222 platform_device_unregister(pdev); 196 (pdev =
223 kfree(pdev); 197 platform_device_register_simple("tpm_atmel", -1, NULL, 0))) {
224 pdev = NULL; 198 rc = PTR_ERR(pdev);
225 return -EBUSY; 199 goto err_rel_reg;
226 } 200 }
227 201
228 if ((rc = tpm_register_hardware(&pdev->dev, &tpm_atmel)) < 0) { 202 if ((rc = tpm_register_hardware(&pdev->dev, &tpm_atmel)) < 0)
229 release_region(tpm_atmel.base, 2); 203 goto err_unreg_dev;
230 platform_device_unregister(pdev);
231 kfree(pdev);
232 pdev = NULL;
233 return rc;
234 }
235
236 dev_info(&pdev->dev, "Atmel TPM 1.1, Base Address: 0x%x\n",
237 tpm_atmel.base);
238 return 0; 204 return 0;
205
206err_unreg_dev:
207 platform_device_unregister(pdev);
208err_rel_reg:
209 atmel_put_base_addr(&tpm_atmel);
210 if (tpm_atmel.have_region)
211 atmel_release_region(tpm_atmel.base,
212 tpm_atmel.region_size);
213err_unreg_drv:
214 driver_unregister(&atml_drv);
215 return rc;
239} 216}
240 217
241static void __exit cleanup_atmel(void) 218static void __exit cleanup_atmel(void)
242{ 219{
243 if (pdev) {
244 tpm_atml_remove(&pdev->dev);
245 platform_device_unregister(pdev);
246 kfree(pdev);
247 pdev = NULL;
248 }
249
250 driver_unregister(&atml_drv); 220 driver_unregister(&atml_drv);
221 atml_plat_remove();
251} 222}
252 223
253module_init(init_atmel); 224module_init(init_atmel);
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h
new file mode 100644
index 000000000000..d3478aaadd77
--- /dev/null
+++ b/drivers/char/tpm/tpm_atmel.h
@@ -0,0 +1,131 @@
1/*
2 * Copyright (C) 2005 IBM Corporation
3 *
4 * Authors:
5 * Kylene Hall <kjhall@us.ibm.com>
6 *
7 * Maintained by: <tpmdd_devel@lists.sourceforge.net>
8 *
9 * Device driver for TCG/TCPA TPM (trusted platform module).
10 * Specifications at www.trustedcomputinggroup.org
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation, version 2 of the
15 * License.
16 *
17 * These difference are required on power because the device must be
18 * discovered through the device tree and iomap must be used to get
19 * around the need for holes in the io_page_mask. This does not happen
20 * automatically because the tpm is not a normal pci device and lives
21 * under the root node.
22 *
23 */
24
25#ifdef CONFIG_PPC64
26#define atmel_getb(chip, offset) readb(chip->vendor->iobase + offset);
27#define atmel_putb(val, chip, offset) writeb(val, chip->vendor->iobase + offset)
28#define atmel_request_region request_mem_region
29#define atmel_release_region release_mem_region
30
31static inline void atmel_put_base_addr(struct tpm_vendor_specific
32 *vendor)
33{
34 iounmap(vendor->iobase);
35}
36
37static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific *vendor)
38{
39 struct device_node *dn;
40 unsigned long address, size;
41 unsigned int *reg;
42 int reglen;
43 int naddrc;
44 int nsizec;
45
46 dn = of_find_node_by_name(NULL, "tpm");
47
48 if (!dn)
49 return NULL;
50
51 if (!device_is_compatible(dn, "AT97SC3201")) {
52 of_node_put(dn);
53 return NULL;
54 }
55
56 reg = (unsigned int *) get_property(dn, "reg", &reglen);
57 naddrc = prom_n_addr_cells(dn);
58 nsizec = prom_n_size_cells(dn);
59
60 of_node_put(dn);
61
62
63 if (naddrc == 2)
64 address = ((unsigned long) reg[0] << 32) | reg[1];
65 else
66 address = reg[0];
67
68 if (nsizec == 2)
69 size =
70 ((unsigned long) reg[naddrc] << 32) | reg[naddrc + 1];
71 else
72 size = reg[naddrc];
73
74 vendor->base = address;
75 vendor->region_size = size;
76 return ioremap(vendor->base, vendor->region_size);
77}
78#else
79#define atmel_getb(chip, offset) inb(chip->vendor->base + offset)
80#define atmel_putb(val, chip, offset) outb(val, chip->vendor->base + offset)
81#define atmel_request_region request_region
82#define atmel_release_region release_region
83/* Atmel definitions */
84enum tpm_atmel_addr {
85 TPM_ATMEL_BASE_ADDR_LO = 0x08,
86 TPM_ATMEL_BASE_ADDR_HI = 0x09
87};
88
89/* Verify this is a 1.1 Atmel TPM */
90static int atmel_verify_tpm11(void)
91{
92
93 /* verify that it is an Atmel part */
94 if (tpm_read_index(TPM_ADDR, 4) != 'A' ||
95 tpm_read_index(TPM_ADDR, 5) != 'T' ||
96 tpm_read_index(TPM_ADDR, 6) != 'M' ||
97 tpm_read_index(TPM_ADDR, 7) != 'L')
98 return 1;
99
100 /* query chip for its version number */
101 if (tpm_read_index(TPM_ADDR, 0x00) != 1 ||
102 tpm_read_index(TPM_ADDR, 0x01) != 1)
103 return 1;
104
105 /* This is an atmel supported part */
106 return 0;
107}
108
109static inline void atmel_put_base_addr(struct tpm_vendor_specific
110 *vendor)
111{
112}
113
114/* Determine where to talk to device */
115static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific
116 *vendor)
117{
118 int lo, hi;
119
120 if (atmel_verify_tpm11() != 0)
121 return NULL;
122
123 lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO);
124 hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI);
125
126 vendor->base = (hi << 8) | lo;
127 vendor->region_size = 2;
128
129 return ioport_map(vendor->base, vendor->region_size);
130}
131#endif
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/vr41xx_giu.c b/drivers/char/vr41xx_giu.c
index 94641085faf8..9ac6d43437b3 100644
--- a/drivers/char/vr41xx_giu.c
+++ b/drivers/char/vr41xx_giu.c
@@ -613,7 +613,7 @@ static struct file_operations gpio_fops = {
613 .release = gpio_release, 613 .release = gpio_release,
614}; 614};
615 615
616static int giu_probe(struct device *dev) 616static int giu_probe(struct platform_device *dev)
617{ 617{
618 unsigned long start, size, flags = 0; 618 unsigned long start, size, flags = 0;
619 unsigned int nr_pins = 0; 619 unsigned int nr_pins = 0;
@@ -697,7 +697,7 @@ static int giu_probe(struct device *dev)
697 return cascade_irq(GIUINT_IRQ, giu_get_irq); 697 return cascade_irq(GIUINT_IRQ, giu_get_irq);
698} 698}
699 699
700static int giu_remove(struct device *dev) 700static int giu_remove(struct platform_device *dev)
701{ 701{
702 iounmap(giu_base); 702 iounmap(giu_base);
703 703
@@ -710,11 +710,12 @@ static int giu_remove(struct device *dev)
710 710
711static struct platform_device *giu_platform_device; 711static struct platform_device *giu_platform_device;
712 712
713static struct device_driver giu_device_driver = { 713static struct platform_driver giu_device_driver = {
714 .name = "GIU",
715 .bus = &platform_bus_type,
716 .probe = giu_probe, 714 .probe = giu_probe,
717 .remove = giu_remove, 715 .remove = giu_remove,
716 .driver = {
717 .name = "GIU",
718 },
718}; 719};
719 720
720static int __devinit vr41xx_giu_init(void) 721static int __devinit vr41xx_giu_init(void)
@@ -725,7 +726,7 @@ static int __devinit vr41xx_giu_init(void)
725 if (IS_ERR(giu_platform_device)) 726 if (IS_ERR(giu_platform_device))
726 return PTR_ERR(giu_platform_device); 727 return PTR_ERR(giu_platform_device);
727 728
728 retval = driver_register(&giu_device_driver); 729 retval = platform_driver_register(&giu_device_driver);
729 if (retval < 0) 730 if (retval < 0)
730 platform_device_unregister(giu_platform_device); 731 platform_device_unregister(giu_platform_device);
731 732
@@ -734,7 +735,7 @@ static int __devinit vr41xx_giu_init(void)
734 735
735static void __devexit vr41xx_giu_exit(void) 736static void __devexit vr41xx_giu_exit(void)
736{ 737{
737 driver_unregister(&giu_device_driver); 738 platform_driver_unregister(&giu_device_driver);
738 739
739 platform_device_unregister(giu_platform_device); 740 platform_device_unregister(giu_platform_device);
740} 741}
diff --git a/drivers/char/vr41xx_rtc.c b/drivers/char/vr41xx_rtc.c
index 5e3292df69d8..435b30748e23 100644
--- a/drivers/char/vr41xx_rtc.c
+++ b/drivers/char/vr41xx_rtc.c
@@ -560,13 +560,11 @@ static struct miscdevice rtc_miscdevice = {
560 .fops = &rtc_fops, 560 .fops = &rtc_fops,
561}; 561};
562 562
563static int rtc_probe(struct device *dev) 563static int rtc_probe(struct platform_device *pdev)
564{ 564{
565 struct platform_device *pdev;
566 unsigned int irq; 565 unsigned int irq;
567 int retval; 566 int retval;
568 567
569 pdev = to_platform_device(dev);
570 if (pdev->num_resources != 2) 568 if (pdev->num_resources != 2)
571 return -EBUSY; 569 return -EBUSY;
572 570
@@ -635,7 +633,7 @@ static int rtc_probe(struct device *dev)
635 return 0; 633 return 0;
636} 634}
637 635
638static int rtc_remove(struct device *dev) 636static int rtc_remove(struct platform_device *dev)
639{ 637{
640 int retval; 638 int retval;
641 639
@@ -655,11 +653,12 @@ static int rtc_remove(struct device *dev)
655 653
656static struct platform_device *rtc_platform_device; 654static struct platform_device *rtc_platform_device;
657 655
658static struct device_driver rtc_device_driver = { 656static struct platform_driver rtc_device_driver = {
659 .name = rtc_name,
660 .bus = &platform_bus_type,
661 .probe = rtc_probe, 657 .probe = rtc_probe,
662 .remove = rtc_remove, 658 .remove = rtc_remove,
659 .driver = {
660 .name = rtc_name,
661 },
663}; 662};
664 663
665static int __devinit vr41xx_rtc_init(void) 664static int __devinit vr41xx_rtc_init(void)
@@ -691,7 +690,7 @@ static int __devinit vr41xx_rtc_init(void)
691 if (IS_ERR(rtc_platform_device)) 690 if (IS_ERR(rtc_platform_device))
692 return PTR_ERR(rtc_platform_device); 691 return PTR_ERR(rtc_platform_device);
693 692
694 retval = driver_register(&rtc_device_driver); 693 retval = platform_driver_register(&rtc_device_driver);
695 if (retval < 0) 694 if (retval < 0)
696 platform_device_unregister(rtc_platform_device); 695 platform_device_unregister(rtc_platform_device);
697 696
@@ -700,7 +699,7 @@ static int __devinit vr41xx_rtc_init(void)
700 699
701static void __devexit vr41xx_rtc_exit(void) 700static void __devexit vr41xx_rtc_exit(void)
702{ 701{
703 driver_unregister(&rtc_device_driver); 702 platform_driver_unregister(&rtc_device_driver);
704 703
705 platform_device_unregister(rtc_platform_device); 704 platform_device_unregister(rtc_platform_device);
706} 705}
diff --git a/drivers/char/watchdog/booke_wdt.c b/drivers/char/watchdog/booke_wdt.c
index abc30cca6645..b6640606b44d 100644
--- a/drivers/char/watchdog/booke_wdt.c
+++ b/drivers/char/watchdog/booke_wdt.c
@@ -4,7 +4,7 @@
4 * Watchdog timer for PowerPC Book-E systems 4 * Watchdog timer for PowerPC Book-E systems
5 * 5 *
6 * Author: Matthew McClintock 6 * Author: Matthew McClintock
7 * Maintainer: Kumar Gala <kumar.gala@freescale.com> 7 * Maintainer: Kumar Gala <galak@kernel.crashing.org>
8 * 8 *
9 * Copyright 2005 Freescale Semiconductor Inc. 9 * Copyright 2005 Freescale Semiconductor Inc.
10 * 10 *
@@ -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/mpcore_wdt.c b/drivers/char/watchdog/mpcore_wdt.c
index da631c114fd1..b4d843489881 100644
--- a/drivers/char/watchdog/mpcore_wdt.c
+++ b/drivers/char/watchdog/mpcore_wdt.c
@@ -139,7 +139,7 @@ static int mpcore_wdt_set_heartbeat(int t)
139 */ 139 */
140static int mpcore_wdt_open(struct inode *inode, struct file *file) 140static int mpcore_wdt_open(struct inode *inode, struct file *file)
141{ 141{
142 struct mpcore_wdt *wdt = dev_get_drvdata(&mpcore_wdt_dev->dev); 142 struct mpcore_wdt *wdt = platform_get_drvdata(mpcore_wdt_dev);
143 143
144 if (test_and_set_bit(0, &wdt->timer_alive)) 144 if (test_and_set_bit(0, &wdt->timer_alive))
145 return -EBUSY; 145 return -EBUSY;
@@ -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 */
@@ -291,9 +287,9 @@ static int mpcore_wdt_ioctl(struct inode *inode, struct file *file,
291 * System shutdown handler. Turn off the watchdog if we're 287 * System shutdown handler. Turn off the watchdog if we're
292 * restarting or halting the system. 288 * restarting or halting the system.
293 */ 289 */
294static void mpcore_wdt_shutdown(struct device *_dev) 290static void mpcore_wdt_shutdown(struct platform_device *dev)
295{ 291{
296 struct mpcore_wdt *wdt = dev_get_drvdata(_dev); 292 struct mpcore_wdt *wdt = platform_get_drvdata(dev);
297 293
298 if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT) 294 if (system_state == SYSTEM_RESTART || system_state == SYSTEM_HALT)
299 mpcore_wdt_stop(wdt); 295 mpcore_wdt_stop(wdt);
@@ -317,9 +313,8 @@ static struct miscdevice mpcore_wdt_miscdev = {
317 .fops = &mpcore_wdt_fops, 313 .fops = &mpcore_wdt_fops,
318}; 314};
319 315
320static int __devinit mpcore_wdt_probe(struct device *_dev) 316static int __devinit mpcore_wdt_probe(struct platform_device *dev)
321{ 317{
322 struct platform_device *dev = to_platform_device(_dev);
323 struct mpcore_wdt *wdt; 318 struct mpcore_wdt *wdt;
324 struct resource *res; 319 struct resource *res;
325 int ret; 320 int ret;
@@ -364,7 +359,7 @@ static int __devinit mpcore_wdt_probe(struct device *_dev)
364 } 359 }
365 360
366 mpcore_wdt_stop(wdt); 361 mpcore_wdt_stop(wdt);
367 dev_set_drvdata(&dev->dev, wdt); 362 platform_set_drvdata(&dev->dev, wdt);
368 mpcore_wdt_dev = dev; 363 mpcore_wdt_dev = dev;
369 364
370 return 0; 365 return 0;
@@ -379,11 +374,11 @@ static int __devinit mpcore_wdt_probe(struct device *_dev)
379 return ret; 374 return ret;
380} 375}
381 376
382static int __devexit mpcore_wdt_remove(struct device *dev) 377static int __devexit mpcore_wdt_remove(struct platform_device *dev)
383{ 378{
384 struct mpcore_wdt *wdt = dev_get_drvdata(dev); 379 struct mpcore_wdt *wdt = platform_get_drvdata(dev);
385 380
386 dev_set_drvdata(dev, NULL); 381 platform_set_drvdata(dev, NULL);
387 382
388 misc_deregister(&mpcore_wdt_miscdev); 383 misc_deregister(&mpcore_wdt_miscdev);
389 384
@@ -395,13 +390,14 @@ static int __devexit mpcore_wdt_remove(struct device *dev)
395 return 0; 390 return 0;
396} 391}
397 392
398static struct device_driver mpcore_wdt_driver = { 393static struct platform_driver mpcore_wdt_driver = {
399 .owner = THIS_MODULE,
400 .name = "mpcore_wdt",
401 .bus = &platform_bus_type,
402 .probe = mpcore_wdt_probe, 394 .probe = mpcore_wdt_probe,
403 .remove = __devexit_p(mpcore_wdt_remove), 395 .remove = __devexit_p(mpcore_wdt_remove),
404 .shutdown = mpcore_wdt_shutdown, 396 .shutdown = mpcore_wdt_shutdown,
397 .driver = {
398 .owner = THIS_MODULE,
399 .name = "mpcore_wdt",
400 },
405}; 401};
406 402
407static char banner[] __initdata = KERN_INFO "MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n"; 403static char banner[] __initdata = KERN_INFO "MPcore Watchdog Timer: 0.1. mpcore_noboot=%d mpcore_margin=%d sec (nowayout= %d)\n";
@@ -420,12 +416,12 @@ static int __init mpcore_wdt_init(void)
420 416
421 printk(banner, mpcore_noboot, mpcore_margin, nowayout); 417 printk(banner, mpcore_noboot, mpcore_margin, nowayout);
422 418
423 return driver_register(&mpcore_wdt_driver); 419 return platform_driver_register(&mpcore_wdt_driver);
424} 420}
425 421
426static void __exit mpcore_wdt_exit(void) 422static void __exit mpcore_wdt_exit(void)
427{ 423{
428 driver_unregister(&mpcore_wdt_driver); 424 platform_driver_unregister(&mpcore_wdt_driver);
429} 425}
430 426
431module_init(mpcore_wdt_init); 427module_init(mpcore_wdt_init);
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c
index 119b3c541d95..00d9ef04a369 100644
--- a/drivers/char/watchdog/mv64x60_wdt.c
+++ b/drivers/char/watchdog/mv64x60_wdt.c
@@ -182,10 +182,9 @@ static struct miscdevice mv64x60_wdt_miscdev = {
182 .fops = &mv64x60_wdt_fops, 182 .fops = &mv64x60_wdt_fops,
183}; 183};
184 184
185static int __devinit mv64x60_wdt_probe(struct device *dev) 185static int __devinit mv64x60_wdt_probe(struct platform_device *dev)
186{ 186{
187 struct platform_device *pd = to_platform_device(dev); 187 struct mv64x60_wdt_pdata *pdata = dev->dev.platform_data;
188 struct mv64x60_wdt_pdata *pdata = pd->dev.platform_data;
189 int bus_clk = 133; 188 int bus_clk = 133;
190 189
191 mv64x60_wdt_timeout = 10; 190 mv64x60_wdt_timeout = 10;
@@ -202,7 +201,7 @@ static int __devinit mv64x60_wdt_probe(struct device *dev)
202 return misc_register(&mv64x60_wdt_miscdev); 201 return misc_register(&mv64x60_wdt_miscdev);
203} 202}
204 203
205static int __devexit mv64x60_wdt_remove(struct device *dev) 204static int __devexit mv64x60_wdt_remove(struct platform_device *dev)
206{ 205{
207 misc_deregister(&mv64x60_wdt_miscdev); 206 misc_deregister(&mv64x60_wdt_miscdev);
208 207
@@ -212,12 +211,13 @@ static int __devexit mv64x60_wdt_remove(struct device *dev)
212 return 0; 211 return 0;
213} 212}
214 213
215static struct device_driver mv64x60_wdt_driver = { 214static struct platform_driver mv64x60_wdt_driver = {
216 .owner = THIS_MODULE,
217 .name = MV64x60_WDT_NAME,
218 .bus = &platform_bus_type,
219 .probe = mv64x60_wdt_probe, 215 .probe = mv64x60_wdt_probe,
220 .remove = __devexit_p(mv64x60_wdt_remove), 216 .remove = __devexit_p(mv64x60_wdt_remove),
217 .driver = {
218 .owner = THIS_MODULE,
219 .name = MV64x60_WDT_NAME,
220 },
221}; 221};
222 222
223static struct platform_device *mv64x60_wdt_dev; 223static struct platform_device *mv64x60_wdt_dev;
@@ -235,14 +235,14 @@ static int __init mv64x60_wdt_init(void)
235 goto out; 235 goto out;
236 } 236 }
237 237
238 ret = driver_register(&mv64x60_wdt_driver); 238 ret = platform_driver_register(&mv64x60_wdt_driver);
239 out: 239 out:
240 return ret; 240 return ret;
241} 241}
242 242
243static void __exit mv64x60_wdt_exit(void) 243static void __exit mv64x60_wdt_exit(void)
244{ 244{
245 driver_unregister(&mv64x60_wdt_driver); 245 platform_driver_unregister(&mv64x60_wdt_driver);
246 platform_device_unregister(mv64x60_wdt_dev); 246 platform_device_unregister(mv64x60_wdt_dev);
247} 247}
248 248
diff --git a/drivers/char/watchdog/pcwd_pci.c b/drivers/char/watchdog/pcwd_pci.c
index d9ef55bdf88a..2451edbefece 100644
--- a/drivers/char/watchdog/pcwd_pci.c
+++ b/drivers/char/watchdog/pcwd_pci.c
@@ -755,7 +755,6 @@ static struct pci_device_id pcipcwd_pci_tbl[] = {
755MODULE_DEVICE_TABLE(pci, pcipcwd_pci_tbl); 755MODULE_DEVICE_TABLE(pci, pcipcwd_pci_tbl);
756 756
757static struct pci_driver pcipcwd_driver = { 757static struct pci_driver pcipcwd_driver = {
758 .owner = THIS_MODULE,
759 .name = WATCHDOG_NAME, 758 .name = WATCHDOG_NAME,
760 .id_table = pcipcwd_pci_tbl, 759 .id_table = pcipcwd_pci_tbl,
761 .probe = pcipcwd_card_init, 760 .probe = pcipcwd_card_init,
diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c
index 751cb77b0715..eb667daee19b 100644
--- a/drivers/char/watchdog/s3c2410_wdt.c
+++ b/drivers/char/watchdog/s3c2410_wdt.c
@@ -347,15 +347,14 @@ static irqreturn_t s3c2410wdt_irq(int irqno, void *param,
347} 347}
348/* device interface */ 348/* device interface */
349 349
350static int s3c2410wdt_probe(struct device *dev) 350static int s3c2410wdt_probe(struct platform_device *pdev)
351{ 351{
352 struct platform_device *pdev = to_platform_device(dev);
353 struct resource *res; 352 struct resource *res;
354 int started = 0; 353 int started = 0;
355 int ret; 354 int ret;
356 int size; 355 int size;
357 356
358 DBG("%s: probe=%p, device=%p\n", __FUNCTION__, pdev, dev); 357 DBG("%s: probe=%p\n", __FUNCTION__, pdev);
359 358
360 /* get the memory region for the watchdog timer */ 359 /* get the memory region for the watchdog timer */
361 360
@@ -386,13 +385,13 @@ static int s3c2410wdt_probe(struct device *dev)
386 return -ENOENT; 385 return -ENOENT;
387 } 386 }
388 387
389 ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, dev); 388 ret = request_irq(res->start, s3c2410wdt_irq, 0, pdev->name, pdev);
390 if (ret != 0) { 389 if (ret != 0) {
391 printk(KERN_INFO PFX "failed to install irq (%d)\n", ret); 390 printk(KERN_INFO PFX "failed to install irq (%d)\n", ret);
392 return ret; 391 return ret;
393 } 392 }
394 393
395 wdt_clock = clk_get(dev, "watchdog"); 394 wdt_clock = clk_get(&pdev->dev, "watchdog");
396 if (wdt_clock == NULL) { 395 if (wdt_clock == NULL) {
397 printk(KERN_INFO PFX "failed to find watchdog clock source\n"); 396 printk(KERN_INFO PFX "failed to find watchdog clock source\n");
398 return -ENOENT; 397 return -ENOENT;
@@ -430,7 +429,7 @@ static int s3c2410wdt_probe(struct device *dev)
430 return 0; 429 return 0;
431} 430}
432 431
433static int s3c2410wdt_remove(struct device *dev) 432static int s3c2410wdt_remove(struct platform_device *dev)
434{ 433{
435 if (wdt_mem != NULL) { 434 if (wdt_mem != NULL) {
436 release_resource(wdt_mem); 435 release_resource(wdt_mem);
@@ -454,7 +453,7 @@ static int s3c2410wdt_remove(struct device *dev)
454 return 0; 453 return 0;
455} 454}
456 455
457static void s3c2410wdt_shutdown(struct device *dev) 456static void s3c2410wdt_shutdown(struct platform_device *dev)
458{ 457{
459 s3c2410wdt_stop(); 458 s3c2410wdt_stop();
460} 459}
@@ -464,7 +463,7 @@ static void s3c2410wdt_shutdown(struct device *dev)
464static unsigned long wtcon_save; 463static unsigned long wtcon_save;
465static unsigned long wtdat_save; 464static unsigned long wtdat_save;
466 465
467static int s3c2410wdt_suspend(struct device *dev, pm_message_t state) 466static int s3c2410wdt_suspend(struct platform_device *dev, pm_message_t state)
468{ 467{
469 /* Save watchdog state, and turn it off. */ 468 /* Save watchdog state, and turn it off. */
470 wtcon_save = readl(wdt_base + S3C2410_WTCON); 469 wtcon_save = readl(wdt_base + S3C2410_WTCON);
@@ -476,7 +475,7 @@ static int s3c2410wdt_suspend(struct device *dev, pm_message_t state)
476 return 0; 475 return 0;
477} 476}
478 477
479static int s3c2410wdt_resume(struct device *dev) 478static int s3c2410wdt_resume(struct platform_device *dev)
480{ 479{
481 /* Restore watchdog state. */ 480 /* Restore watchdog state. */
482 481
@@ -496,15 +495,16 @@ static int s3c2410wdt_resume(struct device *dev)
496#endif /* CONFIG_PM */ 495#endif /* CONFIG_PM */
497 496
498 497
499static struct device_driver s3c2410wdt_driver = { 498static struct platform_driver s3c2410wdt_driver = {
500 .owner = THIS_MODULE,
501 .name = "s3c2410-wdt",
502 .bus = &platform_bus_type,
503 .probe = s3c2410wdt_probe, 499 .probe = s3c2410wdt_probe,
504 .remove = s3c2410wdt_remove, 500 .remove = s3c2410wdt_remove,
505 .shutdown = s3c2410wdt_shutdown, 501 .shutdown = s3c2410wdt_shutdown,
506 .suspend = s3c2410wdt_suspend, 502 .suspend = s3c2410wdt_suspend,
507 .resume = s3c2410wdt_resume, 503 .resume = s3c2410wdt_resume,
504 .driver = {
505 .owner = THIS_MODULE,
506 .name = "s3c2410-wdt",
507 },
508}; 508};
509 509
510 510
@@ -513,12 +513,12 @@ static char banner[] __initdata = KERN_INFO "S3C2410 Watchdog Timer, (c) 2004 Si
513static int __init watchdog_init(void) 513static int __init watchdog_init(void)
514{ 514{
515 printk(banner); 515 printk(banner);
516 return driver_register(&s3c2410wdt_driver); 516 return platform_driver_register(&s3c2410wdt_driver);
517} 517}
518 518
519static void __exit watchdog_exit(void) 519static void __exit watchdog_exit(void)
520{ 520{
521 driver_unregister(&s3c2410wdt_driver); 521 platform_driver_unregister(&s3c2410wdt_driver);
522} 522}
523 523
524module_init(watchdog_init); 524module_init(watchdog_init);
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/char/watchdog/wdt_pci.c b/drivers/char/watchdog/wdt_pci.c
index dc9370f6c348..4b3311993d48 100644
--- a/drivers/char/watchdog/wdt_pci.c
+++ b/drivers/char/watchdog/wdt_pci.c
@@ -711,7 +711,6 @@ MODULE_DEVICE_TABLE(pci, wdtpci_pci_tbl);
711 711
712 712
713static struct pci_driver wdtpci_driver = { 713static struct pci_driver wdtpci_driver = {
714 .owner = THIS_MODULE,
715 .name = "wdt_pci", 714 .name = "wdt_pci",
716 .id_table = wdtpci_pci_tbl, 715 .id_table = wdtpci_pci_tbl,
717 .probe = wdtpci_init_one, 716 .probe = wdtpci_init_one,
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 23a63207d747..815902c2c856 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -693,8 +693,8 @@ static int cpufreq_remove_dev (struct sys_device * sys_dev)
693 unsigned int cpu = sys_dev->id; 693 unsigned int cpu = sys_dev->id;
694 unsigned long flags; 694 unsigned long flags;
695 struct cpufreq_policy *data; 695 struct cpufreq_policy *data;
696 struct sys_device *cpu_sys_dev;
697#ifdef CONFIG_SMP 696#ifdef CONFIG_SMP
697 struct sys_device *cpu_sys_dev;
698 unsigned int j; 698 unsigned int j;
699#endif 699#endif
700 700
@@ -1113,21 +1113,13 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
1113{ 1113{
1114 int retval = -EINVAL; 1114 int retval = -EINVAL;
1115 1115
1116 /* 1116 lock_cpu_hotplug();
1117 * If we are already in context of hotplug thread, we dont need to
1118 * acquire the hotplug lock. Otherwise acquire cpucontrol to prevent
1119 * hotplug from removing this cpu that we are working on.
1120 */
1121 if (!current_in_cpu_hotplug())
1122 lock_cpu_hotplug();
1123
1124 dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu, 1117 dprintk("target for CPU %u: %u kHz, relation %u\n", policy->cpu,
1125 target_freq, relation); 1118 target_freq, relation);
1126 if (cpu_online(policy->cpu) && cpufreq_driver->target) 1119 if (cpu_online(policy->cpu) && cpufreq_driver->target)
1127 retval = cpufreq_driver->target(policy, target_freq, relation); 1120 retval = cpufreq_driver->target(policy, target_freq, relation);
1128 1121
1129 if (!current_in_cpu_hotplug()) 1122 unlock_cpu_hotplug();
1130 unlock_cpu_hotplug();
1131 1123
1132 return retval; 1124 return retval;
1133} 1125}
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/Kconfig b/drivers/firmware/Kconfig
index b6815c6c29a2..1e371a510dd2 100644
--- a/drivers/firmware/Kconfig
+++ b/drivers/firmware/Kconfig
@@ -60,6 +60,7 @@ config EFI_PCDP
60 60
61config DELL_RBU 61config DELL_RBU
62 tristate "BIOS update support for DELL systems via sysfs" 62 tristate "BIOS update support for DELL systems via sysfs"
63 depends on X86
63 select FW_LOADER 64 select FW_LOADER
64 help 65 help
65 Say m if you want to have the option of updating the BIOS for your 66 Say m if you want to have the option of updating the BIOS for your
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/hdaps.c b/drivers/hwmon/hdaps.c
index 1e5dfc7805e2..23a9e1ea8e32 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -60,9 +60,11 @@
60 60
61#define HDAPS_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */ 61#define HDAPS_POLL_PERIOD (HZ/20) /* poll for input every 1/20s */
62#define HDAPS_INPUT_FUZZ 4 /* input event threshold */ 62#define HDAPS_INPUT_FUZZ 4 /* input event threshold */
63#define HDAPS_INPUT_FLAT 4
63 64
64static struct timer_list hdaps_timer; 65static struct timer_list hdaps_timer;
65static struct platform_device *pdev; 66static struct platform_device *pdev;
67static struct input_dev *hdaps_idev;
66static unsigned int hdaps_invert; 68static unsigned int hdaps_invert;
67static u8 km_activity; 69static u8 km_activity;
68static int rest_x; 70static int rest_x;
@@ -284,7 +286,7 @@ out:
284 286
285/* Device model stuff */ 287/* Device model stuff */
286 288
287static int hdaps_probe(struct device *dev) 289static int hdaps_probe(struct platform_device *dev)
288{ 290{
289 int ret; 291 int ret;
290 292
@@ -296,29 +298,18 @@ static int hdaps_probe(struct device *dev)
296 return 0; 298 return 0;
297} 299}
298 300
299static int hdaps_resume(struct device *dev) 301static int hdaps_resume(struct platform_device *dev)
300{ 302{
301 return hdaps_device_init(); 303 return hdaps_device_init();
302} 304}
303 305
304static struct device_driver hdaps_driver = { 306static struct platform_driver hdaps_driver = {
305 .name = "hdaps",
306 .bus = &platform_bus_type,
307 .owner = THIS_MODULE,
308 .probe = hdaps_probe, 307 .probe = hdaps_probe,
309 .resume = hdaps_resume 308 .resume = hdaps_resume,
310}; 309 .driver = {
311 310 .name = "hdaps",
312/* Input class stuff */ 311 .owner = THIS_MODULE,
313 312 },
314static struct input_dev hdaps_idev = {
315 .name = "hdaps",
316 .evbit = { BIT(EV_ABS) },
317 .absbit = { BIT(ABS_X) | BIT(ABS_Y) },
318 .absmin = { [ABS_X] = -256, [ABS_Y] = -256 },
319 .absmax = { [ABS_X] = 256, [ABS_Y] = 256 },
320 .absfuzz = { [ABS_X] = HDAPS_INPUT_FUZZ, [ABS_Y] = HDAPS_INPUT_FUZZ },
321 .absflat = { [ABS_X] = HDAPS_INPUT_FUZZ, [ABS_Y] = HDAPS_INPUT_FUZZ },
322}; 313};
323 314
324/* 315/*
@@ -342,9 +333,9 @@ static void hdaps_mousedev_poll(unsigned long unused)
342 if (__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y)) 333 if (__hdaps_read_pair(HDAPS_PORT_XPOS, HDAPS_PORT_YPOS, &x, &y))
343 goto out; 334 goto out;
344 335
345 input_report_abs(&hdaps_idev, ABS_X, x - rest_x); 336 input_report_abs(hdaps_idev, ABS_X, x - rest_x);
346 input_report_abs(&hdaps_idev, ABS_Y, y - rest_y); 337 input_report_abs(hdaps_idev, ABS_Y, y - rest_y);
347 input_sync(&hdaps_idev); 338 input_sync(hdaps_idev);
348 339
349 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD); 340 mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);
350 341
@@ -550,7 +541,7 @@ static int __init hdaps_init(void)
550 goto out; 541 goto out;
551 } 542 }
552 543
553 ret = driver_register(&hdaps_driver); 544 ret = platform_driver_register(&hdaps_driver);
554 if (ret) 545 if (ret)
555 goto out_region; 546 goto out_region;
556 547
@@ -564,12 +555,25 @@ static int __init hdaps_init(void)
564 if (ret) 555 if (ret)
565 goto out_device; 556 goto out_device;
566 557
558 hdaps_idev = input_allocate_device();
559 if (!hdaps_idev) {
560 ret = -ENOMEM;
561 goto out_group;
562 }
563
567 /* initial calibrate for the input device */ 564 /* initial calibrate for the input device */
568 hdaps_calibrate(); 565 hdaps_calibrate();
569 566
570 /* initialize the input class */ 567 /* initialize the input class */
571 hdaps_idev.dev = &pdev->dev; 568 hdaps_idev->name = "hdaps";
572 input_register_device(&hdaps_idev); 569 hdaps_idev->cdev.dev = &pdev->dev;
570 hdaps_idev->evbit[0] = BIT(EV_ABS);
571 input_set_abs_params(hdaps_idev, ABS_X,
572 -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
573 input_set_abs_params(hdaps_idev, ABS_Y,
574 -256, 256, HDAPS_INPUT_FUZZ, HDAPS_INPUT_FLAT);
575
576 input_register_device(hdaps_idev);
573 577
574 /* start up our timer for the input device */ 578 /* start up our timer for the input device */
575 init_timer(&hdaps_timer); 579 init_timer(&hdaps_timer);
@@ -580,10 +584,12 @@ static int __init hdaps_init(void)
580 printk(KERN_INFO "hdaps: driver successfully loaded.\n"); 584 printk(KERN_INFO "hdaps: driver successfully loaded.\n");
581 return 0; 585 return 0;
582 586
587out_group:
588 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
583out_device: 589out_device:
584 platform_device_unregister(pdev); 590 platform_device_unregister(pdev);
585out_driver: 591out_driver:
586 driver_unregister(&hdaps_driver); 592 platform_driver_unregister(&hdaps_driver);
587out_region: 593out_region:
588 release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS); 594 release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS);
589out: 595out:
@@ -594,10 +600,10 @@ out:
594static void __exit hdaps_exit(void) 600static void __exit hdaps_exit(void)
595{ 601{
596 del_timer_sync(&hdaps_timer); 602 del_timer_sync(&hdaps_timer);
597 input_unregister_device(&hdaps_idev); 603 input_unregister_device(hdaps_idev);
598 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group); 604 sysfs_remove_group(&pdev->dev.kobj, &hdaps_attribute_group);
599 platform_device_unregister(pdev); 605 platform_device_unregister(pdev);
600 driver_unregister(&hdaps_driver); 606 platform_driver_unregister(&hdaps_driver);
601 release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS); 607 release_region(HDAPS_LOW_PORT, HDAPS_NR_PORTS);
602 608
603 printk(KERN_INFO "hdaps: driver unloaded.\n"); 609 printk(KERN_INFO "hdaps: driver unloaded.\n");
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index 6c41e25e670b..a61f5d00f10a 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -522,8 +522,15 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
522 struct i2c_client *client = to_i2c_client(dev); 522 struct i2c_client *client = to_i2c_client(dev);
523 struct it87_data *data = i2c_get_clientdata(client); 523 struct it87_data *data = i2c_get_clientdata(client);
524 int val = simple_strtol(buf, NULL, 10); 524 int val = simple_strtol(buf, NULL, 10);
525 u8 reg = it87_read_value(client, IT87_REG_FAN_DIV);
525 526
526 down(&data->update_lock); 527 down(&data->update_lock);
528 switch (nr) {
529 case 0: data->fan_div[nr] = reg & 0x07; break;
530 case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break;
531 case 2: data->fan_div[nr] = (reg & 0x40) ? 3 : 1; break;
532 }
533
527 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); 534 data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
528 it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]); 535 it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]);
529 up(&data->update_lock); 536 up(&data->update_lock);
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index bde0cda9477e..78cdd506439f 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -451,7 +451,7 @@ static DEVICE_ATTR(fan3_div, S_IRUGO, show_fan_3_div, NULL);
451static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf) 451static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
452{ 452{
453 struct lm78_data *data = lm78_update_device(dev); 453 struct lm78_data *data = lm78_update_device(dev);
454 return sprintf(buf, "%d\n", vid_from_reg(82, data->vid)); 454 return sprintf(buf, "%d\n", vid_from_reg(data->vid, 82));
455} 455}
456static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 456static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL);
457 457
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 4e9a04e1f08e..bbb3dcde146b 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -456,7 +456,9 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
456 (w83627thf == data->type || w83637hf == data->type)) 456 (w83627thf == data->type || w83637hf == data->type))
457 457
458 /* use VRM9 calculation */ 458 /* use VRM9 calculation */
459 data->in_min[0] = (u8)(((val * 100) - 70000 + 244) / 488); 459 data->in_min[0] =
460 SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0,
461 255);
460 else 462 else
461 /* use VRM8 (standard) calculation */ 463 /* use VRM8 (standard) calculation */
462 data->in_min[0] = IN_TO_REG(val); 464 data->in_min[0] = IN_TO_REG(val);
@@ -481,7 +483,9 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
481 (w83627thf == data->type || w83637hf == data->type)) 483 (w83627thf == data->type || w83637hf == data->type))
482 484
483 /* use VRM9 calculation */ 485 /* use VRM9 calculation */
484 data->in_max[0] = (u8)(((val * 100) - 70000 + 244) / 488); 486 data->in_max[0] =
487 SENSORS_LIMIT(((val * 100) - 70000 + 244) / 488, 0,
488 255);
485 else 489 else
486 /* use VRM8 (standard) calculation */ 490 /* use VRM8 (standard) calculation */
487 data->in_max[0] = IN_TO_REG(val); 491 data->in_max[0] = IN_TO_REG(val);
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index 4be59dbb78c4..1ba072630361 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -193,6 +193,7 @@ static const u8 W83792D_REG_LEVELS[3][4] = {
193 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */ 193 0xE2 } /* (bit3-0) SmartFanII: Fan3 Level 3 */
194}; 194};
195 195
196#define W83792D_REG_GPIO_EN 0x1A
196#define W83792D_REG_CONFIG 0x40 197#define W83792D_REG_CONFIG 0x40
197#define W83792D_REG_VID_FANDIV 0x47 198#define W83792D_REG_VID_FANDIV 0x47
198#define W83792D_REG_CHIPID 0x49 199#define W83792D_REG_CHIPID 0x49
@@ -257,7 +258,7 @@ DIV_TO_REG(long val)
257{ 258{
258 int i; 259 int i;
259 val = SENSORS_LIMIT(val, 1, 128) >> 1; 260 val = SENSORS_LIMIT(val, 1, 128) >> 1;
260 for (i = 0; i < 6; i++) { 261 for (i = 0; i < 7; i++) {
261 if (val == 0) 262 if (val == 0)
262 break; 263 break;
263 val >>= 1; 264 val >>= 1;
@@ -1282,8 +1283,8 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1282 w83792d_init_client(new_client); 1283 w83792d_init_client(new_client);
1283 1284
1284 /* A few vars need to be filled upon startup */ 1285 /* A few vars need to be filled upon startup */
1285 for (i = 1; i <= 7; i++) { 1286 for (i = 0; i < 7; i++) {
1286 data->fan_min[i - 1] = w83792d_read_value(new_client, 1287 data->fan_min[i] = w83792d_read_value(new_client,
1287 W83792D_REG_FAN_MIN[i]); 1288 W83792D_REG_FAN_MIN[i]);
1288 } 1289 }
1289 1290
@@ -1306,10 +1307,20 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
1306 device_create_file_fan(new_client, 1); 1307 device_create_file_fan(new_client, 1);
1307 device_create_file_fan(new_client, 2); 1308 device_create_file_fan(new_client, 2);
1308 device_create_file_fan(new_client, 3); 1309 device_create_file_fan(new_client, 3);
1309 device_create_file_fan(new_client, 4); 1310
1310 device_create_file_fan(new_client, 5); 1311 /* Read GPIO enable register to check if pins for fan 4,5 are used as
1311 device_create_file_fan(new_client, 6); 1312 GPIO */
1312 device_create_file_fan(new_client, 7); 1313 val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN);
1314 if (!(val1 & 0x40))
1315 device_create_file_fan(new_client, 4);
1316 if (!(val1 & 0x20))
1317 device_create_file_fan(new_client, 5);
1318
1319 val1 = w83792d_read_value(new_client, W83792D_REG_PIN);
1320 if (val1 & 0x40)
1321 device_create_file_fan(new_client, 6);
1322 if (val1 & 0x04)
1323 device_create_file_fan(new_client, 7);
1313 1324
1314 device_create_file_temp1(new_client); /* Temp1 */ 1325 device_create_file_temp1(new_client); /* Temp1 */
1315 device_create_file_temp_add(new_client, 2); /* Temp2 */ 1326 device_create_file_temp_add(new_client, 2); /* Temp2 */
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index ba90f5140af6..3eb47890db40 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -513,7 +513,6 @@ static void __devexit ali1535_remove(struct pci_dev *dev)
513} 513}
514 514
515static struct pci_driver ali1535_driver = { 515static struct pci_driver ali1535_driver = {
516 .owner = THIS_MODULE,
517 .name = "ali1535_smbus", 516 .name = "ali1535_smbus",
518 .id_table = ali1535_ids, 517 .id_table = ali1535_ids,
519 .probe = ali1535_probe, 518 .probe = ali1535_probe,
diff --git a/drivers/i2c/busses/i2c-ali1563.c b/drivers/i2c/busses/i2c-ali1563.c
index f1a62d892425..e6f63208fc4a 100644
--- a/drivers/i2c/busses/i2c-ali1563.c
+++ b/drivers/i2c/busses/i2c-ali1563.c
@@ -408,7 +408,6 @@ static struct pci_device_id __devinitdata ali1563_id_table[] = {
408MODULE_DEVICE_TABLE (pci, ali1563_id_table); 408MODULE_DEVICE_TABLE (pci, ali1563_id_table);
409 409
410static struct pci_driver ali1563_pci_driver = { 410static struct pci_driver ali1563_pci_driver = {
411 .owner = THIS_MODULE,
412 .name = "ali1563_smbus", 411 .name = "ali1563_smbus",
413 .id_table = ali1563_id_table, 412 .id_table = ali1563_id_table,
414 .probe = ali1563_probe, 413 .probe = ali1563_probe,
diff --git a/drivers/i2c/busses/i2c-ali15x3.c b/drivers/i2c/busses/i2c-ali15x3.c
index 400b08ed4299..7a5c0941dbc1 100644
--- a/drivers/i2c/busses/i2c-ali15x3.c
+++ b/drivers/i2c/busses/i2c-ali15x3.c
@@ -504,7 +504,6 @@ static void __devexit ali15x3_remove(struct pci_dev *dev)
504} 504}
505 505
506static struct pci_driver ali15x3_driver = { 506static struct pci_driver ali15x3_driver = {
507 .owner = THIS_MODULE,
508 .name = "ali15x3_smbus", 507 .name = "ali15x3_smbus",
509 .id_table = ali15x3_ids, 508 .id_table = ali15x3_ids,
510 .probe = ali15x3_probe, 509 .probe = ali15x3_probe,
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index de035d137c3f..1750dedaf4b5 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -401,7 +401,6 @@ static void __devexit amd756_remove(struct pci_dev *dev)
401} 401}
402 402
403static struct pci_driver amd756_driver = { 403static struct pci_driver amd756_driver = {
404 .owner = THIS_MODULE,
405 .name = "amd756_smbus", 404 .name = "amd756_smbus",
406 .id_table = amd756_ids, 405 .id_table = amd756_ids,
407 .probe = amd756_probe, 406 .probe = amd756_probe,
diff --git a/drivers/i2c/busses/i2c-amd8111.c b/drivers/i2c/busses/i2c-amd8111.c
index f3b79a68dbec..e5ef560e686a 100644
--- a/drivers/i2c/busses/i2c-amd8111.c
+++ b/drivers/i2c/busses/i2c-amd8111.c
@@ -384,7 +384,6 @@ static void __devexit amd8111_remove(struct pci_dev *dev)
384} 384}
385 385
386static struct pci_driver amd8111_driver = { 386static struct pci_driver amd8111_driver = {
387 .owner = THIS_MODULE,
388 .name = "amd8111_smbus2", 387 .name = "amd8111_smbus2",
389 .id_table = amd8111_ids, 388 .id_table = amd8111_ids,
390 .probe = amd8111_probe, 389 .probe = amd8111_probe,
diff --git a/drivers/i2c/busses/i2c-hydra.c b/drivers/i2c/busses/i2c-hydra.c
index 1b5354e24bf5..e0cb3b0f92fa 100644
--- a/drivers/i2c/busses/i2c-hydra.c
+++ b/drivers/i2c/busses/i2c-hydra.c
@@ -155,7 +155,6 @@ static void __devexit hydra_remove(struct pci_dev *dev)
155 155
156 156
157static struct pci_driver hydra_driver = { 157static struct pci_driver hydra_driver = {
158 .owner = THIS_MODULE,
159 .name = "hydra_smbus", 158 .name = "hydra_smbus",
160 .id_table = hydra_ids, 159 .id_table = hydra_ids,
161 .probe = hydra_probe, 160 .probe = hydra_probe,
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 4f63195069da..ac3eafa8aac0 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -560,7 +560,6 @@ static void __devexit i801_remove(struct pci_dev *dev)
560} 560}
561 561
562static struct pci_driver i801_driver = { 562static struct pci_driver i801_driver = {
563 .owner = THIS_MODULE,
564 .name = "i801_smbus", 563 .name = "i801_smbus",
565 .id_table = i801_ids, 564 .id_table = i801_ids,
566 .probe = i801_probe, 565 .probe = i801_probe,
diff --git a/drivers/i2c/busses/i2c-i810.c b/drivers/i2c/busses/i2c-i810.c
index 52bc30593bd7..748be30f2bae 100644
--- a/drivers/i2c/busses/i2c-i810.c
+++ b/drivers/i2c/busses/i2c-i810.c
@@ -233,7 +233,6 @@ static void __devexit i810_remove(struct pci_dev *dev)
233} 233}
234 234
235static struct pci_driver i810_driver = { 235static struct pci_driver i810_driver = {
236 .owner = THIS_MODULE,
237 .name = "i810_smbus", 236 .name = "i810_smbus",
238 .id_table = i810_ids, 237 .id_table = i810_ids,
239 .probe = i810_probe, 238 .probe = i810_probe,
diff --git a/drivers/i2c/busses/i2c-iop3xx.c b/drivers/i2c/busses/i2c-iop3xx.c
index cfae4ad00fae..1414851a17b8 100644
--- a/drivers/i2c/busses/i2c-iop3xx.c
+++ b/drivers/i2c/busses/i2c-iop3xx.c
@@ -405,10 +405,9 @@ static struct i2c_algorithm iop3xx_i2c_algo = {
405}; 405};
406 406
407static int 407static int
408iop3xx_i2c_remove(struct device *device) 408iop3xx_i2c_remove(struct platform_device *pdev)
409{ 409{
410 struct platform_device *pdev = to_platform_device(device); 410 struct i2c_adapter *padapter = platform_get_drvdata(pdev);
411 struct i2c_adapter *padapter = dev_get_drvdata(&pdev->dev);
412 struct i2c_algo_iop3xx_data *adapter_data = 411 struct i2c_algo_iop3xx_data *adapter_data =
413 (struct i2c_algo_iop3xx_data *)padapter->algo_data; 412 (struct i2c_algo_iop3xx_data *)padapter->algo_data;
414 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 413 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -426,15 +425,14 @@ iop3xx_i2c_remove(struct device *device)
426 kfree(adapter_data); 425 kfree(adapter_data);
427 kfree(padapter); 426 kfree(padapter);
428 427
429 dev_set_drvdata(&pdev->dev, NULL); 428 platform_set_drvdata(pdev, NULL);
430 429
431 return 0; 430 return 0;
432} 431}
433 432
434static int 433static int
435iop3xx_i2c_probe(struct device *dev) 434iop3xx_i2c_probe(struct platform_device *pdev)
436{ 435{
437 struct platform_device *pdev = to_platform_device(dev);
438 struct resource *res; 436 struct resource *res;
439 int ret; 437 int ret;
440 struct i2c_adapter *new_adapter; 438 struct i2c_adapter *new_adapter;
@@ -499,7 +497,7 @@ iop3xx_i2c_probe(struct device *dev)
499 iop3xx_i2c_set_slave_addr(adapter_data); 497 iop3xx_i2c_set_slave_addr(adapter_data);
500 iop3xx_i2c_enable(adapter_data); 498 iop3xx_i2c_enable(adapter_data);
501 499
502 dev_set_drvdata(&pdev->dev, new_adapter); 500 platform_set_drvdata(pdev, new_adapter);
503 new_adapter->algo_data = adapter_data; 501 new_adapter->algo_data = adapter_data;
504 502
505 i2c_add_adapter(new_adapter); 503 i2c_add_adapter(new_adapter);
@@ -523,24 +521,25 @@ out:
523} 521}
524 522
525 523
526static struct device_driver iop3xx_i2c_driver = { 524static struct platform_driver iop3xx_i2c_driver = {
527 .owner = THIS_MODULE,
528 .name = "IOP3xx-I2C",
529 .bus = &platform_bus_type,
530 .probe = iop3xx_i2c_probe, 525 .probe = iop3xx_i2c_probe,
531 .remove = iop3xx_i2c_remove 526 .remove = iop3xx_i2c_remove,
527 .driver = {
528 .owner = THIS_MODULE,
529 .name = "IOP3xx-I2C",
530 },
532}; 531};
533 532
534static int __init 533static int __init
535i2c_iop3xx_init (void) 534i2c_iop3xx_init (void)
536{ 535{
537 return driver_register(&iop3xx_i2c_driver); 536 return platform_driver_register(&iop3xx_i2c_driver);
538} 537}
539 538
540static void __exit 539static void __exit
541i2c_iop3xx_exit (void) 540i2c_iop3xx_exit (void)
542{ 541{
543 driver_unregister(&iop3xx_i2c_driver); 542 platform_driver_unregister(&iop3xx_i2c_driver);
544 return; 543 return;
545} 544}
546 545
diff --git a/drivers/i2c/busses/i2c-ixp2000.c b/drivers/i2c/busses/i2c-ixp2000.c
index 64552a376f2d..cd6f45d186ab 100644
--- a/drivers/i2c/busses/i2c-ixp2000.c
+++ b/drivers/i2c/busses/i2c-ixp2000.c
@@ -36,8 +36,6 @@
36#include <asm/hardware.h> /* Pick up IXP2000-specific bits */ 36#include <asm/hardware.h> /* Pick up IXP2000-specific bits */
37#include <asm/arch/gpio.h> 37#include <asm/arch/gpio.h>
38 38
39static struct device_driver ixp2000_i2c_driver;
40
41static inline int ixp2000_scl_pin(void *data) 39static inline int ixp2000_scl_pin(void *data)
42{ 40{
43 return ((struct ixp2000_i2c_pins*)data)->scl_pin; 41 return ((struct ixp2000_i2c_pins*)data)->scl_pin;
@@ -86,12 +84,11 @@ struct ixp2000_i2c_data {
86 struct i2c_algo_bit_data algo_data; 84 struct i2c_algo_bit_data algo_data;
87}; 85};
88 86
89static int ixp2000_i2c_remove(struct device *dev) 87static int ixp2000_i2c_remove(struct platform_device *plat_dev)
90{ 88{
91 struct platform_device *plat_dev = to_platform_device(dev); 89 struct ixp2000_i2c_data *drv_data = platform_get_drvdata(plat_dev);
92 struct ixp2000_i2c_data *drv_data = dev_get_drvdata(&plat_dev->dev);
93 90
94 dev_set_drvdata(&plat_dev->dev, NULL); 91 platform_set_drvdata(plat_dev, NULL);
95 92
96 i2c_bit_del_bus(&drv_data->adapter); 93 i2c_bit_del_bus(&drv_data->adapter);
97 94
@@ -100,10 +97,9 @@ static int ixp2000_i2c_remove(struct device *dev)
100 return 0; 97 return 0;
101} 98}
102 99
103static int ixp2000_i2c_probe(struct device *dev) 100static int ixp2000_i2c_probe(struct platform_device *plat_dev)
104{ 101{
105 int err; 102 int err;
106 struct platform_device *plat_dev = to_platform_device(dev);
107 struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data; 103 struct ixp2000_i2c_pins *gpio = plat_dev->dev.platform_data;
108 struct ixp2000_i2c_data *drv_data = 104 struct ixp2000_i2c_data *drv_data =
109 kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL); 105 kzalloc(sizeof(struct ixp2000_i2c_data), GFP_KERNEL);
@@ -122,7 +118,7 @@ static int ixp2000_i2c_probe(struct device *dev)
122 drv_data->algo_data.timeout = 100; 118 drv_data->algo_data.timeout = 100;
123 119
124 drv_data->adapter.id = I2C_HW_B_IXP2000, 120 drv_data->adapter.id = I2C_HW_B_IXP2000,
125 strlcpy(drv_data->adapter.name, ixp2000_i2c_driver.name, 121 strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
126 I2C_NAME_SIZE); 122 I2C_NAME_SIZE);
127 drv_data->adapter.algo_data = &drv_data->algo_data, 123 drv_data->adapter.algo_data = &drv_data->algo_data,
128 124
@@ -134,32 +130,33 @@ static int ixp2000_i2c_probe(struct device *dev)
134 gpio_line_set(gpio->sda_pin, 0); 130 gpio_line_set(gpio->sda_pin, 0);
135 131
136 if ((err = i2c_bit_add_bus(&drv_data->adapter)) != 0) { 132 if ((err = i2c_bit_add_bus(&drv_data->adapter)) != 0) {
137 dev_err(dev, "Could not install, error %d\n", err); 133 dev_err(&plat_dev->dev, "Could not install, error %d\n", err);
138 kfree(drv_data); 134 kfree(drv_data);
139 return err; 135 return err;
140 } 136 }
141 137
142 dev_set_drvdata(&plat_dev->dev, drv_data); 138 platform_set_drvdata(plat_dev, drv_data);
143 139
144 return 0; 140 return 0;
145} 141}
146 142
147static struct device_driver ixp2000_i2c_driver = { 143static struct platform_driver ixp2000_i2c_driver = {
148 .owner = THIS_MODULE,
149 .name = "IXP2000-I2C",
150 .bus = &platform_bus_type,
151 .probe = ixp2000_i2c_probe, 144 .probe = ixp2000_i2c_probe,
152 .remove = ixp2000_i2c_remove, 145 .remove = ixp2000_i2c_remove,
146 .driver = {
147 .name = "IXP2000-I2C",
148 .owner = THIS_MODULE,
149 },
153}; 150};
154 151
155static int __init ixp2000_i2c_init(void) 152static int __init ixp2000_i2c_init(void)
156{ 153{
157 return driver_register(&ixp2000_i2c_driver); 154 return platform_driver_register(&ixp2000_i2c_driver);
158} 155}
159 156
160static void __exit ixp2000_i2c_exit(void) 157static void __exit ixp2000_i2c_exit(void)
161{ 158{
162 driver_unregister(&ixp2000_i2c_driver); 159 platform_driver_unregister(&ixp2000_i2c_driver);
163} 160}
164 161
165module_init(ixp2000_i2c_init); 162module_init(ixp2000_i2c_init);
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index cc652c350814..e422d8b2d4d6 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -35,8 +35,6 @@
35 35
36#include <asm/hardware.h> /* Pick up IXP4xx-specific bits */ 36#include <asm/hardware.h> /* Pick up IXP4xx-specific bits */
37 37
38static struct device_driver ixp4xx_i2c_driver;
39
40static inline int ixp4xx_scl_pin(void *data) 38static inline int ixp4xx_scl_pin(void *data)
41{ 39{
42 return ((struct ixp4xx_i2c_pins*)data)->scl_pin; 40 return ((struct ixp4xx_i2c_pins*)data)->scl_pin;
@@ -87,12 +85,11 @@ struct ixp4xx_i2c_data {
87 struct i2c_algo_bit_data algo_data; 85 struct i2c_algo_bit_data algo_data;
88}; 86};
89 87
90static int ixp4xx_i2c_remove(struct device *dev) 88static int ixp4xx_i2c_remove(struct platform_device *plat_dev)
91{ 89{
92 struct platform_device *plat_dev = to_platform_device(dev); 90 struct ixp4xx_i2c_data *drv_data = platform_get_drvdata(plat_dev);
93 struct ixp4xx_i2c_data *drv_data = dev_get_drvdata(&plat_dev->dev);
94 91
95 dev_set_drvdata(&plat_dev->dev, NULL); 92 platform_set_drvdata(plat_dev, NULL);
96 93
97 i2c_bit_del_bus(&drv_data->adapter); 94 i2c_bit_del_bus(&drv_data->adapter);
98 95
@@ -101,10 +98,9 @@ static int ixp4xx_i2c_remove(struct device *dev)
101 return 0; 98 return 0;
102} 99}
103 100
104static int ixp4xx_i2c_probe(struct device *dev) 101static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
105{ 102{
106 int err; 103 int err;
107 struct platform_device *plat_dev = to_platform_device(dev);
108 struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data; 104 struct ixp4xx_i2c_pins *gpio = plat_dev->dev.platform_data;
109 struct ixp4xx_i2c_data *drv_data = 105 struct ixp4xx_i2c_data *drv_data =
110 kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL); 106 kzalloc(sizeof(struct ixp4xx_i2c_data), GFP_KERNEL);
@@ -130,7 +126,7 @@ static int ixp4xx_i2c_probe(struct device *dev)
130 drv_data->algo_data.timeout = 100; 126 drv_data->algo_data.timeout = 100;
131 127
132 drv_data->adapter.id = I2C_HW_B_IXP4XX; 128 drv_data->adapter.id = I2C_HW_B_IXP4XX;
133 strlcpy(drv_data->adapter.name, ixp4xx_i2c_driver.name, 129 strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
134 I2C_NAME_SIZE); 130 I2C_NAME_SIZE);
135 drv_data->adapter.algo_data = &drv_data->algo_data; 131 drv_data->adapter.algo_data = &drv_data->algo_data;
136 132
@@ -142,33 +138,34 @@ static int ixp4xx_i2c_probe(struct device *dev)
142 gpio_line_set(gpio->sda_pin, 0); 138 gpio_line_set(gpio->sda_pin, 0);
143 139
144 if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) { 140 if ((err = i2c_bit_add_bus(&drv_data->adapter) != 0)) {
145 printk(KERN_ERR "ERROR: Could not install %s\n", dev->bus_id); 141 printk(KERN_ERR "ERROR: Could not install %s\n", plat_dev->dev.bus_id);
146 142
147 kfree(drv_data); 143 kfree(drv_data);
148 return err; 144 return err;
149 } 145 }
150 146
151 dev_set_drvdata(&plat_dev->dev, drv_data); 147 platform_set_drvdata(plat_dev, drv_data);
152 148
153 return 0; 149 return 0;
154} 150}
155 151
156static struct device_driver ixp4xx_i2c_driver = { 152static struct platform_driver ixp4xx_i2c_driver = {
157 .owner = THIS_MODULE,
158 .name = "IXP4XX-I2C",
159 .bus = &platform_bus_type,
160 .probe = ixp4xx_i2c_probe, 153 .probe = ixp4xx_i2c_probe,
161 .remove = ixp4xx_i2c_remove, 154 .remove = ixp4xx_i2c_remove,
155 .driver = {
156 .name = "IXP4XX-I2C",
157 .owner = THIS_MODULE,
158 },
162}; 159};
163 160
164static int __init ixp4xx_i2c_init(void) 161static int __init ixp4xx_i2c_init(void)
165{ 162{
166 return driver_register(&ixp4xx_i2c_driver); 163 return platform_driver_register(&ixp4xx_i2c_driver);
167} 164}
168 165
169static void __exit ixp4xx_i2c_exit(void) 166static void __exit ixp4xx_i2c_exit(void)
170{ 167{
171 driver_unregister(&ixp4xx_i2c_driver); 168 platform_driver_unregister(&ixp4xx_i2c_driver);
172} 169}
173 170
174module_init(ixp4xx_i2c_init); 171module_init(ixp4xx_i2c_init);
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 65b939a059e9..5ccd338a9dc9 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -288,11 +288,10 @@ static struct i2c_adapter mpc_ops = {
288 .retries = 1 288 .retries = 1
289}; 289};
290 290
291static int fsl_i2c_probe(struct device *device) 291static int fsl_i2c_probe(struct platform_device *pdev)
292{ 292{
293 int result = 0; 293 int result = 0;
294 struct mpc_i2c *i2c; 294 struct mpc_i2c *i2c;
295 struct platform_device *pdev = to_platform_device(device);
296 struct fsl_i2c_platform_data *pdata; 295 struct fsl_i2c_platform_data *pdata;
297 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 296 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
298 297
@@ -323,7 +322,7 @@ static int fsl_i2c_probe(struct device *device)
323 } 322 }
324 323
325 mpc_i2c_setclock(i2c); 324 mpc_i2c_setclock(i2c);
326 dev_set_drvdata(device, i2c); 325 platform_set_drvdata(pdev, i2c);
327 326
328 i2c->adap = mpc_ops; 327 i2c->adap = mpc_ops;
329 i2c_set_adapdata(&i2c->adap, i2c); 328 i2c_set_adapdata(&i2c->adap, i2c);
@@ -345,12 +344,12 @@ static int fsl_i2c_probe(struct device *device)
345 return result; 344 return result;
346}; 345};
347 346
348static int fsl_i2c_remove(struct device *device) 347static int fsl_i2c_remove(struct platform_device *pdev)
349{ 348{
350 struct mpc_i2c *i2c = dev_get_drvdata(device); 349 struct mpc_i2c *i2c = platform_get_drvdata(pdev);
351 350
352 i2c_del_adapter(&i2c->adap); 351 i2c_del_adapter(&i2c->adap);
353 dev_set_drvdata(device, NULL); 352 platform_set_drvdata(pdev, NULL);
354 353
355 if (i2c->irq != 0) 354 if (i2c->irq != 0)
356 free_irq(i2c->irq, i2c); 355 free_irq(i2c->irq, i2c);
@@ -361,22 +360,23 @@ static int fsl_i2c_remove(struct device *device)
361}; 360};
362 361
363/* Structure for a device driver */ 362/* Structure for a device driver */
364static struct device_driver fsl_i2c_driver = { 363static struct platform_driver fsl_i2c_driver = {
365 .owner = THIS_MODULE,
366 .name = "fsl-i2c",
367 .bus = &platform_bus_type,
368 .probe = fsl_i2c_probe, 364 .probe = fsl_i2c_probe,
369 .remove = fsl_i2c_remove, 365 .remove = fsl_i2c_remove,
366 .driver = {
367 .owner = THIS_MODULE,
368 .name = "fsl-i2c",
369 },
370}; 370};
371 371
372static int __init fsl_i2c_init(void) 372static int __init fsl_i2c_init(void)
373{ 373{
374 return driver_register(&fsl_i2c_driver); 374 return platform_driver_register(&fsl_i2c_driver);
375} 375}
376 376
377static void __exit fsl_i2c_exit(void) 377static void __exit fsl_i2c_exit(void)
378{ 378{
379 driver_unregister(&fsl_i2c_driver); 379 platform_driver_unregister(&fsl_i2c_driver);
380} 380}
381 381
382module_init(fsl_i2c_init); 382module_init(fsl_i2c_init);
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 6b48027b2ee3..81031eb51056 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -492,11 +492,10 @@ mv64xxx_i2c_unmap_regs(struct mv64xxx_i2c_data *drv_data)
492} 492}
493 493
494static int __devinit 494static int __devinit
495mv64xxx_i2c_probe(struct device *dev) 495mv64xxx_i2c_probe(struct platform_device *pd)
496{ 496{
497 struct platform_device *pd = to_platform_device(dev);
498 struct mv64xxx_i2c_data *drv_data; 497 struct mv64xxx_i2c_data *drv_data;
499 struct mv64xxx_i2c_pdata *pdata = dev->platform_data; 498 struct mv64xxx_i2c_pdata *pdata = pd->dev.platform_data;
500 int rc; 499 int rc;
501 500
502 if ((pd->id != 0) || !pdata) 501 if ((pd->id != 0) || !pdata)
@@ -526,18 +525,19 @@ mv64xxx_i2c_probe(struct device *dev)
526 drv_data->adapter.class = I2C_CLASS_HWMON; 525 drv_data->adapter.class = I2C_CLASS_HWMON;
527 drv_data->adapter.timeout = pdata->timeout; 526 drv_data->adapter.timeout = pdata->timeout;
528 drv_data->adapter.retries = pdata->retries; 527 drv_data->adapter.retries = pdata->retries;
529 dev_set_drvdata(dev, drv_data); 528 platform_set_drvdata(pd, drv_data);
530 i2c_set_adapdata(&drv_data->adapter, drv_data); 529 i2c_set_adapdata(&drv_data->adapter, drv_data);
531 530
532 if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0, 531 if (request_irq(drv_data->irq, mv64xxx_i2c_intr, 0,
533 MV64XXX_I2C_CTLR_NAME, drv_data)) { 532 MV64XXX_I2C_CTLR_NAME, drv_data)) {
534 533 dev_err(&drv_data->adapter.dev,
535 dev_err(dev, "mv64xxx: Can't register intr handler " 534 "mv64xxx: Can't register intr handler irq: %d\n",
536 "irq: %d\n", drv_data->irq); 535 drv_data->irq);
537 rc = -EINVAL; 536 rc = -EINVAL;
538 goto exit_unmap_regs; 537 goto exit_unmap_regs;
539 } else if ((rc = i2c_add_adapter(&drv_data->adapter)) != 0) { 538 } else if ((rc = i2c_add_adapter(&drv_data->adapter)) != 0) {
540 dev_err(dev, "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc); 539 dev_err(&drv_data->adapter.dev,
540 "mv64xxx: Can't add i2c adapter, rc: %d\n", -rc);
541 goto exit_free_irq; 541 goto exit_free_irq;
542 } 542 }
543 543
@@ -555,9 +555,9 @@ mv64xxx_i2c_probe(struct device *dev)
555} 555}
556 556
557static int __devexit 557static int __devexit
558mv64xxx_i2c_remove(struct device *dev) 558mv64xxx_i2c_remove(struct platform_device *dev)
559{ 559{
560 struct mv64xxx_i2c_data *drv_data = dev_get_drvdata(dev); 560 struct mv64xxx_i2c_data *drv_data = platform_get_drvdata(dev);
561 int rc; 561 int rc;
562 562
563 rc = i2c_del_adapter(&drv_data->adapter); 563 rc = i2c_del_adapter(&drv_data->adapter);
@@ -568,24 +568,25 @@ mv64xxx_i2c_remove(struct device *dev)
568 return rc; 568 return rc;
569} 569}
570 570
571static struct device_driver mv64xxx_i2c_driver = { 571static struct platform_driver mv64xxx_i2c_driver = {
572 .owner = THIS_MODULE,
573 .name = MV64XXX_I2C_CTLR_NAME,
574 .bus = &platform_bus_type,
575 .probe = mv64xxx_i2c_probe, 572 .probe = mv64xxx_i2c_probe,
576 .remove = mv64xxx_i2c_remove, 573 .remove = mv64xxx_i2c_remove,
574 .driver = {
575 .owner = THIS_MODULE,
576 .name = MV64XXX_I2C_CTLR_NAME,
577 },
577}; 578};
578 579
579static int __init 580static int __init
580mv64xxx_i2c_init(void) 581mv64xxx_i2c_init(void)
581{ 582{
582 return driver_register(&mv64xxx_i2c_driver); 583 return platform_driver_register(&mv64xxx_i2c_driver);
583} 584}
584 585
585static void __exit 586static void __exit
586mv64xxx_i2c_exit(void) 587mv64xxx_i2c_exit(void)
587{ 588{
588 driver_unregister(&mv64xxx_i2c_driver); 589 platform_driver_unregister(&mv64xxx_i2c_driver);
589} 590}
590 591
591module_init(mv64xxx_i2c_init); 592module_init(mv64xxx_i2c_init);
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c
index fd26036e68a3..4d18e6e5f159 100644
--- a/drivers/i2c/busses/i2c-nforce2.c
+++ b/drivers/i2c/busses/i2c-nforce2.c
@@ -347,7 +347,6 @@ static void __devexit nforce2_remove(struct pci_dev *dev)
347} 347}
348 348
349static struct pci_driver nforce2_driver = { 349static struct pci_driver nforce2_driver = {
350 .owner = THIS_MODULE,
351 .name = "nForce2_smbus", 350 .name = "nForce2_smbus",
352 .id_table = nforce2_ids, 351 .id_table = nforce2_ids,
353 .probe = nforce2_probe, 352 .probe = nforce2_probe,
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 7d63eec423fe..692f47345481 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -462,7 +462,6 @@ static void __devexit piix4_remove(struct pci_dev *dev)
462} 462}
463 463
464static struct pci_driver piix4_driver = { 464static struct pci_driver piix4_driver = {
465 .owner = THIS_MODULE,
466 .name = "piix4_smbus", 465 .name = "piix4_smbus",
467 .id_table = piix4_ids, 466 .id_table = piix4_ids,
468 .probe = piix4_probe, 467 .probe = piix4_probe,
diff --git a/drivers/i2c/busses/i2c-prosavage.c b/drivers/i2c/busses/i2c-prosavage.c
index 42cb1d8ca659..9479525892e3 100644
--- a/drivers/i2c/busses/i2c-prosavage.c
+++ b/drivers/i2c/busses/i2c-prosavage.c
@@ -301,7 +301,6 @@ static struct pci_device_id prosavage_pci_tbl[] = {
301MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl); 301MODULE_DEVICE_TABLE (pci, prosavage_pci_tbl);
302 302
303static struct pci_driver prosavage_driver = { 303static struct pci_driver prosavage_driver = {
304 .owner = THIS_MODULE,
305 .name = "prosavage_smbus", 304 .name = "prosavage_smbus",
306 .id_table = prosavage_pci_tbl, 305 .id_table = prosavage_pci_tbl,
307 .probe = prosavage_probe, 306 .probe = prosavage_probe,
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 67ccbea24ba4..70f7ab829d36 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -936,10 +936,10 @@ static struct pxa_i2c i2c_pxa = {
936 }, 936 },
937}; 937};
938 938
939static int i2c_pxa_probe(struct device *dev) 939static int i2c_pxa_probe(struct platform_device *dev)
940{ 940{
941 struct pxa_i2c *i2c = &i2c_pxa; 941 struct pxa_i2c *i2c = &i2c_pxa;
942 struct i2c_pxa_platform_data *plat = dev->platform_data; 942 struct i2c_pxa_platform_data *plat = dev->dev.platform_data;
943 int ret; 943 int ret;
944 944
945#ifdef CONFIG_PXA27x 945#ifdef CONFIG_PXA27x
@@ -968,7 +968,7 @@ static int i2c_pxa_probe(struct device *dev)
968 i2c_pxa_reset(i2c); 968 i2c_pxa_reset(i2c);
969 969
970 i2c->adap.algo_data = i2c; 970 i2c->adap.algo_data = i2c;
971 i2c->adap.dev.parent = dev; 971 i2c->adap.dev.parent = &dev->dev;
972 972
973 ret = i2c_add_adapter(&i2c->adap); 973 ret = i2c_add_adapter(&i2c->adap);
974 if (ret < 0) { 974 if (ret < 0) {
@@ -976,7 +976,7 @@ static int i2c_pxa_probe(struct device *dev)
976 goto err_irq; 976 goto err_irq;
977 } 977 }
978 978
979 dev_set_drvdata(dev, i2c); 979 platform_set_drvdata(dev, i2c);
980 980
981#ifdef CONFIG_I2C_PXA_SLAVE 981#ifdef CONFIG_I2C_PXA_SLAVE
982 printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n", 982 printk(KERN_INFO "I2C: %s: PXA I2C adapter, slave address %d\n",
@@ -993,11 +993,11 @@ static int i2c_pxa_probe(struct device *dev)
993 return ret; 993 return ret;
994} 994}
995 995
996static int i2c_pxa_remove(struct device *dev) 996static int i2c_pxa_remove(struct platform_device *dev)
997{ 997{
998 struct pxa_i2c *i2c = dev_get_drvdata(dev); 998 struct pxa_i2c *i2c = platform_get_drvdata(dev);
999 999
1000 dev_set_drvdata(dev, NULL); 1000 platform_set_drvdata(dev, NULL);
1001 1001
1002 i2c_del_adapter(&i2c->adap); 1002 i2c_del_adapter(&i2c->adap);
1003 free_irq(IRQ_I2C, i2c); 1003 free_irq(IRQ_I2C, i2c);
@@ -1006,21 +1006,22 @@ static int i2c_pxa_remove(struct device *dev)
1006 return 0; 1006 return 0;
1007} 1007}
1008 1008
1009static struct device_driver i2c_pxa_driver = { 1009static struct platform_driver i2c_pxa_driver = {
1010 .name = "pxa2xx-i2c",
1011 .bus = &platform_bus_type,
1012 .probe = i2c_pxa_probe, 1010 .probe = i2c_pxa_probe,
1013 .remove = i2c_pxa_remove, 1011 .remove = i2c_pxa_remove,
1012 .driver = {
1013 .name = "pxa2xx-i2c",
1014 },
1014}; 1015};
1015 1016
1016static int __init i2c_adap_pxa_init(void) 1017static int __init i2c_adap_pxa_init(void)
1017{ 1018{
1018 return driver_register(&i2c_pxa_driver); 1019 return platform_driver_register(&i2c_pxa_driver);
1019} 1020}
1020 1021
1021static void i2c_adap_pxa_exit(void) 1022static void i2c_adap_pxa_exit(void)
1022{ 1023{
1023 return driver_unregister(&i2c_pxa_driver); 1024 return platform_driver_unregister(&i2c_pxa_driver);
1024} 1025}
1025 1026
1026module_init(i2c_adap_pxa_init); 1027module_init(i2c_adap_pxa_init);
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 1b582262e677..58cfd3111ef6 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -760,24 +760,23 @@ static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c)
760 * called by the bus driver when a suitable device is found 760 * called by the bus driver when a suitable device is found
761*/ 761*/
762 762
763static int s3c24xx_i2c_probe(struct device *dev) 763static int s3c24xx_i2c_probe(struct platform_device *pdev)
764{ 764{
765 struct platform_device *pdev = to_platform_device(dev);
766 struct s3c24xx_i2c *i2c = &s3c24xx_i2c; 765 struct s3c24xx_i2c *i2c = &s3c24xx_i2c;
767 struct resource *res; 766 struct resource *res;
768 int ret; 767 int ret;
769 768
770 /* find the clock and enable it */ 769 /* find the clock and enable it */
771 770
772 i2c->dev = dev; 771 i2c->dev = &pdev->dev;
773 i2c->clk = clk_get(dev, "i2c"); 772 i2c->clk = clk_get(&pdev->dev, "i2c");
774 if (IS_ERR(i2c->clk)) { 773 if (IS_ERR(i2c->clk)) {
775 dev_err(dev, "cannot get clock\n"); 774 dev_err(&pdev->dev, "cannot get clock\n");
776 ret = -ENOENT; 775 ret = -ENOENT;
777 goto out; 776 goto out;
778 } 777 }
779 778
780 dev_dbg(dev, "clock source %p\n", i2c->clk); 779 dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk);
781 780
782 clk_use(i2c->clk); 781 clk_use(i2c->clk);
783 clk_enable(i2c->clk); 782 clk_enable(i2c->clk);
@@ -786,7 +785,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
786 785
787 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 786 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
788 if (res == NULL) { 787 if (res == NULL) {
789 dev_err(dev, "cannot find IO resource\n"); 788 dev_err(&pdev->dev, "cannot find IO resource\n");
790 ret = -ENOENT; 789 ret = -ENOENT;
791 goto out; 790 goto out;
792 } 791 }
@@ -795,7 +794,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
795 pdev->name); 794 pdev->name);
796 795
797 if (i2c->ioarea == NULL) { 796 if (i2c->ioarea == NULL) {
798 dev_err(dev, "cannot request IO\n"); 797 dev_err(&pdev->dev, "cannot request IO\n");
799 ret = -ENXIO; 798 ret = -ENXIO;
800 goto out; 799 goto out;
801 } 800 }
@@ -803,17 +802,17 @@ static int s3c24xx_i2c_probe(struct device *dev)
803 i2c->regs = ioremap(res->start, (res->end-res->start)+1); 802 i2c->regs = ioremap(res->start, (res->end-res->start)+1);
804 803
805 if (i2c->regs == NULL) { 804 if (i2c->regs == NULL) {
806 dev_err(dev, "cannot map IO\n"); 805 dev_err(&pdev->dev, "cannot map IO\n");
807 ret = -ENXIO; 806 ret = -ENXIO;
808 goto out; 807 goto out;
809 } 808 }
810 809
811 dev_dbg(dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res); 810 dev_dbg(&pdev->dev, "registers %p (%p, %p)\n", i2c->regs, i2c->ioarea, res);
812 811
813 /* setup info block for the i2c core */ 812 /* setup info block for the i2c core */
814 813
815 i2c->adap.algo_data = i2c; 814 i2c->adap.algo_data = i2c;
816 i2c->adap.dev.parent = dev; 815 i2c->adap.dev.parent = &pdev->dev;
817 816
818 /* initialise the i2c controller */ 817 /* initialise the i2c controller */
819 818
@@ -827,7 +826,7 @@ static int s3c24xx_i2c_probe(struct device *dev)
827 826
828 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 827 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
829 if (res == NULL) { 828 if (res == NULL) {
830 dev_err(dev, "cannot find IRQ\n"); 829 dev_err(&pdev->dev, "cannot find IRQ\n");
831 ret = -ENOENT; 830 ret = -ENOENT;
832 goto out; 831 goto out;
833 } 832 }
@@ -836,23 +835,23 @@ static int s3c24xx_i2c_probe(struct device *dev)
836 pdev->name, i2c); 835 pdev->name, i2c);
837 836
838 if (ret != 0) { 837 if (ret != 0) {
839 dev_err(dev, "cannot claim IRQ\n"); 838 dev_err(&pdev->dev, "cannot claim IRQ\n");
840 goto out; 839 goto out;
841 } 840 }
842 841
843 i2c->irq = res; 842 i2c->irq = res;
844 843
845 dev_dbg(dev, "irq resource %p (%ld)\n", res, res->start); 844 dev_dbg(&pdev->dev, "irq resource %p (%ld)\n", res, res->start);
846 845
847 ret = i2c_add_adapter(&i2c->adap); 846 ret = i2c_add_adapter(&i2c->adap);
848 if (ret < 0) { 847 if (ret < 0) {
849 dev_err(dev, "failed to add bus to i2c core\n"); 848 dev_err(&pdev->dev, "failed to add bus to i2c core\n");
850 goto out; 849 goto out;
851 } 850 }
852 851
853 dev_set_drvdata(dev, i2c); 852 platform_set_drvdata(pdev, i2c);
854 853
855 dev_info(dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id); 854 dev_info(&pdev->dev, "%s: S3C I2C adapter\n", i2c->adap.dev.bus_id);
856 855
857 out: 856 out:
858 if (ret < 0) 857 if (ret < 0)
@@ -866,22 +865,22 @@ static int s3c24xx_i2c_probe(struct device *dev)
866 * called when device is removed from the bus 865 * called when device is removed from the bus
867*/ 866*/
868 867
869static int s3c24xx_i2c_remove(struct device *dev) 868static int s3c24xx_i2c_remove(struct platform_device *pdev)
870{ 869{
871 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 870 struct s3c24xx_i2c *i2c = platform_get_drvdata(pdev);
872 871
873 if (i2c != NULL) { 872 if (i2c != NULL) {
874 s3c24xx_i2c_free(i2c); 873 s3c24xx_i2c_free(i2c);
875 dev_set_drvdata(dev, NULL); 874 platform_set_drvdata(pdev, NULL);
876 } 875 }
877 876
878 return 0; 877 return 0;
879} 878}
880 879
881#ifdef CONFIG_PM 880#ifdef CONFIG_PM
882static int s3c24xx_i2c_resume(struct device *dev) 881static int s3c24xx_i2c_resume(struct platform_device *dev)
883{ 882{
884 struct s3c24xx_i2c *i2c = dev_get_drvdata(dev); 883 struct s3c24xx_i2c *i2c = platform_get_drvdata(dev);
885 884
886 if (i2c != NULL) 885 if (i2c != NULL)
887 s3c24xx_i2c_init(i2c); 886 s3c24xx_i2c_init(i2c);
@@ -895,33 +894,35 @@ static int s3c24xx_i2c_resume(struct device *dev)
895 894
896/* device driver for platform bus bits */ 895/* device driver for platform bus bits */
897 896
898static struct device_driver s3c2410_i2c_driver = { 897static struct platform_driver s3c2410_i2c_driver = {
899 .owner = THIS_MODULE,
900 .name = "s3c2410-i2c",
901 .bus = &platform_bus_type,
902 .probe = s3c24xx_i2c_probe, 898 .probe = s3c24xx_i2c_probe,
903 .remove = s3c24xx_i2c_remove, 899 .remove = s3c24xx_i2c_remove,
904 .resume = s3c24xx_i2c_resume, 900 .resume = s3c24xx_i2c_resume,
901 .driver = {
902 .owner = THIS_MODULE,
903 .name = "s3c2410-i2c",
904 },
905}; 905};
906 906
907static struct device_driver s3c2440_i2c_driver = { 907static struct platform_driver s3c2440_i2c_driver = {
908 .owner = THIS_MODULE,
909 .name = "s3c2440-i2c",
910 .bus = &platform_bus_type,
911 .probe = s3c24xx_i2c_probe, 908 .probe = s3c24xx_i2c_probe,
912 .remove = s3c24xx_i2c_remove, 909 .remove = s3c24xx_i2c_remove,
913 .resume = s3c24xx_i2c_resume, 910 .resume = s3c24xx_i2c_resume,
911 .driver = {
912 .owner = THIS_MODULE,
913 .name = "s3c2440-i2c",
914 },
914}; 915};
915 916
916static int __init i2c_adap_s3c_init(void) 917static int __init i2c_adap_s3c_init(void)
917{ 918{
918 int ret; 919 int ret;
919 920
920 ret = driver_register(&s3c2410_i2c_driver); 921 ret = platform_driver_register(&s3c2410_i2c_driver);
921 if (ret == 0) { 922 if (ret == 0) {
922 ret = driver_register(&s3c2440_i2c_driver); 923 ret = platform_driver_register(&s3c2440_i2c_driver);
923 if (ret) 924 if (ret)
924 driver_unregister(&s3c2410_i2c_driver); 925 platform_driver_unregister(&s3c2410_i2c_driver);
925 } 926 }
926 927
927 return ret; 928 return ret;
@@ -929,8 +930,8 @@ static int __init i2c_adap_s3c_init(void)
929 930
930static void __exit i2c_adap_s3c_exit(void) 931static void __exit i2c_adap_s3c_exit(void)
931{ 932{
932 driver_unregister(&s3c2410_i2c_driver); 933 platform_driver_unregister(&s3c2410_i2c_driver);
933 driver_unregister(&s3c2440_i2c_driver); 934 platform_driver_unregister(&s3c2440_i2c_driver);
934} 935}
935 936
936module_init(i2c_adap_s3c_init); 937module_init(i2c_adap_s3c_init);
diff --git a/drivers/i2c/busses/i2c-savage4.c b/drivers/i2c/busses/i2c-savage4.c
index aebe87ba4033..0c8518298e4d 100644
--- a/drivers/i2c/busses/i2c-savage4.c
+++ b/drivers/i2c/busses/i2c-savage4.c
@@ -179,7 +179,6 @@ static void __devexit savage4_remove(struct pci_dev *dev)
179} 179}
180 180
181static struct pci_driver savage4_driver = { 181static struct pci_driver savage4_driver = {
182 .owner = THIS_MODULE,
183 .name = "savage4_smbus", 182 .name = "savage4_smbus",
184 .id_table = savage4_ids, 183 .id_table = savage4_ids,
185 .probe = savage4_probe, 184 .probe = savage4_probe,
diff --git a/drivers/i2c/busses/i2c-sis5595.c b/drivers/i2c/busses/i2c-sis5595.c
index 3ad27c3ba15b..b57ab74d23ec 100644
--- a/drivers/i2c/busses/i2c-sis5595.c
+++ b/drivers/i2c/busses/i2c-sis5595.c
@@ -398,7 +398,6 @@ static void __devexit sis5595_remove(struct pci_dev *dev)
398} 398}
399 399
400static struct pci_driver sis5595_driver = { 400static struct pci_driver sis5595_driver = {
401 .owner = THIS_MODULE,
402 .name = "sis5595_smbus", 401 .name = "sis5595_smbus",
403 .id_table = sis5595_ids, 402 .id_table = sis5595_ids,
404 .probe = sis5595_probe, 403 .probe = sis5595_probe,
diff --git a/drivers/i2c/busses/i2c-sis630.c b/drivers/i2c/busses/i2c-sis630.c
index 7f49e5fd3ff0..acb75e282414 100644
--- a/drivers/i2c/busses/i2c-sis630.c
+++ b/drivers/i2c/busses/i2c-sis630.c
@@ -496,7 +496,6 @@ static void __devexit sis630_remove(struct pci_dev *dev)
496 496
497 497
498static struct pci_driver sis630_driver = { 498static struct pci_driver sis630_driver = {
499 .owner = THIS_MODULE,
500 .name = "sis630_smbus", 499 .name = "sis630_smbus",
501 .id_table = sis630_ids, 500 .id_table = sis630_ids,
502 .probe = sis630_probe, 501 .probe = sis630_probe,
diff --git a/drivers/i2c/busses/i2c-sis96x.c b/drivers/i2c/busses/i2c-sis96x.c
index 6a134c091324..3024907cdafe 100644
--- a/drivers/i2c/busses/i2c-sis96x.c
+++ b/drivers/i2c/busses/i2c-sis96x.c
@@ -329,7 +329,6 @@ static void __devexit sis96x_remove(struct pci_dev *dev)
329} 329}
330 330
331static struct pci_driver sis96x_driver = { 331static struct pci_driver sis96x_driver = {
332 .owner = THIS_MODULE,
333 .name = "sis96x_smbus", 332 .name = "sis96x_smbus",
334 .id_table = sis96x_ids, 333 .id_table = sis96x_ids,
335 .probe = sis96x_probe, 334 .probe = sis96x_probe,
diff --git a/drivers/i2c/busses/i2c-via.c b/drivers/i2c/busses/i2c-via.c
index 544a38e64394..484bbacfce6b 100644
--- a/drivers/i2c/busses/i2c-via.c
+++ b/drivers/i2c/busses/i2c-via.c
@@ -159,7 +159,6 @@ static void __devexit vt586b_remove(struct pci_dev *dev)
159 159
160 160
161static struct pci_driver vt586b_driver = { 161static struct pci_driver vt586b_driver = {
162 .owner = THIS_MODULE,
163 .name = "vt586b_smbus", 162 .name = "vt586b_smbus",
164 .id_table = vt586b_ids, 163 .id_table = vt586b_ids,
165 .probe = vt586b_probe, 164 .probe = vt586b_probe,
diff --git a/drivers/i2c/busses/i2c-viapro.c b/drivers/i2c/busses/i2c-viapro.c
index a2237d4b2cf2..47e52bf2c5ec 100644
--- a/drivers/i2c/busses/i2c-viapro.c
+++ b/drivers/i2c/busses/i2c-viapro.c
@@ -440,7 +440,6 @@ static struct pci_device_id vt596_ids[] = {
440MODULE_DEVICE_TABLE(pci, vt596_ids); 440MODULE_DEVICE_TABLE(pci, vt596_ids);
441 441
442static struct pci_driver vt596_driver = { 442static struct pci_driver vt596_driver = {
443 .owner = THIS_MODULE,
444 .name = "vt596_smbus", 443 .name = "vt596_smbus",
445 .id_table = vt596_ids, 444 .id_table = vt596_ids,
446 .probe = vt596_probe, 445 .probe = vt596_probe,
diff --git a/drivers/i2c/busses/i2c-voodoo3.c b/drivers/i2c/busses/i2c-voodoo3.c
index 650c3ebde84c..b675773b0cc1 100644
--- a/drivers/i2c/busses/i2c-voodoo3.c
+++ b/drivers/i2c/busses/i2c-voodoo3.c
@@ -225,7 +225,6 @@ static void __devexit voodoo3_remove(struct pci_dev *dev)
225} 225}
226 226
227static struct pci_driver voodoo3_driver = { 227static struct pci_driver voodoo3_driver = {
228 .owner = THIS_MODULE,
229 .name = "voodoo3_smbus", 228 .name = "voodoo3_smbus",
230 .id_table = voodoo3_ids, 229 .id_table = voodoo3_ids,
231 .probe = voodoo3_probe, 230 .probe = voodoo3_probe,
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index 9dbb72fffbe2..d2a100d77839 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -873,26 +873,27 @@ static int otg_init(struct isp1301 *isp)
873 return 0; 873 return 0;
874} 874}
875 875
876static int otg_probe(struct device *dev) 876static int otg_probe(struct platform_device *dev)
877{ 877{
878 // struct omap_usb_config *config = dev->platform_data; 878 // struct omap_usb_config *config = dev->platform_data;
879 879
880 otg_dev = to_platform_device(dev); 880 otg_dev = dev;
881 return 0; 881 return 0;
882} 882}
883 883
884static int otg_remove(struct device *dev) 884static int otg_remove(struct platform_device *dev)
885{ 885{
886 otg_dev = 0; 886 otg_dev = 0;
887 return 0; 887 return 0;
888} 888}
889 889
890struct device_driver omap_otg_driver = { 890struct platform_driver omap_otg_driver = {
891 .owner = THIS_MODULE,
892 .name = "omap_otg",
893 .bus = &platform_bus_type,
894 .probe = otg_probe, 891 .probe = otg_probe,
895 .remove = otg_remove, 892 .remove = otg_remove,
893 .driver = {
894 .owner = THIS_MODULE,
895 .name = "omap_otg",
896 },
896}; 897};
897 898
898static int otg_bind(struct isp1301 *isp) 899static int otg_bind(struct isp1301 *isp)
@@ -902,7 +903,7 @@ static int otg_bind(struct isp1301 *isp)
902 if (otg_dev) 903 if (otg_dev)
903 return -EBUSY; 904 return -EBUSY;
904 905
905 status = driver_register(&omap_otg_driver); 906 status = platform_driver_register(&omap_otg_driver);
906 if (status < 0) 907 if (status < 0)
907 return status; 908 return status;
908 909
@@ -913,7 +914,7 @@ static int otg_bind(struct isp1301 *isp)
913 status = -ENODEV; 914 status = -ENODEV;
914 915
915 if (status < 0) 916 if (status < 0)
916 driver_unregister(&omap_otg_driver); 917 platform_driver_unregister(&omap_otg_driver);
917 return status; 918 return status;
918} 919}
919 920
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 42e5b8175cbf..1c81174595b3 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -625,7 +625,7 @@ config BLK_DEV_NS87415
625 tristate "NS87415 chipset support" 625 tristate "NS87415 chipset support"
626 help 626 help
627 This driver adds detection and support for the NS87415 chip 627 This driver adds detection and support for the NS87415 chip
628 (used in SPARC64, among others). 628 (used mainly on SPARC64 and PA-RISC machines).
629 629
630 Please read the comments at the top of <file:drivers/ide/pci/ns87415.c>. 630 Please read the comments at the top of <file:drivers/ide/pci/ns87415.c>.
631 631
@@ -787,6 +787,10 @@ config BLK_DEV_IDE_PMAC_BLINK
787 This option enables the use of the sleep LED as a hard drive 787 This option enables the use of the sleep LED as a hard drive
788 activity LED. 788 activity LED.
789 789
790config BLK_DEV_IDE_SWARM
791 tristate "IDE for Sibyte evaluation boards"
792 depends on SIBYTE_SB1xxx_SOC
793
790config BLK_DEV_IDE_AU1XXX 794config BLK_DEV_IDE_AU1XXX
791 bool "IDE for AMD Alchemy Au1200" 795 bool "IDE for AMD Alchemy Au1200"
792 depends on SOC_AU1200 796 depends on SOC_AU1200
@@ -803,14 +807,6 @@ config BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA
803 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX 807 depends on SOC_AU1200 && BLK_DEV_IDE_AU1XXX
804endchoice 808endchoice
805 809
806config BLK_DEV_IDE_AU1XXX_BURSTABLE_ON
807 bool "Enable burstable Mode on DbDMA"
808 default false
809 depends BLK_DEV_IDE_AU1XXX
810 help
811 This option enable the burstable Flag on DbDMA controller
812 (cf. "AMD Alchemy 'Au1200' Processor Data Book - PRELIMINARY").
813
814config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ 810config BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ
815 int "Maximum transfer size (KB) per request (up to 128)" 811 int "Maximum transfer size (KB) per request (up to 128)"
816 default "128" 812 default "128"
@@ -936,7 +932,7 @@ config BLK_DEV_Q40IDE
936 932
937config BLK_DEV_MPC8xx_IDE 933config BLK_DEV_MPC8xx_IDE
938 bool "MPC8xx IDE support" 934 bool "MPC8xx IDE support"
939 depends on 8xx 935 depends on 8xx && IDE=y && BLK_DEV_IDE=y
940 help 936 help
941 This option provides support for IDE on Motorola MPC8xx Systems. 937 This option provides support for IDE on Motorola MPC8xx Systems.
942 Please see 'Type of MPC8xx IDE interface' for details. 938 Please see 'Type of MPC8xx IDE interface' for details.
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index cca9c075966d..569fae717503 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -48,6 +48,6 @@ obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o
48obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o 48obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o
49obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o 49obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o
50 50
51obj-$(CONFIG_BLK_DEV_IDE) += legacy/ arm/ 51obj-$(CONFIG_BLK_DEV_IDE) += legacy/ arm/ mips/
52obj-$(CONFIG_BLK_DEV_HD) += legacy/ 52obj-$(CONFIG_BLK_DEV_HD) += legacy/
53obj-$(CONFIG_ETRAX_IDE) += cris/ 53obj-$(CONFIG_ETRAX_IDE) += cris/
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index c2f47923d174..b4d7a3efb90f 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -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
@@ -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 /*
@@ -3328,8 +3321,8 @@ static ide_proc_entry_t idecd_proc[] = {
3328#endif 3321#endif
3329 3322
3330static ide_driver_t ide_cdrom_driver = { 3323static ide_driver_t ide_cdrom_driver = {
3331 .owner = THIS_MODULE,
3332 .gen_driver = { 3324 .gen_driver = {
3325 .owner = THIS_MODULE,
3333 .name = "ide-cdrom", 3326 .name = "ide-cdrom",
3334 .bus = &ide_bus_type, 3327 .bus = &ide_bus_type,
3335 .probe = ide_cd_probe, 3328 .probe = ide_cd_probe,
@@ -3510,8 +3503,8 @@ static void __exit ide_cdrom_exit(void)
3510{ 3503{
3511 driver_unregister(&ide_cdrom_driver.gen_driver); 3504 driver_unregister(&ide_cdrom_driver.gen_driver);
3512} 3505}
3513 3506
3514static int ide_cdrom_init(void) 3507static int __init ide_cdrom_init(void)
3515{ 3508{
3516 return driver_register(&ide_cdrom_driver.gen_driver); 3509 return driver_register(&ide_cdrom_driver.gen_driver);
3517} 3510}
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 e827b39e4b3c..449522f0540c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1034,12 +1034,12 @@ static int ide_disk_remove(struct device *dev)
1034 struct ide_disk_obj *idkp = drive->driver_data; 1034 struct ide_disk_obj *idkp = drive->driver_data;
1035 struct gendisk *g = idkp->disk; 1035 struct gendisk *g = idkp->disk;
1036 1036
1037 ide_cacheflush_p(drive);
1038
1039 ide_unregister_subdriver(drive, idkp->driver); 1037 ide_unregister_subdriver(drive, idkp->driver);
1040 1038
1041 del_gendisk(g); 1039 del_gendisk(g);
1042 1040
1041 ide_cacheflush_p(drive);
1042
1043 ide_disk_put(idkp); 1043 ide_disk_put(idkp);
1044 1044
1045 return 0; 1045 return 0;
@@ -1089,8 +1089,8 @@ static void ide_device_shutdown(struct device *dev)
1089} 1089}
1090 1090
1091static ide_driver_t idedisk_driver = { 1091static ide_driver_t idedisk_driver = {
1092 .owner = THIS_MODULE,
1093 .gen_driver = { 1092 .gen_driver = {
1093 .owner = THIS_MODULE,
1094 .name = "ide-disk", 1094 .name = "ide-disk",
1095 .bus = &ide_bus_type, 1095 .bus = &ide_bus_type,
1096 .probe = ide_disk_probe, 1096 .probe = ide_disk_probe,
@@ -1266,7 +1266,7 @@ static void __exit idedisk_exit (void)
1266 driver_unregister(&idedisk_driver.gen_driver); 1266 driver_unregister(&idedisk_driver.gen_driver);
1267} 1267}
1268 1268
1269static int idedisk_init (void) 1269static int __init idedisk_init(void)
1270{ 1270{
1271 return driver_register(&idedisk_driver.gen_driver); 1271 return driver_register(&idedisk_driver.gen_driver);
1272} 1272}
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 f615ab759962..9e293c8063dc 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -1925,8 +1925,8 @@ static ide_proc_entry_t idefloppy_proc[] = {
1925static int ide_floppy_probe(struct device *); 1925static int ide_floppy_probe(struct device *);
1926 1926
1927static ide_driver_t idefloppy_driver = { 1927static ide_driver_t idefloppy_driver = {
1928 .owner = THIS_MODULE,
1929 .gen_driver = { 1928 .gen_driver = {
1929 .owner = THIS_MODULE,
1930 .name = "ide-floppy", 1930 .name = "ide-floppy",
1931 .bus = &ide_bus_type, 1931 .bus = &ide_bus_type,
1932 .probe = ide_floppy_probe, 1932 .probe = ide_floppy_probe,
@@ -2191,10 +2191,7 @@ static void __exit idefloppy_exit (void)
2191 driver_unregister(&idefloppy_driver.gen_driver); 2191 driver_unregister(&idefloppy_driver.gen_driver);
2192} 2192}
2193 2193
2194/* 2194static int __init idefloppy_init(void)
2195 * idefloppy_init will register the driver for each floppy.
2196 */
2197static int idefloppy_init (void)
2198{ 2195{
2199 printk("ide-floppy driver " IDEFLOPPY_VERSION "\n"); 2196 printk("ide-floppy driver " IDEFLOPPY_VERSION "\n");
2200 return driver_register(&idefloppy_driver.gen_driver); 2197 return driver_register(&idefloppy_driver.gen_driver);
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index 5275cbb1afe9..ecfafcdafea4 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -1629,12 +1629,6 @@ EXPORT_SYMBOL(ide_init_drive_cmd);
1629 * for the new rq to be completed. This is VERY DANGEROUS, and is 1629 * for the new rq to be completed. This is VERY DANGEROUS, and is
1630 * intended for careful use by the ATAPI tape/cdrom driver code. 1630 * intended for careful use by the ATAPI tape/cdrom driver code.
1631 * 1631 *
1632 * If action is ide_next, then the rq is queued immediately after
1633 * the currently-being-processed-request (if any), and the function
1634 * returns without waiting for the new rq to be completed. As above,
1635 * This is VERY DANGEROUS, and is intended for careful use by the
1636 * ATAPI tape/cdrom driver code.
1637 *
1638 * If action is ide_end, then the rq is queued at the end of the 1632 * If action is ide_end, then the rq is queued at the end of the
1639 * request queue, and the function returns immediately without waiting 1633 * request queue, and the function returns immediately without waiting
1640 * for the new rq to be completed. This is again intended for careful 1634 * for the new rq to be completed. This is again intended for careful
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c
index b09a6537c7a8..41d46dbe6c24 100644
--- a/drivers/ide/ide-lib.c
+++ b/drivers/ide/ide-lib.c
@@ -410,10 +410,10 @@ void ide_toggle_bounce(ide_drive_t *drive, int on)
410{ 410{
411 u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */ 411 u64 addr = BLK_BOUNCE_HIGH; /* dma64_addr_t */
412 412
413 if (on && drive->media == ide_disk) { 413 if (!PCI_DMA_BUS_IS_PHYS) {
414 if (!PCI_DMA_BUS_IS_PHYS) 414 addr = BLK_BOUNCE_ANY;
415 addr = BLK_BOUNCE_ANY; 415 } else if (on && drive->media == ide_disk) {
416 else if (HWIF(drive)->pci_dev) 416 if (HWIF(drive)->pci_dev)
417 addr = HWIF(drive)->pci_dev->dma_mask; 417 addr = HWIF(drive)->pci_dev->dma_mask;
418 } 418 }
419 419
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0ac7eb8f40d5..7d7944ed4158 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -4748,8 +4748,8 @@ static ide_proc_entry_t idetape_proc[] = {
4748static int ide_tape_probe(struct device *); 4748static int ide_tape_probe(struct device *);
4749 4749
4750static ide_driver_t idetape_driver = { 4750static ide_driver_t idetape_driver = {
4751 .owner = THIS_MODULE,
4752 .gen_driver = { 4751 .gen_driver = {
4752 .owner = THIS_MODULE,
4753 .name = "ide-tape", 4753 .name = "ide-tape",
4754 .bus = &ide_bus_type, 4754 .bus = &ide_bus_type,
4755 .probe = ide_tape_probe, 4755 .probe = ide_tape_probe,
@@ -4916,10 +4916,7 @@ static void __exit idetape_exit (void)
4916 unregister_chrdev(IDETAPE_MAJOR, "ht"); 4916 unregister_chrdev(IDETAPE_MAJOR, "ht");
4917} 4917}
4918 4918
4919/* 4919static int __init idetape_init(void)
4920 * idetape_init will register the driver for each tape.
4921 */
4922static int idetape_init (void)
4923{ 4920{
4924 int error = 1; 4921 int error = 1;
4925 idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape"); 4922 idetape_sysfs_class = class_create(THIS_MODULE, "ide_tape");
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 54f9639c2a8c..62ebefd6394a 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -51,8 +51,6 @@
51#include <asm/uaccess.h> 51#include <asm/uaccess.h>
52#include <asm/io.h> 52#include <asm/io.h>
53 53
54#define DEBUG_TASKFILE 0 /* unset when fixed */
55
56static void ata_bswap_data (void *buffer, int wcount) 54static void ata_bswap_data (void *buffer, int wcount)
57{ 55{
58 u16 *p = buffer; 56 u16 *p = buffer;
@@ -765,9 +763,6 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
765 ide_hwif_t *hwif = HWIF(drive); 763 ide_hwif_t *hwif = HWIF(drive);
766 task_struct_t *taskfile = (task_struct_t *) task->tfRegister; 764 task_struct_t *taskfile = (task_struct_t *) task->tfRegister;
767 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister; 765 hob_struct_t *hobfile = (hob_struct_t *) task->hobRegister;
768#if DEBUG_TASKFILE
769 u8 status;
770#endif
771 766
772 if (task->data_phase == TASKFILE_MULTI_IN || 767 if (task->data_phase == TASKFILE_MULTI_IN ||
773 task->data_phase == TASKFILE_MULTI_OUT) { 768 task->data_phase == TASKFILE_MULTI_OUT) {
@@ -778,19 +773,13 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
778 } 773 }
779 774
780 /* 775 /*
781 * (ks) Check taskfile in/out flags. 776 * (ks) Check taskfile in flags.
782 * If set, then execute as it is defined. 777 * If set, then execute as it is defined.
783 * If not set, then define default settings. 778 * If not set, then define default settings.
784 * The default values are: 779 * The default values are:
785 * write and read all taskfile registers (except data) 780 * read all taskfile registers (except data)
786 * write and read the hob registers (sector,nsector,lcyl,hcyl) 781 * read the hob registers (sector, nsector, lcyl, hcyl)
787 */ 782 */
788 if (task->tf_out_flags.all == 0) {
789 task->tf_out_flags.all = IDE_TASKFILE_STD_OUT_FLAGS;
790 if (drive->addressing == 1)
791 task->tf_out_flags.all |= (IDE_HOB_STD_OUT_FLAGS << 8);
792 }
793
794 if (task->tf_in_flags.all == 0) { 783 if (task->tf_in_flags.all == 0) {
795 task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS; 784 task->tf_in_flags.all = IDE_TASKFILE_STD_IN_FLAGS;
796 if (drive->addressing == 1) 785 if (drive->addressing == 1)
@@ -803,16 +792,6 @@ ide_startstop_t flagged_taskfile (ide_drive_t *drive, ide_task_t *task)
803 hwif->OUTB(drive->ctl, IDE_CONTROL_REG); 792 hwif->OUTB(drive->ctl, IDE_CONTROL_REG);
804 SELECT_MASK(drive, 0); 793 SELECT_MASK(drive, 0);
805 794
806#if DEBUG_TASKFILE
807 status = hwif->INB(IDE_STATUS_REG);
808 if (status & 0x80) {
809 printk("flagged_taskfile -> Bad status. Status = %02x. wait 100 usec ...\n", status);
810 udelay(100);
811 status = hwif->INB(IDE_STATUS_REG);
812 printk("flagged_taskfile -> Status = %02x\n", status);
813 }
814#endif
815
816 if (task->tf_out_flags.b.data) { 795 if (task->tf_out_flags.b.data) {
817 u16 data = taskfile->data + (hobfile->data << 8); 796 u16 data = taskfile->data + (hobfile->data << 8);
818 hwif->OUTW(data, IDE_DATA_REG); 797 hwif->OUTW(data, IDE_DATA_REG);
diff --git a/drivers/ide/mips/Makefile b/drivers/ide/mips/Makefile
new file mode 100644
index 000000000000..677c7b2bac92
--- /dev/null
+++ b/drivers/ide/mips/Makefile
@@ -0,0 +1,4 @@
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/mips/swarm.c b/drivers/ide/mips/swarm.c
new file mode 100644
index 000000000000..66f6064f4640
--- /dev/null
+++ b/drivers/ide/mips/swarm.c
@@ -0,0 +1,201 @@
1/*
2 * Copyright (C) 2001, 2002, 2003 Broadcom Corporation
3 * Copyright (C) 2004 MontaVista Software Inc.
4 * Author: Manish Lachwani, mlachwani@mvista.com
5 * Copyright (C) 2004 MIPS Technologies, Inc. All rights reserved.
6 * Author: Maciej W. Rozycki <macro@mips.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 */
22
23/*
24 * Derived loosely from ide-pmac.c, so:
25 * Copyright (C) 1998 Paul Mackerras.
26 * Copyright (C) 1995-1998 Mark Lord
27 */
28
29/*
30 * Boards with SiByte processors so far have supported IDE devices via
31 * the Generic Bus, PCI bus, and built-in PCMCIA interface. In all
32 * cases, byte-swapping must be avoided for these devices (whereas
33 * other PCI devices, for example, will require swapping). Any
34 * SiByte-targetted kernel including IDE support will include this
35 * file. Probing of a Generic Bus for an IDE device is controlled by
36 * the definition of "SIBYTE_HAVE_IDE", which is provided by
37 * <asm/sibyte/board.h> for Broadcom boards.
38 */
39
40#include <linux/ide.h>
41#include <linux/ioport.h>
42#include <linux/kernel.h>
43#include <linux/types.h>
44#include <linux/platform_device.h>
45
46#include <asm/io.h>
47
48#include <asm/sibyte/board.h>
49#include <asm/sibyte/sb1250_genbus.h>
50#include <asm/sibyte/sb1250_regs.h>
51
52#define DRV_NAME "ide-swarm"
53
54static char swarm_ide_string[] = DRV_NAME;
55
56static struct resource swarm_ide_resource = {
57 .name = "SWARM GenBus IDE",
58 .flags = IORESOURCE_MEM,
59};
60
61static struct platform_device *swarm_ide_dev;
62
63/*
64 * swarm_ide_probe - if the board header indicates the existence of
65 * Generic Bus IDE, allocate a HWIF for it.
66 */
67static int __devinit swarm_ide_probe(struct device *dev)
68{
69 ide_hwif_t *hwif;
70 u8 __iomem *base;
71 phys_t offset, size;
72 int i;
73
74 if (!SIBYTE_HAVE_IDE)
75 return -ENODEV;
76
77 /* Find an empty slot. */
78 for (i = 0; i < MAX_HWIFS; i++)
79 if (!ide_hwifs[i].io_ports[IDE_DATA_OFFSET])
80 break;
81 if (i >= MAX_HWIFS) {
82 printk(KERN_ERR DRV_NAME ": no free slot for interface\n");
83 return -ENOMEM;
84 }
85
86 hwif = ide_hwifs + i;
87
88 base = ioremap(A_IO_EXT_BASE, 0x800);
89 offset = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_START_ADDR, IDE_CS));
90 size = __raw_readq(base + R_IO_EXT_REG(R_IO_EXT_MULT_SIZE, IDE_CS));
91 iounmap(base);
92
93 offset = G_IO_START_ADDR(offset) << S_IO_ADDRBASE;
94 size = (G_IO_MULT_SIZE(size) + 1) << S_IO_REGSIZE;
95 if (offset < A_PHYS_GENBUS || offset >= A_PHYS_GENBUS_END) {
96 printk(KERN_INFO DRV_NAME
97 ": IDE interface at GenBus disabled\n");
98 return -EBUSY;
99 }
100
101 printk(KERN_INFO DRV_NAME ": IDE interface at GenBus slot %i\n",
102 IDE_CS);
103
104 swarm_ide_resource.start = offset;
105 swarm_ide_resource.end = offset + size - 1;
106 if (request_resource(&iomem_resource, &swarm_ide_resource)) {
107 printk(KERN_ERR DRV_NAME
108 ": can't request I/O memory resource\n");
109 return -EBUSY;
110 }
111
112 base = ioremap(offset, size);
113
114 /* Setup MMIO ops. */
115 default_hwif_mmiops(hwif);
116 /* Prevent resource map manipulation. */
117 hwif->mmio = 2;
118 hwif->noprobe = 0;
119
120 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++)
121 hwif->hw.io_ports[i] =
122 (unsigned long)(base + ((0x1f0 + i) << 5));
123 hwif->hw.io_ports[IDE_CONTROL_OFFSET] =
124 (unsigned long)(base + (0x3f6 << 5));
125 hwif->hw.irq = K_INT_GB_IDE;
126
127 memcpy(hwif->io_ports, hwif->hw.io_ports, sizeof(hwif->io_ports));
128 hwif->irq = hwif->hw.irq;
129
130 dev_set_drvdata(dev, hwif);
131
132 return 0;
133}
134
135static struct device_driver swarm_ide_driver = {
136 .name = swarm_ide_string,
137 .bus = &platform_bus_type,
138 .probe = swarm_ide_probe,
139};
140
141static void swarm_ide_platform_release(struct device *device)
142{
143 struct platform_device *pldev;
144
145 /* free device */
146 pldev = to_platform_device(device);
147 kfree(pldev);
148}
149
150static int __devinit swarm_ide_init_module(void)
151{
152 struct platform_device *pldev;
153 int err;
154
155 printk(KERN_INFO "SWARM IDE driver\n");
156
157 if (driver_register(&swarm_ide_driver)) {
158 printk(KERN_ERR "Driver registration failed\n");
159 err = -ENODEV;
160 goto out;
161 }
162
163 if (!(pldev = kmalloc(sizeof (*pldev), GFP_KERNEL))) {
164 err = -ENOMEM;
165 goto out_unregister_driver;
166 }
167
168 memset (pldev, 0, sizeof (*pldev));
169 pldev->name = swarm_ide_string;
170 pldev->id = 0;
171 pldev->dev.release = swarm_ide_platform_release;
172
173 if (platform_device_register(pldev)) {
174 err = -ENODEV;
175 goto out_free_pldev;
176 }
177
178 if (!pldev->dev.driver) {
179 /*
180 * The driver was not bound to this device, there was
181 * no hardware at this address. Unregister it, as the
182 * release fuction will take care of freeing the
183 * allocated structure
184 */
185 platform_device_unregister (pldev);
186 }
187
188 swarm_ide_dev = pldev;
189
190 return 0;
191
192out_free_pldev:
193 kfree(pldev);
194
195out_unregister_driver:
196 driver_unregister(&swarm_ide_driver);
197out:
198 return err;
199}
200
201module_init(swarm_ide_init_module);
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index 52cadc005d72..a21b1e11eef4 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -65,23 +65,6 @@ static struct chipset_bus_clock_list_entry aec6xxx_34_base [] = {
65#define BUSCLOCK(D) \ 65#define BUSCLOCK(D) \
66 ((struct chipset_bus_clock_list_entry *) pci_get_drvdata((D))) 66 ((struct chipset_bus_clock_list_entry *) pci_get_drvdata((D)))
67 67
68#if 0
69 if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) {
70 (void) pci_read_config_byte(dev, 0x54, &art);
71 p += sprintf(p, "DMA Mode: %s(%s)",
72 (c0&0x20)?((art&0x03)?"UDMA":" DMA"):" PIO",
73 (art&0x02)?"2":(art&0x01)?"1":"0");
74 p += sprintf(p, " %s(%s)",
75 (c0&0x40)?((art&0x0c)?"UDMA":" DMA"):" PIO",
76 (art&0x08)?"2":(art&0x04)?"1":"0");
77 p += sprintf(p, " %s(%s)",
78 (c1&0x20)?((art&0x30)?"UDMA":" DMA"):" PIO",
79 (art&0x20)?"2":(art&0x10)?"1":"0");
80 p += sprintf(p, " %s(%s)\n",
81 (c1&0x40)?((art&0xc0)?"UDMA":" DMA"):" PIO",
82 (art&0x80)?"2":(art&0x40)?"1":"0");
83 } else {
84#endif
85 68
86/* 69/*
87 * TO DO: active tuning and correction of cards without a bios. 70 * TO DO: active tuning and correction of cards without a bios.
@@ -112,13 +95,9 @@ static u8 aec62xx_ratemask (ide_drive_t *drive)
112 switch(hwif->pci_dev->device) { 95 switch(hwif->pci_dev->device) {
113 case PCI_DEVICE_ID_ARTOP_ATP865: 96 case PCI_DEVICE_ID_ARTOP_ATP865:
114 case PCI_DEVICE_ID_ARTOP_ATP865R: 97 case PCI_DEVICE_ID_ARTOP_ATP865R:
115#if 0
116 mode = (hwif->INB(hwif->dma_master) & 0x10) ? 4 : 3;
117#else
118 mode = (hwif->INB(((hwif->channel) ? 98 mode = (hwif->INB(((hwif->channel) ?
119 hwif->mate->dma_status : 99 hwif->mate->dma_status :
120 hwif->dma_status)) & 0x10) ? 4 : 3; 100 hwif->dma_status)) & 0x10) ? 4 : 3;
121#endif
122 break; 101 break;
123 case PCI_DEVICE_ID_ARTOP_ATP860: 102 case PCI_DEVICE_ID_ARTOP_ATP860:
124 case PCI_DEVICE_ID_ARTOP_ATP860R: 103 case PCI_DEVICE_ID_ARTOP_ATP860R:
@@ -263,35 +242,9 @@ static int aec62xx_irq_timeout (ide_drive_t *drive)
263 case PCI_DEVICE_ID_ARTOP_ATP865: 242 case PCI_DEVICE_ID_ARTOP_ATP865:
264 case PCI_DEVICE_ID_ARTOP_ATP865R: 243 case PCI_DEVICE_ID_ARTOP_ATP865R:
265 printk(" AEC62XX time out "); 244 printk(" AEC62XX time out ");
266#if 0
267 {
268 int i = 0;
269 u8 reg49h = 0;
270 pci_read_config_byte(HWIF(drive)->pci_dev, 0x49, &reg49h);
271 for (i=0;i<256;i++)
272 pci_write_config_byte(HWIF(drive)->pci_dev, 0x49, reg49h|0x10);
273 pci_write_config_byte(HWIF(drive)->pci_dev, 0x49, reg49h & ~0x10);
274 }
275 return 0;
276#endif
277 default: 245 default:
278 break; 246 break;
279 } 247 }
280#if 0
281 {
282 ide_hwif_t *hwif = HWIF(drive);
283 struct pci_dev *dev = hwif->pci_dev;
284 u8 tmp1 = 0, tmp2 = 0, mode6 = 0;
285
286 pci_read_config_byte(dev, 0x44, &tmp1);
287 pci_read_config_byte(dev, 0x45, &tmp2);
288 printk(" AEC6280 r44=%x r45=%x ",tmp1,tmp2);
289 mode6 = HWIF(drive)->INB(((hwif->channel) ?
290 hwif->mate->dma_status :
291 hwif->dma_status));
292 printk(" AEC6280 133=%x ", (mode6 & 0x10));
293 }
294#endif
295 return 0; 248 return 0;
296} 249}
297 250
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 6cf49394a80f..cf84350efc55 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -876,10 +876,15 @@ static ide_pci_device_t ali15x3_chipset __devinitdata = {
876 876
877static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) 877static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id)
878{ 878{
879 static struct pci_device_id ati_rs100[] = {
880 { PCI_DEVICE(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100) },
881 { },
882 };
883
879 ide_pci_device_t *d = &ali15x3_chipset; 884 ide_pci_device_t *d = &ali15x3_chipset;
880 885
881 if(pci_find_device(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100, NULL)) 886 if (pci_dev_present(ati_rs100))
882 printk(KERN_ERR "Warning: ATI Radeon IGP Northbridge is not yet fully tested.\n"); 887 printk(KERN_WARNING "alim15x3: ATI Radeon IGP Northbridge is not yet fully tested.\n");
883 888
884#if defined(CONFIG_SPARC64) 889#if defined(CONFIG_SPARC64)
885 d->init_hwif = init_hwif_common_ali15x3; 890 d->init_hwif = init_hwif_common_ali15x3;
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index 7dc24682d197..ea3c52cc8ac1 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -222,10 +222,9 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
222 222
223 /* We must not grab the entire device, it has 'ISA' space in its 223 /* We must not grab the entire device, it has 'ISA' space in its
224 BARS too and we will freak out other bits of the kernel */ 224 BARS too and we will freak out other bits of the kernel */
225 if(pci_enable_device_bars(dev, 1<<2)) 225 if (pci_enable_device_bars(dev, 1<<2)) {
226 {
227 printk(KERN_WARNING "%s: Unable to enable 55x0.\n", d->name); 226 printk(KERN_WARNING "%s: Unable to enable 55x0.\n", d->name);
228 return 1; 227 return -ENODEV;
229 } 228 }
230 pci_set_master(dev); 229 pci_set_master(dev);
231 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { 230 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
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/siimage.c b/drivers/ide/pci/siimage.c
index 022d244f2eb0..f1ca154dd52c 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -6,7 +6,13 @@
6 * 6 *
7 * May be copied or modified under the terms of the GNU General Public License 7 * May be copied or modified under the terms of the GNU General Public License
8 * 8 *
9 * Documentation available under NDA only 9 * Documentation for CMD680:
10 * http://gkernel.sourceforge.net/specs/sii/sii-0680a-v1.31.pdf.bz2
11 *
12 * Documentation for SiI 3112:
13 * http://gkernel.sourceforge.net/specs/sii/3112A_SiI-DS-0095-B2.pdf.bz2
14 *
15 * Errata and other documentation only available under NDA.
10 * 16 *
11 * 17 *
12 * FAQ Items: 18 * FAQ Items:
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 16b3e2d8bfb1..75a2253a3e68 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -87,6 +87,7 @@ static const struct {
87 u8 chipset_family; 87 u8 chipset_family;
88 u8 flags; 88 u8 flags;
89} SiSHostChipInfo[] = { 89} SiSHostChipInfo[] = {
90 { "SiS965", PCI_DEVICE_ID_SI_965, ATA_133 },
90 { "SiS745", PCI_DEVICE_ID_SI_745, ATA_100 }, 91 { "SiS745", PCI_DEVICE_ID_SI_745, ATA_100 },
91 { "SiS735", PCI_DEVICE_ID_SI_735, ATA_100 }, 92 { "SiS735", PCI_DEVICE_ID_SI_735, ATA_100 },
92 { "SiS733", PCI_DEVICE_ID_SI_733, ATA_100 }, 93 { "SiS733", PCI_DEVICE_ID_SI_733, ATA_100 },
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index ea0806c82be0..8a5c7b286b2b 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -399,34 +399,6 @@ static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const c
399 return dev->irq; 399 return dev->irq;
400} 400}
401 401
402static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base)
403{
404 unsigned int rev;
405 u8 dma_state;
406
407 DBG(("init_dma_sl82c105(hwif: ide%d, dma_base: 0x%08x)\n", hwif->index, dma_base));
408
409 hwif->autodma = 0;
410
411 if (!dma_base)
412 return;
413
414 dma_state = hwif->INB(dma_base + 2);
415 rev = sl82c105_bridge_revision(hwif->pci_dev);
416 if (rev <= 5) {
417 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
418 hwif->name, rev);
419 dma_state &= ~0x60;
420 } else {
421 dma_state |= 0x60;
422 if (!noautodma)
423 hwif->autodma = 1;
424 }
425 hwif->OUTB(dma_state, dma_base + 2);
426
427 ide_setup_dma(hwif, dma_base, 8);
428}
429
430/* 402/*
431 * Initialise the chip 403 * Initialise the chip
432 */ 404 */
@@ -434,6 +406,8 @@ static void __devinit init_dma_sl82c105(ide_hwif_t *hwif, unsigned long dma_base
434static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) 406static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
435{ 407{
436 struct pci_dev *dev = hwif->pci_dev; 408 struct pci_dev *dev = hwif->pci_dev;
409 unsigned int rev;
410 u8 dma_state;
437 u32 val; 411 u32 val;
438 412
439 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); 413 DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index));
@@ -455,33 +429,54 @@ static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif)
455 pci_read_config_dword(dev, 0x40, &val); 429 pci_read_config_dword(dev, 0x40, &val);
456 *((u32 *)&hwif->hwif_data) = val; 430 *((u32 *)&hwif->hwif_data) = val;
457 431
432 hwif->atapi_dma = 0;
433 hwif->mwdma_mask = 0;
434 hwif->swdma_mask = 0;
435 hwif->autodma = 0;
436
458 if (!hwif->dma_base) 437 if (!hwif->dma_base)
459 return; 438 return;
460 439
461 hwif->atapi_dma = 1; 440 dma_state = hwif->INB(hwif->dma_base + 2) & ~0x60;
462 hwif->mwdma_mask = 0x07; 441 rev = sl82c105_bridge_revision(hwif->pci_dev);
463 hwif->swdma_mask = 0x07; 442 if (rev <= 5) {
464 443 /*
444 * Never ever EVER under any circumstances enable
445 * DMA when the bridge is this old.
446 */
447 printk(" %s: Winbond 553 bridge revision %d, BM-DMA disabled\n",
448 hwif->name, rev);
449 } else {
465#ifdef CONFIG_BLK_DEV_IDEDMA 450#ifdef CONFIG_BLK_DEV_IDEDMA
466 hwif->ide_dma_check = &sl82c105_check_drive; 451 dma_state |= 0x60;
467 hwif->ide_dma_on = &sl82c105_ide_dma_on; 452
468 hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly; 453 hwif->atapi_dma = 1;
469 hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq; 454 hwif->mwdma_mask = 0x07;
470 hwif->dma_start = &sl82c105_ide_dma_start; 455 hwif->swdma_mask = 0x07;
471 hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout; 456
472 457 hwif->ide_dma_check = &sl82c105_check_drive;
473 if (!noautodma) 458 hwif->ide_dma_on = &sl82c105_ide_dma_on;
474 hwif->autodma = 1; 459 hwif->ide_dma_off_quietly = &sl82c105_ide_dma_off_quietly;
475 hwif->drives[0].autodma = hwif->autodma; 460 hwif->ide_dma_lostirq = &sl82c105_ide_dma_lost_irq;
476 hwif->drives[1].autodma = hwif->autodma; 461 hwif->dma_start = &sl82c105_ide_dma_start;
462 hwif->ide_dma_timeout = &sl82c105_ide_dma_timeout;
463
464 if (!noautodma)
465 hwif->autodma = 1;
466 hwif->drives[0].autodma = hwif->autodma;
467 hwif->drives[1].autodma = hwif->autodma;
468
469 if (hwif->mate)
470 hwif->serialized = hwif->mate->serialized = 1;
477#endif /* CONFIG_BLK_DEV_IDEDMA */ 471#endif /* CONFIG_BLK_DEV_IDEDMA */
472 }
473 hwif->OUTB(dma_state, hwif->dma_base + 2);
478} 474}
479 475
480static ide_pci_device_t sl82c105_chipset __devinitdata = { 476static ide_pci_device_t sl82c105_chipset __devinitdata = {
481 .name = "W82C105", 477 .name = "W82C105",
482 .init_chipset = init_chipset_sl82c105, 478 .init_chipset = init_chipset_sl82c105,
483 .init_hwif = init_hwif_sl82c105, 479 .init_hwif = init_hwif_sl82c105,
484 .init_dma = init_dma_sl82c105,
485 .channels = 2, 480 .channels = 2,
486 .autodma = NOAUTODMA, 481 .autodma = NOAUTODMA,
487 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, 482 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index a4d099c937ff..86fb1e0286d3 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -79,6 +79,8 @@ static struct via_isa_bridge {
79 u8 rev_max; 79 u8 rev_max;
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 },
83 { "vt8251", PCI_DEVICE_ID_VIA_8251, 0x00, 0x2f, VIA_UDMA_133 | VIA_BAD_AST },
82 { "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 },
83 { "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 },
84 { "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 },
@@ -100,185 +102,14 @@ static struct via_isa_bridge {
100 { NULL } 102 { NULL }
101}; 103};
102 104
103static struct via_isa_bridge *via_config;
104static unsigned int via_80w;
105static unsigned int via_clock; 105static unsigned int via_clock;
106static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" }; 106static char *via_dma[] = { "MWDMA16", "UDMA33", "UDMA66", "UDMA100", "UDMA133" };
107 107
108/* 108struct via82cxxx_dev
109 * VIA /proc entry.
110 */
111
112#if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS)
113
114#include <linux/stat.h>
115#include <linux/proc_fs.h>
116
117static u8 via_proc = 0;
118static unsigned long via_base;
119static struct pci_dev *bmide_dev, *isa_dev;
120
121static char *via_control3[] = { "No limit", "64", "128", "192" };
122
123#define via_print(format, arg...) p += sprintf(p, format "\n" , ## arg)
124#define via_print_drive(name, format, arg...)\
125 p += sprintf(p, name); for (i = 0; i < 4; i++) p += sprintf(p, format, ## arg); p += sprintf(p, "\n");
126
127
128/**
129 * via_get_info - generate via /proc file
130 * @buffer: buffer for data
131 * @addr: set to start of data to use
132 * @offset: current file offset
133 * @count: size of read
134 *
135 * Fills in buffer with the debugging/configuration information for
136 * the VIA chipset tuning and attached drives
137 */
138
139static int via_get_info(char *buffer, char **addr, off_t offset, int count)
140{ 109{
141 int speed[4], cycle[4], setup[4], active[4], recover[4], den[4], 110 struct via_isa_bridge *via_config;
142 uen[4], udma[4], umul[4], active8b[4], recover8b[4]; 111 unsigned int via_80w;
143 struct pci_dev *dev = bmide_dev; 112};
144 unsigned int v, u, i;
145 int len;
146 u16 c, w;
147 u8 t, x;
148 char *p = buffer;
149
150 via_print("----------VIA BusMastering IDE Configuration"
151 "----------------");
152
153 via_print("Driver Version: 3.38");
154 via_print("South Bridge: VIA %s",
155 via_config->name);
156
157 pci_read_config_byte(isa_dev, PCI_REVISION_ID, &t);
158 pci_read_config_byte(dev, PCI_REVISION_ID, &x);
159 via_print("Revision: ISA %#x IDE %#x", t, x);
160 via_print("Highest DMA rate: %s",
161 via_dma[via_config->flags & VIA_UDMA]);
162
163 via_print("BM-DMA base: %#lx", via_base);
164 via_print("PCI clock: %d.%dMHz",
165 via_clock / 1000, via_clock / 100 % 10);
166
167 pci_read_config_byte(dev, VIA_MISC_1, &t);
168 via_print("Master Read Cycle IRDY: %dws",
169 (t & 64) >> 6);
170 via_print("Master Write Cycle IRDY: %dws",
171 (t & 32) >> 5);
172 via_print("BM IDE Status Register Read Retry: %s",
173 (t & 8) ? "yes" : "no");
174
175 pci_read_config_byte(dev, VIA_MISC_3, &t);
176 via_print("Max DRDY Pulse Width: %s%s",
177 via_control3[(t & 0x03)], (t & 0x03) ? " PCI clocks" : "");
178
179 via_print("-----------------------Primary IDE"
180 "-------Secondary IDE------");
181 via_print("Read DMA FIFO flush: %10s%20s",
182 (t & 0x80) ? "yes" : "no", (t & 0x40) ? "yes" : "no");
183 via_print("End Sector FIFO flush: %10s%20s",
184 (t & 0x20) ? "yes" : "no", (t & 0x10) ? "yes" : "no");
185
186 pci_read_config_byte(dev, VIA_IDE_CONFIG, &t);
187 via_print("Prefetch Buffer: %10s%20s",
188 (t & 0x80) ? "yes" : "no", (t & 0x20) ? "yes" : "no");
189 via_print("Post Write Buffer: %10s%20s",
190 (t & 0x40) ? "yes" : "no", (t & 0x10) ? "yes" : "no");
191
192 pci_read_config_byte(dev, VIA_IDE_ENABLE, &t);
193 via_print("Enabled: %10s%20s",
194 (t & 0x02) ? "yes" : "no", (t & 0x01) ? "yes" : "no");
195
196 c = inb(via_base + 0x02) | (inb(via_base + 0x0a) << 8);
197 via_print("Simplex only: %10s%20s",
198 (c & 0x80) ? "yes" : "no", (c & 0x8000) ? "yes" : "no");
199
200 via_print("Cable Type: %10s%20s",
201 (via_80w & 1) ? "80w" : "40w", (via_80w & 2) ? "80w" : "40w");
202
203 via_print("-------------------drive0----drive1"
204 "----drive2----drive3-----");
205
206 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t);
207 pci_read_config_dword(dev, VIA_DRIVE_TIMING, &v);
208 pci_read_config_word(dev, VIA_8BIT_TIMING, &w);
209
210 if (via_config->flags & VIA_UDMA)
211 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
212 else u = 0;
213
214 for (i = 0; i < 4; i++) {
215
216 setup[i] = ((t >> ((3 - i) << 1)) & 0x3) + 1;
217 recover8b[i] = ((w >> ((1 - (i >> 1)) << 3)) & 0xf) + 1;
218 active8b[i] = ((w >> (((1 - (i >> 1)) << 3) + 4)) & 0xf) + 1;
219 active[i] = ((v >> (((3 - i) << 3) + 4)) & 0xf) + 1;
220 recover[i] = ((v >> ((3 - i) << 3)) & 0xf) + 1;
221 udma[i] = ((u >> ((3 - i) << 3)) & 0x7) + 2;
222 umul[i] = ((u >> (((3 - i) & 2) << 3)) & 0x8) ? 1 : 2;
223 uen[i] = ((u >> ((3 - i) << 3)) & 0x20);
224 den[i] = (c & ((i & 1) ? 0x40 : 0x20) << ((i & 2) << 2));
225
226 speed[i] = 2 * via_clock / (active[i] + recover[i]);
227 cycle[i] = 1000000 * (active[i] + recover[i]) / via_clock;
228
229 if (!uen[i] || !den[i])
230 continue;
231
232 switch (via_config->flags & VIA_UDMA) {
233
234 case VIA_UDMA_33:
235 speed[i] = 2 * via_clock / udma[i];
236 cycle[i] = 1000000 * udma[i] / via_clock;
237 break;
238
239 case VIA_UDMA_66:
240 speed[i] = 4 * via_clock / (udma[i] * umul[i]);
241 cycle[i] = 500000 * (udma[i] * umul[i]) / via_clock;
242 break;
243
244 case VIA_UDMA_100:
245 speed[i] = 6 * via_clock / udma[i];
246 cycle[i] = 333333 * udma[i] / via_clock;
247 break;
248
249 case VIA_UDMA_133:
250 speed[i] = 8 * via_clock / udma[i];
251 cycle[i] = 250000 * udma[i] / via_clock;
252 break;
253 }
254 }
255
256 via_print_drive("Transfer Mode: ", "%10s",
257 den[i] ? (uen[i] ? "UDMA" : "DMA") : "PIO");
258
259 via_print_drive("Address Setup: ", "%8dns",
260 1000000 * setup[i] / via_clock);
261 via_print_drive("Cmd Active: ", "%8dns",
262 1000000 * active8b[i] / via_clock);
263 via_print_drive("Cmd Recovery: ", "%8dns",
264 1000000 * recover8b[i] / via_clock);
265 via_print_drive("Data Active: ", "%8dns",
266 1000000 * active[i] / via_clock);
267 via_print_drive("Data Recovery: ", "%8dns",
268 1000000 * recover[i] / via_clock);
269 via_print_drive("Cycle Time: ", "%8dns",
270 cycle[i]);
271 via_print_drive("Transfer Rate: ", "%4d.%dMB/s",
272 speed[i] / 1000, speed[i] / 100 % 10);
273
274 /* hoping it is less than 4K... */
275 len = (p - buffer) - offset;
276 *addr = buffer + offset;
277
278 return len > count ? count : len;
279}
280
281#endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */
282 113
283/** 114/**
284 * via_set_speed - write timing registers 115 * via_set_speed - write timing registers
@@ -289,11 +120,13 @@ static int via_get_info(char *buffer, char **addr, off_t offset, int count)
289 * via_set_speed writes timing values to the chipset registers 120 * via_set_speed writes timing values to the chipset registers
290 */ 121 */
291 122
292static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing) 123static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing)
293{ 124{
125 struct pci_dev *dev = hwif->pci_dev;
126 struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif);
294 u8 t; 127 u8 t;
295 128
296 if (~via_config->flags & VIA_BAD_AST) { 129 if (~vdev->via_config->flags & VIA_BAD_AST) {
297 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t); 130 pci_read_config_byte(dev, VIA_ADDRESS_SETUP, &t);
298 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1)); 131 t = (t & ~(3 << ((3 - dn) << 1))) | ((FIT(timing->setup, 1, 4) - 1) << ((3 - dn) << 1));
299 pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t); 132 pci_write_config_byte(dev, VIA_ADDRESS_SETUP, t);
@@ -305,7 +138,7 @@ static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing)
305 pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn), 138 pci_write_config_byte(dev, VIA_DRIVE_TIMING + (3 - dn),
306 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1)); 139 ((FIT(timing->active, 1, 16) - 1) << 4) | (FIT(timing->recover, 1, 16) - 1));
307 140
308 switch (via_config->flags & VIA_UDMA) { 141 switch (vdev->via_config->flags & VIA_UDMA) {
309 case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break; 142 case VIA_UDMA_33: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 5) - 2)) : 0x03; break;
310 case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break; 143 case VIA_UDMA_66: t = timing->udma ? (0xe8 | (FIT(timing->udma, 2, 9) - 2)) : 0x0f; break;
311 case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break; 144 case VIA_UDMA_100: t = timing->udma ? (0xe0 | (FIT(timing->udma, 2, 9) - 2)) : 0x07; break;
@@ -329,6 +162,7 @@ static void via_set_speed(struct pci_dev *dev, u8 dn, struct ide_timing *timing)
329static int via_set_drive(ide_drive_t *drive, u8 speed) 162static int via_set_drive(ide_drive_t *drive, u8 speed)
330{ 163{
331 ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1); 164 ide_drive_t *peer = HWIF(drive)->drives + (~drive->dn & 1);
165 struct via82cxxx_dev *vdev = ide_get_hwifdata(drive->hwif);
332 struct ide_timing t, p; 166 struct ide_timing t, p;
333 unsigned int T, UT; 167 unsigned int T, UT;
334 168
@@ -337,7 +171,7 @@ static int via_set_drive(ide_drive_t *drive, u8 speed)
337 171
338 T = 1000000000 / via_clock; 172 T = 1000000000 / via_clock;
339 173
340 switch (via_config->flags & VIA_UDMA) { 174 switch (vdev->via_config->flags & VIA_UDMA) {
341 case VIA_UDMA_33: UT = T; break; 175 case VIA_UDMA_33: UT = T; break;
342 case VIA_UDMA_66: UT = T/2; break; 176 case VIA_UDMA_66: UT = T/2; break;
343 case VIA_UDMA_100: UT = T/3; break; 177 case VIA_UDMA_100: UT = T/3; break;
@@ -352,7 +186,7 @@ static int via_set_drive(ide_drive_t *drive, u8 speed)
352 ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); 186 ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT);
353 } 187 }
354 188
355 via_set_speed(HWIF(drive)->pci_dev, drive->dn, &t); 189 via_set_speed(HWIF(drive), drive->dn, &t);
356 190
357 if (!drive->init_speed) 191 if (!drive->init_speed)
358 drive->init_speed = speed; 192 drive->init_speed = speed;
@@ -390,20 +224,41 @@ static void via82cxxx_tune_drive(ide_drive_t *drive, u8 pio)
390 224
391static int via82cxxx_ide_dma_check (ide_drive_t *drive) 225static int via82cxxx_ide_dma_check (ide_drive_t *drive)
392{ 226{
393 u16 w80 = HWIF(drive)->udma_four; 227 ide_hwif_t *hwif = HWIF(drive);
228 struct via82cxxx_dev *vdev = ide_get_hwifdata(hwif);
229 u16 w80 = hwif->udma_four;
394 230
395 u16 speed = ide_find_best_mode(drive, 231 u16 speed = ide_find_best_mode(drive,
396 XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA | 232 XFER_PIO | XFER_EPIO | XFER_SWDMA | XFER_MWDMA |
397 (via_config->flags & VIA_UDMA ? XFER_UDMA : 0) | 233 (vdev->via_config->flags & VIA_UDMA ? XFER_UDMA : 0) |
398 (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) | 234 (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_66 ? XFER_UDMA_66 : 0) |
399 (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) | 235 (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_100 ? XFER_UDMA_100 : 0) |
400 (w80 && (via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0)); 236 (w80 && (vdev->via_config->flags & VIA_UDMA) >= VIA_UDMA_133 ? XFER_UDMA_133 : 0));
401 237
402 via_set_drive(drive, speed); 238 via_set_drive(drive, speed);
403 239
404 if (drive->autodma && (speed & XFER_MODE) != XFER_PIO) 240 if (drive->autodma && (speed & XFER_MODE) != XFER_PIO)
405 return HWIF(drive)->ide_dma_on(drive); 241 return hwif->ide_dma_on(drive);
406 return HWIF(drive)->ide_dma_off_quietly(drive); 242 return hwif->ide_dma_off_quietly(drive);
243}
244
245static struct via_isa_bridge *via_config_find(struct pci_dev **isa)
246{
247 struct via_isa_bridge *via_config;
248 u8 t;
249
250 for (via_config = via_isa_bridges; via_config->id; via_config++)
251 if ((*isa = pci_find_device(PCI_VENDOR_ID_VIA +
252 !!(via_config->flags & VIA_BAD_ID),
253 via_config->id, NULL))) {
254
255 pci_read_config_byte(*isa, PCI_REVISION_ID, &t);
256 if (t >= via_config->rev_min &&
257 t <= via_config->rev_max)
258 break;
259 }
260
261 return via_config;
407} 262}
408 263
409/** 264/**
@@ -418,82 +273,28 @@ static int via82cxxx_ide_dma_check (ide_drive_t *drive)
418static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name) 273static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name)
419{ 274{
420 struct pci_dev *isa = NULL; 275 struct pci_dev *isa = NULL;
276 struct via_isa_bridge *via_config;
421 u8 t, v; 277 u8 t, v;
422 unsigned int u; 278 unsigned int u;
423 int i;
424 279
425 /* 280 /*
426 * Find the ISA bridge to see how good the IDE is. 281 * Find the ISA bridge to see how good the IDE is.
427 */ 282 */
428 283 via_config = via_config_find(&isa);
429 for (via_config = via_isa_bridges; via_config->id; via_config++)
430 if ((isa = pci_find_device(PCI_VENDOR_ID_VIA +
431 !!(via_config->flags & VIA_BAD_ID),
432 via_config->id, NULL))) {
433
434 pci_read_config_byte(isa, PCI_REVISION_ID, &t);
435 if (t >= via_config->rev_min &&
436 t <= via_config->rev_max)
437 break;
438 }
439
440 if (!via_config->id) { 284 if (!via_config->id) {
441 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 285 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n");
442 return -ENODEV; 286 return -ENODEV;
443 } 287 }
444 288
445 /* 289 /*
446 * Check 80-wire cable presence and setup Clk66. 290 * Setup or disable Clk66 if appropriate
447 */ 291 */
448 292
449 switch (via_config->flags & VIA_UDMA) { 293 if ((via_config->flags & VIA_UDMA) == VIA_UDMA_66) {
450 294 /* Enable Clk66 */
451 case VIA_UDMA_66: 295 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
452 /* Enable Clk66 */ 296 pci_write_config_dword(dev, VIA_UDMA_TIMING, u|0x80008);
453 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); 297 } else if (via_config->flags & VIA_BAD_CLK66) {
454 pci_write_config_dword(dev, VIA_UDMA_TIMING, u|0x80008);
455 for (i = 24; i >= 0; i -= 8)
456 if (((u >> (i & 16)) & 8) &&
457 ((u >> i) & 0x20) &&
458 (((u >> i) & 7) < 2)) {
459 /*
460 * 2x PCI clock and
461 * UDMA w/ < 3T/cycle
462 */
463 via_80w |= (1 << (1 - (i >> 4)));
464 }
465 break;
466
467 case VIA_UDMA_100:
468 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
469 for (i = 24; i >= 0; i -= 8)
470 if (((u >> i) & 0x10) ||
471 (((u >> i) & 0x20) &&
472 (((u >> i) & 7) < 4))) {
473 /* BIOS 80-wire bit or
474 * UDMA w/ < 60ns/cycle
475 */
476 via_80w |= (1 << (1 - (i >> 4)));
477 }
478 break;
479
480 case VIA_UDMA_133:
481 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
482 for (i = 24; i >= 0; i -= 8)
483 if (((u >> i) & 0x10) ||
484 (((u >> i) & 0x20) &&
485 (((u >> i) & 7) < 6))) {
486 /* BIOS 80-wire bit or
487 * UDMA w/ < 60ns/cycle
488 */
489 via_80w |= (1 << (1 - (i >> 4)));
490 }
491 break;
492
493 }
494
495 /* Disable Clk66 */
496 if (via_config->flags & VIA_BAD_CLK66) {
497 /* Would cause trouble on 596a and 686 */ 298 /* Would cause trouble on 596a and 686 */
498 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u); 299 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
499 pci_write_config_dword(dev, VIA_UDMA_TIMING, u & ~0x80008); 300 pci_write_config_dword(dev, VIA_UDMA_TIMING, u & ~0x80008);
@@ -560,26 +361,78 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
560 via_dma[via_config->flags & VIA_UDMA], 361 via_dma[via_config->flags & VIA_UDMA],
561 pci_name(dev)); 362 pci_name(dev));
562 363
563 /* 364 return 0;
564 * Setup /proc/ide/via entry. 365}
565 */ 366
367/*
368 * Check and handle 80-wire cable presence
369 */
370static void __devinit via_cable_detect(struct pci_dev *dev, struct via82cxxx_dev *vdev)
371{
372 unsigned int u;
373 int i;
374 pci_read_config_dword(dev, VIA_UDMA_TIMING, &u);
375
376 switch (vdev->via_config->flags & VIA_UDMA) {
377
378 case VIA_UDMA_66:
379 for (i = 24; i >= 0; i -= 8)
380 if (((u >> (i & 16)) & 8) &&
381 ((u >> i) & 0x20) &&
382 (((u >> i) & 7) < 2)) {
383 /*
384 * 2x PCI clock and
385 * UDMA w/ < 3T/cycle
386 */
387 vdev->via_80w |= (1 << (1 - (i >> 4)));
388 }
389 break;
390
391 case VIA_UDMA_100:
392 for (i = 24; i >= 0; i -= 8)
393 if (((u >> i) & 0x10) ||
394 (((u >> i) & 0x20) &&
395 (((u >> i) & 7) < 4))) {
396 /* BIOS 80-wire bit or
397 * UDMA w/ < 60ns/cycle
398 */
399 vdev->via_80w |= (1 << (1 - (i >> 4)));
400 }
401 break;
402
403 case VIA_UDMA_133:
404 for (i = 24; i >= 0; i -= 8)
405 if (((u >> i) & 0x10) ||
406 (((u >> i) & 0x20) &&
407 (((u >> i) & 7) < 6))) {
408 /* BIOS 80-wire bit or
409 * UDMA w/ < 60ns/cycle
410 */
411 vdev->via_80w |= (1 << (1 - (i >> 4)));
412 }
413 break;
566 414
567#if defined(DISPLAY_VIA_TIMINGS) && defined(CONFIG_PROC_FS)
568 if (!via_proc) {
569 via_base = pci_resource_start(dev, 4);
570 bmide_dev = dev;
571 isa_dev = isa;
572 ide_pci_create_host_proc("via", via_get_info);
573 via_proc = 1;
574 } 415 }
575#endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */
576 return 0;
577} 416}
578 417
579static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) 418static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
580{ 419{
420 struct via82cxxx_dev *vdev = kmalloc(sizeof(struct via82cxxx_dev),
421 GFP_KERNEL);
422 struct pci_dev *isa = NULL;
581 int i; 423 int i;
582 424
425 if (vdev == NULL) {
426 printk(KERN_ERR "VP_IDE: out of memory :(\n");
427 return;
428 }
429
430 memset(vdev, 0, sizeof(struct via82cxxx_dev));
431 ide_set_hwifdata(hwif, vdev);
432
433 vdev->via_config = via_config_find(&isa);
434 via_cable_detect(hwif->pci_dev, vdev);
435
583 hwif->autodma = 0; 436 hwif->autodma = 0;
584 437
585 hwif->tuneproc = &via82cxxx_tune_drive; 438 hwif->tuneproc = &via82cxxx_tune_drive;
@@ -594,7 +447,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
594 447
595 for (i = 0; i < 2; i++) { 448 for (i = 0; i < 2; i++) {
596 hwif->drives[i].io_32bit = 1; 449 hwif->drives[i].io_32bit = 1;
597 hwif->drives[i].unmask = (via_config->flags & VIA_NO_UNMASK) ? 0 : 1; 450 hwif->drives[i].unmask = (vdev->via_config->flags & VIA_NO_UNMASK) ? 0 : 1;
598 hwif->drives[i].autotune = 1; 451 hwif->drives[i].autotune = 1;
599 hwif->drives[i].dn = hwif->channel * 2 + i; 452 hwif->drives[i].dn = hwif->channel * 2 + i;
600 } 453 }
@@ -608,7 +461,7 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
608 hwif->swdma_mask = 0x07; 461 hwif->swdma_mask = 0x07;
609 462
610 if (!hwif->udma_four) 463 if (!hwif->udma_four)
611 hwif->udma_four = (via_80w >> hwif->channel) & 1; 464 hwif->udma_four = (vdev->via_80w >> hwif->channel) & 1;
612 hwif->ide_dma_check = &via82cxxx_ide_dma_check; 465 hwif->ide_dma_check = &via82cxxx_ide_dma_check;
613 if (!noautodma) 466 if (!noautodma)
614 hwif->autodma = 1; 467 hwif->autodma = 1;
@@ -616,24 +469,35 @@ static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif)
616 hwif->drives[1].autodma = hwif->autodma; 469 hwif->drives[1].autodma = hwif->autodma;
617} 470}
618 471
619static ide_pci_device_t via82cxxx_chipset __devinitdata = { 472static ide_pci_device_t via82cxxx_chipsets[] __devinitdata = {
620 .name = "VP_IDE", 473 { /* 0 */
621 .init_chipset = init_chipset_via82cxxx, 474 .name = "VP_IDE",
622 .init_hwif = init_hwif_via82cxxx, 475 .init_chipset = init_chipset_via82cxxx,
623 .channels = 2, 476 .init_hwif = init_hwif_via82cxxx,
624 .autodma = NOAUTODMA, 477 .channels = 2,
625 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, 478 .autodma = NOAUTODMA,
626 .bootable = ON_BOARD, 479 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}},
480 .bootable = ON_BOARD
481 },{ /* 1 */
482 .name = "VP_IDE",
483 .init_chipset = init_chipset_via82cxxx,
484 .init_hwif = init_hwif_via82cxxx,
485 .channels = 2,
486 .autodma = AUTODMA,
487 .enablebits = {{0x00,0x00,0x00}, {0x00,0x00,0x00}},
488 .bootable = ON_BOARD,
489 }
627}; 490};
628 491
629static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id) 492static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_id *id)
630{ 493{
631 return ide_setup_pci_device(dev, &via82cxxx_chipset); 494 return ide_setup_pci_device(dev, &via82cxxx_chipsets[id->driver_data]);
632} 495}
633 496
634static struct pci_device_id via_pci_tbl[] = { 497static struct pci_device_id via_pci_tbl[] = {
635 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 498 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C576_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
636 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 499 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
500 { PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_6410, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
637 { 0, }, 501 { 0, },
638}; 502};
639MODULE_DEVICE_TABLE(pci, via_pci_tbl); 503MODULE_DEVICE_TABLE(pci, via_pci_tbl);
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c
index b3e65a65d202..16b28357885b 100644
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1401,20 +1401,6 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
1401 /* We probe the hwif now */ 1401 /* We probe the hwif now */
1402 probe_hwif_init(hwif); 1402 probe_hwif_init(hwif);
1403 1403
1404 /* The code IDE code will have set hwif->present if we have devices attached,
1405 * if we don't, the discard the interface except if we are on a media bay slot
1406 */
1407 if (!hwif->present && !pmif->mediabay) {
1408 printk(KERN_INFO "ide%d: Bus empty, interface released.\n",
1409 hwif->index);
1410 default_hwif_iops(hwif);
1411 for (i = IDE_DATA_OFFSET; i <= IDE_CONTROL_OFFSET; ++i)
1412 hwif->io_ports[i] = 0;
1413 hwif->chipset = ide_unknown;
1414 hwif->noprobe = 1;
1415 return -ENODEV;
1416 }
1417
1418 return 0; 1404 return 0;
1419} 1405}
1420 1406
@@ -1667,11 +1653,16 @@ static struct macio_driver pmac_ide_macio_driver =
1667}; 1653};
1668 1654
1669static struct pci_device_id pmac_ide_pci_match[] = { 1655static struct pci_device_id pmac_ide_pci_match[] = {
1670 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1656 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_ATA,
1671 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1657 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1672 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1658 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID_ATA100,
1659 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1660 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_K2_ATA100,
1661 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1673 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_ATA, 1662 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_ATA,
1674 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1663 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1664 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_ATA,
1665 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1675}; 1666};
1676 1667
1677static struct pci_driver pmac_ide_pci_driver = { 1668static struct pci_driver pmac_ide_pci_driver = {
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index 18ed7765417c..7ebf992e8c2f 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -787,8 +787,9 @@ static int pre_init = 1; /* Before first ordered IDE scan */
787static LIST_HEAD(ide_pci_drivers); 787static LIST_HEAD(ide_pci_drivers);
788 788
789/* 789/*
790 * ide_register_pci_driver - attach IDE driver 790 * __ide_pci_register_driver - attach IDE driver
791 * @driver: pci driver 791 * @driver: pci driver
792 * @module: owner module of the driver
792 * 793 *
793 * Registers a driver with the IDE layer. The IDE layer arranges that 794 * Registers a driver with the IDE layer. The IDE layer arranges that
794 * boot time setup is done in the expected device order and then 795 * boot time setup is done in the expected device order and then
@@ -801,15 +802,16 @@ static LIST_HEAD(ide_pci_drivers);
801 * Returns are the same as for pci_register_driver 802 * Returns are the same as for pci_register_driver
802 */ 803 */
803 804
804int ide_pci_register_driver(struct pci_driver *driver) 805int __ide_pci_register_driver(struct pci_driver *driver, struct module *module)
805{ 806{
806 if(!pre_init) 807 if(!pre_init)
807 return pci_module_init(driver); 808 return __pci_register_driver(driver, module);
809 driver->driver.owner = module;
808 list_add_tail(&driver->node, &ide_pci_drivers); 810 list_add_tail(&driver->node, &ide_pci_drivers);
809 return 0; 811 return 0;
810} 812}
811 813
812EXPORT_SYMBOL_GPL(ide_pci_register_driver); 814EXPORT_SYMBOL_GPL(__ide_pci_register_driver);
813 815
814/** 816/**
815 * ide_unregister_pci_driver - unregister an IDE driver 817 * ide_unregister_pci_driver - unregister an IDE driver
@@ -897,6 +899,6 @@ void __init ide_scan_pcibus (int scan_direction)
897 { 899 {
898 list_del(l); 900 list_del(l);
899 d = list_entry(l, struct pci_driver, node); 901 d = list_entry(l, struct pci_driver, node);
900 pci_register_driver(d); 902 __pci_register_driver(d, d->driver.owner);
901 } 903 }
902} 904}
diff --git a/drivers/ieee1394/hosts.h b/drivers/ieee1394/hosts.h
index 38f42112dff0..ae9b02cc013f 100644
--- a/drivers/ieee1394/hosts.h
+++ b/drivers/ieee1394/hosts.h
@@ -41,6 +41,7 @@ struct hpsb_host {
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;
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c
index 7fff5a1d2ea4..0ea37b1bccb2 100644
--- a/drivers/ieee1394/nodemgr.c
+++ b/drivers/ieee1394/nodemgr.c
@@ -1349,6 +1349,33 @@ static void nodemgr_update_pdrv(struct node_entry *ne)
1349} 1349}
1350 1350
1351 1351
1352/* Write the BROADCAST_CHANNEL as per IEEE1394a 8.3.2.3.11 and 8.4.2.3. This
1353 * seems like an optional service but in the end it is practically mandatory
1354 * as a consequence of these clauses.
1355 *
1356 * Note that we cannot do a broadcast write to all nodes at once because some
1357 * pre-1394a devices would hang. */
1358static void nodemgr_irm_write_bc(struct node_entry *ne, int generation)
1359{
1360 const u64 bc_addr = (CSR_REGISTER_BASE | CSR_BROADCAST_CHANNEL);
1361 quadlet_t bc_remote, bc_local;
1362 int ret;
1363
1364 if (!ne->host->is_irm || ne->generation != generation ||
1365 ne->nodeid == ne->host->node_id)
1366 return;
1367
1368 bc_local = cpu_to_be32(ne->host->csr.broadcast_channel);
1369
1370 /* Check if the register is implemented and 1394a compliant. */
1371 ret = hpsb_read(ne->host, ne->nodeid, generation, bc_addr, &bc_remote,
1372 sizeof(bc_remote));
1373 if (!ret && bc_remote & cpu_to_be32(0x80000000) &&
1374 bc_remote != bc_local)
1375 hpsb_node_write(ne, bc_addr, &bc_local, sizeof(bc_local));
1376}
1377
1378
1352static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation) 1379static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int generation)
1353{ 1380{
1354 struct device *dev; 1381 struct device *dev;
@@ -1360,6 +1387,8 @@ static void nodemgr_probe_ne(struct host_info *hi, struct node_entry *ne, int ge
1360 if (!dev) 1387 if (!dev)
1361 return; 1388 return;
1362 1389
1390 nodemgr_irm_write_bc(ne, generation);
1391
1363 /* If "needs_probe", then this is either a new or changed node we 1392 /* If "needs_probe", then this is either a new or changed node we
1364 * rescan totally. If the generation matches for an existing node 1393 * rescan totally. If the generation matches for an existing node
1365 * (one that existed prior to the bus reset) we send update calls 1394 * (one that existed prior to the bus reset) we send update calls
@@ -1413,9 +1442,25 @@ static void nodemgr_node_probe(struct host_info *hi, int generation)
1413 return; 1442 return;
1414} 1443}
1415 1444
1416/* Because we are a 1394a-2000 compliant IRM, we need to inform all the other 1445static int nodemgr_send_resume_packet(struct hpsb_host *host)
1417 * nodes of the broadcast channel. (Really we're only setting the validity 1446{
1418 * bit). Other IRM responsibilities go in here as well. */ 1447 struct hpsb_packet *packet;
1448 int ret = 1;
1449
1450 packet = hpsb_make_phypacket(host,
1451 0x003c0000 | NODEID_TO_NODE(host->node_id) << 24);
1452 if (packet) {
1453 packet->no_waiter = 1;
1454 packet->generation = get_hpsb_generation(host);
1455 ret = hpsb_send_packet(packet);
1456 }
1457 if (ret)
1458 HPSB_WARN("fw-host%d: Failed to broadcast resume packet",
1459 host->id);
1460 return ret;
1461}
1462
1463/* Perform a few high-level IRM responsibilities. */
1419static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles) 1464static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
1420{ 1465{
1421 quadlet_t bc; 1466 quadlet_t bc;
@@ -1424,13 +1469,8 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
1424 if (!host->is_irm || host->irm_id == (nodeid_t)-1) 1469 if (!host->is_irm || host->irm_id == (nodeid_t)-1)
1425 return 1; 1470 return 1;
1426 1471
1427 host->csr.broadcast_channel |= 0x40000000; /* set validity bit */ 1472 /* We are a 1394a-2000 compliant IRM. Set the validity bit. */
1428 1473 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 1474
1435 /* If there is no bus manager then we should set the root node's 1475 /* 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 1476 * force_root bit to promote bus stability per the 1394
@@ -1463,6 +1503,13 @@ static int nodemgr_do_irm_duties(struct hpsb_host *host, int cycles)
1463 } 1503 }
1464 } 1504 }
1465 1505
1506 /* Some devices suspend their ports while being connected to an inactive
1507 * host adapter, i.e. if connected before the low-level driver is
1508 * loaded. They become visible either when physically unplugged and
1509 * replugged, or when receiving a resume packet. Send one once. */
1510 if (!host->resume_packet_sent && !nodemgr_send_resume_packet(host))
1511 host->resume_packet_sent = 1;
1512
1466 return 1; 1513 return 1;
1467} 1514}
1468 1515
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c
index 12cec7c4a342..f7e18ccc5c0a 100644
--- a/drivers/ieee1394/sbp2.c
+++ b/drivers/ieee1394/sbp2.c
@@ -2350,6 +2350,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2350 struct scsi_cmnd *SCpnt = NULL; 2350 struct scsi_cmnd *SCpnt = NULL;
2351 u32 scsi_status = SBP2_SCSI_STATUS_GOOD; 2351 u32 scsi_status = SBP2_SCSI_STATUS_GOOD;
2352 struct sbp2_command_info *command; 2352 struct sbp2_command_info *command;
2353 unsigned long flags;
2353 2354
2354 SBP2_DEBUG("sbp2_handle_status_write"); 2355 SBP2_DEBUG("sbp2_handle_status_write");
2355 2356
@@ -2451,9 +2452,11 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest
2451 * null out last orb so that next time around we write directly to the orb pointer... 2452 * null out last orb so that next time around we write directly to the orb pointer...
2452 * Quick start saves one 1394 bus transaction. 2453 * Quick start saves one 1394 bus transaction.
2453 */ 2454 */
2455 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
2454 if (list_empty(&scsi_id->sbp2_command_orb_inuse)) { 2456 if (list_empty(&scsi_id->sbp2_command_orb_inuse)) {
2455 scsi_id->last_orb = NULL; 2457 scsi_id->last_orb = NULL;
2456 } 2458 }
2459 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
2457 2460
2458 } else { 2461 } else {
2459 2462
@@ -2563,9 +2566,11 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id
2563 struct sbp2scsi_host_info *hi = scsi_id->hi; 2566 struct sbp2scsi_host_info *hi = scsi_id->hi;
2564 struct list_head *lh; 2567 struct list_head *lh;
2565 struct sbp2_command_info *command; 2568 struct sbp2_command_info *command;
2569 unsigned long flags;
2566 2570
2567 SBP2_DEBUG("sbp2scsi_complete_all_commands"); 2571 SBP2_DEBUG("sbp2scsi_complete_all_commands");
2568 2572
2573 spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags);
2569 while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { 2574 while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) {
2570 SBP2_DEBUG("Found pending command to complete"); 2575 SBP2_DEBUG("Found pending command to complete");
2571 lh = scsi_id->sbp2_command_orb_inuse.next; 2576 lh = scsi_id->sbp2_command_orb_inuse.next;
@@ -2582,6 +2587,7 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id
2582 command->Current_done(command->Current_SCpnt); 2587 command->Current_done(command->Current_SCpnt);
2583 } 2588 }
2584 } 2589 }
2590 spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags);
2585 2591
2586 return; 2592 return;
2587} 2593}
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 41d6b4017acb..d393b504bf26 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -355,9 +355,9 @@ error4:
355 spin_unlock_irqrestore(&port_priv->reg_lock, flags); 355 spin_unlock_irqrestore(&port_priv->reg_lock, flags);
356 kfree(reg_req); 356 kfree(reg_req);
357error3: 357error3:
358 kfree(mad_agent_priv);
359error2:
360 ib_dereg_mr(mad_agent_priv->agent.mr); 358 ib_dereg_mr(mad_agent_priv->agent.mr);
359error2:
360 kfree(mad_agent_priv);
361error1: 361error1:
362 return ret; 362 return ret;
363} 363}
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index aed5ca23fb22..eb7f52537ccc 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -31,7 +31,7 @@
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 * 33 *
34 * $Id: user_mad.c 2814 2005-07-06 19:14:09Z halr $ 34 * $Id: user_mad.c 4010 2005-11-09 23:11:56Z roland $
35 */ 35 */
36 36
37#include <linux/module.h> 37#include <linux/module.h>
@@ -110,13 +110,13 @@ struct ib_umad_device {
110}; 110};
111 111
112struct ib_umad_file { 112struct ib_umad_file {
113 struct ib_umad_port *port; 113 struct ib_umad_port *port;
114 struct list_head recv_list; 114 struct list_head recv_list;
115 struct list_head port_list; 115 struct list_head port_list;
116 spinlock_t recv_lock; 116 spinlock_t recv_lock;
117 wait_queue_head_t recv_wait; 117 wait_queue_head_t recv_wait;
118 struct ib_mad_agent *agent[IB_UMAD_MAX_AGENTS]; 118 struct ib_mad_agent *agent[IB_UMAD_MAX_AGENTS];
119 struct ib_mr *mr[IB_UMAD_MAX_AGENTS]; 119 int agents_dead;
120}; 120};
121 121
122struct ib_umad_packet { 122struct ib_umad_packet {
@@ -145,6 +145,12 @@ static void ib_umad_release_dev(struct kref *ref)
145 kfree(dev); 145 kfree(dev);
146} 146}
147 147
148/* caller must hold port->mutex at least for reading */
149static struct ib_mad_agent *__get_agent(struct ib_umad_file *file, int id)
150{
151 return file->agents_dead ? NULL : file->agent[id];
152}
153
148static int queue_packet(struct ib_umad_file *file, 154static int queue_packet(struct ib_umad_file *file,
149 struct ib_mad_agent *agent, 155 struct ib_mad_agent *agent,
150 struct ib_umad_packet *packet) 156 struct ib_umad_packet *packet)
@@ -152,10 +158,11 @@ static int queue_packet(struct ib_umad_file *file,
152 int ret = 1; 158 int ret = 1;
153 159
154 down_read(&file->port->mutex); 160 down_read(&file->port->mutex);
161
155 for (packet->mad.hdr.id = 0; 162 for (packet->mad.hdr.id = 0;
156 packet->mad.hdr.id < IB_UMAD_MAX_AGENTS; 163 packet->mad.hdr.id < IB_UMAD_MAX_AGENTS;
157 packet->mad.hdr.id++) 164 packet->mad.hdr.id++)
158 if (agent == file->agent[packet->mad.hdr.id]) { 165 if (agent == __get_agent(file, packet->mad.hdr.id)) {
159 spin_lock_irq(&file->recv_lock); 166 spin_lock_irq(&file->recv_lock);
160 list_add_tail(&packet->list, &file->recv_list); 167 list_add_tail(&packet->list, &file->recv_list);
161 spin_unlock_irq(&file->recv_lock); 168 spin_unlock_irq(&file->recv_lock);
@@ -303,9 +310,9 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
303 u8 method; 310 u8 method;
304 __be64 *tid; 311 __be64 *tid;
305 int ret, length, hdr_len, copy_offset; 312 int ret, length, hdr_len, copy_offset;
306 int rmpp_active = 0; 313 int rmpp_active, has_rmpp_header;
307 314
308 if (count < sizeof (struct ib_user_mad)) 315 if (count < sizeof (struct ib_user_mad) + IB_MGMT_RMPP_HDR)
309 return -EINVAL; 316 return -EINVAL;
310 317
311 length = count - sizeof (struct ib_user_mad); 318 length = count - sizeof (struct ib_user_mad);
@@ -327,7 +334,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
327 334
328 down_read(&file->port->mutex); 335 down_read(&file->port->mutex);
329 336
330 agent = file->agent[packet->mad.hdr.id]; 337 agent = __get_agent(file, packet->mad.hdr.id);
331 if (!agent) { 338 if (!agent) {
332 ret = -EINVAL; 339 ret = -EINVAL;
333 goto err_up; 340 goto err_up;
@@ -353,28 +360,31 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
353 } 360 }
354 361
355 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data; 362 rmpp_mad = (struct ib_rmpp_mad *) packet->mad.data;
356 if (ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) & IB_MGMT_RMPP_FLAG_ACTIVE) { 363 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
357 /* RMPP active */ 364 hdr_len = IB_MGMT_SA_HDR;
358 if (!agent->rmpp_version) {
359 ret = -EINVAL;
360 goto err_ah;
361 }
362
363 /* Validate that the management class can support RMPP */
364 if (rmpp_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_SUBN_ADM) {
365 hdr_len = IB_MGMT_SA_HDR;
366 } else if ((rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START) &&
367 (rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END)) {
368 hdr_len = IB_MGMT_VENDOR_HDR;
369 } else {
370 ret = -EINVAL;
371 goto err_ah;
372 }
373 rmpp_active = 1;
374 copy_offset = IB_MGMT_RMPP_HDR; 365 copy_offset = IB_MGMT_RMPP_HDR;
366 has_rmpp_header = 1;
367 } else if (rmpp_mad->mad_hdr.mgmt_class >= IB_MGMT_CLASS_VENDOR_RANGE2_START &&
368 rmpp_mad->mad_hdr.mgmt_class <= IB_MGMT_CLASS_VENDOR_RANGE2_END) {
369 hdr_len = IB_MGMT_VENDOR_HDR;
370 copy_offset = IB_MGMT_RMPP_HDR;
371 has_rmpp_header = 1;
375 } else { 372 } else {
376 hdr_len = IB_MGMT_MAD_HDR; 373 hdr_len = IB_MGMT_MAD_HDR;
377 copy_offset = IB_MGMT_MAD_HDR; 374 copy_offset = IB_MGMT_MAD_HDR;
375 has_rmpp_header = 0;
376 }
377
378 if (has_rmpp_header)
379 rmpp_active = ib_get_rmpp_flags(&rmpp_mad->rmpp_hdr) &
380 IB_MGMT_RMPP_FLAG_ACTIVE;
381 else
382 rmpp_active = 0;
383
384 /* Validate that the management class can support RMPP */
385 if (rmpp_active && !agent->rmpp_version) {
386 ret = -EINVAL;
387 goto err_ah;
378 } 388 }
379 389
380 packet->msg = ib_create_send_mad(agent, 390 packet->msg = ib_create_send_mad(agent,
@@ -481,7 +491,7 @@ static int ib_umad_reg_agent(struct ib_umad_file *file, unsigned long arg)
481 } 491 }
482 492
483 for (agent_id = 0; agent_id < IB_UMAD_MAX_AGENTS; ++agent_id) 493 for (agent_id = 0; agent_id < IB_UMAD_MAX_AGENTS; ++agent_id)
484 if (!file->agent[agent_id]) 494 if (!__get_agent(file, agent_id))
485 goto found; 495 goto found;
486 496
487 ret = -ENOMEM; 497 ret = -ENOMEM;
@@ -505,29 +515,15 @@ found:
505 goto out; 515 goto out;
506 } 516 }
507 517
508 file->agent[agent_id] = agent;
509
510 file->mr[agent_id] = ib_get_dma_mr(agent->qp->pd, IB_ACCESS_LOCAL_WRITE);
511 if (IS_ERR(file->mr[agent_id])) {
512 ret = -ENOMEM;
513 goto err;
514 }
515
516 if (put_user(agent_id, 518 if (put_user(agent_id,
517 (u32 __user *) (arg + offsetof(struct ib_user_mad_reg_req, id)))) { 519 (u32 __user *) (arg + offsetof(struct ib_user_mad_reg_req, id)))) {
518 ret = -EFAULT; 520 ret = -EFAULT;
519 goto err_mr; 521 ib_unregister_mad_agent(agent);
522 goto out;
520 } 523 }
521 524
525 file->agent[agent_id] = agent;
522 ret = 0; 526 ret = 0;
523 goto out;
524
525err_mr:
526 ib_dereg_mr(file->mr[agent_id]);
527
528err:
529 file->agent[agent_id] = NULL;
530 ib_unregister_mad_agent(agent);
531 527
532out: 528out:
533 up_write(&file->port->mutex); 529 up_write(&file->port->mutex);
@@ -536,27 +532,29 @@ out:
536 532
537static int ib_umad_unreg_agent(struct ib_umad_file *file, unsigned long arg) 533static int ib_umad_unreg_agent(struct ib_umad_file *file, unsigned long arg)
538{ 534{
535 struct ib_mad_agent *agent = NULL;
539 u32 id; 536 u32 id;
540 int ret = 0; 537 int ret = 0;
541 538
542 down_write(&file->port->mutex); 539 if (get_user(id, (u32 __user *) arg))
540 return -EFAULT;
543 541
544 if (get_user(id, (u32 __user *) arg)) { 542 down_write(&file->port->mutex);
545 ret = -EFAULT;
546 goto out;
547 }
548 543
549 if (id < 0 || id >= IB_UMAD_MAX_AGENTS || !file->agent[id]) { 544 if (id < 0 || id >= IB_UMAD_MAX_AGENTS || !__get_agent(file, id)) {
550 ret = -EINVAL; 545 ret = -EINVAL;
551 goto out; 546 goto out;
552 } 547 }
553 548
554 ib_dereg_mr(file->mr[id]); 549 agent = file->agent[id];
555 ib_unregister_mad_agent(file->agent[id]);
556 file->agent[id] = NULL; 550 file->agent[id] = NULL;
557 551
558out: 552out:
559 up_write(&file->port->mutex); 553 up_write(&file->port->mutex);
554
555 if (agent)
556 ib_unregister_mad_agent(agent);
557
560 return ret; 558 return ret;
561} 559}
562 560
@@ -621,23 +619,29 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
621 struct ib_umad_file *file = filp->private_data; 619 struct ib_umad_file *file = filp->private_data;
622 struct ib_umad_device *dev = file->port->umad_dev; 620 struct ib_umad_device *dev = file->port->umad_dev;
623 struct ib_umad_packet *packet, *tmp; 621 struct ib_umad_packet *packet, *tmp;
622 int already_dead;
624 int i; 623 int i;
625 624
626 down_write(&file->port->mutex); 625 down_write(&file->port->mutex);
627 for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i) 626
628 if (file->agent[i]) { 627 already_dead = file->agents_dead;
629 ib_dereg_mr(file->mr[i]); 628 file->agents_dead = 1;
630 ib_unregister_mad_agent(file->agent[i]);
631 }
632 629
633 list_for_each_entry_safe(packet, tmp, &file->recv_list, list) 630 list_for_each_entry_safe(packet, tmp, &file->recv_list, list)
634 kfree(packet); 631 kfree(packet);
635 632
636 list_del(&file->port_list); 633 list_del(&file->port_list);
637 up_write(&file->port->mutex);
638 634
639 kfree(file); 635 downgrade_write(&file->port->mutex);
636
637 if (!already_dead)
638 for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
639 if (file->agent[i])
640 ib_unregister_mad_agent(file->agent[i]);
640 641
642 up_read(&file->port->mutex);
643
644 kfree(file);
641 kref_put(&dev->ref, ib_umad_release_dev); 645 kref_put(&dev->ref, ib_umad_release_dev);
642 646
643 return 0; 647 return 0;
@@ -801,7 +805,7 @@ static int ib_umad_init_port(struct ib_device *device, int port_num,
801 goto err_class; 805 goto err_class;
802 port->sm_dev->owner = THIS_MODULE; 806 port->sm_dev->owner = THIS_MODULE;
803 port->sm_dev->ops = &umad_sm_fops; 807 port->sm_dev->ops = &umad_sm_fops;
804 kobject_set_name(&port->dev->kobj, "issm%d", port->dev_num); 808 kobject_set_name(&port->sm_dev->kobj, "issm%d", port->dev_num);
805 if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1)) 809 if (cdev_add(port->sm_dev, base_dev + port->dev_num + IB_UMAD_MAX_PORTS, 1))
806 goto err_sm_cdev; 810 goto err_sm_cdev;
807 811
@@ -863,14 +867,36 @@ static void ib_umad_kill_port(struct ib_umad_port *port)
863 867
864 port->ib_dev = NULL; 868 port->ib_dev = NULL;
865 869
866 list_for_each_entry(file, &port->file_list, port_list) 870 /*
867 for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id) { 871 * Now go through the list of files attached to this port and
868 if (!file->agent[id]) 872 * unregister all of their MAD agents. We need to hold
869 continue; 873 * port->mutex while doing this to avoid racing with
870 ib_dereg_mr(file->mr[id]); 874 * ib_umad_close(), but we can't hold the mutex for writing
871 ib_unregister_mad_agent(file->agent[id]); 875 * while calling ib_unregister_mad_agent(), since that might
872 file->agent[id] = NULL; 876 * deadlock by calling back into queue_packet(). So we
873 } 877 * downgrade our lock to a read lock, and then drop and
878 * reacquire the write lock for the next iteration.
879 *
880 * We do list_del_init() on the file's list_head so that the
881 * list_del in ib_umad_close() is still OK, even after the
882 * file is removed from the list.
883 */
884 while (!list_empty(&port->file_list)) {
885 file = list_entry(port->file_list.next, struct ib_umad_file,
886 port_list);
887
888 file->agents_dead = 1;
889 list_del_init(&file->port_list);
890
891 downgrade_write(&port->mutex);
892
893 for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id)
894 if (file->agent[id])
895 ib_unregister_mad_agent(file->agent[id]);
896
897 up_read(&port->mutex);
898 down_write(&port->mutex);
899 }
874 900
875 up_write(&port->mutex); 901 up_write(&port->mutex);
876 902
@@ -913,7 +939,7 @@ static void ib_umad_add_one(struct ib_device *device)
913 939
914err: 940err:
915 while (--i >= s) 941 while (--i >= s)
916 ib_umad_kill_port(&umad_dev->port[i]); 942 ib_umad_kill_port(&umad_dev->port[i - s]);
917 943
918 kref_put(&umad_dev->ref, ib_umad_release_dev); 944 kref_put(&umad_dev->ref, ib_umad_release_dev);
919} 945}
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index ecb830127865..7114e3fbab00 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -105,12 +105,23 @@ struct ib_uverbs_event {
105 u32 *counter; 105 u32 *counter;
106}; 106};
107 107
108struct ib_uverbs_mcast_entry {
109 struct list_head list;
110 union ib_gid gid;
111 u16 lid;
112};
113
108struct ib_uevent_object { 114struct ib_uevent_object {
109 struct ib_uobject uobject; 115 struct ib_uobject uobject;
110 struct list_head event_list; 116 struct list_head event_list;
111 u32 events_reported; 117 u32 events_reported;
112}; 118};
113 119
120struct ib_uqp_object {
121 struct ib_uevent_object uevent;
122 struct list_head mcast_list;
123};
124
114struct ib_ucq_object { 125struct ib_ucq_object {
115 struct ib_uobject uobject; 126 struct ib_uobject uobject;
116 struct ib_uverbs_file *uverbs_file; 127 struct ib_uverbs_file *uverbs_file;
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 63a74151c60b..a57d021d435a 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -708,7 +708,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
708 resp->wc[i].opcode = wc[i].opcode; 708 resp->wc[i].opcode = wc[i].opcode;
709 resp->wc[i].vendor_err = wc[i].vendor_err; 709 resp->wc[i].vendor_err = wc[i].vendor_err;
710 resp->wc[i].byte_len = wc[i].byte_len; 710 resp->wc[i].byte_len = wc[i].byte_len;
711 resp->wc[i].imm_data = wc[i].imm_data; 711 resp->wc[i].imm_data = (__u32 __force) wc[i].imm_data;
712 resp->wc[i].qp_num = wc[i].qp_num; 712 resp->wc[i].qp_num = wc[i].qp_num;
713 resp->wc[i].src_qp = wc[i].src_qp; 713 resp->wc[i].src_qp = wc[i].src_qp;
714 resp->wc[i].wc_flags = wc[i].wc_flags; 714 resp->wc[i].wc_flags = wc[i].wc_flags;
@@ -815,7 +815,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
815 struct ib_uverbs_create_qp cmd; 815 struct ib_uverbs_create_qp cmd;
816 struct ib_uverbs_create_qp_resp resp; 816 struct ib_uverbs_create_qp_resp resp;
817 struct ib_udata udata; 817 struct ib_udata udata;
818 struct ib_uevent_object *uobj; 818 struct ib_uqp_object *uobj;
819 struct ib_pd *pd; 819 struct ib_pd *pd;
820 struct ib_cq *scq, *rcq; 820 struct ib_cq *scq, *rcq;
821 struct ib_srq *srq; 821 struct ib_srq *srq;
@@ -866,10 +866,11 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
866 attr.cap.max_recv_sge = cmd.max_recv_sge; 866 attr.cap.max_recv_sge = cmd.max_recv_sge;
867 attr.cap.max_inline_data = cmd.max_inline_data; 867 attr.cap.max_inline_data = cmd.max_inline_data;
868 868
869 uobj->uobject.user_handle = cmd.user_handle; 869 uobj->uevent.uobject.user_handle = cmd.user_handle;
870 uobj->uobject.context = file->ucontext; 870 uobj->uevent.uobject.context = file->ucontext;
871 uobj->events_reported = 0; 871 uobj->uevent.events_reported = 0;
872 INIT_LIST_HEAD(&uobj->event_list); 872 INIT_LIST_HEAD(&uobj->uevent.event_list);
873 INIT_LIST_HEAD(&uobj->mcast_list);
873 874
874 qp = pd->device->create_qp(pd, &attr, &udata); 875 qp = pd->device->create_qp(pd, &attr, &udata);
875 if (IS_ERR(qp)) { 876 if (IS_ERR(qp)) {
@@ -882,7 +883,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
882 qp->send_cq = attr.send_cq; 883 qp->send_cq = attr.send_cq;
883 qp->recv_cq = attr.recv_cq; 884 qp->recv_cq = attr.recv_cq;
884 qp->srq = attr.srq; 885 qp->srq = attr.srq;
885 qp->uobject = &uobj->uobject; 886 qp->uobject = &uobj->uevent.uobject;
886 qp->event_handler = attr.event_handler; 887 qp->event_handler = attr.event_handler;
887 qp->qp_context = attr.qp_context; 888 qp->qp_context = attr.qp_context;
888 qp->qp_type = attr.qp_type; 889 qp->qp_type = attr.qp_type;
@@ -901,14 +902,19 @@ retry:
901 goto err_destroy; 902 goto err_destroy;
902 } 903 }
903 904
904 ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->uobject.id); 905 ret = idr_get_new(&ib_uverbs_qp_idr, qp, &uobj->uevent.uobject.id);
905 906
906 if (ret == -EAGAIN) 907 if (ret == -EAGAIN)
907 goto retry; 908 goto retry;
908 if (ret) 909 if (ret)
909 goto err_destroy; 910 goto err_destroy;
910 911
911 resp.qp_handle = uobj->uobject.id; 912 resp.qp_handle = uobj->uevent.uobject.id;
913 resp.max_recv_sge = attr.cap.max_recv_sge;
914 resp.max_send_sge = attr.cap.max_send_sge;
915 resp.max_recv_wr = attr.cap.max_recv_wr;
916 resp.max_send_wr = attr.cap.max_send_wr;
917 resp.max_inline_data = attr.cap.max_inline_data;
912 918
913 if (copy_to_user((void __user *) (unsigned long) cmd.response, 919 if (copy_to_user((void __user *) (unsigned long) cmd.response,
914 &resp, sizeof resp)) { 920 &resp, sizeof resp)) {
@@ -917,7 +923,7 @@ retry:
917 } 923 }
918 924
919 down(&file->mutex); 925 down(&file->mutex);
920 list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list); 926 list_add_tail(&uobj->uevent.uobject.list, &file->ucontext->qp_list);
921 up(&file->mutex); 927 up(&file->mutex);
922 928
923 up(&ib_uverbs_idr_mutex); 929 up(&ib_uverbs_idr_mutex);
@@ -925,7 +931,7 @@ retry:
925 return in_len; 931 return in_len;
926 932
927err_idr: 933err_idr:
928 idr_remove(&ib_uverbs_qp_idr, uobj->uobject.id); 934 idr_remove(&ib_uverbs_qp_idr, uobj->uevent.uobject.id);
929 935
930err_destroy: 936err_destroy:
931 ib_destroy_qp(qp); 937 ib_destroy_qp(qp);
@@ -1027,7 +1033,7 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1027 struct ib_uverbs_destroy_qp cmd; 1033 struct ib_uverbs_destroy_qp cmd;
1028 struct ib_uverbs_destroy_qp_resp resp; 1034 struct ib_uverbs_destroy_qp_resp resp;
1029 struct ib_qp *qp; 1035 struct ib_qp *qp;
1030 struct ib_uevent_object *uobj; 1036 struct ib_uqp_object *uobj;
1031 int ret = -EINVAL; 1037 int ret = -EINVAL;
1032 1038
1033 if (copy_from_user(&cmd, buf, sizeof cmd)) 1039 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1041,7 +1047,12 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1041 if (!qp || qp->uobject->context != file->ucontext) 1047 if (!qp || qp->uobject->context != file->ucontext)
1042 goto out; 1048 goto out;
1043 1049
1044 uobj = container_of(qp->uobject, struct ib_uevent_object, uobject); 1050 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1051
1052 if (!list_empty(&uobj->mcast_list)) {
1053 ret = -EBUSY;
1054 goto out;
1055 }
1045 1056
1046 ret = ib_destroy_qp(qp); 1057 ret = ib_destroy_qp(qp);
1047 if (ret) 1058 if (ret)
@@ -1050,12 +1061,12 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file,
1050 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); 1061 idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle);
1051 1062
1052 down(&file->mutex); 1063 down(&file->mutex);
1053 list_del(&uobj->uobject.list); 1064 list_del(&uobj->uevent.uobject.list);
1054 up(&file->mutex); 1065 up(&file->mutex);
1055 1066
1056 ib_uverbs_release_uevent(file, uobj); 1067 ib_uverbs_release_uevent(file, &uobj->uevent);
1057 1068
1058 resp.events_reported = uobj->events_reported; 1069 resp.events_reported = uobj->uevent.events_reported;
1059 1070
1060 kfree(uobj); 1071 kfree(uobj);
1061 1072
@@ -1135,7 +1146,7 @@ ssize_t ib_uverbs_post_send(struct ib_uverbs_file *file,
1135 next->num_sge = user_wr->num_sge; 1146 next->num_sge = user_wr->num_sge;
1136 next->opcode = user_wr->opcode; 1147 next->opcode = user_wr->opcode;
1137 next->send_flags = user_wr->send_flags; 1148 next->send_flags = user_wr->send_flags;
1138 next->imm_data = user_wr->imm_data; 1149 next->imm_data = (__be32 __force) user_wr->imm_data;
1139 1150
1140 if (qp->qp_type == IB_QPT_UD) { 1151 if (qp->qp_type == IB_QPT_UD) {
1141 next->wr.ud.ah = idr_find(&ib_uverbs_ah_idr, 1152 next->wr.ud.ah = idr_find(&ib_uverbs_ah_idr,
@@ -1537,6 +1548,8 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
1537{ 1548{
1538 struct ib_uverbs_attach_mcast cmd; 1549 struct ib_uverbs_attach_mcast cmd;
1539 struct ib_qp *qp; 1550 struct ib_qp *qp;
1551 struct ib_uqp_object *uobj;
1552 struct ib_uverbs_mcast_entry *mcast;
1540 int ret = -EINVAL; 1553 int ret = -EINVAL;
1541 1554
1542 if (copy_from_user(&cmd, buf, sizeof cmd)) 1555 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1545,9 +1558,36 @@ ssize_t ib_uverbs_attach_mcast(struct ib_uverbs_file *file,
1545 down(&ib_uverbs_idr_mutex); 1558 down(&ib_uverbs_idr_mutex);
1546 1559
1547 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); 1560 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1548 if (qp && qp->uobject->context == file->ucontext) 1561 if (!qp || qp->uobject->context != file->ucontext)
1549 ret = ib_attach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid); 1562 goto out;
1563
1564 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1565
1566 list_for_each_entry(mcast, &uobj->mcast_list, list)
1567 if (cmd.mlid == mcast->lid &&
1568 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
1569 ret = 0;
1570 goto out;
1571 }
1550 1572
1573 mcast = kmalloc(sizeof *mcast, GFP_KERNEL);
1574 if (!mcast) {
1575 ret = -ENOMEM;
1576 goto out;
1577 }
1578
1579 mcast->lid = cmd.mlid;
1580 memcpy(mcast->gid.raw, cmd.gid, sizeof mcast->gid.raw);
1581
1582 ret = ib_attach_mcast(qp, &mcast->gid, cmd.mlid);
1583 if (!ret) {
1584 uobj = container_of(qp->uobject, struct ib_uqp_object,
1585 uevent.uobject);
1586 list_add_tail(&mcast->list, &uobj->mcast_list);
1587 } else
1588 kfree(mcast);
1589
1590out:
1551 up(&ib_uverbs_idr_mutex); 1591 up(&ib_uverbs_idr_mutex);
1552 1592
1553 return ret ? ret : in_len; 1593 return ret ? ret : in_len;
@@ -1558,7 +1598,9 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
1558 int out_len) 1598 int out_len)
1559{ 1599{
1560 struct ib_uverbs_detach_mcast cmd; 1600 struct ib_uverbs_detach_mcast cmd;
1601 struct ib_uqp_object *uobj;
1561 struct ib_qp *qp; 1602 struct ib_qp *qp;
1603 struct ib_uverbs_mcast_entry *mcast;
1562 int ret = -EINVAL; 1604 int ret = -EINVAL;
1563 1605
1564 if (copy_from_user(&cmd, buf, sizeof cmd)) 1606 if (copy_from_user(&cmd, buf, sizeof cmd))
@@ -1567,9 +1609,24 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
1567 down(&ib_uverbs_idr_mutex); 1609 down(&ib_uverbs_idr_mutex);
1568 1610
1569 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle); 1611 qp = idr_find(&ib_uverbs_qp_idr, cmd.qp_handle);
1570 if (qp && qp->uobject->context == file->ucontext) 1612 if (!qp || qp->uobject->context != file->ucontext)
1571 ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid); 1613 goto out;
1614
1615 ret = ib_detach_mcast(qp, (union ib_gid *) cmd.gid, cmd.mlid);
1616 if (ret)
1617 goto out;
1572 1618
1619 uobj = container_of(qp->uobject, struct ib_uqp_object, uevent.uobject);
1620
1621 list_for_each_entry(mcast, &uobj->mcast_list, list)
1622 if (cmd.mlid == mcast->lid &&
1623 !memcmp(cmd.gid, mcast->gid.raw, sizeof mcast->gid.raw)) {
1624 list_del(&mcast->list);
1625 kfree(mcast);
1626 break;
1627 }
1628
1629out:
1573 up(&ib_uverbs_idr_mutex); 1630 up(&ib_uverbs_idr_mutex);
1574 1631
1575 return ret ? ret : in_len; 1632 return ret ? ret : in_len;
@@ -1701,7 +1758,6 @@ ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
1701 } 1758 }
1702 1759
1703 attr.max_wr = cmd.max_wr; 1760 attr.max_wr = cmd.max_wr;
1704 attr.max_sge = cmd.max_sge;
1705 attr.srq_limit = cmd.srq_limit; 1761 attr.srq_limit = cmd.srq_limit;
1706 1762
1707 ret = ib_modify_srq(srq, &attr, cmd.attr_mask); 1763 ret = ib_modify_srq(srq, &attr, cmd.attr_mask);
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index de6581d7cb8d..81737bd6faea 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -160,6 +160,18 @@ void ib_uverbs_release_uevent(struct ib_uverbs_file *file,
160 spin_unlock_irq(&file->async_file->lock); 160 spin_unlock_irq(&file->async_file->lock);
161} 161}
162 162
163static void ib_uverbs_detach_umcast(struct ib_qp *qp,
164 struct ib_uqp_object *uobj)
165{
166 struct ib_uverbs_mcast_entry *mcast, *tmp;
167
168 list_for_each_entry_safe(mcast, tmp, &uobj->mcast_list, list) {
169 ib_detach_mcast(qp, &mcast->gid, mcast->lid);
170 list_del(&mcast->list);
171 kfree(mcast);
172 }
173}
174
163static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file, 175static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
164 struct ib_ucontext *context) 176 struct ib_ucontext *context)
165{ 177{
@@ -180,13 +192,14 @@ static int ib_uverbs_cleanup_ucontext(struct ib_uverbs_file *file,
180 192
181 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) { 193 list_for_each_entry_safe(uobj, tmp, &context->qp_list, list) {
182 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id); 194 struct ib_qp *qp = idr_find(&ib_uverbs_qp_idr, uobj->id);
183 struct ib_uevent_object *uevent = 195 struct ib_uqp_object *uqp =
184 container_of(uobj, struct ib_uevent_object, uobject); 196 container_of(uobj, struct ib_uqp_object, uevent.uobject);
185 idr_remove(&ib_uverbs_qp_idr, uobj->id); 197 idr_remove(&ib_uverbs_qp_idr, uobj->id);
198 ib_uverbs_detach_umcast(qp, uqp);
186 ib_destroy_qp(qp); 199 ib_destroy_qp(qp);
187 list_del(&uobj->list); 200 list_del(&uobj->list);
188 ib_uverbs_release_uevent(file, uevent); 201 ib_uverbs_release_uevent(file, &uqp->uevent);
189 kfree(uevent); 202 kfree(uqp);
190 } 203 }
191 204
192 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) { 205 list_for_each_entry_safe(uobj, tmp, &context->cq_list, list) {
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 4186cc888ea5..4c15e112736c 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -325,16 +325,8 @@ EXPORT_SYMBOL(ib_destroy_cq);
325int ib_resize_cq(struct ib_cq *cq, 325int ib_resize_cq(struct ib_cq *cq,
326 int cqe) 326 int cqe)
327{ 327{
328 int ret; 328 return cq->device->resize_cq ?
329 329 cq->device->resize_cq(cq, cqe) : -ENOSYS;
330 if (!cq->device->resize_cq)
331 return -ENOSYS;
332
333 ret = cq->device->resize_cq(cq, &cqe);
334 if (!ret)
335 cq->cqe = cqe;
336
337 return ret;
338} 330}
339EXPORT_SYMBOL(ib_resize_cq); 331EXPORT_SYMBOL(ib_resize_cq);
340 332
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
index 25ebab64bc42..c3bec7490f52 100644
--- a/drivers/infiniband/hw/mthca/mthca_catas.c
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -97,7 +97,7 @@ static void poll_catas(unsigned long dev_ptr)
97 } 97 }
98 98
99 spin_lock_irqsave(&catas_lock, flags); 99 spin_lock_irqsave(&catas_lock, flags);
100 if (dev->catas_err.stop) 100 if (!dev->catas_err.stop)
101 mod_timer(&dev->catas_err.timer, 101 mod_timer(&dev->catas_err.timer,
102 jiffies + MTHCA_CATAS_POLL_INTERVAL); 102 jiffies + MTHCA_CATAS_POLL_INTERVAL);
103 spin_unlock_irqrestore(&catas_lock, flags); 103 spin_unlock_irqrestore(&catas_lock, flags);
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 49f211d55df7..9ed34587fc5c 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -1060,6 +1060,8 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
1060 dev_lim->hca.arbel.resize_srq = field & 1; 1060 dev_lim->hca.arbel.resize_srq = field & 1;
1061 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_RQ_OFFSET); 1061 MTHCA_GET(field, outbox, QUERY_DEV_LIM_MAX_SG_RQ_OFFSET);
1062 dev_lim->max_sg = min_t(int, field, dev_lim->max_sg); 1062 dev_lim->max_sg = min_t(int, field, dev_lim->max_sg);
1063 MTHCA_GET(size, outbox, QUERY_DEV_LIM_MAX_DESC_SZ_RQ_OFFSET);
1064 dev_lim->max_desc_sz = min_t(int, size, dev_lim->max_desc_sz);
1063 MTHCA_GET(size, outbox, QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET); 1065 MTHCA_GET(size, outbox, QUERY_DEV_LIM_MPT_ENTRY_SZ_OFFSET);
1064 dev_lim->mpt_entry_sz = size; 1066 dev_lim->mpt_entry_sz = size;
1065 MTHCA_GET(field, outbox, QUERY_DEV_LIM_PBL_SZ_OFFSET); 1067 MTHCA_GET(field, outbox, QUERY_DEV_LIM_PBL_SZ_OFFSET);
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index f98e23555826..4a8adcef2079 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -258,7 +258,7 @@ void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn,
258{ 258{
259 struct mthca_cq *cq; 259 struct mthca_cq *cq;
260 struct mthca_cqe *cqe; 260 struct mthca_cqe *cqe;
261 int prod_index; 261 u32 prod_index;
262 int nfreed = 0; 262 int nfreed = 0;
263 263
264 spin_lock_irq(&dev->cq_table.lock); 264 spin_lock_irq(&dev->cq_table.lock);
@@ -293,19 +293,15 @@ void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn,
293 * Now sweep backwards through the CQ, removing CQ entries 293 * Now sweep backwards through the CQ, removing CQ entries
294 * that match our QP by copying older entries on top of them. 294 * that match our QP by copying older entries on top of them.
295 */ 295 */
296 while (prod_index > cq->cons_index) { 296 while ((int) --prod_index - (int) cq->cons_index >= 0) {
297 cqe = get_cqe(cq, (prod_index - 1) & cq->ibcq.cqe); 297 cqe = get_cqe(cq, prod_index & cq->ibcq.cqe);
298 if (cqe->my_qpn == cpu_to_be32(qpn)) { 298 if (cqe->my_qpn == cpu_to_be32(qpn)) {
299 if (srq) 299 if (srq)
300 mthca_free_srq_wqe(srq, be32_to_cpu(cqe->wqe)); 300 mthca_free_srq_wqe(srq, be32_to_cpu(cqe->wqe));
301 ++nfreed; 301 ++nfreed;
302 } 302 } else if (nfreed)
303 else if (nfreed) 303 memcpy(get_cqe(cq, (prod_index + nfreed) & cq->ibcq.cqe),
304 memcpy(get_cqe(cq, (prod_index - 1 + nfreed) & 304 cqe, MTHCA_CQ_ENTRY_SIZE);
305 cq->ibcq.cqe),
306 cqe,
307 MTHCA_CQ_ENTRY_SIZE);
308 --prod_index;
309 } 305 }
310 306
311 if (nfreed) { 307 if (nfreed) {
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index e7e5d3b4f004..497ff794ef6a 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -131,6 +131,7 @@ struct mthca_limits {
131 int max_sg; 131 int max_sg;
132 int num_qps; 132 int num_qps;
133 int max_wqes; 133 int max_wqes;
134 int max_desc_sz;
134 int max_qp_init_rdma; 135 int max_qp_init_rdma;
135 int reserved_qps; 136 int reserved_qps;
136 int num_srqs; 137 int num_srqs;
@@ -154,6 +155,7 @@ struct mthca_limits {
154 int reserved_mcgs; 155 int reserved_mcgs;
155 int num_pds; 156 int num_pds;
156 int reserved_pds; 157 int reserved_pds;
158 u32 page_size_cap;
157 u32 flags; 159 u32 flags;
158 u8 port_width_cap; 160 u8 port_width_cap;
159}; 161};
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 45c6328e780c..6f94b25f3acd 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -168,6 +168,7 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
168 mdev->limits.max_srq_wqes = dev_lim->max_srq_sz; 168 mdev->limits.max_srq_wqes = dev_lim->max_srq_sz;
169 mdev->limits.reserved_srqs = dev_lim->reserved_srqs; 169 mdev->limits.reserved_srqs = dev_lim->reserved_srqs;
170 mdev->limits.reserved_eecs = dev_lim->reserved_eecs; 170 mdev->limits.reserved_eecs = dev_lim->reserved_eecs;
171 mdev->limits.max_desc_sz = dev_lim->max_desc_sz;
171 /* 172 /*
172 * Subtract 1 from the limit because we need to allocate a 173 * Subtract 1 from the limit because we need to allocate a
173 * spare CQE so the HCA HW can tell the difference between an 174 * spare CQE so the HCA HW can tell the difference between an
@@ -181,6 +182,7 @@ static int __devinit mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim
181 mdev->limits.reserved_uars = dev_lim->reserved_uars; 182 mdev->limits.reserved_uars = dev_lim->reserved_uars;
182 mdev->limits.reserved_pds = dev_lim->reserved_pds; 183 mdev->limits.reserved_pds = dev_lim->reserved_pds;
183 mdev->limits.port_width_cap = dev_lim->max_port_width; 184 mdev->limits.port_width_cap = dev_lim->max_port_width;
185 mdev->limits.page_size_cap = ~(u32) (dev_lim->min_page_sz - 1);
184 mdev->limits.flags = dev_lim->flags; 186 mdev->limits.flags = dev_lim->flags;
185 187
186 /* IB_DEVICE_RESIZE_MAX_WR not supported by driver. 188 /* IB_DEVICE_RESIZE_MAX_WR not supported by driver.
@@ -1196,7 +1198,6 @@ MODULE_DEVICE_TABLE(pci, mthca_pci_table);
1196 1198
1197static struct pci_driver mthca_driver = { 1199static struct pci_driver mthca_driver = {
1198 .name = DRV_NAME, 1200 .name = DRV_NAME,
1199 .owner = THIS_MODULE,
1200 .id_table = mthca_pci_table, 1201 .id_table = mthca_pci_table,
1201 .probe = mthca_init_one, 1202 .probe = mthca_init_one,
1202 .remove = __devexit_p(mthca_remove_one) 1203 .remove = __devexit_p(mthca_remove_one)
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index 6b0166668269..4cc7e2846df1 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -90,6 +90,7 @@ static int mthca_query_device(struct ib_device *ibdev,
90 memcpy(&props->node_guid, out_mad->data + 12, 8); 90 memcpy(&props->node_guid, out_mad->data + 12, 8);
91 91
92 props->max_mr_size = ~0ull; 92 props->max_mr_size = ~0ull;
93 props->page_size_cap = mdev->limits.page_size_cap;
93 props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps; 94 props->max_qp = mdev->limits.num_qps - mdev->limits.reserved_qps;
94 props->max_qp_wr = mdev->limits.max_wqes; 95 props->max_qp_wr = mdev->limits.max_wqes;
95 props->max_sge = mdev->limits.max_sg; 96 props->max_sge = mdev->limits.max_sg;
@@ -615,11 +616,11 @@ static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
615 return ERR_PTR(err); 616 return ERR_PTR(err);
616 } 617 }
617 618
618 init_attr->cap.max_inline_data = 0;
619 init_attr->cap.max_send_wr = qp->sq.max; 619 init_attr->cap.max_send_wr = qp->sq.max;
620 init_attr->cap.max_recv_wr = qp->rq.max; 620 init_attr->cap.max_recv_wr = qp->rq.max;
621 init_attr->cap.max_send_sge = qp->sq.max_gs; 621 init_attr->cap.max_send_sge = qp->sq.max_gs;
622 init_attr->cap.max_recv_sge = qp->rq.max_gs; 622 init_attr->cap.max_recv_sge = qp->rq.max_gs;
623 init_attr->cap.max_inline_data = qp->max_inline_data;
623 624
624 return &qp->ibqp; 625 return &qp->ibqp;
625} 626}
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index bcd4b01a339c..1e73947b4702 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -251,6 +251,7 @@ struct mthca_qp {
251 struct mthca_wq sq; 251 struct mthca_wq sq;
252 enum ib_sig_type sq_policy; 252 enum ib_sig_type sq_policy;
253 int send_wqe_offset; 253 int send_wqe_offset;
254 int max_inline_data;
254 255
255 u64 *wrid; 256 u64 *wrid;
256 union mthca_buf queue; 257 union mthca_buf queue;
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 8852ea477c21..7450550db736 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -730,15 +730,16 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
730 } 730 }
731 731
732 if (attr_mask & IB_QP_ACCESS_FLAGS) { 732 if (attr_mask & IB_QP_ACCESS_FLAGS) {
733 qp_context->params2 |=
734 cpu_to_be32(attr->qp_access_flags & IB_ACCESS_REMOTE_WRITE ?
735 MTHCA_QP_BIT_RWE : 0);
736
733 /* 737 /*
734 * Only enable RDMA/atomics if we have responder 738 * Only enable RDMA reads and atomics if we have
735 * resources set to a non-zero value. 739 * responder resources set to a non-zero value.
736 */ 740 */
737 if (qp->resp_depth) { 741 if (qp->resp_depth) {
738 qp_context->params2 |= 742 qp_context->params2 |=
739 cpu_to_be32(attr->qp_access_flags & IB_ACCESS_REMOTE_WRITE ?
740 MTHCA_QP_BIT_RWE : 0);
741 qp_context->params2 |=
742 cpu_to_be32(attr->qp_access_flags & IB_ACCESS_REMOTE_READ ? 743 cpu_to_be32(attr->qp_access_flags & IB_ACCESS_REMOTE_READ ?
743 MTHCA_QP_BIT_RRE : 0); 744 MTHCA_QP_BIT_RRE : 0);
744 qp_context->params2 |= 745 qp_context->params2 |=
@@ -759,31 +760,27 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
759 if (qp->resp_depth && !attr->max_dest_rd_atomic) { 760 if (qp->resp_depth && !attr->max_dest_rd_atomic) {
760 /* 761 /*
761 * Lowering our responder resources to zero. 762 * Lowering our responder resources to zero.
762 * Turn off RDMA/atomics as responder. 763 * Turn off reads RDMA and atomics as responder.
763 * (RWE/RRE/RAE in params2 already zero) 764 * (RRE/RAE in params2 already zero)
764 */ 765 */
765 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RWE | 766 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RRE |
766 MTHCA_QP_OPTPAR_RRE |
767 MTHCA_QP_OPTPAR_RAE); 767 MTHCA_QP_OPTPAR_RAE);
768 } 768 }
769 769
770 if (!qp->resp_depth && attr->max_dest_rd_atomic) { 770 if (!qp->resp_depth && attr->max_dest_rd_atomic) {
771 /* 771 /*
772 * Increasing our responder resources from 772 * Increasing our responder resources from
773 * zero. Turn on RDMA/atomics as appropriate. 773 * zero. Turn on RDMA reads and atomics as
774 * appropriate.
774 */ 775 */
775 qp_context->params2 |= 776 qp_context->params2 |=
776 cpu_to_be32(qp->atomic_rd_en & IB_ACCESS_REMOTE_WRITE ?
777 MTHCA_QP_BIT_RWE : 0);
778 qp_context->params2 |=
779 cpu_to_be32(qp->atomic_rd_en & IB_ACCESS_REMOTE_READ ? 777 cpu_to_be32(qp->atomic_rd_en & IB_ACCESS_REMOTE_READ ?
780 MTHCA_QP_BIT_RRE : 0); 778 MTHCA_QP_BIT_RRE : 0);
781 qp_context->params2 |= 779 qp_context->params2 |=
782 cpu_to_be32(qp->atomic_rd_en & IB_ACCESS_REMOTE_ATOMIC ? 780 cpu_to_be32(qp->atomic_rd_en & IB_ACCESS_REMOTE_ATOMIC ?
783 MTHCA_QP_BIT_RAE : 0); 781 MTHCA_QP_BIT_RAE : 0);
784 782
785 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RWE | 783 qp_param->opt_param_mask |= cpu_to_be32(MTHCA_QP_OPTPAR_RRE |
786 MTHCA_QP_OPTPAR_RRE |
787 MTHCA_QP_OPTPAR_RAE); 784 MTHCA_QP_OPTPAR_RAE);
788 } 785 }
789 786
@@ -874,7 +871,10 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
874 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL); 871 qp->ibqp.srq ? to_msrq(qp->ibqp.srq) : NULL);
875 872
876 mthca_wq_init(&qp->sq); 873 mthca_wq_init(&qp->sq);
874 qp->sq.last = get_send_wqe(qp, qp->sq.max - 1);
875
877 mthca_wq_init(&qp->rq); 876 mthca_wq_init(&qp->rq);
877 qp->rq.last = get_recv_wqe(qp, qp->rq.max - 1);
878 878
879 if (mthca_is_memfree(dev)) { 879 if (mthca_is_memfree(dev)) {
880 *qp->sq.db = 0; 880 *qp->sq.db = 0;
@@ -885,6 +885,50 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask)
885 return err; 885 return err;
886} 886}
887 887
888static void mthca_adjust_qp_caps(struct mthca_dev *dev,
889 struct mthca_pd *pd,
890 struct mthca_qp *qp)
891{
892 int max_data_size;
893
894 /*
895 * Calculate the maximum size of WQE s/g segments, excluding
896 * the next segment and other non-data segments.
897 */
898 max_data_size = min(dev->limits.max_desc_sz, 1 << qp->sq.wqe_shift) -
899 sizeof (struct mthca_next_seg);
900
901 switch (qp->transport) {
902 case MLX:
903 max_data_size -= 2 * sizeof (struct mthca_data_seg);
904 break;
905
906 case UD:
907 if (mthca_is_memfree(dev))
908 max_data_size -= sizeof (struct mthca_arbel_ud_seg);
909 else
910 max_data_size -= sizeof (struct mthca_tavor_ud_seg);
911 break;
912
913 default:
914 max_data_size -= sizeof (struct mthca_raddr_seg);
915 break;
916 }
917
918 /* We don't support inline data for kernel QPs (yet). */
919 if (!pd->ibpd.uobject)
920 qp->max_inline_data = 0;
921 else
922 qp->max_inline_data = max_data_size - MTHCA_INLINE_HEADER_SIZE;
923
924 qp->sq.max_gs = min_t(int, dev->limits.max_sg,
925 max_data_size / sizeof (struct mthca_data_seg));
926 qp->rq.max_gs = min_t(int, dev->limits.max_sg,
927 (min(dev->limits.max_desc_sz, 1 << qp->rq.wqe_shift) -
928 sizeof (struct mthca_next_seg)) /
929 sizeof (struct mthca_data_seg));
930}
931
888/* 932/*
889 * Allocate and register buffer for WQEs. qp->rq.max, sq.max, 933 * Allocate and register buffer for WQEs. qp->rq.max, sq.max,
890 * rq.max_gs and sq.max_gs must all be assigned. 934 * rq.max_gs and sq.max_gs must all be assigned.
@@ -902,27 +946,53 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
902 size = sizeof (struct mthca_next_seg) + 946 size = sizeof (struct mthca_next_seg) +
903 qp->rq.max_gs * sizeof (struct mthca_data_seg); 947 qp->rq.max_gs * sizeof (struct mthca_data_seg);
904 948
949 if (size > dev->limits.max_desc_sz)
950 return -EINVAL;
951
905 for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size; 952 for (qp->rq.wqe_shift = 6; 1 << qp->rq.wqe_shift < size;
906 qp->rq.wqe_shift++) 953 qp->rq.wqe_shift++)
907 ; /* nothing */ 954 ; /* nothing */
908 955
909 size = sizeof (struct mthca_next_seg) + 956 size = qp->sq.max_gs * sizeof (struct mthca_data_seg);
910 qp->sq.max_gs * sizeof (struct mthca_data_seg);
911 switch (qp->transport) { 957 switch (qp->transport) {
912 case MLX: 958 case MLX:
913 size += 2 * sizeof (struct mthca_data_seg); 959 size += 2 * sizeof (struct mthca_data_seg);
914 break; 960 break;
961
915 case UD: 962 case UD:
916 if (mthca_is_memfree(dev)) 963 size += mthca_is_memfree(dev) ?
917 size += sizeof (struct mthca_arbel_ud_seg); 964 sizeof (struct mthca_arbel_ud_seg) :
918 else 965 sizeof (struct mthca_tavor_ud_seg);
919 size += sizeof (struct mthca_tavor_ud_seg);
920 break; 966 break;
967
968 case UC:
969 size += sizeof (struct mthca_raddr_seg);
970 break;
971
972 case RC:
973 size += sizeof (struct mthca_raddr_seg);
974 /*
975 * An atomic op will require an atomic segment, a
976 * remote address segment and one scatter entry.
977 */
978 size = max_t(int, size,
979 sizeof (struct mthca_atomic_seg) +
980 sizeof (struct mthca_raddr_seg) +
981 sizeof (struct mthca_data_seg));
982 break;
983
921 default: 984 default:
922 /* bind seg is as big as atomic + raddr segs */ 985 break;
923 size += sizeof (struct mthca_bind_seg);
924 } 986 }
925 987
988 /* Make sure that we have enough space for a bind request */
989 size = max_t(int, size, sizeof (struct mthca_bind_seg));
990
991 size += sizeof (struct mthca_next_seg);
992
993 if (size > dev->limits.max_desc_sz)
994 return -EINVAL;
995
926 for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size; 996 for (qp->sq.wqe_shift = 6; 1 << qp->sq.wqe_shift < size;
927 qp->sq.wqe_shift++) 997 qp->sq.wqe_shift++)
928 ; /* nothing */ 998 ; /* nothing */
@@ -1066,6 +1136,8 @@ static int mthca_alloc_qp_common(struct mthca_dev *dev,
1066 return ret; 1136 return ret;
1067 } 1137 }
1068 1138
1139 mthca_adjust_qp_caps(dev, pd, qp);
1140
1069 /* 1141 /*
1070 * If this is a userspace QP, we're done now. The doorbells 1142 * If this is a userspace QP, we're done now. The doorbells
1071 * will be allocated and buffers will be initialized in 1143 * will be allocated and buffers will be initialized in
@@ -1486,8 +1558,8 @@ int mthca_tavor_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1486 } 1558 }
1487 1559
1488 wqe += sizeof (struct mthca_atomic_seg); 1560 wqe += sizeof (struct mthca_atomic_seg);
1489 size += sizeof (struct mthca_raddr_seg) / 16 + 1561 size += (sizeof (struct mthca_raddr_seg) +
1490 sizeof (struct mthca_atomic_seg); 1562 sizeof (struct mthca_atomic_seg)) / 16;
1491 break; 1563 break;
1492 1564
1493 case IB_WR_RDMA_WRITE: 1565 case IB_WR_RDMA_WRITE:
@@ -1637,6 +1709,7 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
1637{ 1709{
1638 struct mthca_dev *dev = to_mdev(ibqp->device); 1710 struct mthca_dev *dev = to_mdev(ibqp->device);
1639 struct mthca_qp *qp = to_mqp(ibqp); 1711 struct mthca_qp *qp = to_mqp(ibqp);
1712 __be32 doorbell[2];
1640 unsigned long flags; 1713 unsigned long flags;
1641 int err = 0; 1714 int err = 0;
1642 int nreq; 1715 int nreq;
@@ -1654,6 +1727,22 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
1654 ind = qp->rq.next_ind; 1727 ind = qp->rq.next_ind;
1655 1728
1656 for (nreq = 0; wr; ++nreq, wr = wr->next) { 1729 for (nreq = 0; wr; ++nreq, wr = wr->next) {
1730 if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
1731 nreq = 0;
1732
1733 doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
1734 doorbell[1] = cpu_to_be32(qp->qpn << 8);
1735
1736 wmb();
1737
1738 mthca_write64(doorbell,
1739 dev->kar + MTHCA_RECEIVE_DOORBELL,
1740 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
1741
1742 qp->rq.head += MTHCA_TAVOR_MAX_WQES_PER_RECV_DB;
1743 size0 = 0;
1744 }
1745
1657 if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) { 1746 if (mthca_wq_overflow(&qp->rq, nreq, qp->ibqp.recv_cq)) {
1658 mthca_err(dev, "RQ %06x full (%u head, %u tail," 1747 mthca_err(dev, "RQ %06x full (%u head, %u tail,"
1659 " %d max, %d nreq)\n", qp->qpn, 1748 " %d max, %d nreq)\n", qp->qpn,
@@ -1711,8 +1800,6 @@ int mthca_tavor_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
1711 1800
1712out: 1801out:
1713 if (likely(nreq)) { 1802 if (likely(nreq)) {
1714 __be32 doorbell[2];
1715
1716 doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0); 1803 doorbell[0] = cpu_to_be32((qp->rq.next_ind << qp->rq.wqe_shift) | size0);
1717 doorbell[1] = cpu_to_be32((qp->qpn << 8) | nreq); 1804 doorbell[1] = cpu_to_be32((qp->qpn << 8) | nreq);
1718 1805
@@ -1735,6 +1822,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1735{ 1822{
1736 struct mthca_dev *dev = to_mdev(ibqp->device); 1823 struct mthca_dev *dev = to_mdev(ibqp->device);
1737 struct mthca_qp *qp = to_mqp(ibqp); 1824 struct mthca_qp *qp = to_mqp(ibqp);
1825 __be32 doorbell[2];
1738 void *wqe; 1826 void *wqe;
1739 void *prev_wqe; 1827 void *prev_wqe;
1740 unsigned long flags; 1828 unsigned long flags;
@@ -1754,6 +1842,34 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1754 ind = qp->sq.head & (qp->sq.max - 1); 1842 ind = qp->sq.head & (qp->sq.max - 1);
1755 1843
1756 for (nreq = 0; wr; ++nreq, wr = wr->next) { 1844 for (nreq = 0; wr; ++nreq, wr = wr->next) {
1845 if (unlikely(nreq == MTHCA_ARBEL_MAX_WQES_PER_SEND_DB)) {
1846 nreq = 0;
1847
1848 doorbell[0] = cpu_to_be32((MTHCA_ARBEL_MAX_WQES_PER_SEND_DB << 24) |
1849 ((qp->sq.head & 0xffff) << 8) |
1850 f0 | op0);
1851 doorbell[1] = cpu_to_be32((qp->qpn << 8) | size0);
1852
1853 qp->sq.head += MTHCA_ARBEL_MAX_WQES_PER_SEND_DB;
1854 size0 = 0;
1855
1856 /*
1857 * Make sure that descriptors are written before
1858 * doorbell record.
1859 */
1860 wmb();
1861 *qp->sq.db = cpu_to_be32(qp->sq.head & 0xffff);
1862
1863 /*
1864 * Make sure doorbell record is written before we
1865 * write MMIO send doorbell.
1866 */
1867 wmb();
1868 mthca_write64(doorbell,
1869 dev->kar + MTHCA_SEND_DOORBELL,
1870 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
1871 }
1872
1757 if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) { 1873 if (mthca_wq_overflow(&qp->sq, nreq, qp->ibqp.send_cq)) {
1758 mthca_err(dev, "SQ %06x full (%u head, %u tail," 1874 mthca_err(dev, "SQ %06x full (%u head, %u tail,"
1759 " %d max, %d nreq)\n", qp->qpn, 1875 " %d max, %d nreq)\n", qp->qpn,
@@ -1806,8 +1922,8 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1806 } 1922 }
1807 1923
1808 wqe += sizeof (struct mthca_atomic_seg); 1924 wqe += sizeof (struct mthca_atomic_seg);
1809 size += sizeof (struct mthca_raddr_seg) / 16 + 1925 size += (sizeof (struct mthca_raddr_seg) +
1810 sizeof (struct mthca_atomic_seg); 1926 sizeof (struct mthca_atomic_seg)) / 16;
1811 break; 1927 break;
1812 1928
1813 case IB_WR_RDMA_READ: 1929 case IB_WR_RDMA_READ:
@@ -1930,8 +2046,6 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
1930 2046
1931out: 2047out:
1932 if (likely(nreq)) { 2048 if (likely(nreq)) {
1933 __be32 doorbell[2];
1934
1935 doorbell[0] = cpu_to_be32((nreq << 24) | 2049 doorbell[0] = cpu_to_be32((nreq << 24) |
1936 ((qp->sq.head & 0xffff) << 8) | 2050 ((qp->sq.head & 0xffff) << 8) |
1937 f0 | op0); 2051 f0 | op0);
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index 26d5161fde07..f7d234295efe 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -417,6 +417,7 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
417{ 417{
418 struct mthca_dev *dev = to_mdev(ibsrq->device); 418 struct mthca_dev *dev = to_mdev(ibsrq->device);
419 struct mthca_srq *srq = to_msrq(ibsrq); 419 struct mthca_srq *srq = to_msrq(ibsrq);
420 __be32 doorbell[2];
420 unsigned long flags; 421 unsigned long flags;
421 int err = 0; 422 int err = 0;
422 int first_ind; 423 int first_ind;
@@ -432,6 +433,25 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
432 first_ind = srq->first_free; 433 first_ind = srq->first_free;
433 434
434 for (nreq = 0; wr; ++nreq, wr = wr->next) { 435 for (nreq = 0; wr; ++nreq, wr = wr->next) {
436 if (unlikely(nreq == MTHCA_TAVOR_MAX_WQES_PER_RECV_DB)) {
437 nreq = 0;
438
439 doorbell[0] = cpu_to_be32(first_ind << srq->wqe_shift);
440 doorbell[1] = cpu_to_be32(srq->srqn << 8);
441
442 /*
443 * Make sure that descriptors are written
444 * before doorbell is rung.
445 */
446 wmb();
447
448 mthca_write64(doorbell,
449 dev->kar + MTHCA_RECEIVE_DOORBELL,
450 MTHCA_GET_DOORBELL_LOCK(&dev->doorbell_lock));
451
452 first_ind = srq->first_free;
453 }
454
435 ind = srq->first_free; 455 ind = srq->first_free;
436 456
437 if (ind < 0) { 457 if (ind < 0) {
@@ -494,8 +514,6 @@ int mthca_tavor_post_srq_recv(struct ib_srq *ibsrq, struct ib_recv_wr *wr,
494 } 514 }
495 515
496 if (likely(nreq)) { 516 if (likely(nreq)) {
497 __be32 doorbell[2];
498
499 doorbell[0] = cpu_to_be32(first_ind << srq->wqe_shift); 517 doorbell[0] = cpu_to_be32(first_ind << srq->wqe_shift);
500 doorbell[1] = cpu_to_be32((srq->srqn << 8) | nreq); 518 doorbell[1] = cpu_to_be32((srq->srqn << 8) | nreq);
501 519
diff --git a/drivers/infiniband/hw/mthca/mthca_wqe.h b/drivers/infiniband/hw/mthca/mthca_wqe.h
index 1f4c0ff28f79..e7d2c1e86199 100644
--- a/drivers/infiniband/hw/mthca/mthca_wqe.h
+++ b/drivers/infiniband/hw/mthca/mthca_wqe.h
@@ -49,7 +49,9 @@ enum {
49}; 49};
50 50
51enum { 51enum {
52 MTHCA_INVAL_LKEY = 0x100 52 MTHCA_INVAL_LKEY = 0x100,
53 MTHCA_TAVOR_MAX_WQES_PER_RECV_DB = 256,
54 MTHCA_ARBEL_MAX_WQES_PER_SEND_DB = 255
53}; 55};
54 56
55struct mthca_next_seg { 57struct mthca_next_seg {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index 0095acc0fbbe..9923a15a9996 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -179,6 +179,7 @@ struct ipoib_dev_priv {
179#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 179#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
180 struct list_head fs_list; 180 struct list_head fs_list;
181 struct dentry *mcg_dentry; 181 struct dentry *mcg_dentry;
182 struct dentry *path_dentry;
182#endif 183#endif
183}; 184};
184 185
@@ -270,7 +271,6 @@ void ipoib_mcast_dev_flush(struct net_device *dev);
270 271
271#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 272#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
272struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev); 273struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev);
273void ipoib_mcast_iter_free(struct ipoib_mcast_iter *iter);
274int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter); 274int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter);
275void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter, 275void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
276 union ib_gid *gid, 276 union ib_gid *gid,
@@ -278,6 +278,11 @@ void ipoib_mcast_iter_read(struct ipoib_mcast_iter *iter,
278 unsigned int *queuelen, 278 unsigned int *queuelen,
279 unsigned int *complete, 279 unsigned int *complete,
280 unsigned int *send_only); 280 unsigned int *send_only);
281
282struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev);
283int ipoib_path_iter_next(struct ipoib_path_iter *iter);
284void ipoib_path_iter_read(struct ipoib_path_iter *iter,
285 struct ipoib_path *path);
281#endif 286#endif
282 287
283int ipoib_mcast_attach(struct net_device *dev, u16 mlid, 288int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
@@ -299,13 +304,13 @@ void ipoib_pkey_poll(void *dev);
299int ipoib_pkey_dev_delay_open(struct net_device *dev); 304int ipoib_pkey_dev_delay_open(struct net_device *dev);
300 305
301#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 306#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
302int ipoib_create_debug_file(struct net_device *dev); 307void ipoib_create_debug_files(struct net_device *dev);
303void ipoib_delete_debug_file(struct net_device *dev); 308void ipoib_delete_debug_files(struct net_device *dev);
304int ipoib_register_debugfs(void); 309int ipoib_register_debugfs(void);
305void ipoib_unregister_debugfs(void); 310void ipoib_unregister_debugfs(void);
306#else 311#else
307static inline int ipoib_create_debug_file(struct net_device *dev) { return 0; } 312static inline void ipoib_create_debug_files(struct net_device *dev) { }
308static inline void ipoib_delete_debug_file(struct net_device *dev) { } 313static inline void ipoib_delete_debug_files(struct net_device *dev) { }
309static inline int ipoib_register_debugfs(void) { return 0; } 314static inline int ipoib_register_debugfs(void) { return 0; }
310static inline void ipoib_unregister_debugfs(void) { } 315static inline void ipoib_unregister_debugfs(void) { }
311#endif 316#endif
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
index 38b150f775e7..685258e34034 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
@@ -43,6 +43,18 @@ struct file_operations;
43 43
44static struct dentry *ipoib_root; 44static struct dentry *ipoib_root;
45 45
46static void format_gid(union ib_gid *gid, char *buf)
47{
48 int i, n;
49
50 for (n = 0, i = 0; i < 8; ++i) {
51 n += sprintf(buf + n, "%x",
52 be16_to_cpu(((__be16 *) gid->raw)[i]));
53 if (i < 7)
54 buf[n++] = ':';
55 }
56}
57
46static void *ipoib_mcg_seq_start(struct seq_file *file, loff_t *pos) 58static void *ipoib_mcg_seq_start(struct seq_file *file, loff_t *pos)
47{ 59{
48 struct ipoib_mcast_iter *iter; 60 struct ipoib_mcast_iter *iter;
@@ -54,7 +66,7 @@ static void *ipoib_mcg_seq_start(struct seq_file *file, loff_t *pos)
54 66
55 while (n--) { 67 while (n--) {
56 if (ipoib_mcast_iter_next(iter)) { 68 if (ipoib_mcast_iter_next(iter)) {
57 ipoib_mcast_iter_free(iter); 69 kfree(iter);
58 return NULL; 70 return NULL;
59 } 71 }
60 } 72 }
@@ -70,7 +82,7 @@ static void *ipoib_mcg_seq_next(struct seq_file *file, void *iter_ptr,
70 (*pos)++; 82 (*pos)++;
71 83
72 if (ipoib_mcast_iter_next(iter)) { 84 if (ipoib_mcast_iter_next(iter)) {
73 ipoib_mcast_iter_free(iter); 85 kfree(iter);
74 return NULL; 86 return NULL;
75 } 87 }
76 88
@@ -87,32 +99,32 @@ static int ipoib_mcg_seq_show(struct seq_file *file, void *iter_ptr)
87 struct ipoib_mcast_iter *iter = iter_ptr; 99 struct ipoib_mcast_iter *iter = iter_ptr;
88 char gid_buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"]; 100 char gid_buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
89 union ib_gid mgid; 101 union ib_gid mgid;
90 int i, n;
91 unsigned long created; 102 unsigned long created;
92 unsigned int queuelen, complete, send_only; 103 unsigned int queuelen, complete, send_only;
93 104
94 if (iter) { 105 if (!iter)
95 ipoib_mcast_iter_read(iter, &mgid, &created, &queuelen, 106 return 0;
96 &complete, &send_only);
97 107
98 for (n = 0, i = 0; i < sizeof mgid / 2; ++i) { 108 ipoib_mcast_iter_read(iter, &mgid, &created, &queuelen,
99 n += sprintf(gid_buf + n, "%x", 109 &complete, &send_only);
100 be16_to_cpu(((__be16 *) mgid.raw)[i]));
101 if (i < sizeof mgid / 2 - 1)
102 gid_buf[n++] = ':';
103 }
104 }
105 110
106 seq_printf(file, "GID: %*s", -(1 + (int) sizeof gid_buf), gid_buf); 111 format_gid(&mgid, gid_buf);
107 112
108 seq_printf(file, 113 seq_printf(file,
109 " created: %10ld queuelen: %4d complete: %d send_only: %d\n", 114 "GID: %s\n"
110 created, queuelen, complete, send_only); 115 " created: %10ld\n"
116 " queuelen: %9d\n"
117 " complete: %9s\n"
118 " send_only: %8s\n"
119 "\n",
120 gid_buf, created, queuelen,
121 complete ? "yes" : "no",
122 send_only ? "yes" : "no");
111 123
112 return 0; 124 return 0;
113} 125}
114 126
115static struct seq_operations ipoib_seq_ops = { 127static struct seq_operations ipoib_mcg_seq_ops = {
116 .start = ipoib_mcg_seq_start, 128 .start = ipoib_mcg_seq_start,
117 .next = ipoib_mcg_seq_next, 129 .next = ipoib_mcg_seq_next,
118 .stop = ipoib_mcg_seq_stop, 130 .stop = ipoib_mcg_seq_stop,
@@ -124,7 +136,7 @@ static int ipoib_mcg_open(struct inode *inode, struct file *file)
124 struct seq_file *seq; 136 struct seq_file *seq;
125 int ret; 137 int ret;
126 138
127 ret = seq_open(file, &ipoib_seq_ops); 139 ret = seq_open(file, &ipoib_mcg_seq_ops);
128 if (ret) 140 if (ret)
129 return ret; 141 return ret;
130 142
@@ -134,7 +146,7 @@ static int ipoib_mcg_open(struct inode *inode, struct file *file)
134 return 0; 146 return 0;
135} 147}
136 148
137static struct file_operations ipoib_fops = { 149static struct file_operations ipoib_mcg_fops = {
138 .owner = THIS_MODULE, 150 .owner = THIS_MODULE,
139 .open = ipoib_mcg_open, 151 .open = ipoib_mcg_open,
140 .read = seq_read, 152 .read = seq_read,
@@ -142,25 +154,138 @@ static struct file_operations ipoib_fops = {
142 .release = seq_release 154 .release = seq_release
143}; 155};
144 156
145int ipoib_create_debug_file(struct net_device *dev) 157static void *ipoib_path_seq_start(struct seq_file *file, loff_t *pos)
158{
159 struct ipoib_path_iter *iter;
160 loff_t n = *pos;
161
162 iter = ipoib_path_iter_init(file->private);
163 if (!iter)
164 return NULL;
165
166 while (n--) {
167 if (ipoib_path_iter_next(iter)) {
168 kfree(iter);
169 return NULL;
170 }
171 }
172
173 return iter;
174}
175
176static void *ipoib_path_seq_next(struct seq_file *file, void *iter_ptr,
177 loff_t *pos)
178{
179 struct ipoib_path_iter *iter = iter_ptr;
180
181 (*pos)++;
182
183 if (ipoib_path_iter_next(iter)) {
184 kfree(iter);
185 return NULL;
186 }
187
188 return iter;
189}
190
191static void ipoib_path_seq_stop(struct seq_file *file, void *iter_ptr)
192{
193 /* nothing for now */
194}
195
196static int ipoib_path_seq_show(struct seq_file *file, void *iter_ptr)
197{
198 struct ipoib_path_iter *iter = iter_ptr;
199 char gid_buf[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
200 struct ipoib_path path;
201 int rate;
202
203 if (!iter)
204 return 0;
205
206 ipoib_path_iter_read(iter, &path);
207
208 format_gid(&path.pathrec.dgid, gid_buf);
209
210 seq_printf(file,
211 "GID: %s\n"
212 " complete: %6s\n",
213 gid_buf, path.pathrec.dlid ? "yes" : "no");
214
215 if (path.pathrec.dlid) {
216 rate = ib_sa_rate_enum_to_int(path.pathrec.rate) * 25;
217
218 seq_printf(file,
219 " DLID: 0x%04x\n"
220 " SL: %12d\n"
221 " rate: %*d%s Gb/sec\n",
222 be16_to_cpu(path.pathrec.dlid),
223 path.pathrec.sl,
224 10 - ((rate % 10) ? 2 : 0),
225 rate / 10, rate % 10 ? ".5" : "");
226 }
227
228 seq_putc(file, '\n');
229
230 return 0;
231}
232
233static struct seq_operations ipoib_path_seq_ops = {
234 .start = ipoib_path_seq_start,
235 .next = ipoib_path_seq_next,
236 .stop = ipoib_path_seq_stop,
237 .show = ipoib_path_seq_show,
238};
239
240static int ipoib_path_open(struct inode *inode, struct file *file)
241{
242 struct seq_file *seq;
243 int ret;
244
245 ret = seq_open(file, &ipoib_path_seq_ops);
246 if (ret)
247 return ret;
248
249 seq = file->private_data;
250 seq->private = inode->u.generic_ip;
251
252 return 0;
253}
254
255static struct file_operations ipoib_path_fops = {
256 .owner = THIS_MODULE,
257 .open = ipoib_path_open,
258 .read = seq_read,
259 .llseek = seq_lseek,
260 .release = seq_release
261};
262
263void ipoib_create_debug_files(struct net_device *dev)
146{ 264{
147 struct ipoib_dev_priv *priv = netdev_priv(dev); 265 struct ipoib_dev_priv *priv = netdev_priv(dev);
148 char name[IFNAMSIZ + sizeof "_mcg"]; 266 char name[IFNAMSIZ + sizeof "_path"];
149 267
150 snprintf(name, sizeof name, "%s_mcg", dev->name); 268 snprintf(name, sizeof name, "%s_mcg", dev->name);
151
152 priv->mcg_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO, 269 priv->mcg_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
153 ipoib_root, dev, &ipoib_fops); 270 ipoib_root, dev, &ipoib_mcg_fops);
154 271 if (!priv->mcg_dentry)
155 return priv->mcg_dentry ? 0 : -ENOMEM; 272 ipoib_warn(priv, "failed to create mcg debug file\n");
273
274 snprintf(name, sizeof name, "%s_path", dev->name);
275 priv->path_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
276 ipoib_root, dev, &ipoib_path_fops);
277 if (!priv->path_dentry)
278 ipoib_warn(priv, "failed to create path debug file\n");
156} 279}
157 280
158void ipoib_delete_debug_file(struct net_device *dev) 281void ipoib_delete_debug_files(struct net_device *dev)
159{ 282{
160 struct ipoib_dev_priv *priv = netdev_priv(dev); 283 struct ipoib_dev_priv *priv = netdev_priv(dev);
161 284
162 if (priv->mcg_dentry) 285 if (priv->mcg_dentry)
163 debugfs_remove(priv->mcg_dentry); 286 debugfs_remove(priv->mcg_dentry);
287 if (priv->path_dentry)
288 debugfs_remove(priv->path_dentry);
164} 289}
165 290
166int ipoib_register_debugfs(void) 291int ipoib_register_debugfs(void)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index 54ef2fea530f..23885801b6d2 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -608,9 +608,13 @@ void ipoib_ib_dev_flush(void *_dev)
608 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) 608 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags))
609 ipoib_ib_dev_up(dev); 609 ipoib_ib_dev_up(dev);
610 610
611 down(&priv->vlan_mutex);
612
611 /* Flush any child interfaces too */ 613 /* Flush any child interfaces too */
612 list_for_each_entry(cpriv, &priv->child_intfs, list) 614 list_for_each_entry(cpriv, &priv->child_intfs, list)
613 ipoib_ib_dev_flush(&cpriv->dev); 615 ipoib_ib_dev_flush(&cpriv->dev);
616
617 up(&priv->vlan_mutex);
614} 618}
615 619
616void ipoib_ib_dev_cleanup(struct net_device *dev) 620void ipoib_ib_dev_cleanup(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index ce0296273e76..475d98fa9e26 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -58,6 +58,11 @@ module_param_named(debug_level, ipoib_debug_level, int, 0644);
58MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0"); 58MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
59#endif 59#endif
60 60
61struct ipoib_path_iter {
62 struct net_device *dev;
63 struct ipoib_path path;
64};
65
61static const u8 ipv4_bcast_addr[] = { 66static const u8 ipv4_bcast_addr[] = {
62 0x00, 0xff, 0xff, 0xff, 67 0x00, 0xff, 0xff, 0xff,
63 0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00, 68 0xff, 0x12, 0x40, 0x1b, 0x00, 0x00, 0x00, 0x00,
@@ -89,8 +94,10 @@ int ipoib_open(struct net_device *dev)
89 if (ipoib_ib_dev_open(dev)) 94 if (ipoib_ib_dev_open(dev))
90 return -EINVAL; 95 return -EINVAL;
91 96
92 if (ipoib_ib_dev_up(dev)) 97 if (ipoib_ib_dev_up(dev)) {
98 ipoib_ib_dev_stop(dev);
93 return -EINVAL; 99 return -EINVAL;
100 }
94 101
95 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) { 102 if (!test_bit(IPOIB_FLAG_SUBINTERFACE, &priv->flags)) {
96 struct ipoib_dev_priv *cpriv; 103 struct ipoib_dev_priv *cpriv;
@@ -250,6 +257,64 @@ static void path_free(struct net_device *dev, struct ipoib_path *path)
250 kfree(path); 257 kfree(path);
251} 258}
252 259
260#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
261
262struct ipoib_path_iter *ipoib_path_iter_init(struct net_device *dev)
263{
264 struct ipoib_path_iter *iter;
265
266 iter = kmalloc(sizeof *iter, GFP_KERNEL);
267 if (!iter)
268 return NULL;
269
270 iter->dev = dev;
271 memset(iter->path.pathrec.dgid.raw, 0, 16);
272
273 if (ipoib_path_iter_next(iter)) {
274 kfree(iter);
275 return NULL;
276 }
277
278 return iter;
279}
280
281int ipoib_path_iter_next(struct ipoib_path_iter *iter)
282{
283 struct ipoib_dev_priv *priv = netdev_priv(iter->dev);
284 struct rb_node *n;
285 struct ipoib_path *path;
286 int ret = 1;
287
288 spin_lock_irq(&priv->lock);
289
290 n = rb_first(&priv->path_tree);
291
292 while (n) {
293 path = rb_entry(n, struct ipoib_path, rb_node);
294
295 if (memcmp(iter->path.pathrec.dgid.raw, path->pathrec.dgid.raw,
296 sizeof (union ib_gid)) < 0) {
297 iter->path = *path;
298 ret = 0;
299 break;
300 }
301
302 n = rb_next(n);
303 }
304
305 spin_unlock_irq(&priv->lock);
306
307 return ret;
308}
309
310void ipoib_path_iter_read(struct ipoib_path_iter *iter,
311 struct ipoib_path *path)
312{
313 *path = iter->path;
314}
315
316#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
317
253void ipoib_flush_paths(struct net_device *dev) 318void ipoib_flush_paths(struct net_device *dev)
254{ 319{
255 struct ipoib_dev_priv *priv = netdev_priv(dev); 320 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -335,9 +400,9 @@ static void path_rec_completion(int status,
335 while ((skb = __skb_dequeue(&neigh->queue))) 400 while ((skb = __skb_dequeue(&neigh->queue)))
336 __skb_queue_tail(&skqueue, skb); 401 __skb_queue_tail(&skqueue, skb);
337 } 402 }
338 } else 403 }
339 path->query = NULL;
340 404
405 path->query = NULL;
341 complete(&path->done); 406 complete(&path->done);
342 407
343 spin_unlock_irqrestore(&priv->lock, flags); 408 spin_unlock_irqrestore(&priv->lock, flags);
@@ -365,7 +430,6 @@ static struct ipoib_path *path_rec_create(struct net_device *dev,
365 skb_queue_head_init(&path->queue); 430 skb_queue_head_init(&path->queue);
366 431
367 INIT_LIST_HEAD(&path->neigh_list); 432 INIT_LIST_HEAD(&path->neigh_list);
368 init_completion(&path->done);
369 433
370 memcpy(path->pathrec.dgid.raw, gid->raw, sizeof (union ib_gid)); 434 memcpy(path->pathrec.dgid.raw, gid->raw, sizeof (union ib_gid));
371 path->pathrec.sgid = priv->local_gid; 435 path->pathrec.sgid = priv->local_gid;
@@ -383,6 +447,8 @@ static int path_rec_start(struct net_device *dev,
383 ipoib_dbg(priv, "Start path record lookup for " IPOIB_GID_FMT "\n", 447 ipoib_dbg(priv, "Start path record lookup for " IPOIB_GID_FMT "\n",
384 IPOIB_GID_ARG(path->pathrec.dgid)); 448 IPOIB_GID_ARG(path->pathrec.dgid));
385 449
450 init_completion(&path->done);
451
386 path->query_id = 452 path->query_id =
387 ib_sa_path_rec_get(priv->ca, priv->port, 453 ib_sa_path_rec_get(priv->ca, priv->port,
388 &path->pathrec, 454 &path->pathrec,
@@ -763,7 +829,7 @@ void ipoib_dev_cleanup(struct net_device *dev)
763{ 829{
764 struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv, *tcpriv; 830 struct ipoib_dev_priv *priv = netdev_priv(dev), *cpriv, *tcpriv;
765 831
766 ipoib_delete_debug_file(dev); 832 ipoib_delete_debug_files(dev);
767 833
768 /* Delete any child interfaces first */ 834 /* Delete any child interfaces first */
769 list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) { 835 list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) {
@@ -972,8 +1038,7 @@ static struct net_device *ipoib_add_port(const char *format,
972 goto register_failed; 1038 goto register_failed;
973 } 1039 }
974 1040
975 if (ipoib_create_debug_file(priv->dev)) 1041 ipoib_create_debug_files(priv->dev);
976 goto debug_failed;
977 1042
978 if (ipoib_add_pkey_attr(priv->dev)) 1043 if (ipoib_add_pkey_attr(priv->dev))
979 goto sysfs_failed; 1044 goto sysfs_failed;
@@ -987,9 +1052,7 @@ static struct net_device *ipoib_add_port(const char *format,
987 return priv->dev; 1052 return priv->dev;
988 1053
989sysfs_failed: 1054sysfs_failed:
990 ipoib_delete_debug_file(priv->dev); 1055 ipoib_delete_debug_files(priv->dev);
991
992debug_failed:
993 unregister_netdev(priv->dev); 1056 unregister_netdev(priv->dev);
994 1057
995register_failed: 1058register_failed:
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index 3ecf78a9493a..ef3ee035bbc8 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -120,12 +120,8 @@ static void ipoib_mcast_free(struct ipoib_mcast *mcast)
120 if (mcast->ah) 120 if (mcast->ah)
121 ipoib_put_ah(mcast->ah); 121 ipoib_put_ah(mcast->ah);
122 122
123 while (!skb_queue_empty(&mcast->pkt_queue)) { 123 while (!skb_queue_empty(&mcast->pkt_queue))
124 struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue); 124 dev_kfree_skb_any(skb_dequeue(&mcast->pkt_queue));
125
126 skb->dev = dev;
127 dev_kfree_skb_any(skb);
128 }
129 125
130 kfree(mcast); 126 kfree(mcast);
131} 127}
@@ -139,20 +135,14 @@ static struct ipoib_mcast *ipoib_mcast_alloc(struct net_device *dev,
139 if (!mcast) 135 if (!mcast)
140 return NULL; 136 return NULL;
141 137
142 init_completion(&mcast->done);
143
144 mcast->dev = dev; 138 mcast->dev = dev;
145 mcast->created = jiffies; 139 mcast->created = jiffies;
146 mcast->backoff = 1; 140 mcast->backoff = 1;
147 mcast->logcount = 0;
148 141
149 INIT_LIST_HEAD(&mcast->list); 142 INIT_LIST_HEAD(&mcast->list);
150 INIT_LIST_HEAD(&mcast->neigh_list); 143 INIT_LIST_HEAD(&mcast->neigh_list);
151 skb_queue_head_init(&mcast->pkt_queue); 144 skb_queue_head_init(&mcast->pkt_queue);
152 145
153 mcast->ah = NULL;
154 mcast->query = NULL;
155
156 return mcast; 146 return mcast;
157} 147}
158 148
@@ -317,13 +307,8 @@ ipoib_mcast_sendonly_join_complete(int status,
317 IPOIB_GID_ARG(mcast->mcmember.mgid), status); 307 IPOIB_GID_ARG(mcast->mcmember.mgid), status);
318 308
319 /* Flush out any queued packets */ 309 /* Flush out any queued packets */
320 while (!skb_queue_empty(&mcast->pkt_queue)) { 310 while (!skb_queue_empty(&mcast->pkt_queue))
321 struct sk_buff *skb = skb_dequeue(&mcast->pkt_queue); 311 dev_kfree_skb_any(skb_dequeue(&mcast->pkt_queue));
322
323 skb->dev = dev;
324
325 dev_kfree_skb_any(skb);
326 }
327 312
328 /* Clear the busy flag so we try again */ 313 /* Clear the busy flag so we try again */
329 clear_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags); 314 clear_bit(IPOIB_MCAST_FLAG_BUSY, &mcast->flags);
@@ -359,6 +344,8 @@ static int ipoib_mcast_sendonly_join(struct ipoib_mcast *mcast)
359 rec.port_gid = priv->local_gid; 344 rec.port_gid = priv->local_gid;
360 rec.pkey = cpu_to_be16(priv->pkey); 345 rec.pkey = cpu_to_be16(priv->pkey);
361 346
347 init_completion(&mcast->done);
348
362 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec, 349 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec,
363 IB_SA_MCMEMBER_REC_MGID | 350 IB_SA_MCMEMBER_REC_MGID |
364 IB_SA_MCMEMBER_REC_PORT_GID | 351 IB_SA_MCMEMBER_REC_PORT_GID |
@@ -478,6 +465,8 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
478 rec.traffic_class = priv->broadcast->mcmember.traffic_class; 465 rec.traffic_class = priv->broadcast->mcmember.traffic_class;
479 } 466 }
480 467
468 init_completion(&mcast->done);
469
481 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec, comp_mask, 470 ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec, comp_mask,
482 mcast->backoff * 1000, GFP_ATOMIC, 471 mcast->backoff * 1000, GFP_ATOMIC,
483 ipoib_mcast_join_complete, 472 ipoib_mcast_join_complete,
@@ -928,21 +917,16 @@ struct ipoib_mcast_iter *ipoib_mcast_iter_init(struct net_device *dev)
928 return NULL; 917 return NULL;
929 918
930 iter->dev = dev; 919 iter->dev = dev;
931 memset(iter->mgid.raw, 0, sizeof iter->mgid); 920 memset(iter->mgid.raw, 0, 16);
932 921
933 if (ipoib_mcast_iter_next(iter)) { 922 if (ipoib_mcast_iter_next(iter)) {
934 ipoib_mcast_iter_free(iter); 923 kfree(iter);
935 return NULL; 924 return NULL;
936 } 925 }
937 926
938 return iter; 927 return iter;
939} 928}
940 929
941void ipoib_mcast_iter_free(struct ipoib_mcast_iter *iter)
942{
943 kfree(iter);
944}
945
946int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter) 930int ipoib_mcast_iter_next(struct ipoib_mcast_iter *iter)
947{ 931{
948 struct ipoib_dev_priv *priv = netdev_priv(iter->dev); 932 struct ipoib_dev_priv *priv = netdev_priv(iter->dev);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 332d730e60c2..d280b341a37f 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -113,8 +113,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
113 113
114 priv->parent = ppriv->dev; 114 priv->parent = ppriv->dev;
115 115
116 if (ipoib_create_debug_file(priv->dev)) 116 ipoib_create_debug_files(priv->dev);
117 goto debug_failed;
118 117
119 if (ipoib_add_pkey_attr(priv->dev)) 118 if (ipoib_add_pkey_attr(priv->dev))
120 goto sysfs_failed; 119 goto sysfs_failed;
@@ -130,9 +129,7 @@ int ipoib_vlan_add(struct net_device *pdev, unsigned short pkey)
130 return 0; 129 return 0;
131 130
132sysfs_failed: 131sysfs_failed:
133 ipoib_delete_debug_file(priv->dev); 132 ipoib_delete_debug_files(priv->dev);
134
135debug_failed:
136 unregister_netdev(priv->dev); 133 unregister_netdev(priv->dev);
137 134
138register_failed: 135register_failed:
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 321a3a10e69b..ee9fe226ae99 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -802,13 +802,21 @@ static int srp_post_recv(struct srp_target_port *target)
802 802
803/* 803/*
804 * Must be called with target->scsi_host->host_lock held to protect 804 * Must be called with target->scsi_host->host_lock held to protect
805 * req_lim and tx_head. 805 * req_lim and tx_head. Lock cannot be dropped between call here and
806 * call to __srp_post_send().
806 */ 807 */
807static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target) 808static struct srp_iu *__srp_get_tx_iu(struct srp_target_port *target)
808{ 809{
809 if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE) 810 if (target->tx_head - target->tx_tail >= SRP_SQ_SIZE)
810 return NULL; 811 return NULL;
811 812
813 if (unlikely(target->req_lim < 1)) {
814 if (printk_ratelimit())
815 printk(KERN_DEBUG PFX "Target has req_lim %d\n",
816 target->req_lim);
817 return NULL;
818 }
819
812 return target->tx_ring[target->tx_head & SRP_SQ_SIZE]; 820 return target->tx_ring[target->tx_head & SRP_SQ_SIZE];
813} 821}
814 822
@@ -823,11 +831,6 @@ static int __srp_post_send(struct srp_target_port *target,
823 struct ib_send_wr wr, *bad_wr; 831 struct ib_send_wr wr, *bad_wr;
824 int ret = 0; 832 int ret = 0;
825 833
826 if (target->req_lim < 1) {
827 printk(KERN_ERR PFX "Target has req_lim %d\n", target->req_lim);
828 return -EAGAIN;
829 }
830
831 list.addr = iu->dma; 834 list.addr = iu->dma;
832 list.length = len; 835 list.length = len;
833 list.lkey = target->srp_host->mr->lkey; 836 list.lkey = target->srp_host->mr->lkey;
@@ -1417,6 +1420,8 @@ static ssize_t srp_create_target(struct class_device *class_dev,
1417 if (!target_host) 1420 if (!target_host)
1418 return -ENOMEM; 1421 return -ENOMEM;
1419 1422
1423 target_host->max_lun = SRP_MAX_LUN;
1424
1420 target = host_to_target(target_host); 1425 target = host_to_target(target_host);
1421 memset(target, 0, sizeof *target); 1426 memset(target, 0, sizeof *target);
1422 1427
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 4fec28a71367..b564f18caf78 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -54,6 +54,7 @@ enum {
54 SRP_PORT_REDIRECT = 1, 54 SRP_PORT_REDIRECT = 1,
55 SRP_DLID_REDIRECT = 2, 55 SRP_DLID_REDIRECT = 2,
56 56
57 SRP_MAX_LUN = 512,
57 SRP_MAX_IU_LEN = 256, 58 SRP_MAX_IU_LEN = 256,
58 59
59 SRP_RQ_SHIFT = 6, 60 SRP_RQ_SHIFT = 6,
diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
index 0506934244f0..caac6d63d46f 100644
--- a/drivers/input/gameport/gameport.c
+++ b/drivers/input/gameport/gameport.c
@@ -339,14 +339,20 @@ static struct gameport_event *gameport_get_event(void)
339 return event; 339 return event;
340} 340}
341 341
342static void gameport_handle_events(void) 342static void gameport_handle_event(void)
343{ 343{
344 struct gameport_event *event; 344 struct gameport_event *event;
345 struct gameport_driver *gameport_drv; 345 struct gameport_driver *gameport_drv;
346 346
347 down(&gameport_sem); 347 down(&gameport_sem);
348 348
349 while ((event = gameport_get_event())) { 349 /*
350 * Note that we handle only one event here to give swsusp
351 * a chance to freeze kgameportd thread. Gameport events
352 * should be pretty rare so we are not concerned about
353 * taking performance hit.
354 */
355 if ((event = gameport_get_event())) {
350 356
351 switch (event->type) { 357 switch (event->type) {
352 case GAMEPORT_REGISTER_PORT: 358 case GAMEPORT_REGISTER_PORT:
@@ -433,7 +439,7 @@ static struct gameport *gameport_get_pending_child(struct gameport *parent)
433static int gameport_thread(void *nothing) 439static int gameport_thread(void *nothing)
434{ 440{
435 do { 441 do {
436 gameport_handle_events(); 442 gameport_handle_event();
437 wait_event_interruptible(gameport_wait, 443 wait_event_interruptible(gameport_wait,
438 kthread_should_stop() || !list_empty(&gameport_event_list)); 444 kthread_should_stop() || !list_empty(&gameport_event_list));
439 try_to_freeze(); 445 try_to_freeze();
diff --git a/drivers/input/input.c b/drivers/input/input.c
index c8ae2bb054e0..bdd2a7fc268d 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -536,7 +536,7 @@ static struct attribute *input_dev_attrs[] = {
536 NULL 536 NULL
537}; 537};
538 538
539static struct attribute_group input_dev_group = { 539static struct attribute_group input_dev_attr_group = {
540 .attrs = input_dev_attrs, 540 .attrs = input_dev_attrs,
541}; 541};
542 542
@@ -717,35 +717,14 @@ struct input_dev *input_allocate_device(void)
717 return dev; 717 return dev;
718} 718}
719 719
720static void input_register_classdevice(struct input_dev *dev)
721{
722 static atomic_t input_no = ATOMIC_INIT(0);
723 const char *path;
724
725 __module_get(THIS_MODULE);
726
727 dev->dev = dev->cdev.dev;
728
729 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id),
730 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
731
732 path = kobject_get_path(&dev->cdev.class->subsys.kset.kobj, GFP_KERNEL);
733 printk(KERN_INFO "input: %s as %s/%s\n",
734 dev->name ? dev->name : "Unspecified device",
735 path ? path : "", dev->cdev.class_id);
736 kfree(path);
737
738 class_device_add(&dev->cdev);
739 sysfs_create_group(&dev->cdev.kobj, &input_dev_group);
740 sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group);
741 sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
742}
743
744int input_register_device(struct input_dev *dev) 720int input_register_device(struct input_dev *dev)
745{ 721{
722 static atomic_t input_no = ATOMIC_INIT(0);
746 struct input_handle *handle; 723 struct input_handle *handle;
747 struct input_handler *handler; 724 struct input_handler *handler;
748 struct input_device_id *id; 725 struct input_device_id *id;
726 const char *path;
727 int error;
749 728
750 if (!dev->dynalloc) { 729 if (!dev->dynalloc) {
751 printk(KERN_WARNING "input: device %s is statically allocated, will not register\n" 730 printk(KERN_WARNING "input: device %s is statically allocated, will not register\n"
@@ -773,7 +752,32 @@ int input_register_device(struct input_dev *dev)
773 INIT_LIST_HEAD(&dev->h_list); 752 INIT_LIST_HEAD(&dev->h_list);
774 list_add_tail(&dev->node, &input_dev_list); 753 list_add_tail(&dev->node, &input_dev_list);
775 754
776 input_register_classdevice(dev); 755 dev->cdev.class = &input_class;
756 snprintf(dev->cdev.class_id, sizeof(dev->cdev.class_id),
757 "input%ld", (unsigned long) atomic_inc_return(&input_no) - 1);
758
759 error = class_device_add(&dev->cdev);
760 if (error)
761 return error;
762
763 error = sysfs_create_group(&dev->cdev.kobj, &input_dev_attr_group);
764 if (error)
765 goto fail1;
766
767 error = sysfs_create_group(&dev->cdev.kobj, &input_dev_id_attr_group);
768 if (error)
769 goto fail2;
770
771 error = sysfs_create_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
772 if (error)
773 goto fail3;
774
775 __module_get(THIS_MODULE);
776
777 path = kobject_get_path(&dev->cdev.kobj, GFP_KERNEL);
778 printk(KERN_INFO "input: %s as %s\n",
779 dev->name ? dev->name : "Unspecified device", path ? path : "N/A");
780 kfree(path);
777 781
778 list_for_each_entry(handler, &input_handler_list, node) 782 list_for_each_entry(handler, &input_handler_list, node)
779 if (!handler->blacklist || !input_match_device(handler->blacklist, dev)) 783 if (!handler->blacklist || !input_match_device(handler->blacklist, dev))
@@ -784,6 +788,11 @@ int input_register_device(struct input_dev *dev)
784 input_wakeup_procfs_readers(); 788 input_wakeup_procfs_readers();
785 789
786 return 0; 790 return 0;
791
792 fail3: sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
793 fail2: sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
794 fail1: class_device_del(&dev->cdev);
795 return error;
787} 796}
788 797
789void input_unregister_device(struct input_dev *dev) 798void input_unregister_device(struct input_dev *dev)
@@ -805,7 +814,7 @@ void input_unregister_device(struct input_dev *dev)
805 814
806 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group); 815 sysfs_remove_group(&dev->cdev.kobj, &input_dev_caps_attr_group);
807 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group); 816 sysfs_remove_group(&dev->cdev.kobj, &input_dev_id_attr_group);
808 sysfs_remove_group(&dev->cdev.kobj, &input_dev_group); 817 sysfs_remove_group(&dev->cdev.kobj, &input_dev_attr_group);
809 class_device_unregister(&dev->cdev); 818 class_device_unregister(&dev->cdev);
810 819
811 input_wakeup_procfs_readers(); 820 input_wakeup_procfs_readers();
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/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c
index 820c7fd9a604..a0256f8de8ef 100644
--- a/drivers/input/keyboard/atkbd.c
+++ b/drivers/input/keyboard/atkbd.c
@@ -166,6 +166,9 @@ static unsigned char atkbd_unxlate_table[128] = {
166 166
167#define ATKBD_SPECIAL 248 167#define ATKBD_SPECIAL 248
168 168
169#define ATKBD_LED_EVENT_BIT 0
170#define ATKBD_REP_EVENT_BIT 1
171
169static struct { 172static struct {
170 unsigned char keycode; 173 unsigned char keycode;
171 unsigned char set2; 174 unsigned char set2;
@@ -211,6 +214,10 @@ struct atkbd {
211 unsigned char err_xl; 214 unsigned char err_xl;
212 unsigned int last; 215 unsigned int last;
213 unsigned long time; 216 unsigned long time;
217
218 struct work_struct event_work;
219 struct semaphore event_sem;
220 unsigned long event_mask;
214}; 221};
215 222
216static ssize_t atkbd_attr_show_helper(struct device *dev, char *buf, 223static ssize_t atkbd_attr_show_helper(struct device *dev, char *buf,
@@ -424,58 +431,86 @@ out:
424} 431}
425 432
426/* 433/*
427 * Event callback from the input module. Events that change the state of 434 * atkbd_event_work() is used to complete processing of events that
428 * the hardware are processed here. 435 * can not be processed by input_event() which is often called from
436 * interrupt context.
429 */ 437 */
430 438
431static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 439static void atkbd_event_work(void *data)
432{ 440{
433 struct atkbd *atkbd = dev->private;
434 const short period[32] = 441 const short period[32] =
435 { 33, 37, 42, 46, 50, 54, 58, 63, 67, 75, 83, 92, 100, 109, 116, 125, 442 { 33, 37, 42, 46, 50, 54, 58, 63, 67, 75, 83, 92, 100, 109, 116, 125,
436 133, 149, 167, 182, 200, 217, 232, 250, 270, 303, 333, 370, 400, 435, 470, 500 }; 443 133, 149, 167, 182, 200, 217, 232, 250, 270, 303, 333, 370, 400, 435, 470, 500 };
437 const short delay[4] = 444 const short delay[4] =
438 { 250, 500, 750, 1000 }; 445 { 250, 500, 750, 1000 };
446
447 struct atkbd *atkbd = data;
448 struct input_dev *dev = atkbd->dev;
439 unsigned char param[2]; 449 unsigned char param[2];
440 int i, j; 450 int i, j;
441 451
452 down(&atkbd->event_sem);
453
454 if (test_and_clear_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask)) {
455 param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0)
456 | (test_bit(LED_NUML, dev->led) ? 2 : 0)
457 | (test_bit(LED_CAPSL, dev->led) ? 4 : 0);
458 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS);
459
460 if (atkbd->extra) {
461 param[0] = 0;
462 param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0)
463 | (test_bit(LED_SLEEP, dev->led) ? 0x02 : 0)
464 | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0)
465 | (test_bit(LED_MISC, dev->led) ? 0x10 : 0)
466 | (test_bit(LED_MUTE, dev->led) ? 0x20 : 0);
467 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS);
468 }
469 }
470
471 if (test_and_clear_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask)) {
472 i = j = 0;
473 while (i < 31 && period[i] < dev->rep[REP_PERIOD])
474 i++;
475 while (j < 3 && delay[j] < dev->rep[REP_DELAY])
476 j++;
477 dev->rep[REP_PERIOD] = period[i];
478 dev->rep[REP_DELAY] = delay[j];
479 param[0] = i | (j << 5);
480 ps2_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP);
481 }
482
483 up(&atkbd->event_sem);
484}
485
486/*
487 * Event callback from the input module. Events that change the state of
488 * the hardware are processed here. If action can not be performed in
489 * interrupt context it is offloaded to atkbd_event_work.
490 */
491
492static int atkbd_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
493{
494 struct atkbd *atkbd = dev->private;
495
442 if (!atkbd->write) 496 if (!atkbd->write)
443 return -1; 497 return -1;
444 498
445 switch (type) { 499 switch (type) {
446 500
447 case EV_LED: 501 case EV_LED:
448 502 set_bit(ATKBD_LED_EVENT_BIT, &atkbd->event_mask);
449 param[0] = (test_bit(LED_SCROLLL, dev->led) ? 1 : 0) 503 wmb();
450 | (test_bit(LED_NUML, dev->led) ? 2 : 0) 504 schedule_work(&atkbd->event_work);
451 | (test_bit(LED_CAPSL, dev->led) ? 4 : 0);
452 ps2_schedule_command(&atkbd->ps2dev, param, ATKBD_CMD_SETLEDS);
453
454 if (atkbd->extra) {
455 param[0] = 0;
456 param[1] = (test_bit(LED_COMPOSE, dev->led) ? 0x01 : 0)
457 | (test_bit(LED_SLEEP, dev->led) ? 0x02 : 0)
458 | (test_bit(LED_SUSPEND, dev->led) ? 0x04 : 0)
459 | (test_bit(LED_MISC, dev->led) ? 0x10 : 0)
460 | (test_bit(LED_MUTE, dev->led) ? 0x20 : 0);
461 ps2_schedule_command(&atkbd->ps2dev, param, ATKBD_CMD_EX_SETLEDS);
462 }
463
464 return 0; 505 return 0;
465 506
466 case EV_REP: 507 case EV_REP:
467 508
468 if (atkbd->softrepeat) return 0; 509 if (!atkbd->softrepeat) {
469 510 set_bit(ATKBD_REP_EVENT_BIT, &atkbd->event_mask);
470 i = j = 0; 511 wmb();
471 while (i < 31 && period[i] < dev->rep[REP_PERIOD]) 512 schedule_work(&atkbd->event_work);
472 i++; 513 }
473 while (j < 3 && delay[j] < dev->rep[REP_DELAY])
474 j++;
475 dev->rep[REP_PERIOD] = period[i];
476 dev->rep[REP_DELAY] = delay[j];
477 param[0] = i | (j << 5);
478 ps2_schedule_command(&atkbd->ps2dev, param, ATKBD_CMD_SETREP);
479 514
480 return 0; 515 return 0;
481 } 516 }
@@ -810,6 +845,8 @@ static int atkbd_connect(struct serio *serio, struct serio_driver *drv)
810 845
811 atkbd->dev = dev; 846 atkbd->dev = dev;
812 ps2_init(&atkbd->ps2dev, serio); 847 ps2_init(&atkbd->ps2dev, serio);
848 INIT_WORK(&atkbd->event_work, atkbd_event_work, atkbd);
849 init_MUTEX(&atkbd->event_sem);
813 850
814 switch (serio->id.type) { 851 switch (serio->id.type) {
815 852
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c
index d00d14bb637a..64672d491222 100644
--- a/drivers/input/keyboard/corgikbd.c
+++ b/drivers/input/keyboard/corgikbd.c
@@ -259,17 +259,17 @@ static void corgikbd_hinge_timer(unsigned long data)
259} 259}
260 260
261#ifdef CONFIG_PM 261#ifdef CONFIG_PM
262static int corgikbd_suspend(struct device *dev, pm_message_t state) 262static int corgikbd_suspend(struct platform_device *dev, pm_message_t state)
263{ 263{
264 struct corgikbd *corgikbd = dev_get_drvdata(dev); 264 struct corgikbd *corgikbd = platform_get_drvdata(dev);
265 corgikbd->suspended = 1; 265 corgikbd->suspended = 1;
266 266
267 return 0; 267 return 0;
268} 268}
269 269
270static int corgikbd_resume(struct device *dev) 270static int corgikbd_resume(struct platform_device *dev)
271{ 271{
272 struct corgikbd *corgikbd = dev_get_drvdata(dev); 272 struct corgikbd *corgikbd = platform_get_drvdata(dev);
273 273
274 /* Upon resume, ignore the suspend key for a short while */ 274 /* Upon resume, ignore the suspend key for a short while */
275 corgikbd->suspend_jiffies=jiffies; 275 corgikbd->suspend_jiffies=jiffies;
@@ -282,7 +282,7 @@ static int corgikbd_resume(struct device *dev)
282#define corgikbd_resume NULL 282#define corgikbd_resume NULL
283#endif 283#endif
284 284
285static int __init corgikbd_probe(struct device *dev) 285static int __init corgikbd_probe(struct platform_device *pdev)
286{ 286{
287 struct corgikbd *corgikbd; 287 struct corgikbd *corgikbd;
288 struct input_dev *input_dev; 288 struct input_dev *input_dev;
@@ -296,7 +296,7 @@ static int __init corgikbd_probe(struct device *dev)
296 return -ENOMEM; 296 return -ENOMEM;
297 } 297 }
298 298
299 dev_set_drvdata(dev, corgikbd); 299 platform_set_drvdata(pdev, corgikbd);
300 300
301 corgikbd->input = input_dev; 301 corgikbd->input = input_dev;
302 spin_lock_init(&corgikbd->lock); 302 spin_lock_init(&corgikbd->lock);
@@ -321,7 +321,7 @@ static int __init corgikbd_probe(struct device *dev)
321 input_dev->id.vendor = 0x0001; 321 input_dev->id.vendor = 0x0001;
322 input_dev->id.product = 0x0001; 322 input_dev->id.product = 0x0001;
323 input_dev->id.version = 0x0100; 323 input_dev->id.version = 0x0100;
324 input_dev->cdev.dev = dev; 324 input_dev->cdev.dev = &pdev->dev;
325 input_dev->private = corgikbd; 325 input_dev->private = corgikbd;
326 326
327 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); 327 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW);
@@ -356,10 +356,10 @@ static int __init corgikbd_probe(struct device *dev)
356 return 0; 356 return 0;
357} 357}
358 358
359static int corgikbd_remove(struct device *dev) 359static int corgikbd_remove(struct platform_device *pdev)
360{ 360{
361 int i; 361 int i;
362 struct corgikbd *corgikbd = dev_get_drvdata(dev); 362 struct corgikbd *corgikbd = platform_get_drvdata(pdev);
363 363
364 for (i = 0; i < CORGI_KEY_SENSE_NUM; i++) 364 for (i = 0; i < CORGI_KEY_SENSE_NUM; i++)
365 free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd); 365 free_irq(CORGI_IRQ_GPIO_KEY_SENSE(i), corgikbd);
@@ -374,23 +374,24 @@ static int corgikbd_remove(struct device *dev)
374 return 0; 374 return 0;
375} 375}
376 376
377static struct device_driver corgikbd_driver = { 377static struct platform_driver corgikbd_driver = {
378 .name = "corgi-keyboard",
379 .bus = &platform_bus_type,
380 .probe = corgikbd_probe, 378 .probe = corgikbd_probe,
381 .remove = corgikbd_remove, 379 .remove = corgikbd_remove,
382 .suspend = corgikbd_suspend, 380 .suspend = corgikbd_suspend,
383 .resume = corgikbd_resume, 381 .resume = corgikbd_resume,
382 .driver = {
383 .name = "corgi-keyboard",
384 },
384}; 385};
385 386
386static int __devinit corgikbd_init(void) 387static int __devinit corgikbd_init(void)
387{ 388{
388 return driver_register(&corgikbd_driver); 389 return platform_driver_register(&corgikbd_driver);
389} 390}
390 391
391static void __exit corgikbd_exit(void) 392static void __exit corgikbd_exit(void)
392{ 393{
393 driver_unregister(&corgikbd_driver); 394 platform_driver_unregister(&corgikbd_driver);
394} 395}
395 396
396module_init(corgikbd_init); 397module_init(corgikbd_init);
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c
index 0fa38a559cdf..6a15fe3bc527 100644
--- a/drivers/input/keyboard/spitzkbd.c
+++ b/drivers/input/keyboard/spitzkbd.c
@@ -309,10 +309,10 @@ static void spitzkbd_hinge_timer(unsigned long data)
309} 309}
310 310
311#ifdef CONFIG_PM 311#ifdef CONFIG_PM
312static int spitzkbd_suspend(struct device *dev, pm_message_t state) 312static int spitzkbd_suspend(struct platform_device *dev, pm_message_t state)
313{ 313{
314 int i; 314 int i;
315 struct spitzkbd *spitzkbd = dev_get_drvdata(dev); 315 struct spitzkbd *spitzkbd = platform_get_drvdata(dev);
316 spitzkbd->suspended = 1; 316 spitzkbd->suspended = 1;
317 317
318 /* Set Strobe lines as inputs - *except* strobe line 0 leave this 318 /* Set Strobe lines as inputs - *except* strobe line 0 leave this
@@ -323,10 +323,10 @@ static int spitzkbd_suspend(struct device *dev, pm_message_t state)
323 return 0; 323 return 0;
324} 324}
325 325
326static int spitzkbd_resume(struct device *dev) 326static int spitzkbd_resume(struct platform_device *dev)
327{ 327{
328 int i; 328 int i;
329 struct spitzkbd *spitzkbd = dev_get_drvdata(dev); 329 struct spitzkbd *spitzkbd = platform_get_drvdata(dev);
330 330
331 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++) 331 for (i = 0; i < SPITZ_KEY_STROBE_NUM; i++)
332 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH); 332 pxa_gpio_mode(spitz_strobes[i] | GPIO_OUT | GPIO_DFLT_HIGH);
@@ -342,7 +342,7 @@ static int spitzkbd_resume(struct device *dev)
342#define spitzkbd_resume NULL 342#define spitzkbd_resume NULL
343#endif 343#endif
344 344
345static int __init spitzkbd_probe(struct device *dev) 345static int __init spitzkbd_probe(struct platform_device *dev)
346{ 346{
347 struct spitzkbd *spitzkbd; 347 struct spitzkbd *spitzkbd;
348 struct input_dev *input_dev; 348 struct input_dev *input_dev;
@@ -358,7 +358,7 @@ static int __init spitzkbd_probe(struct device *dev)
358 return -ENOMEM; 358 return -ENOMEM;
359 } 359 }
360 360
361 dev_set_drvdata(dev, spitzkbd); 361 platform_set_drvdata(dev, spitzkbd);
362 strcpy(spitzkbd->phys, "spitzkbd/input0"); 362 strcpy(spitzkbd->phys, "spitzkbd/input0");
363 363
364 spin_lock_init(&spitzkbd->lock); 364 spin_lock_init(&spitzkbd->lock);
@@ -380,7 +380,7 @@ static int __init spitzkbd_probe(struct device *dev)
380 input_dev->private = spitzkbd; 380 input_dev->private = spitzkbd;
381 input_dev->name = "Spitz Keyboard"; 381 input_dev->name = "Spitz Keyboard";
382 input_dev->phys = spitzkbd->phys; 382 input_dev->phys = spitzkbd->phys;
383 input_dev->cdev.dev = dev; 383 input_dev->cdev.dev = &dev->dev;
384 384
385 input_dev->id.bustype = BUS_HOST; 385 input_dev->id.bustype = BUS_HOST;
386 input_dev->id.vendor = 0x0001; 386 input_dev->id.vendor = 0x0001;
@@ -437,10 +437,10 @@ static int __init spitzkbd_probe(struct device *dev)
437 return 0; 437 return 0;
438} 438}
439 439
440static int spitzkbd_remove(struct device *dev) 440static int spitzkbd_remove(struct platform_device *dev)
441{ 441{
442 int i; 442 int i;
443 struct spitzkbd *spitzkbd = dev_get_drvdata(dev); 443 struct spitzkbd *spitzkbd = platform_get_drvdata(dev);
444 444
445 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++) 445 for (i = 0; i < SPITZ_KEY_SENSE_NUM; i++)
446 free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd); 446 free_irq(IRQ_GPIO(spitz_senses[i]), spitzkbd);
@@ -460,23 +460,24 @@ static int spitzkbd_remove(struct device *dev)
460 return 0; 460 return 0;
461} 461}
462 462
463static struct device_driver spitzkbd_driver = { 463static struct platform_driver spitzkbd_driver = {
464 .name = "spitz-keyboard",
465 .bus = &platform_bus_type,
466 .probe = spitzkbd_probe, 464 .probe = spitzkbd_probe,
467 .remove = spitzkbd_remove, 465 .remove = spitzkbd_remove,
468 .suspend = spitzkbd_suspend, 466 .suspend = spitzkbd_suspend,
469 .resume = spitzkbd_resume, 467 .resume = spitzkbd_resume,
468 .driver = {
469 .name = "spitz-keyboard",
470 },
470}; 471};
471 472
472static int __devinit spitzkbd_init(void) 473static int __devinit spitzkbd_init(void)
473{ 474{
474 return driver_register(&spitzkbd_driver); 475 return platform_driver_register(&spitzkbd_driver);
475} 476}
476 477
477static void __exit spitzkbd_exit(void) 478static void __exit spitzkbd_exit(void)
478{ 479{
479 driver_unregister(&spitzkbd_driver); 480 platform_driver_unregister(&spitzkbd_driver);
480} 481}
481 482
482module_init(spitzkbd_init); 483module_init(spitzkbd_init);
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index b3eaac1b35b6..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.
@@ -40,6 +40,16 @@ config INPUT_M68K_BEEP
40 tristate "M68k Beeper support" 40 tristate "M68k Beeper support"
41 depends on M68K 41 depends on M68K
42 42
43config INPUT_WISTRON_BTNS
44 tristate "x86 Wistron laptop button interface"
45 depends on X86 && !X86_64
46 help
47 Say Y here for support of Winstron laptop button interface, used on
48 laptops of various brands, including Acer and Fujitsu-Siemens.
49
50 To compile this driver as a module, choose M here: the module will
51 be called wistron_btns.
52
43config INPUT_UINPUT 53config INPUT_UINPUT
44 tristate "User level driver support" 54 tristate "User level driver support"
45 help 55 help
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index f8d01c69f349..ce44cce01285 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -9,4 +9,5 @@ obj-$(CONFIG_INPUT_PCSPKR) += pcspkr.o
9obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o 9obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o
10obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o 10obj-$(CONFIG_INPUT_98SPKR) += 98spkr.o
11obj-$(CONFIG_INPUT_UINPUT) += uinput.o 11obj-$(CONFIG_INPUT_UINPUT) += uinput.o
12obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
12obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o 13obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 948c1cc01bc9..546ed9b4901d 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -92,24 +92,19 @@ static void uinput_request_done(struct uinput_device *udev, struct uinput_reques
92{ 92{
93 /* Mark slot as available */ 93 /* Mark slot as available */
94 udev->requests[request->id] = NULL; 94 udev->requests[request->id] = NULL;
95 wake_up_interruptible(&udev->requests_waitq); 95 wake_up(&udev->requests_waitq);
96 96
97 complete(&request->done); 97 complete(&request->done);
98} 98}
99 99
100static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request) 100static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request)
101{ 101{
102 int retval;
103
104 /* Tell our userspace app about this new request by queueing an input event */ 102 /* Tell our userspace app about this new request by queueing an input event */
105 uinput_dev_event(dev, EV_UINPUT, request->code, request->id); 103 uinput_dev_event(dev, EV_UINPUT, request->code, request->id);
106 104
107 /* Wait for the request to complete */ 105 /* Wait for the request to complete */
108 retval = wait_for_completion_interruptible(&request->done); 106 wait_for_completion(&request->done);
109 if (!retval) 107 return request->retval;
110 retval = request->retval;
111
112 return retval;
113} 108}
114 109
115static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect) 110static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect)
@@ -152,67 +147,62 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id)
152 return retval; 147 return retval;
153} 148}
154 149
155static int uinput_create_device(struct uinput_device *udev) 150static void uinput_destroy_device(struct uinput_device *udev)
156{ 151{
157 if (!udev->dev->name) { 152 const char *name, *phys;
158 printk(KERN_DEBUG "%s: write device info first\n", UINPUT_NAME); 153
159 return -EINVAL; 154 if (udev->dev) {
155 name = udev->dev->name;
156 phys = udev->dev->phys;
157 if (udev->state == UIST_CREATED)
158 input_unregister_device(udev->dev);
159 else
160 input_free_device(udev->dev);
161 kfree(name);
162 kfree(phys);
163 udev->dev = NULL;
160 } 164 }
161 165
162 udev->dev->event = uinput_dev_event; 166 udev->state = UIST_NEW_DEVICE;
163 udev->dev->upload_effect = uinput_dev_upload_effect;
164 udev->dev->erase_effect = uinput_dev_erase_effect;
165 udev->dev->private = udev;
166
167 init_waitqueue_head(&udev->waitq);
168
169 input_register_device(udev->dev);
170
171 set_bit(UIST_CREATED, &udev->state);
172
173 return 0;
174} 167}
175 168
176static int uinput_destroy_device(struct uinput_device *udev) 169static int uinput_create_device(struct uinput_device *udev)
177{ 170{
178 if (!test_bit(UIST_CREATED, &udev->state)) { 171 int error;
179 printk(KERN_WARNING "%s: create the device first\n", UINPUT_NAME); 172
173 if (udev->state != UIST_SETUP_COMPLETE) {
174 printk(KERN_DEBUG "%s: write device info first\n", UINPUT_NAME);
180 return -EINVAL; 175 return -EINVAL;
181 } 176 }
182 177
183 input_unregister_device(udev->dev); 178 error = input_register_device(udev->dev);
179 if (error) {
180 uinput_destroy_device(udev);
181 return error;
182 }
184 183
185 clear_bit(UIST_CREATED, &udev->state); 184 udev->state = UIST_CREATED;
186 185
187 return 0; 186 return 0;
188} 187}
189 188
190static int uinput_open(struct inode *inode, struct file *file) 189static int uinput_open(struct inode *inode, struct file *file)
191{ 190{
192 struct uinput_device *newdev; 191 struct uinput_device *newdev;
193 struct input_dev *newinput;
194 192
195 newdev = kmalloc(sizeof(struct uinput_device), GFP_KERNEL); 193 newdev = kzalloc(sizeof(struct uinput_device), GFP_KERNEL);
196 if (!newdev) 194 if (!newdev)
197 goto error; 195 return -ENOMEM;
198 memset(newdev, 0, sizeof(struct uinput_device)); 196
197 init_MUTEX(&newdev->sem);
199 spin_lock_init(&newdev->requests_lock); 198 spin_lock_init(&newdev->requests_lock);
200 init_waitqueue_head(&newdev->requests_waitq); 199 init_waitqueue_head(&newdev->requests_waitq);
201 200 init_waitqueue_head(&newdev->waitq);
202 newinput = kmalloc(sizeof(struct input_dev), GFP_KERNEL); 201 newdev->state = UIST_NEW_DEVICE;
203 if (!newinput)
204 goto cleanup;
205 memset(newinput, 0, sizeof(struct input_dev));
206
207 newdev->dev = newinput;
208 202
209 file->private_data = newdev; 203 file->private_data = newdev;
210 204
211 return 0; 205 return 0;
212cleanup:
213 kfree(newdev);
214error:
215 return -ENOMEM;
216} 206}
217 207
218static int uinput_validate_absbits(struct input_dev *dev) 208static int uinput_validate_absbits(struct input_dev *dev)
@@ -246,34 +236,55 @@ static int uinput_validate_absbits(struct input_dev *dev)
246 return retval; 236 return retval;
247} 237}
248 238
249static int uinput_alloc_device(struct file *file, const char __user *buffer, size_t count) 239static int uinput_allocate_device(struct uinput_device *udev)
240{
241 udev->dev = input_allocate_device();
242 if (!udev->dev)
243 return -ENOMEM;
244
245 udev->dev->event = uinput_dev_event;
246 udev->dev->upload_effect = uinput_dev_upload_effect;
247 udev->dev->erase_effect = uinput_dev_erase_effect;
248 udev->dev->private = udev;
249
250 return 0;
251}
252
253static int uinput_setup_device(struct uinput_device *udev, const char __user *buffer, size_t count)
250{ 254{
251 struct uinput_user_dev *user_dev; 255 struct uinput_user_dev *user_dev;
252 struct input_dev *dev; 256 struct input_dev *dev;
253 struct uinput_device *udev;
254 char *name; 257 char *name;
255 int size; 258 int size;
256 int retval; 259 int retval;
257 260
258 retval = count; 261 if (count != sizeof(struct uinput_user_dev))
262 return -EINVAL;
263
264 if (!udev->dev) {
265 retval = uinput_allocate_device(udev);
266 if (retval)
267 return retval;
268 }
259 269
260 udev = file->private_data;
261 dev = udev->dev; 270 dev = udev->dev;
262 271
263 user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL); 272 user_dev = kmalloc(sizeof(struct uinput_user_dev), GFP_KERNEL);
264 if (!user_dev) { 273 if (!user_dev)
265 retval = -ENOMEM; 274 return -ENOMEM;
266 goto exit;
267 }
268 275
269 if (copy_from_user(user_dev, buffer, sizeof(struct uinput_user_dev))) { 276 if (copy_from_user(user_dev, buffer, sizeof(struct uinput_user_dev))) {
270 retval = -EFAULT; 277 retval = -EFAULT;
271 goto exit; 278 goto exit;
272 } 279 }
273 280
274 kfree(dev->name);
275
276 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1; 281 size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
282 if (!size) {
283 retval = -EINVAL;
284 goto exit;
285 }
286
287 kfree(dev->name);
277 dev->name = name = kmalloc(size, GFP_KERNEL); 288 dev->name = name = kmalloc(size, GFP_KERNEL);
278 if (!name) { 289 if (!name) {
279 retval = -ENOMEM; 290 retval = -ENOMEM;
@@ -296,32 +307,50 @@ static int uinput_alloc_device(struct file *file, const char __user *buffer, siz
296 /* check if absmin/absmax/absfuzz/absflat are filled as 307 /* check if absmin/absmax/absfuzz/absflat are filled as
297 * told in Documentation/input/input-programming.txt */ 308 * told in Documentation/input/input-programming.txt */
298 if (test_bit(EV_ABS, dev->evbit)) { 309 if (test_bit(EV_ABS, dev->evbit)) {
299 int err = uinput_validate_absbits(dev); 310 retval = uinput_validate_absbits(dev);
300 if (err < 0) { 311 if (retval < 0)
301 retval = err; 312 goto exit;
302 kfree(dev->name);
303 }
304 } 313 }
305 314
306exit: 315 udev->state = UIST_SETUP_COMPLETE;
316 retval = count;
317
318 exit:
307 kfree(user_dev); 319 kfree(user_dev);
308 return retval; 320 return retval;
309} 321}
310 322
323static inline ssize_t uinput_inject_event(struct uinput_device *udev, const char __user *buffer, size_t count)
324{
325 struct input_event ev;
326
327 if (count != sizeof(struct input_event))
328 return -EINVAL;
329
330 if (copy_from_user(&ev, buffer, sizeof(struct input_event)))
331 return -EFAULT;
332
333 input_event(udev->dev, ev.type, ev.code, ev.value);
334
335 return sizeof(struct input_event);
336}
337
311static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos) 338static ssize_t uinput_write(struct file *file, const char __user *buffer, size_t count, loff_t *ppos)
312{ 339{
313 struct uinput_device *udev = file->private_data; 340 struct uinput_device *udev = file->private_data;
341 int retval;
342
343 retval = down_interruptible(&udev->sem);
344 if (retval)
345 return retval;
314 346
315 if (test_bit(UIST_CREATED, &udev->state)) { 347 retval = udev->state == UIST_CREATED ?
316 struct input_event ev; 348 uinput_inject_event(udev, buffer, count) :
349 uinput_setup_device(udev, buffer, count);
317 350
318 if (copy_from_user(&ev, buffer, sizeof(struct input_event))) 351 up(&udev->sem);
319 return -EFAULT;
320 input_event(udev->dev, ev.type, ev.code, ev.value);
321 } else
322 count = uinput_alloc_device(file, buffer, count);
323 352
324 return count; 353 return retval;
325} 354}
326 355
327static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos) 356static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count, loff_t *ppos)
@@ -329,28 +358,38 @@ static ssize_t uinput_read(struct file *file, char __user *buffer, size_t count,
329 struct uinput_device *udev = file->private_data; 358 struct uinput_device *udev = file->private_data;
330 int retval = 0; 359 int retval = 0;
331 360
332 if (!test_bit(UIST_CREATED, &udev->state)) 361 if (udev->state != UIST_CREATED)
333 return -ENODEV; 362 return -ENODEV;
334 363
335 if (udev->head == udev->tail && (file->f_flags & O_NONBLOCK)) 364 if (udev->head == udev->tail && (file->f_flags & O_NONBLOCK))
336 return -EAGAIN; 365 return -EAGAIN;
337 366
338 retval = wait_event_interruptible(udev->waitq, 367 retval = wait_event_interruptible(udev->waitq,
339 udev->head != udev->tail || !test_bit(UIST_CREATED, &udev->state)); 368 udev->head != udev->tail || udev->state != UIST_CREATED);
340 if (retval) 369 if (retval)
341 return retval; 370 return retval;
342 371
343 if (!test_bit(UIST_CREATED, &udev->state)) 372 retval = down_interruptible(&udev->sem);
344 return -ENODEV; 373 if (retval)
374 return retval;
345 375
346 while ((udev->head != udev->tail) && 376 if (udev->state != UIST_CREATED) {
347 (retval + sizeof(struct input_event) <= count)) { 377 retval = -ENODEV;
348 if (copy_to_user(buffer + retval, &udev->buff[udev->tail], sizeof(struct input_event))) 378 goto out;
349 return -EFAULT; 379 }
380
381 while (udev->head != udev->tail && retval + sizeof(struct input_event) <= count) {
382 if (copy_to_user(buffer + retval, &udev->buff[udev->tail], sizeof(struct input_event))) {
383 retval = -EFAULT;
384 goto out;
385 }
350 udev->tail = (udev->tail + 1) % UINPUT_BUFFER_SIZE; 386 udev->tail = (udev->tail + 1) % UINPUT_BUFFER_SIZE;
351 retval += sizeof(struct input_event); 387 retval += sizeof(struct input_event);
352 } 388 }
353 389
390 out:
391 up(&udev->sem);
392
354 return retval; 393 return retval;
355} 394}
356 395
@@ -366,28 +405,30 @@ static unsigned int uinput_poll(struct file *file, poll_table *wait)
366 return 0; 405 return 0;
367} 406}
368 407
369static int uinput_burn_device(struct uinput_device *udev) 408static int uinput_release(struct inode *inode, struct file *file)
370{ 409{
371 if (test_bit(UIST_CREATED, &udev->state)) 410 struct uinput_device *udev = file->private_data;
372 uinput_destroy_device(udev);
373 411
374 kfree(udev->dev->name); 412 uinput_destroy_device(udev);
375 kfree(udev->dev->phys);
376 kfree(udev->dev);
377 kfree(udev); 413 kfree(udev);
378 414
379 return 0; 415 return 0;
380} 416}
381 417
382static int uinput_close(struct inode *inode, struct file *file) 418#define uinput_set_bit(_arg, _bit, _max) \
419({ \
420 int __ret = 0; \
421 if (udev->state == UIST_CREATED) \
422 __ret = -EINVAL; \
423 else if ((_arg) > (_max)) \
424 __ret = -EINVAL; \
425 else set_bit((_arg), udev->dev->_bit); \
426 __ret; \
427})
428
429static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
383{ 430{
384 uinput_burn_device(file->private_data); 431 int retval;
385 return 0;
386}
387
388static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
389{
390 int retval = 0;
391 struct uinput_device *udev; 432 struct uinput_device *udev;
392 void __user *p = (void __user *)arg; 433 void __user *p = (void __user *)arg;
393 struct uinput_ff_upload ff_up; 434 struct uinput_ff_upload ff_up;
@@ -398,19 +439,14 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
398 439
399 udev = file->private_data; 440 udev = file->private_data;
400 441
401 /* device attributes can not be changed after the device is created */ 442 retval = down_interruptible(&udev->sem);
402 switch (cmd) { 443 if (retval)
403 case UI_SET_EVBIT: 444 return retval;
404 case UI_SET_KEYBIT: 445
405 case UI_SET_RELBIT: 446 if (!udev->dev) {
406 case UI_SET_ABSBIT: 447 retval = uinput_allocate_device(udev);
407 case UI_SET_MSCBIT: 448 if (retval)
408 case UI_SET_LEDBIT: 449 goto out;
409 case UI_SET_SNDBIT:
410 case UI_SET_FFBIT:
411 case UI_SET_PHYS:
412 if (test_bit(UIST_CREATED, &udev->state))
413 return -EINVAL;
414 } 450 }
415 451
416 switch (cmd) { 452 switch (cmd) {
@@ -419,74 +455,50 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
419 break; 455 break;
420 456
421 case UI_DEV_DESTROY: 457 case UI_DEV_DESTROY:
422 retval = uinput_destroy_device(udev); 458 uinput_destroy_device(udev);
423 break; 459 break;
424 460
425 case UI_SET_EVBIT: 461 case UI_SET_EVBIT:
426 if (arg > EV_MAX) { 462 retval = uinput_set_bit(arg, evbit, EV_MAX);
427 retval = -EINVAL;
428 break;
429 }
430 set_bit(arg, udev->dev->evbit);
431 break; 463 break;
432 464
433 case UI_SET_KEYBIT: 465 case UI_SET_KEYBIT:
434 if (arg > KEY_MAX) { 466 retval = uinput_set_bit(arg, keybit, KEY_MAX);
435 retval = -EINVAL;
436 break;
437 }
438 set_bit(arg, udev->dev->keybit);
439 break; 467 break;
440 468
441 case UI_SET_RELBIT: 469 case UI_SET_RELBIT:
442 if (arg > REL_MAX) { 470 retval = uinput_set_bit(arg, relbit, REL_MAX);
443 retval = -EINVAL;
444 break;
445 }
446 set_bit(arg, udev->dev->relbit);
447 break; 471 break;
448 472
449 case UI_SET_ABSBIT: 473 case UI_SET_ABSBIT:
450 if (arg > ABS_MAX) { 474 retval = uinput_set_bit(arg, absbit, ABS_MAX);
451 retval = -EINVAL;
452 break;
453 }
454 set_bit(arg, udev->dev->absbit);
455 break; 475 break;
456 476
457 case UI_SET_MSCBIT: 477 case UI_SET_MSCBIT:
458 if (arg > MSC_MAX) { 478 retval = uinput_set_bit(arg, mscbit, MSC_MAX);
459 retval = -EINVAL;
460 break;
461 }
462 set_bit(arg, udev->dev->mscbit);
463 break; 479 break;
464 480
465 case UI_SET_LEDBIT: 481 case UI_SET_LEDBIT:
466 if (arg > LED_MAX) { 482 retval = uinput_set_bit(arg, ledbit, LED_MAX);
467 retval = -EINVAL;
468 break;
469 }
470 set_bit(arg, udev->dev->ledbit);
471 break; 483 break;
472 484
473 case UI_SET_SNDBIT: 485 case UI_SET_SNDBIT:
474 if (arg > SND_MAX) { 486 retval = uinput_set_bit(arg, sndbit, SND_MAX);
475 retval = -EINVAL;
476 break;
477 }
478 set_bit(arg, udev->dev->sndbit);
479 break; 487 break;
480 488
481 case UI_SET_FFBIT: 489 case UI_SET_FFBIT:
482 if (arg > FF_MAX) { 490 retval = uinput_set_bit(arg, ffbit, FF_MAX);
483 retval = -EINVAL; 491 break;
484 break; 492
485 } 493 case UI_SET_SWBIT:
486 set_bit(arg, udev->dev->ffbit); 494 retval = uinput_set_bit(arg, swbit, SW_MAX);
487 break; 495 break;
488 496
489 case UI_SET_PHYS: 497 case UI_SET_PHYS:
498 if (udev->state == UIST_CREATED) {
499 retval = -EINVAL;
500 goto out;
501 }
490 length = strnlen_user(p, 1024); 502 length = strnlen_user(p, 1024);
491 if (length <= 0) { 503 if (length <= 0) {
492 retval = -EFAULT; 504 retval = -EFAULT;
@@ -575,23 +587,26 @@ static int uinput_ioctl(struct inode *inode, struct file *file, unsigned int cmd
575 default: 587 default:
576 retval = -EINVAL; 588 retval = -EINVAL;
577 } 589 }
590
591 out:
592 up(&udev->sem);
578 return retval; 593 return retval;
579} 594}
580 595
581static struct file_operations uinput_fops = { 596static struct file_operations uinput_fops = {
582 .owner = THIS_MODULE, 597 .owner = THIS_MODULE,
583 .open = uinput_open, 598 .open = uinput_open,
584 .release = uinput_close, 599 .release = uinput_release,
585 .read = uinput_read, 600 .read = uinput_read,
586 .write = uinput_write, 601 .write = uinput_write,
587 .poll = uinput_poll, 602 .poll = uinput_poll,
588 .ioctl = uinput_ioctl, 603 .unlocked_ioctl = uinput_ioctl,
589}; 604};
590 605
591static struct miscdevice uinput_misc = { 606static struct miscdevice uinput_misc = {
592 .fops = &uinput_fops, 607 .fops = &uinput_fops,
593 .minor = UINPUT_MINOR, 608 .minor = UINPUT_MINOR,
594 .name = UINPUT_NAME, 609 .name = UINPUT_NAME,
595}; 610};
596 611
597static int __init uinput_init(void) 612static int __init uinput_init(void)
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
new file mode 100644
index 000000000000..bac3085185fe
--- /dev/null
+++ b/drivers/input/misc/wistron_btns.c
@@ -0,0 +1,561 @@
1/*
2 * Wistron laptop button driver
3 * Copyright (C) 2005 Miloslav Trmac <mitr@volny.cz>
4 * Copyright (C) 2005 Bernhard Rosenkraenzer <bero@arklinux.org>
5 * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru>
6 *
7 * You can redistribute and/or modify this program under the terms of the
8 * GNU General Public License version 2 as published by the Free Software
9 * Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place Suite 330, Boston, MA 02111-1307, USA.
19 */
20#include <asm/io.h>
21#include <linux/dmi.h>
22#include <linux/init.h>
23#include <linux/input.h>
24#include <linux/interrupt.h>
25#include <linux/kernel.h>
26#include <linux/mc146818rtc.h>
27#include <linux/module.h>
28#include <linux/preempt.h>
29#include <linux/string.h>
30#include <linux/timer.h>
31#include <linux/types.h>
32#include <linux/platform_device.h>
33
34/*
35 * Number of attempts to read data from queue per poll;
36 * the queue can hold up to 31 entries
37 */
38#define MAX_POLL_ITERATIONS 64
39
40#define POLL_FREQUENCY 10 /* Number of polls per second */
41
42#if POLL_FREQUENCY > HZ
43#error "POLL_FREQUENCY too high"
44#endif
45
46/* BIOS subsystem IDs */
47#define WIFI 0x35
48#define BLUETOOTH 0x34
49
50MODULE_AUTHOR("Miloslav Trmac <mitr@volny.cz>");
51MODULE_DESCRIPTION("Wistron laptop button driver");
52MODULE_LICENSE("GPL v2");
53MODULE_VERSION("0.1");
54
55static int force; /* = 0; */
56module_param(force, bool, 0);
57MODULE_PARM_DESC(force, "Load even if computer is not in database");
58
59static char *keymap_name; /* = NULL; */
60module_param_named(keymap, keymap_name, charp, 0);
61MODULE_PARM_DESC(keymap, "Keymap name, if it can't be autodetected");
62
63static struct platform_device *wistron_device;
64
65 /* BIOS interface implementation */
66
67static void __iomem *bios_entry_point; /* BIOS routine entry point */
68static void __iomem *bios_code_map_base;
69static void __iomem *bios_data_map_base;
70
71static u8 cmos_address;
72
73struct regs {
74 u32 eax, ebx, ecx;
75};
76
77static void call_bios(struct regs *regs)
78{
79 unsigned long flags;
80
81 preempt_disable();
82 local_irq_save(flags);
83 asm volatile ("pushl %%ebp;"
84 "movl %7, %%ebp;"
85 "call *%6;"
86 "popl %%ebp"
87 : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx)
88 : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx),
89 "m" (bios_entry_point), "m" (bios_data_map_base)
90 : "edx", "edi", "esi", "memory");
91 local_irq_restore(flags);
92 preempt_enable();
93}
94
95static size_t __init locate_wistron_bios(void __iomem *base)
96{
97 static const unsigned char __initdata signature[] =
98 { 0x42, 0x21, 0x55, 0x30 };
99 size_t offset;
100
101 for (offset = 0; offset < 0x10000; offset += 0x10) {
102 if (check_signature(base + offset, signature,
103 sizeof(signature)) != 0)
104 return offset;
105 }
106 return -1;
107}
108
109static int __init map_bios(void)
110{
111 void __iomem *base;
112 size_t offset;
113 u32 entry_point;
114
115 base = ioremap(0xF0000, 0x10000); /* Can't fail */
116 offset = locate_wistron_bios(base);
117 if (offset < 0) {
118 printk(KERN_ERR "wistron_btns: BIOS entry point not found\n");
119 iounmap(base);
120 return -ENODEV;
121 }
122
123 entry_point = readl(base + offset + 5);
124 printk(KERN_DEBUG
125 "wistron_btns: BIOS signature found at %p, entry point %08X\n",
126 base + offset, entry_point);
127
128 if (entry_point >= 0xF0000) {
129 bios_code_map_base = base;
130 bios_entry_point = bios_code_map_base + (entry_point & 0xFFFF);
131 } else {
132 iounmap(base);
133 bios_code_map_base = ioremap(entry_point & ~0x3FFF, 0x4000);
134 if (bios_code_map_base == NULL) {
135 printk(KERN_ERR
136 "wistron_btns: Can't map BIOS code at %08X\n",
137 entry_point & ~0x3FFF);
138 goto err;
139 }
140 bios_entry_point = bios_code_map_base + (entry_point & 0x3FFF);
141 }
142 /* The Windows driver maps 0x10000 bytes, we keep only one page... */
143 bios_data_map_base = ioremap(0x400, 0xc00);
144 if (bios_data_map_base == NULL) {
145 printk(KERN_ERR "wistron_btns: Can't map BIOS data\n");
146 goto err_code;
147 }
148 return 0;
149
150err_code:
151 iounmap(bios_code_map_base);
152err:
153 return -ENOMEM;
154}
155
156static inline void unmap_bios(void)
157{
158 iounmap(bios_code_map_base);
159 iounmap(bios_data_map_base);
160}
161
162 /* BIOS calls */
163
164static u16 bios_pop_queue(void)
165{
166 struct regs regs;
167
168 memset(&regs, 0, sizeof (regs));
169 regs.eax = 0x9610;
170 regs.ebx = 0x061C;
171 regs.ecx = 0x0000;
172 call_bios(&regs);
173
174 return regs.eax;
175}
176
177static void __init bios_attach(void)
178{
179 struct regs regs;
180
181 memset(&regs, 0, sizeof (regs));
182 regs.eax = 0x9610;
183 regs.ebx = 0x012E;
184 call_bios(&regs);
185}
186
187static void bios_detach(void)
188{
189 struct regs regs;
190
191 memset(&regs, 0, sizeof (regs));
192 regs.eax = 0x9610;
193 regs.ebx = 0x002E;
194 call_bios(&regs);
195}
196
197static u8 __init bios_get_cmos_address(void)
198{
199 struct regs regs;
200
201 memset(&regs, 0, sizeof (regs));
202 regs.eax = 0x9610;
203 regs.ebx = 0x051C;
204 call_bios(&regs);
205
206 return regs.ecx;
207}
208
209static u16 __init bios_get_default_setting(u8 subsys)
210{
211 struct regs regs;
212
213 memset(&regs, 0, sizeof (regs));
214 regs.eax = 0x9610;
215 regs.ebx = 0x0200 | subsys;
216 call_bios(&regs);
217
218 return regs.eax;
219}
220
221static void bios_set_state(u8 subsys, int enable)
222{
223 struct regs regs;
224
225 memset(&regs, 0, sizeof (regs));
226 regs.eax = 0x9610;
227 regs.ebx = (enable ? 0x0100 : 0x0000) | subsys;
228 call_bios(&regs);
229}
230
231/* Hardware database */
232
233struct key_entry {
234 char type; /* See KE_* below */
235 u8 code;
236 unsigned keycode; /* For KE_KEY */
237};
238
239enum { KE_END, KE_KEY, KE_WIFI, KE_BLUETOOTH };
240
241static const struct key_entry *keymap; /* = NULL; Current key map */
242static int have_wifi;
243static int have_bluetooth;
244
245static int __init dmi_matched(struct dmi_system_id *dmi)
246{
247 const struct key_entry *key;
248
249 keymap = dmi->driver_data;
250 for (key = keymap; key->type != KE_END; key++) {
251 if (key->type == KE_WIFI) {
252 have_wifi = 1;
253 break;
254 } else if (key->type == KE_BLUETOOTH) {
255 have_bluetooth = 1;
256 break;
257 }
258 }
259 return 1;
260}
261
262static struct key_entry keymap_empty[] = {
263 { KE_END, 0 }
264};
265
266static struct key_entry keymap_fs_amilo_pro_v2000[] = {
267 { KE_KEY, 0x01, KEY_HELP },
268 { KE_KEY, 0x11, KEY_PROG1 },
269 { KE_KEY, 0x12, KEY_PROG2 },
270 { KE_WIFI, 0x30, 0 },
271 { KE_KEY, 0x31, KEY_MAIL },
272 { KE_KEY, 0x36, KEY_WWW },
273 { KE_END, 0 }
274};
275
276static struct key_entry keymap_wistron_ms2141[] = {
277 { KE_KEY, 0x11, KEY_PROG1 },
278 { KE_KEY, 0x12, KEY_PROG2 },
279 { KE_WIFI, 0x30, 0 },
280 { KE_KEY, 0x22, KEY_REWIND },
281 { KE_KEY, 0x23, KEY_FORWARD },
282 { KE_KEY, 0x24, KEY_PLAYPAUSE },
283 { KE_KEY, 0x25, KEY_STOPCD },
284 { KE_KEY, 0x31, KEY_MAIL },
285 { KE_KEY, 0x36, KEY_WWW },
286 { KE_END, 0 }
287};
288
289static struct key_entry keymap_acer_aspire_1500[] = {
290 { KE_KEY, 0x11, KEY_PROG1 },
291 { KE_KEY, 0x12, KEY_PROG2 },
292 { KE_WIFI, 0x30, 0 },
293 { KE_KEY, 0x31, KEY_MAIL },
294 { KE_KEY, 0x36, KEY_WWW },
295 { KE_BLUETOOTH, 0x44, 0 },
296 { KE_END, 0 }
297};
298
299/*
300 * If your machine is not here (which is currently rather likely), please send
301 * a list of buttons and their key codes (reported when loading this module
302 * with force=1) and the output of dmidecode to $MODULE_AUTHOR.
303 */
304static struct dmi_system_id dmi_ids[] = {
305 {
306 .callback = dmi_matched,
307 .ident = "Fujitsu-Siemens Amilo Pro V2000",
308 .matches = {
309 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
310 DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2000"),
311 },
312 .driver_data = keymap_fs_amilo_pro_v2000
313 },
314 {
315 .callback = dmi_matched,
316 .ident = "Acer Aspire 1500",
317 .matches = {
318 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
319 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1500"),
320 },
321 .driver_data = keymap_acer_aspire_1500
322 },
323 { NULL, }
324};
325
326static int __init select_keymap(void)
327{
328 if (keymap_name != NULL) {
329 if (strcmp (keymap_name, "1557/MS2141") == 0)
330 keymap = keymap_wistron_ms2141;
331 else {
332 printk(KERN_ERR "wistron_btns: Keymap unknown\n");
333 return -EINVAL;
334 }
335 }
336 dmi_check_system(dmi_ids);
337 if (keymap == NULL) {
338 if (!force) {
339 printk(KERN_ERR "wistron_btns: System unknown\n");
340 return -ENODEV;
341 }
342 keymap = keymap_empty;
343 }
344 return 0;
345}
346
347 /* Input layer interface */
348
349static struct input_dev *input_dev;
350
351static int __init setup_input_dev(void)
352{
353 const struct key_entry *key;
354 int error;
355
356 input_dev = input_allocate_device();
357 if (!input_dev)
358 return -ENOMEM;
359
360 input_dev->name = "Wistron laptop buttons";
361 input_dev->phys = "wistron/input0";
362 input_dev->id.bustype = BUS_HOST;
363 input_dev->cdev.dev = &wistron_device->dev;
364
365 for (key = keymap; key->type != KE_END; key++) {
366 if (key->type == KE_KEY) {
367 input_dev->evbit[LONG(EV_KEY)] = BIT(EV_KEY);
368 set_bit(key->keycode, input_dev->keybit);
369 }
370 }
371
372 error = input_register_device(input_dev);
373 if (error) {
374 input_free_device(input_dev);
375 return error;
376 }
377
378 return 0;
379}
380
381static void report_key(unsigned keycode)
382{
383 input_report_key(input_dev, keycode, 1);
384 input_sync(input_dev);
385 input_report_key(input_dev, keycode, 0);
386 input_sync(input_dev);
387}
388
389 /* Driver core */
390
391static int wifi_enabled;
392static int bluetooth_enabled;
393
394static void poll_bios(unsigned long);
395
396static struct timer_list poll_timer = TIMER_INITIALIZER(poll_bios, 0, 0);
397
398static void handle_key(u8 code)
399{
400 const struct key_entry *key;
401
402 for (key = keymap; key->type != KE_END; key++) {
403 if (code == key->code) {
404 switch (key->type) {
405 case KE_KEY:
406 report_key(key->keycode);
407 break;
408
409 case KE_WIFI:
410 if (have_wifi) {
411 wifi_enabled = !wifi_enabled;
412 bios_set_state(WIFI, wifi_enabled);
413 }
414 break;
415
416 case KE_BLUETOOTH:
417 if (have_bluetooth) {
418 bluetooth_enabled = !bluetooth_enabled;
419 bios_set_state(BLUETOOTH, bluetooth_enabled);
420 }
421 break;
422
423 case KE_END:
424 default:
425 BUG();
426 }
427 return;
428 }
429 }
430 printk(KERN_NOTICE "wistron_btns: Unknown key code %02X\n", code);
431}
432
433static void poll_bios(unsigned long discard)
434{
435 u8 qlen;
436 u16 val;
437
438 for (;;) {
439 qlen = CMOS_READ(cmos_address);
440 if (qlen == 0)
441 break;
442 val = bios_pop_queue();
443 if (val != 0 && !discard)
444 handle_key((u8)val);
445 }
446
447 mod_timer(&poll_timer, jiffies + HZ / POLL_FREQUENCY);
448}
449
450static int wistron_suspend(struct platform_device *dev, pm_message_t state)
451{
452 del_timer_sync(&poll_timer);
453
454 if (have_wifi)
455 bios_set_state(WIFI, 0);
456
457 if (have_bluetooth)
458 bios_set_state(BLUETOOTH, 0);
459
460 return 0;
461}
462
463static int wistron_resume(struct platform_device *dev)
464{
465 if (have_wifi)
466 bios_set_state(WIFI, wifi_enabled);
467
468 if (have_bluetooth)
469 bios_set_state(BLUETOOTH, bluetooth_enabled);
470
471 poll_bios(1);
472
473 return 0;
474}
475
476static struct platform_driver wistron_driver = {
477 .suspend = wistron_suspend,
478 .resume = wistron_resume,
479 .driver = {
480 .name = "wistron-bios",
481 },
482};
483
484static int __init wb_module_init(void)
485{
486 int err;
487
488 err = select_keymap();
489 if (err)
490 return err;
491
492 err = map_bios();
493 if (err)
494 return err;
495
496 bios_attach();
497 cmos_address = bios_get_cmos_address();
498
499 err = platform_driver_register(&wistron_driver);
500 if (err)
501 goto err_detach_bios;
502
503 wistron_device = platform_device_register_simple("wistron-bios", -1, NULL, 0);
504 if (IS_ERR(wistron_device)) {
505 err = PTR_ERR(wistron_device);
506 goto err_unregister_driver;
507 }
508
509 if (have_wifi) {
510 u16 wifi = bios_get_default_setting(WIFI);
511 if (wifi & 1)
512 wifi_enabled = (wifi & 2) ? 1 : 0;
513 else
514 have_wifi = 0;
515
516 if (have_wifi)
517 bios_set_state(WIFI, wifi_enabled);
518 }
519
520 if (have_bluetooth) {
521 u16 bt = bios_get_default_setting(BLUETOOTH);
522 if (bt & 1)
523 bluetooth_enabled = (bt & 2) ? 1 : 0;
524 else
525 have_bluetooth = 0;
526
527 if (have_bluetooth)
528 bios_set_state(BLUETOOTH, bluetooth_enabled);
529 }
530
531 err = setup_input_dev();
532 if (err)
533 goto err_unregister_device;
534
535 poll_bios(1); /* Flush stale event queue and arm timer */
536
537 return 0;
538
539 err_unregister_device:
540 platform_device_unregister(wistron_device);
541 err_unregister_driver:
542 platform_driver_unregister(&wistron_driver);
543 err_detach_bios:
544 bios_detach();
545 unmap_bios();
546
547 return err;
548}
549
550static void __exit wb_module_exit(void)
551{
552 del_timer_sync(&poll_timer);
553 input_unregister_device(input_dev);
554 platform_device_unregister(wistron_device);
555 platform_driver_unregister(&wistron_driver);
556 bios_detach();
557 unmap_bios();
558}
559
560module_init(wb_module_init);
561module_exit(wb_module_exit);
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.c b/drivers/input/serio/i8042.c
index 01e186422021..ac86c1d1d83e 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -912,7 +912,7 @@ static long i8042_panic_blink(long count)
912 * Here we try to restore the original BIOS settings 912 * Here we try to restore the original BIOS settings
913 */ 913 */
914 914
915static int i8042_suspend(struct device *dev, pm_message_t state) 915static int i8042_suspend(struct platform_device *dev, pm_message_t state)
916{ 916{
917 del_timer_sync(&i8042_timer); 917 del_timer_sync(&i8042_timer);
918 i8042_controller_reset(); 918 i8042_controller_reset();
@@ -925,7 +925,7 @@ static int i8042_suspend(struct device *dev, pm_message_t state)
925 * Here we try to reset everything back to a state in which suspended 925 * Here we try to reset everything back to a state in which suspended
926 */ 926 */
927 927
928static int i8042_resume(struct device *dev) 928static int i8042_resume(struct platform_device *dev)
929{ 929{
930 int i; 930 int i;
931 931
@@ -964,17 +964,18 @@ static int i8042_resume(struct device *dev)
964 * because otherwise BIOSes will be confused. 964 * because otherwise BIOSes will be confused.
965 */ 965 */
966 966
967static void i8042_shutdown(struct device *dev) 967static void i8042_shutdown(struct platform_device *dev)
968{ 968{
969 i8042_controller_cleanup(); 969 i8042_controller_cleanup();
970} 970}
971 971
972static struct device_driver i8042_driver = { 972static struct platform_driver i8042_driver = {
973 .name = "i8042",
974 .bus = &platform_bus_type,
975 .suspend = i8042_suspend, 973 .suspend = i8042_suspend,
976 .resume = i8042_resume, 974 .resume = i8042_resume,
977 .shutdown = i8042_shutdown, 975 .shutdown = i8042_shutdown,
976 .driver = {
977 .name = "i8042",
978 },
978}; 979};
979 980
980static int __init i8042_create_kbd_port(void) 981static int __init i8042_create_kbd_port(void)
@@ -1078,7 +1079,7 @@ static int __init i8042_init(void)
1078 goto err_platform_exit; 1079 goto err_platform_exit;
1079 } 1080 }
1080 1081
1081 err = driver_register(&i8042_driver); 1082 err = platform_driver_register(&i8042_driver);
1082 if (err) 1083 if (err)
1083 goto err_controller_cleanup; 1084 goto err_controller_cleanup;
1084 1085
@@ -1126,7 +1127,7 @@ static int __init i8042_init(void)
1126 err_unregister_device: 1127 err_unregister_device:
1127 platform_device_unregister(i8042_platform_device); 1128 platform_device_unregister(i8042_platform_device);
1128 err_unregister_driver: 1129 err_unregister_driver:
1129 driver_unregister(&i8042_driver); 1130 platform_driver_unregister(&i8042_driver);
1130 err_controller_cleanup: 1131 err_controller_cleanup:
1131 i8042_controller_cleanup(); 1132 i8042_controller_cleanup();
1132 err_platform_exit: 1133 err_platform_exit:
@@ -1148,7 +1149,7 @@ static void __exit i8042_exit(void)
1148 del_timer_sync(&i8042_timer); 1149 del_timer_sync(&i8042_timer);
1149 1150
1150 platform_device_unregister(i8042_platform_device); 1151 platform_device_unregister(i8042_platform_device);
1151 driver_unregister(&i8042_driver); 1152 platform_driver_unregister(&i8042_driver);
1152 1153
1153 i8042_platform_exit(); 1154 i8042_platform_exit();
1154 1155
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/rpckbd.c b/drivers/input/serio/rpckbd.c
index 52c49258f8a4..a3bd11589bc3 100644
--- a/drivers/input/serio/rpckbd.c
+++ b/drivers/input/serio/rpckbd.c
@@ -107,7 +107,7 @@ static void rpckbd_close(struct serio *port)
107 * Allocate and initialize serio structure for subsequent registration 107 * Allocate and initialize serio structure for subsequent registration
108 * with serio core. 108 * with serio core.
109 */ 109 */
110static int __devinit rpckbd_probe(struct device *dev) 110static int __devinit rpckbd_probe(struct platform_device *dev)
111{ 111{
112 struct serio *serio; 112 struct serio *serio;
113 113
@@ -120,37 +120,38 @@ static int __devinit rpckbd_probe(struct device *dev)
120 serio->write = rpckbd_write; 120 serio->write = rpckbd_write;
121 serio->open = rpckbd_open; 121 serio->open = rpckbd_open;
122 serio->close = rpckbd_close; 122 serio->close = rpckbd_close;
123 serio->dev.parent = dev; 123 serio->dev.parent = &dev->dev;
124 strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name)); 124 strlcpy(serio->name, "RiscPC PS/2 kbd port", sizeof(serio->name));
125 strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys)); 125 strlcpy(serio->phys, "rpckbd/serio0", sizeof(serio->phys));
126 126
127 dev_set_drvdata(dev, serio); 127 platform_set_drvdata(dev, serio);
128 serio_register_port(serio); 128 serio_register_port(serio);
129 return 0; 129 return 0;
130} 130}
131 131
132static int __devexit rpckbd_remove(struct device *dev) 132static int __devexit rpckbd_remove(struct platform_device *dev)
133{ 133{
134 struct serio *serio = dev_get_drvdata(dev); 134 struct serio *serio = platform_get_drvdata(dev);
135 serio_unregister_port(serio); 135 serio_unregister_port(serio);
136 return 0; 136 return 0;
137} 137}
138 138
139static struct device_driver rpckbd_driver = { 139static struct platform_driver rpckbd_driver = {
140 .name = "kart",
141 .bus = &platform_bus_type,
142 .probe = rpckbd_probe, 140 .probe = rpckbd_probe,
143 .remove = __devexit_p(rpckbd_remove), 141 .remove = __devexit_p(rpckbd_remove),
142 .driver = {
143 .name = "kart",
144 },
144}; 145};
145 146
146static int __init rpckbd_init(void) 147static int __init rpckbd_init(void)
147{ 148{
148 return driver_register(&rpckbd_driver); 149 return platform_driver_register(&rpckbd_driver);
149} 150}
150 151
151static void __exit rpckbd_exit(void) 152static void __exit rpckbd_exit(void)
152{ 153{
153 driver_unregister(&rpckbd_driver); 154 platform_driver_unregister(&rpckbd_driver);
154} 155}
155 156
156module_init(rpckbd_init); 157module_init(rpckbd_init);
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index edd15db17715..fbb69ef6a77b 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -269,14 +269,20 @@ static struct serio_event *serio_get_event(void)
269 return event; 269 return event;
270} 270}
271 271
272static void serio_handle_events(void) 272static void serio_handle_event(void)
273{ 273{
274 struct serio_event *event; 274 struct serio_event *event;
275 struct serio_driver *serio_drv; 275 struct serio_driver *serio_drv;
276 276
277 down(&serio_sem); 277 down(&serio_sem);
278 278
279 while ((event = serio_get_event())) { 279 /*
280 * Note that we handle only one event here to give swsusp
281 * a chance to freeze kseriod thread. Serio events should
282 * be pretty rare so we are not concerned about taking
283 * performance hit.
284 */
285 if ((event = serio_get_event())) {
280 286
281 switch (event->type) { 287 switch (event->type) {
282 case SERIO_REGISTER_PORT: 288 case SERIO_REGISTER_PORT:
@@ -368,7 +374,7 @@ static struct serio *serio_get_pending_child(struct serio *parent)
368static int serio_thread(void *nothing) 374static int serio_thread(void *nothing)
369{ 375{
370 do { 376 do {
371 serio_handle_events(); 377 serio_handle_event();
372 wait_event_interruptible(serio_wait, 378 wait_event_interruptible(serio_wait,
373 kthread_should_stop() || !list_empty(&serio_event_list)); 379 kthread_should_stop() || !list_empty(&serio_event_list));
374 try_to_freeze(); 380 try_to_freeze();
diff --git a/drivers/input/touchscreen/corgi_ts.c b/drivers/input/touchscreen/corgi_ts.c
index 15e88eeae8d6..1042987856f7 100644
--- a/drivers/input/touchscreen/corgi_ts.c
+++ b/drivers/input/touchscreen/corgi_ts.c
@@ -231,9 +231,9 @@ static irqreturn_t ts_interrupt(int irq, void *dev_id, struct pt_regs *regs)
231} 231}
232 232
233#ifdef CONFIG_PM 233#ifdef CONFIG_PM
234static int corgits_suspend(struct device *dev, pm_message_t state) 234static int corgits_suspend(struct platform_device *dev, pm_message_t state)
235{ 235{
236 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 236 struct corgi_ts *corgi_ts = platform_get_drvdata(dev);
237 237
238 if (corgi_ts->pendown) { 238 if (corgi_ts->pendown) {
239 del_timer_sync(&corgi_ts->timer); 239 del_timer_sync(&corgi_ts->timer);
@@ -248,9 +248,9 @@ static int corgits_suspend(struct device *dev, pm_message_t state)
248 return 0; 248 return 0;
249} 249}
250 250
251static int corgits_resume(struct device *dev) 251static int corgits_resume(struct platform_device *dev)
252{ 252{
253 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 253 struct corgi_ts *corgi_ts = platform_get_drvdata(dev);
254 254
255 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS); 255 corgi_ssp_ads7846_putget((4u << ADSCTRL_ADR_SH) | ADSCTRL_STS);
256 /* Enable Falling Edge */ 256 /* Enable Falling Edge */
@@ -264,10 +264,9 @@ static int corgits_resume(struct device *dev)
264#define corgits_resume NULL 264#define corgits_resume NULL
265#endif 265#endif
266 266
267static int __init corgits_probe(struct device *dev) 267static int __init corgits_probe(struct platform_device *pdev)
268{ 268{
269 struct corgi_ts *corgi_ts; 269 struct corgi_ts *corgi_ts;
270 struct platform_device *pdev = to_platform_device(dev);
271 struct input_dev *input_dev; 270 struct input_dev *input_dev;
272 int err = -ENOMEM; 271 int err = -ENOMEM;
273 272
@@ -276,9 +275,9 @@ static int __init corgits_probe(struct device *dev)
276 if (!corgi_ts || !input_dev) 275 if (!corgi_ts || !input_dev)
277 goto fail; 276 goto fail;
278 277
279 dev_set_drvdata(dev, corgi_ts); 278 platform_set_drvdata(pdev, corgi_ts);
280 279
281 corgi_ts->machinfo = dev->platform_data; 280 corgi_ts->machinfo = pdev->dev.platform_data;
282 corgi_ts->irq_gpio = platform_get_irq(pdev, 0); 281 corgi_ts->irq_gpio = platform_get_irq(pdev, 0);
283 282
284 if (corgi_ts->irq_gpio < 0) { 283 if (corgi_ts->irq_gpio < 0) {
@@ -298,7 +297,7 @@ static int __init corgits_probe(struct device *dev)
298 input_dev->id.vendor = 0x0001; 297 input_dev->id.vendor = 0x0001;
299 input_dev->id.product = 0x0002; 298 input_dev->id.product = 0x0002;
300 input_dev->id.version = 0x0100; 299 input_dev->id.version = 0x0100;
301 input_dev->cdev.dev = dev; 300 input_dev->cdev.dev = &pdev->dev;
302 input_dev->private = corgi_ts; 301 input_dev->private = corgi_ts;
303 302
304 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); 303 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
@@ -339,9 +338,9 @@ static int __init corgits_probe(struct device *dev)
339 338
340} 339}
341 340
342static int corgits_remove(struct device *dev) 341static int corgits_remove(struct platform_device *pdev)
343{ 342{
344 struct corgi_ts *corgi_ts = dev_get_drvdata(dev); 343 struct corgi_ts *corgi_ts = platform_get_drvdata(pdev);
345 344
346 free_irq(corgi_ts->irq_gpio, NULL); 345 free_irq(corgi_ts->irq_gpio, NULL);
347 del_timer_sync(&corgi_ts->timer); 346 del_timer_sync(&corgi_ts->timer);
@@ -351,23 +350,24 @@ static int corgits_remove(struct device *dev)
351 return 0; 350 return 0;
352} 351}
353 352
354static struct device_driver corgits_driver = { 353static struct platform_driver corgits_driver = {
355 .name = "corgi-ts",
356 .bus = &platform_bus_type,
357 .probe = corgits_probe, 354 .probe = corgits_probe,
358 .remove = corgits_remove, 355 .remove = corgits_remove,
359 .suspend = corgits_suspend, 356 .suspend = corgits_suspend,
360 .resume = corgits_resume, 357 .resume = corgits_resume,
358 .driver = {
359 .name = "corgi-ts",
360 },
361}; 361};
362 362
363static int __devinit corgits_init(void) 363static int __devinit corgits_init(void)
364{ 364{
365 return driver_register(&corgits_driver); 365 return platform_driver_register(&corgits_driver);
366} 366}
367 367
368static void __exit corgits_exit(void) 368static void __exit corgits_exit(void)
369{ 369{
370 driver_unregister(&corgits_driver); 370 platform_driver_unregister(&corgits_driver);
371} 371}
372 372
373module_init(corgits_init); 373module_init(corgits_init);
diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 801c98f30e5c..c82105920d71 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -110,7 +110,7 @@ config HISAX_16_3
110 110
111config HISAX_TELESPCI 111config HISAX_TELESPCI
112 bool "Teles PCI" 112 bool "Teles PCI"
113 depends on PCI && (BROKEN || !(SPARC64 || PPC)) 113 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K))
114 help 114 help
115 This enables HiSax support for the Teles PCI. 115 This enables HiSax support for the Teles PCI.
116 See <file:Documentation/isdn/README.HiSax> on how to configure it. 116 See <file:Documentation/isdn/README.HiSax> on how to configure it.
@@ -238,7 +238,7 @@ config HISAX_MIC
238 238
239config HISAX_NETJET 239config HISAX_NETJET
240 bool "NETjet card" 240 bool "NETjet card"
241 depends on PCI && (BROKEN || !(SPARC64 || PPC)) 241 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K))
242 help 242 help
243 This enables HiSax support for the NetJet from Traverse 243 This enables HiSax support for the NetJet from Traverse
244 Technologies. 244 Technologies.
@@ -249,7 +249,7 @@ config HISAX_NETJET
249 249
250config HISAX_NETJET_U 250config HISAX_NETJET_U
251 bool "NETspider U card" 251 bool "NETspider U card"
252 depends on PCI && (BROKEN || !(SPARC64 || PPC)) 252 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K))
253 help 253 help
254 This enables HiSax support for the Netspider U interface ISDN card 254 This enables HiSax support for the Netspider U interface ISDN card
255 from Traverse Technologies. 255 from Traverse Technologies.
@@ -317,7 +317,7 @@ config HISAX_GAZEL
317 317
318config HISAX_HFC_PCI 318config HISAX_HFC_PCI
319 bool "HFC PCI-Bus cards" 319 bool "HFC PCI-Bus cards"
320 depends on PCI && (BROKEN || !(SPARC64 || PPC)) 320 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K))
321 help 321 help
322 This enables HiSax support for the HFC-S PCI 2BDS0 based cards. 322 This enables HiSax support for the HFC-S PCI 2BDS0 based cards.
323 323
@@ -344,14 +344,14 @@ config HISAX_HFC_SX
344 344
345config HISAX_ENTERNOW_PCI 345config HISAX_ENTERNOW_PCI
346 bool "Formula-n enter:now PCI card" 346 bool "Formula-n enter:now PCI card"
347 depends on PCI && (BROKEN || !(SPARC64 || PPC)) 347 depends on PCI && (BROKEN || !(SPARC || PPC || PARISC || M68K))
348 help 348 help
349 This enables HiSax support for the Formula-n enter:now PCI 349 This enables HiSax support for the Formula-n enter:now PCI
350 ISDN card. 350 ISDN card.
351 351
352config HISAX_AMD7930 352config HISAX_AMD7930
353 bool "Am7930 (EXPERIMENTAL)" 353 bool "Am7930 (EXPERIMENTAL)"
354 depends on EXPERIMENTAL && (SPARC32 || SPARC64) 354 depends on EXPERIMENTAL && SPARC
355 help 355 help
356 This enables HiSax support for the AMD7930 chips on some SPARCs. 356 This enables HiSax support for the AMD7930 chips on some SPARCs.
357 This code is not finished yet. 357 This code is not finished yet.
diff --git a/drivers/isdn/hisax/hfc_usb.c b/drivers/isdn/hisax/hfc_usb.c
index 32bf0d5d0f9a..f8457ef48826 100644
--- a/drivers/isdn/hisax/hfc_usb.c
+++ b/drivers/isdn/hisax/hfc_usb.c
@@ -71,78 +71,68 @@ typedef struct {
71/****************************************/ 71/****************************************/
72static struct usb_device_id hfcusb_idtab[] = { 72static struct usb_device_id hfcusb_idtab[] = {
73 { 73 {
74 .idVendor = 0x0959, 74 USB_DEVICE(0x0959, 0x2bd0),
75 .idProduct = 0x2bd0,
76 .driver_info = (unsigned long) &((hfcsusb_vdata) 75 .driver_info = (unsigned long) &((hfcsusb_vdata)
77 {LED_OFF, {4, 0, 2, 1}, 76 {LED_OFF, {4, 0, 2, 1},
78 "ISDN USB TA (Cologne Chip HFC-S USB based)"}), 77 "ISDN USB TA (Cologne Chip HFC-S USB based)"}),
79 }, 78 },
80 { 79 {
81 .idVendor = 0x0675, 80 USB_DEVICE(0x0675, 0x1688),
82 .idProduct = 0x1688,
83 .driver_info = (unsigned long) &((hfcsusb_vdata) 81 .driver_info = (unsigned long) &((hfcsusb_vdata)
84 {LED_SCHEME1, {1, 2, 0, 0}, 82 {LED_SCHEME1, {1, 2, 0, 0},
85 "DrayTek miniVigor 128 USB ISDN TA"}), 83 "DrayTek miniVigor 128 USB ISDN TA"}),
86 }, 84 },
87 { 85 {
88 .idVendor = 0x07b0, 86 USB_DEVICE(0x07b0, 0x0007),
89 .idProduct = 0x0007,
90 .driver_info = (unsigned long) &((hfcsusb_vdata) 87 .driver_info = (unsigned long) &((hfcsusb_vdata)
91 {LED_SCHEME1, {0x80, -64, -32, -16}, 88 {LED_SCHEME1, {0x80, -64, -32, -16},
92 "Billion tiny USB ISDN TA 128"}), 89 "Billion tiny USB ISDN TA 128"}),
93 }, 90 },
94 { 91 {
95 .idVendor = 0x0742, 92 USB_DEVICE(0x0742, 0x2008),
96 .idProduct = 0x2008,
97 .driver_info = (unsigned long) &((hfcsusb_vdata) 93 .driver_info = (unsigned long) &((hfcsusb_vdata)
98 {LED_SCHEME1, {4, 0, 2, 1}, 94 {LED_SCHEME1, {4, 0, 2, 1},
99 "Stollmann USB TA"}), 95 "Stollmann USB TA"}),
100 }, 96 },
101 { 97 {
102 .idVendor = 0x0742, 98 USB_DEVICE(0x0742, 0x2009),
103 .idProduct = 0x2009,
104 .driver_info = (unsigned long) &((hfcsusb_vdata) 99 .driver_info = (unsigned long) &((hfcsusb_vdata)
105 {LED_SCHEME1, {4, 0, 2, 1}, 100 {LED_SCHEME1, {4, 0, 2, 1},
106 "Aceex USB ISDN TA"}), 101 "Aceex USB ISDN TA"}),
107 }, 102 },
108 { 103 {
109 .idVendor = 0x0742, 104 USB_DEVICE(0x0742, 0x200A),
110 .idProduct = 0x200A,
111 .driver_info = (unsigned long) &((hfcsusb_vdata) 105 .driver_info = (unsigned long) &((hfcsusb_vdata)
112 {LED_SCHEME1, {4, 0, 2, 1}, 106 {LED_SCHEME1, {4, 0, 2, 1},
113 "OEM USB ISDN TA"}), 107 "OEM USB ISDN TA"}),
114 }, 108 },
115 { 109 {
116 .idVendor = 0x08e3, 110 USB_DEVICE(0x08e3, 0x0301),
117 .idProduct = 0x0301,
118 .driver_info = (unsigned long) &((hfcsusb_vdata) 111 .driver_info = (unsigned long) &((hfcsusb_vdata)
119 {LED_SCHEME1, {2, 0, 1, 4}, 112 {LED_SCHEME1, {2, 0, 1, 4},
120 "Olitec USB RNIS"}), 113 "Olitec USB RNIS"}),
121 }, 114 },
122 { 115 {
123 .idVendor = 0x07fa, 116 USB_DEVICE(0x07fa, 0x0846),
124 .idProduct = 0x0846,
125 .driver_info = (unsigned long) &((hfcsusb_vdata) 117 .driver_info = (unsigned long) &((hfcsusb_vdata)
126 {LED_SCHEME1, {0x80, -64, -32, -16}, 118 {LED_SCHEME1, {0x80, -64, -32, -16},
127 "Bewan Modem RNIS USB"}), 119 "Bewan Modem RNIS USB"}),
128 }, 120 },
129 { 121 {
130 .idVendor = 0x07fa, 122 USB_DEVICE(0x07fa, 0x0847),
131 .idProduct = 0x0847,
132 .driver_info = (unsigned long) &((hfcsusb_vdata) 123 .driver_info = (unsigned long) &((hfcsusb_vdata)
133 {LED_SCHEME1, {0x80, -64, -32, -16}, 124 {LED_SCHEME1, {0x80, -64, -32, -16},
134 "Djinn Numeris USB"}), 125 "Djinn Numeris USB"}),
135 }, 126 },
136 { 127 {
137 .idVendor = 0x07b0, 128 USB_DEVICE(0x07b0, 0x0006),
138 .idProduct = 0x0006,
139 .driver_info = (unsigned long) &((hfcsusb_vdata) 129 .driver_info = (unsigned long) &((hfcsusb_vdata)
140 {LED_SCHEME1, {0x80, -64, -32, -16}, 130 {LED_SCHEME1, {0x80, -64, -32, -16},
141 "Twister ISDN TA"}), 131 "Twister ISDN TA"}),
142 }, 132 },
133 { }
143}; 134};
144 135
145
146/***************************************************************/ 136/***************************************************************/
147/* structure defining input+output fifos (interrupt/bulk mode) */ 137/* structure defining input+output fifos (interrupt/bulk mode) */
148/***************************************************************/ 138/***************************************************************/
diff --git a/drivers/isdn/pcbit/Kconfig b/drivers/isdn/pcbit/Kconfig
index f06997faef16..0933881ab0c2 100644
--- a/drivers/isdn/pcbit/Kconfig
+++ b/drivers/isdn/pcbit/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config ISDN_DRV_PCBIT 4config ISDN_DRV_PCBIT
5 tristate "PCBIT-D support" 5 tristate "PCBIT-D support"
6 depends on ISDN_I4L && ISA && (BROKEN || !PPC) 6 depends on ISDN_I4L && ISA && (BROKEN || X86)
7 help 7 help
8 This enables support for the PCBIT ISDN-card. This card is 8 This enables support for the PCBIT ISDN-card. This card is
9 manufactured in Portugal by Octal. For running this card, 9 manufactured in Portugal by Octal. For running this card,
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 3fc8cdd94c3d..190878eef990 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -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
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/bitmap.c b/drivers/md/bitmap.c
index 51315302a85e..252d55df9642 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -326,9 +326,9 @@ static int write_page(struct bitmap *bitmap, struct page *page, int wait)
326 } 326 }
327 } 327 }
328 328
329 ret = page->mapping->a_ops->prepare_write(NULL, page, 0, PAGE_SIZE); 329 ret = page->mapping->a_ops->prepare_write(bitmap->file, page, 0, PAGE_SIZE);
330 if (!ret) 330 if (!ret)
331 ret = page->mapping->a_ops->commit_write(NULL, page, 0, 331 ret = page->mapping->a_ops->commit_write(bitmap->file, page, 0,
332 PAGE_SIZE); 332 PAGE_SIZE);
333 if (ret) { 333 if (ret) {
334 unlock_page(page); 334 unlock_page(page);
diff --git a/drivers/md/dm-bio-list.h b/drivers/md/dm-bio-list.h
index bc021e1fd4d1..bbf4615f0e30 100644
--- a/drivers/md/dm-bio-list.h
+++ b/drivers/md/dm-bio-list.h
@@ -33,6 +33,9 @@ static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
33 33
34static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2) 34static inline void bio_list_merge(struct bio_list *bl, struct bio_list *bl2)
35{ 35{
36 if (!bl2->head)
37 return;
38
36 if (bl->tail) 39 if (bl->tail)
37 bl->tail->bi_next = bl2->head; 40 bl->tail->bi_next = bl2->head;
38 else 41 else
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 54ec737195e0..07d44e19536e 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -425,8 +425,8 @@ static void list_version_get_needed(struct target_type *tt, void *needed_param)
425{ 425{
426 size_t *needed = needed_param; 426 size_t *needed = needed_param;
427 427
428 *needed += sizeof(struct dm_target_versions);
428 *needed += strlen(tt->name); 429 *needed += strlen(tt->name);
429 *needed += sizeof(tt->version);
430 *needed += ALIGN_MASK; 430 *needed += ALIGN_MASK;
431} 431}
432 432
@@ -974,6 +974,7 @@ static int table_load(struct dm_ioctl *param, size_t param_size)
974 if (!hc) { 974 if (!hc) {
975 DMWARN("device doesn't appear to be in the dev hash table."); 975 DMWARN("device doesn't appear to be in the dev hash table.");
976 up_write(&_hash_lock); 976 up_write(&_hash_lock);
977 dm_table_put(t);
977 return -ENXIO; 978 return -ENXIO;
978 } 979 }
979 980
diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c
index e110655eabdb..a76349cb10a5 100644
--- a/drivers/md/dm-log.c
+++ b/drivers/md/dm-log.c
@@ -333,10 +333,10 @@ static int core_ctr(struct dirty_log *log, struct dm_target *ti,
333 lc->sync = sync; 333 lc->sync = sync;
334 334
335 /* 335 /*
336 * Work out how many words we need to hold the bitset. 336 * Work out how many "unsigned long"s we need to hold the bitset.
337 */ 337 */
338 bitset_size = dm_round_up(region_count, 338 bitset_size = dm_round_up(region_count,
339 sizeof(*lc->clean_bits) << BYTE_SHIFT); 339 sizeof(unsigned long) << BYTE_SHIFT);
340 bitset_size >>= BYTE_SHIFT; 340 bitset_size >>= BYTE_SHIFT;
341 341
342 lc->bitset_uint32_count = bitset_size / 4; 342 lc->bitset_uint32_count = bitset_size / 4;
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index f9b7b32d5d5c..f72a82fb9434 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -1000,6 +1000,7 @@ static int do_end_io(struct multipath *m, struct bio *bio,
1000{ 1000{
1001 struct hw_handler *hwh = &m->hw_handler; 1001 struct hw_handler *hwh = &m->hw_handler;
1002 unsigned err_flags = MP_FAIL_PATH; /* Default behavior */ 1002 unsigned err_flags = MP_FAIL_PATH; /* Default behavior */
1003 unsigned long flags;
1003 1004
1004 if (!error) 1005 if (!error)
1005 return 0; /* I/O complete */ 1006 return 0; /* I/O complete */
@@ -1010,17 +1011,17 @@ static int do_end_io(struct multipath *m, struct bio *bio,
1010 if (error == -EOPNOTSUPP) 1011 if (error == -EOPNOTSUPP)
1011 return error; 1012 return error;
1012 1013
1013 spin_lock(&m->lock); 1014 spin_lock_irqsave(&m->lock, flags);
1014 if (!m->nr_valid_paths) { 1015 if (!m->nr_valid_paths) {
1015 if (!m->queue_if_no_path) { 1016 if (!m->queue_if_no_path) {
1016 spin_unlock(&m->lock); 1017 spin_unlock_irqrestore(&m->lock, flags);
1017 return -EIO; 1018 return -EIO;
1018 } else { 1019 } else {
1019 spin_unlock(&m->lock); 1020 spin_unlock_irqrestore(&m->lock, flags);
1020 goto requeue; 1021 goto requeue;
1021 } 1022 }
1022 } 1023 }
1023 spin_unlock(&m->lock); 1024 spin_unlock_irqrestore(&m->lock, flags);
1024 1025
1025 if (hwh->type && hwh->type->error) 1026 if (hwh->type && hwh->type->error)
1026 err_flags = hwh->type->error(hwh, bio); 1027 err_flags = hwh->type->error(hwh, bio);
@@ -1040,12 +1041,12 @@ static int do_end_io(struct multipath *m, struct bio *bio,
1040 dm_bio_restore(&mpio->details, bio); 1041 dm_bio_restore(&mpio->details, bio);
1041 1042
1042 /* queue for the daemon to resubmit or fail */ 1043 /* queue for the daemon to resubmit or fail */
1043 spin_lock(&m->lock); 1044 spin_lock_irqsave(&m->lock, flags);
1044 bio_list_add(&m->queued_ios, bio); 1045 bio_list_add(&m->queued_ios, bio);
1045 m->queue_size++; 1046 m->queue_size++;
1046 if (!m->queue_io) 1047 if (!m->queue_io)
1047 queue_work(kmultipathd, &m->process_queued_ios); 1048 queue_work(kmultipathd, &m->process_queued_ios);
1048 spin_unlock(&m->lock); 1049 spin_unlock_irqrestore(&m->lock, flags);
1049 1050
1050 return 1; /* io not complete */ 1051 return 1; /* io not complete */
1051} 1052}
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 2375709a392c..6b0fc1670929 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -376,16 +376,18 @@ static void rh_inc(struct region_hash *rh, region_t region)
376 read_lock(&rh->hash_lock); 376 read_lock(&rh->hash_lock);
377 reg = __rh_find(rh, region); 377 reg = __rh_find(rh, region);
378 378
379 spin_lock_irq(&rh->region_lock);
379 atomic_inc(&reg->pending); 380 atomic_inc(&reg->pending);
380 381
381 spin_lock_irq(&rh->region_lock);
382 if (reg->state == RH_CLEAN) { 382 if (reg->state == RH_CLEAN) {
383 rh->log->type->mark_region(rh->log, reg->key);
384
385 reg->state = RH_DIRTY; 383 reg->state = RH_DIRTY;
386 list_del_init(&reg->list); /* take off the clean list */ 384 list_del_init(&reg->list); /* take off the clean list */
387 } 385 spin_unlock_irq(&rh->region_lock);
388 spin_unlock_irq(&rh->region_lock); 386
387 rh->log->type->mark_region(rh->log, reg->key);
388 } else
389 spin_unlock_irq(&rh->region_lock);
390
389 391
390 read_unlock(&rh->hash_lock); 392 read_unlock(&rh->hash_lock);
391} 393}
@@ -408,21 +410,17 @@ static void rh_dec(struct region_hash *rh, region_t region)
408 reg = __rh_lookup(rh, region); 410 reg = __rh_lookup(rh, region);
409 read_unlock(&rh->hash_lock); 411 read_unlock(&rh->hash_lock);
410 412
413 spin_lock_irqsave(&rh->region_lock, flags);
411 if (atomic_dec_and_test(&reg->pending)) { 414 if (atomic_dec_and_test(&reg->pending)) {
412 spin_lock_irqsave(&rh->region_lock, flags);
413 if (atomic_read(&reg->pending)) { /* check race */
414 spin_unlock_irqrestore(&rh->region_lock, flags);
415 return;
416 }
417 if (reg->state == RH_RECOVERING) { 415 if (reg->state == RH_RECOVERING) {
418 list_add_tail(&reg->list, &rh->quiesced_regions); 416 list_add_tail(&reg->list, &rh->quiesced_regions);
419 } else { 417 } else {
420 reg->state = RH_CLEAN; 418 reg->state = RH_CLEAN;
421 list_add(&reg->list, &rh->clean_regions); 419 list_add(&reg->list, &rh->clean_regions);
422 } 420 }
423 spin_unlock_irqrestore(&rh->region_lock, flags);
424 should_wake = 1; 421 should_wake = 1;
425 } 422 }
423 spin_unlock_irqrestore(&rh->region_lock, flags);
426 424
427 if (should_wake) 425 if (should_wake)
428 wake(); 426 wake();
diff --git a/drivers/md/md.c b/drivers/md/md.c
index adf960d8a7c9..8175a2a222da 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1028,7 +1028,6 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1028 mddev->size = le64_to_cpu(sb->size)/2; 1028 mddev->size = le64_to_cpu(sb->size)/2;
1029 mddev->events = le64_to_cpu(sb->events); 1029 mddev->events = le64_to_cpu(sb->events);
1030 mddev->bitmap_offset = 0; 1030 mddev->bitmap_offset = 0;
1031 mddev->default_bitmap_offset = 0;
1032 mddev->default_bitmap_offset = 1024; 1031 mddev->default_bitmap_offset = 1024;
1033 1032
1034 mddev->recovery_cp = le64_to_cpu(sb->resync_offset); 1033 mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
@@ -1730,7 +1729,7 @@ level_show(mddev_t *mddev, char *page)
1730 if (p == NULL && mddev->raid_disks == 0) 1729 if (p == NULL && mddev->raid_disks == 0)
1731 return 0; 1730 return 0;
1732 if (mddev->level >= 0) 1731 if (mddev->level >= 0)
1733 return sprintf(page, "RAID-%d\n", mddev->level); 1732 return sprintf(page, "raid%d\n", mddev->level);
1734 else 1733 else
1735 return sprintf(page, "%s\n", p->name); 1734 return sprintf(page, "%s\n", p->name);
1736} 1735}
@@ -2932,6 +2931,9 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
2932 2931
2933 mddev->sb_dirty = 1; 2932 mddev->sb_dirty = 1;
2934 2933
2934 mddev->default_bitmap_offset = MD_SB_BYTES >> 9;
2935 mddev->bitmap_offset = 0;
2936
2935 /* 2937 /*
2936 * Generate a 128 bit UUID 2938 * Generate a 128 bit UUID
2937 */ 2939 */
@@ -3156,7 +3158,7 @@ static int md_ioctl(struct inode *inode, struct file *file,
3156 if (cnt > 0 ) { 3158 if (cnt > 0 ) {
3157 printk(KERN_WARNING 3159 printk(KERN_WARNING
3158 "md: %s(pid %d) used deprecated START_ARRAY ioctl. " 3160 "md: %s(pid %d) used deprecated START_ARRAY ioctl. "
3159 "This will not be supported beyond 2.6\n", 3161 "This will not be supported beyond July 2006\n",
3160 current->comm, current->pid); 3162 current->comm, current->pid);
3161 cnt--; 3163 cnt--;
3162 } 3164 }
@@ -3437,10 +3439,19 @@ static int md_thread(void * arg)
3437 allow_signal(SIGKILL); 3439 allow_signal(SIGKILL);
3438 while (!kthread_should_stop()) { 3440 while (!kthread_should_stop()) {
3439 3441
3440 wait_event_timeout(thread->wqueue, 3442 /* We need to wait INTERRUPTIBLE so that
3441 test_bit(THREAD_WAKEUP, &thread->flags) 3443 * we don't add to the load-average.
3442 || kthread_should_stop(), 3444 * That means we need to be sure no signals are
3443 thread->timeout); 3445 * pending
3446 */
3447 if (signal_pending(current))
3448 flush_signals(current);
3449
3450 wait_event_interruptible_timeout
3451 (thread->wqueue,
3452 test_bit(THREAD_WAKEUP, &thread->flags)
3453 || kthread_should_stop(),
3454 thread->timeout);
3444 try_to_freeze(); 3455 try_to_freeze();
3445 3456
3446 clear_bit(THREAD_WAKEUP, &thread->flags); 3457 clear_bit(THREAD_WAKEUP, &thread->flags);
@@ -3837,11 +3848,20 @@ static int is_mddev_idle(mddev_t *mddev)
3837 curr_events = disk_stat_read(disk, sectors[0]) + 3848 curr_events = disk_stat_read(disk, sectors[0]) +
3838 disk_stat_read(disk, sectors[1]) - 3849 disk_stat_read(disk, sectors[1]) -
3839 atomic_read(&disk->sync_io); 3850 atomic_read(&disk->sync_io);
3840 /* Allow some slack between valud of curr_events and last_events, 3851 /* The difference between curr_events and last_events
3841 * as there are some uninteresting races. 3852 * will be affected by any new non-sync IO (making
3853 * curr_events bigger) and any difference in the amount of
3854 * in-flight syncio (making current_events bigger or smaller)
3855 * The amount in-flight is currently limited to
3856 * 32*64K in raid1/10 and 256*PAGE_SIZE in raid5/6
3857 * which is at most 4096 sectors.
3858 * These numbers are fairly fragile and should be made
3859 * more robust, probably by enforcing the
3860 * 'window size' that md_do_sync sort-of uses.
3861 *
3842 * Note: the following is an unsigned comparison. 3862 * Note: the following is an unsigned comparison.
3843 */ 3863 */
3844 if ((curr_events - rdev->last_events + 32) > 64) { 3864 if ((curr_events - rdev->last_events + 4096) > 8192) {
3845 rdev->last_events = curr_events; 3865 rdev->last_events = curr_events;
3846 idle = 0; 3866 idle = 0;
3847 } 3867 }
@@ -4100,7 +4120,7 @@ static void md_do_sync(mddev_t *mddev)
4100 if (currspeed > sysctl_speed_limit_min) { 4120 if (currspeed > sysctl_speed_limit_min) {
4101 if ((currspeed > sysctl_speed_limit_max) || 4121 if ((currspeed > sysctl_speed_limit_max) ||
4102 !is_mddev_idle(mddev)) { 4122 !is_mddev_idle(mddev)) {
4103 msleep(250); 4123 msleep(500);
4104 goto repeat; 4124 goto repeat;
4105 } 4125 }
4106 } 4126 }
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 2da9d3ba902d..229d7b204297 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -320,7 +320,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: 320 * this branch is our 'one mirror IO has finished' event handler:
321 */ 321 */
322 r1_bio->bios[mirror] = NULL; 322 r1_bio->bios[mirror] = NULL;
323 bio_put(bio);
324 if (!uptodate) { 323 if (!uptodate) {
325 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev); 324 md_error(r1_bio->mddev, conf->mirrors[mirror].rdev);
326 /* an I/O failed, we can't clear the bitmap */ 325 /* an I/O failed, we can't clear the bitmap */
@@ -377,7 +376,6 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
377 } 376 }
378 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { 377 if (test_bit(R1BIO_BehindIO, &r1_bio->state)) {
379 /* free extra copy of the data pages */ 378 /* free extra copy of the data pages */
380/* FIXME bio has been freed!!! */
381 int i = bio->bi_vcnt; 379 int i = bio->bi_vcnt;
382 while (i--) 380 while (i--)
383 __free_page(bio->bi_io_vec[i].bv_page); 381 __free_page(bio->bi_io_vec[i].bv_page);
@@ -391,6 +389,9 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int
391 raid_end_bio_io(r1_bio); 389 raid_end_bio_io(r1_bio);
392 } 390 }
393 391
392 if (r1_bio->bios[mirror]==NULL)
393 bio_put(bio);
394
394 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); 395 rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev);
395 return 0; 396 return 0;
396} 397}
@@ -953,9 +954,6 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
953 int mirror = 0; 954 int mirror = 0;
954 mirror_info_t *p; 955 mirror_info_t *p;
955 956
956 if (rdev->saved_raid_disk >= 0 &&
957 conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
958 mirror = rdev->saved_raid_disk;
959 for (mirror=0; mirror < mddev->raid_disks; mirror++) 957 for (mirror=0; mirror < mddev->raid_disks; mirror++)
960 if ( !(p=conf->mirrors+mirror)->rdev) { 958 if ( !(p=conf->mirrors+mirror)->rdev) {
961 959
@@ -972,7 +970,10 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
972 p->head_position = 0; 970 p->head_position = 0;
973 rdev->raid_disk = mirror; 971 rdev->raid_disk = mirror;
974 found = 1; 972 found = 1;
975 if (rdev->saved_raid_disk != mirror) 973 /* As all devices are equivalent, we don't need a full recovery
974 * if this was recently any drive of the array
975 */
976 if (rdev->saved_raid_disk < 0)
976 conf->fullsync = 1; 977 conf->fullsync = 1;
977 rcu_assign_pointer(p->rdev, rdev); 978 rcu_assign_pointer(p->rdev, rdev);
978 break; 979 break;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 867f06ae33d9..713dc9c2c730 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -552,7 +552,11 @@ static int read_balance(conf_t *conf, r10bio_t *r10_bio)
552 !test_bit(In_sync, &rdev->flags)) 552 !test_bit(In_sync, &rdev->flags))
553 continue; 553 continue;
554 554
555 if (!atomic_read(&rdev->nr_pending)) { 555 /* This optimisation is debatable, and completely destroys
556 * sequential read speed for 'far copies' arrays. So only
557 * keep it for 'near' arrays, and review those later.
558 */
559 if (conf->near_copies > 1 && !atomic_read(&rdev->nr_pending)) {
556 disk = ndisk; 560 disk = ndisk;
557 slot = nslot; 561 slot = nslot;
558 break; 562 break;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e2a40283e323..fafc4bc045f7 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -98,7 +98,7 @@ static inline void __release_stripe(raid5_conf_t *conf, struct stripe_head *sh)
98 list_add_tail(&sh->lru, &conf->inactive_list); 98 list_add_tail(&sh->lru, &conf->inactive_list);
99 atomic_dec(&conf->active_stripes); 99 atomic_dec(&conf->active_stripes);
100 if (!conf->inactive_blocked || 100 if (!conf->inactive_blocked ||
101 atomic_read(&conf->active_stripes) < (NR_STRIPES*3/4)) 101 atomic_read(&conf->active_stripes) < (conf->max_nr_stripes*3/4))
102 wake_up(&conf->wait_for_stripe); 102 wake_up(&conf->wait_for_stripe);
103 } 103 }
104 } 104 }
@@ -264,7 +264,8 @@ static struct stripe_head *get_active_stripe(raid5_conf_t *conf, sector_t sector
264 conf->inactive_blocked = 1; 264 conf->inactive_blocked = 1;
265 wait_event_lock_irq(conf->wait_for_stripe, 265 wait_event_lock_irq(conf->wait_for_stripe,
266 !list_empty(&conf->inactive_list) && 266 !list_empty(&conf->inactive_list) &&
267 (atomic_read(&conf->active_stripes) < (NR_STRIPES *3/4) 267 (atomic_read(&conf->active_stripes)
268 < (conf->max_nr_stripes *3/4)
268 || !conf->inactive_blocked), 269 || !conf->inactive_blocked),
269 conf->device_lock, 270 conf->device_lock,
270 unplug_slaves(conf->mddev); 271 unplug_slaves(conf->mddev);
@@ -1704,7 +1705,9 @@ static void raid5d (mddev_t *mddev)
1704 1705
1705 if (conf->seq_flush - conf->seq_write > 0) { 1706 if (conf->seq_flush - conf->seq_write > 0) {
1706 int seq = conf->seq_flush; 1707 int seq = conf->seq_flush;
1708 spin_unlock_irq(&conf->device_lock);
1707 bitmap_unplug(mddev->bitmap); 1709 bitmap_unplug(mddev->bitmap);
1710 spin_lock_irq(&conf->device_lock);
1708 conf->seq_write = seq; 1711 conf->seq_write = seq;
1709 activate_bit_delay(conf); 1712 activate_bit_delay(conf);
1710 } 1713 }
@@ -1915,7 +1918,7 @@ static int run(mddev_t *mddev)
1915 goto abort; 1918 goto abort;
1916 } 1919 }
1917 } 1920 }
1918memory = conf->max_nr_stripes * (sizeof(struct stripe_head) + 1921 memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
1919 conf->raid_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024; 1922 conf->raid_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024;
1920 if (grow_stripes(conf, conf->max_nr_stripes)) { 1923 if (grow_stripes(conf, conf->max_nr_stripes)) {
1921 printk(KERN_ERR 1924 printk(KERN_ERR
diff --git a/drivers/md/raid6main.c b/drivers/md/raid6main.c
index eae5a35629c5..0000d162d198 100644
--- a/drivers/md/raid6main.c
+++ b/drivers/md/raid6main.c
@@ -1702,6 +1702,8 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1702 int data_disks = raid_disks - 2; 1702 int data_disks = raid_disks - 2;
1703 sector_t max_sector = mddev->size << 1; 1703 sector_t max_sector = mddev->size << 1;
1704 int sync_blocks; 1704 int sync_blocks;
1705 int still_degraded = 0;
1706 int i;
1705 1707
1706 if (sector_nr >= max_sector) { 1708 if (sector_nr >= max_sector) {
1707 /* just being told to finish up .. nothing much to do */ 1709 /* just being told to finish up .. nothing much to do */
@@ -1710,7 +1712,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1710 if (mddev->curr_resync < max_sector) /* aborted */ 1712 if (mddev->curr_resync < max_sector) /* aborted */
1711 bitmap_end_sync(mddev->bitmap, mddev->curr_resync, 1713 bitmap_end_sync(mddev->bitmap, mddev->curr_resync,
1712 &sync_blocks, 1); 1714 &sync_blocks, 1);
1713 else /* compelted sync */ 1715 else /* completed sync */
1714 conf->fullsync = 0; 1716 conf->fullsync = 0;
1715 bitmap_close_sync(mddev->bitmap); 1717 bitmap_close_sync(mddev->bitmap);
1716 1718
@@ -1748,7 +1750,16 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1748 */ 1750 */
1749 schedule_timeout_uninterruptible(1); 1751 schedule_timeout_uninterruptible(1);
1750 } 1752 }
1751 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 0); 1753 /* Need to check if array will still be degraded after recovery/resync
1754 * We don't need to check the 'failed' flag as when that gets set,
1755 * recovery aborts.
1756 */
1757 for (i=0; i<mddev->raid_disks; i++)
1758 if (conf->disks[i].rdev == NULL)
1759 still_degraded = 1;
1760
1761 bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, still_degraded);
1762
1752 spin_lock(&sh->lock); 1763 spin_lock(&sh->lock);
1753 set_bit(STRIPE_SYNCING, &sh->state); 1764 set_bit(STRIPE_SYNCING, &sh->state);
1754 clear_bit(STRIPE_INSYNC, &sh->state); 1765 clear_bit(STRIPE_INSYNC, &sh->state);
@@ -1784,7 +1795,9 @@ static void raid6d (mddev_t *mddev)
1784 1795
1785 if (conf->seq_flush - conf->seq_write > 0) { 1796 if (conf->seq_flush - conf->seq_write > 0) {
1786 int seq = conf->seq_flush; 1797 int seq = conf->seq_flush;
1798 spin_unlock_irq(&conf->device_lock);
1787 bitmap_unplug(mddev->bitmap); 1799 bitmap_unplug(mddev->bitmap);
1800 spin_lock_irq(&conf->device_lock);
1788 conf->seq_write = seq; 1801 conf->seq_write = seq;
1789 activate_bit_delay(conf); 1802 activate_bit_delay(conf);
1790 } 1803 }
@@ -2145,9 +2158,15 @@ static int raid6_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
2145 /* no point adding a device */ 2158 /* no point adding a device */
2146 return 0; 2159 return 0;
2147 /* 2160 /*
2148 * find the disk ... 2161 * find the disk ... but prefer rdev->saved_raid_disk
2162 * if possible.
2149 */ 2163 */
2150 for (disk=0; disk < mddev->raid_disks; disk++) 2164 if (rdev->saved_raid_disk >= 0 &&
2165 conf->disks[rdev->saved_raid_disk].rdev == NULL)
2166 disk = rdev->saved_raid_disk;
2167 else
2168 disk = 0;
2169 for ( ; disk < mddev->raid_disks; disk++)
2151 if ((p=conf->disks + disk)->rdev == NULL) { 2170 if ((p=conf->disks + disk)->rdev == NULL) {
2152 clear_bit(In_sync, &rdev->flags); 2171 clear_bit(In_sync, &rdev->flags);
2153 rdev->raid_disk = disk; 2172 rdev->raid_disk = disk;
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 4b71fd6f7aed..97fa3fc571c4 100644
--- a/drivers/media/common/ir-common.c
+++ b/drivers/media/common/ir-common.c
@@ -126,6 +126,66 @@ IR_KEYTAB_TYPE ir_codes_winfast[IR_KEYTAB_SIZE] = {
126}; 126};
127EXPORT_SYMBOL_GPL(ir_codes_winfast); 127EXPORT_SYMBOL_GPL(ir_codes_winfast);
128 128
129IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
130 [ 0x59 ] = KEY_MUTE,
131 [ 0x4a ] = KEY_POWER,
132
133 [ 0x18 ] = KEY_TEXT,
134 [ 0x26 ] = KEY_TV,
135 [ 0x3d ] = KEY_PRINT,
136
137 [ 0x48 ] = KEY_RED,
138 [ 0x04 ] = KEY_GREEN,
139 [ 0x11 ] = KEY_YELLOW,
140 [ 0x00 ] = KEY_BLUE,
141
142 [ 0x2d ] = KEY_VOLUMEUP,
143 [ 0x1e ] = KEY_VOLUMEDOWN,
144
145 [ 0x49 ] = KEY_MENU,
146
147 [ 0x16 ] = KEY_CHANNELUP,
148 [ 0x17 ] = KEY_CHANNELDOWN,
149
150 [ 0x20 ] = KEY_UP,
151 [ 0x21 ] = KEY_DOWN,
152 [ 0x22 ] = KEY_LEFT,
153 [ 0x23 ] = KEY_RIGHT,
154 [ 0x0d ] = KEY_SELECT,
155
156
157
158 [ 0x08 ] = KEY_BACK,
159 [ 0x07 ] = KEY_REFRESH,
160
161 [ 0x2f ] = KEY_ZOOM,
162 [ 0x29 ] = KEY_RECORD,
163
164 [ 0x4b ] = KEY_PAUSE,
165 [ 0x4d ] = KEY_REWIND,
166 [ 0x2e ] = KEY_PLAY,
167 [ 0x4e ] = KEY_FORWARD,
168 [ 0x53 ] = KEY_PREVIOUS,
169 [ 0x4c ] = KEY_STOP,
170 [ 0x54 ] = KEY_NEXT,
171
172 [ 0x69 ] = KEY_KP0,
173 [ 0x6a ] = KEY_KP1,
174 [ 0x6b ] = KEY_KP2,
175 [ 0x6c ] = KEY_KP3,
176 [ 0x6d ] = KEY_KP4,
177 [ 0x6e ] = KEY_KP5,
178 [ 0x6f ] = KEY_KP6,
179 [ 0x70 ] = KEY_KP7,
180 [ 0x71 ] = KEY_KP8,
181 [ 0x72 ] = KEY_KP9,
182
183 [ 0x74 ] = KEY_CHANNEL,
184 [ 0x0a ] = KEY_BACKSPACE,
185};
186
187EXPORT_SYMBOL_GPL(ir_codes_pinnacle);
188
129/* empty keytable, can be used as placeholder for not-yet created keytables */ 189/* empty keytable, can be used as placeholder for not-yet created keytables */
130IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = { 190IR_KEYTAB_TYPE ir_codes_empty[IR_KEYTAB_SIZE] = {
131 [ 42 ] = KEY_COFFEE, 191 [ 42 ] = KEY_COFFEE,
@@ -253,6 +313,7 @@ void ir_input_init(struct input_dev *dev, struct ir_input_state *ir,
253 if (ir_codes) 313 if (ir_codes)
254 memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes)); 314 memcpy(ir->ir_codes, ir_codes, sizeof(ir->ir_codes));
255 315
316
256 dev->keycode = ir->ir_codes; 317 dev->keycode = ir->ir_codes;
257 dev->keycodesize = sizeof(IR_KEYTAB_TYPE); 318 dev->keycodesize = sizeof(IR_KEYTAB_TYPE);
258 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/Kconfig b/drivers/media/dvb/b2c2/Kconfig
index d7417eac2aba..2583a865a58e 100644
--- a/drivers/media/dvb/b2c2/Kconfig
+++ b/drivers/media/dvb/b2c2/Kconfig
@@ -7,6 +7,7 @@ config DVB_B2C2_FLEXCOP
7 select DVB_NXT2002 7 select DVB_NXT2002
8 select DVB_STV0297 8 select DVB_STV0297
9 select DVB_BCM3510 9 select DVB_BCM3510
10 select DVB_LGDT330X
10 help 11 help
11 Support for the digital TV receiver chip made by B2C2 Inc. included in 12 Support for the digital TV receiver chip made by B2C2 Inc. included in
12 Technisats PCI cards and USB boxes. 13 Technisats PCI cards and USB boxes.
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-hw-filter.c b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
index 75cf237196eb..b386cc66c6b3 100644
--- a/drivers/media/dvb/b2c2/flexcop-hw-filter.c
+++ b/drivers/media/dvb/b2c2/flexcop-hw-filter.c
@@ -19,7 +19,7 @@ void flexcop_smc_ctrl(struct flexcop_device *fc, int onoff)
19 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff); 19 flexcop_set_ibi_value(ctrl_208,SMC_Enable_sig,onoff);
20} 20}
21 21
22void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff) 22static void flexcop_null_filter_ctrl(struct flexcop_device *fc, int onoff)
23{ 23{
24 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff); 24 flexcop_set_ibi_value(ctrl_208,Null_filter_sig,onoff);
25} 25}
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 a1607e7d6d6b..336fc284fa52 100644
--- a/drivers/media/dvb/cinergyT2/cinergyT2.c
+++ b/drivers/media/dvb/cinergyT2/cinergyT2.c
@@ -276,7 +276,7 @@ static void cinergyt2_free_stream_urbs (struct cinergyt2 *cinergyt2)
276 if (cinergyt2->stream_urb[i]) 276 if (cinergyt2->stream_urb[i])
277 usb_free_urb(cinergyt2->stream_urb[i]); 277 usb_free_urb(cinergyt2->stream_urb[i]);
278 278
279 pci_free_consistent(NULL, STREAM_URB_COUNT*STREAM_BUF_SIZE, 279 usb_buffer_free(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
280 cinergyt2->streambuf, cinergyt2->streambuf_dmahandle); 280 cinergyt2->streambuf, cinergyt2->streambuf_dmahandle);
281} 281}
282 282
@@ -284,9 +284,8 @@ static int cinergyt2_alloc_stream_urbs (struct cinergyt2 *cinergyt2)
284{ 284{
285 int i; 285 int i;
286 286
287 cinergyt2->streambuf = pci_alloc_consistent(NULL, 287 cinergyt2->streambuf = usb_buffer_alloc(cinergyt2->udev, STREAM_URB_COUNT*STREAM_BUF_SIZE,
288 STREAM_URB_COUNT*STREAM_BUF_SIZE, 288 SLAB_KERNEL, &cinergyt2->streambuf_dmahandle);
289 &cinergyt2->streambuf_dmahandle);
290 if (!cinergyt2->streambuf) { 289 if (!cinergyt2->streambuf) {
291 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n"); 290 dprintk(1, "failed to alloc consistent stream memory area, bailing out!\n");
292 return -ENOMEM; 291 return -ENOMEM;
@@ -773,13 +772,15 @@ static int cinergyt2_register_rc(struct cinergyt2 *cinergyt2)
773 input_dev->name = DRIVER_NAME " remote control"; 772 input_dev->name = DRIVER_NAME " remote control";
774 input_dev->phys = cinergyt2->phys; 773 input_dev->phys = cinergyt2->phys;
775 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); 774 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP);
776 for (i = 0; ARRAY_SIZE(rc_keys); i += 3) 775 for (i = 0; i < ARRAY_SIZE(rc_keys); i += 3)
777 set_bit(rc_keys[i + 2], input_dev->keybit); 776 set_bit(rc_keys[i + 2], input_dev->keybit);
778 input_dev->keycodesize = 0; 777 input_dev->keycodesize = 0;
779 input_dev->keycodemax = 0; 778 input_dev->keycodemax = 0;
780 779
781 input_register_device(cinergyt2->rc_input_dev); 780 input_register_device(cinergyt2->rc_input_dev);
782 schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2); 781 schedule_delayed_work(&cinergyt2->rc_query_work, HZ/2);
782
783 return 0;
783} 784}
784 785
785static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2) 786static void cinergyt2_unregister_rc(struct cinergyt2 *cinergyt2)
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 2aa767f9bd7d..5956c35d34ac 100644
--- a/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
+++ b/drivers/media/dvb/dvb-core/dvb_ca_en50221.c
@@ -35,7 +35,7 @@
35#include <linux/moduleparam.h> 35#include <linux/moduleparam.h>
36#include <linux/vmalloc.h> 36#include <linux/vmalloc.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <linux/rwsem.h> 38#include <linux/spinlock.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40 40
41#include "dvb_ca_en50221.h" 41#include "dvb_ca_en50221.h"
@@ -111,9 +111,6 @@ struct dvb_ca_slot {
111 /* size of the buffer to use when talking to the CAM */ 111 /* size of the buffer to use when talking to the CAM */
112 int link_buf_size; 112 int link_buf_size;
113 113
114 /* semaphore for syncing access to slot structure */
115 struct rw_semaphore sem;
116
117 /* buffer for incoming packets */ 114 /* buffer for incoming packets */
118 struct dvb_ringbuffer rx_buffer; 115 struct dvb_ringbuffer rx_buffer;
119 116
@@ -501,7 +498,7 @@ static int dvb_ca_en50221_parse_attributes(struct dvb_ca_private *ca, int slot)
501 /* process the CFTABLE_ENTRY tuples, and any after those */ 498 /* process the CFTABLE_ENTRY tuples, and any after those */
502 while ((!end_chain) && (address < 0x1000)) { 499 while ((!end_chain) && (address < 0x1000)) {
503 if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType, 500 if ((status = dvb_ca_en50221_read_tuple(ca, slot, &address, &tupleType,
504 &tupleLength, tuple)) < 0) 501 &tupleLength, tuple)) < 0)
505 return status; 502 return status;
506 switch (tupleType) { 503 switch (tupleType) {
507 case 0x1B: // CISTPL_CFTABLE_ENTRY 504 case 0x1B: // CISTPL_CFTABLE_ENTRY
@@ -602,14 +599,11 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
602 if (ebuf == NULL) { 599 if (ebuf == NULL) {
603 int buf_free; 600 int buf_free;
604 601
605 down_read(&ca->slot_info[slot].sem);
606 if (ca->slot_info[slot].rx_buffer.data == NULL) { 602 if (ca->slot_info[slot].rx_buffer.data == NULL) {
607 up_read(&ca->slot_info[slot].sem);
608 status = -EIO; 603 status = -EIO;
609 goto exit; 604 goto exit;
610 } 605 }
611 buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer); 606 buf_free = dvb_ringbuffer_free(&ca->slot_info[slot].rx_buffer);
612 up_read(&ca->slot_info[slot].sem);
613 607
614 if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) { 608 if (buf_free < (ca->slot_info[slot].link_buf_size + DVB_RINGBUFFER_PKTHDRSIZE)) {
615 status = -EAGAIN; 609 status = -EAGAIN;
@@ -680,14 +674,11 @@ static int dvb_ca_en50221_read_data(struct dvb_ca_private *ca, int slot, u8 * eb
680 674
681 /* OK, add it to the receive buffer, or copy into external buffer if supplied */ 675 /* OK, add it to the receive buffer, or copy into external buffer if supplied */
682 if (ebuf == NULL) { 676 if (ebuf == NULL) {
683 down_read(&ca->slot_info[slot].sem);
684 if (ca->slot_info[slot].rx_buffer.data == NULL) { 677 if (ca->slot_info[slot].rx_buffer.data == NULL) {
685 up_read(&ca->slot_info[slot].sem);
686 status = -EIO; 678 status = -EIO;
687 goto exit; 679 goto exit;
688 } 680 }
689 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read); 681 dvb_ringbuffer_pkt_write(&ca->slot_info[slot].rx_buffer, buf, bytes_read);
690 up_read(&ca->slot_info[slot].sem);
691 } else { 682 } else {
692 memcpy(ebuf, buf, bytes_read); 683 memcpy(ebuf, buf, bytes_read);
693 } 684 }
@@ -802,12 +793,8 @@ static int dvb_ca_en50221_slot_shutdown(struct dvb_ca_private *ca, int slot)
802{ 793{
803 dprintk("%s\n", __FUNCTION__); 794 dprintk("%s\n", __FUNCTION__);
804 795
805 down_write(&ca->slot_info[slot].sem);
806 ca->pub->slot_shutdown(ca->pub, slot); 796 ca->pub->slot_shutdown(ca->pub, slot);
807 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE; 797 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_NONE;
808 vfree(ca->slot_info[slot].rx_buffer.data);
809 ca->slot_info[slot].rx_buffer.data = NULL;
810 up_write(&ca->slot_info[slot].sem);
811 798
812 /* need to wake up all processes to check if they're now 799 /* need to wake up all processes to check if they're now
813 trying to write to a defunct CAM */ 800 trying to write to a defunct CAM */
@@ -893,7 +880,7 @@ void dvb_ca_en50221_frda_irq(struct dvb_ca_en50221 *pubca, int slot)
893 880
894 case DVB_CA_SLOTSTATE_RUNNING: 881 case DVB_CA_SLOTSTATE_RUNNING:
895 if (ca->open) 882 if (ca->open)
896 dvb_ca_en50221_read_data(ca, slot, NULL, 0); 883 dvb_ca_en50221_thread_wakeup(ca);
897 break; 884 break;
898 } 885 }
899} 886}
@@ -1127,16 +1114,16 @@ static int dvb_ca_en50221_thread(void *data)
1127 break; 1114 break;
1128 } 1115 }
1129 1116
1130 rxbuf = vmalloc(RX_BUFFER_SIZE); 1117 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1131 if (rxbuf == NULL) { 1118 rxbuf = vmalloc(RX_BUFFER_SIZE);
1132 printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num); 1119 if (rxbuf == NULL) {
1133 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID; 1120 printk("dvb_ca adapter %d: Unable to allocate CAM rx buffer :(\n", ca->dvbdev->adapter->num);
1134 dvb_ca_en50221_thread_update_delay(ca); 1121 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_INVALID;
1135 break; 1122 dvb_ca_en50221_thread_update_delay(ca);
1123 break;
1124 }
1125 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
1136 } 1126 }
1137 down_write(&ca->slot_info[slot].sem);
1138 dvb_ringbuffer_init(&ca->slot_info[slot].rx_buffer, rxbuf, RX_BUFFER_SIZE);
1139 up_write(&ca->slot_info[slot].sem);
1140 1127
1141 ca->pub->slot_ts_enable(ca->pub, slot); 1128 ca->pub->slot_ts_enable(ca->pub, slot);
1142 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING; 1129 ca->slot_info[slot].slot_state = DVB_CA_SLOTSTATE_RUNNING;
@@ -1148,11 +1135,7 @@ static int dvb_ca_en50221_thread(void *data)
1148 if (!ca->open) 1135 if (!ca->open)
1149 continue; 1136 continue;
1150 1137
1151 // no need to poll if the CAM supports IRQs 1138 // poll slots for data
1152 if (ca->slot_info[slot].da_irq_supported)
1153 break;
1154
1155 // poll mode
1156 pktcount = 0; 1139 pktcount = 0;
1157 while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) { 1140 while ((status = dvb_ca_en50221_read_data(ca, slot, NULL, 0)) > 0) {
1158 if (!ca->open) 1141 if (!ca->open)
@@ -1367,12 +1350,13 @@ exit:
1367/** 1350/**
1368 * Condition for waking up in dvb_ca_en50221_io_read_condition 1351 * Condition for waking up in dvb_ca_en50221_io_read_condition
1369 */ 1352 */
1370static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *result, int *_slot) 1353static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca,
1354 int *result, int *_slot)
1371{ 1355{
1372 int slot; 1356 int slot;
1373 int slot_count = 0; 1357 int slot_count = 0;
1374 int idx; 1358 int idx;
1375 int fraglen; 1359 size_t fraglen;
1376 int connection_id = -1; 1360 int connection_id = -1;
1377 int found = 0; 1361 int found = 0;
1378 u8 hdr[2]; 1362 u8 hdr[2];
@@ -1382,10 +1366,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *resu
1382 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING) 1366 if (ca->slot_info[slot].slot_state != DVB_CA_SLOTSTATE_RUNNING)
1383 goto nextslot; 1367 goto nextslot;
1384 1368
1385 down_read(&ca->slot_info[slot].sem);
1386
1387 if (ca->slot_info[slot].rx_buffer.data == NULL) { 1369 if (ca->slot_info[slot].rx_buffer.data == NULL) {
1388 up_read(&ca->slot_info[slot].sem);
1389 return 0; 1370 return 0;
1390 } 1371 }
1391 1372
@@ -1403,10 +1384,7 @@ static int dvb_ca_en50221_io_read_condition(struct dvb_ca_private *ca, int *resu
1403 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen); 1384 idx = dvb_ringbuffer_pkt_next(&ca->slot_info[slot].rx_buffer, idx, &fraglen);
1404 } 1385 }
1405 1386
1406 if (!found) 1387nextslot:
1407 up_read(&ca->slot_info[slot].sem);
1408
1409 nextslot:
1410 slot = (slot + 1) % ca->slot_count; 1388 slot = (slot + 1) % ca->slot_count;
1411 slot_count++; 1389 slot_count++;
1412 } 1390 }
@@ -1511,8 +1489,7 @@ static ssize_t dvb_ca_en50221_io_read(struct file *file, char __user * buf,
1511 goto exit; 1489 goto exit;
1512 status = pktlen; 1490 status = pktlen;
1513 1491
1514 exit: 1492exit:
1515 up_read(&ca->slot_info[slot].sem);
1516 return status; 1493 return status;
1517} 1494}
1518 1495
@@ -1544,11 +1521,11 @@ static int dvb_ca_en50221_io_open(struct inode *inode, struct file *file)
1544 for (i = 0; i < ca->slot_count; i++) { 1521 for (i = 0; i < ca->slot_count; i++) {
1545 1522
1546 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) { 1523 if (ca->slot_info[i].slot_state == DVB_CA_SLOTSTATE_RUNNING) {
1547 down_write(&ca->slot_info[i].sem);
1548 if (ca->slot_info[i].rx_buffer.data != NULL) { 1524 if (ca->slot_info[i].rx_buffer.data != NULL) {
1525 /* it is safe to call this here without locks because
1526 * ca->open == 0. Data is not read in this case */
1549 dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer); 1527 dvb_ringbuffer_flush(&ca->slot_info[i].rx_buffer);
1550 } 1528 }
1551 up_write(&ca->slot_info[i].sem);
1552 } 1529 }
1553 } 1530 }
1554 1531
@@ -1607,7 +1584,6 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
1607 dprintk("%s\n", __FUNCTION__); 1584 dprintk("%s\n", __FUNCTION__);
1608 1585
1609 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1586 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
1610 up_read(&ca->slot_info[slot].sem);
1611 mask |= POLLIN; 1587 mask |= POLLIN;
1612 } 1588 }
1613 1589
@@ -1619,7 +1595,6 @@ static unsigned int dvb_ca_en50221_io_poll(struct file *file, poll_table * wait)
1619 poll_wait(file, &ca->wait_queue, wait); 1595 poll_wait(file, &ca->wait_queue, wait);
1620 1596
1621 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) { 1597 if (dvb_ca_en50221_io_read_condition(ca, &result, &slot) == 1) {
1622 up_read(&ca->slot_info[slot].sem);
1623 mask |= POLLIN; 1598 mask |= POLLIN;
1624 } 1599 }
1625 1600
@@ -1709,7 +1684,6 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1709 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE; 1684 ca->slot_info[i].slot_state = DVB_CA_SLOTSTATE_NONE;
1710 atomic_set(&ca->slot_info[i].camchange_count, 0); 1685 atomic_set(&ca->slot_info[i].camchange_count, 0);
1711 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED; 1686 ca->slot_info[i].camchange_type = DVB_CA_EN50221_CAMCHANGE_REMOVED;
1712 init_rwsem(&ca->slot_info[i].sem);
1713 } 1687 }
1714 1688
1715 if (signal_pending(current)) { 1689 if (signal_pending(current)) {
@@ -1729,7 +1703,7 @@ int dvb_ca_en50221_init(struct dvb_adapter *dvb_adapter,
1729 ca->thread_pid = ret; 1703 ca->thread_pid = ret;
1730 return 0; 1704 return 0;
1731 1705
1732 error: 1706error:
1733 if (ca != NULL) { 1707 if (ca != NULL) {
1734 if (ca->dvbdev != NULL) 1708 if (ca->dvbdev != NULL)
1735 dvb_unregister_device(ca->dvbdev); 1709 dvb_unregister_device(ca->dvbdev);
@@ -1771,6 +1745,9 @@ void dvb_ca_en50221_release(struct dvb_ca_en50221 *pubca)
1771 1745
1772 for (i = 0; i < ca->slot_count; i++) { 1746 for (i = 0; i < ca->slot_count; i++) {
1773 dvb_ca_en50221_slot_shutdown(ca, i); 1747 dvb_ca_en50221_slot_shutdown(ca, i);
1748 if (ca->slot_info[i].rx_buffer.data != NULL) {
1749 vfree(ca->slot_info[i].rx_buffer.data);
1750 }
1774 } 1751 }
1775 kfree(ca->slot_info); 1752 kfree(ca->slot_info);
1776 dvb_unregister_device(ca->dvbdev); 1753 dvb_unregister_device(ca->dvbdev);
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 87935490bfb2..86bba81e851e 100644
--- a/drivers/media/dvb/dvb-core/dvb_net.c
+++ b/drivers/media/dvb/dvb-core/dvb_net.c
@@ -151,6 +151,8 @@ struct dvb_net_priv {
151 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */ 151 unsigned char ule_bridged; /* Whether the ULE_BRIDGED extension header was found. */
152 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */ 152 int ule_sndu_remain; /* Nr. of bytes still required for current ULE SNDU. */
153 unsigned long ts_count; /* Current ts cell counter. */ 153 unsigned long ts_count; /* Current ts cell counter. */
154
155 struct semaphore mutex;
154}; 156};
155 157
156 158
@@ -711,7 +713,7 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
711 if (buffer1_len > 32768) 713 if (buffer1_len > 32768)
712 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len); 714 printk(KERN_WARNING "length > 32k: %zu.\n", buffer1_len);
713 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n", 715 /* printk("TS callback: %u bytes, %u TS cells @ %p.\n",
714 buffer1_len, buffer1_len / TS_SZ, buffer1); */ 716 buffer1_len, buffer1_len / TS_SZ, buffer1); */
715 dvb_net_ule(dev, buffer1, buffer1_len); 717 dvb_net_ule(dev, buffer1, buffer1_len);
716 return 0; 718 return 0;
717} 719}
@@ -719,8 +721,8 @@ static int dvb_net_ts_callback(const u8 *buffer1, size_t buffer1_len,
719 721
720static 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)
721{ 723{
722 u8 *eth; 724 u8 *eth;
723 struct sk_buff *skb; 725 struct sk_buff *skb;
724 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);
725 int snap = 0; 727 int snap = 0;
726 728
@@ -752,7 +754,7 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
752 return; 754 return;
753 } 755 }
754 snap = 8; 756 snap = 8;
755 } 757 }
756 if (pkt[7]) { 758 if (pkt[7]) {
757 /* FIXME: assemble datagram from multiple sections */ 759 /* FIXME: assemble datagram from multiple sections */
758 stats->rx_errors++; 760 stats->rx_errors++;
@@ -776,14 +778,14 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
776 memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap); 778 memcpy(eth + 14, pkt + 12 + snap, pkt_len - 12 - 4 - snap);
777 779
778 /* create ethernet header: */ 780 /* create ethernet header: */
779 eth[0]=pkt[0x0b]; 781 eth[0]=pkt[0x0b];
780 eth[1]=pkt[0x0a]; 782 eth[1]=pkt[0x0a];
781 eth[2]=pkt[0x09]; 783 eth[2]=pkt[0x09];
782 eth[3]=pkt[0x08]; 784 eth[3]=pkt[0x08];
783 eth[4]=pkt[0x04]; 785 eth[4]=pkt[0x04];
784 eth[5]=pkt[0x03]; 786 eth[5]=pkt[0x03];
785 787
786 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;
787 789
788 if (snap) { 790 if (snap) {
789 eth[12] = pkt[18]; 791 eth[12] = pkt[18];
@@ -805,7 +807,7 @@ static void dvb_net_sec(struct net_device *dev, u8 *pkt, int pkt_len)
805 807
806 stats->rx_packets++; 808 stats->rx_packets++;
807 stats->rx_bytes+=skb->len; 809 stats->rx_bytes+=skb->len;
808 netif_rx(skb); 810 netif_rx(skb);
809} 811}
810 812
811static 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,
@@ -813,7 +815,7 @@ static int dvb_net_sec_callback(const u8 *buffer1, size_t buffer1_len,
813 struct dmx_section_filter *filter, 815 struct dmx_section_filter *filter,
814 enum dmx_success success) 816 enum dmx_success success)
815{ 817{
816 struct net_device *dev = filter->priv; 818 struct net_device *dev = filter->priv;
817 819
818 /** 820 /**
819 * we rely on the DVB API definition where exactly one complete 821 * we rely on the DVB API definition where exactly one complete
@@ -881,12 +883,13 @@ static int dvb_net_filter_sec_set(struct net_device *dev,
881 883
882static int dvb_net_feed_start(struct net_device *dev) 884static int dvb_net_feed_start(struct net_device *dev)
883{ 885{
884 int ret, i; 886 int ret = 0, i;
885 struct dvb_net_priv *priv = dev->priv; 887 struct dvb_net_priv *priv = dev->priv;
886 struct dmx_demux *demux = priv->demux; 888 struct dmx_demux *demux = priv->demux;
887 unsigned char *mac = (unsigned char *) dev->dev_addr; 889 unsigned char *mac = (unsigned char *) dev->dev_addr;
888 890
889 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);
890 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0]) 893 if (priv->tsfeed || priv->secfeed || priv->secfilter || priv->multi_secfilter[0])
891 printk("%s: BUG %d\n", __FUNCTION__, __LINE__); 894 printk("%s: BUG %d\n", __FUNCTION__, __LINE__);
892 895
@@ -900,7 +903,7 @@ static int dvb_net_feed_start(struct net_device *dev)
900 dvb_net_sec_callback); 903 dvb_net_sec_callback);
901 if (ret<0) { 904 if (ret<0) {
902 printk("%s: could not allocate section feed\n", dev->name); 905 printk("%s: could not allocate section feed\n", dev->name);
903 return ret; 906 goto error;
904 } 907 }
905 908
906 ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1); 909 ret = priv->secfeed->set(priv->secfeed, priv->pid, 32768, 1);
@@ -909,7 +912,7 @@ static int dvb_net_feed_start(struct net_device *dev)
909 printk("%s: could not set section feed\n", dev->name); 912 printk("%s: could not set section feed\n", dev->name);
910 priv->demux->release_section_feed(priv->demux, priv->secfeed); 913 priv->demux->release_section_feed(priv->demux, priv->secfeed);
911 priv->secfeed=NULL; 914 priv->secfeed=NULL;
912 return ret; 915 goto error;
913 } 916 }
914 917
915 if (priv->rx_mode != RX_MODE_PROMISC) { 918 if (priv->rx_mode != RX_MODE_PROMISC) {
@@ -948,7 +951,7 @@ static int dvb_net_feed_start(struct net_device *dev)
948 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback); 951 ret = demux->allocate_ts_feed(demux, &priv->tsfeed, dvb_net_ts_callback);
949 if (ret < 0) { 952 if (ret < 0) {
950 printk("%s: could not allocate ts feed\n", dev->name); 953 printk("%s: could not allocate ts feed\n", dev->name);
951 return ret; 954 goto error;
952 } 955 }
953 956
954 /* Set netdevice pointer for ts decaps callback. */ 957 /* Set netdevice pointer for ts decaps callback. */
@@ -962,23 +965,26 @@ static int dvb_net_feed_start(struct net_device *dev)
962 printk("%s: could not set ts feed\n", dev->name); 965 printk("%s: could not set ts feed\n", dev->name);
963 priv->demux->release_ts_feed(priv->demux, priv->tsfeed); 966 priv->demux->release_ts_feed(priv->demux, priv->tsfeed);
964 priv->tsfeed = NULL; 967 priv->tsfeed = NULL;
965 return ret; 968 goto error;
966 } 969 }
967 970
968 dprintk("%s: start filtering\n", __FUNCTION__); 971 dprintk("%s: start filtering\n", __FUNCTION__);
969 priv->tsfeed->start_filtering(priv->tsfeed); 972 priv->tsfeed->start_filtering(priv->tsfeed);
970 } else 973 } else
971 return -EINVAL; 974 ret = -EINVAL;
972 975
973 return 0; 976error:
977 up(&priv->mutex);
978 return ret;
974} 979}
975 980
976static int dvb_net_feed_stop(struct net_device *dev) 981static int dvb_net_feed_stop(struct net_device *dev)
977{ 982{
978 struct dvb_net_priv *priv = dev->priv; 983 struct dvb_net_priv *priv = dev->priv;
979 int i; 984 int i, ret = 0;
980 985
981 dprintk("%s\n", __FUNCTION__); 986 dprintk("%s\n", __FUNCTION__);
987 down(&priv->mutex);
982 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) { 988 if (priv->feedtype == DVB_NET_FEEDTYPE_MPE) {
983 if (priv->secfeed) { 989 if (priv->secfeed) {
984 if (priv->secfeed->is_filtering) { 990 if (priv->secfeed->is_filtering) {
@@ -1019,8 +1025,9 @@ static int dvb_net_feed_stop(struct net_device *dev)
1019 else 1025 else
1020 printk("%s: no ts feed to stop\n", dev->name); 1026 printk("%s: no ts feed to stop\n", dev->name);
1021 } else 1027 } else
1022 return -EINVAL; 1028 ret = -EINVAL;
1023 return 0; 1029 up(&priv->mutex);
1030 return ret;
1024} 1031}
1025 1032
1026 1033
@@ -1044,8 +1051,8 @@ static void wq_set_multicast_list (void *data)
1044 struct dvb_net_priv *priv = dev->priv; 1051 struct dvb_net_priv *priv = dev->priv;
1045 1052
1046 dvb_net_feed_stop(dev); 1053 dvb_net_feed_stop(dev);
1047
1048 priv->rx_mode = RX_MODE_UNI; 1054 priv->rx_mode = RX_MODE_UNI;
1055 spin_lock_bh(&dev->xmit_lock);
1049 1056
1050 if (dev->flags & IFF_PROMISC) { 1057 if (dev->flags & IFF_PROMISC) {
1051 dprintk("%s: promiscuous mode\n", dev->name); 1058 dprintk("%s: promiscuous mode\n", dev->name);
@@ -1070,6 +1077,7 @@ static void wq_set_multicast_list (void *data)
1070 } 1077 }
1071 } 1078 }
1072 1079
1080 spin_unlock_bh(&dev->xmit_lock);
1073 dvb_net_feed_start(dev); 1081 dvb_net_feed_start(dev);
1074} 1082}
1075 1083
@@ -1121,12 +1129,12 @@ static int dvb_net_stop(struct net_device *dev)
1121 struct dvb_net_priv *priv = dev->priv; 1129 struct dvb_net_priv *priv = dev->priv;
1122 1130
1123 priv->in_use--; 1131 priv->in_use--;
1124 return dvb_net_feed_stop(dev); 1132 return dvb_net_feed_stop(dev);
1125} 1133}
1126 1134
1127static 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)
1128{ 1136{
1129 return &((struct dvb_net_priv*) dev->priv)->stats; 1137 return &((struct dvb_net_priv*) dev->priv)->stats;
1130} 1138}
1131 1139
1132static void dvb_net_setup(struct net_device *dev) 1140static void dvb_net_setup(struct net_device *dev)
@@ -1200,6 +1208,7 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype)
1200 1208
1201 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net); 1209 INIT_WORK(&priv->set_multicast_list_wq, wq_set_multicast_list, net);
1202 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net); 1210 INIT_WORK(&priv->restart_net_feed_wq, wq_restart_net_feed, net);
1211 init_MUTEX(&priv->mutex);
1203 1212
1204 net->base_addr = pid; 1213 net->base_addr = pid;
1205 1214
@@ -1351,10 +1360,10 @@ static struct file_operations dvb_net_fops = {
1351}; 1360};
1352 1361
1353static struct dvb_device dvbdev_net = { 1362static struct dvb_device dvbdev_net = {
1354 .priv = NULL, 1363 .priv = NULL,
1355 .users = 1, 1364 .users = 1,
1356 .writers = 1, 1365 .writers = 1,
1357 .fops = &dvb_net_fops, 1366 .fops = &dvb_net_fops,
1358}; 1367};
1359 1368
1360 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 49f541d9a042..8c7beffb045f 100644
--- a/drivers/media/dvb/dvb-usb/a800.c
+++ b/drivers/media/dvb/dvb-usb/a800.c
@@ -65,7 +65,7 @@ static struct dvb_usb_rc_key a800_rc_keys[] = {
65 65
66}; 66};
67 67
68int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 68static int a800_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
69{ 69{
70 u8 key[5]; 70 u8 key[5];
71 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0), 71 if (usb_control_msg(d->udev,usb_rcvctrlpipe(d->udev,0),
diff --git a/drivers/media/dvb/dvb-usb/dibusb-common.c b/drivers/media/dvb/dvb-usb/dibusb-common.c
index 00b946419b40..269d899da488 100644
--- a/drivers/media/dvb/dvb-usb/dibusb-common.c
+++ b/drivers/media/dvb/dvb-usb/dibusb-common.c
@@ -21,9 +21,9 @@ MODULE_LICENSE("GPL");
21int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff) 21int dibusb_streaming_ctrl(struct dvb_usb_device *d, int onoff)
22{ 22{
23 if (d->priv != NULL) { 23 if (d->priv != NULL) {
24 struct dib_fe_xfer_ops *ops = d->priv; 24 struct dibusb_state *st = d->priv;
25 if (ops->fifo_ctrl != NULL) 25 if (st->ops.fifo_ctrl != NULL)
26 if (ops->fifo_ctrl(d->fe,onoff)) { 26 if (st->ops.fifo_ctrl(d->fe,onoff)) {
27 err("error while controlling the fifo of the demod."); 27 err("error while controlling the fifo of the demod.");
28 return -ENODEV; 28 return -ENODEV;
29 } 29 }
@@ -35,9 +35,9 @@ EXPORT_SYMBOL(dibusb_streaming_ctrl);
35int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff) 35int dibusb_pid_filter(struct dvb_usb_device *d, int index, u16 pid, int onoff)
36{ 36{
37 if (d->priv != NULL) { 37 if (d->priv != NULL) {
38 struct dib_fe_xfer_ops *ops = d->priv; 38 struct dibusb_state *st = d->priv;
39 if (d->pid_filtering && ops->pid_ctrl != NULL) 39 if (st->ops.pid_ctrl != NULL)
40 ops->pid_ctrl(d->fe,index,pid,onoff); 40 st->ops.pid_ctrl(d->fe,index,pid,onoff);
41 } 41 }
42 return 0; 42 return 0;
43} 43}
@@ -46,9 +46,9 @@ EXPORT_SYMBOL(dibusb_pid_filter);
46int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff) 46int dibusb_pid_filter_ctrl(struct dvb_usb_device *d, int onoff)
47{ 47{
48 if (d->priv != NULL) { 48 if (d->priv != NULL) {
49 struct dib_fe_xfer_ops *ops = d->priv; 49 struct dibusb_state *st = d->priv;
50 if (ops->pid_parse != NULL) 50 if (st->ops.pid_parse != NULL)
51 if (ops->pid_parse(d->fe,onoff) < 0) 51 if (st->ops.pid_parse(d->fe,onoff) < 0)
52 err("could not handle pid_parser"); 52 err("could not handle pid_parser");
53 } 53 }
54 return 0; 54 return 0;
diff --git a/drivers/media/dvb/dvb-usb/digitv.c b/drivers/media/dvb/dvb-usb/digitv.c
index 74545f82eff1..f98e306a5759 100644
--- a/drivers/media/dvb/dvb-usb/digitv.c
+++ b/drivers/media/dvb/dvb-usb/digitv.c
@@ -148,7 +148,7 @@ static struct dvb_usb_rc_key digitv_rc_keys[] = {
148}; 148};
149 149
150/* TODO is it really the NEC protocol ? */ 150/* TODO is it really the NEC protocol ? */
151int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state) 151static int digitv_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
152{ 152{
153 u8 key[5]; 153 u8 key[5];
154 154
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index a902059812a2..dd8e0b94edba 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -23,7 +23,7 @@ module_param_named(disable_rc_polling, dvb_usb_disable_rc_polling, int, 0644);
23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0)."); 23MODULE_PARM_DESC(disable_rc_polling, "disable remote control polling (default: 0).");
24 24
25/* general initialization functions */ 25/* general initialization functions */
26int dvb_usb_exit(struct dvb_usb_device *d) 26static int dvb_usb_exit(struct dvb_usb_device *d)
27{ 27{
28 deb_info("state before exiting everything: %x\n",d->state); 28 deb_info("state before exiting everything: %x\n",d->state);
29 dvb_usb_remote_exit(d); 29 dvb_usb_remote_exit(d);
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/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/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 9f639297a9f2..5de0e6d350b1 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -2,12 +2,12 @@
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>
9 9
10 Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk> 10 Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
11 11
12 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
diff --git a/drivers/media/dvb/frontends/cx22702.h b/drivers/media/dvb/frontends/cx22702.h
index 11f86806756e..5633976a58f1 100644
--- a/drivers/media/dvb/frontends/cx22702.h
+++ b/drivers/media/dvb/frontends/cx22702.h
@@ -2,12 +2,12 @@
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>
9 9
10 Copyright (C) 2004 Steven Toth <steve@toth.demon.co.uk> 10 Copyright (C) 2004 Steven Toth <stoth@hauppauge.com>
11 11
12 This program is free software; you can redistribute it and/or modify 12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by 13 it under the terms of the GNU General Public License as published by
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 bad0933eb714..aeafef46e3eb 100644
--- a/drivers/media/dvb/frontends/nxt200x.c
+++ b/drivers/media/dvb/frontends/nxt200x.c
@@ -44,6 +44,8 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/module.h> 45#include <linux/module.h>
46#include <linux/moduleparam.h> 46#include <linux/moduleparam.h>
47#include <linux/slab.h>
48#include <linux/string.h>
47 49
48#include "dvb_frontend.h" 50#include "dvb_frontend.h"
49#include "dvb-pll.h" 51#include "dvb-pll.h"
@@ -337,7 +339,7 @@ static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
337 switch (state->demod_chip) { 339 switch (state->demod_chip) {
338 case NXT2004: 340 case NXT2004:
339 if (i2c_writebytes(state, state->config->pll_address, data, 4)) 341 if (i2c_writebytes(state, state->config->pll_address, data, 4))
340 printk(KERN_WARNING "nxt200x: error writing to tuner\n"); 342 printk(KERN_WARNING "nxt200x: error writing to tuner\n");
341 /* wait until we have a lock */ 343 /* wait until we have a lock */
342 while (count < 20) { 344 while (count < 20) {
343 i2c_readbytes(state, state->config->pll_address, &buf, 1); 345 i2c_readbytes(state, state->config->pll_address, &buf, 1);
@@ -495,7 +497,7 @@ static int nxt2004_load_firmware (struct dvb_frontend* fe, const struct firmware
495 497
496 /* calculate firmware CRC */ 498 /* calculate firmware CRC */
497 for (position = 0; position < fw->size; position++) { 499 for (position = 0; position < fw->size; position++) {
498 crc = nxt200x_crc(crc, fw->data[position]); 500 crc = nxt200x_crc(crc, fw->data[position]);
499 } 501 }
500 502
501 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/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
index c6d276618e86..ad8647a3c85e 100644
--- a/drivers/media/dvb/frontends/ves1820.c
+++ b/drivers/media/dvb/frontends/ves1820.c
@@ -140,25 +140,25 @@ static int ves1820_set_symbolrate(struct ves1820_state *state, u32 symbolrate)
140 /* yeuch! */ 140 /* yeuch! */
141 fpxin = state->config->xin * 10; 141 fpxin = state->config->xin * 10;
142 fptmp = fpxin; do_div(fptmp, 123); 142 fptmp = fpxin; do_div(fptmp, 123);
143 if (symbolrate < fptmp); 143 if (symbolrate < fptmp)
144 SFIL = 1; 144 SFIL = 1;
145 fptmp = fpxin; do_div(fptmp, 160); 145 fptmp = fpxin; do_div(fptmp, 160);
146 if (symbolrate < fptmp); 146 if (symbolrate < fptmp)
147 SFIL = 0; 147 SFIL = 0;
148 fptmp = fpxin; do_div(fptmp, 246); 148 fptmp = fpxin; do_div(fptmp, 246);
149 if (symbolrate < fptmp); 149 if (symbolrate < fptmp)
150 SFIL = 1; 150 SFIL = 1;
151 fptmp = fpxin; do_div(fptmp, 320); 151 fptmp = fpxin; do_div(fptmp, 320);
152 if (symbolrate < fptmp); 152 if (symbolrate < fptmp)
153 SFIL = 0; 153 SFIL = 0;
154 fptmp = fpxin; do_div(fptmp, 492); 154 fptmp = fpxin; do_div(fptmp, 492);
155 if (symbolrate < fptmp); 155 if (symbolrate < fptmp)
156 SFIL = 1; 156 SFIL = 1;
157 fptmp = fpxin; do_div(fptmp, 640); 157 fptmp = fpxin; do_div(fptmp, 640);
158 if (symbolrate < fptmp); 158 if (symbolrate < fptmp)
159 SFIL = 0; 159 SFIL = 0;
160 fptmp = fpxin; do_div(fptmp, 984); 160 fptmp = fpxin; do_div(fptmp, 984);
161 if (symbolrate < fptmp); 161 if (symbolrate < fptmp)
162 SFIL = 1; 162 SFIL = 1;
163 163
164 fin = state->config->xin >> 4; 164 fin = state->config->xin >> 4;
diff --git a/drivers/media/dvb/ttpci/Kconfig b/drivers/media/dvb/ttpci/Kconfig
index d8bf65877897..fa5034a9ecf5 100644
--- a/drivers/media/dvb/ttpci/Kconfig
+++ b/drivers/media/dvb/ttpci/Kconfig
@@ -81,6 +81,7 @@ config DVB_BUDGET_CI
81 tristate "Budget cards with onboard CI connector" 81 tristate "Budget cards with onboard CI connector"
82 depends on DVB_CORE && PCI 82 depends on DVB_CORE && PCI
83 select VIDEO_SAA7146 83 select VIDEO_SAA7146
84 select DVB_STV0297
84 select DVB_STV0299 85 select DVB_STV0299
85 select DVB_TDA1004X 86 select DVB_TDA1004X
86 help 87 help
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_ca.c b/drivers/media/dvb/ttpci/av7110_ca.c
index c3801e328fe9..6079e8865d5b 100644
--- a/drivers/media/dvb/ttpci/av7110_ca.c
+++ b/drivers/media/dvb/ttpci/av7110_ca.c
@@ -40,6 +40,7 @@
40 40
41#include "av7110.h" 41#include "av7110.h"
42#include "av7110_hw.h" 42#include "av7110_hw.h"
43#include "av7110_ca.h"
43 44
44 45
45void CI_handle(struct av7110 *av7110, u8 *data, u16 len) 46void CI_handle(struct av7110 *av7110, u8 *data, u16 len)
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-av.c b/drivers/media/dvb/ttpci/budget-av.c
index aa75dc03a0b3..9f51bae7194c 100644
--- a/drivers/media/dvb/ttpci/budget-av.c
+++ b/drivers/media/dvb/ttpci/budget-av.c
@@ -1020,6 +1020,8 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
1020 1020
1021static struct saa7146_extension budget_extension = { 1021static struct saa7146_extension budget_extension = {
1022 .name = "budget_av", 1022 .name = "budget_av",
1023 .flags = SAA7146_I2C_SHORT_DELAY,
1024
1023 .pci_tbl = pci_tbl, 1025 .pci_tbl = pci_tbl,
1024 1026
1025 .module = THIS_MODULE, 1027 .module = THIS_MODULE,
diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c
index 75fb92d60998..b9b3cd9c0369 100644
--- a/drivers/media/dvb/ttpci/budget-ci.c
+++ b/drivers/media/dvb/ttpci/budget-ci.c
@@ -1166,7 +1166,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
1166 1166
1167static struct saa7146_extension budget_extension = { 1167static struct saa7146_extension budget_extension = {
1168 .name = "budget_ci dvb\0", 1168 .name = "budget_ci dvb\0",
1169 .flags = 0, 1169 .flags = SAA7146_I2C_SHORT_DELAY,
1170 1170
1171 .module = THIS_MODULE, 1171 .module = THIS_MODULE,
1172 .pci_tbl = &pci_tbl[0], 1172 .pci_tbl = &pci_tbl[0],
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 4fd8bbc47037..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 }
@@ -738,7 +738,7 @@ MODULE_DEVICE_TABLE(pci, pci_tbl);
738 738
739static struct saa7146_extension budget_extension = { 739static struct saa7146_extension budget_extension = {
740 .name = "budget dvb\0", 740 .name = "budget dvb\0",
741 .flags = 0, 741 .flags = SAA7146_I2C_SHORT_DELAY,
742 742
743 .module = THIS_MODULE, 743 .module = THIS_MODULE,
744 .pci_tbl = pci_tbl, 744 .pci_tbl = pci_tbl,
diff --git a/drivers/media/dvb/ttpci/budget.h b/drivers/media/dvb/ttpci/budget.h
index c6ef496ba70a..fdaa3318ad3a 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(): ",__stringify(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 e9a8457b0727..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
@@ -37,6 +37,7 @@
37#include <linux/string.h> 37#include <linux/string.h>
38#include <linux/i2c.h> 38#include <linux/i2c.h>
39 39
40#include "ttpci-eeprom.h"
40 41
41#if 1 42#if 1
42#define dprintk(x...) do { printk(x); } while (0) 43#define dprintk(x...) do { printk(x); } while (0)
@@ -47,41 +48,41 @@
47 48
48static int check_mac_tt(u8 *buf) 49static int check_mac_tt(u8 *buf)
49{ 50{
50 int i; 51 int i;
51 u16 tmp = 0xffff; 52 u16 tmp = 0xffff;
52 53
53 for (i = 0; i < 8; i++) { 54 for (i = 0; i < 8; i++) {
54 tmp = (tmp << 8) | ((tmp >> 8) ^ buf[i]); 55 tmp = (tmp << 8) | ((tmp >> 8) ^ buf[i]);
55 tmp ^= (tmp >> 4) & 0x0f; 56 tmp ^= (tmp >> 4) & 0x0f;
56 tmp ^= (tmp << 12) ^ ((tmp & 0xff) << 5); 57 tmp ^= (tmp << 12) ^ ((tmp & 0xff) << 5);
57 } 58 }
58 tmp ^= 0xffff; 59 tmp ^= 0xffff;
59 return (((tmp >> 8) ^ buf[8]) | ((tmp & 0xff) ^ buf[9])); 60 return (((tmp >> 8) ^ buf[8]) | ((tmp & 0xff) ^ buf[9]));
60} 61}
61 62
62static int getmac_tt(u8 * decodedMAC, u8 * encodedMAC) 63static int getmac_tt(u8 * decodedMAC, u8 * encodedMAC)
63{ 64{
64 u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c, 65 u8 xor[20] = { 0x72, 0x23, 0x68, 0x19, 0x5c, 0xa8, 0x71, 0x2c,
65 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6, 66 0x54, 0xd3, 0x7b, 0xf1, 0x9E, 0x23, 0x16, 0xf6,
66 0x1d, 0x36, 0x64, 0x78}; 67 0x1d, 0x36, 0x64, 0x78};
67 u8 data[20]; 68 u8 data[20];
68 int i; 69 int i;
69 70
70 /* 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 */
71 memcpy(data, encodedMAC, 20); 72 memcpy(data, encodedMAC, 20);
72 73
73 for (i = 0; i < 20; i++) 74 for (i = 0; i < 20; i++)
74 data[i] ^= xor[i]; 75 data[i] ^= xor[i];
75 for (i = 0; i < 10; i++) 76 for (i = 0; i < 10; i++)
76 data[i] = ((data[2 * i + 1] << 8) | data[2 * i]) 77 data[i] = ((data[2 * i + 1] << 8) | data[2 * i])
77 >> ((data[2 * i + 1] >> 6) & 3); 78 >> ((data[2 * i + 1] >> 6) & 3);
78 79
79 if (check_mac_tt(data)) 80 if (check_mac_tt(data))
80 return -ENODEV; 81 return -ENODEV;
81 82
82 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];
83 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];
84 return 0; 85 return 0;
85} 86}
86 87
87static 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 199b01188858..fc87efc5049c 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -26,15 +26,12 @@ config VIDEO_BT848
26 module will be called bttv. 26 module will be called bttv.
27 27
28config VIDEO_BT848_DVB 28config VIDEO_BT848_DVB
29 tristate "DVB/ATSC Support for bt878 based TV cards" 29 bool "DVB/ATSC Support for bt878 based TV cards"
30 depends on VIDEO_BT848 && DVB_CORE 30 depends on VIDEO_BT848 && DVB_CORE
31 select DVB_BT8XX 31 select DVB_BT8XX
32 ---help--- 32 ---help---
33 This adds support for DVB/ATSC cards based on the BT878 chip. 33 This adds support for DVB/ATSC cards based on the BT878 chip.
34 34
35 To compile this driver as a module, choose M here: the
36 module will be called dvb-bt8xx.
37
38config VIDEO_SAA6588 35config VIDEO_SAA6588
39 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards" 36 tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards"
40 depends on VIDEO_DEV && I2C && VIDEO_BT848 37 depends on VIDEO_DEV && I2C && VIDEO_BT848
@@ -191,7 +188,7 @@ config VIDEO_ZORAN
191 188
192 To compile this driver as a module, choose M here: the 189 To compile this driver as a module, choose M here: the
193 module will be called zr36067. 190 module will be called zr36067.
194 191
195config VIDEO_ZORAN_BUZ 192config VIDEO_ZORAN_BUZ
196 tristate "Iomega Buz support" 193 tristate "Iomega Buz support"
197 depends on VIDEO_ZORAN 194 depends on VIDEO_ZORAN
@@ -207,8 +204,8 @@ config VIDEO_ZORAN_DC10
207 204
208config VIDEO_ZORAN_DC30 205config VIDEO_ZORAN_DC30
209 tristate "Pinnacle/Miro DC30(+) support" 206 tristate "Pinnacle/Miro DC30(+) support"
210 depends on VIDEO_ZORAN 207 depends on VIDEO_ZORAN
211 help 208 help
212 Support for the Pinnacle/Miro DC30(+) MJPEG capture/playback 209 Support for the Pinnacle/Miro DC30(+) MJPEG capture/playback
213 card. This also supports really old DC10 cards based on the 210 card. This also supports really old DC10 cards based on the
214 zr36050 MJPEG codec and zr36016 VFE. 211 zr36050 MJPEG codec and zr36016 VFE.
@@ -263,7 +260,7 @@ config VIDEO_MXB
263 ---help--- 260 ---help---
264 This is a video4linux driver for the 'Multimedia eXtension Board' 261 This is a video4linux driver for the 'Multimedia eXtension Board'
265 TV card by Siemens-Nixdorf. 262 TV card by Siemens-Nixdorf.
266 263
267 To compile this driver as a module, choose M here: the 264 To compile this driver as a module, choose M here: the
268 module will be called mxb. 265 module will be called mxb.
269 266
@@ -277,7 +274,7 @@ config VIDEO_DPC
277 for SAA7146 bases boards, so if you have some unsupported 274 for SAA7146 bases boards, so if you have some unsupported
278 saa7146 based, analog video card, chances are good that it 275 saa7146 based, analog video card, chances are good that it
279 will work with this skeleton driver. 276 will work with this skeleton driver.
280 277
281 To compile this driver as a module, choose M here: the 278 To compile this driver as a module, choose M here: the
282 module will be called dpc7146. 279 module will be called dpc7146.
283 280
@@ -288,7 +285,7 @@ config VIDEO_HEXIUM_ORION
288 ---help--- 285 ---help---
289 This is a video4linux driver for the Hexium HV-PCI6 and 286 This is a video4linux driver for the Hexium HV-PCI6 and
290 Orion frame grabber cards by Hexium. 287 Orion frame grabber cards by Hexium.
291 288
292 To compile this driver as a module, choose M here: the 289 To compile this driver as a module, choose M here: the
293 module will be called hexium_orion. 290 module will be called hexium_orion.
294 291
@@ -300,7 +297,7 @@ config VIDEO_HEXIUM_GEMINI
300 This is a video4linux driver for the Hexium Gemini frame 297 This is a video4linux driver for the Hexium Gemini frame
301 grabber card by Hexium. Please note that the Gemini Dual 298 grabber card by Hexium. Please note that the Gemini Dual
302 card is *not* fully supported. 299 card is *not* fully supported.
303 300
304 To compile this driver as a module, choose M here: the 301 To compile this driver as a module, choose M here: the
305 module will be called hexium_gemini. 302 module will be called hexium_gemini.
306 303
@@ -333,4 +330,18 @@ config VIDEO_M32R_AR_M64278
333 Say Y here to use the Renesas M64278E-800 camera module, 330 Say Y here to use the Renesas M64278E-800 camera module,
334 which supports VGA(640x480 pixcels) size of images. 331 which supports VGA(640x480 pixcels) size of images.
335 332
333config VIDEO_AUDIO_DECODER
334 tristate "Add support for additional audio chipsets"
335 depends on VIDEO_DEV && I2C && EXPERIMENTAL
336 ---help---
337 Say Y here to compile drivers for WM8775 and CS53L32A audio
338 decoders.
339
340config VIDEO_DECODER
341 tristate "Add support for additional video chipsets"
342 depends on VIDEO_DEV && I2C && EXPERIMENTAL
343 ---help---
344 Say Y here to compile drivers for SAA7115, SAA7127 and CX25840
345 video decoders.
346
336endmenu 347endmenu
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index 3ac465992400..82060f9909d8 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -36,10 +36,11 @@ obj-$(CONFIG_VIDEO_CPIA) += cpia.o
36obj-$(CONFIG_VIDEO_CPIA_PP) += cpia_pp.o 36obj-$(CONFIG_VIDEO_CPIA_PP) += cpia_pp.o
37obj-$(CONFIG_VIDEO_CPIA_USB) += cpia_usb.o 37obj-$(CONFIG_VIDEO_CPIA_USB) += cpia_usb.o
38obj-$(CONFIG_VIDEO_MEYE) += meye.o 38obj-$(CONFIG_VIDEO_MEYE) += meye.o
39obj-$(CONFIG_VIDEO_SAA7134) += saa7134/ 39obj-$(CONFIG_VIDEO_SAA7134) += ir-kbd-i2c.o saa7134/
40obj-$(CONFIG_VIDEO_CX88) += cx88/ 40obj-$(CONFIG_VIDEO_CX88) += cx88/
41obj-$(CONFIG_VIDEO_EM28XX) += em28xx/ 41obj-$(CONFIG_VIDEO_EM28XX) += em28xx/
42obj-$(CONFIG_VIDEO_EM28XX) += saa711x.o tvp5150.o 42obj-$(CONFIG_VIDEO_EM28XX) += saa711x.o tvp5150.o
43obj-$(CONFIG_VIDEO_AUDIO_DECODER) += wm8775.o cs53l32a.o
43obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/ 44obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip/
44obj-$(CONFIG_VIDEO_MXB) += saa7111.o tuner.o tda9840.o tea6415c.o tea6420.o mxb.o 45obj-$(CONFIG_VIDEO_MXB) += saa7111.o tuner.o tda9840.o tea6415c.o tea6420.o mxb.o
45obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o 46obj-$(CONFIG_VIDEO_HEXIUM_ORION) += hexium_orion.o
@@ -55,4 +56,6 @@ obj-$(CONFIG_VIDEO_TVEEPROM) += tveeprom.o
55 56
56obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o 57obj-$(CONFIG_VIDEO_M32R_AR_M64278) += arv.o
57 58
59obj-$(CONFIG_VIDEO_DECODER) += saa7115.o cx25840/ saa7127.o
60
58EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core 61EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt832.c
index e4063950ae57..3ca1d768bfd3 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt832.c
@@ -231,18 +231,18 @@ bt832_command(struct i2c_client *client, unsigned int cmd, void *arg)
231 231
232static struct i2c_driver driver = { 232static struct i2c_driver driver = {
233 .owner = THIS_MODULE, 233 .owner = THIS_MODULE,
234 .name = "i2c bt832 driver", 234 .name = "i2c bt832 driver",
235 .id = -1, /* FIXME */ 235 .id = -1, /* FIXME */
236 .flags = I2C_DF_NOTIFY, 236 .flags = I2C_DF_NOTIFY,
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 .flags = I2C_CLIENT_ALLOW_USE,
245 .driver = &driver, 245 .driver = &driver,
246}; 246};
247 247
248 248
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c
index 3413bace443a..012be639aa18 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bttv-cards.c
@@ -2133,7 +2133,10 @@ struct tvcard bttv_tvcards[] = {
2133 .tuner_addr = ADDR_UNSET, 2133 .tuner_addr = ADDR_UNSET,
2134 .radio_addr = ADDR_UNSET, 2134 .radio_addr = ADDR_UNSET,
2135 .has_dvb = 1, 2135 .has_dvb = 1,
2136 .has_remote = 1,
2137 .gpiomask = 0x1b,
2136 .no_gpioirq = 1, 2138 .no_gpioirq = 1,
2139 .any_irq = 1,
2137 }, 2140 },
2138 [BTTV_BOARD_PV143] = { 2141 [BTTV_BOARD_PV143] = {
2139 /* Jorge Boncompte - DTI2 <jorge@dti2.net> */ 2142 /* Jorge Boncompte - DTI2 <jorge@dti2.net> */
@@ -2796,7 +2799,24 @@ struct tvcard bttv_tvcards[] = {
2796 .tuner_addr = ADDR_UNSET, 2799 .tuner_addr = ADDR_UNSET,
2797 .radio_addr = ADDR_UNSET, 2800 .radio_addr = ADDR_UNSET,
2798 }, 2801 },
2799 2802 /* ---- card 0x8e ---------------------------------- */
2803 [BTTV_BOARD_SABRENT_TVFM] = {
2804 .name = "Sabrent TV-FM (bttv version)",
2805 .video_inputs = 3,
2806 .audio_inputs = 1,
2807 .tuner = 0,
2808 .svhs = 2,
2809 .gpiomask = 0x108007,
2810 .muxsel = { 2, 3, 1, 1},
2811 .audiomux = { 100000, 100002, 100002, 100000},
2812 .no_msp34xx = 1,
2813 .no_tda9875 = 1,
2814 .no_tda7432 = 1,
2815 .pll = PLL_28,
2816 .tuner_type = TUNER_TNF_5335MF,
2817 .tuner_addr = ADDR_UNSET,
2818 .has_radio = 1,
2819 },
2800}; 2820};
2801 2821
2802static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards); 2822static const unsigned int bttv_num_tvcards = ARRAY_SIZE(bttv_tvcards);
@@ -2884,7 +2904,7 @@ void __devinit bttv_idcard(struct bttv *btv)
2884 */ 2904 */
2885 2905
2886/* Some Modular Technology cards have an eeprom, but no subsystem ID */ 2906/* Some Modular Technology cards have an eeprom, but no subsystem ID */
2887void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256]) 2907static void identify_by_eeprom(struct bttv *btv, unsigned char eeprom_data[256])
2888{ 2908{
2889 int type = -1; 2909 int type = -1;
2890 2910
@@ -3367,6 +3387,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
3367 btv->has_remote=1; 3387 btv->has_remote=1;
3368 if (!bttv_tvcards[btv->c.type].no_gpioirq) 3388 if (!bttv_tvcards[btv->c.type].no_gpioirq)
3369 btv->gpioirq=1; 3389 btv->gpioirq=1;
3390 if (bttv_tvcards[btv->c.type].any_irq)
3391 btv->any_irq = 1;
3370 if (bttv_tvcards[btv->c.type].audio_hook) 3392 if (bttv_tvcards[btv->c.type].audio_hook)
3371 btv->audio_hook=bttv_tvcards[btv->c.type].audio_hook; 3393 btv->audio_hook=bttv_tvcards[btv->c.type].audio_hook;
3372 3394
@@ -3857,7 +3879,7 @@ static void __devinit init_PXC200(struct bttv *btv)
3857 * error. ERROR_CPLD_Check_Failed. 3879 * error. ERROR_CPLD_Check_Failed.
3858 */ 3880 */
3859/* ----------------------------------------------------------------------- */ 3881/* ----------------------------------------------------------------------- */
3860void 3882static void
3861init_RTV24 (struct bttv *btv) 3883init_RTV24 (struct bttv *btv)
3862{ 3884{
3863 uint32_t dataRead = 0; 3885 uint32_t dataRead = 0;
@@ -4081,7 +4103,7 @@ void tea5757_set_freq(struct bttv *btv, unsigned short freq)
4081/* ----------------------------------------------------------------------- */ 4103/* ----------------------------------------------------------------------- */
4082/* winview */ 4104/* winview */
4083 4105
4084void winview_audio(struct bttv *btv, struct video_audio *v, int set) 4106static void winview_audio(struct bttv *btv, struct video_audio *v, int set)
4085{ 4107{
4086 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */ 4108 /* PT2254A programming Jon Tombs, jon@gte.esi.us.es */
4087 int bits_out, loops, vol, data; 4109 int bits_out, loops, vol, data;
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c
index 0005741d5514..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 */
@@ -1720,7 +1720,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1720 memset(i,0,sizeof(*i)); 1720 memset(i,0,sizeof(*i));
1721 i->index = n; 1721 i->index = n;
1722 i->type = V4L2_INPUT_TYPE_CAMERA; 1722 i->type = V4L2_INPUT_TYPE_CAMERA;
1723 i->audioset = 1; 1723 i->audioset = 0;
1724 if (i->index == bttv_tvcards[btv->c.type].tuner) { 1724 if (i->index == bttv_tvcards[btv->c.type].tuner) {
1725 sprintf(i->name, "Television"); 1725 sprintf(i->name, "Television");
1726 i->type = V4L2_INPUT_TYPE_TUNER; 1726 i->type = V4L2_INPUT_TYPE_TUNER;
@@ -1771,12 +1771,20 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1771 memset(t,0,sizeof(*t)); 1771 memset(t,0,sizeof(*t));
1772 strcpy(t->name, "Television"); 1772 strcpy(t->name, "Television");
1773 t->type = V4L2_TUNER_ANALOG_TV; 1773 t->type = V4L2_TUNER_ANALOG_TV;
1774 t->rangehigh = 0xffffffffUL;
1775 t->capability = V4L2_TUNER_CAP_NORM; 1774 t->capability = V4L2_TUNER_CAP_NORM;
1776 t->rxsubchans = V4L2_TUNER_SUB_MONO; 1775 t->rxsubchans = V4L2_TUNER_SUB_MONO;
1777 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) 1776 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
1778 t->signal = 0xffff; 1777 t->signal = 0xffff;
1779 { 1778 {
1779 struct video_tuner tuner;
1780
1781 memset(&tuner, 0, sizeof (tuner));
1782 tuner.rangehigh = 0xffffffffUL;
1783 bttv_call_i2c_clients(btv, VIDIOCGTUNER, &tuner);
1784 t->rangelow = tuner.rangelow;
1785 t->rangehigh = tuner.rangehigh;
1786 }
1787 {
1780 /* Hmmm ... */ 1788 /* Hmmm ... */
1781 struct video_audio va; 1789 struct video_audio va;
1782 memset(&va, 0, sizeof(struct video_audio)); 1790 memset(&va, 0, sizeof(struct video_audio));
@@ -1853,7 +1861,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
1853 } 1861 }
1854 case VIDIOC_LOG_STATUS: 1862 case VIDIOC_LOG_STATUS:
1855 { 1863 {
1856 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, 0); 1864 bttv_call_i2c_clients(btv, VIDIOC_LOG_STATUS, NULL);
1857 return 0; 1865 return 0;
1858 } 1866 }
1859 1867
@@ -1956,7 +1964,7 @@ static int setup_window(struct bttv_fh *fh, struct bttv *btv,
1956 } 1964 }
1957 1965
1958 down(&fh->cap.lock); 1966 down(&fh->cap.lock);
1959 kfree(fh->ov.clips); 1967 kfree(fh->ov.clips);
1960 fh->ov.clips = clips; 1968 fh->ov.clips = clips;
1961 fh->ov.nclips = n; 1969 fh->ov.nclips = n;
1962 1970
@@ -2029,19 +2037,33 @@ static int bttv_switch_type(struct bttv_fh *fh, enum v4l2_buf_type type)
2029 return 0; 2037 return 0;
2030} 2038}
2031 2039
2040static void
2041pix_format_set_size (struct v4l2_pix_format * f,
2042 const struct bttv_format * fmt,
2043 unsigned int width,
2044 unsigned int height)
2045{
2046 f->width = width;
2047 f->height = height;
2048
2049 if (fmt->flags & FORMAT_FLAGS_PLANAR) {
2050 f->bytesperline = width; /* Y plane */
2051 f->sizeimage = (width * height * fmt->depth) >> 3;
2052 } else {
2053 f->bytesperline = (width * fmt->depth) >> 3;
2054 f->sizeimage = height * f->bytesperline;
2055 }
2056}
2057
2032static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f) 2058static int bttv_g_fmt(struct bttv_fh *fh, struct v4l2_format *f)
2033{ 2059{
2034 switch (f->type) { 2060 switch (f->type) {
2035 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 2061 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
2036 memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format)); 2062 memset(&f->fmt.pix,0,sizeof(struct v4l2_pix_format));
2037 f->fmt.pix.width = fh->width; 2063 pix_format_set_size (&f->fmt.pix, fh->fmt,
2038 f->fmt.pix.height = fh->height; 2064 fh->width, fh->height);
2039 f->fmt.pix.field = fh->cap.field; 2065 f->fmt.pix.field = fh->cap.field;
2040 f->fmt.pix.pixelformat = fh->fmt->fourcc; 2066 f->fmt.pix.pixelformat = fh->fmt->fourcc;
2041 f->fmt.pix.bytesperline =
2042 (f->fmt.pix.width * fh->fmt->depth) >> 3;
2043 f->fmt.pix.sizeimage =
2044 f->fmt.pix.height * f->fmt.pix.bytesperline;
2045 return 0; 2067 return 0;
2046 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 2068 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
2047 memset(&f->fmt.win,0,sizeof(struct v4l2_window)); 2069 memset(&f->fmt.win,0,sizeof(struct v4l2_window));
@@ -2106,11 +2128,9 @@ static int bttv_try_fmt(struct bttv_fh *fh, struct bttv *btv,
2106 f->fmt.pix.width = maxw; 2128 f->fmt.pix.width = maxw;
2107 if (f->fmt.pix.height > maxh) 2129 if (f->fmt.pix.height > maxh)
2108 f->fmt.pix.height = maxh; 2130 f->fmt.pix.height = maxh;
2109 f->fmt.pix.width &= ~0x03; 2131 pix_format_set_size (&f->fmt.pix, fmt,
2110 f->fmt.pix.bytesperline = 2132 f->fmt.pix.width & ~3,
2111 (f->fmt.pix.width * fmt->depth) >> 3; 2133 f->fmt.pix.height);
2112 f->fmt.pix.sizeimage =
2113 f->fmt.pix.height * f->fmt.pix.bytesperline;
2114 2134
2115 return 0; 2135 return 0;
2116 } 2136 }
@@ -2278,6 +2298,15 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2278 retval = -EINVAL; 2298 retval = -EINVAL;
2279 goto fh_unlock_and_return; 2299 goto fh_unlock_and_return;
2280 } 2300 }
2301 if (fmt->flags & FORMAT_FLAGS_RAW) {
2302 /* VIDIOCMCAPTURE uses gbufsize, not RAW_BPL *
2303 RAW_LINES * 2. F1 is stored at offset 0, F2
2304 at buffer size / 2. */
2305 fh->width = RAW_BPL;
2306 fh->height = gbufsize / RAW_BPL;
2307 btv->init.width = RAW_BPL;
2308 btv->init.height = gbufsize / RAW_BPL;
2309 }
2281 fh->ovfmt = fmt; 2310 fh->ovfmt = fmt;
2282 fh->fmt = fmt; 2311 fh->fmt = fmt;
2283 btv->init.ovfmt = fmt; 2312 btv->init.ovfmt = fmt;
@@ -2589,9 +2618,11 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2589 2618
2590 if (0 == v4l2) 2619 if (0 == v4l2)
2591 return -EINVAL; 2620 return -EINVAL;
2592 strcpy(cap->driver,"bttv"); 2621 memset(cap, 0, sizeof (*cap));
2593 strlcpy(cap->card,btv->video_dev->name,sizeof(cap->card)); 2622 strlcpy(cap->driver, "bttv", sizeof (cap->driver));
2594 sprintf(cap->bus_info,"PCI:%s",pci_name(btv->c.pci)); 2623 strlcpy(cap->card, btv->video_dev->name, sizeof (cap->card));
2624 snprintf(cap->bus_info, sizeof (cap->bus_info),
2625 "PCI:%s", pci_name(btv->c.pci));
2595 cap->version = BTTV_VERSION_CODE; 2626 cap->version = BTTV_VERSION_CODE;
2596 cap->capabilities = 2627 cap->capabilities =
2597 V4L2_CAP_VIDEO_CAPTURE | 2628 V4L2_CAP_VIDEO_CAPTURE |
@@ -2727,7 +2758,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
2727 fh->ov.w.height = fb->fmt.height; 2758 fh->ov.w.height = fb->fmt.height;
2728 btv->init.ov.w.width = fb->fmt.width; 2759 btv->init.ov.w.width = fb->fmt.width;
2729 btv->init.ov.w.height = fb->fmt.height; 2760 btv->init.ov.w.height = fb->fmt.height;
2730 kfree(fh->ov.clips); 2761 kfree(fh->ov.clips);
2731 fh->ov.clips = NULL; 2762 fh->ov.clips = NULL;
2732 fh->ov.nclips = 0; 2763 fh->ov.nclips = 0;
2733 2764
@@ -2952,6 +2983,8 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
2952 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; 2983 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
2953 field = videobuf_next_field(&fh->cap); 2984 field = videobuf_next_field(&fh->cap);
2954 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { 2985 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
2986 kfree (fh->cap.read_buf);
2987 fh->cap.read_buf = NULL;
2955 up(&fh->cap.lock); 2988 up(&fh->cap.lock);
2956 return POLLERR; 2989 return POLLERR;
2957 } 2990 }
@@ -3667,6 +3700,10 @@ static irqreturn_t bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
3667 int handled = 0; 3700 int handled = 0;
3668 3701
3669 btv=(struct bttv *)dev_id; 3702 btv=(struct bttv *)dev_id;
3703
3704 if (btv->any_irq)
3705 handled = bttv_any_irq(&btv->c);
3706
3670 count=0; 3707 count=0;
3671 while (1) { 3708 while (1) {
3672 /* get/clear interrupt status bits */ 3709 /* get/clear interrupt status bits */
diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bttv-gpio.c
index 575ce8b8e714..616a5b7e510c 100644
--- a/drivers/media/video/bttv-gpio.c
+++ b/drivers/media/video/bttv-gpio.c
@@ -113,6 +113,24 @@ void bttv_gpio_irq(struct bttv_core *core)
113 } 113 }
114} 114}
115 115
116int bttv_any_irq(struct bttv_core *core)
117{
118 struct bttv_sub_driver *drv;
119 struct bttv_sub_device *dev;
120 struct list_head *item;
121 int handled = 0;
122
123 list_for_each(item,&core->subs) {
124 dev = list_entry(item,struct bttv_sub_device,list);
125 drv = to_bttv_sub_drv(dev->dev.driver);
126 if (drv && drv->any_irq) {
127 if (drv->any_irq(dev))
128 handled = 1;
129 }
130 }
131 return handled;
132}
133
116/* ----------------------------------------------------------------------- */ 134/* ----------------------------------------------------------------------- */
117/* external: sub-driver register/unregister */ 135/* external: sub-driver register/unregister */
118 136
diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bttv.h
index 124ea41dada4..93298f06e019 100644
--- a/drivers/media/video/bttv.h
+++ b/drivers/media/video/bttv.h
@@ -162,6 +162,7 @@
162#define BTTV_BOARD_PV_M4900 0x8b 162#define BTTV_BOARD_PV_M4900 0x8b
163#define BTTV_BOARD_OSPREY440 0x8c 163#define BTTV_BOARD_OSPREY440 0x8c
164#define BTTV_BOARD_ASOUND_SKYEYE 0x8d 164#define BTTV_BOARD_ASOUND_SKYEYE 0x8d
165#define BTTV_BOARD_SABRENT_TVFM 0x8e
165 166
166/* i2c address list */ 167/* i2c address list */
167#define I2C_TSA5522 0xc2 168#define I2C_TSA5522 0xc2
@@ -234,6 +235,7 @@ struct tvcard
234 unsigned int has_dvb:1; 235 unsigned int has_dvb:1;
235 unsigned int has_remote:1; 236 unsigned int has_remote:1;
236 unsigned int no_gpioirq:1; 237 unsigned int no_gpioirq:1;
238 unsigned int any_irq:1;
237 239
238 /* other settings */ 240 /* other settings */
239 unsigned int pll; 241 unsigned int pll;
@@ -333,6 +335,7 @@ struct bttv_sub_driver {
333 struct device_driver drv; 335 struct device_driver drv;
334 char wanted[BUS_ID_SIZE]; 336 char wanted[BUS_ID_SIZE];
335 void (*gpio_irq)(struct bttv_sub_device *sub); 337 void (*gpio_irq)(struct bttv_sub_device *sub);
338 int (*any_irq)(struct bttv_sub_device *sub);
336}; 339};
337#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv) 340#define to_bttv_sub_drv(x) container_of((x), struct bttv_sub_driver, drv)
338 341
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h
index 386f546f7d11..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"
@@ -208,6 +209,7 @@ extern struct bus_type bttv_sub_bus_type;
208int bttv_sub_add_device(struct bttv_core *core, char *name); 209int bttv_sub_add_device(struct bttv_core *core, char *name);
209int bttv_sub_del_devices(struct bttv_core *core); 210int bttv_sub_del_devices(struct bttv_core *core);
210void bttv_gpio_irq(struct bttv_core *core); 211void bttv_gpio_irq(struct bttv_core *core);
212int bttv_any_irq(struct bttv_core *core);
211 213
212 214
213/* ---------------------------------------------------------- */ 215/* ---------------------------------------------------------- */
@@ -273,6 +275,7 @@ struct bttv {
273 struct bttv_pll_info pll; 275 struct bttv_pll_info pll;
274 int triton1; 276 int triton1;
275 int gpioirq; 277 int gpioirq;
278 int any_irq;
276 int use_i2c_hw; 279 int use_i2c_hw;
277 280
278 /* old gpio interface */ 281 /* old gpio interface */
diff --git a/drivers/media/video/cx25840/Makefile b/drivers/media/video/cx25840/Makefile
new file mode 100644
index 000000000000..543ebacdc9d7
--- /dev/null
+++ b/drivers/media/video/cx25840/Makefile
@@ -0,0 +1,6 @@
1cx25840-objs := cx25840-core.o cx25840-audio.o cx25840-firmware.o \
2 cx25840-vbi.o
3
4obj-$(CONFIG_VIDEO_DECODER) += cx25840.o
5
6EXTRA_CFLAGS += -I$(src)/..
diff --git a/drivers/media/video/cx25840/cx25840-audio.c b/drivers/media/video/cx25840/cx25840-audio.c
new file mode 100644
index 000000000000..740908f8027d
--- /dev/null
+++ b/drivers/media/video/cx25840/cx25840-audio.c
@@ -0,0 +1,368 @@
1/* cx25840 audio functions
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18
19#include <linux/videodev2.h>
20#include <linux/i2c.h>
21#include <media/audiochip.h>
22#include <media/v4l2-common.h>
23
24#include "cx25840.h"
25
26inline static int set_audclk_freq(struct i2c_client *client,
27 enum v4l2_audio_clock_freq freq)
28{
29 struct cx25840_state *state = i2c_get_clientdata(client);
30
31 /* assert soft reset */
32 cx25840_and_or(client, 0x810, ~0x1, 0x01);
33
34 /* common for all inputs and rates */
35 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x10 */
36 cx25840_write(client, 0x127, 0x50);
37
38 switch (state->audio_input) {
39 case AUDIO_TUNER:
40 switch (freq) {
41 case V4L2_AUDCLK_32_KHZ:
42 /* VID_PLL and AUX_PLL */
43 cx25840_write4(client, 0x108, 0x0f040610);
44
45 /* AUX_PLL_FRAC */
46 cx25840_write4(client, 0x110, 0xee39bb01);
47
48 /* src3/4/6_ctl = 0x0801f77f */
49 cx25840_write4(client, 0x900, 0x7ff70108);
50 cx25840_write4(client, 0x904, 0x7ff70108);
51 cx25840_write4(client, 0x90c, 0x7ff70108);
52 break;
53
54 case V4L2_AUDCLK_441_KHZ:
55 /* VID_PLL and AUX_PLL */
56 cx25840_write4(client, 0x108, 0x0f040910);
57
58 /* AUX_PLL_FRAC */
59 cx25840_write4(client, 0x110, 0xd66bec00);
60
61 /* src3/4/6_ctl = 0x08016d59 */
62 cx25840_write4(client, 0x900, 0x596d0108);
63 cx25840_write4(client, 0x904, 0x596d0108);
64 cx25840_write4(client, 0x90c, 0x596d0108);
65 break;
66
67 case V4L2_AUDCLK_48_KHZ:
68 /* VID_PLL and AUX_PLL */
69 cx25840_write4(client, 0x108, 0x0f040a10);
70
71 /* AUX_PLL_FRAC */
72 cx25840_write4(client, 0x110, 0xe5d69800);
73
74 /* src3/4/6_ctl = 0x08014faa */
75 cx25840_write4(client, 0x900, 0xaa4f0108);
76 cx25840_write4(client, 0x904, 0xaa4f0108);
77 cx25840_write4(client, 0x90c, 0xaa4f0108);
78 break;
79 }
80 break;
81
82 case AUDIO_EXTERN_1:
83 case AUDIO_EXTERN_2:
84 case AUDIO_INTERN:
85 case AUDIO_RADIO:
86 switch (freq) {
87 case V4L2_AUDCLK_32_KHZ:
88 /* VID_PLL and AUX_PLL */
89 cx25840_write4(client, 0x108, 0x0f04081e);
90
91 /* AUX_PLL_FRAC */
92 cx25840_write4(client, 0x110, 0x69082a01);
93
94 /* src1_ctl = 0x08010000 */
95 cx25840_write4(client, 0x8f8, 0x00000108);
96
97 /* src3/4/6_ctl = 0x08020000 */
98 cx25840_write4(client, 0x900, 0x00000208);
99 cx25840_write4(client, 0x904, 0x00000208);
100 cx25840_write4(client, 0x90c, 0x00000208);
101
102 /* SA_MCLK_SEL=1, SA_MCLK_DIV=0x14 */
103 cx25840_write(client, 0x127, 0x54);
104 break;
105
106 case V4L2_AUDCLK_441_KHZ:
107 /* VID_PLL and AUX_PLL */
108 cx25840_write4(client, 0x108, 0x0f040918);
109
110 /* AUX_PLL_FRAC */
111 cx25840_write4(client, 0x110, 0xd66bec00);
112
113 /* src1_ctl = 0x08010000 */
114 cx25840_write4(client, 0x8f8, 0xcd600108);
115
116 /* src3/4/6_ctl = 0x08020000 */
117 cx25840_write4(client, 0x900, 0x85730108);
118 cx25840_write4(client, 0x904, 0x85730108);
119 cx25840_write4(client, 0x90c, 0x85730108);
120 break;
121
122 case V4L2_AUDCLK_48_KHZ:
123 /* VID_PLL and AUX_PLL */
124 cx25840_write4(client, 0x108, 0x0f040a18);
125
126 /* AUX_PLL_FRAC */
127 cx25840_write4(client, 0x110, 0xe5d69800);
128
129 /* src1_ctl = 0x08010000 */
130 cx25840_write4(client, 0x8f8, 0x00800108);
131
132 /* src3/4/6_ctl = 0x08020000 */
133 cx25840_write4(client, 0x900, 0x55550108);
134 cx25840_write4(client, 0x904, 0x55550108);
135 cx25840_write4(client, 0x90c, 0x55550108);
136 break;
137 }
138 break;
139 }
140
141 /* deassert soft reset */
142 cx25840_and_or(client, 0x810, ~0x1, 0x00);
143
144 state->audclk_freq = freq;
145
146 return 0;
147}
148
149static int set_input(struct i2c_client *client, int audio_input)
150{
151 struct cx25840_state *state = i2c_get_clientdata(client);
152
153 cx25840_dbg("set audio input (%d)\n", audio_input);
154
155 /* stop microcontroller */
156 cx25840_and_or(client, 0x803, ~0x10, 0);
157
158 /* Mute everything to prevent the PFFT! */
159 cx25840_write(client, 0x8d3, 0x1f);
160
161 switch (audio_input) {
162 case AUDIO_TUNER:
163 /* Set Path1 to Analog Demod Main Channel */
164 cx25840_write4(client, 0x8d0, 0x7038061f);
165
166 /* When the microcontroller detects the
167 * audio format, it will unmute the lines */
168 cx25840_and_or(client, 0x803, ~0x10, 0x10);
169 break;
170
171 case AUDIO_EXTERN_1:
172 case AUDIO_EXTERN_2:
173 case AUDIO_INTERN:
174 case AUDIO_RADIO:
175 /* Set Path1 to Serial Audio Input */
176 cx25840_write4(client, 0x8d0, 0x12100101);
177
178 /* The microcontroller should not be started for the
179 * non-tuner inputs: autodetection is specific for
180 * TV audio. */
181 break;
182
183 default:
184 cx25840_dbg("Invalid audio input selection %d\n", audio_input);
185 return -EINVAL;
186 }
187
188 state->audio_input = audio_input;
189
190 return set_audclk_freq(client, state->audclk_freq);
191}
192
193inline static int get_volume(struct i2c_client *client)
194{
195 /* Volume runs +18dB to -96dB in 1/2dB steps
196 * change to fit the msp3400 -114dB to +12dB range */
197
198 /* check PATH1_VOLUME */
199 int vol = 228 - cx25840_read(client, 0x8d4);
200 vol = (vol / 2) + 23;
201 return vol << 9;
202}
203
204inline static void set_volume(struct i2c_client *client, int volume)
205{
206 /* First convert the volume to msp3400 values (0-127) */
207 int vol = volume >> 9;
208 /* now scale it up to cx25840 values
209 * -114dB to -96dB maps to 0
210 * this should be 19, but in my testing that was 4dB too loud */
211 if (vol <= 23) {
212 vol = 0;
213 } else {
214 vol -= 23;
215 }
216
217 /* PATH1_VOLUME */
218 cx25840_write(client, 0x8d4, 228 - (vol * 2));
219}
220
221inline static int get_bass(struct i2c_client *client)
222{
223 /* bass is 49 steps +12dB to -12dB */
224
225 /* check PATH1_EQ_BASS_VOL */
226 int bass = cx25840_read(client, 0x8d9) & 0x3f;
227 bass = (((48 - bass) * 0xffff) + 47) / 48;
228 return bass;
229}
230
231inline static void set_bass(struct i2c_client *client, int bass)
232{
233 /* PATH1_EQ_BASS_VOL */
234 cx25840_and_or(client, 0x8d9, ~0x3f, 48 - (bass * 48 / 0xffff));
235}
236
237inline static int get_treble(struct i2c_client *client)
238{
239 /* treble is 49 steps +12dB to -12dB */
240
241 /* check PATH1_EQ_TREBLE_VOL */
242 int treble = cx25840_read(client, 0x8db) & 0x3f;
243 treble = (((48 - treble) * 0xffff) + 47) / 48;
244 return treble;
245}
246
247inline static void set_treble(struct i2c_client *client, int treble)
248{
249 /* PATH1_EQ_TREBLE_VOL */
250 cx25840_and_or(client, 0x8db, ~0x3f, 48 - (treble * 48 / 0xffff));
251}
252
253inline static int get_balance(struct i2c_client *client)
254{
255 /* balance is 7 bit, 0 to -96dB */
256
257 /* check PATH1_BAL_LEVEL */
258 int balance = cx25840_read(client, 0x8d5) & 0x7f;
259 /* check PATH1_BAL_LEFT */
260 if ((cx25840_read(client, 0x8d5) & 0x80) == 0)
261 balance = 0x80 - balance;
262 else
263 balance = 0x80 + balance;
264 return balance << 8;
265}
266
267inline static void set_balance(struct i2c_client *client, int balance)
268{
269 int bal = balance >> 8;
270 if (bal > 0x80) {
271 /* PATH1_BAL_LEFT */
272 cx25840_and_or(client, 0x8d5, 0x7f, 0x80);
273 /* PATH1_BAL_LEVEL */
274 cx25840_and_or(client, 0x8d5, ~0x7f, bal & 0x7f);
275 } else {
276 /* PATH1_BAL_LEFT */
277 cx25840_and_or(client, 0x8d5, 0x7f, 0x00);
278 /* PATH1_BAL_LEVEL */
279 cx25840_and_or(client, 0x8d5, ~0x7f, 0x80 - bal);
280 }
281}
282
283inline static int get_mute(struct i2c_client *client)
284{
285 /* check SRC1_MUTE_EN */
286 return cx25840_read(client, 0x8d3) & 0x2 ? 1 : 0;
287}
288
289inline static void set_mute(struct i2c_client *client, int mute)
290{
291 struct cx25840_state *state = i2c_get_clientdata(client);
292
293 if (state->audio_input == AUDIO_TUNER) {
294 /* Must turn off microcontroller in order to mute sound.
295 * Not sure if this is the best method, but it does work.
296 * If the microcontroller is running, then it will undo any
297 * changes to the mute register. */
298 if (mute) {
299 /* disable microcontroller */
300 cx25840_and_or(client, 0x803, ~0x10, 0x00);
301 cx25840_write(client, 0x8d3, 0x1f);
302 } else {
303 /* enable microcontroller */
304 cx25840_and_or(client, 0x803, ~0x10, 0x10);
305 }
306 } else {
307 /* SRC1_MUTE_EN */
308 cx25840_and_or(client, 0x8d3, ~0x2, mute ? 0x02 : 0x00);
309 }
310}
311
312int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg)
313{
314 struct v4l2_control *ctrl = arg;
315
316 switch (cmd) {
317 case AUDC_SET_INPUT:
318 return set_input(client, *(int *)arg);
319 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
320 return set_audclk_freq(client, *(enum v4l2_audio_clock_freq *)arg);
321 case VIDIOC_G_CTRL:
322 switch (ctrl->id) {
323 case V4L2_CID_AUDIO_VOLUME:
324 ctrl->value = get_volume(client);
325 break;
326 case V4L2_CID_AUDIO_BASS:
327 ctrl->value = get_bass(client);
328 break;
329 case V4L2_CID_AUDIO_TREBLE:
330 ctrl->value = get_treble(client);
331 break;
332 case V4L2_CID_AUDIO_BALANCE:
333 ctrl->value = get_balance(client);
334 break;
335 case V4L2_CID_AUDIO_MUTE:
336 ctrl->value = get_mute(client);
337 break;
338 default:
339 return -EINVAL;
340 }
341 break;
342 case VIDIOC_S_CTRL:
343 switch (ctrl->id) {
344 case V4L2_CID_AUDIO_VOLUME:
345 set_volume(client, ctrl->value);
346 break;
347 case V4L2_CID_AUDIO_BASS:
348 set_bass(client, ctrl->value);
349 break;
350 case V4L2_CID_AUDIO_TREBLE:
351 set_treble(client, ctrl->value);
352 break;
353 case V4L2_CID_AUDIO_BALANCE:
354 set_balance(client, ctrl->value);
355 break;
356 case V4L2_CID_AUDIO_MUTE:
357 set_mute(client, ctrl->value);
358 break;
359 default:
360 return -EINVAL;
361 }
362 break;
363 default:
364 return -EINVAL;
365 }
366
367 return 0;
368}
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
new file mode 100644
index 000000000000..5b93723a1768
--- /dev/null
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -0,0 +1,1056 @@
1/* cx25840 - Conexant CX25840 audio/video decoder driver
2 *
3 * Copyright (C) 2004 Ulf Eklund
4 *
5 * Based on the saa7115 driver and on the first verison of Chris Kennedy's
6 * cx25840 driver.
7 *
8 * Changes by Tyler Trafford <tatrafford@comcast.net>
9 * - cleanup/rewrite for V4L2 API (2005)
10 *
11 * VBI support by Hans Verkuil <hverkuil@xs4all.nl>.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 */
27
28
29#include <linux/kernel.h>
30#include <linux/module.h>
31#include <linux/slab.h>
32#include <linux/videodev2.h>
33#include <linux/i2c.h>
34#include <media/audiochip.h>
35#include <media/v4l2-common.h>
36
37#include "cx25840.h"
38
39MODULE_DESCRIPTION("Conexant CX25840 audio/video decoder driver");
40MODULE_AUTHOR("Ulf Eklund, Chris Kennedy, Hans Verkuil, Tyler Trafford");
41MODULE_LICENSE("GPL");
42
43static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
44
45
46int cx25840_debug = 0;
47
48module_param(cx25840_debug, bool, 0644);
49
50MODULE_PARM_DESC(cx25840_debug, "Debugging messages [0=Off (default) 1=On]");
51
52I2C_CLIENT_INSMOD;
53
54/* ----------------------------------------------------------------------- */
55
56int cx25840_write(struct i2c_client *client, u16 addr, u8 value)
57{
58 u8 buffer[3];
59 buffer[0] = addr >> 8;
60 buffer[1] = addr & 0xff;
61 buffer[2] = value;
62 return i2c_master_send(client, buffer, 3);
63}
64
65int cx25840_write4(struct i2c_client *client, u16 addr, u32 value)
66{
67 u8 buffer[6];
68 buffer[0] = addr >> 8;
69 buffer[1] = addr & 0xff;
70 buffer[2] = value >> 24;
71 buffer[3] = (value >> 16) & 0xff;
72 buffer[4] = (value >> 8) & 0xff;
73 buffer[5] = value & 0xff;
74 return i2c_master_send(client, buffer, 6);
75}
76
77u8 cx25840_read(struct i2c_client * client, u16 addr)
78{
79 u8 buffer[2];
80 buffer[0] = addr >> 8;
81 buffer[1] = addr & 0xff;
82
83 if (i2c_master_send(client, buffer, 2) < 2)
84 return 0;
85
86 if (i2c_master_recv(client, buffer, 1) < 1)
87 return 0;
88
89 return buffer[0];
90}
91
92u32 cx25840_read4(struct i2c_client * client, u16 addr)
93{
94 u8 buffer[4];
95 buffer[0] = addr >> 8;
96 buffer[1] = addr & 0xff;
97
98 if (i2c_master_send(client, buffer, 2) < 2)
99 return 0;
100
101 if (i2c_master_recv(client, buffer, 4) < 4)
102 return 0;
103
104 return (buffer[0] << 24) | (buffer[1] << 16) |
105 (buffer[2] << 8) | buffer[3];
106}
107
108int cx25840_and_or(struct i2c_client *client, u16 addr, u8 and_mask,
109 u8 or_value)
110{
111 return cx25840_write(client, addr,
112 (cx25840_read(client, addr) & and_mask) |
113 or_value);
114}
115
116/* ----------------------------------------------------------------------- */
117
118static int set_input(struct i2c_client *, enum cx25840_input);
119static void input_change(struct i2c_client *);
120static void log_status(struct i2c_client *client);
121
122/* ----------------------------------------------------------------------- */
123
124static inline void init_dll1(struct i2c_client *client)
125{
126 /* This is the Hauppauge sequence used to
127 * initialize the Delay Lock Loop 1 (ADC DLL). */
128 cx25840_write(client, 0x159, 0x23);
129 cx25840_write(client, 0x15a, 0x87);
130 cx25840_write(client, 0x15b, 0x06);
131 cx25840_write(client, 0x159, 0xe1);
132 cx25840_write(client, 0x15a, 0x86);
133 cx25840_write(client, 0x159, 0xe0);
134 cx25840_write(client, 0x159, 0xe1);
135 cx25840_write(client, 0x15b, 0x10);
136}
137
138static inline void init_dll2(struct i2c_client *client)
139{
140 /* This is the Hauppauge sequence used to
141 * initialize the Delay Lock Loop 2 (ADC DLL). */
142 cx25840_write(client, 0x15d, 0xe3);
143 cx25840_write(client, 0x15e, 0x86);
144 cx25840_write(client, 0x15f, 0x06);
145 cx25840_write(client, 0x15d, 0xe1);
146 cx25840_write(client, 0x15d, 0xe0);
147 cx25840_write(client, 0x15d, 0xe1);
148}
149
150static void cx25840_initialize(struct i2c_client *client, int loadfw)
151{
152 struct cx25840_state *state = i2c_get_clientdata(client);
153
154 /* datasheet startup in numbered steps, refer to page 3-77 */
155 /* 2. */
156 cx25840_and_or(client, 0x803, ~0x10, 0x00);
157 /* The default of this register should be 4, but I get 0 instead.
158 * Set this register to 4 manually. */
159 cx25840_write(client, 0x000, 0x04);
160 /* 3. */
161 init_dll1(client);
162 init_dll2(client);
163 cx25840_write(client, 0x136, 0x0a);
164 /* 4. */
165 cx25840_write(client, 0x13c, 0x01);
166 cx25840_write(client, 0x13c, 0x00);
167 /* 5. */
168 if (loadfw)
169 cx25840_loadfw(client);
170 /* 6. */
171 cx25840_write(client, 0x115, 0x8c);
172 cx25840_write(client, 0x116, 0x07);
173 cx25840_write(client, 0x118, 0x02);
174 /* 7. */
175 cx25840_write(client, 0x4a5, 0x80);
176 cx25840_write(client, 0x4a5, 0x00);
177 cx25840_write(client, 0x402, 0x00);
178 /* 8. */
179 cx25840_write(client, 0x401, 0x18);
180 cx25840_write(client, 0x4a2, 0x10);
181 cx25840_write(client, 0x402, 0x04);
182 /* 10. */
183 cx25840_write(client, 0x8d3, 0x1f);
184 cx25840_write(client, 0x8e3, 0x03);
185
186 cx25840_vbi_setup(client);
187
188 /* trial and error says these are needed to get audio */
189 cx25840_write(client, 0x914, 0xa0);
190 cx25840_write(client, 0x918, 0xa0);
191 cx25840_write(client, 0x919, 0x01);
192
193 /* stereo prefered */
194 cx25840_write(client, 0x809, 0x04);
195 /* AC97 shift */
196 cx25840_write(client, 0x8cf, 0x0f);
197
198 /* (re)set video input */
199 set_input(client, state->input);
200 /* (re)set audio input */
201 cx25840_audio(client, AUDC_SET_INPUT, &state->audio_input);
202
203 /* start microcontroller */
204 cx25840_and_or(client, 0x803, ~0x10, 0x10);
205}
206
207/* ----------------------------------------------------------------------- */
208
209static void input_change(struct i2c_client *client)
210{
211 struct cx25840_state *state = i2c_get_clientdata(client);
212 v4l2_std_id std = cx25840_get_v4lstd(client);
213
214 /* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC
215 instead of V4L2_STD_PAL. Someone needs to test this. */
216 if (std & V4L2_STD_PAL) {
217 /* Follow tuner change procedure for PAL */
218 cx25840_write(client, 0x808, 0xff);
219 cx25840_write(client, 0x80b, 0x10);
220 } else if (std & V4L2_STD_SECAM) {
221 /* Select autodetect for SECAM */
222 cx25840_write(client, 0x808, 0xff);
223 cx25840_write(client, 0x80b, 0x10);
224 } else if (std & V4L2_STD_NTSC) {
225 /* NTSC */
226 if (state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
227 /* Certain Hauppauge PVR150 models have a hardware bug
228 that causes audio to drop out. For these models the
229 audio standard must be set explicitly.
230 To be precise: it affects cards with tuner models
231 85, 99 and 112 (model numbers from tveeprom). */
232 if (std == V4L2_STD_NTSC_M_JP) {
233 /* Japan uses EIAJ audio standard */
234 cx25840_write(client, 0x808, 0x2f);
235 } else {
236 /* Others use the BTSC audio standard */
237 cx25840_write(client, 0x808, 0x1f);
238 }
239 /* South Korea uses the A2-M (aka Zweiton M) audio
240 standard, and should set 0x808 to 0x3f, but I don't
241 know how to detect this. */
242 } else if (std == V4L2_STD_NTSC_M_JP) {
243 /* Japan uses EIAJ audio standard */
244 cx25840_write(client, 0x808, 0xf7);
245 } else {
246 /* Others use the BTSC audio standard */
247 cx25840_write(client, 0x808, 0xf6);
248 }
249 /* South Korea uses the A2-M (aka Zweiton M) audio standard,
250 and should set 0x808 to 0xf8, but I don't know how to
251 detect this. */
252 cx25840_write(client, 0x80b, 0x00);
253 }
254
255 if (cx25840_read(client, 0x803) & 0x10) {
256 /* restart audio decoder microcontroller */
257 cx25840_and_or(client, 0x803, ~0x10, 0x00);
258 cx25840_and_or(client, 0x803, ~0x10, 0x10);
259 }
260}
261
262static int set_input(struct i2c_client *client, enum cx25840_input input)
263{
264 struct cx25840_state *state = i2c_get_clientdata(client);
265
266 cx25840_dbg("decoder set input (%d)\n", input);
267
268 switch (input) {
269 case CX25840_TUNER:
270 cx25840_dbg("now setting Tuner input\n");
271
272 if (state->cardtype == CARDTYPE_PVR150 ||
273 state->cardtype == CARDTYPE_PVR150_WORKAROUND) {
274 /* CH_SEL_ADC2=1 */
275 cx25840_and_or(client, 0x102, ~0x2, 0x02);
276 }
277
278 /* Video Input Control */
279 if (state->cardtype == CARDTYPE_PG600) {
280 cx25840_write(client, 0x103, 0x11);
281 } else {
282 cx25840_write(client, 0x103, 0x46);
283 }
284
285 /* INPUT_MODE=0 */
286 cx25840_and_or(client, 0x401, ~0x6, 0x00);
287 break;
288
289 case CX25840_COMPOSITE0:
290 case CX25840_COMPOSITE1:
291 cx25840_dbg("now setting Composite input\n");
292
293 /* Video Input Control */
294 if (state->cardtype == CARDTYPE_PG600) {
295 cx25840_write(client, 0x103, 0x00);
296 } else {
297 cx25840_write(client, 0x103, 0x02);
298 }
299
300 /* INPUT_MODE=0 */
301 cx25840_and_or(client, 0x401, ~0x6, 0x00);
302 break;
303
304 case CX25840_SVIDEO0:
305 case CX25840_SVIDEO1:
306 cx25840_dbg("now setting S-Video input\n");
307
308 /* CH_SEL_ADC2=0 */
309 cx25840_and_or(client, 0x102, ~0x2, 0x00);
310
311 /* Video Input Control */
312 if (state->cardtype == CARDTYPE_PG600) {
313 cx25840_write(client, 0x103, 0x02);
314 } else {
315 cx25840_write(client, 0x103, 0x10);
316 }
317
318 /* INPUT_MODE=1 */
319 cx25840_and_or(client, 0x401, ~0x6, 0x02);
320 break;
321
322 default:
323 cx25840_err("%d is not a valid input!\n", input);
324 return -EINVAL;
325 }
326
327 state->input = input;
328 input_change(client);
329 return 0;
330}
331
332/* ----------------------------------------------------------------------- */
333
334static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
335{
336 u8 fmt=0; /* zero is autodetect */
337
338 /* First tests should be against specific std */
339 if (std & V4L2_STD_NTSC_M_JP) {
340 fmt=0x2;
341 } else if (std & V4L2_STD_NTSC_443) {
342 fmt=0x3;
343 } else if (std & V4L2_STD_PAL_M) {
344 fmt=0x5;
345 } else if (std & V4L2_STD_PAL_N) {
346 fmt=0x6;
347 } else if (std & V4L2_STD_PAL_Nc) {
348 fmt=0x7;
349 } else if (std & V4L2_STD_PAL_60) {
350 fmt=0x8;
351 } else {
352 /* Then, test against generic ones */
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 }
360 }
361
362 cx25840_and_or(client, 0x400, ~0xf, fmt);
363 cx25840_vbi_setup(client);
364 return 0;
365}
366
367v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
368{
369 /* check VID_FMT_SEL first */
370 u8 fmt = cx25840_read(client, 0x400) & 0xf;
371
372 if (!fmt) {
373 /* check AFD_FMT_STAT if set to autodetect */
374 fmt = cx25840_read(client, 0x40d) & 0xf;
375 }
376
377 switch (fmt) {
378 case 0x1: return V4L2_STD_NTSC_M;
379 case 0x2: return V4L2_STD_NTSC_M_JP;
380 case 0x3: return V4L2_STD_NTSC_443;
381 case 0x4: return V4L2_STD_PAL;
382 case 0x5: return V4L2_STD_PAL_M;
383 case 0x6: return V4L2_STD_PAL_N;
384 case 0x7: return V4L2_STD_PAL_Nc;
385 case 0x8: return V4L2_STD_PAL_60;
386 case 0xc: return V4L2_STD_SECAM;
387 default: return V4L2_STD_UNKNOWN;
388 }
389}
390
391/* ----------------------------------------------------------------------- */
392
393static int set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
394{
395 struct cx25840_state *state = i2c_get_clientdata(client);
396
397 switch (ctrl->id) {
398 case CX25840_CID_CARDTYPE:
399 switch (ctrl->value) {
400 case CARDTYPE_PVR150:
401 case CARDTYPE_PVR150_WORKAROUND:
402 case CARDTYPE_PG600:
403 state->cardtype = ctrl->value;
404 break;
405 default:
406 return -ERANGE;
407 }
408
409 set_input(client, state->input);
410 break;
411
412 case V4L2_CID_BRIGHTNESS:
413 if (ctrl->value < 0 || ctrl->value > 255) {
414 cx25840_err("invalid brightness setting %d\n",
415 ctrl->value);
416 return -ERANGE;
417 }
418
419 cx25840_write(client, 0x414, ctrl->value - 128);
420 break;
421
422 case V4L2_CID_CONTRAST:
423 if (ctrl->value < 0 || ctrl->value > 127) {
424 cx25840_err("invalid contrast setting %d\n",
425 ctrl->value);
426 return -ERANGE;
427 }
428
429 cx25840_write(client, 0x415, ctrl->value << 1);
430 break;
431
432 case V4L2_CID_SATURATION:
433 if (ctrl->value < 0 || ctrl->value > 127) {
434 cx25840_err("invalid saturation setting %d\n",
435 ctrl->value);
436 return -ERANGE;
437 }
438
439 cx25840_write(client, 0x420, ctrl->value << 1);
440 cx25840_write(client, 0x421, ctrl->value << 1);
441 break;
442
443 case V4L2_CID_HUE:
444 if (ctrl->value < -127 || ctrl->value > 127) {
445 cx25840_err("invalid hue setting %d\n", ctrl->value);
446 return -ERANGE;
447 }
448
449 cx25840_write(client, 0x422, ctrl->value);
450 break;
451
452 case V4L2_CID_AUDIO_VOLUME:
453 case V4L2_CID_AUDIO_BASS:
454 case V4L2_CID_AUDIO_TREBLE:
455 case V4L2_CID_AUDIO_BALANCE:
456 case V4L2_CID_AUDIO_MUTE:
457 return cx25840_audio(client, VIDIOC_S_CTRL, ctrl);
458 }
459
460 return 0;
461}
462
463static int get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
464{
465 struct cx25840_state *state = i2c_get_clientdata(client);
466
467 switch (ctrl->id) {
468 case CX25840_CID_CARDTYPE:
469 ctrl->value = state->cardtype;
470 break;
471 case V4L2_CID_BRIGHTNESS:
472 ctrl->value = cx25840_read(client, 0x414) + 128;
473 break;
474 case V4L2_CID_CONTRAST:
475 ctrl->value = cx25840_read(client, 0x415) >> 1;
476 break;
477 case V4L2_CID_SATURATION:
478 ctrl->value = cx25840_read(client, 0x420) >> 1;
479 break;
480 case V4L2_CID_HUE:
481 ctrl->value = cx25840_read(client, 0x422);
482 break;
483 case V4L2_CID_AUDIO_VOLUME:
484 case V4L2_CID_AUDIO_BASS:
485 case V4L2_CID_AUDIO_TREBLE:
486 case V4L2_CID_AUDIO_BALANCE:
487 case V4L2_CID_AUDIO_MUTE:
488 return cx25840_audio(client, VIDIOC_G_CTRL, ctrl);
489 default:
490 return -EINVAL;
491 }
492
493 return 0;
494}
495
496/* ----------------------------------------------------------------------- */
497
498static int get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
499{
500 switch (fmt->type) {
501 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
502 return cx25840_vbi(client, VIDIOC_G_FMT, fmt);
503 default:
504 return -EINVAL;
505 }
506
507 return 0;
508}
509
510static int set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
511{
512 struct v4l2_pix_format *pix;
513 int HSC, VSC, Vsrc, Hsrc, filter, Vlines;
514 int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC);
515
516 switch (fmt->type) {
517 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
518 pix = &(fmt->fmt.pix);
519
520 Vsrc = (cx25840_read(client, 0x476) & 0x3f) << 4;
521 Vsrc |= (cx25840_read(client, 0x475) & 0xf0) >> 4;
522
523 Hsrc = (cx25840_read(client, 0x472) & 0x3f) << 4;
524 Hsrc |= (cx25840_read(client, 0x471) & 0xf0) >> 4;
525
526 Vlines = pix->height + (is_pal ? 4 : 7);
527
528 if ((pix->width * 16 < Hsrc) || (Hsrc < pix->width) ||
529 (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {
530 cx25840_err("%dx%d is not a valid size!\n",
531 pix->width, pix->height);
532 return -ERANGE;
533 }
534
535 HSC = (Hsrc * (1 << 20)) / pix->width - (1 << 20);
536 VSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9));
537 VSC &= 0x1fff;
538
539 if (pix->width >= 385)
540 filter = 0;
541 else if (pix->width > 192)
542 filter = 1;
543 else if (pix->width > 96)
544 filter = 2;
545 else
546 filter = 3;
547
548 cx25840_dbg("decoder set size %dx%d -> scale %ux%u\n",
549 pix->width, pix->height, HSC, VSC);
550
551 /* HSCALE=HSC */
552 cx25840_write(client, 0x418, HSC & 0xff);
553 cx25840_write(client, 0x419, (HSC >> 8) & 0xff);
554 cx25840_write(client, 0x41a, HSC >> 16);
555 /* VSCALE=VSC */
556 cx25840_write(client, 0x41c, VSC & 0xff);
557 cx25840_write(client, 0x41d, VSC >> 8);
558 /* VS_INTRLACE=1 VFILT=filter */
559 cx25840_write(client, 0x41e, 0x8 | filter);
560 break;
561
562 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:
563 return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
564
565 case V4L2_BUF_TYPE_VBI_CAPTURE:
566 return cx25840_vbi(client, VIDIOC_S_FMT, fmt);
567
568 default:
569 return -EINVAL;
570 }
571
572 return 0;
573}
574
575/* ----------------------------------------------------------------------- */
576
577static int cx25840_command(struct i2c_client *client, unsigned int cmd,
578 void *arg)
579{
580 struct cx25840_state *state = i2c_get_clientdata(client);
581 struct v4l2_tuner *vt = arg;
582 int result = 0;
583
584 switch (cmd) {
585 case 0:
586 break;
587
588#ifdef CONFIG_VIDEO_ADV_DEBUG
589 /* ioctls to allow direct access to the
590 * cx25840 registers for testing */
591 case VIDIOC_INT_G_REGISTER:
592 {
593 struct v4l2_register *reg = arg;
594
595 if (reg->i2c_id != I2C_DRIVERID_CX25840)
596 return -EINVAL;
597 reg->val = cx25840_read(client, reg->reg & 0x0fff);
598 break;
599 }
600
601 case VIDIOC_INT_S_REGISTER:
602 {
603 struct v4l2_register *reg = arg;
604
605 if (reg->i2c_id != I2C_DRIVERID_CX25840)
606 return -EINVAL;
607 if (!capable(CAP_SYS_ADMIN))
608 return -EPERM;
609 cx25840_write(client, reg->reg & 0x0fff, reg->val & 0xff);
610 break;
611 }
612#endif
613
614 case VIDIOC_INT_DECODE_VBI_LINE:
615 return cx25840_vbi(client, cmd, arg);
616
617 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
618 case AUDC_SET_INPUT:
619 result = cx25840_audio(client, cmd, arg);
620 break;
621
622 case VIDIOC_STREAMON:
623 cx25840_dbg("enable output\n");
624 cx25840_write(client, 0x115, 0x8c);
625 cx25840_write(client, 0x116, 0x07);
626 break;
627
628 case VIDIOC_STREAMOFF:
629 cx25840_dbg("disable output\n");
630 cx25840_write(client, 0x115, 0x00);
631 cx25840_write(client, 0x116, 0x00);
632 break;
633
634 case VIDIOC_LOG_STATUS:
635 log_status(client);
636 break;
637
638 case VIDIOC_G_CTRL:
639 result = get_v4lctrl(client, (struct v4l2_control *)arg);
640 break;
641
642 case VIDIOC_S_CTRL:
643 result = set_v4lctrl(client, (struct v4l2_control *)arg);
644 break;
645
646 case VIDIOC_G_STD:
647 *(v4l2_std_id *)arg = cx25840_get_v4lstd(client);
648 break;
649
650 case VIDIOC_S_STD:
651 result = set_v4lstd(client, *(v4l2_std_id *)arg);
652 break;
653
654 case VIDIOC_G_INPUT:
655 *(int *)arg = state->input;
656 break;
657
658 case VIDIOC_S_INPUT:
659 result = set_input(client, *(int *)arg);
660 break;
661
662 case VIDIOC_S_FREQUENCY:
663 input_change(client);
664 break;
665
666 case VIDIOC_G_TUNER:
667 {
668 u8 mode = cx25840_read(client, 0x804);
669 u8 pref = cx25840_read(client, 0x809) & 0xf;
670 u8 vpres = cx25840_read(client, 0x80a) & 0x10;
671 int val = 0;
672
673 vt->capability |=
674 V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LANG1 |
675 V4L2_TUNER_CAP_LANG2 | V4L2_TUNER_CAP_SAP;
676
677 vt->signal = vpres ? 0xffff : 0x0;
678
679 /* get rxsubchans and audmode */
680 if ((mode & 0xf) == 1)
681 val |= V4L2_TUNER_SUB_STEREO;
682 else
683 val |= V4L2_TUNER_SUB_MONO;
684
685 if (mode == 2 || mode == 4)
686 val |= V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
687
688 if (mode & 0x10)
689 val |= V4L2_TUNER_SUB_SAP;
690
691 vt->rxsubchans = val;
692
693 switch (pref) {
694 case 0:
695 vt->audmode = V4L2_TUNER_MODE_MONO;
696 break;
697 case 1:
698 case 2:
699 vt->audmode = V4L2_TUNER_MODE_LANG2;
700 break;
701 case 4:
702 default:
703 vt->audmode = V4L2_TUNER_MODE_STEREO;
704 }
705 break;
706 }
707
708 case VIDIOC_S_TUNER:
709 switch (vt->audmode) {
710 case V4L2_TUNER_MODE_MONO:
711 case V4L2_TUNER_MODE_LANG1:
712 /* Force PREF_MODE to MONO */
713 cx25840_and_or(client, 0x809, ~0xf, 0x00);
714 break;
715 case V4L2_TUNER_MODE_STEREO:
716 /* Force PREF_MODE to STEREO */
717 cx25840_and_or(client, 0x809, ~0xf, 0x04);
718 break;
719 case V4L2_TUNER_MODE_LANG2:
720 /* Force PREF_MODE to LANG2 */
721 cx25840_and_or(client, 0x809, ~0xf, 0x01);
722 break;
723 }
724 break;
725
726 case VIDIOC_G_FMT:
727 result = get_v4lfmt(client, (struct v4l2_format *)arg);
728 break;
729
730 case VIDIOC_S_FMT:
731 result = set_v4lfmt(client, (struct v4l2_format *)arg);
732 break;
733
734 case VIDIOC_INT_RESET:
735 cx25840_initialize(client, 0);
736 break;
737
738 case VIDIOC_INT_G_CHIP_IDENT:
739 *(enum v4l2_chip_ident *)arg =
740 V4L2_IDENT_CX25840 + ((cx25840_read(client, 0x100) >> 4) & 0xf);
741 break;
742
743 default:
744 cx25840_err("invalid ioctl %x\n", cmd);
745 return -EINVAL;
746 }
747
748 return result;
749}
750
751/* ----------------------------------------------------------------------- */
752
753static struct i2c_driver i2c_driver_cx25840;
754
755static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
756 int kind)
757{
758 struct i2c_client *client;
759 struct cx25840_state *state;
760 u16 device_id;
761
762 /* Check if the adapter supports the needed features
763 * Not until kernel version 2.6.11 did the bit-algo
764 * correctly report that it would do an I2C-level xfer */
765 if (!i2c_check_functionality(adapter, I2C_FUNC_I2C))
766 return 0;
767
768 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
769 if (client == 0)
770 return -ENOMEM;
771
772 memset(client, 0, sizeof(struct i2c_client));
773 client->addr = address;
774 client->adapter = adapter;
775 client->driver = &i2c_driver_cx25840;
776 client->flags = I2C_CLIENT_ALLOW_USE;
777 snprintf(client->name, sizeof(client->name) - 1, "cx25840");
778
779 cx25840_dbg("detecting cx25840 client on address 0x%x\n", address << 1);
780
781 device_id = cx25840_read(client, 0x101) << 8;
782 device_id |= cx25840_read(client, 0x100);
783
784 /* The high byte of the device ID should be
785 * 0x84 if chip is present */
786 if ((device_id & 0xff00) != 0x8400) {
787 cx25840_dbg("cx25840 not found\n");
788 kfree(client);
789 return 0;
790 }
791
792 cx25840_info("cx25%3x-2%x found @ 0x%x (%s)\n",
793 (device_id & 0xfff0) >> 4,
794 (device_id & 0x0f) < 3 ? (device_id & 0x0f) + 1 : 3,
795 address << 1, adapter->name);
796
797 state = kmalloc(sizeof(struct cx25840_state), GFP_KERNEL);
798 if (state == NULL) {
799 kfree(client);
800 return -ENOMEM;
801 }
802
803 i2c_set_clientdata(client, state);
804 memset(state, 0, sizeof(struct cx25840_state));
805 state->input = CX25840_TUNER;
806 state->audclk_freq = V4L2_AUDCLK_48_KHZ;
807 state->audio_input = AUDIO_TUNER;
808 state->cardtype = CARDTYPE_PVR150;
809
810 cx25840_initialize(client, 1);
811
812 i2c_attach_client(client);
813
814 return 0;
815}
816
817static int cx25840_attach_adapter(struct i2c_adapter *adapter)
818{
819#ifdef I2C_CLASS_TV_ANALOG
820 if (adapter->class & I2C_CLASS_TV_ANALOG)
821#else
822 if (adapter->id == I2C_HW_B_BT848)
823#endif
824 return i2c_probe(adapter, &addr_data, &cx25840_detect_client);
825 return 0;
826}
827
828static int cx25840_detach_client(struct i2c_client *client)
829{
830 struct cx25840_state *state = i2c_get_clientdata(client);
831 int err;
832
833 err = i2c_detach_client(client);
834 if (err) {
835 return err;
836 }
837
838 kfree(state);
839 kfree(client);
840
841 return 0;
842}
843
844/* ----------------------------------------------------------------------- */
845
846static struct i2c_driver i2c_driver_cx25840 = {
847 .name = "cx25840",
848
849 .id = I2C_DRIVERID_CX25840,
850 .flags = I2C_DF_NOTIFY,
851
852 .attach_adapter = cx25840_attach_adapter,
853 .detach_client = cx25840_detach_client,
854 .command = cx25840_command,
855 .owner = THIS_MODULE,
856};
857
858
859static int __init m__init(void)
860{
861 return i2c_add_driver(&i2c_driver_cx25840);
862}
863
864static void __exit m__exit(void)
865{
866 i2c_del_driver(&i2c_driver_cx25840);
867}
868
869module_init(m__init);
870module_exit(m__exit);
871
872/* ----------------------------------------------------------------------- */
873
874static void log_status(struct i2c_client *client)
875{
876 static const char *const fmt_strs[] = {
877 "0x0",
878 "NTSC-M", "NTSC-J", "NTSC-4.43",
879 "PAL-BDGHI", "PAL-M", "PAL-N", "PAL-Nc", "PAL-60",
880 "0x9", "0xA", "0xB",
881 "SECAM",
882 "0xD", "0xE", "0xF"
883 };
884
885 struct cx25840_state *state = i2c_get_clientdata(client);
886 u8 microctrl_vidfmt = cx25840_read(client, 0x80a);
887 u8 vidfmt_sel = cx25840_read(client, 0x400) & 0xf;
888 u8 gen_stat1 = cx25840_read(client, 0x40d);
889 u8 download_ctl = cx25840_read(client, 0x803);
890 u8 mod_det_stat0 = cx25840_read(client, 0x804);
891 u8 mod_det_stat1 = cx25840_read(client, 0x805);
892 u8 audio_config = cx25840_read(client, 0x808);
893 u8 pref_mode = cx25840_read(client, 0x809);
894 u8 afc0 = cx25840_read(client, 0x80b);
895 u8 mute_ctl = cx25840_read(client, 0x8d3);
896 char *p;
897
898 cx25840_info("Video signal: %spresent\n",
899 (microctrl_vidfmt & 0x10) ? "" : "not ");
900 cx25840_info("Detected format: %s\n",
901 fmt_strs[gen_stat1 & 0xf]);
902
903 switch (mod_det_stat0) {
904 case 0x00: p = "mono"; break;
905 case 0x01: p = "stereo"; break;
906 case 0x02: p = "dual"; break;
907 case 0x04: p = "tri"; break;
908 case 0x10: p = "mono with SAP"; break;
909 case 0x11: p = "stereo with SAP"; break;
910 case 0x12: p = "dual with SAP"; break;
911 case 0x14: p = "tri with SAP"; break;
912 case 0xfe: p = "forced mode"; break;
913 default: p = "not defined";
914 }
915 cx25840_info("Detected audio mode: %s\n", p);
916
917 switch (mod_det_stat1) {
918 case 0x00: p = "not defined"; break;
919 case 0x01: p = "EIAJ"; break;
920 case 0x02: p = "A2-M"; break;
921 case 0x03: p = "A2-BG"; break;
922 case 0x04: p = "A2-DK1"; break;
923 case 0x05: p = "A2-DK2"; break;
924 case 0x06: p = "A2-DK3"; break;
925 case 0x07: p = "A1 (6.0 MHz FM Mono)"; break;
926 case 0x08: p = "AM-L"; break;
927 case 0x09: p = "NICAM-BG"; break;
928 case 0x0a: p = "NICAM-DK"; break;
929 case 0x0b: p = "NICAM-I"; break;
930 case 0x0c: p = "NICAM-L"; break;
931 case 0x0d: p = "BTSC/EIAJ/A2-M Mono (4.5 MHz FMMono)"; break;
932 case 0x0e: p = "IF FM Radio"; break;
933 case 0x0f: p = "BTSC"; break;
934 case 0x10: p = "high-deviation FM"; break;
935 case 0x11: p = "very high-deviation FM"; break;
936 case 0xfd: p = "unknown audio standard"; break;
937 case 0xfe: p = "forced audio standard"; break;
938 case 0xff: p = "no detected audio standard"; break;
939 default: p = "not defined";
940 }
941 cx25840_info("Detected audio standard: %s\n", p);
942 cx25840_info("Audio muted: %s\n",
943 (mute_ctl & 0x2) ? "yes" : "no");
944 cx25840_info("Audio microcontroller: %s\n",
945 (download_ctl & 0x10) ? "running" : "stopped");
946
947 switch (audio_config >> 4) {
948 case 0x00: p = "undefined"; break;
949 case 0x01: p = "BTSC"; break;
950 case 0x02: p = "EIAJ"; break;
951 case 0x03: p = "A2-M"; break;
952 case 0x04: p = "A2-BG"; break;
953 case 0x05: p = "A2-DK1"; break;
954 case 0x06: p = "A2-DK2"; break;
955 case 0x07: p = "A2-DK3"; break;
956 case 0x08: p = "A1 (6.0 MHz FM Mono)"; break;
957 case 0x09: p = "AM-L"; break;
958 case 0x0a: p = "NICAM-BG"; break;
959 case 0x0b: p = "NICAM-DK"; break;
960 case 0x0c: p = "NICAM-I"; break;
961 case 0x0d: p = "NICAM-L"; break;
962 case 0x0e: p = "FM radio"; break;
963 case 0x0f: p = "automatic detection"; break;
964 default: p = "undefined";
965 }
966 cx25840_info("Configured audio standard: %s\n", p);
967
968 if ((audio_config >> 4) < 0xF) {
969 switch (audio_config & 0xF) {
970 case 0x00: p = "MONO1 (LANGUAGE A/Mono L+R channel for BTSC, EIAJ, A2)"; break;
971 case 0x01: p = "MONO2 (LANGUAGE B)"; break;
972 case 0x02: p = "MONO3 (STEREO forced MONO)"; break;
973 case 0x03: p = "MONO4 (NICAM ANALOG-Language C/Analog Fallback)"; break;
974 case 0x04: p = "STEREO"; break;
975 case 0x05: p = "DUAL1 (AB)"; break;
976 case 0x06: p = "DUAL2 (AC) (FM)"; break;
977 case 0x07: p = "DUAL3 (BC) (FM)"; break;
978 case 0x08: p = "DUAL4 (AC) (AM)"; break;
979 case 0x09: p = "DUAL5 (BC) (AM)"; break;
980 case 0x0a: p = "SAP"; break;
981 default: p = "undefined";
982 }
983 cx25840_info("Configured audio mode: %s\n", p);
984 } else {
985 switch (audio_config & 0xF) {
986 case 0x00: p = "BG"; break;
987 case 0x01: p = "DK1"; break;
988 case 0x02: p = "DK2"; break;
989 case 0x03: p = "DK3"; break;
990 case 0x04: p = "I"; break;
991 case 0x05: p = "L"; break;
992 case 0x06: p = "BTSC"; break;
993 case 0x07: p = "EIAJ"; break;
994 case 0x08: p = "A2-M"; break;
995 case 0x09: p = "FM Radio"; break;
996 case 0x0f: p = "automatic standard and mode detection"; break;
997 default: p = "undefined";
998 }
999 cx25840_info("Configured audio system: %s\n", p);
1000 }
1001
1002 cx25840_info("Specified standard: %s\n",
1003 vidfmt_sel ? fmt_strs[vidfmt_sel] : "automatic detection");
1004
1005 switch (state->input) {
1006 case CX25840_COMPOSITE0: p = "Composite 0"; break;
1007 case CX25840_COMPOSITE1: p = "Composite 1"; break;
1008 case CX25840_SVIDEO0: p = "S-Video 0"; break;
1009 case CX25840_SVIDEO1: p = "S-Video 1"; break;
1010 case CX25840_TUNER: p = "Tuner"; break;
1011 }
1012 cx25840_info("Specified input: %s\n", p);
1013 cx25840_info("Specified audio input: %s\n",
1014 state->audio_input == 0 ? "Tuner" : "External");
1015
1016 switch (state->audclk_freq) {
1017 case V4L2_AUDCLK_441_KHZ: p = "44.1 kHz"; break;
1018 case V4L2_AUDCLK_48_KHZ: p = "48 kHz"; break;
1019 case V4L2_AUDCLK_32_KHZ: p = "32 kHz"; break;
1020 default: p = "undefined";
1021 }
1022 cx25840_info("Specified audioclock freq: %s\n", p);
1023
1024 switch (pref_mode & 0xf) {
1025 case 0: p = "mono/language A"; break;
1026 case 1: p = "language B"; break;
1027 case 2: p = "language C"; break;
1028 case 3: p = "analog fallback"; break;
1029 case 4: p = "stereo"; break;
1030 case 5: p = "language AC"; break;
1031 case 6: p = "language BC"; break;
1032 case 7: p = "language AB"; break;
1033 default: p = "undefined";
1034 }
1035 cx25840_info("Preferred audio mode: %s\n", p);
1036
1037 if ((audio_config & 0xf) == 0xf) {
1038 switch ((afc0 >> 3) & 0x3) {
1039 case 0: p = "system DK"; break;
1040 case 1: p = "system L"; break;
1041 case 2: p = "autodetect"; break;
1042 default: p = "undefined";
1043 }
1044 cx25840_info("Selected 65 MHz format: %s\n", p);
1045
1046 switch (afc0 & 0x7) {
1047 case 0: p = "chroma"; break;
1048 case 1: p = "BTSC"; break;
1049 case 2: p = "EIAJ"; break;
1050 case 3: p = "A2-M"; break;
1051 case 4: p = "autodetect"; break;
1052 default: p = "undefined";
1053 }
1054 cx25840_info("Selected 45 MHz format: %s\n", p);
1055 }
1056}
diff --git a/drivers/media/video/cx25840/cx25840-firmware.c b/drivers/media/video/cx25840/cx25840-firmware.c
new file mode 100644
index 000000000000..df9d50a75542
--- /dev/null
+++ b/drivers/media/video/cx25840/cx25840-firmware.c
@@ -0,0 +1,167 @@
1/* cx25840 firmware functions
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18
19#include <linux/module.h>
20#include <linux/i2c.h>
21#include <linux/i2c-algo-bit.h>
22#include <linux/firmware.h>
23#include <media/v4l2-common.h>
24
25#include "cx25840.h"
26
27#define FWFILE "v4l-cx25840.fw"
28#define FWSEND 1024
29
30#define FWDEV(x) &((x)->adapter->dev)
31
32static int fastfw = 1;
33static char *firmware = FWFILE;
34
35module_param(fastfw, bool, 0444);
36module_param(firmware, charp, 0444);
37
38MODULE_PARM_DESC(fastfw, "Load firmware fast [0=100MHz 1=333MHz (default)]");
39MODULE_PARM_DESC(firmware, "Firmware image [default: " FWFILE "]");
40
41static inline void set_i2c_delay(struct i2c_client *client, int delay)
42{
43 struct i2c_algo_bit_data *algod = client->adapter->algo_data;
44
45 /* We aren't guaranteed to be using algo_bit,
46 * so avoid the null pointer dereference
47 * and disable the 'fast firmware load' */
48 if (algod) {
49 algod->udelay = delay;
50 } else {
51 fastfw = 0;
52 }
53}
54
55static inline void start_fw_load(struct i2c_client *client)
56{
57 /* DL_ADDR_LB=0 DL_ADDR_HB=0 */
58 cx25840_write(client, 0x800, 0x00);
59 cx25840_write(client, 0x801, 0x00);
60 // DL_MAP=3 DL_AUTO_INC=0 DL_ENABLE=1
61 cx25840_write(client, 0x803, 0x0b);
62 /* AUTO_INC_DIS=1 */
63 cx25840_write(client, 0x000, 0x20);
64
65 if (fastfw)
66 set_i2c_delay(client, 3);
67}
68
69static inline void end_fw_load(struct i2c_client *client)
70{
71 if (fastfw)
72 set_i2c_delay(client, 10);
73
74 /* AUTO_INC_DIS=0 */
75 cx25840_write(client, 0x000, 0x00);
76 /* DL_ENABLE=0 */
77 cx25840_write(client, 0x803, 0x03);
78}
79
80static inline int check_fw_load(struct i2c_client *client, int size)
81{
82 /* DL_ADDR_HB DL_ADDR_LB */
83 int s = cx25840_read(client, 0x801) << 8;
84 s |= cx25840_read(client, 0x800);
85
86 if (size != s) {
87 cx25840_err("firmware %s load failed\n", firmware);
88 return -EINVAL;
89 }
90
91 cx25840_info("loaded %s firmware (%d bytes)\n", firmware, size);
92 return 0;
93}
94
95static inline int fw_write(struct i2c_client *client, u8 * data, int size)
96{
97 if (i2c_master_send(client, data, size) < size) {
98
99 if (fastfw) {
100 cx25840_err("333MHz i2c firmware load failed\n");
101 fastfw = 0;
102 set_i2c_delay(client, 10);
103
104 if (i2c_master_send(client, data, size) < size) {
105 cx25840_err
106 ("100MHz i2c firmware load failed\n");
107 return -ENOSYS;
108 }
109
110 } else {
111 cx25840_err("firmware load i2c failure\n");
112 return -ENOSYS;
113 }
114
115 }
116
117 return 0;
118}
119
120int cx25840_loadfw(struct i2c_client *client)
121{
122 const struct firmware *fw = NULL;
123 u8 buffer[4], *ptr;
124 int size, send, retval;
125
126 if (request_firmware(&fw, firmware, FWDEV(client)) != 0) {
127 cx25840_err("unable to open firmware %s\n", firmware);
128 return -EINVAL;
129 }
130
131 start_fw_load(client);
132
133 buffer[0] = 0x08;
134 buffer[1] = 0x02;
135 buffer[2] = fw->data[0];
136 buffer[3] = fw->data[1];
137 retval = fw_write(client, buffer, 4);
138
139 if (retval < 0) {
140 release_firmware(fw);
141 return retval;
142 }
143
144 size = fw->size - 2;
145 ptr = fw->data;
146 while (size > 0) {
147 ptr[0] = 0x08;
148 ptr[1] = 0x02;
149 send = size > (FWSEND - 2) ? FWSEND : size + 2;
150 retval = fw_write(client, ptr, send);
151
152 if (retval < 0) {
153 release_firmware(fw);
154 return retval;
155 }
156
157 size -= FWSEND - 2;
158 ptr += FWSEND - 2;
159 }
160
161 end_fw_load(client);
162
163 size = fw->size;
164 release_firmware(fw);
165
166 return check_fw_load(client, size);
167}
diff --git a/drivers/media/video/cx25840/cx25840-vbi.c b/drivers/media/video/cx25840/cx25840-vbi.c
new file mode 100644
index 000000000000..13ba4e15ddea
--- /dev/null
+++ b/drivers/media/video/cx25840/cx25840-vbi.c
@@ -0,0 +1,315 @@
1/* cx25840 VBI functions
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License
5 * as published by the Free Software Foundation; either version 2
6 * of the License, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 */
17
18
19#include <linux/videodev2.h>
20#include <linux/i2c.h>
21#include <media/v4l2-common.h>
22
23#include "cx25840.h"
24
25static inline int odd_parity(u8 c)
26{
27 c ^= (c >> 4);
28 c ^= (c >> 2);
29 c ^= (c >> 1);
30
31 return c & 1;
32}
33
34static inline int decode_vps(u8 * dst, u8 * p)
35{
36 static const u8 biphase_tbl[] = {
37 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
38 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
39 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
40 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
41 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
42 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
43 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
44 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
45 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
46 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
47 0xc3, 0x4b, 0x43, 0xc3, 0x87, 0x0f, 0x07, 0x87,
48 0x83, 0x0b, 0x03, 0x83, 0xc3, 0x4b, 0x43, 0xc3,
49 0xc1, 0x49, 0x41, 0xc1, 0x85, 0x0d, 0x05, 0x85,
50 0x81, 0x09, 0x01, 0x81, 0xc1, 0x49, 0x41, 0xc1,
51 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
52 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
53 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
54 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
55 0xc2, 0x4a, 0x42, 0xc2, 0x86, 0x0e, 0x06, 0x86,
56 0x82, 0x0a, 0x02, 0x82, 0xc2, 0x4a, 0x42, 0xc2,
57 0xc0, 0x48, 0x40, 0xc0, 0x84, 0x0c, 0x04, 0x84,
58 0x80, 0x08, 0x00, 0x80, 0xc0, 0x48, 0x40, 0xc0,
59 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
60 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
61 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
62 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
63 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
64 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
65 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
66 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
67 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
68 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
69 };
70
71 u8 c, err = 0;
72 int i;
73
74 for (i = 0; i < 2 * 13; i += 2) {
75 err |= biphase_tbl[p[i]] | biphase_tbl[p[i + 1]];
76 c = (biphase_tbl[p[i + 1]] & 0xf) |
77 ((biphase_tbl[p[i]] & 0xf) << 4);
78 dst[i / 2] = c;
79 }
80
81 return err & 0xf0;
82}
83
84void cx25840_vbi_setup(struct i2c_client *client)
85{
86 v4l2_std_id std = cx25840_get_v4lstd(client);
87
88 if (std & ~V4L2_STD_NTSC) {
89 /* datasheet startup, step 8d */
90 cx25840_write(client, 0x49f, 0x11);
91
92 cx25840_write(client, 0x470, 0x84);
93 cx25840_write(client, 0x471, 0x00);
94 cx25840_write(client, 0x472, 0x2d);
95 cx25840_write(client, 0x473, 0x5d);
96
97 cx25840_write(client, 0x474, 0x24);
98 cx25840_write(client, 0x475, 0x40);
99 cx25840_write(client, 0x476, 0x24);
100 cx25840_write(client, 0x477, 0x28);
101
102 cx25840_write(client, 0x478, 0x1f);
103 cx25840_write(client, 0x479, 0x02);
104
105 if (std & V4L2_STD_SECAM) {
106 cx25840_write(client, 0x47a, 0x80);
107 cx25840_write(client, 0x47b, 0x00);
108 cx25840_write(client, 0x47c, 0x5f);
109 cx25840_write(client, 0x47d, 0x42);
110 } else {
111 cx25840_write(client, 0x47a, 0x90);
112 cx25840_write(client, 0x47b, 0x20);
113 cx25840_write(client, 0x47c, 0x63);
114 cx25840_write(client, 0x47d, 0x82);
115 }
116
117 cx25840_write(client, 0x47e, 0x0a);
118 cx25840_write(client, 0x47f, 0x01);
119 } else {
120 /* datasheet startup, step 8d */
121 cx25840_write(client, 0x49f, 0x14);
122
123 cx25840_write(client, 0x470, 0x7a);
124 cx25840_write(client, 0x471, 0x00);
125 cx25840_write(client, 0x472, 0x2d);
126 cx25840_write(client, 0x473, 0x5b);
127
128 cx25840_write(client, 0x474, 0x1a);
129 cx25840_write(client, 0x475, 0x70);
130 cx25840_write(client, 0x476, 0x1e);
131 cx25840_write(client, 0x477, 0x1e);
132
133 cx25840_write(client, 0x478, 0x1f);
134 cx25840_write(client, 0x479, 0x02);
135 cx25840_write(client, 0x47a, 0x50);
136 cx25840_write(client, 0x47b, 0x66);
137
138 cx25840_write(client, 0x47c, 0x1f);
139 cx25840_write(client, 0x47d, 0x7c);
140 cx25840_write(client, 0x47e, 0x08);
141 cx25840_write(client, 0x47f, 0x00);
142 }
143}
144
145int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg)
146{
147 struct v4l2_format *fmt;
148 struct v4l2_sliced_vbi_format *svbi;
149
150 switch (cmd) {
151 case VIDIOC_G_FMT:
152 {
153 static u16 lcr2vbi[] = {
154 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
155 0, V4L2_SLICED_WSS_625, 0, /* 4 */
156 V4L2_SLICED_CAPTION_525, /* 6 */
157 0, 0, V4L2_SLICED_VPS, 0, 0, /* 9 */
158 0, 0, 0, 0
159 };
160 int i;
161
162 fmt = arg;
163 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
164 return -EINVAL;
165 svbi = &fmt->fmt.sliced;
166 memset(svbi, 0, sizeof(*svbi));
167 /* we're done if raw VBI is active */
168 if ((cx25840_read(client, 0x404) & 0x10) == 0)
169 break;
170
171 for (i = 7; i <= 23; i++) {
172 u8 v = cx25840_read(client, 0x424 + i - 7);
173
174 svbi->service_lines[0][i] = lcr2vbi[v >> 4];
175 svbi->service_lines[1][i] = lcr2vbi[v & 0xf];
176 svbi->service_set |=
177 svbi->service_lines[0][i] | svbi->service_lines[1][i];
178 }
179 break;
180 }
181
182 case VIDIOC_S_FMT:
183 {
184 int is_pal = !(cx25840_get_v4lstd(client) & V4L2_STD_NTSC);
185 int vbi_offset = is_pal ? 1 : 0;
186 int i, x;
187 u8 lcr[24];
188
189 fmt = arg;
190 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
191 return -EINVAL;
192 svbi = &fmt->fmt.sliced;
193 if (svbi->service_set == 0) {
194 /* raw VBI */
195 memset(svbi, 0, sizeof(*svbi));
196
197 /* Setup VBI */
198 cx25840_vbi_setup(client);
199
200 /* VBI Offset */
201 cx25840_write(client, 0x47f, vbi_offset);
202 cx25840_write(client, 0x404, 0x2e);
203 break;
204 }
205
206 for (x = 0; x <= 23; x++)
207 lcr[x] = 0x00;
208
209 /* Setup VBI */
210 cx25840_vbi_setup(client);
211
212 /* Sliced VBI */
213 cx25840_write(client, 0x404, 0x36); /* Ancillery data */
214 cx25840_write(client, 0x406, 0x13);
215 cx25840_write(client, 0x47f, vbi_offset);
216
217 if (is_pal) {
218 for (i = 0; i <= 6; i++)
219 svbi->service_lines[0][i] =
220 svbi->service_lines[1][i] = 0;
221 } else {
222 for (i = 0; i <= 9; i++)
223 svbi->service_lines[0][i] =
224 svbi->service_lines[1][i] = 0;
225
226 for (i = 22; i <= 23; i++)
227 svbi->service_lines[0][i] =
228 svbi->service_lines[1][i] = 0;
229 }
230
231 for (i = 7; i <= 23; i++) {
232 for (x = 0; x <= 1; x++) {
233 switch (svbi->service_lines[1-x][i]) {
234 case V4L2_SLICED_TELETEXT_B:
235 lcr[i] |= 1 << (4 * x);
236 break;
237 case V4L2_SLICED_WSS_625:
238 lcr[i] |= 4 << (4 * x);
239 break;
240 case V4L2_SLICED_CAPTION_525:
241 lcr[i] |= 6 << (4 * x);
242 break;
243 case V4L2_SLICED_VPS:
244 lcr[i] |= 9 << (4 * x);
245 break;
246 }
247 }
248 }
249
250 for (x = 1, i = 0x424; i <= 0x434; i++, x++) {
251 cx25840_write(client, i, lcr[6 + x]);
252 }
253
254 cx25840_write(client, 0x43c, 0x16);
255
256 if (is_pal) {
257 cx25840_write(client, 0x474, 0x2a);
258 } else {
259 cx25840_write(client, 0x474, 0x1a + 6);
260 }
261 break;
262 }
263
264 case VIDIOC_INT_DECODE_VBI_LINE:
265 {
266 struct v4l2_decode_vbi_line *vbi = arg;
267 u8 *p = vbi->p;
268 int id1, id2, l, err = 0;
269
270 if (p[0] || p[1] != 0xff || p[2] != 0xff ||
271 (p[3] != 0x55 && p[3] != 0x91)) {
272 vbi->line = vbi->type = 0;
273 break;
274 }
275
276 p += 4;
277 id1 = p[-1];
278 id2 = p[0] & 0xf;
279 l = p[2] & 0x3f;
280 l += 5;
281 p += 4;
282
283 switch (id2) {
284 case 1:
285 id2 = V4L2_SLICED_TELETEXT_B;
286 break;
287 case 4:
288 id2 = V4L2_SLICED_WSS_625;
289 break;
290 case 6:
291 id2 = V4L2_SLICED_CAPTION_525;
292 err = !odd_parity(p[0]) || !odd_parity(p[1]);
293 break;
294 case 9:
295 id2 = V4L2_SLICED_VPS;
296 if (decode_vps(p, p) != 0) {
297 err = 1;
298 }
299 break;
300 default:
301 id2 = 0;
302 err = 1;
303 break;
304 }
305
306 vbi->type = err ? 0 : id2;
307 vbi->line = err ? 0 : l;
308 vbi->is_second_field = err ? 0 : (id1 == 0x55);
309 vbi->p = p;
310 break;
311 }
312 }
313
314 return 0;
315}
diff --git a/drivers/media/video/cx25840/cx25840.h b/drivers/media/video/cx25840/cx25840.h
new file mode 100644
index 000000000000..4932ed1c9b19
--- /dev/null
+++ b/drivers/media/video/cx25840/cx25840.h
@@ -0,0 +1,92 @@
1/* cx25840 API header
2 *
3 * Copyright (C) 2003-2004 Chris Kennedy
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#ifndef _CX25840_H_
21#define _CX25840_H_
22
23
24#include <linux/videodev2.h>
25#include <linux/i2c.h>
26
27extern int cx25840_debug;
28
29#define cx25840_dbg(fmt, arg...) do { if (cx25840_debug) \
30 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
31 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
32
33#define cx25840_err(fmt, arg...) do { \
34 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \
35 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
36
37#define cx25840_info(fmt, arg...) do { \
38 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \
39 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
40
41#define CX25840_CID_CARDTYPE (V4L2_CID_PRIVATE_BASE+0)
42
43/* The CARDTYPE_PVR150_WORKAROUND cardtype activates a workaround for a
44 hardware bug that is present in PVR150 (and possible PVR500) cards that
45 have certain NTSC tuners (tveeprom model numbers 85, 99 and 112). The
46 audio autodetect fails on some channels for these models and the workaround
47 is to select the audio standard explicitly. Many thanks to Hauppauge for
48 providing this information. */
49enum cx25840_cardtype {
50 CARDTYPE_PVR150,
51 CARDTYPE_PG600,
52 CARDTYPE_PVR150_WORKAROUND,
53};
54
55enum cx25840_input {
56 CX25840_TUNER,
57 CX25840_COMPOSITE0,
58 CX25840_COMPOSITE1,
59 CX25840_SVIDEO0,
60 CX25840_SVIDEO1
61};
62
63struct cx25840_state {
64 enum cx25840_cardtype cardtype;
65 enum cx25840_input input;
66 int audio_input;
67 enum v4l2_audio_clock_freq audclk_freq;
68};
69
70/* ----------------------------------------------------------------------- */
71/* cx25850-core.c */
72int cx25840_write(struct i2c_client *client, u16 addr, u8 value);
73int cx25840_write4(struct i2c_client *client, u16 addr, u32 value);
74u8 cx25840_read(struct i2c_client *client, u16 addr);
75u32 cx25840_read4(struct i2c_client *client, u16 addr);
76int cx25840_and_or(struct i2c_client *client, u16 addr, u8 mask, u8 value);
77v4l2_std_id cx25840_get_v4lstd(struct i2c_client *client);
78
79/* ----------------------------------------------------------------------- */
80/* cx25850-firmware.c */
81int cx25840_loadfw(struct i2c_client *client);
82
83/* ----------------------------------------------------------------------- */
84/* cx25850-audio.c */
85int cx25840_audio(struct i2c_client *client, unsigned int cmd, void *arg);
86
87/* ----------------------------------------------------------------------- */
88/* cx25850-vbi.c */
89void cx25840_vbi_setup(struct i2c_client *client);
90int cx25840_vbi(struct i2c_client *client, unsigned int cmd, void *arg);
91
92#endif
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index 41818b6205b3..85ba4106dc79 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -46,8 +46,8 @@ config VIDEO_CX88_DVB_ALL_FRONTENDS
46 If you are unsure, choose Y. 46 If you are unsure, choose Y.
47 47
48config VIDEO_CX88_DVB_MT352 48config VIDEO_CX88_DVB_MT352
49 tristate "Zarlink MT352 DVB-T Support" 49 bool "Zarlink MT352 DVB-T Support"
50 default m 50 default y
51 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 51 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
52 select DVB_MT352 52 select DVB_MT352
53 ---help--- 53 ---help---
@@ -55,8 +55,8 @@ config VIDEO_CX88_DVB_MT352
55 Connexant 2388x chip and the MT352 demodulator. 55 Connexant 2388x chip and the MT352 demodulator.
56 56
57config VIDEO_CX88_DVB_OR51132 57config VIDEO_CX88_DVB_OR51132
58 tristate "OR51132 ATSC Support" 58 bool "OR51132 ATSC Support"
59 default m 59 default y
60 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 60 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
61 select DVB_OR51132 61 select DVB_OR51132
62 ---help--- 62 ---help---
@@ -64,8 +64,8 @@ config VIDEO_CX88_DVB_OR51132
64 Connexant 2388x chip and the OR51132 demodulator. 64 Connexant 2388x chip and the OR51132 demodulator.
65 65
66config VIDEO_CX88_DVB_CX22702 66config VIDEO_CX88_DVB_CX22702
67 tristate "Conexant CX22702 DVB-T Support" 67 bool "Conexant CX22702 DVB-T Support"
68 default m 68 default y
69 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 69 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
70 select DVB_CX22702 70 select DVB_CX22702
71 ---help--- 71 ---help---
@@ -73,8 +73,8 @@ config VIDEO_CX88_DVB_CX22702
73 Connexant 2388x chip and the CX22702 demodulator. 73 Connexant 2388x chip and the CX22702 demodulator.
74 74
75config VIDEO_CX88_DVB_LGDT330X 75config VIDEO_CX88_DVB_LGDT330X
76 tristate "LG Electronics DT3302/DT3303 ATSC Support" 76 bool "LG Electronics DT3302/DT3303 ATSC Support"
77 default m 77 default y
78 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 78 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
79 select DVB_LGDT330X 79 select DVB_LGDT330X
80 ---help--- 80 ---help---
@@ -82,8 +82,8 @@ config VIDEO_CX88_DVB_LGDT330X
82 Connexant 2388x chip and the LGDT3302/LGDT3303 demodulator. 82 Connexant 2388x chip and the LGDT3302/LGDT3303 demodulator.
83 83
84config VIDEO_CX88_DVB_NXT200X 84config VIDEO_CX88_DVB_NXT200X
85 tristate "NXT2002/NXT2004 ATSC Support" 85 bool "NXT2002/NXT2004 ATSC Support"
86 default m 86 default y
87 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS 87 depends on VIDEO_CX88_DVB && !VIDEO_CX88_DVB_ALL_FRONTENDS
88 select DVB_NXT200X 88 select DVB_NXT200X
89 ---help--- 89 ---help---
diff --git a/drivers/media/video/cx88/Makefile b/drivers/media/video/cx88/Makefile
index 0df40b773454..54401b02b7ce 100644
--- a/drivers/media/video/cx88/Makefile
+++ b/drivers/media/video/cx88/Makefile
@@ -9,21 +9,12 @@ obj-$(CONFIG_VIDEO_CX88_DVB) += cx88-dvb.o
9EXTRA_CFLAGS += -I$(src)/.. 9EXTRA_CFLAGS += -I$(src)/..
10EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core 10EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
11EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends 11EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
12ifneq ($(CONFIG_VIDEO_BUF_DVB),n) 12
13 EXTRA_CFLAGS += -DHAVE_VIDEO_BUF_DVB=1 13extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
14endif 14extra-cflags-$(CONFIG_DVB_CX22702) += -DHAVE_CX22702=1
15ifneq ($(CONFIG_DVB_CX22702),n) 15extra-cflags-$(CONFIG_DVB_OR51132) += -DHAVE_OR51132=1
16 EXTRA_CFLAGS += -DHAVE_CX22702=1 16extra-cflags-$(CONFIG_DVB_LGDT330X) += -DHAVE_LGDT330X=1
17endif 17extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
18ifneq ($(CONFIG_DVB_OR51132),n) 18extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
19 EXTRA_CFLAGS += -DHAVE_OR51132=1 19
20endif 20EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
21ifneq ($(CONFIG_DVB_LGDT330X),n)
22 EXTRA_CFLAGS += -DHAVE_LGDT330X=1
23endif
24ifneq ($(CONFIG_DVB_MT352),n)
25 EXTRA_CFLAGS += -DHAVE_MT352=1
26endif
27ifneq ($(CONFIG_DVB_NXT200X),n)
28 EXTRA_CFLAGS += -DHAVE_NXT200X=1
29endif
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-cards.c b/drivers/media/video/cx88/cx88-cards.c
index f2268631b7c0..951709aa88ba 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -567,6 +567,7 @@ struct cx88_board cx88_boards[] = {
567 .radio_type = UNSET, 567 .radio_type = UNSET,
568 .tuner_addr = ADDR_UNSET, 568 .tuner_addr = ADDR_UNSET,
569 .radio_addr = ADDR_UNSET, 569 .radio_addr = ADDR_UNSET,
570 .tda9887_conf = TDA9887_PRESENT,
570 .input = {{ 571 .input = {{
571 .type = CX88_VMUX_TELEVISION, 572 .type = CX88_VMUX_TELEVISION,
572 .vmux = 0, 573 .vmux = 0,
@@ -711,6 +712,7 @@ struct cx88_board cx88_boards[] = {
711 .radio_type = UNSET, 712 .radio_type = UNSET,
712 .tuner_addr = ADDR_UNSET, 713 .tuner_addr = ADDR_UNSET,
713 .radio_addr = ADDR_UNSET, 714 .radio_addr = ADDR_UNSET,
715 .tda9887_conf = TDA9887_PRESENT,
714 .input = {{ 716 .input = {{
715 .type = CX88_VMUX_TELEVISION, 717 .type = CX88_VMUX_TELEVISION,
716 .vmux = 0, 718 .vmux = 0,
@@ -1083,41 +1085,28 @@ static void hauppauge_eeprom(struct cx88_core *core, u8 *eeprom_data)
1083 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data); 1085 tveeprom_hauppauge_analog(&core->i2c_client, &tv, eeprom_data);
1084 core->tuner_type = tv.tuner_type; 1086 core->tuner_type = tv.tuner_type;
1085 core->has_radio = tv.has_radio; 1087 core->has_radio = tv.has_radio;
1086}
1087
1088static int hauppauge_eeprom_dvb(struct cx88_core *core, u8 *ee)
1089{
1090 int model;
1091 int tuner;
1092 1088
1093 /* Make sure we support the board model */ 1089 /* Make sure we support the board model */
1094 model = ee[0x1f] << 24 | ee[0x1e] << 16 | ee[0x1d] << 8 | ee[0x1c]; 1090 switch (tv.model)
1095 switch(model) { 1091 {
1096 case 90002: 1092 case 90002: /* Nova-T-PCI (9002) */
1097 case 90500: 1093 case 92001: /* Nova-S-Plus (Video and IR) */
1098 case 90501: 1094 case 92002: /* Nova-S-Plus (Video and IR) */
1095 case 90003: /* Nova-T-PCI (9002 No RF out) */
1096 case 90500: /* Nova-T-PCI (oem) */
1097 case 90501: /* Nova-T-PCI (oem/IR) */
1098 case 92000: /* Nova-SE2 (OEM, No Video or IR) */
1099
1099 /* known */ 1100 /* known */
1100 break; 1101 break;
1101 default: 1102 default:
1102 printk("%s: warning: unknown hauppauge model #%d\n", 1103 printk("%s: warning: unknown hauppauge model #%d\n",
1103 core->name, model); 1104 core->name, tv.model);
1104 break; 1105 break;
1105 } 1106 }
1106 1107
1107 /* Make sure we support the tuner */ 1108 printk(KERN_INFO "%s: hauppauge eeprom: model=%d\n",
1108 tuner = ee[0x2d]; 1109 core->name, tv.model);
1109 switch(tuner) {
1110 case 0x4B: /* dtt 7595 */
1111 case 0x4C: /* dtt 7592 */
1112 break;
1113 default:
1114 printk("%s: error: unknown hauppauge tuner 0x%02x\n",
1115 core->name, tuner);
1116 return -ENODEV;
1117 }
1118 printk(KERN_INFO "%s: hauppauge eeprom: model=%d, tuner=%d\n",
1119 core->name, model, tuner);
1120 return 0;
1121} 1110}
1122 1111
1123/* ----------------------------------------------------------------------- */ 1112/* ----------------------------------------------------------------------- */
@@ -1201,7 +1190,7 @@ void cx88_card_list(struct cx88_core *core, struct pci_dev *pci)
1201 1190
1202void cx88_card_setup(struct cx88_core *core) 1191void cx88_card_setup(struct cx88_core *core)
1203{ 1192{
1204 static u8 eeprom[128]; 1193 static u8 eeprom[256];
1205 1194
1206 if (0 == core->i2c_rc) { 1195 if (0 == core->i2c_rc) {
1207 core->i2c_client.addr = 0xa0 >> 1; 1196 core->i2c_client.addr = 0xa0 >> 1;
@@ -1224,7 +1213,7 @@ void cx88_card_setup(struct cx88_core *core)
1224 break; 1213 break;
1225 case CX88_BOARD_HAUPPAUGE_DVB_T1: 1214 case CX88_BOARD_HAUPPAUGE_DVB_T1:
1226 if (0 == core->i2c_rc) 1215 if (0 == core->i2c_rc)
1227 hauppauge_eeprom_dvb(core,eeprom); 1216 hauppauge_eeprom(core,eeprom);
1228 break; 1217 break;
1229 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1: 1218 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
1230 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS: 1219 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index eb806af17182..bb6eb54e19ce 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -837,6 +837,29 @@ static int set_pll(struct cx88_core *core, int prescale, u32 ofreq)
837 return -1; 837 return -1;
838} 838}
839 839
840int cx88_start_audio_dma(struct cx88_core *core)
841{
842 /* setup fifo + format */
843 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
844 cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
845
846 cx_write(MO_AUDD_LNGTH, 128); /* fifo bpl size */
847 cx_write(MO_AUDR_LNGTH, 128); /* fifo bpl size */
848
849 /* start dma */
850 cx_write(MO_AUD_DMACNTRL, 0x0003); /* Up and Down fifo enable */
851
852 return 0;
853}
854
855int cx88_stop_audio_dma(struct cx88_core *core)
856{
857 /* stop dma */
858 cx_write(MO_AUD_DMACNTRL, 0x0000);
859
860 return 0;
861}
862
840static int set_tvaudio(struct cx88_core *core) 863static int set_tvaudio(struct cx88_core *core)
841{ 864{
842 struct cx88_tvnorm *norm = core->tvnorm; 865 struct cx88_tvnorm *norm = core->tvnorm;
@@ -877,12 +900,16 @@ static int set_tvaudio(struct cx88_core *core)
877 cx88_set_tvaudio(core); 900 cx88_set_tvaudio(core);
878 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */ 901 /* cx88_set_stereo(dev,V4L2_TUNER_MODE_STEREO); */
879 902
880 cx_write(MO_AUDD_LNGTH, 128); /* fifo size */ 903/*
881 cx_write(MO_AUDR_LNGTH, 128); /* fifo size */ 904 This should be needed only on cx88-alsa. It seems that some cx88 chips have
882 cx_write(MO_AUD_DMACNTRL, 0x03); /* need audio fifo */ 905 bugs and does require DMA enabled for it to work.
906 */
907 cx88_start_audio_dma(core);
883 return 0; 908 return 0;
884} 909}
885 910
911
912
886int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm) 913int cx88_set_tvnorm(struct cx88_core *core, struct cx88_tvnorm *norm)
887{ 914{
888 u32 fsc8; 915 u32 fsc8;
@@ -1204,6 +1231,8 @@ EXPORT_SYMBOL(cx88_set_scale);
1204EXPORT_SYMBOL(cx88_vdev_init); 1231EXPORT_SYMBOL(cx88_vdev_init);
1205EXPORT_SYMBOL(cx88_core_get); 1232EXPORT_SYMBOL(cx88_core_get);
1206EXPORT_SYMBOL(cx88_core_put); 1233EXPORT_SYMBOL(cx88_core_put);
1234EXPORT_SYMBOL(cx88_start_audio_dma);
1235EXPORT_SYMBOL(cx88_stop_audio_dma);
1207 1236
1208/* 1237/*
1209 * Local variables: 1238 * Local variables:
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index 9cce91ec334b..99ea955f5987 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -439,9 +439,6 @@ static int dvb_register(struct cx8802_dev *dev)
439 /* Put the analog decoder in standby to keep it quiet */ 439 /* Put the analog decoder in standby to keep it quiet */
440 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); 440 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
441 441
442 /* Put the analog decoder in standby to keep it quiet */
443 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
444
445 /* register everything */ 442 /* register everything */
446 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev); 443 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev);
447} 444}
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-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 6d9bec1c583b..a1b120c8a9b5 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -119,13 +119,10 @@ static void set_audio_registers(struct cx88_core *core, const struct rlist *l)
119 119
120static void set_audio_start(struct cx88_core *core, u32 mode) 120static void set_audio_start(struct cx88_core *core, u32 mode)
121{ 121{
122 // mute 122 /* mute */
123 cx_write(AUD_VOL_CTL, (1 << 6)); 123 cx_write(AUD_VOL_CTL, (1 << 6));
124 124
125 // start programming 125 /* start programming */
126 cx_write(MO_AUD_DMACNTRL, 0x0000);
127 msleep(100);
128 //cx_write(AUD_CTL, 0x0000);
129 cx_write(AUD_INIT, mode); 126 cx_write(AUD_INIT, mode);
130 cx_write(AUD_INIT_LD, 0x0001); 127 cx_write(AUD_INIT_LD, 0x0001);
131 cx_write(AUD_SOFT_RESET, 0x0001); 128 cx_write(AUD_SOFT_RESET, 0x0001);
@@ -135,17 +132,21 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
135{ 132{
136 u32 volume; 133 u32 volume;
137 134
135 /* restart dma; This avoids buzz in NICAM and is good in others */
136 cx88_stop_audio_dma(core);
137 cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
138 cx88_start_audio_dma(core);
139
138 if (cx88_boards[core->board].blackbird) { 140 if (cx88_boards[core->board].blackbird) {
139 // sets sound input from external adc 141 /* sets sound input from external adc */
140 cx_set(AUD_CTL, EN_I2SIN_ENABLE); 142 cx_set(AUD_CTL, EN_I2SIN_ENABLE);
141 //cx_write(AUD_I2SINPUTCNTL, 0);
142 cx_write(AUD_I2SINPUTCNTL, 4); 143 cx_write(AUD_I2SINPUTCNTL, 4);
143 cx_write(AUD_BAUDRATE, 1); 144 cx_write(AUD_BAUDRATE, 1);
144 // 'pass-thru mode': this enables the i2s output to the mpeg encoder 145 /* 'pass-thru mode': this enables the i2s output to the mpeg encoder */
145 cx_set(AUD_CTL, EN_I2SOUT_ENABLE); 146 cx_set(AUD_CTL, EN_I2SOUT_ENABLE);
146 cx_write(AUD_I2SOUTPUTCNTL, 1); 147 cx_write(AUD_I2SOUTPUTCNTL, 1);
147 cx_write(AUD_I2SCNTL, 0); 148 cx_write(AUD_I2SCNTL, 0);
148 //cx_write(AUD_APB_IN_RATE_ADJ, 0); 149 /* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
149 } else { 150 } else {
150 ctl |= EN_DAC_ENABLE; 151 ctl |= EN_DAC_ENABLE;
151 cx_write(AUD_CTL, ctl); 152 cx_write(AUD_CTL, ctl);
@@ -153,7 +154,6 @@ static void set_audio_finish(struct cx88_core *core, u32 ctl)
153 154
154 /* finish programming */ 155 /* finish programming */
155 cx_write(AUD_SOFT_RESET, 0x0000); 156 cx_write(AUD_SOFT_RESET, 0x0000);
156 cx_write(MO_AUD_DMACNTRL, 0x0003);
157 157
158 /* unmute */ 158 /* unmute */
159 volume = cx_sread(SHADOW_AUD_VOL_CTL); 159 volume = cx_sread(SHADOW_AUD_VOL_CTL);
@@ -313,7 +313,6 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
313 {AUD_RATE_ADJ3, 0x00000100}, 313 {AUD_RATE_ADJ3, 0x00000100},
314 {AUD_RATE_ADJ4, 0x00000400}, 314 {AUD_RATE_ADJ4, 0x00000400},
315 {AUD_RATE_ADJ5, 0x00001000}, 315 {AUD_RATE_ADJ5, 0x00001000},
316 //{ AUD_DMD_RA_DDS, 0x00c0d5ce },
317 {AUD_ERRLOGPERIOD_R, 0x00000fff}, 316 {AUD_ERRLOGPERIOD_R, 0x00000fff},
318 {AUD_ERRINTRPTTHSHLD1_R, 0x000003ff}, 317 {AUD_ERRINTRPTTHSHLD1_R, 0x000003ff},
319 {AUD_ERRINTRPTTHSHLD2_R, 0x000000ff}, 318 {AUD_ERRINTRPTTHSHLD2_R, 0x000000ff},
@@ -351,12 +350,12 @@ static void set_audio_standard_NICAM(struct cx88_core *core, u32 mode)
351 set_audio_registers(core, nicam_l); 350 set_audio_registers(core, nicam_l);
352 break; 351 break;
353 case WW_I: 352 case WW_I:
354 dprintk("%s PAL-I NICAM (status: devel)\n", __FUNCTION__); 353 dprintk("%s PAL-I NICAM (status: known-good)\n", __FUNCTION__);
355 set_audio_registers(core, nicam_bgdki_common); 354 set_audio_registers(core, nicam_bgdki_common);
356 set_audio_registers(core, nicam_i); 355 set_audio_registers(core, nicam_i);
357 break; 356 break;
358 default: 357 default:
359 dprintk("%s PAL-BGDK NICAM (status: unknown)\n", __FUNCTION__); 358 dprintk("%s PAL-BGDK NICAM (status: known-good)\n", __FUNCTION__);
360 set_audio_registers(core, nicam_bgdki_common); 359 set_audio_registers(core, nicam_bgdki_common);
361 set_audio_registers(core, nicam_default); 360 set_audio_registers(core, nicam_default);
362 break; 361 break;
@@ -715,8 +714,7 @@ int cx88_detect_nicam(struct cx88_core *core)
715 /* if bit1=1 then nicam is detected */ 714 /* if bit1=1 then nicam is detected */
716 j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1); 715 j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1);
717 716
718 /* 3x detected: absolutly sure now */ 717 if (j == 1) {
719 if (j == 3) {
720 dprintk("nicam is detected.\n"); 718 dprintk("nicam is detected.\n");
721 return 1; 719 return 1;
722 } 720 }
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index b19d3a9e2298..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
@@ -491,6 +490,10 @@ extern struct cx88_core* cx88_core_get(struct pci_dev *pci);
491extern void cx88_core_put(struct cx88_core *core, 490extern void cx88_core_put(struct cx88_core *core,
492 struct pci_dev *pci); 491 struct pci_dev *pci);
493 492
493extern int cx88_start_audio_dma(struct cx88_core *core);
494extern int cx88_stop_audio_dma(struct cx88_core *core);
495
496
494/* ----------------------------------------------------------- */ 497/* ----------------------------------------------------------- */
495/* cx88-vbi.c */ 498/* cx88-vbi.c */
496 499
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index d54bc0127484..0cfe75416ec6 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -32,7 +32,7 @@
32 32
33/* #define ENABLE_DEBUG_ISOC_FRAMES */ 33/* #define ENABLE_DEBUG_ISOC_FRAMES */
34 34
35unsigned int core_debug; 35static unsigned int core_debug;
36module_param(core_debug,int,0644); 36module_param(core_debug,int,0644);
37MODULE_PARM_DESC(core_debug,"enable debug messages [core]"); 37MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
38 38
@@ -41,7 +41,7 @@ MODULE_PARM_DESC(core_debug,"enable debug messages [core]");
41 printk(KERN_INFO "%s %s :"fmt, \ 41 printk(KERN_INFO "%s %s :"fmt, \
42 dev->name, __FUNCTION__ , ##arg); } while (0) 42 dev->name, __FUNCTION__ , ##arg); } while (0)
43 43
44unsigned int reg_debug; 44static unsigned int reg_debug;
45module_param(reg_debug,int,0644); 45module_param(reg_debug,int,0644);
46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]"); 46MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
47 47
@@ -50,7 +50,7 @@ MODULE_PARM_DESC(reg_debug,"enable debug messages [URB reg]");
50 printk(KERN_INFO "%s %s :"fmt, \ 50 printk(KERN_INFO "%s %s :"fmt, \
51 dev->name, __FUNCTION__ , ##arg); } while (0) 51 dev->name, __FUNCTION__ , ##arg); } while (0)
52 52
53unsigned int isoc_debug; 53static unsigned int isoc_debug;
54module_param(isoc_debug,int,0644); 54module_param(isoc_debug,int,0644);
55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]"); 55MODULE_PARM_DESC(isoc_debug,"enable debug messages [isoc transfers]");
56 56
@@ -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..7f5603054f02 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)
diff --git a/drivers/media/video/em28xx/em28xx-input.c b/drivers/media/video/em28xx/em28xx-input.c
index 32c49df58adc..9b94f77d6fd7 100644
--- a/drivers/media/video/em28xx/em28xx-input.c
+++ b/drivers/media/video/em28xx/em28xx-input.c
@@ -120,9 +120,6 @@ static int get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
120 if (buf[1]==0xff) 120 if (buf[1]==0xff)
121 return 0; 121 return 0;
122 122
123 /* avoid fast reapeating */
124 if (buf[1]==ir->old)
125 return 0;
126 ir->old=buf[1]; 123 ir->old=buf[1];
127 124
128 /* Rearranges bits to the right order */ 125 /* Rearranges bits to the right order */
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 57c1826b928e..06d76879bde2 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
@@ -226,7 +216,7 @@ static int em28xx_config(struct em28xx *dev)
226 * em28xx_config_i2c() 216 * em28xx_config_i2c()
227 * configure i2c attached devices 217 * configure i2c attached devices
228 */ 218 */
229void em28xx_config_i2c(struct em28xx *dev) 219static void em28xx_config_i2c(struct em28xx *dev)
230{ 220{
231 struct v4l2_frequency f; 221 struct v4l2_frequency f;
232 struct video_decoder_init em28xx_vdi = {.data = NULL }; 222 struct video_decoder_init em28xx_vdi = {.data = NULL };
@@ -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 }
diff --git a/drivers/media/video/ir-kbd-gpio.c b/drivers/media/video/ir-kbd-gpio.c
index ed81934ef3cd..de1385e5d05e 100644
--- a/drivers/media/video/ir-kbd-gpio.c
+++ b/drivers/media/video/ir-kbd-gpio.c
@@ -221,24 +221,98 @@ static IR_KEYTAB_TYPE ir_codes_conceptronic[IR_KEYTAB_SIZE] = {
221 [ 24 ] = KEY_MUTE // mute/unmute 221 [ 24 ] = KEY_MUTE // mute/unmute
222}; 222};
223 223
224static IR_KEYTAB_TYPE ir_codes_nebula[IR_KEYTAB_SIZE] = {
225 [0x00] = KEY_KP0,
226 [0x01] = KEY_KP1,
227 [0x02] = KEY_KP2,
228 [0x03] = KEY_KP3,
229 [0x04] = KEY_KP4,
230 [0x05] = KEY_KP5,
231 [0x06] = KEY_KP6,
232 [0x07] = KEY_KP7,
233 [0x08] = KEY_KP8,
234 [0x09] = KEY_KP9,
235 [0x0a] = KEY_TV,
236 [0x0b] = KEY_AUX,
237 [0x0c] = KEY_DVD,
238 [0x0d] = KEY_POWER,
239 [0x0e] = KEY_MHP, /* labelled 'Picture' */
240 [0x0f] = KEY_AUDIO,
241 [0x10] = KEY_INFO,
242 [0x11] = KEY_F13, /* 16:9 */
243 [0x12] = KEY_F14, /* 14:9 */
244 [0x13] = KEY_EPG,
245 [0x14] = KEY_EXIT,
246 [0x15] = KEY_MENU,
247 [0x16] = KEY_UP,
248 [0x17] = KEY_DOWN,
249 [0x18] = KEY_LEFT,
250 [0x19] = KEY_RIGHT,
251 [0x1a] = KEY_ENTER,
252 [0x1b] = KEY_CHANNELUP,
253 [0x1c] = KEY_CHANNELDOWN,
254 [0x1d] = KEY_VOLUMEUP,
255 [0x1e] = KEY_VOLUMEDOWN,
256 [0x1f] = KEY_RED,
257 [0x20] = KEY_GREEN,
258 [0x21] = KEY_YELLOW,
259 [0x22] = KEY_BLUE,
260 [0x23] = KEY_SUBTITLE,
261 [0x24] = KEY_F15, /* AD */
262 [0x25] = KEY_TEXT,
263 [0x26] = KEY_MUTE,
264 [0x27] = KEY_REWIND,
265 [0x28] = KEY_STOP,
266 [0x29] = KEY_PLAY,
267 [0x2a] = KEY_FASTFORWARD,
268 [0x2b] = KEY_F16, /* chapter */
269 [0x2c] = KEY_PAUSE,
270 [0x2d] = KEY_PLAY,
271 [0x2e] = KEY_RECORD,
272 [0x2f] = KEY_F17, /* picture in picture */
273 [0x30] = KEY_KPPLUS, /* zoom in */
274 [0x31] = KEY_KPMINUS, /* zoom out */
275 [0x32] = KEY_F18, /* capture */
276 [0x33] = KEY_F19, /* web */
277 [0x34] = KEY_EMAIL,
278 [0x35] = KEY_PHONE,
279 [0x36] = KEY_PC
280};
281
224struct IR { 282struct IR {
225 struct bttv_sub_device *sub; 283 struct bttv_sub_device *sub;
226 struct input_dev *input; 284 struct input_dev *input;
227 struct ir_input_state ir; 285 struct ir_input_state ir;
228 char name[32]; 286 char name[32];
229 char phys[32]; 287 char phys[32];
288
289 /* Usual gpio signalling */
290
230 u32 mask_keycode; 291 u32 mask_keycode;
231 u32 mask_keydown; 292 u32 mask_keydown;
232 u32 mask_keyup; 293 u32 mask_keyup;
233 294 u32 polling;
234 int polling;
235 u32 last_gpio; 295 u32 last_gpio;
236 struct work_struct work; 296 struct work_struct work;
237 struct timer_list timer; 297 struct timer_list timer;
298
299 /* RC5 gpio */
300 u32 rc5_gpio;
301 struct timer_list timer_end; /* timer_end for code completion */
302 struct timer_list timer_keyup; /* timer_end for key release */
303 u32 last_rc5; /* last good rc5 code */
304 u32 last_bit; /* last raw bit seen */
305 u32 code; /* raw code under construction */
306 struct timeval base_time; /* time of last seen code */
307 int active; /* building raw code */
238}; 308};
239 309
240static int debug; 310static int debug;
241module_param(debug, int, 0644); /* debug level (0,1,2) */ 311module_param(debug, int, 0644); /* debug level (0,1,2) */
312static int repeat_delay = 500;
313module_param(repeat_delay, int, 0644);
314static int repeat_period = 33;
315module_param(repeat_period, int, 0644);
242 316
243#define DEVNAME "ir-kbd-gpio" 317#define DEVNAME "ir-kbd-gpio"
244#define dprintk(fmt, arg...) if (debug) \ 318#define dprintk(fmt, arg...) if (debug) \
@@ -254,7 +328,7 @@ static struct bttv_sub_driver driver = {
254 .probe = ir_probe, 328 .probe = ir_probe,
255 .remove = ir_remove, 329 .remove = ir_remove,
256 }, 330 },
257 .gpio_irq = ir_irq, 331 .gpio_irq = ir_irq,
258}; 332};
259 333
260/* ---------------------------------------------------------------------- */ 334/* ---------------------------------------------------------------------- */
@@ -327,6 +401,173 @@ static void ir_work(void *data)
327 mod_timer(&ir->timer, timeout); 401 mod_timer(&ir->timer, timeout);
328} 402}
329 403
404/* ---------------------------------------------------------------*/
405
406static int rc5_remote_gap = 885;
407module_param(rc5_remote_gap, int, 0644);
408static int rc5_key_timeout = 200;
409module_param(rc5_key_timeout, int, 0644);
410
411#define RC5_START(x) (((x)>>12)&3)
412#define RC5_TOGGLE(x) (((x)>>11)&1)
413#define RC5_ADDR(x) (((x)>>6)&31)
414#define RC5_INSTR(x) ((x)&63)
415
416/* decode raw bit pattern to RC5 code */
417static u32 rc5_decode(unsigned int code)
418{
419 unsigned int org_code = code;
420 unsigned int pair;
421 unsigned int rc5 = 0;
422 int i;
423
424 code = (code << 1) | 1;
425 for (i = 0; i < 14; ++i) {
426 pair = code & 0x3;
427 code >>= 2;
428
429 rc5 <<= 1;
430 switch (pair) {
431 case 0:
432 case 2:
433 break;
434 case 1:
435 rc5 |= 1;
436 break;
437 case 3:
438 dprintk("bad code: %x\n", org_code);
439 return 0;
440 }
441 }
442 dprintk("code=%x, rc5=%x, start=%x, toggle=%x, address=%x, "
443 "instr=%x\n", rc5, org_code, RC5_START(rc5),
444 RC5_TOGGLE(rc5), RC5_ADDR(rc5), RC5_INSTR(rc5));
445 return rc5;
446}
447
448static int ir_rc5_irq(struct bttv_sub_device *sub)
449{
450 struct IR *ir = dev_get_drvdata(&sub->dev);
451 struct timeval tv;
452 u32 gpio;
453 u32 gap;
454 unsigned long current_jiffies, timeout;
455
456 /* read gpio port */
457 gpio = bttv_gpio_read(ir->sub->core);
458
459 /* remote IRQ? */
460 if (!(gpio & 0x20))
461 return 0;
462
463 /* get time of bit */
464 current_jiffies = jiffies;
465 do_gettimeofday(&tv);
466
467 /* avoid overflow with gap >1s */
468 if (tv.tv_sec - ir->base_time.tv_sec > 1) {
469 gap = 200000;
470 } else {
471 gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
472 tv.tv_usec - ir->base_time.tv_usec;
473 }
474
475 /* active code => add bit */
476 if (ir->active) {
477 /* only if in the code (otherwise spurious IRQ or timer
478 late) */
479 if (ir->last_bit < 28) {
480 ir->last_bit = (gap - rc5_remote_gap / 2) /
481 rc5_remote_gap;
482 ir->code |= 1 << ir->last_bit;
483 }
484 /* starting new code */
485 } else {
486 ir->active = 1;
487 ir->code = 0;
488 ir->base_time = tv;
489 ir->last_bit = 0;
490
491 timeout = current_jiffies + (500 + 30 * HZ) / 1000;
492 mod_timer(&ir->timer_end, timeout);
493 }
494
495 /* toggle GPIO pin 4 to reset the irq */
496 bttv_gpio_write(ir->sub->core, gpio & ~(1 << 4));
497 bttv_gpio_write(ir->sub->core, gpio | (1 << 4));
498 return 1;
499}
500
501static void ir_rc5_timer_end(unsigned long data)
502{
503 struct IR *ir = (struct IR *)data;
504 struct timeval tv;
505 unsigned long current_jiffies, timeout;
506 u32 gap;
507
508 /* get time */
509 current_jiffies = jiffies;
510 do_gettimeofday(&tv);
511
512 /* avoid overflow with gap >1s */
513 if (tv.tv_sec - ir->base_time.tv_sec > 1) {
514 gap = 200000;
515 } else {
516 gap = 1000000 * (tv.tv_sec - ir->base_time.tv_sec) +
517 tv.tv_usec - ir->base_time.tv_usec;
518 }
519
520 /* Allow some timmer jitter (RC5 is ~24ms anyway so this is ok) */
521 if (gap < 28000) {
522 dprintk("spurious timer_end\n");
523 return;
524 }
525
526 ir->active = 0;
527 if (ir->last_bit < 20) {
528 /* ignore spurious codes (caused by light/other remotes) */
529 dprintk("short code: %x\n", ir->code);
530 } else {
531 u32 rc5 = rc5_decode(ir->code);
532
533 /* two start bits? */
534 if (RC5_START(rc5) != 3) {
535 dprintk("rc5 start bits invalid: %u\n", RC5_START(rc5));
536
537 /* right address? */
538 } else if (RC5_ADDR(rc5) == 0x0) {
539 u32 toggle = RC5_TOGGLE(rc5);
540 u32 instr = RC5_INSTR(rc5);
541
542 /* Good code, decide if repeat/repress */
543 if (toggle != RC5_TOGGLE(ir->last_rc5) ||
544 instr != RC5_INSTR(ir->last_rc5)) {
545 dprintk("instruction %x, toggle %x\n", instr,
546 toggle);
547 ir_input_nokey(ir->input, &ir->ir);
548 ir_input_keydown(ir->input, &ir->ir, instr,
549 instr);
550 }
551
552 /* Set/reset key-up timer */
553 timeout = current_jiffies + (500 + rc5_key_timeout
554 * HZ) / 1000;
555 mod_timer(&ir->timer_keyup, timeout);
556
557 /* Save code for repeat test */
558 ir->last_rc5 = rc5;
559 }
560 }
561}
562
563static void ir_rc5_timer_keyup(unsigned long data)
564{
565 struct IR *ir = (struct IR *)data;
566
567 dprintk("key released\n");
568 ir_input_nokey(ir->input, &ir->ir);
569}
570
330/* ---------------------------------------------------------------------- */ 571/* ---------------------------------------------------------------------- */
331 572
332static int ir_probe(struct device *dev) 573static int ir_probe(struct device *dev)
@@ -400,6 +641,12 @@ static int ir_probe(struct device *dev)
400 ir->mask_keyup = 0x006000; 641 ir->mask_keyup = 0x006000;
401 ir->polling = 50; // ms 642 ir->polling = 50; // ms
402 break; 643 break;
644 case BTTV_BOARD_NEBULA_DIGITV:
645 ir_codes = ir_codes_nebula;
646 driver.any_irq = ir_rc5_irq;
647 driver.gpio_irq = NULL;
648 ir->rc5_gpio = 1;
649 break;
403 } 650 }
404 if (NULL == ir_codes) { 651 if (NULL == ir_codes) {
405 kfree(ir); 652 kfree(ir);
@@ -407,9 +654,17 @@ static int ir_probe(struct device *dev)
407 return -ENODEV; 654 return -ENODEV;
408 } 655 }
409 656
410 /* init hardware-specific stuff */ 657 if (ir->rc5_gpio) {
411 bttv_gpio_inout(sub->core, ir->mask_keycode | ir->mask_keydown, 0); 658 u32 gpio;
412 ir->sub = sub; 659 /* enable remote irq */
660 bttv_gpio_inout(sub->core, (1 << 4), 1 << 4);
661 gpio = bttv_gpio_read(sub->core);
662 bttv_gpio_write(sub->core, gpio & ~(1 << 4));
663 bttv_gpio_write(sub->core, gpio | (1 << 4));
664 } else {
665 /* init hardware-specific stuff */
666 bttv_gpio_inout(sub->core, ir->mask_keycode | ir->mask_keydown, 0);
667 }
413 668
414 /* init input device */ 669 /* init input device */
415 snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)", 670 snprintf(ir->name, sizeof(ir->name), "bttv IR (card=%d)",
@@ -431,18 +686,34 @@ static int ir_probe(struct device *dev)
431 } 686 }
432 input_dev->cdev.dev = &sub->core->pci->dev; 687 input_dev->cdev.dev = &sub->core->pci->dev;
433 688
689 ir->input = input_dev;
690 ir->sub = sub;
691
434 if (ir->polling) { 692 if (ir->polling) {
435 INIT_WORK(&ir->work, ir_work, ir); 693 INIT_WORK(&ir->work, ir_work, ir);
436 init_timer(&ir->timer); 694 init_timer(&ir->timer);
437 ir->timer.function = ir_timer; 695 ir->timer.function = ir_timer;
438 ir->timer.data = (unsigned long)ir; 696 ir->timer.data = (unsigned long)ir;
439 schedule_work(&ir->work); 697 schedule_work(&ir->work);
698 } else if (ir->rc5_gpio) {
699 /* set timer_end for code completion */
700 init_timer(&ir->timer_end);
701 ir->timer_end.function = ir_rc5_timer_end;
702 ir->timer_end.data = (unsigned long)ir;
703
704 init_timer(&ir->timer_keyup);
705 ir->timer_keyup.function = ir_rc5_timer_keyup;
706 ir->timer_keyup.data = (unsigned long)ir;
440 } 707 }
441 708
442 /* all done */ 709 /* all done */
443 dev_set_drvdata(dev, ir); 710 dev_set_drvdata(dev, ir);
444 input_register_device(ir->input); 711 input_register_device(ir->input);
445 712
713 /* the remote isn't as bouncy as a keyboard */
714 ir->input->rep[REP_DELAY] = repeat_delay;
715 ir->input->rep[REP_PERIOD] = repeat_period;
716
446 return 0; 717 return 0;
447} 718}
448 719
@@ -455,6 +726,16 @@ static int ir_remove(struct device *dev)
455 flush_scheduled_work(); 726 flush_scheduled_work();
456 } 727 }
457 728
729 if (ir->rc5_gpio) {
730 u32 gpio;
731
732 del_timer(&ir->timer_end);
733 flush_scheduled_work();
734
735 gpio = bttv_gpio_read(ir->sub->core);
736 bttv_gpio_write(ir->sub->core, gpio & ~(1 << 4));
737 }
738
458 input_unregister_device(ir->input); 739 input_unregister_device(ir->input);
459 kfree(ir); 740 kfree(ir);
460 return 0; 741 return 0;
diff --git a/drivers/media/video/ir-kbd-i2c.c b/drivers/media/video/ir-kbd-i2c.c
index 0085567a1421..740e543311af 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
@@ -183,6 +184,58 @@ static int get_key_knc1(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
183 return 1; 184 return 1;
184} 185}
185 186
187/* The new pinnacle PCTV remote (with the colored buttons)
188 *
189 * Ricardo Cerqueira <v4l@cerqueira.org>
190 */
191
192int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
193{
194 unsigned char b[4];
195 unsigned int start = 0,parity = 0,code = 0;
196
197 /* poll IR chip */
198 if (4 != i2c_master_recv(&ir->c,b,4)) {
199 dprintk(2,"read error\n");
200 return -EIO;
201 }
202
203 for (start = 0; start<4; start++) {
204 if (b[start] == 0x80) {
205 code=b[(start+3)%4];
206 parity=b[(start+2)%4];
207 }
208 }
209
210 /* Empty Request */
211 if (parity==0)
212 return 0;
213
214 /* Repeating... */
215 if (ir->old == parity)
216 return 0;
217
218
219 ir->old = parity;
220
221 /* Reduce code value to fit inside IR_KEYTAB_SIZE
222 *
223 * this is the only value that results in 42 unique
224 * codes < 128
225 */
226
227 code %= 0x88;
228
229 *ir_raw = code;
230 *ir_key = code;
231
232 dprintk(1,"Pinnacle PCTV key %02x\n", code);
233
234 return 1;
235}
236
237EXPORT_SYMBOL_GPL(get_key_pinnacle);
238
186/* ----------------------------------------------------------------------- */ 239/* ----------------------------------------------------------------------- */
187 240
188static void ir_key_poll(struct IR_i2c *ir) 241static void ir_key_poll(struct IR_i2c *ir)
@@ -226,7 +279,7 @@ static int ir_probe(struct i2c_adapter *adap);
226 279
227static struct i2c_driver driver = { 280static struct i2c_driver driver = {
228 .name = "ir remote kbd driver", 281 .name = "ir remote kbd driver",
229 .id = I2C_DRIVERID_EXP3, /* FIXME */ 282 .id = I2C_DRIVERID_INFRARED,
230 .flags = I2C_DF_NOTIFY, 283 .flags = I2C_DF_NOTIFY,
231 .attach_adapter = ir_probe, 284 .attach_adapter = ir_probe,
232 .detach_client = ir_detach, 285 .detach_client = ir_detach,
@@ -244,15 +297,15 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
244 IR_KEYTAB_TYPE *ir_codes = NULL; 297 IR_KEYTAB_TYPE *ir_codes = NULL;
245 char *name; 298 char *name;
246 int ir_type; 299 int ir_type;
247 struct IR_i2c *ir; 300 struct IR_i2c *ir;
248 struct input_dev *input_dev; 301 struct input_dev *input_dev;
249 302
250 ir = kzalloc(sizeof(struct IR_i2c), GFP_KERNEL); 303 ir = kzalloc(sizeof(struct IR_i2c),GFP_KERNEL);
251 input_dev = input_allocate_device(); 304 input_dev = input_allocate_device();
252 if (!ir || !input_dev) { 305 if (!ir || !input_dev) {
253 kfree(ir); 306 kfree(ir);
254 input_free_device(input_dev); 307 input_free_device(input_dev);
255 return -ENOMEM; 308 return -ENOMEM;
256 } 309 }
257 310
258 ir->c = client_template; 311 ir->c = client_template;
@@ -308,7 +361,7 @@ static int ir_attach(struct i2c_adapter *adap, int addr,
308 /* register i2c device 361 /* register i2c device
309 * At device register, IR codes may be changed to be 362 * At device register, IR codes may be changed to be
310 * board dependent. 363 * board dependent.
311 */ 364 */
312 i2c_attach_client(&ir->c); 365 i2c_attach_client(&ir->c);
313 366
314 /* If IR not supported or disabled, unregisters driver */ 367 /* If IR not supported or disabled, unregisters driver */
diff --git a/drivers/media/video/msp3400.c b/drivers/media/video/msp3400.c
index a23fb0338986..d86f8e92e534 100644
--- a/drivers/media/video/msp3400.c
+++ b/drivers/media/video/msp3400.c
@@ -134,7 +134,7 @@ struct msp3400c {
134 int rxsubchans; 134 int rxsubchans;
135 135
136 int muted; 136 int muted;
137 int left, right; /* volume */ 137 int left, right; /* volume */
138 int bass, treble; 138 int bass, treble;
139 139
140 /* shadow register set */ 140 /* shadow register set */
@@ -882,6 +882,7 @@ static void watch_stereo(struct i2c_client *client)
882 msp->watch_stereo = 0; 882 msp->watch_stereo = 0;
883} 883}
884 884
885
885static int msp3400c_thread(void *data) 886static int msp3400c_thread(void *data)
886{ 887{
887 struct i2c_client *client = data; 888 struct i2c_client *client = data;
@@ -889,6 +890,7 @@ static int msp3400c_thread(void *data)
889 struct CARRIER_DETECT *cd; 890 struct CARRIER_DETECT *cd;
890 int count, max1,max2,val1,val2, val,this; 891 int count, max1,max2,val1,val2, val,this;
891 892
893
892 msp3400_info("msp3400 daemon started\n"); 894 msp3400_info("msp3400 daemon started\n");
893 for (;;) { 895 for (;;) {
894 msp3400_dbg_mediumvol("msp3400 thread: sleep\n"); 896 msp3400_dbg_mediumvol("msp3400 thread: sleep\n");
@@ -1162,6 +1164,7 @@ static int msp3410d_thread(void *data)
1162 int mode,val,i,std; 1164 int mode,val,i,std;
1163 1165
1164 msp3400_info("msp3410 daemon started\n"); 1166 msp3400_info("msp3410 daemon started\n");
1167
1165 for (;;) { 1168 for (;;) {
1166 msp3400_dbg_mediumvol("msp3410 thread: sleep\n"); 1169 msp3400_dbg_mediumvol("msp3410 thread: sleep\n");
1167 msp34xx_sleep(msp,-1); 1170 msp34xx_sleep(msp,-1);
@@ -1384,6 +1387,7 @@ static int msp34xxg_thread(void *data)
1384 int val, std, i; 1387 int val, std, i;
1385 1388
1386 msp3400_info("msp34xxg daemon started\n"); 1389 msp3400_info("msp34xxg daemon started\n");
1390
1387 msp->source = 1; /* default */ 1391 msp->source = 1; /* default */
1388 for (;;) { 1392 for (;;) {
1389 msp3400_dbg_mediumvol("msp34xxg thread: sleep\n"); 1393 msp3400_dbg_mediumvol("msp34xxg thread: sleep\n");
@@ -1559,11 +1563,11 @@ static void msp_wake_thread(struct i2c_client *client);
1559static struct i2c_driver driver = { 1563static struct i2c_driver driver = {
1560 .owner = THIS_MODULE, 1564 .owner = THIS_MODULE,
1561 .name = "msp3400", 1565 .name = "msp3400",
1562 .id = I2C_DRIVERID_MSP3400, 1566 .id = I2C_DRIVERID_MSP3400,
1563 .flags = I2C_DF_NOTIFY, 1567 .flags = I2C_DF_NOTIFY,
1564 .attach_adapter = msp_probe, 1568 .attach_adapter = msp_probe,
1565 .detach_client = msp_detach, 1569 .detach_client = msp_detach,
1566 .command = msp_command, 1570 .command = msp_command,
1567 .driver = { 1571 .driver = {
1568 .suspend = msp_suspend, 1572 .suspend = msp_suspend,
1569 .resume = msp_resume, 1573 .resume = msp_resume,
@@ -1574,7 +1578,7 @@ static struct i2c_client client_template =
1574{ 1578{
1575 .name = "(unset)", 1579 .name = "(unset)",
1576 .flags = I2C_CLIENT_ALLOW_USE, 1580 .flags = I2C_CLIENT_ALLOW_USE,
1577 .driver = &driver, 1581 .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/saa6588.c b/drivers/media/video/saa6588.c
index dca3ddfd510f..923322503e8f 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
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
new file mode 100644
index 000000000000..e717e30d8187
--- /dev/null
+++ b/drivers/media/video/saa7115.c
@@ -0,0 +1,1378 @@
1/* saa7115 - Philips SAA7114/SAA7115 video decoder driver
2 *
3 * Based on saa7114 driver by Maxim Yevtyushkin, which is based on
4 * the saa7111 driver by Dave Perks.
5 *
6 * Copyright (C) 1998 Dave Perks <dperks@ibm.net>
7 * Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
8 *
9 * Slight changes for video timing and attachment output by
10 * Wolfgang Scherr <scherr@net4you.net>
11 *
12 * Moved over to the linux >= 2.4.x i2c protocol (1/1/2003)
13 * by Ronald Bultje <rbultje@ronald.bitfreak.net>
14 *
15 * Added saa7115 support by Kevin Thayer <nufan_wfk at yahoo.com>
16 * (2/17/2003)
17 *
18 * VBI support (2004) and cleanups (2005) by Hans Verkuil <hverkuil@xs4all.nl>
19 *
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation; either version 2
23 * of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
33 */
34
35
36#include <linux/kernel.h>
37#include <linux/module.h>
38#include <linux/slab.h>
39#include <linux/i2c.h>
40#include <linux/videodev2.h>
41#include <media/v4l2-common.h>
42
43MODULE_DESCRIPTION("Philips SAA7114/SAA7115 video decoder driver");
44MODULE_AUTHOR("Maxim Yevtyushkin, Kevin Thayer, Chris Kennedy, Hans Verkuil");
45MODULE_LICENSE("GPL");
46
47static int debug = 0;
48module_param(debug, int, 0644);
49
50MODULE_PARM_DESC(debug, "Debug level (0-1)");
51
52#define saa7115_dbg(fmt,arg...) \
53 do { \
54 if (debug) \
55 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
56 i2c_adapter_id(client->adapter), client->addr , ## arg); \
57 } while (0)
58
59#define saa7115_err(fmt, arg...) do { \
60 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \
61 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
62#define saa7115_info(fmt, arg...) do { \
63 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \
64 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
65
66static unsigned short normal_i2c[] = { 0x42 >> 1, 0x40 >> 1, I2C_CLIENT_END };
67
68
69I2C_CLIENT_INSMOD;
70
71struct saa7115_state {
72 v4l2_std_id std;
73 int input;
74 int enable;
75 int bright;
76 int contrast;
77 int hue;
78 int sat;
79 enum v4l2_chip_ident ident;
80 enum v4l2_audio_clock_freq audclk_freq;
81};
82
83/* ----------------------------------------------------------------------- */
84
85static inline int saa7115_write(struct i2c_client *client, u8 reg, u8 value)
86{
87 return i2c_smbus_write_byte_data(client, reg, value);
88}
89
90static int saa7115_writeregs(struct i2c_client *client, const unsigned char *regs)
91{
92 unsigned char reg, data;
93
94 while (*regs != 0x00) {
95 reg = *(regs++);
96 data = *(regs++);
97 if (saa7115_write(client, reg, data) < 0)
98 return -1;
99 }
100 return 0;
101}
102
103static inline int saa7115_read(struct i2c_client *client, u8 reg)
104{
105 return i2c_smbus_read_byte_data(client, reg);
106}
107
108/* ----------------------------------------------------------------------- */
109
110/* If a value differs from the Hauppauge driver values, then the comment starts with
111 'was 0xXX' to denote the Hauppauge value. Otherwise the value is identical to what the
112 Hauppauge driver sets. */
113
114static const unsigned char saa7115_init_auto_input[] = {
115 0x01, 0x48, /* white peak control disabled */
116 0x03, 0x20, /* was 0x30. 0x20: long vertical blanking */
117 0x04, 0x90, /* analog gain set to 0 */
118 0x05, 0x90, /* analog gain set to 0 */
119 0x06, 0xeb, /* horiz sync begin = -21 */
120 0x07, 0xe0, /* horiz sync stop = -17 */
121 0x0a, 0x80, /* was 0x88. decoder brightness, 0x80 is itu standard */
122 0x0b, 0x44, /* was 0x48. decoder contrast, 0x44 is itu standard */
123 0x0c, 0x40, /* was 0x47. decoder saturation, 0x40 is itu standard */
124 0x0d, 0x00, /* chrominance hue control */
125 0x0f, 0x00, /* chrominance gain control: use automicatic mode */
126 0x10, 0x06, /* chrominance/luminance control: active adaptive combfilter */
127 0x11, 0x00, /* delay control */
128 0x12, 0x9d, /* RTS0 output control: VGATE */
129 0x13, 0x80, /* X-port output control: ITU656 standard mode, RTCO output enable RTCE */
130 0x14, 0x00, /* analog/ADC/auto compatibility control */
131 0x18, 0x40, /* raw data gain 0x00 = nominal */
132 0x19, 0x80, /* raw data offset 0x80 = 0 LSB */
133 0x1a, 0x77, /* color killer level control 0x77 = recommended */
134 0x1b, 0x42, /* misc chroma control 0x42 = recommended */
135 0x1c, 0xa9, /* combfilter control 0xA9 = recommended */
136 0x1d, 0x01, /* combfilter control 0x01 = recommended */
137 0x88, 0xd0, /* reset device */
138 0x88, 0xf0, /* set device programmed, all in operational mode */
139 0x00, 0x00
140};
141
142static const unsigned char saa7115_cfg_reset_scaler[] = {
143 0x87, 0x00, /* disable I-port output */
144 0x88, 0xd0, /* reset scaler */
145 0x88, 0xf0, /* activate scaler */
146 0x87, 0x01, /* enable I-port output */
147 0x00, 0x00
148};
149
150/* ============== SAA7715 VIDEO templates ============= */
151
152static const unsigned char saa7115_cfg_60hz_fullres_x[] = {
153 0xcc, 0xd0, /* hsize low (output), hor. output window size = 0x2d0 = 720 */
154 0xcd, 0x02, /* hsize hi (output) */
155
156 /* Why not in 60hz-Land, too? */
157 0xd0, 0x01, /* downscale = 1 */
158 0xd8, 0x00, /* hor lum scaling 0x0400 = 1 */
159 0xd9, 0x04,
160 0xdc, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
161 0xdd, 0x02, /* H-scaling incr chroma */
162
163 0x00, 0x00
164};
165static const unsigned char saa7115_cfg_60hz_fullres_y[] = {
166 0xce, 0xf8, /* vsize low (output), ver. output window size = 248 (but 60hz is 240?) */
167 0xcf, 0x00, /* vsize hi (output) */
168
169 /* Why not in 60hz-Land, too? */
170 0xd5, 0x40, /* Lum contrast, nominal value = 0x40 */
171 0xd6, 0x40, /* Chroma satur. nominal value = 0x80 */
172
173 0xe0, 0x00, /* V-scaling incr luma low */
174 0xe1, 0x04, /* " hi */
175 0xe2, 0x00, /* V-scaling incr chroma low */
176 0xe3, 0x04, /* " hi */
177
178 0x00, 0x00
179};
180
181static const unsigned char saa7115_cfg_60hz_video[] = {
182 0x80, 0x00, /* reset tasks */
183 0x88, 0xd0, /* reset scaler */
184
185 0x15, 0x03, /* VGATE pulse start */
186 0x16, 0x11, /* VGATE pulse stop */
187 0x17, 0x9c, /* VGATE MSB and other values */
188
189 0x08, 0x68, /* 0xBO: auto detection, 0x68 = NTSC */
190 0x0e, 0x07, /* lots of different stuff... video autodetection is on */
191
192 0x5a, 0x06, /* Vertical offset, standard 60hz value for ITU656 line counting */
193
194 /* Task A */
195 0x90, 0x80, /* Task Handling Control */
196 0x91, 0x48, /* X-port formats/config */
197 0x92, 0x40, /* Input Ref. signal Def. */
198 0x93, 0x84, /* I-port config */
199 0x94, 0x01, /* hoffset low (input), 0x0002 is minimum */
200 0x95, 0x00, /* hoffset hi (input) */
201 0x96, 0xd0, /* hsize low (input), 0x02d0 = 720 */
202 0x97, 0x02, /* hsize hi (input) */
203 0x98, 0x05, /* voffset low (input) */
204 0x99, 0x00, /* voffset hi (input) */
205 0x9a, 0x0c, /* vsize low (input), 0x0c = 12 */
206 0x9b, 0x00, /* vsize hi (input) */
207 0x9c, 0xa0, /* hsize low (output), 0x05a0 = 1440 */
208 0x9d, 0x05, /* hsize hi (output) */
209 0x9e, 0x0c, /* vsize low (output), 0x0c = 12 */
210 0x9f, 0x00, /* vsize hi (output) */
211
212 /* Task B */
213 0xc0, 0x00, /* Task Handling Control */
214 0xc1, 0x08, /* X-port formats/config */
215 0xc2, 0x00, /* Input Ref. signal Def. */
216 0xc3, 0x80, /* I-port config */
217 0xc4, 0x02, /* hoffset low (input), 0x0002 is minimum */
218 0xc5, 0x00, /* hoffset hi (input) */
219 0xc6, 0xd0, /* hsize low (input), 0x02d0 = 720 */
220 0xc7, 0x02, /* hsize hi (input) */
221 0xc8, 0x12, /* voffset low (input), 0x12 = 18 */
222 0xc9, 0x00, /* voffset hi (input) */
223 0xca, 0xf8, /* vsize low (input), 0xf8 = 248 */
224 0xcb, 0x00, /* vsize hi (input) */
225 0xcc, 0xd0, /* hsize low (output), 0x02d0 = 720 */
226 0xcd, 0x02, /* hsize hi (output) */
227
228 0xf0, 0xad, /* Set PLL Register. 60hz 525 lines per frame, 27 MHz */
229 0xf1, 0x05, /* low bit with 0xF0 */
230 0xf5, 0xad, /* Set pulse generator register */
231 0xf6, 0x01,
232
233 0x87, 0x00, /* Disable I-port output */
234 0x88, 0xd0, /* reset scaler */
235 0x80, 0x20, /* Activate only task "B", continuous mode (was 0xA0) */
236 0x88, 0xf0, /* activate scaler */
237 0x87, 0x01, /* Enable I-port output */
238 0x00, 0x00
239};
240
241static const unsigned char saa7115_cfg_50hz_fullres_x[] = {
242 0xcc, 0xd0, /* hsize low (output), 720 same as 60hz */
243 0xcd, 0x02, /* hsize hi (output) */
244
245 0xd0, 0x01, /* down scale = 1 */
246 0xd8, 0x00, /* hor lum scaling 0x0400 = 1 */
247 0xd9, 0x04,
248 0xdc, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
249 0xdd, 0x02, /* H-scaling incr chroma */
250
251 0x00, 0x00
252};
253static const unsigned char saa7115_cfg_50hz_fullres_y[] = {
254 0xce, 0x20, /* vsize low (output), 0x0120 = 288 */
255 0xcf, 0x01, /* vsize hi (output) */
256
257 0xd5, 0x40, /* Lum contrast, nominal value = 0x40 */
258 0xd6, 0x40, /* Chroma satur. nominal value = 0x80 */
259
260 0xe0, 0x00, /* V-scaling incr luma low */
261 0xe1, 0x04, /* " hi */
262 0xe2, 0x00, /* V-scaling incr chroma low */
263 0xe3, 0x04, /* " hi */
264
265 0x00, 0x00
266};
267
268static const unsigned char saa7115_cfg_50hz_video[] = {
269 0x80, 0x00, /* reset tasks */
270 0x88, 0xd0, /* reset scaler */
271
272 0x15, 0x37, /* VGATE start */
273 0x16, 0x16, /* VGATE stop */
274 0x17, 0x99, /* VGATE MSB and other values */
275
276 0x08, 0x28, /* 0x28 = PAL */
277 0x0e, 0x07, /* chrominance control 1 */
278
279 0x5a, 0x03, /* Vertical offset, standard 50hz value */
280
281 /* Task A */
282 0x90, 0x81, /* Task Handling Control */
283 0x91, 0x48, /* X-port formats/config */
284 0x92, 0x40, /* Input Ref. signal Def. */
285 0x93, 0x84, /* I-port config */
286 /* This is weird: the datasheet says that you should use 2 as the minimum value, */
287 /* but Hauppauge uses 0, and changing that to 2 causes indeed problems (for 50hz) */
288 0x94, 0x00, /* hoffset low (input), 0x0002 is minimum */
289 0x95, 0x00, /* hoffset hi (input) */
290 0x96, 0xd0, /* hsize low (input), 0x02d0 = 720 */
291 0x97, 0x02, /* hsize hi (input) */
292 0x98, 0x03, /* voffset low (input) */
293 0x99, 0x00, /* voffset hi (input) */
294 0x9a, 0x12, /* vsize low (input), 0x12 = 18 */
295 0x9b, 0x00, /* vsize hi (input) */
296 0x9c, 0xa0, /* hsize low (output), 0x05a0 = 1440 */
297 0x9d, 0x05, /* hsize hi (output) */
298 0x9e, 0x12, /* vsize low (output), 0x12 = 18 */
299 0x9f, 0x00, /* vsize hi (output) */
300
301 /* Task B */
302 0xc0, 0x00, /* Task Handling Control */
303 0xc1, 0x08, /* X-port formats/config */
304 0xc2, 0x00, /* Input Ref. signal Def. */
305 0xc3, 0x80, /* I-port config */
306 0xc4, 0x00, /* hoffset low (input), 0x0002 is minimum. See comment at 0x94 above. */
307 0xc5, 0x00, /* hoffset hi (input) */
308 0xc6, 0xd0, /* hsize low (input), 0x02d0 = 720 */
309 0xc7, 0x02, /* hsize hi (input) */
310 0xc8, 0x16, /* voffset low (input), 0x16 = 22 */
311 0xc9, 0x00, /* voffset hi (input) */
312 0xca, 0x20, /* vsize low (input), 0x0120 = 288 */
313 0xcb, 0x01, /* vsize hi (input) */
314 0xcc, 0xd0, /* hsize low (output), 0x02d0 = 720 */
315 0xcd, 0x02, /* hsize hi (output) */
316 0xce, 0x20, /* vsize low (output), 0x0120 = 288 */
317 0xcf, 0x01, /* vsize hi (output) */
318
319 0xf0, 0xb0, /* Set PLL Register. 50hz 625 lines per frame, 27 MHz */
320 0xf1, 0x05, /* low bit with 0xF0, (was 0x05) */
321 0xf5, 0xb0, /* Set pulse generator register */
322 0xf6, 0x01,
323
324 0x87, 0x00, /* Disable I-port output */
325 0x88, 0xd0, /* reset scaler (was 0xD0) */
326 0x80, 0x20, /* Activate only task "B" */
327 0x88, 0xf0, /* activate scaler */
328 0x87, 0x01, /* Enable I-port output */
329 0x00, 0x00
330};
331
332/* ============== SAA7715 VIDEO templates (end) ======= */
333
334static const unsigned char saa7115_cfg_vbi_on[] = {
335 0x80, 0x00, /* reset tasks */
336 0x88, 0xd0, /* reset scaler */
337 0x80, 0x30, /* Activate both tasks */
338 0x88, 0xf0, /* activate scaler */
339 0x87, 0x01, /* Enable I-port output */
340 0x00, 0x00
341};
342
343static const unsigned char saa7115_cfg_vbi_off[] = {
344 0x80, 0x00, /* reset tasks */
345 0x88, 0xd0, /* reset scaler */
346 0x80, 0x20, /* Activate only task "B" */
347 0x88, 0xf0, /* activate scaler */
348 0x87, 0x01, /* Enable I-port output */
349 0x00, 0x00
350};
351
352static const unsigned char saa7115_init_misc[] = {
353 0x38, 0x03, /* audio stuff */
354 0x39, 0x10,
355 0x3a, 0x08,
356
357 0x81, 0x01, /* reg 0x15,0x16 define blanking window */
358 0x82, 0x00,
359 0x83, 0x01, /* I port settings */
360 0x84, 0x20,
361 0x85, 0x21,
362 0x86, 0xc5,
363 0x87, 0x01,
364
365 /* Task A */
366 0xa0, 0x01, /* down scale = 1 */
367 0xa1, 0x00, /* prescale accumulation length = 1 */
368 0xa2, 0x00, /* dc gain and fir prefilter control */
369 0xa4, 0x80, /* Lum Brightness, nominal value = 0x80 */
370 0xa5, 0x40, /* Lum contrast, nominal value = 0x40 */
371 0xa6, 0x40, /* Chroma satur. nominal value = 0x80 */
372 0xa8, 0x00, /* hor lum scaling 0x0200 = 2 zoom */
373 0xa9, 0x02, /* note: 2 x zoom ensures that VBI lines have same length as video lines. */
374 0xaa, 0x00, /* H-phase offset Luma = 0 */
375 0xac, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
376 0xad, 0x01, /* H-scaling incr chroma */
377 0xae, 0x00, /* H-phase offset chroma. must be offset luma / 2 */
378
379 0xb0, 0x00, /* V-scaling incr luma low */
380 0xb1, 0x04, /* " hi */
381 0xb2, 0x00, /* V-scaling incr chroma low */
382 0xb3, 0x04, /* " hi */
383 0xb4, 0x01, /* V-scaling mode control */
384 0xb8, 0x00, /* V-phase offset chroma 00 */
385 0xb9, 0x00, /* V-phase offset chroma 01 */
386 0xba, 0x00, /* V-phase offset chroma 10 */
387 0xbb, 0x00, /* V-phase offset chroma 11 */
388 0xbc, 0x00, /* V-phase offset luma 00 */
389 0xbd, 0x00, /* V-phase offset luma 01 */
390 0xbe, 0x00, /* V-phase offset luma 10 */
391 0xbf, 0x00, /* V-phase offset luma 11 */
392
393 /* Task B */
394 0xd0, 0x01, /* down scale = 1 */
395 0xd1, 0x00, /* prescale accumulation length = 1 */
396 0xd2, 0x00, /* dc gain and fir prefilter control */
397 0xd4, 0x80, /* Lum Brightness, nominal value = 0x80 */
398 0xd5, 0x40, /* Lum contrast, nominal value = 0x40 */
399 0xd6, 0x40, /* Chroma satur. nominal value = 0x80 */
400 0xd8, 0x00, /* hor lum scaling 0x0400 = 1 */
401 0xd9, 0x04,
402 0xda, 0x00, /* H-phase offset Luma = 0 */
403 0xdc, 0x00, /* hor chrom scaling 0x0200. must be hor lum scaling / 2 */
404 0xdd, 0x02, /* H-scaling incr chroma */
405 0xde, 0x00, /* H-phase offset chroma. must be offset luma / 2 */
406
407 0xe0, 0x00, /* V-scaling incr luma low */
408 0xe1, 0x04, /* " hi */
409 0xe2, 0x00, /* V-scaling incr chroma low */
410 0xe3, 0x04, /* " hi */
411 0xe4, 0x01, /* V-scaling mode control */
412 0xe8, 0x00, /* V-phase offset chroma 00 */
413 0xe9, 0x00, /* V-phase offset chroma 01 */
414 0xea, 0x00, /* V-phase offset chroma 10 */
415 0xeb, 0x00, /* V-phase offset chroma 11 */
416 0xec, 0x00, /* V-phase offset luma 00 */
417 0xed, 0x00, /* V-phase offset luma 01 */
418 0xee, 0x00, /* V-phase offset luma 10 */
419 0xef, 0x00, /* V-phase offset luma 11 */
420
421 0xf2, 0x50, /* crystal clock = 24.576 MHz, target = 27MHz */
422 0xf3, 0x46,
423 0xf4, 0x00,
424 0xf7, 0x4b, /* not the recommended settings! */
425 0xf8, 0x00,
426 0xf9, 0x4b,
427 0xfa, 0x00,
428 0xfb, 0x4b,
429 0xff, 0x88, /* PLL2 lock detection settings: 71 lines 50% phase error */
430
431 /* Turn off VBI */
432 0x40, 0x20, /* No framing code errors allowed. */
433 0x41, 0xff,
434 0x42, 0xff,
435 0x43, 0xff,
436 0x44, 0xff,
437 0x45, 0xff,
438 0x46, 0xff,
439 0x47, 0xff,
440 0x48, 0xff,
441 0x49, 0xff,
442 0x4a, 0xff,
443 0x4b, 0xff,
444 0x4c, 0xff,
445 0x4d, 0xff,
446 0x4e, 0xff,
447 0x4f, 0xff,
448 0x50, 0xff,
449 0x51, 0xff,
450 0x52, 0xff,
451 0x53, 0xff,
452 0x54, 0xff,
453 0x55, 0xff,
454 0x56, 0xff,
455 0x57, 0xff,
456 0x58, 0x40,
457 0x59, 0x47,
458 0x5b, 0x83,
459 0x5d, 0xbd,
460 0x5e, 0x35,
461
462 0x02, 0x84, /* input tuner -> input 4, amplifier active */
463 0x09, 0x53, /* 0x53, was 0x56 for 60hz. luminance control */
464
465 0x80, 0x20, /* enable task B */
466 0x88, 0xd0,
467 0x88, 0xf0,
468 0x00, 0x00
469};
470
471/* ============== SAA7715 AUDIO settings ============= */
472
473/* 48.0 kHz */
474static const unsigned char saa7115_cfg_48_audio[] = {
475 0x34, 0xce,
476 0x35, 0xfb,
477 0x36, 0x30,
478 0x00, 0x00
479};
480
481/* 44.1 kHz */
482static const unsigned char saa7115_cfg_441_audio[] = {
483 0x34, 0xf2,
484 0x35, 0x00,
485 0x36, 0x2d,
486 0x00, 0x00
487};
488
489/* 32.0 kHz */
490static const unsigned char saa7115_cfg_32_audio[] = {
491 0x34, 0xdf,
492 0x35, 0xa7,
493 0x36, 0x20,
494 0x00, 0x00
495};
496
497/* 48.0 kHz 60hz */
498static const unsigned char saa7115_cfg_60hz_48_audio[] = {
499 0x30, 0xcd,
500 0x31, 0x20,
501 0x32, 0x03,
502 0x00, 0x00
503};
504
505/* 48.0 kHz 50hz */
506static const unsigned char saa7115_cfg_50hz_48_audio[] = {
507 0x30, 0x00,
508 0x31, 0xc0,
509 0x32, 0x03,
510 0x00, 0x00
511};
512
513/* 44.1 kHz 60hz */
514static const unsigned char saa7115_cfg_60hz_441_audio[] = {
515 0x30, 0xbc,
516 0x31, 0xdf,
517 0x32, 0x02,
518 0x00, 0x00
519};
520
521/* 44.1 kHz 50hz */
522static const unsigned char saa7115_cfg_50hz_441_audio[] = {
523 0x30, 0x00,
524 0x31, 0x72,
525 0x32, 0x03,
526 0x00, 0x00
527};
528
529/* 32.0 kHz 60hz */
530static const unsigned char saa7115_cfg_60hz_32_audio[] = {
531 0x30, 0xde,
532 0x31, 0x15,
533 0x32, 0x02,
534 0x00, 0x00
535};
536
537/* 32.0 kHz 50hz */
538static const unsigned char saa7115_cfg_50hz_32_audio[] = {
539 0x30, 0x00,
540 0x31, 0x80,
541 0x32, 0x02,
542 0x00, 0x00
543};
544
545static int saa7115_odd_parity(u8 c)
546{
547 c ^= (c >> 4);
548 c ^= (c >> 2);
549 c ^= (c >> 1);
550
551 return c & 1;
552}
553
554static int saa7115_decode_vps(u8 * dst, u8 * p)
555{
556 static const u8 biphase_tbl[] = {
557 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
558 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
559 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
560 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
561 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
562 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
563 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
564 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
565 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
566 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
567 0xc3, 0x4b, 0x43, 0xc3, 0x87, 0x0f, 0x07, 0x87,
568 0x83, 0x0b, 0x03, 0x83, 0xc3, 0x4b, 0x43, 0xc3,
569 0xc1, 0x49, 0x41, 0xc1, 0x85, 0x0d, 0x05, 0x85,
570 0x81, 0x09, 0x01, 0x81, 0xc1, 0x49, 0x41, 0xc1,
571 0xe1, 0x69, 0x61, 0xe1, 0xa5, 0x2d, 0x25, 0xa5,
572 0xa1, 0x29, 0x21, 0xa1, 0xe1, 0x69, 0x61, 0xe1,
573 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
574 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
575 0xc2, 0x4a, 0x42, 0xc2, 0x86, 0x0e, 0x06, 0x86,
576 0x82, 0x0a, 0x02, 0x82, 0xc2, 0x4a, 0x42, 0xc2,
577 0xc0, 0x48, 0x40, 0xc0, 0x84, 0x0c, 0x04, 0x84,
578 0x80, 0x08, 0x00, 0x80, 0xc0, 0x48, 0x40, 0xc0,
579 0xe0, 0x68, 0x60, 0xe0, 0xa4, 0x2c, 0x24, 0xa4,
580 0xa0, 0x28, 0x20, 0xa0, 0xe0, 0x68, 0x60, 0xe0,
581 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
582 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
583 0xd2, 0x5a, 0x52, 0xd2, 0x96, 0x1e, 0x16, 0x96,
584 0x92, 0x1a, 0x12, 0x92, 0xd2, 0x5a, 0x52, 0xd2,
585 0xd0, 0x58, 0x50, 0xd0, 0x94, 0x1c, 0x14, 0x94,
586 0x90, 0x18, 0x10, 0x90, 0xd0, 0x58, 0x50, 0xd0,
587 0xf0, 0x78, 0x70, 0xf0, 0xb4, 0x3c, 0x34, 0xb4,
588 0xb0, 0x38, 0x30, 0xb0, 0xf0, 0x78, 0x70, 0xf0,
589 };
590 int i;
591 u8 c, err = 0;
592
593 for (i = 0; i < 2 * 13; i += 2) {
594 err |= biphase_tbl[p[i]] | biphase_tbl[p[i + 1]];
595 c = (biphase_tbl[p[i + 1]] & 0xf) | ((biphase_tbl[p[i]] & 0xf) << 4);
596 dst[i / 2] = c;
597 }
598 return err & 0xf0;
599}
600
601static int saa7115_decode_wss(u8 * p)
602{
603 static const int wss_bits[8] = {
604 0, 0, 0, 1, 0, 1, 1, 1
605 };
606 unsigned char parity;
607 int wss = 0;
608 int i;
609
610 for (i = 0; i < 16; i++) {
611 int b1 = wss_bits[p[i] & 7];
612 int b2 = wss_bits[(p[i] >> 3) & 7];
613
614 if (b1 == b2)
615 return -1;
616 wss |= b2 << i;
617 }
618 parity = wss & 15;
619 parity ^= parity >> 2;
620 parity ^= parity >> 1;
621
622 if (!(parity & 1))
623 return -1;
624
625 return wss;
626}
627
628
629static int saa7115_set_audio_clock_freq(struct i2c_client *client, enum v4l2_audio_clock_freq freq)
630{
631 struct saa7115_state *state = i2c_get_clientdata(client);
632
633 saa7115_dbg("set audio clock freq: %d\n", freq);
634 switch (freq) {
635 case V4L2_AUDCLK_32_KHZ:
636 saa7115_writeregs(client, saa7115_cfg_32_audio);
637 if (state->std & V4L2_STD_525_60) {
638 saa7115_writeregs(client, saa7115_cfg_60hz_32_audio);
639 } else {
640 saa7115_writeregs(client, saa7115_cfg_50hz_32_audio);
641 }
642 break;
643 case V4L2_AUDCLK_441_KHZ:
644 saa7115_writeregs(client, saa7115_cfg_441_audio);
645 if (state->std & V4L2_STD_525_60) {
646 saa7115_writeregs(client, saa7115_cfg_60hz_441_audio);
647 } else {
648 saa7115_writeregs(client, saa7115_cfg_50hz_441_audio);
649 }
650 break;
651 case V4L2_AUDCLK_48_KHZ:
652 saa7115_writeregs(client, saa7115_cfg_48_audio);
653 if (state->std & V4L2_STD_525_60) {
654 saa7115_writeregs(client, saa7115_cfg_60hz_48_audio);
655 } else {
656 saa7115_writeregs(client, saa7115_cfg_50hz_48_audio);
657 }
658 break;
659 default:
660 saa7115_dbg("invalid audio setting %d\n", freq);
661 return -EINVAL;
662 }
663 state->audclk_freq = freq;
664 return 0;
665}
666
667static int saa7115_set_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
668{
669 struct saa7115_state *state = i2c_get_clientdata(client);
670
671 switch (ctrl->id) {
672 case V4L2_CID_BRIGHTNESS:
673 if (ctrl->value < 0 || ctrl->value > 255) {
674 saa7115_err("invalid brightness setting %d\n", ctrl->value);
675 return -ERANGE;
676 }
677
678 state->bright = ctrl->value;
679 saa7115_write(client, 0x0a, state->bright);
680 break;
681
682 case V4L2_CID_CONTRAST:
683 if (ctrl->value < 0 || ctrl->value > 127) {
684 saa7115_err("invalid contrast setting %d\n", ctrl->value);
685 return -ERANGE;
686 }
687
688 state->contrast = ctrl->value;
689 saa7115_write(client, 0x0b, state->contrast);
690 break;
691
692 case V4L2_CID_SATURATION:
693 if (ctrl->value < 0 || ctrl->value > 127) {
694 saa7115_err("invalid saturation setting %d\n", ctrl->value);
695 return -ERANGE;
696 }
697
698 state->sat = ctrl->value;
699 saa7115_write(client, 0x0c, state->sat);
700 break;
701
702 case V4L2_CID_HUE:
703 if (ctrl->value < -127 || ctrl->value > 127) {
704 saa7115_err("invalid hue setting %d\n", ctrl->value);
705 return -ERANGE;
706 }
707
708 state->hue = ctrl->value;
709 saa7115_write(client, 0x0d, state->hue);
710 break;
711 }
712
713 return 0;
714}
715
716static int saa7115_get_v4lctrl(struct i2c_client *client, struct v4l2_control *ctrl)
717{
718 struct saa7115_state *state = i2c_get_clientdata(client);
719
720 switch (ctrl->id) {
721 case V4L2_CID_BRIGHTNESS:
722 ctrl->value = state->bright;
723 break;
724 case V4L2_CID_CONTRAST:
725 ctrl->value = state->contrast;
726 break;
727 case V4L2_CID_SATURATION:
728 ctrl->value = state->sat;
729 break;
730 case V4L2_CID_HUE:
731 ctrl->value = state->hue;
732 break;
733 default:
734 return -EINVAL;
735 }
736
737 return 0;
738}
739
740static void saa7115_set_v4lstd(struct i2c_client *client, v4l2_std_id std)
741{
742 struct saa7115_state *state = i2c_get_clientdata(client);
743 int taskb = saa7115_read(client, 0x80) & 0x10;
744
745 // This works for NTSC-M, SECAM-L and the 50Hz PAL variants.
746 if (std & V4L2_STD_525_60) {
747 saa7115_dbg("decoder set standard 60 Hz\n");
748 saa7115_writeregs(client, saa7115_cfg_60hz_video);
749 } else {
750 saa7115_dbg("decoder set standard 50 Hz\n");
751 saa7115_writeregs(client, saa7115_cfg_50hz_video);
752 }
753
754 state->std = std;
755
756 /* restart task B if needed */
757 if (taskb && state->ident == V4L2_IDENT_SAA7114) {
758 saa7115_writeregs(client, saa7115_cfg_vbi_on);
759 }
760
761 /* switch audio mode too! */
762 saa7115_set_audio_clock_freq(client, state->audclk_freq);
763}
764
765static v4l2_std_id saa7115_get_v4lstd(struct i2c_client *client)
766{
767 struct saa7115_state *state = i2c_get_clientdata(client);
768
769 return state->std;
770}
771
772static void saa7115_log_status(struct i2c_client *client)
773{
774 struct saa7115_state *state = i2c_get_clientdata(client);
775 char *audfreq = "undefined";
776 int reg1e, reg1f;
777 int signalOk;
778 int vcr;
779
780 switch (state->audclk_freq) {
781 case V4L2_AUDCLK_32_KHZ: audfreq = "32 kHz"; break;
782 case V4L2_AUDCLK_441_KHZ: audfreq = "44.1 kHz"; break;
783 case V4L2_AUDCLK_48_KHZ: audfreq = "48 kHz"; break;
784 }
785
786 saa7115_info("Audio frequency: %s\n", audfreq);
787 if (client->name[6] == '4') {
788 /* status for the saa7114 */
789 reg1f = saa7115_read(client, 0x1f);
790 signalOk = (reg1f & 0xc1) == 0x81;
791 saa7115_info("Video signal: %s\n", signalOk ? "ok" : "bad");
792 saa7115_info("Frequency: %s\n", (reg1f & 0x20) ? "60Hz" : "50Hz");
793 return;
794 }
795
796 /* status for the saa7115 */
797 reg1e = saa7115_read(client, 0x1e);
798 reg1f = saa7115_read(client, 0x1f);
799
800 signalOk = (reg1f & 0xc1) == 0x81 && (reg1e & 0xc0) == 0x80;
801 vcr = !(reg1f & 0x10);
802
803 saa7115_info("Video signal: %s\n", signalOk ? (vcr ? "VCR" : "broadcast/DVD") : "bad");
804 saa7115_info("Frequency: %s\n", (reg1f & 0x20) ? "60Hz" : "50Hz");
805
806 switch (reg1e & 0x03) {
807 case 1:
808 saa7115_info("Detected format: NTSC\n");
809 break;
810 case 2:
811 saa7115_info("Detected format: PAL\n");
812 break;
813 case 3:
814 saa7115_info("Detected format: SECAM\n");
815 break;
816 default:
817 saa7115_info("Detected format: BW/No color\n");
818 break;
819 }
820}
821
822/* setup the sliced VBI lcr registers according to the sliced VBI format */
823static void saa7115_set_lcr(struct i2c_client *client, struct v4l2_sliced_vbi_format *fmt)
824{
825 struct saa7115_state *state = i2c_get_clientdata(client);
826 int is_50hz = (state->std & V4L2_STD_625_50);
827 u8 lcr[24];
828 int i, x;
829
830 /* saa7114 doesn't yet support VBI */
831 if (state->ident == V4L2_IDENT_SAA7114)
832 return;
833
834 for (i = 0; i <= 23; i++)
835 lcr[i] = 0xff;
836
837 if (fmt->service_set == 0) {
838 /* raw VBI */
839 if (is_50hz)
840 for (i = 6; i <= 23; i++)
841 lcr[i] = 0xdd;
842 else
843 for (i = 10; i <= 21; i++)
844 lcr[i] = 0xdd;
845 } else {
846 /* sliced VBI */
847 /* first clear lines that cannot be captured */
848 if (is_50hz) {
849 for (i = 0; i <= 5; i++)
850 fmt->service_lines[0][i] =
851 fmt->service_lines[1][i] = 0;
852 }
853 else {
854 for (i = 0; i <= 9; i++)
855 fmt->service_lines[0][i] =
856 fmt->service_lines[1][i] = 0;
857 for (i = 22; i <= 23; i++)
858 fmt->service_lines[0][i] =
859 fmt->service_lines[1][i] = 0;
860 }
861
862 /* Now set the lcr values according to the specified service */
863 for (i = 6; i <= 23; i++) {
864 lcr[i] = 0;
865 for (x = 0; x <= 1; x++) {
866 switch (fmt->service_lines[1-x][i]) {
867 case 0:
868 lcr[i] |= 0xf << (4 * x);
869 break;
870 case V4L2_SLICED_TELETEXT_B:
871 lcr[i] |= 1 << (4 * x);
872 break;
873 case V4L2_SLICED_CAPTION_525:
874 lcr[i] |= 4 << (4 * x);
875 break;
876 case V4L2_SLICED_WSS_625:
877 lcr[i] |= 5 << (4 * x);
878 break;
879 case V4L2_SLICED_VPS:
880 lcr[i] |= 7 << (4 * x);
881 break;
882 }
883 }
884 }
885 }
886
887 /* write the lcr registers */
888 for (i = 2; i <= 23; i++) {
889 saa7115_write(client, i - 2 + 0x41, lcr[i]);
890 }
891
892 /* enable/disable raw VBI capturing */
893 saa7115_writeregs(client, fmt->service_set == 0 ? saa7115_cfg_vbi_on : saa7115_cfg_vbi_off);
894}
895
896static int saa7115_get_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
897{
898 static u16 lcr2vbi[] = {
899 0, V4L2_SLICED_TELETEXT_B, 0, /* 1 */
900 0, V4L2_SLICED_CAPTION_525, /* 4 */
901 V4L2_SLICED_WSS_625, 0, /* 5 */
902 V4L2_SLICED_VPS, 0, 0, 0, 0, /* 7 */
903 0, 0, 0, 0
904 };
905 struct v4l2_sliced_vbi_format *sliced = &fmt->fmt.sliced;
906 int i;
907
908 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
909 return -EINVAL;
910 memset(sliced, 0, sizeof(*sliced));
911 /* done if using raw VBI */
912 if (saa7115_read(client, 0x80) & 0x10)
913 return 0;
914 for (i = 2; i <= 23; i++) {
915 u8 v = saa7115_read(client, i - 2 + 0x41);
916
917 sliced->service_lines[0][i] = lcr2vbi[v >> 4];
918 sliced->service_lines[1][i] = lcr2vbi[v & 0xf];
919 sliced->service_set |=
920 sliced->service_lines[0][i] | sliced->service_lines[1][i];
921 }
922 return 0;
923}
924
925static int saa7115_set_v4lfmt(struct i2c_client *client, struct v4l2_format *fmt)
926{
927 struct saa7115_state *state = i2c_get_clientdata(client);
928 struct v4l2_pix_format *pix;
929 int HPSC, HFSC;
930 int VSCY, Vsrc;
931 int is_50hz = state->std & V4L2_STD_625_50;
932
933 if (fmt->type == V4L2_BUF_TYPE_SLICED_VBI_CAPTURE) {
934 saa7115_set_lcr(client, &fmt->fmt.sliced);
935 return 0;
936 }
937 if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
938 return -EINVAL;
939
940 pix = &(fmt->fmt.pix);
941
942 saa7115_dbg("decoder set size\n");
943
944 /* FIXME need better bounds checking here */
945 if ((pix->width < 1) || (pix->width > 1440))
946 return -EINVAL;
947 if ((pix->height < 1) || (pix->height > 960))
948 return -EINVAL;
949
950 /* probably have a valid size, let's set it */
951 /* Set output width/height */
952 /* width */
953 saa7115_write(client, 0xcc, (u8) (pix->width & 0xff));
954 saa7115_write(client, 0xcd, (u8) ((pix->width >> 8) & 0xff));
955 /* height */
956 saa7115_write(client, 0xce, (u8) (pix->height & 0xff));
957 saa7115_write(client, 0xcf, (u8) ((pix->height >> 8) & 0xff));
958
959 /* Scaling settings */
960 /* Hprescaler is floor(inres/outres) */
961 /* FIXME hardcoding input res */
962 if (pix->width != 720) {
963 HPSC = (int)(720 / pix->width);
964 /* 0 is not allowed (div. by zero) */
965 HPSC = HPSC ? HPSC : 1;
966 HFSC = (int)((1024 * 720) / (HPSC * pix->width));
967
968 saa7115_dbg("Hpsc: 0x%05x, Hfsc: 0x%05x\n", HPSC, HFSC);
969 /* FIXME hardcodes to "Task B"
970 * write H prescaler integer */
971 saa7115_write(client, 0xd0, (u8) (HPSC & 0x3f));
972
973 /* write H fine-scaling (luminance) */
974 saa7115_write(client, 0xd8, (u8) (HFSC & 0xff));
975 saa7115_write(client, 0xd9, (u8) ((HFSC >> 8) & 0xff));
976 /* write H fine-scaling (chrominance)
977 * must be lum/2, so i'll just bitshift :) */
978 saa7115_write(client, 0xDC, (u8) ((HFSC >> 1) & 0xff));
979 saa7115_write(client, 0xDD, (u8) ((HFSC >> 9) & 0xff));
980 } else {
981 if (is_50hz) {
982 saa7115_dbg("Setting full 50hz width\n");
983 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_x);
984 } else {
985 saa7115_dbg("Setting full 60hz width\n");
986 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
987 }
988 }
989
990 Vsrc = is_50hz ? 576 : 480;
991
992 if (pix->height != Vsrc) {
993 VSCY = (int)((1024 * Vsrc) / pix->height);
994 saa7115_dbg("Vsrc: %d, Vscy: 0x%05x\n", Vsrc, VSCY);
995
996 /* Correct Contrast and Luminance */
997 saa7115_write(client, 0xd5, (u8) (64 * 1024 / VSCY));
998 saa7115_write(client, 0xd6, (u8) (64 * 1024 / VSCY));
999
1000 /* write V fine-scaling (luminance) */
1001 saa7115_write(client, 0xe0, (u8) (VSCY & 0xff));
1002 saa7115_write(client, 0xe1, (u8) ((VSCY >> 8) & 0xff));
1003 /* write V fine-scaling (chrominance) */
1004 saa7115_write(client, 0xe2, (u8) (VSCY & 0xff));
1005 saa7115_write(client, 0xe3, (u8) ((VSCY >> 8) & 0xff));
1006 } else {
1007 if (is_50hz) {
1008 saa7115_dbg("Setting full 50Hz height\n");
1009 saa7115_writeregs(client, saa7115_cfg_50hz_fullres_y);
1010 } else {
1011 saa7115_dbg("Setting full 60hz height\n");
1012 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
1013 }
1014 }
1015
1016 saa7115_writeregs(client, saa7115_cfg_reset_scaler);
1017 return 0;
1018}
1019
1020/* Decode the sliced VBI data stream as created by the saa7115.
1021 The format is described in the saa7115 datasheet in Tables 25 and 26
1022 and in Figure 33.
1023 The current implementation uses SAV/EAV codes and not the ancillary data
1024 headers. The vbi->p pointer points to the SDID byte right after the SAV
1025 code. */
1026static void saa7115_decode_vbi_line(struct i2c_client *client,
1027 struct v4l2_decode_vbi_line *vbi)
1028{
1029 static const char vbi_no_data_pattern[] = {
1030 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0, 0xa0
1031 };
1032 struct saa7115_state *state = i2c_get_clientdata(client);
1033 u8 *p = vbi->p;
1034 u32 wss;
1035 int id1, id2; /* the ID1 and ID2 bytes from the internal header */
1036
1037 vbi->type = 0; /* mark result as a failure */
1038 id1 = p[2];
1039 id2 = p[3];
1040 /* Note: the field bit is inverted for 60 Hz video */
1041 if (state->std & V4L2_STD_525_60)
1042 id1 ^= 0x40;
1043
1044 /* Skip internal header, p now points to the start of the payload */
1045 p += 4;
1046 vbi->p = p;
1047
1048 /* calculate field and line number of the VBI packet (1-23) */
1049 vbi->is_second_field = ((id1 & 0x40) != 0);
1050 vbi->line = (id1 & 0x3f) << 3;
1051 vbi->line |= (id2 & 0x70) >> 4;
1052
1053 /* Obtain data type */
1054 id2 &= 0xf;
1055
1056 /* If the VBI slicer does not detect any signal it will fill up
1057 the payload buffer with 0xa0 bytes. */
1058 if (!memcmp(p, vbi_no_data_pattern, sizeof(vbi_no_data_pattern)))
1059 return;
1060
1061 /* decode payloads */
1062 switch (id2) {
1063 case 1:
1064 vbi->type = V4L2_SLICED_TELETEXT_B;
1065 break;
1066 case 4:
1067 if (!saa7115_odd_parity(p[0]) || !saa7115_odd_parity(p[1]))
1068 return;
1069 vbi->type = V4L2_SLICED_CAPTION_525;
1070 break;
1071 case 5:
1072 wss = saa7115_decode_wss(p);
1073 if (wss == -1)
1074 return;
1075 p[0] = wss & 0xff;
1076 p[1] = wss >> 8;
1077 vbi->type = V4L2_SLICED_WSS_625;
1078 break;
1079 case 7:
1080 if (saa7115_decode_vps(p, p) != 0)
1081 return;
1082 vbi->type = V4L2_SLICED_VPS;
1083 break;
1084 default:
1085 return;
1086 }
1087}
1088
1089/* ============ SAA7115 AUDIO settings (end) ============= */
1090
1091static int saa7115_command(struct i2c_client *client, unsigned int cmd, void *arg)
1092{
1093 struct saa7115_state *state = i2c_get_clientdata(client);
1094 int *iarg = arg;
1095
1096 /* ioctls to allow direct access to the saa7115 registers for testing */
1097 switch (cmd) {
1098 case VIDIOC_S_FMT:
1099 return saa7115_set_v4lfmt(client, (struct v4l2_format *)arg);
1100
1101 case VIDIOC_G_FMT:
1102 return saa7115_get_v4lfmt(client, (struct v4l2_format *)arg);
1103
1104 case VIDIOC_INT_AUDIO_CLOCK_FREQ:
1105 return saa7115_set_audio_clock_freq(client, *(enum v4l2_audio_clock_freq *)arg);
1106
1107 case VIDIOC_G_TUNER:
1108 {
1109 struct v4l2_tuner *vt = arg;
1110 int status;
1111
1112 status = saa7115_read(client, 0x1f);
1113
1114 saa7115_dbg("status: 0x%02x\n", status);
1115 vt->signal = ((status & (1 << 6)) == 0) ? 0xffff : 0x0;
1116 break;
1117 }
1118
1119 case VIDIOC_LOG_STATUS:
1120 saa7115_log_status(client);
1121 break;
1122
1123 case VIDIOC_G_CTRL:
1124 return saa7115_get_v4lctrl(client, (struct v4l2_control *)arg);
1125
1126 case VIDIOC_S_CTRL:
1127 return saa7115_set_v4lctrl(client, (struct v4l2_control *)arg);
1128
1129 case VIDIOC_G_STD:
1130 *(v4l2_std_id *)arg = saa7115_get_v4lstd(client);
1131 break;
1132
1133 case VIDIOC_S_STD:
1134 saa7115_set_v4lstd(client, *(v4l2_std_id *)arg);
1135 break;
1136
1137 case VIDIOC_G_INPUT:
1138 *(int *)arg = state->input;
1139 break;
1140
1141 case VIDIOC_S_INPUT:
1142 saa7115_dbg("decoder set input %d\n", *iarg);
1143 /* inputs from 0-9 are available */
1144 if (*iarg < 0 || *iarg > 9) {
1145 return -EINVAL;
1146 }
1147
1148 if (state->input == *iarg)
1149 break;
1150 saa7115_dbg("now setting %s input\n",
1151 *iarg >= 6 ? "S-Video" : "Composite");
1152 state->input = *iarg;
1153
1154 /* select mode */
1155 saa7115_write(client, 0x02,
1156 (saa7115_read(client, 0x02) & 0xf0) |
1157 state->input);
1158
1159 /* bypass chrominance trap for modes 6..9 */
1160 saa7115_write(client, 0x09,
1161 (saa7115_read(client, 0x09) & 0x7f) |
1162 (state->input < 6 ? 0x0 : 0x80));
1163 break;
1164
1165 case VIDIOC_STREAMON:
1166 case VIDIOC_STREAMOFF:
1167 saa7115_dbg("%s output\n",
1168 (cmd == VIDIOC_STREAMON) ? "enable" : "disable");
1169
1170 if (state->enable != (cmd == VIDIOC_STREAMON)) {
1171 state->enable = (cmd == VIDIOC_STREAMON);
1172 saa7115_write(client, 0x87, state->enable);
1173 }
1174 break;
1175
1176 case VIDIOC_INT_DECODE_VBI_LINE:
1177 saa7115_decode_vbi_line(client, arg);
1178 break;
1179
1180 case VIDIOC_INT_RESET:
1181 saa7115_dbg("decoder RESET\n");
1182 saa7115_writeregs(client, saa7115_cfg_reset_scaler);
1183 break;
1184
1185 case VIDIOC_INT_G_VBI_DATA:
1186 {
1187 struct v4l2_sliced_vbi_data *data = arg;
1188
1189 switch (data->id) {
1190 case V4L2_SLICED_WSS_625:
1191 if (saa7115_read(client, 0x6b) & 0xc0)
1192 return -EIO;
1193 data->data[0] = saa7115_read(client, 0x6c);
1194 data->data[1] = saa7115_read(client, 0x6d);
1195 return 0;
1196 case V4L2_SLICED_CAPTION_525:
1197 if (data->field == 0) {
1198 /* CC */
1199 if (saa7115_read(client, 0x66) & 0xc0)
1200 return -EIO;
1201 data->data[0] = saa7115_read(client, 0x67);
1202 data->data[1] = saa7115_read(client, 0x68);
1203 return 0;
1204 }
1205 /* XDS */
1206 if (saa7115_read(client, 0x66) & 0x30)
1207 return -EIO;
1208 data->data[0] = saa7115_read(client, 0x69);
1209 data->data[1] = saa7115_read(client, 0x6a);
1210 return 0;
1211 default:
1212 return -EINVAL;
1213 }
1214 break;
1215 }
1216
1217#ifdef CONFIG_VIDEO_ADV_DEBUG
1218 case VIDIOC_INT_G_REGISTER:
1219 {
1220 struct v4l2_register *reg = arg;
1221
1222 if (reg->i2c_id != I2C_DRIVERID_SAA711X)
1223 return -EINVAL;
1224 reg->val = saa7115_read(client, reg->reg & 0xff);
1225 break;
1226 }
1227
1228 case VIDIOC_INT_S_REGISTER:
1229 {
1230 struct v4l2_register *reg = arg;
1231
1232 if (reg->i2c_id != I2C_DRIVERID_SAA711X)
1233 return -EINVAL;
1234 if (!capable(CAP_SYS_ADMIN))
1235 return -EPERM;
1236 saa7115_write(client, reg->reg & 0xff, reg->val & 0xff);
1237 break;
1238 }
1239#endif
1240
1241 case VIDIOC_INT_G_CHIP_IDENT:
1242 *iarg = state->ident;
1243 break;
1244
1245 default:
1246 return -EINVAL;
1247 }
1248
1249 return 0;
1250}
1251
1252/* ----------------------------------------------------------------------- */
1253
1254static struct i2c_driver i2c_driver_saa7115;
1255
1256static int saa7115_attach(struct i2c_adapter *adapter, int address, int kind)
1257{
1258 struct i2c_client *client;
1259 struct saa7115_state *state;
1260 u8 chip_id;
1261
1262 /* Check if the adapter supports the needed features */
1263 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
1264 return 0;
1265
1266 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
1267 if (client == 0)
1268 return -ENOMEM;
1269 memset(client, 0, sizeof(struct i2c_client));
1270 client->addr = address;
1271 client->adapter = adapter;
1272 client->driver = &i2c_driver_saa7115;
1273 client->flags = I2C_CLIENT_ALLOW_USE;
1274 snprintf(client->name, sizeof(client->name) - 1, "saa7115");
1275
1276 saa7115_dbg("detecting saa7115 client on address 0x%x\n", address << 1);
1277
1278 saa7115_write(client, 0, 5);
1279 chip_id = saa7115_read(client, 0) & 0x0f;
1280 if (chip_id != 4 && chip_id != 5) {
1281 saa7115_dbg("saa7115 not found\n");
1282 kfree(client);
1283 return 0;
1284 }
1285 if (chip_id == 4) {
1286 snprintf(client->name, sizeof(client->name) - 1, "saa7114");
1287 }
1288 saa7115_info("saa711%d found @ 0x%x (%s)\n", chip_id, address << 1, adapter->name);
1289
1290 state = kmalloc(sizeof(struct saa7115_state), GFP_KERNEL);
1291 i2c_set_clientdata(client, state);
1292 if (state == NULL) {
1293 kfree(client);
1294 return -ENOMEM;
1295 }
1296 memset(state, 0, sizeof(struct saa7115_state));
1297 state->std = V4L2_STD_NTSC;
1298 state->input = -1;
1299 state->enable = 1;
1300 state->bright = 128;
1301 state->contrast = 64;
1302 state->hue = 0;
1303 state->sat = 64;
1304 state->ident = (chip_id == 4) ? V4L2_IDENT_SAA7114 : V4L2_IDENT_SAA7115;
1305 state->audclk_freq = V4L2_AUDCLK_48_KHZ;
1306
1307 saa7115_dbg("writing init values\n");
1308
1309 /* init to 60hz/48khz */
1310 saa7115_writeregs(client, saa7115_init_auto_input);
1311 saa7115_writeregs(client, saa7115_init_misc);
1312 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_x);
1313 saa7115_writeregs(client, saa7115_cfg_60hz_fullres_y);
1314 saa7115_writeregs(client, saa7115_cfg_60hz_video);
1315 saa7115_writeregs(client, saa7115_cfg_48_audio);
1316 saa7115_writeregs(client, saa7115_cfg_60hz_48_audio);
1317 saa7115_writeregs(client, saa7115_cfg_reset_scaler);
1318
1319 i2c_attach_client(client);
1320
1321 saa7115_dbg("status: (1E) 0x%02x, (1F) 0x%02x\n",
1322 saa7115_read(client, 0x1e), saa7115_read(client, 0x1f));
1323
1324 return 0;
1325}
1326
1327static int saa7115_probe(struct i2c_adapter *adapter)
1328{
1329#ifdef I2C_CLASS_TV_ANALOG
1330 if (adapter->class & I2C_CLASS_TV_ANALOG)
1331#else
1332 if (adapter->id == I2C_HW_B_BT848)
1333#endif
1334 return i2c_probe(adapter, &addr_data, &saa7115_attach);
1335 return 0;
1336}
1337
1338static int saa7115_detach(struct i2c_client *client)
1339{
1340 struct saa7115_state *state = i2c_get_clientdata(client);
1341 int err;
1342
1343 err = i2c_detach_client(client);
1344 if (err) {
1345 return err;
1346 }
1347
1348 kfree(state);
1349 kfree(client);
1350 return 0;
1351}
1352
1353/* ----------------------------------------------------------------------- */
1354
1355/* i2c implementation */
1356static struct i2c_driver i2c_driver_saa7115 = {
1357 .name = "saa7115",
1358 .id = I2C_DRIVERID_SAA711X,
1359 .flags = I2C_DF_NOTIFY,
1360 .attach_adapter = saa7115_probe,
1361 .detach_client = saa7115_detach,
1362 .command = saa7115_command,
1363 .owner = THIS_MODULE,
1364};
1365
1366
1367static int __init saa7115_init_module(void)
1368{
1369 return i2c_add_driver(&i2c_driver_saa7115);
1370}
1371
1372static void __exit saa7115_cleanup_module(void)
1373{
1374 i2c_del_driver(&i2c_driver_saa7115);
1375}
1376
1377module_init(saa7115_init_module);
1378module_exit(saa7115_cleanup_module);
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index 9aa8827de2c3..31f7b950b01c 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -36,7 +36,6 @@
36#include <asm/pgtable.h> 36#include <asm/pgtable.h>
37#include <asm/page.h> 37#include <asm/page.h>
38#include <linux/sched.h> 38#include <linux/sched.h>
39#include <asm/segment.h>
40#include <linux/types.h> 39#include <linux/types.h>
41#include <asm/uaccess.h> 40#include <asm/uaccess.h>
42#include <linux/videodev.h> 41#include <linux/videodev.h>
@@ -60,7 +59,7 @@ MODULE_PARM_DESC(debug, " Set the default Debug level. Default: 0 (Off) - (0-1)
60#define dprintk(num, format, args...) \ 59#define dprintk(num, format, args...) \
61 do { \ 60 do { \
62 if (debug >= num) \ 61 if (debug >= num) \
63 printk(format , ##args); \ 62 printk(format, ##args); \
64 } while (0) 63 } while (0)
65 64
66/* ----------------------------------------------------------------------- */ 65/* ----------------------------------------------------------------------- */
@@ -324,7 +323,7 @@ saa711x_command (struct i2c_client *client,
324 323
325 case VIDEO_MODE_SECAM: 324 case VIDEO_MODE_SECAM:
326 saa711x_write(client, 0x08, 325 saa711x_write(client, 0x08,
327 (decoder->reg[0x0e] & 0x3f) | 0x00); 326 (decoder->reg[0x08] & 0x3f) | 0x00);
328 saa711x_write(client, 0x0e, 327 saa711x_write(client, 0x0e,
329 (decoder->reg[0x0e] & 0x8f) | 0x50); 328 (decoder->reg[0x0e] & 0x8f) | 0x50);
330 break; 329 break;
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
new file mode 100644
index 000000000000..c36f014f1fdf
--- /dev/null
+++ b/drivers/media/video/saa7127.c
@@ -0,0 +1,849 @@
1/*
2 * saa7127 - Philips SAA7127/SAA7129 video encoder driver
3 *
4 * Copyright (C) 2003 Roy Bulter <rbulter@hetnet.nl>
5 *
6 * Based on SAA7126 video encoder driver by Gillem & Andreas Oberritter
7 *
8 * Copyright (C) 2000-2001 Gillem <htoa@gmx.net>
9 * Copyright (C) 2002 Andreas Oberritter <obi@saftware.de>
10 *
11 * Based on Stadis 4:2:2 MPEG-2 Decoder Driver by Nathan Laredo
12 *
13 * Copyright (C) 1999 Nathan Laredo <laredo@gnu.org>
14 *
15 * This driver is designed for the Hauppauge 250/350 Linux driver
16 * from the ivtv Project
17 *
18 * Copyright (C) 2003 Kevin Thayer <nufan_wfk@yahoo.com>
19 *
20 * Dual output support:
21 * Copyright (C) 2004 Eric Varsanyi
22 *
23 * NTSC Tuning and 7.5 IRE Setup
24 * Copyright (C) 2004 Chris Kennedy <c@groovy.org>
25 *
26 * VBI additions & cleanup:
27 * Copyright (C) 2004, 2005 Hans Verkuil <hverkuil@xs4all.nl>
28 *
29 * Note: the saa7126 is identical to the saa7127, and the saa7128 is
30 * identical to the saa7129, except that the saa7126 and saa7128 have
31 * macrovision anti-taping support. This driver will almost certainly
32 * work find for those chips, except of course for the missing anti-taping
33 * support.
34 *
35 * This program is free software; you can redistribute it and/or modify
36 * it under the terms of the GNU General Public License as published by
37 * the Free Software Foundation; either version 2 of the License, or
38 * (at your option) any later version.
39 *
40 * This program is distributed in the hope that it will be useful,
41 * but WITHOUT ANY WARRANTY; without even the implied warranty of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 * GNU General Public License for more details.
44 *
45 * You should have received a copy of the GNU General Public License
46 * along with this program; if not, write to the Free Software
47 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
48 */
49
50
51#include <linux/kernel.h>
52#include <linux/module.h>
53#include <linux/slab.h>
54#include <linux/i2c.h>
55#include <linux/videodev2.h>
56#include <media/v4l2-common.h>
57
58static int debug = 0;
59static int test_image = 0;
60
61MODULE_DESCRIPTION("Philips SAA7127/9 video encoder driver");
62MODULE_AUTHOR("Kevin Thayer, Chris Kennedy, Hans Verkuil");
63MODULE_LICENSE("GPL");
64module_param(debug, int, 0644);
65module_param(test_image, int, 0644);
66MODULE_PARM_DESC(debug, "debug level (0-2)");
67MODULE_PARM_DESC(test_image, "test_image (0-1)");
68
69#define saa7127_dbg(fmt, arg...) \
70 do { \
71 if (debug >= 1) \
72 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
73 i2c_adapter_id(client->adapter), client->addr , ## arg); \
74 } while (0)
75
76/* High volume debug. Use with care. */
77#define saa7127_dbg_highvol(fmt, arg...) \
78 do { \
79 if (debug == 2) \
80 printk(KERN_INFO "%s debug %d-%04x: " fmt, client->driver->name, \
81 i2c_adapter_id(client->adapter), client->addr , ## arg); \
82 } while (0)
83
84#define saa7127_err(fmt, arg...) do { \
85 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->name, \
86 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
87#define saa7127_info(fmt, arg...) do { \
88 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->name, \
89 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
90
91static unsigned short normal_i2c[] = { 0x88 >> 1, I2C_CLIENT_END };
92
93
94I2C_CLIENT_INSMOD;
95
96/*
97 * SAA7127 registers
98 */
99
100#define SAA7127_REG_STATUS 0x00
101#define SAA7127_REG_WIDESCREEN_CONFIG 0x26
102#define SAA7127_REG_WIDESCREEN_ENABLE 0x27
103#define SAA7127_REG_BURST_START 0x28
104#define SAA7127_REG_BURST_END 0x29
105#define SAA7127_REG_COPYGEN_0 0x2a
106#define SAA7127_REG_COPYGEN_1 0x2b
107#define SAA7127_REG_COPYGEN_2 0x2c
108#define SAA7127_REG_OUTPUT_PORT_CONTROL 0x2d
109#define SAA7127_REG_GAIN_LUMINANCE_RGB 0x38
110#define SAA7127_REG_GAIN_COLORDIFF_RGB 0x39
111#define SAA7127_REG_INPUT_PORT_CONTROL_1 0x3a
112#define SAA7129_REG_FADE_KEY_COL2 0x4f
113#define SAA7127_REG_CHROMA_PHASE 0x5a
114#define SAA7127_REG_GAINU 0x5b
115#define SAA7127_REG_GAINV 0x5c
116#define SAA7127_REG_BLACK_LEVEL 0x5d
117#define SAA7127_REG_BLANKING_LEVEL 0x5e
118#define SAA7127_REG_VBI_BLANKING 0x5f
119#define SAA7127_REG_DAC_CONTROL 0x61
120#define SAA7127_REG_BURST_AMP 0x62
121#define SAA7127_REG_SUBC3 0x63
122#define SAA7127_REG_SUBC2 0x64
123#define SAA7127_REG_SUBC1 0x65
124#define SAA7127_REG_SUBC0 0x66
125#define SAA7127_REG_LINE_21_ODD_0 0x67
126#define SAA7127_REG_LINE_21_ODD_1 0x68
127#define SAA7127_REG_LINE_21_EVEN_0 0x69
128#define SAA7127_REG_LINE_21_EVEN_1 0x6a
129#define SAA7127_REG_RCV_PORT_CONTROL 0x6b
130#define SAA7127_REG_VTRIG 0x6c
131#define SAA7127_REG_HTRIG_HI 0x6d
132#define SAA7127_REG_MULTI 0x6e
133#define SAA7127_REG_CLOSED_CAPTION 0x6f
134#define SAA7127_REG_RCV2_OUTPUT_START 0x70
135#define SAA7127_REG_RCV2_OUTPUT_END 0x71
136#define SAA7127_REG_RCV2_OUTPUT_MSBS 0x72
137#define SAA7127_REG_TTX_REQUEST_H_START 0x73
138#define SAA7127_REG_TTX_REQUEST_H_DELAY_LENGTH 0x74
139#define SAA7127_REG_CSYNC_ADVANCE_VSYNC_SHIFT 0x75
140#define SAA7127_REG_TTX_ODD_REQ_VERT_START 0x76
141#define SAA7127_REG_TTX_ODD_REQ_VERT_END 0x77
142#define SAA7127_REG_TTX_EVEN_REQ_VERT_START 0x78
143#define SAA7127_REG_TTX_EVEN_REQ_VERT_END 0x79
144#define SAA7127_REG_FIRST_ACTIVE 0x7a
145#define SAA7127_REG_LAST_ACTIVE 0x7b
146#define SAA7127_REG_MSB_VERTICAL 0x7c
147#define SAA7127_REG_DISABLE_TTX_LINE_LO_0 0x7e
148#define SAA7127_REG_DISABLE_TTX_LINE_LO_1 0x7f
149
150/*
151 **********************************************************************
152 *
153 * Arrays with configuration parameters for the SAA7127
154 *
155 **********************************************************************
156 */
157
158struct i2c_reg_value {
159 unsigned char reg;
160 unsigned char value;
161};
162
163static const struct i2c_reg_value saa7129_init_config_extra[] = {
164 { SAA7127_REG_OUTPUT_PORT_CONTROL, 0x38 },
165 { SAA7127_REG_VTRIG, 0xfa },
166};
167
168static const struct i2c_reg_value saa7127_init_config_common[] = {
169 { SAA7127_REG_WIDESCREEN_CONFIG, 0x0d },
170 { SAA7127_REG_WIDESCREEN_ENABLE, 0x00 },
171 { SAA7127_REG_COPYGEN_0, 0x77 },
172 { SAA7127_REG_COPYGEN_1, 0x41 },
173 { SAA7127_REG_COPYGEN_2, 0x00 }, /* Macrovision enable/disable */
174 { SAA7127_REG_OUTPUT_PORT_CONTROL, 0x9e },
175 { SAA7127_REG_GAIN_LUMINANCE_RGB, 0x00 },
176 { SAA7127_REG_GAIN_COLORDIFF_RGB, 0x00 },
177 { SAA7127_REG_INPUT_PORT_CONTROL_1, 0x80 }, /* for color bars */
178 { SAA7127_REG_LINE_21_ODD_0, 0x77 },
179 { SAA7127_REG_LINE_21_ODD_1, 0x41 },
180 { SAA7127_REG_LINE_21_EVEN_0, 0x88 },
181 { SAA7127_REG_LINE_21_EVEN_1, 0x41 },
182 { SAA7127_REG_RCV_PORT_CONTROL, 0x12 },
183 { SAA7127_REG_VTRIG, 0xf9 },
184 { SAA7127_REG_HTRIG_HI, 0x00 },
185 { SAA7127_REG_RCV2_OUTPUT_START, 0x41 },
186 { SAA7127_REG_RCV2_OUTPUT_END, 0xc3 },
187 { SAA7127_REG_RCV2_OUTPUT_MSBS, 0x00 },
188 { SAA7127_REG_TTX_REQUEST_H_START, 0x3e },
189 { SAA7127_REG_TTX_REQUEST_H_DELAY_LENGTH, 0xb8 },
190 { SAA7127_REG_CSYNC_ADVANCE_VSYNC_SHIFT, 0x03 },
191 { SAA7127_REG_TTX_ODD_REQ_VERT_START, 0x15 },
192 { SAA7127_REG_TTX_ODD_REQ_VERT_END, 0x16 },
193 { SAA7127_REG_TTX_EVEN_REQ_VERT_START, 0x15 },
194 { SAA7127_REG_TTX_EVEN_REQ_VERT_END, 0x16 },
195 { SAA7127_REG_FIRST_ACTIVE, 0x1a },
196 { SAA7127_REG_LAST_ACTIVE, 0x01 },
197 { SAA7127_REG_MSB_VERTICAL, 0xc0 },
198 { SAA7127_REG_DISABLE_TTX_LINE_LO_0, 0x00 },
199 { SAA7127_REG_DISABLE_TTX_LINE_LO_1, 0x00 },
200 { 0, 0 }
201};
202
203#define SAA7127_60HZ_DAC_CONTROL 0x15
204static const struct i2c_reg_value saa7127_init_config_60hz[] = {
205 { SAA7127_REG_BURST_START, 0x19 },
206 /* BURST_END is also used as a chip ID in saa7127_detect_client */
207 { SAA7127_REG_BURST_END, 0x1d },
208 { SAA7127_REG_CHROMA_PHASE, 0xa3 },
209 { SAA7127_REG_GAINU, 0x98 },
210 { SAA7127_REG_GAINV, 0xd3 },
211 { SAA7127_REG_BLACK_LEVEL, 0x39 },
212 { SAA7127_REG_BLANKING_LEVEL, 0x2e },
213 { SAA7127_REG_VBI_BLANKING, 0x2e },
214 { SAA7127_REG_DAC_CONTROL, 0x15 },
215 { SAA7127_REG_BURST_AMP, 0x4d },
216 { SAA7127_REG_SUBC3, 0x1f },
217 { SAA7127_REG_SUBC2, 0x7c },
218 { SAA7127_REG_SUBC1, 0xf0 },
219 { SAA7127_REG_SUBC0, 0x21 },
220 { SAA7127_REG_MULTI, 0x90 },
221 { SAA7127_REG_CLOSED_CAPTION, 0x11 },
222 { 0, 0 }
223};
224
225#define SAA7127_50HZ_DAC_CONTROL 0x02
226static struct i2c_reg_value saa7127_init_config_50hz[] = {
227 { SAA7127_REG_BURST_START, 0x21 },
228 /* BURST_END is also used as a chip ID in saa7127_detect_client */
229 { SAA7127_REG_BURST_END, 0x1d },
230 { SAA7127_REG_CHROMA_PHASE, 0x3f },
231 { SAA7127_REG_GAINU, 0x7d },
232 { SAA7127_REG_GAINV, 0xaf },
233 { SAA7127_REG_BLACK_LEVEL, 0x33 },
234 { SAA7127_REG_BLANKING_LEVEL, 0x35 },
235 { SAA7127_REG_VBI_BLANKING, 0x35 },
236 { SAA7127_REG_DAC_CONTROL, 0x02 },
237 { SAA7127_REG_BURST_AMP, 0x2f },
238 { SAA7127_REG_SUBC3, 0xcb },
239 { SAA7127_REG_SUBC2, 0x8a },
240 { SAA7127_REG_SUBC1, 0x09 },
241 { SAA7127_REG_SUBC0, 0x2a },
242 { SAA7127_REG_MULTI, 0xa0 },
243 { SAA7127_REG_CLOSED_CAPTION, 0x00 },
244 { 0, 0 }
245};
246
247/* Enumeration for the Supported input types */
248enum saa7127_input_type {
249 SAA7127_INPUT_TYPE_NORMAL,
250 SAA7127_INPUT_TYPE_TEST_IMAGE
251};
252
253/* Enumeration for the Supported Output signal types */
254enum saa7127_output_type {
255 SAA7127_OUTPUT_TYPE_BOTH,
256 SAA7127_OUTPUT_TYPE_COMPOSITE,
257 SAA7127_OUTPUT_TYPE_SVIDEO,
258 SAA7127_OUTPUT_TYPE_RGB,
259 SAA7127_OUTPUT_TYPE_YUV_C,
260 SAA7127_OUTPUT_TYPE_YUV_V
261};
262
263/*
264 **********************************************************************
265 *
266 * Encoder Struct, holds the configuration state of the encoder
267 *
268 **********************************************************************
269 */
270
271struct saa7127_state {
272 v4l2_std_id std;
273 enum v4l2_chip_ident ident;
274 enum saa7127_input_type input_type;
275 enum saa7127_output_type output_type;
276 int video_enable;
277 int wss_enable;
278 u16 wss_mode;
279 int cc_enable;
280 u16 cc_data;
281 int xds_enable;
282 u16 xds_data;
283 int vps_enable;
284 u8 vps_data[5];
285 u8 reg_2d;
286 u8 reg_3a;
287 u8 reg_3a_cb; /* colorbar bit */
288 u8 reg_61;
289};
290
291static const char * const output_strs[] =
292{
293 "S-Video + Composite",
294 "Composite",
295 "S-Video",
296 "RGB",
297 "YUV C",
298 "YUV V"
299};
300
301static const char * const wss_strs[] = {
302 "invalid",
303 "letterbox 14:9 center",
304 "letterbox 14:9 top",
305 "invalid",
306 "letterbox 16:9 top",
307 "invalid",
308 "invalid",
309 "16:9 full format anamorphic"
310 "4:3 full format",
311 "invalid",
312 "invalid",
313 "letterbox 16:9 center",
314 "invalid",
315 "letterbox >16:9 center",
316 "14:9 full format center",
317 "invalid",
318};
319
320/* ----------------------------------------------------------------------- */
321
322static int saa7127_read(struct i2c_client *client, u8 reg)
323{
324 return i2c_smbus_read_byte_data(client, reg);
325}
326
327/* ----------------------------------------------------------------------- */
328
329static int saa7127_write(struct i2c_client *client, u8 reg, u8 val)
330{
331 int i;
332
333 for (i = 0; i < 3; i++) {
334 if (i2c_smbus_write_byte_data(client, reg, val) == 0)
335 return 0;
336 }
337 saa7127_err("I2C Write Problem\n");
338 return -1;
339}
340
341/* ----------------------------------------------------------------------- */
342
343static int saa7127_write_inittab(struct i2c_client *client,
344 const struct i2c_reg_value *regs)
345{
346 while (regs->reg != 0) {
347 saa7127_write(client, regs->reg, regs->value);
348 regs++;
349 }
350 return 0;
351}
352
353/* ----------------------------------------------------------------------- */
354
355static int saa7127_set_vps(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
356{
357 struct saa7127_state *state = i2c_get_clientdata(client);
358 int enable = (data->line != 0);
359
360 if (enable && (data->field != 0 || data->line != 16))
361 return -EINVAL;
362 if (state->vps_enable != enable) {
363 saa7127_dbg("Turn VPS Signal %s\n", enable ? "on" : "off");
364 saa7127_write(client, 0x54, enable << 7);
365 state->vps_enable = enable;
366 }
367 if (!enable)
368 return 0;
369
370 state->vps_data[0] = data->data[4];
371 state->vps_data[1] = data->data[10];
372 state->vps_data[2] = data->data[11];
373 state->vps_data[3] = data->data[12];
374 state->vps_data[4] = data->data[13];
375 saa7127_dbg("Set VPS data %02x %02x %02x %02x %02x\n",
376 state->vps_data[0], state->vps_data[1],
377 state->vps_data[2], state->vps_data[3],
378 state->vps_data[4]);
379 saa7127_write(client, 0x55, state->vps_data[0]);
380 saa7127_write(client, 0x56, state->vps_data[1]);
381 saa7127_write(client, 0x57, state->vps_data[2]);
382 saa7127_write(client, 0x58, state->vps_data[3]);
383 saa7127_write(client, 0x59, state->vps_data[4]);
384 return 0;
385}
386
387/* ----------------------------------------------------------------------- */
388
389static int saa7127_set_cc(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
390{
391 struct saa7127_state *state = i2c_get_clientdata(client);
392 u16 cc = data->data[1] << 8 | data->data[0];
393 int enable = (data->line != 0);
394
395 if (enable && (data->field != 0 || data->line != 21))
396 return -EINVAL;
397 if (state->cc_enable != enable) {
398 saa7127_dbg("Turn CC %s\n", enable ? "on" : "off");
399 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
400 (state->xds_enable << 7) | (enable << 6) | 0x11);
401 state->cc_enable = enable;
402 }
403 if (!enable)
404 return 0;
405
406 saa7127_dbg_highvol("CC data: %04x\n", cc);
407 saa7127_write(client, SAA7127_REG_LINE_21_ODD_0, cc & 0xff);
408 saa7127_write(client, SAA7127_REG_LINE_21_ODD_1, cc >> 8);
409 state->cc_data = cc;
410 return 0;
411}
412
413/* ----------------------------------------------------------------------- */
414
415static int saa7127_set_xds(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
416{
417 struct saa7127_state *state = i2c_get_clientdata(client);
418 u16 xds = data->data[1] << 8 | data->data[0];
419 int enable = (data->line != 0);
420
421 if (enable && (data->field != 1 || data->line != 21))
422 return -EINVAL;
423 if (state->xds_enable != enable) {
424 saa7127_dbg("Turn XDS %s\n", enable ? "on" : "off");
425 saa7127_write(client, SAA7127_REG_CLOSED_CAPTION,
426 (enable << 7) | (state->cc_enable << 6) | 0x11);
427 state->xds_enable = enable;
428 }
429 if (!enable)
430 return 0;
431
432 saa7127_dbg_highvol("XDS data: %04x\n", xds);
433 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_0, xds & 0xff);
434 saa7127_write(client, SAA7127_REG_LINE_21_EVEN_1, xds >> 8);
435 state->xds_data = xds;
436 return 0;
437}
438
439/* ----------------------------------------------------------------------- */
440
441static int saa7127_set_wss(struct i2c_client *client, struct v4l2_sliced_vbi_data *data)
442{
443 struct saa7127_state *state = i2c_get_clientdata(client);
444 int enable = (data->line != 0);
445
446 if (enable && (data->field != 0 || data->line != 23))
447 return -EINVAL;
448 if (state->wss_enable != enable) {
449 saa7127_dbg("Turn WSS %s\n", enable ? "on" : "off");
450 saa7127_write(client, 0x27, enable << 7);
451 state->wss_enable = enable;
452 }
453 if (!enable)
454 return 0;
455
456 saa7127_write(client, 0x26, data->data[0]);
457 saa7127_write(client, 0x27, 0x80 | (data->data[1] & 0x3f));
458 saa7127_dbg("WSS mode: %s\n", wss_strs[data->data[0] & 0xf]);
459 state->wss_mode = (data->data[1] & 0x3f) << 8 | data->data[0];
460 return 0;
461}
462
463/* ----------------------------------------------------------------------- */
464
465static int saa7127_set_video_enable(struct i2c_client *client, int enable)
466{
467 struct saa7127_state *state = i2c_get_clientdata(client);
468
469 if (enable) {
470 saa7127_dbg("Enable Video Output\n");
471 saa7127_write(client, 0x2d, state->reg_2d);
472 saa7127_write(client, 0x61, state->reg_61);
473 } else {
474 saa7127_dbg("Disable Video Output\n");
475 saa7127_write(client, 0x2d, (state->reg_2d & 0xf0));
476 saa7127_write(client, 0x61, (state->reg_61 | 0xc0));
477 }
478 state->video_enable = enable;
479 return 0;
480}
481
482/* ----------------------------------------------------------------------- */
483
484static int saa7127_set_std(struct i2c_client *client, v4l2_std_id std)
485{
486 struct saa7127_state *state = i2c_get_clientdata(client);
487 const struct i2c_reg_value *inittab;
488
489 if (std & V4L2_STD_525_60) {
490 saa7127_dbg("Selecting 60 Hz video Standard\n");
491 inittab = saa7127_init_config_60hz;
492 state->reg_61 = SAA7127_60HZ_DAC_CONTROL;
493 } else {
494 saa7127_dbg("Selecting 50 Hz video Standard\n");
495 inittab = saa7127_init_config_50hz;
496 state->reg_61 = SAA7127_50HZ_DAC_CONTROL;
497 }
498
499 /* Write Table */
500 saa7127_write_inittab(client, inittab);
501 state->std = std;
502 return 0;
503}
504
505/* ----------------------------------------------------------------------- */
506
507static int saa7127_set_output_type(struct i2c_client *client, int output)
508{
509 struct saa7127_state *state = i2c_get_clientdata(client);
510
511 switch (output) {
512 case SAA7127_OUTPUT_TYPE_RGB:
513 state->reg_2d = 0x0f; /* RGB + CVBS (for sync) */
514 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */
515 break;
516
517 case SAA7127_OUTPUT_TYPE_COMPOSITE:
518 state->reg_2d = 0x08; /* 00001000 CVBS only, RGB DAC's off (high impedance mode) */
519 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */
520 break;
521
522 case SAA7127_OUTPUT_TYPE_SVIDEO:
523 state->reg_2d = 0xff; /* 11111111 croma -> R, luma -> CVBS + G + B */
524 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */
525 break;
526
527 case SAA7127_OUTPUT_TYPE_YUV_V:
528 state->reg_2d = 0x4f; /* reg 2D = 01001111, all DAC's on, RGB + VBS */
529 state->reg_3a = 0x0b; /* reg 3A = 00001011, bypass RGB-matrix */
530 break;
531
532 case SAA7127_OUTPUT_TYPE_YUV_C:
533 state->reg_2d = 0x0f; /* reg 2D = 00001111, all DAC's on, RGB + CVBS */
534 state->reg_3a = 0x0b; /* reg 3A = 00001011, bypass RGB-matrix */
535 break;
536
537 case SAA7127_OUTPUT_TYPE_BOTH:
538 state->reg_2d = 0xbf;
539 state->reg_3a = 0x13; /* by default switch YUV to RGB-matrix on */
540 break;
541
542 default:
543 return -EINVAL;
544 }
545 saa7127_dbg("Selecting %s output type\n", output_strs[output]);
546
547 /* Configure Encoder */
548 saa7127_write(client, 0x2d, state->reg_2d);
549 saa7127_write(client, 0x3a, state->reg_3a | state->reg_3a_cb);
550 state->output_type = output;
551 return 0;
552}
553
554/* ----------------------------------------------------------------------- */
555
556static int saa7127_set_input_type(struct i2c_client *client, int input)
557{
558 struct saa7127_state *state = i2c_get_clientdata(client);
559
560 switch (input) {
561 case SAA7127_INPUT_TYPE_NORMAL: /* avia */
562 saa7127_dbg("Selecting Normal Encoder Input\n");
563 state->reg_3a_cb = 0;
564 break;
565
566 case SAA7127_INPUT_TYPE_TEST_IMAGE: /* color bar */
567 saa7127_dbg("Selecting Color Bar generator\n");
568 state->reg_3a_cb = 0x80;
569 break;
570
571 default:
572 return -EINVAL;
573 }
574 saa7127_write(client, 0x3a, state->reg_3a | state->reg_3a_cb);
575 state->input_type = input;
576 return 0;
577}
578
579/* ----------------------------------------------------------------------- */
580
581static int saa7127_command(struct i2c_client *client,
582 unsigned int cmd, void *arg)
583{
584 struct saa7127_state *state = i2c_get_clientdata(client);
585 struct v4l2_format *fmt = arg;
586 int *iarg = arg;
587
588 switch (cmd) {
589 case VIDIOC_S_STD:
590 if (state->std == *(v4l2_std_id *)arg)
591 break;
592 return saa7127_set_std(client, *(v4l2_std_id *)arg);
593
594 case VIDIOC_G_STD:
595 *(v4l2_std_id *)arg = state->std;
596 break;
597
598 case VIDIOC_S_INPUT:
599 if (state->input_type == *iarg)
600 break;
601 return saa7127_set_input_type(client, *iarg);
602
603 case VIDIOC_S_OUTPUT:
604 if (state->output_type == *iarg)
605 break;
606 return saa7127_set_output_type(client, *iarg);
607
608 case VIDIOC_STREAMON:
609 case VIDIOC_STREAMOFF:
610 if (state->video_enable == (cmd == VIDIOC_STREAMON))
611 break;
612 return saa7127_set_video_enable(client, cmd == VIDIOC_STREAMON);
613
614 case VIDIOC_G_FMT:
615 if (fmt->type != V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
616 return -EINVAL;
617
618 memset(&fmt->fmt.sliced, 0, sizeof(fmt->fmt.sliced));
619 if (state->vps_enable)
620 fmt->fmt.sliced.service_lines[0][16] = V4L2_SLICED_VPS;
621 if (state->wss_enable)
622 fmt->fmt.sliced.service_lines[0][23] = V4L2_SLICED_WSS_625;
623 if (state->cc_enable) {
624 fmt->fmt.sliced.service_lines[0][21] = V4L2_SLICED_CAPTION_525;
625 fmt->fmt.sliced.service_lines[1][21] = V4L2_SLICED_CAPTION_525;
626 }
627 fmt->fmt.sliced.service_set =
628 (state->vps_enable ? V4L2_SLICED_VPS : 0) |
629 (state->wss_enable ? V4L2_SLICED_WSS_625 : 0) |
630 (state->cc_enable ? V4L2_SLICED_CAPTION_525 : 0);
631 break;
632
633 case VIDIOC_LOG_STATUS:
634 saa7127_info("Standard: %s\n", (state->std & V4L2_STD_525_60) ? "60 Hz" : "50 Hz");
635 saa7127_info("Input: %s\n", state->input_type ? "color bars" : "normal");
636 saa7127_info("Output: %s\n", state->video_enable ?
637 output_strs[state->output_type] : "disabled");
638 saa7127_info("WSS: %s\n", state->wss_enable ?
639 wss_strs[state->wss_mode] : "disabled");
640 saa7127_info("VPS: %s\n", state->vps_enable ? "enabled" : "disabled");
641 saa7127_info("CC: %s\n", state->cc_enable ? "enabled" : "disabled");
642 break;
643
644#ifdef CONFIG_VIDEO_ADV_DEBUG
645 case VIDIOC_INT_G_REGISTER:
646 {
647 struct v4l2_register *reg = arg;
648
649 if (reg->i2c_id != I2C_DRIVERID_SAA7127)
650 return -EINVAL;
651 reg->val = saa7127_read(client, reg->reg & 0xff);
652 break;
653 }
654
655 case VIDIOC_INT_S_REGISTER:
656 {
657 struct v4l2_register *reg = arg;
658
659 if (reg->i2c_id != I2C_DRIVERID_SAA7127)
660 return -EINVAL;
661 if (!capable(CAP_SYS_ADMIN))
662 return -EPERM;
663 saa7127_write(client, reg->reg & 0xff, reg->val & 0xff);
664 break;
665 }
666#endif
667
668 case VIDIOC_INT_S_VBI_DATA:
669 {
670 struct v4l2_sliced_vbi_data *data = arg;
671
672 switch (data->id) {
673 case V4L2_SLICED_WSS_625:
674 return saa7127_set_wss(client, data);
675 case V4L2_SLICED_VPS:
676 return saa7127_set_vps(client, data);
677 case V4L2_SLICED_CAPTION_525:
678 if (data->field == 0)
679 return saa7127_set_cc(client, data);
680 return saa7127_set_xds(client, data);
681 default:
682 return -EINVAL;
683 }
684 break;
685 }
686
687 case VIDIOC_INT_G_CHIP_IDENT:
688 *(enum v4l2_chip_ident *)arg = state->ident;
689 break;
690
691 default:
692 return -EINVAL;
693 }
694 return 0;
695}
696
697/* ----------------------------------------------------------------------- */
698
699static struct i2c_driver i2c_driver_saa7127;
700
701/* ----------------------------------------------------------------------- */
702
703static int saa7127_attach(struct i2c_adapter *adapter, int address, int kind)
704{
705 struct i2c_client *client;
706 struct saa7127_state *state;
707 struct v4l2_sliced_vbi_data vbi = { 0, 0, 0, 0 }; /* set to disabled */
708 int read_result = 0;
709
710 /* Check if the adapter supports the needed features */
711 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
712 return 0;
713
714 client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
715 if (client == 0)
716 return -ENOMEM;
717
718 memset(client, 0, sizeof(struct i2c_client));
719 client->addr = address;
720 client->adapter = adapter;
721 client->driver = &i2c_driver_saa7127;
722 client->flags = I2C_CLIENT_ALLOW_USE;
723 snprintf(client->name, sizeof(client->name) - 1, "saa7127");
724
725 saa7127_dbg("detecting saa7127 client on address 0x%x\n", address << 1);
726
727 /* First test register 0: Bits 5-7 are a version ID (should be 0),
728 and bit 2 should also be 0.
729 This is rather general, so the second test is more specific and
730 looks at the 'ending point of burst in clock cycles' which is
731 0x1d after a reset and not expected to ever change. */
732 if ((saa7127_read(client, 0) & 0xe4) != 0 ||
733 (saa7127_read(client, 0x29) & 0x3f) != 0x1d) {
734 saa7127_dbg("saa7127 not found\n");
735 kfree(client);
736 return 0;
737 }
738 state = kmalloc(sizeof(struct saa7127_state), GFP_KERNEL);
739
740 if (state == NULL) {
741 kfree(client);
742 return (-ENOMEM);
743 }
744
745 i2c_set_clientdata(client, state);
746 memset(state, 0, sizeof(struct saa7127_state));
747
748 /* Configure Encoder */
749
750 saa7127_dbg("Configuring encoder\n");
751 saa7127_write_inittab(client, saa7127_init_config_common);
752 saa7127_set_std(client, V4L2_STD_NTSC);
753 saa7127_set_output_type(client, SAA7127_OUTPUT_TYPE_BOTH);
754 saa7127_set_vps(client, &vbi);
755 saa7127_set_wss(client, &vbi);
756 saa7127_set_cc(client, &vbi);
757 saa7127_set_xds(client, &vbi);
758 if (test_image == 1) {
759 /* The Encoder has an internal Colorbar generator */
760 /* This can be used for debugging */
761 saa7127_set_input_type(client, SAA7127_INPUT_TYPE_TEST_IMAGE);
762 } else {
763 saa7127_set_input_type(client, SAA7127_INPUT_TYPE_NORMAL);
764 }
765 saa7127_set_video_enable(client, 1);
766
767 /* Detect if it's an saa7129 */
768 read_result = saa7127_read(client, SAA7129_REG_FADE_KEY_COL2);
769 saa7127_write(client, SAA7129_REG_FADE_KEY_COL2, 0xaa);
770 if (saa7127_read(client, SAA7129_REG_FADE_KEY_COL2) == 0xaa) {
771 saa7127_info("saa7129 found @ 0x%x (%s)\n", address << 1, adapter->name);
772 saa7127_write(client, SAA7129_REG_FADE_KEY_COL2, read_result);
773 saa7127_write_inittab(client, saa7129_init_config_extra);
774 state->ident = V4L2_IDENT_SAA7129;
775 } else {
776 saa7127_info("saa7127 found @ 0x%x (%s)\n", address << 1, adapter->name);
777 state->ident = V4L2_IDENT_SAA7127;
778 }
779
780 i2c_attach_client(client);
781
782 return 0;
783}
784
785/* ----------------------------------------------------------------------- */
786
787static int saa7127_probe(struct i2c_adapter *adapter)
788{
789#ifdef I2C_CLASS_TV_ANALOG
790 if (adapter->class & I2C_CLASS_TV_ANALOG)
791#else
792 if (adapter->id == I2C_HW_B_BT848)
793#endif
794 return i2c_probe(adapter, &addr_data, saa7127_attach);
795 return 0;
796}
797
798/* ----------------------------------------------------------------------- */
799
800static int saa7127_detach(struct i2c_client *client)
801{
802 struct saa7127_state *state = i2c_get_clientdata(client);
803 int err;
804
805 /* Turn off TV output */
806 saa7127_set_video_enable(client, 0);
807
808 err = i2c_detach_client(client);
809
810 if (err) {
811 return err;
812 }
813
814 kfree(state);
815 kfree(client);
816 return 0;
817}
818
819/* ----------------------------------------------------------------------- */
820
821static struct i2c_driver i2c_driver_saa7127 = {
822 .name = "saa7127",
823 .id = I2C_DRIVERID_SAA7127,
824 .flags = I2C_DF_NOTIFY,
825 .attach_adapter = saa7127_probe,
826 .detach_client = saa7127_detach,
827 .command = saa7127_command,
828 .owner = THIS_MODULE,
829};
830
831
832/* ----------------------------------------------------------------------- */
833
834static int __init saa7127_init_module(void)
835{
836 return i2c_add_driver(&i2c_driver_saa7127);
837}
838
839/* ----------------------------------------------------------------------- */
840
841static void __exit saa7127_cleanup_module(void)
842{
843 i2c_del_driver(&i2c_driver_saa7127);
844}
845
846/* ----------------------------------------------------------------------- */
847
848module_init(saa7127_init_module);
849module_exit(saa7127_cleanup_module);
diff --git a/drivers/media/video/saa7134/Kconfig b/drivers/media/video/saa7134/Kconfig
index 624e8808a517..8a5c3e71b37d 100644
--- a/drivers/media/video/saa7134/Kconfig
+++ b/drivers/media/video/saa7134/Kconfig
@@ -1,6 +1,6 @@
1config VIDEO_SAA7134 1config VIDEO_SAA7134
2 tristate "Philips SAA7134 support" 2 tristate "Philips SAA7134 support"
3 depends on VIDEO_DEV && PCI && I2C && SOUND 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
@@ -12,6 +12,29 @@ config VIDEO_SAA7134
12 To compile this driver as a module, choose M here: the 12 To compile this driver as a module, choose M here: the
13 module will be called saa7134. 13 module will be called saa7134.
14 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
15config VIDEO_SAA7134_DVB 38config VIDEO_SAA7134_DVB
16 tristate "DVB/ATSC Support for saa7134 based TV cards" 39 tristate "DVB/ATSC Support for saa7134 based TV cards"
17 depends on VIDEO_SAA7134 && DVB_CORE 40 depends on VIDEO_SAA7134 && DVB_CORE
@@ -41,8 +64,8 @@ config VIDEO_SAA7134_DVB_ALL_FRONTENDS
41 If you are unsure, choose Y. 64 If you are unsure, choose Y.
42 65
43config VIDEO_SAA7134_DVB_MT352 66config VIDEO_SAA7134_DVB_MT352
44 tristate "Zarlink MT352 DVB-T Support" 67 bool "Zarlink MT352 DVB-T Support"
45 default m 68 default y
46 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS 69 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
47 select DVB_MT352 70 select DVB_MT352
48 ---help--- 71 ---help---
@@ -50,8 +73,8 @@ config VIDEO_SAA7134_DVB_MT352
50 Philips saa7134 chip and the MT352 demodulator. 73 Philips saa7134 chip and the MT352 demodulator.
51 74
52config VIDEO_SAA7134_DVB_TDA1004X 75config VIDEO_SAA7134_DVB_TDA1004X
53 tristate "Phillips TDA10045H/TDA10046H DVB-T Support" 76 bool "Phillips TDA10045H/TDA10046H DVB-T Support"
54 default m 77 default y
55 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS 78 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
56 select DVB_TDA1004X 79 select DVB_TDA1004X
57 ---help--- 80 ---help---
@@ -59,8 +82,8 @@ config VIDEO_SAA7134_DVB_TDA1004X
59 Philips saa7134 chip and the TDA10045H/TDA10046H demodulator. 82 Philips saa7134 chip and the TDA10045H/TDA10046H demodulator.
60 83
61config VIDEO_SAA7134_DVB_NXT200X 84config VIDEO_SAA7134_DVB_NXT200X
62 tristate "NXT2002/NXT2004 ATSC Support" 85 bool "NXT2002/NXT2004 ATSC Support"
63 default m 86 default y
64 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS 87 depends on VIDEO_SAA7134_DVB && !VIDEO_SAA7134_DVB_ALL_FRONTENDS
65 select DVB_NXT200X 88 select DVB_NXT200X
66 ---help--- 89 ---help---
diff --git a/drivers/media/video/saa7134/Makefile b/drivers/media/video/saa7134/Makefile
index e0b28f0533af..1ba998424bbd 100644
--- a/drivers/media/video/saa7134/Makefile
+++ b/drivers/media/video/saa7134/Makefile
@@ -1,24 +1,23 @@
1 1
2saa7134-objs := saa7134-cards.o saa7134-core.o saa7134-i2c.o \ 2saa7134-objs := saa7134-cards.o saa7134-core.o saa7134-i2c.o \
3 saa7134-oss.o saa7134-ts.o saa7134-tvaudio.o \ 3 saa7134-ts.o saa7134-tvaudio.o saa7134-vbi.o \
4 saa7134-vbi.o 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
9obj-$(CONFIG_VIDEO_SAA7134_ALSA) += saa7134-alsa.o
10obj-$(CONFIG_VIDEO_SAA7134_OSS) += saa7134-oss.o
11
8obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o 12obj-$(CONFIG_VIDEO_SAA7134_DVB) += saa7134-dvb.o
9 13
10EXTRA_CFLAGS += -I$(src)/.. 14EXTRA_CFLAGS += -I$(src)/..
11EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core 15EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
12EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends 16EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/frontends
13ifneq ($(CONFIG_VIDEO_BUF_DVB),n) 17
14 EXTRA_CFLAGS += -DHAVE_VIDEO_BUF_DVB=1 18extra-cflags-$(CONFIG_VIDEO_BUF_DVB) += -DHAVE_VIDEO_BUF_DVB=1
15endif 19extra-cflags-$(CONFIG_DVB_MT352) += -DHAVE_MT352=1
16ifneq ($(CONFIG_DVB_MT352),n) 20extra-cflags-$(CONFIG_DVB_TDA1004X) += -DHAVE_TDA1004X=1
17 EXTRA_CFLAGS += -DHAVE_MT352=1 21extra-cflags-$(CONFIG_DVB_NXT200X) += -DHAVE_NXT200X=1
18endif 22
19ifneq ($(CONFIG_DVB_TDA1004X),n) 23EXTRA_CFLAGS += $(extra-cflags-y) $(extra-cflags-m)
20 EXTRA_CFLAGS += -DHAVE_TDA1004X=1
21endif
22ifneq ($(CONFIG_DVB_NXT200X),n)
23 EXTRA_CFLAGS += -DHAVE_NXT200X=1
24endif
diff --git a/drivers/media/video/saa7134/saa6752hs.c b/drivers/media/video/saa7134/saa6752hs.c
index cdd1ed9c8065..a61d24f588f7 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
@@ -597,19 +598,19 @@ saa6752hs_command(struct i2c_client *client, unsigned int cmd, void *arg)
597 598
598static struct i2c_driver driver = { 599static struct i2c_driver driver = {
599 .owner = THIS_MODULE, 600 .owner = THIS_MODULE,
600 .name = "i2c saa6752hs MPEG encoder", 601 .name = "i2c saa6752hs MPEG encoder",
601 .id = I2C_DRIVERID_SAA6752HS, 602 .id = I2C_DRIVERID_SAA6752HS,
602 .flags = I2C_DF_NOTIFY, 603 .flags = I2C_DF_NOTIFY,
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 .flags = I2C_CLIENT_ALLOW_USE,
612 .driver = &driver, 613 .driver = &driver,
613}; 614};
614 615
615static int __init saa6752hs_init_module(void) 616static 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 4f3c42354329..ade05f75fdb0 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -30,7 +30,9 @@
30#include <sound/core.h> 30#include <sound/core.h>
31#include <sound/control.h> 31#include <sound/control.h>
32#include <sound/pcm.h> 32#include <sound/pcm.h>
33#include <sound/pcm_params.h>
33#include <sound/initval.h> 34#include <sound/initval.h>
35#include <linux/interrupt.h>
34 36
35#include "saa7134.h" 37#include "saa7134.h"
36#include "saa7134-reg.h" 38#include "saa7134-reg.h"
@@ -49,6 +51,7 @@ MODULE_PARM_DESC(debug,"enable debug messages [alsa]");
49#define MIXER_ADDR_LINE2 2 51#define MIXER_ADDR_LINE2 2
50#define MIXER_ADDR_LAST 2 52#define MIXER_ADDR_LAST 2
51 53
54
52static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 55static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
53static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 56static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
54static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0}; 57static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
@@ -57,18 +60,21 @@ module_param_array(index, int, NULL, 0444);
57MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s)."); 60MODULE_PARM_DESC(index, "Index value for SAA7134 capture interface(s).");
58 61
59#define dprintk(fmt, arg...) if (debug) \ 62#define dprintk(fmt, arg...) if (debug) \
60 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ## arg) 63 printk(KERN_DEBUG "%s/alsa: " fmt, dev->name , ##arg)
64
65
61 66
62/* 67/*
63 * Main chip structure 68 * Main chip structure
64 */ 69 */
70
65typedef struct snd_card_saa7134 { 71typedef struct snd_card_saa7134 {
66 snd_card_t *card; 72 snd_card_t *card;
67 spinlock_t mixer_lock; 73 spinlock_t mixer_lock;
68 int mixer_volume[MIXER_ADDR_LAST+1][2]; 74 int mixer_volume[MIXER_ADDR_LAST+1][2];
69 int capture_source[MIXER_ADDR_LAST+1][2]; 75 int capture_source[MIXER_ADDR_LAST+1][2];
70 struct pci_dev *pci; 76 struct pci_dev *pci;
71 struct saa7134_dev *saadev; 77 struct saa7134_dev *dev;
72 78
73 unsigned long iobase; 79 unsigned long iobase;
74 int irq; 80 int irq;
@@ -83,12 +89,10 @@ typedef struct snd_card_saa7134 {
83 */ 89 */
84 90
85typedef struct snd_card_saa7134_pcm { 91typedef struct snd_card_saa7134_pcm {
86 struct saa7134_dev *saadev; 92 struct saa7134_dev *dev;
87 93
88 spinlock_t lock; 94 spinlock_t lock;
89 unsigned int pcm_size; /* buffer size */ 95
90 unsigned int pcm_count; /* bytes per period */
91 unsigned int pcm_bps; /* bytes per second */
92 snd_pcm_substream_t *substream; 96 snd_pcm_substream_t *substream;
93} snd_card_saa7134_pcm_t; 97} snd_card_saa7134_pcm_t;
94 98
@@ -100,13 +104,11 @@ static snd_card_t *snd_saa7134_cards[SNDRV_CARDS];
100 * 104 *
101 * Called when the capture device is released or the buffer overflows 105 * Called when the capture device is released or the buffer overflows
102 * 106 *
103 * - Copied verbatim from saa7134-oss's dsp_dma_stop. Can be dropped 107 * - Copied verbatim from saa7134-oss's dsp_dma_stop.
104 * if we just share dsp_dma_stop and use it here
105 * 108 *
106 */ 109 */
107 110
108static void saa7134_dma_stop(struct saa7134_dev *dev) 111static void saa7134_dma_stop(struct saa7134_dev *dev)
109
110{ 112{
111 dev->dmasound.dma_blk = -1; 113 dev->dmasound.dma_blk = -1;
112 dev->dmasound.dma_running = 0; 114 dev->dmasound.dma_running = 0;
@@ -118,8 +120,7 @@ static void saa7134_dma_stop(struct saa7134_dev *dev)
118 * 120 *
119 * Called when preparing the capture device for use 121 * Called when preparing the capture device for use
120 * 122 *
121 * - Copied verbatim from saa7134-oss's dsp_dma_start. Can be dropped 123 * - Copied verbatim from saa7134-oss's dsp_dma_start.
122 * if we just share dsp_dma_start and use it here
123 * 124 *
124 */ 125 */
125 126
@@ -141,7 +142,8 @@ static void saa7134_dma_start(struct saa7134_dev *dev)
141 * 142 *
142 */ 143 */
143 144
144void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status) 145static void saa7134_irq_alsa_done(struct saa7134_dev *dev,
146 unsigned long status)
145{ 147{
146 int next_blk, reg = 0; 148 int next_blk, reg = 0;
147 149
@@ -170,9 +172,9 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
170 if (dev->dmasound.read_count >= dev->dmasound.blksize * (dev->dmasound.blocks-2)) { 172 if (dev->dmasound.read_count >= dev->dmasound.blksize * (dev->dmasound.blocks-2)) {
171 dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count, 173 dprintk("irq: overrun [full=%d/%d] - Blocks in %d\n",dev->dmasound.read_count,
172 dev->dmasound.bufsize, dev->dmasound.blocks); 174 dev->dmasound.bufsize, dev->dmasound.blocks);
175 spin_unlock(&dev->slock);
173 snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN); 176 snd_pcm_stop(dev->dmasound.substream,SNDRV_PCM_STATE_XRUN);
174 saa7134_dma_stop(dev); 177 return;
175 goto done;
176 } 178 }
177 179
178 /* next block addr */ 180 /* next block addr */
@@ -194,6 +196,7 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
194 snd_pcm_period_elapsed(dev->dmasound.substream); 196 snd_pcm_period_elapsed(dev->dmasound.substream);
195 spin_lock(&dev->slock); 197 spin_lock(&dev->slock);
196 } 198 }
199
197 done: 200 done:
198 spin_unlock(&dev->slock); 201 spin_unlock(&dev->slock);
199 202
@@ -209,7 +212,9 @@ void saa7134_irq_alsa_done(struct saa7134_dev *dev, unsigned long status)
209 212
210static 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)
211{ 214{
212 struct saa7134_dev *dev = (struct saa7134_dev*) dev_id; 215 struct saa7134_dmasound *dmasound = dev_id;
216 struct saa7134_dev *dev = dmasound->priv_data;
217
213 unsigned long report, status; 218 unsigned long report, status;
214 int loop, handled = 0; 219 int loop, handled = 0;
215 220
@@ -248,56 +253,23 @@ static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream,
248 int cmd) 253 int cmd)
249{ 254{
250 snd_pcm_runtime_t *runtime = substream->runtime; 255 snd_pcm_runtime_t *runtime = substream->runtime;
251 snd_card_saa7134_pcm_t *saapcm = runtime->private_data; 256 snd_card_saa7134_pcm_t *pcm = runtime->private_data;
252 struct saa7134_dev *dev=saapcm->saadev; 257 struct saa7134_dev *dev=pcm->dev;
253 int err = 0; 258 int err = 0;
254 259
255 spin_lock_irq(&dev->slock); 260 spin_lock(&dev->slock);
256 if (cmd == SNDRV_PCM_TRIGGER_START) { 261 if (cmd == SNDRV_PCM_TRIGGER_START) {
257 /* start dma */ 262 /* start dma */
258 saa7134_dma_start(dev); 263 saa7134_dma_start(dev);
259 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) { 264 } else if (cmd == SNDRV_PCM_TRIGGER_STOP) {
260 /* stop dma */ 265 /* stop dma */
261 saa7134_dma_stop(dev); 266 saa7134_dma_stop(dev);
262 } else { 267 } else {
263 err = -EINVAL; 268 err = -EINVAL;
264 } 269 }
265 spin_unlock_irq(&dev->slock); 270 spin_unlock(&dev->slock);
266
267 return err;
268}
269
270/*
271 * DMA buffer config
272 *
273 * Sets the values that will later be used as the size of the buffer,
274 * size of the fragments, and total number of fragments.
275 * Must be called during the preparation stage, before memory is
276 * allocated
277 *
278 * - Copied verbatim from saa7134-oss. Can be dropped
279 * if we just share dsp_buffer_conf from OSS.
280 */
281 271
282static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks) 272 return err;
283{
284 if (blksize < 0x100)
285 blksize = 0x100;
286 if (blksize > 0x10000)
287 blksize = 0x10000;
288
289 if (blocks < 2)
290 blocks = 2;
291 if ((blksize * blocks) > 1024*1024)
292 blocks = 1024*1024 / blksize;
293
294 dev->dmasound.blocks = blocks;
295 dev->dmasound.blksize = blksize;
296 dev->dmasound.bufsize = blksize * blocks;
297
298 dprintk("buffer config: %d blocks / %d bytes, %d kB total\n",
299 blocks,blksize,blksize * blocks / 1024);
300 return 0;
301} 273}
302 274
303/* 275/*
@@ -307,16 +279,16 @@ static int dsp_buffer_conf(struct saa7134_dev *dev, int blksize, int blocks)
307 * ALSA, but I was unable to use ALSA's own DMA, and had to force the 279 * ALSA, but I was unable to use ALSA's own DMA, and had to force the
308 * usage of V4L's 280 * usage of V4L's
309 * 281 *
310 * - Copied verbatim from saa7134-oss. Can be dropped 282 * - Copied verbatim from saa7134-oss.
311 * if we just share dsp_buffer_init from OSS. 283 *
312 */ 284 */
313 285
314static int dsp_buffer_init(struct saa7134_dev *dev) 286static int dsp_buffer_init(struct saa7134_dev *dev)
315{ 287{
316 int err; 288 int err;
317 289
318 if (!dev->dmasound.bufsize) 290 BUG_ON(!dev->dmasound.bufsize);
319 BUG(); 291
320 videobuf_dma_init(&dev->dmasound.dma); 292 videobuf_dma_init(&dev->dmasound.dma);
321 err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE, 293 err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE,
322 (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT); 294 (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
@@ -326,6 +298,28 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
326} 298}
327 299
328/* 300/*
301 * DMA buffer release
302 *
303 * Called after closing the device, during snd_card_saa7134_capture_close
304 *
305 */
306
307static int dsp_buffer_free(struct saa7134_dev *dev)
308{
309 if (!dev->dmasound.blksize)
310 BUG();
311
312 videobuf_dma_free(&dev->dmasound.dma);
313
314 dev->dmasound.blocks = 0;
315 dev->dmasound.blksize = 0;
316 dev->dmasound.bufsize = 0;
317
318 return 0;
319}
320
321
322/*
329 * ALSA PCM preparation 323 * ALSA PCM preparation
330 * 324 *
331 * - One of the ALSA capture callbacks. 325 * - One of the ALSA capture callbacks.
@@ -340,84 +334,30 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
340static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) 334static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
341{ 335{
342 snd_pcm_runtime_t *runtime = substream->runtime; 336 snd_pcm_runtime_t *runtime = substream->runtime;
343 int err, bswap, sign; 337 int bswap, sign;
344 u32 fmt, control; 338 u32 fmt, control;
345 snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); 339 snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
346 struct saa7134_dev *dev; 340 struct saa7134_dev *dev;
347 snd_card_saa7134_pcm_t *saapcm = runtime->private_data; 341 snd_card_saa7134_pcm_t *pcm = runtime->private_data;
348 unsigned int bps;
349 unsigned long size;
350 unsigned count;
351 342
352 size = snd_pcm_lib_buffer_bytes(substream); 343 pcm->dev->dmasound.substream = substream;
353 count = snd_pcm_lib_period_bytes(substream);
354
355 saapcm->saadev->dmasound.substream = substream;
356 bps = runtime->rate * runtime->channels;
357 bps *= snd_pcm_format_width(runtime->format);
358 bps /= 8;
359 if (bps <= 0)
360 return -EINVAL;
361 saapcm->pcm_bps = bps;
362 saapcm->pcm_size = snd_pcm_lib_buffer_bytes(substream);
363 saapcm->pcm_count = snd_pcm_lib_period_bytes(substream);
364
365
366 dev=saa7134->saadev;
367
368 dsp_buffer_conf(dev,saapcm->pcm_count,(saapcm->pcm_size/saapcm->pcm_count));
369
370 err = dsp_buffer_init(dev);
371 if (0 != err)
372 goto fail2;
373
374 /* prepare buffer */
375 if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma)))
376 return err;
377 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt)))
378 goto fail1;
379 if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->dmasound.pt,
380 dev->dmasound.dma.sglist,
381 dev->dmasound.dma.sglen,
382 0)))
383 goto fail2;
384 344
345 dev = saa7134->dev;
385 346
386 347 if (snd_pcm_format_width(runtime->format) == 8)
387 switch (runtime->format) {
388 case SNDRV_PCM_FORMAT_U8:
389 case SNDRV_PCM_FORMAT_S8:
390 fmt = 0x00; 348 fmt = 0x00;
391 break; 349 else
392 case SNDRV_PCM_FORMAT_U16_LE:
393 case SNDRV_PCM_FORMAT_U16_BE:
394 case SNDRV_PCM_FORMAT_S16_LE:
395 case SNDRV_PCM_FORMAT_S16_BE:
396 fmt = 0x01; 350 fmt = 0x01;
397 break;
398 default:
399 err = -EINVAL;
400 return 1;
401 }
402 351
403 switch (runtime->format) { 352 if (snd_pcm_format_signed(runtime->format))
404 case SNDRV_PCM_FORMAT_S8:
405 case SNDRV_PCM_FORMAT_S16_LE:
406 case SNDRV_PCM_FORMAT_S16_BE:
407 sign = 1; 353 sign = 1;
408 break; 354 else
409 default:
410 sign = 0; 355 sign = 0;
411 break;
412 }
413 356
414 switch (runtime->format) { 357 if (snd_pcm_format_big_endian(runtime->format))
415 case SNDRV_PCM_FORMAT_U16_BE: 358 bswap = 1;
416 case SNDRV_PCM_FORMAT_S16_BE: 359 else
417 bswap = 1; break; 360 bswap = 0;
418 default:
419 bswap = 0; break;
420 }
421 361
422 switch (dev->pci->device) { 362 switch (dev->pci->device) {
423 case PCI_DEVICE_ID_PHILIPS_SAA7134: 363 case PCI_DEVICE_ID_PHILIPS_SAA7134:
@@ -445,7 +385,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
445 fmt |= 0x04; 385 fmt |= 0x04;
446 saa_writel(SAA7133_NUM_SAMPLES, dev->dmasound.blksize -1); 386 saa_writel(SAA7133_NUM_SAMPLES, dev->dmasound.blksize -1);
447 saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24)); 387 saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210 | (fmt << 24));
448 //saa_writel(SAA7133_AUDIO_CHANNEL, 0x543210);
449 break; 388 break;
450 } 389 }
451 390
@@ -459,12 +398,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
459 if (bswap) 398 if (bswap)
460 control |= SAA7134_RS_CONTROL_BSWAP; 399 control |= SAA7134_RS_CONTROL_BSWAP;
461 400
462 /* I should be able to use runtime->dma_addr in the control
463 byte, but it doesn't work. So I allocate the DMA using the
464 V4L functions, and force ALSA to use that as the DMA area */
465
466 runtime->dma_area = dev->dmasound.dma.vmalloc;
467
468 saa_writel(SAA7134_RS_BA1(6),0); 401 saa_writel(SAA7134_RS_BA1(6),0);
469 saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize); 402 saa_writel(SAA7134_RS_BA2(6),dev->dmasound.blksize);
470 saa_writel(SAA7134_RS_PITCH(6),0); 403 saa_writel(SAA7134_RS_PITCH(6),0);
@@ -473,12 +406,6 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
473 dev->dmasound.rate = runtime->rate; 406 dev->dmasound.rate = runtime->rate;
474 407
475 return 0; 408 return 0;
476 fail2:
477 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
478 fail1:
479 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
480 return err;
481
482 409
483} 410}
484 411
@@ -496,10 +423,8 @@ static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream)
496static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * substream) 423static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * substream)
497{ 424{
498 snd_pcm_runtime_t *runtime = substream->runtime; 425 snd_pcm_runtime_t *runtime = substream->runtime;
499 snd_card_saa7134_pcm_t *saapcm = runtime->private_data; 426 snd_card_saa7134_pcm_t *pcm = runtime->private_data;
500 struct saa7134_dev *dev=saapcm->saadev; 427 struct saa7134_dev *dev=pcm->dev;
501
502
503 428
504 if (dev->dmasound.read_count) { 429 if (dev->dmasound.read_count) {
505 dev->dmasound.read_count -= snd_pcm_lib_period_bytes(substream); 430 dev->dmasound.read_count -= snd_pcm_lib_period_bytes(substream);
@@ -540,9 +465,9 @@ static snd_pcm_hardware_t snd_card_saa7134_capture =
540 465
541static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime) 466static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime)
542{ 467{
543 snd_card_saa7134_pcm_t *saapcm = runtime->private_data; 468 snd_card_saa7134_pcm_t *pcm = runtime->private_data;
544 469
545 kfree(saapcm); 470 kfree(pcm);
546} 471}
547 472
548 473
@@ -552,17 +477,76 @@ static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime)
552 * - One of the ALSA capture callbacks. 477 * - One of the ALSA capture callbacks.
553 * 478 *
554 * Called on initialization, right before the PCM preparation 479 * Called on initialization, right before the PCM preparation
555 * Usually used in ALSA to allocate the DMA, but since we don't use the
556 * ALSA DMA it does nothing
557 * 480 *
558 */ 481 */
559 482
560static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream, 483static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
561 snd_pcm_hw_params_t * hw_params) 484 snd_pcm_hw_params_t * hw_params)
562{ 485{
486 snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
487 struct saa7134_dev *dev;
488 unsigned int period_size, periods;
489 int err;
563 490
564 return 0; 491 period_size = params_period_bytes(hw_params);
492 periods = params_periods(hw_params);
493
494 snd_assert(period_size >= 0x100 && period_size <= 0x10000,
495 return -EINVAL);
496 snd_assert(periods >= 2, return -EINVAL);
497 snd_assert(period_size * periods <= 1024 * 1024, return -EINVAL);
498
499 dev = saa7134->dev;
500
501 if (dev->dmasound.blocks == periods &&
502 dev->dmasound.blksize == period_size)
503 return 0;
565 504
505 /* release the old buffer */
506 if (substream->runtime->dma_area) {
507 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
508 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
509 dsp_buffer_free(dev);
510 substream->runtime->dma_area = NULL;
511 }
512 dev->dmasound.blocks = periods;
513 dev->dmasound.blksize = period_size;
514 dev->dmasound.bufsize = period_size * periods;
515
516 err = dsp_buffer_init(dev);
517 if (0 != err) {
518 dev->dmasound.blocks = 0;
519 dev->dmasound.blksize = 0;
520 dev->dmasound.bufsize = 0;
521 return err;
522 }
523
524 if (0 != (err = videobuf_dma_pci_map(dev->pci, &dev->dmasound.dma))) {
525 dsp_buffer_free(dev);
526 return err;
527 }
528 if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) {
529 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
530 dsp_buffer_free(dev);
531 return err;
532 }
533 if (0 != (err = saa7134_pgtable_build(dev->pci,&dev->dmasound.pt,
534 dev->dmasound.dma.sglist,
535 dev->dmasound.dma.sglen,
536 0))) {
537 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
538 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
539 dsp_buffer_free(dev);
540 return err;
541 }
542
543 /* I should be able to use runtime->dma_addr in the control
544 byte, but it doesn't work. So I allocate the DMA using the
545 V4L functions, and force ALSA to use that as the DMA area */
546
547 substream->runtime->dma_area = dev->dmasound.dma.vmalloc;
548
549 return 1;
566 550
567} 551}
568 552
@@ -572,33 +556,23 @@ static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream,
572 * - One of the ALSA capture callbacks. 556 * - One of the ALSA capture callbacks.
573 * 557 *
574 * Called after closing the device, but before snd_card_saa7134_capture_close 558 * Called after closing the device, but before snd_card_saa7134_capture_close
575 * Usually used in ALSA to free the DMA, but since we don't use the 559 * It stops the DMA audio and releases the buffers.
576 * ALSA DMA I'm almost sure this isn't necessary.
577 * 560 *
578 */ 561 */
579 562
580static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream) 563static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream)
581{ 564{
582 return 0; 565 snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
583} 566 struct saa7134_dev *dev;
584
585/*
586 * DMA buffer release
587 *
588 * Called after closing the device, during snd_card_saa7134_capture_close
589 *
590 */
591 567
592static int dsp_buffer_free(struct saa7134_dev *dev) 568 dev = saa7134->dev;
593{
594 if (!dev->dmasound.blksize)
595 BUG();
596 569
597 videobuf_dma_free(&dev->dmasound.dma); 570 if (substream->runtime->dma_area) {
598 571 saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
599 dev->dmasound.blocks = 0; 572 videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
600 dev->dmasound.blksize = 0; 573 dsp_buffer_free(dev);
601 dev->dmasound.bufsize = 0; 574 substream->runtime->dma_area = NULL;
575 }
602 576
603 return 0; 577 return 0;
604} 578}
@@ -608,21 +582,12 @@ static int dsp_buffer_free(struct saa7134_dev *dev)
608 * 582 *
609 * - One of the ALSA capture callbacks. 583 * - One of the ALSA capture callbacks.
610 * 584 *
611 * Called after closing the device. It stops the DMA audio and releases 585 * Called after closing the device.
612 * the buffers
613 * 586 *
614 */ 587 */
615 588
616static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream) 589static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream)
617{ 590{
618 snd_card_saa7134_t *chip = snd_pcm_substream_chip(substream);
619 struct saa7134_dev *dev = chip->saadev;
620
621 /* unlock buffer */
622 saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
623 videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
624
625 dsp_buffer_free(dev);
626 return 0; 591 return 0;
627} 592}
628 593
@@ -639,29 +604,28 @@ static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream)
639static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream) 604static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream)
640{ 605{
641 snd_pcm_runtime_t *runtime = substream->runtime; 606 snd_pcm_runtime_t *runtime = substream->runtime;
642 snd_card_saa7134_pcm_t *saapcm; 607 snd_card_saa7134_pcm_t *pcm;
643 snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); 608 snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream);
644 struct saa7134_dev *dev = saa7134->saadev; 609 struct saa7134_dev *dev = saa7134->dev;
645 int err; 610 int err;
646 611
647 down(&dev->dmasound.lock); 612 down(&dev->dmasound.lock);
648 613
649 dev->dmasound.afmt = SNDRV_PCM_FORMAT_U8;
650 dev->dmasound.channels = 2;
651 dev->dmasound.read_count = 0; 614 dev->dmasound.read_count = 0;
652 dev->dmasound.read_offset = 0; 615 dev->dmasound.read_offset = 0;
653 616
654 up(&dev->dmasound.lock); 617 up(&dev->dmasound.lock);
655 618
656 saapcm = kzalloc(sizeof(*saapcm), GFP_KERNEL); 619 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL);
657 if (saapcm == NULL) 620 if (pcm == NULL)
658 return -ENOMEM; 621 return -ENOMEM;
659 saapcm->saadev=saa7134->saadev;
660 622
661 spin_lock_init(&saapcm->lock); 623 pcm->dev=saa7134->dev;
624
625 spin_lock_init(&pcm->lock);
662 626
663 saapcm->substream = substream; 627 pcm->substream = substream;
664 runtime->private_data = saapcm; 628 runtime->private_data = pcm;
665 runtime->private_free = snd_card_saa7134_runtime_free; 629 runtime->private_free = snd_card_saa7134_runtime_free;
666 runtime->hw = snd_card_saa7134_capture; 630 runtime->hw = snd_card_saa7134_capture;
667 631
@@ -736,7 +700,6 @@ static int snd_saa7134_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
736static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 700static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
737{ 701{
738 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); 702 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
739 unsigned long flags;
740 int change, addr = kcontrol->private_value; 703 int change, addr = kcontrol->private_value;
741 int left, right; 704 int left, right;
742 705
@@ -750,12 +713,12 @@ static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_
750 right = 0; 713 right = 0;
751 if (right > 20) 714 if (right > 20)
752 right = 20; 715 right = 20;
753 spin_lock_irqsave(&chip->mixer_lock, flags); 716 spin_lock_irq(&chip->mixer_lock);
754 change = chip->mixer_volume[addr][0] != left || 717 change = chip->mixer_volume[addr][0] != left ||
755 chip->mixer_volume[addr][1] != right; 718 chip->mixer_volume[addr][1] != right;
756 chip->mixer_volume[addr][0] = left; 719 chip->mixer_volume[addr][0] = left;
757 chip->mixer_volume[addr][1] = right; 720 chip->mixer_volume[addr][1] = right;
758 spin_unlock_irqrestore(&chip->mixer_lock, flags); 721 spin_unlock_irq(&chip->mixer_lock);
759 return change; 722 return change;
760} 723}
761 724
@@ -777,38 +740,37 @@ static int snd_saa7134_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_
777static int snd_saa7134_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 740static int snd_saa7134_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
778{ 741{
779 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); 742 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
780 unsigned long flags;
781 int addr = kcontrol->private_value; 743 int addr = kcontrol->private_value;
782 744
783 spin_lock_irqsave(&chip->mixer_lock, flags); 745 spin_lock_irq(&chip->mixer_lock);
784 ucontrol->value.integer.value[0] = chip->capture_source[addr][0]; 746 ucontrol->value.integer.value[0] = chip->capture_source[addr][0];
785 ucontrol->value.integer.value[1] = chip->capture_source[addr][1]; 747 ucontrol->value.integer.value[1] = chip->capture_source[addr][1];
786 spin_unlock_irqrestore(&chip->mixer_lock, flags); 748 spin_unlock_irq(&chip->mixer_lock);
749
787 return 0; 750 return 0;
788} 751}
789 752
790static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) 753static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol)
791{ 754{
792 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); 755 snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol);
793 unsigned long flags;
794 int change, addr = kcontrol->private_value; 756 int change, addr = kcontrol->private_value;
795 int left, right; 757 int left, right;
796 u32 anabar, xbarin; 758 u32 anabar, xbarin;
797 int analog_io, rate; 759 int analog_io, rate;
798 struct saa7134_dev *dev; 760 struct saa7134_dev *dev;
799 761
800 dev = chip->saadev; 762 dev = chip->dev;
801 763
802 left = ucontrol->value.integer.value[0] & 1; 764 left = ucontrol->value.integer.value[0] & 1;
803 right = ucontrol->value.integer.value[1] & 1; 765 right = ucontrol->value.integer.value[1] & 1;
804 spin_lock_irqsave(&chip->mixer_lock, flags); 766 spin_lock_irq(&chip->mixer_lock);
805 767
806 change = chip->capture_source[addr][0] != left || 768 change = chip->capture_source[addr][0] != left ||
807 chip->capture_source[addr][1] != right; 769 chip->capture_source[addr][1] != right;
808 chip->capture_source[addr][0] = left; 770 chip->capture_source[addr][0] = left;
809 chip->capture_source[addr][1] = right; 771 chip->capture_source[addr][1] = right;
810 dev->dmasound.input=addr; 772 dev->dmasound.input=addr;
811 spin_unlock_irqrestore(&chip->mixer_lock, flags); 773 spin_unlock_irq(&chip->mixer_lock);
812 774
813 775
814 if (change) { 776 if (change) {
@@ -898,43 +860,44 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip)
898 return 0; 860 return 0;
899} 861}
900 862
901static int snd_saa7134_free(snd_card_saa7134_t *chip) 863static void snd_saa7134_free(snd_card_t * card)
902{ 864{
903 return 0; 865 snd_card_saa7134_t *chip = card->private_data;
904} 866
867 if (chip->dev->dmasound.priv_data == NULL)
868 return;
869
870 if (chip->irq >= 0) {
871 synchronize_irq(chip->irq);
872 free_irq(chip->irq, &chip->dev->dmasound);
873 }
874
875 chip->dev->dmasound.priv_data = NULL;
905 876
906static int snd_saa7134_dev_free(snd_device_t *device)
907{
908 snd_card_saa7134_t *chip = device->device_data;
909 return snd_saa7134_free(chip);
910} 877}
911 878
912/* 879/*
913 * ALSA initialization 880 * ALSA initialization
914 * 881 *
915 * Called by saa7134-core, it creates the basic structures and registers 882 * Called by the init routine, once for each saa7134 device present,
916 * the ALSA devices 883 * it creates the basic structures and registers the ALSA devices
917 * 884 *
918 */ 885 */
919 886
920int alsa_card_saa7134_create (struct saa7134_dev *saadev) 887static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum)
921{ 888{
922 static int dev;
923 889
924 snd_card_t *card; 890 snd_card_t *card;
925 snd_card_saa7134_t *chip; 891 snd_card_saa7134_t *chip;
926 int err; 892 int err;
927 static snd_device_ops_t ops = {
928 .dev_free = snd_saa7134_dev_free,
929 };
930 893
931 894
932 if (dev >= SNDRV_CARDS) 895 if (devnum >= SNDRV_CARDS)
933 return -ENODEV; 896 return -ENODEV;
934 if (!enable[dev]) 897 if (!enable[devnum])
935 return -ENODEV; 898 return -ENODEV;
936 899
937 card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); 900 card = snd_card_new(index[devnum], id[devnum], THIS_MODULE, sizeof(snd_card_saa7134_t));
938 901
939 if (card == NULL) 902 if (card == NULL)
940 return -ENOMEM; 903 return -ENOMEM;
@@ -943,34 +906,33 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev)
943 906
944 /* Card "creation" */ 907 /* Card "creation" */
945 908
946 chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); 909 card->private_free = snd_saa7134_free;
947 if (chip == NULL) { 910 chip = (snd_card_saa7134_t *) card->private_data;
948 return -ENOMEM;
949 }
950 911
951 spin_lock_init(&chip->lock); 912 spin_lock_init(&chip->lock);
952 spin_lock_init(&chip->mixer_lock); 913 spin_lock_init(&chip->mixer_lock);
953 914
954 chip->saadev = saadev; 915 chip->dev = dev;
955 916
956 chip->card = card; 917 chip->card = card;
957 918
958 chip->pci = saadev->pci; 919 chip->pci = dev->pci;
959 chip->irq = saadev->pci->irq; 920 chip->iobase = pci_resource_start(dev->pci, 0);
960 chip->iobase = pci_resource_start(saadev->pci, 0);
961 921
962 err = request_irq(saadev->pci->irq, saa7134_alsa_irq, 922
963 SA_SHIRQ | SA_INTERRUPT, saadev->name, saadev); 923 err = request_irq(dev->pci->irq, saa7134_alsa_irq,
924 SA_SHIRQ | SA_INTERRUPT, dev->name,
925 (void*) &dev->dmasound);
964 926
965 if (err < 0) { 927 if (err < 0) {
966 printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n", 928 printk(KERN_ERR "%s: can't get IRQ %d for ALSA\n",
967 saadev->name, saadev->pci->irq); 929 dev->name, dev->pci->irq);
968 goto __nodev; 930 goto __nodev;
969 } 931 }
970 932
971 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { 933 chip->irq = dev->pci->irq;
972 goto __nodev; 934
973 } 935 init_MUTEX(&dev->dmasound.lock);
974 936
975 if ((err = snd_card_saa7134_new_mixer(chip)) < 0) 937 if ((err = snd_card_saa7134_new_mixer(chip)) < 0)
976 goto __nodev; 938 goto __nodev;
@@ -984,19 +946,36 @@ int alsa_card_saa7134_create (struct saa7134_dev *saadev)
984 946
985 strcpy(card->shortname, "SAA7134"); 947 strcpy(card->shortname, "SAA7134");
986 sprintf(card->longname, "%s at 0x%lx irq %d", 948 sprintf(card->longname, "%s at 0x%lx irq %d",
987 chip->saadev->name, chip->iobase, chip->irq); 949 chip->dev->name, chip->iobase, chip->irq);
950
951 printk(KERN_INFO "%s/alsa: %s registered as card %d\n",dev->name,card->longname,index[devnum]);
988 952
989 if ((err = snd_card_register(card)) == 0) { 953 if ((err = snd_card_register(card)) == 0) {
990 snd_saa7134_cards[dev] = card; 954 snd_saa7134_cards[devnum] = card;
991 return 0; 955 return 0;
992 } 956 }
993 957
994__nodev: 958__nodev:
995 snd_card_free(card); 959 snd_card_free(card);
996 kfree(chip);
997 return err; 960 return err;
998} 961}
999 962
963
964static int alsa_device_init(struct saa7134_dev *dev)
965{
966 dev->dmasound.priv_data = dev;
967 alsa_card_saa7134_create(dev,dev->nr);
968 return 1;
969}
970
971static int alsa_device_exit(struct saa7134_dev *dev)
972{
973
974 snd_card_free(snd_saa7134_cards[dev->nr]);
975 snd_saa7134_cards[dev->nr] = NULL;
976 return 1;
977}
978
1000/* 979/*
1001 * Module initializer 980 * Module initializer
1002 * 981 *
@@ -1007,17 +986,30 @@ __nodev:
1007 986
1008static int saa7134_alsa_init(void) 987static int saa7134_alsa_init(void)
1009{ 988{
1010 struct saa7134_dev *saadev = NULL; 989 struct saa7134_dev *dev = NULL;
1011 struct list_head *list; 990 struct list_head *list;
991
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 }
1012 999
1013 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n"); 1000 printk(KERN_INFO "saa7134 ALSA driver for DMA sound loaded\n");
1014 1001
1015 list_for_each(list,&saa7134_devlist) { 1002 list_for_each(list,&saa7134_devlist) {
1016 saadev = list_entry(list, struct saa7134_dev, devlist); 1003 dev = list_entry(list, struct saa7134_dev, devlist);
1017 alsa_card_saa7134_create(saadev); 1004 if (dev->dmasound.priv_data == NULL) {
1018 } 1005 alsa_device_init(dev);
1006 } else {
1007 printk(KERN_ERR "saa7134 ALSA: DMA sound is being handled by OSS. ignoring %s\n",dev->name);
1008 return -EBUSY;
1009 }
1010 }
1019 1011
1020 if (saadev == NULL) 1012 if (dev == NULL)
1021 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n"); 1013 printk(KERN_INFO "saa7134 ALSA: no saa7134 cards found\n");
1022 1014
1023 return 0; 1015 return 0;
@@ -1028,7 +1020,7 @@ static int saa7134_alsa_init(void)
1028 * Module destructor 1020 * Module destructor
1029 */ 1021 */
1030 1022
1031void saa7134_alsa_exit(void) 1023static void saa7134_alsa_exit(void)
1032{ 1024{
1033 int idx; 1025 int idx;
1034 1026
@@ -1036,12 +1028,18 @@ void saa7134_alsa_exit(void)
1036 snd_card_free(snd_saa7134_cards[idx]); 1028 snd_card_free(snd_saa7134_cards[idx]);
1037 } 1029 }
1038 1030
1031 dmasound_init = NULL;
1032 dmasound_exit = NULL;
1039 printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n"); 1033 printk(KERN_INFO "saa7134 ALSA driver for DMA sound unloaded\n");
1040 1034
1041 return; 1035 return;
1042} 1036}
1043 1037
1044module_init(saa7134_alsa_init); 1038/* We initialize this late, to make sure the sound system is up and running */
1039late_initcall(saa7134_alsa_init);
1045module_exit(saa7134_alsa_exit); 1040module_exit(saa7134_alsa_exit);
1046MODULE_LICENSE("GPL"); 1041MODULE_LICENSE("GPL");
1047MODULE_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 663d03e5bc67..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,
@@ -2529,6 +2529,32 @@ struct saa7134_board saa7134_boards[] = {
2529 .amux = LINE1, 2529 .amux = LINE1,
2530 }}, 2530 }},
2531 }, 2531 },
2532 [SAA7134_BOARD_MSI_TVATANYWHERE_PLUS] = {
2533 .name = "MSI TV@Anywhere plus",
2534 .audio_clock = 0x00187de7,
2535 .tuner_type = TUNER_PHILIPS_TDA8290,
2536 .radio_type = UNSET,
2537 .tuner_addr = ADDR_UNSET,
2538 .radio_addr = ADDR_UNSET,
2539 .inputs = {{
2540 .name = name_tv,
2541 .vmux = 1,
2542 .amux = TV,
2543 .tv = 1,
2544 },{
2545 .name = name_comp1,
2546 .vmux = 3,
2547 .amux = LINE1,
2548 },{
2549 .name = name_svideo,
2550 .vmux = 0,
2551 .amux = LINE1,
2552 }},
2553 .radio = {
2554 .name = name_radio,
2555 .amux = LINE1,
2556 },
2557 },
2532}; 2558};
2533 2559
2534const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards); 2560const unsigned int saa7134_bcount = ARRAY_SIZE(saa7134_boards);
@@ -2970,6 +2996,12 @@ struct pci_device_id saa7134_pci_tbl[] = {
2970 .subdevice = 0x2018, 2996 .subdevice = 0x2018,
2971 .driver_data = SAA7134_BOARD_PHILIPS_TIGER, 2997 .driver_data = SAA7134_BOARD_PHILIPS_TIGER,
2972 },{ 2998 },{
2999 .vendor = PCI_VENDOR_ID_PHILIPS,
3000 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
3001 .subvendor = 0x1462,
3002 .subdevice = 0x6231,
3003 .driver_data = SAA7134_BOARD_MSI_TVATANYWHERE_PLUS,
3004 },{
2973 /* --- boards without eeprom + subsystem ID --- */ 3005 /* --- boards without eeprom + subsystem ID --- */
2974 .vendor = PCI_VENDOR_ID_PHILIPS, 3006 .vendor = PCI_VENDOR_ID_PHILIPS,
2975 .device = PCI_DEVICE_ID_PHILIPS_SAA7134, 3007 .device = PCI_DEVICE_ID_PHILIPS_SAA7134,
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 19b88744fb31..23d8747338ed 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -53,13 +53,13 @@ static unsigned int gpio_tracking = 0;
53module_param(gpio_tracking, int, 0644); 53module_param(gpio_tracking, int, 0644);
54MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]"); 54MODULE_PARM_DESC(gpio_tracking,"enable debug messages [gpio]");
55 55
56static unsigned int oss = 0;
57module_param(oss, int, 0444);
58MODULE_PARM_DESC(oss,"register oss devices (default: no)");
59
60static unsigned int alsa = 0; 56static unsigned int alsa = 0;
61module_param(alsa, int, 0444); 57module_param(alsa, int, 0644);
62MODULE_PARM_DESC(alsa,"register alsa devices (default: no)"); 58MODULE_PARM_DESC(alsa,"enable ALSA DMA sound [dmasound]");
59
60static unsigned int oss = 0;
61module_param(oss, int, 0644);
62MODULE_PARM_DESC(oss,"enable OSS DMA sound [dmasound]");
63 63
64static unsigned int latency = UNSET; 64static unsigned int latency = UNSET;
65module_param(latency, int, 0444); 65module_param(latency, int, 0444);
@@ -68,24 +68,19 @@ MODULE_PARM_DESC(latency,"pci latency timer");
68static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 68static unsigned int video_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
69static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 69static unsigned int vbi_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
70static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 70static unsigned int radio_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
71static unsigned int dsp_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
72static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
73static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 71static unsigned int tuner[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
74static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET }; 72static unsigned int card[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
75 73
74
76module_param_array(video_nr, int, NULL, 0444); 75module_param_array(video_nr, int, NULL, 0444);
77module_param_array(vbi_nr, int, NULL, 0444); 76module_param_array(vbi_nr, int, NULL, 0444);
78module_param_array(radio_nr, int, NULL, 0444); 77module_param_array(radio_nr, int, NULL, 0444);
79module_param_array(dsp_nr, int, NULL, 0444);
80module_param_array(mixer_nr, int, NULL, 0444);
81module_param_array(tuner, int, NULL, 0444); 78module_param_array(tuner, int, NULL, 0444);
82module_param_array(card, int, NULL, 0444); 79module_param_array(card, int, NULL, 0444);
83 80
84MODULE_PARM_DESC(video_nr, "video device number"); 81MODULE_PARM_DESC(video_nr, "video device number");
85MODULE_PARM_DESC(vbi_nr, "vbi device number"); 82MODULE_PARM_DESC(vbi_nr, "vbi device number");
86MODULE_PARM_DESC(radio_nr, "radio device number"); 83MODULE_PARM_DESC(radio_nr, "radio device number");
87MODULE_PARM_DESC(dsp_nr, "oss dsp device number");
88MODULE_PARM_DESC(mixer_nr, "oss mixer device number");
89MODULE_PARM_DESC(tuner, "tuner type"); 84MODULE_PARM_DESC(tuner, "tuner type");
90MODULE_PARM_DESC(card, "card type"); 85MODULE_PARM_DESC(card, "card type");
91 86
@@ -94,6 +89,9 @@ LIST_HEAD(saa7134_devlist);
94static LIST_HEAD(mops_list); 89static LIST_HEAD(mops_list);
95static unsigned int saa7134_devcount; 90static unsigned int saa7134_devcount;
96 91
92int (*dmasound_init)(struct saa7134_dev *dev);
93int (*dmasound_exit)(struct saa7134_dev *dev);
94
97#define dprintk(fmt, arg...) if (core_debug) \ 95#define dprintk(fmt, arg...) if (core_debug) \
98 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg) 96 printk(KERN_DEBUG "%s/core: " fmt, dev->name , ## arg)
99 97
@@ -190,11 +188,11 @@ void saa7134_track_gpio(struct saa7134_dev *dev, char *msg)
190/* ----------------------------------------------------------- */ 188/* ----------------------------------------------------------- */
191/* delayed request_module */ 189/* delayed request_module */
192 190
193#ifdef CONFIG_MODULES 191#if defined(CONFIG_MODULES) && defined(MODULE)
194
195static int need_empress; 192static int need_empress;
196static int need_dvb; 193static int need_dvb;
197static int need_alsa; 194static int need_alsa;
195static int need_oss;
198 196
199static int pending_call(struct notifier_block *self, unsigned long state, 197static int pending_call(struct notifier_block *self, unsigned long state,
200 void *module) 198 void *module)
@@ -208,6 +206,8 @@ static int pending_call(struct notifier_block *self, unsigned long state,
208 request_module("saa7134-dvb"); 206 request_module("saa7134-dvb");
209 if (need_alsa) 207 if (need_alsa)
210 request_module("saa7134-alsa"); 208 request_module("saa7134-alsa");
209 if (need_oss)
210 request_module("saa7134-oss");
211 return NOTIFY_DONE; 211 return NOTIFY_DONE;
212} 212}
213 213
@@ -218,10 +218,11 @@ static struct notifier_block pending_notifier = {
218 218
219static void request_module_depend(char *name, int *flag) 219static void request_module_depend(char *name, int *flag)
220{ 220{
221 int err;
221 switch (THIS_MODULE->state) { 222 switch (THIS_MODULE->state) {
222 case MODULE_STATE_COMING: 223 case MODULE_STATE_COMING:
223 if (!pending_registered) { 224 if (!pending_registered) {
224 register_module_notifier(&pending_notifier); 225 err = register_module_notifier(&pending_notifier);
225 pending_registered = 1; 226 pending_registered = 1;
226 } 227 }
227 *flag = 1; 228 *flag = 1;
@@ -236,9 +237,7 @@ static void request_module_depend(char *name, int *flag)
236} 237}
237 238
238#else 239#else
239
240#define request_module_depend(name,flag) 240#define request_module_depend(name,flag)
241
242#endif /* CONFIG_MODULES */ 241#endif /* CONFIG_MODULES */
243 242
244/* ------------------------------------------------------------------ */ 243/* ------------------------------------------------------------------ */
@@ -578,12 +577,14 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
578 goto out; 577 goto out;
579 } 578 }
580 579
581 /* If alsa support is active and we get a sound report, exit 580 /* If dmasound support is active and we get a sound report, exit
582 and let the saa7134-alsa module deal with it */ 581 and let the saa7134-alsa/oss module deal with it */
583 582
584 if ((report & SAA7134_IRQ_REPORT_DONE_RA3) && alsa) { 583 if ((report & SAA7134_IRQ_REPORT_DONE_RA3) &&
584 (dev->dmasound.priv_data != NULL) )
585 {
585 if (irq_debug > 1) 586 if (irq_debug > 1)
586 printk(KERN_DEBUG "%s/irq: ignoring interrupt for ALSA\n", 587 printk(KERN_DEBUG "%s/irq: ignoring interrupt for DMA sound\n",
587 dev->name); 588 dev->name);
588 goto out; 589 goto out;
589 } 590 }
@@ -609,12 +610,6 @@ static irqreturn_t saa7134_irq(int irq, void *dev_id, struct pt_regs *regs)
609 card_has_mpeg(dev)) 610 card_has_mpeg(dev))
610 saa7134_irq_ts_done(dev,status); 611 saa7134_irq_ts_done(dev,status);
611 612
612 if ((report & SAA7134_IRQ_REPORT_DONE_RA3)) {
613 if (oss) {
614 saa7134_irq_oss_done(dev,status);
615 }
616 }
617
618 if ((report & (SAA7134_IRQ_REPORT_GPIO16 | 613 if ((report & (SAA7134_IRQ_REPORT_GPIO16 |
619 SAA7134_IRQ_REPORT_GPIO18)) && 614 SAA7134_IRQ_REPORT_GPIO18)) &&
620 dev->remote) 615 dev->remote)
@@ -689,14 +684,6 @@ static int saa7134_hwinit1(struct saa7134_dev *dev)
689 * audio will not work. 684 * audio will not work.
690 */ 685 */
691 686
692 switch (dev->pci->device) {
693 case PCI_DEVICE_ID_PHILIPS_SAA7134:
694 case PCI_DEVICE_ID_PHILIPS_SAA7133:
695 case PCI_DEVICE_ID_PHILIPS_SAA7135:
696 saa7134_oss_init1(dev);
697 break;
698 }
699
700 /* enable peripheral devices */ 687 /* enable peripheral devices */
701 saa_writeb(SAA7134_SPECIAL_MODE, 0x01); 688 saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
702 689
@@ -728,8 +715,6 @@ static int saa7134_hwinit2(struct saa7134_dev *dev)
728 irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 | 715 irq2_mask |= (SAA7134_IRQ2_INTE_GPIO18 |
729 SAA7134_IRQ2_INTE_GPIO18A | 716 SAA7134_IRQ2_INTE_GPIO18A |
730 SAA7134_IRQ2_INTE_GPIO16 ); 717 SAA7134_IRQ2_INTE_GPIO16 );
731 else if (dev->has_remote == SAA7134_REMOTE_I2C)
732 request_module("ir-kbd-i2c");
733 718
734 saa_writel(SAA7134_IRQ1, 0); 719 saa_writel(SAA7134_IRQ1, 0);
735 saa_writel(SAA7134_IRQ2, irq2_mask); 720 saa_writel(SAA7134_IRQ2, irq2_mask);
@@ -742,13 +727,6 @@ static int saa7134_hwfini(struct saa7134_dev *dev)
742{ 727{
743 dprintk("hwfini\n"); 728 dprintk("hwfini\n");
744 729
745 switch (dev->pci->device) {
746 case PCI_DEVICE_ID_PHILIPS_SAA7134:
747 case PCI_DEVICE_ID_PHILIPS_SAA7133:
748 case PCI_DEVICE_ID_PHILIPS_SAA7135:
749 saa7134_oss_fini(dev);
750 break;
751 }
752 if (card_has_mpeg(dev)) 730 if (card_has_mpeg(dev))
753 saa7134_ts_fini(dev); 731 saa7134_ts_fini(dev);
754 saa7134_input_fini(dev); 732 saa7134_input_fini(dev);
@@ -986,11 +964,12 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
986 if (card_is_dvb(dev)) 964 if (card_is_dvb(dev))
987 request_module_depend("saa7134-dvb",&need_dvb); 965 request_module_depend("saa7134-dvb",&need_dvb);
988 966
989 if (!oss && alsa) { 967
990 dprintk("Requesting ALSA module\n"); 968 if (alsa)
991 request_module_depend("saa7134-alsa",&need_alsa); 969 request_module_depend("saa7134-alsa",&need_alsa);
992 }
993 970
971 if (oss)
972 request_module_depend("saa7134-oss",&need_oss);
994 973
995 v4l2_prio_init(&dev->prio); 974 v4l2_prio_init(&dev->prio);
996 975
@@ -1024,32 +1003,6 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1024 dev->name,dev->radio_dev->minor & 0x1f); 1003 dev->name,dev->radio_dev->minor & 0x1f);
1025 } 1004 }
1026 1005
1027 /* register oss devices */
1028 switch (dev->pci->device) {
1029 case PCI_DEVICE_ID_PHILIPS_SAA7134:
1030 case PCI_DEVICE_ID_PHILIPS_SAA7133:
1031 case PCI_DEVICE_ID_PHILIPS_SAA7135:
1032 if (oss) {
1033 err = dev->dmasound.minor_dsp =
1034 register_sound_dsp(&saa7134_dsp_fops,
1035 dsp_nr[dev->nr]);
1036 if (err < 0) {
1037 goto fail4;
1038 }
1039 printk(KERN_INFO "%s: registered device dsp%d\n",
1040 dev->name,dev->dmasound.minor_dsp >> 4);
1041
1042 err = dev->dmasound.minor_mixer =
1043 register_sound_mixer(&saa7134_mixer_fops,
1044 mixer_nr[dev->nr]);
1045 if (err < 0)
1046 goto fail5;
1047 printk(KERN_INFO "%s: registered device mixer%d\n",
1048 dev->name,dev->dmasound.minor_mixer >> 4);
1049 }
1050 break;
1051 }
1052
1053 /* everything worked */ 1006 /* everything worked */
1054 pci_set_drvdata(pci_dev,dev); 1007 pci_set_drvdata(pci_dev,dev);
1055 saa7134_devcount++; 1008 saa7134_devcount++;
@@ -1064,17 +1017,13 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
1064 1017
1065 /* check for signal */ 1018 /* check for signal */
1066 saa7134_irq_video_intl(dev); 1019 saa7134_irq_video_intl(dev);
1067 return 0;
1068 1020
1069 fail5: 1021 if (dmasound_init && !dev->dmasound.priv_data) {
1070 switch (dev->pci->device) { 1022 dmasound_init(dev);
1071 case PCI_DEVICE_ID_PHILIPS_SAA7134:
1072 case PCI_DEVICE_ID_PHILIPS_SAA7133:
1073 case PCI_DEVICE_ID_PHILIPS_SAA7135:
1074 if (oss)
1075 unregister_sound_dsp(dev->dmasound.minor_dsp);
1076 break;
1077 } 1023 }
1024
1025 return 0;
1026
1078 fail4: 1027 fail4:
1079 saa7134_unregister_video(dev); 1028 saa7134_unregister_video(dev);
1080 saa7134_i2c_unregister(dev); 1029 saa7134_i2c_unregister(dev);
@@ -1096,6 +1045,11 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1096 struct list_head *item; 1045 struct list_head *item;
1097 struct saa7134_mpeg_ops *mops; 1046 struct saa7134_mpeg_ops *mops;
1098 1047
1048 /* Release DMA sound modules if present */
1049 if (dmasound_exit && dev->dmasound.priv_data) {
1050 dmasound_exit(dev);
1051 }
1052
1099 /* debugging ... */ 1053 /* debugging ... */
1100 if (irq_debug) { 1054 if (irq_debug) {
1101 u32 report = saa_readl(SAA7134_IRQ_REPORT); 1055 u32 report = saa_readl(SAA7134_IRQ_REPORT);
@@ -1125,19 +1079,18 @@ static void __devexit saa7134_finidev(struct pci_dev *pci_dev)
1125 saa7134_devcount--; 1079 saa7134_devcount--;
1126 1080
1127 saa7134_i2c_unregister(dev); 1081 saa7134_i2c_unregister(dev);
1128 switch (dev->pci->device) {
1129 case PCI_DEVICE_ID_PHILIPS_SAA7134:
1130 case PCI_DEVICE_ID_PHILIPS_SAA7133:
1131 case PCI_DEVICE_ID_PHILIPS_SAA7135:
1132 if (oss) {
1133 unregister_sound_mixer(dev->dmasound.minor_mixer);
1134 unregister_sound_dsp(dev->dmasound.minor_dsp);
1135 }
1136 break;
1137 }
1138 saa7134_unregister_video(dev); 1082 saa7134_unregister_video(dev);
1139 1083
1140 /* release ressources */ 1084
1085 /* the DMA sound modules should be unloaded before reaching
1086 this, but just in case they are still present... */
1087 if (dev->dmasound.priv_data != NULL) {
1088 free_irq(pci_dev->irq, &dev->dmasound);
1089 dev->dmasound.priv_data = NULL;
1090 }
1091
1092
1093 /* release resources */
1141 free_irq(pci_dev->irq, dev); 1094 free_irq(pci_dev->irq, dev);
1142 iounmap(dev->lmmio); 1095 iounmap(dev->lmmio);
1143 release_mem_region(pci_resource_start(pci_dev,0), 1096 release_mem_region(pci_resource_start(pci_dev,0),
@@ -1208,10 +1161,10 @@ static int saa7134_init(void)
1208 1161
1209static void saa7134_fini(void) 1162static void saa7134_fini(void)
1210{ 1163{
1211#ifdef CONFIG_MODULES 1164#if defined(CONFIG_MODULES) && defined(MODULE)
1212 if (pending_registered) 1165 if (pending_registered)
1213 unregister_module_notifier(&pending_notifier); 1166 unregister_module_notifier(&pending_notifier);
1214#endif 1167#endif /* CONFIG_MODULES */
1215 pci_unregister_driver(&saa7134_pci_driver); 1168 pci_unregister_driver(&saa7134_pci_driver);
1216} 1169}
1217 1170
@@ -1225,8 +1178,10 @@ EXPORT_SYMBOL(saa7134_i2c_call_clients);
1225EXPORT_SYMBOL(saa7134_devlist); 1178EXPORT_SYMBOL(saa7134_devlist);
1226EXPORT_SYMBOL(saa7134_boards); 1179EXPORT_SYMBOL(saa7134_boards);
1227 1180
1228/* ----------------- For ALSA -------------------------------- */ 1181/* ----------------- for the DMA sound modules --------------- */
1229 1182
1183EXPORT_SYMBOL(dmasound_init);
1184EXPORT_SYMBOL(dmasound_exit);
1230EXPORT_SYMBOL(saa7134_pgtable_free); 1185EXPORT_SYMBOL(saa7134_pgtable_free);
1231EXPORT_SYMBOL(saa7134_pgtable_build); 1186EXPORT_SYMBOL(saa7134_pgtable_build);
1232EXPORT_SYMBOL(saa7134_pgtable_alloc); 1187EXPORT_SYMBOL(saa7134_pgtable_alloc);
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..df9dd36721e0 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->name, client->addr, client->name);
337 337
338 /* Am I an i2c remote control? */ 338 /* Am I an i2c remote control? */
339 339
diff --git a/drivers/media/video/saa7134/saa7134-input.c b/drivers/media/video/saa7134/saa7134-input.c
index 329accda6d45..ab75ca5ac356 100644
--- a/drivers/media/video/saa7134/saa7134-input.c
+++ b/drivers/media/video/saa7134/saa7134-input.c
@@ -485,64 +485,6 @@ static IR_KEYTAB_TYPE ir_codes_purpletv[IR_KEYTAB_SIZE] = {
485 485
486}; 486};
487 487
488static IR_KEYTAB_TYPE ir_codes_pinnacle[IR_KEYTAB_SIZE] = {
489 [ 0x59 ] = KEY_MUTE,
490 [ 0x4a ] = KEY_POWER,
491
492 [ 0x18 ] = KEY_TEXT,
493 [ 0x26 ] = KEY_TV,
494 [ 0x3d ] = KEY_PRINT,
495
496 [ 0x48 ] = KEY_RED,
497 [ 0x04 ] = KEY_GREEN,
498 [ 0x11 ] = KEY_YELLOW,
499 [ 0x00 ] = KEY_BLUE,
500
501 [ 0x2d ] = KEY_VOLUMEUP,
502 [ 0x1e ] = KEY_VOLUMEDOWN,
503
504 [ 0x49 ] = KEY_MENU,
505
506 [ 0x16 ] = KEY_CHANNELUP,
507 [ 0x17 ] = KEY_CHANNELDOWN,
508
509 [ 0x20 ] = KEY_UP,
510 [ 0x21 ] = KEY_DOWN,
511 [ 0x22 ] = KEY_LEFT,
512 [ 0x23 ] = KEY_RIGHT,
513 [ 0x0d ] = KEY_SELECT,
514
515
516
517 [ 0x08 ] = KEY_BACK,
518 [ 0x07 ] = KEY_REFRESH,
519
520 [ 0x2f ] = KEY_ZOOM,
521 [ 0x29 ] = KEY_RECORD,
522
523 [ 0x4b ] = KEY_PAUSE,
524 [ 0x4d ] = KEY_REWIND,
525 [ 0x2e ] = KEY_PLAY,
526 [ 0x4e ] = KEY_FORWARD,
527 [ 0x53 ] = KEY_PREVIOUS,
528 [ 0x4c ] = KEY_STOP,
529 [ 0x54 ] = KEY_NEXT,
530
531 [ 0x69 ] = KEY_KP0,
532 [ 0x6a ] = KEY_KP1,
533 [ 0x6b ] = KEY_KP2,
534 [ 0x6c ] = KEY_KP3,
535 [ 0x6d ] = KEY_KP4,
536 [ 0x6e ] = KEY_KP5,
537 [ 0x6f ] = KEY_KP6,
538 [ 0x70 ] = KEY_KP7,
539 [ 0x71 ] = KEY_KP8,
540 [ 0x72 ] = KEY_KP9,
541
542 [ 0x74 ] = KEY_CHANNEL,
543 [ 0x0a ] = KEY_BACKSPACE,
544};
545
546/* Mapping for the 28 key remote control as seen at 488/* Mapping for the 28 key remote control as seen at
547 http://www.sednacomputer.com/photo/cardbus-tv.jpg 489 http://www.sednacomputer.com/photo/cardbus-tv.jpg
548 Pavel Mihaylov <bin@bash.info> */ 490 Pavel Mihaylov <bin@bash.info> */
@@ -635,57 +577,6 @@ static int get_key_purpletv(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
635 return 1; 577 return 1;
636} 578}
637 579
638/* The new pinnacle PCTV remote (with the colored buttons)
639 *
640 * Ricardo Cerqueira <v4l@cerqueira.org>
641 */
642
643static int get_key_pinnacle(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw)
644{
645 unsigned char b[4];
646 unsigned int start = 0,parity = 0,code = 0;
647
648 /* poll IR chip */
649 if (4 != i2c_master_recv(&ir->c,b,4)) {
650 i2cdprintk("read error\n");
651 return -EIO;
652 }
653
654 for (start = 0; start<4; start++) {
655 if (b[start] == 0x80) {
656 code=b[(start+3)%4];
657 parity=b[(start+2)%4];
658 }
659 }
660
661 /* Empty Request */
662 if (parity==0)
663 return 0;
664
665 /* Repeating... */
666 if (ir->old == parity)
667 return 0;
668
669
670 ir->old = parity;
671
672 /* Reduce code value to fit inside IR_KEYTAB_SIZE
673 *
674 * this is the only value that results in 42 unique
675 * codes < 128
676 */
677
678 code %= 0x88;
679
680 *ir_raw = code;
681 *ir_key = code;
682
683 i2cdprintk("Pinnacle PCTV key %02x\n", code);
684
685 return 1;
686}
687
688
689void saa7134_input_irq(struct saa7134_dev *dev) 580void saa7134_input_irq(struct saa7134_dev *dev)
690{ 581{
691 struct saa7134_ir *ir = dev->remote; 582 struct saa7134_ir *ir = dev->remote;
@@ -822,6 +713,8 @@ int saa7134_input_init1(struct saa7134_dev *dev)
822 return -ENOMEM; 713 return -ENOMEM;
823 } 714 }
824 715
716 ir->dev = input_dev;
717
825 /* init hardware-specific stuff */ 718 /* init hardware-specific stuff */
826 ir->mask_keycode = mask_keycode; 719 ir->mask_keycode = mask_keycode;
827 ir->mask_keydown = mask_keydown; 720 ir->mask_keydown = mask_keydown;
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index fd53dfcc1644..8badd2a9cb2f 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -4,6 +4,8 @@
4 * oss dsp interface 4 * oss dsp interface
5 * 5 *
6 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs] 6 * (c) 2001,02 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
7 * 2005 conversion to standalone module:
8 * Ricardo Cerqueira <v4l@cerqueira.org>
7 * 9 *
8 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
@@ -25,7 +27,9 @@
25#include <linux/module.h> 27#include <linux/module.h>
26#include <linux/moduleparam.h> 28#include <linux/moduleparam.h>
27#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/interrupt.h>
28#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/sound.h>
29#include <linux/soundcard.h> 33#include <linux/soundcard.h>
30 34
31#include "saa7134-reg.h" 35#include "saa7134-reg.h"
@@ -33,15 +37,23 @@
33 37
34/* ------------------------------------------------------------------ */ 38/* ------------------------------------------------------------------ */
35 39
36static unsigned int oss_debug = 0; 40static unsigned int debug = 0;
37module_param(oss_debug, int, 0644); 41module_param(debug, int, 0644);
38MODULE_PARM_DESC(oss_debug,"enable debug messages [oss]"); 42MODULE_PARM_DESC(debug,"enable debug messages [oss]");
39 43
40static unsigned int oss_rate = 0; 44static unsigned int rate = 0;
41module_param(oss_rate, int, 0444); 45module_param(rate, int, 0444);
42MODULE_PARM_DESC(oss_rate,"sample rate (valid are: 32000,48000)"); 46MODULE_PARM_DESC(rate,"sample rate (valid are: 32000,48000)");
43 47
44#define dprintk(fmt, arg...) if (oss_debug) \ 48static unsigned int dsp_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
49MODULE_PARM_DESC(dsp_nr, "device numbers for SAA7134 capture interface(s).");
50module_param_array(dsp_nr, int, NULL, 0444);
51
52static unsigned int mixer_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
53MODULE_PARM_DESC(mixer_nr, "mixer numbers for SAA7134 capture interface(s).");
54module_param_array(mixer_nr, int, NULL, 0444);
55
56#define dprintk(fmt, arg...) if (debug) \
45 printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg) 57 printk(KERN_DEBUG "%s/oss: " fmt, dev->name , ## arg)
46 58
47 59
@@ -369,7 +381,7 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
369 int __user *p = argp; 381 int __user *p = argp;
370 int val = 0; 382 int val = 0;
371 383
372 if (oss_debug > 1) 384 if (debug > 1)
373 saa7134_print_ioctl(dev->name,cmd); 385 saa7134_print_ioctl(dev->name,cmd);
374 switch (cmd) { 386 switch (cmd) {
375 case OSS_GETVERSION: 387 case OSS_GETVERSION:
@@ -665,7 +677,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file,
665 void __user *argp = (void __user *) arg; 677 void __user *argp = (void __user *) arg;
666 int __user *p = argp; 678 int __user *p = argp;
667 679
668 if (oss_debug > 1) 680 if (debug > 1)
669 saa7134_print_ioctl(dev->name,cmd); 681 saa7134_print_ioctl(dev->name,cmd);
670 switch (cmd) { 682 switch (cmd) {
671 case OSS_GETVERSION: 683 case OSS_GETVERSION:
@@ -768,8 +780,41 @@ struct file_operations saa7134_mixer_fops = {
768 780
769/* ------------------------------------------------------------------ */ 781/* ------------------------------------------------------------------ */
770 782
783static irqreturn_t saa7134_oss_irq(int irq, void *dev_id, struct pt_regs *regs)
784{
785 struct saa7134_dmasound *dmasound = dev_id;
786 struct saa7134_dev *dev = dmasound->priv_data;
787 unsigned long report, status;
788 int loop, handled = 0;
789
790 for (loop = 0; loop < 10; loop++) {
791 report = saa_readl(SAA7134_IRQ_REPORT);
792 status = saa_readl(SAA7134_IRQ_STATUS);
793
794 if (report & SAA7134_IRQ_REPORT_DONE_RA3) {
795 handled = 1;
796 saa_writel(SAA7134_IRQ_REPORT,report);
797 saa7134_irq_oss_done(dev, status);
798 } else {
799 goto out;
800 }
801 }
802
803 if (loop == 10) {
804 dprintk("error! looping IRQ!");
805 }
806out:
807 return IRQ_RETVAL(handled);
808}
809
771int saa7134_oss_init1(struct saa7134_dev *dev) 810int saa7134_oss_init1(struct saa7134_dev *dev)
772{ 811{
812
813 if ((request_irq(dev->pci->irq, saa7134_oss_irq,
814 SA_SHIRQ | SA_INTERRUPT, dev->name,
815 (void*) &dev->dmasound)) < 0)
816 return -1;
817
773 /* general */ 818 /* general */
774 init_MUTEX(&dev->dmasound.lock); 819 init_MUTEX(&dev->dmasound.lock);
775 init_waitqueue_head(&dev->dmasound.wq); 820 init_waitqueue_head(&dev->dmasound.wq);
@@ -785,8 +830,8 @@ int saa7134_oss_init1(struct saa7134_dev *dev)
785 830
786 /* dsp */ 831 /* dsp */
787 dev->dmasound.rate = 32000; 832 dev->dmasound.rate = 32000;
788 if (oss_rate) 833 if (rate)
789 dev->dmasound.rate = oss_rate; 834 dev->dmasound.rate = rate;
790 dev->dmasound.rate = (dev->dmasound.rate > 40000) ? 48000 : 32000; 835 dev->dmasound.rate = (dev->dmasound.rate > 40000) ? 48000 : 32000;
791 836
792 /* mixer */ 837 /* mixer */
@@ -840,7 +885,7 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
840 /* next block addr */ 885 /* next block addr */
841 next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks; 886 next_blk = (dev->dmasound.dma_blk + 2) % dev->dmasound.blocks;
842 saa_writel(reg,next_blk * dev->dmasound.blksize); 887 saa_writel(reg,next_blk * dev->dmasound.blksize);
843 if (oss_debug > 2) 888 if (debug > 2)
844 dprintk("irq: ok, %s, next_blk=%d, addr=%x\n", 889 dprintk("irq: ok, %s, next_blk=%d, addr=%x\n",
845 (status & 0x10000000) ? "even" : "odd ", next_blk, 890 (status & 0x10000000) ? "even" : "odd ", next_blk,
846 next_blk * dev->dmasound.blksize); 891 next_blk * dev->dmasound.blksize);
@@ -854,6 +899,124 @@ void saa7134_irq_oss_done(struct saa7134_dev *dev, unsigned long status)
854 spin_unlock(&dev->slock); 899 spin_unlock(&dev->slock);
855} 900}
856 901
902static int saa7134_dsp_create(struct saa7134_dev *dev)
903{
904 int err;
905
906 err = dev->dmasound.minor_dsp =
907 register_sound_dsp(&saa7134_dsp_fops,
908 dsp_nr[dev->nr]);
909 if (err < 0) {
910 goto fail;
911 }
912 printk(KERN_INFO "%s: registered device dsp%d\n",
913 dev->name,dev->dmasound.minor_dsp >> 4);
914
915 err = dev->dmasound.minor_mixer =
916 register_sound_mixer(&saa7134_mixer_fops,
917 mixer_nr[dev->nr]);
918 if (err < 0)
919 goto fail;
920 printk(KERN_INFO "%s: registered device mixer%d\n",
921 dev->name,dev->dmasound.minor_mixer >> 4);
922
923 return 0;
924
925fail:
926 unregister_sound_dsp(dev->dmasound.minor_dsp);
927 return 0;
928
929
930}
931
932static int oss_device_init(struct saa7134_dev *dev)
933{
934 dev->dmasound.priv_data = dev;
935 saa7134_oss_init1(dev);
936 saa7134_dsp_create(dev);
937 return 1;
938}
939
940static int oss_device_exit(struct saa7134_dev *dev)
941{
942
943 unregister_sound_mixer(dev->dmasound.minor_mixer);
944 unregister_sound_dsp(dev->dmasound.minor_dsp);
945
946 saa7134_oss_fini(dev);
947
948 if (dev->pci->irq > 0) {
949 synchronize_irq(dev->pci->irq);
950 free_irq(dev->pci->irq,&dev->dmasound);
951 }
952
953 dev->dmasound.priv_data = NULL;
954 return 1;
955}
956
957static int saa7134_oss_init(void)
958{
959 struct saa7134_dev *dev = NULL;
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 }
969
970 printk(KERN_INFO "saa7134 OSS driver for DMA sound loaded\n");
971
972
973 list_for_each(list,&saa7134_devlist) {
974 dev = list_entry(list, struct saa7134_dev, devlist);
975 if (dev->dmasound.priv_data == NULL) {
976 oss_device_init(dev);
977 } else {
978 printk(KERN_ERR "saa7134 OSS: DMA sound is being handled by ALSA, ignoring %s\n",dev->name);
979 return -EBUSY;
980 }
981 }
982
983 if (dev == NULL)
984 printk(KERN_INFO "saa7134 OSS: no saa7134 cards found\n");
985
986 return 0;
987
988}
989
990static void saa7134_oss_exit(void)
991{
992 struct saa7134_dev *dev = NULL;
993 struct list_head *list;
994
995 list_for_each(list,&saa7134_devlist) {
996 dev = list_entry(list, struct saa7134_dev, devlist);
997
998 /* Device isn't registered by OSS, probably ALSA's */
999 if (!dev->dmasound.minor_dsp)
1000 continue;
1001
1002 oss_device_exit(dev);
1003
1004 }
1005
1006 dmasound_init = NULL;
1007 dmasound_exit = NULL;
1008
1009 printk(KERN_INFO "saa7134 OSS driver for DMA sound unloaded\n");
1010
1011 return;
1012}
1013
1014/* We initialize this late, to make sure the sound system is up and running */
1015late_initcall(saa7134_oss_init);
1016module_exit(saa7134_oss_exit);
1017MODULE_LICENSE("GPL");
1018MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
1019
857/* ----------------------------------------------------------- */ 1020/* ----------------------------------------------------------- */
858/* 1021/*
859 * Local variables: 1022 * Local variables:
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index fb9727471661..add49db1ad41 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -208,6 +208,7 @@ struct saa7134_format {
208#define SAA7134_BOARD_SEDNA_PC_TV_CARDBUS 79 208#define SAA7134_BOARD_SEDNA_PC_TV_CARDBUS 79
209#define SAA7134_BOARD_ASUSTEK_DIGIMATRIX_TV 80 209#define SAA7134_BOARD_ASUSTEK_DIGIMATRIX_TV 80
210#define SAA7134_BOARD_PHILIPS_TIGER 81 210#define SAA7134_BOARD_PHILIPS_TIGER 81
211#define SAA7134_BOARD_MSI_TVATANYWHERE_PLUS 82
211 212
212#define SAA7134_MAXBOARDS 8 213#define SAA7134_MAXBOARDS 8
213#define SAA7134_INPUT_MAX 8 214#define SAA7134_INPUT_MAX 8
@@ -383,6 +384,7 @@ struct saa7134_dmasound {
383 unsigned int dma_blk; 384 unsigned int dma_blk;
384 unsigned int read_offset; 385 unsigned int read_offset;
385 unsigned int read_count; 386 unsigned int read_count;
387 void * priv_data;
386 snd_pcm_substream_t *substream; 388 snd_pcm_substream_t *substream;
387}; 389};
388 390
@@ -569,6 +571,10 @@ void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf);
569 571
570int saa7134_set_dmabits(struct saa7134_dev *dev); 572int saa7134_set_dmabits(struct saa7134_dev *dev);
571 573
574extern int (*dmasound_init)(struct saa7134_dev *dev);
575extern int (*dmasound_exit)(struct saa7134_dev *dev);
576
577
572/* ----------------------------------------------------------- */ 578/* ----------------------------------------------------------- */
573/* saa7134-cards.c */ 579/* saa7134-cards.c */
574 580
diff --git a/drivers/media/video/tda8290.c b/drivers/media/video/tda8290.c
index b2dfe07e9f9d..61d94ddaff41 100644
--- a/drivers/media/video/tda8290.c
+++ b/drivers/media/video/tda8290.c
@@ -437,6 +437,10 @@ static void set_audio(struct tuner *t)
437 t->sgIF = 124; 437 t->sgIF = 124;
438 t->tda8290_easy_mode = 0x20; 438 t->tda8290_easy_mode = 0x20;
439 mode = "L"; 439 mode = "L";
440 } else if (t->std & V4L2_STD_SECAM_LC) {
441 t->sgIF = 20;
442 t->tda8290_easy_mode = 0x40;
443 mode = "LC";
440 } 444 }
441 tuner_dbg("setting tda8290 to system %s\n", mode); 445 tuner_dbg("setting tda8290 to system %s\n", mode);
442} 446}
diff --git a/drivers/media/video/tda9887.c b/drivers/media/video/tda9887.c
index 4249127c0a1d..2f2414e90e8b 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)
@@ -819,12 +820,12 @@ static int tda9887_resume(struct device * dev)
819 820
820static struct i2c_driver driver = { 821static struct i2c_driver driver = {
821 .owner = THIS_MODULE, 822 .owner = THIS_MODULE,
822 .name = "i2c tda9887 driver", 823 .name = "i2c tda9887 driver",
823 .id = -1, /* FIXME */ 824 .id = -1, /* FIXME */
824 .flags = I2C_DF_NOTIFY, 825 .flags = I2C_DF_NOTIFY,
825 .attach_adapter = tda9887_probe, 826 .attach_adapter = tda9887_probe,
826 .detach_client = tda9887_detach, 827 .detach_client = tda9887_detach,
827 .command = tda9887_command, 828 .command = tda9887_command,
828 .driver = { 829 .driver = {
829 .suspend = tda9887_suspend, 830 .suspend = tda9887_suspend,
830 .resume = tda9887_resume, 831 .resume = tda9887_resume,
@@ -834,7 +835,7 @@ static struct i2c_client client_template =
834{ 835{
835 .name = "tda9887", 836 .name = "tda9887",
836 .flags = I2C_CLIENT_ALLOW_USE, 837 .flags = I2C_CLIENT_ALLOW_USE,
837 .driver = &driver, 838 .driver = &driver,
838}; 839};
839 840
840static int __init tda9887_init_module(void) 841static int __init tda9887_init_module(void)
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 73c4041c35d7..e58abdfcaab8 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -251,7 +251,7 @@ static inline int check_mode(struct tuner *t, char *cmd)
251 251
252static char pal[] = "-"; 252static char pal[] = "-";
253module_param_string(pal, pal, sizeof(pal), 0644); 253module_param_string(pal, pal, sizeof(pal), 0644);
254static char secam[] = "-"; 254static char secam[] = "--";
255module_param_string(secam, secam, sizeof(secam), 0644); 255module_param_string(secam, secam, sizeof(secam), 0644);
256 256
257/* get more precise norm info from insmod option */ 257/* get more precise norm info from insmod option */
@@ -307,8 +307,13 @@ static int tuner_fixup_std(struct tuner *t)
307 break; 307 break;
308 case 'l': 308 case 'l':
309 case 'L': 309 case 'L':
310 tuner_dbg ("insmod fixup: SECAM => SECAM-L\n"); 310 if ((secam[1]=='C')||(secam[1]=='c')) {
311 t->std = V4L2_STD_SECAM_L; 311 tuner_dbg ("insmod fixup: SECAM => SECAM-L'\n");
312 t->std = V4L2_STD_SECAM_LC;
313 } else {
314 tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
315 t->std = V4L2_STD_SECAM_L;
316 }
312 break; 317 break;
313 case '-': 318 case '-':
314 /* default parameter, do nothing */ 319 /* default parameter, do nothing */
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index d832205818f2..e0c9fdb9914a 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -233,7 +233,7 @@ static struct tunertype tuners[] = {
233 { "Ymec TVision TVF-5533MF", Philips, NTSC, 233 { "Ymec TVision TVF-5533MF", Philips, NTSC,
234 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732}, 234 16*160.00,16*454.00,0x01,0x02,0x04,0x8e,732},
235 235
236 /* 60-68 */ 236 /* 60-69 */
237 { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC, 237 { "Thomson DDT 7611 (ATSC/NTSC)", THOMSON, ATSC,
238 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732}, 238 16*157.25,16*454.00,0x39,0x3a,0x3c,0x8e,732},
239 { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL, 239 { "Tena TNF9533-D/IF/TNF9533-B/DF", Philips, PAL,
@@ -252,6 +252,8 @@ static struct tunertype tuners[] = {
252 16*160.00,16*442.00,0xa1,0xa2,0xa4,0xc8,623 }, 252 16*160.00,16*442.00,0xa1,0xa2,0xa4,0xc8,623 },
253 { "Philips TUV1236D ATSC/NTSC dual in", Philips, ATSC, 253 { "Philips TUV1236D ATSC/NTSC dual in", Philips, ATSC,
254 16*157.25,16*454.00,0x01,0x02,0x04,0xce,732 }, 254 16*157.25,16*454.00,0x01,0x02,0x04,0xce,732 },
255 { "Tena TNF 5335 MF", Philips, NTSC,
256 16*157.25,16*454.00,0x01,0x02,0x04,0x8e,732 },
255}; 257};
256 258
257unsigned const int tuner_count = ARRAY_SIZE(tuners); 259unsigned const int tuner_count = ARRAY_SIZE(tuners);
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index c31bf28b73fe..5b20e8177cad 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;
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 72e8741e8b59..5ac235365dd8 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -81,7 +81,7 @@ hauppauge_tuner_fmt[] =
81 { 0x00000010, " PAL(I)" }, 81 { 0x00000010, " PAL(I)" },
82 { 0x00400000, " SECAM(L/L')" }, 82 { 0x00400000, " SECAM(L/L')" },
83 { 0x00000e00, " PAL(D/K)" }, 83 { 0x00000e00, " PAL(D/K)" },
84 { 0x03000000, " ATSC Digital" }, 84 { 0x03000000, " ATSC/DVB Digital" },
85}; 85};
86 86
87/* This is the full list of possible tuners. Many thanks to Hauppauge for 87/* This is the full list of possible tuners. Many thanks to Hauppauge for
@@ -206,16 +206,30 @@ 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_ABSENT, "TCL MFNM05-4"}, 212 { TUNER_PHILIPS_FM1236_MK3, "TCL MFNM05-4"},
213 { TUNER_ABSENT, "TCL MNM05-4"}, 213 { TUNER_ABSENT, "TCL MNM05-4"},
214 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"}, 214 { TUNER_PHILIPS_FM1216ME_MK3, "TCL MPE05-2"},
215 { TUNER_ABSENT, "TCL MQNM05-4"}, 215 { TUNER_ABSENT, "TCL MQNM05-4"},
216 { TUNER_ABSENT, "LG TAPC-W701D"}, 216 { TUNER_ABSENT, "LG TAPC-W701D"},
217 { TUNER_ABSENT, "TCL 9886P-WM"}, 217 { TUNER_ABSENT, "TCL 9886P-WM"},
218 { TUNER_ABSENT, "TCL 1676NM-WM"}, 218 { TUNER_ABSENT, "TCL 1676NM-WM"},
219 /* 110-119 */
220 { TUNER_ABSENT, "Thompson DTT75105"},
221 { TUNER_ABSENT, "Conexant_CX24109"},
222 { TUNER_ABSENT, "TCL M2523_5N_E"},
223 { TUNER_ABSENT, "TCL M2523_3DB_E"},
224 { TUNER_ABSENT, "Philips 8275A"},
225 { TUNER_ABSENT, "Microtune MT2060"},
226 { TUNER_ABSENT, "Philips FM1236 MK5"},
227 { TUNER_ABSENT, "Philips FM1216ME MK5"},
228 { TUNER_ABSENT, "TCL M2523_3DI_E"},
229 { TUNER_ABSENT, "Samsung THPD5222FG30A"},
230 /* 120-129 */
231 { TUNER_ABSENT, "Xceive XC3028"},
232 { TUNER_ABSENT, "Philips FQ1216LME MK5"},
219}; 233};
220 234
221static struct HAUPPAUGE_AUDIOIC 235static struct HAUPPAUGE_AUDIOIC
@@ -325,6 +339,7 @@ static int hasRadioTuner(int tunerType)
325 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM: 339 case 78: //PNPEnv_TUNER_TDA8275C1_8290_FM:
326 case 89: //PNPEnv_TUNER_TCL_MFPE05_2: 340 case 89: //PNPEnv_TUNER_TCL_MFPE05_2:
327 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4: 341 case 92: //PNPEnv_TUNER_PHILIPS_FQ1236A_MK4:
342 case 105:
328 return 1; 343 return 1;
329 } 344 }
330 return 0; 345 return 0;
@@ -368,10 +383,15 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
368 memset(tvee, 0, sizeof(*tvee)); 383 memset(tvee, 0, sizeof(*tvee));
369 done = len = beenhere = 0; 384 done = len = beenhere = 0;
370 385
371 /* Hack for processing eeprom for em28xx */ 386 /* Hack for processing eeprom for em28xx and cx 2388x*/
372 if ((eeprom_data[0]==0x1a)&&(eeprom_data[1]==0xeb)&& 387 if ((eeprom_data[0] == 0x1a) && (eeprom_data[1] == 0xeb) &&
373 (eeprom_data[2]==0x67)&&(eeprom_data[3]==0x95)) 388 (eeprom_data[2] == 0x67) && (eeprom_data[3] == 0x95))
374 start=0xa0; 389 start=0xa0; /* Generic em28xx offset */
390 else if (((eeprom_data[0] & 0xf0) == 0x10) &&
391 (eeprom_data[1] == 0x00) &&
392 (eeprom_data[2] == 0x00) &&
393 (eeprom_data[8] == 0x84))
394 start=8; /* Generic cx2388x offset */
375 else 395 else
376 start=0; 396 start=0;
377 397
@@ -448,6 +468,17 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
448 eeprom_data[i+5] + 468 eeprom_data[i+5] +
449 (eeprom_data[i+6] << 8) + 469 (eeprom_data[i+6] << 8) +
450 (eeprom_data[i+7] << 16); 470 (eeprom_data[i+7] << 16);
471
472 if ( (eeprom_data[i + 8] && 0xf0) &&
473 (tvee->serial_number < 0xffffff) ) {
474 tvee->MAC_address[0] = 0x00;
475 tvee->MAC_address[1] = 0x0D;
476 tvee->MAC_address[2] = 0xFE;
477 tvee->MAC_address[3] = eeprom_data[i + 7];
478 tvee->MAC_address[4] = eeprom_data[i + 6];
479 tvee->MAC_address[5] = eeprom_data[i + 5];
480 tvee->has_MAC_address = 1;
481 }
451 break; 482 break;
452 483
453 case 0x05: 484 case 0x05:
@@ -466,11 +497,14 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
466 case 0x06: 497 case 0x06:
467 /* tag 'ModelRev' */ 498 /* tag 'ModelRev' */
468 tvee->model = 499 tvee->model =
469 eeprom_data[i+1] + 500 eeprom_data[i + 1] +
470 (eeprom_data[i+2] << 8); 501 (eeprom_data[i + 2] << 8) +
471 tvee->revision = eeprom_data[i+5] + 502 (eeprom_data[i + 3] << 16) +
472 (eeprom_data[i+6] << 8) + 503 (eeprom_data[i + 4] << 24);
473 (eeprom_data[i+7] << 16); 504 tvee->revision =
505 eeprom_data[i +5 ] +
506 (eeprom_data[i + 6] << 8) +
507 (eeprom_data[i + 7] << 16);
474 break; 508 break;
475 509
476 case 0x07: 510 case 0x07:
@@ -563,6 +597,8 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
563 t_name2 = "unknown"; 597 t_name2 = "unknown";
564 } 598 }
565 599
600 tvee->tuner_hauppauge_model = tuner1;
601 tvee->tuner2_hauppauge_model = tuner2;
566 tvee->tuner_formats = 0; 602 tvee->tuner_formats = 0;
567 tvee->tuner2_formats = 0; 603 tvee->tuner2_formats = 0;
568 for (i = j = 0; i < 8; i++) { 604 for (i = j = 0; i < 8; i++) {
@@ -578,6 +614,12 @@ void tveeprom_hauppauge_analog(struct i2c_client *c, struct tveeprom *tvee,
578 614
579 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n", 615 tveeprom_info("Hauppauge model %d, rev %s, serial# %d\n",
580 tvee->model, tvee->rev_str, tvee->serial_number); 616 tvee->model, tvee->rev_str, tvee->serial_number);
617 if (tvee->has_MAC_address == 1) {
618 tveeprom_info("MAC address is %02X-%02X-%02X-%02X-%02X-%02X\n",
619 tvee->MAC_address[0], tvee->MAC_address[1],
620 tvee->MAC_address[2], tvee->MAC_address[3],
621 tvee->MAC_address[4], tvee->MAC_address[5]);
622 }
581 tveeprom_info("tuner model is %s (idx %d, type %d)\n", 623 tveeprom_info("tuner model is %s (idx %d, type %d)\n",
582 t_name1, tuner1, tvee->tuner_type); 624 t_name1, tuner1, tvee->tuner_type);
583 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n", 625 tveeprom_info("TV standards%s%s%s%s%s%s%s%s (eeprom 0x%02x)\n",
@@ -711,7 +753,8 @@ tveeprom_detect_client(struct i2c_adapter *adapter,
711 client->driver = &i2c_driver_tveeprom; 753 client->driver = &i2c_driver_tveeprom;
712 client->flags = I2C_CLIENT_ALLOW_USE; 754 client->flags = I2C_CLIENT_ALLOW_USE;
713 snprintf(client->name, sizeof(client->name), "tveeprom"); 755 snprintf(client->name, sizeof(client->name), "tveeprom");
714 i2c_attach_client(client); 756 i2c_attach_client(client);
757
715 return 0; 758 return 0;
716} 759}
717 760
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 81e6d4494e7d..97431e26d229 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 */
@@ -770,7 +770,6 @@ static int tvp5150_detect_client(struct i2c_adapter *adapter,
770 770
771 if (debug > 1) 771 if (debug > 1)
772 dump_reg(client); 772 dump_reg(client);
773
774 return 0; 773 return 0;
775} 774}
776 775
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/video-buf.c b/drivers/media/video/video-buf.c
index acfd3a103f35..9a6bf287e26a 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -753,10 +753,9 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
753 int retval; 753 int retval;
754 754
755 /* setup stuff */ 755 /* setup stuff */
756 retval = -ENOMEM;
757 q->read_buf = videobuf_alloc(q->msize); 756 q->read_buf = videobuf_alloc(q->msize);
758 if (NULL == q->read_buf) 757 if (NULL == q->read_buf)
759 goto done; 758 return -ENOMEM;
760 759
761 q->read_buf->memory = V4L2_MEMORY_USERPTR; 760 q->read_buf->memory = V4L2_MEMORY_USERPTR;
762 q->read_buf->baddr = (unsigned long)data; 761 q->read_buf->baddr = (unsigned long)data;
@@ -817,10 +816,14 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
817 if (NULL == q->read_buf) 816 if (NULL == q->read_buf)
818 goto done; 817 goto done;
819 q->read_buf->memory = V4L2_MEMORY_USERPTR; 818 q->read_buf->memory = V4L2_MEMORY_USERPTR;
819 q->read_buf->bsize = count; /* preferred size */
820 field = videobuf_next_field(q); 820 field = videobuf_next_field(q);
821 retval = q->ops->buf_prepare(q,q->read_buf,field); 821 retval = q->ops->buf_prepare(q,q->read_buf,field);
822 if (0 != retval) 822 if (0 != retval) {
823 kfree (q->read_buf);
824 q->read_buf = NULL;
823 goto done; 825 goto done;
826 }
824 spin_lock_irqsave(q->irqlock,flags); 827 spin_lock_irqsave(q->irqlock,flags);
825 q->ops->buf_queue(q,q->read_buf); 828 q->ops->buf_queue(q,q->read_buf);
826 spin_unlock_irqrestore(q->irqlock,flags); 829 spin_unlock_irqrestore(q->irqlock,flags);
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 83c49f9610d0..6de5b0094b82 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -76,14 +76,14 @@ static void video_release(struct class_device *cd)
76} 76}
77 77
78static struct class video_class = { 78static struct class video_class = {
79 .name = VIDEO_NAME, 79 .name = VIDEO_NAME,
80 .release = video_release, 80 .release = video_release,
81}; 81};
82 82
83/* 83/*
84 * Active devices 84 * Active devices
85 */ 85 */
86 86
87static struct video_device *video_device[VIDEO_NUM_DEVICES]; 87static struct video_device *video_device[VIDEO_NUM_DEVICES];
88static DECLARE_MUTEX(videodev_lock); 88static DECLARE_MUTEX(videodev_lock);
89 89
@@ -101,7 +101,7 @@ static int video_open(struct inode *inode, struct file *file)
101 int err = 0; 101 int err = 0;
102 struct video_device *vfl; 102 struct video_device *vfl;
103 struct file_operations *old_fops; 103 struct file_operations *old_fops;
104 104
105 if(minor>=VIDEO_NUM_DEVICES) 105 if(minor>=VIDEO_NUM_DEVICES)
106 return -ENODEV; 106 return -ENODEV;
107 down(&videodev_lock); 107 down(&videodev_lock);
@@ -189,7 +189,7 @@ video_usercopy(struct inode *inode, struct file *file,
189 return -ENOMEM; 189 return -ENOMEM;
190 parg = mbuf; 190 parg = mbuf;
191 } 191 }
192 192
193 err = -EFAULT; 193 err = -EFAULT;
194 if (_IOC_DIR(cmd) & _IOC_WRITE) 194 if (_IOC_DIR(cmd) & _IOC_WRITE)
195 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd))) 195 if (copy_from_user(parg, (void __user *)arg, _IOC_SIZE(cmd)))
@@ -240,7 +240,7 @@ int video_exclusive_open(struct inode *inode, struct file *file)
240int video_exclusive_release(struct inode *inode, struct file *file) 240int video_exclusive_release(struct inode *inode, struct file *file)
241{ 241{
242 struct video_device *vfl = video_devdata(file); 242 struct video_device *vfl = video_devdata(file);
243 243
244 vfl->users--; 244 vfl->users--;
245 return 0; 245 return 0;
246} 246}
@@ -253,7 +253,7 @@ static struct file_operations video_fops;
253 * @type: type of device to register 253 * @type: type of device to register
254 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... 254 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
255 * -1 == first free) 255 * -1 == first free)
256 * 256 *
257 * The registration code assigns minor numbers based on the type 257 * The registration code assigns minor numbers based on the type
258 * requested. -ENFILE is returned in all the device slots for this 258 * requested. -ENFILE is returned in all the device slots for this
259 * category are full. If not then the minor field is set and the 259 * category are full. If not then the minor field is set and the
@@ -269,7 +269,7 @@ static struct file_operations video_fops;
269 * 269 *
270 * %VFL_TYPE_VBI - Vertical blank data (undecoded) 270 * %VFL_TYPE_VBI - Vertical blank data (undecoded)
271 * 271 *
272 * %VFL_TYPE_RADIO - A radio card 272 * %VFL_TYPE_RADIO - A radio card
273 */ 273 */
274 274
275int video_register_device(struct video_device *vfd, int type, int nr) 275int video_register_device(struct video_device *vfd, int type, int nr)
@@ -278,7 +278,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
278 int base; 278 int base;
279 int end; 279 int end;
280 char *name_base; 280 char *name_base;
281 281
282 switch(type) 282 switch(type)
283 { 283 {
284 case VFL_TYPE_GRABBER: 284 case VFL_TYPE_GRABBER:
@@ -293,7 +293,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
293 break; 293 break;
294 case VFL_TYPE_VBI: 294 case VFL_TYPE_VBI:
295 base=224; 295 base=224;
296 end=240; 296 end=256;
297 name_base = "vbi"; 297 name_base = "vbi";
298 break; 298 break;
299 case VFL_TYPE_RADIO: 299 case VFL_TYPE_RADIO:
@@ -334,7 +334,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
334 init_MUTEX(&vfd->lock); 334 init_MUTEX(&vfd->lock);
335 335
336 /* sysfs class */ 336 /* sysfs class */
337 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev)); 337 memset(&vfd->class_dev, 0x00, sizeof(vfd->class_dev));
338 if (vfd->dev) 338 if (vfd->dev)
339 vfd->class_dev.dev = vfd->dev; 339 vfd->class_dev.dev = vfd->dev;
340 vfd->class_dev.class = &video_class; 340 vfd->class_dev.class = &video_class;
@@ -360,7 +360,7 @@ int video_register_device(struct video_device *vfd, int type, int nr)
360 * This unregisters the passed device and deassigns the minor 360 * This unregisters the passed device and deassigns the minor
361 * number. Future open calls will be met with errors. 361 * number. Future open calls will be met with errors.
362 */ 362 */
363 363
364void video_unregister_device(struct video_device *vfd) 364void video_unregister_device(struct video_device *vfd)
365{ 365{
366 down(&videodev_lock); 366 down(&videodev_lock);
@@ -384,7 +384,7 @@ static struct file_operations video_fops=
384/* 384/*
385 * Initialise video for linux 385 * Initialise video for linux
386 */ 386 */
387 387
388static int __init videodev_init(void) 388static int __init videodev_init(void)
389{ 389{
390 int ret; 390 int ret;
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index 22f286222004..a6936ad74fcf 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -5,6 +5,11 @@
5 * 5 *
6 * Based on saa7115 driver 6 * Based on saa7115 driver
7 * 7 *
8 * Copyright (C) 2005 Hans Verkuil <hverkuil@xs4all.nl>
9 * - Cleanup
10 * - V4L2 API update
11 * - sound fixes
12 *
8 * This program is free software; you can redistribute it and/or modify 13 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 14 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 15 * the Free Software Foundation; either version 2 of the License, or
@@ -31,7 +36,7 @@
31#include <media/audiochip.h> 36#include <media/audiochip.h>
32 37
33MODULE_DESCRIPTION("wm8775 driver"); 38MODULE_DESCRIPTION("wm8775 driver");
34MODULE_AUTHOR("Ulf Eklund"); 39MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
35MODULE_LICENSE("GPL"); 40MODULE_LICENSE("GPL");
36 41
37#define wm8775_err(fmt, arg...) do { \ 42#define wm8775_err(fmt, arg...) do { \
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 74022316fc63..4262a22adc22 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -91,9 +91,9 @@ static int mfcounter = 0;
91 * Public data... 91 * Public data...
92 */ 92 */
93int mpt_lan_index = -1; 93int mpt_lan_index = -1;
94static int mpt_stm_index = -1; 94int mpt_stm_index = -1;
95 95
96static struct proc_dir_entry *mpt_proc_root_dir; 96struct proc_dir_entry *mpt_proc_root_dir;
97 97
98#define WHOINIT_UNKNOWN 0xAA 98#define WHOINIT_UNKNOWN 0xAA
99 99
@@ -1118,6 +1118,65 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
1118 return -1; 1118 return -1;
1119} 1119}
1120 1120
1121int
1122mpt_alt_ioc_wait(MPT_ADAPTER *ioc)
1123{
1124 int loop_count = 30 * 4; /* Wait 30 seconds */
1125 int status = -1; /* -1 means failed to get board READY */
1126
1127 do {
1128 spin_lock(&ioc->initializing_hba_lock);
1129 if (ioc->initializing_hba_lock_flag == 0) {
1130 ioc->initializing_hba_lock_flag=1;
1131 spin_unlock(&ioc->initializing_hba_lock);
1132 status = 0;
1133 break;
1134 }
1135 spin_unlock(&ioc->initializing_hba_lock);
1136 set_current_state(TASK_INTERRUPTIBLE);
1137 schedule_timeout(HZ/4);
1138 } while (--loop_count);
1139
1140 return status;
1141}
1142
1143/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1144/*
1145 * mpt_bringup_adapter - This is a wrapper function for mpt_do_ioc_recovery
1146 * @ioc: Pointer to MPT adapter structure
1147 * @sleepFlag: Use schedule if CAN_SLEEP else use udelay.
1148 *
1149 * This routine performs all the steps necessary to bring the IOC
1150 * to a OPERATIONAL state.
1151 *
1152 * Special Note: This function was added with spin lock's so as to allow
1153 * the dv(domain validation) work thread to succeed on the other channel
1154 * that maybe occuring at the same time when this function is called.
1155 * Without this lock, the dv would fail when message frames were
1156 * requested during hba bringup on the alternate ioc.
1157 */
1158static int
1159mpt_bringup_adapter(MPT_ADAPTER *ioc, int sleepFlag)
1160{
1161 int r;
1162
1163 if(ioc->alt_ioc) {
1164 if((r=mpt_alt_ioc_wait(ioc->alt_ioc)!=0))
1165 return r;
1166 }
1167
1168 r = mpt_do_ioc_recovery(ioc, MPT_HOSTEVENT_IOC_BRINGUP,
1169 CAN_SLEEP);
1170
1171 if(ioc->alt_ioc) {
1172 spin_lock(&ioc->alt_ioc->initializing_hba_lock);
1173 ioc->alt_ioc->initializing_hba_lock_flag=0;
1174 spin_unlock(&ioc->alt_ioc->initializing_hba_lock);
1175 }
1176
1177return r;
1178}
1179
1121/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1180/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1122/* 1181/*
1123 * mpt_attach - Install a PCI intelligent MPT adapter. 1182 * mpt_attach - Install a PCI intelligent MPT adapter.
@@ -1186,6 +1245,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1186 ioc->pcidev = pdev; 1245 ioc->pcidev = pdev;
1187 ioc->diagPending = 0; 1246 ioc->diagPending = 0;
1188 spin_lock_init(&ioc->diagLock); 1247 spin_lock_init(&ioc->diagLock);
1248 spin_lock_init(&ioc->initializing_hba_lock);
1189 1249
1190 /* Initialize the event logging. 1250 /* Initialize the event logging.
1191 */ 1251 */
@@ -1408,8 +1468,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1408 */ 1468 */
1409 mpt_detect_bound_ports(ioc, pdev); 1469 mpt_detect_bound_ports(ioc, pdev);
1410 1470
1411 if ((r = mpt_do_ioc_recovery(ioc, 1471 if ((r = mpt_bringup_adapter(ioc, CAN_SLEEP)) != 0){
1412 MPT_HOSTEVENT_IOC_BRINGUP, CAN_SLEEP)) != 0) {
1413 printk(KERN_WARNING MYNAM 1472 printk(KERN_WARNING MYNAM
1414 ": WARNING - %s did not initialize properly! (%d)\n", 1473 ": WARNING - %s did not initialize properly! (%d)\n",
1415 ioc->name, r); 1474 ioc->name, r);
@@ -6271,6 +6330,7 @@ EXPORT_SYMBOL(mpt_resume);
6271EXPORT_SYMBOL(mpt_suspend); 6330EXPORT_SYMBOL(mpt_suspend);
6272#endif 6331#endif
6273EXPORT_SYMBOL(ioc_list); 6332EXPORT_SYMBOL(ioc_list);
6333EXPORT_SYMBOL(mpt_proc_root_dir);
6274EXPORT_SYMBOL(mpt_register); 6334EXPORT_SYMBOL(mpt_register);
6275EXPORT_SYMBOL(mpt_deregister); 6335EXPORT_SYMBOL(mpt_deregister);
6276EXPORT_SYMBOL(mpt_event_register); 6336EXPORT_SYMBOL(mpt_event_register);
@@ -6288,6 +6348,7 @@ EXPORT_SYMBOL(mpt_verify_adapter);
6288EXPORT_SYMBOL(mpt_GetIocState); 6348EXPORT_SYMBOL(mpt_GetIocState);
6289EXPORT_SYMBOL(mpt_print_ioc_summary); 6349EXPORT_SYMBOL(mpt_print_ioc_summary);
6290EXPORT_SYMBOL(mpt_lan_index); 6350EXPORT_SYMBOL(mpt_lan_index);
6351EXPORT_SYMBOL(mpt_stm_index);
6291EXPORT_SYMBOL(mpt_HardResetHandler); 6352EXPORT_SYMBOL(mpt_HardResetHandler);
6292EXPORT_SYMBOL(mpt_config); 6353EXPORT_SYMBOL(mpt_config);
6293EXPORT_SYMBOL(mpt_toolbox); 6354EXPORT_SYMBOL(mpt_toolbox);
@@ -6296,6 +6357,7 @@ EXPORT_SYMBOL(mpt_read_ioc_pg_3);
6296EXPORT_SYMBOL(mpt_alloc_fw_memory); 6357EXPORT_SYMBOL(mpt_alloc_fw_memory);
6297EXPORT_SYMBOL(mpt_free_fw_memory); 6358EXPORT_SYMBOL(mpt_free_fw_memory);
6298EXPORT_SYMBOL(mptbase_sas_persist_operation); 6359EXPORT_SYMBOL(mptbase_sas_persist_operation);
6360EXPORT_SYMBOL(mpt_alt_ioc_wait);
6299 6361
6300 6362
6301/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 6363/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 8ad277a9afa1..bac8eb4186d2 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -611,6 +611,8 @@ typedef struct _MPT_ADAPTER
611 int DoneCtx; 611 int DoneCtx;
612 int TaskCtx; 612 int TaskCtx;
613 int InternalCtx; 613 int InternalCtx;
614 spinlock_t initializing_hba_lock;
615 int initializing_hba_lock_flag;
614 struct list_head list; 616 struct list_head list;
615 struct net_device *netdev; 617 struct net_device *netdev;
616 struct list_head sas_topology; 618 struct list_head sas_topology;
@@ -1001,13 +1003,16 @@ extern void mpt_free_fw_memory(MPT_ADAPTER *ioc);
1001extern int mpt_findImVolumes(MPT_ADAPTER *ioc); 1003extern int mpt_findImVolumes(MPT_ADAPTER *ioc);
1002extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc); 1004extern int mpt_read_ioc_pg_3(MPT_ADAPTER *ioc);
1003extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode); 1005extern int mptbase_sas_persist_operation(MPT_ADAPTER *ioc, u8 persist_opcode);
1006extern int mpt_alt_ioc_wait(MPT_ADAPTER *ioc);
1004 1007
1005/* 1008/*
1006 * Public data decl's... 1009 * Public data decl's...
1007 */ 1010 */
1008extern struct list_head ioc_list; 1011extern struct list_head ioc_list;
1012extern struct proc_dir_entry *mpt_proc_root_dir;
1009 1013
1010extern int mpt_lan_index; /* needed by mptlan.c */ 1014extern int mpt_lan_index; /* needed by mptlan.c */
1015extern int mpt_stm_index; /* needed by mptstm.c */
1011 1016
1012/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1017/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1013#endif /* } __KERNEL__ */ 1018#endif /* } __KERNEL__ */
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 4330ed0cedaa..b7b9846ff3fd 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -4162,6 +4162,12 @@ mptscsih_domainValidation(void *arg)
4162 } 4162 }
4163 } 4163 }
4164 4164
4165 if(mpt_alt_ioc_wait(hd->ioc)!=0) {
4166 ddvprintk((MYIOC_s_WARN_FMT "alt_ioc busy!\n",
4167 hd->ioc->name));
4168 continue;
4169 }
4170
4165 if (mptscsih_doDv(hd, 0, id) == 1) { 4171 if (mptscsih_doDv(hd, 0, id) == 1) {
4166 /* Untagged device was busy, try again 4172 /* Untagged device was busy, try again
4167 */ 4173 */
@@ -4173,6 +4179,10 @@ mptscsih_domainValidation(void *arg)
4173 hd->ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_PENDING); 4179 hd->ioc->spi_data.dvStatus[id] &= ~(MPT_SCSICFG_DV_NOT_DONE | MPT_SCSICFG_DV_PENDING);
4174 } 4180 }
4175 4181
4182 spin_lock(&hd->ioc->initializing_hba_lock);
4183 hd->ioc->initializing_hba_lock_flag=0;
4184 spin_unlock(&hd->ioc->initializing_hba_lock);
4185
4176 if (isPhysDisk) { 4186 if (isPhysDisk) {
4177 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) { 4187 for (ii=0; ii < MPT_MAX_SCSI_DEVICES; ii++) {
4178 if (hd->ioc->raid_data.isRaid & (1 << ii)) { 4188 if (hd->ioc->raid_data.isRaid & (1 << ii)) {
diff --git a/drivers/message/i2o/pci.c b/drivers/message/i2o/pci.c
index 66c03e882570..ee7075fa1ec3 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
@@ -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
@@ -421,11 +424,12 @@ static int __devinit i2o_pci_probe(struct pci_dev *pdev,
421 i2o_pci_free(c); 424 i2o_pci_free(c);
422 425
423 free_controller: 426 free_controller:
424 i2o_iop_free(c);
425 put_device(c->device.parent); 427 put_device(c->device.parent);
428 i2o_iop_free(c);
426 429
427 disable: 430 disable:
428 pci_disable_device(pdev); 431 if (!pci_dev_busy)
432 pci_disable_device(pdev);
429 433
430 return rc; 434 return rc;
431} 435}
diff --git a/drivers/mfd/mcp-sa11x0.c b/drivers/mfd/mcp-sa11x0.c
index 7daa0ed7331c..1eab7cffceaa 100644
--- a/drivers/mfd/mcp-sa11x0.c
+++ b/drivers/mfd/mcp-sa11x0.c
@@ -138,9 +138,8 @@ static struct mcp_ops mcp_sa11x0 = {
138 .disable = mcp_sa11x0_disable, 138 .disable = mcp_sa11x0_disable,
139}; 139};
140 140
141static int mcp_sa11x0_probe(struct device *dev) 141static int mcp_sa11x0_probe(struct platform_device *pdev)
142{ 142{
143 struct platform_device *pdev = to_platform_device(dev);
144 struct mcp_plat_data *data = pdev->dev.platform_data; 143 struct mcp_plat_data *data = pdev->dev.platform_data;
145 struct mcp *mcp; 144 struct mcp *mcp;
146 int ret; 145 int ret;
@@ -165,7 +164,7 @@ static int mcp_sa11x0_probe(struct device *dev)
165 mcp->dma_telco_rd = DMA_Ser4MCP1Rd; 164 mcp->dma_telco_rd = DMA_Ser4MCP1Rd;
166 mcp->dma_telco_wr = DMA_Ser4MCP1Wr; 165 mcp->dma_telco_wr = DMA_Ser4MCP1Wr;
167 166
168 dev_set_drvdata(dev, mcp); 167 platform_set_drvdata(pdev, mcp);
169 168
170 if (machine_is_assabet()) { 169 if (machine_is_assabet()) {
171 ASSABET_BCR_set(ASSABET_BCR_CODEC_RST); 170 ASSABET_BCR_set(ASSABET_BCR_CODEC_RST);
@@ -202,26 +201,26 @@ static int mcp_sa11x0_probe(struct device *dev)
202 201
203 release: 202 release:
204 release_mem_region(0x80060000, 0x60); 203 release_mem_region(0x80060000, 0x60);
205 dev_set_drvdata(dev, NULL); 204 platform_set_drvdata(pdev, NULL);
206 205
207 out: 206 out:
208 return ret; 207 return ret;
209} 208}
210 209
211static int mcp_sa11x0_remove(struct device *dev) 210static int mcp_sa11x0_remove(struct platform_device *dev)
212{ 211{
213 struct mcp *mcp = dev_get_drvdata(dev); 212 struct mcp *mcp = platform_get_drvdata(dev);
214 213
215 dev_set_drvdata(dev, NULL); 214 platform_set_drvdata(dev, NULL);
216 mcp_host_unregister(mcp); 215 mcp_host_unregister(mcp);
217 release_mem_region(0x80060000, 0x60); 216 release_mem_region(0x80060000, 0x60);
218 217
219 return 0; 218 return 0;
220} 219}
221 220
222static int mcp_sa11x0_suspend(struct device *dev, pm_message_t state) 221static int mcp_sa11x0_suspend(struct platform_device *dev, pm_message_t state)
223{ 222{
224 struct mcp *mcp = dev_get_drvdata(dev); 223 struct mcp *mcp = platform_get_drvdata(dev);
225 224
226 priv(mcp)->mccr0 = Ser4MCCR0; 225 priv(mcp)->mccr0 = Ser4MCCR0;
227 priv(mcp)->mccr1 = Ser4MCCR1; 226 priv(mcp)->mccr1 = Ser4MCCR1;
@@ -230,9 +229,9 @@ static int mcp_sa11x0_suspend(struct device *dev, pm_message_t state)
230 return 0; 229 return 0;
231} 230}
232 231
233static int mcp_sa11x0_resume(struct device *dev) 232static int mcp_sa11x0_resume(struct platform_device *dev)
234{ 233{
235 struct mcp *mcp = dev_get_drvdata(dev); 234 struct mcp *mcp = platform_get_drvdata(dev);
236 235
237 Ser4MCCR1 = priv(mcp)->mccr1; 236 Ser4MCCR1 = priv(mcp)->mccr1;
238 Ser4MCCR0 = priv(mcp)->mccr0; 237 Ser4MCCR0 = priv(mcp)->mccr0;
@@ -243,13 +242,14 @@ static int mcp_sa11x0_resume(struct device *dev)
243/* 242/*
244 * The driver for the SA11x0 MCP port. 243 * The driver for the SA11x0 MCP port.
245 */ 244 */
246static struct device_driver mcp_sa11x0_driver = { 245static struct platform_driver mcp_sa11x0_driver = {
247 .name = "sa11x0-mcp",
248 .bus = &platform_bus_type,
249 .probe = mcp_sa11x0_probe, 246 .probe = mcp_sa11x0_probe,
250 .remove = mcp_sa11x0_remove, 247 .remove = mcp_sa11x0_remove,
251 .suspend = mcp_sa11x0_suspend, 248 .suspend = mcp_sa11x0_suspend,
252 .resume = mcp_sa11x0_resume, 249 .resume = mcp_sa11x0_resume,
250 .driver = {
251 .name = "sa11x0-mcp",
252 },
253}; 253};
254 254
255/* 255/*
@@ -257,12 +257,12 @@ static struct device_driver mcp_sa11x0_driver = {
257 */ 257 */
258static int __init mcp_sa11x0_init(void) 258static int __init mcp_sa11x0_init(void)
259{ 259{
260 return driver_register(&mcp_sa11x0_driver); 260 return platform_driver_register(&mcp_sa11x0_driver);
261} 261}
262 262
263static void __exit mcp_sa11x0_exit(void) 263static void __exit mcp_sa11x0_exit(void)
264{ 264{
265 driver_unregister(&mcp_sa11x0_driver); 265 platform_driver_unregister(&mcp_sa11x0_driver);
266} 266}
267 267
268module_init(mcp_sa11x0_init); 268module_init(mcp_sa11x0_init);
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/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c
index bc2b72b32905..11a801be71c8 100644
--- a/drivers/misc/hdpuftrs/hdpu_cpustate.c
+++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c
@@ -26,8 +26,8 @@
26 26
27#define SKY_CPUSTATE_VERSION "1.1" 27#define SKY_CPUSTATE_VERSION "1.1"
28 28
29static int hdpu_cpustate_probe(struct device *ddev); 29static int hdpu_cpustate_probe(struct platform_device *pdev);
30static int hdpu_cpustate_remove(struct device *ddev); 30static int hdpu_cpustate_remove(struct platform_device *pdev);
31 31
32struct cpustate_t cpustate; 32struct cpustate_t cpustate;
33 33
@@ -158,11 +158,12 @@ static int cpustate_read_proc(char *page, char **start, off_t off,
158 return len; 158 return len;
159} 159}
160 160
161static struct device_driver hdpu_cpustate_driver = { 161static struct platform_driver hdpu_cpustate_driver = {
162 .name = HDPU_CPUSTATE_NAME,
163 .bus = &platform_bus_type,
164 .probe = hdpu_cpustate_probe, 162 .probe = hdpu_cpustate_probe,
165 .remove = hdpu_cpustate_remove, 163 .remove = hdpu_cpustate_remove,
164 .driver = {
165 .name = HDPU_CPUSTATE_NAME,
166 },
166}; 167};
167 168
168/* 169/*
@@ -187,9 +188,8 @@ static struct miscdevice cpustate_dev = {
187 &cpustate_fops 188 &cpustate_fops
188}; 189};
189 190
190static int hdpu_cpustate_probe(struct device *ddev) 191static int hdpu_cpustate_probe(struct platform_device *pdev)
191{ 192{
192 struct platform_device *pdev = to_platform_device(ddev);
193 struct resource *res; 193 struct resource *res;
194 struct proc_dir_entry *proc_de; 194 struct proc_dir_entry *proc_de;
195 int ret; 195 int ret;
@@ -217,7 +217,7 @@ static int hdpu_cpustate_probe(struct device *ddev)
217 return 0; 217 return 0;
218} 218}
219 219
220static int hdpu_cpustate_remove(struct device *ddev) 220static int hdpu_cpustate_remove(struct platform_device *pdev)
221{ 221{
222 222
223 cpustate.set_addr = NULL; 223 cpustate.set_addr = NULL;
@@ -232,13 +232,13 @@ static int hdpu_cpustate_remove(struct device *ddev)
232static int __init cpustate_init(void) 232static int __init cpustate_init(void)
233{ 233{
234 int rc; 234 int rc;
235 rc = driver_register(&hdpu_cpustate_driver); 235 rc = platform_driver_register(&hdpu_cpustate_driver);
236 return rc; 236 return rc;
237} 237}
238 238
239static void __exit cpustate_exit(void) 239static void __exit cpustate_exit(void)
240{ 240{
241 driver_unregister(&hdpu_cpustate_driver); 241 platform_driver_unregister(&hdpu_cpustate_driver);
242} 242}
243 243
244module_init(cpustate_init); 244module_init(cpustate_init);
diff --git a/drivers/misc/hdpuftrs/hdpu_nexus.c b/drivers/misc/hdpuftrs/hdpu_nexus.c
index 4bb461793851..ea9d5f233c83 100644
--- a/drivers/misc/hdpuftrs/hdpu_nexus.c
+++ b/drivers/misc/hdpuftrs/hdpu_nexus.c
@@ -22,19 +22,20 @@
22 22
23#include <linux/platform_device.h> 23#include <linux/platform_device.h>
24 24
25static int hdpu_nexus_probe(struct device *ddev); 25static int hdpu_nexus_probe(struct platform_device *pdev);
26static int hdpu_nexus_remove(struct device *ddev); 26static int hdpu_nexus_remove(struct platform_device *pdev);
27 27
28static struct proc_dir_entry *hdpu_slot_id; 28static struct proc_dir_entry *hdpu_slot_id;
29static struct proc_dir_entry *hdpu_chassis_id; 29static struct proc_dir_entry *hdpu_chassis_id;
30static int slot_id = -1; 30static int slot_id = -1;
31static int chassis_id = -1; 31static int chassis_id = -1;
32 32
33static struct device_driver hdpu_nexus_driver = { 33static struct platform_driver hdpu_nexus_driver = {
34 .name = HDPU_NEXUS_NAME,
35 .bus = &platform_bus_type,
36 .probe = hdpu_nexus_probe, 34 .probe = hdpu_nexus_probe,
37 .remove = hdpu_nexus_remove, 35 .remove = hdpu_nexus_remove,
36 .driver = {
37 .name = HDPU_NEXUS_NAME,
38 },
38}; 39};
39 40
40int hdpu_slot_id_read(char *buffer, char **buffer_location, off_t offset, 41int hdpu_slot_id_read(char *buffer, char **buffer_location, off_t offset,
@@ -55,9 +56,8 @@ int hdpu_chassis_id_read(char *buffer, char **buffer_location, off_t offset,
55 return sprintf(buffer, "%d\n", chassis_id); 56 return sprintf(buffer, "%d\n", chassis_id);
56} 57}
57 58
58static int hdpu_nexus_probe(struct device *ddev) 59static int hdpu_nexus_probe(struct platform_device *pdev)
59{ 60{
60 struct platform_device *pdev = to_platform_device(ddev);
61 struct resource *res; 61 struct resource *res;
62 62
63 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 63 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -80,7 +80,7 @@ static int hdpu_nexus_probe(struct device *ddev)
80 return 0; 80 return 0;
81} 81}
82 82
83static int hdpu_nexus_remove(struct device *ddev) 83static int hdpu_nexus_remove(struct platform_device *pdev)
84{ 84{
85 slot_id = -1; 85 slot_id = -1;
86 chassis_id = -1; 86 chassis_id = -1;
@@ -94,13 +94,13 @@ static int hdpu_nexus_remove(struct device *ddev)
94static int __init nexus_init(void) 94static int __init nexus_init(void)
95{ 95{
96 int rc; 96 int rc;
97 rc = driver_register(&hdpu_nexus_driver); 97 rc = platform_driver_register(&hdpu_nexus_driver);
98 return rc; 98 return rc;
99} 99}
100 100
101static void __exit nexus_exit(void) 101static void __exit nexus_exit(void)
102{ 102{
103 driver_unregister(&hdpu_nexus_driver); 103 platform_driver_unregister(&hdpu_nexus_driver);
104} 104}
105 105
106module_init(nexus_init); 106module_init(nexus_init);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index da528390acf8..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{
@@ -816,7 +824,7 @@ static void mmc_discover_cards(struct mmc_host *host)
816 824
817 cmd.opcode = SD_SEND_RELATIVE_ADDR; 825 cmd.opcode = SD_SEND_RELATIVE_ADDR;
818 cmd.arg = 0; 826 cmd.arg = 0;
819 cmd.flags = MMC_RSP_R1; 827 cmd.flags = MMC_RSP_R6;
820 828
821 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES); 829 err = mmc_wait_for_cmd(host, &cmd, CMD_RETRIES);
822 if (err != MMC_ERR_NONE) 830 if (err != MMC_ERR_NONE)
@@ -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..abcf19116d70 100644
--- a/drivers/mmc/mmc_block.c
+++ b/drivers/mmc/mmc_block.c
@@ -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/mmci.c b/drivers/mmc/mmci.c
index 1e6bdba26756..166c9b0ad04e 100644
--- a/drivers/mmc/mmci.c
+++ b/drivers/mmc/mmci.c
@@ -22,7 +22,6 @@
22 22
23#include <asm/div64.h> 23#include <asm/div64.h>
24#include <asm/io.h> 24#include <asm/io.h>
25#include <asm/irq.h>
26#include <asm/scatterlist.h> 25#include <asm/scatterlist.h>
27#include <asm/sizes.h> 26#include <asm/sizes.h>
28#include <asm/hardware/amba.h> 27#include <asm/hardware/amba.h>
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index f31e247b2cbe..ee8f8a0420d1 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -428,9 +428,8 @@ static irqreturn_t pxamci_detect_irq(int irq, void *devid, struct pt_regs *regs)
428 return IRQ_HANDLED; 428 return IRQ_HANDLED;
429} 429}
430 430
431static int pxamci_probe(struct device *dev) 431static int pxamci_probe(struct platform_device *pdev)
432{ 432{
433 struct platform_device *pdev = to_platform_device(dev);
434 struct mmc_host *mmc; 433 struct mmc_host *mmc;
435 struct pxamci_host *host = NULL; 434 struct pxamci_host *host = NULL;
436 struct resource *r; 435 struct resource *r;
@@ -445,7 +444,7 @@ static int pxamci_probe(struct device *dev)
445 if (!r) 444 if (!r)
446 return -EBUSY; 445 return -EBUSY;
447 446
448 mmc = mmc_alloc_host(sizeof(struct pxamci_host), dev); 447 mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev);
449 if (!mmc) { 448 if (!mmc) {
450 ret = -ENOMEM; 449 ret = -ENOMEM;
451 goto out; 450 goto out;
@@ -474,7 +473,7 @@ static int pxamci_probe(struct device *dev)
474 host->pdata->ocr_mask : 473 host->pdata->ocr_mask :
475 MMC_VDD_32_33|MMC_VDD_33_34; 474 MMC_VDD_32_33|MMC_VDD_33_34;
476 475
477 host->sg_cpu = dma_alloc_coherent(dev, PAGE_SIZE, &host->sg_dma, GFP_KERNEL); 476 host->sg_cpu = dma_alloc_coherent(&pdev->dev, PAGE_SIZE, &host->sg_dma, GFP_KERNEL);
478 if (!host->sg_cpu) { 477 if (!host->sg_cpu) {
479 ret = -ENOMEM; 478 ret = -ENOMEM;
480 goto out; 479 goto out;
@@ -511,10 +510,10 @@ static int pxamci_probe(struct device *dev)
511 if (ret) 510 if (ret)
512 goto out; 511 goto out;
513 512
514 dev_set_drvdata(dev, mmc); 513 platform_set_drvdata(pdev, mmc);
515 514
516 if (host->pdata && host->pdata->init) 515 if (host->pdata && host->pdata->init)
517 host->pdata->init(dev, pxamci_detect_irq, mmc); 516 host->pdata->init(&pdev->dev, pxamci_detect_irq, mmc);
518 517
519 mmc_add_host(mmc); 518 mmc_add_host(mmc);
520 519
@@ -527,7 +526,7 @@ static int pxamci_probe(struct device *dev)
527 if (host->base) 526 if (host->base)
528 iounmap(host->base); 527 iounmap(host->base);
529 if (host->sg_cpu) 528 if (host->sg_cpu)
530 dma_free_coherent(dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); 529 dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
531 } 530 }
532 if (mmc) 531 if (mmc)
533 mmc_free_host(mmc); 532 mmc_free_host(mmc);
@@ -535,17 +534,17 @@ static int pxamci_probe(struct device *dev)
535 return ret; 534 return ret;
536} 535}
537 536
538static int pxamci_remove(struct device *dev) 537static int pxamci_remove(struct platform_device *pdev)
539{ 538{
540 struct mmc_host *mmc = dev_get_drvdata(dev); 539 struct mmc_host *mmc = platform_get_drvdata(pdev);
541 540
542 dev_set_drvdata(dev, NULL); 541 platform_set_drvdata(pdev, NULL);
543 542
544 if (mmc) { 543 if (mmc) {
545 struct pxamci_host *host = mmc_priv(mmc); 544 struct pxamci_host *host = mmc_priv(mmc);
546 545
547 if (host->pdata && host->pdata->exit) 546 if (host->pdata && host->pdata->exit)
548 host->pdata->exit(dev, mmc); 547 host->pdata->exit(&pdev->dev, mmc);
549 548
550 mmc_remove_host(mmc); 549 mmc_remove_host(mmc);
551 550
@@ -560,7 +559,7 @@ static int pxamci_remove(struct device *dev)
560 free_irq(host->irq, host); 559 free_irq(host->irq, host);
561 pxa_free_dma(host->dma); 560 pxa_free_dma(host->dma);
562 iounmap(host->base); 561 iounmap(host->base);
563 dma_free_coherent(dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); 562 dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma);
564 563
565 release_resource(host->res); 564 release_resource(host->res);
566 565
@@ -570,9 +569,9 @@ static int pxamci_remove(struct device *dev)
570} 569}
571 570
572#ifdef CONFIG_PM 571#ifdef CONFIG_PM
573static int pxamci_suspend(struct device *dev, pm_message_t state) 572static int pxamci_suspend(struct platform_device *dev, pm_message_t state)
574{ 573{
575 struct mmc_host *mmc = dev_get_drvdata(dev); 574 struct mmc_host *mmc = platform_get_drvdata(dev);
576 int ret = 0; 575 int ret = 0;
577 576
578 if (mmc) 577 if (mmc)
@@ -581,9 +580,9 @@ static int pxamci_suspend(struct device *dev, pm_message_t state)
581 return ret; 580 return ret;
582} 581}
583 582
584static int pxamci_resume(struct device *dev) 583static int pxamci_resume(struct platform_device *dev)
585{ 584{
586 struct mmc_host *mmc = dev_get_drvdata(dev); 585 struct mmc_host *mmc = platform_get_drvdata(dev);
587 int ret = 0; 586 int ret = 0;
588 587
589 if (mmc) 588 if (mmc)
@@ -596,23 +595,24 @@ static int pxamci_resume(struct device *dev)
596#define pxamci_resume NULL 595#define pxamci_resume NULL
597#endif 596#endif
598 597
599static struct device_driver pxamci_driver = { 598static struct platform_driver pxamci_driver = {
600 .name = DRIVER_NAME,
601 .bus = &platform_bus_type,
602 .probe = pxamci_probe, 599 .probe = pxamci_probe,
603 .remove = pxamci_remove, 600 .remove = pxamci_remove,
604 .suspend = pxamci_suspend, 601 .suspend = pxamci_suspend,
605 .resume = pxamci_resume, 602 .resume = pxamci_resume,
603 .driver = {
604 .name = DRIVER_NAME,
605 },
606}; 606};
607 607
608static int __init pxamci_init(void) 608static int __init pxamci_init(void)
609{ 609{
610 return driver_register(&pxamci_driver); 610 return platform_driver_register(&pxamci_driver);
611} 611}
612 612
613static void __exit pxamci_exit(void) 613static void __exit pxamci_exit(void)
614{ 614{
615 driver_unregister(&pxamci_driver); 615 platform_driver_unregister(&pxamci_driver);
616} 616}
617 617
618module_init(pxamci_init); 618module_init(pxamci_init);
diff --git a/drivers/mmc/wbsd.c b/drivers/mmc/wbsd.c
index e954b8354fef..c7eb7c269081 100644
--- a/drivers/mmc/wbsd.c
+++ b/drivers/mmc/wbsd.c
@@ -42,7 +42,7 @@
42#include "wbsd.h" 42#include "wbsd.h"
43 43
44#define DRIVER_NAME "wbsd" 44#define DRIVER_NAME "wbsd"
45#define DRIVER_VERSION "1.4" 45#define DRIVER_VERSION "1.5"
46 46
47#ifdef CONFIG_MMC_DEBUG 47#ifdef CONFIG_MMC_DEBUG
48#define DBG(x...) \ 48#define DBG(x...) \
@@ -1932,14 +1932,14 @@ static void __devexit wbsd_shutdown(struct device* dev, int pnp)
1932 * Non-PnP 1932 * Non-PnP
1933 */ 1933 */
1934 1934
1935static int __devinit wbsd_probe(struct device* dev) 1935static int __devinit wbsd_probe(struct platform_device* dev)
1936{ 1936{
1937 return wbsd_init(dev, io, irq, dma, 0); 1937 return wbsd_init(&dev->dev, io, irq, dma, 0);
1938} 1938}
1939 1939
1940static int __devexit wbsd_remove(struct device* dev) 1940static int __devexit wbsd_remove(struct platform_device* dev)
1941{ 1941{
1942 wbsd_shutdown(dev, 0); 1942 wbsd_shutdown(&dev->dev, 0);
1943 1943
1944 return 0; 1944 return 0;
1945} 1945}
@@ -1983,9 +1983,9 @@ static void __devexit wbsd_pnp_remove(struct pnp_dev * dev)
1983 1983
1984#ifdef CONFIG_PM 1984#ifdef CONFIG_PM
1985 1985
1986static int wbsd_suspend(struct device *dev, pm_message_t state) 1986static int wbsd_suspend(struct platform_device *dev, pm_message_t state)
1987{ 1987{
1988 struct mmc_host *mmc = dev_get_drvdata(dev); 1988 struct mmc_host *mmc = platform_get_drvdata(dev);
1989 struct wbsd_host *host; 1989 struct wbsd_host *host;
1990 int ret; 1990 int ret;
1991 1991
@@ -2005,9 +2005,9 @@ static int wbsd_suspend(struct device *dev, pm_message_t state)
2005 return 0; 2005 return 0;
2006} 2006}
2007 2007
2008static int wbsd_resume(struct device *dev) 2008static int wbsd_resume(struct platform_device *dev)
2009{ 2009{
2010 struct mmc_host *mmc = dev_get_drvdata(dev); 2010 struct mmc_host *mmc = platform_get_drvdata(dev);
2011 struct wbsd_host *host; 2011 struct wbsd_host *host;
2012 2012
2013 if (!mmc) 2013 if (!mmc)
@@ -2038,14 +2038,15 @@ static int wbsd_resume(struct device *dev)
2038 2038
2039static struct platform_device *wbsd_device; 2039static struct platform_device *wbsd_device;
2040 2040
2041static struct device_driver wbsd_driver = { 2041static struct platform_driver wbsd_driver = {
2042 .name = DRIVER_NAME,
2043 .bus = &platform_bus_type,
2044 .probe = wbsd_probe, 2042 .probe = wbsd_probe,
2045 .remove = wbsd_remove, 2043 .remove = __devexit_p(wbsd_remove),
2046 2044
2047 .suspend = wbsd_suspend, 2045 .suspend = wbsd_suspend,
2048 .resume = wbsd_resume, 2046 .resume = wbsd_resume,
2047 .driver = {
2048 .name = DRIVER_NAME,
2049 },
2049}; 2050};
2050 2051
2051#ifdef CONFIG_PNP 2052#ifdef CONFIG_PNP
@@ -2054,7 +2055,7 @@ static struct pnp_driver wbsd_pnp_driver = {
2054 .name = DRIVER_NAME, 2055 .name = DRIVER_NAME,
2055 .id_table = pnp_dev_table, 2056 .id_table = pnp_dev_table,
2056 .probe = wbsd_pnp_probe, 2057 .probe = wbsd_pnp_probe,
2057 .remove = wbsd_pnp_remove, 2058 .remove = __devexit_p(wbsd_pnp_remove),
2058}; 2059};
2059 2060
2060#endif /* CONFIG_PNP */ 2061#endif /* CONFIG_PNP */
@@ -2085,7 +2086,7 @@ static int __init wbsd_drv_init(void)
2085 2086
2086 if (nopnp) 2087 if (nopnp)
2087 { 2088 {
2088 result = driver_register(&wbsd_driver); 2089 result = platform_driver_register(&wbsd_driver);
2089 if (result < 0) 2090 if (result < 0)
2090 return result; 2091 return result;
2091 2092
@@ -2111,7 +2112,7 @@ static void __exit wbsd_drv_exit(void)
2111 { 2112 {
2112 platform_device_unregister(wbsd_device); 2113 platform_device_unregister(wbsd_device);
2113 2114
2114 driver_unregister(&wbsd_driver); 2115 platform_driver_unregister(&wbsd_driver);
2115 } 2116 }
2116 2117
2117 DBG("unloaded\n"); 2118 DBG("unloaded\n");
@@ -2127,6 +2128,7 @@ module_param(irq, uint, 0444);
2127module_param(dma, int, 0444); 2128module_param(dma, int, 0444);
2128 2129
2129MODULE_LICENSE("GPL"); 2130MODULE_LICENSE("GPL");
2131MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>");
2130MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver"); 2132MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver");
2131MODULE_VERSION(DRIVER_VERSION); 2133MODULE_VERSION(DRIVER_VERSION);
2132 2134
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c
index 143f01a4c170..69c04945591f 100644
--- a/drivers/mtd/chips/cfi_cmdset_0001.c
+++ b/drivers/mtd/chips/cfi_cmdset_0001.c
@@ -4,7 +4,7 @@
4 * 4 *
5 * (C) 2000 Red Hat. GPL'd 5 * (C) 2000 Red Hat. GPL'd
6 * 6 *
7 * $Id: cfi_cmdset_0001.c,v 1.185 2005/11/07 11:14:22 gleixner Exp $ 7 * $Id: cfi_cmdset_0001.c,v 1.186 2005/11/23 22:07:52 nico Exp $
8 * 8 *
9 * 9 *
10 * 10/10/2000 Nicolas Pitre <nico@cam.org> 10 * 10/10/2000 Nicolas Pitre <nico@cam.org>
@@ -644,9 +644,8 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
644 * 644 *
645 * - contension arbitration is handled in the owner's context. 645 * - contension arbitration is handled in the owner's context.
646 * 646 *
647 * The 'shared' struct can be read when its lock is taken. 647 * The 'shared' struct can be read and/or written only when
648 * However any writes to it can only be made when the current 648 * its lock is taken.
649 * owner's lock is also held.
650 */ 649 */
651 struct flchip_shared *shared = chip->priv; 650 struct flchip_shared *shared = chip->priv;
652 struct flchip *contender; 651 struct flchip *contender;
@@ -675,14 +674,13 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
675 } 674 }
676 timeo = jiffies + HZ; 675 timeo = jiffies + HZ;
677 spin_lock(&shared->lock); 676 spin_lock(&shared->lock);
677 spin_unlock(contender->mutex);
678 } 678 }
679 679
680 /* We now own it */ 680 /* We now own it */
681 shared->writing = chip; 681 shared->writing = chip;
682 if (mode == FL_ERASING) 682 if (mode == FL_ERASING)
683 shared->erasing = chip; 683 shared->erasing = chip;
684 if (contender && contender != chip)
685 spin_unlock(contender->mutex);
686 spin_unlock(&shared->lock); 684 spin_unlock(&shared->lock);
687 } 685 }
688 686
diff --git a/drivers/mtd/chips/cfi_probe.c b/drivers/mtd/chips/cfi_probe.c
index 90eb30e06b7c..e636aa86bc24 100644
--- a/drivers/mtd/chips/cfi_probe.c
+++ b/drivers/mtd/chips/cfi_probe.c
@@ -1,7 +1,7 @@
1/* 1/*
2 Common Flash Interface probe code. 2 Common Flash Interface probe code.
3 (C) 2000 Red Hat. GPL'd. 3 (C) 2000 Red Hat. GPL'd.
4 $Id: cfi_probe.c,v 1.84 2005/11/07 11:14:23 gleixner Exp $ 4 $Id: cfi_probe.c,v 1.86 2005/11/29 14:48:31 gleixner Exp $
5*/ 5*/
6 6
7#include <linux/config.h> 7#include <linux/config.h>
@@ -230,8 +230,8 @@ static int __xipram cfi_chip_setup(struct map_info *map,
230 cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL); 230 cfi_send_gen_cmd(0xaa, 0x555, base, map, cfi, cfi->device_type, NULL);
231 cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL); 231 cfi_send_gen_cmd(0x55, 0x2aa, base, map, cfi, cfi->device_type, NULL);
232 cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL); 232 cfi_send_gen_cmd(0x90, 0x555, base, map, cfi, cfi->device_type, NULL);
233 cfi->mfr = cfi_read_query(map, base); 233 cfi->mfr = cfi_read_query16(map, base);
234 cfi->id = cfi_read_query(map, base + ofs_factor); 234 cfi->id = cfi_read_query16(map, base + ofs_factor);
235 235
236 /* Put it back into Read Mode */ 236 /* Put it back into Read Mode */
237 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL); 237 cfi_send_gen_cmd(0xF0, 0, base, map, cfi, cfi->device_type, NULL);
@@ -426,7 +426,7 @@ static struct mtd_chip_driver cfi_chipdrv = {
426 .module = THIS_MODULE 426 .module = THIS_MODULE
427}; 427};
428 428
429int __init cfi_probe_init(void) 429static int __init cfi_probe_init(void)
430{ 430{
431 register_mtd_chip_driver(&cfi_chipdrv); 431 register_mtd_chip_driver(&cfi_chipdrv);
432 return 0; 432 return 0;
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c
index 2d26bdef82d5..36f61a6a766e 100644
--- a/drivers/mtd/chips/sharp.c
+++ b/drivers/mtd/chips/sharp.c
@@ -4,7 +4,7 @@
4 * Copyright 2000,2001 David A. Schleef <ds@schleef.org> 4 * Copyright 2000,2001 David A. Schleef <ds@schleef.org>
5 * 2000,2001 Lineo, Inc. 5 * 2000,2001 Lineo, Inc.
6 * 6 *
7 * $Id: sharp.c,v 1.16 2005/11/07 11:14:23 gleixner Exp $ 7 * $Id: sharp.c,v 1.17 2005/11/29 14:28:28 gleixner Exp $
8 * 8 *
9 * Devices supported: 9 * Devices supported:
10 * LH28F016SCT Symmetrical block flash memory, 2Mx8 10 * LH28F016SCT Symmetrical block flash memory, 2Mx8
@@ -160,22 +160,28 @@ struct mtd_info *sharp_probe(struct map_info *map)
160 return mtd; 160 return mtd;
161} 161}
162 162
163static inline void sharp_send_cmd(struct map_info *map, unsigned long cmd, unsigned long adr)
164{
165 map_word map_cmd;
166 map_cmd.x[0] = cmd;
167 map_write(map, map_cmd, adr);
168}
169
163static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd) 170static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
164{ 171{
165 unsigned long tmp; 172 map_word tmp, read0, read4;
166 unsigned long base = 0; 173 unsigned long base = 0;
167 u32 read0, read4;
168 int width = 4; 174 int width = 4;
169 175
170 tmp = map_read32(map, base+0); 176 tmp = map_read(map, base+0);
171 177
172 map_write32(map, CMD_READ_ID, base+0); 178 sharp_send_cmd(map, CMD_READ_ID, base+0);
173 179
174 read0=map_read32(map, base+0); 180 read0 = map_read(map, base+0);
175 read4=map_read32(map, base+4); 181 read4 = map_read(map, base+4);
176 if(read0 == 0x89898989){ 182 if(read0.x[0] == 0x89898989){
177 printk("Looks like sharp flash\n"); 183 printk("Looks like sharp flash\n");
178 switch(read4){ 184 switch(read4.x[0]){
179 case 0xaaaaaaaa: 185 case 0xaaaaaaaa:
180 case 0xa0a0a0a0: 186 case 0xa0a0a0a0:
181 /* aa - LH28F016SCT-L95 2Mx8, 32 64k blocks*/ 187 /* aa - LH28F016SCT-L95 2Mx8, 32 64k blocks*/
@@ -197,16 +203,16 @@ static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
197 return width; 203 return width;
198#endif 204#endif
199 default: 205 default:
200 printk("Sort-of looks like sharp flash, 0x%08x 0x%08x\n", 206 printk("Sort-of looks like sharp flash, 0x%08lx 0x%08lx\n",
201 read0,read4); 207 read0.x[0], read4.x[0]);
202 } 208 }
203 }else if((map_read32(map, base+0) == CMD_READ_ID)){ 209 }else if((map_read(map, base+0).x[0] == CMD_READ_ID)){
204 /* RAM, probably */ 210 /* RAM, probably */
205 printk("Looks like RAM\n"); 211 printk("Looks like RAM\n");
206 map_write32(map, tmp, base+0); 212 map_write(map, tmp, base+0);
207 }else{ 213 }else{
208 printk("Doesn't look like sharp flash, 0x%08x 0x%08x\n", 214 printk("Doesn't look like sharp flash, 0x%08lx 0x%08lx\n",
209 read0,read4); 215 read0.x[0], read4.x[0]);
210 } 216 }
211 217
212 return 0; 218 return 0;
@@ -215,7 +221,8 @@ static int sharp_probe_map(struct map_info *map,struct mtd_info *mtd)
215/* This function returns with the chip->mutex lock held. */ 221/* This function returns with the chip->mutex lock held. */
216static int sharp_wait(struct map_info *map, struct flchip *chip) 222static int sharp_wait(struct map_info *map, struct flchip *chip)
217{ 223{
218 int status, i; 224 int i;
225 map_word status;
219 unsigned long timeo = jiffies + HZ; 226 unsigned long timeo = jiffies + HZ;
220 DECLARE_WAITQUEUE(wait, current); 227 DECLARE_WAITQUEUE(wait, current);
221 int adr = 0; 228 int adr = 0;
@@ -225,12 +232,12 @@ retry:
225 232
226 switch(chip->state){ 233 switch(chip->state){
227 case FL_READY: 234 case FL_READY:
228 map_write32(map,CMD_READ_STATUS,adr); 235 sharp_send_cmd(map, CMD_READ_STATUS, adr);
229 chip->state = FL_STATUS; 236 chip->state = FL_STATUS;
230 case FL_STATUS: 237 case FL_STATUS:
231 for(i=0;i<100;i++){ 238 for(i=0;i<100;i++){
232 status = map_read32(map,adr); 239 status = map_read(map, adr);
233 if((status & SR_READY)==SR_READY) 240 if((status.x[0] & SR_READY)==SR_READY)
234 break; 241 break;
235 udelay(1); 242 udelay(1);
236 } 243 }
@@ -254,7 +261,7 @@ retry:
254 goto retry; 261 goto retry;
255 } 262 }
256 263
257 map_write32(map,CMD_RESET, adr); 264 sharp_send_cmd(map, CMD_RESET, adr);
258 265
259 chip->state = FL_READY; 266 chip->state = FL_READY;
260 267
@@ -351,37 +358,39 @@ static int sharp_write_oneword(struct map_info *map, struct flchip *chip,
351 int timeo; 358 int timeo;
352 int try; 359 int try;
353 int i; 360 int i;
354 int status = 0; 361 map_word data, status;
355 362
363 status.x[0] = 0;
356 ret = sharp_wait(map,chip); 364 ret = sharp_wait(map,chip);
357 365
358 for(try=0;try<10;try++){ 366 for(try=0;try<10;try++){
359 map_write32(map,CMD_BYTE_WRITE,adr); 367 sharp_send_cmd(map, CMD_BYTE_WRITE, adr);
360 /* cpu_to_le32 -> hack to fix the writel be->le conversion */ 368 /* cpu_to_le32 -> hack to fix the writel be->le conversion */
361 map_write32(map,cpu_to_le32(datum),adr); 369 data.x[0] = cpu_to_le32(datum);
370 map_write(map, data, adr);
362 371
363 chip->state = FL_WRITING; 372 chip->state = FL_WRITING;
364 373
365 timeo = jiffies + (HZ/2); 374 timeo = jiffies + (HZ/2);
366 375
367 map_write32(map,CMD_READ_STATUS,adr); 376 sharp_send_cmd(map, CMD_READ_STATUS, adr);
368 for(i=0;i<100;i++){ 377 for(i=0;i<100;i++){
369 status = map_read32(map,adr); 378 status = map_read(map, adr);
370 if((status & SR_READY)==SR_READY) 379 if((status.x[0] & SR_READY) == SR_READY)
371 break; 380 break;
372 } 381 }
373 if(i==100){ 382 if(i==100){
374 printk("sharp: timed out writing\n"); 383 printk("sharp: timed out writing\n");
375 } 384 }
376 385
377 if(!(status&SR_ERRORS)) 386 if(!(status.x[0] & SR_ERRORS))
378 break; 387 break;
379 388
380 printk("sharp: error writing byte at addr=%08lx status=%08x\n",adr,status); 389 printk("sharp: error writing byte at addr=%08lx status=%08lx\n", adr, status.x[0]);
381 390
382 map_write32(map,CMD_CLEAR_STATUS,adr); 391 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
383 } 392 }
384 map_write32(map,CMD_RESET,adr); 393 sharp_send_cmd(map, CMD_RESET, adr);
385 chip->state = FL_READY; 394 chip->state = FL_READY;
386 395
387 wake_up(&chip->wq); 396 wake_up(&chip->wq);
@@ -434,18 +443,18 @@ static int sharp_do_wait_for_ready(struct map_info *map, struct flchip *chip,
434{ 443{
435 int ret; 444 int ret;
436 unsigned long timeo; 445 unsigned long timeo;
437 int status; 446 map_word status;
438 DECLARE_WAITQUEUE(wait, current); 447 DECLARE_WAITQUEUE(wait, current);
439 448
440 map_write32(map,CMD_READ_STATUS,adr); 449 sharp_send_cmd(map, CMD_READ_STATUS, adr);
441 status = map_read32(map,adr); 450 status = map_read(map, adr);
442 451
443 timeo = jiffies + HZ; 452 timeo = jiffies + HZ;
444 453
445 while(time_before(jiffies, timeo)){ 454 while(time_before(jiffies, timeo)){
446 map_write32(map,CMD_READ_STATUS,adr); 455 sharp_send_cmd(map, CMD_READ_STATUS, adr);
447 status = map_read32(map,adr); 456 status = map_read(map, adr);
448 if((status & SR_READY)==SR_READY){ 457 if((status.x[0] & SR_READY)==SR_READY){
449 ret = 0; 458 ret = 0;
450 goto out; 459 goto out;
451 } 460 }
@@ -476,7 +485,7 @@ static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip,
476{ 485{
477 int ret; 486 int ret;
478 //int timeo; 487 //int timeo;
479 int status; 488 map_word status;
480 //int i; 489 //int i;
481 490
482//printk("sharp_erase_oneblock()\n"); 491//printk("sharp_erase_oneblock()\n");
@@ -486,26 +495,26 @@ static int sharp_erase_oneblock(struct map_info *map, struct flchip *chip,
486 sharp_unlock_oneblock(map,chip,adr); 495 sharp_unlock_oneblock(map,chip,adr);
487#endif 496#endif
488 497
489 map_write32(map,CMD_BLOCK_ERASE_1,adr); 498 sharp_send_cmd(map, CMD_BLOCK_ERASE_1, adr);
490 map_write32(map,CMD_BLOCK_ERASE_2,adr); 499 sharp_send_cmd(map, CMD_BLOCK_ERASE_2, adr);
491 500
492 chip->state = FL_ERASING; 501 chip->state = FL_ERASING;
493 502
494 ret = sharp_do_wait_for_ready(map,chip,adr); 503 ret = sharp_do_wait_for_ready(map,chip,adr);
495 if(ret<0)return ret; 504 if(ret<0)return ret;
496 505
497 map_write32(map,CMD_READ_STATUS,adr); 506 sharp_send_cmd(map, CMD_READ_STATUS, adr);
498 status = map_read32(map,adr); 507 status = map_read(map, adr);
499 508
500 if(!(status&SR_ERRORS)){ 509 if(!(status.x[0] & SR_ERRORS)){
501 map_write32(map,CMD_RESET,adr); 510 sharp_send_cmd(map, CMD_RESET, adr);
502 chip->state = FL_READY; 511 chip->state = FL_READY;
503 //spin_unlock_bh(chip->mutex); 512 //spin_unlock_bh(chip->mutex);
504 return 0; 513 return 0;
505 } 514 }
506 515
507 printk("sharp: error erasing block at addr=%08lx status=%08x\n",adr,status); 516 printk("sharp: error erasing block at addr=%08lx status=%08lx\n", adr, status.x[0]);
508 map_write32(map,CMD_CLEAR_STATUS,adr); 517 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
509 518
510 //spin_unlock_bh(chip->mutex); 519 //spin_unlock_bh(chip->mutex);
511 520
@@ -517,20 +526,20 @@ static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip,
517 unsigned long adr) 526 unsigned long adr)
518{ 527{
519 int i; 528 int i;
520 int status; 529 map_word status;
521 530
522 map_write32(map,CMD_CLEAR_BLOCK_LOCKS_1,adr); 531 sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_1, adr);
523 map_write32(map,CMD_CLEAR_BLOCK_LOCKS_2,adr); 532 sharp_send_cmd(map, CMD_CLEAR_BLOCK_LOCKS_2, adr);
524 533
525 udelay(100); 534 udelay(100);
526 535
527 status = map_read32(map,adr); 536 status = map_read(map, adr);
528 printk("status=%08x\n",status); 537 printk("status=%08lx\n", status.x[0]);
529 538
530 for(i=0;i<1000;i++){ 539 for(i=0;i<1000;i++){
531 //map_write32(map,CMD_READ_STATUS,adr); 540 //sharp_send_cmd(map, CMD_READ_STATUS, adr);
532 status = map_read32(map,adr); 541 status = map_read(map, adr);
533 if((status & SR_READY)==SR_READY) 542 if((status.x[0] & SR_READY) == SR_READY)
534 break; 543 break;
535 udelay(100); 544 udelay(100);
536 } 545 }
@@ -538,14 +547,14 @@ static void sharp_unlock_oneblock(struct map_info *map, struct flchip *chip,
538 printk("sharp: timed out unlocking block\n"); 547 printk("sharp: timed out unlocking block\n");
539 } 548 }
540 549
541 if(!(status&SR_ERRORS)){ 550 if(!(status.x[0] & SR_ERRORS)){
542 map_write32(map,CMD_RESET,adr); 551 sharp_send_cmd(map, CMD_RESET, adr);
543 chip->state = FL_READY; 552 chip->state = FL_READY;
544 return; 553 return;
545 } 554 }
546 555
547 printk("sharp: error unlocking block at addr=%08lx status=%08x\n",adr,status); 556 printk("sharp: error unlocking block at addr=%08lx status=%08lx\n", adr, status.x[0]);
548 map_write32(map,CMD_CLEAR_STATUS,adr); 557 sharp_send_cmd(map, CMD_CLEAR_STATUS, adr);
549} 558}
550#endif 559#endif
551 560
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/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c
index 0aaa0ced9aba..7ff403b2a0a0 100644
--- a/drivers/mtd/devices/block2mtd.c
+++ b/drivers/mtd/devices/block2mtd.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: block2mtd.c,v 1.29 2005/11/07 11:14:24 gleixner Exp $ 2 * $Id: block2mtd.c,v 1.30 2005/11/29 14:48:32 gleixner Exp $
3 * 3 *
4 * block2mtd.c - create an mtd from a block device 4 * block2mtd.c - create an mtd from a block device
5 * 5 *
@@ -19,7 +19,7 @@
19#include <linux/mtd/mtd.h> 19#include <linux/mtd/mtd.h>
20#include <linux/buffer_head.h> 20#include <linux/buffer_head.h>
21 21
22#define VERSION "$Revision: 1.29 $" 22#define VERSION "$Revision: 1.30 $"
23 23
24 24
25#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args) 25#define ERROR(fmt, args...) printk(KERN_ERR "block2mtd: " fmt "\n" , ## args)
@@ -40,7 +40,7 @@ static LIST_HEAD(blkmtd_device_list);
40 40
41 41
42#define PAGE_READAHEAD 64 42#define PAGE_READAHEAD 64
43void cache_readahead(struct address_space *mapping, int index) 43static void cache_readahead(struct address_space *mapping, int index)
44{ 44{
45 filler_t *filler = (filler_t*)mapping->a_ops->readpage; 45 filler_t *filler = (filler_t*)mapping->a_ops->readpage;
46 int i, pagei; 46 int i, pagei;
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c
index f5026cee087f..0ff2e4378244 100644
--- a/drivers/mtd/devices/ms02-nv.c
+++ b/drivers/mtd/devices/ms02-nv.c
@@ -6,7 +6,7 @@
6 * as published by the Free Software Foundation; either version 6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version. 7 * 2 of the License, or (at your option) any later version.
8 * 8 *
9 * $Id: ms02-nv.c,v 1.10 2005/06/20 12:24:41 macro Exp $ 9 * $Id: ms02-nv.c,v 1.11 2005/11/14 13:41:47 macro Exp $
10 */ 10 */
11 11
12#include <linux/init.h> 12#include <linux/init.h>
@@ -293,13 +293,13 @@ static int __init ms02nv_init(void)
293 293
294 switch (mips_machtype) { 294 switch (mips_machtype) {
295 case MACH_DS5000_200: 295 case MACH_DS5000_200:
296 csr = (volatile u32 *)KN02_CSR_BASE; 296 csr = (volatile u32 *)CKSEG1ADDR(KN02_SLOT_BASE + KN02_CSR);
297 if (*csr & KN02_CSR_BNK32M) 297 if (*csr & KN02_CSR_BNK32M)
298 stride = 2; 298 stride = 2;
299 break; 299 break;
300 case MACH_DS5000_2X0: 300 case MACH_DS5000_2X0:
301 case MACH_DS5900: 301 case MACH_DS5900:
302 csr = (volatile u32 *)KN03_MCR_BASE; 302 csr = (volatile u32 *)CKSEG1ADDR(KN03_SLOT_BASE + IOASIC_MCR);
303 if (*csr & KN03_MCR_BNK32M) 303 if (*csr & KN03_MCR_BNK32M)
304 stride = 2; 304 stride = 2;
305 break; 305 break;
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index de7e231d6d18..8a878b34eca0 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -1,5 +1,5 @@
1/* This version ported to the Linux-MTD system by dwmw2@infradead.org 1/* This version ported to the Linux-MTD system by dwmw2@infradead.org
2 * $Id: ftl.c,v 1.58 2005/11/07 11:14:19 gleixner Exp $ 2 * $Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $
3 * 3 *
4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br> 4 * Fixes: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups 5 * - fixes some leaks on failure in build_maps and ftl_notify_add, cleanups
@@ -1084,9 +1084,9 @@ struct mtd_blktrans_ops ftl_tr = {
1084 .owner = THIS_MODULE, 1084 .owner = THIS_MODULE,
1085}; 1085};
1086 1086
1087int init_ftl(void) 1087static int init_ftl(void)
1088{ 1088{
1089 DEBUG(0, "$Id: ftl.c,v 1.58 2005/11/07 11:14:19 gleixner Exp $\n"); 1089 DEBUG(0, "$Id: ftl.c,v 1.59 2005/11/29 14:48:31 gleixner Exp $\n");
1090 1090
1091 return register_mtd_blktrans(&ftl_tr); 1091 return register_mtd_blktrans(&ftl_tr);
1092} 1092}
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 48638c8097a5..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
@@ -94,7 +94,7 @@ config MTD_NETSC520
94 94
95config MTD_TS5500 95config MTD_TS5500
96 tristate "JEDEC Flash device mapped on Technologic Systems TS-5500" 96 tristate "JEDEC Flash device mapped on Technologic Systems TS-5500"
97 depends on ELAN 97 depends on X86
98 select MTD_PARTITIONS 98 select MTD_PARTITIONS
99 select MTD_JEDECPROBE 99 select MTD_JEDECPROBE
100 select MTD_CFI_AMDSTD 100 select MTD_CFI_AMDSTD
@@ -538,12 +538,6 @@ config MTD_MPC1211
538 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02). 538 This enables access to the flash chips on the Interface MPC-1211(CTP/PCI/MPC-SH02).
539 If you have such a board, say 'Y'. 539 If you have such a board, say 'Y'.
540 540
541config MTD_PQ2FADS
542 tristate "JEDEC flash SIMM mapped on PQ2FADS and 8272ADS boards"
543 depends on (ADS8272 || PQ2FADS) && MTD_PARTITIONS && MTD_JEDECPROBE && MTD_PHYSMAP && MTD_CFI_GEOMETRY && MTD_CFI_INTELEXT
544 help
545 This enables access to flash SIMM on PQ2FADS-like boards
546
547config MTD_OMAP_NOR 541config MTD_OMAP_NOR
548 tristate "TI OMAP board mappings" 542 tristate "TI OMAP board mappings"
549 depends on MTD_CFI && ARCH_OMAP 543 depends on MTD_CFI && ARCH_OMAP
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 7d9e940a1dcd..2f7e254912f0 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -70,6 +70,5 @@ obj-$(CONFIG_MTD_DMV182) += dmv182.o
70obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o 70obj-$(CONFIG_MTD_SHARP_SL) += sharpsl-flash.o
71obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o 71obj-$(CONFIG_MTD_PLATRAM) += plat-ram.o
72obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o 72obj-$(CONFIG_MTD_OMAP_NOR) += omap_nor.o
73obj-$(CONFIG_MTD_PQ2FADS) += pq2fads.o
74obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o 73obj-$(CONFIG_MTD_MTX1) += mtx-1_flash.o
75obj-$(CONFIG_MTD_TQM834x) += tqm834x.o 74obj-$(CONFIG_MTD_TQM834x) += tqm834x.o
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c
index b7858eb93534..51f962dd7e31 100644
--- a/drivers/mtd/maps/bast-flash.c
+++ b/drivers/mtd/maps/bast-flash.c
@@ -63,11 +63,6 @@ struct bast_flash_info {
63 63
64static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 64static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
65 65
66static struct bast_flash_info *to_bast_info(struct device *dev)
67{
68 return (struct bast_flash_info *)dev_get_drvdata(dev);
69}
70
71static void bast_flash_setrw(int to) 66static void bast_flash_setrw(int to)
72{ 67{
73 unsigned int val; 68 unsigned int val;
@@ -87,11 +82,11 @@ static void bast_flash_setrw(int to)
87 local_irq_restore(flags); 82 local_irq_restore(flags);
88} 83}
89 84
90static int bast_flash_remove(struct device *dev) 85static int bast_flash_remove(struct platform_device *pdev)
91{ 86{
92 struct bast_flash_info *info = to_bast_info(dev); 87 struct bast_flash_info *info = platform_get_drvdata(pdev);
93 88
94 dev_set_drvdata(dev, NULL); 89 platform_set_drvdata(pdev, NULL);
95 90
96 if (info == NULL) 91 if (info == NULL)
97 return 0; 92 return 0;
@@ -116,9 +111,8 @@ static int bast_flash_remove(struct device *dev)
116 return 0; 111 return 0;
117} 112}
118 113
119static int bast_flash_probe(struct device *dev) 114static int bast_flash_probe(struct platform_device *pdev)
120{ 115{
121 struct platform_device *pdev = to_platform_device(dev);
122 struct bast_flash_info *info; 116 struct bast_flash_info *info;
123 struct resource *res; 117 struct resource *res;
124 int err = 0; 118 int err = 0;
@@ -131,13 +125,13 @@ static int bast_flash_probe(struct device *dev)
131 } 125 }
132 126
133 memzero(info, sizeof(*info)); 127 memzero(info, sizeof(*info));
134 dev_set_drvdata(dev, info); 128 platform_set_drvdata(pdev, info);
135 129
136 res = pdev->resource; /* assume that the flash has one resource */ 130 res = pdev->resource; /* assume that the flash has one resource */
137 131
138 info->map.phys = res->start; 132 info->map.phys = res->start;
139 info->map.size = res->end - res->start + 1; 133 info->map.size = res->end - res->start + 1;
140 info->map.name = dev->bus_id; 134 info->map.name = pdev->dev.bus_id;
141 info->map.bankwidth = 2; 135 info->map.bankwidth = 2;
142 136
143 if (info->map.size > AREA_MAXSIZE) 137 if (info->map.size > AREA_MAXSIZE)
@@ -199,27 +193,28 @@ static int bast_flash_probe(struct device *dev)
199 /* fall through to exit error */ 193 /* fall through to exit error */
200 194
201 exit_error: 195 exit_error:
202 bast_flash_remove(dev); 196 bast_flash_remove(pdev);
203 return err; 197 return err;
204} 198}
205 199
206static struct device_driver bast_flash_driver = { 200static struct platform_driver bast_flash_driver = {
207 .name = "bast-nor",
208 .owner = THIS_MODULE,
209 .bus = &platform_bus_type,
210 .probe = bast_flash_probe, 201 .probe = bast_flash_probe,
211 .remove = bast_flash_remove, 202 .remove = bast_flash_remove,
203 .driver = {
204 .name = "bast-nor",
205 .owner = THIS_MODULE,
206 },
212}; 207};
213 208
214static int __init bast_flash_init(void) 209static int __init bast_flash_init(void)
215{ 210{
216 printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n"); 211 printk("BAST NOR-Flash Driver, (c) 2004 Simtec Electronics\n");
217 return driver_register(&bast_flash_driver); 212 return platform_driver_register(&bast_flash_driver);
218} 213}
219 214
220static void __exit bast_flash_exit(void) 215static void __exit bast_flash_exit(void)
221{ 216{
222 driver_unregister(&bast_flash_driver); 217 platform_driver_unregister(&bast_flash_driver);
223} 218}
224 219
225module_init(bast_flash_init); 220module_init(bast_flash_init);
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c
index fe738fd8d6f8..a3ba52fbd868 100644
--- a/drivers/mtd/maps/integrator-flash.c
+++ b/drivers/mtd/maps/integrator-flash.c
@@ -67,9 +67,8 @@ static void armflash_set_vpp(struct map_info *map, int on)
67 67
68static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL }; 68static const char *probes[] = { "cmdlinepart", "RedBoot", "afs", NULL };
69 69
70static int armflash_probe(struct device *_dev) 70static int armflash_probe(struct platform_device *dev)
71{ 71{
72 struct platform_device *dev = to_platform_device(_dev);
73 struct flash_platform_data *plat = dev->dev.platform_data; 72 struct flash_platform_data *plat = dev->dev.platform_data;
74 struct resource *res = dev->resource; 73 struct resource *res = dev->resource;
75 unsigned int size = res->end - res->start + 1; 74 unsigned int size = res->end - res->start + 1;
@@ -138,7 +137,7 @@ static int armflash_probe(struct device *_dev)
138 } 137 }
139 138
140 if (err == 0) 139 if (err == 0)
141 dev_set_drvdata(&dev->dev, info); 140 platform_set_drvdata(dev, info);
142 141
143 /* 142 /*
144 * If we got an error, free all resources. 143 * If we got an error, free all resources.
@@ -163,12 +162,11 @@ static int armflash_probe(struct device *_dev)
163 return err; 162 return err;
164} 163}
165 164
166static int armflash_remove(struct device *_dev) 165static int armflash_remove(struct platform_device *dev)
167{ 166{
168 struct platform_device *dev = to_platform_device(_dev); 167 struct armflash_info *info = platform_get_drvdata(dev);
169 struct armflash_info *info = dev_get_drvdata(&dev->dev);
170 168
171 dev_set_drvdata(&dev->dev, NULL); 169 platform_set_drvdata(dev, NULL);
172 170
173 if (info) { 171 if (info) {
174 if (info->mtd) { 172 if (info->mtd) {
@@ -190,21 +188,22 @@ static int armflash_remove(struct device *_dev)
190 return 0; 188 return 0;
191} 189}
192 190
193static struct device_driver armflash_driver = { 191static struct platform_driver armflash_driver = {
194 .name = "armflash",
195 .bus = &platform_bus_type,
196 .probe = armflash_probe, 192 .probe = armflash_probe,
197 .remove = armflash_remove, 193 .remove = armflash_remove,
194 .driver = {
195 .name = "armflash",
196 },
198}; 197};
199 198
200static int __init armflash_init(void) 199static int __init armflash_init(void)
201{ 200{
202 return driver_register(&armflash_driver); 201 return platform_driver_register(&armflash_driver);
203} 202}
204 203
205static void __exit armflash_exit(void) 204static void __exit armflash_exit(void)
206{ 205{
207 driver_unregister(&armflash_driver); 206 platform_driver_unregister(&armflash_driver);
208} 207}
209 208
210module_init(armflash_init); 209module_init(armflash_init);
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c
index 35097c9bbf50..b8ccb0a95789 100644
--- a/drivers/mtd/maps/ipaq-flash.c
+++ b/drivers/mtd/maps/ipaq-flash.c
@@ -246,7 +246,7 @@ int __init ipaq_mtd_init(void)
246 ipaq_map[i].size = h3xxx_max_flash_size; 246 ipaq_map[i].size = h3xxx_max_flash_size;
247 ipaq_map[i].set_vpp = h3xxx_set_vpp; 247 ipaq_map[i].set_vpp = h3xxx_set_vpp;
248 ipaq_map[i].phys = cs_phys[i]; 248 ipaq_map[i].phys = cs_phys[i];
249 ipaq_map[i].virt = __ioremap(cs_phys[i], 0x04000000, 0, 1); 249 ipaq_map[i].virt = ioremap(cs_phys[i], 0x04000000);
250 if (machine_is_h3100 () || machine_is_h1900()) 250 if (machine_is_h3100 () || machine_is_h1900())
251 ipaq_map[i].bankwidth = 2; 251 ipaq_map[i].bankwidth = 2;
252 } 252 }
@@ -280,7 +280,7 @@ int __init ipaq_mtd_init(void)
280 nb_parts = ARRAY_SIZE(jornada_partitions); 280 nb_parts = ARRAY_SIZE(jornada_partitions);
281 ipaq_map[0].size = jornada_max_flash_size; 281 ipaq_map[0].size = jornada_max_flash_size;
282 ipaq_map[0].set_vpp = jornada56x_set_vpp; 282 ipaq_map[0].set_vpp = jornada56x_set_vpp;
283 ipaq_map[0].virt = (__u32)__ioremap(0x0, 0x04000000, 0, 1); 283 ipaq_map[0].virt = (__u32)ioremap(0x0, 0x04000000);
284 } 284 }
285#endif 285#endif
286#ifdef CONFIG_SA1100_JORNADA720 286#ifdef CONFIG_SA1100_JORNADA720
@@ -442,7 +442,7 @@ static int __init h1900_special_case(void)
442 ipaq_map[0].size = 0x80000; 442 ipaq_map[0].size = 0x80000;
443 ipaq_map[0].set_vpp = h3xxx_set_vpp; 443 ipaq_map[0].set_vpp = h3xxx_set_vpp;
444 ipaq_map[0].phys = 0x0; 444 ipaq_map[0].phys = 0x0;
445 ipaq_map[0].virt = __ioremap(0x0, 0x04000000, 0, 1); 445 ipaq_map[0].virt = ioremap(0x0, 0x04000000);
446 ipaq_map[0].bankwidth = 2; 446 ipaq_map[0].bankwidth = 2;
447 447
448 printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt); 448 printk(KERN_NOTICE "iPAQ flash: probing %d-bit flash bus, window=%lx with JEDEC.\n", ipaq_map[0].bankwidth*8, ipaq_map[0].virt);
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 641eb2b55e9f..2c9cc7f37e92 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -111,13 +111,12 @@ static void ixp2000_flash_copy_to(struct map_info *map, unsigned long to,
111} 111}
112 112
113 113
114static int ixp2000_flash_remove(struct device *_dev) 114static int ixp2000_flash_remove(struct platform_device *dev)
115{ 115{
116 struct platform_device *dev = to_platform_device(_dev);
117 struct flash_platform_data *plat = dev->dev.platform_data; 116 struct flash_platform_data *plat = dev->dev.platform_data;
118 struct ixp2000_flash_info *info = dev_get_drvdata(&dev->dev); 117 struct ixp2000_flash_info *info = platform_get_drvdata(dev);
119 118
120 dev_set_drvdata(&dev->dev, NULL); 119 platform_set_drvdata(dev, NULL);
121 120
122 if(!info) 121 if(!info)
123 return 0; 122 return 0;
@@ -143,10 +142,9 @@ static int ixp2000_flash_remove(struct device *_dev)
143} 142}
144 143
145 144
146static int ixp2000_flash_probe(struct device *_dev) 145static int ixp2000_flash_probe(struct platform_device *dev)
147{ 146{
148 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 147 static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
149 struct platform_device *dev = to_platform_device(_dev);
150 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data; 148 struct ixp2000_flash_data *ixp_data = dev->dev.platform_data;
151 struct flash_platform_data *plat; 149 struct flash_platform_data *plat;
152 struct ixp2000_flash_info *info; 150 struct ixp2000_flash_info *info;
@@ -161,12 +159,12 @@ static int ixp2000_flash_probe(struct device *_dev)
161 return -ENODEV; 159 return -ENODEV;
162 160
163 window_size = dev->resource->end - dev->resource->start + 1; 161 window_size = dev->resource->end - dev->resource->start + 1;
164 dev_info(_dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n", 162 dev_info(&dev->dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n",
165 ixp_data->nr_banks, ((u32)window_size >> 20)); 163 ixp_data->nr_banks, ((u32)window_size >> 20));
166 164
167 if (plat->width != 1) { 165 if (plat->width != 1) {
168 dev_err(_dev, "IXP2000 MTD map only supports 8-bit mode, asking for %d\n", 166 dev_err(&dev->dev, "IXP2000 MTD map only supports 8-bit mode, asking for %d\n",
169 plat->width * 8); 167 plat->width * 8);
170 return -EIO; 168 return -EIO;
171 } 169 }
172 170
@@ -177,7 +175,7 @@ static int ixp2000_flash_probe(struct device *_dev)
177 } 175 }
178 memzero(info, sizeof(struct ixp2000_flash_info)); 176 memzero(info, sizeof(struct ixp2000_flash_info));
179 177
180 dev_set_drvdata(&dev->dev, info); 178 platform_set_drvdata(dev, info);
181 179
182 /* 180 /*
183 * Tell the MTD layer we're not 1:1 mapped so that it does 181 * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -204,7 +202,7 @@ static int ixp2000_flash_probe(struct device *_dev)
204 dev->resource->end - dev->resource->start + 1, 202 dev->resource->end - dev->resource->start + 1,
205 dev->dev.bus_id); 203 dev->dev.bus_id);
206 if (!info->res) { 204 if (!info->res) {
207 dev_err(_dev, "Could not reserve memory region\n"); 205 dev_err(&dev->dev, "Could not reserve memory region\n");
208 err = -ENOMEM; 206 err = -ENOMEM;
209 goto Error; 207 goto Error;
210 } 208 }
@@ -212,7 +210,7 @@ static int ixp2000_flash_probe(struct device *_dev)
212 info->map.map_priv_1 = (unsigned long) ioremap(dev->resource->start, 210 info->map.map_priv_1 = (unsigned long) ioremap(dev->resource->start,
213 dev->resource->end - dev->resource->start + 1); 211 dev->resource->end - dev->resource->start + 1);
214 if (!info->map.map_priv_1) { 212 if (!info->map.map_priv_1) {
215 dev_err(_dev, "Failed to ioremap flash region\n"); 213 dev_err(&dev->dev, "Failed to ioremap flash region\n");
216 err = -EIO; 214 err = -EIO;
217 goto Error; 215 goto Error;
218 } 216 }
@@ -223,13 +221,13 @@ static int ixp2000_flash_probe(struct device *_dev)
223 */ 221 */
224 222
225 erratum44_workaround = ixp2000_has_broken_slowport(); 223 erratum44_workaround = ixp2000_has_broken_slowport();
226 dev_info(_dev, "Erratum 44 workaround %s\n", 224 dev_info(&dev->dev, "Erratum 44 workaround %s\n",
227 erratum44_workaround ? "enabled" : "disabled"); 225 erratum44_workaround ? "enabled" : "disabled");
228#endif 226#endif
229 227
230 info->mtd = do_map_probe(plat->map_name, &info->map); 228 info->mtd = do_map_probe(plat->map_name, &info->map);
231 if (!info->mtd) { 229 if (!info->mtd) {
232 dev_err(_dev, "map_probe failed\n"); 230 dev_err(&dev->dev, "map_probe failed\n");
233 err = -ENXIO; 231 err = -ENXIO;
234 goto Error; 232 goto Error;
235 } 233 }
@@ -239,7 +237,7 @@ static int ixp2000_flash_probe(struct device *_dev)
239 if (err > 0) { 237 if (err > 0) {
240 err = add_mtd_partitions(info->mtd, info->partitions, err); 238 err = add_mtd_partitions(info->mtd, info->partitions, err);
241 if(err) 239 if(err)
242 dev_err(_dev, "Could not parse partitions\n"); 240 dev_err(&dev->dev, "Could not parse partitions\n");
243 } 241 }
244 242
245 if (err) 243 if (err)
@@ -248,25 +246,26 @@ static int ixp2000_flash_probe(struct device *_dev)
248 return 0; 246 return 0;
249 247
250Error: 248Error:
251 ixp2000_flash_remove(_dev); 249 ixp2000_flash_remove(dev);
252 return err; 250 return err;
253} 251}
254 252
255static struct device_driver ixp2000_flash_driver = { 253static struct platform_driver ixp2000_flash_driver = {
256 .name = "IXP2000-Flash", 254 .probe = ixp2000_flash_probe,
257 .bus = &platform_bus_type, 255 .remove = ixp2000_flash_remove,
258 .probe = &ixp2000_flash_probe, 256 .driver = {
259 .remove = &ixp2000_flash_remove 257 .name = "IXP2000-Flash",
258 },
260}; 259};
261 260
262static int __init ixp2000_flash_init(void) 261static int __init ixp2000_flash_init(void)
263{ 262{
264 return driver_register(&ixp2000_flash_driver); 263 return platform_driver_register(&ixp2000_flash_driver);
265} 264}
266 265
267static void __exit ixp2000_flash_exit(void) 266static void __exit ixp2000_flash_exit(void)
268{ 267{
269 driver_unregister(&ixp2000_flash_driver); 268 platform_driver_unregister(&ixp2000_flash_driver);
270} 269}
271 270
272module_init(ixp2000_flash_init); 271module_init(ixp2000_flash_init);
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 56b3a355bf7b..986c58628390 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: ixp4xx.c,v 1.12 2005/11/07 11:14:27 gleixner Exp $ 2 * $Id: ixp4xx.c,v 1.13 2005/11/16 16:23:21 dvrabel Exp $
3 * 3 *
4 * drivers/mtd/maps/ixp4xx.c 4 * drivers/mtd/maps/ixp4xx.c
5 * 5 *
@@ -34,10 +34,55 @@
34 34
35#include <linux/reboot.h> 35#include <linux/reboot.h>
36 36
37/*
38 * Read/write a 16 bit word from flash address 'addr'.
39 *
40 * When the cpu is in little-endian mode it swizzles the address lines
41 * ('address coherency') so we need to undo the swizzling to ensure commands
42 * and the like end up on the correct flash address.
43 *
44 * To further complicate matters, due to the way the expansion bus controller
45 * handles 32 bit reads, the byte stream ABCD is stored on the flash as:
46 * D15 D0
47 * +---+---+
48 * | A | B | 0
49 * +---+---+
50 * | C | D | 2
51 * +---+---+
52 * This means that on LE systems each 16 bit word must be swapped. Note that
53 * this requires CONFIG_MTD_CFI_BE_BYTE_SWAP to be enabled to 'unswap' the CFI
54 * data and other flash commands which are always in D7-D0.
55 */
37#ifndef __ARMEB__ 56#ifndef __ARMEB__
57#ifndef CONFIG_MTD_CFI_BE_BYTE_SWAP
58# error CONFIG_MTD_CFI_BE_BYTE_SWAP required
59#endif
60
61static inline u16 flash_read16(void __iomem *addr)
62{
63 return be16_to_cpu(__raw_readw((void __iomem *)((unsigned long)addr ^ 0x2)));
64}
65
66static inline void flash_write16(u16 d, void __iomem *addr)
67{
68 __raw_writew(cpu_to_be16(d), (void __iomem *)((unsigned long)addr ^ 0x2));
69}
70
38#define BYTE0(h) ((h) & 0xFF) 71#define BYTE0(h) ((h) & 0xFF)
39#define BYTE1(h) (((h) >> 8) & 0xFF) 72#define BYTE1(h) (((h) >> 8) & 0xFF)
73
40#else 74#else
75
76static inline u16 flash_read16(const void __iomem *addr)
77{
78 return __raw_readw(addr);
79}
80
81static inline void flash_write16(u16 d, void __iomem *addr)
82{
83 __raw_writew(d, addr);
84}
85
41#define BYTE0(h) (((h) >> 8) & 0xFF) 86#define BYTE0(h) (((h) >> 8) & 0xFF)
42#define BYTE1(h) ((h) & 0xFF) 87#define BYTE1(h) ((h) & 0xFF)
43#endif 88#endif
@@ -45,7 +90,7 @@
45static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs) 90static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
46{ 91{
47 map_word val; 92 map_word val;
48 val.x[0] = le16_to_cpu(readw(map->virt + ofs)); 93 val.x[0] = flash_read16(map->virt + ofs);
49 return val; 94 return val;
50} 95}
51 96
@@ -57,19 +102,28 @@ static map_word ixp4xx_read16(struct map_info *map, unsigned long ofs)
57static void ixp4xx_copy_from(struct map_info *map, void *to, 102static void ixp4xx_copy_from(struct map_info *map, void *to,
58 unsigned long from, ssize_t len) 103 unsigned long from, ssize_t len)
59{ 104{
60 int i;
61 u8 *dest = (u8 *) to; 105 u8 *dest = (u8 *) to;
62 void __iomem *src = map->virt + from; 106 void __iomem *src = map->virt + from;
63 u16 data;
64 107
65 for (i = 0; i < (len / 2); i++) { 108 if (len <= 0)
66 data = le16_to_cpu(readw(src + 2*i)); 109 return;
67 dest[i * 2] = BYTE0(data); 110
68 dest[i * 2 + 1] = BYTE1(data); 111 if (from & 1) {
112 *dest++ = BYTE1(flash_read16(src));
113 src++;
114 --len;
69 } 115 }
70 116
71 if (len & 1) 117 while (len >= 2) {
72 dest[len - 1] = BYTE0(le16_to_cpu(readw(src + 2*i))); 118 u16 data = flash_read16(src);
119 *dest++ = BYTE0(data);
120 *dest++ = BYTE1(data);
121 src += 2;
122 len -= 2;
123 }
124
125 if (len > 0)
126 *dest++ = BYTE0(flash_read16(src));
73} 127}
74 128
75/* 129/*
@@ -79,7 +133,7 @@ static void ixp4xx_copy_from(struct map_info *map, void *to,
79static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr) 133static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long adr)
80{ 134{
81 if (!(adr & 1)) 135 if (!(adr & 1))
82 writew(cpu_to_le16(d.x[0]), map->virt + adr); 136 flash_write16(d.x[0], map->virt + adr);
83} 137}
84 138
85/* 139/*
@@ -87,7 +141,7 @@ static void ixp4xx_probe_write16(struct map_info *map, map_word d, unsigned long
87 */ 141 */
88static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr) 142static void ixp4xx_write16(struct map_info *map, map_word d, unsigned long adr)
89{ 143{
90 writew(cpu_to_le16(d.x[0]), map->virt + adr); 144 flash_write16(d.x[0], map->virt + adr);
91} 145}
92 146
93struct ixp4xx_flash_info { 147struct ixp4xx_flash_info {
@@ -99,13 +153,12 @@ struct ixp4xx_flash_info {
99 153
100static const char *probes[] = { "RedBoot", "cmdlinepart", NULL }; 154static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
101 155
102static int ixp4xx_flash_remove(struct device *_dev) 156static int ixp4xx_flash_remove(struct platform_device *dev)
103{ 157{
104 struct platform_device *dev = to_platform_device(_dev);
105 struct flash_platform_data *plat = dev->dev.platform_data; 158 struct flash_platform_data *plat = dev->dev.platform_data;
106 struct ixp4xx_flash_info *info = dev_get_drvdata(&dev->dev); 159 struct ixp4xx_flash_info *info = platform_get_drvdata(dev);
107 160
108 dev_set_drvdata(&dev->dev, NULL); 161 platform_set_drvdata(dev, NULL);
109 162
110 if(!info) 163 if(!info)
111 return 0; 164 return 0;
@@ -130,9 +183,8 @@ static int ixp4xx_flash_remove(struct device *_dev)
130 return 0; 183 return 0;
131} 184}
132 185
133static int ixp4xx_flash_probe(struct device *_dev) 186static int ixp4xx_flash_probe(struct platform_device *dev)
134{ 187{
135 struct platform_device *dev = to_platform_device(_dev);
136 struct flash_platform_data *plat = dev->dev.platform_data; 188 struct flash_platform_data *plat = dev->dev.platform_data;
137 struct ixp4xx_flash_info *info; 189 struct ixp4xx_flash_info *info;
138 int err = -1; 190 int err = -1;
@@ -153,7 +205,7 @@ static int ixp4xx_flash_probe(struct device *_dev)
153 } 205 }
154 memzero(info, sizeof(struct ixp4xx_flash_info)); 206 memzero(info, sizeof(struct ixp4xx_flash_info));
155 207
156 dev_set_drvdata(&dev->dev, info); 208 platform_set_drvdata(dev, info);
157 209
158 /* 210 /*
159 * Tell the MTD layer we're not 1:1 mapped so that it does 211 * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -214,25 +266,26 @@ static int ixp4xx_flash_probe(struct device *_dev)
214 return 0; 266 return 0;
215 267
216Error: 268Error:
217 ixp4xx_flash_remove(_dev); 269 ixp4xx_flash_remove(dev);
218 return err; 270 return err;
219} 271}
220 272
221static struct device_driver ixp4xx_flash_driver = { 273static struct platform_driver ixp4xx_flash_driver = {
222 .name = "IXP4XX-Flash",
223 .bus = &platform_bus_type,
224 .probe = ixp4xx_flash_probe, 274 .probe = ixp4xx_flash_probe,
225 .remove = ixp4xx_flash_remove, 275 .remove = ixp4xx_flash_remove,
276 .driver = {
277 .name = "IXP4XX-Flash",
278 },
226}; 279};
227 280
228static int __init ixp4xx_flash_init(void) 281static int __init ixp4xx_flash_init(void)
229{ 282{
230 return driver_register(&ixp4xx_flash_driver); 283 return platform_driver_register(&ixp4xx_flash_driver);
231} 284}
232 285
233static void __exit ixp4xx_flash_exit(void) 286static void __exit ixp4xx_flash_exit(void)
234{ 287{
235 driver_unregister(&ixp4xx_flash_driver); 288 platform_driver_unregister(&ixp4xx_flash_driver);
236} 289}
237 290
238 291
diff --git a/drivers/mtd/maps/nettel.c b/drivers/mtd/maps/nettel.c
index f00ee7e54dba..632eb2aa968f 100644
--- a/drivers/mtd/maps/nettel.c
+++ b/drivers/mtd/maps/nettel.c
@@ -6,7 +6,7 @@
6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com) 6 * (C) Copyright 2000-2001, Greg Ungerer (gerg@snapgear.com)
7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com) 7 * (C) Copyright 2001-2002, SnapGear (www.snapgear.com)
8 * 8 *
9 * $Id: nettel.c,v 1.11 2005/11/07 11:14:27 gleixner Exp $ 9 * $Id: nettel.c,v 1.12 2005/11/29 14:30:00 gleixner Exp $
10 */ 10 */
11 11
12/****************************************************************************/ 12/****************************************************************************/
@@ -479,7 +479,7 @@ void __exit nettel_cleanup(void)
479 } 479 }
480 if (nettel_intel_map.virt) { 480 if (nettel_intel_map.virt) {
481 iounmap(nettel_intel_map.virt); 481 iounmap(nettel_intel_map.virt);
482 nettel_intel_map.virt = 0; 482 nettel_intel_map.virt = NULL;
483 } 483 }
484#endif 484#endif
485} 485}
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c
index fd3b4a5fc207..418afffb2d80 100644
--- a/drivers/mtd/maps/omap_nor.c
+++ b/drivers/mtd/maps/omap_nor.c
@@ -70,11 +70,10 @@ static void omap_set_vpp(struct map_info *map, int enable)
70 } 70 }
71} 71}
72 72
73static int __devinit omapflash_probe(struct device *dev) 73static int __devinit omapflash_probe(struct platform_device *pdev)
74{ 74{
75 int err; 75 int err;
76 struct omapflash_info *info; 76 struct omapflash_info *info;
77 struct platform_device *pdev = to_platform_device(dev);
78 struct flash_platform_data *pdata = pdev->dev.platform_data; 77 struct flash_platform_data *pdata = pdev->dev.platform_data;
79 struct resource *res = pdev->resource; 78 struct resource *res = pdev->resource;
80 unsigned long size = res->end - res->start + 1; 79 unsigned long size = res->end - res->start + 1;
@@ -119,7 +118,7 @@ static int __devinit omapflash_probe(struct device *dev)
119#endif 118#endif
120 add_mtd_device(info->mtd); 119 add_mtd_device(info->mtd);
121 120
122 dev_set_drvdata(&pdev->dev, info); 121 platform_set_drvdata(pdev, info);
123 122
124 return 0; 123 return 0;
125 124
@@ -133,12 +132,11 @@ out_free_info:
133 return err; 132 return err;
134} 133}
135 134
136static int __devexit omapflash_remove(struct device *dev) 135static int __devexit omapflash_remove(struct platform_device *pdev)
137{ 136{
138 struct platform_device *pdev = to_platform_device(dev); 137 struct omapflash_info *info = platform_get_drvdata(pdev);
139 struct omapflash_info *info = dev_get_drvdata(&pdev->dev);
140 138
141 dev_set_drvdata(&pdev->dev, NULL); 139 platform_set_drvdata(pdev, NULL);
142 140
143 if (info) { 141 if (info) {
144 if (info->parts) { 142 if (info->parts) {
@@ -155,21 +153,22 @@ static int __devexit omapflash_remove(struct device *dev)
155 return 0; 153 return 0;
156} 154}
157 155
158static struct device_driver omapflash_driver = { 156static struct platform_driver omapflash_driver = {
159 .name = "omapflash",
160 .bus = &platform_bus_type,
161 .probe = omapflash_probe, 157 .probe = omapflash_probe,
162 .remove = __devexit_p(omapflash_remove), 158 .remove = __devexit_p(omapflash_remove),
159 .driver = {
160 .name = "omapflash",
161 },
163}; 162};
164 163
165static int __init omapflash_init(void) 164static int __init omapflash_init(void)
166{ 165{
167 return driver_register(&omapflash_driver); 166 return platform_driver_register(&omapflash_driver);
168} 167}
169 168
170static void __exit omapflash_exit(void) 169static void __exit omapflash_exit(void)
171{ 170{
172 driver_unregister(&omapflash_driver); 171 platform_driver_unregister(&omapflash_driver);
173} 172}
174 173
175module_init(omapflash_init); 174module_init(omapflash_init);
diff --git a/drivers/mtd/maps/pci.c b/drivers/mtd/maps/pci.c
index 8b3570b09095..21822c2edbe4 100644
--- a/drivers/mtd/maps/pci.c
+++ b/drivers/mtd/maps/pci.c
@@ -7,7 +7,7 @@
7 * it under the terms of the GNU General Public License version 2 as 7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
9 * 9 *
10 * $Id: pci.c,v 1.13 2005/11/07 11:14:27 gleixner Exp $ 10 * $Id: pci.c,v 1.14 2005/11/17 08:20:27 dwmw2 Exp $
11 * 11 *
12 * Generic PCI memory map driver. We support the following boards: 12 * Generic PCI memory map driver. We support the following boards:
13 * - Intel IQ80310 ATU. 13 * - Intel IQ80310 ATU.
@@ -102,7 +102,7 @@ static void mtd_pci_copyto(struct map_info *_map, unsigned long to, const void *
102 memcpy_toio(map->base + map->translate(map, to), from, len); 102 memcpy_toio(map->base + map->translate(map, to), from, len);
103} 103}
104 104
105static struct map_info mtd_pci_map = { 105static const struct map_info mtd_pci_map = {
106 .phys = NO_XIP, 106 .phys = NO_XIP,
107 .copy_from = mtd_pci_copyfrom, 107 .copy_from = mtd_pci_copyfrom,
108 .copy_to = mtd_pci_copyto, 108 .copy_to = mtd_pci_copyto,
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 9ee760f97bc6..f49ebc3c4606 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * $Id: physmap.c,v 1.38 2005/11/07 11:14:28 gleixner Exp $ 2 * $Id: physmap.c,v 1.39 2005/11/29 14:49:36 gleixner Exp $
3 * 3 *
4 * Normal mappings of chips in physical memory 4 * Normal mappings of chips in physical memory
5 * 5 *
@@ -19,6 +19,7 @@
19#include <linux/mtd/map.h> 19#include <linux/mtd/map.h>
20#include <linux/config.h> 20#include <linux/config.h>
21#include <linux/mtd/partitions.h> 21#include <linux/mtd/partitions.h>
22#include <linux/mtd/physmap.h>
22 23
23static struct mtd_info *mymtd; 24static struct mtd_info *mymtd;
24 25
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c
index a02eed94a231..5d3c75451ca2 100644
--- a/drivers/mtd/maps/plat-ram.c
+++ b/drivers/mtd/maps/plat-ram.c
@@ -56,9 +56,9 @@ struct platram_info {
56 * device private data to struct platram_info conversion 56 * device private data to struct platram_info conversion
57*/ 57*/
58 58
59static inline struct platram_info *to_platram_info(struct device *dev) 59static inline struct platram_info *to_platram_info(struct platform_device *dev)
60{ 60{
61 return (struct platram_info *)dev_get_drvdata(dev); 61 return (struct platram_info *)platform_get_drvdata(dev);
62} 62}
63 63
64/* platram_setrw 64/* platram_setrw
@@ -83,13 +83,13 @@ static inline void platram_setrw(struct platram_info *info, int to)
83 * called to remove the device from the driver's control 83 * called to remove the device from the driver's control
84*/ 84*/
85 85
86static int platram_remove(struct device *dev) 86static int platram_remove(struct platform_device *pdev)
87{ 87{
88 struct platram_info *info = to_platram_info(dev); 88 struct platram_info *info = to_platram_info(pdev);
89 89
90 dev_set_drvdata(dev, NULL); 90 platform_set_drvdata(pdev, NULL);
91 91
92 dev_dbg(dev, "removing device\n"); 92 dev_dbg(&pdev->dev, "removing device\n");
93 93
94 if (info == NULL) 94 if (info == NULL)
95 return 0; 95 return 0;
@@ -130,61 +130,60 @@ static int platram_remove(struct device *dev)
130 * driver is found. 130 * driver is found.
131*/ 131*/
132 132
133static int platram_probe(struct device *dev) 133static int platram_probe(struct platform_device *pdev)
134{ 134{
135 struct platform_device *pd = to_platform_device(dev);
136 struct platdata_mtd_ram *pdata; 135 struct platdata_mtd_ram *pdata;
137 struct platram_info *info; 136 struct platram_info *info;
138 struct resource *res; 137 struct resource *res;
139 int err = 0; 138 int err = 0;
140 139
141 dev_dbg(dev, "probe entered\n"); 140 dev_dbg(&pdev->dev, "probe entered\n");
142 141
143 if (dev->platform_data == NULL) { 142 if (pdev->dev.platform_data == NULL) {
144 dev_err(dev, "no platform data supplied\n"); 143 dev_err(&pdev->dev, "no platform data supplied\n");
145 err = -ENOENT; 144 err = -ENOENT;
146 goto exit_error; 145 goto exit_error;
147 } 146 }
148 147
149 pdata = dev->platform_data; 148 pdata = pdev->dev.platform_data;
150 149
151 info = kmalloc(sizeof(*info), GFP_KERNEL); 150 info = kmalloc(sizeof(*info), GFP_KERNEL);
152 if (info == NULL) { 151 if (info == NULL) {
153 dev_err(dev, "no memory for flash info\n"); 152 dev_err(&pdev->dev, "no memory for flash info\n");
154 err = -ENOMEM; 153 err = -ENOMEM;
155 goto exit_error; 154 goto exit_error;
156 } 155 }
157 156
158 memset(info, 0, sizeof(*info)); 157 memset(info, 0, sizeof(*info));
159 dev_set_drvdata(dev, info); 158 platform_set_drvdata(pdev, info);
160 159
161 info->dev = dev; 160 info->dev = &pdev->dev;
162 info->pdata = pdata; 161 info->pdata = pdata;
163 162
164 /* get the resource for the memory mapping */ 163 /* get the resource for the memory mapping */
165 164
166 res = platform_get_resource(pd, IORESOURCE_MEM, 0); 165 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
167 166
168 if (res == NULL) { 167 if (res == NULL) {
169 dev_err(dev, "no memory resource specified\n"); 168 dev_err(&pdev->dev, "no memory resource specified\n");
170 err = -ENOENT; 169 err = -ENOENT;
171 goto exit_free; 170 goto exit_free;
172 } 171 }
173 172
174 dev_dbg(dev, "got platform resource %p (0x%lx)\n", res, res->start); 173 dev_dbg(&pdev->dev, "got platform resource %p (0x%lx)\n", res, res->start);
175 174
176 /* setup map parameters */ 175 /* setup map parameters */
177 176
178 info->map.phys = res->start; 177 info->map.phys = res->start;
179 info->map.size = (res->end - res->start) + 1; 178 info->map.size = (res->end - res->start) + 1;
180 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pd->name; 179 info->map.name = pdata->mapname != NULL ? pdata->mapname : (char *)pdev->name;
181 info->map.bankwidth = pdata->bankwidth; 180 info->map.bankwidth = pdata->bankwidth;
182 181
183 /* register our usage of the memory area */ 182 /* register our usage of the memory area */
184 183
185 info->area = request_mem_region(res->start, info->map.size, pd->name); 184 info->area = request_mem_region(res->start, info->map.size, pdev->name);
186 if (info->area == NULL) { 185 if (info->area == NULL) {
187 dev_err(dev, "failed to request memory region\n"); 186 dev_err(&pdev->dev, "failed to request memory region\n");
188 err = -EIO; 187 err = -EIO;
189 goto exit_free; 188 goto exit_free;
190 } 189 }
@@ -192,23 +191,23 @@ static int platram_probe(struct device *dev)
192 /* remap the memory area */ 191 /* remap the memory area */
193 192
194 info->map.virt = ioremap(res->start, info->map.size); 193 info->map.virt = ioremap(res->start, info->map.size);
195 dev_dbg(dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size); 194 dev_dbg(&pdev->dev, "virt %p, %lu bytes\n", info->map.virt, info->map.size);
196 195
197 if (info->map.virt == NULL) { 196 if (info->map.virt == NULL) {
198 dev_err(dev, "failed to ioremap() region\n"); 197 dev_err(&pdev->dev, "failed to ioremap() region\n");
199 err = -EIO; 198 err = -EIO;
200 goto exit_free; 199 goto exit_free;
201 } 200 }
202 201
203 simple_map_init(&info->map); 202 simple_map_init(&info->map);
204 203
205 dev_dbg(dev, "initialised map, probing for mtd\n"); 204 dev_dbg(&pdev->dev, "initialised map, probing for mtd\n");
206 205
207 /* probe for the right mtd map driver */ 206 /* probe for the right mtd map driver */
208 207
209 info->mtd = do_map_probe("map_ram" , &info->map); 208 info->mtd = do_map_probe("map_ram" , &info->map);
210 if (info->mtd == NULL) { 209 if (info->mtd == NULL) {
211 dev_err(dev, "failed to probe for map_ram\n"); 210 dev_err(&pdev->dev, "failed to probe for map_ram\n");
212 err = -ENOMEM; 211 err = -ENOMEM;
213 goto exit_free; 212 goto exit_free;
214 } 213 }
@@ -237,27 +236,28 @@ static int platram_probe(struct device *dev)
237#endif /* CONFIG_MTD_PARTITIONS */ 236#endif /* CONFIG_MTD_PARTITIONS */
238 237
239 if (add_mtd_device(info->mtd)) { 238 if (add_mtd_device(info->mtd)) {
240 dev_err(dev, "add_mtd_device() failed\n"); 239 dev_err(&pdev->dev, "add_mtd_device() failed\n");
241 err = -ENOMEM; 240 err = -ENOMEM;
242 } 241 }
243 242
244 dev_info(dev, "registered mtd device\n"); 243 dev_info(&pdev->dev, "registered mtd device\n");
245 return err; 244 return err;
246 245
247 exit_free: 246 exit_free:
248 platram_remove(dev); 247 platram_remove(pdev);
249 exit_error: 248 exit_error:
250 return err; 249 return err;
251} 250}
252 251
253/* device driver info */ 252/* device driver info */
254 253
255static struct device_driver platram_driver = { 254static struct platform_driver platram_driver = {
256 .name = "mtd-ram",
257 .owner = THIS_MODULE,
258 .bus = &platform_bus_type,
259 .probe = platram_probe, 255 .probe = platram_probe,
260 .remove = platram_remove, 256 .remove = platram_remove,
257 .driver = {
258 .name = "mtd-ram",
259 .owner = THIS_MODULE,
260 },
261}; 261};
262 262
263/* module init/exit */ 263/* module init/exit */
@@ -265,12 +265,12 @@ static struct device_driver platram_driver = {
265static int __init platram_init(void) 265static int __init platram_init(void)
266{ 266{
267 printk("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n"); 267 printk("Generic platform RAM MTD, (c) 2004 Simtec Electronics\n");
268 return driver_register(&platram_driver); 268 return platform_driver_register(&platram_driver);
269} 269}
270 270
271static void __exit platram_exit(void) 271static void __exit platram_exit(void)
272{ 272{
273 driver_unregister(&platram_driver); 273 platform_driver_unregister(&platram_driver);
274} 274}
275 275
276module_init(platram_init); 276module_init(platram_init);
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c
index 9e8bb1782be0..5cefb015633c 100644
--- a/drivers/mtd/maps/sa1100-flash.c
+++ b/drivers/mtd/maps/sa1100-flash.c
@@ -356,9 +356,8 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
356 356
357static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL }; 357static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
358 358
359static int __init sa1100_mtd_probe(struct device *dev) 359static int __init sa1100_mtd_probe(struct platform_device *pdev)
360{ 360{
361 struct platform_device *pdev = to_platform_device(dev);
362 struct flash_platform_data *plat = pdev->dev.platform_data; 361 struct flash_platform_data *plat = pdev->dev.platform_data;
363 struct mtd_partition *parts; 362 struct mtd_partition *parts;
364 const char *part_type = NULL; 363 const char *part_type = NULL;
@@ -402,28 +401,28 @@ static int __init sa1100_mtd_probe(struct device *dev)
402 401
403 info->nr_parts = nr_parts; 402 info->nr_parts = nr_parts;
404 403
405 dev_set_drvdata(dev, info); 404 platform_set_drvdata(pdev, info);
406 err = 0; 405 err = 0;
407 406
408 out: 407 out:
409 return err; 408 return err;
410} 409}
411 410
412static int __exit sa1100_mtd_remove(struct device *dev) 411static int __exit sa1100_mtd_remove(struct platform_device *pdev)
413{ 412{
414 struct sa_info *info = dev_get_drvdata(dev); 413 struct sa_info *info = platform_get_drvdata(pdev);
415 struct flash_platform_data *plat = dev->platform_data; 414 struct flash_platform_data *plat = pdev->dev.platform_data;
416 415
417 dev_set_drvdata(dev, NULL); 416 platform_set_drvdata(pdev, NULL);
418 sa1100_destroy(info, plat); 417 sa1100_destroy(info, plat);
419 418
420 return 0; 419 return 0;
421} 420}
422 421
423#ifdef CONFIG_PM 422#ifdef CONFIG_PM
424static int sa1100_mtd_suspend(struct device *dev, pm_message_t state) 423static int sa1100_mtd_suspend(struct platform_device *dev, pm_message_t state)
425{ 424{
426 struct sa_info *info = dev_get_drvdata(dev); 425 struct sa_info *info = platform_get_drvdata(dev);
427 int ret = 0; 426 int ret = 0;
428 427
429 if (info) 428 if (info)
@@ -432,17 +431,17 @@ static int sa1100_mtd_suspend(struct device *dev, pm_message_t state)
432 return ret; 431 return ret;
433} 432}
434 433
435static int sa1100_mtd_resume(struct device *dev) 434static int sa1100_mtd_resume(struct platform_device *dev)
436{ 435{
437 struct sa_info *info = dev_get_drvdata(dev); 436 struct sa_info *info = platform_get_drvdata(dev);
438 if (info) 437 if (info)
439 info->mtd->resume(info->mtd); 438 info->mtd->resume(info->mtd);
440 return 0; 439 return 0;
441} 440}
442 441
443static void sa1100_mtd_shutdown(struct device *dev) 442static void sa1100_mtd_shutdown(struct platform_device *dev)
444{ 443{
445 struct sa_info *info = dev_get_drvdata(dev); 444 struct sa_info *info = platform_get_drvdata(dev);
446 if (info && info->mtd->suspend(info->mtd) == 0) 445 if (info && info->mtd->suspend(info->mtd) == 0)
447 info->mtd->resume(info->mtd); 446 info->mtd->resume(info->mtd);
448} 447}
@@ -452,24 +451,25 @@ static void sa1100_mtd_shutdown(struct device *dev)
452#define sa1100_mtd_shutdown NULL 451#define sa1100_mtd_shutdown NULL
453#endif 452#endif
454 453
455static struct device_driver sa1100_mtd_driver = { 454static struct platform_driver sa1100_mtd_driver = {
456 .name = "flash",
457 .bus = &platform_bus_type,
458 .probe = sa1100_mtd_probe, 455 .probe = sa1100_mtd_probe,
459 .remove = __exit_p(sa1100_mtd_remove), 456 .remove = __exit_p(sa1100_mtd_remove),
460 .suspend = sa1100_mtd_suspend, 457 .suspend = sa1100_mtd_suspend,
461 .resume = sa1100_mtd_resume, 458 .resume = sa1100_mtd_resume,
462 .shutdown = sa1100_mtd_shutdown, 459 .shutdown = sa1100_mtd_shutdown,
460 .driver = {
461 .name = "flash",
462 },
463}; 463};
464 464
465static int __init sa1100_mtd_init(void) 465static int __init sa1100_mtd_init(void)
466{ 466{
467 return driver_register(&sa1100_mtd_driver); 467 return platform_driver_register(&sa1100_mtd_driver);
468} 468}
469 469
470static void __exit sa1100_mtd_exit(void) 470static void __exit sa1100_mtd_exit(void)
471{ 471{
472 driver_unregister(&sa1100_mtd_driver); 472 platform_driver_unregister(&sa1100_mtd_driver);
473} 473}
474 474
475module_init(sa1100_mtd_init); 475module_init(sa1100_mtd_init);
diff --git a/drivers/mtd/maps/sc520cdp.c b/drivers/mtd/maps/sc520cdp.c
index 6fb9f3c57aab..ed92afadd8a9 100644
--- a/drivers/mtd/maps/sc520cdp.c
+++ b/drivers/mtd/maps/sc520cdp.c
@@ -16,7 +16,7 @@
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18 * 18 *
19 * $Id: sc520cdp.c,v 1.22 2005/11/07 11:14:28 gleixner Exp $ 19 * $Id: sc520cdp.c,v 1.23 2005/11/17 08:20:27 dwmw2 Exp $
20 * 20 *
21 * 21 *
22 * The SC520CDP is an evaluation board for the Elan SC520 processor available 22 * The SC520CDP is an evaluation board for the Elan SC520 processor available
@@ -164,7 +164,7 @@ struct sc520_par_table
164 unsigned long default_address; 164 unsigned long default_address;
165}; 165};
166 166
167static struct sc520_par_table par_table[NUM_FLASH_BANKS] = 167static const struct sc520_par_table par_table[NUM_FLASH_BANKS] =
168{ 168{
169 { /* Flash Bank #0: selected by ROMCS0 */ 169 { /* Flash Bank #0: selected by ROMCS0 */
170 SC520_PAR_ROMCS0, 170 SC520_PAR_ROMCS0,
diff --git a/drivers/mtd/nand/h1910.c b/drivers/mtd/nand/h1910.c
index 041e4b3358fb..f68f7a99a630 100644
--- a/drivers/mtd/nand/h1910.c
+++ b/drivers/mtd/nand/h1910.c
@@ -112,7 +112,7 @@ static int __init h1910_init (void)
112 if (!machine_is_h1900()) 112 if (!machine_is_h1900())
113 return -ENODEV; 113 return -ENODEV;
114 114
115 nandaddr = __ioremap(0x08000000, 0x1000, 0, 1); 115 nandaddr = ioremap(0x08000000, 0x1000);
116 if (!nandaddr) { 116 if (!nandaddr) {
117 printk("Failed to ioremap nand flash.\n"); 117 printk("Failed to ioremap nand flash.\n");
118 return -ENOMEM; 118 return -ENOMEM;
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index de4500395300..a0af92cc7efd 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -1486,7 +1486,7 @@ ns_nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len)
1486/* 1486/*
1487 * Module initialization function 1487 * Module initialization function
1488 */ 1488 */
1489int __init ns_init_module(void) 1489static int __init ns_init_module(void)
1490{ 1490{
1491 struct nand_chip *chip; 1491 struct nand_chip *chip;
1492 struct nandsim *nand; 1492 struct nandsim *nand;
diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c
index 97e9b7892d29..d209214b1318 100644
--- a/drivers/mtd/nand/s3c2410.c
+++ b/drivers/mtd/nand/s3c2410.c
@@ -125,14 +125,14 @@ static struct s3c2410_nand_info *s3c2410_nand_mtd_toinfo(struct mtd_info *mtd)
125 return s3c2410_nand_mtd_toours(mtd)->info; 125 return s3c2410_nand_mtd_toours(mtd)->info;
126} 126}
127 127
128static struct s3c2410_nand_info *to_nand_info(struct device *dev) 128static struct s3c2410_nand_info *to_nand_info(struct platform_device *dev)
129{ 129{
130 return dev_get_drvdata(dev); 130 return platform_get_drvdata(dev);
131} 131}
132 132
133static struct s3c2410_platform_nand *to_nand_plat(struct device *dev) 133static struct s3c2410_platform_nand *to_nand_plat(struct platform_device *dev)
134{ 134{
135 return dev->platform_data; 135 return dev->dev.platform_data;
136} 136}
137 137
138/* timing calculations */ 138/* timing calculations */
@@ -165,9 +165,9 @@ static int s3c2410_nand_calc_rate(int wanted, unsigned long clk, int max)
165/* controller setup */ 165/* controller setup */
166 166
167static int s3c2410_nand_inithw(struct s3c2410_nand_info *info, 167static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
168 struct device *dev) 168 struct platform_device *pdev)
169{ 169{
170 struct s3c2410_platform_nand *plat = to_nand_plat(dev); 170 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
171 unsigned long clkrate = clk_get_rate(info->clk); 171 unsigned long clkrate = clk_get_rate(info->clk);
172 int tacls, twrph0, twrph1; 172 int tacls, twrph0, twrph1;
173 unsigned long cfg; 173 unsigned long cfg;
@@ -430,11 +430,11 @@ static void s3c2410_nand_write_buf(struct mtd_info *mtd,
430 430
431/* device management functions */ 431/* device management functions */
432 432
433static int s3c2410_nand_remove(struct device *dev) 433static int s3c2410_nand_remove(struct platform_device *pdev)
434{ 434{
435 struct s3c2410_nand_info *info = to_nand_info(dev); 435 struct s3c2410_nand_info *info = to_nand_info(pdev);
436 436
437 dev_set_drvdata(dev, NULL); 437 platform_set_drvdata(pdev, NULL);
438 438
439 if (info == NULL) 439 if (info == NULL)
440 return 0; 440 return 0;
@@ -562,10 +562,9 @@ static void s3c2410_nand_init_chip(struct s3c2410_nand_info *info,
562 * nand layer to look for devices 562 * nand layer to look for devices
563*/ 563*/
564 564
565static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440) 565static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440)
566{ 566{
567 struct platform_device *pdev = to_platform_device(dev); 567 struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
568 struct s3c2410_platform_nand *plat = to_nand_plat(dev);
569 struct s3c2410_nand_info *info; 568 struct s3c2410_nand_info *info;
570 struct s3c2410_nand_mtd *nmtd; 569 struct s3c2410_nand_mtd *nmtd;
571 struct s3c2410_nand_set *sets; 570 struct s3c2410_nand_set *sets;
@@ -575,26 +574,26 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
575 int nr_sets; 574 int nr_sets;
576 int setno; 575 int setno;
577 576
578 pr_debug("s3c2410_nand_probe(%p)\n", dev); 577 pr_debug("s3c2410_nand_probe(%p)\n", pdev);
579 578
580 info = kmalloc(sizeof(*info), GFP_KERNEL); 579 info = kmalloc(sizeof(*info), GFP_KERNEL);
581 if (info == NULL) { 580 if (info == NULL) {
582 dev_err(dev, "no memory for flash info\n"); 581 dev_err(&pdev->dev, "no memory for flash info\n");
583 err = -ENOMEM; 582 err = -ENOMEM;
584 goto exit_error; 583 goto exit_error;
585 } 584 }
586 585
587 memzero(info, sizeof(*info)); 586 memzero(info, sizeof(*info));
588 dev_set_drvdata(dev, info); 587 platform_set_drvdata(pdev, info);
589 588
590 spin_lock_init(&info->controller.lock); 589 spin_lock_init(&info->controller.lock);
591 init_waitqueue_head(&info->controller.wq); 590 init_waitqueue_head(&info->controller.wq);
592 591
593 /* get the clock source and enable it */ 592 /* get the clock source and enable it */
594 593
595 info->clk = clk_get(dev, "nand"); 594 info->clk = clk_get(&pdev->dev, "nand");
596 if (IS_ERR(info->clk)) { 595 if (IS_ERR(info->clk)) {
597 dev_err(dev, "failed to get clock"); 596 dev_err(&pdev->dev, "failed to get clock");
598 err = -ENOENT; 597 err = -ENOENT;
599 goto exit_error; 598 goto exit_error;
600 } 599 }
@@ -611,27 +610,27 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
611 info->area = request_mem_region(res->start, size, pdev->name); 610 info->area = request_mem_region(res->start, size, pdev->name);
612 611
613 if (info->area == NULL) { 612 if (info->area == NULL) {
614 dev_err(dev, "cannot reserve register region\n"); 613 dev_err(&pdev->dev, "cannot reserve register region\n");
615 err = -ENOENT; 614 err = -ENOENT;
616 goto exit_error; 615 goto exit_error;
617 } 616 }
618 617
619 info->device = dev; 618 info->device = &pdev->dev;
620 info->platform = plat; 619 info->platform = plat;
621 info->regs = ioremap(res->start, size); 620 info->regs = ioremap(res->start, size);
622 info->is_s3c2440 = is_s3c2440; 621 info->is_s3c2440 = is_s3c2440;
623 622
624 if (info->regs == NULL) { 623 if (info->regs == NULL) {
625 dev_err(dev, "cannot reserve register region\n"); 624 dev_err(&pdev->dev, "cannot reserve register region\n");
626 err = -EIO; 625 err = -EIO;
627 goto exit_error; 626 goto exit_error;
628 } 627 }
629 628
630 dev_dbg(dev, "mapped registers at %p\n", info->regs); 629 dev_dbg(&pdev->dev, "mapped registers at %p\n", info->regs);
631 630
632 /* initialise the hardware */ 631 /* initialise the hardware */
633 632
634 err = s3c2410_nand_inithw(info, dev); 633 err = s3c2410_nand_inithw(info, pdev);
635 if (err != 0) 634 if (err != 0)
636 goto exit_error; 635 goto exit_error;
637 636
@@ -645,7 +644,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
645 size = nr_sets * sizeof(*info->mtds); 644 size = nr_sets * sizeof(*info->mtds);
646 info->mtds = kmalloc(size, GFP_KERNEL); 645 info->mtds = kmalloc(size, GFP_KERNEL);
647 if (info->mtds == NULL) { 646 if (info->mtds == NULL) {
648 dev_err(dev, "failed to allocate mtd storage\n"); 647 dev_err(&pdev->dev, "failed to allocate mtd storage\n");
649 err = -ENOMEM; 648 err = -ENOMEM;
650 goto exit_error; 649 goto exit_error;
651 } 650 }
@@ -677,7 +676,7 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
677 return 0; 676 return 0;
678 677
679 exit_error: 678 exit_error:
680 s3c2410_nand_remove(dev); 679 s3c2410_nand_remove(pdev);
681 680
682 if (err == 0) 681 if (err == 0)
683 err = -EINVAL; 682 err = -EINVAL;
@@ -686,44 +685,46 @@ static int s3c24xx_nand_probe(struct device *dev, int is_s3c2440)
686 685
687/* driver device registration */ 686/* driver device registration */
688 687
689static int s3c2410_nand_probe(struct device *dev) 688static int s3c2410_nand_probe(struct platform_device *dev)
690{ 689{
691 return s3c24xx_nand_probe(dev, 0); 690 return s3c24xx_nand_probe(dev, 0);
692} 691}
693 692
694static int s3c2440_nand_probe(struct device *dev) 693static int s3c2440_nand_probe(struct platform_device *dev)
695{ 694{
696 return s3c24xx_nand_probe(dev, 1); 695 return s3c24xx_nand_probe(dev, 1);
697} 696}
698 697
699static struct device_driver s3c2410_nand_driver = { 698static struct platform_driver s3c2410_nand_driver = {
700 .name = "s3c2410-nand",
701 .owner = THIS_MODULE,
702 .bus = &platform_bus_type,
703 .probe = s3c2410_nand_probe, 699 .probe = s3c2410_nand_probe,
704 .remove = s3c2410_nand_remove, 700 .remove = s3c2410_nand_remove,
701 .driver = {
702 .name = "s3c2410-nand",
703 .owner = THIS_MODULE,
704 },
705}; 705};
706 706
707static struct device_driver s3c2440_nand_driver = { 707static struct platform_driver s3c2440_nand_driver = {
708 .name = "s3c2440-nand",
709 .owner = THIS_MODULE,
710 .bus = &platform_bus_type,
711 .probe = s3c2440_nand_probe, 708 .probe = s3c2440_nand_probe,
712 .remove = s3c2410_nand_remove, 709 .remove = s3c2410_nand_remove,
710 .driver = {
711 .name = "s3c2440-nand",
712 .owner = THIS_MODULE,
713 },
713}; 714};
714 715
715static int __init s3c2410_nand_init(void) 716static int __init s3c2410_nand_init(void)
716{ 717{
717 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n"); 718 printk("S3C24XX NAND Driver, (c) 2004 Simtec Electronics\n");
718 719
719 driver_register(&s3c2440_nand_driver); 720 platform_driver_register(&s3c2440_nand_driver);
720 return driver_register(&s3c2410_nand_driver); 721 return platform_driver_register(&s3c2410_nand_driver);
721} 722}
722 723
723static void __exit s3c2410_nand_exit(void) 724static void __exit s3c2410_nand_exit(void)
724{ 725{
725 driver_unregister(&s3c2440_nand_driver); 726 platform_driver_unregister(&s3c2440_nand_driver);
726 driver_unregister(&s3c2410_nand_driver); 727 platform_driver_unregister(&s3c2410_nand_driver);
727} 728}
728 729
729module_init(s3c2410_nand_init); 730module_init(s3c2410_nand_init);
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/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 0ab8d29caeea..20ce212638fc 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -30,11 +30,9 @@ MODULE_PARM_DESC(block_size, "Block size to use by RFD, defaults to erase unit s
30 30
31#define PREFIX "rfd_ftl: " 31#define PREFIX "rfd_ftl: "
32 32
33/* Major device # for FTL device */ 33/* This major has been assigned by device@lanana.org */
34
35/* A request for this major has been sent to device@lanana.org */
36#ifndef RFD_FTL_MAJOR 34#ifndef RFD_FTL_MAJOR
37#define RFD_FTL_MAJOR 95 35#define RFD_FTL_MAJOR 256
38#endif 36#endif
39 37
40/* Maximum number of partitions in an FTL region */ 38/* Maximum number of partitions in an FTL region */
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c
index 977935a3d898..824e430486c2 100644
--- a/drivers/net/3c509.c
+++ b/drivers/net/3c509.c
@@ -84,6 +84,7 @@ static int max_interrupt_work = 10;
84#include <linux/netdevice.h> 84#include <linux/netdevice.h>
85#include <linux/etherdevice.h> 85#include <linux/etherdevice.h>
86#include <linux/pm.h> 86#include <linux/pm.h>
87#include <linux/pm_legacy.h>
87#include <linux/skbuff.h> 88#include <linux/skbuff.h>
88#include <linux/delay.h> /* for udelay() */ 89#include <linux/delay.h> /* for udelay() */
89#include <linux/spinlock.h> 90#include <linux/spinlock.h>
@@ -173,7 +174,7 @@ struct el3_private {
173 /* skb send-queue */ 174 /* skb send-queue */
174 int head, size; 175 int head, size;
175 struct sk_buff *queue[SKB_QUEUE_SIZE]; 176 struct sk_buff *queue[SKB_QUEUE_SIZE];
176#ifdef CONFIG_PM 177#ifdef CONFIG_PM_LEGACY
177 struct pm_dev *pmdev; 178 struct pm_dev *pmdev;
178#endif 179#endif
179 enum { 180 enum {
@@ -200,7 +201,7 @@ static void el3_tx_timeout (struct net_device *dev);
200static void el3_down(struct net_device *dev); 201static void el3_down(struct net_device *dev);
201static void el3_up(struct net_device *dev); 202static void el3_up(struct net_device *dev);
202static struct ethtool_ops ethtool_ops; 203static struct ethtool_ops ethtool_ops;
203#ifdef CONFIG_PM 204#ifdef CONFIG_PM_LEGACY
204static int el3_suspend(struct pm_dev *pdev); 205static int el3_suspend(struct pm_dev *pdev);
205static int el3_resume(struct pm_dev *pdev); 206static int el3_resume(struct pm_dev *pdev);
206static int el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data); 207static int el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data);
@@ -361,7 +362,7 @@ static void el3_common_remove (struct net_device *dev)
361 struct el3_private *lp = netdev_priv(dev); 362 struct el3_private *lp = netdev_priv(dev);
362 363
363 (void) lp; /* Keep gcc quiet... */ 364 (void) lp; /* Keep gcc quiet... */
364#ifdef CONFIG_PM 365#ifdef CONFIG_PM_LEGACY
365 if (lp->pmdev) 366 if (lp->pmdev)
366 pm_unregister(lp->pmdev); 367 pm_unregister(lp->pmdev);
367#endif 368#endif
@@ -571,7 +572,7 @@ no_pnp:
571 if (err) 572 if (err)
572 goto out1; 573 goto out1;
573 574
574#ifdef CONFIG_PM 575#ifdef CONFIG_PM_LEGACY
575 /* register power management */ 576 /* register power management */
576 lp->pmdev = pm_register(PM_ISA_DEV, card_idx, el3_pm_callback); 577 lp->pmdev = pm_register(PM_ISA_DEV, card_idx, el3_pm_callback);
577 if (lp->pmdev) { 578 if (lp->pmdev) {
@@ -1479,7 +1480,7 @@ el3_up(struct net_device *dev)
1479} 1480}
1480 1481
1481/* Power Management support functions */ 1482/* Power Management support functions */
1482#ifdef CONFIG_PM 1483#ifdef CONFIG_PM_LEGACY
1483 1484
1484static int 1485static int
1485el3_suspend(struct pm_dev *pdev) 1486el3_suspend(struct pm_dev *pdev)
@@ -1548,7 +1549,7 @@ el3_pm_callback(struct pm_dev *pdev, pm_request_t rqst, void *data)
1548 return 0; 1549 return 0;
1549} 1550}
1550 1551
1551#endif /* CONFIG_PM */ 1552#endif /* CONFIG_PM_LEGACY */
1552 1553
1553/* Parameters that may be passed into the module. */ 1554/* Parameters that may be passed into the module. */
1554static int debug = -1; 1555static int debug = -1;
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 5c69d57f8548..ebd7313d7fc1 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -812,7 +812,7 @@ config SMC91X
812 tristate "SMC 91C9x/91C1xxx support" 812 tristate "SMC 91C9x/91C1xxx support"
813 select CRC32 813 select CRC32
814 select MII 814 select MII
815 depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH) 815 depends on NET_ETHERNET && (ARM || REDWOOD_5 || REDWOOD_6 || M32R || SUPERH || SOC_AU1X00)
816 help 816 help
817 This is a driver for SMC's 91x series of Ethernet chipsets, 817 This is a driver for SMC's 91x series of Ethernet chipsets,
818 including the SMC91C94 and the SMC91C111. Say Y if you want it 818 including the SMC91C94 and the SMC91C111. Say Y if you want it
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index 332e9953c55c..cd0b1dccfb61 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -32,6 +32,7 @@
32 * 32 *
33 */ 33 */
34 34
35#include <linux/config.h>
35#include <linux/module.h> 36#include <linux/module.h>
36#include <linux/kernel.h> 37#include <linux/kernel.h>
37#include <linux/sched.h> 38#include <linux/sched.h>
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index c53848f787eb..7aa49b974dc5 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -28,8 +28,8 @@
28 28
29#define DRV_MODULE_NAME "b44" 29#define DRV_MODULE_NAME "b44"
30#define PFX DRV_MODULE_NAME ": " 30#define PFX DRV_MODULE_NAME ": "
31#define DRV_MODULE_VERSION "0.96" 31#define DRV_MODULE_VERSION "0.97"
32#define DRV_MODULE_RELDATE "Nov 8, 2005" 32#define DRV_MODULE_RELDATE "Nov 30, 2005"
33 33
34#define B44_DEF_MSG_ENABLE \ 34#define B44_DEF_MSG_ENABLE \
35 (NETIF_MSG_DRV | \ 35 (NETIF_MSG_DRV | \
@@ -1417,6 +1417,7 @@ static int b44_open(struct net_device *dev)
1417 add_timer(&bp->timer); 1417 add_timer(&bp->timer);
1418 1418
1419 b44_enable_ints(bp); 1419 b44_enable_ints(bp);
1420 netif_start_queue(dev);
1420out: 1421out:
1421 return err; 1422 return err;
1422} 1423}
@@ -1837,12 +1838,15 @@ static int b44_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
1837{ 1838{
1838 struct mii_ioctl_data *data = if_mii(ifr); 1839 struct mii_ioctl_data *data = if_mii(ifr);
1839 struct b44 *bp = netdev_priv(dev); 1840 struct b44 *bp = netdev_priv(dev);
1840 int err; 1841 int err = -EINVAL;
1842
1843 if (!netif_running(dev))
1844 goto out;
1841 1845
1842 spin_lock_irq(&bp->lock); 1846 spin_lock_irq(&bp->lock);
1843 err = generic_mii_ioctl(&bp->mii_if, data, cmd, NULL); 1847 err = generic_mii_ioctl(&bp->mii_if, data, cmd, NULL);
1844 spin_unlock_irq(&bp->lock); 1848 spin_unlock_irq(&bp->lock);
1845 1849out:
1846 return err; 1850 return err;
1847} 1851}
1848 1852
@@ -2113,6 +2117,7 @@ static int b44_resume(struct pci_dev *pdev)
2113 add_timer(&bp->timer); 2117 add_timer(&bp->timer);
2114 2118
2115 b44_enable_ints(bp); 2119 b44_enable_ints(bp);
2120 netif_wake_queue(dev);
2116 return 0; 2121 return 0;
2117} 2122}
2118 2123
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 8f464271664d..49fa1e4413fa 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -2707,7 +2707,7 @@ bnx2_init_nvram(struct bnx2 *bp)
2707 2707
2708 if (j == entry_count) { 2708 if (j == entry_count) {
2709 bp->flash_info = NULL; 2709 bp->flash_info = NULL;
2710 printk(KERN_ALERT "Unknown flash/EEPROM type.\n"); 2710 printk(KERN_ALERT PFX "Unknown flash/EEPROM type.\n");
2711 rc = -ENODEV; 2711 rc = -ENODEV;
2712 } 2712 }
2713 2713
@@ -3903,6 +3903,8 @@ bnx2_test_loopback(struct bnx2 *bp)
3903 3903
3904 pkt_size = 1514; 3904 pkt_size = 1514;
3905 skb = dev_alloc_skb(pkt_size); 3905 skb = dev_alloc_skb(pkt_size);
3906 if (!skb)
3907 return -ENOMEM;
3906 packet = skb_put(skb, pkt_size); 3908 packet = skb_put(skb, pkt_size);
3907 memcpy(packet, bp->mac_addr, 6); 3909 memcpy(packet, bp->mac_addr, 6);
3908 memset(packet + 6, 0x0, 8); 3910 memset(packet + 6, 0x0, 8);
@@ -4798,11 +4800,7 @@ bnx2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4798 struct bnx2 *bp = dev->priv; 4800 struct bnx2 *bp = dev->priv;
4799 int rc; 4801 int rc;
4800 4802
4801 if (eeprom->offset > bp->flash_info->total_size) 4803 /* parameters already validated in ethtool_get_eeprom */
4802 return -EINVAL;
4803
4804 if ((eeprom->offset + eeprom->len) > bp->flash_info->total_size)
4805 eeprom->len = bp->flash_info->total_size - eeprom->offset;
4806 4804
4807 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len); 4805 rc = bnx2_nvram_read(bp, eeprom->offset, eebuf, eeprom->len);
4808 4806
@@ -4816,11 +4814,7 @@ bnx2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
4816 struct bnx2 *bp = dev->priv; 4814 struct bnx2 *bp = dev->priv;
4817 int rc; 4815 int rc;
4818 4816
4819 if (eeprom->offset > bp->flash_info->total_size) 4817 /* parameters already validated in ethtool_set_eeprom */
4820 return -EINVAL;
4821
4822 if ((eeprom->offset + eeprom->len) > bp->flash_info->total_size)
4823 eeprom->len = bp->flash_info->total_size - eeprom->offset;
4824 4818
4825 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len); 4819 rc = bnx2_nvram_write(bp, eeprom->offset, eebuf, eeprom->len);
4826 4820
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 0d33a93df96b..03804cc38be0 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -398,13 +398,19 @@ static struct mca_driver depca_mca_driver = {
398}; 398};
399#endif 399#endif
400 400
401static int depca_isa_probe (struct device *); 401static int depca_isa_probe (struct platform_device *);
402 402
403static struct device_driver depca_isa_driver = { 403static int __devexit depca_isa_remove(struct platform_device *pdev)
404 .name = depca_string, 404{
405 .bus = &platform_bus_type, 405 return depca_device_remove(&pdev->dev);
406}
407
408static struct platform_driver depca_isa_driver = {
406 .probe = depca_isa_probe, 409 .probe = depca_isa_probe,
407 .remove = __devexit_p(depca_device_remove), 410 .remove = __devexit_p(depca_isa_remove),
411 .driver = {
412 .name = depca_string,
413 },
408}; 414};
409 415
410/* 416/*
@@ -1525,7 +1531,7 @@ static enum depca_type __init depca_shmem_probe (ulong *mem_start)
1525 return adapter; 1531 return adapter;
1526} 1532}
1527 1533
1528static int __init depca_isa_probe (struct device *device) 1534static int __init depca_isa_probe (struct platform_device *device)
1529{ 1535{
1530 struct net_device *dev; 1536 struct net_device *dev;
1531 struct depca_private *lp; 1537 struct depca_private *lp;
@@ -1533,7 +1539,7 @@ static int __init depca_isa_probe (struct device *device)
1533 enum depca_type adapter = unknown; 1539 enum depca_type adapter = unknown;
1534 int status = 0; 1540 int status = 0;
1535 1541
1536 ioaddr = (u_long) device->platform_data; 1542 ioaddr = (u_long) device->dev.platform_data;
1537 1543
1538 if ((status = depca_common_init (ioaddr, &dev))) 1544 if ((status = depca_common_init (ioaddr, &dev)))
1539 goto out; 1545 goto out;
@@ -1553,7 +1559,7 @@ static int __init depca_isa_probe (struct device *device)
1553 lp->adapter = adapter; 1559 lp->adapter = adapter;
1554 lp->mem_start = mem_start; 1560 lp->mem_start = mem_start;
1555 1561
1556 if ((status = depca_hw_init(dev, device))) 1562 if ((status = depca_hw_init(dev, &device->dev)))
1557 goto out_free; 1563 goto out_free;
1558 1564
1559 return 0; 1565 return 0;
@@ -2082,7 +2088,7 @@ static int __init depca_module_init (void)
2082#ifdef CONFIG_EISA 2088#ifdef CONFIG_EISA
2083 err |= eisa_driver_register (&depca_eisa_driver); 2089 err |= eisa_driver_register (&depca_eisa_driver);
2084#endif 2090#endif
2085 err |= driver_register (&depca_isa_driver); 2091 err |= platform_driver_register (&depca_isa_driver);
2086 depca_platform_probe (); 2092 depca_platform_probe ();
2087 2093
2088 return err; 2094 return err;
@@ -2097,7 +2103,7 @@ static void __exit depca_module_exit (void)
2097#ifdef CONFIG_EISA 2103#ifdef CONFIG_EISA
2098 eisa_driver_unregister (&depca_eisa_driver); 2104 eisa_driver_unregister (&depca_eisa_driver);
2099#endif 2105#endif
2100 driver_unregister (&depca_isa_driver); 2106 platform_driver_unregister (&depca_isa_driver);
2101 2107
2102 for (i = 0; depca_io_ports[i].iobase; i++) { 2108 for (i = 0; depca_io_ports[i].iobase; i++) {
2103 if (depca_io_ports[i].device) { 2109 if (depca_io_ports[i].device) {
diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c
index 2a290cc397ad..70b47e4c4e9c 100644
--- a/drivers/net/dgrs.c
+++ b/drivers/net/dgrs.c
@@ -1458,6 +1458,8 @@ static struct pci_driver dgrs_pci_driver = {
1458 .probe = dgrs_pci_probe, 1458 .probe = dgrs_pci_probe,
1459 .remove = __devexit_p(dgrs_pci_remove), 1459 .remove = __devexit_p(dgrs_pci_remove),
1460}; 1460};
1461#else
1462static struct pci_driver dgrs_pci_driver = {};
1461#endif 1463#endif
1462 1464
1463 1465
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index f8c9bcdab68b..24996da4c1c4 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -148,7 +148,7 @@ typedef struct board_info {
148} board_info_t; 148} board_info_t;
149 149
150/* function declaration ------------------------------------- */ 150/* function declaration ------------------------------------- */
151static int dm9000_probe(struct device *); 151static int dm9000_probe(struct platform_device *);
152static int dm9000_open(struct net_device *); 152static int dm9000_open(struct net_device *);
153static int dm9000_start_xmit(struct sk_buff *, struct net_device *); 153static int dm9000_start_xmit(struct sk_buff *, struct net_device *);
154static int dm9000_stop(struct net_device *); 154static int dm9000_stop(struct net_device *);
@@ -378,9 +378,8 @@ dm9000_release_board(struct platform_device *pdev, struct board_info *db)
378 * Search DM9000 board, allocate space and register it 378 * Search DM9000 board, allocate space and register it
379 */ 379 */
380static int 380static int
381dm9000_probe(struct device *dev) 381dm9000_probe(struct platform_device *pdev)
382{ 382{
383 struct platform_device *pdev = to_platform_device(dev);
384 struct dm9000_plat_data *pdata = pdev->dev.platform_data; 383 struct dm9000_plat_data *pdata = pdev->dev.platform_data;
385 struct board_info *db; /* Point a board information structure */ 384 struct board_info *db; /* Point a board information structure */
386 struct net_device *ndev; 385 struct net_device *ndev;
@@ -398,7 +397,7 @@ dm9000_probe(struct device *dev)
398 } 397 }
399 398
400 SET_MODULE_OWNER(ndev); 399 SET_MODULE_OWNER(ndev);
401 SET_NETDEV_DEV(ndev, dev); 400 SET_NETDEV_DEV(ndev, &pdev->dev);
402 401
403 PRINTK2("dm9000_probe()"); 402 PRINTK2("dm9000_probe()");
404 403
@@ -569,7 +568,7 @@ dm9000_probe(struct device *dev)
569 printk("%s: Invalid ethernet MAC address. Please " 568 printk("%s: Invalid ethernet MAC address. Please "
570 "set using ifconfig\n", ndev->name); 569 "set using ifconfig\n", ndev->name);
571 570
572 dev_set_drvdata(dev, ndev); 571 platform_set_drvdata(pdev, ndev);
573 ret = register_netdev(ndev); 572 ret = register_netdev(ndev);
574 573
575 if (ret == 0) { 574 if (ret == 0) {
@@ -1140,9 +1139,9 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1140} 1139}
1141 1140
1142static int 1141static int
1143dm9000_drv_suspend(struct device *dev, pm_message_t state) 1142dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
1144{ 1143{
1145 struct net_device *ndev = dev_get_drvdata(dev); 1144 struct net_device *ndev = platform_get_drvdata(dev);
1146 1145
1147 if (ndev) { 1146 if (ndev) {
1148 if (netif_running(ndev)) { 1147 if (netif_running(ndev)) {
@@ -1154,9 +1153,9 @@ dm9000_drv_suspend(struct device *dev, pm_message_t state)
1154} 1153}
1155 1154
1156static int 1155static int
1157dm9000_drv_resume(struct device *dev) 1156dm9000_drv_resume(struct platform_device *dev)
1158{ 1157{
1159 struct net_device *ndev = dev_get_drvdata(dev); 1158 struct net_device *ndev = platform_get_drvdata(dev);
1160 board_info_t *db = (board_info_t *) ndev->priv; 1159 board_info_t *db = (board_info_t *) ndev->priv;
1161 1160
1162 if (ndev) { 1161 if (ndev) {
@@ -1172,12 +1171,11 @@ dm9000_drv_resume(struct device *dev)
1172} 1171}
1173 1172
1174static int 1173static int
1175dm9000_drv_remove(struct device *dev) 1174dm9000_drv_remove(struct platform_device *pdev)
1176{ 1175{
1177 struct platform_device *pdev = to_platform_device(dev); 1176 struct net_device *ndev = platform_get_drvdata(pdev);
1178 struct net_device *ndev = dev_get_drvdata(dev);
1179 1177
1180 dev_set_drvdata(dev, NULL); 1178 platform_set_drvdata(pdev, NULL);
1181 1179
1182 unregister_netdev(ndev); 1180 unregister_netdev(ndev);
1183 dm9000_release_board(pdev, (board_info_t *) ndev->priv); 1181 dm9000_release_board(pdev, (board_info_t *) ndev->priv);
@@ -1188,13 +1186,14 @@ dm9000_drv_remove(struct device *dev)
1188 return 0; 1186 return 0;
1189} 1187}
1190 1188
1191static struct device_driver dm9000_driver = { 1189static struct platform_driver dm9000_driver = {
1192 .name = "dm9000",
1193 .bus = &platform_bus_type,
1194 .probe = dm9000_probe, 1190 .probe = dm9000_probe,
1195 .remove = dm9000_drv_remove, 1191 .remove = dm9000_drv_remove,
1196 .suspend = dm9000_drv_suspend, 1192 .suspend = dm9000_drv_suspend,
1197 .resume = dm9000_drv_resume, 1193 .resume = dm9000_drv_resume,
1194 .driver = {
1195 .name = "dm9000",
1196 },
1198}; 1197};
1199 1198
1200static int __init 1199static int __init
@@ -1202,13 +1201,13 @@ dm9000_init(void)
1202{ 1201{
1203 printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME); 1202 printk(KERN_INFO "%s Ethernet Driver\n", CARDNAME);
1204 1203
1205 return driver_register(&dm9000_driver); /* search board and register */ 1204 return platform_driver_register(&dm9000_driver); /* search board and register */
1206} 1205}
1207 1206
1208static void __exit 1207static void __exit
1209dm9000_cleanup(void) 1208dm9000_cleanup(void)
1210{ 1209{
1211 driver_unregister(&dm9000_driver); 1210 platform_driver_unregister(&dm9000_driver);
1212} 1211}
1213 1212
1214module_init(dm9000_init); 1213module_init(dm9000_init);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 7a6aeae2c9fa..22cd04556707 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -156,7 +156,7 @@
156 156
157#define DRV_NAME "e100" 157#define DRV_NAME "e100"
158#define DRV_EXT "-NAPI" 158#define DRV_EXT "-NAPI"
159#define DRV_VERSION "3.4.14-k2"DRV_EXT 159#define DRV_VERSION "3.4.14-k4"DRV_EXT
160#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver" 160#define DRV_DESCRIPTION "Intel(R) PRO/100 Network Driver"
161#define DRV_COPYRIGHT "Copyright(c) 1999-2005 Intel Corporation" 161#define DRV_COPYRIGHT "Copyright(c) 1999-2005 Intel Corporation"
162#define PFX DRV_NAME ": " 162#define PFX DRV_NAME ": "
@@ -903,8 +903,8 @@ static void mdio_write(struct net_device *netdev, int addr, int reg, int data)
903 903
904static void e100_get_defaults(struct nic *nic) 904static void e100_get_defaults(struct nic *nic)
905{ 905{
906 struct param_range rfds = { .min = 16, .max = 256, .count = 64 }; 906 struct param_range rfds = { .min = 16, .max = 256, .count = 256 };
907 struct param_range cbs = { .min = 64, .max = 256, .count = 64 }; 907 struct param_range cbs = { .min = 64, .max = 256, .count = 128 };
908 908
909 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id); 909 pci_read_config_byte(nic->pdev, PCI_REVISION_ID, &nic->rev_id);
910 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */ 910 /* MAC type is encoded as rev ID; exception: ICH is treated as 82559 */
@@ -1007,25 +1007,264 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1007 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]); 1007 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
1008} 1008}
1009 1009
1010/********************************************************/
1011/* Micro code for 8086:1229 Rev 8 */
1012/********************************************************/
1013
1014/* Parameter values for the D101M B-step */
1015#define D101M_CPUSAVER_TIMER_DWORD 78
1016#define D101M_CPUSAVER_BUNDLE_DWORD 65
1017#define D101M_CPUSAVER_MIN_SIZE_DWORD 126
1018
1019#define D101M_B_RCVBUNDLE_UCODE \
1020{\
10210x00550215, 0xFFFF0437, 0xFFFFFFFF, 0x06A70789, 0xFFFFFFFF, 0x0558FFFF, \
10220x000C0001, 0x00101312, 0x000C0008, 0x00380216, \
10230x0010009C, 0x00204056, 0x002380CC, 0x00380056, \
10240x0010009C, 0x00244C0B, 0x00000800, 0x00124818, \
10250x00380438, 0x00000000, 0x00140000, 0x00380555, \
10260x00308000, 0x00100662, 0x00100561, 0x000E0408, \
10270x00134861, 0x000C0002, 0x00103093, 0x00308000, \
10280x00100624, 0x00100561, 0x000E0408, 0x00100861, \
10290x000C007E, 0x00222C21, 0x000C0002, 0x00103093, \
10300x00380C7A, 0x00080000, 0x00103090, 0x00380C7A, \
10310x00000000, 0x00000000, 0x00000000, 0x00000000, \
10320x0010009C, 0x00244C2D, 0x00010004, 0x00041000, \
10330x003A0437, 0x00044010, 0x0038078A, 0x00000000, \
10340x00100099, 0x00206C7A, 0x0010009C, 0x00244C48, \
10350x00130824, 0x000C0001, 0x00101213, 0x00260C75, \
10360x00041000, 0x00010004, 0x00130826, 0x000C0006, \
10370x002206A8, 0x0013C926, 0x00101313, 0x003806A8, \
10380x00000000, 0x00000000, 0x00000000, 0x00000000, \
10390x00000000, 0x00000000, 0x00000000, 0x00000000, \
10400x00080600, 0x00101B10, 0x00050004, 0x00100826, \
10410x00101210, 0x00380C34, 0x00000000, 0x00000000, \
10420x0021155B, 0x00100099, 0x00206559, 0x0010009C, \
10430x00244559, 0x00130836, 0x000C0000, 0x00220C62, \
10440x000C0001, 0x00101B13, 0x00229C0E, 0x00210C0E, \
10450x00226C0E, 0x00216C0E, 0x0022FC0E, 0x00215C0E, \
10460x00214C0E, 0x00380555, 0x00010004, 0x00041000, \
10470x00278C67, 0x00040800, 0x00018100, 0x003A0437, \
10480x00130826, 0x000C0001, 0x00220559, 0x00101313, \
10490x00380559, 0x00000000, 0x00000000, 0x00000000, \
10500x00000000, 0x00000000, 0x00000000, 0x00000000, \
10510x00000000, 0x00130831, 0x0010090B, 0x00124813, \
10520x000CFF80, 0x002606AB, 0x00041000, 0x00010004, \
10530x003806A8, 0x00000000, 0x00000000, 0x00000000, \
1054}
1055
1056/********************************************************/
1057/* Micro code for 8086:1229 Rev 9 */
1058/********************************************************/
1059
1060/* Parameter values for the D101S */
1061#define D101S_CPUSAVER_TIMER_DWORD 78
1062#define D101S_CPUSAVER_BUNDLE_DWORD 67
1063#define D101S_CPUSAVER_MIN_SIZE_DWORD 128
1064
1065#define D101S_RCVBUNDLE_UCODE \
1066{\
10670x00550242, 0xFFFF047E, 0xFFFFFFFF, 0x06FF0818, 0xFFFFFFFF, 0x05A6FFFF, \
10680x000C0001, 0x00101312, 0x000C0008, 0x00380243, \
10690x0010009C, 0x00204056, 0x002380D0, 0x00380056, \
10700x0010009C, 0x00244F8B, 0x00000800, 0x00124818, \
10710x0038047F, 0x00000000, 0x00140000, 0x003805A3, \
10720x00308000, 0x00100610, 0x00100561, 0x000E0408, \
10730x00134861, 0x000C0002, 0x00103093, 0x00308000, \
10740x00100624, 0x00100561, 0x000E0408, 0x00100861, \
10750x000C007E, 0x00222FA1, 0x000C0002, 0x00103093, \
10760x00380F90, 0x00080000, 0x00103090, 0x00380F90, \
10770x00000000, 0x00000000, 0x00000000, 0x00000000, \
10780x0010009C, 0x00244FAD, 0x00010004, 0x00041000, \
10790x003A047E, 0x00044010, 0x00380819, 0x00000000, \
10800x00100099, 0x00206FFD, 0x0010009A, 0x0020AFFD, \
10810x0010009C, 0x00244FC8, 0x00130824, 0x000C0001, \
10820x00101213, 0x00260FF7, 0x00041000, 0x00010004, \
10830x00130826, 0x000C0006, 0x00220700, 0x0013C926, \
10840x00101313, 0x00380700, 0x00000000, 0x00000000, \
10850x00000000, 0x00000000, 0x00000000, 0x00000000, \
10860x00080600, 0x00101B10, 0x00050004, 0x00100826, \
10870x00101210, 0x00380FB6, 0x00000000, 0x00000000, \
10880x002115A9, 0x00100099, 0x002065A7, 0x0010009A, \
10890x0020A5A7, 0x0010009C, 0x002445A7, 0x00130836, \
10900x000C0000, 0x00220FE4, 0x000C0001, 0x00101B13, \
10910x00229F8E, 0x00210F8E, 0x00226F8E, 0x00216F8E, \
10920x0022FF8E, 0x00215F8E, 0x00214F8E, 0x003805A3, \
10930x00010004, 0x00041000, 0x00278FE9, 0x00040800, \
10940x00018100, 0x003A047E, 0x00130826, 0x000C0001, \
10950x002205A7, 0x00101313, 0x003805A7, 0x00000000, \
10960x00000000, 0x00000000, 0x00000000, 0x00000000, \
10970x00000000, 0x00000000, 0x00000000, 0x00130831, \
10980x0010090B, 0x00124813, 0x000CFF80, 0x00260703, \
10990x00041000, 0x00010004, 0x00380700 \
1100}
1101
1102/********************************************************/
1103/* Micro code for the 8086:1229 Rev F/10 */
1104/********************************************************/
1105
1106/* Parameter values for the D102 E-step */
1107#define D102_E_CPUSAVER_TIMER_DWORD 42
1108#define D102_E_CPUSAVER_BUNDLE_DWORD 54
1109#define D102_E_CPUSAVER_MIN_SIZE_DWORD 46
1110
1111#define D102_E_RCVBUNDLE_UCODE \
1112{\
11130x007D028F, 0x0E4204F9, 0x14ED0C85, 0x14FA14E9, 0x0EF70E36, 0x1FFF1FFF, \
11140x00E014B9, 0x00000000, 0x00000000, 0x00000000, \
11150x00E014BD, 0x00000000, 0x00000000, 0x00000000, \
11160x00E014D5, 0x00000000, 0x00000000, 0x00000000, \
11170x00000000, 0x00000000, 0x00000000, 0x00000000, \
11180x00E014C1, 0x00000000, 0x00000000, 0x00000000, \
11190x00000000, 0x00000000, 0x00000000, 0x00000000, \
11200x00000000, 0x00000000, 0x00000000, 0x00000000, \
11210x00000000, 0x00000000, 0x00000000, 0x00000000, \
11220x00E014C8, 0x00000000, 0x00000000, 0x00000000, \
11230x00200600, 0x00E014EE, 0x00000000, 0x00000000, \
11240x0030FF80, 0x00940E46, 0x00038200, 0x00102000, \
11250x00E00E43, 0x00000000, 0x00000000, 0x00000000, \
11260x00300006, 0x00E014FB, 0x00000000, 0x00000000, \
11270x00000000, 0x00000000, 0x00000000, 0x00000000, \
11280x00000000, 0x00000000, 0x00000000, 0x00000000, \
11290x00000000, 0x00000000, 0x00000000, 0x00000000, \
11300x00906E41, 0x00800E3C, 0x00E00E39, 0x00000000, \
11310x00906EFD, 0x00900EFD, 0x00E00EF8, 0x00000000, \
11320x00000000, 0x00000000, 0x00000000, 0x00000000, \
11330x00000000, 0x00000000, 0x00000000, 0x00000000, \
11340x00000000, 0x00000000, 0x00000000, 0x00000000, \
11350x00000000, 0x00000000, 0x00000000, 0x00000000, \
11360x00000000, 0x00000000, 0x00000000, 0x00000000, \
11370x00000000, 0x00000000, 0x00000000, 0x00000000, \
11380x00000000, 0x00000000, 0x00000000, 0x00000000, \
11390x00000000, 0x00000000, 0x00000000, 0x00000000, \
11400x00000000, 0x00000000, 0x00000000, 0x00000000, \
11410x00000000, 0x00000000, 0x00000000, 0x00000000, \
11420x00000000, 0x00000000, 0x00000000, 0x00000000, \
11430x00000000, 0x00000000, 0x00000000, 0x00000000, \
11440x00000000, 0x00000000, 0x00000000, 0x00000000, \
11450x00000000, 0x00000000, 0x00000000, 0x00000000, \
1146}
1147
1010static void e100_load_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb) 1148static void e100_load_ucode(struct nic *nic, struct cb *cb, struct sk_buff *skb)
1011{ 1149{
1012 int i; 1150/* *INDENT-OFF* */
1013 static const u32 ucode[UCODE_SIZE] = { 1151 static struct {
1014 /* NFS packets are misinterpreted as TCO packets and 1152 u32 ucode[UCODE_SIZE + 1];
1015 * incorrectly routed to the BMC over SMBus. This 1153 u8 mac;
1016 * microcode patch checks the fragmented IP bit in the 1154 u8 timer_dword;
1017 * NFS/UDP header to distinguish between NFS and TCO. */ 1155 u8 bundle_dword;
1018 0x0EF70E36, 0x1FFF1FFF, 0x1FFF1FFF, 0x1FFF1FFF, 0x1FFF1FFF, 1156 u8 min_size_dword;
1019 0x1FFF1FFF, 0x00906E41, 0x00800E3C, 0x00E00E39, 0x00000000, 1157 } ucode_opts[] = {
1020 0x00906EFD, 0x00900EFD, 0x00E00EF8, 1158 { D101M_B_RCVBUNDLE_UCODE,
1021 }; 1159 mac_82559_D101M,
1022 1160 D101M_CPUSAVER_TIMER_DWORD,
1023 if(nic->mac == mac_82551_F || nic->mac == mac_82551_10) { 1161 D101M_CPUSAVER_BUNDLE_DWORD,
1024 for(i = 0; i < UCODE_SIZE; i++) 1162 D101M_CPUSAVER_MIN_SIZE_DWORD },
1163 { D101S_RCVBUNDLE_UCODE,
1164 mac_82559_D101S,
1165 D101S_CPUSAVER_TIMER_DWORD,
1166 D101S_CPUSAVER_BUNDLE_DWORD,
1167 D101S_CPUSAVER_MIN_SIZE_DWORD },
1168 { D102_E_RCVBUNDLE_UCODE,
1169 mac_82551_F,
1170 D102_E_CPUSAVER_TIMER_DWORD,
1171 D102_E_CPUSAVER_BUNDLE_DWORD,
1172 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1173 { D102_E_RCVBUNDLE_UCODE,
1174 mac_82551_10,
1175 D102_E_CPUSAVER_TIMER_DWORD,
1176 D102_E_CPUSAVER_BUNDLE_DWORD,
1177 D102_E_CPUSAVER_MIN_SIZE_DWORD },
1178 { {0}, 0, 0, 0, 0}
1179 }, *opts;
1180/* *INDENT-ON* */
1181
1182/*************************************************************************
1183* CPUSaver parameters
1184*
1185* All CPUSaver parameters are 16-bit literals that are part of a
1186* "move immediate value" instruction. By changing the value of
1187* the literal in the instruction before the code is loaded, the
1188* driver can change the algorithm.
1189*
1190* INTDELAY - This loads the dead-man timer with its inital value.
1191* When this timer expires the interrupt is asserted, and the
1192* timer is reset each time a new packet is received. (see
1193* BUNDLEMAX below to set the limit on number of chained packets)
1194* The current default is 0x600 or 1536. Experiments show that
1195* the value should probably stay within the 0x200 - 0x1000.
1196*
1197* BUNDLEMAX -
1198* This sets the maximum number of frames that will be bundled. In
1199* some situations, such as the TCP windowing algorithm, it may be
1200* better to limit the growth of the bundle size than let it go as
1201* high as it can, because that could cause too much added latency.
1202* The default is six, because this is the number of packets in the
1203* default TCP window size. A value of 1 would make CPUSaver indicate
1204* an interrupt for every frame received. If you do not want to put
1205* a limit on the bundle size, set this value to xFFFF.
1206*
1207* BUNDLESMALL -
1208* This contains a bit-mask describing the minimum size frame that
1209* will be bundled. The default masks the lower 7 bits, which means
1210* that any frame less than 128 bytes in length will not be bundled,
1211* but will instead immediately generate an interrupt. This does
1212* not affect the current bundle in any way. Any frame that is 128
1213* bytes or large will be bundled normally. This feature is meant
1214* to provide immediate indication of ACK frames in a TCP environment.
1215* Customers were seeing poor performance when a machine with CPUSaver
1216* enabled was sending but not receiving. The delay introduced when
1217* the ACKs were received was enough to reduce total throughput, because
1218* the sender would sit idle until the ACK was finally seen.
1219*
1220* The current default is 0xFF80, which masks out the lower 7 bits.
1221* This means that any frame which is x7F (127) bytes or smaller
1222* will cause an immediate interrupt. Because this value must be a
1223* bit mask, there are only a few valid values that can be used. To
1224* turn this feature off, the driver can write the value xFFFF to the
1225* lower word of this instruction (in the same way that the other
1226* parameters are used). Likewise, a value of 0xF800 (2047) would
1227* cause an interrupt to be generated for every frame, because all
1228* standard Ethernet frames are <= 2047 bytes in length.
1229*************************************************************************/
1230
1231/* if you wish to disable the ucode functionality, while maintaining the
1232 * workarounds it provides, set the following defines to:
1233 * BUNDLESMALL 0
1234 * BUNDLEMAX 1
1235 * INTDELAY 1
1236 */
1237#define BUNDLESMALL 1
1238#define BUNDLEMAX (u16)6
1239#define INTDELAY (u16)1536 /* 0x600 */
1240
1241 /* do not load u-code for ICH devices */
1242 if (nic->flags & ich)
1243 goto noloaducode;
1244
1245 /* Search for ucode match against h/w rev_id */
1246 for (opts = ucode_opts; opts->mac; opts++) {
1247 int i;
1248 u32 *ucode = opts->ucode;
1249 if (nic->mac != opts->mac)
1250 continue;
1251
1252 /* Insert user-tunable settings */
1253 ucode[opts->timer_dword] &= 0xFFFF0000;
1254 ucode[opts->timer_dword] |= INTDELAY;
1255 ucode[opts->bundle_dword] &= 0xFFFF0000;
1256 ucode[opts->bundle_dword] |= BUNDLEMAX;
1257 ucode[opts->min_size_dword] &= 0xFFFF0000;
1258 ucode[opts->min_size_dword] |= (BUNDLESMALL) ? 0xFFFF : 0xFF80;
1259
1260 for (i = 0; i < UCODE_SIZE; i++)
1025 cb->u.ucode[i] = cpu_to_le32(ucode[i]); 1261 cb->u.ucode[i] = cpu_to_le32(ucode[i]);
1026 cb->command = cpu_to_le16(cb_ucode); 1262 cb->command = cpu_to_le16(cb_ucode);
1027 } else 1263 return;
1028 cb->command = cpu_to_le16(cb_nop); 1264 }
1265
1266noloaducode:
1267 cb->command = cpu_to_le16(cb_nop);
1029} 1268}
1030 1269
1031static void e100_setup_iaaddr(struct nic *nic, struct cb *cb, 1270static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 8b207f0e139e..e0ae248b4313 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2621,19 +2621,7 @@ e1000_transfer_dhcp_info(struct e1000_adapter *adapter, struct sk_buff *skb)
2621 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) ) 2621 E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) )
2622 return 0; 2622 return 0;
2623 } 2623 }
2624 if(htons(ETH_P_IP) == skb->protocol) { 2624 if ((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
2625 const struct iphdr *ip = skb->nh.iph;
2626 if(IPPROTO_UDP == ip->protocol) {
2627 struct udphdr *udp = (struct udphdr *)(skb->h.uh);
2628 if(ntohs(udp->dest) == 67) {
2629 offset = (uint8_t *)udp + 8 - skb->data;
2630 length = skb->len - offset;
2631
2632 return e1000_mng_write_dhcp_info(hw,
2633 (uint8_t *)udp + 8, length);
2634 }
2635 }
2636 } else if((skb->len > MINIMUM_DHCP_PACKET_SIZE) && (!skb->protocol)) {
2637 struct ethhdr *eth = (struct ethhdr *) skb->data; 2625 struct ethhdr *eth = (struct ethhdr *) skb->data;
2638 if((htons(ETH_P_IP) == eth->h_proto)) { 2626 if((htons(ETH_P_IP) == eth->h_proto)) {
2639 const struct iphdr *ip = 2627 const struct iphdr *ip =
diff --git a/drivers/net/fec_8xx/Kconfig b/drivers/net/fec_8xx/Kconfig
index 94e7a9af8705..a84c232395e3 100644
--- a/drivers/net/fec_8xx/Kconfig
+++ b/drivers/net/fec_8xx/Kconfig
@@ -1,6 +1,6 @@
1config FEC_8XX 1config FEC_8XX
2 tristate "Motorola 8xx FEC driver" 2 tristate "Motorola 8xx FEC driver"
3 depends on NET_ETHERNET && FEC 3 depends on NET_ETHERNET && 8xx
4 select MII 4 select MII
5 5
6config FEC_8XX_GENERIC_PHY 6config FEC_8XX_GENERIC_PHY
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c
index 22aec6ed80f5..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)
@@ -80,7 +80,7 @@
80 * into nv_close, otherwise reenabling for wol can 80 * into nv_close, otherwise reenabling for wol can
81 * cause DMA to kfree'd memory. 81 * cause DMA to kfree'd memory.
82 * 0.31: 14 Nov 2004: ethtool support for getting/setting link 82 * 0.31: 14 Nov 2004: ethtool support for getting/setting link
83 * capabilities. 83 * capabilities.
84 * 0.32: 16 Apr 2005: RX_ERROR4 handling added. 84 * 0.32: 16 Apr 2005: RX_ERROR4 handling added.
85 * 0.33: 16 May 2005: Support for MCP51 added. 85 * 0.33: 16 May 2005: Support for MCP51 added.
86 * 0.34: 18 Jun 2005: Add DEV_NEED_LINKTIMER to all nForce nics. 86 * 0.34: 18 Jun 2005: Add DEV_NEED_LINKTIMER to all nForce nics.
@@ -89,14 +89,18 @@
89 * 0.37: 10 Jul 2005: Additional ethtool support, cleanup of pci id list 89 * 0.37: 10 Jul 2005: Additional ethtool support, cleanup of pci id list
90 * 0.38: 16 Jul 2005: tx irq rewrite: Use global flags instead of 90 * 0.38: 16 Jul 2005: tx irq rewrite: Use global flags instead of
91 * per-packet flags. 91 * per-packet flags.
92 * 0.39: 18 Jul 2005: Add 64bit descriptor support. 92 * 0.39: 18 Jul 2005: Add 64bit descriptor support.
93 * 0.40: 19 Jul 2005: Add support for mac address change. 93 * 0.40: 19 Jul 2005: Add support for mac address change.
94 * 0.41: 30 Jul 2005: Write back original MAC in nv_close instead 94 * 0.41: 30 Jul 2005: Write back original MAC in nv_close instead
95 * of nv_remove 95 * of nv_remove
96 * 0.42: 06 Aug 2005: Fix lack of link speed initialization 96 * 0.42: 06 Aug 2005: Fix lack of link speed initialization
97 * in the second (and later) nv_open call 97 * in the second (and later) nv_open call
98 * 0.43: 10 Aug 2005: Add support for tx checksum. 98 * 0.43: 10 Aug 2005: Add support for tx checksum.
99 * 0.44: 20 Aug 2005: Add support for scatter gather and segmentation. 99 * 0.44: 20 Aug 2005: Add support for scatter gather and segmentation.
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.
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
100 * 104 *
101 * Known bugs: 105 * Known bugs:
102 * 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.
@@ -108,7 +112,7 @@
108 * 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
109 * superfluous timer interrupts from the nic. 113 * superfluous timer interrupts from the nic.
110 */ 114 */
111#define FORCEDETH_VERSION "0.44" 115#define FORCEDETH_VERSION "0.48"
112#define DRV_NAME "forcedeth" 116#define DRV_NAME "forcedeth"
113 117
114#include <linux/module.h> 118#include <linux/module.h>
@@ -163,7 +167,8 @@ enum {
163#define NVREG_IRQ_LINK 0x0040 167#define NVREG_IRQ_LINK 0x0040
164#define NVREG_IRQ_TX_ERROR 0x0080 168#define NVREG_IRQ_TX_ERROR 0x0080
165#define NVREG_IRQ_TX1 0x0100 169#define NVREG_IRQ_TX1 0x0100
166#define NVREG_IRQMASK_WANTED 0x00df 170#define NVREG_IRQMASK_THROUGHPUT 0x00df
171#define NVREG_IRQMASK_CPU 0x0040
167 172
168#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \ 173#define NVREG_IRQ_UNKNOWN (~(NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF|NVREG_IRQ_TX_ERR| \
169 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX_ERROR| \ 174 NVREG_IRQ_TX_OK|NVREG_IRQ_TIMER|NVREG_IRQ_LINK|NVREG_IRQ_TX_ERROR| \
@@ -177,7 +182,8 @@ enum {
177 * NVREG_POLL_DEFAULT=97 would result in an interval length of 1 ms 182 * NVREG_POLL_DEFAULT=97 would result in an interval length of 1 ms
178 */ 183 */
179 NvRegPollingInterval = 0x00c, 184 NvRegPollingInterval = 0x00c,
180#define NVREG_POLL_DEFAULT 970 185#define NVREG_POLL_DEFAULT_THROUGHPUT 970
186#define NVREG_POLL_DEFAULT_CPU 13
181 NvRegMisc1 = 0x080, 187 NvRegMisc1 = 0x080,
182#define NVREG_MISC1_HD 0x02 188#define NVREG_MISC1_HD 0x02
183#define NVREG_MISC1_FORCE 0x3b0f3c 189#define NVREG_MISC1_FORCE 0x3b0f3c
@@ -538,6 +544,25 @@ struct fe_priv {
538 */ 544 */
539static int max_interrupt_work = 5; 545static int max_interrupt_work = 5;
540 546
547/*
548 * Optimization can be either throuput mode or cpu mode
549 *
550 * Throughput Mode: Every tx and rx packet will generate an interrupt.
551 * CPU Mode: Interrupts are controlled by a timer.
552 */
553#define NV_OPTIMIZATION_MODE_THROUGHPUT 0
554#define NV_OPTIMIZATION_MODE_CPU 1
555static int optimization_mode = NV_OPTIMIZATION_MODE_THROUGHPUT;
556
557/*
558 * Poll interval for timer irq
559 *
560 * This interval determines how frequent an interrupt is generated.
561 * The is value is determined by [(time_in_micro_secs * 100) / (2^10)]
562 * Min = 0, and Max = 65535
563 */
564static int poll_interval = -1;
565
541static inline struct fe_priv *get_nvpriv(struct net_device *dev) 566static inline struct fe_priv *get_nvpriv(struct net_device *dev)
542{ 567{
543 return netdev_priv(dev); 568 return netdev_priv(dev);
@@ -847,8 +872,8 @@ static int nv_alloc_rx(struct net_device *dev)
847 } else { 872 } else {
848 skb = np->rx_skbuff[nr]; 873 skb = np->rx_skbuff[nr];
849 } 874 }
850 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,
851 PCI_DMA_FROMDEVICE); 876 skb->end-skb->data, PCI_DMA_FROMDEVICE);
852 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) {
853 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]);
854 wmb(); 879 wmb();
@@ -975,7 +1000,7 @@ static void nv_drain_rx(struct net_device *dev)
975 wmb(); 1000 wmb();
976 if (np->rx_skbuff[i]) { 1001 if (np->rx_skbuff[i]) {
977 pci_unmap_single(np->pci_dev, np->rx_dma[i], 1002 pci_unmap_single(np->pci_dev, np->rx_dma[i],
978 np->rx_skbuff[i]->len, 1003 np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
979 PCI_DMA_FROMDEVICE); 1004 PCI_DMA_FROMDEVICE);
980 dev_kfree_skb(np->rx_skbuff[i]); 1005 dev_kfree_skb(np->rx_skbuff[i]);
981 np->rx_skbuff[i] = NULL; 1006 np->rx_skbuff[i] = NULL;
@@ -1310,7 +1335,7 @@ static void nv_rx_process(struct net_device *dev)
1310 * the performance. 1335 * the performance.
1311 */ 1336 */
1312 pci_unmap_single(np->pci_dev, np->rx_dma[i], 1337 pci_unmap_single(np->pci_dev, np->rx_dma[i],
1313 np->rx_skbuff[i]->len, 1338 np->rx_skbuff[i]->end-np->rx_skbuff[i]->data,
1314 PCI_DMA_FROMDEVICE); 1339 PCI_DMA_FROMDEVICE);
1315 1340
1316 { 1341 {
@@ -1328,67 +1353,71 @@ static void nv_rx_process(struct net_device *dev)
1328 if (!(Flags & NV_RX_DESCRIPTORVALID)) 1353 if (!(Flags & NV_RX_DESCRIPTORVALID))
1329 goto next_pkt; 1354 goto next_pkt;
1330 1355
1331 if (Flags & NV_RX_MISSEDFRAME) { 1356 if (Flags & NV_RX_ERROR) {
1332 np->stats.rx_missed_errors++; 1357 if (Flags & NV_RX_MISSEDFRAME) {
1333 np->stats.rx_errors++; 1358 np->stats.rx_missed_errors++;
1334 goto next_pkt;
1335 }
1336 if (Flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
1337 np->stats.rx_errors++;
1338 goto next_pkt;
1339 }
1340 if (Flags & NV_RX_CRCERR) {
1341 np->stats.rx_crc_errors++;
1342 np->stats.rx_errors++;
1343 goto next_pkt;
1344 }
1345 if (Flags & NV_RX_OVERFLOW) {
1346 np->stats.rx_over_errors++;
1347 np->stats.rx_errors++;
1348 goto next_pkt;
1349 }
1350 if (Flags & NV_RX_ERROR4) {
1351 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1352 if (len < 0) {
1353 np->stats.rx_errors++; 1359 np->stats.rx_errors++;
1354 goto next_pkt; 1360 goto next_pkt;
1355 } 1361 }
1356 } 1362 if (Flags & (NV_RX_ERROR1|NV_RX_ERROR2|NV_RX_ERROR3)) {
1357 /* framing errors are soft errors. */ 1363 np->stats.rx_errors++;
1358 if (Flags & NV_RX_FRAMINGERR) { 1364 goto next_pkt;
1359 if (Flags & NV_RX_SUBSTRACT1) { 1365 }
1360 len--; 1366 if (Flags & NV_RX_CRCERR) {
1367 np->stats.rx_crc_errors++;
1368 np->stats.rx_errors++;
1369 goto next_pkt;
1370 }
1371 if (Flags & NV_RX_OVERFLOW) {
1372 np->stats.rx_over_errors++;
1373 np->stats.rx_errors++;
1374 goto next_pkt;
1375 }
1376 if (Flags & NV_RX_ERROR4) {
1377 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1378 if (len < 0) {
1379 np->stats.rx_errors++;
1380 goto next_pkt;
1381 }
1382 }
1383 /* framing errors are soft errors. */
1384 if (Flags & NV_RX_FRAMINGERR) {
1385 if (Flags & NV_RX_SUBSTRACT1) {
1386 len--;
1387 }
1361 } 1388 }
1362 } 1389 }
1363 } else { 1390 } else {
1364 if (!(Flags & NV_RX2_DESCRIPTORVALID)) 1391 if (!(Flags & NV_RX2_DESCRIPTORVALID))
1365 goto next_pkt; 1392 goto next_pkt;
1366 1393
1367 if (Flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) { 1394 if (Flags & NV_RX2_ERROR) {
1368 np->stats.rx_errors++; 1395 if (Flags & (NV_RX2_ERROR1|NV_RX2_ERROR2|NV_RX2_ERROR3)) {
1369 goto next_pkt;
1370 }
1371 if (Flags & NV_RX2_CRCERR) {
1372 np->stats.rx_crc_errors++;
1373 np->stats.rx_errors++;
1374 goto next_pkt;
1375 }
1376 if (Flags & NV_RX2_OVERFLOW) {
1377 np->stats.rx_over_errors++;
1378 np->stats.rx_errors++;
1379 goto next_pkt;
1380 }
1381 if (Flags & NV_RX2_ERROR4) {
1382 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1383 if (len < 0) {
1384 np->stats.rx_errors++; 1396 np->stats.rx_errors++;
1385 goto next_pkt; 1397 goto next_pkt;
1386 } 1398 }
1387 } 1399 if (Flags & NV_RX2_CRCERR) {
1388 /* framing errors are soft errors */ 1400 np->stats.rx_crc_errors++;
1389 if (Flags & NV_RX2_FRAMINGERR) { 1401 np->stats.rx_errors++;
1390 if (Flags & NV_RX2_SUBSTRACT1) { 1402 goto next_pkt;
1391 len--; 1403 }
1404 if (Flags & NV_RX2_OVERFLOW) {
1405 np->stats.rx_over_errors++;
1406 np->stats.rx_errors++;
1407 goto next_pkt;
1408 }
1409 if (Flags & NV_RX2_ERROR4) {
1410 len = nv_getlen(dev, np->rx_skbuff[i]->data, len);
1411 if (len < 0) {
1412 np->stats.rx_errors++;
1413 goto next_pkt;
1414 }
1415 }
1416 /* framing errors are soft errors */
1417 if (Flags & NV_RX2_FRAMINGERR) {
1418 if (Flags & NV_RX2_SUBSTRACT1) {
1419 len--;
1420 }
1392 } 1421 }
1393 } 1422 }
1394 Flags &= NV_RX2_CHECKSUMMASK; 1423 Flags &= NV_RX2_CHECKSUMMASK;
@@ -1612,6 +1641,17 @@ static void nv_set_multicast(struct net_device *dev)
1612 spin_unlock_irq(&np->lock); 1641 spin_unlock_irq(&np->lock);
1613} 1642}
1614 1643
1644/**
1645 * nv_update_linkspeed: Setup the MAC according to the link partner
1646 * @dev: Network device to be configured
1647 *
1648 * The function queries the PHY and checks if there is a link partner.
1649 * If yes, then it sets up the MAC accordingly. Otherwise, the MAC is
1650 * set to 10 MBit HD.
1651 *
1652 * The function returns 0 if there is no link partner and 1 if there is
1653 * a good link partner.
1654 */
1615static int nv_update_linkspeed(struct net_device *dev) 1655static int nv_update_linkspeed(struct net_device *dev)
1616{ 1656{
1617 struct fe_priv *np = netdev_priv(dev); 1657 struct fe_priv *np = netdev_priv(dev);
@@ -1751,13 +1791,11 @@ set_speed:
1751static void nv_linkchange(struct net_device *dev) 1791static void nv_linkchange(struct net_device *dev)
1752{ 1792{
1753 if (nv_update_linkspeed(dev)) { 1793 if (nv_update_linkspeed(dev)) {
1754 if (netif_carrier_ok(dev)) { 1794 if (!netif_carrier_ok(dev)) {
1755 nv_stop_rx(dev);
1756 } else {
1757 netif_carrier_on(dev); 1795 netif_carrier_on(dev);
1758 printk(KERN_INFO "%s: link up.\n", dev->name); 1796 printk(KERN_INFO "%s: link up.\n", dev->name);
1797 nv_start_rx(dev);
1759 } 1798 }
1760 nv_start_rx(dev);
1761 } else { 1799 } else {
1762 if (netif_carrier_ok(dev)) { 1800 if (netif_carrier_ok(dev)) {
1763 netif_carrier_off(dev); 1801 netif_carrier_off(dev);
@@ -1799,22 +1837,18 @@ static irqreturn_t nv_nic_irq(int foo, void *data, struct pt_regs *regs)
1799 if (!(events & np->irqmask)) 1837 if (!(events & np->irqmask))
1800 break; 1838 break;
1801 1839
1802 if (events & (NVREG_IRQ_TX1|NVREG_IRQ_TX_OK|NVREG_IRQ_TX_ERROR|NVREG_IRQ_TX_ERR)) { 1840 spin_lock(&np->lock);
1841 nv_tx_done(dev);
1842 spin_unlock(&np->lock);
1843
1844 nv_rx_process(dev);
1845 if (nv_alloc_rx(dev)) {
1803 spin_lock(&np->lock); 1846 spin_lock(&np->lock);
1804 nv_tx_done(dev); 1847 if (!np->in_shutdown)
1848 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
1805 spin_unlock(&np->lock); 1849 spin_unlock(&np->lock);
1806 } 1850 }
1807 1851
1808 if (events & (NVREG_IRQ_RX_ERROR|NVREG_IRQ_RX|NVREG_IRQ_RX_NOBUF)) {
1809 nv_rx_process(dev);
1810 if (nv_alloc_rx(dev)) {
1811 spin_lock(&np->lock);
1812 if (!np->in_shutdown)
1813 mod_timer(&np->oom_kick, jiffies + OOM_REFILL);
1814 spin_unlock(&np->lock);
1815 }
1816 }
1817
1818 if (events & NVREG_IRQ_LINK) { 1852 if (events & NVREG_IRQ_LINK) {
1819 spin_lock(&np->lock); 1853 spin_lock(&np->lock);
1820 nv_link_irq(dev); 1854 nv_link_irq(dev);
@@ -2216,7 +2250,14 @@ static int nv_open(struct net_device *dev)
2216 writel(NVREG_RNDSEED_FORCE | (i&NVREG_RNDSEED_MASK), base + NvRegRandomSeed); 2250 writel(NVREG_RNDSEED_FORCE | (i&NVREG_RNDSEED_MASK), base + NvRegRandomSeed);
2217 writel(NVREG_UNKSETUP1_VAL, base + NvRegUnknownSetupReg1); 2251 writel(NVREG_UNKSETUP1_VAL, base + NvRegUnknownSetupReg1);
2218 writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2); 2252 writel(NVREG_UNKSETUP2_VAL, base + NvRegUnknownSetupReg2);
2219 writel(NVREG_POLL_DEFAULT, base + NvRegPollingInterval); 2253 if (poll_interval == -1) {
2254 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT)
2255 writel(NVREG_POLL_DEFAULT_THROUGHPUT, base + NvRegPollingInterval);
2256 else
2257 writel(NVREG_POLL_DEFAULT_CPU, base + NvRegPollingInterval);
2258 }
2259 else
2260 writel(poll_interval & 0xFFFF, base + NvRegPollingInterval);
2220 writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6); 2261 writel(NVREG_UNKSETUP6_VAL, base + NvRegUnknownSetupReg6);
2221 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING, 2262 writel((np->phyaddr << NVREG_ADAPTCTL_PHYSHIFT)|NVREG_ADAPTCTL_PHYVALID|NVREG_ADAPTCTL_RUNNING,
2222 base + NvRegAdapterControl); 2263 base + NvRegAdapterControl);
@@ -2415,7 +2456,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2415 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK; 2456 np->txrxctl_bits |= NVREG_TXRXCTL_RXCHECK;
2416 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG; 2457 dev->features |= NETIF_F_HW_CSUM | NETIF_F_SG;
2417#ifdef NETIF_F_TSO 2458#ifdef NETIF_F_TSO
2418 dev->features |= NETIF_F_TSO; 2459 /* disabled dev->features |= NETIF_F_TSO; */
2419#endif 2460#endif
2420 } 2461 }
2421 2462
@@ -2501,7 +2542,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2501 } else { 2542 } else {
2502 np->tx_flags = NV_TX2_VALID; 2543 np->tx_flags = NV_TX2_VALID;
2503 } 2544 }
2504 np->irqmask = NVREG_IRQMASK_WANTED; 2545 if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT)
2546 np->irqmask = NVREG_IRQMASK_THROUGHPUT;
2547 else
2548 np->irqmask = NVREG_IRQMASK_CPU;
2549
2505 if (id->driver_data & DEV_NEED_TIMERIRQ) 2550 if (id->driver_data & DEV_NEED_TIMERIRQ)
2506 np->irqmask |= NVREG_IRQ_TIMER; 2551 np->irqmask |= NVREG_IRQ_TIMER;
2507 if (id->driver_data & DEV_NEED_LINKTIMER) { 2552 if (id->driver_data & DEV_NEED_LINKTIMER) {
@@ -2514,16 +2559,17 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2514 } 2559 }
2515 2560
2516 /* find a suitable phy */ 2561 /* find a suitable phy */
2517 for (i = 1; i < 32; i++) { 2562 for (i = 1; i <= 32; i++) {
2518 int id1, id2; 2563 int id1, id2;
2564 int phyaddr = i & 0x1F;
2519 2565
2520 spin_lock_irq(&np->lock); 2566 spin_lock_irq(&np->lock);
2521 id1 = mii_rw(dev, i, MII_PHYSID1, MII_READ); 2567 id1 = mii_rw(dev, phyaddr, MII_PHYSID1, MII_READ);
2522 spin_unlock_irq(&np->lock); 2568 spin_unlock_irq(&np->lock);
2523 if (id1 < 0 || id1 == 0xffff) 2569 if (id1 < 0 || id1 == 0xffff)
2524 continue; 2570 continue;
2525 spin_lock_irq(&np->lock); 2571 spin_lock_irq(&np->lock);
2526 id2 = mii_rw(dev, i, MII_PHYSID2, MII_READ); 2572 id2 = mii_rw(dev, phyaddr, MII_PHYSID2, MII_READ);
2527 spin_unlock_irq(&np->lock); 2573 spin_unlock_irq(&np->lock);
2528 if (id2 < 0 || id2 == 0xffff) 2574 if (id2 < 0 || id2 == 0xffff)
2529 continue; 2575 continue;
@@ -2531,23 +2577,19 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i
2531 id1 = (id1 & PHYID1_OUI_MASK) << PHYID1_OUI_SHFT; 2577 id1 = (id1 & PHYID1_OUI_MASK) << PHYID1_OUI_SHFT;
2532 id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT; 2578 id2 = (id2 & PHYID2_OUI_MASK) >> PHYID2_OUI_SHFT;
2533 dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n", 2579 dprintk(KERN_DEBUG "%s: open: Found PHY %04x:%04x at address %d.\n",
2534 pci_name(pci_dev), id1, id2, i); 2580 pci_name(pci_dev), id1, id2, phyaddr);
2535 np->phyaddr = i; 2581 np->phyaddr = phyaddr;
2536 np->phy_oui = id1 | id2; 2582 np->phy_oui = id1 | id2;
2537 break; 2583 break;
2538 } 2584 }
2539 if (i == 32) { 2585 if (i == 33) {
2540 /* PHY in isolate mode? No phy attached and user wants to
2541 * test loopback? Very odd, but can be correct.
2542 */
2543 printk(KERN_INFO "%s: open: Could not find a valid PHY.\n", 2586 printk(KERN_INFO "%s: open: Could not find a valid PHY.\n",
2544 pci_name(pci_dev)); 2587 pci_name(pci_dev));
2545 } 2588 goto out_freering;
2546
2547 if (i != 32) {
2548 /* reset it */
2549 phy_init(dev);
2550 } 2589 }
2590
2591 /* reset it */
2592 phy_init(dev);
2551 2593
2552 /* set default link speed settings */ 2594 /* set default link speed settings */
2553 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10; 2595 np->linkspeed = NVREG_LINKSPEED_FORCE|NVREG_LINKSPEED_10;
@@ -2689,6 +2731,10 @@ static void __exit exit_nic(void)
2689 2731
2690module_param(max_interrupt_work, int, 0); 2732module_param(max_interrupt_work, int, 0);
2691MODULE_PARM_DESC(max_interrupt_work, "forcedeth maximum events handled per interrupt"); 2733MODULE_PARM_DESC(max_interrupt_work, "forcedeth maximum events handled per interrupt");
2734module_param(optimization_mode, int, 0);
2735MODULE_PARM_DESC(optimization_mode, "In throughput mode (0), every tx & rx packet will generate an interrupt. In CPU mode (1), interrupts are controlled by a timer.");
2736module_param(poll_interval, int, 0);
2737MODULE_PARM_DESC(poll_interval, "Interval determines how frequent timer interrupt is generated by [(time_in_micro_secs * 100) / (2^10)]. Min is 0 and Max is 65535.");
2692 2738
2693MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>"); 2739MODULE_AUTHOR("Manfred Spraul <manfred@colorfullife.com>");
2694MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver"); 2740MODULE_DESCRIPTION("Reverse Engineered nForce ethernet driver");
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index 9342d5bc7bb4..f5d49a110654 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -37,6 +37,7 @@
37#include <linux/ethtool.h> 37#include <linux/ethtool.h>
38#include <linux/bitops.h> 38#include <linux/bitops.h>
39#include <linux/fs.h> 39#include <linux/fs.h>
40#include <linux/platform_device.h>
40 41
41#include <linux/vmalloc.h> 42#include <linux/vmalloc.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c
index a940b96433c7..e67b1d06611c 100644
--- a/drivers/net/fs_enet/mac-fcc.c
+++ b/drivers/net/fs_enet/mac-fcc.c
@@ -34,6 +34,7 @@
34#include <linux/ethtool.h> 34#include <linux/ethtool.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/platform_device.h>
37 38
38#include <asm/immap_cpm2.h> 39#include <asm/immap_cpm2.h>
39#include <asm/mpc8260.h> 40#include <asm/mpc8260.h>
diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c
index 5ef4e845a387..2e8f44469699 100644
--- a/drivers/net/fs_enet/mac-fec.c
+++ b/drivers/net/fs_enet/mac-fec.c
@@ -34,6 +34,7 @@
34#include <linux/ethtool.h> 34#include <linux/ethtool.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/platform_device.h>
37 38
38#include <asm/irq.h> 39#include <asm/irq.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c
index d8c6e9cadcf5..a3897fda71fa 100644
--- a/drivers/net/fs_enet/mac-scc.c
+++ b/drivers/net/fs_enet/mac-scc.c
@@ -34,6 +34,7 @@
34#include <linux/ethtool.h> 34#include <linux/ethtool.h>
35#include <linux/bitops.h> 35#include <linux/bitops.h>
36#include <linux/fs.h> 36#include <linux/fs.h>
37#include <linux/platform_device.h>
37 38
38#include <asm/irq.h> 39#include <asm/irq.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 54d294ad6df5..0f030b73cbb3 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -6,7 +6,7 @@
6 * Based on 8260_io/fcc_enet.c 6 * Based on 8260_io/fcc_enet.c
7 * 7 *
8 * Author: Andy Fleming 8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 9 * Maintainer: Kumar Gala
10 * 10 *
11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
12 * 12 *
@@ -126,8 +126,8 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs);
126static void adjust_link(struct net_device *dev); 126static void adjust_link(struct net_device *dev);
127static void init_registers(struct net_device *dev); 127static void init_registers(struct net_device *dev);
128static int init_phy(struct net_device *dev); 128static int init_phy(struct net_device *dev);
129static int gfar_probe(struct device *device); 129static int gfar_probe(struct platform_device *pdev);
130static int gfar_remove(struct device *device); 130static int gfar_remove(struct platform_device *pdev);
131static void free_skb_resources(struct gfar_private *priv); 131static void free_skb_resources(struct gfar_private *priv);
132static void gfar_set_multi(struct net_device *dev); 132static void gfar_set_multi(struct net_device *dev);
133static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr); 133static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr);
@@ -156,12 +156,11 @@ int gfar_uses_fcb(struct gfar_private *priv)
156 156
157/* Set up the ethernet device structure, private data, 157/* Set up the ethernet device structure, private data,
158 * and anything else we need before we start */ 158 * and anything else we need before we start */
159static int gfar_probe(struct device *device) 159static int gfar_probe(struct platform_device *pdev)
160{ 160{
161 u32 tempval; 161 u32 tempval;
162 struct net_device *dev = NULL; 162 struct net_device *dev = NULL;
163 struct gfar_private *priv = NULL; 163 struct gfar_private *priv = NULL;
164 struct platform_device *pdev = to_platform_device(device);
165 struct gianfar_platform_data *einfo; 164 struct gianfar_platform_data *einfo;
166 struct resource *r; 165 struct resource *r;
167 int idx; 166 int idx;
@@ -208,7 +207,7 @@ static int gfar_probe(struct device *device)
208 207
209 spin_lock_init(&priv->lock); 208 spin_lock_init(&priv->lock);
210 209
211 dev_set_drvdata(device, dev); 210 platform_set_drvdata(pdev, dev);
212 211
213 /* Stop the DMA engine now, in case it was running before */ 212 /* Stop the DMA engine now, in case it was running before */
214 /* (The firmware could have used it, and left it running). */ 213 /* (The firmware could have used it, and left it running). */
@@ -245,7 +244,7 @@ static int gfar_probe(struct device *device)
245 dev->base_addr = (unsigned long) (priv->regs); 244 dev->base_addr = (unsigned long) (priv->regs);
246 245
247 SET_MODULE_OWNER(dev); 246 SET_MODULE_OWNER(dev);
248 SET_NETDEV_DEV(dev, device); 247 SET_NETDEV_DEV(dev, &pdev->dev);
249 248
250 /* Fill in the dev structure */ 249 /* Fill in the dev structure */
251 dev->open = gfar_enet_open; 250 dev->open = gfar_enet_open;
@@ -377,12 +376,12 @@ regs_fail:
377 return err; 376 return err;
378} 377}
379 378
380static int gfar_remove(struct device *device) 379static int gfar_remove(struct platform_device *pdev)
381{ 380{
382 struct net_device *dev = dev_get_drvdata(device); 381 struct net_device *dev = platform_get_drvdata(pdev);
383 struct gfar_private *priv = netdev_priv(dev); 382 struct gfar_private *priv = netdev_priv(dev);
384 383
385 dev_set_drvdata(device, NULL); 384 platform_set_drvdata(pdev, NULL);
386 385
387 iounmap((void *) priv->regs); 386 iounmap((void *) priv->regs);
388 free_netdev(dev); 387 free_netdev(dev);
@@ -1861,11 +1860,12 @@ static irqreturn_t gfar_error(int irq, void *dev_id, struct pt_regs *regs)
1861} 1860}
1862 1861
1863/* Structure for a device driver */ 1862/* Structure for a device driver */
1864static struct device_driver gfar_driver = { 1863static struct platform_driver gfar_driver = {
1865 .name = "fsl-gianfar",
1866 .bus = &platform_bus_type,
1867 .probe = gfar_probe, 1864 .probe = gfar_probe,
1868 .remove = gfar_remove, 1865 .remove = gfar_remove,
1866 .driver = {
1867 .name = "fsl-gianfar",
1868 },
1869}; 1869};
1870 1870
1871static int __init gfar_init(void) 1871static int __init gfar_init(void)
@@ -1875,7 +1875,7 @@ static int __init gfar_init(void)
1875 if (err) 1875 if (err)
1876 return err; 1876 return err;
1877 1877
1878 err = driver_register(&gfar_driver); 1878 err = platform_driver_register(&gfar_driver);
1879 1879
1880 if (err) 1880 if (err)
1881 gfar_mdio_exit(); 1881 gfar_mdio_exit();
@@ -1885,7 +1885,7 @@ static int __init gfar_init(void)
1885 1885
1886static void __exit gfar_exit(void) 1886static void __exit gfar_exit(void)
1887{ 1887{
1888 driver_unregister(&gfar_driver); 1888 platform_driver_unregister(&gfar_driver);
1889 gfar_mdio_exit(); 1889 gfar_mdio_exit();
1890} 1890}
1891 1891
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index 220084e53341..5065ba82cb76 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -6,7 +6,7 @@
6 * Based on 8260_io/fcc_enet.c 6 * Based on 8260_io/fcc_enet.c
7 * 7 *
8 * Author: Andy Fleming 8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 9 * Maintainer: Kumar Gala
10 * 10 *
11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 11 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
12 * 12 *
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index 5a2d810ce575..cfa3cd7c91a0 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -6,7 +6,7 @@
6 * Based on e1000 ethtool support 6 * Based on e1000 ethtool support
7 * 7 *
8 * Author: Andy Fleming 8 * Author: Andy Fleming
9 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 9 * Maintainer: Kumar Gala
10 * 10 *
11 * Copyright (c) 2003,2004 Freescale Semiconductor, Inc. 11 * Copyright (c) 2003,2004 Freescale Semiconductor, Inc.
12 * 12 *
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index 7263395d78bb..04a462c2a5b7 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -5,7 +5,7 @@
5 * Provides Bus interface for MIIM regs 5 * Provides Bus interface for MIIM regs
6 * 6 *
7 * Author: Andy Fleming 7 * Author: Andy Fleming
8 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 8 * Maintainer: Kumar Gala
9 * 9 *
10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
11 * 11 *
@@ -133,7 +133,7 @@ int gfar_mdio_probe(struct device *dev)
133 if (NULL == dev) 133 if (NULL == dev)
134 return -EINVAL; 134 return -EINVAL;
135 135
136 new_bus = kmalloc(sizeof(struct mii_bus), GFP_KERNEL); 136 new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL);
137 137
138 if (NULL == new_bus) 138 if (NULL == new_bus)
139 return -ENOMEM; 139 return -ENOMEM;
diff --git a/drivers/net/gianfar_mii.h b/drivers/net/gianfar_mii.h
index 56e5665d5c9b..e85eb216fb5b 100644
--- a/drivers/net/gianfar_mii.h
+++ b/drivers/net/gianfar_mii.h
@@ -5,7 +5,7 @@
5 * Driver for the MDIO bus controller in the Gianfar register space 5 * Driver for the MDIO bus controller in the Gianfar register space
6 * 6 *
7 * Author: Andy Fleming 7 * Author: Andy Fleming
8 * Maintainer: Kumar Gala (kumar.gala@freescale.com) 8 * Maintainer: Kumar Gala
9 * 9 *
10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc. 10 * Copyright (c) 2002-2004 Freescale Semiconductor, Inc.
11 * 11 *
diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
index 666cfbbcf6d9..5958a6314723 100644
--- a/drivers/net/gt96100eth.c
+++ b/drivers/net/gt96100eth.c
@@ -72,8 +72,6 @@ static void dump_tx_desc(int dbg_lvl, struct net_device *dev, int i);
72static void dump_rx_desc(int dbg_lvl, struct net_device *dev, int i); 72static void dump_rx_desc(int dbg_lvl, struct net_device *dev, int i);
73static void dump_skb(int dbg_lvl, struct net_device *dev, 73static void dump_skb(int dbg_lvl, struct net_device *dev,
74 struct sk_buff *skb); 74 struct sk_buff *skb);
75static void dump_hw_addr(int dbg_lvl, struct net_device *dev,
76 const char* pfx, unsigned char* addr_str);
77static void update_stats(struct gt96100_private *gp); 75static void update_stats(struct gt96100_private *gp);
78static void abort(struct net_device *dev, u32 abort_bits); 76static void abort(struct net_device *dev, u32 abort_bits);
79static void hard_stop(struct net_device *dev); 77static void hard_stop(struct net_device *dev);
@@ -334,13 +332,13 @@ dump_MII(int dbg_lvl, struct net_device *dev)
334 332
335static void 333static void
336dump_hw_addr(int dbg_lvl, struct net_device *dev, const char* pfx, 334dump_hw_addr(int dbg_lvl, struct net_device *dev, const char* pfx,
337 unsigned char* addr_str) 335 const char* func, unsigned char* addr_str)
338{ 336{
339 int i; 337 int i;
340 char buf[100], octet[5]; 338 char buf[100], octet[5];
341 339
342 if (dbg_lvl <= GT96100_DEBUG) { 340 if (dbg_lvl <= GT96100_DEBUG) {
343 strcpy(buf, pfx); 341 sprintf(buf, pfx, func);
344 for (i = 0; i < 6; i++) { 342 for (i = 0; i < 6; i++) {
345 sprintf(octet, "%2.2x%s", 343 sprintf(octet, "%2.2x%s",
346 addr_str[i], i<5 ? ":" : "\n"); 344 addr_str[i], i<5 ? ":" : "\n");
@@ -708,7 +706,7 @@ static int __init gt96100_probe1(struct pci_dev *pci, int port_num)
708 706
709 info("%s found at 0x%x, irq %d\n", 707 info("%s found at 0x%x, irq %d\n",
710 chip_name(gp->chip_rev), gtif->iobase, gtif->irq); 708 chip_name(gp->chip_rev), gtif->iobase, gtif->irq);
711 dump_hw_addr(0, dev, "HW Address ", dev->dev_addr); 709 dump_hw_addr(0, dev, "%s: HW Address ", __FUNCTION__, dev->dev_addr);
712 info("%s chip revision=%d\n", chip_name(gp->chip_rev), gp->chip_rev); 710 info("%s chip revision=%d\n", chip_name(gp->chip_rev), gp->chip_rev);
713 info("%s ethernet port %d\n", chip_name(gp->chip_rev), gp->port_num); 711 info("%s ethernet port %d\n", chip_name(gp->chip_rev), gp->port_num);
714 info("external PHY ID1=0x%04x, ID2=0x%04x\n", phy_id1, phy_id2); 712 info("external PHY ID1=0x%04x, ID2=0x%04x\n", phy_id1, phy_id2);
@@ -1488,7 +1486,7 @@ gt96100_set_rx_mode(struct net_device *dev)
1488 gt96100_add_hash_entry(dev, dev->dev_addr); 1486 gt96100_add_hash_entry(dev, dev->dev_addr);
1489 1487
1490 for (mcptr = dev->mc_list; mcptr; mcptr = mcptr->next) { 1488 for (mcptr = dev->mc_list; mcptr; mcptr = mcptr->next) {
1491 dump_hw_addr(2, dev, __FUNCTION__ ": addr=", 1489 dump_hw_addr(2, dev, "%s: addr=", __FUNCTION__,
1492 mcptr->dmi_addr); 1490 mcptr->dmi_addr);
1493 gt96100_add_hash_entry(dev, mcptr->dmi_addr); 1491 gt96100_add_hash_entry(dev, mcptr->dmi_addr);
1494 } 1492 }
diff --git a/drivers/net/ibm_emac/ibm_emac_core.c b/drivers/net/ibm_emac/ibm_emac_core.c
index eb7d69478715..1da8a66f91e1 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.c
+++ b/drivers/net/ibm_emac/ibm_emac_core.c
@@ -65,7 +65,7 @@
65 */ 65 */
66 66
67#define DRV_NAME "emac" 67#define DRV_NAME "emac"
68#define DRV_VERSION "3.53" 68#define DRV_VERSION "3.54"
69#define DRV_DESC "PPC 4xx OCP EMAC driver" 69#define DRV_DESC "PPC 4xx OCP EMAC driver"
70 70
71MODULE_DESCRIPTION(DRV_DESC); 71MODULE_DESCRIPTION(DRV_DESC);
@@ -158,6 +158,14 @@ static inline void emac_report_timeout_error(struct ocp_enet_private *dev,
158#define PHY_POLL_LINK_ON HZ 158#define PHY_POLL_LINK_ON HZ
159#define PHY_POLL_LINK_OFF (HZ / 5) 159#define PHY_POLL_LINK_OFF (HZ / 5)
160 160
161/* Graceful stop timeouts in us.
162 * We should allow up to 1 frame time (full-duplex, ignoring collisions)
163 */
164#define STOP_TIMEOUT_10 1230
165#define STOP_TIMEOUT_100 124
166#define STOP_TIMEOUT_1000 13
167#define STOP_TIMEOUT_1000_JUMBO 73
168
161/* Please, keep in sync with struct ibm_emac_stats/ibm_emac_error_stats */ 169/* Please, keep in sync with struct ibm_emac_stats/ibm_emac_error_stats */
162static const char emac_stats_keys[EMAC_ETHTOOL_STATS_COUNT][ETH_GSTRING_LEN] = { 170static const char emac_stats_keys[EMAC_ETHTOOL_STATS_COUNT][ETH_GSTRING_LEN] = {
163 "rx_packets", "rx_bytes", "tx_packets", "tx_bytes", "rx_packets_csum", 171 "rx_packets", "rx_bytes", "tx_packets", "tx_bytes", "rx_packets_csum",
@@ -222,10 +230,12 @@ static void emac_tx_disable(struct ocp_enet_private *dev)
222 230
223 r = in_be32(&p->mr0); 231 r = in_be32(&p->mr0);
224 if (r & EMAC_MR0_TXE) { 232 if (r & EMAC_MR0_TXE) {
225 int n = 300; 233 int n = dev->stop_timeout;
226 out_be32(&p->mr0, r & ~EMAC_MR0_TXE); 234 out_be32(&p->mr0, r & ~EMAC_MR0_TXE);
227 while (!(in_be32(&p->mr0) & EMAC_MR0_TXI) && n) 235 while (!(in_be32(&p->mr0) & EMAC_MR0_TXI) && n) {
236 udelay(1);
228 --n; 237 --n;
238 }
229 if (unlikely(!n)) 239 if (unlikely(!n))
230 emac_report_timeout_error(dev, "TX disable timeout"); 240 emac_report_timeout_error(dev, "TX disable timeout");
231 } 241 }
@@ -248,9 +258,11 @@ static void emac_rx_enable(struct ocp_enet_private *dev)
248 if (!(r & EMAC_MR0_RXE)) { 258 if (!(r & EMAC_MR0_RXE)) {
249 if (unlikely(!(r & EMAC_MR0_RXI))) { 259 if (unlikely(!(r & EMAC_MR0_RXI))) {
250 /* Wait if previous async disable is still in progress */ 260 /* Wait if previous async disable is still in progress */
251 int n = 100; 261 int n = dev->stop_timeout;
252 while (!(r = in_be32(&p->mr0) & EMAC_MR0_RXI) && n) 262 while (!(r = in_be32(&p->mr0) & EMAC_MR0_RXI) && n) {
263 udelay(1);
253 --n; 264 --n;
265 }
254 if (unlikely(!n)) 266 if (unlikely(!n))
255 emac_report_timeout_error(dev, 267 emac_report_timeout_error(dev,
256 "RX disable timeout"); 268 "RX disable timeout");
@@ -273,10 +285,12 @@ static void emac_rx_disable(struct ocp_enet_private *dev)
273 285
274 r = in_be32(&p->mr0); 286 r = in_be32(&p->mr0);
275 if (r & EMAC_MR0_RXE) { 287 if (r & EMAC_MR0_RXE) {
276 int n = 300; 288 int n = dev->stop_timeout;
277 out_be32(&p->mr0, r & ~EMAC_MR0_RXE); 289 out_be32(&p->mr0, r & ~EMAC_MR0_RXE);
278 while (!(in_be32(&p->mr0) & EMAC_MR0_RXI) && n) 290 while (!(in_be32(&p->mr0) & EMAC_MR0_RXI) && n) {
291 udelay(1);
279 --n; 292 --n;
293 }
280 if (unlikely(!n)) 294 if (unlikely(!n))
281 emac_report_timeout_error(dev, "RX disable timeout"); 295 emac_report_timeout_error(dev, "RX disable timeout");
282 } 296 }
@@ -395,6 +409,7 @@ static int emac_configure(struct ocp_enet_private *dev)
395 r = EMAC_MR1_BASE(emac_opb_mhz()) | EMAC_MR1_VLE | EMAC_MR1_IST; 409 r = EMAC_MR1_BASE(emac_opb_mhz()) | EMAC_MR1_VLE | EMAC_MR1_IST;
396 if (dev->phy.duplex == DUPLEX_FULL) 410 if (dev->phy.duplex == DUPLEX_FULL)
397 r |= EMAC_MR1_FDE; 411 r |= EMAC_MR1_FDE;
412 dev->stop_timeout = STOP_TIMEOUT_10;
398 switch (dev->phy.speed) { 413 switch (dev->phy.speed) {
399 case SPEED_1000: 414 case SPEED_1000:
400 if (emac_phy_gpcs(dev->phy.mode)) { 415 if (emac_phy_gpcs(dev->phy.mode)) {
@@ -409,12 +424,16 @@ static int emac_configure(struct ocp_enet_private *dev)
409 r |= EMAC_MR1_MF_1000; 424 r |= EMAC_MR1_MF_1000;
410 r |= EMAC_MR1_RFS_16K; 425 r |= EMAC_MR1_RFS_16K;
411 gige = 1; 426 gige = 1;
412 427
413 if (dev->ndev->mtu > ETH_DATA_LEN) 428 if (dev->ndev->mtu > ETH_DATA_LEN) {
414 r |= EMAC_MR1_JPSM; 429 r |= EMAC_MR1_JPSM;
430 dev->stop_timeout = STOP_TIMEOUT_1000_JUMBO;
431 } else
432 dev->stop_timeout = STOP_TIMEOUT_1000;
415 break; 433 break;
416 case SPEED_100: 434 case SPEED_100:
417 r |= EMAC_MR1_MF_100; 435 r |= EMAC_MR1_MF_100;
436 dev->stop_timeout = STOP_TIMEOUT_100;
418 /* Fall through */ 437 /* Fall through */
419 default: 438 default:
420 r |= EMAC_MR1_RFS_4K; 439 r |= EMAC_MR1_RFS_4K;
@@ -2048,6 +2067,7 @@ static int __init emac_probe(struct ocp_device *ocpdev)
2048 dev->phy.duplex = DUPLEX_FULL; 2067 dev->phy.duplex = DUPLEX_FULL;
2049 dev->phy.autoneg = AUTONEG_DISABLE; 2068 dev->phy.autoneg = AUTONEG_DISABLE;
2050 dev->phy.pause = dev->phy.asym_pause = 0; 2069 dev->phy.pause = dev->phy.asym_pause = 0;
2070 dev->stop_timeout = STOP_TIMEOUT_100;
2051 init_timer(&dev->link_timer); 2071 init_timer(&dev->link_timer);
2052 dev->link_timer.function = emac_link_timer; 2072 dev->link_timer.function = emac_link_timer;
2053 dev->link_timer.data = (unsigned long)dev; 2073 dev->link_timer.data = (unsigned long)dev;
diff --git a/drivers/net/ibm_emac/ibm_emac_core.h b/drivers/net/ibm_emac/ibm_emac_core.h
index e9b44d030ac3..911abbaf471b 100644
--- a/drivers/net/ibm_emac/ibm_emac_core.h
+++ b/drivers/net/ibm_emac/ibm_emac_core.h
@@ -189,6 +189,8 @@ struct ocp_enet_private {
189 struct timer_list link_timer; 189 struct timer_list link_timer;
190 int reset_failed; 190 int reset_failed;
191 191
192 int stop_timeout; /* in us */
193
192 struct ibm_emac_error_stats estats; 194 struct ibm_emac_error_stats estats;
193 struct net_device_stats nstats; 195 struct net_device_stats nstats;
194 196
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
index be191d80ef9c..ceb98fd398af 100644
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -58,7 +58,7 @@
58 58
59#include "ibmveth.h" 59#include "ibmveth.h"
60 60
61#define DEBUG 1 61#undef DEBUG
62 62
63#define ibmveth_printk(fmt, args...) \ 63#define ibmveth_printk(fmt, args...) \
64 printk(KERN_INFO "%s: " fmt, __FILE__, ## args) 64 printk(KERN_INFO "%s: " fmt, __FILE__, ## args)
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c
index 6a3129bc15a6..9b8295ee06ef 100644
--- a/drivers/net/ioc3-eth.c
+++ b/drivers/net/ioc3-eth.c
@@ -1360,7 +1360,7 @@ static struct pci_driver ioc3_driver = {
1360 1360
1361static int __init ioc3_init_module(void) 1361static int __init ioc3_init_module(void)
1362{ 1362{
1363 return pci_module_init(&ioc3_driver); 1363 return pci_register_driver(&ioc3_driver);
1364} 1364}
1365 1365
1366static void __exit ioc3_cleanup_module(void) 1366static void __exit ioc3_cleanup_module(void)
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c
index 9bf34681d3df..2e7882eb7d6f 100644
--- a/drivers/net/irda/ali-ircc.c
+++ b/drivers/net/irda/ali-ircc.c
@@ -40,6 +40,7 @@
40#include <asm/byteorder.h> 40#include <asm/byteorder.h>
41 41
42#include <linux/pm.h> 42#include <linux/pm.h>
43#include <linux/pm_legacy.h>
43 44
44#include <net/irda/wrapper.h> 45#include <net/irda/wrapper.h>
45#include <net/irda/irda.h> 46#include <net/irda/irda.h>
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c
index 805714ec9a8a..ee717d0e939e 100644
--- a/drivers/net/irda/nsc-ircc.c
+++ b/drivers/net/irda/nsc-ircc.c
@@ -59,6 +59,7 @@
59#include <asm/byteorder.h> 59#include <asm/byteorder.h>
60 60
61#include <linux/pm.h> 61#include <linux/pm.h>
62#include <linux/pm_legacy.h>
62 63
63#include <net/irda/wrapper.h> 64#include <net/irda/wrapper.h>
64#include <net/irda/irda.h> 65#include <net/irda/irda.h>
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 76e0b9fb5e96..63d38fbbd04e 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -291,9 +291,9 @@ static void sa1100_irda_shutdown(struct sa1100_irda *si)
291/* 291/*
292 * Suspend the IrDA interface. 292 * Suspend the IrDA interface.
293 */ 293 */
294static int sa1100_irda_suspend(struct device *_dev, pm_message_t state) 294static int sa1100_irda_suspend(struct platform_device *pdev, pm_message_t state)
295{ 295{
296 struct net_device *dev = dev_get_drvdata(_dev); 296 struct net_device *dev = platform_get_drvdata(pdev);
297 struct sa1100_irda *si; 297 struct sa1100_irda *si;
298 298
299 if (!dev) 299 if (!dev)
@@ -316,9 +316,9 @@ static int sa1100_irda_suspend(struct device *_dev, pm_message_t state)
316/* 316/*
317 * Resume the IrDA interface. 317 * Resume the IrDA interface.
318 */ 318 */
319static int sa1100_irda_resume(struct device *_dev) 319static int sa1100_irda_resume(struct platform_device *pdev)
320{ 320{
321 struct net_device *dev = dev_get_drvdata(_dev); 321 struct net_device *dev = platform_get_drvdata(pdev);
322 struct sa1100_irda *si; 322 struct sa1100_irda *si;
323 323
324 if (!dev) 324 if (!dev)
@@ -886,9 +886,8 @@ static int sa1100_irda_init_iobuf(iobuff_t *io, int size)
886 return io->head ? 0 : -ENOMEM; 886 return io->head ? 0 : -ENOMEM;
887} 887}
888 888
889static int sa1100_irda_probe(struct device *_dev) 889static int sa1100_irda_probe(struct platform_device *pdev)
890{ 890{
891 struct platform_device *pdev = to_platform_device(_dev);
892 struct net_device *dev; 891 struct net_device *dev;
893 struct sa1100_irda *si; 892 struct sa1100_irda *si;
894 unsigned int baudrate_mask; 893 unsigned int baudrate_mask;
@@ -967,7 +966,7 @@ static int sa1100_irda_probe(struct device *_dev)
967 966
968 err = register_netdev(dev); 967 err = register_netdev(dev);
969 if (err == 0) 968 if (err == 0)
970 dev_set_drvdata(&pdev->dev, dev); 969 platform_set_drvdata(pdev, dev);
971 970
972 if (err) { 971 if (err) {
973 err_mem_5: 972 err_mem_5:
@@ -985,9 +984,9 @@ static int sa1100_irda_probe(struct device *_dev)
985 return err; 984 return err;
986} 985}
987 986
988static int sa1100_irda_remove(struct device *_dev) 987static int sa1100_irda_remove(struct platform_device *pdev)
989{ 988{
990 struct net_device *dev = dev_get_drvdata(_dev); 989 struct net_device *dev = platform_get_drvdata(pdev);
991 990
992 if (dev) { 991 if (dev) {
993 struct sa1100_irda *si = dev->priv; 992 struct sa1100_irda *si = dev->priv;
@@ -1004,13 +1003,14 @@ static int sa1100_irda_remove(struct device *_dev)
1004 return 0; 1003 return 0;
1005} 1004}
1006 1005
1007static struct device_driver sa1100ir_driver = { 1006static struct platform_driver sa1100ir_driver = {
1008 .name = "sa11x0-ir",
1009 .bus = &platform_bus_type,
1010 .probe = sa1100_irda_probe, 1007 .probe = sa1100_irda_probe,
1011 .remove = sa1100_irda_remove, 1008 .remove = sa1100_irda_remove,
1012 .suspend = sa1100_irda_suspend, 1009 .suspend = sa1100_irda_suspend,
1013 .resume = sa1100_irda_resume, 1010 .resume = sa1100_irda_resume,
1011 .driver = {
1012 .name = "sa11x0-ir",
1013 },
1014}; 1014};
1015 1015
1016static int __init sa1100_irda_init(void) 1016static int __init sa1100_irda_init(void)
@@ -1023,12 +1023,12 @@ static int __init sa1100_irda_init(void)
1023 if (power_level > 3) 1023 if (power_level > 3)
1024 power_level = 3; 1024 power_level = 3;
1025 1025
1026 return driver_register(&sa1100ir_driver); 1026 return platform_driver_register(&sa1100ir_driver);
1027} 1027}
1028 1028
1029static void __exit sa1100_irda_exit(void) 1029static void __exit sa1100_irda_exit(void)
1030{ 1030{
1031 driver_unregister(&sa1100ir_driver); 1031 platform_driver_unregister(&sa1100ir_driver);
1032} 1032}
1033 1033
1034module_init(sa1100_irda_init); 1034module_init(sa1100_irda_init);
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index a1d207f2fa68..ec94ecdb103d 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -214,14 +214,15 @@ static int smsc_ircc_probe_transceiver_smsc_ircc_atc(int fir_base);
214 214
215/* Power Management */ 215/* Power Management */
216 216
217static int smsc_ircc_suspend(struct device *dev, pm_message_t state); 217static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state);
218static int smsc_ircc_resume(struct device *dev); 218static int smsc_ircc_resume(struct platform_device *dev);
219 219
220static struct device_driver smsc_ircc_driver = { 220static struct platform_driver smsc_ircc_driver = {
221 .name = SMSC_IRCC2_DRIVER_NAME,
222 .bus = &platform_bus_type,
223 .suspend = smsc_ircc_suspend, 221 .suspend = smsc_ircc_suspend,
224 .resume = smsc_ircc_resume, 222 .resume = smsc_ircc_resume,
223 .driver = {
224 .name = SMSC_IRCC2_DRIVER_NAME,
225 },
225}; 226};
226 227
227/* Transceivers for SMSC-ircc */ 228/* Transceivers for SMSC-ircc */
@@ -346,7 +347,7 @@ static int __init smsc_ircc_init(void)
346 347
347 IRDA_DEBUG(1, "%s\n", __FUNCTION__); 348 IRDA_DEBUG(1, "%s\n", __FUNCTION__);
348 349
349 ret = driver_register(&smsc_ircc_driver); 350 ret = platform_driver_register(&smsc_ircc_driver);
350 if (ret) { 351 if (ret) {
351 IRDA_ERROR("%s, Can't register driver!\n", driver_name); 352 IRDA_ERROR("%s, Can't register driver!\n", driver_name);
352 return ret; 353 return ret;
@@ -378,7 +379,7 @@ static int __init smsc_ircc_init(void)
378 } 379 }
379 380
380 if (ret) 381 if (ret)
381 driver_unregister(&smsc_ircc_driver); 382 platform_driver_unregister(&smsc_ircc_driver);
382 383
383 return ret; 384 return ret;
384} 385}
@@ -491,7 +492,7 @@ static int __init smsc_ircc_open(unsigned int fir_base, unsigned int sir_base, u
491 err = PTR_ERR(self->pldev); 492 err = PTR_ERR(self->pldev);
492 goto err_out5; 493 goto err_out5;
493 } 494 }
494 dev_set_drvdata(&self->pldev->dev, self); 495 platform_set_drvdata(self->pldev, self);
495 496
496 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name); 497 IRDA_MESSAGE("IrDA: Registered device %s\n", dev->name);
497 dev_count++; 498 dev_count++;
@@ -1685,9 +1686,9 @@ static int smsc_ircc_net_close(struct net_device *dev)
1685 return 0; 1686 return 0;
1686} 1687}
1687 1688
1688static int smsc_ircc_suspend(struct device *dev, pm_message_t state) 1689static int smsc_ircc_suspend(struct platform_device *dev, pm_message_t state)
1689{ 1690{
1690 struct smsc_ircc_cb *self = dev_get_drvdata(dev); 1691 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
1691 1692
1692 if (!self->io.suspended) { 1693 if (!self->io.suspended) {
1693 IRDA_DEBUG(1, "%s, Suspending\n", driver_name); 1694 IRDA_DEBUG(1, "%s, Suspending\n", driver_name);
@@ -1706,9 +1707,9 @@ static int smsc_ircc_suspend(struct device *dev, pm_message_t state)
1706 return 0; 1707 return 0;
1707} 1708}
1708 1709
1709static int smsc_ircc_resume(struct device *dev) 1710static int smsc_ircc_resume(struct platform_device *dev)
1710{ 1711{
1711 struct smsc_ircc_cb *self = dev_get_drvdata(dev); 1712 struct smsc_ircc_cb *self = platform_get_drvdata(dev);
1712 1713
1713 if (self->io.suspended) { 1714 if (self->io.suspended) {
1714 IRDA_DEBUG(1, "%s, Waking up\n", driver_name); 1715 IRDA_DEBUG(1, "%s, Waking up\n", driver_name);
@@ -1788,7 +1789,7 @@ static void __exit smsc_ircc_cleanup(void)
1788 smsc_ircc_close(dev_self[i]); 1789 smsc_ircc_close(dev_self[i]);
1789 } 1790 }
1790 1791
1791 driver_unregister(&smsc_ircc_driver); 1792 platform_driver_unregister(&smsc_ircc_driver);
1792} 1793}
1793 1794
1794/* 1795/*
diff --git a/drivers/net/jazzsonic.c b/drivers/net/jazzsonic.c
index 2fb3101cb33e..272d331d29cd 100644
--- a/drivers/net/jazzsonic.c
+++ b/drivers/net/jazzsonic.c
@@ -194,7 +194,7 @@ out:
194 * Probe for a SONIC ethernet controller on a Mips Jazz board. 194 * Probe for a SONIC ethernet controller on a Mips Jazz board.
195 * Actually probing is superfluous but we're paranoid. 195 * Actually probing is superfluous but we're paranoid.
196 */ 196 */
197static int __init jazz_sonic_probe(struct device *device) 197static int __init jazz_sonic_probe(struct platform_device *pdev)
198{ 198{
199 struct net_device *dev; 199 struct net_device *dev;
200 struct sonic_local *lp; 200 struct sonic_local *lp;
@@ -212,8 +212,8 @@ static int __init jazz_sonic_probe(struct device *device)
212 return -ENOMEM; 212 return -ENOMEM;
213 213
214 lp = netdev_priv(dev); 214 lp = netdev_priv(dev);
215 lp->device = device; 215 lp->device = &pdev->dev;
216 SET_NETDEV_DEV(dev, device); 216 SET_NETDEV_DEV(dev, &pdev->dev);
217 SET_MODULE_OWNER(dev); 217 SET_MODULE_OWNER(dev);
218 218
219 netdev_boot_setup_check(dev); 219 netdev_boot_setup_check(dev);
@@ -264,9 +264,9 @@ MODULE_PARM_DESC(sonic_debug, "jazzsonic debug level (1-4)");
264 264
265#include "sonic.c" 265#include "sonic.c"
266 266
267static int __devexit jazz_sonic_device_remove (struct device *device) 267static int __devexit jazz_sonic_device_remove (struct platform_device *pdev)
268{ 268{
269 struct net_device *dev = device->driver_data; 269 struct net_device *dev = platform_get_drvdata(pdev);
270 struct sonic_local* lp = netdev_priv(dev); 270 struct sonic_local* lp = netdev_priv(dev);
271 271
272 unregister_netdev (dev); 272 unregister_netdev (dev);
@@ -278,24 +278,25 @@ static int __devexit jazz_sonic_device_remove (struct device *device)
278 return 0; 278 return 0;
279} 279}
280 280
281static struct device_driver jazz_sonic_driver = { 281static struct platform_driver jazz_sonic_driver = {
282 .name = jazz_sonic_string,
283 .bus = &platform_bus_type,
284 .probe = jazz_sonic_probe, 282 .probe = jazz_sonic_probe,
285 .remove = __devexit_p(jazz_sonic_device_remove), 283 .remove = __devexit_p(jazz_sonic_device_remove),
284 .driver = {
285 .name = jazz_sonic_string,
286 },
286}; 287};
287 288
288static int __init jazz_sonic_init_module(void) 289static int __init jazz_sonic_init_module(void)
289{ 290{
290 int err; 291 int err;
291 292
292 if ((err = driver_register(&jazz_sonic_driver))) { 293 if ((err = platform_driver_register(&jazz_sonic_driver))) {
293 printk(KERN_ERR "Driver registration failed\n"); 294 printk(KERN_ERR "Driver registration failed\n");
294 return err; 295 return err;
295 } 296 }
296 297
297 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0); 298 jazz_sonic_device = platform_device_alloc(jazz_sonic_string, 0);
298 if (!jazz_sonnic_device) 299 if (!jazz_sonic_device)
299 goto out_unregister; 300 goto out_unregister;
300 301
301 if (platform_device_add(jazz_sonic_device)) { 302 if (platform_device_add(jazz_sonic_device)) {
@@ -306,14 +307,14 @@ static int __init jazz_sonic_init_module(void)
306 return 0; 307 return 0;
307 308
308out_unregister: 309out_unregister:
309 driver_unregister(&jazz_sonic_driver); 310 platform_driver_unregister(&jazz_sonic_driver);
310 311
311 return -ENOMEM; 312 return -ENOMEM;
312} 313}
313 314
314static void __exit jazz_sonic_cleanup_module(void) 315static void __exit jazz_sonic_cleanup_module(void)
315{ 316{
316 driver_unregister(&jazz_sonic_driver); 317 platform_driver_unregister(&jazz_sonic_driver);
317 318
318 if (jazz_sonic_device) { 319 if (jazz_sonic_device) {
319 platform_device_unregister(jazz_sonic_device); 320 platform_device_unregister(jazz_sonic_device);
diff --git a/drivers/net/macsonic.c b/drivers/net/macsonic.c
index 9ef4592aca03..02d5c6822733 100644
--- a/drivers/net/macsonic.c
+++ b/drivers/net/macsonic.c
@@ -525,7 +525,7 @@ int __init mac_nubus_sonic_probe(struct net_device* dev)
525 return macsonic_init(dev); 525 return macsonic_init(dev);
526} 526}
527 527
528static int __init mac_sonic_probe(struct device *device) 528static int __init mac_sonic_probe(struct platform_device *device)
529{ 529{
530 struct net_device *dev; 530 struct net_device *dev;
531 struct sonic_local *lp; 531 struct sonic_local *lp;
@@ -537,8 +537,8 @@ static int __init mac_sonic_probe(struct device *device)
537 return -ENOMEM; 537 return -ENOMEM;
538 538
539 lp = netdev_priv(dev); 539 lp = netdev_priv(dev);
540 lp->device = device; 540 lp->device = &device->dev;
541 SET_NETDEV_DEV(dev, device); 541 SET_NETDEV_DEV(dev, &device->dev);
542 SET_MODULE_OWNER(dev); 542 SET_MODULE_OWNER(dev);
543 543
544 /* This will catch fatal stuff like -ENOMEM as well as success */ 544 /* This will catch fatal stuff like -ENOMEM as well as success */
@@ -579,9 +579,9 @@ MODULE_PARM_DESC(sonic_debug, "macsonic debug level (1-4)");
579 579
580#include "sonic.c" 580#include "sonic.c"
581 581
582static int __devexit mac_sonic_device_remove (struct device *device) 582static int __devexit mac_sonic_device_remove (struct platform_device *device)
583{ 583{
584 struct net_device *dev = device->driver_data; 584 struct net_device *dev = platform_get_drvdata(device);
585 struct sonic_local* lp = netdev_priv(dev); 585 struct sonic_local* lp = netdev_priv(dev);
586 586
587 unregister_netdev (dev); 587 unregister_netdev (dev);
@@ -592,18 +592,19 @@ static int __devexit mac_sonic_device_remove (struct device *device)
592 return 0; 592 return 0;
593} 593}
594 594
595static struct device_driver mac_sonic_driver = { 595static struct platform_driver mac_sonic_driver = {
596 .name = mac_sonic_string,
597 .bus = &platform_bus_type,
598 .probe = mac_sonic_probe, 596 .probe = mac_sonic_probe,
599 .remove = __devexit_p(mac_sonic_device_remove), 597 .remove = __devexit_p(mac_sonic_device_remove),
598 .driver = {
599 .name = mac_sonic_string,
600 },
600}; 601};
601 602
602static int __init mac_sonic_init_module(void) 603static int __init mac_sonic_init_module(void)
603{ 604{
604 int err; 605 int err;
605 606
606 if ((err = driver_register(&mac_sonic_driver))) { 607 if ((err = platform_driver_register(&mac_sonic_driver))) {
607 printk(KERN_ERR "Driver registration failed\n"); 608 printk(KERN_ERR "Driver registration failed\n");
608 return err; 609 return err;
609 } 610 }
@@ -628,7 +629,7 @@ out_unregister:
628 629
629static void __exit mac_sonic_cleanup_module(void) 630static void __exit mac_sonic_cleanup_module(void)
630{ 631{
631 driver_unregister(&mac_sonic_driver); 632 platform_driver_unregister(&mac_sonic_driver);
632 633
633 if (mac_sonic_device) { 634 if (mac_sonic_device) {
634 platform_device_unregister(mac_sonic_device); 635 platform_device_unregister(mac_sonic_device);
diff --git a/drivers/net/mipsnet.h b/drivers/net/mipsnet.h
index 878535953cb1..026c732024c9 100644
--- a/drivers/net/mipsnet.h
+++ b/drivers/net/mipsnet.h
@@ -1,28 +1,8 @@
1// 1/*
2// <COPYRIGHT CLASS="1B" YEAR="2005"> 2 * This file is subject to the terms and conditions of the GNU General Public
3// Unpublished work (c) MIPS Technologies, Inc. All rights reserved. 3 * License. See the file "COPYING" in the main directory of this archive
4// Unpublished rights reserved under the copyright laws of the U.S.A. and 4 * for more details.
5// other countries. 5 */
6//
7// PROPRIETARY / SECRET CONFIDENTIAL INFORMATION OF MIPS TECHNOLOGIES, INC.
8// FOR INTERNAL USE ONLY.
9//
10// Under no circumstances (contract or otherwise) may this information be
11// disclosed to, or copied, modified or used by anyone other than employees
12// or contractors of MIPS Technologies having a need to know.
13// </COPYRIGHT>
14//
15//++
16// File: MIPS_Net.h
17//
18// Description:
19// The definition of the emulated MIPSNET device's interface.
20//
21// Notes: This include file needs to work from a Linux device drivers.
22//
23//--
24//
25
26#ifndef __MIPSNET_H 6#ifndef __MIPSNET_H
27#define __MIPSNET_H 7#define __MIPSNET_H
28 8
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index 71f2c6705bc3..3cb9b3fe0cf1 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -1387,9 +1387,8 @@ static void mv643xx_netpoll(struct net_device *netdev)
1387 * Input : struct device * 1387 * Input : struct device *
1388 * Output : -ENOMEM if failed , 0 if success 1388 * Output : -ENOMEM if failed , 0 if success
1389 */ 1389 */
1390static int mv643xx_eth_probe(struct device *ddev) 1390static int mv643xx_eth_probe(struct platform_device *pdev)
1391{ 1391{
1392 struct platform_device *pdev = to_platform_device(ddev);
1393 struct mv643xx_eth_platform_data *pd; 1392 struct mv643xx_eth_platform_data *pd;
1394 int port_num = pdev->id; 1393 int port_num = pdev->id;
1395 struct mv643xx_private *mp; 1394 struct mv643xx_private *mp;
@@ -1402,7 +1401,7 @@ static int mv643xx_eth_probe(struct device *ddev)
1402 if (!dev) 1401 if (!dev)
1403 return -ENOMEM; 1402 return -ENOMEM;
1404 1403
1405 dev_set_drvdata(ddev, dev); 1404 platform_set_drvdata(pdev, dev);
1406 1405
1407 mp = netdev_priv(dev); 1406 mp = netdev_priv(dev);
1408 1407
@@ -1546,21 +1545,20 @@ out:
1546 return err; 1545 return err;
1547} 1546}
1548 1547
1549static int mv643xx_eth_remove(struct device *ddev) 1548static int mv643xx_eth_remove(struct platform_device *pdev)
1550{ 1549{
1551 struct net_device *dev = dev_get_drvdata(ddev); 1550 struct net_device *dev = platform_get_drvdata(pdev);
1552 1551
1553 unregister_netdev(dev); 1552 unregister_netdev(dev);
1554 flush_scheduled_work(); 1553 flush_scheduled_work();
1555 1554
1556 free_netdev(dev); 1555 free_netdev(dev);
1557 dev_set_drvdata(ddev, NULL); 1556 platform_set_drvdata(pdev, NULL);
1558 return 0; 1557 return 0;
1559} 1558}
1560 1559
1561static int mv643xx_eth_shared_probe(struct device *ddev) 1560static int mv643xx_eth_shared_probe(struct platform_device *pdev)
1562{ 1561{
1563 struct platform_device *pdev = to_platform_device(ddev);
1564 struct resource *res; 1562 struct resource *res;
1565 1563
1566 printk(KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n"); 1564 printk(KERN_NOTICE "MV-643xx 10/100/1000 Ethernet Driver\n");
@@ -1578,7 +1576,7 @@ static int mv643xx_eth_shared_probe(struct device *ddev)
1578 1576
1579} 1577}
1580 1578
1581static int mv643xx_eth_shared_remove(struct device *ddev) 1579static int mv643xx_eth_shared_remove(struct platform_device *pdev)
1582{ 1580{
1583 iounmap(mv643xx_eth_shared_base); 1581 iounmap(mv643xx_eth_shared_base);
1584 mv643xx_eth_shared_base = NULL; 1582 mv643xx_eth_shared_base = NULL;
@@ -1586,18 +1584,20 @@ static int mv643xx_eth_shared_remove(struct device *ddev)
1586 return 0; 1584 return 0;
1587} 1585}
1588 1586
1589static struct device_driver mv643xx_eth_driver = { 1587static struct platform_driver mv643xx_eth_driver = {
1590 .name = MV643XX_ETH_NAME,
1591 .bus = &platform_bus_type,
1592 .probe = mv643xx_eth_probe, 1588 .probe = mv643xx_eth_probe,
1593 .remove = mv643xx_eth_remove, 1589 .remove = mv643xx_eth_remove,
1590 .driver = {
1591 .name = MV643XX_ETH_NAME,
1592 },
1594}; 1593};
1595 1594
1596static struct device_driver mv643xx_eth_shared_driver = { 1595static struct platform_driver mv643xx_eth_shared_driver = {
1597 .name = MV643XX_ETH_SHARED_NAME,
1598 .bus = &platform_bus_type,
1599 .probe = mv643xx_eth_shared_probe, 1596 .probe = mv643xx_eth_shared_probe,
1600 .remove = mv643xx_eth_shared_remove, 1597 .remove = mv643xx_eth_shared_remove,
1598 .driver = {
1599 .name = MV643XX_ETH_SHARED_NAME,
1600 },
1601}; 1601};
1602 1602
1603/* 1603/*
@@ -1613,11 +1613,11 @@ static int __init mv643xx_init_module(void)
1613{ 1613{
1614 int rc; 1614 int rc;
1615 1615
1616 rc = driver_register(&mv643xx_eth_shared_driver); 1616 rc = platform_driver_register(&mv643xx_eth_shared_driver);
1617 if (!rc) { 1617 if (!rc) {
1618 rc = driver_register(&mv643xx_eth_driver); 1618 rc = platform_driver_register(&mv643xx_eth_driver);
1619 if (rc) 1619 if (rc)
1620 driver_unregister(&mv643xx_eth_shared_driver); 1620 platform_driver_unregister(&mv643xx_eth_shared_driver);
1621 } 1621 }
1622 return rc; 1622 return rc;
1623} 1623}
@@ -1633,8 +1633,8 @@ static int __init mv643xx_init_module(void)
1633 */ 1633 */
1634static void __exit mv643xx_cleanup_module(void) 1634static void __exit mv643xx_cleanup_module(void)
1635{ 1635{
1636 driver_unregister(&mv643xx_eth_driver); 1636 platform_driver_unregister(&mv643xx_eth_driver);
1637 driver_unregister(&mv643xx_eth_shared_driver); 1637 platform_driver_unregister(&mv643xx_eth_shared_driver);
1638} 1638}
1639 1639
1640module_init(mv643xx_init_module); 1640module_init(mv643xx_init_module);
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index 384a736a0d2f..356f50909222 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -131,10 +131,9 @@ typedef struct local_info_t {
131 u_short tx_queue_len; 131 u_short tx_queue_len;
132 cardtype_t cardtype; 132 cardtype_t cardtype;
133 u_short sent; 133 u_short sent;
134 u_char mc_filter[8];
135} local_info_t; 134} local_info_t;
136 135
137#define MC_FILTERBREAK 8 136#define MC_FILTERBREAK 64
138 137
139/*====================================================================*/ 138/*====================================================================*/
140/* 139/*
@@ -1005,15 +1004,8 @@ static void fjn_reset(struct net_device *dev)
1005 for (i = 0; i < 6; i++) 1004 for (i = 0; i < 6; i++)
1006 outb(dev->dev_addr[i], ioaddr + NODE_ID + i); 1005 outb(dev->dev_addr[i], ioaddr + NODE_ID + i);
1007 1006
1008 /* Switch to bank 1 */ 1007 /* (re)initialize the multicast table */
1009 if (lp->cardtype == MBH10302) 1008 set_rx_mode(dev);
1010 outb(BANK_1, ioaddr + CONFIG_1);
1011 else
1012 outb(BANK_1U, ioaddr + CONFIG_1);
1013
1014 /* set the multicast table to accept none. */
1015 for (i = 0; i < 8; i++)
1016 outb(0x00, ioaddr + MAR_ADR + i);
1017 1009
1018 /* Switch to bank 2 (runtime mode) */ 1010 /* Switch to bank 2 (runtime mode) */
1019 if (lp->cardtype == MBH10302) 1011 if (lp->cardtype == MBH10302)
@@ -1264,11 +1256,11 @@ static struct net_device_stats *fjn_get_stats(struct net_device *dev)
1264static void set_rx_mode(struct net_device *dev) 1256static void set_rx_mode(struct net_device *dev)
1265{ 1257{
1266 kio_addr_t ioaddr = dev->base_addr; 1258 kio_addr_t ioaddr = dev->base_addr;
1267 struct local_info_t *lp = netdev_priv(dev);
1268 u_char mc_filter[8]; /* Multicast hash filter */ 1259 u_char mc_filter[8]; /* Multicast hash filter */
1269 u_long flags; 1260 u_long flags;
1270 int i; 1261 int i;
1271 1262
1263 int saved_bank;
1272 int saved_config_0 = inb(ioaddr + CONFIG_0); 1264 int saved_config_0 = inb(ioaddr + CONFIG_0);
1273 1265
1274 local_irq_save(flags); 1266 local_irq_save(flags);
@@ -1306,15 +1298,13 @@ static void set_rx_mode(struct net_device *dev)
1306 outb(2, ioaddr + RX_MODE); /* Use normal mode. */ 1298 outb(2, ioaddr + RX_MODE); /* Use normal mode. */
1307 } 1299 }
1308 1300
1309 if (memcmp(mc_filter, lp->mc_filter, sizeof(mc_filter))) { 1301 /* Switch to bank 1 and set the multicast table. */
1310 int saved_bank = inb(ioaddr + CONFIG_1); 1302 saved_bank = inb(ioaddr + CONFIG_1);
1311 /* Switch to bank 1 and set the multicast table. */ 1303 outb(0xe4, ioaddr + CONFIG_1);
1312 outb(0xe4, ioaddr + CONFIG_1); 1304
1313 for (i = 0; i < 8; i++) 1305 for (i = 0; i < 8; i++)
1314 outb(mc_filter[i], ioaddr + MAR_ADR + i); 1306 outb(mc_filter[i], ioaddr + MAR_ADR + i);
1315 memcpy(lp->mc_filter, mc_filter, sizeof(mc_filter)); 1307 outb(saved_bank, ioaddr + CONFIG_1);
1316 outb(saved_bank, ioaddr + CONFIG_1);
1317 }
1318 1308
1319 outb(saved_config_0, ioaddr + CONFIG_0); 1309 outb(saved_config_0, ioaddr + CONFIG_0);
1320 1310
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/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/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/r8169.c b/drivers/net/r8169.c
index 159b56a56ef4..14a76f7cf900 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -1346,10 +1346,8 @@ rtl8169_init_board(struct pci_dev *pdev, struct net_device **dev_out,
1346 } else { 1346 } else {
1347 if (netif_msg_probe(tp)) { 1347 if (netif_msg_probe(tp)) {
1348 printk(KERN_ERR PFX 1348 printk(KERN_ERR PFX
1349 "Cannot find PowerManagement capability. " 1349 "PowerManagement capability not found.\n");
1350 "Aborting.\n");
1351 } 1350 }
1352 goto err_out_mwi;
1353 } 1351 }
1354 1352
1355 /* make sure PCI base addr 1 is MMIO */ 1353 /* make sure PCI base addr 1 is MMIO */
@@ -2516,7 +2514,7 @@ rtl8169_interrupt(int irq, void *dev_instance, struct pt_regs *regs)
2516 } while (boguscnt > 0); 2514 } while (boguscnt > 0);
2517 2515
2518 if (boguscnt <= 0) { 2516 if (boguscnt <= 0) {
2519 if (net_ratelimit() && netif_msg_intr(tp)) { 2517 if (netif_msg_intr(tp) && net_ratelimit() ) {
2520 printk(KERN_WARNING 2518 printk(KERN_WARNING
2521 "%s: Too much work at interrupt!\n", dev->name); 2519 "%s: Too much work at interrupt!\n", dev->name);
2522 } 2520 }
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index e57df8dfe6b4..669dd52c412a 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -3078,7 +3078,7 @@ int s2io_set_swapper(nic_t * sp)
3078 3078
3079static int wait_for_msix_trans(nic_t *nic, int i) 3079static int wait_for_msix_trans(nic_t *nic, int i)
3080{ 3080{
3081 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3081 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3082 u64 val64; 3082 u64 val64;
3083 int ret = 0, cnt = 0; 3083 int ret = 0, cnt = 0;
3084 3084
@@ -3099,7 +3099,7 @@ static int wait_for_msix_trans(nic_t *nic, int i)
3099 3099
3100void restore_xmsi_data(nic_t *nic) 3100void restore_xmsi_data(nic_t *nic)
3101{ 3101{
3102 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3102 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3103 u64 val64; 3103 u64 val64;
3104 int i; 3104 int i;
3105 3105
@@ -3117,7 +3117,7 @@ void restore_xmsi_data(nic_t *nic)
3117 3117
3118static void store_xmsi_data(nic_t *nic) 3118static void store_xmsi_data(nic_t *nic)
3119{ 3119{
3120 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3120 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3121 u64 val64, addr, data; 3121 u64 val64, addr, data;
3122 int i; 3122 int i;
3123 3123
@@ -3140,7 +3140,7 @@ static void store_xmsi_data(nic_t *nic)
3140 3140
3141int s2io_enable_msi(nic_t *nic) 3141int s2io_enable_msi(nic_t *nic)
3142{ 3142{
3143 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3143 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3144 u16 msi_ctrl, msg_val; 3144 u16 msi_ctrl, msg_val;
3145 struct config_param *config = &nic->config; 3145 struct config_param *config = &nic->config;
3146 struct net_device *dev = nic->dev; 3146 struct net_device *dev = nic->dev;
@@ -3190,7 +3190,7 @@ int s2io_enable_msi(nic_t *nic)
3190 3190
3191int s2io_enable_msi_x(nic_t *nic) 3191int s2io_enable_msi_x(nic_t *nic)
3192{ 3192{
3193 XENA_dev_config_t *bar0 = (XENA_dev_config_t *) nic->bar0; 3193 XENA_dev_config_t __iomem *bar0 = nic->bar0;
3194 u64 tx_mat, rx_mat; 3194 u64 tx_mat, rx_mat;
3195 u16 msi_control; /* Temp variable */ 3195 u16 msi_control; /* Temp variable */
3196 int ret, i, j, msix_indx = 1; 3196 int ret, i, j, msix_indx = 1;
diff --git a/drivers/net/saa9730.c b/drivers/net/saa9730.c
index 110e777f206e..b2acedbefa8f 100644
--- a/drivers/net/saa9730.c
+++ b/drivers/net/saa9730.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * Carsten Langgaard, carstenl@mips.com 2 * Copyright (C) 2000, 2005 MIPS Technologies, Inc. All rights reserved.
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. 3 * Authors: Carsten Langgaard <carstenl@mips.com>
4 * 4 * Maciej W. Rozycki <macro@mips.com>
5 * ######################################################################## 5 * Copyright (C) 2004 Ralf Baechle <ralf@linux-mips.org>
6 * 6 *
7 * This program is free software; you can distribute it and/or modify it 7 * This program is free software; you can distribute it and/or modify it
8 * under the terms of the GNU General Public License (Version 2) as 8 * under the terms of the GNU General Public License (Version 2) as
@@ -17,15 +17,13 @@
17 * with this program; if not, write to the Free Software Foundation, Inc., 17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 18 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
19 * 19 *
20 * ########################################################################
21 *
22 * SAA9730 ethernet driver. 20 * SAA9730 ethernet driver.
23 * 21 *
24 * Changes: 22 * Changes:
25 * Angelo Dell'Aera <buffer@antifork.org> : Conversion to the new PCI API (pci_driver). 23 * Angelo Dell'Aera <buffer@antifork.org> : Conversion to the new PCI API
26 * Conversion to spinlocks. 24 * (pci_driver).
27 * Error handling fixes. 25 * Conversion to spinlocks.
28 * 26 * Error handling fixes.
29 */ 27 */
30 28
31#include <linux/init.h> 29#include <linux/init.h>
@@ -36,8 +34,11 @@
36#include <linux/skbuff.h> 34#include <linux/skbuff.h>
37#include <linux/pci.h> 35#include <linux/pci.h>
38#include <linux/spinlock.h> 36#include <linux/spinlock.h>
37#include <linux/types.h>
39 38
40#include <asm/addrspace.h> 39#include <asm/addrspace.h>
40#include <asm/io.h>
41
41#include <asm/mips-boards/prom.h> 42#include <asm/mips-boards/prom.h>
42 43
43#include "saa9730.h" 44#include "saa9730.h"
@@ -51,8 +52,8 @@ int lan_saa9730_debug;
51#define DRV_MODULE_NAME "saa9730" 52#define DRV_MODULE_NAME "saa9730"
52 53
53static struct pci_device_id saa9730_pci_tbl[] = { 54static struct pci_device_id saa9730_pci_tbl[] = {
54 { PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA9370, 55 { PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA9730,
55 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 56 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
56 { 0, } 57 { 0, }
57}; 58};
58 59
@@ -61,50 +62,48 @@ MODULE_DEVICE_TABLE(pci, saa9730_pci_tbl);
61/* Non-zero only if the current card is a PCI with BIOS-set IRQ. */ 62/* Non-zero only if the current card is a PCI with BIOS-set IRQ. */
62static unsigned int pci_irq_line; 63static unsigned int pci_irq_line;
63 64
64#define INL(a) inl((unsigned long)a)
65#define OUTL(x,a) outl(x,(unsigned long)a)
66
67static void evm_saa9730_enable_lan_int(struct lan_saa9730_private *lp) 65static void evm_saa9730_enable_lan_int(struct lan_saa9730_private *lp)
68{ 66{
69 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT, 67 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
70 &lp->evm_saa9730_regs->InterruptBlock1); 68 &lp->evm_saa9730_regs->InterruptBlock1);
71 OUTL(INL(&lp->evm_saa9730_regs->InterruptStatus1) | EVM_LAN_INT, 69 outl(readl(&lp->evm_saa9730_regs->InterruptStatus1) | EVM_LAN_INT,
72 &lp->evm_saa9730_regs->InterruptStatus1); 70 &lp->evm_saa9730_regs->InterruptStatus1);
73 OUTL(INL(&lp->evm_saa9730_regs->InterruptEnable1) | EVM_LAN_INT | 71 outl(readl(&lp->evm_saa9730_regs->InterruptEnable1) | EVM_LAN_INT |
74 EVM_MASTER_EN, &lp->evm_saa9730_regs->InterruptEnable1); 72 EVM_MASTER_EN, &lp->evm_saa9730_regs->InterruptEnable1);
75} 73}
74
76static void evm_saa9730_disable_lan_int(struct lan_saa9730_private *lp) 75static void evm_saa9730_disable_lan_int(struct lan_saa9730_private *lp)
77{ 76{
78 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT, 77 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
79 &lp->evm_saa9730_regs->InterruptBlock1); 78 &lp->evm_saa9730_regs->InterruptBlock1);
80 OUTL(INL(&lp->evm_saa9730_regs->InterruptEnable1) & ~EVM_LAN_INT, 79 outl(readl(&lp->evm_saa9730_regs->InterruptEnable1) & ~EVM_LAN_INT,
81 &lp->evm_saa9730_regs->InterruptEnable1); 80 &lp->evm_saa9730_regs->InterruptEnable1);
82} 81}
83 82
84static void evm_saa9730_clear_lan_int(struct lan_saa9730_private *lp) 83static void evm_saa9730_clear_lan_int(struct lan_saa9730_private *lp)
85{ 84{
86 OUTL(EVM_LAN_INT, &lp->evm_saa9730_regs->InterruptStatus1); 85 outl(EVM_LAN_INT, &lp->evm_saa9730_regs->InterruptStatus1);
87} 86}
88 87
89static void evm_saa9730_block_lan_int(struct lan_saa9730_private *lp) 88static void evm_saa9730_block_lan_int(struct lan_saa9730_private *lp)
90{ 89{
91 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT, 90 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) & ~EVM_LAN_INT,
92 &lp->evm_saa9730_regs->InterruptBlock1); 91 &lp->evm_saa9730_regs->InterruptBlock1);
93} 92}
94 93
95static void evm_saa9730_unblock_lan_int(struct lan_saa9730_private *lp) 94static void evm_saa9730_unblock_lan_int(struct lan_saa9730_private *lp)
96{ 95{
97 OUTL(INL(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT, 96 outl(readl(&lp->evm_saa9730_regs->InterruptBlock1) | EVM_LAN_INT,
98 &lp->evm_saa9730_regs->InterruptBlock1); 97 &lp->evm_saa9730_regs->InterruptBlock1);
99} 98}
100 99
101static void show_saa9730_regs(struct lan_saa9730_private *lp) 100static void __attribute_used__ show_saa9730_regs(struct lan_saa9730_private *lp)
102{ 101{
103 int i, j; 102 int i, j;
104 printk("TxmBufferA = %x\n", lp->TxmBuffer[0][0]); 103 printk("TxmBufferA = %p\n", lp->TxmBuffer[0][0]);
105 printk("TxmBufferB = %x\n", lp->TxmBuffer[1][0]); 104 printk("TxmBufferB = %p\n", lp->TxmBuffer[1][0]);
106 printk("RcvBufferA = %x\n", lp->RcvBuffer[0][0]); 105 printk("RcvBufferA = %p\n", lp->RcvBuffer[0][0]);
107 printk("RcvBufferB = %x\n", lp->RcvBuffer[1][0]); 106 printk("RcvBufferB = %p\n", lp->RcvBuffer[1][0]);
108 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) { 107 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {
109 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) { 108 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) {
110 printk("TxmBuffer[%d][%d] = %x\n", i, j, 109 printk("TxmBuffer[%d][%d] = %x\n", i, j,
@@ -120,13 +119,13 @@ static void show_saa9730_regs(struct lan_saa9730_private *lp)
120 } 119 }
121 } 120 }
122 printk("lp->evm_saa9730_regs->InterruptBlock1 = %x\n", 121 printk("lp->evm_saa9730_regs->InterruptBlock1 = %x\n",
123 INL(&lp->evm_saa9730_regs->InterruptBlock1)); 122 readl(&lp->evm_saa9730_regs->InterruptBlock1));
124 printk("lp->evm_saa9730_regs->InterruptStatus1 = %x\n", 123 printk("lp->evm_saa9730_regs->InterruptStatus1 = %x\n",
125 INL(&lp->evm_saa9730_regs->InterruptStatus1)); 124 readl(&lp->evm_saa9730_regs->InterruptStatus1));
126 printk("lp->evm_saa9730_regs->InterruptEnable1 = %x\n", 125 printk("lp->evm_saa9730_regs->InterruptEnable1 = %x\n",
127 INL(&lp->evm_saa9730_regs->InterruptEnable1)); 126 readl(&lp->evm_saa9730_regs->InterruptEnable1));
128 printk("lp->lan_saa9730_regs->Ok2Use = %x\n", 127 printk("lp->lan_saa9730_regs->Ok2Use = %x\n",
129 INL(&lp->lan_saa9730_regs->Ok2Use)); 128 readl(&lp->lan_saa9730_regs->Ok2Use));
130 printk("lp->NextTxmBufferIndex = %x\n", lp->NextTxmBufferIndex); 129 printk("lp->NextTxmBufferIndex = %x\n", lp->NextTxmBufferIndex);
131 printk("lp->NextTxmPacketIndex = %x\n", lp->NextTxmPacketIndex); 130 printk("lp->NextTxmPacketIndex = %x\n", lp->NextTxmPacketIndex);
132 printk("lp->PendingTxmBufferIndex = %x\n", 131 printk("lp->PendingTxmBufferIndex = %x\n",
@@ -134,23 +133,23 @@ static void show_saa9730_regs(struct lan_saa9730_private *lp)
134 printk("lp->PendingTxmPacketIndex = %x\n", 133 printk("lp->PendingTxmPacketIndex = %x\n",
135 lp->PendingTxmPacketIndex); 134 lp->PendingTxmPacketIndex);
136 printk("lp->lan_saa9730_regs->LanDmaCtl = %x\n", 135 printk("lp->lan_saa9730_regs->LanDmaCtl = %x\n",
137 INL(&lp->lan_saa9730_regs->LanDmaCtl)); 136 readl(&lp->lan_saa9730_regs->LanDmaCtl));
138 printk("lp->lan_saa9730_regs->DmaStatus = %x\n", 137 printk("lp->lan_saa9730_regs->DmaStatus = %x\n",
139 INL(&lp->lan_saa9730_regs->DmaStatus)); 138 readl(&lp->lan_saa9730_regs->DmaStatus));
140 printk("lp->lan_saa9730_regs->CamCtl = %x\n", 139 printk("lp->lan_saa9730_regs->CamCtl = %x\n",
141 INL(&lp->lan_saa9730_regs->CamCtl)); 140 readl(&lp->lan_saa9730_regs->CamCtl));
142 printk("lp->lan_saa9730_regs->TxCtl = %x\n", 141 printk("lp->lan_saa9730_regs->TxCtl = %x\n",
143 INL(&lp->lan_saa9730_regs->TxCtl)); 142 readl(&lp->lan_saa9730_regs->TxCtl));
144 printk("lp->lan_saa9730_regs->TxStatus = %x\n", 143 printk("lp->lan_saa9730_regs->TxStatus = %x\n",
145 INL(&lp->lan_saa9730_regs->TxStatus)); 144 readl(&lp->lan_saa9730_regs->TxStatus));
146 printk("lp->lan_saa9730_regs->RxCtl = %x\n", 145 printk("lp->lan_saa9730_regs->RxCtl = %x\n",
147 INL(&lp->lan_saa9730_regs->RxCtl)); 146 readl(&lp->lan_saa9730_regs->RxCtl));
148 printk("lp->lan_saa9730_regs->RxStatus = %x\n", 147 printk("lp->lan_saa9730_regs->RxStatus = %x\n",
149 INL(&lp->lan_saa9730_regs->RxStatus)); 148 readl(&lp->lan_saa9730_regs->RxStatus));
150 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) { 149 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) {
151 OUTL(i, &lp->lan_saa9730_regs->CamAddress); 150 outl(i, &lp->lan_saa9730_regs->CamAddress);
152 printk("lp->lan_saa9730_regs->CamData = %x\n", 151 printk("lp->lan_saa9730_regs->CamData = %x\n",
153 INL(&lp->lan_saa9730_regs->CamData)); 152 readl(&lp->lan_saa9730_regs->CamData));
154 } 153 }
155 printk("lp->stats.tx_packets = %lx\n", lp->stats.tx_packets); 154 printk("lp->stats.tx_packets = %lx\n", lp->stats.tx_packets);
156 printk("lp->stats.tx_errors = %lx\n", lp->stats.tx_errors); 155 printk("lp->stats.tx_errors = %lx\n", lp->stats.tx_errors);
@@ -178,17 +177,17 @@ static void show_saa9730_regs(struct lan_saa9730_private *lp)
178 lp->stats.rx_length_errors); 177 lp->stats.rx_length_errors);
179 178
180 printk("lp->lan_saa9730_regs->DebugPCIMasterAddr = %x\n", 179 printk("lp->lan_saa9730_regs->DebugPCIMasterAddr = %x\n",
181 INL(&lp->lan_saa9730_regs->DebugPCIMasterAddr)); 180 readl(&lp->lan_saa9730_regs->DebugPCIMasterAddr));
182 printk("lp->lan_saa9730_regs->DebugLanTxStateMachine = %x\n", 181 printk("lp->lan_saa9730_regs->DebugLanTxStateMachine = %x\n",
183 INL(&lp->lan_saa9730_regs->DebugLanTxStateMachine)); 182 readl(&lp->lan_saa9730_regs->DebugLanTxStateMachine));
184 printk("lp->lan_saa9730_regs->DebugLanRxStateMachine = %x\n", 183 printk("lp->lan_saa9730_regs->DebugLanRxStateMachine = %x\n",
185 INL(&lp->lan_saa9730_regs->DebugLanRxStateMachine)); 184 readl(&lp->lan_saa9730_regs->DebugLanRxStateMachine));
186 printk("lp->lan_saa9730_regs->DebugLanTxFifoPointers = %x\n", 185 printk("lp->lan_saa9730_regs->DebugLanTxFifoPointers = %x\n",
187 INL(&lp->lan_saa9730_regs->DebugLanTxFifoPointers)); 186 readl(&lp->lan_saa9730_regs->DebugLanTxFifoPointers));
188 printk("lp->lan_saa9730_regs->DebugLanRxFifoPointers = %x\n", 187 printk("lp->lan_saa9730_regs->DebugLanRxFifoPointers = %x\n",
189 INL(&lp->lan_saa9730_regs->DebugLanRxFifoPointers)); 188 readl(&lp->lan_saa9730_regs->DebugLanRxFifoPointers));
190 printk("lp->lan_saa9730_regs->DebugLanCtlStateMachine = %x\n", 189 printk("lp->lan_saa9730_regs->DebugLanCtlStateMachine = %x\n",
191 INL(&lp->lan_saa9730_regs->DebugLanCtlStateMachine)); 190 readl(&lp->lan_saa9730_regs->DebugLanCtlStateMachine));
192} 191}
193 192
194static void lan_saa9730_buffer_init(struct lan_saa9730_private *lp) 193static void lan_saa9730_buffer_init(struct lan_saa9730_private *lp)
@@ -214,98 +213,108 @@ static void lan_saa9730_buffer_init(struct lan_saa9730_private *lp)
214 } 213 }
215} 214}
216 215
217static int lan_saa9730_allocate_buffers(struct lan_saa9730_private *lp) 216static void lan_saa9730_free_buffers(struct pci_dev *pdev,
217 struct lan_saa9730_private *lp)
218{ 218{
219 unsigned int mem_size; 219 pci_free_consistent(pdev, lp->buffer_size, lp->buffer_start,
220 void *Pa; 220 lp->dma_addr);
221 unsigned int i, j, RcvBufferSize, TxmBufferSize; 221}
222 unsigned int buffer_start;
223 222
224 /* 223static int lan_saa9730_allocate_buffers(struct pci_dev *pdev,
225 * Allocate all RX and TX packets in one chunk. 224 struct lan_saa9730_private *lp)
226 * The Rx and Tx packets must be PACKET_SIZE aligned. 225{
227 */ 226 void *Pa;
228 mem_size = ((LAN_SAA9730_RCV_Q_SIZE + LAN_SAA9730_TXM_Q_SIZE) * 227 unsigned int i, j, rxoffset, txoffset;
229 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_BUFFERS) + 228 int ret;
230 LAN_SAA9730_PACKET_SIZE;
231 buffer_start =
232 (unsigned int) kmalloc(mem_size, GFP_DMA | GFP_KERNEL);
233
234 if (!buffer_start)
235 return -ENOMEM;
236
237 /*
238 * Set DMA buffer to kseg1 (uncached).
239 * Make sure to flush before using it uncached.
240 */
241 Pa = (void *) KSEG1ADDR((buffer_start + LAN_SAA9730_PACKET_SIZE) &
242 ~(LAN_SAA9730_PACKET_SIZE - 1));
243 dma_cache_wback_inv((unsigned long) Pa, mem_size);
244 229
245 /* Initialize buffer space */ 230 /* Initialize buffer space */
246 RcvBufferSize = LAN_SAA9730_PACKET_SIZE;
247 TxmBufferSize = LAN_SAA9730_PACKET_SIZE;
248 lp->DmaRcvPackets = LAN_SAA9730_RCV_Q_SIZE; 231 lp->DmaRcvPackets = LAN_SAA9730_RCV_Q_SIZE;
249 lp->DmaTxmPackets = LAN_SAA9730_TXM_Q_SIZE; 232 lp->DmaTxmPackets = LAN_SAA9730_TXM_Q_SIZE;
250 233
234 /* Initialize Rx Buffer Index */
235 lp->NextRcvPacketIndex = 0;
236 lp->NextRcvBufferIndex = 0;
237
238 /* Set current buffer index & next available packet index */
239 lp->NextTxmPacketIndex = 0;
240 lp->NextTxmBufferIndex = 0;
241 lp->PendingTxmPacketIndex = 0;
242 lp->PendingTxmBufferIndex = 0;
243
244 /*
245 * Allocate all RX and TX packets in one chunk.
246 * The Rx and Tx packets must be PACKET_SIZE aligned.
247 */
248 lp->buffer_size = ((LAN_SAA9730_RCV_Q_SIZE + LAN_SAA9730_TXM_Q_SIZE) *
249 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_BUFFERS) +
250 LAN_SAA9730_PACKET_SIZE;
251 lp->buffer_start = pci_alloc_consistent(pdev, lp->buffer_size,
252 &lp->dma_addr);
253 if (!lp->buffer_start) {
254 ret = -ENOMEM;
255 goto out;
256 }
257
258 Pa = (void *)ALIGN((unsigned long)lp->buffer_start,
259 LAN_SAA9730_PACKET_SIZE);
260
261 rxoffset = Pa - lp->buffer_start;
262
251 /* Init RX buffers */ 263 /* Init RX buffers */
252 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) { 264 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {
253 for (j = 0; j < LAN_SAA9730_RCV_Q_SIZE; j++) { 265 for (j = 0; j < LAN_SAA9730_RCV_Q_SIZE; j++) {
254 *(unsigned int *) Pa = 266 *(unsigned int *) Pa =
255 cpu_to_le32(RXSF_READY << 267 cpu_to_le32(RXSF_READY <<
256 RX_STAT_CTL_OWNER_SHF); 268 RX_STAT_CTL_OWNER_SHF);
257 lp->RcvBuffer[i][j] = (unsigned int) Pa; 269 lp->RcvBuffer[i][j] = Pa;
258 Pa += RcvBufferSize; 270 Pa += LAN_SAA9730_PACKET_SIZE;
259 } 271 }
260 } 272 }
261 273
274 txoffset = Pa - lp->buffer_start;
275
262 /* Init TX buffers */ 276 /* Init TX buffers */
263 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) { 277 for (i = 0; i < LAN_SAA9730_BUFFERS; i++) {
264 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) { 278 for (j = 0; j < LAN_SAA9730_TXM_Q_SIZE; j++) {
265 *(unsigned int *) Pa = 279 *(unsigned int *) Pa =
266 cpu_to_le32(TXSF_EMPTY << 280 cpu_to_le32(TXSF_EMPTY <<
267 TX_STAT_CTL_OWNER_SHF); 281 TX_STAT_CTL_OWNER_SHF);
268 lp->TxmBuffer[i][j] = (unsigned int) Pa; 282 lp->TxmBuffer[i][j] = Pa;
269 Pa += TxmBufferSize; 283 Pa += LAN_SAA9730_PACKET_SIZE;
270 } 284 }
271 } 285 }
272 286
273 /* 287 /*
274 * Set rx buffer A and rx buffer B to point to the first two buffer 288 * Set rx buffer A and rx buffer B to point to the first two buffer
275 * spaces. 289 * spaces.
276 */ 290 */
277 OUTL(PHYSADDR(lp->RcvBuffer[0][0]), 291 outl(lp->dma_addr + rxoffset,
278 &lp->lan_saa9730_regs->RxBuffA); 292 &lp->lan_saa9730_regs->RxBuffA);
279 OUTL(PHYSADDR(lp->RcvBuffer[1][0]), 293 outl(lp->dma_addr + rxoffset +
294 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_RCV_Q_SIZE,
280 &lp->lan_saa9730_regs->RxBuffB); 295 &lp->lan_saa9730_regs->RxBuffB);
281 296
282 /* Initialize Buffer Index */ 297 /*
283 lp->NextRcvPacketIndex = 0;
284 lp->NextRcvToUseIsA = 1;
285
286 /* Set current buffer index & next availble packet index */
287 lp->NextTxmPacketIndex = 0;
288 lp->NextTxmBufferIndex = 0;
289 lp->PendingTxmPacketIndex = 0;
290 lp->PendingTxmBufferIndex = 0;
291
292 /*
293 * Set txm_buf_a and txm_buf_b to point to the first two buffer 298 * Set txm_buf_a and txm_buf_b to point to the first two buffer
294 * space 299 * space
295 */ 300 */
296 OUTL(PHYSADDR(lp->TxmBuffer[0][0]), 301 outl(lp->dma_addr + txoffset,
297 &lp->lan_saa9730_regs->TxBuffA); 302 &lp->lan_saa9730_regs->TxBuffA);
298 OUTL(PHYSADDR(lp->TxmBuffer[1][0]), 303 outl(lp->dma_addr + txoffset +
304 LAN_SAA9730_PACKET_SIZE * LAN_SAA9730_TXM_Q_SIZE,
299 &lp->lan_saa9730_regs->TxBuffB); 305 &lp->lan_saa9730_regs->TxBuffB);
300 306
301 /* Set packet number */ 307 /* Set packet number */
302 OUTL((lp->DmaRcvPackets << PK_COUNT_RX_A_SHF) | 308 outl((lp->DmaRcvPackets << PK_COUNT_RX_A_SHF) |
303 (lp->DmaRcvPackets << PK_COUNT_RX_B_SHF) | 309 (lp->DmaRcvPackets << PK_COUNT_RX_B_SHF) |
304 (lp->DmaTxmPackets << PK_COUNT_TX_A_SHF) | 310 (lp->DmaTxmPackets << PK_COUNT_TX_A_SHF) |
305 (lp->DmaTxmPackets << PK_COUNT_TX_B_SHF), 311 (lp->DmaTxmPackets << PK_COUNT_TX_B_SHF),
306 &lp->lan_saa9730_regs->PacketCount); 312 &lp->lan_saa9730_regs->PacketCount);
307 313
308 return 0; 314 return 0;
315
316out:
317 return ret;
309} 318}
310 319
311static int lan_saa9730_cam_load(struct lan_saa9730_private *lp) 320static int lan_saa9730_cam_load(struct lan_saa9730_private *lp)
@@ -317,8 +326,8 @@ static int lan_saa9730_cam_load(struct lan_saa9730_private *lp)
317 326
318 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) { 327 for (i = 0; i < LAN_SAA9730_CAM_DWORDS; i++) {
319 /* First set address to where data is written */ 328 /* First set address to where data is written */
320 OUTL(i, &lp->lan_saa9730_regs->CamAddress); 329 outl(i, &lp->lan_saa9730_regs->CamAddress);
321 OUTL((NetworkAddress[0] << 24) | (NetworkAddress[1] << 16) 330 outl((NetworkAddress[0] << 24) | (NetworkAddress[1] << 16)
322 | (NetworkAddress[2] << 8) | NetworkAddress[3], 331 | (NetworkAddress[2] << 8) | NetworkAddress[3],
323 &lp->lan_saa9730_regs->CamData); 332 &lp->lan_saa9730_regs->CamData);
324 NetworkAddress += 4; 333 NetworkAddress += 4;
@@ -328,8 +337,7 @@ static int lan_saa9730_cam_load(struct lan_saa9730_private *lp)
328 337
329static int lan_saa9730_cam_init(struct net_device *dev) 338static int lan_saa9730_cam_init(struct net_device *dev)
330{ 339{
331 struct lan_saa9730_private *lp = 340 struct lan_saa9730_private *lp = netdev_priv(dev);
332 (struct lan_saa9730_private *) dev->priv;
333 unsigned int i; 341 unsigned int i;
334 342
335 /* Copy MAC-address into all entries. */ 343 /* Copy MAC-address into all entries. */
@@ -347,7 +355,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
347 355
348 /* Check link status, spin here till station is not busy. */ 356 /* Check link status, spin here till station is not busy. */
349 i = 0; 357 i = 0;
350 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) { 358 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) {
351 i++; 359 i++;
352 if (i > 100) { 360 if (i > 100) {
353 printk("Error: lan_saa9730_mii_init: timeout\n"); 361 printk("Error: lan_saa9730_mii_init: timeout\n");
@@ -357,12 +365,12 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
357 } 365 }
358 366
359 /* Now set the control and address register. */ 367 /* Now set the control and address register. */
360 OUTL(MD_CA_BUSY | PHY_STATUS | PHY_ADDRESS << MD_CA_PHY_SHF, 368 outl(MD_CA_BUSY | PHY_STATUS | PHY_ADDRESS << MD_CA_PHY_SHF,
361 &lp->lan_saa9730_regs->StationMgmtCtl); 369 &lp->lan_saa9730_regs->StationMgmtCtl);
362 370
363 /* check link status, spin here till station is not busy */ 371 /* check link status, spin here till station is not busy */
364 i = 0; 372 i = 0;
365 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) { 373 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) & MD_CA_BUSY) {
366 i++; 374 i++;
367 if (i > 100) { 375 if (i > 100) {
368 printk("Error: lan_saa9730_mii_init: timeout\n"); 376 printk("Error: lan_saa9730_mii_init: timeout\n");
@@ -375,7 +383,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
375 mdelay(1); 383 mdelay(1);
376 384
377 /* Check the link status. */ 385 /* Check the link status. */
378 if (INL(&lp->lan_saa9730_regs->StationMgmtData) & 386 if (readl(&lp->lan_saa9730_regs->StationMgmtData) &
379 PHY_STATUS_LINK_UP) { 387 PHY_STATUS_LINK_UP) {
380 /* Link is up. */ 388 /* Link is up. */
381 return 0; 389 return 0;
@@ -383,14 +391,14 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
383 /* Link is down, reset the PHY first. */ 391 /* Link is down, reset the PHY first. */
384 392
385 /* set PHY address = 'CONTROL' */ 393 /* set PHY address = 'CONTROL' */
386 OUTL(PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR | PHY_CONTROL, 394 outl(PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR | PHY_CONTROL,
387 &lp->lan_saa9730_regs->StationMgmtCtl); 395 &lp->lan_saa9730_regs->StationMgmtCtl);
388 396
389 /* Wait for 1 ms. */ 397 /* Wait for 1 ms. */
390 mdelay(1); 398 mdelay(1);
391 399
392 /* set 'CONTROL' = force reset and renegotiate */ 400 /* set 'CONTROL' = force reset and renegotiate */
393 OUTL(PHY_CONTROL_RESET | PHY_CONTROL_AUTO_NEG | 401 outl(PHY_CONTROL_RESET | PHY_CONTROL_AUTO_NEG |
394 PHY_CONTROL_RESTART_AUTO_NEG, 402 PHY_CONTROL_RESTART_AUTO_NEG,
395 &lp->lan_saa9730_regs->StationMgmtData); 403 &lp->lan_saa9730_regs->StationMgmtData);
396 404
@@ -398,12 +406,12 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
398 mdelay(50); 406 mdelay(50);
399 407
400 /* set 'BUSY' to start operation */ 408 /* set 'BUSY' to start operation */
401 OUTL(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR | 409 outl(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF | MD_CA_WR |
402 PHY_CONTROL, &lp->lan_saa9730_regs->StationMgmtCtl); 410 PHY_CONTROL, &lp->lan_saa9730_regs->StationMgmtCtl);
403 411
404 /* await completion */ 412 /* await completion */
405 i = 0; 413 i = 0;
406 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & 414 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) &
407 MD_CA_BUSY) { 415 MD_CA_BUSY) {
408 i++; 416 i++;
409 if (i > 100) { 417 if (i > 100) {
@@ -419,13 +427,13 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
419 427
420 for (l = 0; l < 2; l++) { 428 for (l = 0; l < 2; l++) {
421 /* set PHY address = 'STATUS' */ 429 /* set PHY address = 'STATUS' */
422 OUTL(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF | 430 outl(MD_CA_BUSY | PHY_ADDRESS << MD_CA_PHY_SHF |
423 PHY_STATUS, 431 PHY_STATUS,
424 &lp->lan_saa9730_regs->StationMgmtCtl); 432 &lp->lan_saa9730_regs->StationMgmtCtl);
425 433
426 /* await completion */ 434 /* await completion */
427 i = 0; 435 i = 0;
428 while (INL(&lp->lan_saa9730_regs->StationMgmtCtl) & 436 while (readl(&lp->lan_saa9730_regs->StationMgmtCtl) &
429 MD_CA_BUSY) { 437 MD_CA_BUSY) {
430 i++; 438 i++;
431 if (i > 100) { 439 if (i > 100) {
@@ -440,7 +448,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
440 mdelay(3000); 448 mdelay(3000);
441 449
442 /* check the link status */ 450 /* check the link status */
443 if (INL(&lp->lan_saa9730_regs->StationMgmtData) & 451 if (readl(&lp->lan_saa9730_regs->StationMgmtData) &
444 PHY_STATUS_LINK_UP) { 452 PHY_STATUS_LINK_UP) {
445 /* link is up */ 453 /* link is up */
446 break; 454 break;
@@ -454,7 +462,7 @@ static int lan_saa9730_mii_init(struct lan_saa9730_private *lp)
454static int lan_saa9730_control_init(struct lan_saa9730_private *lp) 462static int lan_saa9730_control_init(struct lan_saa9730_private *lp)
455{ 463{
456 /* Initialize DMA control register. */ 464 /* Initialize DMA control register. */
457 OUTL((LANMB_ANY << DMA_CTL_MAX_XFER_SHF) | 465 outl((LANMB_ANY << DMA_CTL_MAX_XFER_SHF) |
458 (LANEND_LITTLE << DMA_CTL_ENDIAN_SHF) | 466 (LANEND_LITTLE << DMA_CTL_ENDIAN_SHF) |
459 (LAN_SAA9730_RCV_Q_INT_THRESHOLD << DMA_CTL_RX_INT_COUNT_SHF) 467 (LAN_SAA9730_RCV_Q_INT_THRESHOLD << DMA_CTL_RX_INT_COUNT_SHF)
460 | DMA_CTL_RX_INT_TO_EN | DMA_CTL_RX_INT_EN | 468 | DMA_CTL_RX_INT_TO_EN | DMA_CTL_RX_INT_EN |
@@ -462,27 +470,27 @@ static int lan_saa9730_control_init(struct lan_saa9730_private *lp)
462 &lp->lan_saa9730_regs->LanDmaCtl); 470 &lp->lan_saa9730_regs->LanDmaCtl);
463 471
464 /* Initial MAC control register. */ 472 /* Initial MAC control register. */
465 OUTL((MACCM_MII << MAC_CONTROL_CONN_SHF) | MAC_CONTROL_FULL_DUP, 473 outl((MACCM_MII << MAC_CONTROL_CONN_SHF) | MAC_CONTROL_FULL_DUP,
466 &lp->lan_saa9730_regs->MacCtl); 474 &lp->lan_saa9730_regs->MacCtl);
467 475
468 /* Initialize CAM control register. */ 476 /* Initialize CAM control register. */
469 OUTL(CAM_CONTROL_COMP_EN | CAM_CONTROL_BROAD_ACC, 477 outl(CAM_CONTROL_COMP_EN | CAM_CONTROL_BROAD_ACC,
470 &lp->lan_saa9730_regs->CamCtl); 478 &lp->lan_saa9730_regs->CamCtl);
471 479
472 /* 480 /*
473 * Initialize CAM enable register, only turn on first entry, should 481 * Initialize CAM enable register, only turn on first entry, should
474 * contain own addr. 482 * contain own addr.
475 */ 483 */
476 OUTL(0x0001, &lp->lan_saa9730_regs->CamEnable); 484 outl(0x0001, &lp->lan_saa9730_regs->CamEnable);
477 485
478 /* Initialize Tx control register */ 486 /* Initialize Tx control register */
479 OUTL(TX_CTL_EN_COMP, &lp->lan_saa9730_regs->TxCtl); 487 outl(TX_CTL_EN_COMP, &lp->lan_saa9730_regs->TxCtl);
480 488
481 /* Initialize Rcv control register */ 489 /* Initialize Rcv control register */
482 OUTL(RX_CTL_STRIP_CRC, &lp->lan_saa9730_regs->RxCtl); 490 outl(RX_CTL_STRIP_CRC, &lp->lan_saa9730_regs->RxCtl);
483 491
484 /* Reset DMA engine */ 492 /* Reset DMA engine */
485 OUTL(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest); 493 outl(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest);
486 494
487 return 0; 495 return 0;
488} 496}
@@ -492,21 +500,21 @@ static int lan_saa9730_stop(struct lan_saa9730_private *lp)
492 int i; 500 int i;
493 501
494 /* Stop DMA first */ 502 /* Stop DMA first */
495 OUTL(INL(&lp->lan_saa9730_regs->LanDmaCtl) & 503 outl(readl(&lp->lan_saa9730_regs->LanDmaCtl) &
496 ~(DMA_CTL_EN_TX_DMA | DMA_CTL_EN_RX_DMA), 504 ~(DMA_CTL_EN_TX_DMA | DMA_CTL_EN_RX_DMA),
497 &lp->lan_saa9730_regs->LanDmaCtl); 505 &lp->lan_saa9730_regs->LanDmaCtl);
498 506
499 /* Set the SW Reset bits in DMA and MAC control registers */ 507 /* Set the SW Reset bits in DMA and MAC control registers */
500 OUTL(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest); 508 outl(DMA_TEST_SW_RESET, &lp->lan_saa9730_regs->DmaTest);
501 OUTL(INL(&lp->lan_saa9730_regs->MacCtl) | MAC_CONTROL_RESET, 509 outl(readl(&lp->lan_saa9730_regs->MacCtl) | MAC_CONTROL_RESET,
502 &lp->lan_saa9730_regs->MacCtl); 510 &lp->lan_saa9730_regs->MacCtl);
503 511
504 /* 512 /*
505 * Wait for MAC reset to have finished. The reset bit is auto cleared 513 * Wait for MAC reset to have finished. The reset bit is auto cleared
506 * when the reset is done. 514 * when the reset is done.
507 */ 515 */
508 i = 0; 516 i = 0;
509 while (INL(&lp->lan_saa9730_regs->MacCtl) & MAC_CONTROL_RESET) { 517 while (readl(&lp->lan_saa9730_regs->MacCtl) & MAC_CONTROL_RESET) {
510 i++; 518 i++;
511 if (i > 100) { 519 if (i > 100) {
512 printk 520 printk
@@ -524,7 +532,7 @@ static int lan_saa9730_dma_init(struct lan_saa9730_private *lp)
524 /* Stop lan controller. */ 532 /* Stop lan controller. */
525 lan_saa9730_stop(lp); 533 lan_saa9730_stop(lp);
526 534
527 OUTL(LAN_SAA9730_DEFAULT_TIME_OUT_CNT, 535 outl(LAN_SAA9730_DEFAULT_TIME_OUT_CNT,
528 &lp->lan_saa9730_regs->Timeout); 536 &lp->lan_saa9730_regs->Timeout);
529 537
530 return 0; 538 return 0;
@@ -536,28 +544,27 @@ static int lan_saa9730_start(struct lan_saa9730_private *lp)
536 544
537 /* Initialize Rx Buffer Index */ 545 /* Initialize Rx Buffer Index */
538 lp->NextRcvPacketIndex = 0; 546 lp->NextRcvPacketIndex = 0;
539 lp->NextRcvToUseIsA = 1; 547 lp->NextRcvBufferIndex = 0;
540 548
541 /* Set current buffer index & next availble packet index */ 549 /* Set current buffer index & next available packet index */
542 lp->NextTxmPacketIndex = 0; 550 lp->NextTxmPacketIndex = 0;
543 lp->NextTxmBufferIndex = 0; 551 lp->NextTxmBufferIndex = 0;
544 lp->PendingTxmPacketIndex = 0; 552 lp->PendingTxmPacketIndex = 0;
545 lp->PendingTxmBufferIndex = 0; 553 lp->PendingTxmBufferIndex = 0;
546 554
547 OUTL(INL(&lp->lan_saa9730_regs->LanDmaCtl) | DMA_CTL_EN_TX_DMA | 555 outl(readl(&lp->lan_saa9730_regs->LanDmaCtl) | DMA_CTL_EN_TX_DMA |
548 DMA_CTL_EN_RX_DMA, &lp->lan_saa9730_regs->LanDmaCtl); 556 DMA_CTL_EN_RX_DMA, &lp->lan_saa9730_regs->LanDmaCtl);
549 557
550 /* For Tx, turn on MAC then DMA */ 558 /* For Tx, turn on MAC then DMA */
551 OUTL(INL(&lp->lan_saa9730_regs->TxCtl) | TX_CTL_TX_EN, 559 outl(readl(&lp->lan_saa9730_regs->TxCtl) | TX_CTL_TX_EN,
552 &lp->lan_saa9730_regs->TxCtl); 560 &lp->lan_saa9730_regs->TxCtl);
553 561
554 /* For Rx, turn on DMA then MAC */ 562 /* For Rx, turn on DMA then MAC */
555 OUTL(INL(&lp->lan_saa9730_regs->RxCtl) | RX_CTL_RX_EN, 563 outl(readl(&lp->lan_saa9730_regs->RxCtl) | RX_CTL_RX_EN,
556 &lp->lan_saa9730_regs->RxCtl); 564 &lp->lan_saa9730_regs->RxCtl);
557 565
558 /* Set Ok2Use to let hardware owns the buffers */ 566 /* Set Ok2Use to let hardware own the buffers. */
559 OUTL(OK2USE_RX_A | OK2USE_RX_B | OK2USE_TX_A | OK2USE_TX_B, 567 outl(OK2USE_RX_A | OK2USE_RX_B, &lp->lan_saa9730_regs->Ok2Use);
560 &lp->lan_saa9730_regs->Ok2Use);
561 568
562 return 0; 569 return 0;
563} 570}
@@ -572,8 +579,7 @@ static int lan_saa9730_restart(struct lan_saa9730_private *lp)
572 579
573static int lan_saa9730_tx(struct net_device *dev) 580static int lan_saa9730_tx(struct net_device *dev)
574{ 581{
575 struct lan_saa9730_private *lp = 582 struct lan_saa9730_private *lp = netdev_priv(dev);
576 (struct lan_saa9730_private *) dev->priv;
577 unsigned int *pPacket; 583 unsigned int *pPacket;
578 unsigned int tx_status; 584 unsigned int tx_status;
579 585
@@ -581,13 +587,11 @@ static int lan_saa9730_tx(struct net_device *dev)
581 printk("lan_saa9730_tx interrupt\n"); 587 printk("lan_saa9730_tx interrupt\n");
582 588
583 /* Clear interrupt. */ 589 /* Clear interrupt. */
584 OUTL(DMA_STATUS_MAC_TX_INT, &lp->lan_saa9730_regs->DmaStatus); 590 outl(DMA_STATUS_MAC_TX_INT, &lp->lan_saa9730_regs->DmaStatus);
585 591
586 while (1) { 592 while (1) {
587 pPacket = 593 pPacket = lp->TxmBuffer[lp->PendingTxmBufferIndex]
588 (unsigned int *) lp->TxmBuffer[lp-> 594 [lp->PendingTxmPacketIndex];
589 PendingTxmBufferIndex]
590 [lp->PendingTxmPacketIndex];
591 595
592 /* Get status of first packet transmitted. */ 596 /* Get status of first packet transmitted. */
593 tx_status = le32_to_cpu(*pPacket); 597 tx_status = le32_to_cpu(*pPacket);
@@ -605,23 +609,22 @@ static int lan_saa9730_tx(struct net_device *dev)
605 lp->stats.tx_errors++; 609 lp->stats.tx_errors++;
606 if (tx_status & 610 if (tx_status &
607 (TX_STATUS_EX_COLL << TX_STAT_CTL_STATUS_SHF)) 611 (TX_STATUS_EX_COLL << TX_STAT_CTL_STATUS_SHF))
608 lp->stats.tx_aborted_errors++; 612 lp->stats.tx_aborted_errors++;
609 if (tx_status & 613 if (tx_status &
610 (TX_STATUS_LATE_COLL << 614 (TX_STATUS_LATE_COLL << TX_STAT_CTL_STATUS_SHF))
611 TX_STAT_CTL_STATUS_SHF)) lp->stats. 615 lp->stats.tx_window_errors++;
612 tx_window_errors++;
613 if (tx_status & 616 if (tx_status &
614 (TX_STATUS_L_CARR << TX_STAT_CTL_STATUS_SHF)) 617 (TX_STATUS_L_CARR << TX_STAT_CTL_STATUS_SHF))
615 lp->stats.tx_carrier_errors++; 618 lp->stats.tx_carrier_errors++;
616 if (tx_status & 619 if (tx_status &
617 (TX_STATUS_UNDER << TX_STAT_CTL_STATUS_SHF)) 620 (TX_STATUS_UNDER << TX_STAT_CTL_STATUS_SHF))
618 lp->stats.tx_fifo_errors++; 621 lp->stats.tx_fifo_errors++;
619 if (tx_status & 622 if (tx_status &
620 (TX_STATUS_SQ_ERR << TX_STAT_CTL_STATUS_SHF)) 623 (TX_STATUS_SQ_ERR << TX_STAT_CTL_STATUS_SHF))
621 lp->stats.tx_heartbeat_errors++; 624 lp->stats.tx_heartbeat_errors++;
622 625
623 lp->stats.collisions += 626 lp->stats.collisions +=
624 tx_status & TX_STATUS_TX_COLL_MSK; 627 tx_status & TX_STATUS_TX_COLL_MSK;
625 } 628 }
626 629
627 /* Free buffer. */ 630 /* Free buffer. */
@@ -636,21 +639,15 @@ static int lan_saa9730_tx(struct net_device *dev)
636 } 639 }
637 } 640 }
638 641
639 /* Make sure A and B are available to hardware. */ 642 /* The tx buffer is no longer full. */
640 OUTL(OK2USE_TX_A | OK2USE_TX_B, &lp->lan_saa9730_regs->Ok2Use); 643 netif_wake_queue(dev);
641
642 if (netif_queue_stopped(dev)) {
643 /* The tx buffer is no longer full. */
644 netif_wake_queue(dev);
645 }
646 644
647 return 0; 645 return 0;
648} 646}
649 647
650static int lan_saa9730_rx(struct net_device *dev) 648static int lan_saa9730_rx(struct net_device *dev)
651{ 649{
652 struct lan_saa9730_private *lp = 650 struct lan_saa9730_private *lp = netdev_priv(dev);
653 (struct lan_saa9730_private *) dev->priv;
654 int len = 0; 651 int len = 0;
655 struct sk_buff *skb = 0; 652 struct sk_buff *skb = 0;
656 unsigned int rx_status; 653 unsigned int rx_status;
@@ -663,16 +660,13 @@ static int lan_saa9730_rx(struct net_device *dev)
663 printk("lan_saa9730_rx interrupt\n"); 660 printk("lan_saa9730_rx interrupt\n");
664 661
665 /* Clear receive interrupts. */ 662 /* Clear receive interrupts. */
666 OUTL(DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT | 663 outl(DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT |
667 DMA_STATUS_RX_TO_INT, &lp->lan_saa9730_regs->DmaStatus); 664 DMA_STATUS_RX_TO_INT, &lp->lan_saa9730_regs->DmaStatus);
668 665
669 /* Address next packet */ 666 /* Address next packet */
670 if (lp->NextRcvToUseIsA) 667 BufferIndex = lp->NextRcvBufferIndex;
671 BufferIndex = 0;
672 else
673 BufferIndex = 1;
674 PacketIndex = lp->NextRcvPacketIndex; 668 PacketIndex = lp->NextRcvPacketIndex;
675 pPacket = (unsigned int *) lp->RcvBuffer[BufferIndex][PacketIndex]; 669 pPacket = lp->RcvBuffer[BufferIndex][PacketIndex];
676 rx_status = le32_to_cpu(*pPacket); 670 rx_status = le32_to_cpu(*pPacket);
677 671
678 /* Process each packet. */ 672 /* Process each packet. */
@@ -715,51 +709,39 @@ static int lan_saa9730_rx(struct net_device *dev)
715 lp->stats.rx_errors++; 709 lp->stats.rx_errors++;
716 if (rx_status & 710 if (rx_status &
717 (RX_STATUS_CRC_ERR << RX_STAT_CTL_STATUS_SHF)) 711 (RX_STATUS_CRC_ERR << RX_STAT_CTL_STATUS_SHF))
718 lp->stats.rx_crc_errors++; 712 lp->stats.rx_crc_errors++;
719 if (rx_status & 713 if (rx_status &
720 (RX_STATUS_ALIGN_ERR << 714 (RX_STATUS_ALIGN_ERR << RX_STAT_CTL_STATUS_SHF))
721 RX_STAT_CTL_STATUS_SHF)) lp->stats. 715 lp->stats.rx_frame_errors++;
722 rx_frame_errors++;
723 if (rx_status & 716 if (rx_status &
724 (RX_STATUS_OVERFLOW << RX_STAT_CTL_STATUS_SHF)) 717 (RX_STATUS_OVERFLOW << RX_STAT_CTL_STATUS_SHF))
725 lp->stats.rx_fifo_errors++; 718 lp->stats.rx_fifo_errors++;
726 if (rx_status & 719 if (rx_status &
727 (RX_STATUS_LONG_ERR << RX_STAT_CTL_STATUS_SHF)) 720 (RX_STATUS_LONG_ERR << RX_STAT_CTL_STATUS_SHF))
728 lp->stats.rx_length_errors++; 721 lp->stats.rx_length_errors++;
729 } 722 }
730 723
731 /* Indicate we have processed the buffer. */ 724 /* Indicate we have processed the buffer. */
732 *pPacket = 725 *pPacket = cpu_to_le32(RXSF_READY << RX_STAT_CTL_OWNER_SHF);
733 cpu_to_le32(RXSF_READY << RX_STAT_CTL_OWNER_SHF); 726
727 /* Make sure A or B is available to hardware as appropriate. */
728 outl(BufferIndex ? OK2USE_RX_B : OK2USE_RX_A,
729 &lp->lan_saa9730_regs->Ok2Use);
734 730
735 /* Go to next packet in sequence. */ 731 /* Go to next packet in sequence. */
736 lp->NextRcvPacketIndex++; 732 lp->NextRcvPacketIndex++;
737 if (lp->NextRcvPacketIndex >= LAN_SAA9730_RCV_Q_SIZE) { 733 if (lp->NextRcvPacketIndex >= LAN_SAA9730_RCV_Q_SIZE) {
738 lp->NextRcvPacketIndex = 0; 734 lp->NextRcvPacketIndex = 0;
739 if (BufferIndex) { 735 lp->NextRcvBufferIndex ^= 1;
740 lp->NextRcvToUseIsA = 1;
741 } else {
742 lp->NextRcvToUseIsA = 0;
743 }
744 } 736 }
745 OUTL(OK2USE_RX_A | OK2USE_RX_B,
746 &lp->lan_saa9730_regs->Ok2Use);
747 737
748 /* Address next packet */ 738 /* Address next packet */
749 if (lp->NextRcvToUseIsA) 739 BufferIndex = lp->NextRcvBufferIndex;
750 BufferIndex = 0;
751 else
752 BufferIndex = 1;
753 PacketIndex = lp->NextRcvPacketIndex; 740 PacketIndex = lp->NextRcvPacketIndex;
754 pPacket = 741 pPacket = lp->RcvBuffer[BufferIndex][PacketIndex];
755 (unsigned int *) lp->
756 RcvBuffer[BufferIndex][PacketIndex];
757 rx_status = le32_to_cpu(*pPacket); 742 rx_status = le32_to_cpu(*pPacket);
758 } 743 }
759 744
760 /* Make sure A and B are available to hardware. */
761 OUTL(OK2USE_RX_A | OK2USE_RX_B, &lp->lan_saa9730_regs->Ok2Use);
762
763 return 0; 745 return 0;
764} 746}
765 747
@@ -767,8 +749,7 @@ static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id,
767 struct pt_regs *regs) 749 struct pt_regs *regs)
768{ 750{
769 struct net_device *dev = (struct net_device *) dev_id; 751 struct net_device *dev = (struct net_device *) dev_id;
770 struct lan_saa9730_private *lp = 752 struct lan_saa9730_private *lp = netdev_priv(dev);
771 (struct lan_saa9730_private *) dev->priv;
772 753
773 if (lan_saa9730_debug > 5) 754 if (lan_saa9730_debug > 5)
774 printk("lan_saa9730_interrupt\n"); 755 printk("lan_saa9730_interrupt\n");
@@ -780,11 +761,11 @@ static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id,
780 evm_saa9730_clear_lan_int(lp); 761 evm_saa9730_clear_lan_int(lp);
781 762
782 /* Service pending transmit interrupts. */ 763 /* Service pending transmit interrupts. */
783 if (INL(&lp->lan_saa9730_regs->DmaStatus) & DMA_STATUS_MAC_TX_INT) 764 if (readl(&lp->lan_saa9730_regs->DmaStatus) & DMA_STATUS_MAC_TX_INT)
784 lan_saa9730_tx(dev); 765 lan_saa9730_tx(dev);
785 766
786 /* Service pending receive interrupts. */ 767 /* Service pending receive interrupts. */
787 if (INL(&lp->lan_saa9730_regs->DmaStatus) & 768 if (readl(&lp->lan_saa9730_regs->DmaStatus) &
788 (DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT | 769 (DMA_STATUS_MAC_RX_INT | DMA_STATUS_RX_INT |
789 DMA_STATUS_RX_TO_INT)) lan_saa9730_rx(dev); 770 DMA_STATUS_RX_TO_INT)) lan_saa9730_rx(dev);
790 771
@@ -794,15 +775,9 @@ static irqreturn_t lan_saa9730_interrupt(const int irq, void *dev_id,
794 return IRQ_HANDLED; 775 return IRQ_HANDLED;
795} 776}
796 777
797static int lan_saa9730_open_fail(struct net_device *dev)
798{
799 return -ENODEV;
800}
801
802static int lan_saa9730_open(struct net_device *dev) 778static int lan_saa9730_open(struct net_device *dev)
803{ 779{
804 struct lan_saa9730_private *lp = 780 struct lan_saa9730_private *lp = netdev_priv(dev);
805 (struct lan_saa9730_private *) dev->priv;
806 781
807 /* Associate IRQ with lan_saa9730_interrupt */ 782 /* Associate IRQ with lan_saa9730_interrupt */
808 if (request_irq(dev->irq, &lan_saa9730_interrupt, 0, "SAA9730 Eth", 783 if (request_irq(dev->irq, &lan_saa9730_interrupt, 0, "SAA9730 Eth",
@@ -834,15 +809,13 @@ static int lan_saa9730_write(struct lan_saa9730_private *lp,
834 int PacketIndex; 809 int PacketIndex;
835 810
836 if (lan_saa9730_debug > 5) 811 if (lan_saa9730_debug > 5)
837 printk("lan_saa9730_write: skb=%08x\n", 812 printk("lan_saa9730_write: skb=%p\n", skb);
838 (unsigned int) skb);
839 813
840 BufferIndex = lp->NextTxmBufferIndex; 814 BufferIndex = lp->NextTxmBufferIndex;
841 PacketIndex = lp->NextTxmPacketIndex; 815 PacketIndex = lp->NextTxmPacketIndex;
842 816
843 tx_status = 817 tx_status = le32_to_cpu(*(unsigned int *)lp->TxmBuffer[BufferIndex]
844 le32_to_cpu(*(unsigned int *) lp-> 818 [PacketIndex]);
845 TxmBuffer[BufferIndex][PacketIndex]);
846 if ((tx_status & TX_STAT_CTL_OWNER_MSK) != 819 if ((tx_status & TX_STAT_CTL_OWNER_MSK) !=
847 (TXSF_EMPTY << TX_STAT_CTL_OWNER_SHF)) { 820 (TXSF_EMPTY << TX_STAT_CTL_OWNER_SHF)) {
848 if (lan_saa9730_debug > 4) 821 if (lan_saa9730_debug > 4)
@@ -858,29 +831,29 @@ static int lan_saa9730_write(struct lan_saa9730_private *lp,
858 lp->NextTxmBufferIndex ^= 1; 831 lp->NextTxmBufferIndex ^= 1;
859 } 832 }
860 833
861 pbPacketData = 834 pbPacketData = lp->TxmBuffer[BufferIndex][PacketIndex];
862 (unsigned char *) lp->TxmBuffer[BufferIndex][PacketIndex];
863 pbPacketData += 4; 835 pbPacketData += 4;
864 836
865 /* copy the bits */ 837 /* copy the bits */
866 memcpy(pbPacketData, pbData, len); 838 memcpy(pbPacketData, pbData, len);
867 839
868 /* Set transmit status for hardware */ 840 /* Set transmit status for hardware */
869 *(unsigned int *) lp->TxmBuffer[BufferIndex][PacketIndex] = 841 *(unsigned int *)lp->TxmBuffer[BufferIndex][PacketIndex] =
870 cpu_to_le32((TXSF_READY << TX_STAT_CTL_OWNER_SHF) | 842 cpu_to_le32((TXSF_READY << TX_STAT_CTL_OWNER_SHF) |
871 (TX_STAT_CTL_INT_AFTER_TX << TX_STAT_CTL_FRAME_SHF) 843 (TX_STAT_CTL_INT_AFTER_TX <<
872 | (len << TX_STAT_CTL_LENGTH_SHF)); 844 TX_STAT_CTL_FRAME_SHF) |
873 845 (len << TX_STAT_CTL_LENGTH_SHF));
874 /* Set hardware tx buffer. */ 846
875 OUTL(OK2USE_TX_A | OK2USE_TX_B, &lp->lan_saa9730_regs->Ok2Use); 847 /* Make sure A or B is available to hardware as appropriate. */
848 outl(BufferIndex ? OK2USE_TX_B : OK2USE_TX_A,
849 &lp->lan_saa9730_regs->Ok2Use);
876 850
877 return 0; 851 return 0;
878} 852}
879 853
880static void lan_saa9730_tx_timeout(struct net_device *dev) 854static void lan_saa9730_tx_timeout(struct net_device *dev)
881{ 855{
882 struct lan_saa9730_private *lp = 856 struct lan_saa9730_private *lp = netdev_priv(dev);
883 (struct lan_saa9730_private *) dev->priv;
884 857
885 /* Transmitter timeout, serious problems */ 858 /* Transmitter timeout, serious problems */
886 lp->stats.tx_errors++; 859 lp->stats.tx_errors++;
@@ -889,20 +862,19 @@ static void lan_saa9730_tx_timeout(struct net_device *dev)
889 lan_saa9730_restart(lp); 862 lan_saa9730_restart(lp);
890 863
891 dev->trans_start = jiffies; 864 dev->trans_start = jiffies;
892 netif_start_queue(dev); 865 netif_wake_queue(dev);
893} 866}
894 867
895static int lan_saa9730_start_xmit(struct sk_buff *skb, 868static int lan_saa9730_start_xmit(struct sk_buff *skb,
896 struct net_device *dev) 869 struct net_device *dev)
897{ 870{
898 struct lan_saa9730_private *lp = 871 struct lan_saa9730_private *lp = netdev_priv(dev);
899 (struct lan_saa9730_private *) dev->priv;
900 unsigned long flags; 872 unsigned long flags;
901 int skblen; 873 int skblen;
902 int len; 874 int len;
903 875
904 if (lan_saa9730_debug > 4) 876 if (lan_saa9730_debug > 4)
905 printk("Send packet: skb=%08x\n", (unsigned int) skb); 877 printk("Send packet: skb=%p\n", skb);
906 878
907 skblen = skb->len; 879 skblen = skb->len;
908 880
@@ -912,8 +884,7 @@ static int lan_saa9730_start_xmit(struct sk_buff *skb,
912 884
913 if (lan_saa9730_write(lp, skb, skblen)) { 885 if (lan_saa9730_write(lp, skb, skblen)) {
914 spin_unlock_irqrestore(&lp->lock, flags); 886 spin_unlock_irqrestore(&lp->lock, flags);
915 printk("Error when writing packet to controller: skb=%08x\n", 887 printk("Error when writing packet to controller: skb=%p\n", skb);
916 (unsigned int) skb);
917 netif_stop_queue(dev); 888 netif_stop_queue(dev);
918 return -1; 889 return -1;
919 } 890 }
@@ -922,7 +893,7 @@ static int lan_saa9730_start_xmit(struct sk_buff *skb,
922 lp->stats.tx_packets++; 893 lp->stats.tx_packets++;
923 894
924 dev->trans_start = jiffies; 895 dev->trans_start = jiffies;
925 netif_start_queue(dev); 896 netif_wake_queue(dev);
926 dev_kfree_skb(skb); 897 dev_kfree_skb(skb);
927 898
928 spin_unlock_irqrestore(&lp->lock, flags); 899 spin_unlock_irqrestore(&lp->lock, flags);
@@ -932,8 +903,7 @@ static int lan_saa9730_start_xmit(struct sk_buff *skb,
932 903
933static int lan_saa9730_close(struct net_device *dev) 904static int lan_saa9730_close(struct net_device *dev)
934{ 905{
935 struct lan_saa9730_private *lp = 906 struct lan_saa9730_private *lp = netdev_priv(dev);
936 (struct lan_saa9730_private *) dev->priv;
937 907
938 if (lan_saa9730_debug > 1) 908 if (lan_saa9730_debug > 1)
939 printk("lan_saa9730_close:\n"); 909 printk("lan_saa9730_close:\n");
@@ -955,33 +925,31 @@ static int lan_saa9730_close(struct net_device *dev)
955static struct net_device_stats *lan_saa9730_get_stats(struct net_device 925static struct net_device_stats *lan_saa9730_get_stats(struct net_device
956 *dev) 926 *dev)
957{ 927{
958 struct lan_saa9730_private *lp = 928 struct lan_saa9730_private *lp = netdev_priv(dev);
959 (struct lan_saa9730_private *) dev->priv;
960 929
961 return &lp->stats; 930 return &lp->stats;
962} 931}
963 932
964static void lan_saa9730_set_multicast(struct net_device *dev) 933static void lan_saa9730_set_multicast(struct net_device *dev)
965{ 934{
966 struct lan_saa9730_private *lp = 935 struct lan_saa9730_private *lp = netdev_priv(dev);
967 (struct lan_saa9730_private *) dev->priv;
968 936
969 /* Stop the controller */ 937 /* Stop the controller */
970 lan_saa9730_stop(lp); 938 lan_saa9730_stop(lp);
971 939
972 if (dev->flags & IFF_PROMISC) { 940 if (dev->flags & IFF_PROMISC) {
973 /* accept all packets */ 941 /* accept all packets */
974 OUTL(CAM_CONTROL_COMP_EN | CAM_CONTROL_STATION_ACC | 942 outl(CAM_CONTROL_COMP_EN | CAM_CONTROL_STATION_ACC |
975 CAM_CONTROL_GROUP_ACC | CAM_CONTROL_BROAD_ACC, 943 CAM_CONTROL_GROUP_ACC | CAM_CONTROL_BROAD_ACC,
976 &lp->lan_saa9730_regs->CamCtl); 944 &lp->lan_saa9730_regs->CamCtl);
977 } else { 945 } else {
978 if (dev->flags & IFF_ALLMULTI) { 946 if (dev->flags & IFF_ALLMULTI) {
979 /* accept all multicast packets */ 947 /* accept all multicast packets */
980 OUTL(CAM_CONTROL_COMP_EN | CAM_CONTROL_GROUP_ACC | 948 outl(CAM_CONTROL_COMP_EN | CAM_CONTROL_GROUP_ACC |
981 CAM_CONTROL_BROAD_ACC, 949 CAM_CONTROL_BROAD_ACC,
982 &lp->lan_saa9730_regs->CamCtl); 950 &lp->lan_saa9730_regs->CamCtl);
983 } else { 951 } else {
984 /* 952 /*
985 * Will handle the multicast stuff later. -carstenl 953 * Will handle the multicast stuff later. -carstenl
986 */ 954 */
987 } 955 }
@@ -993,91 +961,86 @@ static void lan_saa9730_set_multicast(struct net_device *dev)
993 961
994static void __devexit saa9730_remove_one(struct pci_dev *pdev) 962static void __devexit saa9730_remove_one(struct pci_dev *pdev)
995{ 963{
996 struct net_device *dev = pci_get_drvdata(pdev); 964 struct net_device *dev = pci_get_drvdata(pdev);
997 965 struct lan_saa9730_private *lp = netdev_priv(dev);
998 if (dev) { 966
999 unregister_netdev(dev); 967 if (dev) {
1000 kfree(dev->priv); 968 unregister_netdev(dev);
1001 free_netdev(dev); 969 lan_saa9730_free_buffers(pdev, lp);
1002 pci_release_regions(pdev); 970 iounmap(lp->lan_saa9730_regs);
1003 pci_disable_device(pdev); 971 iounmap(lp->evm_saa9730_regs);
1004 pci_set_drvdata(pdev, NULL); 972 free_netdev(dev);
1005 } 973 pci_release_regions(pdev);
974 pci_disable_device(pdev);
975 pci_set_drvdata(pdev, NULL);
976 }
1006} 977}
1007 978
1008 979
1009static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq) 980static int lan_saa9730_init(struct net_device *dev, struct pci_dev *pdev,
981 unsigned long ioaddr, int irq)
1010{ 982{
1011 struct lan_saa9730_private *lp; 983 struct lan_saa9730_private *lp = netdev_priv(dev);
1012 unsigned char ethernet_addr[6]; 984 unsigned char ethernet_addr[6];
1013 int ret = 0; 985 int ret;
1014 986
1015 dev->open = lan_saa9730_open_fail; 987 if (get_ethernet_addr(ethernet_addr)) {
988 ret = -ENODEV;
989 goto out;
990 }
1016 991
1017 if (get_ethernet_addr(ethernet_addr))
1018 return -ENODEV;
1019
1020 memcpy(dev->dev_addr, ethernet_addr, 6); 992 memcpy(dev->dev_addr, ethernet_addr, 6);
1021 dev->base_addr = ioaddr; 993 dev->base_addr = ioaddr;
1022 dev->irq = irq; 994 dev->irq = irq;
1023
1024 /*
1025 * Make certain the data structures used by the controller are aligned
1026 * and DMAble.
1027 */
1028 /*
1029 * XXX: that is obviously broken - kfree() won't be happy with us.
1030 */
1031 lp = (struct lan_saa9730_private *) (((unsigned long)
1032 kmalloc(sizeof(*lp) + 7,
1033 GFP_DMA | GFP_KERNEL)
1034 + 7) & ~7);
1035 995
1036 if (!lp) 996 lp->pci_dev = pdev;
1037 return -ENOMEM;
1038
1039 dev->priv = lp;
1040 memset(lp, 0, sizeof(*lp));
1041 997
1042 /* Set SAA9730 LAN base address. */ 998 /* Set SAA9730 LAN base address. */
1043 lp->lan_saa9730_regs = (t_lan_saa9730_regmap *) (ioaddr + 999 lp->lan_saa9730_regs = ioremap(ioaddr + SAA9730_LAN_REGS_ADDR,
1044 SAA9730_LAN_REGS_ADDR); 1000 SAA9730_LAN_REGS_SIZE);
1001 if (!lp->lan_saa9730_regs) {
1002 ret = -ENOMEM;
1003 goto out;
1004 }
1045 1005
1046 /* Set SAA9730 EVM base address. */ 1006 /* Set SAA9730 EVM base address. */
1047 lp->evm_saa9730_regs = (t_evm_saa9730_regmap *) (ioaddr + 1007 lp->evm_saa9730_regs = ioremap(ioaddr + SAA9730_EVM_REGS_ADDR,
1048 SAA9730_EVM_REGS_ADDR); 1008 SAA9730_EVM_REGS_SIZE);
1009 if (!lp->evm_saa9730_regs) {
1010 ret = -ENOMEM;
1011 goto out_iounmap_lan;
1012 }
1049 1013
1050 /* Allocate LAN RX/TX frame buffer space. */ 1014 /* Allocate LAN RX/TX frame buffer space. */
1051 /* FIXME: a leak */ 1015 if ((ret = lan_saa9730_allocate_buffers(pdev, lp)))
1052 if ((ret = lan_saa9730_allocate_buffers(lp))) 1016 goto out_iounmap;
1053 goto out;
1054 1017
1055 /* Stop LAN controller. */ 1018 /* Stop LAN controller. */
1056 if ((ret = lan_saa9730_stop(lp))) 1019 if ((ret = lan_saa9730_stop(lp)))
1057 goto out; 1020 goto out_free_consistent;
1058 1021
1059 /* Initialize CAM registers. */ 1022 /* Initialize CAM registers. */
1060 if ((ret = lan_saa9730_cam_init(dev))) 1023 if ((ret = lan_saa9730_cam_init(dev)))
1061 goto out; 1024 goto out_free_consistent;
1062 1025
1063 /* Initialize MII registers. */ 1026 /* Initialize MII registers. */
1064 if ((ret = lan_saa9730_mii_init(lp))) 1027 if ((ret = lan_saa9730_mii_init(lp)))
1065 goto out; 1028 goto out_free_consistent;
1066 1029
1067 /* Initialize control registers. */ 1030 /* Initialize control registers. */
1068 if ((ret = lan_saa9730_control_init(lp))) 1031 if ((ret = lan_saa9730_control_init(lp)))
1069 goto out; 1032 goto out_free_consistent;
1070 1033
1071 /* Load CAM registers. */ 1034 /* Load CAM registers. */
1072 if ((ret = lan_saa9730_cam_load(lp))) 1035 if ((ret = lan_saa9730_cam_load(lp)))
1073 goto out; 1036 goto out_free_consistent;
1074 1037
1075 /* Initialize DMA context registers. */ 1038 /* Initialize DMA context registers. */
1076 if ((ret = lan_saa9730_dma_init(lp))) 1039 if ((ret = lan_saa9730_dma_init(lp)))
1077 goto out; 1040 goto out_free_consistent;
1078 1041
1079 spin_lock_init(&lp->lock); 1042 spin_lock_init(&lp->lock);
1080 1043
1081 dev->open = lan_saa9730_open; 1044 dev->open = lan_saa9730_open;
1082 dev->hard_start_xmit = lan_saa9730_start_xmit; 1045 dev->hard_start_xmit = lan_saa9730_start_xmit;
1083 dev->stop = lan_saa9730_close; 1046 dev->stop = lan_saa9730_close;
@@ -1086,44 +1049,43 @@ static int lan_saa9730_init(struct net_device *dev, int ioaddr, int irq)
1086 dev->tx_timeout = lan_saa9730_tx_timeout; 1049 dev->tx_timeout = lan_saa9730_tx_timeout;
1087 dev->watchdog_timeo = (HZ >> 1); 1050 dev->watchdog_timeo = (HZ >> 1);
1088 dev->dma = 0; 1051 dev->dma = 0;
1089 1052
1090 ret = register_netdev(dev); 1053 ret = register_netdev (dev);
1091 if (ret) 1054 if (ret)
1092 goto out; 1055 goto out_free_consistent;
1056
1093 return 0; 1057 return 0;
1094 1058
1095 out: 1059out_free_consistent:
1096 kfree(dev->priv); 1060 lan_saa9730_free_buffers(pdev, lp);
1061out_iounmap:
1062 iounmap(lp->evm_saa9730_regs);
1063out_iounmap_lan:
1064 iounmap(lp->lan_saa9730_regs);
1065out:
1097 return ret; 1066 return ret;
1098} 1067}
1099 1068
1100 1069
1101static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 1070static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1102{ 1071{
1103 struct net_device *dev; 1072 struct net_device *dev = NULL;
1104 unsigned int pci_ioaddr; 1073 unsigned long pci_ioaddr;
1105 int err; 1074 int err;
1106 1075
1107 if (lan_saa9730_debug > 1) 1076 if (lan_saa9730_debug > 1)
1108 printk("saa9730.c: PCI bios is present, checking for devices...\n"); 1077 printk("saa9730.c: PCI bios is present, checking for devices...\n");
1109 1078
1110 err = -ENOMEM;
1111 dev = alloc_etherdev(0);
1112 if (!dev)
1113 goto out;
1114
1115 SET_MODULE_OWNER(dev);
1116
1117 err = pci_enable_device(pdev); 1079 err = pci_enable_device(pdev);
1118 if (err) { 1080 if (err) {
1119 printk(KERN_ERR "Cannot enable PCI device, aborting.\n"); 1081 printk(KERN_ERR "Cannot enable PCI device, aborting.\n");
1120 goto out1; 1082 goto out;
1121 } 1083 }
1122 1084
1123 err = pci_request_regions(pdev, DRV_MODULE_NAME); 1085 err = pci_request_regions(pdev, DRV_MODULE_NAME);
1124 if (err) { 1086 if (err) {
1125 printk(KERN_ERR "Cannot obtain PCI resources, aborting.\n"); 1087 printk(KERN_ERR "Cannot obtain PCI resources, aborting.\n");
1126 goto out2; 1088 goto out_disable_pdev;
1127 } 1089 }
1128 1090
1129 pci_irq_line = pdev->irq; 1091 pci_irq_line = pdev->irq;
@@ -1132,49 +1094,54 @@ static int __devinit saa9730_init_one(struct pci_dev *pdev, const struct pci_dev
1132 pci_ioaddr = pci_resource_start(pdev, 1); 1094 pci_ioaddr = pci_resource_start(pdev, 1);
1133 pci_set_master(pdev); 1095 pci_set_master(pdev);
1134 1096
1135 printk("Found SAA9730 (PCI) at %#x, irq %d.\n", 1097 printk("Found SAA9730 (PCI) at %lx, irq %d.\n",
1136 pci_ioaddr, pci_irq_line); 1098 pci_ioaddr, pci_irq_line);
1137 1099
1138 err = lan_saa9730_init(dev, pci_ioaddr, pci_irq_line); 1100 dev = alloc_etherdev(sizeof(struct lan_saa9730_private));
1101 if (!dev)
1102 goto out_disable_pdev;
1103
1104 err = lan_saa9730_init(dev, pdev, pci_ioaddr, pci_irq_line);
1139 if (err) { 1105 if (err) {
1140 printk("Lan init failed"); 1106 printk("LAN init failed");
1141 goto out2; 1107 goto out_free_netdev;
1142 } 1108 }
1143 1109
1144 pci_set_drvdata(pdev, dev); 1110 pci_set_drvdata(pdev, dev);
1145 SET_NETDEV_DEV(dev, &pdev->dev); 1111 SET_NETDEV_DEV(dev, &pdev->dev);
1146 return 0; 1112 return 0;
1147 1113
1148out2: 1114out_free_netdev:
1149 pci_disable_device(pdev);
1150out1:
1151 free_netdev(dev); 1115 free_netdev(dev);
1116out_disable_pdev:
1117 pci_disable_device(pdev);
1152out: 1118out:
1119 pci_set_drvdata(pdev, NULL);
1153 return err; 1120 return err;
1154} 1121}
1155 1122
1156 1123
1157static struct pci_driver saa9730_driver = { 1124static struct pci_driver saa9730_driver = {
1158 .name = DRV_MODULE_NAME, 1125 .name = DRV_MODULE_NAME,
1159 .id_table = saa9730_pci_tbl, 1126 .id_table = saa9730_pci_tbl,
1160 .probe = saa9730_init_one, 1127 .probe = saa9730_init_one,
1161 .remove = __devexit_p(saa9730_remove_one), 1128 .remove = __devexit_p(saa9730_remove_one),
1162}; 1129};
1163 1130
1164 1131
1165static int __init saa9730_init(void) 1132static int __init saa9730_init(void)
1166{ 1133{
1167 return pci_module_init(&saa9730_driver); 1134 return pci_module_init(&saa9730_driver);
1168} 1135}
1169 1136
1170static void __exit saa9730_cleanup(void) 1137static void __exit saa9730_cleanup(void)
1171{ 1138{
1172 pci_unregister_driver(&saa9730_driver); 1139 pci_unregister_driver(&saa9730_driver);
1173} 1140}
1174 1141
1175module_init(saa9730_init); 1142module_init(saa9730_init);
1176module_exit(saa9730_cleanup); 1143module_exit(saa9730_cleanup);
1177 1144
1178 1145MODULE_AUTHOR("Ralf Baechle <ralf@linux-mips.org>");
1179 1146MODULE_DESCRIPTION("Philips SAA9730 ethernet driver");
1180MODULE_LICENSE("GPL"); 1147MODULE_LICENSE("GPL");
diff --git a/drivers/net/saa9730.h b/drivers/net/saa9730.h
index 9e9da6b4080f..a7e9d29a86a7 100644
--- a/drivers/net/saa9730.h
+++ b/drivers/net/saa9730.h
@@ -1,6 +1,7 @@
1/* 1/*
2 * Carsten Langgaard, carstenl@mips.com 2 * Copyright (C) 2000, 2005 MIPS Technologies, Inc. All rights reserved.
3 * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. 3 * Authors: Carsten Langgaard <carstenl@mips.com>
4 * Maciej W. Rozycki <macro@mips.com>
4 * 5 *
5 * ######################################################################## 6 * ########################################################################
6 * 7 *
@@ -265,6 +266,7 @@
265 266
266/* The SAA9730 (LAN) controller register map, as seen via the PCI-bus. */ 267/* The SAA9730 (LAN) controller register map, as seen via the PCI-bus. */
267#define SAA9730_LAN_REGS_ADDR 0x20400 268#define SAA9730_LAN_REGS_ADDR 0x20400
269#define SAA9730_LAN_REGS_SIZE 0x00400
268 270
269struct lan_saa9730_regmap { 271struct lan_saa9730_regmap {
270 volatile unsigned int TxBuffA; /* 0x20400 */ 272 volatile unsigned int TxBuffA; /* 0x20400 */
@@ -309,6 +311,7 @@ typedef volatile struct lan_saa9730_regmap t_lan_saa9730_regmap;
309 311
310/* The SAA9730 (EVM) controller register map, as seen via the PCI-bus. */ 312/* The SAA9730 (EVM) controller register map, as seen via the PCI-bus. */
311#define SAA9730_EVM_REGS_ADDR 0x02000 313#define SAA9730_EVM_REGS_ADDR 0x02000
314#define SAA9730_EVM_REGS_SIZE 0x00400
312 315
313struct evm_saa9730_regmap { 316struct evm_saa9730_regmap {
314 volatile unsigned int InterruptStatus1; /* 0x2000 */ 317 volatile unsigned int InterruptStatus1; /* 0x2000 */
@@ -329,16 +332,32 @@ typedef volatile struct evm_saa9730_regmap t_evm_saa9730_regmap;
329 332
330 333
331struct lan_saa9730_private { 334struct lan_saa9730_private {
335 /*
336 * Rx/Tx packet buffers.
337 * The Rx and Tx packets must be PACKET_SIZE aligned.
338 */
339 void *buffer_start;
340 unsigned int buffer_size;
341
342 /*
343 * DMA address of beginning of this object, returned
344 * by pci_alloc_consistent().
345 */
346 dma_addr_t dma_addr;
347
348 /* Pointer to the associated pci device structure */
349 struct pci_dev *pci_dev;
350
332 /* Pointer for the SAA9730 LAN controller register set. */ 351 /* Pointer for the SAA9730 LAN controller register set. */
333 t_lan_saa9730_regmap *lan_saa9730_regs; 352 t_lan_saa9730_regmap *lan_saa9730_regs;
334 353
335 /* Pointer to the SAA9730 EVM register. */ 354 /* Pointer to the SAA9730 EVM register. */
336 t_evm_saa9730_regmap *evm_saa9730_regs; 355 t_evm_saa9730_regmap *evm_saa9730_regs;
337 356
338 /* TRUE if the next buffer to write is RxBuffA, FALSE if RxBuffB. */
339 unsigned char NextRcvToUseIsA;
340 /* Rcv buffer Index. */ 357 /* Rcv buffer Index. */
341 unsigned char NextRcvPacketIndex; 358 unsigned char NextRcvPacketIndex;
359 /* Next buffer index. */
360 unsigned char NextRcvBufferIndex;
342 361
343 /* Index of next packet to use in that buffer. */ 362 /* Index of next packet to use in that buffer. */
344 unsigned char NextTxmPacketIndex; 363 unsigned char NextTxmPacketIndex;
@@ -353,13 +372,8 @@ struct lan_saa9730_private {
353 unsigned char DmaRcvPackets; 372 unsigned char DmaRcvPackets;
354 unsigned char DmaTxmPackets; 373 unsigned char DmaTxmPackets;
355 374
356 unsigned char RcvAIndex; /* index into RcvBufferSpace[] for Blk A */ 375 void *TxmBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_TXM_Q_SIZE];
357 unsigned char RcvBIndex; /* index into RcvBufferSpace[] for Blk B */ 376 void *RcvBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_RCV_Q_SIZE];
358
359 unsigned int
360 TxmBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_TXM_Q_SIZE];
361 unsigned int
362 RcvBuffer[LAN_SAA9730_BUFFERS][LAN_SAA9730_RCV_Q_SIZE];
363 unsigned int TxBufferFree[LAN_SAA9730_BUFFERS]; 377 unsigned int TxBufferFree[LAN_SAA9730_BUFFERS];
364 378
365 unsigned char PhysicalAddress[LAN_SAA9730_CAM_ENTRIES][6]; 379 unsigned char PhysicalAddress[LAN_SAA9730_CAM_ENTRIES][6];
diff --git a/drivers/net/sk98lin/Makefile b/drivers/net/sk98lin/Makefile
index 6783039ffb75..7653d6e33aa2 100644
--- a/drivers/net/sk98lin/Makefile
+++ b/drivers/net/sk98lin/Makefile
@@ -27,8 +27,7 @@ sk98lin-objs := \
27 sktimer.o \ 27 sktimer.o \
28 skvpd.o \ 28 skvpd.o \
29 skxmac2.o \ 29 skxmac2.o \
30 skproc.o \ 30 skproc.o
31 skcsum.o
32 31
33# DBGDEF = \ 32# DBGDEF = \
34# -DDEBUG 33# -DDEBUG
@@ -77,7 +76,7 @@ endif
77# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources 76# SK_DBGCAT_DRV_INT_SRC 0x04000000 interrupts sources
78# SK_DBGCAT_DRV_EVENT 0x08000000 driver events 77# SK_DBGCAT_DRV_EVENT 0x08000000 driver events
79 78
80EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DSK_USE_CSUM -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM) 79EXTRA_CFLAGS += -Idrivers/net/sk98lin -DSK_DIAG_SUPPORT -DGENESIS -DYUKON $(DBGDEF) $(SKPARAM)
81 80
82clean: 81clean:
83 rm -f core *.o *.a *.s 82 rm -f core *.o *.a *.s
diff --git a/drivers/net/sk98lin/h/skdrv2nd.h b/drivers/net/sk98lin/h/skdrv2nd.h
index 542cec57f86a..2dc5728e3ef6 100644
--- a/drivers/net/sk98lin/h/skdrv2nd.h
+++ b/drivers/net/sk98lin/h/skdrv2nd.h
@@ -425,10 +425,6 @@ struct s_AC {
425 TX_PORT TxPort[SK_MAX_MACS][2]; 425 TX_PORT TxPort[SK_MAX_MACS][2];
426 RX_PORT RxPort[SK_MAX_MACS]; 426 RX_PORT RxPort[SK_MAX_MACS];
427 427
428 unsigned int CsOfs1; /* for checksum calculation */
429 unsigned int CsOfs2; /* for checksum calculation */
430 SK_U32 CsOfs; /* for checksum calculation */
431
432 SK_BOOL CheckQueue; /* check event queue soon */ 428 SK_BOOL CheckQueue; /* check event queue soon */
433 SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */ 429 SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */
434 DIM_INFO DynIrqModInfo; /* all data related to DIM */ 430 DIM_INFO DynIrqModInfo; /* all data related to DIM */
diff --git a/drivers/net/sk98lin/skcsum.c b/drivers/net/sk98lin/skcsum.c
deleted file mode 100644
index 38a6e7a631f3..000000000000
--- a/drivers/net/sk98lin/skcsum.c
+++ /dev/null
@@ -1,871 +0,0 @@
1/******************************************************************************
2 *
3 * Name: skcsum.c
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.12 $
6 * Date: $Date: 2003/08/20 13:55:53 $
7 * Purpose: Store/verify Internet checksum in send/receive packets.
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 * The information in this file is provided "AS IS" without warranty.
21 *
22 ******************************************************************************/
23
24#ifdef SK_USE_CSUM /* Check if CSUM is to be used. */
25
26#ifndef lint
27static const char SysKonnectFileId[] =
28 "@(#) $Id: skcsum.c,v 1.12 2003/08/20 13:55:53 mschmid Exp $ (C) SysKonnect.";
29#endif /* !lint */
30
31/******************************************************************************
32 *
33 * Description:
34 *
35 * This is the "GEnesis" common module "CSUM".
36 *
37 * This module contains the code necessary to calculate, store, and verify the
38 * Internet Checksum of IP, TCP, and UDP frames.
39 *
40 * "GEnesis" is an abbreviation of "Gigabit Ethernet Network System in Silicon"
41 * and is the code name of this SysKonnect project.
42 *
43 * Compilation Options:
44 *
45 * SK_USE_CSUM - Define if CSUM is to be used. Otherwise, CSUM will be an
46 * empty module.
47 *
48 * SKCS_OVERWRITE_PROTO - Define to overwrite the default protocol id
49 * definitions. In this case, all SKCS_PROTO_xxx definitions must be made
50 * external.
51 *
52 * SKCS_OVERWRITE_STATUS - Define to overwrite the default return status
53 * definitions. In this case, all SKCS_STATUS_xxx definitions must be made
54 * external.
55 *
56 * Include File Hierarchy:
57 *
58 * "h/skdrv1st.h"
59 * "h/skcsum.h"
60 * "h/sktypes.h"
61 * "h/skqueue.h"
62 * "h/skdrv2nd.h"
63 *
64 ******************************************************************************/
65
66#include "h/skdrv1st.h"
67#include "h/skcsum.h"
68#include "h/skdrv2nd.h"
69
70/* defines ********************************************************************/
71
72/* The size of an Ethernet MAC header. */
73#define SKCS_ETHERNET_MAC_HEADER_SIZE (6+6+2)
74
75/* The size of the used topology's MAC header. */
76#define SKCS_MAC_HEADER_SIZE SKCS_ETHERNET_MAC_HEADER_SIZE
77
78/* The size of the IP header without any option fields. */
79#define SKCS_IP_HEADER_SIZE 20
80
81/*
82 * Field offsets within the IP header.
83 */
84
85/* "Internet Header Version" and "Length". */
86#define SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH 0
87
88/* "Total Length". */
89#define SKCS_OFS_IP_TOTAL_LENGTH 2
90
91/* "Flags" "Fragment Offset". */
92#define SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET 6
93
94/* "Next Level Protocol" identifier. */
95#define SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL 9
96
97/* Source IP address. */
98#define SKCS_OFS_IP_SOURCE_ADDRESS 12
99
100/* Destination IP address. */
101#define SKCS_OFS_IP_DESTINATION_ADDRESS 16
102
103
104/*
105 * Field offsets within the UDP header.
106 */
107
108/* UDP checksum. */
109#define SKCS_OFS_UDP_CHECKSUM 6
110
111/* IP "Next Level Protocol" identifiers (see RFC 790). */
112#define SKCS_PROTO_ID_TCP 6 /* Transport Control Protocol */
113#define SKCS_PROTO_ID_UDP 17 /* User Datagram Protocol */
114
115/* IP "Don't Fragment" bit. */
116#define SKCS_IP_DONT_FRAGMENT SKCS_HTON16(0x4000)
117
118/* Add a byte offset to a pointer. */
119#define SKCS_IDX(pPtr, Ofs) ((void *) ((char *) (pPtr) + (Ofs)))
120
121/*
122 * Macros that convert host to network representation and vice versa, i.e.
123 * little/big endian conversion on little endian machines only.
124 */
125#ifdef SK_LITTLE_ENDIAN
126#define SKCS_HTON16(Val16) (((unsigned) (Val16) >> 8) | (((Val16) & 0xff) << 8))
127#endif /* SK_LITTLE_ENDIAN */
128#ifdef SK_BIG_ENDIAN
129#define SKCS_HTON16(Val16) (Val16)
130#endif /* SK_BIG_ENDIAN */
131#define SKCS_NTOH16(Val16) SKCS_HTON16(Val16)
132
133/* typedefs *******************************************************************/
134
135/* function prototypes ********************************************************/
136
137/******************************************************************************
138 *
139 * SkCsGetSendInfo - get checksum information for a send packet
140 *
141 * Description:
142 * Get all checksum information necessary to send a TCP or UDP packet. The
143 * function checks the IP header passed to it. If the high-level protocol
144 * is either TCP or UDP the pseudo header checksum is calculated and
145 * returned.
146 *
147 * The function returns the total length of the IP header (including any
148 * IP option fields), which is the same as the start offset of the IP data
149 * which in turn is the start offset of the TCP or UDP header.
150 *
151 * The function also returns the TCP or UDP pseudo header checksum, which
152 * should be used as the start value for the hardware checksum calculation.
153 * (Note that any actual pseudo header checksum can never calculate to
154 * zero.)
155 *
156 * Note:
157 * There is a bug in the GENESIS ASIC which may lead to wrong checksums.
158 *
159 * Arguments:
160 * pAc - A pointer to the adapter context struct.
161 *
162 * pIpHeader - Pointer to IP header. Must be at least the IP header *not*
163 * including any option fields, i.e. at least 20 bytes.
164 *
165 * Note: This pointer will be used to address 8-, 16-, and 32-bit
166 * variables with the respective alignment offsets relative to the pointer.
167 * Thus, the pointer should point to a 32-bit aligned address. If the
168 * target system cannot address 32-bit variables on non 32-bit aligned
169 * addresses, then the pointer *must* point to a 32-bit aligned address.
170 *
171 * pPacketInfo - A pointer to the packet information structure for this
172 * packet. Before calling this SkCsGetSendInfo(), the following field must
173 * be initialized:
174 *
175 * ProtocolFlags - Initialize with any combination of
176 * SKCS_PROTO_XXX bit flags. SkCsGetSendInfo() will only work on
177 * the protocols specified here. Any protocol(s) not specified
178 * here will be ignored.
179 *
180 * Note: Only one checksum can be calculated in hardware. Thus, if
181 * SKCS_PROTO_IP is specified in the 'ProtocolFlags',
182 * SkCsGetSendInfo() must calculate the IP header checksum in
183 * software. It might be a better idea to have the calling
184 * protocol stack calculate the IP header checksum.
185 *
186 * Returns: N/A
187 * On return, the following fields in 'pPacketInfo' may or may not have
188 * been filled with information, depending on the protocol(s) found in the
189 * packet:
190 *
191 * ProtocolFlags - Returns the SKCS_PROTO_XXX bit flags of the protocol(s)
192 * that were both requested by the caller and actually found in the packet.
193 * Protocol(s) not specified by the caller and/or not found in the packet
194 * will have their respective SKCS_PROTO_XXX bit flags reset.
195 *
196 * Note: For IP fragments, TCP and UDP packet information is ignored.
197 *
198 * IpHeaderLength - The total length in bytes of the complete IP header
199 * including any option fields is returned here. This is the start offset
200 * of the IP data, i.e. the TCP or UDP header if present.
201 *
202 * IpHeaderChecksum - If IP has been specified in the 'ProtocolFlags', the
203 * 16-bit Internet Checksum of the IP header is returned here. This value
204 * is to be stored into the packet's 'IP Header Checksum' field.
205 *
206 * PseudoHeaderChecksum - If this is a TCP or UDP packet and if TCP or UDP
207 * has been specified in the 'ProtocolFlags', the 16-bit Internet Checksum
208 * of the TCP or UDP pseudo header is returned here.
209 */
210void SkCsGetSendInfo(
211SK_AC *pAc, /* Adapter context struct. */
212void *pIpHeader, /* IP header. */
213SKCS_PACKET_INFO *pPacketInfo, /* Packet information struct. */
214int NetNumber) /* Net number */
215{
216 /* Internet Header Version found in IP header. */
217 unsigned InternetHeaderVersion;
218
219 /* Length of the IP header as found in IP header. */
220 unsigned IpHeaderLength;
221
222 /* Bit field specifiying the desired/found protocols. */
223 unsigned ProtocolFlags;
224
225 /* Next level protocol identifier found in IP header. */
226 unsigned NextLevelProtocol;
227
228 /* Length of IP data portion. */
229 unsigned IpDataLength;
230
231 /* TCP/UDP pseudo header checksum. */
232 unsigned long PseudoHeaderChecksum;
233
234 /* Pointer to next level protocol statistics structure. */
235 SKCS_PROTO_STATS *NextLevelProtoStats;
236
237 /* Temporary variable. */
238 unsigned Tmp;
239
240 Tmp = *(SK_U8 *)
241 SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
242
243 /* Get the Internet Header Version (IHV). */
244 /* Note: The IHV is stored in the upper four bits. */
245
246 InternetHeaderVersion = Tmp >> 4;
247
248 /* Check the Internet Header Version. */
249 /* Note: We currently only support IP version 4. */
250
251 if (InternetHeaderVersion != 4) { /* IPv4? */
252 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
253 ("Tx: Unknown Internet Header Version %u.\n",
254 InternetHeaderVersion));
255 pPacketInfo->ProtocolFlags = 0;
256 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
257 return;
258 }
259
260 /* Get the IP header length (IHL). */
261 /*
262 * Note: The IHL is stored in the lower four bits as the number of
263 * 4-byte words.
264 */
265
266 IpHeaderLength = (Tmp & 0xf) * 4;
267 pPacketInfo->IpHeaderLength = IpHeaderLength;
268
269 /* Check the IP header length. */
270
271 /* 04-Aug-1998 sw - Really check the IHL? Necessary? */
272
273 if (IpHeaderLength < 5*4) {
274 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_TX,
275 ("Tx: Invalid IP Header Length %u.\n", IpHeaderLength));
276 pPacketInfo->ProtocolFlags = 0;
277 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxUnableCts++;
278 return;
279 }
280
281 /* This is an IPv4 frame with a header of valid length. */
282
283 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].TxOkCts++;
284
285 /* Check if we should calculate the IP header checksum. */
286
287 ProtocolFlags = pPacketInfo->ProtocolFlags;
288
289 if (ProtocolFlags & SKCS_PROTO_IP) {
290 pPacketInfo->IpHeaderChecksum =
291 SkCsCalculateChecksum(pIpHeader, IpHeaderLength);
292 }
293
294 /* Get the next level protocol identifier. */
295
296 NextLevelProtocol =
297 *(SK_U8 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
298
299 /*
300 * Check if this is a TCP or UDP frame and if we should calculate the
301 * TCP/UDP pseudo header checksum.
302 *
303 * Also clear all protocol bit flags of protocols not present in the
304 * frame.
305 */
306
307 if ((ProtocolFlags & SKCS_PROTO_TCP) != 0 &&
308 NextLevelProtocol == SKCS_PROTO_ID_TCP) {
309 /* TCP/IP frame. */
310 ProtocolFlags &= SKCS_PROTO_TCP | SKCS_PROTO_IP;
311 NextLevelProtoStats =
312 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
313 }
314 else if ((ProtocolFlags & SKCS_PROTO_UDP) != 0 &&
315 NextLevelProtocol == SKCS_PROTO_ID_UDP) {
316 /* UDP/IP frame. */
317 ProtocolFlags &= SKCS_PROTO_UDP | SKCS_PROTO_IP;
318 NextLevelProtoStats =
319 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
320 }
321 else {
322 /*
323 * Either not a TCP or UDP frame and/or TCP/UDP processing not
324 * specified.
325 */
326 pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
327 return;
328 }
329
330 /* Check if this is an IP fragment. */
331
332 /*
333 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
334 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
335 * and the "More Fragments" are zero, it is *not* a fragment. We can
336 * easily check both at the same time since they are in the same 16-bit
337 * word.
338 */
339
340 if ((*(SK_U16 *)
341 SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
342 ~SKCS_IP_DONT_FRAGMENT) != 0) {
343 /* IP fragment; ignore all other protocols. */
344 pPacketInfo->ProtocolFlags = ProtocolFlags & SKCS_PROTO_IP;
345 NextLevelProtoStats->TxUnableCts++;
346 return;
347 }
348
349 /*
350 * Calculate the TCP/UDP pseudo header checksum.
351 */
352
353 /* Get total length of IP header and data. */
354
355 IpDataLength =
356 *(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
357
358 /* Get length of IP data portion. */
359
360 IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
361
362 /* Calculate the sum of all pseudo header fields (16-bit). */
363
364 PseudoHeaderChecksum =
365 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
366 SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
367 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
368 SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
369 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
370 SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
371 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
372 SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
373 (unsigned long) SKCS_HTON16(NextLevelProtocol) +
374 (unsigned long) SKCS_HTON16(IpDataLength);
375
376 /* Add-in any carries. */
377
378 SKCS_OC_ADD(PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
379
380 /* Add-in any new carry. */
381
382 SKCS_OC_ADD(pPacketInfo->PseudoHeaderChecksum, PseudoHeaderChecksum, 0);
383
384 pPacketInfo->ProtocolFlags = ProtocolFlags;
385 NextLevelProtoStats->TxOkCts++; /* Success. */
386} /* SkCsGetSendInfo */
387
388
389/******************************************************************************
390 *
391 * SkCsGetReceiveInfo - verify checksum information for a received packet
392 *
393 * Description:
394 * Verify a received frame's checksum. The function returns a status code
395 * reflecting the result of the verification.
396 *
397 * Note:
398 * Before calling this function you have to verify that the frame is
399 * not padded and Checksum1 and Checksum2 are bigger than 1.
400 *
401 * Arguments:
402 * pAc - Pointer to adapter context struct.
403 *
404 * pIpHeader - Pointer to IP header. Must be at least the length in bytes
405 * of the received IP header including any option fields. For UDP packets,
406 * 8 additional bytes are needed to access the UDP checksum.
407 *
408 * Note: The actual length of the IP header is stored in the lower four
409 * bits of the first octet of the IP header as the number of 4-byte words,
410 * so it must be multiplied by four to get the length in bytes. Thus, the
411 * maximum IP header length is 15 * 4 = 60 bytes.
412 *
413 * Checksum1 - The first 16-bit Internet Checksum calculated by the
414 * hardware starting at the offset returned by SkCsSetReceiveFlags().
415 *
416 * Checksum2 - The second 16-bit Internet Checksum calculated by the
417 * hardware starting at the offset returned by SkCsSetReceiveFlags().
418 *
419 * Returns:
420 * SKCS_STATUS_UNKNOWN_IP_VERSION - Not an IP v4 frame.
421 * SKCS_STATUS_IP_CSUM_ERROR - IP checksum error.
422 * SKCS_STATUS_IP_CSUM_ERROR_TCP - IP checksum error in TCP frame.
423 * SKCS_STATUS_IP_CSUM_ERROR_UDP - IP checksum error in UDP frame
424 * SKCS_STATUS_IP_FRAGMENT - IP fragment (IP checksum ok).
425 * SKCS_STATUS_IP_CSUM_OK - IP checksum ok (not a TCP or UDP frame).
426 * SKCS_STATUS_TCP_CSUM_ERROR - TCP checksum error (IP checksum ok).
427 * SKCS_STATUS_UDP_CSUM_ERROR - UDP checksum error (IP checksum ok).
428 * SKCS_STATUS_TCP_CSUM_OK - IP and TCP checksum ok.
429 * SKCS_STATUS_UDP_CSUM_OK - IP and UDP checksum ok.
430 * SKCS_STATUS_IP_CSUM_OK_NO_UDP - IP checksum OK and no UDP checksum.
431 *
432 * Note: If SKCS_OVERWRITE_STATUS is defined, the SKCS_STATUS_XXX values
433 * returned here can be defined in some header file by the module using CSUM.
434 * In this way, the calling module can assign return values for its own needs,
435 * e.g. by assigning bit flags to the individual protocols.
436 */
437SKCS_STATUS SkCsGetReceiveInfo(
438SK_AC *pAc, /* Adapter context struct. */
439void *pIpHeader, /* IP header. */
440unsigned Checksum1, /* Hardware checksum 1. */
441unsigned Checksum2, /* Hardware checksum 2. */
442int NetNumber) /* Net number */
443{
444 /* Internet Header Version found in IP header. */
445 unsigned InternetHeaderVersion;
446
447 /* Length of the IP header as found in IP header. */
448 unsigned IpHeaderLength;
449
450 /* Length of IP data portion. */
451 unsigned IpDataLength;
452
453 /* IP header checksum. */
454 unsigned IpHeaderChecksum;
455
456 /* IP header options checksum, if any. */
457 unsigned IpOptionsChecksum;
458
459 /* IP data checksum, i.e. TCP/UDP checksum. */
460 unsigned IpDataChecksum;
461
462 /* Next level protocol identifier found in IP header. */
463 unsigned NextLevelProtocol;
464
465 /* The checksum of the "next level protocol", i.e. TCP or UDP. */
466 unsigned long NextLevelProtocolChecksum;
467
468 /* Pointer to next level protocol statistics structure. */
469 SKCS_PROTO_STATS *NextLevelProtoStats;
470
471 /* Temporary variable. */
472 unsigned Tmp;
473
474 Tmp = *(SK_U8 *)
475 SKCS_IDX(pIpHeader, SKCS_OFS_IP_HEADER_VERSION_AND_LENGTH);
476
477 /* Get the Internet Header Version (IHV). */
478 /* Note: The IHV is stored in the upper four bits. */
479
480 InternetHeaderVersion = Tmp >> 4;
481
482 /* Check the Internet Header Version. */
483 /* Note: We currently only support IP version 4. */
484
485 if (InternetHeaderVersion != 4) { /* IPv4? */
486 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
487 ("Rx: Unknown Internet Header Version %u.\n",
488 InternetHeaderVersion));
489 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxUnableCts++;
490 return (SKCS_STATUS_UNKNOWN_IP_VERSION);
491 }
492
493 /* Get the IP header length (IHL). */
494 /*
495 * Note: The IHL is stored in the lower four bits as the number of
496 * 4-byte words.
497 */
498
499 IpHeaderLength = (Tmp & 0xf) * 4;
500
501 /* Check the IP header length. */
502
503 /* 04-Aug-1998 sw - Really check the IHL? Necessary? */
504
505 if (IpHeaderLength < 5*4) {
506 SK_DBG_MSG(pAc, SK_DBGMOD_CSUM, SK_DBGCAT_ERR | SK_DBGCAT_RX,
507 ("Rx: Invalid IP Header Length %u.\n", IpHeaderLength));
508 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
509 return (SKCS_STATUS_IP_CSUM_ERROR);
510 }
511
512 /* This is an IPv4 frame with a header of valid length. */
513
514 /* Get the IP header and data checksum. */
515
516 IpDataChecksum = Checksum2;
517
518 /*
519 * The IP header checksum is calculated as follows:
520 *
521 * IpHeaderChecksum = Checksum1 - Checksum2
522 */
523
524 SKCS_OC_SUB(IpHeaderChecksum, Checksum1, Checksum2);
525
526 /* Check if any IP header options. */
527
528 if (IpHeaderLength > SKCS_IP_HEADER_SIZE) {
529
530 /* Get the IP options checksum. */
531
532 IpOptionsChecksum = SkCsCalculateChecksum(
533 SKCS_IDX(pIpHeader, SKCS_IP_HEADER_SIZE),
534 IpHeaderLength - SKCS_IP_HEADER_SIZE);
535
536 /* Adjust the IP header and IP data checksums. */
537
538 SKCS_OC_ADD(IpHeaderChecksum, IpHeaderChecksum, IpOptionsChecksum);
539
540 SKCS_OC_SUB(IpDataChecksum, IpDataChecksum, IpOptionsChecksum);
541 }
542
543 /*
544 * Check if the IP header checksum is ok.
545 *
546 * NOTE: We must check the IP header checksum even if the caller just wants
547 * us to check upper-layer checksums, because we cannot do any further
548 * processing of the packet without a valid IP checksum.
549 */
550
551 /* Get the next level protocol identifier. */
552
553 NextLevelProtocol = *(SK_U8 *)
554 SKCS_IDX(pIpHeader, SKCS_OFS_IP_NEXT_LEVEL_PROTOCOL);
555
556 if (IpHeaderChecksum != 0xffff) {
557 pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_IP].RxErrCts++;
558 /* the NDIS tester wants to know the upper level protocol too */
559 if (NextLevelProtocol == SKCS_PROTO_ID_TCP) {
560 return(SKCS_STATUS_IP_CSUM_ERROR_TCP);
561 }
562 else if (NextLevelProtocol == SKCS_PROTO_ID_UDP) {
563 return(SKCS_STATUS_IP_CSUM_ERROR_UDP);
564 }
565 return (SKCS_STATUS_IP_CSUM_ERROR);
566 }
567
568 /*
569 * Check if this is a TCP or UDP frame and if we should calculate the
570 * TCP/UDP pseudo header checksum.
571 *
572 * Also clear all protocol bit flags of protocols not present in the
573 * frame.
574 */
575
576 if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_TCP) != 0 &&
577 NextLevelProtocol == SKCS_PROTO_ID_TCP) {
578 /* TCP/IP frame. */
579 NextLevelProtoStats =
580 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_TCP];
581 }
582 else if ((pAc->Csum.ReceiveFlags[NetNumber] & SKCS_PROTO_UDP) != 0 &&
583 NextLevelProtocol == SKCS_PROTO_ID_UDP) {
584 /* UDP/IP frame. */
585 NextLevelProtoStats =
586 &pAc->Csum.ProtoStats[NetNumber][SKCS_PROTO_STATS_UDP];
587 }
588 else {
589 /*
590 * Either not a TCP or UDP frame and/or TCP/UDP processing not
591 * specified.
592 */
593 return (SKCS_STATUS_IP_CSUM_OK);
594 }
595
596 /* Check if this is an IP fragment. */
597
598 /*
599 * Note: An IP fragment has a non-zero "Fragment Offset" field and/or
600 * the "More Fragments" bit set. Thus, if both the "Fragment Offset"
601 * and the "More Fragments" are zero, it is *not* a fragment. We can
602 * easily check both at the same time since they are in the same 16-bit
603 * word.
604 */
605
606 if ((*(SK_U16 *)
607 SKCS_IDX(pIpHeader, SKCS_OFS_IP_FLAGS_AND_FRAGMENT_OFFSET) &
608 ~SKCS_IP_DONT_FRAGMENT) != 0) {
609 /* IP fragment; ignore all other protocols. */
610 NextLevelProtoStats->RxUnableCts++;
611 return (SKCS_STATUS_IP_FRAGMENT);
612 }
613
614 /*
615 * 08-May-2000 ra
616 *
617 * From RFC 768 (UDP)
618 * If the computed checksum is zero, it is transmitted as all ones (the
619 * equivalent in one's complement arithmetic). An all zero transmitted
620 * checksum value means that the transmitter generated no checksum (for
621 * debugging or for higher level protocols that don't care).
622 */
623
624 if (NextLevelProtocol == SKCS_PROTO_ID_UDP &&
625 *(SK_U16*)SKCS_IDX(pIpHeader, IpHeaderLength + 6) == 0x0000) {
626
627 NextLevelProtoStats->RxOkCts++;
628
629 return (SKCS_STATUS_IP_CSUM_OK_NO_UDP);
630 }
631
632 /*
633 * Calculate the TCP/UDP checksum.
634 */
635
636 /* Get total length of IP header and data. */
637
638 IpDataLength =
639 *(SK_U16 *) SKCS_IDX(pIpHeader, SKCS_OFS_IP_TOTAL_LENGTH);
640
641 /* Get length of IP data portion. */
642
643 IpDataLength = SKCS_NTOH16(IpDataLength) - IpHeaderLength;
644
645 NextLevelProtocolChecksum =
646
647 /* Calculate the pseudo header checksum. */
648
649 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
650 SKCS_OFS_IP_SOURCE_ADDRESS + 0) +
651 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
652 SKCS_OFS_IP_SOURCE_ADDRESS + 2) +
653 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
654 SKCS_OFS_IP_DESTINATION_ADDRESS + 0) +
655 (unsigned long) *(SK_U16 *) SKCS_IDX(pIpHeader,
656 SKCS_OFS_IP_DESTINATION_ADDRESS + 2) +
657 (unsigned long) SKCS_HTON16(NextLevelProtocol) +
658 (unsigned long) SKCS_HTON16(IpDataLength) +
659
660 /* Add the TCP/UDP header checksum. */
661
662 (unsigned long) IpDataChecksum;
663
664 /* Add-in any carries. */
665
666 SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
667
668 /* Add-in any new carry. */
669
670 SKCS_OC_ADD(NextLevelProtocolChecksum, NextLevelProtocolChecksum, 0);
671
672 /* Check if the TCP/UDP checksum is ok. */
673
674 if ((unsigned) NextLevelProtocolChecksum == 0xffff) {
675
676 /* TCP/UDP checksum ok. */
677
678 NextLevelProtoStats->RxOkCts++;
679
680 return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
681 SKCS_STATUS_TCP_CSUM_OK : SKCS_STATUS_UDP_CSUM_OK);
682 }
683
684 /* TCP/UDP checksum error. */
685
686 NextLevelProtoStats->RxErrCts++;
687
688 return (NextLevelProtocol == SKCS_PROTO_ID_TCP ?
689 SKCS_STATUS_TCP_CSUM_ERROR : SKCS_STATUS_UDP_CSUM_ERROR);
690} /* SkCsGetReceiveInfo */
691
692
693/******************************************************************************
694 *
695 * SkCsSetReceiveFlags - set checksum receive flags
696 *
697 * Description:
698 * Use this function to set the various receive flags. According to the
699 * protocol flags set by the caller, the start offsets within received
700 * packets of the two hardware checksums are returned. These offsets must
701 * be stored in all receive descriptors.
702 *
703 * Arguments:
704 * pAc - Pointer to adapter context struct.
705 *
706 * ReceiveFlags - Any combination of SK_PROTO_XXX flags of the protocols
707 * for which the caller wants checksum information on received frames.
708 *
709 * pChecksum1Offset - The start offset of the first receive descriptor
710 * hardware checksum to be calculated for received frames is returned
711 * here.
712 *
713 * pChecksum2Offset - The start offset of the second receive descriptor
714 * hardware checksum to be calculated for received frames is returned
715 * here.
716 *
717 * Returns: N/A
718 * Returns the two hardware checksum start offsets.
719 */
720void SkCsSetReceiveFlags(
721SK_AC *pAc, /* Adapter context struct. */
722unsigned ReceiveFlags, /* New receive flags. */
723unsigned *pChecksum1Offset, /* Offset for hardware checksum 1. */
724unsigned *pChecksum2Offset, /* Offset for hardware checksum 2. */
725int NetNumber)
726{
727 /* Save the receive flags. */
728
729 pAc->Csum.ReceiveFlags[NetNumber] = ReceiveFlags;
730
731 /* First checksum start offset is the IP header. */
732 *pChecksum1Offset = SKCS_MAC_HEADER_SIZE;
733
734 /*
735 * Second checksum start offset is the IP data. Note that this may vary
736 * if there are any IP header options in the actual packet.
737 */
738 *pChecksum2Offset = SKCS_MAC_HEADER_SIZE + SKCS_IP_HEADER_SIZE;
739} /* SkCsSetReceiveFlags */
740
741#ifndef SK_CS_CALCULATE_CHECKSUM
742
743/******************************************************************************
744 *
745 * SkCsCalculateChecksum - calculate checksum for specified data
746 *
747 * Description:
748 * Calculate and return the 16-bit Internet Checksum for the specified
749 * data.
750 *
751 * Arguments:
752 * pData - Pointer to data for which the checksum shall be calculated.
753 * Note: The pointer should be aligned on a 16-bit boundary.
754 *
755 * Length - Length in bytes of data to checksum.
756 *
757 * Returns:
758 * The 16-bit Internet Checksum for the specified data.
759 *
760 * Note: The checksum is calculated in the machine's natural byte order,
761 * i.e. little vs. big endian. Thus, the resulting checksum is different
762 * for the same input data on little and big endian machines.
763 *
764 * However, when written back to the network packet, the byte order is
765 * always in correct network order.
766 */
767unsigned SkCsCalculateChecksum(
768void *pData, /* Data to checksum. */
769unsigned Length) /* Length of data. */
770{
771 SK_U16 *pU16; /* Pointer to the data as 16-bit words. */
772 unsigned long Checksum; /* Checksum; must be at least 32 bits. */
773
774 /* Sum up all 16-bit words. */
775
776 pU16 = (SK_U16 *) pData;
777 for (Checksum = 0; Length > 1; Length -= 2) {
778 Checksum += *pU16++;
779 }
780
781 /* If this is an odd number of bytes, add-in the last byte. */
782
783 if (Length > 0) {
784#ifdef SK_BIG_ENDIAN
785 /* Add the last byte as the high byte. */
786 Checksum += ((unsigned) *(SK_U8 *) pU16) << 8;
787#else /* !SK_BIG_ENDIAN */
788 /* Add the last byte as the low byte. */
789 Checksum += *(SK_U8 *) pU16;
790#endif /* !SK_BIG_ENDIAN */
791 }
792
793 /* Add-in any carries. */
794
795 SKCS_OC_ADD(Checksum, Checksum, 0);
796
797 /* Add-in any new carry. */
798
799 SKCS_OC_ADD(Checksum, Checksum, 0);
800
801 /* Note: All bits beyond the 16-bit limit are now zero. */
802
803 return ((unsigned) Checksum);
804} /* SkCsCalculateChecksum */
805
806#endif /* SK_CS_CALCULATE_CHECKSUM */
807
808/******************************************************************************
809 *
810 * SkCsEvent - the CSUM event dispatcher
811 *
812 * Description:
813 * This is the event handler for the CSUM module.
814 *
815 * Arguments:
816 * pAc - Pointer to adapter context.
817 *
818 * Ioc - I/O context.
819 *
820 * Event - Event id.
821 *
822 * Param - Event dependent parameter.
823 *
824 * Returns:
825 * The 16-bit Internet Checksum for the specified data.
826 *
827 * Note: The checksum is calculated in the machine's natural byte order,
828 * i.e. little vs. big endian. Thus, the resulting checksum is different
829 * for the same input data on little and big endian machines.
830 *
831 * However, when written back to the network packet, the byte order is
832 * always in correct network order.
833 */
834int SkCsEvent(
835SK_AC *pAc, /* Pointer to adapter context. */
836SK_IOC Ioc, /* I/O context. */
837SK_U32 Event, /* Event id. */
838SK_EVPARA Param) /* Event dependent parameter. */
839{
840 int ProtoIndex;
841 int NetNumber;
842
843 switch (Event) {
844 /*
845 * Clear protocol statistics.
846 *
847 * Param - Protocol index, or -1 for all protocols.
848 * - Net number.
849 */
850 case SK_CSUM_EVENT_CLEAR_PROTO_STATS:
851
852 ProtoIndex = (int)Param.Para32[1];
853 NetNumber = (int)Param.Para32[0];
854 if (ProtoIndex < 0) { /* Clear for all protocols. */
855 if (NetNumber >= 0) {
856 SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][0], 0,
857 sizeof(pAc->Csum.ProtoStats[NetNumber]));
858 }
859 }
860 else { /* Clear for individual protocol. */
861 SK_MEMSET(&pAc->Csum.ProtoStats[NetNumber][ProtoIndex], 0,
862 sizeof(pAc->Csum.ProtoStats[NetNumber][ProtoIndex]));
863 }
864 break;
865 default:
866 break;
867 }
868 return (0); /* Success. */
869} /* SkCsEvent */
870
871#endif /* SK_USE_CSUM */
diff --git a/drivers/net/sk98lin/skethtool.c b/drivers/net/sk98lin/skethtool.c
index fb639959292b..b71769ae4603 100644
--- a/drivers/net/sk98lin/skethtool.c
+++ b/drivers/net/sk98lin/skethtool.c
@@ -549,4 +549,6 @@ struct ethtool_ops SkGeEthtoolOps = {
549 .phys_id = locateDevice, 549 .phys_id = locateDevice,
550 .get_pauseparam = getPauseParams, 550 .get_pauseparam = getPauseParams,
551 .set_pauseparam = setPauseParams, 551 .set_pauseparam = setPauseParams,
552 .get_link = ethtool_op_get_link,
553 .get_perm_addr = ethtool_op_get_perm_addr,
552}; 554};
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index b18c92cb629e..ae7343934758 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -101,7 +101,6 @@
101 * "h/skgeinit.h" 101 * "h/skgeinit.h"
102 * "h/skaddr.h" 102 * "h/skaddr.h"
103 * "h/skgesirq.h" 103 * "h/skgesirq.h"
104 * "h/skcsum.h"
105 * "h/skrlmt.h" 104 * "h/skrlmt.h"
106 * 105 *
107 ******************************************************************************/ 106 ******************************************************************************/
@@ -113,6 +112,7 @@
113#include <linux/init.h> 112#include <linux/init.h>
114#include <linux/proc_fs.h> 113#include <linux/proc_fs.h>
115#include <linux/dma-mapping.h> 114#include <linux/dma-mapping.h>
115#include <linux/ip.h>
116 116
117#include "h/skdrv1st.h" 117#include "h/skdrv1st.h"
118#include "h/skdrv2nd.h" 118#include "h/skdrv2nd.h"
@@ -601,11 +601,6 @@ SK_BOOL DualNet;
601 return(-EAGAIN); 601 return(-EAGAIN);
602 } 602 }
603 603
604 SkCsSetReceiveFlags(pAC,
605 SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
606 &pAC->CsOfs1, &pAC->CsOfs2, 0);
607 pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
608
609 BoardInitMem(pAC); 604 BoardInitMem(pAC);
610 /* tschilling: New common function with minimum size check. */ 605 /* tschilling: New common function with minimum size check. */
611 DualNet = SK_FALSE; 606 DualNet = SK_FALSE;
@@ -823,7 +818,7 @@ uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */
823 /* set the pointers right */ 818 /* set the pointers right */
824 pDescr->VNextRxd = VNextDescr & 0xffffffffULL; 819 pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
825 pDescr->pNextRxd = pNextDescr; 820 pDescr->pNextRxd = pNextDescr;
826 pDescr->TcpSumStarts = pAC->CsOfs; 821 if (!IsTx) pDescr->TcpSumStarts = ETH_HLEN << 16 | ETH_HLEN;
827 822
828 /* advance one step */ 823 /* advance one step */
829 pPrevDescr = pDescr; 824 pPrevDescr = pDescr;
@@ -1505,8 +1500,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1505 TXD *pOldTxd; 1500 TXD *pOldTxd;
1506 unsigned long Flags; 1501 unsigned long Flags;
1507 SK_U64 PhysAddr; 1502 SK_U64 PhysAddr;
1508 int Protocol;
1509 int IpHeaderLength;
1510 int BytesSend = pMessage->len; 1503 int BytesSend = pMessage->len;
1511 1504
1512 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X")); 1505 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X"));
@@ -1579,8 +1572,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1579 pTxd->pMBuf = pMessage; 1572 pTxd->pMBuf = pMessage;
1580 1573
1581 if (pMessage->ip_summed == CHECKSUM_HW) { 1574 if (pMessage->ip_summed == CHECKSUM_HW) {
1582 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1575 u16 hdrlen = pMessage->h.raw - pMessage->data;
1583 if ((Protocol == C_PROTO_ID_UDP) && 1576 u16 offset = hdrlen + pMessage->csum;
1577
1578 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1584 (pAC->GIni.GIChipRev == 0) && 1579 (pAC->GIni.GIChipRev == 0) &&
1585 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1580 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1586 pTxd->TBControl = BMU_TCP_CHECK; 1581 pTxd->TBControl = BMU_TCP_CHECK;
@@ -1588,14 +1583,9 @@ struct sk_buff *pMessage) /* pointer to send-message */
1588 pTxd->TBControl = BMU_UDP_CHECK; 1583 pTxd->TBControl = BMU_UDP_CHECK;
1589 } 1584 }
1590 1585
1591 IpHeaderLength = (SK_U8)pMessage->data[C_OFFSET_IPHEADER]; 1586 pTxd->TcpSumOfs = 0;
1592 IpHeaderLength = (IpHeaderLength & 0xf) * 4; 1587 pTxd->TcpSumSt = hdrlen;
1593 pTxd->TcpSumOfs = 0; /* PH-Checksum already calculated */ 1588 pTxd->TcpSumWr = offset;
1594 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength +
1595 (Protocol == C_PROTO_ID_UDP ?
1596 C_OFFSET_UDPHEADER_UDPCS :
1597 C_OFFSET_TCPHEADER_TCPCS);
1598 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength;
1599 1589
1600 pTxd->TBControl |= BMU_OWN | BMU_STF | 1590 pTxd->TBControl |= BMU_OWN | BMU_STF |
1601 BMU_SW | BMU_EOF | 1591 BMU_SW | BMU_EOF |
@@ -1658,11 +1648,10 @@ struct sk_buff *pMessage) /* pointer to send-message */
1658 TXD *pTxdLst; 1648 TXD *pTxdLst;
1659 int CurrFrag; 1649 int CurrFrag;
1660 int BytesSend; 1650 int BytesSend;
1661 int IpHeaderLength;
1662 int Protocol;
1663 skb_frag_t *sk_frag; 1651 skb_frag_t *sk_frag;
1664 SK_U64 PhysAddr; 1652 SK_U64 PhysAddr;
1665 unsigned long Flags; 1653 unsigned long Flags;
1654 SK_U32 Control;
1666 1655
1667 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags); 1656 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
1668#ifndef USE_TX_COMPLETE 1657#ifndef USE_TX_COMPLETE
@@ -1685,7 +1674,6 @@ struct sk_buff *pMessage) /* pointer to send-message */
1685 pTxdFst = pTxd; 1674 pTxdFst = pTxd;
1686 pTxdLst = pTxd; 1675 pTxdLst = pTxd;
1687 BytesSend = 0; 1676 BytesSend = 0;
1688 Protocol = 0;
1689 1677
1690 /* 1678 /*
1691 ** Map the first fragment (header) into the DMA-space 1679 ** Map the first fragment (header) into the DMA-space
@@ -1703,32 +1691,31 @@ struct sk_buff *pMessage) /* pointer to send-message */
1703 ** Does the HW need to evaluate checksum for TCP or UDP packets? 1691 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1704 */ 1692 */
1705 if (pMessage->ip_summed == CHECKSUM_HW) { 1693 if (pMessage->ip_summed == CHECKSUM_HW) {
1706 pTxd->TBControl = BMU_STF | BMU_STFWD | skb_headlen(pMessage); 1694 u16 hdrlen = pMessage->h.raw - pMessage->data;
1695 u16 offset = hdrlen + pMessage->csum;
1696
1697 Control = BMU_STFWD;
1698
1707 /* 1699 /*
1708 ** We have to use the opcode for tcp here, because the 1700 ** We have to use the opcode for tcp here, because the
1709 ** opcode for udp is not working in the hardware yet 1701 ** opcode for udp is not working in the hardware yet
1710 ** (Revision 2.0) 1702 ** (Revision 2.0)
1711 */ 1703 */
1712 Protocol = ((SK_U8)pMessage->data[C_OFFSET_IPPROTO] & 0xff); 1704 if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) &&
1713 if ((Protocol == C_PROTO_ID_UDP) &&
1714 (pAC->GIni.GIChipRev == 0) && 1705 (pAC->GIni.GIChipRev == 0) &&
1715 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { 1706 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1716 pTxd->TBControl |= BMU_TCP_CHECK; 1707 Control |= BMU_TCP_CHECK;
1717 } else { 1708 } else {
1718 pTxd->TBControl |= BMU_UDP_CHECK; 1709 Control |= BMU_UDP_CHECK;
1719 } 1710 }
1720 1711
1721 IpHeaderLength = ((SK_U8)pMessage->data[C_OFFSET_IPHEADER] & 0xf)*4; 1712 pTxd->TcpSumOfs = 0;
1722 pTxd->TcpSumOfs = 0; /* PH-Checksum already claculated */ 1713 pTxd->TcpSumSt = hdrlen;
1723 pTxd->TcpSumSt = C_LEN_ETHERMAC_HEADER + IpHeaderLength + 1714 pTxd->TcpSumWr = offset;
1724 (Protocol == C_PROTO_ID_UDP ? 1715 } else
1725 C_OFFSET_UDPHEADER_UDPCS : 1716 Control = BMU_CHECK | BMU_SW;
1726 C_OFFSET_TCPHEADER_TCPCS); 1717
1727 pTxd->TcpSumWr = C_LEN_ETHERMAC_HEADER + IpHeaderLength; 1718 pTxd->TBControl = BMU_STF | Control | skb_headlen(pMessage);
1728 } else {
1729 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_STF |
1730 skb_headlen(pMessage);
1731 }
1732 1719
1733 pTxd = pTxd->pNextTxd; 1720 pTxd = pTxd->pNextTxd;
1734 pTxPort->TxdRingFree--; 1721 pTxPort->TxdRingFree--;
@@ -1752,40 +1739,18 @@ struct sk_buff *pMessage) /* pointer to send-message */
1752 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); 1739 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
1753 pTxd->pMBuf = pMessage; 1740 pTxd->pMBuf = pMessage;
1754 1741
1755 /* 1742 pTxd->TBControl = Control | BMU_OWN | sk_frag->size;;
1756 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1757 */
1758 if (pMessage->ip_summed == CHECKSUM_HW) {
1759 pTxd->TBControl = BMU_OWN | BMU_SW | BMU_STFWD;
1760 /*
1761 ** We have to use the opcode for tcp here because the
1762 ** opcode for udp is not working in the hardware yet
1763 ** (revision 2.0)
1764 */
1765 if ((Protocol == C_PROTO_ID_UDP) &&
1766 (pAC->GIni.GIChipRev == 0) &&
1767 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
1768 pTxd->TBControl |= BMU_TCP_CHECK;
1769 } else {
1770 pTxd->TBControl |= BMU_UDP_CHECK;
1771 }
1772 } else {
1773 pTxd->TBControl = BMU_CHECK | BMU_SW | BMU_OWN;
1774 }
1775 1743
1776 /* 1744 /*
1777 ** Do we have the last fragment? 1745 ** Do we have the last fragment?
1778 */ 1746 */
1779 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) { 1747 if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) {
1780#ifdef USE_TX_COMPLETE 1748#ifdef USE_TX_COMPLETE
1781 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF | sk_frag->size; 1749 pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF;
1782#else 1750#else
1783 pTxd->TBControl |= BMU_EOF | sk_frag->size; 1751 pTxd->TBControl |= BMU_EOF;
1784#endif 1752#endif
1785 pTxdFst->TBControl |= BMU_OWN | BMU_SW; 1753 pTxdFst->TBControl |= BMU_OWN | BMU_SW;
1786
1787 } else {
1788 pTxd->TBControl |= sk_frag->size;
1789 } 1754 }
1790 pTxdLst = pTxd; 1755 pTxdLst = pTxd;
1791 pTxd = pTxd->pNextTxd; 1756 pTxd = pTxd->pNextTxd;
@@ -2032,7 +1997,6 @@ SK_U32 Control; /* control field of descriptor */
2032struct sk_buff *pMsg; /* pointer to message holding frame */ 1997struct sk_buff *pMsg; /* pointer to message holding frame */
2033struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */ 1998struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */
2034int FrameLength; /* total length of received frame */ 1999int FrameLength; /* total length of received frame */
2035int IpFrameLength;
2036SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */ 2000SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */
2037SK_EVPARA EvPara; /* an event parameter union */ 2001SK_EVPARA EvPara; /* an event parameter union */
2038unsigned long Flags; /* for spin lock */ 2002unsigned long Flags; /* for spin lock */
@@ -2045,10 +2009,6 @@ SK_BOOL IsMc;
2045SK_BOOL IsBadFrame; /* Bad frame */ 2009SK_BOOL IsBadFrame; /* Bad frame */
2046 2010
2047SK_U32 FrameStat; 2011SK_U32 FrameStat;
2048unsigned short Csum1;
2049unsigned short Csum2;
2050unsigned short Type;
2051int Result;
2052SK_U64 PhysAddr; 2012SK_U64 PhysAddr;
2053 2013
2054rx_start: 2014rx_start:
@@ -2177,8 +2137,8 @@ rx_start:
2177 (dma_addr_t) PhysAddr, 2137 (dma_addr_t) PhysAddr,
2178 FrameLength, 2138 FrameLength,
2179 PCI_DMA_FROMDEVICE); 2139 PCI_DMA_FROMDEVICE);
2180 eth_copy_and_sum(pNewMsg, pMsg->data, 2140 memcpy(pNewMsg->data, pMsg, FrameLength);
2181 FrameLength, 0); 2141
2182 pci_dma_sync_single_for_device(pAC->PciDev, 2142 pci_dma_sync_single_for_device(pAC->PciDev,
2183 (dma_addr_t) PhysAddr, 2143 (dma_addr_t) PhysAddr,
2184 FrameLength, 2144 FrameLength,
@@ -2206,69 +2166,16 @@ rx_start:
2206 2166
2207 /* set length in message */ 2167 /* set length in message */
2208 skb_put(pMsg, FrameLength); 2168 skb_put(pMsg, FrameLength);
2209 /* hardware checksum */ 2169 } /* frame > SK_COPY_TRESHOLD */
2210 Type = ntohs(*((short*)&pMsg->data[12]));
2211 2170
2212#ifdef USE_SK_RX_CHECKSUM 2171#ifdef USE_SK_RX_CHECKSUM
2213 if (Type == 0x800) { 2172 pMsg->csum = pRxd->TcpSums & 0xffff;
2214 Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff); 2173 pMsg->ip_summed = CHECKSUM_HW;
2215 Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
2216 IpFrameLength = (int) ntohs((unsigned short)
2217 ((unsigned short *) pMsg->data)[8]);
2218
2219 /*
2220 * Test: If frame is padded, a check is not possible!
2221 * Frame not padded? Length difference must be 14 (0xe)!
2222 */
2223 if ((FrameLength - IpFrameLength) != 0xe) {
2224 /* Frame padded => TCP offload not possible! */
2225 pMsg->ip_summed = CHECKSUM_NONE;
2226 } else {
2227 /* Frame not padded => TCP offload! */
2228 if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
2229 (pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
2230 (pAC->ChipsetType)) {
2231 Result = SkCsGetReceiveInfo(pAC,
2232 &pMsg->data[14],
2233 Csum1, Csum2, pRxPort->PortIndex);
2234 if (Result ==
2235 SKCS_STATUS_IP_FRAGMENT ||
2236 Result ==
2237 SKCS_STATUS_IP_CSUM_OK ||
2238 Result ==
2239 SKCS_STATUS_TCP_CSUM_OK ||
2240 Result ==
2241 SKCS_STATUS_UDP_CSUM_OK) {
2242 pMsg->ip_summed =
2243 CHECKSUM_UNNECESSARY;
2244 }
2245 else if (Result ==
2246 SKCS_STATUS_TCP_CSUM_ERROR ||
2247 Result ==
2248 SKCS_STATUS_UDP_CSUM_ERROR ||
2249 Result ==
2250 SKCS_STATUS_IP_CSUM_ERROR_UDP ||
2251 Result ==
2252 SKCS_STATUS_IP_CSUM_ERROR_TCP ||
2253 Result ==
2254 SKCS_STATUS_IP_CSUM_ERROR ) {
2255 /* HW Checksum error */
2256 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2257 SK_DBGCAT_DRV_RX_PROGRESS,
2258 ("skge: CRC error. Frame dropped!\n"));
2259 goto rx_failed;
2260 } else {
2261 pMsg->ip_summed =
2262 CHECKSUM_NONE;
2263 }
2264 }/* checksumControl calculation valid */
2265 } /* Frame length check */
2266 } /* IP frame */
2267#else 2174#else
2268 pMsg->ip_summed = CHECKSUM_NONE; 2175 pMsg->ip_summed = CHECKSUM_NONE;
2269#endif 2176#endif
2270 } /* frame > SK_COPY_TRESHOLD */ 2177
2271 2178
2272 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V")); 2179 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V"));
2273 ForRlmt = SK_RLMT_RX_PROTOCOL; 2180 ForRlmt = SK_RLMT_RX_PROTOCOL;
2274#if 0 2181#if 0
@@ -4946,7 +4853,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4946 dev->irq = pdev->irq; 4853 dev->irq = pdev->irq;
4947 error = SkGeInitPCI(pAC); 4854 error = SkGeInitPCI(pAC);
4948 if (error) { 4855 if (error) {
4949 printk("SKGE: PCI setup failed: %i\n", error); 4856 printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error);
4950 goto out_free_netdev; 4857 goto out_free_netdev;
4951 } 4858 }
4952 4859
@@ -4982,7 +4889,7 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
4982 4889
4983 /* Register net device */ 4890 /* Register net device */
4984 if (register_netdev(dev)) { 4891 if (register_netdev(dev)) {
4985 printk(KERN_ERR "SKGE: Could not register device.\n"); 4892 printk(KERN_ERR "sk98lin: Could not register device.\n");
4986 goto out_free_resources; 4893 goto out_free_resources;
4987 } 4894 }
4988 4895
@@ -5001,8 +4908,8 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5001 4908
5002 SkGeYellowLED(pAC, pAC->IoBase, 1); 4909 SkGeYellowLED(pAC, pAC->IoBase, 1);
5003 4910
5004
5005 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); 4911 memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6);
4912 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5006 4913
5007 SkGeProcCreate(dev); 4914 SkGeProcCreate(dev);
5008 4915
@@ -5048,13 +4955,14 @@ static int __devinit skge_probe_one(struct pci_dev *pdev,
5048#endif 4955#endif
5049 4956
5050 if (register_netdev(dev)) { 4957 if (register_netdev(dev)) {
5051 printk(KERN_ERR "SKGE: Could not register device.\n"); 4958 printk(KERN_ERR "sk98lin: Could not register device for seconf port.\n");
5052 free_netdev(dev); 4959 free_netdev(dev);
5053 pAC->dev[1] = pAC->dev[0]; 4960 pAC->dev[1] = pAC->dev[0];
5054 } else { 4961 } else {
5055 SkGeProcCreate(dev); 4962 SkGeProcCreate(dev);
5056 memcpy(&dev->dev_addr, 4963 memcpy(&dev->dev_addr,
5057 &pAC->Addr.Net[1].CurrentMacAddress, 6); 4964 &pAC->Addr.Net[1].CurrentMacAddress, 6);
4965 memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
5058 4966
5059 printk("%s: %s\n", dev->name, pAC->DeviceStr); 4967 printk("%s: %s\n", dev->name, pAC->DeviceStr);
5060 printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); 4968 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 596c93b12daa..00d683063c01 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -2280,11 +2280,13 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2280 } 2280 }
2281 2281
2282 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) { 2282 if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) {
2283 netif_stop_queue(dev); 2283 if (!netif_queue_stopped(dev)) {
2284 spin_unlock_irqrestore(&skge->tx_lock, flags); 2284 netif_stop_queue(dev);
2285 2285
2286 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n", 2286 printk(KERN_WARNING PFX "%s: ring full when queue awake!\n",
2287 dev->name); 2287 dev->name);
2288 }
2289 spin_unlock_irqrestore(&skge->tx_lock, flags);
2288 return NETDEV_TX_BUSY; 2290 return NETDEV_TX_BUSY;
2289 } 2291 }
2290 2292
@@ -2300,14 +2302,12 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
2300 td->dma_hi = map >> 32; 2302 td->dma_hi = map >> 32;
2301 2303
2302 if (skb->ip_summed == CHECKSUM_HW) { 2304 if (skb->ip_summed == CHECKSUM_HW) {
2303 const struct iphdr *ip
2304 = (const struct iphdr *) (skb->data + ETH_HLEN);
2305 int offset = skb->h.raw - skb->data; 2305 int offset = skb->h.raw - skb->data;
2306 2306
2307 /* This seems backwards, but it is what the sk98lin 2307 /* This seems backwards, but it is what the sk98lin
2308 * does. Looks like hardware is wrong? 2308 * does. Looks like hardware is wrong?
2309 */ 2309 */
2310 if (ip->protocol == IPPROTO_UDP 2310 if (skb->h.ipiph->protocol == IPPROTO_UDP
2311 && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON) 2311 && hw->chip_rev == 0 && hw->chip_id == CHIP_ID_YUKON)
2312 control = BMU_TCP_CHECK; 2312 control = BMU_TCP_CHECK;
2313 else 2313 else
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 74d5f1a6fdea..28bf2e69eb5e 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -155,6 +155,12 @@ MODULE_LICENSE("GPL");
155#define MEMORY_WAIT_TIME 16 155#define MEMORY_WAIT_TIME 16
156 156
157/* 157/*
158 * The maximum number of processing loops allowed for each call to the
159 * IRQ handler.
160 */
161#define MAX_IRQ_LOOPS 8
162
163/*
158 * This selects whether TX packets are sent one by one to the SMC91x internal 164 * This selects whether TX packets are sent one by one to the SMC91x internal
159 * memory and throttled until transmission completes. This may prevent 165 * memory and throttled until transmission completes. This may prevent
160 * RX overruns a litle by keeping much of the memory free for RX packets 166 * RX overruns a litle by keeping much of the memory free for RX packets
@@ -684,7 +690,6 @@ static void smc_hardware_send_pkt(unsigned long data)
684 690
685 /* queue the packet for TX */ 691 /* queue the packet for TX */
686 SMC_SET_MMU_CMD(MC_ENQUEUE); 692 SMC_SET_MMU_CMD(MC_ENQUEUE);
687 SMC_ACK_INT(IM_TX_EMPTY_INT);
688 smc_special_unlock(&lp->lock); 693 smc_special_unlock(&lp->lock);
689 694
690 dev->trans_start = jiffies; 695 dev->trans_start = jiffies;
@@ -1207,6 +1212,7 @@ static void smc_phy_configure(void *data)
1207 smc_phy_check_media(dev, 1); 1212 smc_phy_check_media(dev, 1);
1208 1213
1209smc_phy_configure_exit: 1214smc_phy_configure_exit:
1215 SMC_SELECT_BANK(2);
1210 spin_unlock_irq(&lp->lock); 1216 spin_unlock_irq(&lp->lock);
1211 lp->work_pending = 0; 1217 lp->work_pending = 0;
1212} 1218}
@@ -1305,7 +1311,7 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1305 SMC_SET_INT_MASK(0); 1311 SMC_SET_INT_MASK(0);
1306 1312
1307 /* set a timeout value, so I don't stay here forever */ 1313 /* set a timeout value, so I don't stay here forever */
1308 timeout = 8; 1314 timeout = MAX_IRQ_LOOPS;
1309 1315
1310 do { 1316 do {
1311 status = SMC_GET_INT(); 1317 status = SMC_GET_INT();
@@ -1372,10 +1378,13 @@ static irqreturn_t smc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1372 /* restore register states */ 1378 /* restore register states */
1373 SMC_SET_PTR(saved_pointer); 1379 SMC_SET_PTR(saved_pointer);
1374 SMC_SET_INT_MASK(mask); 1380 SMC_SET_INT_MASK(mask);
1375
1376 spin_unlock(&lp->lock); 1381 spin_unlock(&lp->lock);
1377 1382
1378 DBG(3, "%s: Interrupt done (%d loops)\n", dev->name, 8-timeout); 1383 if (timeout == MAX_IRQ_LOOPS)
1384 PRINTK("%s: spurious interrupt (mask = 0x%02x)\n",
1385 dev->name, mask);
1386 DBG(3, "%s: Interrupt done (%d loops)\n",
1387 dev->name, MAX_IRQ_LOOPS - timeout);
1379 1388
1380 /* 1389 /*
1381 * We return IRQ_HANDLED unconditionally here even if there was 1390 * We return IRQ_HANDLED unconditionally here even if there was
@@ -2183,9 +2192,8 @@ static void smc_release_datacs(struct platform_device *pdev, struct net_device *
2183 * 0 --> there is a device 2192 * 0 --> there is a device
2184 * anything else, error 2193 * anything else, error
2185 */ 2194 */
2186static int smc_drv_probe(struct device *dev) 2195static int smc_drv_probe(struct platform_device *pdev)
2187{ 2196{
2188 struct platform_device *pdev = to_platform_device(dev);
2189 struct net_device *ndev; 2197 struct net_device *ndev;
2190 struct resource *res; 2198 struct resource *res;
2191 unsigned int __iomem *addr; 2199 unsigned int __iomem *addr;
@@ -2212,7 +2220,7 @@ static int smc_drv_probe(struct device *dev)
2212 goto out_release_io; 2220 goto out_release_io;
2213 } 2221 }
2214 SET_MODULE_OWNER(ndev); 2222 SET_MODULE_OWNER(ndev);
2215 SET_NETDEV_DEV(ndev, dev); 2223 SET_NETDEV_DEV(ndev, &pdev->dev);
2216 2224
2217 ndev->dma = (unsigned char)-1; 2225 ndev->dma = (unsigned char)-1;
2218 ndev->irq = platform_get_irq(pdev, 0); 2226 ndev->irq = platform_get_irq(pdev, 0);
@@ -2233,7 +2241,7 @@ static int smc_drv_probe(struct device *dev)
2233 goto out_release_attrib; 2241 goto out_release_attrib;
2234 } 2242 }
2235 2243
2236 dev_set_drvdata(dev, ndev); 2244 platform_set_drvdata(pdev, ndev);
2237 ret = smc_probe(ndev, addr); 2245 ret = smc_probe(ndev, addr);
2238 if (ret != 0) 2246 if (ret != 0)
2239 goto out_iounmap; 2247 goto out_iounmap;
@@ -2249,7 +2257,7 @@ static int smc_drv_probe(struct device *dev)
2249 return 0; 2257 return 0;
2250 2258
2251 out_iounmap: 2259 out_iounmap:
2252 dev_set_drvdata(dev, NULL); 2260 platform_set_drvdata(pdev, NULL);
2253 iounmap(addr); 2261 iounmap(addr);
2254 out_release_attrib: 2262 out_release_attrib:
2255 smc_release_attrib(pdev); 2263 smc_release_attrib(pdev);
@@ -2263,14 +2271,13 @@ static int smc_drv_probe(struct device *dev)
2263 return ret; 2271 return ret;
2264} 2272}
2265 2273
2266static int smc_drv_remove(struct device *dev) 2274static int smc_drv_remove(struct platform_device *pdev)
2267{ 2275{
2268 struct platform_device *pdev = to_platform_device(dev); 2276 struct net_device *ndev = platform_get_drvdata(pdev);
2269 struct net_device *ndev = dev_get_drvdata(dev);
2270 struct smc_local *lp = netdev_priv(ndev); 2277 struct smc_local *lp = netdev_priv(ndev);
2271 struct resource *res; 2278 struct resource *res;
2272 2279
2273 dev_set_drvdata(dev, NULL); 2280 platform_set_drvdata(pdev, NULL);
2274 2281
2275 unregister_netdev(ndev); 2282 unregister_netdev(ndev);
2276 2283
@@ -2295,9 +2302,9 @@ static int smc_drv_remove(struct device *dev)
2295 return 0; 2302 return 0;
2296} 2303}
2297 2304
2298static int smc_drv_suspend(struct device *dev, pm_message_t state) 2305static int smc_drv_suspend(struct platform_device *dev, pm_message_t state)
2299{ 2306{
2300 struct net_device *ndev = dev_get_drvdata(dev); 2307 struct net_device *ndev = platform_get_drvdata(dev);
2301 2308
2302 if (ndev) { 2309 if (ndev) {
2303 if (netif_running(ndev)) { 2310 if (netif_running(ndev)) {
@@ -2309,14 +2316,13 @@ static int smc_drv_suspend(struct device *dev, pm_message_t state)
2309 return 0; 2316 return 0;
2310} 2317}
2311 2318
2312static int smc_drv_resume(struct device *dev) 2319static int smc_drv_resume(struct platform_device *dev)
2313{ 2320{
2314 struct platform_device *pdev = to_platform_device(dev); 2321 struct net_device *ndev = platform_get_drvdata(dev);
2315 struct net_device *ndev = dev_get_drvdata(dev);
2316 2322
2317 if (ndev) { 2323 if (ndev) {
2318 struct smc_local *lp = netdev_priv(ndev); 2324 struct smc_local *lp = netdev_priv(ndev);
2319 smc_enable_device(pdev); 2325 smc_enable_device(dev);
2320 if (netif_running(ndev)) { 2326 if (netif_running(ndev)) {
2321 smc_reset(ndev); 2327 smc_reset(ndev);
2322 smc_enable(ndev); 2328 smc_enable(ndev);
@@ -2328,13 +2334,14 @@ static int smc_drv_resume(struct device *dev)
2328 return 0; 2334 return 0;
2329} 2335}
2330 2336
2331static struct device_driver smc_driver = { 2337static struct platform_driver smc_driver = {
2332 .name = CARDNAME,
2333 .bus = &platform_bus_type,
2334 .probe = smc_drv_probe, 2338 .probe = smc_drv_probe,
2335 .remove = smc_drv_remove, 2339 .remove = smc_drv_remove,
2336 .suspend = smc_drv_suspend, 2340 .suspend = smc_drv_suspend,
2337 .resume = smc_drv_resume, 2341 .resume = smc_drv_resume,
2342 .driver = {
2343 .name = CARDNAME,
2344 },
2338}; 2345};
2339 2346
2340static int __init smc_init(void) 2347static int __init smc_init(void)
@@ -2348,12 +2355,12 @@ static int __init smc_init(void)
2348#endif 2355#endif
2349#endif 2356#endif
2350 2357
2351 return driver_register(&smc_driver); 2358 return platform_driver_register(&smc_driver);
2352} 2359}
2353 2360
2354static void __exit smc_cleanup(void) 2361static void __exit smc_cleanup(void)
2355{ 2362{
2356 driver_unregister(&smc_driver); 2363 platform_driver_unregister(&smc_driver);
2357} 2364}
2358 2365
2359module_init(smc_init); 2366module_init(smc_init);
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h
index 817f200742c3..5c2824be4ee6 100644
--- a/drivers/net/smc91x.h
+++ b/drivers/net/smc91x.h
@@ -100,14 +100,14 @@
100#define SMC_IO_SHIFT 0 100#define SMC_IO_SHIFT 0
101#define SMC_NOWAIT 1 101#define SMC_NOWAIT 1
102 102
103#define SMC_inb(a, r) inb((a) + (r)) 103#define SMC_inb(a, r) readb((a) + (r))
104#define SMC_insb(a, r, p, l) insb((a) + (r), p, (l)) 104#define SMC_insb(a, r, p, l) readsb((a) + (r), p, (l))
105#define SMC_inw(a, r) inw((a) + (r)) 105#define SMC_inw(a, r) readw((a) + (r))
106#define SMC_insw(a, r, p, l) insw((a) + (r), p, l) 106#define SMC_insw(a, r, p, l) readsw((a) + (r), p, l)
107#define SMC_outb(v, a, r) outb(v, (a) + (r)) 107#define SMC_outb(v, a, r) writeb(v, (a) + (r))
108#define SMC_outsb(a, r, p, l) outsb((a) + (r), p, (l)) 108#define SMC_outsb(a, r, p, l) writesb((a) + (r), p, (l))
109#define SMC_outw(v, a, r) outw(v, (a) + (r)) 109#define SMC_outw(v, a, r) writew(v, (a) + (r))
110#define SMC_outsw(a, r, p, l) outsw((a) + (r), p, l) 110#define SMC_outsw(a, r, p, l) writesw((a) + (r), p, l)
111 111
112#define set_irq_type(irq, type) do {} while (0) 112#define set_irq_type(irq, type) do {} while (0)
113 113
@@ -289,6 +289,38 @@ static inline void SMC_outsw (unsigned long a, int r, unsigned char* p, int l)
289#define RPC_LSA_DEFAULT RPC_LED_TX_RX 289#define RPC_LSA_DEFAULT RPC_LED_TX_RX
290#define RPC_LSB_DEFAULT RPC_LED_100_10 290#define RPC_LSB_DEFAULT RPC_LED_100_10
291 291
292#elif defined(CONFIG_SOC_AU1X00)
293
294#include <au1xxx.h>
295
296/* We can only do 16-bit reads and writes in the static memory space. */
297#define SMC_CAN_USE_8BIT 0
298#define SMC_CAN_USE_16BIT 1
299#define SMC_CAN_USE_32BIT 0
300#define SMC_IO_SHIFT 0
301#define SMC_NOWAIT 1
302
303#define SMC_inw(a, r) au_readw((unsigned long)((a) + (r)))
304#define SMC_insw(a, r, p, l) \
305 do { \
306 unsigned long _a = (unsigned long)((a) + (r)); \
307 int _l = (l); \
308 u16 *_p = (u16 *)(p); \
309 while (_l-- > 0) \
310 *_p++ = au_readw(_a); \
311 } while(0)
312#define SMC_outw(v, a, r) au_writew(v, (unsigned long)((a) + (r)))
313#define SMC_outsw(a, r, p, l) \
314 do { \
315 unsigned long _a = (unsigned long)((a) + (r)); \
316 int _l = (l); \
317 const u16 *_p = (const u16 *)(p); \
318 while (_l-- > 0) \
319 au_writew(*_p++ , _a); \
320 } while(0)
321
322#define set_irq_type(irq, type) do {} while (0)
323
292#else 324#else
293 325
294#define SMC_CAN_USE_8BIT 1 326#define SMC_CAN_USE_8BIT 1
diff --git a/drivers/net/spider_net.c b/drivers/net/spider_net.c
index c796f41b4a52..0d765f1733b5 100644
--- a/drivers/net/spider_net.c
+++ b/drivers/net/spider_net.c
@@ -2290,7 +2290,6 @@ spider_net_remove(struct pci_dev *pdev)
2290} 2290}
2291 2291
2292static struct pci_driver spider_net_driver = { 2292static struct pci_driver spider_net_driver = {
2293 .owner = THIS_MODULE,
2294 .name = spider_net_driver_name, 2293 .name = spider_net_driver_name,
2295 .id_table = spider_net_pci_tbl, 2294 .id_table = spider_net_pci_tbl,
2296 .probe = spider_net_probe, 2295 .probe = spider_net_probe,
diff --git a/drivers/net/sungem.c b/drivers/net/sungem.c
index de399563a9db..28ce47a02408 100644
--- a/drivers/net/sungem.c
+++ b/drivers/net/sungem.c
@@ -128,6 +128,8 @@ static struct pci_device_id gem_pci_tbl[] = {
128 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 128 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
129 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_SUNGEM, 129 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_SH_SUNGEM,
130 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 130 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
131 { PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_IPID2_GMAC,
132 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
131 {0, } 133 {0, }
132}; 134};
133 135
@@ -2905,7 +2907,7 @@ static int __devinit gem_get_device_address(struct gem *gp)
2905 return 0; 2907 return 0;
2906} 2908}
2907 2909
2908static void __devexit gem_remove_one(struct pci_dev *pdev) 2910static void gem_remove_one(struct pci_dev *pdev)
2909{ 2911{
2910 struct net_device *dev = pci_get_drvdata(pdev); 2912 struct net_device *dev = pci_get_drvdata(pdev);
2911 2913
@@ -3179,7 +3181,7 @@ static struct pci_driver gem_driver = {
3179 .name = GEM_MODULE_NAME, 3181 .name = GEM_MODULE_NAME,
3180 .id_table = gem_pci_tbl, 3182 .id_table = gem_pci_tbl,
3181 .probe = gem_init_one, 3183 .probe = gem_init_one,
3182 .remove = __devexit_p(gem_remove_one), 3184 .remove = gem_remove_one,
3183#ifdef CONFIG_PM 3185#ifdef CONFIG_PM
3184 .suspend = gem_suspend, 3186 .suspend = gem_suspend,
3185 .resume = gem_resume, 3187 .resume = gem_resume,
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 1828a6bf8458..2fc9893d69e1 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -68,8 +68,8 @@
68 68
69#define DRV_MODULE_NAME "tg3" 69#define DRV_MODULE_NAME "tg3"
70#define PFX DRV_MODULE_NAME ": " 70#define PFX DRV_MODULE_NAME ": "
71#define DRV_MODULE_VERSION "3.43" 71#define DRV_MODULE_VERSION "3.47"
72#define DRV_MODULE_RELDATE "Oct 24, 2005" 72#define DRV_MODULE_RELDATE "Dec 28, 2005"
73 73
74#define TG3_DEF_MAC_MODE 0 74#define TG3_DEF_MAC_MODE 0
75#define TG3_DEF_RX_MODE 0 75#define TG3_DEF_RX_MODE 0
@@ -341,6 +341,16 @@ static struct {
341 { "interrupt test (offline)" }, 341 { "interrupt test (offline)" },
342}; 342};
343 343
344static void tg3_write32(struct tg3 *tp, u32 off, u32 val)
345{
346 writel(val, tp->regs + off);
347}
348
349static u32 tg3_read32(struct tg3 *tp, u32 off)
350{
351 return (readl(tp->regs + off));
352}
353
344static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val) 354static void tg3_write_indirect_reg32(struct tg3 *tp, u32 off, u32 val)
345{ 355{
346 unsigned long flags; 356 unsigned long flags;
@@ -411,13 +421,29 @@ static u32 tg3_read_indirect_mbox(struct tg3 *tp, u32 off)
411 return val; 421 return val;
412} 422}
413 423
414static void _tw32_flush(struct tg3 *tp, u32 off, u32 val) 424/* usec_wait specifies the wait time in usec when writing to certain registers
425 * where it is unsafe to read back the register without some delay.
426 * GRC_LOCAL_CTRL is one example if the GPIOs are toggled to switch power.
427 * TG3PCI_CLOCK_CTRL is another example if the clock frequencies are changed.
428 */
429static void _tw32_flush(struct tg3 *tp, u32 off, u32 val, u32 usec_wait)
415{ 430{
416 tp->write32(tp, off, val); 431 if ((tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) ||
417 if (!(tp->tg3_flags & TG3_FLAG_PCIX_TARGET_HWBUG) && 432 (tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND))
418 !(tp->tg3_flags & TG3_FLAG_5701_REG_WRITE_BUG) && 433 /* Non-posted methods */
419 !(tp->tg3_flags2 & TG3_FLG2_ICH_WORKAROUND)) 434 tp->write32(tp, off, val);
420 tp->read32(tp, off); /* flush */ 435 else {
436 /* Posted method */
437 tg3_write32(tp, off, val);
438 if (usec_wait)
439 udelay(usec_wait);
440 tp->read32(tp, off);
441 }
442 /* Wait again after the read for the posted method to guarantee that
443 * the wait time is met.
444 */
445 if (usec_wait)
446 udelay(usec_wait);
421} 447}
422 448
423static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val) 449static inline void tw32_mailbox_flush(struct tg3 *tp, u32 off, u32 val)
@@ -438,16 +464,6 @@ static void tg3_write32_tx_mbox(struct tg3 *tp, u32 off, u32 val)
438 readl(mbox); 464 readl(mbox);
439} 465}
440 466
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) 467#define tw32_mailbox(reg, val) tp->write32_mbox(tp, reg, val)
452#define tw32_mailbox_f(reg, val) tw32_mailbox_flush(tp, (reg), (val)) 468#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) 469#define tw32_rx_mbox(reg, val) tp->write32_rx_mbox(tp, reg, val)
@@ -455,7 +471,8 @@ static u32 tg3_read32(struct tg3 *tp, u32 off)
455#define tr32_mailbox(reg) tp->read32_mbox(tp, reg) 471#define tr32_mailbox(reg) tp->read32_mbox(tp, reg)
456 472
457#define tw32(reg,val) tp->write32(tp, reg, val) 473#define tw32(reg,val) tp->write32(tp, reg, val)
458#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val)) 474#define tw32_f(reg,val) _tw32_flush(tp,(reg),(val), 0)
475#define tw32_wait_f(reg,val,us) _tw32_flush(tp,(reg),(val), (us))
459#define tr32(reg) tp->read32(tp, reg) 476#define tr32(reg) tp->read32(tp, reg)
460 477
461static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val) 478static void tg3_write_mem(struct tg3 *tp, u32 off, u32 val)
@@ -595,21 +612,19 @@ static void tg3_switch_clocks(struct tg3 *tp)
595 612
596 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { 613 if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
597 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) { 614 if (orig_clock_ctrl & CLOCK_CTRL_625_CORE) {
598 tw32_f(TG3PCI_CLOCK_CTRL, 615 tw32_wait_f(TG3PCI_CLOCK_CTRL,
599 clock_ctrl | CLOCK_CTRL_625_CORE); 616 clock_ctrl | CLOCK_CTRL_625_CORE, 40);
600 udelay(40);
601 } 617 }
602 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) { 618 } else if ((orig_clock_ctrl & CLOCK_CTRL_44MHZ_CORE) != 0) {
603 tw32_f(TG3PCI_CLOCK_CTRL, 619 tw32_wait_f(TG3PCI_CLOCK_CTRL,
604 clock_ctrl | 620 clock_ctrl |
605 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK)); 621 (CLOCK_CTRL_44MHZ_CORE | CLOCK_CTRL_ALTCLK),
606 udelay(40); 622 40);
607 tw32_f(TG3PCI_CLOCK_CTRL, 623 tw32_wait_f(TG3PCI_CLOCK_CTRL,
608 clock_ctrl | (CLOCK_CTRL_ALTCLK)); 624 clock_ctrl | (CLOCK_CTRL_ALTCLK),
609 udelay(40); 625 40);
610 } 626 }
611 tw32_f(TG3PCI_CLOCK_CTRL, clock_ctrl); 627 tw32_wait_f(TG3PCI_CLOCK_CTRL, clock_ctrl, 40);
612 udelay(40);
613} 628}
614 629
615#define PHY_BUSY_LOOPS 5000 630#define PHY_BUSY_LOOPS 5000
@@ -1017,37 +1032,50 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1017 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0) 1032 if ((tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT) != 0)
1018 return; 1033 return;
1019 1034
1020 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) { 1035 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
1021 tp_peer = pci_get_drvdata(tp->pdev_peer); 1036 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714)) {
1022 if (!tp_peer) 1037 struct net_device *dev_peer;
1038
1039 dev_peer = pci_get_drvdata(tp->pdev_peer);
1040 if (!dev_peer)
1023 BUG(); 1041 BUG();
1042 tp_peer = netdev_priv(dev_peer);
1024 } 1043 }
1025 1044
1026
1027 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 || 1045 if ((tp->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1028 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0) { 1046 (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0 ||
1047 (tp_peer->tg3_flags & TG3_FLAG_WOL_ENABLE) != 0 ||
1048 (tp_peer->tg3_flags & TG3_FLAG_ENABLE_ASF) != 0) {
1029 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 || 1049 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5700 ||
1030 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) { 1050 GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5701) {
1031 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1051 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1032 (GRC_LCLCTRL_GPIO_OE0 | 1052 (GRC_LCLCTRL_GPIO_OE0 |
1033 GRC_LCLCTRL_GPIO_OE1 | 1053 GRC_LCLCTRL_GPIO_OE1 |
1034 GRC_LCLCTRL_GPIO_OE2 | 1054 GRC_LCLCTRL_GPIO_OE2 |
1035 GRC_LCLCTRL_GPIO_OUTPUT0 | 1055 GRC_LCLCTRL_GPIO_OUTPUT0 |
1036 GRC_LCLCTRL_GPIO_OUTPUT1)); 1056 GRC_LCLCTRL_GPIO_OUTPUT1),
1037 udelay(100); 1057 100);
1038 } else { 1058 } else {
1039 u32 no_gpio2; 1059 u32 no_gpio2;
1040 u32 grc_local_ctrl; 1060 u32 grc_local_ctrl = 0;
1041 1061
1042 if (tp_peer != tp && 1062 if (tp_peer != tp &&
1043 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1063 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1044 return; 1064 return;
1045 1065
1066 /* Workaround to prevent overdrawing Amps. */
1067 if (GET_ASIC_REV(tp->pci_chip_rev_id) ==
1068 ASIC_REV_5714) {
1069 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
1070 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1071 grc_local_ctrl, 100);
1072 }
1073
1046 /* On 5753 and variants, GPIO2 cannot be used. */ 1074 /* On 5753 and variants, GPIO2 cannot be used. */
1047 no_gpio2 = tp->nic_sram_data_cfg & 1075 no_gpio2 = tp->nic_sram_data_cfg &
1048 NIC_SRAM_DATA_CFG_NO_GPIO2; 1076 NIC_SRAM_DATA_CFG_NO_GPIO2;
1049 1077
1050 grc_local_ctrl = GRC_LCLCTRL_GPIO_OE0 | 1078 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE0 |
1051 GRC_LCLCTRL_GPIO_OE1 | 1079 GRC_LCLCTRL_GPIO_OE1 |
1052 GRC_LCLCTRL_GPIO_OE2 | 1080 GRC_LCLCTRL_GPIO_OE2 |
1053 GRC_LCLCTRL_GPIO_OUTPUT1 | 1081 GRC_LCLCTRL_GPIO_OUTPUT1 |
@@ -1056,21 +1084,18 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1056 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 | 1084 grc_local_ctrl &= ~(GRC_LCLCTRL_GPIO_OE2 |
1057 GRC_LCLCTRL_GPIO_OUTPUT2); 1085 GRC_LCLCTRL_GPIO_OUTPUT2);
1058 } 1086 }
1059 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1087 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1060 grc_local_ctrl); 1088 grc_local_ctrl, 100);
1061 udelay(100);
1062 1089
1063 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0; 1090 grc_local_ctrl |= GRC_LCLCTRL_GPIO_OUTPUT0;
1064 1091
1065 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1092 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1066 grc_local_ctrl); 1093 grc_local_ctrl, 100);
1067 udelay(100);
1068 1094
1069 if (!no_gpio2) { 1095 if (!no_gpio2) {
1070 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2; 1096 grc_local_ctrl &= ~GRC_LCLCTRL_GPIO_OUTPUT2;
1071 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1097 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1072 grc_local_ctrl); 1098 grc_local_ctrl, 100);
1073 udelay(100);
1074 } 1099 }
1075 } 1100 }
1076 } else { 1101 } else {
@@ -1080,19 +1105,16 @@ static void tg3_frob_aux_power(struct tg3 *tp)
1080 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0) 1105 (tp_peer->tg3_flags & TG3_FLAG_INIT_COMPLETE) != 0)
1081 return; 1106 return;
1082 1107
1083 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1108 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1084 (GRC_LCLCTRL_GPIO_OE1 | 1109 (GRC_LCLCTRL_GPIO_OE1 |
1085 GRC_LCLCTRL_GPIO_OUTPUT1)); 1110 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1086 udelay(100);
1087 1111
1088 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1112 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1089 (GRC_LCLCTRL_GPIO_OE1)); 1113 GRC_LCLCTRL_GPIO_OE1, 100);
1090 udelay(100);
1091 1114
1092 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl | 1115 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl |
1093 (GRC_LCLCTRL_GPIO_OE1 | 1116 (GRC_LCLCTRL_GPIO_OE1 |
1094 GRC_LCLCTRL_GPIO_OUTPUT1)); 1117 GRC_LCLCTRL_GPIO_OUTPUT1), 100);
1095 udelay(100);
1096 } 1118 }
1097 } 1119 }
1098} 1120}
@@ -1105,6 +1127,8 @@ static int tg3_setup_phy(struct tg3 *, int);
1105 1127
1106static void tg3_write_sig_post_reset(struct tg3 *, int); 1128static void tg3_write_sig_post_reset(struct tg3 *, int);
1107static int tg3_halt_cpu(struct tg3 *, u32); 1129static int tg3_halt_cpu(struct tg3 *, u32);
1130static int tg3_nvram_lock(struct tg3 *);
1131static void tg3_nvram_unlock(struct tg3 *);
1108 1132
1109static int tg3_set_power_state(struct tg3 *tp, int state) 1133static int tg3_set_power_state(struct tg3 *tp, int state)
1110{ 1134{
@@ -1133,10 +1157,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1133 udelay(100); /* Delay after power state change */ 1157 udelay(100); /* Delay after power state change */
1134 1158
1135 /* Switch out of Vaux if it is not a LOM */ 1159 /* Switch out of Vaux if it is not a LOM */
1136 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT)) { 1160 if (!(tp->tg3_flags & TG3_FLAG_EEPROM_WRITE_PROT))
1137 tw32_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl); 1161 tw32_wait_f(GRC_LOCAL_CTRL, tp->grc_local_ctrl, 100);
1138 udelay(100);
1139 }
1140 1162
1141 return 0; 1163 return 0;
1142 1164
@@ -1179,6 +1201,21 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1179 tg3_setup_phy(tp, 0); 1201 tg3_setup_phy(tp, 0);
1180 } 1202 }
1181 1203
1204 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1205 int i;
1206 u32 val;
1207
1208 for (i = 0; i < 200; i++) {
1209 tg3_read_mem(tp, NIC_SRAM_FW_ASF_STATUS_MBOX, &val);
1210 if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
1211 break;
1212 msleep(1);
1213 }
1214 }
1215 tg3_write_mem(tp, NIC_SRAM_WOL_MBOX, WOL_SIGNATURE |
1216 WOL_DRV_STATE_SHUTDOWN |
1217 WOL_DRV_WOL | WOL_SET_MAGIC_PKT);
1218
1182 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps); 1219 pci_read_config_word(tp->pdev, pm + PCI_PM_PMC, &power_caps);
1183 1220
1184 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) { 1221 if (tp->tg3_flags & TG3_FLAG_WOL_ENABLE) {
@@ -1220,10 +1257,8 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1220 base_val |= (CLOCK_CTRL_RXCLK_DISABLE | 1257 base_val |= (CLOCK_CTRL_RXCLK_DISABLE |
1221 CLOCK_CTRL_TXCLK_DISABLE); 1258 CLOCK_CTRL_TXCLK_DISABLE);
1222 1259
1223 tw32_f(TG3PCI_CLOCK_CTRL, base_val | 1260 tw32_wait_f(TG3PCI_CLOCK_CTRL, base_val | CLOCK_CTRL_ALTCLK |
1224 CLOCK_CTRL_ALTCLK | 1261 CLOCK_CTRL_PWRDOWN_PLL133, 40);
1225 CLOCK_CTRL_PWRDOWN_PLL133);
1226 udelay(40);
1227 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) { 1262 } else if (tp->tg3_flags2 & TG3_FLG2_5780_CLASS) {
1228 /* do nothing */ 1263 /* do nothing */
1229 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) && 1264 } else if (!((tp->tg3_flags2 & TG3_FLG2_5750_PLUS) &&
@@ -1244,11 +1279,11 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1244 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE; 1279 newbits2 = newbits1 | CLOCK_CTRL_44MHZ_CORE;
1245 } 1280 }
1246 1281
1247 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1); 1282 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits1,
1248 udelay(40); 1283 40);
1249 1284
1250 tw32_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2); 1285 tw32_wait_f(TG3PCI_CLOCK_CTRL, tp->pci_clock_ctrl | newbits2,
1251 udelay(40); 1286 40);
1252 1287
1253 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) { 1288 if (!(tp->tg3_flags2 & TG3_FLG2_5705_PLUS)) {
1254 u32 newbits3; 1289 u32 newbits3;
@@ -1262,9 +1297,20 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1262 newbits3 = CLOCK_CTRL_44MHZ_CORE; 1297 newbits3 = CLOCK_CTRL_44MHZ_CORE;
1263 } 1298 }
1264 1299
1265 tw32_f(TG3PCI_CLOCK_CTRL, 1300 tw32_wait_f(TG3PCI_CLOCK_CTRL,
1266 tp->pci_clock_ctrl | newbits3); 1301 tp->pci_clock_ctrl | newbits3, 40);
1267 udelay(40); 1302 }
1303 }
1304
1305 if (!(tp->tg3_flags & TG3_FLAG_WOL_ENABLE) &&
1306 !(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1307 /* Turn off the PHY */
1308 if (!(tp->tg3_flags2 & TG3_FLG2_PHY_SERDES)) {
1309 tg3_writephy(tp, MII_TG3_EXT_CTRL,
1310 MII_TG3_EXT_CTRL_FORCE_LED_OFF);
1311 tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x01b2);
1312 if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5700)
1313 tg3_writephy(tp, MII_BMCR, BMCR_PDOWN);
1268 } 1314 }
1269 } 1315 }
1270 1316
@@ -1277,8 +1323,12 @@ static int tg3_set_power_state(struct tg3 *tp, int state)
1277 1323
1278 val &= ~((1 << 16) | (1 << 4) | (1 << 2) | (1 << 1) | 1); 1324 val &= ~((1 << 16) | (1 << 4) | (1 << 2) | (1 << 1) | 1);
1279 tw32(0x7d00, val); 1325 tw32(0x7d00, val);
1280 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) 1326 if (!(tp->tg3_flags & TG3_FLAG_ENABLE_ASF)) {
1327 tg3_nvram_lock(tp);
1281 tg3_halt_cpu(tp, RX_CPU_BASE); 1328 tg3_halt_cpu(tp, RX_CPU_BASE);
1329 tw32_f(NVRAM_SWARB, SWARB_REQ_CLR0);
1330 tg3_nvram_unlock(tp);
1331 }
1282 } 1332 }
1283 1333
1284 /* Finally, set the new power state. */ 1334 /* Finally, set the new power state. */
@@ -1812,7 +1862,7 @@ static int tg3_setup_copper_phy(struct tg3 *tp, int force_reset)
1812 } 1862 }
1813 } 1863 }
1814relink: 1864relink:
1815 if (current_link_up == 0) { 1865 if (current_link_up == 0 || tp->link_config.phy_is_low_power) {
1816 u32 tmp; 1866 u32 tmp;
1817 1867
1818 tg3_phy_copper_begin(tp); 1868 tg3_phy_copper_begin(tp);
@@ -3565,12 +3615,15 @@ static int tg3_start_xmit(struct sk_buff *skb, struct net_device *dev)
3565 if (!spin_trylock(&tp->tx_lock)) 3615 if (!spin_trylock(&tp->tx_lock))
3566 return NETDEV_TX_LOCKED; 3616 return NETDEV_TX_LOCKED;
3567 3617
3568 /* This is a hard error, log it. */
3569 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) { 3618 if (unlikely(TX_BUFFS_AVAIL(tp) <= (skb_shinfo(skb)->nr_frags + 1))) {
3570 netif_stop_queue(dev); 3619 if (!netif_queue_stopped(dev)) {
3620 netif_stop_queue(dev);
3621
3622 /* This is a hard error, log it. */
3623 printk(KERN_ERR PFX "%s: BUG! Tx Ring full when "
3624 "queue awake!\n", dev->name);
3625 }
3571 spin_unlock(&tp->tx_lock); 3626 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; 3627 return NETDEV_TX_BUSY;
3575 } 3628 }
3576 3629
@@ -7098,8 +7151,13 @@ do { p = (u32 *)(orig_p + (reg)); \
7098 GET_REG32_LOOP(BUFMGR_MODE, 0x58); 7151 GET_REG32_LOOP(BUFMGR_MODE, 0x58);
7099 GET_REG32_LOOP(RDMAC_MODE, 0x08); 7152 GET_REG32_LOOP(RDMAC_MODE, 0x08);
7100 GET_REG32_LOOP(WDMAC_MODE, 0x08); 7153 GET_REG32_LOOP(WDMAC_MODE, 0x08);
7101 GET_REG32_LOOP(RX_CPU_BASE, 0x280); 7154 GET_REG32_1(RX_CPU_MODE);
7102 GET_REG32_LOOP(TX_CPU_BASE, 0x280); 7155 GET_REG32_1(RX_CPU_STATE);
7156 GET_REG32_1(RX_CPU_PGMCTR);
7157 GET_REG32_1(RX_CPU_HWBKPT);
7158 GET_REG32_1(TX_CPU_MODE);
7159 GET_REG32_1(TX_CPU_STATE);
7160 GET_REG32_1(TX_CPU_PGMCTR);
7103 GET_REG32_LOOP(GRCMBOX_INTERRUPT_0, 0x110); 7161 GET_REG32_LOOP(GRCMBOX_INTERRUPT_0, 0x110);
7104 GET_REG32_LOOP(FTQ_RESET, 0x120); 7162 GET_REG32_LOOP(FTQ_RESET, 0x120);
7105 GET_REG32_LOOP(MSGINT_MODE, 0x0c); 7163 GET_REG32_LOOP(MSGINT_MODE, 0x0c);
@@ -7922,13 +7980,12 @@ static int tg3_test_memory(struct tg3 *tp)
7922 u32 offset; 7980 u32 offset;
7923 u32 len; 7981 u32 len;
7924 } mem_tbl_570x[] = { 7982 } mem_tbl_570x[] = {
7925 { 0x00000000, 0x01000}, 7983 { 0x00000000, 0x00b50},
7926 { 0x00002000, 0x1c000}, 7984 { 0x00002000, 0x1c000},
7927 { 0xffffffff, 0x00000} 7985 { 0xffffffff, 0x00000}
7928 }, mem_tbl_5705[] = { 7986 }, mem_tbl_5705[] = {
7929 { 0x00000100, 0x0000c}, 7987 { 0x00000100, 0x0000c},
7930 { 0x00000200, 0x00008}, 7988 { 0x00000200, 0x00008},
7931 { 0x00000b50, 0x00400},
7932 { 0x00004000, 0x00800}, 7989 { 0x00004000, 0x00800},
7933 { 0x00006000, 0x01000}, 7990 { 0x00006000, 0x01000},
7934 { 0x00008000, 0x02000}, 7991 { 0x00008000, 0x02000},
@@ -8530,6 +8587,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
8530 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) { 8587 GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5701) {
8531 tp->tg3_flags |= TG3_FLAG_NVRAM; 8588 tp->tg3_flags |= TG3_FLAG_NVRAM;
8532 8589
8590 tg3_nvram_lock(tp);
8533 tg3_enable_nvram_access(tp); 8591 tg3_enable_nvram_access(tp);
8534 8592
8535 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752) 8593 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
@@ -8540,6 +8598,7 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
8540 tg3_get_nvram_size(tp); 8598 tg3_get_nvram_size(tp);
8541 8599
8542 tg3_disable_nvram_access(tp); 8600 tg3_disable_nvram_access(tp);
8601 tg3_nvram_unlock(tp);
8543 8602
8544 } else { 8603 } else {
8545 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED); 8604 tp->tg3_flags &= ~(TG3_FLAG_NVRAM | TG3_FLAG_NVRAM_BUFFERED);
@@ -8637,10 +8696,10 @@ static int tg3_nvram_read(struct tg3 *tp, u32 offset, u32 *val)
8637 if (ret == 0) 8696 if (ret == 0)
8638 *val = swab32(tr32(NVRAM_RDDATA)); 8697 *val = swab32(tr32(NVRAM_RDDATA));
8639 8698
8640 tg3_nvram_unlock(tp);
8641
8642 tg3_disable_nvram_access(tp); 8699 tg3_disable_nvram_access(tp);
8643 8700
8701 tg3_nvram_unlock(tp);
8702
8644 return ret; 8703 return ret;
8645} 8704}
8646 8705
@@ -8725,6 +8784,10 @@ static int tg3_nvram_write_block_unbuffered(struct tg3 *tp, u32 offset, u32 len,
8725 8784
8726 offset = offset + (pagesize - page_off); 8785 offset = offset + (pagesize - page_off);
8727 8786
8787 /* Nvram lock released by tg3_nvram_read() above,
8788 * so need to get it again.
8789 */
8790 tg3_nvram_lock(tp);
8728 tg3_enable_nvram_access(tp); 8791 tg3_enable_nvram_access(tp);
8729 8792
8730 /* 8793 /*
@@ -10423,7 +10486,7 @@ static char * __devinit tg3_bus_string(struct tg3 *tp, char *str)
10423 return str; 10486 return str;
10424} 10487}
10425 10488
10426static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp) 10489static struct pci_dev * __devinit tg3_find_peer(struct tg3 *tp)
10427{ 10490{
10428 struct pci_dev *peer; 10491 struct pci_dev *peer;
10429 unsigned int func, devnr = tp->pdev->devfn & ~7; 10492 unsigned int func, devnr = tp->pdev->devfn & ~7;
@@ -10434,8 +10497,13 @@ static struct pci_dev * __devinit tg3_find_5704_peer(struct tg3 *tp)
10434 break; 10497 break;
10435 pci_dev_put(peer); 10498 pci_dev_put(peer);
10436 } 10499 }
10437 if (!peer || peer == tp->pdev) 10500 /* 5704 can be configured in single-port mode, set peer to
10438 BUG(); 10501 * tp->pdev in that case.
10502 */
10503 if (!peer) {
10504 peer = tp->pdev;
10505 return peer;
10506 }
10439 10507
10440 /* 10508 /*
10441 * We don't need to keep the refcount elevated; there's no way 10509 * We don't need to keep the refcount elevated; there's no way
@@ -10671,8 +10739,9 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
10671 tp->rx_pending = 63; 10739 tp->rx_pending = 63;
10672 } 10740 }
10673 10741
10674 if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) 10742 if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704) ||
10675 tp->pdev_peer = tg3_find_5704_peer(tp); 10743 (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5714))
10744 tp->pdev_peer = tg3_find_peer(tp);
10676 10745
10677 err = tg3_get_device_address(tp); 10746 err = tg3_get_device_address(tp);
10678 if (err) { 10747 if (err) {
@@ -10817,12 +10886,14 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state)
10817 10886
10818 tg3_full_lock(tp, 0); 10887 tg3_full_lock(tp, 0);
10819 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 10888 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
10889 tp->tg3_flags &= ~TG3_FLAG_INIT_COMPLETE;
10820 tg3_full_unlock(tp); 10890 tg3_full_unlock(tp);
10821 10891
10822 err = tg3_set_power_state(tp, pci_choose_state(pdev, state)); 10892 err = tg3_set_power_state(tp, pci_choose_state(pdev, state));
10823 if (err) { 10893 if (err) {
10824 tg3_full_lock(tp, 0); 10894 tg3_full_lock(tp, 0);
10825 10895
10896 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
10826 tg3_init_hw(tp); 10897 tg3_init_hw(tp);
10827 10898
10828 tp->timer.expires = jiffies + tp->timer_offset; 10899 tp->timer.expires = jiffies + tp->timer_offset;
@@ -10856,6 +10927,7 @@ static int tg3_resume(struct pci_dev *pdev)
10856 10927
10857 tg3_full_lock(tp, 0); 10928 tg3_full_lock(tp, 0);
10858 10929
10930 tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE;
10859 tg3_init_hw(tp); 10931 tg3_init_hw(tp);
10860 10932
10861 tp->timer.expires = jiffies + tp->timer_offset; 10933 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/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index d04c918ebef8..4f756960db2a 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -344,9 +344,10 @@ module_param_array(dma, int, NULL, 0);
344 344
345static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS]; 345static struct platform_device *proteon_dev[ISATR_MAX_ADAPTERS];
346 346
347static struct device_driver proteon_driver = { 347static struct platform_driver proteon_driver = {
348 .name = "proteon", 348 .driver = {
349 .bus = &platform_bus_type, 349 .name = "proteon",
350 },
350}; 351};
351 352
352static int __init proteon_init(void) 353static int __init proteon_init(void)
@@ -355,7 +356,7 @@ static int __init proteon_init(void)
355 struct platform_device *pdev; 356 struct platform_device *pdev;
356 int i, num = 0, err = 0; 357 int i, num = 0, err = 0;
357 358
358 err = driver_register(&proteon_driver); 359 err = platform_driver_register(&proteon_driver);
359 if (err) 360 if (err)
360 return err; 361 return err;
361 362
@@ -372,7 +373,7 @@ static int __init proteon_init(void)
372 err = setup_card(dev, &pdev->dev); 373 err = setup_card(dev, &pdev->dev);
373 if (!err) { 374 if (!err) {
374 proteon_dev[i] = pdev; 375 proteon_dev[i] = pdev;
375 dev_set_drvdata(&pdev->dev, dev); 376 platform_set_drvdata(pdev, dev);
376 ++num; 377 ++num;
377 } else { 378 } else {
378 platform_device_unregister(pdev); 379 platform_device_unregister(pdev);
@@ -399,17 +400,17 @@ static void __exit proteon_cleanup(void)
399 400
400 if (!pdev) 401 if (!pdev)
401 continue; 402 continue;
402 dev = dev_get_drvdata(&pdev->dev); 403 dev = platform_get_drvdata(pdev);
403 unregister_netdev(dev); 404 unregister_netdev(dev);
404 release_region(dev->base_addr, PROTEON_IO_EXTENT); 405 release_region(dev->base_addr, PROTEON_IO_EXTENT);
405 free_irq(dev->irq, dev); 406 free_irq(dev->irq, dev);
406 free_dma(dev->dma); 407 free_dma(dev->dma);
407 tmsdev_term(dev); 408 tmsdev_term(dev);
408 free_netdev(dev); 409 free_netdev(dev);
409 dev_set_drvdata(&pdev->dev, NULL); 410 platform_set_drvdata(pdev, NULL);
410 platform_device_unregister(pdev); 411 platform_device_unregister(pdev);
411 } 412 }
412 driver_unregister(&proteon_driver); 413 platform_driver_unregister(&proteon_driver);
413} 414}
414 415
415module_init(proteon_init); 416module_init(proteon_init);
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index 72cf708396be..d6ba41cf3110 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -354,9 +354,10 @@ module_param_array(dma, int, NULL, 0);
354 354
355static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS]; 355static struct platform_device *sk_isa_dev[ISATR_MAX_ADAPTERS];
356 356
357static struct device_driver sk_isa_driver = { 357static struct platform_driver sk_isa_driver = {
358 .name = "skisa", 358 .driver = {
359 .bus = &platform_bus_type, 359 .name = "skisa",
360 },
360}; 361};
361 362
362static int __init sk_isa_init(void) 363static int __init sk_isa_init(void)
@@ -365,7 +366,7 @@ static int __init sk_isa_init(void)
365 struct platform_device *pdev; 366 struct platform_device *pdev;
366 int i, num = 0, err = 0; 367 int i, num = 0, err = 0;
367 368
368 err = driver_register(&sk_isa_driver); 369 err = platform_driver_register(&sk_isa_driver);
369 if (err) 370 if (err)
370 return err; 371 return err;
371 372
@@ -382,7 +383,7 @@ static int __init sk_isa_init(void)
382 err = setup_card(dev, &pdev->dev); 383 err = setup_card(dev, &pdev->dev);
383 if (!err) { 384 if (!err) {
384 sk_isa_dev[i] = pdev; 385 sk_isa_dev[i] = pdev;
385 dev_set_drvdata(&sk_isa_dev[i]->dev, dev); 386 platform_set_drvdata(sk_isa_dev[i], dev);
386 ++num; 387 ++num;
387 } else { 388 } else {
388 platform_device_unregister(pdev); 389 platform_device_unregister(pdev);
@@ -409,17 +410,17 @@ static void __exit sk_isa_cleanup(void)
409 410
410 if (!pdev) 411 if (!pdev)
411 continue; 412 continue;
412 dev = dev_get_drvdata(&pdev->dev); 413 dev = platform_get_drvdata(pdev);
413 unregister_netdev(dev); 414 unregister_netdev(dev);
414 release_region(dev->base_addr, SK_ISA_IO_EXTENT); 415 release_region(dev->base_addr, SK_ISA_IO_EXTENT);
415 free_irq(dev->irq, dev); 416 free_irq(dev->irq, dev);
416 free_dma(dev->dma); 417 free_dma(dev->dma);
417 tmsdev_term(dev); 418 tmsdev_term(dev);
418 free_netdev(dev); 419 free_netdev(dev);
419 dev_set_drvdata(&pdev->dev, NULL); 420 platform_set_drvdata(pdev, NULL);
420 platform_device_unregister(pdev); 421 platform_device_unregister(pdev);
421 } 422 }
422 driver_unregister(&sk_isa_driver); 423 platform_driver_unregister(&sk_isa_driver);
423} 424}
424 425
425module_init(sk_isa_init); 426module_init(sk_isa_init);
diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c
index a01efa6d5c62..1fd04662c4fc 100644
--- a/drivers/net/wan/hdlc_cisco.c
+++ b/drivers/net/wan/hdlc_cisco.c
@@ -192,7 +192,9 @@ static int cisco_rx(struct sk_buff *skb)
192 "uptime %ud%uh%um%us)\n", 192 "uptime %ud%uh%um%us)\n",
193 dev->name, days, hrs, 193 dev->name, days, hrs,
194 min, sec); 194 min, sec);
195#if 0
195 netif_carrier_on(dev); 196 netif_carrier_on(dev);
197#endif
196 hdlc->state.cisco.up = 1; 198 hdlc->state.cisco.up = 1;
197 } 199 }
198 } 200 }
@@ -225,7 +227,9 @@ static void cisco_timer(unsigned long arg)
225 hdlc->state.cisco.settings.timeout * HZ)) { 227 hdlc->state.cisco.settings.timeout * HZ)) {
226 hdlc->state.cisco.up = 0; 228 hdlc->state.cisco.up = 0;
227 printk(KERN_INFO "%s: Link down\n", dev->name); 229 printk(KERN_INFO "%s: Link down\n", dev->name);
230#if 0
228 netif_carrier_off(dev); 231 netif_carrier_off(dev);
232#endif
229 } 233 }
230 234
231 cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ, 235 cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ,
@@ -261,8 +265,10 @@ static void cisco_stop(struct net_device *dev)
261{ 265{
262 hdlc_device *hdlc = dev_to_hdlc(dev); 266 hdlc_device *hdlc = dev_to_hdlc(dev);
263 del_timer_sync(&hdlc->state.cisco.timer); 267 del_timer_sync(&hdlc->state.cisco.timer);
268#if 0
264 if (netif_carrier_ok(dev)) 269 if (netif_carrier_ok(dev))
265 netif_carrier_off(dev); 270 netif_carrier_off(dev);
271#endif
266 hdlc->state.cisco.up = 0; 272 hdlc->state.cisco.up = 0;
267 hdlc->state.cisco.request_sent = 0; 273 hdlc->state.cisco.request_sent = 0;
268} 274}
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index e1601d35dced..523afe17564e 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -545,8 +545,10 @@ static void fr_set_link_state(int reliable, struct net_device *dev)
545 545
546 hdlc->state.fr.reliable = reliable; 546 hdlc->state.fr.reliable = reliable;
547 if (reliable) { 547 if (reliable) {
548#if 0
548 if (!netif_carrier_ok(dev)) 549 if (!netif_carrier_ok(dev))
549 netif_carrier_on(dev); 550 netif_carrier_on(dev);
551#endif
550 552
551 hdlc->state.fr.n391cnt = 0; /* Request full status */ 553 hdlc->state.fr.n391cnt = 0; /* Request full status */
552 hdlc->state.fr.dce_changed = 1; 554 hdlc->state.fr.dce_changed = 1;
@@ -560,8 +562,10 @@ static void fr_set_link_state(int reliable, struct net_device *dev)
560 } 562 }
561 } 563 }
562 } else { 564 } else {
565#if 0
563 if (netif_carrier_ok(dev)) 566 if (netif_carrier_ok(dev))
564 netif_carrier_off(dev); 567 netif_carrier_off(dev);
568#endif
565 569
566 while (pvc) { /* Deactivate all PVCs */ 570 while (pvc) { /* Deactivate all PVCs */
567 pvc_carrier(0, pvc); 571 pvc_carrier(0, pvc);
diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c
index cdd4c09c2d90..46cef8f92133 100644
--- a/drivers/net/wan/hdlc_generic.c
+++ b/drivers/net/wan/hdlc_generic.c
@@ -79,11 +79,13 @@ static void __hdlc_set_carrier_on(struct net_device *dev)
79 hdlc_device *hdlc = dev_to_hdlc(dev); 79 hdlc_device *hdlc = dev_to_hdlc(dev);
80 if (hdlc->proto.start) 80 if (hdlc->proto.start)
81 return hdlc->proto.start(dev); 81 return hdlc->proto.start(dev);
82#if 0
82#ifdef DEBUG_LINK 83#ifdef DEBUG_LINK
83 if (netif_carrier_ok(dev)) 84 if (netif_carrier_ok(dev))
84 printk(KERN_ERR "hdlc_set_carrier_on(): already on\n"); 85 printk(KERN_ERR "hdlc_set_carrier_on(): already on\n");
85#endif 86#endif
86 netif_carrier_on(dev); 87 netif_carrier_on(dev);
88#endif
87} 89}
88 90
89 91
@@ -94,11 +96,13 @@ static void __hdlc_set_carrier_off(struct net_device *dev)
94 if (hdlc->proto.stop) 96 if (hdlc->proto.stop)
95 return hdlc->proto.stop(dev); 97 return hdlc->proto.stop(dev);
96 98
99#if 0
97#ifdef DEBUG_LINK 100#ifdef DEBUG_LINK
98 if (!netif_carrier_ok(dev)) 101 if (!netif_carrier_ok(dev))
99 printk(KERN_ERR "hdlc_set_carrier_off(): already off\n"); 102 printk(KERN_ERR "hdlc_set_carrier_off(): already off\n");
100#endif 103#endif
101 netif_carrier_off(dev); 104 netif_carrier_off(dev);
105#endif
102} 106}
103 107
104 108
@@ -294,8 +298,10 @@ int register_hdlc_device(struct net_device *dev)
294 if (result != 0) 298 if (result != 0)
295 return -EIO; 299 return -EIO;
296 300
301#if 0
297 if (netif_carrier_ok(dev)) 302 if (netif_carrier_ok(dev))
298 netif_carrier_off(dev); /* no carrier until DCD goes up */ 303 netif_carrier_off(dev); /* no carrier until DCD goes up */
304#endif
299 305
300 return 0; 306 return 0;
301} 307}
diff --git a/drivers/net/wan/sdladrv.c b/drivers/net/wan/sdladrv.c
index 7c2cf2e76300..032c0f81928e 100644
--- a/drivers/net/wan/sdladrv.c
+++ b/drivers/net/wan/sdladrv.c
@@ -1994,7 +1994,7 @@ static int detect_s514 (sdlahw_t* hw)
1994 modname, hw->irq); 1994 modname, hw->irq);
1995 1995
1996 /* map the physical PCI memory to virtual memory */ 1996 /* map the physical PCI memory to virtual memory */
1997 (void *)hw->dpmbase = ioremap((unsigned long)S514_mem_base_addr, 1997 hw->dpmbase = ioremap((unsigned long)S514_mem_base_addr,
1998 (unsigned long)MAX_SIZEOF_S514_MEMORY); 1998 (unsigned long)MAX_SIZEOF_S514_MEMORY);
1999 /* map the physical control register memory to virtual memory */ 1999 /* map the physical control register memory to virtual memory */
2000 hw->vector = (unsigned long)ioremap( 2000 hw->vector = (unsigned long)ioremap(
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 7187958e40ca..00e55165b760 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -330,7 +330,7 @@ config PCI_HERMES
330 330
331config ATMEL 331config ATMEL
332 tristate "Atmel at76c50x chipset 802.11b support" 332 tristate "Atmel at76c50x chipset 802.11b support"
333 depends on NET_RADIO && EXPERIMENTAL 333 depends on NET_RADIO
334 select FW_LOADER 334 select FW_LOADER
335 select CRC32 335 select CRC32
336 ---help--- 336 ---help---
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 340ab4ee4b67..7a92b1cbd6aa 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -2755,8 +2755,8 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
2755 SET_NETDEV_DEV(dev, dmdev); 2755 SET_NETDEV_DEV(dev, dmdev);
2756 2756
2757 2757
2758 if (test_bit(FLAG_MPI,&ai->flags)) 2758 reset_card (dev, 1);
2759 reset_card (dev, 1); 2759 msleep(400);
2760 2760
2761 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev ); 2761 rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev );
2762 if (rc) { 2762 if (rc) {
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index a3e23527fe7f..5e53c5258a33 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -72,7 +72,7 @@
72#include "atmel.h" 72#include "atmel.h"
73 73
74#define DRIVER_MAJOR 0 74#define DRIVER_MAJOR 0
75#define DRIVER_MINOR 96 75#define DRIVER_MINOR 98
76 76
77MODULE_AUTHOR("Simon Kelley"); 77MODULE_AUTHOR("Simon Kelley");
78MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards."); 78MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.");
@@ -1504,7 +1504,7 @@ static int atmel_read_proc(char *page, char **start, off_t off,
1504 return len; 1504 return len;
1505} 1505}
1506 1506
1507struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWType fw_type, 1507struct net_device *init_atmel_card( unsigned short irq, unsigned long port, const AtmelFWType fw_type,
1508 struct device *sys_dev, int (*card_present)(void *), void *card) 1508 struct device *sys_dev, int (*card_present)(void *), void *card)
1509{ 1509{
1510 struct net_device *dev; 1510 struct net_device *dev;
@@ -1605,8 +1605,8 @@ struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWT
1605 goto err_out_free; 1605 goto err_out_free;
1606 } 1606 }
1607 1607
1608 if (priv->bus_type == BUS_TYPE_PCI && 1608 if (!request_region(dev->base_addr, 32,
1609 !request_region( dev->base_addr, 64, dev->name )) { 1609 priv->bus_type == BUS_TYPE_PCCARD ? "atmel_cs" : "atmel_pci")) {
1610 goto err_out_irq; 1610 goto err_out_irq;
1611 } 1611 }
1612 1612
@@ -1622,15 +1622,16 @@ struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWT
1622 1622
1623 create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv); 1623 create_proc_read_entry ("driver/atmel", 0, NULL, atmel_read_proc, priv);
1624 1624
1625 printk(KERN_INFO "%s: Atmel at76c50x wireless. Version %d.%d simon@thekelleys.org.uk\n", 1625 printk(KERN_INFO "%s: Atmel at76c50x. Version %d.%d. MAC %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
1626 dev->name, DRIVER_MAJOR, DRIVER_MINOR); 1626 dev->name, DRIVER_MAJOR, DRIVER_MINOR,
1627 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] );
1627 1629
1628 SET_MODULE_OWNER(dev); 1630 SET_MODULE_OWNER(dev);
1629 return dev; 1631 return dev;
1630 1632
1631 err_out_res: 1633 err_out_res:
1632 if (priv->bus_type == BUS_TYPE_PCI) 1634 release_region( dev->base_addr, 32);
1633 release_region( dev->base_addr, 64 );
1634 err_out_irq: 1635 err_out_irq:
1635 free_irq(dev->irq, dev); 1636 free_irq(dev->irq, dev);
1636 err_out_free: 1637 err_out_free:
@@ -1640,7 +1641,7 @@ struct net_device *init_atmel_card( unsigned short irq, int port, const AtmelFWT
1640 1641
1641EXPORT_SYMBOL(init_atmel_card); 1642EXPORT_SYMBOL(init_atmel_card);
1642 1643
1643void stop_atmel_card(struct net_device *dev, int freeres) 1644void stop_atmel_card(struct net_device *dev)
1644{ 1645{
1645 struct atmel_private *priv = netdev_priv(dev); 1646 struct atmel_private *priv = netdev_priv(dev);
1646 1647
@@ -1654,10 +1655,7 @@ void stop_atmel_card(struct net_device *dev, int freeres)
1654 remove_proc_entry("driver/atmel", NULL); 1655 remove_proc_entry("driver/atmel", NULL);
1655 free_irq(dev->irq, dev); 1656 free_irq(dev->irq, dev);
1656 kfree(priv->firmware); 1657 kfree(priv->firmware);
1657 if (freeres) { 1658 release_region(dev->base_addr, 32);
1658 /* PCMCIA frees this stuff, so only for PCI */
1659 release_region(dev->base_addr, 64);
1660 }
1661 free_netdev(dev); 1659 free_netdev(dev);
1662} 1660}
1663 1661
@@ -1810,9 +1808,9 @@ static int atmel_set_encode(struct net_device *dev,
1810 } 1808 }
1811 if(dwrq->flags & IW_ENCODE_RESTRICTED) 1809 if(dwrq->flags & IW_ENCODE_RESTRICTED)
1812 priv->exclude_unencrypted = 1; 1810 priv->exclude_unencrypted = 1;
1813 if(dwrq->flags & IW_ENCODE_OPEN) 1811 if(dwrq->flags & IW_ENCODE_OPEN)
1814 priv->exclude_unencrypted = 0; 1812 priv->exclude_unencrypted = 0;
1815 1813
1816 return -EINPROGRESS; /* Call commit handler */ 1814 return -EINPROGRESS; /* Call commit handler */
1817} 1815}
1818 1816
@@ -1827,11 +1825,12 @@ static int atmel_get_encode(struct net_device *dev,
1827 1825
1828 if (!priv->wep_is_on) 1826 if (!priv->wep_is_on)
1829 dwrq->flags = IW_ENCODE_DISABLED; 1827 dwrq->flags = IW_ENCODE_DISABLED;
1830 else if (priv->exclude_unencrypted) 1828 else {
1831 dwrq->flags = IW_ENCODE_RESTRICTED; 1829 if (priv->exclude_unencrypted)
1832 else 1830 dwrq->flags = IW_ENCODE_RESTRICTED;
1833 dwrq->flags = IW_ENCODE_OPEN; 1831 else
1834 1832 dwrq->flags = IW_ENCODE_OPEN;
1833 }
1835 /* Which key do we want ? -1 -> tx index */ 1834 /* Which key do we want ? -1 -> tx index */
1836 if (index < 0 || index >= 4) 1835 if (index < 0 || index >= 4)
1837 index = priv->default_key; 1836 index = priv->default_key;
@@ -2645,8 +2644,8 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability, u8 c
2645 } 2644 }
2646} 2645}
2647 2646
2648 2647
2649static void send_authentication_request(struct atmel_private *priv, u8 *challenge, int challenge_len) 2648static void send_authentication_request(struct atmel_private *priv, u16 system, u8 *challenge, int challenge_len)
2650{ 2649{
2651 struct ieee80211_hdr_4addr header; 2650 struct ieee80211_hdr_4addr header;
2652 struct auth_body auth; 2651 struct auth_body auth;
@@ -2658,14 +2657,11 @@ static void send_authentication_request(struct atmel_private *priv, u8 *challeng
2658 memcpy(header.addr2, priv->dev->dev_addr, 6); 2657 memcpy(header.addr2, priv->dev->dev_addr, 6);
2659 memcpy(header.addr3, priv->CurrentBSSID, 6); 2658 memcpy(header.addr3, priv->CurrentBSSID, 6);
2660 2659
2661 if (priv->wep_is_on) { 2660 if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1)
2662 auth.alg = cpu_to_le16(C80211_MGMT_AAN_SHAREDKEY);
2663 /* no WEP for authentication frames with TrSeqNo 1 */ 2661 /* no WEP for authentication frames with TrSeqNo 1 */
2664 if (priv->CurrentAuthentTransactionSeqNum != 1) 2662 header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED);
2665 header.frame_ctl |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); 2663
2666 } else { 2664 auth.alg = cpu_to_le16(system);
2667 auth.alg = cpu_to_le16(C80211_MGMT_AAN_OPENSYSTEM);
2668 }
2669 2665
2670 auth.status = 0; 2666 auth.status = 0;
2671 auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum); 2667 auth.trans_seq = cpu_to_le16(priv->CurrentAuthentTransactionSeqNum);
@@ -2834,6 +2830,7 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2834 struct auth_body *auth = (struct auth_body *)priv->rx_buf; 2830 struct auth_body *auth = (struct auth_body *)priv->rx_buf;
2835 u16 status = le16_to_cpu(auth->status); 2831 u16 status = le16_to_cpu(auth->status);
2836 u16 trans_seq_no = le16_to_cpu(auth->trans_seq); 2832 u16 trans_seq_no = le16_to_cpu(auth->trans_seq);
2833 u16 system = le16_to_cpu(auth->alg);
2837 2834
2838 if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) { 2835 if (status == C80211_MGMT_SC_Success && !priv->wep_is_on) {
2839 /* no WEP */ 2836 /* no WEP */
@@ -2855,7 +2852,7 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2855 2852
2856 if (trans_seq_no == 0x0002 && 2853 if (trans_seq_no == 0x0002 &&
2857 auth->el_id == C80211_MGMT_ElementID_ChallengeText) { 2854 auth->el_id == C80211_MGMT_ElementID_ChallengeText) {
2858 send_authentication_request(priv, auth->chall_text, auth->chall_text_len); 2855 send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len);
2859 return; 2856 return;
2860 } 2857 }
2861 2858
@@ -2872,14 +2869,20 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
2872 } 2869 }
2873 } 2870 }
2874 2871
2875 if (status == C80211_MGMT_SC_AuthAlgNotSupported && priv->connect_to_any_BSS) { 2872 if (status == C80211_MGMT_SC_AuthAlgNotSupported) {
2876 int bss_index; 2873 /* Do opensystem first, then try sharedkey */
2877 2874 if (system == C80211_MGMT_AAN_OPENSYSTEM) {
2878 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80; 2875 priv->CurrentAuthentTransactionSeqNum = 0x001;
2879 2876 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0);
2880 if ((bss_index = retrieve_bss(priv)) != -1) { 2877 } else if (priv->connect_to_any_BSS) {
2881 atmel_join_bss(priv, bss_index); 2878 int bss_index;
2882 return; 2879
2880 priv->BSSinfo[(int)(priv->current_BSS)].channel |= 0x80;
2881
2882 if ((bss_index = retrieve_bss(priv)) != -1) {
2883 atmel_join_bss(priv, bss_index);
2884 return;
2885 }
2883 } 2886 }
2884 } 2887 }
2885 2888
@@ -3205,7 +3208,7 @@ static void atmel_management_timer(u_long a)
3205 priv->AuthenticationRequestRetryCnt++; 3208 priv->AuthenticationRequestRetryCnt++;
3206 priv->CurrentAuthentTransactionSeqNum = 0x0001; 3209 priv->CurrentAuthentTransactionSeqNum = 0x0001;
3207 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); 3210 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3208 send_authentication_request(priv, NULL, 0); 3211 send_authentication_request(priv, C80211_MGMT_AAN_OPENSYSTEM, NULL, 0);
3209 } 3212 }
3210 3213
3211 break; 3214 break;
@@ -3312,7 +3315,7 @@ static void atmel_command_irq(struct atmel_private *priv)
3312 3315
3313 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); 3316 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES);
3314 priv->CurrentAuthentTransactionSeqNum = 0x0001; 3317 priv->CurrentAuthentTransactionSeqNum = 0x0001;
3315 send_authentication_request(priv, NULL, 0); 3318 send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0);
3316 } 3319 }
3317 return; 3320 return;
3318 } 3321 }
@@ -3482,11 +3485,6 @@ static int probe_atmel_card(struct net_device *dev)
3482 printk(KERN_ALERT "%s: *** Invalid MAC address. UPGRADE Firmware ****\n", dev->name); 3485 printk(KERN_ALERT "%s: *** Invalid MAC address. UPGRADE Firmware ****\n", dev->name);
3483 memcpy(dev->dev_addr, default_mac, 6); 3486 memcpy(dev->dev_addr, default_mac, 6);
3484 } 3487 }
3485 printk(KERN_INFO "%s: MAC address %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
3486 dev->name,
3487 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
3488 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] );
3489
3490 } 3488 }
3491 3489
3492 return rc; 3490 return rc;
diff --git a/drivers/net/wireless/atmel.h b/drivers/net/wireless/atmel.h
index 825000edfc2c..b9b3e5b76544 100644
--- a/drivers/net/wireless/atmel.h
+++ b/drivers/net/wireless/atmel.h
@@ -35,9 +35,9 @@ typedef enum {
35 ATMEL_FW_TYPE_506 35 ATMEL_FW_TYPE_506
36} AtmelFWType; 36} AtmelFWType;
37 37
38struct net_device *init_atmel_card(unsigned short, int, const AtmelFWType, struct device *, 38struct net_device *init_atmel_card(unsigned short, unsigned long, const AtmelFWType, struct device *,
39 int (*present_func)(void *), void * ); 39 int (*present_func)(void *), void * );
40void stop_atmel_card( struct net_device *, int ); 40void stop_atmel_card( struct net_device *);
41int atmel_open( struct net_device * ); 41int atmel_open( struct net_device * );
42 42
43#endif 43#endif
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 1bd13146c644..17d1fd90f832 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -63,6 +63,7 @@
63 be present but disabled -- but it can then be enabled for specific 63 be present but disabled -- but it can then be enabled for specific
64 modules at load time with a 'pc_debug=#' option to insmod. 64 modules at load time with a 'pc_debug=#' option to insmod.
65*/ 65*/
66
66#ifdef PCMCIA_DEBUG 67#ifdef PCMCIA_DEBUG
67static int pc_debug = PCMCIA_DEBUG; 68static int pc_debug = PCMCIA_DEBUG;
68module_param(pc_debug, int, 0); 69module_param(pc_debug, int, 0);
@@ -285,41 +286,6 @@ static int card_present(void *arg)
285 return 0; 286 return 0;
286} 287}
287 288
288/* list of cards we know about and their firmware requirements.
289 Go either by Manfid or version strings.
290 Cards not in this list will need a firmware parameter to the module
291 in all probability. Note that the SMC 2632 V2 and V3 have the same
292 manfids, so we ignore those and use the version1 strings. */
293
294static struct {
295 int manf, card;
296 char *ver1;
297 AtmelFWType firmware;
298 char *name;
299} card_table[] = {
300 { 0, 0, "WLAN/802.11b PC CARD", ATMEL_FW_TYPE_502D, "Actiontec 802CAT1" },
301 { 0, 0, "ATMEL/AT76C502AR", ATMEL_FW_TYPE_502, "NoName-RFMD" },
302 { 0, 0, "ATMEL/AT76C502AR_D", ATMEL_FW_TYPE_502D, "NoName-revD" },
303 { 0, 0, "ATMEL/AT76C502AR_E", ATMEL_FW_TYPE_502E, "NoName-revE" },
304 { 0, 0, "ATMEL/AT76C504", ATMEL_FW_TYPE_504, "NoName-504" },
305 { 0, 0, "ATMEL/AT76C504A", ATMEL_FW_TYPE_504A_2958, "NoName-504a-2958" },
306 { 0, 0, "ATMEL/AT76C504_R", ATMEL_FW_TYPE_504_2958, "NoName-504-2958" },
307 { MANFID_3COM, 0x0620, NULL, ATMEL_FW_TYPE_502_3COM, "3com 3CRWE62092B" },
308 { MANFID_3COM, 0x0696, NULL, ATMEL_FW_TYPE_502_3COM, "3com 3CRSHPW196" },
309 { 0, 0, "SMC/2632W-V2", ATMEL_FW_TYPE_502, "SMC 2632W-V2" },
310 { 0, 0, "SMC/2632W", ATMEL_FW_TYPE_502D, "SMC 2632W-V3" },
311 { 0xd601, 0x0007, NULL, ATMEL_FW_TYPE_502, "Sitecom WLAN-011" },
312 { 0x01bf, 0x3302, NULL, ATMEL_FW_TYPE_502E, "Belkin F5D6020-V2" },
313 { 0, 0, "BT/Voyager 1020 Laptop Adapter", ATMEL_FW_TYPE_502, "BT Voyager 1020" },
314 { 0, 0, "IEEE 802.11b/Wireless LAN PC Card", ATMEL_FW_TYPE_502, "Siemens Gigaset PC Card II" },
315 { 0, 0, "IEEE 802.11b/Wireless LAN Card S", ATMEL_FW_TYPE_504_2958, "Siemens Gigaset PC Card II" },
316 { 0, 0, "CNet/CNWLC 11Mbps Wireless PC Card V-5", ATMEL_FW_TYPE_502E, "CNet CNWLC-811ARL" },
317 { 0, 0, "Wireless/PC_CARD", ATMEL_FW_TYPE_502D, "Planet WL-3552" },
318 { 0, 0, "OEM/11Mbps Wireless LAN PC Card V-3", ATMEL_FW_TYPE_502, "OEM 11Mbps WLAN PCMCIA Card" },
319 { 0, 0, "11WAVE/11WP611AL-E", ATMEL_FW_TYPE_502E, "11WAVE WaveBuddy" },
320 { 0, 0, "LG/LW2100N", ATMEL_FW_TYPE_502E, "LG LW2100N 11Mbps WLAN PCMCIA Card" },
321};
322
323static void atmel_config(dev_link_t *link) 289static void atmel_config(dev_link_t *link)
324{ 290{
325 client_handle_t handle; 291 client_handle_t handle;
@@ -328,10 +294,11 @@ static void atmel_config(dev_link_t *link)
328 local_info_t *dev; 294 local_info_t *dev;
329 int last_fn, last_ret; 295 int last_fn, last_ret;
330 u_char buf[64]; 296 u_char buf[64];
331 int card_index = -1, done = 0; 297 struct pcmcia_device_id *did;
332 298
333 handle = link->handle; 299 handle = link->handle;
334 dev = link->priv; 300 dev = link->priv;
301 did = handle_to_dev(handle).driver_data;
335 302
336 DEBUG(0, "atmel_config(0x%p)\n", link); 303 DEBUG(0, "atmel_config(0x%p)\n", link);
337 304
@@ -340,59 +307,6 @@ static void atmel_config(dev_link_t *link)
340 tuple.TupleDataMax = sizeof(buf); 307 tuple.TupleDataMax = sizeof(buf);
341 tuple.TupleOffset = 0; 308 tuple.TupleOffset = 0;
342 309
343 tuple.DesiredTuple = CISTPL_MANFID;
344 if (pcmcia_get_first_tuple(handle, &tuple) == 0) {
345 int i;
346 cistpl_manfid_t *manfid;
347 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
348 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
349 manfid = &(parse.manfid);
350 for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
351 if (!card_table[i].ver1 &&
352 manfid->manf == card_table[i].manf &&
353 manfid->card == card_table[i].card) {
354 card_index = i;
355 done = 1;
356 }
357 }
358 }
359
360 tuple.DesiredTuple = CISTPL_VERS_1;
361 if (!done && (pcmcia_get_first_tuple(handle, &tuple) == 0)) {
362 int i, j, k;
363 cistpl_vers_1_t *ver1;
364 CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple));
365 CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse));
366 ver1 = &(parse.version_1);
367
368 for (i = 0; i < sizeof(card_table)/sizeof(card_table[0]); i++) {
369 for (j = 0; j < ver1->ns; j++) {
370 char *p = card_table[i].ver1;
371 char *q = &ver1->str[ver1->ofs[j]];
372 if (!p)
373 goto mismatch;
374 for (k = 0; k < j; k++) {
375 while ((*p != '\0') && (*p != '/')) p++;
376 if (*p == '\0') {
377 if (*q != '\0')
378 goto mismatch;
379 } else {
380 p++;
381 }
382 }
383 while((*q != '\0') && (*p != '\0') &&
384 (*p != '/') && (*p == *q)) p++, q++;
385 if (((*p != '\0') && *p != '/') || *q != '\0')
386 goto mismatch;
387 }
388 card_index = i;
389 break; /* done */
390
391 mismatch:
392 j = 0; /* dummy stmt to shut up compiler */
393 }
394 }
395
396 /* 310 /*
397 This reads the card's CONFIG tuple to find its configuration 311 This reads the card's CONFIG tuple to find its configuration
398 registers. 312 registers.
@@ -509,12 +423,13 @@ static void atmel_config(dev_link_t *link)
509 ((local_info_t*)link->priv)->eth_dev = 423 ((local_info_t*)link->priv)->eth_dev =
510 init_atmel_card(link->irq.AssignedIRQ, 424 init_atmel_card(link->irq.AssignedIRQ,
511 link->io.BasePort1, 425 link->io.BasePort1,
512 card_index == -1 ? ATMEL_FW_TYPE_NONE : card_table[card_index].firmware, 426 did ? did->driver_info : ATMEL_FW_TYPE_NONE,
513 &handle_to_dev(handle), 427 &handle_to_dev(handle),
514 card_present, 428 card_present,
515 link); 429 link);
516 if (!((local_info_t*)link->priv)->eth_dev) 430 if (!((local_info_t*)link->priv)->eth_dev)
517 goto cs_failed; 431 goto cs_failed;
432
518 433
519 /* 434 /*
520 At this point, the dev_node_t structure(s) need to be 435 At this point, the dev_node_t structure(s) need to be
@@ -523,26 +438,7 @@ static void atmel_config(dev_link_t *link)
523 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name ); 438 strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
524 dev->node.major = dev->node.minor = 0; 439 dev->node.major = dev->node.minor = 0;
525 link->dev = &dev->node; 440 link->dev = &dev->node;
526 441
527 /* Finally, report what we've done */
528 printk(KERN_INFO "%s: %s%sindex 0x%02x: Vcc %d.%d",
529 dev->node.dev_name,
530 card_index == -1 ? "" : card_table[card_index].name,
531 card_index == -1 ? "" : " ",
532 link->conf.ConfigIndex,
533 link->conf.Vcc/10, link->conf.Vcc%10);
534 if (link->conf.Vpp1)
535 printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10);
536 if (link->conf.Attributes & CONF_ENABLE_IRQ)
537 printk(", irq %d", link->irq.AssignedIRQ);
538 if (link->io.NumPorts1)
539 printk(", io 0x%04x-0x%04x", link->io.BasePort1,
540 link->io.BasePort1+link->io.NumPorts1-1);
541 if (link->io.NumPorts2)
542 printk(" & 0x%04x-0x%04x", link->io.BasePort2,
543 link->io.BasePort2+link->io.NumPorts2-1);
544 printk("\n");
545
546 link->state &= ~DEV_CONFIG_PENDING; 442 link->state &= ~DEV_CONFIG_PENDING;
547 return; 443 return;
548 444
@@ -569,7 +465,7 @@ static void atmel_release(dev_link_t *link)
569 link->dev = NULL; 465 link->dev = NULL;
570 466
571 if (dev) 467 if (dev)
572 stop_atmel_card(dev, 0); 468 stop_atmel_card(dev);
573 ((local_info_t*)link->priv)->eth_dev = NULL; 469 ((local_info_t*)link->priv)->eth_dev = NULL;
574 470
575 /* Don't bother checking to see if these succeed or not */ 471 /* Don't bother checking to see if these succeed or not */
@@ -637,25 +533,47 @@ static int atmel_event(event_t event, int priority,
637} /* atmel_event */ 533} /* atmel_event */
638 534
639/*====================================================================*/ 535/*====================================================================*/
536/* We use the driver_info field to store the correct firmware type for a card. */
537
538#define PCMCIA_DEVICE_MANF_CARD_INFO(manf, card, info) { \
539 .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \
540 PCMCIA_DEV_ID_MATCH_CARD_ID, \
541 .manf_id = (manf), \
542 .card_id = (card), \
543 .driver_info = (kernel_ulong_t)(info), }
544
545#define PCMCIA_DEVICE_PROD_ID12_INFO(v1, v2, vh1, vh2, info) { \
546 .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID1| \
547 PCMCIA_DEV_ID_MATCH_PROD_ID2, \
548 .prod_id = { (v1), (v2), NULL, NULL }, \
549 .prod_id_hash = { (vh1), (vh2), 0, 0 }, \
550 .driver_info = (kernel_ulong_t)(info), }
551
640static struct pcmcia_device_id atmel_ids[] = { 552static struct pcmcia_device_id atmel_ids[] = {
641 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0620), 553 PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0620, ATMEL_FW_TYPE_502_3COM),
642 PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0696), 554 PCMCIA_DEVICE_MANF_CARD_INFO(0x0101, 0x0696, ATMEL_FW_TYPE_502_3COM),
643 PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3302), 555 PCMCIA_DEVICE_MANF_CARD_INFO(0x01bf, 0x3302, ATMEL_FW_TYPE_502E),
644 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0007), 556 PCMCIA_DEVICE_MANF_CARD_INFO(0xd601, 0x0007, ATMEL_FW_TYPE_502),
645 PCMCIA_DEVICE_PROD_ID12("11WAVE", "11WP611AL-E", 0x9eb2da1f, 0xc9a0d3f9), 557 PCMCIA_DEVICE_PROD_ID12_INFO("11WAVE", "11WP611AL-E", 0x9eb2da1f, 0xc9a0d3f9, ATMEL_FW_TYPE_502E),
646 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C502AR", 0xabda4164, 0x41b37e1f), 558 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C502AR", 0xabda4164, 0x41b37e1f, ATMEL_FW_TYPE_502),
647 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504", 0xabda4164, 0x5040670a), 559 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C502AR_D", 0xabda4164, 0x3675d704, ATMEL_FW_TYPE_502D),
648 PCMCIA_DEVICE_PROD_ID12("ATMEL", "AT76C504A", 0xabda4164, 0xe15ed87f), 560 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C502AR_E", 0xabda4164, 0x4172e792, ATMEL_FW_TYPE_502E),
649 PCMCIA_DEVICE_PROD_ID12("BT", "Voyager 1020 Laptop Adapter", 0xae49b86a, 0x1e957cd5), 561 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C504_R", 0xabda4164, 0x917f3d72, ATMEL_FW_TYPE_504_2958),
650 PCMCIA_DEVICE_PROD_ID12("CNet", "CNWLC 11Mbps Wireless PC Card V-5", 0xbc477dde, 0x502fae6b), 562 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C504", 0xabda4164, 0x5040670a, ATMEL_FW_TYPE_504),
651 PCMCIA_DEVICE_PROD_ID12("IEEE 802.11b", "Wireless LAN PC Card", 0x5b878724, 0x122f1df6), 563 PCMCIA_DEVICE_PROD_ID12_INFO("ATMEL", "AT76C504A", 0xabda4164, 0xe15ed87f, ATMEL_FW_TYPE_504A_2958),
652 PCMCIA_DEVICE_PROD_ID12("OEM", "11Mbps Wireless LAN PC Card V-3", 0xfea54c90, 0x1c5b0f68), 564 PCMCIA_DEVICE_PROD_ID12_INFO("BT", "Voyager 1020 Laptop Adapter", 0xae49b86a, 0x1e957cd5, ATMEL_FW_TYPE_502),
653 PCMCIA_DEVICE_PROD_ID12("SMC", "2632W", 0xc4f8b18b, 0x30f38774), 565 PCMCIA_DEVICE_PROD_ID12_INFO("CNet", "CNWLC 11Mbps Wireless PC Card V-5", 0xbc477dde, 0x502fae6b, ATMEL_FW_TYPE_502E),
654 PCMCIA_DEVICE_PROD_ID12("SMC", "2632W-V2", 0xc4f8b18b, 0x172d1377), 566 PCMCIA_DEVICE_PROD_ID12_INFO("IEEE 802.11b", "Wireless LAN PC Card", 0x5b878724, 0x122f1df6, ATMEL_FW_TYPE_502),
655 PCMCIA_DEVICE_PROD_ID12("Wireless", "PC", 0xa407ecdd, 0x556e4d7e), 567 PCMCIA_DEVICE_PROD_ID12_INFO("IEEE 802.11b", "Wireless LAN Card S", 0x5b878724, 0x5fba533a, ATMEL_FW_TYPE_504_2958),
656 PCMCIA_DEVICE_PROD_ID12("WLAN", "802.11b PC CARD", 0x575c516c, 0xb1f6dbc4), 568 PCMCIA_DEVICE_PROD_ID12_INFO("OEM", "11Mbps Wireless LAN PC Card V-3", 0xfea54c90, 0x1c5b0f68, ATMEL_FW_TYPE_502),
569 PCMCIA_DEVICE_PROD_ID12_INFO("SMC", "2632W", 0xc4f8b18b, 0x30f38774, ATMEL_FW_TYPE_502D),
570 PCMCIA_DEVICE_PROD_ID12_INFO("SMC", "2632W-V2", 0xc4f8b18b, 0x172d1377, ATMEL_FW_TYPE_502),
571 PCMCIA_DEVICE_PROD_ID12_INFO("Wireless", "PC_CARD", 0xa407ecdd, 0x119f6314, ATMEL_FW_TYPE_502D),
572 PCMCIA_DEVICE_PROD_ID12_INFO("WLAN", "802.11b PC CARD", 0x575c516c, 0xb1f6dbc4, ATMEL_FW_TYPE_502D),
573 PCMCIA_DEVICE_PROD_ID12_INFO("LG", "LW2100N", 0xb474d43a, 0x6b1fec94, ATMEL_FW_TYPE_502E),
657 PCMCIA_DEVICE_NULL 574 PCMCIA_DEVICE_NULL
658}; 575};
576
659MODULE_DEVICE_TABLE(pcmcia, atmel_ids); 577MODULE_DEVICE_TABLE(pcmcia, atmel_ids);
660 578
661static struct pcmcia_driver atmel_driver = { 579static struct pcmcia_driver atmel_driver = {
diff --git a/drivers/net/wireless/atmel_pci.c b/drivers/net/wireless/atmel_pci.c
index 2eb00a957bbe..a61b3bc6cccf 100644
--- a/drivers/net/wireless/atmel_pci.c
+++ b/drivers/net/wireless/atmel_pci.c
@@ -72,7 +72,7 @@ static int __devinit atmel_pci_probe(struct pci_dev *pdev,
72 72
73static void __devexit atmel_pci_remove(struct pci_dev *pdev) 73static void __devexit atmel_pci_remove(struct pci_dev *pdev)
74{ 74{
75 stop_atmel_card(pci_get_drvdata(pdev), 1); 75 stop_atmel_card(pci_get_drvdata(pdev));
76} 76}
77 77
78static int __init atmel_init_module(void) 78static int __init atmel_init_module(void)
diff --git a/drivers/net/wireless/hermes.c b/drivers/net/wireless/hermes.c
index 579480dad374..346c6febb033 100644
--- a/drivers/net/wireless/hermes.c
+++ b/drivers/net/wireless/hermes.c
@@ -398,7 +398,7 @@ static int hermes_bap_seek(hermes_t *hw, int bap, u16 id, u16 offset)
398 * 398 *
399 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 399 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
400 */ 400 */
401int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len, 401int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
402 u16 id, u16 offset) 402 u16 id, u16 offset)
403{ 403{
404 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 404 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -424,7 +424,7 @@ int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len,
424 * 424 *
425 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 425 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
426 */ 426 */
427int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len, 427int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
428 u16 id, u16 offset) 428 u16 id, u16 offset)
429{ 429{
430 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 430 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
@@ -450,7 +450,7 @@ int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len,
450 * 450 *
451 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware 451 * Returns: < 0 on internal failure (errno), 0 on success, > 0 on error from firmware
452 */ 452 */
453int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, unsigned len, 453int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, unsigned data_len, int len,
454 u16 id, u16 offset) 454 u16 id, u16 offset)
455{ 455{
456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0; 456 int dreg = bap ? HERMES_DATA1 : HERMES_DATA0;
diff --git a/drivers/net/wireless/hermes.h b/drivers/net/wireless/hermes.h
index a6bd472d75d4..7644f72a9f4e 100644
--- a/drivers/net/wireless/hermes.h
+++ b/drivers/net/wireless/hermes.h
@@ -372,12 +372,12 @@ int hermes_docmd_wait(hermes_t *hw, u16 cmd, u16 parm0,
372 struct hermes_response *resp); 372 struct hermes_response *resp);
373int hermes_allocate(hermes_t *hw, u16 size, u16 *fid); 373int hermes_allocate(hermes_t *hw, u16 size, u16 *fid);
374 374
375int hermes_bap_pread(hermes_t *hw, int bap, void *buf, unsigned len, 375int hermes_bap_pread(hermes_t *hw, int bap, void *buf, int len,
376 u16 id, u16 offset); 376 u16 id, u16 offset);
377int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, unsigned len, 377int hermes_bap_pwrite(hermes_t *hw, int bap, const void *buf, int len,
378 u16 id, u16 offset); 378 u16 id, u16 offset);
379int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf, 379int hermes_bap_pwrite_pad(hermes_t *hw, int bap, const void *buf,
380 unsigned data_len, unsigned len, u16 id, u16 offset); 380 unsigned data_len, int len, u16 id, u16 offset);
381int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen, 381int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned buflen,
382 u16 *length, void *buf); 382 u16 *length, void *buf);
383int hermes_write_ltv(hermes_t *hw, int bap, u16 rid, 383int hermes_write_ltv(hermes_t *hw, int bap, u16 rid,
diff --git a/drivers/net/wireless/i82593.h b/drivers/net/wireless/i82593.h
index 33acb8add4d6..afac5c7a323d 100644
--- a/drivers/net/wireless/i82593.h
+++ b/drivers/net/wireless/i82593.h
@@ -7,11 +7,16 @@
7 * 7 *
8 * Copyright 1994, Anders Klemets <klemets@it.kth.se> 8 * Copyright 1994, Anders Klemets <klemets@it.kth.se>
9 * 9 *
10 * This software may be freely distributed for noncommercial purposes
11 * as long as this notice is retained.
12 *
13 * HISTORY 10 * HISTORY
14 * i82593.h,v 11 * i82593.h,v
12 * Revision 1.4 2005/11/4 09:15:00 baroniunas
13 * Modified copyright with permission of author as follows:
14 *
15 * "If I82539.H is the only file with my copyright statement
16 * that is included in the Source Forge project, then you have
17 * my approval to change the copyright statement to be a GPL
18 * license, in the way you proposed on October 10."
19 *
15 * Revision 1.1 1996/07/17 15:23:12 root 20 * Revision 1.1 1996/07/17 15:23:12 root
16 * Initial revision 21 * Initial revision
17 * 22 *
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c
index a2e6214169e9..77d2a21d4cd0 100644
--- a/drivers/net/wireless/ipw2100.c
+++ b/drivers/net/wireless/ipw2100.c
@@ -6344,7 +6344,8 @@ static struct net_device *ipw2100_alloc_device(struct pci_dev *pci_dev,
6344 dev->ethtool_ops = &ipw2100_ethtool_ops; 6344 dev->ethtool_ops = &ipw2100_ethtool_ops;
6345 dev->tx_timeout = ipw2100_tx_timeout; 6345 dev->tx_timeout = ipw2100_tx_timeout;
6346 dev->wireless_handlers = &ipw2100_wx_handler_def; 6346 dev->wireless_handlers = &ipw2100_wx_handler_def;
6347 dev->get_wireless_stats = ipw2100_wx_wireless_stats; 6347 priv->wireless_data.ieee80211 = priv->ieee;
6348 dev->wireless_data = &priv->wireless_data;
6348 dev->set_mac_address = ipw2100_set_address; 6349 dev->set_mac_address = ipw2100_set_address;
6349 dev->watchdog_timeo = 3 * HZ; 6350 dev->watchdog_timeo = 3 * HZ;
6350 dev->irq = 0; 6351 dev->irq = 0;
@@ -7178,6 +7179,11 @@ static int ipw2100_wx_get_range(struct net_device *dev,
7178 } 7179 }
7179 range->num_frequency = val; 7180 range->num_frequency = val;
7180 7181
7182 /* Event capability (kernel + driver) */
7183 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
7184 IW_EVENT_CAPA_MASK(SIOCGIWAP));
7185 range->event_capa[1] = IW_EVENT_CAPA_K_1;
7186
7181 IPW_DEBUG_WX("GET Range\n"); 7187 IPW_DEBUG_WX("GET Range\n");
7182 7188
7183 return 0; 7189 return 0;
@@ -8446,16 +8452,6 @@ static iw_handler ipw2100_private_handler[] = {
8446#endif /* CONFIG_IPW2100_MONITOR */ 8452#endif /* CONFIG_IPW2100_MONITOR */
8447}; 8453};
8448 8454
8449static struct iw_handler_def ipw2100_wx_handler_def = {
8450 .standard = ipw2100_wx_handlers,
8451 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler),
8452 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler),
8453 .num_private_args = sizeof(ipw2100_private_args) /
8454 sizeof(struct iw_priv_args),
8455 .private = (iw_handler *) ipw2100_private_handler,
8456 .private_args = (struct iw_priv_args *)ipw2100_private_args,
8457};
8458
8459/* 8455/*
8460 * Get wireless statistics. 8456 * Get wireless statistics.
8461 * Called by /proc/net/wireless 8457 * Called by /proc/net/wireless
@@ -8597,6 +8593,17 @@ static struct iw_statistics *ipw2100_wx_wireless_stats(struct net_device *dev)
8597 return (struct iw_statistics *)NULL; 8593 return (struct iw_statistics *)NULL;
8598} 8594}
8599 8595
8596static struct iw_handler_def ipw2100_wx_handler_def = {
8597 .standard = ipw2100_wx_handlers,
8598 .num_standard = sizeof(ipw2100_wx_handlers) / sizeof(iw_handler),
8599 .num_private = sizeof(ipw2100_private_handler) / sizeof(iw_handler),
8600 .num_private_args = sizeof(ipw2100_private_args) /
8601 sizeof(struct iw_priv_args),
8602 .private = (iw_handler *) ipw2100_private_handler,
8603 .private_args = (struct iw_priv_args *)ipw2100_private_args,
8604 .get_wireless_stats = ipw2100_wx_wireless_stats,
8605};
8606
8600static void ipw2100_wx_event_work(struct ipw2100_priv *priv) 8607static void ipw2100_wx_event_work(struct ipw2100_priv *priv)
8601{ 8608{
8602 union iwreq_data wrqu; 8609 union iwreq_data wrqu;
diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h
index 140fdf2a0a09..7c65b10bb164 100644
--- a/drivers/net/wireless/ipw2100.h
+++ b/drivers/net/wireless/ipw2100.h
@@ -571,6 +571,8 @@ struct ipw2100_priv {
571 struct net_device *net_dev; 571 struct net_device *net_dev;
572 struct iw_statistics wstats; 572 struct iw_statistics wstats;
573 573
574 struct iw_public_data wireless_data;
575
574 struct tasklet_struct irq_tasklet; 576 struct tasklet_struct irq_tasklet;
575 577
576 struct workqueue_struct *workqueue; 578 struct workqueue_struct *workqueue;
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c
index b0d195d1721a..5e7c7e944c9d 100644
--- a/drivers/net/wireless/ipw2200.c
+++ b/drivers/net/wireless/ipw2200.c
@@ -1110,8 +1110,7 @@ static struct ipw_fw_error *ipw_alloc_error_log(struct ipw_priv *priv)
1110 error->elem_len = elem_len; 1110 error->elem_len = elem_len;
1111 error->log_len = log_len; 1111 error->log_len = log_len;
1112 error->elem = (struct ipw_error_elem *)error->payload; 1112 error->elem = (struct ipw_error_elem *)error->payload;
1113 error->log = (struct ipw_event *)(error->elem + 1113 error->log = (struct ipw_event *)(error->elem + elem_len);
1114 (sizeof(*error->elem) * elem_len));
1115 1114
1116 ipw_capture_event_log(priv, log_len, error->log); 1115 ipw_capture_event_log(priv, log_len, error->log);
1117 1116
@@ -8926,6 +8925,10 @@ static int ipw_request_direct_scan(struct ipw_priv *priv, char *essid,
8926 struct ipw_scan_request_ext scan; 8925 struct ipw_scan_request_ext scan;
8927 int err = 0, scan_type; 8926 int err = 0, scan_type;
8928 8927
8928 if (!(priv->status & STATUS_INIT) ||
8929 (priv->status & STATUS_EXIT_PENDING))
8930 return 0;
8931
8929 down(&priv->sem); 8932 down(&priv->sem);
8930 8933
8931 if (priv->status & STATUS_RF_KILL_MASK) { 8934 if (priv->status & STATUS_RF_KILL_MASK) {
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c
index 488ab06fb79f..6fd0bf736830 100644
--- a/drivers/net/wireless/orinoco.c
+++ b/drivers/net/wireless/orinoco.c
@@ -3512,9 +3512,8 @@ static int orinoco_ioctl_setpower(struct net_device *dev,
3512 break; 3512 break;
3513 default: 3513 default:
3514 err = -EINVAL; 3514 err = -EINVAL;
3515 }
3516 if (err)
3517 goto out; 3515 goto out;
3516 }
3518 3517
3519 if (prq->flags & IW_POWER_TIMEOUT) { 3518 if (prq->flags & IW_POWER_TIMEOUT) {
3520 priv->pm_on = 1; 3519 priv->pm_on = 1;
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/prism54/isl_38xx.c b/drivers/net/wireless/prism54/isl_38xx.c
index 109a96d90007..23deee69974b 100644
--- a/drivers/net/wireless/prism54/isl_38xx.c
+++ b/drivers/net/wireless/prism54/isl_38xx.c
@@ -164,12 +164,12 @@ isl38xx_trigger_device(int asleep, void __iomem *device_base)
164 /* assert the Wakeup interrupt in the Device Interrupt Register */ 164 /* assert the Wakeup interrupt in the Device Interrupt Register */
165 isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_WAKEUP, 165 isl38xx_w32_flush(device_base, ISL38XX_DEV_INT_WAKEUP,
166 ISL38XX_DEV_INT_REG); 166 ISL38XX_DEV_INT_REG);
167
168#if VERBOSE > SHOW_ERROR_MESSAGES
167 udelay(ISL38XX_WRITEIO_DELAY); 169 udelay(ISL38XX_WRITEIO_DELAY);
168 170
169 /* perform another read on the Device Status Register */ 171 /* perform another read on the Device Status Register */
170 reg = readl(device_base + ISL38XX_CTRL_STAT_REG); 172 reg = readl(device_base + ISL38XX_CTRL_STAT_REG);
171
172#if VERBOSE > SHOW_ERROR_MESSAGES
173 do_gettimeofday(&current_time); 173 do_gettimeofday(&current_time);
174 DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n", 174 DEBUG(SHOW_TRACING, "%08li.%08li Device register read %08x\n",
175 current_time.tv_sec, (long)current_time.tv_usec, reg); 175 current_time.tv_sec, (long)current_time.tv_usec, reg);
diff --git a/drivers/parisc/iosapic.c b/drivers/parisc/iosapic.c
index a39fbfef789a..19657efa8dc3 100644
--- a/drivers/parisc/iosapic.c
+++ b/drivers/parisc/iosapic.c
@@ -700,6 +700,28 @@ static unsigned int iosapic_startup_irq(unsigned int irq)
700 return 0; 700 return 0;
701} 701}
702 702
703#ifdef CONFIG_SMP
704static void iosapic_set_affinity_irq(unsigned int irq, cpumask_t dest)
705{
706 struct vector_info *vi = iosapic_get_vector(irq);
707 u32 d0, d1, dummy_d0;
708 unsigned long flags;
709
710 if (cpu_check_affinity(irq, &dest))
711 return;
712
713 vi->txn_addr = txn_affinity_addr(irq, first_cpu(dest));
714
715 spin_lock_irqsave(&iosapic_lock, flags);
716 /* d1 contains the destination CPU, so only want to set that
717 * entry */
718 iosapic_rd_irt_entry(vi, &d0, &d1);
719 iosapic_set_irt_data(vi, &dummy_d0, &d1);
720 iosapic_wr_irt_entry(vi, d0, d1);
721 spin_unlock_irqrestore(&iosapic_lock, flags);
722}
723#endif
724
703static struct hw_interrupt_type iosapic_interrupt_type = { 725static struct hw_interrupt_type iosapic_interrupt_type = {
704 .typename = "IO-SAPIC-level", 726 .typename = "IO-SAPIC-level",
705 .startup = iosapic_startup_irq, 727 .startup = iosapic_startup_irq,
@@ -708,7 +730,9 @@ static struct hw_interrupt_type iosapic_interrupt_type = {
708 .disable = iosapic_disable_irq, 730 .disable = iosapic_disable_irq,
709 .ack = no_ack_irq, 731 .ack = no_ack_irq,
710 .end = iosapic_end_irq, 732 .end = iosapic_end_irq,
711// .set_affinity = iosapic_set_affinity_irq, 733#ifdef CONFIG_SMP
734 .set_affinity = iosapic_set_affinity_irq,
735#endif
712}; 736};
713 737
714int iosapic_fixup_irq(void *isi_obj, struct pci_dev *pcidev) 738int iosapic_fixup_irq(void *isi_obj, struct pci_dev *pcidev)
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index bab3bcabcb6e..d14888e149bb 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -24,6 +24,9 @@
24 * Major changes to get basic interrupt infrastructure working to 24 * Major changes to get basic interrupt infrastructure working to
25 * hopefully be able to support all SuperIO devices. Currently 25 * hopefully be able to support all SuperIO devices. Currently
26 * works with serial. -- John Marvin <jsm@fc.hp.com> 26 * works with serial. -- John Marvin <jsm@fc.hp.com>
27 *
28 * Converted superio_init() to be a PCI_FIXUP_FINAL callee.
29 * -- Kyle McMartin <kyle@parisc-linux.org>
27 */ 30 */
28 31
29 32
@@ -141,10 +144,10 @@ superio_interrupt(int parent_irq, void *devp, struct pt_regs *regs)
141} 144}
142 145
143/* Initialize Super I/O device */ 146/* Initialize Super I/O device */
144 147static void
145static void __devinit 148superio_init(struct pci_dev *pcidev)
146superio_init(struct superio_device *sio)
147{ 149{
150 struct superio_device *sio = &sio_dev;
148 struct pci_dev *pdev = sio->lio_pdev; 151 struct pci_dev *pdev = sio->lio_pdev;
149 u16 word; 152 u16 word;
150 153
@@ -160,8 +163,8 @@ superio_init(struct superio_device *sio)
160 /* ...then properly fixup the USB to point at suckyio PIC */ 163 /* ...then properly fixup the USB to point at suckyio PIC */
161 sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev); 164 sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
162 165
163 printk (KERN_INFO "SuperIO: Found NS87560 Legacy I/O device at %s (IRQ %i) \n", 166 printk(KERN_INFO "SuperIO: Found NS87560 Legacy I/O device at %s (IRQ %i) \n",
164 pci_name(pdev),pdev->irq); 167 pci_name(pdev), pdev->irq);
165 168
166 pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base); 169 pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
167 sio->sp1_base &= ~1; 170 sio->sp1_base &= ~1;
@@ -274,7 +277,7 @@ superio_init(struct superio_device *sio)
274 277
275 sio->suckyio_irq_enabled = 1; 278 sio->suckyio_irq_enabled = 1;
276} 279}
277 280DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO, superio_init);
278 281
279static void superio_disable_irq(unsigned int irq) 282static void superio_disable_irq(unsigned int irq)
280{ 283{
@@ -452,8 +455,10 @@ static void superio_fixup_pci(struct pci_dev *pdev)
452DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, superio_fixup_pci); 455DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415, superio_fixup_pci);
453 456
454 457
455static int __devinit superio_probe(struct pci_dev *dev, const struct pci_device_id *id) 458static int __devinit
459superio_probe(struct pci_dev *dev, const struct pci_device_id *id)
456{ 460{
461 struct superio_device *sio = &sio_dev;
457 462
458 /* 463 /*
459 ** superio_probe(00:0e.0) ven 0x100b dev 0x2 sv 0x0 sd 0x0 class 0x1018a 464 ** superio_probe(00:0e.0) ven 0x100b dev 0x2 sv 0x0 sd 0x0 class 0x1018a
@@ -466,7 +471,8 @@ static int __devinit superio_probe(struct pci_dev *dev, const struct pci_device_
466 dev->subsystem_vendor, dev->subsystem_device, 471 dev->subsystem_vendor, dev->subsystem_device,
467 dev->class); 472 dev->class);
468 473
469 superio_init(&sio_dev); 474 if (!sio->suckyio_irq_enabled)
475 BUG(); /* Enabled by PCI_FIXUP_FINAL */
470 476
471 if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) { /* Function 1 */ 477 if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) { /* Function 1 */
472 superio_parport_init(); 478 superio_parport_init();
@@ -481,19 +487,21 @@ static int __devinit superio_probe(struct pci_dev *dev, const struct pci_device_
481 DBG_INIT("superio_probe: WTF? Fire Extinguisher?\n"); 487 DBG_INIT("superio_probe: WTF? Fire Extinguisher?\n");
482 } 488 }
483 489
484 /* Let appropriate other driver claim this device. */ 490 /* Let appropriate other driver claim this device. */
485 return -ENODEV; 491 return -ENODEV;
486} 492}
487 493
488static struct pci_device_id superio_tbl[] = { 494static struct pci_device_id superio_tbl[] = {
489 { PCI_VENDOR_ID_NS, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 495 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_LIO) },
496 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87560_USB) },
497 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_87415) },
490 { 0, } 498 { 0, }
491}; 499};
492 500
493static struct pci_driver superio_driver = { 501static struct pci_driver superio_driver = {
494 .name = "SuperIO", 502 .name = "SuperIO",
495 .id_table = superio_tbl, 503 .id_table = superio_tbl,
496 .probe = superio_probe, 504 .probe = superio_probe,
497}; 505};
498 506
499static int __init superio_modinit(void) 507static int __init superio_modinit(void)
@@ -506,6 +514,5 @@ static void __exit superio_exit(void)
506 pci_unregister_driver(&superio_driver); 514 pci_unregister_driver(&superio_driver);
507} 515}
508 516
509
510module_init(superio_modinit); 517module_init(superio_modinit);
511module_exit(superio_exit); 518module_exit(superio_exit);
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/access.c b/drivers/pci/access.c
index 2a42add7f563..ea16805a153c 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -2,6 +2,8 @@
2#include <linux/module.h> 2#include <linux/module.h>
3#include <linux/ioport.h> 3#include <linux/ioport.h>
4 4
5#include "pci.h"
6
5/* 7/*
6 * This interrupt-safe spinlock protects all accesses to PCI 8 * This interrupt-safe spinlock protects all accesses to PCI
7 * configuration space. 9 * configuration space.
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 061ead21ef14..6a61b9f286e1 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -32,8 +32,6 @@
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/delay.h> 34#include <linux/delay.h>
35#include <asm/semaphore.h>
36#include <asm/io.h>
37#include <linux/pcieport_if.h> 35#include <linux/pcieport_if.h>
38#include "pci_hotplug.h" 36#include "pci_hotplug.h"
39 37
@@ -42,6 +40,7 @@
42extern int pciehp_poll_mode; 40extern int pciehp_poll_mode;
43extern int pciehp_poll_time; 41extern int pciehp_poll_time;
44extern int pciehp_debug; 42extern int pciehp_debug;
43extern int pciehp_force;
45 44
46/*#define dbg(format, arg...) do { if (pciehp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/ 45/*#define dbg(format, arg...) do { if (pciehp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/
47#define dbg(format, arg...) do { if (pciehp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0) 46#define dbg(format, arg...) do { if (pciehp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0)
@@ -49,25 +48,11 @@ extern int pciehp_debug;
49#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg) 48#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
50#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg) 49#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
51 50
52struct pci_func { 51struct hotplug_params {
53 struct pci_func *next; 52 u8 cache_line_size;
54 u8 bus; 53 u8 latency_timer;
55 u8 device; 54 u8 enable_serr;
56 u8 function; 55 u8 enable_perr;
57 u8 is_a_board;
58 u16 status;
59 u8 configured;
60 u8 switch_save;
61 u8 presence_save;
62 u32 base_length[0x06];
63 u8 base_type[0x06];
64 u16 reserved2;
65 u32 config_space[0x20];
66 struct pci_resource *mem_head;
67 struct pci_resource *p_mem_head;
68 struct pci_resource *io_head;
69 struct pci_resource *bus_head;
70 struct pci_dev* pci_dev;
71}; 56};
72 57
73struct slot { 58struct slot {
@@ -75,13 +60,7 @@ struct slot {
75 u8 bus; 60 u8 bus;
76 u8 device; 61 u8 device;
77 u32 number; 62 u32 number;
78 u8 is_a_board;
79 u8 configured;
80 u8 state; 63 u8 state;
81 u8 switch_save;
82 u8 presence_save;
83 u32 capabilities;
84 u16 reserved2;
85 struct timer_list task_event; 64 struct timer_list task_event;
86 u8 hp_slot; 65 u8 hp_slot;
87 struct controller *ctrl; 66 struct controller *ctrl;
@@ -90,42 +69,47 @@ struct slot {
90 struct list_head slot_list; 69 struct list_head slot_list;
91}; 70};
92 71
93struct pci_resource {
94 struct pci_resource * next;
95 u32 base;
96 u32 length;
97};
98
99struct event_info { 72struct event_info {
100 u32 event_type; 73 u32 event_type;
101 u8 hp_slot; 74 u8 hp_slot;
102}; 75};
103 76
77typedef u8(*php_intr_callback_t) (u8 hp_slot, void *instance_id);
78
79struct php_ctlr_state_s {
80 struct php_ctlr_state_s *pnext;
81 struct pci_dev *pci_dev;
82 unsigned int irq;
83 unsigned long flags; /* spinlock's */
84 u32 slot_device_offset;
85 u32 num_slots;
86 struct timer_list int_poll_timer; /* Added for poll event */
87 php_intr_callback_t attention_button_callback;
88 php_intr_callback_t switch_change_callback;
89 php_intr_callback_t presence_change_callback;
90 php_intr_callback_t power_fault_callback;
91 void *callback_instance_id;
92 struct ctrl_reg *creg; /* Ptr to controller register space */
93};
94
95#define MAX_EVENTS 10
104struct controller { 96struct controller {
105 struct controller *next; 97 struct controller *next;
106 struct semaphore crit_sect; /* critical section semaphore */ 98 struct semaphore crit_sect; /* critical section semaphore */
107 void *hpc_ctlr_handle; /* HPC controller handle */ 99 struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
108 int num_slots; /* Number of slots on ctlr */ 100 int num_slots; /* Number of slots on ctlr */
109 int slot_num_inc; /* 1 or -1 */ 101 int slot_num_inc; /* 1 or -1 */
110 struct pci_resource *mem_head;
111 struct pci_resource *p_mem_head;
112 struct pci_resource *io_head;
113 struct pci_resource *bus_head;
114 struct pci_dev *pci_dev; 102 struct pci_dev *pci_dev;
115 struct pci_bus *pci_bus; 103 struct pci_bus *pci_bus;
116 struct event_info event_queue[10]; 104 struct event_info event_queue[MAX_EVENTS];
117 struct slot *slot; 105 struct slot *slot;
118 struct hpc_ops *hpc_ops; 106 struct hpc_ops *hpc_ops;
119 wait_queue_head_t queue; /* sleep & wake process */ 107 wait_queue_head_t queue; /* sleep & wake process */
120 u8 next_event; 108 u8 next_event;
121 u8 seg;
122 u8 bus; 109 u8 bus;
123 u8 device; 110 u8 device;
124 u8 function; 111 u8 function;
125 u8 rev;
126 u8 slot_device_offset; 112 u8 slot_device_offset;
127 u8 add_support;
128 enum pci_bus_speed speed;
129 u32 first_slot; /* First physical slot number */ /* PCIE only has 1 slot */ 113 u32 first_slot; /* First physical slot number */ /* PCIE only has 1 slot */
130 u8 slot_bus; /* Bus where the slots handled by this controller sit */ 114 u8 slot_bus; /* Bus where the slots handled by this controller sit */
131 u8 ctrlcap; 115 u8 ctrlcap;
@@ -133,20 +117,6 @@ struct controller {
133 u8 cap_base; 117 u8 cap_base;
134}; 118};
135 119
136struct irq_mapping {
137 u8 barber_pole;
138 u8 valid_INT;
139 u8 interrupt[4];
140};
141
142struct resource_lists {
143 struct pci_resource *mem_head;
144 struct pci_resource *p_mem_head;
145 struct pci_resource *io_head;
146 struct pci_resource *bus_head;
147 struct irq_mapping *irqs;
148};
149
150#define INT_BUTTON_IGNORE 0 120#define INT_BUTTON_IGNORE 0
151#define INT_PRESENCE_ON 1 121#define INT_PRESENCE_ON 1
152#define INT_PRESENCE_OFF 2 122#define INT_PRESENCE_OFF 2
@@ -200,21 +170,14 @@ struct resource_lists {
200 * error Messages 170 * error Messages
201 */ 171 */
202#define msg_initialization_err "Initialization failure, error=%d\n" 172#define msg_initialization_err "Initialization failure, error=%d\n"
203#define msg_HPC_rev_error "Unsupported revision of the PCI hot plug controller found.\n"
204#define msg_HPC_non_pcie "The PCI hot plug controller is not supported by this driver.\n"
205#define msg_HPC_not_supported "This system is not supported by this version of pciephd module. Upgrade to a newer version of pciehpd\n"
206#define msg_unable_to_save "Unable to store PCI hot plug add resource information. This system must be rebooted before adding any PCI devices.\n"
207#define msg_button_on "PCI slot #%d - powering on due to button press.\n" 173#define msg_button_on "PCI slot #%d - powering on due to button press.\n"
208#define msg_button_off "PCI slot #%d - powering off due to button press.\n" 174#define msg_button_off "PCI slot #%d - powering off due to button press.\n"
209#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n" 175#define msg_button_cancel "PCI slot #%d - action canceled due to button press.\n"
210#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n" 176#define msg_button_ignore "PCI slot #%d - button press ignored. (action in progress...)\n"
211 177
212/* controller functions */ 178/* controller functions */
213extern int pciehprm_find_available_resources (struct controller *ctrl);
214extern int pciehp_event_start_thread (void); 179extern int pciehp_event_start_thread (void);
215extern void pciehp_event_stop_thread (void); 180extern void pciehp_event_stop_thread (void);
216extern struct pci_func *pciehp_slot_create (unsigned char busnumber);
217extern struct pci_func *pciehp_slot_find (unsigned char bus, unsigned char device, unsigned char index);
218extern int pciehp_enable_slot (struct slot *slot); 181extern int pciehp_enable_slot (struct slot *slot);
219extern int pciehp_disable_slot (struct slot *slot); 182extern int pciehp_disable_slot (struct slot *slot);
220 183
@@ -224,25 +187,17 @@ extern u8 pciehp_handle_presence_change (u8 hp_slot, void *inst_id);
224extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id); 187extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id);
225/* extern void long_delay (int delay); */ 188/* extern void long_delay (int delay); */
226 189
227/* resource functions */
228extern int pciehp_resource_sort_and_combine (struct pci_resource **head);
229
230/* pci functions */ 190/* pci functions */
231extern int pciehp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num); 191extern int pciehp_configure_device (struct slot *p_slot);
232/*extern int pciehp_get_bus_dev (struct controller *ctrl, u8 *bus_num, u8 *dev_num, struct slot *slot);*/ 192extern int pciehp_unconfigure_device (struct slot *p_slot);
233extern int pciehp_save_config (struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num); 193extern int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev);
234extern int pciehp_save_used_resources (struct controller *ctrl, struct pci_func * func, int flag); 194extern void pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
235extern int pciehp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot); 195 struct hotplug_params *hpp);
236extern void pciehp_destroy_board_resources (struct pci_func * func); 196
237extern int pciehp_return_board_resources (struct pci_func * func, struct resource_lists * resources);
238extern void pciehp_destroy_resource_list (struct resource_lists * resources);
239extern int pciehp_configure_device (struct controller* ctrl, struct pci_func* func);
240extern int pciehp_unconfigure_device (struct pci_func* func);
241 197
242 198
243/* Global variables */ 199/* Global variables */
244extern struct controller *pciehp_ctrl_list; 200extern struct controller *pciehp_ctrl_list;
245extern struct pci_func *pciehp_slot_list[256];
246 201
247/* Inline functions */ 202/* Inline functions */
248 203
@@ -252,12 +207,9 @@ static inline struct slot *pciehp_find_slot(struct controller *ctrl, u8 device)
252 207
253 p_slot = ctrl->slot; 208 p_slot = ctrl->slot;
254 209
255 dbg("p_slot = %p\n", p_slot);
256
257 while (p_slot && (p_slot->device != device)) { 210 while (p_slot && (p_slot->device != device)) {
258 tmp_slot = p_slot; 211 tmp_slot = p_slot;
259 p_slot = p_slot->next; 212 p_slot = p_slot->next;
260 dbg("In while loop, p_slot = %p\n", p_slot);
261 } 213 }
262 if (p_slot == NULL) { 214 if (p_slot == NULL) {
263 err("ERROR: pciehp_find_slot device=0x%x\n", device); 215 err("ERROR: pciehp_find_slot device=0x%x\n", device);
@@ -273,7 +225,6 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl)
273 225
274 DECLARE_WAITQUEUE(wait, current); 226 DECLARE_WAITQUEUE(wait, current);
275 227
276 dbg("%s : start\n", __FUNCTION__);
277 add_wait_queue(&ctrl->queue, &wait); 228 add_wait_queue(&ctrl->queue, &wait);
278 if (!pciehp_poll_mode) 229 if (!pciehp_poll_mode)
279 /* Sleep for up to 1 second */ 230 /* Sleep for up to 1 second */
@@ -285,19 +236,9 @@ static inline int wait_for_ctrl_irq(struct controller *ctrl)
285 if (signal_pending(current)) 236 if (signal_pending(current))
286 retval = -EINTR; 237 retval = -EINTR;
287 238
288 dbg("%s : end\n", __FUNCTION__);
289 return retval; 239 return retval;
290} 240}
291 241
292/* Puts node back in the resource list pointed to by head */
293static inline void return_resource(struct pci_resource **head, struct pci_resource *node)
294{
295 if (!node || !head)
296 return;
297 node->next = *head;
298 *head = node;
299}
300
301#define SLOT_NAME_SIZE 10 242#define SLOT_NAME_SIZE 10
302 243
303static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot) 244static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
@@ -311,14 +252,7 @@ enum php_ctlr_type {
311 ACPI 252 ACPI
312}; 253};
313 254
314typedef u8(*php_intr_callback_t) (unsigned int change_id, void *instance_id); 255int pcie_init(struct controller *ctrl, struct pcie_device *dev);
315
316int pcie_init(struct controller *ctrl, struct pcie_device *dev,
317 php_intr_callback_t attention_button_callback,
318 php_intr_callback_t switch_change_callback,
319 php_intr_callback_t presence_change_callback,
320 php_intr_callback_t power_fault_callback);
321
322 256
323/* This has no meaning for PCI Express, as there is only 1 slot per port */ 257/* This has no meaning for PCI Express, as there is only 1 slot per port */
324int pcie_get_ctlr_slot_config(struct controller *ctrl, 258int pcie_get_ctlr_slot_config(struct controller *ctrl,
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index cafc7eadcf80..8df704860348 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -27,27 +27,20 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/moduleparam.h> 31#include <linux/moduleparam.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
34#include <linux/types.h> 33#include <linux/types.h>
35#include <linux/proc_fs.h>
36#include <linux/slab.h>
37#include <linux/workqueue.h>
38#include <linux/pci.h> 34#include <linux/pci.h>
39#include <linux/init.h>
40#include <asm/uaccess.h>
41#include "pciehp.h" 35#include "pciehp.h"
42#include "pciehprm.h"
43#include <linux/interrupt.h> 36#include <linux/interrupt.h>
44 37
45/* Global variables */ 38/* Global variables */
46int pciehp_debug; 39int pciehp_debug;
47int pciehp_poll_mode; 40int pciehp_poll_mode;
48int pciehp_poll_time; 41int pciehp_poll_time;
42int pciehp_force;
49struct controller *pciehp_ctrl_list; 43struct controller *pciehp_ctrl_list;
50struct pci_func *pciehp_slot_list[256];
51 44
52#define DRIVER_VERSION "0.4" 45#define DRIVER_VERSION "0.4"
53#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>" 46#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -60,9 +53,11 @@ MODULE_LICENSE("GPL");
60module_param(pciehp_debug, bool, 0644); 53module_param(pciehp_debug, bool, 0644);
61module_param(pciehp_poll_mode, bool, 0644); 54module_param(pciehp_poll_mode, bool, 0644);
62module_param(pciehp_poll_time, int, 0644); 55module_param(pciehp_poll_time, int, 0644);
56module_param(pciehp_force, bool, 0644);
63MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not"); 57MODULE_PARM_DESC(pciehp_debug, "Debugging mode enabled or not");
64MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not"); 58MODULE_PARM_DESC(pciehp_poll_mode, "Using polling mechanism for hot-plug events or not");
65MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds"); 59MODULE_PARM_DESC(pciehp_poll_time, "Polling mechanism frequency, in seconds");
60MODULE_PARM_DESC(pciehp_force, "Force pciehp, even if _OSC and OSHP are missing");
66 61
67#define PCIE_MODULE_NAME "pciehp" 62#define PCIE_MODULE_NAME "pciehp"
68 63
@@ -114,8 +109,6 @@ static int init_slots(struct controller *ctrl)
114 u32 slot_number; 109 u32 slot_number;
115 int result = -ENOMEM; 110 int result = -ENOMEM;
116 111
117 dbg("%s\n",__FUNCTION__);
118
119 number_of_slots = ctrl->num_slots; 112 number_of_slots = ctrl->num_slots;
120 slot_device = ctrl->slot_device_offset; 113 slot_device = ctrl->slot_device_offset;
121 slot_number = ctrl->first_slot; 114 slot_number = ctrl->first_slot;
@@ -370,7 +363,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
370 u8 value; 363 u8 value;
371 struct pci_dev *pdev; 364 struct pci_dev *pdev;
372 365
373 dbg("%s: Called by hp_drv\n", __FUNCTION__);
374 ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL); 366 ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
375 if (!ctrl) { 367 if (!ctrl) {
376 err("%s : out of memory\n", __FUNCTION__); 368 err("%s : out of memory\n", __FUNCTION__);
@@ -378,22 +370,15 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
378 } 370 }
379 memset(ctrl, 0, sizeof(struct controller)); 371 memset(ctrl, 0, sizeof(struct controller));
380 372
381 dbg("%s: DRV_thread pid = %d\n", __FUNCTION__, current->pid);
382
383 pdev = dev->port; 373 pdev = dev->port;
374 ctrl->pci_dev = pdev;
384 375
385 rc = pcie_init(ctrl, dev, 376 rc = pcie_init(ctrl, dev);
386 (php_intr_callback_t) pciehp_handle_attention_button,
387 (php_intr_callback_t) pciehp_handle_switch_change,
388 (php_intr_callback_t) pciehp_handle_presence_change,
389 (php_intr_callback_t) pciehp_handle_power_fault);
390 if (rc) { 377 if (rc) {
391 dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME); 378 dbg("%s: controller initialization failed\n", PCIE_MODULE_NAME);
392 goto err_out_free_ctrl; 379 goto err_out_free_ctrl;
393 } 380 }
394 381
395 ctrl->pci_dev = pdev;
396
397 pci_set_drvdata(pdev, ctrl); 382 pci_set_drvdata(pdev, ctrl);
398 383
399 ctrl->pci_bus = kmalloc(sizeof(*ctrl->pci_bus), GFP_KERNEL); 384 ctrl->pci_bus = kmalloc(sizeof(*ctrl->pci_bus), GFP_KERNEL);
@@ -402,7 +387,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
402 rc = -ENOMEM; 387 rc = -ENOMEM;
403 goto err_out_unmap_mmio_region; 388 goto err_out_unmap_mmio_region;
404 } 389 }
405 dbg("%s: ctrl->pci_bus %p\n", __FUNCTION__, ctrl->pci_bus);
406 memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus)); 390 memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus));
407 ctrl->bus = pdev->bus->number; /* ctrl bus */ 391 ctrl->bus = pdev->bus->number; /* ctrl bus */
408 ctrl->slot_bus = pdev->subordinate->number; /* bus controlled by this HPC */ 392 ctrl->slot_bus = pdev->subordinate->number; /* bus controlled by this HPC */
@@ -424,25 +408,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
424 first_device_num = ctrl->slot_device_offset; 408 first_device_num = ctrl->slot_device_offset;
425 num_ctlr_slots = ctrl->num_slots; 409 num_ctlr_slots = ctrl->num_slots;
426 410
427 /* Store PCI Config Space for all devices on this bus */
428 dbg("%s: Before calling pciehp_save_config, ctrl->bus %x,ctrl->slot_bus %x\n",
429 __FUNCTION__,ctrl->bus, ctrl->slot_bus);
430 rc = pciehp_save_config(ctrl, ctrl->slot_bus, num_ctlr_slots, first_device_num);
431 if (rc) {
432 err("%s: unable to save PCI configuration data, error %d\n", __FUNCTION__, rc);
433 goto err_out_free_ctrl_bus;
434 }
435
436 /* Get IO, memory, and IRQ resources for new devices */
437 rc = pciehprm_find_available_resources(ctrl);
438 ctrl->add_support = !rc;
439
440 if (rc) {
441 dbg("pciehprm_find_available_resources = %#x\n", rc);
442 err("unable to locate PCI configuration resources for hot plug add.\n");
443 goto err_out_free_ctrl_bus;
444 }
445
446 /* Setup the slot information structures */ 411 /* Setup the slot information structures */
447 rc = init_slots(ctrl); 412 rc = init_slots(ctrl);
448 if (rc) { 413 if (rc) {
@@ -451,7 +416,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
451 } 416 }
452 417
453 t_slot = pciehp_find_slot(ctrl, first_device_num); 418 t_slot = pciehp_find_slot(ctrl, first_device_num);
454 dbg("%s: t_slot %p\n", __FUNCTION__, t_slot);
455 419
456 /* Finish setting up the hot plug ctrl device */ 420 /* Finish setting up the hot plug ctrl device */
457 ctrl->next_event = 0; 421 ctrl->next_event = 0;
@@ -468,7 +432,6 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
468 down(&ctrl->crit_sect); 432 down(&ctrl->crit_sect);
469 433
470 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */ 434 t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
471 dbg("%s: adpater value %x\n", __FUNCTION__, value);
472 435
473 if ((POWER_CTRL(ctrl->ctrlcap)) && !value) { 436 if ((POWER_CTRL(ctrl->ctrlcap)) && !value) {
474 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/ 437 rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
@@ -501,7 +464,6 @@ err_out_none:
501 464
502static int pcie_start_thread(void) 465static int pcie_start_thread(void)
503{ 466{
504 int loop;
505 int retval = 0; 467 int retval = 0;
506 468
507 dbg("Initialize + Start the notification/polling mechanism \n"); 469 dbg("Initialize + Start the notification/polling mechanism \n");
@@ -512,32 +474,11 @@ static int pcie_start_thread(void)
512 return retval; 474 return retval;
513 } 475 }
514 476
515 dbg("Initialize slot lists\n");
516 /* One slot list for each bus in the system */
517 for (loop = 0; loop < 256; loop++) {
518 pciehp_slot_list[loop] = NULL;
519 }
520
521 return retval; 477 return retval;
522} 478}
523 479
524static inline void __exit
525free_pciehp_res(struct pci_resource *res)
526{
527 struct pci_resource *tres;
528
529 while (res) {
530 tres = res;
531 res = res->next;
532 kfree(tres);
533 }
534}
535
536static void __exit unload_pciehpd(void) 480static void __exit unload_pciehpd(void)
537{ 481{
538 struct pci_func *next;
539 struct pci_func *TempSlot;
540 int loop;
541 struct controller *ctrl; 482 struct controller *ctrl;
542 struct controller *tctrl; 483 struct controller *tctrl;
543 484
@@ -546,11 +487,6 @@ static void __exit unload_pciehpd(void)
546 while (ctrl) { 487 while (ctrl) {
547 cleanup_slots(ctrl); 488 cleanup_slots(ctrl);
548 489
549 free_pciehp_res(ctrl->io_head);
550 free_pciehp_res(ctrl->mem_head);
551 free_pciehp_res(ctrl->p_mem_head);
552 free_pciehp_res(ctrl->bus_head);
553
554 kfree (ctrl->pci_bus); 490 kfree (ctrl->pci_bus);
555 491
556 ctrl->hpc_ops->release_ctlr(ctrl); 492 ctrl->hpc_ops->release_ctlr(ctrl);
@@ -561,20 +497,6 @@ static void __exit unload_pciehpd(void)
561 kfree(tctrl); 497 kfree(tctrl);
562 } 498 }
563 499
564 for (loop = 0; loop < 256; loop++) {
565 next = pciehp_slot_list[loop];
566 while (next != NULL) {
567 free_pciehp_res(next->io_head);
568 free_pciehp_res(next->mem_head);
569 free_pciehp_res(next->p_mem_head);
570 free_pciehp_res(next->bus_head);
571
572 TempSlot = next;
573 next = next->next;
574 kfree(TempSlot);
575 }
576 }
577
578 /* Stop the notification mechanism */ 500 /* Stop the notification mechanism */
579 pciehp_event_stop_thread(); 501 pciehp_event_stop_thread();
580 502
@@ -639,21 +561,16 @@ static int __init pcied_init(void)
639 if (retval) 561 if (retval)
640 goto error_hpc_init; 562 goto error_hpc_init;
641 563
642 retval = pciehprm_init(PCI); 564 retval = pcie_port_service_register(&hpdriver_portdrv);
643 if (!retval) { 565 dbg("pcie_port_service_register = %d\n", retval);
644 retval = pcie_port_service_register(&hpdriver_portdrv); 566 info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
645 dbg("pcie_port_service_register = %d\n", retval); 567 if (retval)
646 info(DRIVER_DESC " version: " DRIVER_VERSION "\n"); 568 dbg("%s: Failure to register service\n", __FUNCTION__);
647 if (retval)
648 dbg("%s: Failure to register service\n", __FUNCTION__);
649 }
650 569
651error_hpc_init: 570error_hpc_init:
652 if (retval) { 571 if (retval) {
653 pciehprm_cleanup();
654 pciehp_event_stop_thread(); 572 pciehp_event_stop_thread();
655 } else 573 };
656 pciehprm_print_pirt();
657 574
658 return retval; 575 return retval;
659} 576}
@@ -663,9 +580,6 @@ static void __exit pcied_cleanup(void)
663 dbg("unload_pciehpd()\n"); 580 dbg("unload_pciehpd()\n");
664 unload_pciehpd(); 581 unload_pciehpd();
665 582
666 pciehprm_cleanup();
667
668 dbg("pcie_port_service_unregister\n");
669 pcie_port_service_unregister(&hpdriver_portdrv); 583 pcie_port_service_unregister(&hpdriver_portdrv);
670 584
671 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n"); 585 info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 898f6da6f0de..83c4b865718a 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -27,25 +27,14 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/slab.h>
35#include <linux/workqueue.h>
36#include <linux/interrupt.h>
37#include <linux/delay.h>
38#include <linux/wait.h>
39#include <linux/smp_lock.h> 33#include <linux/smp_lock.h>
40#include <linux/pci.h> 34#include <linux/pci.h>
41#include "../pci.h" 35#include "../pci.h"
42#include "pciehp.h" 36#include "pciehp.h"
43#include "pciehprm.h"
44 37
45static u32 configure_new_device(struct controller *ctrl, struct pci_func *func,
46 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev);
47static int configure_new_function( struct controller *ctrl, struct pci_func *func,
48 u8 behind_bridge, struct resource_lists *resources, u8 bridge_bus, u8 bridge_dev);
49static void interrupt_event_handler(struct controller *ctrl); 38static void interrupt_event_handler(struct controller *ctrl);
50 39
51static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */ 40static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */
@@ -60,22 +49,18 @@ u8 pciehp_handle_attention_button(u8 hp_slot, void *inst_id)
60 struct slot *p_slot; 49 struct slot *p_slot;
61 u8 rc = 0; 50 u8 rc = 0;
62 u8 getstatus; 51 u8 getstatus;
63 struct pci_func *func;
64 struct event_info *taskInfo; 52 struct event_info *taskInfo;
65 53
66 /* Attention Button Change */ 54 /* Attention Button Change */
67 dbg("pciehp: Attention button interrupt received.\n"); 55 dbg("pciehp: Attention button interrupt received.\n");
68 56
69 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
70
71 /* This is the structure that tells the worker thread what to do */ 57 /* This is the structure that tells the worker thread what to do */
72 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 58 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
73 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 59 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
74 60
75 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
76 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 61 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
77 62
78 ctrl->next_event = (ctrl->next_event + 1) % 10; 63 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
79 taskInfo->hp_slot = hp_slot; 64 taskInfo->hp_slot = hp_slot;
80 65
81 rc++; 66 rc++;
@@ -117,24 +102,20 @@ u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
117 struct slot *p_slot; 102 struct slot *p_slot;
118 u8 rc = 0; 103 u8 rc = 0;
119 u8 getstatus; 104 u8 getstatus;
120 struct pci_func *func;
121 struct event_info *taskInfo; 105 struct event_info *taskInfo;
122 106
123 /* Switch Change */ 107 /* Switch Change */
124 dbg("pciehp: Switch interrupt received.\n"); 108 dbg("pciehp: Switch interrupt received.\n");
125 109
126 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
127
128 /* This is the structure that tells the worker thread 110 /* This is the structure that tells the worker thread
129 * what to do 111 * what to do
130 */ 112 */
131 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 113 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
132 ctrl->next_event = (ctrl->next_event + 1) % 10; 114 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
133 taskInfo->hp_slot = hp_slot; 115 taskInfo->hp_slot = hp_slot;
134 116
135 rc++; 117 rc++;
136 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 118 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
137 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
138 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 119 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
139 120
140 if (getstatus) { 121 if (getstatus) {
@@ -142,14 +123,12 @@ u8 pciehp_handle_switch_change(u8 hp_slot, void *inst_id)
142 * Switch opened 123 * Switch opened
143 */ 124 */
144 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot); 125 info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot);
145 func->switch_save = 0;
146 taskInfo->event_type = INT_SWITCH_OPEN; 126 taskInfo->event_type = INT_SWITCH_OPEN;
147 } else { 127 } else {
148 /* 128 /*
149 * Switch closed 129 * Switch closed
150 */ 130 */
151 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot); 131 info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot);
152 func->switch_save = 0x10;
153 taskInfo->event_type = INT_SWITCH_CLOSE; 132 taskInfo->event_type = INT_SWITCH_CLOSE;
154 } 133 }
155 134
@@ -163,20 +142,17 @@ u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
163{ 142{
164 struct controller *ctrl = (struct controller *) inst_id; 143 struct controller *ctrl = (struct controller *) inst_id;
165 struct slot *p_slot; 144 struct slot *p_slot;
166 u8 rc = 0; 145 u8 presence_save, rc = 0;
167 struct pci_func *func;
168 struct event_info *taskInfo; 146 struct event_info *taskInfo;
169 147
170 /* Presence Change */ 148 /* Presence Change */
171 dbg("pciehp: Presence/Notify input change.\n"); 149 dbg("pciehp: Presence/Notify input change.\n");
172 150
173 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
174
175 /* This is the structure that tells the worker thread 151 /* This is the structure that tells the worker thread
176 * what to do 152 * what to do
177 */ 153 */
178 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 154 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
179 ctrl->next_event = (ctrl->next_event + 1) % 10; 155 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
180 taskInfo->hp_slot = hp_slot; 156 taskInfo->hp_slot = hp_slot;
181 157
182 rc++; 158 rc++;
@@ -185,8 +161,8 @@ u8 pciehp_handle_presence_change(u8 hp_slot, void *inst_id)
185 /* Switch is open, assume a presence change 161 /* Switch is open, assume a presence change
186 * Save the presence state 162 * Save the presence state
187 */ 163 */
188 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save)); 164 p_slot->hpc_ops->get_adapter_status(p_slot, &presence_save);
189 if (func->presence_save) { 165 if (presence_save) {
190 /* 166 /*
191 * Card Present 167 * Card Present
192 */ 168 */
@@ -211,19 +187,16 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
211 struct controller *ctrl = (struct controller *) inst_id; 187 struct controller *ctrl = (struct controller *) inst_id;
212 struct slot *p_slot; 188 struct slot *p_slot;
213 u8 rc = 0; 189 u8 rc = 0;
214 struct pci_func *func;
215 struct event_info *taskInfo; 190 struct event_info *taskInfo;
216 191
217 /* power fault */ 192 /* power fault */
218 dbg("pciehp: Power fault interrupt received.\n"); 193 dbg("pciehp: Power fault interrupt received.\n");
219 194
220 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
221
222 /* this is the structure that tells the worker thread 195 /* this is the structure that tells the worker thread
223 * what to do 196 * what to do
224 */ 197 */
225 taskInfo = &(ctrl->event_queue[ctrl->next_event]); 198 taskInfo = &(ctrl->event_queue[ctrl->next_event]);
226 ctrl->next_event = (ctrl->next_event + 1) % 10; 199 ctrl->next_event = (ctrl->next_event + 1) % MAX_EVENTS;
227 taskInfo->hp_slot = hp_slot; 200 taskInfo->hp_slot = hp_slot;
228 201
229 rc++; 202 rc++;
@@ -234,7 +207,6 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
234 * power fault Cleared 207 * power fault Cleared
235 */ 208 */
236 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot); 209 info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot);
237 func->status = 0x00;
238 taskInfo->event_type = INT_POWER_FAULT_CLEAR; 210 taskInfo->event_type = INT_POWER_FAULT_CLEAR;
239 } else { 211 } else {
240 /* 212 /*
@@ -242,8 +214,6 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
242 */ 214 */
243 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot); 215 info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot);
244 taskInfo->event_type = INT_POWER_FAULT; 216 taskInfo->event_type = INT_POWER_FAULT;
245 /* set power fault status for this board */
246 func->status = 0xFF;
247 info("power fault bit %x set\n", hp_slot); 217 info("power fault bit %x set\n", hp_slot);
248 } 218 }
249 if (rc) 219 if (rc)
@@ -252,810 +222,6 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
252 return rc; 222 return rc;
253} 223}
254 224
255
256/**
257 * sort_by_size: sort nodes by their length, smallest first.
258 *
259 * @head: list to sort
260 */
261static int sort_by_size(struct pci_resource **head)
262{
263 struct pci_resource *current_res;
264 struct pci_resource *next_res;
265 int out_of_order = 1;
266
267 if (!(*head))
268 return 1;
269
270 if (!((*head)->next))
271 return 0;
272
273 while (out_of_order) {
274 out_of_order = 0;
275
276 /* Special case for swapping list head */
277 if (((*head)->next) &&
278 ((*head)->length > (*head)->next->length)) {
279 out_of_order++;
280 current_res = *head;
281 *head = (*head)->next;
282 current_res->next = (*head)->next;
283 (*head)->next = current_res;
284 }
285
286 current_res = *head;
287
288 while (current_res->next && current_res->next->next) {
289 if (current_res->next->length > current_res->next->next->length) {
290 out_of_order++;
291 next_res = current_res->next;
292 current_res->next = current_res->next->next;
293 current_res = current_res->next;
294 next_res->next = current_res->next;
295 current_res->next = next_res;
296 } else
297 current_res = current_res->next;
298 }
299 } /* End of out_of_order loop */
300
301 return 0;
302}
303
304
305/*
306 * sort_by_max_size
307 *
308 * Sorts nodes on the list by their length.
309 * Largest first.
310 *
311 */
312static int sort_by_max_size(struct pci_resource **head)
313{
314 struct pci_resource *current_res;
315 struct pci_resource *next_res;
316 int out_of_order = 1;
317
318 if (!(*head))
319 return 1;
320
321 if (!((*head)->next))
322 return 0;
323
324 while (out_of_order) {
325 out_of_order = 0;
326
327 /* Special case for swapping list head */
328 if (((*head)->next) &&
329 ((*head)->length < (*head)->next->length)) {
330 out_of_order++;
331 current_res = *head;
332 *head = (*head)->next;
333 current_res->next = (*head)->next;
334 (*head)->next = current_res;
335 }
336
337 current_res = *head;
338
339 while (current_res->next && current_res->next->next) {
340 if (current_res->next->length < current_res->next->next->length) {
341 out_of_order++;
342 next_res = current_res->next;
343 current_res->next = current_res->next->next;
344 current_res = current_res->next;
345 next_res->next = current_res->next;
346 current_res->next = next_res;
347 } else
348 current_res = current_res->next;
349 }
350 } /* End of out_of_order loop */
351
352 return 0;
353}
354
355
356/**
357 * do_pre_bridge_resource_split: return one unused resource node
358 * @head: list to scan
359 *
360 */
361static struct pci_resource *
362do_pre_bridge_resource_split(struct pci_resource **head,
363 struct pci_resource **orig_head, u32 alignment)
364{
365 struct pci_resource *prevnode = NULL;
366 struct pci_resource *node;
367 struct pci_resource *split_node;
368 u32 rc;
369 u32 temp_dword;
370 dbg("do_pre_bridge_resource_split\n");
371
372 if (!(*head) || !(*orig_head))
373 return NULL;
374
375 rc = pciehp_resource_sort_and_combine(head);
376
377 if (rc)
378 return NULL;
379
380 if ((*head)->base != (*orig_head)->base)
381 return NULL;
382
383 if ((*head)->length == (*orig_head)->length)
384 return NULL;
385
386
387 /* If we got here, there the bridge requires some of the resource, but
388 * we may be able to split some off of the front
389 */
390 node = *head;
391
392 if (node->length & (alignment -1)) {
393 /* this one isn't an aligned length, so we'll make a new entry
394 * and split it up.
395 */
396 split_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
397
398 if (!split_node)
399 return NULL;
400
401 temp_dword = (node->length | (alignment-1)) + 1 - alignment;
402
403 split_node->base = node->base;
404 split_node->length = temp_dword;
405
406 node->length -= temp_dword;
407 node->base += split_node->length;
408
409 /* Put it in the list */
410 *head = split_node;
411 split_node->next = node;
412 }
413
414 if (node->length < alignment)
415 return NULL;
416
417 /* Now unlink it */
418 if (*head == node) {
419 *head = node->next;
420 } else {
421 prevnode = *head;
422 while (prevnode->next != node)
423 prevnode = prevnode->next;
424
425 prevnode->next = node->next;
426 }
427 node->next = NULL;
428
429 return node;
430}
431
432
433/**
434 * do_bridge_resource_split: return one unused resource node
435 * @head: list to scan
436 *
437 */
438static struct pci_resource *
439do_bridge_resource_split(struct pci_resource **head, u32 alignment)
440{
441 struct pci_resource *prevnode = NULL;
442 struct pci_resource *node;
443 u32 rc;
444 u32 temp_dword;
445
446 if (!(*head))
447 return NULL;
448
449 rc = pciehp_resource_sort_and_combine(head);
450
451 if (rc)
452 return NULL;
453
454 node = *head;
455
456 while (node->next) {
457 prevnode = node;
458 node = node->next;
459 kfree(prevnode);
460 }
461
462 if (node->length < alignment) {
463 kfree(node);
464 return NULL;
465 }
466
467 if (node->base & (alignment - 1)) {
468 /* Short circuit if adjusted size is too small */
469 temp_dword = (node->base | (alignment-1)) + 1;
470 if ((node->length - (temp_dword - node->base)) < alignment) {
471 kfree(node);
472 return NULL;
473 }
474
475 node->length -= (temp_dword - node->base);
476 node->base = temp_dword;
477 }
478
479 if (node->length & (alignment - 1)) {
480 /* There's stuff in use after this node */
481 kfree(node);
482 return NULL;
483 }
484
485 return node;
486}
487
488
489/*
490 * get_io_resource
491 *
492 * this function sorts the resource list by size and then
493 * returns the first node of "size" length that is not in the
494 * ISA aliasing window. If it finds a node larger than "size"
495 * it will split it up.
496 *
497 * size must be a power of two.
498 */
499static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size)
500{
501 struct pci_resource *prevnode;
502 struct pci_resource *node;
503 struct pci_resource *split_node = NULL;
504 u32 temp_dword;
505
506 if (!(*head))
507 return NULL;
508
509 if ( pciehp_resource_sort_and_combine(head) )
510 return NULL;
511
512 if ( sort_by_size(head) )
513 return NULL;
514
515 for (node = *head; node; node = node->next) {
516 if (node->length < size)
517 continue;
518
519 if (node->base & (size - 1)) {
520 /* this one isn't base aligned properly
521 so we'll make a new entry and split it up */
522 temp_dword = (node->base | (size-1)) + 1;
523
524 /*/ Short circuit if adjusted size is too small */
525 if ((node->length - (temp_dword - node->base)) < size)
526 continue;
527
528 split_node = kmalloc(sizeof(struct pci_resource),
529 GFP_KERNEL);
530
531 if (!split_node)
532 return NULL;
533
534 split_node->base = node->base;
535 split_node->length = temp_dword - node->base;
536 node->base = temp_dword;
537 node->length -= split_node->length;
538
539 /* Put it in the list */
540 split_node->next = node->next;
541 node->next = split_node;
542 } /* End of non-aligned base */
543
544 /* Don't need to check if too small since we already did */
545 if (node->length > size) {
546 /* this one is longer than we need
547 so we'll make a new entry and split it up */
548 split_node = kmalloc(sizeof(struct pci_resource),
549 GFP_KERNEL);
550
551 if (!split_node)
552 return NULL;
553
554 split_node->base = node->base + size;
555 split_node->length = node->length - size;
556 node->length = size;
557
558 /* Put it in the list */
559 split_node->next = node->next;
560 node->next = split_node;
561 } /* End of too big on top end */
562
563 /* For IO make sure it's not in the ISA aliasing space */
564 if (node->base & 0x300L)
565 continue;
566
567 /* If we got here, then it is the right size
568 Now take it out of the list */
569 if (*head == node) {
570 *head = node->next;
571 } else {
572 prevnode = *head;
573 while (prevnode->next != node)
574 prevnode = prevnode->next;
575
576 prevnode->next = node->next;
577 }
578 node->next = NULL;
579 /* Stop looping */
580 break;
581 }
582
583 return node;
584}
585
586
587/*
588 * get_max_resource
589 *
590 * Gets the largest node that is at least "size" big from the
591 * list pointed to by head. It aligns the node on top and bottom
592 * to "size" alignment before returning it.
593 * J.I. modified to put max size limits of; 64M->32M->16M->8M->4M->1M
594 * This is needed to avoid allocating entire ACPI _CRS res to one child bridge/slot.
595 */
596static struct pci_resource *get_max_resource(struct pci_resource **head, u32 size)
597{
598 struct pci_resource *max;
599 struct pci_resource *temp;
600 struct pci_resource *split_node;
601 u32 temp_dword;
602 u32 max_size[] = { 0x4000000, 0x2000000, 0x1000000, 0x0800000, 0x0400000, 0x0200000, 0x0100000, 0x00 };
603 int i;
604
605 if (!(*head))
606 return NULL;
607
608 if (pciehp_resource_sort_and_combine(head))
609 return NULL;
610
611 if (sort_by_max_size(head))
612 return NULL;
613
614 for (max = *head;max; max = max->next) {
615
616 /* If not big enough we could probably just bail,
617 instead we'll continue to the next. */
618 if (max->length < size)
619 continue;
620
621 if (max->base & (size - 1)) {
622 /* this one isn't base aligned properly
623 so we'll make a new entry and split it up */
624 temp_dword = (max->base | (size-1)) + 1;
625
626 /* Short circuit if adjusted size is too small */
627 if ((max->length - (temp_dword - max->base)) < size)
628 continue;
629
630 split_node = kmalloc(sizeof(struct pci_resource),
631 GFP_KERNEL);
632
633 if (!split_node)
634 return NULL;
635
636 split_node->base = max->base;
637 split_node->length = temp_dword - max->base;
638 max->base = temp_dword;
639 max->length -= split_node->length;
640
641 /* Put it next in the list */
642 split_node->next = max->next;
643 max->next = split_node;
644 }
645
646 if ((max->base + max->length) & (size - 1)) {
647 /* this one isn't end aligned properly at the top
648 so we'll make a new entry and split it up */
649 split_node = kmalloc(sizeof(struct pci_resource),
650 GFP_KERNEL);
651
652 if (!split_node)
653 return NULL;
654 temp_dword = ((max->base + max->length) & ~(size - 1));
655 split_node->base = temp_dword;
656 split_node->length = max->length + max->base
657 - split_node->base;
658 max->length -= split_node->length;
659
660 /* Put it in the list */
661 split_node->next = max->next;
662 max->next = split_node;
663 }
664
665 /* Make sure it didn't shrink too much when we aligned it */
666 if (max->length < size)
667 continue;
668
669 for ( i = 0; max_size[i] > size; i++) {
670 if (max->length > max_size[i]) {
671 split_node = kmalloc(sizeof(struct pci_resource),
672 GFP_KERNEL);
673 if (!split_node)
674 break; /* return NULL; */
675 split_node->base = max->base + max_size[i];
676 split_node->length = max->length - max_size[i];
677 max->length = max_size[i];
678 /* Put it next in the list */
679 split_node->next = max->next;
680 max->next = split_node;
681 break;
682 }
683 }
684
685 /* Now take it out of the list */
686 temp = (struct pci_resource*) *head;
687 if (temp == max) {
688 *head = max->next;
689 } else {
690 while (temp && temp->next != max) {
691 temp = temp->next;
692 }
693
694 temp->next = max->next;
695 }
696
697 max->next = NULL;
698 return max;
699 }
700
701 /* If we get here, we couldn't find one */
702 return NULL;
703}
704
705
706/*
707 * get_resource
708 *
709 * this function sorts the resource list by size and then
710 * returns the first node of "size" length. If it finds a node
711 * larger than "size" it will split it up.
712 *
713 * size must be a power of two.
714 */
715static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
716{
717 struct pci_resource *prevnode;
718 struct pci_resource *node;
719 struct pci_resource *split_node;
720 u32 temp_dword;
721
722 if (!(*head))
723 return NULL;
724
725 if ( pciehp_resource_sort_and_combine(head) )
726 return NULL;
727
728 if ( sort_by_size(head) )
729 return NULL;
730
731 for (node = *head; node; node = node->next) {
732 dbg("%s: req_size =0x%x node=%p, base=0x%x, length=0x%x\n",
733 __FUNCTION__, size, node, node->base, node->length);
734 if (node->length < size)
735 continue;
736
737 if (node->base & (size - 1)) {
738 dbg("%s: not aligned\n", __FUNCTION__);
739 /* this one isn't base aligned properly
740 so we'll make a new entry and split it up */
741 temp_dword = (node->base | (size-1)) + 1;
742
743 /* Short circuit if adjusted size is too small */
744 if ((node->length - (temp_dword - node->base)) < size)
745 continue;
746
747 split_node = kmalloc(sizeof(struct pci_resource),
748 GFP_KERNEL);
749
750 if (!split_node)
751 return NULL;
752
753 split_node->base = node->base;
754 split_node->length = temp_dword - node->base;
755 node->base = temp_dword;
756 node->length -= split_node->length;
757
758 /* Put it in the list */
759 split_node->next = node->next;
760 node->next = split_node;
761 } /* End of non-aligned base */
762
763 /* Don't need to check if too small since we already did */
764 if (node->length > size) {
765 dbg("%s: too big\n", __FUNCTION__);
766 /* this one is longer than we need
767 so we'll make a new entry and split it up */
768 split_node = kmalloc(sizeof(struct pci_resource),
769 GFP_KERNEL);
770
771 if (!split_node)
772 return NULL;
773
774 split_node->base = node->base + size;
775 split_node->length = node->length - size;
776 node->length = size;
777
778 /* Put it in the list */
779 split_node->next = node->next;
780 node->next = split_node;
781 } /* End of too big on top end */
782
783 dbg("%s: got one!!!\n", __FUNCTION__);
784 /* If we got here, then it is the right size
785 Now take it out of the list */
786 if (*head == node) {
787 *head = node->next;
788 } else {
789 prevnode = *head;
790 while (prevnode->next != node)
791 prevnode = prevnode->next;
792
793 prevnode->next = node->next;
794 }
795 node->next = NULL;
796 /* Stop looping */
797 break;
798 }
799 return node;
800}
801
802
803/*
804 * pciehp_resource_sort_and_combine
805 *
806 * Sorts all of the nodes in the list in ascending order by
807 * their base addresses. Also does garbage collection by
808 * combining adjacent nodes.
809 *
810 * returns 0 if success
811 */
812int pciehp_resource_sort_and_combine(struct pci_resource **head)
813{
814 struct pci_resource *node1;
815 struct pci_resource *node2;
816 int out_of_order = 1;
817
818 dbg("%s: head = %p, *head = %p\n", __FUNCTION__, head, *head);
819
820 if (!(*head))
821 return 1;
822
823 dbg("*head->next = %p\n",(*head)->next);
824
825 if (!(*head)->next)
826 return 0; /* only one item on the list, already sorted! */
827
828 dbg("*head->base = 0x%x\n",(*head)->base);
829 dbg("*head->next->base = 0x%x\n",(*head)->next->base);
830 while (out_of_order) {
831 out_of_order = 0;
832
833 /* Special case for swapping list head */
834 if (((*head)->next) &&
835 ((*head)->base > (*head)->next->base)) {
836 node1 = *head;
837 (*head) = (*head)->next;
838 node1->next = (*head)->next;
839 (*head)->next = node1;
840 out_of_order++;
841 }
842
843 node1 = (*head);
844
845 while (node1->next && node1->next->next) {
846 if (node1->next->base > node1->next->next->base) {
847 out_of_order++;
848 node2 = node1->next;
849 node1->next = node1->next->next;
850 node1 = node1->next;
851 node2->next = node1->next;
852 node1->next = node2;
853 } else
854 node1 = node1->next;
855 }
856 } /* End of out_of_order loop */
857
858 node1 = *head;
859
860 while (node1 && node1->next) {
861 if ((node1->base + node1->length) == node1->next->base) {
862 /* Combine */
863 dbg("8..\n");
864 node1->length += node1->next->length;
865 node2 = node1->next;
866 node1->next = node1->next->next;
867 kfree(node2);
868 } else
869 node1 = node1->next;
870 }
871
872 return 0;
873}
874
875
876/**
877 * pciehp_slot_create - Creates a node and adds it to the proper bus.
878 * @busnumber - bus where new node is to be located
879 *
880 * Returns pointer to the new node or NULL if unsuccessful
881 */
882struct pci_func *pciehp_slot_create(u8 busnumber)
883{
884 struct pci_func *new_slot;
885 struct pci_func *next;
886 dbg("%s: busnumber %x\n", __FUNCTION__, busnumber);
887 new_slot = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
888
889 if (new_slot == NULL)
890 return new_slot;
891
892 memset(new_slot, 0, sizeof(struct pci_func));
893
894 new_slot->next = NULL;
895 new_slot->configured = 1;
896
897 if (pciehp_slot_list[busnumber] == NULL) {
898 pciehp_slot_list[busnumber] = new_slot;
899 } else {
900 next = pciehp_slot_list[busnumber];
901 while (next->next != NULL)
902 next = next->next;
903 next->next = new_slot;
904 }
905 return new_slot;
906}
907
908
909/**
910 * slot_remove - Removes a node from the linked list of slots.
911 * @old_slot: slot to remove
912 *
913 * Returns 0 if successful, !0 otherwise.
914 */
915static int slot_remove(struct pci_func * old_slot)
916{
917 struct pci_func *next;
918
919 if (old_slot == NULL)
920 return 1;
921
922 next = pciehp_slot_list[old_slot->bus];
923
924 if (next == NULL)
925 return 1;
926
927 if (next == old_slot) {
928 pciehp_slot_list[old_slot->bus] = old_slot->next;
929 pciehp_destroy_board_resources(old_slot);
930 kfree(old_slot);
931 return 0;
932 }
933
934 while ((next->next != old_slot) && (next->next != NULL)) {
935 next = next->next;
936 }
937
938 if (next->next == old_slot) {
939 next->next = old_slot->next;
940 pciehp_destroy_board_resources(old_slot);
941 kfree(old_slot);
942 return 0;
943 } else
944 return 2;
945}
946
947
948/**
949 * bridge_slot_remove - Removes a node from the linked list of slots.
950 * @bridge: bridge to remove
951 *
952 * Returns 0 if successful, !0 otherwise.
953 */
954static int bridge_slot_remove(struct pci_func *bridge)
955{
956 u8 subordinateBus, secondaryBus;
957 u8 tempBus;
958 struct pci_func *next;
959
960 if (bridge == NULL)
961 return 1;
962
963 secondaryBus = (bridge->config_space[0x06] >> 8) & 0xFF;
964 subordinateBus = (bridge->config_space[0x06] >> 16) & 0xFF;
965
966 for (tempBus = secondaryBus; tempBus <= subordinateBus; tempBus++) {
967 next = pciehp_slot_list[tempBus];
968
969 while (!slot_remove(next)) {
970 next = pciehp_slot_list[tempBus];
971 }
972 }
973
974 next = pciehp_slot_list[bridge->bus];
975
976 if (next == NULL) {
977 return 1;
978 }
979
980 if (next == bridge) {
981 pciehp_slot_list[bridge->bus] = bridge->next;
982 kfree(bridge);
983 return 0;
984 }
985
986 while ((next->next != bridge) && (next->next != NULL)) {
987 next = next->next;
988 }
989
990 if (next->next == bridge) {
991 next->next = bridge->next;
992 kfree(bridge);
993 return 0;
994 } else
995 return 2;
996}
997
998
999/**
1000 * pciehp_slot_find - Looks for a node by bus, and device, multiple functions accessed
1001 * @bus: bus to find
1002 * @device: device to find
1003 * @index: is 0 for first function found, 1 for the second...
1004 *
1005 * Returns pointer to the node if successful, %NULL otherwise.
1006 */
1007struct pci_func *pciehp_slot_find(u8 bus, u8 device, u8 index)
1008{
1009 int found = -1;
1010 struct pci_func *func;
1011
1012 func = pciehp_slot_list[bus];
1013 dbg("%s: bus %x device %x index %x\n",
1014 __FUNCTION__, bus, device, index);
1015 if (func != NULL) {
1016 dbg("%s: func-> bus %x device %x function %x pci_dev %p\n",
1017 __FUNCTION__, func->bus, func->device, func->function,
1018 func->pci_dev);
1019 } else
1020 dbg("%s: func == NULL\n", __FUNCTION__);
1021
1022 if ((func == NULL) || ((func->device == device) && (index == 0)))
1023 return func;
1024
1025 if (func->device == device)
1026 found++;
1027
1028 while (func->next != NULL) {
1029 func = func->next;
1030
1031 dbg("%s: In while loop, func-> bus %x device %x function %x pci_dev %p\n",
1032 __FUNCTION__, func->bus, func->device, func->function,
1033 func->pci_dev);
1034 if (func->device == device)
1035 found++;
1036 dbg("%s: while loop, found %d, index %d\n", __FUNCTION__,
1037 found, index);
1038
1039 if ((found == index) || (func->function == index)) {
1040 dbg("%s: Found bus %x dev %x func %x\n", __FUNCTION__,
1041 func->bus, func->device, func->function);
1042 return func;
1043 }
1044 }
1045
1046 return NULL;
1047}
1048
1049static int is_bridge(struct pci_func * func)
1050{
1051 /* Check the header type */
1052 if (((func->config_space[0x03] >> 16) & 0xFF) == 0x01)
1053 return 1;
1054 else
1055 return 0;
1056}
1057
1058
1059/* The following routines constitute the bulk of the 225/* The following routines constitute the bulk of the
1060 hotplug controller logic 226 hotplug controller logic
1061 */ 227 */
@@ -1100,20 +266,17 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
1100 * Configures board 266 * Configures board
1101 * 267 *
1102 */ 268 */
1103static u32 board_added(struct pci_func * func, struct controller * ctrl) 269static int board_added(struct slot *p_slot)
1104{ 270{
1105 u8 hp_slot; 271 u8 hp_slot;
1106 int index; 272 int rc = 0;
1107 u32 temp_register = 0xFFFFFFFF; 273 struct controller *ctrl = p_slot->ctrl;
1108 u32 rc = 0;
1109 struct pci_func *new_func = NULL;
1110 struct slot *p_slot;
1111 struct resource_lists res_lists;
1112 274
1113 p_slot = pciehp_find_slot(ctrl, func->device); 275 hp_slot = p_slot->device - ctrl->slot_device_offset;
1114 hp_slot = func->device - ctrl->slot_device_offset;
1115 276
1116 dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n", __FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot); 277 dbg("%s: slot device, slot offset, hp slot = %d, %d ,%d\n",
278 __FUNCTION__, p_slot->device,
279 ctrl->slot_device_offset, hp_slot);
1117 280
1118 /* Wait for exclusive access to hardware */ 281 /* Wait for exclusive access to hardware */
1119 down(&ctrl->crit_sect); 282 down(&ctrl->crit_sect);
@@ -1141,9 +304,7 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
1141 up(&ctrl->crit_sect); 304 up(&ctrl->crit_sect);
1142 305
1143 /* Wait for ~1 second */ 306 /* Wait for ~1 second */
1144 dbg("%s: before long_delay\n", __FUNCTION__);
1145 wait_for_ctrl_irq (ctrl); 307 wait_for_ctrl_irq (ctrl);
1146 dbg("%s: afterlong_delay\n", __FUNCTION__);
1147 308
1148 /* Check link training status */ 309 /* Check link training status */
1149 rc = p_slot->hpc_ops->check_lnk_status(ctrl); 310 rc = p_slot->hpc_ops->check_lnk_status(ctrl);
@@ -1153,98 +314,42 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
1153 return rc; 314 return rc;
1154 } 315 }
1155 316
1156 dbg("%s: func status = %x\n", __FUNCTION__, func->status);
1157
1158 /* Check for a power fault */ 317 /* Check for a power fault */
1159 if (func->status == 0xFF) { 318 if (p_slot->hpc_ops->query_power_fault(p_slot)) {
1160 /* power fault occurred, but it was benign */ 319 dbg("%s: power fault detected\n", __FUNCTION__);
1161 temp_register = 0xFFFFFFFF;
1162 dbg("%s: temp register set to %x by power fault\n", __FUNCTION__, temp_register);
1163 rc = POWER_FAILURE; 320 rc = POWER_FAILURE;
1164 func->status = 0; 321 goto err_exit;
1165 } else {
1166 /* Get vendor/device ID u32 */
1167 rc = pci_bus_read_config_dword (ctrl->pci_dev->subordinate, PCI_DEVFN(func->device, func->function),
1168 PCI_VENDOR_ID, &temp_register);
1169 dbg("%s: pci_bus_read_config_dword returns %d\n", __FUNCTION__, rc);
1170 dbg("%s: temp_register is %x\n", __FUNCTION__, temp_register);
1171
1172 if (rc != 0) {
1173 /* Something's wrong here */
1174 temp_register = 0xFFFFFFFF;
1175 dbg("%s: temp register set to %x by error\n", __FUNCTION__, temp_register);
1176 }
1177 /* Preset return code. It will be changed later if things go okay. */
1178 rc = NO_ADAPTER_PRESENT;
1179 } 322 }
1180 323
1181 /* All F's is an empty slot or an invalid board */ 324 rc = pciehp_configure_device(p_slot);
1182 if (temp_register != 0xFFFFFFFF) { /* Check for a board in the slot */ 325 if (rc) {
1183 res_lists.io_head = ctrl->io_head; 326 err("Cannot add device 0x%x:%x\n", p_slot->bus,
1184 res_lists.mem_head = ctrl->mem_head; 327 p_slot->device);
1185 res_lists.p_mem_head = ctrl->p_mem_head; 328 goto err_exit;
1186 res_lists.bus_head = ctrl->bus_head; 329 }
1187 res_lists.irqs = NULL;
1188
1189 rc = configure_new_device(ctrl, func, 0, &res_lists, 0, 0);
1190 dbg("%s: back from configure_new_device\n", __FUNCTION__);
1191
1192 ctrl->io_head = res_lists.io_head;
1193 ctrl->mem_head = res_lists.mem_head;
1194 ctrl->p_mem_head = res_lists.p_mem_head;
1195 ctrl->bus_head = res_lists.bus_head;
1196
1197 pciehp_resource_sort_and_combine(&(ctrl->mem_head));
1198 pciehp_resource_sort_and_combine(&(ctrl->p_mem_head));
1199 pciehp_resource_sort_and_combine(&(ctrl->io_head));
1200 pciehp_resource_sort_and_combine(&(ctrl->bus_head));
1201
1202 if (rc) {
1203 set_slot_off(ctrl, p_slot);
1204 return rc;
1205 }
1206 pciehp_save_slot_config(ctrl, func);
1207 330
1208 func->status = 0; 331 /*
1209 func->switch_save = 0x10; 332 * Some PCI Express root ports require fixup after hot-plug operation.
1210 func->is_a_board = 0x01; 333 */
334 if (pcie_mch_quirk)
335 pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
336 if (PWR_LED(ctrl->ctrlcap)) {
337 /* Wait for exclusive access to hardware */
338 down(&ctrl->crit_sect);
1211 339
1212 /* next, we will instantiate the linux pci_dev structures 340 p_slot->hpc_ops->green_led_on(p_slot);
1213 * (with appropriate driver notification, if already present)
1214 */
1215 index = 0;
1216 do {
1217 new_func = pciehp_slot_find(ctrl->slot_bus, func->device, index++);
1218 if (new_func && !new_func->pci_dev) {
1219 dbg("%s:call pci_hp_configure_dev, func %x\n",
1220 __FUNCTION__, index);
1221 pciehp_configure_device(ctrl, new_func);
1222 }
1223 } while (new_func);
1224
1225 /*
1226 * Some PCI Express root ports require fixup after hot-plug operation.
1227 */
1228 if (pcie_mch_quirk)
1229 pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
1230
1231 if (PWR_LED(ctrl->ctrlcap)) {
1232 /* Wait for exclusive access to hardware */
1233 down(&ctrl->crit_sect);
1234
1235 p_slot->hpc_ops->green_led_on(p_slot);
1236 341
1237 /* Wait for the command to complete */ 342 /* Wait for the command to complete */
1238 wait_for_ctrl_irq (ctrl); 343 wait_for_ctrl_irq (ctrl);
1239 344
1240 /* Done with exclusive hardware access */ 345 /* Done with exclusive hardware access */
1241 up(&ctrl->crit_sect); 346 up(&ctrl->crit_sect);
1242 } 347 }
1243 } else {
1244 set_slot_off(ctrl, p_slot);
1245 return -1;
1246 }
1247 return 0; 348 return 0;
349
350err_exit:
351 set_slot_off(ctrl, p_slot);
352 return -1;
1248} 353}
1249 354
1250 355
@@ -1252,56 +357,23 @@ static u32 board_added(struct pci_func * func, struct controller * ctrl)
1252 * remove_board - Turns off slot and LED's 357 * remove_board - Turns off slot and LED's
1253 * 358 *
1254 */ 359 */
1255static u32 remove_board(struct pci_func *func, struct controller *ctrl) 360static int remove_board(struct slot *p_slot)
1256{ 361{
1257 int index;
1258 u8 skip = 0;
1259 u8 device; 362 u8 device;
1260 u8 hp_slot; 363 u8 hp_slot;
1261 u32 rc; 364 int rc;
1262 struct resource_lists res_lists; 365 struct controller *ctrl = p_slot->ctrl;
1263 struct pci_func *temp_func;
1264 struct slot *p_slot;
1265
1266 if (func == NULL)
1267 return 1;
1268 366
1269 if (pciehp_unconfigure_device(func)) 367 if (pciehp_unconfigure_device(p_slot))
1270 return 1; 368 return 1;
1271 369
1272 device = func->device; 370 device = p_slot->device;
1273 371
1274 hp_slot = func->device - ctrl->slot_device_offset; 372 hp_slot = p_slot->device - ctrl->slot_device_offset;
1275 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 373 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1276 374
1277 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot); 375 dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
1278 376
1279 if ((ctrl->add_support) &&
1280 !(func->bus_head || func->mem_head || func->p_mem_head || func->io_head)) {
1281 /* Here we check to see if we've saved any of the board's
1282 * resources already. If so, we'll skip the attempt to
1283 * determine what's being used.
1284 */
1285 index = 0;
1286
1287 temp_func = func;
1288
1289 while ((temp_func = pciehp_slot_find(temp_func->bus, temp_func->device, index++))) {
1290 if (temp_func->bus_head || temp_func->mem_head
1291 || temp_func->p_mem_head || temp_func->io_head) {
1292 skip = 1;
1293 break;
1294 }
1295 }
1296
1297 if (!skip)
1298 rc = pciehp_save_used_resources(ctrl, func, DISABLE_CARD);
1299 }
1300 /* Change status to shutdown */
1301 if (func->is_a_board)
1302 func->status = 0x01;
1303 func->configured = 0;
1304
1305 /* Wait for exclusive access to hardware */ 377 /* Wait for exclusive access to hardware */
1306 down(&ctrl->crit_sect); 378 down(&ctrl->crit_sect);
1307 379
@@ -1328,56 +400,6 @@ static u32 remove_board(struct pci_func *func, struct controller *ctrl)
1328 /* Done with exclusive hardware access */ 400 /* Done with exclusive hardware access */
1329 up(&ctrl->crit_sect); 401 up(&ctrl->crit_sect);
1330 402
1331 if (ctrl->add_support) {
1332 while (func) {
1333 res_lists.io_head = ctrl->io_head;
1334 res_lists.mem_head = ctrl->mem_head;
1335 res_lists.p_mem_head = ctrl->p_mem_head;
1336 res_lists.bus_head = ctrl->bus_head;
1337
1338 dbg("Returning resources to ctlr lists for (B/D/F) = (%#x/%#x/%#x)\n",
1339 func->bus, func->device, func->function);
1340
1341 pciehp_return_board_resources(func, &res_lists);
1342
1343 ctrl->io_head = res_lists.io_head;
1344 ctrl->mem_head = res_lists.mem_head;
1345 ctrl->p_mem_head = res_lists.p_mem_head;
1346 ctrl->bus_head = res_lists.bus_head;
1347
1348 pciehp_resource_sort_and_combine(&(ctrl->mem_head));
1349 pciehp_resource_sort_and_combine(&(ctrl->p_mem_head));
1350 pciehp_resource_sort_and_combine(&(ctrl->io_head));
1351 pciehp_resource_sort_and_combine(&(ctrl->bus_head));
1352
1353 if (is_bridge(func)) {
1354 dbg("PCI Bridge Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n",
1355 ctrl->seg, func->bus, func->device, func->function);
1356 bridge_slot_remove(func);
1357 } else {
1358 dbg("PCI Function Hot-Remove s:b:d:f(%02x:%02x:%02x:%02x)\n",
1359 ctrl->seg, func->bus, func->device, func->function);
1360 slot_remove(func);
1361 }
1362
1363 func = pciehp_slot_find(ctrl->slot_bus, device, 0);
1364 }
1365
1366 /* Setup slot structure with entry for empty slot */
1367 func = pciehp_slot_create(ctrl->slot_bus);
1368
1369 if (func == NULL) {
1370 return 1;
1371 }
1372
1373 func->bus = ctrl->slot_bus;
1374 func->device = device;
1375 func->function = 0;
1376 func->configured = 0;
1377 func->switch_save = 0x10;
1378 func->is_a_board = 0;
1379 }
1380
1381 return 0; 403 return 0;
1382} 404}
1383 405
@@ -1411,13 +433,15 @@ static void pciehp_pushbutton_thread(unsigned long slot)
1411 p_slot->hpc_ops->get_power_status(p_slot, &getstatus); 433 p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
1412 if (getstatus) { 434 if (getstatus) {
1413 p_slot->state = POWEROFF_STATE; 435 p_slot->state = POWEROFF_STATE;
1414 dbg("In power_down_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); 436 dbg("%s: disabling bus:device(%x:%x)\n", __FUNCTION__,
437 p_slot->bus, p_slot->device);
1415 438
1416 pciehp_disable_slot(p_slot); 439 pciehp_disable_slot(p_slot);
1417 p_slot->state = STATIC_STATE; 440 p_slot->state = STATIC_STATE;
1418 } else { 441 } else {
1419 p_slot->state = POWERON_STATE; 442 p_slot->state = POWERON_STATE;
1420 dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); 443 dbg("%s: adding bus:device(%x:%x)\n", __FUNCTION__,
444 p_slot->bus, p_slot->device);
1421 445
1422 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 446 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
1423 /* Wait for exclusive access to hardware */ 447 /* Wait for exclusive access to hardware */
@@ -1459,13 +483,15 @@ static void pciehp_surprise_rm_thread(unsigned long slot)
1459 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus); 483 p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
1460 if (!getstatus) { 484 if (!getstatus) {
1461 p_slot->state = POWEROFF_STATE; 485 p_slot->state = POWEROFF_STATE;
1462 dbg("In removing board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); 486 dbg("%s: removing bus:device(%x:%x)\n",
487 __FUNCTION__, p_slot->bus, p_slot->device);
1463 488
1464 pciehp_disable_slot(p_slot); 489 pciehp_disable_slot(p_slot);
1465 p_slot->state = STATIC_STATE; 490 p_slot->state = STATIC_STATE;
1466 } else { 491 } else {
1467 p_slot->state = POWERON_STATE; 492 p_slot->state = POWERON_STATE;
1468 dbg("In add_board, b:d(%x:%x)\n", p_slot->bus, p_slot->device); 493 dbg("%s: adding bus:device(%x:%x)\n",
494 __FUNCTION__, p_slot->bus, p_slot->device);
1469 495
1470 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) { 496 if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
1471 /* Wait for exclusive access to hardware */ 497 /* Wait for exclusive access to hardware */
@@ -1531,7 +557,6 @@ int pciehp_event_start_thread(void)
1531 err ("Can't start up our event thread\n"); 557 err ("Can't start up our event thread\n");
1532 return -1; 558 return -1;
1533 } 559 }
1534 dbg("Our event thread pid = %d\n", pid);
1535 return 0; 560 return 0;
1536} 561}
1537 562
@@ -1539,9 +564,7 @@ int pciehp_event_start_thread(void)
1539void pciehp_event_stop_thread(void) 564void pciehp_event_stop_thread(void)
1540{ 565{
1541 event_finished = 1; 566 event_finished = 1;
1542 dbg("event_thread finish command given\n");
1543 up(&event_semaphore); 567 up(&event_semaphore);
1544 dbg("wait for event_thread to exit\n");
1545 down(&event_exit); 568 down(&event_exit);
1546} 569}
1547 570
@@ -1573,7 +596,6 @@ static void interrupt_event_handler(struct controller *ctrl)
1573{ 596{
1574 int loop = 0; 597 int loop = 0;
1575 int change = 1; 598 int change = 1;
1576 struct pci_func *func;
1577 u8 hp_slot; 599 u8 hp_slot;
1578 u8 getstatus; 600 u8 getstatus;
1579 struct slot *p_slot; 601 struct slot *p_slot;
@@ -1581,16 +603,12 @@ static void interrupt_event_handler(struct controller *ctrl)
1581 while (change) { 603 while (change) {
1582 change = 0; 604 change = 0;
1583 605
1584 for (loop = 0; loop < 10; loop++) { 606 for (loop = 0; loop < MAX_EVENTS; loop++) {
1585 if (ctrl->event_queue[loop].event_type != 0) { 607 if (ctrl->event_queue[loop].event_type != 0) {
1586 hp_slot = ctrl->event_queue[loop].hp_slot; 608 hp_slot = ctrl->event_queue[loop].hp_slot;
1587 609
1588 func = pciehp_slot_find(ctrl->slot_bus, (hp_slot + ctrl->slot_device_offset), 0);
1589
1590 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset); 610 p_slot = pciehp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
1591 611
1592 dbg("hp_slot %d, func %p, p_slot %p\n", hp_slot, func, p_slot);
1593
1594 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) { 612 if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) {
1595 dbg("button cancel\n"); 613 dbg("button cancel\n");
1596 del_timer(&p_slot->task_event); 614 del_timer(&p_slot->task_event);
@@ -1682,7 +700,6 @@ static void interrupt_event_handler(struct controller *ctrl)
1682 p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread; 700 p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
1683 p_slot->task_event.data = (unsigned long) p_slot; 701 p_slot->task_event.data = (unsigned long) p_slot;
1684 702
1685 dbg("add_timer p_slot = %p\n", (void *) p_slot);
1686 add_timer(&p_slot->task_event); 703 add_timer(&p_slot->task_event);
1687 } 704 }
1688 } 705 }
@@ -1737,13 +754,6 @@ int pciehp_enable_slot(struct slot *p_slot)
1737{ 754{
1738 u8 getstatus = 0; 755 u8 getstatus = 0;
1739 int rc; 756 int rc;
1740 struct pci_func *func;
1741
1742 func = pciehp_slot_find(p_slot->bus, p_slot->device, 0);
1743 if (!func) {
1744 dbg("%s: Error! slot NULL\n", __FUNCTION__);
1745 return 1;
1746 }
1747 757
1748 /* Check to see if (latch closed, card present, power off) */ 758 /* Check to see if (latch closed, card present, power off) */
1749 down(&p_slot->ctrl->crit_sect); 759 down(&p_slot->ctrl->crit_sect);
@@ -1773,45 +783,11 @@ int pciehp_enable_slot(struct slot *p_slot)
1773 } 783 }
1774 up(&p_slot->ctrl->crit_sect); 784 up(&p_slot->ctrl->crit_sect);
1775 785
1776 slot_remove(func);
1777
1778 func = pciehp_slot_create(p_slot->bus);
1779 if (func == NULL)
1780 return 1;
1781
1782 func->bus = p_slot->bus;
1783 func->device = p_slot->device;
1784 func->function = 0;
1785 func->configured = 0;
1786 func->is_a_board = 1;
1787
1788 /* We have to save the presence info for these slots */
1789 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
1790 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 786 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1791 func->switch_save = !getstatus? 0x10:0;
1792 787
1793 rc = board_added(func, p_slot->ctrl); 788 rc = board_added(p_slot);
1794 if (rc) { 789 if (rc) {
1795 if (is_bridge(func))
1796 bridge_slot_remove(func);
1797 else
1798 slot_remove(func);
1799
1800 /* Setup slot structure with entry for empty slot */
1801 func = pciehp_slot_create(p_slot->bus);
1802 if (func == NULL)
1803 return 1; /* Out of memory */
1804
1805 func->bus = p_slot->bus;
1806 func->device = p_slot->device;
1807 func->function = 0;
1808 func->configured = 0;
1809 func->is_a_board = 1;
1810
1811 /* We have to save the presence info for these slots */
1812 p_slot->hpc_ops->get_adapter_status(p_slot, &(func->presence_save));
1813 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus); 790 p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
1814 func->switch_save = !getstatus? 0x10:0;
1815 } 791 }
1816 792
1817 if (p_slot) 793 if (p_slot)
@@ -1823,14 +799,8 @@ int pciehp_enable_slot(struct slot *p_slot)
1823 799
1824int pciehp_disable_slot(struct slot *p_slot) 800int pciehp_disable_slot(struct slot *p_slot)
1825{ 801{
1826 u8 class_code, header_type, BCR;
1827 u8 index = 0;
1828 u8 getstatus = 0; 802 u8 getstatus = 0;
1829 u32 rc = 0;
1830 int ret = 0; 803 int ret = 0;
1831 unsigned int devfn;
1832 struct pci_bus *pci_bus = p_slot->ctrl->pci_dev->subordinate;
1833 struct pci_func *func;
1834 804
1835 if (!p_slot->ctrl) 805 if (!p_slot->ctrl)
1836 return 1; 806 return 1;
@@ -1867,838 +837,8 @@ int pciehp_disable_slot(struct slot *p_slot)
1867 837
1868 up(&p_slot->ctrl->crit_sect); 838 up(&p_slot->ctrl->crit_sect);
1869 839
1870 func = pciehp_slot_find(p_slot->bus, p_slot->device, index++); 840 ret = remove_board(p_slot);
1871 841 update_slot_info(p_slot);
1872 /* Make sure there are no video controllers here 842 return ret;
1873 * for all func of p_slot
1874 */
1875 while (func && !rc) {
1876 pci_bus->number = func->bus;
1877 devfn = PCI_DEVFN(func->device, func->function);
1878
1879 /* Check the Class Code */
1880 rc = pci_bus_read_config_byte (pci_bus, devfn, 0x0B, &class_code);
1881 if (rc)
1882 return rc;
1883
1884 if (class_code == PCI_BASE_CLASS_DISPLAY) {
1885 /* Display/Video adapter (not supported) */
1886 rc = REMOVE_NOT_SUPPORTED;
1887 } else {
1888 /* See if it's a bridge */
1889 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
1890 if (rc)
1891 return rc;
1892
1893 /* If it's a bridge, check the VGA Enable bit */
1894 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) {
1895 rc = pci_bus_read_config_byte (pci_bus, devfn, PCI_BRIDGE_CONTROL, &BCR);
1896 if (rc)
1897 return rc;
1898
1899 /* If the VGA Enable bit is set, remove isn't supported */
1900 if (BCR & PCI_BRIDGE_CTL_VGA) {
1901 rc = REMOVE_NOT_SUPPORTED;
1902 }
1903 }
1904 }
1905
1906 func = pciehp_slot_find(p_slot->bus, p_slot->device, index++);
1907 }
1908
1909 func = pciehp_slot_find(p_slot->bus, p_slot->device, 0);
1910 if ((func != NULL) && !rc) {
1911 rc = remove_board(func, p_slot->ctrl);
1912 } else if (!rc)
1913 rc = 1;
1914
1915 if (p_slot)
1916 update_slot_info(p_slot);
1917
1918 return rc;
1919}
1920
1921
1922/**
1923 * configure_new_device - Configures the PCI header information of one board.
1924 *
1925 * @ctrl: pointer to controller structure
1926 * @func: pointer to function structure
1927 * @behind_bridge: 1 if this is a recursive call, 0 if not
1928 * @resources: pointer to set of resource lists
1929 *
1930 * Returns 0 if success
1931 *
1932 */
1933static u32 configure_new_device(struct controller * ctrl, struct pci_func * func,
1934 u8 behind_bridge, struct resource_lists * resources, u8 bridge_bus, u8 bridge_dev)
1935{
1936 u8 temp_byte, function, max_functions, stop_it;
1937 int rc;
1938 u32 ID;
1939 struct pci_func *new_slot;
1940 struct pci_bus lpci_bus, *pci_bus;
1941 int index;
1942
1943 new_slot = func;
1944
1945 dbg("%s\n", __FUNCTION__);
1946 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
1947 pci_bus = &lpci_bus;
1948 pci_bus->number = func->bus;
1949
1950 /* Check for Multi-function device */
1951 rc = pci_bus_read_config_byte(pci_bus, PCI_DEVFN(func->device, func->function), 0x0E, &temp_byte);
1952 if (rc) {
1953 dbg("%s: rc = %d\n", __FUNCTION__, rc);
1954 return rc;
1955 }
1956
1957 if (temp_byte & 0x80) /* Multi-function device */
1958 max_functions = 8;
1959 else
1960 max_functions = 1;
1961
1962 function = 0;
1963
1964 do {
1965 rc = configure_new_function(ctrl, new_slot, behind_bridge,
1966 resources, bridge_bus, bridge_dev);
1967
1968 if (rc) {
1969 dbg("configure_new_function failed: %d\n", rc);
1970 index = 0;
1971
1972 while (new_slot) {
1973 new_slot = pciehp_slot_find(new_slot->bus,
1974 new_slot->device, index++);
1975
1976 if (new_slot)
1977 pciehp_return_board_resources(new_slot,
1978 resources);
1979 }
1980
1981 return rc;
1982 }
1983
1984 function++;
1985
1986 stop_it = 0;
1987
1988 /* The following loop skips to the next present function
1989 * and creates a board structure
1990 */
1991
1992 while ((function < max_functions) && (!stop_it)) {
1993 pci_bus_read_config_dword(pci_bus, PCI_DEVFN(func->device, function), 0x00, &ID);
1994
1995 if (ID == 0xFFFFFFFF) { /* There's nothing there. */
1996 function++;
1997 } else { /* There's something there */
1998 /* Setup slot structure. */
1999 new_slot = pciehp_slot_create(func->bus);
2000
2001 if (new_slot == NULL) {
2002 /* Out of memory */
2003 return 1;
2004 }
2005
2006 new_slot->bus = func->bus;
2007 new_slot->device = func->device;
2008 new_slot->function = function;
2009 new_slot->is_a_board = 1;
2010 new_slot->status = 0;
2011
2012 stop_it++;
2013 }
2014 }
2015
2016 } while (function < max_functions);
2017 dbg("returning from %s\n", __FUNCTION__);
2018
2019 return 0;
2020}
2021
2022/*
2023 * Configuration logic that involves the hotplug data structures and
2024 * their bookkeeping
2025 */
2026
2027/**
2028 * configure_bridge: fill bridge's registers, either configure or disable it.
2029 */
2030static int
2031configure_bridge(struct pci_bus *pci_bus, unsigned int devfn,
2032 struct pci_resource *mem_node,
2033 struct pci_resource **hold_mem_node,
2034 int base_addr, int limit_addr)
2035{
2036 u16 temp_word;
2037 u32 rc;
2038
2039 if (mem_node) {
2040 memcpy(*hold_mem_node, mem_node, sizeof(struct pci_resource));
2041 mem_node->next = NULL;
2042
2043 /* set Mem base and Limit registers */
2044 RES_CHECK(mem_node->base, 16);
2045 temp_word = (u16)(mem_node->base >> 16);
2046 rc = pci_bus_write_config_word(pci_bus, devfn, base_addr, temp_word);
2047
2048 RES_CHECK(mem_node->base + mem_node->length - 1, 16);
2049 temp_word = (u16)((mem_node->base + mem_node->length - 1) >> 16);
2050 rc = pci_bus_write_config_word(pci_bus, devfn, limit_addr, temp_word);
2051 } else {
2052 temp_word = 0xFFFF;
2053 rc = pci_bus_write_config_word(pci_bus, devfn, base_addr, temp_word);
2054
2055 temp_word = 0x0000;
2056 rc = pci_bus_write_config_word(pci_bus, devfn, limit_addr, temp_word);
2057
2058 kfree(*hold_mem_node);
2059 *hold_mem_node = NULL;
2060 }
2061 return rc;
2062}
2063
2064static int
2065configure_new_bridge(struct controller *ctrl, struct pci_func *func,
2066 u8 behind_bridge, struct resource_lists *resources,
2067 struct pci_bus *pci_bus)
2068{
2069 int cloop;
2070 u8 temp_byte;
2071 u8 device;
2072 u16 temp_word;
2073 u32 rc;
2074 u32 ID;
2075 unsigned int devfn;
2076 struct pci_resource *mem_node;
2077 struct pci_resource *p_mem_node;
2078 struct pci_resource *io_node;
2079 struct pci_resource *bus_node;
2080 struct pci_resource *hold_mem_node;
2081 struct pci_resource *hold_p_mem_node;
2082 struct pci_resource *hold_IO_node;
2083 struct pci_resource *hold_bus_node;
2084 struct irq_mapping irqs;
2085 struct pci_func *new_slot;
2086 struct resource_lists temp_resources;
2087
2088 devfn = PCI_DEVFN(func->device, func->function);
2089
2090 /* set Primary bus */
2091 dbg("set Primary bus = 0x%x\n", func->bus);
2092 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_PRIMARY_BUS, func->bus);
2093 if (rc)
2094 return rc;
2095
2096 /* find range of busses to use */
2097 bus_node = get_max_resource(&resources->bus_head, 1L);
2098
2099 /* If we don't have any busses to allocate, we can't continue */
2100 if (!bus_node) {
2101 err("Got NO bus resource to use\n");
2102 return -ENOMEM;
2103 }
2104 dbg("Got ranges of buses to use: base:len=0x%x:%x\n", bus_node->base, bus_node->length);
2105
2106 /* set Secondary bus */
2107 temp_byte = (u8)bus_node->base;
2108 dbg("set Secondary bus = 0x%x\n", temp_byte);
2109 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, temp_byte);
2110 if (rc)
2111 return rc;
2112
2113 /* set subordinate bus */
2114 temp_byte = (u8)(bus_node->base + bus_node->length - 1);
2115 dbg("set subordinate bus = 0x%x\n", temp_byte);
2116 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
2117 if (rc)
2118 return rc;
2119
2120 /* Set HP parameters (Cache Line Size, Latency Timer) */
2121 rc = pciehprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_BRIDGE);
2122 if (rc)
2123 return rc;
2124
2125 /* Setup the IO, memory, and prefetchable windows */
2126
2127 io_node = get_max_resource(&(resources->io_head), 0x1000L);
2128 if (io_node) {
2129 dbg("io_node(base, len, next) (%x, %x, %p)\n", io_node->base,
2130 io_node->length, io_node->next);
2131 }
2132
2133 mem_node = get_max_resource(&(resources->mem_head), 0x100000L);
2134 if (mem_node) {
2135 dbg("mem_node(base, len, next) (%x, %x, %p)\n", mem_node->base,
2136 mem_node->length, mem_node->next);
2137 }
2138
2139 if (resources->p_mem_head)
2140 p_mem_node = get_max_resource(&(resources->p_mem_head), 0x100000L);
2141 else {
2142 /*
2143 * In some platform implementation, MEM and PMEM are not
2144 * distinguished, and hence ACPI _CRS has only MEM entries
2145 * for both MEM and PMEM.
2146 */
2147 dbg("using MEM for PMEM\n");
2148 p_mem_node = get_max_resource(&(resources->mem_head), 0x100000L);
2149 }
2150 if (p_mem_node) {
2151 dbg("p_mem_node(base, len, next) (%x, %x, %p)\n", p_mem_node->base,
2152 p_mem_node->length, p_mem_node->next);
2153 }
2154
2155 /* set up the IRQ info */
2156 if (!resources->irqs) {
2157 irqs.barber_pole = 0;
2158 irqs.interrupt[0] = 0;
2159 irqs.interrupt[1] = 0;
2160 irqs.interrupt[2] = 0;
2161 irqs.interrupt[3] = 0;
2162 irqs.valid_INT = 0;
2163 } else {
2164 irqs.barber_pole = resources->irqs->barber_pole;
2165 irqs.interrupt[0] = resources->irqs->interrupt[0];
2166 irqs.interrupt[1] = resources->irqs->interrupt[1];
2167 irqs.interrupt[2] = resources->irqs->interrupt[2];
2168 irqs.interrupt[3] = resources->irqs->interrupt[3];
2169 irqs.valid_INT = resources->irqs->valid_INT;
2170 }
2171
2172 /* set up resource lists that are now aligned on top and bottom
2173 * for anything behind the bridge.
2174 */
2175 temp_resources.bus_head = bus_node;
2176 temp_resources.io_head = io_node;
2177 temp_resources.mem_head = mem_node;
2178 temp_resources.p_mem_head = p_mem_node;
2179 temp_resources.irqs = &irqs;
2180
2181 /* Make copies of the nodes we are going to pass down so that
2182 * if there is a problem,we can just use these to free resources
2183 */
2184 hold_bus_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2185 hold_IO_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2186 hold_mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2187 hold_p_mem_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
2188
2189 if (!hold_bus_node || !hold_IO_node || !hold_mem_node || !hold_p_mem_node) {
2190 kfree(hold_bus_node);
2191 kfree(hold_IO_node);
2192 kfree(hold_mem_node);
2193 kfree(hold_p_mem_node);
2194
2195 return 1;
2196 }
2197
2198 memcpy(hold_bus_node, bus_node, sizeof(struct pci_resource));
2199
2200 bus_node->base += 1;
2201 bus_node->length -= 1;
2202 bus_node->next = NULL;
2203
2204 /* If we have IO resources copy them and fill in the bridge's
2205 * IO range registers
2206 */
2207 if (io_node) {
2208 memcpy(hold_IO_node, io_node, sizeof(struct pci_resource));
2209 io_node->next = NULL;
2210
2211 /* set IO base and Limit registers */
2212 RES_CHECK(io_node->base, 8);
2213 temp_byte = (u8)(io_node->base >> 8);
2214 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_BASE, temp_byte);
2215
2216 RES_CHECK(io_node->base + io_node->length - 1, 8);
2217 temp_byte = (u8)((io_node->base + io_node->length - 1) >> 8);
2218 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2219 } else {
2220 kfree(hold_IO_node);
2221 hold_IO_node = NULL;
2222 }
2223
2224 /* If we have memory resources copy them and fill in the bridge's
2225 * memory range registers. Otherwise, fill in the range
2226 * registers with values that disable them.
2227 */
2228 rc = configure_bridge(pci_bus, devfn, mem_node, &hold_mem_node,
2229 PCI_MEMORY_BASE, PCI_MEMORY_LIMIT);
2230
2231 /* If we have prefetchable memory resources copy them and
2232 * fill in the bridge's memory range registers. Otherwise,
2233 * fill in the range registers with values that disable them.
2234 */
2235 rc = configure_bridge(pci_bus, devfn, p_mem_node, &hold_p_mem_node,
2236 PCI_PREF_MEMORY_BASE, PCI_PREF_MEMORY_LIMIT);
2237
2238 /* Adjust this to compensate for extra adjustment in first loop */
2239 irqs.barber_pole--;
2240
2241 rc = 0;
2242
2243 /* Here we actually find the devices and configure them */
2244 for (device = 0; (device <= 0x1F) && !rc; device++) {
2245 irqs.barber_pole = (irqs.barber_pole + 1) & 0x03;
2246
2247 ID = 0xFFFFFFFF;
2248 pci_bus->number = hold_bus_node->base;
2249 pci_bus_read_config_dword (pci_bus, PCI_DEVFN(device, 0), PCI_VENDOR_ID, &ID);
2250 pci_bus->number = func->bus;
2251
2252 if (ID != 0xFFFFFFFF) { /* device Present */
2253 /* Setup slot structure. */
2254 new_slot = pciehp_slot_create(hold_bus_node->base);
2255
2256 if (new_slot == NULL) {
2257 /* Out of memory */
2258 rc = -ENOMEM;
2259 continue;
2260 }
2261
2262 new_slot->bus = hold_bus_node->base;
2263 new_slot->device = device;
2264 new_slot->function = 0;
2265 new_slot->is_a_board = 1;
2266 new_slot->status = 0;
2267
2268 rc = configure_new_device(ctrl, new_slot, 1,
2269 &temp_resources, func->bus,
2270 func->device);
2271 dbg("configure_new_device rc=0x%x\n",rc);
2272 } /* End of IF (device in slot?) */
2273 } /* End of FOR loop */
2274
2275 if (rc) {
2276 pciehp_destroy_resource_list(&temp_resources);
2277
2278 return_resource(&(resources->bus_head), hold_bus_node);
2279 return_resource(&(resources->io_head), hold_IO_node);
2280 return_resource(&(resources->mem_head), hold_mem_node);
2281 return_resource(&(resources->p_mem_head), hold_p_mem_node);
2282 return(rc);
2283 }
2284
2285 /* save the interrupt routing information */
2286 if (resources->irqs) {
2287 resources->irqs->interrupt[0] = irqs.interrupt[0];
2288 resources->irqs->interrupt[1] = irqs.interrupt[1];
2289 resources->irqs->interrupt[2] = irqs.interrupt[2];
2290 resources->irqs->interrupt[3] = irqs.interrupt[3];
2291 resources->irqs->valid_INT = irqs.valid_INT;
2292 } else if (!behind_bridge) {
2293 /* We need to hook up the interrupts here */
2294 for (cloop = 0; cloop < 4; cloop++) {
2295 if (irqs.valid_INT & (0x01 << cloop)) {
2296 rc = pciehp_set_irq(func->bus, func->device,
2297 0x0A + cloop, irqs.interrupt[cloop]);
2298 if (rc) {
2299 pciehp_destroy_resource_list (&temp_resources);
2300 return_resource(&(resources->bus_head), hold_bus_node);
2301 return_resource(&(resources->io_head), hold_IO_node);
2302 return_resource(&(resources->mem_head), hold_mem_node);
2303 return_resource(&(resources->p_mem_head), hold_p_mem_node);
2304 return rc;
2305 }
2306 }
2307 } /* end of for loop */
2308 }
2309
2310 /* Return unused bus resources
2311 * First use the temporary node to store information for the board
2312 */
2313 if (hold_bus_node && bus_node && temp_resources.bus_head) {
2314 hold_bus_node->length = bus_node->base - hold_bus_node->base;
2315
2316 hold_bus_node->next = func->bus_head;
2317 func->bus_head = hold_bus_node;
2318
2319 temp_byte = (u8)(temp_resources.bus_head->base - 1);
2320
2321 /* set subordinate bus */
2322 dbg("re-set subordinate bus = 0x%x\n", temp_byte);
2323 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_SUBORDINATE_BUS, temp_byte);
2324
2325 if (temp_resources.bus_head->length == 0) {
2326 kfree(temp_resources.bus_head);
2327 temp_resources.bus_head = NULL;
2328 } else {
2329 dbg("return bus res of b:d(0x%x:%x) base:len(0x%x:%x)\n",
2330 func->bus, func->device, temp_resources.bus_head->base, temp_resources.bus_head->length);
2331 return_resource(&(resources->bus_head), temp_resources.bus_head);
2332 }
2333 }
2334
2335 /* If we have IO space available and there is some left,
2336 * return the unused portion
2337 */
2338 if (hold_IO_node && temp_resources.io_head) {
2339 io_node = do_pre_bridge_resource_split(&(temp_resources.io_head),
2340 &hold_IO_node, 0x1000);
2341
2342 /* Check if we were able to split something off */
2343 if (io_node) {
2344 hold_IO_node->base = io_node->base + io_node->length;
2345
2346 RES_CHECK(hold_IO_node->base, 8);
2347 temp_byte = (u8)((hold_IO_node->base) >> 8);
2348 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_BASE, temp_byte);
2349
2350 return_resource(&(resources->io_head), io_node);
2351 }
2352
2353 io_node = do_bridge_resource_split(&(temp_resources.io_head), 0x1000);
2354
2355 /* Check if we were able to split something off */
2356 if (io_node) {
2357 /* First use the temporary node to store information for the board */
2358 hold_IO_node->length = io_node->base - hold_IO_node->base;
2359
2360 /* If we used any, add it to the board's list */
2361 if (hold_IO_node->length) {
2362 hold_IO_node->next = func->io_head;
2363 func->io_head = hold_IO_node;
2364
2365 RES_CHECK(io_node->base - 1, 8);
2366 temp_byte = (u8)((io_node->base - 1) >> 8);
2367 rc = pci_bus_write_config_byte (pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2368
2369 return_resource(&(resources->io_head), io_node);
2370 } else {
2371 /* it doesn't need any IO */
2372 temp_byte = 0x00;
2373 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_IO_LIMIT, temp_byte);
2374
2375 return_resource(&(resources->io_head), io_node);
2376 kfree(hold_IO_node);
2377 }
2378 } else {
2379 /* it used most of the range */
2380 hold_IO_node->next = func->io_head;
2381 func->io_head = hold_IO_node;
2382 }
2383 } else if (hold_IO_node) {
2384 /* it used the whole range */
2385 hold_IO_node->next = func->io_head;
2386 func->io_head = hold_IO_node;
2387 }
2388
2389 /* If we have memory space available and there is some left,
2390 * return the unused portion
2391 */
2392 if (hold_mem_node && temp_resources.mem_head) {
2393 mem_node = do_pre_bridge_resource_split(&(temp_resources.mem_head), &hold_mem_node, 0x100000L);
2394
2395 /* Check if we were able to split something off */
2396 if (mem_node) {
2397 hold_mem_node->base = mem_node->base + mem_node->length;
2398
2399 RES_CHECK(hold_mem_node->base, 16);
2400 temp_word = (u16)((hold_mem_node->base) >> 16);
2401 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_BASE, temp_word);
2402
2403 return_resource(&(resources->mem_head), mem_node);
2404 }
2405
2406 mem_node = do_bridge_resource_split(&(temp_resources.mem_head), 0x100000L);
2407
2408 /* Check if we were able to split something off */
2409 if (mem_node) {
2410 /* First use the temporary node to store information for the board */
2411 hold_mem_node->length = mem_node->base - hold_mem_node->base;
2412
2413 if (hold_mem_node->length) {
2414 hold_mem_node->next = func->mem_head;
2415 func->mem_head = hold_mem_node;
2416
2417 /* configure end address */
2418 RES_CHECK(mem_node->base - 1, 16);
2419 temp_word = (u16)((mem_node->base - 1) >> 16);
2420 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2421
2422 /* Return unused resources to the pool */
2423 return_resource(&(resources->mem_head), mem_node);
2424 } else {
2425 /* it doesn't need any Mem */
2426 temp_word = 0x0000;
2427 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_MEMORY_LIMIT, temp_word);
2428
2429 return_resource(&(resources->mem_head), mem_node);
2430 kfree(hold_mem_node);
2431 }
2432 } else {
2433 /* it used most of the range */
2434 hold_mem_node->next = func->mem_head;
2435 func->mem_head = hold_mem_node;
2436 }
2437 } else if (hold_mem_node) {
2438 /* it used the whole range */
2439 hold_mem_node->next = func->mem_head;
2440 func->mem_head = hold_mem_node;
2441 }
2442
2443 /* If we have prefetchable memory space available and there is some
2444 * left at the end, return the unused portion
2445 */
2446 if (hold_p_mem_node && temp_resources.p_mem_head) {
2447 p_mem_node = do_pre_bridge_resource_split(&(temp_resources.p_mem_head),
2448 &hold_p_mem_node, 0x100000L);
2449
2450 /* Check if we were able to split something off */
2451 if (p_mem_node) {
2452 hold_p_mem_node->base = p_mem_node->base + p_mem_node->length;
2453
2454 RES_CHECK(hold_p_mem_node->base, 16);
2455 temp_word = (u16)((hold_p_mem_node->base) >> 16);
2456 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_BASE, temp_word);
2457
2458 return_resource(&(resources->p_mem_head), p_mem_node);
2459 }
2460
2461 p_mem_node = do_bridge_resource_split(&(temp_resources.p_mem_head), 0x100000L);
2462
2463 /* Check if we were able to split something off */
2464 if (p_mem_node) {
2465 /* First use the temporary node to store information for the board */
2466 hold_p_mem_node->length = p_mem_node->base - hold_p_mem_node->base;
2467
2468 /* If we used any, add it to the board's list */
2469 if (hold_p_mem_node->length) {
2470 hold_p_mem_node->next = func->p_mem_head;
2471 func->p_mem_head = hold_p_mem_node;
2472
2473 RES_CHECK(p_mem_node->base - 1, 16);
2474 temp_word = (u16)((p_mem_node->base - 1) >> 16);
2475 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2476
2477 return_resource(&(resources->p_mem_head), p_mem_node);
2478 } else {
2479 /* it doesn't need any PMem */
2480 temp_word = 0x0000;
2481 rc = pci_bus_write_config_word (pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, temp_word);
2482
2483 return_resource(&(resources->p_mem_head), p_mem_node);
2484 kfree(hold_p_mem_node);
2485 }
2486 } else {
2487 /* it used the most of the range */
2488 hold_p_mem_node->next = func->p_mem_head;
2489 func->p_mem_head = hold_p_mem_node;
2490 }
2491 } else if (hold_p_mem_node) {
2492 /* it used the whole range */
2493 hold_p_mem_node->next = func->p_mem_head;
2494 func->p_mem_head = hold_p_mem_node;
2495 }
2496
2497 /* We should be configuring an IRQ and the bridge's base address
2498 * registers if it needs them. Although we have never seen such
2499 * a device
2500 */
2501
2502 pciehprm_enable_card(ctrl, func, PCI_HEADER_TYPE_BRIDGE);
2503
2504 dbg("PCI Bridge Hot-Added s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus, func->device, func->function);
2505
2506 return rc;
2507} 843}
2508 844
2509/**
2510 * configure_new_function - Configures the PCI header information of one device
2511 *
2512 * @ctrl: pointer to controller structure
2513 * @func: pointer to function structure
2514 * @behind_bridge: 1 if this is a recursive call, 0 if not
2515 * @resources: pointer to set of resource lists
2516 *
2517 * Calls itself recursively for bridged devices.
2518 * Returns 0 if success
2519 *
2520 */
2521static int
2522configure_new_function(struct controller *ctrl, struct pci_func *func,
2523 u8 behind_bridge, struct resource_lists *resources,
2524 u8 bridge_bus, u8 bridge_dev)
2525{
2526 int cloop;
2527 u8 temp_byte;
2528 u8 class_code;
2529 u32 rc;
2530 u32 temp_register;
2531 u32 base;
2532 unsigned int devfn;
2533 struct pci_resource *mem_node;
2534 struct pci_resource *io_node;
2535 struct pci_bus lpci_bus, *pci_bus;
2536
2537 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
2538 pci_bus = &lpci_bus;
2539 pci_bus->number = func->bus;
2540 devfn = PCI_DEVFN(func->device, func->function);
2541
2542 /* Check for Bridge */
2543 rc = pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &temp_byte);
2544 if (rc)
2545 return rc;
2546 dbg("%s: bus %x dev %x func %x temp_byte = %x\n", __FUNCTION__,
2547 func->bus, func->device, func->function, temp_byte);
2548
2549 if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
2550 rc = configure_new_bridge(ctrl, func, behind_bridge, resources,
2551 pci_bus);
2552
2553 if (rc)
2554 return rc;
2555 } else if ((temp_byte & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
2556 /* Standard device */
2557 u64 base64;
2558 rc = pci_bus_read_config_byte(pci_bus, devfn, 0x0B, &class_code);
2559
2560 if (class_code == PCI_BASE_CLASS_DISPLAY)
2561 return DEVICE_TYPE_NOT_SUPPORTED;
2562
2563 /* Figure out IO and memory needs */
2564 for (cloop = PCI_BASE_ADDRESS_0; cloop <= PCI_BASE_ADDRESS_5; cloop += 4) {
2565 temp_register = 0xFFFFFFFF;
2566
2567 rc = pci_bus_write_config_dword (pci_bus, devfn, cloop, temp_register);
2568 rc = pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp_register);
2569 dbg("Bar[%x]=0x%x on bus:dev:func(0x%x:%x:%x)\n", cloop, temp_register,
2570 func->bus, func->device, func->function);
2571
2572 if (!temp_register)
2573 continue;
2574
2575 base64 = 0L;
2576 if (temp_register & PCI_BASE_ADDRESS_SPACE_IO) {
2577 /* Map IO */
2578
2579 /* set base = amount of IO space */
2580 base = temp_register & 0xFFFFFFFC;
2581 base = ~base + 1;
2582
2583 dbg("NEED IO length(0x%x)\n", base);
2584 io_node = get_io_resource(&(resources->io_head),(ulong)base);
2585
2586 /* allocate the resource to the board */
2587 if (io_node) {
2588 dbg("Got IO base=0x%x(length=0x%x)\n", io_node->base, io_node->length);
2589 base = (u32)io_node->base;
2590 io_node->next = func->io_head;
2591 func->io_head = io_node;
2592 } else {
2593 err("Got NO IO resource(length=0x%x)\n", base);
2594 return -ENOMEM;
2595 }
2596 } else { /* map MEM */
2597 int prefetchable = 1;
2598 struct pci_resource **res_node = &func->p_mem_head;
2599 char *res_type_str = "PMEM";
2600 u32 temp_register2;
2601
2602 if (!(temp_register & PCI_BASE_ADDRESS_MEM_PREFETCH)) {
2603 prefetchable = 0;
2604 res_node = &func->mem_head;
2605 res_type_str++;
2606 }
2607
2608 base = temp_register & 0xFFFFFFF0;
2609 base = ~base + 1;
2610
2611 switch (temp_register & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
2612 case PCI_BASE_ADDRESS_MEM_TYPE_32:
2613 dbg("NEED 32 %s bar=0x%x(length=0x%x)\n", res_type_str, temp_register, base);
2614
2615 if (prefetchable && resources->p_mem_head)
2616 mem_node=get_resource(&(resources->p_mem_head), (ulong)base);
2617 else {
2618 if (prefetchable)
2619 dbg("using MEM for PMEM\n");
2620 mem_node = get_resource(&(resources->mem_head), (ulong)base);
2621 }
2622
2623 /* allocate the resource to the board */
2624 if (mem_node) {
2625 base = (u32)mem_node->base;
2626 mem_node->next = *res_node;
2627 *res_node = mem_node;
2628 dbg("Got 32 %s base=0x%x(length=0x%x)\n", res_type_str, mem_node->base,
2629 mem_node->length);
2630 } else {
2631 err("Got NO 32 %s resource(length=0x%x)\n", res_type_str, base);
2632 return -ENOMEM;
2633 }
2634 break;
2635 case PCI_BASE_ADDRESS_MEM_TYPE_64:
2636 rc = pci_bus_read_config_dword(pci_bus, devfn, cloop+4, &temp_register2);
2637 dbg("NEED 64 %s bar=0x%x:%x(length=0x%x)\n", res_type_str, temp_register2,
2638 temp_register, base);
2639
2640 if (prefetchable && resources->p_mem_head)
2641 mem_node = get_resource(&(resources->p_mem_head), (ulong)base);
2642 else {
2643 if (prefetchable)
2644 dbg("using MEM for PMEM\n");
2645 mem_node = get_resource(&(resources->mem_head), (ulong)base);
2646 }
2647
2648 /* allocate the resource to the board */
2649 if (mem_node) {
2650 base64 = mem_node->base;
2651 mem_node->next = *res_node;
2652 *res_node = mem_node;
2653 dbg("Got 64 %s base=0x%x:%x(length=%x)\n", res_type_str, (u32)(base64 >> 32),
2654 (u32)base64, mem_node->length);
2655 } else {
2656 err("Got NO 64 %s resource(length=0x%x)\n", res_type_str, base);
2657 return -ENOMEM;
2658 }
2659 break;
2660 default:
2661 dbg("reserved BAR type=0x%x\n", temp_register);
2662 break;
2663 }
2664
2665 }
2666
2667 if (base64) {
2668 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, (u32)base64);
2669 cloop += 4;
2670 base64 >>= 32;
2671
2672 if (base64) {
2673 dbg("%s: high dword of base64(0x%x) set to 0\n", __FUNCTION__, (u32)base64);
2674 base64 = 0x0L;
2675 }
2676
2677 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, (u32)base64);
2678 } else {
2679 rc = pci_bus_write_config_dword(pci_bus, devfn, cloop, base);
2680 }
2681 } /* End of base register loop */
2682
2683 /* disable ROM base Address */
2684 rc = pci_bus_write_config_dword (pci_bus, devfn, PCI_ROM_ADDRESS, 0x00);
2685
2686 /* Set HP parameters (Cache Line Size, Latency Timer) */
2687 rc = pciehprm_set_hpp(ctrl, func, PCI_HEADER_TYPE_NORMAL);
2688 if (rc)
2689 return rc;
2690
2691 pciehprm_enable_card(ctrl, func, PCI_HEADER_TYPE_NORMAL);
2692
2693 dbg("PCI function Hot-Added s:b:d:f(%02x:%02x:%02x:%02x)\n", ctrl->seg, func->bus, func->device,
2694 func->function);
2695 } /* End of Not-A-Bridge else */
2696 else {
2697 /* It's some strange type of PCI adapter (Cardbus?) */
2698 return DEVICE_TYPE_NOT_SUPPORTED;
2699 }
2700
2701 func->configured = 1;
2702
2703 return 0;
2704}
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 7a0e27f0e063..0b8b26beb163 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -27,16 +27,12 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/kernel.h> 30#include <linux/kernel.h>
32#include <linux/module.h> 31#include <linux/module.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/slab.h>
35#include <linux/vmalloc.h>
36#include <linux/interrupt.h>
37#include <linux/spinlock.h>
38#include <linux/pci.h> 33#include <linux/pci.h>
39#include <asm/system.h> 34#include <linux/interrupt.h>
35
40#include "../pci.h" 36#include "../pci.h"
41#include "pciehp.h" 37#include "pciehp.h"
42 38
@@ -217,23 +213,6 @@ static int pcie_cap_base = 0; /* Base of the PCI Express capability item struct
217#define MRL_STATE 0x0020 213#define MRL_STATE 0x0020
218#define PRSN_STATE 0x0040 214#define PRSN_STATE 0x0040
219 215
220struct php_ctlr_state_s {
221 struct php_ctlr_state_s *pnext;
222 struct pci_dev *pci_dev;
223 unsigned int irq;
224 unsigned long flags; /* spinlock's */
225 u32 slot_device_offset;
226 u32 num_slots;
227 struct timer_list int_poll_timer; /* Added for poll event */
228 php_intr_callback_t attention_button_callback;
229 php_intr_callback_t switch_change_callback;
230 php_intr_callback_t presence_change_callback;
231 php_intr_callback_t power_fault_callback;
232 void *callback_instance_id;
233 struct ctrl_reg *creg; /* Ptr to controller register space */
234};
235
236
237static spinlock_t hpc_event_lock; 216static spinlock_t hpc_event_lock;
238 217
239DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */ 218DEFINE_DBG_BUFFER /* Debug string buffer for entire HPC defined here */
@@ -297,7 +276,6 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
297 276
298 DBG_ENTER_ROUTINE 277 DBG_ENTER_ROUTINE
299 278
300 dbg("%s : Enter\n", __FUNCTION__);
301 if (!php_ctlr) { 279 if (!php_ctlr) {
302 err("%s: Invalid HPC controller handle!\n", __FUNCTION__); 280 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
303 return -1; 281 return -1;
@@ -308,7 +286,6 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
308 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 286 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
309 return retval; 287 return retval;
310 } 288 }
311 dbg("%s : hp_register_read_word SLOT_STATUS %x\n", __FUNCTION__, slot_status);
312 289
313 if ((slot_status & CMD_COMPLETED) == CMD_COMPLETED ) { 290 if ((slot_status & CMD_COMPLETED) == CMD_COMPLETED ) {
314 /* After 1 sec and CMD_COMPLETED still not set, just proceed forward to issue 291 /* After 1 sec and CMD_COMPLETED still not set, just proceed forward to issue
@@ -316,14 +293,11 @@ static int pcie_write_cmd(struct slot *slot, u16 cmd)
316 dbg("%s : CMD_COMPLETED not clear after 1 sec.\n", __FUNCTION__); 293 dbg("%s : CMD_COMPLETED not clear after 1 sec.\n", __FUNCTION__);
317 } 294 }
318 295
319 dbg("%s: Before hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd);
320 retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE); 296 retval = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), cmd | CMD_CMPL_INTR_ENABLE);
321 if (retval) { 297 if (retval) {
322 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 298 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
323 return retval; 299 return retval;
324 } 300 }
325 dbg("%s : hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, cmd | CMD_CMPL_INTR_ENABLE);
326 dbg("%s : Exit\n", __FUNCTION__);
327 301
328 DBG_LEAVE_ROUTINE 302 DBG_LEAVE_ROUTINE
329 return retval; 303 return retval;
@@ -509,7 +483,6 @@ static int hpc_query_power_fault(struct slot * slot)
509 u16 slot_status; 483 u16 slot_status;
510 u8 pwr_fault; 484 u8 pwr_fault;
511 int retval = 0; 485 int retval = 0;
512 u8 status;
513 486
514 DBG_ENTER_ROUTINE 487 DBG_ENTER_ROUTINE
515 488
@@ -521,15 +494,13 @@ static int hpc_query_power_fault(struct slot * slot)
521 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status); 494 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(slot->ctrl->cap_base), slot_status);
522 495
523 if (retval) { 496 if (retval) {
524 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 497 err("%s : Cannot check for power fault\n", __FUNCTION__);
525 return retval; 498 return retval;
526 } 499 }
527 pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1); 500 pwr_fault = (u8)((slot_status & PWR_FAULT_DETECTED) >> 1);
528 status = (pwr_fault != 1) ? 1 : 0;
529 501
530 DBG_LEAVE_ROUTINE 502 DBG_LEAVE_ROUTINE
531 /* Note: Logic 0 => fault */ 503 return pwr_fault;
532 return status;
533} 504}
534 505
535static int hpc_set_attention_status(struct slot *slot, u8 value) 506static int hpc_set_attention_status(struct slot *slot, u8 value)
@@ -539,7 +510,8 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
539 u16 slot_ctrl; 510 u16 slot_ctrl;
540 int rc = 0; 511 int rc = 0;
541 512
542 dbg("%s: \n", __FUNCTION__); 513 DBG_ENTER_ROUTINE
514
543 if (!php_ctlr) { 515 if (!php_ctlr) {
544 err("%s: Invalid HPC controller handle!\n", __FUNCTION__); 516 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
545 return -1; 517 return -1;
@@ -555,7 +527,6 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
555 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 527 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
556 return rc; 528 return rc;
557 } 529 }
558 dbg("%s : hp_register_read_word SLOT_CTRL %x\n", __FUNCTION__, slot_ctrl);
559 530
560 switch (value) { 531 switch (value) {
561 case 0 : /* turn off */ 532 case 0 : /* turn off */
@@ -576,6 +547,7 @@ static int hpc_set_attention_status(struct slot *slot, u8 value)
576 pcie_write_cmd(slot, slot_cmd); 547 pcie_write_cmd(slot, slot_cmd);
577 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 548 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
578 549
550 DBG_LEAVE_ROUTINE
579 return rc; 551 return rc;
580} 552}
581 553
@@ -587,7 +559,8 @@ static void hpc_set_green_led_on(struct slot *slot)
587 u16 slot_ctrl; 559 u16 slot_ctrl;
588 int rc = 0; 560 int rc = 0;
589 561
590 dbg("%s: \n", __FUNCTION__); 562 DBG_ENTER_ROUTINE
563
591 if (!php_ctlr) { 564 if (!php_ctlr) {
592 err("%s: Invalid HPC controller handle!\n", __FUNCTION__); 565 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
593 return ; 566 return ;
@@ -604,7 +577,6 @@ static void hpc_set_green_led_on(struct slot *slot)
604 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 577 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
605 return; 578 return;
606 } 579 }
607 dbg("%s : hp_register_read_word SLOT_CTRL %x\n", __FUNCTION__, slot_ctrl);
608 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0100; 580 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0100;
609 if (!pciehp_poll_mode) 581 if (!pciehp_poll_mode)
610 slot_cmd = slot_cmd | HP_INTR_ENABLE; 582 slot_cmd = slot_cmd | HP_INTR_ENABLE;
@@ -612,6 +584,7 @@ static void hpc_set_green_led_on(struct slot *slot)
612 pcie_write_cmd(slot, slot_cmd); 584 pcie_write_cmd(slot, slot_cmd);
613 585
614 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 586 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
587 DBG_LEAVE_ROUTINE
615 return; 588 return;
616} 589}
617 590
@@ -622,7 +595,8 @@ static void hpc_set_green_led_off(struct slot *slot)
622 u16 slot_ctrl; 595 u16 slot_ctrl;
623 int rc = 0; 596 int rc = 0;
624 597
625 dbg("%s: \n", __FUNCTION__); 598 DBG_ENTER_ROUTINE
599
626 if (!php_ctlr) { 600 if (!php_ctlr) {
627 err("%s: Invalid HPC controller handle!\n", __FUNCTION__); 601 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
628 return ; 602 return ;
@@ -639,7 +613,6 @@ static void hpc_set_green_led_off(struct slot *slot)
639 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 613 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
640 return; 614 return;
641 } 615 }
642 dbg("%s : hp_register_read_word SLOT_CTRL %x\n", __FUNCTION__, slot_ctrl);
643 616
644 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0300; 617 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0300;
645 618
@@ -648,6 +621,7 @@ static void hpc_set_green_led_off(struct slot *slot)
648 pcie_write_cmd(slot, slot_cmd); 621 pcie_write_cmd(slot, slot_cmd);
649 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 622 dbg("%s: SLOT_CTRL %x write cmd %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
650 623
624 DBG_LEAVE_ROUTINE
651 return; 625 return;
652} 626}
653 627
@@ -658,7 +632,8 @@ static void hpc_set_green_led_blink(struct slot *slot)
658 u16 slot_ctrl; 632 u16 slot_ctrl;
659 int rc = 0; 633 int rc = 0;
660 634
661 dbg("%s: \n", __FUNCTION__); 635 DBG_ENTER_ROUTINE
636
662 if (!php_ctlr) { 637 if (!php_ctlr) {
663 err("%s: Invalid HPC controller handle!\n", __FUNCTION__); 638 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
664 return ; 639 return ;
@@ -675,7 +650,6 @@ static void hpc_set_green_led_blink(struct slot *slot)
675 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 650 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
676 return; 651 return;
677 } 652 }
678 dbg("%s : hp_register_read_word SLOT_CTRL %x\n", __FUNCTION__, slot_ctrl);
679 653
680 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0200; 654 slot_cmd = (slot_ctrl & ~PWR_LED_CTRL) | 0x0200;
681 655
@@ -684,6 +658,7 @@ static void hpc_set_green_led_blink(struct slot *slot)
684 pcie_write_cmd(slot, slot_cmd); 658 pcie_write_cmd(slot, slot_cmd);
685 659
686 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd); 660 dbg("%s: SLOT_CTRL %x write cmd %x\n",__FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base), slot_cmd);
661 DBG_LEAVE_ROUTINE
687 return; 662 return;
688} 663}
689 664
@@ -775,12 +750,11 @@ static int hpc_power_on_slot(struct slot * slot)
775{ 750{
776 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle; 751 struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
777 u16 slot_cmd; 752 u16 slot_cmd;
778 u16 slot_ctrl; 753 u16 slot_ctrl, slot_status;
779 754
780 int retval = 0; 755 int retval = 0;
781 756
782 DBG_ENTER_ROUTINE 757 DBG_ENTER_ROUTINE
783 dbg("%s: \n", __FUNCTION__);
784 758
785 if (!php_ctlr) { 759 if (!php_ctlr) {
786 err("%s: Invalid HPC controller handle!\n", __FUNCTION__); 760 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
@@ -793,14 +767,20 @@ static int hpc_power_on_slot(struct slot * slot)
793 return -1; 767 return -1;
794 } 768 }
795 769
770 /* Clear sticky power-fault bit from previous power failures */
771 hp_register_read_word(php_ctlr->pci_dev,
772 SLOT_STATUS(slot->ctrl->cap_base), slot_status);
773 slot_status &= PWR_FAULT_DETECTED;
774 if (slot_status)
775 hp_register_write_word(php_ctlr->pci_dev,
776 SLOT_STATUS(slot->ctrl->cap_base), slot_status);
777
796 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl); 778 retval = hp_register_read_word(php_ctlr->pci_dev, SLOT_CTRL(slot->ctrl->cap_base), slot_ctrl);
797 779
798 if (retval) { 780 if (retval) {
799 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 781 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
800 return retval; 782 return retval;
801 } 783 }
802 dbg("%s: SLOT_CTRL %x, value read %xn", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base),
803 slot_ctrl);
804 784
805 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON; 785 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_ON;
806 786
@@ -829,7 +809,6 @@ static int hpc_power_off_slot(struct slot * slot)
829 int retval = 0; 809 int retval = 0;
830 810
831 DBG_ENTER_ROUTINE 811 DBG_ENTER_ROUTINE
832 dbg("%s: \n", __FUNCTION__);
833 812
834 if (!php_ctlr) { 813 if (!php_ctlr) {
835 err("%s: Invalid HPC controller handle!\n", __FUNCTION__); 814 err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
@@ -848,8 +827,6 @@ static int hpc_power_off_slot(struct slot * slot)
848 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 827 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
849 return retval; 828 return retval;
850 } 829 }
851 dbg("%s: SLOT_CTRL %x, value read %x\n", __FUNCTION__, SLOT_CTRL(slot->ctrl->cap_base),
852 slot_ctrl);
853 830
854 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF; 831 slot_cmd = (slot_ctrl & ~PWR_CTRL) | POWER_OFF;
855 832
@@ -924,7 +901,6 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
924 return IRQ_NONE; 901 return IRQ_NONE;
925 } 902 }
926 903
927 dbg("%s: Set Mask Hot-plug Interrupt Enable\n", __FUNCTION__);
928 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word); 904 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
929 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00; 905 temp_word = (temp_word & ~HP_INTR_ENABLE & ~CMD_CMPL_INTR_ENABLE) | 0x00;
930 906
@@ -933,7 +909,6 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
933 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 909 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
934 return IRQ_NONE; 910 return IRQ_NONE;
935 } 911 }
936 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
937 912
938 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 913 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
939 if (rc) { 914 if (rc) {
@@ -949,14 +924,12 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
949 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 924 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
950 return IRQ_NONE; 925 return IRQ_NONE;
951 } 926 }
952 dbg("%s: hp_register_write_word SLOT_STATUS with value %x\n", __FUNCTION__, temp_word);
953 } 927 }
954 928
955 if (intr_loc & CMD_COMPLETED) { 929 if (intr_loc & CMD_COMPLETED) {
956 /* 930 /*
957 * Command Complete Interrupt Pending 931 * Command Complete Interrupt Pending
958 */ 932 */
959 dbg("%s: In Command Complete Interrupt Pending\n", __FUNCTION__);
960 wake_up_interruptible(&ctrl->queue); 933 wake_up_interruptible(&ctrl->queue);
961 } 934 }
962 935
@@ -989,7 +962,6 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
989 } 962 }
990 963
991 dbg("%s: Unmask Hot-plug Interrupt Enable\n", __FUNCTION__); 964 dbg("%s: Unmask Hot-plug Interrupt Enable\n", __FUNCTION__);
992 dbg("%s: hp_register_read_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
993 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 965 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE;
994 966
995 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word); 967 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_CTRL(ctrl->cap_base), temp_word);
@@ -997,14 +969,12 @@ static irqreturn_t pcie_isr(int IRQ, void *dev_id, struct pt_regs *regs)
997 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 969 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
998 return IRQ_NONE; 970 return IRQ_NONE;
999 } 971 }
1000 dbg("%s: hp_register_write_word SLOT_CTRL with value %x\n", __FUNCTION__, temp_word);
1001 972
1002 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 973 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1003 if (rc) { 974 if (rc) {
1004 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 975 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1005 return IRQ_NONE; 976 return IRQ_NONE;
1006 } 977 }
1007 dbg("%s: hp_register_read_word SLOT_STATUS with value %x\n", __FUNCTION__, slot_status);
1008 978
1009 /* Clear command complete interrupt caused by this write */ 979 /* Clear command complete interrupt caused by this write */
1010 temp_word = 0x1F; 980 temp_word = 0x1F;
@@ -1248,12 +1218,7 @@ static struct hpc_ops pciehp_hpc_ops = {
1248 .check_lnk_status = hpc_check_lnk_status, 1218 .check_lnk_status = hpc_check_lnk_status,
1249}; 1219};
1250 1220
1251int pcie_init(struct controller * ctrl, 1221int pcie_init(struct controller * ctrl, struct pcie_device *dev)
1252 struct pcie_device *dev,
1253 php_intr_callback_t attention_button_callback,
1254 php_intr_callback_t switch_change_callback,
1255 php_intr_callback_t presence_change_callback,
1256 php_intr_callback_t power_fault_callback)
1257{ 1222{
1258 struct php_ctlr_state_s *php_ctlr, *p; 1223 struct php_ctlr_state_s *php_ctlr, *p;
1259 void *instance_id = ctrl; 1224 void *instance_id = ctrl;
@@ -1282,8 +1247,8 @@ int pcie_init(struct controller * ctrl,
1282 pdev = dev->port; 1247 pdev = dev->port;
1283 php_ctlr->pci_dev = pdev; /* save pci_dev in context */ 1248 php_ctlr->pci_dev = pdev; /* save pci_dev in context */
1284 1249
1285 dbg("%s: pdev->vendor %x pdev->device %x\n", __FUNCTION__, 1250 dbg("%s: hotplug controller vendor id 0x%x device id 0x%x\n",
1286 pdev->vendor, pdev->device); 1251 __FUNCTION__, pdev->vendor, pdev->device);
1287 1252
1288 saved_cap_base = pcie_cap_base; 1253 saved_cap_base = pcie_cap_base;
1289 1254
@@ -1340,8 +1305,6 @@ int pcie_init(struct controller * ctrl,
1340 first = 0; 1305 first = 0;
1341 } 1306 }
1342 1307
1343 dbg("pdev = %p: b:d:f:irq=0x%x:%x:%x:%x\n", pdev, pdev->bus->number,
1344 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq);
1345 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++) 1308 for ( rc = 0; rc < DEVICE_COUNT_RESOURCE; rc++)
1346 if (pci_resource_len(pdev, rc) > 0) 1309 if (pci_resource_len(pdev, rc) > 0)
1347 dbg("pci resource[%d] start=0x%lx(len=0x%lx)\n", rc, 1310 dbg("pci resource[%d] start=0x%lx(len=0x%lx)\n", rc,
@@ -1359,13 +1322,12 @@ int pcie_init(struct controller * ctrl,
1359 1322
1360 /* find the IRQ */ 1323 /* find the IRQ */
1361 php_ctlr->irq = dev->irq; 1324 php_ctlr->irq = dev->irq;
1362 dbg("HPC interrupt = %d\n", php_ctlr->irq);
1363 1325
1364 /* Save interrupt callback info */ 1326 /* Save interrupt callback info */
1365 php_ctlr->attention_button_callback = attention_button_callback; 1327 php_ctlr->attention_button_callback = pciehp_handle_attention_button;
1366 php_ctlr->switch_change_callback = switch_change_callback; 1328 php_ctlr->switch_change_callback = pciehp_handle_switch_change;
1367 php_ctlr->presence_change_callback = presence_change_callback; 1329 php_ctlr->presence_change_callback = pciehp_handle_presence_change;
1368 php_ctlr->power_fault_callback = power_fault_callback; 1330 php_ctlr->power_fault_callback = pciehp_handle_power_fault;
1369 php_ctlr->callback_instance_id = instance_id; 1331 php_ctlr->callback_instance_id = instance_id;
1370 1332
1371 /* return PCI Controller Info */ 1333 /* return PCI Controller Info */
@@ -1387,15 +1349,12 @@ int pcie_init(struct controller * ctrl,
1387 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1349 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1388 goto abort_free_ctlr; 1350 goto abort_free_ctlr;
1389 } 1351 }
1390 dbg("%s : Mask HPIE hp_register_write_word SLOT_CTRL %x\n", __FUNCTION__, temp_word);
1391 1352
1392 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1353 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1393 if (rc) { 1354 if (rc) {
1394 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1355 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1395 goto abort_free_ctlr; 1356 goto abort_free_ctlr;
1396 } 1357 }
1397 dbg("%s: Mask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base)
1398 , slot_status);
1399 1358
1400 temp_word = 0x1F; /* Clear all events */ 1359 temp_word = 0x1F; /* Clear all events */
1401 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1360 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
@@ -1403,7 +1362,6 @@ int pcie_init(struct controller * ctrl,
1403 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1362 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1404 goto abort_free_ctlr; 1363 goto abort_free_ctlr;
1405 } 1364 }
1406 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word);
1407 1365
1408 if (pciehp_poll_mode) {/* Install interrupt polling code */ 1366 if (pciehp_poll_mode) {/* Install interrupt polling code */
1409 /* Install and start the interrupt polling timer */ 1367 /* Install and start the interrupt polling timer */
@@ -1419,13 +1377,14 @@ int pcie_init(struct controller * ctrl,
1419 } 1377 }
1420 } 1378 }
1421 1379
1380 dbg("pciehp ctrl b:d:f:irq=0x%x:%x:%x:%x\n", pdev->bus->number,
1381 PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), dev->irq);
1382
1422 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1383 rc = hp_register_read_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
1423 if (rc) { 1384 if (rc) {
1424 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__); 1385 err("%s : hp_register_read_word SLOT_CTRL failed\n", __FUNCTION__);
1425 goto abort_free_ctlr; 1386 goto abort_free_ctlr;
1426 } 1387 }
1427 dbg("%s: SLOT_CTRL %x value read %x\n", __FUNCTION__, SLOT_CTRL(ctrl->cap_base), temp_word);
1428 dbg("%s: slot_cap %x\n", __FUNCTION__, slot_cap);
1429 1388
1430 intr_enable = intr_enable | PRSN_DETECT_ENABLE; 1389 intr_enable = intr_enable | PRSN_DETECT_ENABLE;
1431 1390
@@ -1445,7 +1404,6 @@ int pcie_init(struct controller * ctrl,
1445 } else { 1404 } else {
1446 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE; 1405 temp_word = (temp_word & ~HP_INTR_ENABLE) | HP_INTR_ENABLE;
1447 } 1406 }
1448 dbg("%s: temp_word %x\n", __FUNCTION__, temp_word);
1449 1407
1450 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */ 1408 /* Unmask Hot-plug Interrupt Enable for the interrupt notification mechanism case */
1451 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word); 1409 rc = hp_register_write_word(pdev, SLOT_CTRL(ctrl->cap_base), temp_word);
@@ -1453,14 +1411,11 @@ int pcie_init(struct controller * ctrl,
1453 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__); 1411 err("%s : hp_register_write_word SLOT_CTRL failed\n", __FUNCTION__);
1454 goto abort_free_ctlr; 1412 goto abort_free_ctlr;
1455 } 1413 }
1456 dbg("%s : Unmask HPIE hp_register_write_word SLOT_CTRL with %x\n", __FUNCTION__, temp_word);
1457 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status); 1414 rc = hp_register_read_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), slot_status);
1458 if (rc) { 1415 if (rc) {
1459 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__); 1416 err("%s : hp_register_read_word SLOT_STATUS failed\n", __FUNCTION__);
1460 goto abort_free_ctlr; 1417 goto abort_free_ctlr;
1461 } 1418 }
1462 dbg("%s: Unmask HPIE SLOT_STATUS offset %x reads slot_status %x\n", __FUNCTION__,
1463 SLOT_STATUS(ctrl->cap_base), slot_status);
1464 1419
1465 temp_word = 0x1F; /* Clear all events */ 1420 temp_word = 0x1F; /* Clear all events */
1466 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word); 1421 rc = hp_register_write_word(php_ctlr->pci_dev, SLOT_STATUS(ctrl->cap_base), temp_word);
@@ -1468,8 +1423,16 @@ int pcie_init(struct controller * ctrl,
1468 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__); 1423 err("%s : hp_register_write_word SLOT_STATUS failed\n", __FUNCTION__);
1469 goto abort_free_ctlr; 1424 goto abort_free_ctlr;
1470 } 1425 }
1471 dbg("%s: SLOT_STATUS offset %x writes slot_status %x\n", __FUNCTION__, SLOT_STATUS(ctrl->cap_base), temp_word);
1472 1426
1427 if (pciehp_force) {
1428 dbg("Bypassing BIOS check for pciehp use on %s\n",
1429 pci_name(ctrl->pci_dev));
1430 } else {
1431 rc = pciehp_get_hp_hw_control_from_firmware(ctrl->pci_dev);
1432 if (rc)
1433 goto abort_free_ctlr;
1434 }
1435
1473 /* Add this HPC instance into the HPC list */ 1436 /* Add this HPC instance into the HPC list */
1474 spin_lock(&list_lock); 1437 spin_lock(&list_lock);
1475 if (php_ctlr_list_head == 0) { 1438 if (php_ctlr_list_head == 0) {
diff --git a/drivers/pci/hotplug/pciehp_pci.c b/drivers/pci/hotplug/pciehp_pci.c
index ff17d8e07e94..647673a7d224 100644
--- a/drivers/pci/hotplug/pciehp_pci.c
+++ b/drivers/pci/hotplug/pciehp_pci.c
@@ -27,801 +27,111 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/slab.h>
35#include <linux/workqueue.h>
36#include <linux/proc_fs.h>
37#include <linux/pci.h> 33#include <linux/pci.h>
38#include "../pci.h" 34#include "../pci.h"
39#include "pciehp.h" 35#include "pciehp.h"
40#ifndef CONFIG_IA64
41#include "../../../arch/i386/pci/pci.h" /* horrible hack showing how processor dependant we are... */
42#endif
43 36
44 37
45int pciehp_configure_device (struct controller* ctrl, struct pci_func* func) 38int pciehp_configure_device(struct slot *p_slot)
46{ 39{
47 unsigned char bus; 40 struct pci_dev *dev;
48 struct pci_bus *child; 41 struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
49 int num; 42 int num, fn;
50 43
51 if (func->pci_dev == NULL) 44 dev = pci_find_slot(p_slot->bus, PCI_DEVFN(p_slot->device, 0));
52 func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function)); 45 if (dev) {
53 46 err("Device %s already exists at %x:%x, cannot hot-add\n",
54 /* Still NULL ? Well then scan for it ! */ 47 pci_name(dev), p_slot->bus, p_slot->device);
55 if (func->pci_dev == NULL) { 48 return -EINVAL;
56 dbg("%s: pci_dev still null. do pci_scan_slot\n", __FUNCTION__);
57
58 num = pci_scan_slot(ctrl->pci_dev->subordinate, PCI_DEVFN(func->device, func->function));
59
60 if (num)
61 pci_bus_add_devices(ctrl->pci_dev->subordinate);
62
63 func->pci_dev = pci_find_slot(func->bus, PCI_DEVFN(func->device, func->function));
64 if (func->pci_dev == NULL) {
65 dbg("ERROR: pci_dev still null\n");
66 return 0;
67 }
68 } 49 }
69 50
70 if (func->pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { 51 num = pci_scan_slot(parent, PCI_DEVFN(p_slot->device, 0));
71 pci_read_config_byte(func->pci_dev, PCI_SECONDARY_BUS, &bus); 52 if (num == 0) {
72 child = pci_add_new_bus(func->pci_dev->bus, (func->pci_dev), bus); 53 err("No new device found\n");
73 pci_do_scan_bus(child); 54 return -ENODEV;
55 }
74 56
57 for (fn = 0; fn < 8; fn++) {
58 if (!(dev = pci_find_slot(p_slot->bus,
59 PCI_DEVFN(p_slot->device, fn))))
60 continue;
61 if ((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
62 err("Cannot hot-add display device %s\n",
63 pci_name(dev));
64 continue;
65 }
66 if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
67 (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)) {
68 /* Find an unused bus number for the new bridge */
69 struct pci_bus *child;
70 unsigned char busnr, start = parent->secondary;
71 unsigned char end = parent->subordinate;
72 for (busnr = start; busnr <= end; busnr++) {
73 if (!pci_find_bus(pci_domain_nr(parent),
74 busnr))
75 break;
76 }
77 if (busnr >= end) {
78 err("No free bus for hot-added bridge\n");
79 continue;
80 }
81 child = pci_add_new_bus(parent, dev, busnr);
82 if (!child) {
83 err("Cannot add new bus for %s\n",
84 pci_name(dev));
85 continue;
86 }
87 child->subordinate = pci_do_scan_bus(child);
88 pci_bus_size_bridges(child);
89 }
90 /* TBD: program firmware provided _HPP values */
91 /* program_fw_provided_values(dev); */
75 } 92 }
76 93
94 pci_bus_assign_resources(parent);
95 pci_bus_add_devices(parent);
96 pci_enable_bridges(parent);
77 return 0; 97 return 0;
78} 98}
79 99
80 100int pciehp_unconfigure_device(struct slot *p_slot)
81int pciehp_unconfigure_device(struct pci_func* func)
82{ 101{
83 int rc = 0; 102 int rc = 0;
84 int j; 103 int j;
85 struct pci_bus *pbus; 104 u8 bctl = 0;
86 105
87 dbg("%s: bus/dev/func = %x/%x/%x\n", __FUNCTION__, func->bus, 106 dbg("%s: bus/dev = %x/%x\n", __FUNCTION__, p_slot->bus,
88 func->device, func->function); 107 p_slot->device);
89 pbus = func->pci_dev->bus;
90 108
91 for (j=0; j<8 ; j++) { 109 for (j=0; j<8 ; j++) {
92 struct pci_dev* temp = pci_find_slot(func->bus, 110 struct pci_dev* temp = pci_find_slot(p_slot->bus,
93 (func->device << 3) | j); 111 (p_slot->device << 3) | j);
94 if (temp) { 112 if (!temp)
95 pci_remove_bus_device(temp); 113 continue;
114 if ((temp->class >> 16) == PCI_BASE_CLASS_DISPLAY) {
115 err("Cannot remove display device %s\n",
116 pci_name(temp));
117 continue;
96 } 118 }
119 if (temp->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
120 pci_read_config_byte(temp, PCI_BRIDGE_CONTROL, &bctl);
121 if (bctl & PCI_BRIDGE_CTL_VGA) {
122 err("Cannot remove display device %s\n",
123 pci_name(temp));
124 continue;
125 }
126 }
127 pci_remove_bus_device(temp);
97 } 128 }
98 /* 129 /*
99 * Some PCI Express root ports require fixup after hot-plug operation. 130 * Some PCI Express root ports require fixup after hot-plug operation.
100 */ 131 */
101 if (pcie_mch_quirk) 132 if (pcie_mch_quirk)
102 pci_fixup_device(pci_fixup_final, pbus->self); 133 pci_fixup_device(pci_fixup_final, p_slot->ctrl->pci_dev);
103 134
104 return rc; 135 return rc;
105} 136}
106 137
107/*
108 * pciehp_set_irq
109 *
110 * @bus_num: bus number of PCI device
111 * @dev_num: device number of PCI device
112 * @slot: pointer to u8 where slot number will be returned
113 */
114int pciehp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
115{
116#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_IO_APIC)
117 int rc;
118 u16 temp_word;
119 struct pci_dev fakedev;
120 struct pci_bus fakebus;
121
122 fakedev.devfn = dev_num << 3;
123 fakedev.bus = &fakebus;
124 fakebus.number = bus_num;
125 dbg("%s: dev %d, bus %d, pin %d, num %d\n",
126 __FUNCTION__, dev_num, bus_num, int_pin, irq_num);
127 rc = pcibios_set_irq_routing(&fakedev, int_pin - 0x0a, irq_num);
128 dbg("%s: rc %d\n", __FUNCTION__, rc);
129 if (!rc)
130 return !rc;
131
132 /* set the Edge Level Control Register (ELCR) */
133 temp_word = inb(0x4d0);
134 temp_word |= inb(0x4d1) << 8;
135
136 temp_word |= 0x01 << irq_num;
137
138 /* This should only be for x86 as it sets the Edge Level Control Register */
139 outb((u8) (temp_word & 0xFF), 0x4d0);
140 outb((u8) ((temp_word & 0xFF00) >> 8), 0x4d1);
141#endif
142 return 0;
143}
144
145/* More PCI configuration routines; this time centered around hotplug controller */
146
147
148/*
149 * pciehp_save_config
150 *
151 * Reads configuration for all slots in a PCI bus and saves info.
152 *
153 * Note: For non-hot plug busses, the slot # saved is the device #
154 *
155 * returns 0 if success
156 */
157int pciehp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num)
158{
159 int rc;
160 u8 class_code;
161 u8 header_type;
162 u32 ID;
163 u8 secondary_bus;
164 struct pci_func *new_slot;
165 int sub_bus;
166 int max_functions;
167 int function;
168 u8 DevError;
169 int device = 0;
170 int cloop = 0;
171 int stop_it;
172 int index;
173 int is_hot_plug = num_ctlr_slots || first_device_num;
174 struct pci_bus lpci_bus, *pci_bus;
175 int FirstSupported, LastSupported;
176
177 dbg("%s: Enter\n", __FUNCTION__);
178
179 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
180 pci_bus = &lpci_bus;
181
182 dbg("%s: num_ctlr_slots = %d, first_device_num = %d\n", __FUNCTION__,
183 num_ctlr_slots, first_device_num);
184
185 /* Decide which slots are supported */
186 if (is_hot_plug) {
187 /*********************************
188 * is_hot_plug is the slot mask
189 *********************************/
190 FirstSupported = first_device_num;
191 LastSupported = FirstSupported + num_ctlr_slots - 1;
192 } else {
193 FirstSupported = 0;
194 LastSupported = 0x1F;
195 }
196
197 dbg("FirstSupported = %d, LastSupported = %d\n", FirstSupported,
198 LastSupported);
199
200 /* Save PCI configuration space for all devices in supported slots */
201 dbg("%s: pci_bus->number = %x\n", __FUNCTION__, pci_bus->number);
202 pci_bus->number = busnumber;
203 dbg("%s: bus = %x, dev = %x\n", __FUNCTION__, busnumber, device);
204 for (device = FirstSupported; device <= LastSupported; device++) {
205 ID = 0xFFFFFFFF;
206 rc = pci_bus_read_config_dword(pci_bus, PCI_DEVFN(device, 0),
207 PCI_VENDOR_ID, &ID);
208
209 if (ID != 0xFFFFFFFF) { /* device in slot */
210 dbg("%s: ID = %x\n", __FUNCTION__, ID);
211 rc = pci_bus_read_config_byte(pci_bus, PCI_DEVFN(device, 0),
212 0x0B, &class_code);
213 if (rc)
214 return rc;
215
216 rc = pci_bus_read_config_byte(pci_bus, PCI_DEVFN(device, 0),
217 PCI_HEADER_TYPE, &header_type);
218 if (rc)
219 return rc;
220
221 dbg("class_code = %x, header_type = %x\n", class_code, header_type);
222
223 /* If multi-function device, set max_functions to 8 */
224 if (header_type & 0x80)
225 max_functions = 8;
226 else
227 max_functions = 1;
228
229 function = 0;
230
231 do {
232 DevError = 0;
233 dbg("%s: In do loop\n", __FUNCTION__);
234
235 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* P-P Bridge */
236 /* Recurse the subordinate bus
237 * get the subordinate bus number
238 */
239 rc = pci_bus_read_config_byte(pci_bus,
240 PCI_DEVFN(device, function),
241 PCI_SECONDARY_BUS, &secondary_bus);
242 if (rc) {
243 return rc;
244 } else {
245 sub_bus = (int) secondary_bus;
246
247 /* Save secondary bus cfg spc with this recursive call. */
248 rc = pciehp_save_config(ctrl, sub_bus, 0, 0);
249 if (rc)
250 return rc;
251 }
252 }
253
254 index = 0;
255 new_slot = pciehp_slot_find(busnumber, device, index++);
256
257 dbg("%s: new_slot = %p bus %x dev %x fun %x\n",
258 __FUNCTION__, new_slot, busnumber, device, index-1);
259
260 while (new_slot && (new_slot->function != (u8) function)) {
261 new_slot = pciehp_slot_find(busnumber, device, index++);
262 dbg("%s: while loop, new_slot = %p bus %x dev %x fun %x\n",
263 __FUNCTION__, new_slot, busnumber, device, index-1);
264 }
265 if (!new_slot) {
266 /* Setup slot structure. */
267 new_slot = pciehp_slot_create(busnumber);
268 dbg("%s: if, new_slot = %p bus %x dev %x fun %x\n",
269 __FUNCTION__, new_slot, busnumber, device, function);
270
271 if (new_slot == NULL)
272 return(1);
273 }
274
275 new_slot->bus = (u8) busnumber;
276 new_slot->device = (u8) device;
277 new_slot->function = (u8) function;
278 new_slot->is_a_board = 1;
279 new_slot->switch_save = 0x10;
280 /* In case of unsupported board */
281 new_slot->status = DevError;
282 new_slot->pci_dev = pci_find_slot(new_slot->bus,
283 (new_slot->device << 3) | new_slot->function);
284 dbg("new_slot->pci_dev = %p\n", new_slot->pci_dev);
285
286 for (cloop = 0; cloop < 0x20; cloop++) {
287 rc = pci_bus_read_config_dword(pci_bus,
288 PCI_DEVFN(device, function),
289 cloop << 2,
290 (u32 *) &(new_slot->config_space [cloop]));
291 /* dbg("new_slot->config_space[%x] = %x\n",
292 cloop, new_slot->config_space[cloop]); */
293 if (rc)
294 return rc;
295 }
296
297 function++;
298
299 stop_it = 0;
300
301 /* this loop skips to the next present function
302 * reading in Class Code and Header type.
303 */
304
305 while ((function < max_functions)&&(!stop_it)) {
306 dbg("%s: In while loop \n", __FUNCTION__);
307 rc = pci_bus_read_config_dword(pci_bus,
308 PCI_DEVFN(device, function),
309 PCI_VENDOR_ID, &ID);
310
311 if (ID == 0xFFFFFFFF) { /* nothing there. */
312 function++;
313 dbg("Nothing there\n");
314 } else { /* Something there */
315 rc = pci_bus_read_config_byte(pci_bus,
316 PCI_DEVFN(device, function),
317 0x0B, &class_code);
318 if (rc)
319 return rc;
320
321 rc = pci_bus_read_config_byte(pci_bus,
322 PCI_DEVFN(device, function),
323 PCI_HEADER_TYPE, &header_type);
324 if (rc)
325 return rc;
326
327 dbg("class_code = %x, header_type = %x\n", class_code, header_type);
328 stop_it++;
329 }
330 }
331
332 } while (function < max_functions);
333 /* End of IF (device in slot?) */
334 } else if (is_hot_plug) {
335 /* Setup slot structure with entry for empty slot */
336 new_slot = pciehp_slot_create(busnumber);
337
338 if (new_slot == NULL) {
339 return(1);
340 }
341 dbg("new_slot = %p, bus = %x, dev = %x, fun = %x\n", new_slot,
342 new_slot->bus, new_slot->device, new_slot->function);
343
344 new_slot->bus = (u8) busnumber;
345 new_slot->device = (u8) device;
346 new_slot->function = 0;
347 new_slot->is_a_board = 0;
348 new_slot->presence_save = 0;
349 new_slot->switch_save = 0;
350 }
351 } /* End of FOR loop */
352
353 dbg("%s: Exit\n", __FUNCTION__);
354 return(0);
355}
356
357
358/*
359 * pciehp_save_slot_config
360 *
361 * Saves configuration info for all PCI devices in a given slot
362 * including subordinate busses.
363 *
364 * returns 0 if success
365 */
366int pciehp_save_slot_config(struct controller *ctrl, struct pci_func * new_slot)
367{
368 int rc;
369 u8 class_code;
370 u8 header_type;
371 u32 ID;
372 u8 secondary_bus;
373 int sub_bus;
374 int max_functions;
375 int function;
376 int cloop = 0;
377 int stop_it;
378 struct pci_bus lpci_bus, *pci_bus;
379 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
380 pci_bus = &lpci_bus;
381 pci_bus->number = new_slot->bus;
382
383 ID = 0xFFFFFFFF;
384
385 pci_bus_read_config_dword(pci_bus, PCI_DEVFN(new_slot->device, 0),
386 PCI_VENDOR_ID, &ID);
387
388 if (ID != 0xFFFFFFFF) { /* device in slot */
389 pci_bus_read_config_byte(pci_bus, PCI_DEVFN(new_slot->device, 0),
390 0x0B, &class_code);
391
392 pci_bus_read_config_byte(pci_bus, PCI_DEVFN(new_slot->device, 0),
393 PCI_HEADER_TYPE, &header_type);
394
395 if (header_type & 0x80) /* Multi-function device */
396 max_functions = 8;
397 else
398 max_functions = 1;
399
400 function = 0;
401
402 do {
403 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
404 /* Recurse the subordinate bus */
405 pci_bus_read_config_byte(pci_bus,
406 PCI_DEVFN(new_slot->device, function),
407 PCI_SECONDARY_BUS, &secondary_bus);
408
409 sub_bus = (int) secondary_bus;
410
411 /* Save the config headers for the secondary bus. */
412 rc = pciehp_save_config(ctrl, sub_bus, 0, 0);
413
414 if (rc)
415 return rc;
416
417 } /* End of IF */
418
419 new_slot->status = 0;
420
421 for (cloop = 0; cloop < 0x20; cloop++) {
422 pci_bus_read_config_dword(pci_bus,
423 PCI_DEVFN(new_slot->device, function),
424 cloop << 2,
425 (u32 *) &(new_slot->config_space [cloop]));
426 }
427
428 function++;
429
430 stop_it = 0;
431
432 /* this loop skips to the next present function
433 * reading in the Class Code and the Header type.
434 */
435
436 while ((function < max_functions) && (!stop_it)) {
437 pci_bus_read_config_dword(pci_bus,
438 PCI_DEVFN(new_slot->device, function),
439 PCI_VENDOR_ID, &ID);
440
441 if (ID == 0xFFFFFFFF) { /* nothing there. */
442 function++;
443 } else { /* Something there */
444 pci_bus_read_config_byte(pci_bus,
445 PCI_DEVFN(new_slot->device, function),
446 0x0B, &class_code);
447
448 pci_bus_read_config_byte(pci_bus,
449 PCI_DEVFN(new_slot->device, function),
450 PCI_HEADER_TYPE, &header_type);
451
452 stop_it++;
453 }
454 }
455
456 } while (function < max_functions);
457 } /* End of IF (device in slot?) */
458 else {
459 return 2;
460 }
461
462 return 0;
463}
464
465
466/*
467 * pciehp_save_used_resources
468 *
469 * Stores used resource information for existing boards. this is
470 * for boards that were in the system when this driver was loaded.
471 * this function is for hot plug ADD
472 *
473 * returns 0 if success
474 * if disable == 1(DISABLE_CARD),
475 * it loops for all functions of the slot and disables them.
476 * else, it just get resources of the function and return.
477 */
478int pciehp_save_used_resources(struct controller *ctrl, struct pci_func *func, int disable)
479{
480 u8 cloop;
481 u8 header_type;
482 u8 secondary_bus;
483 u8 temp_byte;
484 u16 command;
485 u16 save_command;
486 u16 w_base, w_length;
487 u32 temp_register;
488 u32 save_base;
489 u32 base, length;
490 u64 base64 = 0;
491 int index = 0;
492 unsigned int devfn;
493 struct pci_resource *mem_node = NULL;
494 struct pci_resource *p_mem_node = NULL;
495 struct pci_resource *t_mem_node;
496 struct pci_resource *io_node;
497 struct pci_resource *bus_node;
498 struct pci_bus lpci_bus, *pci_bus;
499 memcpy(&lpci_bus, ctrl->pci_dev->subordinate, sizeof(lpci_bus));
500 pci_bus = &lpci_bus;
501
502 if (disable)
503 func = pciehp_slot_find(func->bus, func->device, index++);
504
505 while ((func != NULL) && func->is_a_board) {
506 pci_bus->number = func->bus;
507 devfn = PCI_DEVFN(func->device, func->function);
508
509 /* Save the command register */
510 pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &save_command);
511
512 if (disable) {
513 /* disable card */
514 command = 0x00;
515 pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
516 }
517
518 /* Check for Bridge */
519 pci_bus_read_config_byte(pci_bus, devfn, PCI_HEADER_TYPE, &header_type);
520
521 if ((header_type & 0x7F) == PCI_HEADER_TYPE_BRIDGE) { /* PCI-PCI Bridge */
522 dbg("Save_used_res of PCI bridge b:d=0x%x:%x, sc=0x%x\n",
523 func->bus, func->device, save_command);
524 if (disable) {
525 /* Clear Bridge Control Register */
526 command = 0x00;
527 pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, command);
528 }
529
530 pci_bus_read_config_byte(pci_bus, devfn, PCI_SECONDARY_BUS, &secondary_bus);
531 pci_bus_read_config_byte(pci_bus, devfn, PCI_SUBORDINATE_BUS, &temp_byte);
532
533 bus_node = kmalloc(sizeof(struct pci_resource),
534 GFP_KERNEL);
535 if (!bus_node)
536 return -ENOMEM;
537
538 bus_node->base = (ulong)secondary_bus;
539 bus_node->length = (ulong)(temp_byte - secondary_bus + 1);
540
541 bus_node->next = func->bus_head;
542 func->bus_head = bus_node;
543
544 /* Save IO base and Limit registers */
545 pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_BASE, &temp_byte);
546 base = temp_byte;
547 pci_bus_read_config_byte(pci_bus, devfn, PCI_IO_LIMIT, &temp_byte);
548 length = temp_byte;
549
550 if ((base <= length) && (!disable || (save_command & PCI_COMMAND_IO))) {
551 io_node = kmalloc(sizeof(struct pci_resource),
552 GFP_KERNEL);
553 if (!io_node)
554 return -ENOMEM;
555
556 io_node->base = (ulong)(base & PCI_IO_RANGE_MASK) << 8;
557 io_node->length = (ulong)(length - base + 0x10) << 8;
558
559 io_node->next = func->io_head;
560 func->io_head = io_node;
561 }
562
563 /* Save memory base and Limit registers */
564 pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_BASE, &w_base);
565 pci_bus_read_config_word(pci_bus, devfn, PCI_MEMORY_LIMIT, &w_length);
566
567 if ((w_base <= w_length) && (!disable || (save_command & PCI_COMMAND_MEMORY))) {
568 mem_node = kmalloc(sizeof(struct pci_resource),
569 GFP_KERNEL);
570 if (!mem_node)
571 return -ENOMEM;
572
573 mem_node->base = (ulong)w_base << 16;
574 mem_node->length = (ulong)(w_length - w_base + 0x10) << 16;
575
576 mem_node->next = func->mem_head;
577 func->mem_head = mem_node;
578 }
579 /* Save prefetchable memory base and Limit registers */
580 pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_BASE, &w_base);
581 pci_bus_read_config_word(pci_bus, devfn, PCI_PREF_MEMORY_LIMIT, &w_length);
582
583 if ((w_base <= w_length) && (!disable || (save_command & PCI_COMMAND_MEMORY))) {
584 p_mem_node = kmalloc(sizeof(struct pci_resource),
585 GFP_KERNEL);
586 if (!p_mem_node)
587 return -ENOMEM;
588
589 p_mem_node->base = (ulong)w_base << 16;
590 p_mem_node->length = (ulong)(w_length - w_base + 0x10) << 16;
591
592 p_mem_node->next = func->p_mem_head;
593 func->p_mem_head = p_mem_node;
594 }
595 } else if ((header_type & 0x7F) == PCI_HEADER_TYPE_NORMAL) {
596 dbg("Save_used_res of PCI adapter b:d=0x%x:%x, sc=0x%x\n",
597 func->bus, func->device, save_command);
598
599 /* Figure out IO and memory base lengths */
600 for (cloop = PCI_BASE_ADDRESS_0; cloop <= PCI_BASE_ADDRESS_5; cloop += 4) {
601 pci_bus_read_config_dword(pci_bus, devfn, cloop, &save_base);
602
603 temp_register = 0xFFFFFFFF;
604 pci_bus_write_config_dword(pci_bus, devfn, cloop, temp_register);
605 pci_bus_read_config_dword(pci_bus, devfn, cloop, &temp_register);
606
607 if (!disable)
608 pci_bus_write_config_dword(pci_bus, devfn, cloop, save_base);
609
610 if (!temp_register)
611 continue;
612
613 base = temp_register;
614
615 if ((base & PCI_BASE_ADDRESS_SPACE_IO) &&
616 (!disable || (save_command & PCI_COMMAND_IO))) {
617 /* IO base */
618 /* set temp_register = amount of IO space requested */
619 base = base & 0xFFFFFFFCL;
620 base = (~base) + 1;
621
622 io_node = kmalloc(sizeof (struct pci_resource),
623 GFP_KERNEL);
624 if (!io_node)
625 return -ENOMEM;
626
627 io_node->base = (ulong)save_base & PCI_BASE_ADDRESS_IO_MASK;
628 io_node->length = (ulong)base;
629 dbg("sur adapter: IO bar=0x%x(length=0x%x)\n",
630 io_node->base, io_node->length);
631
632 io_node->next = func->io_head;
633 func->io_head = io_node;
634 } else { /* map Memory */
635 int prefetchable = 1;
636 /* struct pci_resources **res_node; */
637 char *res_type_str = "PMEM";
638 u32 temp_register2;
639
640 t_mem_node = kmalloc(sizeof (struct pci_resource),
641 GFP_KERNEL);
642 if (!t_mem_node)
643 return -ENOMEM;
644
645 if (!(base & PCI_BASE_ADDRESS_MEM_PREFETCH) &&
646 (!disable || (save_command & PCI_COMMAND_MEMORY))) {
647 prefetchable = 0;
648 mem_node = t_mem_node;
649 res_type_str++;
650 } else
651 p_mem_node = t_mem_node;
652
653 base = base & 0xFFFFFFF0L;
654 base = (~base) + 1;
655
656 switch (temp_register & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
657 case PCI_BASE_ADDRESS_MEM_TYPE_32:
658 if (prefetchable) {
659 p_mem_node->base = (ulong)save_base & PCI_BASE_ADDRESS_MEM_MASK;
660 p_mem_node->length = (ulong)base;
661 dbg("sur adapter: 32 %s bar=0x%x(length=0x%x)\n",
662 res_type_str,
663 p_mem_node->base,
664 p_mem_node->length);
665
666 p_mem_node->next = func->p_mem_head;
667 func->p_mem_head = p_mem_node;
668 } else {
669 mem_node->base = (ulong)save_base & PCI_BASE_ADDRESS_MEM_MASK;
670 mem_node->length = (ulong)base;
671 dbg("sur adapter: 32 %s bar=0x%x(length=0x%x)\n",
672 res_type_str,
673 mem_node->base,
674 mem_node->length);
675
676 mem_node->next = func->mem_head;
677 func->mem_head = mem_node;
678 }
679 break;
680 case PCI_BASE_ADDRESS_MEM_TYPE_64:
681 pci_bus_read_config_dword(pci_bus, devfn, cloop+4, &temp_register2);
682 base64 = temp_register2;
683 base64 = (base64 << 32) | save_base;
684
685 if (temp_register2) {
686 dbg("sur adapter: 64 %s high dword of base64(0x%x:%x) masked to 0\n",
687 res_type_str, temp_register2, (u32)base64);
688 base64 &= 0x00000000FFFFFFFFL;
689 }
690
691 if (prefetchable) {
692 p_mem_node->base = base64 & PCI_BASE_ADDRESS_MEM_MASK;
693 p_mem_node->length = base;
694 dbg("sur adapter: 64 %s base=0x%x(len=0x%x)\n",
695 res_type_str,
696 p_mem_node->base,
697 p_mem_node->length);
698
699 p_mem_node->next = func->p_mem_head;
700 func->p_mem_head = p_mem_node;
701 } else {
702 mem_node->base = base64 & PCI_BASE_ADDRESS_MEM_MASK;
703 mem_node->length = base;
704 dbg("sur adapter: 64 %s base=0x%x(len=0x%x)\n",
705 res_type_str,
706 mem_node->base,
707 mem_node->length);
708
709 mem_node->next = func->mem_head;
710 func->mem_head = mem_node;
711 }
712 cloop += 4;
713 break;
714 default:
715 dbg("asur: reserved BAR type=0x%x\n",
716 temp_register);
717 break;
718 }
719 }
720 } /* End of base register loop */
721 } else { /* Some other unknown header type */
722 dbg("Save_used_res of PCI unknown type b:d=0x%x:%x. skip.\n",
723 func->bus, func->device);
724 }
725
726 /* find the next device in this slot */
727 if (!disable)
728 break;
729 func = pciehp_slot_find(func->bus, func->device, index++);
730 }
731
732 return 0;
733}
734
735
736/**
737 * kfree_resource_list: release memory of all list members
738 * @res: resource list to free
739 */
740static inline void
741return_resource_list(struct pci_resource **func, struct pci_resource **res)
742{
743 struct pci_resource *node;
744 struct pci_resource *t_node;
745
746 node = *func;
747 *func = NULL;
748 while (node) {
749 t_node = node->next;
750 return_resource(res, node);
751 node = t_node;
752 }
753}
754
755/*
756 * pciehp_return_board_resources
757 *
758 * this routine returns all resources allocated to a board to
759 * the available pool.
760 *
761 * returns 0 if success
762 */
763int pciehp_return_board_resources(struct pci_func * func,
764 struct resource_lists * resources)
765{
766 int rc;
767
768 dbg("%s\n", __FUNCTION__);
769
770 if (!func)
771 return 1;
772
773 return_resource_list(&(func->io_head),&(resources->io_head));
774 return_resource_list(&(func->mem_head),&(resources->mem_head));
775 return_resource_list(&(func->p_mem_head),&(resources->p_mem_head));
776 return_resource_list(&(func->bus_head),&(resources->bus_head));
777
778 rc = pciehp_resource_sort_and_combine(&(resources->mem_head));
779 rc |= pciehp_resource_sort_and_combine(&(resources->p_mem_head));
780 rc |= pciehp_resource_sort_and_combine(&(resources->io_head));
781 rc |= pciehp_resource_sort_and_combine(&(resources->bus_head));
782
783 return rc;
784}
785
786/**
787 * kfree_resource_list: release memory of all list members
788 * @res: resource list to free
789 */
790static inline void
791kfree_resource_list(struct pci_resource **r)
792{
793 struct pci_resource *res, *tres;
794
795 res = *r;
796 *r = NULL;
797
798 while (res) {
799 tres = res;
800 res = res->next;
801 kfree(tres);
802 }
803}
804
805/**
806 * pciehp_destroy_resource_list: put node back in the resource list
807 * @resources: list to put nodes back
808 */
809void pciehp_destroy_resource_list(struct resource_lists * resources)
810{
811 kfree_resource_list(&(resources->io_head));
812 kfree_resource_list(&(resources->mem_head));
813 kfree_resource_list(&(resources->p_mem_head));
814 kfree_resource_list(&(resources->bus_head));
815}
816
817/**
818 * pciehp_destroy_board_resources: put node back in the resource list
819 * @resources: list to put nodes back
820 */
821void pciehp_destroy_board_resources(struct pci_func * func)
822{
823 kfree_resource_list(&(func->io_head));
824 kfree_resource_list(&(func->mem_head));
825 kfree_resource_list(&(func->p_mem_head));
826 kfree_resource_list(&(func->bus_head));
827}
diff --git a/drivers/pci/hotplug/pciehprm.h b/drivers/pci/hotplug/pciehprm.h
deleted file mode 100644
index 05f20fbc5f50..000000000000
--- a/drivers/pci/hotplug/pciehprm.h
+++ /dev/null
@@ -1,52 +0,0 @@
1/*
2 * PCIEHPRM : PCIEHP Resource Manager for ACPI/non-ACPI platform
3 *
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001,2003 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
8 *
9 * All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
27 *
28 */
29
30#ifndef _PCIEHPRM_H_
31#define _PCIEHPRM_H_
32
33#ifdef CONFIG_HOTPLUG_PCI_PCIE_PHPRM_NONACPI
34#include "pciehprm_nonacpi.h"
35#endif
36
37int pciehprm_init(enum php_ctlr_type ct);
38void pciehprm_cleanup(void);
39int pciehprm_print_pirt(void);
40int pciehprm_find_available_resources(struct controller *ctrl);
41int pciehprm_set_hpp(struct controller *ctrl, struct pci_func *func, u8 card_type);
42void pciehprm_enable_card(struct controller *ctrl, struct pci_func *func, u8 card_type);
43
44#ifdef DEBUG
45#define RES_CHECK(this, bits) \
46 { if (((this) & (bits - 1))) \
47 printk("%s:%d ERR: potential res loss!\n", __FUNCTION__, __LINE__); }
48#else
49#define RES_CHECK(this, bits)
50#endif
51
52#endif /* _PCIEHPRM_H_ */
diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c
index 1406db35b089..ae244e218620 100644
--- a/drivers/pci/hotplug/pciehprm_acpi.c
+++ b/drivers/pci/hotplug/pciehprm_acpi.c
@@ -24,100 +24,20 @@
24 * 24 *
25 */ 25 */
26 26
27#include <linux/config.h>
28#include <linux/module.h> 27#include <linux/module.h>
29#include <linux/kernel.h> 28#include <linux/kernel.h>
30#include <linux/types.h> 29#include <linux/types.h>
31#include <linux/pci.h> 30#include <linux/pci.h>
32#include <linux/init.h>
33#include <linux/acpi.h> 31#include <linux/acpi.h>
34#include <linux/efi.h>
35#include <linux/pci-acpi.h> 32#include <linux/pci-acpi.h>
36#include <asm/uaccess.h>
37#include <asm/system.h>
38#ifdef CONFIG_IA64
39#include <asm/iosapic.h>
40#endif
41#include <acpi/acpi.h>
42#include <acpi/acpi_bus.h> 33#include <acpi/acpi_bus.h>
43#include <acpi/actypes.h> 34#include <acpi/actypes.h>
44#include "pciehp.h" 35#include "pciehp.h"
45#include "pciehprm.h"
46
47#define PCI_MAX_BUS 0x100
48#define ACPI_STA_DEVICE_PRESENT 0x01
49 36
50#define METHOD_NAME__SUN "_SUN" 37#define METHOD_NAME__SUN "_SUN"
51#define METHOD_NAME__HPP "_HPP" 38#define METHOD_NAME__HPP "_HPP"
52#define METHOD_NAME_OSHP "OSHP" 39#define METHOD_NAME_OSHP "OSHP"
53 40
54/* Status code for running acpi method to gain native control */
55#define NC_NOT_RUN 0
56#define OSC_NOT_EXIST 1
57#define OSC_RUN_FAILED 2
58#define OSHP_NOT_EXIST 3
59#define OSHP_RUN_FAILED 4
60#define NC_RUN_SUCCESS 5
61
62#define PHP_RES_BUS 0xA0
63#define PHP_RES_IO 0xA1
64#define PHP_RES_MEM 0xA2
65#define PHP_RES_PMEM 0xA3
66
67#define BRIDGE_TYPE_P2P 0x00
68#define BRIDGE_TYPE_HOST 0x01
69
70/* this should go to drivers/acpi/include/ */
71struct acpi__hpp {
72 u8 cache_line_size;
73 u8 latency_timer;
74 u8 enable_serr;
75 u8 enable_perr;
76};
77
78struct acpi_php_slot {
79 struct acpi_php_slot *next;
80 struct acpi_bridge *bridge;
81 acpi_handle handle;
82 int seg;
83 int bus;
84 int dev;
85 int fun;
86 u32 sun;
87 struct pci_resource *mem_head;
88 struct pci_resource *p_mem_head;
89 struct pci_resource *io_head;
90 struct pci_resource *bus_head;
91 void *slot_ops; /* _STA, _EJx, etc */
92 struct slot *slot;
93}; /* per func */
94
95struct acpi_bridge {
96 struct acpi_bridge *parent;
97 struct acpi_bridge *next;
98 struct acpi_bridge *child;
99 acpi_handle handle;
100 int seg;
101 int pbus; /* pdev->bus->number */
102 int pdevice; /* PCI_SLOT(pdev->devfn) */
103 int pfunction; /* PCI_DEVFN(pdev->devfn) */
104 int bus; /* pdev->subordinate->number */
105 struct acpi__hpp *_hpp;
106 struct acpi_php_slot *slots;
107 struct pci_resource *tmem_head; /* total from crs */
108 struct pci_resource *tp_mem_head; /* total from crs */
109 struct pci_resource *tio_head; /* total from crs */
110 struct pci_resource *tbus_head; /* total from crs */
111 struct pci_resource *mem_head; /* available */
112 struct pci_resource *p_mem_head; /* available */
113 struct pci_resource *io_head; /* available */
114 struct pci_resource *bus_head; /* available */
115 int scanned;
116 int type;
117};
118
119static struct acpi_bridge *acpi_bridges_head;
120
121static u8 * acpi_path_name( acpi_handle handle) 41static u8 * acpi_path_name( acpi_handle handle)
122{ 42{
123 acpi_status status; 43 acpi_status status;
@@ -133,85 +53,43 @@ static u8 * acpi_path_name( acpi_handle handle)
133 return path_name; 53 return path_name;
134} 54}
135 55
136static void acpi_get__hpp ( struct acpi_bridge *ab); 56static acpi_status
137static int acpi_run_oshp ( struct acpi_bridge *ab); 57acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
138static int osc_run_status = NC_NOT_RUN;
139static int oshp_run_status = NC_NOT_RUN;
140
141static int acpi_add_slot_to_php_slots(
142 struct acpi_bridge *ab,
143 int bus_num,
144 acpi_handle handle,
145 u32 adr,
146 u32 sun
147 )
148{
149 struct acpi_php_slot *aps;
150 static long samesun = -1;
151
152 aps = (struct acpi_php_slot *) kmalloc (sizeof(struct acpi_php_slot), GFP_KERNEL);
153 if (!aps) {
154 err ("acpi_pciehprm: alloc for aps fail\n");
155 return -1;
156 }
157 memset(aps, 0, sizeof(struct acpi_php_slot));
158
159 aps->handle = handle;
160 aps->bus = bus_num;
161 aps->dev = (adr >> 16) & 0xffff;
162 aps->fun = adr & 0xffff;
163 aps->sun = sun;
164
165 aps->next = ab->slots; /* cling to the bridge */
166 aps->bridge = ab;
167 ab->slots = aps;
168
169 ab->scanned += 1;
170 if (!ab->_hpp)
171 acpi_get__hpp(ab);
172
173 if (osc_run_status == OSC_NOT_EXIST)
174 oshp_run_status = acpi_run_oshp(ab);
175
176 if (sun != samesun) {
177 info("acpi_pciehprm: Slot sun(%x) at s:b:d:f=0x%02x:%02x:%02x:%02x\n",
178 aps->sun, ab->seg, aps->bus, aps->dev, aps->fun);
179 samesun = sun;
180 }
181 return 0;
182}
183
184static void acpi_get__hpp ( struct acpi_bridge *ab)
185{ 58{
186 acpi_status status; 59 acpi_status status;
187 u8 nui[4]; 60 u8 nui[4];
188 struct acpi_buffer ret_buf = { 0, NULL}; 61 struct acpi_buffer ret_buf = { 0, NULL};
189 union acpi_object *ext_obj, *package; 62 union acpi_object *ext_obj, *package;
190 u8 *path_name = acpi_path_name(ab->handle); 63 u8 *path_name = acpi_path_name(handle);
191 int i, len = 0; 64 int i, len = 0;
192 65
193 /* get _hpp */ 66 /* get _hpp */
194 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf); 67 status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf);
195 switch (status) { 68 switch (status) {
196 case AE_BUFFER_OVERFLOW: 69 case AE_BUFFER_OVERFLOW:
197 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL); 70 ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
198 if (!ret_buf.pointer) { 71 if (!ret_buf.pointer) {
199 err ("acpi_pciehprm:%s alloc for _HPP fail\n", path_name); 72 err ("%s:%s alloc for _HPP fail\n", __FUNCTION__,
200 return; 73 path_name);
74 return AE_NO_MEMORY;
201 } 75 }
202 status = acpi_evaluate_object(ab->handle, METHOD_NAME__HPP, NULL, &ret_buf); 76 status = acpi_evaluate_object(handle, METHOD_NAME__HPP,
77 NULL, &ret_buf);
203 if (ACPI_SUCCESS(status)) 78 if (ACPI_SUCCESS(status))
204 break; 79 break;
205 default: 80 default:
206 if (ACPI_FAILURE(status)) { 81 if (ACPI_FAILURE(status)) {
207 err("acpi_pciehprm:%s _HPP fail=0x%x\n", path_name, status); 82 dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__,
208 return; 83 path_name, status);
84 return status;
209 } 85 }
210 } 86 }
211 87
212 ext_obj = (union acpi_object *) ret_buf.pointer; 88 ext_obj = (union acpi_object *) ret_buf.pointer;
213 if (ext_obj->type != ACPI_TYPE_PACKAGE) { 89 if (ext_obj->type != ACPI_TYPE_PACKAGE) {
214 err ("acpi_pciehprm:%s _HPP obj not a package\n", path_name); 90 err ("%s:%s _HPP obj not a package\n", __FUNCTION__,
91 path_name);
92 status = AE_ERROR;
215 goto free_and_return; 93 goto free_and_return;
216 } 94 }
217 95
@@ -224,1514 +102,153 @@ static void acpi_get__hpp ( struct acpi_bridge *ab)
224 nui[i] = (u8)ext_obj->integer.value; 102 nui[i] = (u8)ext_obj->integer.value;
225 break; 103 break;
226 default: 104 default:
227 err ("acpi_pciehprm:%s _HPP obj type incorrect\n", path_name); 105 err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__,
106 path_name);
107 status = AE_ERROR;
228 goto free_and_return; 108 goto free_and_return;
229 } 109 }
230 } 110 }
231 111
232 ab->_hpp = kmalloc (sizeof (struct acpi__hpp), GFP_KERNEL); 112 hpp->cache_line_size = nui[0];
233 if (!ab->_hpp) { 113 hpp->latency_timer = nui[1];
234 err ("acpi_pciehprm:%s alloc for _HPP failed\n", path_name); 114 hpp->enable_serr = nui[2];
235 goto free_and_return; 115 hpp->enable_perr = nui[3];
236 }
237 memset(ab->_hpp, 0, sizeof(struct acpi__hpp));
238 116
239 ab->_hpp->cache_line_size = nui[0]; 117 dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size);
240 ab->_hpp->latency_timer = nui[1]; 118 dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer);
241 ab->_hpp->enable_serr = nui[2]; 119 dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr);
242 ab->_hpp->enable_perr = nui[3]; 120 dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr);
243
244 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
245 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
246 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
247 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
248 121
249free_and_return: 122free_and_return:
250 kfree(ret_buf.pointer); 123 kfree(ret_buf.pointer);
124 return status;
251} 125}
252 126
253static int acpi_run_oshp ( struct acpi_bridge *ab) 127static acpi_status acpi_run_oshp(acpi_handle handle)
254{ 128{
255 acpi_status status; 129 acpi_status status;
256 u8 *path_name = acpi_path_name(ab->handle); 130 u8 *path_name = acpi_path_name(handle);
257 131
258 /* run OSHP */ 132 /* run OSHP */
259 status = acpi_evaluate_object(ab->handle, METHOD_NAME_OSHP, NULL, NULL); 133 status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL);
260 if (ACPI_FAILURE(status)) { 134 if (ACPI_FAILURE(status)) {
261 err("acpi_pciehprm:%s OSHP fails=0x%x\n", path_name, status); 135 dbg("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name,
262 oshp_run_status = (status == AE_NOT_FOUND) ? OSHP_NOT_EXIST : OSHP_RUN_FAILED; 136 status);
263 } else { 137 } else {
264 oshp_run_status = NC_RUN_SUCCESS; 138 dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name);
265 dbg("acpi_pciehprm:%s OSHP passes =0x%x\n", path_name, status);
266 dbg("acpi_pciehprm:%s oshp_run_status =0x%x\n", path_name, oshp_run_status);
267 }
268 return oshp_run_status;
269}
270
271static acpi_status acpi_evaluate_crs(
272 acpi_handle handle,
273 struct acpi_resource **retbuf
274 )
275{
276 acpi_status status;
277 struct acpi_buffer crsbuf;
278 u8 *path_name = acpi_path_name(handle);
279
280 crsbuf.length = 0;
281 crsbuf.pointer = NULL;
282
283 status = acpi_get_current_resources (handle, &crsbuf);
284
285 switch (status) {
286 case AE_BUFFER_OVERFLOW:
287 break; /* found */
288 case AE_NOT_FOUND:
289 dbg("acpi_pciehprm:%s _CRS not found\n", path_name);
290 return status;
291 default:
292 err ("acpi_pciehprm:%s _CRS fail=0x%x\n", path_name, status);
293 return status;
294 } 139 }
295
296 crsbuf.pointer = kmalloc (crsbuf.length, GFP_KERNEL);
297 if (!crsbuf.pointer) {
298 err ("acpi_pciehprm: alloc %ld bytes for %s _CRS fail\n", (ulong)crsbuf.length, path_name);
299 return AE_NO_MEMORY;
300 }
301
302 status = acpi_get_current_resources (handle, &crsbuf);
303 if (ACPI_FAILURE(status)) {
304 err("acpi_pciehprm: %s _CRS fail=0x%x.\n", path_name, status);
305 kfree(crsbuf.pointer);
306 return status;
307 }
308
309 *retbuf = crsbuf.pointer;
310
311 return status; 140 return status;
312} 141}
313 142
314static void free_pci_resource ( struct pci_resource *aprh) 143static int is_root_bridge(acpi_handle handle)
315{ 144{
316 struct pci_resource *res, *next; 145 acpi_status status;
146 struct acpi_device_info *info;
147 struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
148 int i;
317 149
318 for (res = aprh; res; res = next) { 150 status = acpi_get_object_info(handle, &buffer);
319 next = res->next; 151 if (ACPI_SUCCESS(status)) {
320 kfree(res); 152 info = buffer.pointer;
321 } 153 if ((info->valid & ACPI_VALID_HID) &&
322} 154 !strcmp(PCI_ROOT_HID_STRING,
323 155 info->hardware_id.value)) {
324static void print_pci_resource ( struct pci_resource *aprh) 156 acpi_os_free(buffer.pointer);
325{ 157 return 1;
326 struct pci_resource *res; 158 }
327 159 if (info->valid & ACPI_VALID_CID) {
328 for (res = aprh; res; res = res->next) 160 for (i=0; i < info->compatibility_id.count; i++) {
329 dbg(" base= 0x%x length= 0x%x\n", res->base, res->length); 161 if (!strcmp(PCI_ROOT_HID_STRING,
330} 162 info->compatibility_id.id[i].value)) {
331 163 acpi_os_free(buffer.pointer);
332static void print_slot_resources( struct acpi_php_slot *aps) 164 return 1;
333{ 165 }
334 if (aps->bus_head) { 166 }
335 dbg(" BUS Resources:\n");
336 print_pci_resource (aps->bus_head);
337 }
338
339 if (aps->io_head) {
340 dbg(" IO Resources:\n");
341 print_pci_resource (aps->io_head);
342 }
343
344 if (aps->mem_head) {
345 dbg(" MEM Resources:\n");
346 print_pci_resource (aps->mem_head);
347 }
348
349 if (aps->p_mem_head) {
350 dbg(" PMEM Resources:\n");
351 print_pci_resource (aps->p_mem_head);
352 }
353}
354
355static void print_pci_resources( struct acpi_bridge *ab)
356{
357 if (ab->tbus_head) {
358 dbg(" Total BUS Resources:\n");
359 print_pci_resource (ab->tbus_head);
360 }
361 if (ab->bus_head) {
362 dbg(" BUS Resources:\n");
363 print_pci_resource (ab->bus_head);
364 }
365
366 if (ab->tio_head) {
367 dbg(" Total IO Resources:\n");
368 print_pci_resource (ab->tio_head);
369 }
370 if (ab->io_head) {
371 dbg(" IO Resources:\n");
372 print_pci_resource (ab->io_head);
373 }
374
375 if (ab->tmem_head) {
376 dbg(" Total MEM Resources:\n");
377 print_pci_resource (ab->tmem_head);
378 }
379 if (ab->mem_head) {
380 dbg(" MEM Resources:\n");
381 print_pci_resource (ab->mem_head);
382 }
383
384 if (ab->tp_mem_head) {
385 dbg(" Total PMEM Resources:\n");
386 print_pci_resource (ab->tp_mem_head);
387 }
388 if (ab->p_mem_head) {
389 dbg(" PMEM Resources:\n");
390 print_pci_resource (ab->p_mem_head);
391 }
392 if (ab->_hpp) {
393 dbg(" _HPP: cache_line_size=0x%x\n", ab->_hpp->cache_line_size);
394 dbg(" _HPP: latency timer =0x%x\n", ab->_hpp->latency_timer);
395 dbg(" _HPP: enable SERR =0x%x\n", ab->_hpp->enable_serr);
396 dbg(" _HPP: enable PERR =0x%x\n", ab->_hpp->enable_perr);
397 }
398}
399
400static int pciehprm_delete_resource(
401 struct pci_resource **aprh,
402 ulong base,
403 ulong size)
404{
405 struct pci_resource *res;
406 struct pci_resource *prevnode;
407 struct pci_resource *split_node;
408 ulong tbase;
409
410 pciehp_resource_sort_and_combine(aprh);
411
412 for (res = *aprh; res; res = res->next) {
413 if (res->base > base)
414 continue;
415
416 if ((res->base + res->length) < (base + size))
417 continue;
418
419 if (res->base < base) {
420 tbase = base;
421
422 if ((res->length - (tbase - res->base)) < size)
423 continue;
424
425 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
426 if (!split_node)
427 return -ENOMEM;
428
429 split_node->base = res->base;
430 split_node->length = tbase - res->base;
431 res->base = tbase;
432 res->length -= split_node->length;
433
434 split_node->next = res->next;
435 res->next = split_node;
436 }
437
438 if (res->length >= size) {
439 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
440 if (!split_node)
441 return -ENOMEM;
442
443 split_node->base = res->base + size;
444 split_node->length = res->length - size;
445 res->length = size;
446
447 split_node->next = res->next;
448 res->next = split_node;
449 }
450
451 if (*aprh == res) {
452 *aprh = res->next;
453 } else {
454 prevnode = *aprh;
455 while (prevnode->next != res)
456 prevnode = prevnode->next;
457
458 prevnode->next = res->next;
459 }
460 res->next = NULL;
461 kfree(res);
462 break;
463 }
464
465 return 0;
466}
467
468static int pciehprm_delete_resources(
469 struct pci_resource **aprh,
470 struct pci_resource *this
471 )
472{
473 struct pci_resource *res;
474
475 for (res = this; res; res = res->next)
476 pciehprm_delete_resource(aprh, res->base, res->length);
477
478 return 0;
479}
480
481static int pciehprm_add_resource(
482 struct pci_resource **aprh,
483 ulong base,
484 ulong size)
485{
486 struct pci_resource *res;
487
488 for (res = *aprh; res; res = res->next) {
489 if ((res->base + res->length) == base) {
490 res->length += size;
491 size = 0L;
492 break;
493 } 167 }
494 if (res->next == *aprh)
495 break;
496 } 168 }
497
498 if (size) {
499 res = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
500 if (!res) {
501 err ("acpi_pciehprm: alloc for res fail\n");
502 return -ENOMEM;
503 }
504 memset(res, 0, sizeof (struct pci_resource));
505
506 res->base = base;
507 res->length = size;
508 res->next = *aprh;
509 *aprh = res;
510 }
511
512 return 0; 169 return 0;
513} 170}
514 171
515static int pciehprm_add_resources( 172int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
516 struct pci_resource **aprh,
517 struct pci_resource *this
518 )
519{
520 struct pci_resource *res;
521 int rc = 0;
522
523 for (res = this; res && !rc; res = res->next)
524 rc = pciehprm_add_resource(aprh, res->base, res->length);
525
526 return rc;
527}
528
529static void acpi_parse_io (
530 struct acpi_bridge *ab,
531 union acpi_resource_data *data
532 )
533{ 173{
534 struct acpi_resource_io *dataio; 174 acpi_status status;
535 dataio = (struct acpi_resource_io *) data; 175 acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
536 176 struct pci_dev *pdev = dev;
537 dbg("Io Resource\n"); 177 u8 *path_name;
538 dbg(" %d bit decode\n", ACPI_DECODE_16 == dataio->io_decode ? 16:10); 178 /*
539 dbg(" Range minimum base: %08X\n", dataio->min_base_address); 179 * Per PCI firmware specification, we should run the ACPI _OSC
540 dbg(" Range maximum base: %08X\n", dataio->max_base_address); 180 * method to get control of hotplug hardware before using it.
541 dbg(" Alignment: %08X\n", dataio->alignment); 181 * If an _OSC is missing, we look for an OSHP to do the same thing.
542 dbg(" Range Length: %08X\n", dataio->range_length); 182 * To handle different BIOS behavior, we look for _OSC and OSHP
543} 183 * within the scope of the hotplug controller and its parents, upto
544 184 * the host bridge under which this controller exists.
545static void acpi_parse_fixed_io (
546 struct acpi_bridge *ab,
547 union acpi_resource_data *data
548 )
549{
550 struct acpi_resource_fixed_io *datafio;
551 datafio = (struct acpi_resource_fixed_io *) data;
552
553 dbg("Fixed Io Resource\n");
554 dbg(" Range base address: %08X", datafio->base_address);
555 dbg(" Range length: %08X", datafio->range_length);
556}
557
558static void acpi_parse_address16_32 (
559 struct acpi_bridge *ab,
560 union acpi_resource_data *data,
561 acpi_resource_type id
562 )
563{
564 /*
565 * acpi_resource_address16 == acpi_resource_address32
566 * acpi_resource_address16 *data16 = (acpi_resource_address16 *) data;
567 */ 185 */
568 struct acpi_resource_address32 *data32 = (struct acpi_resource_address32 *) data; 186 while (!handle) {
569 struct pci_resource **aprh, **tprh; 187 /*
570 188 * This hotplug controller was not listed in the ACPI name
571 if (id == ACPI_RSTYPE_ADDRESS16) 189 * space at all. Try to get acpi handle of parent pci bus.
572 dbg("acpi_pciehprm:16-Bit Address Space Resource\n"); 190 */
573 else 191 if (!pdev || !pdev->bus->parent)
574 dbg("acpi_pciehprm:32-Bit Address Space Resource\n");
575
576 switch (data32->resource_type) {
577 case ACPI_MEMORY_RANGE:
578 dbg(" Resource Type: Memory Range\n");
579 aprh = &ab->mem_head;
580 tprh = &ab->tmem_head;
581
582 switch (data32->attribute.memory.cache_attribute) {
583 case ACPI_NON_CACHEABLE_MEMORY:
584 dbg(" Type Specific: Noncacheable memory\n");
585 break;
586 case ACPI_CACHABLE_MEMORY:
587 dbg(" Type Specific: Cacheable memory\n");
588 break;
589 case ACPI_WRITE_COMBINING_MEMORY:
590 dbg(" Type Specific: Write-combining memory\n");
591 break;
592 case ACPI_PREFETCHABLE_MEMORY:
593 aprh = &ab->p_mem_head;
594 dbg(" Type Specific: Prefetchable memory\n");
595 break;
596 default:
597 dbg(" Type Specific: Invalid cache attribute\n");
598 break; 192 break;
599 } 193 dbg("Could not find %s in acpi namespace, trying parent\n",
600 194 pci_name(pdev));
601 dbg(" Type Specific: Read%s\n", ACPI_READ_WRITE_MEMORY == data32->attribute.memory.read_write_attribute ? "/Write":" Only"); 195 if (!pdev->bus->parent->self)
602 break; 196 /* Parent must be a host bridge */
603 197 handle = acpi_get_pci_rootbridge_handle(
604 case ACPI_IO_RANGE: 198 pci_domain_nr(pdev->bus->parent),
605 dbg(" Resource Type: I/O Range\n"); 199 pdev->bus->parent->number);
606 aprh = &ab->io_head; 200 else
607 tprh = &ab->tio_head; 201 handle = DEVICE_ACPI_HANDLE(
608 202 &(pdev->bus->parent->self->dev));
609 switch (data32->attribute.io.range_attribute) { 203 pdev = pdev->bus->parent->self;
610 case ACPI_NON_ISA_ONLY_RANGES: 204 }
611 dbg(" Type Specific: Non-ISA Io Addresses\n"); 205
612 break; 206 while (handle) {
613 case ACPI_ISA_ONLY_RANGES: 207 path_name = acpi_path_name(handle);
614 dbg(" Type Specific: ISA Io Addresses\n"); 208 dbg("Trying to get hotplug control for %s \n", path_name);
615 break; 209 status = pci_osc_control_set(handle,
616 case ACPI_ENTIRE_RANGE: 210 OSC_PCI_EXPRESS_NATIVE_HP_CONTROL);
617 dbg(" Type Specific: ISA and non-ISA Io Addresses\n"); 211 if (status == AE_NOT_FOUND)
618 break; 212 status = acpi_run_oshp(handle);
619 default: 213 if (ACPI_SUCCESS(status)) {
620 dbg(" Type Specific: Invalid range attribute\n"); 214 dbg("Gained control for hotplug HW for pci %s (%s)\n",
215 pci_name(dev), path_name);
216 return 0;
217 }
218 if (is_root_bridge(handle))
621 break; 219 break;
622 } 220 chandle = handle;
623 break; 221 status = acpi_get_parent(chandle, &handle);
624
625 case ACPI_BUS_NUMBER_RANGE:
626 dbg(" Resource Type: Bus Number Range(fixed)\n");
627 /* fixup to be compatible with the rest of php driver */
628 data32->min_address_range++;
629 data32->address_length--;
630 aprh = &ab->bus_head;
631 tprh = &ab->tbus_head;
632 break;
633 default:
634 dbg(" Resource Type: Invalid resource type. Exiting.\n");
635 return;
636 }
637
638 dbg(" Resource %s\n", ACPI_CONSUMER == data32->producer_consumer ? "Consumer":"Producer");
639 dbg(" %s decode\n", ACPI_SUB_DECODE == data32->decode ? "Subtractive":"Positive");
640 dbg(" Min address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->min_address_fixed ? "":"not");
641 dbg(" Max address is %s fixed\n", ACPI_ADDRESS_FIXED == data32->max_address_fixed ? "":"not");
642 dbg(" Granularity: %08X\n", data32->granularity);
643 dbg(" Address range min: %08X\n", data32->min_address_range);
644 dbg(" Address range max: %08X\n", data32->max_address_range);
645 dbg(" Address translation offset: %08X\n", data32->address_translation_offset);
646 dbg(" Address Length: %08X\n", data32->address_length);
647
648 if (0xFF != data32->resource_source.index) {
649 dbg(" Resource Source Index: %X\n", data32->resource_source.index);
650 /* dbg(" Resource Source: %s\n", data32->resource_source.string_ptr); */
651 }
652
653 pciehprm_add_resource(aprh, data32->min_address_range, data32->address_length);
654}
655
656static acpi_status acpi_parse_crs(
657 struct acpi_bridge *ab,
658 struct acpi_resource *crsbuf
659 )
660{
661 acpi_status status = AE_OK;
662 struct acpi_resource *resource = crsbuf;
663 u8 count = 0;
664 u8 done = 0;
665
666 while (!done) {
667 dbg("acpi_pciehprm: PCI bus 0x%x Resource structure %x.\n", ab->bus, count++);
668 switch (resource->id) {
669 case ACPI_RSTYPE_IRQ:
670 dbg("Irq -------- Resource\n");
671 break;
672 case ACPI_RSTYPE_DMA:
673 dbg("DMA -------- Resource\n");
674 break;
675 case ACPI_RSTYPE_START_DPF:
676 dbg("Start DPF -------- Resource\n");
677 break;
678 case ACPI_RSTYPE_END_DPF:
679 dbg("End DPF -------- Resource\n");
680 break;
681 case ACPI_RSTYPE_IO:
682 acpi_parse_io (ab, &resource->data);
683 break;
684 case ACPI_RSTYPE_FIXED_IO:
685 acpi_parse_fixed_io (ab, &resource->data);
686 break;
687 case ACPI_RSTYPE_VENDOR:
688 dbg("Vendor -------- Resource\n");
689 break;
690 case ACPI_RSTYPE_END_TAG:
691 dbg("End_tag -------- Resource\n");
692 done = 1;
693 break;
694 case ACPI_RSTYPE_MEM24:
695 dbg("Mem24 -------- Resource\n");
696 break;
697 case ACPI_RSTYPE_MEM32:
698 dbg("Mem32 -------- Resource\n");
699 break;
700 case ACPI_RSTYPE_FIXED_MEM32:
701 dbg("Fixed Mem32 -------- Resource\n");
702 break;
703 case ACPI_RSTYPE_ADDRESS16:
704 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS16);
705 break;
706 case ACPI_RSTYPE_ADDRESS32:
707 acpi_parse_address16_32(ab, &resource->data, ACPI_RSTYPE_ADDRESS32);
708 break;
709 case ACPI_RSTYPE_ADDRESS64:
710 info("Address64 -------- Resource unparsed\n");
711 break;
712 case ACPI_RSTYPE_EXT_IRQ:
713 dbg("Ext Irq -------- Resource\n");
714 break;
715 default:
716 dbg("Invalid -------- resource type 0x%x\n", resource->id);
717 break;
718 }
719
720 resource = (struct acpi_resource *) ((char *)resource + resource->length);
721 }
722
723 return status;
724}
725
726static acpi_status acpi_get_crs( struct acpi_bridge *ab)
727{
728 acpi_status status;
729 struct acpi_resource *crsbuf;
730
731 status = acpi_evaluate_crs(ab->handle, &crsbuf);
732 if (ACPI_SUCCESS(status)) {
733 status = acpi_parse_crs(ab, crsbuf);
734 kfree(crsbuf);
735
736 pciehp_resource_sort_and_combine(&ab->bus_head);
737 pciehp_resource_sort_and_combine(&ab->io_head);
738 pciehp_resource_sort_and_combine(&ab->mem_head);
739 pciehp_resource_sort_and_combine(&ab->p_mem_head);
740
741 pciehprm_add_resources (&ab->tbus_head, ab->bus_head);
742 pciehprm_add_resources (&ab->tio_head, ab->io_head);
743 pciehprm_add_resources (&ab->tmem_head, ab->mem_head);
744 pciehprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
745 }
746
747 return status;
748}
749
750/* find acpi_bridge downword from ab. */
751static struct acpi_bridge *
752find_acpi_bridge_by_bus(
753 struct acpi_bridge *ab,
754 int seg,
755 int bus /* pdev->subordinate->number */
756 )
757{
758 struct acpi_bridge *lab = NULL;
759
760 if (!ab)
761 return NULL;
762
763 if ((ab->bus == bus) && (ab->seg == seg))
764 return ab;
765
766 if (ab->child)
767 lab = find_acpi_bridge_by_bus(ab->child, seg, bus);
768
769 if (!lab)
770 if (ab->next)
771 lab = find_acpi_bridge_by_bus(ab->next, seg, bus);
772
773 return lab;
774}
775
776/*
777 * Build a device tree of ACPI PCI Bridges
778 */
779static void pciehprm_acpi_register_a_bridge (
780 struct acpi_bridge **head,
781 struct acpi_bridge *pab, /* parent bridge to which child bridge is added */
782 struct acpi_bridge *cab /* child bridge to add */
783 )
784{
785 struct acpi_bridge *lpab;
786 struct acpi_bridge *lcab;
787
788 lpab = find_acpi_bridge_by_bus(*head, pab->seg, pab->bus);
789 if (!lpab) {
790 if (!(pab->type & BRIDGE_TYPE_HOST))
791 warn("PCI parent bridge s:b(%x:%x) not in list.\n", pab->seg, pab->bus);
792 pab->next = *head;
793 *head = pab;
794 lpab = pab;
795 }
796
797 if ((cab->type & BRIDGE_TYPE_HOST) && (pab == cab))
798 return;
799
800 lcab = find_acpi_bridge_by_bus(*head, cab->seg, cab->bus);
801 if (lcab) {
802 if ((pab->bus != lcab->parent->bus) || (lcab->bus != cab->bus))
803 err("PCI child bridge s:b(%x:%x) in list with diff parent.\n", cab->seg, cab->bus);
804 return;
805 } else
806 lcab = cab;
807
808 lcab->parent = lpab;
809 lcab->next = lpab->child;
810 lpab->child = lcab;
811}
812
813static acpi_status pciehprm_acpi_build_php_slots_callback(
814 acpi_handle handle,
815 u32 Level,
816 void *context,
817 void **retval
818 )
819{
820 ulong bus_num;
821 ulong seg_num;
822 ulong sun, adr;
823 ulong padr = 0;
824 acpi_handle phandle = NULL;
825 struct acpi_bridge *pab = (struct acpi_bridge *)context;
826 struct acpi_bridge *lab;
827 acpi_status status;
828 u8 *path_name = acpi_path_name(handle);
829
830 /* get _SUN */
831 status = acpi_evaluate_integer(handle, METHOD_NAME__SUN, NULL, &sun);
832 switch(status) {
833 case AE_NOT_FOUND:
834 return AE_OK;
835 default:
836 if (ACPI_FAILURE(status)) {
837 err("acpi_pciehprm:%s _SUN fail=0x%x\n", path_name, status);
838 return status;
839 }
840 }
841
842 /* get _ADR. _ADR must exist if _SUN exists */
843 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
844 if (ACPI_FAILURE(status)) {
845 err("acpi_pciehprm:%s _ADR fail=0x%x\n", path_name, status);
846 return status;
847 }
848
849 dbg("acpi_pciehprm:%s sun=0x%08x adr=0x%08x\n", path_name, (u32)sun, (u32)adr);
850
851 status = acpi_get_parent(handle, &phandle);
852 if (ACPI_FAILURE(status)) {
853 err("acpi_pciehprm:%s get_parent fail=0x%x\n", path_name, status);
854 return (status);
855 }
856
857 bus_num = pab->bus;
858 seg_num = pab->seg;
859
860 if (pab->bus == bus_num) {
861 lab = pab;
862 } else {
863 dbg("WARN: pab is not parent\n");
864 lab = find_acpi_bridge_by_bus(pab, seg_num, bus_num);
865 if (!lab) {
866 dbg("acpi_pciehprm: alloc new P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
867 lab = (struct acpi_bridge *)kmalloc(sizeof(struct acpi_bridge), GFP_KERNEL);
868 if (!lab) {
869 err("acpi_pciehprm: alloc for ab fail\n");
870 return AE_NO_MEMORY;
871 }
872 memset(lab, 0, sizeof(struct acpi_bridge));
873
874 lab->handle = phandle;
875 lab->pbus = pab->bus;
876 lab->pdevice = (int)(padr >> 16) & 0xffff;
877 lab->pfunction = (int)(padr & 0xffff);
878 lab->bus = (int)bus_num;
879 lab->scanned = 0;
880 lab->type = BRIDGE_TYPE_P2P;
881
882 pciehprm_acpi_register_a_bridge (&acpi_bridges_head, pab, lab);
883 } else
884 dbg("acpi_pciehprm: found P2P bridge(%x) for sun(%08x)\n", (u32)bus_num, (u32)sun);
885 }
886
887 acpi_add_slot_to_php_slots(lab, (int)bus_num, handle, (u32)adr, (u32)sun);
888
889 return (status);
890}
891
892static int pciehprm_acpi_build_php_slots(
893 struct acpi_bridge *ab,
894 u32 depth
895 )
896{
897 acpi_status status;
898 u8 *path_name = acpi_path_name(ab->handle);
899
900 /* Walk down this pci bridge to get _SUNs if any behind P2P */
901 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
902 ab->handle,
903 depth,
904 pciehprm_acpi_build_php_slots_callback,
905 ab,
906 NULL );
907 if (ACPI_FAILURE(status)) {
908 dbg("acpi_pciehprm:%s walk for _SUN on pci bridge seg:bus(%x:%x) fail=0x%x\n", path_name, ab->seg, ab->bus, status);
909 return -1;
910 }
911
912 return 0;
913}
914
915static void build_a_bridge(
916 struct acpi_bridge *pab,
917 struct acpi_bridge *ab
918 )
919{
920 u8 *path_name = acpi_path_name(ab->handle);
921
922 pciehprm_acpi_register_a_bridge (&acpi_bridges_head, pab, ab);
923
924 switch (ab->type) {
925 case BRIDGE_TYPE_HOST:
926 dbg("acpi_pciehprm: Registered PCI HOST Bridge(%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
927 ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
928 break;
929 case BRIDGE_TYPE_P2P:
930 dbg("acpi_pciehprm: Registered PCI P2P Bridge(%02x-%02x) on s:b:d:f(%02x:%02x:%02x:%02x) [%s]\n",
931 ab->pbus, ab->bus, ab->seg, ab->pbus, ab->pdevice, ab->pfunction, path_name);
932 break;
933 };
934
935 /* build any immediate PHP slots under this pci bridge */
936 pciehprm_acpi_build_php_slots(ab, 1);
937}
938
939static struct acpi_bridge * add_p2p_bridge(
940 acpi_handle handle,
941 struct acpi_bridge *pab, /* parent */
942 ulong adr
943 )
944{
945 struct acpi_bridge *ab;
946 struct pci_dev *pdev;
947 ulong devnum, funcnum;
948 u8 *path_name = acpi_path_name(handle);
949
950 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
951 if (!ab) {
952 err("acpi_pciehprm: alloc for ab fail\n");
953 return NULL;
954 }
955 memset(ab, 0, sizeof(struct acpi_bridge));
956
957 devnum = (adr >> 16) & 0xffff;
958 funcnum = adr & 0xffff;
959
960 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
961 if (!pdev || !pdev->subordinate) {
962 err("acpi_pciehprm:%s is not a P2P Bridge\n", path_name);
963 kfree(ab);
964 return NULL;
965 }
966
967 ab->handle = handle;
968 ab->seg = pab->seg;
969 ab->pbus = pab->bus; /* or pdev->bus->number */
970 ab->pdevice = devnum; /* or PCI_SLOT(pdev->devfn) */
971 ab->pfunction = funcnum; /* or PCI_FUNC(pdev->devfn) */
972 ab->bus = pdev->subordinate->number;
973 ab->scanned = 0;
974 ab->type = BRIDGE_TYPE_P2P;
975
976 dbg("acpi_pciehprm: P2P(%x-%x) on pci=b:d:f(%x:%x:%x) acpi=b:d:f(%x:%x:%x) [%s]\n",
977 pab->bus, ab->bus, pdev->bus->number, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
978 pab->bus, (u32)devnum, (u32)funcnum, path_name);
979
980 build_a_bridge(pab, ab);
981
982 return ab;
983}
984
985static acpi_status scan_p2p_bridge(
986 acpi_handle handle,
987 u32 Level,
988 void *context,
989 void **retval
990 )
991{
992 struct acpi_bridge *pab = (struct acpi_bridge *)context;
993 struct acpi_bridge *ab;
994 acpi_status status;
995 ulong adr = 0;
996 u8 *path_name = acpi_path_name(handle);
997 ulong devnum, funcnum;
998 struct pci_dev *pdev;
999
1000 /* get device, function */
1001 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
1002 if (ACPI_FAILURE(status)) {
1003 if (status != AE_NOT_FOUND)
1004 err("acpi_pciehprm:%s _ADR fail=0x%x\n", path_name, status);
1005 return AE_OK;
1006 }
1007
1008 devnum = (adr >> 16) & 0xffff;
1009 funcnum = adr & 0xffff;
1010
1011 pdev = pci_find_slot(pab->bus, PCI_DEVFN(devnum, funcnum));
1012 if (!pdev)
1013 return AE_OK;
1014 if (!pdev->subordinate)
1015 return AE_OK;
1016
1017 ab = add_p2p_bridge(handle, pab, adr);
1018 if (ab) {
1019 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1020 handle,
1021 (u32)1,
1022 scan_p2p_bridge,
1023 ab,
1024 NULL);
1025 if (ACPI_FAILURE(status)) 222 if (ACPI_FAILURE(status))
1026 dbg("acpi_pciehprm:%s find_p2p fail=0x%x\n", path_name, status); 223 break;
1027 }
1028
1029 return AE_OK;
1030}
1031
1032static struct acpi_bridge * add_host_bridge(
1033 acpi_handle handle,
1034 ulong segnum,
1035 ulong busnum
1036 )
1037{
1038 ulong adr = 0;
1039 acpi_status status;
1040 struct acpi_bridge *ab;
1041 u8 *path_name = acpi_path_name(handle);
1042
1043 /* get device, function: host br adr is always 0000 though. */
1044 status = acpi_evaluate_integer(handle, METHOD_NAME__ADR, NULL, &adr);
1045 if (ACPI_FAILURE(status)) {
1046 err("acpi_pciehprm:%s _ADR fail=0x%x\n", path_name, status);
1047 return NULL;
1048 }
1049 dbg("acpi_pciehprm: ROOT PCI seg(0x%x)bus(0x%x)dev(0x%x)func(0x%x) [%s]\n", (u32)segnum,
1050 (u32)busnum, (u32)(adr >> 16) & 0xffff, (u32)adr & 0xffff, path_name);
1051
1052 ab = (struct acpi_bridge *) kmalloc (sizeof(struct acpi_bridge), GFP_KERNEL);
1053 if (!ab) {
1054 err("acpi_pciehprm: alloc for ab fail\n");
1055 return NULL;
1056 }
1057 memset(ab, 0, sizeof(struct acpi_bridge));
1058
1059 ab->handle = handle;
1060 ab->seg = (int)segnum;
1061 ab->bus = ab->pbus = (int)busnum;
1062 ab->pdevice = (int)(adr >> 16) & 0xffff;
1063 ab->pfunction = (int)(adr & 0xffff);
1064 ab->scanned = 0;
1065 ab->type = BRIDGE_TYPE_HOST;
1066
1067 /* get root pci bridge's current resources */
1068 status = acpi_get_crs(ab);
1069 if (ACPI_FAILURE(status)) {
1070 err("acpi_pciehprm:%s evaluate _CRS fail=0x%x\n", path_name, status);
1071 kfree(ab);
1072 return NULL;
1073 }
1074
1075 status = pci_osc_control_set (OSC_PCI_EXPRESS_NATIVE_HP_CONTROL);
1076 if (ACPI_FAILURE(status)) {
1077 err("%s: status %x\n", __FUNCTION__, status);
1078 osc_run_status = (status == AE_NOT_FOUND) ? OSC_NOT_EXIST : OSC_RUN_FAILED;
1079 } else {
1080 osc_run_status = NC_RUN_SUCCESS;
1081 }
1082 dbg("%s: osc_run_status %x\n", __FUNCTION__, osc_run_status);
1083
1084 build_a_bridge(ab, ab);
1085
1086 return ab;
1087}
1088
1089static acpi_status acpi_scan_from_root_pci_callback (
1090 acpi_handle handle,
1091 u32 Level,
1092 void *context,
1093 void **retval
1094 )
1095{
1096 ulong segnum = 0;
1097 ulong busnum = 0;
1098 acpi_status status;
1099 struct acpi_bridge *ab;
1100 u8 *path_name = acpi_path_name(handle);
1101
1102 /* get bus number of this pci root bridge */
1103 status = acpi_evaluate_integer(handle, METHOD_NAME__SEG, NULL, &segnum);
1104 if (ACPI_FAILURE(status)) {
1105 if (status != AE_NOT_FOUND) {
1106 err("acpi_pciehprm:%s evaluate _SEG fail=0x%x\n", path_name, status);
1107 return status;
1108 }
1109 segnum = 0;
1110 }
1111
1112 /* get bus number of this pci root bridge */
1113 status = acpi_evaluate_integer(handle, METHOD_NAME__BBN, NULL, &busnum);
1114 if (ACPI_FAILURE(status)) {
1115 err("acpi_pciehprm:%s evaluate _BBN fail=0x%x\n", path_name, status);
1116 return (status);
1117 }
1118
1119 ab = add_host_bridge(handle, segnum, busnum);
1120 if (ab) {
1121 status = acpi_walk_namespace ( ACPI_TYPE_DEVICE,
1122 handle,
1123 1,
1124 scan_p2p_bridge,
1125 ab,
1126 NULL);
1127 if (ACPI_FAILURE(status))
1128 dbg("acpi_pciehprm:%s find_p2p fail=0x%x\n", path_name, status);
1129 } 224 }
1130 225
1131 return AE_OK; 226 err("Cannot get control of hotplug hardware for pci %s\n",
227 pci_name(dev));
228 return -1;
1132} 229}
1133 230
1134static int pciehprm_acpi_scan_pci (void) 231void pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
232 struct hotplug_params *hpp)
1135{ 233{
1136 acpi_status status; 234 acpi_status status = AE_NOT_FOUND;
235 struct pci_dev *pdev = dev;
1137 236
1138 /* 237 /*
1139 * TBD: traverse LDM device tree with the help of 238 * _HPP settings apply to all child buses, until another _HPP is
1140 * unified ACPI augmented for php device population. 239 * encountered. If we don't find an _HPP for the input pci dev,
240 * look for it in the parent device scope since that would apply to
241 * this pci dev. If we don't find any _HPP, use hardcoded defaults
1141 */ 242 */
1142 status = acpi_get_devices ( PCI_ROOT_HID_STRING, 243 while (pdev && (ACPI_FAILURE(status))) {
1143 acpi_scan_from_root_pci_callback, 244 acpi_handle handle = DEVICE_ACPI_HANDLE(&(pdev->dev));
1144 NULL, 245 if (!handle)
1145 NULL ); 246 break;
1146 if (ACPI_FAILURE(status)) { 247 status = acpi_run_hpp(handle, hpp);
1147 err("acpi_pciehprm:get_device PCI ROOT HID fail=0x%x\n", status); 248 if (!(pdev->bus->parent))
1148 return -1; 249 break;
1149 } 250 /* Check if a parent object supports _HPP */
1150 251 pdev = pdev->bus->parent->self;
1151 return 0;
1152}
1153
1154int pciehprm_init(enum php_ctlr_type ctlr_type)
1155{
1156 int rc;
1157
1158 if (ctlr_type != PCI)
1159 return -ENODEV;
1160
1161 dbg("pciehprm ACPI init <enter>\n");
1162 acpi_bridges_head = NULL;
1163
1164 /* construct PCI bus:device tree of acpi_handles */
1165 rc = pciehprm_acpi_scan_pci();
1166 if (rc)
1167 return rc;
1168
1169 if ((oshp_run_status != NC_RUN_SUCCESS) && (osc_run_status != NC_RUN_SUCCESS)) {
1170 err("Fails to gain control of native hot-plug\n");
1171 rc = -ENODEV;
1172 }
1173
1174 dbg("pciehprm ACPI init %s\n", (rc)?"fail":"success");
1175 return rc;
1176}
1177
1178static void free_a_slot(struct acpi_php_slot *aps)
1179{
1180 dbg(" free a php func of slot(0x%02x) on PCI b:d:f=0x%02x:%02x:%02x\n", aps->sun, aps->bus, aps->dev, aps->fun);
1181
1182 free_pci_resource (aps->io_head);
1183 free_pci_resource (aps->bus_head);
1184 free_pci_resource (aps->mem_head);
1185 free_pci_resource (aps->p_mem_head);
1186
1187 kfree(aps);
1188}
1189
1190static void free_a_bridge( struct acpi_bridge *ab)
1191{
1192 struct acpi_php_slot *aps, *next;
1193
1194 switch (ab->type) {
1195 case BRIDGE_TYPE_HOST:
1196 dbg("Free ACPI PCI HOST Bridge(%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1197 ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1198 break;
1199 case BRIDGE_TYPE_P2P:
1200 dbg("Free ACPI PCI P2P Bridge(%x-%x) [%s] on s:b:d:f(%x:%x:%x:%x)\n",
1201 ab->pbus, ab->bus, acpi_path_name(ab->handle), ab->seg, ab->pbus, ab->pdevice, ab->pfunction);
1202 break;
1203 };
1204
1205 /* free slots first */
1206 for (aps = ab->slots; aps; aps = next) {
1207 next = aps->next;
1208 free_a_slot(aps);
1209 }
1210
1211 free_pci_resource (ab->io_head);
1212 free_pci_resource (ab->tio_head);
1213 free_pci_resource (ab->bus_head);
1214 free_pci_resource (ab->tbus_head);
1215 free_pci_resource (ab->mem_head);
1216 free_pci_resource (ab->tmem_head);
1217 free_pci_resource (ab->p_mem_head);
1218 free_pci_resource (ab->tp_mem_head);
1219
1220 kfree(ab);
1221}
1222
1223static void pciehprm_free_bridges ( struct acpi_bridge *ab)
1224{
1225 if (!ab)
1226 return;
1227
1228 if (ab->child)
1229 pciehprm_free_bridges (ab->child);
1230
1231 if (ab->next)
1232 pciehprm_free_bridges (ab->next);
1233
1234 free_a_bridge(ab);
1235}
1236
1237void pciehprm_cleanup(void)
1238{
1239 pciehprm_free_bridges (acpi_bridges_head);
1240}
1241
1242static int get_number_of_slots (
1243 struct acpi_bridge *ab,
1244 int selfonly
1245 )
1246{
1247 struct acpi_php_slot *aps;
1248 int prev_slot = -1;
1249 int slot_num = 0;
1250
1251 for ( aps = ab->slots; aps; aps = aps->next)
1252 if (aps->dev != prev_slot) {
1253 prev_slot = aps->dev;
1254 slot_num++;
1255 }
1256
1257 if (ab->child)
1258 slot_num += get_number_of_slots (ab->child, 0);
1259
1260 if (selfonly)
1261 return slot_num;
1262
1263 if (ab->next)
1264 slot_num += get_number_of_slots (ab->next, 0);
1265
1266 return slot_num;
1267}
1268
1269static int print_acpi_resources (struct acpi_bridge *ab)
1270{
1271 struct acpi_php_slot *aps;
1272 int i;
1273
1274 switch (ab->type) {
1275 case BRIDGE_TYPE_HOST:
1276 dbg("PCI HOST Bridge (%x) [%s]\n", ab->bus, acpi_path_name(ab->handle));
1277 break;
1278 case BRIDGE_TYPE_P2P:
1279 dbg("PCI P2P Bridge (%x-%x) [%s]\n", ab->pbus, ab->bus, acpi_path_name(ab->handle));
1280 break;
1281 };
1282
1283 print_pci_resources (ab);
1284
1285 for ( i = -1, aps = ab->slots; aps; aps = aps->next) {
1286 if (aps->dev == i)
1287 continue;
1288 dbg(" Slot sun(%x) s:b:d:f(%02x:%02x:%02x:%02x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1289 print_slot_resources(aps);
1290 i = aps->dev;
1291 }
1292
1293 if (ab->child)
1294 print_acpi_resources (ab->child);
1295
1296 if (ab->next)
1297 print_acpi_resources (ab->next);
1298
1299 return 0;
1300}
1301
1302int pciehprm_print_pirt(void)
1303{
1304 dbg("PCIEHPRM ACPI Slots\n");
1305 if (acpi_bridges_head)
1306 print_acpi_resources (acpi_bridges_head);
1307
1308 return 0;
1309}
1310
1311static struct acpi_php_slot * get_acpi_slot (
1312 struct acpi_bridge *ab,
1313 u32 sun
1314 )
1315{
1316 struct acpi_php_slot *aps = NULL;
1317
1318 for ( aps = ab->slots; aps; aps = aps->next)
1319 if (aps->sun == sun)
1320 return aps;
1321
1322 if (!aps && ab->child) {
1323 aps = (struct acpi_php_slot *)get_acpi_slot (ab->child, sun);
1324 if (aps)
1325 return aps;
1326 }
1327
1328 if (!aps && ab->next) {
1329 aps = (struct acpi_php_slot *)get_acpi_slot (ab->next, sun);
1330 if (aps)
1331 return aps;
1332 }
1333
1334 return aps;
1335
1336}
1337
1338#if 0
1339void * pciehprm_get_slot(struct slot *slot)
1340{
1341 struct acpi_bridge *ab = acpi_bridges_head;
1342 struct acpi_php_slot *aps = get_acpi_slot (ab, slot->number);
1343
1344 aps->slot = slot;
1345
1346 dbg("Got acpi slot sun(%x): s:b:d:f(%x:%x:%x:%x)\n", aps->sun, aps->seg, aps->bus, aps->dev, aps->fun);
1347
1348 return (void *)aps;
1349}
1350#endif
1351
1352static void pciehprm_dump_func_res( struct pci_func *fun)
1353{
1354 struct pci_func *func = fun;
1355
1356 if (func->bus_head) {
1357 dbg(": BUS Resources:\n");
1358 print_pci_resource (func->bus_head);
1359 }
1360 if (func->io_head) {
1361 dbg(": IO Resources:\n");
1362 print_pci_resource (func->io_head);
1363 }
1364 if (func->mem_head) {
1365 dbg(": MEM Resources:\n");
1366 print_pci_resource (func->mem_head);
1367 }
1368 if (func->p_mem_head) {
1369 dbg(": PMEM Resources:\n");
1370 print_pci_resource (func->p_mem_head);
1371 }
1372}
1373
1374static void pciehprm_dump_ctrl_res( struct controller *ctlr)
1375{
1376 struct controller *ctrl = ctlr;
1377
1378 if (ctrl->bus_head) {
1379 dbg(": BUS Resources:\n");
1380 print_pci_resource (ctrl->bus_head);
1381 }
1382 if (ctrl->io_head) {
1383 dbg(": IO Resources:\n");
1384 print_pci_resource (ctrl->io_head);
1385 }
1386 if (ctrl->mem_head) {
1387 dbg(": MEM Resources:\n");
1388 print_pci_resource (ctrl->mem_head);
1389 }
1390 if (ctrl->p_mem_head) {
1391 dbg(": PMEM Resources:\n");
1392 print_pci_resource (ctrl->p_mem_head);
1393 }
1394}
1395
1396static int pciehprm_get_used_resources (
1397 struct controller *ctrl,
1398 struct pci_func *func
1399 )
1400{
1401 return pciehp_save_used_resources (ctrl, func, !DISABLE_CARD);
1402}
1403
1404static int configure_existing_function(
1405 struct controller *ctrl,
1406 struct pci_func *func
1407 )
1408{
1409 int rc;
1410
1411 /* see how much resources the func has used. */
1412 rc = pciehprm_get_used_resources (ctrl, func);
1413
1414 if (!rc) {
1415 /* subtract the resources used by the func from ctrl resources */
1416 rc = pciehprm_delete_resources (&ctrl->bus_head, func->bus_head);
1417 rc |= pciehprm_delete_resources (&ctrl->io_head, func->io_head);
1418 rc |= pciehprm_delete_resources (&ctrl->mem_head, func->mem_head);
1419 rc |= pciehprm_delete_resources (&ctrl->p_mem_head, func->p_mem_head);
1420 if (rc)
1421 warn("aCEF: cannot del used resources\n");
1422 } else
1423 err("aCEF: cannot get used resources\n");
1424
1425 return rc;
1426}
1427
1428static int bind_pci_resources_to_slots ( struct controller *ctrl)
1429{
1430 struct pci_func *func, new_func;
1431 int busn = ctrl->slot_bus;
1432 int devn, funn;
1433 u32 vid;
1434
1435 for (devn = 0; devn < 32; devn++) {
1436 for (funn = 0; funn < 8; funn++) {
1437 /*
1438 if (devn == ctrl->device && funn == ctrl->function)
1439 continue;
1440 */
1441 /* find out if this entry is for an occupied slot */
1442 vid = 0xFFFFFFFF;
1443 pci_bus_read_config_dword(ctrl->pci_dev->subordinate, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
1444
1445 if (vid != 0xFFFFFFFF) {
1446 dbg("%s: vid = %x\n", __FUNCTION__, vid);
1447 func = pciehp_slot_find(busn, devn, funn);
1448 if (!func) {
1449 memset(&new_func, 0, sizeof(struct pci_func));
1450 new_func.bus = busn;
1451 new_func.device = devn;
1452 new_func.function = funn;
1453 new_func.is_a_board = 1;
1454 configure_existing_function(ctrl, &new_func);
1455 pciehprm_dump_func_res(&new_func);
1456 } else {
1457 configure_existing_function(ctrl, func);
1458 pciehprm_dump_func_res(func);
1459 }
1460 dbg("aCCF:existing PCI 0x%x Func ResourceDump\n", ctrl->bus);
1461 }
1462 }
1463 }
1464
1465 return 0;
1466}
1467
1468static int bind_pci_resources(
1469 struct controller *ctrl,
1470 struct acpi_bridge *ab
1471 )
1472{
1473 int status = 0;
1474
1475 if (ab->bus_head) {
1476 dbg("bapr: BUS Resources add on PCI 0x%x\n", ab->bus);
1477 status = pciehprm_add_resources (&ctrl->bus_head, ab->bus_head);
1478 if (pciehprm_delete_resources (&ab->bus_head, ctrl->bus_head))
1479 warn("bapr: cannot sub BUS Resource on PCI 0x%x\n", ab->bus);
1480 if (status) {
1481 err("bapr: BUS Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1482 return status;
1483 }
1484 } else
1485 info("bapr: No BUS Resource on PCI 0x%x.\n", ab->bus);
1486
1487 if (ab->io_head) {
1488 dbg("bapr: IO Resources add on PCI 0x%x\n", ab->bus);
1489 status = pciehprm_add_resources (&ctrl->io_head, ab->io_head);
1490 if (pciehprm_delete_resources (&ab->io_head, ctrl->io_head))
1491 warn("bapr: cannot sub IO Resource on PCI 0x%x\n", ab->bus);
1492 if (status) {
1493 err("bapr: IO Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1494 return status;
1495 }
1496 } else
1497 info("bapr: No IO Resource on PCI 0x%x.\n", ab->bus);
1498
1499 if (ab->mem_head) {
1500 dbg("bapr: MEM Resources add on PCI 0x%x\n", ab->bus);
1501 status = pciehprm_add_resources (&ctrl->mem_head, ab->mem_head);
1502 if (pciehprm_delete_resources (&ab->mem_head, ctrl->mem_head))
1503 warn("bapr: cannot sub MEM Resource on PCI 0x%x\n", ab->bus);
1504 if (status) {
1505 err("bapr: MEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1506 return status;
1507 }
1508 } else
1509 info("bapr: No MEM Resource on PCI 0x%x.\n", ab->bus);
1510
1511 if (ab->p_mem_head) {
1512 dbg("bapr: PMEM Resources add on PCI 0x%x\n", ab->bus);
1513 status = pciehprm_add_resources (&ctrl->p_mem_head, ab->p_mem_head);
1514 if (pciehprm_delete_resources (&ab->p_mem_head, ctrl->p_mem_head))
1515 warn("bapr: cannot sub PMEM Resource on PCI 0x%x\n", ab->bus);
1516 if (status) {
1517 err("bapr: PMEM Resource add on PCI 0x%x: fail=0x%x\n", ab->bus, status);
1518 return status;
1519 }
1520 } else
1521 info("bapr: No PMEM Resource on PCI 0x%x.\n", ab->bus);
1522
1523 return status;
1524}
1525
1526static int no_pci_resources( struct acpi_bridge *ab)
1527{
1528 return !(ab->p_mem_head || ab->mem_head || ab->io_head || ab->bus_head);
1529}
1530
1531static int find_pci_bridge_resources (
1532 struct controller *ctrl,
1533 struct acpi_bridge *ab
1534 )
1535{
1536 int rc = 0;
1537 struct pci_func func;
1538
1539 memset(&func, 0, sizeof(struct pci_func));
1540
1541 func.bus = ab->pbus;
1542 func.device = ab->pdevice;
1543 func.function = ab->pfunction;
1544 func.is_a_board = 1;
1545
1546 /* Get used resources for this PCI bridge */
1547 rc = pciehp_save_used_resources (ctrl, &func, !DISABLE_CARD);
1548
1549 ab->io_head = func.io_head;
1550 ab->mem_head = func.mem_head;
1551 ab->p_mem_head = func.p_mem_head;
1552 ab->bus_head = func.bus_head;
1553 if (ab->bus_head)
1554 pciehprm_delete_resource(&ab->bus_head, ctrl->pci_dev->subordinate->number, 1);
1555
1556 return rc;
1557}
1558
1559static int get_pci_resources_from_bridge(
1560 struct controller *ctrl,
1561 struct acpi_bridge *ab
1562 )
1563{
1564 int rc = 0;
1565
1566 dbg("grfb: Get Resources for PCI 0x%x from actual PCI bridge 0x%x.\n", ctrl->bus, ab->bus);
1567
1568 rc = find_pci_bridge_resources (ctrl, ab);
1569
1570 pciehp_resource_sort_and_combine(&ab->bus_head);
1571 pciehp_resource_sort_and_combine(&ab->io_head);
1572 pciehp_resource_sort_and_combine(&ab->mem_head);
1573 pciehp_resource_sort_and_combine(&ab->p_mem_head);
1574
1575 pciehprm_add_resources (&ab->tbus_head, ab->bus_head);
1576 pciehprm_add_resources (&ab->tio_head, ab->io_head);
1577 pciehprm_add_resources (&ab->tmem_head, ab->mem_head);
1578 pciehprm_add_resources (&ab->tp_mem_head, ab->p_mem_head);
1579
1580 return rc;
1581}
1582
1583static int get_pci_resources(
1584 struct controller *ctrl,
1585 struct acpi_bridge *ab
1586 )
1587{
1588 int rc = 0;
1589
1590 if (no_pci_resources(ab)) {
1591 dbg("spbr:PCI 0x%x has no resources. Get parent resources.\n", ab->bus);
1592 rc = get_pci_resources_from_bridge(ctrl, ab);
1593 }
1594
1595 return rc;
1596}
1597
1598/*
1599 * Get resources for this ctrl.
1600 * 1. get total resources from ACPI _CRS or bridge (this ctrl)
1601 * 2. find used resources of existing adapters
1602 * 3. subtract used resources from total resources
1603 */
1604int pciehprm_find_available_resources( struct controller *ctrl)
1605{
1606 int rc = 0;
1607 struct acpi_bridge *ab;
1608
1609 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->pci_dev->subordinate->number);
1610 if (!ab) {
1611 err("pfar:cannot locate acpi bridge of PCI 0x%x.\n", ctrl->pci_dev->subordinate->number);
1612 return -1;
1613 }
1614 if (no_pci_resources(ab)) {
1615 rc = get_pci_resources(ctrl, ab);
1616 if (rc) {
1617 err("pfar:cannot get pci resources of PCI 0x%x.\n", ctrl->pci_dev->subordinate->number);
1618 return -1;
1619 }
1620 }
1621
1622 rc = bind_pci_resources(ctrl, ab);
1623 dbg("pfar:pre-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1624 pciehprm_dump_ctrl_res(ctrl);
1625
1626 bind_pci_resources_to_slots (ctrl);
1627
1628 dbg("pfar:post-Bind PCI 0x%x Ctrl Resource Dump\n", ctrl->pci_dev->subordinate->number);
1629 pciehprm_dump_ctrl_res(ctrl);
1630
1631 return rc;
1632}
1633
1634int pciehprm_set_hpp(
1635 struct controller *ctrl,
1636 struct pci_func *func,
1637 u8 card_type
1638 )
1639{
1640 struct acpi_bridge *ab;
1641 struct pci_bus lpci_bus, *pci_bus;
1642 int rc = 0;
1643 unsigned int devfn;
1644 u8 cls= 0x08; /* default cache line size */
1645 u8 lt = 0x40; /* default latency timer */
1646 u8 ep = 0;
1647 u8 es = 0;
1648
1649 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1650 pci_bus = &lpci_bus;
1651 pci_bus->number = func->bus;
1652 devfn = PCI_DEVFN(func->device, func->function);
1653
1654 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus);
1655
1656 if (ab) {
1657 if (ab->_hpp) {
1658 lt = (u8)ab->_hpp->latency_timer;
1659 cls = (u8)ab->_hpp->cache_line_size;
1660 ep = (u8)ab->_hpp->enable_perr;
1661 es = (u8)ab->_hpp->enable_serr;
1662 } else
1663 dbg("_hpp: no _hpp for B/D/F=%#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1664 } else
1665 dbg("_hpp: no acpi bridge for B/D/F = %#x/%#x/%#x. use default value\n", func->bus, func->device, func->function);
1666
1667
1668 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1669 /* set subordinate Latency Timer */
1670 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, lt);
1671 } 252 }
1672
1673 /* set base Latency Timer */
1674 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_LATENCY_TIMER, lt);
1675 dbg(" set latency timer =0x%02x: %x\n", lt, rc);
1676
1677 rc |= pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, cls);
1678 dbg(" set cache_line_size=0x%02x: %x\n", cls, rc);
1679
1680 return rc;
1681} 253}
1682 254
1683void pciehprm_enable_card(
1684 struct controller *ctrl,
1685 struct pci_func *func,
1686 u8 card_type)
1687{
1688 u16 command, cmd, bcommand, bcmd;
1689 struct pci_bus lpci_bus, *pci_bus;
1690 struct acpi_bridge *ab;
1691 unsigned int devfn;
1692 int rc;
1693
1694 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
1695 pci_bus = &lpci_bus;
1696 pci_bus->number = func->bus;
1697 devfn = PCI_DEVFN(func->device, func->function);
1698
1699 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &cmd);
1700
1701 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
1702 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcmd);
1703 }
1704
1705 command = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
1706 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
1707 bcommand = bcmd | PCI_BRIDGE_CTL_NO_ISA;
1708
1709 ab = find_acpi_bridge_by_bus(acpi_bridges_head, ctrl->seg, ctrl->bus);
1710 if (ab) {
1711 if (ab->_hpp) {
1712 if (ab->_hpp->enable_perr) {
1713 command |= PCI_COMMAND_PARITY;
1714 bcommand |= PCI_BRIDGE_CTL_PARITY;
1715 } else {
1716 command &= ~PCI_COMMAND_PARITY;
1717 bcommand &= ~PCI_BRIDGE_CTL_PARITY;
1718 }
1719 if (ab->_hpp->enable_serr) {
1720 command |= PCI_COMMAND_SERR;
1721 bcommand |= PCI_BRIDGE_CTL_SERR;
1722 } else {
1723 command &= ~PCI_COMMAND_SERR;
1724 bcommand &= ~PCI_BRIDGE_CTL_SERR;
1725 }
1726 } else
1727 dbg("no _hpp for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1728 } else
1729 dbg("no acpi bridge for B/D/F = %#x/%#x/%#x.\n", func->bus, func->device, func->function);
1730
1731 if (command != cmd) {
1732 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
1733 }
1734 if ((card_type == PCI_HEADER_TYPE_BRIDGE) && (bcommand != bcmd)) {
1735 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, bcommand);
1736 }
1737}
diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.c b/drivers/pci/hotplug/pciehprm_nonacpi.c
index 76c727c74cc0..29180dfe8493 100644
--- a/drivers/pci/hotplug/pciehprm_nonacpi.c
+++ b/drivers/pci/hotplug/pciehprm_nonacpi.c
@@ -27,479 +27,21 @@
27 * 27 *
28 */ 28 */
29 29
30#include <linux/config.h>
31#include <linux/module.h> 30#include <linux/module.h>
32#include <linux/kernel.h> 31#include <linux/kernel.h>
33#include <linux/types.h> 32#include <linux/types.h>
34#include <linux/sched.h> 33#include <linux/sched.h>
35#include <linux/pci.h> 34#include <linux/pci.h>
36#include <linux/init.h>
37#include <linux/slab.h> 35#include <linux/slab.h>
38
39#include <asm/uaccess.h>
40#ifdef CONFIG_IA64
41#include <asm/iosapic.h>
42#endif
43
44#include "pciehp.h" 36#include "pciehp.h"
45#include "pciehprm.h"
46#include "pciehprm_nonacpi.h"
47
48 37
49void pciehprm_cleanup(void) 38void pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
39 struct hotplug_params *hpp)
50{ 40{
51 return; 41 return;
52} 42}
53 43
54int pciehprm_print_pirt(void) 44int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
55{
56 return 0;
57}
58
59int pciehprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
60{
61
62 *sun = (u8) (ctrl->first_slot);
63 return 0;
64}
65
66
67static void print_pci_resource ( struct pci_resource *aprh)
68{
69 struct pci_resource *res;
70
71 for (res = aprh; res; res = res->next)
72 dbg(" base= 0x%x length= 0x%x\n", res->base, res->length);
73}
74
75
76static void phprm_dump_func_res( struct pci_func *fun)
77{
78 struct pci_func *func = fun;
79
80 if (func->bus_head) {
81 dbg(": BUS Resources:\n");
82 print_pci_resource (func->bus_head);
83 }
84 if (func->io_head) {
85 dbg(": IO Resources:\n");
86 print_pci_resource (func->io_head);
87 }
88 if (func->mem_head) {
89 dbg(": MEM Resources:\n");
90 print_pci_resource (func->mem_head);
91 }
92 if (func->p_mem_head) {
93 dbg(": PMEM Resources:\n");
94 print_pci_resource (func->p_mem_head);
95 }
96}
97
98static int phprm_get_used_resources (
99 struct controller *ctrl,
100 struct pci_func *func
101 )
102{
103 return pciehp_save_used_resources (ctrl, func, !DISABLE_CARD);
104}
105
106static int phprm_delete_resource(
107 struct pci_resource **aprh,
108 ulong base,
109 ulong size)
110{
111 struct pci_resource *res;
112 struct pci_resource *prevnode;
113 struct pci_resource *split_node;
114 ulong tbase;
115
116 pciehp_resource_sort_and_combine(aprh);
117
118 for (res = *aprh; res; res = res->next) {
119 if (res->base > base)
120 continue;
121
122 if ((res->base + res->length) < (base + size))
123 continue;
124
125 if (res->base < base) {
126 tbase = base;
127
128 if ((res->length - (tbase - res->base)) < size)
129 continue;
130
131 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
132 if (!split_node)
133 return -ENOMEM;
134
135 split_node->base = res->base;
136 split_node->length = tbase - res->base;
137 res->base = tbase;
138 res->length -= split_node->length;
139
140 split_node->next = res->next;
141 res->next = split_node;
142 }
143
144 if (res->length >= size) {
145 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
146 if (!split_node)
147 return -ENOMEM;
148
149 split_node->base = res->base + size;
150 split_node->length = res->length - size;
151 res->length = size;
152
153 split_node->next = res->next;
154 res->next = split_node;
155 }
156
157 if (*aprh == res) {
158 *aprh = res->next;
159 } else {
160 prevnode = *aprh;
161 while (prevnode->next != res)
162 prevnode = prevnode->next;
163
164 prevnode->next = res->next;
165 }
166 res->next = NULL;
167 kfree(res);
168 break;
169 }
170
171 return 0;
172}
173
174
175static int phprm_delete_resources(
176 struct pci_resource **aprh,
177 struct pci_resource *this
178 )
179{
180 struct pci_resource *res;
181
182 for (res = this; res; res = res->next)
183 phprm_delete_resource(aprh, res->base, res->length);
184
185 return 0;
186}
187
188
189static int configure_existing_function(
190 struct controller *ctrl,
191 struct pci_func *func
192 )
193{
194 int rc;
195
196 /* see how much resources the func has used. */
197 rc = phprm_get_used_resources (ctrl, func);
198
199 if (!rc) {
200 /* subtract the resources used by the func from ctrl resources */
201 rc = phprm_delete_resources (&ctrl->bus_head, func->bus_head);
202 rc |= phprm_delete_resources (&ctrl->io_head, func->io_head);
203 rc |= phprm_delete_resources (&ctrl->mem_head, func->mem_head);
204 rc |= phprm_delete_resources (&ctrl->p_mem_head, func->p_mem_head);
205 if (rc)
206 warn("aCEF: cannot del used resources\n");
207 } else
208 err("aCEF: cannot get used resources\n");
209
210 return rc;
211}
212
213static int pciehprm_delete_resource(
214 struct pci_resource **aprh,
215 ulong base,
216 ulong size)
217{
218 struct pci_resource *res;
219 struct pci_resource *prevnode;
220 struct pci_resource *split_node;
221 ulong tbase;
222
223 pciehp_resource_sort_and_combine(aprh);
224
225 for (res = *aprh; res; res = res->next) {
226 if (res->base > base)
227 continue;
228
229 if ((res->base + res->length) < (base + size))
230 continue;
231
232 if (res->base < base) {
233 tbase = base;
234
235 if ((res->length - (tbase - res->base)) < size)
236 continue;
237
238 split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
239 if (!split_node)
240 return -ENOMEM;
241
242 split_node->base = res->base;
243 split_node->length = tbase - res->base;
244 res->base = tbase;
245 res->length -= split_node->length;
246
247 split_node->next = res->next;
248 res->next = split_node;
249 }
250
251 if (res->length >= size) {
252 split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
253 if (!split_node)
254 return -ENOMEM;
255
256 split_node->base = res->base + size;
257 split_node->length = res->length - size;
258 res->length = size;
259
260 split_node->next = res->next;
261 res->next = split_node;
262 }
263
264 if (*aprh == res) {
265 *aprh = res->next;
266 } else {
267 prevnode = *aprh;
268 while (prevnode->next != res)
269 prevnode = prevnode->next;
270
271 prevnode->next = res->next;
272 }
273 res->next = NULL;
274 kfree(res);
275 break;
276 }
277
278 return 0;
279}
280
281static int bind_pci_resources_to_slots ( struct controller *ctrl)
282{ 45{
283 struct pci_func *func, new_func;
284 int busn = ctrl->slot_bus;
285 int devn, funn;
286 u32 vid;
287
288 for (devn = 0; devn < 32; devn++) {
289 for (funn = 0; funn < 8; funn++) {
290 /*
291 if (devn == ctrl->device && funn == ctrl->function)
292 continue;
293 */
294 /* find out if this entry is for an occupied slot */
295 vid = 0xFFFFFFFF;
296
297 pci_bus_read_config_dword(ctrl->pci_dev->subordinate, PCI_DEVFN(devn, funn), PCI_VENDOR_ID, &vid);
298
299 if (vid != 0xFFFFFFFF) {
300 dbg("%s: vid = %x bus %x dev %x fun %x\n", __FUNCTION__,
301 vid, busn, devn, funn);
302 func = pciehp_slot_find(busn, devn, funn);
303 dbg("%s: func = %p\n", __FUNCTION__,func);
304 if (!func) {
305 memset(&new_func, 0, sizeof(struct pci_func));
306 new_func.bus = busn;
307 new_func.device = devn;
308 new_func.function = funn;
309 new_func.is_a_board = 1;
310 configure_existing_function(ctrl, &new_func);
311 phprm_dump_func_res(&new_func);
312 } else {
313 configure_existing_function(ctrl, func);
314 phprm_dump_func_res(func);
315 }
316 dbg("aCCF:existing PCI 0x%x Func ResourceDump\n", ctrl->bus);
317 }
318 }
319 }
320
321 return 0; 46 return 0;
322} 47}
323
324static void phprm_dump_ctrl_res( struct controller *ctlr)
325{
326 struct controller *ctrl = ctlr;
327
328 if (ctrl->bus_head) {
329 dbg(": BUS Resources:\n");
330 print_pci_resource (ctrl->bus_head);
331 }
332 if (ctrl->io_head) {
333 dbg(": IO Resources:\n");
334 print_pci_resource (ctrl->io_head);
335 }
336 if (ctrl->mem_head) {
337 dbg(": MEM Resources:\n");
338 print_pci_resource (ctrl->mem_head);
339 }
340 if (ctrl->p_mem_head) {
341 dbg(": PMEM Resources:\n");
342 print_pci_resource (ctrl->p_mem_head);
343 }
344}
345
346/*
347 * phprm_find_available_resources
348 *
349 * Finds available memory, IO, and IRQ resources for programming
350 * devices which may be added to the system
351 * this function is for hot plug ADD!
352 *
353 * returns 0 if success
354 */
355int pciehprm_find_available_resources(struct controller *ctrl)
356{
357 struct pci_func func;
358 u32 rc;
359
360 memset(&func, 0, sizeof(struct pci_func));
361
362 func.bus = ctrl->bus;
363 func.device = ctrl->device;
364 func.function = ctrl->function;
365 func.is_a_board = 1;
366
367 /* Get resources for this PCI bridge */
368 rc = pciehp_save_used_resources (ctrl, &func, !DISABLE_CARD);
369 dbg("%s: pciehp_save_used_resources rc = %d\n", __FUNCTION__, rc);
370
371 if (func.mem_head)
372 func.mem_head->next = ctrl->mem_head;
373 ctrl->mem_head = func.mem_head;
374
375 if (func.p_mem_head)
376 func.p_mem_head->next = ctrl->p_mem_head;
377 ctrl->p_mem_head = func.p_mem_head;
378
379 if (func.io_head)
380 func.io_head->next = ctrl->io_head;
381 ctrl->io_head = func.io_head;
382
383 if(func.bus_head)
384 func.bus_head->next = ctrl->bus_head;
385 ctrl->bus_head = func.bus_head;
386
387 if (ctrl->bus_head)
388 pciehprm_delete_resource(&ctrl->bus_head, ctrl->pci_dev->subordinate->number, 1);
389
390 dbg("%s:pre-Bind PCI 0x%x Ctrl Resource Dump\n", __FUNCTION__, ctrl->bus);
391 phprm_dump_ctrl_res(ctrl);
392
393 dbg("%s: before bind_pci_resources_to slots\n", __FUNCTION__);
394
395 bind_pci_resources_to_slots (ctrl);
396
397 dbg("%s:post-Bind PCI 0x%x Ctrl Resource Dump\n", __FUNCTION__, ctrl->bus);
398 phprm_dump_ctrl_res(ctrl);
399
400 return (rc);
401}
402
403int pciehprm_set_hpp(
404 struct controller *ctrl,
405 struct pci_func *func,
406 u8 card_type)
407{
408 u32 rc;
409 u8 temp_byte;
410 struct pci_bus lpci_bus, *pci_bus;
411 unsigned int devfn;
412 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
413 pci_bus = &lpci_bus;
414 pci_bus->number = func->bus;
415 devfn = PCI_DEVFN(func->device, func->function);
416
417 temp_byte = 0x40; /* hard coded value for LT */
418 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
419 /* set subordinate Latency Timer */
420 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_SEC_LATENCY_TIMER, temp_byte);
421
422 if (rc) {
423 dbg("%s: set secondary LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__,
424 func->bus, func->device, func->function);
425 return rc;
426 }
427 }
428
429 /* set base Latency Timer */
430 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_LATENCY_TIMER, temp_byte);
431
432 if (rc) {
433 dbg("%s: set LT error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus, func->device, func->function);
434 return rc;
435 }
436
437 /* set Cache Line size */
438 temp_byte = 0x08; /* hard coded value for CLS */
439
440 rc = pci_bus_write_config_byte(pci_bus, devfn, PCI_CACHE_LINE_SIZE, temp_byte);
441
442 if (rc) {
443 dbg("%s: set CLS error. b:d:f(%02x:%02x:%02x)\n", __FUNCTION__, func->bus, func->device, func->function);
444 }
445
446 /* set enable_perr */
447 /* set enable_serr */
448
449 return rc;
450}
451
452void pciehprm_enable_card(
453 struct controller *ctrl,
454 struct pci_func *func,
455 u8 card_type)
456{
457 u16 command, bcommand;
458 struct pci_bus lpci_bus, *pci_bus;
459 unsigned int devfn;
460 int rc;
461
462 memcpy(&lpci_bus, ctrl->pci_bus, sizeof(lpci_bus));
463 pci_bus = &lpci_bus;
464 pci_bus->number = func->bus;
465 devfn = PCI_DEVFN(func->device, func->function);
466
467 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_COMMAND, &command);
468
469 command |= PCI_COMMAND_PARITY | PCI_COMMAND_SERR
470 | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE
471 | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
472
473 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_COMMAND, command);
474
475 if (card_type == PCI_HEADER_TYPE_BRIDGE) {
476
477 rc = pci_bus_read_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, &bcommand);
478
479 bcommand |= PCI_BRIDGE_CTL_PARITY | PCI_BRIDGE_CTL_SERR
480 | PCI_BRIDGE_CTL_NO_ISA;
481
482 rc = pci_bus_write_config_word(pci_bus, devfn, PCI_BRIDGE_CONTROL, bcommand);
483 }
484}
485
486static int legacy_pciehprm_init_pci(void)
487{
488 return 0;
489}
490
491int pciehprm_init(enum php_ctlr_type ctrl_type)
492{
493 int retval;
494
495 switch (ctrl_type) {
496 case PCI:
497 retval = legacy_pciehprm_init_pci();
498 break;
499 default:
500 retval = -ENODEV;
501 break;
502 }
503
504 return retval;
505}
diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.h b/drivers/pci/hotplug/pciehprm_nonacpi.h
deleted file mode 100644
index b10603b0e958..000000000000
--- a/drivers/pci/hotplug/pciehprm_nonacpi.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * PCIEHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform
3 *
4 * Copyright (C) 1995,2001 Compaq Computer Corporation
5 * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
6 * Copyright (C) 2001 IBM Corp.
7 * Copyright (C) 2003-2004 Intel Corporation
8 *
9 * All rights reserved.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
19 * NON INFRINGEMENT. See the GNU General Public License for more
20 * details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 *
26 * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
27 *
28 */
29
30#ifndef _PCIEHPRM_NONACPI_H_
31#define _PCIEHPRM_NONACPI_H_
32
33struct irq_info {
34 u8 bus, devfn; /* bus, device and function */
35 struct {
36 u8 link; /* IRQ line ID, chipset dependent, 0=not routed */
37 u16 bitmap; /* Available IRQs */
38 } __attribute__ ((packed)) irq[4];
39 u8 slot; /* slot number, 0=onboard */
40 u8 rfu;
41} __attribute__ ((packed));
42
43struct irq_routing_table {
44 u32 signature; /* PIRQ_SIGNATURE should be here */
45 u16 version; /* PIRQ_VERSION */
46 u16 size; /* Table size in bytes */
47 u8 rtr_bus, rtr_devfn; /* Where the interrupt router lies */
48 u16 exclusive_irqs; /* IRQs devoted exclusively to PCI usage */
49 u16 rtr_vendor, rtr_device; /* Vendor and device ID of interrupt router */
50 u32 miniport_data; /* Crap */
51 u8 rfu[11];
52 u8 checksum; /* Modulo 256 checksum must give zero */
53 struct irq_info slots[0];
54} __attribute__ ((packed));
55
56#endif /* _PCIEHPRM_NONACPI_H_ */
diff --git a/drivers/pci/hotplug/rpadlpar_core.c b/drivers/pci/hotplug/rpadlpar_core.c
index fcb66b9a0e28..cc03609f45d0 100644
--- a/drivers/pci/hotplug/rpadlpar_core.c
+++ b/drivers/pci/hotplug/rpadlpar_core.c
@@ -134,43 +134,6 @@ static void rpadlpar_claim_one_bus(struct pci_bus *b)
134 rpadlpar_claim_one_bus(child_bus); 134 rpadlpar_claim_one_bus(child_bus);
135} 135}
136 136
137static int pci_add_secondary_bus(struct device_node *dn,
138 struct pci_dev *bridge_dev)
139{
140 struct pci_dn *pdn = dn->data;
141 struct pci_controller *hose = pdn->phb;
142 struct pci_bus *child;
143 u8 sec_busno;
144
145 /* Get busno of downstream bus */
146 pci_read_config_byte(bridge_dev, PCI_SECONDARY_BUS, &sec_busno);
147
148 /* Allocate and add to children of bridge_dev->bus */
149 child = pci_add_new_bus(bridge_dev->bus, bridge_dev, sec_busno);
150 if (!child) {
151 printk(KERN_ERR "%s: could not add secondary bus\n", __FUNCTION__);
152 return -ENOMEM;
153 }
154
155 sprintf(child->name, "PCI Bus #%02x", child->number);
156
157 /* Fixup subordinate bridge bases and resources */
158 pcibios_fixup_bus(child);
159
160 /* Claim new bus resources */
161 rpadlpar_claim_one_bus(bridge_dev->bus);
162
163 if (hose->last_busno < child->number)
164 hose->last_busno = child->number;
165
166 pdn->bussubno = child->number;
167
168 /* ioremap() for child bus, which may or may not succeed */
169 remap_bus_range(child);
170
171 return 0;
172}
173
174static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent, 137static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
175 struct device_node *dev_dn) 138 struct device_node *dev_dn)
176{ 139{
@@ -188,29 +151,41 @@ static struct pci_dev *dlpar_find_new_dev(struct pci_bus *parent,
188static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn) 151static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
189{ 152{
190 struct pci_dn *pdn = dn->data; 153 struct pci_dn *pdn = dn->data;
191 struct pci_controller *hose = pdn->phb; 154 struct pci_controller *phb = pdn->phb;
192 struct pci_dev *dev = NULL; 155 struct pci_dev *dev = NULL;
193 156
194 /* Scan phb bus for EADS device, adding new one to bus->devices */ 157 rpaphp_eeh_init_nodes(dn);
195 if (!pci_scan_single_device(hose->bus, pdn->devfn)) { 158 /* Add EADS device to PHB bus, adding new entry to bus->devices */
196 printk(KERN_ERR "%s: found no device on bus\n", __FUNCTION__); 159 dev = of_create_pci_dev(dn, phb->bus, pdn->devfn);
160 if (!dev) {
161 printk(KERN_ERR "%s: failed to create pci dev for %s\n",
162 __FUNCTION__, dn->full_name);
197 return NULL; 163 return NULL;
198 } 164 }
199 165
166 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
167 dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
168 of_scan_pci_bridge(dn, dev);
169
170 rpaphp_init_new_devs(dev->subordinate);
171
172 /* Claim new bus resources */
173 rpadlpar_claim_one_bus(dev->bus);
174
175 /* ioremap() for child bus, which may or may not succeed */
176 (void) remap_bus_range(dev->bus);
177
200 /* Add new devices to global lists. Register in proc, sysfs. */ 178 /* Add new devices to global lists. Register in proc, sysfs. */
201 pci_bus_add_devices(hose->bus); 179 pci_bus_add_devices(phb->bus);
202 180
203 /* Confirm new bridge dev was created */ 181 /* Confirm new bridge dev was created */
204 dev = dlpar_find_new_dev(hose->bus, dn); 182 dev = dlpar_find_new_dev(phb->bus, dn);
205 if (dev) { 183 if (dev) {
206 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) { 184 if (dev->hdr_type != PCI_HEADER_TYPE_BRIDGE) {
207 printk(KERN_ERR "%s: unexpected header type %d\n", 185 printk(KERN_ERR "%s: unexpected header type %d\n",
208 __FUNCTION__, dev->hdr_type); 186 __FUNCTION__, dev->hdr_type);
209 return NULL; 187 return NULL;
210 } 188 }
211
212 if (pci_add_secondary_bus(dn, dev))
213 return NULL;
214 } 189 }
215 190
216 return dev; 191 return dev;
@@ -219,7 +194,6 @@ static struct pci_dev *dlpar_pci_add_bus(struct device_node *dn)
219static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn) 194static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
220{ 195{
221 struct pci_dev *dev; 196 struct pci_dev *dev;
222 int rc;
223 197
224 if (rpaphp_find_pci_bus(dn)) 198 if (rpaphp_find_pci_bus(dn))
225 return -EINVAL; 199 return -EINVAL;
@@ -232,15 +206,6 @@ static int dlpar_add_pci_slot(char *drc_name, struct device_node *dn)
232 return -EIO; 206 return -EIO;
233 } 207 }
234 208
235 if (dn->child) {
236 rc = rpaphp_config_pci_adapter(dev->subordinate);
237 if (rc < 0) {
238 printk(KERN_ERR "%s: unable to enable slot %s\n",
239 __FUNCTION__, drc_name);
240 return -EIO;
241 }
242 }
243
244 /* Add hotplug slot */ 209 /* Add hotplug slot */
245 if (rpaphp_add_slot(dn)) { 210 if (rpaphp_add_slot(dn)) {
246 printk(KERN_ERR "%s: unable to add hotplug slot %s\n", 211 printk(KERN_ERR "%s: unable to add hotplug slot %s\n",
@@ -306,7 +271,7 @@ static int dlpar_add_phb(char *drc_name, struct device_node *dn)
306{ 271{
307 struct pci_controller *phb; 272 struct pci_controller *phb;
308 273
309 if (PCI_DN(dn)->phb) { 274 if (PCI_DN(dn) && PCI_DN(dn)->phb) {
310 /* PHB already exists */ 275 /* PHB already exists */
311 return -EINVAL; 276 return -EINVAL;
312 } 277 }
@@ -435,6 +400,8 @@ int dlpar_remove_pci_slot(char *drc_name, struct device_node *dn)
435 __FUNCTION__, drc_name); 400 __FUNCTION__, drc_name);
436 return -EIO; 401 return -EIO;
437 } 402 }
403 } else {
404 rpaphp_unconfig_pci_adapter(bus);
438 } 405 }
439 406
440 if (unmap_bus_range(bus)) { 407 if (unmap_bus_range(bus)) {
diff --git a/drivers/pci/hotplug/rpaphp.h b/drivers/pci/hotplug/rpaphp.h
index 71ea5f9bb284..57ea71a7bda5 100644
--- a/drivers/pci/hotplug/rpaphp.h
+++ b/drivers/pci/hotplug/rpaphp.h
@@ -93,6 +93,8 @@ extern int rpaphp_claim_resource(struct pci_dev *dev, int resource);
93extern int rpaphp_enable_pci_slot(struct slot *slot); 93extern int rpaphp_enable_pci_slot(struct slot *slot);
94extern int register_pci_slot(struct slot *slot); 94extern int register_pci_slot(struct slot *slot);
95extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value); 95extern int rpaphp_get_pci_adapter_status(struct slot *slot, int is_init, u8 * value);
96extern void rpaphp_init_new_devs(struct pci_bus *bus);
97extern void rpaphp_eeh_init_nodes(struct device_node *dn);
96 98
97extern int rpaphp_config_pci_adapter(struct pci_bus *bus); 99extern int rpaphp_config_pci_adapter(struct pci_bus *bus);
98extern int rpaphp_unconfig_pci_adapter(struct pci_bus *bus); 100extern int rpaphp_unconfig_pci_adapter(struct pci_bus *bus);
diff --git a/drivers/pci/hotplug/rpaphp_pci.c b/drivers/pci/hotplug/rpaphp_pci.c
index f7c12d7dfcfc..4b35097b3d9f 100644
--- a/drivers/pci/hotplug/rpaphp_pci.c
+++ b/drivers/pci/hotplug/rpaphp_pci.c
@@ -154,8 +154,7 @@ exit:
154} 154}
155 155
156/* Must be called before pci_bus_add_devices */ 156/* Must be called before pci_bus_add_devices */
157static void 157void rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
158rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
159{ 158{
160 struct pci_dev *dev; 159 struct pci_dev *dev;
161 160
@@ -184,6 +183,20 @@ rpaphp_fixup_new_pci_devices(struct pci_bus *bus, int fix_bus)
184 } 183 }
185} 184}
186 185
186static void rpaphp_eeh_add_bus_device(struct pci_bus *bus)
187{
188 struct pci_dev *dev;
189
190 list_for_each_entry(dev, &bus->devices, bus_list) {
191 eeh_add_device_late(dev);
192 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) {
193 struct pci_bus *subbus = dev->subordinate;
194 if (subbus)
195 rpaphp_eeh_add_bus_device (subbus);
196 }
197 }
198}
199
187static int rpaphp_pci_config_bridge(struct pci_dev *dev) 200static int rpaphp_pci_config_bridge(struct pci_dev *dev)
188{ 201{
189 u8 sec_busno; 202 u8 sec_busno;
@@ -217,6 +230,13 @@ static int rpaphp_pci_config_bridge(struct pci_dev *dev)
217 return 0; 230 return 0;
218} 231}
219 232
233void rpaphp_init_new_devs(struct pci_bus *bus)
234{
235 rpaphp_fixup_new_pci_devices(bus, 0);
236 rpaphp_eeh_add_bus_device(bus);
237}
238EXPORT_SYMBOL_GPL(rpaphp_init_new_devs);
239
220/***************************************************************************** 240/*****************************************************************************
221 rpaphp_pci_config_slot() will configure all devices under the 241 rpaphp_pci_config_slot() will configure all devices under the
222 given slot->dn and return the the first pci_dev. 242 given slot->dn and return the the first pci_dev.
@@ -233,36 +253,51 @@ rpaphp_pci_config_slot(struct pci_bus *bus)
233 if (!dn || !dn->child) 253 if (!dn || !dn->child)
234 return NULL; 254 return NULL;
235 255
236 slotno = PCI_SLOT(PCI_DN(dn->child)->devfn); 256 if (_machine == PLATFORM_PSERIES_LPAR) {
257 of_scan_bus(dn, bus);
258 if (list_empty(&bus->devices)) {
259 err("%s: No new device found\n", __FUNCTION__);
260 return NULL;
261 }
237 262
238 /* pci_scan_slot should find all children */ 263 rpaphp_init_new_devs(bus);
239 num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
240 if (num) {
241 rpaphp_fixup_new_pci_devices(bus, 1);
242 pci_bus_add_devices(bus); 264 pci_bus_add_devices(bus);
243 } 265 dev = list_entry(&bus->devices, struct pci_dev, bus_list);
244 if (list_empty(&bus->devices)) { 266 } else {
245 err("%s: No new device found\n", __FUNCTION__); 267 slotno = PCI_SLOT(PCI_DN(dn->child)->devfn);
246 return NULL; 268
247 } 269 /* pci_scan_slot should find all children */
248 list_for_each_entry(dev, &bus->devices, bus_list) { 270 num = pci_scan_slot(bus, PCI_DEVFN(slotno, 0));
249 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) 271 if (num) {
250 rpaphp_pci_config_bridge(dev); 272 rpaphp_fixup_new_pci_devices(bus, 1);
273 pci_bus_add_devices(bus);
274 }
275 if (list_empty(&bus->devices)) {
276 err("%s: No new device found\n", __FUNCTION__);
277 return NULL;
278 }
279 list_for_each_entry(dev, &bus->devices, bus_list) {
280 if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE)
281 rpaphp_pci_config_bridge(dev);
282
283 rpaphp_eeh_add_bus_device(bus);
284 }
251 } 285 }
252 286
253 return dev; 287 return dev;
254} 288}
255 289
256static void enable_eeh(struct device_node *dn) 290void rpaphp_eeh_init_nodes(struct device_node *dn)
257{ 291{
258 struct device_node *sib; 292 struct device_node *sib;
259 293
260 for (sib = dn->child; sib; sib = sib->sibling) 294 for (sib = dn->child; sib; sib = sib->sibling)
261 enable_eeh(sib); 295 rpaphp_eeh_init_nodes(sib);
262 eeh_add_device_early(dn); 296 eeh_add_device_early(dn);
263 return; 297 return;
264 298
265} 299}
300EXPORT_SYMBOL_GPL(rpaphp_eeh_init_nodes);
266 301
267static void print_slot_pci_funcs(struct pci_bus *bus) 302static void print_slot_pci_funcs(struct pci_bus *bus)
268{ 303{
@@ -289,7 +324,7 @@ int rpaphp_config_pci_adapter(struct pci_bus *bus)
289 if (!dn) 324 if (!dn)
290 goto exit; 325 goto exit;
291 326
292 enable_eeh(dn); 327 rpaphp_eeh_init_nodes(dn);
293 dev = rpaphp_pci_config_slot(bus); 328 dev = rpaphp_pci_config_slot(bus);
294 if (!dev) { 329 if (!dev) {
295 err("%s: can't find any devices.\n", __FUNCTION__); 330 err("%s: can't find any devices.\n", __FUNCTION__);
@@ -331,6 +366,7 @@ int rpaphp_unconfig_pci_adapter(struct pci_bus *bus)
331 } 366 }
332 return 0; 367 return 0;
333} 368}
369EXPORT_SYMBOL_GPL(rpaphp_unconfig_pci_adapter);
334 370
335static int setup_pci_hotplug_slot_info(struct slot *slot) 371static int setup_pci_hotplug_slot_info(struct slot *slot)
336{ 372{
@@ -444,8 +480,8 @@ int rpaphp_enable_pci_slot(struct slot *slot)
444 retval = rpaphp_config_pci_adapter(slot->bus); 480 retval = rpaphp_config_pci_adapter(slot->bus);
445 if (!retval) { 481 if (!retval) {
446 slot->state = CONFIGURED; 482 slot->state = CONFIGURED;
447 dbg("%s: PCI devices in slot[%s] has been configured\n", 483 info("%s: devices in slot[%s] configured\n",
448 __FUNCTION__, slot->name); 484 __FUNCTION__, slot->name);
449 } else { 485 } else {
450 slot->state = NOT_CONFIGURED; 486 slot->state = NOT_CONFIGURED;
451 dbg("%s: no pci_dev struct for adapter in slot[%s]\n", 487 dbg("%s: no pci_dev struct for adapter in slot[%s]\n",
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index 40905a6c8094..9987a6fd65b8 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -31,6 +31,8 @@
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/types.h> 32#include <linux/types.h>
33#include <linux/pci.h> 33#include <linux/pci.h>
34#include <linux/interrupt.h>
35
34#include "shpchp.h" 36#include "shpchp.h"
35 37
36#ifdef DEBUG 38#ifdef DEBUG
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index b8e95acea3b6..38009bc0fd5d 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -34,7 +34,7 @@
34#include "../pci.h" 34#include "../pci.h"
35#include "shpchp.h" 35#include "shpchp.h"
36 36
37void program_fw_provided_values(struct pci_dev *dev) 37static void program_fw_provided_values(struct pci_dev *dev)
38{ 38{
39 u16 pci_cmd, pci_bctl; 39 u16 pci_cmd, pci_bctl;
40 struct pci_dev *cdev; 40 struct pci_dev *cdev;
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index a2033552423c..202b7507a357 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -23,6 +23,8 @@
23#include "pci.h" 23#include "pci.h"
24#include "msi.h" 24#include "msi.h"
25 25
26#define MSI_TARGET_CPU first_cpu(cpu_online_map)
27
26static DEFINE_SPINLOCK(msi_lock); 28static DEFINE_SPINLOCK(msi_lock);
27static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL }; 29static struct msi_desc* msi_desc[NR_IRQS] = { [0 ... NR_IRQS-1] = NULL };
28static kmem_cache_t* msi_cachep; 30static kmem_cache_t* msi_cachep;
@@ -92,6 +94,7 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
92 struct msi_desc *entry; 94 struct msi_desc *entry;
93 struct msg_address address; 95 struct msg_address address;
94 unsigned int irq = vector; 96 unsigned int irq = vector;
97 unsigned int dest_cpu = first_cpu(cpu_mask);
95 98
96 entry = (struct msi_desc *)msi_desc[vector]; 99 entry = (struct msi_desc *)msi_desc[vector];
97 if (!entry || !entry->dev) 100 if (!entry || !entry->dev)
@@ -108,9 +111,9 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
108 pci_read_config_dword(entry->dev, msi_lower_address_reg(pos), 111 pci_read_config_dword(entry->dev, msi_lower_address_reg(pos),
109 &address.lo_address.value); 112 &address.lo_address.value);
110 address.lo_address.value &= MSI_ADDRESS_DEST_ID_MASK; 113 address.lo_address.value &= MSI_ADDRESS_DEST_ID_MASK;
111 address.lo_address.value |= (cpu_mask_to_apicid(cpu_mask) << 114 address.lo_address.value |= (cpu_physical_id(dest_cpu) <<
112 MSI_TARGET_CPU_SHIFT); 115 MSI_TARGET_CPU_SHIFT);
113 entry->msi_attrib.current_cpu = cpu_mask_to_apicid(cpu_mask); 116 entry->msi_attrib.current_cpu = cpu_physical_id(dest_cpu);
114 pci_write_config_dword(entry->dev, msi_lower_address_reg(pos), 117 pci_write_config_dword(entry->dev, msi_lower_address_reg(pos),
115 address.lo_address.value); 118 address.lo_address.value);
116 set_native_irq_info(irq, cpu_mask); 119 set_native_irq_info(irq, cpu_mask);
@@ -123,9 +126,9 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
123 126
124 address.lo_address.value = readl(entry->mask_base + offset); 127 address.lo_address.value = readl(entry->mask_base + offset);
125 address.lo_address.value &= MSI_ADDRESS_DEST_ID_MASK; 128 address.lo_address.value &= MSI_ADDRESS_DEST_ID_MASK;
126 address.lo_address.value |= (cpu_mask_to_apicid(cpu_mask) << 129 address.lo_address.value |= (cpu_physical_id(dest_cpu) <<
127 MSI_TARGET_CPU_SHIFT); 130 MSI_TARGET_CPU_SHIFT);
128 entry->msi_attrib.current_cpu = cpu_mask_to_apicid(cpu_mask); 131 entry->msi_attrib.current_cpu = cpu_physical_id(dest_cpu);
129 writel(address.lo_address.value, entry->mask_base + offset); 132 writel(address.lo_address.value, entry->mask_base + offset);
130 set_native_irq_info(irq, cpu_mask); 133 set_native_irq_info(irq, cpu_mask);
131 break; 134 break;
@@ -259,14 +262,15 @@ static void msi_data_init(struct msg_data *msi_data,
259static void msi_address_init(struct msg_address *msi_address) 262static void msi_address_init(struct msg_address *msi_address)
260{ 263{
261 unsigned int dest_id; 264 unsigned int dest_id;
265 unsigned long dest_phys_id = cpu_physical_id(MSI_TARGET_CPU);
262 266
263 memset(msi_address, 0, sizeof(struct msg_address)); 267 memset(msi_address, 0, sizeof(struct msg_address));
264 msi_address->hi_address = (u32)0; 268 msi_address->hi_address = (u32)0;
265 dest_id = (MSI_ADDRESS_HEADER << MSI_ADDRESS_HEADER_SHIFT); 269 dest_id = (MSI_ADDRESS_HEADER << MSI_ADDRESS_HEADER_SHIFT);
266 msi_address->lo_address.u.dest_mode = MSI_DEST_MODE; 270 msi_address->lo_address.u.dest_mode = MSI_PHYSICAL_MODE;
267 msi_address->lo_address.u.redirection_hint = MSI_REDIRECTION_HINT_MODE; 271 msi_address->lo_address.u.redirection_hint = MSI_REDIRECTION_HINT_MODE;
268 msi_address->lo_address.u.dest_id = dest_id; 272 msi_address->lo_address.u.dest_id = dest_id;
269 msi_address->lo_address.value |= (MSI_TARGET_CPU << MSI_TARGET_CPU_SHIFT); 273 msi_address->lo_address.value |= (dest_phys_id << MSI_TARGET_CPU_SHIFT);
270} 274}
271 275
272static int msi_free_vector(struct pci_dev* dev, int vector, int reassign); 276static int msi_free_vector(struct pci_dev* dev, int vector, int reassign);
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index e9e37abe1f76..6917c6cb0912 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -91,9 +91,7 @@ acpi_query_osc (
91static acpi_status 91static acpi_status
92acpi_run_osc ( 92acpi_run_osc (
93 acpi_handle handle, 93 acpi_handle handle,
94 u32 level, 94 void *context)
95 void *context,
96 void **retval )
97{ 95{
98 acpi_status status; 96 acpi_status status;
99 struct acpi_object_list input; 97 struct acpi_object_list input;
@@ -180,11 +178,12 @@ EXPORT_SYMBOL(pci_osc_support_set);
180 178
181/** 179/**
182 * pci_osc_control_set - commit requested control to Firmware 180 * pci_osc_control_set - commit requested control to Firmware
181 * @handle: acpi_handle for the target ACPI object
183 * @flags: driver's requested control bits 182 * @flags: driver's requested control bits
184 * 183 *
185 * Attempt to take control from Firmware on requested control bits. 184 * Attempt to take control from Firmware on requested control bits.
186 **/ 185 **/
187acpi_status pci_osc_control_set(u32 flags) 186acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
188{ 187{
189 acpi_status status; 188 acpi_status status;
190 u32 ctrlset; 189 u32 ctrlset;
@@ -198,10 +197,7 @@ acpi_status pci_osc_control_set(u32 flags)
198 return AE_SUPPORT; 197 return AE_SUPPORT;
199 } 198 }
200 ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset; 199 ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset;
201 status = acpi_get_devices ( PCI_ROOT_HID_STRING, 200 status = acpi_run_osc(handle, ctrlset_buf);
202 acpi_run_osc,
203 ctrlset_buf,
204 NULL );
205 if (ACPI_FAILURE (status)) { 201 if (ACPI_FAILURE (status)) {
206 ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset; 202 ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset;
207 } 203 }
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 94e68c54d273..a9046d4b8af3 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -37,7 +37,7 @@ struct pci_dynid {
37 * Adds a new dynamic pci device ID to this driver, 37 * Adds a new dynamic pci device ID to this driver,
38 * and causes the driver to probe for all devices again. 38 * and causes the driver to probe for all devices again.
39 */ 39 */
40static inline ssize_t 40static ssize_t
41store_new_id(struct device_driver *driver, const char *buf, size_t count) 41store_new_id(struct device_driver *driver, const char *buf, size_t count)
42{ 42{
43 struct pci_dynid *dynid; 43 struct pci_dynid *dynid;
@@ -364,15 +364,16 @@ static struct kobj_type pci_driver_kobj_type = {
364}; 364};
365 365
366/** 366/**
367 * pci_register_driver - register a new pci driver 367 * __pci_register_driver - register a new pci driver
368 * @drv: the driver structure to register 368 * @drv: the driver structure to register
369 * @owner: owner module of drv
369 * 370 *
370 * Adds the driver structure to the list of registered drivers. 371 * Adds the driver structure to the list of registered drivers.
371 * Returns a negative value on error, otherwise 0. 372 * Returns a negative value on error, otherwise 0.
372 * If no error occurred, the driver remains registered even if 373 * If no error occurred, the driver remains registered even if
373 * no device was claimed during registration. 374 * no device was claimed during registration.
374 */ 375 */
375int pci_register_driver(struct pci_driver *drv) 376int __pci_register_driver(struct pci_driver *drv, struct module *owner)
376{ 377{
377 int error; 378 int error;
378 379
@@ -389,7 +390,7 @@ int pci_register_driver(struct pci_driver *drv)
389 printk(KERN_WARNING "Warning: PCI driver %s has a struct " 390 printk(KERN_WARNING "Warning: PCI driver %s has a struct "
390 "device_driver shutdown method, please update!\n", 391 "device_driver shutdown method, please update!\n",
391 drv->name); 392 drv->name);
392 drv->driver.owner = drv->owner; 393 drv->driver.owner = owner;
393 drv->driver.kobj.ktype = &pci_driver_kobj_type; 394 drv->driver.kobj.ktype = &pci_driver_kobj_type;
394 395
395 spin_lock_init(&drv->dynids.lock); 396 spin_lock_init(&drv->dynids.lock);
@@ -526,7 +527,7 @@ postcore_initcall(pci_driver_init);
526 527
527EXPORT_SYMBOL(pci_match_id); 528EXPORT_SYMBOL(pci_match_id);
528EXPORT_SYMBOL(pci_match_device); 529EXPORT_SYMBOL(pci_match_device);
529EXPORT_SYMBOL(pci_register_driver); 530EXPORT_SYMBOL(__pci_register_driver);
530EXPORT_SYMBOL(pci_unregister_driver); 531EXPORT_SYMBOL(pci_unregister_driver);
531EXPORT_SYMBOL(pci_dev_driver); 532EXPORT_SYMBOL(pci_dev_driver);
532EXPORT_SYMBOL(pci_bus_type); 533EXPORT_SYMBOL(pci_bus_type);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e74d75843047..8e287a828d5d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -63,11 +63,38 @@ pci_max_busnr(void)
63 return max; 63 return max;
64} 64}
65 65
66static int __pci_find_next_cap(struct pci_bus *bus, unsigned int devfn, u8 pos, int cap)
67{
68 u8 id;
69 int ttl = 48;
70
71 while (ttl--) {
72 pci_bus_read_config_byte(bus, devfn, pos, &pos);
73 if (pos < 0x40)
74 break;
75 pos &= ~3;
76 pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID,
77 &id);
78 if (id == 0xff)
79 break;
80 if (id == cap)
81 return pos;
82 pos += PCI_CAP_LIST_NEXT;
83 }
84 return 0;
85}
86
87int pci_find_next_capability(struct pci_dev *dev, u8 pos, int cap)
88{
89 return __pci_find_next_cap(dev->bus, dev->devfn,
90 pos + PCI_CAP_LIST_NEXT, cap);
91}
92EXPORT_SYMBOL_GPL(pci_find_next_capability);
93
66static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_type, int cap) 94static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_type, int cap)
67{ 95{
68 u16 status; 96 u16 status;
69 u8 pos, id; 97 u8 pos;
70 int ttl = 48;
71 98
72 pci_bus_read_config_word(bus, devfn, PCI_STATUS, &status); 99 pci_bus_read_config_word(bus, devfn, PCI_STATUS, &status);
73 if (!(status & PCI_STATUS_CAP_LIST)) 100 if (!(status & PCI_STATUS_CAP_LIST))
@@ -76,24 +103,15 @@ static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_ty
76 switch (hdr_type) { 103 switch (hdr_type) {
77 case PCI_HEADER_TYPE_NORMAL: 104 case PCI_HEADER_TYPE_NORMAL:
78 case PCI_HEADER_TYPE_BRIDGE: 105 case PCI_HEADER_TYPE_BRIDGE:
79 pci_bus_read_config_byte(bus, devfn, PCI_CAPABILITY_LIST, &pos); 106 pos = PCI_CAPABILITY_LIST;
80 break; 107 break;
81 case PCI_HEADER_TYPE_CARDBUS: 108 case PCI_HEADER_TYPE_CARDBUS:
82 pci_bus_read_config_byte(bus, devfn, PCI_CB_CAPABILITY_LIST, &pos); 109 pos = PCI_CB_CAPABILITY_LIST;
83 break; 110 break;
84 default: 111 default:
85 return 0; 112 return 0;
86 } 113 }
87 while (ttl-- && pos >= 0x40) { 114 return __pci_find_next_cap(bus, devfn, pos, cap);
88 pos &= ~3;
89 pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, &id);
90 if (id == 0xff)
91 break;
92 if (id == cap)
93 return pos;
94 pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_NEXT, &pos);
95 }
96 return 0;
97} 115}
98 116
99/** 117/**
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index 5627ce1d2b32..3a4f49f4effb 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -462,11 +462,11 @@ static void __devinit quirk_vt82c686_acpi(struct pci_dev *dev)
462 462
463 pci_read_config_word(dev, 0x70, &hm); 463 pci_read_config_word(dev, 0x70, &hm);
464 hm &= PCI_BASE_ADDRESS_IO_MASK; 464 hm &= PCI_BASE_ADDRESS_IO_MASK;
465 quirk_io_region(dev, hm, 128, PCI_BRIDGE_RESOURCES + 1, "vt82c868 HW-mon"); 465 quirk_io_region(dev, hm, 128, PCI_BRIDGE_RESOURCES + 1, "vt82c686 HW-mon");
466 466
467 pci_read_config_dword(dev, 0x90, &smb); 467 pci_read_config_dword(dev, 0x90, &smb);
468 smb &= PCI_BASE_ADDRESS_IO_MASK; 468 smb &= PCI_BASE_ADDRESS_IO_MASK;
469 quirk_io_region(dev, smb, 16, PCI_BRIDGE_RESOURCES + 2, "vt82c868 SMB"); 469 quirk_io_region(dev, smb, 16, PCI_BRIDGE_RESOURCES + 2, "vt82c686 SMB");
470} 470}
471DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vt82c686_acpi ); 471DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_vt82c686_acpi );
472 472
@@ -1243,6 +1243,21 @@ static void __devinit quirk_netmos(struct pci_dev *dev)
1243} 1243}
1244DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID, quirk_netmos); 1244DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NETMOS, PCI_ANY_ID, quirk_netmos);
1245 1245
1246
1247static void __devinit fixup_rev1_53c810(struct pci_dev* dev)
1248{
1249 /* rev 1 ncr53c810 chips don't set the class at all which means
1250 * they don't get their resources remapped. Fix that here.
1251 */
1252
1253 if (dev->class == PCI_CLASS_NOT_DEFINED) {
1254 printk(KERN_INFO "NCR 53c810 rev 1 detected, setting PCI class.\n");
1255 dev->class = PCI_CLASS_STORAGE_SCSI;
1256 }
1257}
1258DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NCR, PCI_DEVICE_ID_NCR_53C810, fixup_rev1_53c810);
1259
1260
1246static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end) 1261static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, struct pci_fixup *end)
1247{ 1262{
1248 while (f < end) { 1263 while (f < end) {
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig
index ccf20039e909..309eb557f9a3 100644
--- a/drivers/pcmcia/Kconfig
+++ b/drivers/pcmcia/Kconfig
@@ -156,7 +156,7 @@ config TCIC
156 156
157config PCMCIA_M8XX 157config PCMCIA_M8XX
158 tristate "MPC8xx PCMCIA support" 158 tristate "MPC8xx PCMCIA support"
159 depends on PCMCIA && PPC 159 depends on PCMCIA && PPC && 8xx
160 select PCCARD_NONSTATIC 160 select PCCARD_NONSTATIC
161 help 161 help
162 Say Y here to include support for PowerPC 8xx series PCMCIA 162 Say Y here to include support for PowerPC 8xx series PCMCIA
diff --git a/drivers/pcmcia/Makefile b/drivers/pcmcia/Makefile
index fe37541abbfe..bcecf5133b7e 100644
--- a/drivers/pcmcia/Makefile
+++ b/drivers/pcmcia/Makefile
@@ -25,7 +25,7 @@ obj-$(CONFIG_PD6729) += pd6729.o
25obj-$(CONFIG_I82365) += i82365.o 25obj-$(CONFIG_I82365) += i82365.o
26obj-$(CONFIG_I82092) += i82092.o 26obj-$(CONFIG_I82092) += i82092.o
27obj-$(CONFIG_TCIC) += tcic.o 27obj-$(CONFIG_TCIC) += tcic.o
28obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o 28obj-$(CONFIG_PCMCIA_M8XX) += m8xx_pcmcia.o
29obj-$(CONFIG_HD64465_PCMCIA) += hd64465_ss.o 29obj-$(CONFIG_HD64465_PCMCIA) += hd64465_ss.o
30obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o 30obj-$(CONFIG_PCMCIA_SA1100) += sa11xx_core.o sa1100_cs.o
31obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o 31obj-$(CONFIG_PCMCIA_SA1111) += sa11xx_core.o sa1111_cs.o
@@ -47,10 +47,10 @@ au1x00_ss-$(CONFIG_MIPS_PB1200) += au1000_db1x00.o
47au1x00_ss-$(CONFIG_MIPS_PB1500) += au1000_pb1x00.o 47au1x00_ss-$(CONFIG_MIPS_PB1500) += au1000_pb1x00.o
48au1x00_ss-$(CONFIG_MIPS_DB1000) += au1000_db1x00.o 48au1x00_ss-$(CONFIG_MIPS_DB1000) += au1000_db1x00.o
49au1x00_ss-$(CONFIG_MIPS_DB1100) += au1000_db1x00.o 49au1x00_ss-$(CONFIG_MIPS_DB1100) += au1000_db1x00.o
50au1x00_ss-$(CONFIG_MIPS_DB1200) += au1000_db1x00.o 50au1x00_ss-$(CONFIG_MIPS_DB1200) += au1000_db1x00.o
51au1x00_ss-$(CONFIG_MIPS_DB1500) += au1000_db1x00.o 51au1x00_ss-$(CONFIG_MIPS_DB1500) += au1000_db1x00.o
52au1x00_ss-$(CONFIG_MIPS_DB1550) += au1000_db1x00.o 52au1x00_ss-$(CONFIG_MIPS_DB1550) += au1000_db1x00.o
53au1x00_ss-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o 53au1x00_ss-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o
54 54
55sa1111_cs-y += sa1111_generic.o 55sa1111_cs-y += sa1111_generic.o
56sa1111_cs-$(CONFIG_ASSABET_NEPONSET) += sa1100_neponset.o 56sa1111_cs-$(CONFIG_ASSABET_NEPONSET) += sa1100_neponset.o
diff --git a/drivers/pcmcia/au1000_db1x00.c b/drivers/pcmcia/au1000_db1x00.c
index 24cfee1a412c..abc13f28ba3f 100644
--- a/drivers/pcmcia/au1000_db1x00.c
+++ b/drivers/pcmcia/au1000_db1x00.c
@@ -30,6 +30,7 @@
30 * 30 *
31 */ 31 */
32 32
33#include <linux/config.h>
33#include <linux/module.h> 34#include <linux/module.h>
34#include <linux/kernel.h> 35#include <linux/kernel.h>
35#include <linux/errno.h> 36#include <linux/errno.h>
diff --git a/drivers/pcmcia/au1000_generic.h b/drivers/pcmcia/au1000_generic.h
index b0e7908392a7..f2c970b5f4ff 100644
--- a/drivers/pcmcia/au1000_generic.h
+++ b/drivers/pcmcia/au1000_generic.h
@@ -22,6 +22,8 @@
22#define __ASM_AU1000_PCMCIA_H 22#define __ASM_AU1000_PCMCIA_H
23 23
24/* include the world */ 24/* include the world */
25#include <linux/config.h>
26
25#include <pcmcia/cs_types.h> 27#include <pcmcia/cs_types.h>
26#include <pcmcia/cs.h> 28#include <pcmcia/cs.h>
27#include <pcmcia/ss.h> 29#include <pcmcia/ss.h>
diff --git a/drivers/pcmcia/au1000_pb1x00.c b/drivers/pcmcia/au1000_pb1x00.c
index 86c0808d6a05..fd5522ede867 100644
--- a/drivers/pcmcia/au1000_pb1x00.c
+++ b/drivers/pcmcia/au1000_pb1x00.c
@@ -21,6 +21,7 @@
21 * with this program; if not, write to the Free Software Foundation, Inc., 21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 22 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 */ 23 */
24#include <linux/config.h>
24#include <linux/module.h> 25#include <linux/module.h>
25#include <linux/init.h> 26#include <linux/init.h>
26#include <linux/delay.h> 27#include <linux/delay.h>
diff --git a/drivers/pcmcia/au1000_xxs1500.c b/drivers/pcmcia/au1000_xxs1500.c
index 01a895bc9a47..01874b0bb03b 100644
--- a/drivers/pcmcia/au1000_xxs1500.c
+++ b/drivers/pcmcia/au1000_xxs1500.c
@@ -27,7 +27,6 @@
27 */ 27 */
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/config.h>
31#include <linux/delay.h> 30#include <linux/delay.h>
32#include <linux/ioport.h> 31#include <linux/ioport.h>
33#include <linux/kernel.h> 32#include <linux/kernel.h>
diff --git a/drivers/pcmcia/cs.c b/drivers/pcmcia/cs.c
index 234cdca6fe13..a30aa74304a2 100644
--- a/drivers/pcmcia/cs.c
+++ b/drivers/pcmcia/cs.c
@@ -513,6 +513,11 @@ static int socket_insert(struct pcmcia_socket *skt)
513 ret = socket_setup(skt, setup_delay); 513 ret = socket_setup(skt, setup_delay);
514 if (ret == CS_SUCCESS) { 514 if (ret == CS_SUCCESS) {
515 skt->state |= SOCKET_PRESENT; 515 skt->state |= SOCKET_PRESENT;
516
517 printk(KERN_NOTICE "pccard: %s card inserted into slot %d\n",
518 (skt->state & SOCKET_CARDBUS) ? "CardBus" : "PCMCIA",
519 skt->sock);
520
516#ifdef CONFIG_CARDBUS 521#ifdef CONFIG_CARDBUS
517 if (skt->state & SOCKET_CARDBUS) { 522 if (skt->state & SOCKET_CARDBUS) {
518 cb_alloc(skt); 523 cb_alloc(skt);
@@ -598,6 +603,7 @@ static int socket_resume(struct pcmcia_socket *skt)
598 603
599static void socket_remove(struct pcmcia_socket *skt) 604static void socket_remove(struct pcmcia_socket *skt)
600{ 605{
606 printk(KERN_NOTICE "pccard: card ejected from slot %d\n", skt->sock);
601 socket_shutdown(skt); 607 socket_shutdown(skt);
602 cs_socket_put(skt); 608 cs_socket_put(skt);
603} 609}
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 39d096b52926..7f8219f3fd9e 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -544,6 +544,9 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f
544 list_add_tail(&p_dev->socket_device_list, &s->devices_list); 544 list_add_tail(&p_dev->socket_device_list, &s->devices_list);
545 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); 545 spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags);
546 546
547 printk(KERN_NOTICE "pcmcia: registering new device %s\n",
548 p_dev->devname);
549
547 pcmcia_device_query(p_dev); 550 pcmcia_device_query(p_dev);
548 551
549 if (device_register(&p_dev->dev)) { 552 if (device_register(&p_dev->dev)) {
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c
index 7ce455d01cc9..4d56bc9926d6 100644
--- a/drivers/pcmcia/i82365.c
+++ b/drivers/pcmcia/i82365.c
@@ -1339,10 +1339,7 @@ static struct device_driver i82365_driver = {
1339 .resume = pcmcia_socket_dev_resume, 1339 .resume = pcmcia_socket_dev_resume,
1340}; 1340};
1341 1341
1342static struct platform_device i82365_device = { 1342static struct platform_device *i82365_device;
1343 .name = "i82365",
1344 .id = 0,
1345};
1346 1343
1347static int __init init_i82365(void) 1344static int __init init_i82365(void)
1348{ 1345{
@@ -1352,7 +1349,14 @@ static int __init init_i82365(void)
1352 if (ret) 1349 if (ret)
1353 return ret; 1350 return ret;
1354 1351
1355 ret = platform_device_register(&i82365_device); 1352 i82365_device = platform_device_alloc("i82365", 0);
1353 if (i82365_device) {
1354 ret = platform_device_add(i82365_device);
1355 if (ret)
1356 platform_device_put(i82365_device);
1357 } else
1358 ret = -ENOMEM;
1359
1356 if (ret) { 1360 if (ret) {
1357 driver_unregister(&i82365_driver); 1361 driver_unregister(&i82365_driver);
1358 return ret; 1362 return ret;
@@ -1365,7 +1369,8 @@ static int __init init_i82365(void)
1365 1369
1366 if (sockets == 0) { 1370 if (sockets == 0) {
1367 printk("not found.\n"); 1371 printk("not found.\n");
1368 platform_device_unregister(&i82365_device); 1372 platform_device_unregister(i82365_device);
1373 release_region(i365_base, 2);
1369 driver_unregister(&i82365_driver); 1374 driver_unregister(&i82365_driver);
1370 return -ENODEV; 1375 return -ENODEV;
1371 } 1376 }
@@ -1376,7 +1381,7 @@ static int __init init_i82365(void)
1376 1381
1377 /* register sockets with the pcmcia core */ 1382 /* register sockets with the pcmcia core */
1378 for (i = 0; i < sockets; i++) { 1383 for (i = 0; i < sockets; i++) {
1379 socket[i].socket.dev.dev = &i82365_device.dev; 1384 socket[i].socket.dev.dev = &i82365_device->dev;
1380 socket[i].socket.ops = &pcic_operations; 1385 socket[i].socket.ops = &pcic_operations;
1381 socket[i].socket.resource_ops = &pccard_nonstatic_ops; 1386 socket[i].socket.resource_ops = &pccard_nonstatic_ops;
1382 socket[i].socket.owner = THIS_MODULE; 1387 socket[i].socket.owner = THIS_MODULE;
@@ -1414,7 +1419,7 @@ static void __exit exit_i82365(void)
1414 if (socket[i].flags & IS_REGISTERED) 1419 if (socket[i].flags & IS_REGISTERED)
1415 pcmcia_unregister_socket(&socket[i].socket); 1420 pcmcia_unregister_socket(&socket[i].socket);
1416 } 1421 }
1417 platform_device_unregister(&i82365_device); 1422 platform_device_unregister(i82365_device);
1418 if (poll_interval != 0) 1423 if (poll_interval != 0)
1419 del_timer_sync(&poll_timer); 1424 del_timer_sync(&poll_timer);
1420 if (grab_irq != 0) 1425 if (grab_irq != 0)
diff --git a/drivers/pcmcia/m32r_cfc.c b/drivers/pcmcia/m32r_cfc.c
index 2c22b4b3619d..078579ae6359 100644
--- a/drivers/pcmcia/m32r_cfc.c
+++ b/drivers/pcmcia/m32r_cfc.c
@@ -355,9 +355,10 @@ static void add_pcc_socket(ulong base, int irq, ulong mapaddr, kio_addr_t ioaddr
355#ifndef CONFIG_PLAT_USRV 355#ifndef CONFIG_PLAT_USRV
356 /* insert interrupt */ 356 /* insert interrupt */
357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 357 request_irq(irq, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
358#ifndef CONFIG_PLAT_MAPPI3
358 /* eject interrupt */ 359 /* eject interrupt */
359 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt); 360 request_irq(irq+1, pcc_interrupt, 0, "m32r_cfc", pcc_interrupt);
360 361#endif
361 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n"); 362 debug(3, "m32r_cfc: enable CFMSK, RDYSEL\n");
362 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01); 363 pcc_set(pcc_sockets, (unsigned int)PLD_CFIMASK, 0x01);
363#endif /* CONFIG_PLAT_USRV */ 364#endif /* CONFIG_PLAT_USRV */
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index f8bed87cf2f1..6d9f71cfcb34 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -39,7 +39,6 @@
39 39
40#include <asm/io.h> 40#include <asm/io.h>
41#include <asm/bitops.h> 41#include <asm/bitops.h>
42#include <asm/segment.h>
43#include <asm/system.h> 42#include <asm/system.h>
44 43
45#include <linux/kernel.h> 44#include <linux/kernel.h>
@@ -50,6 +49,7 @@
50#include <linux/ioport.h> 49#include <linux/ioport.h>
51#include <linux/delay.h> 50#include <linux/delay.h>
52#include <linux/interrupt.h> 51#include <linux/interrupt.h>
52#include <linux/platform_device.h>
53 53
54#include <asm/mpc8xx.h> 54#include <asm/mpc8xx.h>
55#include <asm/8xx_immap.h> 55#include <asm/8xx_immap.h>
@@ -546,29 +546,11 @@ static void m8xx_shutdown(void)
546 free_irq(pcmcia_schlvl, NULL); 546 free_irq(pcmcia_schlvl, NULL);
547} 547}
548 548
549/* copied from tcic.c */
550
551static int m8xx_drv_suspend(struct device *dev, pm_message_t state, u32 level)
552{
553 int ret = 0;
554 if (level == SUSPEND_SAVE_STATE)
555 ret = pcmcia_socket_dev_suspend(dev, state);
556 return ret;
557}
558
559static int m8xx_drv_resume(struct device *dev, u32 level)
560{
561 int ret = 0;
562 if (level == RESUME_RESTORE_STATE)
563 ret = pcmcia_socket_dev_resume(dev);
564 return ret;
565}
566
567static struct device_driver m8xx_driver = { 549static struct device_driver m8xx_driver = {
568 .name = "m8xx-pcmcia", 550 .name = "m8xx-pcmcia",
569 .bus = &platform_bus_type, 551 .bus = &platform_bus_type,
570 .suspend = m8xx_drv_suspend, 552 .suspend = pcmcia_socket_dev_suspend,
571 .resume = m8xx_drv_resume, 553 .resume = pcmcia_socket_dev_resume,
572}; 554};
573 555
574static struct platform_device m8xx_device = { 556static struct platform_device m8xx_device = {
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index f5b7d360fc10..1026f2bc3185 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -1179,12 +1179,12 @@ raw3270_create_attributes(struct raw3270 *rp)
1179 //FIXME: check return code 1179 //FIXME: check return code
1180 sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group); 1180 sysfs_create_group(&rp->cdev->dev.kobj, &raw3270_attr_group);
1181 rp->clttydev = 1181 rp->clttydev =
1182 class_device_create(class3270, 1182 class_device_create(class3270, NULL,
1183 MKDEV(IBM_TTY3270_MAJOR, rp->minor), 1183 MKDEV(IBM_TTY3270_MAJOR, rp->minor),
1184 &rp->cdev->dev, "tty%s", 1184 &rp->cdev->dev, "tty%s",
1185 rp->cdev->dev.bus_id); 1185 rp->cdev->dev.bus_id);
1186 rp->cltubdev = 1186 rp->cltubdev =
1187 class_device_create(class3270, 1187 class_device_create(class3270, NULL,
1188 MKDEV(IBM_FS3270_MAJOR, rp->minor), 1188 MKDEV(IBM_FS3270_MAJOR, rp->minor),
1189 &rp->cdev->dev, "tub%s", 1189 &rp->cdev->dev, "tub%s",
1190 rp->cdev->dev.bus_id); 1190 rp->cdev->dev.bus_id);
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 1c8ad2fcad8a..da8c515743e8 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -8,7 +8,7 @@
8 * Author(s): Original Code written by 8 * Author(s): Original Code written by
9 * DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com) 9 * DJ Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
10 * Rewritten by 10 * Rewritten by
11 * Frank Pavlic (pavlic@de.ibm.com) and 11 * Frank Pavlic (fpavlic@de.ibm.com) and
12 * Martin Schwidefsky <schwidefsky@de.ibm.com> 12 * Martin Schwidefsky <schwidefsky@de.ibm.com>
13 * 13 *
14 * $Revision: 1.99 $ $Date: 2005/05/11 08:10:17 $ 14 * $Revision: 1.99 $ $Date: 2005/05/11 08:10:17 $
@@ -2342,6 +2342,6 @@ __exit lcs_cleanup_module(void)
2342module_init(lcs_init_module); 2342module_init(lcs_init_module);
2343module_exit(lcs_cleanup_module); 2343module_exit(lcs_cleanup_module);
2344 2344
2345MODULE_AUTHOR("Frank Pavlic <pavlic@de.ibm.com>"); 2345MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
2346MODULE_LICENSE("GPL"); 2346MODULE_LICENSE("GPL");
2347 2347
diff --git a/drivers/s390/net/qeth.h b/drivers/s390/net/qeth.h
index 38a2441564d7..d238c7ed103b 100644
--- a/drivers/s390/net/qeth.h
+++ b/drivers/s390/net/qeth.h
@@ -8,6 +8,7 @@
8#include <linux/trdevice.h> 8#include <linux/trdevice.h>
9#include <linux/etherdevice.h> 9#include <linux/etherdevice.h>
10#include <linux/if_vlan.h> 10#include <linux/if_vlan.h>
11#include <linux/ctype.h>
11 12
12#include <net/ipv6.h> 13#include <net/ipv6.h>
13#include <linux/in6.h> 14#include <linux/in6.h>
@@ -24,7 +25,7 @@
24 25
25#include "qeth_mpc.h" 26#include "qeth_mpc.h"
26 27
27#define VERSION_QETH_H "$Revision: 1.142 $" 28#define VERSION_QETH_H "$Revision: 1.152 $"
28 29
29#ifdef CONFIG_QETH_IPV6 30#ifdef CONFIG_QETH_IPV6
30#define QETH_VERSION_IPV6 ":IPv6" 31#define QETH_VERSION_IPV6 ":IPv6"
@@ -718,8 +719,6 @@ struct qeth_reply {
718 atomic_t refcnt; 719 atomic_t refcnt;
719}; 720};
720 721
721#define QETH_BROADCAST_WITH_ECHO 1
722#define QETH_BROADCAST_WITHOUT_ECHO 2
723 722
724struct qeth_card_blkt { 723struct qeth_card_blkt {
725 int time_total; 724 int time_total;
@@ -727,8 +726,10 @@ struct qeth_card_blkt {
727 int inter_packet_jumbo; 726 int inter_packet_jumbo;
728}; 727};
729 728
730 729#define QETH_BROADCAST_WITH_ECHO 0x01
731 730#define QETH_BROADCAST_WITHOUT_ECHO 0x02
731#define QETH_LAYER2_MAC_READ 0x01
732#define QETH_LAYER2_MAC_REGISTERED 0x02
732struct qeth_card_info { 733struct qeth_card_info {
733 unsigned short unit_addr2; 734 unsigned short unit_addr2;
734 unsigned short cula; 735 unsigned short cula;
@@ -736,7 +737,7 @@ struct qeth_card_info {
736 __u16 func_level; 737 __u16 func_level;
737 char mcl_level[QETH_MCL_LENGTH + 1]; 738 char mcl_level[QETH_MCL_LENGTH + 1];
738 int guestlan; 739 int guestlan;
739 int layer2_mac_registered; 740 int mac_bits;
740 int portname_required; 741 int portname_required;
741 int portno; 742 int portno;
742 char portname[9]; 743 char portname[9];
@@ -749,6 +750,7 @@ struct qeth_card_info {
749 int unique_id; 750 int unique_id;
750 struct qeth_card_blkt blkt; 751 struct qeth_card_blkt blkt;
751 __u32 csum_mask; 752 __u32 csum_mask;
753 enum qeth_ipa_promisc_modes promisc_mode;
752}; 754};
753 755
754struct qeth_card_options { 756struct qeth_card_options {
@@ -775,6 +777,7 @@ struct qeth_card_options {
775enum qeth_threads { 777enum qeth_threads {
776 QETH_SET_IP_THREAD = 1, 778 QETH_SET_IP_THREAD = 1,
777 QETH_RECOVER_THREAD = 2, 779 QETH_RECOVER_THREAD = 2,
780 QETH_SET_PROMISC_MODE_THREAD = 4,
778}; 781};
779 782
780struct qeth_osn_info { 783struct qeth_osn_info {
@@ -1074,6 +1077,26 @@ qeth_get_qdio_q_format(struct qeth_card *card)
1074 } 1077 }
1075} 1078}
1076 1079
1080static inline int
1081qeth_isdigit(char * buf)
1082{
1083 while (*buf) {
1084 if (!isdigit(*buf++))
1085 return 0;
1086 }
1087 return 1;
1088}
1089
1090static inline int
1091qeth_isxdigit(char * buf)
1092{
1093 while (*buf) {
1094 if (!isxdigit(*buf++))
1095 return 0;
1096 }
1097 return 1;
1098}
1099
1077static inline void 1100static inline void
1078qeth_ipaddr4_to_string(const __u8 *addr, char *buf) 1101qeth_ipaddr4_to_string(const __u8 *addr, char *buf)
1079{ 1102{
@@ -1090,18 +1113,27 @@ qeth_string_to_ipaddr4(const char *buf, __u8 *addr)
1090 int i; 1113 int i;
1091 1114
1092 start = buf; 1115 start = buf;
1093 for (i = 0; i < 3; i++) { 1116 for (i = 0; i < 4; i++) {
1094 if (!(end = strchr(start, '.'))) 1117 if (i == 3) {
1118 end = strchr(start,0xa);
1119 if (end)
1120 len = end - start;
1121 else
1122 len = strlen(start);
1123 }
1124 else {
1125 end = strchr(start, '.');
1126 len = end - start;
1127 }
1128 if ((len <= 0) || (len > 3))
1095 return -EINVAL; 1129 return -EINVAL;
1096 len = end - start;
1097 memset(abuf, 0, 4); 1130 memset(abuf, 0, 4);
1098 strncpy(abuf, start, len); 1131 strncpy(abuf, start, len);
1132 if (!qeth_isdigit(abuf))
1133 return -EINVAL;
1099 addr[i] = simple_strtoul(abuf, &tmp, 10); 1134 addr[i] = simple_strtoul(abuf, &tmp, 10);
1100 start = end + 1; 1135 start = end + 1;
1101 } 1136 }
1102 memset(abuf, 0, 4);
1103 strcpy(abuf, start);
1104 addr[3] = simple_strtoul(abuf, &tmp, 10);
1105 return 0; 1137 return 0;
1106} 1138}
1107 1139
@@ -1128,18 +1160,27 @@ qeth_string_to_ipaddr6(const char *buf, __u8 *addr)
1128 1160
1129 tmp_addr = (u16 *)addr; 1161 tmp_addr = (u16 *)addr;
1130 start = buf; 1162 start = buf;
1131 for (i = 0; i < 7; i++) { 1163 for (i = 0; i < 8; i++) {
1132 if (!(end = strchr(start, ':'))) 1164 if (i == 7) {
1165 end = strchr(start,0xa);
1166 if (end)
1167 len = end - start;
1168 else
1169 len = strlen(start);
1170 }
1171 else {
1172 end = strchr(start, ':');
1173 len = end - start;
1174 }
1175 if ((len <= 0) || (len > 4))
1133 return -EINVAL; 1176 return -EINVAL;
1134 len = end - start;
1135 memset(abuf, 0, 5); 1177 memset(abuf, 0, 5);
1136 strncpy(abuf, start, len); 1178 strncpy(abuf, start, len);
1179 if (!qeth_isxdigit(abuf))
1180 return -EINVAL;
1137 tmp_addr[i] = simple_strtoul(abuf, &tmp, 16); 1181 tmp_addr[i] = simple_strtoul(abuf, &tmp, 16);
1138 start = end + 1; 1182 start = end + 1;
1139 } 1183 }
1140 memset(abuf, 0, 5);
1141 strcpy(abuf, start);
1142 tmp_addr[7] = simple_strtoul(abuf, &tmp, 16);
1143 return 0; 1184 return 0;
1144} 1185}
1145 1186
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 692003c9f896..f8f55cc468ba 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.224 $) 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 *
@@ -9,10 +9,10 @@
9 * Author(s): Original Code written by 9 * Author(s): Original Code written by
10 * Utz Bacher (utz.bacher@de.ibm.com) 10 * Utz Bacher (utz.bacher@de.ibm.com)
11 * Rewritten by 11 * Rewritten by
12 * Frank Pavlic (pavlic@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.224 $ $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
@@ -72,7 +72,7 @@
72#include "qeth_eddp.h" 72#include "qeth_eddp.h"
73#include "qeth_tso.h" 73#include "qeth_tso.h"
74 74
75#define VERSION_QETH_C "$Revision: 1.224 $" 75#define VERSION_QETH_C "$Revision: 1.251 $"
76static const char *version = "qeth S/390 OSA-Express driver"; 76static const char *version = "qeth S/390 OSA-Express driver";
77 77
78/** 78/**
@@ -160,6 +160,9 @@ static void
160qeth_set_multicast_list(struct net_device *); 160qeth_set_multicast_list(struct net_device *);
161 161
162static void 162static void
163qeth_setadp_promisc_mode(struct qeth_card *);
164
165static void
163qeth_notify_processes(void) 166qeth_notify_processes(void)
164{ 167{
165 /*notify all registered processes */ 168 /*notify all registered processes */
@@ -515,7 +518,8 @@ __qeth_set_offline(struct ccwgroup_device *cgdev, int recovery_mode)
515 518
516 QETH_DBF_TEXT(setup, 3, "setoffl"); 519 QETH_DBF_TEXT(setup, 3, "setoffl");
517 QETH_DBF_HEX(setup, 3, &card, sizeof(void *)); 520 QETH_DBF_HEX(setup, 3, &card, sizeof(void *));
518 521
522 netif_carrier_off(card->dev);
519 recover_flag = card->state; 523 recover_flag = card->state;
520 if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){ 524 if (qeth_stop_card(card, recovery_mode) == -ERESTARTSYS){
521 PRINT_WARN("Stopping card %s interrupted by user!\n", 525 PRINT_WARN("Stopping card %s interrupted by user!\n",
@@ -602,11 +606,20 @@ __qeth_ref_ip_on_card(struct qeth_card *card, struct qeth_ipaddr *todo,
602 int found = 0; 606 int found = 0;
603 607
604 list_for_each_entry(addr, &card->ip_list, entry) { 608 list_for_each_entry(addr, &card->ip_list, entry) {
609 if (card->options.layer2) {
610 if ((addr->type == todo->type) &&
611 (memcmp(&addr->mac, &todo->mac,
612 OSA_ADDR_LEN) == 0)) {
613 found = 1;
614 break;
615 }
616 continue;
617 }
605 if ((addr->proto == QETH_PROT_IPV4) && 618 if ((addr->proto == QETH_PROT_IPV4) &&
606 (todo->proto == QETH_PROT_IPV4) && 619 (todo->proto == QETH_PROT_IPV4) &&
607 (addr->type == todo->type) && 620 (addr->type == todo->type) &&
608 (addr->u.a4.addr == todo->u.a4.addr) && 621 (addr->u.a4.addr == todo->u.a4.addr) &&
609 (addr->u.a4.mask == todo->u.a4.mask) ){ 622 (addr->u.a4.mask == todo->u.a4.mask)) {
610 found = 1; 623 found = 1;
611 break; 624 break;
612 } 625 }
@@ -615,12 +628,12 @@ __qeth_ref_ip_on_card(struct qeth_card *card, struct qeth_ipaddr *todo,
615 (addr->type == todo->type) && 628 (addr->type == todo->type) &&
616 (addr->u.a6.pfxlen == todo->u.a6.pfxlen) && 629 (addr->u.a6.pfxlen == todo->u.a6.pfxlen) &&
617 (memcmp(&addr->u.a6.addr, &todo->u.a6.addr, 630 (memcmp(&addr->u.a6.addr, &todo->u.a6.addr,
618 sizeof(struct in6_addr)) == 0)) { 631 sizeof(struct in6_addr)) == 0)) {
619 found = 1; 632 found = 1;
620 break; 633 break;
621 } 634 }
622 } 635 }
623 if (found){ 636 if (found) {
624 addr->users += todo->users; 637 addr->users += todo->users;
625 if (addr->users <= 0){ 638 if (addr->users <= 0){
626 *__addr = addr; 639 *__addr = addr;
@@ -632,7 +645,7 @@ __qeth_ref_ip_on_card(struct qeth_card *card, struct qeth_ipaddr *todo,
632 return 0; 645 return 0;
633 } 646 }
634 } 647 }
635 if (todo->users > 0){ 648 if (todo->users > 0) {
636 /* for VIPA and RXIP limit refcount to 1 */ 649 /* for VIPA and RXIP limit refcount to 1 */
637 if (todo->type != QETH_IP_TYPE_NORMAL) 650 if (todo->type != QETH_IP_TYPE_NORMAL)
638 todo->users = 1; 651 todo->users = 1;
@@ -682,12 +695,22 @@ __qeth_insert_ip_todo(struct qeth_card *card, struct qeth_ipaddr *addr, int add)
682 if ((addr->type == QETH_IP_TYPE_DEL_ALL_MC) && 695 if ((addr->type == QETH_IP_TYPE_DEL_ALL_MC) &&
683 (tmp->type == QETH_IP_TYPE_DEL_ALL_MC)) 696 (tmp->type == QETH_IP_TYPE_DEL_ALL_MC))
684 return 0; 697 return 0;
698 if (card->options.layer2) {
699 if ((tmp->type == addr->type) &&
700 (tmp->is_multicast == addr->is_multicast) &&
701 (memcmp(&tmp->mac, &addr->mac,
702 OSA_ADDR_LEN) == 0)) {
703 found = 1;
704 break;
705 }
706 continue;
707 }
685 if ((tmp->proto == QETH_PROT_IPV4) && 708 if ((tmp->proto == QETH_PROT_IPV4) &&
686 (addr->proto == QETH_PROT_IPV4) && 709 (addr->proto == QETH_PROT_IPV4) &&
687 (tmp->type == addr->type) && 710 (tmp->type == addr->type) &&
688 (tmp->is_multicast == addr->is_multicast) && 711 (tmp->is_multicast == addr->is_multicast) &&
689 (tmp->u.a4.addr == addr->u.a4.addr) && 712 (tmp->u.a4.addr == addr->u.a4.addr) &&
690 (tmp->u.a4.mask == addr->u.a4.mask) ){ 713 (tmp->u.a4.mask == addr->u.a4.mask)) {
691 found = 1; 714 found = 1;
692 break; 715 break;
693 } 716 }
@@ -697,7 +720,7 @@ __qeth_insert_ip_todo(struct qeth_card *card, struct qeth_ipaddr *addr, int add)
697 (tmp->is_multicast == addr->is_multicast) && 720 (tmp->is_multicast == addr->is_multicast) &&
698 (tmp->u.a6.pfxlen == addr->u.a6.pfxlen) && 721 (tmp->u.a6.pfxlen == addr->u.a6.pfxlen) &&
699 (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr, 722 (memcmp(&tmp->u.a6.addr, &addr->u.a6.addr,
700 sizeof(struct in6_addr)) == 0) ){ 723 sizeof(struct in6_addr)) == 0)) {
701 found = 1; 724 found = 1;
702 break; 725 break;
703 } 726 }
@@ -707,7 +730,7 @@ __qeth_insert_ip_todo(struct qeth_card *card, struct qeth_ipaddr *addr, int add)
707 tmp->users += addr->users; 730 tmp->users += addr->users;
708 else 731 else
709 tmp->users += add? 1:-1; 732 tmp->users += add? 1:-1;
710 if (tmp->users == 0){ 733 if (tmp->users == 0) {
711 list_del(&tmp->entry); 734 list_del(&tmp->entry);
712 kfree(tmp); 735 kfree(tmp);
713 } 736 }
@@ -738,12 +761,15 @@ qeth_delete_ip(struct qeth_card *card, struct qeth_ipaddr *addr)
738 unsigned long flags; 761 unsigned long flags;
739 int rc = 0; 762 int rc = 0;
740 763
741 QETH_DBF_TEXT(trace,4,"delip"); 764 QETH_DBF_TEXT(trace, 4, "delip");
742 if (addr->proto == QETH_PROT_IPV4) 765
743 QETH_DBF_HEX(trace,4,&addr->u.a4.addr,4); 766 if (card->options.layer2)
767 QETH_DBF_HEX(trace, 4, &addr->mac, 6);
768 else if (addr->proto == QETH_PROT_IPV4)
769 QETH_DBF_HEX(trace, 4, &addr->u.a4.addr, 4);
744 else { 770 else {
745 QETH_DBF_HEX(trace,4,&addr->u.a6.addr,8); 771 QETH_DBF_HEX(trace, 4, &addr->u.a6.addr, 8);
746 QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+8,8); 772 QETH_DBF_HEX(trace, 4, ((char *)&addr->u.a6.addr) + 8, 8);
747 } 773 }
748 spin_lock_irqsave(&card->ip_lock, flags); 774 spin_lock_irqsave(&card->ip_lock, flags);
749 rc = __qeth_insert_ip_todo(card, addr, 0); 775 rc = __qeth_insert_ip_todo(card, addr, 0);
@@ -757,12 +783,14 @@ qeth_add_ip(struct qeth_card *card, struct qeth_ipaddr *addr)
757 unsigned long flags; 783 unsigned long flags;
758 int rc = 0; 784 int rc = 0;
759 785
760 QETH_DBF_TEXT(trace,4,"addip"); 786 QETH_DBF_TEXT(trace, 4, "addip");
761 if (addr->proto == QETH_PROT_IPV4) 787 if (card->options.layer2)
762 QETH_DBF_HEX(trace,4,&addr->u.a4.addr,4); 788 QETH_DBF_HEX(trace, 4, &addr->mac, 6);
789 else if (addr->proto == QETH_PROT_IPV4)
790 QETH_DBF_HEX(trace, 4, &addr->u.a4.addr, 4);
763 else { 791 else {
764 QETH_DBF_HEX(trace,4,&addr->u.a6.addr,8); 792 QETH_DBF_HEX(trace, 4, &addr->u.a6.addr, 8);
765 QETH_DBF_HEX(trace,4,((char *)&addr->u.a6.addr)+8,8); 793 QETH_DBF_HEX(trace, 4, ((char *)&addr->u.a6.addr) + 8, 8);
766 } 794 }
767 spin_lock_irqsave(&card->ip_lock, flags); 795 spin_lock_irqsave(&card->ip_lock, flags);
768 rc = __qeth_insert_ip_todo(card, addr, 1); 796 rc = __qeth_insert_ip_todo(card, addr, 1);
@@ -775,7 +803,7 @@ __qeth_delete_all_mc(struct qeth_card *card, unsigned long *flags)
775{ 803{
776 struct qeth_ipaddr *addr, *tmp; 804 struct qeth_ipaddr *addr, *tmp;
777 int rc; 805 int rc;
778 806again:
779 list_for_each_entry_safe(addr, tmp, &card->ip_list, entry) { 807 list_for_each_entry_safe(addr, tmp, &card->ip_list, entry) {
780 if (addr->is_multicast) { 808 if (addr->is_multicast) {
781 spin_unlock_irqrestore(&card->ip_lock, *flags); 809 spin_unlock_irqrestore(&card->ip_lock, *flags);
@@ -784,6 +812,7 @@ __qeth_delete_all_mc(struct qeth_card *card, unsigned long *flags)
784 if (!rc) { 812 if (!rc) {
785 list_del(&addr->entry); 813 list_del(&addr->entry);
786 kfree(addr); 814 kfree(addr);
815 goto again;
787 } 816 }
788 } 817 }
789 } 818 }
@@ -851,6 +880,7 @@ qeth_set_ip_addr_list(struct qeth_card *card)
851 880
852static void qeth_delete_mc_addresses(struct qeth_card *); 881static void qeth_delete_mc_addresses(struct qeth_card *);
853static void qeth_add_multicast_ipv4(struct qeth_card *); 882static void qeth_add_multicast_ipv4(struct qeth_card *);
883static void qeth_layer2_add_multicast(struct qeth_card *);
854#ifdef CONFIG_QETH_IPV6 884#ifdef CONFIG_QETH_IPV6
855static void qeth_add_multicast_ipv6(struct qeth_card *); 885static void qeth_add_multicast_ipv6(struct qeth_card *);
856#endif 886#endif
@@ -939,6 +969,24 @@ qeth_register_ip_addresses(void *ptr)
939 return 0; 969 return 0;
940} 970}
941 971
972/*
973 * Drive the SET_PROMISC_MODE thread
974 */
975static int
976qeth_set_promisc_mode(void *ptr)
977{
978 struct qeth_card *card = (struct qeth_card *) ptr;
979
980 daemonize("qeth_setprm");
981 QETH_DBF_TEXT(trace,4,"setprm1");
982 if (!qeth_do_run_thread(card, QETH_SET_PROMISC_MODE_THREAD))
983 return 0;
984 QETH_DBF_TEXT(trace,4,"setprm2");
985 qeth_setadp_promisc_mode(card);
986 qeth_clear_thread_running_bit(card, QETH_SET_PROMISC_MODE_THREAD);
987 return 0;
988}
989
942static int 990static int
943qeth_recover(void *ptr) 991qeth_recover(void *ptr)
944{ 992{
@@ -973,7 +1021,6 @@ void
973qeth_schedule_recovery(struct qeth_card *card) 1021qeth_schedule_recovery(struct qeth_card *card)
974{ 1022{
975 QETH_DBF_TEXT(trace,2,"startrec"); 1023 QETH_DBF_TEXT(trace,2,"startrec");
976
977 if (qeth_set_thread_start_bit(card, QETH_RECOVER_THREAD) == 0) 1024 if (qeth_set_thread_start_bit(card, QETH_RECOVER_THREAD) == 0)
978 schedule_work(&card->kernel_thread_starter); 1025 schedule_work(&card->kernel_thread_starter);
979} 1026}
@@ -1005,6 +1052,8 @@ qeth_start_kernel_thread(struct qeth_card *card)
1005 1052
1006 if (qeth_do_start_thread(card, QETH_SET_IP_THREAD)) 1053 if (qeth_do_start_thread(card, QETH_SET_IP_THREAD))
1007 kernel_thread(qeth_register_ip_addresses, (void *)card,SIGCHLD); 1054 kernel_thread(qeth_register_ip_addresses, (void *)card,SIGCHLD);
1055 if (qeth_do_start_thread(card, QETH_SET_PROMISC_MODE_THREAD))
1056 kernel_thread(qeth_set_promisc_mode, (void *)card, SIGCHLD);
1008 if (qeth_do_start_thread(card, QETH_RECOVER_THREAD)) 1057 if (qeth_do_start_thread(card, QETH_RECOVER_THREAD))
1009 kernel_thread(qeth_recover, (void *) card, SIGCHLD); 1058 kernel_thread(qeth_recover, (void *) card, SIGCHLD);
1010} 1059}
@@ -1661,7 +1710,6 @@ qeth_check_ipa_data(struct qeth_card *card, struct qeth_cmd_buffer *iob)
1661 "IP address reset.\n", 1710 "IP address reset.\n",
1662 QETH_CARD_IFNAME(card), 1711 QETH_CARD_IFNAME(card),
1663 card->info.chpid); 1712 card->info.chpid);
1664 netif_carrier_on(card->dev);
1665 qeth_schedule_recovery(card); 1713 qeth_schedule_recovery(card);
1666 return NULL; 1714 return NULL;
1667 case IPA_CMD_MODCCID: 1715 case IPA_CMD_MODCCID:
@@ -1910,7 +1958,7 @@ qeth_osn_send_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
1910{ 1958{
1911 u16 s1, s2; 1959 u16 s1, s2;
1912 1960
1913QETH_DBF_TEXT(trace,4,"osndipa"); 1961 QETH_DBF_TEXT(trace,4,"osndipa");
1914 1962
1915 qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2); 1963 qeth_prepare_ipa_cmd(card, iob, QETH_PROT_OSN2);
1916 s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len); 1964 s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len);
@@ -2154,24 +2202,21 @@ qeth_ulp_setup(struct qeth_card *card)
2154} 2202}
2155 2203
2156static inline int 2204static inline int
2157qeth_check_for_inbound_error(struct qeth_qdio_buffer *buf, 2205qeth_check_qdio_errors(struct qdio_buffer *buf, unsigned int qdio_error,
2158 unsigned int qdio_error, 2206 unsigned int siga_error, const char *dbftext)
2159 unsigned int siga_error)
2160{ 2207{
2161 int rc = 0;
2162
2163 if (qdio_error || siga_error) { 2208 if (qdio_error || siga_error) {
2164 QETH_DBF_TEXT(trace, 2, "qdinerr"); 2209 QETH_DBF_TEXT(trace, 2, dbftext);
2165 QETH_DBF_TEXT(qerr, 2, "qdinerr"); 2210 QETH_DBF_TEXT(qerr, 2, dbftext);
2166 QETH_DBF_TEXT_(qerr, 2, " F15=%02X", 2211 QETH_DBF_TEXT_(qerr, 2, " F15=%02X",
2167 buf->buffer->element[15].flags & 0xff); 2212 buf->element[15].flags & 0xff);
2168 QETH_DBF_TEXT_(qerr, 2, " F14=%02X", 2213 QETH_DBF_TEXT_(qerr, 2, " F14=%02X",
2169 buf->buffer->element[14].flags & 0xff); 2214 buf->element[14].flags & 0xff);
2170 QETH_DBF_TEXT_(qerr, 2, " qerr=%X", qdio_error); 2215 QETH_DBF_TEXT_(qerr, 2, " qerr=%X", qdio_error);
2171 QETH_DBF_TEXT_(qerr, 2, " serr=%X", siga_error); 2216 QETH_DBF_TEXT_(qerr, 2, " serr=%X", siga_error);
2172 rc = 1; 2217 return 1;
2173 } 2218 }
2174 return rc; 2219 return 0;
2175} 2220}
2176 2221
2177static inline struct sk_buff * 2222static inline struct sk_buff *
@@ -2720,8 +2765,9 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status,
2720 for (i = first_element; i < (first_element + count); ++i) { 2765 for (i = first_element; i < (first_element + count); ++i) {
2721 index = i % QDIO_MAX_BUFFERS_PER_Q; 2766 index = i % QDIO_MAX_BUFFERS_PER_Q;
2722 buffer = &card->qdio.in_q->bufs[index]; 2767 buffer = &card->qdio.in_q->bufs[index];
2723 if (!((status == QDIO_STATUS_LOOK_FOR_ERROR) && 2768 if (!((status & QDIO_STATUS_LOOK_FOR_ERROR) &&
2724 qeth_check_for_inbound_error(buffer, qdio_err, siga_err))) 2769 qeth_check_qdio_errors(buffer->buffer,
2770 qdio_err, siga_err,"qinerr")))
2725 qeth_process_inbound_buffer(card, buffer, index); 2771 qeth_process_inbound_buffer(card, buffer, index);
2726 /* clear buffer and give back to hardware */ 2772 /* clear buffer and give back to hardware */
2727 qeth_put_buffer_pool_entry(card, buffer->pool_entry); 2773 qeth_put_buffer_pool_entry(card, buffer->pool_entry);
@@ -2736,12 +2782,13 @@ qeth_qdio_input_handler(struct ccw_device * ccwdev, unsigned int status,
2736static inline int 2782static inline int
2737qeth_handle_send_error(struct qeth_card *card, 2783qeth_handle_send_error(struct qeth_card *card,
2738 struct qeth_qdio_out_buffer *buffer, 2784 struct qeth_qdio_out_buffer *buffer,
2739 int qdio_err, int siga_err) 2785 unsigned int qdio_err, unsigned int siga_err)
2740{ 2786{
2741 int sbalf15 = buffer->buffer->element[15].flags & 0xff; 2787 int sbalf15 = buffer->buffer->element[15].flags & 0xff;
2742 int cc = siga_err & 3; 2788 int cc = siga_err & 3;
2743 2789
2744 QETH_DBF_TEXT(trace, 6, "hdsnderr"); 2790 QETH_DBF_TEXT(trace, 6, "hdsnderr");
2791 qeth_check_qdio_errors(buffer->buffer, qdio_err, siga_err, "qouterr");
2745 switch (cc) { 2792 switch (cc) {
2746 case 0: 2793 case 0:
2747 if (qdio_err){ 2794 if (qdio_err){
@@ -2998,7 +3045,8 @@ qeth_qdio_output_handler(struct ccw_device * ccwdev, unsigned int status,
2998 for(i = first_element; i < (first_element + count); ++i){ 3045 for(i = first_element; i < (first_element + count); ++i){
2999 buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q]; 3046 buffer = &queue->bufs[i % QDIO_MAX_BUFFERS_PER_Q];
3000 /*we only handle the KICK_IT error by doing a recovery */ 3047 /*we only handle the KICK_IT error by doing a recovery */
3001 if (qeth_handle_send_error(card, buffer, qdio_error, siga_error) 3048 if (qeth_handle_send_error(card, buffer,
3049 qdio_error, siga_error)
3002 == QETH_SEND_ERROR_KICK_IT){ 3050 == QETH_SEND_ERROR_KICK_IT){
3003 netif_stop_queue(card->dev); 3051 netif_stop_queue(card->dev);
3004 qeth_schedule_recovery(card); 3052 qeth_schedule_recovery(card);
@@ -3240,7 +3288,6 @@ qeth_init_qdio_info(struct qeth_card *card)
3240 card->qdio.in_buf_pool.buf_count = card->qdio.init_pool.buf_count; 3288 card->qdio.in_buf_pool.buf_count = card->qdio.init_pool.buf_count;
3241 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list); 3289 INIT_LIST_HEAD(&card->qdio.in_buf_pool.entry_list);
3242 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list); 3290 INIT_LIST_HEAD(&card->qdio.init_pool.entry_list);
3243 /* outbound */
3244} 3291}
3245 3292
3246static int 3293static int
@@ -3682,6 +3729,9 @@ qeth_verify_vlan_dev(struct net_device *dev, struct qeth_card *card)
3682 break; 3729 break;
3683 } 3730 }
3684 } 3731 }
3732 if (rc && !(VLAN_DEV_INFO(dev)->real_dev->priv == (void *)card))
3733 return 0;
3734
3685#endif 3735#endif
3686 return rc; 3736 return rc;
3687} 3737}
@@ -3749,7 +3799,7 @@ qeth_open(struct net_device *dev)
3749 3799
3750 if ( (card->info.type != QETH_CARD_TYPE_OSN) && 3800 if ( (card->info.type != QETH_CARD_TYPE_OSN) &&
3751 (card->options.layer2) && 3801 (card->options.layer2) &&
3752 (!card->info.layer2_mac_registered)) { 3802 (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))) {
3753 QETH_DBF_TEXT(trace,4,"nomacadr"); 3803 QETH_DBF_TEXT(trace,4,"nomacadr");
3754 return -EPERM; 3804 return -EPERM;
3755 } 3805 }
@@ -3758,10 +3808,8 @@ qeth_open(struct net_device *dev)
3758 card->data.state = CH_STATE_UP; 3808 card->data.state = CH_STATE_UP;
3759 card->state = CARD_STATE_UP; 3809 card->state = CARD_STATE_UP;
3760 3810
3761 if (!card->lan_online){ 3811 if (!card->lan_online && netif_carrier_ok(dev))
3762 if (netif_carrier_ok(dev)) 3812 netif_carrier_off(dev);
3763 netif_carrier_off(dev);
3764 }
3765 return 0; 3813 return 0;
3766} 3814}
3767 3815
@@ -4311,6 +4359,8 @@ qeth_do_send_packet(struct qeth_card *card, struct qeth_qdio_out_q *queue,
4311out: 4359out:
4312 if (flush_count) 4360 if (flush_count)
4313 qeth_flush_buffers(queue, 0, start_index, flush_count); 4361 qeth_flush_buffers(queue, 0, start_index, flush_count);
4362 else if (!atomic_read(&queue->set_pci_flags_count))
4363 atomic_swap(&queue->state, QETH_OUT_Q_LOCKED_FLUSH);
4314 /* 4364 /*
4315 * queue->state will go from LOCKED -> UNLOCKED or from 4365 * queue->state will go from LOCKED -> UNLOCKED or from
4316 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us 4366 * LOCKED_FLUSH -> LOCKED if output_handler wanted to 'notify' us
@@ -4975,6 +5025,10 @@ qeth_default_setassparms_cb(struct qeth_card *, struct qeth_reply *,
4975 unsigned long); 5025 unsigned long);
4976 5026
4977static int 5027static int
5028qeth_default_setadapterparms_cb(struct qeth_card *card,
5029 struct qeth_reply *reply,
5030 unsigned long data);
5031static int
4978qeth_send_setassparms(struct qeth_card *, struct qeth_cmd_buffer *, 5032qeth_send_setassparms(struct qeth_card *, struct qeth_cmd_buffer *,
4979 __u16, long, 5033 __u16, long,
4980 int (*reply_cb) 5034 int (*reply_cb)
@@ -5301,8 +5355,7 @@ qeth_free_vlan_addresses4(struct qeth_card *card, unsigned short vid)
5301 struct qeth_ipaddr *addr; 5355 struct qeth_ipaddr *addr;
5302 5356
5303 QETH_DBF_TEXT(trace, 4, "frvaddr4"); 5357 QETH_DBF_TEXT(trace, 4, "frvaddr4");
5304 if (!card->vlangrp) 5358
5305 return;
5306 rcu_read_lock(); 5359 rcu_read_lock();
5307 in_dev = __in_dev_get_rcu(card->vlangrp->vlan_devices[vid]); 5360 in_dev = __in_dev_get_rcu(card->vlangrp->vlan_devices[vid]);
5308 if (!in_dev) 5361 if (!in_dev)
@@ -5330,8 +5383,7 @@ qeth_free_vlan_addresses6(struct qeth_card *card, unsigned short vid)
5330 struct qeth_ipaddr *addr; 5383 struct qeth_ipaddr *addr;
5331 5384
5332 QETH_DBF_TEXT(trace, 4, "frvaddr6"); 5385 QETH_DBF_TEXT(trace, 4, "frvaddr6");
5333 if (!card->vlangrp) 5386
5334 return;
5335 in6_dev = in6_dev_get(card->vlangrp->vlan_devices[vid]); 5387 in6_dev = in6_dev_get(card->vlangrp->vlan_devices[vid]);
5336 if (!in6_dev) 5388 if (!in6_dev)
5337 return; 5389 return;
@@ -5351,10 +5403,38 @@ qeth_free_vlan_addresses6(struct qeth_card *card, unsigned short vid)
5351} 5403}
5352 5404
5353static void 5405static void
5406qeth_free_vlan_addresses(struct qeth_card *card, unsigned short vid)
5407{
5408 if (card->options.layer2 || !card->vlangrp)
5409 return;
5410 qeth_free_vlan_addresses4(card, vid);
5411 qeth_free_vlan_addresses6(card, vid);
5412}
5413
5414static int
5415qeth_layer2_send_setdelvlan_cb(struct qeth_card *card,
5416 struct qeth_reply *reply,
5417 unsigned long data)
5418{
5419 struct qeth_ipa_cmd *cmd;
5420
5421 QETH_DBF_TEXT(trace, 2, "L2sdvcb");
5422 cmd = (struct qeth_ipa_cmd *) data;
5423 if (cmd->hdr.return_code) {
5424 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
5425 "Continuing\n",cmd->data.setdelvlan.vlan_id,
5426 QETH_CARD_IFNAME(card), cmd->hdr.return_code);
5427 QETH_DBF_TEXT_(trace, 2, "L2VL%4x", cmd->hdr.command);
5428 QETH_DBF_TEXT_(trace, 2, "L2%s", CARD_BUS_ID(card));
5429 QETH_DBF_TEXT_(trace, 2, "err%d", cmd->hdr.return_code);
5430 }
5431 return 0;
5432}
5433
5434static int
5354qeth_layer2_send_setdelvlan(struct qeth_card *card, __u16 i, 5435qeth_layer2_send_setdelvlan(struct qeth_card *card, __u16 i,
5355 enum qeth_ipa_cmds ipacmd) 5436 enum qeth_ipa_cmds ipacmd)
5356{ 5437{
5357 int rc;
5358 struct qeth_ipa_cmd *cmd; 5438 struct qeth_ipa_cmd *cmd;
5359 struct qeth_cmd_buffer *iob; 5439 struct qeth_cmd_buffer *iob;
5360 5440
@@ -5362,15 +5442,8 @@ qeth_layer2_send_setdelvlan(struct qeth_card *card, __u16 i,
5362 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); 5442 iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4);
5363 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE); 5443 cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
5364 cmd->data.setdelvlan.vlan_id = i; 5444 cmd->data.setdelvlan.vlan_id = i;
5365 5445 return qeth_send_ipa_cmd(card, iob,
5366 rc = qeth_send_ipa_cmd(card, iob, NULL, NULL); 5446 qeth_layer2_send_setdelvlan_cb, NULL);
5367 if (rc) {
5368 PRINT_ERR("Error in processing VLAN %i on %s: 0x%x. "
5369 "Continuing\n",i, QETH_CARD_IFNAME(card), rc);
5370 QETH_DBF_TEXT_(trace, 2, "L2VL%4x", ipacmd);
5371 QETH_DBF_TEXT_(trace, 2, "L2%s", CARD_BUS_ID(card));
5372 QETH_DBF_TEXT_(trace, 2, "err%d", rc);
5373 }
5374} 5447}
5375 5448
5376static void 5449static void
@@ -5420,8 +5493,7 @@ qeth_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
5420 qeth_free_vlan_skbs(card, vid); 5493 qeth_free_vlan_skbs(card, vid);
5421 spin_lock_irqsave(&card->vlanlock, flags); 5494 spin_lock_irqsave(&card->vlanlock, flags);
5422 /* unregister IP addresses of vlan device */ 5495 /* unregister IP addresses of vlan device */
5423 qeth_free_vlan_addresses4(card, vid); 5496 qeth_free_vlan_addresses(card, vid);
5424 qeth_free_vlan_addresses6(card, vid);
5425 if (card->vlangrp) 5497 if (card->vlangrp)
5426 card->vlangrp->vlan_devices[vid] = NULL; 5498 card->vlangrp->vlan_devices[vid] = NULL;
5427 spin_unlock_irqrestore(&card->vlanlock, flags); 5499 spin_unlock_irqrestore(&card->vlanlock, flags);
@@ -5430,6 +5502,59 @@ qeth_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
5430 qeth_set_multicast_list(card->dev); 5502 qeth_set_multicast_list(card->dev);
5431} 5503}
5432#endif 5504#endif
5505/**
5506 * Examine hardware response to SET_PROMISC_MODE
5507 */
5508static int
5509qeth_setadp_promisc_mode_cb(struct qeth_card *card,
5510 struct qeth_reply *reply,
5511 unsigned long data)
5512{
5513 struct qeth_ipa_cmd *cmd;
5514 struct qeth_ipacmd_setadpparms *setparms;
5515
5516 QETH_DBF_TEXT(trace,4,"prmadpcb");
5517
5518 cmd = (struct qeth_ipa_cmd *) data;
5519 setparms = &(cmd->data.setadapterparms);
5520
5521 qeth_default_setadapterparms_cb(card, reply, (unsigned long)cmd);
5522 if (cmd->hdr.return_code) {
5523 QETH_DBF_TEXT_(trace,4,"prmrc%2.2x",cmd->hdr.return_code);
5524 setparms->data.mode = SET_PROMISC_MODE_OFF;
5525 }
5526 card->info.promisc_mode = setparms->data.mode;
5527 return 0;
5528}
5529/*
5530 * Set promiscuous mode (on or off) (SET_PROMISC_MODE command)
5531 */
5532static void
5533qeth_setadp_promisc_mode(struct qeth_card *card)
5534{
5535 enum qeth_ipa_promisc_modes mode;
5536 struct net_device *dev = card->dev;
5537 struct qeth_cmd_buffer *iob;
5538 struct qeth_ipa_cmd *cmd;
5539
5540 QETH_DBF_TEXT(trace, 4, "setprom");
5541
5542 if (((dev->flags & IFF_PROMISC) &&
5543 (card->info.promisc_mode == SET_PROMISC_MODE_ON)) ||
5544 (!(dev->flags & IFF_PROMISC) &&
5545 (card->info.promisc_mode == SET_PROMISC_MODE_OFF)))
5546 return;
5547 mode = SET_PROMISC_MODE_OFF;
5548 if (dev->flags & IFF_PROMISC)
5549 mode = SET_PROMISC_MODE_ON;
5550 QETH_DBF_TEXT_(trace, 4, "mode:%x", mode);
5551
5552 iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_PROMISC_MODE,
5553 sizeof(struct qeth_ipacmd_setadpparms));
5554 cmd = (struct qeth_ipa_cmd *)(iob->data + IPA_PDU_HEADER_SIZE);
5555 cmd->data.setadapterparms.data.mode = mode;
5556 qeth_send_ipa_cmd(card, iob, qeth_setadp_promisc_mode_cb, NULL);
5557}
5433 5558
5434/** 5559/**
5435 * set multicast address on card 5560 * set multicast address on card
@@ -5444,12 +5569,22 @@ qeth_set_multicast_list(struct net_device *dev)
5444 5569
5445 QETH_DBF_TEXT(trace,3,"setmulti"); 5570 QETH_DBF_TEXT(trace,3,"setmulti");
5446 qeth_delete_mc_addresses(card); 5571 qeth_delete_mc_addresses(card);
5572 if (card->options.layer2) {
5573 qeth_layer2_add_multicast(card);
5574 goto out;
5575 }
5447 qeth_add_multicast_ipv4(card); 5576 qeth_add_multicast_ipv4(card);
5448#ifdef CONFIG_QETH_IPV6 5577#ifdef CONFIG_QETH_IPV6
5449 qeth_add_multicast_ipv6(card); 5578 qeth_add_multicast_ipv6(card);
5450#endif 5579#endif
5580out:
5451 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0) 5581 if (qeth_set_thread_start_bit(card, QETH_SET_IP_THREAD) == 0)
5452 schedule_work(&card->kernel_thread_starter); 5582 schedule_work(&card->kernel_thread_starter);
5583 if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE))
5584 return;
5585 if (qeth_set_thread_start_bit(card, QETH_SET_PROMISC_MODE_THREAD)==0)
5586 schedule_work(&card->kernel_thread_starter);
5587
5453} 5588}
5454 5589
5455static int 5590static int
@@ -5657,6 +5792,24 @@ qeth_add_multicast_ipv4(struct qeth_card *card)
5657 in_dev_put(in4_dev); 5792 in_dev_put(in4_dev);
5658} 5793}
5659 5794
5795static void
5796qeth_layer2_add_multicast(struct qeth_card *card)
5797{
5798 struct qeth_ipaddr *ipm;
5799 struct dev_mc_list *dm;
5800
5801 QETH_DBF_TEXT(trace,4,"L2addmc");
5802 for (dm = card->dev->mc_list; dm; dm = dm->next) {
5803 ipm = qeth_get_addr_buffer(QETH_PROT_IPV4);
5804 if (!ipm)
5805 continue;
5806 memcpy(ipm->mac,dm->dmi_addr,MAX_ADDR_LEN);
5807 ipm->is_multicast = 1;
5808 if (!qeth_add_ip(card, ipm))
5809 kfree(ipm);
5810 }
5811}
5812
5660#ifdef CONFIG_QETH_IPV6 5813#ifdef CONFIG_QETH_IPV6
5661static inline void 5814static inline void
5662qeth_add_mc6(struct qeth_card *card, struct inet6_dev *in6_dev) 5815qeth_add_mc6(struct qeth_card *card, struct inet6_dev *in6_dev)
@@ -5716,10 +5869,8 @@ qeth_add_multicast_ipv6(struct qeth_card *card)
5716 struct inet6_dev *in6_dev; 5869 struct inet6_dev *in6_dev;
5717 5870
5718 QETH_DBF_TEXT(trace,4,"chkmcv6"); 5871 QETH_DBF_TEXT(trace,4,"chkmcv6");
5719 if ((card->options.layer2 == 0) && 5872 if (!qeth_is_supported(card, IPA_IPV6))
5720 (!qeth_is_supported(card, IPA_IPV6)) )
5721 return ; 5873 return ;
5722
5723 in6_dev = in6_dev_get(card->dev); 5874 in6_dev = in6_dev_get(card->dev);
5724 if (in6_dev == NULL) 5875 if (in6_dev == NULL)
5725 return; 5876 return;
@@ -5825,10 +5976,10 @@ qeth_layer2_send_setmac_cb(struct qeth_card *card,
5825 PRINT_WARN("Error in registering MAC address on " \ 5976 PRINT_WARN("Error in registering MAC address on " \
5826 "device %s: x%x\n", CARD_BUS_ID(card), 5977 "device %s: x%x\n", CARD_BUS_ID(card),
5827 cmd->hdr.return_code); 5978 cmd->hdr.return_code);
5828 card->info.layer2_mac_registered = 0; 5979 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
5829 cmd->hdr.return_code = -EIO; 5980 cmd->hdr.return_code = -EIO;
5830 } else { 5981 } else {
5831 card->info.layer2_mac_registered = 1; 5982 card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED;
5832 memcpy(card->dev->dev_addr,cmd->data.setdelmac.mac, 5983 memcpy(card->dev->dev_addr,cmd->data.setdelmac.mac,
5833 OSA_ADDR_LEN); 5984 OSA_ADDR_LEN);
5834 PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x " 5985 PRINT_INFO("MAC address %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x "
@@ -5866,7 +6017,7 @@ qeth_layer2_send_delmac_cb(struct qeth_card *card,
5866 cmd->hdr.return_code = -EIO; 6017 cmd->hdr.return_code = -EIO;
5867 return 0; 6018 return 0;
5868 } 6019 }
5869 card->info.layer2_mac_registered = 0; 6020 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
5870 6021
5871 return 0; 6022 return 0;
5872} 6023}
@@ -5874,7 +6025,7 @@ static int
5874qeth_layer2_send_delmac(struct qeth_card *card, __u8 *mac) 6025qeth_layer2_send_delmac(struct qeth_card *card, __u8 *mac)
5875{ 6026{
5876 QETH_DBF_TEXT(trace, 2, "L2Delmac"); 6027 QETH_DBF_TEXT(trace, 2, "L2Delmac");
5877 if (!card->info.layer2_mac_registered) 6028 if (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))
5878 return 0; 6029 return 0;
5879 return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_DELVMAC, 6030 return qeth_layer2_send_setdelmac(card, mac, IPA_CMD_DELVMAC,
5880 qeth_layer2_send_delmac_cb); 6031 qeth_layer2_send_delmac_cb);
@@ -5896,7 +6047,7 @@ qeth_layer2_set_mac_address(struct net_device *dev, void *p)
5896 card = (struct qeth_card *) dev->priv; 6047 card = (struct qeth_card *) dev->priv;
5897 6048
5898 if (!card->options.layer2) { 6049 if (!card->options.layer2) {
5899 PRINT_WARN("Setting MAC address on %s is not supported" 6050 PRINT_WARN("Setting MAC address on %s is not supported "
5900 "in Layer 3 mode.\n", dev->name); 6051 "in Layer 3 mode.\n", dev->name);
5901 QETH_DBF_TEXT(trace, 3, "setmcLY3"); 6052 QETH_DBF_TEXT(trace, 3, "setmcLY3");
5902 return -EOPNOTSUPP; 6053 return -EOPNOTSUPP;
@@ -6441,6 +6592,8 @@ qeth_default_setadapterparms_cb(struct qeth_card *card,
6441 return 0; 6592 return 0;
6442} 6593}
6443 6594
6595
6596
6444static int 6597static int
6445qeth_query_setadapterparms_cb(struct qeth_card *card, struct qeth_reply *reply, 6598qeth_query_setadapterparms_cb(struct qeth_card *card, struct qeth_reply *reply,
6446 unsigned long data) 6599 unsigned long data)
@@ -6481,8 +6634,13 @@ qeth_setadpparms_change_macaddr_cb(struct qeth_card *card,
6481 QETH_DBF_TEXT(trace,4,"chgmaccb"); 6634 QETH_DBF_TEXT(trace,4,"chgmaccb");
6482 6635
6483 cmd = (struct qeth_ipa_cmd *) data; 6636 cmd = (struct qeth_ipa_cmd *) data;
6484 memcpy(card->dev->dev_addr, 6637 if (!card->options.layer2 || card->info.guestlan ||
6485 &cmd->data.setadapterparms.data.change_addr.addr,OSA_ADDR_LEN); 6638 !(card->info.mac_bits & QETH_LAYER2_MAC_READ)) {
6639 memcpy(card->dev->dev_addr,
6640 &cmd->data.setadapterparms.data.change_addr.addr,
6641 OSA_ADDR_LEN);
6642 card->info.mac_bits |= QETH_LAYER2_MAC_READ;
6643 }
6486 qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd); 6644 qeth_default_setadapterparms_cb(card, reply, (unsigned long) cmd);
6487 return 0; 6645 return 0;
6488} 6646}
@@ -6602,6 +6760,12 @@ qeth_layer2_initialize(struct qeth_card *card)
6602 QETH_DBF_TEXT(setup, 2, "doL2init"); 6760 QETH_DBF_TEXT(setup, 2, "doL2init");
6603 QETH_DBF_TEXT_(setup, 2, "doL2%s", CARD_BUS_ID(card)); 6761 QETH_DBF_TEXT_(setup, 2, "doL2%s", CARD_BUS_ID(card));
6604 6762
6763 rc = qeth_query_setadapterparms(card);
6764 if (rc) {
6765 PRINT_WARN("could not query adapter parameters on device %s: "
6766 "x%x\n", CARD_BUS_ID(card), rc);
6767 }
6768
6605 rc = qeth_setadpparms_change_macaddr(card); 6769 rc = qeth_setadpparms_change_macaddr(card);
6606 if (rc) { 6770 if (rc) {
6607 PRINT_WARN("couldn't get MAC address on " 6771 PRINT_WARN("couldn't get MAC address on "
@@ -7769,8 +7933,8 @@ __qeth_set_online(struct ccwgroup_device *gdev, int recovery_mode)
7769 QETH_DBF_TEXT_(setup, 2, "6err%d", rc); 7933 QETH_DBF_TEXT_(setup, 2, "6err%d", rc);
7770 goto out_remove; 7934 goto out_remove;
7771 } 7935 }
7772/*maybe it was set offline without ifconfig down 7936 netif_carrier_on(card->dev);
7773 * we can also use this state for recovery purposes*/ 7937
7774 qeth_set_allowed_threads(card, 0xffffffff, 0); 7938 qeth_set_allowed_threads(card, 0xffffffff, 0);
7775 if (recover_flag == CARD_STATE_RECOVER) 7939 if (recover_flag == CARD_STATE_RECOVER)
7776 qeth_start_again(card, recovery_mode); 7940 qeth_start_again(card, recovery_mode);
@@ -8548,7 +8712,7 @@ EXPORT_SYMBOL(qeth_osn_deregister);
8548EXPORT_SYMBOL(qeth_osn_assist); 8712EXPORT_SYMBOL(qeth_osn_assist);
8549module_init(qeth_init); 8713module_init(qeth_init);
8550module_exit(qeth_exit); 8714module_exit(qeth_exit);
8551MODULE_AUTHOR("Frank Pavlic <pavlic@de.ibm.com>"); 8715MODULE_AUTHOR("Frank Pavlic <fpavlic@de.ibm.com>");
8552MODULE_DESCRIPTION("Linux on zSeries OSA Express and HiperSockets support\n" \ 8716MODULE_DESCRIPTION("Linux on zSeries OSA Express and HiperSockets support\n" \
8553 "Copyright 2000,2003 IBM Corporation\n"); 8717 "Copyright 2000,2003 IBM Corporation\n");
8554 8718
diff --git a/drivers/s390/net/qeth_mpc.c b/drivers/s390/net/qeth_mpc.c
index 30e053d3cac2..5f8754addc14 100644
--- a/drivers/s390/net/qeth_mpc.c
+++ b/drivers/s390/net/qeth_mpc.c
@@ -4,14 +4,14 @@
4 * Linux on zSeries OSA Express and HiperSockets support 4 * Linux on zSeries OSA Express and HiperSockets support
5 * 5 *
6 * Copyright 2000,2003 IBM Corporation 6 * Copyright 2000,2003 IBM Corporation
7 * Author(s): Frank Pavlic <pavlic@de.ibm.com> 7 * Author(s): Frank Pavlic <fpavlic@de.ibm.com>
8 * Thomas Spatzier <tspat@de.ibm.com> 8 * Thomas Spatzier <tspat@de.ibm.com>
9 * 9 *
10 */ 10 */
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 7edc5f1fc0d2..864cec5f6c62 100644
--- a/drivers/s390/net/qeth_mpc.h
+++ b/drivers/s390/net/qeth_mpc.h
@@ -6,7 +6,7 @@
6 * Copyright 2000,2003 IBM Corporation 6 * Copyright 2000,2003 IBM Corporation
7 * Author(s): Utz Bacher <utz.bacher@de.ibm.com> 7 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>
8 * Thomas Spatzier <tspat@de.ibm.com> 8 * Thomas Spatzier <tspat@de.ibm.com>
9 * Frank Pavlic <pavlic@de.ibm.com> 9 * Frank Pavlic <fpavlic@de.ibm.com>
10 * 10 *
11 */ 11 */
12#ifndef __QETH_MPC_H__ 12#ifndef __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.43 $" 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[];
@@ -217,7 +217,7 @@ enum qeth_ipa_setadp_cmd {
217 IPA_SETADP_SEND_OSA_MESSAGE = 0x0100, 217 IPA_SETADP_SEND_OSA_MESSAGE = 0x0100,
218 IPA_SETADP_SET_SNMP_CONTROL = 0x0200, 218 IPA_SETADP_SET_SNMP_CONTROL = 0x0200,
219 IPA_SETADP_READ_SNMP_PARMS = 0x0400, 219 IPA_SETADP_READ_SNMP_PARMS = 0x0400,
220 IPA_SETADP_WRITE_SNMP_PARMS = 0x0800, 220 IPA_SETADP_SET_PROMISC_MODE = 0x0800,
221 IPA_SETADP_QUERY_CARD_INFO = 0x1000, 221 IPA_SETADP_QUERY_CARD_INFO = 0x1000,
222}; 222};
223enum qeth_ipa_mac_ops { 223enum qeth_ipa_mac_ops {
@@ -232,9 +232,12 @@ enum qeth_ipa_addr_ops {
232 CHANGE_ADDR_ADD_ADDR = 1, 232 CHANGE_ADDR_ADD_ADDR = 1,
233 CHANGE_ADDR_DEL_ADDR = 2, 233 CHANGE_ADDR_DEL_ADDR = 2,
234 CHANGE_ADDR_FLUSH_ADDR_TABLE = 4, 234 CHANGE_ADDR_FLUSH_ADDR_TABLE = 4,
235
236
237}; 235};
236enum qeth_ipa_promisc_modes {
237 SET_PROMISC_MODE_OFF = 0,
238 SET_PROMISC_MODE_ON = 1,
239};
240
238/* (SET)DELIP(M) IPA stuff ***************************************************/ 241/* (SET)DELIP(M) IPA stuff ***************************************************/
239struct qeth_ipacmd_setdelip4 { 242struct qeth_ipacmd_setdelip4 {
240 __u8 ip_addr[4]; 243 __u8 ip_addr[4];
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 f91a02db5743..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.55 $) 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.
@@ -8,7 +8,7 @@
8 * Copyright 2000,2003 IBM Corporation 8 * Copyright 2000,2003 IBM Corporation
9 * 9 *
10 * Author(s): Thomas Spatzier <tspat@de.ibm.com> 10 * Author(s): Thomas Spatzier <tspat@de.ibm.com>
11 * Frank Pavlic <pavlic@de.ibm.com> 11 * Frank Pavlic <fpavlic@de.ibm.com>
12 * 12 *
13 */ 13 */
14#include <linux/list.h> 14#include <linux/list.h>
@@ -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.55 $"; 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);
@@ -1117,7 +1117,7 @@ qeth_parse_ipatoe(const char* buf, enum qeth_prot_versions proto,
1117 start = buf; 1117 start = buf;
1118 /* get address string */ 1118 /* get address string */
1119 end = strchr(start, '/'); 1119 end = strchr(start, '/');
1120 if (!end){ 1120 if (!end || (end-start >= 49)){
1121 PRINT_WARN("Invalid format for ipato_addx/delx. " 1121 PRINT_WARN("Invalid format for ipato_addx/delx. "
1122 "Use <ip addr>/<mask bits>\n"); 1122 "Use <ip addr>/<mask bits>\n");
1123 return -EINVAL; 1123 return -EINVAL;
diff --git a/drivers/s390/net/qeth_tso.h b/drivers/s390/net/qeth_tso.h
index ad33e6f466f1..3c50b6f24f51 100644
--- a/drivers/s390/net/qeth_tso.h
+++ b/drivers/s390/net/qeth_tso.h
@@ -1,13 +1,13 @@
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 *
6 * Copyright 2004 IBM Corporation 6 * Copyright 2004 IBM Corporation
7 * 7 *
8 * Author(s): Frank Pavlic <pavlic@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/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index c218b5c944a6..5e84c5aa7779 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -996,6 +996,20 @@ zfcp_adapter_enqueue(struct ccw_device *ccw_device)
996 spin_lock_init(&adapter->fsf_req_list_lock); 996 spin_lock_init(&adapter->fsf_req_list_lock);
997 INIT_LIST_HEAD(&adapter->fsf_req_list_head); 997 INIT_LIST_HEAD(&adapter->fsf_req_list_head);
998 998
999 /* initialize debug locks */
1000
1001 spin_lock_init(&adapter->erp_dbf_lock);
1002 spin_lock_init(&adapter->hba_dbf_lock);
1003 spin_lock_init(&adapter->san_dbf_lock);
1004 spin_lock_init(&adapter->scsi_dbf_lock);
1005
1006 /* initialize error recovery stuff */
1007
1008 rwlock_init(&adapter->erp_lock);
1009 sema_init(&adapter->erp_ready_sem, 0);
1010 INIT_LIST_HEAD(&adapter->erp_ready_head);
1011 INIT_LIST_HEAD(&adapter->erp_running_head);
1012
999 /* initialize abort lock */ 1013 /* initialize abort lock */
1000 rwlock_init(&adapter->abort_lock); 1014 rwlock_init(&adapter->abort_lock);
1001 1015
diff --git a/drivers/s390/scsi/zfcp_dbf.c b/drivers/s390/scsi/zfcp_dbf.c
index 826fb3b00605..95599719f8ab 100644
--- a/drivers/s390/scsi/zfcp_dbf.c
+++ b/drivers/s390/scsi/zfcp_dbf.c
@@ -926,7 +926,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
926 char dbf_name[DEBUG_MAX_NAME_LEN]; 926 char dbf_name[DEBUG_MAX_NAME_LEN];
927 927
928 /* debug feature area which records recovery activity */ 928 /* debug feature area which records recovery activity */
929 spin_lock_init(&adapter->erp_dbf_lock);
930 sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter)); 929 sprintf(dbf_name, "zfcp_%s_erp", zfcp_get_busid_by_adapter(adapter));
931 adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2, 930 adapter->erp_dbf = debug_register(dbf_name, dbfsize, 2,
932 sizeof(struct zfcp_erp_dbf_record)); 931 sizeof(struct zfcp_erp_dbf_record));
@@ -936,7 +935,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
936 debug_set_level(adapter->erp_dbf, 3); 935 debug_set_level(adapter->erp_dbf, 3);
937 936
938 /* debug feature area which records HBA (FSF and QDIO) conditions */ 937 /* debug feature area which records HBA (FSF and QDIO) conditions */
939 spin_lock_init(&adapter->hba_dbf_lock);
940 sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter)); 938 sprintf(dbf_name, "zfcp_%s_hba", zfcp_get_busid_by_adapter(adapter));
941 adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1, 939 adapter->hba_dbf = debug_register(dbf_name, dbfsize, 1,
942 sizeof(struct zfcp_hba_dbf_record)); 940 sizeof(struct zfcp_hba_dbf_record));
@@ -947,7 +945,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
947 debug_set_level(adapter->hba_dbf, 3); 945 debug_set_level(adapter->hba_dbf, 3);
948 946
949 /* debug feature area which records SAN command failures and recovery */ 947 /* debug feature area which records SAN command failures and recovery */
950 spin_lock_init(&adapter->san_dbf_lock);
951 sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter)); 948 sprintf(dbf_name, "zfcp_%s_san", zfcp_get_busid_by_adapter(adapter));
952 adapter->san_dbf = debug_register(dbf_name, dbfsize, 1, 949 adapter->san_dbf = debug_register(dbf_name, dbfsize, 1,
953 sizeof(struct zfcp_san_dbf_record)); 950 sizeof(struct zfcp_san_dbf_record));
@@ -958,7 +955,6 @@ int zfcp_adapter_debug_register(struct zfcp_adapter *adapter)
958 debug_set_level(adapter->san_dbf, 6); 955 debug_set_level(adapter->san_dbf, 6);
959 956
960 /* debug feature area which records SCSI command failures and recovery */ 957 /* debug feature area which records SCSI command failures and recovery */
961 spin_lock_init(&adapter->scsi_dbf_lock);
962 sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter)); 958 sprintf(dbf_name, "zfcp_%s_scsi", zfcp_get_busid_by_adapter(adapter));
963 adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1, 959 adapter->scsi_dbf = debug_register(dbf_name, dbfsize, 1,
964 sizeof(struct zfcp_scsi_dbf_record)); 960 sizeof(struct zfcp_scsi_dbf_record));
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 023f4e558ae4..ee7314d8c2da 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -1071,11 +1071,6 @@ zfcp_erp_thread_setup(struct zfcp_adapter *adapter)
1071 1071
1072 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status); 1072 atomic_clear_mask(ZFCP_STATUS_ADAPTER_ERP_THREAD_UP, &adapter->status);
1073 1073
1074 rwlock_init(&adapter->erp_lock);
1075 INIT_LIST_HEAD(&adapter->erp_ready_head);
1076 INIT_LIST_HEAD(&adapter->erp_running_head);
1077 sema_init(&adapter->erp_ready_sem, 0);
1078
1079 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD); 1074 retval = kernel_thread(zfcp_erp_thread, adapter, SIGCHLD);
1080 if (retval < 0) { 1075 if (retval < 0) {
1081 ZFCP_LOG_NORMAL("error: creation of erp thread failed for " 1076 ZFCP_LOG_NORMAL("error: creation of erp thread failed for "
@@ -2248,29 +2243,26 @@ zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)
2248 return retval; 2243 return retval;
2249} 2244}
2250 2245
2251/*
2252 * function: zfcp_fsf_init
2253 *
2254 * purpose: initializes FSF operation for the specified adapter
2255 *
2256 * returns: 0 - succesful initialization of FSF operation
2257 * !0 - failed to initialize FSF operation
2258 */
2259static int 2246static int
2260zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action) 2247zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *erp_action)
2261{ 2248{
2262 int xconfig, xport; 2249 int retval;
2263 2250
2264 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2251 if ((atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2265 &erp_action->adapter->status)) { 2252 &erp_action->adapter->status)) &&
2253 (erp_action->adapter->adapter_features &
2254 FSF_FEATURE_HBAAPI_MANAGEMENT)) {
2266 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2255 zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2267 atomic_set(&erp_action->adapter->erp_counter, 0); 2256 atomic_set(&erp_action->adapter->erp_counter, 0);
2268 return ZFCP_ERP_FAILED; 2257 return ZFCP_ERP_FAILED;
2269 } 2258 }
2270 2259
2271 xconfig = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action); 2260 retval = zfcp_erp_adapter_strategy_open_fsf_xconfig(erp_action);
2272 xport = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action); 2261 if (retval == ZFCP_ERP_FAILED)
2273 if ((xconfig == ZFCP_ERP_FAILED) || (xport == ZFCP_ERP_FAILED)) 2262 return ZFCP_ERP_FAILED;
2263
2264 retval = zfcp_erp_adapter_strategy_open_fsf_xport(erp_action);
2265 if (retval == ZFCP_ERP_FAILED)
2274 return ZFCP_ERP_FAILED; 2266 return ZFCP_ERP_FAILED;
2275 2267
2276 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action); 2268 return zfcp_erp_adapter_strategy_open_fsf_statusread(erp_action);
@@ -2359,41 +2351,29 @@ zfcp_erp_adapter_strategy_open_fsf_xconfig(struct zfcp_erp_action *erp_action)
2359static int 2351static int
2360zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action) 2352zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2361{ 2353{
2362 int retval = ZFCP_ERP_SUCCEEDED; 2354 int ret;
2363 int retries; 2355 int retries;
2364 int sleep; 2356 int sleep;
2365 struct zfcp_adapter *adapter = erp_action->adapter; 2357 struct zfcp_adapter *adapter = erp_action->adapter;
2366 2358
2367 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status); 2359 atomic_clear_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status);
2368 2360
2369 for (retries = 0; ; retries++) { 2361 retries = 0;
2370 ZFCP_LOG_DEBUG("Doing exchange port data\n"); 2362 do {
2363 write_lock(&adapter->erp_lock);
2371 zfcp_erp_action_to_running(erp_action); 2364 zfcp_erp_action_to_running(erp_action);
2365 write_unlock(&adapter->erp_lock);
2372 zfcp_erp_timeout_init(erp_action); 2366 zfcp_erp_timeout_init(erp_action);
2373 if (zfcp_fsf_exchange_port_data(erp_action, adapter, NULL)) { 2367 ret = zfcp_fsf_exchange_port_data(erp_action, adapter, NULL);
2374 retval = ZFCP_ERP_FAILED; 2368 if (ret == -EOPNOTSUPP) {
2375 debug_text_event(adapter->erp_dbf, 5, "a_fstx_xf"); 2369 debug_text_event(adapter->erp_dbf, 3, "a_xport_notsupp");
2376 ZFCP_LOG_INFO("error: initiation of exchange of " 2370 return ZFCP_ERP_SUCCEEDED;
2377 "port data failed for adapter %s\n", 2371 } else if (ret) {
2378 zfcp_get_busid_by_adapter(adapter)); 2372 debug_text_event(adapter->erp_dbf, 3, "a_xport_failed");
2379 break; 2373 return ZFCP_ERP_FAILED;
2380 } 2374 }
2381 debug_text_event(adapter->erp_dbf, 6, "a_fstx_xok"); 2375 debug_text_event(adapter->erp_dbf, 6, "a_xport_ok");
2382 ZFCP_LOG_DEBUG("Xchange underway\n");
2383 2376
2384 /*
2385 * Why this works:
2386 * Both the normal completion handler as well as the timeout
2387 * handler will do an 'up' when the 'exchange port data'
2388 * request completes or times out. Thus, the signal to go on
2389 * won't be lost utilizing this semaphore.
2390 * Furthermore, this 'adapter_reopen' action is
2391 * guaranteed to be the only action being there (highest action
2392 * which prevents other actions from being created).
2393 * Resulting from that, the wake signal recognized here
2394 * _must_ be the one belonging to the 'exchange port
2395 * data' request.
2396 */
2397 down(&adapter->erp_ready_sem); 2377 down(&adapter->erp_ready_sem);
2398 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) { 2378 if (erp_action->status & ZFCP_STATUS_ERP_TIMEDOUT) {
2399 ZFCP_LOG_INFO("error: exchange of port data " 2379 ZFCP_LOG_INFO("error: exchange of port data "
@@ -2401,29 +2381,19 @@ zfcp_erp_adapter_strategy_open_fsf_xport(struct zfcp_erp_action *erp_action)
2401 zfcp_get_busid_by_adapter(adapter)); 2381 zfcp_get_busid_by_adapter(adapter));
2402 break; 2382 break;
2403 } 2383 }
2404
2405 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 2384 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2406 &adapter->status)) 2385 &adapter->status))
2407 break; 2386 break;
2408 2387
2409 ZFCP_LOG_DEBUG("host connection still initialising... " 2388 if (retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES) {
2410 "waiting and retrying...\n"); 2389 sleep = ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP;
2411 /* sleep a little bit before retry */ 2390 retries++;
2412 sleep = retries < ZFCP_EXCHANGE_PORT_DATA_SHORT_RETRIES ? 2391 } else
2413 ZFCP_EXCHANGE_PORT_DATA_SHORT_SLEEP : 2392 sleep = ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP;
2414 ZFCP_EXCHANGE_PORT_DATA_LONG_SLEEP; 2393 schedule_timeout(sleep);
2415 msleep(jiffies_to_msecs(sleep)); 2394 } while (1);
2416 }
2417
2418 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
2419 &adapter->status)) {
2420 ZFCP_LOG_INFO("error: exchange of port data for "
2421 "adapter %s failed\n",
2422 zfcp_get_busid_by_adapter(adapter));
2423 retval = ZFCP_ERP_FAILED;
2424 }
2425 2395
2426 return retval; 2396 return ZFCP_ERP_SUCCEEDED;
2427} 2397}
2428 2398
2429/* 2399/*
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 3b0fc1163f5f..59587951c847 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -554,6 +554,17 @@ static void
554zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter, 554zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
555 struct fsf_link_down_info *link_down) 555 struct fsf_link_down_info *link_down)
556{ 556{
557 if (atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED,
558 &adapter->status))
559 return;
560
561 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, &adapter->status);
562
563 if (link_down == NULL) {
564 zfcp_erp_adapter_reopen(adapter, 0);
565 return;
566 }
567
557 switch (link_down->error_code) { 568 switch (link_down->error_code) {
558 case FSF_PSQ_LINK_NO_LIGHT: 569 case FSF_PSQ_LINK_NO_LIGHT:
559 ZFCP_LOG_NORMAL("The local link to adapter %s is down " 570 ZFCP_LOG_NORMAL("The local link to adapter %s is down "
@@ -634,20 +645,15 @@ zfcp_fsf_link_down_info_eval(struct zfcp_adapter *adapter,
634 link_down->explanation_code, 645 link_down->explanation_code,
635 link_down->vendor_specific_code); 646 link_down->vendor_specific_code);
636 647
637 if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 648 switch (link_down->error_code) {
638 &adapter->status)) { 649 case FSF_PSQ_LINK_NO_LIGHT:
639 atomic_set_mask(ZFCP_STATUS_ADAPTER_LINK_UNPLUGGED, 650 case FSF_PSQ_LINK_WRAP_PLUG:
640 &adapter->status); 651 case FSF_PSQ_LINK_NO_FCP:
641 switch (link_down->error_code) { 652 case FSF_PSQ_LINK_FIRMWARE_UPDATE:
642 case FSF_PSQ_LINK_NO_LIGHT: 653 zfcp_erp_adapter_reopen(adapter, 0);
643 case FSF_PSQ_LINK_WRAP_PLUG: 654 break;
644 case FSF_PSQ_LINK_NO_FCP: 655 default:
645 case FSF_PSQ_LINK_FIRMWARE_UPDATE: 656 zfcp_erp_adapter_failed(adapter);
646 zfcp_erp_adapter_reopen(adapter, 0);
647 break;
648 default:
649 zfcp_erp_adapter_failed(adapter);
650 }
651 } 657 }
652} 658}
653 659
@@ -919,30 +925,36 @@ zfcp_fsf_status_read_handler(struct zfcp_fsf_req *fsf_req)
919 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK: 925 case FSF_STATUS_READ_SUB_NO_PHYSICAL_LINK:
920 ZFCP_LOG_INFO("Physical link to adapter %s is down\n", 926 ZFCP_LOG_INFO("Physical link to adapter %s is down\n",
921 zfcp_get_busid_by_adapter(adapter)); 927 zfcp_get_busid_by_adapter(adapter));
928 zfcp_fsf_link_down_info_eval(adapter,
929 (struct fsf_link_down_info *)
930 &status_buffer->payload);
922 break; 931 break;
923 case FSF_STATUS_READ_SUB_FDISC_FAILED: 932 case FSF_STATUS_READ_SUB_FDISC_FAILED:
924 ZFCP_LOG_INFO("Local link to adapter %s is down " 933 ZFCP_LOG_INFO("Local link to adapter %s is down "
925 "due to failed FDISC login\n", 934 "due to failed FDISC login\n",
926 zfcp_get_busid_by_adapter(adapter)); 935 zfcp_get_busid_by_adapter(adapter));
936 zfcp_fsf_link_down_info_eval(adapter,
937 (struct fsf_link_down_info *)
938 &status_buffer->payload);
927 break; 939 break;
928 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE: 940 case FSF_STATUS_READ_SUB_FIRMWARE_UPDATE:
929 ZFCP_LOG_INFO("Local link to adapter %s is down " 941 ZFCP_LOG_INFO("Local link to adapter %s is down "
930 "due to firmware update on adapter\n", 942 "due to firmware update on adapter\n",
931 zfcp_get_busid_by_adapter(adapter)); 943 zfcp_get_busid_by_adapter(adapter));
944 zfcp_fsf_link_down_info_eval(adapter, NULL);
932 break; 945 break;
933 default: 946 default:
934 ZFCP_LOG_INFO("Local link to adapter %s is down " 947 ZFCP_LOG_INFO("Local link to adapter %s is down "
935 "due to unknown reason\n", 948 "due to unknown reason\n",
936 zfcp_get_busid_by_adapter(adapter)); 949 zfcp_get_busid_by_adapter(adapter));
950 zfcp_fsf_link_down_info_eval(adapter, NULL);
937 }; 951 };
938 zfcp_fsf_link_down_info_eval(adapter,
939 (struct fsf_link_down_info *) &status_buffer->payload);
940 break; 952 break;
941 953
942 case FSF_STATUS_READ_LINK_UP: 954 case FSF_STATUS_READ_LINK_UP:
943 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. " 955 ZFCP_LOG_NORMAL("Local link to adapter %s was replugged. "
944 "Restarting operations on this adapter\n", 956 "Restarting operations on this adapter\n",
945 zfcp_get_busid_by_adapter(adapter)); 957 zfcp_get_busid_by_adapter(adapter));
946 /* All ports should be marked as ready to run again */ 958 /* All ports should be marked as ready to run again */
947 zfcp_erp_modify_adapter_status(adapter, 959 zfcp_erp_modify_adapter_status(adapter,
948 ZFCP_STATUS_COMMON_RUNNING, 960 ZFCP_STATUS_COMMON_RUNNING,
@@ -2191,13 +2203,10 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2191 return -EOPNOTSUPP; 2203 return -EOPNOTSUPP;
2192 } 2204 }
2193 2205
2194 timer = kmalloc(sizeof(struct timer_list), GFP_KERNEL);
2195 if (!timer)
2196 return -ENOMEM;
2197
2198 /* setup new FSF request */ 2206 /* setup new FSF request */
2199 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA, 2207 retval = zfcp_fsf_req_create(adapter, FSF_QTCB_EXCHANGE_PORT_DATA,
2200 0, 0, &lock_flags, &fsf_req); 2208 erp_action ? ZFCP_REQ_AUTO_CLEANUP : 0,
2209 0, &lock_flags, &fsf_req);
2201 if (retval < 0) { 2210 if (retval < 0) {
2202 ZFCP_LOG_INFO("error: Out of resources. Could not create an " 2211 ZFCP_LOG_INFO("error: Out of resources. Could not create an "
2203 "exchange port data request for" 2212 "exchange port data request for"
@@ -2205,25 +2214,33 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2205 zfcp_get_busid_by_adapter(adapter)); 2214 zfcp_get_busid_by_adapter(adapter));
2206 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2215 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2207 lock_flags); 2216 lock_flags);
2208 goto out; 2217 return retval;
2209 }
2210
2211 if (erp_action) {
2212 erp_action->fsf_req = fsf_req;
2213 fsf_req->erp_action = erp_action;
2214 } 2218 }
2215 2219
2216 if (data) 2220 if (data)
2217 fsf_req->data = (unsigned long) data; 2221 fsf_req->data = (unsigned long) data;
2218 2222
2219 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0); 2223 sbale = zfcp_qdio_sbale_req(fsf_req, fsf_req->sbal_curr, 0);
2220 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ; 2224 sbale[0].flags |= SBAL_FLAGS0_TYPE_READ;
2221 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY; 2225 sbale[1].flags |= SBAL_FLAGS_LAST_ENTRY;
2222 2226
2223 init_timer(timer); 2227 if (erp_action) {
2224 timer->function = zfcp_fsf_request_timeout_handler; 2228 erp_action->fsf_req = fsf_req;
2225 timer->data = (unsigned long) adapter; 2229 fsf_req->erp_action = erp_action;
2226 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT; 2230 timer = &erp_action->timer;
2231 } else {
2232 timer = kmalloc(sizeof(struct timer_list), GFP_ATOMIC);
2233 if (!timer) {
2234 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2235 lock_flags);
2236 zfcp_fsf_req_free(fsf_req);
2237 return -ENOMEM;
2238 }
2239 init_timer(timer);
2240 timer->function = zfcp_fsf_request_timeout_handler;
2241 timer->data = (unsigned long) adapter;
2242 timer->expires = ZFCP_FSF_REQUEST_TIMEOUT;
2243 }
2227 2244
2228 retval = zfcp_fsf_req_send(fsf_req, timer); 2245 retval = zfcp_fsf_req_send(fsf_req, timer);
2229 if (retval) { 2246 if (retval) {
@@ -2233,23 +2250,22 @@ zfcp_fsf_exchange_port_data(struct zfcp_erp_action *erp_action,
2233 zfcp_fsf_req_free(fsf_req); 2250 zfcp_fsf_req_free(fsf_req);
2234 if (erp_action) 2251 if (erp_action)
2235 erp_action->fsf_req = NULL; 2252 erp_action->fsf_req = NULL;
2253 else
2254 kfree(timer);
2236 write_unlock_irqrestore(&adapter->request_queue.queue_lock, 2255 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2237 lock_flags); 2256 lock_flags);
2238 goto out; 2257 return retval;
2239 } 2258 }
2240 2259
2241 ZFCP_LOG_DEBUG("Exchange Port Data request initiated (adapter %s)\n", 2260 write_unlock_irqrestore(&adapter->request_queue.queue_lock, lock_flags);
2242 zfcp_get_busid_by_adapter(adapter));
2243
2244 write_unlock_irqrestore(&adapter->request_queue.queue_lock,
2245 lock_flags);
2246 2261
2247 wait_event(fsf_req->completion_wq, 2262 if (!erp_action) {
2248 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 2263 wait_event(fsf_req->completion_wq,
2249 del_timer_sync(timer); 2264 fsf_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
2250 zfcp_fsf_req_free(fsf_req); 2265 del_timer_sync(timer);
2251 out: 2266 zfcp_fsf_req_free(fsf_req);
2252 kfree(timer); 2267 kfree(timer);
2268 }
2253 return retval; 2269 return retval;
2254} 2270}
2255 2271
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 3dcd1bfba3b4..66608d13a634 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -179,7 +179,7 @@ zfcp_scsi_slave_alloc(struct scsi_device *sdp)
179 struct zfcp_adapter *adapter; 179 struct zfcp_adapter *adapter;
180 struct zfcp_unit *unit; 180 struct zfcp_unit *unit;
181 unsigned long flags; 181 unsigned long flags;
182 int retval = -ENODEV; 182 int retval = -ENXIO;
183 183
184 adapter = (struct zfcp_adapter *) sdp->host->hostdata[0]; 184 adapter = (struct zfcp_adapter *) sdp->host->hostdata[0];
185 if (!adapter) 185 if (!adapter)
diff --git a/drivers/sbus/char/aurora.c b/drivers/sbus/char/aurora.c
index 672f9f2b2163..92e6c5639dd3 100644
--- a/drivers/sbus/char/aurora.c
+++ b/drivers/sbus/char/aurora.c
@@ -124,25 +124,25 @@ static inline int aurora_paranoia_check(struct Aurora_port const * port,
124 */ 124 */
125 125
126/* Get board number from pointer */ 126/* Get board number from pointer */
127extern inline int board_No (struct Aurora_board const * bp) 127static inline int board_No (struct Aurora_board const * bp)
128{ 128{
129 return bp - aurora_board; 129 return bp - aurora_board;
130} 130}
131 131
132/* Get port number from pointer */ 132/* Get port number from pointer */
133extern inline int port_No (struct Aurora_port const * port) 133static inline int port_No (struct Aurora_port const * port)
134{ 134{
135 return AURORA_PORT(port - aurora_port); 135 return AURORA_PORT(port - aurora_port);
136} 136}
137 137
138/* Get pointer to board from pointer to port */ 138/* Get pointer to board from pointer to port */
139extern inline struct Aurora_board * port_Board(struct Aurora_port const * port) 139static inline struct Aurora_board * port_Board(struct Aurora_port const * port)
140{ 140{
141 return &aurora_board[AURORA_BOARD(port - aurora_port)]; 141 return &aurora_board[AURORA_BOARD(port - aurora_port)];
142} 142}
143 143
144/* Wait for Channel Command Register ready */ 144/* Wait for Channel Command Register ready */
145extern inline void aurora_wait_CCR(struct aurora_reg128 * r) 145static inline void aurora_wait_CCR(struct aurora_reg128 * r)
146{ 146{
147 unsigned long delay; 147 unsigned long delay;
148 148
@@ -161,7 +161,7 @@ printk("aurora_wait_CCR\n");
161 */ 161 */
162 162
163/* Must be called with enabled interrupts */ 163/* Must be called with enabled interrupts */
164extern inline void aurora_long_delay(unsigned long delay) 164static inline void aurora_long_delay(unsigned long delay)
165{ 165{
166 unsigned long i; 166 unsigned long i;
167 167
@@ -420,7 +420,7 @@ static void aurora_release_io_range(struct Aurora_board *bp)
420 sbus_iounmap((unsigned long)bp->r3, 4); 420 sbus_iounmap((unsigned long)bp->r3, 4);
421} 421}
422 422
423extern inline void aurora_mark_event(struct Aurora_port * port, int event) 423static inline void aurora_mark_event(struct Aurora_port * port, int event)
424{ 424{
425#ifdef AURORA_DEBUG 425#ifdef AURORA_DEBUG
426 printk("aurora_mark_event: start\n"); 426 printk("aurora_mark_event: start\n");
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c
index 2c86a4b809cd..c3a51d1fae5d 100644
--- a/drivers/sbus/char/display7seg.c
+++ b/drivers/sbus/char/display7seg.c
@@ -119,7 +119,7 @@ static long d7s_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
119{ 119{
120 __u8 regs = readb(d7s_regs); 120 __u8 regs = readb(d7s_regs);
121 __u8 ireg = 0; 121 __u8 ireg = 0;
122 int error = 0 122 int error = 0;
123 123
124 if (D7S_MINOR != iminor(file->f_dentry->d_inode)) 124 if (D7S_MINOR != iminor(file->f_dentry->d_inode))
125 return -ENODEV; 125 return -ENODEV;
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/rtc.c b/drivers/sbus/char/rtc.c
index 5774bdd0e26f..9b988baf0b51 100644
--- a/drivers/sbus/char/rtc.c
+++ b/drivers/sbus/char/rtc.c
@@ -210,27 +210,6 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
210 } 210 }
211} 211}
212 212
213static long rtc_compat_ioctl(struct file *file, unsigned int cmd,
214 unsigned long arg)
215{
216 int rval = -ENOIOCTLCMD;
217
218 switch (cmd) {
219 /*
220 * These two are specific to this driver, the generic rtc ioctls
221 * are hanlded elsewhere.
222 */
223 case RTCGET:
224 case RTCSET:
225 lock_kernel();
226 rval = rtc_ioctl(file->f_dentry->d_inode, file, cmd, arg);
227 unlock_kernel();
228 break;
229 }
230
231 return rval;
232}
233
234static int rtc_open(struct inode *inode, struct file *file) 213static int rtc_open(struct inode *inode, struct file *file)
235{ 214{
236 int ret; 215 int ret;
@@ -258,7 +237,6 @@ static struct file_operations rtc_fops = {
258 .owner = THIS_MODULE, 237 .owner = THIS_MODULE,
259 .llseek = no_llseek, 238 .llseek = no_llseek,
260 .ioctl = rtc_ioctl, 239 .ioctl = rtc_ioctl,
261 .compat_ioctl = rtc_compat_ioctl,
262 .open = rtc_open, 240 .open = rtc_open,
263 .release = rtc_release, 241 .release = rtc_release,
264}; 242};
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/53c7xx.c b/drivers/scsi/53c7xx.c
index 7a33c708f5b3..9cb5dd48383f 100644
--- a/drivers/scsi/53c7xx.c
+++ b/drivers/scsi/53c7xx.c
@@ -343,7 +343,7 @@ static void NCR53c7x0_soft_reset (struct Scsi_Host *host);
343/* Size of event list (per host adapter) */ 343/* Size of event list (per host adapter) */
344static int track_events = 0; 344static int track_events = 0;
345static struct Scsi_Host *first_host = NULL; /* Head of list of NCR boards */ 345static struct Scsi_Host *first_host = NULL; /* Head of list of NCR boards */
346static Scsi_Host_Template *the_template = NULL; 346static struct scsi_host_template *the_template = NULL;
347 347
348/* NCR53c710 script handling code */ 348/* NCR53c710 script handling code */
349 349
@@ -1103,7 +1103,7 @@ NCR53c7x0_init (struct Scsi_Host *host) {
1103} 1103}
1104 1104
1105/* 1105/*
1106 * Function : int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, int chip, 1106 * Function : int ncr53c7xx_init(struct scsi_host_template *tpnt, int board, int chip,
1107 * unsigned long base, int io_port, int irq, int dma, long long options, 1107 * unsigned long base, int io_port, int irq, int dma, long long options,
1108 * int clock); 1108 * int clock);
1109 * 1109 *
@@ -1118,7 +1118,7 @@ NCR53c7x0_init (struct Scsi_Host *host) {
1118 */ 1118 */
1119 1119
1120int 1120int
1121ncr53c7xx_init (Scsi_Host_Template *tpnt, int board, int chip, 1121ncr53c7xx_init (struct scsi_host_template *tpnt, int board, int chip,
1122 unsigned long base, int io_port, int irq, int dma, 1122 unsigned long base, int io_port, int irq, int dma,
1123 long long options, int clock) 1123 long long options, int clock)
1124{ 1124{
diff --git a/drivers/scsi/53c7xx.h b/drivers/scsi/53c7xx.h
index d9098bdace05..218f3b901537 100644
--- a/drivers/scsi/53c7xx.h
+++ b/drivers/scsi/53c7xx.h
@@ -1600,7 +1600,7 @@ struct NCR53c7x0_hostdata {
1600/* Paranoid people could use panic() here. */ 1600/* Paranoid people could use panic() here. */
1601#define FATAL(host) shutdown((host)); 1601#define FATAL(host) shutdown((host));
1602 1602
1603extern int ncr53c7xx_init(Scsi_Host_Template *tpnt, int board, int chip, 1603extern int ncr53c7xx_init(struct scsi_host_template *tpnt, int board, int chip,
1604 unsigned long base, int io_port, int irq, int dma, 1604 unsigned long base, int io_port, int irq, int dma,
1605 long long options, int clock); 1605 long long options, int clock);
1606 1606
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index afeca325b4dc..20dd85a77813 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -497,7 +497,7 @@ config SCSI_ATA_PIIX
497 If unsure, say N. 497 If unsure, say N.
498 498
499config SCSI_SATA_MV 499config SCSI_SATA_MV
500 tristate "Marvell SATA support" 500 tristate "Marvell SATA support (HIGHLY EXPERIMENTAL)"
501 depends on SCSI_SATA && PCI && EXPERIMENTAL 501 depends on SCSI_SATA && PCI && EXPERIMENTAL
502 help 502 help
503 This option enables support for the Marvell Serial ATA family. 503 This option enables support for the Marvell Serial ATA family.
@@ -1295,27 +1295,6 @@ config SCSI_QLOGIC_FAS
1295 To compile this driver as a module, choose M here: the 1295 To compile this driver as a module, choose M here: the
1296 module will be called qlogicfas. 1296 module will be called qlogicfas.
1297 1297
1298config SCSI_QLOGIC_ISP
1299 tristate "Qlogic ISP SCSI support (old driver)"
1300 depends on PCI && SCSI && BROKEN
1301 ---help---
1302 This driver works for all QLogic PCI SCSI host adapters (IQ-PCI,
1303 IQ-PCI-10, IQ_PCI-D) except for the PCI-basic card. (This latter
1304 card is supported by the "AM53/79C974 PCI SCSI" driver.)
1305
1306 If you say Y here, make sure to choose "BIOS" at the question "PCI
1307 access mode".
1308
1309 Please read the file <file:Documentation/scsi/qlogicisp.txt>. You
1310 should also read the SCSI-HOWTO, available from
1311 <http://www.tldp.org/docs.html#howto>.
1312
1313 To compile this driver as a module, choose M here: the
1314 module will be called qlogicisp.
1315
1316 These days the hardware is also supported by the more modern qla1280
1317 driver. In doubt use that one instead of qlogicisp.
1318
1319config SCSI_QLOGIC_FC 1298config SCSI_QLOGIC_FC
1320 tristate "Qlogic ISP FC SCSI support" 1299 tristate "Qlogic ISP FC SCSI support"
1321 depends on PCI && SCSI 1300 depends on PCI && SCSI
@@ -1342,14 +1321,6 @@ config SCSI_QLOGIC_1280
1342 To compile this driver as a module, choose M here: the 1321 To compile this driver as a module, choose M here: the
1343 module will be called qla1280. 1322 module will be called qla1280.
1344 1323
1345config SCSI_QLOGIC_1280_1040
1346 bool "Qlogic QLA 1020/1040 SCSI support"
1347 depends on SCSI_QLOGIC_1280 && SCSI_QLOGIC_ISP!=y
1348 help
1349 Say Y here if you have a QLogic ISP1020/1040 SCSI host adapter and
1350 do not want to use the old driver. This option enables support in
1351 the qla1280 driver for those host adapters.
1352
1353config SCSI_QLOGICPTI 1324config SCSI_QLOGICPTI
1354 tristate "PTI Qlogic, ISP Driver" 1325 tristate "PTI Qlogic, ISP Driver"
1355 depends on SBUS && SCSI 1326 depends on SBUS && SCSI
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index b88b8c455598..f062ea0f813a 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -78,7 +78,6 @@ obj-$(CONFIG_SCSI_NCR_Q720) += NCR_Q720_mod.o
78obj-$(CONFIG_SCSI_SYM53C416) += sym53c416.o 78obj-$(CONFIG_SCSI_SYM53C416) += sym53c416.o
79obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o 79obj-$(CONFIG_SCSI_QLOGIC_FAS) += qlogicfas408.o qlogicfas.o
80obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o 80obj-$(CONFIG_PCMCIA_QLOGIC) += qlogicfas408.o
81obj-$(CONFIG_SCSI_QLOGIC_ISP) += qlogicisp.o
82obj-$(CONFIG_SCSI_QLOGIC_FC) += qlogicfc.o 81obj-$(CONFIG_SCSI_QLOGIC_FC) += qlogicfc.o
83obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o 82obj-$(CONFIG_SCSI_QLOGIC_1280) += qla1280.o
84obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx/ 83obj-$(CONFIG_SCSI_QLA2XXX) += qla2xxx/
diff --git a/drivers/scsi/NCR53C9x.c b/drivers/scsi/NCR53C9x.c
index 26146a4b67b8..640590bd014a 100644
--- a/drivers/scsi/NCR53C9x.c
+++ b/drivers/scsi/NCR53C9x.c
@@ -529,7 +529,7 @@ void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs)
529/* Allocate structure and insert basic data such as SCSI chip frequency 529/* Allocate structure and insert basic data such as SCSI chip frequency
530 * data and a pointer to the device 530 * data and a pointer to the device
531 */ 531 */
532struct NCR_ESP* esp_allocate(Scsi_Host_Template *tpnt, void *esp_dev) 532struct NCR_ESP* esp_allocate(struct scsi_host_template *tpnt, void *esp_dev)
533{ 533{
534 struct NCR_ESP *esp, *elink; 534 struct NCR_ESP *esp, *elink;
535 struct Scsi_Host *esp_host; 535 struct Scsi_Host *esp_host;
@@ -1006,7 +1006,7 @@ static void esp_exec_cmd(struct NCR_ESP *esp)
1006 struct ESP_regs *eregs = esp->eregs; 1006 struct ESP_regs *eregs = esp->eregs;
1007 struct esp_device *esp_dev; 1007 struct esp_device *esp_dev;
1008 Scsi_Cmnd *SCptr; 1008 Scsi_Cmnd *SCptr;
1009 Scsi_Device *SDptr; 1009 struct scsi_device *SDptr;
1010 volatile unchar *cmdp = esp->esp_command; 1010 volatile unchar *cmdp = esp->esp_command;
1011 unsigned char the_esp_command; 1011 unsigned char the_esp_command;
1012 int lun, target; 1012 int lun, target;
@@ -1687,7 +1687,7 @@ static inline int reconnect_lun(struct NCR_ESP *esp, struct ESP_regs *eregs)
1687static inline void esp_connect(struct NCR_ESP *esp, struct ESP_regs *eregs, 1687static inline void esp_connect(struct NCR_ESP *esp, struct ESP_regs *eregs,
1688 Scsi_Cmnd *sp) 1688 Scsi_Cmnd *sp)
1689{ 1689{
1690 Scsi_Device *dp = sp->device; 1690 struct scsi_device *dp = sp->device;
1691 struct esp_device *esp_dev = dp->hostdata; 1691 struct esp_device *esp_dev = dp->hostdata;
1692 1692
1693 if(esp->prev_soff != esp_dev->sync_max_offset || 1693 if(esp->prev_soff != esp_dev->sync_max_offset ||
@@ -3605,7 +3605,7 @@ out:
3605} 3605}
3606#endif 3606#endif
3607 3607
3608int esp_slave_alloc(Scsi_Device *SDptr) 3608int esp_slave_alloc(struct scsi_device *SDptr)
3609{ 3609{
3610 struct esp_device *esp_dev = 3610 struct esp_device *esp_dev =
3611 kmalloc(sizeof(struct esp_device), GFP_ATOMIC); 3611 kmalloc(sizeof(struct esp_device), GFP_ATOMIC);
@@ -3617,7 +3617,7 @@ int esp_slave_alloc(Scsi_Device *SDptr)
3617 return 0; 3617 return 0;
3618} 3618}
3619 3619
3620void esp_slave_destroy(Scsi_Device *SDptr) 3620void esp_slave_destroy(struct scsi_device *SDptr)
3621{ 3621{
3622 struct NCR_ESP *esp = (struct NCR_ESP *) SDptr->host->hostdata; 3622 struct NCR_ESP *esp = (struct NCR_ESP *) SDptr->host->hostdata;
3623 3623
diff --git a/drivers/scsi/NCR53C9x.h b/drivers/scsi/NCR53C9x.h
index 06e7edf23326..65a9b377a410 100644
--- a/drivers/scsi/NCR53C9x.h
+++ b/drivers/scsi/NCR53C9x.h
@@ -653,7 +653,7 @@ extern int nesps, esps_in_use, esps_running;
653 653
654/* External functions */ 654/* External functions */
655extern void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs); 655extern void esp_bootup_reset(struct NCR_ESP *esp, struct ESP_regs *eregs);
656extern struct NCR_ESP *esp_allocate(Scsi_Host_Template *, void *); 656extern struct NCR_ESP *esp_allocate(struct scsi_host_template *, void *);
657extern void esp_deallocate(struct NCR_ESP *); 657extern void esp_deallocate(struct NCR_ESP *);
658extern void esp_release(void); 658extern void esp_release(void);
659extern void esp_initialize(struct NCR_ESP *); 659extern void esp_initialize(struct NCR_ESP *);
@@ -664,6 +664,6 @@ extern int esp_abort(Scsi_Cmnd *);
664extern int esp_reset(Scsi_Cmnd *); 664extern int esp_reset(Scsi_Cmnd *);
665extern int esp_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, int length, 665extern int esp_proc_info(struct Scsi_Host *shost, char *buffer, char **start, off_t offset, int length,
666 int inout); 666 int inout);
667extern int esp_slave_alloc(Scsi_Device *); 667extern int esp_slave_alloc(struct scsi_device *);
668extern void esp_slave_destroy(Scsi_Device *); 668extern void esp_slave_destroy(struct scsi_device *);
669#endif /* !(NCR53C9X_H) */ 669#endif /* !(NCR53C9X_H) */
diff --git a/drivers/scsi/NCR53c406a.c b/drivers/scsi/NCR53c406a.c
index 135376992a57..ae37d3ab9c4a 100644
--- a/drivers/scsi/NCR53c406a.c
+++ b/drivers/scsi/NCR53c406a.c
@@ -447,7 +447,7 @@ static __inline__ int NCR53c406a_pio_write(unsigned char *request, unsigned int
447} 447}
448#endif /* USE_PIO */ 448#endif /* USE_PIO */
449 449
450static int __init NCR53c406a_detect(Scsi_Host_Template * tpnt) 450static int __init NCR53c406a_detect(struct scsi_host_template * tpnt)
451{ 451{
452 int present = 0; 452 int present = 0;
453 struct Scsi_Host *shpnt = NULL; 453 struct Scsi_Host *shpnt = NULL;
@@ -1057,7 +1057,7 @@ MODULE_LICENSE("GPL");
1057 * Use SG_NONE if DMA mode is enabled! 1057 * Use SG_NONE if DMA mode is enabled!
1058 */ 1058 */
1059 1059
1060static Scsi_Host_Template driver_template = 1060static struct scsi_host_template driver_template =
1061{ 1061{
1062 .proc_name = "NCR53c406a" /* proc_name */, 1062 .proc_name = "NCR53c406a" /* proc_name */,
1063 .name = "NCR53c406a" /* name */, 1063 .name = "NCR53c406a" /* name */,
diff --git a/drivers/scsi/a2091.c b/drivers/scsi/a2091.c
index 30a14ba77a6a..54996eaae979 100644
--- a/drivers/scsi/a2091.c
+++ b/drivers/scsi/a2091.c
@@ -172,7 +172,7 @@ static void dma_stop (struct Scsi_Host *instance, Scsi_Cmnd *SCpnt,
172 } 172 }
173} 173}
174 174
175int __init a2091_detect(Scsi_Host_Template *tpnt) 175int __init a2091_detect(struct scsi_host_template *tpnt)
176{ 176{
177 static unsigned char called = 0; 177 static unsigned char called = 0;
178 struct Scsi_Host *instance; 178 struct Scsi_Host *instance;
@@ -233,7 +233,7 @@ static int a2091_bus_reset(Scsi_Cmnd *cmd)
233 233
234#define HOSTS_C 234#define HOSTS_C
235 235
236static Scsi_Host_Template driver_template = { 236static struct scsi_host_template driver_template = {
237 .proc_name = "A2901", 237 .proc_name = "A2901",
238 .name = "Commodore A2091/A590 SCSI", 238 .name = "Commodore A2091/A590 SCSI",
239 .detect = a2091_detect, 239 .detect = a2091_detect,
diff --git a/drivers/scsi/a2091.h b/drivers/scsi/a2091.h
index 54993972dcc6..22d6a13dd8be 100644
--- a/drivers/scsi/a2091.h
+++ b/drivers/scsi/a2091.h
@@ -11,7 +11,7 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14int a2091_detect(Scsi_Host_Template *); 14int a2091_detect(struct scsi_host_template *);
15int a2091_release(struct Scsi_Host *); 15int a2091_release(struct Scsi_Host *);
16const char *wd33c93_info(void); 16const char *wd33c93_info(void);
17int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 17int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c
index 306caf56f3d9..f425d424bf08 100644
--- a/drivers/scsi/a3000.c
+++ b/drivers/scsi/a3000.c
@@ -168,7 +168,7 @@ static void dma_stop (struct Scsi_Host *instance, Scsi_Cmnd *SCpnt,
168 } 168 }
169} 169}
170 170
171int __init a3000_detect(Scsi_Host_Template *tpnt) 171int __init a3000_detect(struct scsi_host_template *tpnt)
172{ 172{
173 wd33c93_regs regs; 173 wd33c93_regs regs;
174 174
@@ -221,7 +221,7 @@ static int a3000_bus_reset(Scsi_Cmnd *cmd)
221 221
222#define HOSTS_C 222#define HOSTS_C
223 223
224static Scsi_Host_Template driver_template = { 224static struct scsi_host_template driver_template = {
225 .proc_name = "A3000", 225 .proc_name = "A3000",
226 .name = "Amiga 3000 built-in SCSI", 226 .name = "Amiga 3000 built-in SCSI",
227 .detect = a3000_detect, 227 .detect = a3000_detect,
diff --git a/drivers/scsi/a3000.h b/drivers/scsi/a3000.h
index b1eda731877d..5535a65150a4 100644
--- a/drivers/scsi/a3000.h
+++ b/drivers/scsi/a3000.h
@@ -11,7 +11,7 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14int a3000_detect(Scsi_Host_Template *); 14int a3000_detect(struct scsi_host_template *);
15int a3000_release(struct Scsi_Host *); 15int a3000_release(struct Scsi_Host *);
16const char *wd33c93_info(void); 16const char *wd33c93_info(void);
17int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 17int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 2a128a156aa1..7139659dd952 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -1579,18 +1579,10 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1579 break; 1579 break;
1580 { 1580 {
1581 u64 capacity; 1581 u64 capacity;
1582 char cp[12]; 1582 char cp[13];
1583 unsigned int offset = 0;
1584 1583
1585 dprintk((KERN_DEBUG "READ CAPACITY_16 command.\n")); 1584 dprintk((KERN_DEBUG "READ CAPACITY_16 command.\n"));
1586 capacity = fsa_dev_ptr[cid].size - 1; 1585 capacity = fsa_dev_ptr[cid].size - 1;
1587 if (scsicmd->cmnd[13] > 12) {
1588 offset = scsicmd->cmnd[13] - 12;
1589 if (offset > sizeof(cp))
1590 break;
1591 memset(cp, 0, offset);
1592 aac_internal_transfer(scsicmd, cp, 0, offset);
1593 }
1594 cp[0] = (capacity >> 56) & 0xff; 1586 cp[0] = (capacity >> 56) & 0xff;
1595 cp[1] = (capacity >> 48) & 0xff; 1587 cp[1] = (capacity >> 48) & 0xff;
1596 cp[2] = (capacity >> 40) & 0xff; 1588 cp[2] = (capacity >> 40) & 0xff;
@@ -1603,7 +1595,18 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1603 cp[9] = 0; 1595 cp[9] = 0;
1604 cp[10] = 2; 1596 cp[10] = 2;
1605 cp[11] = 0; 1597 cp[11] = 0;
1606 aac_internal_transfer(scsicmd, cp, offset, sizeof(cp)); 1598 cp[12] = 0;
1599 aac_internal_transfer(scsicmd, cp, 0,
1600 min((unsigned int)scsicmd->cmnd[13], sizeof(cp)));
1601 if (sizeof(cp) < scsicmd->cmnd[13]) {
1602 unsigned int len, offset = sizeof(cp);
1603
1604 memset(cp, 0, offset);
1605 do {
1606 len = min(scsicmd->cmnd[13]-offset, sizeof(cp));
1607 aac_internal_transfer(scsicmd, cp, offset, len);
1608 } while ((offset += len) < scsicmd->cmnd[13]);
1609 }
1607 1610
1608 /* Do not cache partition table for arrays */ 1611 /* Do not cache partition table for arrays */
1609 scsicmd->device->removable = 1; 1612 scsicmd->device->removable = 1;
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 723c0cea7c04..38d6d00fb0fc 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -820,7 +820,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
820 break; 820 break;
821 821
822 /* 822 /*
823 * Find the Scsi_Device associated with the SCSI 823 * Find the scsi_device associated with the SCSI
824 * address. Make sure we have the right array, and if 824 * address. Make sure we have the right array, and if
825 * so set the flag to initiate a new re-config once we 825 * so set the flag to initiate a new re-config once we
826 * see an AifEnConfigChange AIF come through. 826 * see an AifEnConfigChange AIF come through.
@@ -987,7 +987,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
987 987
988 988
989 /* 989 /*
990 * Find the Scsi_Device associated with the SCSI address, 990 * Find the scsi_device associated with the SCSI address,
991 * and mark it as changed, invalidating the cache. This deals 991 * and mark it as changed, invalidating the cache. This deals
992 * with changes to existing device IDs. 992 * with changes to existing device IDs.
993 */ 993 */
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index ab383d1f59e2..3cb68af90456 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -325,6 +325,8 @@ static int aac_biosparm(struct scsi_device *sdev, struct block_device *bdev,
325 * translations ( 64/32, 128/32, 255/63 ). 325 * translations ( 64/32, 128/32, 255/63 ).
326 */ 326 */
327 buf = scsi_bios_ptable(bdev); 327 buf = scsi_bios_ptable(bdev);
328 if (!buf)
329 return 0;
328 if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) { 330 if(*(__le16 *)(buf + 0x40) == cpu_to_le16(0xaa55)) {
329 struct partition *first = (struct partition * )buf; 331 struct partition *first = (struct partition * )buf;
330 struct partition *entry = first; 332 struct partition *entry = first;
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index f4cfb8f29620..28b93057b607 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -114,7 +114,7 @@
114 #include "advansys.h" 114 #include "advansys.h"
115 #endif 115 #endif
116 116
117 and after "static Scsi_Host_Template builtin_scsi_hosts[] =": 117 and after "static struct scsi_host_template builtin_scsi_hosts[] =":
118 118
119 #ifdef CONFIG_SCSI_ADVANSYS 119 #ifdef CONFIG_SCSI_ADVANSYS
120 ADVANSYS, 120 ADVANSYS,
@@ -160,7 +160,7 @@
160 --- Driver Structures 160 --- Driver Structures
161 --- Driver Data 161 --- Driver Data
162 --- Driver Function Prototypes 162 --- Driver Function Prototypes
163 --- Linux 'Scsi_Host_Template' and advansys_setup() Functions 163 --- Linux 'struct scsi_host_template' and advansys_setup() Functions
164 --- Loadable Driver Support 164 --- Loadable Driver Support
165 --- Miscellaneous Driver Functions 165 --- Miscellaneous Driver Functions
166 --- Functions Required by the Asc Library 166 --- Functions Required by the Asc Library
@@ -4068,7 +4068,7 @@ STATIC void asc_prt_hex(char *f, uchar *, int);
4068 4068
4069 4069
4070/* 4070/*
4071 * --- Linux 'Scsi_Host_Template' and advansys_setup() Functions 4071 * --- Linux 'struct scsi_host_template' and advansys_setup() Functions
4072 */ 4072 */
4073 4073
4074#ifdef CONFIG_PROC_FS 4074#ifdef CONFIG_PROC_FS
diff --git a/drivers/scsi/advansys.h b/drivers/scsi/advansys.h
index 3f4bde02302e..8ee7fb16a725 100644
--- a/drivers/scsi/advansys.h
+++ b/drivers/scsi/advansys.h
@@ -19,7 +19,7 @@
19#define _ADVANSYS_H 19#define _ADVANSYS_H
20 20
21/* 21/*
22 * Scsi_Host_Template function prototypes. 22 * struct scsi_host_template function prototypes.
23 */ 23 */
24int advansys_detect(struct scsi_host_template *); 24int advansys_detect(struct scsi_host_template *);
25int advansys_release(struct Scsi_Host *); 25int advansys_release(struct Scsi_Host *);
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 9b7caf504a56..9df23b654cec 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -424,7 +424,7 @@ MODULE_DEVICE_TABLE(isapnp, id_table);
424 424
425static int registered_count=0; 425static int registered_count=0;
426static struct Scsi_Host *aha152x_host[2]; 426static struct Scsi_Host *aha152x_host[2];
427static Scsi_Host_Template aha152x_driver_template; 427static struct scsi_host_template aha152x_driver_template;
428 428
429/* 429/*
430 * internal states of the host 430 * internal states of the host
@@ -3464,7 +3464,7 @@ static int aha152x_proc_info(struct Scsi_Host *shpnt, char *buffer, char **start
3464 return thislength < length ? thislength : length; 3464 return thislength < length ? thislength : length;
3465} 3465}
3466 3466
3467static Scsi_Host_Template aha152x_driver_template = { 3467static struct scsi_host_template aha152x_driver_template = {
3468 .module = THIS_MODULE, 3468 .module = THIS_MODULE,
3469 .name = AHA152X_REVID, 3469 .name = AHA152X_REVID,
3470 .proc_name = "aha152x", 3470 .proc_name = "aha152x",
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 1b1adfb384cb..51bad7a1e773 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -1021,7 +1021,7 @@ __setup("aha1542=",do_setup);
1021#endif 1021#endif
1022 1022
1023/* return non-zero on detection */ 1023/* return non-zero on detection */
1024static int __init aha1542_detect(Scsi_Host_Template * tpnt) 1024static int __init aha1542_detect(struct scsi_host_template * tpnt)
1025{ 1025{
1026 unsigned char dma_chan; 1026 unsigned char dma_chan;
1027 unsigned char irq_level; 1027 unsigned char irq_level;
@@ -1789,7 +1789,7 @@ static int aha1542_biosparam(struct scsi_device *sdev,
1789MODULE_LICENSE("GPL"); 1789MODULE_LICENSE("GPL");
1790 1790
1791 1791
1792static Scsi_Host_Template driver_template = { 1792static struct scsi_host_template driver_template = {
1793 .proc_name = "aha1542", 1793 .proc_name = "aha1542",
1794 .name = "Adaptec 1542", 1794 .name = "Adaptec 1542",
1795 .detect = aha1542_detect, 1795 .detect = aha1542_detect,
diff --git a/drivers/scsi/aha1542.h b/drivers/scsi/aha1542.h
index 3821ee17f471..1db538552d56 100644
--- a/drivers/scsi/aha1542.h
+++ b/drivers/scsi/aha1542.h
@@ -131,7 +131,7 @@ struct ccb { /* Command Control Block 5.3 */
131 /* REQUEST SENSE */ 131 /* REQUEST SENSE */
132}; 132};
133 133
134static int aha1542_detect(Scsi_Host_Template *); 134static int aha1542_detect(struct scsi_host_template *);
135static int aha1542_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 135static int aha1542_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
136static int aha1542_bus_reset(Scsi_Cmnd * SCpnt); 136static int aha1542_bus_reset(Scsi_Cmnd * SCpnt);
137static int aha1542_dev_reset(Scsi_Cmnd * SCpnt); 137static int aha1542_dev_reset(Scsi_Cmnd * SCpnt);
diff --git a/drivers/scsi/aha1740.c b/drivers/scsi/aha1740.c
index 8f85dcc0e7fa..4b8c6a543925 100644
--- a/drivers/scsi/aha1740.c
+++ b/drivers/scsi/aha1740.c
@@ -570,7 +570,7 @@ static int aha1740_eh_abort_handler (Scsi_Cmnd *dummy)
570 return 0; 570 return 0;
571} 571}
572 572
573static Scsi_Host_Template aha1740_template = { 573static struct scsi_host_template aha1740_template = {
574 .module = THIS_MODULE, 574 .module = THIS_MODULE,
575 .proc_name = "aha1740", 575 .proc_name = "aha1740",
576 .proc_info = aha1740_proc_info, 576 .proc_info = aha1740_proc_info,
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index 10c470e7d316..83467a05dc8e 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -48,7 +48,7 @@
48#include <asm/io.h> 48#include <asm/io.h>
49 49
50#define DRV_NAME "ahci" 50#define DRV_NAME "ahci"
51#define DRV_VERSION "1.01" 51#define DRV_VERSION "1.2"
52 52
53 53
54enum { 54enum {
@@ -134,6 +134,7 @@ enum {
134 PORT_IRQ_D2H_REG_FIS, 134 PORT_IRQ_D2H_REG_FIS,
135 135
136 /* PORT_CMD bits */ 136 /* PORT_CMD bits */
137 PORT_CMD_ATAPI = (1 << 24), /* Device is ATAPI */
137 PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */ 138 PORT_CMD_LIST_ON = (1 << 15), /* cmd list DMA engine running */
138 PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */ 139 PORT_CMD_FIS_ON = (1 << 14), /* FIS DMA engine running */
139 PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */ 140 PORT_CMD_FIS_RX = (1 << 4), /* Enable FIS receive DMA engine */
@@ -255,7 +256,7 @@ static struct ata_port_info ahci_port_info[] = {
255 }, 256 },
256}; 257};
257 258
258static struct pci_device_id ahci_pci_tbl[] = { 259static const struct pci_device_id ahci_pci_tbl[] = {
259 { PCI_VENDOR_ID_INTEL, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 260 { PCI_VENDOR_ID_INTEL, 0x2652, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
260 board_ahci }, /* ICH6 */ 261 board_ahci }, /* ICH6 */
261 { PCI_VENDOR_ID_INTEL, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 262 { PCI_VENDOR_ID_INTEL, 0x2653, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
@@ -441,7 +442,7 @@ static void ahci_phy_reset(struct ata_port *ap)
441 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr; 442 void __iomem *port_mmio = (void __iomem *) ap->ioaddr.cmd_addr;
442 struct ata_taskfile tf; 443 struct ata_taskfile tf;
443 struct ata_device *dev = &ap->device[0]; 444 struct ata_device *dev = &ap->device[0];
444 u32 tmp; 445 u32 new_tmp, tmp;
445 446
446 __sata_phy_reset(ap); 447 __sata_phy_reset(ap);
447 448
@@ -455,8 +456,21 @@ static void ahci_phy_reset(struct ata_port *ap)
455 tf.nsect = (tmp) & 0xff; 456 tf.nsect = (tmp) & 0xff;
456 457
457 dev->class = ata_dev_classify(&tf); 458 dev->class = ata_dev_classify(&tf);
458 if (!ata_dev_present(dev)) 459 if (!ata_dev_present(dev)) {
459 ata_port_disable(ap); 460 ata_port_disable(ap);
461 return;
462 }
463
464 /* Make sure port's ATAPI bit is set appropriately */
465 new_tmp = tmp = readl(port_mmio + PORT_CMD);
466 if (dev->class == ATA_DEV_ATAPI)
467 new_tmp |= PORT_CMD_ATAPI;
468 else
469 new_tmp &= ~PORT_CMD_ATAPI;
470 if (new_tmp != tmp) {
471 writel(new_tmp, port_mmio + PORT_CMD);
472 readl(port_mmio + PORT_CMD); /* flush */
473 }
460} 474}
461 475
462static u8 ahci_check_status(struct ata_port *ap) 476static u8 ahci_check_status(struct ata_port *ap)
@@ -474,11 +488,12 @@ static void ahci_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
474 ata_tf_from_fis(d2h_fis, tf); 488 ata_tf_from_fis(d2h_fis, tf);
475} 489}
476 490
477static void ahci_fill_sg(struct ata_queued_cmd *qc) 491static unsigned int ahci_fill_sg(struct ata_queued_cmd *qc)
478{ 492{
479 struct ahci_port_priv *pp = qc->ap->private_data; 493 struct ahci_port_priv *pp = qc->ap->private_data;
480 struct scatterlist *sg; 494 struct scatterlist *sg;
481 struct ahci_sg *ahci_sg; 495 struct ahci_sg *ahci_sg;
496 unsigned int n_sg = 0;
482 497
483 VPRINTK("ENTER\n"); 498 VPRINTK("ENTER\n");
484 499
@@ -493,8 +508,12 @@ static void ahci_fill_sg(struct ata_queued_cmd *qc)
493 ahci_sg->addr = cpu_to_le32(addr & 0xffffffff); 508 ahci_sg->addr = cpu_to_le32(addr & 0xffffffff);
494 ahci_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16); 509 ahci_sg->addr_hi = cpu_to_le32((addr >> 16) >> 16);
495 ahci_sg->flags_size = cpu_to_le32(sg_len - 1); 510 ahci_sg->flags_size = cpu_to_le32(sg_len - 1);
511
496 ahci_sg++; 512 ahci_sg++;
513 n_sg++;
497 } 514 }
515
516 return n_sg;
498} 517}
499 518
500static void ahci_qc_prep(struct ata_queued_cmd *qc) 519static void ahci_qc_prep(struct ata_queued_cmd *qc)
@@ -503,13 +522,14 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
503 struct ahci_port_priv *pp = ap->private_data; 522 struct ahci_port_priv *pp = ap->private_data;
504 u32 opts; 523 u32 opts;
505 const u32 cmd_fis_len = 5; /* five dwords */ 524 const u32 cmd_fis_len = 5; /* five dwords */
525 unsigned int n_elem;
506 526
507 /* 527 /*
508 * Fill in command slot information (currently only one slot, 528 * Fill in command slot information (currently only one slot,
509 * slot 0, is currently since we don't do queueing) 529 * slot 0, is currently since we don't do queueing)
510 */ 530 */
511 531
512 opts = (qc->n_elem << 16) | cmd_fis_len; 532 opts = cmd_fis_len;
513 if (qc->tf.flags & ATA_TFLAG_WRITE) 533 if (qc->tf.flags & ATA_TFLAG_WRITE)
514 opts |= AHCI_CMD_WRITE; 534 opts |= AHCI_CMD_WRITE;
515 if (is_atapi_taskfile(&qc->tf)) 535 if (is_atapi_taskfile(&qc->tf))
@@ -533,16 +553,31 @@ static void ahci_qc_prep(struct ata_queued_cmd *qc)
533 if (!(qc->flags & ATA_QCFLAG_DMAMAP)) 553 if (!(qc->flags & ATA_QCFLAG_DMAMAP))
534 return; 554 return;
535 555
536 ahci_fill_sg(qc); 556 n_elem = ahci_fill_sg(qc);
557
558 pp->cmd_slot[0].opts |= cpu_to_le32(n_elem << 16);
537} 559}
538 560
539static void ahci_intr_error(struct ata_port *ap, u32 irq_stat) 561static void ahci_restart_port(struct ata_port *ap, u32 irq_stat)
540{ 562{
541 void __iomem *mmio = ap->host_set->mmio_base; 563 void __iomem *mmio = ap->host_set->mmio_base;
542 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no); 564 void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
543 u32 tmp; 565 u32 tmp;
544 int work; 566 int work;
545 567
568 if ((ap->device[0].class != ATA_DEV_ATAPI) ||
569 ((irq_stat & PORT_IRQ_TF_ERR) == 0))
570 printk(KERN_WARNING "ata%u: port reset, "
571 "p_is %x is %x pis %x cmd %x tf %x ss %x se %x\n",
572 ap->id,
573 irq_stat,
574 readl(mmio + HOST_IRQ_STAT),
575 readl(port_mmio + PORT_IRQ_STAT),
576 readl(port_mmio + PORT_CMD),
577 readl(port_mmio + PORT_TFDATA),
578 readl(port_mmio + PORT_SCR_STAT),
579 readl(port_mmio + PORT_SCR_ERR));
580
546 /* stop DMA */ 581 /* stop DMA */
547 tmp = readl(port_mmio + PORT_CMD); 582 tmp = readl(port_mmio + PORT_CMD);
548 tmp &= ~PORT_CMD_START; 583 tmp &= ~PORT_CMD_START;
@@ -580,8 +615,6 @@ static void ahci_intr_error(struct ata_port *ap, u32 irq_stat)
580 tmp |= PORT_CMD_START; 615 tmp |= PORT_CMD_START;
581 writel(tmp, port_mmio + PORT_CMD); 616 writel(tmp, port_mmio + PORT_CMD);
582 readl(port_mmio + PORT_CMD); /* flush */ 617 readl(port_mmio + PORT_CMD); /* flush */
583
584 printk(KERN_WARNING "ata%u: error occurred, port reset\n", ap->id);
585} 618}
586 619
587static void ahci_eng_timeout(struct ata_port *ap) 620static void ahci_eng_timeout(struct ata_port *ap)
@@ -592,17 +625,17 @@ static void ahci_eng_timeout(struct ata_port *ap)
592 struct ata_queued_cmd *qc; 625 struct ata_queued_cmd *qc;
593 unsigned long flags; 626 unsigned long flags;
594 627
595 DPRINTK("ENTER\n"); 628 printk(KERN_WARNING "ata%u: handling error/timeout\n", ap->id);
596 629
597 spin_lock_irqsave(&host_set->lock, flags); 630 spin_lock_irqsave(&host_set->lock, flags);
598 631
599 ahci_intr_error(ap, readl(port_mmio + PORT_IRQ_STAT));
600
601 qc = ata_qc_from_tag(ap, ap->active_tag); 632 qc = ata_qc_from_tag(ap, ap->active_tag);
602 if (!qc) { 633 if (!qc) {
603 printk(KERN_ERR "ata%u: BUG: timeout without command\n", 634 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
604 ap->id); 635 ap->id);
605 } else { 636 } else {
637 ahci_restart_port(ap, readl(port_mmio + PORT_IRQ_STAT));
638
606 /* hack alert! We cannot use the supplied completion 639 /* hack alert! We cannot use the supplied completion
607 * function from inside the ->eh_strategy_handler() thread. 640 * function from inside the ->eh_strategy_handler() thread.
608 * libata is the only user of ->eh_strategy_handler() in 641 * libata is the only user of ->eh_strategy_handler() in
@@ -637,9 +670,19 @@ static inline int ahci_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc)
637 } 670 }
638 671
639 if (status & PORT_IRQ_FATAL) { 672 if (status & PORT_IRQ_FATAL) {
640 ahci_intr_error(ap, status); 673 unsigned int err_mask;
674 if (status & PORT_IRQ_TF_ERR)
675 err_mask = AC_ERR_DEV;
676 else if (status & PORT_IRQ_IF_ERR)
677 err_mask = AC_ERR_ATA_BUS;
678 else
679 err_mask = AC_ERR_HOST_BUS;
680
681 /* command processing has stopped due to error; restart */
682 ahci_restart_port(ap, status);
683
641 if (qc) 684 if (qc)
642 ata_qc_complete(qc, AC_ERR_OTHER); 685 ata_qc_complete(qc, err_mask);
643 } 686 }
644 687
645 return 1; 688 return 1;
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index cfb46c241b38..6aab9dacdeea 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -436,29 +436,20 @@ ahd_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
436{ 436{
437 struct ahd_softc *ahd; 437 struct ahd_softc *ahd;
438 struct ahd_linux_device *dev = scsi_transport_device_data(cmd->device); 438 struct ahd_linux_device *dev = scsi_transport_device_data(cmd->device);
439 int rtn = SCSI_MLQUEUE_HOST_BUSY;
440 unsigned long flags;
439 441
440 ahd = *(struct ahd_softc **)cmd->device->host->hostdata; 442 ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
441 443
442 /* 444 ahd_lock(ahd, &flags);
443 * Close the race of a command that was in the process of 445 if (ahd->platform_data->qfrozen == 0) {
444 * being queued to us just as our simq was frozen. Let 446 cmd->scsi_done = scsi_done;
445 * DV commands through so long as we are only frozen to 447 cmd->result = CAM_REQ_INPROG << 16;
446 * perform DV. 448 rtn = ahd_linux_run_command(ahd, dev, cmd);
447 */
448 if (ahd->platform_data->qfrozen != 0) {
449 printf("%s: queue frozen\n", ahd_name(ahd));
450 449
451 return SCSI_MLQUEUE_HOST_BUSY;
452 } 450 }
453 451 ahd_unlock(ahd, &flags);
454 /* 452 return rtn;
455 * Save the callback on completion function.
456 */
457 cmd->scsi_done = scsi_done;
458
459 cmd->result = CAM_REQ_INPROG << 16;
460
461 return ahd_linux_run_command(ahd, dev, cmd);
462} 453}
463 454
464static inline struct scsi_target ** 455static inline struct scsi_target **
@@ -1081,7 +1072,6 @@ ahd_linux_register_host(struct ahd_softc *ahd, struct scsi_host_template *templa
1081 1072
1082 *((struct ahd_softc **)host->hostdata) = ahd; 1073 *((struct ahd_softc **)host->hostdata) = ahd;
1083 ahd_lock(ahd, &s); 1074 ahd_lock(ahd, &s);
1084 scsi_assign_lock(host, &ahd->platform_data->spin_lock);
1085 ahd->platform_data->host = host; 1075 ahd->platform_data->host = host;
1086 host->can_queue = AHD_MAX_QUEUE; 1076 host->can_queue = AHD_MAX_QUEUE;
1087 host->cmd_per_lun = 2; 1077 host->cmd_per_lun = 2;
@@ -2062,6 +2052,7 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2062 int wait; 2052 int wait;
2063 int disconnected; 2053 int disconnected;
2064 ahd_mode_state saved_modes; 2054 ahd_mode_state saved_modes;
2055 unsigned long flags;
2065 2056
2066 pending_scb = NULL; 2057 pending_scb = NULL;
2067 paused = FALSE; 2058 paused = FALSE;
@@ -2077,7 +2068,7 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2077 printf(" 0x%x", cmd->cmnd[cdb_byte]); 2068 printf(" 0x%x", cmd->cmnd[cdb_byte]);
2078 printf("\n"); 2069 printf("\n");
2079 2070
2080 spin_lock_irq(&ahd->platform_data->spin_lock); 2071 ahd_lock(ahd, &flags);
2081 2072
2082 /* 2073 /*
2083 * First determine if we currently own this command. 2074 * First determine if we currently own this command.
@@ -2114,7 +2105,7 @@ ahd_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2114 scmd_id(cmd), 2105 scmd_id(cmd),
2115 scmd_channel(cmd) + 'A', 2106 scmd_channel(cmd) + 'A',
2116 CAM_LUN_WILDCARD, 2107 CAM_LUN_WILDCARD,
2117 SCB_LIST_NULL, ROLE_INITIATOR) == 0) 2108 SCB_LIST_NULL, ROLE_INITIATOR))
2118 break; 2109 break;
2119 } 2110 }
2120 } 2111 }
@@ -2291,7 +2282,8 @@ done:
2291 int ret; 2282 int ret;
2292 2283
2293 ahd->platform_data->flags |= AHD_SCB_UP_EH_SEM; 2284 ahd->platform_data->flags |= AHD_SCB_UP_EH_SEM;
2294 spin_unlock_irq(&ahd->platform_data->spin_lock); 2285 ahd_unlock(ahd, &flags);
2286
2295 init_timer(&timer); 2287 init_timer(&timer);
2296 timer.data = (u_long)ahd; 2288 timer.data = (u_long)ahd;
2297 timer.expires = jiffies + (5 * HZ); 2289 timer.expires = jiffies + (5 * HZ);
@@ -2305,9 +2297,8 @@ done:
2305 printf("Timer Expired\n"); 2297 printf("Timer Expired\n");
2306 retval = FAILED; 2298 retval = FAILED;
2307 } 2299 }
2308 spin_lock_irq(&ahd->platform_data->spin_lock);
2309 } 2300 }
2310 spin_unlock_irq(&ahd->platform_data->spin_lock); 2301 ahd_unlock(ahd, &flags);
2311 return (retval); 2302 return (retval);
2312} 2303}
2313 2304
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 1861407422e4..d866213f42b8 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -476,26 +476,20 @@ ahc_linux_queue(struct scsi_cmnd * cmd, void (*scsi_done) (struct scsi_cmnd *))
476{ 476{
477 struct ahc_softc *ahc; 477 struct ahc_softc *ahc;
478 struct ahc_linux_device *dev = scsi_transport_device_data(cmd->device); 478 struct ahc_linux_device *dev = scsi_transport_device_data(cmd->device);
479 int rtn = SCSI_MLQUEUE_HOST_BUSY;
480 unsigned long flags;
479 481
480 ahc = *(struct ahc_softc **)cmd->device->host->hostdata; 482 ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
481 483
482 /* 484 ahc_lock(ahc, &flags);
483 * Save the callback on completion function. 485 if (ahc->platform_data->qfrozen == 0) {
484 */ 486 cmd->scsi_done = scsi_done;
485 cmd->scsi_done = scsi_done; 487 cmd->result = CAM_REQ_INPROG << 16;
486 488 rtn = ahc_linux_run_command(ahc, dev, cmd);
487 /* 489 }
488 * Close the race of a command that was in the process of 490 ahc_unlock(ahc, &flags);
489 * being queued to us just as our simq was frozen. Let
490 * DV commands through so long as we are only frozen to
491 * perform DV.
492 */
493 if (ahc->platform_data->qfrozen != 0)
494 return SCSI_MLQUEUE_HOST_BUSY;
495
496 cmd->result = CAM_REQ_INPROG << 16;
497 491
498 return ahc_linux_run_command(ahc, dev, cmd); 492 return rtn;
499} 493}
500 494
501static inline struct scsi_target ** 495static inline struct scsi_target **
@@ -1079,7 +1073,6 @@ ahc_linux_register_host(struct ahc_softc *ahc, struct scsi_host_template *templa
1079 1073
1080 *((struct ahc_softc **)host->hostdata) = ahc; 1074 *((struct ahc_softc **)host->hostdata) = ahc;
1081 ahc_lock(ahc, &s); 1075 ahc_lock(ahc, &s);
1082 scsi_assign_lock(host, &ahc->platform_data->spin_lock);
1083 ahc->platform_data->host = host; 1076 ahc->platform_data->host = host;
1084 host->can_queue = AHC_MAX_QUEUE; 1077 host->can_queue = AHC_MAX_QUEUE;
1085 host->cmd_per_lun = 2; 1078 host->cmd_per_lun = 2;
@@ -2111,6 +2104,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2111 int paused; 2104 int paused;
2112 int wait; 2105 int wait;
2113 int disconnected; 2106 int disconnected;
2107 unsigned long flags;
2114 2108
2115 pending_scb = NULL; 2109 pending_scb = NULL;
2116 paused = FALSE; 2110 paused = FALSE;
@@ -2125,7 +2119,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2125 printf(" 0x%x", cmd->cmnd[cdb_byte]); 2119 printf(" 0x%x", cmd->cmnd[cdb_byte]);
2126 printf("\n"); 2120 printf("\n");
2127 2121
2128 spin_lock_irq(&ahc->platform_data->spin_lock); 2122 ahc_lock(ahc, &flags);
2129 2123
2130 /* 2124 /*
2131 * First determine if we currently own this command. 2125 * First determine if we currently own this command.
@@ -2175,7 +2169,7 @@ ahc_linux_queue_recovery_cmd(struct scsi_cmnd *cmd, scb_flag flag)
2175 if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd), 2169 if (ahc_match_scb(ahc, pending_scb, scmd_id(cmd),
2176 scmd_channel(cmd) + 'A', 2170 scmd_channel(cmd) + 'A',
2177 CAM_LUN_WILDCARD, 2171 CAM_LUN_WILDCARD,
2178 SCB_LIST_NULL, ROLE_INITIATOR) == 0) 2172 SCB_LIST_NULL, ROLE_INITIATOR))
2179 break; 2173 break;
2180 } 2174 }
2181 } 2175 }
@@ -2357,7 +2351,8 @@ done:
2357 int ret; 2351 int ret;
2358 2352
2359 ahc->platform_data->flags |= AHC_UP_EH_SEMAPHORE; 2353 ahc->platform_data->flags |= AHC_UP_EH_SEMAPHORE;
2360 spin_unlock_irq(&ahc->platform_data->spin_lock); 2354 ahc_unlock(ahc, &flags);
2355
2361 init_timer(&timer); 2356 init_timer(&timer);
2362 timer.data = (u_long)ahc; 2357 timer.data = (u_long)ahc;
2363 timer.expires = jiffies + (5 * HZ); 2358 timer.expires = jiffies + (5 * HZ);
@@ -2371,10 +2366,8 @@ done:
2371 printf("Timer Expired\n"); 2366 printf("Timer Expired\n");
2372 retval = FAILED; 2367 retval = FAILED;
2373 } 2368 }
2374 spin_lock_irq(&ahc->platform_data->spin_lock); 2369 } else
2375 } 2370 ahc_unlock(ahc, &flags);
2376
2377 spin_unlock_irq(&ahc->platform_data->spin_lock);
2378 return (retval); 2371 return (retval);
2379} 2372}
2380 2373
diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c
index 880e2d9ffe9b..33d56c344944 100644
--- a/drivers/scsi/aic7xxx_old.c
+++ b/drivers/scsi/aic7xxx_old.c
@@ -6514,7 +6514,7 @@ do_aic7xxx_isr(int irq, void *dev_id, struct pt_regs *regs)
6514static void 6514static void
6515aic7xxx_init_transinfo(struct aic7xxx_host *p, struct aic_dev_data *aic_dev) 6515aic7xxx_init_transinfo(struct aic7xxx_host *p, struct aic_dev_data *aic_dev)
6516{ 6516{
6517 Scsi_Device *sdpnt = aic_dev->SDptr; 6517 struct scsi_device *sdpnt = aic_dev->SDptr;
6518 unsigned char tindex; 6518 unsigned char tindex;
6519 6519
6520 tindex = sdpnt->id | (sdpnt->channel << 3); 6520 tindex = sdpnt->id | (sdpnt->channel << 3);
@@ -6581,7 +6581,7 @@ aic7xxx_init_transinfo(struct aic7xxx_host *p, struct aic_dev_data *aic_dev)
6581 * Set up the initial aic_dev struct pointers 6581 * Set up the initial aic_dev struct pointers
6582 *-F*************************************************************************/ 6582 *-F*************************************************************************/
6583static int 6583static int
6584aic7xxx_slave_alloc(Scsi_Device *SDptr) 6584aic7xxx_slave_alloc(struct scsi_device *SDptr)
6585{ 6585{
6586 struct aic7xxx_host *p = (struct aic7xxx_host *)SDptr->host->hostdata; 6586 struct aic7xxx_host *p = (struct aic7xxx_host *)SDptr->host->hostdata;
6587 struct aic_dev_data *aic_dev; 6587 struct aic_dev_data *aic_dev;
@@ -6644,7 +6644,7 @@ aic7xxx_slave_alloc(Scsi_Device *SDptr)
6644 * queueing to be [en|dis]abled for a specific adapter. 6644 * queueing to be [en|dis]abled for a specific adapter.
6645 *-F*************************************************************************/ 6645 *-F*************************************************************************/
6646static void 6646static void
6647aic7xxx_device_queue_depth(struct aic7xxx_host *p, Scsi_Device *device) 6647aic7xxx_device_queue_depth(struct aic7xxx_host *p, struct scsi_device *device)
6648{ 6648{
6649 int tag_enabled = FALSE; 6649 int tag_enabled = FALSE;
6650 struct aic_dev_data *aic_dev = device->hostdata; 6650 struct aic_dev_data *aic_dev = device->hostdata;
@@ -6734,7 +6734,7 @@ aic7xxx_device_queue_depth(struct aic7xxx_host *p, Scsi_Device *device)
6734 * prepare for this device to go away 6734 * prepare for this device to go away
6735 *-F*************************************************************************/ 6735 *-F*************************************************************************/
6736static void 6736static void
6737aic7xxx_slave_destroy(Scsi_Device *SDptr) 6737aic7xxx_slave_destroy(struct scsi_device *SDptr)
6738{ 6738{
6739 struct aic_dev_data *aic_dev = SDptr->hostdata; 6739 struct aic_dev_data *aic_dev = SDptr->hostdata;
6740 6740
@@ -6754,7 +6754,7 @@ aic7xxx_slave_destroy(Scsi_Device *SDptr)
6754 * depths, allocate command structs, etc. 6754 * depths, allocate command structs, etc.
6755 *-F*************************************************************************/ 6755 *-F*************************************************************************/
6756static int 6756static int
6757aic7xxx_slave_configure(Scsi_Device *SDptr) 6757aic7xxx_slave_configure(struct scsi_device *SDptr)
6758{ 6758{
6759 struct aic7xxx_host *p = (struct aic7xxx_host *) SDptr->host->hostdata; 6759 struct aic7xxx_host *p = (struct aic7xxx_host *) SDptr->host->hostdata;
6760 struct aic_dev_data *aic_dev; 6760 struct aic_dev_data *aic_dev;
@@ -7865,7 +7865,7 @@ detect_maxscb(struct aic7xxx_host *p)
7865 * Register a Adaptec aic7xxx chip SCSI controller with the kernel. 7865 * Register a Adaptec aic7xxx chip SCSI controller with the kernel.
7866 *-F*************************************************************************/ 7866 *-F*************************************************************************/
7867static int 7867static int
7868aic7xxx_register(Scsi_Host_Template *template, struct aic7xxx_host *p, 7868aic7xxx_register(struct scsi_host_template *template, struct aic7xxx_host *p,
7869 int reset_delay) 7869 int reset_delay)
7870{ 7870{
7871 int i, result; 7871 int i, result;
@@ -8412,7 +8412,7 @@ aic7xxx_chip_reset(struct aic7xxx_host *p)
8412 * and a pointer to a aic7xxx_host struct upon success. 8412 * and a pointer to a aic7xxx_host struct upon success.
8413 *-F*************************************************************************/ 8413 *-F*************************************************************************/
8414static struct aic7xxx_host * 8414static struct aic7xxx_host *
8415aic7xxx_alloc(Scsi_Host_Template *sht, struct aic7xxx_host *temp) 8415aic7xxx_alloc(struct scsi_host_template *sht, struct aic7xxx_host *temp)
8416{ 8416{
8417 struct aic7xxx_host *p = NULL; 8417 struct aic7xxx_host *p = NULL;
8418 struct Scsi_Host *host; 8418 struct Scsi_Host *host;
@@ -8991,7 +8991,7 @@ aic7xxx_configure_bugs(struct aic7xxx_host *p)
8991 * mid-level SCSI code is overhauled. 8991 * mid-level SCSI code is overhauled.
8992 *-F*************************************************************************/ 8992 *-F*************************************************************************/
8993static int 8993static int
8994aic7xxx_detect(Scsi_Host_Template *template) 8994aic7xxx_detect(struct scsi_host_template *template)
8995{ 8995{
8996 struct aic7xxx_host *temp_p = NULL; 8996 struct aic7xxx_host *temp_p = NULL;
8997 struct aic7xxx_host *current_p = NULL; 8997 struct aic7xxx_host *current_p = NULL;
@@ -11161,7 +11161,7 @@ MODULE_LICENSE("Dual BSD/GPL");
11161MODULE_VERSION(AIC7XXX_H_VERSION); 11161MODULE_VERSION(AIC7XXX_H_VERSION);
11162 11162
11163 11163
11164static Scsi_Host_Template driver_template = { 11164static struct scsi_host_template driver_template = {
11165 .proc_info = aic7xxx_proc_info, 11165 .proc_info = aic7xxx_proc_info,
11166 .detect = aic7xxx_detect, 11166 .detect = aic7xxx_detect,
11167 .release = aic7xxx_release, 11167 .release = aic7xxx_release,
diff --git a/drivers/scsi/amiga7xx.c b/drivers/scsi/amiga7xx.c
index dea8446f5360..c0844fa32c5d 100644
--- a/drivers/scsi/amiga7xx.c
+++ b/drivers/scsi/amiga7xx.c
@@ -29,7 +29,7 @@
29#include "amiga7xx.h" 29#include "amiga7xx.h"
30 30
31 31
32static int amiga7xx_register_one(Scsi_Host_Template *tpnt, 32static int amiga7xx_register_one(struct scsi_host_template *tpnt,
33 unsigned long address) 33 unsigned long address)
34{ 34{
35 long long options; 35 long long options;
@@ -65,7 +65,7 @@ static struct {
65 { 0 } 65 { 0 }
66}; 66};
67 67
68static int __init amiga7xx_zorro_detect(Scsi_Host_Template *tpnt) 68static int __init amiga7xx_zorro_detect(struct scsi_host_template *tpnt)
69{ 69{
70 int num = 0, i; 70 int num = 0, i;
71 struct zorro_dev *z = NULL; 71 struct zorro_dev *z = NULL;
@@ -89,7 +89,7 @@ static int __init amiga7xx_zorro_detect(Scsi_Host_Template *tpnt)
89#endif /* CONFIG_ZORRO */ 89#endif /* CONFIG_ZORRO */
90 90
91 91
92int __init amiga7xx_detect(Scsi_Host_Template *tpnt) 92int __init amiga7xx_detect(struct scsi_host_template *tpnt)
93{ 93{
94 static unsigned char called = 0; 94 static unsigned char called = 0;
95 int num = 0; 95 int num = 0;
@@ -122,7 +122,7 @@ static int amiga7xx_release(struct Scsi_Host *shost)
122 return 0; 122 return 0;
123} 123}
124 124
125static Scsi_Host_Template driver_template = { 125static struct scsi_host_template driver_template = {
126 .name = "Amiga NCR53c710 SCSI", 126 .name = "Amiga NCR53c710 SCSI",
127 .detect = amiga7xx_detect, 127 .detect = amiga7xx_detect,
128 .release = amiga7xx_release, 128 .release = amiga7xx_release,
diff --git a/drivers/scsi/amiga7xx.h b/drivers/scsi/amiga7xx.h
index 8cc54a5b889e..1b637592d5ae 100644
--- a/drivers/scsi/amiga7xx.h
+++ b/drivers/scsi/amiga7xx.h
@@ -2,7 +2,7 @@
2 2
3#include <linux/types.h> 3#include <linux/types.h>
4 4
5int amiga7xx_detect(Scsi_Host_Template *); 5int amiga7xx_detect(struct scsi_host_template *);
6const char *NCR53c7x0_info(void); 6const char *NCR53c7x0_info(void);
7int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 7int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
8int NCR53c7xx_abort(Scsi_Cmnd *); 8int NCR53c7xx_abort(Scsi_Cmnd *);
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index be2caecbbdd9..b7b20c689c24 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -896,7 +896,7 @@ void acornscsi_done(AS_Host *host, Scsi_Cmnd **SCpntp, unsigned int result)
896 * Notes : this will only be one SG entry or less 896 * Notes : this will only be one SG entry or less
897 */ 897 */
898static 898static
899void acornscsi_data_updateptr(AS_Host *host, Scsi_Pointer *SCp, unsigned int length) 899void acornscsi_data_updateptr(AS_Host *host, struct scsi_pointer *SCp, unsigned int length)
900{ 900{
901 SCp->ptr += length; 901 SCp->ptr += length;
902 SCp->this_residual -= length; 902 SCp->this_residual -= length;
@@ -2862,7 +2862,7 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start,
2862 int length, int inout) 2862 int length, int inout)
2863{ 2863{
2864 int pos, begin = 0, devidx; 2864 int pos, begin = 0, devidx;
2865 Scsi_Device *scd; 2865 struct scsi_device *scd;
2866 AS_Host *host; 2866 AS_Host *host;
2867 char *p = buffer; 2867 char *p = buffer;
2868 2868
@@ -2971,7 +2971,7 @@ int acornscsi_proc_info(struct Scsi_Host *instance, char *buffer, char **start,
2971 return pos; 2971 return pos;
2972} 2972}
2973 2973
2974static Scsi_Host_Template acornscsi_template = { 2974static struct scsi_host_template acornscsi_template = {
2975 .module = THIS_MODULE, 2975 .module = THIS_MODULE,
2976 .proc_info = acornscsi_proc_info, 2976 .proc_info = acornscsi_proc_info,
2977 .name = "AcornSCSI", 2977 .name = "AcornSCSI",
diff --git a/drivers/scsi/arm/acornscsi.h b/drivers/scsi/arm/acornscsi.h
index 03881f091645..2142290f8404 100644
--- a/drivers/scsi/arm/acornscsi.h
+++ b/drivers/scsi/arm/acornscsi.h
@@ -292,7 +292,7 @@ typedef struct acornscsi_hostdata {
292 unsigned char tag; /* reconnected tag */ 292 unsigned char tag; /* reconnected tag */
293 } reconnected; 293 } reconnected;
294 294
295 Scsi_Pointer SCp; /* current commands data pointer */ 295 struct scsi_pointer SCp; /* current commands data pointer */
296 296
297 MsgQueue_t msgs; 297 MsgQueue_t msgs;
298 298
diff --git a/drivers/scsi/arm/arxescsi.c b/drivers/scsi/arm/arxescsi.c
index 29811f5891ee..804125e35fc3 100644
--- a/drivers/scsi/arm/arxescsi.c
+++ b/drivers/scsi/arm/arxescsi.c
@@ -65,7 +65,7 @@ struct arxescsi_info {
65 * Returns : 0 if we should not set CMD_WITHDMA for transfer info command 65 * Returns : 0 if we should not set CMD_WITHDMA for transfer info command
66 */ 66 */
67static fasdmatype_t 67static fasdmatype_t
68arxescsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, 68arxescsi_dma_setup(struct Scsi_Host *host, struct scsi_pointer *SCp,
69 fasdmadir_t direction, fasdmatype_t min_type) 69 fasdmadir_t direction, fasdmatype_t min_type)
70{ 70{
71 /* 71 /*
@@ -111,7 +111,7 @@ static void arxescsi_pseudo_dma_write(unsigned char *addr, void __iomem *base)
111 * transfer - minimum number of bytes we expect to transfer 111 * transfer - minimum number of bytes we expect to transfer
112 */ 112 */
113static void 113static void
114arxescsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp, 114arxescsi_dma_pseudo(struct Scsi_Host *host, struct scsi_pointer *SCp,
115 fasdmadir_t direction, int transfer) 115 fasdmadir_t direction, int transfer)
116{ 116{
117 struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata; 117 struct arxescsi_info *info = (struct arxescsi_info *)host->hostdata;
@@ -197,7 +197,7 @@ arxescsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
197 * Params : host - host 197 * Params : host - host
198 * SCpnt - command 198 * SCpnt - command
199 */ 199 */
200static void arxescsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) 200static void arxescsi_dma_stop(struct Scsi_Host *host, struct scsi_pointer *SCp)
201{ 201{
202 /* 202 /*
203 * no DMA to stop 203 * no DMA to stop
@@ -261,7 +261,7 @@ arxescsi_proc_info(struct Scsi_Host *host, char *buffer, char **start, off_t off
261 return pos; 261 return pos;
262} 262}
263 263
264static Scsi_Host_Template arxescsi_template = { 264static struct scsi_host_template arxescsi_template = {
265 .proc_info = arxescsi_proc_info, 265 .proc_info = arxescsi_proc_info,
266 .name = "ARXE SCSI card", 266 .name = "ARXE SCSI card",
267 .info = arxescsi_info, 267 .info = arxescsi_info,
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c
index 26498553a7cc..81e266be26d0 100644
--- a/drivers/scsi/arm/cumana_1.c
+++ b/drivers/scsi/arm/cumana_1.c
@@ -238,7 +238,7 @@ static void cumanascsi_write(struct Scsi_Host *instance, int reg, int value)
238 238
239#include "../NCR5380.c" 239#include "../NCR5380.c"
240 240
241static Scsi_Host_Template cumanascsi_template = { 241static struct scsi_host_template cumanascsi_template = {
242 .module = THIS_MODULE, 242 .module = THIS_MODULE,
243 .name = "Cumana 16-bit SCSI", 243 .name = "Cumana 16-bit SCSI",
244 .info = cumanascsi_info, 244 .info = cumanascsi_info,
diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c
index 0ef0644eeb29..3a7a46b0dc41 100644
--- a/drivers/scsi/arm/cumana_2.c
+++ b/drivers/scsi/arm/cumana_2.c
@@ -157,7 +157,7 @@ cumanascsi_2_intr(int irq, void *dev_id, struct pt_regs *regs)
157 * Returns : type of transfer to be performed 157 * Returns : type of transfer to be performed
158 */ 158 */
159static fasdmatype_t 159static fasdmatype_t
160cumanascsi_2_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, 160cumanascsi_2_dma_setup(struct Scsi_Host *host, struct scsi_pointer *SCp,
161 fasdmadir_t direction, fasdmatype_t min_type) 161 fasdmadir_t direction, fasdmatype_t min_type)
162{ 162{
163 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; 163 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
@@ -209,7 +209,7 @@ cumanascsi_2_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
209 * transfer - minimum number of bytes we expect to transfer 209 * transfer - minimum number of bytes we expect to transfer
210 */ 210 */
211static void 211static void
212cumanascsi_2_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp, 212cumanascsi_2_dma_pseudo(struct Scsi_Host *host, struct scsi_pointer *SCp,
213 fasdmadir_t direction, int transfer) 213 fasdmadir_t direction, int transfer)
214{ 214{
215 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; 215 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
@@ -283,7 +283,7 @@ cumanascsi_2_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
283 * SCpnt - command 283 * SCpnt - command
284 */ 284 */
285static void 285static void
286cumanascsi_2_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) 286cumanascsi_2_dma_stop(struct Scsi_Host *host, struct scsi_pointer *SCp)
287{ 287{
288 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata; 288 struct cumanascsi2_info *info = (struct cumanascsi2_info *)host->hostdata;
289 if (info->info.scsi.dma != NO_DMA) { 289 if (info->info.scsi.dma != NO_DMA) {
@@ -381,7 +381,7 @@ int cumanascsi_2_proc_info (struct Scsi_Host *host, char *buffer, char **start,
381 return pos; 381 return pos;
382} 382}
383 383
384static Scsi_Host_Template cumanascsi2_template = { 384static struct scsi_host_template cumanascsi2_template = {
385 .module = THIS_MODULE, 385 .module = THIS_MODULE,
386 .proc_info = cumanascsi_2_proc_info, 386 .proc_info = cumanascsi_2_proc_info,
387 .name = "Cumana SCSI II", 387 .name = "Cumana SCSI II",
diff --git a/drivers/scsi/arm/ecoscsi.c b/drivers/scsi/arm/ecoscsi.c
index f8a7fdd3c465..6adcccbf444b 100644
--- a/drivers/scsi/arm/ecoscsi.c
+++ b/drivers/scsi/arm/ecoscsi.c
@@ -155,7 +155,7 @@ printk("reading %p len %d\n",addr, len);
155 155
156#include "../NCR5380.c" 156#include "../NCR5380.c"
157 157
158static Scsi_Host_Template ecoscsi_template = { 158static struct scsi_host_template ecoscsi_template = {
159 .module = THIS_MODULE, 159 .module = THIS_MODULE,
160 .name = "Serial Port EcoSCSI NCR5380", 160 .name = "Serial Port EcoSCSI NCR5380",
161 .proc_name = "ecoscsi", 161 .proc_name = "ecoscsi",
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
index ce711f166cfb..4d1e8f52c924 100644
--- a/drivers/scsi/arm/eesox.c
+++ b/drivers/scsi/arm/eesox.c
@@ -158,7 +158,7 @@ eesoxscsi_intr(int irq, void *dev_id, struct pt_regs *regs)
158 * Returns : type of transfer to be performed 158 * Returns : type of transfer to be performed
159 */ 159 */
160static fasdmatype_t 160static fasdmatype_t
161eesoxscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, 161eesoxscsi_dma_setup(struct Scsi_Host *host, struct scsi_pointer *SCp,
162 fasdmadir_t direction, fasdmatype_t min_type) 162 fasdmadir_t direction, fasdmatype_t min_type)
163{ 163{
164 struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata; 164 struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
@@ -353,7 +353,7 @@ static void eesoxscsi_buffer_out(void *buf, int length, void __iomem *base)
353} 353}
354 354
355static void 355static void
356eesoxscsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp, 356eesoxscsi_dma_pseudo(struct Scsi_Host *host, struct scsi_pointer *SCp,
357 fasdmadir_t dir, int transfer_size) 357 fasdmadir_t dir, int transfer_size)
358{ 358{
359 struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata; 359 struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
@@ -370,7 +370,7 @@ eesoxscsi_dma_pseudo(struct Scsi_Host *host, Scsi_Pointer *SCp,
370 * SCpnt - command 370 * SCpnt - command
371 */ 371 */
372static void 372static void
373eesoxscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) 373eesoxscsi_dma_stop(struct Scsi_Host *host, struct scsi_pointer *SCp)
374{ 374{
375 struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata; 375 struct eesoxscsi_info *info = (struct eesoxscsi_info *)host->hostdata;
376 if (info->info.scsi.dma != NO_DMA) 376 if (info->info.scsi.dma != NO_DMA)
@@ -499,7 +499,7 @@ static ssize_t eesoxscsi_store_term(struct device *dev, struct device_attribute
499static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR, 499static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR,
500 eesoxscsi_show_term, eesoxscsi_store_term); 500 eesoxscsi_show_term, eesoxscsi_store_term);
501 501
502static Scsi_Host_Template eesox_template = { 502static struct scsi_host_template eesox_template = {
503 .module = THIS_MODULE, 503 .module = THIS_MODULE,
504 .proc_info = eesoxscsi_proc_info, 504 .proc_info = eesoxscsi_proc_info,
505 .name = "EESOX SCSI", 505 .name = "EESOX SCSI",
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 4772fb317f3e..3e1053f111dc 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -173,7 +173,7 @@ static void fas216_dumpstate(FAS216_Info *info)
173 fas216_readb(info, REG_CTCH)); 173 fas216_readb(info, REG_CTCH));
174} 174}
175 175
176static void print_SCp(Scsi_Pointer *SCp, const char *prefix, const char *suffix) 176static void print_SCp(struct scsi_pointer *SCp, const char *prefix, const char *suffix)
177{ 177{
178 printk("%sptr %p this_residual 0x%x buffer %p buffers_residual 0x%x%s", 178 printk("%sptr %p this_residual 0x%x buffer %p buffers_residual 0x%x%s",
179 prefix, SCp->ptr, SCp->this_residual, SCp->buffer, 179 prefix, SCp->ptr, SCp->this_residual, SCp->buffer,
@@ -628,7 +628,7 @@ static void fas216_handlesync(FAS216_Info *info, char *msg)
628 */ 628 */
629static void fas216_updateptrs(FAS216_Info *info, int bytes_transferred) 629static void fas216_updateptrs(FAS216_Info *info, int bytes_transferred)
630{ 630{
631 Scsi_Pointer *SCp = &info->scsi.SCp; 631 struct scsi_pointer *SCp = &info->scsi.SCp;
632 632
633 fas216_checkmagic(info); 633 fas216_checkmagic(info);
634 634
@@ -668,7 +668,7 @@ static void fas216_updateptrs(FAS216_Info *info, int bytes_transferred)
668 */ 668 */
669static void fas216_pio(FAS216_Info *info, fasdmadir_t direction) 669static void fas216_pio(FAS216_Info *info, fasdmadir_t direction)
670{ 670{
671 Scsi_Pointer *SCp = &info->scsi.SCp; 671 struct scsi_pointer *SCp = &info->scsi.SCp;
672 672
673 fas216_checkmagic(info); 673 fas216_checkmagic(info);
674 674
@@ -2559,7 +2559,7 @@ int fas216_eh_bus_reset(Scsi_Cmnd *SCpnt)
2559{ 2559{
2560 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata; 2560 FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
2561 unsigned long flags; 2561 unsigned long flags;
2562 Scsi_Device *SDpnt; 2562 struct scsi_device *SDpnt;
2563 2563
2564 fas216_checkmagic(info); 2564 fas216_checkmagic(info);
2565 fas216_log(info, LOG_ERROR, "resetting bus"); 2565 fas216_log(info, LOG_ERROR, "resetting bus");
@@ -3000,7 +3000,7 @@ int fas216_print_stats(FAS216_Info *info, char *buffer)
3000int fas216_print_devices(FAS216_Info *info, char *buffer) 3000int fas216_print_devices(FAS216_Info *info, char *buffer)
3001{ 3001{
3002 struct fas216_device *dev; 3002 struct fas216_device *dev;
3003 Scsi_Device *scd; 3003 struct scsi_device *scd;
3004 char *p = buffer; 3004 char *p = buffer;
3005 3005
3006 p += sprintf(p, "Device/Lun TaggedQ Parity Sync\n"); 3006 p += sprintf(p, "Device/Lun TaggedQ Parity Sync\n");
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
index 60a2a120205b..540914d6fd32 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -243,7 +243,7 @@ typedef struct {
243 unsigned int irq; /* interrupt */ 243 unsigned int irq; /* interrupt */
244 int dma; /* dma channel */ 244 int dma; /* dma channel */
245 245
246 Scsi_Pointer SCp; /* current commands data pointer */ 246 struct scsi_pointer SCp; /* current commands data pointer */
247 247
248 MsgQueue_t msgs; /* message queue for connected device */ 248 MsgQueue_t msgs; /* message queue for connected device */
249 249
@@ -304,9 +304,9 @@ typedef struct {
304 /* dma */ 304 /* dma */
305 struct { 305 struct {
306 fasdmatype_t transfer_type; /* current type of DMA transfer */ 306 fasdmatype_t transfer_type; /* current type of DMA transfer */
307 fasdmatype_t (*setup) (struct Scsi_Host *host, Scsi_Pointer *SCp, fasdmadir_t direction, fasdmatype_t min_dma); 307 fasdmatype_t (*setup) (struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, fasdmatype_t min_dma);
308 void (*pseudo)(struct Scsi_Host *host, Scsi_Pointer *SCp, fasdmadir_t direction, int transfer); 308 void (*pseudo)(struct Scsi_Host *host, struct scsi_pointer *SCp, fasdmadir_t direction, int transfer);
309 void (*stop) (struct Scsi_Host *host, Scsi_Pointer *SCp); 309 void (*stop) (struct Scsi_Host *host, struct scsi_pointer *SCp);
310 } dma; 310 } dma;
311 311
312 /* miscellaneous */ 312 /* miscellaneous */
diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c
index de24bb991f1d..d806b024c3bd 100644
--- a/drivers/scsi/arm/oak.c
+++ b/drivers/scsi/arm/oak.c
@@ -111,7 +111,7 @@ printk("reading %p len %d\n", addr, len);
111 111
112#include "../NCR5380.c" 112#include "../NCR5380.c"
113 113
114static Scsi_Host_Template oakscsi_template = { 114static struct scsi_host_template oakscsi_template = {
115 .module = THIS_MODULE, 115 .module = THIS_MODULE,
116 .proc_info = oakscsi_proc_info, 116 .proc_info = oakscsi_proc_info,
117 .name = "Oak 16-bit SCSI", 117 .name = "Oak 16-bit SCSI",
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
index abda216113f1..3333d7b39139 100644
--- a/drivers/scsi/arm/powertec.c
+++ b/drivers/scsi/arm/powertec.c
@@ -132,7 +132,7 @@ powertecscsi_intr(int irq, void *dev_id, struct pt_regs *regs)
132 * Returns : type of transfer to be performed 132 * Returns : type of transfer to be performed
133 */ 133 */
134static fasdmatype_t 134static fasdmatype_t
135powertecscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp, 135powertecscsi_dma_setup(struct Scsi_Host *host, struct scsi_pointer *SCp,
136 fasdmadir_t direction, fasdmatype_t min_type) 136 fasdmadir_t direction, fasdmatype_t min_type)
137{ 137{
138 struct powertec_info *info = (struct powertec_info *)host->hostdata; 138 struct powertec_info *info = (struct powertec_info *)host->hostdata;
@@ -174,7 +174,7 @@ powertecscsi_dma_setup(struct Scsi_Host *host, Scsi_Pointer *SCp,
174 * SCpnt - command 174 * SCpnt - command
175 */ 175 */
176static void 176static void
177powertecscsi_dma_stop(struct Scsi_Host *host, Scsi_Pointer *SCp) 177powertecscsi_dma_stop(struct Scsi_Host *host, struct scsi_pointer *SCp)
178{ 178{
179 struct powertec_info *info = (struct powertec_info *)host->hostdata; 179 struct powertec_info *info = (struct powertec_info *)host->hostdata;
180 if (info->info.scsi.dma != NO_DMA) 180 if (info->info.scsi.dma != NO_DMA)
@@ -293,7 +293,7 @@ powertecscsi_store_term(struct device *dev, struct device_attribute *attr, const
293static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR, 293static DEVICE_ATTR(bus_term, S_IRUGO | S_IWUSR,
294 powertecscsi_show_term, powertecscsi_store_term); 294 powertecscsi_show_term, powertecscsi_store_term);
295 295
296static Scsi_Host_Template powertecscsi_template = { 296static struct scsi_host_template powertecscsi_template = {
297 .module = THIS_MODULE, 297 .module = THIS_MODULE,
298 .proc_info = powertecscsi_proc_info, 298 .proc_info = powertecscsi_proc_info,
299 .name = "PowerTec SCSI", 299 .name = "PowerTec SCSI",
diff --git a/drivers/scsi/arm/scsi.h b/drivers/scsi/arm/scsi.h
index 19937640e2e7..6dd544a5eb56 100644
--- a/drivers/scsi/arm/scsi.h
+++ b/drivers/scsi/arm/scsi.h
@@ -18,7 +18,7 @@
18 * The scatter-gather list handling. This contains all 18 * The scatter-gather list handling. This contains all
19 * the yucky stuff that needs to be fixed properly. 19 * the yucky stuff that needs to be fixed properly.
20 */ 20 */
21static inline int copy_SCp_to_sg(struct scatterlist *sg, Scsi_Pointer *SCp, int max) 21static inline int copy_SCp_to_sg(struct scatterlist *sg, struct scsi_pointer *SCp, int max)
22{ 22{
23 int bufs = SCp->buffers_residual; 23 int bufs = SCp->buffers_residual;
24 24
@@ -32,7 +32,7 @@ static inline int copy_SCp_to_sg(struct scatterlist *sg, Scsi_Pointer *SCp, int
32 return bufs + 1; 32 return bufs + 1;
33} 33}
34 34
35static inline int next_SCp(Scsi_Pointer *SCp) 35static inline int next_SCp(struct scsi_pointer *SCp)
36{ 36{
37 int ret = SCp->buffers_residual; 37 int ret = SCp->buffers_residual;
38 if (ret) { 38 if (ret) {
@@ -49,7 +49,7 @@ static inline int next_SCp(Scsi_Pointer *SCp)
49 return ret; 49 return ret;
50} 50}
51 51
52static inline unsigned char get_next_SCp_byte(Scsi_Pointer *SCp) 52static inline unsigned char get_next_SCp_byte(struct scsi_pointer *SCp)
53{ 53{
54 char c = *SCp->ptr; 54 char c = *SCp->ptr;
55 55
@@ -59,7 +59,7 @@ static inline unsigned char get_next_SCp_byte(Scsi_Pointer *SCp)
59 return c; 59 return c;
60} 60}
61 61
62static inline void put_next_SCp_byte(Scsi_Pointer *SCp, unsigned char c) 62static inline void put_next_SCp_byte(struct scsi_pointer *SCp, unsigned char c)
63{ 63{
64 *SCp->ptr = c; 64 *SCp->ptr = c;
65 SCp->ptr += 1; 65 SCp->ptr += 1;
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index a1bd8d95623c..333d69dd84ef 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -50,7 +50,7 @@
50#include <linux/libata.h> 50#include <linux/libata.h>
51 51
52#define DRV_NAME "ata_piix" 52#define DRV_NAME "ata_piix"
53#define DRV_VERSION "1.04" 53#define DRV_VERSION "1.05"
54 54
55enum { 55enum {
56 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */ 56 PIIX_IOCFG = 0x54, /* IDE I/O configuration register */
@@ -95,7 +95,7 @@ static void piix_set_dmamode (struct ata_port *ap, struct ata_device *adev);
95 95
96static unsigned int in_module_init = 1; 96static unsigned int in_module_init = 1;
97 97
98static struct pci_device_id piix_pci_tbl[] = { 98static const struct pci_device_id piix_pci_tbl[] = {
99#ifdef ATA_ENABLE_PATA 99#ifdef ATA_ENABLE_PATA
100 { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix4_pata }, 100 { 0x8086, 0x7111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, piix4_pata },
101 { 0x8086, 0x24db, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_pata }, 101 { 0x8086, 0x24db, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich5_pata },
diff --git a/drivers/scsi/atari_NCR5380.c b/drivers/scsi/atari_NCR5380.c
index 2c12be72c4c6..2ae31ceb32a8 100644
--- a/drivers/scsi/atari_NCR5380.c
+++ b/drivers/scsi/atari_NCR5380.c
@@ -255,7 +255,7 @@
255 */ 255 */
256 256
257static struct Scsi_Host *first_instance = NULL; 257static struct Scsi_Host *first_instance = NULL;
258static Scsi_Host_Template *the_template = NULL; 258static struct scsi_host_template *the_template = NULL;
259 259
260/* Macros ease life... :-) */ 260/* Macros ease life... :-) */
261#define SETUP_HOSTDATA(in) \ 261#define SETUP_HOSTDATA(in) \
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index af8adb629b33..f4c1ca7c1572 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -600,7 +600,7 @@ int atari_queue_command (Scsi_Cmnd *cmd, void (*done)(Scsi_Cmnd *))
600#endif 600#endif
601 601
602 602
603int atari_scsi_detect (Scsi_Host_Template *host) 603int atari_scsi_detect (struct scsi_host_template *host)
604{ 604{
605 static int called = 0; 605 static int called = 0;
606 struct Scsi_Host *instance; 606 struct Scsi_Host *instance;
@@ -1141,7 +1141,7 @@ static void atari_scsi_falcon_reg_write( unsigned char reg, unsigned char value
1141 1141
1142#include "atari_NCR5380.c" 1142#include "atari_NCR5380.c"
1143 1143
1144static Scsi_Host_Template driver_template = { 1144static struct scsi_host_template driver_template = {
1145 .proc_info = atari_scsi_proc_info, 1145 .proc_info = atari_scsi_proc_info,
1146 .name = "Atari native SCSI", 1146 .name = "Atari native SCSI",
1147 .detect = atari_scsi_detect, 1147 .detect = atari_scsi_detect,
diff --git a/drivers/scsi/atari_scsi.h b/drivers/scsi/atari_scsi.h
index cc1256988841..f917bdd09b41 100644
--- a/drivers/scsi/atari_scsi.h
+++ b/drivers/scsi/atari_scsi.h
@@ -18,7 +18,7 @@
18/* (I_HAVE_OVERRUNS stuff removed) */ 18/* (I_HAVE_OVERRUNS stuff removed) */
19 19
20#ifndef ASM 20#ifndef ASM
21int atari_scsi_detect (Scsi_Host_Template *); 21int atari_scsi_detect (struct scsi_host_template *);
22const char *atari_scsi_info (struct Scsi_Host *); 22const char *atari_scsi_info (struct Scsi_Host *);
23int atari_scsi_reset (Scsi_Cmnd *, unsigned int); 23int atari_scsi_reset (Scsi_Cmnd *, unsigned int);
24#ifdef MODULE 24#ifdef MODULE
diff --git a/drivers/scsi/blz1230.c b/drivers/scsi/blz1230.c
index 4cd9fcf4dc50..763e409a1ff3 100644
--- a/drivers/scsi/blz1230.c
+++ b/drivers/scsi/blz1230.c
@@ -94,7 +94,7 @@ static volatile unsigned char cmd_buffer[16];
94 */ 94 */
95 95
96/***************************************************************** Detection */ 96/***************************************************************** Detection */
97int __init blz1230_esp_detect(Scsi_Host_Template *tpnt) 97int __init blz1230_esp_detect(struct scsi_host_template *tpnt)
98{ 98{
99 struct NCR_ESP *esp; 99 struct NCR_ESP *esp;
100 struct zorro_dev *z = NULL; 100 struct zorro_dev *z = NULL;
@@ -328,7 +328,7 @@ int blz1230_esp_release(struct Scsi_Host *instance)
328} 328}
329 329
330 330
331static Scsi_Host_Template driver_template = { 331static struct scsi_host_template driver_template = {
332 .proc_name = "esp-blz1230", 332 .proc_name = "esp-blz1230",
333 .proc_info = esp_proc_info, 333 .proc_info = esp_proc_info,
334 .name = "Blizzard1230 SCSI IV", 334 .name = "Blizzard1230 SCSI IV",
diff --git a/drivers/scsi/blz2060.c b/drivers/scsi/blz2060.c
index c5221d0de5ca..d72d05fffdfa 100644
--- a/drivers/scsi/blz2060.c
+++ b/drivers/scsi/blz2060.c
@@ -90,7 +90,7 @@ static volatile unsigned char cmd_buffer[16];
90 */ 90 */
91 91
92/***************************************************************** Detection */ 92/***************************************************************** Detection */
93int __init blz2060_esp_detect(Scsi_Host_Template *tpnt) 93int __init blz2060_esp_detect(struct scsi_host_template *tpnt)
94{ 94{
95 struct NCR_ESP *esp; 95 struct NCR_ESP *esp;
96 struct zorro_dev *z = NULL; 96 struct zorro_dev *z = NULL;
@@ -282,7 +282,7 @@ int blz2060_esp_release(struct Scsi_Host *instance)
282} 282}
283 283
284 284
285static Scsi_Host_Template driver_template = { 285static struct scsi_host_template driver_template = {
286 .proc_name = "esp-blz2060", 286 .proc_name = "esp-blz2060",
287 .proc_info = esp_proc_info, 287 .proc_info = esp_proc_info,
288 .name = "Blizzard2060 SCSI", 288 .name = "Blizzard2060 SCSI",
diff --git a/drivers/scsi/bvme6000.c b/drivers/scsi/bvme6000.c
index 130f30f51a9b..2958b8c2bfb7 100644
--- a/drivers/scsi/bvme6000.c
+++ b/drivers/scsi/bvme6000.c
@@ -23,7 +23,7 @@
23#include<linux/stat.h> 23#include<linux/stat.h>
24 24
25 25
26int bvme6000_scsi_detect(Scsi_Host_Template *tpnt) 26int bvme6000_scsi_detect(struct scsi_host_template *tpnt)
27{ 27{
28 static unsigned char called = 0; 28 static unsigned char called = 0;
29 int clock; 29 int clock;
@@ -59,7 +59,7 @@ static int bvme6000_scsi_release(struct Scsi_Host *shost)
59 return 0; 59 return 0;
60} 60}
61 61
62static Scsi_Host_Template driver_template = { 62static struct scsi_host_template driver_template = {
63 .name = "BVME6000 NCR53c710 SCSI", 63 .name = "BVME6000 NCR53c710 SCSI",
64 .detect = bvme6000_scsi_detect, 64 .detect = bvme6000_scsi_detect,
65 .release = bvme6000_scsi_release, 65 .release = bvme6000_scsi_release,
diff --git a/drivers/scsi/bvme6000.h b/drivers/scsi/bvme6000.h
index 49b6bbb0978e..7c9c0366cc08 100644
--- a/drivers/scsi/bvme6000.h
+++ b/drivers/scsi/bvme6000.h
@@ -3,7 +3,7 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6int bvme6000_scsi_detect(Scsi_Host_Template *); 6int bvme6000_scsi_detect(struct scsi_host_template *);
7const char *NCR53c7x0_info(void); 7const char *NCR53c7x0_info(void);
8int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 8int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
9int NCR53c7xx_abort(Scsi_Cmnd *); 9int NCR53c7xx_abort(Scsi_Cmnd *);
diff --git a/drivers/scsi/cyberstorm.c b/drivers/scsi/cyberstorm.c
index bdbca85d1675..f9b940e56430 100644
--- a/drivers/scsi/cyberstorm.c
+++ b/drivers/scsi/cyberstorm.c
@@ -104,7 +104,7 @@ static volatile unsigned char cmd_buffer[16];
104 */ 104 */
105 105
106/***************************************************************** Detection */ 106/***************************************************************** Detection */
107int __init cyber_esp_detect(Scsi_Host_Template *tpnt) 107int __init cyber_esp_detect(struct scsi_host_template *tpnt)
108{ 108{
109 struct NCR_ESP *esp; 109 struct NCR_ESP *esp;
110 struct zorro_dev *z = NULL; 110 struct zorro_dev *z = NULL;
@@ -353,7 +353,7 @@ int cyber_esp_release(struct Scsi_Host *instance)
353} 353}
354 354
355 355
356static Scsi_Host_Template driver_template = { 356static struct scsi_host_template driver_template = {
357 .proc_name = "esp-cyberstorm", 357 .proc_name = "esp-cyberstorm",
358 .proc_info = esp_proc_info, 358 .proc_info = esp_proc_info,
359 .name = "CyberStorm SCSI", 359 .name = "CyberStorm SCSI",
diff --git a/drivers/scsi/cyberstormII.c b/drivers/scsi/cyberstormII.c
index 845d9259821e..a3caabfd7557 100644
--- a/drivers/scsi/cyberstormII.c
+++ b/drivers/scsi/cyberstormII.c
@@ -81,7 +81,7 @@ static volatile unsigned char cmd_buffer[16];
81 */ 81 */
82 82
83/***************************************************************** Detection */ 83/***************************************************************** Detection */
84int __init cyberII_esp_detect(Scsi_Host_Template *tpnt) 84int __init cyberII_esp_detect(struct scsi_host_template *tpnt)
85{ 85{
86 struct NCR_ESP *esp; 86 struct NCR_ESP *esp;
87 struct zorro_dev *z = NULL; 87 struct zorro_dev *z = NULL;
@@ -290,7 +290,7 @@ int cyberII_esp_release(struct Scsi_Host *instance)
290} 290}
291 291
292 292
293static Scsi_Host_Template driver_template = { 293static struct scsi_host_template driver_template = {
294 .proc_name = "esp-cyberstormII", 294 .proc_name = "esp-cyberstormII",
295 .proc_info = esp_proc_info, 295 .proc_info = esp_proc_info,
296 .name = "CyberStorm Mk II SCSI", 296 .name = "CyberStorm Mk II SCSI",
diff --git a/drivers/scsi/dec_esp.c b/drivers/scsi/dec_esp.c
index 256d6baf8df3..a35ee43a48df 100644
--- a/drivers/scsi/dec_esp.c
+++ b/drivers/scsi/dec_esp.c
@@ -133,7 +133,7 @@ static struct scsi_host_template driver_template = {
133#include "scsi_module.c" 133#include "scsi_module.c"
134 134
135/***************************************************************** Detection */ 135/***************************************************************** Detection */
136static int dec_esp_detect(Scsi_Host_Template * tpnt) 136static int dec_esp_detect(struct scsi_host_template * tpnt)
137{ 137{
138 struct NCR_ESP *esp; 138 struct NCR_ESP *esp;
139 struct ConfigDev *esp_dev; 139 struct ConfigDev *esp_dev;
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index c28e3aea1c3c..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 {
@@ -816,7 +831,7 @@ static int adpt_hba_reset(adpt_hba* pHba)
816static void adpt_i2o_sys_shutdown(void) 831static void adpt_i2o_sys_shutdown(void)
817{ 832{
818 adpt_hba *pHba, *pNext; 833 adpt_hba *pHba, *pNext;
819 struct adpt_i2o_post_wait_data *p1, *p2; 834 struct adpt_i2o_post_wait_data *p1, *old;
820 835
821 printk(KERN_INFO"Shutting down Adaptec I2O controllers.\n"); 836 printk(KERN_INFO"Shutting down Adaptec I2O controllers.\n");
822 printk(KERN_INFO" This could take a few minutes if there are many devices attached\n"); 837 printk(KERN_INFO" This could take a few minutes if there are many devices attached\n");
@@ -830,13 +845,14 @@ static void adpt_i2o_sys_shutdown(void)
830 } 845 }
831 846
832 /* Remove any timedout entries from the wait queue. */ 847 /* Remove any timedout entries from the wait queue. */
833 p2 = NULL;
834// spin_lock_irqsave(&adpt_post_wait_lock, flags); 848// spin_lock_irqsave(&adpt_post_wait_lock, flags);
835 /* Nothing should be outstanding at this point so just 849 /* Nothing should be outstanding at this point so just
836 * free them 850 * free them
837 */ 851 */
838 for(p1 = adpt_post_wait_queue; p1; p2 = p1, p1 = p2->next) { 852 for(p1 = adpt_post_wait_queue; p1;) {
839 kfree(p1); 853 old = p1;
854 p1 = p1->next;
855 kfree(old);
840 } 856 }
841// spin_unlock_irqrestore(&adpt_post_wait_lock, flags); 857// spin_unlock_irqrestore(&adpt_post_wait_lock, flags);
842 adpt_post_wait_queue = NULL; 858 adpt_post_wait_queue = NULL;
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index 489194af43d0..2ad2a89b5db4 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -44,7 +44,7 @@ static int adpt_device_reset(struct scsi_cmnd* cmd);
44 44
45 45
46/* 46/*
47 * Scsi_Host_Template (see hosts.h) 47 * struct scsi_host_template (see hosts.h)
48 */ 48 */
49 49
50#define DPT_DRIVER_NAME "Adaptec I2O RAID" 50#define DPT_DRIVER_NAME "Adaptec I2O RAID"
diff --git a/drivers/scsi/dtc.c b/drivers/scsi/dtc.c
index 897743b23342..310d2f488668 100644
--- a/drivers/scsi/dtc.c
+++ b/drivers/scsi/dtc.c
@@ -199,7 +199,7 @@ static void __init dtc_setup(char *str, int *ints)
199#endif 199#endif
200 200
201/* 201/*
202 * Function : int dtc_detect(Scsi_Host_Template * tpnt) 202 * Function : int dtc_detect(struct scsi_host_template * tpnt)
203 * 203 *
204 * Purpose : detects and initializes DTC 3180/3280 controllers 204 * Purpose : detects and initializes DTC 3180/3280 controllers
205 * that were autoprobed, overridden on the LILO command line, 205 * that were autoprobed, overridden on the LILO command line,
@@ -211,7 +211,7 @@ static void __init dtc_setup(char *str, int *ints)
211 * 211 *
212*/ 212*/
213 213
214static int __init dtc_detect(Scsi_Host_Template * tpnt) 214static int __init dtc_detect(struct scsi_host_template * tpnt)
215{ 215{
216 static int current_override = 0, current_base = 0; 216 static int current_override = 0, current_base = 0;
217 struct Scsi_Host *instance; 217 struct Scsi_Host *instance;
@@ -471,7 +471,7 @@ static int dtc_release(struct Scsi_Host *shost)
471 return 0; 471 return 0;
472} 472}
473 473
474static Scsi_Host_Template driver_template = { 474static struct scsi_host_template driver_template = {
475 .name = "DTC 3180/3280 ", 475 .name = "DTC 3180/3280 ",
476 .detect = dtc_detect, 476 .detect = dtc_detect,
477 .release = dtc_release, 477 .release = dtc_release,
diff --git a/drivers/scsi/dtc.h b/drivers/scsi/dtc.h
index 277cd015ee4e..0b205f8c7326 100644
--- a/drivers/scsi/dtc.h
+++ b/drivers/scsi/dtc.h
@@ -35,7 +35,7 @@
35static int dtc_abort(Scsi_Cmnd *); 35static int dtc_abort(Scsi_Cmnd *);
36static int dtc_biosparam(struct scsi_device *, struct block_device *, 36static int dtc_biosparam(struct scsi_device *, struct block_device *,
37 sector_t, int*); 37 sector_t, int*);
38static int dtc_detect(Scsi_Host_Template *); 38static int dtc_detect(struct scsi_host_template *);
39static int dtc_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 39static int dtc_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
40static int dtc_bus_reset(Scsi_Cmnd *); 40static int dtc_bus_reset(Scsi_Cmnd *);
41 41
diff --git a/drivers/scsi/fastlane.c b/drivers/scsi/fastlane.c
index ae47612b3614..ccee68b52f7e 100644
--- a/drivers/scsi/fastlane.c
+++ b/drivers/scsi/fastlane.c
@@ -125,7 +125,7 @@ static inline void dma_clear(struct NCR_ESP *esp)
125} 125}
126 126
127/***************************************************************** Detection */ 127/***************************************************************** Detection */
128int __init fastlane_esp_detect(Scsi_Host_Template *tpnt) 128int __init fastlane_esp_detect(struct scsi_host_template *tpnt)
129{ 129{
130 struct NCR_ESP *esp; 130 struct NCR_ESP *esp;
131 struct zorro_dev *z = NULL; 131 struct zorro_dev *z = NULL;
@@ -398,7 +398,7 @@ int fastlane_esp_release(struct Scsi_Host *instance)
398} 398}
399 399
400 400
401static Scsi_Host_Template driver_template = { 401static struct scsi_host_template driver_template = {
402 .proc_name = "esp-fastlane", 402 .proc_name = "esp-fastlane",
403 .proc_info = esp_proc_info, 403 .proc_info = esp_proc_info,
404 .name = "Fastlane SCSI", 404 .name = "Fastlane SCSI",
diff --git a/drivers/scsi/fcal.c b/drivers/scsi/fcal.c
index a6f120dcdfc3..03416548f20c 100644
--- a/drivers/scsi/fcal.c
+++ b/drivers/scsi/fcal.c
@@ -70,7 +70,7 @@ static unsigned char target2alpa[] = {
70 70
71static int fcal_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd); 71static int fcal_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmnd *fcmd);
72 72
73int fcal_slave_configure(Scsi_Device *device) 73int fcal_slave_configure(struct scsi_device *device)
74{ 74{
75 int depth_to_use; 75 int depth_to_use;
76 76
@@ -89,7 +89,7 @@ int fcal_slave_configure(Scsi_Device *device)
89 89
90/* Detect all FC Arbitrated Loops attached to the machine. 90/* Detect all FC Arbitrated Loops attached to the machine.
91 fc4 module has done all the work for us... */ 91 fc4 module has done all the work for us... */
92int __init fcal_detect(Scsi_Host_Template *tpnt) 92int __init fcal_detect(struct scsi_host_template *tpnt)
93{ 93{
94 int nfcals = 0; 94 int nfcals = 0;
95 fc_channel *fc; 95 fc_channel *fc;
@@ -244,7 +244,7 @@ int fcal_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t of
244 SPRINTF (" [AL-PA: %02x, Port WWN: %08x%08x, Node WWN: %08x%08x] Not responded to PRLI\n", 244 SPRINTF (" [AL-PA: %02x, Port WWN: %08x%08x, Node WWN: %08x%08x] Not responded to PRLI\n",
245 alpa, u1[0], u1[1], u2[0], u2[1]); 245 alpa, u1[0], u1[1], u2[0], u2[1]);
246 } else { 246 } else {
247 Scsi_Device *scd; 247 struct scsi_device *scd;
248 shost_for_each_device(scd, host) 248 shost_for_each_device(scd, host)
249 if (scd->id == target) { 249 if (scd->id == target) {
250 SPRINTF (" [AL-PA: %02x, Id: %02d, Port WWN: %08x%08x, Node WWN: %08x%08x] ", 250 SPRINTF (" [AL-PA: %02x, Id: %02d, Port WWN: %08x%08x, Node WWN: %08x%08x] ",
@@ -297,7 +297,7 @@ static int fcal_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cmn
297 return 0; 297 return 0;
298} 298}
299 299
300static Scsi_Host_Template driver_template = { 300static struct scsi_host_template driver_template = {
301 .name = "Fibre Channel Arbitrated Loop", 301 .name = "Fibre Channel Arbitrated Loop",
302 .detect = fcal_detect, 302 .detect = fcal_detect,
303 .release = fcal_release, 303 .release = fcal_release,
diff --git a/drivers/scsi/fcal.h b/drivers/scsi/fcal.h
index 21aa32ef9134..7ff2c3494f9e 100644
--- a/drivers/scsi/fcal.h
+++ b/drivers/scsi/fcal.h
@@ -20,8 +20,8 @@ struct fcal {
20 for a particular channel */ 20 for a particular channel */
21#define FCAL_CAN_QUEUE 512 21#define FCAL_CAN_QUEUE 512
22 22
23int fcal_detect(Scsi_Host_Template *); 23int fcal_detect(struct scsi_host_template *);
24int fcal_release(struct Scsi_Host *); 24int fcal_release(struct Scsi_Host *);
25int fcal_slave_configure(Scsi_Device *); 25int fcal_slave_configure(struct scsi_device *);
26 26
27#endif /* !(_FCAL_H) */ 27#endif /* !(_FCAL_H) */
diff --git a/drivers/scsi/fd_mcs.c b/drivers/scsi/fd_mcs.c
index 6d44602aae78..cca485a2b438 100644
--- a/drivers/scsi/fd_mcs.c
+++ b/drivers/scsi/fd_mcs.c
@@ -343,7 +343,7 @@ static void fd_mcs_make_bus_idle(struct Scsi_Host *shpnt)
343 outb(0x01 | PARITY_MASK, TMC_Cntl_port); 343 outb(0x01 | PARITY_MASK, TMC_Cntl_port);
344} 344}
345 345
346static int fd_mcs_detect(Scsi_Host_Template * tpnt) 346static int fd_mcs_detect(struct scsi_host_template * tpnt)
347{ 347{
348 int loop; 348 int loop;
349 struct Scsi_Host *shpnt; 349 struct Scsi_Host *shpnt;
@@ -1343,7 +1343,7 @@ static int fd_mcs_biosparam(struct scsi_device * disk, struct block_device *bdev
1343 return 0; 1343 return 0;
1344} 1344}
1345 1345
1346static Scsi_Host_Template driver_template = { 1346static struct scsi_host_template driver_template = {
1347 .proc_name = "fd_mcs", 1347 .proc_name = "fd_mcs",
1348 .proc_info = fd_mcs_proc_info, 1348 .proc_info = fd_mcs_proc_info,
1349 .detect = fd_mcs_detect, 1349 .detect = fd_mcs_detect,
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index a3aa729b9d3c..45756fa90777 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -285,7 +285,7 @@ static int __init do_DTC3181E_setup(char *str)
285 * Locks: none 285 * Locks: none
286 */ 286 */
287 287
288int __init generic_NCR5380_detect(Scsi_Host_Template * tpnt) 288int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
289{ 289{
290 static int current_override = 0; 290 static int current_override = 0;
291 int count, i; 291 int count, i;
@@ -798,7 +798,7 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c
798 Scsi_Cmnd *ptr; 798 Scsi_Cmnd *ptr;
799 struct NCR5380_hostdata *hostdata; 799 struct NCR5380_hostdata *hostdata;
800#ifdef NCR5380_STATS 800#ifdef NCR5380_STATS
801 Scsi_Device *dev; 801 struct scsi_device *dev;
802 extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE]; 802 extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
803#endif 803#endif
804 804
@@ -899,7 +899,7 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c
899#undef PRINTP 899#undef PRINTP
900#undef ANDP 900#undef ANDP
901 901
902static Scsi_Host_Template driver_template = { 902static struct scsi_host_template driver_template = {
903 .proc_info = generic_NCR5380_proc_info, 903 .proc_info = generic_NCR5380_proc_info,
904 .name = "Generic NCR5380/NCR53C400 Scsi Driver", 904 .name = "Generic NCR5380/NCR53C400 Scsi Driver",
905 .detect = generic_NCR5380_detect, 905 .detect = generic_NCR5380_detect,
diff --git a/drivers/scsi/g_NCR5380.h b/drivers/scsi/g_NCR5380.h
index c8adc5a94884..656fbe2f91f6 100644
--- a/drivers/scsi/g_NCR5380.h
+++ b/drivers/scsi/g_NCR5380.h
@@ -45,7 +45,7 @@
45 45
46#ifndef ASM 46#ifndef ASM
47static int generic_NCR5380_abort(Scsi_Cmnd *); 47static int generic_NCR5380_abort(Scsi_Cmnd *);
48static int generic_NCR5380_detect(Scsi_Host_Template *); 48static int generic_NCR5380_detect(struct scsi_host_template *);
49static int generic_NCR5380_release_resources(struct Scsi_Host *); 49static int generic_NCR5380_release_resources(struct Scsi_Host *);
50static int generic_NCR5380_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 50static int generic_NCR5380_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
51static int generic_NCR5380_bus_reset(Scsi_Cmnd *); 51static int generic_NCR5380_bus_reset(Scsi_Cmnd *);
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index af682301beac..a6deb016584c 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -94,7 +94,7 @@
94 * Bugfix free_irq() 94 * Bugfix free_irq()
95 * 95 *
96 * Revision 1.56 2001/08/09 11:19:39 achim 96 * Revision 1.56 2001/08/09 11:19:39 achim
97 * Scsi_Host_Template changes 97 * struct scsi_host_template changes
98 * 98 *
99 * Revision 1.55 2001/08/09 10:11:28 achim 99 * Revision 1.55 2001/08/09 10:11:28 achim
100 * Command HOST_UNFREEZE_IO before cache service init. 100 * Command HOST_UNFREEZE_IO before cache service init.
@@ -4153,7 +4153,7 @@ int __init option_setup(char *str)
4153 return 1; 4153 return 1;
4154} 4154}
4155 4155
4156static int __init gdth_detect(Scsi_Host_Template *shtp) 4156static int __init gdth_detect(struct scsi_host_template *shtp)
4157{ 4157{
4158 struct Scsi_Host *shp; 4158 struct Scsi_Host *shp;
4159 gdth_pci_str pcistr[MAXHA]; 4159 gdth_pci_str pcistr[MAXHA];
@@ -5562,7 +5562,7 @@ static void gdth_flush(int hanum)
5562#else 5562#else
5563 Scsi_Cmnd *scp; 5563 Scsi_Cmnd *scp;
5564#endif 5564#endif
5565 Scsi_Device *sdev; 5565 struct scsi_device *sdev;
5566 char cmnd[MAX_COMMAND_SIZE]; 5566 char cmnd[MAX_COMMAND_SIZE];
5567 memset(cmnd, 0xff, MAX_COMMAND_SIZE); 5567 memset(cmnd, 0xff, MAX_COMMAND_SIZE);
5568 5568
@@ -5624,10 +5624,10 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf)
5624 gdth_cmd_str gdtcmd; 5624 gdth_cmd_str gdtcmd;
5625#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 5625#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
5626 Scsi_Request *srp; 5626 Scsi_Request *srp;
5627 Scsi_Device *sdev; 5627 struct scsi_device *sdev;
5628#else 5628#else
5629 Scsi_Cmnd *scp; 5629 Scsi_Cmnd *scp;
5630 Scsi_Device *sdev; 5630 struct scsi_device *sdev;
5631#endif 5631#endif
5632 char cmnd[MAX_COMMAND_SIZE]; 5632 char cmnd[MAX_COMMAND_SIZE];
5633#endif 5633#endif
@@ -5683,7 +5683,7 @@ static int gdth_halt(struct notifier_block *nb, ulong event, void *buf)
5683 return NOTIFY_OK; 5683 return NOTIFY_OK;
5684} 5684}
5685 5685
5686static Scsi_Host_Template driver_template = { 5686static struct scsi_host_template driver_template = {
5687 .proc_name = "gdth", 5687 .proc_name = "gdth",
5688 .proc_info = gdth_proc_info, 5688 .proc_info = gdth_proc_info,
5689 .name = "GDT SCSI Disk Array Controller", 5689 .name = "GDT SCSI Disk Array Controller",
diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h
index c0f1e3411524..cc4882fb97ad 100644
--- a/drivers/scsi/gdth.h
+++ b/drivers/scsi/gdth.h
@@ -944,9 +944,9 @@ typedef struct {
944 ulong dma32_cnt, dma64_cnt; /* statistics: DMA buffer */ 944 ulong dma32_cnt, dma64_cnt; /* statistics: DMA buffer */
945#endif 945#endif
946#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) 946#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
947 Scsi_Device *sdev; 947 struct scsi_device *sdev;
948#else 948#else
949 Scsi_Device sdev; 949 struct scsi_device sdev;
950#endif 950#endif
951} gdth_ha_str; 951} gdth_ha_str;
952 952
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c
index 1bd02f8d1e6a..5e8657f9cdf6 100644
--- a/drivers/scsi/gdth_proc.c
+++ b/drivers/scsi/gdth_proc.c
@@ -54,10 +54,10 @@ static int gdth_set_info(char *buffer,int length,struct Scsi_Host *host,
54 int ret_val = -EINVAL; 54 int ret_val = -EINVAL;
55#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 55#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
56 Scsi_Request *scp; 56 Scsi_Request *scp;
57 Scsi_Device *sdev; 57 struct scsi_device *sdev;
58#else 58#else
59 Scsi_Cmnd *scp; 59 Scsi_Cmnd *scp;
60 Scsi_Device *sdev; 60 struct scsi_device *sdev;
61#endif 61#endif
62 TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum)); 62 TRACE2(("gdth_set_info() ha %d bus %d\n",hanum,busnum));
63 63
@@ -232,10 +232,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
232 gdth_evt_str *estr; 232 gdth_evt_str *estr;
233#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) 233#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
234 Scsi_Request *scp; 234 Scsi_Request *scp;
235 Scsi_Device *sdev; 235 struct scsi_device *sdev;
236#else 236#else
237 Scsi_Cmnd *scp; 237 Scsi_Cmnd *scp;
238 Scsi_Device *sdev; 238 struct scsi_device *sdev;
239#endif 239#endif
240 char hrec[161]; 240 char hrec[161];
241 struct timeval tv; 241 struct timeval tv;
@@ -275,7 +275,7 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
275 scp->cmd_len = 12; 275 scp->cmd_len = 12;
276 scp->use_sg = 0; 276 scp->use_sg = 0;
277#else 277#else
278 memset(&sdev,0,sizeof(Scsi_Device)); 278 memset(&sdev,0,sizeof(struct scsi_device));
279 memset(&scp, 0,sizeof(Scsi_Cmnd)); 279 memset(&scp, 0,sizeof(Scsi_Cmnd));
280 sdev.host = scp.host = host; 280 sdev.host = scp.host = host;
281 sdev.id = scp.target = sdev.host->this_id; 281 sdev.id = scp.target = sdev.host->this_id;
diff --git a/drivers/scsi/gvp11.c b/drivers/scsi/gvp11.c
index ab22387c9df1..5b154498056d 100644
--- a/drivers/scsi/gvp11.c
+++ b/drivers/scsi/gvp11.c
@@ -169,7 +169,7 @@ static void dma_stop (struct Scsi_Host *instance, Scsi_Cmnd *SCpnt,
169 169
170#define CHECK_WD33C93 170#define CHECK_WD33C93
171 171
172int __init gvp11_detect(Scsi_Host_Template *tpnt) 172int __init gvp11_detect(struct scsi_host_template *tpnt)
173{ 173{
174 static unsigned char called = 0; 174 static unsigned char called = 0;
175 struct Scsi_Host *instance; 175 struct Scsi_Host *instance;
@@ -361,7 +361,7 @@ static int gvp11_bus_reset(Scsi_Cmnd *cmd)
361 361
362#include "gvp11.h" 362#include "gvp11.h"
363 363
364static Scsi_Host_Template driver_template = { 364static struct scsi_host_template driver_template = {
365 .proc_name = "GVP11", 365 .proc_name = "GVP11",
366 .name = "GVP Series II SCSI", 366 .name = "GVP Series II SCSI",
367 .detect = gvp11_detect, 367 .detect = gvp11_detect,
diff --git a/drivers/scsi/gvp11.h b/drivers/scsi/gvp11.h
index 5148d9fada19..575d219d14ba 100644
--- a/drivers/scsi/gvp11.h
+++ b/drivers/scsi/gvp11.h
@@ -11,7 +11,7 @@
11 11
12#include <linux/types.h> 12#include <linux/types.h>
13 13
14int gvp11_detect(Scsi_Host_Template *); 14int gvp11_detect(struct scsi_host_template *);
15int gvp11_release(struct Scsi_Host *); 15int gvp11_release(struct Scsi_Host *);
16const char *wd33c93_info(void); 16const char *wd33c93_info(void);
17int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 17int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
diff --git a/drivers/scsi/ibmmca.c b/drivers/scsi/ibmmca.c
index 8d97999db60e..b60c1b9270f1 100644
--- a/drivers/scsi/ibmmca.c
+++ b/drivers/scsi/ibmmca.c
@@ -492,7 +492,7 @@ static char *ibmrate(unsigned int, int);
492static int probe_display(int); 492static int probe_display(int);
493static int probe_bus_mode(int); 493static int probe_bus_mode(int);
494static int device_exists(int, int, int *, int *); 494static int device_exists(int, int, int *, int *);
495static struct Scsi_Host *ibmmca_register(Scsi_Host_Template *, int, int, int, char *); 495static struct Scsi_Host *ibmmca_register(struct scsi_host_template *, int, int, int, char *);
496static int option_setup(char *); 496static int option_setup(char *);
497/* local functions needed for proc_info */ 497/* local functions needed for proc_info */
498static int ldn_access_load(int, int); 498static int ldn_access_load(int, int);
@@ -1483,7 +1483,7 @@ static int ibmmca_getinfo(char *buf, int slot, void *dev_id)
1483 return len; 1483 return len;
1484} 1484}
1485 1485
1486int ibmmca_detect(Scsi_Host_Template * scsi_template) 1486int ibmmca_detect(struct scsi_host_template * scsi_template)
1487{ 1487{
1488 struct Scsi_Host *shpnt; 1488 struct Scsi_Host *shpnt;
1489 int port, id, i, j, k, list_size, slot; 1489 int port, id, i, j, k, list_size, slot;
@@ -1736,7 +1736,7 @@ int ibmmca_detect(Scsi_Host_Template * scsi_template)
1736 return found; /* return the number of found SCSI hosts. Should be 1 or 0. */ 1736 return found; /* return the number of found SCSI hosts. Should be 1 or 0. */
1737} 1737}
1738 1738
1739static struct Scsi_Host *ibmmca_register(Scsi_Host_Template * scsi_template, int port, int id, int adaptertype, char *hostname) 1739static struct Scsi_Host *ibmmca_register(struct scsi_host_template * scsi_template, int port, int id, int adaptertype, char *hostname)
1740{ 1740{
1741 struct Scsi_Host *shpnt; 1741 struct Scsi_Host *shpnt;
1742 int i, j; 1742 int i, j;
@@ -2494,7 +2494,7 @@ static int option_setup(char *str)
2494 2494
2495__setup("ibmmcascsi=", option_setup); 2495__setup("ibmmcascsi=", option_setup);
2496 2496
2497static Scsi_Host_Template driver_template = { 2497static struct scsi_host_template driver_template = {
2498 .proc_name = "ibmmca", 2498 .proc_name = "ibmmca",
2499 .proc_info = ibmmca_proc_info, 2499 .proc_info = ibmmca_proc_info,
2500 .name = "IBM SCSI-Subsystem", 2500 .name = "IBM SCSI-Subsystem",
diff --git a/drivers/scsi/ibmmca.h b/drivers/scsi/ibmmca.h
index 6d68f603e9b8..017ee2fa6d63 100644
--- a/drivers/scsi/ibmmca.h
+++ b/drivers/scsi/ibmmca.h
@@ -11,7 +11,7 @@
11/* Common forward declarations for all Linux-versions: */ 11/* Common forward declarations for all Linux-versions: */
12 12
13/* Interfaces to the midlevel Linux SCSI driver */ 13/* Interfaces to the midlevel Linux SCSI driver */
14static int ibmmca_detect (Scsi_Host_Template *); 14static int ibmmca_detect (struct scsi_host_template *);
15static int ibmmca_release (struct Scsi_Host *); 15static int ibmmca_release (struct Scsi_Host *);
16static int ibmmca_queuecommand (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *)); 16static int ibmmca_queuecommand (Scsi_Cmnd *, void (*done) (Scsi_Cmnd *));
17static int ibmmca_abort (Scsi_Cmnd *); 17static int ibmmca_abort (Scsi_Cmnd *);
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 3553da0e1cd5..4cb1f3ed9100 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -784,8 +784,8 @@ static ide_proc_entry_t idescsi_proc[] = {
784#endif 784#endif
785 785
786static ide_driver_t idescsi_driver = { 786static ide_driver_t idescsi_driver = {
787 .owner = THIS_MODULE,
788 .gen_driver = { 787 .gen_driver = {
788 .owner = THIS_MODULE,
789 .name = "ide-scsi", 789 .name = "ide-scsi",
790 .bus = &ide_bus_type, 790 .bus = &ide_bus_type,
791 .probe = ide_scsi_probe, 791 .probe = ide_scsi_probe,
@@ -882,7 +882,7 @@ static inline int should_transform(ide_drive_t *drive, struct scsi_cmnd *cmd)
882 struct gendisk *disk = cmd->request->rq_disk; 882 struct gendisk *disk = cmd->request->rq_disk;
883 883
884 if (disk) { 884 if (disk) {
885 struct Scsi_Device_Template **p = disk->private_data; 885 struct struct scsi_device_Template **p = disk->private_data;
886 if (strcmp((*p)->scsi_driverfs_driver.name, "sg") == 0) 886 if (strcmp((*p)->scsi_driverfs_driver.name, "sg") == 0)
887 return test_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); 887 return test_bit(IDESCSI_SG_TRANSFORM, &scsi->transform);
888 } 888 }
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index fe387b5ce8bd..34daa3e068de 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -1899,7 +1899,7 @@ static int int_tab[] in2000__INITDATA = {
1899}; 1899};
1900 1900
1901 1901
1902static int __init in2000_detect(Scsi_Host_Template * tpnt) 1902static int __init in2000_detect(struct scsi_host_template * tpnt)
1903{ 1903{
1904 struct Scsi_Host *instance; 1904 struct Scsi_Host *instance;
1905 struct IN2000_hostdata *hostdata; 1905 struct IN2000_hostdata *hostdata;
@@ -2305,7 +2305,7 @@ static int in2000_proc_info(struct Scsi_Host *instance, char *buf, char **start,
2305MODULE_LICENSE("GPL"); 2305MODULE_LICENSE("GPL");
2306 2306
2307 2307
2308static Scsi_Host_Template driver_template = { 2308static struct scsi_host_template driver_template = {
2309 .proc_name = "in2000", 2309 .proc_name = "in2000",
2310 .proc_info = in2000_proc_info, 2310 .proc_info = in2000_proc_info,
2311 .name = "Always IN2000", 2311 .name = "Always IN2000",
diff --git a/drivers/scsi/in2000.h b/drivers/scsi/in2000.h
index a240b52554d8..0fb8b06b8392 100644
--- a/drivers/scsi/in2000.h
+++ b/drivers/scsi/in2000.h
@@ -395,7 +395,7 @@ struct IN2000_hostdata {
395# define CLISPIN_UNLOCK(host,flags) spin_unlock_irqrestore(host->host_lock, \ 395# define CLISPIN_UNLOCK(host,flags) spin_unlock_irqrestore(host->host_lock, \
396 flags) 396 flags)
397 397
398static int in2000_detect(Scsi_Host_Template *) in2000__INIT; 398static int in2000_detect(struct scsi_host_template *) in2000__INIT;
399static int in2000_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 399static int in2000_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
400static int in2000_abort(Scsi_Cmnd *); 400static int in2000_abort(Scsi_Cmnd *);
401static void in2000_setup(char *, int *) in2000__INIT; 401static void in2000_setup(char *, int *) in2000__INIT;
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index e0039dfae8e5..fa2cb3582cfa 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -91,11 +91,14 @@ static unsigned int ipr_max_speed = 1;
91static int ipr_testmode = 0; 91static int ipr_testmode = 0;
92static unsigned int ipr_fastfail = 0; 92static unsigned int ipr_fastfail = 0;
93static unsigned int ipr_transop_timeout = IPR_OPERATIONAL_TIMEOUT; 93static unsigned int ipr_transop_timeout = IPR_OPERATIONAL_TIMEOUT;
94static unsigned int ipr_enable_cache = 1;
95static unsigned int ipr_debug = 0;
96static int ipr_auto_create = 1;
94static DEFINE_SPINLOCK(ipr_driver_lock); 97static DEFINE_SPINLOCK(ipr_driver_lock);
95 98
96/* This table describes the differences between DMA controller chips */ 99/* This table describes the differences between DMA controller chips */
97static const struct ipr_chip_cfg_t ipr_chip_cfg[] = { 100static const struct ipr_chip_cfg_t ipr_chip_cfg[] = {
98 { /* Gemstone and Citrine */ 101 { /* Gemstone, Citrine, and Obsidian */
99 .mailbox = 0x0042C, 102 .mailbox = 0x0042C,
100 .cache_line_size = 0x20, 103 .cache_line_size = 0x20,
101 { 104 {
@@ -130,6 +133,8 @@ static const struct ipr_chip_cfg_t ipr_chip_cfg[] = {
130static const struct ipr_chip_t ipr_chip[] = { 133static const struct ipr_chip_t ipr_chip[] = {
131 { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, &ipr_chip_cfg[0] }, 134 { PCI_VENDOR_ID_MYLEX, PCI_DEVICE_ID_IBM_GEMSTONE, &ipr_chip_cfg[0] },
132 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] }, 135 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, &ipr_chip_cfg[0] },
136 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN, &ipr_chip_cfg[0] },
137 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, &ipr_chip_cfg[0] },
133 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] }, 138 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, &ipr_chip_cfg[1] },
134 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] } 139 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, &ipr_chip_cfg[1] }
135}; 140};
@@ -150,6 +155,12 @@ module_param_named(fastfail, ipr_fastfail, int, 0);
150MODULE_PARM_DESC(fastfail, "Reduce timeouts and retries"); 155MODULE_PARM_DESC(fastfail, "Reduce timeouts and retries");
151module_param_named(transop_timeout, ipr_transop_timeout, int, 0); 156module_param_named(transop_timeout, ipr_transop_timeout, int, 0);
152MODULE_PARM_DESC(transop_timeout, "Time in seconds to wait for adapter to come operational (default: 300)"); 157MODULE_PARM_DESC(transop_timeout, "Time in seconds to wait for adapter to come operational (default: 300)");
158module_param_named(enable_cache, ipr_enable_cache, int, 0);
159MODULE_PARM_DESC(enable_cache, "Enable adapter's non-volatile write cache (default: 1)");
160module_param_named(debug, ipr_debug, int, 0);
161MODULE_PARM_DESC(debug, "Enable device driver debugging logging. Set to 1 to enable. (default: 0)");
162module_param_named(auto_create, ipr_auto_create, int, 0);
163MODULE_PARM_DESC(auto_create, "Auto-create single device RAID 0 arrays when initialized (default: 1)");
153MODULE_LICENSE("GPL"); 164MODULE_LICENSE("GPL");
154MODULE_VERSION(IPR_DRIVER_VERSION); 165MODULE_VERSION(IPR_DRIVER_VERSION);
155 166
@@ -285,12 +296,18 @@ struct ipr_error_table_t ipr_error_table[] = {
285 "3110: Device bus error, message or command phase"}, 296 "3110: Device bus error, message or command phase"},
286 {0x04670400, 0, 1, 297 {0x04670400, 0, 1,
287 "9091: Incorrect hardware configuration change has been detected"}, 298 "9091: Incorrect hardware configuration change has been detected"},
299 {0x04678000, 0, 1,
300 "9073: Invalid multi-adapter configuration"},
288 {0x046E0000, 0, 1, 301 {0x046E0000, 0, 1,
289 "FFF4: Command to logical unit failed"}, 302 "FFF4: Command to logical unit failed"},
290 {0x05240000, 1, 0, 303 {0x05240000, 1, 0,
291 "Illegal request, invalid request type or request packet"}, 304 "Illegal request, invalid request type or request packet"},
292 {0x05250000, 0, 0, 305 {0x05250000, 0, 0,
293 "Illegal request, invalid resource handle"}, 306 "Illegal request, invalid resource handle"},
307 {0x05258000, 0, 0,
308 "Illegal request, commands not allowed to this device"},
309 {0x05258100, 0, 0,
310 "Illegal request, command not allowed to a secondary adapter"},
294 {0x05260000, 0, 0, 311 {0x05260000, 0, 0,
295 "Illegal request, invalid field in parameter list"}, 312 "Illegal request, invalid field in parameter list"},
296 {0x05260100, 0, 0, 313 {0x05260100, 0, 0,
@@ -299,6 +316,8 @@ struct ipr_error_table_t ipr_error_table[] = {
299 "Illegal request, parameter value invalid"}, 316 "Illegal request, parameter value invalid"},
300 {0x052C0000, 0, 0, 317 {0x052C0000, 0, 0,
301 "Illegal request, command sequence error"}, 318 "Illegal request, command sequence error"},
319 {0x052C8000, 1, 0,
320 "Illegal request, dual adapter support not enabled"},
302 {0x06040500, 0, 1, 321 {0x06040500, 0, 1,
303 "9031: Array protection temporarily suspended, protection resuming"}, 322 "9031: Array protection temporarily suspended, protection resuming"},
304 {0x06040600, 0, 1, 323 {0x06040600, 0, 1,
@@ -315,18 +334,26 @@ struct ipr_error_table_t ipr_error_table[] = {
315 "3029: A device replacement has occurred"}, 334 "3029: A device replacement has occurred"},
316 {0x064C8000, 0, 1, 335 {0x064C8000, 0, 1,
317 "9051: IOA cache data exists for a missing or failed device"}, 336 "9051: IOA cache data exists for a missing or failed device"},
337 {0x064C8100, 0, 1,
338 "9055: Auxiliary cache IOA contains cache data needed by the primary IOA"},
318 {0x06670100, 0, 1, 339 {0x06670100, 0, 1,
319 "9025: Disk unit is not supported at its physical location"}, 340 "9025: Disk unit is not supported at its physical location"},
320 {0x06670600, 0, 1, 341 {0x06670600, 0, 1,
321 "3020: IOA detected a SCSI bus configuration error"}, 342 "3020: IOA detected a SCSI bus configuration error"},
322 {0x06678000, 0, 1, 343 {0x06678000, 0, 1,
323 "3150: SCSI bus configuration error"}, 344 "3150: SCSI bus configuration error"},
345 {0x06678100, 0, 1,
346 "9074: Asymmetric advanced function disk configuration"},
324 {0x06690200, 0, 1, 347 {0x06690200, 0, 1,
325 "9041: Array protection temporarily suspended"}, 348 "9041: Array protection temporarily suspended"},
326 {0x06698200, 0, 1, 349 {0x06698200, 0, 1,
327 "9042: Corrupt array parity detected on specified device"}, 350 "9042: Corrupt array parity detected on specified device"},
328 {0x066B0200, 0, 1, 351 {0x066B0200, 0, 1,
329 "9030: Array no longer protected due to missing or failed disk unit"}, 352 "9030: Array no longer protected due to missing or failed disk unit"},
353 {0x066B8000, 0, 1,
354 "9071: Link operational transition"},
355 {0x066B8100, 0, 1,
356 "9072: Link not operational transition"},
330 {0x066B8200, 0, 1, 357 {0x066B8200, 0, 1,
331 "9032: Array exposed but still protected"}, 358 "9032: Array exposed but still protected"},
332 {0x07270000, 0, 0, 359 {0x07270000, 0, 0,
@@ -789,7 +816,7 @@ static void ipr_send_hcam(struct ipr_ioa_cfg *ioa_cfg, u8 type,
789 **/ 816 **/
790static void ipr_init_res_entry(struct ipr_resource_entry *res) 817static void ipr_init_res_entry(struct ipr_resource_entry *res)
791{ 818{
792 res->needs_sync_complete = 1; 819 res->needs_sync_complete = 0;
793 res->in_erp = 0; 820 res->in_erp = 0;
794 res->add_to_ml = 0; 821 res->add_to_ml = 0;
795 res->del_from_ml = 0; 822 res->del_from_ml = 0;
@@ -889,29 +916,74 @@ static void ipr_process_ccn(struct ipr_cmnd *ipr_cmd)
889 916
890/** 917/**
891 * ipr_log_vpd - Log the passed VPD to the error log. 918 * ipr_log_vpd - Log the passed VPD to the error log.
892 * @vpids: vendor/product id struct 919 * @vpd: vendor/product id/sn struct
893 * @serial_num: serial number string
894 * 920 *
895 * Return value: 921 * Return value:
896 * none 922 * none
897 **/ 923 **/
898static void ipr_log_vpd(struct ipr_std_inq_vpids *vpids, u8 *serial_num) 924static void ipr_log_vpd(struct ipr_vpd *vpd)
899{ 925{
900 char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN 926 char buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN
901 + IPR_SERIAL_NUM_LEN]; 927 + IPR_SERIAL_NUM_LEN];
902 928
903 memcpy(buffer, vpids->vendor_id, IPR_VENDOR_ID_LEN); 929 memcpy(buffer, vpd->vpids.vendor_id, IPR_VENDOR_ID_LEN);
904 memcpy(buffer + IPR_VENDOR_ID_LEN, vpids->product_id, 930 memcpy(buffer + IPR_VENDOR_ID_LEN, vpd->vpids.product_id,
905 IPR_PROD_ID_LEN); 931 IPR_PROD_ID_LEN);
906 buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN] = '\0'; 932 buffer[IPR_VENDOR_ID_LEN + IPR_PROD_ID_LEN] = '\0';
907 ipr_err("Vendor/Product ID: %s\n", buffer); 933 ipr_err("Vendor/Product ID: %s\n", buffer);
908 934
909 memcpy(buffer, serial_num, IPR_SERIAL_NUM_LEN); 935 memcpy(buffer, vpd->sn, IPR_SERIAL_NUM_LEN);
910 buffer[IPR_SERIAL_NUM_LEN] = '\0'; 936 buffer[IPR_SERIAL_NUM_LEN] = '\0';
911 ipr_err(" Serial Number: %s\n", buffer); 937 ipr_err(" Serial Number: %s\n", buffer);
912} 938}
913 939
914/** 940/**
941 * ipr_log_ext_vpd - Log the passed extended VPD to the error log.
942 * @vpd: vendor/product id/sn/wwn struct
943 *
944 * Return value:
945 * none
946 **/
947static void ipr_log_ext_vpd(struct ipr_ext_vpd *vpd)
948{
949 ipr_log_vpd(&vpd->vpd);
950 ipr_err(" WWN: %08X%08X\n", be32_to_cpu(vpd->wwid[0]),
951 be32_to_cpu(vpd->wwid[1]));
952}
953
954/**
955 * ipr_log_enhanced_cache_error - Log a cache error.
956 * @ioa_cfg: ioa config struct
957 * @hostrcb: hostrcb struct
958 *
959 * Return value:
960 * none
961 **/
962static void ipr_log_enhanced_cache_error(struct ipr_ioa_cfg *ioa_cfg,
963 struct ipr_hostrcb *hostrcb)
964{
965 struct ipr_hostrcb_type_12_error *error =
966 &hostrcb->hcam.u.error.u.type_12_error;
967
968 ipr_err("-----Current Configuration-----\n");
969 ipr_err("Cache Directory Card Information:\n");
970 ipr_log_ext_vpd(&error->ioa_vpd);
971 ipr_err("Adapter Card Information:\n");
972 ipr_log_ext_vpd(&error->cfc_vpd);
973
974 ipr_err("-----Expected Configuration-----\n");
975 ipr_err("Cache Directory Card Information:\n");
976 ipr_log_ext_vpd(&error->ioa_last_attached_to_cfc_vpd);
977 ipr_err("Adapter Card Information:\n");
978 ipr_log_ext_vpd(&error->cfc_last_attached_to_ioa_vpd);
979
980 ipr_err("Additional IOA Data: %08X %08X %08X\n",
981 be32_to_cpu(error->ioa_data[0]),
982 be32_to_cpu(error->ioa_data[1]),
983 be32_to_cpu(error->ioa_data[2]));
984}
985
986/**
915 * ipr_log_cache_error - Log a cache error. 987 * ipr_log_cache_error - Log a cache error.
916 * @ioa_cfg: ioa config struct 988 * @ioa_cfg: ioa config struct
917 * @hostrcb: hostrcb struct 989 * @hostrcb: hostrcb struct
@@ -927,17 +999,15 @@ static void ipr_log_cache_error(struct ipr_ioa_cfg *ioa_cfg,
927 999
928 ipr_err("-----Current Configuration-----\n"); 1000 ipr_err("-----Current Configuration-----\n");
929 ipr_err("Cache Directory Card Information:\n"); 1001 ipr_err("Cache Directory Card Information:\n");
930 ipr_log_vpd(&error->ioa_vpids, error->ioa_sn); 1002 ipr_log_vpd(&error->ioa_vpd);
931 ipr_err("Adapter Card Information:\n"); 1003 ipr_err("Adapter Card Information:\n");
932 ipr_log_vpd(&error->cfc_vpids, error->cfc_sn); 1004 ipr_log_vpd(&error->cfc_vpd);
933 1005
934 ipr_err("-----Expected Configuration-----\n"); 1006 ipr_err("-----Expected Configuration-----\n");
935 ipr_err("Cache Directory Card Information:\n"); 1007 ipr_err("Cache Directory Card Information:\n");
936 ipr_log_vpd(&error->ioa_last_attached_to_cfc_vpids, 1008 ipr_log_vpd(&error->ioa_last_attached_to_cfc_vpd);
937 error->ioa_last_attached_to_cfc_sn);
938 ipr_err("Adapter Card Information:\n"); 1009 ipr_err("Adapter Card Information:\n");
939 ipr_log_vpd(&error->cfc_last_attached_to_ioa_vpids, 1010 ipr_log_vpd(&error->cfc_last_attached_to_ioa_vpd);
940 error->cfc_last_attached_to_ioa_sn);
941 1011
942 ipr_err("Additional IOA Data: %08X %08X %08X\n", 1012 ipr_err("Additional IOA Data: %08X %08X %08X\n",
943 be32_to_cpu(error->ioa_data[0]), 1013 be32_to_cpu(error->ioa_data[0]),
@@ -946,6 +1016,46 @@ static void ipr_log_cache_error(struct ipr_ioa_cfg *ioa_cfg,
946} 1016}
947 1017
948/** 1018/**
1019 * ipr_log_enhanced_config_error - Log a configuration error.
1020 * @ioa_cfg: ioa config struct
1021 * @hostrcb: hostrcb struct
1022 *
1023 * Return value:
1024 * none
1025 **/
1026static void ipr_log_enhanced_config_error(struct ipr_ioa_cfg *ioa_cfg,
1027 struct ipr_hostrcb *hostrcb)
1028{
1029 int errors_logged, i;
1030 struct ipr_hostrcb_device_data_entry_enhanced *dev_entry;
1031 struct ipr_hostrcb_type_13_error *error;
1032
1033 error = &hostrcb->hcam.u.error.u.type_13_error;
1034 errors_logged = be32_to_cpu(error->errors_logged);
1035
1036 ipr_err("Device Errors Detected/Logged: %d/%d\n",
1037 be32_to_cpu(error->errors_detected), errors_logged);
1038
1039 dev_entry = error->dev;
1040
1041 for (i = 0; i < errors_logged; i++, dev_entry++) {
1042 ipr_err_separator;
1043
1044 ipr_phys_res_err(ioa_cfg, dev_entry->dev_res_addr, "Device %d", i + 1);
1045 ipr_log_ext_vpd(&dev_entry->vpd);
1046
1047 ipr_err("-----New Device Information-----\n");
1048 ipr_log_ext_vpd(&dev_entry->new_vpd);
1049
1050 ipr_err("Cache Directory Card Information:\n");
1051 ipr_log_ext_vpd(&dev_entry->ioa_last_with_dev_vpd);
1052
1053 ipr_err("Adapter Card Information:\n");
1054 ipr_log_ext_vpd(&dev_entry->cfc_last_with_dev_vpd);
1055 }
1056}
1057
1058/**
949 * ipr_log_config_error - Log a configuration error. 1059 * ipr_log_config_error - Log a configuration error.
950 * @ioa_cfg: ioa config struct 1060 * @ioa_cfg: ioa config struct
951 * @hostrcb: hostrcb struct 1061 * @hostrcb: hostrcb struct
@@ -966,30 +1076,22 @@ static void ipr_log_config_error(struct ipr_ioa_cfg *ioa_cfg,
966 ipr_err("Device Errors Detected/Logged: %d/%d\n", 1076 ipr_err("Device Errors Detected/Logged: %d/%d\n",
967 be32_to_cpu(error->errors_detected), errors_logged); 1077 be32_to_cpu(error->errors_detected), errors_logged);
968 1078
969 dev_entry = error->dev_entry; 1079 dev_entry = error->dev;
970 1080
971 for (i = 0; i < errors_logged; i++, dev_entry++) { 1081 for (i = 0; i < errors_logged; i++, dev_entry++) {
972 ipr_err_separator; 1082 ipr_err_separator;
973 1083
974 if (dev_entry->dev_res_addr.bus >= IPR_MAX_NUM_BUSES) { 1084 ipr_phys_res_err(ioa_cfg, dev_entry->dev_res_addr, "Device %d", i + 1);
975 ipr_err("Device %d: missing\n", i + 1); 1085 ipr_log_vpd(&dev_entry->vpd);
976 } else {
977 ipr_err("Device %d: %d:%d:%d:%d\n", i + 1,
978 ioa_cfg->host->host_no, dev_entry->dev_res_addr.bus,
979 dev_entry->dev_res_addr.target, dev_entry->dev_res_addr.lun);
980 }
981 ipr_log_vpd(&dev_entry->dev_vpids, dev_entry->dev_sn);
982 1086
983 ipr_err("-----New Device Information-----\n"); 1087 ipr_err("-----New Device Information-----\n");
984 ipr_log_vpd(&dev_entry->new_dev_vpids, dev_entry->new_dev_sn); 1088 ipr_log_vpd(&dev_entry->new_vpd);
985 1089
986 ipr_err("Cache Directory Card Information:\n"); 1090 ipr_err("Cache Directory Card Information:\n");
987 ipr_log_vpd(&dev_entry->ioa_last_with_dev_vpids, 1091 ipr_log_vpd(&dev_entry->ioa_last_with_dev_vpd);
988 dev_entry->ioa_last_with_dev_sn);
989 1092
990 ipr_err("Adapter Card Information:\n"); 1093 ipr_err("Adapter Card Information:\n");
991 ipr_log_vpd(&dev_entry->cfc_last_with_dev_vpids, 1094 ipr_log_vpd(&dev_entry->cfc_last_with_dev_vpd);
992 dev_entry->cfc_last_with_dev_sn);
993 1095
994 ipr_err("Additional IOA Data: %08X %08X %08X %08X %08X\n", 1096 ipr_err("Additional IOA Data: %08X %08X %08X %08X %08X\n",
995 be32_to_cpu(dev_entry->ioa_data[0]), 1097 be32_to_cpu(dev_entry->ioa_data[0]),
@@ -1001,6 +1103,57 @@ static void ipr_log_config_error(struct ipr_ioa_cfg *ioa_cfg,
1001} 1103}
1002 1104
1003/** 1105/**
1106 * ipr_log_enhanced_array_error - Log an array configuration error.
1107 * @ioa_cfg: ioa config struct
1108 * @hostrcb: hostrcb struct
1109 *
1110 * Return value:
1111 * none
1112 **/
1113static void ipr_log_enhanced_array_error(struct ipr_ioa_cfg *ioa_cfg,
1114 struct ipr_hostrcb *hostrcb)
1115{
1116 int i, num_entries;
1117 struct ipr_hostrcb_type_14_error *error;
1118 struct ipr_hostrcb_array_data_entry_enhanced *array_entry;
1119 const u8 zero_sn[IPR_SERIAL_NUM_LEN] = { [0 ... IPR_SERIAL_NUM_LEN-1] = '0' };
1120
1121 error = &hostrcb->hcam.u.error.u.type_14_error;
1122
1123 ipr_err_separator;
1124
1125 ipr_err("RAID %s Array Configuration: %d:%d:%d:%d\n",
1126 error->protection_level,
1127 ioa_cfg->host->host_no,
1128 error->last_func_vset_res_addr.bus,
1129 error->last_func_vset_res_addr.target,
1130 error->last_func_vset_res_addr.lun);
1131
1132 ipr_err_separator;
1133
1134 array_entry = error->array_member;
1135 num_entries = min_t(u32, be32_to_cpu(error->num_entries),
1136 sizeof(error->array_member));
1137
1138 for (i = 0; i < num_entries; i++, array_entry++) {
1139 if (!memcmp(array_entry->vpd.vpd.sn, zero_sn, IPR_SERIAL_NUM_LEN))
1140 continue;
1141
1142 if (be32_to_cpu(error->exposed_mode_adn) == i)
1143 ipr_err("Exposed Array Member %d:\n", i);
1144 else
1145 ipr_err("Array Member %d:\n", i);
1146
1147 ipr_log_ext_vpd(&array_entry->vpd);
1148 ipr_phys_res_err(ioa_cfg, array_entry->dev_res_addr, "Current Location");
1149 ipr_phys_res_err(ioa_cfg, array_entry->expected_dev_res_addr,
1150 "Expected Location");
1151
1152 ipr_err_separator;
1153 }
1154}
1155
1156/**
1004 * ipr_log_array_error - Log an array configuration error. 1157 * ipr_log_array_error - Log an array configuration error.
1005 * @ioa_cfg: ioa config struct 1158 * @ioa_cfg: ioa config struct
1006 * @hostrcb: hostrcb struct 1159 * @hostrcb: hostrcb struct
@@ -1032,36 +1185,19 @@ static void ipr_log_array_error(struct ipr_ioa_cfg *ioa_cfg,
1032 array_entry = error->array_member; 1185 array_entry = error->array_member;
1033 1186
1034 for (i = 0; i < 18; i++) { 1187 for (i = 0; i < 18; i++) {
1035 if (!memcmp(array_entry->serial_num, zero_sn, IPR_SERIAL_NUM_LEN)) 1188 if (!memcmp(array_entry->vpd.sn, zero_sn, IPR_SERIAL_NUM_LEN))
1036 continue; 1189 continue;
1037 1190
1038 if (be32_to_cpu(error->exposed_mode_adn) == i) { 1191 if (be32_to_cpu(error->exposed_mode_adn) == i)
1039 ipr_err("Exposed Array Member %d:\n", i); 1192 ipr_err("Exposed Array Member %d:\n", i);
1040 } else { 1193 else
1041 ipr_err("Array Member %d:\n", i); 1194 ipr_err("Array Member %d:\n", i);
1042 }
1043 1195
1044 ipr_log_vpd(&array_entry->vpids, array_entry->serial_num); 1196 ipr_log_vpd(&array_entry->vpd);
1045
1046 if (array_entry->dev_res_addr.bus >= IPR_MAX_NUM_BUSES) {
1047 ipr_err("Current Location: unknown\n");
1048 } else {
1049 ipr_err("Current Location: %d:%d:%d:%d\n",
1050 ioa_cfg->host->host_no,
1051 array_entry->dev_res_addr.bus,
1052 array_entry->dev_res_addr.target,
1053 array_entry->dev_res_addr.lun);
1054 }
1055 1197
1056 if (array_entry->expected_dev_res_addr.bus >= IPR_MAX_NUM_BUSES) { 1198 ipr_phys_res_err(ioa_cfg, array_entry->dev_res_addr, "Current Location");
1057 ipr_err("Expected Location: unknown\n"); 1199 ipr_phys_res_err(ioa_cfg, array_entry->expected_dev_res_addr,
1058 } else { 1200 "Expected Location");
1059 ipr_err("Expected Location: %d:%d:%d:%d\n",
1060 ioa_cfg->host->host_no,
1061 array_entry->expected_dev_res_addr.bus,
1062 array_entry->expected_dev_res_addr.target,
1063 array_entry->expected_dev_res_addr.lun);
1064 }
1065 1201
1066 ipr_err_separator; 1202 ipr_err_separator;
1067 1203
@@ -1073,35 +1209,95 @@ static void ipr_log_array_error(struct ipr_ioa_cfg *ioa_cfg,
1073} 1209}
1074 1210
1075/** 1211/**
1076 * ipr_log_generic_error - Log an adapter error. 1212 * ipr_log_hex_data - Log additional hex IOA error data.
1077 * @ioa_cfg: ioa config struct 1213 * @data: IOA error data
1078 * @hostrcb: hostrcb struct 1214 * @len: data length
1079 * 1215 *
1080 * Return value: 1216 * Return value:
1081 * none 1217 * none
1082 **/ 1218 **/
1083static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg, 1219static void ipr_log_hex_data(u32 *data, int len)
1084 struct ipr_hostrcb *hostrcb)
1085{ 1220{
1086 int i; 1221 int i;
1087 int ioa_data_len = be32_to_cpu(hostrcb->hcam.length);
1088 1222
1089 if (ioa_data_len == 0) 1223 if (len == 0)
1090 return; 1224 return;
1091 1225
1092 ipr_err("IOA Error Data:\n"); 1226 for (i = 0; i < len / 4; i += 4) {
1093 ipr_err("Offset 0 1 2 3 4 5 6 7 8 9 A B C D E F\n");
1094
1095 for (i = 0; i < ioa_data_len / 4; i += 4) {
1096 ipr_err("%08X: %08X %08X %08X %08X\n", i*4, 1227 ipr_err("%08X: %08X %08X %08X %08X\n", i*4,
1097 be32_to_cpu(hostrcb->hcam.u.raw.data[i]), 1228 be32_to_cpu(data[i]),
1098 be32_to_cpu(hostrcb->hcam.u.raw.data[i+1]), 1229 be32_to_cpu(data[i+1]),
1099 be32_to_cpu(hostrcb->hcam.u.raw.data[i+2]), 1230 be32_to_cpu(data[i+2]),
1100 be32_to_cpu(hostrcb->hcam.u.raw.data[i+3])); 1231 be32_to_cpu(data[i+3]));
1101 } 1232 }
1102} 1233}
1103 1234
1104/** 1235/**
1236 * ipr_log_enhanced_dual_ioa_error - Log an enhanced dual adapter error.
1237 * @ioa_cfg: ioa config struct
1238 * @hostrcb: hostrcb struct
1239 *
1240 * Return value:
1241 * none
1242 **/
1243static void ipr_log_enhanced_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1244 struct ipr_hostrcb *hostrcb)
1245{
1246 struct ipr_hostrcb_type_17_error *error;
1247
1248 error = &hostrcb->hcam.u.error.u.type_17_error;
1249 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
1250
1251 ipr_err("%s\n", error->failure_reason);
1252 ipr_err("Remote Adapter VPD:\n");
1253 ipr_log_ext_vpd(&error->vpd);
1254 ipr_log_hex_data(error->data,
1255 be32_to_cpu(hostrcb->hcam.length) -
1256 (offsetof(struct ipr_hostrcb_error, u) +
1257 offsetof(struct ipr_hostrcb_type_17_error, data)));
1258}
1259
1260/**
1261 * ipr_log_dual_ioa_error - Log a dual adapter error.
1262 * @ioa_cfg: ioa config struct
1263 * @hostrcb: hostrcb struct
1264 *
1265 * Return value:
1266 * none
1267 **/
1268static void ipr_log_dual_ioa_error(struct ipr_ioa_cfg *ioa_cfg,
1269 struct ipr_hostrcb *hostrcb)
1270{
1271 struct ipr_hostrcb_type_07_error *error;
1272
1273 error = &hostrcb->hcam.u.error.u.type_07_error;
1274 error->failure_reason[sizeof(error->failure_reason) - 1] = '\0';
1275
1276 ipr_err("%s\n", error->failure_reason);
1277 ipr_err("Remote Adapter VPD:\n");
1278 ipr_log_vpd(&error->vpd);
1279 ipr_log_hex_data(error->data,
1280 be32_to_cpu(hostrcb->hcam.length) -
1281 (offsetof(struct ipr_hostrcb_error, u) +
1282 offsetof(struct ipr_hostrcb_type_07_error, data)));
1283}
1284
1285/**
1286 * ipr_log_generic_error - Log an adapter error.
1287 * @ioa_cfg: ioa config struct
1288 * @hostrcb: hostrcb struct
1289 *
1290 * Return value:
1291 * none
1292 **/
1293static void ipr_log_generic_error(struct ipr_ioa_cfg *ioa_cfg,
1294 struct ipr_hostrcb *hostrcb)
1295{
1296 ipr_log_hex_data(hostrcb->hcam.u.raw.data,
1297 be32_to_cpu(hostrcb->hcam.length));
1298}
1299
1300/**
1105 * ipr_get_error - Find the specfied IOASC in the ipr_error_table. 1301 * ipr_get_error - Find the specfied IOASC in the ipr_error_table.
1106 * @ioasc: IOASC 1302 * @ioasc: IOASC
1107 * 1303 *
@@ -1172,11 +1368,10 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
1172 1368
1173 if (ioa_cfg->log_level < IPR_DEFAULT_LOG_LEVEL) 1369 if (ioa_cfg->log_level < IPR_DEFAULT_LOG_LEVEL)
1174 return; 1370 return;
1371 if (be32_to_cpu(hostrcb->hcam.length) > sizeof(hostrcb->hcam.u.raw))
1372 hostrcb->hcam.length = cpu_to_be32(sizeof(hostrcb->hcam.u.raw));
1175 1373
1176 switch (hostrcb->hcam.overlay_id) { 1374 switch (hostrcb->hcam.overlay_id) {
1177 case IPR_HOST_RCB_OVERLAY_ID_1:
1178 ipr_log_generic_error(ioa_cfg, hostrcb);
1179 break;
1180 case IPR_HOST_RCB_OVERLAY_ID_2: 1375 case IPR_HOST_RCB_OVERLAY_ID_2:
1181 ipr_log_cache_error(ioa_cfg, hostrcb); 1376 ipr_log_cache_error(ioa_cfg, hostrcb);
1182 break; 1377 break;
@@ -1187,13 +1382,26 @@ static void ipr_handle_log_data(struct ipr_ioa_cfg *ioa_cfg,
1187 case IPR_HOST_RCB_OVERLAY_ID_6: 1382 case IPR_HOST_RCB_OVERLAY_ID_6:
1188 ipr_log_array_error(ioa_cfg, hostrcb); 1383 ipr_log_array_error(ioa_cfg, hostrcb);
1189 break; 1384 break;
1190 case IPR_HOST_RCB_OVERLAY_ID_DEFAULT: 1385 case IPR_HOST_RCB_OVERLAY_ID_7:
1191 ipr_log_generic_error(ioa_cfg, hostrcb); 1386 ipr_log_dual_ioa_error(ioa_cfg, hostrcb);
1387 break;
1388 case IPR_HOST_RCB_OVERLAY_ID_12:
1389 ipr_log_enhanced_cache_error(ioa_cfg, hostrcb);
1390 break;
1391 case IPR_HOST_RCB_OVERLAY_ID_13:
1392 ipr_log_enhanced_config_error(ioa_cfg, hostrcb);
1393 break;
1394 case IPR_HOST_RCB_OVERLAY_ID_14:
1395 case IPR_HOST_RCB_OVERLAY_ID_16:
1396 ipr_log_enhanced_array_error(ioa_cfg, hostrcb);
1192 break; 1397 break;
1398 case IPR_HOST_RCB_OVERLAY_ID_17:
1399 ipr_log_enhanced_dual_ioa_error(ioa_cfg, hostrcb);
1400 break;
1401 case IPR_HOST_RCB_OVERLAY_ID_1:
1402 case IPR_HOST_RCB_OVERLAY_ID_DEFAULT:
1193 default: 1403 default:
1194 dev_err(&ioa_cfg->pdev->dev, 1404 ipr_log_generic_error(ioa_cfg, hostrcb);
1195 "Unknown error received. Overlay ID: %d\n",
1196 hostrcb->hcam.overlay_id);
1197 break; 1405 break;
1198 } 1406 }
1199} 1407}
@@ -1972,6 +2180,103 @@ static struct bin_attribute ipr_trace_attr = {
1972}; 2180};
1973#endif 2181#endif
1974 2182
2183static const struct {
2184 enum ipr_cache_state state;
2185 char *name;
2186} cache_state [] = {
2187 { CACHE_NONE, "none" },
2188 { CACHE_DISABLED, "disabled" },
2189 { CACHE_ENABLED, "enabled" }
2190};
2191
2192/**
2193 * ipr_show_write_caching - Show the write caching attribute
2194 * @class_dev: class device struct
2195 * @buf: buffer
2196 *
2197 * Return value:
2198 * number of bytes printed to buffer
2199 **/
2200static ssize_t ipr_show_write_caching(struct class_device *class_dev, char *buf)
2201{
2202 struct Scsi_Host *shost = class_to_shost(class_dev);
2203 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2204 unsigned long lock_flags = 0;
2205 int i, len = 0;
2206
2207 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2208 for (i = 0; i < ARRAY_SIZE(cache_state); i++) {
2209 if (cache_state[i].state == ioa_cfg->cache_state) {
2210 len = snprintf(buf, PAGE_SIZE, "%s\n", cache_state[i].name);
2211 break;
2212 }
2213 }
2214 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2215 return len;
2216}
2217
2218
2219/**
2220 * ipr_store_write_caching - Enable/disable adapter write cache
2221 * @class_dev: class_device struct
2222 * @buf: buffer
2223 * @count: buffer size
2224 *
2225 * This function will enable/disable adapter write cache.
2226 *
2227 * Return value:
2228 * count on success / other on failure
2229 **/
2230static ssize_t ipr_store_write_caching(struct class_device *class_dev,
2231 const char *buf, size_t count)
2232{
2233 struct Scsi_Host *shost = class_to_shost(class_dev);
2234 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2235 unsigned long lock_flags = 0;
2236 enum ipr_cache_state new_state = CACHE_INVALID;
2237 int i;
2238
2239 if (!capable(CAP_SYS_ADMIN))
2240 return -EACCES;
2241 if (ioa_cfg->cache_state == CACHE_NONE)
2242 return -EINVAL;
2243
2244 for (i = 0; i < ARRAY_SIZE(cache_state); i++) {
2245 if (!strncmp(cache_state[i].name, buf, strlen(cache_state[i].name))) {
2246 new_state = cache_state[i].state;
2247 break;
2248 }
2249 }
2250
2251 if (new_state != CACHE_DISABLED && new_state != CACHE_ENABLED)
2252 return -EINVAL;
2253
2254 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2255 if (ioa_cfg->cache_state == new_state) {
2256 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2257 return count;
2258 }
2259
2260 ioa_cfg->cache_state = new_state;
2261 dev_info(&ioa_cfg->pdev->dev, "%s adapter write cache.\n",
2262 new_state == CACHE_ENABLED ? "Enabling" : "Disabling");
2263 if (!ioa_cfg->in_reset_reload)
2264 ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NORMAL);
2265 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2266 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
2267
2268 return count;
2269}
2270
2271static struct class_device_attribute ipr_ioa_cache_attr = {
2272 .attr = {
2273 .name = "write_cache",
2274 .mode = S_IRUGO | S_IWUSR,
2275 },
2276 .show = ipr_show_write_caching,
2277 .store = ipr_store_write_caching
2278};
2279
1975/** 2280/**
1976 * ipr_show_fw_version - Show the firmware version 2281 * ipr_show_fw_version - Show the firmware version
1977 * @class_dev: class device struct 2282 * @class_dev: class device struct
@@ -2112,6 +2417,74 @@ static struct class_device_attribute ipr_diagnostics_attr = {
2112}; 2417};
2113 2418
2114/** 2419/**
2420 * ipr_show_adapter_state - Show the adapter's state
2421 * @class_dev: class device struct
2422 * @buf: buffer
2423 *
2424 * Return value:
2425 * number of bytes printed to buffer
2426 **/
2427static ssize_t ipr_show_adapter_state(struct class_device *class_dev, char *buf)
2428{
2429 struct Scsi_Host *shost = class_to_shost(class_dev);
2430 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2431 unsigned long lock_flags = 0;
2432 int len;
2433
2434 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2435 if (ioa_cfg->ioa_is_dead)
2436 len = snprintf(buf, PAGE_SIZE, "offline\n");
2437 else
2438 len = snprintf(buf, PAGE_SIZE, "online\n");
2439 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2440 return len;
2441}
2442
2443/**
2444 * ipr_store_adapter_state - Change adapter state
2445 * @class_dev: class_device struct
2446 * @buf: buffer
2447 * @count: buffer size
2448 *
2449 * This function will change the adapter's state.
2450 *
2451 * Return value:
2452 * count on success / other on failure
2453 **/
2454static ssize_t ipr_store_adapter_state(struct class_device *class_dev,
2455 const char *buf, size_t count)
2456{
2457 struct Scsi_Host *shost = class_to_shost(class_dev);
2458 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *)shost->hostdata;
2459 unsigned long lock_flags;
2460 int result = count;
2461
2462 if (!capable(CAP_SYS_ADMIN))
2463 return -EACCES;
2464
2465 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2466 if (ioa_cfg->ioa_is_dead && !strncmp(buf, "online", 6)) {
2467 ioa_cfg->ioa_is_dead = 0;
2468 ioa_cfg->reset_retries = 0;
2469 ioa_cfg->in_ioa_bringdown = 0;
2470 ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
2471 }
2472 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2473 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
2474
2475 return result;
2476}
2477
2478static struct class_device_attribute ipr_ioa_state_attr = {
2479 .attr = {
2480 .name = "state",
2481 .mode = S_IRUGO | S_IWUSR,
2482 },
2483 .show = ipr_show_adapter_state,
2484 .store = ipr_store_adapter_state
2485};
2486
2487/**
2115 * ipr_store_reset_adapter - Reset the adapter 2488 * ipr_store_reset_adapter - Reset the adapter
2116 * @class_dev: class_device struct 2489 * @class_dev: class_device struct
2117 * @buf: buffer 2490 * @buf: buffer
@@ -2183,7 +2556,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
2183 num_elem = buf_len / bsize_elem; 2556 num_elem = buf_len / bsize_elem;
2184 2557
2185 /* Allocate a scatter/gather list for the DMA */ 2558 /* Allocate a scatter/gather list for the DMA */
2186 sglist = kmalloc(sizeof(struct ipr_sglist) + 2559 sglist = kzalloc(sizeof(struct ipr_sglist) +
2187 (sizeof(struct scatterlist) * (num_elem - 1)), 2560 (sizeof(struct scatterlist) * (num_elem - 1)),
2188 GFP_KERNEL); 2561 GFP_KERNEL);
2189 2562
@@ -2192,9 +2565,6 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
2192 return NULL; 2565 return NULL;
2193 } 2566 }
2194 2567
2195 memset(sglist, 0, sizeof(struct ipr_sglist) +
2196 (sizeof(struct scatterlist) * (num_elem - 1)));
2197
2198 scatterlist = sglist->scatterlist; 2568 scatterlist = sglist->scatterlist;
2199 2569
2200 sglist->order = order; 2570 sglist->order = order;
@@ -2289,31 +2659,24 @@ static int ipr_copy_ucode_buffer(struct ipr_sglist *sglist,
2289} 2659}
2290 2660
2291/** 2661/**
2292 * ipr_map_ucode_buffer - Map a microcode download buffer 2662 * ipr_build_ucode_ioadl - Build a microcode download IOADL
2293 * @ipr_cmd: ipr command struct 2663 * @ipr_cmd: ipr command struct
2294 * @sglist: scatter/gather list 2664 * @sglist: scatter/gather list
2295 * @len: total length of download buffer
2296 * 2665 *
2297 * Maps a microcode download scatter/gather list for DMA and 2666 * Builds a microcode download IOA data list (IOADL).
2298 * builds the IOADL.
2299 * 2667 *
2300 * Return value:
2301 * 0 on success / -EIO on failure
2302 **/ 2668 **/
2303static int ipr_map_ucode_buffer(struct ipr_cmnd *ipr_cmd, 2669static void ipr_build_ucode_ioadl(struct ipr_cmnd *ipr_cmd,
2304 struct ipr_sglist *sglist, int len) 2670 struct ipr_sglist *sglist)
2305{ 2671{
2306 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
2307 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb; 2672 struct ipr_ioarcb *ioarcb = &ipr_cmd->ioarcb;
2308 struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl; 2673 struct ipr_ioadl_desc *ioadl = ipr_cmd->ioadl;
2309 struct scatterlist *scatterlist = sglist->scatterlist; 2674 struct scatterlist *scatterlist = sglist->scatterlist;
2310 int i; 2675 int i;
2311 2676
2312 ipr_cmd->dma_use_sg = pci_map_sg(ioa_cfg->pdev, scatterlist, 2677 ipr_cmd->dma_use_sg = sglist->num_dma_sg;
2313 sglist->num_sg, DMA_TO_DEVICE);
2314
2315 ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ; 2678 ioarcb->cmd_pkt.flags_hi |= IPR_FLAGS_HI_WRITE_NOT_READ;
2316 ioarcb->write_data_transfer_length = cpu_to_be32(len); 2679 ioarcb->write_data_transfer_length = cpu_to_be32(sglist->buffer_len);
2317 ioarcb->write_ioadl_len = 2680 ioarcb->write_ioadl_len =
2318 cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg); 2681 cpu_to_be32(sizeof(struct ipr_ioadl_desc) * ipr_cmd->dma_use_sg);
2319 2682
@@ -2324,15 +2687,52 @@ static int ipr_map_ucode_buffer(struct ipr_cmnd *ipr_cmd,
2324 cpu_to_be32(sg_dma_address(&scatterlist[i])); 2687 cpu_to_be32(sg_dma_address(&scatterlist[i]));
2325 } 2688 }
2326 2689
2327 if (likely(ipr_cmd->dma_use_sg)) { 2690 ioadl[i-1].flags_and_data_len |=
2328 ioadl[i-1].flags_and_data_len |= 2691 cpu_to_be32(IPR_IOADL_FLAGS_LAST);
2329 cpu_to_be32(IPR_IOADL_FLAGS_LAST); 2692}
2693
2694/**
2695 * ipr_update_ioa_ucode - Update IOA's microcode
2696 * @ioa_cfg: ioa config struct
2697 * @sglist: scatter/gather list
2698 *
2699 * Initiate an adapter reset to update the IOA's microcode
2700 *
2701 * Return value:
2702 * 0 on success / -EIO on failure
2703 **/
2704static int ipr_update_ioa_ucode(struct ipr_ioa_cfg *ioa_cfg,
2705 struct ipr_sglist *sglist)
2706{
2707 unsigned long lock_flags;
2708
2709 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2710
2711 if (ioa_cfg->ucode_sglist) {
2712 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2713 dev_err(&ioa_cfg->pdev->dev,
2714 "Microcode download already in progress\n");
2715 return -EIO;
2330 } 2716 }
2331 else { 2717
2332 dev_err(&ioa_cfg->pdev->dev, "pci_map_sg failed!\n"); 2718 sglist->num_dma_sg = pci_map_sg(ioa_cfg->pdev, sglist->scatterlist,
2719 sglist->num_sg, DMA_TO_DEVICE);
2720
2721 if (!sglist->num_dma_sg) {
2722 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2723 dev_err(&ioa_cfg->pdev->dev,
2724 "Failed to map microcode download buffer!\n");
2333 return -EIO; 2725 return -EIO;
2334 } 2726 }
2335 2727
2728 ioa_cfg->ucode_sglist = sglist;
2729 ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NORMAL);
2730 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2731 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
2732
2733 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2734 ioa_cfg->ucode_sglist = NULL;
2735 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2336 return 0; 2736 return 0;
2337} 2737}
2338 2738
@@ -2355,7 +2755,6 @@ static ssize_t ipr_store_update_fw(struct class_device *class_dev,
2355 struct ipr_ucode_image_header *image_hdr; 2755 struct ipr_ucode_image_header *image_hdr;
2356 const struct firmware *fw_entry; 2756 const struct firmware *fw_entry;
2357 struct ipr_sglist *sglist; 2757 struct ipr_sglist *sglist;
2358 unsigned long lock_flags;
2359 char fname[100]; 2758 char fname[100];
2360 char *src; 2759 char *src;
2361 int len, result, dnld_size; 2760 int len, result, dnld_size;
@@ -2396,35 +2795,17 @@ static ssize_t ipr_store_update_fw(struct class_device *class_dev,
2396 if (result) { 2795 if (result) {
2397 dev_err(&ioa_cfg->pdev->dev, 2796 dev_err(&ioa_cfg->pdev->dev,
2398 "Microcode buffer copy to DMA buffer failed\n"); 2797 "Microcode buffer copy to DMA buffer failed\n");
2399 ipr_free_ucode_buffer(sglist); 2798 goto out;
2400 release_firmware(fw_entry);
2401 return result;
2402 }
2403
2404 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2405
2406 if (ioa_cfg->ucode_sglist) {
2407 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2408 dev_err(&ioa_cfg->pdev->dev,
2409 "Microcode download already in progress\n");
2410 ipr_free_ucode_buffer(sglist);
2411 release_firmware(fw_entry);
2412 return -EIO;
2413 } 2799 }
2414 2800
2415 ioa_cfg->ucode_sglist = sglist; 2801 result = ipr_update_ioa_ucode(ioa_cfg, sglist);
2416 ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NORMAL);
2417 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2418 wait_event(ioa_cfg->reset_wait_q, !ioa_cfg->in_reset_reload);
2419
2420 spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
2421 ioa_cfg->ucode_sglist = NULL;
2422 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2423 2802
2803 if (!result)
2804 result = count;
2805out:
2424 ipr_free_ucode_buffer(sglist); 2806 ipr_free_ucode_buffer(sglist);
2425 release_firmware(fw_entry); 2807 release_firmware(fw_entry);
2426 2808 return result;
2427 return count;
2428} 2809}
2429 2810
2430static struct class_device_attribute ipr_update_fw_attr = { 2811static struct class_device_attribute ipr_update_fw_attr = {
@@ -2439,8 +2820,10 @@ static struct class_device_attribute *ipr_ioa_attrs[] = {
2439 &ipr_fw_version_attr, 2820 &ipr_fw_version_attr,
2440 &ipr_log_level_attr, 2821 &ipr_log_level_attr,
2441 &ipr_diagnostics_attr, 2822 &ipr_diagnostics_attr,
2823 &ipr_ioa_state_attr,
2442 &ipr_ioa_reset_attr, 2824 &ipr_ioa_reset_attr,
2443 &ipr_update_fw_attr, 2825 &ipr_update_fw_attr,
2826 &ipr_ioa_cache_attr,
2444 NULL, 2827 NULL,
2445}; 2828};
2446 2829
@@ -2548,14 +2931,13 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
2548 unsigned long lock_flags = 0; 2931 unsigned long lock_flags = 0;
2549 2932
2550 ENTER; 2933 ENTER;
2551 dump = kmalloc(sizeof(struct ipr_dump), GFP_KERNEL); 2934 dump = kzalloc(sizeof(struct ipr_dump), GFP_KERNEL);
2552 2935
2553 if (!dump) { 2936 if (!dump) {
2554 ipr_err("Dump memory allocation failed\n"); 2937 ipr_err("Dump memory allocation failed\n");
2555 return -ENOMEM; 2938 return -ENOMEM;
2556 } 2939 }
2557 2940
2558 memset(dump, 0, sizeof(struct ipr_dump));
2559 kref_init(&dump->kref); 2941 kref_init(&dump->kref);
2560 dump->ioa_cfg = ioa_cfg; 2942 dump->ioa_cfg = ioa_cfg;
2561 2943
@@ -2824,8 +3206,10 @@ static int ipr_slave_configure(struct scsi_device *sdev)
2824 if (res) { 3206 if (res) {
2825 if (ipr_is_af_dasd_device(res)) 3207 if (ipr_is_af_dasd_device(res))
2826 sdev->type = TYPE_RAID; 3208 sdev->type = TYPE_RAID;
2827 if (ipr_is_af_dasd_device(res) || ipr_is_ioa_resource(res)) 3209 if (ipr_is_af_dasd_device(res) || ipr_is_ioa_resource(res)) {
2828 sdev->scsi_level = 4; 3210 sdev->scsi_level = 4;
3211 sdev->no_uld_attach = 1;
3212 }
2829 if (ipr_is_vset_device(res)) { 3213 if (ipr_is_vset_device(res)) {
2830 sdev->timeout = IPR_VSET_RW_TIMEOUT; 3214 sdev->timeout = IPR_VSET_RW_TIMEOUT;
2831 blk_queue_max_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS); 3215 blk_queue_max_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS);
@@ -2848,13 +3232,14 @@ static int ipr_slave_configure(struct scsi_device *sdev)
2848 * handling new commands. 3232 * handling new commands.
2849 * 3233 *
2850 * Return value: 3234 * Return value:
2851 * 0 on success 3235 * 0 on success / -ENXIO if device does not exist
2852 **/ 3236 **/
2853static int ipr_slave_alloc(struct scsi_device *sdev) 3237static int ipr_slave_alloc(struct scsi_device *sdev)
2854{ 3238{
2855 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata; 3239 struct ipr_ioa_cfg *ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata;
2856 struct ipr_resource_entry *res; 3240 struct ipr_resource_entry *res;
2857 unsigned long lock_flags; 3241 unsigned long lock_flags;
3242 int rc = -ENXIO;
2858 3243
2859 sdev->hostdata = NULL; 3244 sdev->hostdata = NULL;
2860 3245
@@ -2868,14 +3253,16 @@ static int ipr_slave_alloc(struct scsi_device *sdev)
2868 res->add_to_ml = 0; 3253 res->add_to_ml = 0;
2869 res->in_erp = 0; 3254 res->in_erp = 0;
2870 sdev->hostdata = res; 3255 sdev->hostdata = res;
2871 res->needs_sync_complete = 1; 3256 if (!ipr_is_naca_model(res))
3257 res->needs_sync_complete = 1;
3258 rc = 0;
2872 break; 3259 break;
2873 } 3260 }
2874 } 3261 }
2875 3262
2876 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); 3263 spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
2877 3264
2878 return 0; 3265 return rc;
2879} 3266}
2880 3267
2881/** 3268/**
@@ -2939,7 +3326,7 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd * scsi_cmd)
2939 ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata; 3326 ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata;
2940 res = scsi_cmd->device->hostdata; 3327 res = scsi_cmd->device->hostdata;
2941 3328
2942 if (!res || (!ipr_is_gscsi(res) && !ipr_is_vset_device(res))) 3329 if (!res)
2943 return FAILED; 3330 return FAILED;
2944 3331
2945 /* 3332 /*
@@ -3131,7 +3518,8 @@ static int ipr_cancel_op(struct scsi_cmnd * scsi_cmd)
3131 } 3518 }
3132 3519
3133 list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q); 3520 list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
3134 res->needs_sync_complete = 1; 3521 if (!ipr_is_naca_model(res))
3522 res->needs_sync_complete = 1;
3135 3523
3136 LEAVE; 3524 LEAVE;
3137 return (IPR_IOASC_SENSE_KEY(ioasc) ? FAILED : SUCCESS); 3525 return (IPR_IOASC_SENSE_KEY(ioasc) ? FAILED : SUCCESS);
@@ -3435,7 +3823,8 @@ static void ipr_erp_done(struct ipr_cmnd *ipr_cmd)
3435 } 3823 }
3436 3824
3437 if (res) { 3825 if (res) {
3438 res->needs_sync_complete = 1; 3826 if (!ipr_is_naca_model(res))
3827 res->needs_sync_complete = 1;
3439 res->in_erp = 0; 3828 res->in_erp = 0;
3440 } 3829 }
3441 ipr_unmap_sglist(ioa_cfg, ipr_cmd); 3830 ipr_unmap_sglist(ioa_cfg, ipr_cmd);
@@ -3705,6 +4094,30 @@ static void ipr_gen_sense(struct ipr_cmnd *ipr_cmd)
3705} 4094}
3706 4095
3707/** 4096/**
4097 * ipr_get_autosense - Copy autosense data to sense buffer
4098 * @ipr_cmd: ipr command struct
4099 *
4100 * This function copies the autosense buffer to the buffer
4101 * in the scsi_cmd, if there is autosense available.
4102 *
4103 * Return value:
4104 * 1 if autosense was available / 0 if not
4105 **/
4106static int ipr_get_autosense(struct ipr_cmnd *ipr_cmd)
4107{
4108 struct ipr_ioasa *ioasa = &ipr_cmd->ioasa;
4109
4110 if ((be32_to_cpu(ioasa->ioasc_specific) &
4111 (IPR_ADDITIONAL_STATUS_FMT | IPR_AUTOSENSE_VALID)) == 0)
4112 return 0;
4113
4114 memcpy(ipr_cmd->scsi_cmd->sense_buffer, ioasa->auto_sense.data,
4115 min_t(u16, be16_to_cpu(ioasa->auto_sense.auto_sense_len),
4116 SCSI_SENSE_BUFFERSIZE));
4117 return 1;
4118}
4119
4120/**
3708 * ipr_erp_start - Process an error response for a SCSI op 4121 * ipr_erp_start - Process an error response for a SCSI op
3709 * @ioa_cfg: ioa config struct 4122 * @ioa_cfg: ioa config struct
3710 * @ipr_cmd: ipr command struct 4123 * @ipr_cmd: ipr command struct
@@ -3734,14 +4147,19 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
3734 4147
3735 switch (ioasc & IPR_IOASC_IOASC_MASK) { 4148 switch (ioasc & IPR_IOASC_IOASC_MASK) {
3736 case IPR_IOASC_ABORTED_CMD_TERM_BY_HOST: 4149 case IPR_IOASC_ABORTED_CMD_TERM_BY_HOST:
3737 scsi_cmd->result |= (DID_IMM_RETRY << 16); 4150 if (ipr_is_naca_model(res))
4151 scsi_cmd->result |= (DID_ABORT << 16);
4152 else
4153 scsi_cmd->result |= (DID_IMM_RETRY << 16);
3738 break; 4154 break;
3739 case IPR_IOASC_IR_RESOURCE_HANDLE: 4155 case IPR_IOASC_IR_RESOURCE_HANDLE:
4156 case IPR_IOASC_IR_NO_CMDS_TO_2ND_IOA:
3740 scsi_cmd->result |= (DID_NO_CONNECT << 16); 4157 scsi_cmd->result |= (DID_NO_CONNECT << 16);
3741 break; 4158 break;
3742 case IPR_IOASC_HW_SEL_TIMEOUT: 4159 case IPR_IOASC_HW_SEL_TIMEOUT:
3743 scsi_cmd->result |= (DID_NO_CONNECT << 16); 4160 scsi_cmd->result |= (DID_NO_CONNECT << 16);
3744 res->needs_sync_complete = 1; 4161 if (!ipr_is_naca_model(res))
4162 res->needs_sync_complete = 1;
3745 break; 4163 break;
3746 case IPR_IOASC_SYNC_REQUIRED: 4164 case IPR_IOASC_SYNC_REQUIRED:
3747 if (!res->in_erp) 4165 if (!res->in_erp)
@@ -3749,6 +4167,7 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
3749 scsi_cmd->result |= (DID_IMM_RETRY << 16); 4167 scsi_cmd->result |= (DID_IMM_RETRY << 16);
3750 break; 4168 break;
3751 case IPR_IOASC_MED_DO_NOT_REALLOC: /* prevent retries */ 4169 case IPR_IOASC_MED_DO_NOT_REALLOC: /* prevent retries */
4170 case IPR_IOASA_IR_DUAL_IOA_DISABLED:
3752 scsi_cmd->result |= (DID_PASSTHROUGH << 16); 4171 scsi_cmd->result |= (DID_PASSTHROUGH << 16);
3753 break; 4172 break;
3754 case IPR_IOASC_BUS_WAS_RESET: 4173 case IPR_IOASC_BUS_WAS_RESET:
@@ -3760,21 +4179,27 @@ static void ipr_erp_start(struct ipr_ioa_cfg *ioa_cfg,
3760 if (!res->resetting_device) 4179 if (!res->resetting_device)
3761 scsi_report_bus_reset(ioa_cfg->host, scsi_cmd->device->channel); 4180 scsi_report_bus_reset(ioa_cfg->host, scsi_cmd->device->channel);
3762 scsi_cmd->result |= (DID_ERROR << 16); 4181 scsi_cmd->result |= (DID_ERROR << 16);
3763 res->needs_sync_complete = 1; 4182 if (!ipr_is_naca_model(res))
4183 res->needs_sync_complete = 1;
3764 break; 4184 break;
3765 case IPR_IOASC_HW_DEV_BUS_STATUS: 4185 case IPR_IOASC_HW_DEV_BUS_STATUS:
3766 scsi_cmd->result |= IPR_IOASC_SENSE_STATUS(ioasc); 4186 scsi_cmd->result |= IPR_IOASC_SENSE_STATUS(ioasc);
3767 if (IPR_IOASC_SENSE_STATUS(ioasc) == SAM_STAT_CHECK_CONDITION) { 4187 if (IPR_IOASC_SENSE_STATUS(ioasc) == SAM_STAT_CHECK_CONDITION) {
3768 ipr_erp_cancel_all(ipr_cmd); 4188 if (!ipr_get_autosense(ipr_cmd)) {
3769 return; 4189 if (!ipr_is_naca_model(res)) {
4190 ipr_erp_cancel_all(ipr_cmd);
4191 return;
4192 }
4193 }
3770 } 4194 }
3771 res->needs_sync_complete = 1; 4195 if (!ipr_is_naca_model(res))
4196 res->needs_sync_complete = 1;
3772 break; 4197 break;
3773 case IPR_IOASC_NR_INIT_CMD_REQUIRED: 4198 case IPR_IOASC_NR_INIT_CMD_REQUIRED:
3774 break; 4199 break;
3775 default: 4200 default:
3776 scsi_cmd->result |= (DID_ERROR << 16); 4201 scsi_cmd->result |= (DID_ERROR << 16);
3777 if (!ipr_is_vset_device(res)) 4202 if (!ipr_is_vset_device(res) && !ipr_is_naca_model(res))
3778 res->needs_sync_complete = 1; 4203 res->needs_sync_complete = 1;
3779 break; 4204 break;
3780 } 4205 }
@@ -4073,6 +4498,7 @@ static int ipr_ioa_reset_done(struct ipr_cmnd *ipr_cmd)
4073 ioa_cfg->in_reset_reload = 0; 4498 ioa_cfg->in_reset_reload = 0;
4074 ioa_cfg->allow_cmds = 1; 4499 ioa_cfg->allow_cmds = 1;
4075 ioa_cfg->reset_cmd = NULL; 4500 ioa_cfg->reset_cmd = NULL;
4501 ioa_cfg->doorbell |= IPR_RUNTIME_RESET;
4076 4502
4077 list_for_each_entry(res, &ioa_cfg->used_res_q, queue) { 4503 list_for_each_entry(res, &ioa_cfg->used_res_q, queue) {
4078 if (ioa_cfg->allow_ml_add_del && (res->add_to_ml || res->del_from_ml)) { 4504 if (ioa_cfg->allow_ml_add_del && (res->add_to_ml || res->del_from_ml)) {
@@ -4146,7 +4572,7 @@ static int ipr_set_supported_devs(struct ipr_cmnd *ipr_cmd)
4146 ipr_cmd->job_step = ipr_ioa_reset_done; 4572 ipr_cmd->job_step = ipr_ioa_reset_done;
4147 4573
4148 list_for_each_entry_continue(res, &ioa_cfg->used_res_q, queue) { 4574 list_for_each_entry_continue(res, &ioa_cfg->used_res_q, queue) {
4149 if (!ipr_is_af_dasd_device(res)) 4575 if (!IPR_IS_DASD_DEVICE(res->cfgte.std_inq_data))
4150 continue; 4576 continue;
4151 4577
4152 ipr_cmd->u.res = res; 4578 ipr_cmd->u.res = res;
@@ -4179,6 +4605,36 @@ static int ipr_set_supported_devs(struct ipr_cmnd *ipr_cmd)
4179} 4605}
4180 4606
4181/** 4607/**
4608 * ipr_setup_write_cache - Disable write cache if needed
4609 * @ipr_cmd: ipr command struct
4610 *
4611 * This function sets up adapters write cache to desired setting
4612 *
4613 * Return value:
4614 * IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN
4615 **/
4616static int ipr_setup_write_cache(struct ipr_cmnd *ipr_cmd)
4617{
4618 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
4619
4620 ipr_cmd->job_step = ipr_set_supported_devs;
4621 ipr_cmd->u.res = list_entry(ioa_cfg->used_res_q.next,
4622 struct ipr_resource_entry, queue);
4623
4624 if (ioa_cfg->cache_state != CACHE_DISABLED)
4625 return IPR_RC_JOB_CONTINUE;
4626
4627 ipr_cmd->ioarcb.res_handle = cpu_to_be32(IPR_IOA_RES_HANDLE);
4628 ipr_cmd->ioarcb.cmd_pkt.request_type = IPR_RQTYPE_IOACMD;
4629 ipr_cmd->ioarcb.cmd_pkt.cdb[0] = IPR_IOA_SHUTDOWN;
4630 ipr_cmd->ioarcb.cmd_pkt.cdb[1] = IPR_SHUTDOWN_PREPARE_FOR_NORMAL;
4631
4632 ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT);
4633
4634 return IPR_RC_JOB_RETURN;
4635}
4636
4637/**
4182 * ipr_get_mode_page - Locate specified mode page 4638 * ipr_get_mode_page - Locate specified mode page
4183 * @mode_pages: mode page buffer 4639 * @mode_pages: mode page buffer
4184 * @page_code: page code to find 4640 * @page_code: page code to find
@@ -4389,10 +4845,7 @@ static int ipr_ioafp_mode_select_page28(struct ipr_cmnd *ipr_cmd)
4389 ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, mode_pages), 4845 ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, mode_pages),
4390 length); 4846 length);
4391 4847
4392 ipr_cmd->job_step = ipr_set_supported_devs; 4848 ipr_cmd->job_step = ipr_setup_write_cache;
4393 ipr_cmd->u.res = list_entry(ioa_cfg->used_res_q.next,
4394 struct ipr_resource_entry, queue);
4395
4396 ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT); 4849 ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT);
4397 4850
4398 LEAVE; 4851 LEAVE;
@@ -4431,6 +4884,51 @@ static void ipr_build_mode_sense(struct ipr_cmnd *ipr_cmd,
4431} 4884}
4432 4885
4433/** 4886/**
4887 * ipr_reset_cmd_failed - Handle failure of IOA reset command
4888 * @ipr_cmd: ipr command struct
4889 *
4890 * This function handles the failure of an IOA bringup command.
4891 *
4892 * Return value:
4893 * IPR_RC_JOB_RETURN
4894 **/
4895static int ipr_reset_cmd_failed(struct ipr_cmnd *ipr_cmd)
4896{
4897 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
4898 u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc);
4899
4900 dev_err(&ioa_cfg->pdev->dev,
4901 "0x%02X failed with IOASC: 0x%08X\n",
4902 ipr_cmd->ioarcb.cmd_pkt.cdb[0], ioasc);
4903
4904 ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
4905 list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
4906 return IPR_RC_JOB_RETURN;
4907}
4908
4909/**
4910 * ipr_reset_mode_sense_failed - Handle failure of IOAFP mode sense
4911 * @ipr_cmd: ipr command struct
4912 *
4913 * This function handles the failure of a Mode Sense to the IOAFP.
4914 * Some adapters do not handle all mode pages.
4915 *
4916 * Return value:
4917 * IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN
4918 **/
4919static int ipr_reset_mode_sense_failed(struct ipr_cmnd *ipr_cmd)
4920{
4921 u32 ioasc = be32_to_cpu(ipr_cmd->ioasa.ioasc);
4922
4923 if (ioasc == IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT) {
4924 ipr_cmd->job_step = ipr_setup_write_cache;
4925 return IPR_RC_JOB_CONTINUE;
4926 }
4927
4928 return ipr_reset_cmd_failed(ipr_cmd);
4929}
4930
4931/**
4434 * ipr_ioafp_mode_sense_page28 - Issue Mode Sense Page 28 to IOA 4932 * ipr_ioafp_mode_sense_page28 - Issue Mode Sense Page 28 to IOA
4435 * @ipr_cmd: ipr command struct 4933 * @ipr_cmd: ipr command struct
4436 * 4934 *
@@ -4451,6 +4949,7 @@ static int ipr_ioafp_mode_sense_page28(struct ipr_cmnd *ipr_cmd)
4451 sizeof(struct ipr_mode_pages)); 4949 sizeof(struct ipr_mode_pages));
4452 4950
4453 ipr_cmd->job_step = ipr_ioafp_mode_select_page28; 4951 ipr_cmd->job_step = ipr_ioafp_mode_select_page28;
4952 ipr_cmd->job_step_failed = ipr_reset_mode_sense_failed;
4454 4953
4455 ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT); 4954 ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, IPR_INTERNAL_TIMEOUT);
4456 4955
@@ -4612,6 +5111,27 @@ static void ipr_ioafp_inquiry(struct ipr_cmnd *ipr_cmd, u8 flags, u8 page,
4612} 5111}
4613 5112
4614/** 5113/**
5114 * ipr_inquiry_page_supported - Is the given inquiry page supported
5115 * @page0: inquiry page 0 buffer
5116 * @page: page code.
5117 *
5118 * This function determines if the specified inquiry page is supported.
5119 *
5120 * Return value:
5121 * 1 if page is supported / 0 if not
5122 **/
5123static int ipr_inquiry_page_supported(struct ipr_inquiry_page0 *page0, u8 page)
5124{
5125 int i;
5126
5127 for (i = 0; i < min_t(u8, page0->len, IPR_INQUIRY_PAGE0_ENTRIES); i++)
5128 if (page0->page[i] == page)
5129 return 1;
5130
5131 return 0;
5132}
5133
5134/**
4615 * ipr_ioafp_page3_inquiry - Send a Page 3 Inquiry to the adapter. 5135 * ipr_ioafp_page3_inquiry - Send a Page 3 Inquiry to the adapter.
4616 * @ipr_cmd: ipr command struct 5136 * @ipr_cmd: ipr command struct
4617 * 5137 *
@@ -4624,6 +5144,36 @@ static void ipr_ioafp_inquiry(struct ipr_cmnd *ipr_cmd, u8 flags, u8 page,
4624static int ipr_ioafp_page3_inquiry(struct ipr_cmnd *ipr_cmd) 5144static int ipr_ioafp_page3_inquiry(struct ipr_cmnd *ipr_cmd)
4625{ 5145{
4626 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 5146 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
5147 struct ipr_inquiry_page0 *page0 = &ioa_cfg->vpd_cbs->page0_data;
5148
5149 ENTER;
5150
5151 if (!ipr_inquiry_page_supported(page0, 1))
5152 ioa_cfg->cache_state = CACHE_NONE;
5153
5154 ipr_cmd->job_step = ipr_ioafp_query_ioa_cfg;
5155
5156 ipr_ioafp_inquiry(ipr_cmd, 1, 3,
5157 ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, page3_data),
5158 sizeof(struct ipr_inquiry_page3));
5159
5160 LEAVE;
5161 return IPR_RC_JOB_RETURN;
5162}
5163
5164/**
5165 * ipr_ioafp_page0_inquiry - Send a Page 0 Inquiry to the adapter.
5166 * @ipr_cmd: ipr command struct
5167 *
5168 * This function sends a Page 0 inquiry to the adapter
5169 * to retrieve supported inquiry pages.
5170 *
5171 * Return value:
5172 * IPR_RC_JOB_CONTINUE / IPR_RC_JOB_RETURN
5173 **/
5174static int ipr_ioafp_page0_inquiry(struct ipr_cmnd *ipr_cmd)
5175{
5176 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
4627 char type[5]; 5177 char type[5];
4628 5178
4629 ENTER; 5179 ENTER;
@@ -4633,11 +5183,11 @@ static int ipr_ioafp_page3_inquiry(struct ipr_cmnd *ipr_cmd)
4633 type[4] = '\0'; 5183 type[4] = '\0';
4634 ioa_cfg->type = simple_strtoul((char *)type, NULL, 16); 5184 ioa_cfg->type = simple_strtoul((char *)type, NULL, 16);
4635 5185
4636 ipr_cmd->job_step = ipr_ioafp_query_ioa_cfg; 5186 ipr_cmd->job_step = ipr_ioafp_page3_inquiry;
4637 5187
4638 ipr_ioafp_inquiry(ipr_cmd, 1, 3, 5188 ipr_ioafp_inquiry(ipr_cmd, 1, 0,
4639 ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, page3_data), 5189 ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, page0_data),
4640 sizeof(struct ipr_inquiry_page3)); 5190 sizeof(struct ipr_inquiry_page0));
4641 5191
4642 LEAVE; 5192 LEAVE;
4643 return IPR_RC_JOB_RETURN; 5193 return IPR_RC_JOB_RETURN;
@@ -4657,7 +5207,7 @@ static int ipr_ioafp_std_inquiry(struct ipr_cmnd *ipr_cmd)
4657 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 5207 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
4658 5208
4659 ENTER; 5209 ENTER;
4660 ipr_cmd->job_step = ipr_ioafp_page3_inquiry; 5210 ipr_cmd->job_step = ipr_ioafp_page0_inquiry;
4661 5211
4662 ipr_ioafp_inquiry(ipr_cmd, 0, 0, 5212 ipr_ioafp_inquiry(ipr_cmd, 0, 0,
4663 ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, ioa_vpd), 5213 ioa_cfg->vpd_cbs_dma + offsetof(struct ipr_misc_cbs, ioa_vpd),
@@ -4815,7 +5365,7 @@ static int ipr_reset_enable_ioa(struct ipr_cmnd *ipr_cmd)
4815 } 5365 }
4816 5366
4817 /* Enable destructive diagnostics on IOA */ 5367 /* Enable destructive diagnostics on IOA */
4818 writel(IPR_DOORBELL, ioa_cfg->regs.set_uproc_interrupt_reg); 5368 writel(ioa_cfg->doorbell, ioa_cfg->regs.set_uproc_interrupt_reg);
4819 5369
4820 writel(IPR_PCII_OPER_INTERRUPTS, ioa_cfg->regs.clr_interrupt_mask_reg); 5370 writel(IPR_PCII_OPER_INTERRUPTS, ioa_cfg->regs.clr_interrupt_mask_reg);
4821 int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg); 5371 int_reg = readl(ioa_cfg->regs.sense_interrupt_mask_reg);
@@ -5147,12 +5697,7 @@ static int ipr_reset_ucode_download(struct ipr_cmnd *ipr_cmd)
5147 ipr_cmd->ioarcb.cmd_pkt.cdb[7] = (sglist->buffer_len & 0x00ff00) >> 8; 5697 ipr_cmd->ioarcb.cmd_pkt.cdb[7] = (sglist->buffer_len & 0x00ff00) >> 8;
5148 ipr_cmd->ioarcb.cmd_pkt.cdb[8] = sglist->buffer_len & 0x0000ff; 5698 ipr_cmd->ioarcb.cmd_pkt.cdb[8] = sglist->buffer_len & 0x0000ff;
5149 5699
5150 if (ipr_map_ucode_buffer(ipr_cmd, sglist, sglist->buffer_len)) { 5700 ipr_build_ucode_ioadl(ipr_cmd, sglist);
5151 dev_err(&ioa_cfg->pdev->dev,
5152 "Failed to map microcode download buffer\n");
5153 return IPR_RC_JOB_CONTINUE;
5154 }
5155
5156 ipr_cmd->job_step = ipr_reset_ucode_download_done; 5701 ipr_cmd->job_step = ipr_reset_ucode_download_done;
5157 5702
5158 ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout, 5703 ipr_do_req(ipr_cmd, ipr_reset_ioa_job, ipr_timeout,
@@ -5217,7 +5762,6 @@ static int ipr_reset_shutdown_ioa(struct ipr_cmnd *ipr_cmd)
5217static void ipr_reset_ioa_job(struct ipr_cmnd *ipr_cmd) 5762static void ipr_reset_ioa_job(struct ipr_cmnd *ipr_cmd)
5218{ 5763{
5219 u32 rc, ioasc; 5764 u32 rc, ioasc;
5220 unsigned long scratch = ipr_cmd->u.scratch;
5221 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg; 5765 struct ipr_ioa_cfg *ioa_cfg = ipr_cmd->ioa_cfg;
5222 5766
5223 do { 5767 do {
@@ -5233,17 +5777,13 @@ static void ipr_reset_ioa_job(struct ipr_cmnd *ipr_cmd)
5233 } 5777 }
5234 5778
5235 if (IPR_IOASC_SENSE_KEY(ioasc)) { 5779 if (IPR_IOASC_SENSE_KEY(ioasc)) {
5236 dev_err(&ioa_cfg->pdev->dev, 5780 rc = ipr_cmd->job_step_failed(ipr_cmd);
5237 "0x%02X failed with IOASC: 0x%08X\n", 5781 if (rc == IPR_RC_JOB_RETURN)
5238 ipr_cmd->ioarcb.cmd_pkt.cdb[0], ioasc); 5782 return;
5239
5240 ipr_initiate_ioa_reset(ioa_cfg, IPR_SHUTDOWN_NONE);
5241 list_add_tail(&ipr_cmd->queue, &ioa_cfg->free_q);
5242 return;
5243 } 5783 }
5244 5784
5245 ipr_reinit_ipr_cmnd(ipr_cmd); 5785 ipr_reinit_ipr_cmnd(ipr_cmd);
5246 ipr_cmd->u.scratch = scratch; 5786 ipr_cmd->job_step_failed = ipr_reset_cmd_failed;
5247 rc = ipr_cmd->job_step(ipr_cmd); 5787 rc = ipr_cmd->job_step(ipr_cmd);
5248 } while(rc == IPR_RC_JOB_CONTINUE); 5788 } while(rc == IPR_RC_JOB_CONTINUE);
5249} 5789}
@@ -5517,15 +6057,12 @@ static int __devinit ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg)
5517 int i, rc = -ENOMEM; 6057 int i, rc = -ENOMEM;
5518 6058
5519 ENTER; 6059 ENTER;
5520 ioa_cfg->res_entries = kmalloc(sizeof(struct ipr_resource_entry) * 6060 ioa_cfg->res_entries = kzalloc(sizeof(struct ipr_resource_entry) *
5521 IPR_MAX_PHYSICAL_DEVS, GFP_KERNEL); 6061 IPR_MAX_PHYSICAL_DEVS, GFP_KERNEL);
5522 6062
5523 if (!ioa_cfg->res_entries) 6063 if (!ioa_cfg->res_entries)
5524 goto out; 6064 goto out;
5525 6065
5526 memset(ioa_cfg->res_entries, 0,
5527 sizeof(struct ipr_resource_entry) * IPR_MAX_PHYSICAL_DEVS);
5528
5529 for (i = 0; i < IPR_MAX_PHYSICAL_DEVS; i++) 6066 for (i = 0; i < IPR_MAX_PHYSICAL_DEVS; i++)
5530 list_add_tail(&ioa_cfg->res_entries[i].queue, &ioa_cfg->free_res_q); 6067 list_add_tail(&ioa_cfg->res_entries[i].queue, &ioa_cfg->free_res_q);
5531 6068
@@ -5566,15 +6103,12 @@ static int __devinit ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg)
5566 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q); 6103 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q);
5567 } 6104 }
5568 6105
5569 ioa_cfg->trace = kmalloc(sizeof(struct ipr_trace_entry) * 6106 ioa_cfg->trace = kzalloc(sizeof(struct ipr_trace_entry) *
5570 IPR_NUM_TRACE_ENTRIES, GFP_KERNEL); 6107 IPR_NUM_TRACE_ENTRIES, GFP_KERNEL);
5571 6108
5572 if (!ioa_cfg->trace) 6109 if (!ioa_cfg->trace)
5573 goto out_free_hostrcb_dma; 6110 goto out_free_hostrcb_dma;
5574 6111
5575 memset(ioa_cfg->trace, 0,
5576 sizeof(struct ipr_trace_entry) * IPR_NUM_TRACE_ENTRIES);
5577
5578 rc = 0; 6112 rc = 0;
5579out: 6113out:
5580 LEAVE; 6114 LEAVE;
@@ -5642,6 +6176,9 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
5642 ioa_cfg->host = host; 6176 ioa_cfg->host = host;
5643 ioa_cfg->pdev = pdev; 6177 ioa_cfg->pdev = pdev;
5644 ioa_cfg->log_level = ipr_log_level; 6178 ioa_cfg->log_level = ipr_log_level;
6179 ioa_cfg->doorbell = IPR_DOORBELL;
6180 if (!ipr_auto_create)
6181 ioa_cfg->doorbell |= IPR_RUNTIME_RESET;
5645 sprintf(ioa_cfg->eye_catcher, IPR_EYECATCHER); 6182 sprintf(ioa_cfg->eye_catcher, IPR_EYECATCHER);
5646 sprintf(ioa_cfg->trace_start, IPR_TRACE_START_LABEL); 6183 sprintf(ioa_cfg->trace_start, IPR_TRACE_START_LABEL);
5647 sprintf(ioa_cfg->ipr_free_label, IPR_FREEQ_LABEL); 6184 sprintf(ioa_cfg->ipr_free_label, IPR_FREEQ_LABEL);
@@ -5660,6 +6197,10 @@ static void __devinit ipr_init_ioa_cfg(struct ipr_ioa_cfg *ioa_cfg,
5660 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread, ioa_cfg); 6197 INIT_WORK(&ioa_cfg->work_q, ipr_worker_thread, ioa_cfg);
5661 init_waitqueue_head(&ioa_cfg->reset_wait_q); 6198 init_waitqueue_head(&ioa_cfg->reset_wait_q);
5662 ioa_cfg->sdt_state = INACTIVE; 6199 ioa_cfg->sdt_state = INACTIVE;
6200 if (ipr_enable_cache)
6201 ioa_cfg->cache_state = CACHE_ENABLED;
6202 else
6203 ioa_cfg->cache_state = CACHE_DISABLED;
5663 6204
5664 ipr_initialize_bus_attr(ioa_cfg); 6205 ipr_initialize_bus_attr(ioa_cfg);
5665 6206
@@ -6008,6 +6549,7 @@ static int __devinit ipr_probe(struct pci_dev *pdev,
6008 ipr_scan_vsets(ioa_cfg); 6549 ipr_scan_vsets(ioa_cfg);
6009 scsi_add_device(ioa_cfg->host, IPR_IOA_BUS, IPR_IOA_TARGET, IPR_IOA_LUN); 6550 scsi_add_device(ioa_cfg->host, IPR_IOA_BUS, IPR_IOA_TARGET, IPR_IOA_LUN);
6010 ioa_cfg->allow_ml_add_del = 1; 6551 ioa_cfg->allow_ml_add_del = 1;
6552 ioa_cfg->host->max_channel = IPR_VSET_BUS;
6011 schedule_work(&ioa_cfg->work_q); 6553 schedule_work(&ioa_cfg->work_q);
6012 return 0; 6554 return 0;
6013} 6555}
@@ -6055,12 +6597,30 @@ static struct pci_device_id ipr_pci_table[] __devinitdata = {
6055 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE, 6597 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE,
6056 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571A, 6598 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571A,
6057 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] }, 6599 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
6600 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_CITRINE,
6601 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_575B,
6602 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
6603 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
6604 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A,
6605 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
6606 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_OBSIDIAN,
6607 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
6608 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
6609 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
6610 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572A,
6611 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
6612 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN,
6613 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_572B,
6614 0, 0, (kernel_ulong_t)&ipr_chip_cfg[0] },
6058 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE, 6615 { PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_SNIPE,
6059 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780, 6616 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_2780,
6060 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 6617 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
6061 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP, 6618 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
6062 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571E, 6619 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571E,
6063 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] }, 6620 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
6621 { PCI_VENDOR_ID_ADAPTEC2, PCI_DEVICE_ID_ADAPTEC2_SCAMP,
6622 PCI_VENDOR_ID_IBM, IPR_SUBS_DEV_ID_571F,
6623 0, 0, (kernel_ulong_t)&ipr_chip_cfg[1] },
6064 { } 6624 { }
6065}; 6625};
6066MODULE_DEVICE_TABLE(pci, ipr_pci_table); 6626MODULE_DEVICE_TABLE(pci, ipr_pci_table);
diff --git a/drivers/scsi/ipr.h b/drivers/scsi/ipr.h
index 8cf967108500..6bec673c925c 100644
--- a/drivers/scsi/ipr.h
+++ b/drivers/scsi/ipr.h
@@ -36,23 +36,8 @@
36/* 36/*
37 * Literals 37 * Literals
38 */ 38 */
39#define IPR_DRIVER_VERSION "2.0.14" 39#define IPR_DRIVER_VERSION "2.1.0"
40#define IPR_DRIVER_DATE "(May 2, 2005)" 40#define IPR_DRIVER_DATE "(October 31, 2005)"
41
42/*
43 * IPR_DBG_TRACE: Setting this to 1 will turn on some general function tracing
44 * resulting in a bunch of extra debugging printks to the console
45 *
46 * IPR_DEBUG: Setting this to 1 will turn on some error path tracing.
47 * Enables the ipr_trace macro.
48 */
49#ifdef IPR_DEBUG_ALL
50#define IPR_DEBUG 1
51#define IPR_DBG_TRACE 1
52#else
53#define IPR_DEBUG 0
54#define IPR_DBG_TRACE 0
55#endif
56 41
57/* 42/*
58 * 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
@@ -76,6 +61,10 @@
76#define IPR_SUBS_DEV_ID_571A 0x02C0 61#define IPR_SUBS_DEV_ID_571A 0x02C0
77#define IPR_SUBS_DEV_ID_571B 0x02BE 62#define IPR_SUBS_DEV_ID_571B 0x02BE
78#define IPR_SUBS_DEV_ID_571E 0x02BF 63#define IPR_SUBS_DEV_ID_571E 0x02BF
64#define IPR_SUBS_DEV_ID_571F 0x02D5
65#define IPR_SUBS_DEV_ID_572A 0x02C1
66#define IPR_SUBS_DEV_ID_572B 0x02C2
67#define IPR_SUBS_DEV_ID_575B 0x030D
79 68
80#define IPR_NAME "ipr" 69#define IPR_NAME "ipr"
81 70
@@ -95,7 +84,10 @@
95#define IPR_IOASC_HW_DEV_BUS_STATUS 0x04448500 84#define IPR_IOASC_HW_DEV_BUS_STATUS 0x04448500
96#define IPR_IOASC_IOASC_MASK 0xFFFFFF00 85#define IPR_IOASC_IOASC_MASK 0xFFFFFF00
97#define IPR_IOASC_SCSI_STATUS_MASK 0x000000FF 86#define IPR_IOASC_SCSI_STATUS_MASK 0x000000FF
87#define IPR_IOASC_IR_INVALID_REQ_TYPE_OR_PKT 0x05240000
98#define IPR_IOASC_IR_RESOURCE_HANDLE 0x05250000 88#define IPR_IOASC_IR_RESOURCE_HANDLE 0x05250000
89#define IPR_IOASC_IR_NO_CMDS_TO_2ND_IOA 0x05258100
90#define IPR_IOASA_IR_DUAL_IOA_DISABLED 0x052C8000
99#define IPR_IOASC_BUS_WAS_RESET 0x06290000 91#define IPR_IOASC_BUS_WAS_RESET 0x06290000
100#define IPR_IOASC_BUS_WAS_RESET_BY_OTHER 0x06298000 92#define IPR_IOASC_BUS_WAS_RESET_BY_OTHER 0x06298000
101#define IPR_IOASC_ABORTED_CMD_TERM_BY_HOST 0x0B5A0000 93#define IPR_IOASC_ABORTED_CMD_TERM_BY_HOST 0x0B5A0000
@@ -107,14 +99,14 @@
107#define IPR_NUM_LOG_HCAMS 2 99#define IPR_NUM_LOG_HCAMS 2
108#define IPR_NUM_CFG_CHG_HCAMS 2 100#define IPR_NUM_CFG_CHG_HCAMS 2
109#define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS) 101#define IPR_NUM_HCAMS (IPR_NUM_LOG_HCAMS + IPR_NUM_CFG_CHG_HCAMS)
110#define IPR_MAX_NUM_TARGETS_PER_BUS 0x10 102#define IPR_MAX_NUM_TARGETS_PER_BUS 256
111#define IPR_MAX_NUM_LUNS_PER_TARGET 256 103#define IPR_MAX_NUM_LUNS_PER_TARGET 256
112#define IPR_MAX_NUM_VSET_LUNS_PER_TARGET 8 104#define IPR_MAX_NUM_VSET_LUNS_PER_TARGET 8
113#define IPR_VSET_BUS 0xff 105#define IPR_VSET_BUS 0xff
114#define IPR_IOA_BUS 0xff 106#define IPR_IOA_BUS 0xff
115#define IPR_IOA_TARGET 0xff 107#define IPR_IOA_TARGET 0xff
116#define IPR_IOA_LUN 0xff 108#define IPR_IOA_LUN 0xff
117#define IPR_MAX_NUM_BUSES 4 109#define IPR_MAX_NUM_BUSES 8
118#define IPR_MAX_BUS_TO_SCAN IPR_MAX_NUM_BUSES 110#define IPR_MAX_BUS_TO_SCAN IPR_MAX_NUM_BUSES
119 111
120#define IPR_NUM_RESET_RELOAD_RETRIES 3 112#define IPR_NUM_RESET_RELOAD_RETRIES 3
@@ -205,6 +197,7 @@
205#define IPR_SDT_FMT2_EXP_ROM_SEL 0x8 197#define IPR_SDT_FMT2_EXP_ROM_SEL 0x8
206#define IPR_FMT2_SDT_READY_TO_USE 0xC4D4E3F2 198#define IPR_FMT2_SDT_READY_TO_USE 0xC4D4E3F2
207#define IPR_DOORBELL 0x82800000 199#define IPR_DOORBELL 0x82800000
200#define IPR_RUNTIME_RESET 0x40000000
208 201
209#define IPR_PCII_IOA_TRANS_TO_OPER (0x80000000 >> 0) 202#define IPR_PCII_IOA_TRANS_TO_OPER (0x80000000 >> 0)
210#define IPR_PCII_IOARCB_XFER_FAILED (0x80000000 >> 3) 203#define IPR_PCII_IOARCB_XFER_FAILED (0x80000000 >> 3)
@@ -261,6 +254,16 @@ struct ipr_std_inq_vpids {
261 u8 product_id[IPR_PROD_ID_LEN]; 254 u8 product_id[IPR_PROD_ID_LEN];
262}__attribute__((packed)); 255}__attribute__((packed));
263 256
257struct ipr_vpd {
258 struct ipr_std_inq_vpids vpids;
259 u8 sn[IPR_SERIAL_NUM_LEN];
260}__attribute__((packed));
261
262struct ipr_ext_vpd {
263 struct ipr_vpd vpd;
264 __be32 wwid[2];
265}__attribute__((packed));
266
264struct ipr_std_inq_data { 267struct ipr_std_inq_data {
265 u8 peri_qual_dev_type; 268 u8 peri_qual_dev_type;
266#define IPR_STD_INQ_PERI_QUAL(peri) ((peri) >> 5) 269#define IPR_STD_INQ_PERI_QUAL(peri) ((peri) >> 5)
@@ -304,6 +307,10 @@ struct ipr_config_table_entry {
304#define IPR_SUBTYPE_GENERIC_SCSI 1 307#define IPR_SUBTYPE_GENERIC_SCSI 1
305#define IPR_SUBTYPE_VOLUME_SET 2 308#define IPR_SUBTYPE_VOLUME_SET 2
306 309
310#define IPR_QUEUEING_MODEL(res) ((((res)->cfgte.flags) & 0x70) >> 4)
311#define IPR_QUEUE_FROZEN_MODEL 0
312#define IPR_QUEUE_NACA_MODEL 1
313
307 struct ipr_res_addr res_addr; 314 struct ipr_res_addr res_addr;
308 __be32 res_handle; 315 __be32 res_handle;
309 __be32 reserved4[2]; 316 __be32 reserved4[2];
@@ -410,23 +417,26 @@ struct ipr_ioadl_desc {
410struct ipr_ioasa_vset { 417struct ipr_ioasa_vset {
411 __be32 failing_lba_hi; 418 __be32 failing_lba_hi;
412 __be32 failing_lba_lo; 419 __be32 failing_lba_lo;
413 __be32 ioa_data[22]; 420 __be32 reserved;
414}__attribute__((packed, aligned (4))); 421}__attribute__((packed, aligned (4)));
415 422
416struct ipr_ioasa_af_dasd { 423struct ipr_ioasa_af_dasd {
417 __be32 failing_lba; 424 __be32 failing_lba;
425 __be32 reserved[2];
418}__attribute__((packed, aligned (4))); 426}__attribute__((packed, aligned (4)));
419 427
420struct ipr_ioasa_gpdd { 428struct ipr_ioasa_gpdd {
421 u8 end_state; 429 u8 end_state;
422 u8 bus_phase; 430 u8 bus_phase;
423 __be16 reserved; 431 __be16 reserved;
424 __be32 ioa_data[23]; 432 __be32 ioa_data[2];
425}__attribute__((packed, aligned (4))); 433}__attribute__((packed, aligned (4)));
426 434
427struct ipr_ioasa_raw { 435struct ipr_auto_sense {
428 __be32 ioa_data[24]; 436 __be16 auto_sense_len;
429}__attribute__((packed, aligned (4))); 437 __be16 ioa_data_len;
438 __be32 data[SCSI_SENSE_BUFFERSIZE/sizeof(__be32)];
439};
430 440
431struct ipr_ioasa { 441struct ipr_ioasa {
432 __be32 ioasc; 442 __be32 ioasc;
@@ -453,6 +463,8 @@ struct ipr_ioasa {
453 __be32 fd_res_handle; 463 __be32 fd_res_handle;
454 464
455 __be32 ioasc_specific; /* status code specific field */ 465 __be32 ioasc_specific; /* status code specific field */
466#define IPR_ADDITIONAL_STATUS_FMT 0x80000000
467#define IPR_AUTOSENSE_VALID 0x40000000
456#define IPR_IOASC_SPECIFIC_MASK 0x00ffffff 468#define IPR_IOASC_SPECIFIC_MASK 0x00ffffff
457#define IPR_FIELD_POINTER_VALID (0x80000000 >> 8) 469#define IPR_FIELD_POINTER_VALID (0x80000000 >> 8)
458#define IPR_FIELD_POINTER_MASK 0x0000ffff 470#define IPR_FIELD_POINTER_MASK 0x0000ffff
@@ -461,8 +473,9 @@ struct ipr_ioasa {
461 struct ipr_ioasa_vset vset; 473 struct ipr_ioasa_vset vset;
462 struct ipr_ioasa_af_dasd dasd; 474 struct ipr_ioasa_af_dasd dasd;
463 struct ipr_ioasa_gpdd gpdd; 475 struct ipr_ioasa_gpdd gpdd;
464 struct ipr_ioasa_raw raw;
465 } u; 476 } u;
477
478 struct ipr_auto_sense auto_sense;
466}__attribute__((packed, aligned (4))); 479}__attribute__((packed, aligned (4)));
467 480
468struct ipr_mode_parm_hdr { 481struct ipr_mode_parm_hdr {
@@ -536,28 +549,49 @@ struct ipr_inquiry_page3 {
536 u8 patch_number[4]; 549 u8 patch_number[4];
537}__attribute__((packed)); 550}__attribute__((packed));
538 551
552#define IPR_INQUIRY_PAGE0_ENTRIES 20
553struct ipr_inquiry_page0 {
554 u8 peri_qual_dev_type;
555 u8 page_code;
556 u8 reserved1;
557 u8 len;
558 u8 page[IPR_INQUIRY_PAGE0_ENTRIES];
559}__attribute__((packed));
560
539struct ipr_hostrcb_device_data_entry { 561struct ipr_hostrcb_device_data_entry {
540 struct ipr_std_inq_vpids dev_vpids; 562 struct ipr_vpd vpd;
541 u8 dev_sn[IPR_SERIAL_NUM_LEN];
542 struct ipr_res_addr dev_res_addr; 563 struct ipr_res_addr dev_res_addr;
543 struct ipr_std_inq_vpids new_dev_vpids; 564 struct ipr_vpd new_vpd;
544 u8 new_dev_sn[IPR_SERIAL_NUM_LEN]; 565 struct ipr_vpd ioa_last_with_dev_vpd;
545 struct ipr_std_inq_vpids ioa_last_with_dev_vpids; 566 struct ipr_vpd cfc_last_with_dev_vpd;
546 u8 ioa_last_with_dev_sn[IPR_SERIAL_NUM_LEN];
547 struct ipr_std_inq_vpids cfc_last_with_dev_vpids;
548 u8 cfc_last_with_dev_sn[IPR_SERIAL_NUM_LEN];
549 __be32 ioa_data[5]; 567 __be32 ioa_data[5];
550}__attribute__((packed, aligned (4))); 568}__attribute__((packed, aligned (4)));
551 569
570struct ipr_hostrcb_device_data_entry_enhanced {
571 struct ipr_ext_vpd vpd;
572 u8 ccin[4];
573 struct ipr_res_addr dev_res_addr;
574 struct ipr_ext_vpd new_vpd;
575 u8 new_ccin[4];
576 struct ipr_ext_vpd ioa_last_with_dev_vpd;
577 struct ipr_ext_vpd cfc_last_with_dev_vpd;
578}__attribute__((packed, aligned (4)));
579
552struct ipr_hostrcb_array_data_entry { 580struct ipr_hostrcb_array_data_entry {
553 struct ipr_std_inq_vpids vpids; 581 struct ipr_vpd vpd;
554 u8 serial_num[IPR_SERIAL_NUM_LEN]; 582 struct ipr_res_addr expected_dev_res_addr;
583 struct ipr_res_addr dev_res_addr;
584}__attribute__((packed, aligned (4)));
585
586struct ipr_hostrcb_array_data_entry_enhanced {
587 struct ipr_ext_vpd vpd;
588 u8 ccin[4];
555 struct ipr_res_addr expected_dev_res_addr; 589 struct ipr_res_addr expected_dev_res_addr;
556 struct ipr_res_addr dev_res_addr; 590 struct ipr_res_addr dev_res_addr;
557}__attribute__((packed, aligned (4))); 591}__attribute__((packed, aligned (4)));
558 592
559struct ipr_hostrcb_type_ff_error { 593struct ipr_hostrcb_type_ff_error {
560 __be32 ioa_data[246]; 594 __be32 ioa_data[502];
561}__attribute__((packed, aligned (4))); 595}__attribute__((packed, aligned (4)));
562 596
563struct ipr_hostrcb_type_01_error { 597struct ipr_hostrcb_type_01_error {
@@ -568,47 +602,75 @@ struct ipr_hostrcb_type_01_error {
568}__attribute__((packed, aligned (4))); 602}__attribute__((packed, aligned (4)));
569 603
570struct ipr_hostrcb_type_02_error { 604struct ipr_hostrcb_type_02_error {
571 struct ipr_std_inq_vpids ioa_vpids; 605 struct ipr_vpd ioa_vpd;
572 u8 ioa_sn[IPR_SERIAL_NUM_LEN]; 606 struct ipr_vpd cfc_vpd;
573 struct ipr_std_inq_vpids cfc_vpids; 607 struct ipr_vpd ioa_last_attached_to_cfc_vpd;
574 u8 cfc_sn[IPR_SERIAL_NUM_LEN]; 608 struct ipr_vpd cfc_last_attached_to_ioa_vpd;
575 struct ipr_std_inq_vpids ioa_last_attached_to_cfc_vpids; 609 __be32 ioa_data[3];
576 u8 ioa_last_attached_to_cfc_sn[IPR_SERIAL_NUM_LEN]; 610}__attribute__((packed, aligned (4)));
577 struct ipr_std_inq_vpids cfc_last_attached_to_ioa_vpids; 611
578 u8 cfc_last_attached_to_ioa_sn[IPR_SERIAL_NUM_LEN]; 612struct ipr_hostrcb_type_12_error {
613 struct ipr_ext_vpd ioa_vpd;
614 struct ipr_ext_vpd cfc_vpd;
615 struct ipr_ext_vpd ioa_last_attached_to_cfc_vpd;
616 struct ipr_ext_vpd cfc_last_attached_to_ioa_vpd;
579 __be32 ioa_data[3]; 617 __be32 ioa_data[3];
580 u8 reserved[844];
581}__attribute__((packed, aligned (4))); 618}__attribute__((packed, aligned (4)));
582 619
583struct ipr_hostrcb_type_03_error { 620struct ipr_hostrcb_type_03_error {
584 struct ipr_std_inq_vpids ioa_vpids; 621 struct ipr_vpd ioa_vpd;
585 u8 ioa_sn[IPR_SERIAL_NUM_LEN]; 622 struct ipr_vpd cfc_vpd;
586 struct ipr_std_inq_vpids cfc_vpids;
587 u8 cfc_sn[IPR_SERIAL_NUM_LEN];
588 __be32 errors_detected; 623 __be32 errors_detected;
589 __be32 errors_logged; 624 __be32 errors_logged;
590 u8 ioa_data[12]; 625 u8 ioa_data[12];
591 struct ipr_hostrcb_device_data_entry dev_entry[3]; 626 struct ipr_hostrcb_device_data_entry dev[3];
592 u8 reserved[444]; 627}__attribute__((packed, aligned (4)));
628
629struct ipr_hostrcb_type_13_error {
630 struct ipr_ext_vpd ioa_vpd;
631 struct ipr_ext_vpd cfc_vpd;
632 __be32 errors_detected;
633 __be32 errors_logged;
634 struct ipr_hostrcb_device_data_entry_enhanced dev[3];
593}__attribute__((packed, aligned (4))); 635}__attribute__((packed, aligned (4)));
594 636
595struct ipr_hostrcb_type_04_error { 637struct ipr_hostrcb_type_04_error {
596 struct ipr_std_inq_vpids ioa_vpids; 638 struct ipr_vpd ioa_vpd;
597 u8 ioa_sn[IPR_SERIAL_NUM_LEN]; 639 struct ipr_vpd cfc_vpd;
598 struct ipr_std_inq_vpids cfc_vpids;
599 u8 cfc_sn[IPR_SERIAL_NUM_LEN];
600 u8 ioa_data[12]; 640 u8 ioa_data[12];
601 struct ipr_hostrcb_array_data_entry array_member[10]; 641 struct ipr_hostrcb_array_data_entry array_member[10];
602 __be32 exposed_mode_adn; 642 __be32 exposed_mode_adn;
603 __be32 array_id; 643 __be32 array_id;
604 struct ipr_std_inq_vpids incomp_dev_vpids; 644 struct ipr_vpd incomp_dev_vpd;
605 u8 incomp_dev_sn[IPR_SERIAL_NUM_LEN];
606 __be32 ioa_data2; 645 __be32 ioa_data2;
607 struct ipr_hostrcb_array_data_entry array_member2[8]; 646 struct ipr_hostrcb_array_data_entry array_member2[8];
608 struct ipr_res_addr last_func_vset_res_addr; 647 struct ipr_res_addr last_func_vset_res_addr;
609 u8 vset_serial_num[IPR_SERIAL_NUM_LEN]; 648 u8 vset_serial_num[IPR_SERIAL_NUM_LEN];
610 u8 protection_level[8]; 649 u8 protection_level[8];
611 u8 reserved[124]; 650}__attribute__((packed, aligned (4)));
651
652struct ipr_hostrcb_type_14_error {
653 struct ipr_ext_vpd ioa_vpd;
654 struct ipr_ext_vpd cfc_vpd;
655 __be32 exposed_mode_adn;
656 __be32 array_id;
657 struct ipr_res_addr last_func_vset_res_addr;
658 u8 vset_serial_num[IPR_SERIAL_NUM_LEN];
659 u8 protection_level[8];
660 __be32 num_entries;
661 struct ipr_hostrcb_array_data_entry_enhanced array_member[18];
662}__attribute__((packed, aligned (4)));
663
664struct ipr_hostrcb_type_07_error {
665 u8 failure_reason[64];
666 struct ipr_vpd vpd;
667 u32 data[222];
668}__attribute__((packed, aligned (4)));
669
670struct ipr_hostrcb_type_17_error {
671 u8 failure_reason[64];
672 struct ipr_ext_vpd vpd;
673 u32 data[476];
612}__attribute__((packed, aligned (4))); 674}__attribute__((packed, aligned (4)));
613 675
614struct ipr_hostrcb_error { 676struct ipr_hostrcb_error {
@@ -622,6 +684,11 @@ struct ipr_hostrcb_error {
622 struct ipr_hostrcb_type_02_error type_02_error; 684 struct ipr_hostrcb_type_02_error type_02_error;
623 struct ipr_hostrcb_type_03_error type_03_error; 685 struct ipr_hostrcb_type_03_error type_03_error;
624 struct ipr_hostrcb_type_04_error type_04_error; 686 struct ipr_hostrcb_type_04_error type_04_error;
687 struct ipr_hostrcb_type_07_error type_07_error;
688 struct ipr_hostrcb_type_12_error type_12_error;
689 struct ipr_hostrcb_type_13_error type_13_error;
690 struct ipr_hostrcb_type_14_error type_14_error;
691 struct ipr_hostrcb_type_17_error type_17_error;
625 } u; 692 } u;
626}__attribute__((packed, aligned (4))); 693}__attribute__((packed, aligned (4)));
627 694
@@ -655,6 +722,12 @@ struct ipr_hcam {
655#define IPR_HOST_RCB_OVERLAY_ID_3 0x03 722#define IPR_HOST_RCB_OVERLAY_ID_3 0x03
656#define IPR_HOST_RCB_OVERLAY_ID_4 0x04 723#define IPR_HOST_RCB_OVERLAY_ID_4 0x04
657#define IPR_HOST_RCB_OVERLAY_ID_6 0x06 724#define IPR_HOST_RCB_OVERLAY_ID_6 0x06
725#define IPR_HOST_RCB_OVERLAY_ID_7 0x07
726#define IPR_HOST_RCB_OVERLAY_ID_12 0x12
727#define IPR_HOST_RCB_OVERLAY_ID_13 0x13
728#define IPR_HOST_RCB_OVERLAY_ID_14 0x14
729#define IPR_HOST_RCB_OVERLAY_ID_16 0x16
730#define IPR_HOST_RCB_OVERLAY_ID_17 0x17
658#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF 731#define IPR_HOST_RCB_OVERLAY_ID_DEFAULT 0xFF
659 732
660 u8 reserved1[3]; 733 u8 reserved1[3];
@@ -743,6 +816,7 @@ struct ipr_resource_table {
743 816
744struct ipr_misc_cbs { 817struct ipr_misc_cbs {
745 struct ipr_ioa_vpd ioa_vpd; 818 struct ipr_ioa_vpd ioa_vpd;
819 struct ipr_inquiry_page0 page0_data;
746 struct ipr_inquiry_page3 page3_data; 820 struct ipr_inquiry_page3 page3_data;
747 struct ipr_mode_pages mode_pages; 821 struct ipr_mode_pages mode_pages;
748 struct ipr_supported_device supp_dev; 822 struct ipr_supported_device supp_dev;
@@ -813,6 +887,7 @@ struct ipr_trace_entry {
813struct ipr_sglist { 887struct ipr_sglist {
814 u32 order; 888 u32 order;
815 u32 num_sg; 889 u32 num_sg;
890 u32 num_dma_sg;
816 u32 buffer_len; 891 u32 buffer_len;
817 struct scatterlist scatterlist[1]; 892 struct scatterlist scatterlist[1];
818}; 893};
@@ -825,6 +900,13 @@ enum ipr_sdt_state {
825 DUMP_OBTAINED 900 DUMP_OBTAINED
826}; 901};
827 902
903enum ipr_cache_state {
904 CACHE_NONE,
905 CACHE_DISABLED,
906 CACHE_ENABLED,
907 CACHE_INVALID
908};
909
828/* Per-controller data */ 910/* Per-controller data */
829struct ipr_ioa_cfg { 911struct ipr_ioa_cfg {
830 char eye_catcher[8]; 912 char eye_catcher[8];
@@ -841,6 +923,7 @@ struct ipr_ioa_cfg {
841 u8 allow_cmds:1; 923 u8 allow_cmds:1;
842 u8 allow_ml_add_del:1; 924 u8 allow_ml_add_del:1;
843 925
926 enum ipr_cache_state cache_state;
844 u16 type; /* CCIN of the card */ 927 u16 type; /* CCIN of the card */
845 928
846 u8 log_level; 929 u8 log_level;
@@ -911,6 +994,7 @@ struct ipr_ioa_cfg {
911 u16 reset_retries; 994 u16 reset_retries;
912 995
913 u32 errors_logged; 996 u32 errors_logged;
997 u32 doorbell;
914 998
915 struct Scsi_Host *host; 999 struct Scsi_Host *host;
916 struct pci_dev *pdev; 1000 struct pci_dev *pdev;
@@ -948,6 +1032,7 @@ struct ipr_cmnd {
948 struct timer_list timer; 1032 struct timer_list timer;
949 void (*done) (struct ipr_cmnd *); 1033 void (*done) (struct ipr_cmnd *);
950 int (*job_step) (struct ipr_cmnd *); 1034 int (*job_step) (struct ipr_cmnd *);
1035 int (*job_step_failed) (struct ipr_cmnd *);
951 u16 cmd_index; 1036 u16 cmd_index;
952 u8 sense_buffer[SCSI_SENSE_BUFFERSIZE]; 1037 u8 sense_buffer[SCSI_SENSE_BUFFERSIZE];
953 dma_addr_t sense_buffer_dma; 1038 dma_addr_t sense_buffer_dma;
@@ -1083,11 +1168,7 @@ struct ipr_ucode_image_header {
1083/* 1168/*
1084 * Macros 1169 * Macros
1085 */ 1170 */
1086#if IPR_DEBUG 1171#define IPR_DBG_CMD(CMD) if (ipr_debug) { CMD; }
1087#define IPR_DBG_CMD(CMD) do { CMD; } while (0)
1088#else
1089#define IPR_DBG_CMD(CMD)
1090#endif
1091 1172
1092#ifdef CONFIG_SCSI_IPR_TRACE 1173#ifdef CONFIG_SCSI_IPR_TRACE
1093#define ipr_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr) 1174#define ipr_create_trace_file(kobj, attr) sysfs_create_bin_file(kobj, attr)
@@ -1135,16 +1216,22 @@ struct ipr_ucode_image_header {
1135#define ipr_res_dbg(ioa_cfg, res, fmt, ...) \ 1216#define ipr_res_dbg(ioa_cfg, res, fmt, ...) \
1136 IPR_DBG_CMD(ipr_res_printk(KERN_INFO, ioa_cfg, res, fmt, ##__VA_ARGS__)) 1217 IPR_DBG_CMD(ipr_res_printk(KERN_INFO, ioa_cfg, res, fmt, ##__VA_ARGS__))
1137 1218
1219#define ipr_phys_res_err(ioa_cfg, res, fmt, ...) \
1220{ \
1221 if ((res).bus >= IPR_MAX_NUM_BUSES) { \
1222 ipr_err(fmt": unknown\n", ##__VA_ARGS__); \
1223 } else { \
1224 ipr_err(fmt": %d:%d:%d:%d\n", \
1225 ##__VA_ARGS__, (ioa_cfg)->host->host_no, \
1226 (res).bus, (res).target, (res).lun); \
1227 } \
1228}
1229
1138#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\ 1230#define ipr_trace ipr_dbg("%s: %s: Line: %d\n",\
1139 __FILE__, __FUNCTION__, __LINE__) 1231 __FILE__, __FUNCTION__, __LINE__)
1140 1232
1141#if IPR_DBG_TRACE 1233#define ENTER IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Entering %s\n", __FUNCTION__))
1142#define ENTER printk(KERN_INFO IPR_NAME": Entering %s\n", __FUNCTION__) 1234#define LEAVE IPR_DBG_CMD(printk(KERN_INFO IPR_NAME": Leaving %s\n", __FUNCTION__))
1143#define LEAVE printk(KERN_INFO IPR_NAME": Leaving %s\n", __FUNCTION__)
1144#else
1145#define ENTER
1146#define LEAVE
1147#endif
1148 1235
1149#define ipr_err_separator \ 1236#define ipr_err_separator \
1150ipr_err("----------------------------------------------------------\n") 1237ipr_err("----------------------------------------------------------\n")
@@ -1217,6 +1304,20 @@ static inline int ipr_is_gscsi(struct ipr_resource_entry *res)
1217} 1304}
1218 1305
1219/** 1306/**
1307 * ipr_is_naca_model - Determine if a resource is using NACA queueing model
1308 * @res: resource entry struct
1309 *
1310 * Return value:
1311 * 1 if NACA queueing model / 0 if not NACA queueing model
1312 **/
1313static inline int ipr_is_naca_model(struct ipr_resource_entry *res)
1314{
1315 if (ipr_is_gscsi(res) && IPR_QUEUEING_MODEL(res) == IPR_QUEUE_NACA_MODEL)
1316 return 1;
1317 return 0;
1318}
1319
1320/**
1220 * ipr_is_device - Determine if resource address is that of a device 1321 * ipr_is_device - Determine if resource address is that of a device
1221 * @res_addr: resource address struct 1322 * @res_addr: resource address struct
1222 * 1323 *
@@ -1226,7 +1327,7 @@ static inline int ipr_is_gscsi(struct ipr_resource_entry *res)
1226static inline int ipr_is_device(struct ipr_res_addr *res_addr) 1327static inline int ipr_is_device(struct ipr_res_addr *res_addr)
1227{ 1328{
1228 if ((res_addr->bus < IPR_MAX_NUM_BUSES) && 1329 if ((res_addr->bus < IPR_MAX_NUM_BUSES) &&
1229 (res_addr->target < IPR_MAX_NUM_TARGETS_PER_BUS)) 1330 (res_addr->target < (IPR_MAX_NUM_TARGETS_PER_BUS - 1)))
1230 return 1; 1331 return 1;
1231 1332
1232 return 0; 1333 return 0;
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index cd9b95db5a7d..3882d48a42bf 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -139,6 +139,7 @@
139/* - Remove 3 unused "inline" functions */ 139/* - Remove 3 unused "inline" functions */
140/* 7.12.xx - Use STATIC functions whereever possible */ 140/* 7.12.xx - Use STATIC functions whereever possible */
141/* - Clean up deprecated MODULE_PARM calls */ 141/* - Clean up deprecated MODULE_PARM calls */
142/* 7.12.05 - Remove Version Matching per IBM request */
142/*****************************************************************************/ 143/*****************************************************************************/
143 144
144/* 145/*
@@ -210,7 +211,7 @@ module_param(ips, charp, 0);
210 * DRIVER_VER 211 * DRIVER_VER
211 */ 212 */
212#define IPS_VERSION_HIGH "7.12" 213#define IPS_VERSION_HIGH "7.12"
213#define IPS_VERSION_LOW ".02 " 214#define IPS_VERSION_LOW ".05 "
214 215
215#if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__) 216#if !defined(__i386__) && !defined(__ia64__) && !defined(__x86_64__)
216#warning "This driver has only been tested on the x86/ia64/x86_64 platforms" 217#warning "This driver has only been tested on the x86/ia64/x86_64 platforms"
@@ -247,7 +248,7 @@ module_param(ips, charp, 0);
247/* 248/*
248 * Function prototypes 249 * Function prototypes
249 */ 250 */
250static int ips_detect(Scsi_Host_Template *); 251static int ips_detect(struct scsi_host_template *);
251static int ips_release(struct Scsi_Host *); 252static int ips_release(struct Scsi_Host *);
252static int ips_eh_abort(Scsi_Cmnd *); 253static int ips_eh_abort(Scsi_Cmnd *);
253static int ips_eh_reset(Scsi_Cmnd *); 254static int ips_eh_reset(Scsi_Cmnd *);
@@ -347,8 +348,6 @@ static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
347static int ips_host_info(ips_ha_t *, char *, off_t, int); 348static int ips_host_info(ips_ha_t *, char *, off_t, int);
348static void copy_mem_info(IPS_INFOSTR *, char *, int); 349static void copy_mem_info(IPS_INFOSTR *, char *, int);
349static int copy_info(IPS_INFOSTR *, char *, ...); 350static int copy_info(IPS_INFOSTR *, char *, ...);
350static int ips_get_version_info(ips_ha_t * ha, dma_addr_t, int intr);
351static void ips_version_check(ips_ha_t * ha, int intr);
352static int ips_abort_init(ips_ha_t * ha, int index); 351static int ips_abort_init(ips_ha_t * ha, int index);
353static int ips_init_phase2(int index); 352static int ips_init_phase2(int index);
354 353
@@ -378,7 +377,7 @@ static char *ips_FlashData = NULL; /* CD Boot - Flash Data Buffer */
378static dma_addr_t ips_flashbusaddr; 377static dma_addr_t ips_flashbusaddr;
379static long ips_FlashDataInUse; /* CD Boot - Flash Data In Use Flag */ 378static long ips_FlashDataInUse; /* CD Boot - Flash Data In Use Flag */
380static uint32_t MaxLiteCmds = 32; /* Max Active Cmds for a Lite Adapter */ 379static uint32_t MaxLiteCmds = 32; /* Max Active Cmds for a Lite Adapter */
381static Scsi_Host_Template ips_driver_template = { 380static struct scsi_host_template ips_driver_template = {
382 .detect = ips_detect, 381 .detect = ips_detect,
383 .release = ips_release, 382 .release = ips_release,
384 .info = ips_info, 383 .info = ips_info,
@@ -406,8 +405,6 @@ static Scsi_Host_Template ips_driver_template = {
406#endif 405#endif
407}; 406};
408 407
409static IPS_DEFINE_COMPAT_TABLE( Compatable ); /* Version Compatability Table */
410
411 408
412/* This table describes all ServeRAID Adapters */ 409/* This table describes all ServeRAID Adapters */
413static struct pci_device_id ips_pci_table[] = { 410static struct pci_device_id ips_pci_table[] = {
@@ -590,7 +587,7 @@ __setup("ips=", ips_setup);
590/* */ 587/* */
591/****************************************************************************/ 588/****************************************************************************/
592static int 589static int
593ips_detect(Scsi_Host_Template * SHT) 590ips_detect(struct scsi_host_template * SHT)
594{ 591{
595 int i; 592 int i;
596 593
@@ -1265,9 +1262,9 @@ ips_proc24_info(char *buffer, char **start, off_t offset, int length,
1265/* */ 1262/* */
1266/****************************************************************************/ 1263/****************************************************************************/
1267static void 1264static void
1268ips_select_queue_depth(struct Scsi_Host *host, Scsi_Device * scsi_devs) 1265ips_select_queue_depth(struct Scsi_Host *host, struct scsi_device * scsi_devs)
1269{ 1266{
1270 Scsi_Device *device; 1267 struct scsi_device *device;
1271 ips_ha_t *ha; 1268 ips_ha_t *ha;
1272 int count = 0; 1269 int count = 0;
1273 int min; 1270 int min;
@@ -1310,7 +1307,7 @@ ips_select_queue_depth(struct Scsi_Host *host, Scsi_Device * scsi_devs)
1310/* */ 1307/* */
1311/****************************************************************************/ 1308/****************************************************************************/
1312static int 1309static int
1313ips_slave_configure(Scsi_Device * SDptr) 1310ips_slave_configure(struct scsi_device * SDptr)
1314{ 1311{
1315 ips_ha_t *ha; 1312 ips_ha_t *ha;
1316 int min; 1313 int min;
@@ -5930,7 +5927,7 @@ ips_write_driver_status(ips_ha_t * ha, int intr)
5930 strncpy((char *) ha->nvram->bios_high, ha->bios_version, 4); 5927 strncpy((char *) ha->nvram->bios_high, ha->bios_version, 4);
5931 strncpy((char *) ha->nvram->bios_low, ha->bios_version + 4, 4); 5928 strncpy((char *) ha->nvram->bios_low, ha->bios_version + 4, 4);
5932 5929
5933 ips_version_check(ha, intr); /* Check BIOS/FW/Driver Versions */ 5930 ha->nvram->versioning = 0; /* Indicate the Driver Does Not Support Versioning */
5934 5931
5935 /* now update the page */ 5932 /* now update the page */
5936 if (!ips_readwrite_page5(ha, TRUE, intr)) { 5933 if (!ips_readwrite_page5(ha, TRUE, intr)) {
@@ -6847,135 +6844,6 @@ ips_verify_bios_memio(ips_ha_t * ha, char *buffer, uint32_t buffersize,
6847 return (0); 6844 return (0);
6848} 6845}
6849 6846
6850/*---------------------------------------------------------------------------*/
6851/* Routine Name: ips_version_check */
6852/* */
6853/* Dependencies: */
6854/* Assumes that ips_read_adapter_status() is called first filling in */
6855/* the data for SubSystem Parameters. */
6856/* Called from ips_write_driver_status() so it also assumes NVRAM Page 5 */
6857/* Data is available. */
6858/* */
6859/*---------------------------------------------------------------------------*/
6860static void
6861ips_version_check(ips_ha_t * ha, int intr)
6862{
6863 IPS_VERSION_DATA *VersionInfo;
6864 uint8_t FirmwareVersion[IPS_COMPAT_ID_LENGTH + 1];
6865 uint8_t BiosVersion[IPS_COMPAT_ID_LENGTH + 1];
6866 int MatchError;
6867 int rc;
6868 char BiosString[10];
6869 char FirmwareString[10];
6870
6871 METHOD_TRACE("ips_version_check", 1);
6872
6873 VersionInfo = ( IPS_VERSION_DATA * ) ha->ioctl_data;
6874
6875 memset(FirmwareVersion, 0, IPS_COMPAT_ID_LENGTH + 1);
6876 memset(BiosVersion, 0, IPS_COMPAT_ID_LENGTH + 1);
6877
6878 /* Get the Compatible BIOS Version from NVRAM Page 5 */
6879 memcpy(BiosVersion, ha->nvram->BiosCompatibilityID,
6880 IPS_COMPAT_ID_LENGTH);
6881
6882 rc = IPS_FAILURE;
6883 if (ha->subsys->param[4] & IPS_GET_VERSION_SUPPORT) { /* If Versioning is Supported */
6884 /* Get the Version Info with a Get Version Command */
6885 memset( VersionInfo, 0, sizeof (IPS_VERSION_DATA));
6886 rc = ips_get_version_info(ha, ha->ioctl_busaddr, intr);
6887 if (rc == IPS_SUCCESS)
6888 memcpy(FirmwareVersion, VersionInfo->compatibilityId,
6889 IPS_COMPAT_ID_LENGTH);
6890 }
6891
6892 if (rc != IPS_SUCCESS) { /* If Data Not Obtainable from a GetVersion Command */
6893 /* Get the Firmware Version from Enquiry Data */
6894 memcpy(FirmwareVersion, ha->enq->CodeBlkVersion,
6895 IPS_COMPAT_ID_LENGTH);
6896 }
6897
6898 /* printk(KERN_WARNING "Adapter's BIOS Version = %s\n", BiosVersion); */
6899 /* printk(KERN_WARNING "BIOS Compatible Version = %s\n", IPS_COMPAT_BIOS); */
6900 /* printk(KERN_WARNING "Adapter's Firmware Version = %s\n", FirmwareVersion); */
6901 /* printk(KERN_WARNING "Firmware Compatible Version = %s \n", Compatable[ ha->nvram->adapter_type ]); */
6902
6903 MatchError = 0;
6904
6905 if (strncmp
6906 (FirmwareVersion, Compatable[ha->nvram->adapter_type],
6907 IPS_COMPAT_ID_LENGTH) != 0)
6908 MatchError = 1;
6909
6910 if (strncmp(BiosVersion, IPS_COMPAT_BIOS, IPS_COMPAT_ID_LENGTH) != 0)
6911 MatchError = 1;
6912
6913 ha->nvram->versioning = 1; /* Indicate the Driver Supports Versioning */
6914
6915 if (MatchError) {
6916 ha->nvram->version_mismatch = 1;
6917 if (ips_cd_boot == 0) {
6918 strncpy(&BiosString[0], ha->nvram->bios_high, 4);
6919 strncpy(&BiosString[4], ha->nvram->bios_low, 4);
6920 BiosString[8] = 0;
6921
6922 strncpy(&FirmwareString[0], ha->enq->CodeBlkVersion, 8);
6923 FirmwareString[8] = 0;
6924
6925 IPS_PRINTK(KERN_WARNING, ha->pcidev,
6926 "Warning ! ! ! ServeRAID Version Mismatch\n");
6927 IPS_PRINTK(KERN_WARNING, ha->pcidev,
6928 "Bios = %s, Firmware = %s, Device Driver = %s%s\n",
6929 BiosString, FirmwareString, IPS_VERSION_HIGH,
6930 IPS_VERSION_LOW);
6931 IPS_PRINTK(KERN_WARNING, ha->pcidev,
6932 "These levels should match to avoid possible compatibility problems.\n");
6933 }
6934 } else {
6935 ha->nvram->version_mismatch = 0;
6936 }
6937
6938 return;
6939}
6940
6941/*---------------------------------------------------------------------------*/
6942/* Routine Name: ips_get_version_info */
6943/* */
6944/* Routine Description: */
6945/* Issue an internal GETVERSION Command */
6946/* */
6947/* Return Value: */
6948/* 0 if Successful, else non-zero */
6949/*---------------------------------------------------------------------------*/
6950static int
6951ips_get_version_info(ips_ha_t * ha, dma_addr_t Buffer, int intr)
6952{
6953 ips_scb_t *scb;
6954 int rc;
6955
6956 METHOD_TRACE("ips_get_version_info", 1);
6957
6958 scb = &ha->scbs[ha->max_cmds - 1];
6959
6960 ips_init_scb(ha, scb);
6961
6962 scb->timeout = ips_cmd_timeout;
6963 scb->cdb[0] = IPS_CMD_GET_VERSION_INFO;
6964 scb->cmd.version_info.op_code = IPS_CMD_GET_VERSION_INFO;
6965 scb->cmd.version_info.command_id = IPS_COMMAND_ID(ha, scb);
6966 scb->cmd.version_info.reserved = 0;
6967 scb->cmd.version_info.count = sizeof (IPS_VERSION_DATA);
6968 scb->cmd.version_info.reserved2 = 0;
6969 scb->data_len = sizeof (IPS_VERSION_DATA);
6970 scb->data_busaddr = Buffer;
6971 scb->cmd.version_info.buffer_addr = Buffer;
6972 scb->flags = 0;
6973
6974 /* issue command */
6975 rc = ips_send_wait(ha, scb, ips_cmd_timeout, intr);
6976 return (rc);
6977}
6978
6979/****************************************************************************/ 6847/****************************************************************************/
6980/* */ 6848/* */
6981/* Routine Name: ips_abort_init */ 6849/* Routine Name: ips_abort_init */
diff --git a/drivers/scsi/ips.h b/drivers/scsi/ips.h
index adc6eabbf610..f46c382e5599 100644
--- a/drivers/scsi/ips.h
+++ b/drivers/scsi/ips.h
@@ -450,13 +450,13 @@
450 */ 450 */
451#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) 451#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
452 static int ips_proc24_info(char *, char **, off_t, int, int, int); 452 static int ips_proc24_info(char *, char **, off_t, int, int, int);
453 static void ips_select_queue_depth(struct Scsi_Host *, Scsi_Device *); 453 static void ips_select_queue_depth(struct Scsi_Host *, struct scsi_device *);
454 static int ips_biosparam(Disk *disk, kdev_t dev, int geom[]); 454 static int ips_biosparam(Disk *disk, kdev_t dev, int geom[]);
455#else 455#else
456 static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int); 456 static int ips_proc_info(struct Scsi_Host *, char *, char **, off_t, int, int);
457 static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev, 457 static int ips_biosparam(struct scsi_device *sdev, struct block_device *bdev,
458 sector_t capacity, int geom[]); 458 sector_t capacity, int geom[]);
459 static int ips_slave_configure(Scsi_Device *SDptr); 459 static int ips_slave_configure(struct scsi_device *SDptr);
460#endif 460#endif
461 461
462/* 462/*
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 4fea3e4edaa7..3d8009f55342 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -3368,7 +3368,7 @@ iscsi_conn_set_param(iscsi_connh_t connh, enum iscsi_param param,
3368 switch(param) { 3368 switch(param) {
3369 case ISCSI_PARAM_MAX_RECV_DLENGTH: { 3369 case ISCSI_PARAM_MAX_RECV_DLENGTH: {
3370 char *saveptr = conn->data; 3370 char *saveptr = conn->data;
3371 int flags = GFP_KERNEL; 3371 gfp_t flags = GFP_KERNEL;
3372 3372
3373 if (conn->data_size >= value) { 3373 if (conn->data_size >= value) {
3374 conn->max_recv_dlength = value; 3374 conn->max_recv_dlength = value;
diff --git a/drivers/scsi/jazz_esp.c b/drivers/scsi/jazz_esp.c
index a642f736cf85..23728d1c980c 100644
--- a/drivers/scsi/jazz_esp.c
+++ b/drivers/scsi/jazz_esp.c
@@ -52,7 +52,7 @@ static volatile unsigned char cmd_buffer[16];
52 * via PIO. 52 * via PIO.
53 */ 53 */
54 54
55int jazz_esp_detect(Scsi_Host_Template *tpnt); 55int jazz_esp_detect(struct scsi_host_template *tpnt);
56static int jazz_esp_release(struct Scsi_Host *shost) 56static int jazz_esp_release(struct Scsi_Host *shost)
57{ 57{
58 if (shost->irq) 58 if (shost->irq)
@@ -65,7 +65,7 @@ static int jazz_esp_release(struct Scsi_Host *shost)
65 return 0; 65 return 0;
66} 66}
67 67
68static Scsi_Host_Template driver_template = { 68static struct scsi_host_template driver_template = {
69 .proc_name = "jazz_esp", 69 .proc_name = "jazz_esp",
70 .proc_info = &esp_proc_info, 70 .proc_info = &esp_proc_info,
71 .name = "ESP 100/100a/200", 71 .name = "ESP 100/100a/200",
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index a74b4071a662..d0a0fdbd0fc4 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -532,8 +532,7 @@ void ata_tf_to_fis(const struct ata_taskfile *tf, u8 *fis, u8 pmp)
532 * @fis: Buffer from which data will be input 532 * @fis: Buffer from which data will be input
533 * @tf: Taskfile to output 533 * @tf: Taskfile to output
534 * 534 *
535 * Converts a standard ATA taskfile to a Serial ATA 535 * Converts a serial ATA FIS structure to a standard ATA taskfile.
536 * FIS structure (Register - Host to Device).
537 * 536 *
538 * LOCKING: 537 * LOCKING:
539 * Inherited from caller. 538 * Inherited from caller.
@@ -1047,6 +1046,30 @@ static unsigned int ata_pio_modes(const struct ata_device *adev)
1047 return modes; 1046 return modes;
1048} 1047}
1049 1048
1049static int ata_qc_wait_err(struct ata_queued_cmd *qc,
1050 struct completion *wait)
1051{
1052 int rc = 0;
1053
1054 if (wait_for_completion_timeout(wait, 30 * HZ) < 1) {
1055 /* timeout handling */
1056 unsigned int err_mask = ac_err_mask(ata_chk_status(qc->ap));
1057
1058 if (!err_mask) {
1059 printk(KERN_WARNING "ata%u: slow completion (cmd %x)\n",
1060 qc->ap->id, qc->tf.command);
1061 } else {
1062 printk(KERN_WARNING "ata%u: qc timeout (cmd %x)\n",
1063 qc->ap->id, qc->tf.command);
1064 rc = -EIO;
1065 }
1066
1067 ata_qc_complete(qc, err_mask);
1068 }
1069
1070 return rc;
1071}
1072
1050/** 1073/**
1051 * ata_dev_identify - obtain IDENTIFY x DEVICE page 1074 * ata_dev_identify - obtain IDENTIFY x DEVICE page
1052 * @ap: port on which device we wish to probe resides 1075 * @ap: port on which device we wish to probe resides
@@ -1126,7 +1149,7 @@ retry:
1126 if (rc) 1149 if (rc)
1127 goto err_out; 1150 goto err_out;
1128 else 1151 else
1129 wait_for_completion(&wait); 1152 ata_qc_wait_err(qc, &wait);
1130 1153
1131 spin_lock_irqsave(&ap->host_set->lock, flags); 1154 spin_lock_irqsave(&ap->host_set->lock, flags);
1132 ap->ops->tf_read(ap, &qc->tf); 1155 ap->ops->tf_read(ap, &qc->tf);
@@ -1264,7 +1287,7 @@ retry:
1264 } 1287 }
1265 1288
1266 /* ATAPI-specific feature tests */ 1289 /* ATAPI-specific feature tests */
1267 else { 1290 else if (dev->class == ATA_DEV_ATAPI) {
1268 if (ata_id_is_ata(dev->id)) /* sanity check */ 1291 if (ata_id_is_ata(dev->id)) /* sanity check */
1269 goto err_out_nosup; 1292 goto err_out_nosup;
1270 1293
@@ -1571,11 +1594,13 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1571 1594
1572 /* 1595 /*
1573 * Find the mode. 1596 * Find the mode.
1574 */ 1597 */
1575 1598
1576 if (!(s = ata_timing_find_mode(speed))) 1599 if (!(s = ata_timing_find_mode(speed)))
1577 return -EINVAL; 1600 return -EINVAL;
1578 1601
1602 memcpy(t, s, sizeof(*s));
1603
1579 /* 1604 /*
1580 * If the drive is an EIDE drive, it can tell us it needs extended 1605 * If the drive is an EIDE drive, it can tell us it needs extended
1581 * PIO/MW_DMA cycle timing. 1606 * PIO/MW_DMA cycle timing.
@@ -1596,7 +1621,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
1596 * Convert the timing to bus clock counts. 1621 * Convert the timing to bus clock counts.
1597 */ 1622 */
1598 1623
1599 ata_timing_quantize(s, t, T, UT); 1624 ata_timing_quantize(t, t, T, UT);
1600 1625
1601 /* 1626 /*
1602 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T 1627 * Even in DMA/UDMA modes we still use PIO access for IDENTIFY, S.M.A.R.T
@@ -2268,7 +2293,7 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
2268 if (rc) 2293 if (rc)
2269 ata_port_disable(ap); 2294 ata_port_disable(ap);
2270 else 2295 else
2271 wait_for_completion(&wait); 2296 ata_qc_wait_err(qc, &wait);
2272 2297
2273 DPRINTK("EXIT\n"); 2298 DPRINTK("EXIT\n");
2274} 2299}
@@ -2316,7 +2341,7 @@ static void ata_dev_reread_id(struct ata_port *ap, struct ata_device *dev)
2316 if (rc) 2341 if (rc)
2317 goto err_out; 2342 goto err_out;
2318 2343
2319 wait_for_completion(&wait); 2344 ata_qc_wait_err(qc, &wait);
2320 2345
2321 swap_buf_le16(dev->id, ATA_ID_WORDS); 2346 swap_buf_le16(dev->id, ATA_ID_WORDS);
2322 2347
@@ -2372,7 +2397,7 @@ static void ata_dev_init_params(struct ata_port *ap, struct ata_device *dev)
2372 if (rc) 2397 if (rc)
2373 ata_port_disable(ap); 2398 ata_port_disable(ap);
2374 else 2399 else
2375 wait_for_completion(&wait); 2400 ata_qc_wait_err(qc, &wait);
2376 2401
2377 DPRINTK("EXIT\n"); 2402 DPRINTK("EXIT\n");
2378} 2403}
@@ -2400,7 +2425,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2400 if (qc->flags & ATA_QCFLAG_SINGLE) 2425 if (qc->flags & ATA_QCFLAG_SINGLE)
2401 assert(qc->n_elem == 1); 2426 assert(qc->n_elem == 1);
2402 2427
2403 DPRINTK("unmapping %u sg elements\n", qc->n_elem); 2428 VPRINTK("unmapping %u sg elements\n", qc->n_elem);
2404 2429
2405 /* if we padded the buffer out to 32-bit bound, and data 2430 /* if we padded the buffer out to 32-bit bound, and data
2406 * xfer direction is from-device, we must copy from the 2431 * xfer direction is from-device, we must copy from the
@@ -2410,18 +2435,21 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
2410 pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ); 2435 pad_buf = ap->pad + (qc->tag * ATA_DMA_PAD_SZ);
2411 2436
2412 if (qc->flags & ATA_QCFLAG_SG) { 2437 if (qc->flags & ATA_QCFLAG_SG) {
2413 dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir); 2438 if (qc->n_elem)
2439 dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir);
2414 /* restore last sg */ 2440 /* restore last sg */
2415 sg[qc->orig_n_elem - 1].length += qc->pad_len; 2441 sg[qc->orig_n_elem - 1].length += qc->pad_len;
2416 if (pad_buf) { 2442 if (pad_buf) {
2417 struct scatterlist *psg = &qc->pad_sgent; 2443 struct scatterlist *psg = &qc->pad_sgent;
2418 void *addr = kmap_atomic(psg->page, KM_IRQ0); 2444 void *addr = kmap_atomic(psg->page, KM_IRQ0);
2419 memcpy(addr + psg->offset, pad_buf, qc->pad_len); 2445 memcpy(addr + psg->offset, pad_buf, qc->pad_len);
2420 kunmap_atomic(psg->page, KM_IRQ0); 2446 kunmap_atomic(addr, KM_IRQ0);
2421 } 2447 }
2422 } else { 2448 } else {
2423 dma_unmap_single(ap->host_set->dev, sg_dma_address(&sg[0]), 2449 if (sg_dma_len(&sg[0]) > 0)
2424 sg_dma_len(&sg[0]), dir); 2450 dma_unmap_single(ap->host_set->dev,
2451 sg_dma_address(&sg[0]), sg_dma_len(&sg[0]),
2452 dir);
2425 /* restore sg */ 2453 /* restore sg */
2426 sg->length += qc->pad_len; 2454 sg->length += qc->pad_len;
2427 if (pad_buf) 2455 if (pad_buf)
@@ -2620,6 +2648,11 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2620 sg->length, qc->pad_len); 2648 sg->length, qc->pad_len);
2621 } 2649 }
2622 2650
2651 if (!sg->length) {
2652 sg_dma_address(sg) = 0;
2653 goto skip_map;
2654 }
2655
2623 dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt, 2656 dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt,
2624 sg->length, dir); 2657 sg->length, dir);
2625 if (dma_mapping_error(dma_address)) { 2658 if (dma_mapping_error(dma_address)) {
@@ -2629,6 +2662,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
2629 } 2662 }
2630 2663
2631 sg_dma_address(sg) = dma_address; 2664 sg_dma_address(sg) = dma_address;
2665skip_map:
2632 sg_dma_len(sg) = sg->length; 2666 sg_dma_len(sg) = sg->length;
2633 2667
2634 DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg), 2668 DPRINTK("mapped buffer of %d bytes for %s\n", sg_dma_len(sg),
@@ -2656,7 +2690,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2656 struct ata_port *ap = qc->ap; 2690 struct ata_port *ap = qc->ap;
2657 struct scatterlist *sg = qc->__sg; 2691 struct scatterlist *sg = qc->__sg;
2658 struct scatterlist *lsg = &sg[qc->n_elem - 1]; 2692 struct scatterlist *lsg = &sg[qc->n_elem - 1];
2659 int n_elem, dir; 2693 int n_elem, pre_n_elem, dir, trim_sg = 0;
2660 2694
2661 VPRINTK("ENTER, ata%u\n", ap->id); 2695 VPRINTK("ENTER, ata%u\n", ap->id);
2662 assert(qc->flags & ATA_QCFLAG_SG); 2696 assert(qc->flags & ATA_QCFLAG_SG);
@@ -2683,20 +2717,31 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2683 if (qc->tf.flags & ATA_TFLAG_WRITE) { 2717 if (qc->tf.flags & ATA_TFLAG_WRITE) {
2684 void *addr = kmap_atomic(psg->page, KM_IRQ0); 2718 void *addr = kmap_atomic(psg->page, KM_IRQ0);
2685 memcpy(pad_buf, addr + psg->offset, qc->pad_len); 2719 memcpy(pad_buf, addr + psg->offset, qc->pad_len);
2686 kunmap_atomic(psg->page, KM_IRQ0); 2720 kunmap_atomic(addr, KM_IRQ0);
2687 } 2721 }
2688 2722
2689 sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ); 2723 sg_dma_address(psg) = ap->pad_dma + (qc->tag * ATA_DMA_PAD_SZ);
2690 sg_dma_len(psg) = ATA_DMA_PAD_SZ; 2724 sg_dma_len(psg) = ATA_DMA_PAD_SZ;
2691 /* trim last sg */ 2725 /* trim last sg */
2692 lsg->length -= qc->pad_len; 2726 lsg->length -= qc->pad_len;
2727 if (lsg->length == 0)
2728 trim_sg = 1;
2693 2729
2694 DPRINTK("padding done, sg[%d].length=%u pad_len=%u\n", 2730 DPRINTK("padding done, sg[%d].length=%u pad_len=%u\n",
2695 qc->n_elem - 1, lsg->length, qc->pad_len); 2731 qc->n_elem - 1, lsg->length, qc->pad_len);
2696 } 2732 }
2697 2733
2734 pre_n_elem = qc->n_elem;
2735 if (trim_sg && pre_n_elem)
2736 pre_n_elem--;
2737
2738 if (!pre_n_elem) {
2739 n_elem = 0;
2740 goto skip_map;
2741 }
2742
2698 dir = qc->dma_dir; 2743 dir = qc->dma_dir;
2699 n_elem = dma_map_sg(ap->host_set->dev, sg, qc->n_elem, dir); 2744 n_elem = dma_map_sg(ap->host_set->dev, sg, pre_n_elem, dir);
2700 if (n_elem < 1) { 2745 if (n_elem < 1) {
2701 /* restore last sg */ 2746 /* restore last sg */
2702 lsg->length += qc->pad_len; 2747 lsg->length += qc->pad_len;
@@ -2705,6 +2750,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
2705 2750
2706 DPRINTK("%d sg elements mapped\n", n_elem); 2751 DPRINTK("%d sg elements mapped\n", n_elem);
2707 2752
2753skip_map:
2708 qc->n_elem = n_elem; 2754 qc->n_elem = n_elem;
2709 2755
2710 return 0; 2756 return 0;
@@ -3264,32 +3310,11 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3264{ 3310{
3265 struct ata_port *ap = qc->ap; 3311 struct ata_port *ap = qc->ap;
3266 struct ata_host_set *host_set = ap->host_set; 3312 struct ata_host_set *host_set = ap->host_set;
3267 struct ata_device *dev = qc->dev;
3268 u8 host_stat = 0, drv_stat; 3313 u8 host_stat = 0, drv_stat;
3269 unsigned long flags; 3314 unsigned long flags;
3270 3315
3271 DPRINTK("ENTER\n"); 3316 DPRINTK("ENTER\n");
3272 3317
3273 /* FIXME: doesn't this conflict with timeout handling? */
3274 if (qc->dev->class == ATA_DEV_ATAPI && qc->scsicmd) {
3275 struct scsi_cmnd *cmd = qc->scsicmd;
3276
3277 if (!(cmd->eh_eflags & SCSI_EH_CANCEL_CMD)) {
3278
3279 /* finish completing original command */
3280 spin_lock_irqsave(&host_set->lock, flags);
3281 __ata_qc_complete(qc);
3282 spin_unlock_irqrestore(&host_set->lock, flags);
3283
3284 atapi_request_sense(ap, dev, cmd);
3285
3286 cmd->result = (CHECK_CONDITION << 1) | (DID_OK << 16);
3287 scsi_finish_command(cmd);
3288
3289 goto out;
3290 }
3291 }
3292
3293 spin_lock_irqsave(&host_set->lock, flags); 3318 spin_lock_irqsave(&host_set->lock, flags);
3294 3319
3295 /* hack alert! We cannot use the supplied completion 3320 /* hack alert! We cannot use the supplied completion
@@ -3328,7 +3353,6 @@ static void ata_qc_timeout(struct ata_queued_cmd *qc)
3328 3353
3329 spin_unlock_irqrestore(&host_set->lock, flags); 3354 spin_unlock_irqrestore(&host_set->lock, flags);
3330 3355
3331out:
3332 DPRINTK("EXIT\n"); 3356 DPRINTK("EXIT\n");
3333} 3357}
3334 3358
@@ -3412,16 +3436,11 @@ struct ata_queued_cmd *ata_qc_new_init(struct ata_port *ap,
3412 3436
3413 qc = ata_qc_new(ap); 3437 qc = ata_qc_new(ap);
3414 if (qc) { 3438 if (qc) {
3415 qc->__sg = NULL;
3416 qc->flags = 0;
3417 qc->scsicmd = NULL; 3439 qc->scsicmd = NULL;
3418 qc->ap = ap; 3440 qc->ap = ap;
3419 qc->dev = dev; 3441 qc->dev = dev;
3420 qc->cursect = qc->cursg = qc->cursg_ofs = 0;
3421 qc->nsect = 0;
3422 qc->nbytes = qc->curbytes = 0;
3423 3442
3424 ata_tf_init(ap, &qc->tf, dev->devno); 3443 ata_qc_reinit(qc);
3425 } 3444 }
3426 3445
3427 return qc; 3446 return qc;
@@ -4563,6 +4582,7 @@ ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int
4563 4582
4564 probe_ent->irq = pdev->irq; 4583 probe_ent->irq = pdev->irq;
4565 probe_ent->irq_flags = SA_SHIRQ; 4584 probe_ent->irq_flags = SA_SHIRQ;
4585 probe_ent->private_data = port[0]->private_data;
4566 4586
4567 if (ports & ATA_PORT_PRIMARY) { 4587 if (ports & ATA_PORT_PRIMARY) {
4568 probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0); 4588 probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0);
@@ -4599,6 +4619,7 @@ static struct ata_probe_ent *ata_pci_init_legacy_port(struct pci_dev *pdev, stru
4599 probe_ent->legacy_mode = 1; 4619 probe_ent->legacy_mode = 1;
4600 probe_ent->n_ports = 1; 4620 probe_ent->n_ports = 1;
4601 probe_ent->hard_port_no = port_num; 4621 probe_ent->hard_port_no = port_num;
4622 probe_ent->private_data = port->private_data;
4602 4623
4603 switch(port_num) 4624 switch(port_num)
4604 { 4625 {
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index bb30fcdc9297..2282c04fee46 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -38,6 +38,7 @@
38#include <linux/spinlock.h> 38#include <linux/spinlock.h>
39#include <scsi/scsi.h> 39#include <scsi/scsi.h>
40#include <scsi/scsi_host.h> 40#include <scsi/scsi_host.h>
41#include <scsi/scsi_eh.h>
41#include <scsi/scsi_device.h> 42#include <scsi/scsi_device.h>
42#include <scsi/scsi_request.h> 43#include <scsi/scsi_request.h>
43#include <linux/libata.h> 44#include <linux/libata.h>
@@ -147,7 +148,8 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
147 u8 scsi_cmd[MAX_COMMAND_SIZE]; 148 u8 scsi_cmd[MAX_COMMAND_SIZE];
148 u8 args[4], *argbuf = NULL; 149 u8 args[4], *argbuf = NULL;
149 int argsize = 0; 150 int argsize = 0;
150 struct scsi_request *sreq; 151 struct scsi_sense_hdr sshdr;
152 enum dma_data_direction data_dir;
151 153
152 if (NULL == (void *)arg) 154 if (NULL == (void *)arg)
153 return -EINVAL; 155 return -EINVAL;
@@ -155,10 +157,6 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
155 if (copy_from_user(args, arg, sizeof(args))) 157 if (copy_from_user(args, arg, sizeof(args)))
156 return -EFAULT; 158 return -EFAULT;
157 159
158 sreq = scsi_allocate_request(scsidev, GFP_KERNEL);
159 if (!sreq)
160 return -EINTR;
161
162 memset(scsi_cmd, 0, sizeof(scsi_cmd)); 160 memset(scsi_cmd, 0, sizeof(scsi_cmd));
163 161
164 if (args[3]) { 162 if (args[3]) {
@@ -172,11 +170,11 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
172 scsi_cmd[1] = (4 << 1); /* PIO Data-in */ 170 scsi_cmd[1] = (4 << 1); /* PIO Data-in */
173 scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev, 171 scsi_cmd[2] = 0x0e; /* no off.line or cc, read from dev,
174 block count in sector count field */ 172 block count in sector count field */
175 sreq->sr_data_direction = DMA_FROM_DEVICE; 173 data_dir = DMA_FROM_DEVICE;
176 } else { 174 } else {
177 scsi_cmd[1] = (3 << 1); /* Non-data */ 175 scsi_cmd[1] = (3 << 1); /* Non-data */
178 /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */ 176 /* scsi_cmd[2] is already 0 -- no off.line, cc, or data xfer */
179 sreq->sr_data_direction = DMA_NONE; 177 data_dir = DMA_NONE;
180 } 178 }
181 179
182 scsi_cmd[0] = ATA_16; 180 scsi_cmd[0] = ATA_16;
@@ -194,9 +192,8 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
194 192
195 /* Good values for timeout and retries? Values below 193 /* Good values for timeout and retries? Values below
196 from scsi_ioctl_send_command() for default case... */ 194 from scsi_ioctl_send_command() for default case... */
197 scsi_wait_req(sreq, scsi_cmd, argbuf, argsize, (10*HZ), 5); 195 if (scsi_execute_req(scsidev, scsi_cmd, data_dir, argbuf, argsize,
198 196 &sshdr, (10*HZ), 5)) {
199 if (sreq->sr_result) {
200 rc = -EIO; 197 rc = -EIO;
201 goto error; 198 goto error;
202 } 199 }
@@ -207,8 +204,6 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
207 && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize)) 204 && copy_to_user((void *)(arg + sizeof(args)), argbuf, argsize))
208 rc = -EFAULT; 205 rc = -EFAULT;
209error: 206error:
210 scsi_release_request(sreq);
211
212 if (argbuf) 207 if (argbuf)
213 kfree(argbuf); 208 kfree(argbuf);
214 209
@@ -231,7 +226,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
231 int rc = 0; 226 int rc = 0;
232 u8 scsi_cmd[MAX_COMMAND_SIZE]; 227 u8 scsi_cmd[MAX_COMMAND_SIZE];
233 u8 args[7]; 228 u8 args[7];
234 struct scsi_request *sreq; 229 struct scsi_sense_hdr sshdr;
235 230
236 if (NULL == (void *)arg) 231 if (NULL == (void *)arg)
237 return -EINVAL; 232 return -EINVAL;
@@ -250,26 +245,13 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
250 scsi_cmd[12] = args[5]; 245 scsi_cmd[12] = args[5];
251 scsi_cmd[14] = args[0]; 246 scsi_cmd[14] = args[0];
252 247
253 sreq = scsi_allocate_request(scsidev, GFP_KERNEL);
254 if (!sreq) {
255 rc = -EINTR;
256 goto error;
257 }
258
259 sreq->sr_data_direction = DMA_NONE;
260 /* Good values for timeout and retries? Values below 248 /* Good values for timeout and retries? Values below
261 from scsi_ioctl_send_command() for default case... */ 249 from scsi_ioctl_send_command() for default case... */
262 scsi_wait_req(sreq, scsi_cmd, NULL, 0, (10*HZ), 5); 250 if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr,
263 251 (10*HZ), 5))
264 if (sreq->sr_result) {
265 rc = -EIO; 252 rc = -EIO;
266 goto error;
267 }
268 253
269 /* Need code to retrieve data from check condition? */ 254 /* Need code to retrieve data from check condition? */
270
271error:
272 scsi_release_request(sreq);
273 return rc; 255 return rc;
274} 256}
275 257
@@ -1129,6 +1111,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
1129 * length 0 means transfer 0 block of data. 1111 * length 0 means transfer 0 block of data.
1130 * However, for ATA R/W commands, sector count 0 means 1112 * However, for ATA R/W commands, sector count 0 means
1131 * 256 or 65536 sectors, not 0 sectors as in SCSI. 1113 * 256 or 65536 sectors, not 0 sectors as in SCSI.
1114 *
1115 * WARNING: one or two older ATA drives treat 0 as 0...
1132 */ 1116 */
1133 goto nothing_to_do; 1117 goto nothing_to_do;
1134 1118
@@ -1971,22 +1955,44 @@ void ata_scsi_badcmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *), u8
1971 done(cmd); 1955 done(cmd);
1972} 1956}
1973 1957
1974void atapi_request_sense(struct ata_port *ap, struct ata_device *dev, 1958static int atapi_sense_complete(struct ata_queued_cmd *qc,unsigned int err_mask)
1975 struct scsi_cmnd *cmd)
1976{ 1959{
1977 DECLARE_COMPLETION(wait); 1960 if (err_mask && ((err_mask & AC_ERR_DEV) == 0))
1978 struct ata_queued_cmd *qc; 1961 /* FIXME: not quite right; we don't want the
1979 unsigned long flags; 1962 * translation of taskfile registers into
1980 int rc; 1963 * a sense descriptors, since that's only
1964 * correct for ATA, not ATAPI
1965 */
1966 ata_gen_ata_desc_sense(qc);
1981 1967
1982 DPRINTK("ATAPI request sense\n"); 1968 qc->scsidone(qc->scsicmd);
1969 return 0;
1970}
1983 1971
1984 qc = ata_qc_new_init(ap, dev); 1972/* is it pointless to prefer PIO for "safety reasons"? */
1985 BUG_ON(qc == NULL); 1973static inline int ata_pio_use_silly(struct ata_port *ap)
1974{
1975 return (ap->flags & ATA_FLAG_PIO_DMA);
1976}
1977
1978static void atapi_request_sense(struct ata_queued_cmd *qc)
1979{
1980 struct ata_port *ap = qc->ap;
1981 struct scsi_cmnd *cmd = qc->scsicmd;
1982
1983 DPRINTK("ATAPI request sense\n");
1986 1984
1987 /* FIXME: is this needed? */ 1985 /* FIXME: is this needed? */
1988 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer)); 1986 memset(cmd->sense_buffer, 0, sizeof(cmd->sense_buffer));
1989 1987
1988 ap->ops->tf_read(ap, &qc->tf);
1989
1990 /* fill these in, for the case where they are -not- overwritten */
1991 cmd->sense_buffer[0] = 0x70;
1992 cmd->sense_buffer[2] = qc->tf.feature >> 4;
1993
1994 ata_qc_reinit(qc);
1995
1990 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer)); 1996 ata_sg_init_one(qc, cmd->sense_buffer, sizeof(cmd->sense_buffer));
1991 qc->dma_dir = DMA_FROM_DEVICE; 1997 qc->dma_dir = DMA_FROM_DEVICE;
1992 1998
@@ -1997,22 +2003,20 @@ void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
1997 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; 2003 qc->tf.flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE;
1998 qc->tf.command = ATA_CMD_PACKET; 2004 qc->tf.command = ATA_CMD_PACKET;
1999 2005
2000 qc->tf.protocol = ATA_PROT_ATAPI; 2006 if (ata_pio_use_silly(ap)) {
2001 qc->tf.lbam = (8 * 1024) & 0xff; 2007 qc->tf.protocol = ATA_PROT_ATAPI_DMA;
2002 qc->tf.lbah = (8 * 1024) >> 8; 2008 qc->tf.feature |= ATAPI_PKT_DMA;
2009 } else {
2010 qc->tf.protocol = ATA_PROT_ATAPI;
2011 qc->tf.lbam = (8 * 1024) & 0xff;
2012 qc->tf.lbah = (8 * 1024) >> 8;
2013 }
2003 qc->nbytes = SCSI_SENSE_BUFFERSIZE; 2014 qc->nbytes = SCSI_SENSE_BUFFERSIZE;
2004 2015
2005 qc->waiting = &wait; 2016 qc->complete_fn = atapi_sense_complete;
2006 qc->complete_fn = ata_qc_complete_noop;
2007
2008 spin_lock_irqsave(&ap->host_set->lock, flags);
2009 rc = ata_qc_issue(qc);
2010 spin_unlock_irqrestore(&ap->host_set->lock, flags);
2011 2017
2012 if (rc) 2018 if (ata_qc_issue(qc))
2013 ata_port_disable(ap); 2019 ata_qc_complete(qc, AC_ERR_OTHER);
2014 else
2015 wait_for_completion(&wait);
2016 2020
2017 DPRINTK("EXIT\n"); 2021 DPRINTK("EXIT\n");
2018} 2022}
@@ -2024,19 +2028,8 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2024 VPRINTK("ENTER, err_mask 0x%X\n", err_mask); 2028 VPRINTK("ENTER, err_mask 0x%X\n", err_mask);
2025 2029
2026 if (unlikely(err_mask & AC_ERR_DEV)) { 2030 if (unlikely(err_mask & AC_ERR_DEV)) {
2027 DPRINTK("request check condition\n");
2028
2029 /* FIXME: command completion with check condition
2030 * but no sense causes the error handler to run,
2031 * which then issues REQUEST SENSE, fills in the sense
2032 * buffer, and completes the command (for the second
2033 * time). We need to issue REQUEST SENSE some other
2034 * way, to avoid completing the command twice.
2035 */
2036 cmd->result = SAM_STAT_CHECK_CONDITION; 2031 cmd->result = SAM_STAT_CHECK_CONDITION;
2037 2032 atapi_request_sense(qc);
2038 qc->scsidone(cmd);
2039
2040 return 1; 2033 return 1;
2041 } 2034 }
2042 2035
@@ -2051,7 +2044,7 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2051 else { 2044 else {
2052 u8 *scsicmd = cmd->cmnd; 2045 u8 *scsicmd = cmd->cmnd;
2053 2046
2054 if (scsicmd[0] == INQUIRY) { 2047 if ((scsicmd[0] == INQUIRY) && ((scsicmd[1] & 0x03) == 0)) {
2055 u8 *buf = NULL; 2048 u8 *buf = NULL;
2056 unsigned int buflen; 2049 unsigned int buflen;
2057 2050
@@ -2065,9 +2058,6 @@ static int atapi_qc_complete(struct ata_queued_cmd *qc, unsigned int err_mask)
2065 * device. 2) Ensure response data format / ATAPI information 2058 * device. 2) Ensure response data format / ATAPI information
2066 * are always correct. 2059 * are always correct.
2067 */ 2060 */
2068 /* FIXME: do we ever override EVPD pages and the like, with
2069 * this code?
2070 */
2071 if (buf[2] == 0) { 2061 if (buf[2] == 0) {
2072 buf[2] = 0x5; 2062 buf[2] = 0x5;
2073 buf[3] = 0x32; 2063 buf[3] = 0x32;
@@ -2180,9 +2170,12 @@ ata_scsi_find_dev(struct ata_port *ap, const struct scsi_device *scsidev)
2180 if (unlikely(!ata_dev_present(dev))) 2170 if (unlikely(!ata_dev_present(dev)))
2181 return NULL; 2171 return NULL;
2182 2172
2183 if (!atapi_enabled) { 2173 if (!atapi_enabled || (ap->flags & ATA_FLAG_NO_ATAPI)) {
2184 if (unlikely(dev->class == ATA_DEV_ATAPI)) 2174 if (unlikely(dev->class == ATA_DEV_ATAPI)) {
2175 printk(KERN_WARNING "ata%u(%u): WARNING: ATAPI is %s, device ignored.\n",
2176 ap->id, dev->devno, atapi_enabled ? "not supported with this driver" : "disabled");
2185 return NULL; 2177 return NULL;
2178 }
2186 } 2179 }
2187 2180
2188 return dev; 2181 return dev;
@@ -2246,7 +2239,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2246 struct scsi_cmnd *cmd = qc->scsicmd; 2239 struct scsi_cmnd *cmd = qc->scsicmd;
2247 2240
2248 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN) 2241 if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
2249 return 1; 2242 goto invalid_fld;
2250 2243
2251 /* 2244 /*
2252 * 12 and 16 byte CDBs use different offsets to 2245 * 12 and 16 byte CDBs use different offsets to
@@ -2292,6 +2285,12 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2292 tf->device = scsicmd[8]; 2285 tf->device = scsicmd[8];
2293 tf->command = scsicmd[9]; 2286 tf->command = scsicmd[9];
2294 } 2287 }
2288 /*
2289 * If slave is possible, enforce correct master/slave bit
2290 */
2291 if (qc->ap->flags & ATA_FLAG_SLAVE_POSS)
2292 tf->device = qc->dev->devno ?
2293 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
2295 2294
2296 /* 2295 /*
2297 * Filter SET_FEATURES - XFER MODE command -- otherwise, 2296 * Filter SET_FEATURES - XFER MODE command -- otherwise,
@@ -2302,7 +2301,7 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2302 */ 2301 */
2303 if ((tf->command == ATA_CMD_SET_FEATURES) 2302 if ((tf->command == ATA_CMD_SET_FEATURES)
2304 && (tf->feature == SETFEATURES_XFER)) 2303 && (tf->feature == SETFEATURES_XFER))
2305 return 1; 2304 goto invalid_fld;
2306 2305
2307 /* 2306 /*
2308 * Set flags so that all registers will be written, 2307 * Set flags so that all registers will be written,
@@ -2323,6 +2322,11 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
2323 qc->nsect = cmd->bufflen / ATA_SECT_SIZE; 2322 qc->nsect = cmd->bufflen / ATA_SECT_SIZE;
2324 2323
2325 return 0; 2324 return 0;
2325
2326 invalid_fld:
2327 ata_scsi_set_sense(qc->scsicmd, ILLEGAL_REQUEST, 0x24, 0x00);
2328 /* "Invalid field in cdb" */
2329 return 1;
2326} 2330}
2327 2331
2328/** 2332/**
diff --git a/drivers/scsi/libata.h b/drivers/scsi/libata.h
index fad051ca4672..8ebaa694d18e 100644
--- a/drivers/scsi/libata.h
+++ b/drivers/scsi/libata.h
@@ -29,7 +29,7 @@
29#define __LIBATA_H__ 29#define __LIBATA_H__
30 30
31#define DRV_NAME "libata" 31#define DRV_NAME "libata"
32#define DRV_VERSION "1.12" /* 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 u16 *id; 35 u16 *id;
@@ -54,8 +54,6 @@ extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
54 54
55 55
56/* libata-scsi.c */ 56/* libata-scsi.c */
57extern void atapi_request_sense(struct ata_port *ap, struct ata_device *dev,
58 struct scsi_cmnd *cmd);
59extern void ata_scsi_scan_host(struct ata_port *ap); 57extern void ata_scsi_scan_host(struct ata_port *ap);
60extern int ata_scsi_error(struct Scsi_Host *host); 58extern int ata_scsi_error(struct Scsi_Host *host);
61extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf, 59extern unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index c90723860a04..07498118359d 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -1704,7 +1704,6 @@ MODULE_DEVICE_TABLE(pci, lpfc_id_table);
1704 1704
1705static struct pci_driver lpfc_driver = { 1705static struct pci_driver lpfc_driver = {
1706 .name = LPFC_DRIVER_NAME, 1706 .name = LPFC_DRIVER_NAME,
1707 .owner = THIS_MODULE,
1708 .id_table = lpfc_id_table, 1707 .id_table = lpfc_id_table,
1709 .probe = lpfc_pci_probe_one, 1708 .probe = lpfc_pci_probe_one,
1710 .remove = __devexit_p(lpfc_pci_remove_one), 1709 .remove = __devexit_p(lpfc_pci_remove_one),
diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
index c94c8db84651..e31fadd61904 100644
--- a/drivers/scsi/mac_esp.c
+++ b/drivers/scsi/mac_esp.c
@@ -300,7 +300,7 @@ unsigned long get_base(int chip_num)
300 * Model dependent ESP setup 300 * Model dependent ESP setup
301 */ 301 */
302 302
303int mac_esp_detect(Scsi_Host_Template * tpnt) 303int mac_esp_detect(struct scsi_host_template * tpnt)
304{ 304{
305 int quick = 0; 305 int quick = 0;
306 int chipnum, chipspresent = 0; 306 int chipnum, chipspresent = 0;
@@ -730,7 +730,7 @@ static void dma_setup_quick(struct NCR_ESP * esp, __u32 addr, int count, int wri
730#endif 730#endif
731} 731}
732 732
733static Scsi_Host_Template driver_template = { 733static struct scsi_host_template driver_template = {
734 .proc_name = "mac_esp", 734 .proc_name = "mac_esp",
735 .name = "Mac 53C9x SCSI", 735 .name = "Mac 53C9x SCSI",
736 .detect = mac_esp_detect, 736 .detect = mac_esp_detect,
diff --git a/drivers/scsi/mac_scsi.c b/drivers/scsi/mac_scsi.c
index 92d2c8379abf..777f9bcd1179 100644
--- a/drivers/scsi/mac_scsi.c
+++ b/drivers/scsi/mac_scsi.c
@@ -222,7 +222,7 @@ static struct Scsi_Host *default_instance;
222#endif 222#endif
223 223
224/* 224/*
225 * Function : int macscsi_detect(Scsi_Host_Template * tpnt) 225 * Function : int macscsi_detect(struct scsi_host_template * tpnt)
226 * 226 *
227 * Purpose : initializes mac NCR5380 driver based on the 227 * Purpose : initializes mac NCR5380 driver based on the
228 * command line / compile time port and irq definitions. 228 * command line / compile time port and irq definitions.
@@ -233,7 +233,7 @@ static struct Scsi_Host *default_instance;
233 * 233 *
234 */ 234 */
235 235
236int macscsi_detect(Scsi_Host_Template * tpnt) 236int macscsi_detect(struct scsi_host_template * tpnt)
237{ 237{
238 static int called = 0; 238 static int called = 0;
239 int flags = 0; 239 int flags = 0;
@@ -581,7 +581,7 @@ static int macscsi_pwrite (struct Scsi_Host *instance,
581 581
582#include "NCR5380.c" 582#include "NCR5380.c"
583 583
584static Scsi_Host_Template driver_template = { 584static struct scsi_host_template driver_template = {
585 .proc_name = "Mac5380", 585 .proc_name = "Mac5380",
586 .proc_info = macscsi_proc_info, 586 .proc_info = macscsi_proc_info,
587 .name = "Macintosh NCR5380 SCSI", 587 .name = "Macintosh NCR5380 SCSI",
diff --git a/drivers/scsi/mca_53c9x.c b/drivers/scsi/mca_53c9x.c
index 194c75451faf..998a8bbc1a4b 100644
--- a/drivers/scsi/mca_53c9x.c
+++ b/drivers/scsi/mca_53c9x.c
@@ -103,7 +103,7 @@ static volatile unsigned char cmd_buffer[16];
103static struct ESP_regs eregs; 103static struct ESP_regs eregs;
104 104
105/***************************************************************** Detection */ 105/***************************************************************** Detection */
106static int mca_esp_detect(Scsi_Host_Template *tpnt) 106static int mca_esp_detect(struct scsi_host_template *tpnt)
107{ 107{
108 struct NCR_ESP *esp; 108 struct NCR_ESP *esp;
109 static int io_port_by_pos[] = MCA_53C9X_IO_PORTS; 109 static int io_port_by_pos[] = MCA_53C9X_IO_PORTS;
@@ -444,7 +444,7 @@ static void dma_led_off(struct NCR_ESP *esp)
444 outb(inb(PS2_SYS_CTR) & 0x3f, PS2_SYS_CTR); 444 outb(inb(PS2_SYS_CTR) & 0x3f, PS2_SYS_CTR);
445} 445}
446 446
447static Scsi_Host_Template driver_template = { 447static struct scsi_host_template driver_template = {
448 .proc_name = "mca_53c9x", 448 .proc_name = "mca_53c9x",
449 .name = "NCR 53c9x SCSI", 449 .name = "NCR 53c9x SCSI",
450 .detect = mca_esp_detect, 450 .detect = mca_esp_detect,
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 61a6fd810bb4..578143e93a6f 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -362,6 +362,7 @@ megaraid_queue(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *))
362 adapter_t *adapter; 362 adapter_t *adapter;
363 scb_t *scb; 363 scb_t *scb;
364 int busy=0; 364 int busy=0;
365 unsigned long flags;
365 366
366 adapter = (adapter_t *)scmd->device->host->hostdata; 367 adapter = (adapter_t *)scmd->device->host->hostdata;
367 368
@@ -377,23 +378,25 @@ megaraid_queue(Scsi_Cmnd *scmd, void (*done)(Scsi_Cmnd *))
377 * return 0 in that case. 378 * return 0 in that case.
378 */ 379 */
379 380
381 spin_lock_irqsave(&adapter->lock, flags);
380 scb = mega_build_cmd(adapter, scmd, &busy); 382 scb = mega_build_cmd(adapter, scmd, &busy);
383 if (!scb)
384 goto out;
381 385
382 if(scb) { 386 scb->state |= SCB_PENDQ;
383 scb->state |= SCB_PENDQ; 387 list_add_tail(&scb->list, &adapter->pending_list);
384 list_add_tail(&scb->list, &adapter->pending_list);
385 388
386 /* 389 /*
387 * Check if the HBA is in quiescent state, e.g., during a 390 * Check if the HBA is in quiescent state, e.g., during a
388 * delete logical drive opertion. If it is, don't run 391 * delete logical drive opertion. If it is, don't run
389 * the pending_list. 392 * the pending_list.
390 */ 393 */
391 if(atomic_read(&adapter->quiescent) == 0) { 394 if (atomic_read(&adapter->quiescent) == 0)
392 mega_runpendq(adapter); 395 mega_runpendq(adapter);
393 }
394 return 0;
395 }
396 396
397 busy = 0;
398 out:
399 spin_unlock_irqrestore(&adapter->lock, flags);
397 return busy; 400 return busy;
398} 401}
399 402
@@ -661,7 +664,7 @@ mega_build_cmd(adapter_t *adapter, Scsi_Cmnd *cmd, int *busy)
661 sg->offset; 664 sg->offset;
662 } else 665 } else
663 buf = cmd->request_buffer; 666 buf = cmd->request_buffer;
664 memset(cmd->request_buffer, 0, cmd->cmnd[4]); 667 memset(buf, 0, cmd->cmnd[4]);
665 if (cmd->use_sg) { 668 if (cmd->use_sg) {
666 struct scatterlist *sg; 669 struct scatterlist *sg;
667 670
@@ -1683,7 +1686,7 @@ mega_rundoneq (adapter_t *adapter)
1683 1686
1684 list_for_each(pos, &adapter->completed_list) { 1687 list_for_each(pos, &adapter->completed_list) {
1685 1688
1686 Scsi_Pointer* spos = (Scsi_Pointer *)pos; 1689 struct scsi_pointer* spos = (struct scsi_pointer *)pos;
1687 1690
1688 cmd = list_entry(spos, Scsi_Cmnd, SCp); 1691 cmd = list_entry(spos, Scsi_Cmnd, SCp);
1689 cmd->scsi_done(cmd); 1692 cmd->scsi_done(cmd);
@@ -1981,7 +1984,7 @@ megaraid_reset(struct scsi_cmnd *cmd)
1981 mc.cmd = MEGA_CLUSTER_CMD; 1984 mc.cmd = MEGA_CLUSTER_CMD;
1982 mc.opcode = MEGA_RESET_RESERVATIONS; 1985 mc.opcode = MEGA_RESET_RESERVATIONS;
1983 1986
1984 if( mega_internal_command(adapter, LOCK_INT, &mc, NULL) != 0 ) { 1987 if( mega_internal_command(adapter, &mc, NULL) != 0 ) {
1985 printk(KERN_WARNING 1988 printk(KERN_WARNING
1986 "megaraid: reservation reset failed.\n"); 1989 "megaraid: reservation reset failed.\n");
1987 } 1990 }
@@ -3011,7 +3014,7 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
3011 mc.cmd = FC_NEW_CONFIG; 3014 mc.cmd = FC_NEW_CONFIG;
3012 mc.opcode = OP_DCMD_READ_CONFIG; 3015 mc.opcode = OP_DCMD_READ_CONFIG;
3013 3016
3014 if( mega_internal_command(adapter, LOCK_INT, &mc, NULL) ) { 3017 if( mega_internal_command(adapter, &mc, NULL) ) {
3015 3018
3016 len = sprintf(page, "40LD read config failed.\n"); 3019 len = sprintf(page, "40LD read config failed.\n");
3017 3020
@@ -3029,11 +3032,11 @@ proc_rdrv(adapter_t *adapter, char *page, int start, int end )
3029 else { 3032 else {
3030 mc.cmd = NEW_READ_CONFIG_8LD; 3033 mc.cmd = NEW_READ_CONFIG_8LD;
3031 3034
3032 if( mega_internal_command(adapter, LOCK_INT, &mc, NULL) ) { 3035 if( mega_internal_command(adapter, &mc, NULL) ) {
3033 3036
3034 mc.cmd = READ_CONFIG_8LD; 3037 mc.cmd = READ_CONFIG_8LD;
3035 3038
3036 if( mega_internal_command(adapter, LOCK_INT, &mc, 3039 if( mega_internal_command(adapter, &mc,
3037 NULL) ){ 3040 NULL) ){
3038 3041
3039 len = sprintf(page, 3042 len = sprintf(page,
@@ -3632,7 +3635,7 @@ megadev_ioctl(struct inode *inode, struct file *filep, unsigned int cmd,
3632 /* 3635 /*
3633 * Issue the command 3636 * Issue the command
3634 */ 3637 */
3635 mega_internal_command(adapter, LOCK_INT, &mc, pthru); 3638 mega_internal_command(adapter, &mc, pthru);
3636 3639
3637 rval = mega_n_to_m((void __user *)arg, &mc); 3640 rval = mega_n_to_m((void __user *)arg, &mc);
3638 3641
@@ -3715,7 +3718,7 @@ freemem_and_return:
3715 /* 3718 /*
3716 * Issue the command 3719 * Issue the command
3717 */ 3720 */
3718 mega_internal_command(adapter, LOCK_INT, &mc, NULL); 3721 mega_internal_command(adapter, &mc, NULL);
3719 3722
3720 rval = mega_n_to_m((void __user *)arg, &mc); 3723 rval = mega_n_to_m((void __user *)arg, &mc);
3721 3724
@@ -4234,7 +4237,7 @@ mega_do_del_logdrv(adapter_t *adapter, int logdrv)
4234 mc.opcode = OP_DEL_LOGDRV; 4237 mc.opcode = OP_DEL_LOGDRV;
4235 mc.subopcode = logdrv; 4238 mc.subopcode = logdrv;
4236 4239
4237 rval = mega_internal_command(adapter, LOCK_INT, &mc, NULL); 4240 rval = mega_internal_command(adapter, &mc, NULL);
4238 4241
4239 /* log this event */ 4242 /* log this event */
4240 if(rval) { 4243 if(rval) {
@@ -4367,7 +4370,7 @@ mega_adapinq(adapter_t *adapter, dma_addr_t dma_handle)
4367 4370
4368 mc.xferaddr = (u32)dma_handle; 4371 mc.xferaddr = (u32)dma_handle;
4369 4372
4370 if ( mega_internal_command(adapter, LOCK_INT, &mc, NULL) != 0 ) { 4373 if ( mega_internal_command(adapter, &mc, NULL) != 0 ) {
4371 return -1; 4374 return -1;
4372 } 4375 }
4373 4376
@@ -4435,7 +4438,7 @@ mega_internal_dev_inquiry(adapter_t *adapter, u8 ch, u8 tgt,
4435 mc.cmd = MEGA_MBOXCMD_PASSTHRU; 4438 mc.cmd = MEGA_MBOXCMD_PASSTHRU;
4436 mc.xferaddr = (u32)pthru_dma_handle; 4439 mc.xferaddr = (u32)pthru_dma_handle;
4437 4440
4438 rval = mega_internal_command(adapter, LOCK_INT, &mc, pthru); 4441 rval = mega_internal_command(adapter, &mc, pthru);
4439 4442
4440 pci_free_consistent(pdev, sizeof(mega_passthru), pthru, 4443 pci_free_consistent(pdev, sizeof(mega_passthru), pthru,
4441 pthru_dma_handle); 4444 pthru_dma_handle);
@@ -4449,7 +4452,6 @@ mega_internal_dev_inquiry(adapter_t *adapter, u8 ch, u8 tgt,
4449/** 4452/**
4450 * mega_internal_command() 4453 * mega_internal_command()
4451 * @adapter - pointer to our soft state 4454 * @adapter - pointer to our soft state
4452 * @ls - the scope of the exclusion lock.
4453 * @mc - the mailbox command 4455 * @mc - the mailbox command
4454 * @pthru - Passthru structure for DCDB commands 4456 * @pthru - Passthru structure for DCDB commands
4455 * 4457 *
@@ -4463,8 +4465,7 @@ mega_internal_dev_inquiry(adapter_t *adapter, u8 ch, u8 tgt,
4463 * Note: parameter 'pthru' is null for non-passthru commands. 4465 * Note: parameter 'pthru' is null for non-passthru commands.
4464 */ 4466 */
4465static int 4467static int
4466mega_internal_command(adapter_t *adapter, lockscope_t ls, megacmd_t *mc, 4468mega_internal_command(adapter_t *adapter, megacmd_t *mc, mega_passthru *pthru)
4467 mega_passthru *pthru )
4468{ 4469{
4469 Scsi_Cmnd *scmd; 4470 Scsi_Cmnd *scmd;
4470 struct scsi_device *sdev; 4471 struct scsi_device *sdev;
@@ -4508,15 +4509,8 @@ mega_internal_command(adapter_t *adapter, lockscope_t ls, megacmd_t *mc,
4508 4509
4509 scb->idx = CMDID_INT_CMDS; 4510 scb->idx = CMDID_INT_CMDS;
4510 4511
4511 /*
4512 * Get the lock only if the caller has not acquired it already
4513 */
4514 if( ls == LOCK_INT ) spin_lock_irqsave(&adapter->lock, flags);
4515
4516 megaraid_queue(scmd, mega_internal_done); 4512 megaraid_queue(scmd, mega_internal_done);
4517 4513
4518 if( ls == LOCK_INT ) spin_unlock_irqrestore(&adapter->lock, flags);
4519
4520 wait_for_completion(&adapter->int_waitq); 4514 wait_for_completion(&adapter->int_waitq);
4521 4515
4522 rval = scmd->result; 4516 rval = scmd->result;
@@ -4683,7 +4677,6 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
4683 4677
4684 adapter->flag = flag; 4678 adapter->flag = flag;
4685 spin_lock_init(&adapter->lock); 4679 spin_lock_init(&adapter->lock);
4686 scsi_assign_lock(host, &adapter->lock);
4687 4680
4688 host->cmd_per_lun = max_cmd_per_lun; 4681 host->cmd_per_lun = max_cmd_per_lun;
4689 host->max_sectors = max_sectors_per_io; 4682 host->max_sectors = max_sectors_per_io;
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 4facf557cd19..6f9078025748 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -926,13 +926,6 @@ struct mega_hbas {
926#define MEGA_SGLIST 0x0002 926#define MEGA_SGLIST 0x0002
927 927
928/* 928/*
929 * lockscope definitions, callers can specify the lock scope with this data
930 * type. LOCK_INT would mean the caller has not acquired the lock before
931 * making the call and LOCK_EXT would mean otherwise.
932 */
933typedef enum { LOCK_INT, LOCK_EXT } lockscope_t;
934
935/*
936 * Parameters for the io-mapped controllers 929 * Parameters for the io-mapped controllers
937 */ 930 */
938 931
@@ -1062,8 +1055,7 @@ static int mega_support_random_del(adapter_t *);
1062static int mega_del_logdrv(adapter_t *, int); 1055static int mega_del_logdrv(adapter_t *, int);
1063static int mega_do_del_logdrv(adapter_t *, int); 1056static int mega_do_del_logdrv(adapter_t *, int);
1064static void mega_get_max_sgl(adapter_t *); 1057static void mega_get_max_sgl(adapter_t *);
1065static int mega_internal_command(adapter_t *, lockscope_t, megacmd_t *, 1058static int mega_internal_command(adapter_t *, megacmd_t *, mega_passthru *);
1066 mega_passthru *);
1067static void mega_internal_done(Scsi_Cmnd *); 1059static void mega_internal_done(Scsi_Cmnd *);
1068static int mega_support_cluster(adapter_t *); 1060static int mega_support_cluster(adapter_t *);
1069#endif 1061#endif
diff --git a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
index 8e547130e97d..4675343228ad 100644
--- a/drivers/scsi/megaraid/mega_common.h
+++ b/drivers/scsi/megaraid/mega_common.h
@@ -96,7 +96,6 @@ typedef struct {
96 * @param dpc_h : tasklet handle 96 * @param dpc_h : tasklet handle
97 * @param pdev : pci configuration pointer for kernel 97 * @param pdev : pci configuration pointer for kernel
98 * @param host : pointer to host structure of mid-layer 98 * @param host : pointer to host structure of mid-layer
99 * @param host_lock : pointer to appropriate lock
100 * @param lock : synchronization lock for mid-layer and driver 99 * @param lock : synchronization lock for mid-layer and driver
101 * @param quiescent : driver is quiescent for now. 100 * @param quiescent : driver is quiescent for now.
102 * @param outstanding_cmds : number of commands pending in the driver 101 * @param outstanding_cmds : number of commands pending in the driver
@@ -151,7 +150,6 @@ typedef struct {
151 struct tasklet_struct dpc_h; 150 struct tasklet_struct dpc_h;
152 struct pci_dev *pdev; 151 struct pci_dev *pdev;
153 struct Scsi_Host *host; 152 struct Scsi_Host *host;
154 spinlock_t *host_lock;
155 spinlock_t lock; 153 spinlock_t lock;
156 uint8_t quiescent; 154 uint8_t quiescent;
157 int outstanding_cmds; 155 int outstanding_cmds;
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 1a3d195a2d36..4b5d420d2f4d 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -533,8 +533,6 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
533 533
534 // Initialize the synchronization lock for kernel and LLD 534 // Initialize the synchronization lock for kernel and LLD
535 spin_lock_init(&adapter->lock); 535 spin_lock_init(&adapter->lock);
536 adapter->host_lock = &adapter->lock;
537
538 536
539 // Initialize the command queues: the list of free SCBs and the list 537 // Initialize the command queues: the list of free SCBs and the list
540 // of pending SCBs. 538 // of pending SCBs.
@@ -715,9 +713,6 @@ megaraid_io_attach(adapter_t *adapter)
715 SCSIHOST2ADAP(host) = (caddr_t)adapter; 713 SCSIHOST2ADAP(host) = (caddr_t)adapter;
716 adapter->host = host; 714 adapter->host = host;
717 715
718 // export the parameters required by the mid-layer
719 scsi_assign_lock(host, adapter->host_lock);
720
721 host->irq = adapter->irq; 716 host->irq = adapter->irq;
722 host->unique_id = adapter->unique_id; 717 host->unique_id = adapter->unique_id;
723 host->can_queue = adapter->max_cmds; 718 host->can_queue = adapter->max_cmds;
@@ -1560,10 +1555,6 @@ megaraid_queue_command(struct scsi_cmnd *scp, void (* done)(struct scsi_cmnd *))
1560 scp->scsi_done = done; 1555 scp->scsi_done = done;
1561 scp->result = 0; 1556 scp->result = 0;
1562 1557
1563 assert_spin_locked(adapter->host_lock);
1564
1565 spin_unlock(adapter->host_lock);
1566
1567 /* 1558 /*
1568 * Allocate and build a SCB request 1559 * Allocate and build a SCB request
1569 * if_busy flag will be set if megaraid_mbox_build_cmd() command could 1560 * if_busy flag will be set if megaraid_mbox_build_cmd() command could
@@ -1573,23 +1564,16 @@ megaraid_queue_command(struct scsi_cmnd *scp, void (* done)(struct scsi_cmnd *))
1573 * return 0 in that case, and we would do the callback right away. 1564 * return 0 in that case, and we would do the callback right away.
1574 */ 1565 */
1575 if_busy = 0; 1566 if_busy = 0;
1576 scb = megaraid_mbox_build_cmd(adapter, scp, &if_busy); 1567 scb = megaraid_mbox_build_cmd(adapter, scp, &if_busy);
1577
1578 if (scb) {
1579 megaraid_mbox_runpendq(adapter, scb);
1580 }
1581
1582 spin_lock(adapter->host_lock);
1583
1584 if (!scb) { // command already completed 1568 if (!scb) { // command already completed
1585 done(scp); 1569 done(scp);
1586 return 0; 1570 return 0;
1587 } 1571 }
1588 1572
1573 megaraid_mbox_runpendq(adapter, scb);
1589 return if_busy; 1574 return if_busy;
1590} 1575}
1591 1576
1592
1593/** 1577/**
1594 * megaraid_mbox_build_cmd - transform the mid-layer scsi command to megaraid 1578 * megaraid_mbox_build_cmd - transform the mid-layer scsi command to megaraid
1595 * firmware lingua 1579 * firmware lingua
@@ -2546,9 +2530,7 @@ megaraid_mbox_dpc(unsigned long devp)
2546 megaraid_dealloc_scb(adapter, scb); 2530 megaraid_dealloc_scb(adapter, scb);
2547 2531
2548 // send the scsi packet back to kernel 2532 // send the scsi packet back to kernel
2549 spin_lock(adapter->host_lock);
2550 scp->scsi_done(scp); 2533 scp->scsi_done(scp);
2551 spin_unlock(adapter->host_lock);
2552 } 2534 }
2553 2535
2554 return; 2536 return;
@@ -2563,7 +2545,7 @@ megaraid_mbox_dpc(unsigned long devp)
2563 * aborted. All the commands issued to the F/W must complete. 2545 * aborted. All the commands issued to the F/W must complete.
2564 **/ 2546 **/
2565static int 2547static int
2566__megaraid_abort_handler(struct scsi_cmnd *scp) 2548megaraid_abort_handler(struct scsi_cmnd *scp)
2567{ 2549{
2568 adapter_t *adapter; 2550 adapter_t *adapter;
2569 mraid_device_t *raid_dev; 2551 mraid_device_t *raid_dev;
@@ -2577,8 +2559,6 @@ __megaraid_abort_handler(struct scsi_cmnd *scp)
2577 adapter = SCP2ADAPTER(scp); 2559 adapter = SCP2ADAPTER(scp);
2578 raid_dev = ADAP2RAIDDEV(adapter); 2560 raid_dev = ADAP2RAIDDEV(adapter);
2579 2561
2580 assert_spin_locked(adapter->host_lock);
2581
2582 con_log(CL_ANN, (KERN_WARNING 2562 con_log(CL_ANN, (KERN_WARNING
2583 "megaraid: aborting-%ld cmd=%x <c=%d t=%d l=%d>\n", 2563 "megaraid: aborting-%ld cmd=%x <c=%d t=%d l=%d>\n",
2584 scp->serial_number, scp->cmnd[0], SCP2CHANNEL(scp), 2564 scp->serial_number, scp->cmnd[0], SCP2CHANNEL(scp),
@@ -2658,6 +2638,7 @@ __megaraid_abort_handler(struct scsi_cmnd *scp)
2658 // traverse through the list of all SCB, since driver does not 2638 // traverse through the list of all SCB, since driver does not
2659 // maintain these SCBs on any list 2639 // maintain these SCBs on any list
2660 found = 0; 2640 found = 0;
2641 spin_lock_irq(&adapter->lock);
2661 for (i = 0; i < MBOX_MAX_SCSI_CMDS; i++) { 2642 for (i = 0; i < MBOX_MAX_SCSI_CMDS; i++) {
2662 scb = adapter->kscb_list + i; 2643 scb = adapter->kscb_list + i;
2663 2644
@@ -2680,6 +2661,7 @@ __megaraid_abort_handler(struct scsi_cmnd *scp)
2680 } 2661 }
2681 } 2662 }
2682 } 2663 }
2664 spin_unlock_irq(&adapter->lock);
2683 2665
2684 if (!found) { 2666 if (!found) {
2685 con_log(CL_ANN, (KERN_WARNING 2667 con_log(CL_ANN, (KERN_WARNING
@@ -2696,22 +2678,6 @@ __megaraid_abort_handler(struct scsi_cmnd *scp)
2696 return FAILED; 2678 return FAILED;
2697} 2679}
2698 2680
2699static int
2700megaraid_abort_handler(struct scsi_cmnd *scp)
2701{
2702 adapter_t *adapter;
2703 int rc;
2704
2705 adapter = SCP2ADAPTER(scp);
2706
2707 spin_lock_irq(adapter->host_lock);
2708 rc = __megaraid_abort_handler(scp);
2709 spin_unlock_irq(adapter->host_lock);
2710
2711 return rc;
2712}
2713
2714
2715/** 2681/**
2716 * megaraid_reset_handler - device reset hadler for mailbox based driver 2682 * megaraid_reset_handler - device reset hadler for mailbox based driver
2717 * @scp : reference command 2683 * @scp : reference command
@@ -2723,7 +2689,7 @@ megaraid_abort_handler(struct scsi_cmnd *scp)
2723 * host 2689 * host
2724 **/ 2690 **/
2725static int 2691static int
2726__megaraid_reset_handler(struct scsi_cmnd *scp) 2692megaraid_reset_handler(struct scsi_cmnd *scp)
2727{ 2693{
2728 adapter_t *adapter; 2694 adapter_t *adapter;
2729 scb_t *scb; 2695 scb_t *scb;
@@ -2739,10 +2705,6 @@ __megaraid_reset_handler(struct scsi_cmnd *scp)
2739 adapter = SCP2ADAPTER(scp); 2705 adapter = SCP2ADAPTER(scp);
2740 raid_dev = ADAP2RAIDDEV(adapter); 2706 raid_dev = ADAP2RAIDDEV(adapter);
2741 2707
2742 assert_spin_locked(adapter->host_lock);
2743
2744 con_log(CL_ANN, (KERN_WARNING "megaraid: reseting the host...\n"));
2745
2746 // return failure if adapter is not responding 2708 // return failure if adapter is not responding
2747 if (raid_dev->hw_error) { 2709 if (raid_dev->hw_error) {
2748 con_log(CL_ANN, (KERN_NOTICE 2710 con_log(CL_ANN, (KERN_NOTICE
@@ -2779,8 +2741,6 @@ __megaraid_reset_handler(struct scsi_cmnd *scp)
2779 adapter->outstanding_cmds, MBOX_RESET_WAIT)); 2741 adapter->outstanding_cmds, MBOX_RESET_WAIT));
2780 } 2742 }
2781 2743
2782 spin_unlock(adapter->host_lock);
2783
2784 recovery_window = MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT; 2744 recovery_window = MBOX_RESET_WAIT + MBOX_RESET_EXT_WAIT;
2785 2745
2786 recovering = adapter->outstanding_cmds; 2746 recovering = adapter->outstanding_cmds;
@@ -2806,7 +2766,7 @@ __megaraid_reset_handler(struct scsi_cmnd *scp)
2806 msleep(1000); 2766 msleep(1000);
2807 } 2767 }
2808 2768
2809 spin_lock(adapter->host_lock); 2769 spin_lock(&adapter->lock);
2810 2770
2811 // If still outstanding commands, bail out 2771 // If still outstanding commands, bail out
2812 if (adapter->outstanding_cmds) { 2772 if (adapter->outstanding_cmds) {
@@ -2815,7 +2775,8 @@ __megaraid_reset_handler(struct scsi_cmnd *scp)
2815 2775
2816 raid_dev->hw_error = 1; 2776 raid_dev->hw_error = 1;
2817 2777
2818 return FAILED; 2778 rval = FAILED;
2779 goto out;
2819 } 2780 }
2820 else { 2781 else {
2821 con_log(CL_ANN, (KERN_NOTICE 2782 con_log(CL_ANN, (KERN_NOTICE
@@ -2824,7 +2785,10 @@ __megaraid_reset_handler(struct scsi_cmnd *scp)
2824 2785
2825 2786
2826 // If the controller supports clustering, reset reservations 2787 // If the controller supports clustering, reset reservations
2827 if (!adapter->ha) return SUCCESS; 2788 if (!adapter->ha) {
2789 rval = SUCCESS;
2790 goto out;
2791 }
2828 2792
2829 // clear reservations if any 2793 // clear reservations if any
2830 raw_mbox[0] = CLUSTER_CMD; 2794 raw_mbox[0] = CLUSTER_CMD;
@@ -2841,22 +2805,11 @@ __megaraid_reset_handler(struct scsi_cmnd *scp)
2841 "megaraid: reservation reset failed\n")); 2805 "megaraid: reservation reset failed\n"));
2842 } 2806 }
2843 2807
2808 out:
2809 spin_unlock_irq(&adapter->lock);
2844 return rval; 2810 return rval;
2845} 2811}
2846 2812
2847static int
2848megaraid_reset_handler(struct scsi_cmnd *cmd)
2849{
2850 int rc;
2851
2852 spin_lock_irq(cmd->device->host->host_lock);
2853 rc = __megaraid_reset_handler(cmd);
2854 spin_unlock_irq(cmd->device->host->host_lock);
2855
2856 return rc;
2857}
2858
2859
2860/* 2813/*
2861 * START: internal commands library 2814 * START: internal commands library
2862 * 2815 *
@@ -3776,9 +3729,9 @@ wait_till_fw_empty(adapter_t *adapter)
3776 /* 3729 /*
3777 * Set the quiescent flag to stop issuing cmds to FW. 3730 * Set the quiescent flag to stop issuing cmds to FW.
3778 */ 3731 */
3779 spin_lock_irqsave(adapter->host_lock, flags); 3732 spin_lock_irqsave(&adapter->lock, flags);
3780 adapter->quiescent++; 3733 adapter->quiescent++;
3781 spin_unlock_irqrestore(adapter->host_lock, flags); 3734 spin_unlock_irqrestore(&adapter->lock, flags);
3782 3735
3783 /* 3736 /*
3784 * Wait till there are no more cmds outstanding at FW. Try for at most 3737 * Wait till there are no more cmds outstanding at FW. Try for at most
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c
index 801a63bea8a5..3c32e69afcd9 100644
--- a/drivers/scsi/megaraid/megaraid_sas.c
+++ b/drivers/scsi/megaraid/megaraid_sas.c
@@ -766,17 +766,12 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
766 return FAILED; 766 return FAILED;
767 } 767 }
768 768
769 spin_unlock(scmd->device->host->host_lock);
770
771 ret_val = megasas_wait_for_outstanding(instance); 769 ret_val = megasas_wait_for_outstanding(instance);
772
773 if (ret_val == SUCCESS) 770 if (ret_val == SUCCESS)
774 printk(KERN_NOTICE "megasas: reset successful \n"); 771 printk(KERN_NOTICE "megasas: reset successful \n");
775 else 772 else
776 printk(KERN_ERR "megasas: failed to do reset\n"); 773 printk(KERN_ERR "megasas: failed to do reset\n");
777 774
778 spin_lock(scmd->device->host->host_lock);
779
780 return ret_val; 775 return ret_val;
781} 776}
782 777
diff --git a/drivers/scsi/mvme147.c b/drivers/scsi/mvme147.c
index 33380cee9b77..cb367c2c5c78 100644
--- a/drivers/scsi/mvme147.c
+++ b/drivers/scsi/mvme147.c
@@ -63,7 +63,7 @@ static void dma_stop (struct Scsi_Host *instance, Scsi_Cmnd *SCpnt,
63 m147_pcc->dma_cntrl = 0; 63 m147_pcc->dma_cntrl = 0;
64} 64}
65 65
66int mvme147_detect(Scsi_Host_Template *tpnt) 66int mvme147_detect(struct scsi_host_template *tpnt)
67{ 67{
68 static unsigned char called = 0; 68 static unsigned char called = 0;
69 wd33c93_regs regs; 69 wd33c93_regs regs;
@@ -130,7 +130,7 @@ static int mvme147_bus_reset(Scsi_Cmnd *cmd)
130 130
131#include "mvme147.h" 131#include "mvme147.h"
132 132
133static Scsi_Host_Template driver_template = { 133static struct scsi_host_template driver_template = {
134 .proc_name = "MVME147", 134 .proc_name = "MVME147",
135 .name = "MVME147 built-in SCSI", 135 .name = "MVME147 built-in SCSI",
136 .detect = mvme147_detect, 136 .detect = mvme147_detect,
diff --git a/drivers/scsi/mvme147.h b/drivers/scsi/mvme147.h
index d8903f096182..2f56d69bd180 100644
--- a/drivers/scsi/mvme147.h
+++ b/drivers/scsi/mvme147.h
@@ -10,7 +10,7 @@
10 10
11#include <linux/types.h> 11#include <linux/types.h>
12 12
13int mvme147_detect(Scsi_Host_Template *); 13int mvme147_detect(struct scsi_host_template *);
14int mvme147_release(struct Scsi_Host *); 14int mvme147_release(struct Scsi_Host *);
15const char *wd33c93_info(void); 15const char *wd33c93_info(void);
16int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 16int wd33c93_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
diff --git a/drivers/scsi/mvme16x.c b/drivers/scsi/mvme16x.c
index 29ec699e0e4d..890e9e232dab 100644
--- a/drivers/scsi/mvme16x.c
+++ b/drivers/scsi/mvme16x.c
@@ -21,7 +21,7 @@
21#include<linux/stat.h> 21#include<linux/stat.h>
22 22
23 23
24int mvme16x_scsi_detect(Scsi_Host_Template *tpnt) 24int mvme16x_scsi_detect(struct scsi_host_template *tpnt)
25{ 25{
26 static unsigned char called = 0; 26 static unsigned char called = 0;
27 int clock; 27 int clock;
@@ -61,7 +61,7 @@ static int mvme16x_scsi_release(struct Scsi_Host *shost)
61 return 0; 61 return 0;
62} 62}
63 63
64static Scsi_Host_Template driver_template = { 64static struct scsi_host_template driver_template = {
65 .name = "MVME16x NCR53c710 SCSI", 65 .name = "MVME16x NCR53c710 SCSI",
66 .detect = mvme16x_scsi_detect, 66 .detect = mvme16x_scsi_detect,
67 .release = mvme16x_scsi_release, 67 .release = mvme16x_scsi_release,
diff --git a/drivers/scsi/mvme16x.h b/drivers/scsi/mvme16x.h
index 25173c891d3c..c7a12533fb2c 100644
--- a/drivers/scsi/mvme16x.h
+++ b/drivers/scsi/mvme16x.h
@@ -3,7 +3,7 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6int mvme16x_scsi_detect(Scsi_Host_Template *); 6int mvme16x_scsi_detect(struct scsi_host_template *);
7const char *NCR53c7x0_info(void); 7const char *NCR53c7x0_info(void);
8int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 8int NCR53c7xx_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
9int NCR53c7xx_abort(Scsi_Cmnd *); 9int NCR53c7xx_abort(Scsi_Cmnd *);
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index e4ff4f00676d..a279ebb61447 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -198,7 +198,7 @@ static void __devexit nsp32_remove(struct pci_dev *);
198static int __init init_nsp32 (void); 198static int __init init_nsp32 (void);
199static void __exit exit_nsp32 (void); 199static void __exit exit_nsp32 (void);
200 200
201/* struct Scsi_Host_Template */ 201/* struct struct scsi_host_template */
202#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 202#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
203static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int); 203static int nsp32_proc_info (struct Scsi_Host *, char *, char **, off_t, int, int);
204#else 204#else
@@ -208,7 +208,7 @@ static int nsp32_proc_info (char *, char **, off_t, int, int, int);
208#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73)) 208#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,73))
209static int nsp32_detect (struct pci_dev *pdev); 209static int nsp32_detect (struct pci_dev *pdev);
210#else 210#else
211static int nsp32_detect (Scsi_Host_Template *); 211static int nsp32_detect (struct scsi_host_template *);
212#endif 212#endif
213static int nsp32_queuecommand(struct scsi_cmnd *, 213static int nsp32_queuecommand(struct scsi_cmnd *,
214 void (*done)(struct scsi_cmnd *)); 214 void (*done)(struct scsi_cmnd *));
@@ -2683,7 +2683,7 @@ static int nsp32_detect(struct pci_dev *pdev)
2683#define DETECT_OK 1 2683#define DETECT_OK 1
2684#define DETECT_NG 0 2684#define DETECT_NG 0
2685#define PCIDEV (data->Pci) 2685#define PCIDEV (data->Pci)
2686static int nsp32_detect(Scsi_Host_Template *sht) 2686static int nsp32_detect(struct scsi_host_template *sht)
2687#endif 2687#endif
2688{ 2688{
2689 struct Scsi_Host *host; /* registered host structure */ 2689 struct Scsi_Host *host; /* registered host structure */
diff --git a/drivers/scsi/oktagon_esp.c b/drivers/scsi/oktagon_esp.c
index 573d7ef93f08..5d9c9ada814f 100644
--- a/drivers/scsi/oktagon_esp.c
+++ b/drivers/scsi/oktagon_esp.c
@@ -114,7 +114,7 @@ static volatile unsigned char cmd_buffer[16];
114 */ 114 */
115 115
116/***************************************************************** Detection */ 116/***************************************************************** Detection */
117int oktagon_esp_detect(Scsi_Host_Template *tpnt) 117int oktagon_esp_detect(struct scsi_host_template *tpnt)
118{ 118{
119 struct NCR_ESP *esp; 119 struct NCR_ESP *esp;
120 struct zorro_dev *z = NULL; 120 struct zorro_dev *z = NULL;
@@ -585,7 +585,7 @@ int oktagon_esp_release(struct Scsi_Host *instance)
585} 585}
586 586
587 587
588static Scsi_Host_Template driver_template = { 588static struct scsi_host_template driver_template = {
589 .proc_name = "esp-oktagon", 589 .proc_name = "esp-oktagon",
590 .proc_info = &esp_proc_info, 590 .proc_info = &esp_proc_info,
591 .name = "BSC Oktagon SCSI", 591 .name = "BSC Oktagon SCSI",
diff --git a/drivers/scsi/pas16.c b/drivers/scsi/pas16.c
index 72bc947e45b6..f09e94af9ade 100644
--- a/drivers/scsi/pas16.c
+++ b/drivers/scsi/pas16.c
@@ -369,7 +369,7 @@ void __init pas16_setup(char *str, int *ints)
369} 369}
370 370
371/* 371/*
372 * Function : int pas16_detect(Scsi_Host_Template * tpnt) 372 * Function : int pas16_detect(struct scsi_host_template * tpnt)
373 * 373 *
374 * Purpose : detects and initializes PAS16 controllers 374 * Purpose : detects and initializes PAS16 controllers
375 * that were autoprobed, overridden on the LILO command line, 375 * that were autoprobed, overridden on the LILO command line,
@@ -381,7 +381,7 @@ void __init pas16_setup(char *str, int *ints)
381 * 381 *
382 */ 382 */
383 383
384int __init pas16_detect(Scsi_Host_Template * tpnt) 384int __init pas16_detect(struct scsi_host_template * tpnt)
385{ 385{
386 static int current_override = 0; 386 static int current_override = 0;
387 static unsigned short current_base = 0; 387 static unsigned short current_base = 0;
@@ -615,7 +615,7 @@ static int pas16_release(struct Scsi_Host *shost)
615 return 0; 615 return 0;
616} 616}
617 617
618static Scsi_Host_Template driver_template = { 618static struct scsi_host_template driver_template = {
619 .name = "Pro Audio Spectrum-16 SCSI", 619 .name = "Pro Audio Spectrum-16 SCSI",
620 .detect = pas16_detect, 620 .detect = pas16_detect,
621 .release = pas16_release, 621 .release = pas16_release,
diff --git a/drivers/scsi/pas16.h b/drivers/scsi/pas16.h
index 65ce1cc40d9a..8dc5b1a5f5da 100644
--- a/drivers/scsi/pas16.h
+++ b/drivers/scsi/pas16.h
@@ -117,7 +117,7 @@
117static int pas16_abort(Scsi_Cmnd *); 117static int pas16_abort(Scsi_Cmnd *);
118static int pas16_biosparam(struct scsi_device *, struct block_device *, 118static int pas16_biosparam(struct scsi_device *, struct block_device *,
119 sector_t, int*); 119 sector_t, int*);
120static int pas16_detect(Scsi_Host_Template *); 120static int pas16_detect(struct scsi_host_template *);
121static int pas16_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 121static int pas16_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
122static int pas16_bus_reset(Scsi_Cmnd *); 122static int pas16_bus_reset(Scsi_Cmnd *);
123 123
diff --git a/drivers/scsi/pci2000.h b/drivers/scsi/pci2000.h
index 6c962d7dca47..0ebd8ce9e1de 100644
--- a/drivers/scsi/pci2000.h
+++ b/drivers/scsi/pci2000.h
@@ -184,7 +184,7 @@ typedef struct _INQUIRYDATA
184#endif 184#endif
185 185
186// function prototypes 186// function prototypes
187int Pci2000_Detect (Scsi_Host_Template *tpnt); 187int Pci2000_Detect (struct scsi_host_template *tpnt);
188int Pci2000_Command (Scsi_Cmnd *SCpnt); 188int Pci2000_Command (Scsi_Cmnd *SCpnt);
189int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)); 189int Pci2000_QueueCommand (Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *));
190int Pci2000_Abort (Scsi_Cmnd *SCpnt); 190int Pci2000_Abort (Scsi_Cmnd *SCpnt);
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 3d2f71051fe5..050ea13ff80b 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -81,7 +81,7 @@ module_param(free_ports, bool, 0);
81MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0 (=no))"); 81MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0 (=no))");
82 82
83/* /usr/src/linux/drivers/scsi/hosts.h */ 83/* /usr/src/linux/drivers/scsi/hosts.h */
84static Scsi_Host_Template nsp_driver_template = { 84static struct scsi_host_template nsp_driver_template = {
85 .proc_name = "nsp_cs", 85 .proc_name = "nsp_cs",
86 .proc_info = nsp_proc_info, 86 .proc_info = nsp_proc_info,
87 .name = "WorkBit NinjaSCSI-3/32Bi(16bit)", 87 .name = "WorkBit NinjaSCSI-3/32Bi(16bit)",
@@ -1310,7 +1310,7 @@ timer_out:
1310/*----------------------------------------------------------------*/ 1310/*----------------------------------------------------------------*/
1311/* look for ninja3 card and init if found */ 1311/* look for ninja3 card and init if found */
1312/*----------------------------------------------------------------*/ 1312/*----------------------------------------------------------------*/
1313static struct Scsi_Host *nsp_detect(Scsi_Host_Template *sht) 1313static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht)
1314{ 1314{
1315 struct Scsi_Host *host; /* registered host structure */ 1315 struct Scsi_Host *host; /* registered host structure */
1316 nsp_hw_data *data_b = &nsp_data_base, *data; 1316 nsp_hw_data *data_b = &nsp_data_base, *data;
@@ -1358,7 +1358,7 @@ static struct Scsi_Host *nsp_detect(Scsi_Host_Template *sht)
1358} 1358}
1359 1359
1360#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) 1360#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
1361static int nsp_detect_old(Scsi_Host_Template *sht) 1361static int nsp_detect_old(struct scsi_host_template *sht)
1362{ 1362{
1363 if (nsp_detect(sht) == NULL) { 1363 if (nsp_detect(sht) == NULL) {
1364 return 0; 1364 return 0;
@@ -1717,7 +1717,7 @@ static void nsp_cs_config(dev_link_t *link)
1717 struct Scsi_Host *host; 1717 struct Scsi_Host *host;
1718 nsp_hw_data *data = &nsp_data_base; 1718 nsp_hw_data *data = &nsp_data_base;
1719#if !(LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74)) 1719#if !(LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74))
1720 Scsi_Device *dev; 1720 struct scsi_device *dev;
1721 dev_node_t **tail, *node; 1721 dev_node_t **tail, *node;
1722#endif 1722#endif
1723 1723
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index c201b52e063a..f8b943082717 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -303,9 +303,9 @@ static void nsp_cs_config (dev_link_t *link);
303static int nsp_cs_event (event_t event, int priority, event_callback_args_t *args); 303static int nsp_cs_event (event_t event, int priority, event_callback_args_t *args);
304 304
305/* Linux SCSI subsystem specific functions */ 305/* Linux SCSI subsystem specific functions */
306static struct Scsi_Host *nsp_detect (Scsi_Host_Template *sht); 306static struct Scsi_Host *nsp_detect (struct scsi_host_template *sht);
307#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) 307#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
308static int nsp_detect_old (Scsi_Host_Template *sht); 308static int nsp_detect_old (struct scsi_host_template *sht);
309static int nsp_release_old(struct Scsi_Host *shpnt); 309static int nsp_release_old(struct Scsi_Host *shpnt);
310#endif 310#endif
311static const char *nsp_info (struct Scsi_Host *shpnt); 311static const char *nsp_info (struct Scsi_Host *shpnt);
@@ -345,7 +345,7 @@ static int nsp_expect_signal (Scsi_Cmnd *SCpnt, unsigned char current_phase,
345static int nsp_xfer (Scsi_Cmnd *SCpnt, int phase); 345static int nsp_xfer (Scsi_Cmnd *SCpnt, int phase);
346static int nsp_dataphase_bypass (Scsi_Cmnd *SCpnt); 346static int nsp_dataphase_bypass (Scsi_Cmnd *SCpnt);
347static int nsp_reselected (Scsi_Cmnd *SCpnt); 347static int nsp_reselected (Scsi_Cmnd *SCpnt);
348static struct Scsi_Host *nsp_detect(Scsi_Host_Template *sht); 348static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht);
349 349
350/* Interrupt handler */ 350/* Interrupt handler */
351//static irqreturn_t nspintr(int irq, void *dev_id, struct pt_regs *regs); 351//static irqreturn_t nspintr(int irq, void *dev_id, struct pt_regs *regs);
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 7a516f35834e..bb091a45a880 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -72,7 +72,7 @@ static char *version = "qlogic_cs.c 1.79-ac 2002/10/26 (David Hinds)";
72#define DEBUG(n, args...) 72#define DEBUG(n, args...)
73#endif 73#endif
74 74
75static Scsi_Host_Template qlogicfas_driver_template = { 75static struct scsi_host_template qlogicfas_driver_template = {
76 .module = THIS_MODULE, 76 .module = THIS_MODULE,
77 .name = qlogic_name, 77 .name = qlogic_name,
78 .proc_name = qlogic_name, 78 .proc_name = qlogic_name,
@@ -108,7 +108,7 @@ static dev_link_t *dev_list = NULL;
108 108
109static dev_info_t dev_info = "qlogic_cs"; 109static dev_info_t dev_info = "qlogic_cs";
110 110
111static struct Scsi_Host *qlogic_detect(Scsi_Host_Template *host, 111static struct Scsi_Host *qlogic_detect(struct scsi_host_template *host,
112 dev_link_t *link, int qbase, int qlirq) 112 dev_link_t *link, int qbase, int qlirq)
113{ 113{
114 int qltyp; /* type of chip */ 114 int qltyp; /* type of chip */
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index 78b4ff117af6..f557f17ca00c 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -190,7 +190,7 @@ static struct ata_port_info adma_port_info[] = {
190 }, 190 },
191}; 191};
192 192
193static struct pci_device_id adma_ata_pci_tbl[] = { 193static const struct pci_device_id adma_ata_pci_tbl[] = {
194 { PCI_VENDOR_ID_PDC, 0x1841, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 194 { PCI_VENDOR_ID_PDC, 0x1841, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
195 board_1841_idx }, 195 board_1841_idx },
196 196
diff --git a/drivers/scsi/pluto.c b/drivers/scsi/pluto.c
index c89da7d5b6df..46624ab9c3d2 100644
--- a/drivers/scsi/pluto.c
+++ b/drivers/scsi/pluto.c
@@ -71,7 +71,7 @@ static void __init pluto_detect_scsi_done(Scsi_Cmnd *SCpnt)
71 up(&fc_sem); 71 up(&fc_sem);
72} 72}
73 73
74int pluto_slave_configure(Scsi_Device *device) 74int pluto_slave_configure(struct scsi_device *device)
75{ 75{
76 int depth_to_use; 76 int depth_to_use;
77 77
@@ -90,11 +90,11 @@ int pluto_slave_configure(Scsi_Device *device)
90 90
91/* Detect all SSAs attached to the machine. 91/* Detect all SSAs attached to the machine.
92 To be fast, do it on all online FC channels at the same time. */ 92 To be fast, do it on all online FC channels at the same time. */
93int __init pluto_detect(Scsi_Host_Template *tpnt) 93int __init pluto_detect(struct scsi_host_template *tpnt)
94{ 94{
95 int i, retry, nplutos; 95 int i, retry, nplutos;
96 fc_channel *fc; 96 fc_channel *fc;
97 Scsi_Device dev; 97 struct scsi_device dev;
98 DEFINE_TIMER(fc_timer, pluto_detect_timeout, 0, 0); 98 DEFINE_TIMER(fc_timer, pluto_detect_timeout, 0, 0);
99 99
100 tpnt->proc_name = "pluto"; 100 tpnt->proc_name = "pluto";
@@ -339,7 +339,7 @@ static int pluto_encode_addr(Scsi_Cmnd *SCpnt, u16 *addr, fc_channel *fc, fcp_cm
339 return 0; 339 return 0;
340} 340}
341 341
342static Scsi_Host_Template driver_template = { 342static struct scsi_host_template driver_template = {
343 .name = "Sparc Storage Array 100/200", 343 .name = "Sparc Storage Array 100/200",
344 .detect = pluto_detect, 344 .detect = pluto_detect,
345 .release = pluto_release, 345 .release = pluto_release,
diff --git a/drivers/scsi/pluto.h b/drivers/scsi/pluto.h
index beb844aafccd..5da20616ac36 100644
--- a/drivers/scsi/pluto.h
+++ b/drivers/scsi/pluto.h
@@ -38,10 +38,10 @@ struct pluto_inquiry {
38/* This is the max number of outstanding SCSI commands per pluto */ 38/* This is the max number of outstanding SCSI commands per pluto */
39#define PLUTO_CAN_QUEUE 254 39#define PLUTO_CAN_QUEUE 254
40 40
41int pluto_detect(Scsi_Host_Template *); 41int pluto_detect(struct scsi_host_template *);
42int pluto_release(struct Scsi_Host *); 42int pluto_release(struct Scsi_Host *);
43const char * pluto_info(struct Scsi_Host *); 43const char * pluto_info(struct Scsi_Host *);
44int pluto_slave_configure(Scsi_Device *); 44int pluto_slave_configure(struct scsi_device *);
45 45
46#endif /* !(_PLUTO_H) */ 46#endif /* !(_PLUTO_H) */
47 47
diff --git a/drivers/scsi/psi240i.c b/drivers/scsi/psi240i.c
index 4322c95c995c..5c2cdf523c3b 100644
--- a/drivers/scsi/psi240i.c
+++ b/drivers/scsi/psi240i.c
@@ -538,7 +538,7 @@ static void ReadChipMemory (void *pdata, USHORT base, USHORT length, USHORT port
538 * Returns: Number of adapters found. 538 * Returns: Number of adapters found.
539 * 539 *
540 ****************************************************************/ 540 ****************************************************************/
541static int Psi240i_Detect (Scsi_Host_Template *tpnt) 541static int Psi240i_Detect (struct scsi_host_template *tpnt)
542 { 542 {
543 int board; 543 int board;
544 int count = 0; 544 int count = 0;
@@ -669,7 +669,7 @@ static int Psi240i_BiosParam (struct scsi_device *sdev, struct block_device *dev
669 669
670MODULE_LICENSE("GPL"); 670MODULE_LICENSE("GPL");
671 671
672static Scsi_Host_Template driver_template = { 672static struct scsi_host_template driver_template = {
673 .proc_name = "psi240i", 673 .proc_name = "psi240i",
674 .name = "PSI-240I EIDE Disk Controller", 674 .name = "PSI-240I EIDE Disk Controller",
675 .detect = Psi240i_Detect, 675 .detect = Psi240i_Detect,
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 637fb6565d28..0878f95b5449 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -465,7 +465,7 @@ scsi_adjust_queue_depth(struct scsi_device *device, int tag, int depth)
465 } 465 }
466 device->queue_depth = depth; 466 device->queue_depth = depth;
467} 467}
468static inline struct Scsi_Host *scsi_host_alloc(Scsi_Host_Template *t, size_t s) 468static inline struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *t, size_t s)
469{ 469{
470 return scsi_register(t, s); 470 return scsi_register(t, s);
471} 471}
@@ -639,10 +639,8 @@ struct qla_boards {
639static struct pci_device_id qla1280_pci_tbl[] = { 639static struct pci_device_id qla1280_pci_tbl[] = {
640 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP12160, 640 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP12160,
641 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 641 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
642#ifdef CONFIG_SCSI_QLOGIC_1280_1040
643 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020, 642 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020,
644 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 643 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
645#endif
646 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1080, 644 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1080,
647 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 645 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
648 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1240, 646 {PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1240,
@@ -1177,7 +1175,7 @@ qla1280_biosparam(struct scsi_device *sdev, struct block_device *bdev,
1177 1175
1178#if LINUX_VERSION_CODE < 0x020600 1176#if LINUX_VERSION_CODE < 0x020600
1179static int 1177static int
1180qla1280_detect(Scsi_Host_Template *template) 1178qla1280_detect(struct scsi_host_template *template)
1181{ 1179{
1182 struct pci_device_id *id = &qla1280_pci_tbl[0]; 1180 struct pci_device_id *id = &qla1280_pci_tbl[0];
1183 struct pci_dev *pdev = NULL; 1181 struct pci_dev *pdev = NULL;
@@ -4507,7 +4505,7 @@ static struct scsi_host_template qla1280_driver_template = {
4507 .use_clustering = ENABLE_CLUSTERING, 4505 .use_clustering = ENABLE_CLUSTERING,
4508}; 4506};
4509#else 4507#else
4510static Scsi_Host_Template qla1280_driver_template = { 4508static struct scsi_host_template qla1280_driver_template = {
4511 .proc_name = "qla1280", 4509 .proc_name = "qla1280",
4512 .name = "Qlogic ISP 1280/12160", 4510 .name = "Qlogic ISP 1280/12160",
4513 .detect = qla1280_detect, 4511 .detect = qla1280_detect,
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 89793c1c06b1..5c5d2315cfab 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -970,7 +970,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
970 int rval; 970 int rval;
971 uint32_t cnt, timer; 971 uint32_t cnt, timer;
972 uint32_t risc_address; 972 uint32_t risc_address;
973 uint16_t mb[4]; 973 uint16_t mb[4], wd;
974 974
975 uint32_t stat; 975 uint32_t stat;
976 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 976 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
@@ -1514,10 +1514,10 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1514 1514
1515 WRT_REG_DWORD(&reg->ctrl_status, 1515 WRT_REG_DWORD(&reg->ctrl_status,
1516 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); 1516 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
1517 RD_REG_DWORD(&reg->ctrl_status); 1517 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
1518 1518
1519 udelay(100);
1519 /* Wait for firmware to complete NVRAM accesses. */ 1520 /* Wait for firmware to complete NVRAM accesses. */
1520 udelay(5);
1521 mb[0] = (uint32_t) RD_REG_WORD(&reg->mailbox0); 1521 mb[0] = (uint32_t) RD_REG_WORD(&reg->mailbox0);
1522 for (cnt = 10000 ; cnt && mb[0]; cnt--) { 1522 for (cnt = 10000 ; cnt && mb[0]; cnt--) {
1523 udelay(5); 1523 udelay(5);
@@ -1525,7 +1525,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1525 barrier(); 1525 barrier();
1526 } 1526 }
1527 1527
1528 udelay(20); 1528 /* Wait for soft-reset to complete. */
1529 for (cnt = 0; cnt < 30000; cnt++) { 1529 for (cnt = 0; cnt < 30000; cnt++) {
1530 if ((RD_REG_DWORD(&reg->ctrl_status) & 1530 if ((RD_REG_DWORD(&reg->ctrl_status) &
1531 CSRX_ISP_SOFT_RESET) == 0) 1531 CSRX_ISP_SOFT_RESET) == 0)
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 7096945ea234..7b3efd531297 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -2476,17 +2476,9 @@ typedef struct scsi_qla_host {
2476 */ 2476 */
2477#define LOOP_TRANSITION(ha) \ 2477#define LOOP_TRANSITION(ha) \
2478 (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \ 2478 (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags) || \
2479 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) 2479 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) 2480 atomic_read(&ha->loop_state) == LOOP_DOWN)
2487 2481
2488#define LOOP_RDY(ha) (!LOOP_NOT_READY(ha))
2489
2490#define TGT_Q(ha, t) (ha->otgt[t]) 2482#define TGT_Q(ha, t) (ha->otgt[t])
2491 2483
2492#define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata) 2484#define to_qla_host(x) ((scsi_qla_host_t *) (x)->hostdata)
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 72d9090df3df..c46d2469b85f 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -147,8 +147,8 @@ check_fw_ready_again:
147 * LIP to complete 147 * LIP to complete
148 */ 148 */
149 149
150 if (atomic_read(&ha->loop_state) == 150 if (atomic_read(&ha->loop_state) !=
151 LOOP_DOWN && retry--) { 151 LOOP_READY && retry--) {
152 goto check_fw_ready_again; 152 goto check_fw_ready_again;
153 } 153 }
154 wait_time--; 154 wait_time--;
@@ -567,6 +567,7 @@ qla24xx_reset_risc(scsi_qla_host_t *ha)
567 unsigned long flags = 0; 567 unsigned long flags = 0;
568 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 568 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
569 uint32_t cnt, d2; 569 uint32_t cnt, d2;
570 uint16_t wd;
570 571
571 spin_lock_irqsave(&ha->hardware_lock, flags); 572 spin_lock_irqsave(&ha->hardware_lock, flags);
572 573
@@ -581,10 +582,10 @@ qla24xx_reset_risc(scsi_qla_host_t *ha)
581 582
582 WRT_REG_DWORD(&reg->ctrl_status, 583 WRT_REG_DWORD(&reg->ctrl_status,
583 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); 584 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
584 RD_REG_DWORD(&reg->ctrl_status); 585 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
585 586
587 udelay(100);
586 /* Wait for firmware to complete NVRAM accesses. */ 588 /* Wait for firmware to complete NVRAM accesses. */
587 udelay(5);
588 d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0); 589 d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
589 for (cnt = 10000 ; cnt && d2; cnt--) { 590 for (cnt = 10000 ; cnt && d2; cnt--) {
590 udelay(5); 591 udelay(5);
@@ -592,7 +593,7 @@ qla24xx_reset_risc(scsi_qla_host_t *ha)
592 barrier(); 593 barrier();
593 } 594 }
594 595
595 udelay(20); 596 /* Wait for soft-reset to complete. */
596 d2 = RD_REG_DWORD(&reg->ctrl_status); 597 d2 = RD_REG_DWORD(&reg->ctrl_status);
597 for (cnt = 6000000 ; cnt && (d2 & CSRX_ISP_SOFT_RESET); cnt--) { 598 for (cnt = 6000000 ; cnt && (d2 & CSRX_ISP_SOFT_RESET); cnt--) {
598 udelay(5); 599 udelay(5);
@@ -1258,9 +1259,15 @@ qla2x00_configure_hba(scsi_qla_host_t *ha)
1258 rval = qla2x00_get_adapter_id(ha, 1259 rval = qla2x00_get_adapter_id(ha,
1259 &loop_id, &al_pa, &area, &domain, &topo); 1260 &loop_id, &al_pa, &area, &domain, &topo);
1260 if (rval != QLA_SUCCESS) { 1261 if (rval != QLA_SUCCESS) {
1261 qla_printk(KERN_WARNING, ha, 1262 if (LOOP_TRANSITION(ha) || atomic_read(&ha->loop_down_timer) ||
1262 "ERROR -- Unable to get host loop ID.\n"); 1263 (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) {
1263 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 1264 DEBUG2(printk("%s(%ld) Loop is in a transition state\n",
1265 __func__, ha->host_no));
1266 } else {
1267 qla_printk(KERN_WARNING, ha,
1268 "ERROR -- Unable to get host loop ID.\n");
1269 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1270 }
1264 return (rval); 1271 return (rval);
1265 } 1272 }
1266 1273
@@ -1789,7 +1796,7 @@ qla2x00_configure_loop(scsi_qla_host_t *ha)
1789 } 1796 }
1790 1797
1791 if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) { 1798 if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) {
1792 if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { 1799 if (LOOP_TRANSITION(ha)) {
1793 rval = QLA_FUNCTION_FAILED; 1800 rval = QLA_FUNCTION_FAILED;
1794 } else { 1801 } else {
1795 rval = qla2x00_configure_fabric(ha); 1802 rval = qla2x00_configure_fabric(ha);
@@ -2362,8 +2369,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2362 if (qla2x00_is_reserved_id(ha, loop_id)) 2369 if (qla2x00_is_reserved_id(ha, loop_id))
2363 continue; 2370 continue;
2364 2371
2365 if (atomic_read(&ha->loop_down_timer) || 2372 if (atomic_read(&ha->loop_down_timer) || LOOP_TRANSITION(ha))
2366 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
2367 break; 2373 break;
2368 2374
2369 if (swl != NULL) { 2375 if (swl != NULL) {
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_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index ad3cacb9192d..9746cd1e664b 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -868,10 +868,6 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp)
868 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);) 868 DEBUG11(printk("qla2x00_abort_command(%ld): entered.\n", ha->host_no);)
869 869
870 fcport = sp->fcport; 870 fcport = sp->fcport;
871 if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
872 atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
873 return 1;
874 }
875 871
876 spin_lock_irqsave(&ha->hardware_lock, flags); 872 spin_lock_irqsave(&ha->hardware_lock, flags);
877 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 873 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
@@ -1008,6 +1004,8 @@ qla2x00_get_adapter_id(scsi_qla_host_t *ha, uint16_t *id, uint8_t *al_pa,
1008 mcp->tov = 30; 1004 mcp->tov = 30;
1009 mcp->flags = 0; 1005 mcp->flags = 0;
1010 rval = qla2x00_mailbox_command(ha, mcp); 1006 rval = qla2x00_mailbox_command(ha, mcp);
1007 if (mcp->mb[0] == MBS_COMMAND_ERROR)
1008 rval = QLA_COMMAND_ERROR;
1011 1009
1012 /* Return data. */ 1010 /* Return data. */
1013 *id = mcp->mb[1]; 1011 *id = mcp->mb[1];
@@ -2179,10 +2177,6 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp)
2179 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);) 2177 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no);)
2180 2178
2181 fcport = sp->fcport; 2179 fcport = sp->fcport;
2182 if (atomic_read(&ha->loop_state) == LOOP_DOWN ||
2183 atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
2184 return QLA_FUNCTION_FAILED;
2185 }
2186 2180
2187 spin_lock_irqsave(&ha->hardware_lock, flags); 2181 spin_lock_irqsave(&ha->hardware_lock, flags);
2188 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { 2182 for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) {
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 4bec0b4fb6b4..d54d2a99c3d3 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -126,6 +126,7 @@ qla2x00_write_nvram_word(scsi_qla_host_t *ha, uint32_t addr, uint16_t data)
126 126
127 /* Wait for NVRAM to become ready */ 127 /* Wait for NVRAM to become ready */
128 WRT_REG_WORD(&reg->nvram, NVR_SELECT); 128 WRT_REG_WORD(&reg->nvram, NVR_SELECT);
129 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
129 do { 130 do {
130 NVRAM_DELAY(); 131 NVRAM_DELAY();
131 word = RD_REG_WORD(&reg->nvram); 132 word = RD_REG_WORD(&reg->nvram);
@@ -178,6 +179,7 @@ qla2x00_write_nvram_word_tmo(scsi_qla_host_t *ha, uint32_t addr, uint16_t data,
178 179
179 /* Wait for NVRAM to become ready */ 180 /* Wait for NVRAM to become ready */
180 WRT_REG_WORD(&reg->nvram, NVR_SELECT); 181 WRT_REG_WORD(&reg->nvram, NVR_SELECT);
182 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
181 do { 183 do {
182 NVRAM_DELAY(); 184 NVRAM_DELAY();
183 word = RD_REG_WORD(&reg->nvram); 185 word = RD_REG_WORD(&reg->nvram);
@@ -235,6 +237,7 @@ qla2x00_nvram_request(scsi_qla_host_t *ha, uint32_t nv_cmd)
235 /* Read data from NVRAM. */ 237 /* Read data from NVRAM. */
236 for (cnt = 0; cnt < 16; cnt++) { 238 for (cnt = 0; cnt < 16; cnt++) {
237 WRT_REG_WORD(&reg->nvram, NVR_SELECT | NVR_CLOCK); 239 WRT_REG_WORD(&reg->nvram, NVR_SELECT | NVR_CLOCK);
240 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
238 NVRAM_DELAY(); 241 NVRAM_DELAY();
239 data <<= 1; 242 data <<= 1;
240 reg_data = RD_REG_WORD(&reg->nvram); 243 reg_data = RD_REG_WORD(&reg->nvram);
@@ -337,6 +340,7 @@ qla2x00_clear_nvram_protection(scsi_qla_host_t *ha)
337 340
338 /* Wait for NVRAM to become ready. */ 341 /* Wait for NVRAM to become ready. */
339 WRT_REG_WORD(&reg->nvram, NVR_SELECT); 342 WRT_REG_WORD(&reg->nvram, NVR_SELECT);
343 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
340 do { 344 do {
341 NVRAM_DELAY(); 345 NVRAM_DELAY();
342 word = RD_REG_WORD(&reg->nvram); 346 word = RD_REG_WORD(&reg->nvram);
@@ -388,6 +392,7 @@ qla2x00_set_nvram_protection(scsi_qla_host_t *ha, int stat)
388 392
389 /* Wait for NVRAM to become ready. */ 393 /* Wait for NVRAM to become ready. */
390 WRT_REG_WORD(&reg->nvram, NVR_SELECT); 394 WRT_REG_WORD(&reg->nvram, NVR_SELECT);
395 RD_REG_WORD(&reg->nvram); /* PCI Posting. */
391 do { 396 do {
392 NVRAM_DELAY(); 397 NVRAM_DELAY();
393 word = RD_REG_WORD(&reg->nvram); 398 word = RD_REG_WORD(&reg->nvram);
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index 0d5472f2f59b..f7937f7f9c68 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,9 +7,9 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.01.00-k" 10#define QLA2XXX_VERSION "8.01.03-k"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 1 13#define QLA_DRIVER_MINOR_VER 1
14#define QLA_DRIVER_PATCH_VER 0 14#define QLA_DRIVER_PATCH_VER 3
15#define QLA_DRIVER_BETA_VER 0 15#define QLA_DRIVER_BETA_VER 0
diff --git a/drivers/scsi/qlogicfas.c b/drivers/scsi/qlogicfas.c
index 55e698b651d6..94baca840efe 100644
--- a/drivers/scsi/qlogicfas.c
+++ b/drivers/scsi/qlogicfas.c
@@ -47,7 +47,7 @@ static char qlogicfas_name[] = "qlogicfas";
47 * Look for qlogic card and init if found 47 * Look for qlogic card and init if found
48 */ 48 */
49 49
50static struct Scsi_Host *__qlogicfas_detect(Scsi_Host_Template *host, 50static struct Scsi_Host *__qlogicfas_detect(struct scsi_host_template *host,
51 int qbase, 51 int qbase,
52 int qlirq) 52 int qlirq)
53{ 53{
@@ -142,7 +142,7 @@ module_param_array(irq, int, NULL, 0);
142MODULE_PARM_DESC(iobase, "I/O address"); 142MODULE_PARM_DESC(iobase, "I/O address");
143MODULE_PARM_DESC(irq, "IRQ"); 143MODULE_PARM_DESC(irq, "IRQ");
144 144
145static int __devinit qlogicfas_detect(Scsi_Host_Template *sht) 145static int __devinit qlogicfas_detect(struct scsi_host_template *sht)
146{ 146{
147 struct Scsi_Host *shost; 147 struct Scsi_Host *shost;
148 struct qlogicfas408_priv *priv; 148 struct qlogicfas408_priv *priv;
@@ -183,7 +183,7 @@ static int qlogicfas_release(struct Scsi_Host *shost)
183/* 183/*
184 * The driver template is also needed for PCMCIA 184 * The driver template is also needed for PCMCIA
185 */ 185 */
186static Scsi_Host_Template qlogicfas_driver_template = { 186static struct scsi_host_template qlogicfas_driver_template = {
187 .module = THIS_MODULE, 187 .module = THIS_MODULE,
188 .name = qlogicfas_name, 188 .name = qlogicfas_name,
189 .proc_name = qlogicfas_name, 189 .proc_name = qlogicfas_name,
diff --git a/drivers/scsi/qlogicfc.c b/drivers/scsi/qlogicfc.c
index a4b3b3fd4815..94ef3f08d378 100644
--- a/drivers/scsi/qlogicfc.c
+++ b/drivers/scsi/qlogicfc.c
@@ -711,7 +711,7 @@ static inline void isp2x00_disable_irqs(struct Scsi_Host *host)
711} 711}
712 712
713 713
714static int isp2x00_detect(Scsi_Host_Template * tmpt) 714static int isp2x00_detect(struct scsi_host_template * tmpt)
715{ 715{
716 int hosts = 0; 716 int hosts = 0;
717 unsigned long wait_time; 717 unsigned long wait_time;
@@ -2210,7 +2210,7 @@ void isp2x00_print_scsi_cmd(Scsi_Cmnd * cmd)
2210 2210
2211MODULE_LICENSE("GPL"); 2211MODULE_LICENSE("GPL");
2212 2212
2213static Scsi_Host_Template driver_template = { 2213static struct scsi_host_template driver_template = {
2214 .detect = isp2x00_detect, 2214 .detect = isp2x00_detect,
2215 .release = isp2x00_release, 2215 .release = isp2x00_release,
2216 .info = isp2x00_info, 2216 .info = isp2x00_info,
diff --git a/drivers/scsi/qlogicisp.c b/drivers/scsi/qlogicisp.c
deleted file mode 100644
index 6c9266b8ffdf..000000000000
--- a/drivers/scsi/qlogicisp.c
+++ /dev/null
@@ -1,1934 +0,0 @@
1/*
2 * QLogic ISP1020 Intelligent SCSI Processor Driver (PCI)
3 * Written by Erik H. Moe, ehm@cris.com
4 * Copyright 1995, Erik H. Moe
5 * Copyright 1996, 1997 Michael A. Griffith <grif@acm.org>
6 * Copyright 2000, Jayson C. Vantuyl <vantuyl@csc.smsu.edu>
7 * and Bryon W. Roche <bryon@csc.smsu.edu>
8 *
9 * 64-bit addressing added by Kanoj Sarcar <kanoj@sgi.com>
10 * and Leo Dagum <dagum@sgi.com>
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2, or (at your option) any
15 * later version.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 */
22
23#include <linux/blkdev.h>
24#include <linux/config.h>
25#include <linux/kernel.h>
26#include <linux/string.h>
27#include <linux/ioport.h>
28#include <linux/sched.h>
29#include <linux/types.h>
30#include <linux/pci.h>
31#include <linux/delay.h>
32#include <linux/unistd.h>
33#include <linux/spinlock.h>
34#include <linux/interrupt.h>
35#include <asm/io.h>
36#include <asm/irq.h>
37#include <asm/byteorder.h>
38#include "scsi.h"
39#include <scsi/scsi_host.h>
40
41/*
42 * With the qlogic interface, every queue slot can hold a SCSI
43 * command with up to 4 scatter/gather entries. If we need more
44 * than 4 entries, continuation entries can be used that hold
45 * another 7 entries each. Unlike for other drivers, this means
46 * that the maximum number of scatter/gather entries we can
47 * support at any given time is a function of the number of queue
48 * slots available. That is, host->can_queue and host->sg_tablesize
49 * are dynamic and _not_ independent. This all works fine because
50 * requests are queued serially and the scatter/gather limit is
51 * determined for each queue request anew.
52 */
53#define QLOGICISP_REQ_QUEUE_LEN 63 /* must be power of two - 1 */
54#define QLOGICISP_MAX_SG(ql) (4 + ((ql) > 0) ? 7*((ql) - 1) : 0)
55
56/* Configuration section *****************************************************/
57
58/* Set the following macro to 1 to reload the ISP1020's firmware. This is
59 the latest firmware provided by QLogic. This may be an earlier/later
60 revision than supplied by your board. */
61
62#define RELOAD_FIRMWARE 1
63
64/* Set the following macro to 1 to reload the ISP1020's defaults from nvram.
65 If you are not sure of your settings, leave this alone, the driver will
66 use a set of 'safe' defaults */
67
68#define USE_NVRAM_DEFAULTS 0
69
70/* Macros used for debugging */
71
72#define DEBUG_ISP1020 0
73#define DEBUG_ISP1020_INTR 0
74#define DEBUG_ISP1020_SETUP 0
75#define TRACE_ISP 0
76
77#define DEFAULT_LOOP_COUNT 1000000
78
79/* End Configuration section *************************************************/
80
81#include <linux/module.h>
82
83#if TRACE_ISP
84
85# define TRACE_BUF_LEN (32*1024)
86
87struct {
88 u_long next;
89 struct {
90 u_long time;
91 u_int index;
92 u_int addr;
93 u_char * name;
94 } buf[TRACE_BUF_LEN];
95} trace;
96
97#define TRACE(w, i, a) \
98{ \
99 unsigned long flags; \
100 \
101 trace.buf[trace.next].name = (w); \
102 trace.buf[trace.next].time = jiffies; \
103 trace.buf[trace.next].index = (i); \
104 trace.buf[trace.next].addr = (long) (a); \
105 trace.next = (trace.next + 1) & (TRACE_BUF_LEN - 1); \
106}
107
108#else
109# define TRACE(w, i, a)
110#endif
111
112#if DEBUG_ISP1020
113#define ENTER(x) printk("isp1020 : entering %s()\n", x);
114#define LEAVE(x) printk("isp1020 : leaving %s()\n", x);
115#define DEBUG(x) x
116#else
117#define ENTER(x)
118#define LEAVE(x)
119#define DEBUG(x)
120#endif /* DEBUG_ISP1020 */
121
122#if DEBUG_ISP1020_INTR
123#define ENTER_INTR(x) printk("isp1020 : entering %s()\n", x);
124#define LEAVE_INTR(x) printk("isp1020 : leaving %s()\n", x);
125#define DEBUG_INTR(x) x
126#else
127#define ENTER_INTR(x)
128#define LEAVE_INTR(x)
129#define DEBUG_INTR(x)
130#endif /* DEBUG ISP1020_INTR */
131
132#define ISP1020_REV_ID 1
133
134#define MAX_TARGETS 16
135#define MAX_LUNS 8
136
137/* host configuration and control registers */
138#define HOST_HCCR 0xc0 /* host command and control */
139
140/* pci bus interface registers */
141#define PCI_ID_LOW 0x00 /* vendor id */
142#define PCI_ID_HIGH 0x02 /* device id */
143#define ISP_CFG0 0x04 /* configuration register #0 */
144#define ISP_CFG0_HWMSK 0x000f /* Hardware revision mask */
145#define ISP_CFG0_1020 0x0001 /* ISP1020 */
146#define ISP_CFG0_1020A 0x0002 /* ISP1020A */
147#define ISP_CFG0_1040 0x0003 /* ISP1040 */
148#define ISP_CFG0_1040A 0x0004 /* ISP1040A */
149#define ISP_CFG0_1040B 0x0005 /* ISP1040B */
150#define ISP_CFG0_1040C 0x0006 /* ISP1040C */
151#define ISP_CFG1 0x06 /* configuration register #1 */
152#define ISP_CFG1_F128 0x0040 /* 128-byte FIFO threshold */
153#define ISP_CFG1_F64 0x0030 /* 128-byte FIFO threshold */
154#define ISP_CFG1_F32 0x0020 /* 128-byte FIFO threshold */
155#define ISP_CFG1_F16 0x0010 /* 128-byte FIFO threshold */
156#define ISP_CFG1_BENAB 0x0004 /* Global Bus burst enable */
157#define ISP_CFG1_SXP 0x0001 /* SXP register select */
158#define PCI_INTF_CTL 0x08 /* pci interface control */
159#define PCI_INTF_STS 0x0a /* pci interface status */
160#define PCI_SEMAPHORE 0x0c /* pci semaphore */
161#define PCI_NVRAM 0x0e /* pci nvram interface */
162#define CDMA_CONF 0x20 /* Command DMA Config */
163#define DDMA_CONF 0x40 /* Data DMA Config */
164#define DMA_CONF_SENAB 0x0008 /* SXP to DMA Data enable */
165#define DMA_CONF_RIRQ 0x0004 /* RISC interrupt enable */
166#define DMA_CONF_BENAB 0x0002 /* Bus burst enable */
167#define DMA_CONF_DIR 0x0001 /* DMA direction (0=fifo->host 1=host->fifo) */
168
169/* mailbox registers */
170#define MBOX0 0x70 /* mailbox 0 */
171#define MBOX1 0x72 /* mailbox 1 */
172#define MBOX2 0x74 /* mailbox 2 */
173#define MBOX3 0x76 /* mailbox 3 */
174#define MBOX4 0x78 /* mailbox 4 */
175#define MBOX5 0x7a /* mailbox 5 */
176#define MBOX6 0x7c /* mailbox 6 */
177#define MBOX7 0x7e /* mailbox 7 */
178
179/* mailbox command complete status codes */
180#define MBOX_COMMAND_COMPLETE 0x4000
181#define INVALID_COMMAND 0x4001
182#define HOST_INTERFACE_ERROR 0x4002
183#define TEST_FAILED 0x4003
184#define COMMAND_ERROR 0x4005
185#define COMMAND_PARAM_ERROR 0x4006
186
187/* async event status codes */
188#define ASYNC_SCSI_BUS_RESET 0x8001
189#define SYSTEM_ERROR 0x8002
190#define REQUEST_TRANSFER_ERROR 0x8003
191#define RESPONSE_TRANSFER_ERROR 0x8004
192#define REQUEST_QUEUE_WAKEUP 0x8005
193#define EXECUTION_TIMEOUT_RESET 0x8006
194
195#ifdef CONFIG_QL_ISP_A64
196#define IOCB_SEGS 2
197#define CONTINUATION_SEGS 5
198#define MAX_CONTINUATION_ENTRIES 254
199#else
200#define IOCB_SEGS 4
201#define CONTINUATION_SEGS 7
202#endif /* CONFIG_QL_ISP_A64 */
203
204struct Entry_header {
205 u_char entry_type;
206 u_char entry_cnt;
207 u_char sys_def_1;
208 u_char flags;
209};
210
211/* entry header type commands */
212#ifdef CONFIG_QL_ISP_A64
213#define ENTRY_COMMAND 9
214#define ENTRY_CONTINUATION 0xa
215#else
216#define ENTRY_COMMAND 1
217#define ENTRY_CONTINUATION 2
218#endif /* CONFIG_QL_ISP_A64 */
219
220#define ENTRY_STATUS 3
221#define ENTRY_MARKER 4
222#define ENTRY_EXTENDED_COMMAND 5
223
224/* entry header flag definitions */
225#define EFLAG_CONTINUATION 1
226#define EFLAG_BUSY 2
227#define EFLAG_BAD_HEADER 4
228#define EFLAG_BAD_PAYLOAD 8
229
230struct dataseg {
231 u_int d_base;
232#ifdef CONFIG_QL_ISP_A64
233 u_int d_base_hi;
234#endif
235 u_int d_count;
236};
237
238struct Command_Entry {
239 struct Entry_header hdr;
240 u_int handle;
241 u_char target_lun;
242 u_char target_id;
243 u_short cdb_length;
244 u_short control_flags;
245 u_short rsvd;
246 u_short time_out;
247 u_short segment_cnt;
248 u_char cdb[12];
249#ifdef CONFIG_QL_ISP_A64
250 u_int rsvd1;
251 u_int rsvd2;
252#endif
253 struct dataseg dataseg[IOCB_SEGS];
254};
255
256/* command entry control flag definitions */
257#define CFLAG_NODISC 0x01
258#define CFLAG_HEAD_TAG 0x02
259#define CFLAG_ORDERED_TAG 0x04
260#define CFLAG_SIMPLE_TAG 0x08
261#define CFLAG_TAR_RTN 0x10
262#define CFLAG_READ 0x20
263#define CFLAG_WRITE 0x40
264
265struct Ext_Command_Entry {
266 struct Entry_header hdr;
267 u_int handle;
268 u_char target_lun;
269 u_char target_id;
270 u_short cdb_length;
271 u_short control_flags;
272 u_short rsvd;
273 u_short time_out;
274 u_short segment_cnt;
275 u_char cdb[44];
276};
277
278struct Continuation_Entry {
279 struct Entry_header hdr;
280#ifndef CONFIG_QL_ISP_A64
281 u_int reserved;
282#endif
283 struct dataseg dataseg[CONTINUATION_SEGS];
284};
285
286struct Marker_Entry {
287 struct Entry_header hdr;
288 u_int reserved;
289 u_char target_lun;
290 u_char target_id;
291 u_char modifier;
292 u_char rsvd;
293 u_char rsvds[52];
294};
295
296/* marker entry modifier definitions */
297#define SYNC_DEVICE 0
298#define SYNC_TARGET 1
299#define SYNC_ALL 2
300
301struct Status_Entry {
302 struct Entry_header hdr;
303 u_int handle;
304 u_short scsi_status;
305 u_short completion_status;
306 u_short state_flags;
307 u_short status_flags;
308 u_short time;
309 u_short req_sense_len;
310 u_int residual;
311 u_char rsvd[8];
312 u_char req_sense_data[32];
313};
314
315/* status entry completion status definitions */
316#define CS_COMPLETE 0x0000
317#define CS_INCOMPLETE 0x0001
318#define CS_DMA_ERROR 0x0002
319#define CS_TRANSPORT_ERROR 0x0003
320#define CS_RESET_OCCURRED 0x0004
321#define CS_ABORTED 0x0005
322#define CS_TIMEOUT 0x0006
323#define CS_DATA_OVERRUN 0x0007
324#define CS_COMMAND_OVERRUN 0x0008
325#define CS_STATUS_OVERRUN 0x0009
326#define CS_BAD_MESSAGE 0x000a
327#define CS_NO_MESSAGE_OUT 0x000b
328#define CS_EXT_ID_FAILED 0x000c
329#define CS_IDE_MSG_FAILED 0x000d
330#define CS_ABORT_MSG_FAILED 0x000e
331#define CS_REJECT_MSG_FAILED 0x000f
332#define CS_NOP_MSG_FAILED 0x0010
333#define CS_PARITY_ERROR_MSG_FAILED 0x0011
334#define CS_DEVICE_RESET_MSG_FAILED 0x0012
335#define CS_ID_MSG_FAILED 0x0013
336#define CS_UNEXP_BUS_FREE 0x0014
337#define CS_DATA_UNDERRUN 0x0015
338
339/* status entry state flag definitions */
340#define SF_GOT_BUS 0x0100
341#define SF_GOT_TARGET 0x0200
342#define SF_SENT_CDB 0x0400
343#define SF_TRANSFERRED_DATA 0x0800
344#define SF_GOT_STATUS 0x1000
345#define SF_GOT_SENSE 0x2000
346
347/* status entry status flag definitions */
348#define STF_DISCONNECT 0x0001
349#define STF_SYNCHRONOUS 0x0002
350#define STF_PARITY_ERROR 0x0004
351#define STF_BUS_RESET 0x0008
352#define STF_DEVICE_RESET 0x0010
353#define STF_ABORTED 0x0020
354#define STF_TIMEOUT 0x0040
355#define STF_NEGOTIATION 0x0080
356
357/* interface control commands */
358#define ISP_RESET 0x0001
359#define ISP_EN_INT 0x0002
360#define ISP_EN_RISC 0x0004
361
362/* host control commands */
363#define HCCR_NOP 0x0000
364#define HCCR_RESET 0x1000
365#define HCCR_PAUSE 0x2000
366#define HCCR_RELEASE 0x3000
367#define HCCR_SINGLE_STEP 0x4000
368#define HCCR_SET_HOST_INTR 0x5000
369#define HCCR_CLEAR_HOST_INTR 0x6000
370#define HCCR_CLEAR_RISC_INTR 0x7000
371#define HCCR_BP_ENABLE 0x8000
372#define HCCR_BIOS_DISABLE 0x9000
373#define HCCR_TEST_MODE 0xf000
374
375#define RISC_BUSY 0x0004
376
377/* mailbox commands */
378#define MBOX_NO_OP 0x0000
379#define MBOX_LOAD_RAM 0x0001
380#define MBOX_EXEC_FIRMWARE 0x0002
381#define MBOX_DUMP_RAM 0x0003
382#define MBOX_WRITE_RAM_WORD 0x0004
383#define MBOX_READ_RAM_WORD 0x0005
384#define MBOX_MAILBOX_REG_TEST 0x0006
385#define MBOX_VERIFY_CHECKSUM 0x0007
386#define MBOX_ABOUT_FIRMWARE 0x0008
387#define MBOX_CHECK_FIRMWARE 0x000e
388#define MBOX_INIT_REQ_QUEUE 0x0010
389#define MBOX_INIT_RES_QUEUE 0x0011
390#define MBOX_EXECUTE_IOCB 0x0012
391#define MBOX_WAKE_UP 0x0013
392#define MBOX_STOP_FIRMWARE 0x0014
393#define MBOX_ABORT 0x0015
394#define MBOX_ABORT_DEVICE 0x0016
395#define MBOX_ABORT_TARGET 0x0017
396#define MBOX_BUS_RESET 0x0018
397#define MBOX_STOP_QUEUE 0x0019
398#define MBOX_START_QUEUE 0x001a
399#define MBOX_SINGLE_STEP_QUEUE 0x001b
400#define MBOX_ABORT_QUEUE 0x001c
401#define MBOX_GET_DEV_QUEUE_STATUS 0x001d
402#define MBOX_GET_FIRMWARE_STATUS 0x001f
403#define MBOX_GET_INIT_SCSI_ID 0x0020
404#define MBOX_GET_SELECT_TIMEOUT 0x0021
405#define MBOX_GET_RETRY_COUNT 0x0022
406#define MBOX_GET_TAG_AGE_LIMIT 0x0023
407#define MBOX_GET_CLOCK_RATE 0x0024
408#define MBOX_GET_ACT_NEG_STATE 0x0025
409#define MBOX_GET_ASYNC_DATA_SETUP_TIME 0x0026
410#define MBOX_GET_PCI_PARAMS 0x0027
411#define MBOX_GET_TARGET_PARAMS 0x0028
412#define MBOX_GET_DEV_QUEUE_PARAMS 0x0029
413#define MBOX_SET_INIT_SCSI_ID 0x0030
414#define MBOX_SET_SELECT_TIMEOUT 0x0031
415#define MBOX_SET_RETRY_COUNT 0x0032
416#define MBOX_SET_TAG_AGE_LIMIT 0x0033
417#define MBOX_SET_CLOCK_RATE 0x0034
418#define MBOX_SET_ACTIVE_NEG_STATE 0x0035
419#define MBOX_SET_ASYNC_DATA_SETUP_TIME 0x0036
420#define MBOX_SET_PCI_CONTROL_PARAMS 0x0037
421#define MBOX_SET_TARGET_PARAMS 0x0038
422#define MBOX_SET_DEV_QUEUE_PARAMS 0x0039
423#define MBOX_RETURN_BIOS_BLOCK_ADDR 0x0040
424#define MBOX_WRITE_FOUR_RAM_WORDS 0x0041
425#define MBOX_EXEC_BIOS_IOCB 0x0042
426
427#ifdef CONFIG_QL_ISP_A64
428#define MBOX_CMD_INIT_REQUEST_QUEUE_64 0x0052
429#define MBOX_CMD_INIT_RESPONSE_QUEUE_64 0x0053
430#endif /* CONFIG_QL_ISP_A64 */
431
432#include "qlogicisp_asm.c"
433
434#define PACKB(a, b) (((a)<<4)|(b))
435
436static const u_char mbox_param[] = {
437 PACKB(1, 1), /* MBOX_NO_OP */
438 PACKB(5, 5), /* MBOX_LOAD_RAM */
439 PACKB(2, 0), /* MBOX_EXEC_FIRMWARE */
440 PACKB(5, 5), /* MBOX_DUMP_RAM */
441 PACKB(3, 3), /* MBOX_WRITE_RAM_WORD */
442 PACKB(2, 3), /* MBOX_READ_RAM_WORD */
443 PACKB(6, 6), /* MBOX_MAILBOX_REG_TEST */
444 PACKB(2, 3), /* MBOX_VERIFY_CHECKSUM */
445 PACKB(1, 3), /* MBOX_ABOUT_FIRMWARE */
446 PACKB(0, 0), /* 0x0009 */
447 PACKB(0, 0), /* 0x000a */
448 PACKB(0, 0), /* 0x000b */
449 PACKB(0, 0), /* 0x000c */
450 PACKB(0, 0), /* 0x000d */
451 PACKB(1, 2), /* MBOX_CHECK_FIRMWARE */
452 PACKB(0, 0), /* 0x000f */
453 PACKB(5, 5), /* MBOX_INIT_REQ_QUEUE */
454 PACKB(6, 6), /* MBOX_INIT_RES_QUEUE */
455 PACKB(4, 4), /* MBOX_EXECUTE_IOCB */
456 PACKB(2, 2), /* MBOX_WAKE_UP */
457 PACKB(1, 6), /* MBOX_STOP_FIRMWARE */
458 PACKB(4, 4), /* MBOX_ABORT */
459 PACKB(2, 2), /* MBOX_ABORT_DEVICE */
460 PACKB(3, 3), /* MBOX_ABORT_TARGET */
461 PACKB(2, 2), /* MBOX_BUS_RESET */
462 PACKB(2, 3), /* MBOX_STOP_QUEUE */
463 PACKB(2, 3), /* MBOX_START_QUEUE */
464 PACKB(2, 3), /* MBOX_SINGLE_STEP_QUEUE */
465 PACKB(2, 3), /* MBOX_ABORT_QUEUE */
466 PACKB(2, 4), /* MBOX_GET_DEV_QUEUE_STATUS */
467 PACKB(0, 0), /* 0x001e */
468 PACKB(1, 3), /* MBOX_GET_FIRMWARE_STATUS */
469 PACKB(1, 2), /* MBOX_GET_INIT_SCSI_ID */
470 PACKB(1, 2), /* MBOX_GET_SELECT_TIMEOUT */
471 PACKB(1, 3), /* MBOX_GET_RETRY_COUNT */
472 PACKB(1, 2), /* MBOX_GET_TAG_AGE_LIMIT */
473 PACKB(1, 2), /* MBOX_GET_CLOCK_RATE */
474 PACKB(1, 2), /* MBOX_GET_ACT_NEG_STATE */
475 PACKB(1, 2), /* MBOX_GET_ASYNC_DATA_SETUP_TIME */
476 PACKB(1, 3), /* MBOX_GET_PCI_PARAMS */
477 PACKB(2, 4), /* MBOX_GET_TARGET_PARAMS */
478 PACKB(2, 4), /* MBOX_GET_DEV_QUEUE_PARAMS */
479 PACKB(0, 0), /* 0x002a */
480 PACKB(0, 0), /* 0x002b */
481 PACKB(0, 0), /* 0x002c */
482 PACKB(0, 0), /* 0x002d */
483 PACKB(0, 0), /* 0x002e */
484 PACKB(0, 0), /* 0x002f */
485 PACKB(2, 2), /* MBOX_SET_INIT_SCSI_ID */
486 PACKB(2, 2), /* MBOX_SET_SELECT_TIMEOUT */
487 PACKB(3, 3), /* MBOX_SET_RETRY_COUNT */
488 PACKB(2, 2), /* MBOX_SET_TAG_AGE_LIMIT */
489 PACKB(2, 2), /* MBOX_SET_CLOCK_RATE */
490 PACKB(2, 2), /* MBOX_SET_ACTIVE_NEG_STATE */
491 PACKB(2, 2), /* MBOX_SET_ASYNC_DATA_SETUP_TIME */
492 PACKB(3, 3), /* MBOX_SET_PCI_CONTROL_PARAMS */
493 PACKB(4, 4), /* MBOX_SET_TARGET_PARAMS */
494 PACKB(4, 4), /* MBOX_SET_DEV_QUEUE_PARAMS */
495 PACKB(0, 0), /* 0x003a */
496 PACKB(0, 0), /* 0x003b */
497 PACKB(0, 0), /* 0x003c */
498 PACKB(0, 0), /* 0x003d */
499 PACKB(0, 0), /* 0x003e */
500 PACKB(0, 0), /* 0x003f */
501 PACKB(1, 2), /* MBOX_RETURN_BIOS_BLOCK_ADDR */
502 PACKB(6, 1), /* MBOX_WRITE_FOUR_RAM_WORDS */
503 PACKB(2, 3) /* MBOX_EXEC_BIOS_IOCB */
504#ifdef CONFIG_QL_ISP_A64
505 ,PACKB(0, 0), /* 0x0043 */
506 PACKB(0, 0), /* 0x0044 */
507 PACKB(0, 0), /* 0x0045 */
508 PACKB(0, 0), /* 0x0046 */
509 PACKB(0, 0), /* 0x0047 */
510 PACKB(0, 0), /* 0x0048 */
511 PACKB(0, 0), /* 0x0049 */
512 PACKB(0, 0), /* 0x004a */
513 PACKB(0, 0), /* 0x004b */
514 PACKB(0, 0), /* 0x004c */
515 PACKB(0, 0), /* 0x004d */
516 PACKB(0, 0), /* 0x004e */
517 PACKB(0, 0), /* 0x004f */
518 PACKB(0, 0), /* 0x0050 */
519 PACKB(0, 0), /* 0x0051 */
520 PACKB(8, 8), /* MBOX_CMD_INIT_REQUEST_QUEUE_64 (0x0052) */
521 PACKB(8, 8) /* MBOX_CMD_INIT_RESPONSE_QUEUE_64 (0x0053) */
522#endif /* CONFIG_QL_ISP_A64 */
523};
524
525#define MAX_MBOX_COMMAND (sizeof(mbox_param)/sizeof(u_short))
526
527struct host_param {
528 u_short fifo_threshold;
529 u_short host_adapter_enable;
530 u_short initiator_scsi_id;
531 u_short bus_reset_delay;
532 u_short retry_count;
533 u_short retry_delay;
534 u_short async_data_setup_time;
535 u_short req_ack_active_negation;
536 u_short data_line_active_negation;
537 u_short data_dma_burst_enable;
538 u_short command_dma_burst_enable;
539 u_short tag_aging;
540 u_short selection_timeout;
541 u_short max_queue_depth;
542};
543
544/*
545 * Device Flags:
546 *
547 * Bit Name
548 * ---------
549 * 7 Disconnect Privilege
550 * 6 Parity Checking
551 * 5 Wide Data Transfers
552 * 4 Synchronous Data Transfers
553 * 3 Tagged Queuing
554 * 2 Automatic Request Sense
555 * 1 Stop Queue on Check Condition
556 * 0 Renegotiate on Error
557 */
558
559struct dev_param {
560 u_short device_flags;
561 u_short execution_throttle;
562 u_short synchronous_period;
563 u_short synchronous_offset;
564 u_short device_enable;
565 u_short reserved; /* pad */
566};
567
568/*
569 * The result queue can be quite a bit smaller since continuation entries
570 * do not show up there:
571 */
572#define RES_QUEUE_LEN ((QLOGICISP_REQ_QUEUE_LEN + 1) / 8 - 1)
573#define QUEUE_ENTRY_LEN 64
574#define QSIZE(entries) (((entries) + 1) * QUEUE_ENTRY_LEN)
575
576struct isp_queue_entry {
577 char __opaque[QUEUE_ENTRY_LEN];
578};
579
580struct isp1020_hostdata {
581 void __iomem *memaddr;
582 u_char revision;
583 struct host_param host_param;
584 struct dev_param dev_param[MAX_TARGETS];
585 struct pci_dev *pci_dev;
586
587 struct isp_queue_entry *res_cpu; /* CPU-side address of response queue. */
588 struct isp_queue_entry *req_cpu; /* CPU-size address of request queue. */
589
590 /* result and request queues (shared with isp1020): */
591 u_int req_in_ptr; /* index of next request slot */
592 u_int res_out_ptr; /* index of next result slot */
593
594 /* this is here so the queues are nicely aligned */
595 long send_marker; /* do we need to send a marker? */
596
597 /* The cmd->handle has a fixed size, and is only 32-bits. We
598 * need to take care to handle 64-bit systems correctly thus what
599 * we actually place in cmd->handle is an index to the following
600 * table. Kudos to Matt Jacob for the technique. -DaveM
601 */
602 Scsi_Cmnd *cmd_slots[QLOGICISP_REQ_QUEUE_LEN + 1];
603
604 dma_addr_t res_dma; /* PCI side view of response queue */
605 dma_addr_t req_dma; /* PCI side view of request queue */
606};
607
608/* queue length's _must_ be power of two: */
609#define QUEUE_DEPTH(in, out, ql) ((in - out) & (ql))
610#define REQ_QUEUE_DEPTH(in, out) QUEUE_DEPTH(in, out, \
611 QLOGICISP_REQ_QUEUE_LEN)
612#define RES_QUEUE_DEPTH(in, out) QUEUE_DEPTH(in, out, RES_QUEUE_LEN)
613
614static void isp1020_enable_irqs(struct Scsi_Host *);
615static void isp1020_disable_irqs(struct Scsi_Host *);
616static int isp1020_init(struct Scsi_Host *);
617static int isp1020_reset_hardware(struct Scsi_Host *);
618static int isp1020_set_defaults(struct Scsi_Host *);
619static int isp1020_load_parameters(struct Scsi_Host *);
620static int isp1020_mbox_command(struct Scsi_Host *, u_short []);
621static int isp1020_return_status(struct Status_Entry *);
622static void isp1020_intr_handler(int, void *, struct pt_regs *);
623static irqreturn_t do_isp1020_intr_handler(int, void *, struct pt_regs *);
624
625#if USE_NVRAM_DEFAULTS
626static int isp1020_get_defaults(struct Scsi_Host *);
627static int isp1020_verify_nvram(struct Scsi_Host *);
628static u_short isp1020_read_nvram_word(struct Scsi_Host *, u_short);
629#endif
630
631#if DEBUG_ISP1020
632static void isp1020_print_scsi_cmd(Scsi_Cmnd *);
633#endif
634#if DEBUG_ISP1020_INTR
635static void isp1020_print_status_entry(struct Status_Entry *);
636#endif
637
638/* memaddr should be used to determine if memmapped port i/o is being used
639 * non-null memaddr == mmap'd
640 * JV 7-Jan-2000
641 */
642static inline u_short isp_inw(struct Scsi_Host *host, long offset)
643{
644 struct isp1020_hostdata *h = (struct isp1020_hostdata *)host->hostdata;
645 if (h->memaddr)
646 return readw(h->memaddr + offset);
647 else
648 return inw(host->io_port + offset);
649}
650
651static inline void isp_outw(u_short val, struct Scsi_Host *host, long offset)
652{
653 struct isp1020_hostdata *h = (struct isp1020_hostdata *)host->hostdata;
654 if (h->memaddr)
655 writew(val, h->memaddr + offset);
656 else
657 outw(val, host->io_port + offset);
658}
659
660static inline void isp1020_enable_irqs(struct Scsi_Host *host)
661{
662 isp_outw(ISP_EN_INT|ISP_EN_RISC, host, PCI_INTF_CTL);
663}
664
665
666static inline void isp1020_disable_irqs(struct Scsi_Host *host)
667{
668 isp_outw(0x0, host, PCI_INTF_CTL);
669}
670
671
672static int isp1020_detect(Scsi_Host_Template *tmpt)
673{
674 int hosts = 0;
675 struct Scsi_Host *host;
676 struct isp1020_hostdata *hostdata;
677 struct pci_dev *pdev = NULL;
678
679 ENTER("isp1020_detect");
680
681 tmpt->proc_name = "isp1020";
682
683 while ((pdev = pci_find_device(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020, pdev)))
684 {
685 if (pci_enable_device(pdev))
686 continue;
687
688 host = scsi_register(tmpt, sizeof(struct isp1020_hostdata));
689 if (!host)
690 continue;
691
692 hostdata = (struct isp1020_hostdata *) host->hostdata;
693
694 memset(hostdata, 0, sizeof(struct isp1020_hostdata));
695
696 hostdata->pci_dev = pdev;
697
698 if (isp1020_init(host))
699 goto fail_and_unregister;
700
701 if (isp1020_reset_hardware(host)
702#if USE_NVRAM_DEFAULTS
703 || isp1020_get_defaults(host)
704#else
705 || isp1020_set_defaults(host)
706#endif /* USE_NVRAM_DEFAULTS */
707 || isp1020_load_parameters(host)) {
708 goto fail_uninit;
709 }
710
711 host->this_id = hostdata->host_param.initiator_scsi_id;
712 host->max_sectors = 64;
713
714 if (request_irq(host->irq, do_isp1020_intr_handler, SA_INTERRUPT | SA_SHIRQ,
715 "qlogicisp", host))
716 {
717 printk("qlogicisp : interrupt %d already in use\n",
718 host->irq);
719 goto fail_uninit;
720 }
721
722 isp_outw(0x0, host, PCI_SEMAPHORE);
723 isp_outw(HCCR_CLEAR_RISC_INTR, host, HOST_HCCR);
724 isp1020_enable_irqs(host);
725
726 hosts++;
727 continue;
728
729 fail_uninit:
730 iounmap(hostdata->memaddr);
731 release_region(host->io_port, 0xff);
732 fail_and_unregister:
733 if (hostdata->res_cpu)
734 pci_free_consistent(hostdata->pci_dev,
735 QSIZE(RES_QUEUE_LEN),
736 hostdata->res_cpu,
737 hostdata->res_dma);
738 if (hostdata->req_cpu)
739 pci_free_consistent(hostdata->pci_dev,
740 QSIZE(QLOGICISP_REQ_QUEUE_LEN),
741 hostdata->req_cpu,
742 hostdata->req_dma);
743 scsi_unregister(host);
744 }
745
746 LEAVE("isp1020_detect");
747
748 return hosts;
749}
750
751
752static int isp1020_release(struct Scsi_Host *host)
753{
754 struct isp1020_hostdata *hostdata;
755
756 ENTER("isp1020_release");
757
758 hostdata = (struct isp1020_hostdata *) host->hostdata;
759
760 isp_outw(0x0, host, PCI_INTF_CTL);
761 free_irq(host->irq, host);
762
763 iounmap(hostdata->memaddr);
764
765 release_region(host->io_port, 0xff);
766
767 LEAVE("isp1020_release");
768
769 return 0;
770}
771
772
773static const char *isp1020_info(struct Scsi_Host *host)
774{
775 static char buf[80];
776 struct isp1020_hostdata *hostdata;
777
778 ENTER("isp1020_info");
779
780 hostdata = (struct isp1020_hostdata *) host->hostdata;
781 sprintf(buf,
782 "QLogic ISP1020 SCSI on PCI bus %02x device %02x irq %d %s base 0x%lx",
783 hostdata->pci_dev->bus->number, hostdata->pci_dev->devfn, host->irq,
784 (hostdata->memaddr ? "MEM" : "I/O"),
785 (hostdata->memaddr ? (unsigned long)hostdata->memaddr : host->io_port));
786
787 LEAVE("isp1020_info");
788
789 return buf;
790}
791
792
793/*
794 * The middle SCSI layer ensures that queuecommand never gets invoked
795 * concurrently with itself or the interrupt handler (though the
796 * interrupt handler may call this routine as part of
797 * request-completion handling).
798 */
799static int isp1020_queuecommand(Scsi_Cmnd *Cmnd, void (*done)(Scsi_Cmnd *))
800{
801 int i, n, num_free;
802 u_int in_ptr, out_ptr;
803 struct dataseg * ds;
804 struct scatterlist *sg;
805 struct Command_Entry *cmd;
806 struct Continuation_Entry *cont;
807 struct Scsi_Host *host;
808 struct isp1020_hostdata *hostdata;
809 dma_addr_t dma_addr;
810
811 ENTER("isp1020_queuecommand");
812
813 host = Cmnd->device->host;
814 hostdata = (struct isp1020_hostdata *) host->hostdata;
815 Cmnd->scsi_done = done;
816
817 DEBUG(isp1020_print_scsi_cmd(Cmnd));
818
819 out_ptr = isp_inw(host, + MBOX4);
820 in_ptr = hostdata->req_in_ptr;
821
822 DEBUG(printk("qlogicisp : request queue depth %d\n",
823 REQ_QUEUE_DEPTH(in_ptr, out_ptr)));
824
825 cmd = (struct Command_Entry *) &hostdata->req_cpu[in_ptr];
826 in_ptr = (in_ptr + 1) & QLOGICISP_REQ_QUEUE_LEN;
827 if (in_ptr == out_ptr) {
828 printk("qlogicisp : request queue overflow\n");
829 return 1;
830 }
831
832 if (hostdata->send_marker) {
833 struct Marker_Entry *marker;
834
835 TRACE("queue marker", in_ptr, 0);
836
837 DEBUG(printk("qlogicisp : adding marker entry\n"));
838 marker = (struct Marker_Entry *) cmd;
839 memset(marker, 0, sizeof(struct Marker_Entry));
840
841 marker->hdr.entry_type = ENTRY_MARKER;
842 marker->hdr.entry_cnt = 1;
843 marker->modifier = SYNC_ALL;
844
845 hostdata->send_marker = 0;
846
847 if (((in_ptr + 1) & QLOGICISP_REQ_QUEUE_LEN) == out_ptr) {
848 isp_outw(in_ptr, host, MBOX4);
849 hostdata->req_in_ptr = in_ptr;
850 printk("qlogicisp : request queue overflow\n");
851 return 1;
852 }
853 cmd = (struct Command_Entry *) &hostdata->req_cpu[in_ptr];
854 in_ptr = (in_ptr + 1) & QLOGICISP_REQ_QUEUE_LEN;
855 }
856
857 TRACE("queue command", in_ptr, Cmnd);
858
859 memset(cmd, 0, sizeof(struct Command_Entry));
860
861 cmd->hdr.entry_type = ENTRY_COMMAND;
862 cmd->hdr.entry_cnt = 1;
863
864 cmd->target_lun = Cmnd->device->lun;
865 cmd->target_id = Cmnd->device->id;
866 cmd->cdb_length = cpu_to_le16(Cmnd->cmd_len);
867 cmd->control_flags = cpu_to_le16(CFLAG_READ | CFLAG_WRITE);
868 cmd->time_out = cpu_to_le16(30);
869
870 memcpy(cmd->cdb, Cmnd->cmnd, Cmnd->cmd_len);
871
872 if (Cmnd->use_sg) {
873 int sg_count;
874
875 sg = (struct scatterlist *) Cmnd->request_buffer;
876 ds = cmd->dataseg;
877
878 sg_count = pci_map_sg(hostdata->pci_dev, sg, Cmnd->use_sg,
879 Cmnd->sc_data_direction);
880
881 cmd->segment_cnt = cpu_to_le16(sg_count);
882
883 /* fill in first four sg entries: */
884 n = sg_count;
885 if (n > IOCB_SEGS)
886 n = IOCB_SEGS;
887 for (i = 0; i < n; i++) {
888 dma_addr = sg_dma_address(sg);
889 ds[i].d_base = cpu_to_le32((u32) dma_addr);
890#ifdef CONFIG_QL_ISP_A64
891 ds[i].d_base_hi = cpu_to_le32((u32) (dma_addr>>32));
892#endif /* CONFIG_QL_ISP_A64 */
893 ds[i].d_count = cpu_to_le32(sg_dma_len(sg));
894 ++sg;
895 }
896 sg_count -= IOCB_SEGS;
897
898 while (sg_count > 0) {
899 ++cmd->hdr.entry_cnt;
900 cont = (struct Continuation_Entry *)
901 &hostdata->req_cpu[in_ptr];
902 in_ptr = (in_ptr + 1) & QLOGICISP_REQ_QUEUE_LEN;
903 if (in_ptr == out_ptr) {
904 printk("isp1020: unexpected request queue "
905 "overflow\n");
906 return 1;
907 }
908 TRACE("queue continuation", in_ptr, 0);
909 cont->hdr.entry_type = ENTRY_CONTINUATION;
910 cont->hdr.entry_cnt = 0;
911 cont->hdr.sys_def_1 = 0;
912 cont->hdr.flags = 0;
913#ifndef CONFIG_QL_ISP_A64
914 cont->reserved = 0;
915#endif
916 ds = cont->dataseg;
917 n = sg_count;
918 if (n > CONTINUATION_SEGS)
919 n = CONTINUATION_SEGS;
920 for (i = 0; i < n; ++i) {
921 dma_addr = sg_dma_address(sg);
922 ds[i].d_base = cpu_to_le32((u32) dma_addr);
923#ifdef CONFIG_QL_ISP_A64
924 ds[i].d_base_hi = cpu_to_le32((u32)(dma_addr>>32));
925#endif /* CONFIG_QL_ISP_A64 */
926 ds[i].d_count = cpu_to_le32(sg_dma_len(sg));
927 ++sg;
928 }
929 sg_count -= n;
930 }
931 } else if (Cmnd->request_bufflen) {
932 /*Cmnd->SCp.ptr = (char *)(unsigned long)*/
933 dma_addr = pci_map_single(hostdata->pci_dev,
934 Cmnd->request_buffer,
935 Cmnd->request_bufflen,
936 Cmnd->sc_data_direction);
937 Cmnd->SCp.ptr = (char *)(unsigned long) dma_addr;
938
939 cmd->dataseg[0].d_base =
940 cpu_to_le32((u32) dma_addr);
941#ifdef CONFIG_QL_ISP_A64
942 cmd->dataseg[0].d_base_hi =
943 cpu_to_le32((u32) (dma_addr>>32));
944#endif /* CONFIG_QL_ISP_A64 */
945 cmd->dataseg[0].d_count =
946 cpu_to_le32((u32)Cmnd->request_bufflen);
947 cmd->segment_cnt = cpu_to_le16(1);
948 } else {
949 cmd->dataseg[0].d_base = 0;
950#ifdef CONFIG_QL_ISP_A64
951 cmd->dataseg[0].d_base_hi = 0;
952#endif /* CONFIG_QL_ISP_A64 */
953 cmd->dataseg[0].d_count = 0;
954 cmd->segment_cnt = cpu_to_le16(1); /* Shouldn't this be 0? */
955 }
956
957 /* Committed, record Scsi_Cmd so we can find it later. */
958 cmd->handle = in_ptr;
959 hostdata->cmd_slots[in_ptr] = Cmnd;
960
961 isp_outw(in_ptr, host, MBOX4);
962 hostdata->req_in_ptr = in_ptr;
963
964 num_free = QLOGICISP_REQ_QUEUE_LEN - REQ_QUEUE_DEPTH(in_ptr, out_ptr);
965 host->can_queue = host->host_busy + num_free;
966 host->sg_tablesize = QLOGICISP_MAX_SG(num_free);
967
968 LEAVE("isp1020_queuecommand");
969
970 return 0;
971}
972
973
974#define ASYNC_EVENT_INTERRUPT 0x01
975
976irqreturn_t do_isp1020_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
977{
978 struct Scsi_Host *host = dev_id;
979 unsigned long flags;
980
981 spin_lock_irqsave(host->host_lock, flags);
982 isp1020_intr_handler(irq, dev_id, regs);
983 spin_unlock_irqrestore(host->host_lock, flags);
984
985 return IRQ_HANDLED;
986}
987
988void isp1020_intr_handler(int irq, void *dev_id, struct pt_regs *regs)
989{
990 Scsi_Cmnd *Cmnd;
991 struct Status_Entry *sts;
992 struct Scsi_Host *host = dev_id;
993 struct isp1020_hostdata *hostdata;
994 u_int in_ptr, out_ptr;
995 u_short status;
996
997 ENTER_INTR("isp1020_intr_handler");
998
999 hostdata = (struct isp1020_hostdata *) host->hostdata;
1000
1001 DEBUG_INTR(printk("qlogicisp : interrupt on line %d\n", irq));
1002
1003 if (!(isp_inw(host, PCI_INTF_STS) & 0x04)) {
1004 /* spurious interrupts can happen legally */
1005 DEBUG_INTR(printk("qlogicisp: got spurious interrupt\n"));
1006 return;
1007 }
1008 in_ptr = isp_inw(host, MBOX5);
1009 isp_outw(HCCR_CLEAR_RISC_INTR, host, HOST_HCCR);
1010
1011 if ((isp_inw(host, PCI_SEMAPHORE) & ASYNC_EVENT_INTERRUPT)) {
1012 status = isp_inw(host, MBOX0);
1013
1014 DEBUG_INTR(printk("qlogicisp : mbox completion status: %x\n",
1015 status));
1016
1017 switch (status) {
1018 case ASYNC_SCSI_BUS_RESET:
1019 case EXECUTION_TIMEOUT_RESET:
1020 hostdata->send_marker = 1;
1021 break;
1022 case INVALID_COMMAND:
1023 case HOST_INTERFACE_ERROR:
1024 case COMMAND_ERROR:
1025 case COMMAND_PARAM_ERROR:
1026 printk("qlogicisp : bad mailbox return status\n");
1027 break;
1028 }
1029 isp_outw(0x0, host, PCI_SEMAPHORE);
1030 }
1031 out_ptr = hostdata->res_out_ptr;
1032
1033 DEBUG_INTR(printk("qlogicisp : response queue update\n"));
1034 DEBUG_INTR(printk("qlogicisp : response queue depth %d\n",
1035 QUEUE_DEPTH(in_ptr, out_ptr, RES_QUEUE_LEN)));
1036
1037 while (out_ptr != in_ptr) {
1038 u_int cmd_slot;
1039
1040 sts = (struct Status_Entry *) &hostdata->res_cpu[out_ptr];
1041 out_ptr = (out_ptr + 1) & RES_QUEUE_LEN;
1042
1043 cmd_slot = sts->handle;
1044 Cmnd = hostdata->cmd_slots[cmd_slot];
1045 hostdata->cmd_slots[cmd_slot] = NULL;
1046
1047 TRACE("done", out_ptr, Cmnd);
1048
1049 if (le16_to_cpu(sts->completion_status) == CS_RESET_OCCURRED
1050 || le16_to_cpu(sts->completion_status) == CS_ABORTED
1051 || (le16_to_cpu(sts->status_flags) & STF_BUS_RESET))
1052 hostdata->send_marker = 1;
1053
1054 if (le16_to_cpu(sts->state_flags) & SF_GOT_SENSE)
1055 memcpy(Cmnd->sense_buffer, sts->req_sense_data,
1056 sizeof(Cmnd->sense_buffer));
1057
1058 DEBUG_INTR(isp1020_print_status_entry(sts));
1059
1060 if (sts->hdr.entry_type == ENTRY_STATUS)
1061 Cmnd->result = isp1020_return_status(sts);
1062 else
1063 Cmnd->result = DID_ERROR << 16;
1064
1065 if (Cmnd->use_sg)
1066 pci_unmap_sg(hostdata->pci_dev,
1067 (struct scatterlist *)Cmnd->buffer,
1068 Cmnd->use_sg,
1069 Cmnd->sc_data_direction);
1070 else if (Cmnd->request_bufflen)
1071 pci_unmap_single(hostdata->pci_dev,
1072#ifdef CONFIG_QL_ISP_A64
1073 (dma_addr_t)((long)Cmnd->SCp.ptr),
1074#else
1075 (u32)((long)Cmnd->SCp.ptr),
1076#endif
1077 Cmnd->request_bufflen,
1078 Cmnd->sc_data_direction);
1079
1080 isp_outw(out_ptr, host, MBOX5);
1081 (*Cmnd->scsi_done)(Cmnd);
1082 }
1083 hostdata->res_out_ptr = out_ptr;
1084
1085 LEAVE_INTR("isp1020_intr_handler");
1086}
1087
1088
1089static int isp1020_return_status(struct Status_Entry *sts)
1090{
1091 int host_status = DID_ERROR;
1092#if DEBUG_ISP1020_INTR
1093 static char *reason[] = {
1094 "DID_OK",
1095 "DID_NO_CONNECT",
1096 "DID_BUS_BUSY",
1097 "DID_TIME_OUT",
1098 "DID_BAD_TARGET",
1099 "DID_ABORT",
1100 "DID_PARITY",
1101 "DID_ERROR",
1102 "DID_RESET",
1103 "DID_BAD_INTR"
1104 };
1105#endif /* DEBUG_ISP1020_INTR */
1106
1107 ENTER("isp1020_return_status");
1108
1109 DEBUG(printk("qlogicisp : completion status = 0x%04x\n",
1110 le16_to_cpu(sts->completion_status)));
1111
1112 switch(le16_to_cpu(sts->completion_status)) {
1113 case CS_COMPLETE:
1114 host_status = DID_OK;
1115 break;
1116 case CS_INCOMPLETE:
1117 if (!(le16_to_cpu(sts->state_flags) & SF_GOT_BUS))
1118 host_status = DID_NO_CONNECT;
1119 else if (!(le16_to_cpu(sts->state_flags) & SF_GOT_TARGET))
1120 host_status = DID_BAD_TARGET;
1121 else if (!(le16_to_cpu(sts->state_flags) & SF_SENT_CDB))
1122 host_status = DID_ERROR;
1123 else if (!(le16_to_cpu(sts->state_flags) & SF_TRANSFERRED_DATA))
1124 host_status = DID_ERROR;
1125 else if (!(le16_to_cpu(sts->state_flags) & SF_GOT_STATUS))
1126 host_status = DID_ERROR;
1127 else if (!(le16_to_cpu(sts->state_flags) & SF_GOT_SENSE))
1128 host_status = DID_ERROR;
1129 break;
1130 case CS_DMA_ERROR:
1131 case CS_TRANSPORT_ERROR:
1132 host_status = DID_ERROR;
1133 break;
1134 case CS_RESET_OCCURRED:
1135 host_status = DID_RESET;
1136 break;
1137 case CS_ABORTED:
1138 host_status = DID_ABORT;
1139 break;
1140 case CS_TIMEOUT:
1141 host_status = DID_TIME_OUT;
1142 break;
1143 case CS_DATA_OVERRUN:
1144 case CS_COMMAND_OVERRUN:
1145 case CS_STATUS_OVERRUN:
1146 case CS_BAD_MESSAGE:
1147 case CS_NO_MESSAGE_OUT:
1148 case CS_EXT_ID_FAILED:
1149 case CS_IDE_MSG_FAILED:
1150 case CS_ABORT_MSG_FAILED:
1151 case CS_NOP_MSG_FAILED:
1152 case CS_PARITY_ERROR_MSG_FAILED:
1153 case CS_DEVICE_RESET_MSG_FAILED:
1154 case CS_ID_MSG_FAILED:
1155 case CS_UNEXP_BUS_FREE:
1156 host_status = DID_ERROR;
1157 break;
1158 case CS_DATA_UNDERRUN:
1159 host_status = DID_OK;
1160 break;
1161 default:
1162 printk("qlogicisp : unknown completion status 0x%04x\n",
1163 le16_to_cpu(sts->completion_status));
1164 host_status = DID_ERROR;
1165 break;
1166 }
1167
1168 DEBUG_INTR(printk("qlogicisp : host status (%s) scsi status %x\n",
1169 reason[host_status], le16_to_cpu(sts->scsi_status)));
1170
1171 LEAVE("isp1020_return_status");
1172
1173 return (le16_to_cpu(sts->scsi_status) & STATUS_MASK) | (host_status << 16);
1174}
1175
1176
1177static int isp1020_biosparam(struct scsi_device *sdev, struct block_device *n,
1178 sector_t capacity, int ip[])
1179{
1180 int size = capacity;
1181
1182 ENTER("isp1020_biosparam");
1183
1184 ip[0] = 64;
1185 ip[1] = 32;
1186 ip[2] = size >> 11;
1187 if (ip[2] > 1024) {
1188 ip[0] = 255;
1189 ip[1] = 63;
1190 ip[2] = size / (ip[0] * ip[1]);
1191#if 0
1192 if (ip[2] > 1023)
1193 ip[2] = 1023;
1194#endif
1195 }
1196
1197 LEAVE("isp1020_biosparam");
1198
1199 return 0;
1200}
1201
1202
1203static int isp1020_reset_hardware(struct Scsi_Host *host)
1204{
1205 u_short param[6];
1206 int loop_count;
1207
1208 ENTER("isp1020_reset_hardware");
1209
1210 isp_outw(ISP_RESET, host, PCI_INTF_CTL);
1211 udelay(100);
1212 isp_outw(HCCR_RESET, host, HOST_HCCR);
1213 udelay(100);
1214 isp_outw(HCCR_RELEASE, host, HOST_HCCR);
1215 isp_outw(HCCR_BIOS_DISABLE, host, HOST_HCCR);
1216
1217 loop_count = DEFAULT_LOOP_COUNT;
1218 while (--loop_count && isp_inw(host, HOST_HCCR) == RISC_BUSY) {
1219 barrier();
1220 cpu_relax();
1221 }
1222 if (!loop_count)
1223 printk("qlogicisp: reset_hardware loop timeout\n");
1224
1225 isp_outw(0, host, ISP_CFG1);
1226
1227#if DEBUG_ISP1020
1228 printk("qlogicisp : mbox 0 0x%04x \n", isp_inw(host, MBOX0));
1229 printk("qlogicisp : mbox 1 0x%04x \n", isp_inw(host, MBOX1));
1230 printk("qlogicisp : mbox 2 0x%04x \n", isp_inw(host, MBOX2));
1231 printk("qlogicisp : mbox 3 0x%04x \n", isp_inw(host, MBOX3));
1232 printk("qlogicisp : mbox 4 0x%04x \n", isp_inw(host, MBOX4));
1233 printk("qlogicisp : mbox 5 0x%04x \n", isp_inw(host, MBOX5));
1234#endif /* DEBUG_ISP1020 */
1235
1236 param[0] = MBOX_NO_OP;
1237 isp1020_mbox_command(host, param);
1238 if (param[0] != MBOX_COMMAND_COMPLETE) {
1239 printk("qlogicisp : NOP test failed\n");
1240 return 1;
1241 }
1242
1243 DEBUG(printk("qlogicisp : loading risc ram\n"));
1244
1245#if RELOAD_FIRMWARE
1246 for (loop_count = 0; loop_count < risc_code_length01; loop_count++) {
1247 param[0] = MBOX_WRITE_RAM_WORD;
1248 param[1] = risc_code_addr01 + loop_count;
1249 param[2] = risc_code01[loop_count];
1250 isp1020_mbox_command(host, param);
1251 if (param[0] != MBOX_COMMAND_COMPLETE) {
1252 printk("qlogicisp : firmware load failure at %d\n",
1253 loop_count);
1254 return 1;
1255 }
1256 }
1257#endif /* RELOAD_FIRMWARE */
1258
1259 DEBUG(printk("qlogicisp : verifying checksum\n"));
1260
1261 param[0] = MBOX_VERIFY_CHECKSUM;
1262 param[1] = risc_code_addr01;
1263
1264 isp1020_mbox_command(host, param);
1265
1266 if (param[0] != MBOX_COMMAND_COMPLETE) {
1267 printk("qlogicisp : ram checksum failure\n");
1268 return 1;
1269 }
1270
1271 DEBUG(printk("qlogicisp : executing firmware\n"));
1272
1273 param[0] = MBOX_EXEC_FIRMWARE;
1274 param[1] = risc_code_addr01;
1275
1276 isp1020_mbox_command(host, param);
1277
1278 param[0] = MBOX_ABOUT_FIRMWARE;
1279
1280 isp1020_mbox_command(host, param);
1281
1282 if (param[0] != MBOX_COMMAND_COMPLETE) {
1283 printk("qlogicisp : about firmware failure\n");
1284 return 1;
1285 }
1286
1287 DEBUG(printk("qlogicisp : firmware major revision %d\n", param[1]));
1288 DEBUG(printk("qlogicisp : firmware minor revision %d\n", param[2]));
1289
1290 LEAVE("isp1020_reset_hardware");
1291
1292 return 0;
1293}
1294
1295
1296static int isp1020_init(struct Scsi_Host *sh)
1297{
1298 u_long io_base, mem_base, io_flags, mem_flags;
1299 struct isp1020_hostdata *hostdata;
1300 u_char revision;
1301 u_int irq;
1302 u_short command;
1303 struct pci_dev *pdev;
1304
1305 ENTER("isp1020_init");
1306
1307 hostdata = (struct isp1020_hostdata *) sh->hostdata;
1308 pdev = hostdata->pci_dev;
1309
1310 if (pci_read_config_word(pdev, PCI_COMMAND, &command)
1311 || pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision))
1312 {
1313 printk("qlogicisp : error reading PCI configuration\n");
1314 return 1;
1315 }
1316
1317 io_base = pci_resource_start(pdev, 0);
1318 mem_base = pci_resource_start(pdev, 1);
1319 io_flags = pci_resource_flags(pdev, 0);
1320 mem_flags = pci_resource_flags(pdev, 1);
1321 irq = pdev->irq;
1322
1323 if (pdev->vendor != PCI_VENDOR_ID_QLOGIC) {
1324 printk("qlogicisp : 0x%04x is not QLogic vendor ID\n",
1325 pdev->vendor);
1326 return 1;
1327 }
1328
1329 if (pdev->device != PCI_DEVICE_ID_QLOGIC_ISP1020) {
1330 printk("qlogicisp : 0x%04x does not match ISP1020 device id\n",
1331 pdev->device);
1332 return 1;
1333 }
1334
1335#ifdef __alpha__
1336 /* Force ALPHA to use bus I/O and not bus MEM.
1337 This is to avoid having to use HAE_MEM registers,
1338 which is broken on some platforms and with SMP. */
1339 command &= ~PCI_COMMAND_MEMORY;
1340#endif
1341
1342 sh->io_port = io_base;
1343
1344 if (!request_region(sh->io_port, 0xff, "qlogicisp")) {
1345 printk("qlogicisp : i/o region 0x%lx-0x%lx already "
1346 "in use\n",
1347 sh->io_port, sh->io_port + 0xff);
1348 return 1;
1349 }
1350
1351 if ((command & PCI_COMMAND_MEMORY) &&
1352 ((mem_flags & 1) == 0)) {
1353 hostdata->memaddr = ioremap(mem_base, PAGE_SIZE);
1354 if (!hostdata->memaddr) {
1355 printk("qlogicisp : i/o remapping failed.\n");
1356 goto out_release;
1357 }
1358 } else {
1359 if (command & PCI_COMMAND_IO && (io_flags & 3) != 1) {
1360 printk("qlogicisp : i/o mapping is disabled\n");
1361 goto out_release;
1362 }
1363 hostdata->memaddr = NULL; /* zero to signify no i/o mapping */
1364 mem_base = 0;
1365 }
1366
1367 if (revision != ISP1020_REV_ID)
1368 printk("qlogicisp : new isp1020 revision ID (%d)\n", revision);
1369
1370 if (isp_inw(sh, PCI_ID_LOW) != PCI_VENDOR_ID_QLOGIC
1371 || isp_inw(sh, PCI_ID_HIGH) != PCI_DEVICE_ID_QLOGIC_ISP1020)
1372 {
1373 printk("qlogicisp : can't decode %s address space 0x%lx\n",
1374 (io_base ? "I/O" : "MEM"),
1375 (io_base ? io_base : mem_base));
1376 goto out_unmap;
1377 }
1378
1379 hostdata->revision = revision;
1380
1381 sh->irq = irq;
1382 sh->max_id = MAX_TARGETS;
1383 sh->max_lun = MAX_LUNS;
1384
1385 hostdata->res_cpu = pci_alloc_consistent(hostdata->pci_dev,
1386 QSIZE(RES_QUEUE_LEN),
1387 &hostdata->res_dma);
1388 if (hostdata->res_cpu == NULL) {
1389 printk("qlogicisp : can't allocate response queue\n");
1390 goto out_unmap;
1391 }
1392
1393 hostdata->req_cpu = pci_alloc_consistent(hostdata->pci_dev,
1394 QSIZE(QLOGICISP_REQ_QUEUE_LEN),
1395 &hostdata->req_dma);
1396 if (hostdata->req_cpu == NULL) {
1397 pci_free_consistent(hostdata->pci_dev,
1398 QSIZE(RES_QUEUE_LEN),
1399 hostdata->res_cpu,
1400 hostdata->res_dma);
1401 printk("qlogicisp : can't allocate request queue\n");
1402 goto out_unmap;
1403 }
1404
1405 pci_set_master(pdev);
1406
1407 LEAVE("isp1020_init");
1408
1409 return 0;
1410
1411out_unmap:
1412 iounmap(hostdata->memaddr);
1413out_release:
1414 release_region(sh->io_port, 0xff);
1415 return 1;
1416}
1417
1418
1419#if USE_NVRAM_DEFAULTS
1420
1421static int isp1020_get_defaults(struct Scsi_Host *host)
1422{
1423 int i;
1424 u_short value;
1425 struct isp1020_hostdata *hostdata =
1426 (struct isp1020_hostdata *) host->hostdata;
1427
1428 ENTER("isp1020_get_defaults");
1429
1430 if (!isp1020_verify_nvram(host)) {
1431 printk("qlogicisp : nvram checksum failure\n");
1432 printk("qlogicisp : attempting to use default parameters\n");
1433 return isp1020_set_defaults(host);
1434 }
1435
1436 value = isp1020_read_nvram_word(host, 2);
1437 hostdata->host_param.fifo_threshold = (value >> 8) & 0x03;
1438 hostdata->host_param.host_adapter_enable = (value >> 11) & 0x01;
1439 hostdata->host_param.initiator_scsi_id = (value >> 12) & 0x0f;
1440
1441 value = isp1020_read_nvram_word(host, 3);
1442 hostdata->host_param.bus_reset_delay = value & 0xff;
1443 hostdata->host_param.retry_count = value >> 8;
1444
1445 value = isp1020_read_nvram_word(host, 4);
1446 hostdata->host_param.retry_delay = value & 0xff;
1447 hostdata->host_param.async_data_setup_time = (value >> 8) & 0x0f;
1448 hostdata->host_param.req_ack_active_negation = (value >> 12) & 0x01;
1449 hostdata->host_param.data_line_active_negation = (value >> 13) & 0x01;
1450 hostdata->host_param.data_dma_burst_enable = (value >> 14) & 0x01;
1451 hostdata->host_param.command_dma_burst_enable = (value >> 15);
1452
1453 value = isp1020_read_nvram_word(host, 5);
1454 hostdata->host_param.tag_aging = value & 0xff;
1455
1456 value = isp1020_read_nvram_word(host, 6);
1457 hostdata->host_param.selection_timeout = value & 0xffff;
1458
1459 value = isp1020_read_nvram_word(host, 7);
1460 hostdata->host_param.max_queue_depth = value & 0xffff;
1461
1462#if DEBUG_ISP1020_SETUP
1463 printk("qlogicisp : fifo threshold=%d\n",
1464 hostdata->host_param.fifo_threshold);
1465 printk("qlogicisp : initiator scsi id=%d\n",
1466 hostdata->host_param.initiator_scsi_id);
1467 printk("qlogicisp : bus reset delay=%d\n",
1468 hostdata->host_param.bus_reset_delay);
1469 printk("qlogicisp : retry count=%d\n",
1470 hostdata->host_param.retry_count);
1471 printk("qlogicisp : retry delay=%d\n",
1472 hostdata->host_param.retry_delay);
1473 printk("qlogicisp : async data setup time=%d\n",
1474 hostdata->host_param.async_data_setup_time);
1475 printk("qlogicisp : req/ack active negation=%d\n",
1476 hostdata->host_param.req_ack_active_negation);
1477 printk("qlogicisp : data line active negation=%d\n",
1478 hostdata->host_param.data_line_active_negation);
1479 printk("qlogicisp : data DMA burst enable=%d\n",
1480 hostdata->host_param.data_dma_burst_enable);
1481 printk("qlogicisp : command DMA burst enable=%d\n",
1482 hostdata->host_param.command_dma_burst_enable);
1483 printk("qlogicisp : tag age limit=%d\n",
1484 hostdata->host_param.tag_aging);
1485 printk("qlogicisp : selection timeout limit=%d\n",
1486 hostdata->host_param.selection_timeout);
1487 printk("qlogicisp : max queue depth=%d\n",
1488 hostdata->host_param.max_queue_depth);
1489#endif /* DEBUG_ISP1020_SETUP */
1490
1491 for (i = 0; i < MAX_TARGETS; i++) {
1492
1493 value = isp1020_read_nvram_word(host, 14 + i * 3);
1494 hostdata->dev_param[i].device_flags = value & 0xff;
1495 hostdata->dev_param[i].execution_throttle = value >> 8;
1496
1497 value = isp1020_read_nvram_word(host, 15 + i * 3);
1498 hostdata->dev_param[i].synchronous_period = value & 0xff;
1499 hostdata->dev_param[i].synchronous_offset = (value >> 8) & 0x0f;
1500 hostdata->dev_param[i].device_enable = (value >> 12) & 0x01;
1501
1502#if DEBUG_ISP1020_SETUP
1503 printk("qlogicisp : target 0x%02x\n", i);
1504 printk("qlogicisp : device flags=0x%02x\n",
1505 hostdata->dev_param[i].device_flags);
1506 printk("qlogicisp : execution throttle=%d\n",
1507 hostdata->dev_param[i].execution_throttle);
1508 printk("qlogicisp : synchronous period=%d\n",
1509 hostdata->dev_param[i].synchronous_period);
1510 printk("qlogicisp : synchronous offset=%d\n",
1511 hostdata->dev_param[i].synchronous_offset);
1512 printk("qlogicisp : device enable=%d\n",
1513 hostdata->dev_param[i].device_enable);
1514#endif /* DEBUG_ISP1020_SETUP */
1515 }
1516
1517 LEAVE("isp1020_get_defaults");
1518
1519 return 0;
1520}
1521
1522
1523#define ISP1020_NVRAM_LEN 0x40
1524#define ISP1020_NVRAM_SIG1 0x5349
1525#define ISP1020_NVRAM_SIG2 0x2050
1526
1527static int isp1020_verify_nvram(struct Scsi_Host *host)
1528{
1529 int i;
1530 u_short value;
1531 u_char checksum = 0;
1532
1533 for (i = 0; i < ISP1020_NVRAM_LEN; i++) {
1534 value = isp1020_read_nvram_word(host, i);
1535
1536 switch (i) {
1537 case 0:
1538 if (value != ISP1020_NVRAM_SIG1) return 0;
1539 break;
1540 case 1:
1541 if (value != ISP1020_NVRAM_SIG2) return 0;
1542 break;
1543 case 2:
1544 if ((value & 0xff) != 0x02) return 0;
1545 break;
1546 }
1547 checksum += value & 0xff;
1548 checksum += value >> 8;
1549 }
1550
1551 return (checksum == 0);
1552}
1553
1554#define NVRAM_DELAY() udelay(2) /* 2 microsecond delay */
1555
1556
1557u_short isp1020_read_nvram_word(struct Scsi_Host *host, u_short byte)
1558{
1559 int i;
1560 u_short value, output, input;
1561
1562 byte &= 0x3f; byte |= 0x0180;
1563
1564 for (i = 8; i >= 0; i--) {
1565 output = ((byte >> i) & 0x1) ? 0x4 : 0x0;
1566 isp_outw(output | 0x2, host, PCI_NVRAM); NVRAM_DELAY();
1567 isp_outw(output | 0x3, host, PCI_NVRAM); NVRAM_DELAY();
1568 isp_outw(output | 0x2, host, PCI_NVRAM); NVRAM_DELAY();
1569 }
1570
1571 for (i = 0xf, value = 0; i >= 0; i--) {
1572 value <<= 1;
1573 isp_outw(0x3, host, PCI_NVRAM); NVRAM_DELAY();
1574 input = isp_inw(host, PCI_NVRAM); NVRAM_DELAY();
1575 isp_outw(0x2, host, PCI_NVRAM); NVRAM_DELAY();
1576 if (input & 0x8) value |= 1;
1577 }
1578
1579 isp_outw(0x0, host, PCI_NVRAM); NVRAM_DELAY();
1580
1581 return value;
1582}
1583
1584#endif /* USE_NVRAM_DEFAULTS */
1585
1586
1587static int isp1020_set_defaults(struct Scsi_Host *host)
1588{
1589 struct isp1020_hostdata *hostdata =
1590 (struct isp1020_hostdata *) host->hostdata;
1591 int i;
1592
1593 ENTER("isp1020_set_defaults");
1594
1595 hostdata->host_param.fifo_threshold = 2;
1596 hostdata->host_param.host_adapter_enable = 1;
1597 hostdata->host_param.initiator_scsi_id = 7;
1598 hostdata->host_param.bus_reset_delay = 3;
1599 hostdata->host_param.retry_count = 0;
1600 hostdata->host_param.retry_delay = 1;
1601 hostdata->host_param.async_data_setup_time = 6;
1602 hostdata->host_param.req_ack_active_negation = 1;
1603 hostdata->host_param.data_line_active_negation = 1;
1604 hostdata->host_param.data_dma_burst_enable = 1;
1605 hostdata->host_param.command_dma_burst_enable = 1;
1606 hostdata->host_param.tag_aging = 8;
1607 hostdata->host_param.selection_timeout = 250;
1608 hostdata->host_param.max_queue_depth = 256;
1609
1610 for (i = 0; i < MAX_TARGETS; i++) {
1611 hostdata->dev_param[i].device_flags = 0xfd;
1612 hostdata->dev_param[i].execution_throttle = 16;
1613 hostdata->dev_param[i].synchronous_period = 25;
1614 hostdata->dev_param[i].synchronous_offset = 12;
1615 hostdata->dev_param[i].device_enable = 1;
1616 }
1617
1618 LEAVE("isp1020_set_defaults");
1619
1620 return 0;
1621}
1622
1623
1624static int isp1020_load_parameters(struct Scsi_Host *host)
1625{
1626 int i, k;
1627#ifdef CONFIG_QL_ISP_A64
1628 u_long queue_addr;
1629 u_short param[8];
1630#else
1631 u_int queue_addr;
1632 u_short param[6];
1633#endif
1634 u_short isp_cfg1, hwrev;
1635 struct isp1020_hostdata *hostdata =
1636 (struct isp1020_hostdata *) host->hostdata;
1637
1638 ENTER("isp1020_load_parameters");
1639
1640 hwrev = isp_inw(host, ISP_CFG0) & ISP_CFG0_HWMSK;
1641 isp_cfg1 = ISP_CFG1_F64 | ISP_CFG1_BENAB;
1642 if (hwrev == ISP_CFG0_1040A) {
1643 /* Busted fifo, says mjacob. */
1644 isp_cfg1 &= ISP_CFG1_BENAB;
1645 }
1646
1647 isp_outw(isp_inw(host, ISP_CFG1) | isp_cfg1, host, ISP_CFG1);
1648 isp_outw(isp_inw(host, CDMA_CONF) | DMA_CONF_BENAB, host, CDMA_CONF);
1649 isp_outw(isp_inw(host, DDMA_CONF) | DMA_CONF_BENAB, host, DDMA_CONF);
1650
1651 param[0] = MBOX_SET_INIT_SCSI_ID;
1652 param[1] = hostdata->host_param.initiator_scsi_id;
1653
1654 isp1020_mbox_command(host, param);
1655
1656 if (param[0] != MBOX_COMMAND_COMPLETE) {
1657 printk("qlogicisp : set initiator id failure\n");
1658 return 1;
1659 }
1660
1661 param[0] = MBOX_SET_RETRY_COUNT;
1662 param[1] = hostdata->host_param.retry_count;
1663 param[2] = hostdata->host_param.retry_delay;
1664
1665 isp1020_mbox_command(host, param);
1666
1667 if (param[0] != MBOX_COMMAND_COMPLETE) {
1668 printk("qlogicisp : set retry count failure\n");
1669 return 1;
1670 }
1671
1672 param[0] = MBOX_SET_ASYNC_DATA_SETUP_TIME;
1673 param[1] = hostdata->host_param.async_data_setup_time;
1674
1675 isp1020_mbox_command(host, param);
1676
1677 if (param[0] != MBOX_COMMAND_COMPLETE) {
1678 printk("qlogicisp : async data setup time failure\n");
1679 return 1;
1680 }
1681
1682 param[0] = MBOX_SET_ACTIVE_NEG_STATE;
1683 param[1] = (hostdata->host_param.req_ack_active_negation << 4)
1684 | (hostdata->host_param.data_line_active_negation << 5);
1685
1686 isp1020_mbox_command(host, param);
1687
1688 if (param[0] != MBOX_COMMAND_COMPLETE) {
1689 printk("qlogicisp : set active negation state failure\n");
1690 return 1;
1691 }
1692
1693 param[0] = MBOX_SET_PCI_CONTROL_PARAMS;
1694 param[1] = hostdata->host_param.data_dma_burst_enable << 1;
1695 param[2] = hostdata->host_param.command_dma_burst_enable << 1;
1696
1697 isp1020_mbox_command(host, param);
1698
1699 if (param[0] != MBOX_COMMAND_COMPLETE) {
1700 printk("qlogicisp : set pci control parameter failure\n");
1701 return 1;
1702 }
1703
1704 param[0] = MBOX_SET_TAG_AGE_LIMIT;
1705 param[1] = hostdata->host_param.tag_aging;
1706
1707 isp1020_mbox_command(host, param);
1708
1709 if (param[0] != MBOX_COMMAND_COMPLETE) {
1710 printk("qlogicisp : set tag age limit failure\n");
1711 return 1;
1712 }
1713
1714 param[0] = MBOX_SET_SELECT_TIMEOUT;
1715 param[1] = hostdata->host_param.selection_timeout;
1716
1717 isp1020_mbox_command(host, param);
1718
1719 if (param[0] != MBOX_COMMAND_COMPLETE) {
1720 printk("qlogicisp : set selection timeout failure\n");
1721 return 1;
1722 }
1723
1724 for (i = 0; i < MAX_TARGETS; i++) {
1725
1726 if (!hostdata->dev_param[i].device_enable)
1727 continue;
1728
1729 param[0] = MBOX_SET_TARGET_PARAMS;
1730 param[1] = i << 8;
1731 param[2] = hostdata->dev_param[i].device_flags << 8;
1732 param[3] = (hostdata->dev_param[i].synchronous_offset << 8)
1733 | hostdata->dev_param[i].synchronous_period;
1734
1735 isp1020_mbox_command(host, param);
1736
1737 if (param[0] != MBOX_COMMAND_COMPLETE) {
1738 printk("qlogicisp : set target parameter failure\n");
1739 return 1;
1740 }
1741
1742 for (k = 0; k < MAX_LUNS; k++) {
1743
1744 param[0] = MBOX_SET_DEV_QUEUE_PARAMS;
1745 param[1] = (i << 8) | k;
1746 param[2] = hostdata->host_param.max_queue_depth;
1747 param[3] = hostdata->dev_param[i].execution_throttle;
1748
1749 isp1020_mbox_command(host, param);
1750
1751 if (param[0] != MBOX_COMMAND_COMPLETE) {
1752 printk("qlogicisp : set device queue "
1753 "parameter failure\n");
1754 return 1;
1755 }
1756 }
1757 }
1758
1759 queue_addr = hostdata->res_dma;
1760#ifdef CONFIG_QL_ISP_A64
1761 param[0] = MBOX_CMD_INIT_RESPONSE_QUEUE_64;
1762#else
1763 param[0] = MBOX_INIT_RES_QUEUE;
1764#endif
1765 param[1] = RES_QUEUE_LEN + 1;
1766 param[2] = (u_short) (queue_addr >> 16);
1767 param[3] = (u_short) (queue_addr & 0xffff);
1768 param[4] = 0;
1769 param[5] = 0;
1770#ifdef CONFIG_QL_ISP_A64
1771 param[6] = (u_short) (queue_addr >> 48);
1772 param[7] = (u_short) (queue_addr >> 32);
1773#endif
1774
1775 isp1020_mbox_command(host, param);
1776
1777 if (param[0] != MBOX_COMMAND_COMPLETE) {
1778 printk("qlogicisp : set response queue failure\n");
1779 return 1;
1780 }
1781
1782 queue_addr = hostdata->req_dma;
1783#ifdef CONFIG_QL_ISP_A64
1784 param[0] = MBOX_CMD_INIT_REQUEST_QUEUE_64;
1785#else
1786 param[0] = MBOX_INIT_REQ_QUEUE;
1787#endif
1788 param[1] = QLOGICISP_REQ_QUEUE_LEN + 1;
1789 param[2] = (u_short) (queue_addr >> 16);
1790 param[3] = (u_short) (queue_addr & 0xffff);
1791 param[4] = 0;
1792
1793#ifdef CONFIG_QL_ISP_A64
1794 param[5] = 0;
1795 param[6] = (u_short) (queue_addr >> 48);
1796 param[7] = (u_short) (queue_addr >> 32);
1797#endif
1798
1799 isp1020_mbox_command(host, param);
1800
1801 if (param[0] != MBOX_COMMAND_COMPLETE) {
1802 printk("qlogicisp : set request queue failure\n");
1803 return 1;
1804 }
1805
1806 LEAVE("isp1020_load_parameters");
1807
1808 return 0;
1809}
1810
1811
1812/*
1813 * currently, this is only called during initialization or abort/reset,
1814 * at which times interrupts are disabled, so polling is OK, I guess...
1815 */
1816static int isp1020_mbox_command(struct Scsi_Host *host, u_short param[])
1817{
1818 int loop_count;
1819
1820 if (mbox_param[param[0]] == 0)
1821 return 1;
1822
1823 loop_count = DEFAULT_LOOP_COUNT;
1824 while (--loop_count && isp_inw(host, HOST_HCCR) & 0x0080) {
1825 barrier();
1826 cpu_relax();
1827 }
1828 if (!loop_count)
1829 printk("qlogicisp: mbox_command loop timeout #1\n");
1830
1831 switch(mbox_param[param[0]] >> 4) {
1832 case 8: isp_outw(param[7], host, MBOX7);
1833 case 7: isp_outw(param[6], host, MBOX6);
1834 case 6: isp_outw(param[5], host, MBOX5);
1835 case 5: isp_outw(param[4], host, MBOX4);
1836 case 4: isp_outw(param[3], host, MBOX3);
1837 case 3: isp_outw(param[2], host, MBOX2);
1838 case 2: isp_outw(param[1], host, MBOX1);
1839 case 1: isp_outw(param[0], host, MBOX0);
1840 }
1841
1842 isp_outw(0x0, host, PCI_SEMAPHORE);
1843 isp_outw(HCCR_CLEAR_RISC_INTR, host, HOST_HCCR);
1844 isp_outw(HCCR_SET_HOST_INTR, host, HOST_HCCR);
1845
1846 loop_count = DEFAULT_LOOP_COUNT;
1847 while (--loop_count && !(isp_inw(host, PCI_INTF_STS) & 0x04)) {
1848 barrier();
1849 cpu_relax();
1850 }
1851 if (!loop_count)
1852 printk("qlogicisp: mbox_command loop timeout #2\n");
1853
1854 loop_count = DEFAULT_LOOP_COUNT;
1855 while (--loop_count && isp_inw(host, MBOX0) == 0x04) {
1856 barrier();
1857 cpu_relax();
1858 }
1859 if (!loop_count)
1860 printk("qlogicisp: mbox_command loop timeout #3\n");
1861
1862 switch(mbox_param[param[0]] & 0xf) {
1863 case 8: param[7] = isp_inw(host, MBOX7);
1864 case 7: param[6] = isp_inw(host, MBOX6);
1865 case 6: param[5] = isp_inw(host, MBOX5);
1866 case 5: param[4] = isp_inw(host, MBOX4);
1867 case 4: param[3] = isp_inw(host, MBOX3);
1868 case 3: param[2] = isp_inw(host, MBOX2);
1869 case 2: param[1] = isp_inw(host, MBOX1);
1870 case 1: param[0] = isp_inw(host, MBOX0);
1871 }
1872
1873 isp_outw(0x0, host, PCI_SEMAPHORE);
1874 isp_outw(HCCR_CLEAR_RISC_INTR, host, HOST_HCCR);
1875
1876 return 0;
1877}
1878
1879
1880#if DEBUG_ISP1020_INTR
1881
1882void isp1020_print_status_entry(struct Status_Entry *status)
1883{
1884 int i;
1885
1886 printk("qlogicisp : entry count = 0x%02x, type = 0x%02x, flags = 0x%02x\n",
1887 status->hdr.entry_cnt, status->hdr.entry_type, status->hdr.flags);
1888 printk("qlogicisp : scsi status = 0x%04x, completion status = 0x%04x\n",
1889 le16_to_cpu(status->scsi_status), le16_to_cpu(status->completion_status));
1890 printk("qlogicisp : state flags = 0x%04x, status flags = 0x%04x\n",
1891 le16_to_cpu(status->state_flags), le16_to_cpu(status->status_flags));
1892 printk("qlogicisp : time = 0x%04x, request sense length = 0x%04x\n",
1893 le16_to_cpu(status->time), le16_to_cpu(status->req_sense_len));
1894 printk("qlogicisp : residual transfer length = 0x%08x\n",
1895 le32_to_cpu(status->residual));
1896
1897 for (i = 0; i < le16_to_cpu(status->req_sense_len); i++)
1898 printk("qlogicisp : sense data = 0x%02x\n", status->req_sense_data[i]);
1899}
1900
1901#endif /* DEBUG_ISP1020_INTR */
1902
1903
1904#if DEBUG_ISP1020
1905
1906void isp1020_print_scsi_cmd(Scsi_Cmnd *cmd)
1907{
1908 int i;
1909
1910 printk("qlogicisp : target = 0x%02x, lun = 0x%02x, cmd_len = 0x%02x\n",
1911 cmd->target, cmd->lun, cmd->cmd_len);
1912 printk("qlogicisp : command = ");
1913 for (i = 0; i < cmd->cmd_len; i++)
1914 printk("0x%02x ", cmd->cmnd[i]);
1915 printk("\n");
1916}
1917
1918#endif /* DEBUG_ISP1020 */
1919
1920MODULE_LICENSE("GPL");
1921
1922static Scsi_Host_Template driver_template = {
1923 .detect = isp1020_detect,
1924 .release = isp1020_release,
1925 .info = isp1020_info,
1926 .queuecommand = isp1020_queuecommand,
1927 .bios_param = isp1020_biosparam,
1928 .can_queue = QLOGICISP_REQ_QUEUE_LEN,
1929 .this_id = -1,
1930 .sg_tablesize = QLOGICISP_MAX_SG(QLOGICISP_REQ_QUEUE_LEN),
1931 .cmd_per_lun = 1,
1932 .use_clustering = DISABLE_CLUSTERING,
1933};
1934#include "scsi_module.c"
diff --git a/drivers/scsi/qlogicisp_asm.c b/drivers/scsi/qlogicisp_asm.c
deleted file mode 100644
index 9ea4beca4ac5..000000000000
--- a/drivers/scsi/qlogicisp_asm.c
+++ /dev/null
@@ -1,2034 +0,0 @@
1/*
2 * Firmware Version 7.63.00 (12:07 Jan 27, 1999)
3 */
4static const unsigned short risc_code_version = 7*1024+63;
5
6static const unsigned short risc_code_addr01 = 0x1000 ;
7
8#if RELOAD_FIRMWARE
9
10static const unsigned short risc_code01[] = {
11 0x0078, 0x103a, 0x0000, 0x3f14, 0x0000, 0x2043, 0x4f50, 0x5952,
12 0x4947, 0x4854, 0x2031, 0x3939, 0x3520, 0x514c, 0x4f47, 0x4943,
13 0x2043, 0x4f52, 0x504f, 0x5241, 0x5449, 0x4f4e, 0x2049, 0x5350,
14 0x3130, 0x3230, 0x2049, 0x2f54, 0x2046, 0x6972, 0x6d77, 0x6172,
15 0x6520, 0x2056, 0x6572, 0x7369, 0x6f6e, 0x2030, 0x372e, 0x3633,
16 0x2020, 0x2043, 0x7573, 0x746f, 0x6d65, 0x7220, 0x4e6f, 0x2e20,
17 0x3030, 0x2050, 0x726f, 0x6475, 0x6374, 0x204e, 0x6f2e, 0x2020,
18 0x3031, 0x2024, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x0048,
19 0x1045, 0x0038, 0x104b, 0x0078, 0x1047, 0x0028, 0x104b, 0x20b9,
20 0x1212, 0x0078, 0x104d, 0x20b9, 0x2222, 0x20c1, 0x0008, 0x2071,
21 0x0010, 0x70c3, 0x0004, 0x20c9, 0x76ff, 0x2089, 0x1186, 0x70c7,
22 0x4953, 0x70cb, 0x5020, 0x70cf, 0x2020, 0x70d3, 0x0007, 0x3f00,
23 0x70d6, 0x20c1, 0x0008, 0x2019, 0x0000, 0x2009, 0xfeff, 0x2100,
24 0x200b, 0xa5a5, 0xa1ec, 0x7fff, 0x2d64, 0x206b, 0x0a0a, 0xaddc,
25 0x3fff, 0x2b54, 0x205b, 0x5050, 0x2114, 0xa286, 0xa5a5, 0x0040,
26 0x10bf, 0xa386, 0x000f, 0x0040, 0x1085, 0x2c6a, 0x2a5a, 0x20c1,
27 0x0000, 0x2019, 0x000f, 0x0078, 0x1065, 0x2c6a, 0x2a5a, 0x20c1,
28 0x0008, 0x2009, 0x7fff, 0x2148, 0x2944, 0x204b, 0x0a0a, 0xa9bc,
29 0x3fff, 0x2734, 0x203b, 0x5050, 0x2114, 0xa286, 0x0a0a, 0x0040,
30 0x10a9, 0x284a, 0x263a, 0x20c1, 0x0004, 0x2009, 0x3fff, 0x2134,
31 0x200b, 0x5050, 0x2114, 0xa286, 0x5050, 0x0040, 0x10aa, 0x0078,
32 0x118e, 0x284a, 0x263a, 0x98c0, 0xa188, 0x1000, 0x212c, 0x200b,
33 0xa5a5, 0x2114, 0xa286, 0xa5a5, 0x0040, 0x10bc, 0x250a, 0xa18a,
34 0x1000, 0x98c1, 0x0078, 0x10c1, 0x250a, 0x0078, 0x10c1, 0x2c6a,
35 0x2a5a, 0x2130, 0xa18a, 0x0040, 0x2128, 0xa1a2, 0x5000, 0x8424,
36 0x8424, 0x8424, 0x8424, 0x8424, 0x8424, 0xa192, 0x7700, 0x2009,
37 0x0000, 0x2001, 0x0031, 0x1078, 0x1c9d, 0x2218, 0x2079, 0x5000,
38 0x2fa0, 0x2408, 0x2011, 0x0000, 0x20a9, 0x0040, 0x42a4, 0x8109,
39 0x00c0, 0x10dc, 0x7ef2, 0x8528, 0x7de6, 0x7cea, 0x7bee, 0x7883,
40 0x0000, 0x2031, 0x0030, 0x78cf, 0x0101, 0x780b, 0x0002, 0x780f,
41 0x0002, 0x784f, 0x0003, 0x2069, 0x5040, 0x2001, 0x04fd, 0x2004,
42 0xa082, 0x0005, 0x0048, 0x1104, 0x0038, 0x1100, 0x0078, 0x1108,
43 0x681b, 0x003c, 0x0078, 0x110a, 0x00a8, 0x1108, 0x681b, 0x003c,
44 0x681b, 0x0028, 0x6807, 0x0007, 0x680b, 0x00fa, 0x680f, 0x0008,
45 0x6813, 0x0005, 0x6823, 0x0000, 0x6827, 0x0006, 0x6817, 0x0008,
46 0x682b, 0x0000, 0x681f, 0x0019, 0x2069, 0x5280, 0x2011, 0x0020,
47 0x2009, 0x0010, 0x680b, 0x080c, 0x680f, 0x0019, 0x6803, 0xfd00,
48 0x6807, 0x0018, 0x6a1a, 0x2d00, 0xa0e8, 0x0008, 0xa290, 0x0004,
49 0x8109, 0x00c0, 0x1122, 0x2069, 0x5300, 0x2009, 0x0002, 0x20a9,
50 0x0100, 0x6837, 0x0000, 0x680b, 0x0040, 0x7bf0, 0xa386, 0xfeff,
51 0x00c0, 0x1148, 0x6817, 0x0100, 0x681f, 0x0064, 0x0078, 0x114c,
52 0x6817, 0x0064, 0x681f, 0x0002, 0xade8, 0x0010, 0x0070, 0x1152,
53 0x0078, 0x1139, 0x8109, 0x00c0, 0x1137, 0x1078, 0x21e9, 0x1078,
54 0x46e9, 0x1078, 0x1946, 0x1078, 0x4bdf, 0x3200, 0xa085, 0x000d,
55 0x2090, 0x70c3, 0x0000, 0x0090, 0x116c, 0x70c0, 0xa086, 0x0002,
56 0x00c0, 0x116c, 0x1078, 0x1284, 0x1078, 0x1196, 0x78cc, 0xa005,
57 0x00c0, 0x117a, 0x1078, 0x1cc6, 0x0010, 0x1180, 0x0068, 0x1180,
58 0x1078, 0x20c8, 0x0010, 0x1180, 0x0068, 0x1180, 0x1078, 0x1a2b,
59 0x00e0, 0x116c, 0x1078, 0x4a66, 0x0078, 0x116c, 0x118e, 0x1190,
60 0x23ea, 0x23ea, 0x476a, 0x476a, 0x23ea, 0x23ea, 0x0078, 0x118e,
61 0x0078, 0x1190, 0x0078, 0x1192, 0x0078, 0x1194, 0x0068, 0x1201,
62 0x2061, 0x0000, 0x6018, 0xa084, 0x0001, 0x00c0, 0x1201, 0x7814,
63 0xa005, 0x00c0, 0x11a7, 0x0010, 0x1202, 0x0078, 0x1201, 0x2009,
64 0x505b, 0x2104, 0xa005, 0x00c0, 0x1201, 0x2009, 0x5064, 0x200b,
65 0x0000, 0x7914, 0xa186, 0x0042, 0x00c0, 0x11cc, 0x7816, 0x2009,
66 0x5062, 0x2164, 0x200b, 0x0000, 0x6018, 0x70c6, 0x6014, 0x70ca,
67 0x611c, 0xa18c, 0xff00, 0x6020, 0xa084, 0x00ff, 0xa105, 0x70ce,
68 0x1078, 0x192b, 0x0078, 0x11ff, 0x7814, 0xa086, 0x0018, 0x00c0,
69 0x11d3, 0x1078, 0x165a, 0x7817, 0x0000, 0x2009, 0x5062, 0x2104,
70 0xa065, 0x0040, 0x11ef, 0x0c7e, 0x609c, 0x2060, 0x1078, 0x1996,
71 0x0c7f, 0x609f, 0x0000, 0x1078, 0x1730, 0x2009, 0x000c, 0x6007,
72 0x0103, 0x1078, 0x1907, 0x00c0, 0x11fb, 0x1078, 0x192b, 0x2009,
73 0x5062, 0x200b, 0x0000, 0x2009, 0x505c, 0x2104, 0x200b, 0x0000,
74 0xa005, 0x0040, 0x11ff, 0x2001, 0x4005, 0x0078, 0x1286, 0x0078,
75 0x1284, 0x007c, 0x70c3, 0x0000, 0x70c7, 0x0000, 0x70cb, 0x0000,
76 0x70cf, 0x0000, 0x70c0, 0xa0bc, 0xffc0, 0x00c0, 0x1252, 0x2038,
77 0x0079, 0x1212, 0x1284, 0x12e5, 0x12a9, 0x12fe, 0x130d, 0x1313,
78 0x12a0, 0x1748, 0x1317, 0x1298, 0x12ad, 0x12af, 0x12b1, 0x12b3,
79 0x174d, 0x1298, 0x1329, 0x1360, 0x1672, 0x1742, 0x12b5, 0x1591,
80 0x15ad, 0x15c9, 0x15f4, 0x154a, 0x1558, 0x156c, 0x1580, 0x13df,
81 0x1298, 0x138d, 0x1393, 0x1398, 0x139d, 0x13a3, 0x13a8, 0x13ad,
82 0x13b2, 0x13b7, 0x13bb, 0x13d0, 0x13dc, 0x1298, 0x1298, 0x1298,
83 0x1298, 0x13eb, 0x13f4, 0x1403, 0x1429, 0x1433, 0x143a, 0x1480,
84 0x148f, 0x149e, 0x14b0, 0x152a, 0x153a, 0x1298, 0x1298, 0x1298,
85 0x1298, 0x153f, 0xa0bc, 0xffa0, 0x00c0, 0x1298, 0x2038, 0xa084,
86 0x001f, 0x0079, 0x125b, 0x1786, 0x1789, 0x1799, 0x1298, 0x1298,
87 0x18d8, 0x18f5, 0x1298, 0x1298, 0x1298, 0x18f9, 0x1901, 0x1298,
88 0x1298, 0x1298, 0x1298, 0x12db, 0x12f4, 0x131f, 0x1356, 0x1668,
89 0x1764, 0x1778, 0x1298, 0x1829, 0x1298, 0x18b4, 0x18be, 0x18c2,
90 0x18d0, 0x1298, 0x1298, 0x72ca, 0x71c6, 0x2001, 0x4006, 0x0078,
91 0x1286, 0x73ce, 0x72ca, 0x71c6, 0x2001, 0x4000, 0x70c2, 0x0068,
92 0x1287, 0x2061, 0x0000, 0x601b, 0x0001, 0x2091, 0x5000, 0x00e0,
93 0x128f, 0x00e0, 0x1291, 0x0068, 0x1291, 0x2091, 0x4080, 0x007c,
94 0x70c3, 0x4001, 0x0078, 0x1287, 0x70c3, 0x4006, 0x0078, 0x1287,
95 0x2099, 0x0041, 0x20a1, 0x0041, 0x20a9, 0x0005, 0x53a3, 0x0078,
96 0x1284, 0x70c4, 0x70c3, 0x0004, 0x007a, 0x0078, 0x1284, 0x0078,
97 0x1284, 0x0078, 0x1284, 0x0078, 0x1284, 0x2091, 0x8000, 0x70c3,
98 0x0000, 0x70c7, 0x4953, 0x70cb, 0x5020, 0x70cf, 0x2020, 0x70d3,
99 0x0007, 0x3f00, 0x70d6, 0x2079, 0x0000, 0x781b, 0x0001, 0x2031,
100 0x0030, 0x2059, 0x1000, 0x2029, 0x0457, 0x2051, 0x0470, 0x2061,
101 0x0472, 0x20b9, 0xffff, 0x20c1, 0x0000, 0x2091, 0x5000, 0x2091,
102 0x4080, 0x0078, 0x0455, 0x1078, 0x1b36, 0x00c0, 0x129c, 0x75d8,
103 0x74dc, 0x75da, 0x74de, 0x0078, 0x12e8, 0x2029, 0x0000, 0x2520,
104 0x71d0, 0x73c8, 0x72cc, 0x70c4, 0x1078, 0x1a70, 0x0040, 0x1284,
105 0x70c3, 0x4002, 0x0078, 0x1284, 0x1078, 0x1b36, 0x00c0, 0x129c,
106 0x75d8, 0x74dc, 0x75da, 0x74de, 0x0078, 0x1301, 0x2029, 0x0000,
107 0x2520, 0x71d0, 0x73c8, 0x72cc, 0x70c4, 0x1078, 0x1ad0, 0x0040,
108 0x1284, 0x70c3, 0x4002, 0x0078, 0x1284, 0x71c4, 0x70c8, 0x2114,
109 0x200a, 0x0078, 0x1282, 0x71c4, 0x2114, 0x0078, 0x1282, 0x70c7,
110 0x0007, 0x70cb, 0x003f, 0x70cf, 0x0000, 0x0078, 0x1284, 0x1078,
111 0x1b36, 0x00c0, 0x129c, 0x75d8, 0x76dc, 0x75da, 0x76de, 0x0078,
112 0x132c, 0x2029, 0x0000, 0x2530, 0x70c4, 0x72c8, 0x73cc, 0x74d0,
113 0x70c6, 0x72ca, 0x73ce, 0x74d2, 0xa005, 0x0040, 0x1350, 0x8001,
114 0x7892, 0xa084, 0xfc00, 0x0040, 0x1345, 0x78cc, 0xa085, 0x0001,
115 0x78ce, 0x2001, 0x4005, 0x0078, 0x1286, 0x7a9a, 0x7b9e, 0x7da2,
116 0x7ea6, 0x7c96, 0x78cc, 0xa084, 0xfffc, 0x78ce, 0x0078, 0x1354,
117 0x78cc, 0xa085, 0x0001, 0x78ce, 0x0078, 0x1284, 0x1078, 0x1b36,
118 0x00c0, 0x129c, 0x75d8, 0x76dc, 0x75da, 0x76de, 0x0078, 0x1363,
119 0x2029, 0x0000, 0x2530, 0x70c4, 0x72c8, 0x73cc, 0x74d4, 0x70c6,
120 0x72ca, 0x73ce, 0x74d6, 0xa005, 0x0040, 0x1387, 0x8001, 0x78ae,
121 0xa084, 0xfc00, 0x0040, 0x137c, 0x78cc, 0xa085, 0x0100, 0x78ce,
122 0x2001, 0x4005, 0x0078, 0x1286, 0x7ab6, 0x7bba, 0x7dbe, 0x7ec2,
123 0x7cb2, 0x78cc, 0xa084, 0xfcff, 0x78ce, 0x0078, 0x138b, 0x78cc,
124 0xa085, 0x0100, 0x78ce, 0x0078, 0x1284, 0x2009, 0x5061, 0x210c,
125 0x7aec, 0x0078, 0x1282, 0x2009, 0x5041, 0x210c, 0x0078, 0x1283,
126 0x2009, 0x5042, 0x210c, 0x0078, 0x1283, 0x2061, 0x5040, 0x610c,
127 0x6210, 0x0078, 0x1282, 0x2009, 0x5045, 0x210c, 0x0078, 0x1283,
128 0x2009, 0x5046, 0x210c, 0x0078, 0x1283, 0x2009, 0x5048, 0x210c,
129 0x0078, 0x1283, 0x2009, 0x5049, 0x210c, 0x0078, 0x1283, 0x7908,
130 0x7a0c, 0x0078, 0x1282, 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003,
131 0x8003, 0x8003, 0xa0e8, 0x5280, 0x6a00, 0x6804, 0xa084, 0x0008,
132 0x0040, 0x13cd, 0x6b08, 0x0078, 0x13ce, 0x6b0c, 0x0078, 0x1281,
133 0x77c4, 0x1078, 0x1956, 0x2091, 0x8000, 0x6b1c, 0x6a14, 0x2091,
134 0x8001, 0x2708, 0x0078, 0x1281, 0x794c, 0x0078, 0x1283, 0x77c4,
135 0x1078, 0x1956, 0x2091, 0x8000, 0x6908, 0x6a18, 0x6b10, 0x2091,
136 0x8001, 0x0078, 0x1281, 0x71c4, 0xa182, 0x0010, 0x00c8, 0x127c,
137 0x1078, 0x22c1, 0x0078, 0x1281, 0x71c4, 0xa182, 0x0010, 0x00c8,
138 0x127c, 0x2011, 0x5041, 0x2204, 0x007e, 0x2112, 0x1078, 0x227a,
139 0x017f, 0x0078, 0x1283, 0x71c4, 0x2011, 0x1421, 0x20a9, 0x0008,
140 0x2204, 0xa106, 0x0040, 0x1413, 0x8210, 0x0070, 0x1411, 0x0078,
141 0x1408, 0x0078, 0x127c, 0xa292, 0x1421, 0x027e, 0x2011, 0x5042,
142 0x2204, 0x2112, 0x017f, 0x007e, 0x1078, 0x2286, 0x017f, 0x0078,
143 0x1283, 0x03e8, 0x00fa, 0x01f4, 0x02ee, 0x0064, 0x0019, 0x0032,
144 0x004b, 0x2061, 0x5040, 0x610c, 0x6210, 0x70c4, 0x600e, 0x70c8,
145 0x6012, 0x0078, 0x1282, 0x2061, 0x5040, 0x6114, 0x70c4, 0x6016,
146 0x0078, 0x1283, 0x2061, 0x5040, 0x71c4, 0x2011, 0x0004, 0x601f,
147 0x0019, 0x2019, 0x1212, 0xa186, 0x0028, 0x0040, 0x145b, 0x2011,
148 0x0005, 0x601f, 0x0019, 0x2019, 0x1212, 0xa186, 0x0032, 0x0040,
149 0x145b, 0x2011, 0x0006, 0x601f, 0x000c, 0x2019, 0x2222, 0xa186,
150 0x003c, 0x00c0, 0x127c, 0x6018, 0x007e, 0x611a, 0x7800, 0xa084,
151 0x0001, 0x00c0, 0x1476, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005,
152 0x0048, 0x146e, 0x0038, 0x1472, 0x0078, 0x1476, 0x0028, 0x1472,
153 0x0078, 0x1476, 0x2019, 0x2222, 0x0078, 0x1478, 0x2019, 0x1212,
154 0x23b8, 0x1078, 0x2297, 0x1078, 0x4bdf, 0x017f, 0x0078, 0x1283,
155 0x71c4, 0xa184, 0xffcf, 0x00c0, 0x127c, 0x2011, 0x5048, 0x2204,
156 0x2112, 0x007e, 0x1078, 0x22b9, 0x017f, 0x0078, 0x1283, 0x71c4,
157 0xa182, 0x0010, 0x00c8, 0x127c, 0x2011, 0x5049, 0x2204, 0x007e,
158 0x2112, 0x1078, 0x22a8, 0x017f, 0x0078, 0x1283, 0x71c4, 0x72c8,
159 0xa184, 0xfffd, 0x00c0, 0x127b, 0xa284, 0xfffd, 0x00c0, 0x127b,
160 0x2100, 0x7908, 0x780a, 0x2200, 0x7a0c, 0x780e, 0x0078, 0x1282,
161 0x71c4, 0x8107, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e8,
162 0x5280, 0x2019, 0x0000, 0x72c8, 0xa284, 0x0080, 0x0040, 0x14c6,
163 0x6c14, 0x84ff, 0x00c0, 0x14c6, 0x6817, 0x0040, 0xa284, 0x0040,
164 0x0040, 0x14d0, 0x6c10, 0x84ff, 0x00c0, 0x14d0, 0x6813, 0x0001,
165 0x6800, 0x007e, 0xa226, 0x0040, 0x14f3, 0x6a02, 0xa484, 0x2000,
166 0x0040, 0x14dc, 0xa39d, 0x0010, 0xa484, 0x1000, 0x0040, 0x14e2,
167 0xa39d, 0x0008, 0xa484, 0x4000, 0x0040, 0x14f3, 0x810f, 0xa284,
168 0x4000, 0x0040, 0x14ef, 0x1078, 0x22db, 0x0078, 0x14f3, 0x1078,
169 0x22cd, 0x0078, 0x14f3, 0x72cc, 0x6808, 0xa206, 0x0040, 0x1522,
170 0xa2a4, 0x00ff, 0x2061, 0x5040, 0x6118, 0xa186, 0x0028, 0x0040,
171 0x1509, 0xa186, 0x0032, 0x0040, 0x150f, 0xa186, 0x003c, 0x0040,
172 0x1515, 0xa482, 0x0064, 0x0048, 0x151f, 0x0078, 0x1519, 0xa482,
173 0x0050, 0x0048, 0x151f, 0x0078, 0x1519, 0xa482, 0x0043, 0x0048,
174 0x151f, 0x71c4, 0x71c6, 0x027f, 0x72ca, 0x0078, 0x127d, 0x6a0a,
175 0xa39d, 0x000a, 0x6804, 0xa305, 0x6806, 0x027f, 0x6b0c, 0x71c4,
176 0x0078, 0x1281, 0x77c4, 0x1078, 0x1956, 0x2091, 0x8000, 0x6a14,
177 0x6b1c, 0x2091, 0x8001, 0x70c8, 0x6816, 0x70cc, 0x681e, 0x2708,
178 0x0078, 0x1281, 0x70c4, 0x794c, 0x784e, 0x0078, 0x1283, 0x71c4,
179 0x72c8, 0x73cc, 0xa182, 0x0010, 0x00c8, 0x127c, 0x1078, 0x22e9,
180 0x0078, 0x1281, 0x77c4, 0x1078, 0x1956, 0x2091, 0x8000, 0x6a08,
181 0xa295, 0x0002, 0x6a0a, 0x2091, 0x8001, 0x2708, 0x0078, 0x1282,
182 0x77c4, 0x1078, 0x1956, 0x2091, 0x8000, 0x6a08, 0xa294, 0xfff9,
183 0x6a0a, 0x6804, 0xa005, 0x0040, 0x1567, 0x1078, 0x21b1, 0x2091,
184 0x8001, 0x2708, 0x0078, 0x1282, 0x77c4, 0x1078, 0x1956, 0x2091,
185 0x8000, 0x6a08, 0xa295, 0x0004, 0x6a0a, 0x6804, 0xa005, 0x0040,
186 0x157b, 0x1078, 0x21b1, 0x2091, 0x8001, 0x2708, 0x0078, 0x1282,
187 0x77c4, 0x2041, 0x0001, 0x2049, 0x0005, 0x2051, 0x0020, 0x2091,
188 0x8000, 0x1078, 0x1963, 0x2091, 0x8001, 0x2708, 0x6a08, 0x0078,
189 0x1282, 0x77c4, 0x72c8, 0x73cc, 0x77c6, 0x72ca, 0x73ce, 0x1078,
190 0x19c4, 0x00c0, 0x15a9, 0x6818, 0xa005, 0x0040, 0x15a9, 0x2708,
191 0x1078, 0x22f9, 0x00c0, 0x15a9, 0x7817, 0x0015, 0x2091, 0x8001,
192 0x007c, 0x2091, 0x8001, 0x0078, 0x1284, 0x77c4, 0x77c6, 0x2041,
193 0x0021, 0x2049, 0x0005, 0x2051, 0x0020, 0x2091, 0x8000, 0x1078,
194 0x1963, 0x2061, 0x5040, 0x606f, 0x0003, 0x6782, 0x6093, 0x000f,
195 0x6073, 0x0000, 0x7817, 0x0016, 0x1078, 0x21b1, 0x2091, 0x8001,
196 0x007c, 0x77c8, 0x77ca, 0x77c4, 0x77c6, 0xa7bc, 0xff00, 0x2091,
197 0x8000, 0x2061, 0x5040, 0x606f, 0x0002, 0x6073, 0x0000, 0x6782,
198 0x6093, 0x000f, 0x7817, 0x0017, 0x1078, 0x21b1, 0x2091, 0x8001,
199 0x2041, 0x0021, 0x2049, 0x0004, 0x2051, 0x0010, 0x2091, 0x8000,
200 0x1078, 0x1963, 0x70c8, 0x6836, 0x8738, 0xa784, 0x001f, 0x00c0,
201 0x15e8, 0x2091, 0x8001, 0x007c, 0x78cc, 0xa084, 0x0003, 0x00c0,
202 0x1618, 0x2039, 0x0000, 0x2041, 0x0021, 0x2049, 0x0004, 0x2051,
203 0x0008, 0x1078, 0x1956, 0x2091, 0x8000, 0x6808, 0xa80d, 0x690a,
204 0x2091, 0x8001, 0x8738, 0xa784, 0x001f, 0x00c0, 0x1601, 0xa7bc,
205 0xff00, 0x873f, 0x8738, 0x873f, 0xa784, 0x0f00, 0x00c0, 0x1601,
206 0x2091, 0x8000, 0x2069, 0x0100, 0x6830, 0xa084, 0x0040, 0x0040,
207 0x1641, 0x684b, 0x0004, 0x20a9, 0x0014, 0x6848, 0xa084, 0x0004,
208 0x0040, 0x162e, 0x0070, 0x162e, 0x0078, 0x1625, 0x684b, 0x0009,
209 0x20a9, 0x0014, 0x6848, 0xa084, 0x0001, 0x0040, 0x163b, 0x0070,
210 0x163b, 0x0078, 0x1632, 0x20a9, 0x00fa, 0x0070, 0x1641, 0x0078,
211 0x163d, 0x2079, 0x5000, 0x7817, 0x0018, 0x2061, 0x5040, 0x606f,
212 0x0001, 0x6073, 0x0000, 0x6093, 0x000f, 0x78cc, 0xa085, 0x0002,
213 0x78ce, 0x6808, 0xa084, 0xfffd, 0x680a, 0x681b, 0x0048, 0x2091,
214 0x8001, 0x007c, 0x78cc, 0xa084, 0xfffd, 0x78ce, 0xa084, 0x0001,
215 0x00c0, 0x1664, 0x1078, 0x1a0e, 0x71c4, 0x71c6, 0x794a, 0x007c,
216 0x1078, 0x1b36, 0x00c0, 0x129c, 0x75d8, 0x74dc, 0x75da, 0x74de,
217 0x0078, 0x1675, 0x2029, 0x0000, 0x2520, 0x71c4, 0x73c8, 0x72cc,
218 0x71c6, 0x73ca, 0x72ce, 0x2079, 0x5000, 0x2091, 0x8000, 0x1078,
219 0x1911, 0x2091, 0x8001, 0x0040, 0x172c, 0x20a9, 0x0005, 0x20a1,
220 0x5018, 0x2091, 0x8000, 0x41a1, 0x2091, 0x8001, 0x2009, 0x0020,
221 0x1078, 0x190c, 0x0040, 0x1698, 0x1078, 0x192b, 0x0078, 0x172c,
222 0x6004, 0xa084, 0xff00, 0x8007, 0x8009, 0x0040, 0x16fb, 0x0c7e,
223 0x2c68, 0x2091, 0x8000, 0x1078, 0x1911, 0x2091, 0x8001, 0x0040,
224 0x16cc, 0x2c00, 0x689e, 0x8109, 0x00c0, 0x16a0, 0x609f, 0x0000,
225 0x0c7f, 0x0c7e, 0x7218, 0x731c, 0x7420, 0x7524, 0x2c68, 0x689c,
226 0xa065, 0x0040, 0x16fa, 0x2009, 0x0020, 0x1078, 0x190c, 0x00c0,
227 0x16e3, 0x6004, 0xa084, 0x00ff, 0xa086, 0x0002, 0x00c0, 0x16cc,
228 0x2d00, 0x6002, 0x0078, 0x16b2, 0x0c7f, 0x0c7e, 0x609c, 0x2060,
229 0x1078, 0x1996, 0x0c7f, 0x609f, 0x0000, 0x1078, 0x1730, 0x2009,
230 0x000c, 0x6008, 0xa085, 0x0200, 0x600a, 0x1078, 0x1907, 0x1078,
231 0x192b, 0x0078, 0x172c, 0x0c7f, 0x0c7e, 0x609c, 0x2060, 0x1078,
232 0x1996, 0x0c7f, 0x609f, 0x0000, 0x1078, 0x1730, 0x2009, 0x000c,
233 0x6007, 0x0103, 0x601b, 0x0003, 0x1078, 0x1907, 0x1078, 0x192b,
234 0x0078, 0x172c, 0x0c7f, 0x74c4, 0x73c8, 0x72cc, 0x6014, 0x2091,
235 0x8000, 0x7817, 0x0012, 0x0e7e, 0x2071, 0x5040, 0x706f, 0x0005,
236 0x7073, 0x0000, 0x7376, 0x727a, 0x747e, 0x7082, 0x7087, 0x0000,
237 0x2c00, 0x708a, 0x708f, 0x0000, 0xa02e, 0x2530, 0x611c, 0x61a2,
238 0xa184, 0x0060, 0x0040, 0x171e, 0x1078, 0x467f, 0x0e7f, 0x6596,
239 0x65a6, 0x669a, 0x66aa, 0x60af, 0x0000, 0x60b3, 0x0000, 0x1078,
240 0x21b1, 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, 0x0078, 0x1287,
241 0x20a9, 0x0005, 0x2099, 0x5018, 0x2091, 0x8000, 0x530a, 0x2091,
242 0x8001, 0x2100, 0xa210, 0xa399, 0x0000, 0xa4a1, 0x0000, 0xa5a9,
243 0x0000, 0x007c, 0x71c4, 0x70c7, 0x0000, 0x7906, 0x0078, 0x1284,
244 0x71c4, 0x71c6, 0x2168, 0x0078, 0x174f, 0x2069, 0x1000, 0x690c,
245 0xa016, 0x2d04, 0xa210, 0x8d68, 0x8109, 0x00c0, 0x1751, 0xa285,
246 0x0000, 0x00c0, 0x175f, 0x70c3, 0x4000, 0x0078, 0x1761, 0x70c3,
247 0x4003, 0x70ca, 0x0078, 0x1287, 0x2011, 0x5067, 0x220c, 0x70c4,
248 0x8003, 0x0048, 0x1771, 0x1078, 0x3b49, 0xa184, 0x7fff, 0x0078,
249 0x1775, 0x1078, 0x3b3c, 0xa185, 0x8000, 0x2012, 0x0078, 0x1283,
250 0x71c4, 0x1078, 0x3b33, 0x6100, 0x2001, 0x5067, 0x2004, 0xa084,
251 0x8000, 0xa10d, 0x6204, 0x6308, 0x0078, 0x1281, 0x79e4, 0x0078,
252 0x1283, 0x71c4, 0x71c6, 0x2198, 0x20a1, 0x0042, 0x20a9, 0x0004,
253 0x53a3, 0x21a0, 0x2099, 0x0042, 0x20a9, 0x0004, 0x53a3, 0x0078,
254 0x1284, 0x70c4, 0x2068, 0x2079, 0x5000, 0x2091, 0x8000, 0x1078,
255 0x1911, 0x2091, 0x8001, 0x0040, 0x1825, 0x6007, 0x0001, 0x600b,
256 0x0000, 0x602b, 0x0000, 0x601b, 0x0006, 0x6a10, 0xa28c, 0x000f,
257 0xa284, 0x00f0, 0x8003, 0x8003, 0x8003, 0x8003, 0xa105, 0x6016,
258 0xa284, 0x0800, 0x0040, 0x17c0, 0x601b, 0x000a, 0x0078, 0x17c6,
259 0xa284, 0x1000, 0x0040, 0x17c6, 0x601b, 0x000c, 0xa284, 0x0300,
260 0x0040, 0x17cf, 0x602b, 0x0001, 0x8004, 0x8004, 0x8004, 0xa085,
261 0x0001, 0x601e, 0x6023, 0x0000, 0x6027, 0x0000, 0xa284, 0x0400,
262 0x0040, 0x17dc, 0x602b, 0x0000, 0x20a9, 0x0006, 0xac80, 0x000b,
263 0x20a0, 0xad80, 0x0005, 0x2098, 0x53a3, 0xa284, 0x0300, 0x00c0,
264 0x17f1, 0x6046, 0x604a, 0x604e, 0x6052, 0x6096, 0x609a, 0x0078,
265 0x17fb, 0x6800, 0x6046, 0x6804, 0x604a, 0x6e08, 0x664e, 0x6d0c,
266 0x6552, 0x6596, 0x669a, 0x6014, 0x2091, 0x8000, 0x7817, 0x0042,
267 0x2c08, 0x2061, 0x5040, 0x606f, 0x0005, 0x6073, 0x0000, 0x6077,
268 0x0000, 0x607b, 0x0000, 0x607f, 0x0000, 0x6082, 0x618a, 0xa284,
269 0x0400, 0x608e, 0x2091, 0x8001, 0x0e7e, 0x2071, 0x0020, 0x7007,
270 0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x0e7f, 0x2091, 0x8000,
271 0x1078, 0x21b1, 0x2091, 0x8001, 0x007c, 0x70c3, 0x4005, 0x0078,
272 0x1287, 0x0c7e, 0x0d7e, 0x0e7e, 0x0f7e, 0x2091, 0x8000, 0x2071,
273 0x5040, 0x2079, 0x0100, 0x2061, 0x0010, 0x70a0, 0xa06d, 0x0040,
274 0x18aa, 0x6a04, 0xa294, 0x00ff, 0xa286, 0x0007, 0x0040, 0x1844,
275 0xa286, 0x000f, 0x00c0, 0x18aa, 0x691c, 0xa184, 0x0080, 0x00c0,
276 0x18aa, 0x6824, 0xa18c, 0xff00, 0xa085, 0x0019, 0x6826, 0x71b0,
277 0x81ff, 0x0040, 0x1865, 0x0d7e, 0x2069, 0x0020, 0x6908, 0x6808,
278 0xa106, 0x00c0, 0x1856, 0x690c, 0x680c, 0xa106, 0x00c0, 0x185b,
279 0xa184, 0x00ff, 0x00c0, 0x185b, 0x0d7f, 0x78b8, 0xa084, 0x801f,
280 0x00c0, 0x1865, 0x7848, 0xa085, 0x000c, 0x784a, 0x71b0, 0x81ff,
281 0x0040, 0x1888, 0x70b3, 0x0000, 0x0d7e, 0x2069, 0x0020, 0x6807,
282 0x0008, 0x6804, 0xa084, 0x0008, 0x00c0, 0x1879, 0x6807, 0x0008,
283 0x6804, 0xa084, 0x0008, 0x00c0, 0x1880, 0x6807, 0x0002, 0x0d7f,
284 0x61c4, 0x62c8, 0x63cc, 0x61c6, 0x62ca, 0x63ce, 0x0e7e, 0x2071,
285 0x5000, 0x7266, 0x736a, 0xae80, 0x0019, 0x0e7f, 0x1078, 0x4598,
286 0x78a3, 0x0000, 0x7858, 0xa084, 0xedff, 0x785a, 0x70b4, 0xa080,
287 0x00da, 0x781a, 0x0f7f, 0x0e7f, 0x0d7f, 0x0c7f, 0x2091, 0x8001,
288 0x0078, 0x1284, 0x0f7f, 0x0e7f, 0x0d7f, 0x0c7f, 0x2091, 0x8001,
289 0x2001, 0x4005, 0x0078, 0x1286, 0x7980, 0x71c6, 0x71c4, 0xa182,
290 0x0003, 0x00c8, 0x127c, 0x7982, 0x0078, 0x1284, 0x7980, 0x71c6,
291 0x0078, 0x1284, 0x7974, 0x71c6, 0x71c4, 0x7976, 0x7978, 0x71ca,
292 0x71c8, 0x797a, 0x797c, 0x71ce, 0x71cc, 0x797e, 0x0078, 0x1284,
293 0x7974, 0x71c6, 0x7978, 0x71ca, 0x797c, 0x71ce, 0x0078, 0x1284,
294 0x7900, 0x71c6, 0x71c4, 0x7902, 0x2001, 0x04fd, 0x2004, 0xa082,
295 0x0005, 0x0048, 0x18e7, 0x0038, 0x18e9, 0x0078, 0x18f3, 0x00a8,
296 0x18f3, 0xa18c, 0x0001, 0x00c0, 0x18f1, 0x20b9, 0x2222, 0x0078,
297 0x18f3, 0x20b9, 0x1212, 0x0078, 0x1284, 0x7900, 0x71c6, 0x0078,
298 0x1284, 0x2009, 0x5074, 0x2104, 0x70c6, 0x70c4, 0x200a, 0x0078,
299 0x1284, 0x2009, 0x5074, 0x2104, 0x70c6, 0x0078, 0x1284, 0xac80,
300 0x0001, 0x1078, 0x1af2, 0x007c, 0xac80, 0x0001, 0x1078, 0x1a92,
301 0x007c, 0x7850, 0xa065, 0x0040, 0x1919, 0x2c04, 0x7852, 0x2063,
302 0x0000, 0x007c, 0x0f7e, 0x2079, 0x5000, 0x7850, 0xa06d, 0x0040,
303 0x1929, 0x2d04, 0x7852, 0x6803, 0x0000, 0x6807, 0x0000, 0x680b,
304 0x0000, 0x0f7f, 0x007c, 0x2091, 0x8000, 0x0f7e, 0x2079, 0x5000,
305 0x7850, 0x2062, 0x2c00, 0xa005, 0x00c0, 0x1938, 0x1078, 0x23ca,
306 0x7852, 0x0f7f, 0x2091, 0x8001, 0x007c, 0x0f7e, 0x2079, 0x5000,
307 0x7850, 0x206a, 0x2d00, 0x7852, 0x0f7f, 0x007c, 0x2011, 0x7700,
308 0x7a52, 0x7bec, 0x8319, 0x0040, 0x1953, 0xa280, 0x0031, 0x2012,
309 0x2010, 0x0078, 0x194a, 0x2013, 0x0000, 0x007c, 0xa784, 0x0f00,
310 0x800b, 0xa784, 0x001f, 0x8003, 0x8003, 0x8003, 0x8003, 0xa105,
311 0xa0e8, 0x5300, 0x007c, 0x1078, 0x1956, 0x2900, 0x682a, 0x2a00,
312 0x682e, 0x6808, 0xa084, 0xffef, 0xa80d, 0x690a, 0x2009, 0x5052,
313 0x210c, 0x6804, 0xa005, 0x0040, 0x1995, 0xa116, 0x00c0, 0x1980,
314 0x2060, 0x6000, 0x6806, 0x017e, 0x200b, 0x0000, 0x0078, 0x1983,
315 0x2009, 0x0000, 0x017e, 0x6804, 0xa065, 0x0040, 0x1992, 0x6000,
316 0x6806, 0x1078, 0x19a3, 0x1078, 0x1c42, 0x6810, 0x8001, 0x6812,
317 0x00c0, 0x1983, 0x017f, 0x6902, 0x6906, 0x007c, 0xa065, 0x0040,
318 0x19a2, 0x609c, 0x609f, 0x0000, 0x2008, 0x1078, 0x192b, 0x2100,
319 0x0078, 0x1996, 0x007c, 0x6007, 0x0103, 0x608f, 0x0000, 0x20a9,
320 0x001c, 0xac80, 0x0005, 0x20a0, 0x2001, 0x0000, 0x40a4, 0x6828,
321 0x601a, 0x682c, 0x6022, 0x007c, 0x0e7e, 0x2071, 0x5040, 0x704c,
322 0xa08c, 0x0200, 0x00c0, 0x19c2, 0xa088, 0x5080, 0x2d0a, 0x8000,
323 0x704e, 0xa006, 0x0e7f, 0x007c, 0x1078, 0x1956, 0x2091, 0x8000,
324 0x6804, 0x781e, 0xa065, 0x0040, 0x1a0d, 0x0078, 0x19d5, 0x2c00,
325 0x781e, 0x6000, 0xa065, 0x0040, 0x1a0d, 0x600c, 0xa306, 0x00c0,
326 0x19cf, 0x6010, 0xa206, 0x00c0, 0x19cf, 0x2c28, 0x2001, 0x5052,
327 0x2004, 0xac06, 0x00c0, 0x19e6, 0x0078, 0x1a0b, 0x6804, 0xac06,
328 0x00c0, 0x19f3, 0x6000, 0xa065, 0x6806, 0x00c0, 0x19fd, 0x6803,
329 0x0000, 0x0078, 0x19fd, 0x6400, 0x781c, 0x2060, 0x6402, 0xa486,
330 0x0000, 0x00c0, 0x19fd, 0x2c00, 0x6802, 0x2560, 0x1078, 0x19a3,
331 0x601b, 0x0005, 0x6023, 0x0020, 0x1078, 0x1c42, 0x6810, 0x8001,
332 0x1050, 0x23ca, 0x6812, 0xa085, 0xffff, 0x007c, 0x2039, 0x0000,
333 0x2041, 0x0021, 0x2049, 0x0004, 0x2051, 0x0008, 0x2091, 0x8000,
334 0x1078, 0x1963, 0x8738, 0xa784, 0x001f, 0x00c0, 0x1a18, 0xa7bc,
335 0xff00, 0x873f, 0x8738, 0x873f, 0xa784, 0x0f00, 0x00c0, 0x1a18,
336 0x2091, 0x8001, 0x007c, 0x2061, 0x0000, 0x6018, 0xa084, 0x0001,
337 0x00c0, 0x1a3c, 0x2091, 0x8000, 0x78e0, 0x78e3, 0x0000, 0x2091,
338 0x8001, 0xa005, 0x00c0, 0x1a3d, 0x007c, 0xa08c, 0xfff0, 0x0040,
339 0x1a43, 0x1078, 0x23ca, 0x0079, 0x1a45, 0x1a55, 0x1a58, 0x1a5e,
340 0x1a62, 0x1a56, 0x1a66, 0x1a6c, 0x1a56, 0x1a56, 0x1c0c, 0x1c30,
341 0x1c34, 0x1a56, 0x1a56, 0x1a56, 0x1a56, 0x007c, 0x1078, 0x23ca,
342 0x1078, 0x1a0e, 0x2001, 0x8001, 0x0078, 0x1c3a, 0x2001, 0x8003,
343 0x0078, 0x1c3a, 0x2001, 0x8004, 0x0078, 0x1c3a, 0x1078, 0x1a0e,
344 0x2001, 0x8006, 0x0078, 0x1c3a, 0x2001, 0x8007, 0x0078, 0x1c3a,
345 0x2030, 0x2138, 0xa782, 0x0021, 0x0048, 0x1a78, 0x2009, 0x0020,
346 0x2600, 0x1078, 0x1a92, 0x00c0, 0x1a91, 0xa7ba, 0x0020, 0x0048,
347 0x1a90, 0x0040, 0x1a90, 0x2708, 0xa6b0, 0x0020, 0xa290, 0x0040,
348 0xa399, 0x0000, 0xa4a1, 0x0000, 0xa5a9, 0x0000, 0x0078, 0x1a72,
349 0xa006, 0x007c, 0x81ff, 0x0040, 0x1acd, 0x2099, 0x0030, 0x20a0,
350 0x700c, 0xa084, 0x00ff, 0x0040, 0x1aa4, 0x7007, 0x0004, 0x7004,
351 0xa084, 0x0004, 0x00c0, 0x1a9f, 0x21a8, 0x7017, 0x0000, 0x810b,
352 0x7112, 0x721a, 0x731e, 0x7422, 0x7526, 0x780c, 0xa085, 0x0001,
353 0x7002, 0x7007, 0x0001, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005,
354 0x00c8, 0x1ac1, 0x2009, 0x0022, 0x2104, 0xa084, 0x4000, 0x00c0,
355 0x1ab3, 0x7008, 0x800b, 0x00c8, 0x1ab3, 0x7007, 0x0002, 0xa08c,
356 0x01e0, 0x00c0, 0x1acd, 0x53a5, 0xa006, 0x7003, 0x0000, 0x007c,
357 0x2030, 0x2138, 0xa782, 0x0021, 0x0048, 0x1ad8, 0x2009, 0x0020,
358 0x2600, 0x1078, 0x1af2, 0x00c0, 0x1af1, 0xa7ba, 0x0020, 0x0048,
359 0x1af0, 0x0040, 0x1af0, 0x2708, 0xa6b0, 0x0020, 0xa290, 0x0040,
360 0xa399, 0x0000, 0xa4a1, 0x0000, 0xa5a9, 0x0000, 0x0078, 0x1ad2,
361 0xa006, 0x007c, 0x81ff, 0x0040, 0x1b33, 0x2098, 0x20a1, 0x0030,
362 0x700c, 0xa084, 0x00ff, 0x0040, 0x1b04, 0x7007, 0x0004, 0x7004,
363 0xa084, 0x0004, 0x00c0, 0x1aff, 0x21a8, 0x7017, 0x0000, 0x810b,
364 0x7112, 0x721a, 0x731e, 0x7422, 0x7526, 0x780c, 0xa085, 0x0000,
365 0x7002, 0x53a6, 0x7007, 0x0001, 0x2001, 0x04fd, 0x2004, 0xa082,
366 0x0005, 0x00c8, 0x1b22, 0x2009, 0x0022, 0x2104, 0xa084, 0x4000,
367 0x00c0, 0x1b14, 0x7010, 0xa084, 0xf000, 0x0040, 0x1b2b, 0x7007,
368 0x0008, 0x0078, 0x1b2f, 0x7108, 0x8103, 0x00c8, 0x1b14, 0x7007,
369 0x0002, 0xa184, 0x01e0, 0x7003, 0x0000, 0x007c, 0x2001, 0x04fd,
370 0x2004, 0xa082, 0x0004, 0x00c8, 0x1b3f, 0x0078, 0x1b42, 0xa006,
371 0x0078, 0x1b44, 0xa085, 0x0001, 0x007c, 0x0e7e, 0x2071, 0x5000,
372 0x2d08, 0x7058, 0x6802, 0xa005, 0x00c0, 0x1b4f, 0x715e, 0x715a,
373 0x0e7f, 0x007c, 0x2c08, 0x7858, 0x6002, 0xa005, 0x00c0, 0x1b59,
374 0x795e, 0x795a, 0x007c, 0x2091, 0x8000, 0x6003, 0x0000, 0x2c08,
375 0x785c, 0xa065, 0x00c0, 0x1b67, 0x795a, 0x0078, 0x1b68, 0x6102,
376 0x795e, 0x2091, 0x8001, 0x1078, 0x21ce, 0x007c, 0x0e7e, 0x2071,
377 0x5000, 0x7058, 0xa06d, 0x0040, 0x1b7c, 0x6800, 0x705a, 0xa005,
378 0x00c0, 0x1b7b, 0x705e, 0x8dff, 0x0e7f, 0x007c, 0x0d7e, 0x0c7e,
379 0x0f7e, 0x2079, 0x5000, 0xaf80, 0x0016, 0x2060, 0x6000, 0xa005,
380 0x0040, 0x1bac, 0x2068, 0x6814, 0xa306, 0x00c0, 0x1b95, 0x6828,
381 0xa084, 0x00ff, 0xa406, 0x0040, 0x1b98, 0x2d60, 0x0078, 0x1b86,
382 0x6800, 0xa005, 0x6002, 0x00c0, 0x1ba4, 0xaf80, 0x0016, 0xac06,
383 0x0040, 0x1ba3, 0x2c00, 0x785e, 0x0d7e, 0x689c, 0xa005, 0x0040,
384 0x1bab, 0x1078, 0x1996, 0x007f, 0x0f7f, 0x0c7f, 0x0d7f, 0xa005,
385 0x007c, 0x0d7e, 0x0c7e, 0x0f7e, 0x2079, 0x5000, 0xaf80, 0x0016,
386 0x2060, 0x6000, 0xa005, 0x0040, 0x1bdb, 0x2068, 0x6814, 0xa084,
387 0x00ff, 0xa306, 0x0040, 0x1bc7, 0x2d60, 0x0078, 0x1bb9, 0x6800,
388 0xa005, 0x6002, 0x00c0, 0x1bd3, 0xaf80, 0x0016, 0xac06, 0x0040,
389 0x1bd2, 0x2c00, 0x785e, 0x0d7e, 0x689c, 0xa005, 0x0040, 0x1bda,
390 0x1078, 0x1996, 0x007f, 0x0f7f, 0x0c7f, 0x0d7f, 0xa005, 0x007c,
391 0x0d7e, 0x0c7e, 0x0f7e, 0x2079, 0x5000, 0xaf80, 0x0016, 0x2060,
392 0x6000, 0xa06d, 0x0040, 0x1c07, 0x6814, 0xa306, 0x0040, 0x1bf3,
393 0x2d60, 0x0078, 0x1be8, 0x6800, 0xa005, 0x6002, 0x00c0, 0x1bff,
394 0xaf80, 0x0016, 0xac06, 0x0040, 0x1bfe, 0x2c00, 0x785e, 0x0d7e,
395 0x689c, 0xa005, 0x0040, 0x1c06, 0x1078, 0x1996, 0x007f, 0x0f7f,
396 0x0c7f, 0x0d7f, 0xa005, 0x007c, 0x2091, 0x8000, 0x2069, 0x5040,
397 0x6800, 0xa086, 0x0000, 0x0040, 0x1c1a, 0x2091, 0x8001, 0x78e3,
398 0x0009, 0x007c, 0x6880, 0xa0bc, 0xff00, 0x2041, 0x0021, 0x2049,
399 0x0004, 0x2051, 0x0010, 0x1078, 0x1963, 0x8738, 0xa784, 0x001f,
400 0x00c0, 0x1c23, 0x2091, 0x8001, 0x2001, 0x800a, 0x0078, 0x1c3a,
401 0x2001, 0x800c, 0x0078, 0x1c3a, 0x1078, 0x1a0e, 0x2001, 0x800d,
402 0x0078, 0x1c3a, 0x70c2, 0x2061, 0x0000, 0x601b, 0x0001, 0x2091,
403 0x4080, 0x007c, 0x6004, 0x2c08, 0x2063, 0x0000, 0x7884, 0x8000,
404 0x7886, 0x7888, 0xa005, 0x798a, 0x0040, 0x1c51, 0x2c02, 0x0078,
405 0x1c52, 0x798e, 0x007c, 0x6807, 0x0103, 0x0c7e, 0x2061, 0x5000,
406 0x2d08, 0x206b, 0x0000, 0x6084, 0x8000, 0x6086, 0x6088, 0xa005,
407 0x618a, 0x0040, 0x1c66, 0x2d02, 0x0078, 0x1c67, 0x618e, 0x0c7f,
408 0x007c, 0x1078, 0x1c7a, 0x0040, 0x1c79, 0x0c7e, 0x609c, 0xa065,
409 0x0040, 0x1c74, 0x1078, 0x1996, 0x0c7f, 0x609f, 0x0000, 0x1078,
410 0x192b, 0x007c, 0x788c, 0xa065, 0x0040, 0x1c8c, 0x2091, 0x8000,
411 0x7884, 0x8001, 0x7886, 0x2c04, 0x788e, 0xa005, 0x00c0, 0x1c8a,
412 0x788a, 0x8000, 0x2091, 0x8001, 0x007c, 0x20a9, 0x0010, 0xa006,
413 0x8004, 0x8086, 0x818e, 0x00c8, 0x1c96, 0xa200, 0x0070, 0x1c9a,
414 0x0078, 0x1c91, 0x8086, 0x818e, 0x007c, 0x157e, 0x20a9, 0x0010,
415 0xa005, 0x0040, 0x1cc0, 0xa11a, 0x00c8, 0x1cc0, 0x8213, 0x818d,
416 0x0048, 0x1cb1, 0xa11a, 0x00c8, 0x1cb2, 0x0070, 0x1cb8, 0x0078,
417 0x1ca6, 0xa11a, 0x2308, 0x8210, 0x0070, 0x1cb8, 0x0078, 0x1ca6,
418 0x007e, 0x3200, 0xa084, 0xf7ff, 0x2080, 0x007f, 0x157f, 0x007c,
419 0x007e, 0x3200, 0xa085, 0x0800, 0x0078, 0x1cbc, 0x7994, 0x70d0,
420 0xa106, 0x0040, 0x1d34, 0x2091, 0x8000, 0x2071, 0x0020, 0x7004,
421 0xa005, 0x00c0, 0x1d34, 0x7008, 0x7208, 0xa206, 0x00c0, 0x1d34,
422 0xa286, 0x0008, 0x00c0, 0x1d34, 0x2071, 0x0010, 0x1078, 0x1911,
423 0x0040, 0x1d34, 0x7a9c, 0x7b98, 0x7ca4, 0x7da0, 0xa184, 0xff00,
424 0x0040, 0x1d02, 0x2031, 0x0000, 0x810b, 0x86b5, 0x810b, 0x86b5,
425 0x810b, 0x86b5, 0x810b, 0x86b5, 0x810b, 0x86b5, 0x810b, 0x86b5,
426 0x2100, 0xa210, 0x2600, 0xa319, 0xa4a1, 0x0000, 0xa5a9, 0x0000,
427 0x0078, 0x1d0c, 0x8107, 0x8004, 0x8004, 0xa210, 0xa399, 0x0000,
428 0xa4a1, 0x0000, 0xa5a9, 0x0000, 0x2009, 0x0020, 0x1078, 0x190c,
429 0x2091, 0x8001, 0x0040, 0x1d2b, 0x1078, 0x192b, 0x78a8, 0x8000,
430 0x78aa, 0xa086, 0x0002, 0x00c0, 0x1d34, 0x2091, 0x8000, 0x78e3,
431 0x0002, 0x78ab, 0x0000, 0x78cc, 0xa085, 0x0003, 0x78ce, 0x2091,
432 0x8001, 0x0078, 0x1d34, 0x78ab, 0x0000, 0x1078, 0x208b, 0x6004,
433 0xa084, 0x000f, 0x0079, 0x1d39, 0x2071, 0x0010, 0x2091, 0x8001,
434 0x007c, 0x1d49, 0x1d6b, 0x1d91, 0x1d49, 0x1dae, 0x1d58, 0x1f0d,
435 0x1f28, 0x1d49, 0x1d65, 0x1d8b, 0x1df6, 0x1e63, 0x1eb3, 0x1ec5,
436 0x1f24, 0x2039, 0x0400, 0x78dc, 0xa705, 0x78de, 0x6008, 0xa705,
437 0x600a, 0x1078, 0x1fa6, 0x609c, 0x78da, 0x1078, 0x2073, 0x007c,
438 0x78dc, 0xa084, 0x0100, 0x0040, 0x1d5f, 0x0078, 0x1d49, 0x601c,
439 0xa085, 0x0080, 0x601e, 0x0078, 0x1d72, 0x1078, 0x1b36, 0x00c0,
440 0x1d49, 0x1078, 0x20a5, 0x78dc, 0xa084, 0x0100, 0x0040, 0x1d72,
441 0x0078, 0x1d49, 0x78df, 0x0000, 0x6004, 0x8007, 0xa084, 0x00ff,
442 0x78d2, 0x8001, 0x609f, 0x0000, 0x0040, 0x1d88, 0x1078, 0x1fa6,
443 0x0040, 0x1d88, 0x78dc, 0xa085, 0x0100, 0x78de, 0x0078, 0x1d8a,
444 0x1078, 0x1fca, 0x007c, 0x1078, 0x1b36, 0x00c0, 0x1d49, 0x1078,
445 0x20a1, 0x78dc, 0xa08c, 0x0e00, 0x00c0, 0x1d9a, 0xa084, 0x0100,
446 0x00c0, 0x1d9c, 0x0078, 0x1d49, 0x1078, 0x1fa6, 0x00c0, 0x1dad,
447 0x6104, 0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x1f63, 0xa186,
448 0x000f, 0x0040, 0x1f63, 0x1078, 0x1fca, 0x007c, 0x78dc, 0xa084,
449 0x0100, 0x0040, 0x1db5, 0x0078, 0x1d49, 0x78df, 0x0000, 0x6714,
450 0x2011, 0x0001, 0x20a9, 0x0001, 0x6018, 0xa084, 0x00ff, 0xa005,
451 0x0040, 0x1dd8, 0x2011, 0x0001, 0xa7bc, 0xff00, 0x20a9, 0x0020,
452 0xa08e, 0x0001, 0x0040, 0x1dd8, 0x2039, 0x0000, 0x2011, 0x0002,
453 0x20a9, 0x0100, 0xa08e, 0x0002, 0x0040, 0x1dd8, 0x0078, 0x1df3,
454 0x1078, 0x1956, 0x2091, 0x8000, 0x682b, 0x0000, 0x682f, 0x0000,
455 0x6808, 0xa084, 0xffde, 0x680a, 0xade8, 0x0010, 0x2091, 0x8001,
456 0x0070, 0x1dec, 0x0078, 0x1dda, 0x8211, 0x0040, 0x1df3, 0x20a9,
457 0x0100, 0x0078, 0x1dda, 0x1078, 0x192b, 0x007c, 0x2001, 0x5067,
458 0x2004, 0xa084, 0x8000, 0x0040, 0x1f8b, 0x6114, 0x1078, 0x20c2,
459 0x6900, 0xa184, 0x0001, 0x0040, 0x1e17, 0x6028, 0xa084, 0x00ff,
460 0x00c0, 0x1f83, 0x6800, 0xa084, 0x0001, 0x0040, 0x1f8b, 0x6803,
461 0x0000, 0x680b, 0x0000, 0x6807, 0x0000, 0x0078, 0x1f93, 0x2011,
462 0x0001, 0x6020, 0xa084, 0x4000, 0x0040, 0x1e20, 0xa295, 0x0002,
463 0x6020, 0xa084, 0x0100, 0x0040, 0x1e27, 0xa295, 0x0008, 0x601c,
464 0xa084, 0x0002, 0x0040, 0x1e2e, 0xa295, 0x0004, 0x602c, 0xa08c,
465 0x00ff, 0xa182, 0x0002, 0x0048, 0x1f8f, 0xa182, 0x001b, 0x00c8,
466 0x1f8f, 0x0040, 0x1f8f, 0x690e, 0x602c, 0x8007, 0xa08c, 0x00ff,
467 0xa182, 0x0002, 0x0048, 0x1f8f, 0xa182, 0x001b, 0x00c8, 0x1f8f,
468 0x0040, 0x1f8f, 0x6912, 0x6030, 0xa005, 0x00c0, 0x1e51, 0x2001,
469 0x001e, 0x8000, 0x6816, 0x6028, 0xa084, 0x00ff, 0x0040, 0x1f8b,
470 0x6806, 0x6028, 0x8007, 0xa084, 0x00ff, 0x0040, 0x1f8b, 0x680a,
471 0x6a02, 0x0078, 0x1f93, 0x2001, 0x5067, 0x2004, 0xa084, 0x8000,
472 0x0040, 0x1f8b, 0x6114, 0x1078, 0x20c2, 0x2091, 0x8000, 0x6a04,
473 0x6b08, 0x6418, 0xa484, 0x0003, 0x0040, 0x1e89, 0x6128, 0xa18c,
474 0x00ff, 0x8001, 0x00c0, 0x1e82, 0x2100, 0xa210, 0x0048, 0x1eaf,
475 0x0078, 0x1e89, 0x8001, 0x00c0, 0x1eaf, 0x2100, 0xa212, 0x0048,
476 0x1eaf, 0xa484, 0x000c, 0x0040, 0x1ea3, 0x6128, 0x810f, 0xa18c,
477 0x00ff, 0xa082, 0x0004, 0x00c0, 0x1e9b, 0x2100, 0xa318, 0x0048,
478 0x1eaf, 0x0078, 0x1ea3, 0xa082, 0x0004, 0x00c0, 0x1eaf, 0x2100,
479 0xa31a, 0x0048, 0x1eaf, 0x6030, 0xa005, 0x0040, 0x1ea9, 0x8000,
480 0x6816, 0x6a06, 0x6b0a, 0x2091, 0x8001, 0x0078, 0x1f93, 0x2091,
481 0x8001, 0x0078, 0x1f8f, 0x6114, 0x1078, 0x20c2, 0x2091, 0x8000,
482 0x6b08, 0x8318, 0x0048, 0x1ec1, 0x6b0a, 0x2091, 0x8001, 0x0078,
483 0x1fa2, 0x2091, 0x8001, 0x0078, 0x1f8f, 0x6024, 0x8007, 0xa084,
484 0x00ff, 0x0040, 0x1ee3, 0xa086, 0x0080, 0x00c0, 0x1f0b, 0x20a9,
485 0x0008, 0x2069, 0x7410, 0x2091, 0x8000, 0x6800, 0xa084, 0xfcff,
486 0x6802, 0xade8, 0x0008, 0x0070, 0x1edf, 0x0078, 0x1ed5, 0x2091,
487 0x8001, 0x0078, 0x1f93, 0x6028, 0xa015, 0x0040, 0x1f0b, 0x6114,
488 0x1078, 0x20c2, 0x0d7e, 0xade8, 0x0007, 0x2091, 0x8000, 0x6800,
489 0xa00d, 0x0040, 0x1f08, 0xa206, 0x0040, 0x1ef9, 0x2168, 0x0078,
490 0x1eef, 0x0c7e, 0x2160, 0x6000, 0x6802, 0x1078, 0x192b, 0x0c7f,
491 0x0d7f, 0x6808, 0x8000, 0x680a, 0x2091, 0x8001, 0x0078, 0x1fa2,
492 0x2091, 0x8001, 0x0d7f, 0x0078, 0x1f8b, 0x6114, 0x1078, 0x20c2,
493 0x6800, 0xa084, 0x0001, 0x0040, 0x1f7b, 0x2091, 0x8000, 0x6a04,
494 0x8210, 0x0048, 0x1f20, 0x6a06, 0x2091, 0x8001, 0x0078, 0x1fa2,
495 0x2091, 0x8001, 0x0078, 0x1f8f, 0x1078, 0x1b36, 0x00c0, 0x1d49,
496 0x6114, 0x1078, 0x20c2, 0x60be, 0x6900, 0xa184, 0x0008, 0x0040,
497 0x1f35, 0x6020, 0xa085, 0x0100, 0x6022, 0xa184, 0x0001, 0x0040,
498 0x1f8b, 0xa184, 0x0100, 0x00c0, 0x1f77, 0xa184, 0x0200, 0x00c0,
499 0x1f73, 0x681c, 0xa005, 0x00c0, 0x1f7f, 0x6004, 0xa084, 0x00ff,
500 0xa086, 0x000f, 0x00c0, 0x1f4e, 0x1078, 0x20a5, 0x78df, 0x0000,
501 0x6004, 0x8007, 0xa084, 0x00ff, 0x78d2, 0x8001, 0x609f, 0x0000,
502 0x0040, 0x1f63, 0x1078, 0x1fa6, 0x0040, 0x1f63, 0x78dc, 0xa085,
503 0x0100, 0x78de, 0x007c, 0x78d7, 0x0000, 0x78db, 0x0000, 0x6024,
504 0xa084, 0xff00, 0x6026, 0x1078, 0x39aa, 0x0040, 0x1cc6, 0x1078,
505 0x1b5b, 0x0078, 0x1cc6, 0x2009, 0x0017, 0x0078, 0x1f95, 0x2009,
506 0x000e, 0x0078, 0x1f95, 0x2009, 0x0007, 0x0078, 0x1f95, 0x2009,
507 0x0035, 0x0078, 0x1f95, 0x2009, 0x003e, 0x0078, 0x1f95, 0x2009,
508 0x0004, 0x0078, 0x1f95, 0x2009, 0x0006, 0x0078, 0x1f95, 0x2009,
509 0x0016, 0x0078, 0x1f95, 0x2009, 0x0001, 0x6024, 0xa084, 0xff00,
510 0xa105, 0x6026, 0x2091, 0x8000, 0x1078, 0x1c42, 0x2091, 0x8001,
511 0x0078, 0x1cc6, 0x1078, 0x192b, 0x0078, 0x1cc6, 0x78d4, 0xa06d,
512 0x00c0, 0x1fb1, 0x2c00, 0x78d6, 0x78da, 0x609f, 0x0000, 0x0078,
513 0x1fbd, 0x2c00, 0x689e, 0x609f, 0x0000, 0x78d6, 0x2d00, 0x6002,
514 0x78d8, 0xad06, 0x00c0, 0x1fbd, 0x6002, 0x78d0, 0x8001, 0x78d2,
515 0x00c0, 0x1fc9, 0x78dc, 0xa084, 0xfeff, 0x78de, 0x78d8, 0x2060,
516 0xa006, 0x007c, 0xa02e, 0x2530, 0x611c, 0x61a2, 0xa184, 0xe1ff,
517 0x601e, 0xa184, 0x0060, 0x0040, 0x1fd9, 0x0e7e, 0x1078, 0x467f,
518 0x0e7f, 0x6596, 0x65a6, 0x669a, 0x66aa, 0x60af, 0x0000, 0x60b3,
519 0x0000, 0x6714, 0x1078, 0x1956, 0x2091, 0x8000, 0x60a0, 0xa084,
520 0x8000, 0x00c0, 0x2000, 0x6808, 0xa084, 0x0001, 0x0040, 0x2000,
521 0x2091, 0x8001, 0x1078, 0x19a3, 0x2091, 0x8000, 0x1078, 0x1c42,
522 0x2091, 0x8001, 0x78d7, 0x0000, 0x78db, 0x0000, 0x0078, 0x2072,
523 0x6024, 0xa096, 0x0001, 0x00c0, 0x2007, 0x8000, 0x6026, 0x6a10,
524 0x6814, 0x2091, 0x8001, 0xa202, 0x0048, 0x2016, 0x0040, 0x2016,
525 0x2039, 0x0200, 0x1078, 0x2073, 0x0078, 0x2072, 0x2c08, 0x2091,
526 0x8000, 0x60a0, 0xa084, 0x8000, 0x0040, 0x2043, 0x6800, 0xa065,
527 0x0040, 0x2048, 0x6a04, 0x0e7e, 0x2071, 0x5040, 0x7000, 0xa084,
528 0x0001, 0x0040, 0x203d, 0x7048, 0xa206, 0x00c0, 0x203d, 0x6b04,
529 0x231c, 0x2160, 0x6302, 0x2300, 0xa005, 0x00c0, 0x2038, 0x6902,
530 0x2260, 0x6102, 0x0e7f, 0x0078, 0x204f, 0x2160, 0x6202, 0x6906,
531 0x0e7f, 0x0078, 0x204f, 0x6800, 0xa065, 0x0040, 0x2048, 0x6102,
532 0x6902, 0x00c0, 0x204c, 0x6906, 0x2160, 0x6003, 0x0000, 0x2160,
533 0x60a0, 0xa084, 0x8000, 0x0040, 0x2059, 0x6808, 0xa084, 0xfffc,
534 0x680a, 0x6810, 0x8000, 0x6812, 0x2091, 0x8001, 0x6808, 0xa08c,
535 0x0040, 0x0040, 0x2068, 0xa086, 0x0040, 0x680a, 0x1078, 0x19b4,
536 0x2091, 0x8000, 0x1078, 0x21b1, 0x2091, 0x8001, 0x78db, 0x0000,
537 0x78d7, 0x0000, 0x007c, 0x6008, 0xa705, 0x600a, 0x2091, 0x8000,
538 0x1078, 0x1c42, 0x2091, 0x8001, 0x78d8, 0xa065, 0x0040, 0x2086,
539 0x609c, 0x78da, 0x609f, 0x0000, 0x0078, 0x2076, 0x78d7, 0x0000,
540 0x78db, 0x0000, 0x007c, 0x7990, 0x7894, 0x8000, 0xa10a, 0x00c8,
541 0x2092, 0xa006, 0x7896, 0x70d2, 0x7804, 0xa005, 0x0040, 0x20a0,
542 0x8001, 0x7806, 0x00c0, 0x20a0, 0x0068, 0x20a0, 0x2091, 0x4080,
543 0x007c, 0x2039, 0x20b9, 0x0078, 0x20a7, 0x2039, 0x20bf, 0x2704,
544 0xa005, 0x0040, 0x20b8, 0xac00, 0x2068, 0x6b08, 0x6c0c, 0x6910,
545 0x6a14, 0x690a, 0x6a0e, 0x6b12, 0x6c16, 0x8738, 0x0078, 0x20a7,
546 0x007c, 0x0003, 0x0009, 0x000f, 0x0015, 0x001b, 0x0000, 0x0015,
547 0x001b, 0x0000, 0x0c7e, 0x1078, 0x3b33, 0x2c68, 0x0c7f, 0x007c,
548 0x0010, 0x2139, 0x0068, 0x2139, 0x2029, 0x0000, 0x78cb, 0x0000,
549 0x788c, 0xa065, 0x0040, 0x2132, 0x2009, 0x5074, 0x2104, 0xa084,
550 0x0001, 0x0040, 0x2100, 0x6004, 0xa086, 0x0103, 0x00c0, 0x2100,
551 0x6018, 0xa005, 0x00c0, 0x2100, 0x6014, 0xa005, 0x00c0, 0x2100,
552 0x0d7e, 0x2069, 0x0000, 0x6818, 0xa084, 0x0001, 0x00c0, 0x20ff,
553 0x600c, 0x70c6, 0x6010, 0x70ca, 0x70c3, 0x8020, 0x681b, 0x0001,
554 0x2091, 0x4080, 0x0d7f, 0x1078, 0x1c69, 0x0078, 0x2137, 0x0d7f,
555 0x1078, 0x213a, 0x0040, 0x2132, 0x6204, 0xa294, 0x00ff, 0xa296,
556 0x0003, 0x0040, 0x2112, 0x6204, 0xa296, 0x0110, 0x00c0, 0x2120,
557 0x78cb, 0x0001, 0x6204, 0xa294, 0xff00, 0x8217, 0x8211, 0x0040,
558 0x2120, 0x85ff, 0x00c0, 0x2132, 0x8210, 0xa202, 0x00c8, 0x2132,
559 0x057e, 0x1078, 0x2149, 0x057f, 0x0040, 0x212d, 0x78e0, 0xa086,
560 0x0003, 0x0040, 0x2132, 0x0078, 0x2120, 0x8528, 0x78c8, 0xa005,
561 0x0040, 0x20d0, 0x85ff, 0x0040, 0x2139, 0x2091, 0x4080, 0x78b0,
562 0x70d6, 0x007c, 0x7bac, 0x79b0, 0x70d4, 0xa102, 0x00c0, 0x2143,
563 0x2300, 0xa005, 0x007c, 0x0048, 0x2147, 0xa302, 0x007c, 0x8002,
564 0x007c, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x00c8, 0x2163,
565 0x2091, 0x8000, 0x2071, 0x0020, 0x7004, 0xa005, 0x00c0, 0x2198,
566 0x7008, 0x7208, 0xa206, 0x00c0, 0x2198, 0xa286, 0x0008, 0x00c0,
567 0x2198, 0x2071, 0x0010, 0x1078, 0x219d, 0x2009, 0x0020, 0x6004,
568 0xa086, 0x0103, 0x00c0, 0x2172, 0x6028, 0xa005, 0x00c0, 0x2172,
569 0x2009, 0x000c, 0x1078, 0x1907, 0x0040, 0x218b, 0x78c4, 0x8000,
570 0x78c6, 0xa086, 0x0002, 0x00c0, 0x2198, 0x2091, 0x8000, 0x78e3,
571 0x0003, 0x78c7, 0x0000, 0x78cc, 0xa085, 0x0300, 0x78ce, 0x2091,
572 0x8001, 0x0078, 0x2198, 0x78c7, 0x0000, 0x1078, 0x1c69, 0x79ac,
573 0x78b0, 0x8000, 0xa10a, 0x00c8, 0x2196, 0xa006, 0x78b2, 0xa006,
574 0x2071, 0x0010, 0x2091, 0x8001, 0x007c, 0x8107, 0x8004, 0x8004,
575 0x7ab8, 0x7bb4, 0x7cc0, 0x7dbc, 0xa210, 0xa399, 0x0000, 0xa4a1,
576 0x0000, 0xa5a9, 0x0000, 0x007c, 0x2009, 0x505b, 0x2091, 0x8000,
577 0x200a, 0x0f7e, 0x0e7e, 0x2071, 0x5040, 0x7000, 0xa086, 0x0000,
578 0x00c0, 0x21cb, 0x2009, 0x5012, 0x2104, 0xa005, 0x00c0, 0x21cb,
579 0x2079, 0x0100, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x21cb, 0x0018,
580 0x21cb, 0x781b, 0x004b, 0x0e7f, 0x0f7f, 0x007c, 0x0f7e, 0x0e7e,
581 0x2071, 0x5040, 0x2091, 0x8000, 0x7000, 0xa086, 0x0000, 0x00c0,
582 0x21e4, 0x2079, 0x0100, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x21e4,
583 0x0018, 0x21e4, 0x781b, 0x004d, 0x2091, 0x8001, 0x0e7f, 0x0f7f,
584 0x007c, 0x127e, 0x2091, 0x2300, 0x2071, 0x5040, 0x2079, 0x0100,
585 0x784b, 0x000f, 0x0098, 0x21f7, 0x7838, 0x0078, 0x21f0, 0x20a9,
586 0x0040, 0x7800, 0xa082, 0x0004, 0x0048, 0x2200, 0x20a9, 0x0060,
587 0x789b, 0x0000, 0x78af, 0x0000, 0x78af, 0x0000, 0x0070, 0x220a,
588 0x0078, 0x2202, 0x7800, 0xa082, 0x0004, 0x0048, 0x2219, 0x70b7,
589 0x009b, 0x2019, 0x4da4, 0x1078, 0x2255, 0x702f, 0x8001, 0x0078,
590 0x2225, 0x70b7, 0x0000, 0x2019, 0x4c1c, 0x1078, 0x2255, 0x2019,
591 0x4c5b, 0x1078, 0x2255, 0x702f, 0x8000, 0x7003, 0x0000, 0x1078,
592 0x235e, 0x7004, 0xa084, 0x000f, 0x017e, 0x2009, 0x04fd, 0x210c,
593 0xa18a, 0x0005, 0x0048, 0x223a, 0x0038, 0x2240, 0xa085, 0x6280,
594 0x0078, 0x2242, 0x0028, 0x2240, 0xa085, 0x6280, 0x0078, 0x2242,
595 0xa085, 0x62c0, 0x017f, 0x7806, 0x780f, 0xb204, 0x7843, 0x00d8,
596 0x7853, 0x0080, 0x780b, 0x0008, 0x7047, 0x0008, 0x7053, 0x507f,
597 0x704f, 0x0000, 0x127f, 0x2000, 0x007c, 0x137e, 0x147e, 0x157e,
598 0x047e, 0x20a1, 0x012b, 0x2304, 0xa005, 0x789a, 0x0040, 0x2275,
599 0x8318, 0x2324, 0x8318, 0x2398, 0x24a8, 0xa484, 0xff00, 0x0040,
600 0x226d, 0xa482, 0x0100, 0x20a9, 0x0100, 0x2020, 0x53a6, 0xa005,
601 0x00c0, 0x2264, 0x3318, 0x0078, 0x225b, 0x047f, 0x157f, 0x147f,
602 0x137f, 0x007c, 0xa18c, 0x000f, 0x2011, 0x0101, 0x2204, 0xa084,
603 0xfff0, 0xa105, 0x2012, 0x1078, 0x235e, 0x007c, 0x2011, 0x0101,
604 0x20a9, 0x0009, 0x810b, 0x0070, 0x228f, 0x0078, 0x228a, 0xa18c,
605 0x0e00, 0x2204, 0xa084, 0xf1ff, 0xa105, 0x2012, 0x007c, 0x2009,
606 0x0101, 0x20a9, 0x0005, 0x8213, 0x0070, 0x22a0, 0x0078, 0x229b,
607 0xa294, 0x00e0, 0x2104, 0xa084, 0xff1f, 0xa205, 0x200a, 0x007c,
608 0x2011, 0x0101, 0x20a9, 0x000c, 0x810b, 0x0070, 0x22b1, 0x0078,
609 0x22ac, 0xa18c, 0xf000, 0x2204, 0xa084, 0x0fff, 0xa105, 0x2012,
610 0x007c, 0x2011, 0x0102, 0x2204, 0xa084, 0xffcf, 0xa105, 0x2012,
611 0x007c, 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061, 0x0100,
612 0x609a, 0x62ac, 0x63ac, 0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080,
613 0x0022, 0x0c7e, 0x2061, 0x0100, 0x609a, 0x60a4, 0xa084, 0xffdf,
614 0x60ae, 0x0c7f, 0x007c, 0x8103, 0x8003, 0xa080, 0x0022, 0x0c7e,
615 0x2061, 0x0100, 0x609a, 0x60a4, 0xa085, 0x0020, 0x60ae, 0x0c7f,
616 0x007c, 0x8103, 0x8003, 0xa080, 0x0020, 0x0c7e, 0x2061, 0x0100,
617 0x609a, 0x60a4, 0x62ae, 0x2010, 0x60a4, 0x63ae, 0x2018, 0x0c7f,
618 0x007c, 0x2091, 0x8000, 0x0c7e, 0x0e7e, 0x6818, 0xa005, 0x0040,
619 0x233c, 0x2061, 0x7400, 0x1078, 0x2344, 0x0040, 0x2328, 0x20a9,
620 0x0000, 0x2061, 0x7300, 0x0c7e, 0x1078, 0x2344, 0x0040, 0x2318,
621 0x0c7f, 0x8c60, 0x0070, 0x2316, 0x0078, 0x230b, 0x0078, 0x233c,
622 0x007f, 0xa082, 0x7300, 0x2071, 0x5040, 0x7086, 0x7182, 0x2001,
623 0x0004, 0x706e, 0x7093, 0x000f, 0x1078, 0x21ac, 0x0078, 0x2338,
624 0x60c0, 0xa005, 0x00c0, 0x233c, 0x2071, 0x5040, 0x7182, 0x2c00,
625 0x708a, 0x2001, 0x0006, 0x706e, 0x7093, 0x000f, 0x1078, 0x21ac,
626 0x2001, 0x0000, 0x0078, 0x233e, 0x2001, 0x0001, 0x2091, 0x8001,
627 0xa005, 0x0e7f, 0x0c7f, 0x007c, 0x2c04, 0xa005, 0x0040, 0x235b,
628 0x2060, 0x600c, 0xa306, 0x00c0, 0x2358, 0x6010, 0xa206, 0x00c0,
629 0x2358, 0x6014, 0xa106, 0x00c0, 0x2358, 0xa006, 0x0078, 0x235d,
630 0x6000, 0x0078, 0x2345, 0xa085, 0x0001, 0x007c, 0x2011, 0x5041,
631 0x220c, 0xa18c, 0x000f, 0x2011, 0x013b, 0x2204, 0xa084, 0x0100,
632 0x0040, 0x2374, 0x2021, 0xff04, 0x2122, 0x810b, 0x810b, 0x810b,
633 0x810b, 0xa18d, 0x0f00, 0x2104, 0x007c, 0x0e7e, 0x68e4, 0xa08c,
634 0x0020, 0x0040, 0x23c8, 0xa084, 0x0006, 0x00c0, 0x23c8, 0x6014,
635 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0f0, 0x5280,
636 0x7004, 0xa084, 0x000a, 0x00c0, 0x23c8, 0x7108, 0xa194, 0xff00,
637 0x0040, 0x23c8, 0xa18c, 0x00ff, 0x2001, 0x000c, 0xa106, 0x0040,
638 0x23af, 0x2001, 0x0012, 0xa106, 0x0040, 0x23b3, 0x2001, 0x0014,
639 0xa106, 0x0040, 0x23b7, 0x2001, 0x0019, 0xa106, 0x0040, 0x23bb,
640 0x2001, 0x0032, 0xa106, 0x0040, 0x23bf, 0x0078, 0x23c3, 0x2009,
641 0x0012, 0x0078, 0x23c5, 0x2009, 0x0014, 0x0078, 0x23c5, 0x2009,
642 0x0019, 0x0078, 0x23c5, 0x2009, 0x0020, 0x0078, 0x23c5, 0x2009,
643 0x003f, 0x0078, 0x23c5, 0x2011, 0x0000, 0x2100, 0xa205, 0x700a,
644 0x0e7f, 0x007c, 0x0068, 0x23ca, 0x2091, 0x8000, 0x2071, 0x0000,
645 0x007e, 0x7018, 0xa084, 0x0001, 0x00c0, 0x23d1, 0x007f, 0x2071,
646 0x0010, 0x70ca, 0x007f, 0x70c6, 0x70c3, 0x8002, 0x70db, 0x073f,
647 0x70df, 0x0000, 0x2071, 0x0000, 0x701b, 0x0001, 0x2091, 0x4080,
648 0x0078, 0x23e8, 0x107e, 0x007e, 0x127e, 0x2091, 0x2300, 0x7f3c,
649 0x7e58, 0x7c30, 0x7d38, 0x77c2, 0x74c6, 0x76ca, 0x75ce, 0xa594,
650 0x003f, 0xa49c, 0x0003, 0xa484, 0x000f, 0x0079, 0x23ff, 0x2411,
651 0x2411, 0x2411, 0x274b, 0x3907, 0x240f, 0x2440, 0x244a, 0x240f,
652 0x240f, 0x240f, 0x240f, 0x240f, 0x240f, 0x240f, 0x240f, 0x1078,
653 0x23ca, 0x8507, 0xa084, 0x001f, 0x0079, 0x2416, 0x2454, 0x274b,
654 0x2905, 0x2a02, 0x2a2a, 0x2cc3, 0x2f6e, 0x2fb1, 0x2ffc, 0x3081,
655 0x3139, 0x31e2, 0x2440, 0x2827, 0x2f43, 0x2436, 0x3c78, 0x3c98,
656 0x3e5e, 0x3e6a, 0x3f3f, 0x2436, 0x2436, 0x4012, 0x4016, 0x3c76,
657 0x2436, 0x3dc9, 0x2436, 0x3b56, 0x244a, 0x2436, 0x1078, 0x23ca,
658 0x0018, 0x23ef, 0x127f, 0x2091, 0x8001, 0x007f, 0x107f, 0x007c,
659 0x2019, 0x4cfd, 0x1078, 0x2255, 0x702f, 0x0001, 0x781b, 0x004f,
660 0x0078, 0x2438, 0x2019, 0x4c5b, 0x1078, 0x2255, 0x702f, 0x8000,
661 0x781b, 0x00d5, 0x0078, 0x2438, 0x7242, 0x2009, 0x500f, 0x200b,
662 0x0000, 0xa584, 0x0001, 0x00c0, 0x3b6a, 0x0040, 0x2471, 0x1078,
663 0x23ca, 0x7003, 0x0000, 0x704b, 0x0000, 0x7043, 0x0000, 0x7037,
664 0x0000, 0x1078, 0x38de, 0x0018, 0x23ef, 0x2009, 0x500f, 0x200b,
665 0x0000, 0x7068, 0xa005, 0x00c0, 0x253c, 0x706c, 0xa084, 0x0007,
666 0x0079, 0x247a, 0x2573, 0x2482, 0x248e, 0x24ab, 0x24cd, 0x251a,
667 0x24f3, 0x2482, 0x1078, 0x38c6, 0x2009, 0x0048, 0x1078, 0x2e0f,
668 0x00c0, 0x248c, 0x7003, 0x0004, 0x0078, 0x2438, 0x1078, 0x38c6,
669 0x00c0, 0x24a9, 0x7080, 0x8007, 0x7882, 0x789b, 0x0010, 0x78ab,
670 0x000c, 0x789b, 0x0060, 0x78ab, 0x0001, 0x785b, 0x0004, 0x2009,
671 0x00e5, 0x1078, 0x2e03, 0x00c0, 0x24a9, 0x7003, 0x0004, 0x7093,
672 0x000f, 0x0078, 0x2438, 0x1078, 0x38c6, 0x00c0, 0x24cb, 0x7180,
673 0x8107, 0x7882, 0x789b, 0x0010, 0xa18c, 0x001f, 0xa18d, 0x00c0,
674 0x79aa, 0x78ab, 0x0006, 0x789b, 0x0060, 0x78ab, 0x0002, 0x785b,
675 0x0004, 0x2009, 0x00e5, 0x1078, 0x2e03, 0x00c0, 0x24cb, 0x7003,
676 0x0004, 0x7093, 0x000f, 0x0078, 0x2438, 0x1078, 0x38c6, 0x00c0,
677 0x24f1, 0x7180, 0x8107, 0x7882, 0x789b, 0x0010, 0xa18c, 0x001f,
678 0xa18d, 0x00c0, 0x79aa, 0x78ab, 0x0020, 0x7184, 0x79aa, 0x78ab,
679 0x000d, 0x789b, 0x0060, 0x78ab, 0x0004, 0x785b, 0x0004, 0x2009,
680 0x00e5, 0x1078, 0x2e03, 0x00c0, 0x24f1, 0x7003, 0x0004, 0x7093,
681 0x000f, 0x0078, 0x2438, 0x1078, 0x38c6, 0x00c0, 0x2518, 0x7180,
682 0x8107, 0x7882, 0x789b, 0x0010, 0xa18c, 0x001f, 0xa18d, 0x00c0,
683 0x79aa, 0x78ab, 0x0006, 0x789b, 0x0060, 0x78ab, 0x0002, 0x785b,
684 0x0004, 0x2009, 0x00e5, 0x1078, 0x2e03, 0x00c0, 0x2518, 0x7088,
685 0x708b, 0x0000, 0x2068, 0x704a, 0x7003, 0x0002, 0x7093, 0x000f,
686 0x0078, 0x2438, 0x1078, 0x38c6, 0x00c0, 0x2438, 0x7088, 0x2068,
687 0x6f14, 0x1078, 0x37bd, 0x2c50, 0x1078, 0x3978, 0x789b, 0x0010,
688 0x6814, 0xa084, 0x001f, 0xa085, 0x0080, 0x78aa, 0x6e1c, 0x2041,
689 0x0001, 0x708c, 0xa084, 0x0400, 0x2001, 0x0004, 0x0040, 0x253a,
690 0x2001, 0x0006, 0x0078, 0x265b, 0x1078, 0x38c6, 0x00c0, 0x2438,
691 0x789b, 0x0010, 0x7068, 0x2068, 0x6f14, 0x1078, 0x37bd, 0x2c50,
692 0x1078, 0x3978, 0x6008, 0xa085, 0x0010, 0x600a, 0x6824, 0xa005,
693 0x0040, 0x255a, 0xa082, 0x0006, 0x0048, 0x2558, 0x0078, 0x255a,
694 0x6827, 0x0005, 0x6b14, 0xa39c, 0x001f, 0xa39d, 0x00c0, 0x7058,
695 0xa084, 0x8000, 0x0040, 0x2568, 0xa684, 0x0001, 0x0040, 0x256a,
696 0xa39c, 0xffbf, 0x7baa, 0x2031, 0x0020, 0x2041, 0x0001, 0x2001,
697 0x0003, 0x0078, 0x265b, 0x0018, 0x23ef, 0x744c, 0xa485, 0x0000,
698 0x0040, 0x258d, 0xa080, 0x5080, 0x2030, 0x7150, 0x8108, 0xa12a,
699 0x0048, 0x2584, 0x2009, 0x5080, 0x2164, 0x6504, 0x85ff, 0x00c0,
700 0x259e, 0x8421, 0x00c0, 0x257e, 0x7152, 0x7003, 0x0000, 0x704b,
701 0x0000, 0x7040, 0xa005, 0x0040, 0x3b6a, 0x0078, 0x2438, 0x764c,
702 0xa6b0, 0x5080, 0x7150, 0x2600, 0x0078, 0x2589, 0x7152, 0x2568,
703 0x2558, 0x754a, 0x2c50, 0x6034, 0xa085, 0x0000, 0x00c0, 0x259b,
704 0x6708, 0x773a, 0xa784, 0x033f, 0x0040, 0x25d4, 0xa784, 0x0021,
705 0x00c0, 0x259b, 0xa784, 0x0002, 0x0040, 0x25bd, 0xa784, 0x0004,
706 0x0040, 0x259b, 0xa7bc, 0xfffb, 0x670a, 0xa784, 0x0008, 0x00c0,
707 0x259b, 0xa784, 0x0010, 0x00c0, 0x259b, 0xa784, 0x0200, 0x00c0,
708 0x259b, 0xa784, 0x0100, 0x0040, 0x25d4, 0x6018, 0xa005, 0x00c0,
709 0x259b, 0xa7bc, 0xfeff, 0x670a, 0x6823, 0x0000, 0x6e1c, 0xa684,
710 0x000e, 0x6118, 0x0040, 0x25e4, 0x601c, 0xa102, 0x0048, 0x25e7,
711 0x0040, 0x25e7, 0x0078, 0x2597, 0x81ff, 0x00c0, 0x2597, 0x68c3,
712 0x0000, 0xa784, 0x0080, 0x00c0, 0x25ef, 0x700c, 0x6022, 0xa7bc,
713 0xff7f, 0x670a, 0x1078, 0x3978, 0x0018, 0x23ef, 0x789b, 0x0010,
714 0xa046, 0x1078, 0x38c6, 0x00c0, 0x2438, 0x6b14, 0xa39c, 0x001f,
715 0xa39d, 0x00c0, 0x7058, 0xa084, 0x8000, 0x0040, 0x260b, 0xa684,
716 0x0001, 0x0040, 0x260d, 0xa39c, 0xffbf, 0xa684, 0x0010, 0x0040,
717 0x2613, 0xa39d, 0x0020, 0x7baa, 0x8840, 0xa684, 0x000e, 0x00c0,
718 0x261e, 0xa7bd, 0x0010, 0x670a, 0x0078, 0x2659, 0x7158, 0xa18c,
719 0x0800, 0x0040, 0x33d7, 0x2011, 0x0020, 0xa684, 0x0008, 0x00c0,
720 0x262f, 0x8210, 0xa684, 0x0002, 0x00c0, 0x262f, 0x8210, 0x7aaa,
721 0x8840, 0x1078, 0x38de, 0x6a14, 0x610c, 0x8108, 0xa18c, 0x00ff,
722 0xa1e0, 0x7300, 0x2c64, 0x8cff, 0x0040, 0x2650, 0x6014, 0xa206,
723 0x00c0, 0x263a, 0x60b8, 0x8001, 0x60ba, 0x00c0, 0x2635, 0x0c7e,
724 0x2a60, 0x6008, 0xa085, 0x0100, 0x600a, 0x0c7f, 0x0078, 0x2573,
725 0x1078, 0x38c6, 0x00c0, 0x2438, 0x2a60, 0x610e, 0x79aa, 0x8840,
726 0x7132, 0x2001, 0x0001, 0x007e, 0x715c, 0xa184, 0x0018, 0x0040,
727 0x2676, 0xa184, 0x0010, 0x0040, 0x2669, 0x1078, 0x35d6, 0x00c0,
728 0x2699, 0xa184, 0x0008, 0x0040, 0x2676, 0x69a0, 0xa184, 0x0600,
729 0x00c0, 0x2676, 0x1078, 0x34c7, 0x0078, 0x2699, 0x69a0, 0xa184,
730 0x0800, 0x0040, 0x268d, 0x0c7e, 0x027e, 0x2960, 0x6000, 0xa085,
731 0x2000, 0x6002, 0x6104, 0xa18d, 0x0010, 0x6106, 0x027f, 0x0c7f,
732 0x1078, 0x35d6, 0x00c0, 0x2699, 0x69a0, 0xa184, 0x0200, 0x0040,
733 0x2695, 0x1078, 0x3516, 0x0078, 0x2699, 0xa184, 0x0400, 0x00c0,
734 0x2672, 0x69a0, 0xa184, 0x1000, 0x0040, 0x26a4, 0x6914, 0xa18c,
735 0xff00, 0x810f, 0x1078, 0x22cd, 0x007f, 0x7002, 0xa68c, 0x00e0,
736 0xa684, 0x0060, 0x0040, 0x26b2, 0xa086, 0x0060, 0x00c0, 0x26b2,
737 0xa18d, 0x4000, 0x88ff, 0x0040, 0x26b7, 0xa18d, 0x0004, 0x795a,
738 0x69b6, 0x789b, 0x0060, 0x2800, 0x78aa, 0x789b, 0x0061, 0x6818,
739 0xa08d, 0x8000, 0xa084, 0x7fff, 0x691a, 0xa68c, 0x0080, 0x0040,
740 0x26d6, 0x7097, 0x0000, 0xa08a, 0x000d, 0x0050, 0x26d4, 0xa08a,
741 0x000c, 0x7196, 0x2001, 0x000c, 0x800c, 0x719a, 0x78aa, 0x8008,
742 0x810c, 0x0040, 0x33dd, 0xa18c, 0x00f8, 0x00c0, 0x33dd, 0x157e,
743 0x137e, 0x147e, 0x20a1, 0x012b, 0x789b, 0x0000, 0x8000, 0x80ac,
744 0xad80, 0x000b, 0x2098, 0x53a6, 0x147f, 0x137f, 0x157f, 0x6814,
745 0x8007, 0x7882, 0x6d94, 0x7dd6, 0x7dde, 0x6e98, 0x7ed2, 0x7eda,
746 0x1078, 0x38c6, 0x00c0, 0x270d, 0x702c, 0x8003, 0x0048, 0x2706,
747 0x2019, 0x4c5b, 0x1078, 0x2255, 0x702f, 0x8000, 0x7830, 0xa084,
748 0x00c0, 0x00c0, 0x270d, 0x0098, 0x2715, 0x6008, 0xa084, 0xffef,
749 0x600a, 0x1078, 0x38de, 0x0078, 0x2461, 0x7200, 0xa284, 0x0007,
750 0xa086, 0x0001, 0x00c0, 0x2722, 0x781b, 0x004f, 0x1078, 0x38de,
751 0x0078, 0x2733, 0x6ab4, 0xa295, 0x2000, 0x7a5a, 0x781b, 0x004f,
752 0x1078, 0x38de, 0x7200, 0x2500, 0xa605, 0x0040, 0x2733, 0xa284,
753 0x0007, 0x1079, 0x2741, 0xad80, 0x0009, 0x7036, 0xa284, 0x0007,
754 0xa086, 0x0001, 0x00c0, 0x2438, 0x6018, 0x8000, 0x601a, 0x0078,
755 0x2438, 0x2749, 0x48f7, 0x48f7, 0x48e6, 0x48f7, 0x2749, 0x48e6,
756 0x2749, 0x1078, 0x23ca, 0x1078, 0x38c6, 0x0f7e, 0x2079, 0x5000,
757 0x78cc, 0x0f7f, 0xa084, 0x0001, 0x0040, 0x276f, 0x706c, 0xa086,
758 0x0001, 0x00c0, 0x275e, 0x706e, 0x0078, 0x2802, 0x706c, 0xa086,
759 0x0005, 0x00c0, 0x276d, 0x7088, 0x2068, 0x681b, 0x0004, 0x6817,
760 0x0000, 0x6820, 0xa085, 0x0008, 0x6822, 0x706f, 0x0000, 0x2011,
761 0x0004, 0x716c, 0xa186, 0x0001, 0x0040, 0x2790, 0xa186, 0x0007,
762 0x00c0, 0x2780, 0x2009, 0x5038, 0x200b, 0x0005, 0x0078, 0x2790,
763 0x2009, 0x5013, 0x2104, 0x2009, 0x5012, 0x200a, 0x2009, 0x5038,
764 0x200b, 0x0001, 0x706f, 0x0000, 0x7073, 0x0001, 0x0078, 0x2792,
765 0x706f, 0x0000, 0x1078, 0x4633, 0x157e, 0x20a9, 0x0010, 0x2039,
766 0x0000, 0x1078, 0x36b0, 0xa7b8, 0x0100, 0x0070, 0x27a1, 0x0078,
767 0x2799, 0x157f, 0x7000, 0x0079, 0x27a5, 0x27d3, 0x27ba, 0x27ba,
768 0x27ad, 0x27d3, 0x27d3, 0x27d3, 0x27d3, 0x2021, 0x505a, 0x2404,
769 0xa005, 0x0040, 0x27d3, 0xad06, 0x00c0, 0x27ba, 0x6800, 0x2022,
770 0x0078, 0x27ca, 0x6820, 0xa084, 0x0001, 0x00c0, 0x27c6, 0x6f14,
771 0x1078, 0x37bd, 0x1078, 0x33ae, 0x0078, 0x27ca, 0x7060, 0x2060,
772 0x6800, 0x6002, 0x6a1a, 0x6817, 0x0000, 0x6820, 0xa085, 0x0008,
773 0x6822, 0x1078, 0x1c53, 0x2021, 0x7400, 0x1078, 0x280f, 0x2021,
774 0x505a, 0x1078, 0x280f, 0x157e, 0x20a9, 0x0000, 0x2021, 0x7300,
775 0x1078, 0x280f, 0x8420, 0x0070, 0x27e7, 0x0078, 0x27e0, 0x2061,
776 0x5300, 0x2021, 0x0002, 0x20a9, 0x0100, 0x6018, 0x6110, 0x81ff,
777 0x0040, 0x27f6, 0xa102, 0x0050, 0x27f6, 0x6012, 0x601b, 0x0000,
778 0xace0, 0x0010, 0x0070, 0x27fe, 0x0078, 0x27ed, 0x8421, 0x00c0,
779 0x27eb, 0x157f, 0x709c, 0xa084, 0x8000, 0x0040, 0x2809, 0x1078,
780 0x39cc, 0x7003, 0x0000, 0x704b, 0x0000, 0x0078, 0x2438, 0x047e,
781 0x2404, 0xa005, 0x0040, 0x2823, 0x2068, 0x6800, 0x007e, 0x6a1a,
782 0x6817, 0x0000, 0x6820, 0xa085, 0x0008, 0x6822, 0x1078, 0x1c53,
783 0x007f, 0x0078, 0x2811, 0x047f, 0x2023, 0x0000, 0x007c, 0xa282,
784 0x0003, 0x0050, 0x282d, 0x1078, 0x23ca, 0x2300, 0x0079, 0x2830,
785 0x2833, 0x28a6, 0x28c3, 0xa282, 0x0002, 0x0040, 0x2839, 0x1078,
786 0x23ca, 0x706c, 0x706f, 0x0000, 0x7093, 0x0000, 0x0079, 0x2840,
787 0x2848, 0x2848, 0x284a, 0x287e, 0x33e3, 0x2848, 0x287e, 0x2848,
788 0x1078, 0x23ca, 0x7780, 0x1078, 0x36b0, 0x7780, 0xa7bc, 0x0f00,
789 0x1078, 0x37bd, 0x6018, 0xa005, 0x0040, 0x2875, 0x2021, 0x7400,
790 0x2009, 0x0004, 0x2011, 0x0010, 0x1078, 0x28de, 0x0040, 0x2875,
791 0x157e, 0x20a9, 0x0000, 0x2021, 0x7300, 0x047e, 0x2009, 0x0004,
792 0x2011, 0x0010, 0x1078, 0x28de, 0x047f, 0x0040, 0x2874, 0x8420,
793 0x0070, 0x2874, 0x0078, 0x2865, 0x157f, 0x8738, 0xa784, 0x001f,
794 0x00c0, 0x2850, 0x0078, 0x2461, 0x0078, 0x2461, 0x7780, 0x1078,
795 0x37bd, 0x6018, 0xa005, 0x0040, 0x28a4, 0x2021, 0x7400, 0x2009,
796 0x0005, 0x2011, 0x0020, 0x1078, 0x28de, 0x0040, 0x28a4, 0x157e,
797 0x20a9, 0x0000, 0x2021, 0x7300, 0x047e, 0x2009, 0x0005, 0x2011,
798 0x0020, 0x1078, 0x28de, 0x047f, 0x0040, 0x28a3, 0x8420, 0x0070,
799 0x28a3, 0x0078, 0x2894, 0x157f, 0x0078, 0x2461, 0x2200, 0x0079,
800 0x28a9, 0x28ac, 0x28ae, 0x28ae, 0x1078, 0x23ca, 0x2009, 0x0012,
801 0x706c, 0xa086, 0x0002, 0x0040, 0x28b7, 0x2009, 0x000e, 0x6818,
802 0xa084, 0x8000, 0x0040, 0x28bd, 0x691a, 0x706f, 0x0000, 0x7073,
803 0x0001, 0x0078, 0x3854, 0x2200, 0x0079, 0x28c6, 0x28cb, 0x28ae,
804 0x28c9, 0x1078, 0x23ca, 0x1078, 0x4633, 0x7000, 0xa086, 0x0001,
805 0x00c0, 0x3373, 0x1078, 0x33c4, 0x6008, 0xa084, 0xffef, 0x600a,
806 0x1078, 0x3366, 0x0040, 0x3373, 0x0078, 0x2573, 0x2404, 0xa005,
807 0x0040, 0x2901, 0x2068, 0x2d04, 0x007e, 0x6814, 0xa706, 0x0040,
808 0x28ed, 0x2d20, 0x007f, 0x0078, 0x28df, 0x007f, 0x2022, 0x691a,
809 0x6817, 0x0000, 0x6820, 0xa205, 0x6822, 0x1078, 0x1c53, 0x6010,
810 0x8001, 0x6012, 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x33c4,
811 0x007c, 0xa085, 0x0001, 0x0078, 0x2900, 0x2300, 0x0079, 0x2908,
812 0x290d, 0x290b, 0x29a6, 0x1078, 0x23ca, 0x78ec, 0xa084, 0x0001,
813 0x00c0, 0x2921, 0x7000, 0xa086, 0x0004, 0x00c0, 0x2919, 0x0078,
814 0x2944, 0x1078, 0x33c4, 0x6008, 0xa084, 0xffef, 0x600a, 0x0078,
815 0x3373, 0x78e4, 0xa005, 0x00d0, 0x2944, 0x0018, 0x2438, 0x2008,
816 0xa084, 0x0030, 0x00c0, 0x2930, 0x781b, 0x004f, 0x0078, 0x2438,
817 0x78ec, 0xa084, 0x0003, 0x0040, 0x292c, 0x2100, 0xa084, 0x0007,
818 0x0079, 0x293a, 0x297d, 0x2988, 0x296e, 0x2942, 0x38b9, 0x38b9,
819 0x2942, 0x2997, 0x1078, 0x23ca, 0x7000, 0xa086, 0x0004, 0x00c0,
820 0x295e, 0x706c, 0xa086, 0x0002, 0x00c0, 0x2954, 0x2011, 0x0002,
821 0x2019, 0x0000, 0x0078, 0x2827, 0x706c, 0xa086, 0x0006, 0x0040,
822 0x294e, 0x706c, 0xa086, 0x0004, 0x0040, 0x294e, 0x79e4, 0xa184,
823 0x0030, 0x0040, 0x2968, 0x78ec, 0xa084, 0x0003, 0x00c0, 0x296a,
824 0x0078, 0x2f43, 0x2001, 0x0003, 0x0078, 0x2cd7, 0x6818, 0xa084,
825 0x8000, 0x0040, 0x2975, 0x681b, 0x001d, 0x1078, 0x368f, 0x782b,
826 0x3008, 0x781b, 0x0056, 0x0078, 0x2438, 0x6818, 0xa084, 0x8000,
827 0x0040, 0x2984, 0x681b, 0x001d, 0x1078, 0x368f, 0x0078, 0x3884,
828 0x6818, 0xa084, 0x8000, 0x0040, 0x298f, 0x681b, 0x001d, 0x1078,
829 0x368f, 0x782b, 0x3008, 0x781b, 0x00d2, 0x0078, 0x2438, 0x6818,
830 0xa084, 0x8000, 0x0040, 0x299e, 0x681b, 0x001d, 0x1078, 0x368f,
831 0x782b, 0x3008, 0x781b, 0x0093, 0x0078, 0x2438, 0xa584, 0x000f,
832 0x00c0, 0x29c3, 0x7000, 0x0079, 0x29ad, 0x2461, 0x29b7, 0x29b5,
833 0x3373, 0x3373, 0x3373, 0x3373, 0x29b5, 0x1078, 0x23ca, 0x1078,
834 0x33c4, 0x6008, 0xa084, 0xffef, 0x600a, 0x1078, 0x3366, 0x0040,
835 0x3373, 0x0078, 0x2573, 0x78e4, 0xa005, 0x00d0, 0x2944, 0x0018,
836 0x2944, 0x2008, 0xa084, 0x0030, 0x00c0, 0x29d2, 0x781b, 0x004f,
837 0x0078, 0x2438, 0x78ec, 0xa084, 0x0003, 0x0040, 0x29ce, 0x2100,
838 0xa184, 0x0007, 0x0079, 0x29dc, 0x29ee, 0x29f2, 0x29e6, 0x29e4,
839 0x38b9, 0x38b9, 0x29e4, 0x38af, 0x1078, 0x23ca, 0x1078, 0x3697,
840 0x782b, 0x3008, 0x781b, 0x0056, 0x0078, 0x2438, 0x1078, 0x3697,
841 0x0078, 0x3884, 0x1078, 0x3697, 0x782b, 0x3008, 0x781b, 0x00d2,
842 0x0078, 0x2438, 0x1078, 0x3697, 0x782b, 0x3008, 0x781b, 0x0093,
843 0x0078, 0x2438, 0x2300, 0x0079, 0x2a05, 0x2a0a, 0x2a08, 0x2a0c,
844 0x1078, 0x23ca, 0x0078, 0x3081, 0x681b, 0x0008, 0x78a3, 0x0000,
845 0x79e4, 0xa184, 0x0030, 0x0040, 0x3081, 0x78ec, 0xa084, 0x0003,
846 0x0040, 0x3081, 0xa184, 0x0007, 0x0079, 0x2a1e, 0x2a26, 0x29f2,
847 0x296e, 0x3854, 0x38b9, 0x38b9, 0x2a26, 0x38af, 0x1078, 0x3868,
848 0x0078, 0x2438, 0xa282, 0x0005, 0x0050, 0x2a30, 0x1078, 0x23ca,
849 0x2300, 0x0079, 0x2a33, 0x2a36, 0x2c84, 0x2c92, 0x2200, 0x0079,
850 0x2a39, 0x2a53, 0x2a40, 0x2a53, 0x2a3e, 0x2c69, 0x1078, 0x23ca,
851 0x789b, 0x0018, 0x78a8, 0xa084, 0x00ff, 0xa082, 0x0020, 0x0048,
852 0x366b, 0xa08a, 0x0004, 0x00c8, 0x366b, 0x0079, 0x2a4f, 0x366b,
853 0x366b, 0x366b, 0x3619, 0x789b, 0x0018, 0x79a8, 0xa184, 0x0080,
854 0x0040, 0x2a64, 0x0078, 0x366b, 0x7000, 0xa005, 0x00c0, 0x2a5a,
855 0x2011, 0x0004, 0x0078, 0x31f5, 0xa184, 0x00ff, 0xa08a, 0x0010,
856 0x00c8, 0x366b, 0x0079, 0x2a6c, 0x2a7e, 0x2a7c, 0x2a96, 0x2a9a,
857 0x2b55, 0x366b, 0x366b, 0x2b57, 0x366b, 0x366b, 0x2c65, 0x2c65,
858 0x366b, 0x366b, 0x366b, 0x2c67, 0x1078, 0x23ca, 0xa684, 0x1000,
859 0x0040, 0x2a8b, 0x2001, 0x0500, 0x8000, 0x8000, 0x783a, 0x781b,
860 0x0091, 0x0078, 0x2438, 0x6818, 0xa084, 0x8000, 0x0040, 0x2a94,
861 0x681b, 0x001d, 0x0078, 0x2a82, 0x0078, 0x3854, 0x681b, 0x001d,
862 0x0078, 0x367b, 0x6920, 0x6922, 0xa684, 0x1800, 0x00c0, 0x2adb,
863 0x6820, 0xa084, 0x0001, 0x00c0, 0x2ae1, 0x6818, 0xa086, 0x0008,
864 0x00c0, 0x2aac, 0x681b, 0x0000, 0xa684, 0x0400, 0x0040, 0x2b51,
865 0xa684, 0x0080, 0x0040, 0x2ad7, 0x7097, 0x0000, 0x6818, 0xa084,
866 0x003f, 0xa08a, 0x000d, 0x0050, 0x2ad7, 0xa08a, 0x000c, 0x7196,
867 0x2001, 0x000c, 0x800c, 0x719a, 0x789b, 0x0061, 0x78aa, 0x157e,
868 0x137e, 0x147e, 0x20a1, 0x012b, 0x789b, 0x0000, 0x8000, 0x80ac,
869 0xad80, 0x000b, 0x2098, 0x53a6, 0x147f, 0x137f, 0x157f, 0x781b,
870 0x0058, 0x0078, 0x2438, 0xa684, 0x1000, 0x0040, 0x2ae1, 0x0078,
871 0x2438, 0xa684, 0x0060, 0x0040, 0x2b4d, 0xa684, 0x0800, 0x0040,
872 0x2b4d, 0xa684, 0x8000, 0x00c0, 0x2aef, 0x0078, 0x2b09, 0xa6b4,
873 0x7fff, 0x7e5a, 0x6eb6, 0x789b, 0x0076, 0x7aac, 0x79ac, 0x78ac,
874 0x801b, 0x00c8, 0x2afc, 0x8000, 0xa084, 0x003f, 0xa108, 0xa291,
875 0x0000, 0x6b98, 0x2100, 0xa302, 0x68b2, 0x6b94, 0x2200, 0xa303,
876 0x68ae, 0xa684, 0x4000, 0x0040, 0x2b11, 0xa6b4, 0xbfff, 0x7e5a,
877 0x6eb6, 0x7000, 0xa086, 0x0003, 0x00c0, 0x2b1e, 0x1078, 0x46e9,
878 0x1078, 0x48e6, 0x781b, 0x0064, 0x0078, 0x2438, 0xa006, 0x1078,
879 0x49ed, 0x6ab0, 0x69ac, 0x6c98, 0x6b94, 0x2200, 0xa105, 0x0040,
880 0x2b2d, 0x2200, 0xa422, 0x2100, 0xa31b, 0x6caa, 0x7cd2, 0x7cda,
881 0x6ba6, 0x7bd6, 0x7bde, 0x2300, 0xa405, 0x00c0, 0x2b3f, 0xa6b5,
882 0x4000, 0x7e5a, 0x6eb6, 0x781b, 0x0064, 0x0078, 0x2438, 0x781b,
883 0x0064, 0x2200, 0xa115, 0x00c0, 0x2b49, 0x1078, 0x48f7, 0x0078,
884 0x2438, 0x1078, 0x4942, 0x0078, 0x2438, 0x781b, 0x0065, 0x0078,
885 0x2438, 0x781b, 0x0058, 0x0078, 0x2438, 0x1078, 0x23ca, 0x0078,
886 0x2bb8, 0x6920, 0xa184, 0x0100, 0x0040, 0x2b6f, 0xa18c, 0xfeff,
887 0x6922, 0x0c7e, 0x7054, 0x2060, 0x6000, 0xa084, 0xefff, 0x6002,
888 0x6004, 0xa084, 0xfff5, 0x6006, 0x0c7f, 0x0078, 0x2ba7, 0xa184,
889 0x0200, 0x0040, 0x2ba7, 0xa18c, 0xfdff, 0x6922, 0x0c7e, 0x7054,
890 0x2060, 0x6000, 0xa084, 0xdfff, 0x6002, 0x6004, 0xa084, 0xffef,
891 0x6006, 0x2008, 0x2c48, 0x0c7f, 0xa184, 0x0008, 0x0040, 0x2ba7,
892 0x1078, 0x37b9, 0x1078, 0x34c7, 0x88ff, 0x0040, 0x2ba7, 0x789b,
893 0x0060, 0x2800, 0x78aa, 0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684,
894 0x0400, 0x00c0, 0x2ba1, 0x782b, 0x3008, 0x781b, 0x0056, 0x0078,
895 0x2438, 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2438, 0x7e58,
896 0xa684, 0x0400, 0x00c0, 0x2bb0, 0x781b, 0x0058, 0x0078, 0x2438,
897 0x781b, 0x0065, 0x0078, 0x2438, 0x0078, 0x3673, 0x0078, 0x3673,
898 0x2019, 0x0000, 0x7990, 0xa18c, 0x0007, 0x0040, 0x2bb6, 0x789b,
899 0x0010, 0x78a8, 0xa094, 0x00ff, 0xa286, 0x0001, 0x00c0, 0x2bf6,
900 0x2300, 0x7ca8, 0xa400, 0x2018, 0xa102, 0x0040, 0x2bee, 0x0048,
901 0x2bd3, 0x0078, 0x2bf0, 0xa380, 0x0002, 0xa102, 0x00c8, 0x2bee,
902 0x6920, 0xa18c, 0xfcff, 0x6922, 0x0c7e, 0x7054, 0x2060, 0x6000,
903 0xa084, 0xefef, 0x6002, 0x6004, 0xa084, 0xffe5, 0x6006, 0x0c7f,
904 0x7e58, 0xa6b4, 0xfffb, 0x7e5a, 0x0078, 0x2ba8, 0x0078, 0x2b59,
905 0x24a8, 0x7aa8, 0x00f0, 0x2bf0, 0x0078, 0x2bc1, 0xa284, 0x00f0,
906 0xa086, 0x0020, 0x00c0, 0x2c56, 0x8318, 0x8318, 0x2300, 0xa102,
907 0x0040, 0x2c06, 0x0048, 0x2c06, 0x0078, 0x2c53, 0xa286, 0x0023,
908 0x0040, 0x2bb6, 0x681c, 0xa084, 0xfff1, 0x681e, 0x7e58, 0xa684,
909 0xfff1, 0xa085, 0x0010, 0x2030, 0x7e5a, 0x6008, 0xa085, 0x0010,
910 0x600a, 0x0c7e, 0x7054, 0x2060, 0x6004, 0x2008, 0x2c48, 0x0c7f,
911 0xa184, 0x0010, 0x0040, 0x2c2a, 0x1078, 0x37b9, 0x1078, 0x35d6,
912 0x0078, 0x2c39, 0x0c7e, 0x7054, 0x2060, 0x6004, 0x2008, 0x2c48,
913 0x0c7f, 0xa184, 0x0008, 0x0040, 0x2ba7, 0x1078, 0x37b9, 0x1078,
914 0x34c7, 0x88ff, 0x0040, 0x2ba7, 0x789b, 0x0060, 0x2800, 0x78aa,
915 0xa6b5, 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x2c4d, 0x782b,
916 0x3008, 0x781b, 0x0056, 0x0078, 0x2438, 0x782b, 0x3008, 0x781b,
917 0x0065, 0x0078, 0x2438, 0x7aa8, 0x0078, 0x2bc1, 0x8318, 0x2300,
918 0xa102, 0x0040, 0x2c5f, 0x0048, 0x2c5f, 0x0078, 0x2bc1, 0xa284,
919 0x0080, 0x00c0, 0x367b, 0x0078, 0x3673, 0x0078, 0x367b, 0x0078,
920 0x366b, 0x789b, 0x0018, 0x78a8, 0xa084, 0x00ff, 0xa08e, 0x0001,
921 0x0040, 0x2c74, 0x1078, 0x23ca, 0x7aa8, 0xa294, 0x00ff, 0x78a8,
922 0xa084, 0x00ff, 0xa08a, 0x0004, 0x00c8, 0x366b, 0x0079, 0x2c80,
923 0x366b, 0x3414, 0x366b, 0x356b, 0xa282, 0x0000, 0x00c0, 0x2c8a,
924 0x1078, 0x23ca, 0x1078, 0x368f, 0x782b, 0x3008, 0x781b, 0x0065,
925 0x0078, 0x2438, 0xa282, 0x0003, 0x00c0, 0x2c98, 0x1078, 0x23ca,
926 0xa484, 0x8000, 0x00c0, 0x2cbb, 0x706c, 0xa005, 0x0040, 0x2ca2,
927 0x1078, 0x23ca, 0x6f14, 0x7782, 0xa7bc, 0x0f00, 0x1078, 0x37bd,
928 0x6008, 0xa085, 0x0021, 0x600a, 0x8738, 0xa784, 0x001f, 0x00c0,
929 0x2ca6, 0x1078, 0x3693, 0x706f, 0x0002, 0x2009, 0x5038, 0x200b,
930 0x0009, 0x0078, 0x2cbd, 0x1078, 0x369f, 0x782b, 0x3008, 0x781b,
931 0x0065, 0x0078, 0x2438, 0xa282, 0x0004, 0x0050, 0x2cc9, 0x1078,
932 0x23ca, 0x2300, 0x0079, 0x2ccc, 0x2ccf, 0x2db8, 0x2deb, 0xa286,
933 0x0003, 0x0040, 0x2cd5, 0x1078, 0x23ca, 0x2001, 0x0000, 0x007e,
934 0x68c0, 0xa005, 0x0040, 0x2cde, 0x7003, 0x0003, 0x68a0, 0xa084,
935 0x2000, 0x0040, 0x2ce7, 0x6008, 0xa085, 0x0002, 0x600a, 0x007f,
936 0x703e, 0x7000, 0xa084, 0x0007, 0x0079, 0x2cee, 0x2461, 0x2cf8,
937 0x2cf8, 0x2eed, 0x2f29, 0x2461, 0x2f29, 0x2cf6, 0x1078, 0x23ca,
938 0xa684, 0x1000, 0x00c0, 0x2d00, 0x1078, 0x4633, 0x0040, 0x2d92,
939 0x7868, 0xa08c, 0x00ff, 0x0040, 0x2d48, 0xa186, 0x0008, 0x00c0,
940 0x2d17, 0x1078, 0x33c4, 0x6008, 0xa084, 0xffef, 0x600a, 0x1078,
941 0x3366, 0x0040, 0x2d48, 0x1078, 0x4633, 0x0078, 0x2d2f, 0xa186,
942 0x0028, 0x00c0, 0x2d48, 0x1078, 0x4633, 0x6008, 0xa084, 0xffef,
943 0x600a, 0x6018, 0xa005, 0x0040, 0x2d2f, 0x8001, 0x601a, 0xa005,
944 0x0040, 0x2d2f, 0x8001, 0xa005, 0x0040, 0x2d2f, 0x601e, 0x6820,
945 0xa084, 0x0001, 0x0040, 0x2461, 0x6820, 0xa084, 0xfffe, 0x6822,
946 0x7060, 0x0c7e, 0x2060, 0x6800, 0x6002, 0x0c7f, 0x6004, 0x6802,
947 0xa005, 0x2d00, 0x00c0, 0x2d45, 0x6002, 0x6006, 0x0078, 0x2461,
948 0x017e, 0x1078, 0x2e1c, 0x017f, 0xa684, 0xdf00, 0x681e, 0x682b,
949 0x0000, 0x6f14, 0x81ff, 0x0040, 0x2d92, 0xa186, 0x0002, 0x00c0,
950 0x2d92, 0xa684, 0x0800, 0x00c0, 0x2d65, 0xa684, 0x0060, 0x0040,
951 0x2d65, 0x78d8, 0x7adc, 0x682e, 0x6a32, 0x6820, 0xa084, 0x0800,
952 0x00c0, 0x2d92, 0x8717, 0xa294, 0x000f, 0x8213, 0x8213, 0x8213,
953 0xa290, 0x5280, 0xa290, 0x0000, 0x221c, 0xa384, 0x0100, 0x00c0,
954 0x2d7b, 0x0078, 0x2d81, 0x8210, 0x2204, 0xa085, 0x0018, 0x2012,
955 0x8211, 0xa384, 0x0400, 0x0040, 0x2d8e, 0x68a0, 0xa084, 0x0100,
956 0x00c0, 0x2d8e, 0x1078, 0x2ea0, 0x0078, 0x2461, 0x6008, 0xa085,
957 0x0002, 0x600a, 0x6916, 0x6818, 0xa084, 0x8000, 0x0040, 0x2d9a,
958 0x703c, 0x681a, 0xa68c, 0xdf00, 0x691e, 0x1078, 0x33b5, 0x1078,
959 0x33c4, 0x00c0, 0x2da7, 0x6008, 0xa084, 0xffef, 0x600a, 0x6820,
960 0xa084, 0x0001, 0x00c0, 0x2db0, 0x1078, 0x33ae, 0x0078, 0x2db4,
961 0x7060, 0x2060, 0x6800, 0x6002, 0x1078, 0x1c53, 0x0078, 0x2461,
962 0xa282, 0x0004, 0x0048, 0x2dbe, 0x1078, 0x23ca, 0x2200, 0x0079,
963 0x2dc1, 0x2dbc, 0x2dc5, 0x2dd2, 0x2dc5, 0x7000, 0xa086, 0x0005,
964 0x0040, 0x2dce, 0x1078, 0x368f, 0x782b, 0x3008, 0x781b, 0x0065,
965 0x0078, 0x2438, 0x7890, 0x8007, 0x8001, 0xa084, 0x0007, 0xa080,
966 0x0018, 0x789a, 0x79a8, 0xa18c, 0x00ff, 0xa186, 0x0003, 0x0040,
967 0x2de7, 0xa186, 0x0000, 0x0040, 0x2de7, 0x0078, 0x366b, 0x781b,
968 0x0065, 0x0078, 0x2438, 0x6820, 0xa085, 0x0004, 0x6822, 0x82ff,
969 0x00c0, 0x2df6, 0x1078, 0x368f, 0x0078, 0x2dfd, 0x8211, 0x0040,
970 0x2dfb, 0x1078, 0x23ca, 0x1078, 0x369f, 0x782b, 0x3008, 0x781b,
971 0x0065, 0x0078, 0x2438, 0x702c, 0x8003, 0x0048, 0x2e0d, 0x2019,
972 0x4c5b, 0x1078, 0x2255, 0x702f, 0x8000, 0x1078, 0x38de, 0x7830,
973 0xa084, 0x00c0, 0x00c0, 0x2e19, 0x0018, 0x2e19, 0x791a, 0xa006,
974 0x007c, 0xa085, 0x0001, 0x007c, 0xa684, 0x0060, 0x00c0, 0x2e26,
975 0x682f, 0x0000, 0x6833, 0x0000, 0x0078, 0x2e9f, 0xa684, 0x0800,
976 0x00c0, 0x2e48, 0x68b4, 0xa084, 0x4800, 0xa635, 0xa684, 0x0800,
977 0x00c0, 0x2e48, 0x6998, 0x6a94, 0x692e, 0x6a32, 0x703c, 0xa005,
978 0x00c0, 0x2e40, 0x2200, 0xa105, 0x0040, 0x2e47, 0x703f, 0x0015,
979 0x7000, 0xa086, 0x0006, 0x0040, 0x2e47, 0x1078, 0x4633, 0x007c,
980 0xa684, 0x0020, 0x0040, 0x2e6a, 0xa684, 0x4000, 0x0040, 0x2e56,
981 0x682f, 0x0000, 0x6833, 0x0000, 0x0078, 0x2e40, 0x68b4, 0xa084,
982 0x4800, 0xa635, 0xa684, 0x4000, 0x00c0, 0x2e50, 0x703c, 0xa005,
983 0x00c0, 0x2e64, 0x703f, 0x0015, 0x79d8, 0x7adc, 0x692e, 0x6a32,
984 0x0078, 0x2e40, 0xa684, 0x4000, 0x0040, 0x2e74, 0x682f, 0x0000,
985 0x6833, 0x0000, 0x0078, 0x2e40, 0x68b4, 0xa084, 0x4800, 0xa635,
986 0xa684, 0x4000, 0x00c0, 0x2e6e, 0x703c, 0xa005, 0x00c0, 0x2e82,
987 0x703f, 0x0015, 0x79d8, 0x7adc, 0x78d0, 0x80fb, 0x00c8, 0x2e89,
988 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000, 0x692e, 0x6a32,
989 0x2100, 0xa205, 0x00c0, 0x2e96, 0x0078, 0x2e40, 0x7000, 0xa086,
990 0x0006, 0x0040, 0x2e9f, 0x1078, 0x49ed, 0x0078, 0x2e40, 0x007c,
991 0x6008, 0xa085, 0x0200, 0x600a, 0xa384, 0x0200, 0x0040, 0x2eac,
992 0x6008, 0xa085, 0x0002, 0x600a, 0x681b, 0x0006, 0x688f, 0x0000,
993 0x6893, 0x0000, 0x6a30, 0x692c, 0x6a3e, 0x6942, 0x682f, 0x0003,
994 0x6833, 0x0000, 0x6837, 0x0020, 0x6897, 0x0000, 0x689b, 0x0020,
995 0x68b3, 0x0000, 0x68af, 0x0000, 0x7000, 0x0079, 0x2ec7, 0x2461,
996 0x2ed1, 0x2eda, 0x2ecf, 0x2ecf, 0x2ecf, 0x2ecf, 0x2ecf, 0x1078,
997 0x23ca, 0x6820, 0xa084, 0x0001, 0x00c0, 0x2eda, 0x1078, 0x33ae,
998 0x0078, 0x2ee0, 0x7060, 0x2c50, 0x2060, 0x6800, 0x6002, 0x2a60,
999 0x2021, 0x505a, 0x2404, 0xa005, 0x0040, 0x2ee9, 0x2020, 0x0078,
1000 0x2ee2, 0x2d22, 0x206b, 0x0000, 0x007c, 0x1078, 0x33b5, 0x1078,
1001 0x33c4, 0x6008, 0xa084, 0xfdff, 0x600a, 0x682b, 0x0000, 0x789b,
1002 0x000e, 0x6f14, 0x6817, 0x0002, 0x1078, 0x4a35, 0xa684, 0x0800,
1003 0x0040, 0x2f06, 0x691c, 0xa18d, 0x2000, 0x691e, 0x6818, 0xa084,
1004 0x8000, 0x0040, 0x2f16, 0x7868, 0xa08c, 0x00ff, 0x0040, 0x2f14,
1005 0x681b, 0x001e, 0x0078, 0x2f16, 0x681b, 0x0000, 0x2021, 0x505a,
1006 0x2404, 0xad06, 0x0040, 0x2f1d, 0x7460, 0x6800, 0x2022, 0x68c3,
1007 0x0000, 0x6a3c, 0x6940, 0x6a32, 0x692e, 0x1078, 0x1c53, 0x0078,
1008 0x2461, 0x1078, 0x2e1c, 0x682b, 0x0000, 0x2001, 0x000e, 0x6f14,
1009 0x1078, 0x38e4, 0xa08c, 0x00ff, 0x6916, 0x6818, 0xa084, 0x8000,
1010 0x0040, 0x2f3c, 0x703c, 0x681a, 0xa68c, 0xdf00, 0x691e, 0x706f,
1011 0x0000, 0x0078, 0x2461, 0x7000, 0xa005, 0x00c0, 0x2f49, 0x0078,
1012 0x2461, 0xa006, 0x1078, 0x4633, 0x6817, 0x0000, 0x681b, 0x0014,
1013 0xa68c, 0xdf00, 0x691e, 0x682b, 0x0000, 0x6820, 0xa085, 0x00ff,
1014 0x6822, 0x7000, 0x0079, 0x2f5c, 0x2461, 0x2f66, 0x2f66, 0x2f68,
1015 0x2f68, 0x2f68, 0x2f68, 0x2f64, 0x1078, 0x23ca, 0x1078, 0x33c4,
1016 0x6008, 0xa084, 0xffef, 0x600a, 0x0078, 0x337e, 0x2300, 0x0079,
1017 0x2f71, 0x2f74, 0x2f76, 0x2faf, 0x1078, 0x23ca, 0x7000, 0x0079,
1018 0x2f79, 0x2461, 0x2f83, 0x2f83, 0x2f9e, 0x2f83, 0x2fab, 0x2f9e,
1019 0x2f81, 0x1078, 0x23ca, 0xa684, 0x0060, 0xa086, 0x0060, 0x00c0,
1020 0x2f9a, 0xa6b4, 0xffdf, 0xa6b4, 0xbfff, 0xa6b5, 0x2000, 0x7e5a,
1021 0x681c, 0xa084, 0xffdf, 0x681e, 0x1078, 0x4633, 0x1078, 0x48f7,
1022 0x0078, 0x3854, 0xa684, 0x2000, 0x0040, 0x2f8d, 0x6818, 0xa084,
1023 0x8000, 0x0040, 0x2fab, 0x681b, 0x0015, 0xa684, 0x4000, 0x0040,
1024 0x2fab, 0x681b, 0x0007, 0x1078, 0x3868, 0x0078, 0x2438, 0x1078,
1025 0x23ca, 0x2300, 0x0079, 0x2fb4, 0x2fb7, 0x2fb9, 0x2fec, 0x1078,
1026 0x23ca, 0x7000, 0x0079, 0x2fbc, 0x2461, 0x2fc6, 0x2fc6, 0x2fe1,
1027 0x2fc6, 0x2fe8, 0x2fe1, 0x2fc4, 0x1078, 0x23ca, 0xa684, 0x0060,
1028 0xa086, 0x0060, 0x00c0, 0x2fdd, 0xa6b4, 0xffbf, 0xa6b4, 0xbfff,
1029 0xa6b5, 0x2000, 0x7e5a, 0x681c, 0xa084, 0xffbf, 0x681e, 0x1078,
1030 0x4633, 0x1078, 0x48f7, 0x0078, 0x3854, 0xa684, 0x2000, 0x0040,
1031 0x2fd0, 0x6818, 0xa084, 0x8000, 0x0040, 0x2fe8, 0x681b, 0x0007,
1032 0x781b, 0x00d2, 0x0078, 0x2438, 0x6820, 0xa085, 0x0004, 0x6822,
1033 0x1078, 0x381f, 0xa6b5, 0x0800, 0x1078, 0x368f, 0x782b, 0x3008,
1034 0x781b, 0x0065, 0x0078, 0x2438, 0x2300, 0x0079, 0x2fff, 0x3002,
1035 0x3004, 0x3006, 0x1078, 0x23ca, 0x0078, 0x367b, 0xa684, 0x0400,
1036 0x00c0, 0x302f, 0x79e4, 0xa184, 0x0020, 0x0040, 0x3016, 0x78ec,
1037 0xa084, 0x0003, 0x0040, 0x3016, 0x782b, 0x3009, 0x789b, 0x0060,
1038 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x79e4, 0xa184, 0x0020,
1039 0x0040, 0x3027, 0x78ec, 0xa084, 0x0003, 0x00c0, 0x302b, 0x2001,
1040 0x0014, 0x0078, 0x2cd7, 0xa184, 0x0007, 0x0079, 0x3067, 0x7a90,
1041 0xa294, 0x0007, 0x789b, 0x0060, 0x79a8, 0x81ff, 0x0040, 0x3065,
1042 0x789b, 0x0010, 0x7ba8, 0xa384, 0x0001, 0x00c0, 0x3056, 0x7ba8,
1043 0x7ba8, 0xa386, 0x0001, 0x00c0, 0x3049, 0x2009, 0xfff7, 0x0078,
1044 0x304f, 0xa386, 0x0003, 0x00c0, 0x3056, 0x2009, 0xffef, 0x0c7e,
1045 0x7054, 0x2060, 0x6004, 0xa104, 0x6006, 0x0c7f, 0x789b, 0x0060,
1046 0x78ab, 0x0000, 0xa684, 0xfffb, 0x785a, 0x782b, 0x3009, 0x6920,
1047 0xa18c, 0xfdff, 0xa18c, 0xfeff, 0x6922, 0x0078, 0x3854, 0x297d,
1048 0x2988, 0x3071, 0x3079, 0x306f, 0x306f, 0x3854, 0x3854, 0x1078,
1049 0x23ca, 0x6920, 0xa18c, 0xfdff, 0xa18c, 0xfeff, 0x6922, 0x0078,
1050 0x385e, 0x6920, 0xa18c, 0xfdff, 0xa18c, 0xfeff, 0x6922, 0x0078,
1051 0x3854, 0x79e4, 0xa184, 0x0030, 0x0040, 0x308b, 0x78ec, 0xa084,
1052 0x0003, 0x00c0, 0x30b2, 0x7000, 0xa086, 0x0004, 0x00c0, 0x30a5,
1053 0x706c, 0xa086, 0x0002, 0x00c0, 0x309b, 0x2011, 0x0002, 0x2019,
1054 0x0000, 0x0078, 0x2827, 0x706c, 0xa086, 0x0006, 0x0040, 0x3095,
1055 0x706c, 0xa086, 0x0004, 0x0040, 0x3095, 0x7000, 0xa086, 0x0000,
1056 0x0040, 0x2438, 0x6818, 0xa085, 0x8000, 0x681a, 0x2001, 0x0014,
1057 0x0078, 0x2cd7, 0xa184, 0x0007, 0x0079, 0x30b6, 0x3854, 0x3854,
1058 0x30be, 0x3854, 0x38b9, 0x38b9, 0x3854, 0x3854, 0xa684, 0x0080,
1059 0x0040, 0x30ed, 0x7194, 0x81ff, 0x0040, 0x30ed, 0xa182, 0x000d,
1060 0x00d0, 0x30ce, 0x7097, 0x0000, 0x0078, 0x30d3, 0xa182, 0x000c,
1061 0x7096, 0x2009, 0x000c, 0x789b, 0x0061, 0x79aa, 0x157e, 0x137e,
1062 0x147e, 0x7098, 0x8114, 0xa210, 0x729a, 0xa080, 0x000b, 0xad00,
1063 0x2098, 0x20a1, 0x012b, 0x789b, 0x0000, 0x8108, 0x81ac, 0x53a6,
1064 0x147f, 0x137f, 0x157f, 0x0078, 0x385e, 0xa684, 0x0400, 0x00c0,
1065 0x312e, 0x6820, 0xa084, 0x0001, 0x0040, 0x385e, 0xa68c, 0x0060,
1066 0xa684, 0x0060, 0x0040, 0x3102, 0xa086, 0x0060, 0x00c0, 0x3102,
1067 0xa18d, 0x4000, 0xa18c, 0xfffb, 0x795a, 0x69b6, 0x789b, 0x0060,
1068 0x78ab, 0x0000, 0x789b, 0x0061, 0x6818, 0xa085, 0x8000, 0x681a,
1069 0x78aa, 0x8008, 0x810c, 0x0040, 0x33dd, 0xa18c, 0x00f8, 0x00c0,
1070 0x33dd, 0x157e, 0x137e, 0x147e, 0x20a1, 0x012b, 0x789b, 0x0000,
1071 0x8000, 0x80ac, 0xad80, 0x000b, 0x2098, 0x53a6, 0x147f, 0x137f,
1072 0x157f, 0x6814, 0x8007, 0x7882, 0x0078, 0x385e, 0x6818, 0xa084,
1073 0x8000, 0x0040, 0x3135, 0x681b, 0x0008, 0x781b, 0x00c8, 0x0078,
1074 0x2438, 0x2300, 0x0079, 0x313c, 0x3141, 0x31e0, 0x313f, 0x1078,
1075 0x23ca, 0x7000, 0xa084, 0x0007, 0x0079, 0x3146, 0x2461, 0x3150,
1076 0x3185, 0x315b, 0x314e, 0x2461, 0x314e, 0x314e, 0x1078, 0x23ca,
1077 0x681c, 0xa084, 0x2000, 0x0040, 0x3169, 0x6008, 0xa085, 0x0002,
1078 0x600a, 0x0078, 0x3169, 0x68c0, 0xa005, 0x00c0, 0x3185, 0x6920,
1079 0xa18d, 0x0001, 0x6922, 0x68c3, 0x0001, 0x6800, 0x706a, 0x0078,
1080 0x317f, 0x6920, 0xa18d, 0x0001, 0x6922, 0x6800, 0x6006, 0xa005,
1081 0x00c0, 0x3173, 0x6002, 0x681c, 0xa084, 0x000e, 0x0040, 0x317f,
1082 0x7014, 0x68ba, 0x7130, 0xa188, 0x7300, 0x0078, 0x3181, 0x2009,
1083 0x7400, 0x2104, 0x6802, 0x2d0a, 0x7162, 0x6eb6, 0xa684, 0x0060,
1084 0x0040, 0x31de, 0xa684, 0x0800, 0x00c0, 0x3199, 0xa684, 0x7fff,
1085 0x68b6, 0x6894, 0x68a6, 0x6898, 0x68aa, 0x1078, 0x4633, 0x0078,
1086 0x31de, 0xa684, 0x0020, 0x0040, 0x31ae, 0x68c0, 0xa005, 0x0040,
1087 0x31a5, 0x1078, 0x4a35, 0x0078, 0x31a8, 0xa006, 0x1078, 0x49ed,
1088 0x79d8, 0x7adc, 0x69aa, 0x6aa6, 0x0078, 0x31b4, 0x1078, 0x37ca,
1089 0x69aa, 0x6aa6, 0x1078, 0x49ed, 0xa684, 0x8000, 0x0040, 0x31de,
1090 0xa684, 0x7fff, 0x68b6, 0x2001, 0x0076, 0x1078, 0x38e4, 0x2010,
1091 0x2001, 0x0078, 0x1078, 0x38e4, 0x2008, 0xa684, 0x0020, 0x00c0,
1092 0x31d6, 0x2001, 0x007a, 0x1078, 0x38e4, 0x801b, 0x00c8, 0x31d1,
1093 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000, 0x6b98, 0x2100,
1094 0xa302, 0x68b2, 0x6b94, 0x2200, 0xa303, 0x68ae, 0x0078, 0x2461,
1095 0x0078, 0x367b, 0x7037, 0x0000, 0xa282, 0x0006, 0x0050, 0x31ea,
1096 0x1078, 0x23ca, 0x7000, 0xa084, 0x0007, 0x10c0, 0x398a, 0x2300,
1097 0x0079, 0x31f2, 0x31f5, 0x321e, 0x3232, 0x2200, 0x0079, 0x31f8,
1098 0x321c, 0x367b, 0x31fe, 0x321c, 0x324e, 0x3290, 0x7003, 0x0005,
1099 0x2001, 0x7510, 0x2068, 0x704a, 0x157e, 0x20a9, 0x0031, 0x2003,
1100 0x0000, 0x8000, 0x0070, 0x320e, 0x0078, 0x3207, 0x157f, 0xad80,
1101 0x0009, 0x7036, 0x6817, 0x0000, 0x68b7, 0x0700, 0x6823, 0x0800,
1102 0x6827, 0x0003, 0x0078, 0x366b, 0x1078, 0x23ca, 0x7003, 0x0005,
1103 0x2001, 0x7510, 0x2068, 0x704a, 0xad80, 0x0009, 0x7036, 0x2200,
1104 0x0079, 0x322a, 0x367b, 0x3230, 0x3230, 0x324e, 0x3230, 0x367b,
1105 0x1078, 0x23ca, 0x7003, 0x0005, 0x2001, 0x7510, 0x2068, 0x704a,
1106 0xad80, 0x0009, 0x7036, 0x2200, 0x0079, 0x323e, 0x3246, 0x3244,
1107 0x3244, 0x3246, 0x3244, 0x3246, 0x1078, 0x23ca, 0x1078, 0x369f,
1108 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2438, 0x7003, 0x0002,
1109 0x7a80, 0xa294, 0x0f00, 0x789b, 0x0018, 0x7ca8, 0xa484, 0x001f,
1110 0xa215, 0x2069, 0x7400, 0x2d04, 0x2d08, 0x7162, 0x2068, 0xa005,
1111 0x0040, 0x3269, 0x6814, 0xa206, 0x0040, 0x3285, 0x6800, 0x0078,
1112 0x325c, 0x7003, 0x0005, 0x2001, 0x7510, 0x2068, 0x704a, 0x7036,
1113 0x157e, 0x20a9, 0x0031, 0x2003, 0x0000, 0x8000, 0x0070, 0x327a,
1114 0x0078, 0x3273, 0x157f, 0xad80, 0x0009, 0x7036, 0x6a16, 0x68b7,
1115 0x0700, 0x6823, 0x0800, 0x6827, 0x0003, 0x6eb4, 0x7e5a, 0x6820,
1116 0xa084, 0x0c00, 0x0040, 0x32df, 0x1078, 0x3697, 0x0078, 0x32df,
1117 0x7003, 0x0002, 0x7a80, 0xa294, 0x0f00, 0x789b, 0x0018, 0x7ca8,
1118 0xa484, 0x001f, 0xa215, 0x79a8, 0x79a8, 0xa18c, 0x00ff, 0xa1e8,
1119 0x7300, 0x2d04, 0x2d08, 0x7162, 0x2068, 0xa005, 0x0040, 0x32af,
1120 0x6814, 0xa206, 0x0040, 0x32ca, 0x6800, 0x0078, 0x32a2, 0x7003,
1121 0x0005, 0x2001, 0x7510, 0x2068, 0x704a, 0x157e, 0x20a9, 0x0031,
1122 0x2003, 0x0000, 0x8000, 0x0070, 0x32bf, 0x0078, 0x32b8, 0x157f,
1123 0xad80, 0x0009, 0x7036, 0x6a16, 0x68b7, 0x0700, 0x6823, 0x0800,
1124 0x6827, 0x0003, 0x6eb4, 0x7e5a, 0x6820, 0xa084, 0x0c00, 0x0040,
1125 0x32df, 0xa084, 0x0800, 0x0040, 0x32d9, 0x1078, 0x369b, 0x0078,
1126 0x32df, 0x1078, 0x3697, 0x708b, 0x0000, 0x0078, 0x32df, 0x027e,
1127 0x8207, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa080, 0x5280,
1128 0x2060, 0x7056, 0x6000, 0x705a, 0x6004, 0x705e, 0xa684, 0x0060,
1129 0x0040, 0x3337, 0x6b98, 0x6c94, 0x69ac, 0x68b0, 0xa105, 0x00c0,
1130 0x3319, 0x7bd2, 0x7bda, 0x7cd6, 0x7cde, 0xa6b4, 0xb7ff, 0x7e5a,
1131 0xa684, 0x0060, 0xa086, 0x0060, 0x0040, 0x3337, 0x68c0, 0xa005,
1132 0x0040, 0x3312, 0x7003, 0x0003, 0x682b, 0x0000, 0x1078, 0x48e6,
1133 0x0078, 0x3314, 0x1078, 0x48f7, 0xa6b5, 0x2000, 0x7e5a, 0x0078,
1134 0x3337, 0x68b0, 0xa31a, 0x2100, 0xa423, 0x2400, 0xa305, 0x0040,
1135 0x3337, 0x7bd2, 0x7bda, 0x7cd6, 0x7cde, 0x68b0, 0xa6b4, 0xbfff,
1136 0x7e5a, 0x007e, 0x68c0, 0xa005, 0x007f, 0x0040, 0x3335, 0x7003,
1137 0x0003, 0x1078, 0x48e6, 0x0078, 0x3337, 0x1078, 0x4942, 0x077f,
1138 0x1078, 0x37bd, 0x2009, 0x0065, 0xa684, 0x0004, 0x0040, 0x3358,
1139 0x78e4, 0xa084, 0x0030, 0x0040, 0x3350, 0x78ec, 0xa084, 0x0003,
1140 0x0040, 0x3350, 0x782b, 0x3008, 0x2009, 0x0065, 0x0078, 0x3358,
1141 0x0f7e, 0x2079, 0x5000, 0x1078, 0x4633, 0x0f7f, 0x0040, 0x2461,
1142 0x791a, 0x2d00, 0x704a, 0x8207, 0xa084, 0x000f, 0x8003, 0x8003,
1143 0x8003, 0xa080, 0x5280, 0x2048, 0x0078, 0x2438, 0x6020, 0xa005,
1144 0x0040, 0x3372, 0x8001, 0x6022, 0x6008, 0xa085, 0x0008, 0x600a,
1145 0x7010, 0x6026, 0x007c, 0xa006, 0x1078, 0x4633, 0x6817, 0x0000,
1146 0x681b, 0x0001, 0x6823, 0x0040, 0x681f, 0x0100, 0x7000, 0xa084,
1147 0x0007, 0x0079, 0x3383, 0x2461, 0x338d, 0x338d, 0x33aa, 0x3395,
1148 0x3393, 0x3395, 0x338b, 0x1078, 0x23ca, 0x1078, 0x33b5, 0x1078,
1149 0x33ae, 0x1078, 0x1c53, 0x0078, 0x2461, 0x706c, 0x706f, 0x0000,
1150 0x7093, 0x0000, 0x0079, 0x339c, 0x33a6, 0x33a6, 0x33a4, 0x33a4,
1151 0x33a4, 0x33a6, 0x33a4, 0x33a6, 0x0079, 0x2840, 0x706f, 0x0000,
1152 0x0078, 0x2461, 0x681b, 0x0000, 0x0078, 0x2eed, 0x6800, 0xa005,
1153 0x00c0, 0x33b3, 0x6002, 0x6006, 0x007c, 0x6010, 0xa005, 0x0040,
1154 0x33be, 0x8001, 0x00d0, 0x33be, 0x1078, 0x23ca, 0x6012, 0x6008,
1155 0xa084, 0xffef, 0x600a, 0x007c, 0x6018, 0xa005, 0x0040, 0x33ca,
1156 0x8001, 0x601a, 0x007c, 0x1078, 0x38de, 0x681b, 0x0018, 0x0078,
1157 0x3401, 0x1078, 0x38de, 0x681b, 0x0019, 0x0078, 0x3401, 0x1078,
1158 0x38de, 0x681b, 0x001a, 0x0078, 0x3401, 0x1078, 0x38de, 0x681b,
1159 0x0003, 0x0078, 0x3401, 0x7780, 0x1078, 0x37bd, 0x7184, 0xa18c,
1160 0x00ff, 0xa1e8, 0x7300, 0x2d04, 0x2d08, 0x2068, 0xa005, 0x00c0,
1161 0x33f3, 0x0078, 0x2461, 0x6814, 0x7280, 0xa206, 0x0040, 0x33fb,
1162 0x6800, 0x0078, 0x33ec, 0x6800, 0x200a, 0x681b, 0x0005, 0x708b,
1163 0x0000, 0x1078, 0x33b5, 0x6820, 0xa084, 0x0001, 0x00c0, 0x340a,
1164 0x1078, 0x33ae, 0x1078, 0x33c4, 0x681f, 0x0000, 0x6823, 0x0020,
1165 0x1078, 0x1c53, 0x0078, 0x2461, 0xa282, 0x0003, 0x00c0, 0x366b,
1166 0x7da8, 0xa5ac, 0x00ff, 0x7ca8, 0xa4a4, 0x00ff, 0x6920, 0xa18d,
1167 0x0080, 0x6922, 0xa184, 0x0100, 0x0040, 0x3478, 0xa18c, 0xfeff,
1168 0x6922, 0xa4a4, 0x00ff, 0x0040, 0x3462, 0xa482, 0x000c, 0x0048,
1169 0x3435, 0x0040, 0x3435, 0x2021, 0x000c, 0x852b, 0x852b, 0x1078,
1170 0x372e, 0x0040, 0x343f, 0x1078, 0x3531, 0x0078, 0x346b, 0x1078,
1171 0x36e9, 0x0c7e, 0x2960, 0x6004, 0xa084, 0xfff5, 0x6006, 0x1078,
1172 0x3558, 0x0c7f, 0x6920, 0xa18d, 0x0100, 0x6922, 0x7e58, 0xa6b5,
1173 0x0004, 0x7e5a, 0xa684, 0x0400, 0x00c0, 0x345c, 0x782b, 0x3008,
1174 0x781b, 0x0056, 0x0078, 0x2438, 0x782b, 0x3008, 0x781b, 0x0065,
1175 0x0078, 0x2438, 0x0c7e, 0x2960, 0x6004, 0xa084, 0xfff5, 0x6006,
1176 0x1078, 0x3558, 0x0c7f, 0x7e58, 0xa684, 0x0400, 0x00c0, 0x3474,
1177 0x781b, 0x0058, 0x0078, 0x2438, 0x781b, 0x0065, 0x0078, 0x2438,
1178 0x0c7e, 0x7054, 0x2060, 0x6100, 0xa18c, 0x1000, 0x0040, 0x34b8,
1179 0x6208, 0x8217, 0xa294, 0x00ff, 0xa282, 0x000c, 0x0048, 0x348c,
1180 0x0040, 0x348c, 0x2011, 0x000c, 0x2400, 0xa202, 0x00c8, 0x3491,
1181 0x2220, 0x6208, 0xa294, 0x00ff, 0x7018, 0xa086, 0x0028, 0x00c0,
1182 0x34a1, 0xa282, 0x0019, 0x00c8, 0x34a7, 0x2011, 0x0019, 0x0078,
1183 0x34a7, 0xa282, 0x000c, 0x00c8, 0x34a7, 0x2011, 0x000c, 0x2200,
1184 0xa502, 0x00c8, 0x34ac, 0x2228, 0x1078, 0x36ed, 0x852b, 0x852b,
1185 0x1078, 0x372e, 0x0040, 0x34b8, 0x1078, 0x3531, 0x0078, 0x34bc,
1186 0x1078, 0x36e9, 0x1078, 0x3558, 0x7858, 0xa085, 0x0004, 0x785a,
1187 0x0c7f, 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2438, 0x0c7e,
1188 0x2960, 0x6000, 0xa084, 0x1000, 0x00c0, 0x34df, 0x6010, 0xa084,
1189 0x000f, 0x00c0, 0x34d9, 0x6104, 0xa18c, 0xfff5, 0x6106, 0x0c7f,
1190 0x007c, 0x2011, 0x0032, 0x2019, 0x0000, 0x0078, 0x3506, 0x68a0,
1191 0xa084, 0x0200, 0x00c0, 0x34d9, 0x6208, 0xa294, 0x00ff, 0x7018,
1192 0xa086, 0x0028, 0x00c0, 0x34f4, 0xa282, 0x0019, 0x00c8, 0x34fa,
1193 0x2011, 0x0019, 0x0078, 0x34fa, 0xa282, 0x000c, 0x00c8, 0x34fa,
1194 0x2011, 0x000c, 0x6308, 0x831f, 0xa39c, 0x00ff, 0xa382, 0x000c,
1195 0x0048, 0x3506, 0x0040, 0x3506, 0x2019, 0x000c, 0x78ab, 0x0001,
1196 0x78ab, 0x0003, 0x78ab, 0x0001, 0x7aaa, 0x7baa, 0xa8c0, 0x0005,
1197 0x6820, 0xa085, 0x0100, 0x6822, 0x0c7f, 0x007c, 0x0c7e, 0x2960,
1198 0xa18c, 0xfff5, 0x6106, 0x2011, 0x0032, 0x2019, 0x0000, 0x0078,
1199 0x3521, 0x78ab, 0x0001, 0x78ab, 0x0003, 0x78ab, 0x0001, 0x7aaa,
1200 0x7baa, 0xa8c0, 0x0005, 0x6820, 0xa085, 0x0100, 0x6822, 0x0c7f,
1201 0x007c, 0x0c7e, 0x7154, 0x2160, 0x1078, 0x3538, 0x0c7f, 0x007c,
1202 0x2008, 0xa084, 0xfff0, 0xa425, 0x7c86, 0x6018, 0x789a, 0x7cae,
1203 0x6412, 0x78a4, 0xa084, 0xfff8, 0xa18c, 0x0007, 0xa105, 0x78a6,
1204 0x6016, 0x788a, 0xa4a4, 0x000f, 0x8427, 0x8204, 0x8004, 0xa084,
1205 0x00ff, 0xa405, 0x600e, 0x6004, 0xa084, 0xfff5, 0x6006, 0x007c,
1206 0x0c7e, 0x7054, 0x2060, 0x1078, 0x355f, 0x0c7f, 0x007c, 0x6018,
1207 0x789a, 0x78a4, 0xa084, 0xfff0, 0x78a6, 0x6012, 0x7884, 0xa084,
1208 0xfff0, 0x7886, 0x007c, 0xa282, 0x0002, 0x00c0, 0x366b, 0x7aa8,
1209 0x6920, 0xa18d, 0x0080, 0x6922, 0xa184, 0x0200, 0x0040, 0x35b4,
1210 0xa18c, 0xfdff, 0x6922, 0xa294, 0x00ff, 0xa282, 0x0002, 0x00c8,
1211 0x366b, 0x1078, 0x35fd, 0x1078, 0x3558, 0xa980, 0x0001, 0x200c,
1212 0x1078, 0x37b9, 0x1078, 0x34c7, 0x88ff, 0x0040, 0x35a7, 0x789b,
1213 0x0060, 0x2800, 0x78aa, 0x7e58, 0xa6b5, 0x0004, 0x7e5a, 0xa684,
1214 0x0400, 0x00c0, 0x35a1, 0x782b, 0x3008, 0x781b, 0x0056, 0x0078,
1215 0x2438, 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2438, 0x7e58,
1216 0xa684, 0x0400, 0x00c0, 0x35b0, 0x781b, 0x0058, 0x0078, 0x2438,
1217 0x781b, 0x0065, 0x0078, 0x2438, 0xa282, 0x0002, 0x00c8, 0x35bc,
1218 0xa284, 0x0001, 0x0040, 0x35c6, 0x7154, 0xa188, 0x0000, 0x210c,
1219 0xa18c, 0x2000, 0x00c0, 0x35c6, 0x2011, 0x0000, 0x1078, 0x36db,
1220 0x1078, 0x35fd, 0x1078, 0x3558, 0x7858, 0xa085, 0x0004, 0x785a,
1221 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2438, 0x0c7e, 0x027e,
1222 0x2960, 0x6000, 0x2011, 0x0001, 0xa084, 0x2000, 0x00c0, 0x35ed,
1223 0x6014, 0xa084, 0x0040, 0x00c0, 0x35eb, 0xa18c, 0xffef, 0x6106,
1224 0xa006, 0x0078, 0x35fa, 0x2011, 0x0000, 0x78ab, 0x0001, 0x78ab,
1225 0x0002, 0x78ab, 0x0003, 0x7aaa, 0xa8c0, 0x0004, 0x6820, 0xa085,
1226 0x0200, 0x6822, 0x027f, 0x0c7f, 0x007c, 0x0c7e, 0x7054, 0x2060,
1227 0x1078, 0x3604, 0x0c7f, 0x007c, 0x82ff, 0x0040, 0x3609, 0x2011,
1228 0x0040, 0x6018, 0xa080, 0x0002, 0x789a, 0x78a4, 0xa084, 0xffbf,
1229 0xa205, 0x78a6, 0x788a, 0x6016, 0x6004, 0xa084, 0xffef, 0x6006,
1230 0x007c, 0x007e, 0x7000, 0xa086, 0x0003, 0x0040, 0x3622, 0x007f,
1231 0x0078, 0x3625, 0x007f, 0x0078, 0x3667, 0xa684, 0x0020, 0x0040,
1232 0x3667, 0x7888, 0xa084, 0x0040, 0x0040, 0x3667, 0x7bb8, 0xa384,
1233 0x003f, 0x831b, 0x00c8, 0x3635, 0x8000, 0xa005, 0x0040, 0x364b,
1234 0x831b, 0x00c8, 0x363e, 0x8001, 0x0040, 0x3663, 0xa684, 0x4000,
1235 0x0040, 0x364b, 0x78b8, 0x801b, 0x00c8, 0x3647, 0x8000, 0xa084,
1236 0x003f, 0x00c0, 0x3663, 0xa6b4, 0xbfff, 0x7e5a, 0x79d8, 0x7adc,
1237 0x2001, 0x0001, 0xa108, 0x00c8, 0x3657, 0xa291, 0x0000, 0x79d2,
1238 0x79da, 0x7ad6, 0x7ade, 0x1078, 0x49ed, 0x781b, 0x0064, 0x1078,
1239 0x4872, 0x0078, 0x2438, 0x781b, 0x0064, 0x0078, 0x2438, 0x781b,
1240 0x0065, 0x0078, 0x2438, 0x1078, 0x36a3, 0x782b, 0x3008, 0x781b,
1241 0x0065, 0x0078, 0x2438, 0x1078, 0x368f, 0x782b, 0x3008, 0x781b,
1242 0x0065, 0x0078, 0x2438, 0x6827, 0x0002, 0x1078, 0x3697, 0x78e4,
1243 0xa084, 0x0030, 0x0040, 0x2461, 0x78ec, 0xa084, 0x0003, 0x0040,
1244 0x2461, 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2438, 0x2001,
1245 0x0005, 0x0078, 0x36a5, 0x2001, 0x000c, 0x0078, 0x36a5, 0x2001,
1246 0x0006, 0x0078, 0x36a5, 0x2001, 0x000d, 0x0078, 0x36a5, 0x2001,
1247 0x0009, 0x0078, 0x36a5, 0x2001, 0x0007, 0x789b, 0x0010, 0x78aa,
1248 0x789b, 0x0060, 0x78ab, 0x0001, 0xa6b5, 0x0004, 0x7e5a, 0x007c,
1249 0x077e, 0x873f, 0xa7bc, 0x000f, 0x873b, 0x873b, 0x8703, 0xa0e0,
1250 0x5280, 0xa7b8, 0x0020, 0x7f9a, 0x79a4, 0xa184, 0x000f, 0x0040,
1251 0x36c9, 0xa184, 0xfff0, 0x78a6, 0x6012, 0x6004, 0xa085, 0x0008,
1252 0x6006, 0x8738, 0x8738, 0x7f9a, 0x79a4, 0xa184, 0x0040, 0x0040,
1253 0x36d9, 0xa184, 0xffbf, 0x78a6, 0x6016, 0x6004, 0xa085, 0x0010,
1254 0x6006, 0x077f, 0x007c, 0x789b, 0x0010, 0x78ab, 0x0001, 0x78ab,
1255 0x0002, 0x78ab, 0x0003, 0x7aaa, 0x789b, 0x0060, 0x78ab, 0x0004,
1256 0x007c, 0x2021, 0x0000, 0x2029, 0x0032, 0x789b, 0x0010, 0x78ab,
1257 0x0001, 0x78ab, 0x0003, 0x78ab, 0x0001, 0x7daa, 0x7caa, 0x789b,
1258 0x0060, 0x78ab, 0x0005, 0x007c, 0x157e, 0x8007, 0xa084, 0x00ff,
1259 0x8003, 0x8003, 0xa080, 0x0020, 0x789a, 0x79a4, 0xa18c, 0xfff0,
1260 0x2001, 0x5046, 0x2004, 0xa082, 0x0028, 0x0040, 0x3717, 0x2021,
1261 0x37a0, 0x2019, 0x0014, 0x20a9, 0x000c, 0x0078, 0x371d, 0x2021,
1262 0x37ac, 0x2019, 0x0019, 0x20a9, 0x000d, 0x2011, 0x0064, 0x2404,
1263 0xa084, 0xfff0, 0xa106, 0x0040, 0x372c, 0x8420, 0x2300, 0xa210,
1264 0x0070, 0x372c, 0x0078, 0x371f, 0x157f, 0x007c, 0x157e, 0x2009,
1265 0x5046, 0x210c, 0xa182, 0x0032, 0x0048, 0x3742, 0x0040, 0x3746,
1266 0x2009, 0x3792, 0x2019, 0x0011, 0x20a9, 0x000e, 0x2011, 0x0032,
1267 0x0078, 0x3758, 0xa182, 0x0028, 0x0040, 0x3750, 0x2009, 0x37a0,
1268 0x2019, 0x0014, 0x20a9, 0x000c, 0x2011, 0x0064, 0x0078, 0x3758,
1269 0x2009, 0x37ac, 0x2019, 0x0019, 0x20a9, 0x000d, 0x2011, 0x0064,
1270 0x2200, 0xa502, 0x0040, 0x3768, 0x0048, 0x3768, 0x8108, 0x2300,
1271 0xa210, 0x0070, 0x3765, 0x0078, 0x3758, 0x157f, 0xa006, 0x007c,
1272 0x157f, 0xa582, 0x0064, 0x00c8, 0x3777, 0x7808, 0xa085, 0x0070,
1273 0x780a, 0x7044, 0xa085, 0x0070, 0x7046, 0x0078, 0x3777, 0x78ec,
1274 0xa084, 0x0300, 0x0040, 0x377f, 0x2104, 0x0078, 0x3790, 0x2104,
1275 0xa09e, 0x1102, 0x00c0, 0x3790, 0x2001, 0x04fd, 0x2004, 0xa082,
1276 0x0005, 0x0048, 0x378f, 0x2001, 0x1201, 0x0078, 0x3790, 0x2104,
1277 0xa005, 0x007c, 0x1102, 0x3002, 0x3202, 0x4203, 0x4403, 0x5404,
1278 0x5604, 0x6605, 0x6805, 0x7806, 0x7a06, 0x0c07, 0x0c07, 0x0e07,
1279 0x3202, 0x4202, 0x5202, 0x6202, 0x7202, 0x6605, 0x7605, 0x7805,
1280 0x7a05, 0x7c05, 0x7e05, 0x7f05, 0x2202, 0x3202, 0x4202, 0x5202,
1281 0x5404, 0x6404, 0x7404, 0x7604, 0x7804, 0x7a04, 0x7c04, 0x7e04,
1282 0x7f04, 0x789b, 0x0010, 0xa046, 0x007c, 0xa784, 0x0f00, 0x800b,
1283 0xa784, 0x001f, 0x8003, 0x8003, 0x8003, 0x8003, 0xa105, 0xa0e0,
1284 0x5300, 0x007c, 0x79d8, 0x7adc, 0x78d0, 0x801b, 0x00c8, 0x37d1,
1285 0x8000, 0xa084, 0x003f, 0xa108, 0xa291, 0x0000, 0x007c, 0x0f7e,
1286 0x2079, 0x0100, 0x2009, 0x5040, 0x2091, 0x8000, 0x2104, 0x0079,
1287 0x37e1, 0x3817, 0x37eb, 0x37eb, 0x37eb, 0x37eb, 0x37eb, 0x37eb,
1288 0x381b, 0x1078, 0x23ca, 0x784b, 0x0004, 0x7848, 0xa084, 0x0004,
1289 0x00c0, 0x37ed, 0x784b, 0x0008, 0x7848, 0xa084, 0x0008, 0x00c0,
1290 0x37f4, 0x68b4, 0xa085, 0x4000, 0x68b6, 0x7858, 0xa085, 0x4000,
1291 0x785a, 0x7830, 0xa084, 0x0080, 0x00c0, 0x3817, 0x0018, 0x3817,
1292 0x681c, 0xa084, 0x0020, 0x00c0, 0x3815, 0x0e7e, 0x2071, 0x5040,
1293 0x1078, 0x3868, 0x0e7f, 0x0078, 0x3817, 0x781b, 0x00d2, 0x2091,
1294 0x8001, 0x0f7f, 0x007c, 0x1078, 0x3a42, 0x0078, 0x3817, 0x0c7e,
1295 0x6814, 0x8007, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e0,
1296 0x5280, 0x6004, 0xa084, 0x000a, 0x00c0, 0x3852, 0x6108, 0xa194,
1297 0xff00, 0x0040, 0x3852, 0xa18c, 0x00ff, 0x2001, 0x0019, 0xa106,
1298 0x0040, 0x3841, 0x2001, 0x0032, 0xa106, 0x0040, 0x3845, 0x0078,
1299 0x3849, 0x2009, 0x0020, 0x0078, 0x384b, 0x2009, 0x003f, 0x0078,
1300 0x384b, 0x2011, 0x0000, 0x2100, 0xa205, 0x600a, 0x6004, 0xa085,
1301 0x0002, 0x6006, 0x0c7f, 0x007c, 0x781b, 0x0065, 0x0078, 0x2438,
1302 0x782b, 0x3008, 0x781b, 0x0065, 0x0078, 0x2438, 0x781b, 0x0058,
1303 0x0078, 0x2438, 0x782b, 0x3008, 0x781b, 0x0056, 0x0078, 0x2438,
1304 0x2009, 0x5020, 0x210c, 0xa186, 0x0000, 0x0040, 0x387c, 0xa186,
1305 0x0001, 0x0040, 0x387f, 0x2009, 0x5038, 0x200b, 0x000b, 0x706f,
1306 0x0001, 0x781b, 0x0048, 0x007c, 0x781b, 0x00cc, 0x007c, 0x2009,
1307 0x5038, 0x200b, 0x000a, 0x007c, 0x2009, 0x5020, 0x210c, 0xa186,
1308 0x0000, 0x0040, 0x389f, 0xa186, 0x0001, 0x0040, 0x3899, 0x2009,
1309 0x5038, 0x200b, 0x000b, 0x706f, 0x0001, 0x781b, 0x0048, 0x0078,
1310 0x2438, 0x2009, 0x5038, 0x200b, 0x000a, 0x0078, 0x2438, 0x782b,
1311 0x3008, 0x781b, 0x00cc, 0x0078, 0x2438, 0x781b, 0x00d2, 0x0078,
1312 0x2438, 0x782b, 0x3008, 0x781b, 0x00d2, 0x0078, 0x2438, 0x781b,
1313 0x0093, 0x0078, 0x2438, 0x782b, 0x3008, 0x781b, 0x0093, 0x0078,
1314 0x2438, 0x6818, 0xa084, 0x8000, 0x0040, 0x38c0, 0x681b, 0x001d,
1315 0x706f, 0x0001, 0x781b, 0x0048, 0x0078, 0x2438, 0x007e, 0x7830,
1316 0xa084, 0x00c0, 0x00c0, 0x38dc, 0x7808, 0xa084, 0xfffc, 0x780a,
1317 0x0005, 0x0005, 0x0005, 0x0005, 0x78ec, 0xa084, 0x0021, 0x0040,
1318 0x38dc, 0x7044, 0x780a, 0xa005, 0x007f, 0x007c, 0x7044, 0xa085,
1319 0x0002, 0x7046, 0x780a, 0x007c, 0x007e, 0x7830, 0xa084, 0x0040,
1320 0x00c0, 0x38e5, 0x0098, 0x38f0, 0x007f, 0x789a, 0x78ac, 0x007c,
1321 0x7808, 0xa084, 0xfffd, 0x780a, 0x0005, 0x0005, 0x0005, 0x0005,
1322 0x78ec, 0xa084, 0x0021, 0x0040, 0x38ff, 0x0098, 0x38fd, 0x007f,
1323 0x789a, 0x78ac, 0x007e, 0x7044, 0x780a, 0x007f, 0x007c, 0x78ec,
1324 0xa084, 0x0002, 0x00c0, 0x461d, 0xa784, 0x007d, 0x00c0, 0x3913,
1325 0x2700, 0x1078, 0x23ca, 0xa784, 0x0001, 0x00c0, 0x2f43, 0xa784,
1326 0x0070, 0x0040, 0x3923, 0x0c7e, 0x2d60, 0x2f68, 0x1078, 0x2375,
1327 0x2d78, 0x2c68, 0x0c7f, 0xa784, 0x0008, 0x0040, 0x3930, 0x784b,
1328 0x0008, 0x78ec, 0xa084, 0x0003, 0x0040, 0x2461, 0x0078, 0x3854,
1329 0xa784, 0x0004, 0x0040, 0x3963, 0x78b8, 0xa084, 0x4001, 0x0040,
1330 0x3963, 0x784b, 0x0008, 0x78ec, 0xa084, 0x0003, 0x0040, 0x2461,
1331 0x78e4, 0xa084, 0x0007, 0xa086, 0x0001, 0x00c0, 0x3963, 0x78c0,
1332 0xa085, 0x4800, 0x2030, 0x7e5a, 0x781b, 0x00d2, 0x0078, 0x2438,
1333 0x784b, 0x0008, 0x6818, 0xa084, 0x8000, 0x0040, 0x395f, 0x681b,
1334 0x0015, 0xa684, 0x4000, 0x0040, 0x395f, 0x681b, 0x0007, 0x1078,
1335 0x3868, 0x0078, 0x2438, 0x681b, 0x0003, 0x7858, 0xa084, 0x3f00,
1336 0x681e, 0x682f, 0x0000, 0x6833, 0x0000, 0x784b, 0x0008, 0x78ec,
1337 0xa084, 0x0003, 0x0040, 0x2944, 0x0018, 0x2438, 0x0078, 0x3673,
1338 0x6b14, 0x8307, 0xa084, 0x000f, 0x8003, 0x8003, 0x8003, 0xa080,
1339 0x5280, 0x2060, 0x2048, 0x7056, 0x6000, 0x705a, 0x6004, 0x705e,
1340 0x2a60, 0x007c, 0x0079, 0x398c, 0x3994, 0x3995, 0x3994, 0x3997,
1341 0x3994, 0x3994, 0x3994, 0x399c, 0x007c, 0x1078, 0x33c4, 0x1078,
1342 0x4633, 0x7038, 0x600a, 0x007c, 0x70a0, 0xa005, 0x0040, 0x39a9,
1343 0x2068, 0x1078, 0x1b45, 0x1078, 0x45b5, 0x1078, 0x45bc, 0x70a3,
1344 0x0000, 0x007c, 0x0e7e, 0x2091, 0x8000, 0x2071, 0x5040, 0x7000,
1345 0xa086, 0x0007, 0x00c0, 0x39c0, 0x6110, 0x70bc, 0xa106, 0x00c0,
1346 0x39c0, 0x0e7f, 0x1078, 0x1b52, 0x1078, 0x39c6, 0xa006, 0x007c,
1347 0x2091, 0x8001, 0x0e7f, 0xa085, 0x0001, 0x007c, 0x0f7e, 0x0e7e,
1348 0x2071, 0x5040, 0x0078, 0x21d9, 0x785b, 0x0000, 0x70af, 0x000e,
1349 0x2009, 0x0100, 0x017e, 0x70a0, 0xa06d, 0x0040, 0x39db, 0x70a3,
1350 0x0000, 0x0078, 0x39e1, 0x70b3, 0x0000, 0x1078, 0x1b6e, 0x0040,
1351 0x39e7, 0x70ac, 0x6826, 0x1078, 0x3ac2, 0x0078, 0x39db, 0x017f,
1352 0x157e, 0x0c7e, 0x0d7e, 0x20a9, 0x0008, 0x2061, 0x7410, 0x6000,
1353 0xa105, 0x6002, 0x601c, 0xa06d, 0x0040, 0x39ff, 0x6800, 0x601e,
1354 0x1078, 0x193d, 0x6008, 0x8000, 0x600a, 0x0078, 0x39f2, 0x6018,
1355 0xa06d, 0x0040, 0x3a09, 0x6800, 0x601a, 0x1078, 0x193d, 0x0078,
1356 0x39ff, 0xace0, 0x0008, 0x0070, 0x3a0f, 0x0078, 0x39ef, 0x709c,
1357 0xa084, 0x8000, 0x0040, 0x3a16, 0x1078, 0x3b3c, 0x0d7f, 0x0c7f,
1358 0x157f, 0x007c, 0x127e, 0x2091, 0x2300, 0x6804, 0xa084, 0x000f,
1359 0x0079, 0x3a22, 0x3a32, 0x3a32, 0x3a32, 0x3a32, 0x3a32, 0x3a32,
1360 0x3a34, 0x3a3a, 0x3a32, 0x3a32, 0x3a32, 0x3a32, 0x3a32, 0x3a3c,
1361 0x3a32, 0x3a34, 0x1078, 0x23ca, 0x1078, 0x4466, 0x1078, 0x193d,
1362 0x0078, 0x3a40, 0x6827, 0x000b, 0x1078, 0x4466, 0x1078, 0x3ac2,
1363 0x127f, 0x007c, 0x127e, 0x2091, 0x2300, 0x0098, 0x3a5e, 0x7830,
1364 0xa084, 0x00c0, 0x00c0, 0x3a5e, 0x0d7e, 0x1078, 0x45c5, 0x2d00,
1365 0x682e, 0x2009, 0x0004, 0x2001, 0x0000, 0x6827, 0x0084, 0x1078,
1366 0x457e, 0x1078, 0x3ac2, 0x0d7f, 0x0078, 0x3a90, 0x7948, 0xa185,
1367 0x4000, 0x784a, 0x0098, 0x3a67, 0x794a, 0x0078, 0x3a4c, 0x7828,
1368 0xa086, 0x1834, 0x00c0, 0x3a70, 0xa185, 0x0004, 0x0078, 0x3a77,
1369 0x7828, 0xa186, 0x1814, 0x00c0, 0x3a64, 0xa185, 0x000c, 0x784a,
1370 0x789b, 0x000e, 0x78ab, 0x0002, 0x7858, 0xa084, 0x00ff, 0xa085,
1371 0x0400, 0x785a, 0x70b4, 0xa080, 0x0091, 0x781a, 0x6827, 0x0002,
1372 0x6827, 0x0084, 0x2009, 0x0004, 0x2001, 0x0000, 0x1078, 0x457e,
1373 0x127f, 0x007c, 0x0d7e, 0x6b14, 0x1078, 0x1be0, 0x0040, 0x3a9f,
1374 0x2068, 0x6827, 0x0002, 0x1078, 0x3ac2, 0x0078, 0x3a94, 0x0d7f,
1375 0x007c, 0x0d7e, 0x6b14, 0x6c28, 0xa4a4, 0x00ff, 0x1078, 0x1b7e,
1376 0x0040, 0x3aaf, 0x2068, 0x6827, 0x0002, 0x1078, 0x3ac2, 0x0d7f,
1377 0x007c, 0x0d7e, 0x6b14, 0xa39c, 0x00ff, 0x1078, 0x1bb1, 0x0040,
1378 0x3ac0, 0x2068, 0x6827, 0x0002, 0x1078, 0x3ac2, 0x0078, 0x3ab5,
1379 0x0d7f, 0x007c, 0x0c7e, 0x6914, 0x1078, 0x3b33, 0x6904, 0xa18c,
1380 0x00ff, 0xa186, 0x0006, 0x0040, 0x3add, 0xa186, 0x000d, 0x0040,
1381 0x3afc, 0xa186, 0x0017, 0x00c0, 0x3ad9, 0x1078, 0x193d, 0x0078,
1382 0x3adb, 0x1078, 0x1c55, 0x0c7f, 0x007c, 0x6004, 0x8001, 0x0048,
1383 0x3afa, 0x6006, 0x2009, 0x0000, 0xa684, 0x0001, 0x00c0, 0x3aea,
1384 0xa18d, 0x8000, 0xa684, 0x0004, 0x0040, 0x3af0, 0xa18d, 0x0002,
1385 0x691e, 0x6823, 0x0000, 0x7104, 0x810f, 0x6818, 0xa105, 0x681a,
1386 0x0078, 0x3ad9, 0x1078, 0x23ca, 0x6018, 0xa005, 0x00c0, 0x3b0b,
1387 0x6008, 0x8001, 0x0048, 0x3b0b, 0x600a, 0x601c, 0x6802, 0x2d00,
1388 0x601e, 0x0078, 0x3b21, 0xac88, 0x0006, 0x2104, 0xa005, 0x0040,
1389 0x3b14, 0x2008, 0x0078, 0x3b0d, 0x6802, 0x2d0a, 0x6008, 0x8001,
1390 0x0048, 0x3adb, 0x600a, 0x6018, 0x2068, 0x6800, 0x601a, 0x0078,
1391 0x3b05, 0x157e, 0x137e, 0x147e, 0x0c7e, 0x0d7e, 0x1078, 0x191a,
1392 0x2da0, 0x137f, 0x20a9, 0x0031, 0x53a3, 0x0c7f, 0x147f, 0x137f,
1393 0x157f, 0x0078, 0x3ad9, 0xa184, 0x001f, 0x8003, 0x8003, 0x8003,
1394 0xa080, 0x7410, 0x2060, 0x007c, 0x2019, 0x5051, 0x2304, 0xa085,
1395 0x0001, 0x201a, 0x2019, 0x0102, 0x2304, 0xa085, 0x0001, 0x201a,
1396 0x007c, 0x2019, 0x5051, 0x2304, 0xa084, 0xfffe, 0x201a, 0x2019,
1397 0x0102, 0x2304, 0xa084, 0xfffe, 0x201a, 0x007c, 0x7990, 0xa18c,
1398 0xfff8, 0x7992, 0x70b4, 0xa080, 0x00d8, 0x781a, 0x0078, 0x2438,
1399 0x70a3, 0x0000, 0x7003, 0x0000, 0x7043, 0x0001, 0x7037, 0x0000,
1400 0x0018, 0x23ef, 0x1078, 0x1b6e, 0x0040, 0x3b91, 0x2009, 0x500f,
1401 0x200b, 0x0000, 0x68bc, 0x2060, 0x6100, 0xa184, 0x0300, 0x0040,
1402 0x3b85, 0x6827, 0x000e, 0xa084, 0x0200, 0x0040, 0x3b81, 0x6827,
1403 0x0017, 0x1078, 0x3ac2, 0x0078, 0x3b60, 0x7000, 0xa086, 0x0007,
1404 0x00c0, 0x3be3, 0x2d00, 0x70a2, 0xad80, 0x000f, 0x7036, 0x0078,
1405 0x3b98, 0x7040, 0xa086, 0x0001, 0x0040, 0x2471, 0x0078, 0x2438,
1406 0x2031, 0x0000, 0x691c, 0xa184, 0x0002, 0x0040, 0x3ba1, 0xa6b5,
1407 0x0004, 0xa184, 0x00c0, 0x8003, 0x8003, 0x8007, 0xa080, 0x3c72,
1408 0x2004, 0xa635, 0x6820, 0xa084, 0x0400, 0x0040, 0x3bb9, 0x789b,
1409 0x0018, 0x78ab, 0x0003, 0x789b, 0x0081, 0x78ab, 0x0001, 0xa6b5,
1410 0x1000, 0x6820, 0xa084, 0x8000, 0x0040, 0x3bc5, 0xa6b5, 0x0400,
1411 0x789b, 0x000e, 0x6824, 0x8007, 0x78aa, 0xa684, 0x0200, 0x0040,
1412 0x3bdf, 0x682c, 0x78d2, 0x6830, 0x78d6, 0xa684, 0x0100, 0x0040,
1413 0x3bdd, 0x682c, 0xa084, 0x0001, 0x0040, 0x3bdd, 0x7888, 0xa084,
1414 0x0040, 0x0040, 0x3bdd, 0xa6b5, 0x8000, 0x1078, 0x45ad, 0x7e5a,
1415 0x6eb6, 0x0078, 0x45e4, 0x1078, 0x38c6, 0x00c0, 0x3c6c, 0x702c,
1416 0x8004, 0x0048, 0x3bf1, 0x2019, 0x4cfd, 0x1078, 0x2255, 0x702f,
1417 0x0001, 0x2011, 0x0001, 0x2031, 0x1000, 0x789b, 0x0018, 0x6814,
1418 0xa084, 0x001f, 0xa085, 0x0080, 0x78aa, 0x691c, 0xa184, 0x0002,
1419 0x0040, 0x3c0a, 0xa6b5, 0x0004, 0x78ab, 0x0020, 0x6828, 0x78aa,
1420 0xa290, 0x0002, 0x6820, 0xa084, 0x8000, 0x0040, 0x3c18, 0xa6b5,
1421 0x0400, 0x789b, 0x000e, 0x6824, 0x8007, 0x78aa, 0x0078, 0x3c26,
1422 0x681c, 0xa084, 0x8000, 0x00c0, 0x3c26, 0xa6b5, 0x0800, 0x6820,
1423 0xa084, 0x0100, 0x0040, 0x3c26, 0xa6b5, 0x4000, 0x681c, 0xa084,
1424 0x00c0, 0x8003, 0x8003, 0x8007, 0xa080, 0x3c72, 0x2004, 0xa635,
1425 0xa684, 0x0100, 0x0040, 0x3c40, 0x682c, 0xa084, 0x0001, 0x0040,
1426 0x3c40, 0x7888, 0xa084, 0x0040, 0x0040, 0x3c40, 0xa6b5, 0x8000,
1427 0x789b, 0x007e, 0x7eae, 0x6eb6, 0x6814, 0x8007, 0x78aa, 0x7882,
1428 0x7aaa, 0x7830, 0xa084, 0x00c0, 0x00c0, 0x3c6c, 0x0018, 0x3c6c,
1429 0x70b4, 0xa080, 0x00dd, 0x781a, 0x1078, 0x38de, 0xa684, 0x0200,
1430 0x0040, 0x3c60, 0x682c, 0x78d2, 0x6830, 0x78d6, 0x1078, 0x45ad,
1431 0x2d00, 0x70a2, 0x704a, 0x6810, 0x70be, 0x7003, 0x0007, 0xad80,
1432 0x000f, 0x7036, 0x0078, 0x2438, 0x1078, 0x1b45, 0x1078, 0x38de,
1433 0x0078, 0x2438, 0x0000, 0x0300, 0x0200, 0x0000, 0x1078, 0x23ca,
1434 0x2300, 0x0079, 0x3c7b, 0x3c7e, 0x3c7e, 0x3c80, 0x1078, 0x23ca,
1435 0x1078, 0x45bc, 0x6924, 0xa184, 0x00ff, 0xa086, 0x000a, 0x0040,
1436 0x3c92, 0xa184, 0xff00, 0xa085, 0x000a, 0x6826, 0x1078, 0x1b45,
1437 0x0078, 0x3b60, 0x2001, 0x000a, 0x1078, 0x454c, 0x0078, 0x3b60,
1438 0xa282, 0x0005, 0x0050, 0x3c9e, 0x1078, 0x23ca, 0x7000, 0xa084,
1439 0x0007, 0x10c0, 0x398a, 0x1078, 0x191a, 0x00c0, 0x3cbd, 0xa684,
1440 0x0004, 0x0040, 0x3caf, 0x2001, 0x2800, 0x0078, 0x3cb1, 0x2001,
1441 0x0800, 0x71b4, 0xa188, 0x0091, 0x789b, 0x000e, 0x78aa, 0x2031,
1442 0x0400, 0x7e5a, 0x791a, 0x0078, 0x2438, 0x6807, 0x0106, 0x680b,
1443 0x0000, 0x689f, 0x0000, 0x6827, 0x0000, 0xa386, 0x0002, 0x00c0,
1444 0x3cde, 0xa286, 0x0002, 0x00c0, 0x3cde, 0x78a0, 0xa005, 0x00c0,
1445 0x3cde, 0xa484, 0x8000, 0x00c0, 0x3cde, 0x78e4, 0xa084, 0x0008,
1446 0x0040, 0x3cde, 0xa6b5, 0x0008, 0x2019, 0x0000, 0x1078, 0x40d3,
1447 0x2d00, 0x70a2, 0x704a, 0x7003, 0x0007, 0x7037, 0x0000, 0x6824,
1448 0xa084, 0x0080, 0x0040, 0x3cf0, 0x1078, 0x4180, 0x0078, 0x2438,
1449 0x2300, 0x0079, 0x3cf3, 0x3cf6, 0x3d77, 0x3d96, 0x2200, 0x0079,
1450 0x3cf9, 0x3cfe, 0x3d0e, 0x3d34, 0x3d40, 0x3d63, 0x2029, 0x0001,
1451 0xa026, 0x2011, 0x0000, 0x1078, 0x428d, 0x0079, 0x3d07, 0x3d0c,
1452 0x2438, 0x3b60, 0x3d0c, 0x3d0c, 0x1078, 0x23ca, 0x7990, 0xa18c,
1453 0x0007, 0x00c0, 0x3d15, 0x2009, 0x0008, 0x2011, 0x0001, 0xa684,
1454 0x0004, 0x0040, 0x3d1d, 0x2011, 0x0003, 0x2220, 0xa12a, 0x2011,
1455 0x0001, 0x1078, 0x428d, 0x0079, 0x3d25, 0x3d2a, 0x2438, 0x3b60,
1456 0x3d32, 0x3d2c, 0x0078, 0x45ea, 0x70ab, 0x3d30, 0x0078, 0x2438,
1457 0x0078, 0x3d2a, 0x1078, 0x23ca, 0xa684, 0x0010, 0x0040, 0x3d3e,
1458 0x1078, 0x414f, 0x0040, 0x3d3e, 0x0078, 0x2438, 0x0078, 0x41bc,
1459 0x6000, 0xa084, 0x0002, 0x0040, 0x3d5d, 0x70b4, 0xa080, 0x00cd,
1460 0x781a, 0x0d7e, 0x1078, 0x45c5, 0x2d00, 0x682e, 0x6827, 0x0000,
1461 0x1078, 0x3ac2, 0x0d7f, 0x1078, 0x193d, 0x7003, 0x0000, 0x7037,
1462 0x0000, 0x704b, 0x0000, 0x0078, 0x3b60, 0xa684, 0x0004, 0x00c0,
1463 0x3d63, 0x0078, 0x45ea, 0x6000, 0xa084, 0x0004, 0x00c0, 0x3d75,
1464 0x6000, 0xa084, 0x0001, 0x0040, 0x3d75, 0x70ab, 0x3d75, 0x2001,
1465 0x0007, 0x1078, 0x4544, 0x0078, 0x45f0, 0x0078, 0x45ea, 0x2200,
1466 0x0079, 0x3d7a, 0x3d7f, 0x3d7f, 0x3d7f, 0x3d81, 0x3d7f, 0x1078,
1467 0x23ca, 0x70a7, 0x3d85, 0x0078, 0x45f6, 0x2011, 0x0018, 0x1078,
1468 0x4287, 0x0079, 0x3d8b, 0x3d90, 0x2438, 0x3b60, 0x3d92, 0x3d94,
1469 0x1078, 0x23ca, 0x1078, 0x23ca, 0x1078, 0x23ca, 0x2200, 0x0079,
1470 0x3d99, 0x3d9e, 0x3da0, 0x3da0, 0x3d9e, 0x3d9e, 0x1078, 0x23ca,
1471 0x78e4, 0xa084, 0x0008, 0x0040, 0x3db5, 0x70a7, 0x3da9, 0x0078,
1472 0x45f6, 0x2011, 0x0004, 0x1078, 0x4287, 0x0079, 0x3daf, 0x3db5,
1473 0x2438, 0x3b60, 0x3db5, 0x3dbf, 0x3dc3, 0x70ab, 0x3dbd, 0x2001,
1474 0x0003, 0x1078, 0x4544, 0x0078, 0x45f0, 0x0078, 0x45ea, 0x70ab,
1475 0x3db5, 0x0078, 0x2438, 0x70ab, 0x3dc7, 0x0078, 0x2438, 0x0078,
1476 0x3dbd, 0xa282, 0x0003, 0x0050, 0x3dcf, 0x1078, 0x23ca, 0xa386,
1477 0x0002, 0x00c0, 0x3de8, 0xa286, 0x0002, 0x00c0, 0x3dee, 0x78a0,
1478 0xa005, 0x00c0, 0x3dee, 0xa484, 0x8000, 0x00c0, 0x3dee, 0x78e4,
1479 0xa084, 0x0008, 0x0040, 0x3de8, 0xa6b5, 0x0008, 0x2019, 0x0000,
1480 0xa684, 0x0008, 0x0040, 0x3dee, 0x1078, 0x412c, 0x6810, 0x70be,
1481 0x7003, 0x0007, 0x2300, 0x0079, 0x3df5, 0x3df8, 0x3e25, 0x3e2d,
1482 0x2200, 0x0079, 0x3dfb, 0x3e00, 0x3dfe, 0x3e19, 0x1078, 0x23ca,
1483 0x7990, 0xa1ac, 0x0007, 0xa026, 0x2011, 0x0001, 0x1078, 0x428d,
1484 0x0079, 0x3e0a, 0x3e0f, 0x2438, 0x3b60, 0x3e17, 0x3e11, 0x0078,
1485 0x45ea, 0x70ab, 0x3e15, 0x0078, 0x2438, 0x0078, 0x3e0f, 0x1078,
1486 0x23ca, 0xa684, 0x0010, 0x0040, 0x3e23, 0x1078, 0x414f, 0x0040,
1487 0x3e23, 0x0078, 0x2438, 0x0078, 0x41bc, 0x2200, 0x0079, 0x3e28,
1488 0x3e2b, 0x3e2b, 0x3e2b, 0x1078, 0x23ca, 0x2200, 0x0079, 0x3e30,
1489 0x3e33, 0x3e35, 0x3e35, 0x1078, 0x23ca, 0x78e4, 0xa084, 0x0008,
1490 0x0040, 0x3e4a, 0x70a7, 0x3e3e, 0x0078, 0x45f6, 0x2011, 0x0004,
1491 0x1078, 0x4287, 0x0079, 0x3e44, 0x3e4a, 0x2438, 0x3b60, 0x3e4a,
1492 0x3e54, 0x3e58, 0x70ab, 0x3e52, 0x2001, 0x0003, 0x1078, 0x4544,
1493 0x0078, 0x45f0, 0x0078, 0x45ea, 0x70ab, 0x3e4a, 0x0078, 0x2438,
1494 0x70ab, 0x3e5c, 0x0078, 0x2438, 0x0078, 0x3e52, 0x2300, 0x0079,
1495 0x3e61, 0x3e66, 0x3e68, 0x3e64, 0x1078, 0x23ca, 0x70a4, 0x007a,
1496 0x70a4, 0x007a, 0xa282, 0x0002, 0x0050, 0x3e70, 0x1078, 0x23ca,
1497 0xa684, 0x0200, 0x0040, 0x3e7a, 0x1078, 0x45b5, 0x1078, 0x426f,
1498 0x1078, 0x45bc, 0x2300, 0x0079, 0x3e7d, 0x3e80, 0x3ea4, 0x3f0a,
1499 0xa286, 0x0001, 0x0040, 0x3e86, 0x1078, 0x23ca, 0xa684, 0x0200,
1500 0x0040, 0x3e8e, 0x1078, 0x45b5, 0x1078, 0x45bc, 0x2001, 0x0001,
1501 0x1078, 0x454c, 0x78b8, 0xa084, 0xc001, 0x0040, 0x3ea0, 0x7848,
1502 0xa085, 0x0008, 0x784a, 0x7848, 0xa084, 0x0008, 0x00c0, 0x3e9b,
1503 0x7003, 0x0000, 0x0078, 0x3b60, 0x2200, 0x0079, 0x3ea7, 0x3ea9,
1504 0x3eda, 0x70a7, 0x3ead, 0x0078, 0x45f6, 0x2011, 0x000d, 0x1078,
1505 0x4287, 0x0079, 0x3eb3, 0x3eba, 0x2438, 0x3b60, 0x3ec2, 0x3eca,
1506 0x3ed0, 0x3ed2, 0xa6b4, 0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a,
1507 0x0078, 0x45e4, 0xa6b4, 0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a,
1508 0x0078, 0x45e4, 0x70ab, 0x3ece, 0x0078, 0x2438, 0x0078, 0x3eba,
1509 0x1078, 0x23ca, 0x70ab, 0x3ed6, 0x0078, 0x2438, 0x1078, 0x45fc,
1510 0x0078, 0x2438, 0x70a7, 0x3ede, 0x0078, 0x45f6, 0x2011, 0x0012,
1511 0x1078, 0x4287, 0x0079, 0x3ee4, 0x3eea, 0x2438, 0x3b60, 0x3ef6,
1512 0x3efe, 0x3f04, 0xa6b4, 0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a,
1513 0x70b4, 0xa080, 0x00a5, 0x781a, 0x0078, 0x2438, 0xa6b4, 0x00ff,
1514 0xa6b5, 0x0400, 0x6eb6, 0x7e5a, 0x0078, 0x45e4, 0x70ab, 0x3f02,
1515 0x0078, 0x2438, 0x0078, 0x3eea, 0x70ab, 0x3f08, 0x0078, 0x2438,
1516 0x0078, 0x3ef6, 0xa286, 0x0001, 0x0040, 0x3f10, 0x1078, 0x23ca,
1517 0x70a7, 0x3f14, 0x0078, 0x45f6, 0x2011, 0x0015, 0x1078, 0x4287,
1518 0x0079, 0x3f1a, 0x3f1f, 0x2438, 0x3b60, 0x3f2d, 0x3f39, 0xa6b4,
1519 0x00ff, 0xa6b5, 0x0400, 0x6eb6, 0x7e5a, 0x783b, 0x1301, 0x70b4,
1520 0xa080, 0x00b5, 0x781a, 0x0078, 0x2438, 0xa6b4, 0x00ff, 0xa6b5,
1521 0x0400, 0x6eb6, 0x7e5a, 0x70b4, 0xa080, 0x00a5, 0x781a, 0x0078,
1522 0x2438, 0x70ab, 0x3f3d, 0x0078, 0x2438, 0x0078, 0x3f1f, 0xa282,
1523 0x0003, 0x0050, 0x3f45, 0x1078, 0x23ca, 0x2300, 0x0079, 0x3f48,
1524 0x3f4b, 0x3f82, 0x3fdd, 0xa286, 0x0001, 0x0040, 0x3f51, 0x1078,
1525 0x23ca, 0x6804, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0, 0x3f5e,
1526 0x1078, 0x3ac2, 0x7003, 0x0000, 0x0078, 0x3b60, 0x683b, 0x0000,
1527 0x6837, 0x0000, 0xa684, 0x0200, 0x0040, 0x3f6c, 0x1078, 0x45b5,
1528 0x1078, 0x426f, 0x1078, 0x45bc, 0x2001, 0x0001, 0x1078, 0x454c,
1529 0x78b8, 0xa084, 0xc001, 0x0040, 0x3f7e, 0x7848, 0xa085, 0x0008,
1530 0x784a, 0x7848, 0xa084, 0x0008, 0x00c0, 0x3f79, 0x7003, 0x0000,
1531 0x0078, 0x3b60, 0x2200, 0x0079, 0x3f85, 0x3f87, 0x3fb8, 0x70a7,
1532 0x3f8b, 0x0078, 0x45f6, 0x2011, 0x000d, 0x1078, 0x4287, 0x0079,
1533 0x3f91, 0x3f98, 0x2438, 0x3b60, 0x3fa0, 0x3fa8, 0x3fae, 0x3fb0,
1534 0xa6b4, 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x45e4,
1535 0xa6b4, 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x45e4,
1536 0x70ab, 0x3fac, 0x0078, 0x2438, 0x0078, 0x3f98, 0x1078, 0x23ca,
1537 0x70ab, 0x3fb4, 0x0078, 0x2438, 0x1078, 0x45fc, 0x0078, 0x2438,
1538 0x70a7, 0x3fbc, 0x0078, 0x45f6, 0x2011, 0x0005, 0x1078, 0x4287,
1539 0x0079, 0x3fc2, 0x3fc7, 0x2438, 0x3b60, 0x3fcf, 0x3fd7, 0xa6b4,
1540 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x45e4, 0xa6b4,
1541 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x45e4, 0x70ab,
1542 0x3fdb, 0x0078, 0x2438, 0x0078, 0x3fc7, 0xa286, 0x0001, 0x0040,
1543 0x3fe3, 0x1078, 0x23ca, 0x70a7, 0x3fe7, 0x0078, 0x45f6, 0x2011,
1544 0x0006, 0x1078, 0x4287, 0x0079, 0x3fed, 0x3ff2, 0x2438, 0x3b60,
1545 0x3ff8, 0x4002, 0xa6b5, 0x0800, 0x6eb6, 0x7e5a, 0x0078, 0x45e4,
1546 0xa6b4, 0x00ff, 0xa6b5, 0x0800, 0x6eb6, 0xa6b5, 0x4000, 0x7e5a,
1547 0x0078, 0x45e4, 0x70ab, 0x4006, 0x0078, 0x2438, 0x0078, 0x3ff2,
1548 0x2300, 0x0079, 0x400b, 0x4010, 0x400e, 0x400e, 0x1078, 0x23ca,
1549 0x1078, 0x23ca, 0x2300, 0x71a8, 0xa005, 0x017a, 0x6810, 0x70be,
1550 0xa282, 0x0003, 0x0050, 0x401e, 0x1078, 0x23ca, 0x2300, 0x0079,
1551 0x4021, 0x4024, 0x4037, 0x4059, 0x82ff, 0x00c0, 0x4029, 0x1078,
1552 0x23ca, 0xa684, 0x0200, 0x0040, 0x4031, 0x1078, 0x45b5, 0x1078,
1553 0x45bc, 0x2001, 0x0001, 0x1078, 0x454c, 0x0078, 0x2438, 0xa296,
1554 0x0002, 0x0040, 0x4040, 0x82ff, 0x0040, 0x4040, 0x1078, 0x23ca,
1555 0x70a7, 0x4044, 0x0078, 0x45f6, 0x2011, 0x0018, 0x1078, 0x4287,
1556 0x0079, 0x404a, 0x404f, 0x2438, 0x3b60, 0x4051, 0x4053, 0x0078,
1557 0x45e4, 0x0078, 0x45e4, 0x70ab, 0x4057, 0x0078, 0x2438, 0x0078,
1558 0x404f, 0x2200, 0x0079, 0x405c, 0x405e, 0x4077, 0x70a7, 0x4062,
1559 0x0078, 0x45f6, 0x2011, 0x0017, 0x1078, 0x4287, 0x0079, 0x4068,
1560 0x406d, 0x2438, 0x3b60, 0x406f, 0x4071, 0x0078, 0x45e4, 0x0078,
1561 0x45e4, 0x70ab, 0x4075, 0x0078, 0x2438, 0x0078, 0x406d, 0xa484,
1562 0x8000, 0x00c0, 0x40c1, 0xa684, 0x0100, 0x0040, 0x408b, 0x1078,
1563 0x45b5, 0x1078, 0x426f, 0x1078, 0x45bc, 0x7848, 0xa085, 0x000c,
1564 0x784a, 0x0078, 0x408f, 0x78d8, 0x78d2, 0x78dc, 0x78d6, 0xa6b4,
1565 0xefff, 0x7e5a, 0x70a7, 0x4096, 0x0078, 0x45f6, 0x2011, 0x000d,
1566 0x1078, 0x4287, 0x0079, 0x409c, 0x40a3, 0x2438, 0x3b60, 0x40a3,
1567 0x40b1, 0x40b7, 0x40b9, 0xa684, 0x0100, 0x0040, 0x40af, 0x1078,
1568 0x4573, 0x682c, 0x78d2, 0x6830, 0x78d6, 0x1078, 0x45ad, 0x0078,
1569 0x45e4, 0x70ab, 0x40b5, 0x0078, 0x2438, 0x0078, 0x40a3, 0x1078,
1570 0x23ca, 0x70ab, 0x40bd, 0x0078, 0x2438, 0x1078, 0x45fc, 0x0078,
1571 0x2438, 0x1078, 0x45bc, 0x70ab, 0x40cb, 0x2001, 0x0003, 0x1078,
1572 0x4544, 0x0078, 0x45f0, 0x1078, 0x45ad, 0x682c, 0x78d2, 0x6830,
1573 0x78d6, 0x0078, 0x45e4, 0x70b8, 0x6812, 0x70be, 0x8000, 0x70ba,
1574 0x681b, 0x0000, 0xa684, 0x0008, 0x0040, 0x40f6, 0x157e, 0x137e,
1575 0x147e, 0x7890, 0x8004, 0x8004, 0x8004, 0x8004, 0xa084, 0x000f,
1576 0x681a, 0x80ac, 0x789b, 0x0000, 0xaf80, 0x002b, 0x2098, 0xad80,
1577 0x000b, 0x20a0, 0x53a5, 0x147f, 0x137f, 0x157f, 0xa6c4, 0x0f00,
1578 0xa684, 0x0002, 0x00c0, 0x4102, 0x692c, 0x810d, 0x810d, 0x810d,
1579 0x0078, 0x410f, 0x789b, 0x0010, 0x79ac, 0x0078, 0x410f, 0x017e,
1580 0x2009, 0x0005, 0x2001, 0x3d00, 0x1078, 0x457e, 0x017f, 0xa184,
1581 0x001f, 0xa805, 0x6816, 0x1078, 0x3b33, 0x68be, 0xa684, 0x0004,
1582 0x0040, 0x4120, 0xa18c, 0xff00, 0x78a8, 0xa084, 0x00ff, 0xa105,
1583 0x682a, 0xa6b4, 0x00ff, 0x6000, 0xa084, 0x0008, 0x0040, 0x412a,
1584 0xa6b5, 0x4000, 0x6eb6, 0x007c, 0x157e, 0x137e, 0x147e, 0x6918,
1585 0x7890, 0x8004, 0x8004, 0x8004, 0x8004, 0xa084, 0x000f, 0x007e,
1586 0xa100, 0x681a, 0x007f, 0x8000, 0x8004, 0x0040, 0x414b, 0x20a8,
1587 0x8104, 0xa080, 0x000b, 0xad00, 0x20a0, 0x789b, 0x0000, 0xaf80,
1588 0x002b, 0x2098, 0x53a5, 0x147f, 0x137f, 0x157f, 0x007c, 0x682c,
1589 0xa084, 0x0020, 0x00c0, 0x4157, 0x620c, 0x0078, 0x4158, 0x6210,
1590 0x6b18, 0x2300, 0xa202, 0x0040, 0x4178, 0x2018, 0xa382, 0x000e,
1591 0x0048, 0x4168, 0x0040, 0x4168, 0x2019, 0x000e, 0x0078, 0x416c,
1592 0x7858, 0xa084, 0xffef, 0x785a, 0x783b, 0x1b01, 0x7893, 0x0000,
1593 0x7ba2, 0x70b4, 0xa080, 0x008e, 0x781a, 0xa085, 0x0001, 0x007c,
1594 0x7858, 0xa084, 0xffef, 0x785a, 0x7893, 0x0000, 0xa006, 0x007c,
1595 0x6904, 0xa18c, 0x00ff, 0xa196, 0x0007, 0x0040, 0x418d, 0xa196,
1596 0x000f, 0x0040, 0x418d, 0x6807, 0x0117, 0x6914, 0x1078, 0x3b33,
1597 0x6100, 0x8104, 0x00c8, 0x41a8, 0x601c, 0xa005, 0x0040, 0x419c,
1598 0x2001, 0x0800, 0x0078, 0x41aa, 0x0d7e, 0x6824, 0x007e, 0x1078,
1599 0x45c5, 0x007f, 0x6826, 0x2d00, 0x682e, 0x1078, 0x3ac2, 0x0d7f,
1600 0x2001, 0x0200, 0x6826, 0x8007, 0x789b, 0x000e, 0x78aa, 0x6820,
1601 0xa085, 0x8000, 0x6822, 0x2031, 0x0400, 0x6eb6, 0x7e5a, 0x71b4,
1602 0xa188, 0x0091, 0x791a, 0x007c, 0xa6c4, 0x0f00, 0xa684, 0x0002,
1603 0x00c0, 0x41cf, 0x692c, 0x810d, 0x810d, 0x810d, 0xa184, 0x001f,
1604 0xa805, 0x6816, 0x1078, 0x3b33, 0x68be, 0x0078, 0x41d2, 0x6914,
1605 0x1078, 0x3b33, 0x6100, 0x8104, 0x00c8, 0x421c, 0xa184, 0x0300,
1606 0x0040, 0x41de, 0x6807, 0x0117, 0x0078, 0x41fc, 0x6004, 0xa005,
1607 0x00c0, 0x4205, 0x6807, 0x0117, 0x601c, 0xa005, 0x00c0, 0x41f2,
1608 0x0d7e, 0x1078, 0x45c5, 0x6827, 0x0034, 0x2d00, 0x682e, 0x1078,
1609 0x3ac2, 0x0d7f, 0xa684, 0x0004, 0x0040, 0x41fc, 0x2031, 0x0400,
1610 0x2001, 0x2800, 0x0078, 0x4200, 0x2031, 0x0400, 0x2001, 0x0800,
1611 0x71b4, 0xa188, 0x0091, 0x0078, 0x424a, 0x6018, 0xa005, 0x00c0,
1612 0x41f2, 0x601c, 0xa005, 0x00c0, 0x41f2, 0x689f, 0x0000, 0x6827,
1613 0x003d, 0xa684, 0x0001, 0x0040, 0x4258, 0xa6b5, 0x0800, 0x71b4,
1614 0xa188, 0x00ae, 0x0078, 0x4253, 0x6807, 0x0117, 0x2031, 0x0400,
1615 0x692c, 0xa18c, 0x00ff, 0xa186, 0x0012, 0x00c0, 0x422d, 0x2001,
1616 0x4265, 0x2009, 0x0001, 0x0078, 0x423e, 0xa186, 0x0003, 0x00c0,
1617 0x4237, 0x2001, 0x4266, 0x2009, 0x0012, 0x0078, 0x423e, 0x2001,
1618 0x0200, 0x71b4, 0xa188, 0x0091, 0x0078, 0x424a, 0x1078, 0x4598,
1619 0x78a3, 0x0000, 0x681c, 0xa085, 0x0040, 0x681e, 0x71b4, 0xa188,
1620 0x00da, 0xa006, 0x6826, 0x8007, 0x789b, 0x000e, 0x78aa, 0x6820,
1621 0xa085, 0x8000, 0x6822, 0x6eb6, 0x7e5a, 0x791a, 0x0078, 0x2438,
1622 0x6eb6, 0x1078, 0x3ac2, 0x6810, 0x70be, 0x7003, 0x0007, 0x70a3,
1623 0x0000, 0x704b, 0x0000, 0x0078, 0x2438, 0x0023, 0x0070, 0x0005,
1624 0x0000, 0x0a00, 0x0000, 0x0000, 0x0025, 0x0000, 0x0000, 0x683b,
1625 0x0000, 0x6837, 0x0000, 0xa684, 0x0200, 0x0040, 0x4286, 0x78b8,
1626 0xa08c, 0x001f, 0xa084, 0x8000, 0x0040, 0x427f, 0x8108, 0x78d8,
1627 0xa100, 0x6836, 0x78dc, 0xa081, 0x0000, 0x683a, 0x007c, 0x7990,
1628 0x810f, 0xa5ac, 0x0007, 0x2021, 0x0000, 0xa480, 0x0010, 0x789a,
1629 0x79a8, 0xa18c, 0x00ff, 0xa184, 0x0080, 0x00c0, 0x42b5, 0xa182,
1630 0x0020, 0x00c8, 0x42cf, 0xa182, 0x0012, 0x00c8, 0x4536, 0x2100,
1631 0x1079, 0x42a3, 0x007c, 0x4536, 0x447e, 0x4536, 0x4536, 0x42dc,
1632 0x42df, 0x4319, 0x434f, 0x4381, 0x4384, 0x4536, 0x4536, 0x433a,
1633 0x43a8, 0x43e2, 0x4536, 0x4536, 0x4409, 0xa18c, 0x001f, 0x6814,
1634 0xa084, 0x001f, 0xa106, 0x0040, 0x42cc, 0x70b4, 0xa080, 0x00cd,
1635 0x781a, 0x2001, 0x0014, 0x1078, 0x454c, 0x1078, 0x45bc, 0x7003,
1636 0x0000, 0x2001, 0x0002, 0x007c, 0x2001, 0x0000, 0x007c, 0xa182,
1637 0x0024, 0x00c8, 0x4536, 0xa184, 0x0003, 0x1079, 0x42a3, 0x007c,
1638 0x4536, 0x4536, 0x4536, 0x4536, 0x1078, 0x4536, 0x007c, 0x2200,
1639 0x0079, 0x42e2, 0x440c, 0x440c, 0x4306, 0x4306, 0x4306, 0x4306,
1640 0x4306, 0x4306, 0x4306, 0x4306, 0x4304, 0x4306, 0x42fb, 0x4306,
1641 0x4306, 0x4306, 0x4306, 0x4306, 0x430e, 0x4311, 0x440c, 0x4311,
1642 0x4306, 0x4306, 0x4306, 0x0c7e, 0x077e, 0x6f14, 0x1078, 0x36b0,
1643 0x077f, 0x0c7f, 0x0078, 0x4306, 0x1078, 0x44d1, 0x6827, 0x02b3,
1644 0x2009, 0x000b, 0x2001, 0x4800, 0x0078, 0x4440, 0x1078, 0x452b,
1645 0x007c, 0x6827, 0x0093, 0x2009, 0x000b, 0x2001, 0x4800, 0x0078,
1646 0x4428, 0x2d58, 0x6804, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0,
1647 0x4323, 0x6807, 0x0117, 0x6827, 0x0002, 0x1078, 0x45c5, 0x6827,
1648 0x0036, 0x6932, 0x2d00, 0x682e, 0x0d7e, 0x1078, 0x3a92, 0x1078,
1649 0x4466, 0x2b68, 0x1078, 0x3ac2, 0x0d7f, 0x1078, 0x3ac2, 0x2001,
1650 0x0002, 0x007c, 0x1078, 0x4466, 0x2001, 0x0017, 0x1078, 0x454c,
1651 0x70a3, 0x0000, 0x2009, 0x5038, 0x200b, 0x0006, 0x70af, 0x0017,
1652 0x2009, 0x0200, 0x1078, 0x39d2, 0x2001, 0x0001, 0x007c, 0x2200,
1653 0x0079, 0x4352, 0x440c, 0x443d, 0x443d, 0x443d, 0x4373, 0x444d,
1654 0x4379, 0x444d, 0x444d, 0x4450, 0x4450, 0x4455, 0x4455, 0x436b,
1655 0x436b, 0x443d, 0x443d, 0x444d, 0x443d, 0x4379, 0x440c, 0x4379,
1656 0x4379, 0x4379, 0x4379, 0x6827, 0x0084, 0x2009, 0x000b, 0x2001,
1657 0x4300, 0x0078, 0x445f, 0x2009, 0x000b, 0x2001, 0x4300, 0x0078,
1658 0x4440, 0x6827, 0x0093, 0x2009, 0x000b, 0x2001, 0x4300, 0x0078,
1659 0x4428, 0x2001, 0x0000, 0x007c, 0x2200, 0x0079, 0x4387, 0x440c,
1660 0x43a0, 0x43a0, 0x43a0, 0x43a0, 0x444d, 0x444d, 0x444d, 0x444d,
1661 0x444d, 0x444d, 0x444d, 0x444d, 0x43a0, 0x43a0, 0x43a0, 0x43a0,
1662 0x444d, 0x43a0, 0x43a0, 0x444d, 0x444d, 0x444d, 0x444d, 0x440c,
1663 0x6827, 0x0093, 0x2009, 0x000b, 0x2001, 0x4300, 0x0078, 0x4428,
1664 0xa684, 0x0004, 0x00c0, 0x43bc, 0x6804, 0xa084, 0x00ff, 0xa086,
1665 0x0006, 0x00c0, 0x4536, 0x1078, 0x4466, 0x6807, 0x0117, 0x1078,
1666 0x3ac2, 0x2001, 0x0002, 0x007c, 0x6000, 0xa084, 0x0004, 0x0040,
1667 0x4536, 0x2d58, 0x6804, 0xa084, 0x00ff, 0xa086, 0x0006, 0x00c0,
1668 0x43cb, 0x6807, 0x0117, 0x6827, 0x0002, 0x1078, 0x45c5, 0x6827,
1669 0x0036, 0x6932, 0x2d00, 0x682e, 0x0d7e, 0x1078, 0x3aa1, 0x1078,
1670 0x4466, 0x2b68, 0x1078, 0x3ac2, 0x0d7f, 0x1078, 0x3ac2, 0x2001,
1671 0x0002, 0x007c, 0x6000, 0xa084, 0x0004, 0x0040, 0x4536, 0x2d58,
1672 0x6a04, 0xa294, 0x00ff, 0xa286, 0x0006, 0x00c0, 0x43f1, 0x6807,
1673 0x0117, 0x6827, 0x0002, 0x2d58, 0x1078, 0x45c5, 0x6827, 0x0036,
1674 0x6932, 0x2d00, 0x682e, 0x0d7e, 0x1078, 0x3ab1, 0x1078, 0x4466,
1675 0x2b68, 0x1078, 0x3ac2, 0x0d7f, 0x1078, 0x3ac2, 0x2001, 0x0002,
1676 0x007c, 0x1078, 0x4536, 0x007c, 0x70b4, 0xa080, 0x00cd, 0x781a,
1677 0x2001, 0x0001, 0x1078, 0x454c, 0x1078, 0x45bc, 0x7003, 0x0000,
1678 0x2001, 0x0002, 0x007c, 0x1078, 0x457e, 0x1078, 0x45b5, 0x1078,
1679 0x426f, 0x1078, 0x4180, 0x1078, 0x45bc, 0x2001, 0x0001, 0x007c,
1680 0x1078, 0x457e, 0x1078, 0x45b5, 0x1078, 0x426f, 0x70b4, 0xa080,
1681 0x00cd, 0x781a, 0x2001, 0x0013, 0x1078, 0x454c, 0x1078, 0x45bc,
1682 0x7003, 0x0000, 0x2001, 0x0002, 0x007c, 0x1078, 0x4536, 0x007c,
1683 0x1078, 0x457e, 0x1078, 0x45b5, 0x1078, 0x426f, 0x1078, 0x4180,
1684 0x1078, 0x45bc, 0x2001, 0x0001, 0x007c, 0x2001, 0x0003, 0x007c,
1685 0x1078, 0x44d1, 0x2001, 0x0000, 0x007c, 0x0c7e, 0x077e, 0x6f14,
1686 0x1078, 0x36b0, 0x077f, 0x0c7f, 0x2001, 0x0000, 0x007c, 0x1078,
1687 0x457e, 0x1078, 0x4536, 0x2001, 0x0006, 0x007c, 0x6904, 0xa18c,
1688 0x00ff, 0xa186, 0x0007, 0x0040, 0x4471, 0xa186, 0x000f, 0x00c0,
1689 0x4475, 0x1078, 0x45b5, 0x1078, 0x426f, 0x70b4, 0xa080, 0x00cd,
1690 0x781a, 0x1078, 0x45bc, 0x7003, 0x0000, 0x007c, 0x7aa8, 0xa294,
1691 0x00ff, 0x78a8, 0xa084, 0x00ff, 0xa08a, 0x0004, 0x00c8, 0x4536,
1692 0x1079, 0x448b, 0x007c, 0x4536, 0x448f, 0x4536, 0x44df, 0xa282,
1693 0x0003, 0x0040, 0x4496, 0x1078, 0x4536, 0x007c, 0x7da8, 0xa5ac,
1694 0x00ff, 0x7ca8, 0xa4a4, 0x00ff, 0xa482, 0x000c, 0x0048, 0x44a4,
1695 0x0040, 0x44a4, 0x2021, 0x000c, 0x701c, 0xa502, 0x00c8, 0x44a9,
1696 0x751c, 0x1078, 0x451c, 0x852b, 0x852b, 0x1078, 0x372e, 0x0040,
1697 0x44b5, 0x1078, 0x44c3, 0x0078, 0x44b9, 0x1078, 0x4518, 0x1078,
1698 0x44d1, 0xa6b5, 0x1000, 0x7e5a, 0x70b4, 0xa080, 0x00b9, 0x781a,
1699 0x2001, 0x0004, 0x007c, 0x0c7e, 0x6914, 0x810f, 0xa18c, 0x000f,
1700 0x810b, 0x810b, 0x810b, 0xa1e0, 0x5280, 0x1078, 0x3538, 0x0c7f,
1701 0x007c, 0x0c7e, 0x6814, 0x8007, 0xa084, 0x000f, 0x8003, 0x8003,
1702 0x8003, 0xa0e0, 0x5280, 0x1078, 0x355f, 0x0c7f, 0x007c, 0xa282,
1703 0x0002, 0x00c0, 0x4536, 0x7aa8, 0xa294, 0x00ff, 0xa284, 0xfffe,
1704 0x0040, 0x44ec, 0x2011, 0x0001, 0x1078, 0x450a, 0x1078, 0x44fc,
1705 0x1078, 0x44d1, 0xa6b5, 0x1000, 0x7e5a, 0x70b4, 0xa080, 0x00b9,
1706 0x781a, 0x2001, 0x0004, 0x007c, 0x0c7e, 0x6814, 0x8007, 0xa084,
1707 0x000f, 0x8003, 0x8003, 0x8003, 0xa0e0, 0x5280, 0x1078, 0x3604,
1708 0x0c7f, 0x007c, 0x789b, 0x0018, 0x78ab, 0x0001, 0x78ab, 0x0002,
1709 0x78ab, 0x0003, 0x7aaa, 0x789b, 0x0081, 0x78ab, 0x0004, 0x007c,
1710 0x2021, 0x0000, 0x2029, 0x0032, 0x789b, 0x0018, 0x78ab, 0x0001,
1711 0x78ab, 0x0003, 0x78ab, 0x0001, 0x7daa, 0x7caa, 0x789b, 0x0081,
1712 0x78ab, 0x0005, 0x007c, 0x2001, 0x0003, 0x1078, 0x4544, 0x70b4,
1713 0xa080, 0x00b9, 0x781a, 0x2001, 0x0005, 0x007c, 0x2001, 0x0007,
1714 0x1078, 0x4544, 0xa6b5, 0x1000, 0x7e5a, 0x70b4, 0xa080, 0x00b9,
1715 0x781a, 0x2001, 0x0004, 0x007c, 0x789b, 0x0018, 0x78aa, 0x789b,
1716 0x0081, 0x78ab, 0x0001, 0x007c, 0x6904, 0xa18c, 0x00ff, 0xa196,
1717 0x0007, 0x0040, 0x455a, 0xa196, 0x000f, 0x0040, 0x455a, 0x1078,
1718 0x193d, 0x007c, 0x6924, 0xa194, 0x003f, 0x00c0, 0x4563, 0xa18c,
1719 0xffc0, 0xa105, 0x6826, 0x1078, 0x3ac2, 0x691c, 0xa184, 0x0100,
1720 0x0040, 0x4572, 0x1078, 0x1b7e, 0x6914, 0x1078, 0x3b33, 0x6204,
1721 0x8210, 0x6206, 0x007c, 0x692c, 0x6834, 0x682e, 0xa112, 0x6930,
1722 0x6838, 0x6832, 0xa11b, 0xa200, 0xa301, 0x007c, 0x0c7e, 0xade0,
1723 0x0018, 0x6003, 0x0070, 0x6106, 0x600b, 0x0000, 0x600f, 0x0a00,
1724 0x6013, 0x0000, 0x6017, 0x0000, 0x8007, 0x601a, 0x601f, 0x0000,
1725 0x6023, 0x0000, 0x0c7f, 0x6824, 0xa085, 0x0080, 0x6826, 0x007c,
1726 0x157e, 0x137e, 0x147e, 0x2098, 0xaf80, 0x002d, 0x20a0, 0x81ac,
1727 0x0040, 0x45a3, 0x53a6, 0xa184, 0x0001, 0x0040, 0x45a9, 0x3304,
1728 0x78be, 0x147f, 0x137f, 0x157f, 0x007c, 0x70b0, 0xa005, 0x10c0,
1729 0x23ca, 0x70b3, 0x8000, 0x0078, 0x48f7, 0x71b0, 0x81ff, 0x0040,
1730 0x45bb, 0x1078, 0x49ed, 0x007c, 0x71b0, 0x81ff, 0x0040, 0x45c4,
1731 0x70b3, 0x0000, 0x1078, 0x4633, 0x007c, 0x0c7e, 0x0d7e, 0x1078,
1732 0x191a, 0x0c7f, 0x157e, 0x137e, 0x147e, 0x2da0, 0x2c98, 0x20a9,
1733 0x0031, 0x53a3, 0x147f, 0x137f, 0x157f, 0x6807, 0x010d, 0x680b,
1734 0x0000, 0x7004, 0x8007, 0x681a, 0x6823, 0x0000, 0x681f, 0x0000,
1735 0x689f, 0x0000, 0x0c7f, 0x007c, 0x70b4, 0xa080, 0x0091, 0x781a,
1736 0x0078, 0x2438, 0x70b4, 0xa080, 0x0081, 0x781a, 0x0078, 0x2438,
1737 0x70b4, 0xa080, 0x00b9, 0x781a, 0x0078, 0x2438, 0x70b4, 0xa080,
1738 0x00c3, 0x781a, 0x0078, 0x2438, 0x6904, 0xa18c, 0x00ff, 0xa196,
1739 0x0007, 0x0040, 0x4609, 0xa196, 0x000f, 0x0040, 0x4609, 0x6807,
1740 0x0117, 0x2001, 0x0200, 0x6826, 0x8007, 0x789b, 0x000e, 0x78aa,
1741 0x6820, 0xa085, 0x8000, 0x6822, 0x2031, 0x0400, 0x6eb6, 0x7e5a,
1742 0x71b4, 0xa188, 0x0091, 0x791a, 0x007c, 0x1078, 0x45bc, 0x7848,
1743 0xa085, 0x000c, 0x784a, 0x70b4, 0xa080, 0x00cd, 0x781a, 0x2009,
1744 0x000b, 0x2001, 0x4400, 0x1078, 0x457e, 0x2001, 0x0013, 0x1078,
1745 0x454c, 0x0078, 0x3b60, 0x127e, 0x2091, 0x2200, 0x2049, 0x4633,
1746 0x7000, 0x7204, 0xa205, 0x720c, 0xa215, 0x7008, 0xa084, 0xfff7,
1747 0xa205, 0x0040, 0x4645, 0x0078, 0x464a, 0x7003, 0x0000, 0x127f,
1748 0x2000, 0x007c, 0x7000, 0xa084, 0x0001, 0x00c0, 0x4678, 0x7108,
1749 0x8103, 0x00c8, 0x4657, 0x1078, 0x477a, 0x0078, 0x464f, 0x700c,
1750 0xa08c, 0x00ff, 0x0040, 0x4678, 0x7004, 0x8004, 0x00c8, 0x466f,
1751 0x7014, 0xa005, 0x00c0, 0x466b, 0x7010, 0xa005, 0x0040, 0x466f,
1752 0xa102, 0x00c8, 0x464f, 0x7007, 0x0010, 0x0078, 0x4678, 0x8aff,
1753 0x0040, 0x4678, 0x1078, 0x49c4, 0x00c0, 0x4672, 0x0040, 0x464f,
1754 0x1078, 0x4703, 0x7003, 0x0000, 0x127f, 0x2000, 0x007c, 0x017e,
1755 0x6104, 0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x468b, 0xa18e,
1756 0x000f, 0x00c0, 0x468e, 0x6040, 0x0078, 0x468f, 0x6428, 0x017f,
1757 0x84ff, 0x0040, 0x46b9, 0x2c70, 0x7004, 0xa0bc, 0x000f, 0xa7b8,
1758 0x46c9, 0x273c, 0x87fb, 0x00c0, 0x46a7, 0x0048, 0x46a1, 0x1078,
1759 0x23ca, 0x609c, 0xa075, 0x0040, 0x46b9, 0x0078, 0x4694, 0x2704,
1760 0xae68, 0x6808, 0xa630, 0x680c, 0xa529, 0x8421, 0x0040, 0x46b9,
1761 0x8738, 0x2704, 0xa005, 0x00c0, 0x46a8, 0x709c, 0xa075, 0x00c0,
1762 0x4694, 0x007c, 0x0000, 0x0005, 0x0009, 0x000d, 0x0011, 0x0015,
1763 0x0019, 0x001d, 0x0000, 0x0003, 0x0009, 0x000f, 0x0015, 0x001b,
1764 0x0000, 0x0000, 0x46be, 0x46bb, 0x0000, 0x0000, 0x8000, 0x0000,
1765 0x46be, 0x0000, 0x46c6, 0x46c3, 0x0000, 0x0000, 0x0000, 0x0000,
1766 0x46c6, 0x0000, 0x46c1, 0x46c1, 0x0000, 0x0000, 0x8000, 0x0000,
1767 0x46c1, 0x0000, 0x46c7, 0x46c7, 0x0000, 0x0000, 0x0000, 0x0000,
1768 0x46c7, 0x127e, 0x2091, 0x2200, 0x2079, 0x5000, 0x2071, 0x0010,
1769 0x7007, 0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x2071, 0x0020,
1770 0x7007, 0x000a, 0x7007, 0x0002, 0x7003, 0x0000, 0x2049, 0x0000,
1771 0x127f, 0x2000, 0x007c, 0x2049, 0x4703, 0x2019, 0x0000, 0x7004,
1772 0x8004, 0x00c8, 0x4756, 0x7007, 0x0012, 0x7108, 0x7008, 0xa106,
1773 0x00c0, 0x470d, 0xa184, 0x01e0, 0x0040, 0x4718, 0x1078, 0x23ca,
1774 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x00c8, 0x4723, 0xa184,
1775 0x4000, 0x00c0, 0x470d, 0xa19c, 0x300c, 0xa386, 0x2004, 0x0040,
1776 0x4731, 0xa386, 0x0008, 0x0040, 0x473c, 0xa386, 0x200c, 0x00c0,
1777 0x470d, 0x7200, 0x8204, 0x0048, 0x473c, 0x730c, 0xa384, 0x00ff,
1778 0x0040, 0x473c, 0x1078, 0x23ca, 0x7007, 0x0012, 0x7000, 0xa084,
1779 0x0001, 0x00c0, 0x4756, 0x7008, 0xa084, 0x01e0, 0x00c0, 0x4756,
1780 0x7310, 0x7014, 0xa305, 0x0040, 0x4756, 0x710c, 0xa184, 0x0300,
1781 0x00c0, 0x4756, 0xa184, 0x00ff, 0x00c0, 0x4703, 0x7007, 0x0012,
1782 0x7007, 0x0008, 0x7004, 0xa084, 0x0008, 0x00c0, 0x475a, 0x7007,
1783 0x0012, 0x7108, 0x8103, 0x0048, 0x475f, 0x7003, 0x0000, 0x2049,
1784 0x0000, 0x007c, 0x107e, 0x007e, 0x127e, 0x157e, 0x2091, 0x2200,
1785 0x7108, 0x1078, 0x477a, 0x157f, 0x127f, 0x2091, 0x8001, 0x007f,
1786 0x107f, 0x007c, 0x7204, 0x7500, 0x730c, 0xa384, 0x0300, 0x00c0,
1787 0x47a1, 0xa184, 0x01e0, 0x00c0, 0x47c5, 0x7108, 0xa184, 0x01e0,
1788 0x00c0, 0x47c5, 0x2001, 0x04fd, 0x2004, 0xa082, 0x0005, 0x00c8,
1789 0x4795, 0xa184, 0x4000, 0x00c0, 0x4785, 0xa184, 0x0007, 0x0079,
1790 0x4799, 0x47a3, 0x47b5, 0x47a1, 0x47b5, 0x47a1, 0x4801, 0x47a1,
1791 0x47ff, 0x1078, 0x23ca, 0x7004, 0xa084, 0x0010, 0xa085, 0x0002,
1792 0x7006, 0x8aff, 0x00c0, 0x47b0, 0x2049, 0x0000, 0x0078, 0x47b4,
1793 0x1078, 0x49c4, 0x00c0, 0x47b0, 0x007c, 0x7004, 0xa084, 0x0010,
1794 0xa085, 0x0002, 0x7006, 0x8aff, 0x00c0, 0x47c0, 0x0078, 0x47c4,
1795 0x1078, 0x49c4, 0x00c0, 0x47c0, 0x007c, 0x7007, 0x0012, 0x7108,
1796 0x00e0, 0x47c8, 0x2091, 0x6000, 0x00e0, 0x47cc, 0x2091, 0x6000,
1797 0x7007, 0x0012, 0x7007, 0x0008, 0x7004, 0xa084, 0x0008, 0x00c0,
1798 0x47d4, 0x7007, 0x0012, 0x7108, 0x8103, 0x0048, 0x47d9, 0x7003,
1799 0x0000, 0x7000, 0xa005, 0x00c0, 0x47ed, 0x7004, 0xa005, 0x00c0,
1800 0x47ed, 0x700c, 0xa005, 0x0040, 0x47ef, 0x0078, 0x47d0, 0x2049,
1801 0x0000, 0x1078, 0x37d7, 0x6818, 0xa084, 0x8000, 0x0040, 0x47fa,
1802 0x681b, 0x0002, 0x007c, 0x1078, 0x23ca, 0x1078, 0x23ca, 0x1078,
1803 0x485d, 0x7210, 0x7114, 0x700c, 0xa09c, 0x00ff, 0x2800, 0xa300,
1804 0xa211, 0xa189, 0x0000, 0x1078, 0x485d, 0x2704, 0x2c58, 0xac60,
1805 0x6308, 0x2200, 0xa322, 0x630c, 0x2100, 0xa31b, 0x2400, 0xa305,
1806 0x0040, 0x4824, 0x00c8, 0x4824, 0x8412, 0x8210, 0x830a, 0xa189,
1807 0x0000, 0x2b60, 0x0078, 0x480b, 0x2b60, 0x8a07, 0x007e, 0x6004,
1808 0xa084, 0x0008, 0x0040, 0x4830, 0xa7ba, 0x46c3, 0x0078, 0x4832,
1809 0xa7ba, 0x46bb, 0x007f, 0xa73d, 0x2c00, 0x6886, 0x6f8a, 0x6c92,
1810 0x6b8e, 0x7007, 0x0012, 0x1078, 0x4703, 0x007c, 0x8738, 0x2704,
1811 0xa005, 0x00c0, 0x4851, 0x609c, 0xa005, 0x0040, 0x485a, 0x2060,
1812 0x6004, 0xa084, 0x000f, 0xa080, 0x46c9, 0x203c, 0x87fb, 0x1040,
1813 0x23ca, 0x8a51, 0x0040, 0x4859, 0x7008, 0xa084, 0x0003, 0xa086,
1814 0x0003, 0x007c, 0x2051, 0x0000, 0x007c, 0x8a50, 0x8739, 0x2704,
1815 0xa004, 0x00c0, 0x4871, 0x6000, 0xa064, 0x00c0, 0x4868, 0x2d60,
1816 0x6004, 0xa084, 0x000f, 0xa080, 0x46d9, 0x203c, 0x87fb, 0x1040,
1817 0x23ca, 0x007c, 0x127e, 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x6884,
1818 0x2060, 0x6888, 0x6b8c, 0x6c90, 0x8057, 0xaad4, 0x00ff, 0xa084,
1819 0x00ff, 0x007e, 0x6804, 0xa084, 0x0008, 0x007f, 0x0040, 0x488c,
1820 0xa0b8, 0x46c3, 0x0078, 0x488e, 0xa0b8, 0x46bb, 0x7e08, 0xa6b5,
1821 0x000c, 0x6904, 0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x489c,
1822 0xa18e, 0x000f, 0x00c0, 0x48a5, 0x681c, 0xa084, 0x0040, 0x0040,
1823 0x48ac, 0xa6b5, 0x0001, 0x0078, 0x48ac, 0x681c, 0xa084, 0x0040,
1824 0x0040, 0x48ac, 0xa6b5, 0x0001, 0x7007, 0x0004, 0x7004, 0xa084,
1825 0x0004, 0x00c0, 0x48ae, 0x2400, 0xa305, 0x00c0, 0x48b9, 0x0078,
1826 0x48df, 0x2c58, 0x2704, 0x6104, 0xac60, 0x6000, 0xa400, 0x701a,
1827 0x6004, 0xa301, 0x701e, 0xa184, 0x0008, 0x0040, 0x48cf, 0x6010,
1828 0xa081, 0x0000, 0x7022, 0x6014, 0xa081, 0x0000, 0x7026, 0x6208,
1829 0x2400, 0xa202, 0x7012, 0x620c, 0x2300, 0xa203, 0x7016, 0x7602,
1830 0x7007, 0x0001, 0x2b60, 0x1078, 0x483e, 0x0078, 0x48e1, 0x1078,
1831 0x49c4, 0x00c0, 0x48df, 0x127f, 0x2000, 0x007c, 0x127e, 0x0d7e,
1832 0x2091, 0x2200, 0x0d7f, 0x7007, 0x0004, 0x7004, 0xa084, 0x0004,
1833 0x00c0, 0x48ed, 0x7003, 0x0008, 0x127f, 0x2000, 0x007c, 0x127e,
1834 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x2049, 0x48f7, 0x7007, 0x0004,
1835 0x7004, 0xa084, 0x0004, 0x00c0, 0x4900, 0x7e08, 0xa6b5, 0x000c,
1836 0x6904, 0xa18c, 0x00ff, 0xa186, 0x0007, 0x0040, 0x4913, 0xa18e,
1837 0x000f, 0x00c0, 0x491e, 0x681c, 0xa084, 0x0040, 0x0040, 0x491a,
1838 0xa6b5, 0x0001, 0x6840, 0x2050, 0x0078, 0x4927, 0x681c, 0xa084,
1839 0x0020, 0x00c0, 0x4925, 0xa6b5, 0x0001, 0x6828, 0x2050, 0x2d60,
1840 0x6004, 0xa0bc, 0x000f, 0xa7b8, 0x46c9, 0x273c, 0x87fb, 0x00c0,
1841 0x493b, 0x0048, 0x4935, 0x1078, 0x23ca, 0x689c, 0xa065, 0x0040,
1842 0x493f, 0x0078, 0x4928, 0x1078, 0x49c4, 0x00c0, 0x493b, 0x127f,
1843 0x2000, 0x007c, 0x127e, 0x007e, 0x017e, 0x0d7e, 0x2091, 0x2200,
1844 0x0d7f, 0x037f, 0x047f, 0x7e08, 0xa6b5, 0x000c, 0x6904, 0xa18c,
1845 0x00ff, 0xa186, 0x0007, 0x0040, 0x4959, 0xa18e, 0x000f, 0x00c0,
1846 0x4962, 0x681c, 0xa084, 0x0040, 0x0040, 0x4969, 0xa6b5, 0x0001,
1847 0x0078, 0x4969, 0x681c, 0xa084, 0x0040, 0x0040, 0x4969, 0xa6b5,
1848 0x0001, 0x2049, 0x4942, 0x017e, 0x6904, 0xa18c, 0x00ff, 0xa186,
1849 0x0007, 0x0040, 0x4977, 0xa18e, 0x000f, 0x00c0, 0x497a, 0x6840,
1850 0x0078, 0x497b, 0x6828, 0x017f, 0xa055, 0x0040, 0x49c1, 0x2d70,
1851 0x2e60, 0x7004, 0xa0bc, 0x000f, 0xa7b8, 0x46c9, 0x273c, 0x87fb,
1852 0x00c0, 0x4995, 0x0048, 0x498e, 0x1078, 0x23ca, 0x709c, 0xa075,
1853 0x2060, 0x0040, 0x49c1, 0x0078, 0x4981, 0x2704, 0xae68, 0x6808,
1854 0xa422, 0x680c, 0xa31b, 0x0048, 0x49ae, 0x8a51, 0x00c0, 0x49a2,
1855 0x1078, 0x23ca, 0x8738, 0x2704, 0xa005, 0x00c0, 0x4996, 0x709c,
1856 0xa075, 0x2060, 0x0040, 0x49c1, 0x0078, 0x4981, 0x8422, 0x8420,
1857 0x831a, 0xa399, 0x0000, 0x6908, 0x2400, 0xa122, 0x690c, 0x2300,
1858 0xa11b, 0x00c8, 0x49bd, 0x1078, 0x23ca, 0x2071, 0x0020, 0x0078,
1859 0x48ac, 0x127f, 0x2000, 0x007c, 0x7008, 0xa084, 0x0003, 0xa086,
1860 0x0003, 0x0040, 0x49ec, 0x2704, 0xac08, 0x2104, 0x701a, 0x8108,
1861 0x2104, 0x701e, 0x8108, 0x2104, 0x7012, 0x8108, 0x2104, 0x7016,
1862 0x6004, 0xa084, 0x0008, 0x0040, 0x49e3, 0x8108, 0x2104, 0x7022,
1863 0x8108, 0x2104, 0x7026, 0x7602, 0x7004, 0xa084, 0x0010, 0xa085,
1864 0x0001, 0x7006, 0x1078, 0x483e, 0x007c, 0x127e, 0x007e, 0x0d7e,
1865 0x2091, 0x2200, 0x2049, 0x49ed, 0x0d7f, 0x087f, 0x7108, 0xa184,
1866 0x0003, 0x00c0, 0x4a17, 0x017e, 0x6904, 0xa18c, 0x00ff, 0xa186,
1867 0x0007, 0x0040, 0x4a07, 0xa18e, 0x000f, 0x00c0, 0x4a0a, 0x6840,
1868 0x0078, 0x4a0b, 0x6828, 0x017f, 0xa005, 0x0040, 0x4a25, 0x0078,
1869 0x464a, 0x0020, 0x4a17, 0x1078, 0x4801, 0x0078, 0x4a25, 0x00a0,
1870 0x4a1e, 0x7108, 0x1078, 0x477a, 0x0078, 0x49f6, 0x7007, 0x0010,
1871 0x00a0, 0x4a20, 0x7108, 0x1078, 0x477a, 0x7008, 0xa086, 0x0008,
1872 0x00c0, 0x49f6, 0x7000, 0xa005, 0x00c0, 0x49f6, 0x7003, 0x0000,
1873 0x2049, 0x0000, 0x127f, 0x2000, 0x007c, 0x127e, 0x147e, 0x137e,
1874 0x157e, 0x0c7e, 0x0d7e, 0x2091, 0x2200, 0x0d7f, 0x2049, 0x4a35,
1875 0xad80, 0x0011, 0x20a0, 0x2099, 0x0031, 0x700c, 0xa084, 0x00ff,
1876 0x682a, 0x7007, 0x0008, 0x7007, 0x0002, 0x7003, 0x0001, 0x0040,
1877 0x4a54, 0x8000, 0x80ac, 0x53a5, 0x7007, 0x0004, 0x7004, 0xa084,
1878 0x0004, 0x00c0, 0x4a56, 0x0c7f, 0x2049, 0x0000, 0x7003, 0x0000,
1879 0x157f, 0x137f, 0x147f, 0x127f, 0x2000, 0x007c, 0x2091, 0x6000,
1880 0x2091, 0x8000, 0x78cc, 0xa005, 0x0040, 0x4a7d, 0x7994, 0x70d0,
1881 0xa106, 0x00c0, 0x4a7d, 0x7804, 0xa005, 0x0040, 0x4a7d, 0x7807,
1882 0x0000, 0x0068, 0x4a7d, 0x2091, 0x4080, 0x7820, 0x8001, 0x7822,
1883 0x00c0, 0x4ad8, 0x7824, 0x7822, 0x2069, 0x5040, 0x6800, 0xa084,
1884 0x0007, 0x0040, 0x4a9b, 0xa086, 0x0002, 0x0040, 0x4a9b, 0x6834,
1885 0xa00d, 0x0040, 0x4a9b, 0x2104, 0xa005, 0x0040, 0x4a9b, 0x8001,
1886 0x200a, 0x0040, 0x4b80, 0x7848, 0xa005, 0x0040, 0x4aa9, 0x8001,
1887 0x784a, 0x00c0, 0x4aa9, 0x2009, 0x0102, 0x6844, 0x200a, 0x1078,
1888 0x21b1, 0x6890, 0xa005, 0x0040, 0x4ab5, 0x8001, 0x6892, 0x00c0,
1889 0x4ab5, 0x686f, 0x0000, 0x6873, 0x0001, 0x2061, 0x5300, 0x20a9,
1890 0x0100, 0x2009, 0x0002, 0x6034, 0xa005, 0x0040, 0x4acb, 0x8001,
1891 0x6036, 0x00c0, 0x4acb, 0x6010, 0xa005, 0x0040, 0x4acb, 0x017e,
1892 0x1078, 0x21b1, 0x017f, 0xace0, 0x0010, 0x0070, 0x4ad1, 0x0078,
1893 0x4abb, 0x8109, 0x0040, 0x4ad8, 0x20a9, 0x0100, 0x0078, 0x4abb,
1894 0x1078, 0x4ae5, 0x1078, 0x4b0a, 0x2009, 0x5051, 0x2104, 0x2009,
1895 0x0102, 0x200a, 0x2091, 0x8001, 0x007c, 0x7834, 0x8001, 0x7836,
1896 0x00c0, 0x4b09, 0x7838, 0x7836, 0x2091, 0x8000, 0x7844, 0xa005,
1897 0x00c0, 0x4af4, 0x2001, 0x0101, 0x8001, 0x7846, 0xa080, 0x7300,
1898 0x2040, 0x2004, 0xa065, 0x0040, 0x4b09, 0x6024, 0xa005, 0x0040,
1899 0x4b05, 0x8001, 0x6026, 0x0040, 0x4b39, 0x6000, 0x2c40, 0x0078,
1900 0x4afa, 0x007c, 0x7828, 0x8001, 0x782a, 0x00c0, 0x4b38, 0x782c,
1901 0x782a, 0x7830, 0xa005, 0x00c0, 0x4b17, 0x2001, 0x0200, 0x8001,
1902 0x7832, 0x8003, 0x8003, 0x8003, 0x8003, 0xa090, 0x5300, 0xa298,
1903 0x0002, 0x2304, 0xa084, 0x0008, 0x0040, 0x4b38, 0xa290, 0x0009,
1904 0x2204, 0xa005, 0x0040, 0x4b30, 0x8001, 0x2012, 0x00c0, 0x4b38,
1905 0x2304, 0xa084, 0xfff7, 0xa085, 0x0080, 0x201a, 0x1078, 0x21b1,
1906 0x007c, 0x2069, 0x5040, 0x6800, 0xa005, 0x0040, 0x4b43, 0x6848,
1907 0xac06, 0x0040, 0x4b80, 0x601b, 0x0006, 0x60b4, 0xa084, 0x3f00,
1908 0x601e, 0x6020, 0xa084, 0x00ff, 0xa085, 0x0060, 0x6022, 0x6000,
1909 0x2042, 0x6714, 0x6f82, 0x1078, 0x1956, 0x6818, 0xa005, 0x0040,
1910 0x4b5b, 0x8001, 0x681a, 0x6808, 0xa084, 0xffef, 0x680a, 0x6810,
1911 0x8001, 0x00d0, 0x4b65, 0x1078, 0x23ca, 0x6812, 0x602f, 0x0000,
1912 0x6033, 0x0000, 0x2c68, 0x1078, 0x1c53, 0x2069, 0x5040, 0x7944,
1913 0xa184, 0x0100, 0x2001, 0x0006, 0x686e, 0x00c0, 0x4b7b, 0x6986,
1914 0x2001, 0x0004, 0x686e, 0x1078, 0x21ac, 0x2091, 0x8001, 0x007c,
1915 0x2069, 0x0100, 0x2009, 0x5040, 0x2104, 0xa084, 0x0007, 0x0040,
1916 0x4bdc, 0xa086, 0x0007, 0x00c0, 0x4b96, 0x0d7e, 0x2009, 0x5052,
1917 0x216c, 0x1078, 0x3a1a, 0x0d7f, 0x0078, 0x4bdc, 0x2009, 0x5052,
1918 0x2164, 0x1078, 0x2375, 0x601b, 0x0006, 0x6858, 0xa084, 0x3f00,
1919 0x601e, 0x6020, 0xa084, 0x00ff, 0xa085, 0x0048, 0x6022, 0x602f,
1920 0x0000, 0x6033, 0x0000, 0x6830, 0xa084, 0x0040, 0x0040, 0x4bd0,
1921 0x684b, 0x0004, 0x20a9, 0x0014, 0x6848, 0xa084, 0x0004, 0x0040,
1922 0x4bbd, 0x0070, 0x4bbd, 0x0078, 0x4bb4, 0x684b, 0x0009, 0x20a9,
1923 0x0014, 0x6848, 0xa084, 0x0001, 0x0040, 0x4bca, 0x0070, 0x4bca,
1924 0x0078, 0x4bc1, 0x20a9, 0x00fa, 0x0070, 0x4bd0, 0x0078, 0x4bcc,
1925 0x6808, 0xa084, 0xfffd, 0x680a, 0x681b, 0x0048, 0x2009, 0x505b,
1926 0x200b, 0x0007, 0x784c, 0x784a, 0x2091, 0x8001, 0x007c, 0x2079,
1927 0x5000, 0x1078, 0x4c0a, 0x1078, 0x4bee, 0x1078, 0x4bfc, 0x7833,
1928 0x0000, 0x7847, 0x0000, 0x784b, 0x0000, 0x007c, 0x2019, 0x0003,
1929 0x2011, 0x5046, 0x2204, 0xa086, 0x003c, 0x0040, 0x4bf9, 0x2019,
1930 0x0002, 0x7b2a, 0x7b2e, 0x007c, 0x2019, 0x0039, 0x2011, 0x5046,
1931 0x2204, 0xa086, 0x003c, 0x0040, 0x4c07, 0x2019, 0x0027, 0x7b36,
1932 0x7b3a, 0x007c, 0x2019, 0x3971, 0x2011, 0x5046, 0x2204, 0xa086,
1933 0x003c, 0x0040, 0x4c15, 0x2019, 0x2626, 0x7b22, 0x7b26, 0x783f,
1934 0x0000, 0x7843, 0x000a, 0x007c, 0x0020, 0x002b, 0x0000, 0x0020,
1935 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020,
1936 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020,
1937 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020,
1938 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0014,
1939 0x0014, 0x9849, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014, 0x0014,
1940 0x0014, 0x0080, 0x000f, 0x0000, 0x0201, 0x0604, 0x0c08, 0x2120,
1941 0x4022, 0xf880, 0x0018, 0x300b, 0xa201, 0x0014, 0xa200, 0x0014,
1942 0xa200, 0x0214, 0x0000, 0x006c, 0x0002, 0x0014, 0x98d5, 0x009e,
1943 0x009b, 0xa202, 0x8838, 0x3806, 0x8839, 0x20c3, 0x0864, 0x9889,
1944 0x28c1, 0x9cb6, 0xa203, 0x300c, 0x2846, 0x8161, 0x846a, 0x8300,
1945 0x1856, 0x883a, 0x9865, 0x28f2, 0x9c95, 0x9858, 0x300c, 0x28e1,
1946 0x9c95, 0x2809, 0xa206, 0x64c0, 0x67a0, 0x6fc0, 0x1814, 0x883b,
1947 0x782c, 0x786d, 0x9879, 0x282b, 0xa207, 0x64a0, 0x67a0, 0x6fc0,
1948 0x1814, 0x883b, 0x7822, 0x883e, 0x987d, 0x8576, 0x8677, 0x206b,
1949 0x28c1, 0x9cb6, 0x2044, 0x2103, 0x20a2, 0x2081, 0x9865, 0xa209,
1950 0x2901, 0x9891, 0x0014, 0xa205, 0xa300, 0x1872, 0x879a, 0x883c,
1951 0x1fe2, 0xc601, 0xa20a, 0x856e, 0x0704, 0x9c95, 0x0014, 0xa204,
1952 0xa300, 0x3009, 0x19e2, 0xf868, 0x8176, 0x86eb, 0x85eb, 0x872e,
1953 0x87a9, 0x883f, 0x08e6, 0x9895, 0xf881, 0x9890, 0xc801, 0x0014,
1954 0xf8c1, 0x0016, 0x85b2, 0x80f0, 0x9532, 0xfb02, 0x1de2, 0x0014,
1955 0x8532, 0xf241, 0x0014, 0x1de2, 0x84a8, 0xd7a0, 0x1fe6, 0x0014,
1956 0xa208, 0x6043, 0x8008, 0x1dc1, 0x0016, 0x8300, 0x8160, 0x842a,
1957 0xf041, 0x3008, 0x84a8, 0x11d6, 0x7042, 0x20dd, 0x0011, 0x20d5,
1958 0x8822, 0x0016, 0x8000, 0x2847, 0x1011, 0x98c8, 0x8000, 0xa000,
1959 0x2802, 0x1011, 0x98ce, 0x9865, 0x283e, 0x1011, 0x98d2, 0xa20b,
1960 0x0017, 0x300c, 0xa300, 0x1de2, 0xdb81, 0x0014, 0x0210, 0x98df,
1961 0x0014, 0x26e0, 0x873a, 0xfb02, 0x19f2, 0x1fe2, 0x0014, 0xa20d,
1962 0x3806, 0x0210, 0x9cbb, 0x0704, 0x0000, 0x006c, 0x0002, 0x984f,
1963 0x0014, 0x009e, 0x00a0, 0x0017, 0x60ff, 0x300c, 0x8720, 0xa211,
1964 0x9cd0, 0x8772, 0x8837, 0x2101, 0x987a, 0x10d2, 0x78e2, 0x9cd3,
1965 0x9859, 0xd984, 0xf0e2, 0xf0a1, 0x98cd, 0x0014, 0x8831, 0xd166,
1966 0x8830, 0x800f, 0x9401, 0xb520, 0xc802, 0x8820, 0x987a, 0x2301,
1967 0x987a, 0x10d2, 0x78e4, 0x9cd3, 0x8821, 0x8820, 0x9859, 0xf123,
1968 0xf142, 0xf101, 0x98c6, 0x10d2, 0x70f6, 0x8832, 0x8203, 0x870c,
1969 0xd99e, 0x6001, 0x0014, 0x6845, 0x0214, 0xa21b, 0x9cd0, 0x2001,
1970 0x98c5, 0x8201, 0x1852, 0xd184, 0xd163, 0x8834, 0x8001, 0x988d,
1971 0x3027, 0x84a8, 0x1a56, 0x8833, 0x0014, 0xa218, 0x6981, 0x9cbc,
1972 0x6b2a, 0x6902, 0x1834, 0x989d, 0x1814, 0x8010, 0x8592, 0x8026,
1973 0x84b9, 0x7021, 0x0014, 0xa300, 0x69e1, 0x9ca9, 0x694b, 0xa213,
1974 0x1462, 0xa213, 0x8000, 0x16e1, 0x98b5, 0x8023, 0x16e1, 0x8001,
1975 0x10f1, 0x0016, 0x6969, 0xa214, 0x61c2, 0x8002, 0x14e1, 0x8004,
1976 0x16e1, 0x0101, 0x300a, 0x8827, 0x0014, 0xa217, 0x9cbc, 0x0014,
1977 0xa300, 0x8181, 0x842a, 0x84a8, 0x1ce6, 0x882c, 0x0016, 0xa212,
1978 0x9cd0, 0x10d2, 0x70e4, 0x0004, 0x8007, 0x9424, 0xcc1a, 0x9cd3,
1979 0x98c5, 0x8827, 0x300a, 0x0013, 0x8000, 0x84a4, 0x0016, 0x11c2,
1980 0x211e, 0x870e, 0xa21d, 0x0014, 0x878e, 0x0016, 0xa21c, 0x1035,
1981 0x9891, 0xa210, 0xa000, 0x8010, 0x8592, 0x853b, 0xd044, 0x8022,
1982 0x3807, 0x84bb, 0x98ea, 0x8021, 0x3807, 0x84b9, 0x300c, 0x817e,
1983 0x872b, 0x8772, 0x9891, 0x0000, 0x0020, 0x002b, 0x0000, 0x0020,
1984 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020,
1985 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020,
1986 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020,
1987 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0020, 0x0000, 0x0014,
1988 0x0014, 0x9849, 0x0014, 0x0014, 0x98ea, 0x98d5, 0x0014, 0x0014,
1989 0x0014, 0x0080, 0x013f, 0x0000, 0x0201, 0x0604, 0x0c08, 0x2120,
1990 0x4022, 0xf880, 0x0018, 0x300b, 0xa201, 0x0014, 0xa200, 0x0014,
1991 0xa200, 0x0214, 0xa202, 0x8838, 0x3806, 0x8839, 0x20c3, 0x0864,
1992 0xa833, 0x28c1, 0x9cb6, 0xa203, 0x300c, 0x2846, 0x8161, 0x846a,
1993 0x8300, 0x1856, 0x883a, 0xa804, 0x28f2, 0x9c95, 0xa8f4, 0x300c,
1994 0x28e1, 0x9c95, 0x2809, 0xa206, 0x64c0, 0x67a0, 0x6fc0, 0x1814,
1995 0x883b, 0x782c, 0x786d, 0xa808, 0x282b, 0xa207, 0x64a0, 0x67a0,
1996 0x6fc0, 0x1814, 0x883b, 0x7822, 0x883e, 0xa802, 0x8576, 0x8677,
1997 0x206b, 0x28c1, 0x9cb6, 0x2044, 0x2103, 0x20a2, 0x2081, 0xa8e0,
1998 0xa209, 0x2901, 0xa809, 0x0014, 0xa205, 0xa300, 0x1872, 0x879a,
1999 0x883c, 0x1fe2, 0xc601, 0xa20a, 0x856e, 0x0704, 0x9c95, 0x0014,
2000 0xa204, 0xa300, 0x3009, 0x19e2, 0xf868, 0x8176, 0x86eb, 0x85eb,
2001 0x872e, 0x87a9, 0x883f, 0x08e6, 0xa8f3, 0xf881, 0xa8ec, 0xc801,
2002 0x0014, 0xf8c1, 0x0016, 0x85b2, 0x80f0, 0x9532, 0xfb02, 0x1de2,
2003 0x0014, 0x8532, 0xf241, 0x0014, 0x1de2, 0x84a8, 0xd7a0, 0x1fe6,
2004 0x0014, 0xa208, 0x6043, 0x8008, 0x1dc1, 0x0016, 0x8300, 0x8160,
2005 0x842a, 0xf041, 0x3008, 0x84a8, 0x11d6, 0x7042, 0x20dd, 0x0011,
2006 0x20d5, 0x8822, 0x0016, 0x8000, 0x2847, 0x1011, 0xa8fc, 0x8000,
2007 0xa000, 0x2802, 0x1011, 0xa8fd, 0xa893, 0x283e, 0x1011, 0xa8fd,
2008 0xa20b, 0x0017, 0x300c, 0xa300, 0x1de2, 0xdb81, 0x0014, 0x0210,
2009 0xa801, 0x0014, 0x26e0, 0x873a, 0xfb02, 0x19f2, 0x1fe2, 0x0014,
2010 0xa20d, 0x3806, 0x0210, 0x9cbb, 0x0704, 0x0017, 0x60ff, 0x300c,
2011 0x8720, 0xa211, 0x9d6b, 0x8772, 0x8837, 0x2101, 0xa821, 0x10d2,
2012 0x78e2, 0x9d6e, 0xa8fc, 0xd984, 0xf0e2, 0xf0a1, 0xa86c, 0x0014,
2013 0x8831, 0xd166, 0x8830, 0x800f, 0x9401, 0xb520, 0xc802, 0x8820,
2014 0xa80f, 0x2301, 0xa80d, 0x10d2, 0x78e4, 0x9d6e, 0x8821, 0x8820,
2015 0xa8e6, 0xf123, 0xf142, 0xf101, 0xa84f, 0x10d2, 0x70f6, 0x8832,
2016 0x8203, 0x870c, 0xd99e, 0x6001, 0x0014, 0x6845, 0x0214, 0xa21b,
2017 0x9d6b, 0x2001, 0xa840, 0x8201, 0x1852, 0xd184, 0xd163, 0x8834,
2018 0x8001, 0xa801, 0x3027, 0x84a8, 0x1a56, 0x8833, 0x0014, 0xa218,
2019 0x6981, 0x9d57, 0x6b2a, 0x6902, 0x1834, 0xa805, 0x1814, 0x8010,
2020 0x8592, 0x8026, 0x84b9, 0x7021, 0x0014, 0xa300, 0x69e1, 0x9d44,
2021 0x694b, 0xa213, 0x1462, 0xa213, 0x8000, 0x16e1, 0xa80c, 0x8023,
2022 0x16e1, 0x8001, 0x10f1, 0x0016, 0x6969, 0xa214, 0x61c2, 0x8002,
2023 0x14e1, 0x8004, 0x16e1, 0x0101, 0x300a, 0x8827, 0x0014, 0xa217,
2024 0x9d57, 0x0014, 0xa300, 0x8181, 0x842a, 0x84a8, 0x1ce6, 0x882c,
2025 0x0016, 0xa212, 0x9d6b, 0x10d2, 0x70e4, 0x0004, 0x8007, 0x9424,
2026 0xcc1a, 0x9d6e, 0xa8f8, 0x8827, 0x300a, 0x0013, 0x8000, 0x84a4,
2027 0x0016, 0x11c2, 0x211e, 0x870e, 0xa21d, 0x0014, 0x878e, 0x0016,
2028 0xa21c, 0x1035, 0xa8b4, 0xa210, 0x3807, 0x300c, 0x817e, 0x872b,
2029 0x8772, 0xa8ad, 0x0000, 0x8ec6
2030};
2031
2032#endif /* RELOAD_FIRMWARE */
2033
2034static const unsigned short risc_code_length01 = 0x3f14;
diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c
index caa0c3629626..5b1c12041a4f 100644
--- a/drivers/scsi/raid_class.c
+++ b/drivers/scsi/raid_class.c
@@ -1,5 +1,13 @@
1/* 1/*
2 * RAID Attributes 2 * raid_class.c - implementation of a simple raid visualisation class
3 *
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
5 *
6 * This file is licensed under GPLv2
7 *
8 * This class is designed to allow raid attributes to be visualised and
9 * manipulated in a form independent of the underlying raid. Ultimately this
10 * should work for both hardware and software raids.
3 */ 11 */
4#include <linux/init.h> 12#include <linux/init.h>
5#include <linux/module.h> 13#include <linux/module.h>
@@ -24,7 +32,7 @@ struct raid_internal {
24 32
25struct raid_component { 33struct raid_component {
26 struct list_head node; 34 struct list_head node;
27 struct device *dev; 35 struct class_device cdev;
28 int num; 36 int num;
29}; 37};
30 38
@@ -74,11 +82,10 @@ static int raid_setup(struct transport_container *tc, struct device *dev,
74 82
75 BUG_ON(class_get_devdata(cdev)); 83 BUG_ON(class_get_devdata(cdev));
76 84
77 rd = kmalloc(sizeof(*rd), GFP_KERNEL); 85 rd = kzalloc(sizeof(*rd), GFP_KERNEL);
78 if (!rd) 86 if (!rd)
79 return -ENOMEM; 87 return -ENOMEM;
80 88
81 memset(rd, 0, sizeof(*rd));
82 INIT_LIST_HEAD(&rd->component_list); 89 INIT_LIST_HEAD(&rd->component_list);
83 class_set_devdata(cdev, rd); 90 class_set_devdata(cdev, rd);
84 91
@@ -90,15 +97,15 @@ static int raid_remove(struct transport_container *tc, struct device *dev,
90{ 97{
91 struct raid_data *rd = class_get_devdata(cdev); 98 struct raid_data *rd = class_get_devdata(cdev);
92 struct raid_component *rc, *next; 99 struct raid_component *rc, *next;
100 dev_printk(KERN_ERR, dev, "RAID REMOVE\n");
93 class_set_devdata(cdev, NULL); 101 class_set_devdata(cdev, NULL);
94 list_for_each_entry_safe(rc, next, &rd->component_list, node) { 102 list_for_each_entry_safe(rc, next, &rd->component_list, node) {
95 char buf[40];
96 snprintf(buf, sizeof(buf), "component-%d", rc->num);
97 list_del(&rc->node); 103 list_del(&rc->node);
98 sysfs_remove_link(&cdev->kobj, buf); 104 dev_printk(KERN_ERR, rc->cdev.dev, "RAID COMPONENT REMOVE\n");
99 kfree(rc); 105 class_device_unregister(&rc->cdev);
100 } 106 }
101 kfree(class_get_devdata(cdev)); 107 dev_printk(KERN_ERR, dev, "RAID REMOVE DONE\n");
108 kfree(rd);
102 return 0; 109 return 0;
103} 110}
104 111
@@ -112,10 +119,11 @@ static struct {
112 enum raid_state value; 119 enum raid_state value;
113 char *name; 120 char *name;
114} raid_states[] = { 121} raid_states[] = {
115 { RAID_ACTIVE, "active" }, 122 { RAID_STATE_UNKNOWN, "unknown" },
116 { RAID_DEGRADED, "degraded" }, 123 { RAID_STATE_ACTIVE, "active" },
117 { RAID_RESYNCING, "resyncing" }, 124 { RAID_STATE_DEGRADED, "degraded" },
118 { RAID_OFFLINE, "offline" }, 125 { RAID_STATE_RESYNCING, "resyncing" },
126 { RAID_STATE_OFFLINE, "offline" },
119}; 127};
120 128
121static const char *raid_state_name(enum raid_state state) 129static const char *raid_state_name(enum raid_state state)
@@ -132,6 +140,33 @@ static const char *raid_state_name(enum raid_state state)
132 return name; 140 return name;
133} 141}
134 142
143static struct {
144 enum raid_level value;
145 char *name;
146} raid_levels[] = {
147 { RAID_LEVEL_UNKNOWN, "unknown" },
148 { RAID_LEVEL_LINEAR, "linear" },
149 { RAID_LEVEL_0, "raid0" },
150 { RAID_LEVEL_1, "raid1" },
151 { RAID_LEVEL_3, "raid3" },
152 { RAID_LEVEL_4, "raid4" },
153 { RAID_LEVEL_5, "raid5" },
154 { RAID_LEVEL_6, "raid6" },
155};
156
157static const char *raid_level_name(enum raid_level level)
158{
159 int i;
160 char *name = NULL;
161
162 for (i = 0; i < sizeof(raid_levels)/sizeof(raid_levels[0]); i++) {
163 if (raid_levels[i].value == level) {
164 name = raid_levels[i].name;
165 break;
166 }
167 }
168 return name;
169}
135 170
136#define raid_attr_show_internal(attr, fmt, var, code) \ 171#define raid_attr_show_internal(attr, fmt, var, code) \
137static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \ 172static ssize_t raid_show_##attr(struct class_device *cdev, char *buf) \
@@ -161,11 +196,22 @@ static CLASS_DEVICE_ATTR(attr, S_IRUGO, raid_show_##attr, NULL)
161 196
162#define raid_attr_ro(attr) raid_attr_ro_internal(attr, ) 197#define raid_attr_ro(attr) raid_attr_ro_internal(attr, )
163#define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr)) 198#define raid_attr_ro_fn(attr) raid_attr_ro_internal(attr, ATTR_CODE(attr))
164#define raid_attr_ro_state(attr) raid_attr_ro_states(attr, attr, ATTR_CODE(attr)) 199#define raid_attr_ro_state(attr) raid_attr_ro_states(attr, attr, )
200#define raid_attr_ro_state_fn(attr) raid_attr_ro_states(attr, attr, ATTR_CODE(attr))
201
165 202
166raid_attr_ro(level); 203raid_attr_ro_state(level);
167raid_attr_ro_fn(resync); 204raid_attr_ro_fn(resync);
168raid_attr_ro_state(state); 205raid_attr_ro_state_fn(state);
206
207static void raid_component_release(struct class_device *cdev)
208{
209 struct raid_component *rc = container_of(cdev, struct raid_component,
210 cdev);
211 dev_printk(KERN_ERR, rc->cdev.dev, "COMPONENT RELEASE\n");
212 put_device(rc->cdev.dev);
213 kfree(rc);
214}
169 215
170void raid_component_add(struct raid_template *r,struct device *raid_dev, 216void raid_component_add(struct raid_template *r,struct device *raid_dev,
171 struct device *component_dev) 217 struct device *component_dev)
@@ -175,34 +221,36 @@ void raid_component_add(struct raid_template *r,struct device *raid_dev,
175 raid_dev); 221 raid_dev);
176 struct raid_component *rc; 222 struct raid_component *rc;
177 struct raid_data *rd = class_get_devdata(cdev); 223 struct raid_data *rd = class_get_devdata(cdev);
178 char buf[40];
179 224
180 rc = kmalloc(sizeof(*rc), GFP_KERNEL); 225 rc = kzalloc(sizeof(*rc), GFP_KERNEL);
181 if (!rc) 226 if (!rc)
182 return; 227 return;
183 228
184 INIT_LIST_HEAD(&rc->node); 229 INIT_LIST_HEAD(&rc->node);
185 rc->dev = component_dev; 230 class_device_initialize(&rc->cdev);
231 rc->cdev.release = raid_component_release;
232 rc->cdev.dev = get_device(component_dev);
186 rc->num = rd->component_count++; 233 rc->num = rd->component_count++;
187 234
188 snprintf(buf, sizeof(buf), "component-%d", rc->num); 235 snprintf(rc->cdev.class_id, sizeof(rc->cdev.class_id),
236 "component-%d", rc->num);
189 list_add_tail(&rc->node, &rd->component_list); 237 list_add_tail(&rc->node, &rd->component_list);
190 sysfs_create_link(&cdev->kobj, &component_dev->kobj, buf); 238 rc->cdev.parent = cdev;
239 rc->cdev.class = &raid_class.class;
240 class_device_add(&rc->cdev);
191} 241}
192EXPORT_SYMBOL(raid_component_add); 242EXPORT_SYMBOL(raid_component_add);
193 243
194struct raid_template * 244struct raid_template *
195raid_class_attach(struct raid_function_template *ft) 245raid_class_attach(struct raid_function_template *ft)
196{ 246{
197 struct raid_internal *i = kmalloc(sizeof(struct raid_internal), 247 struct raid_internal *i = kzalloc(sizeof(struct raid_internal),
198 GFP_KERNEL); 248 GFP_KERNEL);
199 int count = 0; 249 int count = 0;
200 250
201 if (unlikely(!i)) 251 if (unlikely(!i))
202 return NULL; 252 return NULL;
203 253
204 memset(i, 0, sizeof(*i));
205
206 i->f = ft; 254 i->f = ft;
207 255
208 i->r.raid_attrs.ac.class = &raid_class.class; 256 i->r.raid_attrs.ac.class = &raid_class.class;
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 93d55233af7b..9321cdf45680 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * sata_mv.c - Marvell SATA support 2 * sata_mv.c - Marvell SATA support
3 * 3 *
4 * Copyright 2005: EMC Corporation, all rights reserved. 4 * Copyright 2005: EMC Corporation, all rights reserved.
5 * Copyright 2005 Red Hat, Inc. All rights reserved.
5 * 6 *
6 * Please ALWAYS copy linux-ide@vger.kernel.org on emails. 7 * Please ALWAYS copy linux-ide@vger.kernel.org on emails.
7 * 8 *
@@ -36,7 +37,7 @@
36#include <asm/io.h> 37#include <asm/io.h>
37 38
38#define DRV_NAME "sata_mv" 39#define DRV_NAME "sata_mv"
39#define DRV_VERSION "0.25" 40#define DRV_VERSION "0.5"
40 41
41enum { 42enum {
42 /* BAR's are enumerated in terms of pci_resource_start() terms */ 43 /* BAR's are enumerated in terms of pci_resource_start() terms */
@@ -50,6 +51,9 @@ enum {
50 MV_PCI_REG_BASE = 0, 51 MV_PCI_REG_BASE = 0,
51 MV_IRQ_COAL_REG_BASE = 0x18000, /* 6xxx part only */ 52 MV_IRQ_COAL_REG_BASE = 0x18000, /* 6xxx part only */
52 MV_SATAHC0_REG_BASE = 0x20000, 53 MV_SATAHC0_REG_BASE = 0x20000,
54 MV_FLASH_CTL = 0x1046c,
55 MV_GPIO_PORT_CTL = 0x104f0,
56 MV_RESET_CFG = 0x180d8,
53 57
54 MV_PCI_REG_SZ = MV_MAJOR_REG_AREA_SZ, 58 MV_PCI_REG_SZ = MV_MAJOR_REG_AREA_SZ,
55 MV_SATAHC_REG_SZ = MV_MAJOR_REG_AREA_SZ, 59 MV_SATAHC_REG_SZ = MV_MAJOR_REG_AREA_SZ,
@@ -72,11 +76,6 @@ enum {
72 MV_SG_TBL_SZ = (16 * MV_MAX_SG_CT), 76 MV_SG_TBL_SZ = (16 * MV_MAX_SG_CT),
73 MV_PORT_PRIV_DMA_SZ = (MV_CRQB_Q_SZ + MV_CRPB_Q_SZ + MV_SG_TBL_SZ), 77 MV_PORT_PRIV_DMA_SZ = (MV_CRQB_Q_SZ + MV_CRPB_Q_SZ + MV_SG_TBL_SZ),
74 78
75 /* Our DMA boundary is determined by an ePRD being unable to handle
76 * anything larger than 64KB
77 */
78 MV_DMA_BOUNDARY = 0xffffU,
79
80 MV_PORTS_PER_HC = 4, 79 MV_PORTS_PER_HC = 4,
81 /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */ 80 /* == (port / MV_PORTS_PER_HC) to determine HC from 0-7 port */
82 MV_PORT_HC_SHIFT = 2, 81 MV_PORT_HC_SHIFT = 2,
@@ -86,16 +85,10 @@ enum {
86 /* Host Flags */ 85 /* Host Flags */
87 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */ 86 MV_FLAG_DUAL_HC = (1 << 30), /* two SATA Host Controllers */
88 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */ 87 MV_FLAG_IRQ_COALESCE = (1 << 29), /* IRQ coalescing capability */
89 MV_FLAG_GLBL_SFT_RST = (1 << 28), /* Global Soft Reset support */
90 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 88 MV_COMMON_FLAGS = (ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
91 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO), 89 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO |
92 MV_6XXX_FLAGS = (MV_FLAG_IRQ_COALESCE | 90 ATA_FLAG_NO_ATAPI),
93 MV_FLAG_GLBL_SFT_RST), 91 MV_6XXX_FLAGS = MV_FLAG_IRQ_COALESCE,
94
95 chip_504x = 0,
96 chip_508x = 1,
97 chip_604x = 2,
98 chip_608x = 3,
99 92
100 CRQB_FLAG_READ = (1 << 0), 93 CRQB_FLAG_READ = (1 << 0),
101 CRQB_TAG_SHIFT = 1, 94 CRQB_TAG_SHIFT = 1,
@@ -116,8 +109,19 @@ enum {
116 PCI_MASTER_EMPTY = (1 << 3), 109 PCI_MASTER_EMPTY = (1 << 3),
117 GLOB_SFT_RST = (1 << 4), 110 GLOB_SFT_RST = (1 << 4),
118 111
119 PCI_IRQ_CAUSE_OFS = 0x1d58, 112 MV_PCI_MODE = 0xd00,
120 PCI_IRQ_MASK_OFS = 0x1d5c, 113 MV_PCI_EXP_ROM_BAR_CTL = 0xd2c,
114 MV_PCI_DISC_TIMER = 0xd04,
115 MV_PCI_MSI_TRIGGER = 0xc38,
116 MV_PCI_SERR_MASK = 0xc28,
117 MV_PCI_XBAR_TMOUT = 0x1d04,
118 MV_PCI_ERR_LOW_ADDRESS = 0x1d40,
119 MV_PCI_ERR_HIGH_ADDRESS = 0x1d44,
120 MV_PCI_ERR_ATTRIBUTE = 0x1d48,
121 MV_PCI_ERR_COMMAND = 0x1d50,
122
123 PCI_IRQ_CAUSE_OFS = 0x1d58,
124 PCI_IRQ_MASK_OFS = 0x1d5c,
121 PCI_UNMASK_ALL_IRQS = 0x7fffff, /* bits 22-0 */ 125 PCI_UNMASK_ALL_IRQS = 0x7fffff, /* bits 22-0 */
122 126
123 HC_MAIN_IRQ_CAUSE_OFS = 0x1d60, 127 HC_MAIN_IRQ_CAUSE_OFS = 0x1d60,
@@ -134,7 +138,7 @@ enum {
134 SELF_INT = (1 << 23), 138 SELF_INT = (1 << 23),
135 TWSI_INT = (1 << 24), 139 TWSI_INT = (1 << 24),
136 HC_MAIN_RSVD = (0x7f << 25), /* bits 31-25 */ 140 HC_MAIN_RSVD = (0x7f << 25), /* bits 31-25 */
137 HC_MAIN_MASKED_IRQS = (TRAN_LO_DONE | TRAN_HI_DONE | 141 HC_MAIN_MASKED_IRQS = (TRAN_LO_DONE | TRAN_HI_DONE |
138 PORTS_0_7_COAL_DONE | GPIO_INT | TWSI_INT | 142 PORTS_0_7_COAL_DONE | GPIO_INT | TWSI_INT |
139 HC_MAIN_RSVD), 143 HC_MAIN_RSVD),
140 144
@@ -153,6 +157,15 @@ enum {
153 /* SATA registers */ 157 /* SATA registers */
154 SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */ 158 SATA_STATUS_OFS = 0x300, /* ctrl, err regs follow status */
155 SATA_ACTIVE_OFS = 0x350, 159 SATA_ACTIVE_OFS = 0x350,
160 PHY_MODE3 = 0x310,
161 PHY_MODE4 = 0x314,
162 PHY_MODE2 = 0x330,
163 MV5_PHY_MODE = 0x74,
164 MV5_LT_MODE = 0x30,
165 MV5_PHY_CTL = 0x0C,
166 SATA_INTERFACE_CTL = 0x050,
167
168 MV_M2_PREAMP_MASK = 0x7e0,
156 169
157 /* Port registers */ 170 /* Port registers */
158 EDMA_CFG_OFS = 0, 171 EDMA_CFG_OFS = 0,
@@ -182,17 +195,16 @@ enum {
182 EDMA_ERR_LNK_CTRL_TX = (0x1f << 21), 195 EDMA_ERR_LNK_CTRL_TX = (0x1f << 21),
183 EDMA_ERR_LNK_DATA_TX = (0x1f << 26), 196 EDMA_ERR_LNK_DATA_TX = (0x1f << 26),
184 EDMA_ERR_TRANS_PROTO = (1 << 31), 197 EDMA_ERR_TRANS_PROTO = (1 << 31),
185 EDMA_ERR_FATAL = (EDMA_ERR_D_PAR | EDMA_ERR_PRD_PAR | 198 EDMA_ERR_FATAL = (EDMA_ERR_D_PAR | EDMA_ERR_PRD_PAR |
186 EDMA_ERR_DEV_DCON | EDMA_ERR_CRBQ_PAR | 199 EDMA_ERR_DEV_DCON | EDMA_ERR_CRBQ_PAR |
187 EDMA_ERR_CRPB_PAR | EDMA_ERR_INTRL_PAR | 200 EDMA_ERR_CRPB_PAR | EDMA_ERR_INTRL_PAR |
188 EDMA_ERR_IORDY | EDMA_ERR_LNK_CTRL_RX_2 | 201 EDMA_ERR_IORDY | EDMA_ERR_LNK_CTRL_RX_2 |
189 EDMA_ERR_LNK_DATA_RX | 202 EDMA_ERR_LNK_DATA_RX |
190 EDMA_ERR_LNK_DATA_TX | 203 EDMA_ERR_LNK_DATA_TX |
191 EDMA_ERR_TRANS_PROTO), 204 EDMA_ERR_TRANS_PROTO),
192 205
193 EDMA_REQ_Q_BASE_HI_OFS = 0x10, 206 EDMA_REQ_Q_BASE_HI_OFS = 0x10,
194 EDMA_REQ_Q_IN_PTR_OFS = 0x14, /* also contains BASE_LO */ 207 EDMA_REQ_Q_IN_PTR_OFS = 0x14, /* also contains BASE_LO */
195 EDMA_REQ_Q_BASE_LO_MASK = 0xfffffc00U,
196 208
197 EDMA_REQ_Q_OUT_PTR_OFS = 0x18, 209 EDMA_REQ_Q_OUT_PTR_OFS = 0x18,
198 EDMA_REQ_Q_PTR_SHIFT = 5, 210 EDMA_REQ_Q_PTR_SHIFT = 5,
@@ -200,7 +212,6 @@ enum {
200 EDMA_RSP_Q_BASE_HI_OFS = 0x1c, 212 EDMA_RSP_Q_BASE_HI_OFS = 0x1c,
201 EDMA_RSP_Q_IN_PTR_OFS = 0x20, 213 EDMA_RSP_Q_IN_PTR_OFS = 0x20,
202 EDMA_RSP_Q_OUT_PTR_OFS = 0x24, /* also contains BASE_LO */ 214 EDMA_RSP_Q_OUT_PTR_OFS = 0x24, /* also contains BASE_LO */
203 EDMA_RSP_Q_BASE_LO_MASK = 0xffffff00U,
204 EDMA_RSP_Q_PTR_SHIFT = 3, 215 EDMA_RSP_Q_PTR_SHIFT = 3,
205 216
206 EDMA_CMD_OFS = 0x28, 217 EDMA_CMD_OFS = 0x28,
@@ -208,14 +219,44 @@ enum {
208 EDMA_DS = (1 << 1), 219 EDMA_DS = (1 << 1),
209 ATA_RST = (1 << 2), 220 ATA_RST = (1 << 2),
210 221
222 EDMA_IORDY_TMOUT = 0x34,
223 EDMA_ARB_CFG = 0x38,
224
211 /* Host private flags (hp_flags) */ 225 /* Host private flags (hp_flags) */
212 MV_HP_FLAG_MSI = (1 << 0), 226 MV_HP_FLAG_MSI = (1 << 0),
227 MV_HP_ERRATA_50XXB0 = (1 << 1),
228 MV_HP_ERRATA_50XXB2 = (1 << 2),
229 MV_HP_ERRATA_60X1B2 = (1 << 3),
230 MV_HP_ERRATA_60X1C0 = (1 << 4),
231 MV_HP_50XX = (1 << 5),
213 232
214 /* Port private flags (pp_flags) */ 233 /* Port private flags (pp_flags) */
215 MV_PP_FLAG_EDMA_EN = (1 << 0), 234 MV_PP_FLAG_EDMA_EN = (1 << 0),
216 MV_PP_FLAG_EDMA_DS_ACT = (1 << 1), 235 MV_PP_FLAG_EDMA_DS_ACT = (1 << 1),
217}; 236};
218 237
238#define IS_50XX(hpriv) ((hpriv)->hp_flags & MV_HP_50XX)
239#define IS_60XX(hpriv) (((hpriv)->hp_flags & MV_HP_50XX) == 0)
240
241enum {
242 /* Our DMA boundary is determined by an ePRD being unable to handle
243 * anything larger than 64KB
244 */
245 MV_DMA_BOUNDARY = 0xffffU,
246
247 EDMA_REQ_Q_BASE_LO_MASK = 0xfffffc00U,
248
249 EDMA_RSP_Q_BASE_LO_MASK = 0xffffff00U,
250};
251
252enum chip_type {
253 chip_504x,
254 chip_508x,
255 chip_5080,
256 chip_604x,
257 chip_608x,
258};
259
219/* Command ReQuest Block: 32B */ 260/* Command ReQuest Block: 32B */
220struct mv_crqb { 261struct mv_crqb {
221 u32 sg_addr; 262 u32 sg_addr;
@@ -252,14 +293,37 @@ struct mv_port_priv {
252 u32 pp_flags; 293 u32 pp_flags;
253}; 294};
254 295
296struct mv_port_signal {
297 u32 amps;
298 u32 pre;
299};
300
301struct mv_host_priv;
302struct mv_hw_ops {
303 void (*phy_errata)(struct mv_host_priv *hpriv, void __iomem *mmio,
304 unsigned int port);
305 void (*enable_leds)(struct mv_host_priv *hpriv, void __iomem *mmio);
306 void (*read_preamp)(struct mv_host_priv *hpriv, int idx,
307 void __iomem *mmio);
308 int (*reset_hc)(struct mv_host_priv *hpriv, void __iomem *mmio,
309 unsigned int n_hc);
310 void (*reset_flash)(struct mv_host_priv *hpriv, void __iomem *mmio);
311 void (*reset_bus)(struct pci_dev *pdev, void __iomem *mmio);
312};
313
255struct mv_host_priv { 314struct mv_host_priv {
256 u32 hp_flags; 315 u32 hp_flags;
316 struct mv_port_signal signal[8];
317 const struct mv_hw_ops *ops;
257}; 318};
258 319
259static void mv_irq_clear(struct ata_port *ap); 320static void mv_irq_clear(struct ata_port *ap);
260static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in); 321static u32 mv_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
261static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val); 322static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
323static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in);
324static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val);
262static void mv_phy_reset(struct ata_port *ap); 325static void mv_phy_reset(struct ata_port *ap);
326static void __mv_phy_reset(struct ata_port *ap, int can_sleep);
263static void mv_host_stop(struct ata_host_set *host_set); 327static void mv_host_stop(struct ata_host_set *host_set);
264static int mv_port_start(struct ata_port *ap); 328static int mv_port_start(struct ata_port *ap);
265static void mv_port_stop(struct ata_port *ap); 329static void mv_port_stop(struct ata_port *ap);
@@ -270,6 +334,29 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
270static void mv_eng_timeout(struct ata_port *ap); 334static void mv_eng_timeout(struct ata_port *ap);
271static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 335static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
272 336
337static void mv5_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio,
338 unsigned int port);
339static void mv5_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio);
340static void mv5_read_preamp(struct mv_host_priv *hpriv, int idx,
341 void __iomem *mmio);
342static int mv5_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio,
343 unsigned int n_hc);
344static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio);
345static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio);
346
347static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio,
348 unsigned int port);
349static void mv6_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio);
350static void mv6_read_preamp(struct mv_host_priv *hpriv, int idx,
351 void __iomem *mmio);
352static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio,
353 unsigned int n_hc);
354static void mv6_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio);
355static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio);
356static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio,
357 unsigned int port_no);
358static void mv_stop_and_reset(struct ata_port *ap);
359
273static struct scsi_host_template mv_sht = { 360static struct scsi_host_template mv_sht = {
274 .module = THIS_MODULE, 361 .module = THIS_MODULE,
275 .name = DRV_NAME, 362 .name = DRV_NAME,
@@ -278,7 +365,7 @@ static struct scsi_host_template mv_sht = {
278 .eh_strategy_handler = ata_scsi_error, 365 .eh_strategy_handler = ata_scsi_error,
279 .can_queue = MV_USE_Q_DEPTH, 366 .can_queue = MV_USE_Q_DEPTH,
280 .this_id = ATA_SHT_THIS_ID, 367 .this_id = ATA_SHT_THIS_ID,
281 .sg_tablesize = MV_MAX_SG_CT, 368 .sg_tablesize = MV_MAX_SG_CT / 2,
282 .max_sectors = ATA_MAX_SECTORS, 369 .max_sectors = ATA_MAX_SECTORS,
283 .cmd_per_lun = ATA_SHT_CMD_PER_LUN, 370 .cmd_per_lun = ATA_SHT_CMD_PER_LUN,
284 .emulated = ATA_SHT_EMULATED, 371 .emulated = ATA_SHT_EMULATED,
@@ -290,7 +377,34 @@ static struct scsi_host_template mv_sht = {
290 .ordered_flush = 1, 377 .ordered_flush = 1,
291}; 378};
292 379
293static const struct ata_port_operations mv_ops = { 380static const struct ata_port_operations mv5_ops = {
381 .port_disable = ata_port_disable,
382
383 .tf_load = ata_tf_load,
384 .tf_read = ata_tf_read,
385 .check_status = ata_check_status,
386 .exec_command = ata_exec_command,
387 .dev_select = ata_std_dev_select,
388
389 .phy_reset = mv_phy_reset,
390
391 .qc_prep = mv_qc_prep,
392 .qc_issue = mv_qc_issue,
393
394 .eng_timeout = mv_eng_timeout,
395
396 .irq_handler = mv_interrupt,
397 .irq_clear = mv_irq_clear,
398
399 .scr_read = mv5_scr_read,
400 .scr_write = mv5_scr_write,
401
402 .port_start = mv_port_start,
403 .port_stop = mv_port_stop,
404 .host_stop = mv_host_stop,
405};
406
407static const struct ata_port_operations mv6_ops = {
294 .port_disable = ata_port_disable, 408 .port_disable = ata_port_disable,
295 409
296 .tf_load = ata_tf_load, 410 .tf_load = ata_tf_load,
@@ -322,43 +436,52 @@ static struct ata_port_info mv_port_info[] = {
322 .sht = &mv_sht, 436 .sht = &mv_sht,
323 .host_flags = MV_COMMON_FLAGS, 437 .host_flags = MV_COMMON_FLAGS,
324 .pio_mask = 0x1f, /* pio0-4 */ 438 .pio_mask = 0x1f, /* pio0-4 */
325 .udma_mask = 0, /* 0x7f (udma0-6 disabled for now) */ 439 .udma_mask = 0x7f, /* udma0-6 */
326 .port_ops = &mv_ops, 440 .port_ops = &mv5_ops,
327 }, 441 },
328 { /* chip_508x */ 442 { /* chip_508x */
329 .sht = &mv_sht, 443 .sht = &mv_sht,
330 .host_flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC), 444 .host_flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC),
331 .pio_mask = 0x1f, /* pio0-4 */ 445 .pio_mask = 0x1f, /* pio0-4 */
332 .udma_mask = 0, /* 0x7f (udma0-6 disabled for now) */ 446 .udma_mask = 0x7f, /* udma0-6 */
333 .port_ops = &mv_ops, 447 .port_ops = &mv5_ops,
448 },
449 { /* chip_5080 */
450 .sht = &mv_sht,
451 .host_flags = (MV_COMMON_FLAGS | MV_FLAG_DUAL_HC),
452 .pio_mask = 0x1f, /* pio0-4 */
453 .udma_mask = 0x7f, /* udma0-6 */
454 .port_ops = &mv5_ops,
334 }, 455 },
335 { /* chip_604x */ 456 { /* chip_604x */
336 .sht = &mv_sht, 457 .sht = &mv_sht,
337 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS), 458 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS),
338 .pio_mask = 0x1f, /* pio0-4 */ 459 .pio_mask = 0x1f, /* pio0-4 */
339 .udma_mask = 0x7f, /* udma0-6 */ 460 .udma_mask = 0x7f, /* udma0-6 */
340 .port_ops = &mv_ops, 461 .port_ops = &mv6_ops,
341 }, 462 },
342 { /* chip_608x */ 463 { /* chip_608x */
343 .sht = &mv_sht, 464 .sht = &mv_sht,
344 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS | 465 .host_flags = (MV_COMMON_FLAGS | MV_6XXX_FLAGS |
345 MV_FLAG_DUAL_HC), 466 MV_FLAG_DUAL_HC),
346 .pio_mask = 0x1f, /* pio0-4 */ 467 .pio_mask = 0x1f, /* pio0-4 */
347 .udma_mask = 0x7f, /* udma0-6 */ 468 .udma_mask = 0x7f, /* udma0-6 */
348 .port_ops = &mv_ops, 469 .port_ops = &mv6_ops,
349 }, 470 },
350}; 471};
351 472
352static struct pci_device_id mv_pci_tbl[] = { 473static const struct pci_device_id mv_pci_tbl[] = {
353 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5040), 0, 0, chip_504x}, 474 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5040), 0, 0, chip_504x},
354 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5041), 0, 0, chip_504x}, 475 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5041), 0, 0, chip_504x},
355 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5080), 0, 0, chip_508x}, 476 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5080), 0, 0, chip_5080},
356 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5081), 0, 0, chip_508x}, 477 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5081), 0, 0, chip_508x},
357 478
358 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6040), 0, 0, chip_604x}, 479 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6040), 0, 0, chip_604x},
359 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6041), 0, 0, chip_604x}, 480 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6041), 0, 0, chip_604x},
360 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6080), 0, 0, chip_608x}, 481 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6080), 0, 0, chip_608x},
361 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6081), 0, 0, chip_608x}, 482 {PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x6081), 0, 0, chip_608x},
483
484 {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x0241), 0, 0, chip_604x},
362 {} /* terminate list */ 485 {} /* terminate list */
363}; 486};
364 487
@@ -369,6 +492,24 @@ static struct pci_driver mv_pci_driver = {
369 .remove = ata_pci_remove_one, 492 .remove = ata_pci_remove_one,
370}; 493};
371 494
495static const struct mv_hw_ops mv5xxx_ops = {
496 .phy_errata = mv5_phy_errata,
497 .enable_leds = mv5_enable_leds,
498 .read_preamp = mv5_read_preamp,
499 .reset_hc = mv5_reset_hc,
500 .reset_flash = mv5_reset_flash,
501 .reset_bus = mv5_reset_bus,
502};
503
504static const struct mv_hw_ops mv6xxx_ops = {
505 .phy_errata = mv6_phy_errata,
506 .enable_leds = mv6_enable_leds,
507 .read_preamp = mv6_read_preamp,
508 .reset_hc = mv6_reset_hc,
509 .reset_flash = mv6_reset_flash,
510 .reset_bus = mv_reset_pci_bus,
511};
512
372/* 513/*
373 * Functions 514 * Functions
374 */ 515 */
@@ -384,11 +525,27 @@ static inline void __iomem *mv_hc_base(void __iomem *base, unsigned int hc)
384 return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ)); 525 return (base + MV_SATAHC0_REG_BASE + (hc * MV_SATAHC_REG_SZ));
385} 526}
386 527
528static inline unsigned int mv_hc_from_port(unsigned int port)
529{
530 return port >> MV_PORT_HC_SHIFT;
531}
532
533static inline unsigned int mv_hardport_from_port(unsigned int port)
534{
535 return port & MV_PORT_MASK;
536}
537
538static inline void __iomem *mv_hc_base_from_port(void __iomem *base,
539 unsigned int port)
540{
541 return mv_hc_base(base, mv_hc_from_port(port));
542}
543
387static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port) 544static inline void __iomem *mv_port_base(void __iomem *base, unsigned int port)
388{ 545{
389 return (mv_hc_base(base, port >> MV_PORT_HC_SHIFT) + 546 return mv_hc_base_from_port(base, port) +
390 MV_SATAHC_ARBTR_REG_SZ + 547 MV_SATAHC_ARBTR_REG_SZ +
391 ((port & MV_PORT_MASK) * MV_PORT_REG_SZ)); 548 (mv_hardport_from_port(port) * MV_PORT_REG_SZ);
392} 549}
393 550
394static inline void __iomem *mv_ap_base(struct ata_port *ap) 551static inline void __iomem *mv_ap_base(struct ata_port *ap)
@@ -396,9 +553,9 @@ static inline void __iomem *mv_ap_base(struct ata_port *ap)
396 return mv_port_base(ap->host_set->mmio_base, ap->port_no); 553 return mv_port_base(ap->host_set->mmio_base, ap->port_no);
397} 554}
398 555
399static inline int mv_get_hc_count(unsigned long hp_flags) 556static inline int mv_get_hc_count(unsigned long host_flags)
400{ 557{
401 return ((hp_flags & MV_FLAG_DUAL_HC) ? 2 : 1); 558 return ((host_flags & MV_FLAG_DUAL_HC) ? 2 : 1);
402} 559}
403 560
404static void mv_irq_clear(struct ata_port *ap) 561static void mv_irq_clear(struct ata_port *ap)
@@ -450,7 +607,7 @@ static void mv_stop_dma(struct ata_port *ap)
450 } else { 607 } else {
451 assert(!(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS))); 608 assert(!(EDMA_EN & readl(port_mmio + EDMA_CMD_OFS)));
452 } 609 }
453 610
454 /* now properly wait for the eDMA to stop */ 611 /* now properly wait for the eDMA to stop */
455 for (i = 1000; i > 0; i--) { 612 for (i = 1000; i > 0; i--) {
456 reg = readl(port_mmio + EDMA_CMD_OFS); 613 reg = readl(port_mmio + EDMA_CMD_OFS);
@@ -501,7 +658,7 @@ static void mv_dump_all_regs(void __iomem *mmio_base, int port,
501 struct pci_dev *pdev) 658 struct pci_dev *pdev)
502{ 659{
503#ifdef ATA_DEBUG 660#ifdef ATA_DEBUG
504 void __iomem *hc_base = mv_hc_base(mmio_base, 661 void __iomem *hc_base = mv_hc_base(mmio_base,
505 port >> MV_PORT_HC_SHIFT); 662 port >> MV_PORT_HC_SHIFT);
506 void __iomem *port_base; 663 void __iomem *port_base;
507 int start_port, num_ports, p, start_hc, num_hcs, hc; 664 int start_port, num_ports, p, start_hc, num_hcs, hc;
@@ -515,7 +672,7 @@ static void mv_dump_all_regs(void __iomem *mmio_base, int port,
515 start_port = port; 672 start_port = port;
516 num_ports = num_hcs = 1; 673 num_ports = num_hcs = 1;
517 } 674 }
518 DPRINTK("All registers for port(s) %u-%u:\n", start_port, 675 DPRINTK("All registers for port(s) %u-%u:\n", start_port,
519 num_ports > 1 ? num_ports - 1 : start_port); 676 num_ports > 1 ? num_ports - 1 : start_port);
520 677
521 if (NULL != pdev) { 678 if (NULL != pdev) {
@@ -583,70 +740,6 @@ static void mv_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
583} 740}
584 741
585/** 742/**
586 * mv_global_soft_reset - Perform the 6xxx global soft reset
587 * @mmio_base: base address of the HBA
588 *
589 * This routine only applies to 6xxx parts.
590 *
591 * LOCKING:
592 * Inherited from caller.
593 */
594static int mv_global_soft_reset(void __iomem *mmio_base)
595{
596 void __iomem *reg = mmio_base + PCI_MAIN_CMD_STS_OFS;
597 int i, rc = 0;
598 u32 t;
599
600 /* Following procedure defined in PCI "main command and status
601 * register" table.
602 */
603 t = readl(reg);
604 writel(t | STOP_PCI_MASTER, reg);
605
606 for (i = 0; i < 1000; i++) {
607 udelay(1);
608 t = readl(reg);
609 if (PCI_MASTER_EMPTY & t) {
610 break;
611 }
612 }
613 if (!(PCI_MASTER_EMPTY & t)) {
614 printk(KERN_ERR DRV_NAME ": PCI master won't flush\n");
615 rc = 1;
616 goto done;
617 }
618
619 /* set reset */
620 i = 5;
621 do {
622 writel(t | GLOB_SFT_RST, reg);
623 t = readl(reg);
624 udelay(1);
625 } while (!(GLOB_SFT_RST & t) && (i-- > 0));
626
627 if (!(GLOB_SFT_RST & t)) {
628 printk(KERN_ERR DRV_NAME ": can't set global reset\n");
629 rc = 1;
630 goto done;
631 }
632
633 /* clear reset and *reenable the PCI master* (not mentioned in spec) */
634 i = 5;
635 do {
636 writel(t & ~(GLOB_SFT_RST | STOP_PCI_MASTER), reg);
637 t = readl(reg);
638 udelay(1);
639 } while ((GLOB_SFT_RST & t) && (i-- > 0));
640
641 if (GLOB_SFT_RST & t) {
642 printk(KERN_ERR DRV_NAME ": can't clear global reset\n");
643 rc = 1;
644 }
645done:
646 return rc;
647}
648
649/**
650 * mv_host_stop - Host specific cleanup/stop routine. 743 * mv_host_stop - Host specific cleanup/stop routine.
651 * @host_set: host data structure 744 * @host_set: host data structure
652 * 745 *
@@ -699,7 +792,7 @@ static int mv_port_start(struct ata_port *ap)
699 goto err_out; 792 goto err_out;
700 memset(pp, 0, sizeof(*pp)); 793 memset(pp, 0, sizeof(*pp));
701 794
702 mem = dma_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma, 795 mem = dma_alloc_coherent(dev, MV_PORT_PRIV_DMA_SZ, &mem_dma,
703 GFP_KERNEL); 796 GFP_KERNEL);
704 if (!mem) 797 if (!mem)
705 goto err_out_pp; 798 goto err_out_pp;
@@ -709,7 +802,7 @@ static int mv_port_start(struct ata_port *ap)
709 if (rc) 802 if (rc)
710 goto err_out_priv; 803 goto err_out_priv;
711 804
712 /* First item in chunk of DMA memory: 805 /* First item in chunk of DMA memory:
713 * 32-slot command request table (CRQB), 32 bytes each in size 806 * 32-slot command request table (CRQB), 32 bytes each in size
714 */ 807 */
715 pp->crqb = mem; 808 pp->crqb = mem;
@@ -717,7 +810,7 @@ static int mv_port_start(struct ata_port *ap)
717 mem += MV_CRQB_Q_SZ; 810 mem += MV_CRQB_Q_SZ;
718 mem_dma += MV_CRQB_Q_SZ; 811 mem_dma += MV_CRQB_Q_SZ;
719 812
720 /* Second item: 813 /* Second item:
721 * 32-slot command response table (CRPB), 8 bytes each in size 814 * 32-slot command response table (CRPB), 8 bytes each in size
722 */ 815 */
723 pp->crpb = mem; 816 pp->crpb = mem;
@@ -731,18 +824,18 @@ static int mv_port_start(struct ata_port *ap)
731 pp->sg_tbl = mem; 824 pp->sg_tbl = mem;
732 pp->sg_tbl_dma = mem_dma; 825 pp->sg_tbl_dma = mem_dma;
733 826
734 writelfl(EDMA_CFG_Q_DEPTH | EDMA_CFG_RD_BRST_EXT | 827 writelfl(EDMA_CFG_Q_DEPTH | EDMA_CFG_RD_BRST_EXT |
735 EDMA_CFG_WR_BUFF_LEN, port_mmio + EDMA_CFG_OFS); 828 EDMA_CFG_WR_BUFF_LEN, port_mmio + EDMA_CFG_OFS);
736 829
737 writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS); 830 writel((pp->crqb_dma >> 16) >> 16, port_mmio + EDMA_REQ_Q_BASE_HI_OFS);
738 writelfl(pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK, 831 writelfl(pp->crqb_dma & EDMA_REQ_Q_BASE_LO_MASK,
739 port_mmio + EDMA_REQ_Q_IN_PTR_OFS); 832 port_mmio + EDMA_REQ_Q_IN_PTR_OFS);
740 833
741 writelfl(0, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS); 834 writelfl(0, port_mmio + EDMA_REQ_Q_OUT_PTR_OFS);
742 writelfl(0, port_mmio + EDMA_RSP_Q_IN_PTR_OFS); 835 writelfl(0, port_mmio + EDMA_RSP_Q_IN_PTR_OFS);
743 836
744 writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS); 837 writel((pp->crpb_dma >> 16) >> 16, port_mmio + EDMA_RSP_Q_BASE_HI_OFS);
745 writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK, 838 writelfl(pp->crpb_dma & EDMA_RSP_Q_BASE_LO_MASK,
746 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 839 port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
747 840
748 pp->req_producer = pp->rsp_consumer = 0; 841 pp->req_producer = pp->rsp_consumer = 0;
@@ -803,20 +896,30 @@ static void mv_fill_sg(struct ata_queued_cmd *qc)
803 struct scatterlist *sg; 896 struct scatterlist *sg;
804 897
805 ata_for_each_sg(sg, qc) { 898 ata_for_each_sg(sg, qc) {
806 u32 sg_len;
807 dma_addr_t addr; 899 dma_addr_t addr;
900 u32 sg_len, len, offset;
808 901
809 addr = sg_dma_address(sg); 902 addr = sg_dma_address(sg);
810 sg_len = sg_dma_len(sg); 903 sg_len = sg_dma_len(sg);
811 904
812 pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff); 905 while (sg_len) {
813 pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16); 906 offset = addr & MV_DMA_BOUNDARY;
814 assert(0 == (sg_len & ~MV_DMA_BOUNDARY)); 907 len = sg_len;
815 pp->sg_tbl[i].flags_size = cpu_to_le32(sg_len); 908 if ((offset + sg_len) > 0x10000)
816 if (ata_sg_is_last(sg, qc)) 909 len = 0x10000 - offset;
817 pp->sg_tbl[i].flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL); 910
911 pp->sg_tbl[i].addr = cpu_to_le32(addr & 0xffffffff);
912 pp->sg_tbl[i].addr_hi = cpu_to_le32((addr >> 16) >> 16);
913 pp->sg_tbl[i].flags_size = cpu_to_le32(len);
914
915 sg_len -= len;
916 addr += len;
917
918 if (!sg_len && ata_sg_is_last(sg, qc))
919 pp->sg_tbl[i].flags_size |= cpu_to_le32(EPRD_FLAG_END_OF_TBL);
818 920
819 i++; 921 i++;
922 }
820 } 923 }
821} 924}
822 925
@@ -857,7 +960,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
857 } 960 }
858 961
859 /* the req producer index should be the same as we remember it */ 962 /* the req producer index should be the same as we remember it */
860 assert(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >> 963 assert(((readl(mv_ap_base(qc->ap) + EDMA_REQ_Q_IN_PTR_OFS) >>
861 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == 964 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
862 pp->req_producer); 965 pp->req_producer);
863 966
@@ -869,9 +972,9 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
869 assert(MV_MAX_Q_DEPTH > qc->tag); 972 assert(MV_MAX_Q_DEPTH > qc->tag);
870 flags |= qc->tag << CRQB_TAG_SHIFT; 973 flags |= qc->tag << CRQB_TAG_SHIFT;
871 974
872 pp->crqb[pp->req_producer].sg_addr = 975 pp->crqb[pp->req_producer].sg_addr =
873 cpu_to_le32(pp->sg_tbl_dma & 0xffffffff); 976 cpu_to_le32(pp->sg_tbl_dma & 0xffffffff);
874 pp->crqb[pp->req_producer].sg_addr_hi = 977 pp->crqb[pp->req_producer].sg_addr_hi =
875 cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16); 978 cpu_to_le32((pp->sg_tbl_dma >> 16) >> 16);
876 pp->crqb[pp->req_producer].ctrl_flags = cpu_to_le16(flags); 979 pp->crqb[pp->req_producer].ctrl_flags = cpu_to_le16(flags);
877 980
@@ -894,7 +997,7 @@ static void mv_qc_prep(struct ata_queued_cmd *qc)
894#ifdef LIBATA_NCQ /* FIXME: remove this line when NCQ added */ 997#ifdef LIBATA_NCQ /* FIXME: remove this line when NCQ added */
895 case ATA_CMD_FPDMA_READ: 998 case ATA_CMD_FPDMA_READ:
896 case ATA_CMD_FPDMA_WRITE: 999 case ATA_CMD_FPDMA_WRITE:
897 mv_crqb_pack_cmd(cw++, tf->hob_feature, ATA_REG_FEATURE, 0); 1000 mv_crqb_pack_cmd(cw++, tf->hob_feature, ATA_REG_FEATURE, 0);
898 mv_crqb_pack_cmd(cw++, tf->feature, ATA_REG_FEATURE, 0); 1001 mv_crqb_pack_cmd(cw++, tf->feature, ATA_REG_FEATURE, 0);
899 break; 1002 break;
900#endif /* FIXME: remove this line when NCQ added */ 1003#endif /* FIXME: remove this line when NCQ added */
@@ -960,7 +1063,7 @@ static int mv_qc_issue(struct ata_queued_cmd *qc)
960 pp->req_producer); 1063 pp->req_producer);
961 /* until we do queuing, the queue should be empty at this point */ 1064 /* until we do queuing, the queue should be empty at this point */
962 assert(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == 1065 assert(((in_ptr >> EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
963 ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) >> 1066 ((readl(port_mmio + EDMA_REQ_Q_OUT_PTR_OFS) >>
964 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK)); 1067 EDMA_REQ_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK));
965 1068
966 mv_inc_q_index(&pp->req_producer); /* now incr producer index */ 1069 mv_inc_q_index(&pp->req_producer); /* now incr producer index */
@@ -997,15 +1100,15 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
997 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS); 1100 out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
998 1101
999 /* the response consumer index should be the same as we remember it */ 1102 /* the response consumer index should be the same as we remember it */
1000 assert(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == 1103 assert(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
1001 pp->rsp_consumer); 1104 pp->rsp_consumer);
1002 1105
1003 /* increment our consumer index... */ 1106 /* increment our consumer index... */
1004 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer); 1107 pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer);
1005 1108
1006 /* and, until we do NCQ, there should only be 1 CRPB waiting */ 1109 /* and, until we do NCQ, there should only be 1 CRPB waiting */
1007 assert(((readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) >> 1110 assert(((readl(port_mmio + EDMA_RSP_Q_IN_PTR_OFS) >>
1008 EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) == 1111 EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) ==
1009 pp->rsp_consumer); 1112 pp->rsp_consumer);
1010 1113
1011 /* write out our inc'd consumer index so EDMA knows we're caught up */ 1114 /* write out our inc'd consumer index so EDMA knows we're caught up */
@@ -1053,7 +1156,7 @@ static void mv_err_intr(struct ata_port *ap)
1053 1156
1054 /* check for fatal here and recover if needed */ 1157 /* check for fatal here and recover if needed */
1055 if (EDMA_ERR_FATAL & edma_err_cause) { 1158 if (EDMA_ERR_FATAL & edma_err_cause) {
1056 mv_phy_reset(ap); 1159 mv_stop_and_reset(ap);
1057 } 1160 }
1058} 1161}
1059 1162
@@ -1118,6 +1221,10 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1118 handled++; 1221 handled++;
1119 } 1222 }
1120 1223
1224 if (ap &&
1225 (ap->flags & (ATA_FLAG_PORT_DISABLED | ATA_FLAG_NOINTR)))
1226 continue;
1227
1121 err_mask = ac_err_mask(ata_status); 1228 err_mask = ac_err_mask(ata_status);
1122 1229
1123 shift = port << 1; /* (port * 2) */ 1230 shift = port << 1; /* (port * 2) */
@@ -1129,14 +1236,15 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1129 err_mask |= AC_ERR_OTHER; 1236 err_mask |= AC_ERR_OTHER;
1130 handled++; 1237 handled++;
1131 } 1238 }
1132 1239
1133 if (handled && ap) { 1240 if (handled && ap) {
1134 qc = ata_qc_from_tag(ap, ap->active_tag); 1241 qc = ata_qc_from_tag(ap, ap->active_tag);
1135 if (NULL != qc) { 1242 if (NULL != qc) {
1136 VPRINTK("port %u IRQ found for qc, " 1243 VPRINTK("port %u IRQ found for qc, "
1137 "ata_status 0x%x\n", port,ata_status); 1244 "ata_status 0x%x\n", port,ata_status);
1138 /* mark qc status appropriately */ 1245 /* mark qc status appropriately */
1139 ata_qc_complete(qc, err_mask); 1246 if (!(qc->tf.ctl & ATA_NIEN))
1247 ata_qc_complete(qc, err_mask);
1140 } 1248 }
1141 } 1249 }
1142 } 1250 }
@@ -1144,7 +1252,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1144} 1252}
1145 1253
1146/** 1254/**
1147 * mv_interrupt - 1255 * mv_interrupt -
1148 * @irq: unused 1256 * @irq: unused
1149 * @dev_instance: private data; in this case the host structure 1257 * @dev_instance: private data; in this case the host structure
1150 * @regs: unused 1258 * @regs: unused
@@ -1154,7 +1262,7 @@ static void mv_host_intr(struct ata_host_set *host_set, u32 relevant,
1154 * routine to handle. Also check for PCI errors which are only 1262 * routine to handle. Also check for PCI errors which are only
1155 * reported here. 1263 * reported here.
1156 * 1264 *
1157 * LOCKING: 1265 * LOCKING:
1158 * This routine holds the host_set lock while processing pending 1266 * This routine holds the host_set lock while processing pending
1159 * interrupts. 1267 * interrupts.
1160 */ 1268 */
@@ -1200,8 +1308,422 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1200 return IRQ_RETVAL(handled); 1308 return IRQ_RETVAL(handled);
1201} 1309}
1202 1310
1311static void __iomem *mv5_phy_base(void __iomem *mmio, unsigned int port)
1312{
1313 void __iomem *hc_mmio = mv_hc_base_from_port(mmio, port);
1314 unsigned long ofs = (mv_hardport_from_port(port) + 1) * 0x100UL;
1315
1316 return hc_mmio + ofs;
1317}
1318
1319static unsigned int mv5_scr_offset(unsigned int sc_reg_in)
1320{
1321 unsigned int ofs;
1322
1323 switch (sc_reg_in) {
1324 case SCR_STATUS:
1325 case SCR_ERROR:
1326 case SCR_CONTROL:
1327 ofs = sc_reg_in * sizeof(u32);
1328 break;
1329 default:
1330 ofs = 0xffffffffU;
1331 break;
1332 }
1333 return ofs;
1334}
1335
1336static u32 mv5_scr_read(struct ata_port *ap, unsigned int sc_reg_in)
1337{
1338 void __iomem *mmio = mv5_phy_base(ap->host_set->mmio_base, ap->port_no);
1339 unsigned int ofs = mv5_scr_offset(sc_reg_in);
1340
1341 if (ofs != 0xffffffffU)
1342 return readl(mmio + ofs);
1343 else
1344 return (u32) ofs;
1345}
1346
1347static void mv5_scr_write(struct ata_port *ap, unsigned int sc_reg_in, u32 val)
1348{
1349 void __iomem *mmio = mv5_phy_base(ap->host_set->mmio_base, ap->port_no);
1350 unsigned int ofs = mv5_scr_offset(sc_reg_in);
1351
1352 if (ofs != 0xffffffffU)
1353 writelfl(val, mmio + ofs);
1354}
1355
1356static void mv5_reset_bus(struct pci_dev *pdev, void __iomem *mmio)
1357{
1358 u8 rev_id;
1359 int early_5080;
1360
1361 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
1362
1363 early_5080 = (pdev->device == 0x5080) && (rev_id == 0);
1364
1365 if (!early_5080) {
1366 u32 tmp = readl(mmio + MV_PCI_EXP_ROM_BAR_CTL);
1367 tmp |= (1 << 0);
1368 writel(tmp, mmio + MV_PCI_EXP_ROM_BAR_CTL);
1369 }
1370
1371 mv_reset_pci_bus(pdev, mmio);
1372}
1373
1374static void mv5_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio)
1375{
1376 writel(0x0fcfffff, mmio + MV_FLASH_CTL);
1377}
1378
1379static void mv5_read_preamp(struct mv_host_priv *hpriv, int idx,
1380 void __iomem *mmio)
1381{
1382 void __iomem *phy_mmio = mv5_phy_base(mmio, idx);
1383 u32 tmp;
1384
1385 tmp = readl(phy_mmio + MV5_PHY_MODE);
1386
1387 hpriv->signal[idx].pre = tmp & 0x1800; /* bits 12:11 */
1388 hpriv->signal[idx].amps = tmp & 0xe0; /* bits 7:5 */
1389}
1390
1391static void mv5_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio)
1392{
1393 u32 tmp;
1394
1395 writel(0, mmio + MV_GPIO_PORT_CTL);
1396
1397 /* FIXME: handle MV_HP_ERRATA_50XXB2 errata */
1398
1399 tmp = readl(mmio + MV_PCI_EXP_ROM_BAR_CTL);
1400 tmp |= ~(1 << 0);
1401 writel(tmp, mmio + MV_PCI_EXP_ROM_BAR_CTL);
1402}
1403
1404static void mv5_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio,
1405 unsigned int port)
1406{
1407 void __iomem *phy_mmio = mv5_phy_base(mmio, port);
1408 const u32 mask = (1<<12) | (1<<11) | (1<<7) | (1<<6) | (1<<5);
1409 u32 tmp;
1410 int fix_apm_sq = (hpriv->hp_flags & MV_HP_ERRATA_50XXB0);
1411
1412 if (fix_apm_sq) {
1413 tmp = readl(phy_mmio + MV5_LT_MODE);
1414 tmp |= (1 << 19);
1415 writel(tmp, phy_mmio + MV5_LT_MODE);
1416
1417 tmp = readl(phy_mmio + MV5_PHY_CTL);
1418 tmp &= ~0x3;
1419 tmp |= 0x1;
1420 writel(tmp, phy_mmio + MV5_PHY_CTL);
1421 }
1422
1423 tmp = readl(phy_mmio + MV5_PHY_MODE);
1424 tmp &= ~mask;
1425 tmp |= hpriv->signal[port].pre;
1426 tmp |= hpriv->signal[port].amps;
1427 writel(tmp, phy_mmio + MV5_PHY_MODE);
1428}
1429
1430
1431#undef ZERO
1432#define ZERO(reg) writel(0, port_mmio + (reg))
1433static void mv5_reset_hc_port(struct mv_host_priv *hpriv, void __iomem *mmio,
1434 unsigned int port)
1435{
1436 void __iomem *port_mmio = mv_port_base(mmio, port);
1437
1438 writelfl(EDMA_DS, port_mmio + EDMA_CMD_OFS);
1439
1440 mv_channel_reset(hpriv, mmio, port);
1441
1442 ZERO(0x028); /* command */
1443 writel(0x11f, port_mmio + EDMA_CFG_OFS);
1444 ZERO(0x004); /* timer */
1445 ZERO(0x008); /* irq err cause */
1446 ZERO(0x00c); /* irq err mask */
1447 ZERO(0x010); /* rq bah */
1448 ZERO(0x014); /* rq inp */
1449 ZERO(0x018); /* rq outp */
1450 ZERO(0x01c); /* respq bah */
1451 ZERO(0x024); /* respq outp */
1452 ZERO(0x020); /* respq inp */
1453 ZERO(0x02c); /* test control */
1454 writel(0xbc, port_mmio + EDMA_IORDY_TMOUT);
1455}
1456#undef ZERO
1457
1458#define ZERO(reg) writel(0, hc_mmio + (reg))
1459static void mv5_reset_one_hc(struct mv_host_priv *hpriv, void __iomem *mmio,
1460 unsigned int hc)
1461{
1462 void __iomem *hc_mmio = mv_hc_base(mmio, hc);
1463 u32 tmp;
1464
1465 ZERO(0x00c);
1466 ZERO(0x010);
1467 ZERO(0x014);
1468 ZERO(0x018);
1469
1470 tmp = readl(hc_mmio + 0x20);
1471 tmp &= 0x1c1c1c1c;
1472 tmp |= 0x03030303;
1473 writel(tmp, hc_mmio + 0x20);
1474}
1475#undef ZERO
1476
1477static int mv5_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio,
1478 unsigned int n_hc)
1479{
1480 unsigned int hc, port;
1481
1482 for (hc = 0; hc < n_hc; hc++) {
1483 for (port = 0; port < MV_PORTS_PER_HC; port++)
1484 mv5_reset_hc_port(hpriv, mmio,
1485 (hc * MV_PORTS_PER_HC) + port);
1486
1487 mv5_reset_one_hc(hpriv, mmio, hc);
1488 }
1489
1490 return 0;
1491}
1492
1493#undef ZERO
1494#define ZERO(reg) writel(0, mmio + (reg))
1495static void mv_reset_pci_bus(struct pci_dev *pdev, void __iomem *mmio)
1496{
1497 u32 tmp;
1498
1499 tmp = readl(mmio + MV_PCI_MODE);
1500 tmp &= 0xff00ffff;
1501 writel(tmp, mmio + MV_PCI_MODE);
1502
1503 ZERO(MV_PCI_DISC_TIMER);
1504 ZERO(MV_PCI_MSI_TRIGGER);
1505 writel(0x000100ff, mmio + MV_PCI_XBAR_TMOUT);
1506 ZERO(HC_MAIN_IRQ_MASK_OFS);
1507 ZERO(MV_PCI_SERR_MASK);
1508 ZERO(PCI_IRQ_CAUSE_OFS);
1509 ZERO(PCI_IRQ_MASK_OFS);
1510 ZERO(MV_PCI_ERR_LOW_ADDRESS);
1511 ZERO(MV_PCI_ERR_HIGH_ADDRESS);
1512 ZERO(MV_PCI_ERR_ATTRIBUTE);
1513 ZERO(MV_PCI_ERR_COMMAND);
1514}
1515#undef ZERO
1516
1517static void mv6_reset_flash(struct mv_host_priv *hpriv, void __iomem *mmio)
1518{
1519 u32 tmp;
1520
1521 mv5_reset_flash(hpriv, mmio);
1522
1523 tmp = readl(mmio + MV_GPIO_PORT_CTL);
1524 tmp &= 0x3;
1525 tmp |= (1 << 5) | (1 << 6);
1526 writel(tmp, mmio + MV_GPIO_PORT_CTL);
1527}
1528
1529/**
1530 * mv6_reset_hc - Perform the 6xxx global soft reset
1531 * @mmio: base address of the HBA
1532 *
1533 * This routine only applies to 6xxx parts.
1534 *
1535 * LOCKING:
1536 * Inherited from caller.
1537 */
1538static int mv6_reset_hc(struct mv_host_priv *hpriv, void __iomem *mmio,
1539 unsigned int n_hc)
1540{
1541 void __iomem *reg = mmio + PCI_MAIN_CMD_STS_OFS;
1542 int i, rc = 0;
1543 u32 t;
1544
1545 /* Following procedure defined in PCI "main command and status
1546 * register" table.
1547 */
1548 t = readl(reg);
1549 writel(t | STOP_PCI_MASTER, reg);
1550
1551 for (i = 0; i < 1000; i++) {
1552 udelay(1);
1553 t = readl(reg);
1554 if (PCI_MASTER_EMPTY & t) {
1555 break;
1556 }
1557 }
1558 if (!(PCI_MASTER_EMPTY & t)) {
1559 printk(KERN_ERR DRV_NAME ": PCI master won't flush\n");
1560 rc = 1;
1561 goto done;
1562 }
1563
1564 /* set reset */
1565 i = 5;
1566 do {
1567 writel(t | GLOB_SFT_RST, reg);
1568 t = readl(reg);
1569 udelay(1);
1570 } while (!(GLOB_SFT_RST & t) && (i-- > 0));
1571
1572 if (!(GLOB_SFT_RST & t)) {
1573 printk(KERN_ERR DRV_NAME ": can't set global reset\n");
1574 rc = 1;
1575 goto done;
1576 }
1577
1578 /* clear reset and *reenable the PCI master* (not mentioned in spec) */
1579 i = 5;
1580 do {
1581 writel(t & ~(GLOB_SFT_RST | STOP_PCI_MASTER), reg);
1582 t = readl(reg);
1583 udelay(1);
1584 } while ((GLOB_SFT_RST & t) && (i-- > 0));
1585
1586 if (GLOB_SFT_RST & t) {
1587 printk(KERN_ERR DRV_NAME ": can't clear global reset\n");
1588 rc = 1;
1589 }
1590done:
1591 return rc;
1592}
1593
1594static void mv6_read_preamp(struct mv_host_priv *hpriv, int idx,
1595 void __iomem *mmio)
1596{
1597 void __iomem *port_mmio;
1598 u32 tmp;
1599
1600 tmp = readl(mmio + MV_RESET_CFG);
1601 if ((tmp & (1 << 0)) == 0) {
1602 hpriv->signal[idx].amps = 0x7 << 8;
1603 hpriv->signal[idx].pre = 0x1 << 5;
1604 return;
1605 }
1606
1607 port_mmio = mv_port_base(mmio, idx);
1608 tmp = readl(port_mmio + PHY_MODE2);
1609
1610 hpriv->signal[idx].amps = tmp & 0x700; /* bits 10:8 */
1611 hpriv->signal[idx].pre = tmp & 0xe0; /* bits 7:5 */
1612}
1613
1614static void mv6_enable_leds(struct mv_host_priv *hpriv, void __iomem *mmio)
1615{
1616 writel(0x00000060, mmio + MV_GPIO_PORT_CTL);
1617}
1618
1619static void mv6_phy_errata(struct mv_host_priv *hpriv, void __iomem *mmio,
1620 unsigned int port)
1621{
1622 void __iomem *port_mmio = mv_port_base(mmio, port);
1623
1624 u32 hp_flags = hpriv->hp_flags;
1625 int fix_phy_mode2 =
1626 hp_flags & (MV_HP_ERRATA_60X1B2 | MV_HP_ERRATA_60X1C0);
1627 int fix_phy_mode4 =
1628 hp_flags & (MV_HP_ERRATA_60X1B2 | MV_HP_ERRATA_60X1C0);
1629 u32 m2, tmp;
1630
1631 if (fix_phy_mode2) {
1632 m2 = readl(port_mmio + PHY_MODE2);
1633 m2 &= ~(1 << 16);
1634 m2 |= (1 << 31);
1635 writel(m2, port_mmio + PHY_MODE2);
1636
1637 udelay(200);
1638
1639 m2 = readl(port_mmio + PHY_MODE2);
1640 m2 &= ~((1 << 16) | (1 << 31));
1641 writel(m2, port_mmio + PHY_MODE2);
1642
1643 udelay(200);
1644 }
1645
1646 /* who knows what this magic does */
1647 tmp = readl(port_mmio + PHY_MODE3);
1648 tmp &= ~0x7F800000;
1649 tmp |= 0x2A800000;
1650 writel(tmp, port_mmio + PHY_MODE3);
1651
1652 if (fix_phy_mode4) {
1653 u32 m4;
1654
1655 m4 = readl(port_mmio + PHY_MODE4);
1656
1657 if (hp_flags & MV_HP_ERRATA_60X1B2)
1658 tmp = readl(port_mmio + 0x310);
1659
1660 m4 = (m4 & ~(1 << 1)) | (1 << 0);
1661
1662 writel(m4, port_mmio + PHY_MODE4);
1663
1664 if (hp_flags & MV_HP_ERRATA_60X1B2)
1665 writel(tmp, port_mmio + 0x310);
1666 }
1667
1668 /* Revert values of pre-emphasis and signal amps to the saved ones */
1669 m2 = readl(port_mmio + PHY_MODE2);
1670
1671 m2 &= ~MV_M2_PREAMP_MASK;
1672 m2 |= hpriv->signal[port].amps;
1673 m2 |= hpriv->signal[port].pre;
1674 m2 &= ~(1 << 16);
1675
1676 writel(m2, port_mmio + PHY_MODE2);
1677}
1678
1679static void mv_channel_reset(struct mv_host_priv *hpriv, void __iomem *mmio,
1680 unsigned int port_no)
1681{
1682 void __iomem *port_mmio = mv_port_base(mmio, port_no);
1683
1684 writelfl(ATA_RST, port_mmio + EDMA_CMD_OFS);
1685
1686 if (IS_60XX(hpriv)) {
1687 u32 ifctl = readl(port_mmio + SATA_INTERFACE_CTL);
1688 ifctl |= (1 << 12) | (1 << 7);
1689 writelfl(ifctl, port_mmio + SATA_INTERFACE_CTL);
1690 }
1691
1692 udelay(25); /* allow reset propagation */
1693
1694 /* Spec never mentions clearing the bit. Marvell's driver does
1695 * clear the bit, however.
1696 */
1697 writelfl(0, port_mmio + EDMA_CMD_OFS);
1698
1699 hpriv->ops->phy_errata(hpriv, mmio, port_no);
1700
1701 if (IS_50XX(hpriv))
1702 mdelay(1);
1703}
1704
1705static void mv_stop_and_reset(struct ata_port *ap)
1706{
1707 struct mv_host_priv *hpriv = ap->host_set->private_data;
1708 void __iomem *mmio = ap->host_set->mmio_base;
1709
1710 mv_stop_dma(ap);
1711
1712 mv_channel_reset(hpriv, mmio, ap->port_no);
1713
1714 __mv_phy_reset(ap, 0);
1715}
1716
1717static inline void __msleep(unsigned int msec, int can_sleep)
1718{
1719 if (can_sleep)
1720 msleep(msec);
1721 else
1722 mdelay(msec);
1723}
1724
1203/** 1725/**
1204 * mv_phy_reset - Perform eDMA reset followed by COMRESET 1726 * __mv_phy_reset - Perform eDMA reset followed by COMRESET
1205 * @ap: ATA channel to manipulate 1727 * @ap: ATA channel to manipulate
1206 * 1728 *
1207 * Part of this is taken from __sata_phy_reset and modified to 1729 * Part of this is taken from __sata_phy_reset and modified to
@@ -1211,41 +1733,47 @@ static irqreturn_t mv_interrupt(int irq, void *dev_instance,
1211 * Inherited from caller. This is coded to safe to call at 1733 * Inherited from caller. This is coded to safe to call at
1212 * interrupt level, i.e. it does not sleep. 1734 * interrupt level, i.e. it does not sleep.
1213 */ 1735 */
1214static void mv_phy_reset(struct ata_port *ap) 1736static void __mv_phy_reset(struct ata_port *ap, int can_sleep)
1215{ 1737{
1738 struct mv_port_priv *pp = ap->private_data;
1739 struct mv_host_priv *hpriv = ap->host_set->private_data;
1216 void __iomem *port_mmio = mv_ap_base(ap); 1740 void __iomem *port_mmio = mv_ap_base(ap);
1217 struct ata_taskfile tf; 1741 struct ata_taskfile tf;
1218 struct ata_device *dev = &ap->device[0]; 1742 struct ata_device *dev = &ap->device[0];
1219 unsigned long timeout; 1743 unsigned long timeout;
1744 int retry = 5;
1745 u32 sstatus;
1220 1746
1221 VPRINTK("ENTER, port %u, mmio 0x%p\n", ap->port_no, port_mmio); 1747 VPRINTK("ENTER, port %u, mmio 0x%p\n", ap->port_no, port_mmio);
1222 1748
1223 mv_stop_dma(ap); 1749 DPRINTK("S-regs after ATA_RST: SStat 0x%08x SErr 0x%08x "
1224
1225 writelfl(ATA_RST, port_mmio + EDMA_CMD_OFS);
1226 udelay(25); /* allow reset propagation */
1227
1228 /* Spec never mentions clearing the bit. Marvell's driver does
1229 * clear the bit, however.
1230 */
1231 writelfl(0, port_mmio + EDMA_CMD_OFS);
1232
1233 VPRINTK("S-regs after ATA_RST: SStat 0x%08x SErr 0x%08x "
1234 "SCtrl 0x%08x\n", mv_scr_read(ap, SCR_STATUS), 1750 "SCtrl 0x%08x\n", mv_scr_read(ap, SCR_STATUS),
1235 mv_scr_read(ap, SCR_ERROR), mv_scr_read(ap, SCR_CONTROL)); 1751 mv_scr_read(ap, SCR_ERROR), mv_scr_read(ap, SCR_CONTROL));
1236 1752
1237 /* proceed to init communications via the scr_control reg */ 1753 /* Issue COMRESET via SControl */
1754comreset_retry:
1238 scr_write_flush(ap, SCR_CONTROL, 0x301); 1755 scr_write_flush(ap, SCR_CONTROL, 0x301);
1239 mdelay(1); 1756 __msleep(1, can_sleep);
1757
1240 scr_write_flush(ap, SCR_CONTROL, 0x300); 1758 scr_write_flush(ap, SCR_CONTROL, 0x300);
1241 timeout = jiffies + (HZ * 1); 1759 __msleep(20, can_sleep);
1760
1761 timeout = jiffies + msecs_to_jiffies(200);
1242 do { 1762 do {
1243 mdelay(10); 1763 sstatus = scr_read(ap, SCR_STATUS) & 0x3;
1244 if ((scr_read(ap, SCR_STATUS) & 0xf) != 1) 1764 if ((sstatus == 3) || (sstatus == 0))
1245 break; 1765 break;
1766
1767 __msleep(1, can_sleep);
1246 } while (time_before(jiffies, timeout)); 1768 } while (time_before(jiffies, timeout));
1247 1769
1248 VPRINTK("S-regs after PHY wake: SStat 0x%08x SErr 0x%08x " 1770 /* work around errata */
1771 if (IS_60XX(hpriv) &&
1772 (sstatus != 0x0) && (sstatus != 0x113) && (sstatus != 0x123) &&
1773 (retry-- > 0))
1774 goto comreset_retry;
1775
1776 DPRINTK("S-regs after PHY wake: SStat 0x%08x SErr 0x%08x "
1249 "SCtrl 0x%08x\n", mv_scr_read(ap, SCR_STATUS), 1777 "SCtrl 0x%08x\n", mv_scr_read(ap, SCR_STATUS),
1250 mv_scr_read(ap, SCR_ERROR), mv_scr_read(ap, SCR_CONTROL)); 1778 mv_scr_read(ap, SCR_ERROR), mv_scr_read(ap, SCR_CONTROL));
1251 1779
@@ -1259,6 +1787,21 @@ static void mv_phy_reset(struct ata_port *ap)
1259 } 1787 }
1260 ap->cbl = ATA_CBL_SATA; 1788 ap->cbl = ATA_CBL_SATA;
1261 1789
1790 /* even after SStatus reflects that device is ready,
1791 * it seems to take a while for link to be fully
1792 * established (and thus Status no longer 0x80/0x7F),
1793 * so we poll a bit for that, here.
1794 */
1795 retry = 20;
1796 while (1) {
1797 u8 drv_stat = ata_check_status(ap);
1798 if ((drv_stat != 0x80) && (drv_stat != 0x7f))
1799 break;
1800 __msleep(500, can_sleep);
1801 if (retry-- <= 0)
1802 break;
1803 }
1804
1262 tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr); 1805 tf.lbah = readb((void __iomem *) ap->ioaddr.lbah_addr);
1263 tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr); 1806 tf.lbam = readb((void __iomem *) ap->ioaddr.lbam_addr);
1264 tf.lbal = readb((void __iomem *) ap->ioaddr.lbal_addr); 1807 tf.lbal = readb((void __iomem *) ap->ioaddr.lbal_addr);
@@ -1269,9 +1812,19 @@ static void mv_phy_reset(struct ata_port *ap)
1269 VPRINTK("Port disabled post-sig: No device present.\n"); 1812 VPRINTK("Port disabled post-sig: No device present.\n");
1270 ata_port_disable(ap); 1813 ata_port_disable(ap);
1271 } 1814 }
1815
1816 writelfl(0, port_mmio + EDMA_ERR_IRQ_CAUSE_OFS);
1817
1818 pp->pp_flags &= ~MV_PP_FLAG_EDMA_EN;
1819
1272 VPRINTK("EXIT\n"); 1820 VPRINTK("EXIT\n");
1273} 1821}
1274 1822
1823static void mv_phy_reset(struct ata_port *ap)
1824{
1825 __mv_phy_reset(ap, 1);
1826}
1827
1275/** 1828/**
1276 * mv_eng_timeout - Routine called by libata when SCSI times out I/O 1829 * mv_eng_timeout - Routine called by libata when SCSI times out I/O
1277 * @ap: ATA channel to manipulate 1830 * @ap: ATA channel to manipulate
@@ -1289,16 +1842,16 @@ static void mv_eng_timeout(struct ata_port *ap)
1289 1842
1290 printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id); 1843 printk(KERN_ERR "ata%u: Entering mv_eng_timeout\n",ap->id);
1291 DPRINTK("All regs @ start of eng_timeout\n"); 1844 DPRINTK("All regs @ start of eng_timeout\n");
1292 mv_dump_all_regs(ap->host_set->mmio_base, ap->port_no, 1845 mv_dump_all_regs(ap->host_set->mmio_base, ap->port_no,
1293 to_pci_dev(ap->host_set->dev)); 1846 to_pci_dev(ap->host_set->dev));
1294 1847
1295 qc = ata_qc_from_tag(ap, ap->active_tag); 1848 qc = ata_qc_from_tag(ap, ap->active_tag);
1296 printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n", 1849 printk(KERN_ERR "mmio_base %p ap %p qc %p scsi_cmnd %p &cmnd %p\n",
1297 ap->host_set->mmio_base, ap, qc, qc->scsicmd, 1850 ap->host_set->mmio_base, ap, qc, qc->scsicmd,
1298 &qc->scsicmd->cmnd); 1851 &qc->scsicmd->cmnd);
1299 1852
1300 mv_err_intr(ap); 1853 mv_err_intr(ap);
1301 mv_phy_reset(ap); 1854 mv_stop_and_reset(ap);
1302 1855
1303 if (!qc) { 1856 if (!qc) {
1304 printk(KERN_ERR "ata%u: BUG: timeout without command\n", 1857 printk(KERN_ERR "ata%u: BUG: timeout without command\n",
@@ -1334,17 +1887,17 @@ static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio)
1334 unsigned long shd_base = (unsigned long) port_mmio + SHD_BLK_OFS; 1887 unsigned long shd_base = (unsigned long) port_mmio + SHD_BLK_OFS;
1335 unsigned serr_ofs; 1888 unsigned serr_ofs;
1336 1889
1337 /* PIO related setup 1890 /* PIO related setup
1338 */ 1891 */
1339 port->data_addr = shd_base + (sizeof(u32) * ATA_REG_DATA); 1892 port->data_addr = shd_base + (sizeof(u32) * ATA_REG_DATA);
1340 port->error_addr = 1893 port->error_addr =
1341 port->feature_addr = shd_base + (sizeof(u32) * ATA_REG_ERR); 1894 port->feature_addr = shd_base + (sizeof(u32) * ATA_REG_ERR);
1342 port->nsect_addr = shd_base + (sizeof(u32) * ATA_REG_NSECT); 1895 port->nsect_addr = shd_base + (sizeof(u32) * ATA_REG_NSECT);
1343 port->lbal_addr = shd_base + (sizeof(u32) * ATA_REG_LBAL); 1896 port->lbal_addr = shd_base + (sizeof(u32) * ATA_REG_LBAL);
1344 port->lbam_addr = shd_base + (sizeof(u32) * ATA_REG_LBAM); 1897 port->lbam_addr = shd_base + (sizeof(u32) * ATA_REG_LBAM);
1345 port->lbah_addr = shd_base + (sizeof(u32) * ATA_REG_LBAH); 1898 port->lbah_addr = shd_base + (sizeof(u32) * ATA_REG_LBAH);
1346 port->device_addr = shd_base + (sizeof(u32) * ATA_REG_DEVICE); 1899 port->device_addr = shd_base + (sizeof(u32) * ATA_REG_DEVICE);
1347 port->status_addr = 1900 port->status_addr =
1348 port->command_addr = shd_base + (sizeof(u32) * ATA_REG_STATUS); 1901 port->command_addr = shd_base + (sizeof(u32) * ATA_REG_STATUS);
1349 /* special case: control/altstatus doesn't have ATA_REG_ address */ 1902 /* special case: control/altstatus doesn't have ATA_REG_ address */
1350 port->altstatus_addr = port->ctl_addr = shd_base + SHD_CTL_AST_OFS; 1903 port->altstatus_addr = port->ctl_addr = shd_base + SHD_CTL_AST_OFS;
@@ -1360,14 +1913,92 @@ static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio)
1360 /* unmask all EDMA error interrupts */ 1913 /* unmask all EDMA error interrupts */
1361 writelfl(~0, port_mmio + EDMA_ERR_IRQ_MASK_OFS); 1914 writelfl(~0, port_mmio + EDMA_ERR_IRQ_MASK_OFS);
1362 1915
1363 VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n", 1916 VPRINTK("EDMA cfg=0x%08x EDMA IRQ err cause/mask=0x%08x/0x%08x\n",
1364 readl(port_mmio + EDMA_CFG_OFS), 1917 readl(port_mmio + EDMA_CFG_OFS),
1365 readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS), 1918 readl(port_mmio + EDMA_ERR_IRQ_CAUSE_OFS),
1366 readl(port_mmio + EDMA_ERR_IRQ_MASK_OFS)); 1919 readl(port_mmio + EDMA_ERR_IRQ_MASK_OFS));
1367} 1920}
1368 1921
1922static int mv_chip_id(struct pci_dev *pdev, struct mv_host_priv *hpriv,
1923 unsigned int board_idx)
1924{
1925 u8 rev_id;
1926 u32 hp_flags = hpriv->hp_flags;
1927
1928 pci_read_config_byte(pdev, PCI_REVISION_ID, &rev_id);
1929
1930 switch(board_idx) {
1931 case chip_5080:
1932 hpriv->ops = &mv5xxx_ops;
1933 hp_flags |= MV_HP_50XX;
1934
1935 switch (rev_id) {
1936 case 0x1:
1937 hp_flags |= MV_HP_ERRATA_50XXB0;
1938 break;
1939 case 0x3:
1940 hp_flags |= MV_HP_ERRATA_50XXB2;
1941 break;
1942 default:
1943 dev_printk(KERN_WARNING, &pdev->dev,
1944 "Applying 50XXB2 workarounds to unknown rev\n");
1945 hp_flags |= MV_HP_ERRATA_50XXB2;
1946 break;
1947 }
1948 break;
1949
1950 case chip_504x:
1951 case chip_508x:
1952 hpriv->ops = &mv5xxx_ops;
1953 hp_flags |= MV_HP_50XX;
1954
1955 switch (rev_id) {
1956 case 0x0:
1957 hp_flags |= MV_HP_ERRATA_50XXB0;
1958 break;
1959 case 0x3:
1960 hp_flags |= MV_HP_ERRATA_50XXB2;
1961 break;
1962 default:
1963 dev_printk(KERN_WARNING, &pdev->dev,
1964 "Applying B2 workarounds to unknown rev\n");
1965 hp_flags |= MV_HP_ERRATA_50XXB2;
1966 break;
1967 }
1968 break;
1969
1970 case chip_604x:
1971 case chip_608x:
1972 hpriv->ops = &mv6xxx_ops;
1973
1974 switch (rev_id) {
1975 case 0x7:
1976 hp_flags |= MV_HP_ERRATA_60X1B2;
1977 break;
1978 case 0x9:
1979 hp_flags |= MV_HP_ERRATA_60X1C0;
1980 break;
1981 default:
1982 dev_printk(KERN_WARNING, &pdev->dev,
1983 "Applying B2 workarounds to unknown rev\n");
1984 hp_flags |= MV_HP_ERRATA_60X1B2;
1985 break;
1986 }
1987 break;
1988
1989 default:
1990 printk(KERN_ERR DRV_NAME ": BUG: invalid board index %u\n", board_idx);
1991 return 1;
1992 }
1993
1994 hpriv->hp_flags = hp_flags;
1995
1996 return 0;
1997}
1998
1369/** 1999/**
1370 * mv_host_init - Perform some early initialization of the host. 2000 * mv_init_host - Perform some early initialization of the host.
2001 * @pdev: host PCI device
1371 * @probe_ent: early data struct representing the host 2002 * @probe_ent: early data struct representing the host
1372 * 2003 *
1373 * If possible, do an early global reset of the host. Then do 2004 * If possible, do an early global reset of the host. Then do
@@ -1376,23 +2007,48 @@ static void mv_port_init(struct ata_ioports *port, void __iomem *port_mmio)
1376 * LOCKING: 2007 * LOCKING:
1377 * Inherited from caller. 2008 * Inherited from caller.
1378 */ 2009 */
1379static int mv_host_init(struct ata_probe_ent *probe_ent) 2010static int mv_init_host(struct pci_dev *pdev, struct ata_probe_ent *probe_ent,
2011 unsigned int board_idx)
1380{ 2012{
1381 int rc = 0, n_hc, port, hc; 2013 int rc = 0, n_hc, port, hc;
1382 void __iomem *mmio = probe_ent->mmio_base; 2014 void __iomem *mmio = probe_ent->mmio_base;
1383 void __iomem *port_mmio; 2015 struct mv_host_priv *hpriv = probe_ent->private_data;
1384 2016
1385 if ((MV_FLAG_GLBL_SFT_RST & probe_ent->host_flags) && 2017 /* global interrupt mask */
1386 mv_global_soft_reset(probe_ent->mmio_base)) { 2018 writel(0, mmio + HC_MAIN_IRQ_MASK_OFS);
1387 rc = 1; 2019
2020 rc = mv_chip_id(pdev, hpriv, board_idx);
2021 if (rc)
1388 goto done; 2022 goto done;
1389 }
1390 2023
1391 n_hc = mv_get_hc_count(probe_ent->host_flags); 2024 n_hc = mv_get_hc_count(probe_ent->host_flags);
1392 probe_ent->n_ports = MV_PORTS_PER_HC * n_hc; 2025 probe_ent->n_ports = MV_PORTS_PER_HC * n_hc;
1393 2026
2027 for (port = 0; port < probe_ent->n_ports; port++)
2028 hpriv->ops->read_preamp(hpriv, port, mmio);
2029
2030 rc = hpriv->ops->reset_hc(hpriv, mmio, n_hc);
2031 if (rc)
2032 goto done;
2033
2034 hpriv->ops->reset_flash(hpriv, mmio);
2035 hpriv->ops->reset_bus(pdev, mmio);
2036 hpriv->ops->enable_leds(hpriv, mmio);
2037
1394 for (port = 0; port < probe_ent->n_ports; port++) { 2038 for (port = 0; port < probe_ent->n_ports; port++) {
1395 port_mmio = mv_port_base(mmio, port); 2039 if (IS_60XX(hpriv)) {
2040 void __iomem *port_mmio = mv_port_base(mmio, port);
2041
2042 u32 ifctl = readl(port_mmio + SATA_INTERFACE_CTL);
2043 ifctl |= (1 << 12);
2044 writelfl(ifctl, port_mmio + SATA_INTERFACE_CTL);
2045 }
2046
2047 hpriv->ops->phy_errata(hpriv, mmio, port);
2048 }
2049
2050 for (port = 0; port < probe_ent->n_ports; port++) {
2051 void __iomem *port_mmio = mv_port_base(mmio, port);
1396 mv_port_init(&probe_ent->port[port], port_mmio); 2052 mv_port_init(&probe_ent->port[port], port_mmio);
1397 } 2053 }
1398 2054
@@ -1416,11 +2072,12 @@ static int mv_host_init(struct ata_probe_ent *probe_ent)
1416 writelfl(~HC_MAIN_MASKED_IRQS, mmio + HC_MAIN_IRQ_MASK_OFS); 2072 writelfl(~HC_MAIN_MASKED_IRQS, mmio + HC_MAIN_IRQ_MASK_OFS);
1417 2073
1418 VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x " 2074 VPRINTK("HC MAIN IRQ cause/mask=0x%08x/0x%08x "
1419 "PCI int cause/mask=0x%08x/0x%08x\n", 2075 "PCI int cause/mask=0x%08x/0x%08x\n",
1420 readl(mmio + HC_MAIN_IRQ_CAUSE_OFS), 2076 readl(mmio + HC_MAIN_IRQ_CAUSE_OFS),
1421 readl(mmio + HC_MAIN_IRQ_MASK_OFS), 2077 readl(mmio + HC_MAIN_IRQ_MASK_OFS),
1422 readl(mmio + PCI_IRQ_CAUSE_OFS), 2078 readl(mmio + PCI_IRQ_CAUSE_OFS),
1423 readl(mmio + PCI_IRQ_MASK_OFS)); 2079 readl(mmio + PCI_IRQ_MASK_OFS));
2080
1424done: 2081done:
1425 return rc; 2082 return rc;
1426} 2083}
@@ -1456,7 +2113,7 @@ static void mv_print_info(struct ata_probe_ent *probe_ent)
1456 2113
1457 dev_printk(KERN_INFO, &pdev->dev, 2114 dev_printk(KERN_INFO, &pdev->dev,
1458 "%u slots %u ports %s mode IRQ via %s\n", 2115 "%u slots %u ports %s mode IRQ via %s\n",
1459 (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports, 2116 (unsigned)MV_MAX_Q_DEPTH, probe_ent->n_ports,
1460 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx"); 2117 scc_s, (MV_HP_FLAG_MSI & hpriv->hp_flags) ? "MSI" : "INTx");
1461} 2118}
1462 2119
@@ -1526,7 +2183,7 @@ static int mv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1526 probe_ent->private_data = hpriv; 2183 probe_ent->private_data = hpriv;
1527 2184
1528 /* initialize adapter */ 2185 /* initialize adapter */
1529 rc = mv_host_init(probe_ent); 2186 rc = mv_init_host(pdev, probe_ent, board_idx);
1530 if (rc) { 2187 if (rc) {
1531 goto err_out_hpriv; 2188 goto err_out_hpriv;
1532 } 2189 }
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index 37a4fae95ed4..4954896dfdb9 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -137,7 +137,7 @@ enum nv_host_type
137 CK804 137 CK804
138}; 138};
139 139
140static struct pci_device_id nv_pci_tbl[] = { 140static const struct pci_device_id nv_pci_tbl[] = {
141 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA, 141 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA,
142 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 }, 142 PCI_ANY_ID, PCI_ANY_ID, 0, 0, NFORCE2 },
143 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA, 143 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA,
diff --git a/drivers/scsi/sata_promise.c b/drivers/scsi/sata_promise.c
index 9edc9d91efc3..2691625f9bce 100644
--- a/drivers/scsi/sata_promise.c
+++ b/drivers/scsi/sata_promise.c
@@ -46,7 +46,7 @@
46#include "sata_promise.h" 46#include "sata_promise.h"
47 47
48#define DRV_NAME "sata_promise" 48#define DRV_NAME "sata_promise"
49#define DRV_VERSION "1.02" 49#define DRV_VERSION "1.03"
50 50
51 51
52enum { 52enum {
@@ -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
@@ -162,8 +165,7 @@ static struct ata_port_info pdc_port_info[] = {
162 /* board_2037x */ 165 /* board_2037x */
163 { 166 {
164 .sht = &pdc_ata_sht, 167 .sht = &pdc_ata_sht,
165 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 168 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
166 ATA_FLAG_SRST | ATA_FLAG_MMIO,
167 .pio_mask = 0x1f, /* pio0-4 */ 169 .pio_mask = 0x1f, /* pio0-4 */
168 .mwdma_mask = 0x07, /* mwdma0-2 */ 170 .mwdma_mask = 0x07, /* mwdma0-2 */
169 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 171 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -173,8 +175,7 @@ static struct ata_port_info pdc_port_info[] = {
173 /* board_20319 */ 175 /* board_20319 */
174 { 176 {
175 .sht = &pdc_ata_sht, 177 .sht = &pdc_ata_sht,
176 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 178 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SATA,
177 ATA_FLAG_SRST | ATA_FLAG_MMIO,
178 .pio_mask = 0x1f, /* pio0-4 */ 179 .pio_mask = 0x1f, /* pio0-4 */
179 .mwdma_mask = 0x07, /* mwdma0-2 */ 180 .mwdma_mask = 0x07, /* mwdma0-2 */
180 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 181 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -184,8 +185,7 @@ static struct ata_port_info pdc_port_info[] = {
184 /* board_20619 */ 185 /* board_20619 */
185 { 186 {
186 .sht = &pdc_ata_sht, 187 .sht = &pdc_ata_sht,
187 .host_flags = ATA_FLAG_NO_LEGACY | ATA_FLAG_SRST | 188 .host_flags = PDC_COMMON_FLAGS | ATA_FLAG_SLAVE_POSS,
188 ATA_FLAG_MMIO | ATA_FLAG_SLAVE_POSS,
189 .pio_mask = 0x1f, /* pio0-4 */ 189 .pio_mask = 0x1f, /* pio0-4 */
190 .mwdma_mask = 0x07, /* mwdma0-2 */ 190 .mwdma_mask = 0x07, /* mwdma0-2 */
191 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 191 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -193,7 +193,7 @@ static struct ata_port_info pdc_port_info[] = {
193 }, 193 },
194}; 194};
195 195
196static struct pci_device_id pdc_ata_pci_tbl[] = { 196static const struct pci_device_id pdc_ata_pci_tbl[] = {
197 { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 197 { PCI_VENDOR_ID_PROMISE, 0x3371, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
198 board_2037x }, 198 board_2037x },
199 { PCI_VENDOR_ID_PROMISE, 0x3570, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 199 { PCI_VENDOR_ID_PROMISE, 0x3570, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
diff --git a/drivers/scsi/sata_qstor.c b/drivers/scsi/sata_qstor.c
index d274ab235781..a8987f5ff5cc 100644
--- a/drivers/scsi/sata_qstor.c
+++ b/drivers/scsi/sata_qstor.c
@@ -41,7 +41,7 @@
41#include <linux/libata.h> 41#include <linux/libata.h>
42 42
43#define DRV_NAME "sata_qstor" 43#define DRV_NAME "sata_qstor"
44#define DRV_VERSION "0.04" 44#define DRV_VERSION "0.05"
45 45
46enum { 46enum {
47 QS_PORTS = 4, 47 QS_PORTS = 4,
@@ -184,7 +184,7 @@ static struct ata_port_info qs_port_info[] = {
184 }, 184 },
185}; 185};
186 186
187static struct pci_device_id qs_ata_pci_tbl[] = { 187static const struct pci_device_id qs_ata_pci_tbl[] = {
188 { PCI_VENDOR_ID_PDC, 0x2068, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 188 { PCI_VENDOR_ID_PDC, 0x2068, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
189 board_2068_idx }, 189 board_2068_idx },
190 190
@@ -268,7 +268,7 @@ static void qs_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
268 writel(val, (void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8))); 268 writel(val, (void __iomem *)(ap->ioaddr.scr_addr + (sc_reg * 8)));
269} 269}
270 270
271static void qs_fill_sg(struct ata_queued_cmd *qc) 271static unsigned int qs_fill_sg(struct ata_queued_cmd *qc)
272{ 272{
273 struct scatterlist *sg; 273 struct scatterlist *sg;
274 struct ata_port *ap = qc->ap; 274 struct ata_port *ap = qc->ap;
@@ -296,6 +296,8 @@ static void qs_fill_sg(struct ata_queued_cmd *qc)
296 (unsigned long long)addr, len); 296 (unsigned long long)addr, len);
297 nelem++; 297 nelem++;
298 } 298 }
299
300 return nelem;
299} 301}
300 302
301static void qs_qc_prep(struct ata_queued_cmd *qc) 303static void qs_qc_prep(struct ata_queued_cmd *qc)
@@ -304,6 +306,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
304 u8 dflags = QS_DF_PORD, *buf = pp->pkt; 306 u8 dflags = QS_DF_PORD, *buf = pp->pkt;
305 u8 hflags = QS_HF_DAT | QS_HF_IEN | QS_HF_VLD; 307 u8 hflags = QS_HF_DAT | QS_HF_IEN | QS_HF_VLD;
306 u64 addr; 308 u64 addr;
309 unsigned int nelem;
307 310
308 VPRINTK("ENTER\n"); 311 VPRINTK("ENTER\n");
309 312
@@ -313,7 +316,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
313 return; 316 return;
314 } 317 }
315 318
316 qs_fill_sg(qc); 319 nelem = qs_fill_sg(qc);
317 320
318 if ((qc->tf.flags & ATA_TFLAG_WRITE)) 321 if ((qc->tf.flags & ATA_TFLAG_WRITE))
319 hflags |= QS_HF_DIRO; 322 hflags |= QS_HF_DIRO;
@@ -324,7 +327,7 @@ static void qs_qc_prep(struct ata_queued_cmd *qc)
324 buf[ 0] = QS_HCB_HDR; 327 buf[ 0] = QS_HCB_HDR;
325 buf[ 1] = hflags; 328 buf[ 1] = hflags;
326 *(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nsect * ATA_SECT_SIZE); 329 *(__le32 *)(&buf[ 4]) = cpu_to_le32(qc->nsect * ATA_SECT_SIZE);
327 *(__le32 *)(&buf[ 8]) = cpu_to_le32(qc->n_elem); 330 *(__le32 *)(&buf[ 8]) = cpu_to_le32(nelem);
328 addr = ((u64)pp->pkt_dma) + QS_CPB_BYTES; 331 addr = ((u64)pp->pkt_dma) + QS_CPB_BYTES;
329 *(__le64 *)(&buf[16]) = cpu_to_le64(addr); 332 *(__le64 *)(&buf[16]) = cpu_to_le64(addr);
330 333
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index d0e3c3c6c25f..36091868560d 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -87,7 +87,7 @@ static void sil_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
87static void sil_post_set_mode (struct ata_port *ap); 87static void sil_post_set_mode (struct ata_port *ap);
88 88
89 89
90static struct pci_device_id sil_pci_tbl[] = { 90static const struct pci_device_id sil_pci_tbl[] = {
91 { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, 91 { 0x1095, 0x3112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
92 { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w }, 92 { 0x1095, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112_m15w },
93 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 }, 93 { 0x1095, 0x3512, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sil_3112 },
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 4682a50650b4..e0d6f194f54f 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -5,17 +5,6 @@
5 * 5 *
6 * Based on preview driver from Silicon Image. 6 * Based on preview driver from Silicon Image.
7 * 7 *
8 * NOTE: No NCQ/ATAPI support yet. The preview driver didn't support
9 * NCQ nor ATAPI, and, unfortunately, I couldn't find out how to make
10 * those work. Enabling those shouldn't be difficult. Basic
11 * structure is all there (in libata-dev tree). If you have any
12 * information about this hardware, please contact me or linux-ide.
13 * Info is needed on...
14 *
15 * - How to issue tagged commands and turn on sactive on issue accordingly.
16 * - Where to put an ATAPI command and how to tell the device to send it.
17 * - How to enable/use 64bit.
18 *
19 * This program is free software; you can redistribute it and/or modify it 8 * 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 9 * 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 10 * Free Software Foundation; either version 2, or (at your option) any
@@ -42,7 +31,7 @@
42#include <asm/io.h> 31#include <asm/io.h>
43 32
44#define DRV_NAME "sata_sil24" 33#define DRV_NAME "sata_sil24"
45#define DRV_VERSION "0.22" /* Silicon Image's preview driver was 0.10 */ 34#define DRV_VERSION "0.23"
46 35
47/* 36/*
48 * Port request block (PRB) 32 bytes 37 * Port request block (PRB) 32 bytes
@@ -139,6 +128,7 @@ enum {
139 PORT_CS_DEV_RST = (1 << 1), /* device reset */ 128 PORT_CS_DEV_RST = (1 << 1), /* device reset */
140 PORT_CS_INIT = (1 << 2), /* port initialize */ 129 PORT_CS_INIT = (1 << 2), /* port initialize */
141 PORT_CS_IRQ_WOC = (1 << 3), /* interrupt write one to clear */ 130 PORT_CS_IRQ_WOC = (1 << 3), /* interrupt write one to clear */
131 PORT_CS_CDB16 = (1 << 5), /* 0=12b cdb, 1=16b cdb */
142 PORT_CS_RESUME = (1 << 6), /* port resume */ 132 PORT_CS_RESUME = (1 << 6), /* port resume */
143 PORT_CS_32BIT_ACTV = (1 << 10), /* 32-bit activation */ 133 PORT_CS_32BIT_ACTV = (1 << 10), /* 32-bit activation */
144 PORT_CS_PM_EN = (1 << 13), /* port multiplier enable */ 134 PORT_CS_PM_EN = (1 << 13), /* port multiplier enable */
@@ -188,11 +178,29 @@ enum {
188 PORT_CERR_XFR_PCIPERR = 35, /* PSD ecode 11 - PCI prity err during transfer */ 178 PORT_CERR_XFR_PCIPERR = 35, /* PSD ecode 11 - PCI prity err during transfer */
189 PORT_CERR_SENDSERVICE = 36, /* FIS received while sending service */ 179 PORT_CERR_SENDSERVICE = 36, /* FIS received while sending service */
190 180
181 /* bits of PRB control field */
182 PRB_CTRL_PROTOCOL = (1 << 0), /* override def. ATA protocol */
183 PRB_CTRL_PACKET_READ = (1 << 4), /* PACKET cmd read */
184 PRB_CTRL_PACKET_WRITE = (1 << 5), /* PACKET cmd write */
185 PRB_CTRL_NIEN = (1 << 6), /* Mask completion irq */
186 PRB_CTRL_SRST = (1 << 7), /* Soft reset request (ign BSY?) */
187
188 /* PRB protocol field */
189 PRB_PROT_PACKET = (1 << 0),
190 PRB_PROT_TCQ = (1 << 1),
191 PRB_PROT_NCQ = (1 << 2),
192 PRB_PROT_READ = (1 << 3),
193 PRB_PROT_WRITE = (1 << 4),
194 PRB_PROT_TRANSPARENT = (1 << 5),
195
191 /* 196 /*
192 * Other constants 197 * Other constants
193 */ 198 */
194 SGE_TRM = (1 << 31), /* Last SGE in chain */ 199 SGE_TRM = (1 << 31), /* Last SGE in chain */
195 PRB_SOFT_RST = (1 << 7), /* Soft reset request (ign BSY?) */ 200 SGE_LNK = (1 << 30), /* linked list
201 Points to SGT, not SGE */
202 SGE_DRD = (1 << 29), /* discard data read (/dev/null)
203 data address ignored */
196 204
197 /* board id */ 205 /* board id */
198 BID_SIL3124 = 0, 206 BID_SIL3124 = 0,
@@ -202,11 +210,22 @@ enum {
202 IRQ_STAT_4PORTS = 0xf, 210 IRQ_STAT_4PORTS = 0xf,
203}; 211};
204 212
205struct sil24_cmd_block { 213struct sil24_ata_block {
206 struct sil24_prb prb; 214 struct sil24_prb prb;
207 struct sil24_sge sge[LIBATA_MAX_PRD]; 215 struct sil24_sge sge[LIBATA_MAX_PRD];
208}; 216};
209 217
218struct sil24_atapi_block {
219 struct sil24_prb prb;
220 u8 cdb[16];
221 struct sil24_sge sge[LIBATA_MAX_PRD - 1];
222};
223
224union sil24_cmd_block {
225 struct sil24_ata_block ata;
226 struct sil24_atapi_block atapi;
227};
228
210/* 229/*
211 * ap->private_data 230 * ap->private_data
212 * 231 *
@@ -214,7 +233,7 @@ struct sil24_cmd_block {
214 * here from the previous interrupt. 233 * here from the previous interrupt.
215 */ 234 */
216struct sil24_port_priv { 235struct sil24_port_priv {
217 struct sil24_cmd_block *cmd_block; /* 32 cmd blocks */ 236 union sil24_cmd_block *cmd_block; /* 32 cmd blocks */
218 dma_addr_t cmd_block_dma; /* DMA base addr for them */ 237 dma_addr_t cmd_block_dma; /* DMA base addr for them */
219 struct ata_taskfile tf; /* Cached taskfile registers */ 238 struct ata_taskfile tf; /* Cached taskfile registers */
220}; 239};
@@ -225,6 +244,7 @@ struct sil24_host_priv {
225 void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */ 244 void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */
226}; 245};
227 246
247static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev);
228static u8 sil24_check_status(struct ata_port *ap); 248static u8 sil24_check_status(struct ata_port *ap);
229static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); 249static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg);
230static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); 250static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val);
@@ -240,7 +260,7 @@ static void sil24_port_stop(struct ata_port *ap);
240static void sil24_host_stop(struct ata_host_set *host_set); 260static void sil24_host_stop(struct ata_host_set *host_set);
241static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 261static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
242 262
243static struct pci_device_id sil24_pci_tbl[] = { 263static const struct pci_device_id sil24_pci_tbl[] = {
244 { 0x1095, 0x3124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3124 }, 264 { 0x1095, 0x3124, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3124 },
245 { 0x1095, 0x3132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3132 }, 265 { 0x1095, 0x3132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3132 },
246 { 0x1095, 0x3131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3131 }, 266 { 0x1095, 0x3131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, BID_SIL3131 },
@@ -278,6 +298,8 @@ static struct scsi_host_template sil24_sht = {
278static const struct ata_port_operations sil24_ops = { 298static const struct ata_port_operations sil24_ops = {
279 .port_disable = ata_port_disable, 299 .port_disable = ata_port_disable,
280 300
301 .dev_config = sil24_dev_config,
302
281 .check_status = sil24_check_status, 303 .check_status = sil24_check_status,
282 .check_altstatus = sil24_check_status, 304 .check_altstatus = sil24_check_status,
283 .dev_select = ata_noop_dev_select, 305 .dev_select = ata_noop_dev_select,
@@ -314,7 +336,7 @@ static struct ata_port_info sil24_port_info[] = {
314 { 336 {
315 .sht = &sil24_sht, 337 .sht = &sil24_sht,
316 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 338 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
317 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 339 ATA_FLAG_SRST | ATA_FLAG_MMIO |
318 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(4), 340 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(4),
319 .pio_mask = 0x1f, /* pio0-4 */ 341 .pio_mask = 0x1f, /* pio0-4 */
320 .mwdma_mask = 0x07, /* mwdma0-2 */ 342 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -325,7 +347,7 @@ static struct ata_port_info sil24_port_info[] = {
325 { 347 {
326 .sht = &sil24_sht, 348 .sht = &sil24_sht,
327 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 349 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
328 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 350 ATA_FLAG_SRST | ATA_FLAG_MMIO |
329 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(2), 351 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(2),
330 .pio_mask = 0x1f, /* pio0-4 */ 352 .pio_mask = 0x1f, /* pio0-4 */
331 .mwdma_mask = 0x07, /* mwdma0-2 */ 353 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -336,7 +358,7 @@ static struct ata_port_info sil24_port_info[] = {
336 { 358 {
337 .sht = &sil24_sht, 359 .sht = &sil24_sht,
338 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 360 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
339 ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 361 ATA_FLAG_SRST | ATA_FLAG_MMIO |
340 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(1), 362 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(1),
341 .pio_mask = 0x1f, /* pio0-4 */ 363 .pio_mask = 0x1f, /* pio0-4 */
342 .mwdma_mask = 0x07, /* mwdma0-2 */ 364 .mwdma_mask = 0x07, /* mwdma0-2 */
@@ -345,6 +367,16 @@ static struct ata_port_info sil24_port_info[] = {
345 }, 367 },
346}; 368};
347 369
370static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev)
371{
372 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
373
374 if (ap->cdb_len == 16)
375 writel(PORT_CS_CDB16, port + PORT_CTRL_STAT);
376 else
377 writel(PORT_CS_CDB16, port + PORT_CTRL_CLR);
378}
379
348static inline void sil24_update_tf(struct ata_port *ap) 380static inline void sil24_update_tf(struct ata_port *ap)
349{ 381{
350 struct sil24_port_priv *pp = ap->private_data; 382 struct sil24_port_priv *pp = ap->private_data;
@@ -396,22 +428,73 @@ static void sil24_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
396 *tf = pp->tf; 428 *tf = pp->tf;
397} 429}
398 430
399static void sil24_phy_reset(struct ata_port *ap) 431static int sil24_issue_SRST(struct ata_port *ap)
400{ 432{
401 __sata_phy_reset(ap); 433 void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr;
434 struct sil24_port_priv *pp = ap->private_data;
435 struct sil24_prb *prb = &pp->cmd_block[0].ata.prb;
436 dma_addr_t paddr = pp->cmd_block_dma;
437 u32 irq_enable, irq_stat;
438 int cnt;
439
440 /* temporarily turn off IRQs during SRST */
441 irq_enable = readl(port + PORT_IRQ_ENABLE_SET);
442 writel(irq_enable, port + PORT_IRQ_ENABLE_CLR);
443
402 /* 444 /*
403 * No ATAPI yet. Just unconditionally indicate ATA device. 445 * XXX: Not sure whether the following sleep is needed or not.
404 * If ATAPI device is attached, it will fail ATA_CMD_ID_ATA 446 * The original driver had it. So....
405 * and libata core will ignore the device.
406 */ 447 */
407 if (!(ap->flags & ATA_FLAG_PORT_DISABLED)) 448 msleep(10);
408 ap->device[0].class = ATA_DEV_ATA; 449
450 prb->ctrl = PRB_CTRL_SRST;
451 prb->fis[1] = 0; /* no PM yet */
452
453 writel((u32)paddr, port + PORT_CMD_ACTIVATE);
454
455 for (cnt = 0; cnt < 100; cnt++) {
456 irq_stat = readl(port + PORT_IRQ_STAT);
457 writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */
458
459 irq_stat >>= PORT_IRQ_RAW_SHIFT;
460 if (irq_stat & (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR))
461 break;
462
463 msleep(1);
464 }
465
466 /* restore IRQs */
467 writel(irq_enable, port + PORT_IRQ_ENABLE_SET);
468
469 if (!(irq_stat & PORT_IRQ_COMPLETE))
470 return -1;
471
472 /* update TF */
473 sil24_update_tf(ap);
474 return 0;
475}
476
477static void sil24_phy_reset(struct ata_port *ap)
478{
479 struct sil24_port_priv *pp = ap->private_data;
480
481 __sata_phy_reset(ap);
482 if (ap->flags & ATA_FLAG_PORT_DISABLED)
483 return;
484
485 if (sil24_issue_SRST(ap) < 0) {
486 printk(KERN_ERR DRV_NAME
487 " ata%u: SRST failed, disabling port\n", ap->id);
488 ap->ops->port_disable(ap);
489 return;
490 }
491
492 ap->device->class = ata_dev_classify(&pp->tf);
409} 493}
410 494
411static inline void sil24_fill_sg(struct ata_queued_cmd *qc, 495static inline void sil24_fill_sg(struct ata_queued_cmd *qc,
412 struct sil24_cmd_block *cb) 496 struct sil24_sge *sge)
413{ 497{
414 struct sil24_sge *sge = cb->sge;
415 struct scatterlist *sg; 498 struct scatterlist *sg;
416 unsigned int idx = 0; 499 unsigned int idx = 0;
417 500
@@ -432,23 +515,47 @@ static void sil24_qc_prep(struct ata_queued_cmd *qc)
432{ 515{
433 struct ata_port *ap = qc->ap; 516 struct ata_port *ap = qc->ap;
434 struct sil24_port_priv *pp = ap->private_data; 517 struct sil24_port_priv *pp = ap->private_data;
435 struct sil24_cmd_block *cb = pp->cmd_block + qc->tag; 518 union sil24_cmd_block *cb = pp->cmd_block + qc->tag;
436 struct sil24_prb *prb = &cb->prb; 519 struct sil24_prb *prb;
520 struct sil24_sge *sge;
437 521
438 switch (qc->tf.protocol) { 522 switch (qc->tf.protocol) {
439 case ATA_PROT_PIO: 523 case ATA_PROT_PIO:
440 case ATA_PROT_DMA: 524 case ATA_PROT_DMA:
441 case ATA_PROT_NODATA: 525 case ATA_PROT_NODATA:
526 prb = &cb->ata.prb;
527 sge = cb->ata.sge;
528 prb->ctrl = 0;
529 break;
530
531 case ATA_PROT_ATAPI:
532 case ATA_PROT_ATAPI_DMA:
533 case ATA_PROT_ATAPI_NODATA:
534 prb = &cb->atapi.prb;
535 sge = cb->atapi.sge;
536 memset(cb->atapi.cdb, 0, 32);
537 memcpy(cb->atapi.cdb, qc->cdb, ap->cdb_len);
538
539 if (qc->tf.protocol != ATA_PROT_ATAPI_NODATA) {
540 if (qc->tf.flags & ATA_TFLAG_WRITE)
541 prb->ctrl = PRB_CTRL_PACKET_WRITE;
542 else
543 prb->ctrl = PRB_CTRL_PACKET_READ;
544 } else
545 prb->ctrl = 0;
546
442 break; 547 break;
548
443 default: 549 default:
444 /* ATAPI isn't supported yet */ 550 prb = NULL; /* shut up, gcc */
551 sge = NULL;
445 BUG(); 552 BUG();
446 } 553 }
447 554
448 ata_tf_to_fis(&qc->tf, prb->fis, 0); 555 ata_tf_to_fis(&qc->tf, prb->fis, 0);
449 556
450 if (qc->flags & ATA_QCFLAG_DMAMAP) 557 if (qc->flags & ATA_QCFLAG_DMAMAP)
451 sil24_fill_sg(qc, cb); 558 sil24_fill_sg(qc, sge);
452} 559}
453 560
454static int sil24_qc_issue(struct ata_queued_cmd *qc) 561static int sil24_qc_issue(struct ata_queued_cmd *qc)
@@ -467,6 +574,31 @@ static void sil24_irq_clear(struct ata_port *ap)
467 /* unused */ 574 /* unused */
468} 575}
469 576
577static int __sil24_restart_controller(void __iomem *port)
578{
579 u32 tmp;
580 int cnt;
581
582 writel(PORT_CS_INIT, port + PORT_CTRL_STAT);
583
584 /* Max ~10ms */
585 for (cnt = 0; cnt < 10000; cnt++) {
586 tmp = readl(port + PORT_CTRL_STAT);
587 if (tmp & PORT_CS_RDY)
588 return 0;
589 udelay(1);
590 }
591
592 return -1;
593}
594
595static void sil24_restart_controller(struct ata_port *ap)
596{
597 if (__sil24_restart_controller((void __iomem *)ap->ioaddr.cmd_addr))
598 printk(KERN_ERR DRV_NAME
599 " ata%u: failed to restart controller\n", ap->id);
600}
601
470static int __sil24_reset_controller(void __iomem *port) 602static int __sil24_reset_controller(void __iomem *port)
471{ 603{
472 int cnt; 604 int cnt;
@@ -486,7 +618,11 @@ static int __sil24_reset_controller(void __iomem *port)
486 618
487 if (tmp & PORT_CS_DEV_RST) 619 if (tmp & PORT_CS_DEV_RST)
488 return -1; 620 return -1;
489 return 0; 621
622 if (tmp & PORT_CS_RDY)
623 return 0;
624
625 return __sil24_restart_controller(port);
490} 626}
491 627
492static void sil24_reset_controller(struct ata_port *ap) 628static void sil24_reset_controller(struct ata_port *ap)
@@ -548,9 +684,15 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
548 if (serror) 684 if (serror)
549 writel(serror, port + PORT_SERROR); 685 writel(serror, port + PORT_SERROR);
550 686
551 printk(KERN_ERR DRV_NAME " ata%u: error interrupt on port%d\n" 687 /*
552 " stat=0x%x irq=0x%x cmd_err=%d sstatus=0x%x serror=0x%x\n", 688 * Don't log ATAPI device errors. They're supposed to happen
553 ap->id, ap->port_no, slot_stat, irq_stat, cmd_err, sstatus, serror); 689 * and any serious errors will be logged using sense data by
690 * the SCSI layer.
691 */
692 if (ap->device[0].class != ATA_DEV_ATAPI || cmd_err > PORT_CERR_SDB)
693 printk("ata%u: error interrupt on port%d\n"
694 " stat=0x%x irq=0x%x cmd_err=%d sstatus=0x%x serror=0x%x\n",
695 ap->id, ap->port_no, slot_stat, irq_stat, cmd_err, sstatus, serror);
554 696
555 if (cmd_err == PORT_CERR_DEV || cmd_err == PORT_CERR_SDB) { 697 if (cmd_err == PORT_CERR_DEV || cmd_err == PORT_CERR_SDB) {
556 /* 698 /*
@@ -558,6 +700,7 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
558 */ 700 */
559 sil24_update_tf(ap); 701 sil24_update_tf(ap);
560 err_mask = ac_err_mask(pp->tf.command); 702 err_mask = ac_err_mask(pp->tf.command);
703 sil24_restart_controller(ap);
561 } else { 704 } else {
562 /* 705 /*
563 * Other errors. libata currently doesn't have any 706 * Other errors. libata currently doesn't have any
@@ -565,12 +708,11 @@ static void sil24_error_intr(struct ata_port *ap, u32 slot_stat)
565 * ATA_ERR. 708 * ATA_ERR.
566 */ 709 */
567 err_mask = AC_ERR_OTHER; 710 err_mask = AC_ERR_OTHER;
711 sil24_reset_controller(ap);
568 } 712 }
569 713
570 if (qc) 714 if (qc)
571 ata_qc_complete(qc, err_mask); 715 ata_qc_complete(qc, err_mask);
572
573 sil24_reset_controller(ap);
574} 716}
575 717
576static inline void sil24_host_intr(struct ata_port *ap) 718static inline void sil24_host_intr(struct ata_port *ap)
@@ -646,7 +788,7 @@ static int sil24_port_start(struct ata_port *ap)
646{ 788{
647 struct device *dev = ap->host_set->dev; 789 struct device *dev = ap->host_set->dev;
648 struct sil24_port_priv *pp; 790 struct sil24_port_priv *pp;
649 struct sil24_cmd_block *cb; 791 union sil24_cmd_block *cb;
650 size_t cb_size = sizeof(*cb); 792 size_t cb_size = sizeof(*cb);
651 dma_addr_t cb_dma; 793 dma_addr_t cb_dma;
652 int rc = -ENOMEM; 794 int rc = -ENOMEM;
@@ -687,6 +829,7 @@ static void sil24_port_stop(struct ata_port *ap)
687 struct sil24_port_priv *pp = ap->private_data; 829 struct sil24_port_priv *pp = ap->private_data;
688 830
689 sil24_cblk_free(pp, dev); 831 sil24_cblk_free(pp, dev);
832 ata_pad_free(ap, dev);
690 kfree(pp); 833 kfree(pp);
691} 834}
692 835
diff --git a/drivers/scsi/sata_sis.c b/drivers/scsi/sata_sis.c
index 42d7c4e92501..32e12620b162 100644
--- a/drivers/scsi/sata_sis.c
+++ b/drivers/scsi/sata_sis.c
@@ -67,7 +67,7 @@ static int sis_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
67static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg); 67static u32 sis_scr_read (struct ata_port *ap, unsigned int sc_reg);
68static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 68static void sis_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
69 69
70static struct pci_device_id sis_pci_tbl[] = { 70static const struct pci_device_id sis_pci_tbl[] = {
71 { PCI_VENDOR_ID_SI, 0x180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 }, 71 { PCI_VENDOR_ID_SI, 0x180, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 },
72 { PCI_VENDOR_ID_SI, 0x181, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 }, 72 { PCI_VENDOR_ID_SI, 0x181, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 },
73 { PCI_VENDOR_ID_SI, 0x182, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 }, 73 { PCI_VENDOR_ID_SI, 0x182, PCI_ANY_ID, PCI_ANY_ID, 0, 0, sis_180 },
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 9895d1caefcf..6e7f7c83a75a 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -54,7 +54,7 @@
54#endif /* CONFIG_PPC_OF */ 54#endif /* CONFIG_PPC_OF */
55 55
56#define DRV_NAME "sata_svw" 56#define DRV_NAME "sata_svw"
57#define DRV_VERSION "1.06" 57#define DRV_VERSION "1.07"
58 58
59/* Taskfile registers offsets */ 59/* Taskfile registers offsets */
60#define K2_SATA_TF_CMD_OFFSET 0x00 60#define K2_SATA_TF_CMD_OFFSET 0x00
@@ -466,7 +466,7 @@ err_out:
466 * 0x24a is device ID for BCM5785 (aka HT1000) HT southbridge integrated SATA 466 * 0x24a is device ID for BCM5785 (aka HT1000) HT southbridge integrated SATA
467 * controller 467 * controller
468 * */ 468 * */
469static struct pci_device_id k2_sata_pci_tbl[] = { 469static const struct pci_device_id k2_sata_pci_tbl[] = {
470 { 0x1166, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 470 { 0x1166, 0x0240, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
471 { 0x1166, 0x0241, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 471 { 0x1166, 0x0241, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
472 { 0x1166, 0x0242, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 }, 472 { 0x1166, 0x0242, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
diff --git a/drivers/scsi/sata_sx4.c b/drivers/scsi/sata_sx4.c
index d5a38784352b..ac7b0d819ebc 100644
--- a/drivers/scsi/sata_sx4.c
+++ b/drivers/scsi/sata_sx4.c
@@ -46,7 +46,7 @@
46#include "sata_promise.h" 46#include "sata_promise.h"
47 47
48#define DRV_NAME "sata_sx4" 48#define DRV_NAME "sata_sx4"
49#define DRV_VERSION "0.7" 49#define DRV_VERSION "0.8"
50 50
51 51
52enum { 52enum {
@@ -220,7 +220,8 @@ static struct ata_port_info pdc_port_info[] = {
220 { 220 {
221 .sht = &pdc_sata_sht, 221 .sht = &pdc_sata_sht,
222 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 222 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
223 ATA_FLAG_SRST | ATA_FLAG_MMIO, 223 ATA_FLAG_SRST | ATA_FLAG_MMIO |
224 ATA_FLAG_NO_ATAPI,
224 .pio_mask = 0x1f, /* pio0-4 */ 225 .pio_mask = 0x1f, /* pio0-4 */
225 .mwdma_mask = 0x07, /* mwdma0-2 */ 226 .mwdma_mask = 0x07, /* mwdma0-2 */
226 .udma_mask = 0x7f, /* udma0-6 ; FIXME */ 227 .udma_mask = 0x7f, /* udma0-6 ; FIXME */
@@ -229,7 +230,7 @@ static struct ata_port_info pdc_port_info[] = {
229 230
230}; 231};
231 232
232static struct pci_device_id pdc_sata_pci_tbl[] = { 233static const struct pci_device_id pdc_sata_pci_tbl[] = {
233 { PCI_VENDOR_ID_PROMISE, 0x6622, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 234 { PCI_VENDOR_ID_PROMISE, 0x6622, PCI_ANY_ID, PCI_ANY_ID, 0, 0,
234 board_20621 }, 235 board_20621 },
235 { } /* terminate list */ 236 { } /* terminate list */
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index cf0baaa4e045..b2422a0f25c8 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -55,7 +55,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
55static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg); 55static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg);
56static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 56static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
57 57
58static struct pci_device_id uli_pci_tbl[] = { 58static const struct pci_device_id uli_pci_tbl[] = {
59 { PCI_VENDOR_ID_AL, 0x5289, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5289 }, 59 { PCI_VENDOR_ID_AL, 0x5289, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5289 },
60 { PCI_VENDOR_ID_AL, 0x5287, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5287 }, 60 { PCI_VENDOR_ID_AL, 0x5287, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5287 },
61 { PCI_VENDOR_ID_AL, 0x5281, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5281 }, 61 { PCI_VENDOR_ID_AL, 0x5281, PCI_ANY_ID, PCI_ANY_ID, 0, 0, uli_5281 },
diff --git a/drivers/scsi/sata_via.c b/drivers/scsi/sata_via.c
index ab19d2ba2a4b..c76215692da2 100644
--- a/drivers/scsi/sata_via.c
+++ b/drivers/scsi/sata_via.c
@@ -75,7 +75,7 @@ static int svia_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
75static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg); 75static u32 svia_scr_read (struct ata_port *ap, unsigned int sc_reg);
76static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val); 76static void svia_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
77 77
78static struct pci_device_id svia_pci_tbl[] = { 78static const struct pci_device_id svia_pci_tbl[] = {
79 { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6420 }, 79 { 0x1106, 0x3149, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6420 },
80 { 0x1106, 0x3249, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6421 }, 80 { 0x1106, 0x3249, PCI_ANY_ID, PCI_ANY_ID, 0, 0, vt6421 },
81 81
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index ce8a2fd7da84..fcfa486965b4 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -47,7 +47,7 @@
47#include <linux/libata.h> 47#include <linux/libata.h>
48 48
49#define DRV_NAME "sata_vsc" 49#define DRV_NAME "sata_vsc"
50#define DRV_VERSION "1.0" 50#define DRV_VERSION "1.1"
51 51
52/* Interrupt register offsets (from chip base address) */ 52/* Interrupt register offsets (from chip base address) */
53#define VSC_SATA_INT_STAT_OFFSET 0x00 53#define VSC_SATA_INT_STAT_OFFSET 0x00
@@ -400,7 +400,7 @@ err_out:
400 * 0x8086/0x3200 is the Intel 31244, which is supposed to be identical 400 * 0x8086/0x3200 is the Intel 31244, which is supposed to be identical
401 * compatibility is untested as of yet 401 * compatibility is untested as of yet
402 */ 402 */
403static struct pci_device_id vsc_sata_pci_tbl[] = { 403static const struct pci_device_id vsc_sata_pci_tbl[] = {
404 { 0x1725, 0x7174, PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 }, 404 { 0x1725, 0x7174, PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 },
405 { 0x8086, 0x3200, PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 }, 405 { 0x8086, 0x3200, PCI_ANY_ID, PCI_ANY_ID, 0x10600, 0xFFFFFF, 0 },
406 { } 406 { }
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 0be60bba58d3..180676d7115a 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -265,10 +265,10 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask)
265 spin_lock_irqsave(&dev->list_lock, flags); 265 spin_lock_irqsave(&dev->list_lock, flags);
266 list_add_tail(&cmd->list, &dev->cmd_list); 266 list_add_tail(&cmd->list, &dev->cmd_list);
267 spin_unlock_irqrestore(&dev->list_lock, flags); 267 spin_unlock_irqrestore(&dev->list_lock, flags);
268 cmd->jiffies_at_alloc = jiffies;
268 } else 269 } else
269 put_device(&dev->sdev_gendev); 270 put_device(&dev->sdev_gendev);
270 271
271 cmd->jiffies_at_alloc = jiffies;
272 return cmd; 272 return cmd;
273} 273}
274EXPORT_SYMBOL(scsi_get_command); 274EXPORT_SYMBOL(scsi_get_command);
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index b61fb1295b8b..3ded9daaf4a0 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -178,7 +178,7 @@ struct sdebug_queued_cmd {
178}; 178};
179static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE]; 179static struct sdebug_queued_cmd queued_arr[SCSI_DEBUG_CANQUEUE];
180 180
181static Scsi_Host_Template sdebug_driver_template = { 181static struct scsi_host_template sdebug_driver_template = {
182 .proc_info = scsi_debug_proc_info, 182 .proc_info = scsi_debug_proc_info,
183 .name = "SCSI DEBUG", 183 .name = "SCSI DEBUG",
184 .info = scsi_debug_info, 184 .info = scsi_debug_info,
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 0c5b02d4c7f8..c0ae9e965f6f 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -417,43 +417,20 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
417} 417}
418 418
419/** 419/**
420 * scsi_eh_times_out - timeout function for error handling.
421 * @scmd: Cmd that is timing out.
422 *
423 * Notes:
424 * During error handling, the kernel thread will be sleeping waiting
425 * for some action to complete on the device. our only job is to
426 * record that it timed out, and to wake up the thread.
427 **/
428static void scsi_eh_times_out(struct scsi_cmnd *scmd)
429{
430 scmd->eh_eflags |= SCSI_EH_REC_TIMEOUT;
431 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd:%p\n", __FUNCTION__,
432 scmd));
433
434 up(scmd->device->host->eh_action);
435}
436
437/**
438 * scsi_eh_done - Completion function for error handling. 420 * scsi_eh_done - Completion function for error handling.
439 * @scmd: Cmd that is done. 421 * @scmd: Cmd that is done.
440 **/ 422 **/
441static void scsi_eh_done(struct scsi_cmnd *scmd) 423static void scsi_eh_done(struct scsi_cmnd *scmd)
442{ 424{
443 /* 425 struct completion *eh_action;
444 * if the timeout handler is already running, then just set the
445 * flag which says we finished late, and return. we have no
446 * way of stopping the timeout handler from running, so we must
447 * always defer to it.
448 */
449 if (del_timer(&scmd->eh_timeout)) {
450 scmd->request->rq_status = RQ_SCSI_DONE;
451 426
452 SCSI_LOG_ERROR_RECOVERY(3, printk("%s scmd: %p result: %x\n", 427 SCSI_LOG_ERROR_RECOVERY(3,
453 __FUNCTION__, scmd, scmd->result)); 428 printk("%s scmd: %p result: %x\n",
429 __FUNCTION__, scmd, scmd->result));
454 430
455 up(scmd->device->host->eh_action); 431 eh_action = scmd->device->host->eh_action;
456 } 432 if (eh_action)
433 complete(eh_action);
457} 434}
458 435
459/** 436/**
@@ -461,10 +438,6 @@ static void scsi_eh_done(struct scsi_cmnd *scmd)
461 * @scmd: SCSI Cmd to send. 438 * @scmd: SCSI Cmd to send.
462 * @timeout: Timeout for cmd. 439 * @timeout: Timeout for cmd.
463 * 440 *
464 * Notes:
465 * The initialization of the structures is quite a bit different in
466 * this case, and furthermore, there is a different completion handler
467 * vs scsi_dispatch_cmd.
468 * Return value: 441 * Return value:
469 * SUCCESS or FAILED or NEEDS_RETRY 442 * SUCCESS or FAILED or NEEDS_RETRY
470 **/ 443 **/
@@ -472,24 +445,16 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
472{ 445{
473 struct scsi_device *sdev = scmd->device; 446 struct scsi_device *sdev = scmd->device;
474 struct Scsi_Host *shost = sdev->host; 447 struct Scsi_Host *shost = sdev->host;
475 DECLARE_MUTEX_LOCKED(sem); 448 DECLARE_COMPLETION(done);
449 unsigned long timeleft;
476 unsigned long flags; 450 unsigned long flags;
477 int rtn = SUCCESS; 451 int rtn;
478 452
479 /*
480 * we will use a queued command if possible, otherwise we will
481 * emulate the queuing and calling of completion function ourselves.
482 */
483 if (sdev->scsi_level <= SCSI_2) 453 if (sdev->scsi_level <= SCSI_2)
484 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) | 454 scmd->cmnd[1] = (scmd->cmnd[1] & 0x1f) |
485 (sdev->lun << 5 & 0xe0); 455 (sdev->lun << 5 & 0xe0);
486 456
487 scsi_add_timer(scmd, timeout, scsi_eh_times_out); 457 shost->eh_action = &done;
488
489 /*
490 * set up the semaphore so we wait for the command to complete.
491 */
492 shost->eh_action = &sem;
493 scmd->request->rq_status = RQ_SCSI_BUSY; 458 scmd->request->rq_status = RQ_SCSI_BUSY;
494 459
495 spin_lock_irqsave(shost->host_lock, flags); 460 spin_lock_irqsave(shost->host_lock, flags);
@@ -497,47 +462,29 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
497 shost->hostt->queuecommand(scmd, scsi_eh_done); 462 shost->hostt->queuecommand(scmd, scsi_eh_done);
498 spin_unlock_irqrestore(shost->host_lock, flags); 463 spin_unlock_irqrestore(shost->host_lock, flags);
499 464
500 down(&sem); 465 timeleft = wait_for_completion_timeout(&done, timeout);
501 scsi_log_completion(scmd, SUCCESS);
502 466
467 scmd->request->rq_status = RQ_SCSI_DONE;
503 shost->eh_action = NULL; 468 shost->eh_action = NULL;
504 469
505 /* 470 scsi_log_completion(scmd, SUCCESS);
506 * see if timeout. if so, tell the host to forget about it.
507 * in other words, we don't want a callback any more.
508 */
509 if (scmd->eh_eflags & SCSI_EH_REC_TIMEOUT) {
510 scmd->eh_eflags &= ~SCSI_EH_REC_TIMEOUT;
511
512 /*
513 * as far as the low level driver is
514 * concerned, this command is still active, so
515 * we must give the low level driver a chance
516 * to abort it. (db)
517 *
518 * FIXME(eric) - we are not tracking whether we could
519 * abort a timed out command or not. not sure how
520 * we should treat them differently anyways.
521 */
522 if (shost->hostt->eh_abort_handler)
523 shost->hostt->eh_abort_handler(scmd);
524
525 scmd->request->rq_status = RQ_SCSI_DONE;
526 rtn = FAILED;
527 }
528 471
529 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd: %p, rtn:%x\n", 472 SCSI_LOG_ERROR_RECOVERY(3,
530 __FUNCTION__, scmd, rtn)); 473 printk("%s: scmd: %p, timeleft: %ld\n",
474 __FUNCTION__, scmd, timeleft));
531 475
532 /* 476 /*
533 * now examine the actual status codes to see whether the command 477 * If there is time left scsi_eh_done got called, and we will
534 * actually did complete normally. 478 * examine the actual status codes to see whether the command
479 * actually did complete normally, else tell the host to forget
480 * about this command.
535 */ 481 */
536 if (rtn == SUCCESS) { 482 if (timeleft) {
537 rtn = scsi_eh_completed_normally(scmd); 483 rtn = scsi_eh_completed_normally(scmd);
538 SCSI_LOG_ERROR_RECOVERY(3, 484 SCSI_LOG_ERROR_RECOVERY(3,
539 printk("%s: scsi_eh_completed_normally %x\n", 485 printk("%s: scsi_eh_completed_normally %x\n",
540 __FUNCTION__, rtn)); 486 __FUNCTION__, rtn));
487
541 switch (rtn) { 488 switch (rtn) {
542 case SUCCESS: 489 case SUCCESS:
543 case NEEDS_RETRY: 490 case NEEDS_RETRY:
@@ -547,6 +494,15 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout)
547 rtn = FAILED; 494 rtn = FAILED;
548 break; 495 break;
549 } 496 }
497 } else {
498 /*
499 * FIXME(eric) - we are not tracking whether we could
500 * abort a timed out command or not. not sure how
501 * we should treat them differently anyways.
502 */
503 if (shost->hostt->eh_abort_handler)
504 shost->hostt->eh_abort_handler(scmd);
505 rtn = FAILED;
550 } 506 }
551 507
552 return rtn; 508 return rtn;
@@ -1571,50 +1527,41 @@ static void scsi_unjam_host(struct Scsi_Host *shost)
1571} 1527}
1572 1528
1573/** 1529/**
1574 * scsi_error_handler - Handle errors/timeouts of SCSI cmds. 1530 * scsi_error_handler - SCSI error handler thread
1575 * @data: Host for which we are running. 1531 * @data: Host for which we are running.
1576 * 1532 *
1577 * Notes: 1533 * Notes:
1578 * This is always run in the context of a kernel thread. The idea is 1534 * This is the main error handling loop. This is run as a kernel thread
1579 * that we start this thing up when the kernel starts up (one per host 1535 * for every SCSI host and handles all error handling activity.
1580 * that we detect), and it immediately goes to sleep and waits for some
1581 * event (i.e. failure). When this takes place, we have the job of
1582 * trying to unjam the bus and restarting things.
1583 **/ 1536 **/
1584int scsi_error_handler(void *data) 1537int scsi_error_handler(void *data)
1585{ 1538{
1586 struct Scsi_Host *shost = (struct Scsi_Host *) data; 1539 struct Scsi_Host *shost = data;
1587 int rtn;
1588 1540
1589 current->flags |= PF_NOFREEZE; 1541 current->flags |= PF_NOFREEZE;
1590 1542
1591
1592 /* 1543 /*
1593 * Note - we always use TASK_INTERRUPTIBLE even if the module 1544 * We use TASK_INTERRUPTIBLE so that the thread is not
1594 * was loaded as part of the kernel. The reason is that 1545 * counted against the load average as a running process.
1595 * UNINTERRUPTIBLE would cause this thread to be counted in 1546 * We never actually get interrupted because kthread_run
1596 * the load average as a running process, and an interruptible 1547 * disables singal delivery for the created thread.
1597 * wait doesn't.
1598 */ 1548 */
1599 set_current_state(TASK_INTERRUPTIBLE); 1549 set_current_state(TASK_INTERRUPTIBLE);
1600 while (!kthread_should_stop()) { 1550 while (!kthread_should_stop()) {
1601 if (shost->host_failed == 0 || 1551 if (shost->host_failed == 0 ||
1602 shost->host_failed != shost->host_busy) { 1552 shost->host_failed != shost->host_busy) {
1603 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler" 1553 SCSI_LOG_ERROR_RECOVERY(1,
1604 " scsi_eh_%d" 1554 printk("Error handler scsi_eh_%d sleeping\n",
1605 " sleeping\n", 1555 shost->host_no));
1606 shost->host_no));
1607 schedule(); 1556 schedule();
1608 set_current_state(TASK_INTERRUPTIBLE); 1557 set_current_state(TASK_INTERRUPTIBLE);
1609 continue; 1558 continue;
1610 } 1559 }
1611 1560
1612 __set_current_state(TASK_RUNNING); 1561 __set_current_state(TASK_RUNNING);
1613 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler" 1562 SCSI_LOG_ERROR_RECOVERY(1,
1614 " scsi_eh_%d waking" 1563 printk("Error handler scsi_eh_%d waking up\n",
1615 " up\n",shost->host_no)); 1564 shost->host_no));
1616
1617 shost->eh_active = 1;
1618 1565
1619 /* 1566 /*
1620 * We have a host that is failing for some reason. Figure out 1567 * We have a host that is failing for some reason. Figure out
@@ -1622,12 +1569,10 @@ int scsi_error_handler(void *data)
1622 * If we fail, we end up taking the thing offline. 1569 * If we fail, we end up taking the thing offline.
1623 */ 1570 */
1624 if (shost->hostt->eh_strategy_handler) 1571 if (shost->hostt->eh_strategy_handler)
1625 rtn = shost->hostt->eh_strategy_handler(shost); 1572 shost->hostt->eh_strategy_handler(shost);
1626 else 1573 else
1627 scsi_unjam_host(shost); 1574 scsi_unjam_host(shost);
1628 1575
1629 shost->eh_active = 0;
1630
1631 /* 1576 /*
1632 * Note - if the above fails completely, the action is to take 1577 * Note - if the above fails completely, the action is to take
1633 * individual devices offline and flush the queue of any 1578 * individual devices offline and flush the queue of any
@@ -1638,15 +1583,10 @@ int scsi_error_handler(void *data)
1638 scsi_restart_operations(shost); 1583 scsi_restart_operations(shost);
1639 set_current_state(TASK_INTERRUPTIBLE); 1584 set_current_state(TASK_INTERRUPTIBLE);
1640 } 1585 }
1641
1642 __set_current_state(TASK_RUNNING); 1586 __set_current_state(TASK_RUNNING);
1643 1587
1644 SCSI_LOG_ERROR_RECOVERY(1, printk("Error handler scsi_eh_%d" 1588 SCSI_LOG_ERROR_RECOVERY(1,
1645 " exiting\n",shost->host_no)); 1589 printk("Error handler scsi_eh_%d exiting\n", shost->host_no));
1646
1647 /*
1648 * Make sure that nobody tries to wake us up again.
1649 */
1650 shost->ehandler = NULL; 1590 shost->ehandler = NULL;
1651 return 0; 1591 return 0;
1652} 1592}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index e40c8b66da40..dc249cb970ea 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -254,55 +254,6 @@ void scsi_do_req(struct scsi_request *sreq, const void *cmnd,
254} 254}
255EXPORT_SYMBOL(scsi_do_req); 255EXPORT_SYMBOL(scsi_do_req);
256 256
257/* This is the end routine we get to if a command was never attached
258 * to the request. Simply complete the request without changing
259 * rq_status; this will cause a DRIVER_ERROR. */
260static void scsi_wait_req_end_io(struct request *req)
261{
262 BUG_ON(!req->waiting);
263
264 complete(req->waiting);
265}
266
267void scsi_wait_req(struct scsi_request *sreq, const void *cmnd, void *buffer,
268 unsigned bufflen, int timeout, int retries)
269{
270 DECLARE_COMPLETION(wait);
271 int write = (sreq->sr_data_direction == DMA_TO_DEVICE);
272 struct request *req;
273
274 req = blk_get_request(sreq->sr_device->request_queue, write,
275 __GFP_WAIT);
276 if (bufflen && blk_rq_map_kern(sreq->sr_device->request_queue, req,
277 buffer, bufflen, __GFP_WAIT)) {
278 sreq->sr_result = DRIVER_ERROR << 24;
279 blk_put_request(req);
280 return;
281 }
282
283 req->flags |= REQ_NOMERGE;
284 req->waiting = &wait;
285 req->end_io = scsi_wait_req_end_io;
286 req->cmd_len = COMMAND_SIZE(((u8 *)cmnd)[0]);
287 req->sense = sreq->sr_sense_buffer;
288 req->sense_len = 0;
289 memcpy(req->cmd, cmnd, req->cmd_len);
290 req->timeout = timeout;
291 req->flags |= REQ_BLOCK_PC;
292 req->rq_disk = NULL;
293 blk_insert_request(sreq->sr_device->request_queue, req,
294 sreq->sr_data_direction == DMA_TO_DEVICE, NULL);
295 wait_for_completion(&wait);
296 sreq->sr_request->waiting = NULL;
297 sreq->sr_result = req->errors;
298 if (req->errors)
299 sreq->sr_result |= (DRIVER_ERROR << 24);
300
301 blk_put_request(req);
302}
303
304EXPORT_SYMBOL(scsi_wait_req);
305
306/** 257/**
307 * scsi_execute - insert request and wait for the result 258 * scsi_execute - insert request and wait for the result
308 * @sdev: scsi device 259 * @sdev: scsi device
@@ -591,10 +542,17 @@ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd)
591 542
592void scsi_next_command(struct scsi_cmnd *cmd) 543void scsi_next_command(struct scsi_cmnd *cmd)
593{ 544{
594 struct request_queue *q = cmd->device->request_queue; 545 struct scsi_device *sdev = cmd->device;
546 struct request_queue *q = sdev->request_queue;
547
548 /* need to hold a reference on the device before we let go of the cmd */
549 get_device(&sdev->sdev_gendev);
595 550
596 scsi_put_command(cmd); 551 scsi_put_command(cmd);
597 scsi_run_queue(q); 552 scsi_run_queue(q);
553
554 /* ok to remove device now */
555 put_device(&sdev->sdev_gendev);
598} 556}
599 557
600void scsi_run_host_queues(struct Scsi_Host *shost) 558void scsi_run_host_queues(struct Scsi_Host *shost)
@@ -1127,6 +1085,26 @@ static void scsi_generic_done(struct scsi_cmnd *cmd)
1127 scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0); 1085 scsi_io_completion(cmd, cmd->result == 0 ? cmd->bufflen : 0, 0);
1128} 1086}
1129 1087
1088void scsi_setup_blk_pc_cmnd(struct scsi_cmnd *cmd, int retries)
1089{
1090 struct request *req = cmd->request;
1091
1092 BUG_ON(sizeof(req->cmd) > sizeof(cmd->cmnd));
1093 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
1094 cmd->cmd_len = req->cmd_len;
1095 if (!req->data_len)
1096 cmd->sc_data_direction = DMA_NONE;
1097 else if (rq_data_dir(req) == WRITE)
1098 cmd->sc_data_direction = DMA_TO_DEVICE;
1099 else
1100 cmd->sc_data_direction = DMA_FROM_DEVICE;
1101
1102 cmd->transfersize = req->data_len;
1103 cmd->allowed = retries;
1104 cmd->timeout_per_command = req->timeout;
1105}
1106EXPORT_SYMBOL_GPL(scsi_setup_blk_pc_cmnd);
1107
1130static int scsi_prep_fn(struct request_queue *q, struct request *req) 1108static int scsi_prep_fn(struct request_queue *q, struct request *req)
1131{ 1109{
1132 struct scsi_device *sdev = q->queuedata; 1110 struct scsi_device *sdev = q->queuedata;
@@ -1262,18 +1240,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1262 goto kill; 1240 goto kill;
1263 } 1241 }
1264 } else { 1242 } else {
1265 memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd)); 1243 scsi_setup_blk_pc_cmnd(cmd, 3);
1266 cmd->cmd_len = req->cmd_len;
1267 if (rq_data_dir(req) == WRITE)
1268 cmd->sc_data_direction = DMA_TO_DEVICE;
1269 else if (req->data_len)
1270 cmd->sc_data_direction = DMA_FROM_DEVICE;
1271 else
1272 cmd->sc_data_direction = DMA_NONE;
1273
1274 cmd->transfersize = req->data_len;
1275 cmd->allowed = 3;
1276 cmd->timeout_per_command = req->timeout;
1277 cmd->done = scsi_generic_done; 1244 cmd->done = scsi_generic_done;
1278 } 1245 }
1279 } 1246 }
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index d05f778d31a8..d632d9e1493c 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -22,7 +22,6 @@ struct Scsi_Host;
22 * Scsi Error Handler Flags 22 * Scsi Error Handler Flags
23 */ 23 */
24#define SCSI_EH_CANCEL_CMD 0x0001 /* Cancel this cmd */ 24#define SCSI_EH_CANCEL_CMD 0x0001 /* Cancel this cmd */
25#define SCSI_EH_REC_TIMEOUT 0x0002 /* EH retry timed out */
26 25
27#define SCSI_SENSE_VALID(scmd) \ 26#define SCSI_SENSE_VALID(scmd) \
28 (((scmd)->sense_buffer[0] & 0x70) == 0x70) 27 (((scmd)->sense_buffer[0] & 0x70) == 0x70)
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 7eb3a2d40dc5..4e6709f448e1 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -9,7 +9,7 @@
9 * global variable (boot or module load time) settings. 9 * global variable (boot or module load time) settings.
10 * 10 *
11 * A specific LUN is scanned via an INQUIRY command; if the LUN has a 11 * A specific LUN is scanned via an INQUIRY command; if the LUN has a
12 * device attached, a Scsi_Device is allocated and setup for it. 12 * device attached, a scsi_device is allocated and setup for it.
13 * 13 *
14 * For every id of every channel on the given host: 14 * For every id of every channel on the given host:
15 * 15 *
@@ -17,7 +17,7 @@
17 * device or storage attached to LUN 0): 17 * device or storage attached to LUN 0):
18 * 18 *
19 * If LUN 0 has a device attached, allocate and setup a 19 * If LUN 0 has a device attached, allocate and setup a
20 * Scsi_Device for it. 20 * scsi_device for it.
21 * 21 *
22 * If target is SCSI-3 or up, issue a REPORT LUN, and scan 22 * If target is SCSI-3 or up, issue a REPORT LUN, and scan
23 * all of the LUNs returned by the REPORT LUN; else, 23 * all of the LUNs returned by the REPORT LUN; else,
@@ -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/**
@@ -441,7 +467,7 @@ void scsi_target_reap(struct scsi_target *starget)
441 * 467 *
442 * If the INQUIRY is successful, zero is returned and the 468 * If the INQUIRY is successful, zero is returned and the
443 * INQUIRY data is in @inq_result; the scsi_level and INQUIRY length 469 * INQUIRY data is in @inq_result; the scsi_level and INQUIRY length
444 * are copied to the Scsi_Device any flags value is stored in *@bflags. 470 * are copied to the scsi_device any flags value is stored in *@bflags.
445 **/ 471 **/
446static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result, 472static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result,
447 int result_len, int *bflags) 473 int result_len, int *bflags)
@@ -509,8 +535,8 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result,
509 /* 535 /*
510 * Get any flags for this device. 536 * Get any flags for this device.
511 * 537 *
512 * XXX add a bflags to Scsi_Device, and replace the 538 * XXX add a bflags to scsi_device, and replace the
513 * corresponding bit fields in Scsi_Device, so bflags 539 * corresponding bit fields in scsi_device, so bflags
514 * need not be passed as an argument. 540 * need not be passed as an argument.
515 */ 541 */
516 *bflags = scsi_get_device_flags(sdev, &inq_result[8], 542 *bflags = scsi_get_device_flags(sdev, &inq_result[8],
@@ -592,21 +618,21 @@ static int scsi_probe_lun(struct scsi_device *sdev, char *inq_result,
592} 618}
593 619
594/** 620/**
595 * scsi_add_lun - allocate and fully initialze a Scsi_Device 621 * scsi_add_lun - allocate and fully initialze a scsi_device
596 * @sdevscan: holds information to be stored in the new Scsi_Device 622 * @sdevscan: holds information to be stored in the new scsi_device
597 * @sdevnew: store the address of the newly allocated Scsi_Device 623 * @sdevnew: store the address of the newly allocated scsi_device
598 * @inq_result: holds the result of a previous INQUIRY to the LUN 624 * @inq_result: holds the result of a previous INQUIRY to the LUN
599 * @bflags: black/white list flag 625 * @bflags: black/white list flag
600 * 626 *
601 * Description: 627 * Description:
602 * Allocate and initialize a Scsi_Device matching sdevscan. Optionally 628 * Allocate and initialize a scsi_device matching sdevscan. Optionally
603 * set fields based on values in *@bflags. If @sdevnew is not 629 * set fields based on values in *@bflags. If @sdevnew is not
604 * NULL, store the address of the new Scsi_Device in *@sdevnew (needed 630 * NULL, store the address of the new scsi_device in *@sdevnew (needed
605 * when scanning a particular LUN). 631 * when scanning a particular LUN).
606 * 632 *
607 * Return: 633 * Return:
608 * SCSI_SCAN_NO_RESPONSE: could not allocate or setup a Scsi_Device 634 * SCSI_SCAN_NO_RESPONSE: could not allocate or setup a scsi_device
609 * SCSI_SCAN_LUN_PRESENT: a new Scsi_Device was allocated and initialized 635 * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
610 **/ 636 **/
611static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags) 637static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
612{ 638{
@@ -674,7 +700,7 @@ static int scsi_add_lun(struct scsi_device *sdev, char *inq_result, int *bflags)
674 * 700 *
675 * The above is vague, as it implies that we could treat 001 and 701 * The above is vague, as it implies that we could treat 001 and
676 * 011 the same. Stay compatible with previous code, and create a 702 * 011 the same. Stay compatible with previous code, and create a
677 * Scsi_Device for a PQ of 1 703 * scsi_device for a PQ of 1
678 * 704 *
679 * Don't set the device offline here; rather let the upper 705 * Don't set the device offline here; rather let the upper
680 * level drivers eval the PQ to decide whether they should 706 * level drivers eval the PQ to decide whether they should
@@ -784,8 +810,8 @@ static inline void scsi_destroy_sdev(struct scsi_device *sdev)
784 * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it 810 * scsi_probe_and_add_lun - probe a LUN, if a LUN is found add it
785 * @starget: pointer to target device structure 811 * @starget: pointer to target device structure
786 * @lun: LUN of target device 812 * @lun: LUN of target device
787 * @sdevscan: probe the LUN corresponding to this Scsi_Device 813 * @sdevscan: probe the LUN corresponding to this scsi_device
788 * @sdevnew: store the value of any new Scsi_Device allocated 814 * @sdevnew: store the value of any new scsi_device allocated
789 * @bflagsp: store bflags here if not NULL 815 * @bflagsp: store bflags here if not NULL
790 * 816 *
791 * Description: 817 * Description:
@@ -793,10 +819,10 @@ static inline void scsi_destroy_sdev(struct scsi_device *sdev)
793 * allocate and set it up by calling scsi_add_lun. 819 * allocate and set it up by calling scsi_add_lun.
794 * 820 *
795 * Return: 821 * Return:
796 * SCSI_SCAN_NO_RESPONSE: could not allocate or setup a Scsi_Device 822 * SCSI_SCAN_NO_RESPONSE: could not allocate or setup a scsi_device
797 * SCSI_SCAN_TARGET_PRESENT: target responded, but no device is 823 * SCSI_SCAN_TARGET_PRESENT: target responded, but no device is
798 * attached at the LUN 824 * attached at the LUN
799 * SCSI_SCAN_LUN_PRESENT: a new Scsi_Device was allocated and initialized 825 * SCSI_SCAN_LUN_PRESENT: a new scsi_device was allocated and initialized
800 **/ 826 **/
801static int scsi_probe_and_add_lun(struct scsi_target *starget, 827static int scsi_probe_and_add_lun(struct scsi_target *starget,
802 uint lun, int *bflagsp, 828 uint lun, int *bflagsp,
@@ -1046,7 +1072,7 @@ EXPORT_SYMBOL(int_to_scsilun);
1046 1072
1047/** 1073/**
1048 * scsi_report_lun_scan - Scan using SCSI REPORT LUN results 1074 * scsi_report_lun_scan - Scan using SCSI REPORT LUN results
1049 * @sdevscan: scan the host, channel, and id of this Scsi_Device 1075 * @sdevscan: scan the host, channel, and id of this scsi_device
1050 * 1076 *
1051 * Description: 1077 * Description:
1052 * If @sdevscan is for a SCSI-3 or up device, send a REPORT LUN 1078 * If @sdevscan is for a SCSI-3 or up device, send a REPORT LUN
@@ -1074,6 +1100,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1074 struct scsi_sense_hdr sshdr; 1100 struct scsi_sense_hdr sshdr;
1075 struct scsi_device *sdev; 1101 struct scsi_device *sdev;
1076 struct Scsi_Host *shost = dev_to_shost(&starget->dev); 1102 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
1103 int ret = 0;
1077 1104
1078 /* 1105 /*
1079 * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set. 1106 * Only support SCSI-3 and up devices if BLIST_NOREPORTLUN is not set.
@@ -1169,8 +1196,8 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1169 /* 1196 /*
1170 * The device probably does not support a REPORT LUN command 1197 * The device probably does not support a REPORT LUN command
1171 */ 1198 */
1172 kfree(lun_data); 1199 ret = 1;
1173 return 1; 1200 goto out_err;
1174 } 1201 }
1175 1202
1176 /* 1203 /*
@@ -1238,6 +1265,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1238 } 1265 }
1239 } 1266 }
1240 1267
1268 out_err:
1241 kfree(lun_data); 1269 kfree(lun_data);
1242 out: 1270 out:
1243 scsi_device_put(sdev); 1271 scsi_device_put(sdev);
@@ -1246,7 +1274,7 @@ static int scsi_report_lun_scan(struct scsi_target *starget, int bflags,
1246 * the sdev we used didn't appear in the report luns scan 1274 * the sdev we used didn't appear in the report luns scan
1247 */ 1275 */
1248 scsi_destroy_sdev(sdev); 1276 scsi_destroy_sdev(sdev);
1249 return 0; 1277 return ret;
1250} 1278}
1251 1279
1252struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel, 1280struct scsi_device *__scsi_add_device(struct Scsi_Host *shost, uint channel,
@@ -1472,16 +1500,16 @@ void scsi_forget_host(struct Scsi_Host *shost)
1472/* 1500/*
1473 * Function: scsi_get_host_dev() 1501 * Function: scsi_get_host_dev()
1474 * 1502 *
1475 * Purpose: Create a Scsi_Device that points to the host adapter itself. 1503 * Purpose: Create a scsi_device that points to the host adapter itself.
1476 * 1504 *
1477 * Arguments: SHpnt - Host that needs a Scsi_Device 1505 * Arguments: SHpnt - Host that needs a scsi_device
1478 * 1506 *
1479 * Lock status: None assumed. 1507 * Lock status: None assumed.
1480 * 1508 *
1481 * Returns: The Scsi_Device or NULL 1509 * Returns: The scsi_device or NULL
1482 * 1510 *
1483 * Notes: 1511 * Notes:
1484 * Attach a single Scsi_Device to the Scsi_Host - this should 1512 * Attach a single scsi_device to the Scsi_Host - this should
1485 * be made to look like a "pseudo-device" that points to the 1513 * be made to look like a "pseudo-device" that points to the
1486 * HA itself. 1514 * HA itself.
1487 * 1515 *
@@ -1518,7 +1546,7 @@ EXPORT_SYMBOL(scsi_get_host_dev);
1518 * 1546 *
1519 * Purpose: Free a scsi_device that points to the host adapter itself. 1547 * Purpose: Free a scsi_device that points to the host adapter itself.
1520 * 1548 *
1521 * Arguments: SHpnt - Host that needs a Scsi_Device 1549 * Arguments: SHpnt - Host that needs a scsi_device
1522 * 1550 *
1523 * Lock status: None assumed. 1551 * Lock status: None assumed.
1524 * 1552 *
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 72a6550a056c..46349293de08 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -691,16 +691,19 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
691 691
692void __scsi_remove_device(struct scsi_device *sdev) 692void __scsi_remove_device(struct scsi_device *sdev)
693{ 693{
694 struct device *dev = &sdev->sdev_gendev;
695
694 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) 696 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
695 return; 697 return;
696 698
697 class_device_unregister(&sdev->sdev_classdev); 699 class_device_unregister(&sdev->sdev_classdev);
698 device_del(&sdev->sdev_gendev); 700 transport_remove_device(dev);
701 device_del(dev);
699 scsi_device_set_state(sdev, SDEV_DEL); 702 scsi_device_set_state(sdev, SDEV_DEL);
700 if (sdev->host->hostt->slave_destroy) 703 if (sdev->host->hostt->slave_destroy)
701 sdev->host->hostt->slave_destroy(sdev); 704 sdev->host->hostt->slave_destroy(sdev);
702 transport_unregister_device(&sdev->sdev_gendev); 705 transport_destroy_device(dev);
703 put_device(&sdev->sdev_gendev); 706 put_device(dev);
704} 707}
705 708
706/** 709/**
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index 6cd5931d9a54..2a1a99a2ef56 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -105,6 +105,7 @@ 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
@@ -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 718a2bc4ed5e..38a53b5f9e9a 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -812,12 +812,10 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer)
812 if (!scsi_device_sync(sdev) && !scsi_device_dt(sdev)) 812 if (!scsi_device_sync(sdev) && !scsi_device_dt(sdev))
813 return; 813 return;
814 814
815 /* see if the device has an echo buffer. If it does we can 815 /* len == -1 is the signal that we need to ascertain the
816 * do the SPI pattern write tests */ 816 * presence of an echo buffer before trying to use it. len ==
817 817 * 0 means we don't have an echo buffer */
818 len = 0; 818 len = -1;
819 if (scsi_device_dt(sdev))
820 len = spi_dv_device_get_echo_buffer(sdev, buffer);
821 819
822 retry: 820 retry:
823 821
@@ -840,11 +838,23 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer)
840 if (spi_min_period(starget) == 8) 838 if (spi_min_period(starget) == 8)
841 DV_SET(pcomp_en, 1); 839 DV_SET(pcomp_en, 1);
842 } 840 }
841 /* Do the read only INQUIRY tests */
842 spi_dv_retrain(sdev, buffer, buffer + sdev->inquiry_len,
843 spi_dv_device_compare_inquiry);
844 /* See if we actually managed to negotiate and sustain DT */
845 if (i->f->get_dt)
846 i->f->get_dt(starget);
847
848 /* see if the device has an echo buffer. If it does we can do
849 * the SPI pattern write tests. Because of some broken
850 * devices, we *only* try this on a device that has actually
851 * negotiated DT */
852
853 if (len == -1 && spi_dt(starget))
854 len = spi_dv_device_get_echo_buffer(sdev, buffer);
843 855
844 if (len == 0) { 856 if (len <= 0) {
845 starget_printk(KERN_INFO, starget, "Domain Validation skipping write tests\n"); 857 starget_printk(KERN_INFO, starget, "Domain Validation skipping write tests\n");
846 spi_dv_retrain(sdev, buffer, buffer + len,
847 spi_dv_device_compare_inquiry);
848 return; 858 return;
849 } 859 }
850 860
diff --git a/drivers/scsi/scsi_typedefs.h b/drivers/scsi/scsi_typedefs.h
index 6c431323581c..29f038b42f60 100644
--- a/drivers/scsi/scsi_typedefs.h
+++ b/drivers/scsi/scsi_typedefs.h
@@ -1,6 +1,3 @@
1 1
2typedef struct scsi_host_template Scsi_Host_Template;
3typedef struct scsi_device Scsi_Device;
4typedef struct scsi_cmnd Scsi_Cmnd; 2typedef struct scsi_cmnd Scsi_Cmnd;
5typedef struct scsi_request Scsi_Request; 3typedef struct scsi_request Scsi_Request;
6typedef struct scsi_pointer Scsi_Pointer;
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bb5b242ac6b4..03fcbab30033 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -245,24 +245,10 @@ static int sd_init_command(struct scsi_cmnd * SCpnt)
245 * SG_IO from block layer already setup, just copy cdb basically 245 * SG_IO from block layer already setup, just copy cdb basically
246 */ 246 */
247 if (blk_pc_request(rq)) { 247 if (blk_pc_request(rq)) {
248 if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd)) 248 scsi_setup_blk_pc_cmnd(SCpnt, SD_PASSTHROUGH_RETRIES);
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) 249 if (rq->timeout)
262 timeout = rq->timeout; 250 timeout = rq->timeout;
263 251
264 SCpnt->transfersize = rq->data_len;
265 SCpnt->allowed = SD_PASSTHROUGH_RETRIES;
266 goto queue; 252 goto queue;
267 } 253 }
268 254
@@ -769,20 +755,16 @@ static void sd_end_flush(request_queue_t *q, struct request *flush_rq)
769static int sd_prepare_flush(request_queue_t *q, struct request *rq) 755static int sd_prepare_flush(request_queue_t *q, struct request *rq)
770{ 756{
771 struct scsi_device *sdev = q->queuedata; 757 struct scsi_device *sdev = q->queuedata;
772 struct scsi_disk *sdkp = scsi_disk_get_from_dev(&sdev->sdev_gendev); 758 struct scsi_disk *sdkp = dev_get_drvdata(&sdev->sdev_gendev);
773 int ret = 0;
774 759
775 if (sdkp) { 760 if (!sdkp || !sdkp->WCE)
776 if (sdkp->WCE) { 761 return 0;
777 memset(rq->cmd, 0, sizeof(rq->cmd)); 762
778 rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; 763 memset(rq->cmd, 0, sizeof(rq->cmd));
779 rq->timeout = SD_TIMEOUT; 764 rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER;
780 rq->cmd[0] = SYNCHRONIZE_CACHE; 765 rq->timeout = SD_TIMEOUT;
781 ret = 1; 766 rq->cmd[0] = SYNCHRONIZE_CACHE;
782 } 767 return 1;
783 scsi_disk_put(sdkp);
784 }
785 return ret;
786} 768}
787 769
788static void sd_rescan(struct device *dev) 770static void sd_rescan(struct device *dev)
diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
index a0cace9aeb79..0ff83ddf13fe 100644
--- a/drivers/scsi/seagate.c
+++ b/drivers/scsi/seagate.c
@@ -418,7 +418,7 @@ static inline void borken_wait (void)
418#define ULOOP( i ) for (clock = i*8;;) 418#define ULOOP( i ) for (clock = i*8;;)
419#define TIMEOUT (!(clock--)) 419#define TIMEOUT (!(clock--))
420 420
421int __init seagate_st0x_detect (Scsi_Host_Template * tpnt) 421int __init seagate_st0x_detect (struct scsi_host_template * tpnt)
422{ 422{
423 struct Scsi_Host *instance; 423 struct Scsi_Host *instance;
424 int i, j; 424 int i, j;
@@ -1649,7 +1649,7 @@ static int seagate_st0x_release(struct Scsi_Host *shost)
1649 return 0; 1649 return 0;
1650} 1650}
1651 1651
1652static Scsi_Host_Template driver_template = { 1652static struct scsi_host_template driver_template = {
1653 .detect = seagate_st0x_detect, 1653 .detect = seagate_st0x_detect,
1654 .release = seagate_st0x_release, 1654 .release = seagate_st0x_release,
1655 .info = seagate_st0x_info, 1655 .info = seagate_st0x_info,
diff --git a/drivers/scsi/seagate.h b/drivers/scsi/seagate.h
index 8889ff1a6b20..fb5f380fa4b3 100644
--- a/drivers/scsi/seagate.h
+++ b/drivers/scsi/seagate.h
@@ -9,7 +9,7 @@
9#ifndef _SEAGATE_H 9#ifndef _SEAGATE_H
10#define SEAGATE_H 10#define SEAGATE_H
11 11
12static int seagate_st0x_detect(Scsi_Host_Template *); 12static int seagate_st0x_detect(struct scsi_host_template *);
13static int seagate_st0x_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 13static int seagate_st0x_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
14 14
15static int seagate_st0x_abort(Scsi_Cmnd *); 15static int seagate_st0x_abort(Scsi_Cmnd *);
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index 72ec59456e69..b55c2a8a547c 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1860,9 +1860,11 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1860 unlock_page(pages[j]); */ 1860 unlock_page(pages[j]); */
1861 res = 0; 1861 res = 0;
1862 out_unmap: 1862 out_unmap:
1863 if (res > 0) 1863 if (res > 0) {
1864 for (j=0; j < res; j++) 1864 for (j=0; j < res; j++)
1865 page_cache_release(pages[j]); 1865 page_cache_release(pages[j]);
1866 res = 0;
1867 }
1866 kfree(pages); 1868 kfree(pages);
1867 return res; 1869 return res;
1868} 1870}
@@ -1878,8 +1880,6 @@ st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages,
1878 for (i=0; i < nr_pages; i++) { 1880 for (i=0; i < nr_pages; i++) {
1879 struct page *page = sgl[i].page; 1881 struct page *page = sgl[i].page;
1880 1882
1881 /* XXX: just for debug. Remove when PageReserved is removed */
1882 BUG_ON(PageReserved(page));
1883 if (dirtied) 1883 if (dirtied)
1884 SetPageDirty(page); 1884 SetPageDirty(page);
1885 /* unlock_page(page); */ 1885 /* unlock_page(page); */
diff --git a/drivers/scsi/sgiwd93.c b/drivers/scsi/sgiwd93.c
index f37147f8f7bf..bf2ceb54354c 100644
--- a/drivers/scsi/sgiwd93.c
+++ b/drivers/scsi/sgiwd93.c
@@ -217,7 +217,7 @@ static inline void init_hpc_chain(struct hpc_data *hd)
217} 217}
218 218
219static struct Scsi_Host * __init sgiwd93_setup_scsi( 219static struct Scsi_Host * __init sgiwd93_setup_scsi(
220 Scsi_Host_Template *SGIblows, int unit, int irq, 220 struct scsi_host_template *SGIblows, int unit, int irq,
221 struct hpc3_scsiregs *hregs, unsigned char *wdregs) 221 struct hpc3_scsiregs *hregs, unsigned char *wdregs)
222{ 222{
223 struct ip22_hostdata *hdata; 223 struct ip22_hostdata *hdata;
@@ -265,7 +265,7 @@ out_unregister:
265 return NULL; 265 return NULL;
266} 266}
267 267
268int __init sgiwd93_detect(Scsi_Host_Template *SGIblows) 268int __init sgiwd93_detect(struct scsi_host_template *SGIblows)
269{ 269{
270 int found = 0; 270 int found = 0;
271 271
@@ -324,7 +324,7 @@ static int sgiwd93_bus_reset(Scsi_Cmnd *cmd)
324 * arguments not with pointers. So this is going to blow up beautyfully 324 * arguments not with pointers. So this is going to blow up beautyfully
325 * on 64-bit systems with memory outside the compat address spaces. 325 * on 64-bit systems with memory outside the compat address spaces.
326 */ 326 */
327static Scsi_Host_Template driver_template = { 327static struct scsi_host_template driver_template = {
328 .proc_name = "SGIWD93", 328 .proc_name = "SGIWD93",
329 .name = "SGI WD93", 329 .name = "SGI WD93",
330 .detect = sgiwd93_detect, 330 .detect = sgiwd93_detect,
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index d68cea753bb2..fb4012b5c188 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, MAX_RETRIES);
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
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 770c4324f3d5..dd592f6a2529 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4194,27 +4194,10 @@ static void st_intr(struct scsi_cmnd *SCpnt)
4194 */ 4194 */
4195static int st_init_command(struct scsi_cmnd *SCpnt) 4195static int st_init_command(struct scsi_cmnd *SCpnt)
4196{ 4196{
4197 struct request *rq;
4198
4199 if (!(SCpnt->request->flags & REQ_BLOCK_PC)) 4197 if (!(SCpnt->request->flags & REQ_BLOCK_PC))
4200 return 0; 4198 return 0;
4201 4199
4202 rq = SCpnt->request; 4200 scsi_setup_blk_pc_cmnd(SCpnt, 0);
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; 4201 SCpnt->done = st_intr;
4219 return 1; 4202 return 1;
4220} 4203}
@@ -4509,6 +4492,7 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa
4509 if (res > 0) { 4492 if (res > 0) {
4510 for (j=0; j < res; j++) 4493 for (j=0; j < res; j++)
4511 page_cache_release(pages[j]); 4494 page_cache_release(pages[j]);
4495 res = 0;
4512 } 4496 }
4513 kfree(pages); 4497 kfree(pages);
4514 return res; 4498 return res;
@@ -4524,8 +4508,6 @@ static int sgl_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_p
4524 for (i=0; i < nr_pages; i++) { 4508 for (i=0; i < nr_pages; i++) {
4525 struct page *page = sgl[i].page; 4509 struct page *page = sgl[i].page;
4526 4510
4527 /* XXX: just for debug. Remove when PageReserved is removed */
4528 BUG_ON(PageReserved(page));
4529 if (dirtied) 4511 if (dirtied)
4530 SetPageDirty(page); 4512 SetPageDirty(page);
4531 /* FIXME: cache flush missing for rw==READ 4513 /* FIXME: cache flush missing for rw==READ
diff --git a/drivers/scsi/sun3_NCR5380.c b/drivers/scsi/sun3_NCR5380.c
index 7e19589e71a0..c041bfd56e12 100644
--- a/drivers/scsi/sun3_NCR5380.c
+++ b/drivers/scsi/sun3_NCR5380.c
@@ -257,7 +257,7 @@
257 */ 257 */
258 258
259static struct Scsi_Host *first_instance = NULL; 259static struct Scsi_Host *first_instance = NULL;
260static Scsi_Host_Template *the_template = NULL; 260static struct scsi_host_template *the_template = NULL;
261 261
262/* Macros ease life... :-) */ 262/* Macros ease life... :-) */
263#define SETUP_HOSTDATA(in) \ 263#define SETUP_HOSTDATA(in) \
diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
index e3ea99f23d60..837173415d4c 100644
--- a/drivers/scsi/sun3_scsi.c
+++ b/drivers/scsi/sun3_scsi.c
@@ -185,7 +185,7 @@ static inline void sun3_udc_write(unsigned short val, unsigned char reg)
185static struct Scsi_Host *default_instance; 185static struct Scsi_Host *default_instance;
186 186
187/* 187/*
188 * Function : int sun3scsi_detect(Scsi_Host_Template * tpnt) 188 * Function : int sun3scsi_detect(struct scsi_host_template * tpnt)
189 * 189 *
190 * Purpose : initializes mac NCR5380 driver based on the 190 * Purpose : initializes mac NCR5380 driver based on the
191 * command line / compile time port and irq definitions. 191 * command line / compile time port and irq definitions.
@@ -196,7 +196,7 @@ static struct Scsi_Host *default_instance;
196 * 196 *
197 */ 197 */
198 198
199int sun3scsi_detect(Scsi_Host_Template * tpnt) 199int sun3scsi_detect(struct scsi_host_template * tpnt)
200{ 200{
201 unsigned long ioaddr; 201 unsigned long ioaddr;
202 static int called = 0; 202 static int called = 0;
@@ -621,7 +621,7 @@ static int sun3scsi_dma_finish(int write_flag)
621 621
622#include "sun3_NCR5380.c" 622#include "sun3_NCR5380.c"
623 623
624static Scsi_Host_Template driver_template = { 624static struct scsi_host_template driver_template = {
625 .name = SUN3_SCSI_NAME, 625 .name = SUN3_SCSI_NAME,
626 .detect = sun3scsi_detect, 626 .detect = sun3scsi_detect,
627 .release = sun3scsi_release, 627 .release = sun3scsi_release,
diff --git a/drivers/scsi/sun3_scsi.h b/drivers/scsi/sun3_scsi.h
index 155282b92a95..834dab428019 100644
--- a/drivers/scsi/sun3_scsi.h
+++ b/drivers/scsi/sun3_scsi.h
@@ -48,7 +48,7 @@
48#define IOBASE_SUN3_VMESCSI 0xff200000 48#define IOBASE_SUN3_VMESCSI 0xff200000
49 49
50static int sun3scsi_abort (Scsi_Cmnd *); 50static int sun3scsi_abort (Scsi_Cmnd *);
51static int sun3scsi_detect (Scsi_Host_Template *); 51static int sun3scsi_detect (struct scsi_host_template *);
52static const char *sun3scsi_info (struct Scsi_Host *); 52static const char *sun3scsi_info (struct Scsi_Host *);
53static int sun3scsi_bus_reset(Scsi_Cmnd *); 53static int sun3scsi_bus_reset(Scsi_Cmnd *);
54static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 54static int sun3scsi_queue_command (Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
diff --git a/drivers/scsi/sun3_scsi_vme.c b/drivers/scsi/sun3_scsi_vme.c
index 9acb5ddebb07..008a82ab8521 100644
--- a/drivers/scsi/sun3_scsi_vme.c
+++ b/drivers/scsi/sun3_scsi_vme.c
@@ -127,7 +127,7 @@ static inline void sun3scsi_write(int reg, int value)
127static struct Scsi_Host *default_instance; 127static struct Scsi_Host *default_instance;
128 128
129/* 129/*
130 * Function : int sun3scsi_detect(Scsi_Host_Template * tpnt) 130 * Function : int sun3scsi_detect(struct scsi_host_template * tpnt)
131 * 131 *
132 * Purpose : initializes mac NCR5380 driver based on the 132 * Purpose : initializes mac NCR5380 driver based on the
133 * command line / compile time port and irq definitions. 133 * command line / compile time port and irq definitions.
@@ -138,7 +138,7 @@ static struct Scsi_Host *default_instance;
138 * 138 *
139 */ 139 */
140 140
141static int sun3scsi_detect(Scsi_Host_Template * tpnt) 141static int sun3scsi_detect(struct scsi_host_template * tpnt)
142{ 142{
143 unsigned long ioaddr, irq = 0; 143 unsigned long ioaddr, irq = 0;
144 static int called = 0; 144 static int called = 0;
@@ -564,7 +564,7 @@ static int sun3scsi_dma_finish(int write_flag)
564 564
565#include "sun3_NCR5380.c" 565#include "sun3_NCR5380.c"
566 566
567static Scsi_Host_Template driver_template = { 567static struct scsi_host_template driver_template = {
568 .name = SUN3_SCSI_NAME, 568 .name = SUN3_SCSI_NAME,
569 .detect = sun3scsi_detect, 569 .detect = sun3scsi_detect,
570 .release = sun3scsi_release, 570 .release = sun3scsi_release,
diff --git a/drivers/scsi/sun3x_esp.c b/drivers/scsi/sun3x_esp.c
index 09d7639079b4..cc990bed9683 100644
--- a/drivers/scsi/sun3x_esp.c
+++ b/drivers/scsi/sun3x_esp.c
@@ -47,7 +47,7 @@ static void dma_advance_sg (Scsi_Cmnd *sp);
47/* Detecting ESP chips on the machine. This is the simple and easy 47/* Detecting ESP chips on the machine. This is the simple and easy
48 * version. 48 * version.
49 */ 49 */
50int sun3x_esp_detect(Scsi_Host_Template *tpnt) 50int sun3x_esp_detect(struct scsi_host_template *tpnt)
51{ 51{
52 struct NCR_ESP *esp; 52 struct NCR_ESP *esp;
53 struct ConfigDev *esp_dev; 53 struct ConfigDev *esp_dev;
@@ -367,7 +367,7 @@ static int sun3x_esp_release(struct Scsi_Host *instance)
367 367
368} 368}
369 369
370static Scsi_Host_Template driver_template = { 370static struct scsi_host_template driver_template = {
371 .proc_name = "sun3x_esp", 371 .proc_name = "sun3x_esp",
372 .proc_info = &esp_proc_info, 372 .proc_info = &esp_proc_info,
373 .name = "Sun ESP 100/100a/200", 373 .name = "Sun ESP 100/100a/200",
diff --git a/drivers/scsi/sym53c416.c b/drivers/scsi/sym53c416.c
index 93dc7b665ccf..8640253d6215 100644
--- a/drivers/scsi/sym53c416.c
+++ b/drivers/scsi/sym53c416.c
@@ -633,7 +633,7 @@ static void sym53c416_probe(void)
633 } 633 }
634} 634}
635 635
636int __init sym53c416_detect(Scsi_Host_Template *tpnt) 636int __init sym53c416_detect(struct scsi_host_template *tpnt)
637{ 637{
638 unsigned long flags; 638 unsigned long flags;
639 struct Scsi_Host * shpnt = NULL; 639 struct Scsi_Host * shpnt = NULL;
@@ -849,7 +849,7 @@ module_param_array(sym53c416_3, uint, NULL, 0);
849 849
850#endif 850#endif
851 851
852static Scsi_Host_Template driver_template = { 852static struct scsi_host_template driver_template = {
853 .proc_name = "sym53c416", 853 .proc_name = "sym53c416",
854 .name = "Symbios Logic 53c416", 854 .name = "Symbios Logic 53c416",
855 .detect = sym53c416_detect, 855 .detect = sym53c416_detect,
diff --git a/drivers/scsi/sym53c416.h b/drivers/scsi/sym53c416.h
index fd6b120d38c4..77860d0748ff 100644
--- a/drivers/scsi/sym53c416.h
+++ b/drivers/scsi/sym53c416.h
@@ -22,7 +22,7 @@
22 22
23#define SYM53C416_SCSI_ID 7 23#define SYM53C416_SCSI_ID 7
24 24
25static int sym53c416_detect(Scsi_Host_Template *); 25static int sym53c416_detect(struct scsi_host_template *);
26static const char *sym53c416_info(struct Scsi_Host *); 26static const char *sym53c416_info(struct Scsi_Host *);
27static int sym53c416_release(struct Scsi_Host *); 27static int sym53c416_release(struct Scsi_Host *);
28static int sym53c416_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 28static int sym53c416_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index d76766c3ce16..7fc0b97173e1 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -2086,6 +2086,7 @@ static void sym2_set_dt(struct scsi_target *starget, int dt)
2086 tp->tgoal.check_nego = 1; 2086 tp->tgoal.check_nego = 1;
2087} 2087}
2088 2088
2089#if 0
2089static void sym2_set_iu(struct scsi_target *starget, int iu) 2090static void sym2_set_iu(struct scsi_target *starget, int iu)
2090{ 2091{
2091 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 2092 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
@@ -2111,7 +2112,7 @@ static void sym2_set_qas(struct scsi_target *starget, int qas)
2111 tp->tgoal.qas = 0; 2112 tp->tgoal.qas = 0;
2112 tp->tgoal.check_nego = 1; 2113 tp->tgoal.check_nego = 1;
2113} 2114}
2114 2115#endif
2115 2116
2116static struct spi_function_template sym2_transport_functions = { 2117static struct spi_function_template sym2_transport_functions = {
2117 .set_offset = sym2_set_offset, 2118 .set_offset = sym2_set_offset,
@@ -2122,10 +2123,12 @@ static struct spi_function_template sym2_transport_functions = {
2122 .show_width = 1, 2123 .show_width = 1,
2123 .set_dt = sym2_set_dt, 2124 .set_dt = sym2_set_dt,
2124 .show_dt = 1, 2125 .show_dt = 1,
2126#if 0
2125 .set_iu = sym2_set_iu, 2127 .set_iu = sym2_set_iu,
2126 .show_iu = 1, 2128 .show_iu = 1,
2127 .set_qas = sym2_set_qas, 2129 .set_qas = sym2_set_qas,
2128 .show_qas = 1, 2130 .show_qas = 1,
2131#endif
2129 .get_signalling = sym2_get_signalling, 2132 .get_signalling = sym2_get_signalling,
2130}; 2133};
2131 2134
diff --git a/drivers/scsi/sym53c8xx_2/sym_hipd.c b/drivers/scsi/sym53c8xx_2/sym_hipd.c
index a7420cad4547..1564ca203a3e 100644
--- a/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ b/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -1405,7 +1405,6 @@ static void sym_check_goals(struct sym_hcb *np, struct scsi_target *starget,
1405 goal->iu = 0; 1405 goal->iu = 0;
1406 goal->dt = 0; 1406 goal->dt = 0;
1407 goal->qas = 0; 1407 goal->qas = 0;
1408 goal->period = 0;
1409 goal->offset = 0; 1408 goal->offset = 0;
1410 return; 1409 return;
1411 } 1410 }
@@ -1465,7 +1464,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 1464 * Many devices implement PPR in a buggy way, so only use it if we
1466 * really want to. 1465 * really want to.
1467 */ 1466 */
1468 if (goal->iu || goal->dt || goal->qas || (goal->period < 0xa)) { 1467 if (goal->offset &&
1468 (goal->iu || goal->dt || goal->qas || (goal->period < 0xa))) {
1469 nego = NS_PPR; 1469 nego = NS_PPR;
1470 } else if (spi_width(starget) != goal->width) { 1470 } else if (spi_width(starget) != goal->width) {
1471 nego = NS_WIDE; 1471 nego = NS_WIDE;
diff --git a/drivers/scsi/t128.c b/drivers/scsi/t128.c
index f4b780e35cb6..21305fc91479 100644
--- a/drivers/scsi/t128.c
+++ b/drivers/scsi/t128.c
@@ -183,7 +183,7 @@ void __init t128_setup(char *str, int *ints){
183} 183}
184 184
185/* 185/*
186 * Function : int t128_detect(Scsi_Host_Template * tpnt) 186 * Function : int t128_detect(struct scsi_host_template * tpnt)
187 * 187 *
188 * Purpose : detects and initializes T128,T128F, or T228 controllers 188 * Purpose : detects and initializes T128,T128F, or T228 controllers
189 * that were autoprobed, overridden on the LILO command line, 189 * that were autoprobed, overridden on the LILO command line,
@@ -195,7 +195,7 @@ void __init t128_setup(char *str, int *ints){
195 * 195 *
196 */ 196 */
197 197
198int __init t128_detect(Scsi_Host_Template * tpnt){ 198int __init t128_detect(struct scsi_host_template * tpnt){
199 static int current_override = 0, current_base = 0; 199 static int current_override = 0, current_base = 0;
200 struct Scsi_Host *instance; 200 struct Scsi_Host *instance;
201 unsigned long base; 201 unsigned long base;
@@ -430,7 +430,7 @@ MODULE_LICENSE("GPL");
430 430
431#include "NCR5380.c" 431#include "NCR5380.c"
432 432
433static Scsi_Host_Template driver_template = { 433static struct scsi_host_template driver_template = {
434 .name = "Trantor T128/T128F/T228", 434 .name = "Trantor T128/T128F/T228",
435 .detect = t128_detect, 435 .detect = t128_detect,
436 .release = t128_release, 436 .release = t128_release,
diff --git a/drivers/scsi/t128.h b/drivers/scsi/t128.h
index 596f3a32a1c6..646e840266e2 100644
--- a/drivers/scsi/t128.h
+++ b/drivers/scsi/t128.h
@@ -95,7 +95,7 @@
95static int t128_abort(Scsi_Cmnd *); 95static int t128_abort(Scsi_Cmnd *);
96static int t128_biosparam(struct scsi_device *, struct block_device *, 96static int t128_biosparam(struct scsi_device *, struct block_device *,
97 sector_t, int*); 97 sector_t, int*);
98static int t128_detect(Scsi_Host_Template *); 98static int t128_detect(struct scsi_host_template *);
99static int t128_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 99static int t128_queue_command(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
100static int t128_bus_reset(Scsi_Cmnd *); 100static int t128_bus_reset(Scsi_Cmnd *);
101 101
diff --git a/drivers/scsi/u14-34f.c b/drivers/scsi/u14-34f.c
index 1ce29ba683eb..33cd90fc657b 100644
--- a/drivers/scsi/u14-34f.c
+++ b/drivers/scsi/u14-34f.c
@@ -282,7 +282,7 @@
282 * clustering is enabled. ENABLE_CLUSTERING provides a performance increase 282 * clustering is enabled. ENABLE_CLUSTERING provides a performance increase
283 * up to 50% on sequential access. 283 * up to 50% on sequential access.
284 * 284 *
285 * Since the Scsi_Host_Template structure is shared among all 14F and 34F, 285 * Since the struct scsi_host_template structure is shared among all 14F and 34F,
286 * the last setting of use_clustering is in effect for all of these boards. 286 * the last setting of use_clustering is in effect for all of these boards.
287 * 287 *
288 * Here a sample configuration using two U14F boards: 288 * Here a sample configuration using two U14F boards:
diff --git a/drivers/scsi/ultrastor.c b/drivers/scsi/ultrastor.c
index 486551bd54ba..e681681ab7a2 100644
--- a/drivers/scsi/ultrastor.c
+++ b/drivers/scsi/ultrastor.c
@@ -343,7 +343,7 @@ static void log_ultrastor_abort(struct ultrastor_config *config,
343} 343}
344#endif 344#endif
345 345
346static int ultrastor_14f_detect(Scsi_Host_Template * tpnt) 346static int ultrastor_14f_detect(struct scsi_host_template * tpnt)
347{ 347{
348 size_t i; 348 size_t i;
349 unsigned char in_byte, version_byte = 0; 349 unsigned char in_byte, version_byte = 0;
@@ -525,7 +525,7 @@ out_release_port:
525 return FALSE; 525 return FALSE;
526} 526}
527 527
528static int ultrastor_24f_detect(Scsi_Host_Template * tpnt) 528static int ultrastor_24f_detect(struct scsi_host_template * tpnt)
529{ 529{
530 int i; 530 int i;
531 struct Scsi_Host * shpnt = NULL; 531 struct Scsi_Host * shpnt = NULL;
@@ -637,7 +637,7 @@ static int ultrastor_24f_detect(Scsi_Host_Template * tpnt)
637 return FALSE; 637 return FALSE;
638} 638}
639 639
640static int ultrastor_detect(Scsi_Host_Template * tpnt) 640static int ultrastor_detect(struct scsi_host_template * tpnt)
641{ 641{
642 tpnt->proc_name = "ultrastor"; 642 tpnt->proc_name = "ultrastor";
643 return ultrastor_14f_detect(tpnt) || ultrastor_24f_detect(tpnt); 643 return ultrastor_14f_detect(tpnt) || ultrastor_24f_detect(tpnt);
@@ -1184,7 +1184,7 @@ static irqreturn_t do_ultrastor_interrupt(int irq, void *dev_id,
1184 1184
1185MODULE_LICENSE("GPL"); 1185MODULE_LICENSE("GPL");
1186 1186
1187static Scsi_Host_Template driver_template = { 1187static struct scsi_host_template driver_template = {
1188 .name = "UltraStor 14F/24F/34F", 1188 .name = "UltraStor 14F/24F/34F",
1189 .detect = ultrastor_detect, 1189 .detect = ultrastor_detect,
1190 .release = ultrastor_release, 1190 .release = ultrastor_release,
diff --git a/drivers/scsi/ultrastor.h b/drivers/scsi/ultrastor.h
index 0a0f8df9e871..da759a11deff 100644
--- a/drivers/scsi/ultrastor.h
+++ b/drivers/scsi/ultrastor.h
@@ -13,7 +13,7 @@
13#ifndef _ULTRASTOR_H 13#ifndef _ULTRASTOR_H
14#define _ULTRASTOR_H 14#define _ULTRASTOR_H
15 15
16static int ultrastor_detect(Scsi_Host_Template *); 16static int ultrastor_detect(struct scsi_host_template *);
17static const char *ultrastor_info(struct Scsi_Host * shpnt); 17static const char *ultrastor_info(struct Scsi_Host * shpnt);
18static int ultrastor_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *)); 18static int ultrastor_queuecommand(Scsi_Cmnd *, void (*done)(Scsi_Cmnd *));
19static int ultrastor_abort(Scsi_Cmnd *); 19static int ultrastor_abort(Scsi_Cmnd *);
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index 2efb317153ce..67e9afa000c1 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -34,6 +34,7 @@
34#include <linux/keyboard.h> 34#include <linux/keyboard.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/pm.h> 36#include <linux/pm.h>
37#include <linux/pm_legacy.h>
37#include <linux/bitops.h> 38#include <linux/bitops.h>
38#include <linux/delay.h> 39#include <linux/delay.h>
39 40
@@ -1343,7 +1344,7 @@ static void show_serial_version(void)
1343 printk("MC68328 serial driver version 1.00\n"); 1344 printk("MC68328 serial driver version 1.00\n");
1344} 1345}
1345 1346
1346#ifdef CONFIG_PM 1347#ifdef CONFIG_PM_LEGACY
1347/* Serial Power management 1348/* Serial Power management
1348 * The console (currently fixed at line 0) is a special case for power 1349 * The console (currently fixed at line 0) is a special case for power
1349 * management because the kernel is so chatty. The console will be 1350 * management because the kernel is so chatty. The console will be
@@ -1393,7 +1394,7 @@ void startup_console(void)
1393 struct m68k_serial *info = &m68k_soft[0]; 1394 struct m68k_serial *info = &m68k_soft[0];
1394 startup(info); 1395 startup(info);
1395} 1396}
1396#endif 1397#endif /* CONFIG_PM_LEGACY */
1397 1398
1398 1399
1399static struct tty_operations rs_ops = { 1400static struct tty_operations rs_ops = {
@@ -1486,7 +1487,7 @@ rs68328_init(void)
1486 IRQ_FLG_STD, 1487 IRQ_FLG_STD,
1487 "M68328_UART", NULL)) 1488 "M68328_UART", NULL))
1488 panic("Unable to attach 68328 serial interrupt\n"); 1489 panic("Unable to attach 68328 serial interrupt\n");
1489#ifdef CONFIG_PM 1490#ifdef CONFIG_PM_LEGACY
1490 serial_pm[i] = pm_register(PM_SYS_DEV, PM_SYS_COM, serial_pm_callback); 1491 serial_pm[i] = pm_register(PM_SYS_DEV, PM_SYS_COM, serial_pm_callback);
1491 if (serial_pm[i]) 1492 if (serial_pm[i])
1492 serial_pm[i]->data = info; 1493 serial_pm[i]->data = info;
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 98820603e75f..d2bcd1f87cd6 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -102,7 +102,7 @@ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
102#define SERIAL_PORT_DFNS 102#define SERIAL_PORT_DFNS
103#endif 103#endif
104 104
105static struct old_serial_port old_serial_port[] = { 105static const struct old_serial_port old_serial_port[] = {
106 SERIAL_PORT_DFNS /* defined in asm/serial.h */ 106 SERIAL_PORT_DFNS /* defined in asm/serial.h */
107}; 107};
108 108
@@ -999,7 +999,10 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
999 serial_outp(up, UART_MCR, save_mcr); 999 serial_outp(up, UART_MCR, save_mcr);
1000 serial8250_clear_fifos(up); 1000 serial8250_clear_fifos(up);
1001 (void)serial_in(up, UART_RX); 1001 (void)serial_in(up, UART_RX);
1002 serial_outp(up, UART_IER, 0); 1002 if (up->capabilities & UART_CAP_UUE)
1003 serial_outp(up, UART_IER, UART_IER_UUE);
1004 else
1005 serial_outp(up, UART_IER, 0);
1003 1006
1004 out: 1007 out:
1005 spin_unlock_irqrestore(&up->port.lock, flags); 1008 spin_unlock_irqrestore(&up->port.lock, flags);
@@ -2381,9 +2384,9 @@ void serial8250_resume_port(int line)
2381 * list is terminated with a zero flags entry, which means we expect 2384 * list is terminated with a zero flags entry, which means we expect
2382 * all entries to have at least UPF_BOOT_AUTOCONF set. 2385 * all entries to have at least UPF_BOOT_AUTOCONF set.
2383 */ 2386 */
2384static int __devinit serial8250_probe(struct device *dev) 2387static int __devinit serial8250_probe(struct platform_device *dev)
2385{ 2388{
2386 struct plat_serial8250_port *p = dev->platform_data; 2389 struct plat_serial8250_port *p = dev->dev.platform_data;
2387 struct uart_port port; 2390 struct uart_port port;
2388 int ret, i; 2391 int ret, i;
2389 2392
@@ -2399,12 +2402,12 @@ static int __devinit serial8250_probe(struct device *dev)
2399 port.flags = p->flags; 2402 port.flags = p->flags;
2400 port.mapbase = p->mapbase; 2403 port.mapbase = p->mapbase;
2401 port.hub6 = p->hub6; 2404 port.hub6 = p->hub6;
2402 port.dev = dev; 2405 port.dev = &dev->dev;
2403 if (share_irqs) 2406 if (share_irqs)
2404 port.flags |= UPF_SHARE_IRQ; 2407 port.flags |= UPF_SHARE_IRQ;
2405 ret = serial8250_register_port(&port); 2408 ret = serial8250_register_port(&port);
2406 if (ret < 0) { 2409 if (ret < 0) {
2407 dev_err(dev, "unable to register port at index %d " 2410 dev_err(&dev->dev, "unable to register port at index %d "
2408 "(IO%lx MEM%lx IRQ%d): %d\n", i, 2411 "(IO%lx MEM%lx IRQ%d): %d\n", i,
2409 p->iobase, p->mapbase, p->irq, ret); 2412 p->iobase, p->mapbase, p->irq, ret);
2410 } 2413 }
@@ -2415,54 +2418,55 @@ static int __devinit serial8250_probe(struct device *dev)
2415/* 2418/*
2416 * Remove serial ports registered against a platform device. 2419 * Remove serial ports registered against a platform device.
2417 */ 2420 */
2418static int __devexit serial8250_remove(struct device *dev) 2421static int __devexit serial8250_remove(struct platform_device *dev)
2419{ 2422{
2420 int i; 2423 int i;
2421 2424
2422 for (i = 0; i < UART_NR; i++) { 2425 for (i = 0; i < UART_NR; i++) {
2423 struct uart_8250_port *up = &serial8250_ports[i]; 2426 struct uart_8250_port *up = &serial8250_ports[i];
2424 2427
2425 if (up->port.dev == dev) 2428 if (up->port.dev == &dev->dev)
2426 serial8250_unregister_port(i); 2429 serial8250_unregister_port(i);
2427 } 2430 }
2428 return 0; 2431 return 0;
2429} 2432}
2430 2433
2431static int serial8250_suspend(struct device *dev, pm_message_t state) 2434static int serial8250_suspend(struct platform_device *dev, pm_message_t state)
2432{ 2435{
2433 int i; 2436 int i;
2434 2437
2435 for (i = 0; i < UART_NR; i++) { 2438 for (i = 0; i < UART_NR; i++) {
2436 struct uart_8250_port *up = &serial8250_ports[i]; 2439 struct uart_8250_port *up = &serial8250_ports[i];
2437 2440
2438 if (up->port.type != PORT_UNKNOWN && up->port.dev == dev) 2441 if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
2439 uart_suspend_port(&serial8250_reg, &up->port); 2442 uart_suspend_port(&serial8250_reg, &up->port);
2440 } 2443 }
2441 2444
2442 return 0; 2445 return 0;
2443} 2446}
2444 2447
2445static int serial8250_resume(struct device *dev) 2448static int serial8250_resume(struct platform_device *dev)
2446{ 2449{
2447 int i; 2450 int i;
2448 2451
2449 for (i = 0; i < UART_NR; i++) { 2452 for (i = 0; i < UART_NR; i++) {
2450 struct uart_8250_port *up = &serial8250_ports[i]; 2453 struct uart_8250_port *up = &serial8250_ports[i];
2451 2454
2452 if (up->port.type != PORT_UNKNOWN && up->port.dev == dev) 2455 if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)
2453 uart_resume_port(&serial8250_reg, &up->port); 2456 uart_resume_port(&serial8250_reg, &up->port);
2454 } 2457 }
2455 2458
2456 return 0; 2459 return 0;
2457} 2460}
2458 2461
2459static struct device_driver serial8250_isa_driver = { 2462static struct platform_driver serial8250_isa_driver = {
2460 .name = "serial8250",
2461 .bus = &platform_bus_type,
2462 .probe = serial8250_probe, 2463 .probe = serial8250_probe,
2463 .remove = __devexit_p(serial8250_remove), 2464 .remove = __devexit_p(serial8250_remove),
2464 .suspend = serial8250_suspend, 2465 .suspend = serial8250_suspend,
2465 .resume = serial8250_resume, 2466 .resume = serial8250_resume,
2467 .driver = {
2468 .name = "serial8250",
2469 },
2466}; 2470};
2467 2471
2468/* 2472/*
@@ -2608,7 +2612,7 @@ static int __init serial8250_init(void)
2608 2612
2609 serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev); 2613 serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev);
2610 2614
2611 ret = driver_register(&serial8250_isa_driver); 2615 ret = platform_driver_register(&serial8250_isa_driver);
2612 if (ret == 0) 2616 if (ret == 0)
2613 goto out; 2617 goto out;
2614 2618
@@ -2630,7 +2634,7 @@ static void __exit serial8250_exit(void)
2630 */ 2634 */
2631 serial8250_isa_devs = NULL; 2635 serial8250_isa_devs = NULL;
2632 2636
2633 driver_unregister(&serial8250_isa_driver); 2637 platform_driver_unregister(&serial8250_isa_driver);
2634 platform_device_unregister(isa_dev); 2638 platform_device_unregister(isa_dev);
2635 2639
2636 uart_unregister_driver(&serial8250_reg); 2640 uart_unregister_driver(&serial8250_reg);
diff --git a/drivers/serial/8250_pci.c b/drivers/serial/8250_pci.c
index 5c3c03932d6d..8adca0ce267f 100644
--- a/drivers/serial/8250_pci.c
+++ b/drivers/serial/8250_pci.c
@@ -468,7 +468,7 @@ static unsigned short timedia_eight_port[] = {
468 0x9167, 0x9168, 0xA066, 0xA167, 0xA168, 0 468 0x9167, 0x9168, 0xA066, 0xA167, 0xA168, 0
469}; 469};
470 470
471static struct timedia_struct { 471static const struct timedia_struct {
472 int num; 472 int num;
473 unsigned short *ids; 473 unsigned short *ids;
474} timedia_data[] = { 474} timedia_data[] = {
@@ -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/8250_pnp.c b/drivers/serial/8250_pnp.c
index 5d8660a42b77..b79ed0665d51 100644
--- a/drivers/serial/8250_pnp.c
+++ b/drivers/serial/8250_pnp.c
@@ -323,6 +323,8 @@ static const struct pnp_device_id pnp_dev_table[] = {
323 { "USR9180", 0 }, 323 { "USR9180", 0 },
324 /* U.S. Robotics 56K Voice INT PnP*/ 324 /* U.S. Robotics 56K Voice INT PnP*/
325 { "USR9190", 0 }, 325 { "USR9190", 0 },
326 /* HP Compaq Tablet PC tc1100 Wacom tablet */
327 { "WACF005", 0 },
326 /* Rockwell's (PORALiNK) 33600 INT PNP */ 328 /* Rockwell's (PORALiNK) 33600 INT PNP */
327 { "WCI0003", 0 }, 329 { "WCI0003", 0 },
328 /* Unkown PnP modems */ 330 /* Unkown PnP modems */
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index ff36f0c9fdad..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
@@ -507,7 +507,7 @@ config SERIAL_SUNSU_CONSOLE
507 507
508config SERIAL_MUX 508config SERIAL_MUX
509 tristate "Serial MUX support" 509 tristate "Serial MUX support"
510 depends on PARISC 510 depends on GSC
511 select SERIAL_CORE 511 select SERIAL_CORE
512 default y 512 default y
513 ---help--- 513 ---help---
@@ -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 938d185841c9..d84476ee6592 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -49,7 +49,6 @@
49#include <linux/serial.h> 49#include <linux/serial.h>
50 50
51#include <asm/io.h> 51#include <asm/io.h>
52#include <asm/irq.h>
53#include <asm/sizes.h> 52#include <asm/sizes.h>
54#include <asm/hardware/amba.h> 53#include <asm/hardware/amba.h>
55#include <asm/hardware/clock.h> 54#include <asm/hardware/clock.h>
@@ -63,7 +62,8 @@
63 62
64#define AMBA_ISR_PASS_LIMIT 256 63#define AMBA_ISR_PASS_LIMIT 256
65 64
66#define UART_DUMMY_RSR_RX 256 65#define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE)
66#define UART_DUMMY_DR_RX (1 << 16)
67 67
68/* 68/*
69 * We wrap our port structure around the generic uart_port. 69 * We wrap our port structure around the generic uart_port.
@@ -116,7 +116,7 @@ pl011_rx_chars(struct uart_amba_port *uap)
116#endif 116#endif
117{ 117{
118 struct tty_struct *tty = uap->port.info->tty; 118 struct tty_struct *tty = uap->port.info->tty;
119 unsigned int status, ch, flag, rsr, max_count = 256; 119 unsigned int status, ch, flag, max_count = 256;
120 120
121 status = readw(uap->port.membase + UART01x_FR); 121 status = readw(uap->port.membase + UART01x_FR);
122 while ((status & UART01x_FR_RXFE) == 0 && max_count--) { 122 while ((status & UART01x_FR_RXFE) == 0 && max_count--) {
@@ -129,7 +129,7 @@ pl011_rx_chars(struct uart_amba_port *uap)
129 */ 129 */
130 } 130 }
131 131
132 ch = readw(uap->port.membase + UART01x_DR); 132 ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX;
133 flag = TTY_NORMAL; 133 flag = TTY_NORMAL;
134 uap->port.icount.rx++; 134 uap->port.icount.rx++;
135 135
@@ -137,34 +137,33 @@ pl011_rx_chars(struct uart_amba_port *uap)
137 * Note that the error handling code is 137 * Note that the error handling code is
138 * out of the main execution path 138 * out of the main execution path
139 */ 139 */
140 rsr = readw(uap->port.membase + UART01x_RSR) | UART_DUMMY_RSR_RX; 140 if (unlikely(ch & UART_DR_ERROR)) {
141 if (unlikely(rsr & UART01x_RSR_ANY)) { 141 if (ch & UART011_DR_BE) {
142 if (rsr & UART01x_RSR_BE) { 142 ch &= ~(UART011_DR_FE | UART011_DR_PE);
143 rsr &= ~(UART01x_RSR_FE | UART01x_RSR_PE);
144 uap->port.icount.brk++; 143 uap->port.icount.brk++;
145 if (uart_handle_break(&uap->port)) 144 if (uart_handle_break(&uap->port))
146 goto ignore_char; 145 goto ignore_char;
147 } else if (rsr & UART01x_RSR_PE) 146 } else if (ch & UART011_DR_PE)
148 uap->port.icount.parity++; 147 uap->port.icount.parity++;
149 else if (rsr & UART01x_RSR_FE) 148 else if (ch & UART011_DR_FE)
150 uap->port.icount.frame++; 149 uap->port.icount.frame++;
151 if (rsr & UART01x_RSR_OE) 150 if (ch & UART011_DR_OE)
152 uap->port.icount.overrun++; 151 uap->port.icount.overrun++;
153 152
154 rsr &= uap->port.read_status_mask; 153 ch &= uap->port.read_status_mask;
155 154
156 if (rsr & UART01x_RSR_BE) 155 if (ch & UART011_DR_BE)
157 flag = TTY_BREAK; 156 flag = TTY_BREAK;
158 else if (rsr & UART01x_RSR_PE) 157 else if (ch & UART011_DR_PE)
159 flag = TTY_PARITY; 158 flag = TTY_PARITY;
160 else if (rsr & UART01x_RSR_FE) 159 else if (ch & UART011_DR_FE)
161 flag = TTY_FRAME; 160 flag = TTY_FRAME;
162 } 161 }
163 162
164 if (uart_handle_sysrq_char(&uap->port, ch, regs)) 163 if (uart_handle_sysrq_char(&uap->port, ch & 255, regs))
165 goto ignore_char; 164 goto ignore_char;
166 165
167 uart_insert_char(&uap->port, rsr, UART01x_RSR_OE, ch, flag); 166 uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
168 167
169 ignore_char: 168 ignore_char:
170 status = readw(uap->port.membase + UART01x_FR); 169 status = readw(uap->port.membase + UART01x_FR);
@@ -476,33 +475,33 @@ pl011_set_termios(struct uart_port *port, struct termios *termios,
476 */ 475 */
477 uart_update_timeout(port, termios->c_cflag, baud); 476 uart_update_timeout(port, termios->c_cflag, baud);
478 477
479 port->read_status_mask = UART01x_RSR_OE; 478 port->read_status_mask = UART011_DR_OE | 255;
480 if (termios->c_iflag & INPCK) 479 if (termios->c_iflag & INPCK)
481 port->read_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE; 480 port->read_status_mask |= UART011_DR_FE | UART011_DR_PE;
482 if (termios->c_iflag & (BRKINT | PARMRK)) 481 if (termios->c_iflag & (BRKINT | PARMRK))
483 port->read_status_mask |= UART01x_RSR_BE; 482 port->read_status_mask |= UART011_DR_BE;
484 483
485 /* 484 /*
486 * Characters to ignore 485 * Characters to ignore
487 */ 486 */
488 port->ignore_status_mask = 0; 487 port->ignore_status_mask = 0;
489 if (termios->c_iflag & IGNPAR) 488 if (termios->c_iflag & IGNPAR)
490 port->ignore_status_mask |= UART01x_RSR_FE | UART01x_RSR_PE; 489 port->ignore_status_mask |= UART011_DR_FE | UART011_DR_PE;
491 if (termios->c_iflag & IGNBRK) { 490 if (termios->c_iflag & IGNBRK) {
492 port->ignore_status_mask |= UART01x_RSR_BE; 491 port->ignore_status_mask |= UART011_DR_BE;
493 /* 492 /*
494 * If we're ignoring parity and break indicators, 493 * If we're ignoring parity and break indicators,
495 * ignore overruns too (for real raw support). 494 * ignore overruns too (for real raw support).
496 */ 495 */
497 if (termios->c_iflag & IGNPAR) 496 if (termios->c_iflag & IGNPAR)
498 port->ignore_status_mask |= UART01x_RSR_OE; 497 port->ignore_status_mask |= UART011_DR_OE;
499 } 498 }
500 499
501 /* 500 /*
502 * Ignore all characters if CREAD is not set. 501 * Ignore all characters if CREAD is not set.
503 */ 502 */
504 if ((termios->c_cflag & CREAD) == 0) 503 if ((termios->c_cflag & CREAD) == 0)
505 port->ignore_status_mask |= UART_DUMMY_RSR_RX; 504 port->ignore_status_mask |= UART_DUMMY_DR_RX;
506 505
507 if (UART_ENABLE_MS(port, termios->c_cflag)) 506 if (UART_ENABLE_MS(port, termios->c_cflag))
508 pl011_enable_ms(port); 507 pl011_enable_ms(port);
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c
index 25825f2aba22..987d22b53c22 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -7,7 +7,7 @@
7 * Based on ppc8xx.c by Thomas Gleixner 7 * Based on ppc8xx.c by Thomas Gleixner
8 * Based on drivers/serial/amba.c by Russell King 8 * Based on drivers/serial/amba.c by Russell King
9 * 9 *
10 * Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2) 10 * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
11 * Pantelis Antoniou (panto@intracom.gr) (CPM1) 11 * Pantelis Antoniou (panto@intracom.gr) (CPM1)
12 * 12 *
13 * Copyright (C) 2004 Freescale Semiconductor, Inc. 13 * Copyright (C) 2004 Freescale Semiconductor, Inc.
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
index 4b0786e7eb7f..d789ee55cbb7 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Driver for CPM (SCC/SMC) serial ports; CPM1 definitions 4 * Driver for CPM (SCC/SMC) serial ports; CPM1 definitions
5 * 5 *
6 * Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2) 6 * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
7 * Pantelis Antoniou (panto@intracom.gr) (CPM1) 7 * Pantelis Antoniou (panto@intracom.gr) (CPM1)
8 * 8 *
9 * Copyright (C) 2004 Freescale Semiconductor, Inc. 9 * Copyright (C) 2004 Freescale Semiconductor, Inc.
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
index 15ad58d94889..fd9e53ed3feb 100644
--- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c
@@ -3,7 +3,7 @@
3 * 3 *
4 * Driver for CPM (SCC/SMC) serial ports; CPM2 definitions 4 * Driver for CPM (SCC/SMC) serial ports; CPM2 definitions
5 * 5 *
6 * Maintainer: Kumar Gala (kumar.gala@freescale.com) (CPM2) 6 * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
7 * Pantelis Antoniou (panto@intracom.gr) (CPM1) 7 * Pantelis Antoniou (panto@intracom.gr) (CPM1)
8 * 8 *
9 * Copyright (C) 2004 Freescale Semiconductor, Inc. 9 * Copyright (C) 2004 Freescale Semiconductor, Inc.
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index e63b9dffc8d7..4d8516d1bb71 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -1,9 +1,9 @@
1/* 1/*
2 * dz.c: Serial port driver for DECStations equiped 2 * dz.c: Serial port driver for DECStations equiped
3 * with the DZ chipset. 3 * with the DZ chipset.
4 * 4 *
5 * Copyright (C) 1998 Olivier A. D. Lebaillif 5 * Copyright (C) 1998 Olivier A. D. Lebaillif
6 * 6 *
7 * Email: olivier.lebaillif@ifrsys.com 7 * Email: olivier.lebaillif@ifrsys.com
8 * 8 *
9 * [31-AUG-98] triemer 9 * [31-AUG-98] triemer
@@ -11,14 +11,14 @@
11 * removed base_addr code - moving address assignment to setup.c 11 * removed base_addr code - moving address assignment to setup.c
12 * Changed name of dz_init to rs_init to be consistent with tc code 12 * Changed name of dz_init to rs_init to be consistent with tc code
13 * [13-NOV-98] triemer fixed code to receive characters 13 * [13-NOV-98] triemer fixed code to receive characters
14 * after patches by harald to irq code. 14 * after patches by harald to irq code.
15 * [09-JAN-99] triemer minor fix for schedule - due to removal of timeout 15 * [09-JAN-99] triemer minor fix for schedule - due to removal of timeout
16 * field from "current" - somewhere between 2.1.121 and 2.1.131 16 * field from "current" - somewhere between 2.1.121 and 2.1.131
17 Qua Jun 27 15:02:26 BRT 2001 17 Qua Jun 27 15:02:26 BRT 2001
18 * [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups 18 * [27-JUN-2001] Arnaldo Carvalho de Melo <acme@conectiva.com.br> - cleanups
19 * 19 *
20 * Parts (C) 1999 David Airlie, airlied@linux.ie 20 * Parts (C) 1999 David Airlie, airlied@linux.ie
21 * [07-SEP-99] Bugfixes 21 * [07-SEP-99] Bugfixes
22 * 22 *
23 * [06-Jan-2002] Russell King <rmk@arm.linux.org.uk> 23 * [06-Jan-2002] Russell King <rmk@arm.linux.org.uk>
24 * Converted to new serial core 24 * Converted to new serial core
@@ -64,7 +64,7 @@ static struct dz_port dz_ports[DZ_NB_PORT];
64 64
65#ifdef DEBUG_DZ 65#ifdef DEBUG_DZ
66/* 66/*
67 * debugging code to send out chars via prom 67 * debugging code to send out chars via prom
68 */ 68 */
69static void debug_console(const char *s, int count) 69static void debug_console(const char *s, int count)
70{ 70{
@@ -82,7 +82,7 @@ static void debug_console(const char *s, int count)
82 * ------------------------------------------------------------ 82 * ------------------------------------------------------------
83 * dz_in () and dz_out () 83 * dz_in () and dz_out ()
84 * 84 *
85 * These routines are used to access the registers of the DZ 85 * These routines are used to access the registers of the DZ
86 * chip, hiding relocation differences between implementation. 86 * chip, hiding relocation differences between implementation.
87 * ------------------------------------------------------------ 87 * ------------------------------------------------------------
88 */ 88 */
@@ -106,8 +106,8 @@ static inline void dz_out(struct dz_port *dport, unsigned offset,
106 * ------------------------------------------------------------ 106 * ------------------------------------------------------------
107 * rs_stop () and rs_start () 107 * rs_stop () and rs_start ()
108 * 108 *
109 * These routines are called before setting or resetting 109 * These routines are called before setting or resetting
110 * tty->stopped. They enable or disable transmitter interrupts, 110 * tty->stopped. They enable or disable transmitter interrupts,
111 * as necessary. 111 * as necessary.
112 * ------------------------------------------------------------ 112 * ------------------------------------------------------------
113 */ 113 */
@@ -156,17 +156,17 @@ static void dz_enable_ms(struct uart_port *port)
156 156
157/* 157/*
158 * ------------------------------------------------------------ 158 * ------------------------------------------------------------
159 * Here starts the interrupt handling routines. All of the 159 * Here starts the interrupt handling routines. All of the
160 * following subroutines are declared as inline and are folded 160 * following subroutines are declared as inline and are folded
161 * into dz_interrupt. They were separated out for readability's 161 * into dz_interrupt. They were separated out for readability's
162 * sake. 162 * sake.
163 * 163 *
164 * Note: rs_interrupt() is a "fast" interrupt, which means that it 164 * Note: rs_interrupt() is a "fast" interrupt, which means that it
165 * runs with interrupts turned off. People who may want to modify 165 * runs with interrupts turned off. People who may want to modify
166 * rs_interrupt() should try to keep the interrupt handler as fast as 166 * rs_interrupt() should try to keep the interrupt handler as fast as
167 * possible. After you are done making modifications, it is not a bad 167 * possible. After you are done making modifications, it is not a bad
168 * idea to do: 168 * idea to do:
169 * 169 *
170 * make drivers/serial/dz.s 170 * make drivers/serial/dz.s
171 * 171 *
172 * and look at the resulting assemble code in dz.s. 172 * and look at the resulting assemble code in dz.s.
@@ -403,7 +403,7 @@ static void dz_set_mctrl(struct uart_port *uport, unsigned int mctrl)
403 * startup () 403 * startup ()
404 * 404 *
405 * various initialization tasks 405 * various initialization tasks
406 * ------------------------------------------------------------------- 406 * -------------------------------------------------------------------
407 */ 407 */
408static int dz_startup(struct uart_port *uport) 408static int dz_startup(struct uart_port *uport)
409{ 409{
@@ -430,13 +430,13 @@ static int dz_startup(struct uart_port *uport)
430 return 0; 430 return 0;
431} 431}
432 432
433/* 433/*
434 * ------------------------------------------------------------------- 434 * -------------------------------------------------------------------
435 * shutdown () 435 * shutdown ()
436 * 436 *
437 * This routine will shutdown a serial port; interrupts are disabled, and 437 * This routine will shutdown a serial port; interrupts are disabled, and
438 * DTR is dropped if the hangup on close termio flag is on. 438 * DTR is dropped if the hangup on close termio flag is on.
439 * ------------------------------------------------------------------- 439 * -------------------------------------------------------------------
440 */ 440 */
441static void dz_shutdown(struct uart_port *uport) 441static void dz_shutdown(struct uart_port *uport)
442{ 442{
@@ -451,7 +451,7 @@ static void dz_shutdown(struct uart_port *uport)
451 * release the bus after transmitting. This must be done when 451 * release the bus after transmitting. This must be done when
452 * the transmit shift register is empty, not be done when the 452 * the transmit shift register is empty, not be done when the
453 * transmit holding register is empty. This functionality 453 * transmit holding register is empty. This functionality
454 * allows an RS485 driver to be written in user space. 454 * allows an RS485 driver to be written in user space.
455 */ 455 */
456static unsigned int dz_tx_empty(struct uart_port *uport) 456static unsigned int dz_tx_empty(struct uart_port *uport)
457{ 457{
@@ -645,9 +645,9 @@ static void __init dz_init_ports(void)
645 645
646 if (mips_machtype == MACH_DS23100 || 646 if (mips_machtype == MACH_DS23100 ||
647 mips_machtype == MACH_DS5100) 647 mips_machtype == MACH_DS5100)
648 base = (unsigned long) KN01_DZ11_BASE; 648 base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_DZ11);
649 else 649 else
650 base = (unsigned long) KN02_DZ11_BASE; 650 base = CKSEG1ADDR(KN02_SLOT_BASE + KN02_DZ11);
651 651
652 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) { 652 for (i = 0, dport = dz_ports; i < DZ_NB_PORT; i++, dport++) {
653 spin_lock_init(&dport->port.lock); 653 spin_lock_init(&dport->port.lock);
@@ -695,13 +695,13 @@ static void dz_console_put_char(struct dz_port *dport, unsigned char ch)
695 695
696 spin_unlock_irqrestore(&dport->port.lock, flags); 696 spin_unlock_irqrestore(&dport->port.lock, flags);
697} 697}
698/* 698/*
699 * ------------------------------------------------------------------- 699 * -------------------------------------------------------------------
700 * dz_console_print () 700 * dz_console_print ()
701 * 701 *
702 * dz_console_print is registered for printk. 702 * dz_console_print is registered for printk.
703 * The console must be locked when we get here. 703 * The console must be locked when we get here.
704 * ------------------------------------------------------------------- 704 * -------------------------------------------------------------------
705 */ 705 */
706static void dz_console_print(struct console *cons, 706static void dz_console_print(struct console *cons,
707 const char *str, 707 const char *str,
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 4a54ff584700..83c4c1216587 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -921,9 +921,9 @@ static struct uart_driver imx_reg = {
921 .cons = IMX_CONSOLE, 921 .cons = IMX_CONSOLE,
922}; 922};
923 923
924static int serial_imx_suspend(struct device *_dev, pm_message_t state) 924static int serial_imx_suspend(struct platform_device *dev, pm_message_t state)
925{ 925{
926 struct imx_port *sport = dev_get_drvdata(_dev); 926 struct imx_port *sport = platform_get_drvdata(dev);
927 927
928 if (sport) 928 if (sport)
929 uart_suspend_port(&imx_reg, &sport->port); 929 uart_suspend_port(&imx_reg, &sport->port);
@@ -931,9 +931,9 @@ static int serial_imx_suspend(struct device *_dev, pm_message_t state)
931 return 0; 931 return 0;
932} 932}
933 933
934static int serial_imx_resume(struct device *_dev) 934static int serial_imx_resume(struct platform_device *dev)
935{ 935{
936 struct imx_port *sport = dev_get_drvdata(_dev); 936 struct imx_port *sport = platform_get_drvdata(dev);
937 937
938 if (sport) 938 if (sport)
939 uart_resume_port(&imx_reg, &sport->port); 939 uart_resume_port(&imx_reg, &sport->port);
@@ -941,21 +941,19 @@ static int serial_imx_resume(struct device *_dev)
941 return 0; 941 return 0;
942} 942}
943 943
944static int serial_imx_probe(struct device *_dev) 944static int serial_imx_probe(struct platform_device *dev)
945{ 945{
946 struct platform_device *dev = to_platform_device(_dev); 946 imx_ports[dev->id].port.dev = &dev->dev;
947
948 imx_ports[dev->id].port.dev = _dev;
949 uart_add_one_port(&imx_reg, &imx_ports[dev->id].port); 947 uart_add_one_port(&imx_reg, &imx_ports[dev->id].port);
950 dev_set_drvdata(_dev, &imx_ports[dev->id]); 948 platform_set_drvdata(dev, &imx_ports[dev->id]);
951 return 0; 949 return 0;
952} 950}
953 951
954static int serial_imx_remove(struct device *_dev) 952static int serial_imx_remove(struct platform_device *dev)
955{ 953{
956 struct imx_port *sport = dev_get_drvdata(_dev); 954 struct imx_port *sport = platform_get_drvdata(dev);
957 955
958 dev_set_drvdata(_dev, NULL); 956 platform_set_drvdata(dev, NULL);
959 957
960 if (sport) 958 if (sport)
961 uart_remove_one_port(&imx_reg, &sport->port); 959 uart_remove_one_port(&imx_reg, &sport->port);
@@ -963,14 +961,15 @@ static int serial_imx_remove(struct device *_dev)
963 return 0; 961 return 0;
964} 962}
965 963
966static struct device_driver serial_imx_driver = { 964static struct platform_driver serial_imx_driver = {
967 .name = "imx-uart",
968 .bus = &platform_bus_type,
969 .probe = serial_imx_probe, 965 .probe = serial_imx_probe,
970 .remove = serial_imx_remove, 966 .remove = serial_imx_remove,
971 967
972 .suspend = serial_imx_suspend, 968 .suspend = serial_imx_suspend,
973 .resume = serial_imx_resume, 969 .resume = serial_imx_resume,
970 .driver = {
971 .name = "imx-uart",
972 },
974}; 973};
975 974
976static int __init imx_serial_init(void) 975static int __init imx_serial_init(void)
@@ -985,7 +984,7 @@ static int __init imx_serial_init(void)
985 if (ret) 984 if (ret)
986 return ret; 985 return ret;
987 986
988 ret = driver_register(&serial_imx_driver); 987 ret = platform_driver_register(&serial_imx_driver);
989 if (ret != 0) 988 if (ret != 0)
990 uart_unregister_driver(&imx_reg); 989 uart_unregister_driver(&imx_reg);
991 990
@@ -995,7 +994,7 @@ static int __init imx_serial_init(void)
995static void __exit imx_serial_exit(void) 994static void __exit imx_serial_exit(void)
996{ 995{
997 uart_unregister_driver(&imx_reg); 996 uart_unregister_driver(&imx_reg);
998 driver_unregister(&serial_imx_driver); 997 platform_driver_unregister(&serial_imx_driver);
999} 998}
1000 999
1001module_init(imx_serial_init); 1000module_init(imx_serial_init);
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 0dd08a09e7e6..b8727d9bf690 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -717,16 +717,15 @@ static struct uart_driver mpc52xx_uart_driver = {
717/* ======================================================================== */ 717/* ======================================================================== */
718 718
719static int __devinit 719static int __devinit
720mpc52xx_uart_probe(struct device *dev) 720mpc52xx_uart_probe(struct platform_device *dev)
721{ 721{
722 struct platform_device *pdev = to_platform_device(dev); 722 struct resource *res = dev->resource;
723 struct resource *res = pdev->resource;
724 723
725 struct uart_port *port = NULL; 724 struct uart_port *port = NULL;
726 int i, idx, ret; 725 int i, idx, ret;
727 726
728 /* Check validity & presence */ 727 /* Check validity & presence */
729 idx = pdev->id; 728 idx = dev->id;
730 if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM) 729 if (idx < 0 || idx >= MPC52xx_PSC_MAXNUM)
731 return -EINVAL; 730 return -EINVAL;
732 731
@@ -749,7 +748,7 @@ mpc52xx_uart_probe(struct device *dev)
749 port->ops = &mpc52xx_uart_ops; 748 port->ops = &mpc52xx_uart_ops;
750 749
751 /* Search for IRQ and mapbase */ 750 /* Search for IRQ and mapbase */
752 for (i=0 ; i<pdev->num_resources ; i++, res++) { 751 for (i=0 ; i<dev->num_resources ; i++, res++) {
753 if (res->flags & IORESOURCE_MEM) 752 if (res->flags & IORESOURCE_MEM)
754 port->mapbase = res->start; 753 port->mapbase = res->start;
755 else if (res->flags & IORESOURCE_IRQ) 754 else if (res->flags & IORESOURCE_IRQ)
@@ -761,17 +760,17 @@ mpc52xx_uart_probe(struct device *dev)
761 /* Add the port to the uart sub-system */ 760 /* Add the port to the uart sub-system */
762 ret = uart_add_one_port(&mpc52xx_uart_driver, port); 761 ret = uart_add_one_port(&mpc52xx_uart_driver, port);
763 if (!ret) 762 if (!ret)
764 dev_set_drvdata(dev, (void*)port); 763 platform_set_drvdata(dev, (void*)port);
765 764
766 return ret; 765 return ret;
767} 766}
768 767
769static int 768static int
770mpc52xx_uart_remove(struct device *dev) 769mpc52xx_uart_remove(struct platform_device *dev)
771{ 770{
772 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); 771 struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
773 772
774 dev_set_drvdata(dev, NULL); 773 platform_set_drvdata(dev, NULL);
775 774
776 if (port) 775 if (port)
777 uart_remove_one_port(&mpc52xx_uart_driver, port); 776 uart_remove_one_port(&mpc52xx_uart_driver, port);
@@ -781,9 +780,9 @@ mpc52xx_uart_remove(struct device *dev)
781 780
782#ifdef CONFIG_PM 781#ifdef CONFIG_PM
783static int 782static int
784mpc52xx_uart_suspend(struct device *dev, pm_message_t state) 783mpc52xx_uart_suspend(struct platform_device *dev, pm_message_t state)
785{ 784{
786 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); 785 struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
787 786
788 if (sport) 787 if (sport)
789 uart_suspend_port(&mpc52xx_uart_driver, port); 788 uart_suspend_port(&mpc52xx_uart_driver, port);
@@ -792,9 +791,9 @@ mpc52xx_uart_suspend(struct device *dev, pm_message_t state)
792} 791}
793 792
794static int 793static int
795mpc52xx_uart_resume(struct device *dev) 794mpc52xx_uart_resume(struct platform_device *dev)
796{ 795{
797 struct uart_port *port = (struct uart_port *) dev_get_drvdata(dev); 796 struct uart_port *port = (struct uart_port *) platform_get_drvdata(dev);
798 797
799 if (port) 798 if (port)
800 uart_resume_port(&mpc52xx_uart_driver, port); 799 uart_resume_port(&mpc52xx_uart_driver, port);
@@ -803,15 +802,16 @@ mpc52xx_uart_resume(struct device *dev)
803} 802}
804#endif 803#endif
805 804
806static struct device_driver mpc52xx_uart_platform_driver = { 805static struct platform_driver mpc52xx_uart_platform_driver = {
807 .name = "mpc52xx-psc",
808 .bus = &platform_bus_type,
809 .probe = mpc52xx_uart_probe, 806 .probe = mpc52xx_uart_probe,
810 .remove = mpc52xx_uart_remove, 807 .remove = mpc52xx_uart_remove,
811#ifdef CONFIG_PM 808#ifdef CONFIG_PM
812 .suspend = mpc52xx_uart_suspend, 809 .suspend = mpc52xx_uart_suspend,
813 .resume = mpc52xx_uart_resume, 810 .resume = mpc52xx_uart_resume,
814#endif 811#endif
812 .driver = {
813 .name = "mpc52xx-psc",
814 },
815}; 815};
816 816
817 817
@@ -828,7 +828,7 @@ mpc52xx_uart_init(void)
828 828
829 ret = uart_register_driver(&mpc52xx_uart_driver); 829 ret = uart_register_driver(&mpc52xx_uart_driver);
830 if (ret == 0) { 830 if (ret == 0) {
831 ret = driver_register(&mpc52xx_uart_platform_driver); 831 ret = platform_driver_register(&mpc52xx_uart_platform_driver);
832 if (ret) 832 if (ret)
833 uart_unregister_driver(&mpc52xx_uart_driver); 833 uart_unregister_driver(&mpc52xx_uart_driver);
834 } 834 }
@@ -839,7 +839,7 @@ mpc52xx_uart_init(void)
839static void __exit 839static void __exit
840mpc52xx_uart_exit(void) 840mpc52xx_uart_exit(void)
841{ 841{
842 driver_unregister(&mpc52xx_uart_platform_driver); 842 platform_driver_unregister(&mpc52xx_uart_platform_driver);
843 uart_unregister_driver(&mpc52xx_uart_driver); 843 uart_unregister_driver(&mpc52xx_uart_driver);
844} 844}
845 845
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index ba8838b234da..8f83e4007ecd 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -1551,15 +1551,14 @@ mpsc_shared_unmap_regs(void)
1551} 1551}
1552 1552
1553static int 1553static int
1554mpsc_shared_drv_probe(struct device *dev) 1554mpsc_shared_drv_probe(struct platform_device *dev)
1555{ 1555{
1556 struct platform_device *pd = to_platform_device(dev);
1557 struct mpsc_shared_pdata *pdata; 1556 struct mpsc_shared_pdata *pdata;
1558 int rc = -ENODEV; 1557 int rc = -ENODEV;
1559 1558
1560 if (pd->id == 0) { 1559 if (dev->id == 0) {
1561 if (!(rc = mpsc_shared_map_regs(pd))) { 1560 if (!(rc = mpsc_shared_map_regs(dev))) {
1562 pdata = (struct mpsc_shared_pdata *)dev->platform_data; 1561 pdata = (struct mpsc_shared_pdata *)dev->dev.platform_data;
1563 1562
1564 mpsc_shared_regs.MPSC_MRR_m = pdata->mrr_val; 1563 mpsc_shared_regs.MPSC_MRR_m = pdata->mrr_val;
1565 mpsc_shared_regs.MPSC_RCRR_m= pdata->rcrr_val; 1564 mpsc_shared_regs.MPSC_RCRR_m= pdata->rcrr_val;
@@ -1577,12 +1576,11 @@ mpsc_shared_drv_probe(struct device *dev)
1577} 1576}
1578 1577
1579static int 1578static int
1580mpsc_shared_drv_remove(struct device *dev) 1579mpsc_shared_drv_remove(struct platform_device *dev)
1581{ 1580{
1582 struct platform_device *pd = to_platform_device(dev);
1583 int rc = -ENODEV; 1581 int rc = -ENODEV;
1584 1582
1585 if (pd->id == 0) { 1583 if (dev->id == 0) {
1586 mpsc_shared_unmap_regs(); 1584 mpsc_shared_unmap_regs();
1587 mpsc_shared_regs.MPSC_MRR_m = 0; 1585 mpsc_shared_regs.MPSC_MRR_m = 0;
1588 mpsc_shared_regs.MPSC_RCRR_m = 0; 1586 mpsc_shared_regs.MPSC_RCRR_m = 0;
@@ -1595,11 +1593,12 @@ mpsc_shared_drv_remove(struct device *dev)
1595 return rc; 1593 return rc;
1596} 1594}
1597 1595
1598static struct device_driver mpsc_shared_driver = { 1596static struct platform_driver mpsc_shared_driver = {
1599 .name = MPSC_SHARED_NAME,
1600 .bus = &platform_bus_type,
1601 .probe = mpsc_shared_drv_probe, 1597 .probe = mpsc_shared_drv_probe,
1602 .remove = mpsc_shared_drv_remove, 1598 .remove = mpsc_shared_drv_remove,
1599 .driver = {
1600 .name = MPSC_SHARED_NAME,
1601 },
1603}; 1602};
1604 1603
1605/* 1604/*
@@ -1732,19 +1731,18 @@ mpsc_drv_get_platform_data(struct mpsc_port_info *pi,
1732} 1731}
1733 1732
1734static int 1733static int
1735mpsc_drv_probe(struct device *dev) 1734mpsc_drv_probe(struct platform_device *dev)
1736{ 1735{
1737 struct platform_device *pd = to_platform_device(dev);
1738 struct mpsc_port_info *pi; 1736 struct mpsc_port_info *pi;
1739 int rc = -ENODEV; 1737 int rc = -ENODEV;
1740 1738
1741 pr_debug("mpsc_drv_probe: Adding MPSC %d\n", pd->id); 1739 pr_debug("mpsc_drv_probe: Adding MPSC %d\n", dev->id);
1742 1740
1743 if (pd->id < MPSC_NUM_CTLRS) { 1741 if (dev->id < MPSC_NUM_CTLRS) {
1744 pi = &mpsc_ports[pd->id]; 1742 pi = &mpsc_ports[dev->id];
1745 1743
1746 if (!(rc = mpsc_drv_map_regs(pi, pd))) { 1744 if (!(rc = mpsc_drv_map_regs(pi, dev))) {
1747 mpsc_drv_get_platform_data(pi, pd, pd->id); 1745 mpsc_drv_get_platform_data(pi, dev, dev->id);
1748 1746
1749 if (!(rc = mpsc_make_ready(pi))) 1747 if (!(rc = mpsc_make_ready(pi)))
1750 if (!(rc = uart_add_one_port(&mpsc_reg, 1748 if (!(rc = uart_add_one_port(&mpsc_reg,
@@ -1764,27 +1762,26 @@ mpsc_drv_probe(struct device *dev)
1764} 1762}
1765 1763
1766static int 1764static int
1767mpsc_drv_remove(struct device *dev) 1765mpsc_drv_remove(struct platform_device *dev)
1768{ 1766{
1769 struct platform_device *pd = to_platform_device(dev); 1767 pr_debug("mpsc_drv_exit: Removing MPSC %d\n", dev->id);
1770 1768
1771 pr_debug("mpsc_drv_exit: Removing MPSC %d\n", pd->id); 1769 if (dev->id < MPSC_NUM_CTLRS) {
1772 1770 uart_remove_one_port(&mpsc_reg, &mpsc_ports[dev->id].port);
1773 if (pd->id < MPSC_NUM_CTLRS) { 1771 mpsc_release_port((struct uart_port *)&mpsc_ports[dev->id].port);
1774 uart_remove_one_port(&mpsc_reg, &mpsc_ports[pd->id].port); 1772 mpsc_drv_unmap_regs(&mpsc_ports[dev->id]);
1775 mpsc_release_port((struct uart_port *)&mpsc_ports[pd->id].port);
1776 mpsc_drv_unmap_regs(&mpsc_ports[pd->id]);
1777 return 0; 1773 return 0;
1778 } 1774 }
1779 else 1775 else
1780 return -ENODEV; 1776 return -ENODEV;
1781} 1777}
1782 1778
1783static struct device_driver mpsc_driver = { 1779static struct platform_driver mpsc_driver = {
1784 .name = MPSC_CTLR_NAME,
1785 .bus = &platform_bus_type,
1786 .probe = mpsc_drv_probe, 1780 .probe = mpsc_drv_probe,
1787 .remove = mpsc_drv_remove, 1781 .remove = mpsc_drv_remove,
1782 .driver = {
1783 .name = MPSC_CTLR_NAME,
1784 },
1788}; 1785};
1789 1786
1790static int __init 1787static int __init
@@ -1798,9 +1795,9 @@ mpsc_drv_init(void)
1798 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs)); 1795 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs));
1799 1796
1800 if (!(rc = uart_register_driver(&mpsc_reg))) { 1797 if (!(rc = uart_register_driver(&mpsc_reg))) {
1801 if (!(rc = driver_register(&mpsc_shared_driver))) { 1798 if (!(rc = platform_driver_register(&mpsc_shared_driver))) {
1802 if ((rc = driver_register(&mpsc_driver))) { 1799 if ((rc = platform_driver_register(&mpsc_driver))) {
1803 driver_unregister(&mpsc_shared_driver); 1800 platform_driver_unregister(&mpsc_shared_driver);
1804 uart_unregister_driver(&mpsc_reg); 1801 uart_unregister_driver(&mpsc_reg);
1805 } 1802 }
1806 } 1803 }
@@ -1815,8 +1812,8 @@ mpsc_drv_init(void)
1815static void __exit 1812static void __exit
1816mpsc_drv_exit(void) 1813mpsc_drv_exit(void)
1817{ 1814{
1818 driver_unregister(&mpsc_driver); 1815 platform_driver_unregister(&mpsc_driver);
1819 driver_unregister(&mpsc_shared_driver); 1816 platform_driver_unregister(&mpsc_shared_driver);
1820 uart_unregister_driver(&mpsc_reg); 1817 uart_unregister_driver(&mpsc_reg);
1821 memset(mpsc_ports, 0, sizeof(mpsc_ports)); 1818 memset(mpsc_ports, 0, sizeof(mpsc_ports));
1822 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs)); 1819 memset(&mpsc_shared_regs, 0, sizeof(mpsc_shared_regs));
diff --git a/drivers/serial/mux.c b/drivers/serial/mux.c
index 660bae5ba179..7633132a10aa 100644
--- a/drivers/serial/mux.c
+++ b/drivers/serial/mux.c
@@ -65,8 +65,8 @@ static struct uart_driver mux_driver = {
65 65
66static struct timer_list mux_timer; 66static struct timer_list mux_timer;
67 67
68#define UART_PUT_CHAR(p, c) __raw_writel((c), (unsigned long)(p)->membase + IO_DATA_REG_OFFSET) 68#define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + IO_DATA_REG_OFFSET)
69#define UART_GET_FIFO_CNT(p) __raw_readl((unsigned long)(p)->membase + IO_DCOUNT_REG_OFFSET) 69#define UART_GET_FIFO_CNT(p) __raw_readl((p)->membase + IO_DCOUNT_REG_OFFSET)
70#define GET_MUX_PORTS(iodc_data) ((((iodc_data)[4] & 0xf0) >> 4) * 8) + 8 70#define GET_MUX_PORTS(iodc_data) ((((iodc_data)[4] & 0xf0) >> 4) * 8) + 8
71 71
72/** 72/**
@@ -79,10 +79,7 @@ static struct timer_list mux_timer;
79 */ 79 */
80static unsigned int mux_tx_empty(struct uart_port *port) 80static unsigned int mux_tx_empty(struct uart_port *port)
81{ 81{
82 unsigned int cnt = __raw_readl((unsigned long)port->membase 82 return UART_GET_FIFO_CNT(port) ? 0 : TIOCSER_TEMT;
83 + IO_DCOUNT_REG_OFFSET);
84
85 return cnt ? 0 : TIOCSER_TEMT;
86} 83}
87 84
88/** 85/**
@@ -218,8 +215,7 @@ static void mux_read(struct uart_port *port)
218 __u32 start_count = port->icount.rx; 215 __u32 start_count = port->icount.rx;
219 216
220 while(1) { 217 while(1) {
221 data = __raw_readl((unsigned long)port->membase 218 data = __raw_readl(port->membase + IO_DATA_REG_OFFSET);
222 + IO_DATA_REG_OFFSET);
223 219
224 if (MUX_STATUS(data)) 220 if (MUX_STATUS(data))
225 continue; 221 continue;
@@ -481,6 +477,13 @@ static int __init mux_probe(struct parisc_device *dev)
481 port->ops = &mux_pops; 477 port->ops = &mux_pops;
482 port->flags = UPF_BOOT_AUTOCONF; 478 port->flags = UPF_BOOT_AUTOCONF;
483 port->line = port_cnt; 479 port->line = port_cnt;
480
481 /* The port->timeout needs to match what is present in
482 * uart_wait_until_sent in serial_core.c. Otherwise
483 * the time spent in msleep_interruptable will be very
484 * long, causing the appearance of a console hang.
485 */
486 port->timeout = HZ / 50;
484 spin_lock_init(&port->lock); 487 spin_lock_init(&port->lock);
485 status = uart_add_one_port(&mux_driver, port); 488 status = uart_add_one_port(&mux_driver, port);
486 BUG_ON(status); 489 BUG_ON(status);
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 16b2f9417af9..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);
@@ -805,9 +805,9 @@ static struct uart_driver serial_pxa_reg = {
805 .cons = PXA_CONSOLE, 805 .cons = PXA_CONSOLE,
806}; 806};
807 807
808static int serial_pxa_suspend(struct device *_dev, pm_message_t state) 808static int serial_pxa_suspend(struct platform_device *dev, pm_message_t state)
809{ 809{
810 struct uart_pxa_port *sport = dev_get_drvdata(_dev); 810 struct uart_pxa_port *sport = platform_get_drvdata(dev);
811 811
812 if (sport) 812 if (sport)
813 uart_suspend_port(&serial_pxa_reg, &sport->port); 813 uart_suspend_port(&serial_pxa_reg, &sport->port);
@@ -815,9 +815,9 @@ static int serial_pxa_suspend(struct device *_dev, pm_message_t state)
815 return 0; 815 return 0;
816} 816}
817 817
818static int serial_pxa_resume(struct device *_dev) 818static int serial_pxa_resume(struct platform_device *dev)
819{ 819{
820 struct uart_pxa_port *sport = dev_get_drvdata(_dev); 820 struct uart_pxa_port *sport = platform_get_drvdata(dev);
821 821
822 if (sport) 822 if (sport)
823 uart_resume_port(&serial_pxa_reg, &sport->port); 823 uart_resume_port(&serial_pxa_reg, &sport->port);
@@ -825,21 +825,19 @@ static int serial_pxa_resume(struct device *_dev)
825 return 0; 825 return 0;
826} 826}
827 827
828static int serial_pxa_probe(struct device *_dev) 828static int serial_pxa_probe(struct platform_device *dev)
829{ 829{
830 struct platform_device *dev = to_platform_device(_dev); 830 serial_pxa_ports[dev->id].port.dev = &dev->dev;
831
832 serial_pxa_ports[dev->id].port.dev = _dev;
833 uart_add_one_port(&serial_pxa_reg, &serial_pxa_ports[dev->id].port); 831 uart_add_one_port(&serial_pxa_reg, &serial_pxa_ports[dev->id].port);
834 dev_set_drvdata(_dev, &serial_pxa_ports[dev->id]); 832 platform_set_drvdata(dev, &serial_pxa_ports[dev->id]);
835 return 0; 833 return 0;
836} 834}
837 835
838static int serial_pxa_remove(struct device *_dev) 836static int serial_pxa_remove(struct platform_device *dev)
839{ 837{
840 struct uart_pxa_port *sport = dev_get_drvdata(_dev); 838 struct uart_pxa_port *sport = platform_get_drvdata(dev);
841 839
842 dev_set_drvdata(_dev, NULL); 840 platform_set_drvdata(dev, NULL);
843 841
844 if (sport) 842 if (sport)
845 uart_remove_one_port(&serial_pxa_reg, &sport->port); 843 uart_remove_one_port(&serial_pxa_reg, &sport->port);
@@ -847,14 +845,15 @@ static int serial_pxa_remove(struct device *_dev)
847 return 0; 845 return 0;
848} 846}
849 847
850static struct device_driver serial_pxa_driver = { 848static struct platform_driver serial_pxa_driver = {
851 .name = "pxa2xx-uart",
852 .bus = &platform_bus_type,
853 .probe = serial_pxa_probe, 849 .probe = serial_pxa_probe,
854 .remove = serial_pxa_remove, 850 .remove = serial_pxa_remove,
855 851
856 .suspend = serial_pxa_suspend, 852 .suspend = serial_pxa_suspend,
857 .resume = serial_pxa_resume, 853 .resume = serial_pxa_resume,
854 .driver = {
855 .name = "pxa2xx-uart",
856 },
858}; 857};
859 858
860int __init serial_pxa_init(void) 859int __init serial_pxa_init(void)
@@ -865,7 +864,7 @@ int __init serial_pxa_init(void)
865 if (ret != 0) 864 if (ret != 0)
866 return ret; 865 return ret;
867 866
868 ret = driver_register(&serial_pxa_driver); 867 ret = platform_driver_register(&serial_pxa_driver);
869 if (ret != 0) 868 if (ret != 0)
870 uart_unregister_driver(&serial_pxa_reg); 869 uart_unregister_driver(&serial_pxa_reg);
871 870
@@ -874,7 +873,7 @@ int __init serial_pxa_init(void)
874 873
875void __exit serial_pxa_exit(void) 874void __exit serial_pxa_exit(void)
876{ 875{
877 driver_unregister(&serial_pxa_driver); 876 platform_driver_unregister(&serial_pxa_driver);
878 uart_unregister_driver(&serial_pxa_reg); 877 uart_unregister_driver(&serial_pxa_reg);
879} 878}
880 879
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 036792328d49..47681c4654e4 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1092,14 +1092,13 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
1092 1092
1093static int probe_index = 0; 1093static int probe_index = 0;
1094 1094
1095static int s3c24xx_serial_probe(struct device *_dev, 1095static int s3c24xx_serial_probe(struct platform_device *dev,
1096 struct s3c24xx_uart_info *info) 1096 struct s3c24xx_uart_info *info)
1097{ 1097{
1098 struct s3c24xx_uart_port *ourport; 1098 struct s3c24xx_uart_port *ourport;
1099 struct platform_device *dev = to_platform_device(_dev);
1100 int ret; 1099 int ret;
1101 1100
1102 dbg("s3c24xx_serial_probe(%p, %p) %d\n", _dev, info, probe_index); 1101 dbg("s3c24xx_serial_probe(%p, %p) %d\n", dev, info, probe_index);
1103 1102
1104 ourport = &s3c24xx_serial_ports[probe_index]; 1103 ourport = &s3c24xx_serial_ports[probe_index];
1105 probe_index++; 1104 probe_index++;
@@ -1112,7 +1111,7 @@ static int s3c24xx_serial_probe(struct device *_dev,
1112 1111
1113 dbg("%s: adding port\n", __FUNCTION__); 1112 dbg("%s: adding port\n", __FUNCTION__);
1114 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port); 1113 uart_add_one_port(&s3c24xx_uart_drv, &ourport->port);
1115 dev_set_drvdata(_dev, &ourport->port); 1114 platform_set_drvdata(dev, &ourport->port);
1116 1115
1117 return 0; 1116 return 0;
1118 1117
@@ -1120,9 +1119,9 @@ static int s3c24xx_serial_probe(struct device *_dev,
1120 return ret; 1119 return ret;
1121} 1120}
1122 1121
1123static int s3c24xx_serial_remove(struct device *_dev) 1122static int s3c24xx_serial_remove(struct platform_device *dev)
1124{ 1123{
1125 struct uart_port *port = s3c24xx_dev_to_port(_dev); 1124 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev);
1126 1125
1127 if (port) 1126 if (port)
1128 uart_remove_one_port(&s3c24xx_uart_drv, port); 1127 uart_remove_one_port(&s3c24xx_uart_drv, port);
@@ -1134,9 +1133,9 @@ static int s3c24xx_serial_remove(struct device *_dev)
1134 1133
1135#ifdef CONFIG_PM 1134#ifdef CONFIG_PM
1136 1135
1137static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state) 1136static int s3c24xx_serial_suspend(struct platform_device *dev, pm_message_t state)
1138{ 1137{
1139 struct uart_port *port = s3c24xx_dev_to_port(dev); 1138 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev);
1140 1139
1141 if (port) 1140 if (port)
1142 uart_suspend_port(&s3c24xx_uart_drv, port); 1141 uart_suspend_port(&s3c24xx_uart_drv, port);
@@ -1144,9 +1143,9 @@ static int s3c24xx_serial_suspend(struct device *dev, pm_message_t state)
1144 return 0; 1143 return 0;
1145} 1144}
1146 1145
1147static int s3c24xx_serial_resume(struct device *dev) 1146static int s3c24xx_serial_resume(struct platform_device *dev)
1148{ 1147{
1149 struct uart_port *port = s3c24xx_dev_to_port(dev); 1148 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev);
1150 struct s3c24xx_uart_port *ourport = to_ourport(port); 1149 struct s3c24xx_uart_port *ourport = to_ourport(port);
1151 1150
1152 if (port) { 1151 if (port) {
@@ -1165,11 +1164,11 @@ static int s3c24xx_serial_resume(struct device *dev)
1165#define s3c24xx_serial_resume NULL 1164#define s3c24xx_serial_resume NULL
1166#endif 1165#endif
1167 1166
1168static int s3c24xx_serial_init(struct device_driver *drv, 1167static int s3c24xx_serial_init(struct platform_driver *drv,
1169 struct s3c24xx_uart_info *info) 1168 struct s3c24xx_uart_info *info)
1170{ 1169{
1171 dbg("s3c24xx_serial_init(%p,%p)\n", drv, info); 1170 dbg("s3c24xx_serial_init(%p,%p)\n", drv, info);
1172 return driver_register(drv); 1171 return platform_driver_register(drv);
1173} 1172}
1174 1173
1175 1174
@@ -1228,19 +1227,20 @@ static struct s3c24xx_uart_info s3c2400_uart_inf = {
1228 .reset_port = s3c2400_serial_resetport, 1227 .reset_port = s3c2400_serial_resetport,
1229}; 1228};
1230 1229
1231static int s3c2400_serial_probe(struct device *dev) 1230static int s3c2400_serial_probe(struct platform_device *dev)
1232{ 1231{
1233 return s3c24xx_serial_probe(dev, &s3c2400_uart_inf); 1232 return s3c24xx_serial_probe(dev, &s3c2400_uart_inf);
1234} 1233}
1235 1234
1236static struct device_driver s3c2400_serial_drv = { 1235static struct platform_driver s3c2400_serial_drv = {
1237 .name = "s3c2400-uart",
1238 .owner = THIS_MODULE,
1239 .bus = &platform_bus_type,
1240 .probe = s3c2400_serial_probe, 1236 .probe = s3c2400_serial_probe,
1241 .remove = s3c24xx_serial_remove, 1237 .remove = s3c24xx_serial_remove,
1242 .suspend = s3c24xx_serial_suspend, 1238 .suspend = s3c24xx_serial_suspend,
1243 .resume = s3c24xx_serial_resume, 1239 .resume = s3c24xx_serial_resume,
1240 .driver = {
1241 .name = "s3c2400-uart",
1242 .owner = THIS_MODULE,
1243 },
1244}; 1244};
1245 1245
1246static inline int s3c2400_serial_init(void) 1246static inline int s3c2400_serial_init(void)
@@ -1250,7 +1250,7 @@ static inline int s3c2400_serial_init(void)
1250 1250
1251static inline void s3c2400_serial_exit(void) 1251static inline void s3c2400_serial_exit(void)
1252{ 1252{
1253 driver_unregister(&s3c2400_serial_drv); 1253 platform_driver_unregister(&s3c2400_serial_drv);
1254} 1254}
1255 1255
1256#define s3c2400_uart_inf_at &s3c2400_uart_inf 1256#define s3c2400_uart_inf_at &s3c2400_uart_inf
@@ -1332,19 +1332,20 @@ static struct s3c24xx_uart_info s3c2410_uart_inf = {
1332 1332
1333/* device management */ 1333/* device management */
1334 1334
1335static int s3c2410_serial_probe(struct device *dev) 1335static int s3c2410_serial_probe(struct platform_device *dev)
1336{ 1336{
1337 return s3c24xx_serial_probe(dev, &s3c2410_uart_inf); 1337 return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
1338} 1338}
1339 1339
1340static struct device_driver s3c2410_serial_drv = { 1340static struct platform_driver s3c2410_serial_drv = {
1341 .name = "s3c2410-uart",
1342 .owner = THIS_MODULE,
1343 .bus = &platform_bus_type,
1344 .probe = s3c2410_serial_probe, 1341 .probe = s3c2410_serial_probe,
1345 .remove = s3c24xx_serial_remove, 1342 .remove = s3c24xx_serial_remove,
1346 .suspend = s3c24xx_serial_suspend, 1343 .suspend = s3c24xx_serial_suspend,
1347 .resume = s3c24xx_serial_resume, 1344 .resume = s3c24xx_serial_resume,
1345 .driver = {
1346 .name = "s3c2410-uart",
1347 .owner = THIS_MODULE,
1348 },
1348}; 1349};
1349 1350
1350static inline int s3c2410_serial_init(void) 1351static inline int s3c2410_serial_init(void)
@@ -1354,7 +1355,7 @@ static inline int s3c2410_serial_init(void)
1354 1355
1355static inline void s3c2410_serial_exit(void) 1356static inline void s3c2410_serial_exit(void)
1356{ 1357{
1357 driver_unregister(&s3c2410_serial_drv); 1358 platform_driver_unregister(&s3c2410_serial_drv);
1358} 1359}
1359 1360
1360#define s3c2410_uart_inf_at &s3c2410_uart_inf 1361#define s3c2410_uart_inf_at &s3c2410_uart_inf
@@ -1493,20 +1494,21 @@ static struct s3c24xx_uart_info s3c2440_uart_inf = {
1493 1494
1494/* device management */ 1495/* device management */
1495 1496
1496static int s3c2440_serial_probe(struct device *dev) 1497static int s3c2440_serial_probe(struct platform_device *dev)
1497{ 1498{
1498 dbg("s3c2440_serial_probe: dev=%p\n", dev); 1499 dbg("s3c2440_serial_probe: dev=%p\n", dev);
1499 return s3c24xx_serial_probe(dev, &s3c2440_uart_inf); 1500 return s3c24xx_serial_probe(dev, &s3c2440_uart_inf);
1500} 1501}
1501 1502
1502static struct device_driver s3c2440_serial_drv = { 1503static struct platform_driver s3c2440_serial_drv = {
1503 .name = "s3c2440-uart",
1504 .owner = THIS_MODULE,
1505 .bus = &platform_bus_type,
1506 .probe = s3c2440_serial_probe, 1504 .probe = s3c2440_serial_probe,
1507 .remove = s3c24xx_serial_remove, 1505 .remove = s3c24xx_serial_remove,
1508 .suspend = s3c24xx_serial_suspend, 1506 .suspend = s3c24xx_serial_suspend,
1509 .resume = s3c24xx_serial_resume, 1507 .resume = s3c24xx_serial_resume,
1508 .driver = {
1509 .name = "s3c2440-uart",
1510 .owner = THIS_MODULE,
1511 },
1510}; 1512};
1511 1513
1512 1514
@@ -1517,7 +1519,7 @@ static inline int s3c2440_serial_init(void)
1517 1519
1518static inline void s3c2440_serial_exit(void) 1520static inline void s3c2440_serial_exit(void)
1519{ 1521{
1520 driver_unregister(&s3c2440_serial_drv); 1522 platform_driver_unregister(&s3c2440_serial_drv);
1521} 1523}
1522 1524
1523#define s3c2440_uart_inf_at &s3c2440_uart_inf 1525#define s3c2440_uart_inf_at &s3c2440_uart_inf
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index ed618cc7ae96..25a086458ab9 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -156,19 +156,16 @@ static void sa1100_stop_tx(struct uart_port *port)
156} 156}
157 157
158/* 158/*
159 * interrupts may not be disabled on entry 159 * port locked and interrupts disabled
160 */ 160 */
161static void sa1100_start_tx(struct uart_port *port) 161static void sa1100_start_tx(struct uart_port *port)
162{ 162{
163 struct sa1100_port *sport = (struct sa1100_port *)port; 163 struct sa1100_port *sport = (struct sa1100_port *)port;
164 unsigned long flags;
165 u32 utcr3; 164 u32 utcr3;
166 165
167 spin_lock_irqsave(&sport->port.lock, flags);
168 utcr3 = UART_GET_UTCR3(sport); 166 utcr3 = UART_GET_UTCR3(sport);
169 sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS); 167 sport->port.read_status_mask |= UTSR0_TO_SM(UTSR0_TFS);
170 UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE); 168 UART_PUT_UTCR3(sport, utcr3 | UTCR3_TIE);
171 spin_unlock_irqrestore(&sport->port.lock, flags);
172} 169}
173 170
174/* 171/*
@@ -834,9 +831,9 @@ static struct uart_driver sa1100_reg = {
834 .cons = SA1100_CONSOLE, 831 .cons = SA1100_CONSOLE,
835}; 832};
836 833
837static int sa1100_serial_suspend(struct device *_dev, pm_message_t state) 834static int sa1100_serial_suspend(struct platform_device *dev, pm_message_t state)
838{ 835{
839 struct sa1100_port *sport = dev_get_drvdata(_dev); 836 struct sa1100_port *sport = platform_get_drvdata(dev);
840 837
841 if (sport) 838 if (sport)
842 uart_suspend_port(&sa1100_reg, &sport->port); 839 uart_suspend_port(&sa1100_reg, &sport->port);
@@ -844,9 +841,9 @@ static int sa1100_serial_suspend(struct device *_dev, pm_message_t state)
844 return 0; 841 return 0;
845} 842}
846 843
847static int sa1100_serial_resume(struct device *_dev) 844static int sa1100_serial_resume(struct platform_device *dev)
848{ 845{
849 struct sa1100_port *sport = dev_get_drvdata(_dev); 846 struct sa1100_port *sport = platform_get_drvdata(dev);
850 847
851 if (sport) 848 if (sport)
852 uart_resume_port(&sa1100_reg, &sport->port); 849 uart_resume_port(&sa1100_reg, &sport->port);
@@ -854,9 +851,8 @@ static int sa1100_serial_resume(struct device *_dev)
854 return 0; 851 return 0;
855} 852}
856 853
857static int sa1100_serial_probe(struct device *_dev) 854static int sa1100_serial_probe(struct platform_device *dev)
858{ 855{
859 struct platform_device *dev = to_platform_device(_dev);
860 struct resource *res = dev->resource; 856 struct resource *res = dev->resource;
861 int i; 857 int i;
862 858
@@ -869,9 +865,9 @@ static int sa1100_serial_probe(struct device *_dev)
869 if (sa1100_ports[i].port.mapbase != res->start) 865 if (sa1100_ports[i].port.mapbase != res->start)
870 continue; 866 continue;
871 867
872 sa1100_ports[i].port.dev = _dev; 868 sa1100_ports[i].port.dev = &dev->dev;
873 uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port); 869 uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port);
874 dev_set_drvdata(_dev, &sa1100_ports[i]); 870 platform_set_drvdata(dev, &sa1100_ports[i]);
875 break; 871 break;
876 } 872 }
877 } 873 }
@@ -879,11 +875,11 @@ static int sa1100_serial_probe(struct device *_dev)
879 return 0; 875 return 0;
880} 876}
881 877
882static int sa1100_serial_remove(struct device *_dev) 878static int sa1100_serial_remove(struct platform_device *pdev)
883{ 879{
884 struct sa1100_port *sport = dev_get_drvdata(_dev); 880 struct sa1100_port *sport = platform_get_drvdata(pdev);
885 881
886 dev_set_drvdata(_dev, NULL); 882 platform_set_drvdata(pdev, NULL);
887 883
888 if (sport) 884 if (sport)
889 uart_remove_one_port(&sa1100_reg, &sport->port); 885 uart_remove_one_port(&sa1100_reg, &sport->port);
@@ -891,13 +887,14 @@ static int sa1100_serial_remove(struct device *_dev)
891 return 0; 887 return 0;
892} 888}
893 889
894static struct device_driver sa11x0_serial_driver = { 890static struct platform_driver sa11x0_serial_driver = {
895 .name = "sa11x0-uart",
896 .bus = &platform_bus_type,
897 .probe = sa1100_serial_probe, 891 .probe = sa1100_serial_probe,
898 .remove = sa1100_serial_remove, 892 .remove = sa1100_serial_remove,
899 .suspend = sa1100_serial_suspend, 893 .suspend = sa1100_serial_suspend,
900 .resume = sa1100_serial_resume, 894 .resume = sa1100_serial_resume,
895 .driver = {
896 .name = "sa11x0-uart",
897 },
901}; 898};
902 899
903static int __init sa1100_serial_init(void) 900static int __init sa1100_serial_init(void)
@@ -910,7 +907,7 @@ static int __init sa1100_serial_init(void)
910 907
911 ret = uart_register_driver(&sa1100_reg); 908 ret = uart_register_driver(&sa1100_reg);
912 if (ret == 0) { 909 if (ret == 0) {
913 ret = driver_register(&sa11x0_serial_driver); 910 ret = platform_driver_register(&sa11x0_serial_driver);
914 if (ret) 911 if (ret)
915 uart_unregister_driver(&sa1100_reg); 912 uart_unregister_driver(&sa1100_reg);
916 } 913 }
@@ -919,7 +916,7 @@ static int __init sa1100_serial_init(void)
919 916
920static void __exit sa1100_serial_exit(void) 917static void __exit sa1100_serial_exit(void)
921{ 918{
922 driver_unregister(&sa11x0_serial_driver); 919 platform_driver_unregister(&sa11x0_serial_driver);
923 uart_unregister_driver(&sa1100_reg); 920 uart_unregister_driver(&sa1100_reg);
924} 921}
925 922
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 427a23858076..c17d680e3f04 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -209,33 +209,45 @@ static void uart_shutdown(struct uart_state *state)
209 struct uart_info *info = state->info; 209 struct uart_info *info = state->info;
210 struct uart_port *port = state->port; 210 struct uart_port *port = state->port;
211 211
212 if (!(info->flags & UIF_INITIALIZED))
213 return;
214
215 /* 212 /*
216 * Turn off DTR and RTS early. 213 * Set the TTY IO error marker
217 */ 214 */
218 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) 215 if (info->tty)
219 uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 216 set_bit(TTY_IO_ERROR, &info->tty->flags);
220 217
221 /* 218 if (info->flags & UIF_INITIALIZED) {
222 * clear delta_msr_wait queue to avoid mem leaks: we may free 219 info->flags &= ~UIF_INITIALIZED;
223 * the irq here so the queue might never be woken up. Note
224 * that we won't end up waiting on delta_msr_wait again since
225 * any outstanding file descriptors should be pointing at
226 * hung_up_tty_fops now.
227 */
228 wake_up_interruptible(&info->delta_msr_wait);
229 220
230 /* 221 /*
231 * Free the IRQ and disable the port. 222 * Turn off DTR and RTS early.
232 */ 223 */
233 port->ops->shutdown(port); 224 if (!info->tty || (info->tty->termios->c_cflag & HUPCL))
225 uart_clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
226
227 /*
228 * clear delta_msr_wait queue to avoid mem leaks: we may free
229 * the irq here so the queue might never be woken up. Note
230 * that we won't end up waiting on delta_msr_wait again since
231 * any outstanding file descriptors should be pointing at
232 * hung_up_tty_fops now.
233 */
234 wake_up_interruptible(&info->delta_msr_wait);
235
236 /*
237 * Free the IRQ and disable the port.
238 */
239 port->ops->shutdown(port);
240
241 /*
242 * Ensure that the IRQ handler isn't running on another CPU.
243 */
244 synchronize_irq(port->irq);
245 }
234 246
235 /* 247 /*
236 * Ensure that the IRQ handler isn't running on another CPU. 248 * kill off our tasklet
237 */ 249 */
238 synchronize_irq(port->irq); 250 tasklet_kill(&info->tlet);
239 251
240 /* 252 /*
241 * Free the transmit buffer page. 253 * Free the transmit buffer page.
@@ -244,15 +256,6 @@ static void uart_shutdown(struct uart_state *state)
244 free_page((unsigned long)info->xmit.buf); 256 free_page((unsigned long)info->xmit.buf);
245 info->xmit.buf = NULL; 257 info->xmit.buf = NULL;
246 } 258 }
247
248 /*
249 * kill off our tasklet
250 */
251 tasklet_kill(&info->tlet);
252 if (info->tty)
253 set_bit(TTY_IO_ERROR, &info->tty->flags);
254
255 info->flags &= ~UIF_INITIALIZED;
256} 259}
257 260
258/** 261/**
@@ -1776,7 +1779,7 @@ struct baud_rates {
1776 unsigned int cflag; 1779 unsigned int cflag;
1777}; 1780};
1778 1781
1779static struct baud_rates baud_rates[] = { 1782static const struct baud_rates baud_rates[] = {
1780 { 921600, B921600 }, 1783 { 921600, B921600 },
1781 { 460800, B460800 }, 1784 { 460800, B460800 },
1782 { 230400, B230400 }, 1785 { 230400, B230400 },
@@ -1928,14 +1931,25 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *port)
1928 1931
1929 if (state->info && state->info->flags & UIF_INITIALIZED) { 1932 if (state->info && state->info->flags & UIF_INITIALIZED) {
1930 struct uart_ops *ops = port->ops; 1933 struct uart_ops *ops = port->ops;
1934 int ret;
1931 1935
1932 ops->set_mctrl(port, 0); 1936 ops->set_mctrl(port, 0);
1933 ops->startup(port); 1937 ret = ops->startup(port);
1934 uart_change_speed(state, NULL); 1938 if (ret == 0) {
1935 spin_lock_irq(&port->lock); 1939 uart_change_speed(state, NULL);
1936 ops->set_mctrl(port, port->mctrl); 1940 spin_lock_irq(&port->lock);
1937 ops->start_tx(port); 1941 ops->set_mctrl(port, port->mctrl);
1938 spin_unlock_irq(&port->lock); 1942 ops->start_tx(port);
1943 spin_unlock_irq(&port->lock);
1944 } else {
1945 /*
1946 * Failed to resume - maybe hardware went away?
1947 * Clear the "initialized" flag so we won't try
1948 * to call the low level drivers shutdown method.
1949 */
1950 state->info->flags &= ~UIF_INITIALIZED;
1951 uart_shutdown(state);
1952 }
1939 } 1953 }
1940 1954
1941 up(&state->sem); 1955 up(&state->sem);
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 2c7d3ef76e8e..7ce0c7e66d37 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -85,7 +85,7 @@ struct multi_id {
85 int multi; /* 1 = multifunction, > 1 = # ports */ 85 int multi; /* 1 = multifunction, > 1 = # ports */
86}; 86};
87 87
88static struct multi_id multi_id[] = { 88static const struct multi_id multi_id[] = {
89 { MANFID_OMEGA, PRODID_OMEGA_QSP_100, 4 }, 89 { MANFID_OMEGA, PRODID_OMEGA_QSP_100, 4 },
90 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232, 2 }, 90 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232, 2 },
91 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232_D1, 2 }, 91 { MANFID_QUATECH, PRODID_QUATECH_DUAL_RS232_D1, 2 },
@@ -354,8 +354,8 @@ next_tuple(client_handle_t handle, tuple_t * tuple, cisparse_t * parse)
354 354
355static int simple_config(dev_link_t *link) 355static int simple_config(dev_link_t *link)
356{ 356{
357 static kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 }; 357 static const kio_addr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
358 static int size_table[2] = { 8, 16 }; 358 static const int size_table[2] = { 8, 16 };
359 client_handle_t handle = link->handle; 359 client_handle_t handle = link->handle;
360 struct serial_info *info = link->priv; 360 struct serial_info *info = link->priv;
361 struct serial_cfg_mem *cfg_mem; 361 struct serial_cfg_mem *cfg_mem;
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index 01696b3e3f61..865d4dea65df 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -924,7 +924,7 @@ static struct uart_driver siu_uart_driver = {
924 .cons = SERIAL_VR41XX_CONSOLE, 924 .cons = SERIAL_VR41XX_CONSOLE,
925}; 925};
926 926
927static int siu_probe(struct device *dev) 927static int siu_probe(struct platform_device *dev)
928{ 928{
929 struct uart_port *port; 929 struct uart_port *port;
930 int num, i, retval; 930 int num, i, retval;
@@ -941,7 +941,7 @@ static int siu_probe(struct device *dev)
941 for (i = 0; i < num; i++) { 941 for (i = 0; i < num; i++) {
942 port = &siu_uart_ports[i]; 942 port = &siu_uart_ports[i];
943 port->ops = &siu_uart_ops; 943 port->ops = &siu_uart_ops;
944 port->dev = dev; 944 port->dev = &dev->dev;
945 945
946 retval = uart_add_one_port(&siu_uart_driver, port); 946 retval = uart_add_one_port(&siu_uart_driver, port);
947 if (retval < 0) { 947 if (retval < 0) {
@@ -958,14 +958,14 @@ static int siu_probe(struct device *dev)
958 return 0; 958 return 0;
959} 959}
960 960
961static int siu_remove(struct device *dev) 961static int siu_remove(struct platform_device *dev)
962{ 962{
963 struct uart_port *port; 963 struct uart_port *port;
964 int i; 964 int i;
965 965
966 for (i = 0; i < siu_uart_driver.nr; i++) { 966 for (i = 0; i < siu_uart_driver.nr; i++) {
967 port = &siu_uart_ports[i]; 967 port = &siu_uart_ports[i];
968 if (port->dev == dev) { 968 if (port->dev == &dev->dev) {
969 uart_remove_one_port(&siu_uart_driver, port); 969 uart_remove_one_port(&siu_uart_driver, port);
970 port->dev = NULL; 970 port->dev = NULL;
971 } 971 }
@@ -976,7 +976,7 @@ static int siu_remove(struct device *dev)
976 return 0; 976 return 0;
977} 977}
978 978
979static int siu_suspend(struct device *dev, pm_message_t state) 979static int siu_suspend(struct platform_device *dev, pm_message_t state)
980{ 980{
981 struct uart_port *port; 981 struct uart_port *port;
982 int i; 982 int i;
@@ -984,7 +984,7 @@ static int siu_suspend(struct device *dev, pm_message_t state)
984 for (i = 0; i < siu_uart_driver.nr; i++) { 984 for (i = 0; i < siu_uart_driver.nr; i++) {
985 port = &siu_uart_ports[i]; 985 port = &siu_uart_ports[i];
986 if ((port->type == PORT_VR41XX_SIU || 986 if ((port->type == PORT_VR41XX_SIU ||
987 port->type == PORT_VR41XX_DSIU) && port->dev == dev) 987 port->type == PORT_VR41XX_DSIU) && port->dev == &dev->dev)
988 uart_suspend_port(&siu_uart_driver, port); 988 uart_suspend_port(&siu_uart_driver, port);
989 989
990 } 990 }
@@ -992,7 +992,7 @@ static int siu_suspend(struct device *dev, pm_message_t state)
992 return 0; 992 return 0;
993} 993}
994 994
995static int siu_resume(struct device *dev) 995static int siu_resume(struct platform_device *dev)
996{ 996{
997 struct uart_port *port; 997 struct uart_port *port;
998 int i; 998 int i;
@@ -1000,7 +1000,7 @@ static int siu_resume(struct device *dev)
1000 for (i = 0; i < siu_uart_driver.nr; i++) { 1000 for (i = 0; i < siu_uart_driver.nr; i++) {
1001 port = &siu_uart_ports[i]; 1001 port = &siu_uart_ports[i];
1002 if ((port->type == PORT_VR41XX_SIU || 1002 if ((port->type == PORT_VR41XX_SIU ||
1003 port->type == PORT_VR41XX_DSIU) && port->dev == dev) 1003 port->type == PORT_VR41XX_DSIU) && port->dev == &dev->dev)
1004 uart_resume_port(&siu_uart_driver, port); 1004 uart_resume_port(&siu_uart_driver, port);
1005 } 1005 }
1006 1006
@@ -1009,13 +1009,14 @@ static int siu_resume(struct device *dev)
1009 1009
1010static struct platform_device *siu_platform_device; 1010static struct platform_device *siu_platform_device;
1011 1011
1012static struct device_driver siu_device_driver = { 1012static struct platform_driver siu_device_driver = {
1013 .name = "SIU",
1014 .bus = &platform_bus_type,
1015 .probe = siu_probe, 1013 .probe = siu_probe,
1016 .remove = siu_remove, 1014 .remove = siu_remove,
1017 .suspend = siu_suspend, 1015 .suspend = siu_suspend,
1018 .resume = siu_resume, 1016 .resume = siu_resume,
1017 .driver = {
1018 .name = "SIU",
1019 },
1019}; 1020};
1020 1021
1021static int __devinit vr41xx_siu_init(void) 1022static int __devinit vr41xx_siu_init(void)
@@ -1026,7 +1027,7 @@ static int __devinit vr41xx_siu_init(void)
1026 if (IS_ERR(siu_platform_device)) 1027 if (IS_ERR(siu_platform_device))
1027 return PTR_ERR(siu_platform_device); 1028 return PTR_ERR(siu_platform_device);
1028 1029
1029 retval = driver_register(&siu_device_driver); 1030 retval = platform_driver_register(&siu_device_driver);
1030 if (retval < 0) 1031 if (retval < 0)
1031 platform_device_unregister(siu_platform_device); 1032 platform_device_unregister(siu_platform_device);
1032 1033
@@ -1035,7 +1036,7 @@ static int __devinit vr41xx_siu_init(void)
1035 1036
1036static void __devexit vr41xx_siu_exit(void) 1037static void __devexit vr41xx_siu_exit(void)
1037{ 1038{
1038 driver_unregister(&siu_device_driver); 1039 platform_driver_unregister(&siu_device_driver);
1039 1040
1040 platform_device_unregister(siu_platform_device); 1041 platform_device_unregister(siu_platform_device);
1041} 1042}
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index c52af73a251b..6756d0fab6fe 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -6,7 +6,7 @@
6 * 6 *
7 * DECstation changes 7 * DECstation changes
8 * Copyright (C) 1998-2000 Harald Koerfgen 8 * Copyright (C) 1998-2000 Harald Koerfgen
9 * Copyright (C) 2000, 2001, 2002, 2003, 2004 Maciej W. Rozycki 9 * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Maciej W. Rozycki
10 * 10 *
11 * For the rest of the code the original Copyright applies: 11 * For the rest of the code the original Copyright applies:
12 * Copyright (C) 1996 Paul Mackerras (Paul.Mackerras@cs.anu.edu.au) 12 * Copyright (C) 1996 Paul Mackerras (Paul.Mackerras@cs.anu.edu.au)
@@ -55,6 +55,7 @@
55#include <linux/delay.h> 55#include <linux/delay.h>
56#include <linux/init.h> 56#include <linux/init.h>
57#include <linux/ioport.h> 57#include <linux/ioport.h>
58#include <linux/spinlock.h>
58#ifdef CONFIG_SERIAL_DEC_CONSOLE 59#ifdef CONFIG_SERIAL_DEC_CONSOLE
59#include <linux/console.h> 60#include <linux/console.h>
60#endif 61#endif
@@ -63,7 +64,6 @@
63#include <asm/pgtable.h> 64#include <asm/pgtable.h>
64#include <asm/irq.h> 65#include <asm/irq.h>
65#include <asm/system.h> 66#include <asm/system.h>
66#include <asm/uaccess.h>
67#include <asm/bootinfo.h> 67#include <asm/bootinfo.h>
68 68
69#include <asm/dec/interrupts.h> 69#include <asm/dec/interrupts.h>
@@ -128,6 +128,8 @@ static struct zs_parms ds_parms = {
128 128
129#define BUS_PRESENT (DS_BUS_PRESENT) 129#define BUS_PRESENT (DS_BUS_PRESENT)
130 130
131DEFINE_SPINLOCK(zs_lock);
132
131struct dec_zschannel zs_channels[NUM_CHANNELS]; 133struct dec_zschannel zs_channels[NUM_CHANNELS];
132struct dec_serial zs_soft[NUM_CHANNELS]; 134struct dec_serial zs_soft[NUM_CHANNELS];
133int zs_channels_found; 135int zs_channels_found;
@@ -159,8 +161,6 @@ static unsigned char zs_init_regs[16] __initdata = {
159 0 /* write 15 */ 161 0 /* write 15 */
160}; 162};
161 163
162DECLARE_TASK_QUEUE(tq_zs_serial);
163
164static struct tty_driver *serial_driver; 164static struct tty_driver *serial_driver;
165 165
166/* serial subtype definitions */ 166/* serial subtype definitions */
@@ -294,8 +294,7 @@ static inline void zs_rtsdtr(struct dec_serial *info, int which, int set)
294{ 294{
295 unsigned long flags; 295 unsigned long flags;
296 296
297 297 spin_lock_irqsave(&zs_lock, flags);
298 save_flags(flags); cli();
299 if (info->zs_channel != info->zs_chan_a) { 298 if (info->zs_channel != info->zs_chan_a) {
300 if (set) { 299 if (set) {
301 info->zs_chan_a->curregs[5] |= (which & (RTS | DTR)); 300 info->zs_chan_a->curregs[5] |= (which & (RTS | DTR));
@@ -304,7 +303,7 @@ static inline void zs_rtsdtr(struct dec_serial *info, int which, int set)
304 } 303 }
305 write_zsreg(info->zs_chan_a, 5, info->zs_chan_a->curregs[5]); 304 write_zsreg(info->zs_chan_a, 5, info->zs_chan_a->curregs[5]);
306 } 305 }
307 restore_flags(flags); 306 spin_unlock_irqrestore(&zs_lock, flags);
308} 307}
309 308
310/* Utility routines for the Zilog */ 309/* Utility routines for the Zilog */
@@ -345,12 +344,10 @@ static inline void rs_recv_clear(struct dec_zschannel *zsc)
345 * This routine is used by the interrupt handler to schedule 344 * This routine is used by the interrupt handler to schedule
346 * processing in the software interrupt portion of the driver. 345 * processing in the software interrupt portion of the driver.
347 */ 346 */
348static _INLINE_ void rs_sched_event(struct dec_serial *info, 347static _INLINE_ void rs_sched_event(struct dec_serial *info, int event)
349 int event)
350{ 348{
351 info->event |= 1 << event; 349 info->event |= 1 << event;
352 queue_task(&info->tqueue, &tq_zs_serial); 350 tasklet_schedule(&info->tlet);
353 mark_bh(SERIAL_BH);
354} 351}
355 352
356static _INLINE_ void receive_chars(struct dec_serial *info, 353static _INLINE_ void receive_chars(struct dec_serial *info,
@@ -497,9 +494,10 @@ static _INLINE_ void status_handle(struct dec_serial *info)
497/* 494/*
498 * This is the serial driver's generic interrupt routine 495 * This is the serial driver's generic interrupt routine
499 */ 496 */
500void rs_interrupt(int irq, void *dev_id, struct pt_regs * regs) 497static irqreturn_t rs_interrupt(int irq, void *dev_id, struct pt_regs *regs)
501{ 498{
502 struct dec_serial *info = (struct dec_serial *) dev_id; 499 struct dec_serial *info = (struct dec_serial *) dev_id;
500 irqreturn_t status = IRQ_NONE;
503 unsigned char zs_intreg; 501 unsigned char zs_intreg;
504 int shift; 502 int shift;
505 503
@@ -521,6 +519,8 @@ void rs_interrupt(int irq, void *dev_id, struct pt_regs * regs)
521 if ((zs_intreg & CHAN_IRQMASK) == 0) 519 if ((zs_intreg & CHAN_IRQMASK) == 0)
522 break; 520 break;
523 521
522 status = IRQ_HANDLED;
523
524 if (zs_intreg & CHBRxIP) { 524 if (zs_intreg & CHBRxIP) {
525 receive_chars(info, regs); 525 receive_chars(info, regs);
526 } 526 }
@@ -534,6 +534,8 @@ void rs_interrupt(int irq, void *dev_id, struct pt_regs * regs)
534 534
535 /* Why do we need this ? */ 535 /* Why do we need this ? */
536 write_zsreg(info->zs_channel, 0, RES_H_IUS); 536 write_zsreg(info->zs_channel, 0, RES_H_IUS);
537
538 return status;
537} 539}
538 540
539#ifdef ZS_DEBUG_REGS 541#ifdef ZS_DEBUG_REGS
@@ -578,12 +580,12 @@ static void rs_stop(struct tty_struct *tty)
578 return; 580 return;
579 581
580#if 1 582#if 1
581 save_flags(flags); cli(); 583 spin_lock_irqsave(&zs_lock, flags);
582 if (info->zs_channel->curregs[5] & TxENAB) { 584 if (info->zs_channel->curregs[5] & TxENAB) {
583 info->zs_channel->curregs[5] &= ~TxENAB; 585 info->zs_channel->curregs[5] &= ~TxENAB;
584 write_zsreg(info->zs_channel, 5, info->zs_channel->curregs[5]); 586 write_zsreg(info->zs_channel, 5, info->zs_channel->curregs[5]);
585 } 587 }
586 restore_flags(flags); 588 spin_unlock_irqrestore(&zs_lock, flags);
587#endif 589#endif
588} 590}
589 591
@@ -595,7 +597,7 @@ static void rs_start(struct tty_struct *tty)
595 if (serial_paranoia_check(info, tty->name, "rs_start")) 597 if (serial_paranoia_check(info, tty->name, "rs_start"))
596 return; 598 return;
597 599
598 save_flags(flags); cli(); 600 spin_lock_irqsave(&zs_lock, flags);
599#if 1 601#if 1
600 if (info->xmit_cnt && info->xmit_buf && !(info->zs_channel->curregs[5] & TxENAB)) { 602 if (info->xmit_cnt && info->xmit_buf && !(info->zs_channel->curregs[5] & TxENAB)) {
601 info->zs_channel->curregs[5] |= TxENAB; 603 info->zs_channel->curregs[5] |= TxENAB;
@@ -606,7 +608,7 @@ static void rs_start(struct tty_struct *tty)
606 transmit_chars(info); 608 transmit_chars(info);
607 } 609 }
608#endif 610#endif
609 restore_flags(flags); 611 spin_unlock_irqrestore(&zs_lock, flags);
610} 612}
611 613
612/* 614/*
@@ -618,12 +620,8 @@ static void rs_start(struct tty_struct *tty)
618 * interrupt driver proper are done; the interrupt driver schedules 620 * interrupt driver proper are done; the interrupt driver schedules
619 * them using rs_sched_event(), and they get done here. 621 * them using rs_sched_event(), and they get done here.
620 */ 622 */
621static void do_serial_bh(void)
622{
623 run_task_queue(&tq_zs_serial);
624}
625 623
626static void do_softint(void *private_) 624static void do_softint(unsigned long private_)
627{ 625{
628 struct dec_serial *info = (struct dec_serial *) private_; 626 struct dec_serial *info = (struct dec_serial *) private_;
629 struct tty_struct *tty; 627 struct tty_struct *tty;
@@ -634,10 +632,11 @@ static void do_softint(void *private_)
634 632
635 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) { 633 if (test_and_clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
636 tty_wakeup(tty); 634 tty_wakeup(tty);
635 wake_up_interruptible(&tty->write_wait);
637 } 636 }
638} 637}
639 638
640int zs_startup(struct dec_serial * info) 639static int zs_startup(struct dec_serial * info)
641{ 640{
642 unsigned long flags; 641 unsigned long flags;
643 642
@@ -650,7 +649,7 @@ int zs_startup(struct dec_serial * info)
650 return -ENOMEM; 649 return -ENOMEM;
651 } 650 }
652 651
653 save_flags(flags); cli(); 652 spin_lock_irqsave(&zs_lock, flags);
654 653
655#ifdef SERIAL_DEBUG_OPEN 654#ifdef SERIAL_DEBUG_OPEN
656 printk("starting up ttyS%d (irq %d)...", info->line, info->irq); 655 printk("starting up ttyS%d (irq %d)...", info->line, info->irq);
@@ -706,7 +705,7 @@ int zs_startup(struct dec_serial * info)
706 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 705 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
707 706
708 info->flags |= ZILOG_INITIALIZED; 707 info->flags |= ZILOG_INITIALIZED;
709 restore_flags(flags); 708 spin_unlock_irqrestore(&zs_lock, flags);
710 return 0; 709 return 0;
711} 710}
712 711
@@ -726,7 +725,7 @@ static void shutdown(struct dec_serial * info)
726 info->irq); 725 info->irq);
727#endif 726#endif
728 727
729 save_flags(flags); cli(); /* Disable interrupts */ 728 spin_lock_irqsave(&zs_lock, flags);
730 729
731 if (info->xmit_buf) { 730 if (info->xmit_buf) {
732 free_page((unsigned long) info->xmit_buf); 731 free_page((unsigned long) info->xmit_buf);
@@ -749,7 +748,7 @@ static void shutdown(struct dec_serial * info)
749 set_bit(TTY_IO_ERROR, &info->tty->flags); 748 set_bit(TTY_IO_ERROR, &info->tty->flags);
750 749
751 info->flags &= ~ZILOG_INITIALIZED; 750 info->flags &= ~ZILOG_INITIALIZED;
752 restore_flags(flags); 751 spin_unlock_irqrestore(&zs_lock, flags);
753} 752}
754 753
755/* 754/*
@@ -785,7 +784,7 @@ static void change_speed(struct dec_serial *info)
785 i += 15; 784 i += 15;
786 } 785 }
787 786
788 save_flags(flags); cli(); 787 spin_lock_irqsave(&zs_lock, flags);
789 info->zs_baud = baud_table[i]; 788 info->zs_baud = baud_table[i];
790 if (info->zs_baud) { 789 if (info->zs_baud) {
791 brg = BPS_TO_BRG(info->zs_baud, zs_parms->clock/info->clk_divisor); 790 brg = BPS_TO_BRG(info->zs_baud, zs_parms->clock/info->clk_divisor);
@@ -858,7 +857,7 @@ static void change_speed(struct dec_serial *info)
858 /* Load up the new values */ 857 /* Load up the new values */
859 load_zsregs(info->zs_channel, info->zs_channel->curregs); 858 load_zsregs(info->zs_channel, info->zs_channel->curregs);
860 859
861 restore_flags(flags); 860 spin_unlock_irqrestore(&zs_lock, flags);
862} 861}
863 862
864static void rs_flush_chars(struct tty_struct *tty) 863static void rs_flush_chars(struct tty_struct *tty)
@@ -874,9 +873,9 @@ static void rs_flush_chars(struct tty_struct *tty)
874 return; 873 return;
875 874
876 /* Enable transmitter */ 875 /* Enable transmitter */
877 save_flags(flags); cli(); 876 spin_lock_irqsave(&zs_lock, flags);
878 transmit_chars(info); 877 transmit_chars(info);
879 restore_flags(flags); 878 spin_unlock_irqrestore(&zs_lock, flags);
880} 879}
881 880
882static int rs_write(struct tty_struct * tty, 881static int rs_write(struct tty_struct * tty,
@@ -892,26 +891,17 @@ static int rs_write(struct tty_struct * tty,
892 if (!tty || !info->xmit_buf) 891 if (!tty || !info->xmit_buf)
893 return 0; 892 return 0;
894 893
895 save_flags(flags);
896 while (1) { 894 while (1) {
897 cli(); 895 spin_lock_irqsave(&zs_lock, flags);
898 c = min(count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, 896 c = min(count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
899 SERIAL_XMIT_SIZE - info->xmit_head)); 897 SERIAL_XMIT_SIZE - info->xmit_head));
900 if (c <= 0) 898 if (c <= 0)
901 break; 899 break;
902 900
903 if (from_user) { 901 memcpy(info->xmit_buf + info->xmit_head, buf, c);
904 down(&tmp_buf_sem);
905 copy_from_user(tmp_buf, buf, c);
906 c = min(c, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
907 SERIAL_XMIT_SIZE - info->xmit_head));
908 memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
909 up(&tmp_buf_sem);
910 } else
911 memcpy(info->xmit_buf + info->xmit_head, buf, c);
912 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); 902 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
913 info->xmit_cnt += c; 903 info->xmit_cnt += c;
914 restore_flags(flags); 904 spin_unlock_irqrestore(&zs_lock, flags);
915 buf += c; 905 buf += c;
916 count -= c; 906 count -= c;
917 total += c; 907 total += c;
@@ -920,7 +910,7 @@ static int rs_write(struct tty_struct * tty,
920 if (info->xmit_cnt && !tty->stopped && !info->tx_stopped 910 if (info->xmit_cnt && !tty->stopped && !info->tx_stopped
921 && !info->tx_active) 911 && !info->tx_active)
922 transmit_chars(info); 912 transmit_chars(info);
923 restore_flags(flags); 913 spin_unlock_irqrestore(&zs_lock, flags);
924 return total; 914 return total;
925} 915}
926 916
@@ -952,9 +942,9 @@ static void rs_flush_buffer(struct tty_struct *tty)
952 942
953 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) 943 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
954 return; 944 return;
955 cli(); 945 spin_lock_irq(&zs_lock);
956 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; 946 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
957 sti(); 947 spin_unlock_irq(&zs_lock);
958 tty_wakeup(tty); 948 tty_wakeup(tty);
959} 949}
960 950
@@ -982,11 +972,11 @@ static void rs_throttle(struct tty_struct * tty)
982 return; 972 return;
983 973
984 if (I_IXOFF(tty)) { 974 if (I_IXOFF(tty)) {
985 save_flags(flags); cli(); 975 spin_lock_irqsave(&zs_lock, flags);
986 info->x_char = STOP_CHAR(tty); 976 info->x_char = STOP_CHAR(tty);
987 if (!info->tx_active) 977 if (!info->tx_active)
988 transmit_chars(info); 978 transmit_chars(info);
989 restore_flags(flags); 979 spin_unlock_irqrestore(&zs_lock, flags);
990 } 980 }
991 981
992 if (C_CRTSCTS(tty)) { 982 if (C_CRTSCTS(tty)) {
@@ -1010,7 +1000,7 @@ static void rs_unthrottle(struct tty_struct * tty)
1010 return; 1000 return;
1011 1001
1012 if (I_IXOFF(tty)) { 1002 if (I_IXOFF(tty)) {
1013 save_flags(flags); cli(); 1003 spin_lock_irqsave(&zs_lock, flags);
1014 if (info->x_char) 1004 if (info->x_char)
1015 info->x_char = 0; 1005 info->x_char = 0;
1016 else { 1006 else {
@@ -1018,7 +1008,7 @@ static void rs_unthrottle(struct tty_struct * tty)
1018 if (!info->tx_active) 1008 if (!info->tx_active)
1019 transmit_chars(info); 1009 transmit_chars(info);
1020 } 1010 }
1021 restore_flags(flags); 1011 spin_unlock_irqrestore(&zs_lock, flags);
1022 } 1012 }
1023 1013
1024 if (C_CRTSCTS(tty)) { 1014 if (C_CRTSCTS(tty)) {
@@ -1111,9 +1101,9 @@ static int get_lsr_info(struct dec_serial * info, unsigned int *value)
1111{ 1101{
1112 unsigned char status; 1102 unsigned char status;
1113 1103
1114 cli(); 1104 spin_lock(&zs_lock);
1115 status = read_zsreg(info->zs_channel, 0); 1105 status = read_zsreg(info->zs_channel, 0);
1116 sti(); 1106 spin_unlock_irq(&zs_lock);
1117 put_user(status,value); 1107 put_user(status,value);
1118 return 0; 1108 return 0;
1119} 1109}
@@ -1136,11 +1126,11 @@ static int rs_tiocmget(struct tty_struct *tty, struct file *file)
1136 if (info->zs_channel == info->zs_chan_a) 1126 if (info->zs_channel == info->zs_chan_a)
1137 result = 0; 1127 result = 0;
1138 else { 1128 else {
1139 cli(); 1129 spin_lock(&zs_lock);
1140 control = info->zs_chan_a->curregs[5]; 1130 control = info->zs_chan_a->curregs[5];
1141 status_a = read_zsreg(info->zs_chan_a, 0); 1131 status_a = read_zsreg(info->zs_chan_a, 0);
1142 status_b = read_zsreg(info->zs_channel, 0); 1132 status_b = read_zsreg(info->zs_channel, 0);
1143 sti(); 1133 spin_unlock_irq(&zs_lock);
1144 result = ((control & RTS) ? TIOCM_RTS: 0) 1134 result = ((control & RTS) ? TIOCM_RTS: 0)
1145 | ((control & DTR) ? TIOCM_DTR: 0) 1135 | ((control & DTR) ? TIOCM_DTR: 0)
1146 | ((status_b & DCD) ? TIOCM_CAR: 0) 1136 | ((status_b & DCD) ? TIOCM_CAR: 0)
@@ -1155,8 +1145,6 @@ static int rs_tiocmset(struct tty_struct *tty, struct file *file,
1155 unsigned int set, unsigned int clear) 1145 unsigned int set, unsigned int clear)
1156{ 1146{
1157 struct dec_serial * info = (struct dec_serial *)tty->driver_data; 1147 struct dec_serial * info = (struct dec_serial *)tty->driver_data;
1158 int error;
1159 unsigned int arg, bits;
1160 1148
1161 if (info->hook) 1149 if (info->hook)
1162 return -ENODEV; 1150 return -ENODEV;
@@ -1170,8 +1158,7 @@ static int rs_tiocmset(struct tty_struct *tty, struct file *file,
1170 if (info->zs_channel == info->zs_chan_a) 1158 if (info->zs_channel == info->zs_chan_a)
1171 return 0; 1159 return 0;
1172 1160
1173 get_user(arg, value); 1161 spin_lock(&zs_lock);
1174 cli();
1175 if (set & TIOCM_RTS) 1162 if (set & TIOCM_RTS)
1176 info->zs_chan_a->curregs[5] |= RTS; 1163 info->zs_chan_a->curregs[5] |= RTS;
1177 if (set & TIOCM_DTR) 1164 if (set & TIOCM_DTR)
@@ -1181,7 +1168,7 @@ static int rs_tiocmset(struct tty_struct *tty, struct file *file,
1181 if (clear & TIOCM_DTR) 1168 if (clear & TIOCM_DTR)
1182 info->zs_chan_a->curregs[5] &= ~DTR; 1169 info->zs_chan_a->curregs[5] &= ~DTR;
1183 write_zsreg(info->zs_chan_a, 5, info->zs_chan_a->curregs[5]); 1170 write_zsreg(info->zs_chan_a, 5, info->zs_chan_a->curregs[5]);
1184 sti(); 1171 spin_unlock_irq(&zs_lock);
1185 return 0; 1172 return 0;
1186} 1173}
1187 1174
@@ -1198,19 +1185,18 @@ static void rs_break(struct tty_struct *tty, int break_state)
1198 if (!info->port) 1185 if (!info->port)
1199 return; 1186 return;
1200 1187
1201 save_flags(flags); cli(); 1188 spin_lock_irqsave(&zs_lock, flags);
1202 if (break_state == -1) 1189 if (break_state == -1)
1203 info->zs_channel->curregs[5] |= SND_BRK; 1190 info->zs_channel->curregs[5] |= SND_BRK;
1204 else 1191 else
1205 info->zs_channel->curregs[5] &= ~SND_BRK; 1192 info->zs_channel->curregs[5] &= ~SND_BRK;
1206 write_zsreg(info->zs_channel, 5, info->zs_channel->curregs[5]); 1193 write_zsreg(info->zs_channel, 5, info->zs_channel->curregs[5]);
1207 restore_flags(flags); 1194 spin_unlock_irqrestore(&zs_lock, flags);
1208} 1195}
1209 1196
1210static int rs_ioctl(struct tty_struct *tty, struct file * file, 1197static int rs_ioctl(struct tty_struct *tty, struct file * file,
1211 unsigned int cmd, unsigned long arg) 1198 unsigned int cmd, unsigned long arg)
1212{ 1199{
1213 int error;
1214 struct dec_serial * info = (struct dec_serial *)tty->driver_data; 1200 struct dec_serial * info = (struct dec_serial *)tty->driver_data;
1215 1201
1216 if (info->hook) 1202 if (info->hook)
@@ -1287,10 +1273,10 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1287 if (!info || serial_paranoia_check(info, tty->name, "rs_close")) 1273 if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
1288 return; 1274 return;
1289 1275
1290 save_flags(flags); cli(); 1276 spin_lock_irqsave(&zs_lock, flags);
1291 1277
1292 if (tty_hung_up_p(filp)) { 1278 if (tty_hung_up_p(filp)) {
1293 restore_flags(flags); 1279 spin_unlock_irqrestore(&zs_lock, flags);
1294 return; 1280 return;
1295 } 1281 }
1296 1282
@@ -1315,7 +1301,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1315 info->count = 0; 1301 info->count = 0;
1316 } 1302 }
1317 if (info->count) { 1303 if (info->count) {
1318 restore_flags(flags); 1304 spin_unlock_irqrestore(&zs_lock, flags);
1319 return; 1305 return;
1320 } 1306 }
1321 info->flags |= ZILOG_CLOSING; 1307 info->flags |= ZILOG_CLOSING;
@@ -1358,7 +1344,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1358 } 1344 }
1359 info->flags &= ~(ZILOG_NORMAL_ACTIVE|ZILOG_CLOSING); 1345 info->flags &= ~(ZILOG_NORMAL_ACTIVE|ZILOG_CLOSING);
1360 wake_up_interruptible(&info->close_wait); 1346 wake_up_interruptible(&info->close_wait);
1361 restore_flags(flags); 1347 spin_unlock_irqrestore(&zs_lock, flags);
1362} 1348}
1363 1349
1364/* 1350/*
@@ -1398,7 +1384,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
1398/* 1384/*
1399 * rs_hangup() --- called by tty_hangup() when a hangup is signaled. 1385 * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
1400 */ 1386 */
1401void rs_hangup(struct tty_struct *tty) 1387static void rs_hangup(struct tty_struct *tty)
1402{ 1388{
1403 struct dec_serial * info = (struct dec_serial *)tty->driver_data; 1389 struct dec_serial * info = (struct dec_serial *)tty->driver_data;
1404 1390
@@ -1466,16 +1452,16 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1466 printk("block_til_ready before block: ttyS%d, count = %d\n", 1452 printk("block_til_ready before block: ttyS%d, count = %d\n",
1467 info->line, info->count); 1453 info->line, info->count);
1468#endif 1454#endif
1469 cli(); 1455 spin_lock(&zs_lock);
1470 if (!tty_hung_up_p(filp)) 1456 if (!tty_hung_up_p(filp))
1471 info->count--; 1457 info->count--;
1472 sti(); 1458 spin_unlock_irq(&zs_lock);
1473 info->blocked_open++; 1459 info->blocked_open++;
1474 while (1) { 1460 while (1) {
1475 cli(); 1461 spin_lock(&zs_lock);
1476 if (tty->termios->c_cflag & CBAUD) 1462 if (tty->termios->c_cflag & CBAUD)
1477 zs_rtsdtr(info, RTS | DTR, 1); 1463 zs_rtsdtr(info, RTS | DTR, 1);
1478 sti(); 1464 spin_unlock_irq(&zs_lock);
1479 set_current_state(TASK_INTERRUPTIBLE); 1465 set_current_state(TASK_INTERRUPTIBLE);
1480 if (tty_hung_up_p(filp) || 1466 if (tty_hung_up_p(filp) ||
1481 !(info->flags & ZILOG_INITIALIZED)) { 1467 !(info->flags & ZILOG_INITIALIZED)) {
@@ -1523,7 +1509,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1523 * the IRQ chain. It also performs the serial-specific 1509 * the IRQ chain. It also performs the serial-specific
1524 * initialization for the tty structure. 1510 * initialization for the tty structure.
1525 */ 1511 */
1526int rs_open(struct tty_struct *tty, struct file * filp) 1512static int rs_open(struct tty_struct *tty, struct file * filp)
1527{ 1513{
1528 struct dec_serial *info; 1514 struct dec_serial *info;
1529 int retval, line; 1515 int retval, line;
@@ -1706,7 +1692,7 @@ static void __init probe_sccs(void)
1706 } 1692 }
1707 } 1693 }
1708 1694
1709 save_and_cli(flags); 1695 spin_lock_irqsave(&zs_lock, flags);
1710 for (n = 0; n < zs_channels_found; n++) { 1696 for (n = 0; n < zs_channels_found; n++) {
1711 if (n % 2 == 0) { 1697 if (n % 2 == 0) {
1712 write_zsreg(zs_soft[n].zs_chan_a, R9, FHWRES); 1698 write_zsreg(zs_soft[n].zs_chan_a, R9, FHWRES);
@@ -1716,7 +1702,7 @@ static void __init probe_sccs(void)
1716 load_zsregs(zs_soft[n].zs_channel, 1702 load_zsregs(zs_soft[n].zs_channel,
1717 zs_soft[n].zs_channel->curregs); 1703 zs_soft[n].zs_channel->curregs);
1718 } 1704 }
1719 restore_flags(flags); 1705 spin_unlock_irqrestore(&zs_lock, flags);
1720} 1706}
1721 1707
1722static struct tty_operations serial_ops = { 1708static struct tty_operations serial_ops = {
@@ -1749,9 +1735,6 @@ int __init zs_init(void)
1749 if(!BUS_PRESENT) 1735 if(!BUS_PRESENT)
1750 return -ENODEV; 1736 return -ENODEV;
1751 1737
1752 /* Setup base handler, and timer table. */
1753 init_bh(SERIAL_BH, do_serial_bh);
1754
1755 /* Find out how many Z8530 SCCs we have */ 1738 /* Find out how many Z8530 SCCs we have */
1756 if (zs_chain == 0) 1739 if (zs_chain == 0)
1757 probe_sccs(); 1740 probe_sccs();
@@ -1800,8 +1783,7 @@ int __init zs_init(void)
1800 info->event = 0; 1783 info->event = 0;
1801 info->count = 0; 1784 info->count = 0;
1802 info->blocked_open = 0; 1785 info->blocked_open = 0;
1803 info->tqueue.routine = do_softint; 1786 tasklet_init(&info->tlet, do_softint, (unsigned long)info);
1804 info->tqueue.data = info;
1805 init_waitqueue_head(&info->open_wait); 1787 init_waitqueue_head(&info->open_wait);
1806 init_waitqueue_head(&info->close_wait); 1788 init_waitqueue_head(&info->close_wait);
1807 printk("ttyS%02d at 0x%08x (irq = %d) is a Z85C30 SCC\n", 1789 printk("ttyS%02d at 0x%08x (irq = %d) is a Z85C30 SCC\n",
@@ -1833,8 +1815,7 @@ int __init zs_init(void)
1833/* 1815/*
1834 * polling I/O routines 1816 * polling I/O routines
1835 */ 1817 */
1836static int 1818static int zs_poll_tx_char(void *handle, unsigned char ch)
1837zs_poll_tx_char(void *handle, unsigned char ch)
1838{ 1819{
1839 struct dec_serial *info = handle; 1820 struct dec_serial *info = handle;
1840 struct dec_zschannel *chan = info->zs_channel; 1821 struct dec_zschannel *chan = info->zs_channel;
@@ -1857,8 +1838,7 @@ zs_poll_tx_char(void *handle, unsigned char ch)
1857 return -ENODEV; 1838 return -ENODEV;
1858} 1839}
1859 1840
1860static int 1841static int zs_poll_rx_char(void *handle)
1861zs_poll_rx_char(void *handle)
1862{ 1842{
1863 struct dec_serial *info = handle; 1843 struct dec_serial *info = handle;
1864 struct dec_zschannel *chan = info->zs_channel; 1844 struct dec_zschannel *chan = info->zs_channel;
@@ -2037,7 +2017,7 @@ static int __init serial_console_setup(struct console *co, char *options)
2037 } 2017 }
2038 co->cflag = cflag; 2018 co->cflag = cflag;
2039 2019
2040 save_and_cli(flags); 2020 spin_lock_irqsave(&zs_lock, flags);
2041 2021
2042 /* 2022 /*
2043 * Set up the baud rate generator. 2023 * Set up the baud rate generator.
@@ -2092,7 +2072,7 @@ static int __init serial_console_setup(struct console *co, char *options)
2092 zs_soft[co->index].clk_divisor = clk_divisor; 2072 zs_soft[co->index].clk_divisor = clk_divisor;
2093 zs_soft[co->index].zs_baud = get_zsbaud(&zs_soft[co->index]); 2073 zs_soft[co->index].zs_baud = get_zsbaud(&zs_soft[co->index]);
2094 2074
2095 restore_flags(flags); 2075 spin_unlock_irqrestore(&zs_lock, flags);
2096 2076
2097 return 0; 2077 return 0;
2098} 2078}
@@ -2229,5 +2209,3 @@ void __init zs_kgdb_hook(int tty_num)
2229 set_debug_traps(); /* init stub */ 2209 set_debug_traps(); /* init stub */
2230} 2210}
2231#endif /* ifdef CONFIG_KGDB */ 2211#endif /* ifdef CONFIG_KGDB */
2232
2233
diff --git a/drivers/tc/zs.h b/drivers/tc/zs.h
index c52edffa6049..13512200ceba 100644
--- a/drivers/tc/zs.h
+++ b/drivers/tc/zs.h
@@ -6,14 +6,14 @@
6 * 6 *
7 * Copyright (C) 1996 Paul Mackerras (Paul.Mackerras@cs.anu.edu.au) 7 * Copyright (C) 1996 Paul Mackerras (Paul.Mackerras@cs.anu.edu.au)
8 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) 8 * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
9 * Copyright (C) 2004 Maciej W. Rozycki 9 * Copyright (C) 2004, 2005 Maciej W. Rozycki
10 */ 10 */
11#ifndef _DECSERIAL_H 11#ifndef _DECSERIAL_H
12#define _DECSERIAL_H 12#define _DECSERIAL_H
13 13
14#include <asm/dec/serial.h> 14#include <asm/dec/serial.h>
15 15
16#define NUM_ZSREGS 16 16#define NUM_ZSREGS 16
17 17
18struct serial_struct { 18struct serial_struct {
19 int type; 19 int type;
@@ -139,8 +139,7 @@ struct dec_serial {
139 int xmit_head; 139 int xmit_head;
140 int xmit_tail; 140 int xmit_tail;
141 int xmit_cnt; 141 int xmit_cnt;
142 struct tq_struct tqueue; 142 struct tasklet_struct tlet;
143 struct tq_struct tqueue_hangup;
144 wait_queue_head_t open_wait; 143 wait_queue_head_t open_wait;
145 wait_queue_head_t close_wait; 144 wait_queue_head_t close_wait;
146}; 145};
@@ -282,7 +281,7 @@ struct dec_serial {
282#define DLC 4 /* Disable Lower Chain */ 281#define DLC 4 /* Disable Lower Chain */
283#define MIE 8 /* Master Interrupt Enable */ 282#define MIE 8 /* Master Interrupt Enable */
284#define STATHI 0x10 /* Status high */ 283#define STATHI 0x10 /* Status high */
285#define SOFTACK 0x20 /* Software Interrupt Acknowledge */ 284#define SOFTACK 0x20 /* Software Interrupt Acknowledge */
286#define NORESET 0 /* No reset on write to R9 */ 285#define NORESET 0 /* No reset on write to R9 */
287#define CHRB 0x40 /* Reset channel B */ 286#define CHRB 0x40 /* Reset channel B */
288#define CHRA 0x80 /* Reset channel A */ 287#define CHRA 0x80 /* Reset channel A */
@@ -395,8 +394,8 @@ struct dec_serial {
395/* Read Register 15 (value of WR 15) */ 394/* Read Register 15 (value of WR 15) */
396 395
397/* Misc macros */ 396/* Misc macros */
398#define ZS_CLEARERR(channel) (write_zsreg(channel, 0, ERR_RES)) 397#define ZS_CLEARERR(channel) (write_zsreg(channel, 0, ERR_RES))
399#define ZS_CLEARFIFO(channel) do { volatile unsigned char garbage; \ 398#define ZS_CLEARFIFO(channel) do { volatile unsigned char garbage; \
400 garbage = read_zsdata(channel); \ 399 garbage = read_zsdata(channel); \
401 garbage = read_zsdata(channel); \ 400 garbage = read_zsdata(channel); \
402 garbage = read_zsdata(channel); \ 401 garbage = read_zsdata(channel); \
diff --git a/drivers/usb/atm/Makefile b/drivers/usb/atm/Makefile
index 751f297be2ef..85099718c683 100644
--- a/drivers/usb/atm/Makefile
+++ b/drivers/usb/atm/Makefile
@@ -6,3 +6,7 @@ obj-$(CONFIG_USB_CXACRU) += cxacru.o
6obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o 6obj-$(CONFIG_USB_SPEEDTOUCH) += speedtch.o
7obj-$(CONFIG_USB_ATM) += usbatm.o 7obj-$(CONFIG_USB_ATM) += usbatm.o
8obj-$(CONFIG_USB_XUSBATM) += xusbatm.o 8obj-$(CONFIG_USB_XUSBATM) += xusbatm.o
9
10ifeq ($(CONFIG_USB_DEBUG),y)
11EXTRA_CFLAGS += -DDEBUG
12endif
diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
index 79861ee12a29..9d59dc62e6d2 100644
--- a/drivers/usb/atm/cxacru.c
+++ b/drivers/usb/atm/cxacru.c
@@ -787,6 +787,9 @@ static const struct usb_device_id cxacru_usb_ids[] = {
787 { /* V = Conexant P = ADSL modem (Hasbani project) */ 787 { /* V = Conexant P = ADSL modem (Hasbani project) */
788 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00 788 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
789 }, 789 },
790 { /* V = Conexant P = ADSL modem (Well PTI-800 */
791 USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
792 },
790 { /* V = Conexant P = ADSL modem */ 793 { /* V = Conexant P = ADSL modem */
791 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00 794 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
792 }, 795 },
diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
index c466739428b2..2e6593e6c1bd 100644
--- a/drivers/usb/atm/usbatm.c
+++ b/drivers/usb/atm/usbatm.c
@@ -879,7 +879,7 @@ static int usbatm_atm_init(struct usbatm_data *instance)
879 879
880 fail: 880 fail:
881 instance->atm_dev = NULL; 881 instance->atm_dev = NULL;
882 shutdown_atm_dev(atm_dev); /* usbatm_atm_dev_close will eventually be called */ 882 atm_dev_deregister(atm_dev); /* usbatm_atm_dev_close will eventually be called */
883 return ret; 883 return ret;
884} 884}
885 885
@@ -1164,7 +1164,7 @@ void usbatm_usb_disconnect(struct usb_interface *intf)
1164 1164
1165 /* ATM finalize */ 1165 /* ATM finalize */
1166 if (instance->atm_dev) 1166 if (instance->atm_dev)
1167 shutdown_atm_dev(instance->atm_dev); 1167 atm_dev_deregister(instance->atm_dev);
1168 1168
1169 usbatm_put_instance(instance); /* taken in usbatm_usb_probe */ 1169 usbatm_put_instance(instance); /* taken in usbatm_usb_probe */
1170} 1170}
diff --git a/drivers/usb/atm/usbatm.h b/drivers/usb/atm/usbatm.h
index 936646457935..1adacd60d713 100644
--- a/drivers/usb/atm/usbatm.h
+++ b/drivers/usb/atm/usbatm.h
@@ -27,14 +27,9 @@
27#include <linux/config.h> 27#include <linux/config.h>
28 28
29/* 29/*
30#define DEBUG
31#define VERBOSE_DEBUG 30#define VERBOSE_DEBUG
32*/ 31*/
33 32
34#if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
35# define DEBUG
36#endif
37
38#include <asm/semaphore.h> 33#include <asm/semaphore.h>
39#include <linux/atm.h> 34#include <linux/atm.h>
40#include <linux/atmdev.h> 35#include <linux/atmdev.h>
diff --git a/drivers/usb/core/Makefile b/drivers/usb/core/Makefile
index dd1c4d2a0c31..86d5c380892d 100644
--- a/drivers/usb/core/Makefile
+++ b/drivers/usb/core/Makefile
@@ -14,3 +14,7 @@ ifeq ($(CONFIG_USB_DEVICEFS),y)
14endif 14endif
15 15
16obj-$(CONFIG_USB) += usbcore.o 16obj-$(CONFIG_USB) += usbcore.o
17
18ifeq ($(CONFIG_USB_DEBUG),y)
19EXTRA_CFLAGS += -DDEBUG
20endif
diff --git a/drivers/usb/core/buffer.c b/drivers/usb/core/buffer.c
index 57e800ac3cee..419c9943a7cb 100644
--- a/drivers/usb/core/buffer.c
+++ b/drivers/usb/core/buffer.c
@@ -15,14 +15,6 @@
15#include <asm/scatterlist.h> 15#include <asm/scatterlist.h>
16#include <linux/dma-mapping.h> 16#include <linux/dma-mapping.h>
17#include <linux/dmapool.h> 17#include <linux/dmapool.h>
18
19
20#ifdef CONFIG_USB_DEBUG
21 #define DEBUG
22#else
23 #undef DEBUG
24#endif
25
26#include <linux/usb.h> 18#include <linux/usb.h>
27#include "hcd.h" 19#include "hcd.h"
28 20
diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
index 993019500cc3..a9d89c78cc20 100644
--- a/drivers/usb/core/config.c
+++ b/drivers/usb/core/config.c
@@ -1,9 +1,4 @@
1#include <linux/config.h> 1#include <linux/config.h>
2
3#ifdef CONFIG_USB_DEBUG
4#define DEBUG
5#endif
6
7#include <linux/usb.h> 2#include <linux/usb.h>
8#include <linux/module.h> 3#include <linux/module.h>
9#include <linux/init.h> 4#include <linux/init.h>
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 942cd437dc48..b1d6e9af732d 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -1392,13 +1392,13 @@ static int proc_ioctl_default(struct dev_state *ps, void __user *arg)
1392} 1392}
1393 1393
1394#ifdef CONFIG_COMPAT 1394#ifdef CONFIG_COMPAT
1395static int proc_ioctl_compat(struct dev_state *ps, void __user *arg) 1395static int proc_ioctl_compat(struct dev_state *ps, compat_uptr_t arg)
1396{ 1396{
1397 struct usbdevfs_ioctl32 __user *uioc; 1397 struct usbdevfs_ioctl32 __user *uioc;
1398 struct usbdevfs_ioctl ctrl; 1398 struct usbdevfs_ioctl ctrl;
1399 u32 udata; 1399 u32 udata;
1400 1400
1401 uioc = compat_ptr(arg); 1401 uioc = compat_ptr((long)arg);
1402 if (get_user(ctrl.ifno, &uioc->ifno) || 1402 if (get_user(ctrl.ifno, &uioc->ifno) ||
1403 get_user(ctrl.ioctl_code, &uioc->ioctl_code) || 1403 get_user(ctrl.ioctl_code, &uioc->ioctl_code) ||
1404 __get_user(udata, &uioc->data)) 1404 __get_user(udata, &uioc->data))
@@ -1511,7 +1511,7 @@ static int usbdev_ioctl(struct inode *inode, struct file *file, unsigned int cmd
1511 1511
1512 case USBDEVFS_IOCTL32: 1512 case USBDEVFS_IOCTL32:
1513 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__); 1513 snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__);
1514 ret = proc_ioctl_compat(ps, p); 1514 ret = proc_ioctl_compat(ps, (compat_uptr_t)(long)p);
1515 break; 1515 break;
1516#endif 1516#endif
1517 1517
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index e695308095ae..37b13368c814 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -19,12 +19,6 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/spinlock.h> 20#include <linux/spinlock.h>
21#include <linux/errno.h> 21#include <linux/errno.h>
22
23#ifdef CONFIG_USB_DEBUG
24 #define DEBUG
25#else
26 #undef DEBUG
27#endif
28#include <linux/usb.h> 22#include <linux/usb.h>
29 23
30#include "usb.h" 24#include "usb.h"
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c
index 84d9e69329bb..29b5b2a6e183 100644
--- a/drivers/usb/core/hcd-pci.c
+++ b/drivers/usb/core/hcd-pci.c
@@ -17,19 +17,20 @@
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/kernel.h> 20#include <linux/kernel.h>
28#include <linux/module.h> 21#include <linux/module.h>
29#include <linux/pci.h> 22#include <linux/pci.h>
23#include <linux/usb.h>
24
30#include <asm/io.h> 25#include <asm/io.h>
31#include <asm/irq.h> 26#include <asm/irq.h>
32#include <linux/usb.h> 27
28#ifdef CONFIG_PPC_PMAC
29#include <asm/machdep.h>
30#include <asm/pmac_feature.h>
31#include <asm/pci-bridge.h>
32#include <asm/prom.h>
33#endif
33 34
34#include "usb.h" 35#include "usb.h"
35#include "hcd.h" 36#include "hcd.h"
@@ -218,6 +219,7 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
218 goto done; 219 goto done;
219 } 220 }
220 } 221 }
222 synchronize_irq(dev->irq);
221 223
222 /* FIXME until the generic PM interfaces change a lot more, this 224 /* FIXME until the generic PM interfaces change a lot more, this
223 * can't use PCI D1 and D2 states. For example, the confusion 225 * can't use PCI D1 and D2 states. For example, the confusion
@@ -284,8 +286,22 @@ int usb_hcd_pci_suspend (struct pci_dev *dev, pm_message_t message)
284 } 286 }
285 287
286done: 288done:
287 if (retval == 0) 289 if (retval == 0) {
288 dev->dev.power.power_state = PMSG_SUSPEND; 290 dev->dev.power.power_state = PMSG_SUSPEND;
291
292#ifdef CONFIG_PPC_PMAC
293 /* Disable ASIC clocks for USB */
294 if (_machine == _MACH_Pmac) {
295 struct device_node *of_node;
296
297 of_node = pci_device_to_OF_node (dev);
298 if (of_node)
299 pmac_call_feature(PMAC_FTR_USB_ENABLE,
300 of_node, 0, 0);
301 }
302#endif
303 }
304
289 return retval; 305 return retval;
290} 306}
291EXPORT_SYMBOL (usb_hcd_pci_suspend); 307EXPORT_SYMBOL (usb_hcd_pci_suspend);
@@ -308,6 +324,18 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
308 return 0; 324 return 0;
309 } 325 }
310 326
327#ifdef CONFIG_PPC_PMAC
328 /* Reenable ASIC clocks for USB */
329 if (_machine == _MACH_Pmac) {
330 struct device_node *of_node;
331
332 of_node = pci_device_to_OF_node (dev);
333 if (of_node)
334 pmac_call_feature (PMAC_FTR_USB_ENABLE,
335 of_node, 0, 1);
336 }
337#endif
338
311 /* NOTE: chip docs cover clean "real suspend" cases (what Linux 339 /* NOTE: chip docs cover clean "real suspend" cases (what Linux
312 * calls "standby", "suspend to RAM", and so on). There are also 340 * calls "standby", "suspend to RAM", and so on). There are also
313 * dirty cases when swsusp fakes a suspend in "shutdown" mode. 341 * dirty cases when swsusp fakes a suspend in "shutdown" mode.
@@ -365,7 +393,7 @@ int usb_hcd_pci_resume (struct pci_dev *dev)
365 393
366 dev->dev.power.power_state = PMSG_ON; 394 dev->dev.power.power_state = PMSG_ON;
367 395
368 hcd->saw_irq = 0; 396 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
369 397
370 if (hcd->driver->resume) { 398 if (hcd->driver->resume) {
371 retval = hcd->driver->resume(hcd); 399 retval = hcd->driver->resume(hcd);
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 6c7ca5b08cd6..da24c31ee00d 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -23,11 +23,6 @@
23 */ 23 */
24 24
25#include <linux/config.h> 25#include <linux/config.h>
26
27#ifdef CONFIG_USB_DEBUG
28#define DEBUG
29#endif
30
31#include <linux/module.h> 26#include <linux/module.h>
32#include <linux/version.h> 27#include <linux/version.h>
33#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -1320,11 +1315,12 @@ static int hcd_unlink_urb (struct urb *urb, int status)
1320 * finish unlinking the initial failed usb_set_address() 1315 * finish unlinking the initial failed usb_set_address()
1321 * or device descriptor fetch. 1316 * or device descriptor fetch.
1322 */ 1317 */
1323 if (!hcd->saw_irq && hcd->self.root_hub != urb->dev) { 1318 if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags)
1319 && hcd->self.root_hub != urb->dev) {
1324 dev_warn (hcd->self.controller, "Unlink after no-IRQ? " 1320 dev_warn (hcd->self.controller, "Unlink after no-IRQ? "
1325 "Controller is probably using the wrong IRQ." 1321 "Controller is probably using the wrong IRQ."
1326 "\n"); 1322 "\n");
1327 hcd->saw_irq = 1; 1323 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
1328 } 1324 }
1329 1325
1330 urb->status = status; 1326 urb->status = status;
@@ -1654,13 +1650,15 @@ irqreturn_t usb_hcd_irq (int irq, void *__hcd, struct pt_regs * r)
1654 struct usb_hcd *hcd = __hcd; 1650 struct usb_hcd *hcd = __hcd;
1655 int start = hcd->state; 1651 int start = hcd->state;
1656 1652
1657 if (start == HC_STATE_HALT) 1653 if (unlikely(start == HC_STATE_HALT ||
1654 !test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
1658 return IRQ_NONE; 1655 return IRQ_NONE;
1659 if (hcd->driver->irq (hcd, r) == IRQ_NONE) 1656 if (hcd->driver->irq (hcd, r) == IRQ_NONE)
1660 return IRQ_NONE; 1657 return IRQ_NONE;
1661 1658
1662 hcd->saw_irq = 1; 1659 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
1663 if (hcd->state == HC_STATE_HALT) 1660
1661 if (unlikely(hcd->state == HC_STATE_HALT))
1664 usb_hc_died (hcd); 1662 usb_hc_died (hcd);
1665 return IRQ_HANDLED; 1663 return IRQ_HANDLED;
1666} 1664}
@@ -1773,6 +1771,8 @@ int usb_add_hcd(struct usb_hcd *hcd,
1773 1771
1774 dev_info(hcd->self.controller, "%s\n", hcd->product_desc); 1772 dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
1775 1773
1774 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
1775
1776 /* till now HC has been in an indeterminate state ... */ 1776 /* till now HC has been in an indeterminate state ... */
1777 if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) { 1777 if (hcd->driver->reset && (retval = hcd->driver->reset(hcd)) < 0) {
1778 dev_err(hcd->self.controller, "can't reset\n"); 1778 dev_err(hcd->self.controller, "can't reset\n");
diff --git a/drivers/usb/core/hcd.h b/drivers/usb/core/hcd.h
index 24a62a2ff86d..c8a1b350e2cf 100644
--- a/drivers/usb/core/hcd.h
+++ b/drivers/usb/core/hcd.h
@@ -72,7 +72,12 @@ struct usb_hcd { /* usb_bus.hcpriv points to this */
72 * hardware info/state 72 * hardware info/state
73 */ 73 */
74 const struct hc_driver *driver; /* hw-specific hooks */ 74 const struct hc_driver *driver; /* hw-specific hooks */
75 unsigned saw_irq : 1; 75
76 /* Flags that need to be manipulated atomically */
77 unsigned long flags;
78#define HCD_FLAG_HW_ACCESSIBLE 0x00000001
79#define HCD_FLAG_SAW_IRQ 0x00000002
80
76 unsigned can_wakeup:1; /* hw supports wakeup? */ 81 unsigned can_wakeup:1; /* hw supports wakeup? */
77 unsigned remote_wakeup:1;/* sw should use wakeup? */ 82 unsigned remote_wakeup:1;/* sw should use wakeup? */
78 unsigned rh_registered:1;/* is root hub registered? */ 83 unsigned rh_registered:1;/* is root hub registered? */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 256d9f698715..f78bd124d290 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -9,11 +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#include <linux/kernel.h> 12#include <linux/kernel.h>
18#include <linux/errno.h> 13#include <linux/errno.h>
19#include <linux/module.h> 14#include <linux/module.h>
@@ -1674,7 +1669,6 @@ int usb_suspend_device(struct usb_device *udev)
1674 return 0; 1669 return 0;
1675#endif 1670#endif
1676} 1671}
1677EXPORT_SYMBOL_GPL(usb_suspend_device);
1678 1672
1679/* 1673/*
1680 * If the USB "suspend" state is in use (rather than "global suspend"), 1674 * If the USB "suspend" state is in use (rather than "global suspend"),
diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 12f490fdee8f..c44bbedec817 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -46,7 +46,6 @@
46 46
47static struct super_operations usbfs_ops; 47static struct super_operations usbfs_ops;
48static struct file_operations default_file_operations; 48static struct file_operations default_file_operations;
49static struct inode_operations usbfs_dir_inode_operations;
50static struct vfsmount *usbfs_mount; 49static struct vfsmount *usbfs_mount;
51static int usbfs_mount_count; /* = 0 */ 50static int usbfs_mount_count; /* = 0 */
52static int ignore_mount = 0; 51static int ignore_mount = 0;
@@ -262,7 +261,7 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t de
262 inode->i_fop = &default_file_operations; 261 inode->i_fop = &default_file_operations;
263 break; 262 break;
264 case S_IFDIR: 263 case S_IFDIR:
265 inode->i_op = &usbfs_dir_inode_operations; 264 inode->i_op = &simple_dir_inode_operations;
266 inode->i_fop = &simple_dir_operations; 265 inode->i_fop = &simple_dir_operations;
267 266
268 /* directory inodes start off with i_nlink == 2 (for "." entry) */ 267 /* directory inodes start off with i_nlink == 2 (for "." entry) */
@@ -417,10 +416,6 @@ static struct file_operations default_file_operations = {
417 .llseek = default_file_lseek, 416 .llseek = default_file_lseek,
418}; 417};
419 418
420static struct inode_operations usbfs_dir_inode_operations = {
421 .lookup = simple_lookup,
422};
423
424static struct super_operations usbfs_ops = { 419static struct super_operations usbfs_ops = {
425 .statfs = simple_statfs, 420 .statfs = simple_statfs,
426 .drop_inode = generic_delete_inode, 421 .drop_inode = generic_delete_inode,
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
index 644a3d4f12aa..fe74f99ca5f4 100644
--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -3,13 +3,6 @@
3 */ 3 */
4 4
5#include <linux/config.h> 5#include <linux/config.h>
6
7#ifdef CONFIG_USB_DEBUG
8 #define DEBUG
9#else
10 #undef DEBUG
11#endif
12
13#include <linux/pci.h> /* for scatterlist macros */ 6#include <linux/pci.h> /* for scatterlist macros */
14#include <linux/usb.h> 7#include <linux/usb.h>
15#include <linux/module.h> 8#include <linux/module.h>
@@ -1457,12 +1450,11 @@ free_interfaces:
1457 */ 1450 */
1458 for (i = 0; i < nintf; ++i) { 1451 for (i = 0; i < nintf; ++i) {
1459 struct usb_interface *intf = cp->interface[i]; 1452 struct usb_interface *intf = cp->interface[i];
1460 struct usb_host_interface *alt = intf->cur_altsetting;
1461 1453
1462 dev_dbg (&dev->dev, 1454 dev_dbg (&dev->dev,
1463 "adding %s (config #%d, interface %d)\n", 1455 "adding %s (config #%d, interface %d)\n",
1464 intf->dev.bus_id, configuration, 1456 intf->dev.bus_id, configuration,
1465 alt->desc.bInterfaceNumber); 1457 intf->cur_altsetting->desc.bInterfaceNumber);
1466 ret = device_add (&intf->dev); 1458 ret = device_add (&intf->dev);
1467 if (ret != 0) { 1459 if (ret != 0) {
1468 dev_err(&dev->dev, 1460 dev_err(&dev->dev,
diff --git a/drivers/usb/core/notify.c b/drivers/usb/core/notify.c
index 37da059eced7..fbbebab52fbd 100644
--- a/drivers/usb/core/notify.c
+++ b/drivers/usb/core/notify.c
@@ -12,13 +12,7 @@
12#include <linux/config.h> 12#include <linux/config.h>
13#include <linux/kernel.h> 13#include <linux/kernel.h>
14#include <linux/notifier.h> 14#include <linux/notifier.h>
15#ifdef CONFIG_USB_DEBUG
16 #define DEBUG
17#else
18 #undef DEBUG
19#endif
20#include <linux/usb.h> 15#include <linux/usb.h>
21
22#include "usb.h" 16#include "usb.h"
23 17
24 18
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index edd83e014452..71d881327e88 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -12,14 +12,7 @@
12 12
13#include <linux/config.h> 13#include <linux/config.h>
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15
16#ifdef CONFIG_USB_DEBUG
17 #define DEBUG
18#else
19 #undef DEBUG
20#endif
21#include <linux/usb.h> 15#include <linux/usb.h>
22
23#include "usb.h" 16#include "usb.h"
24 17
25/* endpoint stuff */ 18/* endpoint stuff */
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index f2a1fed2a802..081796726b95 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -4,12 +4,6 @@
4#include <linux/bitops.h> 4#include <linux/bitops.h>
5#include <linux/slab.h> 5#include <linux/slab.h>
6#include <linux/init.h> 6#include <linux/init.h>
7
8#ifdef CONFIG_USB_DEBUG
9 #define DEBUG
10#else
11 #undef DEBUG
12#endif
13#include <linux/usb.h> 7#include <linux/usb.h>
14#include "hcd.h" 8#include "hcd.h"
15 9
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 0eefff7bcb3c..e80ef9467825 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -22,13 +22,6 @@
22 */ 22 */
23 23
24#include <linux/config.h> 24#include <linux/config.h>
25
26#ifdef CONFIG_USB_DEBUG
27 #define DEBUG
28#else
29 #undef DEBUG
30#endif
31
32#include <linux/module.h> 25#include <linux/module.h>
33#include <linux/string.h> 26#include <linux/string.h>
34#include <linux/bitops.h> 27#include <linux/bitops.h>
@@ -1439,7 +1432,8 @@ static int usb_generic_suspend(struct device *dev, pm_message_t message)
1439 mark_quiesced(intf); 1432 mark_quiesced(intf);
1440 } else { 1433 } else {
1441 // FIXME else if there's no suspend method, disconnect... 1434 // FIXME else if there's no suspend method, disconnect...
1442 dev_warn(dev, "no %s?\n", "suspend"); 1435 dev_warn(dev, "no suspend for driver %s?\n", driver->name);
1436 mark_quiesced(intf);
1443 status = 0; 1437 status = 0;
1444 } 1438 }
1445 return status; 1439 return status;
@@ -1467,8 +1461,10 @@ static int usb_generic_resume(struct device *dev)
1467 } 1461 }
1468 1462
1469 if ((dev->driver == NULL) || 1463 if ((dev->driver == NULL) ||
1470 (dev->driver_data == &usb_generic_driver_data)) 1464 (dev->driver_data == &usb_generic_driver_data)) {
1465 dev->power.power_state.event = PM_EVENT_FREEZE;
1471 return 0; 1466 return 0;
1467 }
1472 1468
1473 intf = to_usb_interface(dev); 1469 intf = to_usb_interface(dev);
1474 driver = to_usb_driver(dev->driver); 1470 driver = to_usb_driver(dev->driver);
@@ -1488,7 +1484,7 @@ static int usb_generic_resume(struct device *dev)
1488 mark_quiesced(intf); 1484 mark_quiesced(intf);
1489 } 1485 }
1490 } else 1486 } else
1491 dev_warn(dev, "no %s?\n", "resume"); 1487 dev_warn(dev, "no resume for driver %s?\n", driver->name);
1492 return 0; 1488 return 0;
1493} 1489}
1494 1490
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c
index 904519085334..c655d46c8aed 100644
--- a/drivers/usb/gadget/dummy_hcd.c
+++ b/drivers/usb/gadget/dummy_hcd.c
@@ -896,7 +896,7 @@ dummy_gadget_release (struct device *dev)
896#endif 896#endif
897} 897}
898 898
899static int dummy_udc_probe (struct device *dev) 899static int dummy_udc_probe (struct platform_device *dev)
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 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; 912 dum->gadget.dev.parent = &dev->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,59 +919,60 @@ static int dummy_udc_probe (struct 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 dev_set_drvdata (dev, dum); 922 platform_set_drvdata (dev, 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 device *dev) 927static int dummy_udc_remove (struct platform_device *dev)
928{ 928{
929 struct dummy *dum = dev_get_drvdata (dev); 929 struct dummy *dum = platform_get_drvdata (dev);
930 930
931 dev_set_drvdata (dev, NULL); 931 platform_set_drvdata (dev, 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 device *dev, pm_message_t state) 937static int dummy_udc_suspend (struct platform_device *dev, pm_message_t state)
938{ 938{
939 struct dummy *dum = dev_get_drvdata(dev); 939 struct dummy *dum = platform_get_drvdata(dev);
940 940
941 dev_dbg (dev, "%s\n", __FUNCTION__); 941 dev_dbg (&dev->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->power.power_state = state; 947 dev->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 device *dev) 952static int dummy_udc_resume (struct platform_device *dev)
953{ 953{
954 struct dummy *dum = dev_get_drvdata(dev); 954 struct dummy *dum = platform_get_drvdata(dev);
955 955
956 dev_dbg (dev, "%s\n", __FUNCTION__); 956 dev_dbg (&dev->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->power.power_state = PMSG_ON; 962 dev->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}
966 966
967static struct device_driver dummy_udc_driver = { 967static struct platform_driver dummy_udc_driver = {
968 .name = (char *) gadget_name,
969 .owner = THIS_MODULE,
970 .bus = &platform_bus_type,
971 .probe = dummy_udc_probe, 968 .probe = dummy_udc_probe,
972 .remove = dummy_udc_remove, 969 .remove = dummy_udc_remove,
973 .suspend = dummy_udc_suspend, 970 .suspend = dummy_udc_suspend,
974 .resume = dummy_udc_resume, 971 .resume = dummy_udc_resume,
972 .driver = {
973 .name = (char *) gadget_name,
974 .owner = THIS_MODULE,
975 },
975}; 976};
976 977
977/*-------------------------------------------------------------------------*/ 978/*-------------------------------------------------------------------------*/
@@ -1898,14 +1899,14 @@ static const struct hc_driver dummy_hcd = {
1898 .bus_resume = dummy_bus_resume, 1899 .bus_resume = dummy_bus_resume,
1899}; 1900};
1900 1901
1901static int dummy_hcd_probe (struct device *dev) 1902static int dummy_hcd_probe (struct platform_device *dev)
1902{ 1903{
1903 struct usb_hcd *hcd; 1904 struct usb_hcd *hcd;
1904 int retval; 1905 int retval;
1905 1906
1906 dev_info (dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); 1907 dev_info(&dev->dev, "%s, driver " DRIVER_VERSION "\n", driver_desc);
1907 1908
1908 hcd = usb_create_hcd (&dummy_hcd, dev, dev->bus_id); 1909 hcd = usb_create_hcd (&dummy_hcd, &dev->dev, dev->dev.bus_id);
1909 if (!hcd) 1910 if (!hcd)
1910 return -ENOMEM; 1911 return -ENOMEM;
1911 the_controller = hcd_to_dummy (hcd); 1912 the_controller = hcd_to_dummy (hcd);
@@ -1918,48 +1919,49 @@ static int dummy_hcd_probe (struct device *dev)
1918 return retval; 1919 return retval;
1919} 1920}
1920 1921
1921static int dummy_hcd_remove (struct device *dev) 1922static int dummy_hcd_remove (struct platform_device *dev)
1922{ 1923{
1923 struct usb_hcd *hcd; 1924 struct usb_hcd *hcd;
1924 1925
1925 hcd = dev_get_drvdata (dev); 1926 hcd = platform_get_drvdata (dev);
1926 usb_remove_hcd (hcd); 1927 usb_remove_hcd (hcd);
1927 usb_put_hcd (hcd); 1928 usb_put_hcd (hcd);
1928 the_controller = NULL; 1929 the_controller = NULL;
1929 return 0; 1930 return 0;
1930} 1931}
1931 1932
1932static int dummy_hcd_suspend (struct device *dev, pm_message_t state) 1933static int dummy_hcd_suspend (struct platform_device *dev, pm_message_t state)
1933{ 1934{
1934 struct usb_hcd *hcd; 1935 struct usb_hcd *hcd;
1935 1936
1936 dev_dbg (dev, "%s\n", __FUNCTION__); 1937 dev_dbg (&dev->dev, "%s\n", __FUNCTION__);
1937 hcd = dev_get_drvdata (dev); 1938 hcd = platform_get_drvdata (dev);
1938 1939
1939 hcd->state = HC_STATE_SUSPENDED; 1940 hcd->state = HC_STATE_SUSPENDED;
1940 return 0; 1941 return 0;
1941} 1942}
1942 1943
1943static int dummy_hcd_resume (struct device *dev) 1944static int dummy_hcd_resume (struct platform_device *dev)
1944{ 1945{
1945 struct usb_hcd *hcd; 1946 struct usb_hcd *hcd;
1946 1947
1947 dev_dbg (dev, "%s\n", __FUNCTION__); 1948 dev_dbg (&dev->dev, "%s\n", __FUNCTION__);
1948 hcd = dev_get_drvdata (dev); 1949 hcd = platform_get_drvdata (dev);
1949 hcd->state = HC_STATE_RUNNING; 1950 hcd->state = HC_STATE_RUNNING;
1950 1951
1951 usb_hcd_poll_rh_status (hcd); 1952 usb_hcd_poll_rh_status (hcd);
1952 return 0; 1953 return 0;
1953} 1954}
1954 1955
1955static struct device_driver dummy_hcd_driver = { 1956static struct platform_driver dummy_hcd_driver = {
1956 .name = (char *) driver_name,
1957 .owner = THIS_MODULE,
1958 .bus = &platform_bus_type,
1959 .probe = dummy_hcd_probe, 1957 .probe = dummy_hcd_probe,
1960 .remove = dummy_hcd_remove, 1958 .remove = dummy_hcd_remove,
1961 .suspend = dummy_hcd_suspend, 1959 .suspend = dummy_hcd_suspend,
1962 .resume = dummy_hcd_resume, 1960 .resume = dummy_hcd_resume,
1961 .driver = {
1962 .name = (char *) driver_name,
1963 .owner = THIS_MODULE,
1964 },
1963}; 1965};
1964 1966
1965/*-------------------------------------------------------------------------*/ 1967/*-------------------------------------------------------------------------*/
@@ -1995,11 +1997,11 @@ static int __init init (void)
1995 if (usb_disabled ()) 1997 if (usb_disabled ())
1996 return -ENODEV; 1998 return -ENODEV;
1997 1999
1998 retval = driver_register (&dummy_hcd_driver); 2000 retval = platform_driver_register (&dummy_hcd_driver);
1999 if (retval < 0) 2001 if (retval < 0)
2000 return retval; 2002 return retval;
2001 2003
2002 retval = driver_register (&dummy_udc_driver); 2004 retval = platform_driver_register (&dummy_udc_driver);
2003 if (retval < 0) 2005 if (retval < 0)
2004 goto err_register_udc_driver; 2006 goto err_register_udc_driver;
2005 2007
@@ -2015,9 +2017,9 @@ static int __init init (void)
2015err_register_udc: 2017err_register_udc:
2016 platform_device_unregister (&the_hcd_pdev); 2018 platform_device_unregister (&the_hcd_pdev);
2017err_register_hcd: 2019err_register_hcd:
2018 driver_unregister (&dummy_udc_driver); 2020 platform_driver_unregister (&dummy_udc_driver);
2019err_register_udc_driver: 2021err_register_udc_driver:
2020 driver_unregister (&dummy_hcd_driver); 2022 platform_driver_unregister (&dummy_hcd_driver);
2021 return retval; 2023 return retval;
2022} 2024}
2023module_init (init); 2025module_init (init);
@@ -2026,7 +2028,7 @@ static void __exit cleanup (void)
2026{ 2028{
2027 platform_device_unregister (&the_udc_pdev); 2029 platform_device_unregister (&the_udc_pdev);
2028 platform_device_unregister (&the_hcd_pdev); 2030 platform_device_unregister (&the_hcd_pdev);
2029 driver_unregister (&dummy_udc_driver); 2031 platform_driver_unregister (&dummy_udc_driver);
2030 driver_unregister (&dummy_hcd_driver); 2032 platform_driver_unregister (&dummy_hcd_driver);
2031} 2033}
2032module_exit (cleanup); 2034module_exit (cleanup);
diff --git a/drivers/usb/gadget/goku_udc.c b/drivers/usb/gadget/goku_udc.c
index 654469778ab5..b0f3cd63e3b9 100644
--- a/drivers/usb/gadget/goku_udc.c
+++ b/drivers/usb/gadget/goku_udc.c
@@ -1970,7 +1970,6 @@ MODULE_DEVICE_TABLE (pci, pci_ids);
1970static struct pci_driver goku_pci_driver = { 1970static struct pci_driver goku_pci_driver = {
1971 .name = (char *) driver_name, 1971 .name = (char *) driver_name,
1972 .id_table = pci_ids, 1972 .id_table = pci_ids,
1973 .owner = THIS_MODULE,
1974 1973
1975 .probe = goku_probe, 1974 .probe = goku_probe,
1976 .remove = goku_remove, 1975 .remove = goku_remove,
diff --git a/drivers/usb/gadget/lh7a40x_udc.c b/drivers/usb/gadget/lh7a40x_udc.c
index bc6269f10cbb..e02fea5a5433 100644
--- a/drivers/usb/gadget/lh7a40x_udc.c
+++ b/drivers/usb/gadget/lh7a40x_udc.c
@@ -2085,21 +2085,21 @@ static struct lh7a40x_udc memory = {
2085/* 2085/*
2086 * probe - binds to the platform device 2086 * probe - binds to the platform device
2087 */ 2087 */
2088static int lh7a40x_udc_probe(struct device *_dev) 2088static int lh7a40x_udc_probe(struct platform_device *pdev)
2089{ 2089{
2090 struct lh7a40x_udc *dev = &memory; 2090 struct lh7a40x_udc *dev = &memory;
2091 int retval; 2091 int retval;
2092 2092
2093 DEBUG("%s: %p\n", __FUNCTION__, _dev); 2093 DEBUG("%s: %p\n", __FUNCTION__, pdev);
2094 2094
2095 spin_lock_init(&dev->lock); 2095 spin_lock_init(&dev->lock);
2096 dev->dev = _dev; 2096 dev->dev = &pdev->dev;
2097 2097
2098 device_initialize(&dev->gadget.dev); 2098 device_initialize(&dev->gadget.dev);
2099 dev->gadget.dev.parent = _dev; 2099 dev->gadget.dev.parent = &pdev->dev;
2100 2100
2101 the_controller = dev; 2101 the_controller = dev;
2102 dev_set_drvdata(_dev, dev); 2102 platform_set_drvdata(pdev, dev);
2103 2103
2104 udc_disable(dev); 2104 udc_disable(dev);
2105 udc_reinit(dev); 2105 udc_reinit(dev);
@@ -2119,11 +2119,11 @@ static int lh7a40x_udc_probe(struct device *_dev)
2119 return retval; 2119 return retval;
2120} 2120}
2121 2121
2122static int lh7a40x_udc_remove(struct device *_dev) 2122static int lh7a40x_udc_remove(struct platform_device *pdev)
2123{ 2123{
2124 struct lh7a40x_udc *dev = _dev->driver_data; 2124 struct lh7a40x_udc *dev = platform_get_drvdata(pdev);
2125 2125
2126 DEBUG("%s: %p\n", __FUNCTION__, dev); 2126 DEBUG("%s: %p\n", __FUNCTION__, pdev);
2127 2127
2128 udc_disable(dev); 2128 udc_disable(dev);
2129 remove_proc_files(); 2129 remove_proc_files();
@@ -2131,7 +2131,7 @@ static int lh7a40x_udc_remove(struct device *_dev)
2131 2131
2132 free_irq(IRQ_USBINTR, dev); 2132 free_irq(IRQ_USBINTR, dev);
2133 2133
2134 dev_set_drvdata(_dev, 0); 2134 platform_set_drvdata(pdev, 0);
2135 2135
2136 the_controller = 0; 2136 the_controller = 0;
2137 2137
@@ -2140,26 +2140,27 @@ static int lh7a40x_udc_remove(struct device *_dev)
2140 2140
2141/*-------------------------------------------------------------------------*/ 2141/*-------------------------------------------------------------------------*/
2142 2142
2143static struct device_driver udc_driver = { 2143static struct platform_driver udc_driver = {
2144 .name = (char *)driver_name,
2145 .owner = THIS_MODULE,
2146 .bus = &platform_bus_type,
2147 .probe = lh7a40x_udc_probe, 2144 .probe = lh7a40x_udc_probe,
2148 .remove = lh7a40x_udc_remove 2145 .remove = lh7a40x_udc_remove
2149 /* FIXME power management support */ 2146 /* FIXME power management support */
2150 /* .suspend = ... disable UDC */ 2147 /* .suspend = ... disable UDC */
2151 /* .resume = ... re-enable UDC */ 2148 /* .resume = ... re-enable UDC */
2149 .driver = {
2150 .name = (char *)driver_name,
2151 .owner = THIS_MODULE,
2152 },
2152}; 2153};
2153 2154
2154static int __init udc_init(void) 2155static int __init udc_init(void)
2155{ 2156{
2156 DEBUG("%s: %s version %s\n", __FUNCTION__, driver_name, DRIVER_VERSION); 2157 DEBUG("%s: %s version %s\n", __FUNCTION__, driver_name, DRIVER_VERSION);
2157 return driver_register(&udc_driver); 2158 return platform_driver_register(&udc_driver);
2158} 2159}
2159 2160
2160static void __exit udc_exit(void) 2161static void __exit udc_exit(void)
2161{ 2162{
2162 driver_unregister(&udc_driver); 2163 platform_driver_unregister(&udc_driver);
2163} 2164}
2164 2165
2165module_init(udc_init); 2166module_init(udc_init);
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c
index 0dc6bb00bf72..c32e1f7476da 100644
--- a/drivers/usb/gadget/net2280.c
+++ b/drivers/usb/gadget/net2280.c
@@ -2948,7 +2948,6 @@ MODULE_DEVICE_TABLE (pci, pci_ids);
2948static struct pci_driver net2280_pci_driver = { 2948static struct pci_driver net2280_pci_driver = {
2949 .name = (char *) driver_name, 2949 .name = (char *) driver_name,
2950 .id_table = pci_ids, 2950 .id_table = pci_ids,
2951 .owner = THIS_MODULE,
2952 2951
2953 .probe = net2280_probe, 2952 .probe = net2280_probe,
2954 .remove = net2280_remove, 2953 .remove = net2280_remove,
diff --git a/drivers/usb/gadget/omap_udc.c b/drivers/usb/gadget/omap_udc.c
index 387692a3611e..a8972d7c97be 100644
--- a/drivers/usb/gadget/omap_udc.c
+++ b/drivers/usb/gadget/omap_udc.c
@@ -2707,18 +2707,17 @@ omap_udc_setup(struct platform_device *odev, struct otg_transceiver *xceiv)
2707 return 0; 2707 return 0;
2708} 2708}
2709 2709
2710static int __init omap_udc_probe(struct device *dev) 2710static int __init omap_udc_probe(struct platform_device *pdev)
2711{ 2711{
2712 struct platform_device *odev = to_platform_device(dev);
2713 int status = -ENODEV; 2712 int status = -ENODEV;
2714 int hmc; 2713 int hmc;
2715 struct otg_transceiver *xceiv = NULL; 2714 struct otg_transceiver *xceiv = NULL;
2716 const char *type = NULL; 2715 const char *type = NULL;
2717 struct omap_usb_config *config = dev->platform_data; 2716 struct omap_usb_config *config = pdev->dev.platform_data;
2718 2717
2719 /* NOTE: "knows" the order of the resources! */ 2718 /* NOTE: "knows" the order of the resources! */
2720 if (!request_mem_region(odev->resource[0].start, 2719 if (!request_mem_region(pdev->resource[0].start,
2721 odev->resource[0].end - odev->resource[0].start + 1, 2720 pdev->resource[0].end - pdev->resource[0].start + 1,
2722 driver_name)) { 2721 driver_name)) {
2723 DBG("request_mem_region failed\n"); 2722 DBG("request_mem_region failed\n");
2724 return -EBUSY; 2723 return -EBUSY;
@@ -2803,7 +2802,7 @@ bad_on_1710:
2803 INFO("hmc mode %d, %s transceiver\n", hmc, type); 2802 INFO("hmc mode %d, %s transceiver\n", hmc, type);
2804 2803
2805 /* a "gadget" abstracts/virtualizes the controller */ 2804 /* a "gadget" abstracts/virtualizes the controller */
2806 status = omap_udc_setup(odev, xceiv); 2805 status = omap_udc_setup(pdev, xceiv);
2807 if (status) { 2806 if (status) {
2808 goto cleanup0; 2807 goto cleanup0;
2809 } 2808 }
@@ -2821,28 +2820,28 @@ bad_on_1710:
2821 udc->clr_halt = UDC_RESET_EP; 2820 udc->clr_halt = UDC_RESET_EP;
2822 2821
2823 /* USB general purpose IRQ: ep0, state changes, dma, etc */ 2822 /* USB general purpose IRQ: ep0, state changes, dma, etc */
2824 status = request_irq(odev->resource[1].start, omap_udc_irq, 2823 status = request_irq(pdev->resource[1].start, omap_udc_irq,
2825 SA_SAMPLE_RANDOM, driver_name, udc); 2824 SA_SAMPLE_RANDOM, driver_name, udc);
2826 if (status != 0) { 2825 if (status != 0) {
2827 ERR( "can't get irq %ld, err %d\n", 2826 ERR( "can't get irq %ld, err %d\n",
2828 odev->resource[1].start, status); 2827 pdev->resource[1].start, status);
2829 goto cleanup1; 2828 goto cleanup1;
2830 } 2829 }
2831 2830
2832 /* USB "non-iso" IRQ (PIO for all but ep0) */ 2831 /* USB "non-iso" IRQ (PIO for all but ep0) */
2833 status = request_irq(odev->resource[2].start, omap_udc_pio_irq, 2832 status = request_irq(pdev->resource[2].start, omap_udc_pio_irq,
2834 SA_SAMPLE_RANDOM, "omap_udc pio", udc); 2833 SA_SAMPLE_RANDOM, "omap_udc pio", udc);
2835 if (status != 0) { 2834 if (status != 0) {
2836 ERR( "can't get irq %ld, err %d\n", 2835 ERR( "can't get irq %ld, err %d\n",
2837 odev->resource[2].start, status); 2836 pdev->resource[2].start, status);
2838 goto cleanup2; 2837 goto cleanup2;
2839 } 2838 }
2840#ifdef USE_ISO 2839#ifdef USE_ISO
2841 status = request_irq(odev->resource[3].start, omap_udc_iso_irq, 2840 status = request_irq(pdev->resource[3].start, omap_udc_iso_irq,
2842 SA_INTERRUPT, "omap_udc iso", udc); 2841 SA_INTERRUPT, "omap_udc iso", udc);
2843 if (status != 0) { 2842 if (status != 0) {
2844 ERR("can't get irq %ld, err %d\n", 2843 ERR("can't get irq %ld, err %d\n",
2845 odev->resource[3].start, status); 2844 pdev->resource[3].start, status);
2846 goto cleanup3; 2845 goto cleanup3;
2847 } 2846 }
2848#endif 2847#endif
@@ -2853,11 +2852,11 @@ bad_on_1710:
2853 2852
2854#ifdef USE_ISO 2853#ifdef USE_ISO
2855cleanup3: 2854cleanup3:
2856 free_irq(odev->resource[2].start, udc); 2855 free_irq(pdev->resource[2].start, udc);
2857#endif 2856#endif
2858 2857
2859cleanup2: 2858cleanup2:
2860 free_irq(odev->resource[1].start, udc); 2859 free_irq(pdev->resource[1].start, udc);
2861 2860
2862cleanup1: 2861cleanup1:
2863 kfree (udc); 2862 kfree (udc);
@@ -2866,14 +2865,13 @@ cleanup1:
2866cleanup0: 2865cleanup0:
2867 if (xceiv) 2866 if (xceiv)
2868 put_device(xceiv->dev); 2867 put_device(xceiv->dev);
2869 release_mem_region(odev->resource[0].start, 2868 release_mem_region(pdev->resource[0].start,
2870 odev->resource[0].end - odev->resource[0].start + 1); 2869 pdev->resource[0].end - pdev->resource[0].start + 1);
2871 return status; 2870 return status;
2872} 2871}
2873 2872
2874static int __exit omap_udc_remove(struct device *dev) 2873static int __exit omap_udc_remove(struct platform_device *pdev)
2875{ 2874{
2876 struct platform_device *odev = to_platform_device(dev);
2877 DECLARE_COMPLETION(done); 2875 DECLARE_COMPLETION(done);
2878 2876
2879 if (!udc) 2877 if (!udc)
@@ -2891,13 +2889,13 @@ static int __exit omap_udc_remove(struct device *dev)
2891 remove_proc_file(); 2889 remove_proc_file();
2892 2890
2893#ifdef USE_ISO 2891#ifdef USE_ISO
2894 free_irq(odev->resource[3].start, udc); 2892 free_irq(pdev->resource[3].start, udc);
2895#endif 2893#endif
2896 free_irq(odev->resource[2].start, udc); 2894 free_irq(pdev->resource[2].start, udc);
2897 free_irq(odev->resource[1].start, udc); 2895 free_irq(pdev->resource[1].start, udc);
2898 2896
2899 release_mem_region(odev->resource[0].start, 2897 release_mem_region(pdev->resource[0].start,
2900 odev->resource[0].end - odev->resource[0].start + 1); 2898 pdev->resource[0].end - pdev->resource[0].start + 1);
2901 2899
2902 device_unregister(&udc->gadget.dev); 2900 device_unregister(&udc->gadget.dev);
2903 wait_for_completion(&done); 2901 wait_for_completion(&done);
@@ -2915,7 +2913,7 @@ static int __exit omap_udc_remove(struct device *dev)
2915 * may involve talking to an external transceiver (e.g. isp1301). 2913 * may involve talking to an external transceiver (e.g. isp1301).
2916 */ 2914 */
2917 2915
2918static int omap_udc_suspend(struct device *dev, pm_message_t message) 2916static int omap_udc_suspend(struct platform_device *dev, pm_message_t message)
2919{ 2917{
2920 u32 devstat; 2918 u32 devstat;
2921 2919
@@ -2935,7 +2933,7 @@ static int omap_udc_suspend(struct device *dev, pm_message_t message)
2935 return 0; 2933 return 0;
2936} 2934}
2937 2935
2938static int omap_udc_resume(struct device *dev) 2936static int omap_udc_resume(struct platform_device *dev)
2939{ 2937{
2940 DBG("resume + wakeup/SRP\n"); 2938 DBG("resume + wakeup/SRP\n");
2941 omap_pullup(&udc->gadget, 1); 2939 omap_pullup(&udc->gadget, 1);
@@ -2947,14 +2945,15 @@ static int omap_udc_resume(struct device *dev)
2947 2945
2948/*-------------------------------------------------------------------------*/ 2946/*-------------------------------------------------------------------------*/
2949 2947
2950static struct device_driver udc_driver = { 2948static struct platform_driver udc_driver = {
2951 .name = (char *) driver_name,
2952 .owner = THIS_MODULE,
2953 .bus = &platform_bus_type,
2954 .probe = omap_udc_probe, 2949 .probe = omap_udc_probe,
2955 .remove = __exit_p(omap_udc_remove), 2950 .remove = __exit_p(omap_udc_remove),
2956 .suspend = omap_udc_suspend, 2951 .suspend = omap_udc_suspend,
2957 .resume = omap_udc_resume, 2952 .resume = omap_udc_resume,
2953 .driver = {
2954 .owner = THIS_MODULE,
2955 .name = (char *) driver_name,
2956 },
2958}; 2957};
2959 2958
2960static int __init udc_init(void) 2959static int __init udc_init(void)
@@ -2965,13 +2964,13 @@ static int __init udc_init(void)
2965#endif 2964#endif
2966 "%s\n", driver_desc, 2965 "%s\n", driver_desc,
2967 use_dma ? " (dma)" : ""); 2966 use_dma ? " (dma)" : "");
2968 return driver_register(&udc_driver); 2967 return platform_driver_register(&udc_driver);
2969} 2968}
2970module_init(udc_init); 2969module_init(udc_init);
2971 2970
2972static void __exit udc_exit(void) 2971static void __exit udc_exit(void)
2973{ 2972{
2974 driver_unregister(&udc_driver); 2973 platform_driver_unregister(&udc_driver);
2975} 2974}
2976module_exit(udc_exit); 2975module_exit(udc_exit);
2977 2976
diff --git a/drivers/usb/gadget/pxa2xx_udc.c b/drivers/usb/gadget/pxa2xx_udc.c
index 510d28a924db..bb028c5b8952 100644
--- a/drivers/usb/gadget/pxa2xx_udc.c
+++ b/drivers/usb/gadget/pxa2xx_udc.c
@@ -2432,7 +2432,7 @@ static struct pxa2xx_udc memory = {
2432/* 2432/*
2433 * probe - binds to the platform device 2433 * probe - binds to the platform device
2434 */ 2434 */
2435static int __init pxa2xx_udc_probe(struct device *_dev) 2435static int __init pxa2xx_udc_probe(struct platform_device *pdev)
2436{ 2436{
2437 struct pxa2xx_udc *dev = &memory; 2437 struct pxa2xx_udc *dev = &memory;
2438 int retval, out_dma = 1; 2438 int retval, out_dma = 1;
@@ -2495,19 +2495,19 @@ static int __init pxa2xx_udc_probe(struct device *_dev)
2495#endif 2495#endif
2496 2496
2497 /* other non-static parts of init */ 2497 /* other non-static parts of init */
2498 dev->dev = _dev; 2498 dev->dev = &pdev->dev;
2499 dev->mach = _dev->platform_data; 2499 dev->mach = pdev->dev.platform_data;
2500 2500
2501 init_timer(&dev->timer); 2501 init_timer(&dev->timer);
2502 dev->timer.function = udc_watchdog; 2502 dev->timer.function = udc_watchdog;
2503 dev->timer.data = (unsigned long) dev; 2503 dev->timer.data = (unsigned long) dev;
2504 2504
2505 device_initialize(&dev->gadget.dev); 2505 device_initialize(&dev->gadget.dev);
2506 dev->gadget.dev.parent = _dev; 2506 dev->gadget.dev.parent = &pdev->dev;
2507 dev->gadget.dev.dma_mask = _dev->dma_mask; 2507 dev->gadget.dev.dma_mask = pdev->dev.dma_mask;
2508 2508
2509 the_controller = dev; 2509 the_controller = dev;
2510 dev_set_drvdata(_dev, dev); 2510 platform_set_drvdata(pdev, dev);
2511 2511
2512 udc_disable(dev); 2512 udc_disable(dev);
2513 udc_reinit(dev); 2513 udc_reinit(dev);
@@ -2559,14 +2559,14 @@ lubbock_fail0:
2559 return 0; 2559 return 0;
2560} 2560}
2561 2561
2562static void pxa2xx_udc_shutdown(struct device *_dev) 2562static void pxa2xx_udc_shutdown(struct platform_device *_dev)
2563{ 2563{
2564 pullup_off(); 2564 pullup_off();
2565} 2565}
2566 2566
2567static int __exit pxa2xx_udc_remove(struct device *_dev) 2567static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
2568{ 2568{
2569 struct pxa2xx_udc *dev = dev_get_drvdata(_dev); 2569 struct pxa2xx_udc *dev = platform_get_drvdata(pdev);
2570 2570
2571 udc_disable(dev); 2571 udc_disable(dev);
2572 remove_proc_files(); 2572 remove_proc_files();
@@ -2580,7 +2580,7 @@ static int __exit pxa2xx_udc_remove(struct device *_dev)
2580 free_irq(LUBBOCK_USB_DISC_IRQ, dev); 2580 free_irq(LUBBOCK_USB_DISC_IRQ, dev);
2581 free_irq(LUBBOCK_USB_IRQ, dev); 2581 free_irq(LUBBOCK_USB_IRQ, dev);
2582 } 2582 }
2583 dev_set_drvdata(_dev, NULL); 2583 platform_set_drvdata(pdev, NULL);
2584 the_controller = NULL; 2584 the_controller = NULL;
2585 return 0; 2585 return 0;
2586} 2586}
@@ -2601,9 +2601,9 @@ static int __exit pxa2xx_udc_remove(struct device *_dev)
2601 * VBUS IRQs should probably be ignored so that the PXA device just acts 2601 * VBUS IRQs should probably be ignored so that the PXA device just acts
2602 * "dead" to USB hosts until system resume. 2602 * "dead" to USB hosts until system resume.
2603 */ 2603 */
2604static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state) 2604static int pxa2xx_udc_suspend(struct platform_device *dev, pm_message_t state)
2605{ 2605{
2606 struct pxa2xx_udc *udc = dev_get_drvdata(dev); 2606 struct pxa2xx_udc *udc = platform_get_drvdata(dev);
2607 2607
2608 if (!udc->mach->udc_command) 2608 if (!udc->mach->udc_command)
2609 WARN("USB host won't detect disconnect!\n"); 2609 WARN("USB host won't detect disconnect!\n");
@@ -2612,9 +2612,9 @@ static int pxa2xx_udc_suspend(struct device *dev, pm_message_t state)
2612 return 0; 2612 return 0;
2613} 2613}
2614 2614
2615static int pxa2xx_udc_resume(struct device *dev) 2615static int pxa2xx_udc_resume(struct platform_device *dev)
2616{ 2616{
2617 struct pxa2xx_udc *udc = dev_get_drvdata(dev); 2617 struct pxa2xx_udc *udc = platform_get_drvdata(dev);
2618 2618
2619 pullup(udc, 1); 2619 pullup(udc, 1);
2620 2620
@@ -2628,27 +2628,28 @@ static int pxa2xx_udc_resume(struct device *dev)
2628 2628
2629/*-------------------------------------------------------------------------*/ 2629/*-------------------------------------------------------------------------*/
2630 2630
2631static struct device_driver udc_driver = { 2631static struct platform_driver udc_driver = {
2632 .name = "pxa2xx-udc",
2633 .owner = THIS_MODULE,
2634 .bus = &platform_bus_type,
2635 .probe = pxa2xx_udc_probe, 2632 .probe = pxa2xx_udc_probe,
2636 .shutdown = pxa2xx_udc_shutdown, 2633 .shutdown = pxa2xx_udc_shutdown,
2637 .remove = __exit_p(pxa2xx_udc_remove), 2634 .remove = __exit_p(pxa2xx_udc_remove),
2638 .suspend = pxa2xx_udc_suspend, 2635 .suspend = pxa2xx_udc_suspend,
2639 .resume = pxa2xx_udc_resume, 2636 .resume = pxa2xx_udc_resume,
2637 .driver = {
2638 .owner = THIS_MODULE,
2639 .name = "pxa2xx-udc",
2640 },
2640}; 2641};
2641 2642
2642static int __init udc_init(void) 2643static int __init udc_init(void)
2643{ 2644{
2644 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION); 2645 printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
2645 return driver_register(&udc_driver); 2646 return platform_driver_register(&udc_driver);
2646} 2647}
2647module_init(udc_init); 2648module_init(udc_init);
2648 2649
2649static void __exit udc_exit(void) 2650static void __exit udc_exit(void)
2650{ 2651{
2651 driver_unregister(&udc_driver); 2652 platform_driver_unregister(&udc_driver);
2652} 2653}
2653module_exit(udc_exit); 2654module_exit(udc_exit);
2654 2655
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index af3c05eb86fc..29f52a44b928 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -411,50 +411,39 @@ static void ehci_stop (struct usb_hcd *hcd)
411 dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status)); 411 dbg_status (ehci, "ehci_stop completed", readl (&ehci->regs->status));
412} 412}
413 413
414static int ehci_run (struct usb_hcd *hcd) 414/* one-time init, only for memory state */
415static int ehci_init(struct usb_hcd *hcd)
415{ 416{
416 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 417 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
417 u32 temp; 418 u32 temp;
418 int retval; 419 int retval;
419 u32 hcc_params; 420 u32 hcc_params;
420 int first; 421
421 422 spin_lock_init(&ehci->lock);
422 /* skip some things on restart paths */ 423
423 first = (ehci->watchdog.data == 0); 424 init_timer(&ehci->watchdog);
424 if (first) { 425 ehci->watchdog.function = ehci_watchdog;
425 init_timer (&ehci->watchdog); 426 ehci->watchdog.data = (unsigned long) ehci;
426 ehci->watchdog.function = ehci_watchdog;
427 ehci->watchdog.data = (unsigned long) ehci;
428 }
429 427
430 /* 428 /*
431 * hw default: 1K periodic list heads, one per frame. 429 * hw default: 1K periodic list heads, one per frame.
432 * periodic_size can shrink by USBCMD update if hcc_params allows. 430 * periodic_size can shrink by USBCMD update if hcc_params allows.
433 */ 431 */
434 ehci->periodic_size = DEFAULT_I_TDPS; 432 ehci->periodic_size = DEFAULT_I_TDPS;
435 if (first && (retval = ehci_mem_init (ehci, GFP_KERNEL)) < 0) 433 if ((retval = ehci_mem_init(ehci, GFP_KERNEL)) < 0)
436 return retval; 434 return retval;
437 435
438 /* controllers may cache some of the periodic schedule ... */ 436 /* controllers may cache some of the periodic schedule ... */
439 hcc_params = readl (&ehci->caps->hcc_params); 437 hcc_params = readl(&ehci->caps->hcc_params);
440 if (HCC_ISOC_CACHE (hcc_params)) // full frame cache 438 if (HCC_ISOC_CACHE(hcc_params)) // full frame cache
441 ehci->i_thresh = 8; 439 ehci->i_thresh = 8;
442 else // N microframes cached 440 else // N microframes cached
443 ehci->i_thresh = 2 + HCC_ISOC_THRES (hcc_params); 441 ehci->i_thresh = 2 + HCC_ISOC_THRES(hcc_params);
444 442
445 ehci->reclaim = NULL; 443 ehci->reclaim = NULL;
446 ehci->reclaim_ready = 0; 444 ehci->reclaim_ready = 0;
447 ehci->next_uframe = -1; 445 ehci->next_uframe = -1;
448 446
449 /* controller state: unknown --> reset */
450
451 /* EHCI spec section 4.1 */
452 if ((retval = ehci_reset (ehci)) != 0) {
453 ehci_mem_cleanup (ehci);
454 return retval;
455 }
456 writel (ehci->periodic_dma, &ehci->regs->frame_list);
457
458 /* 447 /*
459 * dedicate a qh for the async ring head, since we couldn't unlink 448 * dedicate a qh for the async ring head, since we couldn't unlink
460 * a 'real' qh without stopping the async schedule [4.8]. use it 449 * a 'real' qh without stopping the async schedule [4.8]. use it
@@ -462,37 +451,13 @@ static int ehci_run (struct usb_hcd *hcd)
462 * its dummy is used in hw_alt_next of many tds, to prevent the qh 451 * its dummy is used in hw_alt_next of many tds, to prevent the qh
463 * from automatically advancing to the next td after short reads. 452 * from automatically advancing to the next td after short reads.
464 */ 453 */
465 if (first) { 454 ehci->async->qh_next.qh = NULL;
466 ehci->async->qh_next.qh = NULL; 455 ehci->async->hw_next = QH_NEXT(ehci->async->qh_dma);
467 ehci->async->hw_next = QH_NEXT (ehci->async->qh_dma); 456 ehci->async->hw_info1 = cpu_to_le32(QH_HEAD);
468 ehci->async->hw_info1 = cpu_to_le32 (QH_HEAD); 457 ehci->async->hw_token = cpu_to_le32(QTD_STS_HALT);
469 ehci->async->hw_token = cpu_to_le32 (QTD_STS_HALT); 458 ehci->async->hw_qtd_next = EHCI_LIST_END;
470 ehci->async->hw_qtd_next = EHCI_LIST_END; 459 ehci->async->qh_state = QH_STATE_LINKED;
471 ehci->async->qh_state = QH_STATE_LINKED; 460 ehci->async->hw_alt_next = QTD_NEXT(ehci->async->dummy->qtd_dma);
472 ehci->async->hw_alt_next = QTD_NEXT (ehci->async->dummy->qtd_dma);
473 }
474 writel ((u32)ehci->async->qh_dma, &ehci->regs->async_next);
475
476 /*
477 * hcc_params controls whether ehci->regs->segment must (!!!)
478 * be used; it constrains QH/ITD/SITD and QTD locations.
479 * pci_pool consistent memory always uses segment zero.
480 * streaming mappings for I/O buffers, like pci_map_single(),
481 * can return segments above 4GB, if the device allows.
482 *
483 * NOTE: the dma mask is visible through dma_supported(), so
484 * drivers can pass this info along ... like NETIF_F_HIGHDMA,
485 * Scsi_Host.highmem_io, and so forth. It's readonly to all
486 * host side drivers though.
487 */
488 if (HCC_64BIT_ADDR (hcc_params)) {
489 writel (0, &ehci->regs->segment);
490#if 0
491// this is deeply broken on almost all architectures
492 if (!dma_set_mask (hcd->self.controller, DMA_64BIT_MASK))
493 ehci_info (ehci, "enabled 64bit DMA\n");
494#endif
495 }
496 461
497 /* clear interrupt enables, set irq latency */ 462 /* clear interrupt enables, set irq latency */
498 if (log2_irq_thresh < 0 || log2_irq_thresh > 6) 463 if (log2_irq_thresh < 0 || log2_irq_thresh > 6)
@@ -507,13 +472,13 @@ static int ehci_run (struct usb_hcd *hcd)
507 * make problems: throughput reduction (!), data errors... 472 * make problems: throughput reduction (!), data errors...
508 */ 473 */
509 if (park) { 474 if (park) {
510 park = min (park, (unsigned) 3); 475 park = min(park, (unsigned) 3);
511 temp |= CMD_PARK; 476 temp |= CMD_PARK;
512 temp |= park << 8; 477 temp |= park << 8;
513 } 478 }
514 ehci_info (ehci, "park %d\n", park); 479 ehci_dbg(ehci, "park %d\n", park);
515 } 480 }
516 if (HCC_PGM_FRAMELISTLEN (hcc_params)) { 481 if (HCC_PGM_FRAMELISTLEN(hcc_params)) {
517 /* periodic schedule size can be smaller than default */ 482 /* periodic schedule size can be smaller than default */
518 temp &= ~(3 << 2); 483 temp &= ~(3 << 2);
519 temp |= (EHCI_TUNE_FLS << 2); 484 temp |= (EHCI_TUNE_FLS << 2);
@@ -521,16 +486,63 @@ static int ehci_run (struct usb_hcd *hcd)
521 case 0: ehci->periodic_size = 1024; break; 486 case 0: ehci->periodic_size = 1024; break;
522 case 1: ehci->periodic_size = 512; break; 487 case 1: ehci->periodic_size = 512; break;
523 case 2: ehci->periodic_size = 256; break; 488 case 2: ehci->periodic_size = 256; break;
524 default: BUG (); 489 default: BUG();
525 } 490 }
526 } 491 }
492 ehci->command = temp;
493
494 ehci->reboot_notifier.notifier_call = ehci_reboot;
495 register_reboot_notifier(&ehci->reboot_notifier);
496
497 return 0;
498}
499
500/* start HC running; it's halted, ehci_init() has been run (once) */
501static int ehci_run (struct usb_hcd *hcd)
502{
503 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
504 int retval;
505 u32 temp;
506 u32 hcc_params;
507
508 /* EHCI spec section 4.1 */
509 if ((retval = ehci_reset(ehci)) != 0) {
510 unregister_reboot_notifier(&ehci->reboot_notifier);
511 ehci_mem_cleanup(ehci);
512 return retval;
513 }
514 writel(ehci->periodic_dma, &ehci->regs->frame_list);
515 writel((u32)ehci->async->qh_dma, &ehci->regs->async_next);
516
517 /*
518 * hcc_params controls whether ehci->regs->segment must (!!!)
519 * be used; it constrains QH/ITD/SITD and QTD locations.
520 * pci_pool consistent memory always uses segment zero.
521 * streaming mappings for I/O buffers, like pci_map_single(),
522 * can return segments above 4GB, if the device allows.
523 *
524 * NOTE: the dma mask is visible through dma_supported(), so
525 * drivers can pass this info along ... like NETIF_F_HIGHDMA,
526 * Scsi_Host.highmem_io, and so forth. It's readonly to all
527 * host side drivers though.
528 */
529 hcc_params = readl(&ehci->caps->hcc_params);
530 if (HCC_64BIT_ADDR(hcc_params)) {
531 writel(0, &ehci->regs->segment);
532#if 0
533// this is deeply broken on almost all architectures
534 if (!dma_set_mask(hcd->self.controller, DMA_64BIT_MASK))
535 ehci_info(ehci, "enabled 64bit DMA\n");
536#endif
537 }
538
539
527 // Philips, Intel, and maybe others need CMD_RUN before the 540 // Philips, Intel, and maybe others need CMD_RUN before the
528 // root hub will detect new devices (why?); NEC doesn't 541 // root hub will detect new devices (why?); NEC doesn't
529 temp |= CMD_RUN; 542 ehci->command &= ~(CMD_LRESET|CMD_IAAD|CMD_PSE|CMD_ASE|CMD_RESET);
530 writel (temp, &ehci->regs->command); 543 ehci->command |= CMD_RUN;
531 dbg_cmd (ehci, "init", temp); 544 writel (ehci->command, &ehci->regs->command);
532 545 dbg_cmd (ehci, "init", ehci->command);
533 /* set async sleep time = 10 us ... ? */
534 546
535 /* 547 /*
536 * Start, enabling full USB 2.0 functionality ... usb 1.1 devices 548 * Start, enabling full USB 2.0 functionality ... usb 1.1 devices
@@ -538,26 +550,23 @@ static int ehci_run (struct usb_hcd *hcd)
538 * involved with the root hub. (Except where one is integrated, 550 * involved with the root hub. (Except where one is integrated,
539 * and there's no companion controller unless maybe for USB OTG.) 551 * and there's no companion controller unless maybe for USB OTG.)
540 */ 552 */
541 if (first) {
542 ehci->reboot_notifier.notifier_call = ehci_reboot;
543 register_reboot_notifier (&ehci->reboot_notifier);
544 }
545
546 hcd->state = HC_STATE_RUNNING; 553 hcd->state = HC_STATE_RUNNING;
547 writel (FLAG_CF, &ehci->regs->configured_flag); 554 writel (FLAG_CF, &ehci->regs->configured_flag);
548 readl (&ehci->regs->command); /* unblock posted write */ 555 readl (&ehci->regs->command); /* unblock posted writes */
549 556
550 temp = HC_VERSION(readl (&ehci->caps->hc_capbase)); 557 temp = HC_VERSION(readl (&ehci->caps->hc_capbase));
551 ehci_info (ehci, 558 ehci_info (ehci,
552 "USB %x.%x %s, EHCI %x.%02x, driver %s\n", 559 "USB %x.%x started, EHCI %x.%02x, driver %s\n",
553 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f), 560 ((ehci->sbrn & 0xf0)>>4), (ehci->sbrn & 0x0f),
554 first ? "initialized" : "restarted",
555 temp >> 8, temp & 0xff, DRIVER_VERSION); 561 temp >> 8, temp & 0xff, DRIVER_VERSION);
556 562
557 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */ 563 writel (INTR_MASK, &ehci->regs->intr_enable); /* Turn On Interrupts */
558 564
559 if (first) 565 /* GRR this is run-once init(), being done every time the HC starts.
560 create_debug_files (ehci); 566 * So long as they're part of class devices, we can't do it init()
567 * since the class device isn't created that early.
568 */
569 create_debug_files(ehci);
561 570
562 return 0; 571 return 0;
563} 572}
@@ -636,9 +645,8 @@ static irqreturn_t ehci_irq (struct usb_hcd *hcd, struct pt_regs *regs)
636 * stop that signaling. 645 * stop that signaling.
637 */ 646 */
638 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20); 647 ehci->reset_done [i] = jiffies + msecs_to_jiffies (20);
639 mod_timer (&hcd->rh_timer,
640 ehci->reset_done [i] + 1);
641 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1); 648 ehci_dbg (ehci, "port %d remote wakeup\n", i + 1);
649 usb_hcd_resume_root_hub(hcd);
642 } 650 }
643 } 651 }
644 652
diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
index 88cb4ada686e..82caf336e9b6 100644
--- a/drivers/usb/host/ehci-hub.c
+++ b/drivers/usb/host/ehci-hub.c
@@ -94,6 +94,13 @@ static int ehci_bus_resume (struct usb_hcd *hcd)
94 msleep(5); 94 msleep(5);
95 spin_lock_irq (&ehci->lock); 95 spin_lock_irq (&ehci->lock);
96 96
97 /* Ideally and we've got a real resume here, and no port's power
98 * was lost. (For PCI, that means Vaux was maintained.) But we
99 * could instead be restoring a swsusp snapshot -- so that BIOS was
100 * the last user of the controller, not reset/pm hardware keeping
101 * state we gave to it.
102 */
103
97 /* re-init operational registers in case we lost power */ 104 /* re-init operational registers in case we lost power */
98 if (readl (&ehci->regs->intr_enable) == 0) { 105 if (readl (&ehci->regs->intr_enable) == 0) {
99 /* at least some APM implementations will try to deliver 106 /* at least some APM implementations will try to deliver
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c
index 145008853966..13f73a836e45 100644
--- a/drivers/usb/host/ehci-pci.c
+++ b/drivers/usb/host/ehci-pci.c
@@ -27,7 +27,7 @@
27/* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/... 27/* EHCI 0.96 (and later) section 5.1 says how to kick BIOS/SMM/...
28 * off the controller (maybe it can boot from highspeed USB disks). 28 * off the controller (maybe it can boot from highspeed USB disks).
29 */ 29 */
30static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap) 30static int bios_handoff(struct ehci_hcd *ehci, int where, u32 cap)
31{ 31{
32 struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller); 32 struct pci_dev *pdev = to_pci_dev(ehci_to_hcd(ehci)->self.controller);
33 33
@@ -48,7 +48,7 @@ static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap)
48 where, cap); 48 where, cap);
49 // some BIOS versions seem buggy... 49 // some BIOS versions seem buggy...
50 // return 1; 50 // return 1;
51 ehci_warn (ehci, "continuing after BIOS bug...\n"); 51 ehci_warn(ehci, "continuing after BIOS bug...\n");
52 /* disable all SMIs, and clear "BIOS owns" flag */ 52 /* disable all SMIs, and clear "BIOS owns" flag */
53 pci_write_config_dword(pdev, where + 4, 0); 53 pci_write_config_dword(pdev, where + 4, 0);
54 pci_write_config_byte(pdev, where + 2, 0); 54 pci_write_config_byte(pdev, where + 2, 0);
@@ -58,96 +58,47 @@ static int bios_handoff (struct ehci_hcd *ehci, int where, u32 cap)
58 return 0; 58 return 0;
59} 59}
60 60
61/* called by khubd or root hub init threads */ 61/* called after powerup, by probe or system-pm "wakeup" */
62static int ehci_pci_reset (struct usb_hcd *hcd) 62static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev)
63{ 63{
64 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
65 u32 temp; 64 u32 temp;
65 int retval;
66 unsigned count = 256/4; 66 unsigned count = 256/4;
67 67
68 spin_lock_init (&ehci->lock); 68 /* optional debug port, normally in the first BAR */
69 69 temp = pci_find_capability(pdev, 0x0a);
70 ehci->caps = hcd->regs; 70 if (temp) {
71 ehci->regs = hcd->regs + HC_LENGTH (readl (&ehci->caps->hc_capbase)); 71 pci_read_config_dword(pdev, temp, &temp);
72 dbg_hcs_params (ehci, "reset"); 72 temp >>= 16;
73 dbg_hcc_params (ehci, "reset"); 73 if ((temp & (3 << 13)) == (1 << 13)) {
74 74 temp &= 0x1fff;
75 /* cache this readonly data; minimize chip reads */ 75 ehci->debug = ehci_to_hcd(ehci)->regs + temp;
76 ehci->hcs_params = readl (&ehci->caps->hcs_params); 76 temp = readl(&ehci->debug->control);
77 77 ehci_info(ehci, "debug port %d%s\n",
78 if (hcd->self.controller->bus == &pci_bus_type) { 78 HCS_DEBUG_PORT(ehci->hcs_params),
79 struct pci_dev *pdev = to_pci_dev(hcd->self.controller); 79 (temp & DBGP_ENABLED)
80 80 ? " IN USE"
81 switch (pdev->vendor) { 81 : "");
82 case PCI_VENDOR_ID_TDI: 82 if (!(temp & DBGP_ENABLED))
83 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) { 83 ehci->debug = NULL;
84 ehci->is_tdi_rh_tt = 1;
85 tdi_reset (ehci);
86 }
87 break;
88 case PCI_VENDOR_ID_AMD:
89 /* AMD8111 EHCI doesn't work, according to AMD errata */
90 if (pdev->device == 0x7463) {
91 ehci_info (ehci, "ignoring AMD8111 (errata)\n");
92 return -EIO;
93 }
94 break;
95 case PCI_VENDOR_ID_NVIDIA:
96 /* NVidia reports that certain chips don't handle
97 * QH, ITD, or SITD addresses above 2GB. (But TD,
98 * data buffer, and periodic schedule are normal.)
99 */
100 switch (pdev->device) {
101 case 0x003c: /* MCP04 */
102 case 0x005b: /* CK804 */
103 case 0x00d8: /* CK8 */
104 case 0x00e8: /* CK8S */
105 if (pci_set_consistent_dma_mask(pdev,
106 DMA_31BIT_MASK) < 0)
107 ehci_warn (ehci, "can't enable NVidia "
108 "workaround for >2GB RAM\n");
109 break;
110 }
111 break;
112 }
113
114 /* optional debug port, normally in the first BAR */
115 temp = pci_find_capability (pdev, 0x0a);
116 if (temp) {
117 pci_read_config_dword(pdev, temp, &temp);
118 temp >>= 16;
119 if ((temp & (3 << 13)) == (1 << 13)) {
120 temp &= 0x1fff;
121 ehci->debug = hcd->regs + temp;
122 temp = readl (&ehci->debug->control);
123 ehci_info (ehci, "debug port %d%s\n",
124 HCS_DEBUG_PORT(ehci->hcs_params),
125 (temp & DBGP_ENABLED)
126 ? " IN USE"
127 : "");
128 if (!(temp & DBGP_ENABLED))
129 ehci->debug = NULL;
130 }
131 } 84 }
85 }
132 86
133 temp = HCC_EXT_CAPS (readl (&ehci->caps->hcc_params)); 87 temp = HCC_EXT_CAPS(readl(&ehci->caps->hcc_params));
134 } else
135 temp = 0;
136 88
137 /* EHCI 0.96 and later may have "extended capabilities" */ 89 /* EHCI 0.96 and later may have "extended capabilities" */
138 while (temp && count--) { 90 while (temp && count--) {
139 u32 cap; 91 u32 cap;
140 92
141 pci_read_config_dword (to_pci_dev(hcd->self.controller), 93 pci_read_config_dword(pdev, temp, &cap);
142 temp, &cap); 94 ehci_dbg(ehci, "capability %04x at %02x\n", cap, temp);
143 ehci_dbg (ehci, "capability %04x at %02x\n", cap, temp);
144 switch (cap & 0xff) { 95 switch (cap & 0xff) {
145 case 1: /* BIOS/SMM/... handoff */ 96 case 1: /* BIOS/SMM/... handoff */
146 if (bios_handoff (ehci, temp, cap) != 0) 97 if (bios_handoff(ehci, temp, cap) != 0)
147 return -EOPNOTSUPP; 98 return -EOPNOTSUPP;
148 break; 99 break;
149 case 0: /* illegal reserved capability */ 100 case 0: /* illegal reserved capability */
150 ehci_warn (ehci, "illegal capability!\n"); 101 ehci_dbg(ehci, "illegal capability!\n");
151 cap = 0; 102 cap = 0;
152 /* FALLTHROUGH */ 103 /* FALLTHROUGH */
153 default: /* unknown */ 104 default: /* unknown */
@@ -156,77 +107,114 @@ static int ehci_pci_reset (struct usb_hcd *hcd)
156 temp = (cap >> 8) & 0xff; 107 temp = (cap >> 8) & 0xff;
157 } 108 }
158 if (!count) { 109 if (!count) {
159 ehci_err (ehci, "bogus capabilities ... PCI problems!\n"); 110 ehci_err(ehci, "bogus capabilities ... PCI problems!\n");
160 return -EIO; 111 return -EIO;
161 } 112 }
162 if (ehci_is_TDI(ehci))
163 ehci_reset (ehci);
164 113
165 ehci_port_power (ehci, 0); 114 /* PCI Memory-Write-Invalidate cycle support is optional (uncommon) */
115 retval = pci_set_mwi(pdev);
116 if (!retval)
117 ehci_dbg(ehci, "MWI active\n");
118
119 ehci_port_power(ehci, 0);
120
121 return 0;
122}
123
124/* called during probe() after chip reset completes */
125static int ehci_pci_setup(struct usb_hcd *hcd)
126{
127 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
128 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
129 u32 temp;
130 int retval;
131
132 ehci->caps = hcd->regs;
133 ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase));
134 dbg_hcs_params(ehci, "reset");
135 dbg_hcc_params(ehci, "reset");
136
137 /* cache this readonly data; minimize chip reads */
138 ehci->hcs_params = readl(&ehci->caps->hcs_params);
139
140 retval = ehci_halt(ehci);
141 if (retval)
142 return retval;
143
144 /* data structure init */
145 retval = ehci_init(hcd);
146 if (retval)
147 return retval;
148
149 /* NOTE: only the parts below this line are PCI-specific */
150
151 switch (pdev->vendor) {
152 case PCI_VENDOR_ID_TDI:
153 if (pdev->device == PCI_DEVICE_ID_TDI_EHCI) {
154 ehci->is_tdi_rh_tt = 1;
155 tdi_reset(ehci);
156 }
157 break;
158 case PCI_VENDOR_ID_AMD:
159 /* AMD8111 EHCI doesn't work, according to AMD errata */
160 if (pdev->device == 0x7463) {
161 ehci_info(ehci, "ignoring AMD8111 (errata)\n");
162 retval = -EIO;
163 goto done;
164 }
165 break;
166 case PCI_VENDOR_ID_NVIDIA:
167 /* NVidia reports that certain chips don't handle
168 * QH, ITD, or SITD addresses above 2GB. (But TD,
169 * data buffer, and periodic schedule are normal.)
170 */
171 switch (pdev->device) {
172 case 0x003c: /* MCP04 */
173 case 0x005b: /* CK804 */
174 case 0x00d8: /* CK8 */
175 case 0x00e8: /* CK8S */
176 if (pci_set_consistent_dma_mask(pdev,
177 DMA_31BIT_MASK) < 0)
178 ehci_warn(ehci, "can't enable NVidia "
179 "workaround for >2GB RAM\n");
180 break;
181 }
182 break;
183 }
184
185 if (ehci_is_TDI(ehci))
186 ehci_reset(ehci);
166 187
167 /* at least the Genesys GL880S needs fixup here */ 188 /* at least the Genesys GL880S needs fixup here */
168 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params); 189 temp = HCS_N_CC(ehci->hcs_params) * HCS_N_PCC(ehci->hcs_params);
169 temp &= 0x0f; 190 temp &= 0x0f;
170 if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) { 191 if (temp && HCS_N_PORTS(ehci->hcs_params) > temp) {
171 ehci_dbg (ehci, "bogus port configuration: " 192 ehci_dbg(ehci, "bogus port configuration: "
172 "cc=%d x pcc=%d < ports=%d\n", 193 "cc=%d x pcc=%d < ports=%d\n",
173 HCS_N_CC(ehci->hcs_params), 194 HCS_N_CC(ehci->hcs_params),
174 HCS_N_PCC(ehci->hcs_params), 195 HCS_N_PCC(ehci->hcs_params),
175 HCS_N_PORTS(ehci->hcs_params)); 196 HCS_N_PORTS(ehci->hcs_params));
176 197
177 if (hcd->self.controller->bus == &pci_bus_type) { 198 switch (pdev->vendor) {
178 struct pci_dev *pdev; 199 case 0x17a0: /* GENESYS */
179 200 /* GL880S: should be PORTS=2 */
180 pdev = to_pci_dev(hcd->self.controller); 201 temp |= (ehci->hcs_params & ~0xf);
181 switch (pdev->vendor) { 202 ehci->hcs_params = temp;
182 case 0x17a0: /* GENESYS */ 203 break;
183 /* GL880S: should be PORTS=2 */ 204 case PCI_VENDOR_ID_NVIDIA:
184 temp |= (ehci->hcs_params & ~0xf); 205 /* NF4: should be PCC=10 */
185 ehci->hcs_params = temp; 206 break;
186 break;
187 case PCI_VENDOR_ID_NVIDIA:
188 /* NF4: should be PCC=10 */
189 break;
190 }
191 } 207 }
192 } 208 }
193 209
194 /* force HC to halt state */ 210 /* Serial Bus Release Number is at PCI 0x60 offset */
195 return ehci_halt (ehci); 211 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
196}
197
198static int ehci_pci_start (struct usb_hcd *hcd)
199{
200 struct ehci_hcd *ehci = hcd_to_ehci (hcd);
201 int result = 0;
202
203 if (hcd->self.controller->bus == &pci_bus_type) {
204 struct pci_dev *pdev;
205 u16 port_wake;
206
207 pdev = to_pci_dev(hcd->self.controller);
208
209 /* Serial Bus Release Number is at PCI 0x60 offset */
210 pci_read_config_byte(pdev, 0x60, &ehci->sbrn);
211
212 /* port wake capability, reported by boot firmware */
213 pci_read_config_word(pdev, 0x62, &port_wake);
214 hcd->can_wakeup = (port_wake & 1) != 0;
215
216 /* help hc dma work well with cachelines */
217 result = pci_set_mwi(pdev);
218 if (result)
219 ehci_dbg(ehci, "unable to enable MWI - not fatal.\n");
220 }
221
222 return ehci_run (hcd);
223}
224 212
225/* always called by thread; normally rmmod */ 213 /* REVISIT: per-port wake capability (PCI 0x62) currently unused */
226 214
227static void ehci_pci_stop (struct usb_hcd *hcd) 215 retval = ehci_pci_reinit(ehci, pdev);
228{ 216done:
229 ehci_stop (hcd); 217 return retval;
230} 218}
231 219
232/*-------------------------------------------------------------------------*/ 220/*-------------------------------------------------------------------------*/
@@ -235,90 +223,113 @@ static void ehci_pci_stop (struct usb_hcd *hcd)
235 223
236/* suspend/resume, section 4.3 */ 224/* suspend/resume, section 4.3 */
237 225
238/* These routines rely on the bus (pci, platform, etc) 226/* These routines rely on the PCI bus glue
239 * to handle powerdown and wakeup, and currently also on 227 * to handle powerdown and wakeup, and currently also on
240 * transceivers that don't need any software attention to set up 228 * transceivers that don't need any software attention to set up
241 * the right sort of wakeup. 229 * the right sort of wakeup.
230 * Also they depend on separate root hub suspend/resume.
242 */ 231 */
243 232
244static int ehci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 233static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message)
245{ 234{
246 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 235 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
247 236 unsigned long flags;
248 if (time_before (jiffies, ehci->next_statechange)) 237 int rc = 0;
249 msleep (100); 238
239 if (time_before(jiffies, ehci->next_statechange))
240 msleep(10);
241
242 /* Root hub was already suspended. Disable irq emission and
243 * mark HW unaccessible, bail out if RH has been resumed. Use
244 * the spinlock to properly synchronize with possible pending
245 * RH suspend or resume activity.
246 *
247 * This is still racy as hcd->state is manipulated outside of
248 * any locks =P But that will be a different fix.
249 */
250 spin_lock_irqsave (&ehci->lock, flags);
251 if (hcd->state != HC_STATE_SUSPENDED) {
252 rc = -EINVAL;
253 goto bail;
254 }
255 writel (0, &ehci->regs->intr_enable);
256 (void)readl(&ehci->regs->intr_enable);
250 257
251#ifdef CONFIG_USB_SUSPEND 258 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
252 (void) usb_suspend_device (hcd->self.root_hub); 259 bail:
253#else 260 spin_unlock_irqrestore (&ehci->lock, flags);
254 usb_lock_device (hcd->self.root_hub);
255 (void) ehci_bus_suspend (hcd);
256 usb_unlock_device (hcd->self.root_hub);
257#endif
258 261
259 // save (PCI) FLADJ in case of Vaux power loss 262 // could save FLADJ in case of Vaux power loss
260 // ... we'd only use it to handle clock skew 263 // ... we'd only use it to handle clock skew
261 264
262 return 0; 265 return rc;
263} 266}
264 267
265static int ehci_pci_resume (struct usb_hcd *hcd) 268static int ehci_pci_resume(struct usb_hcd *hcd)
266{ 269{
267 struct ehci_hcd *ehci = hcd_to_ehci (hcd); 270 struct ehci_hcd *ehci = hcd_to_ehci(hcd);
268 unsigned port; 271 unsigned port;
269 struct usb_device *root = hcd->self.root_hub; 272 struct usb_device *root = hcd->self.root_hub;
273 struct pci_dev *pdev = to_pci_dev(hcd->self.controller);
270 int retval = -EINVAL; 274 int retval = -EINVAL;
271 275
272 // maybe restore (PCI) FLADJ 276 // maybe restore FLADJ
277
278 if (time_before(jiffies, ehci->next_statechange))
279 msleep(100);
273 280
274 if (time_before (jiffies, ehci->next_statechange)) 281 /* Mark hardware accessible again as we are out of D3 state by now */
275 msleep (100); 282 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
283
284 /* If CF is clear, we lost PCI Vaux power and need to restart. */
285 if (readl(&ehci->regs->configured_flag) != FLAG_CF)
286 goto restart;
276 287
277 /* If any port is suspended (or owned by the companion), 288 /* If any port is suspended (or owned by the companion),
278 * we know we can/must resume the HC (and mustn't reset it). 289 * we know we can/must resume the HC (and mustn't reset it).
290 * We just defer that to the root hub code.
279 */ 291 */
280 for (port = HCS_N_PORTS (ehci->hcs_params); port > 0; ) { 292 for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) {
281 u32 status; 293 u32 status;
282 port--; 294 port--;
283 status = readl (&ehci->regs->port_status [port]); 295 status = readl(&ehci->regs->port_status [port]);
284 if (!(status & PORT_POWER)) 296 if (!(status & PORT_POWER))
285 continue; 297 continue;
286 if (status & (PORT_SUSPEND | PORT_OWNER)) { 298 if (status & (PORT_SUSPEND | PORT_RESUME | PORT_OWNER)) {
287 down (&hcd->self.root_hub->serialize); 299 usb_hcd_resume_root_hub(hcd);
288 retval = ehci_bus_resume (hcd); 300 return 0;
289 up (&hcd->self.root_hub->serialize);
290 break;
291 } 301 }
302 }
303
304restart:
305 ehci_dbg(ehci, "lost power, restarting\n");
306 for (port = HCS_N_PORTS(ehci->hcs_params); port > 0; ) {
307 port--;
292 if (!root->children [port]) 308 if (!root->children [port])
293 continue; 309 continue;
294 dbg_port (ehci, __FUNCTION__, port + 1, status); 310 usb_set_device_state(root->children[port],
295 usb_set_device_state (root->children[port],
296 USB_STATE_NOTATTACHED); 311 USB_STATE_NOTATTACHED);
297 } 312 }
298 313
299 /* Else reset, to cope with power loss or flush-to-storage 314 /* Else reset, to cope with power loss or flush-to-storage
300 * style "resume" having activated BIOS during reboot. 315 * style "resume" having let BIOS kick in during reboot.
301 */ 316 */
302 if (port == 0) { 317 (void) ehci_halt(ehci);
303 (void) ehci_halt (ehci); 318 (void) ehci_reset(ehci);
304 (void) ehci_reset (ehci); 319 (void) ehci_pci_reinit(ehci, pdev);
305 (void) ehci_pci_reset (hcd); 320
306 321 /* emptying the schedule aborts any urbs */
307 /* emptying the schedule aborts any urbs */ 322 spin_lock_irq(&ehci->lock);
308 spin_lock_irq (&ehci->lock); 323 if (ehci->reclaim)
309 if (ehci->reclaim) 324 ehci->reclaim_ready = 1;
310 ehci->reclaim_ready = 1; 325 ehci_work(ehci, NULL);
311 ehci_work (ehci, NULL); 326 spin_unlock_irq(&ehci->lock);
312 spin_unlock_irq (&ehci->lock); 327
313 328 /* restart; khubd will disconnect devices */
314 /* restart; khubd will disconnect devices */ 329 retval = ehci_run(hcd);
315 retval = ehci_run (hcd); 330
316 331 /* here we "know" root ports should always stay powered */
317 /* here we "know" root ports should always stay powered; 332 ehci_port_power(ehci, 1);
318 * but some controllers may lose all power.
319 */
320 ehci_port_power (ehci, 1);
321 }
322 333
323 return retval; 334 return retval;
324} 335}
@@ -338,13 +349,13 @@ static const struct hc_driver ehci_pci_hc_driver = {
338 /* 349 /*
339 * basic lifecycle operations 350 * basic lifecycle operations
340 */ 351 */
341 .reset = ehci_pci_reset, 352 .reset = ehci_pci_setup,
342 .start = ehci_pci_start, 353 .start = ehci_run,
343#ifdef CONFIG_PM 354#ifdef CONFIG_PM
344 .suspend = ehci_pci_suspend, 355 .suspend = ehci_pci_suspend,
345 .resume = ehci_pci_resume, 356 .resume = ehci_pci_resume,
346#endif 357#endif
347 .stop = ehci_pci_stop, 358 .stop = ehci_stop,
348 359
349 /* 360 /*
350 * managing i/o requests and associated device resources 361 * managing i/o requests and associated device resources
@@ -377,13 +388,12 @@ static const struct pci_device_id pci_ids [] = { {
377 }, 388 },
378 { /* end: all zeroes */ } 389 { /* end: all zeroes */ }
379}; 390};
380MODULE_DEVICE_TABLE (pci, pci_ids); 391MODULE_DEVICE_TABLE(pci, pci_ids);
381 392
382/* pci driver glue; this is a "new style" PCI driver module */ 393/* pci driver glue; this is a "new style" PCI driver module */
383static struct pci_driver ehci_pci_driver = { 394static struct pci_driver ehci_pci_driver = {
384 .name = (char *) hcd_name, 395 .name = (char *) hcd_name,
385 .id_table = pci_ids, 396 .id_table = pci_ids,
386 .owner = THIS_MODULE,
387 397
388 .probe = usb_hcd_pci_probe, 398 .probe = usb_hcd_pci_probe,
389 .remove = usb_hcd_pci_remove, 399 .remove = usb_hcd_pci_remove,
@@ -394,22 +404,22 @@ static struct pci_driver ehci_pci_driver = {
394#endif 404#endif
395}; 405};
396 406
397static int __init ehci_hcd_pci_init (void) 407static int __init ehci_hcd_pci_init(void)
398{ 408{
399 if (usb_disabled()) 409 if (usb_disabled())
400 return -ENODEV; 410 return -ENODEV;
401 411
402 pr_debug ("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n", 412 pr_debug("%s: block sizes: qh %Zd qtd %Zd itd %Zd sitd %Zd\n",
403 hcd_name, 413 hcd_name,
404 sizeof (struct ehci_qh), sizeof (struct ehci_qtd), 414 sizeof(struct ehci_qh), sizeof(struct ehci_qtd),
405 sizeof (struct ehci_itd), sizeof (struct ehci_sitd)); 415 sizeof(struct ehci_itd), sizeof(struct ehci_sitd));
406 416
407 return pci_register_driver (&ehci_pci_driver); 417 return pci_register_driver(&ehci_pci_driver);
408} 418}
409module_init (ehci_hcd_pci_init); 419module_init(ehci_hcd_pci_init);
410 420
411static void __exit ehci_hcd_pci_cleanup (void) 421static void __exit ehci_hcd_pci_cleanup(void)
412{ 422{
413 pci_unregister_driver (&ehci_pci_driver); 423 pci_unregister_driver(&ehci_pci_driver);
414} 424}
415module_exit (ehci_hcd_pci_cleanup); 425module_exit(ehci_hcd_pci_cleanup);
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 5bb872c3496d..bf03ec0d8ee2 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -912,6 +912,7 @@ submit_async (
912 int epnum; 912 int epnum;
913 unsigned long flags; 913 unsigned long flags;
914 struct ehci_qh *qh = NULL; 914 struct ehci_qh *qh = NULL;
915 int rc = 0;
915 916
916 qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list); 917 qtd = list_entry (qtd_list->next, struct ehci_qtd, qtd_list);
917 epnum = ep->desc.bEndpointAddress; 918 epnum = ep->desc.bEndpointAddress;
@@ -926,21 +927,28 @@ submit_async (
926#endif 927#endif
927 928
928 spin_lock_irqsave (&ehci->lock, flags); 929 spin_lock_irqsave (&ehci->lock, flags);
930 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
931 &ehci_to_hcd(ehci)->flags))) {
932 rc = -ESHUTDOWN;
933 goto done;
934 }
935
929 qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv); 936 qh = qh_append_tds (ehci, urb, qtd_list, epnum, &ep->hcpriv);
937 if (unlikely(qh == NULL)) {
938 rc = -ENOMEM;
939 goto done;
940 }
930 941
931 /* Control/bulk operations through TTs don't need scheduling, 942 /* Control/bulk operations through TTs don't need scheduling,
932 * the HC and TT handle it when the TT has a buffer ready. 943 * the HC and TT handle it when the TT has a buffer ready.
933 */ 944 */
934 if (likely (qh != NULL)) { 945 if (likely (qh->qh_state == QH_STATE_IDLE))
935 if (likely (qh->qh_state == QH_STATE_IDLE)) 946 qh_link_async (ehci, qh_get (qh));
936 qh_link_async (ehci, qh_get (qh)); 947 done:
937 }
938 spin_unlock_irqrestore (&ehci->lock, flags); 948 spin_unlock_irqrestore (&ehci->lock, flags);
939 if (unlikely (qh == NULL)) { 949 if (unlikely (qh == NULL))
940 qtd_list_free (ehci, urb, qtd_list); 950 qtd_list_free (ehci, urb, qtd_list);
941 return -ENOMEM; 951 return rc;
942 }
943 return 0;
944} 952}
945 953
946/*-------------------------------------------------------------------------*/ 954/*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index f0c8aa1ccd5d..57e77374d228 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -602,6 +602,12 @@ static int intr_submit (
602 602
603 spin_lock_irqsave (&ehci->lock, flags); 603 spin_lock_irqsave (&ehci->lock, flags);
604 604
605 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
606 &ehci_to_hcd(ehci)->flags))) {
607 status = -ESHUTDOWN;
608 goto done;
609 }
610
605 /* get qh and force any scheduling errors */ 611 /* get qh and force any scheduling errors */
606 INIT_LIST_HEAD (&empty); 612 INIT_LIST_HEAD (&empty);
607 qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv); 613 qh = qh_append_tds (ehci, urb, &empty, epnum, &ep->hcpriv);
@@ -1456,7 +1462,11 @@ static int itd_submit (struct ehci_hcd *ehci, struct urb *urb,
1456 1462
1457 /* schedule ... need to lock */ 1463 /* schedule ... need to lock */
1458 spin_lock_irqsave (&ehci->lock, flags); 1464 spin_lock_irqsave (&ehci->lock, flags);
1459 status = iso_stream_schedule (ehci, urb, stream); 1465 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
1466 &ehci_to_hcd(ehci)->flags)))
1467 status = -ESHUTDOWN;
1468 else
1469 status = iso_stream_schedule (ehci, urb, stream);
1460 if (likely (status == 0)) 1470 if (likely (status == 0))
1461 itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); 1471 itd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
1462 spin_unlock_irqrestore (&ehci->lock, flags); 1472 spin_unlock_irqrestore (&ehci->lock, flags);
@@ -1815,7 +1825,11 @@ static int sitd_submit (struct ehci_hcd *ehci, struct urb *urb,
1815 1825
1816 /* schedule ... need to lock */ 1826 /* schedule ... need to lock */
1817 spin_lock_irqsave (&ehci->lock, flags); 1827 spin_lock_irqsave (&ehci->lock, flags);
1818 status = iso_stream_schedule (ehci, urb, stream); 1828 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE,
1829 &ehci_to_hcd(ehci)->flags)))
1830 status = -ESHUTDOWN;
1831 else
1832 status = iso_stream_schedule (ehci, urb, stream);
1819 if (status == 0) 1833 if (status == 0)
1820 sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream); 1834 sitd_link_urb (ehci, urb, ehci->periodic_size << 3, stream);
1821 spin_unlock_irqrestore (&ehci->lock, flags); 1835 spin_unlock_irqrestore (&ehci->lock, flags);
diff --git a/drivers/usb/host/isp116x-hcd.c b/drivers/usb/host/isp116x-hcd.c
index f9c3f5b8dd1c..82f64986bc22 100644
--- a/drivers/usb/host/isp116x-hcd.c
+++ b/drivers/usb/host/isp116x-hcd.c
@@ -1633,17 +1633,15 @@ static struct hc_driver isp116x_hc_driver = {
1633 1633
1634/*----------------------------------------------------------------*/ 1634/*----------------------------------------------------------------*/
1635 1635
1636static int __init_or_module isp116x_remove(struct device *dev) 1636static int __init_or_module isp116x_remove(struct platform_device *pdev)
1637{ 1637{
1638 struct usb_hcd *hcd = dev_get_drvdata(dev); 1638 struct usb_hcd *hcd = platform_get_drvdata(pdev);
1639 struct isp116x *isp116x; 1639 struct isp116x *isp116x;
1640 struct platform_device *pdev;
1641 struct resource *res; 1640 struct resource *res;
1642 1641
1643 if (!hcd) 1642 if (!hcd)
1644 return 0; 1643 return 0;
1645 isp116x = hcd_to_isp116x(hcd); 1644 isp116x = hcd_to_isp116x(hcd);
1646 pdev = container_of(dev, struct platform_device, dev);
1647 remove_debug_file(isp116x); 1645 remove_debug_file(isp116x);
1648 usb_remove_hcd(hcd); 1646 usb_remove_hcd(hcd);
1649 1647
@@ -1660,18 +1658,16 @@ static int __init_or_module isp116x_remove(struct device *dev)
1660 1658
1661#define resource_len(r) (((r)->end - (r)->start) + 1) 1659#define resource_len(r) (((r)->end - (r)->start) + 1)
1662 1660
1663static int __init isp116x_probe(struct device *dev) 1661static int __init isp116x_probe(struct platform_device *pdev)
1664{ 1662{
1665 struct usb_hcd *hcd; 1663 struct usb_hcd *hcd;
1666 struct isp116x *isp116x; 1664 struct isp116x *isp116x;
1667 struct platform_device *pdev;
1668 struct resource *addr, *data; 1665 struct resource *addr, *data;
1669 void __iomem *addr_reg; 1666 void __iomem *addr_reg;
1670 void __iomem *data_reg; 1667 void __iomem *data_reg;
1671 int irq; 1668 int irq;
1672 int ret = 0; 1669 int ret = 0;
1673 1670
1674 pdev = container_of(dev, struct platform_device, dev);
1675 if (pdev->num_resources < 3) { 1671 if (pdev->num_resources < 3) {
1676 ret = -ENODEV; 1672 ret = -ENODEV;
1677 goto err1; 1673 goto err1;
@@ -1685,7 +1681,7 @@ static int __init isp116x_probe(struct device *dev)
1685 goto err1; 1681 goto err1;
1686 } 1682 }
1687 1683
1688 if (dev->dma_mask) { 1684 if (pdev->dev.dma_mask) {
1689 DBG("DMA not supported\n"); 1685 DBG("DMA not supported\n");
1690 ret = -EINVAL; 1686 ret = -EINVAL;
1691 goto err1; 1687 goto err1;
@@ -1711,7 +1707,7 @@ static int __init isp116x_probe(struct device *dev)
1711 } 1707 }
1712 1708
1713 /* allocate and initialize hcd */ 1709 /* allocate and initialize hcd */
1714 hcd = usb_create_hcd(&isp116x_hc_driver, dev, dev->bus_id); 1710 hcd = usb_create_hcd(&isp116x_hc_driver, &pdev->dev, pdev->dev.bus_id);
1715 if (!hcd) { 1711 if (!hcd) {
1716 ret = -ENOMEM; 1712 ret = -ENOMEM;
1717 goto err5; 1713 goto err5;
@@ -1723,7 +1719,7 @@ static int __init isp116x_probe(struct device *dev)
1723 isp116x->addr_reg = addr_reg; 1719 isp116x->addr_reg = addr_reg;
1724 spin_lock_init(&isp116x->lock); 1720 spin_lock_init(&isp116x->lock);
1725 INIT_LIST_HEAD(&isp116x->async); 1721 INIT_LIST_HEAD(&isp116x->async);
1726 isp116x->board = dev->platform_data; 1722 isp116x->board = pdev->dev.platform_data;
1727 1723
1728 if (!isp116x->board) { 1724 if (!isp116x->board) {
1729 ERR("Platform data structure not initialized\n"); 1725 ERR("Platform data structure not initialized\n");
@@ -1764,13 +1760,13 @@ static int __init isp116x_probe(struct device *dev)
1764/* 1760/*
1765 Suspend of platform device 1761 Suspend of platform device
1766*/ 1762*/
1767static int isp116x_suspend(struct device *dev, pm_message_t state) 1763static int isp116x_suspend(struct platform_device *dev, pm_message_t state)
1768{ 1764{
1769 int ret = 0; 1765 int ret = 0;
1770 1766
1771 VDBG("%s: state %x\n", __func__, state); 1767 VDBG("%s: state %x\n", __func__, state);
1772 1768
1773 dev->power.power_state = state; 1769 dev->dev.power.power_state = state;
1774 1770
1775 return ret; 1771 return ret;
1776} 1772}
@@ -1778,13 +1774,13 @@ static int isp116x_suspend(struct device *dev, pm_message_t state)
1778/* 1774/*
1779 Resume platform device 1775 Resume platform device
1780*/ 1776*/
1781static int isp116x_resume(struct device *dev) 1777static int isp116x_resume(struct platform_device *dev)
1782{ 1778{
1783 int ret = 0; 1779 int ret = 0;
1784 1780
1785 VDBG("%s: state %x\n", __func__, dev->power.power_state); 1781 VDBG("%s: state %x\n", __func__, dev->dev.power.power_state);
1786 1782
1787 dev->power.power_state = PMSG_ON; 1783 dev->dev.power.power_state = PMSG_ON;
1788 1784
1789 return ret; 1785 return ret;
1790} 1786}
@@ -1796,13 +1792,14 @@ static int isp116x_resume(struct device *dev)
1796 1792
1797#endif 1793#endif
1798 1794
1799static struct device_driver isp116x_driver = { 1795static struct platform_driver isp116x_driver = {
1800 .name = (char *)hcd_name,
1801 .bus = &platform_bus_type,
1802 .probe = isp116x_probe, 1796 .probe = isp116x_probe,
1803 .remove = isp116x_remove, 1797 .remove = isp116x_remove,
1804 .suspend = isp116x_suspend, 1798 .suspend = isp116x_suspend,
1805 .resume = isp116x_resume, 1799 .resume = isp116x_resume,
1800 .driver = {
1801 .name = (char *)hcd_name,
1802 },
1806}; 1803};
1807 1804
1808/*-----------------------------------------------------------------*/ 1805/*-----------------------------------------------------------------*/
@@ -1813,14 +1810,14 @@ static int __init isp116x_init(void)
1813 return -ENODEV; 1810 return -ENODEV;
1814 1811
1815 INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); 1812 INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION);
1816 return driver_register(&isp116x_driver); 1813 return platform_driver_register(&isp116x_driver);
1817} 1814}
1818 1815
1819module_init(isp116x_init); 1816module_init(isp116x_init);
1820 1817
1821static void __exit isp116x_cleanup(void) 1818static void __exit isp116x_cleanup(void)
1822{ 1819{
1823 driver_unregister(&isp116x_driver); 1820 platform_driver_unregister(&isp116x_driver);
1824} 1821}
1825 1822
1826module_exit(isp116x_cleanup); 1823module_exit(isp116x_cleanup);
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index f0c78cf14b6c..d9cf3b327d96 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -225,9 +225,8 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
225 225
226/*-------------------------------------------------------------------------*/ 226/*-------------------------------------------------------------------------*/
227 227
228static int ohci_hcd_au1xxx_drv_probe(struct device *dev) 228static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
229{ 229{
230 struct platform_device *pdev = to_platform_device(dev);
231 int ret; 230 int ret;
232 231
233 pr_debug ("In ohci_hcd_au1xxx_drv_probe"); 232 pr_debug ("In ohci_hcd_au1xxx_drv_probe");
@@ -239,39 +238,37 @@ static int ohci_hcd_au1xxx_drv_probe(struct device *dev)
239 return ret; 238 return ret;
240} 239}
241 240
242static int ohci_hcd_au1xxx_drv_remove(struct device *dev) 241static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
243{ 242{
244 struct platform_device *pdev = to_platform_device(dev); 243 struct usb_hcd *hcd = platform_get_drvdata(pdev);
245 struct usb_hcd *hcd = dev_get_drvdata(dev);
246 244
247 usb_hcd_au1xxx_remove(hcd, pdev); 245 usb_hcd_au1xxx_remove(hcd, pdev);
248 return 0; 246 return 0;
249} 247}
250 /*TBD*/ 248 /*TBD*/
251/*static int ohci_hcd_au1xxx_drv_suspend(struct device *dev) 249/*static int ohci_hcd_au1xxx_drv_suspend(struct platform_device *dev)
252{ 250{
253 struct platform_device *pdev = to_platform_device(dev); 251 struct usb_hcd *hcd = platform_get_drvdata(dev);
254 struct usb_hcd *hcd = dev_get_drvdata(dev);
255 252
256 return 0; 253 return 0;
257} 254}
258static int ohci_hcd_au1xxx_drv_resume(struct device *dev) 255static int ohci_hcd_au1xxx_drv_resume(struct platform_device *dev)
259{ 256{
260 struct platform_device *pdev = to_platform_device(dev); 257 struct usb_hcd *hcd = platform_get_drvdata(dev);
261 struct usb_hcd *hcd = dev_get_drvdata(dev);
262 258
263 return 0; 259 return 0;
264} 260}
265*/ 261*/
266 262
267static struct device_driver ohci_hcd_au1xxx_driver = { 263static struct platform_driver ohci_hcd_au1xxx_driver = {
268 .name = "au1xxx-ohci",
269 .owner = THIS_MODULE,
270 .bus = &platform_bus_type,
271 .probe = ohci_hcd_au1xxx_drv_probe, 264 .probe = ohci_hcd_au1xxx_drv_probe,
272 .remove = ohci_hcd_au1xxx_drv_remove, 265 .remove = ohci_hcd_au1xxx_drv_remove,
273 /*.suspend = ohci_hcd_au1xxx_drv_suspend, */ 266 /*.suspend = ohci_hcd_au1xxx_drv_suspend, */
274 /*.resume = ohci_hcd_au1xxx_drv_resume, */ 267 /*.resume = ohci_hcd_au1xxx_drv_resume, */
268 .driver = {
269 .name = "au1xxx-ohci",
270 .owner = THIS_MODULE,
271 },
275}; 272};
276 273
277static int __init ohci_hcd_au1xxx_init (void) 274static int __init ohci_hcd_au1xxx_init (void)
@@ -280,12 +277,12 @@ static int __init ohci_hcd_au1xxx_init (void)
280 pr_debug ("block sizes: ed %d td %d\n", 277 pr_debug ("block sizes: ed %d td %d\n",
281 sizeof (struct ed), sizeof (struct td)); 278 sizeof (struct ed), sizeof (struct td));
282 279
283 return driver_register(&ohci_hcd_au1xxx_driver); 280 return platform_driver_register(&ohci_hcd_au1xxx_driver);
284} 281}
285 282
286static void __exit ohci_hcd_au1xxx_cleanup (void) 283static void __exit ohci_hcd_au1xxx_cleanup (void)
287{ 284{
288 driver_unregister(&ohci_hcd_au1xxx_driver); 285 platform_driver_unregister(&ohci_hcd_au1xxx_driver);
289} 286}
290 287
291module_init (ohci_hcd_au1xxx_init); 288module_init (ohci_hcd_au1xxx_init);
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index 5c0c6c8a7a82..bf1d9abc07ac 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -115,7 +115,7 @@
115 115
116/*-------------------------------------------------------------------------*/ 116/*-------------------------------------------------------------------------*/
117 117
118// #define OHCI_VERBOSE_DEBUG /* not always helpful */ 118#undef OHCI_VERBOSE_DEBUG /* not always helpful */
119 119
120/* For initializing controller (mask in an HCFS mode too) */ 120/* For initializing controller (mask in an HCFS mode too) */
121#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR 121#define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
@@ -253,6 +253,10 @@ static int ohci_urb_enqueue (
253 spin_lock_irqsave (&ohci->lock, flags); 253 spin_lock_irqsave (&ohci->lock, flags);
254 254
255 /* don't submit to a dead HC */ 255 /* don't submit to a dead HC */
256 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
257 retval = -ENODEV;
258 goto fail;
259 }
256 if (!HC_IS_RUNNING(hcd->state)) { 260 if (!HC_IS_RUNNING(hcd->state)) {
257 retval = -ENODEV; 261 retval = -ENODEV;
258 goto fail; 262 goto fail;
diff --git a/drivers/usb/host/ohci-hub.c b/drivers/usb/host/ohci-hub.c
index e01e77bc324b..72e3b12a1926 100644
--- a/drivers/usb/host/ohci-hub.c
+++ b/drivers/usb/host/ohci-hub.c
@@ -53,6 +53,11 @@ static int ohci_bus_suspend (struct usb_hcd *hcd)
53 53
54 spin_lock_irqsave (&ohci->lock, flags); 54 spin_lock_irqsave (&ohci->lock, flags);
55 55
56 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) {
57 spin_unlock_irqrestore (&ohci->lock, flags);
58 return -ESHUTDOWN;
59 }
60
56 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); 61 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
57 switch (ohci->hc_control & OHCI_CTRL_HCFS) { 62 switch (ohci->hc_control & OHCI_CTRL_HCFS) {
58 case OHCI_USB_RESUME: 63 case OHCI_USB_RESUME:
@@ -140,11 +145,19 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
140 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 145 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
141 u32 temp, enables; 146 u32 temp, enables;
142 int status = -EINPROGRESS; 147 int status = -EINPROGRESS;
148 unsigned long flags;
143 149
144 if (time_before (jiffies, ohci->next_statechange)) 150 if (time_before (jiffies, ohci->next_statechange))
145 msleep(5); 151 msleep(5);
146 152
147 spin_lock_irq (&ohci->lock); 153 spin_lock_irqsave (&ohci->lock, flags);
154
155 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))) {
156 spin_unlock_irqrestore (&ohci->lock, flags);
157 return -ESHUTDOWN;
158 }
159
160
148 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control); 161 ohci->hc_control = ohci_readl (ohci, &ohci->regs->control);
149 162
150 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) { 163 if (ohci->hc_control & (OHCI_CTRL_IR | OHCI_SCHED_ENABLES)) {
@@ -179,7 +192,7 @@ static int ohci_bus_resume (struct usb_hcd *hcd)
179 ohci_dbg (ohci, "lost power\n"); 192 ohci_dbg (ohci, "lost power\n");
180 status = -EBUSY; 193 status = -EBUSY;
181 } 194 }
182 spin_unlock_irq (&ohci->lock); 195 spin_unlock_irqrestore (&ohci->lock, flags);
183 if (status == -EBUSY) { 196 if (status == -EBUSY) {
184 (void) ohci_init (ohci); 197 (void) ohci_init (ohci);
185 return ohci_restart (ohci); 198 return ohci_restart (ohci);
@@ -297,8 +310,8 @@ ohci_hub_status_data (struct usb_hcd *hcd, char *buf)
297 /* handle autosuspended root: finish resuming before 310 /* handle autosuspended root: finish resuming before
298 * letting khubd or root hub timer see state changes. 311 * letting khubd or root hub timer see state changes.
299 */ 312 */
300 if ((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER 313 if (unlikely((ohci->hc_control & OHCI_CTRL_HCFS) != OHCI_USB_OPER
301 || !HC_IS_RUNNING(hcd->state)) { 314 || !HC_IS_RUNNING(hcd->state))) {
302 can_suspend = 0; 315 can_suspend = 0;
303 goto done; 316 goto done;
304 } 317 }
@@ -508,6 +521,9 @@ static int ohci_hub_control (
508 u32 temp; 521 u32 temp;
509 int retval = 0; 522 int retval = 0;
510 523
524 if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
525 return -ESHUTDOWN;
526
511 switch (typeReq) { 527 switch (typeReq) {
512 case ClearHubFeature: 528 case ClearHubFeature:
513 switch (wValue) { 529 switch (wValue) {
diff --git a/drivers/usb/host/ohci-lh7a404.c b/drivers/usb/host/ohci-lh7a404.c
index 336c766c6e29..3959ccc88332 100644
--- a/drivers/usb/host/ohci-lh7a404.c
+++ b/drivers/usb/host/ohci-lh7a404.c
@@ -204,9 +204,8 @@ static const struct hc_driver ohci_lh7a404_hc_driver = {
204 204
205/*-------------------------------------------------------------------------*/ 205/*-------------------------------------------------------------------------*/
206 206
207static int ohci_hcd_lh7a404_drv_probe(struct device *dev) 207static int ohci_hcd_lh7a404_drv_probe(struct platform_device *pdev)
208{ 208{
209 struct platform_device *pdev = to_platform_device(dev);
210 int ret; 209 int ret;
211 210
212 pr_debug ("In ohci_hcd_lh7a404_drv_probe"); 211 pr_debug ("In ohci_hcd_lh7a404_drv_probe");
@@ -218,40 +217,38 @@ static int ohci_hcd_lh7a404_drv_probe(struct device *dev)
218 return ret; 217 return ret;
219} 218}
220 219
221static int ohci_hcd_lh7a404_drv_remove(struct device *dev) 220static int ohci_hcd_lh7a404_drv_remove(struct platform_device *pdev)
222{ 221{
223 struct platform_device *pdev = to_platform_device(dev); 222 struct usb_hcd *hcd = platform_get_drvdata(pdev);
224 struct usb_hcd *hcd = dev_get_drvdata(dev);
225 223
226 usb_hcd_lh7a404_remove(hcd, pdev); 224 usb_hcd_lh7a404_remove(hcd, pdev);
227 return 0; 225 return 0;
228} 226}
229 /*TBD*/ 227 /*TBD*/
230/*static int ohci_hcd_lh7a404_drv_suspend(struct device *dev) 228/*static int ohci_hcd_lh7a404_drv_suspend(struct platform_device *dev)
231{ 229{
232 struct platform_device *pdev = to_platform_device(dev); 230 struct usb_hcd *hcd = platform_get_drvdata(dev);
233 struct usb_hcd *hcd = dev_get_drvdata(dev);
234 231
235 return 0; 232 return 0;
236} 233}
237static int ohci_hcd_lh7a404_drv_resume(struct device *dev) 234static int ohci_hcd_lh7a404_drv_resume(struct platform_device *dev)
238{ 235{
239 struct platform_device *pdev = to_platform_device(dev); 236 struct usb_hcd *hcd = platform_get_drvdata(dev);
240 struct usb_hcd *hcd = dev_get_drvdata(dev);
241 237
242 238
243 return 0; 239 return 0;
244} 240}
245*/ 241*/
246 242
247static struct device_driver ohci_hcd_lh7a404_driver = { 243static struct platform_driver ohci_hcd_lh7a404_driver = {
248 .name = "lh7a404-ohci",
249 .owner = THIS_MODULE,
250 .bus = &platform_bus_type,
251 .probe = ohci_hcd_lh7a404_drv_probe, 244 .probe = ohci_hcd_lh7a404_drv_probe,
252 .remove = ohci_hcd_lh7a404_drv_remove, 245 .remove = ohci_hcd_lh7a404_drv_remove,
253 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */ 246 /*.suspend = ohci_hcd_lh7a404_drv_suspend, */
254 /*.resume = ohci_hcd_lh7a404_drv_resume, */ 247 /*.resume = ohci_hcd_lh7a404_drv_resume, */
248 .driver = {
249 .name = "lh7a404-ohci",
250 .owner = THIS_MODULE,
251 },
255}; 252};
256 253
257static int __init ohci_hcd_lh7a404_init (void) 254static int __init ohci_hcd_lh7a404_init (void)
@@ -260,12 +257,12 @@ static int __init ohci_hcd_lh7a404_init (void)
260 pr_debug ("block sizes: ed %d td %d\n", 257 pr_debug ("block sizes: ed %d td %d\n",
261 sizeof (struct ed), sizeof (struct td)); 258 sizeof (struct ed), sizeof (struct td));
262 259
263 return driver_register(&ohci_hcd_lh7a404_driver); 260 return platform_driver_register(&ohci_hcd_lh7a404_driver);
264} 261}
265 262
266static void __exit ohci_hcd_lh7a404_cleanup (void) 263static void __exit ohci_hcd_lh7a404_cleanup (void)
267{ 264{
268 driver_unregister(&ohci_hcd_lh7a404_driver); 265 platform_driver_unregister(&ohci_hcd_lh7a404_driver);
269} 266}
270 267
271module_init (ohci_hcd_lh7a404_init); 268module_init (ohci_hcd_lh7a404_init);
diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c
index e46cc540cf4d..c9e29d808711 100644
--- a/drivers/usb/host/ohci-omap.c
+++ b/drivers/usb/host/ohci-omap.c
@@ -433,24 +433,22 @@ static const struct hc_driver ohci_omap_hc_driver = {
433 433
434/*-------------------------------------------------------------------------*/ 434/*-------------------------------------------------------------------------*/
435 435
436static int ohci_hcd_omap_drv_probe(struct device *dev) 436static int ohci_hcd_omap_drv_probe(struct platform_device *dev)
437{ 437{
438 return usb_hcd_omap_probe(&ohci_omap_hc_driver, 438 return usb_hcd_omap_probe(&ohci_omap_hc_driver, dev);
439 to_platform_device(dev));
440} 439}
441 440
442static int ohci_hcd_omap_drv_remove(struct device *dev) 441static int ohci_hcd_omap_drv_remove(struct platform_device *dev)
443{ 442{
444 struct platform_device *pdev = to_platform_device(dev); 443 struct usb_hcd *hcd = platform_get_drvdata(dev);
445 struct usb_hcd *hcd = dev_get_drvdata(dev);
446 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 444 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
447 445
448 usb_hcd_omap_remove(hcd, pdev); 446 usb_hcd_omap_remove(hcd, dev);
449 if (ohci->transceiver) { 447 if (ohci->transceiver) {
450 (void) otg_set_host(ohci->transceiver, 0); 448 (void) otg_set_host(ohci->transceiver, 0);
451 put_device(ohci->transceiver->dev); 449 put_device(ohci->transceiver->dev);
452 } 450 }
453 dev_set_drvdata(dev, NULL); 451 platform_set_drvdata(dev, NULL);
454 452
455 return 0; 453 return 0;
456} 454}
@@ -459,9 +457,9 @@ static int ohci_hcd_omap_drv_remove(struct device *dev)
459 457
460#ifdef CONFIG_PM 458#ifdef CONFIG_PM
461 459
462static int ohci_omap_suspend(struct device *dev, pm_message_t message) 460static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message)
463{ 461{
464 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); 462 struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev));
465 463
466 if (time_before(jiffies, ohci->next_statechange)) 464 if (time_before(jiffies, ohci->next_statechange))
467 msleep(5); 465 msleep(5);
@@ -473,9 +471,9 @@ static int ohci_omap_suspend(struct device *dev, pm_message_t message)
473 return 0; 471 return 0;
474} 472}
475 473
476static int ohci_omap_resume(struct device *dev) 474static int ohci_omap_resume(struct platform_device *dev)
477{ 475{
478 struct ohci_hcd *ohci = hcd_to_ohci(dev_get_drvdata(dev)); 476 struct ohci_hcd *ohci = hcd_to_ohci(platform_get_drvdata(dev));
479 477
480 if (time_before(jiffies, ohci->next_statechange)) 478 if (time_before(jiffies, ohci->next_statechange))
481 msleep(5); 479 msleep(5);
@@ -494,16 +492,17 @@ static int ohci_omap_resume(struct device *dev)
494/* 492/*
495 * Driver definition to register with the OMAP bus 493 * Driver definition to register with the OMAP bus
496 */ 494 */
497static struct device_driver ohci_hcd_omap_driver = { 495static struct platform_driver ohci_hcd_omap_driver = {
498 .name = "ohci",
499 .owner = THIS_MODULE,
500 .bus = &platform_bus_type,
501 .probe = ohci_hcd_omap_drv_probe, 496 .probe = ohci_hcd_omap_drv_probe,
502 .remove = ohci_hcd_omap_drv_remove, 497 .remove = ohci_hcd_omap_drv_remove,
503#ifdef CONFIG_PM 498#ifdef CONFIG_PM
504 .suspend = ohci_omap_suspend, 499 .suspend = ohci_omap_suspend,
505 .resume = ohci_omap_resume, 500 .resume = ohci_omap_resume,
506#endif 501#endif
502 .driver = {
503 .owner = THIS_MODULE,
504 .name = "ohci",
505 },
507}; 506};
508 507
509static int __init ohci_hcd_omap_init (void) 508static int __init ohci_hcd_omap_init (void)
@@ -515,12 +514,12 @@ static int __init ohci_hcd_omap_init (void)
515 pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name, 514 pr_debug("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
516 sizeof (struct ed), sizeof (struct td)); 515 sizeof (struct ed), sizeof (struct td));
517 516
518 return driver_register(&ohci_hcd_omap_driver); 517 return platform_driver_register(&ohci_hcd_omap_driver);
519} 518}
520 519
521static void __exit ohci_hcd_omap_cleanup (void) 520static void __exit ohci_hcd_omap_cleanup (void)
522{ 521{
523 driver_unregister(&ohci_hcd_omap_driver); 522 platform_driver_unregister(&ohci_hcd_omap_driver);
524} 523}
525 524
526module_init (ohci_hcd_omap_init); 525module_init (ohci_hcd_omap_init);
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c
index 7ce1d9ef0289..1b09dde068e1 100644
--- a/drivers/usb/host/ohci-pci.c
+++ b/drivers/usb/host/ohci-pci.c
@@ -14,15 +14,6 @@
14 * This file is licenced under the GPL. 14 * This file is licenced under the GPL.
15 */ 15 */
16 16
17#include <linux/jiffies.h>
18
19#ifdef CONFIG_PPC_PMAC
20#include <asm/machdep.h>
21#include <asm/pmac_feature.h>
22#include <asm/pci-bridge.h>
23#include <asm/prom.h>
24#endif
25
26#ifndef CONFIG_PCI 17#ifndef CONFIG_PCI
27#error "This file is PCI bus glue. CONFIG_PCI must be defined." 18#error "This file is PCI bus glue. CONFIG_PCI must be defined."
28#endif 19#endif
@@ -114,40 +105,36 @@ ohci_pci_start (struct usb_hcd *hcd)
114 105
115static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message) 106static int ohci_pci_suspend (struct usb_hcd *hcd, pm_message_t message)
116{ 107{
117 /* root hub was already suspended */ 108 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
118 109 unsigned long flags;
119 /* FIXME these PMAC things get called in the wrong places. ASIC 110 int rc = 0;
120 * clocks should be turned off AFTER entering D3, and on BEFORE 111
121 * trying to enter D0. Evidently the PCI layer doesn't currently 112 /* Root hub was already suspended. Disable irq emission and
122 * provide the right sort of platform hooks for this ... 113 * mark HW unaccessible, bail out if RH has been resumed. Use
114 * the spinlock to properly synchronize with possible pending
115 * RH suspend or resume activity.
116 *
117 * This is still racy as hcd->state is manipulated outside of
118 * any locks =P But that will be a different fix.
123 */ 119 */
124#ifdef CONFIG_PPC_PMAC 120 spin_lock_irqsave (&ohci->lock, flags);
125 if (_machine == _MACH_Pmac) { 121 if (hcd->state != HC_STATE_SUSPENDED) {
126 struct device_node *of_node; 122 rc = -EINVAL;
127 123 goto bail;
128 /* Disable USB PAD & cell clock */
129 of_node = pci_device_to_OF_node (to_pci_dev(hcd->self.controller));
130 if (of_node)
131 pmac_call_feature(PMAC_FTR_USB_ENABLE, of_node, 0, 0);
132 } 124 }
133#endif /* CONFIG_PPC_PMAC */ 125 ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable);
134 return 0; 126 (void)ohci_readl(ohci, &ohci->regs->intrdisable);
127 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
128 bail:
129 spin_unlock_irqrestore (&ohci->lock, flags);
130
131 return rc;
135} 132}
136 133
137 134
138static int ohci_pci_resume (struct usb_hcd *hcd) 135static int ohci_pci_resume (struct usb_hcd *hcd)
139{ 136{
140#ifdef CONFIG_PPC_PMAC 137 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
141 if (_machine == _MACH_Pmac) {
142 struct device_node *of_node;
143
144 /* Re-enable USB PAD & cell clock */
145 of_node = pci_device_to_OF_node (to_pci_dev(hcd->self.controller));
146 if (of_node)
147 pmac_call_feature (PMAC_FTR_USB_ENABLE, of_node, 0, 1);
148 }
149#endif /* CONFIG_PPC_PMAC */
150
151 usb_hcd_resume_root_hub(hcd); 138 usb_hcd_resume_root_hub(hcd);
152 return 0; 139 return 0;
153} 140}
@@ -218,7 +205,6 @@ MODULE_DEVICE_TABLE (pci, pci_ids);
218static struct pci_driver ohci_pci_driver = { 205static struct pci_driver ohci_pci_driver = {
219 .name = (char *) hcd_name, 206 .name = (char *) hcd_name,
220 .id_table = pci_ids, 207 .id_table = pci_ids,
221 .owner = THIS_MODULE,
222 208
223 .probe = usb_hcd_pci_probe, 209 .probe = usb_hcd_pci_probe,
224 .remove = usb_hcd_pci_remove, 210 .remove = usb_hcd_pci_remove,
diff --git a/drivers/usb/host/ohci-ppc-soc.c b/drivers/usb/host/ohci-ppc-soc.c
index 92cf6f4a1374..2ec6a78bd65e 100644
--- a/drivers/usb/host/ohci-ppc-soc.c
+++ b/drivers/usb/host/ohci-ppc-soc.c
@@ -172,9 +172,8 @@ static const struct hc_driver ohci_ppc_soc_hc_driver = {
172 .start_port_reset = ohci_start_port_reset, 172 .start_port_reset = ohci_start_port_reset,
173}; 173};
174 174
175static int ohci_hcd_ppc_soc_drv_probe(struct device *dev) 175static int ohci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
176{ 176{
177 struct platform_device *pdev = to_platform_device(dev);
178 int ret; 177 int ret;
179 178
180 if (usb_disabled()) 179 if (usb_disabled())
@@ -184,25 +183,25 @@ static int ohci_hcd_ppc_soc_drv_probe(struct device *dev)
184 return ret; 183 return ret;
185} 184}
186 185
187static int ohci_hcd_ppc_soc_drv_remove(struct device *dev) 186static int ohci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
188{ 187{
189 struct platform_device *pdev = to_platform_device(dev); 188 struct usb_hcd *hcd = platform_get_drvdata(pdev);
190 struct usb_hcd *hcd = dev_get_drvdata(dev);
191 189
192 usb_hcd_ppc_soc_remove(hcd, pdev); 190 usb_hcd_ppc_soc_remove(hcd, pdev);
193 return 0; 191 return 0;
194} 192}
195 193
196static struct device_driver ohci_hcd_ppc_soc_driver = { 194static struct platform_driver ohci_hcd_ppc_soc_driver = {
197 .name = "ppc-soc-ohci",
198 .owner = THIS_MODULE,
199 .bus = &platform_bus_type,
200 .probe = ohci_hcd_ppc_soc_drv_probe, 195 .probe = ohci_hcd_ppc_soc_drv_probe,
201 .remove = ohci_hcd_ppc_soc_drv_remove, 196 .remove = ohci_hcd_ppc_soc_drv_remove,
202#ifdef CONFIG_PM 197#ifdef CONFIG_PM
203 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/ 198 /*.suspend = ohci_hcd_ppc_soc_drv_suspend,*/
204 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/ 199 /*.resume = ohci_hcd_ppc_soc_drv_resume,*/
205#endif 200#endif
201 .driver = {
202 .name = "ppc-soc-ohci",
203 .owner = THIS_MODULE,
204 },
206}; 205};
207 206
208static int __init ohci_hcd_ppc_soc_init(void) 207static int __init ohci_hcd_ppc_soc_init(void)
@@ -211,12 +210,12 @@ static int __init ohci_hcd_ppc_soc_init(void)
211 pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed), 210 pr_debug("block sizes: ed %d td %d\n", sizeof(struct ed),
212 sizeof(struct td)); 211 sizeof(struct td));
213 212
214 return driver_register(&ohci_hcd_ppc_soc_driver); 213 return platform_driver_register(&ohci_hcd_ppc_soc_driver);
215} 214}
216 215
217static void __exit ohci_hcd_ppc_soc_cleanup(void) 216static void __exit ohci_hcd_ppc_soc_cleanup(void)
218{ 217{
219 driver_unregister(&ohci_hcd_ppc_soc_driver); 218 platform_driver_unregister(&ohci_hcd_ppc_soc_driver);
220} 219}
221 220
222module_init(ohci_hcd_ppc_soc_init); 221module_init(ohci_hcd_ppc_soc_init);
diff --git a/drivers/usb/host/ohci-pxa27x.c b/drivers/usb/host/ohci-pxa27x.c
index 59e20568e8f9..9d65ec307990 100644
--- a/drivers/usb/host/ohci-pxa27x.c
+++ b/drivers/usb/host/ohci-pxa27x.c
@@ -290,9 +290,8 @@ static const struct hc_driver ohci_pxa27x_hc_driver = {
290 290
291/*-------------------------------------------------------------------------*/ 291/*-------------------------------------------------------------------------*/
292 292
293static int ohci_hcd_pxa27x_drv_probe(struct device *dev) 293static int ohci_hcd_pxa27x_drv_probe(struct platform_device *pdev)
294{ 294{
295 struct platform_device *pdev = to_platform_device(dev);
296 int ret; 295 int ret;
297 296
298 pr_debug ("In ohci_hcd_pxa27x_drv_probe"); 297 pr_debug ("In ohci_hcd_pxa27x_drv_probe");
@@ -304,41 +303,39 @@ static int ohci_hcd_pxa27x_drv_probe(struct device *dev)
304 return ret; 303 return ret;
305} 304}
306 305
307static int ohci_hcd_pxa27x_drv_remove(struct device *dev) 306static int ohci_hcd_pxa27x_drv_remove(struct platform_device *pdev)
308{ 307{
309 struct platform_device *pdev = to_platform_device(dev); 308 struct usb_hcd *hcd = platform_get_drvdata(pdev);
310 struct usb_hcd *hcd = dev_get_drvdata(dev);
311 309
312 usb_hcd_pxa27x_remove(hcd, pdev); 310 usb_hcd_pxa27x_remove(hcd, pdev);
313 return 0; 311 return 0;
314} 312}
315 313
316static int ohci_hcd_pxa27x_drv_suspend(struct device *dev, pm_message_t state) 314static int ohci_hcd_pxa27x_drv_suspend(struct platform_device *dev, pm_message_t state)
317{ 315{
318// struct platform_device *pdev = to_platform_device(dev); 316// struct usb_hcd *hcd = platform_get_drvdata(dev);
319// struct usb_hcd *hcd = dev_get_drvdata(dev);
320 printk("%s: not implemented yet\n", __FUNCTION__); 317 printk("%s: not implemented yet\n", __FUNCTION__);
321 318
322 return 0; 319 return 0;
323} 320}
324 321
325static int ohci_hcd_pxa27x_drv_resume(struct device *dev) 322static int ohci_hcd_pxa27x_drv_resume(struct platform_device *dev)
326{ 323{
327// struct platform_device *pdev = to_platform_device(dev); 324// struct usb_hcd *hcd = platform_get_drvdata(dev);
328// struct usb_hcd *hcd = dev_get_drvdata(dev);
329 printk("%s: not implemented yet\n", __FUNCTION__); 325 printk("%s: not implemented yet\n", __FUNCTION__);
330 326
331 return 0; 327 return 0;
332} 328}
333 329
334 330
335static struct device_driver ohci_hcd_pxa27x_driver = { 331static struct platform_driver ohci_hcd_pxa27x_driver = {
336 .name = "pxa27x-ohci",
337 .bus = &platform_bus_type,
338 .probe = ohci_hcd_pxa27x_drv_probe, 332 .probe = ohci_hcd_pxa27x_drv_probe,
339 .remove = ohci_hcd_pxa27x_drv_remove, 333 .remove = ohci_hcd_pxa27x_drv_remove,
340 .suspend = ohci_hcd_pxa27x_drv_suspend, 334 .suspend = ohci_hcd_pxa27x_drv_suspend,
341 .resume = ohci_hcd_pxa27x_drv_resume, 335 .resume = ohci_hcd_pxa27x_drv_resume,
336 .driver = {
337 .name = "pxa27x-ohci",
338 },
342}; 339};
343 340
344static int __init ohci_hcd_pxa27x_init (void) 341static int __init ohci_hcd_pxa27x_init (void)
@@ -347,12 +344,12 @@ static int __init ohci_hcd_pxa27x_init (void)
347 pr_debug ("block sizes: ed %d td %d\n", 344 pr_debug ("block sizes: ed %d td %d\n",
348 sizeof (struct ed), sizeof (struct td)); 345 sizeof (struct ed), sizeof (struct td));
349 346
350 return driver_register(&ohci_hcd_pxa27x_driver); 347 return platform_driver_register(&ohci_hcd_pxa27x_driver);
351} 348}
352 349
353static void __exit ohci_hcd_pxa27x_cleanup (void) 350static void __exit ohci_hcd_pxa27x_cleanup (void)
354{ 351{
355 driver_unregister(&ohci_hcd_pxa27x_driver); 352 platform_driver_unregister(&ohci_hcd_pxa27x_driver);
356} 353}
357 354
358module_init (ohci_hcd_pxa27x_init); 355module_init (ohci_hcd_pxa27x_init);
diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c
index ee1fc605b402..35cc9402adc0 100644
--- a/drivers/usb/host/ohci-s3c2410.c
+++ b/drivers/usb/host/ohci-s3c2410.c
@@ -459,39 +459,38 @@ static const struct hc_driver ohci_s3c2410_hc_driver = {
459 459
460/* device driver */ 460/* device driver */
461 461
462static int ohci_hcd_s3c2410_drv_probe(struct device *dev) 462static int ohci_hcd_s3c2410_drv_probe(struct platform_device *pdev)
463{ 463{
464 struct platform_device *pdev = to_platform_device(dev);
465 return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); 464 return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev);
466} 465}
467 466
468static int ohci_hcd_s3c2410_drv_remove(struct device *dev) 467static int ohci_hcd_s3c2410_drv_remove(struct platform_device *pdev)
469{ 468{
470 struct platform_device *pdev = to_platform_device(dev); 469 struct usb_hcd *hcd = platform_get_drvdata(pdev);
471 struct usb_hcd *hcd = dev_get_drvdata(dev);
472 470
473 usb_hcd_s3c2410_remove(hcd, pdev); 471 usb_hcd_s3c2410_remove(hcd, pdev);
474 return 0; 472 return 0;
475} 473}
476 474
477static struct device_driver ohci_hcd_s3c2410_driver = { 475static struct platform_driver ohci_hcd_s3c2410_driver = {
478 .name = "s3c2410-ohci",
479 .owner = THIS_MODULE,
480 .bus = &platform_bus_type,
481 .probe = ohci_hcd_s3c2410_drv_probe, 476 .probe = ohci_hcd_s3c2410_drv_probe,
482 .remove = ohci_hcd_s3c2410_drv_remove, 477 .remove = ohci_hcd_s3c2410_drv_remove,
483 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */ 478 /*.suspend = ohci_hcd_s3c2410_drv_suspend, */
484 /*.resume = ohci_hcd_s3c2410_drv_resume, */ 479 /*.resume = ohci_hcd_s3c2410_drv_resume, */
480 .driver = {
481 .owner = THIS_MODULE,
482 .name = "s3c2410-ohci",
483 },
485}; 484};
486 485
487static int __init ohci_hcd_s3c2410_init (void) 486static int __init ohci_hcd_s3c2410_init (void)
488{ 487{
489 return driver_register(&ohci_hcd_s3c2410_driver); 488 return platform_driver_register(&ohci_hcd_s3c2410_driver);
490} 489}
491 490
492static void __exit ohci_hcd_s3c2410_cleanup (void) 491static void __exit ohci_hcd_s3c2410_cleanup (void)
493{ 492{
494 driver_unregister(&ohci_hcd_s3c2410_driver); 493 platform_driver_unregister(&ohci_hcd_s3c2410_driver);
495} 494}
496 495
497module_init (ohci_hcd_s3c2410_init); 496module_init (ohci_hcd_s3c2410_init);
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c
index 5607c0ae6835..a7722a6a5a5b 100644
--- a/drivers/usb/host/sl811-hcd.c
+++ b/drivers/usb/host/sl811-hcd.c
@@ -1631,24 +1631,21 @@ static struct hc_driver sl811h_hc_driver = {
1631/*-------------------------------------------------------------------------*/ 1631/*-------------------------------------------------------------------------*/
1632 1632
1633static int __devexit 1633static int __devexit
1634sl811h_remove(struct device *dev) 1634sl811h_remove(struct platform_device *dev)
1635{ 1635{
1636 struct usb_hcd *hcd = dev_get_drvdata(dev); 1636 struct usb_hcd *hcd = platform_get_drvdata(dev);
1637 struct sl811 *sl811 = hcd_to_sl811(hcd); 1637 struct sl811 *sl811 = hcd_to_sl811(hcd);
1638 struct platform_device *pdev;
1639 struct resource *res; 1638 struct resource *res;
1640 1639
1641 pdev = container_of(dev, struct platform_device, dev);
1642
1643 remove_debug_file(sl811); 1640 remove_debug_file(sl811);
1644 usb_remove_hcd(hcd); 1641 usb_remove_hcd(hcd);
1645 1642
1646 /* some platforms may use IORESOURCE_IO */ 1643 /* some platforms may use IORESOURCE_IO */
1647 res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1644 res = platform_get_resource(dev, IORESOURCE_MEM, 1);
1648 if (res) 1645 if (res)
1649 iounmap(sl811->data_reg); 1646 iounmap(sl811->data_reg);
1650 1647
1651 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1648 res = platform_get_resource(dev, IORESOURCE_MEM, 0);
1652 if (res) 1649 if (res)
1653 iounmap(sl811->addr_reg); 1650 iounmap(sl811->addr_reg);
1654 1651
@@ -1657,11 +1654,10 @@ sl811h_remove(struct device *dev)
1657} 1654}
1658 1655
1659static int __devinit 1656static int __devinit
1660sl811h_probe(struct device *dev) 1657sl811h_probe(struct platform_device *dev)
1661{ 1658{
1662 struct usb_hcd *hcd; 1659 struct usb_hcd *hcd;
1663 struct sl811 *sl811; 1660 struct sl811 *sl811;
1664 struct platform_device *pdev;
1665 struct resource *addr, *data; 1661 struct resource *addr, *data;
1666 int irq; 1662 int irq;
1667 void __iomem *addr_reg; 1663 void __iomem *addr_reg;
@@ -1674,24 +1670,23 @@ sl811h_probe(struct device *dev)
1674 * specific platform_data. we don't probe for IRQs, and do only 1670 * specific platform_data. we don't probe for IRQs, and do only
1675 * minimal sanity checking. 1671 * minimal sanity checking.
1676 */ 1672 */
1677 pdev = container_of(dev, struct platform_device, dev); 1673 irq = platform_get_irq(dev, 0);
1678 irq = platform_get_irq(pdev, 0); 1674 if (dev->num_resources < 3 || irq < 0)
1679 if (pdev->num_resources < 3 || irq < 0)
1680 return -ENODEV; 1675 return -ENODEV;
1681 1676
1682 /* refuse to confuse usbcore */ 1677 /* refuse to confuse usbcore */
1683 if (dev->dma_mask) { 1678 if (dev->dev.dma_mask) {
1684 DBG("no we won't dma\n"); 1679 DBG("no we won't dma\n");
1685 return -EINVAL; 1680 return -EINVAL;
1686 } 1681 }
1687 1682
1688 /* the chip may be wired for either kind of addressing */ 1683 /* the chip may be wired for either kind of addressing */
1689 addr = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1684 addr = platform_get_resource(dev, IORESOURCE_MEM, 0);
1690 data = platform_get_resource(pdev, IORESOURCE_MEM, 1); 1685 data = platform_get_resource(dev, IORESOURCE_MEM, 1);
1691 retval = -EBUSY; 1686 retval = -EBUSY;
1692 if (!addr || !data) { 1687 if (!addr || !data) {
1693 addr = platform_get_resource(pdev, IORESOURCE_IO, 0); 1688 addr = platform_get_resource(dev, IORESOURCE_IO, 0);
1694 data = platform_get_resource(pdev, IORESOURCE_IO, 1); 1689 data = platform_get_resource(dev, IORESOURCE_IO, 1);
1695 if (!addr || !data) 1690 if (!addr || !data)
1696 return -ENODEV; 1691 return -ENODEV;
1697 ioaddr = 1; 1692 ioaddr = 1;
@@ -1713,7 +1708,7 @@ sl811h_probe(struct device *dev)
1713 } 1708 }
1714 1709
1715 /* allocate and initialize hcd */ 1710 /* allocate and initialize hcd */
1716 hcd = usb_create_hcd(&sl811h_hc_driver, dev, dev->bus_id); 1711 hcd = usb_create_hcd(&sl811h_hc_driver, &dev->dev, dev->dev.bus_id);
1717 if (!hcd) { 1712 if (!hcd) {
1718 retval = -ENOMEM; 1713 retval = -ENOMEM;
1719 goto err5; 1714 goto err5;
@@ -1723,7 +1718,7 @@ sl811h_probe(struct device *dev)
1723 1718
1724 spin_lock_init(&sl811->lock); 1719 spin_lock_init(&sl811->lock);
1725 INIT_LIST_HEAD(&sl811->async); 1720 INIT_LIST_HEAD(&sl811->async);
1726 sl811->board = dev->platform_data; 1721 sl811->board = dev->dev.platform_data;
1727 init_timer(&sl811->timer); 1722 init_timer(&sl811->timer);
1728 sl811->timer.function = sl811h_timer; 1723 sl811->timer.function = sl811h_timer;
1729 sl811->timer.data = (unsigned long) sl811; 1724 sl811->timer.data = (unsigned long) sl811;
@@ -1785,9 +1780,9 @@ sl811h_probe(struct device *dev)
1785 */ 1780 */
1786 1781
1787static int 1782static int
1788sl811h_suspend(struct device *dev, pm_message_t state) 1783sl811h_suspend(struct platform_device *dev, pm_message_t state)
1789{ 1784{
1790 struct usb_hcd *hcd = dev_get_drvdata(dev); 1785 struct usb_hcd *hcd = platform_get_drvdata(dev);
1791 struct sl811 *sl811 = hcd_to_sl811(hcd); 1786 struct sl811 *sl811 = hcd_to_sl811(hcd);
1792 int retval = 0; 1787 int retval = 0;
1793 1788
@@ -1796,27 +1791,27 @@ sl811h_suspend(struct device *dev, pm_message_t state)
1796 else if (state.event == PM_EVENT_SUSPEND) 1791 else if (state.event == PM_EVENT_SUSPEND)
1797 port_power(sl811, 0); 1792 port_power(sl811, 0);
1798 if (retval == 0) 1793 if (retval == 0)
1799 dev->power.power_state = state; 1794 dev->dev.power.power_state = state;
1800 return retval; 1795 return retval;
1801} 1796}
1802 1797
1803static int 1798static int
1804sl811h_resume(struct device *dev) 1799sl811h_resume(struct platform_device *dev)
1805{ 1800{
1806 struct usb_hcd *hcd = dev_get_drvdata(dev); 1801 struct usb_hcd *hcd = platform_get_drvdata(dev);
1807 struct sl811 *sl811 = hcd_to_sl811(hcd); 1802 struct sl811 *sl811 = hcd_to_sl811(hcd);
1808 1803
1809 /* with no "check to see if VBUS is still powered" board hook, 1804 /* with no "check to see if VBUS is still powered" board hook,
1810 * let's assume it'd only be powered to enable remote wakeup. 1805 * let's assume it'd only be powered to enable remote wakeup.
1811 */ 1806 */
1812 if (dev->power.power_state.event == PM_EVENT_SUSPEND 1807 if (dev->dev.power.power_state.event == PM_EVENT_SUSPEND
1813 || !hcd->can_wakeup) { 1808 || !hcd->can_wakeup) {
1814 sl811->port1 = 0; 1809 sl811->port1 = 0;
1815 port_power(sl811, 1); 1810 port_power(sl811, 1);
1816 return 0; 1811 return 0;
1817 } 1812 }
1818 1813
1819 dev->power.power_state = PMSG_ON; 1814 dev->dev.power.power_state = PMSG_ON;
1820 return sl811h_bus_resume(hcd); 1815 return sl811h_bus_resume(hcd);
1821} 1816}
1822 1817
@@ -1829,16 +1824,16 @@ sl811h_resume(struct device *dev)
1829 1824
1830 1825
1831/* this driver is exported so sl811_cs can depend on it */ 1826/* this driver is exported so sl811_cs can depend on it */
1832struct device_driver sl811h_driver = { 1827struct platform_driver sl811h_driver = {
1833 .name = (char *) hcd_name,
1834 .bus = &platform_bus_type,
1835 .owner = THIS_MODULE,
1836
1837 .probe = sl811h_probe, 1828 .probe = sl811h_probe,
1838 .remove = __devexit_p(sl811h_remove), 1829 .remove = __devexit_p(sl811h_remove),
1839 1830
1840 .suspend = sl811h_suspend, 1831 .suspend = sl811h_suspend,
1841 .resume = sl811h_resume, 1832 .resume = sl811h_resume,
1833 .driver = {
1834 .name = (char *) hcd_name,
1835 .owner = THIS_MODULE,
1836 },
1842}; 1837};
1843EXPORT_SYMBOL(sl811h_driver); 1838EXPORT_SYMBOL(sl811h_driver);
1844 1839
@@ -1850,12 +1845,12 @@ static int __init sl811h_init(void)
1850 return -ENODEV; 1845 return -ENODEV;
1851 1846
1852 INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION); 1847 INFO("driver %s, %s\n", hcd_name, DRIVER_VERSION);
1853 return driver_register(&sl811h_driver); 1848 return platform_driver_register(&sl811h_driver);
1854} 1849}
1855module_init(sl811h_init); 1850module_init(sl811h_init);
1856 1851
1857static void __exit sl811h_cleanup(void) 1852static void __exit sl811h_cleanup(void)
1858{ 1853{
1859 driver_unregister(&sl811h_driver); 1854 platform_driver_unregister(&sl811h_driver);
1860} 1855}
1861module_exit(sl811h_cleanup); 1856module_exit(sl811h_cleanup);
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index 15e0a511069b..79efaf7d86a3 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -717,6 +717,8 @@ static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message)
717 * at the source, so we must turn off PIRQ. 717 * at the source, so we must turn off PIRQ.
718 */ 718 */
719 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0); 719 pci_write_config_word(to_pci_dev(uhci_dev(uhci)), USBLEGSUP, 0);
720 mb();
721 clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
720 uhci->hc_inaccessible = 1; 722 uhci->hc_inaccessible = 1;
721 hcd->poll_rh = 0; 723 hcd->poll_rh = 0;
722 724
@@ -733,6 +735,12 @@ static int uhci_resume(struct usb_hcd *hcd)
733 735
734 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__); 736 dev_dbg(uhci_dev(uhci), "%s\n", __FUNCTION__);
735 737
738 /* We aren't in D3 state anymore, we do that even if dead as I
739 * really don't want to keep a stale HCD_FLAG_HW_ACCESSIBLE=0
740 */
741 set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
742 mb();
743
736 if (uhci->rh_state == UHCI_RH_RESET) /* Dead */ 744 if (uhci->rh_state == UHCI_RH_RESET) /* Dead */
737 return 0; 745 return 0;
738 spin_lock_irq(&uhci->lock); 746 spin_lock_irq(&uhci->lock);
@@ -831,7 +839,6 @@ MODULE_DEVICE_TABLE(pci, uhci_pci_ids);
831static struct pci_driver uhci_pci_driver = { 839static struct pci_driver uhci_pci_driver = {
832 .name = (char *)hcd_name, 840 .name = (char *)hcd_name,
833 .id_table = uhci_pci_ids, 841 .id_table = uhci_pci_ids,
834 .owner = THIS_MODULE,
835 842
836 .probe = usb_hcd_pci_probe, 843 .probe = usb_hcd_pci_probe,
837 .remove = usb_hcd_pci_remove, 844 .remove = usb_hcd_pci_remove,
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index c89d0769b3da..950543aa5ac7 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -327,6 +327,18 @@ static inline void mts_urb_abort(struct mts_desc* desc) {
327 usb_kill_urb( desc->urb ); 327 usb_kill_urb( desc->urb );
328} 328}
329 329
330static int mts_slave_alloc (struct scsi_device *s)
331{
332 s->inquiry_len = 0x24;
333 return 0;
334}
335
336static int mts_slave_configure (struct scsi_device *s)
337{
338 blk_queue_dma_alignment(s->request_queue, (512 - 1));
339 return 0;
340}
341
330static int mts_scsi_abort (Scsi_Cmnd *srb) 342static int mts_scsi_abort (Scsi_Cmnd *srb)
331{ 343{
332 struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]); 344 struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);
@@ -411,7 +423,7 @@ static void mts_transfer_done( struct urb *transfer, struct pt_regs *regs )
411 MTS_INT_INIT(); 423 MTS_INT_INIT();
412 424
413 context->srb->result &= MTS_SCSI_ERR_MASK; 425 context->srb->result &= MTS_SCSI_ERR_MASK;
414 context->srb->result |= (unsigned)context->status<<1; 426 context->srb->result |= (unsigned)(*context->scsi_status)<<1;
415 427
416 mts_transfer_cleanup(transfer); 428 mts_transfer_cleanup(transfer);
417 429
@@ -427,7 +439,7 @@ static void mts_get_status( struct urb *transfer )
427 mts_int_submit_urb(transfer, 439 mts_int_submit_urb(transfer,
428 usb_rcvbulkpipe(context->instance->usb_dev, 440 usb_rcvbulkpipe(context->instance->usb_dev,
429 context->instance->ep_response), 441 context->instance->ep_response),
430 &context->status, 442 context->scsi_status,
431 1, 443 1,
432 mts_transfer_done ); 444 mts_transfer_done );
433} 445}
@@ -481,7 +493,7 @@ static void mts_command_done( struct urb *transfer, struct pt_regs *regs )
481 context->data_pipe, 493 context->data_pipe,
482 context->data, 494 context->data,
483 context->data_length, 495 context->data_length,
484 context->srb->use_sg ? mts_do_sg : mts_data_done); 496 context->srb->use_sg > 1 ? mts_do_sg : mts_data_done);
485 } else { 497 } else {
486 mts_get_status(transfer); 498 mts_get_status(transfer);
487 } 499 }
@@ -627,12 +639,11 @@ int mts_scsi_queuecommand( Scsi_Cmnd *srb, mts_scsi_cmnd_callback callback )
627 callback(srb); 639 callback(srb);
628 640
629 } 641 }
630
631out: 642out:
632 return err; 643 return err;
633} 644}
634 645
635static Scsi_Host_Template mts_scsi_host_template = { 646static struct scsi_host_template mts_scsi_host_template = {
636 .module = THIS_MODULE, 647 .module = THIS_MODULE,
637 .name = "microtekX6", 648 .name = "microtekX6",
638 .proc_name = "microtekX6", 649 .proc_name = "microtekX6",
@@ -645,6 +656,9 @@ static Scsi_Host_Template mts_scsi_host_template = {
645 .cmd_per_lun = 1, 656 .cmd_per_lun = 1,
646 .use_clustering = 1, 657 .use_clustering = 1,
647 .emulated = 1, 658 .emulated = 1,
659 .slave_alloc = mts_slave_alloc,
660 .slave_configure = mts_slave_configure,
661 .max_sectors= 256, /* 128 K */
648}; 662};
649 663
650struct vendor_product 664struct vendor_product
@@ -771,8 +785,8 @@ static int mts_usb_probe(struct usb_interface *intf,
771 MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" ); 785 MTS_WARNING( "couldn't find an output bulk endpoint. Bailing out.\n" );
772 return -ENODEV; 786 return -ENODEV;
773 } 787 }
774 788
775 789
776 new_desc = kzalloc(sizeof(struct mts_desc), GFP_KERNEL); 790 new_desc = kzalloc(sizeof(struct mts_desc), GFP_KERNEL);
777 if (!new_desc) 791 if (!new_desc)
778 goto out; 792 goto out;
@@ -781,6 +795,10 @@ static int mts_usb_probe(struct usb_interface *intf,
781 if (!new_desc->urb) 795 if (!new_desc->urb)
782 goto out_kfree; 796 goto out_kfree;
783 797
798 new_desc->context.scsi_status = kmalloc(1, GFP_KERNEL);
799 if (!new_desc->context.scsi_status)
800 goto out_kfree2;
801
784 new_desc->usb_dev = dev; 802 new_desc->usb_dev = dev;
785 new_desc->usb_intf = intf; 803 new_desc->usb_intf = intf;
786 init_MUTEX(&new_desc->lock); 804 init_MUTEX(&new_desc->lock);
@@ -817,6 +835,8 @@ static int mts_usb_probe(struct usb_interface *intf,
817 usb_set_intfdata(intf, new_desc); 835 usb_set_intfdata(intf, new_desc);
818 return 0; 836 return 0;
819 837
838 out_kfree2:
839 kfree(new_desc->context.scsi_status);
820 out_free_urb: 840 out_free_urb:
821 usb_free_urb(new_desc->urb); 841 usb_free_urb(new_desc->urb);
822 out_kfree: 842 out_kfree:
@@ -836,6 +856,7 @@ static void mts_usb_disconnect (struct usb_interface *intf)
836 856
837 scsi_host_put(desc->host); 857 scsi_host_put(desc->host);
838 usb_free_urb(desc->urb); 858 usb_free_urb(desc->urb);
859 kfree(desc->context.scsi_status);
839 kfree(desc); 860 kfree(desc);
840} 861}
841 862
@@ -856,5 +877,3 @@ module_exit(microtek_drv_exit);
856MODULE_AUTHOR( DRIVER_AUTHOR ); 877MODULE_AUTHOR( DRIVER_AUTHOR );
857MODULE_DESCRIPTION( DRIVER_DESC ); 878MODULE_DESCRIPTION( DRIVER_DESC );
858MODULE_LICENSE("GPL"); 879MODULE_LICENSE("GPL");
859
860
diff --git a/drivers/usb/image/microtek.h b/drivers/usb/image/microtek.h
index 3271deb8c001..926d4bdc6746 100644
--- a/drivers/usb/image/microtek.h
+++ b/drivers/usb/image/microtek.h
@@ -22,7 +22,7 @@ struct mts_transfer_context
22 int data_pipe; 22 int data_pipe;
23 int fragment; 23 int fragment;
24 24
25 u8 status; /* status returned from ep_response after command completion */ 25 u8 *scsi_status; /* status returned from ep_response after command completion */
26}; 26};
27 27
28 28
diff --git a/drivers/usb/input/Makefile b/drivers/usb/input/Makefile
index 5e03b93f29f6..07cb17db42fc 100644
--- a/drivers/usb/input/Makefile
+++ b/drivers/usb/input/Makefile
@@ -42,3 +42,7 @@ obj-$(CONFIG_USB_ACECAD) += acecad.o
42obj-$(CONFIG_USB_YEALINK) += yealink.o 42obj-$(CONFIG_USB_YEALINK) += yealink.o
43obj-$(CONFIG_USB_XPAD) += xpad.o 43obj-$(CONFIG_USB_XPAD) += xpad.o
44obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o 44obj-$(CONFIG_USB_APPLETOUCH) += appletouch.o
45
46ifeq ($(CONFIG_USB_DEBUG),y)
47EXTRA_CFLAGS += -DDEBUG
48endif
diff --git a/drivers/usb/input/aiptek.c b/drivers/usb/input/aiptek.c
index 1c3b472a3bca..0e2505c073db 100644
--- a/drivers/usb/input/aiptek.c
+++ b/drivers/usb/input/aiptek.c
@@ -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);
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 79ddce4555ab..a3e44ef1df43 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);
@@ -1318,6 +1320,7 @@ void hid_init_reports(struct hid_device *hid)
1318#define USB_DEVICE_ID_WACOM_PTU 0x0003 1320#define USB_DEVICE_ID_WACOM_PTU 0x0003
1319#define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0 1321#define USB_DEVICE_ID_WACOM_INTUOS3 0x00B0
1320#define USB_DEVICE_ID_WACOM_CINTIQ 0x003F 1322#define USB_DEVICE_ID_WACOM_CINTIQ 0x003F
1323#define USB_DEVICE_ID_WACOM_DTF 0x00C0
1321 1324
1322#define USB_VENDOR_ID_ACECAD 0x0460 1325#define USB_VENDOR_ID_ACECAD 0x0460
1323#define USB_DEVICE_ID_ACECAD_FLAIR 0x0004 1326#define USB_DEVICE_ID_ACECAD_FLAIR 0x0004
@@ -1524,6 +1527,9 @@ static struct hid_blacklist {
1524 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 3, HID_QUIRK_IGNORE }, 1527 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 3, HID_QUIRK_IGNORE },
1525 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 4, HID_QUIRK_IGNORE }, 1528 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 4, HID_QUIRK_IGNORE },
1526 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 5, HID_QUIRK_IGNORE }, 1529 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 5, HID_QUIRK_IGNORE },
1530 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 7, HID_QUIRK_IGNORE },
1531 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 8, HID_QUIRK_IGNORE },
1532 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PL + 9, HID_QUIRK_IGNORE },
1527 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 1, HID_QUIRK_IGNORE }, 1533 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 1, HID_QUIRK_IGNORE },
1528 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 2, HID_QUIRK_IGNORE }, 1534 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 2, HID_QUIRK_IGNORE },
1529 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 3, HID_QUIRK_IGNORE }, 1535 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 3, HID_QUIRK_IGNORE },
@@ -1531,11 +1537,19 @@ static struct hid_blacklist {
1531 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 5, HID_QUIRK_IGNORE }, 1537 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 5, HID_QUIRK_IGNORE },
1532 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE }, 1538 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS2 + 7, HID_QUIRK_IGNORE },
1533 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE }, 1539 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO, HID_QUIRK_IGNORE },
1540 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 1, HID_QUIRK_IGNORE },
1541 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 2, HID_QUIRK_IGNORE },
1542 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 3, HID_QUIRK_IGNORE },
1543 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_VOLITO + 4, HID_QUIRK_IGNORE },
1544 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 5, HID_QUIRK_IGNORE },
1545 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_GRAPHIRE + 6, HID_QUIRK_IGNORE },
1534 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE }, 1546 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_PTU, HID_QUIRK_IGNORE },
1535 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3, HID_QUIRK_IGNORE }, 1547 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3, HID_QUIRK_IGNORE },
1536 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 1, HID_QUIRK_IGNORE }, 1548 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 1, HID_QUIRK_IGNORE },
1537 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 2, HID_QUIRK_IGNORE }, 1549 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 2, HID_QUIRK_IGNORE },
1550 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_INTUOS3 + 5, HID_QUIRK_IGNORE },
1538 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_CINTIQ, HID_QUIRK_IGNORE }, 1551 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_CINTIQ, HID_QUIRK_IGNORE },
1552 { USB_VENDOR_ID_WACOM, USB_DEVICE_ID_WACOM_DTF, HID_QUIRK_IGNORE },
1539 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1553 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
1540 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE }, 1554 { USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20, HID_QUIRK_IGNORE },
1541 1555
diff --git a/drivers/usb/input/hid-input.c b/drivers/usb/input/hid-input.c
index 9ff25eb520a6..1220a5004a5c 100644
--- a/drivers/usb/input/hid-input.c
+++ b/drivers/usb/input/hid-input.c
@@ -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/itmtouch.c b/drivers/usb/input/itmtouch.c
index 3b581853cf10..4a50acb39d29 100644
--- a/drivers/usb/input/itmtouch.c
+++ b/drivers/usb/input/itmtouch.c
@@ -40,13 +40,6 @@
40 *****************************************************************************/ 40 *****************************************************************************/
41 41
42#include <linux/config.h> 42#include <linux/config.h>
43
44#ifdef CONFIG_USB_DEBUG
45 #define DEBUG
46#else
47 #undef DEBUG
48#endif
49
50#include <linux/kernel.h> 43#include <linux/kernel.h>
51#include <linux/slab.h> 44#include <linux/slab.h>
52#include <linux/input.h> 45#include <linux/input.h>
diff --git a/drivers/usb/input/kbtab.c b/drivers/usb/input/kbtab.c
index a248664b5d1d..fd48e74e78ed 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;
diff --git a/drivers/usb/input/keyspan_remote.c b/drivers/usb/input/keyspan_remote.c
index 5b8d65f62abf..a32cfe51b77d 100644
--- a/drivers/usb/input/keyspan_remote.c
+++ b/drivers/usb/input/keyspan_remote.c
@@ -160,7 +160,8 @@ static int keyspan_load_tester(struct usb_keyspan* dev, int bits_needed)
160 * though so it's not too big a deal 160 * though so it's not too big a deal
161 */ 161 */
162 if (dev->data.pos >= dev->data.len) { 162 if (dev->data.pos >= dev->data.len) {
163 dev_dbg(&dev->udev, "%s - Error ran out of data. pos: %d, len: %d\n", 163 dev_dbg(&dev->udev->dev,
164 "%s - Error ran out of data. pos: %d, len: %d\n",
164 __FUNCTION__, dev->data.pos, dev->data.len); 165 __FUNCTION__, dev->data.pos, dev->data.len);
165 return -1; 166 return -1;
166 } 167 }
@@ -306,7 +307,7 @@ static void keyspan_check_data(struct usb_keyspan *remote, struct pt_regs *regs)
306 err("Bad message recieved, no stop bit found.\n"); 307 err("Bad message recieved, no stop bit found.\n");
307 } 308 }
308 309
309 dev_dbg(&remote->udev, 310 dev_dbg(&remote->udev->dev,
310 "%s found valid message: system: %d, button: %d, toggle: %d\n", 311 "%s found valid message: system: %d, button: %d, toggle: %d\n",
311 __FUNCTION__, message.system, message.button, message.toggle); 312 __FUNCTION__, message.system, message.button, message.toggle);
312 313
diff --git a/drivers/usb/input/mtouchusb.c b/drivers/usb/input/mtouchusb.c
index 7fce526560ca..52cc18cd247d 100644
--- a/drivers/usb/input/mtouchusb.c
+++ b/drivers/usb/input/mtouchusb.c
@@ -40,13 +40,6 @@
40 *****************************************************************************/ 40 *****************************************************************************/
41 41
42#include <linux/config.h> 42#include <linux/config.h>
43
44#ifdef CONFIG_USB_DEBUG
45 #define DEBUG
46#else
47 #undef DEBUG
48#endif
49
50#include <linux/kernel.h> 43#include <linux/kernel.h>
51#include <linux/slab.h> 44#include <linux/slab.h>
52#include <linux/input.h> 45#include <linux/input.h>
diff --git a/drivers/usb/input/pid.c b/drivers/usb/input/pid.c
index dca5ee93a4ef..19e015d171aa 100644
--- a/drivers/usb/input/pid.c
+++ b/drivers/usb/input/pid.c
@@ -37,8 +37,6 @@
37#include "hid.h" 37#include "hid.h"
38#include "pid.h" 38#include "pid.h"
39 39
40#define DEBUG
41
42#define CHECK_OWNERSHIP(i, hid_pid) \ 40#define CHECK_OWNERSHIP(i, hid_pid) \
43 ((i) < FF_EFFECTS_MAX && i >= 0 && \ 41 ((i) < FF_EFFECTS_MAX && i >= 0 && \
44 test_bit(FF_PID_FLAGS_USED, &hid_pid->effects[(i)].flags) && \ 42 test_bit(FF_PID_FLAGS_USED, &hid_pid->effects[(i)].flags) && \
diff --git a/drivers/usb/input/touchkitusb.c b/drivers/usb/input/touchkitusb.c
index 0043e6ebcd1f..7420c6b84284 100644
--- a/drivers/usb/input/touchkitusb.c
+++ b/drivers/usb/input/touchkitusb.c
@@ -30,10 +30,6 @@
30#include <linux/input.h> 30#include <linux/input.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33
34#if !defined(DEBUG) && defined(CONFIG_USB_DEBUG)
35#define DEBUG
36#endif
37#include <linux/usb.h> 33#include <linux/usb.h>
38#include <linux/usb_input.h> 34#include <linux/usb_input.h>
39 35
diff --git a/drivers/usb/input/wacom.c b/drivers/usb/input/wacom.c
index ea0f75773ae1..dc099bbe12bf 100644
--- a/drivers/usb/input/wacom.c
+++ b/drivers/usb/input/wacom.c
@@ -52,8 +52,10 @@
52 * v1.30.1 (pi) - Added Graphire3 support 52 * v1.30.1 (pi) - Added Graphire3 support
53 * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ... 53 * v1.40 (pc) - Add support for several new devices, fix eraser reporting, ...
54 * v1.43 (pc) - Added support for Cintiq 21UX 54 * v1.43 (pc) - Added support for Cintiq 21UX
55 - Fixed a Graphire bug 55 * - Fixed a Graphire bug
56 - Merged wacom_intuos3_irq into wacom_intuos_irq 56 * - Merged wacom_intuos3_irq into wacom_intuos_irq
57 * v1.44 (pc) - Added support for Graphire4, Cintiq 710, Intuos3 6x11, etc.
58 * - Report Device IDs
57 */ 59 */
58 60
59/* 61/*
@@ -76,7 +78,7 @@
76/* 78/*
77 * Version Information 79 * Version Information
78 */ 80 */
79#define DRIVER_VERSION "v1.43" 81#define DRIVER_VERSION "v1.44"
80#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>" 82#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@ucw.cz>"
81#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver" 83#define DRIVER_DESC "USB Wacom Graphire and Wacom Intuos tablet driver"
82#define DRIVER_LICENSE "GPL" 84#define DRIVER_LICENSE "GPL"
@@ -86,10 +88,14 @@ MODULE_DESCRIPTION(DRIVER_DESC);
86MODULE_LICENSE(DRIVER_LICENSE); 88MODULE_LICENSE(DRIVER_LICENSE);
87 89
88#define USB_VENDOR_ID_WACOM 0x056a 90#define USB_VENDOR_ID_WACOM 0x056a
91#define STYLUS_DEVICE_ID 0x02
92#define CURSOR_DEVICE_ID 0x06
93#define ERASER_DEVICE_ID 0x0A
89 94
90enum { 95enum {
91 PENPARTNER = 0, 96 PENPARTNER = 0,
92 GRAPHIRE, 97 GRAPHIRE,
98 G4,
93 PL, 99 PL,
94 INTUOS, 100 INTUOS,
95 INTUOS3, 101 INTUOS3,
@@ -116,6 +122,7 @@ struct wacom {
116 struct urb *irq; 122 struct urb *irq;
117 struct wacom_features *features; 123 struct wacom_features *features;
118 int tool[2]; 124 int tool[2];
125 int id[2];
119 __u32 serial[2]; 126 __u32 serial[2];
120 char phys[32]; 127 char phys[32];
121}; 128};
@@ -136,7 +143,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
136 struct wacom *wacom = urb->context; 143 struct wacom *wacom = urb->context;
137 unsigned char *data = wacom->data; 144 unsigned char *data = wacom->data;
138 struct input_dev *dev = wacom->dev; 145 struct input_dev *dev = wacom->dev;
139 int prox, pressure; 146 int prox, pressure, id;
140 int retval; 147 int retval;
141 148
142 switch (urb->status) { 149 switch (urb->status) {
@@ -163,6 +170,7 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
163 170
164 input_regs(dev, regs); 171 input_regs(dev, regs);
165 172
173 id = ERASER_DEVICE_ID;
166 if (prox) { 174 if (prox) {
167 175
168 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1)); 176 pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
@@ -177,11 +185,15 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
177 * an out of proximity for previous tool then a in for new tool. 185 * an out of proximity for previous tool then a in for new tool.
178 */ 186 */
179 if (!wacom->tool[0]) { 187 if (!wacom->tool[0]) {
180 /* Going into proximity select tool */ 188 /* Eraser bit set for DTF */
181 wacom->tool[1] = (data[4] & 0x20)? BTN_TOOL_RUBBER : BTN_TOOL_PEN; 189 if (data[1] & 0x10)
190 wacom->tool[1] = BTN_TOOL_RUBBER;
191 else
192 /* Going into proximity select tool */
193 wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
182 } else { 194 } else {
183 /* was entered with stylus2 pressed */ 195 /* was entered with stylus2 pressed */
184 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20) ) { 196 if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
185 /* report out proximity for previous tool */ 197 /* report out proximity for previous tool */
186 input_report_key(dev, wacom->tool[1], 0); 198 input_report_key(dev, wacom->tool[1], 0);
187 input_sync(dev); 199 input_sync(dev);
@@ -192,8 +204,9 @@ static void wacom_pl_irq(struct urb *urb, struct pt_regs *regs)
192 if (wacom->tool[1] != BTN_TOOL_RUBBER) { 204 if (wacom->tool[1] != BTN_TOOL_RUBBER) {
193 /* Unknown tool selected default to pen tool */ 205 /* Unknown tool selected default to pen tool */
194 wacom->tool[1] = BTN_TOOL_PEN; 206 wacom->tool[1] = BTN_TOOL_PEN;
207 id = STYLUS_DEVICE_ID;
195 } 208 }
196 input_report_key(dev, wacom->tool[1], prox); /* report in proximity for tool */ 209 input_report_key(dev, wacom->tool[1], id); /* report in proximity for tool */
197 input_report_abs(dev, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14)); 210 input_report_abs(dev, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
198 input_report_abs(dev, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14)); 211 input_report_abs(dev, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
199 input_report_abs(dev, ABS_PRESSURE, pressure); 212 input_report_abs(dev, ABS_PRESSURE, pressure);
@@ -250,10 +263,10 @@ static void wacom_ptu_irq(struct urb *urb, struct pt_regs *regs)
250 263
251 input_regs(dev, regs); 264 input_regs(dev, regs);
252 if (data[1] & 0x04) { 265 if (data[1] & 0x04) {
253 input_report_key(dev, BTN_TOOL_RUBBER, data[1] & 0x20); 266 input_report_key(dev, BTN_TOOL_RUBBER, (data[1] & 0x20) ? ERASER_DEVICE_ID : 0);
254 input_report_key(dev, BTN_TOUCH, data[1] & 0x08); 267 input_report_key(dev, BTN_TOUCH, data[1] & 0x08);
255 } else { 268 } else {
256 input_report_key(dev, BTN_TOOL_PEN, data[1] & 0x20); 269 input_report_key(dev, BTN_TOOL_PEN, (data[1] & 0x20) ? STYLUS_DEVICE_ID : 0);
257 input_report_key(dev, BTN_TOUCH, data[1] & 0x01); 270 input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
258 } 271 }
259 input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[2])); 272 input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[2]));
@@ -299,7 +312,7 @@ static void wacom_penpartner_irq(struct urb *urb, struct pt_regs *regs)
299 } 312 }
300 313
301 input_regs(dev, regs); 314 input_regs(dev, regs);
302 input_report_key(dev, BTN_TOOL_PEN, 1); 315 input_report_key(dev, BTN_TOOL_PEN, STYLUS_DEVICE_ID);
303 input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[1])); 316 input_report_abs(dev, ABS_X, le16_to_cpu(*(__le16 *) &data[1]));
304 input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[3])); 317 input_report_abs(dev, ABS_Y, le16_to_cpu(*(__le16 *) &data[3]));
305 input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127); 318 input_report_abs(dev, ABS_PRESSURE, (signed char)data[6] + 127);
@@ -319,7 +332,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
319 struct wacom *wacom = urb->context; 332 struct wacom *wacom = urb->context;
320 unsigned char *data = wacom->data; 333 unsigned char *data = wacom->data;
321 struct input_dev *dev = wacom->dev; 334 struct input_dev *dev = wacom->dev;
322 int x, y; 335 int x, y, id, rw;
323 int retval; 336 int retval;
324 337
325 switch (urb->status) { 338 switch (urb->status) {
@@ -344,6 +357,7 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
344 357
345 input_regs(dev, regs); 358 input_regs(dev, regs);
346 359
360 id = STYLUS_DEVICE_ID;
347 if (data[1] & 0x10) { /* in prox */ 361 if (data[1] & 0x10) { /* in prox */
348 362
349 switch ((data[1] >> 5) & 3) { 363 switch ((data[1] >> 5) & 3) {
@@ -354,18 +368,27 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
354 368
355 case 1: /* Rubber */ 369 case 1: /* Rubber */
356 wacom->tool[0] = BTN_TOOL_RUBBER; 370 wacom->tool[0] = BTN_TOOL_RUBBER;
371 id = ERASER_DEVICE_ID;
357 break; 372 break;
358 373
359 case 2: /* Mouse with wheel */ 374 case 2: /* Mouse with wheel */
360 input_report_key(dev, BTN_MIDDLE, data[1] & 0x04); 375 input_report_key(dev, BTN_MIDDLE, data[1] & 0x04);
361 input_report_rel(dev, REL_WHEEL, (signed char) data[6]); 376 if (wacom->features->type == G4) {
377 rw = data[7] & 0x04 ? -(data[7] & 0x03) : (data[7] & 0x03);
378 input_report_rel(dev, REL_WHEEL, rw);
379 } else
380 input_report_rel(dev, REL_WHEEL, (signed char) data[6]);
362 /* fall through */ 381 /* fall through */
363 382
364 case 3: /* Mouse without wheel */ 383 case 3: /* Mouse without wheel */
365 wacom->tool[0] = BTN_TOOL_MOUSE; 384 wacom->tool[0] = BTN_TOOL_MOUSE;
385 id = CURSOR_DEVICE_ID;
366 input_report_key(dev, BTN_LEFT, data[1] & 0x01); 386 input_report_key(dev, BTN_LEFT, data[1] & 0x01);
367 input_report_key(dev, BTN_RIGHT, data[1] & 0x02); 387 input_report_key(dev, BTN_RIGHT, data[1] & 0x02);
368 input_report_abs(dev, ABS_DISTANCE, data[7]); 388 if (wacom->features->type == G4)
389 input_report_abs(dev, ABS_DISTANCE, data[6]);
390 else
391 input_report_abs(dev, ABS_DISTANCE, data[7]);
369 break; 392 break;
370 } 393 }
371 } 394 }
@@ -376,16 +399,50 @@ static void wacom_graphire_irq(struct urb *urb, struct pt_regs *regs)
376 input_report_abs(dev, ABS_X, x); 399 input_report_abs(dev, ABS_X, x);
377 input_report_abs(dev, ABS_Y, y); 400 input_report_abs(dev, ABS_Y, y);
378 if (wacom->tool[0] != BTN_TOOL_MOUSE) { 401 if (wacom->tool[0] != BTN_TOOL_MOUSE) {
379 input_report_abs(dev, ABS_PRESSURE, le16_to_cpu(*(__le16 *) &data[6])); 402 input_report_abs(dev, ABS_PRESSURE, data[6] | ((data[7] & 0x01) << 8));
380 input_report_key(dev, BTN_TOUCH, data[1] & 0x01); 403 input_report_key(dev, BTN_TOUCH, data[1] & 0x01);
381 input_report_key(dev, BTN_STYLUS, data[1] & 0x02); 404 input_report_key(dev, BTN_STYLUS, data[1] & 0x02);
382 input_report_key(dev, BTN_STYLUS2, data[1] & 0x04); 405 input_report_key(dev, BTN_STYLUS2, data[1] & 0x04);
383 } 406 }
384 } 407 }
385 408
386 input_report_key(dev, wacom->tool[0], data[1] & 0x10); 409 input_report_key(dev, wacom->tool[0], (data[1] & 0x10) ? id : 0);
387 input_sync(dev); 410 input_sync(dev);
388 411
412 /* send pad data */
413 if (wacom->features->type == G4) {
414 /* fist time sending pad data */
415 if (wacom->tool[1] != BTN_TOOL_FINGER) {
416 wacom->id[1] = 0;
417 wacom->serial[1] = (data[7] & 0x38) >> 2;
418 }
419 if (data[7] & 0xf8) {
420 input_report_key(dev, BTN_0, (data[7] & 0x40));
421 input_report_key(dev, BTN_4, (data[7] & 0x80));
422 if (((data[7] & 0x38) >> 2) == (wacom->serial[1] & 0x0e))
423 /* alter REL_WHEEL value so X apps can get it */
424 wacom->serial[1] += (wacom->serial[1] & 0x01) ? -1 : 1;
425 else
426 wacom->serial[1] = (data[7] & 0x38 ) >> 2;
427
428 /* don't alter the value when there is no wheel event */
429 if (wacom->serial[1] == 1)
430 wacom->serial[1] = 0;
431 rw = wacom->serial[1];
432 rw = (rw & 0x08) ? -(rw & 0x07) : (rw & 0x07);
433 input_report_rel(dev, REL_WHEEL, rw);
434 wacom->tool[1] = BTN_TOOL_FINGER;
435 wacom->id[1] = data[7] & 0xf8;
436 input_report_key(dev, wacom->tool[1], 0xf0);
437 input_event(dev, EV_MSC, MSC_SERIAL, 0xf0);
438 } else if (wacom->id[1]) {
439 wacom->id[1] = 0;
440 wacom->serial[1] = 0;
441 input_report_key(dev, wacom->tool[1], 0);
442 input_event(dev, EV_MSC, MSC_SERIAL, 0xf0);
443 }
444 input_sync(dev);
445 }
389 exit: 446 exit:
390 retval = usb_submit_urb (urb, GFP_ATOMIC); 447 retval = usb_submit_urb (urb, GFP_ATOMIC);
391 if (retval) 448 if (retval)
@@ -410,7 +467,8 @@ static int wacom_intuos_inout(struct urb *urb)
410 (data[4] << 20) + (data[5] << 12) + 467 (data[4] << 20) + (data[5] << 12) +
411 (data[6] << 4) + (data[7] >> 4); 468 (data[6] << 4) + (data[7] >> 4);
412 469
413 switch ((data[2] << 4) | (data[3] >> 4)) { 470 wacom->id[idx] = (data[2] << 4) | (data[3] >> 4);
471 switch (wacom->id[idx]) {
414 case 0x812: /* Inking pen */ 472 case 0x812: /* Inking pen */
415 case 0x801: /* Intuos3 Inking pen */ 473 case 0x801: /* Intuos3 Inking pen */
416 case 0x012: 474 case 0x012:
@@ -458,7 +516,7 @@ static int wacom_intuos_inout(struct urb *urb)
458 default: /* Unknown tool */ 516 default: /* Unknown tool */
459 wacom->tool[idx] = BTN_TOOL_PEN; 517 wacom->tool[idx] = BTN_TOOL_PEN;
460 } 518 }
461 input_report_key(dev, wacom->tool[idx], 1); 519 input_report_key(dev, wacom->tool[idx], wacom->id[idx]);
462 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 520 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
463 input_sync(dev); 521 input_sync(dev);
464 return 1; 522 return 1;
@@ -637,7 +695,7 @@ static void wacom_intuos_irq(struct urb *urb, struct pt_regs *regs)
637 } 695 }
638 } 696 }
639 697
640 input_report_key(dev, wacom->tool[idx], 1); 698 input_report_key(dev, wacom->tool[idx], wacom->id[idx]);
641 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]); 699 input_event(dev, EV_MSC, MSC_SERIAL, wacom->serial[idx]);
642 input_sync(dev); 700 input_sync(dev);
643 701
@@ -655,6 +713,13 @@ static struct wacom_features wacom_features[] = {
655 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_graphire_irq }, 713 { "Wacom Graphire2 5x7", 8, 13918, 10206, 511, 32, GRAPHIRE, wacom_graphire_irq },
656 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_graphire_irq }, 714 { "Wacom Graphire3", 8, 10208, 7424, 511, 32, GRAPHIRE, wacom_graphire_irq },
657 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_graphire_irq }, 715 { "Wacom Graphire3 6x8", 8, 16704, 12064, 511, 32, GRAPHIRE, wacom_graphire_irq },
716 { "Wacom Graphire4 4x5", 8, 10208, 7424, 511, 32, G4, wacom_graphire_irq },
717 { "Wacom Graphire4 6x8", 8, 16704, 12064, 511, 32, G4, wacom_graphire_irq },
718 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq },
719 { "Wacom PenStation2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_graphire_irq },
720 { "Wacom Volito2 4x5", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq },
721 { "Wacom Volito2 2x3", 8, 3248, 2320, 511, 32, GRAPHIRE, wacom_graphire_irq },
722 { "Wacom PenPartner2", 8, 3250, 2320, 255, 32, GRAPHIRE, wacom_graphire_irq },
658 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, 723 { "Wacom Intuos 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq },
659 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, 724 { "Wacom Intuos 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq },
660 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, 725 { "Wacom Intuos 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq },
@@ -666,16 +731,20 @@ static struct wacom_features wacom_features[] = {
666 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_pl_irq }, 731 { "Wacom PL600SX", 8, 6260, 5016, 255, 32, PL, wacom_pl_irq },
667 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_pl_irq }, 732 { "Wacom PL550", 8, 6144, 4608, 511, 32, PL, wacom_pl_irq },
668 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_pl_irq }, 733 { "Wacom PL800", 8, 7220, 5780, 511, 32, PL, wacom_pl_irq },
734 { "Wacom PL700", 8, 6758, 5406, 511, 32, PL, wacom_pl_irq },
735 { "Wacom PL510", 8, 6282, 4762, 511, 32, PL, wacom_pl_irq },
736 { "Wacom PL710", 8, 34080, 27660, 511, 32, PL, wacom_pl_irq },
737 { "Wacom DTF720", 8, 6858, 5506, 511, 32, PL, wacom_pl_irq },
738 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL, wacom_ptu_irq },
669 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq }, 739 { "Wacom Intuos2 4x5", 10, 12700, 10600, 1023, 15, INTUOS, wacom_intuos_irq },
670 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, 740 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq },
671 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq }, 741 { "Wacom Intuos2 9x12", 10, 30480, 24060, 1023, 15, INTUOS, wacom_intuos_irq },
672 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, 742 { "Wacom Intuos2 12x12", 10, 30480, 31680, 1023, 15, INTUOS, wacom_intuos_irq },
673 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq }, 743 { "Wacom Intuos2 12x18", 10, 45720, 31680, 1023, 15, INTUOS, wacom_intuos_irq },
674 { "Wacom Volito", 8, 5104, 3712, 511, 32, GRAPHIRE, wacom_graphire_irq },
675 { "Wacom Cintiq Partner",8, 20480, 15360, 511, 32, PL, wacom_ptu_irq },
676 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_intuos_irq }, 744 { "Wacom Intuos3 4x5", 10, 25400, 20320, 1023, 15, INTUOS3, wacom_intuos_irq },
677 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_intuos_irq }, 745 { "Wacom Intuos3 6x8", 10, 40640, 30480, 1023, 15, INTUOS3, wacom_intuos_irq },
678 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_intuos_irq }, 746 { "Wacom Intuos3 9x12", 10, 60960, 45720, 1023, 15, INTUOS3, wacom_intuos_irq },
747 { "Wacom Intuos3 6x11", 10, 54204, 31750, 1023, 15, INTUOS3, wacom_intuos_irq },
679 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_intuos_irq }, 748 { "Wacom Cintiq 21UX", 10, 87200, 65600, 1023, 15, CINTIQ, wacom_intuos_irq },
680 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq }, 749 { "Wacom Intuos2 6x8", 10, 20320, 16240, 1023, 15, INTUOS, wacom_intuos_irq },
681 { } 750 { }
@@ -688,6 +757,13 @@ static struct usb_device_id wacom_ids[] = {
688 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) }, 757 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x12) },
689 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) }, 758 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x13) },
690 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) }, 759 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x14) },
760 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x15) },
761 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x16) },
762 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
763 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x61) },
764 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x62) },
765 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x63) },
766 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x64) },
691 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) }, 767 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x20) },
692 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) }, 768 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x21) },
693 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) }, 769 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x22) },
@@ -699,16 +775,20 @@ static struct usb_device_id wacom_ids[] = {
699 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) }, 775 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x33) },
700 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) }, 776 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x34) },
701 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) }, 777 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x35) },
778 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x37) },
779 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x38) },
780 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x39) },
781 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xC0) },
782 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
702 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) }, 783 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x41) },
703 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) }, 784 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x42) },
704 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) }, 785 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x43) },
705 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) }, 786 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x44) },
706 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) }, 787 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x45) },
707 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x60) },
708 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x03) },
709 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) }, 788 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB0) },
710 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) }, 789 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB1) },
711 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) }, 790 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB2) },
791 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0xB5) },
712 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) }, 792 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x3F) },
713 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) }, 793 { USB_DEVICE(USB_VENDOR_ID_WACOM, 0x47) },
714 { } 794 { }
@@ -774,11 +854,18 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
774 854
775 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS); 855 input_dev->evbit[0] |= BIT(EV_KEY) | BIT(EV_ABS);
776 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS); 856 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_PEN) | BIT(BTN_TOUCH) | BIT(BTN_STYLUS);
777 input_set_abs_params(input_dev, ABS_X, 0, wacom->features->y_max, 4, 0); 857 input_set_abs_params(input_dev, ABS_X, 0, wacom->features->x_max, 4, 0);
778 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);
779 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);
780 860
781 switch (wacom->features->type) { 861 switch (wacom->features->type) {
862 case G4:
863 input_dev->evbit[0] |= BIT(EV_MSC);
864 input_dev->mscbit[0] |= BIT(MSC_SERIAL);
865 input_dev->keybit[LONG(BTN_DIGI)] |= BIT(BTN_TOOL_FINGER);
866 input_dev->keybit[LONG(BTN_LEFT)] |= BIT(BTN_0) | BIT(BTN_1) | BIT(BTN_2) | BIT(BTN_3) | BIT(BTN_4) | BIT(BTN_5) | BIT(BTN_6) | BIT(BTN_7);
867 /* fall through */
868
782 case GRAPHIRE: 869 case GRAPHIRE:
783 input_dev->evbit[0] |= BIT(EV_REL); 870 input_dev->evbit[0] |= BIT(EV_REL);
784 input_dev->relbit[0] |= BIT(REL_WHEEL); 871 input_dev->relbit[0] |= BIT(REL_WHEEL);
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c
index cf8cfbabefde..b2e66e3b90aa 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/usb/media/sn9c102_core.c
@@ -199,7 +199,7 @@ static void sn9c102_release_buffers(struct sn9c102_device* cam)
199{ 199{
200 if (cam->nbuffers) { 200 if (cam->nbuffers) {
201 rvfree(cam->frame[0].bufmem, 201 rvfree(cam->frame[0].bufmem,
202 cam->nbuffers * cam->frame[0].buf.length); 202 cam->nbuffers * PAGE_ALIGN(cam->frame[0].buf.length));
203 cam->nbuffers = 0; 203 cam->nbuffers = 0;
204 } 204 }
205} 205}
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 862e40a83689..6c693bc68e2e 100644
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -18,4 +18,8 @@ obj-$(CONFIG_USB_RIO500) += rio500.o
18obj-$(CONFIG_USB_TEST) += usbtest.o 18obj-$(CONFIG_USB_TEST) += usbtest.o
19obj-$(CONFIG_USB_USS720) += uss720.o 19obj-$(CONFIG_USB_USS720) += uss720.o
20 20
21obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/ \ No newline at end of file 21obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
22
23ifeq ($(CONFIG_USB_DEBUG),y)
24EXTRA_CFLAGS += -DDEBUG
25endif
diff --git a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c
index 5f33f7c64885..b293db3c28c3 100644
--- a/drivers/usb/misc/auerswald.c
+++ b/drivers/usb/misc/auerswald.c
@@ -30,7 +30,6 @@
30#include <linux/module.h> 30#include <linux/module.h>
31#include <linux/init.h> 31#include <linux/init.h>
32#include <linux/wait.h> 32#include <linux/wait.h>
33#undef DEBUG /* include debug macros until it's done */
34#include <linux/usb.h> 33#include <linux/usb.h>
35 34
36/*-------------------------------------------------------------------*/ 35/*-------------------------------------------------------------------*/
@@ -1697,7 +1696,7 @@ static ssize_t auerchar_write (struct file *file, const char __user *buf, size_t
1697 int ret; 1696 int ret;
1698 wait_queue_t wait; 1697 wait_queue_t wait;
1699 1698
1700 dbg ("auerchar_write %d bytes", len); 1699 dbg ("auerchar_write %zd bytes", len);
1701 1700
1702 /* Error checking */ 1701 /* Error checking */
1703 if (!ccp) 1702 if (!ccp)
diff --git a/drivers/usb/misc/phidgetservo.c b/drivers/usb/misc/phidgetservo.c
index b84eda631ab5..a30d4a6ee824 100644
--- a/drivers/usb/misc/phidgetservo.c
+++ b/drivers/usb/misc/phidgetservo.c
@@ -26,9 +26,6 @@
26 */ 26 */
27 27
28#include <linux/config.h> 28#include <linux/config.h>
29#ifdef CONFIG_USB_DEBUG
30#define DEBUG 1
31#endif
32#include <linux/kernel.h> 29#include <linux/kernel.h>
33#include <linux/errno.h> 30#include <linux/errno.h>
34#include <linux/init.h> 31#include <linux/init.h>
diff --git a/drivers/usb/misc/rio500.c b/drivers/usb/misc/rio500.c
index 7d02d8ec6b1a..9590dbac5d9a 100644
--- a/drivers/usb/misc/rio500.c
+++ b/drivers/usb/misc/rio500.c
@@ -393,7 +393,7 @@ read_rio(struct file *file, char __user *buffer, size_t count, loff_t * ppos)
393 ibuf, this_read, &partial, 393 ibuf, this_read, &partial,
394 8000); 394 8000);
395 395
396 dbg(KERN_DEBUG "read stats: result:%d this_read:%u partial:%u", 396 dbg("read stats: result:%d this_read:%u partial:%u",
397 result, this_read, partial); 397 result, this_read, partial);
398 398
399 if (partial) { 399 if (partial) {
diff --git a/drivers/usb/misc/usbled.c b/drivers/usb/misc/usbled.c
index f6ba4c788dbc..3c93921cb6b3 100644
--- a/drivers/usb/misc/usbled.c
+++ b/drivers/usb/misc/usbled.c
@@ -10,9 +10,6 @@
10 */ 10 */
11 11
12#include <linux/config.h> 12#include <linux/config.h>
13#ifdef CONFIG_USB_DEBUG
14 #define DEBUG 1
15#endif
16#include <linux/kernel.h> 13#include <linux/kernel.h>
17#include <linux/errno.h> 14#include <linux/errno.h>
18#include <linux/init.h> 15#include <linux/init.h>
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 2997f558159b..605a2afe34ed 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -1,7 +1,4 @@
1#include <linux/config.h> 1#include <linux/config.h>
2#if !defined (DEBUG) && defined (CONFIG_USB_DEBUG)
3# define DEBUG
4#endif
5#include <linux/kernel.h> 2#include <linux/kernel.h>
6#include <linux/errno.h> 3#include <linux/errno.h>
7#include <linux/init.h> 4#include <linux/init.h>
diff --git a/drivers/usb/misc/uss720.c b/drivers/usb/misc/uss720.c
index 0592cb5e6c4d..1cabe7ed91f5 100644
--- a/drivers/usb/misc/uss720.c
+++ b/drivers/usb/misc/uss720.c
@@ -41,8 +41,6 @@
41 41
42/*****************************************************************************/ 42/*****************************************************************************/
43 43
44#define DEBUG
45
46#include <linux/module.h> 44#include <linux/module.h>
47#include <linux/socket.h> 45#include <linux/socket.h>
48#include <linux/parport.h> 46#include <linux/parport.h>
diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile
index 222c0495f791..a21e6eaabaf6 100644
--- a/drivers/usb/net/Makefile
+++ b/drivers/usb/net/Makefile
@@ -16,3 +16,7 @@ obj-$(CONFIG_USB_NET_CDC_SUBSET) += cdc_subset.o
16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o 16obj-$(CONFIG_USB_NET_ZAURUS) += zaurus.o
17obj-$(CONFIG_USB_USBNET) += usbnet.o 17obj-$(CONFIG_USB_USBNET) += usbnet.o
18obj-$(CONFIG_USB_ZD1201) += zd1201.o 18obj-$(CONFIG_USB_ZD1201) += zd1201.o
19
20ifeq ($(CONFIG_USB_DEBUG),y)
21EXTRA_CFLAGS += -DDEBUG
22endif
diff --git a/drivers/usb/net/asix.c b/drivers/usb/net/asix.c
index 252a34fbb42c..542120ef1fd2 100644
--- a/drivers/usb/net/asix.c
+++ b/drivers/usb/net/asix.c
@@ -23,9 +23,6 @@
23// #define VERBOSE // more; success messages 23// #define VERBOSE // more; success messages
24 24
25#include <linux/config.h> 25#include <linux/config.h>
26#ifdef CONFIG_USB_DEBUG
27# define DEBUG
28#endif
29#include <linux/module.h> 26#include <linux/module.h>
30#include <linux/kmod.h> 27#include <linux/kmod.h>
31#include <linux/sched.h> 28#include <linux/sched.h>
diff --git a/drivers/usb/net/cdc_ether.c b/drivers/usb/net/cdc_ether.c
index 652b04bbf6af..c008c981862b 100644
--- a/drivers/usb/net/cdc_ether.c
+++ b/drivers/usb/net/cdc_ether.c
@@ -21,9 +21,6 @@
21// #define VERBOSE // more; success messages 21// #define VERBOSE // more; success messages
22 22
23#include <linux/config.h> 23#include <linux/config.h>
24#ifdef CONFIG_USB_DEBUG
25# define DEBUG
26#endif
27#include <linux/module.h> 24#include <linux/module.h>
28#include <linux/sched.h> 25#include <linux/sched.h>
29#include <linux/init.h> 26#include <linux/init.h>
diff --git a/drivers/usb/net/cdc_subset.c b/drivers/usb/net/cdc_subset.c
index f1730b685fd2..f05cfb83c82d 100644
--- a/drivers/usb/net/cdc_subset.c
+++ b/drivers/usb/net/cdc_subset.c
@@ -18,9 +18,6 @@
18 */ 18 */
19 19
20#include <linux/config.h> 20#include <linux/config.h>
21#ifdef CONFIG_USB_DEBUG
22# define DEBUG
23#endif
24#include <linux/module.h> 21#include <linux/module.h>
25#include <linux/kmod.h> 22#include <linux/kmod.h>
26#include <linux/sched.h> 23#include <linux/sched.h>
diff --git a/drivers/usb/net/gl620a.c b/drivers/usb/net/gl620a.c
index c0f263b202a6..2455e9a85674 100644
--- a/drivers/usb/net/gl620a.c
+++ b/drivers/usb/net/gl620a.c
@@ -22,9 +22,6 @@
22// #define VERBOSE // more; success messages 22// #define VERBOSE // more; success messages
23 23
24#include <linux/config.h> 24#include <linux/config.h>
25#ifdef CONFIG_USB_DEBUG
26# define DEBUG
27#endif
28#include <linux/module.h> 25#include <linux/module.h>
29#include <linux/sched.h> 26#include <linux/sched.h>
30#include <linux/init.h> 27#include <linux/init.h>
diff --git a/drivers/usb/net/kaweth.c b/drivers/usb/net/kaweth.c
index 6bef1be6b36c..b5776518020f 100644
--- a/drivers/usb/net/kaweth.c
+++ b/drivers/usb/net/kaweth.c
@@ -219,7 +219,6 @@ struct kaweth_device
219 219
220 __u32 status; 220 __u32 status;
221 int end; 221 int end;
222 int removed;
223 int suspend_lowmem_rx; 222 int suspend_lowmem_rx;
224 int suspend_lowmem_ctrl; 223 int suspend_lowmem_ctrl;
225 int linkstate; 224 int linkstate;
@@ -699,6 +698,7 @@ static int kaweth_close(struct net_device *net)
699 698
700 usb_kill_urb(kaweth->irq_urb); 699 usb_kill_urb(kaweth->irq_urb);
701 usb_kill_urb(kaweth->rx_urb); 700 usb_kill_urb(kaweth->rx_urb);
701 usb_kill_urb(kaweth->tx_urb);
702 702
703 flush_scheduled_work(); 703 flush_scheduled_work();
704 704
@@ -750,13 +750,6 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net)
750 750
751 spin_lock(&kaweth->device_lock); 751 spin_lock(&kaweth->device_lock);
752 752
753 if (kaweth->removed) {
754 /* our device is undergoing disconnection - we bail out */
755 spin_unlock(&kaweth->device_lock);
756 dev_kfree_skb_irq(skb);
757 return 0;
758 }
759
760 kaweth_async_set_rx_mode(kaweth); 753 kaweth_async_set_rx_mode(kaweth);
761 netif_stop_queue(net); 754 netif_stop_queue(net);
762 755
@@ -1136,10 +1129,6 @@ static void kaweth_disconnect(struct usb_interface *intf)
1136 return; 1129 return;
1137 } 1130 }
1138 netdev = kaweth->net; 1131 netdev = kaweth->net;
1139 kaweth->removed = 1;
1140 usb_kill_urb(kaweth->irq_urb);
1141 usb_kill_urb(kaweth->rx_urb);
1142 usb_kill_urb(kaweth->tx_urb);
1143 1132
1144 kaweth_dbg("Unregistering net device"); 1133 kaweth_dbg("Unregistering net device");
1145 unregister_netdev(netdev); 1134 unregister_netdev(netdev);
diff --git a/drivers/usb/net/net1080.c b/drivers/usb/net/net1080.c
index cee55f8cf64f..b3799b1a2b0d 100644
--- a/drivers/usb/net/net1080.c
+++ b/drivers/usb/net/net1080.c
@@ -21,9 +21,6 @@
21// #define VERBOSE // more; success messages 21// #define VERBOSE // more; success messages
22 22
23#include <linux/config.h> 23#include <linux/config.h>
24#ifdef CONFIG_USB_DEBUG
25# define DEBUG
26#endif
27#include <linux/module.h> 24#include <linux/module.h>
28#include <linux/sched.h> 25#include <linux/sched.h>
29#include <linux/init.h> 26#include <linux/init.h>
diff --git a/drivers/usb/net/pegasus.c b/drivers/usb/net/pegasus.c
index 537eb181d985..683e3df5d607 100644
--- a/drivers/usb/net/pegasus.c
+++ b/drivers/usb/net/pegasus.c
@@ -28,8 +28,6 @@
28 * is out of the interrupt routine. 28 * is out of the interrupt routine.
29 */ 29 */
30 30
31#undef DEBUG
32
33#include <linux/sched.h> 31#include <linux/sched.h>
34#include <linux/slab.h> 32#include <linux/slab.h>
35#include <linux/init.h> 33#include <linux/init.h>
diff --git a/drivers/usb/net/plusb.c b/drivers/usb/net/plusb.c
index 74c2b3581c76..89856aa0e3b8 100644
--- a/drivers/usb/net/plusb.c
+++ b/drivers/usb/net/plusb.c
@@ -21,9 +21,6 @@
21// #define VERBOSE // more; success messages 21// #define VERBOSE // more; success messages
22 22
23#include <linux/config.h> 23#include <linux/config.h>
24#ifdef CONFIG_USB_DEBUG
25# define DEBUG
26#endif
27#include <linux/module.h> 24#include <linux/module.h>
28#include <linux/sched.h> 25#include <linux/sched.h>
29#include <linux/init.h> 26#include <linux/init.h>
diff --git a/drivers/usb/net/rndis_host.c b/drivers/usb/net/rndis_host.c
index b5a925dc1beb..c0ecbab6f6ba 100644
--- a/drivers/usb/net/rndis_host.c
+++ b/drivers/usb/net/rndis_host.c
@@ -21,9 +21,6 @@
21// #define VERBOSE // more; success messages 21// #define VERBOSE // more; success messages
22 22
23#include <linux/config.h> 23#include <linux/config.h>
24#ifdef CONFIG_USB_DEBUG
25# define DEBUG
26#endif
27#include <linux/module.h> 24#include <linux/module.h>
28#include <linux/sched.h> 25#include <linux/sched.h>
29#include <linux/init.h> 26#include <linux/init.h>
diff --git a/drivers/usb/net/usbnet.c b/drivers/usb/net/usbnet.c
index 74f05c9c84d5..362d6907c9bb 100644
--- a/drivers/usb/net/usbnet.c
+++ b/drivers/usb/net/usbnet.c
@@ -34,9 +34,6 @@
34// #define VERBOSE // more; success messages 34// #define VERBOSE // more; success messages
35 35
36#include <linux/config.h> 36#include <linux/config.h>
37#ifdef CONFIG_USB_DEBUG
38# define DEBUG
39#endif
40#include <linux/module.h> 37#include <linux/module.h>
41#include <linux/sched.h> 38#include <linux/sched.h>
42#include <linux/init.h> 39#include <linux/init.h>
diff --git a/drivers/usb/net/zaurus.c b/drivers/usb/net/zaurus.c
index 5d4b7d55b097..680d13957af4 100644
--- a/drivers/usb/net/zaurus.c
+++ b/drivers/usb/net/zaurus.c
@@ -21,9 +21,6 @@
21// #define VERBOSE // more; success messages 21// #define VERBOSE // more; success messages
22 22
23#include <linux/config.h> 23#include <linux/config.h>
24#ifdef CONFIG_USB_DEBUG
25# define DEBUG
26#endif
27#include <linux/module.h> 24#include <linux/module.h>
28#include <linux/sched.h> 25#include <linux/sched.h>
29#include <linux/init.h> 26#include <linux/init.h>
diff --git a/drivers/usb/serial/ChangeLog.old b/drivers/usb/serial/ChangeLog.history
index c1b279939bbf..52c4f7bd7a80 100644
--- a/drivers/usb/serial/ChangeLog.old
+++ b/drivers/usb/serial/ChangeLog.history
@@ -400,7 +400,7 @@ visor.c Change Log comments:
400 400
401 (11/11/2001) gkh 401 (11/11/2001) gkh
402 Added support for the m125 devices, and added check to prevent oopses 402 Added support for the m125 devices, and added check to prevent oopses
403 for Clié devices that lie about the number of ports they have. 403 for Clié devices that lie about the number of ports they have.
404 404
405 (08/30/2001) gkh 405 (08/30/2001) gkh
406 Added support for the Clie devices, both the 3.5 and 4.0 os versions. 406 Added support for the Clie devices, both the 3.5 and 4.0 os versions.
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index 7b5e8e4ee2bb..14f55fd26a64 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -62,6 +62,15 @@ config USB_SERIAL_AIRPRIME
62 To compile this driver as a module, choose M here: the 62 To compile this driver as a module, choose M here: the
63 module will be called airprime. 63 module will be called airprime.
64 64
65config USB_SERIAL_ANYDATA
66 tristate "USB AnyData CDMA Wireless Driver"
67 depends on USB_SERIAL
68 help
69 Say Y here if you want to use a AnyData CDMA device.
70
71 To compile this driver as a module, choose M here: the
72 module will be called anydata.
73
65config USB_SERIAL_BELKIN 74config USB_SERIAL_BELKIN
66 tristate "USB Belkin and Peracom Single Port Serial Driver" 75 tristate "USB Belkin and Peracom Single Port Serial Driver"
67 depends on USB_SERIAL 76 depends on USB_SERIAL
@@ -394,15 +403,6 @@ config USB_SERIAL_MCT_U232
394 To compile this driver as a module, choose M here: the 403 To compile this driver as a module, choose M here: the
395 module will be called mct_u232. 404 module will be called mct_u232.
396 405
397config USB_SERIAL_NOKIA_DKU2
398 tristate "USB Nokia DKU2 Driver"
399 depends on USB_SERIAL
400 help
401 Say Y here if you want to use a Nokia DKU2 device.
402
403 To compile this driver as a module, choose M here: the
404 module will be called nokia_dku2.
405
406config USB_SERIAL_PL2303 406config USB_SERIAL_PL2303
407 tristate "USB Prolific 2303 Single Port Serial Driver" 407 tristate "USB Prolific 2303 Single Port Serial Driver"
408 depends on USB_SERIAL 408 depends on USB_SERIAL
diff --git a/drivers/usb/serial/Makefile b/drivers/usb/serial/Makefile
index 55fd461793b7..f0b04420cea1 100644
--- a/drivers/usb/serial/Makefile
+++ b/drivers/usb/serial/Makefile
@@ -12,6 +12,7 @@ usbserial-obj-$(CONFIG_USB_EZUSB) += ezusb.o
12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y) 12usbserial-objs := usb-serial.o generic.o bus.o $(usbserial-obj-y)
13 13
14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o 14obj-$(CONFIG_USB_SERIAL_AIRPRIME) += airprime.o
15obj-$(CONFIG_USB_SERIAL_ANYDATA) += anydata.o
15obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o 16obj-$(CONFIG_USB_SERIAL_BELKIN) += belkin_sa.o
16obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o 17obj-$(CONFIG_USB_SERIAL_CP2101) += cp2101.o
17obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o 18obj-$(CONFIG_USB_SERIAL_CYBERJACK) += cyberjack.o
@@ -31,7 +32,6 @@ obj-$(CONFIG_USB_SERIAL_KEYSPAN_PDA) += keyspan_pda.o
31obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o 32obj-$(CONFIG_USB_SERIAL_KLSI) += kl5kusb105.o
32obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o 33obj-$(CONFIG_USB_SERIAL_KOBIL_SCT) += kobil_sct.o
33obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o 34obj-$(CONFIG_USB_SERIAL_MCT_U232) += mct_u232.o
34obj-$(CONFIG_USB_SERIAL_NOKIA_DKU2) += nokia_dku2.o
35obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o 35obj-$(CONFIG_USB_SERIAL_OMNINET) += omninet.o
36obj-$(CONFIG_USB_SERIAL_OPTION) += option.o 36obj-$(CONFIG_USB_SERIAL_OPTION) += option.o
37obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o 37obj-$(CONFIG_USB_SERIAL_PL2303) += pl2303.o
diff --git a/drivers/usb/serial/anydata.c b/drivers/usb/serial/anydata.c
new file mode 100644
index 000000000000..18022a74a3dc
--- /dev/null
+++ b/drivers/usb/serial/anydata.c
@@ -0,0 +1,123 @@
1/*
2 * AnyData CDMA Serial USB driver
3 *
4 * Copyright (C) 2005 Greg Kroah-Hartman <gregkh@suse.de>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 */
10
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/tty.h>
14#include <linux/module.h>
15#include <linux/usb.h>
16#include "usb-serial.h"
17
18static struct usb_device_id id_table [] = {
19 { USB_DEVICE(0x16d5, 0x6501) }, /* AirData CDMA device */
20 { },
21};
22MODULE_DEVICE_TABLE(usb, id_table);
23
24/* if overridden by the user, then use their value for the size of the
25 * read and write urbs */
26static int buffer_size;
27static int debug;
28
29static struct usb_driver anydata_driver = {
30 .owner = THIS_MODULE,
31 .name = "anydata",
32 .probe = usb_serial_probe,
33 .disconnect = usb_serial_disconnect,
34 .id_table = id_table,
35};
36
37static int anydata_open(struct usb_serial_port *port, struct file *filp)
38{
39 char *buffer;
40 int result = 0;
41
42 dbg("%s - port %d", __FUNCTION__, port->number);
43
44 if (buffer_size) {
45 /* override the default buffer sizes */
46 buffer = kmalloc(buffer_size, GFP_KERNEL);
47 if (!buffer) {
48 dev_err(&port->dev, "%s - out of memory.\n",
49 __FUNCTION__);
50 return -ENOMEM;
51 }
52 kfree (port->read_urb->transfer_buffer);
53 port->read_urb->transfer_buffer = buffer;
54 port->read_urb->transfer_buffer_length = buffer_size;
55
56 buffer = kmalloc(buffer_size, GFP_KERNEL);
57 if (!buffer) {
58 dev_err(&port->dev, "%s - out of memory.\n",
59 __FUNCTION__);
60 return -ENOMEM;
61 }
62 kfree (port->write_urb->transfer_buffer);
63 port->write_urb->transfer_buffer = buffer;
64 port->write_urb->transfer_buffer_length = buffer_size;
65 port->bulk_out_size = buffer_size;
66 }
67
68 /* Start reading from the device */
69 usb_fill_bulk_urb(port->read_urb, port->serial->dev,
70 usb_rcvbulkpipe(port->serial->dev,
71 port->bulk_in_endpointAddress),
72 port->read_urb->transfer_buffer,
73 port->read_urb->transfer_buffer_length,
74 usb_serial_generic_write_bulk_callback, port);
75 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
76 if (result)
77 dev_err(&port->dev,
78 "%s - failed submitting read urb, error %d\n",
79 __FUNCTION__, result);
80
81 return result;
82}
83
84static struct usb_serial_driver anydata_device = {
85 .driver = {
86 .owner = THIS_MODULE,
87 .name = "anydata",
88 },
89 .id_table = id_table,
90 .num_interrupt_in = NUM_DONT_CARE,
91 .num_bulk_in = NUM_DONT_CARE,
92 .num_bulk_out = NUM_DONT_CARE,
93 .num_ports = 1,
94 .open = anydata_open,
95};
96
97static int __init anydata_init(void)
98{
99 int retval;
100
101 retval = usb_serial_register(&anydata_device);
102 if (retval)
103 return retval;
104 retval = usb_register(&anydata_driver);
105 if (retval)
106 usb_serial_deregister(&anydata_device);
107 return retval;
108}
109
110static void __exit anydata_exit(void)
111{
112 usb_deregister(&anydata_driver);
113 usb_serial_deregister(&anydata_device);
114}
115
116module_init(anydata_init);
117module_exit(anydata_exit);
118MODULE_LICENSE("GPL");
119
120module_param(debug, bool, S_IRUGO | S_IWUSR);
121MODULE_PARM_DESC(debug, "Debug enabled or not");
122module_param(buffer_size, int, 0);
123MODULE_PARM_DESC(buffer_size, "Size of the transfer buffers");
diff --git a/drivers/usb/serial/cp2101.c b/drivers/usb/serial/cp2101.c
index c5334dd89b12..c9787001cf2a 100644
--- a/drivers/usb/serial/cp2101.c
+++ b/drivers/usb/serial/cp2101.c
@@ -60,6 +60,7 @@ static struct usb_device_id id_table [] = {
60 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */ 60 { USB_DEVICE(0x10C4, 0x80F6) }, /* Suunto sports instrument */
61 { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */ 61 { USB_DEVICE(0x10A6, 0xAA26) }, /* Knock-off DCU-11 cable */
62 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */ 62 { USB_DEVICE(0x10AB, 0x10C5) }, /* Siemens MC60 Cable */
63 { USB_DEVICE(0x16D6, 0x0001) }, /* Jablotron serial interface */
63 { } /* Terminating Entry */ 64 { } /* Terminating Entry */
64}; 65};
65 66
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index 61204bf7cd78..06e04b442ff1 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -475,6 +475,8 @@ static struct usb_device_id id_table_combined [] = {
475 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) }, 475 { USB_DEVICE(FTDI_VID, FTDI_ARTEMIS_PID) },
476 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) }, 476 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16_PID) },
477 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) }, 477 { USB_DEVICE(FTDI_VID, FTDI_ATIK_ATK16HR_PID) },
478 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_B1_PID) },
479 { USB_DEVICE(KOBIL_VID, KOBIL_CONV_KAAN_PID) },
478 { }, /* Optional parameter entry */ 480 { }, /* Optional parameter entry */
479 { } /* Terminating entry */ 481 { } /* Terminating entry */
480}; 482};
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index ddb63df31ce6..773ea3eca086 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -128,6 +128,13 @@
128#define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */ 128#define SEALEVEL_2803_8_PID 0X2883 /* SeaLINK+8 (2803) Port 8 */
129 129
130/* 130/*
131 * The following are the values for two KOBIL chipcard terminals.
132 */
133#define KOBIL_VID 0x0d46 /* KOBIL Vendor ID */
134#define KOBIL_CONV_B1_PID 0x2020 /* KOBIL Konverter for B1 */
135#define KOBIL_CONV_KAAN_PID 0x2021 /* KOBIL_Konverter for KAAN */
136
137/*
131 * DSS-20 Sync Station for Sony Ericsson P800 138 * DSS-20 Sync Station for Sony Ericsson P800
132 */ 139 */
133 140
diff --git a/drivers/usb/serial/generic.c b/drivers/usb/serial/generic.c
index 8909208f506a..53a47c31cd0e 100644
--- a/drivers/usb/serial/generic.c
+++ b/drivers/usb/serial/generic.c
@@ -309,6 +309,7 @@ void usb_serial_generic_write_bulk_callback (struct urb *urb, struct pt_regs *re
309 309
310 schedule_work(&port->work); 310 schedule_work(&port->work);
311} 311}
312EXPORT_SYMBOL_GPL(usb_serial_generic_write_bulk_callback);
312 313
313void usb_serial_generic_shutdown (struct usb_serial *serial) 314void usb_serial_generic_shutdown (struct usb_serial *serial)
314{ 315{
diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c
index a02fada85362..7744b8148bc5 100644
--- a/drivers/usb/serial/ipw.c
+++ b/drivers/usb/serial/ipw.c
@@ -46,7 +46,6 @@
46#include <linux/module.h> 46#include <linux/module.h>
47#include <linux/spinlock.h> 47#include <linux/spinlock.h>
48#include <linux/usb.h> 48#include <linux/usb.h>
49#include <linux/usb.h>
50#include <asm/uaccess.h> 49#include <asm/uaccess.h>
51#include "usb-serial.h" 50#include "usb-serial.h"
52 51
diff --git a/drivers/usb/serial/nokia_dku2.c b/drivers/usb/serial/nokia_dku2.c
deleted file mode 100644
index fad01bef3a64..000000000000
--- a/drivers/usb/serial/nokia_dku2.c
+++ /dev/null
@@ -1,142 +0,0 @@
1/*
2 * Nokia DKU2 USB driver
3 *
4 * Copyright (C) 2004
5 * Author: C Kemp
6 *
7 * This program is largely derived from work by the linux-usb group
8 * and associated source files. Please see the usb/serial files for
9 * individual credits and copyrights.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * 20.09.2005 - Matthias Blaesing <matthias.blaesing@rwth-aachen.de>
17 * Added short name to device structure to make driver load into kernel 2.6.13
18 *
19 * 20.09.2005 - Matthias Blaesing <matthias.blaesing@rwth-aachen.de>
20 * Added usb_deregister to exit code - to allow remove and reinsert of module
21 */
22
23
24#include <linux/config.h>
25#include <linux/kernel.h>
26#include <linux/errno.h>
27#include <linux/init.h>
28#include <linux/slab.h>
29#include <linux/tty.h>
30#include <linux/tty_driver.h>
31#include <linux/tty_flip.h>
32#include <linux/module.h>
33#include <linux/usb.h>
34#include "usb-serial.h"
35
36
37#define NOKIA_VENDOR_ID 0x0421
38#define NOKIA7600_PRODUCT_ID 0x0400
39#define NOKIA6230_PRODUCT_ID 0x040f
40#define NOKIA6170_PRODUCT_ID 0x0416
41#define NOKIA6670_PRODUCT_ID 0x041d
42#define NOKIA6680_PRODUCT_ID 0x041e
43#define NOKIA6230i_PRODUCT_ID 0x0428
44
45#define NOKIA_AT_PORT 0x82
46#define NOKIA_FBUS_PORT 0x86
47
48/*
49 * Version Information
50 */
51#define DRIVER_VERSION "v0.2"
52#define DRIVER_AUTHOR "C Kemp"
53#define DRIVER_DESC "Nokia DKU2 Driver"
54
55static struct usb_device_id id_table [] = {
56 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA7600_PRODUCT_ID) },
57 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6230_PRODUCT_ID) },
58 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6170_PRODUCT_ID) },
59 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6670_PRODUCT_ID) },
60 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6680_PRODUCT_ID) },
61 { USB_DEVICE(NOKIA_VENDOR_ID, NOKIA6230i_PRODUCT_ID) },
62 { } /* Terminating entry */
63};
64MODULE_DEVICE_TABLE(usb, id_table);
65
66/* The only thing which makes this device different from a generic
67 * device is that we have to set an alternative configuration to make
68 * the relevant endpoints available. In 2.6 this is really easy... */
69static int nokia_probe(struct usb_serial *serial,
70 const struct usb_device_id *id)
71{
72 int retval = -ENODEV;
73
74 if (serial->interface->altsetting[0].endpoint[0].desc.bEndpointAddress == NOKIA_AT_PORT) {
75 /* the AT port */
76 dev_info(&serial->dev->dev, "Nokia AT Port:\n");
77 retval = 0;
78 } else if (serial->interface->num_altsetting == 2 &&
79 serial->interface->altsetting[1].endpoint[0].desc.bEndpointAddress == NOKIA_FBUS_PORT) {
80 /* the FBUS port */
81 dev_info(&serial->dev->dev, "Nokia FBUS Port:\n");
82 usb_set_interface(serial->dev, 10, 1);
83 retval = 0;
84 }
85
86 return retval;
87}
88
89static struct usb_driver nokia_driver = {
90 .owner = THIS_MODULE,
91 .name = "nokia_dku2",
92 .probe = usb_serial_probe,
93 .disconnect = usb_serial_disconnect,
94 .id_table = id_table,
95};
96
97static struct usb_serial_driver nokia_serial_driver = {
98 .driver = {
99 .owner = THIS_MODULE,
100 .name = "nokia_dku2",
101 },
102 .description = "Nokia 7600/6230(i)/6170/66x0 DKU2 driver",
103 .id_table = id_table,
104 .num_interrupt_in = 1,
105 .num_bulk_in = 1,
106 .num_bulk_out = 1,
107 .num_ports = 1,
108 .probe = nokia_probe,
109};
110
111static int __init nokia_init(void)
112{
113 int retval;
114
115 retval = usb_serial_register(&nokia_serial_driver);
116 if (retval)
117 return retval;
118
119 retval = usb_register(&nokia_driver);
120 if (retval) {
121 usb_serial_deregister(&nokia_serial_driver);
122 return retval;
123 }
124
125 info(DRIVER_VERSION " " DRIVER_AUTHOR);
126 info(DRIVER_DESC);
127
128 return retval;
129}
130
131static void __exit nokia_exit(void)
132{
133 usb_deregister(&nokia_driver);
134 usb_serial_deregister(&nokia_serial_driver);
135}
136
137module_init(nokia_init);
138module_exit(nokia_exit);
139
140MODULE_AUTHOR(DRIVER_AUTHOR);
141MODULE_DESCRIPTION(DRIVER_DESC);
142MODULE_LICENSE("GPL");
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 165c119bf10e..41a45a5025b2 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -71,7 +71,9 @@ static struct usb_device_id id_table [] = {
71 { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) }, 71 { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) },
72 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, 72 { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) },
73 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, 73 { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) },
74 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1) },
74 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) }, 75 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) },
76 { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) },
75 { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) }, 77 { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) },
76 { USB_DEVICE( NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID ) }, 78 { USB_DEVICE( NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID ) },
77 { } /* Terminating entry */ 79 { } /* Terminating entry */
@@ -811,7 +813,9 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
811 u8 length = UART_STATE; 813 u8 length = UART_STATE;
812 814
813 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) &&
814 (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 ||
817 le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_SX1 ||
818 le16_to_cpu(port->serial->dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_X75)) {
815 length = 1; 819 length = 1;
816 status_idx = 0; 820 status_idx = 0;
817 } 821 }
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 7be9644f5a03..21d434d81813 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -54,7 +54,9 @@
54#define SAMSUNG_PRODUCT_ID 0x8001 54#define SAMSUNG_PRODUCT_ID 0x8001
55 55
56#define SIEMENS_VENDOR_ID 0x11f5 56#define SIEMENS_VENDOR_ID 0x11f5
57#define SIEMENS_PRODUCT_ID_SX1 0x0001
57#define SIEMENS_PRODUCT_ID_X65 0x0003 58#define SIEMENS_PRODUCT_ID_X65 0x0003
59#define SIEMENS_PRODUCT_ID_X75 0x0004
58 60
59#define SYNTECH_VENDOR_ID 0x0745 61#define SYNTECH_VENDOR_ID 0x0745
60#define SYNTECH_PRODUCT_ID 0x0001 62#define SYNTECH_PRODUCT_ID 0x0001
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig
index 1a9679f76f5a..c41d64dbb0f0 100644
--- a/drivers/usb/storage/Kconfig
+++ b/drivers/usb/storage/Kconfig
@@ -115,7 +115,7 @@ config USB_STORAGE_JUMPSHOT
115 115
116config USB_STORAGE_ONETOUCH 116config USB_STORAGE_ONETOUCH
117 bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)" 117 bool "Support OneTouch Button on Maxtor Hard Drives (EXPERIMENTAL)"
118 depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL 118 depends on USB_STORAGE && INPUT_EVDEV && EXPERIMENTAL && !PM
119 help 119 help
120 Say Y here to include additional code to support the Maxtor OneTouch 120 Say Y here to include additional code to support the Maxtor OneTouch
121 USB hard drive's onetouch button. 121 USB hard drive's onetouch button.
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/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index 33c55a6261bb..fea176d7e79a 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -853,7 +853,7 @@ static int usbat_identify_device(struct us_data *us,
853 rc = usbat_device_reset(us); 853 rc = usbat_device_reset(us);
854 if (rc != USB_STOR_TRANSPORT_GOOD) 854 if (rc != USB_STOR_TRANSPORT_GOOD)
855 return rc; 855 return rc;
856 msleep(25); 856 msleep(500);
857 857
858 /* 858 /*
859 * In attempt to distinguish between HP CDRW's and Flash readers, we now 859 * In attempt to distinguish between HP CDRW's and Flash readers, we now
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 9e926a8f2116..f5f47a34b168 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -710,11 +710,6 @@ UNUSUAL_DEV( 0x0686, 0x4017, 0x0001, 0x0001,
710 "DIMAGE E223", 710 "DIMAGE E223",
711 US_SC_SCSI, US_PR_DEVICE, NULL, 0 ), 711 US_SC_SCSI, US_PR_DEVICE, NULL, 0 ),
712 712
713UNUSUAL_DEV( 0x0693, 0x0002, 0x0100, 0x0100,
714 "Hagiwara",
715 "FlashGate SmartMedia",
716 US_SC_SCSI, US_PR_BULK, NULL, 0 ),
717
718UNUSUAL_DEV( 0x0693, 0x0005, 0x0100, 0x0100, 713UNUSUAL_DEV( 0x0693, 0x0005, 0x0100, 0x0100,
719 "Hagiwara", 714 "Hagiwara",
720 "Flashgate", 715 "Flashgate",
@@ -1008,6 +1003,11 @@ UNUSUAL_DEV( 0x0c0b, 0xa109, 0x0000, 0xffff,
1008 * 1003 *
1009 */ 1004 */
1010#ifdef CONFIG_USB_STORAGE_ONETOUCH 1005#ifdef CONFIG_USB_STORAGE_ONETOUCH
1006 UNUSUAL_DEV( 0x0d49, 0x7000, 0x0000, 0x9999,
1007 "Maxtor",
1008 "OneTouch External Harddrive",
1009 US_SC_DEVICE, US_PR_DEVICE, onetouch_connect_input,
1010 0),
1011 UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999, 1011 UNUSUAL_DEV( 0x0d49, 0x7010, 0x0000, 0x9999,
1012 "Maxtor", 1012 "Maxtor",
1013 "OneTouch External Harddrive", 1013 "OneTouch External Harddrive",
@@ -1118,6 +1118,15 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1118 US_SC_DEVICE, US_PR_DEVICE, NULL, 1118 US_SC_DEVICE, US_PR_DEVICE, NULL,
1119 US_FL_GO_SLOW ), 1119 US_FL_GO_SLOW ),
1120 1120
1121/*
1122 * David Härdeman <david@2gen.com>
1123 * The key makes the SCSI stack print confusing (but harmless) messages
1124 */
1125UNUSUAL_DEV( 0x4146, 0xba01, 0x0100, 0x0100,
1126 "Iomega",
1127 "Micro Mini 1GB",
1128 US_SC_DEVICE, US_PR_DEVICE, NULL, US_FL_NOT_LOCKABLE ),
1129
1121#ifdef CONFIG_USB_STORAGE_SDDR55 1130#ifdef CONFIG_USB_STORAGE_SDDR55
1122UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999, 1131UNUSUAL_DEV( 0x55aa, 0xa103, 0x0000, 0x9999,
1123 "Sandisk", 1132 "Sandisk",
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 25b6ca6ad081..cc8e3bf5001b 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -534,9 +534,15 @@ config FB_SUN3
534 bool "Sun3 framebuffer support" 534 bool "Sun3 framebuffer support"
535 depends on (FB = y) && (SUN3 || SUN3X) && BROKEN 535 depends on (FB = y) && (SUN3 || SUN3X) && BROKEN
536 536
537config FB_SBUS
538 bool "SBUS and UPA framebuffers"
539 depends on (FB = y) && SPARC
540 help
541 Say Y if you want support for SBUS or UPA based frame buffer device.
542
537config FB_BW2 543config FB_BW2
538 bool "BWtwo support" 544 bool "BWtwo support"
539 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 545 depends on (FB = y) && (SPARC && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
540 select FB_CFB_FILLRECT 546 select FB_CFB_FILLRECT
541 select FB_CFB_COPYAREA 547 select FB_CFB_COPYAREA
542 select FB_CFB_IMAGEBLIT 548 select FB_CFB_IMAGEBLIT
@@ -545,7 +551,8 @@ config FB_BW2
545 551
546config FB_CG3 552config FB_CG3
547 bool "CGthree support" 553 bool "CGthree support"
548 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
549 select FB_CFB_COPYAREA 556 select FB_CFB_COPYAREA
550 select FB_CFB_IMAGEBLIT 557 select FB_CFB_IMAGEBLIT
551 help 558 help
@@ -553,7 +560,7 @@ config FB_CG3
553 560
554config FB_CG6 561config FB_CG6
555 bool "CGsix (GX,TurboGX) support" 562 bool "CGsix (GX,TurboGX) support"
556 depends on (FB = y) && ((SPARC32 || SPARC64) && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3) 563 depends on (FB = y) && (SPARC && FB_SBUS || (SUN3 || SUN3X) && FB_SUN3)
557 select FB_CFB_COPYAREA 564 select FB_CFB_COPYAREA
558 select FB_CFB_IMAGEBLIT 565 select FB_CFB_IMAGEBLIT
559 help 566 help
@@ -1210,12 +1217,6 @@ config FB_AU1100
1210 1217
1211source "drivers/video/geode/Kconfig" 1218source "drivers/video/geode/Kconfig"
1212 1219
1213config FB_SBUS
1214 bool "SBUS and UPA framebuffers"
1215 depends on (FB = y) && (SPARC32 || SPARC64)
1216 help
1217 Say Y if you want support for SBUS or UPA based frame buffer device.
1218
1219config FB_FFB 1220config FB_FFB
1220 bool "Creator/Creator3D/Elite3D support" 1221 bool "Creator/Creator3D/Elite3D support"
1221 depends on FB_SBUS && SPARC64 1222 depends on FB_SBUS && SPARC64
@@ -1267,7 +1268,7 @@ config FB_LEO
1267 1268
1268config FB_PCI 1269config FB_PCI
1269 bool "PCI framebuffers" 1270 bool "PCI framebuffers"
1270 depends on (FB = y) && PCI && (SPARC64 || SPARC32) 1271 depends on (FB = y) && PCI && SPARC
1271 1272
1272config FB_IGA 1273config FB_IGA
1273 bool "IGA 168x display support" 1274 bool "IGA 168x display support"
diff --git a/drivers/video/acornfb.c b/drivers/video/acornfb.c
index 193b482570c7..750cebb18306 100644
--- a/drivers/video/acornfb.c
+++ b/drivers/video/acornfb.c
@@ -1279,7 +1279,7 @@ free_unused_pages(unsigned int virtual_start, unsigned int virtual_end)
1279 printk("acornfb: freed %dK memory\n", mb_freed); 1279 printk("acornfb: freed %dK memory\n", mb_freed);
1280} 1280}
1281 1281
1282static int __init acornfb_probe(struct device *dev) 1282static int __init acornfb_probe(struct platform_device *dev)
1283{ 1283{
1284 unsigned long size; 1284 unsigned long size;
1285 u_int h_sync, v_sync; 1285 u_int h_sync, v_sync;
@@ -1292,7 +1292,7 @@ static int __init acornfb_probe(struct device *dev)
1292 1292
1293 acornfb_init_fbinfo(); 1293 acornfb_init_fbinfo();
1294 1294
1295 current_par.dev = dev; 1295 current_par.dev = &dev->dev;
1296 1296
1297 if (current_par.montype == -1) 1297 if (current_par.montype == -1)
1298 current_par.montype = acornfb_detect_monitortype(); 1298 current_par.montype = acornfb_detect_monitortype();
@@ -1453,15 +1453,16 @@ static int __init acornfb_probe(struct device *dev)
1453 return 0; 1453 return 0;
1454} 1454}
1455 1455
1456static struct device_driver acornfb_driver = { 1456static struct platform_driver acornfb_driver = {
1457 .name = "acornfb",
1458 .bus = &platform_bus_type,
1459 .probe = acornfb_probe, 1457 .probe = acornfb_probe,
1458 .driver = {
1459 .name = "acornfb",
1460 },
1460}; 1461};
1461 1462
1462static int __init acornfb_init(void) 1463static int __init acornfb_init(void)
1463{ 1464{
1464 return driver_register(&acornfb_driver); 1465 return platform_driver_register(&acornfb_driver);
1465} 1466}
1466 1467
1467module_init(acornfb_init); 1468module_init(acornfb_init);
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index a1fc8bbb1090..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 */
@@ -514,9 +514,8 @@ static struct fb_ops arcfb_ops = {
514 .fb_ioctl = arcfb_ioctl, 514 .fb_ioctl = arcfb_ioctl,
515}; 515};
516 516
517static int __init arcfb_probe(struct device *device) 517static int __init arcfb_probe(struct platform_device *dev)
518{ 518{
519 struct platform_device *dev = to_platform_device(device);
520 struct fb_info *info; 519 struct fb_info *info;
521 int retval = -ENOMEM; 520 int retval = -ENOMEM;
522 int videomemorysize; 521 int videomemorysize;
@@ -559,7 +558,7 @@ static int __init arcfb_probe(struct device *device)
559 retval = register_framebuffer(info); 558 retval = register_framebuffer(info);
560 if (retval < 0) 559 if (retval < 0)
561 goto err1; 560 goto err1;
562 dev_set_drvdata(&dev->dev, info); 561 platform_set_drvdata(dev, info);
563 if (irq) { 562 if (irq) {
564 par->irq = irq; 563 par->irq = irq;
565 if (request_irq(par->irq, &arcfb_interrupt, SA_SHIRQ, 564 if (request_irq(par->irq, &arcfb_interrupt, SA_SHIRQ,
@@ -600,9 +599,9 @@ err:
600 return retval; 599 return retval;
601} 600}
602 601
603static int arcfb_remove(struct device *device) 602static int arcfb_remove(struct platform_device *dev)
604{ 603{
605 struct fb_info *info = dev_get_drvdata(device); 604 struct fb_info *info = platform_get_drvdata(dev);
606 605
607 if (info) { 606 if (info) {
608 unregister_framebuffer(info); 607 unregister_framebuffer(info);
@@ -612,11 +611,12 @@ static int arcfb_remove(struct device *device)
612 return 0; 611 return 0;
613} 612}
614 613
615static struct device_driver arcfb_driver = { 614static struct platform_driver arcfb_driver = {
616 .name = "arcfb",
617 .bus = &platform_bus_type,
618 .probe = arcfb_probe, 615 .probe = arcfb_probe,
619 .remove = arcfb_remove, 616 .remove = arcfb_remove,
617 .driver = {
618 .name = "arcfb",
619 },
620}; 620};
621 621
622static struct platform_device *arcfb_device; 622static struct platform_device *arcfb_device;
@@ -628,7 +628,7 @@ static int __init arcfb_init(void)
628 if (!arcfb_enable) 628 if (!arcfb_enable)
629 return -ENXIO; 629 return -ENXIO;
630 630
631 ret = driver_register(&arcfb_driver); 631 ret = platform_driver_register(&arcfb_driver);
632 if (!ret) { 632 if (!ret) {
633 arcfb_device = platform_device_alloc("arcfb", 0); 633 arcfb_device = platform_device_alloc("arcfb", 0);
634 if (arcfb_device) { 634 if (arcfb_device) {
@@ -638,7 +638,7 @@ static int __init arcfb_init(void)
638 } 638 }
639 if (ret) { 639 if (ret) {
640 platform_device_put(arcfb_device); 640 platform_device_put(arcfb_device);
641 driver_unregister(&arcfb_driver); 641 platform_driver_unregister(&arcfb_driver);
642 } 642 }
643 } 643 }
644 return ret; 644 return ret;
@@ -648,7 +648,7 @@ static int __init arcfb_init(void)
648static void __exit arcfb_exit(void) 648static void __exit arcfb_exit(void)
649{ 649{
650 platform_device_unregister(arcfb_device); 650 platform_device_unregister(arcfb_device);
651 driver_unregister(&arcfb_driver); 651 platform_driver_unregister(&arcfb_driver);
652} 652}
653 653
654module_param(num_cols, ulong, 0); 654module_param(num_cols, ulong, 0);
diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c
index 4867498f68e8..6a219b2c77e3 100644
--- a/drivers/video/backlight/corgi_bl.c
+++ b/drivers/video/backlight/corgi_bl.c
@@ -48,6 +48,12 @@ static void corgibl_send_intensity(int intensity)
48 corgibl_mach_set_intensity(intensity); 48 corgibl_mach_set_intensity(intensity);
49 49
50 spin_unlock_irqrestore(&bl_lock, flags); 50 spin_unlock_irqrestore(&bl_lock, flags);
51
52 corgi_kick_batt = symbol_get(sharpsl_battery_kick);
53 if (corgi_kick_batt) {
54 corgi_kick_batt();
55 symbol_put(sharpsl_battery_kick);
56 }
51} 57}
52 58
53static void corgibl_blank(int blank) 59static void corgibl_blank(int blank)
@@ -73,13 +79,13 @@ static void corgibl_blank(int blank)
73} 79}
74 80
75#ifdef CONFIG_PM 81#ifdef CONFIG_PM
76static int corgibl_suspend(struct device *dev, pm_message_t state) 82static int corgibl_suspend(struct platform_device *dev, pm_message_t state)
77{ 83{
78 corgibl_blank(FB_BLANK_POWERDOWN); 84 corgibl_blank(FB_BLANK_POWERDOWN);
79 return 0; 85 return 0;
80} 86}
81 87
82static int corgibl_resume(struct device *dev) 88static int corgibl_resume(struct platform_device *dev)
83{ 89{
84 corgibl_blank(FB_BLANK_UNBLANK); 90 corgibl_blank(FB_BLANK_UNBLANK);
85 return 0; 91 return 0;
@@ -137,9 +143,9 @@ static struct backlight_properties corgibl_data = {
137 143
138static struct backlight_device *corgi_backlight_device; 144static struct backlight_device *corgi_backlight_device;
139 145
140static int __init corgibl_probe(struct device *dev) 146static int __init corgibl_probe(struct platform_device *pdev)
141{ 147{
142 struct corgibl_machinfo *machinfo = dev->platform_data; 148 struct corgibl_machinfo *machinfo = pdev->dev.platform_data;
143 149
144 corgibl_data.max_brightness = machinfo->max_intensity; 150 corgibl_data.max_brightness = machinfo->max_intensity;
145 corgibl_mach_set_intensity = machinfo->set_bl_intensity; 151 corgibl_mach_set_intensity = machinfo->set_bl_intensity;
@@ -156,7 +162,7 @@ static int __init corgibl_probe(struct device *dev)
156 return 0; 162 return 0;
157} 163}
158 164
159static int corgibl_remove(struct device *dev) 165static int corgibl_remove(struct platform_device *dev)
160{ 166{
161 backlight_device_unregister(corgi_backlight_device); 167 backlight_device_unregister(corgi_backlight_device);
162 168
@@ -166,23 +172,24 @@ static int corgibl_remove(struct device *dev)
166 return 0; 172 return 0;
167} 173}
168 174
169static struct device_driver corgibl_driver = { 175static struct platform_driver corgibl_driver = {
170 .name = "corgi-bl",
171 .bus = &platform_bus_type,
172 .probe = corgibl_probe, 176 .probe = corgibl_probe,
173 .remove = corgibl_remove, 177 .remove = corgibl_remove,
174 .suspend = corgibl_suspend, 178 .suspend = corgibl_suspend,
175 .resume = corgibl_resume, 179 .resume = corgibl_resume,
180 .driver = {
181 .name = "corgi-bl",
182 },
176}; 183};
177 184
178static int __init corgibl_init(void) 185static int __init corgibl_init(void)
179{ 186{
180 return driver_register(&corgibl_driver); 187 return platform_driver_register(&corgibl_driver);
181} 188}
182 189
183static void __exit corgibl_exit(void) 190static void __exit corgibl_exit(void)
184{ 191{
185 driver_unregister(&corgibl_driver); 192 platform_driver_unregister(&corgibl_driver);
186} 193}
187 194
188module_init(corgibl_init); 195module_init(corgibl_init);
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index f53bf3ba1278..9248fe1fbb1a 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -51,6 +51,9 @@ static struct fb_ops bw2_ops = {
51 .fb_imageblit = cfb_imageblit, 51 .fb_imageblit = cfb_imageblit,
52 .fb_mmap = bw2_mmap, 52 .fb_mmap = bw2_mmap,
53 .fb_ioctl = bw2_ioctl, 53 .fb_ioctl = bw2_ioctl,
54#ifdef CONFIG_COMPAT
55 .fb_compat_ioctl = sbusfb_compat_ioctl,
56#endif
54}; 57};
55 58
56/* OBio addresses for the bwtwo registers */ 59/* OBio addresses for the bwtwo registers */
@@ -118,7 +121,6 @@ struct bw2_par {
118 unsigned long fbsize; 121 unsigned long fbsize;
119 122
120 struct sbus_dev *sdev; 123 struct sbus_dev *sdev;
121 struct list_head list;
122}; 124};
123 125
124/** 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 030d4b13b1c2..a56147102abb 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -49,6 +49,9 @@ static struct fb_ops cg14_ops = {
49 .fb_imageblit = cfb_imageblit, 49 .fb_imageblit = cfb_imageblit,
50 .fb_mmap = cg14_mmap, 50 .fb_mmap = cg14_mmap,
51 .fb_ioctl = cg14_ioctl, 51 .fb_ioctl = cg14_ioctl,
52#ifdef CONFIG_COMPAT
53 .fb_compat_ioctl = sbusfb_compat_ioctl,
54#endif
52}; 55};
53 56
54#define CG14_MCR_INTENABLE_SHIFT 7 57#define CG14_MCR_INTENABLE_SHIFT 7
@@ -203,7 +206,6 @@ struct cg14_par {
203 int mode; 206 int mode;
204 int ramsize; 207 int ramsize;
205 struct sbus_dev *sdev; 208 struct sbus_dev *sdev;
206 struct list_head list;
207}; 209};
208 210
209static 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 b94eee8c42d5..9fcd89608ed7 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -50,6 +50,9 @@ static struct fb_ops cg3_ops = {
50 .fb_imageblit = cfb_imageblit, 50 .fb_imageblit = cfb_imageblit,
51 .fb_mmap = cg3_mmap, 51 .fb_mmap = cg3_mmap,
52 .fb_ioctl = cg3_ioctl, 52 .fb_ioctl = cg3_ioctl,
53#ifdef CONFIG_COMPAT
54 .fb_compat_ioctl = sbusfb_compat_ioctl,
55#endif
53}; 56};
54 57
55 58
@@ -121,7 +124,6 @@ struct cg3_par {
121 unsigned long fbsize; 124 unsigned long fbsize;
122 125
123 struct sbus_dev *sdev; 126 struct sbus_dev *sdev;
124 struct list_head list;
125}; 127};
126 128
127/** 129/**
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index 414c4409e924..050835e39aa3 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -54,6 +54,9 @@ static struct fb_ops cg6_ops = {
54 .fb_sync = cg6_sync, 54 .fb_sync = cg6_sync,
55 .fb_mmap = cg6_mmap, 55 .fb_mmap = cg6_mmap,
56 .fb_ioctl = cg6_ioctl, 56 .fb_ioctl = cg6_ioctl,
57#ifdef CONFIG_COMPAT
58 .fb_compat_ioctl = sbusfb_compat_ioctl,
59#endif
57}; 60};
58 61
59/* Offset of interesting structures in the OBIO space */ 62/* Offset of interesting structures in the OBIO space */
@@ -262,7 +265,6 @@ struct cg6_par {
262 unsigned long fbsize; 265 unsigned long fbsize;
263 266
264 struct sbus_dev *sdev; 267 struct sbus_dev *sdev;
265 struct list_head list;
266}; 268};
267 269
268static int cg6_sync(struct fb_info *info) 270static int cg6_sync(struct fb_info *info)
@@ -609,7 +611,7 @@ static void cg6_chip_init(struct fb_info *info)
609 struct cg6_par *par = (struct cg6_par *) info->par; 611 struct cg6_par *par = (struct cg6_par *) info->par;
610 struct cg6_tec __iomem *tec = par->tec; 612 struct cg6_tec __iomem *tec = par->tec;
611 struct cg6_fbc __iomem *fbc = par->fbc; 613 struct cg6_fbc __iomem *fbc = par->fbc;
612 u32 rev, conf, mode, tmp; 614 u32 rev, conf, mode;
613 int i; 615 int i;
614 616
615 /* Turn off stuff in the Transform Engine. */ 617 /* Turn off stuff in the Transform Engine. */
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index 2858c5c8ba3c..e0dbdfc0c8b4 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -404,7 +404,7 @@ struct cirrusfb_info {
404 struct cirrusfb_regs currentmode; 404 struct cirrusfb_regs currentmode;
405 int blank_mode; 405 int blank_mode;
406 406
407 u32 pseudo_palette[17]; 407 u32 pseudo_palette[16];
408 struct { u8 red, green, blue, pad; } palette[256]; 408 struct { u8 red, green, blue, pad; } palette[256];
409 409
410#ifdef CONFIG_ZORRO 410#ifdef CONFIG_ZORRO
@@ -1603,14 +1603,14 @@ static int cirrusfb_setcolreg (unsigned regno, unsigned red, unsigned green,
1603 1603
1604 switch (info->var.bits_per_pixel) { 1604 switch (info->var.bits_per_pixel) {
1605 case 8: 1605 case 8:
1606 ((u8*)(info->pseudo_palette))[regno] = v; 1606 cinfo->pseudo_palette[regno] = v;
1607 break; 1607 break;
1608 case 16: 1608 case 16:
1609 ((u16*)(info->pseudo_palette))[regno] = v; 1609 cinfo->pseudo_palette[regno] = v;
1610 break; 1610 break;
1611 case 24: 1611 case 24:
1612 case 32: 1612 case 32:
1613 ((u32*)(info->pseudo_palette))[regno] = v; 1613 cinfo->pseudo_palette[regno] = v;
1614 break; 1614 break;
1615 } 1615 }
1616 return 0; 1616 return 0;
@@ -2020,18 +2020,21 @@ static void cirrusfb_prim_fillrect(struct cirrusfb_info *cinfo,
2020 const struct fb_fillrect *region) 2020 const struct fb_fillrect *region)
2021{ 2021{
2022 int m; /* bytes per pixel */ 2022 int m; /* bytes per pixel */
2023 u32 color = (cinfo->info->fix.visual == FB_VISUAL_TRUECOLOR) ?
2024 cinfo->pseudo_palette[region->color] : region->color;
2025
2023 if(cinfo->info->var.bits_per_pixel == 1) { 2026 if(cinfo->info->var.bits_per_pixel == 1) {
2024 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel, 2027 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel,
2025 region->dx / 8, region->dy, 2028 region->dx / 8, region->dy,
2026 region->width / 8, region->height, 2029 region->width / 8, region->height,
2027 region->color, 2030 color,
2028 cinfo->currentmode.line_length); 2031 cinfo->currentmode.line_length);
2029 } else { 2032 } else {
2030 m = ( cinfo->info->var.bits_per_pixel + 7 ) / 8; 2033 m = ( cinfo->info->var.bits_per_pixel + 7 ) / 8;
2031 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel, 2034 cirrusfb_RectFill(cinfo->regbase, cinfo->info->var.bits_per_pixel,
2032 region->dx * m, region->dy, 2035 region->dx * m, region->dy,
2033 region->width * m, region->height, 2036 region->width * m, region->height,
2034 region->color, 2037 color,
2035 cinfo->currentmode.line_length); 2038 cinfo->currentmode.line_length);
2036 } 2039 }
2037 return; 2040 return;
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig
index 94c5f1392cce..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
@@ -215,12 +215,5 @@ config FONT_10x18
215 big letters. It fits between the sun 12x22 and the normal 8x16 font. 215 big letters. It fits between the sun 12x22 and the normal 8x16 font.
216 If other fonts are too big or too small for you, say Y, otherwise say N. 216 If other fonts are too big or too small for you, say Y, otherwise say N.
217 217
218config FONT_RL
219 bool "console Roman Large 8x16 font" if FONTS
220 depends on FRAMEBUFFER_CONSOLE
221 help
222 This is the visually-appealing "RL" console font that is
223 included with the kbd package.
224
225endmenu 218endmenu
226 219
diff --git a/drivers/video/console/Makefile b/drivers/video/console/Makefile
index fed600c9ca55..9b26dda18a38 100644
--- a/drivers/video/console/Makefile
+++ b/drivers/video/console/Makefile
@@ -15,7 +15,6 @@ font-objs-$(CONFIG_FONT_10x18) += font_10x18.o
15font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o 15font-objs-$(CONFIG_FONT_PEARL_8x8) += font_pearl_8x8.o
16font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o 16font-objs-$(CONFIG_FONT_ACORN_8x8) += font_acorn_8x8.o
17font-objs-$(CONFIG_FONT_MINI_4x6) += font_mini_4x6.o 17font-objs-$(CONFIG_FONT_MINI_4x6) += font_mini_4x6.o
18font-objs-$(CONFIG_FONT_RL) += font_rl.o
19 18
20font-objs += $(font-objs-y) 19font-objs += $(font-objs-y)
21 20
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index e7802ffe549a..3660e51b2612 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -106,8 +106,7 @@ enum {
106 FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */ 106 FBCON_LOGO_DONTSHOW = -3 /* do not show the logo */
107}; 107};
108 108
109struct display fb_display[MAX_NR_CONSOLES]; 109static struct display fb_display[MAX_NR_CONSOLES];
110EXPORT_SYMBOL(fb_display);
111 110
112static signed char con2fb_map[MAX_NR_CONSOLES]; 111static signed char con2fb_map[MAX_NR_CONSOLES];
113static signed char con2fb_map_boot[MAX_NR_CONSOLES]; 112static signed char con2fb_map_boot[MAX_NR_CONSOLES];
@@ -653,13 +652,12 @@ static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
653{ 652{
654 struct fbcon_ops *ops = info->fbcon_par; 653 struct fbcon_ops *ops = info->fbcon_par;
655 654
655 ops->p = (p) ? p : &fb_display[vc->vc_num];
656
656 if ((info->flags & FBINFO_MISC_TILEBLITTING)) 657 if ((info->flags & FBINFO_MISC_TILEBLITTING))
657 fbcon_set_tileops(vc, info, p, ops); 658 fbcon_set_tileops(vc, info, p, ops);
658 else { 659 else {
659 struct display *disp; 660 fbcon_set_rotation(info, ops->p);
660
661 disp = (p) ? p : &fb_display[vc->vc_num];
662 fbcon_set_rotation(info, disp);
663 fbcon_set_bitops(ops); 661 fbcon_set_bitops(ops);
664 } 662 }
665} 663}
@@ -668,11 +666,10 @@ static void set_blitting_type(struct vc_data *vc, struct fb_info *info,
668 struct display *p) 666 struct display *p)
669{ 667{
670 struct fbcon_ops *ops = info->fbcon_par; 668 struct fbcon_ops *ops = info->fbcon_par;
671 struct display *disp;
672 669
673 info->flags &= ~FBINFO_MISC_TILEBLITTING; 670 info->flags &= ~FBINFO_MISC_TILEBLITTING;
674 disp = (p) ? p : &fb_display[vc->vc_num]; 671 ops->p = (p) ? p : &fb_display[vc->vc_num];
675 fbcon_set_rotation(info, disp); 672 fbcon_set_rotation(info, ops->p);
676 fbcon_set_bitops(ops); 673 fbcon_set_bitops(ops);
677} 674}
678#endif /* CONFIG_MISC_TILEBLITTING */ 675#endif /* CONFIG_MISC_TILEBLITTING */
@@ -2051,7 +2048,7 @@ static int fbcon_switch(struct vc_data *vc)
2051 struct fbcon_ops *ops; 2048 struct fbcon_ops *ops;
2052 struct display *p = &fb_display[vc->vc_num]; 2049 struct display *p = &fb_display[vc->vc_num];
2053 struct fb_var_screeninfo var; 2050 struct fb_var_screeninfo var;
2054 int i, prev_console; 2051 int i, prev_console, charcnt = 256;
2055 2052
2056 info = registered_fb[con2fb_map[vc->vc_num]]; 2053 info = registered_fb[con2fb_map[vc->vc_num]];
2057 ops = info->fbcon_par; 2054 ops = info->fbcon_par;
@@ -2106,7 +2103,8 @@ static int fbcon_switch(struct vc_data *vc)
2106 fb_set_var(info, &var); 2103 fb_set_var(info, &var);
2107 ops->var = info->var; 2104 ops->var = info->var;
2108 2105
2109 if (old_info != NULL && old_info != info) { 2106 if (old_info != NULL && (old_info != info ||
2107 info->flags & FBINFO_MISC_ALWAYS_SETPAR)) {
2110 if (info->fbops->fb_set_par) 2108 if (info->fbops->fb_set_par)
2111 info->fbops->fb_set_par(info); 2109 info->fbops->fb_set_par(info);
2112 fbcon_del_cursor_timer(old_info); 2110 fbcon_del_cursor_timer(old_info);
@@ -2123,6 +2121,13 @@ static int fbcon_switch(struct vc_data *vc)
2123 2121
2124 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);
2125 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
2126 updatescrollmode(p, info, vc); 2131 updatescrollmode(p, info, vc);
2127 2132
2128 switch (p->scrollmode) { 2133 switch (p->scrollmode) {
@@ -2142,8 +2147,12 @@ static int fbcon_switch(struct vc_data *vc)
2142 2147
2143 scrollback_max = 0; 2148 scrollback_max = 0;
2144 scrollback_current = 0; 2149 scrollback_current = 0;
2145 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; 2150
2146 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
2147 fbcon_set_palette(vc, color_table); 2156 fbcon_set_palette(vc, color_table);
2148 fbcon_clear_margins(vc, 0); 2157 fbcon_clear_margins(vc, 0);
2149 2158
@@ -2187,11 +2196,14 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch)
2187 ops->graphics = 1; 2196 ops->graphics = 1;
2188 2197
2189 if (!blank) { 2198 if (!blank) {
2199 if (info->fbops->fb_save_state)
2200 info->fbops->fb_save_state(info);
2190 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE; 2201 var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE;
2191 fb_set_var(info, &var); 2202 fb_set_var(info, &var);
2192 ops->graphics = 0; 2203 ops->graphics = 0;
2193 ops->var = info->var; 2204 ops->var = info->var;
2194 } 2205 } else if (info->fbops->fb_restore_state)
2206 info->fbops->fb_restore_state(info);
2195 } 2207 }
2196 2208
2197 if (!fbcon_is_inactive(vc, info)) { 2209 if (!fbcon_is_inactive(vc, info)) {
@@ -2739,8 +2751,12 @@ static void fbcon_modechanged(struct fb_info *info)
2739 updatescrollmode(p, info, vc); 2751 updatescrollmode(p, info, vc);
2740 scrollback_max = 0; 2752 scrollback_max = 0;
2741 scrollback_current = 0; 2753 scrollback_current = 0;
2742 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; 2754
2743 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
2744 fbcon_set_palette(vc, color_table); 2760 fbcon_set_palette(vc, color_table);
2745 update_screen(vc); 2761 update_screen(vc);
2746 if (softback_buf) 2762 if (softback_buf)
@@ -2777,8 +2793,13 @@ static void fbcon_set_all_vcs(struct fb_info *info)
2777 updatescrollmode(p, info, vc); 2793 updatescrollmode(p, info, vc);
2778 scrollback_max = 0; 2794 scrollback_max = 0;
2779 scrollback_current = 0; 2795 scrollback_current = 0;
2780 ops->var.xoffset = ops->var.yoffset = p->yscroll = 0; 2796
2781 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
2782 fbcon_set_palette(vc, color_table); 2803 fbcon_set_palette(vc, color_table);
2783 update_screen(vc); 2804 update_screen(vc);
2784 if (softback_buf) 2805 if (softback_buf)
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index accfd7bd8e93..6892e7ff34de 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -52,8 +52,6 @@ struct display {
52 struct fb_videomode *mode; 52 struct fb_videomode *mode;
53}; 53};
54 54
55extern struct display fb_display[];
56
57struct fbcon_ops { 55struct fbcon_ops {
58 void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy, 56 void (*bmove)(struct vc_data *vc, struct fb_info *info, int sy,
59 int sx, int dy, int dx, int height, int width); 57 int sx, int dy, int dx, int height, int width);
@@ -73,6 +71,7 @@ struct fbcon_ops {
73 struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */ 71 struct fb_var_screeninfo var; /* copy of the current fb_var_screeninfo */
74 struct timer_list cursor_timer; /* Cursor timer */ 72 struct timer_list cursor_timer; /* Cursor timer */
75 struct fb_cursor cursor_state; 73 struct fb_cursor cursor_state;
74 struct display *p;
76 int currcon; /* Current VC. */ 75 int currcon; /* Current VC. */
77 int cursor_flash; 76 int cursor_flash;
78 int cursor_reset; 77 int cursor_reset;
diff --git a/drivers/video/console/fbcon_ccw.c b/drivers/video/console/fbcon_ccw.c
index 680aabab73c5..4952b66ae206 100644
--- a/drivers/video/console/fbcon_ccw.c
+++ b/drivers/video/console/fbcon_ccw.c
@@ -34,7 +34,7 @@ static inline void ccw_update_attr(u8 *dst, u8 *src, int attribute,
34 msk <<= (8 - mod); 34 msk <<= (8 - mod);
35 35
36 if (offset > mod) 36 if (offset > mod)
37 set_bit(FBCON_BIT(7), (void *)&msk1); 37 msk1 |= 0x01;
38 38
39 for (i = 0; i < vc->vc_font.width; i++) { 39 for (i = 0; i < vc->vc_font.width; i++) {
40 for (j = 0; j < width; j++) { 40 for (j = 0; j < width; j++) {
@@ -63,9 +63,9 @@ static inline void ccw_update_attr(u8 *dst, u8 *src, int attribute,
63static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy, 63static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
64 int sx, int dy, int dx, int height, int width) 64 int sx, int dy, int dx, int height, int width)
65{ 65{
66 struct display *p = &fb_display[vc->vc_num]; 66 struct fbcon_ops *ops = info->fbcon_par;
67 struct fb_copyarea area; 67 struct fb_copyarea area;
68 u32 vyres = GETVYRES(p->scrollmode, info); 68 u32 vyres = GETVYRES(ops->p->scrollmode, info);
69 69
70 area.sx = sy * vc->vc_font.height; 70 area.sx = sy * vc->vc_font.height;
71 area.sy = vyres - ((sx + width) * vc->vc_font.width); 71 area.sy = vyres - ((sx + width) * vc->vc_font.width);
@@ -80,10 +80,10 @@ static void ccw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
80static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy, 80static void ccw_clear(struct vc_data *vc, struct fb_info *info, int sy,
81 int sx, int height, int width) 81 int sx, int height, int width)
82{ 82{
83 struct display *p = &fb_display[vc->vc_num]; 83 struct fbcon_ops *ops = info->fbcon_par;
84 struct fb_fillrect region; 84 struct fb_fillrect region;
85 int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; 85 int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
86 u32 vyres = GETVYRES(p->scrollmode, info); 86 u32 vyres = GETVYRES(ops->p->scrollmode, info);
87 87
88 region.color = attr_bgcol_ec(bgshift,vc); 88 region.color = attr_bgcol_ec(bgshift,vc);
89 region.dx = sy * vc->vc_font.height; 89 region.dx = sy * vc->vc_font.height;
@@ -131,7 +131,6 @@ static void ccw_putcs(struct vc_data *vc, struct fb_info *info,
131 int fg, int bg) 131 int fg, int bg)
132{ 132{
133 struct fb_image image; 133 struct fb_image image;
134 struct display *p = &fb_display[vc->vc_num];
135 struct fbcon_ops *ops = info->fbcon_par; 134 struct fbcon_ops *ops = info->fbcon_par;
136 u32 width = (vc->vc_font.height + 7)/8; 135 u32 width = (vc->vc_font.height + 7)/8;
137 u32 cellsize = width * vc->vc_font.width; 136 u32 cellsize = width * vc->vc_font.width;
@@ -141,7 +140,7 @@ static void ccw_putcs(struct vc_data *vc, struct fb_info *info,
141 u32 cnt, pitch, size; 140 u32 cnt, pitch, size;
142 u32 attribute = get_attribute(info, scr_readw(s)); 141 u32 attribute = get_attribute(info, scr_readw(s));
143 u8 *dst, *buf = NULL; 142 u8 *dst, *buf = NULL;
144 u32 vyres = GETVYRES(p->scrollmode, info); 143 u32 vyres = GETVYRES(ops->p->scrollmode, info);
145 144
146 if (!ops->fontbuffer) 145 if (!ops->fontbuffer)
147 return; 146 return;
@@ -397,9 +396,8 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info,
397int ccw_update_start(struct fb_info *info) 396int ccw_update_start(struct fb_info *info)
398{ 397{
399 struct fbcon_ops *ops = info->fbcon_par; 398 struct fbcon_ops *ops = info->fbcon_par;
400 struct display *p = &fb_display[ops->currcon];
401 u32 yoffset; 399 u32 yoffset;
402 u32 vyres = GETVYRES(p->scrollmode, info); 400 u32 vyres = GETVYRES(ops->p->scrollmode, info);
403 int err; 401 int err;
404 402
405 yoffset = (vyres - info->var.yres) - ops->var.xoffset; 403 yoffset = (vyres - info->var.yres) - ops->var.xoffset;
diff --git a/drivers/video/console/fbcon_cw.c b/drivers/video/console/fbcon_cw.c
index 6c6f3b6dd175..6d92b8456206 100644
--- a/drivers/video/console/fbcon_cw.c
+++ b/drivers/video/console/fbcon_cw.c
@@ -49,9 +49,9 @@ static inline void cw_update_attr(u8 *dst, u8 *src, int attribute,
49static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy, 49static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
50 int sx, int dy, int dx, int height, int width) 50 int sx, int dy, int dx, int height, int width)
51{ 51{
52 struct display *p = &fb_display[vc->vc_num]; 52 struct fbcon_ops *ops = info->fbcon_par;
53 struct fb_copyarea area; 53 struct fb_copyarea area;
54 u32 vxres = GETVXRES(p->scrollmode, info); 54 u32 vxres = GETVXRES(ops->p->scrollmode, info);
55 55
56 area.sx = vxres - ((sy + height) * vc->vc_font.height); 56 area.sx = vxres - ((sy + height) * vc->vc_font.height);
57 area.sy = sx * vc->vc_font.width; 57 area.sy = sx * vc->vc_font.width;
@@ -66,10 +66,10 @@ static void cw_bmove(struct vc_data *vc, struct fb_info *info, int sy,
66static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy, 66static void cw_clear(struct vc_data *vc, struct fb_info *info, int sy,
67 int sx, int height, int width) 67 int sx, int height, int width)
68{ 68{
69 struct display *p = &fb_display[vc->vc_num]; 69 struct fbcon_ops *ops = info->fbcon_par;
70 struct fb_fillrect region; 70 struct fb_fillrect region;
71 int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; 71 int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
72 u32 vxres = GETVXRES(p->scrollmode, info); 72 u32 vxres = GETVXRES(ops->p->scrollmode, info);
73 73
74 region.color = attr_bgcol_ec(bgshift,vc); 74 region.color = attr_bgcol_ec(bgshift,vc);
75 region.dx = vxres - ((sy + height) * vc->vc_font.height); 75 region.dx = vxres - ((sy + height) * vc->vc_font.height);
@@ -117,7 +117,6 @@ static void cw_putcs(struct vc_data *vc, struct fb_info *info,
117 int fg, int bg) 117 int fg, int bg)
118{ 118{
119 struct fb_image image; 119 struct fb_image image;
120 struct display *p = &fb_display[vc->vc_num];
121 struct fbcon_ops *ops = info->fbcon_par; 120 struct fbcon_ops *ops = info->fbcon_par;
122 u32 width = (vc->vc_font.height + 7)/8; 121 u32 width = (vc->vc_font.height + 7)/8;
123 u32 cellsize = width * vc->vc_font.width; 122 u32 cellsize = width * vc->vc_font.width;
@@ -127,7 +126,7 @@ static void cw_putcs(struct vc_data *vc, struct fb_info *info,
127 u32 cnt, pitch, size; 126 u32 cnt, pitch, size;
128 u32 attribute = get_attribute(info, scr_readw(s)); 127 u32 attribute = get_attribute(info, scr_readw(s));
129 u8 *dst, *buf = NULL; 128 u8 *dst, *buf = NULL;
130 u32 vxres = GETVXRES(p->scrollmode, info); 129 u32 vxres = GETVXRES(ops->p->scrollmode, info);
131 130
132 if (!ops->fontbuffer) 131 if (!ops->fontbuffer)
133 return; 132 return;
@@ -381,8 +380,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info,
381int cw_update_start(struct fb_info *info) 380int cw_update_start(struct fb_info *info)
382{ 381{
383 struct fbcon_ops *ops = info->fbcon_par; 382 struct fbcon_ops *ops = info->fbcon_par;
384 struct display *p = &fb_display[ops->currcon]; 383 u32 vxres = GETVXRES(ops->p->scrollmode, info);
385 u32 vxres = GETVXRES(p->scrollmode, info);
386 u32 xoffset; 384 u32 xoffset;
387 int err; 385 int err;
388 386
diff --git a/drivers/video/console/fbcon_rotate.h b/drivers/video/console/fbcon_rotate.h
index 90c672096c2e..1b8f92fdc6a8 100644
--- a/drivers/video/console/fbcon_rotate.h
+++ b/drivers/video/console/fbcon_rotate.h
@@ -21,21 +21,13 @@
21 (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \ 21 (s == SCROLL_REDRAW || s == SCROLL_MOVE || !(i)->fix.xpanstep) ? \
22 (i)->var.xres : (i)->var.xres_virtual; }) 22 (i)->var.xres : (i)->var.xres_virtual; })
23 23
24/*
25 * The bitmap is always big endian
26 */
27#if defined(__LITTLE_ENDIAN)
28#define FBCON_BIT(b) (7 - (b))
29#else
30#define FBCON_BIT(b) (b)
31#endif
32 24
33static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat) 25static inline int pattern_test_bit(u32 x, u32 y, u32 pitch, const char *pat)
34{ 26{
35 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8; 27 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
36 28
37 pat +=index; 29 pat +=index;
38 return (test_bit(FBCON_BIT(bit), (void *)pat)); 30 return (*pat) & (0x80 >> bit);
39} 31}
40 32
41static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat) 33static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
@@ -43,13 +35,14 @@ static inline void pattern_set_bit(u32 x, u32 y, u32 pitch, char *pat)
43 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8; 35 u32 tmp = (y * pitch) + x, index = tmp / 8, bit = tmp % 8;
44 36
45 pat += index; 37 pat += index;
46 set_bit(FBCON_BIT(bit), (void *)pat); 38
39 (*pat) |= 0x80 >> bit;
47} 40}
48 41
49static inline void rotate_ud(const char *in, char *out, u32 width, u32 height) 42static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
50{ 43{
51 int i, j; 44 int i, j;
52 int shift = width % 8; 45 int shift = (8 - (width % 8)) & 7;
53 46
54 width = (width + 7) & ~7; 47 width = (width + 7) & ~7;
55 48
@@ -85,7 +78,7 @@ static inline void rotate_cw(const char *in, char *out, u32 width, u32 height)
85static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height) 78static inline void rotate_ccw(const char *in, char *out, u32 width, u32 height)
86{ 79{
87 int i, j, h = height, w = width; 80 int i, j, h = height, w = width;
88 int shift = width % 8; 81 int shift = (8 - (width % 8)) & 7;
89 82
90 width = (width + 7) & ~7; 83 width = (width + 7) & ~7;
91 height = (height + 7) & ~7; 84 height = (height + 7) & ~7;
diff --git a/drivers/video/console/fbcon_ud.c b/drivers/video/console/fbcon_ud.c
index 2e1d9d4249cd..9dd059e8b645 100644
--- a/drivers/video/console/fbcon_ud.c
+++ b/drivers/video/console/fbcon_ud.c
@@ -48,10 +48,10 @@ static inline void ud_update_attr(u8 *dst, u8 *src, int attribute,
48static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy, 48static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy,
49 int sx, int dy, int dx, int height, int width) 49 int sx, int dy, int dx, int height, int width)
50{ 50{
51 struct display *p = &fb_display[vc->vc_num]; 51 struct fbcon_ops *ops = info->fbcon_par;
52 struct fb_copyarea area; 52 struct fb_copyarea area;
53 u32 vyres = GETVYRES(p->scrollmode, info); 53 u32 vyres = GETVYRES(ops->p->scrollmode, info);
54 u32 vxres = GETVXRES(p->scrollmode, info); 54 u32 vxres = GETVXRES(ops->p->scrollmode, info);
55 55
56 area.sy = vyres - ((sy + height) * vc->vc_font.height); 56 area.sy = vyres - ((sy + height) * vc->vc_font.height);
57 area.sx = vxres - ((sx + width) * vc->vc_font.width); 57 area.sx = vxres - ((sx + width) * vc->vc_font.width);
@@ -66,11 +66,11 @@ static void ud_bmove(struct vc_data *vc, struct fb_info *info, int sy,
66static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy, 66static void ud_clear(struct vc_data *vc, struct fb_info *info, int sy,
67 int sx, int height, int width) 67 int sx, int height, int width)
68{ 68{
69 struct display *p = &fb_display[vc->vc_num]; 69 struct fbcon_ops *ops = info->fbcon_par;
70 struct fb_fillrect region; 70 struct fb_fillrect region;
71 int bgshift = (vc->vc_hi_font_mask) ? 13 : 12; 71 int bgshift = (vc->vc_hi_font_mask) ? 13 : 12;
72 u32 vyres = GETVYRES(p->scrollmode, info); 72 u32 vyres = GETVYRES(ops->p->scrollmode, info);
73 u32 vxres = GETVXRES(p->scrollmode, info); 73 u32 vxres = GETVXRES(ops->p->scrollmode, info);
74 74
75 region.color = attr_bgcol_ec(bgshift,vc); 75 region.color = attr_bgcol_ec(bgshift,vc);
76 region.dy = vyres - ((sy + height) * vc->vc_font.height); 76 region.dy = vyres - ((sy + height) * vc->vc_font.height);
@@ -153,7 +153,6 @@ static void ud_putcs(struct vc_data *vc, struct fb_info *info,
153 int fg, int bg) 153 int fg, int bg)
154{ 154{
155 struct fb_image image; 155 struct fb_image image;
156 struct display *p = &fb_display[vc->vc_num];
157 struct fbcon_ops *ops = info->fbcon_par; 156 struct fbcon_ops *ops = info->fbcon_par;
158 u32 width = (vc->vc_font.width + 7)/8; 157 u32 width = (vc->vc_font.width + 7)/8;
159 u32 cellsize = width * vc->vc_font.height; 158 u32 cellsize = width * vc->vc_font.height;
@@ -163,8 +162,8 @@ static void ud_putcs(struct vc_data *vc, struct fb_info *info,
163 u32 mod = vc->vc_font.width % 8, cnt, pitch, size; 162 u32 mod = vc->vc_font.width % 8, cnt, pitch, size;
164 u32 attribute = get_attribute(info, scr_readw(s)); 163 u32 attribute = get_attribute(info, scr_readw(s));
165 u8 *dst, *buf = NULL; 164 u8 *dst, *buf = NULL;
166 u32 vyres = GETVYRES(p->scrollmode, info); 165 u32 vyres = GETVYRES(ops->p->scrollmode, info);
167 u32 vxres = GETVXRES(p->scrollmode, info); 166 u32 vxres = GETVXRES(ops->p->scrollmode, info);
168 167
169 if (!ops->fontbuffer) 168 if (!ops->fontbuffer)
170 return; 169 return;
@@ -421,14 +420,15 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info,
421int ud_update_start(struct fb_info *info) 420int ud_update_start(struct fb_info *info)
422{ 421{
423 struct fbcon_ops *ops = info->fbcon_par; 422 struct fbcon_ops *ops = info->fbcon_par;
424 struct display *p = &fb_display[ops->currcon]; 423 int xoffset, yoffset;
425 u32 xoffset, yoffset; 424 u32 vyres = GETVYRES(ops->p->scrollmode, info);
426 u32 vyres = GETVYRES(p->scrollmode, info); 425 u32 vxres = GETVXRES(ops->p->scrollmode, info);
427 u32 vxres = GETVXRES(p->scrollmode, info);
428 int err; 426 int err;
429 427
430 xoffset = (vxres - info->var.xres) - ops->var.xoffset; 428 xoffset = vxres - info->var.xres - ops->var.xoffset;
431 yoffset = (vyres - info->var.yres) - ops->var.yoffset; 429 yoffset = vyres - info->var.yres - ops->var.yoffset;
430 if (yoffset < 0)
431 yoffset += vyres;
432 ops->var.xoffset = xoffset; 432 ops->var.xoffset = xoffset;
433 ops->var.yoffset = yoffset; 433 ops->var.yoffset = yoffset;
434 err = fb_pan_display(info, &ops->var); 434 err = fb_pan_display(info, &ops->var);
diff --git a/drivers/video/console/font_rl.c b/drivers/video/console/font_rl.c
deleted file mode 100644
index dfecc27d8ded..000000000000
--- a/drivers/video/console/font_rl.c
+++ /dev/null
@@ -1,4374 +0,0 @@
1
2/* This font is simply the "rl.fnt" console font from the kbd utility.
3 * Converted by Zack T Smith, fbui@comcast.net.
4 * The original binary file is covered under the GNU Public License.
5 */
6
7#include <linux/font.h>
8
9#define FONTDATAMAX 4096
10
11static unsigned char patterns[4096] = {
120x00,
130x00,
140x00,
150x00,
160x00,
170x00,
180x00,
190x00,
200x00,
210x00,
220x00,
230x00,
240x00,
250x00,
260x00,
270x00,
28
290x00,
300x00,
310x3c,
320x42,
330x81,
340xe7,
350xa5,
360x99,
370x81,
380x81,
390x99,
400x42,
410x3c,
420x00,
430x00,
440x00,
45
460x00,
470x00,
480x3c,
490x7e,
500xff,
510x99,
520xdb,
530xe7,
540xff,
550xff,
560xe7,
570x7e,
580x3c,
590x00,
600x00,
610x00,
62
630x00,
640x00,
650x00,
660x6c,
670xfe,
680xfe,
690xfe,
700xfe,
710xfe,
720x7c,
730x38,
740x10,
750x00,
760x00,
770x00,
780x00,
79
800x00,
810x00,
820x00,
830x00,
840x10,
850x38,
860x7c,
870xfe,
880x7c,
890x38,
900x10,
910x00,
920x00,
930x00,
940x00,
950x00,
96
970x00,
980x00,
990x38,
1000x38,
1010x10,
1020xd6,
1030xfe,
1040xd6,
1050x10,
1060x10,
1070x38,
1080x7c,
1090x00,
1100x00,
1110x00,
1120x00,
113
1140x00,
1150x00,
1160x10,
1170x38,
1180x7c,
1190xfe,
1200xfe,
1210x54,
1220x10,
1230x10,
1240x38,
1250x7c,
1260x00,
1270x00,
1280x00,
1290x00,
130
1310x00,
1320x00,
1330x00,
1340x00,
1350x00,
1360x00,
1370x18,
1380x3c,
1390x3c,
1400x18,
1410x00,
1420x00,
1430x00,
1440x00,
1450x00,
1460x00,
147
1480xff,
1490xff,
1500xff,
1510xff,
1520xff,
1530xff,
1540xe7,
1550xc3,
1560xc3,
1570xe7,
1580xff,
1590xff,
1600xff,
1610xff,
1620xff,
1630xff,
164
1650x00,
1660x00,
1670x00,
1680x00,
1690x00,
1700x3c,
1710x66,
1720x42,
1730x42,
1740x66,
1750x3c,
1760x00,
1770x00,
1780x00,
1790x00,
1800x00,
181
1820xff,
1830xff,
1840xff,
1850xff,
1860xff,
1870xc3,
1880x99,
1890xbd,
1900xbd,
1910x99,
1920xc3,
1930xff,
1940xff,
1950xff,
1960xff,
1970xff,
198
1990x00,
2000x00,
2010x0f,
2020x07,
2030x0d,
2040x18,
2050x78,
2060xcc,
2070xcc,
2080xcc,
2090xcc,
2100x78,
2110x00,
2120x00,
2130x00,
2140x00,
215
2160x00,
2170x00,
2180x3c,
2190x66,
2200x66,
2210x66,
2220x3c,
2230x18,
2240x7e,
2250x18,
2260x18,
2270x18,
2280x00,
2290x00,
2300x00,
2310x00,
232
2330x00,
2340x08,
2350x0c,
2360x0a,
2370x0a,
2380x0a,
2390x08,
2400x08,
2410x08,
2420x38,
2430x78,
2440x30,
2450x00,
2460x00,
2470x00,
2480x00,
249
2500x00,
2510x10,
2520x18,
2530x1c,
2540x1e,
2550x1e,
2560x16,
2570x12,
2580x72,
2590xf2,
2600x62,
2610x0e,
2620x1e,
2630x0c,
2640x00,
2650x00,
266
2670x00,
2680x00,
2690x00,
2700x10,
2710x92,
2720x54,
2730x38,
2740xfe,
2750x38,
2760x54,
2770x92,
2780x10,
2790x00,
2800x00,
2810x00,
2820x00,
283
2840x00,
2850x00,
2860x00,
2870x80,
2880xc0,
2890xe0,
2900xb8,
2910x8e,
2920xb8,
2930xe0,
2940xc0,
2950x80,
2960x00,
2970x00,
2980x00,
2990x00,
300
3010x00,
3020x00,
3030x00,
3040x02,
3050x06,
3060x0e,
3070x3a,
3080xe2,
3090x3a,
3100x0e,
3110x06,
3120x02,
3130x00,
3140x00,
3150x00,
3160x00,
317
3180x00,
3190x00,
3200x10,
3210x38,
3220x7c,
3230xd6,
3240x10,
3250x10,
3260x10,
3270x10,
3280xd6,
3290x7c,
3300x38,
3310x10,
3320x00,
3330x00,
334
3350x00,
3360x42,
3370xe7,
3380xe7,
3390xe7,
3400xe7,
3410x42,
3420x42,
3430x42,
3440x00,
3450x66,
3460x66,
3470x66,
3480x00,
3490x00,
3500x00,
351
3520x00,
3530x7f,
3540xca,
3550xca,
3560xca,
3570xca,
3580x7a,
3590x0a,
3600x0a,
3610x0a,
3620x0a,
3630x0a,
3640x1b,
3650x00,
3660x00,
3670x00,
368
3690x00,
3700x1e,
3710x31,
3720x78,
3730xcc,
3740xc6,
3750xc3,
3760x63,
3770x33,
3780x1e,
3790x8c,
3800x78,
3810x00,
3820x00,
3830x00,
3840x00,
385
3860x00,
3870x00,
3880x00,
3890x00,
3900x00,
3910x00,
3920x00,
3930x00,
3940xfe,
3950xfe,
3960xfe,
3970xfe,
3980x00,
3990x00,
4000x00,
4010x00,
402
4030x00,
4040x00,
4050x10,
4060x38,
4070x7c,
4080xd6,
4090x10,
4100x10,
4110x10,
4120x10,
4130xd6,
4140x7c,
4150x38,
4160x10,
4170xfe,
4180x00,
419
4200x00,
4210x00,
4220x10,
4230x38,
4240x7c,
4250xd6,
4260x10,
4270x10,
4280x10,
4290x10,
4300x10,
4310x10,
4320x10,
4330x10,
4340x00,
4350x00,
436
4370x00,
4380x00,
4390x10,
4400x10,
4410x10,
4420x10,
4430x10,
4440x10,
4450x10,
4460x10,
4470xd6,
4480x7c,
4490x38,
4500x10,
4510x00,
4520x00,
453
4540x00,
4550x00,
4560x00,
4570x00,
4580x00,
4590x08,
4600x0c,
4610x06,
4620xff,
4630x06,
4640x0c,
4650x08,
4660x00,
4670x00,
4680x00,
4690x00,
470
4710x00,
4720x00,
4730x00,
4740x00,
4750x00,
4760x10,
4770x30,
4780x60,
4790xff,
4800x60,
4810x30,
4820x10,
4830x00,
4840x00,
4850x00,
4860x00,
487
4880x22,
4890x44,
4900x88,
4910xcc,
4920xee,
4930x44,
4940x00,
4950x00,
4960x00,
4970x00,
4980x00,
4990x00,
5000x00,
5010x00,
5020x00,
5030x00,
504
5050x00,
5060x00,
5070x00,
5080x00,
5090x00,
5100x24,
5110x42,
5120xff,
5130x42,
5140x24,
5150x00,
5160x00,
5170x00,
5180x00,
5190x00,
5200x00,
521
5220x00,
5230x00,
5240x00,
5250x10,
5260x38,
5270x38,
5280x6c,
5290x6c,
5300xc6,
5310xfe,
5320x00,
5330x00,
5340x00,
5350x00,
5360x00,
5370x00,
538
5390x00,
5400x00,
5410x00,
5420xfe,
5430xc6,
5440x6c,
5450x6c,
5460x38,
5470x38,
5480x10,
5490x00,
5500x00,
5510x00,
5520x00,
5530x00,
5540x00,
555
5560x00,
5570x00,
5580x00,
5590x00,
5600x00,
5610x00,
5620x00,
5630x00,
5640x00,
5650x00,
5660x00,
5670x00,
5680x00,
5690x00,
5700x00,
5710x00,
572
5730x00,
5740x18,
5750x3c,
5760x3c,
5770x3c,
5780x3c,
5790x18,
5800x18,
5810x18,
5820x10,
5830x00,
5840x18,
5850x18,
5860x00,
5870x00,
5880x00,
589
5900x22,
5910x77,
5920x33,
5930x11,
5940x22,
5950x44,
5960x00,
5970x00,
5980x00,
5990x00,
6000x00,
6010x00,
6020x00,
6030x00,
6040x00,
6050x00,
606
6070x00,
6080x00,
6090x12,
6100x12,
6110x12,
6120x7f,
6130x24,
6140x24,
6150x24,
6160xfe,
6170x48,
6180x48,
6190x48,
6200x00,
6210x00,
6220x00,
623
6240x10,
6250x10,
6260x7c,
6270xd2,
6280xd0,
6290xd0,
6300xd0,
6310x7c,
6320x16,
6330x16,
6340x16,
6350x96,
6360x7c,
6370x10,
6380x10,
6390x00,
640
6410x00,
6420x42,
6430xbe,
6440x44,
6450x0c,
6460x08,
6470x18,
6480x10,
6490x30,
6500x20,
6510x64,
6520x4a,
6530xc4,
6540x00,
6550x00,
6560x00,
657
6580x00,
6590x38,
6600x6c,
6610x6c,
6620x6c,
6630x38,
6640x37,
6650x72,
6660xdc,
6670xcc,
6680xcc,
6690xcc,
6700x77,
6710x00,
6720x00,
6730x00,
674
6750x10,
6760x38,
6770x18,
6780x08,
6790x10,
6800x20,
6810x00,
6820x00,
6830x00,
6840x00,
6850x00,
6860x00,
6870x00,
6880x00,
6890x00,
6900x00,
691
6920x00,
6930x04,
6940x08,
6950x10,
6960x10,
6970x30,
6980x30,
6990x30,
7000x30,
7010x30,
7020x10,
7030x10,
7040x08,
7050x04,
7060x00,
7070x00,
708
7090x00,
7100x20,
7110x10,
7120x08,
7130x08,
7140x0c,
7150x0c,
7160x0c,
7170x0c,
7180x0c,
7190x08,
7200x08,
7210x10,
7220x20,
7230x00,
7240x00,
725
7260x00,
7270x00,
7280x00,
7290x00,
7300x44,
7310x28,
7320x38,
7330xfe,
7340x38,
7350x28,
7360x44,
7370x00,
7380x00,
7390x00,
7400x00,
7410x00,
742
7430x00,
7440x00,
7450x00,
7460x00,
7470x00,
7480x18,
7490x18,
7500x7e,
7510x18,
7520x18,
7530x00,
7540x00,
7550x00,
7560x00,
7570x00,
7580x00,
759
7600x00,
7610x00,
7620x00,
7630x00,
7640x00,
7650x00,
7660x00,
7670x00,
7680x00,
7690x00,
7700x10,
7710x38,
7720x18,
7730x08,
7740x10,
7750x20,
776
7770x00,
7780x00,
7790x00,
7800x00,
7810x00,
7820x00,
7830x00,
7840x7e,
7850x00,
7860x00,
7870x00,
7880x00,
7890x00,
7900x00,
7910x00,
7920x00,
793
7940x00,
7950x00,
7960x00,
7970x00,
7980x00,
7990x00,
8000x00,
8010x00,
8020x00,
8030x00,
8040x10,
8050x38,
8060x10,
8070x00,
8080x00,
8090x00,
810
8110x00,
8120x06,
8130x06,
8140x0c,
8150x0c,
8160x18,
8170x18,
8180x30,
8190x30,
8200x60,
8210x60,
8220xc0,
8230xc0,
8240x00,
8250x00,
8260x00,
827
8280x00,
8290x00,
8300x00,
8310x00,
8320x3c,
8330x46,
8340xc6,
8350xc6,
8360xc6,
8370xc6,
8380xc6,
8390xc4,
8400x78,
8410x00,
8420x00,
8430x00,
844
8450x00,
8460x00,
8470x00,
8480x00,
8490x08,
8500x18,
8510x78,
8520x18,
8530x18,
8540x18,
8550x18,
8560x18,
8570x7e,
8580x00,
8590x00,
8600x00,
861
8620x00,
8630x00,
8640x00,
8650x00,
8660x7c,
8670x86,
8680x06,
8690x0c,
8700x18,
8710x20,
8720x40,
8730xc1,
8740xfe,
8750x00,
8760x00,
8770x00,
878
8790x00,
8800x00,
8810x00,
8820x00,
8830x3c,
8840x46,
8850x04,
8860x08,
8870x1c,
8880x06,
8890x06,
8900x06,
8910x06,
8920x0c,
8930x70,
8940x00,
895
8960x00,
8970x00,
8980x00,
8990x00,
9000x04,
9010x08,
9020x10,
9030x2c,
9040x4c,
9050x8c,
9060x8c,
9070xfe,
9080x0c,
9090x0c,
9100x0c,
9110x00,
912
9130x00,
9140x00,
9150x00,
9160x02,
9170x3c,
9180x20,
9190x20,
9200x70,
9210x0c,
9220x06,
9230x06,
9240x06,
9250x06,
9260x0c,
9270x70,
9280x00,
929
9300x00,
9310x00,
9320x18,
9330x20,
9340x40,
9350xc0,
9360xdc,
9370xc6,
9380xc6,
9390xc6,
9400xc6,
9410x44,
9420x38,
9430x00,
9440x00,
9450x00,
946
9470x00,
9480x00,
9490x00,
9500x40,
9510x7e,
9520x82,
9530x06,
9540x04,
9550x0c,
9560x18,
9570x18,
9580x30,
9590x30,
9600x30,
9610x30,
9620x00,
963
9640x00,
9650x00,
9660x7c,
9670xc6,
9680xc6,
9690x64,
9700x38,
9710x4c,
9720xc6,
9730xc6,
9740xc6,
9750xc6,
9760x7c,
9770x00,
9780x00,
9790x00,
980
9810x00,
9820x00,
9830x00,
9840x00,
9850x38,
9860x44,
9870xc6,
9880xc6,
9890x76,
9900x06,
9910x06,
9920x06,
9930x04,
9940x08,
9950x30,
9960x00,
997
9980x00,
9990x00,
10000x00,
10010x00,
10020x10,
10030x38,
10040x10,
10050x00,
10060x00,
10070x00,
10080x10,
10090x38,
10100x10,
10110x00,
10120x00,
10130x00,
1014
10150x00,
10160x00,
10170x00,
10180x00,
10190x10,
10200x38,
10210x10,
10220x00,
10230x00,
10240x00,
10250x10,
10260x38,
10270x18,
10280x08,
10290x10,
10300x20,
1031
10320x00,
10330x06,
10340x0c,
10350x18,
10360x30,
10370x60,
10380xa0,
10390xa0,
10400x60,
10410x30,
10420x18,
10430x0c,
10440x06,
10450x00,
10460x00,
10470x00,
1048
10490x00,
10500x00,
10510x00,
10520x00,
10530x00,
10540x7e,
10550x00,
10560x00,
10570x7e,
10580x00,
10590x00,
10600x00,
10610x00,
10620x00,
10630x00,
10640x00,
1065
10660x00,
10670x60,
10680x30,
10690x18,
10700x0c,
10710x06,
10720x05,
10730x05,
10740x06,
10750x0c,
10760x18,
10770x30,
10780x60,
10790x00,
10800x00,
10810x00,
1082
10830x00,
10840x7c,
10850x86,
10860xc6,
10870x06,
10880x04,
10890x08,
10900x10,
10910x10,
10920x18,
10930x00,
10940x18,
10950x18,
10960x00,
10970x00,
10980x00,
1099
11000x00,
11010x00,
11020x3c,
11030x46,
11040xc6,
11050xce,
11060xd6,
11070xd6,
11080xd6,
11090xdc,
11100xc0,
11110xc4,
11120x78,
11130x00,
11140x00,
11150x00,
1116
11170x00,
11180x18,
11190x18,
11200x18,
11210x3c,
11220x2c,
11230x2c,
11240x2c,
11250x7e,
11260x46,
11270x46,
11280x46,
11290xef,
11300x00,
11310x00,
11320x00,
1133
11340x00,
11350xfc,
11360x66,
11370x66,
11380x66,
11390x66,
11400x7c,
11410x66,
11420x66,
11430x66,
11440x66,
11450x66,
11460xfc,
11470x00,
11480x00,
11490x00,
1150
11510x00,
11520x3a,
11530x66,
11540xc2,
11550xc0,
11560xc0,
11570xc0,
11580xc0,
11590xc0,
11600xc0,
11610xc0,
11620x62,
11630x3c,
11640x00,
11650x00,
11660x00,
1167
11680x00,
11690xfc,
11700x66,
11710x63,
11720x63,
11730x63,
11740x63,
11750x63,
11760x63,
11770x63,
11780x63,
11790x66,
11800xfc,
11810x00,
11820x00,
11830x00,
1184
11850x00,
11860xff,
11870x61,
11880x60,
11890x60,
11900x64,
11910x7c,
11920x64,
11930x60,
11940x60,
11950x60,
11960x61,
11970xfe,
11980x00,
11990x00,
12000x00,
1201
12020x00,
12030xff,
12040x61,
12050x61,
12060x60,
12070x64,
12080x7c,
12090x64,
12100x60,
12110x60,
12120x60,
12130x60,
12140xf0,
12150x00,
12160x00,
12170x00,
1218
12190x00,
12200x3a,
12210x66,
12220xc2,
12230xc0,
12240xc0,
12250xc0,
12260xcf,
12270xc6,
12280xc6,
12290xc6,
12300x66,
12310x38,
12320x00,
12330x00,
12340x00,
1235
12360x00,
12370xf7,
12380x62,
12390x62,
12400x62,
12410x62,
12420x7e,
12430x62,
12440x62,
12450x62,
12460x62,
12470x62,
12480xf7,
12490x00,
12500x00,
12510x00,
1252
12530x00,
12540x3c,
12550x18,
12560x18,
12570x18,
12580x18,
12590x18,
12600x18,
12610x18,
12620x18,
12630x18,
12640x18,
12650x3c,
12660x00,
12670x00,
12680x00,
1269
12700x00,
12710x1e,
12720x0c,
12730x0c,
12740x0c,
12750x0c,
12760x0c,
12770x0c,
12780x0c,
12790x0c,
12800x0c,
12810x0c,
12820x0c,
12830x0c,
12840x08,
12850xf0,
1286
12870x00,
12880xf7,
12890x64,
12900x6c,
12910x68,
12920x68,
12930x78,
12940x6c,
12950x6c,
12960x6c,
12970x66,
12980x66,
12990xf7,
13000x00,
13010x00,
13020x00,
1303
13040x00,
13050xf8,
13060x60,
13070x60,
13080x60,
13090x60,
13100x60,
13110x60,
13120x60,
13130x60,
13140x60,
13150x61,
13160xfe,
13170x00,
13180x00,
13190x00,
1320
13210x00,
13220xc3,
13230x66,
13240x76,
13250x7e,
13260x56,
13270x56,
13280x46,
13290x46,
13300x46,
13310x46,
13320x46,
13330xef,
13340x00,
13350x00,
13360x00,
1337
13380x00,
13390xe7,
13400x62,
13410x62,
13420x72,
13430x52,
13440x5a,
13450x4a,
13460x4e,
13470x46,
13480x46,
13490x42,
13500xe2,
13510x00,
13520x00,
13530x00,
1354
13550x00,
13560x3c,
13570x66,
13580xc3,
13590xc3,
13600xc3,
13610xc3,
13620xc3,
13630xc3,
13640xc3,
13650xc3,
13660x66,
13670x3c,
13680x00,
13690x00,
13700x00,
1371
13720x00,
13730xfc,
13740x66,
13750x66,
13760x66,
13770x66,
13780x6c,
13790x60,
13800x60,
13810x60,
13820x60,
13830x60,
13840xf0,
13850x00,
13860x00,
13870x00,
1388
13890x00,
13900x3c,
13910x66,
13920xc3,
13930xc3,
13940xc3,
13950xc3,
13960xc3,
13970xc3,
13980xc3,
13990xc3,
14000x66,
14010x3c,
14020x10,
14030x39,
14040x0e,
1405
14060x00,
14070xfc,
14080x66,
14090x66,
14100x66,
14110x66,
14120x7c,
14130x6c,
14140x66,
14150x66,
14160x66,
14170x66,
14180xf3,
14190x00,
14200x00,
14210x00,
1422
14230x00,
14240x7a,
14250xc6,
14260xc2,
14270xc0,
14280x70,
14290x3c,
14300x0e,
14310x06,
14320x06,
14330x86,
14340xc6,
14350xbc,
14360x00,
14370x00,
14380x00,
1439
14400x00,
14410xff,
14420x99,
14430x18,
14440x18,
14450x18,
14460x18,
14470x18,
14480x18,
14490x18,
14500x18,
14510x18,
14520x3c,
14530x00,
14540x00,
14550x00,
1456
14570x00,
14580xf7,
14590x62,
14600x62,
14610x62,
14620x62,
14630x62,
14640x62,
14650x62,
14660x62,
14670x62,
14680x62,
14690x3c,
14700x00,
14710x00,
14720x00,
1473
14740x00,
14750xf7,
14760x62,
14770x62,
14780x62,
14790x76,
14800x34,
14810x34,
14820x34,
14830x3c,
14840x18,
14850x18,
14860x18,
14870x00,
14880x00,
14890x00,
1490
14910x00,
14920xf7,
14930x62,
14940x62,
14950x62,
14960x62,
14970x6a,
14980x6a,
14990x6a,
15000x6a,
15010x7e,
15020x7e,
15030x34,
15040x00,
15050x00,
15060x00,
1507
15080x00,
15090xf7,
15100x62,
15110x62,
15120x34,
15130x34,
15140x18,
15150x18,
15160x2c,
15170x2c,
15180x46,
15190x46,
15200xef,
15210x00,
15220x00,
15230x00,
1524
15250x00,
15260xf7,
15270x62,
15280x62,
15290x62,
15300x34,
15310x34,
15320x18,
15330x18,
15340x18,
15350x18,
15360x18,
15370x3c,
15380x00,
15390x00,
15400x00,
1541
15420x00,
15430x7f,
15440x46,
15450x86,
15460x0c,
15470x0c,
15480x18,
15490x18,
15500x30,
15510x30,
15520x61,
15530x62,
15540xfe,
15550x00,
15560x00,
15570x00,
1558
15590x00,
15600x3c,
15610x30,
15620x30,
15630x30,
15640x30,
15650x30,
15660x30,
15670x30,
15680x30,
15690x30,
15700x30,
15710x3c,
15720x00,
15730x00,
15740x00,
1575
15760x00,
15770xc0,
15780xc0,
15790x60,
15800x60,
15810x30,
15820x30,
15830x18,
15840x18,
15850x0c,
15860x0c,
15870x06,
15880x06,
15890x00,
15900x00,
15910x00,
1592
15930x00,
15940x3c,
15950x0c,
15960x0c,
15970x0c,
15980x0c,
15990x0c,
16000x0c,
16010x0c,
16020x0c,
16030x0c,
16040x0c,
16050x3c,
16060x00,
16070x00,
16080x00,
1609
16100x00,
16110x10,
16120x38,
16130x4c,
16140x86,
16150x00,
16160x00,
16170x00,
16180x00,
16190x00,
16200x00,
16210x00,
16220x00,
16230x00,
16240x00,
16250x00,
1626
16270x00,
16280x00,
16290x00,
16300x00,
16310x00,
16320x00,
16330x00,
16340x00,
16350x00,
16360x00,
16370x00,
16380x00,
16390x00,
16400xff,
16410x00,
16420x00,
1643
16440x00,
16450x18,
16460x20,
16470x30,
16480x38,
16490x10,
16500x00,
16510x00,
16520x00,
16530x00,
16540x00,
16550x00,
16560x00,
16570x00,
16580x00,
16590x00,
1660
16610x00,
16620x00,
16630x00,
16640x00,
16650x00,
16660x78,
16670x8c,
16680x0c,
16690x3c,
16700xcc,
16710xcc,
16720xcd,
16730x76,
16740x00,
16750x00,
16760x00,
1677
16780x00,
16790x20,
16800xe0,
16810x60,
16820x60,
16830x6c,
16840x76,
16850x66,
16860x66,
16870x66,
16880x66,
16890x76,
16900x6c,
16910x00,
16920x00,
16930x00,
1694
16950x00,
16960x00,
16970x00,
16980x00,
16990x00,
17000x3c,
17010x66,
17020x60,
17030x60,
17040x60,
17050x60,
17060x62,
17070x3c,
17080x00,
17090x00,
17100x00,
1711
17120x00,
17130x04,
17140x1c,
17150x0c,
17160x0c,
17170x6c,
17180xdc,
17190xcc,
17200xcc,
17210xcc,
17220xcc,
17230xdc,
17240x66,
17250x00,
17260x00,
17270x00,
1728
17290x00,
17300x00,
17310x00,
17320x00,
17330x00,
17340x3c,
17350x66,
17360x7e,
17370x60,
17380x60,
17390x60,
17400x62,
17410x3c,
17420x00,
17430x00,
17440x00,
1745
17460x00,
17470x1e,
17480x31,
17490x33,
17500x30,
17510x30,
17520x78,
17530x30,
17540x30,
17550x30,
17560x30,
17570x30,
17580x78,
17590x00,
17600x00,
17610x00,
1762
17630x00,
17640x00,
17650x00,
17660x00,
17670x00,
17680x7b,
17690xce,
17700xcc,
17710xcc,
17720xcc,
17730x78,
17740x60,
17750x7c,
17760x86,
17770xc6,
17780x7c,
1779
17800x00,
17810x20,
17820xe0,
17830x60,
17840x60,
17850x6c,
17860x76,
17870x66,
17880x66,
17890x66,
17900x66,
17910x66,
17920xf7,
17930x00,
17940x00,
17950x00,
1796
17970x00,
17980x10,
17990x38,
18000x10,
18010x00,
18020x18,
18030x38,
18040x18,
18050x18,
18060x18,
18070x18,
18080x18,
18090x3c,
18100x00,
18110x00,
18120x00,
1813
18140x00,
18150x08,
18160x1c,
18170x08,
18180x00,
18190x0c,
18200x1c,
18210x0c,
18220x0c,
18230x0c,
18240x0c,
18250x0c,
18260x6c,
18270x4c,
18280x38,
18290x00,
1830
18310x00,
18320x20,
18330xe0,
18340x60,
18350x60,
18360x67,
18370x66,
18380x6c,
18390x78,
18400x6c,
18410x6c,
18420x66,
18430xe7,
18440x00,
18450x00,
18460x00,
1847
18480x00,
18490x08,
18500x38,
18510x18,
18520x18,
18530x18,
18540x18,
18550x18,
18560x18,
18570x18,
18580x18,
18590x18,
18600x3c,
18610x00,
18620x00,
18630x00,
1864
18650x00,
18660x00,
18670x00,
18680x00,
18690x00,
18700x6a,
18710xfe,
18720x6a,
18730x6a,
18740x6a,
18750x62,
18760x62,
18770xf7,
18780x00,
18790x00,
18800x00,
1881
18820x00,
18830x00,
18840x00,
18850x00,
18860x00,
18870x5c,
18880xf6,
18890x66,
18900x66,
18910x66,
18920x66,
18930x66,
18940xf7,
18950x00,
18960x00,
18970x00,
1898
18990x00,
19000x00,
19010x00,
19020x00,
19030x00,
19040x3c,
19050x66,
19060x66,
19070x66,
19080x66,
19090x66,
19100x66,
19110x3c,
19120x00,
19130x00,
19140x00,
1915
19160x00,
19170x00,
19180x00,
19190x00,
19200x00,
19210x5c,
19220xe6,
19230x66,
19240x66,
19250x66,
19260x66,
19270x66,
19280x7c,
19290x60,
19300x60,
19310xf0,
1932
19330x00,
19340x00,
19350x00,
19360x00,
19370x00,
19380x76,
19390xcc,
19400xcc,
19410xcc,
19420xcc,
19430xcc,
19440xcc,
19450x7c,
19460x0c,
19470x0c,
19480x1e,
1949
19500x00,
19510x00,
19520x00,
19530x00,
19540x00,
19550x5e,
19560xf6,
19570x60,
19580x60,
19590x60,
19600x60,
19610x60,
19620xf0,
19630x00,
19640x00,
19650x00,
1966
19670x00,
19680x00,
19690x00,
19700x00,
19710x00,
19720x7a,
19730xc6,
19740x72,
19750x1c,
19760x06,
19770x86,
19780xc6,
19790xbc,
19800x00,
19810x00,
19820x00,
1983
19840x00,
19850x00,
19860x00,
19870x10,
19880x30,
19890x7c,
19900x30,
19910x30,
19920x30,
19930x30,
19940x30,
19950x34,
19960x18,
19970x00,
19980x00,
19990x00,
2000
20010x00,
20020x00,
20030x00,
20040x00,
20050x00,
20060xee,
20070x66,
20080x66,
20090x66,
20100x66,
20110x66,
20120x67,
20130x3a,
20140x00,
20150x00,
20160x00,
2017
20180x00,
20190x00,
20200x00,
20210x00,
20220x00,
20230xf7,
20240x62,
20250x76,
20260x34,
20270x34,
20280x3c,
20290x18,
20300x18,
20310x00,
20320x00,
20330x00,
2034
20350x00,
20360x00,
20370x00,
20380x00,
20390x00,
20400xf7,
20410x62,
20420x6a,
20430x6a,
20440x6a,
20450x6a,
20460x7e,
20470x24,
20480x00,
20490x00,
20500x00,
2051
20520x00,
20530x00,
20540x00,
20550x00,
20560x00,
20570xf7,
20580x62,
20590x34,
20600x18,
20610x2c,
20620x46,
20630x46,
20640xef,
20650x00,
20660x00,
20670x00,
2068
20690x00,
20700x00,
20710x00,
20720x00,
20730x00,
20740xf7,
20750x62,
20760x62,
20770x34,
20780x34,
20790x18,
20800x18,
20810x18,
20820x10,
20830xb0,
20840xe0,
2085
20860x00,
20870x00,
20880x00,
20890x00,
20900x00,
20910xfe,
20920x8c,
20930x18,
20940x30,
20950x30,
20960x60,
20970xc2,
20980xfe,
20990x00,
21000x00,
21010x00,
2102
21030x00,
21040x0e,
21050x18,
21060x10,
21070x10,
21080x08,
21090x70,
21100x70,
21110x08,
21120x10,
21130x10,
21140x18,
21150x0e,
21160x00,
21170x00,
21180x00,
2119
21200x18,
21210x18,
21220x18,
21230x18,
21240x18,
21250x18,
21260x18,
21270x18,
21280x18,
21290x18,
21300x18,
21310x18,
21320x18,
21330x18,
21340x00,
21350x00,
2136
21370x00,
21380x70,
21390x18,
21400x08,
21410x08,
21420x10,
21430x0e,
21440x0e,
21450x10,
21460x08,
21470x08,
21480x18,
21490x70,
21500x00,
21510x00,
21520x00,
2153
21540x00,
21550x00,
21560x00,
21570x00,
21580x00,
21590x00,
21600x76,
21610xdc,
21620x00,
21630x00,
21640x00,
21650x00,
21660x00,
21670x00,
21680x00,
21690x00,
2170
21710x00,
21720x00,
21730x00,
21740x00,
21750x10,
21760x38,
21770x6c,
21780xc6,
21790xc6,
21800xc6,
21810xfe,
21820x00,
21830x00,
21840x00,
21850x00,
21860x00,
2187
21880x00,
21890x00,
21900x3a,
21910x66,
21920xc2,
21930xc0,
21940xc0,
21950xc0,
21960xc0,
21970xc0,
21980x62,
21990x3c,
22000x18,
22010x0c,
22020x24,
22030x18,
2204
22050x00,
22060x00,
22070x66,
22080x00,
22090x00,
22100xee,
22110x66,
22120x66,
22130x66,
22140x66,
22150x66,
22160x66,
22170x3b,
22180x00,
22190x00,
22200x00,
2221
22220x00,
22230x0c,
22240x18,
22250x20,
22260x00,
22270x3c,
22280x66,
22290x7e,
22300x60,
22310x60,
22320x60,
22330x62,
22340x3c,
22350x00,
22360x00,
22370x00,
2238
22390x00,
22400x30,
22410x58,
22420x8c,
22430x00,
22440x78,
22450x8c,
22460x0c,
22470x3c,
22480xcc,
22490xcc,
22500xcd,
22510x76,
22520x00,
22530x00,
22540x00,
2255
22560x00,
22570x00,
22580x66,
22590x00,
22600x00,
22610x78,
22620x8c,
22630x0c,
22640x3c,
22650xcc,
22660xcc,
22670xcd,
22680x76,
22690x00,
22700x00,
22710x00,
2272
22730x00,
22740x30,
22750x18,
22760x04,
22770x00,
22780x78,
22790x8c,
22800x0c,
22810x3c,
22820xcc,
22830xcc,
22840xcd,
22850x76,
22860x00,
22870x00,
22880x00,
2289
22900x38,
22910x44,
22920x44,
22930x38,
22940x00,
22950x78,
22960x8c,
22970x0c,
22980x3c,
22990xcc,
23000xcc,
23010xcd,
23020x76,
23030x00,
23040x00,
23050x00,
2306
23070x00,
23080x00,
23090x00,
23100x00,
23110x00,
23120x3c,
23130x66,
23140x60,
23150x60,
23160x60,
23170x60,
23180x62,
23190x3c,
23200x08,
23210x24,
23220x18,
2323
23240x00,
23250x18,
23260x2c,
23270x46,
23280x00,
23290x3c,
23300x66,
23310x7e,
23320x60,
23330x60,
23340x60,
23350x62,
23360x3c,
23370x00,
23380x00,
23390x00,
2340
23410x00,
23420x00,
23430x66,
23440x00,
23450x00,
23460x3c,
23470x66,
23480x7e,
23490x60,
23500x60,
23510x60,
23520x62,
23530x3c,
23540x00,
23550x00,
23560x00,
2357
23580x00,
23590x30,
23600x18,
23610x04,
23620x00,
23630x3c,
23640x66,
23650x7e,
23660x60,
23670x60,
23680x60,
23690x62,
23700x3c,
23710x00,
23720x00,
23730x00,
2374
23750x00,
23760x00,
23770x66,
23780x00,
23790x00,
23800x38,
23810x18,
23820x18,
23830x18,
23840x18,
23850x18,
23860x18,
23870x3c,
23880x00,
23890x00,
23900x00,
2391
23920x00,
23930x18,
23940x2c,
23950x46,
23960x00,
23970x38,
23980x18,
23990x18,
24000x18,
24010x18,
24020x18,
24030x18,
24040x3c,
24050x00,
24060x00,
24070x00,
2408
24090x00,
24100x60,
24110x30,
24120x08,
24130x00,
24140x38,
24150x18,
24160x18,
24170x18,
24180x18,
24190x18,
24200x18,
24210x3c,
24220x00,
24230x00,
24240x00,
2425
24260x66,
24270x18,
24280x18,
24290x18,
24300x3c,
24310x2c,
24320x2c,
24330x2c,
24340x7e,
24350x46,
24360x46,
24370x46,
24380xef,
24390x00,
24400x00,
24410x00,
2442
24430x18,
24440x24,
24450x18,
24460x18,
24470x3c,
24480x2c,
24490x2c,
24500x2c,
24510x7e,
24520x46,
24530x46,
24540x46,
24550xef,
24560x00,
24570x00,
24580x00,
2459
24600x0c,
24610x18,
24620xff,
24630x61,
24640x60,
24650x60,
24660x64,
24670x7c,
24680x64,
24690x60,
24700x60,
24710x61,
24720xfe,
24730x00,
24740x00,
24750x00,
2476
24770x00,
24780x00,
24790x00,
24800x00,
24810x00,
24820x76,
24830x9b,
24840x1b,
24850x3f,
24860xd8,
24870xd8,
24880xd9,
24890x6e,
24900x00,
24910x00,
24920x00,
2493
24940x00,
24950x1f,
24960x1d,
24970x1d,
24980x3c,
24990x2c,
25000x2e,
25010x2c,
25020x7c,
25030x4c,
25040x4c,
25050x4d,
25060xef,
25070x00,
25080x00,
25090x00,
2510
25110x00,
25120x18,
25130x2c,
25140x46,
25150x00,
25160x3c,
25170x66,
25180x66,
25190x66,
25200x66,
25210x66,
25220x66,
25230x3c,
25240x00,
25250x00,
25260x00,
2527
25280x00,
25290x00,
25300x66,
25310x00,
25320x00,
25330x3c,
25340x66,
25350x66,
25360x66,
25370x66,
25380x66,
25390x66,
25400x3c,
25410x00,
25420x00,
25430x00,
2544
25450x00,
25460x30,
25470x18,
25480x04,
25490x00,
25500x3c,
25510x66,
25520x66,
25530x66,
25540x66,
25550x66,
25560x66,
25570x3c,
25580x00,
25590x00,
25600x00,
2561
25620x00,
25630x18,
25640x2c,
25650x46,
25660x00,
25670xee,
25680x66,
25690x66,
25700x66,
25710x66,
25720x66,
25730x67,
25740x3a,
25750x00,
25760x00,
25770x00,
2578
25790x00,
25800x30,
25810x18,
25820x04,
25830x00,
25840xee,
25850x66,
25860x66,
25870x66,
25880x66,
25890x66,
25900x67,
25910x3a,
25920x00,
25930x00,
25940x00,
2595
25960x00,
25970x00,
25980x66,
25990x00,
26000x00,
26010xf7,
26020x62,
26030x62,
26040x34,
26050x34,
26060x18,
26070x18,
26080x18,
26090x10,
26100xb0,
26110xe0,
2612
26130x66,
26140x00,
26150x3c,
26160x66,
26170xc3,
26180xc3,
26190xc3,
26200xc3,
26210xc3,
26220xc3,
26230xc3,
26240x66,
26250x3c,
26260x00,
26270x00,
26280x00,
2629
26300x66,
26310x00,
26320xf7,
26330x62,
26340x62,
26350x62,
26360x62,
26370x62,
26380x62,
26390x62,
26400x62,
26410x62,
26420x3c,
26430x00,
26440x00,
26450x00,
2646
26470x00,
26480x00,
26490x10,
26500x10,
26510x10,
26520x7c,
26530xc6,
26540xc0,
26550xc0,
26560xc0,
26570xc0,
26580xc2,
26590x7c,
26600x10,
26610x10,
26620x00,
2663
26640x00,
26650x38,
26660x64,
26670x6c,
26680x60,
26690x60,
26700xf0,
26710x60,
26720x60,
26730x60,
26740x60,
26750x66,
26760xfc,
26770x00,
26780x00,
26790x00,
2680
26810x00,
26820x81,
26830xc3,
26840x66,
26850x3c,
26860x18,
26870xff,
26880x18,
26890x18,
26900xff,
26910x18,
26920x18,
26930x18,
26940x00,
26950x00,
26960x00,
2697
26980x00,
26990xfe,
27000x63,
27010x63,
27020x63,
27030x63,
27040x6e,
27050x60,
27060x64,
27070x6e,
27080x64,
27090x64,
27100xf5,
27110x06,
27120x00,
27130x00,
2714
27150x00,
27160x0e,
27170x19,
27180x1b,
27190x18,
27200x18,
27210x3c,
27220x18,
27230x18,
27240x18,
27250x18,
27260xd8,
27270x98,
27280x70,
27290x00,
27300x00,
2731
27320x00,
27330x0c,
27340x18,
27350x20,
27360x00,
27370x78,
27380x8c,
27390x0c,
27400x3c,
27410xcc,
27420xcc,
27430xcd,
27440x76,
27450x00,
27460x00,
27470x00,
2748
27490x00,
27500x06,
27510x0c,
27520x10,
27530x00,
27540x38,
27550x18,
27560x18,
27570x18,
27580x18,
27590x18,
27600x18,
27610x3c,
27620x00,
27630x00,
27640x00,
2765
27660x00,
27670x0c,
27680x18,
27690x20,
27700x00,
27710x3c,
27720x66,
27730x66,
27740x66,
27750x66,
27760x66,
27770x66,
27780x3c,
27790x00,
27800x00,
27810x00,
2782
27830x00,
27840x0c,
27850x18,
27860x20,
27870x00,
27880xee,
27890x66,
27900x66,
27910x66,
27920x66,
27930x66,
27940x67,
27950x3a,
27960x00,
27970x00,
27980x00,
2799
28000x00,
28010x00,
28020x32,
28030x4c,
28040x00,
28050x5c,
28060xf6,
28070x66,
28080x66,
28090x66,
28100x66,
28110x66,
28120xf7,
28130x00,
28140x00,
28150x00,
2816
28170x32,
28180x4c,
28190x00,
28200xe7,
28210x72,
28220x52,
28230x5a,
28240x4a,
28250x4e,
28260x46,
28270x46,
28280x42,
28290xe2,
28300x00,
28310x00,
28320x00,
2833
28340x00,
28350x78,
28360x8c,
28370x0c,
28380x3c,
28390xcc,
28400xcc,
28410xcd,
28420x76,
28430x00,
28440xfe,
28450x00,
28460x00,
28470x00,
28480x00,
28490x00,
2850
28510x00,
28520x3c,
28530x66,
28540x66,
28550x66,
28560x66,
28570x66,
28580x66,
28590x3c,
28600x00,
28610x7e,
28620x00,
28630x00,
28640x00,
28650x00,
28660x00,
2867
28680x00,
28690x30,
28700x30,
28710x00,
28720x30,
28730x10,
28740x10,
28750x20,
28760x40,
28770xc0,
28780xc6,
28790xc2,
28800x7c,
28810x00,
28820x00,
28830x00,
2884
28850x00,
28860x00,
28870x00,
28880x00,
28890x00,
28900x00,
28910xfe,
28920xc0,
28930xc0,
28940xc0,
28950xc0,
28960x00,
28970x00,
28980x00,
28990x00,
29000x00,
2901
29020x00,
29030x00,
29040x00,
29050x00,
29060x00,
29070x00,
29080xfe,
29090x06,
29100x06,
29110x06,
29120x06,
29130x00,
29140x00,
29150x00,
29160x00,
29170x00,
2918
29190x00,
29200x20,
29210xe0,
29220x63,
29230x66,
29240xfc,
29250x18,
29260x30,
29270x60,
29280xce,
29290x93,
29300x06,
29310x0c,
29320x1f,
29330x00,
29340x00,
2935
29360x00,
29370x20,
29380xe0,
29390x63,
29400x66,
29410xfc,
29420x18,
29430x30,
29440x64,
29450xc8,
29460x96,
29470x3f,
29480x06,
29490x06,
29500x00,
29510x00,
2952
29530x00,
29540x18,
29550x18,
29560x00,
29570x08,
29580x18,
29590x18,
29600x18,
29610x3c,
29620x3c,
29630x3c,
29640x3c,
29650x18,
29660x00,
29670x00,
29680x00,
2969
29700x00,
29710x00,
29720x00,
29730x00,
29740x00,
29750x36,
29760x6c,
29770xd8,
29780xd8,
29790x6c,
29800x36,
29810x00,
29820x00,
29830x00,
29840x00,
29850x00,
2986
29870x00,
29880x00,
29890x00,
29900x00,
29910x00,
29920xd8,
29930x6c,
29940x36,
29950x36,
29960x6c,
29970xd8,
29980x00,
29990x00,
30000x00,
30010x00,
30020x00,
3003
30040x82,
30050x10,
30060x82,
30070x10,
30080x82,
30090x10,
30100x82,
30110x10,
30120x82,
30130x10,
30140x82,
30150x10,
30160x82,
30170x10,
30180x82,
30190x10,
3020
30210x00,
30220x95,
30230x00,
30240xa9,
30250x00,
30260x95,
30270x00,
30280xa9,
30290x00,
30300x95,
30310x00,
30320xa9,
30330x00,
30340x95,
30350x00,
30360xa9,
3037
30380x92,
30390x49,
30400x92,
30410x49,
30420x92,
30430x49,
30440x92,
30450x49,
30460x92,
30470x49,
30480x92,
30490x49,
30500x92,
30510x49,
30520x92,
30530x49,
3054
30550x18,
30560x18,
30570x18,
30580x18,
30590x18,
30600x18,
30610x18,
30620x18,
30630x18,
30640x18,
30650x18,
30660x18,
30670x18,
30680x18,
30690x18,
30700x18,
3071
30720x18,
30730x18,
30740x18,
30750x18,
30760x18,
30770x18,
30780x18,
30790xf8,
30800x18,
30810x18,
30820x18,
30830x18,
30840x18,
30850x18,
30860x18,
30870x18,
3088
30890x18,
30900x18,
30910x18,
30920x18,
30930x18,
30940x18,
30950xf8,
30960x18,
30970x18,
30980xf8,
30990x18,
31000x18,
31010x18,
31020x18,
31030x18,
31040x18,
3105
31060x66,
31070x66,
31080x66,
31090x66,
31100x66,
31110x66,
31120x66,
31130xe6,
31140x66,
31150x66,
31160x66,
31170x66,
31180x66,
31190x66,
31200x66,
31210x66,
3122
31230x00,
31240x00,
31250x00,
31260x00,
31270x00,
31280x00,
31290x00,
31300xfe,
31310x66,
31320x66,
31330x66,
31340x66,
31350x66,
31360x66,
31370x66,
31380x66,
3139
31400x00,
31410x00,
31420x00,
31430x00,
31440x00,
31450x00,
31460xf8,
31470x18,
31480x18,
31490xf8,
31500x18,
31510x18,
31520x18,
31530x18,
31540x18,
31550x18,
3156
31570x66,
31580x66,
31590x66,
31600x66,
31610x66,
31620x66,
31630xe6,
31640x06,
31650x06,
31660xe6,
31670x66,
31680x66,
31690x66,
31700x66,
31710x66,
31720x66,
3173
31740x66,
31750x66,
31760x66,
31770x66,
31780x66,
31790x66,
31800x66,
31810x66,
31820x66,
31830x66,
31840x66,
31850x66,
31860x66,
31870x66,
31880x66,
31890x66,
3190
31910x00,
31920x00,
31930x00,
31940x00,
31950x00,
31960x00,
31970xfe,
31980x06,
31990x06,
32000xe6,
32010x66,
32020x66,
32030x66,
32040x66,
32050x66,
32060x66,
3207
32080x66,
32090x66,
32100x66,
32110x66,
32120x66,
32130x66,
32140xe6,
32150x06,
32160x06,
32170xfe,
32180x00,
32190x00,
32200x00,
32210x00,
32220x00,
32230x00,
3224
32250x66,
32260x66,
32270x66,
32280x66,
32290x66,
32300x66,
32310x66,
32320xfe,
32330x00,
32340x00,
32350x00,
32360x00,
32370x00,
32380x00,
32390x00,
32400x00,
3241
32420x18,
32430x18,
32440x18,
32450x18,
32460x18,
32470x18,
32480xf8,
32490x18,
32500x18,
32510xf8,
32520x00,
32530x00,
32540x00,
32550x00,
32560x00,
32570x00,
3258
32590x00,
32600x00,
32610x00,
32620x00,
32630x00,
32640x00,
32650x00,
32660xf8,
32670x18,
32680x18,
32690x18,
32700x18,
32710x18,
32720x18,
32730x18,
32740x18,
3275
32760x18,
32770x18,
32780x18,
32790x18,
32800x18,
32810x18,
32820x18,
32830x1f,
32840x00,
32850x00,
32860x00,
32870x00,
32880x00,
32890x00,
32900x00,
32910x00,
3292
32930x18,
32940x18,
32950x18,
32960x18,
32970x18,
32980x18,
32990x18,
33000xff,
33010x00,
33020x00,
33030x00,
33040x00,
33050x00,
33060x00,
33070x00,
33080x00,
3309
33100x00,
33110x00,
33120x00,
33130x00,
33140x00,
33150x00,
33160x00,
33170xff,
33180x18,
33190x18,
33200x18,
33210x18,
33220x18,
33230x18,
33240x18,
33250x18,
3326
33270x18,
33280x18,
33290x18,
33300x18,
33310x18,
33320x18,
33330x18,
33340x1f,
33350x18,
33360x18,
33370x18,
33380x18,
33390x18,
33400x18,
33410x18,
33420x18,
3343
33440x00,
33450x00,
33460x00,
33470x00,
33480x00,
33490x00,
33500x00,
33510xff,
33520x00,
33530x00,
33540x00,
33550x00,
33560x00,
33570x00,
33580x00,
33590x00,
3360
33610x18,
33620x18,
33630x18,
33640x18,
33650x18,
33660x18,
33670x18,
33680xff,
33690x18,
33700x18,
33710x18,
33720x18,
33730x18,
33740x18,
33750x18,
33760x18,
3377
33780x18,
33790x18,
33800x18,
33810x18,
33820x18,
33830x18,
33840x1f,
33850x18,
33860x18,
33870x1f,
33880x18,
33890x18,
33900x18,
33910x18,
33920x18,
33930x18,
3394
33950x66,
33960x66,
33970x66,
33980x66,
33990x66,
34000x66,
34010x66,
34020x67,
34030x66,
34040x66,
34050x66,
34060x66,
34070x66,
34080x66,
34090x66,
34100x66,
3411
34120x66,
34130x66,
34140x66,
34150x66,
34160x66,
34170x66,
34180x67,
34190x60,
34200x60,
34210x7f,
34220x00,
34230x00,
34240x00,
34250x00,
34260x00,
34270x00,
3428
34290x00,
34300x00,
34310x00,
34320x00,
34330x00,
34340x00,
34350x7f,
34360x60,
34370x60,
34380x67,
34390x66,
34400x66,
34410x66,
34420x66,
34430x66,
34440x66,
3445
34460x66,
34470x66,
34480x66,
34490x66,
34500x66,
34510x66,
34520xe7,
34530x00,
34540x00,
34550xff,
34560x00,
34570x00,
34580x00,
34590x00,
34600x00,
34610x00,
3462
34630x00,
34640x00,
34650x00,
34660x00,
34670x00,
34680x00,
34690xff,
34700x00,
34710x00,
34720xe7,
34730x66,
34740x66,
34750x66,
34760x66,
34770x66,
34780x66,
3479
34800x66,
34810x66,
34820x66,
34830x66,
34840x66,
34850x66,
34860x67,
34870x60,
34880x60,
34890x67,
34900x66,
34910x66,
34920x66,
34930x66,
34940x66,
34950x66,
3496
34970x00,
34980x00,
34990x00,
35000x00,
35010x00,
35020x00,
35030xff,
35040x00,
35050x00,
35060xff,
35070x00,
35080x00,
35090x00,
35100x00,
35110x00,
35120x00,
3513
35140x66,
35150x66,
35160x66,
35170x66,
35180x66,
35190x66,
35200xe7,
35210x00,
35220x00,
35230xe7,
35240x66,
35250x66,
35260x66,
35270x66,
35280x66,
35290x66,
3530
35310x18,
35320x18,
35330x18,
35340x18,
35350x18,
35360x18,
35370xff,
35380x00,
35390x00,
35400xff,
35410x00,
35420x00,
35430x00,
35440x00,
35450x00,
35460x00,
3547
35480x66,
35490x66,
35500x66,
35510x66,
35520x66,
35530x66,
35540x66,
35550xff,
35560x00,
35570x00,
35580x00,
35590x00,
35600x00,
35610x00,
35620x00,
35630x00,
3564
35650x00,
35660x00,
35670x00,
35680x00,
35690x00,
35700x00,
35710xff,
35720x00,
35730x00,
35740xff,
35750x18,
35760x18,
35770x18,
35780x18,
35790x18,
35800x18,
3581
35820x00,
35830x00,
35840x00,
35850x00,
35860x00,
35870x00,
35880x00,
35890xff,
35900x66,
35910x66,
35920x66,
35930x66,
35940x66,
35950x66,
35960x66,
35970x66,
3598
35990x66,
36000x66,
36010x66,
36020x66,
36030x66,
36040x66,
36050x66,
36060x7f,
36070x00,
36080x00,
36090x00,
36100x00,
36110x00,
36120x00,
36130x00,
36140x00,
3615
36160x18,
36170x18,
36180x18,
36190x18,
36200x18,
36210x18,
36220x1f,
36230x18,
36240x18,
36250x1f,
36260x00,
36270x00,
36280x00,
36290x00,
36300x00,
36310x00,
3632
36330x00,
36340x00,
36350x00,
36360x00,
36370x00,
36380x00,
36390x1f,
36400x18,
36410x18,
36420x1f,
36430x18,
36440x18,
36450x18,
36460x18,
36470x18,
36480x18,
3649
36500x00,
36510x00,
36520x00,
36530x00,
36540x00,
36550x00,
36560x00,
36570x7f,
36580x66,
36590x66,
36600x66,
36610x66,
36620x66,
36630x66,
36640x66,
36650x66,
3666
36670x66,
36680x66,
36690x66,
36700x66,
36710x66,
36720x66,
36730x66,
36740xff,
36750x66,
36760x66,
36770x66,
36780x66,
36790x66,
36800x66,
36810x66,
36820x66,
3683
36840x18,
36850x18,
36860x18,
36870x18,
36880x18,
36890x18,
36900xff,
36910x00,
36920x00,
36930xff,
36940x18,
36950x18,
36960x18,
36970x18,
36980x18,
36990x18,
3700
37010x18,
37020x18,
37030x18,
37040x18,
37050x18,
37060x18,
37070x18,
37080xf8,
37090x00,
37100x00,
37110x00,
37120x00,
37130x00,
37140x00,
37150x00,
37160x00,
3717
37180x00,
37190x00,
37200x00,
37210x00,
37220x00,
37230x00,
37240x00,
37250x1f,
37260x18,
37270x18,
37280x18,
37290x18,
37300x18,
37310x18,
37320x18,
37330x18,
3734
37350xff,
37360xff,
37370xff,
37380xff,
37390xff,
37400xff,
37410xff,
37420xff,
37430xff,
37440xff,
37450xff,
37460xff,
37470xff,
37480xff,
37490xff,
37500xff,
3751
37520x00,
37530x00,
37540x00,
37550x00,
37560x00,
37570x00,
37580x00,
37590x00,
37600xff,
37610xff,
37620xff,
37630xff,
37640xff,
37650xff,
37660xff,
37670xff,
3768
37690xf0,
37700xf0,
37710xf0,
37720xf0,
37730xf0,
37740xf0,
37750xf0,
37760xf0,
37770xf0,
37780xf0,
37790xf0,
37800xf0,
37810xf0,
37820xf0,
37830xf0,
37840xf0,
3785
37860x0f,
37870x0f,
37880x0f,
37890x0f,
37900x0f,
37910x0f,
37920x0f,
37930x0f,
37940x0f,
37950x0f,
37960x0f,
37970x0f,
37980x0f,
37990x0f,
38000x0f,
38010x0f,
3802
38030xff,
38040xff,
38050xff,
38060xff,
38070xff,
38080xff,
38090xff,
38100xff,
38110x00,
38120x00,
38130x00,
38140x00,
38150x00,
38160x00,
38170x00,
38180x00,
3819
38200x00,
38210x00,
38220x00,
38230x00,
38240x00,
38250x00,
38260x77,
38270xcc,
38280xcc,
38290xcc,
38300xcc,
38310xde,
38320x73,
38330x00,
38340x00,
38350x00,
3836
38370x00,
38380x7c,
38390xc6,
38400xc6,
38410xc6,
38420xc4,
38430xc8,
38440xc4,
38450xc6,
38460xc6,
38470xc6,
38480xc6,
38490xdc,
38500xc0,
38510xc0,
38520x00,
3853
38540x00,
38550xff,
38560x61,
38570x60,
38580x60,
38590x60,
38600x60,
38610x60,
38620x60,
38630x60,
38640x60,
38650x60,
38660xf0,
38670x00,
38680x00,
38690x00,
3870
38710x00,
38720x00,
38730x00,
38740x00,
38750x01,
38760x7e,
38770xa4,
38780x24,
38790x2c,
38800x6c,
38810x6c,
38820x6c,
38830x48,
38840x00,
38850x00,
38860x00,
3887
38880x00,
38890xff,
38900xc1,
38910x60,
38920x30,
38930x18,
38940x0c,
38950x18,
38960x30,
38970x60,
38980xc0,
38990xc1,
39000xfe,
39010x00,
39020x00,
39030x00,
3904
39050x00,
39060x00,
39070x00,
39080x00,
39090x00,
39100x7f,
39110xc8,
39120xc8,
39130xc8,
39140xc8,
39150xc8,
39160xc8,
39170x70,
39180x00,
39190x00,
39200x00,
3921
39220x00,
39230x00,
39240x00,
39250x00,
39260x00,
39270x22,
39280x66,
39290x66,
39300x66,
39310x66,
39320x66,
39330x7c,
39340x60,
39350x60,
39360x60,
39370xc0,
3938
39390x00,
39400x00,
39410x00,
39420x00,
39430x00,
39440x76,
39450xdc,
39460x18,
39470x18,
39480x18,
39490x18,
39500x18,
39510x10,
39520x00,
39530x00,
39540x00,
3955
39560x00,
39570x38,
39580x10,
39590x7c,
39600xd6,
39610xd6,
39620xd6,
39630xd6,
39640xd6,
39650xd6,
39660x7c,
39670x10,
39680x38,
39690x00,
39700x00,
39710x00,
3972
39730x00,
39740x38,
39750x6c,
39760xc6,
39770xc6,
39780xc6,
39790xfe,
39800xc6,
39810xc6,
39820xc6,
39830xc6,
39840x6c,
39850x38,
39860x00,
39870x00,
39880x00,
3989
39900x00,
39910x3c,
39920x66,
39930xc3,
39940xc3,
39950xc3,
39960xc3,
39970xc3,
39980x66,
39990x24,
40000x24,
40010xa5,
40020xe7,
40030x00,
40040x00,
40050x00,
4006
40070x00,
40080x1e,
40090x31,
40100x30,
40110x18,
40120x0c,
40130x3e,
40140x66,
40150x66,
40160x66,
40170x66,
40180x66,
40190x3c,
40200x00,
40210x00,
40220x00,
4023
40240x00,
40250x00,
40260x00,
40270x00,
40280x6e,
40290xff,
40300x99,
40310x99,
40320x99,
40330x99,
40340xff,
40350x76,
40360x00,
40370x00,
40380x00,
40390x00,
4040
40410x00,
40420x00,
40430x00,
40440x02,
40450x04,
40460x7c,
40470xca,
40480x92,
40490xa6,
40500x7c,
40510x40,
40520x80,
40530x00,
40540x00,
40550x00,
40560x00,
4057
40580x00,
40590x1c,
40600x30,
40610x60,
40620x60,
40630x60,
40640x7c,
40650x60,
40660x60,
40670x60,
40680x60,
40690x30,
40700x1c,
40710x00,
40720x00,
40730x00,
4074
40750x00,
40760x00,
40770x7c,
40780xc6,
40790xc6,
40800xc6,
40810xc6,
40820xc6,
40830xc6,
40840xc6,
40850xc6,
40860xc6,
40870xc6,
40880x00,
40890x00,
40900x00,
4091
40920x00,
40930x00,
40940x00,
40950xfe,
40960x00,
40970x00,
40980x00,
40990x7c,
41000x00,
41010x00,
41020x00,
41030xfe,
41040x00,
41050x00,
41060x00,
41070x00,
4108
41090x00,
41100x00,
41110x00,
41120x00,
41130x18,
41140x18,
41150x7e,
41160x18,
41170x18,
41180x00,
41190x00,
41200x7e,
41210x00,
41220x00,
41230x00,
41240x00,
4125
41260x00,
41270x00,
41280x00,
41290x30,
41300x18,
41310x0c,
41320x06,
41330x0c,
41340x18,
41350x30,
41360x00,
41370x7e,
41380x00,
41390x00,
41400x00,
41410x00,
4142
41430x00,
41440x00,
41450x00,
41460x0c,
41470x18,
41480x30,
41490x60,
41500x30,
41510x18,
41520x0c,
41530x00,
41540x7e,
41550x00,
41560x00,
41570x00,
41580x00,
4159
41600x00,
41610x00,
41620x00,
41630x0e,
41640x19,
41650x1b,
41660x18,
41670x18,
41680x18,
41690x18,
41700x18,
41710x18,
41720x18,
41730x18,
41740x18,
41750x18,
4176
41770x18,
41780x18,
41790x18,
41800x18,
41810x18,
41820x18,
41830x18,
41840x18,
41850x18,
41860xd8,
41870x98,
41880x70,
41890x00,
41900x00,
41910x00,
41920x00,
4193
41940x00,
41950x00,
41960x00,
41970x00,
41980x18,
41990x18,
42000x00,
42010x7e,
42020x00,
42030x18,
42040x18,
42050x00,
42060x00,
42070x00,
42080x00,
42090x00,
4210
42110x00,
42120x00,
42130x00,
42140x00,
42150x00,
42160x76,
42170xdc,
42180x00,
42190x00,
42200x76,
42210xdc,
42220x00,
42230x00,
42240x00,
42250x00,
42260x00,
4227
42280x00,
42290x38,
42300x44,
42310x44,
42320x44,
42330x38,
42340x00,
42350x00,
42360x00,
42370x00,
42380x00,
42390x00,
42400x00,
42410x00,
42420x00,
42430x00,
4244
42450x00,
42460x00,
42470x00,
42480x00,
42490x00,
42500x00,
42510x00,
42520x18,
42530x18,
42540x00,
42550x00,
42560x00,
42570x00,
42580x00,
42590x00,
42600x00,
4261
42620x00,
42630x00,
42640x00,
42650x00,
42660x00,
42670x00,
42680x00,
42690x00,
42700x18,
42710x00,
42720x00,
42730x00,
42740x00,
42750x00,
42760x00,
42770x00,
4278
42790x00,
42800x00,
42810x07,
42820x06,
42830x06,
42840x0c,
42850x0c,
42860x08,
42870x98,
42880xd0,
42890xf0,
42900x60,
42910x20,
42920x00,
42930x00,
42940x00,
4295
42960x00,
42970xcc,
42980x76,
42990x66,
43000x66,
43010x66,
43020x66,
43030xf7,
43040x00,
43050x00,
43060x00,
43070x00,
43080x00,
43090x00,
43100x00,
43110x00,
4312
43130x00,
43140x70,
43150x98,
43160x18,
43170x30,
43180x60,
43190x88,
43200xf8,
43210x00,
43220x00,
43230x00,
43240x00,
43250x00,
43260x00,
43270x00,
43280x00,
4329
43300x00,
43310x00,
43320x00,
43330x00,
43340x00,
43350x7c,
43360x64,
43370x64,
43380x64,
43390x64,
43400x64,
43410x7c,
43420x00,
43430x00,
43440x00,
43450x00,
4346
43470x00,
43480x00,
43490x00,
43500x00,
43510x00,
43520x00,
43530x00,
43540x00,
43550x00,
43560x00,
43570x00,
43580x00,
43590x00,
43600x00,
43610x00,
43620x00,
4363
4364};
4365
4366
4367const struct font_desc font_rl = {
4368 RL_IDX,
4369 "RomanLarge",
4370 8,
4371 16,
4372 patterns,
4373 -1
4374};
diff --git a/drivers/video/console/fonts.c b/drivers/video/console/fonts.c
index 9be83bed1959..4fd07d9eca03 100644
--- a/drivers/video/console/fonts.c
+++ b/drivers/video/console/fonts.c
@@ -64,10 +64,6 @@ static const struct font_desc *fonts[] = {
64#undef NO_FONTS 64#undef NO_FONTS
65 &font_mini_4x6, 65 &font_mini_4x6,
66#endif 66#endif
67#ifdef CONFIG_FONT_RL
68#undef NO_FONTS
69 &font_rl,
70#endif
71}; 67};
72 68
73#define num_fonts (sizeof(fonts)/sizeof(*fonts)) 69#define num_fonts (sizeof(fonts)/sizeof(*fonts))
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index 274f90543e32..167de397e4b4 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -966,6 +966,7 @@ static int vgacon_adjust_height(struct vc_data *vc, unsigned fontheight)
966 outb_p(0x12, vga_video_port_reg); /* Vertical display limit */ 966 outb_p(0x12, vga_video_port_reg); /* Vertical display limit */
967 outb_p(vde, vga_video_port_val); 967 outb_p(vde, vga_video_port_val);
968 spin_unlock_irq(&vga_lock); 968 spin_unlock_irq(&vga_lock);
969 vga_video_font_height = fontheight;
969 970
970 for (i = 0; i < MAX_NR_CONSOLES; i++) { 971 for (i = 0; i < MAX_NR_CONSOLES; i++) {
971 struct vc_data *c = vc_cons[i].d; 972 struct vc_data *c = vc_cons[i].d;
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/dnfb.c b/drivers/video/dnfb.c
index 957a3ada2b75..5abd3cb00671 100644
--- a/drivers/video/dnfb.c
+++ b/drivers/video/dnfb.c
@@ -227,9 +227,8 @@ void dnfb_copyarea(struct fb_info *info, const struct fb_copyarea *area)
227 * Initialization 227 * Initialization
228 */ 228 */
229 229
230static int __devinit dnfb_probe(struct device *device) 230static int __devinit dnfb_probe(struct platform_device *dev)
231{ 231{
232 struct platform_device *dev = to_platform_device(device);
233 struct fb_info *info; 232 struct fb_info *info;
234 int err = 0; 233 int err = 0;
235 234
@@ -257,7 +256,7 @@ static int __devinit dnfb_probe(struct device *device)
257 framebuffer_release(info); 256 framebuffer_release(info);
258 return err; 257 return err;
259 } 258 }
260 dev_set_drvdata(&dev->dev, info); 259 platform_set_drvdata(dev, info);
261 260
262 /* now we have registered we can safely setup the hardware */ 261 /* now we have registered we can safely setup the hardware */
263 out_8(AP_CONTROL_3A, RESET_CREG); 262 out_8(AP_CONTROL_3A, RESET_CREG);
@@ -271,10 +270,11 @@ static int __devinit dnfb_probe(struct device *device)
271 return err; 270 return err;
272} 271}
273 272
274static struct device_driver dnfb_driver = { 273static struct platform_driver dnfb_driver = {
275 .name = "dnfb",
276 .bus = &platform_bus_type,
277 .probe = dnfb_probe, 274 .probe = dnfb_probe,
275 .driver = {
276 .name = "dnfb",
277 },
278}; 278};
279 279
280static struct platform_device dnfb_device = { 280static struct platform_device dnfb_device = {
@@ -288,12 +288,12 @@ int __init dnfb_init(void)
288 if (fb_get_options("dnfb", NULL)) 288 if (fb_get_options("dnfb", NULL))
289 return -ENODEV; 289 return -ENODEV;
290 290
291 ret = driver_register(&dnfb_driver); 291 ret = platform_driver_register(&dnfb_driver);
292 292
293 if (!ret) { 293 if (!ret) {
294 ret = platform_device_register(&dnfb_device); 294 ret = platform_device_register(&dnfb_device);
295 if (ret) 295 if (ret)
296 driver_unregister(&dnfb_driver); 296 platform_driver_unregister(&dnfb_driver);
297 } 297 }
298 return ret; 298 return ret;
299} 299}
diff --git a/drivers/video/epson1355fb.c b/drivers/video/epson1355fb.c
index 6a81a1dd8f3d..3b0e71383448 100644
--- a/drivers/video/epson1355fb.c
+++ b/drivers/video/epson1355fb.c
@@ -609,9 +609,9 @@ static void epson1355fb_platform_release(struct device *device)
609{ 609{
610} 610}
611 611
612static int epson1355fb_remove(struct device *device) 612static int epson1355fb_remove(struct platform_device *dev)
613{ 613{
614 struct fb_info *info = dev_get_drvdata(device); 614 struct fb_info *info = platform_get_drvdata(dev);
615 struct epson1355_par *par = info->par; 615 struct epson1355_par *par = info->par;
616 616
617 backlight_enable(0); 617 backlight_enable(0);
@@ -632,9 +632,8 @@ static int epson1355fb_remove(struct device *device)
632 return 0; 632 return 0;
633} 633}
634 634
635int __init epson1355fb_probe(struct device *device) 635int __init epson1355fb_probe(struct platform_device *dev)
636{ 636{
637 struct platform_device *dev = to_platform_device(device);
638 struct epson1355_par *default_par; 637 struct epson1355_par *default_par;
639 struct fb_info *info; 638 struct fb_info *info;
640 u8 revision; 639 u8 revision;
@@ -713,7 +712,7 @@ int __init epson1355fb_probe(struct device *device)
713 /* 712 /*
714 * Our driver data. 713 * Our driver data.
715 */ 714 */
716 dev_set_drvdata(&dev->dev, info); 715 platform_set_drvdata(dev, info);
717 716
718 printk(KERN_INFO "fb%d: %s frame buffer device\n", 717 printk(KERN_INFO "fb%d: %s frame buffer device\n",
719 info->node, info->fix.id); 718 info->node, info->fix.id);
@@ -721,15 +720,16 @@ int __init epson1355fb_probe(struct device *device)
721 return 0; 720 return 0;
722 721
723 bail: 722 bail:
724 epson1355fb_remove(device); 723 epson1355fb_remove(dev);
725 return rc; 724 return rc;
726} 725}
727 726
728static struct device_driver epson1355fb_driver = { 727static struct platform_driver epson1355fb_driver = {
729 .name = "epson1355fb",
730 .bus = &platform_bus_type,
731 .probe = epson1355fb_probe, 728 .probe = epson1355fb_probe,
732 .remove = epson1355fb_remove, 729 .remove = epson1355fb_remove,
730 .driver = {
731 .name = "epson1355fb",
732 },
733}; 733};
734 734
735static struct platform_device epson1355fb_device = { 735static struct platform_device epson1355fb_device = {
@@ -747,11 +747,11 @@ int __init epson1355fb_init(void)
747 if (fb_get_options("epson1355fb", NULL)) 747 if (fb_get_options("epson1355fb", NULL))
748 return -ENODEV; 748 return -ENODEV;
749 749
750 ret = driver_register(&epson1355fb_driver); 750 ret = platform_driver_register(&epson1355fb_driver);
751 if (!ret) { 751 if (!ret) {
752 ret = platform_device_register(&epson1355fb_device); 752 ret = platform_device_register(&epson1355fb_device);
753 if (ret) 753 if (ret)
754 driver_unregister(&epson1355fb_driver); 754 platform_driver_unregister(&epson1355fb_driver);
755 } 755 }
756 return ret; 756 return ret;
757} 757}
@@ -762,7 +762,7 @@ module_init(epson1355fb_init);
762static void __exit epson1355fb_exit(void) 762static void __exit epson1355fb_exit(void)
763{ 763{
764 platform_device_unregister(&epson1355fb_device); 764 platform_device_unregister(&epson1355fb_device);
765 driver_unregister(&epson1355fb_driver); 765 platform_driver_unregister(&epson1355fb_driver);
766} 766}
767 767
768/* ------------------------------------------------------------------------- */ 768/* ------------------------------------------------------------------------- */
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 9f180096c896..10dfdf035264 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -452,13 +452,17 @@ int fb_prepare_logo(struct fb_info *info, int rotate)
452 452
453 /* Return if no suitable logo was found */ 453 /* Return if no suitable logo was found */
454 fb_logo.logo = fb_find_logo(depth); 454 fb_logo.logo = fb_find_logo(depth);
455
456 if (!fb_logo.logo) {
457 return 0;
458 }
455 459
456 if (rotate == FB_ROTATE_UR || rotate == FB_ROTATE_UD) 460 if (rotate == FB_ROTATE_UR || rotate == FB_ROTATE_UD)
457 yres = info->var.yres; 461 yres = info->var.yres;
458 else 462 else
459 yres = info->var.xres; 463 yres = info->var.xres;
460 464
461 if (fb_logo.logo && fb_logo.logo->height > yres) { 465 if (fb_logo.logo->height > yres) {
462 fb_logo.logo = NULL; 466 fb_logo.logo = NULL;
463 return 0; 467 return 0;
464 } 468 }
@@ -718,14 +722,30 @@ static void try_to_load(int fb)
718int 722int
719fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var) 723fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var)
720{ 724{
725 struct fb_fix_screeninfo *fix = &info->fix;
721 int xoffset = var->xoffset; 726 int xoffset = var->xoffset;
722 int yoffset = var->yoffset; 727 int yoffset = var->yoffset;
723 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;
724 748
725 if (xoffset < 0 || yoffset < 0 || !info->fbops->fb_pan_display ||
726 xoffset + info->var.xres > info->var.xres_virtual ||
727 yoffset + info->var.yres > info->var.yres_virtual)
728 return -EINVAL;
729 if ((err = info->fbops->fb_pan_display(var, info))) 749 if ((err = info->fbops->fb_pan_display(var, info)))
730 return err; 750 return err;
731 info->var.xoffset = var->xoffset; 751 info->var.xoffset = var->xoffset;
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 04417dc16c2e..c4870d559afc 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -57,6 +57,9 @@ static struct fb_ops ffb_ops = {
57 .fb_sync = ffb_sync, 57 .fb_sync = ffb_sync,
58 .fb_mmap = ffb_mmap, 58 .fb_mmap = ffb_mmap,
59 .fb_ioctl = ffb_ioctl, 59 .fb_ioctl = ffb_ioctl,
60#ifdef CONFIG_COMPAT
61 .fb_compat_ioctl = sbusfb_compat_ioctl,
62#endif
60}; 63};
61 64
62/* Register layout and definitions */ 65/* Register layout and definitions */
@@ -356,7 +359,6 @@ struct ffb_par {
356 int prom_parent_node; 359 int prom_parent_node;
357 int dac_rev; 360 int dac_rev;
358 int board_type; 361 int board_type;
359 struct list_head list;
360}; 362};
361 363
362static void FFBFifo(struct ffb_par *par, int n) 364static void FFBFifo(struct ffb_par *par, int n)
diff --git a/drivers/video/gbefb.c b/drivers/video/gbefb.c
index 9d5e4f342110..d744c51807b7 100644
--- a/drivers/video/gbefb.c
+++ b/drivers/video/gbefb.c
@@ -1105,12 +1105,11 @@ int __init gbefb_setup(char *options)
1105 return 0; 1105 return 0;
1106} 1106}
1107 1107
1108static int __init gbefb_probe(struct device *dev) 1108static int __init gbefb_probe(struct platform_device *p_dev)
1109{ 1109{
1110 int i, ret = 0; 1110 int i, ret = 0;
1111 struct fb_info *info; 1111 struct fb_info *info;
1112 struct gbefb_par *par; 1112 struct gbefb_par *par;
1113 struct platform_device *p_dev = to_platform_device(dev);
1114#ifndef MODULE 1113#ifndef MODULE
1115 char *options = NULL; 1114 char *options = NULL;
1116#endif 1115#endif
@@ -1204,8 +1203,8 @@ static int __init gbefb_probe(struct device *dev)
1204 goto out_gbe_unmap; 1203 goto out_gbe_unmap;
1205 } 1204 }
1206 1205
1207 dev_set_drvdata(&p_dev->dev, info); 1206 platform_set_drvdata(p_dev, info);
1208 gbefb_create_sysfs(dev); 1207 gbefb_create_sysfs(&p_dev->dev);
1209 1208
1210 printk(KERN_INFO "fb%d: %s rev %d @ 0x%08x using %dkB memory\n", 1209 printk(KERN_INFO "fb%d: %s rev %d @ 0x%08x using %dkB memory\n",
1211 info->node, info->fix.id, gbe_revision, (unsigned) GBE_BASE, 1210 info->node, info->fix.id, gbe_revision, (unsigned) GBE_BASE,
@@ -1231,10 +1230,9 @@ out_release_framebuffer:
1231 return ret; 1230 return ret;
1232} 1231}
1233 1232
1234static int __devexit gbefb_remove(struct device* dev) 1233static int __devexit gbefb_remove(struct platform_device* p_dev)
1235{ 1234{
1236 struct platform_device *p_dev = to_platform_device(dev); 1235 struct fb_info *info = platform_get_drvdata(p_dev);
1237 struct fb_info *info = dev_get_drvdata(&p_dev->dev);
1238 1236
1239 unregister_framebuffer(info); 1237 unregister_framebuffer(info);
1240 gbe_turn_off(); 1238 gbe_turn_off();
@@ -1252,18 +1250,19 @@ static int __devexit gbefb_remove(struct device* dev)
1252 return 0; 1250 return 0;
1253} 1251}
1254 1252
1255static struct device_driver gbefb_driver = { 1253static struct platform_driver gbefb_driver = {
1256 .name = "gbefb",
1257 .bus = &platform_bus_type,
1258 .probe = gbefb_probe, 1254 .probe = gbefb_probe,
1259 .remove = __devexit_p(gbefb_remove), 1255 .remove = __devexit_p(gbefb_remove),
1256 .driver = {
1257 .name = "gbefb",
1258 },
1260}; 1259};
1261 1260
1262static struct platform_device *gbefb_device; 1261static struct platform_device *gbefb_device;
1263 1262
1264int __init gbefb_init(void) 1263int __init gbefb_init(void)
1265{ 1264{
1266 int ret = driver_register(&gbefb_driver); 1265 int ret = platform_driver_register(&gbefb_driver);
1267 if (!ret) { 1266 if (!ret) {
1268 gbefb_device = platform_device_alloc("gbefb", 0); 1267 gbefb_device = platform_device_alloc("gbefb", 0);
1269 if (gbefb_device) { 1268 if (gbefb_device) {
@@ -1273,7 +1272,7 @@ int __init gbefb_init(void)
1273 } 1272 }
1274 if (ret) { 1273 if (ret) {
1275 platform_device_put(gbefb_device); 1274 platform_device_put(gbefb_device);
1276 driver_unregister(&gbefb_driver); 1275 platform_driver_unregister(&gbefb_driver);
1277 } 1276 }
1278 } 1277 }
1279 return ret; 1278 return ret;
@@ -1282,7 +1281,7 @@ int __init gbefb_init(void)
1282void __exit gbefb_exit(void) 1281void __exit gbefb_exit(void)
1283{ 1282{
1284 platform_device_unregister(gbefb_device); 1283 platform_device_unregister(gbefb_device);
1285 driver_unregister(&gbefb_driver); 1284 platform_driver_unregister(&gbefb_driver);
1286} 1285}
1287 1286
1288module_init(gbefb_init); 1287module_init(gbefb_init);
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index e20b9f3a255f..5924cc225c95 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -423,18 +423,18 @@ static void imxfb_setup_gpio(struct imxfb_info *fbi)
423 * Power management hooks. Note that we won't be called from IRQ context, 423 * Power management hooks. Note that we won't be called from IRQ context,
424 * unlike the blank functions above, so we may sleep. 424 * unlike the blank functions above, so we may sleep.
425 */ 425 */
426static int imxfb_suspend(struct device *dev, pm_message_t state) 426static int imxfb_suspend(struct platform_device *dev, pm_message_t state)
427{ 427{
428 struct imxfb_info *fbi = dev_get_drvdata(dev); 428 struct imxfb_info *fbi = platform_get_drvdata(dev);
429 pr_debug("%s\n",__FUNCTION__); 429 pr_debug("%s\n",__FUNCTION__);
430 430
431 imxfb_disable_controller(fbi); 431 imxfb_disable_controller(fbi);
432 return 0; 432 return 0;
433} 433}
434 434
435static int imxfb_resume(struct device *dev) 435static int imxfb_resume(struct platform_device *dev)
436{ 436{
437 struct imxfb_info *fbi = dev_get_drvdata(dev); 437 struct imxfb_info *fbi = platform_get_drvdata(dev);
438 pr_debug("%s\n",__FUNCTION__); 438 pr_debug("%s\n",__FUNCTION__);
439 439
440 imxfb_enable_controller(fbi); 440 imxfb_enable_controller(fbi);
@@ -538,9 +538,8 @@ static int __init imxfb_map_video_memory(struct fb_info *info)
538 return fbi->map_cpu ? 0 : -ENOMEM; 538 return fbi->map_cpu ? 0 : -ENOMEM;
539} 539}
540 540
541static int __init imxfb_probe(struct device *dev) 541static int __init imxfb_probe(struct platform_device *pdev)
542{ 542{
543 struct platform_device *pdev = to_platform_device(dev);
544 struct imxfb_info *fbi; 543 struct imxfb_info *fbi;
545 struct fb_info *info; 544 struct fb_info *info;
546 struct imxfb_mach_info *inf; 545 struct imxfb_mach_info *inf;
@@ -553,21 +552,21 @@ static int __init imxfb_probe(struct device *dev)
553 if(!res) 552 if(!res)
554 return -ENODEV; 553 return -ENODEV;
555 554
556 inf = dev->platform_data; 555 inf = pdev->dev.platform_data;
557 if(!inf) { 556 if(!inf) {
558 dev_err(dev,"No platform_data available\n"); 557 dev_err(dev,"No platform_data available\n");
559 return -ENOMEM; 558 return -ENOMEM;
560 } 559 }
561 560
562 info = framebuffer_alloc(sizeof(struct imxfb_info), dev); 561 info = framebuffer_alloc(sizeof(struct imxfb_info), &pdev->dev);
563 if(!info) 562 if(!info)
564 return -ENOMEM; 563 return -ENOMEM;
565 564
566 fbi = info->par; 565 fbi = info->par;
567 566
568 dev_set_drvdata(dev, info); 567 platform_set_drvdata(pdev, info);
569 568
570 ret = imxfb_init_fbinfo(dev); 569 ret = imxfb_init_fbinfo(&pdev->dev);
571 if( ret < 0 ) 570 if( ret < 0 )
572 goto failed_init; 571 goto failed_init;
573 572
@@ -621,22 +620,21 @@ failed_register:
621 fb_dealloc_cmap(&info->cmap); 620 fb_dealloc_cmap(&info->cmap);
622failed_cmap: 621failed_cmap:
623 if (!inf->fixed_screen_cpu) 622 if (!inf->fixed_screen_cpu)
624 dma_free_writecombine(dev,fbi->map_size,fbi->map_cpu, 623 dma_free_writecombine(&pdev->dev,fbi->map_size,fbi->map_cpu,
625 fbi->map_dma); 624 fbi->map_dma);
626failed_map: 625failed_map:
627 kfree(info->pseudo_palette); 626 kfree(info->pseudo_palette);
628failed_regs: 627failed_regs:
629 release_mem_region(res->start, res->end - res->start); 628 release_mem_region(res->start, res->end - res->start);
630failed_init: 629failed_init:
631 dev_set_drvdata(dev, NULL); 630 platform_set_drvdata(pdev, NULL);
632 framebuffer_release(info); 631 framebuffer_release(info);
633 return ret; 632 return ret;
634} 633}
635 634
636static int imxfb_remove(struct device *dev) 635static int imxfb_remove(struct platform_device *pdev)
637{ 636{
638 struct platform_device *pdev = to_platform_device(dev); 637 struct fb_info *info = platform_get_drvdata(pdev);
639 struct fb_info *info = dev_get_drvdata(dev);
640 struct imxfb_info *fbi = info->par; 638 struct imxfb_info *fbi = info->par;
641 struct resource *res; 639 struct resource *res;
642 640
@@ -651,36 +649,37 @@ static int imxfb_remove(struct device *dev)
651 framebuffer_release(info); 649 framebuffer_release(info);
652 650
653 release_mem_region(res->start, res->end - res->start + 1); 651 release_mem_region(res->start, res->end - res->start + 1);
654 dev_set_drvdata(dev, NULL); 652 platform_set_drvdata(pdev, NULL);
655 653
656 return 0; 654 return 0;
657} 655}
658 656
659void imxfb_shutdown(struct device * dev) 657void imxfb_shutdown(struct platform_device * dev)
660{ 658{
661 struct fb_info *info = dev_get_drvdata(dev); 659 struct fb_info *info = platform_get_drvdata(dev);
662 struct imxfb_info *fbi = info->par; 660 struct imxfb_info *fbi = info->par;
663 imxfb_disable_controller(fbi); 661 imxfb_disable_controller(fbi);
664} 662}
665 663
666static struct device_driver imxfb_driver = { 664static struct platform_driver imxfb_driver = {
667 .name = "imx-fb",
668 .bus = &platform_bus_type,
669 .probe = imxfb_probe, 665 .probe = imxfb_probe,
670 .suspend = imxfb_suspend, 666 .suspend = imxfb_suspend,
671 .resume = imxfb_resume, 667 .resume = imxfb_resume,
672 .remove = imxfb_remove, 668 .remove = imxfb_remove,
673 .shutdown = imxfb_shutdown, 669 .shutdown = imxfb_shutdown,
670 .driver = {
671 .name = "imx-fb",
672 },
674}; 673};
675 674
676int __init imxfb_init(void) 675int __init imxfb_init(void)
677{ 676{
678 return driver_register(&imxfb_driver); 677 return platform_driver_register(&imxfb_driver);
679} 678}
680 679
681static void __exit imxfb_cleanup(void) 680static void __exit imxfb_cleanup(void)
682{ 681{
683 driver_unregister(&imxfb_driver); 682 platform_driver_unregister(&imxfb_driver);
684} 683}
685 684
686module_init(imxfb_init); 685module_init(imxfb_init);
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 84a7fe435bb8..494287f8f8bf 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -51,6 +51,9 @@ static struct fb_ops leo_ops = {
51 .fb_imageblit = cfb_imageblit, 51 .fb_imageblit = cfb_imageblit,
52 .fb_mmap = leo_mmap, 52 .fb_mmap = leo_mmap,
53 .fb_ioctl = leo_ioctl, 53 .fb_ioctl = leo_ioctl,
54#ifdef CONFIG_COMPAT
55 .fb_compat_ioctl = sbusfb_compat_ioctl,
56#endif
54}; 57};
55 58
56#define LEO_OFF_LC_SS0_KRN 0x00200000UL 59#define LEO_OFF_LC_SS0_KRN 0x00200000UL
@@ -194,7 +197,6 @@ struct leo_par {
194 unsigned long fbsize; 197 unsigned long fbsize;
195 198
196 struct sbus_dev *sdev; 199 struct sbus_dev *sdev;
197 struct list_head list;
198}; 200};
199 201
200static 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/nvidia/nv_proto.h b/drivers/video/nvidia/nv_proto.h
index f60b1f432270..3353103e8b0b 100644
--- a/drivers/video/nvidia/nv_proto.h
+++ b/drivers/video/nvidia/nv_proto.h
@@ -42,7 +42,7 @@ int nvidia_probe_i2c_connector(struct fb_info *info, int conn,
42#define nvidia_probe_i2c_connector(p, c, edid) (-1) 42#define nvidia_probe_i2c_connector(p, c, edid) (-1)
43#endif 43#endif
44 44
45#ifdef CONFIG_FB_OF 45#ifdef CONFIG_PPC_OF
46int nvidia_probe_of_connector(struct fb_info *info, int conn, 46int nvidia_probe_of_connector(struct fb_info *info, int conn,
47 u8 ** out_edid); 47 u8 ** out_edid);
48#else 48#else
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 0b40a2a721c1..bee09c6e48f6 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -1301,7 +1301,7 @@ static int nvidiafb_pan_display(struct fb_var_screeninfo *var,
1301 struct nvidia_par *par = info->par; 1301 struct nvidia_par *par = info->par;
1302 u32 total; 1302 u32 total;
1303 1303
1304 total = info->var.yoffset * info->fix.line_length + info->var.xoffset; 1304 total = var->yoffset * info->fix.line_length + var->xoffset;
1305 1305
1306 NVSetStartAddress(par, total); 1306 NVSetStartAddress(par, total);
1307 1307
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 2c856838694e..00d87f5bb7be 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -26,6 +26,7 @@
26#include <linux/fb.h> 26#include <linux/fb.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/ioport.h> 28#include <linux/ioport.h>
29#include <linux/pci.h>
29#include <asm/io.h> 30#include <asm/io.h>
30#include <asm/prom.h> 31#include <asm/prom.h>
31 32
@@ -325,8 +326,8 @@ static void __init offb_init_nodriver(struct device_node *dp)
325 int *pp, i; 326 int *pp, i;
326 unsigned int len; 327 unsigned int len;
327 int width = 640, height = 480, depth = 8, pitch; 328 int width = 640, height = 480, depth = 8, pitch;
328 unsigned *up; 329 unsigned int rsize, *up;
329 unsigned long address; 330 unsigned long address = 0;
330 331
331 if ((pp = (int *) get_property(dp, "depth", &len)) != NULL 332 if ((pp = (int *) get_property(dp, "depth", &len)) != NULL
332 && len == sizeof(int)) 333 && len == sizeof(int))
@@ -344,10 +345,40 @@ static void __init offb_init_nodriver(struct device_node *dp)
344 pitch = 0x1000; 345 pitch = 0x1000;
345 } else 346 } else
346 pitch = width; 347 pitch = width;
347 if ((up = (unsigned *) get_property(dp, "address", &len)) != NULL 348
348 && len == sizeof(unsigned)) 349 rsize = (unsigned long)pitch * (unsigned long)height *
350 (unsigned long)(depth / 8);
351
352 /* Try to match device to a PCI device in order to get a properly
353 * translated address rather then trying to decode the open firmware
354 * stuff in various incorrect ways
355 */
356#ifdef CONFIG_PCI
357 /* First try to locate the PCI device if any */
358 {
359 struct pci_dev *pdev = NULL;
360
361 for_each_pci_dev(pdev) {
362 if (dp == pci_device_to_OF_node(pdev))
363 break;
364 }
365 if (pdev) {
366 for (i = 0; i < 6 && address == 0; i++) {
367 if ((pci_resource_flags(pdev, i) &
368 IORESOURCE_MEM) &&
369 (pci_resource_len(pdev, i) >= rsize))
370 address = pci_resource_start(pdev, i);
371 }
372 pci_dev_put(pdev);
373 }
374 }
375#endif /* CONFIG_PCI */
376
377 if (address == 0 &&
378 (up = (unsigned *) get_property(dp, "address", &len)) != NULL &&
379 len == sizeof(unsigned))
349 address = (u_long) * up; 380 address = (u_long) * up;
350 else { 381 if (address == 0) {
351 for (i = 0; i < dp->n_addrs; ++i) 382 for (i = 0; i < dp->n_addrs; ++i)
352 if (dp->addrs[i].size >= 383 if (dp->addrs[i].size >=
353 pitch * height * depth / 8) 384 pitch * height * depth / 8)
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index 9aaf65fb623a..b251e754e16c 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -48,6 +48,9 @@ static struct fb_ops p9100_ops = {
48 .fb_imageblit = cfb_imageblit, 48 .fb_imageblit = cfb_imageblit,
49 .fb_mmap = p9100_mmap, 49 .fb_mmap = p9100_mmap,
50 .fb_ioctl = p9100_ioctl, 50 .fb_ioctl = p9100_ioctl,
51#ifdef CONFIG_COMPAT
52 .fb_compat_ioctl = sbusfb_compat_ioctl,
53#endif
51}; 54};
52 55
53/* P9100 control registers */ 56/* P9100 control registers */
@@ -137,7 +140,6 @@ struct p9100_par {
137 unsigned long fbsize; 140 unsigned long fbsize;
138 141
139 struct sbus_dev *sdev; 142 struct sbus_dev *sdev;
140 struct list_head list;
141}; 143};
142 144
143/** 145/**
diff --git a/drivers/video/pxafb.c b/drivers/video/pxafb.c
index f305a5b77b23..9fc10b9e6f57 100644
--- a/drivers/video/pxafb.c
+++ b/drivers/video/pxafb.c
@@ -980,17 +980,17 @@ pxafb_freq_policy(struct notifier_block *nb, unsigned long val, void *data)
980 * Power management hooks. Note that we won't be called from IRQ context, 980 * Power management hooks. Note that we won't be called from IRQ context,
981 * unlike the blank functions above, so we may sleep. 981 * unlike the blank functions above, so we may sleep.
982 */ 982 */
983static int pxafb_suspend(struct device *dev, pm_message_t state) 983static int pxafb_suspend(struct platform_device *dev, pm_message_t state)
984{ 984{
985 struct pxafb_info *fbi = dev_get_drvdata(dev); 985 struct pxafb_info *fbi = platform_get_drvdata(dev);
986 986
987 set_ctrlr_state(fbi, C_DISABLE_PM); 987 set_ctrlr_state(fbi, C_DISABLE_PM);
988 return 0; 988 return 0;
989} 989}
990 990
991static int pxafb_resume(struct device *dev) 991static int pxafb_resume(struct platform_device *dev)
992{ 992{
993 struct pxafb_info *fbi = dev_get_drvdata(dev); 993 struct pxafb_info *fbi = platform_get_drvdata(dev);
994 994
995 set_ctrlr_state(fbi, C_ENABLE_PM); 995 set_ctrlr_state(fbi, C_ENABLE_PM);
996 return 0; 996 return 0;
@@ -1268,7 +1268,7 @@ static int __init pxafb_parse_options(struct device *dev, char *options)
1268} 1268}
1269#endif 1269#endif
1270 1270
1271int __init pxafb_probe(struct device *dev) 1271int __init pxafb_probe(struct platform_device *dev)
1272{ 1272{
1273 struct pxafb_info *fbi; 1273 struct pxafb_info *fbi;
1274 struct pxafb_mach_info *inf; 1274 struct pxafb_mach_info *inf;
@@ -1276,14 +1276,14 @@ int __init pxafb_probe(struct device *dev)
1276 1276
1277 dev_dbg(dev, "pxafb_probe\n"); 1277 dev_dbg(dev, "pxafb_probe\n");
1278 1278
1279 inf = dev->platform_data; 1279 inf = dev->dev.platform_data;
1280 ret = -ENOMEM; 1280 ret = -ENOMEM;
1281 fbi = NULL; 1281 fbi = NULL;
1282 if (!inf) 1282 if (!inf)
1283 goto failed; 1283 goto failed;
1284 1284
1285#ifdef CONFIG_FB_PXA_PARAMETERS 1285#ifdef CONFIG_FB_PXA_PARAMETERS
1286 ret = pxafb_parse_options(dev, g_options); 1286 ret = pxafb_parse_options(&dev->dev, g_options);
1287 if (ret < 0) 1287 if (ret < 0)
1288 goto failed; 1288 goto failed;
1289#endif 1289#endif
@@ -1293,36 +1293,36 @@ int __init pxafb_probe(struct device *dev)
1293 * a warning is given. */ 1293 * a warning is given. */
1294 1294
1295 if (inf->lccr0 & LCCR0_INVALID_CONFIG_MASK) 1295 if (inf->lccr0 & LCCR0_INVALID_CONFIG_MASK)
1296 dev_warn(dev, "machine LCCR0 setting contains illegal bits: %08x\n", 1296 dev_warn(&dev->dev, "machine LCCR0 setting contains illegal bits: %08x\n",
1297 inf->lccr0 & LCCR0_INVALID_CONFIG_MASK); 1297 inf->lccr0 & LCCR0_INVALID_CONFIG_MASK);
1298 if (inf->lccr3 & LCCR3_INVALID_CONFIG_MASK) 1298 if (inf->lccr3 & LCCR3_INVALID_CONFIG_MASK)
1299 dev_warn(dev, "machine LCCR3 setting contains illegal bits: %08x\n", 1299 dev_warn(&dev->dev, "machine LCCR3 setting contains illegal bits: %08x\n",
1300 inf->lccr3 & LCCR3_INVALID_CONFIG_MASK); 1300 inf->lccr3 & LCCR3_INVALID_CONFIG_MASK);
1301 if (inf->lccr0 & LCCR0_DPD && 1301 if (inf->lccr0 & LCCR0_DPD &&
1302 ((inf->lccr0 & LCCR0_PAS) != LCCR0_Pas || 1302 ((inf->lccr0 & LCCR0_PAS) != LCCR0_Pas ||
1303 (inf->lccr0 & LCCR0_SDS) != LCCR0_Sngl || 1303 (inf->lccr0 & LCCR0_SDS) != LCCR0_Sngl ||
1304 (inf->lccr0 & LCCR0_CMS) != LCCR0_Mono)) 1304 (inf->lccr0 & LCCR0_CMS) != LCCR0_Mono))
1305 dev_warn(dev, "Double Pixel Data (DPD) mode is only valid in passive mono" 1305 dev_warn(&dev->dev, "Double Pixel Data (DPD) mode is only valid in passive mono"
1306 " single panel mode\n"); 1306 " single panel mode\n");
1307 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Act && 1307 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Act &&
1308 (inf->lccr0 & LCCR0_SDS) == LCCR0_Dual) 1308 (inf->lccr0 & LCCR0_SDS) == LCCR0_Dual)
1309 dev_warn(dev, "Dual panel only valid in passive mode\n"); 1309 dev_warn(&dev->dev, "Dual panel only valid in passive mode\n");
1310 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas && 1310 if ((inf->lccr0 & LCCR0_PAS) == LCCR0_Pas &&
1311 (inf->upper_margin || inf->lower_margin)) 1311 (inf->upper_margin || inf->lower_margin))
1312 dev_warn(dev, "Upper and lower margins must be 0 in passive mode\n"); 1312 dev_warn(&dev->dev, "Upper and lower margins must be 0 in passive mode\n");
1313#endif 1313#endif
1314 1314
1315 dev_dbg(dev, "got a %dx%dx%d LCD\n",inf->xres, inf->yres, inf->bpp); 1315 dev_dbg(&dev->dev, "got a %dx%dx%d LCD\n",inf->xres, inf->yres, inf->bpp);
1316 if (inf->xres == 0 || inf->yres == 0 || inf->bpp == 0) { 1316 if (inf->xres == 0 || inf->yres == 0 || inf->bpp == 0) {
1317 dev_err(dev, "Invalid resolution or bit depth\n"); 1317 dev_err(&dev->dev, "Invalid resolution or bit depth\n");
1318 ret = -EINVAL; 1318 ret = -EINVAL;
1319 goto failed; 1319 goto failed;
1320 } 1320 }
1321 pxafb_backlight_power = inf->pxafb_backlight_power; 1321 pxafb_backlight_power = inf->pxafb_backlight_power;
1322 pxafb_lcd_power = inf->pxafb_lcd_power; 1322 pxafb_lcd_power = inf->pxafb_lcd_power;
1323 fbi = pxafb_init_fbinfo(dev); 1323 fbi = pxafb_init_fbinfo(&dev->dev);
1324 if (!fbi) { 1324 if (!fbi) {
1325 dev_err(dev, "Failed to initialize framebuffer device\n"); 1325 dev_err(&dev->dev, "Failed to initialize framebuffer device\n");
1326 ret = -ENOMEM; // only reason for pxafb_init_fbinfo to fail is kmalloc 1326 ret = -ENOMEM; // only reason for pxafb_init_fbinfo to fail is kmalloc
1327 goto failed; 1327 goto failed;
1328 } 1328 }
@@ -1330,14 +1330,14 @@ int __init pxafb_probe(struct device *dev)
1330 /* Initialize video memory */ 1330 /* Initialize video memory */
1331 ret = pxafb_map_video_memory(fbi); 1331 ret = pxafb_map_video_memory(fbi);
1332 if (ret) { 1332 if (ret) {
1333 dev_err(dev, "Failed to allocate video RAM: %d\n", ret); 1333 dev_err(&dev->dev, "Failed to allocate video RAM: %d\n", ret);
1334 ret = -ENOMEM; 1334 ret = -ENOMEM;
1335 goto failed; 1335 goto failed;
1336 } 1336 }
1337 1337
1338 ret = request_irq(IRQ_LCD, pxafb_handle_irq, SA_INTERRUPT, "LCD", fbi); 1338 ret = request_irq(IRQ_LCD, pxafb_handle_irq, SA_INTERRUPT, "LCD", fbi);
1339 if (ret) { 1339 if (ret) {
1340 dev_err(dev, "request_irq failed: %d\n", ret); 1340 dev_err(&dev->dev, "request_irq failed: %d\n", ret);
1341 ret = -EBUSY; 1341 ret = -EBUSY;
1342 goto failed; 1342 goto failed;
1343 } 1343 }
@@ -1349,11 +1349,11 @@ int __init pxafb_probe(struct device *dev)
1349 pxafb_check_var(&fbi->fb.var, &fbi->fb); 1349 pxafb_check_var(&fbi->fb.var, &fbi->fb);
1350 pxafb_set_par(&fbi->fb); 1350 pxafb_set_par(&fbi->fb);
1351 1351
1352 dev_set_drvdata(dev, fbi); 1352 platform_set_drvdata(dev, fbi);
1353 1353
1354 ret = register_framebuffer(&fbi->fb); 1354 ret = register_framebuffer(&fbi->fb);
1355 if (ret < 0) { 1355 if (ret < 0) {
1356 dev_err(dev, "Failed to register framebuffer device: %d\n", ret); 1356 dev_err(&dev->dev, "Failed to register framebuffer device: %d\n", ret);
1357 goto failed; 1357 goto failed;
1358 } 1358 }
1359 1359
@@ -1376,26 +1376,28 @@ int __init pxafb_probe(struct device *dev)
1376 return 0; 1376 return 0;
1377 1377
1378failed: 1378failed:
1379 dev_set_drvdata(dev, NULL); 1379 platform_set_drvdata(dev, NULL);
1380 kfree(fbi); 1380 kfree(fbi);
1381 return ret; 1381 return ret;
1382} 1382}
1383 1383
1384static struct device_driver pxafb_driver = { 1384static struct platform_driver pxafb_driver = {
1385 .name = "pxa2xx-fb",
1386 .bus = &platform_bus_type,
1387 .probe = pxafb_probe, 1385 .probe = pxafb_probe,
1388#ifdef CONFIG_PM 1386#ifdef CONFIG_PM
1389 .suspend = pxafb_suspend, 1387 .suspend = pxafb_suspend,
1390 .resume = pxafb_resume, 1388 .resume = pxafb_resume,
1391#endif 1389#endif
1390 .driver = {
1391 .name = "pxa2xx-fb",
1392 },
1392}; 1393};
1393 1394
1394#ifndef MODULE 1395#ifndef MODULE
1395int __devinit pxafb_setup(char *options) 1396int __devinit pxafb_setup(char *options)
1396{ 1397{
1397# ifdef CONFIG_FB_PXA_PARAMETERS 1398# ifdef CONFIG_FB_PXA_PARAMETERS
1398 strlcpy(g_options, options, sizeof(g_options)); 1399 if (options)
1400 strlcpy(g_options, options, sizeof(g_options));
1399# endif 1401# endif
1400 return 0; 1402 return 0;
1401} 1403}
@@ -1415,7 +1417,7 @@ int __devinit pxafb_init(void)
1415 return -ENODEV; 1417 return -ENODEV;
1416 pxafb_setup(option); 1418 pxafb_setup(option);
1417#endif 1419#endif
1418 return driver_register(&pxafb_driver); 1420 return platform_driver_register(&pxafb_driver);
1419} 1421}
1420 1422
1421module_init(pxafb_init); 1423module_init(pxafb_init);
diff --git a/drivers/video/q40fb.c b/drivers/video/q40fb.c
index bfc41f2c902a..fc91dbf896d2 100644
--- a/drivers/video/q40fb.c
+++ b/drivers/video/q40fb.c
@@ -86,9 +86,8 @@ static struct fb_ops q40fb_ops = {
86 .fb_imageblit = cfb_imageblit, 86 .fb_imageblit = cfb_imageblit,
87}; 87};
88 88
89static int __init q40fb_probe(struct device *device) 89static int __init q40fb_probe(struct platform_device *dev)
90{ 90{
91 struct platform_device *dev = to_platform_device(device);
92 struct fb_info *info; 91 struct fb_info *info;
93 92
94 if (!MACH_IS_Q40) 93 if (!MACH_IS_Q40)
@@ -128,10 +127,11 @@ static int __init q40fb_probe(struct device *device)
128 return 0; 127 return 0;
129} 128}
130 129
131static struct device_driver q40fb_driver = { 130static struct platform_driver q40fb_driver = {
132 .name = "q40fb",
133 .bus = &platform_bus_type,
134 .probe = q40fb_probe, 131 .probe = q40fb_probe,
132 .driver = {
133 .name = "q40fb",
134 },
135}; 135};
136 136
137static struct platform_device q40fb_device = { 137static struct platform_device q40fb_device = {
@@ -145,12 +145,12 @@ int __init q40fb_init(void)
145 if (fb_get_options("q40fb", NULL)) 145 if (fb_get_options("q40fb", NULL))
146 return -ENODEV; 146 return -ENODEV;
147 147
148 ret = driver_register(&q40fb_driver); 148 ret = platform_driver_register(&q40fb_driver);
149 149
150 if (!ret) { 150 if (!ret) {
151 ret = platform_device_register(&q40fb_device); 151 ret = platform_device_register(&q40fb_device);
152 if (ret) 152 if (ret)
153 driver_unregister(&q40fb_driver); 153 platform_driver_unregister(&q40fb_driver);
154 } 154 }
155 return ret; 155 return ret;
156} 156}
diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
index 3edbd14c5c46..e5d0f92eeae3 100644
--- a/drivers/video/s1d13xxxfb.c
+++ b/drivers/video/s1d13xxxfb.c
@@ -503,10 +503,9 @@ s1d13xxxfb_fetch_hw_state(struct fb_info *info)
503 503
504 504
505static int 505static int
506s1d13xxxfb_remove(struct device *dev) 506s1d13xxxfb_remove(struct platform_device *pdev)
507{ 507{
508 struct fb_info *info = dev_get_drvdata(dev); 508 struct fb_info *info = platform_get_drvdata(pdev);
509 struct platform_device *pdev = to_platform_device(dev);
510 struct s1d13xxxfb_par *par = NULL; 509 struct s1d13xxxfb_par *par = NULL;
511 510
512 if (info) { 511 if (info) {
@@ -534,9 +533,8 @@ s1d13xxxfb_remove(struct device *dev)
534} 533}
535 534
536static int __devinit 535static int __devinit
537s1d13xxxfb_probe(struct device *dev) 536s1d13xxxfb_probe(struct platform_device *pdev)
538{ 537{
539 struct platform_device *pdev = to_platform_device(dev);
540 struct s1d13xxxfb_par *default_par; 538 struct s1d13xxxfb_par *default_par;
541 struct fb_info *info; 539 struct fb_info *info;
542 struct s1d13xxxfb_pdata *pdata = NULL; 540 struct s1d13xxxfb_pdata *pdata = NULL;
@@ -548,8 +546,8 @@ s1d13xxxfb_probe(struct device *dev)
548 printk(KERN_INFO "Epson S1D13XXX FB Driver\n"); 546 printk(KERN_INFO "Epson S1D13XXX FB Driver\n");
549 547
550 /* enable platform-dependent hardware glue, if any */ 548 /* enable platform-dependent hardware glue, if any */
551 if (dev->platform_data) 549 if (pdev->dev.platform_data)
552 pdata = dev->platform_data; 550 pdata = pdev->dev.platform_data;
553 551
554 if (pdata && pdata->platform_init_video) 552 if (pdata && pdata->platform_init_video)
555 pdata->platform_init_video(); 553 pdata->platform_init_video();
@@ -572,14 +570,14 @@ s1d13xxxfb_probe(struct device *dev)
572 570
573 if (!request_mem_region(pdev->resource[0].start, 571 if (!request_mem_region(pdev->resource[0].start,
574 pdev->resource[0].end - pdev->resource[0].start +1, "s1d13xxxfb mem")) { 572 pdev->resource[0].end - pdev->resource[0].start +1, "s1d13xxxfb mem")) {
575 dev_dbg(dev, "request_mem_region failed\n"); 573 dev_dbg(&pdev->dev, "request_mem_region failed\n");
576 ret = -EBUSY; 574 ret = -EBUSY;
577 goto bail; 575 goto bail;
578 } 576 }
579 577
580 if (!request_mem_region(pdev->resource[1].start, 578 if (!request_mem_region(pdev->resource[1].start,
581 pdev->resource[1].end - pdev->resource[1].start +1, "s1d13xxxfb regs")) { 579 pdev->resource[1].end - pdev->resource[1].start +1, "s1d13xxxfb regs")) {
582 dev_dbg(dev, "request_mem_region failed\n"); 580 dev_dbg(&pdev->dev, "request_mem_region failed\n");
583 ret = -EBUSY; 581 ret = -EBUSY;
584 goto bail; 582 goto bail;
585 } 583 }
@@ -640,7 +638,7 @@ s1d13xxxfb_probe(struct device *dev)
640 goto bail; 638 goto bail;
641 } 639 }
642 640
643 dev_set_drvdata(&pdev->dev, info); 641 platform_set_drvdata(pdev, info);
644 642
645 printk(KERN_INFO "fb%d: %s frame buffer device\n", 643 printk(KERN_INFO "fb%d: %s frame buffer device\n",
646 info->node, info->fix.id); 644 info->node, info->fix.id);
@@ -648,15 +646,15 @@ s1d13xxxfb_probe(struct device *dev)
648 return 0; 646 return 0;
649 647
650bail: 648bail:
651 s1d13xxxfb_remove(dev); 649 s1d13xxxfb_remove(pdev);
652 return ret; 650 return ret;
653 651
654} 652}
655 653
656#ifdef CONFIG_PM 654#ifdef CONFIG_PM
657static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state) 655static int s1d13xxxfb_suspend(struct platform_device *dev, pm_message_t state)
658{ 656{
659 struct fb_info *info = dev_get_drvdata(dev); 657 struct fb_info *info = platform_get_drvdata(dev);
660 struct s1d13xxxfb_par *s1dfb = info->par; 658 struct s1d13xxxfb_par *s1dfb = info->par;
661 struct s1d13xxxfb_pdata *pdata = NULL; 659 struct s1d13xxxfb_pdata *pdata = NULL;
662 660
@@ -664,8 +662,8 @@ static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state)
664 lcd_enable(s1dfb, 0); 662 lcd_enable(s1dfb, 0);
665 crt_enable(s1dfb, 0); 663 crt_enable(s1dfb, 0);
666 664
667 if (dev->platform_data) 665 if (dev->dev.platform_data)
668 pdata = dev->platform_data; 666 pdata = dev->dev.platform_data;
669 667
670#if 0 668#if 0
671 if (!s1dfb->disp_save) 669 if (!s1dfb->disp_save)
@@ -701,9 +699,9 @@ static int s1d13xxxfb_suspend(struct device *dev, pm_message_t state)
701 return 0; 699 return 0;
702} 700}
703 701
704static int s1d13xxxfb_resume(struct device *dev) 702static int s1d13xxxfb_resume(struct platform_device *dev)
705{ 703{
706 struct fb_info *info = dev_get_drvdata(dev); 704 struct fb_info *info = platform_get_drvdata(dev);
707 struct s1d13xxxfb_par *s1dfb = info->par; 705 struct s1d13xxxfb_par *s1dfb = info->par;
708 struct s1d13xxxfb_pdata *pdata = NULL; 706 struct s1d13xxxfb_pdata *pdata = NULL;
709 707
@@ -714,8 +712,8 @@ static int s1d13xxxfb_resume(struct device *dev)
714 while ((s1d13xxxfb_readreg(s1dfb, S1DREG_PS_STATUS) & 0x01)) 712 while ((s1d13xxxfb_readreg(s1dfb, S1DREG_PS_STATUS) & 0x01))
715 udelay(10); 713 udelay(10);
716 714
717 if (dev->platform_data) 715 if (dev->dev.platform_data)
718 pdata = dev->platform_data; 716 pdata = dev->dev.platform_data;
719 717
720 if (s1dfb->regs_save) { 718 if (s1dfb->regs_save) {
721 /* will write RO regs, *should* get away with it :) */ 719 /* will write RO regs, *should* get away with it :) */
@@ -741,15 +739,16 @@ static int s1d13xxxfb_resume(struct device *dev)
741} 739}
742#endif /* CONFIG_PM */ 740#endif /* CONFIG_PM */
743 741
744static struct device_driver s1d13xxxfb_driver = { 742static struct platform_driver s1d13xxxfb_driver = {
745 .name = S1D_DEVICENAME,
746 .bus = &platform_bus_type,
747 .probe = s1d13xxxfb_probe, 743 .probe = s1d13xxxfb_probe,
748 .remove = s1d13xxxfb_remove, 744 .remove = s1d13xxxfb_remove,
749#ifdef CONFIG_PM 745#ifdef CONFIG_PM
750 .suspend = s1d13xxxfb_suspend, 746 .suspend = s1d13xxxfb_suspend,
751 .resume = s1d13xxxfb_resume 747 .resume = s1d13xxxfb_resume,
752#endif 748#endif
749 .driver = {
750 .name = S1D_DEVICENAME,
751 },
753}; 752};
754 753
755 754
@@ -759,14 +758,14 @@ s1d13xxxfb_init(void)
759 if (fb_get_options("s1d13xxxfb", NULL)) 758 if (fb_get_options("s1d13xxxfb", NULL))
760 return -ENODEV; 759 return -ENODEV;
761 760
762 return driver_register(&s1d13xxxfb_driver); 761 return platform_driver_register(&s1d13xxxfb_driver);
763} 762}
764 763
765 764
766static void __exit 765static void __exit
767s1d13xxxfb_exit(void) 766s1d13xxxfb_exit(void)
768{ 767{
769 driver_unregister(&s1d13xxxfb_driver); 768 platform_driver_unregister(&s1d13xxxfb_driver);
770} 769}
771 770
772module_init(s1d13xxxfb_init); 771module_init(s1d13xxxfb_init);
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index 855a6778b9eb..ce6e749db3a7 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -634,19 +634,18 @@ static irqreturn_t s3c2410fb_irq(int irq, void *dev_id, struct pt_regs *r)
634 634
635static char driver_name[]="s3c2410fb"; 635static char driver_name[]="s3c2410fb";
636 636
637int __init s3c2410fb_probe(struct device *dev) 637int __init s3c2410fb_probe(struct platform_device *pdev)
638{ 638{
639 struct s3c2410fb_info *info; 639 struct s3c2410fb_info *info;
640 struct fb_info *fbinfo; 640 struct fb_info *fbinfo;
641 struct platform_device *pdev = to_platform_device(dev);
642 struct s3c2410fb_hw *mregs; 641 struct s3c2410fb_hw *mregs;
643 int ret; 642 int ret;
644 int irq; 643 int irq;
645 int i; 644 int i;
646 645
647 mach_info = dev->platform_data; 646 mach_info = pdev->dev.platform_data;
648 if (mach_info == NULL) { 647 if (mach_info == NULL) {
649 dev_err(dev,"no platform data for lcd, cannot attach\n"); 648 dev_err(&pdev->dev,"no platform data for lcd, cannot attach\n");
650 return -EINVAL; 649 return -EINVAL;
651 } 650 }
652 651
@@ -654,11 +653,11 @@ int __init s3c2410fb_probe(struct device *dev)
654 653
655 irq = platform_get_irq(pdev, 0); 654 irq = platform_get_irq(pdev, 0);
656 if (irq < 0) { 655 if (irq < 0) {
657 dev_err(dev, "no irq for device\n"); 656 dev_err(&pdev->dev, "no irq for device\n");
658 return -ENOENT; 657 return -ENOENT;
659 } 658 }
660 659
661 fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), dev); 660 fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), &pdev->dev);
662 if (!fbinfo) { 661 if (!fbinfo) {
663 return -ENOMEM; 662 return -ENOMEM;
664 } 663 }
@@ -666,7 +665,7 @@ int __init s3c2410fb_probe(struct device *dev)
666 665
667 info = fbinfo->par; 666 info = fbinfo->par;
668 info->fb = fbinfo; 667 info->fb = fbinfo;
669 dev_set_drvdata(dev, fbinfo); 668 platform_set_drvdata(pdev, fbinfo);
670 669
671 s3c2410fb_init_registers(info); 670 s3c2410fb_init_registers(info);
672 671
@@ -676,7 +675,7 @@ int __init s3c2410fb_probe(struct device *dev)
676 675
677 memcpy(&info->regs, &mach_info->regs, sizeof(info->regs)); 676 memcpy(&info->regs, &mach_info->regs, sizeof(info->regs));
678 677
679 info->mach_info = dev->platform_data; 678 info->mach_info = pdev->dev.platform_data;
680 679
681 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; 680 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
682 fbinfo->fix.type_aux = 0; 681 fbinfo->fix.type_aux = 0;
@@ -735,7 +734,7 @@ int __init s3c2410fb_probe(struct device *dev)
735 734
736 ret = request_irq(irq, s3c2410fb_irq, SA_INTERRUPT, pdev->name, info); 735 ret = request_irq(irq, s3c2410fb_irq, SA_INTERRUPT, pdev->name, info);
737 if (ret) { 736 if (ret) {
738 dev_err(dev, "cannot get irq %d - err %d\n", irq, ret); 737 dev_err(&pdev->dev, "cannot get irq %d - err %d\n", irq, ret);
739 ret = -EBUSY; 738 ret = -EBUSY;
740 goto release_mem; 739 goto release_mem;
741 } 740 }
@@ -773,7 +772,7 @@ int __init s3c2410fb_probe(struct device *dev)
773 } 772 }
774 773
775 /* create device files */ 774 /* create device files */
776 device_create_file(dev, &dev_attr_debug); 775 device_create_file(&pdev->dev, &dev_attr_debug);
777 776
778 printk(KERN_INFO "fb%d: %s frame buffer device\n", 777 printk(KERN_INFO "fb%d: %s frame buffer device\n",
779 fbinfo->node, fbinfo->fix.id); 778 fbinfo->node, fbinfo->fix.id);
@@ -816,10 +815,9 @@ static void s3c2410fb_stop_lcd(void)
816/* 815/*
817 * Cleanup 816 * Cleanup
818 */ 817 */
819static int s3c2410fb_remove(struct device *dev) 818static int s3c2410fb_remove(struct platform_device *pdev)
820{ 819{
821 struct platform_device *pdev = to_platform_device(dev); 820 struct fb_info *fbinfo = platform_get_drvdata(pdev);
822 struct fb_info *fbinfo = dev_get_drvdata(dev);
823 struct s3c2410fb_info *info = fbinfo->par; 821 struct s3c2410fb_info *info = fbinfo->par;
824 int irq; 822 int irq;
825 823
@@ -847,9 +845,9 @@ static int s3c2410fb_remove(struct device *dev)
847 845
848/* suspend and resume support for the lcd controller */ 846/* suspend and resume support for the lcd controller */
849 847
850static int s3c2410fb_suspend(struct device *dev, pm_message_t state) 848static int s3c2410fb_suspend(struct platform_device *dev, pm_message_t state)
851{ 849{
852 struct fb_info *fbinfo = dev_get_drvdata(dev); 850 struct fb_info *fbinfo = platform_get_drvdata(dev);
853 struct s3c2410fb_info *info = fbinfo->par; 851 struct s3c2410fb_info *info = fbinfo->par;
854 852
855 s3c2410fb_stop_lcd(); 853 s3c2410fb_stop_lcd();
@@ -864,9 +862,9 @@ static int s3c2410fb_suspend(struct device *dev, pm_message_t state)
864 return 0; 862 return 0;
865} 863}
866 864
867static int s3c2410fb_resume(struct device *dev) 865static int s3c2410fb_resume(struct platform_device *dev)
868{ 866{
869 struct fb_info *fbinfo = dev_get_drvdata(dev); 867 struct fb_info *fbinfo = platform_get_drvdata(dev);
870 struct s3c2410fb_info *info = fbinfo->par; 868 struct s3c2410fb_info *info = fbinfo->par;
871 869
872 clk_enable(info->clk); 870 clk_enable(info->clk);
@@ -882,24 +880,25 @@ static int s3c2410fb_resume(struct device *dev)
882#define s3c2410fb_resume NULL 880#define s3c2410fb_resume NULL
883#endif 881#endif
884 882
885static struct device_driver s3c2410fb_driver = { 883static struct platform_driver s3c2410fb_driver = {
886 .name = "s3c2410-lcd",
887 .owner = THIS_MODULE,
888 .bus = &platform_bus_type,
889 .probe = s3c2410fb_probe, 884 .probe = s3c2410fb_probe,
885 .remove = s3c2410fb_remove,
890 .suspend = s3c2410fb_suspend, 886 .suspend = s3c2410fb_suspend,
891 .resume = s3c2410fb_resume, 887 .resume = s3c2410fb_resume,
892 .remove = s3c2410fb_remove 888 .driver = {
889 .name = "s3c2410-lcd",
890 .owner = THIS_MODULE,
891 },
893}; 892};
894 893
895int __devinit s3c2410fb_init(void) 894int __devinit s3c2410fb_init(void)
896{ 895{
897 return driver_register(&s3c2410fb_driver); 896 return platform_driver_register(&s3c2410fb_driver);
898} 897}
899 898
900static void __exit s3c2410fb_cleanup(void) 899static void __exit s3c2410fb_cleanup(void)
901{ 900{
902 driver_unregister(&s3c2410fb_driver); 901 platform_driver_unregister(&s3c2410fb_driver);
903} 902}
904 903
905 904
diff --git a/drivers/video/sa1100fb.c b/drivers/video/sa1100fb.c
index a5184575cfae..2ea1354e439f 100644
--- a/drivers/video/sa1100fb.c
+++ b/drivers/video/sa1100fb.c
@@ -1308,17 +1308,17 @@ sa1100fb_freq_policy(struct notifier_block *nb, unsigned long val,
1308 * Power management hooks. Note that we won't be called from IRQ context, 1308 * Power management hooks. Note that we won't be called from IRQ context,
1309 * unlike the blank functions above, so we may sleep. 1309 * unlike the blank functions above, so we may sleep.
1310 */ 1310 */
1311static int sa1100fb_suspend(struct device *dev, pm_message_t state) 1311static int sa1100fb_suspend(struct platform_device *dev, pm_message_t state)
1312{ 1312{
1313 struct sa1100fb_info *fbi = dev_get_drvdata(dev); 1313 struct sa1100fb_info *fbi = platform_get_drvdata(dev);
1314 1314
1315 set_ctrlr_state(fbi, C_DISABLE_PM); 1315 set_ctrlr_state(fbi, C_DISABLE_PM);
1316 return 0; 1316 return 0;
1317} 1317}
1318 1318
1319static int sa1100fb_resume(struct device *dev) 1319static int sa1100fb_resume(struct platform_device *dev)
1320{ 1320{
1321 struct sa1100fb_info *fbi = dev_get_drvdata(dev); 1321 struct sa1100fb_info *fbi = platform_get_drvdata(dev);
1322 1322
1323 set_ctrlr_state(fbi, C_ENABLE_PM); 1323 set_ctrlr_state(fbi, C_ENABLE_PM);
1324 return 0; 1324 return 0;
@@ -1452,7 +1452,7 @@ static struct sa1100fb_info * __init sa1100fb_init_fbinfo(struct device *dev)
1452 return fbi; 1452 return fbi;
1453} 1453}
1454 1454
1455static int __init sa1100fb_probe(struct device *dev) 1455static int __init sa1100fb_probe(struct platform_device *pdev)
1456{ 1456{
1457 struct sa1100fb_info *fbi; 1457 struct sa1100fb_info *fbi;
1458 int ret; 1458 int ret;
@@ -1460,7 +1460,7 @@ static int __init sa1100fb_probe(struct device *dev)
1460 if (!request_mem_region(0xb0100000, 0x10000, "LCD")) 1460 if (!request_mem_region(0xb0100000, 0x10000, "LCD"))
1461 return -EBUSY; 1461 return -EBUSY;
1462 1462
1463 fbi = sa1100fb_init_fbinfo(dev); 1463 fbi = sa1100fb_init_fbinfo(&pdev->dev);
1464 ret = -ENOMEM; 1464 ret = -ENOMEM;
1465 if (!fbi) 1465 if (!fbi)
1466 goto failed; 1466 goto failed;
@@ -1488,7 +1488,7 @@ static int __init sa1100fb_probe(struct device *dev)
1488 */ 1488 */
1489 sa1100fb_check_var(&fbi->fb.var, &fbi->fb); 1489 sa1100fb_check_var(&fbi->fb.var, &fbi->fb);
1490 1490
1491 dev_set_drvdata(dev, fbi); 1491 platform_set_drvdata(pdev, fbi);
1492 1492
1493 ret = register_framebuffer(&fbi->fb); 1493 ret = register_framebuffer(&fbi->fb);
1494 if (ret < 0) 1494 if (ret < 0)
@@ -1505,18 +1505,19 @@ static int __init sa1100fb_probe(struct device *dev)
1505 return 0; 1505 return 0;
1506 1506
1507failed: 1507failed:
1508 dev_set_drvdata(dev, NULL); 1508 platform_set_drvdata(pdev, NULL);
1509 kfree(fbi); 1509 kfree(fbi);
1510 release_mem_region(0xb0100000, 0x10000); 1510 release_mem_region(0xb0100000, 0x10000);
1511 return ret; 1511 return ret;
1512} 1512}
1513 1513
1514static struct device_driver sa1100fb_driver = { 1514static struct platform_driver sa1100fb_driver = {
1515 .name = "sa11x0-fb",
1516 .bus = &platform_bus_type,
1517 .probe = sa1100fb_probe, 1515 .probe = sa1100fb_probe,
1518 .suspend = sa1100fb_suspend, 1516 .suspend = sa1100fb_suspend,
1519 .resume = sa1100fb_resume, 1517 .resume = sa1100fb_resume,
1518 .driver = {
1519 .name = "sa11x0-fb",
1520 },
1520}; 1521};
1521 1522
1522int __init sa1100fb_init(void) 1523int __init sa1100fb_init(void)
@@ -1524,7 +1525,7 @@ int __init sa1100fb_init(void)
1524 if (fb_get_options("sa1100fb", NULL)) 1525 if (fb_get_options("sa1100fb", NULL))
1525 return -ENODEV; 1526 return -ENODEV;
1526 1527
1527 return driver_register(&sa1100fb_driver); 1528 return platform_driver_register(&sa1100fb_driver);
1528} 1529}
1529 1530
1530int __init sa1100fb_setup(char *options) 1531int __init sa1100fb_setup(char *options)
diff --git a/drivers/video/sbuslib.c b/drivers/video/sbuslib.c
index 34f72edba820..3a74a63dd4f2 100644
--- a/drivers/video/sbuslib.c
+++ b/drivers/video/sbuslib.c
@@ -3,6 +3,7 @@
3 * Copyright (C) 2003 David S. Miller (davem@redhat.com) 3 * Copyright (C) 2003 David S. Miller (davem@redhat.com)
4 */ 4 */
5 5
6#include <linux/compat.h>
6#include <linux/kernel.h> 7#include <linux/kernel.h>
7#include <linux/module.h> 8#include <linux/module.h>
8#include <linux/string.h> 9#include <linux/string.h>
@@ -45,6 +46,9 @@ int sbusfb_mmap_helper(struct sbus_mmap_map *map,
45 unsigned long off; 46 unsigned long off;
46 int i; 47 int i;
47 48
49 if (!(vma->vm_flags & (VM_SHARED | VM_MAYSHARE)))
50 return -EINVAL;
51
48 size = vma->vm_end - vma->vm_start; 52 size = vma->vm_end - vma->vm_start;
49 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) 53 if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
50 return -EINVAL; 54 return -EINVAL;
@@ -182,3 +186,109 @@ int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
182 }; 186 };
183} 187}
184EXPORT_SYMBOL(sbusfb_ioctl_helper); 188EXPORT_SYMBOL(sbusfb_ioctl_helper);
189
190#ifdef CONFIG_COMPAT
191struct fbcmap32 {
192 int index; /* first element (0 origin) */
193 int count;
194 u32 red;
195 u32 green;
196 u32 blue;
197};
198
199#define FBIOPUTCMAP32 _IOW('F', 3, struct fbcmap32)
200#define FBIOGETCMAP32 _IOW('F', 4, struct fbcmap32)
201
202static int fbiogetputcmap(struct file *file, struct fb_info *info,
203 unsigned int cmd, unsigned long arg)
204{
205 struct fbcmap32 __user *argp = (void __user *)arg;
206 struct fbcmap __user *p = compat_alloc_user_space(sizeof(*p));
207 u32 addr;
208 int ret;
209
210 ret = copy_in_user(p, argp, 2 * sizeof(int));
211 ret |= get_user(addr, &argp->red);
212 ret |= put_user(compat_ptr(addr), &p->red);
213 ret |= get_user(addr, &argp->green);
214 ret |= put_user(compat_ptr(addr), &p->green);
215 ret |= get_user(addr, &argp->blue);
216 ret |= put_user(compat_ptr(addr), &p->blue);
217 if (ret)
218 return -EFAULT;
219 return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
220 (cmd == FBIOPUTCMAP32) ?
221 FBIOPUTCMAP_SPARC : FBIOGETCMAP_SPARC,
222 (unsigned long)p, info);
223}
224
225struct fbcursor32 {
226 short set; /* what to set, choose from the list above */
227 short enable; /* cursor on/off */
228 struct fbcurpos pos; /* cursor position */
229 struct fbcurpos hot; /* cursor hot spot */
230 struct fbcmap32 cmap; /* color map info */
231 struct fbcurpos size; /* cursor bit map size */
232 u32 image; /* cursor image bits */
233 u32 mask; /* cursor mask bits */
234};
235
236#define FBIOSCURSOR32 _IOW('F', 24, struct fbcursor32)
237#define FBIOGCURSOR32 _IOW('F', 25, struct fbcursor32)
238
239static int fbiogscursor(struct file *file, struct fb_info *info,
240 unsigned long arg)
241{
242 struct fbcursor __user *p = compat_alloc_user_space(sizeof(*p));
243 struct fbcursor32 __user *argp = (void __user *)arg;
244 compat_uptr_t addr;
245 int ret;
246
247 ret = copy_in_user(p, argp,
248 2 * sizeof (short) + 2 * sizeof(struct fbcurpos));
249 ret |= copy_in_user(&p->size, &argp->size, sizeof(struct fbcurpos));
250 ret |= copy_in_user(&p->cmap, &argp->cmap, 2 * sizeof(int));
251 ret |= get_user(addr, &argp->cmap.red);
252 ret |= put_user(compat_ptr(addr), &p->cmap.red);
253 ret |= get_user(addr, &argp->cmap.green);
254 ret |= put_user(compat_ptr(addr), &p->cmap.green);
255 ret |= get_user(addr, &argp->cmap.blue);
256 ret |= put_user(compat_ptr(addr), &p->cmap.blue);
257 ret |= get_user(addr, &argp->mask);
258 ret |= put_user(compat_ptr(addr), &p->mask);
259 ret |= get_user(addr, &argp->image);
260 ret |= put_user(compat_ptr(addr), &p->image);
261 if (ret)
262 return -EFAULT;
263 return info->fbops->fb_ioctl(file->f_dentry->d_inode, file,
264 FBIOSCURSOR, (unsigned long)p, info);
265}
266
267long sbusfb_compat_ioctl(struct file *file, unsigned int cmd,
268 unsigned long arg, struct fb_info *info)
269{
270 switch (cmd) {
271 case FBIOGTYPE:
272 case FBIOSATTR:
273 case FBIOGATTR:
274 case FBIOSVIDEO:
275 case FBIOGVIDEO:
276 case FBIOGCURSOR32: /* This is not implemented yet.
277 Later it should be converted... */
278 case FBIOSCURPOS:
279 case FBIOGCURPOS:
280 case FBIOGCURMAX:
281 return info->fbops->fb_ioctl(file->f_dentry->d_inode,
282 file, cmd, arg, info);
283 case FBIOPUTCMAP32:
284 return fbiogetputcmap(file, info, cmd, arg);
285 case FBIOGETCMAP32:
286 return fbiogetputcmap(file, info, cmd, arg);
287 case FBIOSCURSOR32:
288 return fbiogscursor(file, info, arg);
289 default:
290 return -ENOIOCTLCMD;
291 }
292}
293EXPORT_SYMBOL(sbusfb_compat_ioctl);
294#endif
diff --git a/drivers/video/sbuslib.h b/drivers/video/sbuslib.h
index a6aa33ba09d6..b470e52ce9e2 100644
--- a/drivers/video/sbuslib.h
+++ b/drivers/video/sbuslib.h
@@ -20,5 +20,7 @@ extern int sbusfb_mmap_helper(struct sbus_mmap_map *map,
20int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg, 20int sbusfb_ioctl_helper(unsigned long cmd, unsigned long arg,
21 struct fb_info *info, 21 struct fb_info *info,
22 int type, int fb_depth, unsigned long fb_size); 22 int type, int fb_depth, unsigned long fb_size);
23long sbusfb_compat_ioctl(struct file *file, unsigned int cmd,
24 unsigned long arg, struct fb_info *info);
23 25
24#endif /* _SBUSLIB_H */ 26#endif /* _SBUSLIB_H */
diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
index 2e8769dd345a..7054660767e4 100644
--- a/drivers/video/sgivwfb.c
+++ b/drivers/video/sgivwfb.c
@@ -750,9 +750,8 @@ int __init sgivwfb_setup(char *options)
750/* 750/*
751 * Initialisation 751 * Initialisation
752 */ 752 */
753static int __init sgivwfb_probe(struct device *device) 753static int __init sgivwfb_probe(struct platform_device *dev)
754{ 754{
755 struct platform_device *dev = to_platform_device(device);
756 struct sgivw_par *par; 755 struct sgivw_par *par;
757 struct fb_info *info; 756 struct fb_info *info;
758 char *monitor; 757 char *monitor;
@@ -813,7 +812,7 @@ static int __init sgivwfb_probe(struct device *device)
813 goto fail_register_framebuffer; 812 goto fail_register_framebuffer;
814 } 813 }
815 814
816 dev_set_drvdata(&dev->dev, info); 815 platform_set_drvdata(dev, info);
817 816
818 printk(KERN_INFO "fb%d: SGI DBE frame buffer device, using %ldK of video memory at %#lx\n", 817 printk(KERN_INFO "fb%d: SGI DBE frame buffer device, using %ldK of video memory at %#lx\n",
819 info->node, sgivwfb_mem_size >> 10, sgivwfb_mem_phys); 818 info->node, sgivwfb_mem_size >> 10, sgivwfb_mem_phys);
@@ -831,9 +830,9 @@ fail_ioremap_regs:
831 return -ENXIO; 830 return -ENXIO;
832} 831}
833 832
834static int sgivwfb_remove(struct device *device) 833static int sgivwfb_remove(struct platform_device *dev)
835{ 834{
836 struct fb_info *info = dev_get_drvdata(device); 835 struct fb_info *info = platform_get_drvdata(dev);
837 836
838 if (info) { 837 if (info) {
839 struct sgivw_par *par = info->par; 838 struct sgivw_par *par = info->par;
@@ -847,11 +846,12 @@ static int sgivwfb_remove(struct device *device)
847 return 0; 846 return 0;
848} 847}
849 848
850static struct device_driver sgivwfb_driver = { 849static struct platform_driver sgivwfb_driver = {
851 .name = "sgivwfb",
852 .bus = &platform_bus_type,
853 .probe = sgivwfb_probe, 850 .probe = sgivwfb_probe,
854 .remove = sgivwfb_remove, 851 .remove = sgivwfb_remove,
852 .driver = {
853 .name = "sgivwfb",
854 },
855}; 855};
856 856
857static struct platform_device *sgivwfb_device; 857static struct platform_device *sgivwfb_device;
@@ -867,7 +867,7 @@ int __init sgivwfb_init(void)
867 return -ENODEV; 867 return -ENODEV;
868 sgivwfb_setup(option); 868 sgivwfb_setup(option);
869#endif 869#endif
870 ret = driver_register(&sgivwfb_driver); 870 ret = platform_driver_register(&sgivwfb_driver);
871 if (!ret) { 871 if (!ret) {
872 sgivwfb_device = platform_device_alloc("sgivwfb", 0); 872 sgivwfb_device = platform_device_alloc("sgivwfb", 0);
873 if (sgivwfb_device) { 873 if (sgivwfb_device) {
@@ -875,7 +875,7 @@ int __init sgivwfb_init(void)
875 } else 875 } else
876 ret = -ENOMEM; 876 ret = -ENOMEM;
877 if (ret) { 877 if (ret) {
878 driver_unregister(&sgivwfb_driver); 878 platform_driver_unregister(&sgivwfb_driver);
879 platform_device_put(sgivwfb_device); 879 platform_device_put(sgivwfb_device);
880 } 880 }
881 } 881 }
@@ -890,7 +890,7 @@ MODULE_LICENSE("GPL");
890static void __exit sgivwfb_exit(void) 890static void __exit sgivwfb_exit(void)
891{ 891{
892 platform_device_unregister(sgivwfb_device); 892 platform_device_unregister(sgivwfb_device);
893 driver_unregister(&sgivwfb_driver); 893 platform_driver_unregister(&sgivwfb_driver);
894} 894}
895 895
896module_exit(sgivwfb_exit); 896module_exit(sgivwfb_exit);
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index 59fff29bc02e..2b27b4474001 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -52,6 +52,9 @@ static struct fb_ops tcx_ops = {
52 .fb_imageblit = cfb_imageblit, 52 .fb_imageblit = cfb_imageblit,
53 .fb_mmap = tcx_mmap, 53 .fb_mmap = tcx_mmap,
54 .fb_ioctl = tcx_ioctl, 54 .fb_ioctl = tcx_ioctl,
55#ifdef CONFIG_COMPAT
56 .fb_compat_ioctl = sbusfb_compat_ioctl,
57#endif
55}; 58};
56 59
57/* THC definitions */ 60/* THC definitions */
@@ -122,7 +125,6 @@ struct tcx_par {
122 int lowdepth; 125 int lowdepth;
123 126
124 struct sbus_dev *sdev; 127 struct sbus_dev *sdev;
125 struct list_head list;
126}; 128};
127 129
128/* Reset control plane so that WID is 8-bit plane. */ 130/* Reset control plane so that WID is 8-bit plane. */
@@ -441,7 +443,7 @@ static void tcx_init_one(struct sbus_dev *sdev)
441 443
442 tcx_reset(&all->info); 444 tcx_reset(&all->info);
443 445
444 tcx_blank(0, &all->info); 446 tcx_blank(FB_BLANK_UNBLANK, &all->info);
445 447
446 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) { 448 if (fb_alloc_cmap(&all->info.cmap, 256, 0)) {
447 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/video/vesafb.c b/drivers/video/vesafb.c
index e25eae1a78c1..3e58ddc2bc38 100644
--- a/drivers/video/vesafb.c
+++ b/drivers/video/vesafb.c
@@ -245,9 +245,8 @@ static int __init vesafb_setup(char *options)
245 return 0; 245 return 0;
246} 246}
247 247
248static int __init vesafb_probe(struct device *device) 248static int __init vesafb_probe(struct platform_device *dev)
249{ 249{
250 struct platform_device *dev = to_platform_device(device);
251 struct fb_info *info; 250 struct fb_info *info;
252 int i, err; 251 int i, err;
253 unsigned int size_vmode; 252 unsigned int size_vmode;
@@ -414,6 +413,7 @@ static int __init vesafb_probe(struct device *device)
414 * region already (FIXME) */ 413 * region already (FIXME) */
415 request_region(0x3c0, 32, "vesafb"); 414 request_region(0x3c0, 32, "vesafb");
416 415
416#ifdef CONFIG_MTRR
417 if (mtrr) { 417 if (mtrr) {
418 unsigned int temp_size = size_total; 418 unsigned int temp_size = size_total;
419 unsigned int type = 0; 419 unsigned int type = 0;
@@ -451,6 +451,7 @@ static int __init vesafb_probe(struct device *device)
451 } while (temp_size >= PAGE_SIZE && rc == -EINVAL); 451 } while (temp_size >= PAGE_SIZE && rc == -EINVAL);
452 } 452 }
453 } 453 }
454#endif
454 455
455 info->fbops = &vesafb_ops; 456 info->fbops = &vesafb_ops;
456 info->var = vesafb_defined; 457 info->var = vesafb_defined;
@@ -480,10 +481,11 @@ err:
480 return err; 481 return err;
481} 482}
482 483
483static struct device_driver vesafb_driver = { 484static struct platform_driver vesafb_driver = {
484 .name = "vesafb",
485 .bus = &platform_bus_type,
486 .probe = vesafb_probe, 485 .probe = vesafb_probe,
486 .driver = {
487 .name = "vesafb",
488 },
487}; 489};
488 490
489static struct platform_device vesafb_device = { 491static struct platform_device vesafb_device = {
@@ -498,12 +500,12 @@ static int __init vesafb_init(void)
498 /* ignore error return of fb_get_options */ 500 /* ignore error return of fb_get_options */
499 fb_get_options("vesafb", &option); 501 fb_get_options("vesafb", &option);
500 vesafb_setup(option); 502 vesafb_setup(option);
501 ret = driver_register(&vesafb_driver); 503 ret = platform_driver_register(&vesafb_driver);
502 504
503 if (!ret) { 505 if (!ret) {
504 ret = platform_device_register(&vesafb_device); 506 ret = platform_device_register(&vesafb_device);
505 if (ret) 507 if (ret)
506 driver_unregister(&vesafb_driver); 508 platform_driver_unregister(&vesafb_driver);
507 } 509 }
508 return ret; 510 return ret;
509} 511}
diff --git a/drivers/video/vfb.c b/drivers/video/vfb.c
index 8794dc5d2466..ffa1ad474226 100644
--- a/drivers/video/vfb.c
+++ b/drivers/video/vfb.c
@@ -403,9 +403,8 @@ static void vfb_platform_release(struct device *device)
403 // This is called when the reference count goes to zero. 403 // This is called when the reference count goes to zero.
404} 404}
405 405
406static int __init vfb_probe(struct device *device) 406static int __init vfb_probe(struct platform_device *dev)
407{ 407{
408 struct platform_device *dev = to_platform_device(device);
409 struct fb_info *info; 408 struct fb_info *info;
410 int retval = -ENOMEM; 409 int retval = -ENOMEM;
411 410
@@ -447,7 +446,7 @@ static int __init vfb_probe(struct device *device)
447 retval = register_framebuffer(info); 446 retval = register_framebuffer(info);
448 if (retval < 0) 447 if (retval < 0)
449 goto err2; 448 goto err2;
450 dev_set_drvdata(&dev->dev, info); 449 platform_set_drvdata(dev, info);
451 450
452 printk(KERN_INFO 451 printk(KERN_INFO
453 "fb%d: Virtual frame buffer device, using %ldK of video memory\n", 452 "fb%d: Virtual frame buffer device, using %ldK of video memory\n",
@@ -462,9 +461,9 @@ err:
462 return retval; 461 return retval;
463} 462}
464 463
465static int vfb_remove(struct device *device) 464static int vfb_remove(struct platform_device *dev)
466{ 465{
467 struct fb_info *info = dev_get_drvdata(device); 466 struct fb_info *info = platform_get_drvdata(dev);
468 467
469 if (info) { 468 if (info) {
470 unregister_framebuffer(info); 469 unregister_framebuffer(info);
@@ -474,11 +473,12 @@ static int vfb_remove(struct device *device)
474 return 0; 473 return 0;
475} 474}
476 475
477static struct device_driver vfb_driver = { 476static struct platform_driver vfb_driver = {
478 .name = "vfb",
479 .bus = &platform_bus_type,
480 .probe = vfb_probe, 477 .probe = vfb_probe,
481 .remove = vfb_remove, 478 .remove = vfb_remove,
479 .driver = {
480 .name = "vfb",
481 },
482}; 482};
483 483
484static struct platform_device vfb_device = { 484static struct platform_device vfb_device = {
@@ -504,12 +504,12 @@ static int __init vfb_init(void)
504 if (!vfb_enable) 504 if (!vfb_enable)
505 return -ENXIO; 505 return -ENXIO;
506 506
507 ret = driver_register(&vfb_driver); 507 ret = platform_driver_register(&vfb_driver);
508 508
509 if (!ret) { 509 if (!ret) {
510 ret = platform_device_register(&vfb_device); 510 ret = platform_device_register(&vfb_device);
511 if (ret) 511 if (ret)
512 driver_unregister(&vfb_driver); 512 platform_driver_unregister(&vfb_driver);
513 } 513 }
514 return ret; 514 return ret;
515} 515}
@@ -520,7 +520,7 @@ module_init(vfb_init);
520static void __exit vfb_exit(void) 520static void __exit vfb_exit(void)
521{ 521{
522 platform_device_unregister(&vfb_device); 522 platform_device_unregister(&vfb_device);
523 driver_unregister(&vfb_driver); 523 platform_driver_unregister(&vfb_driver);
524} 524}
525 525
526module_exit(vfb_exit); 526module_exit(vfb_exit);
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 48e70f153c4b..f6e24ee85f07 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -437,9 +437,9 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
437 } 437 }
438} 438}
439 439
440static int w100fb_suspend(struct device *dev, pm_message_t state) 440static int w100fb_suspend(struct platform_device *dev, pm_message_t state)
441{ 441{
442 struct fb_info *info = dev_get_drvdata(dev); 442 struct fb_info *info = platform_get_drvdata(dev);
443 struct w100fb_par *par=info->par; 443 struct w100fb_par *par=info->par;
444 struct w100_tg_info *tg = par->mach->tg; 444 struct w100_tg_info *tg = par->mach->tg;
445 445
@@ -452,9 +452,9 @@ static int w100fb_suspend(struct device *dev, pm_message_t state)
452 return 0; 452 return 0;
453} 453}
454 454
455static int w100fb_resume(struct device *dev) 455static int w100fb_resume(struct platform_device *dev)
456{ 456{
457 struct fb_info *info = dev_get_drvdata(dev); 457 struct fb_info *info = platform_get_drvdata(dev);
458 struct w100fb_par *par=info->par; 458 struct w100fb_par *par=info->par;
459 struct w100_tg_info *tg = par->mach->tg; 459 struct w100_tg_info *tg = par->mach->tg;
460 460
@@ -473,13 +473,12 @@ static int w100fb_resume(struct device *dev)
473#endif 473#endif
474 474
475 475
476int __init w100fb_probe(struct device *dev) 476int __init w100fb_probe(struct platform_device *pdev)
477{ 477{
478 int err = -EIO; 478 int err = -EIO;
479 struct w100fb_mach_info *inf; 479 struct w100fb_mach_info *inf;
480 struct fb_info *info = NULL; 480 struct fb_info *info = NULL;
481 struct w100fb_par *par; 481 struct w100fb_par *par;
482 struct platform_device *pdev = to_platform_device(dev);
483 struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 482 struct resource *mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
484 unsigned int chip_id; 483 unsigned int chip_id;
485 484
@@ -515,16 +514,16 @@ int __init w100fb_probe(struct device *dev)
515 if (remapped_fbuf == NULL) 514 if (remapped_fbuf == NULL)
516 goto out; 515 goto out;
517 516
518 info=framebuffer_alloc(sizeof(struct w100fb_par), dev); 517 info=framebuffer_alloc(sizeof(struct w100fb_par), &pdev->dev);
519 if (!info) { 518 if (!info) {
520 err = -ENOMEM; 519 err = -ENOMEM;
521 goto out; 520 goto out;
522 } 521 }
523 522
524 par = info->par; 523 par = info->par;
525 dev_set_drvdata(dev, info); 524 platform_set_drvdata(pdev, info);
526 525
527 inf = dev->platform_data; 526 inf = pdev->dev.platform_data;
528 par->chip_id = chip_id; 527 par->chip_id = chip_id;
529 par->mach = inf; 528 par->mach = inf;
530 par->fastpll_mode = 0; 529 par->fastpll_mode = 0;
@@ -600,10 +599,10 @@ int __init w100fb_probe(struct device *dev)
600 goto out; 599 goto out;
601 } 600 }
602 601
603 device_create_file(dev, &dev_attr_fastpllclk); 602 device_create_file(&pdev->dev, &dev_attr_fastpllclk);
604 device_create_file(dev, &dev_attr_reg_read); 603 device_create_file(&pdev->dev, &dev_attr_reg_read);
605 device_create_file(dev, &dev_attr_reg_write); 604 device_create_file(&pdev->dev, &dev_attr_reg_write);
606 device_create_file(dev, &dev_attr_flip); 605 device_create_file(&pdev->dev, &dev_attr_flip);
607 606
608 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); 607 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id);
609 return 0; 608 return 0;
@@ -622,15 +621,15 @@ out:
622} 621}
623 622
624 623
625static int w100fb_remove(struct device *dev) 624static int w100fb_remove(struct platform_device *pdev)
626{ 625{
627 struct fb_info *info = dev_get_drvdata(dev); 626 struct fb_info *info = platform_get_drvdata(pdev);
628 struct w100fb_par *par=info->par; 627 struct w100fb_par *par=info->par;
629 628
630 device_remove_file(dev, &dev_attr_fastpllclk); 629 device_remove_file(&pdev->dev, &dev_attr_fastpllclk);
631 device_remove_file(dev, &dev_attr_reg_read); 630 device_remove_file(&pdev->dev, &dev_attr_reg_read);
632 device_remove_file(dev, &dev_attr_reg_write); 631 device_remove_file(&pdev->dev, &dev_attr_reg_write);
633 device_remove_file(dev, &dev_attr_flip); 632 device_remove_file(&pdev->dev, &dev_attr_flip);
634 633
635 unregister_framebuffer(info); 634 unregister_framebuffer(info);
636 635
@@ -1448,23 +1447,24 @@ static void w100_vsync(void)
1448 writel(0x00000002, remapped_regs + mmGEN_INT_STATUS); 1447 writel(0x00000002, remapped_regs + mmGEN_INT_STATUS);
1449} 1448}
1450 1449
1451static struct device_driver w100fb_driver = { 1450static struct platform_driver w100fb_driver = {
1452 .name = "w100fb",
1453 .bus = &platform_bus_type,
1454 .probe = w100fb_probe, 1451 .probe = w100fb_probe,
1455 .remove = w100fb_remove, 1452 .remove = w100fb_remove,
1456 .suspend = w100fb_suspend, 1453 .suspend = w100fb_suspend,
1457 .resume = w100fb_resume, 1454 .resume = w100fb_resume,
1455 .driver = {
1456 .name = "w100fb",
1457 },
1458}; 1458};
1459 1459
1460int __devinit w100fb_init(void) 1460int __devinit w100fb_init(void)
1461{ 1461{
1462 return driver_register(&w100fb_driver); 1462 return platform_driver_register(&w100fb_driver);
1463} 1463}
1464 1464
1465void __exit w100fb_cleanup(void) 1465void __exit w100fb_cleanup(void)
1466{ 1466{
1467 driver_unregister(&w100fb_driver); 1467 platform_driver_unregister(&w100fb_driver);
1468} 1468}
1469 1469
1470module_init(w100fb_init); 1470module_init(w100fb_init);